diff --git a/etc/timer/parser.cpp b/etc/timer/parser.cpp index 752d44db3..c10bfc95a 100644 --- a/etc/timer/parser.cpp +++ b/etc/timer/parser.cpp @@ -9,21 +9,21 @@ using namespace std; namespace fs = filesystem; #define DEBUG -#define IND (string)"\t" +#define IND (string) "\t" #define functionDefinition "__FUNCTION_DEFINITION__ " #define typeDefinition "__TYPE_DEFINITION__ " #define timeElapsed "__TIME_ELAPSED__ " #define parameterDefinition "__PARAMETER_DEFINITION__ " -void findFlagAndExtract (const string &line, vector *out); -bool processLog(const string &filePathm, vector *output); -void addLogToHtml(vector *input, ofstream &htmlFile); -void addTimeDiv (ofstream &file, vector::iterator it, int indent); -string getFlag (const string &line); +void findFlagAndExtract(const string &line, vector< string > *out); +bool processLog(const string &filePathm, vector< string > *output); +void addLogToHtml(vector< string > *input, ofstream &htmlFile); +void addTimeDiv(ofstream &file, vector< string >::iterator it, int indent); +string getFlag(const string &line); string getValue(const string &line); -string getClass (const string &line); -string getInd (int n); +string getClass(const string &line); +string getInd(int n); /*! * \brief Main function @@ -31,7 +31,7 @@ string getInd (int n); * \param argv Argument(s) value(s) * \return Success / Failure */ -int main (int argc, char *argv[]) { +int main(int argc, char *argv[]) { // Parameters string unitDirectory = "../FreeFem-sources/unit/"; string flagValOutputFile = "flagVal"; @@ -41,8 +41,7 @@ int main (int argc, char *argv[]) { unitDirectory = argv[1]; flagValOutputFile = argv[2]; htmlOutputFile = argv[3]; - } - else if (argc != 1) { + } else if (argc != 1) { cout << "Correct use : ./parser.exe [unitdirectory] [flagvaloutputfile] [htmlfile]" << endl; return EXIT_FAILURE; } @@ -52,35 +51,31 @@ int main (int argc, char *argv[]) { ofstream htmlFile(htmlOutputFile); // Retrieve and process all .log files - for(auto &logdir : fs::directory_iterator(unitDirectory)) { - if (!logdir.is_directory()) - continue; + for (auto &logdir : fs::directory_iterator(unitDirectory)) { + if (!logdir.is_directory( )) continue; - for(auto &log : fs::directory_iterator(logdir.path())) { - if (log.path().extension() != ".log") - continue; + for (auto &log : fs::directory_iterator(logdir.path( ))) { + if (log.path( ).extension( ) != ".log") continue; - #ifdef DEBUG - cout << endl << log.path().filename().string() << endl; - #endif +#ifdef DEBUG + cout << endl << log.path( ).filename( ).string( ) << endl; +#endif // find the flags and their associated values - vector output; - if (!processLog(log.path().string(), &output)) - return EXIT_FAILURE; + vector< string > output; + if (!processLog(log.path( ).string( ), &output)) return EXIT_FAILURE; // add flags and their associated values to flagVal file - for (vector::iterator it = output.begin(); it != output.end(); ++it) - flagValFile << *it << endl; + for (vector< string >::iterator it = output.begin( ); it != output.end( ); ++it) flagValFile << *it << endl; // add formated flag and value to html file addLogToHtml(&output, htmlFile); } } - flagValFile.close(); - htmlFile.close(); - return EXIT_SUCCESS; + flagValFile.close( ); + htmlFile.close( ); + return EXIT_SUCCESS; } /*! @@ -89,15 +84,13 @@ int main (int argc, char *argv[]) { * \param type Type * \param out Out */ -void findFlagAndExtract (const string &line, vector *output) { - if (!line.length()) - return; - size_t pos = line.find(functionDefinition); +void findFlagAndExtract(const string &line, vector< string > *output) { + if (!line.length( )) return; + size_t pos = line.find(functionDefinition); if (pos == string::npos) pos = line.find(typeDefinition); if (pos == string::npos) pos = line.find(timeElapsed); if (pos == string::npos) pos = line.find(parameterDefinition); - if (line[0] == '_' && pos != string::npos) - output->push_back(line); + if (line[0] == '_' && pos != string::npos) output->push_back(line); } /*! @@ -106,135 +99,123 @@ void findFlagAndExtract (const string &line, vector *output) { * \param output String vector containing flag anv their associated values * \return Successfully processed or not */ -bool processLog(const string &filePath, vector *output) { - vector fileContent; - ifstream file(filePath, ios::in); // open file, read only mode - if (file) { - string temp; - while (getline(file, temp)) // read all lines, keep ones containing flags +bool processLog(const string &filePath, vector< string > *output) { + vector< string > fileContent; + ifstream file(filePath, ios::in); // open file, read only mode + if (file) { + string temp; + while (getline(file, temp)) // read all lines, keep ones containing flags findFlagAndExtract(temp, output); - } else { // return error - cerr << "Unable to open " << filePath << endl; + } else { // return error + cerr << "Unable to open " << filePath << endl; return false; - } - file.close(); + } + file.close( ); - #ifdef DEBUG - cout << output->size() << (output->size() < 2 ? " flag" : " flags") << " found" << endl; - // Display vector content - for (vector::iterator it = output->begin(); it != output->end(); ++it) - cout << *it << endl; - #endif +#ifdef DEBUG + cout << output->size( ) << (output->size( ) < 2 ? " flag" : " flags") << " found" << endl; + // Display vector content + for (vector< string >::iterator it = output->begin( ); it != output->end( ); ++it) cout << *it << endl; +#endif return true; } /*! - * \brief Add formated log content to html file - * \param input Log formatted content - * \param htmlFile HTML output file - */ -void addLogToHtml(vector *input, ofstream &htmlFile) { - if (!htmlFile || !input->size()) - return; + * \brief Add formated log content to html file + * \param input Log formatted content + * \param htmlFile HTML output file + */ +void addLogToHtml(vector< string > *input, ofstream &htmlFile) { + if (!htmlFile || !input->size( )) return; - vector::iterator it = input->begin(); + vector< string >::iterator it = input->begin( ); - if (input->size() == 1) { + if (input->size( ) == 1) { htmlFile << "
" << endl; htmlFile << getInd(1) << "

" << getValue(*it) << "

" << endl; htmlFile << "
" << endl; return; } - while((it != input->end()) && (getFlag(*it) == functionDefinition)) { + while ((it != input->end( )) && (getFlag(*it) == functionDefinition)) { htmlFile << "
" << endl; htmlFile << getInd(1) << "

" << getValue(*it) << "

" << endl; it++; - flagsleft: { - if ((getFlag(*it) != typeDefinition) && (getFlag(*it) != parameterDefinition)) - goto timeonly; + flagsleft: { + if ((getFlag(*it) != typeDefinition) && (getFlag(*it) != parameterDefinition)) goto timeonly; - while ((it != input->end()) && ((getFlag(*it) == typeDefinition) || (getFlag(*it) == parameterDefinition))) { - htmlFile << getInd(1) << "
" << endl; - htmlFile << getInd(2) << "

" << getValue(*it) << "

" << endl; + while ((it != input->end( )) && ((getFlag(*it) == typeDefinition) || (getFlag(*it) == parameterDefinition))) { + htmlFile << getInd(1) << "
" << endl; + htmlFile << getInd(2) << "

" << getValue(*it) << "

" << endl; + it++; + while ((it < input->end( )) && (getFlag(*it) == timeElapsed)) { + addTimeDiv(htmlFile, it, 2); it++; - while ((it < input->end()) && (getFlag(*it) == timeElapsed)) { - addTimeDiv(htmlFile, it, 2); - it++; - } - htmlFile << getInd(1) << "
" << endl; } + htmlFile << getInd(1) << "
" << endl; + } - timeonly: while ((it != input->end()) && (getFlag(*it) == timeElapsed)) { - addTimeDiv(htmlFile, it, 1); - it++; - } + timeonly: + while ((it != input->end( )) && (getFlag(*it) == timeElapsed)) { + addTimeDiv(htmlFile, it, 1); + it++; } + } - if ((it != input->end()) && (getFlag(*it) != functionDefinition)) - goto flagsleft; + if ((it != input->end( )) && (getFlag(*it) != functionDefinition)) goto flagsleft; htmlFile << "
" << endl; } } /*! - * \brief Add div element containing time elapsed to html file - * \param it String iterator - * \param indent Div indentation - */ -void addTimeDiv (ofstream &htmlFile, vector::iterator it, int indent) { + * \brief Add div element containing time elapsed to html file + * \param it String iterator + * \param indent Div indentation + */ +void addTimeDiv(ofstream &htmlFile, vector< string >::iterator it, int indent) { htmlFile << getInd(indent) << "
" << endl; htmlFile << getInd(indent + 1) << "

" << getValue(*it) << "

" << endl; - htmlFile << getInd(indent) <<"
" << endl; + htmlFile << getInd(indent) << "" << endl; } /*! - * \brief Extract flag on a line - * \param line Line to process - * \return Flag on line - */ -string getFlag (const string &line) { - return line.substr(0, line.find(" ") + 1); -} + * \brief Extract flag on a line + * \param line Line to process + * \return Flag on line + */ +string getFlag(const string &line) { return line.substr(0, line.find(" ") + 1); } /*! - * \brief Extract value after a flag - * \param line Line containing a flag - * \return Value on line - */ -string getValue (const string &line) { - return line.substr(line.find(" ") + 1); -} + * \brief Extract value after a flag + * \param line Line containing a flag + * \return Value on line + */ +string getValue(const string &line) { return line.substr(line.find(" ") + 1); } /*! - * \brief Returns class for html format - * \param line Line containing the flag - * \return Html class - */ -string getClass (const string &line) { + * \brief Returns class for html format + * \param line Line containing the flag + * \return Html class + */ +string getClass(const string &line) { string flag = getFlag(line); - if (flag == timeElapsed) - return "time"; - if (flag == typeDefinition) - return "type"; - if (flag == parameterDefinition) - return "parameter"; - if (flag == functionDefinition) - return "function"; + if (flag == timeElapsed) return "time"; + if (flag == typeDefinition) return "type"; + if (flag == parameterDefinition) return "parameter"; + if (flag == functionDefinition) return "function"; return ""; } /*! - * \brief Returns a specific number of indentations - * \param n Number of indentations - * \return Indentations - */ -string getInd (int n) { + * \brief Returns a specific number of indentations + * \param n Number of indentations + * \return Indentations + */ +string getInd(int n) { string out = ""; - for (int i = 0; i < n; i++) - out += IND; + for (int i = 0; i < n; i++) out += IND; return out; } diff --git a/etc/tools/md2edp.cpp b/etc/tools/md2edp.cpp index 1ff8d96e6..e1ef1753a 100644 --- a/etc/tools/md2edp.cpp +++ b/etc/tools/md2edp.cpp @@ -2,52 +2,51 @@ #include #include using namespace std; -int md2edp(const char *fname) -{ - // cout << fname << endl; - int ok=0; - string fn = fname; - string ofn = fn; - size_t lm=ofn.rfind(".md"),lofn=ofn.size(); - if ( lofn-lm == 3) - ofn.replace(ofn.end()-3,ofn.end(), ".edp"); - cout << " md2edp " << fn << " -> " << ofn << endl; - - ifstream fin(fn.c_str()); - ofstream *fout=0; - - // - long cas = 1; - if( fin ) - { - - while (!fin.eof()) - { - string ln ; - getline(fin,ln); - if( (ln.find("~~~freefem")==0) || (ln.find("```freefem")==0)) cas++; - else if ((cas%2 == 0 ) && ( (ln.find("~~~")==0 )|| (ln.find("```")==0))) cas++; - else if( cas%2==0) { - if(!fout) { fout = new ofstream(ofn.c_str()); - if(!fout) break; - *fout << "// created with md2edp " << fn << endl; - } - *fout << ln << endl;} +int md2edp(const char *fname) { + // cout << fname << endl; + int ok = 0; + string fn = fname; + string ofn = fn; + size_t lm = ofn.rfind(".md"), lofn = ofn.size( ); + if (lofn - lm == 3) ofn.replace(ofn.end( ) - 3, ofn.end( ), ".edp"); + cout << " md2edp " << fn << " -> " << ofn << endl; - // cout << cas << " ..." << ln << endl; - + ifstream fin(fn.c_str( )); + ofstream *fout = 0; + + // + long cas = 1; + if (fin) { + + while (!fin.eof( )) { + string ln; + getline(fin, ln); + if ((ln.find("~~~freefem") == 0) || (ln.find("```freefem") == 0)) + cas++; + else if ((cas % 2 == 0) && ((ln.find("~~~") == 0) || (ln.find("```") == 0))) + cas++; + else if (cas % 2 == 0) { + if (!fout) { + fout = new ofstream(ofn.c_str( )); + if (!fout) break; + *fout << "// created with md2edp " << fn << endl; } - } else { - ok=1;cout << " error of file (skip) "<< fname << endl; + *fout << ln << endl; + } + + // cout << cas << " ..." << ln << endl; } - if( !fout) cout << " skip "<< fname << " no freefem code " << endl; - if(fout) delete fout; - return ok; + } else { + ok = 1; + cout << " error of file (skip) " << fname << endl; + } + if (!fout) cout << " skip " << fname << " no freefem code " << endl; + if (fout) delete fout; + return ok; } -int main(int argc,const char ** argv) -{ - int ok =0; - for(size_t i=1; i< argc;i++) - if(md2edp(argv[i])) ok =1; - return ok; +int main(int argc, const char **argv) { + int ok = 0; + for (size_t i = 1; i < argc; i++) + if (md2edp(argv[i])) ok = 1; + return ok; } diff --git a/plugin/mpi/MPICG.cpp b/plugin/mpi/MPICG.cpp index a4135565a..20088a90c 100644 --- a/plugin/mpi/MPICG.cpp +++ b/plugin/mpi/MPICG.cpp @@ -1,501 +1,438 @@ // ORIG-DATE: 02/2009 // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE +// SUMMARY : +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE // AUTHOR : Jacques Morice // E-MAIL : jacques.morice@ann.jussieu.fr // +/* clang-format off */ //ff-c++-LIBRARY-dep: mpi -//ff-c++-cpp-dep: +//ff-c++-cpp-dep: +/* clang-format on */ -/* +/* This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Thank to the ARN () FF2A3 grant - ref:ANR-07-CIS7-002-01 + ref:ANR-07-CIS7-002-01 */ - #include "mpi.h" -#include +#include using namespace std; #include "ff++.hpp" #include "CGNL.hpp" -//#include "gmres.hpp" - - -template -int NLCG(const DJ & dJ,const P & C,KN_ &x,const int nbitermax, double &eps,long kprint,MPI_Comm * ) -{ - // ------------- - typedef KN Rn; - int n=x.N(); - - R ro=1; - Rn g(n),h(n),Ah(n), & Cg(Ah); // on utilise Ah pour stocke Cg - g=dJ*x;// dJ(x,g); - Cg = C*g; // gradient preconditionne - h =-Cg; - R g2 = (Cg,g); - if (g2 < 1e-30) - { if(kprint>1) - cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; - return 2; } - if (kprint>5 ) - cout << " 0 GCNL g^2 =" << g2 << endl; - R reps2 =eps >0 ? eps*eps*g2 : -eps; // epsilon relatif - eps = reps2; - for (int iter=0;iter<=nbitermax;iter++) - { - ro = argmin(ro,dJ,x,h,g,Ah); - - Cg = C*g; - R g2p=g2; - g2 = (Cg,g); - if ( kprint < nbitermax ) - cout << "CGNL:" < +int NLCG(const DJ &dJ, const P &C, KN_< R > &x, const int nbitermax, double &eps, long kprint, MPI_Comm *) { + // ------------- + typedef KN< R > Rn; + int n = x.N( ); + + R ro = 1; + Rn g(n), h(n), Ah(n), &Cg(Ah); // on utilise Ah pour stocke Cg + g = dJ * x; // dJ(x,g); + Cg = C * g; // gradient preconditionne + h = -Cg; + R g2 = (Cg, g); + if (g2 < 1e-30) { + if (kprint > 1) cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; + return 2; + } + if (kprint > 5) cout << " 0 GCNL g^2 =" << g2 << endl; + R reps2 = eps > 0 ? eps * eps * g2 : -eps; // epsilon relatif + eps = reps2; + for (int iter = 0; iter <= nbitermax; iter++) { + ro = argmin(ro, dJ, x, h, g, Ah); + + Cg = C * g; + R g2p = g2; + g2 = (Cg, g); + if (kprint < nbitermax) cout << "CGNL:" << iter << ", ro = " << ro << " ||g||^2 = " << g2 << endl; + if (g2 < reps2) { + if (kprint < nbitermax) cout << "CGNL converge: " << iter << ", ro = " << ro << " ||g||^2 = " << g2 << endl; + return 1; // ok + } + R gamma = g2 / g2p; + h *= gamma; + h -= Cg; // h = -Cg * gamma* h + } + if (verbosity) cout << " Non convergence of the NL cojugate gradient " << endl; + return 0; } -template struct MPI_TYPE {}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_LONG;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_INT;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}}; - -template -R ReduceSum1(R s,MPI_Comm * comm) -{ - R r=0; +template< class T > +struct MPI_TYPE {}; +template<> +struct MPI_TYPE< long > { + static MPI_Datatype TYPE( ) { return MPI_LONG; } +}; +template<> +struct MPI_TYPE< int > { + static MPI_Datatype TYPE( ) { return MPI_INT; } +}; +template<> +struct MPI_TYPE< double > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE; } +}; +template<> +struct MPI_TYPE< char > { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; + +template< class R > +R ReduceSum1(R s, MPI_Comm *comm) { + R r = 0; // nt MPI_Allreduce( void *sendbuf, void *recbuf, int count, // MPI_Datatype datatype, MPI_Op op, MPI_Comm comm ) - MPI_Allreduce( &s, &r, 1 ,MPI_TYPE::TYPE(), MPI_SUM, *comm ); - return r; + MPI_Allreduce(&s, &r, 1, MPI_TYPE< R >::TYPE( ), MPI_SUM, *comm); + return r; } -template -int ConjuguedGradient2(const M & A,const P & C,KN_ &x,const KN_ &b,const int nbitermax, double &eps,long kprint,MPI_Comm * commworld) -{ - // ConjuguedGradient2 affine A*x = 0 est toujours appele avec les condition aux limites - // ------------- - typedef KN Rn; - int n=x.N(); - // if (verbosity>99) kprint=1; - R ro=1; - Rn g(n),h(n),Ah(n), & Cg(Ah); // on utilise Ah pour stocke Cg - g = A*x; - g -= b; - Cg = C*g; // gradient preconditionne - h =-Cg; - R g2 = ReduceSum1((Cg,g),commworld); - if (g2 < 1e-30) - { if(kprint<=nbitermax) - cout << "GC g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; - return 2; } - if (kprint<5 ) - cout << " 0 GC g^2 =" << g2 << endl; - R reps2 =eps >0 ? eps*eps*g2 : -eps; // epsilon relatif - eps = reps2; - for (int iter=0;iter<=nbitermax;iter++) - { - R rop = ro; - x += rop*h; // x+ rop*h , g=Ax (x old) - // ((Ah = A*x - b) - g); - // Ah -= b; // Ax + rop*Ah = rop*Ah + g = - // Ah -= g; // Ah*rop - Ah = A*x; - Ah -= b; // Ax + rop*Ah = rop*Ah + g = - Ah -= g; // Ah*rop - - R hAh =ReduceSum1((h,Ah),commworld); - R gh = ReduceSum1((g,h),commworld); - if (std::norm(hAh)<1e-100) ExecError("CG2: Matrix is not defined (/0), sorry "); - ro = -gh*rop/hAh ; // ro optimal (produit scalaire usuel) - x += (ro-rop) *h; - g += (ro/rop) *Ah; // plus besoin de Ah, on utilise avec Cg optimisation - Cg = C*g; - R g2p=g2; - g2 = ReduceSum1((Cg,g),commworld); - if ( ( (iter%kprint) == kprint-1) ) - cout << "CG:" <5 || (verbosity>2 && j%100==0) ) - cout << "GMRES: " << j << " " << abs(s(i+1)) << " " << normb << " " - << abs(s(i+1)) / normb << " < " << tol << endl; - - if ((resid = abs(s(i+1)) / normb) < tol) { - if(verbosity) - cout << "GMRES converges: " << j << " " << abs(s(i+1)) << " " << normb << " " - << abs(s(i+1)) / normb << " < " << tol << endl; - - Update(x, i, H, s, v); - tol = resid; - max_iter = j; - delete [] v; - return 0; - } - } - if(!(j <= max_iter)) break; - Update(x, i-1 , H, s, v); - Ax = A*x; - Ax = b-Ax; - - r = M*(Ax); - beta = sqrt(ReduceSum1((r,r),commworld)); - if(verbosity>4) - cout << "GMRES: restart" << j << " " << beta << " " << normb << " " - << beta / normb << " < " << tol << endl; - if ((resid = beta / normb) < tol) { - tol = resid; - max_iter = j; - delete [] v; - return 0; - } + if (!(j <= max_iter)) break; + Update(x, i - 1, H, s, v); + Ax = A * x; + Ax = b - Ax; + + r = M * (Ax); + beta = sqrt(ReduceSum1((r, r), commworld)); + if (verbosity > 4) cout << "GMRES: restart" << j << " " << beta << " " << normb << " " << beta / normb << " < " << tol << endl; + if ((resid = beta / normb) < tol) { + tol = resid; + max_iter = j; + delete[] v; + return 0; } - - if(verbosity) - cout << "WARNING: GMRES do not converges: " << j <<"/" << max_iter << ", resid = " << resid - << ", tol= " << tol << ", normb "<< normb << endl; - tol = resid; - delete [] v; - - return 1; + } + + if (verbosity) cout << "WARNING: GMRES do not converges: " << j << "/" << max_iter << ", resid = " << resid << ", tol= " << tol << ", normb " << normb << endl; + tol = resid; + delete[] v; + + return 1; } +template< class R > +class MPILinearCG : public OneOperator { + public: + typedef KN< R > Kn; + typedef KN_< R > Kn_; + const int cas, CG; -template -class MPILinearCG : public OneOperator -{ -public: - typedef KN Kn; - typedef KN_ Kn_; - const int cas,CG; - - class MatF_O: RNM_VirtualMatrix { public: - Stack stack; - mutable Kn x; - C_F0 c_x; - Kn *b; - - Expression mat1,mat; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - MatF_O(int n,Stack stk,const OneOperator * op,Kn *bb=0) - : RNM_VirtualMatrix(n),stack(stk), - x(n),c_x(CPValue(x)),b(bb), - mat1(op->code(basicAC_F0_wa(c_x))), - mat( CastTo(C_F0(mat1,(aType)*op))) { - //ffassert(atype() ==(aType) *op); - // WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 - - } - ~MatF_O() { - // cout << " del MatF_O mat " << endl; - if(mat1 != mat) - delete mat; - delete mat1; - // cout << " del MatF_Ocx ..." << endl; - Expression zzz = c_x; - // cout << " zzz "<< zzz << endl; - delete zzz; - // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 - - } - void addMatMul(const KN_ & xx, KN_ & Ax) const - //void addMatMul(const Kn_ & xx, Kn_ & Ax) const - { - ffassert(xx.N()==Ax.N()); - x =xx; - Ax += GetAny((*mat)(stack)); - if(b && &Ax!=b) Ax += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b - WhereStackOfPtr2Free(stack)->clean(); - } - plusAx operator*(const Kn & x) const {return plusAx(this,x);} - bool ChecknbLine(int n) const { return true;} - bool ChecknbColumn(int m) const { return true;} - - }; - - - class E_LCG: public E_F0mps { public: - const int cas;// <0 => Nolinear - const int CG; - static const int n_name_param=7; - - static basicAC_F0::name_and_type name_param[] ; - - - Expression nargs[n_name_param]; - - const OneOperator *A, *C; - Expression X,B; - - E_LCG(const basicAC_F0 & args,int cc,int gc) :cas(cc),CG(gc) - { - args.SetNameParam(n_name_param,name_param,nargs); - { const Polymorphic * op= dynamic_cast(args[0].LeftValue()); - ffassert(op); - A = op->Find("(",ArrayOfaType(atype(),false)); } - if (nargs[2]) - { const Polymorphic * op= dynamic_cast(nargs[2]); - ffassert(op); - C = op->Find("(",ArrayOfaType(atype(),false)); } - else C =0; - X = to(args[1]); - if (args.size()>2) - B = to(args[2]); - else - B=0; - } - - virtual AnyType operator()(Stack stack) const { - int ret=-1; - - // WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 - try { - Kn &x = *GetAny((*X)(stack)); - int n=x.N(); - double eps = 1.0e-6; - int nbitermax= 100; - long verb = verbosity; - - pcommworld vcommworld=0; - long dKrylov=50; - if (nargs[0]) eps= GetAny((*nargs[0])(stack)); - if (nargs[1]) nbitermax = GetAny((*nargs[1])(stack)); - if (nargs[3]) eps= *GetAny((*nargs[3])(stack)); - if (nargs[4]) vcommworld = GetAny((*nargs[4])(stack)); - if (nargs[5]) dKrylov= GetAny((*nargs[5])(stack)); - if (nargs[6]) verb=Abs(GetAny((*nargs[6])(stack))); - long gcverb=51L-Min(Abs(verb),50L); - if(verb==0) gcverb = 1000000000;// no print - - MPI_Comm mpiCommWorld = MPI_COMM_WORLD; - MPI_Comm * commworld= vcommworld ? (MPI_Comm *) vcommworld: & mpiCommWorld ; - KN bzero(B?1:n); // const array zero - bzero=R(); - KN *bb=&bzero; - if (B) { - Kn &b = *GetAny((*B)(stack)); - R p = (b,b); - if (p) - { - // ExecError("Sorry MPILinearCG work only with nul right hand side, so put the right hand in the function"); - } - bb = &b; - } - KN * bbgmres =0; - if ( !B && !CG) bbgmres=bb; // none zero if gmres without B - MatF_O AA(n,stack,A,bbgmres); - if(bbgmres ){ - AA.addMatMul(*bbgmres,*bbgmres); // *bbgmres= AA* *bbgmres; // Ok Ax == b -> not translation of b . - *bbgmres = - *bbgmres; - if(verbosity>1) cout << " ** GMRES set b = -A(0); : max=" << bbgmres->max() << " " << bbgmres->min()<(n),x,nbitermax,eps, gcverb ,commworld); - } - else - if (C) - { MatF_O CC(n,stack,C); - ret = ConjuguedGradient2(AA,CC,x,*bb,nbitermax,eps, gcverb ,commworld);} - else - ret = ConjuguedGradient2(AA,MatriceIdentite(n),x,*bb,nbitermax,eps, gcverb ,commworld); - } - else {// GMRES - - KNM H(dKrylov+1,dKrylov+1); - int k=dKrylov;//,nn=n; - if (cas<0) { - ErrorExec("NL GMRES: to do! sorry ",1); - /* if (C) - { MatF_O CC(n,stack,C); - ret = NLGMRES(AA,CC,x,nbitermax,eps, 51L-Min(Abs(verbosity),50L) );} - else - ret = NLGMRES(AA,MatriceIdentite(n),x,nbitermax,eps, 51L-Min(Abs(verbosity),50L)); - ConjuguedGradient */ - } - else - { - if (C) - { MatF_O CC(n,stack,C); - ret=GMRES_MPI(AA,(KN &)x, *bb,CC,H,k,nbitermax,eps,commworld,verb);} - else - ret=GMRES_MPI(AA,(KN &)x, *bb,MatriceIdentite(n),H,k,nbitermax,eps,commworld,verb); - } - - } - - - - if( nargs[3]) *GetAny((*nargs[3])(stack)) = -(eps); - } - catch(...) - { - // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 - throw; - } - // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 - - return SetAny(ret); - - } - operator aType () const { return atype();} - - }; - - E_F0 * code(const basicAC_F0 & args) const { - return new E_LCG(args,cas,CG);} - - MPILinearCG() : OneOperator(atype(), - atype(), - atype *>(),atype *>()),cas(2),CG(1){} - - MPILinearCG(int cc,int CGG) : OneOperator(atype(), - atype(), - atype *>(),atype *>()),cas(cc),CG(CGG){} - - MPILinearCG(int cc,int CGG,int ) : OneOperator(atype(), - atype(), - atype *>()),cas(cc),CG(CGG){} - - MPILinearCG(int cc) : OneOperator(atype(), - atype(), - atype *>()),cas(cc),CG(1){} - -}; + class MatF_O : RNM_VirtualMatrix< R > { + public: + Stack stack; + mutable Kn x; + C_F0 c_x; + Kn *b; + Expression mat1, mat; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + MatF_O(int n, Stack stk, const OneOperator *op, Kn *bb = 0) + : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), b(bb), mat1(op->code(basicAC_F0_wa(c_x))), mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op))) { + // ffassert(atype() ==(aType) *op); + // WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 + } + ~MatF_O( ) { + // cout << " del MatF_O mat " << endl; + if (mat1 != mat) delete mat; + delete mat1; + // cout << " del MatF_Ocx ..." << endl; + Expression zzz = c_x; + // cout << " zzz "<< zzz << endl; + delete zzz; + // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 + } + void addMatMul(const KN_< R > &xx, KN_< R > &Ax) const + // void addMatMul(const Kn_ & xx, Kn_ & Ax) const + { + ffassert(xx.N( ) == Ax.N( )); + x = xx; + Ax += GetAny< Kn_ >((*mat)(stack)); + if (b && &Ax != b) Ax += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b + WhereStackOfPtr2Free(stack)->clean( ); + } + plusAx operator*(const Kn &x) const { return plusAx(this, x); } + bool ChecknbLine(int n) const { return true; } + bool ChecknbColumn(int m) const { return true; } + }; + class E_LCG : public E_F0mps { + public: + const int cas; // <0 => Nolinear + const int CG; + static const int n_name_param = 7; + static basicAC_F0::name_and_type name_param[]; -template -basicAC_F0::name_and_type MPILinearCG::E_LCG::name_param[]= { - { "eps", &typeid(double) }, - { "nbiter",&typeid(long) }, - { "precon",&typeid(Polymorphic*)}, - { "veps" , &typeid(double*) }, - { "comm", &typeid(pcommworld)} , - { "dimKrylov", &typeid(long) }, - { "verbosity", &typeid(long) } -}; + Expression nargs[n_name_param]; + + const OneOperator *A, *C; + Expression X, B; + + E_LCG(const basicAC_F0 &args, int cc, int gc) : cas(cc), CG(gc) { + args.SetNameParam(n_name_param, name_param, nargs); + { + const Polymorphic *op = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )); + ffassert(op); + A = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); + } + if (nargs[2]) { + const Polymorphic *op = dynamic_cast< const Polymorphic * >(nargs[2]); + ffassert(op); + C = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); + } else + C = 0; + X = to< Kn * >(args[1]); + if (args.size( ) > 2) + B = to< Kn * >(args[2]); + else + B = 0; + } + + virtual AnyType operator( )(Stack stack) const { + int ret = -1; + + // WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 + try { + Kn &x = *GetAny< Kn * >((*X)(stack)); + int n = x.N( ); + double eps = 1.0e-6; + int nbitermax = 100; + long verb = verbosity; + pcommworld vcommworld = 0; + long dKrylov = 50; + if (nargs[0]) eps = GetAny< double >((*nargs[0])(stack)); + if (nargs[1]) nbitermax = GetAny< long >((*nargs[1])(stack)); + if (nargs[3]) eps = *GetAny< double * >((*nargs[3])(stack)); + if (nargs[4]) vcommworld = GetAny< pcommworld >((*nargs[4])(stack)); + if (nargs[5]) dKrylov = GetAny< long >((*nargs[5])(stack)); + if (nargs[6]) verb = Abs(GetAny< long >((*nargs[6])(stack))); + long gcverb = 51L - Min(Abs(verb), 50L); + if (verb == 0) gcverb = 1000000000; // no print + MPI_Comm mpiCommWorld = MPI_COMM_WORLD; + MPI_Comm *commworld = vcommworld ? (MPI_Comm *)vcommworld : &mpiCommWorld; + KN< R > bzero(B ? 1 : n); // const array zero + bzero = R( ); + KN< R > *bb = &bzero; + if (B) { + Kn &b = *GetAny< Kn * >((*B)(stack)); + R p = (b, b); + if (p) { + // ExecError("Sorry MPILinearCG work only with nul right hand side, so put the right hand in the function"); + } + bb = &b; + } + KN< R > *bbgmres = 0; + if (!B && !CG) bbgmres = bb; // none zero if gmres without B + MatF_O AA(n, stack, A, bbgmres); + if (bbgmres) { + AA.addMatMul(*bbgmres, *bbgmres); // *bbgmres= AA* *bbgmres; // Ok Ax == b -> not translation of b . + *bbgmres = -*bbgmres; + if (verbosity > 1) cout << " ** GMRES set b = -A(0); : max=" << bbgmres->max( ) << " " << bbgmres->min( ) << endl; + } + + if (CG) { + + if (cas < 0) { + if (C) { + MatF_O CC(n, stack, C); + ret = NLCG(AA, CC, x, nbitermax, eps, gcverb, commworld); + } else + ret = NLCG(AA, MatriceIdentite< R >(n), x, nbitermax, eps, gcverb, commworld); + } else if (C) { + MatF_O CC(n, stack, C); + ret = ConjuguedGradient2(AA, CC, x, *bb, nbitermax, eps, gcverb, commworld); + } else + ret = ConjuguedGradient2(AA, MatriceIdentite< R >(n), x, *bb, nbitermax, eps, gcverb, commworld); + } else { // GMRES + + KNM< R > H(dKrylov + 1, dKrylov + 1); + int k = dKrylov; //,nn=n; + if (cas < 0) { + ErrorExec("NL GMRES: to do! sorry ", 1); + /* if (C) + { MatF_O CC(n,stack,C); + ret = NLGMRES(AA,CC,x,nbitermax,eps, 51L-Min(Abs(verbosity),50L) );} + else + ret = NLGMRES(AA,MatriceIdentite(n),x,nbitermax,eps, 51L-Min(Abs(verbosity),50L)); + ConjuguedGradient */ + } else { + if (C) { + MatF_O CC(n, stack, C); + ret = GMRES_MPI(AA, (KN< R > &)x, *bb, CC, H, k, nbitermax, eps, commworld, verb); + } else + ret = GMRES_MPI(AA, (KN< R > &)x, *bb, MatriceIdentite< R >(n), H, k, nbitermax, eps, commworld, verb); + } + } + + if (nargs[3]) *GetAny< double * >((*nargs[3])(stack)) = -(eps); + } catch (...) { + // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 + throw; + } + // WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 + return SetAny< long >(ret); + } + operator aType( ) const { return atype< long >( ); } + }; + E_F0 *code(const basicAC_F0 &args) const { return new E_LCG(args, cas, CG); } + + MPILinearCG( ) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), cas(2), CG(1) {} + + MPILinearCG(int cc, int CGG) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), cas(cc), CG(CGG) {} + + MPILinearCG(int cc, int CGG, int) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc), CG(CGG) {} + + MPILinearCG(int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc), CG(1) {} +}; + +template< class R > +basicAC_F0::name_and_type MPILinearCG< R >::E_LCG::name_param[] = {{"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, {"veps", &typeid(double *)}, + {"comm", &typeid(pcommworld)}, {"dimKrylov", &typeid(long)}, {"verbosity", &typeid(long)}}; /* --FH: class Init { public: Init(); }; LOADINIT(Init); -*/ -static void Load_Init() -{ - - Global.Add("MPILinearCG","(",new MPILinearCG()); // old form with rhs (must be zer - Global.Add("MPIAffineCG","(",new MPILinearCG(1)); // without right handsize - Global.Add("MPILinearGMRES","(",new MPILinearCG(0,0)); // with right handsize - Global.Add("MPIAffineGMRES","(",new MPILinearCG(0,0,0)); // with right handsize - Global.Add("MPINLCG","(",new MPILinearCG(-1)); // without right handsize - +*/ +static void Load_Init( ) { + + Global.Add("MPILinearCG", "(", new MPILinearCG< R >( )); // old form with rhs (must be zer + Global.Add("MPIAffineCG", "(", new MPILinearCG< R >(1)); // without right handsize + Global.Add("MPILinearGMRES", "(", new MPILinearCG< R >(0, 0)); // with right handsize + Global.Add("MPIAffineGMRES", "(", new MPILinearCG< R >(0, 0, 0)); // with right handsize + Global.Add("MPINLCG", "(", new MPILinearCG< R >(-1)); // without right handsize } - LOADFUNC(Load_Init) +LOADFUNC(Load_Init) diff --git a/plugin/mpi/MUMPS.cpp b/plugin/mpi/MUMPS.cpp index 338ff9ea3..5e5826037 100644 --- a/plugin/mpi/MUMPS.cpp +++ b/plugin/mpi/MUMPS.cpp @@ -21,8 +21,10 @@ // E-MAIL : frederic.hecht@sorbonne-unviersite.fr // *INDENT-OFF* // +/* clang-format off */ //ff-c++-LIBRARY-dep: mumps parmetis metis [ptscotch scotch] scalapack blas mpifc fc mpi pthread //ff-c++-cpp-dep: +/* clang-format on */ // *INDENT-ON* // // F. Hecht december 2011 @@ -31,16 +33,15 @@ #include #ifdef _WIN32 __declspec(dllexport) int toto; -MPI_Fint* _imp__MPI_F_STATUS_IGNORE; -MPI_Fint* _imp__MPI_F_STATUSES_IGNORE; +MPI_Fint *_imp__MPI_F_STATUS_IGNORE; +MPI_Fint *_imp__MPI_F_STATUSES_IGNORE; //__declspec(dllexport) void __guard_check_icall_fptr(unsigned long ptr) { } #endif -#include +#include using namespace std; #include "ff++.hpp" - #include #include @@ -52,349 +53,343 @@ const int JOB_ANA_FAC = 4; const int JOB_SOLVE = 3; const int USE_COMM_WORLD = -987654; -template struct MUMPS_STRUC_TRAIT {typedef void MUMPS; typedef void R; }; -template<> struct MUMPS_STRUC_TRAIT {typedef DMUMPS_STRUC_C MUMPS; typedef double R;}; -template<> struct MUMPS_STRUC_TRAIT {typedef ZMUMPS_STRUC_C MUMPS; typedef ZMUMPS_COMPLEX R;}; -void mumps_c(DMUMPS_STRUC_C *id) { dmumps_c(id);} -void mumps_c(ZMUMPS_STRUC_C *id) { zmumps_c(id);} - -template struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}};; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_LONG;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_INT;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE_COMPLEX;}}; +template< typename RR > +struct MUMPS_STRUC_TRAIT { + typedef void MUMPS; + typedef void R; +}; +template<> +struct MUMPS_STRUC_TRAIT< double > { + typedef DMUMPS_STRUC_C MUMPS; + typedef double R; +}; +template<> +struct MUMPS_STRUC_TRAIT< Complex > { + typedef ZMUMPS_STRUC_C MUMPS; + typedef ZMUMPS_COMPLEX R; +}; +void mumps_c(DMUMPS_STRUC_C *id) { dmumps_c(id); } +void mumps_c(ZMUMPS_STRUC_C *id) { zmumps_c(id); } +template< class T > +struct MPI_TYPE { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; +; +template<> +struct MPI_TYPE< long > { + static MPI_Datatype TYPE( ) { return MPI_LONG; } +}; +template<> +struct MPI_TYPE< int > { + static MPI_Datatype TYPE( ) { return MPI_INT; } +}; +template<> +struct MPI_TYPE< double > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE; } +}; +template<> +struct MPI_TYPE< char > { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; +template<> +struct MPI_TYPE< Complex > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE_COMPLEX; } +}; static std::string analysis[] = {"AMD", "", "AMF", "SCOTCH", "PORD", "METIS", "QAMD", "automatic sequential", "automatic parallel", "PT-SCOTCH", "ParMetis"}; -//template -template -class SolveMUMPS_mpi: public VirtualSolver -{ -public: - static const int orTypeSol; - typedef HashMatrix HMat; - typedef R K; // - HMat &A; - - - // typedef double R; - long verb; - double eps; - double tgv; - int cn,cs; - typedef typename MUMPS_STRUC_TRAIT::R MR; - mutable typename MUMPS_STRUC_TRAIT::MUMPS id; - KN *rinfog; - KN *infog; - mutable unsigned char strategy; - bool distributed; - MPI_Comm comm; - int mpirank; - int matrank; - // int distributed; - - int& ICNTL (int i) const {return id.icntl[i - 1];} - double& CNTL (int i) const {return id.cntl[i - 1];} - int& INFO (int i) const {return id.info[i - 1];} - double& RINFO (int i) const {return id.rinfo[i - 1];} - int& INFOG (int i) const {return id.infog[i - 1];} - double& RINFOG (int i) const {return id.rinfog[i - 1];} - - void SetVerb () const { - ICNTL(1) = 6;// output stream for error messages. - ICNTL(2) = 6;// stream for diagnostic printing, statistics, and warning messages. - ICNTL(3) = 6;// output stream global information, collected on the host. - ICNTL(4) = min(max(verb-2,1L),4L); // the level of printing for error, warning, and diag - if(verb ==0 )ICNTL(4) =0; - ICNTL(11)=0; // noerroranalysisisperformed(nostatistics). - if( id.job ==JOB_SOLVE && verb >99) - { //computes statistics related to an error analysis of the linear system - if( verb > 999) ICNTL(11)=1; // All Stat (veryexpensive) - else ICNTL(11)=2;// compute main statistics - } - - - } - void Clean () - { - delete [] id.irn; - delete [] id.jcn; - delete [] id.a; - - delete [] id.irn_loc; - delete [] id.jcn_loc; - delete [] id.a_loc; - - id.irn_loc = 0; - id.jcn_loc = 0; - id.a_loc = 0; - - id.irn=0; - id.jcn=0; - id.a =0; +// template +template< class R = double > +class SolveMUMPS_mpi : public VirtualSolver< int, R > { + public: + static const int orTypeSol; + typedef HashMatrix< int, R > HMat; + typedef R K; // + HMat &A; + + // typedef double R; + long verb; + double eps; + double tgv; + int cn, cs; + typedef typename MUMPS_STRUC_TRAIT< R >::R MR; + mutable typename MUMPS_STRUC_TRAIT< R >::MUMPS id; + KN< double > *rinfog; + KN< long > *infog; + mutable unsigned char strategy; + bool distributed; + MPI_Comm comm; + int mpirank; + int matrank; + // int distributed; + + int &ICNTL(int i) const { return id.icntl[i - 1]; } + double &CNTL(int i) const { return id.cntl[i - 1]; } + int &INFO(int i) const { return id.info[i - 1]; } + double &RINFO(int i) const { return id.rinfo[i - 1]; } + int &INFOG(int i) const { return id.infog[i - 1]; } + double &RINFOG(int i) const { return id.rinfog[i - 1]; } + + void SetVerb( ) const { + ICNTL(1) = 6; // output stream for error messages. + ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. + ICNTL(3) = 6; // output stream global information, collected on the host. + ICNTL(4) = min(max(verb - 2, 1L), 4L); // the level of printing for error, warning, and diag + if (verb == 0) ICNTL(4) = 0; + ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). + if (id.job == JOB_SOLVE && verb > 99) { // computes statistics related to an error analysis of the linear system + if (verb > 999) + ICNTL(11) = 1; // All Stat (veryexpensive) + else + ICNTL(11) = 2; // compute main statistics } - void to_mumps_mat() - { - Clean (); - - id.nrhs = 0;// - int n = A.n; - int nz = A.nnz; - ffassert(A.n == A.m); - if( distributed || (mpirank == matrank) ) + } + void Clean( ) { + delete[] id.irn; + delete[] id.jcn; + delete[] id.a; + + delete[] id.irn_loc; + delete[] id.jcn_loc; + delete[] id.a_loc; + + id.irn_loc = 0; + id.jcn_loc = 0; + id.a_loc = 0; + + id.irn = 0; + id.jcn = 0; + id.a = 0; + } + void to_mumps_mat( ) { + Clean( ); + + id.nrhs = 0; // + int n = A.n; + int nz = A.nnz; + ffassert(A.n == A.m); + if (distributed || (mpirank == matrank)) { + int *irn = new int[nz]; + int *jcn = new int[nz]; + R *a = new R[nz]; + A.COO( ); + + for (int k = 0; k < nz; ++k) { { - int *irn = new int[nz]; - int *jcn = new int[nz]; - R *a = new R[nz]; - A.COO(); - - for (int k = 0; k < nz; ++k) { - { - irn[k] = A.i[k]+1; - jcn[k] = A.j[k] + 1; - a[k] = A.aij[k]; - } - } - - id.n = n; - - if(!distributed) - { - if(mpirank == matrank) - { - id.nz = nz; - id.irn = irn; - id.jcn = jcn; - id.a = (MR *)(void *)a; - } - else - { // no matrix - id.nz=0; - id.a =0; - id.irn = 0;; - id.jcn = 0; - - } - - } - else - { - id.nz_loc = nz; - id.irn_loc = irn; - id.jcn_loc = jcn; - id.a_loc = (MR *)(void *)a; - - } - id.rhs = 0; - ffassert( A.half == id.sym );// - ICNTL(5) = 0; // input matrix type - ICNTL(7) = 7; // NUMBERING ... - - ICNTL(9) = 1; // 1: A x = b, !1 : tA x = b during slove phase - ICNTL(18) = 0; - if(strategy > 0 && strategy < 9 && strategy != 2) - { - ICNTL(28) = 1; // 1: sequential analysis - ICNTL(7) = strategy - 1; // 0: AMD - } - // 1: - // 2: AMF - // 3: SCOTCH - // 4: PORD - // 5: METIS - // 6: QAMD - // 7: automatic - else - { - ICNTL(28) = 1; - ICNTL(7) = 7; - } - if(strategy > 8 && strategy < 12) - { - ICNTL(28) = 2; // 2: parallel analysis - ICNTL(29) = strategy - 9; // 0: automatic - } // 1: PT-STOCH - // 2: ParMetis - ICNTL(9) = 1; - ICNTL(11) = 0; // verbose level - ICNTL(18) = distributed ? 3: 0; // centralized matrix input if !distributed - ICNTL(20) = 0; // dense RHS - ICNTL(14) = 30; + irn[k] = A.i[k] + 1; + jcn[k] = A.j[k] + 1; + a[k] = A.aij[k]; } - } - void Check (const char *msg = "mumps_mpi") - { - if (INFO(1) != 0) { - cout << " Erreur Mumps mpi: number " << INFO(1) << endl; - cout << " Fatal Erreur " << msg << endl; - Clean (); - id.job = JOB_END; - mumps_c(&id); /* Terminate instance */ - ErrorExec(msg, INFO(1)); + } + + id.n = n; + + if (!distributed) { + if (mpirank == matrank) { + id.nz = nz; + id.irn = irn; + id.jcn = jcn; + id.a = (MR *)(void *)a; + } else { // no matrix + id.nz = 0; + id.a = 0; + id.irn = 0; + ; + id.jcn = 0; } + + } else { + id.nz_loc = nz; + id.irn_loc = irn; + id.jcn_loc = jcn; + id.a_loc = (MR *)(void *)a; + } + id.rhs = 0; + ffassert(A.half == id.sym); // + ICNTL(5) = 0; // input matrix type + ICNTL(7) = 7; // NUMBERING ... + + ICNTL(9) = 1; // 1: A x = b, !1 : tA x = b during slove phase + ICNTL(18) = 0; + if (strategy > 0 && strategy < 9 && strategy != 2) { + ICNTL(28) = 1; // 1: sequential analysis + ICNTL(7) = strategy - 1; // 0: AMD + } + // 1: + // 2: AMF + // 3: SCOTCH + // 4: PORD + // 5: METIS + // 6: QAMD + // 7: automatic + else { + ICNTL(28) = 1; + ICNTL(7) = 7; + } + if (strategy > 8 && strategy < 12) { + ICNTL(28) = 2; // 2: parallel analysis + ICNTL(29) = strategy - 9; // 0: automatic + } // 1: PT-STOCH + // 2: ParMetis + ICNTL(9) = 1; + ICNTL(11) = 0; // verbose level + ICNTL(18) = distributed ? 3 : 0; // centralized matrix input if !distributed + ICNTL(20) = 0; // dense RHS + ICNTL(14) = 30; } - void CopyInfo() - { - if (rinfog) { - // copy rinfog - if (rinfog->N() < 40) {rinfog->resize(40);} - - for (int i = 0; i < 40; ++i) { - (*rinfog)[i] = RINFOG(i + 1); - } - } - - if (infog) { - // copy ginfo - if (infog->N() < 40) {infog->resize(40);} - - for (int i = 0; i < 40; ++i) { - (*infog)[i] = INFOG(i + 1); - } - } + } + void Check(const char *msg = "mumps_mpi") { + if (INFO(1) != 0) { + cout << " Erreur Mumps mpi: number " << INFO(1) << endl; + cout << " Fatal Erreur " << msg << endl; + Clean( ); + id.job = JOB_END; + mumps_c(&id); /* Terminate instance */ + ErrorExec(msg, INFO(1)); } - SolveMUMPS_mpi (HMat &AA, const Data_Sparse_Solver & ds,Stack stack ) - : A(AA), verb(ds.verb), - eps(ds.epsilon), - tgv(ds.tgv),cn(0),cs(0), - rinfog(ds.rinfo), infog(ds.info), - matrank(ds.master),distributed(ds.master<0), - strategy(ds.strategy) - { - - if(ds.commworld) - MPI_Comm_dup(*((MPI_Comm*)ds.commworld), &comm); - else - MPI_Comm_dup(MPI_COMM_WORLD, &comm); - - MPI_Comm_rank(comm, &mpirank); - int master = mpirank==matrank; - int myid = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - - id.irn=0; - id.jcn=0; - id.a =0; - - id.job = JOB_INIT; - id.par = 1; - id.sym = A.half; - id.comm_fortran = MPI_Comm_c2f(comm); - SetVerb(); - mumps_c(&id); - - - Check("MUMPS_mpi build/init"); - if (verbosity > 3 && master) { - cout << " -- MUMPS n= " << id.n << ", peak Mem: " << INFOG(22) << " Mb" << " sym: " << id.sym << endl; - } - - + } + void CopyInfo( ) { + if (rinfog) { + // copy rinfog + if (rinfog->N( ) < 40) { + rinfog->resize(40); + } + + for (int i = 0; i < 40; ++i) { + (*rinfog)[i] = RINFOG(i + 1); + } } - - - - ~SolveMUMPS_mpi () { - Clean (); - id.job = JOB_END; - SetVerb () ; - mumps_c(&id); /* Terminate instance */ - /*int ierr = */ - MPI_Comm_free(&comm); + + if (infog) { + // copy ginfo + if (infog->N( ) < 40) { + infog->resize(40); + } + + for (int i = 0; i < 40; ++i) { + (*infog)[i] = INFOG(i + 1); + } } - - - void dosolver(K *x,K*b,int N,int trans) - { - size_t nN=id.n*N; - if (verbosity > 1 && mpirank==0) { - cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " - << id.n << " sym =" << id.sym <<" trans = " << trans << endl; - } - ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase - id.nrhs = N; - // x = b; - if(distributed) - { - MPI_Reduce( (void *) b,(void *) x , nN , MPI_TYPE::TYPE(),MPI_SUM,0,comm); - } - else if(mpirank==0) std::copy(b,b+nN,x); - - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < nN; ++k) - x[k] = RNM::conj(x[k]); - - id.rhs = (MR *)(void *)(R *)x; - id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. - SetVerb(); - mumps_c(&id); - - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < nN; ++k) - x[k] = RNM::conj(x[k]); - - Check("MUMPS_mpi dosolver"); - if(distributed) // send the solution ... - MPI_Bcast(reinterpret_cast (x),nN, MPI_TYPE::TYPE(), 0,comm); - - - if (verb > 9 && mpirank==0) { - - for(int j=0; j B(b+j*id.n,id.n); - cout << j <<" b linfty " << B.linfty() << endl; - } - } - - if (verb > 2) { - - for(int j=0; j B(x+j*id.n,id.n); - cout << " x " << j <<" linfty " << B.linfty() << endl; - } - } - CopyInfo(); - + } + SolveMUMPS_mpi(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) + : A(AA), verb(ds.verb), eps(ds.epsilon), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), infog(ds.info), matrank(ds.master), distributed(ds.master < 0), strategy(ds.strategy) { + + if (ds.commworld) + MPI_Comm_dup(*((MPI_Comm *)ds.commworld), &comm); + else + MPI_Comm_dup(MPI_COMM_WORLD, &comm); + + MPI_Comm_rank(comm, &mpirank); + int master = mpirank == matrank; + int myid = 0; + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + + id.irn = 0; + id.jcn = 0; + id.a = 0; + + id.job = JOB_INIT; + id.par = 1; + id.sym = A.half; + id.comm_fortran = MPI_Comm_c2f(comm); + SetVerb( ); + mumps_c(&id); + + Check("MUMPS_mpi build/init"); + if (verbosity > 3 && master) { + cout << " -- MUMPS n= " << id.n << ", peak Mem: " << INFOG(22) << " Mb" << " sym: " << id.sym << endl; } - - void fac_init(){ - to_mumps_mat(); - } // n, nzz fixe - void fac_symbolic(){ - id.job = JOB_ANA; - SetVerb (); - mumps_c(&id); - Check("MUMPS_mpi Analyse"); - CopyInfo(); + } + + ~SolveMUMPS_mpi( ) { + Clean( ); + id.job = JOB_END; + SetVerb( ); + mumps_c(&id); /* Terminate instance */ + /*int ierr = */ + MPI_Comm_free(&comm); + } + + void dosolver(K *x, K *b, int N, int trans) { + size_t nN = id.n * N; + if (verbosity > 1 && mpirank == 0) { + cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n << " sym =" << id.sym << " trans = " << trans << endl; } - void fac_numeric(){ - id.job = JOB_FAC; - SetVerb () ; - mumps_c(&id); - Check("MUMPS_mpi Factorize"); - CopyInfo(); + ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase + id.nrhs = N; + // x = b; + if (distributed) { + MPI_Reduce((void *)b, (void *)x, nN, MPI_TYPE< R >::TYPE( ), MPI_SUM, 0, comm); + } else if (mpirank == 0) + std::copy(b, b + nN, x); + + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < nN; ++k) x[k] = RNM::conj(x[k]); + + id.rhs = (MR *)(void *)(R *)x; + id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. + SetVerb( ); + mumps_c(&id); + + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < nN; ++k) x[k] = RNM::conj(x[k]); + + Check("MUMPS_mpi dosolver"); + if (distributed) // send the solution ... + MPI_Bcast(reinterpret_cast< void * >(x), nN, MPI_TYPE< R >::TYPE( ), 0, comm); + + if (verb > 9 && mpirank == 0) { + + for (int j = 0; j < N; ++j) { + KN_< R > B(b + j * id.n, id.n); + cout << j << " b linfty " << B.linfty( ) << endl; + } } - void UpdateState(){ - if( A.GetReDoNumerics() ) cn++; - if( A.GetReDoSymbolic() ) cs++; - this->ChangeCodeState(A.n,cs,cn); + + if (verb > 2) { + + for (int j = 0; j < N; ++j) { + KN_< R > B(x + j * id.n, id.n); + cout << " x " << j << " linfty " << B.linfty( ) << endl; + } } - + CopyInfo( ); + } + + void fac_init( ) { to_mumps_mat( ); } // n, nzz fixe + void fac_symbolic( ) { + id.job = JOB_ANA; + SetVerb( ); + mumps_c(&id); + Check("MUMPS_mpi Analyse"); + CopyInfo( ); + } + void fac_numeric( ) { + id.job = JOB_FAC; + SetVerb( ); + mumps_c(&id); + Check("MUMPS_mpi Factorize"); + CopyInfo( ); + } + void UpdateState( ) { + if (A.GetReDoNumerics( )) cn++; + if (A.GetReDoSymbolic( )) cs++; + this->ChangeCodeState(A.n, cs, cn); + } }; // 1 unsym , 2 herm, 4 sym, 8 pos , 16 nopos, 32 seq, 64 ompi, 128 mpi -template<> const int SolveMUMPS_mpi::orTypeSol = 1|2|4|8|16|32; -template<> const int SolveMUMPS_mpi>::orTypeSol = 1|4|8|16|32; - -static void Load_Init() -{ - addsolver>("MUMPS",50,1); - addsolver>("MUMPS",50,1); - addsolver>("MUMPSMPI",50,1); - addsolver>("MUMPSMPI",50,1); - setptrstring(def_solver,"MUMPSMPI"); +template<> +const int SolveMUMPS_mpi< double >::orTypeSol = 1 | 2 | 4 | 8 | 16 | 32; +template<> +const int SolveMUMPS_mpi< std::complex< double > >::orTypeSol = 1 | 4 | 8 | 16 | 32; + +static void Load_Init( ) { + addsolver< SolveMUMPS_mpi< double > >("MUMPS", 50, 1); + addsolver< SolveMUMPS_mpi< Complex > >("MUMPS", 50, 1); + addsolver< SolveMUMPS_mpi< double > >("MUMPSMPI", 50, 1); + addsolver< SolveMUMPS_mpi< Complex > >("MUMPSMPI", 50, 1); + setptrstring(def_solver, "MUMPSMPI"); } LOADFUNC(Load_Init) diff --git a/plugin/mpi/MUMPS_mpi.cpp b/plugin/mpi/MUMPS_mpi.cpp index 299ac6013..2f35b652b 100644 --- a/plugin/mpi/MUMPS_mpi.cpp +++ b/plugin/mpi/MUMPS_mpi.cpp @@ -21,8 +21,10 @@ // E-MAIL : frederic.hecht@sorbonne-unviersite.fr // *INDENT-OFF* // +/* clang-format off */ //ff-c++-LIBRARY-dep: mumps parmetis metis [ptscotch scotch] scalapack blas mpifc fc mpi pthread //ff-c++-cpp-dep: +/* clang-format on */ // *INDENT-ON* // // F. Hecht december 2011 @@ -31,16 +33,15 @@ #include #ifdef _WIN32 __declspec(dllexport) int toto; -MPI_Fint* _imp__MPI_F_STATUS_IGNORE; -MPI_Fint* _imp__MPI_F_STATUSES_IGNORE; +MPI_Fint *_imp__MPI_F_STATUS_IGNORE; +MPI_Fint *_imp__MPI_F_STATUSES_IGNORE; //__declspec(dllexport) void __guard_check_icall_fptr(unsigned long ptr) { } #endif -#include +#include using namespace std; #include "ff++.hpp" - #include #include @@ -52,351 +53,345 @@ const int JOB_ANA_FAC = 4; const int JOB_SOLVE = 3; const int USE_COMM_WORLD = -987654; -template struct MUMPS_STRUC_TRAIT {typedef void MUMPS; typedef void R; }; -template<> struct MUMPS_STRUC_TRAIT {typedef DMUMPS_STRUC_C MUMPS; typedef double R;}; -template<> struct MUMPS_STRUC_TRAIT {typedef ZMUMPS_STRUC_C MUMPS; typedef ZMUMPS_COMPLEX R;}; -void mumps_c(DMUMPS_STRUC_C *id) { dmumps_c(id);} -void mumps_c(ZMUMPS_STRUC_C *id) { zmumps_c(id);} - -template struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}};; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_LONG;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_INT;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE_COMPLEX;}}; +template< typename RR > +struct MUMPS_STRUC_TRAIT { + typedef void MUMPS; + typedef void R; +}; +template<> +struct MUMPS_STRUC_TRAIT< double > { + typedef DMUMPS_STRUC_C MUMPS; + typedef double R; +}; +template<> +struct MUMPS_STRUC_TRAIT< Complex > { + typedef ZMUMPS_STRUC_C MUMPS; + typedef ZMUMPS_COMPLEX R; +}; +void mumps_c(DMUMPS_STRUC_C *id) { dmumps_c(id); } +void mumps_c(ZMUMPS_STRUC_C *id) { zmumps_c(id); } +template< class T > +struct MPI_TYPE { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; +; +template<> +struct MPI_TYPE< long > { + static MPI_Datatype TYPE( ) { return MPI_LONG; } +}; +template<> +struct MPI_TYPE< int > { + static MPI_Datatype TYPE( ) { return MPI_INT; } +}; +template<> +struct MPI_TYPE< double > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE; } +}; +template<> +struct MPI_TYPE< char > { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; +template<> +struct MPI_TYPE< Complex > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE_COMPLEX; } +}; static std::string analysis[] = {"AMD", "", "AMF", "SCOTCH", "PORD", "METIS", "QAMD", "automatic sequential", "automatic parallel", "PT-SCOTCH", "ParMetis"}; -//template -template -class SolveMUMPS_mpi: public VirtualSolver -{ -public: - static const int orTypeSol; - typedef HashMatrix HMat; - typedef R K; // - HMat &A; - - - // typedef double R; - long verb; - double eps; - double tgv; - int cn,cs; - typedef typename MUMPS_STRUC_TRAIT::R MR; - mutable typename MUMPS_STRUC_TRAIT::MUMPS id; - KN *rinfog; - KN *infog; - mutable unsigned char strategy; - bool distributed; - MPI_Comm comm; - int mpirank; - int matrank; - // int distributed; - - int& ICNTL (int i) const {return id.icntl[i - 1];} - double& CNTL (int i) const {return id.cntl[i - 1];} - int& INFO (int i) const {return id.info[i - 1];} - double& RINFO (int i) const {return id.rinfo[i - 1];} - int& INFOG (int i) const {return id.infog[i - 1];} - double& RINFOG (int i) const {return id.rinfog[i - 1];} - - void SetVerb () const { - ICNTL(1) = 6;// output stream for error messages. - ICNTL(2) = 6;// stream for diagnostic printing, statistics, and warning messages. - ICNTL(3) = 6;// output stream global information, collected on the host. - ICNTL(4) = min(max(verb-2,1L),4L); // the level of printing for error, warning, and diag - if(verb ==0 )ICNTL(4) =0; - ICNTL(11)=0; // noerroranalysisisperformed(nostatistics). - if( id.job ==JOB_SOLVE && verb >99) - { //computes statistics related to an error analysis of the linear system - if( verb > 999) ICNTL(11)=1; // All Stat (veryexpensive) - else ICNTL(11)=2;// compute main statistics - } - - - } - void Clean () - { - delete [] id.irn; - delete [] id.jcn; - delete [] id.a; - - delete [] id.irn_loc; - delete [] id.jcn_loc; - delete [] id.a_loc; - - id.irn_loc = 0; - id.jcn_loc = 0; - id.a_loc = 0; - - id.irn=0; - id.jcn=0; - id.a =0; +// template +template< class R = double > +class SolveMUMPS_mpi : public VirtualSolver< int, R > { + public: + static const int orTypeSol; + typedef HashMatrix< int, R > HMat; + typedef R K; // + HMat &A; + + // typedef double R; + long verb; + double eps; + double tgv; + int cn, cs; + typedef typename MUMPS_STRUC_TRAIT< R >::R MR; + mutable typename MUMPS_STRUC_TRAIT< R >::MUMPS id; + KN< double > *rinfog; + KN< long > *infog; + mutable unsigned char strategy; + bool distributed; + MPI_Comm comm; + int mpirank; + int matrank; + // int distributed; + + int &ICNTL(int i) const { return id.icntl[i - 1]; } + double &CNTL(int i) const { return id.cntl[i - 1]; } + int &INFO(int i) const { return id.info[i - 1]; } + double &RINFO(int i) const { return id.rinfo[i - 1]; } + int &INFOG(int i) const { return id.infog[i - 1]; } + double &RINFOG(int i) const { return id.rinfog[i - 1]; } + + void SetVerb( ) const { + ICNTL(1) = 6; // output stream for error messages. + ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. + ICNTL(3) = 6; // output stream global information, collected on the host. + ICNTL(4) = min(max(verb - 2, 1L), 4L); // the level of printing for error, warning, and diag + if (verb == 0) ICNTL(4) = 0; + ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). + if (id.job == JOB_SOLVE && verb > 99) { // computes statistics related to an error analysis of the linear system + if (verb > 999) + ICNTL(11) = 1; // All Stat (veryexpensive) + else + ICNTL(11) = 2; // compute main statistics } - void to_mumps_mat() - { - Clean (); - - id.nrhs = 0;// - int n = A.n; - int nz = A.nnz; - ffassert(A.n == A.m); - if( distributed || (mpirank == matrank) ) + } + void Clean( ) { + delete[] id.irn; + delete[] id.jcn; + delete[] id.a; + + delete[] id.irn_loc; + delete[] id.jcn_loc; + delete[] id.a_loc; + + id.irn_loc = 0; + id.jcn_loc = 0; + id.a_loc = 0; + + id.irn = 0; + id.jcn = 0; + id.a = 0; + } + void to_mumps_mat( ) { + Clean( ); + + id.nrhs = 0; // + int n = A.n; + int nz = A.nnz; + ffassert(A.n == A.m); + if (distributed || (mpirank == matrank)) { + int *irn = new int[nz]; + int *jcn = new int[nz]; + R *a = new R[nz]; + A.COO( ); + + for (int k = 0; k < nz; ++k) { { - int *irn = new int[nz]; - int *jcn = new int[nz]; - R *a = new R[nz]; - A.COO(); - - for (int k = 0; k < nz; ++k) { - { - irn[k] = A.i[k]+1; - jcn[k] = A.j[k] + 1; - a[k] = A.aij[k]; - } - } - - id.n = n; - - if(!distributed) - { - if(mpirank == matrank) - { - id.nz = nz; - id.irn = irn; - id.jcn = jcn; - id.a = (MR *)(void *)a; - } - else - { // no matrix - id.nz=0; - id.a =0; - id.irn = 0;; - id.jcn = 0; - - } - - } - else - { - id.nz_loc = nz; - id.irn_loc = irn; - id.jcn_loc = jcn; - id.a_loc = (MR *)(void *)a; - - } - id.rhs = 0; - ffassert( A.half == id.sym );// - ICNTL(5) = 0; // input matrix type - ICNTL(7) = 7; // NUMBERING ... - - ICNTL(9) = 1; // 1: A x = b, !1 : tA x = b during slove phase - ICNTL(18) = 0; - if(strategy > 0 && strategy < 9 && strategy != 2) - { - ICNTL(28) = 1; // 1: sequential analysis - ICNTL(7) = strategy - 1; // 0: AMD - } - // 1: - // 2: AMF - // 3: SCOTCH - // 4: PORD - // 5: METIS - // 6: QAMD - // 7: automatic - else - { - ICNTL(28) = 1; - ICNTL(7) = 7; - } - if(strategy > 8 && strategy < 12) - { - ICNTL(28) = 2; // 2: parallel analysis - ICNTL(29) = strategy - 9; // 0: automatic - } // 1: PT-STOCH - // 2: ParMetis - ICNTL(9) = 1; - ICNTL(11) = 0; // verbose level - ICNTL(18) = distributed ? 3: 0; // centralized matrix input if !distributed - ICNTL(20) = 0; // dense RHS - ICNTL(14) = 30; + irn[k] = A.i[k] + 1; + jcn[k] = A.j[k] + 1; + a[k] = A.aij[k]; } - } - void Check (const char *msg = "mumps_mpi") - { - if (INFO(1) != 0) { - cout << " Erreur Mumps mpi: number " << INFO(1) << endl; - cout << " Fatal Erreur " << msg << endl; - Clean (); - id.job = JOB_END; - mumps_c(&id); /* Terminate instance */ - ErrorExec(msg, INFO(1)); + } + + id.n = n; + + if (!distributed) { + if (mpirank == matrank) { + id.nz = nz; + id.irn = irn; + id.jcn = jcn; + id.a = (MR *)(void *)a; + } else { // no matrix + id.nz = 0; + id.a = 0; + id.irn = 0; + ; + id.jcn = 0; } + + } else { + id.nz_loc = nz; + id.irn_loc = irn; + id.jcn_loc = jcn; + id.a_loc = (MR *)(void *)a; + } + id.rhs = 0; + ffassert(A.half == id.sym); // + ICNTL(5) = 0; // input matrix type + ICNTL(7) = 7; // NUMBERING ... + + ICNTL(9) = 1; // 1: A x = b, !1 : tA x = b during slove phase + ICNTL(18) = 0; + if (strategy > 0 && strategy < 9 && strategy != 2) { + ICNTL(28) = 1; // 1: sequential analysis + ICNTL(7) = strategy - 1; // 0: AMD + } + // 1: + // 2: AMF + // 3: SCOTCH + // 4: PORD + // 5: METIS + // 6: QAMD + // 7: automatic + else { + ICNTL(28) = 1; + ICNTL(7) = 7; + } + if (strategy > 8 && strategy < 12) { + ICNTL(28) = 2; // 2: parallel analysis + ICNTL(29) = strategy - 9; // 0: automatic + } // 1: PT-STOCH + // 2: ParMetis + ICNTL(9) = 1; + ICNTL(11) = 0; // verbose level + ICNTL(18) = distributed ? 3 : 0; // centralized matrix input if !distributed + ICNTL(20) = 0; // dense RHS + ICNTL(14) = 30; } - void CopyInfo() - { - if (rinfog) { - // copy rinfog - if (rinfog->N() < 40) {rinfog->resize(40);} - - for (int i = 0; i < 40; ++i) { - (*rinfog)[i] = RINFOG(i + 1); - } - } - - if (infog) { - // copy ginfo - if (infog->N() < 40) {infog->resize(40);} - - for (int i = 0; i < 40; ++i) { - (*infog)[i] = INFOG(i + 1); - } - } + } + void Check(const char *msg = "mumps_mpi") { + if (INFO(1) != 0) { + cout << " Erreur Mumps mpi: number " << INFO(1) << endl; + cout << " Fatal Erreur " << msg << endl; + Clean( ); + id.job = JOB_END; + mumps_c(&id); /* Terminate instance */ + ErrorExec(msg, INFO(1)); } - SolveMUMPS_mpi (HMat &AA, const Data_Sparse_Solver & ds,Stack stack ) - : A(AA), verb(ds.verb), - eps(ds.epsilon), - tgv(ds.tgv),cn(0),cs(0), - rinfog(ds.rinfo), infog(ds.info), - matrank(ds.master),distributed(ds.master<0), - strategy(ds.strategy) - { - - if(ds.commworld) - MPI_Comm_dup(*((MPI_Comm*)ds.commworld), &comm); - else - MPI_Comm_dup(MPI_COMM_WORLD, &comm); - - MPI_Comm_rank(comm, &mpirank); - int master = mpirank==matrank; - int myid = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - - id.irn=0; - id.jcn=0; - id.a =0; - - id.job = JOB_INIT; - id.par = 1; - id.sym = A.half; - id.comm_fortran = MPI_Comm_c2f(comm); - SetVerb(); - mumps_c(&id); - - - Check("MUMPS_mpi build/init"); - if (verbosity > 3 && master) { - cout << " -- MUMPS n= " << id.n << ", peak Mem: " << INFOG(22) << " Mb" << " sym: " << id.sym << endl; - } - - + } + void CopyInfo( ) { + if (rinfog) { + // copy rinfog + if (rinfog->N( ) < 40) { + rinfog->resize(40); + } + + for (int i = 0; i < 40; ++i) { + (*rinfog)[i] = RINFOG(i + 1); + } } - - - - ~SolveMUMPS_mpi () { - Clean (); - id.job = JOB_END; - SetVerb () ; - mumps_c(&id); /* Terminate instance */ - /*int ierr = */ - MPI_Comm_free(&comm); + + if (infog) { + // copy ginfo + if (infog->N( ) < 40) { + infog->resize(40); + } + + for (int i = 0; i < 40; ++i) { + (*infog)[i] = INFOG(i + 1); + } } - - - void dosolver(K *x,K*b,int N,int trans) - { - size_t nN=id.n*N; - if (verbosity > 1 && mpirank==0) { - cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " - << id.n << " sym =" << id.sym <<" trans = " << trans << endl; - } - ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase - id.nrhs = N; - id.lrhs = id.n; - // x = b; - if(distributed) - { - ffassert(id.nrhs==1); - MPI_Reduce( (void *) b,(void *) x , nN , MPI_TYPE::TYPE(),MPI_SUM,0,comm); - } - else if(mpirank==0) std::copy(b,b+nN,x); - - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < nN; ++k) - x[k] = RNM::conj(x[k]); - - id.rhs = (MR *)(void *)(R *)x; - id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. - SetVerb(); - mumps_c(&id); - - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < nN; ++k) - x[k] = RNM::conj(x[k]); - - Check("MUMPS_mpi dosolver"); - if(distributed) // send the solution ... - MPI_Bcast(reinterpret_cast (x),nN, MPI_TYPE::TYPE(), 0,comm); - - - if (verb > 9 && mpirank==0) { - - for(int j=0; j B(b+j*id.n,id.n); - cout << j <<" b linfty " << B.linfty() << endl; - } - } - - if (verb > 2) { - - for(int j=0; j B(x+j*id.n,id.n); - cout << " x " << j <<" linfty " << B.linfty() << endl; - } - } - CopyInfo(); - + } + SolveMUMPS_mpi(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) + : A(AA), verb(ds.verb), eps(ds.epsilon), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), infog(ds.info), matrank(ds.master), distributed(ds.master < 0), strategy(ds.strategy) { + + if (ds.commworld) + MPI_Comm_dup(*((MPI_Comm *)ds.commworld), &comm); + else + MPI_Comm_dup(MPI_COMM_WORLD, &comm); + + MPI_Comm_rank(comm, &mpirank); + int master = mpirank == matrank; + int myid = 0; + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + + id.irn = 0; + id.jcn = 0; + id.a = 0; + + id.job = JOB_INIT; + id.par = 1; + id.sym = A.half; + id.comm_fortran = MPI_Comm_c2f(comm); + SetVerb( ); + mumps_c(&id); + + Check("MUMPS_mpi build/init"); + if (verbosity > 3 && master) { + cout << " -- MUMPS n= " << id.n << ", peak Mem: " << INFOG(22) << " Mb" << " sym: " << id.sym << endl; } - - void fac_init(){ - to_mumps_mat(); - } // n, nzz fixe - void fac_symbolic(){ - id.job = JOB_ANA; - SetVerb (); - mumps_c(&id); - Check("MUMPS_mpi Analyse"); - CopyInfo(); + } + + ~SolveMUMPS_mpi( ) { + Clean( ); + id.job = JOB_END; + SetVerb( ); + mumps_c(&id); /* Terminate instance */ + /*int ierr = */ + MPI_Comm_free(&comm); + } + + void dosolver(K *x, K *b, int N, int trans) { + size_t nN = id.n * N; + if (verbosity > 1 && mpirank == 0) { + cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n << " sym =" << id.sym << " trans = " << trans << endl; } - void fac_numeric(){ - id.job = JOB_FAC; - SetVerb () ; - mumps_c(&id); - Check("MUMPS_mpi Factorize"); - CopyInfo(); + ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase + id.nrhs = N; + id.lrhs = id.n; + // x = b; + if (distributed) { + ffassert(id.nrhs == 1); + MPI_Reduce((void *)b, (void *)x, nN, MPI_TYPE< R >::TYPE( ), MPI_SUM, 0, comm); + } else if (mpirank == 0) + std::copy(b, b + nN, x); + + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < nN; ++k) x[k] = RNM::conj(x[k]); + + id.rhs = (MR *)(void *)(R *)x; + id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. + SetVerb( ); + mumps_c(&id); + + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < nN; ++k) x[k] = RNM::conj(x[k]); + + Check("MUMPS_mpi dosolver"); + if (distributed) // send the solution ... + MPI_Bcast(reinterpret_cast< void * >(x), nN, MPI_TYPE< R >::TYPE( ), 0, comm); + + if (verb > 9 && mpirank == 0) { + + for (int j = 0; j < N; ++j) { + KN_< R > B(b + j * id.n, id.n); + cout << j << " b linfty " << B.linfty( ) << endl; + } } - void UpdateState(){ - if( A.GetReDoNumerics() ) cn++; - if( A.GetReDoSymbolic() ) cs++; - this->ChangeCodeState(A.n,cs,cn); + + if (verb > 2) { + + for (int j = 0; j < N; ++j) { + KN_< R > B(x + j * id.n, id.n); + cout << " x " << j << " linfty " << B.linfty( ) << endl; + } } - + CopyInfo( ); + } + + void fac_init( ) { to_mumps_mat( ); } // n, nzz fixe + void fac_symbolic( ) { + id.job = JOB_ANA; + SetVerb( ); + mumps_c(&id); + Check("MUMPS_mpi Analyse"); + CopyInfo( ); + } + void fac_numeric( ) { + id.job = JOB_FAC; + SetVerb( ); + mumps_c(&id); + Check("MUMPS_mpi Factorize"); + CopyInfo( ); + } + void UpdateState( ) { + if (A.GetReDoNumerics( )) cn++; + if (A.GetReDoSymbolic( )) cs++; + this->ChangeCodeState(A.n, cs, cn); + } }; // 1 unsym , 2 herm, 4 sym, 8 pos , 16 nopos, 32 seq, 64 ompi, 128 mpi -template<> const int SolveMUMPS_mpi::orTypeSol = 1|2|4|8|16|32; -template<> const int SolveMUMPS_mpi>::orTypeSol = 1|4|8|16|32; - -static void Load_Init() -{ - addsolver>("MUMPS",50,1); - addsolver>("MUMPS",50,1); - addsolver>("MUMPSMPI",50,1); - addsolver>("MUMPSMPI",50,1); - setptrstring(def_solver,"MUMPSMPI"); +template<> +const int SolveMUMPS_mpi< double >::orTypeSol = 1 | 2 | 4 | 8 | 16 | 32; +template<> +const int SolveMUMPS_mpi< std::complex< double > >::orTypeSol = 1 | 4 | 8 | 16 | 32; + +static void Load_Init( ) { + addsolver< SolveMUMPS_mpi< double > >("MUMPS", 50, 1); + addsolver< SolveMUMPS_mpi< Complex > >("MUMPS", 50, 1); + addsolver< SolveMUMPS_mpi< double > >("MUMPSMPI", 50, 1); + addsolver< SolveMUMPS_mpi< Complex > >("MUMPSMPI", 50, 1); + setptrstring(def_solver, "MUMPSMPI"); } LOADFUNC(Load_Init) diff --git a/plugin/mpi/PETSc-code.hpp b/plugin/mpi/PETSc-code.hpp index 8759fe559..76c0dd804 100644 --- a/plugin/mpi/PETSc-code.hpp +++ b/plugin/mpi/PETSc-code.hpp @@ -13,212 +13,214 @@ typedef PETSc::DistributedCSR< HpSchur< PetscComplex > > DbddcC; #if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) namespace PETSc { -template -struct HtoolCtx { - htool::VirtualGenerator* generator; - bemtool::Dof

* dof; + template< typename P, typename MeshBemtool > + struct HtoolCtx { + htool::VirtualGenerator< PetscScalar >* generator; + bemtool::Dof< P >* dof; MeshBemtool* mesh; bemtool::Geometry* node; - HtoolCtx() : generator(), dof(), mesh(), node() { } - ~HtoolCtx() { - delete generator; - delete dof; - delete mesh; - delete node; + HtoolCtx( ) : generator( ), dof( ), mesh( ), node( ) {} + ~HtoolCtx( ) { + delete generator; + delete dof; + delete mesh; + delete node; } -}; + }; -template -static PetscErrorCode GenEntriesFromCtx(PetscInt sdim,PetscInt M,PetscInt N, const PetscInt *const J, const PetscInt *const K, PetscScalar* ptr,void *ctx) { + template< typename P, typename MeshBemtool > + static PetscErrorCode GenEntriesFromCtx(PetscInt sdim, PetscInt M, PetscInt N, const PetscInt* const J, const PetscInt* const K, PetscScalar* ptr, void* ctx) { PetscFunctionBeginUser; - HtoolCtx* user = reinterpret_cast*>(ctx); - user->generator->copy_submatrix(M,N,J,K,ptr); + HtoolCtx< P, MeshBemtool >* user = reinterpret_cast< HtoolCtx< P, MeshBemtool >* >(ctx); + user->generator->copy_submatrix(M, N, J, K, ptr); PetscFunctionReturn(PETSC_SUCCESS); -} + } -template + template< typename P, typename MeshBemtool > #if PETSC_VERSION_GE(3, 23, 0) -static PetscErrorCode DestroyHtoolCtx(void **ctx) { - HtoolCtx* user = (HtoolCtx*)*ctx; + static PetscErrorCode DestroyHtoolCtx(void** ctx) { + HtoolCtx< P, MeshBemtool >* user = (HtoolCtx< P, MeshBemtool >*)*ctx; #else -static PetscErrorCode DestroyHtoolCtx(void *ctx) { - HtoolCtx* user = (HtoolCtx*)ctx; + static PetscErrorCode DestroyHtoolCtx(void* ctx) { + HtoolCtx< P, MeshBemtool >* user = (HtoolCtx< P, MeshBemtool >*)ctx; #endif PetscFunctionBeginUser; delete user; PetscFunctionReturn(PETSC_SUCCESS); -} + } -template class Gen, typename P, typename MeshBemtool, typename std::enable_if< std::is_same< HtoolCtx, Gen >::value >::type* = nullptr> -htool::VirtualGenerator* get_gen(Gen* generator) { + template< template< typename P, typename MeshBemtool > class Gen, typename P, typename MeshBemtool, + typename std::enable_if< std::is_same< HtoolCtx< P, MeshBemtool >, Gen< P, MeshBemtool > >::value >::type* = nullptr > + htool::VirtualGenerator< PetscScalar >* get_gen(Gen< P, MeshBemtool >* generator) { return generator->generator; -} + } -template class Gen, typename P, typename MeshBemtool, typename std::enable_if< !std::is_same< HtoolCtx, Gen >::value >::type* = nullptr> -htool::VirtualGenerator* get_gen(Gen* generator) { + template< template< typename P, typename MeshBemtool > class Gen, typename P, typename MeshBemtool, + typename std::enable_if< !std::is_same< HtoolCtx< P, MeshBemtool >, Gen< P, MeshBemtool > >::value >::type* = nullptr > + htool::VirtualGenerator< PetscScalar >* get_gen(Gen< P, MeshBemtool >* generator) { return generator; -} + } -template class Gen, typename P, typename MeshBemtool, class R = PetscScalar, typename std::enable_if< std::is_same< Matrix, Dmat >::value >::type* = nullptr> -void Assembly(Matrix* A, Gen* generator, string compressor,vector &p1,vector &p2,MPI_Comm comm,int dim,bool sym = false) { + template< class Matrix, template< typename P, typename MeshBemtool > class Gen, typename P, typename MeshBemtool, class R = PetscScalar, + typename std::enable_if< std::is_same< Matrix, Dmat >::value >::type* = nullptr > + void Assembly(Matrix* A, Gen< P, MeshBemtool >* generator, string compressor, vector< double >& p1, vector< double >& p2, MPI_Comm comm, int dim, bool sym = false) { PetscInt m, M; KSPDestroy(&A->_ksp); - if(A->_vS) { - for(int i = 0; i < A->_vS->size(); ++i) - MatDestroy(&(*A->_vS)[i]); - delete A->_vS; - A->_vS = nullptr; - } - if(!A->_petsc) { - MatCreateHtoolFromKernel(PETSC_COMM_SELF,p2.size()/3,p1.size()/3,p2.size()/3,p1.size()/3,3,p2.data(),p1.data(),nullptr,get_gen(generator),&A->_petsc); + if (A->_vS) { + for (int i = 0; i < A->_vS->size( ); ++i) MatDestroy(&(*A->_vS)[i]); + delete A->_vS; + A->_vS = nullptr; } - else { - Mat B; - PetscInt m, n, M, N, rbegin, cbegin; - MatGetLocalSize(A->_petsc, &m, &n); - MatGetSize(A->_petsc, &M, &N); - MatGetOwnershipRange(A->_petsc, &rbegin, NULL); - MatGetOwnershipRangeColumn(A->_petsc, &cbegin, NULL); - ffassert(N == p1.size()/3 && M == p2.size()/3); - MatCreateHtoolFromKernel(PetscObjectComm((PetscObject)A->_petsc),m,n,M,N,3,p2.data()+rbegin*3,p1.data()+cbegin*3,nullptr,get_gen(generator),&B); - MatHeaderReplace(A->_petsc, &B); + if (!A->_petsc) { + MatCreateHtoolFromKernel(PETSC_COMM_SELF, p2.size( ) / 3, p1.size( ) / 3, p2.size( ) / 3, p1.size( ) / 3, 3, p2.data( ), p1.data( ), nullptr, get_gen(generator), &A->_petsc); + } else { + Mat B; + PetscInt m, n, M, N, rbegin, cbegin; + MatGetLocalSize(A->_petsc, &m, &n); + MatGetSize(A->_petsc, &M, &N); + MatGetOwnershipRange(A->_petsc, &rbegin, NULL); + MatGetOwnershipRangeColumn(A->_petsc, &cbegin, NULL); + ffassert(N == p1.size( ) / 3 && M == p2.size( ) / 3); + MatCreateHtoolFromKernel(PetscObjectComm((PetscObject)A->_petsc), m, n, M, N, 3, p2.data( ) + rbegin * 3, p1.data( ) + cbegin * 3, nullptr, get_gen(generator), &B); + MatHeaderReplace(A->_petsc, &B); } - if(compressor.size()) { - PetscOptionsInsertString(NULL, compressor.c_str()); + if (compressor.size( )) { + PetscOptionsInsertString(NULL, compressor.c_str( )); } - if(sym) { - MatSetOption(A->_petsc, MAT_SYMMETRIC, PETSC_TRUE); + if (sym) { + MatSetOption(A->_petsc, MAT_SYMMETRIC, PETSC_TRUE); } MatSetFromOptions(A->_petsc); MatAssemblyBegin(A->_petsc, MAT_FINAL_ASSEMBLY); MatAssemblyEnd(A->_petsc, MAT_FINAL_ASSEMBLY); - if(std::is_same, Gen>::value) { - MatHtoolSetKernel(A->_petsc, GenEntriesFromCtx, generator); + if (std::is_same< HtoolCtx< P, MeshBemtool >, Gen< P, MeshBemtool > >::value) { + MatHtoolSetKernel(A->_petsc, GenEntriesFromCtx< P, MeshBemtool >, generator); } -} + } -template= 3) || std::is_same::value >::type* = nullptr > -void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& PVh, bool same, int VFBEM, Stack stack, const list& bargs, const Data_Sparse_Solver& ds, Dmat* B) { + template< class fes1, class fes2, typename std::enable_if< (fes1::FESpace::Mesh::RdHat::d >= 3) || std::is_same< typename fes1::FESpace::Mesh, Mesh >::value >::type* = nullptr > + void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& PVh, bool same, int VFBEM, Stack stack, const list< C_F0 >& bargs, const Data_Sparse_Solver& ds, Dmat* B) { ffassert(VFBEM == -1); -} + } -template::value || std::is_same::value || std::is_same::value >::type* = nullptr > -bemtool::Dof

* new_dof(MeshBemtool *mesh) { - return new bemtool::Dof

(*mesh); -} + template< typename P, typename MeshBemtool, + typename std::enable_if< std::is_same< P, bemtool::RT0_2D >::value || std::is_same< P, bemtool::P0_1D >::value || std::is_same< P, bemtool::P0_2D >::value >::type* = nullptr > + bemtool::Dof< P >* new_dof(MeshBemtool* mesh) { + return new bemtool::Dof< P >(*mesh); + } -template::value && !std::is_same::value && !std::is_same::value >::type* = nullptr > -bemtool::Dof

* new_dof(MeshBemtool *mesh) { - return new bemtool::Dof

(*mesh, true); -} + template< typename P, typename MeshBemtool, + typename std::enable_if< !std::is_same< P, bemtool::RT0_2D >::value && !std::is_same< P, bemtool::P0_1D >::value && !std::is_same< P, bemtool::P0_2D >::value >::type* = nullptr > + bemtool::Dof< P >* new_dof(MeshBemtool* mesh) { + return new bemtool::Dof< P >(*mesh, true); + } -template::type* = nullptr > -void dispatch(MeshBemtool *mesh, bemtool::Geometry *node, int VFBEM, Stack stack, const list& bargs, const Data_Sparse_Solver& ds, Dmat* B, const Mesh2& ThV, std::vector& p1, std::vector& p2, bool same, const FESpace2& Vh) { - HtoolCtx* ctx = new HtoolCtx; - ctx->dof = new_dof

(mesh); + template< typename P, typename MeshBemtool, typename Mesh1, bool T, typename Mesh2, typename FESpace2, typename std::enable_if< !T >::type* = nullptr > + void dispatch(MeshBemtool* mesh, bemtool::Geometry* node, int VFBEM, Stack stack, const list< C_F0 >& bargs, const Data_Sparse_Solver& ds, Dmat* B, const Mesh2& ThV, std::vector< double >& p1, + std::vector< double >& p2, bool same, const FESpace2& Vh) { + HtoolCtx< P, MeshBemtool >* ctx = new HtoolCtx< P, MeshBemtool >; + ctx->dof = new_dof< P >(mesh); ctx->mesh = mesh; ctx->node = node; bemtool::Geometry node_output; if (VFBEM == 1) { - pair> kernel = getBemKernel(stack, bargs); - BemKernel *Ker = kernel.first; - std::complex alpha = kernel.second; - ff_BIO_Generator_Maxwell(ctx->generator,Ker,*ctx->dof,alpha); - } - else if (VFBEM == 2) { - BemPotential *Pot = getBemPotential(stack, bargs); - if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d+1) - Mesh2Bemtool(ThV,node_output); - else if (Vh.MaxNbNodePerElement == 1) { - int m = Vh.NbOfDF; - typename Mesh2::RdHat pbt(1./(Mesh2::RdHat::d+1),1./(Mesh2::RdHat::d+1)); - for (int i=0; i > kernel = getBemKernel(stack, bargs); + BemKernel* Ker = kernel.first; + std::complex< double > alpha = kernel.second; + ff_BIO_Generator_Maxwell< PetscScalar >(ctx->generator, Ker, *ctx->dof, alpha); + } else if (VFBEM == 2) { + BemPotential* Pot = getBemPotential(stack, bargs); + if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d + 1) + Mesh2Bemtool(ThV, node_output); + else if (Vh.MaxNbNodePerElement == 1) { + int m = Vh.NbOfDF; + typename Mesh2::RdHat pbt(1. / (Mesh2::RdHat::d + 1), 1. / (Mesh2::RdHat::d + 1)); + for (int i = 0; i < m; i++) { + Fem2D::R3 p = ThV[i](pbt); + bemtool::R3 q; + q[0] = p.x; + q[1] = p.y; + q[2] = p.z; + node_output.setnodes(q); } - else - ffassert(0); - ff_POT_Generator_Maxwell(ctx->generator,Pot,*ctx->dof,*mesh,node_output); + } else + ffassert(0); + ff_POT_Generator_Maxwell< PetscScalar, P >(ctx->generator, Pot, *ctx->dof, *mesh, node_output); } if (same) { - PetscContainer ptr; - PetscObjectQuery((PetscObject)B->_petsc, "HtoolCtx", (PetscObject*)&ptr); - PetscContainerDestroy(&ptr); - Assembly(B,ctx,ds.sparams,p1,p1,MPI_COMM_NULL,Mesh1::RdHat::d+1,ds.sym); - PetscContainerCreate(PetscObjectComm((PetscObject)B->_petsc), &ptr); - PetscContainerSetPointer(ptr, ctx); + PetscContainer ptr; + PetscObjectQuery((PetscObject)B->_petsc, "HtoolCtx", (PetscObject*)&ptr); + PetscContainerDestroy(&ptr); + Assembly(B, ctx, ds.sparams, p1, p1, MPI_COMM_NULL, Mesh1::RdHat::d + 1, ds.sym); + PetscContainerCreate(PetscObjectComm((PetscObject)B->_petsc), &ptr); + PetscContainerSetPointer(ptr, ctx); #if PETSC_VERSION_GE(3, 23, 0) - PetscContainerSetCtxDestroy(ptr, DestroyHtoolCtx); + PetscContainerSetCtxDestroy(ptr, DestroyHtoolCtx< P, MeshBemtool >); #else - PetscContainerSetUserDestroy(ptr, DestroyHtoolCtx); + PetscContainerSetUserDestroy(ptr, DestroyHtoolCtx< P, MeshBemtool >); #endif - PetscObjectCompose((PetscObject)B->_petsc, "HtoolCtx", (PetscObject)ptr); - } - else { - Assembly(B,ctx,ds.sparams,p1,p2,MPI_COMM_NULL,Mesh1::RdHat::d+1,ds.sym); - delete ctx; + PetscObjectCompose((PetscObject)B->_petsc, "HtoolCtx", (PetscObject)ptr); + } else { + Assembly(B, ctx, ds.sparams, p1, p2, MPI_COMM_NULL, Mesh1::RdHat::d + 1, ds.sym); + delete ctx; } -} + } -template::type* = nullptr > -void dispatch(MeshBemtool *mesh, bemtool::Geometry *node, int VFBEM, Stack stack, const list& bargs, const Data_Sparse_Solver& ds, Dmat* B, const Mesh2& ThV, std::vector& p1, std::vector& p2, bool same, const FESpace2& Vh) { - HtoolCtx* ctx = new HtoolCtx; - ctx->dof = new_dof

(mesh); + template< typename P, typename MeshBemtool, typename Mesh1, bool T, typename Mesh2, typename FESpace2, typename std::enable_if< T >::type* = nullptr > + void dispatch(MeshBemtool* mesh, bemtool::Geometry* node, int VFBEM, Stack stack, const list< C_F0 >& bargs, const Data_Sparse_Solver& ds, Dmat* B, const Mesh2& ThV, std::vector< double >& p1, + std::vector< double >& p2, bool same, const FESpace2& Vh) { + HtoolCtx< P, MeshBemtool >* ctx = new HtoolCtx< P, MeshBemtool >; + ctx->dof = new_dof< P >(mesh); ctx->mesh = mesh; ctx->node = node; bemtool::Geometry node_output; if (VFBEM == 1) { - pair> kernel = getBemKernel(stack, bargs); - BemKernel *Ker = kernel.first; - std::complex alpha = kernel.second; - ff_BIO_Generator(ctx->generator,Ker,*ctx->dof,alpha); - } - else if (VFBEM == 2) { - BemPotential *Pot = getBemPotential(stack, bargs); - if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d+1) - Mesh2Bemtool(ThV,node_output); - else if (Vh.MaxNbNodePerElement == 1) { - int m = Vh.NbOfDF; - typename Mesh2::RdHat pbt(1./(Mesh2::RdHat::d+1),1./(Mesh2::RdHat::d+1)); - for (int i=0; i > kernel = getBemKernel(stack, bargs); + BemKernel* Ker = kernel.first; + std::complex< double > alpha = kernel.second; + ff_BIO_Generator< PetscScalar, P, Mesh1 >(ctx->generator, Ker, *ctx->dof, alpha); + } else if (VFBEM == 2) { + BemPotential* Pot = getBemPotential(stack, bargs); + if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d + 1) + Mesh2Bemtool(ThV, node_output); + else if (Vh.MaxNbNodePerElement == 1) { + int m = Vh.NbOfDF; + typename Mesh2::RdHat pbt(1. / (Mesh2::RdHat::d + 1), 1. / (Mesh2::RdHat::d + 1)); + for (int i = 0; i < m; i++) { + Fem2D::R3 p = ThV[i](pbt); + bemtool::R3 q; + q[0] = p.x; + q[1] = p.y; + q[2] = p.z; + node_output.setnodes(q); } - else - ffassert(0); - ff_POT_Generator(ctx->generator,Pot,*ctx->dof,*mesh,node_output); + } else + ffassert(0); + ff_POT_Generator< PetscScalar, P, MeshBemtool, Mesh1 >(ctx->generator, Pot, *ctx->dof, *mesh, node_output); } if (same) { - PetscContainer ptr; - PetscObjectQuery((PetscObject)B->_petsc, "HtoolCtx", (PetscObject*)&ptr); - PetscContainerDestroy(&ptr); - Assembly(B,ctx,ds.sparams,p1,p1,MPI_COMM_NULL,Mesh1::RdHat::d+1,ds.sym); - PetscContainerCreate(PetscObjectComm((PetscObject)B->_petsc), &ptr); - PetscContainerSetPointer(ptr, ctx); + PetscContainer ptr; + PetscObjectQuery((PetscObject)B->_petsc, "HtoolCtx", (PetscObject*)&ptr); + PetscContainerDestroy(&ptr); + Assembly(B, ctx, ds.sparams, p1, p1, MPI_COMM_NULL, Mesh1::RdHat::d + 1, ds.sym); + PetscContainerCreate(PetscObjectComm((PetscObject)B->_petsc), &ptr); + PetscContainerSetPointer(ptr, ctx); #if PETSC_VERSION_GE(3, 23, 0) - PetscContainerSetCtxDestroy(ptr, DestroyHtoolCtx); + PetscContainerSetCtxDestroy(ptr, DestroyHtoolCtx< P, MeshBemtool >); #else - PetscContainerSetUserDestroy(ptr, DestroyHtoolCtx); + PetscContainerSetUserDestroy(ptr, DestroyHtoolCtx< P, MeshBemtool >); #endif - PetscObjectCompose((PetscObject)B->_petsc, "HtoolCtx", (PetscObject)ptr); - } - else { - Assembly(B,ctx,ds.sparams,p1,p2,MPI_COMM_NULL,Mesh1::RdHat::d+1,ds.sym); - delete ctx; + PetscObjectCompose((PetscObject)B->_petsc, "HtoolCtx", (PetscObject)ptr); + } else { + Assembly(B, ctx, ds.sparams, p1, p2, MPI_COMM_NULL, Mesh1::RdHat::d + 1, ds.sym); + delete ctx; } -} + } -template::value >::type* = nullptr > -void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& PVh, bool same, int VFBEM, Stack stack, const list& bargs, const Data_Sparse_Solver& ds, Dmat* B) { - if (VFBEM == 1) - ffassert(same); + template< class fes1, class fes2, typename std::enable_if< (fes1::FESpace::Mesh::RdHat::d < 3) && !std::is_same< typename fes1::FESpace::Mesh, Mesh >::value >::type* = nullptr > + void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& PVh, bool same, int VFBEM, Stack stack, const list< C_F0 >& bargs, const Data_Sparse_Solver& ds, Dmat* B) { + if (VFBEM == 1) ffassert(same); typedef typename fes1::pfes pfes1; typedef typename fes1::FESpace FESpace1; typedef typename FESpace1::Mesh Mesh1; @@ -227,24 +229,24 @@ void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& typedef typename fes2::FESpace FESpace2; typedef typename FESpace2::Mesh Mesh2; - typedef typename std::conditional::type MeshBemtool; - typedef typename std::conditional::type P0; - typedef typename std::conditional::type P1; - typedef typename std::conditional::type P2; + typedef typename std::conditional< Mesh1::RdHat::d == 1, bemtool::Mesh1D, bemtool::Mesh2D >::type MeshBemtool; + typedef typename std::conditional< Mesh1::RdHat::d == 1, bemtool::P0_1D, bemtool::P0_2D >::type P0; + typedef typename std::conditional< Mesh1::RdHat::d == 1, bemtool::P1_1D, bemtool::P1_2D >::type P1; + typedef typename std::conditional< Mesh1::RdHat::d == 1, bemtool::P2_1D, bemtool::P2_2D >::type P2; const FESpace1& Uh = *PUh; const FESpace2& Vh = *PVh; - const Mesh1& ThU = Uh.Th; // line - const Mesh2& ThV = Vh.Th; // colunm + const Mesh1& ThU = Uh.Th; // line + const Mesh2& ThV = Vh.Th; // colunm int n = Uh.NbOfDF; int m = Vh.NbOfDF; - bemtool::Geometry *node = new bemtool::Geometry; - MeshBemtool *mesh = new MeshBemtool; + bemtool::Geometry* node = new bemtool::Geometry; + MeshBemtool* mesh = new MeshBemtool; Mesh2Bemtool(ThU, *node, *mesh); - vector p1; - p1.reserve(3*n); - vector p2; - typename Mesh1::RdHat pbs(1./(Mesh1::RdHat::d+1),1./(Mesh1::RdHat::d+1)); + vector< double > p1; + p1.reserve(3 * n); + vector< double > p2; + typename Mesh1::RdHat pbs(1. / (Mesh1::RdHat::d + 1), 1. / (Mesh1::RdHat::d + 1)); int Snbv = Uh.TFE[0]->ndfonVertex; int Snbe = Uh.TFE[0]->ndfonEdge; int Snbt = Uh.TFE[0]->ndfonFace; @@ -253,136 +255,130 @@ void varfBem(const typename fes1::FESpace*& PUh, const typename fes2::FESpace*& bool SP2 = (Snbv == 1) && (Snbe == 1) && (Snbt == 0); bool SRT0 = (Mesh1::RdHat::d == 2) && (Snbv == 0) && (Snbe == 1) && (Snbt == 0); if (SP2) { - bemtool::Dof dof(*mesh,true); - for (int i=0; i& j = dof.ToElt(i); - bemtool::R3 p = dof(j[0][0])[j[0][1]]; - p1.emplace_back(p[0]); - p1.emplace_back(p[1]); - p1.emplace_back(p[2]); - } - } - else if (SRT0) { - bemtool::Dof dof(*mesh); - for (int i=0; i& j = dof.ToElt(i); - bemtool::R3 p = dof(j[0][0])[j[0][1]]; - p1.emplace_back(p[0]); - p1.emplace_back(p[1]); - p1.emplace_back(p[2]); - } - } - else { - for (int i=0; i dof(*mesh, true); + for (int i = 0; i < n; i++) { + const std::vector< bemtool::N2 >& j = dof.ToElt(i); + bemtool::R3 p = dof(j[0][0])[j[0][1]]; + p1.emplace_back(p[0]); + p1.emplace_back(p[1]); + p1.emplace_back(p[2]); + } + } else if (SRT0) { + bemtool::Dof< bemtool::RT0_2D > dof(*mesh); + for (int i = 0; i < n; i++) { + const std::vector< bemtool::N2 >& j = dof.ToElt(i); + bemtool::R3 p = dof(j[0][0])[j[0][1]]; + p1.emplace_back(p[0]); + p1.emplace_back(p[1]); + p1.emplace_back(p[2]); + } + } else { + for (int i = 0; i < n; i++) { + Fem2D::R3 p; + if (SP1) + p = ThU.vertices[i]; + else if (SP0) + p = ThU[i](pbs); + else { + if (mpirank == 0) std::cerr << "ff-BemTool error: only P0, P1 and P2 discretizations are available for now." << std::endl; + ffassert(0); } + p1.emplace_back(p.x); + p1.emplace_back(p.y); + p1.emplace_back(p.z); + } } if (!same) { - if(Vh.TFE[0]->N == 1) { - typename Mesh2::RdHat pbt(1./(Mesh2::RdHat::d+1),1./(Mesh2::RdHat::d+1)); - p2.reserve(3*m); - for (int i=0; iN == 1) { + typename Mesh2::RdHat pbt(1. / (Mesh2::RdHat::d + 1), 1. / (Mesh2::RdHat::d + 1)); + p2.reserve(3 * m); + for (int i = 0; i < m; i++) { + Fem2D::R3 p; + if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d + 1) + p = ThV.vertices[i]; + else if (Vh.MaxNbNodePerElement == 1) + p = ThV[i](pbt); + else { + if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; + ffassert(0); + } + p2.emplace_back(p.x); + p2.emplace_back(p.y); + p2.emplace_back(p.z); } - else { - ffassert(SRT0 && Mesh1::RdHat::d == 2 && VFBEM == 2); - int nnn = Vh.TFE[0]->N; - - typename Mesh2::RdHat pbt(1./(Mesh2::RdHat::d+1),1./(Mesh2::RdHat::d+1)); - p2.reserve(3*m); - - int mDofScalar = m/nnn; // computation of the dof of one component - - for (int i=0; iN; + + typename Mesh2::RdHat pbt(1. / (Mesh2::RdHat::d + 1), 1. / (Mesh2::RdHat::d + 1)); + p2.reserve(3 * m); + + int mDofScalar = m / nnn; // computation of the dof of one component + + for (int i = 0; i < mDofScalar; i++) { + Fem2D::R3 p; + if (Vh.MaxNbNodePerElement == Mesh2::RdHat::d + 1) + p = ThV.vertices[i]; + else if (Vh.MaxNbNodePerElement == 1) + p = ThV[i](pbt); + else { + if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; + ffassert(0); + } + for (int iii = 0; iii < nnn; iii++) { + ffassert(nnn * 3 * i + 3 * iii + 2 < nnn * 3 * m); + p2.emplace_back(p.x); + p2.emplace_back(p.y); + p2.emplace_back(p.z); + } } + } } if (SP1) - dispatch(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); + dispatch< P1, MeshBemtool, Mesh1, true >(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); else if (SP0) - dispatch(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); + dispatch< P0, MeshBemtool, Mesh1, true >(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); else if (SP2) - dispatch(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); + dispatch< P2, MeshBemtool, Mesh1, true >(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); else if (SRT0 && Mesh1::RdHat::d == 2) { - dispatch(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); - } - else - ffassert(0); -} -} // namespace PETSc + dispatch< bemtool::RT0_2D, MeshBemtool, Mesh1, false >(mesh, node, VFBEM, stack, bargs, ds, B, ThV, p1, p2, same, Vh); + } else + ffassert(0); + } +} // namespace PETSc #endif namespace PETSc { - template + template< class K, class MMesh, class fes1, class fes2 > struct varfToMat : public OneOperator { class Op : public E_F0mps { - public: - Call_FormBilinear* b; + public: + Call_FormBilinear< fes1, fes2 >* b; Expression a; - AnyType operator()(Stack s) const; + AnyType operator( )(Stack s) const; - Op(Expression x, Expression y) : b(new Call_FormBilinear(*dynamic_cast*>(y))), a(x) { - ffassert(b && b->nargs); - ffassert(FieldOfForm(b->largs, IsComplexType>::value) == IsComplexType>::value); + Op(Expression x, Expression y) : b(new Call_FormBilinear< fes1, fes2 >(*dynamic_cast< const Call_FormBilinear< fes1, fes2 >* >(y))), a(x) { + ffassert(b && b->nargs); + ffassert(FieldOfForm(b->largs, IsComplexType< upscaled_type< K > >::value) == IsComplexType< upscaled_type< K > >::value); - #if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) - // Check the nbitem of inconnu and test in BemFormBilinear - checkNbItemFEspacesInconnuAndTest(b->largs,b->N,b->M); - #endif +#if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) + // Check the nbitem of inconnu and test in BemFormBilinear + checkNbItemFEspacesInconnuAndTest(b->largs, b->N, b->M); +#endif } - operator aType () const { return atype(); } + operator aType( ) const { return atype< Dmat* >( ); } }; - E_F0* code(const basicAC_F0& args) const { - return new Op(to(args[0]), args[1]); - } - varfToMat() : OneOperator(atype(), atype(), atype*>()) {} + E_F0* code(const basicAC_F0& args) const { return new Op(to< Dmat* >(args[0]), args[1]); } + varfToMat( ) : OneOperator(atype< Dmat* >( ), atype< Dmat* >( ), atype< const Call_FormBilinear< fes1, fes2 >* >( )) {} }; - template::value >::type* = nullptr > + template< class fes1, class fes2, typename std::enable_if< std::is_same< fes1, fes2 >::value >::type* = nullptr > void assert_ptr(fes1* pUh, fes2* pVh) { ffassert(pUh == pVh); } - template::value >::type* = nullptr > - void assert_ptr(fes1* pUh, fes2* pVh) { } - template - AnyType varfToMat::Op::operator()(Stack stack) const { + template< class fes1, class fes2, typename std::enable_if< !std::is_same< fes1, fes2 >::value >::type* = nullptr > + void assert_ptr(fes1* pUh, fes2* pVh) {} + template< class K, class MMesh, class fes1, class fes2 > + AnyType varfToMat< K, MMesh, fes1, fes2 >::Op::operator( )(Stack stack) const { typedef typename fes1::pfes pfes1; typedef typename fes1::FESpace FESpace1; typedef typename FESpace1::Mesh Mesh1; @@ -392,8 +388,8 @@ namespace PETSc { typedef typename FESpace2::Mesh Mesh2; ffassert(b && b->nargs); - pfes1* pUh = GetAny((*b->euh)(stack)); - pfes2* pVh = GetAny((*b->evh)(stack)); + pfes1* pUh = GetAny< pfes1* >((*b->euh)(stack)); + pfes2* pVh = GetAny< pfes2* >((*b->evh)(stack)); const FESpace1* PUh = (FESpace1*)**pUh; const FESpace2* PVh = (FESpace2*)**pVh; @@ -401,11 +397,11 @@ namespace PETSc { ds.factorize = 0; ds.initmat = true; int np = OpCall_FormBilinear_np::n_name_param - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver>(stack, ds, b->nargs, np); + SetEnd_Data_Sparse_Solver< upscaled_type< K > >(stack, ds, b->nargs, np); WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); - Dmat& B(*GetAny((*a)(stack))); + Dmat& B(*GetAny< Dmat* >((*a)(stack))); const FESpace1& Uh = *PUh; const FESpace2& Vh = *PVh; bool same = isSameMesh(b->largs, PUh ? &Uh.Th : nullptr, PVh ? &Vh.Th : nullptr, stack); @@ -415,93 +411,81 @@ namespace PETSc { int VFBEM = -1; #endif if (VFBEM == -1) { - Matrice_Creuse> A; - A.init(); - if(same) { - if(PUh && PVh) { - if(A.Uh != Uh || A.Vh != Vh) { + Matrice_Creuse< upscaled_type< K > > A; + A.init( ); + if (same) { + if (PUh && PVh) { + if (A.Uh != Uh || A.Vh != Vh) { A.Uh = Uh; A.Vh = Vh; - if(ds.sym) { - A.A.master(new MatriceMorse>(Vh.NbOfDF, Vh.NbOfDF, 0, ds.sym)); + if (ds.sym) { + A.A.master(new MatriceMorse< upscaled_type< K > >(Vh.NbOfDF, Vh.NbOfDF, 0, ds.sym)); assert_ptr(&Uh, &Vh); - } - else - A.A.master(new MatriceMorse>(Vh.NbOfDF, Uh.NbOfDF, 2 * Vh.NbOfDF, 0)); - } - if(AssembleVarForm, MatriceCreuse>, MMesh, FESpace1,FESpace2>(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, b->largs)) - AssembleBC, MMesh,FESpace1, FESpace2>(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, 0, b->largs, ds.tgv); + } else + A.A.master(new MatriceMorse< upscaled_type< K > >(Vh.NbOfDF, Uh.NbOfDF, 2 * Vh.NbOfDF, 0)); } - else - A.A.master(new MatriceMorse>(PVh ? Vh.NbOfDF : 0, PUh ? Uh.NbOfDF : 0, 0, 0)); - } - else { - MatriceMorse> *pMA = new MatriceMorse>(PVh ? Vh.NbOfDF : 0, PUh ? Uh.NbOfDF : 0, 0, ds.sym); - MatriceMap>& D = *pMA; + if (AssembleVarForm< upscaled_type< K >, MatriceCreuse< upscaled_type< K > >, MMesh, FESpace1, FESpace2 >(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, b->largs)) + AssembleBC< upscaled_type< K >, MMesh, FESpace1, FESpace2 >(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, 0, b->largs, ds.tgv); + } else + A.A.master(new MatriceMorse< upscaled_type< K > >(PVh ? Vh.NbOfDF : 0, PUh ? Uh.NbOfDF : 0, 0, 0)); + } else { + MatriceMorse< upscaled_type< K > >* pMA = new MatriceMorse< upscaled_type< K > >(PVh ? Vh.NbOfDF : 0, PUh ? Uh.NbOfDF : 0, 0, ds.sym); + MatriceMap< upscaled_type< K > >& D = *pMA; bool bc = false; - if (PUh && PVh) - bc = AssembleVarForm, MatriceMap>, MMesh, FESpace1,FESpace2>(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, &D, 0, b->largs); + if (PUh && PVh) bc = AssembleVarForm< upscaled_type< K >, MatriceMap< upscaled_type< K > >, MMesh, FESpace1, FESpace2 >(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, &D, 0, b->largs); A.A.master(pMA); - if(bc) - AssembleBC>(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, 0, b->largs, ds.tgv); + if (bc) AssembleBC< upscaled_type< K > >(stack, *((MMesh*)&PUh->Th), Uh, Vh, ds.sym, A.A, 0, 0, b->largs, ds.tgv); } changeOperatorSimple(&B, &A); - if(B._A) - B._A->setMatrix(nullptr); + if (B._A) B._A->setMatrix(nullptr); } #if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) else { - varfBem(PUh, PVh, same, VFBEM, stack, b->largs, ds, &B); + varfBem< fes1, fes2 >(PUh, PVh, same, VFBEM, stack, b->largs, ds, &B); } #endif - return SetAny(&B); + return SetAny< Dmat* >(&B); } -} // namespace PETSc +} // namespace PETSc namespace PETSc { template< class Type > struct _n_User; template< class Type > using User = _n_User< Type >*; - template< bool C, class HpddmType, - typename std::enable_if< std::is_same< HpddmType, Dmat >::value >::type* = nullptr > - void initPETScStructure( - HpddmType* ptA, PetscInt bs, PetscBool symmetric, - KN< typename std::conditional< std::is_same< HpddmType, Dmat >::value, double, long >::type >* ptD) { + template< bool C, class HpddmType, typename std::enable_if< std::is_same< HpddmType, Dmat >::value >::type* = nullptr > + void initPETScStructure(HpddmType* ptA, PetscInt bs, PetscBool symmetric, KN< typename std::conditional< std::is_same< HpddmType, Dmat >::value, double, long >::type >* ptD) { double timing = MPI_Wtime( ); long long global; if (ptD) { - if(!ptA->_D) { - PetscReal* d = reinterpret_cast(ptD->operator double*()); - if(!std::is_same, PetscReal>::value) { - for(int i = 0; i < ptD->n; ++i) - d[i] = ptD->operator[](i); + if (!ptA->_D) { + PetscReal* d = reinterpret_cast< PetscReal* >(ptD->operator double*( )); + if (!std::is_same< upscaled_type< PetscReal >, PetscReal >::value) { + for (int i = 0; i < ptD->n; ++i) d[i] = ptD->operator[](i); } ptA->_A->restriction(d); - if (!C) ptA->_A->initialize(d); + if (!C) + ptA->_A->initialize(d); else { - ptA->_D = new KN(ptD->n); - for(int i = 0; i < ptD->n; ++i) - ptA->_D->operator[](i) = d[i]; + ptA->_D = new KN< PetscReal >(ptD->n); + for (int i = 0; i < ptD->n; ++i) ptA->_D->operator[](i) = d[i]; ptA->_A->initialize(*ptA->_D); } - } - else { + } else { ptA->_A->initialize(*ptA->_D); } } - if (!C && !ptD) global = PETSC_DECIDE; - else ptA->_A->distributedNumbering(ptA->_num, ptA->_first, ptA->_last, global); - if (verbosity > 0 && mpirank == 0) - cout << " --- global numbering created (in " << MPI_Wtime( ) - timing << ")" << endl; + if (!C && !ptD) + global = PETSC_DECIDE; + else + ptA->_A->distributedNumbering(ptA->_num, ptA->_first, ptA->_last, global); + if (verbosity > 0 && mpirank == 0) cout << " --- global numbering created (in " << MPI_Wtime( ) - timing << ")" << endl; timing = MPI_Wtime( ); PetscInt* ia = nullptr; PetscInt* ja = nullptr; PetscScalar* c = nullptr; - bool free = ptA->_A->getMatrix( )->HPDDM_ia - ? ptA->_A->distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, c) - : false; - MatCreate(ptA->_A->getCommunicator(), &ptA->_petsc); + bool free = ptA->_A->getMatrix( )->HPDDM_ia ? ptA->_A->distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, c) : false; + MatCreate(ptA->_A->getCommunicator( ), &ptA->_petsc); if (bs > 1) MatSetBlockSize(ptA->_petsc, bs); MatSetSizes(ptA->_petsc, ptA->_last - ptA->_first, ptA->_last - ptA->_first, global, global); bool sym = ptA->_A->getMatrix( )->HPDDM_sym; @@ -527,31 +511,24 @@ namespace PETSc { delete[] c; } ptA->_A->setBuffer( ); - if (verbosity > 0 && mpirank == 0) - cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; + if (verbosity > 0 && mpirank == 0) cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; } - template< bool C, class HpddmType, - typename std::enable_if< !std::is_same< HpddmType, Dmat >::value >::type* = nullptr > - void initPETScStructure( - HpddmType* ptA, PetscInt& bs, PetscBool symmetric, - KN< typename std::conditional< std::is_same< HpddmType, Dmat >::value, double, long >::type >* ptD) { + template< bool C, class HpddmType, typename std::enable_if< !std::is_same< HpddmType, Dmat >::value >::type* = nullptr > + void initPETScStructure(HpddmType* ptA, PetscInt& bs, PetscBool symmetric, KN< typename std::conditional< std::is_same< HpddmType, Dmat >::value, double, long >::type >* ptD) { const HPDDM::MatrixCSR< PetscScalar >* M = ptA->_A->getMatrix( ); if (!M->HPDDM_sym) cout << "Please assemble a symmetric CSR" << endl; double timing = MPI_Wtime( ); ptA->_A->template renumber< false >(STL< long >(*ptD), nullptr); long long global; ptA->_A->distributedNumbering(ptA->_num, ptA->_first, ptA->_last, global); - if (verbosity > 0 && mpirank == 0) - cout << " --- global numbering created (in " << MPI_Wtime( ) - timing << ")" << endl; + if (verbosity > 0 && mpirank == 0) cout << " --- global numbering created (in " << MPI_Wtime( ) - timing << ")" << endl; timing = MPI_Wtime( ); PetscInt* indices; PetscMalloc(sizeof(PetscInt) * M->HPDDM_n / bs, &indices); for (unsigned int i = 0; i < M->HPDDM_n; i += bs) indices[i / bs] = ptA->_num[i] / bs; ISLocalToGlobalMapping rmap; - ISLocalToGlobalMappingCreate(ptA->_A->getCommunicator(), bs, M->HPDDM_n / bs, indices, PETSC_OWN_POINTER, - &rmap); - MatCreateIS(ptA->_A->getCommunicator(), bs, PETSC_DECIDE, PETSC_DECIDE, global, global, rmap, NULL, - &ptA->_petsc); + ISLocalToGlobalMappingCreate(ptA->_A->getCommunicator( ), bs, M->HPDDM_n / bs, indices, PETSC_OWN_POINTER, &rmap); + MatCreateIS(ptA->_A->getCommunicator( ), bs, PETSC_DECIDE, PETSC_DECIDE, global, global, rmap, NULL, &ptA->_petsc); Mat local; MatISGetLocalMat(ptA->_petsc, &local); MatSetType(local, MATSEQSBAIJ); @@ -560,14 +537,11 @@ namespace PETSc { for (int i = 0; i < transpose.size( ); ++i) for (int j = M->HPDDM_ia[i]; j < M->HPDDM_ia[i + 1]; ++j) { transpose[M->HPDDM_ja[j]].emplace_back(i, M->HPDDM_a[j]); - if (bs > 1 && (i - M->HPDDM_ja[j] <= (i % bs)) && M->HPDDM_ja[j] != i) - transpose[i].emplace_back(M->HPDDM_ja[j], M->HPDDM_a[j]); + if (bs > 1 && (i - M->HPDDM_ja[j] <= (i % bs)) && M->HPDDM_ja[j] != i) transpose[i].emplace_back(M->HPDDM_ja[j], M->HPDDM_a[j]); } int nnz = 0; for (int i = 0; i < transpose.size( ); ++i) { - std::sort(transpose[i].begin( ), transpose[i].end( ), - [](const std::pair< int, PetscScalar >& lhs, - const std::pair< int, PetscScalar >& rhs) { return lhs.first < rhs.first; }); + std::sort(transpose[i].begin( ), transpose[i].end( ), [](const std::pair< int, PetscScalar >& lhs, const std::pair< int, PetscScalar >& rhs) { return lhs.first < rhs.first; }); nnz += transpose[i].size( ); } PetscInt* ia = new PetscInt[M->HPDDM_n / bs + 1]; @@ -577,8 +551,7 @@ namespace PETSc { for (int i = 0; i < transpose.size( ); ++i) { for (int j = 0; j < transpose[i].size( ); ++j) { if (i % bs == 0 && j % bs == 0) ja[ia[i / bs] + j / bs] = transpose[i][j].first / bs; - a[ia[i / bs] * (bs * bs) + j % bs + (j / bs) * (bs * bs) + (i % bs) * bs] = - transpose[i][j].second; + a[ia[i / bs] * (bs * bs) + j % bs + (j / bs) * (bs * bs) + (i % bs) * bs] = transpose[i][j].second; } if (i % bs == 0) ia[i / bs + 1] = ia[i / bs] + transpose[i].size( ) / bs; } @@ -608,8 +581,7 @@ namespace PETSc { ISDestroy(&to); // ISLocalToGlobalMappingView(rmap, PETSC_VIEWER_STDOUT_WORLD); ISLocalToGlobalMappingDestroy(&rmap); - if (verbosity > 0 && mpirank == 0) - cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; + if (verbosity > 0 && mpirank == 0) cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; } template< class Type, class K > long globalNumbering(Type* const& A, KN< K >* const& numbering) { @@ -623,14 +595,10 @@ namespace PETSc { static Mat ff_to_PETSc(const HPDDM::MatrixCSR< PetscScalar >* const A) { Mat aux; if (A->HPDDM_sym) { - std::vector< std::pair< int, int > >* transpose = - new std::vector< std::pair< int, int > >[A->HPDDM_n]( ); + std::vector< std::pair< int, int > >* transpose = new std::vector< std::pair< int, int > >[A->HPDDM_n]( ); for (int i = 0; i < A->HPDDM_n; ++i) - for (int j = A->HPDDM_ia[i] - (HPDDM_NUMBERING == 'F'); - j < A->HPDDM_ia[i + 1] - (HPDDM_NUMBERING == 'F'); ++j) - transpose[A->HPDDM_ja[j] - (HPDDM_NUMBERING == 'F')].emplace_back(i, j); - for (int i = 0; i < A->HPDDM_n; ++i) - std::sort(transpose[i].begin( ), transpose[i].end( )); + for (int j = A->HPDDM_ia[i] - (HPDDM_NUMBERING == 'F'); j < A->HPDDM_ia[i + 1] - (HPDDM_NUMBERING == 'F'); ++j) transpose[A->HPDDM_ja[j] - (HPDDM_NUMBERING == 'F')].emplace_back(i, j); + for (int i = 0; i < A->HPDDM_n; ++i) std::sort(transpose[i].begin( ), transpose[i].end( )); PetscInt* ia = new PetscInt[A->HPDDM_n + 1]; PetscInt* ja = new PetscInt[A->HPDDM_nnz]; PetscScalar* c = new PetscScalar[A->HPDDM_nnz]; @@ -651,8 +619,8 @@ namespace PETSc { delete[] c; delete[] ja; delete[] ia; - } else if(std::is_sameHPDDM_ia), PetscInt>::value) - MatCreateSeqAIJWithArrays(PETSC_COMM_SELF, A->HPDDM_n, A->HPDDM_m, reinterpret_cast(A->HPDDM_ia), reinterpret_cast(A->HPDDM_ja), A->HPDDM_a, &aux); + } else if (std::is_same< decltype(A->HPDDM_ia), PetscInt >::value) + MatCreateSeqAIJWithArrays(PETSC_COMM_SELF, A->HPDDM_n, A->HPDDM_m, reinterpret_cast< PetscInt* >(A->HPDDM_ia), reinterpret_cast< PetscInt* >(A->HPDDM_ja), A->HPDDM_a, &aux); else { MatCreate(PETSC_COMM_SELF, &aux); MatSetSizes(aux, A->HPDDM_n, A->HPDDM_n, A->HPDDM_n, A->HPDDM_n); @@ -675,45 +643,45 @@ namespace PETSc { return aux; } template< class Type > - long ParMmgCommunicators(Type* const& A, KN< double >* const& gamma, KN< long >* const& rest, KN< KN< long >>* const& communicators) { + long ParMmgCommunicators(Type* const& A, KN< double >* const& gamma, KN< long >* const& rest, KN< KN< long > >* const& communicators) { if (A && A->_petsc && A->_A) { - std::unordered_map> map; - PetscScalar* val = new PetscScalar[A->_A->getDof()](); - for(int i = 0; i < rest->n; ++i) { - if(std::abs(gamma->operator[](i) - 1.0) < 1.0e-6) { + std::unordered_map< int, std::pair< int, PetscInt > > map; + PetscScalar* val = new PetscScalar[A->_A->getDof( )]( ); + for (int i = 0; i < rest->n; ++i) { + if (std::abs(gamma->operator[](i) - 1.0) < 1.0e-6) { map[rest->operator[](i)] = std::make_pair(i, A->_num[rest->operator[](i)]); - val[rest->operator[](i)] = HPDDM::Wrapper::d__1; + val[rest->operator[](i)] = HPDDM::Wrapper< PetscScalar >::d__1; } } A->_A->recvBuffer(val); - delete [] val; - PetscScalar** const buffer = A->_A->getBuffer(); - const HPDDM::vectorNeighbor& neighbors = A->_A->getMap(); - communicators->resize(2 * neighbors.size() + 1); - communicators->operator[](0).resize(neighbors.size()); + delete[] val; + PetscScalar** const buffer = A->_A->getBuffer( ); + const HPDDM::vectorNeighbor& neighbors = A->_A->getMap( ); + communicators->resize(2 * neighbors.size( ) + 1); + communicators->operator[](0).resize(neighbors.size( )); unsigned short k = 0; - for(unsigned short i = 0; i < neighbors.size(); ++i) { - communicators->operator[](0)[k] = neighbors[i].first; - communicators->operator[](2 * k + 1).resize(neighbors[i].second.size()); - communicators->operator[](2 * k + 2).resize(neighbors[i].second.size()); - int m = 0; - for(unsigned int j = 0; j < neighbors[i].second.size(); ++j) { - if(std::abs(buffer[i][j] - HPDDM::Wrapper::d__1) < 1.0e-6) { - std::unordered_map>::const_iterator it = map.find(neighbors[i].second[j]); - if(it != map.cend()) { - communicators->operator[](2 * k + 1)[m] = it->second.first + 1; - communicators->operator[](2 * k + 2)[m++] = it->second.second + 1; - } - } - } - if(m > 0) { - communicators->operator[](2 * k + 1).resize(m); - communicators->operator[](2 * k + 2).resize(m); - ++k; + for (unsigned short i = 0; i < neighbors.size( ); ++i) { + communicators->operator[](0)[k] = neighbors[i].first; + communicators->operator[](2 * k + 1).resize(neighbors[i].second.size( )); + communicators->operator[](2 * k + 2).resize(neighbors[i].second.size( )); + int m = 0; + for (unsigned int j = 0; j < neighbors[i].second.size( ); ++j) { + if (std::abs(buffer[i][j] - HPDDM::Wrapper< PetscScalar >::d__1) < 1.0e-6) { + std::unordered_map< int, std::pair< int, PetscInt > >::const_iterator it = map.find(neighbors[i].second[j]); + if (it != map.cend( )) { + communicators->operator[](2 * k + 1)[m] = it->second.first + 1; + communicators->operator[](2 * k + 2)[m++] = it->second.second + 1; + } } + } + if (m > 0) { + communicators->operator[](2 * k + 1).resize(m); + communicators->operator[](2 * k + 2).resize(m); + ++k; + } } int size; - MPI_Comm_size(A->_A->getCommunicator(), &size); + MPI_Comm_size(A->_A->getCommunicator( ), &size); ffassert(size == 1 || k); communicators->operator[](0).resize(k); communicators->resize(2 * k + 1); @@ -736,7 +704,7 @@ namespace PETSc { args.SetNameParam(n_name_param, name_param, nargs); A = to< Type* >(args[0]); if (c == 0) - B = to< Matrice_Creuse< upscaled_type >* >(args[1]); + B = to< Matrice_Creuse< upscaled_type< PetscScalar > >* >(args[1]); else B = to< Type* >(args[1]); } @@ -745,23 +713,17 @@ namespace PETSc { operator aType( ) const { return atype< long >( ); } }; E_F0* code(const basicAC_F0& args) const { return new changeOperator_Op(args, c); } - changeOperator( ) - : OneOperator(atype< long >( ), atype< Type* >( ), - atype< Matrice_Creuse< upscaled_type >* >( )), - c(0) {} - changeOperator(int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( )), c(1) {} + changeOperator( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Matrice_Creuse< upscaled_type< PetscScalar > >* >( )), c(0) {} + changeOperator(int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( )), c(1) {} }; template< class Type > - basicAC_F0::name_and_type changeOperator< Type >::changeOperator_Op::name_param[] = { - {"restriction", &typeid(Matrice_Creuse< double >*)}, {"parent", &typeid(Type*)}}; + basicAC_F0::name_and_type changeOperator< Type >::changeOperator_Op::name_param[] = {{"restriction", &typeid(Matrice_Creuse< double >*)}, {"parent", &typeid(Type*)}}; template< class Type > - void change(Type* const& ptA, Matrice_Creuse< upscaled_type >* const& mat, Type* const& ptB, - Type* const& ptParent, Matrice_Creuse< double >* const& pList = nullptr) { + void change(Type* const& ptA, Matrice_Creuse< upscaled_type< PetscScalar > >* const& mat, Type* const& ptB, Type* const& ptParent, Matrice_Creuse< double >* const& pList = nullptr) { if (mat) { if (ptA) { - MatriceMorse< upscaled_type >* mN = nullptr; - if (mat->A) mN = static_cast< MatriceMorse< upscaled_type >* >(&*(mat->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mN = nullptr; + if (mat->A) mN = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&*(mat->A)); PetscBool assembled = PETSC_FALSE; if (ptA->_petsc) MatAssembled(ptA->_petsc, &assembled); if (mN) { @@ -785,78 +747,74 @@ namespace PETSc { dM = nullptr; } if (ptA->_A) { - ptA->_A->setMatrix(dN); + ptA->_A->setMatrix(dN); #if defined(PCHPDDM) && defined(PETSC_USE_SHARED_LIBRARIES) - PC pc = nullptr; - if(ptParent) { - PetscInt M, N; - Mat** mat; - MatNestGetSubMats(ptParent->_petsc, &M, &N, &mat); - PetscInt i; - for(i = 0; i < std::min(N, M); ++i) { - if(mat[i][i] == ptA->_petsc) - break; - } - if(i < std::min(N, M)) { - PC parent; - KSPGetPC(ptParent->_ksp, &parent); - PetscBool isType; - PetscObjectTypeCompare((PetscObject)parent, PCFIELDSPLIT, &isType); - if(isType) { - KSP *subksp; - PetscInt nsplits; - PCFieldSplitGetSubKSP(parent, &nsplits, &subksp); - KSPGetPC(subksp[i], &pc); - PetscFree(subksp); - } - } + PC pc = nullptr; + if (ptParent) { + PetscInt M, N; + Mat** mat; + MatNestGetSubMats(ptParent->_petsc, &M, &N, &mat); + PetscInt i; + for (i = 0; i < std::min(N, M); ++i) { + if (mat[i][i] == ptA->_petsc) break; } - else if(ptA->_ksp) { - KSPGetPC(ptA->_ksp, &pc); + if (i < std::min(N, M)) { + PC parent; + KSPGetPC(ptParent->_ksp, &parent); + PetscBool isType; + PetscObjectTypeCompare((PetscObject)parent, PCFIELDSPLIT, &isType); + if (isType) { + KSP* subksp; + PetscInt nsplits; + PCFieldSplitGetSubKSP(parent, &nsplits, &subksp); + KSPGetPC(subksp[i], &pc); + PetscFree(subksp); + } } - if(pc) { - PCType type; - PCGetType(pc, &type); - PetscBool isType; - PetscStrcmp(type, PCHPDDM, &isType); - if(isType) { - const HPDDM::MatrixCSR* const A = ptA->_A->getMatrix(); - Mat aux = ff_to_PETSc(A); - Mat N; - PetscObjectQuery((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject*)&N); - if(!N) { - PetscInt* idx; - PetscMalloc1(dN->HPDDM_n, &idx); - std::copy_n(ptA->_num, dN->HPDDM_n, idx); - IS is; - ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getMatrix()->HPDDM_n, idx, PETSC_OWN_POINTER, &is); - PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); - if (!A->HPDDM_sym && ptA->_petsc) { - PetscInt bs; - MatGetBlockSize(ptA->_petsc, &bs); - if (bs > 1) { - ISSetBlockSize(is, bs); - MatSetBlockSize(aux, bs); - } - } - PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL); - PCSetFromOptions(pc); - MatDestroy(&aux); - ISDestroy(&is); - } - else { - PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); - if (!A->HPDDM_sym && ptA->_petsc) { - PetscInt bs; - MatGetBlockSize(ptA->_petsc, &bs); - if (bs > 1) - MatSetBlockSize(aux, bs); - } - PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL); - MatDestroy(&aux); - } + } else if (ptA->_ksp) { + KSPGetPC(ptA->_ksp, &pc); + } + if (pc) { + PCType type; + PCGetType(pc, &type); + PetscBool isType; + PetscStrcmp(type, PCHPDDM, &isType); + if (isType) { + const HPDDM::MatrixCSR< PetscScalar >* const A = ptA->_A->getMatrix( ); + Mat aux = ff_to_PETSc(A); + Mat N; + PetscObjectQuery((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject*)&N); + if (!N) { + PetscInt* idx; + PetscMalloc1(dN->HPDDM_n, &idx); + std::copy_n(ptA->_num, dN->HPDDM_n, idx); + IS is; + ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getMatrix( )->HPDDM_n, idx, PETSC_OWN_POINTER, &is); + PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); + if (!A->HPDDM_sym && ptA->_petsc) { + PetscInt bs; + MatGetBlockSize(ptA->_petsc, &bs); + if (bs > 1) { + ISSetBlockSize(is, bs); + MatSetBlockSize(aux, bs); + } + } + PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL); + PCSetFromOptions(pc); + MatDestroy(&aux); + ISDestroy(&is); + } else { + PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); + if (!A->HPDDM_sym && ptA->_petsc) { + PetscInt bs; + MatGetBlockSize(ptA->_petsc, &bs); + if (bs > 1) MatSetBlockSize(aux, bs); } + PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL); + MatDestroy(&aux); + } } + } #endif } ffassert(ptA->_num); @@ -867,52 +825,45 @@ namespace PETSc { if (ptA->_cnum) { PetscInt* cnum = ptA->_num + dN->HPDDM_n; if (ptA->_petsc) { - int rank, size, N; - unsigned int flag = mN->nnz && mN->nnz == mN->n * mN->m ? 1 : 0; - MPI_Comm_size(PetscObjectComm((PetscObject)ptA->_petsc), &size); - if (size > 1) { - PetscBool dense; - const PetscInt* ranges; - MatGetOwnershipRangesColumn(ptA->_petsc, &ranges); - MPI_Comm_rank(PetscObjectComm((PetscObject)ptA->_petsc), &rank); - MatGetSize(ptA->_petsc, NULL, &N); - if (ranges[1] == N) { - if (rank != 0) - cnum = new PetscInt[N]; - MPI_Bcast(cnum, N, MPIU_INT, 0, PetscObjectComm((PetscObject)ptA->_petsc)); - } - PetscObjectTypeCompareAny((PetscObject)ptA->_petsc, &dense, MATMPIDENSE, MATSEQDENSE, ""); - if (!dense) - MPI_Allreduce(MPI_IN_PLACE, &flag, 1, MPI_UNSIGNED, MPI_MAX, PetscObjectComm((PetscObject)ptA->_petsc)); - else - flag = true; + int rank, size, N; + unsigned int flag = mN->nnz && mN->nnz == mN->n * mN->m ? 1 : 0; + MPI_Comm_size(PetscObjectComm((PetscObject)ptA->_petsc), &size); + if (size > 1) { + PetscBool dense; + const PetscInt* ranges; + MatGetOwnershipRangesColumn(ptA->_petsc, &ranges); + MPI_Comm_rank(PetscObjectComm((PetscObject)ptA->_petsc), &rank); + MatGetSize(ptA->_petsc, NULL, &N); + if (ranges[1] == N) { + if (rank != 0) cnum = new PetscInt[N]; + MPI_Bcast(cnum, N, MPIU_INT, 0, PetscObjectComm((PetscObject)ptA->_petsc)); } - if (flag) dense = true; - if (dense) - MatSetType(ptA->_petsc, MATDENSE); + PetscObjectTypeCompareAny((PetscObject)ptA->_petsc, &dense, MATMPIDENSE, MATSEQDENSE, ""); + if (!dense) + MPI_Allreduce(MPI_IN_PLACE, &flag, 1, MPI_UNSIGNED, MPI_MAX, PetscObjectComm((PetscObject)ptA->_petsc)); + else + flag = true; + } + if (flag) dense = true; + if (dense) MatSetType(ptA->_petsc, MATDENSE); } - free = HPDDM::template Subdomain< PetscScalar >::distributedCSR( - ptA->_num, ptA->_first, ptA->_last, ia, ja, c, dN, cnum); - if (cnum != ptA->_num + dN->HPDDM_n) - delete [] cnum; - } - else + free = HPDDM::template Subdomain< PetscScalar >::distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, c, dN, cnum); + if (cnum != ptA->_num + dN->HPDDM_n) delete[] cnum; + } else free = ptA->_A->distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, c); if (assembled || dense) { MatSetOption(ptA->_petsc, MAT_NO_OFF_PROC_ENTRIES, PETSC_TRUE); MatZeroEntries(ptA->_petsc); for (PetscInt i = 0; i < ptA->_last - ptA->_first; ++i) { PetscInt row = ptA->_first + i; - MatSetValues(ptA->_petsc, 1, &row, ia[i + 1] - ia[i], - ja + ia[i], c + ia[i], INSERT_VALUES); + MatSetValues(ptA->_petsc, 1, &row, ia[i + 1] - ia[i], ja + ia[i], c + ia[i], INSERT_VALUES); } MatAssemblyBegin(ptA->_petsc, MAT_FINAL_ASSEMBLY); MatAssemblyEnd(ptA->_petsc, MAT_FINAL_ASSEMBLY); } else { if (!ptA->_petsc) { MatCreate(PETSC_COMM_WORLD, &ptA->_petsc); - MatSetSizes(ptA->_petsc, ptA->_last - ptA->_first, ptA->_last - ptA->_first, - PETSC_DECIDE, PETSC_DECIDE); + MatSetSizes(ptA->_petsc, ptA->_last - ptA->_first, ptA->_last - ptA->_first, PETSC_DECIDE, PETSC_DECIDE); } if (ptA->_A && ptA->_A->getMatrix( )->HPDDM_sym) { MatSetType(ptA->_petsc, MATSBAIJ); @@ -930,8 +881,7 @@ namespace PETSc { delete[] ja; delete[] c; } - if (!ptA->_A) - delete dN; + if (!ptA->_A) delete dN; } else if (!assembled) { PetscInt m; MatGetLocalSize(ptA->_petsc, &m, NULL); @@ -991,8 +941,7 @@ namespace PETSc { MatCreateTranspose(C, &D); MatNestSetSubMat(ptParent->_petsc, i, j, D); MatDestroy(&D); - } - else if (norm > PETSC_MACHINE_EPSILON && isType[1]) { + } else if (norm > PETSC_MACHINE_EPSILON && isType[1]) { MatCreateHermitianTranspose(C, &D); MatNestSetSubMat(ptParent->_petsc, i, j, D); MatDestroy(&D); @@ -1057,9 +1006,7 @@ namespace PETSc { ptA->dtor( ); ptA->_petsc = backup; PetscMPIInt flag; - if (ptA->_petsc) - MPI_Comm_compare(PetscObjectComm((PetscObject)ptA->_petsc), - PetscObjectComm((PetscObject)ptB->_petsc), &flag); + if (ptA->_petsc) MPI_Comm_compare(PetscObjectComm((PetscObject)ptA->_petsc), PetscObjectComm((PetscObject)ptB->_petsc), &flag); if (!ptA->_petsc || (flag != MPI_CONGRUENT && flag != MPI_IDENT)) { MatDestroy(&ptA->_petsc); if (ptB->_petsc) { @@ -1094,11 +1041,9 @@ namespace PETSc { template< class Type > AnyType changeOperator< Type >::changeOperator_Op::operator( )(Stack stack) const { Type* ptA = GetAny< Type* >((*A)(stack)); - Matrice_Creuse< upscaled_type >* mat = - c == 0 ? GetAny< Matrice_Creuse< upscaled_type >* >((*B)(stack)) : nullptr; + Matrice_Creuse< upscaled_type< PetscScalar > >* mat = c == 0 ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*B)(stack)) : nullptr; Type* ptB = c != 0 ? GetAny< Type* >((*B)(stack)) : nullptr; - Matrice_Creuse< double >* pList = - nargs[0] ? GetAny< Matrice_Creuse< double >* >((*nargs[0])(stack)) : nullptr; + Matrice_Creuse< double >* pList = nargs[0] ? GetAny< Matrice_Creuse< double >* >((*nargs[0])(stack)) : nullptr; Type* ptParent = nargs[1] ? GetAny< Type* >((*nargs[1])(stack)) : nullptr; change(ptA, mat, ptB, ptParent, pList); return 0L; @@ -1108,59 +1053,52 @@ namespace PETSc { change(dA, nullptr, A, null); return dA; } - Dmat* changeOperatorSimple(Dmat* const& dA, Matrice_Creuse< upscaled_type >* const& A) { + Dmat* changeOperatorSimple(Dmat* const& dA, Matrice_Creuse< upscaled_type< PetscScalar > >* const& A) { Dmat* const null = nullptr; change(dA, A, null, null); return dA; } - template + template< class A, class B > struct scale { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = long; + using result_type = long; static long f(A const& a, const B& b) { MatScale(a->_petsc, PetscScalar(b)); return 0L; } }; - template + template< class A, class B > struct AXPY { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = long; + using result_type = long; static long f(A const& a, const B& b) { MatAXPY(a->_petsc, 1.0, b->_petsc, DIFFERENT_NONZERO_PATTERN); return 0L; } }; - std::pair* toP(Dmat* const& M) { - return new std::pair{1.0, M}; - } - AnyType M2P(Stack, const AnyType& p) { - return toP(GetAny(p)); - } - template + std::pair< PetscScalar, Dmat* >* toP(Dmat* const& M) { return new std::pair< PetscScalar, Dmat* >{1.0, M}; } + AnyType M2P(Stack, const AnyType& p) { return toP(GetAny< Dmat* >(p)); } + template< class K > AnyType AddCombDmat(Stack stack, Expression emat, Expression combMat) { - Dmat* A = GetAny((*emat)(stack)); + Dmat* A = GetAny< Dmat* >((*emat)(stack)); ffassert(A && A->_petsc); - std::pair, Dmat*>* p = GetAny, Dmat*>*>((*combMat)(stack)); + std::pair< upscaled_type< PetscScalar >, Dmat* >* p = GetAny< std::pair< upscaled_type< PetscScalar >, Dmat* >* >((*combMat)(stack)); ffassert(p && p->second && p->second->_petsc); MatAXPY(A->_petsc, PetscScalar(p->first), p->second->_petsc, DIFFERENT_NONZERO_PATTERN); delete p; return A; } - template + template< class K > struct Op2 { - using first_argument_type = K; + using first_argument_type = K; using second_argument_type = Dmat*; - using result_type = std::pair*; - typedef std::pair P; - static P* f(K const& a,Dmat* const& b) { - return new P{a, b}; - } + using result_type = std::pair< K, Dmat* >*; + typedef std::pair< K, Dmat* > P; + static P* f(K const& a, Dmat* const& b) { return new P{a, b}; } }; - long changeSchur(Dmat* const& dA, KN< Matrice_Creuse< upscaled_type > >* const& schurPreconditioner, - KN< double >* const& schurList) { + long changeSchur(Dmat* const& dA, KN< Matrice_Creuse< upscaled_type< PetscScalar > > >* const& schurPreconditioner, KN< double >* const& schurList) { setVectorSchur(dA, schurPreconditioner, schurList); return 0L; } @@ -1174,11 +1112,9 @@ namespace PETSc { PetscInt low; out->resize(in->n); Vec x, y; - VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, in->n, PETSC_DECIDE, - in->operator PetscScalar*(), &x); + VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, in->n, PETSC_DECIDE, in->operator PetscScalar*( ), &x); VecGetOwnershipRange(x, &low, NULL); - VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, in->n, PETSC_DECIDE, - out->operator PetscScalar*(), &y); + VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, in->n, PETSC_DECIDE, out->operator PetscScalar*( ), &y); IS to; PetscInt* idx = new PetscInt[in->n]; @@ -1197,58 +1133,51 @@ namespace PETSc { } long stagePush(string* const& str) { #if defined(PETSC_USE_LOG) - PetscLogStage stage; - PetscLogStageGetId(str->c_str(), &stage); - if(stage == -1) { - PetscLogStageRegister(str->c_str(), &stage); - } - PetscLogStagePush(stage); + PetscLogStage stage; + PetscLogStageGetId(str->c_str( ), &stage); + if (stage == -1) { + PetscLogStageRegister(str->c_str( ), &stage); + } + PetscLogStagePush(stage); #endif - return 0L; + return 0L; } - long stagePop() { + long stagePop( ) { #if defined(PETSC_USE_LOG) - PetscLogStagePop(); + PetscLogStagePop( ); #endif - return 0L; + return 0L; } - double memoryGetCurrentUsage() { - PetscLogDouble mem; - PetscMemoryGetCurrentUsage(&mem); - return mem; + double memoryGetCurrentUsage( ) { + PetscLogDouble mem; + PetscMemoryGetCurrentUsage(&mem); + return mem; } long hasType(string* const& obj, string* const& type) { - if (obj->size() > 0 && type->size() > 0) { - std::string o(*obj); - std::transform(o.begin(), o.end(), o.begin(), ::toupper); - std::string t(*type); - std::transform(t.begin(), t.end(), t.begin(), ::tolower); - if (o.compare("PC") == 0) { - PetscErrorCode (*pc)(PC*); - PetscFunctionListFind(PCList, t.c_str(), &pc); - if(pc) - return 1L; - } - else if (o.compare("KSP") == 0) { - PetscErrorCode (*ksp)(KSP*); - PetscFunctionListFind(KSPList, t.c_str(), &ksp); - if(ksp) - return 1L; - } - else if (o.compare("MAT") == 0) { - PetscErrorCode (*mat)(Mat*); - PetscFunctionListFind(MatList, t.c_str(), &mat); - if(mat) - return 1L; - } - else if (o.compare("MATSOLVER") == 0) { - PetscBool foundtype; - MatSolverTypeGet(t.c_str(), MATAIJ, MAT_FACTOR_LU, &foundtype, NULL, NULL); - if(foundtype) - return 1L; - } + if (obj->size( ) > 0 && type->size( ) > 0) { + std::string o(*obj); + std::transform(o.begin( ), o.end( ), o.begin( ), ::toupper); + std::string t(*type); + std::transform(t.begin( ), t.end( ), t.begin( ), ::tolower); + if (o.compare("PC") == 0) { + PetscErrorCode (*pc)(PC*); + PetscFunctionListFind(PCList, t.c_str( ), &pc); + if (pc) return 1L; + } else if (o.compare("KSP") == 0) { + PetscErrorCode (*ksp)(KSP*); + PetscFunctionListFind(KSPList, t.c_str( ), &ksp); + if (ksp) return 1L; + } else if (o.compare("MAT") == 0) { + PetscErrorCode (*mat)(Mat*); + PetscFunctionListFind(MatList, t.c_str( ), &mat); + if (mat) return 1L; + } else if (o.compare("MATSOLVER") == 0) { + PetscBool foundtype; + MatSolverTypeGet(t.c_str( ), MATAIJ, MAT_FACTOR_LU, &foundtype, NULL, NULL); + if (foundtype) return 1L; } - return 0L; + } + return 0L; } template< class HpddmType, int C, bool D = false > @@ -1260,47 +1189,37 @@ namespace PETSc { Expression A; Expression B; Expression K; - const OneOperator *codeA; + const OneOperator* codeA; const int c; static const int n_name_param = 3; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - initCSRfromDMatrix_Op(const basicAC_F0& args, int d) - : A(0), B(0), K(0), codeA(nullptr), c(d) { + initCSRfromDMatrix_Op(const basicAC_F0& args, int d) : A(0), B(0), K(0), codeA(nullptr), c(d) { args.SetNameParam(n_name_param, name_param, nargs); A = to< DistributedCSR< HpddmType >* >(args[0]); B = to< DistributedCSR< HpddmType >* >(args[1]); - if (c == 0) K = to< Matrice_Creuse< upscaled_type >* >(args[2]); + if (c == 0) + K = to< Matrice_Creuse< upscaled_type< PetscScalar > >* >(args[2]); else if (c == 1) { const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[2].LeftValue( )); ffassert(op); - codeA = op->Find("(", ArrayOfaType(atype< KN< upscaled_type >* >( ), false)); + codeA = op->Find("(", ArrayOfaType(atype< KN< upscaled_type< PetscScalar > >* >( ), false)); } } AnyType operator( )(Stack stack) const; operator aType( ) const { return atype< DistributedCSR< HpddmType >* >( ); } }; - E_F0* code(const basicAC_F0& args) const { - return new initCSRfromDMatrix_Op(args, c); - } + E_F0* code(const basicAC_F0& args) const { return new initCSRfromDMatrix_Op(args, c); } initCSRfromDMatrix( ) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< typename std::conditional >*, Polymorphic*>::type >( )), + : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), + atype< typename std::conditional< C == 0, Matrice_Creuse< upscaled_type< PetscScalar > >*, Polymorphic* >::type >( )), c(C) {} - initCSRfromDMatrix(int) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( )), - c(2) {} + initCSRfromDMatrix(int) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( )), c(2) {} }; template< class HpddmType, int C, bool D > - basicAC_F0::name_and_type - initCSRfromDMatrix< HpddmType, C, D >::initCSRfromDMatrix_Op::name_param[] = { - {C == 1 ? "transpose" : "clean", C == 1 ? &typeid(Polymorphic*) : &typeid(bool)}, - {"symmetric", &typeid(bool)}, - {"restriction", &typeid(Matrice_Creuse< double >*)}}; + basicAC_F0::name_and_type initCSRfromDMatrix< HpddmType, C, D >::initCSRfromDMatrix_Op::name_param[] = { + {C == 1 ? "transpose" : "clean", C == 1 ? &typeid(Polymorphic*) : &typeid(bool)}, {"symmetric", &typeid(bool)}, {"restriction", &typeid(Matrice_Creuse< double >*)}}; template< class HpddmType, int D > class initRectangularCSRfromDMatrix : public OneOperator { @@ -1312,54 +1231,42 @@ namespace PETSc { Expression B; Expression C; Expression K; - const OneOperator *codeA; + const OneOperator* codeA; const int c; static const int n_name_param = 2; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - initRectangularCSRfromDMatrix_Op(const basicAC_F0& args, int d) - : A(0), B(0), C(0), K(0), codeA(nullptr), c(d) { + initRectangularCSRfromDMatrix_Op(const basicAC_F0& args, int d) : A(0), B(0), C(0), K(0), codeA(nullptr), c(d) { args.SetNameParam(n_name_param, name_param, nargs); A = to< DistributedCSR< HpddmType >* >(args[0]); B = to< DistributedCSR< HpddmType >* >(args[1]); C = to< DistributedCSR< HpddmType >* >(args[2]); - if (c == 0 || c == 3) K = to< Matrice_Creuse< upscaled_type >* >(args[3]); + if (c == 0 || c == 3) K = to< Matrice_Creuse< upscaled_type< PetscScalar > >* >(args[3]); if (c == 2) { const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[3].LeftValue( )); ffassert(op); - codeA = op->Find("(", ArrayOfaType(atype< KN< upscaled_type >* >( ), false)); + codeA = op->Find("(", ArrayOfaType(atype< KN< upscaled_type< PetscScalar > >* >( ), false)); } } AnyType operator( )(Stack stack) const; operator aType( ) const { return c != 3 ? atype< DistributedCSR< HpddmType >* >( ) : atype< long >( ); } }; - E_F0* code(const basicAC_F0& args) const { - return new initRectangularCSRfromDMatrix_Op(args, c); - } + E_F0* code(const basicAC_F0& args) const { return new initRectangularCSRfromDMatrix_Op(args, c); } initRectangularCSRfromDMatrix( ) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< typename std::conditional >*, Polymorphic* >::type >( )), + : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), + atype< typename std::conditional< D == 0, Matrice_Creuse< upscaled_type< PetscScalar > >*, Polymorphic* >::type >( )), c(D ? 2 : 0) {} initRectangularCSRfromDMatrix(int) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( )), - c(1) {} + : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( )), c(1) {} initRectangularCSRfromDMatrix(int, int) - : OneOperator( - atype< long >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< Matrice_Creuse< upscaled_type >* >( )), + : OneOperator(atype< long >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), + atype< Matrice_Creuse< upscaled_type< PetscScalar > >* >( )), c(3) {} }; template< class HpddmType, int D > - basicAC_F0::name_and_type - initRectangularCSRfromDMatrix< HpddmType, D >::initRectangularCSRfromDMatrix_Op::name_param[] = { - {D == 1 ? "transpose" : "clean", D == 1 ? &typeid(Polymorphic*) : &typeid(bool)}, - {"numbering", &typeid(KN>*)}}; + basicAC_F0::name_and_type initRectangularCSRfromDMatrix< HpddmType, D >::initRectangularCSRfromDMatrix_Op::name_param[] = { + {D == 1 ? "transpose" : "clean", D == 1 ? &typeid(Polymorphic*) : &typeid(bool)}, {"numbering", &typeid(KN< upscaled_type< PetscScalar > >*)}}; #if !defined(PETSC_USE_REAL_SINGLE) template< class HpddmType > @@ -1371,34 +1278,19 @@ namespace PETSc { static const int n_name_param = 6; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - initCSRfromMatrix_Op(const basicAC_F0& args, Expression param1, Expression param2, - Expression param3) - : A(param1), K(param2), size(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + initCSRfromMatrix_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), K(param2), size(param3) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; template< class HpddmType > basicAC_F0::name_and_type initCSRfromMatrix_Op< HpddmType >::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"bs", &typeid(long)}, - {"symmetric", &typeid(bool)}, - {"clean", &typeid(bool)}, - {"bsr", &typeid(bool)}, - {"prune", &typeid(bool)}}; + {"communicator", &typeid(pcommworld)}, {"bs", &typeid(long)}, {"symmetric", &typeid(bool)}, {"clean", &typeid(bool)}, {"bsr", &typeid(bool)}, {"prune", &typeid(bool)}}; template< class HpddmType > class initCSRfromMatrix : public OneOperator { public: - initCSRfromMatrix( ) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), - atype< Matrice_Creuse< PetscScalar >* >( ), atype< KN< long >* >( )) {} - - E_F0* code(const basicAC_F0& args) const { - return new initCSRfromMatrix_Op< HpddmType >(args, t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } + initCSRfromMatrix( ) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< Matrice_Creuse< PetscScalar >* >( ), atype< KN< long >* >( )) {} + + E_F0* code(const basicAC_F0& args) const { return new initCSRfromMatrix_Op< HpddmType >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; template< class HpddmType > AnyType initCSRfromMatrix_Op< HpddmType >::operator( )(Stack stack) const { @@ -1418,8 +1310,7 @@ namespace PETSc { ffassert(ptSize->n >= 3 + mK->n); ptA->_first = ptSize->operator( )(0); ptA->_last = ptSize->operator( )(1); - MatSetSizes(ptA->_petsc, mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1), - ptSize->operator( )(2) * (bsr ? bs : 1), ptSize->operator( )(2) * (bsr ? bs : 1)); + MatSetSizes(ptA->_petsc, mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1), ptSize->operator( )(2) * (bsr ? bs : 1), ptSize->operator( )(2) * (bsr ? bs : 1)); if (prune) { ffassert(0); } @@ -1429,8 +1320,7 @@ namespace PETSc { ptA->_first = 0; ptA->_last = mK->n; ptA->_num = nullptr; - MatSetSizes(ptA->_petsc, mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1), - mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1)); + MatSetSizes(ptA->_petsc, mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1), mK->n * (bsr ? bs : 1)); if (prune) { ffassert(0); } @@ -1440,23 +1330,16 @@ namespace PETSc { MatSetType(ptA->_petsc, bsr ? MATBAIJ : MATAIJ); mK->CSR( ); if (bsr) { - MatSeqBAIJSetPreallocationCSR(ptA->_petsc, bs, reinterpret_cast< PetscInt* >(mK->p), - reinterpret_cast< PetscInt* >(mK->j), mK->aij); - MatMPIBAIJSetPreallocationCSR(ptA->_petsc, bs, reinterpret_cast< PetscInt* >(mK->p), - reinterpret_cast< PetscInt* >(mK->j), mK->aij); - } - else { - MatSeqAIJSetPreallocationCSR(ptA->_petsc, reinterpret_cast< PetscInt* >(mK->p), - reinterpret_cast< PetscInt* >(mK->j), mK->aij); - MatMPIAIJSetPreallocationCSR(ptA->_petsc, reinterpret_cast< PetscInt* >(mK->p), - reinterpret_cast< PetscInt* >(mK->j), mK->aij); + MatSeqBAIJSetPreallocationCSR(ptA->_petsc, bs, reinterpret_cast< PetscInt* >(mK->p), reinterpret_cast< PetscInt* >(mK->j), mK->aij); + MatMPIBAIJSetPreallocationCSR(ptA->_petsc, bs, reinterpret_cast< PetscInt* >(mK->p), reinterpret_cast< PetscInt* >(mK->j), mK->aij); + } else { + MatSeqAIJSetPreallocationCSR(ptA->_petsc, reinterpret_cast< PetscInt* >(mK->p), reinterpret_cast< PetscInt* >(mK->j), mK->aij); + MatMPIAIJSetPreallocationCSR(ptA->_petsc, reinterpret_cast< PetscInt* >(mK->p), reinterpret_cast< PetscInt* >(mK->j), mK->aij); } if (prune) { ffassert(0); } - MatSetOption( - ptA->_petsc, MAT_SYMMETRIC, - nargs[2] && GetAny< bool >((*nargs[2])(stack)) ? PETSC_TRUE : PETSC_FALSE); + MatSetOption(ptA->_petsc, MAT_SYMMETRIC, nargs[2] && GetAny< bool >((*nargs[2])(stack)) ? PETSC_TRUE : PETSC_FALSE); if (clean) ptK->destroy( ); if (prune) { ffassert(0); @@ -1471,32 +1354,19 @@ namespace PETSc { static const int n_name_param = 5; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - initCSRfromArray_Op(const basicAC_F0& args, Expression param1, Expression param2) - : A(param1), K(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } + initCSRfromArray_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), K(param2) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; template< class HpddmType > basicAC_F0::name_and_type initCSRfromArray_Op< HpddmType >::name_param[] = { - {"columns", &typeid(KN< long >*)}, - {"communicator", &typeid(pcommworld)}, - {"bs", &typeid(long)}, - {"symmetric", &typeid(bool)}, - {"clean", &typeid(bool)}}; + {"columns", &typeid(KN< long >*)}, {"communicator", &typeid(pcommworld)}, {"bs", &typeid(long)}, {"symmetric", &typeid(bool)}, {"clean", &typeid(bool)}}; template< class HpddmType > class initCSRfromArray : public OneOperator { public: - initCSRfromArray( ) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), - atype< KN< Matrice_Creuse< PetscScalar > >* >( )) {} - - E_F0* code(const basicAC_F0& args) const { - return new initCSRfromArray_Op< HpddmType >(args, t[0]->CastTo(args[0]), - t[1]->CastTo(args[1])); - } + initCSRfromArray( ) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< KN< Matrice_Creuse< PetscScalar > >* >( )) {} + + E_F0* code(const basicAC_F0& args) const { return new initCSRfromArray_Op< HpddmType >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } }; template< class HpddmType > AnyType initCSRfromArray_Op< HpddmType >::operator( )(Stack stack) const { @@ -1504,8 +1374,7 @@ namespace PETSc { int size; MPI_Comm_size(comm, &size); DistributedCSR< HpddmType >* ptA = GetAny< DistributedCSR< HpddmType >* >((*A)(stack)); - KN< Matrice_Creuse< PetscScalar > >* ptK = - GetAny< KN< Matrice_Creuse< PetscScalar > >* >((*K)(stack)); + KN< Matrice_Creuse< PetscScalar > >* ptK = GetAny< KN< Matrice_Creuse< PetscScalar > >* >((*K)(stack)); KN< long >* ptJ = nargs[0] ? GetAny< KN< long >* >((*nargs[0])(stack)) : nullptr; if (!ptJ || ptJ->n == ptK->n) { double timing = MPI_Wtime( ); @@ -1520,10 +1389,7 @@ namespace PETSc { MPI_Comm_rank(comm, &rank); int* dims = new int[size]( ); std::vector< std::pair< int, int > >::const_iterator it = - std::lower_bound(v.cbegin( ), v.cend( ), std::make_pair(rank, 0), - [](const std::pair< int, int >& lhs, const std::pair< int, int >& rhs) { - return lhs.first < rhs.first; - }); + std::lower_bound(v.cbegin( ), v.cend( ), std::make_pair(rank, 0), [](const std::pair< int, int >& lhs, const std::pair< int, int >& rhs) { return lhs.first < rhs.first; }); int n = 0; if (!ptJ) { dims[rank] = ptK->operator[](mpisize / ptK->n > 1 ? 0 : rank).M( ); @@ -1541,8 +1407,7 @@ namespace PETSc { for (int i = 0; i < n + 1; ++i) { ia[i] = 0; for (int k = 0; k < size; ++k) { - MatriceMorse< PetscScalar >* mA = - static_cast< MatriceMorse< PetscScalar >* >(&(*(ptK->operator[](k)).A)); + MatriceMorse< PetscScalar >* mA = static_cast< MatriceMorse< PetscScalar >* >(&(*(ptK->operator[](k)).A)); mA->CSR( ); if (i < mA->n + 1) ia[i] += mA->p[i]; } @@ -1554,18 +1419,14 @@ namespace PETSc { for (int i = 0; i < n; ++i) { int backup = offset; for (int k = 0; k < size; ++k) { - MatriceMorse< PetscScalar >* mA = static_cast< MatriceMorse< PetscScalar >* >( - &(*(ptK->operator[](ptJ ? v[k].second : k)).A)); + MatriceMorse< PetscScalar >* mA = static_cast< MatriceMorse< PetscScalar >* >(&(*(ptK->operator[](ptJ ? v[k].second : k)).A)); mA->CSR( ); if (i < mA->n) { int j = mA->p[i]; - for (; j < mA->p[i + 1] && mA->j[j] < dims[ptJ ? v[k].first : k]; ++j) - ja[nnz + j - mA->p[i]] = mA->j[j] + offset; + for (; j < mA->p[i + 1] && mA->j[j] < dims[ptJ ? v[k].first : k]; ++j) ja[nnz + j - mA->p[i]] = mA->j[j] + offset; std::copy_n(mA->aij + mA->p[i], j - mA->p[i], c + nnz); nnz += j - mA->p[i]; - if (k < (ptJ ? v.size( ) : size) - 1) - offset += - (ptJ ? std::accumulate(dims + v[k].first, dims + v[k + 1].first, 0) : dims[k]); + if (k < (ptJ ? v.size( ) : size) - 1) offset += (ptJ ? std::accumulate(dims + v[k].first, dims + v[k + 1].first, 0) : dims[k]); } } offset = backup; @@ -1579,8 +1440,7 @@ namespace PETSc { if (!ptJ && (size / ptK->n > 1)) MatSetSizes(ptA->_petsc, n, n, PETSC_DECIDE, PETSC_DECIDE); else - MatSetSizes(ptA->_petsc, n, ptK->operator[](ptJ ? it->second : rank).M( ), PETSC_DECIDE, - PETSC_DECIDE); + MatSetSizes(ptA->_petsc, n, ptK->operator[](ptJ ? it->second : rank).M( ), PETSC_DECIDE, PETSC_DECIDE); } ptA->_first = 0; ptA->_last = n; @@ -1589,8 +1449,7 @@ namespace PETSc { int* lg = nullptr; PetscScalar* a = nullptr; for (int k = 0; k < size; ++k) { - MatriceMorse< PetscScalar >* mA = static_cast< MatriceMorse< PetscScalar >* >( - &(*(ptK->operator[](ptJ ? v[k].second : k)).A)); + MatriceMorse< PetscScalar >* mA = static_cast< MatriceMorse< PetscScalar >* >(&(*(ptK->operator[](ptJ ? v[k].second : k)).A)); if (k == 0) { mA->CSR( ); cl = mA->j; @@ -1607,14 +1466,11 @@ namespace PETSc { MatSetType(ptA->_petsc, MATAIJ); MatSeqAIJSetPreallocationCSR(ptA->_petsc, ia, ja, c); MatMPIAIJSetPreallocationCSR(ptA->_petsc, ia, ja, c); - MatSetOption( - ptA->_petsc, MAT_SYMMETRIC, - nargs[3] && GetAny< bool >((*nargs[3])(stack)) ? PETSC_TRUE : PETSC_FALSE); + MatSetOption(ptA->_petsc, MAT_SYMMETRIC, nargs[3] && GetAny< bool >((*nargs[3])(stack)) ? PETSC_TRUE : PETSC_FALSE); delete[] ia; delete[] ja; delete[] c; - if (verbosity > 0 && mpirank == 0) - cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; + if (verbosity > 0 && mpirank == 0) cout << " --- global CSR created (in " << MPI_Wtime( ) - timing << ")" << endl; timing = MPI_Wtime( ); } return ptA; @@ -1641,16 +1497,13 @@ namespace PETSc { if (c == 1 || c == 3 || c == 4) K = to< long >(args[1]); else if (c == 5) - K = to< KNM* >(args[1]); + K = to< KNM< Dmat >* >(args[1]); else - K = to< Matrice_Creuse< upscaled_type >* >(args[1]); + K = to< Matrice_Creuse< upscaled_type< PetscScalar > >* >(args[1]); if (c == 0 || c == 1) { R = to< KN< KN< long > >* >(args[2]); - D = to< KN< typename std::conditional< - std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >( - args[3]); - } - else if (c == 4) + D = to< KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >(args[3]); + } else if (c == 4) R = to< long >(args[2]); } @@ -1659,47 +1512,25 @@ namespace PETSc { }; E_F0* code(const basicAC_F0& args) const { return new E_initCSR(args, c); } initCSR( ) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< Matrice_Creuse< upscaled_type >* >( ), atype< KN< KN< long > >* >( ), - atype< KN< - typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, - double, long >::type >* >( )), + : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< Matrice_Creuse< upscaled_type< PetscScalar > >* >( ), atype< KN< KN< long > >* >( ), + atype< KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >( )), c(0) {} initCSR(int) - : OneOperator( - atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< long >( ), atype< KN< KN< long > >* >( ), - atype< KN< - typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, - double, long >::type >* >( )), + : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< long >( ), atype< KN< KN< long > >* >( ), + atype< KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >( )), c(1) {} - initCSR(int, int) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), - atype< Matrice_Creuse< upscaled_type >* >( )), - c(2) {} - initCSR(int, int, int) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< long >( )), - c(3) {} - initCSR(int, int, int, int) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), - atype< DistributedCSR< HpddmType >* >( ), atype< long >( ), atype< long >( )), - c(4) {} - initCSR(int, int, int, int, int) - : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), - atype< KNM>* >( )), - c(5) {} + initCSR(int, int) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< Matrice_Creuse< upscaled_type< PetscScalar > >* >( )), c(2) {} + initCSR(int, int, int) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< long >( )), c(3) {} + initCSR(int, int, int, int) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< long >( ), atype< long >( )), c(4) {} + initCSR(int, int, int, int, int) : OneOperator(atype< DistributedCSR< HpddmType >* >( ), atype< DistributedCSR< HpddmType >* >( ), atype< KNM< DistributedCSR< HpddmType > >* >( )), c(5) {} }; template< class HpddmType, bool C > - basicAC_F0::name_and_type initCSR< HpddmType, C >::E_initCSR::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"bs", &typeid(long)}, - {"clean", &typeid(bool)}, - {"symmetric", &typeid(bool)}, - {"restriction", &typeid(Matrice_Creuse< double >*)}, - {"level", &typeid(long)}}; + basicAC_F0::name_and_type initCSR< HpddmType, C >::E_initCSR::name_param[] = {{"communicator", &typeid(pcommworld)}, + {"bs", &typeid(long)}, + {"clean", &typeid(bool)}, + {"symmetric", &typeid(bool)}, + {"restriction", &typeid(Matrice_Creuse< double >*)}, + {"level", &typeid(long)}}; template< class HpddmType, bool C > AnyType initCSR< HpddmType, C >::E_initCSR::operator( )(Stack stack) const { DistributedCSR< HpddmType >* ptA = GetAny< DistributedCSR< HpddmType >* >((*A)(stack)); @@ -1707,12 +1538,12 @@ namespace PETSc { MPI_Comm comm1 = MPI_COMM_NULL, comm2 = MPI_COMM_NULL; KNM< Dmat >* pt = GetAny< KNM< Dmat >* >((*K)(stack)); ffassert(pt); - Mat* array = new Mat[pt->N() * pt->M()](); - for (int i = 0; i < pt->N(); ++i) { - for (int j = 0; j < pt->M(); ++j) { - if (pt->operator()(i, j)._petsc) { - array[i * pt->M() + j] = pt->operator()(i, j)._petsc; - PetscObjectGetComm((PetscObject)array[i * pt->M() + j], &comm2); + Mat* array = new Mat[pt->N( ) * pt->M( )]( ); + for (int i = 0; i < pt->N( ); ++i) { + for (int j = 0; j < pt->M( ); ++j) { + if (pt->operator( )(i, j)._petsc) { + array[i * pt->M( ) + j] = pt->operator( )(i, j)._petsc; + PetscObjectGetComm((PetscObject)array[i * pt->M( ) + j], &comm2); } if (comm1 != MPI_COMM_NULL) { int flag; @@ -1722,27 +1553,20 @@ namespace PETSc { comm1 = comm2; } } - MatCreateNest(comm1, pt->N(), NULL, pt->M(), NULL, array, &ptA->_petsc); - delete [] array; - } - else { + MatCreateNest(comm1, pt->N( ), NULL, pt->M( ), NULL, array, &ptA->_petsc); + delete[] array; + } else { KN< KN< long > >* ptR = (c == 0 || c == 1 ? GetAny< KN< KN< long > >* >((*R)(stack)) : nullptr); - KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, - double, long >::type >* ptD = - (c == 0 || c == 1 - ? GetAny< KN< typename std::conditional< - std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >( - (*D)(stack)) - : nullptr), *empty = nullptr; + KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type > + *ptD = (c == 0 || c == 1 ? GetAny< KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >* >((*D)(stack)) : nullptr), + *empty = nullptr; PetscInt bs = nargs[1] ? GetAny< long >((*nargs[1])(stack)) : 1; int dof = 0; - MatriceMorse< upscaled_type >* mA = nullptr; + MatriceMorse< upscaled_type< PetscScalar > >* mA = nullptr; if (c == 0 || c == 2) { - mA = static_cast< MatriceMorse< upscaled_type >* >( - &(*GetAny< Matrice_Creuse< upscaled_type >* >((*K)(stack))->A)); + mA = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*K)(stack))->A)); if (c == 2) ffassert(mA); - } - else + } else dof = GetAny< long >((*K)(stack)); MPI_Comm* comm = nargs[0] ? (MPI_Comm*)GetAny< pcommworld >((*nargs[0])(stack)) : 0; if ((c == 2 && mA->n != mA->m) || c == 4) { @@ -1751,8 +1575,7 @@ namespace PETSc { if (c != 4) { ptA->_last = mA->n; ptA->_clast = mA->m; - } - else { + } else { ptA->_last = dof; ptA->_clast = GetAny< long >((*R)(stack)); } @@ -1773,9 +1596,8 @@ namespace PETSc { ptA->_clast += cbegin; if (c != 4) { ff_HPDDM_MatrixCSR< PetscScalar > dA(mA); - if(cbegin) - for(int i = 0; i < dA.HPDDM_nnz; ++i) - dA.HPDDM_ja[i] += cbegin; + if (cbegin) + for (int i = 0; i < dA.HPDDM_nnz; ++i) dA.HPDDM_ja[i] += cbegin; #if defined(PETSC_USE_64BIT_INDICES) PetscInt* ia = new PetscInt[dA.HPDDM_n + 1]; std::copy_n(dA.HPDDM_ia, dA.HPDDM_n + 1, ia); @@ -1792,12 +1614,10 @@ namespace PETSc { MatSeqAIJSetPreallocationCSR(ptA->_petsc, dA.HPDDM_ia, dA.HPDDM_ja, dA.HPDDM_a); MatMPIAIJSetPreallocationCSR(ptA->_petsc, dA.HPDDM_ia, dA.HPDDM_ja, dA.HPDDM_a); #endif - if(cbegin) - for(int i = 0; i < dA.HPDDM_nnz; ++i) - dA.HPDDM_ja[i] -= cbegin; + if (cbegin) + for (int i = 0; i < dA.HPDDM_nnz; ++i) dA.HPDDM_ja[i] -= cbegin; } - } - else { + } else { ptA->_A = new HpddmType; if ((ptR || c == 2 || c == 3) && (mA || (c != 0 && c != 2))) { HPDDM::MatrixCSR< PetscScalar >* dA; @@ -1805,22 +1625,16 @@ namespace PETSc { dA = new_HPDDM_MatrixCSR< PetscScalar >(mA); else dA = new HPDDM::MatrixCSR< PetscScalar >(dof, dof, 0, nullptr, nullptr, nullptr, false); - Matrice_Creuse< double >* pList = - nargs[4] ? GetAny< Matrice_Creuse< double >* >((*nargs[4])(stack)) : 0; + Matrice_Creuse< double >* pList = nargs[4] ? GetAny< Matrice_Creuse< double >* >((*nargs[4])(stack)) : 0; HPDDM::MatrixCSR< void >* dL = nullptr; int level = nargs[5] ? std::abs(GetAny< long >((*nargs[5])(stack))) : 0; - KN_< KN< long > > sub((c == 0 || c == 1) && ptR->n > 0 && ptR->operator[](0).n > 0 - ? (*ptR)(FromTo(1 + level * ptR->operator[](0).n, - 1 + (level + 1) * ptR->operator[](0).n - 1)) - : KN< KN< long > >( )); - if (std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value && pList && - (mA || (c != 0 && c != 2))) { + KN_< KN< long > > sub((c == 0 || c == 1) && ptR->n > 0 && ptR->operator[](0).n > 0 ? (*ptR)(FromTo(1 + level * ptR->operator[](0).n, 1 + (level + 1) * ptR->operator[](0).n - 1)) + : KN< KN< long > >( )); + if (std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value && pList && (mA || (c != 0 && c != 2))) { int n = 0; ptA->_exchange = new HPDDM::template Subdomain< PetscScalar >*[2]( ); ptA->_exchange[0] = new HPDDM::template Subdomain< PetscScalar >( ); - ptA->_exchange[0]->initialize( - dA, STL< long >((c == 0 || c == 1) && ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), - sub, comm); + ptA->_exchange[0]->initialize(dA, STL< long >((c == 0 || c == 1) && ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), sub, comm); ptA->_exchange[0]->setBuffer( ); if (pList->A) { MatriceMorse< double >* mList = static_cast< MatriceMorse< double >* >(&*(pList->A)); @@ -1829,25 +1643,21 @@ namespace PETSc { ffassert(mList->m == (mA ? mA->n : dof)); n = mList->n; dL = new HPDDM::MatrixCSR< void >(n, mA ? mA->n : dof, n, mList->p, mList->j, false); - ptA->_D = new KN(n); + ptA->_D = new KN< PetscReal >(n); for (int i = 0; i < n; ++i) ptA->_D->operator[](i) = ptD->operator[](mList->j[i]); } else { dL = new HPDDM::MatrixCSR< void >(0, mA ? mA->n : dof, 0, nullptr, nullptr, false); - empty = new KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, - double, long >::type >(0); + empty = new KN< typename std::conditional< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value, double, long >::type >(0); } } - ptA->_A->HPDDM::template Subdomain< PetscScalar >::initialize( - dA, STL< long >((c == 0 || c == 1) && ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), sub, - comm, dL); + ptA->_A->HPDDM::template Subdomain< PetscScalar >::initialize(dA, STL< long >((c == 0 || c == 1) && ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), sub, comm, dL); delete dL; ptA->_num = new PetscInt[ptA->_A->getMatrix( )->HPDDM_n]; if (!C && (c == 2 || c == 3)) { - long long global; - ptA->_A->distributedNumbering(ptA->_num, ptA->_first, ptA->_last, global); + long long global; + ptA->_A->distributedNumbering(ptA->_num, ptA->_first, ptA->_last, global); } - initPETScStructure(ptA, bs, - nargs[3] && GetAny< bool >((*nargs[3])(stack)) ? PETSC_TRUE : PETSC_FALSE, empty ? empty : ptD); + initPETScStructure< C >(ptA, bs, nargs[3] && GetAny< bool >((*nargs[3])(stack)) ? PETSC_TRUE : PETSC_FALSE, empty ? empty : ptD); delete empty; if (!std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value) { mA->p = ptA->_A->getMatrix( )->HPDDM_ia; @@ -1932,8 +1742,8 @@ namespace PETSc { } else if (atype< PetscScalar >( )->CastingFrom(r)) { e_M[i][j] = to< PetscScalar >(c_M); t_M[i][j] = 7; - } else if (atype< std::pair* >( )->CastingFrom(r)) { - e_M[i][j] = to< std::pair* >(c_M); + } else if (atype< std::pair< Dmat*, Dmat* >* >( )->CastingFrom(r)) { + e_M[i][j] = to< std::pair< Dmat*, Dmat* >* >(c_M); t_M[i][j] = 8; } else CompileError("Unsupported type in submatrix"); @@ -1950,13 +1760,11 @@ namespace PETSc { delete[] t_M; } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Result >( ), atype< E_Array >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( ), atype< E_Array >( )); } static E_F0* f(const basicAC_F0& args) { return new initCSRfromBlockMatrix(args, 0); } AnyType operator( )(Stack s) const { - Dmat** exchange = new Dmat*[N * M](); - Mat* a = new Mat[N * M](); + Dmat** exchange = new Dmat*[N * M]( ); + Mat* a = new Mat[N * M]( ); MPI_Comm comm1 = MPI_COMM_NULL, comm2 = MPI_COMM_NULL; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { @@ -1999,14 +1807,16 @@ namespace PETSc { } else if (t == 9 || t == 10) { if (!a[i * M + j]) { KNM< PetscScalar >* x; - if (t == 9) x = GetAny< KNM< PetscScalar >* >(e_ij); - else x = GetAny< Transpose< KNM< PetscScalar >* > >(e_ij); + if (t == 9) + x = GetAny< KNM< PetscScalar >* >(e_ij); + else + x = GetAny< Transpose< KNM< PetscScalar >* > >(e_ij); PetscMPIInt rank; MPI_Comm_rank(comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD, &rank); - MatCreateDense(comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD, x->N(), rank == 0 ? x->M() : 0, PETSC_DECIDE, x->M(), NULL, a + i * M + j); + MatCreateDense(comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD, x->N( ), rank == 0 ? x->M( ) : 0, PETSC_DECIDE, x->M( ), NULL, a + i * M + j); PetscScalar* array; MatDenseGetArray(a[i * M + j], &array); - if (array) std::copy_n(static_cast< PetscScalar* >(*x), x->N() * x->M(), array); + if (array) std::copy_n(static_cast< PetscScalar* >(*x), x->N( ) * x->M( ), array); MatDenseRestoreArray(a[i * M + j], &array); if (t == 10) { Mat C; @@ -2020,14 +1830,15 @@ namespace PETSc { if (e && ((t == 9 && u == 10) || (t == 10 && u == 9))) { AnyType e_ji = (*e)(s); KNM< PetscScalar >* y; - if (u == 9) y = GetAny< KNM< PetscScalar >* >(e_ji); - else y = GetAny< Transpose< KNM< PetscScalar >* > >(e_ji); + if (u == 9) + y = GetAny< KNM< PetscScalar >* >(e_ji); + else + y = GetAny< Transpose< KNM< PetscScalar >* > >(e_ji); if (y == x) { if (u == 9) { MatHermitianTransposeGetMat(a[i * M + j], a + j * N + i); PetscObjectReference((PetscObject)a[j * N + i]); - } - else + } else MatCreateHermitianTranspose(a[i * M + j], a + j * N + i); } } @@ -2036,8 +1847,10 @@ namespace PETSc { } else if (t == 3 || t == 4) { if (!a[i * M + j]) { KN< PetscScalar > x; - if (t == 3) x = GetAny< KN_< PetscScalar > >(e_ij); - else x = GetAny< Transpose< KN_< PetscScalar > > >(e_ij); + if (t == 3) + x = GetAny< KN_< PetscScalar > >(e_ij); + else + x = GetAny< Transpose< KN_< PetscScalar > > >(e_ij); MatCreateDense(comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD, x.n, PETSC_DECIDE, PETSC_DECIDE, 1, NULL, a + i * M + j); PetscScalar* array; MatDenseGetArray(a[i * M + j], &array); @@ -2055,26 +1868,27 @@ namespace PETSc { if (e && ((t == 3 && u == 4) || (t == 4 && u == 3))) { AnyType e_ji = (*e)(s); KN< PetscScalar > y; - if (u == 3) y = GetAny< KN_< PetscScalar > >(e_ji); - else y = GetAny< Transpose< KN_< PetscScalar > > >(e_ji); + if (u == 3) + y = GetAny< KN_< PetscScalar > >(e_ji); + else + y = GetAny< Transpose< KN_< PetscScalar > > >(e_ji); y -= x; - double norm = y.linfty(); + double norm = y.linfty( ); MPI_Allreduce(MPI_IN_PLACE, &norm, 1, MPI_DOUBLE, MPI_MAX, comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD); if (norm < 1.0E-14) { if (u == 3) { MatHermitianTransposeGetMat(a[i * M + j], a + j * N + i); PetscObjectReference((PetscObject)a[j * N + i]); - } - else + } else MatCreateHermitianTranspose(a[i * M + j], a + j * N + i); } } } } } else if (t == 8) { - std::pair* p = GetAny*>(e_ij); + std::pair< Dmat*, Dmat* >* p = GetAny< std::pair< Dmat*, Dmat* >* >(e_ij); ffassert(p && p->first->_petsc && p->second->_petsc); - Mat mats[2] = { p->second->_petsc, p->first->_petsc }; + Mat mats[2] = {p->second->_petsc, p->first->_petsc}; MatCreateComposite(PetscObjectComm((PetscObject)p->first->_petsc), 2, mats, a + i * M + j); MatCompositeSetType(a[i * M + j], MAT_COMPOSITE_MULTIPLICATIVE); delete p; @@ -2089,10 +1903,9 @@ namespace PETSc { MatCreateNest(comm1 != MPI_COMM_NULL ? comm1 : PETSC_COMM_WORLD, N, NULL, M, NULL, a, &sparse_mat->_petsc); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) { - if (a[i * M + j]) - PetscObjectDereference((PetscObject)a[i * M + j]); + if (a[i * M + j]) PetscObjectDereference((PetscObject)a[i * M + j]); } - sparse_mat->_exchange = reinterpret_cast**>(exchange); + sparse_mat->_exchange = reinterpret_cast< HPDDM::Subdomain< PetscScalar >** >(exchange); delete[] a; return sparse_mat; } @@ -2101,9 +1914,7 @@ namespace PETSc { class assignBlockMatrix : public initCSRfromBlockMatrix< HpddmType > { public: assignBlockMatrix(const basicAC_F0& args) : initCSRfromBlockMatrix< HpddmType >(args, 1) {} - static E_F0* f(const basicAC_F0& args) { - return new initCSRfromBlockMatrix< HpddmType >(args, 1); - } + static E_F0* f(const basicAC_F0& args) { return new initCSRfromBlockMatrix< HpddmType >(args, 1); } }; template< class Type > @@ -2138,38 +1949,33 @@ namespace PETSc { }; E_F0* code(const basicAC_F0& args) const { return new setOptions_Op(args, c); } setOptions( ) : OneOperator(atype< long >( ), atype< Type* >( )), c(0) {} - setOptions(int) - : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), - atype< KN< Matrice_Creuse< double > >* >( )), - c(1) {} - setOptions(int, int) - : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), atype< long >( )), c(2) {} - setOptions(int, int, int) - : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), atype< KN< Dmat >* >( )), c(3) {} + setOptions(int) : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), atype< KN< Matrice_Creuse< double > >* >( )), c(1) {} + setOptions(int, int) : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), atype< long >( )), c(2) {} + setOptions(int, int, int) : OneOperator(atype< long >( ), atype< KN< Dmat >* >( ), atype< KN< Dmat >* >( )), c(3) {} }; template< class Type > basicAC_F0::name_and_type setOptions< Type >::setOptions_Op::name_param[] = { - {"sparams", &typeid(std::string*)}, // 0 - {"nearnullspace", &typeid(FEbaseArrayKn< upscaled_type >*)}, // 1 - {"fields", &typeid(KN< double >*)}, // 2 - {"names", &typeid(KN< String >*)}, // 3 - {"prefix", &typeid(std::string*)}, // 4 - {"schurPreconditioner", &typeid(KN< Matrice_Creuse< upscaled_type > >*)}, // 5 - {"schurList", &typeid(KN< double >*)}, // 6 - {"parent", &typeid(Type*)}, // 7 - {"nullspace", &typeid(KNM< upscaled_type >*)}, // 8 - {"fieldsplit", &typeid(long)}, // 9 - {"schurComplement", &typeid(KNM< upscaled_type >*)}, // 10 - {"schur", &typeid(KN< Dmat >*)}, // 11 - {"aux", &typeid(Matrice_Creuse< upscaled_type >*)}, // 12 - {"coordinates", &typeid(KNM< double >*)}, // 13 - {"gradient", &typeid(Dmat*)}, // 14 - {"O", &typeid(Matrice_Creuse< upscaled_type >*)}, // 15 - {"bs", &typeid(long)}, // 16 - {"precon", &typeid(Polymorphic*)}, // 17 - {"setup", &typeid(bool)}, // 18 - {"monitor", &typeid(Polymorphic*)}, // 19 - {"deflation", &typeid(FEbaseArrayKn>*)} // 20 + {"sparams", &typeid(std::string*)}, // 0 + {"nearnullspace", &typeid(FEbaseArrayKn< upscaled_type< PetscScalar > >*)}, // 1 + {"fields", &typeid(KN< double >*)}, // 2 + {"names", &typeid(KN< String >*)}, // 3 + {"prefix", &typeid(std::string*)}, // 4 + {"schurPreconditioner", &typeid(KN< Matrice_Creuse< upscaled_type< PetscScalar > > >*)}, // 5 + {"schurList", &typeid(KN< double >*)}, // 6 + {"parent", &typeid(Type*)}, // 7 + {"nullspace", &typeid(KNM< upscaled_type< PetscScalar > >*)}, // 8 + {"fieldsplit", &typeid(long)}, // 9 + {"schurComplement", &typeid(KNM< upscaled_type< PetscScalar > >*)}, // 10 + {"schur", &typeid(KN< Dmat >*)}, // 11 + {"aux", &typeid(Matrice_Creuse< upscaled_type< PetscScalar > >*)}, // 12 + {"coordinates", &typeid(KNM< double >*)}, // 13 + {"gradient", &typeid(Dmat*)}, // 14 + {"O", &typeid(Matrice_Creuse< upscaled_type< PetscScalar > >*)}, // 15 + {"bs", &typeid(long)}, // 16 + {"precon", &typeid(Polymorphic*)}, // 17 + {"setup", &typeid(bool)}, // 18 + {"monitor", &typeid(Polymorphic*)}, // 19 + {"deflation", &typeid(FEbaseArrayKn< upscaled_type< PetscScalar > >*)} // 20 }; class ShellInjection; template< class Type > @@ -2215,98 +2021,86 @@ namespace PETSc { typename NonlinearSolver< Type >::VecF_O* ecJ; }; static Mat* O; - PetscErrorCode CustomCreateSubMatrices(Mat,PetscInt,const IS*,const IS*,MatReuse scall,Mat *submat[]) { + PetscErrorCode CustomCreateSubMatrices(Mat, PetscInt, const IS*, const IS*, MatReuse scall, Mat* submat[]) { PetscErrorCode ierr; PetscFunctionBeginUser; if (scall == MAT_INITIAL_MATRIX) { - ierr = PetscCalloc1(1,submat);CHKERRQ(ierr); + ierr = PetscCalloc1(1, submat); + CHKERRQ(ierr); } (*submat)[0] = *O; PetscFunctionReturn(PETSC_SUCCESS); } - template< class T, typename std::enable_if< std::is_same< T, KN< PetscScalar > >::value || std::is_same< T, KN< long > >::value >::type* = - nullptr > + template< class T, typename std::enable_if< std::is_same< T, KN< PetscScalar > >::value || std::is_same< T, KN< long > >::value >::type* = nullptr > void resize(T* v, int n, int m) { v->resize(n); } - template< class T, typename std::enable_if< std::is_same< T, KNM< PetscScalar > >::value || std::is_same< T, KNM< long > >::value >::type* = - nullptr > + template< class T, typename std::enable_if< std::is_same< T, KNM< PetscScalar > >::value || std::is_same< T, KNM< long > >::value >::type* = nullptr > void resize(T* v, int n, int m) { v->resize(n, m); } - template< class T, typename std::enable_if< - !std::is_same< T, KN< PetscScalar > >::value && !std::is_same< T, KNM< PetscScalar > >::value && - !std::is_same< T, KN< long > >::value && !std::is_same< T, KNM< long > >::value>::type* = nullptr > + template< class T, typename std::enable_if< !std::is_same< T, KN< PetscScalar > >::value && !std::is_same< T, KNM< PetscScalar > >::value && !std::is_same< T, KN< long > >::value && + !std::is_same< T, KNM< long > >::value >::type* = nullptr > void resize(T* v, int n, int m) {} - template< class T, typename std::enable_if< std::is_same< T, KN< PetscScalar > >::value || std::is_same< T, KN< long > >::value >::type* = - nullptr > + template< class T, typename std::enable_if< std::is_same< T, KN< PetscScalar > >::value || std::is_same< T, KN< long > >::value >::type* = nullptr > void init_KN_or_KNM(T* v, T* w) { v->init(w->n); } - template< class T, typename std::enable_if< std::is_same< T, KNM< PetscScalar > >::value || std::is_same< T, KNM< long > >::value >::type* = - nullptr > + template< class T, typename std::enable_if< std::is_same< T, KNM< PetscScalar > >::value || std::is_same< T, KNM< long > >::value >::type* = nullptr > void init_KN_or_KNM(T* v, T* w) { - v->init(w->N(), w->M()); + v->init(w->N( ), w->M( )); } template< class T, class U > - void changeNumbering_func(PetscInt* const num, PetscInt first, PetscInt last, - PetscInt m, PetscInt n, PetscInt bs, T* ptIn, U* ptOut, bool inverse) { + void changeNumbering_func(PetscInt* const num, PetscInt first, PetscInt last, PetscInt m, PetscInt n, PetscInt bs, T* ptIn, U* ptOut, bool inverse) { PetscScalar* out; if (!inverse) { - resize(ptOut, m ? m : n, ptIn->M()); - out = ptOut->operator PetscScalar*(); + resize(ptOut, m ? m : n, ptIn->M( )); + out = ptOut->operator PetscScalar*( ); if (last - first) { - for(int i = 0; i < ptIn->M(); ++i) { - HPDDM::Subdomain< PetscScalar >::template distributedVec< 0 >( - num, first, last, ptIn->operator PetscScalar*() + i * ptIn->N(), out, static_cast(ptIn->N() / bs), bs); + for (int i = 0; i < ptIn->M( ); ++i) { + HPDDM::Subdomain< PetscScalar >::template distributedVec< 0 >(num, first, last, ptIn->operator PetscScalar*( ) + i * ptIn->N( ), out, static_cast< PetscInt >(ptIn->N( ) / bs), bs); out += last - first; } - } - else - std::copy_n(ptIn->operator PetscScalar*(), ptIn->N() * ptOut->M(), out); + } else + std::copy_n(ptIn->operator PetscScalar*( ), ptIn->N( ) * ptOut->M( ), out); } else { - resize(ptIn, n, ptOut->M()); - if(ptIn->N()) - *ptIn = PetscScalar( ); - out = ptOut->operator PetscScalar*(); + resize(ptIn, n, ptOut->M( )); + if (ptIn->N( )) *ptIn = PetscScalar( ); + out = ptOut->operator PetscScalar*( ); if (num) { - for(int i = 0; i < ptIn->M(); ++i) { - HPDDM::Subdomain< PetscScalar >::template distributedVec< 1 >( - num, first, last, ptIn->operator PetscScalar*() + i * ptIn->N(), out, static_cast(ptIn->N() / bs), bs); + for (int i = 0; i < ptIn->M( ); ++i) { + HPDDM::Subdomain< PetscScalar >::template distributedVec< 1 >(num, first, last, ptIn->operator PetscScalar*( ) + i * ptIn->N( ), out, static_cast< PetscInt >(ptIn->N( ) / bs), bs); out += last - first; } - } - else - std::copy_n(out, ptIn->N() * ptOut->M(), ptIn->operator PetscScalar*()); + } else + std::copy_n(out, ptIn->N( ) * ptOut->M( ), ptIn->operator PetscScalar*( )); } } - template< bool T, class K, class U, typename std::enable_if< std::is_same< K, upscaled_type >::value && std::is_same< U, upscaled_type>::value >::type* = nullptr > - void MatMult(MatriceMorse* const& A, KN_& in, KN_& out) { + template< bool T, class K, class U, typename std::enable_if< std::is_same< K, upscaled_type< PetscScalar > >::value && std::is_same< U, upscaled_type< U > >::value >::type* = nullptr > + void MatMult(MatriceMorse< K >* const& A, KN_< U >& in, KN_< U >& out) { A->addMatMul(in, out, T, in.step, out.step); } - template< bool T, class K, class U, typename std::enable_if< !std::is_same< K, upscaled_type >::value && std::is_same< U, upscaled_type>::value >::type* = nullptr > - void MatMult(MatriceMorse* const& A, KN_& in, KN_& out) { - upscaled_type* pc = in; - double* pr = reinterpret_cast(pc); - KN_< K > realIn(pr + 0, in.N(), 2 * in.step); - KN_< K > imagIn(pr + 1, in.N(), 2 * in.step); + template< bool T, class K, class U, typename std::enable_if< !std::is_same< K, upscaled_type< PetscScalar > >::value && std::is_same< U, upscaled_type< U > >::value >::type* = nullptr > + void MatMult(MatriceMorse< K >* const& A, KN_< U >& in, KN_< U >& out) { + upscaled_type< PetscScalar >* pc = in; + double* pr = reinterpret_cast< double* >(pc); + KN_< K > realIn(pr + 0, in.N( ), 2 * in.step); + KN_< K > imagIn(pr + 1, in.N( ), 2 * in.step); pc = out; - pr = reinterpret_cast(pc); - KN_< K > realOut(pr + 0, out.N(), 2 * out.step); - KN_< K > imagOut(pr + 1, out.N(), 2 * out.step); + pr = reinterpret_cast< double* >(pc); + KN_< K > realOut(pr + 0, out.N( ), 2 * out.step); + KN_< K > imagOut(pr + 1, out.N( ), 2 * out.step); A->addMatMul(realIn, realOut, T, 2 * in.step, 2 * out.step); A->addMatMul(imagIn, imagOut, T, 2 * in.step, 2 * out.step); } - template< bool T, class K, class U, typename std::enable_if< !std::is_same< U, upscaled_type>::value >::type* = nullptr > - void MatMult(MatriceMorse* const& A, KN_& in, KN_& out) { - KN< upscaled_type > inUp(in.N()); - KN< upscaled_type > outUp(out.N()); - for(int j = 0; j < in.N(); ++j) - inUp[j] = in[j]; - MatMult(A, inUp, outUp); - for(int j = 0; j < out.N(); ++j) - out[j] = outUp[j]; + template< bool T, class K, class U, typename std::enable_if< !std::is_same< U, upscaled_type< U > >::value >::type* = nullptr > + void MatMult(MatriceMorse< K >* const& A, KN_< U >& in, KN_< U >& out) { + KN< upscaled_type< PetscScalar > > inUp(in.N( )); + KN< upscaled_type< PetscScalar > > outUp(out.N( )); + for (int j = 0; j < in.N( ); ++j) inUp[j] = in[j]; + MatMult< T >(A, inUp, outUp); + for (int j = 0; j < out.N( ); ++j) out[j] = outUp[j]; } template< bool T > static PetscErrorCode ShellInjectionOp(Mat A, Vec x, Vec y) { @@ -2316,67 +2110,73 @@ namespace PETSc { PetscErrorCode ierr; PetscFunctionBeginUser; - ierr = MatShellGetContext(A, &user);CHKERRQ(ierr); + ierr = MatShellGetContext(A, &user); + CHKERRQ(ierr); MatriceMorse< double >* mP = user->P->A ? static_cast< MatriceMorse< double >* >(&(*user->P->A)) : nullptr; if (mP) { - ierr = VecGetArrayRead(x, &in);CHKERRQ(ierr); - ierr = VecGetArray(y, &out);CHKERRQ(ierr); + ierr = VecGetArrayRead(x, &in); + CHKERRQ(ierr); + ierr = VecGetArray(y, &out); + CHKERRQ(ierr); if (!T) { PetscInt mFine, nCoarse; MatGetLocalSize(A, &mFine, nullptr); MatGetLocalSize(A, nullptr, &nCoarse); KN< PetscScalar > coarse(user->C->_A->getDof( )); KN_< PetscScalar > coarseIn(const_cast< PetscScalar* >(in), nCoarse); - changeNumbering_func(user->C->_num, user->C->_first, user->C->_last, nCoarse, - user->C->_A->getDof(), 1, &coarse, &coarseIn, true); + changeNumbering_func(user->C->_num, user->C->_first, user->C->_last, nCoarse, user->C->_A->getDof( ), 1, &coarse, &coarseIn, true); KN< PetscScalar > fine(user->f->_A->getDof( )); fine = PetscScalar( ); user->C->_A->exchange(coarse); - MatMult(mP, coarse, fine); + MatMult< false >(mP, coarse, fine); KN_< PetscScalar > fineOut(out, mFine); fineOut = PetscScalar( ); - changeNumbering_func(user->f->_num, user->f->_first, user->f->_last, mFine, - user->f->_A->getDof(), 1, &fine, &fineOut, false); + changeNumbering_func(user->f->_num, user->f->_first, user->f->_last, mFine, user->f->_A->getDof( ), 1, &fine, &fineOut, false); } else { PetscInt nFine, mCoarse; MatGetLocalSize(A, nullptr, &nFine); MatGetLocalSize(A, &mCoarse, nullptr); KN< PetscScalar > fine(user->f->_A->getDof( )); KN_< PetscScalar > fineIn(const_cast< PetscScalar* >(in), nFine); - changeNumbering_func(user->f->_num, user->f->_first, user->f->_last, nFine, - user->f->_A->getDof(), 1, &fine, &fineIn, true); + changeNumbering_func(user->f->_num, user->f->_first, user->f->_last, nFine, user->f->_A->getDof( ), 1, &fine, &fineIn, true); KN< PetscScalar > coarse(user->C->_A->getDof( )); coarse = PetscScalar( ); user->f->_A->exchange(fine); - MatMult(mP, fine, coarse); + MatMult< true >(mP, fine, coarse); KN_< PetscScalar > coarseOut(out, mCoarse); - changeNumbering_func(user->C->_num, user->C->_first, user->C->_last, mCoarse, - user->C->_A->getDof(), 1, &coarse, &coarseOut, false); + changeNumbering_func(user->C->_num, user->C->_first, user->C->_last, mCoarse, user->C->_A->getDof( ), 1, &coarse, &coarseOut, false); } - ierr = VecRestoreArray(y, &out);CHKERRQ(ierr); - ierr = VecRestoreArrayRead(x, &in);CHKERRQ(ierr); - } else VecCopy(x, y); + ierr = VecRestoreArray(y, &out); + CHKERRQ(ierr); + ierr = VecRestoreArrayRead(x, &in); + CHKERRQ(ierr); + } else + VecCopy(x, y); PetscFunctionReturn(PETSC_SUCCESS); } - template< class Type, typename std::enable_if::value>::type* = nullptr > + template< class Type, typename std::enable_if< !std::is_same< Type, ShellInjection >::value >::type* = nullptr > static PetscErrorCode ShellDestroy(Mat A) { User< Type > user; PetscErrorCode ierr; PetscFunctionBeginUser; - ierr = MatShellGetContext(A, &user);CHKERRQ(ierr); + ierr = MatShellGetContext(A, &user); + CHKERRQ(ierr); delete user->op; - ierr = PetscFree(user);CHKERRQ(ierr); + ierr = PetscFree(user); + CHKERRQ(ierr); PetscFunctionReturn(PETSC_SUCCESS); } - template< class Type, typename std::enable_if::value>::type* = nullptr > + template< class Type, typename std::enable_if< std::is_same< Type, ShellInjection >::value >::type* = nullptr > static PetscErrorCode ShellDestroy(Mat A) { User< Type > user; PetscErrorCode ierr; PetscFunctionBeginUser; - ierr = MatShellGetContext(A, &user);CHKERRQ(ierr); - ierr = PetscFree(user);CHKERRQ(ierr); + ierr = MatShellGetContext(A, &user); + CHKERRQ(ierr); + ierr = PetscFree(user); + CHKERRQ(ierr); PetscFunctionReturn(PETSC_SUCCESS); } template< class Type > @@ -2385,9 +2185,11 @@ namespace PETSc { PetscErrorCode ierr; PetscFunctionBeginUser; - ierr = PCShellGetContext(pc, (void**)&user);CHKERRQ(ierr); + ierr = PCShellGetContext(pc, (void**)&user); + CHKERRQ(ierr); delete user->op; - ierr = PetscFree(user);CHKERRQ(ierr); + ierr = PetscFree(user); + CHKERRQ(ierr); PetscFunctionReturn(PETSC_SUCCESS); } template< class Type > @@ -2397,11 +2199,11 @@ namespace PETSc { PetscFunctionReturn(PETSC_SUCCESS); } struct WrapperSubKSP { - IS is; - KSP *ksp; + IS is; + KSP* ksp; }; static PetscErrorCode WrapperApply(PC pc, Vec in, Vec out) { - WrapperSubKSP *ctx; + WrapperSubKSP* ctx; PetscFunctionBeginUser; VecCopy(in, out); PCShellGetContext(pc, (void**)&ctx); @@ -2411,7 +2213,7 @@ namespace PETSc { PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode WrapperDestroy(PC pc) { - WrapperSubKSP *ctx; + WrapperSubKSP* ctx; PetscFunctionBeginUser; PCShellGetContext(pc, (void**)&ctx); ISDestroy(&ctx->is); @@ -2419,7 +2221,7 @@ namespace PETSc { PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode WrapperView(PC pc, PetscViewer viewer) { - WrapperSubKSP *ctx; + WrapperSubKSP* ctx; PetscFunctionBeginUser; PCShellGetContext(pc, (void**)&ctx); KSPView(*ctx->ksp, viewer); @@ -2430,8 +2232,7 @@ namespace PETSc { template< class Type > PetscErrorCode Monitor(KSP ksp, PetscInt it, PetscReal rnorm, void* ctx) { PetscFunctionBeginUser; - typename LinearSolver< Type >::MonF_O* mat = - reinterpret_cast< typename LinearSolver< Type >::MonF_O* >(ctx); + typename LinearSolver< Type >::MonF_O* mat = reinterpret_cast< typename LinearSolver< Type >::MonF_O* >(ctx); mat->apply(it, rnorm); PetscFunctionReturn(PETSC_SUCCESS); } @@ -2450,8 +2251,7 @@ namespace PETSc { } ptA = reinterpret_cast< Type* >(&tabA->operator[](level)); level = tabA->N( ) - level - 1; - } - else + } else ptA = GetAny< Type* >((*A)(stack)); ptParent = nargs[7] ? GetAny< Type* >((*nargs[7])(stack)) : 0; if (ptParent && ptParent->_ksp) { @@ -2483,22 +2283,19 @@ namespace PETSc { PCShellSetView(subpc, WrapperView); KSPSetSkipPCSetFromOptions(subksp[0], PETSC_TRUE); PetscInt* idx; - PetscMalloc1(ptA->_A->getDof(), &idx); - std::map map; - ffassert(ptA->_A->getDof() == ptParent->_A->getDof()); - for(int i = 0; i < ptA->_A->getDof(); ++i) - map[ptParent->_num[i]] = i; + PetscMalloc1(ptA->_A->getDof( ), &idx); + std::map< int, int > map; + ffassert(ptA->_A->getDof( ) == ptParent->_A->getDof( )); + for (int i = 0; i < ptA->_A->getDof( ); ++i) map[ptParent->_num[i]] = i; int i = 0; - for(const std::pair& v : map) - idx[i++] = v.second; + for (const std::pair< const int, int >& v : map) idx[i++] = v.second; IS perm; - ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getDof(), idx, PETSC_OWN_POINTER, &perm); + ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getDof( ), idx, PETSC_OWN_POINTER, &perm); ISInvertPermutation(perm, PETSC_DECIDE, &wrapper->is); ISDestroy(&perm); wrapper->ksp = &ptA->_ksp; PetscBool assembled = PETSC_FALSE; - if (ptA->_petsc) - MatAssembled(ptA->_petsc, &assembled); + if (ptA->_petsc) MatAssembled(ptA->_petsc, &assembled); if (!assembled) { Mat A; MatType type; @@ -2506,16 +2303,13 @@ namespace PETSc { MatGetType(A, &type); PetscBool convert; PetscStrcmp(type, MATSEQSBAIJ, &convert); - if(convert) - MatConvert(A, MATSEQAIJ, MAT_INPLACE_MATRIX, &A); + if (convert) MatConvert(A, MATSEQAIJ, MAT_INPLACE_MATRIX, &A); MatDestroy(&ptA->_petsc); MatPermute(A, wrapper->is, wrapper->is, &ptA->_petsc); - if(convert) - MatConvert(ptA->_petsc, MATSBAIJ, MAT_INPLACE_MATRIX, &ptA->_petsc); + if (convert) MatConvert(ptA->_petsc, MATSBAIJ, MAT_INPLACE_MATRIX, &ptA->_petsc); } } - } - else { + } else { PCFieldSplitGetSubKSP(pc, &n, &subksp); Mat** mat; PetscInt M, N; @@ -2528,8 +2322,7 @@ namespace PETSc { if (type == PC_COMPOSITE_SCHUR) { PCFieldSplitSchurPreType type; PCFieldSplitGetSchurPre(pc, &type, NULL); - if (type == PC_FIELDSPLIT_SCHUR_PRE_SELF) - keep = true; + if (type == PC_FIELDSPLIT_SCHUR_PRE_SELF) keep = true; } #endif for (int i = 0; i < M; ++i) { @@ -2537,8 +2330,7 @@ namespace PETSc { KSPDestroy(&ptA->_ksp); ptA->_ksp = subksp[i]; PetscObjectReference((PetscObject)subksp[i]); - if (!keep) - KSPSetOperators(subksp[i], ptA->_petsc, ptA->_petsc); + if (!keep) KSPSetOperators(subksp[i], ptA->_petsc, ptA->_petsc); break; } } @@ -2547,15 +2339,14 @@ namespace PETSc { } if (nargs[0]) { std::string* options = GetAny< std::string* >((*nargs[0])(stack)); - PetscOptionsInsertString(NULL, options->c_str()); + PetscOptionsInsertString(NULL, options->c_str( )); } long FS = nargs[9] ? GetAny< long >((*nargs[9])(stack)) : -1; KSP ksp = nullptr; if (ptA && ptA->_petsc) { { long bs = nargs[16] ? GetAny< long >((*nargs[16])(stack)) : -1; - if(bs >= 1) - MatSetBlockSize(ptA->_petsc, bs); + if (bs >= 1) MatSetBlockSize(ptA->_petsc, bs); } PetscBool assembled; MatAssembled(ptA->_petsc, &assembled); @@ -2563,8 +2354,7 @@ namespace PETSc { KSPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &ptA->_ksp); KSPSetOperators(ptA->_ksp, ptA->_petsc, ptA->_petsc); } - if (nargs[4] && c != 2) - KSPSetOptionsPrefix(ptA->_ksp, GetAny< std::string* >((*nargs[4])(stack))->c_str( )); + if (nargs[4] && c != 2) KSPSetOptionsPrefix(ptA->_ksp, GetAny< std::string* >((*nargs[4])(stack))->c_str( )); if (c == 1 || c == 3) { KN< Matrice_Creuse< double > >* mP = (c == 1 ? GetAny< KN< Matrice_Creuse< double > >* >((*P)(stack)) : nullptr); KN< Dmat >* mD = (c == 3 ? GetAny< KN< Dmat >* >((*P)(stack)) : nullptr); @@ -2583,31 +2373,29 @@ namespace PETSc { for (int i = 0; i < level; ++i) { KSP smoother; PCMGGetSmoother(pc, level - i - 1, &smoother); - if (c != 3 || tabA->N( ) > 1) - KSPSetOperators(smoother, tabA->operator[](i)._petsc, - tabA->operator[](i)._petsc); + if (c != 3 || tabA->N( ) > 1) KSPSetOperators(smoother, tabA->operator[](i)._petsc, tabA->operator[](i)._petsc); if (i < level - 1) { if (c == 1) { - User< ShellInjection > user = nullptr; - PetscNew(&user); - user->P = &mP->operator[](i); - user->f = &tabA->operator[](i); - user->C = &tabA->operator[](i + 1); - Mat P; - PetscInt mFine, MFine, mCoarse, MCoarse; - MatGetLocalSize(tabA->operator[](i)._petsc, &mFine, nullptr); - MatGetSize(tabA->operator[](i)._petsc, &MFine, nullptr); - MatGetLocalSize(tabA->operator[](i + 1)._petsc, &mCoarse, nullptr); - MatGetSize(tabA->operator[](i + 1)._petsc, &MCoarse, nullptr); - MatCreateShell(PetscObjectComm((PetscObject)tabA->operator[](i + 1)._petsc), mFine, mCoarse, MFine, MCoarse, user, &P); - MatShellSetOperation(P, MATOP_MULT, (PetscErrorCodeFn *)ShellInjectionOp< false >); - MatShellSetOperation(P, MATOP_MULT_TRANSPOSE, (PetscErrorCodeFn *)ShellInjectionOp< true >); - MatShellSetOperation(P, MATOP_DESTROY, (PetscErrorCodeFn *)ShellDestroy< ShellInjection >); - PCMGSetInterpolation(pc, level - i - 1, P); - MatDestroy(&P); + User< ShellInjection > user = nullptr; + PetscNew(&user); + user->P = &mP->operator[](i); + user->f = &tabA->operator[](i); + user->C = &tabA->operator[](i + 1); + Mat P; + PetscInt mFine, MFine, mCoarse, MCoarse; + MatGetLocalSize(tabA->operator[](i)._petsc, &mFine, nullptr); + MatGetSize(tabA->operator[](i)._petsc, &MFine, nullptr); + MatGetLocalSize(tabA->operator[](i + 1)._petsc, &mCoarse, nullptr); + MatGetSize(tabA->operator[](i + 1)._petsc, &MCoarse, nullptr); + MatCreateShell(PetscObjectComm((PetscObject)tabA->operator[](i + 1)._petsc), mFine, mCoarse, MFine, MCoarse, user, &P); + MatShellSetOperation(P, MATOP_MULT, (PetscErrorCodeFn*)ShellInjectionOp< false >); + MatShellSetOperation(P, MATOP_MULT_TRANSPOSE, (PetscErrorCodeFn*)ShellInjectionOp< true >); + MatShellSetOperation(P, MATOP_DESTROY, (PetscErrorCodeFn*)ShellDestroy< ShellInjection >); + PCMGSetInterpolation(pc, level - i - 1, P); + MatDestroy(&P); } else { - PCMGSetInterpolation(pc, level - i - 1, mD->operator[](i)._petsc); - MatDestroy(&(mD->operator[](i)._petsc)); + PCMGSetInterpolation(pc, level - i - 1, mD->operator[](i)._petsc); + MatDestroy(&(mD->operator[](i)._petsc)); } } } @@ -2624,8 +2412,10 @@ namespace PETSc { PetscInt nsplits; KSP* subksp; PCFieldSplitGetSubKSP(pc, &nsplits, &subksp); - if (FS < nsplits) ksp = subksp[FS]; - else ffassert(0); + if (FS < nsplits) + ksp = subksp[FS]; + else + ffassert(0); PetscFree(subksp); } KSPGetPC(ksp, &pc); @@ -2637,8 +2427,7 @@ namespace PETSc { if (isFieldSplit) { KN< double >* fields = nargs[2] ? GetAny< KN< double >* >((*nargs[2])(stack)) : 0; KN< String >* names = nargs[3] ? GetAny< KN< String >* >((*nargs[3])(stack)) : 0; - KN< Matrice_Creuse< upscaled_type > >* mS = - nargs[5] ? GetAny< KN< Matrice_Creuse< upscaled_type > >* >((*nargs[5])(stack)) : 0; + KN< Matrice_Creuse< upscaled_type< PetscScalar > > >* mS = nargs[5] ? GetAny< KN< Matrice_Creuse< upscaled_type< PetscScalar > > >* >((*nargs[5])(stack)) : 0; KN< double >* pL = nargs[6] ? GetAny< KN< double >* >((*nargs[6])(stack)) : 0; KN< Dmat >* mdS = nargs[11] ? GetAny< KN< Dmat >* >((*nargs[11])(stack)) : 0; if (mdS) @@ -2646,15 +2435,13 @@ namespace PETSc { else setFieldSplitPC(ptA, ksp, fields, names, mS, pL); } - } - else ksp = ptA->_ksp; + } else + ksp = ptA->_ksp; KSPSetFromOptions(ksp); if (c != 1) { if (std::is_same< Type, Dmat >::value) { - FEbaseArrayKn< upscaled_type >* ptNS = - nargs[1] ? GetAny< FEbaseArrayKn< upscaled_type >* >((*nargs[1])(stack)) : 0; - KNM< upscaled_type >* ptPETScNS = - nargs[8] ? GetAny< KNM< upscaled_type >* >((*nargs[8])(stack)) : 0; + FEbaseArrayKn< upscaled_type< PetscScalar > >* ptNS = nargs[1] ? GetAny< FEbaseArrayKn< upscaled_type< PetscScalar > >* >((*nargs[1])(stack)) : 0; + KNM< upscaled_type< PetscScalar > >* ptPETScNS = nargs[8] ? GetAny< KNM< upscaled_type< PetscScalar > >* >((*nargs[8])(stack)) : 0; int dim = ptNS ? ptNS->N : 0; int dimPETSc = ptPETScNS ? ptPETScNS->M( ) : 0; if (dim || dimPETSc) { @@ -2676,15 +2463,12 @@ namespace PETSc { for (unsigned short i = 0; i < dim; ++i) { PetscScalar* x; VecGetArray(ns[i], &x); - upscaled_type* get = *ptNS->get(i); - PetscScalar* base = reinterpret_cast(get); - if(!std::is_same, PetscReal>::value) { - for(int j = 0; j < ptNS->get(i)->n; ++j) - base[j] = get[j]; + upscaled_type< PetscScalar >* get = *ptNS->get(i); + PetscScalar* base = reinterpret_cast< PetscScalar* >(get); + if (!std::is_same< upscaled_type< PetscReal >, PetscReal >::value) { + for (int j = 0; j < ptNS->get(i)->n; ++j) base[j] = get[j]; } - HPDDM::Subdomain< PetscScalar >::template distributedVec< 0 >( - ptA->_num, ptA->_first, ptA->_last, base, - x, static_cast(ptNS->get(i)->n)); + HPDDM::Subdomain< PetscScalar >::template distributedVec< 0 >(ptA->_num, ptA->_first, ptA->_last, base, x, static_cast< PetscInt >(ptNS->get(i)->n)); VecRestoreArray(ns[i], &x); } PetscScalar* dots = new PetscScalar[std::max(dim, dimPETSc)]; @@ -2699,8 +2483,10 @@ namespace PETSc { delete[] dots; MatNullSpace sp; MatNullSpaceCreate(PetscObjectComm((PetscObject)ptA->_petsc), PETSC_FALSE, std::max(dim, dimPETSc), ns, &sp); - if (dim) MatSetNearNullSpace(ptA->_petsc, sp); - else MatSetNullSpace(ptA->_petsc, sp); + if (dim) + MatSetNearNullSpace(ptA->_petsc, sp); + else + MatSetNullSpace(ptA->_petsc, sp); MatNullSpaceDestroy(&sp); VecDestroyVecs(std::max(dim, dimPETSc), &ns); } @@ -2709,10 +2495,10 @@ namespace PETSc { PCType type; PCGetType(pc, &type); PetscBool isType; - KNM< upscaled_type >* coordinates = - nargs[13] ? GetAny< KNM< upscaled_type >* >((*nargs[13])(stack)) : nullptr; + KNM< upscaled_type< PetscReal > >* coordinates = nargs[13] ? GetAny< KNM< upscaled_type< PetscReal > >* >((*nargs[13])(stack)) : nullptr; Dmat* G = nargs[14] ? GetAny< Dmat* >((*nargs[14])(stack)) : nullptr; - if (coordinates && std::is_same>::value) PCSetCoordinates(pc, coordinates->N( ), coordinates->M( ), reinterpret_cast(coordinates->operator double*())); + if (coordinates && std::is_same< PetscReal, upscaled_type< PetscReal > >::value) + PCSetCoordinates(pc, coordinates->N( ), coordinates->M( ), reinterpret_cast< PetscReal* >(coordinates->operator double*( ))); #if defined(PETSC_HAVE_HYPRE) if (G) { PetscStrcmp(type, PCHYPRE, &isType); @@ -2721,99 +2507,86 @@ namespace PETSc { #endif if (assembled && ptA->_A && ptA->_num) { PetscInt* idx; - PetscMalloc1(ptA->_A->getDof(), &idx); - std::copy_n(ptA->_num, ptA->_A->getDof(), idx); + PetscMalloc1(ptA->_A->getDof( ), &idx); + std::copy_n(ptA->_num, ptA->_A->getDof( ), idx); IS is; - ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getDof(), idx, PETSC_OWN_POINTER, - &is); + ISCreateGeneral(PETSC_COMM_SELF, ptA->_A->getDof( ), idx, PETSC_OWN_POINTER, &is); #if defined(PETSC_HAVE_HPDDM) && defined(PETSC_USE_SHARED_LIBRARIES) PetscStrcmp(type, PCHPDDM, &isType); const HPDDM::MatrixCSR< PetscScalar >* const A = ptA->_A->getMatrix( ); if (isType) { - if(nargs[20]) { - Mat Z; - FEbaseArrayKn>* deflation = GetAny>*>((*nargs[20])(stack)); - MatCreateSeqDense(PETSC_COMM_SELF, ptA->_A->getDof(), deflation->N, NULL, &Z); - PetscScalar* data; - MatDenseGetArrayWrite(Z, &data); - for(int i = 0; i < deflation->N; ++i) - std::copy_n(&(*deflation->get(i))[0], deflation->get(0)->n, data + i * deflation->get(0)->n); - MatDenseRestoreArrayWrite(Z, &data); - PCHPDDMSetDeflationMat(pc, is, Z); - MatDestroy(&Z); - } - else if(A) { + if (nargs[20]) { + Mat Z; + FEbaseArrayKn< upscaled_type< PetscScalar > >* deflation = GetAny< FEbaseArrayKn< upscaled_type< PetscScalar > >* >((*nargs[20])(stack)); + MatCreateSeqDense(PETSC_COMM_SELF, ptA->_A->getDof( ), deflation->N, NULL, &Z); + PetscScalar* data; + MatDenseGetArrayWrite(Z, &data); + for (int i = 0; i < deflation->N; ++i) std::copy_n(&(*deflation->get(i))[0], deflation->get(0)->n, data + i * deflation->get(0)->n); + MatDenseRestoreArrayWrite(Z, &data); + PCHPDDMSetDeflationMat(pc, is, Z); + MatDestroy(&Z); + } else if (A) { if (!A->HPDDM_ia) { - Matrice_Creuse< upscaled_type >* ptK = - nargs[15] ? GetAny< Matrice_Creuse< upscaled_type >* >((*nargs[15])(stack)) : nullptr; + Matrice_Creuse< upscaled_type< PetscScalar > >* ptK = nargs[15] ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*nargs[15])(stack)) : nullptr; Mat aux = nullptr; HPDDM::MatrixCSR< PetscScalar >* B = nullptr; if (ptK && ptK->A) { - MatriceMorse< upscaled_type >* mA = - static_cast< MatriceMorse< upscaled_type >* >(&(*ptK->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mA = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*ptK->A)); B = new_HPDDM_MatrixCSR< PetscScalar >(mA); aux = ff_to_PETSc(B); - } - else { - MatCreate(PETSC_COMM_SELF, &aux); - MatSetSizes(aux, 0, 0, 0, 0); - MatSetType(aux, MATSEQAIJ); - MatAssemblyBegin(aux, MAT_FINAL_ASSEMBLY); - MatAssemblyEnd(aux, MAT_FINAL_ASSEMBLY); + } else { + MatCreate(PETSC_COMM_SELF, &aux); + MatSetSizes(aux, 0, 0, 0, 0); + MatSetType(aux, MATSEQAIJ); + MatAssemblyBegin(aux, MAT_FINAL_ASSEMBLY); + MatAssemblyEnd(aux, MAT_FINAL_ASSEMBLY); } if (aux) { Mat N; PetscObjectQuery((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject*)&N); if (!A->HPDDM_sym && ptA->_petsc) { - PetscInt bs; - MatGetBlockSize(ptA->_petsc, &bs); - if (bs > 1) { - if (!N) - ISSetBlockSize(is, bs); - MatSetBlockSize(aux, bs); - } - } - if(!N) { - PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL); - PCSetFromOptions(pc); - MatDestroy(&aux); - } - else { - PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); - PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL); - MatDestroy(&aux); - } - delete B; - } - } - else { - Mat aux = ff_to_PETSc(A); - Mat N; - PetscObjectQuery((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject*)&N); - if (!A->HPDDM_sym && ptA->_petsc) { PetscInt bs; MatGetBlockSize(ptA->_petsc, &bs); if (bs > 1) { - if (!N) - ISSetBlockSize(is, bs); - MatSetBlockSize(aux, bs); + if (!N) ISSetBlockSize(is, bs); + MatSetBlockSize(aux, bs); } - } - if(!N) { + } + if (!N) { PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL); PCSetFromOptions(pc); MatDestroy(&aux); - } - else { + } else { PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL); MatDestroy(&aux); + } + delete B; + } + } else { + Mat aux = ff_to_PETSc(A); + Mat N; + PetscObjectQuery((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject*)&N); + if (!A->HPDDM_sym && ptA->_petsc) { + PetscInt bs; + MatGetBlockSize(ptA->_petsc, &bs); + if (bs > 1) { + if (!N) ISSetBlockSize(is, bs); + MatSetBlockSize(aux, bs); + } + } + if (!N) { + PCHPDDMSetAuxiliaryMat(pc, is, aux, NULL, NULL); + PCSetFromOptions(pc); + MatDestroy(&aux); + } else { + PetscObjectCompose((PetscObject)pc, "_PCHPDDM_Neumann_Mat", (PetscObject)aux); + PCHPDDMSetAuxiliaryMat(pc, NULL, aux, NULL, NULL); + MatDestroy(&aux); } - Matrice_Creuse< upscaled_type >* ptK = - nargs[12] ? GetAny< Matrice_Creuse< upscaled_type >* >((*nargs[12])(stack)) : nullptr; + Matrice_Creuse< upscaled_type< PetscScalar > >* ptK = nargs[12] ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*nargs[12])(stack)) : nullptr; if (ptK && ptK->A) { - MatriceMorse< upscaled_type >* mA = - static_cast< MatriceMorse< upscaled_type >* >(&(*ptK->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mA = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*ptK->A)); HPDDM::MatrixCSR< PetscScalar >* B = new_HPDDM_MatrixCSR< PetscScalar >(mA); aux = ff_to_PETSc(B); PCHPDDMSetRHSMat(pc, aux); @@ -2822,14 +2595,11 @@ namespace PETSc { } } } - } - else { + } else { #endif - Matrice_Creuse< upscaled_type >* ptO = - nargs[15] ? GetAny< Matrice_Creuse< upscaled_type >* >((*nargs[15])(stack)) : nullptr; + Matrice_Creuse< upscaled_type< PetscScalar > >* ptO = nargs[15] ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*nargs[15])(stack)) : nullptr; if (ptO && ptO->A) { - MatriceMorse< upscaled_type >* mO = - static_cast< MatriceMorse< upscaled_type >* >(&(*ptO->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mO = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*ptO->A)); ff_HPDDM_MatrixCSR< PetscScalar > dO(mO); PCSetType(pc, PCASM); IS loc; @@ -2841,7 +2611,7 @@ namespace PETSc { int nnz = dO.HPDDM_nnz; MPI_Allreduce(MPI_IN_PLACE, &nnz, 1, MPI_INT, MPI_MAX, PetscObjectComm((PetscObject)ptA->_petsc)); if (nnz) { - MatSetOperation(ptA->_petsc, MATOP_CREATE_SUBMATRICES, (PetscErrorCodeFn *)CustomCreateSubMatrices); + MatSetOperation(ptA->_petsc, MATOP_CREATE_SUBMATRICES, (PetscErrorCodeFn*)CustomCreateSubMatrices); Mat aux = ff_to_PETSc(&dO); IS perm; ISSortPermutation(is, PETSC_TRUE, &perm); @@ -2853,7 +2623,7 @@ namespace PETSc { PCSetUp(pc); ISDestroy(&loc); if (nnz) { - MatSetOperation(ptA->_petsc, MATOP_CREATE_SUBMATRICES, (PetscErrorCodeFn *)MatCreateSubMatrices); + MatSetOperation(ptA->_petsc, MATOP_CREATE_SUBMATRICES, (PetscErrorCodeFn*)MatCreateSubMatrices); delete O; } O = nullptr; @@ -2896,50 +2666,45 @@ namespace PETSc { pS->resize(m, n); PetscScalar* data; MatDenseGetArray(S, &data); - std::copy_n(data, m * n, pS->operator PetscScalar*()); + std::copy_n(data, m * n, pS->operator PetscScalar*( )); MatDenseRestoreArray(S, &data); MatFactorRestoreSchurComplement(F, &S, status); ISDestroy(&is); } } if (std::is_same< Type, Dmat >::value && ptA->_petsc && nargs[17]) { - PC pc; - KSPGetPC(ksp, &pc); - PetscBool isType; - PetscObjectTypeCompare((PetscObject)pc, PCSHELL, &isType); - User< LinearSolver< Type > > userPC = nullptr; - if(isType) { - PCShellGetContext(pc, &userPC); - if(userPC) - delete userPC->op; - } - else { - PCSetType(pc, PCSHELL); - } - if(!userPC) - PetscNew(&userPC); - const Polymorphic* op = dynamic_cast< const Polymorphic* >(nargs[17]); - ffassert(op); - const OneOperator* codeA = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); - PetscInt n; - MatGetLocalSize(ptA->_petsc, &n, NULL); - userPC->op = new typename LinearSolver< Type >::MatF_O(n, stack, codeA); - PCShellSetContext(pc, userPC); - PCShellSetApply(pc, Op_User< LinearSolver< Type >, PC >); - PCShellSetDestroy(pc, PCShellDestroy< LinearSolver< Dmat > >); + PC pc; + KSPGetPC(ksp, &pc); + PetscBool isType; + PetscObjectTypeCompare((PetscObject)pc, PCSHELL, &isType); + User< LinearSolver< Type > > userPC = nullptr; + if (isType) { + PCShellGetContext(pc, &userPC); + if (userPC) delete userPC->op; + } else { + PCSetType(pc, PCSHELL); + } + if (!userPC) PetscNew(&userPC); + const Polymorphic* op = dynamic_cast< const Polymorphic* >(nargs[17]); + ffassert(op); + const OneOperator* codeA = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); + PetscInt n; + MatGetLocalSize(ptA->_petsc, &n, NULL); + userPC->op = new typename LinearSolver< Type >::MatF_O(n, stack, codeA); + PCShellSetContext(pc, userPC); + PCShellSetApply(pc, Op_User< LinearSolver< Type >, PC >); + PCShellSetDestroy(pc, PCShellDestroy< LinearSolver< Dmat > >); } const Polymorphic* op = nargs[19] ? dynamic_cast< const Polymorphic* >(nargs[19]) : nullptr; if (op) { ffassert(op); - const OneOperator* codeM = op->Find( - "(", ArrayOfaType(atype< long >( ), atype< double >( ), false)); + const OneOperator* codeM = op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), false)); typename LinearSolver< Type >::MonF_O* mon = new typename LinearSolver< Type >::MonF_O(stack, codeM); KSPMonitorSet(ksp, Monitor< LinearSolver< Type > >, mon, MonitorDestroy< Type >); } } } - if(nargs[18] && GetAny< bool >((*nargs[18])(stack))) - KSPSetUp(ksp); + if (nargs[18] && GetAny< bool >((*nargs[18])(stack))) KSPSetUp(ksp); return 0L; } @@ -2950,76 +2715,75 @@ namespace PETSc { static const int n_name_param = 3; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - view_Op(const basicAC_F0& args, Expression param1) : A(param1) { - args.SetNameParam(n_name_param, name_param, nargs); - } + view_Op(const basicAC_F0& args, Expression param1) : A(param1) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; template< class Type, unsigned short O > basicAC_F0::name_and_type view_Op< Type, O >::name_param[] = { - {!std::is_same>::value && !O ? "object" : "communicator", !std::is_same>::value && !O ? &typeid(std::string*) : &typeid(pcommworld)}, + {!std::is_same< Type, KNM< PetscScalar > >::value && !O ? "object" : "communicator", !std::is_same< Type, KNM< PetscScalar > >::value && !O ? &typeid(std::string*) : &typeid(pcommworld)}, {"format", &typeid(std::string*)}, - {"name", &typeid(std::string*)} - }; + {"name", &typeid(std::string*)}}; template< class Type, unsigned short O > class view : public OneOperator { public: view( ) : OneOperator(atype< long >( ), atype< Type* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new view_Op< Type, O >(args, t[0]->CastTo(args[0])); - } + E_F0* code(const basicAC_F0& args) const { return new view_Op< Type, O >(args, t[0]->CastTo(args[0])); } }; - template< class Type, unsigned short O, typename std::enable_if>::value>::type* = nullptr > + template< class Type, unsigned short O, typename std::enable_if< !std::is_same< Type, KNM< PetscScalar > >::value >::type* = nullptr > AnyType view_dispatched(Type* const& ptA, std::string const& o, std::string* const& type, std::string* const& name, MPI_Comm const& comm) { bool pop = false; PetscViewer viewer = NULL; - if(type && type->compare("info_detail") == 0) { + if (type && type->compare("info_detail") == 0) { ffassert(!O && (ptA->_petsc || ptA->_ksp)); - if(name) PetscViewerASCIIOpen(!O ? PetscObjectComm(ptA->_petsc ? (PetscObject)ptA->_petsc : (PetscObject)ptA->_ksp) : comm, name->c_str(), &viewer); - else viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)viewer)); + if (name) + PetscViewerASCIIOpen(!O ? PetscObjectComm(ptA->_petsc ? (PetscObject)ptA->_petsc : (PetscObject)ptA->_ksp) : comm, name->c_str( ), &viewer); + else + viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)viewer)); PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO_DETAIL); pop = true; } - if (o.size() == 0 || o.compare("MAT") == 0) { - if(type) { - if(type->compare("matlab") == 0) { - if(name) PetscViewerASCIIOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str(), &viewer); - else viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); - pop = true; - } - else if(type->compare("info") == 0) { - ffassert(!O); - if(name) PetscViewerASCIIOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str(), &viewer); - else viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO); - pop = true; - } - else if(type->compare("binary") == 0) { - if(name) PetscViewerBinaryOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str(), O ? FILE_MODE_READ : FILE_MODE_WRITE, &viewer); - else viewer = PETSC_VIEWER_BINARY_(PetscObjectComm((PetscObject)ptA->_petsc)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_NATIVE); - pop = true; - } - else if(type->compare("draw") == 0) { - ffassert(!O); - MatView(ptA->_petsc, PETSC_VIEWER_DRAW_WORLD); - return 0L; - } + if (o.size( ) == 0 || o.compare("MAT") == 0) { + if (type) { + if (type->compare("matlab") == 0) { + if (name) + PetscViewerASCIIOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str( ), &viewer); + else + viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); + pop = true; + } else if (type->compare("info") == 0) { + ffassert(!O); + if (name) + PetscViewerASCIIOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str( ), &viewer); + else + viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO); + pop = true; + } else if (type->compare("binary") == 0) { + if (name) + PetscViewerBinaryOpen(!O ? PetscObjectComm((PetscObject)ptA->_petsc) : comm, name->c_str( ), O ? FILE_MODE_READ : FILE_MODE_WRITE, &viewer); + else + viewer = PETSC_VIEWER_BINARY_(PetscObjectComm((PetscObject)ptA->_petsc)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_NATIVE); + pop = true; + } else if (type->compare("draw") == 0) { + ffassert(!O); + MatView(ptA->_petsc, PETSC_VIEWER_DRAW_WORLD); + return 0L; + } } - if(!viewer && name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)ptA->_petsc), name->c_str(), &viewer); - if(!O) - MatView(ptA->_petsc, viewer ? viewer : PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc))); + if (!viewer && name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)ptA->_petsc), name->c_str( ), &viewer); + if (!O) + MatView(ptA->_petsc, viewer ? viewer : PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc))); else { - ffassert(viewer); - ptA->dtor( ); - MatCreate(comm, &ptA->_petsc); - MatLoad(ptA->_petsc, viewer); + ffassert(viewer); + ptA->dtor( ); + MatCreate(comm, &ptA->_petsc); + MatLoad(ptA->_petsc, viewer); } - } - else { + } else { ffassert(!O); if (ptA->_ksp) { if (o.compare("KSP") == 0) @@ -3031,84 +2795,83 @@ namespace PETSc { } } } - if(pop) - PetscViewerPopFormat(PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc))); - if(name) - PetscViewerDestroy(&viewer); + if (pop) PetscViewerPopFormat(PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ptA->_petsc))); + if (name) PetscViewerDestroy(&viewer); return 0L; } - template< class Type, unsigned short O, typename std::enable_if>::value>::type* = nullptr > + template< class Type, unsigned short O, typename std::enable_if< std::is_same< Type, KNM< PetscScalar > >::value >::type* = nullptr > AnyType view_dispatched(Type* const& ptA, std::string const& o, std::string* const& type, std::string* const& name, MPI_Comm const& comm) { bool pop = false; PetscViewer viewer = NULL; Mat A; - if(!O) - MatCreateDense(comm, ptA->N( ), PETSC_DECIDE, PETSC_DECIDE, ptA->M(), &ptA->operator( )(0, 0), &A); + if (!O) + MatCreateDense(comm, ptA->N( ), PETSC_DECIDE, PETSC_DECIDE, ptA->M( ), &ptA->operator( )(0, 0), &A); else - MatCreate(comm, &A); - if(type) { - if(type->compare("matlab") == 0) { - if(name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str(), &viewer); - else viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); - pop = true; - } - else if(type->compare("info") == 0) { - ffassert(!O); - if(name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str(), &viewer); - else viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO); - pop = true; - } - else if(type->compare("binary") == 0) { - if(name) PetscViewerBinaryOpen(PetscObjectComm((PetscObject)A), name->c_str(), O ? FILE_MODE_READ : FILE_MODE_WRITE, &viewer); - else viewer = PETSC_VIEWER_BINARY_(PetscObjectComm((PetscObject)A)); - PetscViewerPushFormat(viewer, PETSC_VIEWER_NATIVE); - pop = true; - } - else if(type->compare("draw") == 0) { - ffassert(!O); - MatView(A, PETSC_VIEWER_DRAW_WORLD); - MatDestroy(&A); - return 0L; - } + MatCreate(comm, &A); + if (type) { + if (type->compare("matlab") == 0) { + if (name) + PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str( ), &viewer); + else + viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); + pop = true; + } else if (type->compare("info") == 0) { + ffassert(!O); + if (name) + PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str( ), &viewer); + else + viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_INFO); + pop = true; + } else if (type->compare("binary") == 0) { + if (name) + PetscViewerBinaryOpen(PetscObjectComm((PetscObject)A), name->c_str( ), O ? FILE_MODE_READ : FILE_MODE_WRITE, &viewer); + else + viewer = PETSC_VIEWER_BINARY_(PetscObjectComm((PetscObject)A)); + PetscViewerPushFormat(viewer, PETSC_VIEWER_NATIVE); + pop = true; + } else if (type->compare("draw") == 0) { + ffassert(!O); + MatView(A, PETSC_VIEWER_DRAW_WORLD); + MatDestroy(&A); + return 0L; + } } - if(!viewer && name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str(), &viewer); - if(!O) - MatView(A, viewer ? viewer : PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A))); + if (!viewer && name) PetscViewerASCIIOpen(PetscObjectComm((PetscObject)A), name->c_str( ), &viewer); + if (!O) + MatView(A, viewer ? viewer : PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A))); else { - ffassert(viewer); - MatSetType(A, MATDENSE); - MatLoad(A, viewer); - PetscInt m, N; - MatGetLocalSize(A, &m, NULL); - MatGetSize(A, NULL, &N); - ptA->resize(m, N); - PetscScalar* array; - MatDenseGetArray(A, &array); - if (array) std::copy_n(array, m * N, &(ptA->operator( )(0, 0))); - MatDenseRestoreArray(A, &array); + ffassert(viewer); + MatSetType(A, MATDENSE); + MatLoad(A, viewer); + PetscInt m, N; + MatGetLocalSize(A, &m, NULL); + MatGetSize(A, NULL, &N); + ptA->resize(m, N); + PetscScalar* array; + MatDenseGetArray(A, &array); + if (array) std::copy_n(array, m * N, &(ptA->operator( )(0, 0))); + MatDenseRestoreArray(A, &array); } - if(pop) - PetscViewerPopFormat(PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A))); - if(name) - PetscViewerDestroy(&viewer); + if (pop) PetscViewerPopFormat(PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)A))); + if (name) PetscViewerDestroy(&viewer); MatDestroy(&A); return 0L; } template< class Type, unsigned short O > AnyType view_Op< Type, O >::operator( )(Stack stack) const { Type* ptA = GetAny< Type* >((*A)(stack)); - std::string* object = !std::is_same>::value && !O && nargs[0] ? GetAny< std::string* >((*nargs[0])(stack)) : NULL; - MPI_Comm comm = (std::is_same>::value || O) && nargs[0] ? *static_cast< MPI_Comm* >(GetAny< pcommworld >((*nargs[0])(stack))) : PETSC_COMM_WORLD; + std::string* object = !std::is_same< Type, KNM< PetscScalar > >::value && !O && nargs[0] ? GetAny< std::string* >((*nargs[0])(stack)) : NULL; + MPI_Comm comm = (std::is_same< Type, KNM< PetscScalar > >::value || O) && nargs[0] ? *static_cast< MPI_Comm* >(GetAny< pcommworld >((*nargs[0])(stack))) : PETSC_COMM_WORLD; std::string o(object ? *object : ""); - std::transform(o.begin(), o.end(), o.begin(), ::toupper); + std::transform(o.begin( ), o.end( ), o.begin( ), ::toupper); std::string* type = nargs[1] ? GetAny< std::string* >((*nargs[1])(stack)) : NULL; std::string* name = nargs[2] ? GetAny< std::string* >((*nargs[2])(stack)) : NULL; - return view_dispatched(ptA, o, type, name, comm); + return view_dispatched< Type, O >(ptA, o, type, name, comm); } - template< class Type, template class Storage > + template< class Type, template< class > class Storage > class changeNumbering : public OneOperator { public: const int c; @@ -3147,51 +2910,34 @@ namespace PETSc { v.emplace_back(CastTo< KN_< PetscScalar > >((*Ex)[i])); } } - if(c == 3) - out = to< Storage< long >* >(args[2]); + if (c == 3) + out = to< Storage< long >* >(args[2]); else - out = to< Storage< PetscScalar >* >(args[2]); + out = to< Storage< PetscScalar >* >(args[2]); } AnyType operator( )(Stack stack) const; operator aType( ) const { return atype< long >( ); } }; E_F0* code(const basicAC_F0& args) const { return new changeNumbering_Op(args, c); } - changeNumbering( ) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Storage< PetscScalar >* >( ), - atype< Storage< PetscScalar >* >( )), - c(0) {} - changeNumbering(int) - : OneOperator(atype< long >( ), atype< KN< long >* >( ), atype< Storage< PetscScalar >* >( ), - atype< Storage< PetscScalar >* >( )), - c(1) {} - changeNumbering(int, int) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< E_Array >( ), - atype< Storage< PetscScalar >* >( )), - c(2) {} - changeNumbering(int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Storage< PetscScalar >* >( ), - atype< Storage< long >* >( )), - c(3) {} - changeNumbering(int, int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< FEbaseArrayKn< PetscScalar >* >( ), - atype< Storage< PetscScalar >* >( )), - c(4) {} + changeNumbering( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Storage< PetscScalar >* >( ), atype< Storage< PetscScalar >* >( )), c(0) {} + changeNumbering(int) : OneOperator(atype< long >( ), atype< KN< long >* >( ), atype< Storage< PetscScalar >* >( ), atype< Storage< PetscScalar >* >( )), c(1) {} + changeNumbering(int, int) : OneOperator(atype< long >( ), atype< E_Array >( ), atype< E_Array >( ), atype< Storage< PetscScalar >* >( )), c(2) {} + changeNumbering(int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Storage< PetscScalar >* >( ), atype< Storage< long >* >( )), c(3) {} + changeNumbering(int, int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< FEbaseArrayKn< PetscScalar >* >( ), atype< Storage< PetscScalar >* >( )), c(4) {} }; - template< class Type, template class Storage > - basicAC_F0::name_and_type changeNumbering< Type, Storage >::changeNumbering_Op::name_param[] = { - {"inverse", &typeid(bool)}, {"exchange", &typeid(bool)}}; - template< class Type, template class Storage > + template< class Type, template< class > class Storage > + basicAC_F0::name_and_type changeNumbering< Type, Storage >::changeNumbering_Op::name_param[] = {{"inverse", &typeid(bool)}, {"exchange", &typeid(bool)}}; + template< class Type, template< class > class Storage > AnyType changeNumbering< Type, Storage >::changeNumbering_Op::operator( )(Stack stack) const { Storage< long >* ptOutCast = (c == 3 ? GetAny< Storage< long >* >((*out)(stack)) : nullptr); Storage< PetscScalar >* ptOut = (c != 3 ? GetAny< Storage< PetscScalar >* >((*out)(stack)) : nullptr); - if(c == 3) { - ptOut = new Storage< PetscScalar >; - PETSc::resize(ptOut, ptOutCast->N(), 1); + if (c == 3) { + ptOut = new Storage< PetscScalar >; + PETSc::resize(ptOut, ptOutCast->N( ), 1); } bool inverse = nargs[0] && GetAny< bool >((*nargs[0])(stack)); - if(inverse) - ffassert(ptOut->operator PetscScalar*()); + if (inverse) ffassert(ptOut->operator PetscScalar*( )); int sum = 0; if (c == 0 || c == 2 || c == 3 || c == 4) { PetscScalar* pt = *ptOut; @@ -3204,76 +2950,64 @@ namespace PETSc { if (c != 4) { Storage< PetscScalar >* ptIn = GetAny< Storage< PetscScalar >* >((*(E[j].second))(stack)); if (!inverse) { - ffassert(ptIn->N() == ptA->_A->getDof()); - if (j == 0 && ptIn->M() != ptOut->M()) - PETSc::resize(ptOut, ptOut->N(), ptIn->M()); + ffassert(ptIn->N( ) == ptA->_A->getDof( )); + if (j == 0 && ptIn->M( ) != ptOut->M( )) PETSc::resize(ptOut, ptOut->N( ), ptIn->M( )); } - ffassert(ptIn->M() == ptOut->M()); + ffassert(ptIn->M( ) == ptOut->M( )); if (c != 2) { - if (inverse) ffassert(ptOut->N() == m); - changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof(), - 1, ptIn, ptOut, inverse); + if (inverse) ffassert(ptOut->N( ) == m); + changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof( ), 1, ptIn, ptOut, inverse); } else { sum += m; - if (ptOut->N() < sum && !inverse) { - PETSc::resize(ptOut, sum, ptIn->M()); + if (ptOut->N( ) < sum && !inverse) { + PETSc::resize(ptOut, sum, ptIn->M( )); pt = *ptOut + sum - m; - } - else if (inverse && ptIn->N() != ptA->_A->getDof()) - PETSc::resize(ptIn, ptA->_A->getDof(), ptIn->M()); - for (int i = 0; i < ptIn->M(); ++i) { - KN_< PetscScalar > ptOutShift(pt + i * ptOut->N(), m); - KN_< PetscScalar > ptInShift(*ptIn + i * ptIn->N(), ptA->_A->getDof()); - changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof(), - 1, &ptInShift, &ptOutShift, inverse); + } else if (inverse && ptIn->N( ) != ptA->_A->getDof( )) + PETSc::resize(ptIn, ptA->_A->getDof( ), ptIn->M( )); + for (int i = 0; i < ptIn->M( ); ++i) { + KN_< PetscScalar > ptOutShift(pt + i * ptOut->N( ), m); + KN_< PetscScalar > ptInShift(*ptIn + i * ptIn->N( ), ptA->_A->getDof( )); + changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof( ), 1, &ptInShift, &ptOutShift, inverse); } } if (inverse && nargs[1] && GetAny< bool >((*nargs[1])(stack))) { - for(int i = 0; i < ptIn->M(); ++i) - ptA->_A->exchange(*ptIn + i * ptIn->N()); + for (int i = 0; i < ptIn->M( ); ++i) ptA->_A->exchange(*ptIn + i * ptIn->N( )); } if (c == 2) { pt += m; - if (j == E.size( ) - 1) - ffassert(ptOut->N() == std::distance(static_cast< PetscScalar* >(*ptOut), pt) || - (!inverse && ptOut->N() == sum)); - KN_ view = GetAny>((*(v[j]))(stack)); - if(view.operator PetscScalar*() != ptIn->operator PetscScalar*()) - view = *ptIn; + if (j == E.size( ) - 1) ffassert(ptOut->N( ) == std::distance(static_cast< PetscScalar* >(*ptOut), pt) || (!inverse && ptOut->N( ) == sum)); + KN_< PetscScalar > view = GetAny< KN_< PetscScalar > >((*(v[j]))(stack)); + if (view.operator PetscScalar*( ) != ptIn->operator PetscScalar*( )) view = *ptIn; } } else { FEbaseArrayKn< PetscScalar >* ptIn = GetAny< FEbaseArrayKn< PetscScalar >* >((*(E[j].second))(stack)); - ffassert(ptIn && ptIn->N == ptOut->M()); - ffassert(ptIn->get(0) && ptIn->get(0)->n == ptA->_A->getDof()); - ffassert(ptOut->N() == m); - for(int i = 0; i < ptIn->N; ++i) { - KN_< PetscScalar > out(pt + i * m, m); - changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof(), - 1, ptIn->get(i), &out, inverse); + ffassert(ptIn && ptIn->N == ptOut->M( )); + ffassert(ptIn->get(0) && ptIn->get(0)->n == ptA->_A->getDof( )); + ffassert(ptOut->N( ) == m); + for (int i = 0; i < ptIn->N; ++i) { + KN_< PetscScalar > out(pt + i * m, m); + changeNumbering_func(ptA->_num, ptA->_first, ptA->_last, m, ptA->_A->getDof( ), 1, ptIn->get(i), &out, inverse); } if (inverse && nargs[1] && GetAny< bool >((*nargs[1])(stack))) { - for(int i = 0; i < ptIn->N; ++i) - ptA->_A->exchange(&(*ptIn->get(i))[0]); + for (int i = 0; i < ptIn->N; ++i) ptA->_A->exchange(&(*ptIn->get(i))[0]); } } } } - if(c == 3) { - PETSc::resize(ptOutCast, ptOut->N(), 1); - PetscScalar* pt = *ptOut; - long* ptCast = *ptOutCast; - for(int i = 0; i < ptOut->N(); ++i) - ptCast[i] = std::lround(std::real(pt[i])); - delete ptOut; + if (c == 3) { + PETSc::resize(ptOutCast, ptOut->N( ), 1); + PetscScalar* pt = *ptOut; + long* ptCast = *ptOutCast; + for (int i = 0; i < ptOut->N( ); ++i) ptCast[i] = std::lround(std::real(pt[i])); + delete ptOut; } } else { Storage< PetscScalar >* ptIn = GetAny< Storage< PetscScalar >* >((*in)(stack)); - ffassert(ptIn->M() == 1); - ffassert(ptOut->M() == 1); + ffassert(ptIn->M( ) == 1); + ffassert(ptOut->M( ) == 1); KN< long >* ptA = GetAny< KN< long >* >((*A)(stack)); - PetscInt* num = reinterpret_cast< PetscInt* >(ptA->operator long*()); - changeNumbering_func(num + 2, num[0], num[1], num[1] - num[0], ptA->n - 2, 1, ptIn, ptOut, - inverse); + PetscInt* num = reinterpret_cast< PetscInt* >(ptA->operator long*( )); + changeNumbering_func(num + 2, num[0], num[1], num[1] - num[0], ptA->n - 2, 1, ptIn, ptOut, inverse); } return 0L; } @@ -3312,15 +3046,14 @@ namespace PETSc { } return 0L; } - template< char P, class Type, class Storage, typename std::enable_if< std::is_same< Storage, KNM< PetscScalar > >::value >::type* = nullptr > + template< char P, class Type, class Storage, typename std::enable_if< std::is_same< Storage, KNM< PetscScalar > >::value >::type* = nullptr > long MatMatMult(Type* const& A, Storage* const& in, Storage* const& out) { if (A->_petsc) { Mat x, y; PetscInt n, m, N, M; MatGetLocalSize(A->_petsc, &n, &m); MatGetSize(A->_petsc, &N, &M); - MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), P == 'T' || P == 'H' ? n : m, PETSC_DECIDE, - P == 'T' || P == 'H' ? N : M, in->M( ), &(in->operator( )(0, 0)), &x); + MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), P == 'T' || P == 'H' ? n : m, PETSC_DECIDE, P == 'T' || P == 'H' ? N : M, in->M( ), &(in->operator( )(0, 0)), &x); if (P == 'T' || P == 'H') { ffassert(in->N( ) == n); out->resize(m, in->M( )); @@ -3341,8 +3074,7 @@ namespace PETSc { } else { ffassert(in->N( ) == m); out->resize(n, in->M( )); - MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), P == 'T' || P == 'H' ? m : n, PETSC_DECIDE, - P == 'T' || P == 'H' ? M : N, in->M( ), &(out->operator( )(0, 0)), &y); + MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), P == 'T' || P == 'H' ? m : n, PETSC_DECIDE, P == 'T' || P == 'H' ? M : N, in->M( ), &(out->operator( )(0, 0)), &y); MatMatMult(A->_petsc, x, MAT_REUSE_MATRIX, PETSC_DEFAULT, &y); } MatDestroy(&y); @@ -3350,22 +3082,21 @@ namespace PETSc { } return 0L; } - template< char P, class Type, class Storage, typename std::enable_if< std::is_same< Storage, Dmat >::value >::type* = nullptr > + template< char P, class Type, class Storage, typename std::enable_if< std::is_same< Storage, Dmat >::value >::type* = nullptr > long MatMatMult(Type* const& A, Storage* const& in, Storage* const& out) { ffassert(out != in && out != A); if (out->_petsc) out->dtor( ); PetscBool isDense; PetscObjectTypeCompareAny((PetscObject)in->_petsc, &isDense, MATMPIDENSE, MATSEQDENSE, ""); if (isDense) { - PetscInt m, M, n; - MatGetLocalSize(A->_petsc, &m, NULL); - MatGetSize(A->_petsc, &M, NULL); - MatGetLocalSize(in->_petsc, &n, NULL); - MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), m, n, M, PETSC_DETERMINE, NULL, &out->_petsc); - MatMatMult(A->_petsc, in->_petsc, MAT_REUSE_MATRIX, PETSC_DEFAULT, &out->_petsc); - } - else - MatMatMult(A->_petsc, in->_petsc, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &out->_petsc); + PetscInt m, M, n; + MatGetLocalSize(A->_petsc, &m, NULL); + MatGetSize(A->_petsc, &M, NULL); + MatGetLocalSize(in->_petsc, &n, NULL); + MatCreateDense(PetscObjectComm((PetscObject)A->_petsc), m, n, M, PETSC_DETERMINE, NULL, &out->_petsc); + MatMatMult(A->_petsc, in->_petsc, MAT_REUSE_MATRIX, PETSC_DEFAULT, &out->_petsc); + } else + MatMatMult(A->_petsc, in->_petsc, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &out->_petsc); return 0L; } template< class Type > @@ -3400,12 +3131,11 @@ namespace PETSc { if (isType[0]) { MatHermitianTransposeGetMat(D, &b.back( ).second); MatHermitianTranspose(b.back( ).second, MAT_INITIAL_MATRIX, &C); - } - else { + } else { MatTransposeGetMat(D, &b.back( ).second); MatTranspose(b.back( ).second, MAT_INITIAL_MATRIX, &C); } - PetscObjectReference((PetscObject)b.back().second); + PetscObjectReference((PetscObject)b.back( ).second); MatNestSetSubMat(A, i, j, C); MatDestroy(&C); } @@ -3429,31 +3159,25 @@ namespace PETSc { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - convert_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), B(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } + convert_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), B(param2) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; template< class Type > - basicAC_F0::name_and_type convert_Op< Type >::name_param[] = { - {"type", &typeid(std::string*)} - }; + basicAC_F0::name_and_type convert_Op< Type >::name_param[] = {{"type", &typeid(std::string*)}}; template< class Type > class convert : public OneOperator { public: convert( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new convert_Op< Type >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0* code(const basicAC_F0& args) const { return new convert_Op< Type >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } }; template< class Type > AnyType convert_Op< Type >::operator( )(Stack stack) const { Type* ptA = GetAny< Type* >((*A)(stack)); Type* ptB = GetAny< Type* >((*B)(stack)); std::string stype = nargs[0] ? *GetAny< std::string* >((*nargs[0])(stack)) : "aij"; - if (nargs[0]) std::transform(stype.begin(), stype.end(), stype.begin(), ::tolower); + if (nargs[0]) std::transform(stype.begin( ), stype.end( ), stype.begin( ), ::tolower); if (ptA->_petsc) { if (ptB->_petsc) ptB->dtor( ); MatType type; @@ -3462,8 +3186,7 @@ namespace PETSc { PetscStrcmp(type, MATNEST, &isType); if (isType) { prepareConvert(ptA->_petsc, &ptB->_petsc); - } - else { + } else { Mat C = ptA->_petsc; #if defined(PETSC_HAVE_HTOOL) PetscStrcmp(type, MATHTOOL, &isType); @@ -3476,10 +3199,9 @@ namespace PETSc { } #endif if (!isType) { - MatType mtype(stype.c_str()); + MatType mtype(stype.c_str( )); MatConvert(C, mtype, MAT_INITIAL_MATRIX, &ptB->_petsc); - if (C != ptA->_petsc) - MatDestroy(&C); + if (C != ptA->_petsc) MatDestroy(&C); } } } @@ -3490,7 +3212,7 @@ namespace PETSc { if (A->_ksp) { KSPConvergedReason reason; KSPGetConvergedReason(A->_ksp, &reason); - return static_cast(reason); + return static_cast< long >(reason); } return 0L; } @@ -3499,14 +3221,14 @@ namespace PETSc { if (A->_ksp) { PetscInt its; KSPGetIterationNumber(A->_ksp, &its); - return static_cast(its); + return static_cast< long >(its); } return 0L; } template< class Type > long SetResidualHistory(Type* const& A, KN< double >* const& hist) { if (A->_ksp) { - KSPSetResidualHistory(A->_ksp, hist->operator double*(), hist->n, PETSC_TRUE); + KSPSetResidualHistory(A->_ksp, hist->operator double*( ), hist->n, PETSC_TRUE); } return 0L; } @@ -3541,8 +3263,8 @@ namespace PETSc { C_F0 c_x; Expression mat, matT; MatF_O(int n, Stack stk, const OneOperator* op, int m = -1, const OneOperator* opT = nullptr) - : RNM_VirtualMatrix< PetscScalar >(n, m), stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0), matT(opT ? CastTo< Kn_ >(C_F0(opT->code(basicAC_F0_wa(c_x)), (aType)*opT)) : 0) {} + : RNM_VirtualMatrix< PetscScalar >(n, m), stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0), + matT(opT ? CastTo< Kn_ >(C_F0(opT->code(basicAC_F0_wa(c_x)), (aType)*opT)) : 0) {} ~MatF_O( ) { delete matT; delete mat; @@ -3550,16 +3272,14 @@ namespace PETSc { delete zzz; } void addMatMul(const Kn_& xx, Kn_& Ax) const { - if(x.N( ) != xx.N( )) - x.resize(xx.N( )); + if (x.N( ) != xx.N( )) x.resize(xx.N( )); x = xx; ffassert(mat); Ax += GetAny< Kn_ >((*mat)(stack)); WhereStackOfPtr2Free(stack)->clean( ); } void addMatTransMul(const Kn_& xx, Kn_& Ax) const { - if(x.N( ) != xx.N( )) - x.resize(xx.N( )); + if (x.N( ) != xx.N( )) x.resize(xx.N( )); x = xx; ffassert(matT); Ax += GetAny< Kn_ >((*matT)(stack)); @@ -3574,10 +3294,7 @@ namespace PETSc { mutable double t; C_F0 c_t; Expression mat; - MonF_O(Stack stk, const OneOperator* op) - : stack(stk), s(0), c_s(CPValue(s)), t(0), c_t(CPValue(t)), - mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_s, c_t})), (aType)*op)) : 0) { - } + MonF_O(Stack stk, const OneOperator* op) : stack(stk), s(0), c_s(CPValue(s)), t(0), c_t(CPValue(t)), mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_s, c_t})), (aType)*op)) : 0) {} ~MonF_O( ) { delete mat; Expression zzz = c_s; @@ -3638,42 +3355,20 @@ namespace PETSc { operator aType( ) const { return atype< long >( ); } }; E_F0* code(const basicAC_F0& args) const { return new E_LinearSolver(args, c); } - LinearSolver( ) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( )), - c(0) {} - LinearSolver(int) - : OneOperator(atype< long >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( )), - c(1) {} - LinearSolver(int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< KNM< PetscScalar >* >( ), - atype< KNM< PetscScalar >* >( )), - c(2) {} - LinearSolver(int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( )), - c(3) {} - LinearSolver(int, int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( ), - atype< Type* >( )), - c(4) {} - LinearSolver(int, int, int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( )), - c(5) {} - LinearSolver(int, int, int, int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< KNM< PetscScalar >* >( ), - atype< KNM< PetscScalar >* >( )), - c(6) {} + LinearSolver( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( )), c(0) {} + LinearSolver(int) : OneOperator(atype< long >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( )), c(1) {} + LinearSolver(int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KNM< PetscScalar >* >( ), atype< KNM< PetscScalar >* >( )), c(2) {} + LinearSolver(int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( )), c(3) {} + LinearSolver(int, int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( ), atype< Type* >( )), c(4) {} + LinearSolver(int, int, int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( )), c(5) {} + LinearSolver(int, int, int, int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KNM< PetscScalar >* >( ), atype< KNM< PetscScalar >* >( )), c(6) {} }; template< class Type > - basicAC_F0::name_and_type LinearSolver< Type >::E_LinearSolver::name_param[] = { - {"precon", &typeid(Polymorphic*)}, {"sparams", &typeid(std::string*)}}; + basicAC_F0::name_and_type LinearSolver< Type >::E_LinearSolver::name_param[] = {{"precon", &typeid(Polymorphic*)}, {"sparams", &typeid(std::string*)}}; template< class Type > AnyType LinearSolver< Type >::E_LinearSolver::operator( )(Stack stack) const { if (c != 2 && c != 6) { - KN< PetscScalar >* in, *out; + KN< PetscScalar >*in, *out; if (c != 4) { in = GetAny< KN< PetscScalar >* >((*x)(stack)); out = GetAny< KN< PetscScalar >* >((*y)(stack)); @@ -3694,8 +3389,7 @@ namespace PETSc { ffassert(in->n == size); } VecGetLocalSize(y, &size); - if (!x) - ffassert(in->n == size); + if (!x) ffassert(in->n == size); if (out->n != size) { out->resize(size); *out = PetscScalar( ); @@ -3708,7 +3402,7 @@ namespace PETSc { } VecPlaceArray(y, *out); PetscInt N, rbegin; - PetscScalar* tmpIn, *tmpOut; + PetscScalar *tmpIn, *tmpOut; if (c != 3 && c != 5) KSPSolve(ptA->_ksp, x, y); else { @@ -3733,7 +3427,8 @@ namespace PETSc { Mat XD; if (!isDense) { MatConvert(X->_petsc, MATDENSE, MAT_INITIAL_MATRIX, &XD); - } else XD = X->_petsc; + } else + XD = X->_petsc; if (!Y->_petsc) MatDuplicate(XD, MAT_DO_NOT_COPY_VALUES, &Y->_petsc); KSPMatSolve(ptA->_ksp, XD, Y->_petsc); if (!isDense) MatDestroy(&XD); @@ -3744,8 +3439,7 @@ namespace PETSc { user->op = new LinearSolver< Type >::MatF_O(in->n, stack, codeA); Mat S; MatCreateShell(PETSC_COMM_WORLD, in->n, in->n, PETSC_DECIDE, PETSC_DECIDE, user, &S); - MatShellSetOperation(S, MATOP_MULT, - (PetscErrorCodeFn *)Op_User< LinearSolver< Type >, Mat >); + MatShellSetOperation(S, MATOP_MULT, (PetscErrorCodeFn*)Op_User< LinearSolver< Type >, Mat >); Vec x, y; MatCreateVecs(S, &x, &y); if (out->n != in->n) { @@ -3759,7 +3453,7 @@ namespace PETSc { KSPSetOperators(ksp, S, S); if (nargs[1]) { std::string* options = GetAny< std::string* >((*nargs[1])(stack)); - PetscOptionsInsertString(NULL, options->c_str()); + PetscOptionsInsertString(NULL, options->c_str( )); } PC pc; KSPGetPC(ksp, &pc); @@ -3800,8 +3494,7 @@ namespace PETSc { KSPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &ptA->_ksp); KSPSetOperators(ptA->_ksp, ptA->_petsc, ptA->_petsc); isType = PETSC_FALSE; - } - else { + } else { KSPType type; KSPGetType(ptA->_ksp, &type); #if defined(KSPHPDDM) @@ -3812,18 +3505,19 @@ namespace PETSc { } isType = PETSC_TRUE; #if defined(PETSC_HAVE_HPDDM) - if(isType) { + if (isType) { MatGetSize(ptA->_petsc, &M, NULL); Mat B, C; - MatCreateDense(PetscObjectComm((PetscObject)ptA->_ksp), in->N( ), PETSC_DECIDE, M, in->M(), &in->operator( )(0, 0), &B); - MatCreateDense(PetscObjectComm((PetscObject)ptA->_ksp), out->N( ), PETSC_DECIDE, M, out->M(), &out->operator( )(0, 0), &C); - if (c == 2) KSPMatSolve(ptA->_ksp, B, C); - else KSPMatSolveTranspose(ptA->_ksp, B, C); + MatCreateDense(PetscObjectComm((PetscObject)ptA->_ksp), in->N( ), PETSC_DECIDE, M, in->M( ), &in->operator( )(0, 0), &B); + MatCreateDense(PetscObjectComm((PetscObject)ptA->_ksp), out->N( ), PETSC_DECIDE, M, out->M( ), &out->operator( )(0, 0), &C); + if (c == 2) + KSPMatSolve(ptA->_ksp, B, C); + else + KSPMatSolveTranspose(ptA->_ksp, B, C); MatDestroy(&C); MatDestroy(&B); - } - else - ffassert(0); + } else + ffassert(0); #else HPDDM::PETScOperator op(ptA->_ksp, m); op.apply(&in->operator( )(0, 0), &out->operator( )(0, 0), in->M( )); @@ -3833,29 +3527,27 @@ namespace PETSc { return 0L; } template< class HpddmType, int C, bool D > - AnyType initCSRfromDMatrix< HpddmType, C, D >::initCSRfromDMatrix_Op::operator( )( - Stack stack) const { + AnyType initCSRfromDMatrix< HpddmType, C, D >::initCSRfromDMatrix_Op::operator( )(Stack stack) const { ffassert((C == 0 && (c == 0 || c == 2)) || (C == c && C == 1)); DistributedCSR< HpddmType >* ptA = GetAny< DistributedCSR< HpddmType >* >((*A)(stack)); DistributedCSR< HpddmType >* ptB = GetAny< DistributedCSR< HpddmType >* >((*B)(stack)); - Matrice_Creuse< upscaled_type >* ptK = (c == 0 ? GetAny< Matrice_Creuse< upscaled_type >* >((*K)(stack)) : nullptr); + Matrice_Creuse< upscaled_type< PetscScalar > >* ptK = (c == 0 ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*K)(stack)) : nullptr); if (ptB->_A) { HPDDM::MatrixCSR< PetscScalar >* dA; if (c == 0 && ptK->A) { - MatriceMorse< upscaled_type >* mA = static_cast< MatriceMorse< upscaled_type >* >(&(*ptK->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mA = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*ptK->A)); dA = new_HPDDM_MatrixCSR< PetscScalar >(mA); } else { if (c == 0) { int* ia = new int[1]( ); dA = new HPDDM::MatrixCSR< PetscScalar >(0, 0, 0, nullptr, ia, nullptr, false, true); } else { - int m = ptB->_A->getDof(); + int m = ptB->_A->getDof( ); int* ia = (c == 1 ? new int[m + 1]( ) : nullptr); dA = new HPDDM::MatrixCSR< PetscScalar >(m, m, 0, nullptr, ia, nullptr, false, true); } } - Matrice_Creuse< double >* pList = - nargs[2] && c != 1 ? GetAny< Matrice_Creuse< double >* >((*nargs[2])(stack)) : nullptr; + Matrice_Creuse< double >* pList = nargs[2] && c != 1 ? GetAny< Matrice_Creuse< double >* >((*nargs[2])(stack)) : nullptr; PetscInt bs; MatGetBlockSize(ptB->_petsc, &bs); KN< double >* empty = nullptr; @@ -3866,24 +3558,22 @@ namespace PETSc { std::copy_n(ptB->_num, dA->HPDDM_n, ptA->_num); ptA->_first = ptB->_first; ptA->_last = ptB->_last; - if (ptB->_A->getScaling()) { - ptA->_D = new KN(dA->HPDDM_n); - for (int i = 0; i < dA->HPDDM_n; ++i) ptA->_D->operator[](i) = ptB->_A->getScaling()[i]; + if (ptB->_A->getScaling( )) { + ptA->_D = new KN< PetscReal >(dA->HPDDM_n); + for (int i = 0; i < dA->HPDDM_n; ++i) ptA->_D->operator[](i) = ptB->_A->getScaling( )[i]; #if !defined(PETSC_USE_REAL_DOUBLE) - empty = new KN(dA->HPDDM_n); - for (int i = 0; i < dA->HPDDM_n; ++i) empty->operator[](i) = ptB->_A->getScaling()[i]; + empty = new KN< double >(dA->HPDDM_n); + for (int i = 0; i < dA->HPDDM_n; ++i) empty->operator[](i) = ptB->_A->getScaling( )[i]; #else - empty = ptA->_D; + empty = ptA->_D; #endif } - initPETScStructure(ptA, bs, - nargs[1] && GetAny< bool >((*nargs[1])(stack)) ? PETSC_TRUE : PETSC_FALSE, - empty); + initPETScStructure< D >(ptA, bs, nargs[1] && GetAny< bool >((*nargs[1])(stack)) ? PETSC_TRUE : PETSC_FALSE, empty); #if defined(PETSC_USE_REAL_DOUBLE) empty = nullptr; #endif } else { - int n = ptB->_A->getDof(); + int n = ptB->_A->getDof( ); ffassert(dA->HPDDM_n == n); HPDDM::MatrixCSR< void >* L; if (pList->A) { @@ -3892,32 +3582,29 @@ namespace PETSc { ffassert(mList->n == mList->nnz); ffassert(mList->m == n); L = new HPDDM::MatrixCSR< void >(mList->n, n, mList->n, mList->p, mList->j, false); - ptA->_D = new KN(mList->n); - for (int i = 0; i < mList->n; ++i) ptA->_D->operator[](i) = ptB->_A->getScaling()[mList->j[i]]; - empty = new KN< double >(n, (double*)(ptB->_A->getScaling())); + ptA->_D = new KN< PetscReal >(mList->n); + for (int i = 0; i < mList->n; ++i) ptA->_D->operator[](i) = ptB->_A->getScaling( )[mList->j[i]]; + empty = new KN< double >(n, (double*)(ptB->_A->getScaling( ))); } else { L = new HPDDM::MatrixCSR< void >(0, n, 0, nullptr, nullptr, false); empty = new KN< double >(0); } - const HPDDM::vectorNeighbor& map = ptB->_A->getMap(); - std::vector o; - std::vector> r; - o.reserve(map.size()); - r.reserve(map.size()); - for(const auto& i : map) { - o.emplace_back(i.first); - r.emplace_back(i.second); + const HPDDM::vectorNeighbor& map = ptB->_A->getMap( ); + std::vector< int > o; + std::vector< std::vector< int > > r; + o.reserve(map.size( )); + r.reserve(map.size( )); + for (const auto& i : map) { + o.emplace_back(i.first); + r.emplace_back(i.second); } - const MPI_Comm& comm = ptB->_A->getCommunicator(); + const MPI_Comm& comm = ptB->_A->getCommunicator( ); ptA->_A = new HpddmType; - ptA->_A->HPDDM::template Subdomain< PetscScalar >::initialize( - dA, o, r, const_cast(&comm), L); + ptA->_A->HPDDM::template Subdomain< PetscScalar >::initialize(dA, o, r, const_cast< MPI_Comm* >(&comm), L); delete L; - ptA->_num = new PetscInt[ptA->_A->getDof()]; - initPETScStructure(ptA, bs, - nargs[1] && GetAny< bool >((*nargs[1])(stack)) ? PETSC_TRUE : PETSC_FALSE, empty); - if (c != 0 || !ptK->A) - delete dA; + ptA->_num = new PetscInt[ptA->_A->getDof( )]; + initPETScStructure< D >(ptA, bs, nargs[1] && GetAny< bool >((*nargs[1])(stack)) ? PETSC_TRUE : PETSC_FALSE, empty); + if (c != 0 || !ptK->A) delete dA; } delete empty; if (c == 1) { @@ -3926,36 +3613,32 @@ namespace PETSc { PetscNew(&user); user->op = nullptr; const Polymorphic* op = nargs[0] ? dynamic_cast< const Polymorphic* >(nargs[0]) : nullptr; - if(op) { - const OneOperator* codeAt = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); - if (codeAt) { - user->op = new LinearSolver< Dmat >::MatF_O(ptB->_last - ptB->_first, stack, codeA, -1, codeAt); - MatShellSetOperation(ptA->_petsc, MATOP_MULT_TRANSPOSE, - (PetscErrorCodeFn *)Op_User< LinearSolver< Mat >, Mat, 'T' >); - } + if (op) { + const OneOperator* codeAt = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); + if (codeAt) { + user->op = new LinearSolver< Dmat >::MatF_O(ptB->_last - ptB->_first, stack, codeA, -1, codeAt); + MatShellSetOperation(ptA->_petsc, MATOP_MULT_TRANSPOSE, (PetscErrorCodeFn*)Op_User< LinearSolver< Mat >, Mat, 'T' >); + } } - if(!user->op) user->op = new LinearSolver< Dmat >::MatF_O(ptB->_last - ptB->_first, stack, codeA); + if (!user->op) user->op = new LinearSolver< Dmat >::MatF_O(ptB->_last - ptB->_first, stack, codeA); MatShellSetContext(ptA->_petsc, user); - MatShellSetOperation(ptA->_petsc, MATOP_MULT, - (PetscErrorCodeFn *)Op_User< LinearSolver< Mat >, Mat >); - MatShellSetOperation(ptA->_petsc, MATOP_DESTROY, (PetscErrorCodeFn *)ShellDestroy< LinearSolver< Dmat > >); + MatShellSetOperation(ptA->_petsc, MATOP_MULT, (PetscErrorCodeFn*)Op_User< LinearSolver< Mat >, Mat >); + MatShellSetOperation(ptA->_petsc, MATOP_DESTROY, (PetscErrorCodeFn*)ShellDestroy< LinearSolver< Dmat > >); MatSetUp(ptA->_petsc); } - } else if(ptB->_petsc) { + } else if (ptB->_petsc) { MatDuplicate(ptB->_petsc, MAT_COPY_VALUES, &ptA->_petsc); } if (c == 0 && nargs[0] && GetAny< bool >((*nargs[0])(stack))) ptK->destroy( ); return ptA; } template< class HpddmType, int D > - AnyType initRectangularCSRfromDMatrix< HpddmType, D >::initRectangularCSRfromDMatrix_Op::operator( )( - Stack stack) const { + AnyType initRectangularCSRfromDMatrix< HpddmType, D >::initRectangularCSRfromDMatrix_Op::operator( )(Stack stack) const { ffassert((D == 0 && (c == 0 || c == 1 || c == 3)) || (c == 2 && D == 1)); DistributedCSR< HpddmType >* ptA = GetAny< DistributedCSR< HpddmType >* >((*A)(stack)); DistributedCSR< HpddmType >* ptB = GetAny< DistributedCSR< HpddmType >* >((*B)(stack)); DistributedCSR< HpddmType >* ptC = GetAny< DistributedCSR< HpddmType >* >((*C)(stack)); - Matrice_Creuse< upscaled_type >* ptK = - (c == 0 || c == 3 ? GetAny< Matrice_Creuse< upscaled_type >* >((*K)(stack)) : nullptr); + Matrice_Creuse< upscaled_type< PetscScalar > >* ptK = (c == 0 || c == 3 ? GetAny< Matrice_Creuse< upscaled_type< PetscScalar > >* >((*K)(stack)) : nullptr); if (ptB->_petsc && ptC->_petsc) { ptA->_first = ptB->_first; ptA->_last = ptB->_last; @@ -3974,23 +3657,20 @@ namespace PETSc { PetscScalar* a = nullptr; bool free = true; if (ptK && ptK->A) { - MatriceMorse< upscaled_type >* mA = static_cast< MatriceMorse< upscaled_type >* >(&(*ptK->A)); + MatriceMorse< upscaled_type< PetscScalar > >* mA = static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*ptK->A)); ff_HPDDM_MatrixCSR< PetscScalar > dA(mA); - ptA->_num = new PetscInt[mA->n + (ptC->_A && ptC->_A->getMatrix() ? ptC->_A->getMatrix()->HPDDM_m : mA->m)]; + ptA->_num = new PetscInt[mA->n + (ptC->_A && ptC->_A->getMatrix( ) ? ptC->_A->getMatrix( )->HPDDM_m : mA->m)]; ptA->_cnum = ptA->_num + mA->n; std::copy_n(ptB->_num, mA->n, ptA->_num); - std::copy_n(ptC->_num, (ptC->_A && ptC->_A->getMatrix() ? ptC->_A->getMatrix()->HPDDM_m : mA->m), ptA->_cnum); - KN* numbering = nargs[1] ? GetAny< KN* >((*nargs[1])(stack)) : NULL; + std::copy_n(ptC->_num, (ptC->_A && ptC->_A->getMatrix( ) ? ptC->_A->getMatrix( )->HPDDM_m : mA->m), ptA->_cnum); + KN< PetscScalar >* numbering = nargs[1] ? GetAny< KN< PetscScalar >* >((*nargs[1])(stack)) : NULL; if (c == 0 || !numbering) - free = HPDDM::template Subdomain< PetscScalar >::distributedCSR( - ptA->_num, ptA->_first, ptA->_last, ia, ja, a, &dA, ptA->_num + mA->n); + free = HPDDM::template Subdomain< PetscScalar >::distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, a, &dA, ptA->_num + mA->n); else { - KN col(mA->m); - ffassert(mA->m == numbering->N()); - for(int i = 0; i < col.N(); ++i) - col[i] = std::lround(std::real(numbering->operator[](i))); - free = HPDDM::template Subdomain< PetscScalar >::distributedCSR( - ptA->_num, ptA->_first, ptA->_last, ia, ja, a, &dA, col.operator PetscInt*()); + KN< PetscInt > col(mA->m); + ffassert(mA->m == numbering->N( )); + for (int i = 0; i < col.N( ); ++i) col[i] = std::lround(std::real(numbering->operator[](i))); + free = HPDDM::template Subdomain< PetscScalar >::distributedCSR(ptA->_num, ptA->_first, ptA->_last, ia, ja, a, &dA, col.operator PetscInt*( )); } } else ia = new PetscInt[ptB->_last - ptB->_first + 1]( ); @@ -4008,33 +3688,31 @@ namespace PETSc { PetscNew(&user); user->op = nullptr; const Polymorphic* op = nargs[0] ? dynamic_cast< const Polymorphic* >(nargs[0]) : nullptr; - if(op) { - const OneOperator* codeAt = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); - if (codeAt) { - user->op = new LinearSolver< Dmat >::MatF_O(ptC->_last - ptC->_first, stack, codeA, ptB->_last - ptB->_first, codeAt); - MatShellSetOperation(ptA->_petsc, MATOP_MULT_TRANSPOSE, - (PetscErrorCodeFn *)Op_User< LinearSolver< Mat >, Mat, 'T' >); - } + if (op) { + const OneOperator* codeAt = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); + if (codeAt) { + user->op = new LinearSolver< Dmat >::MatF_O(ptC->_last - ptC->_first, stack, codeA, ptB->_last - ptB->_first, codeAt); + MatShellSetOperation(ptA->_petsc, MATOP_MULT_TRANSPOSE, (PetscErrorCodeFn*)Op_User< LinearSolver< Mat >, Mat, 'T' >); + } } - if(!user->op) user->op = new LinearSolver< Dmat >::MatF_O(ptC->_last - ptC->_first, stack, codeA, ptB->_last - ptB->_first); + if (!user->op) user->op = new LinearSolver< Dmat >::MatF_O(ptC->_last - ptC->_first, stack, codeA, ptB->_last - ptB->_first); MatShellSetContext(ptA->_petsc, user); - MatShellSetOperation(ptA->_petsc, MATOP_MULT, - (PetscErrorCodeFn *)Op_User< LinearSolver< Mat >, Mat >); - MatShellSetOperation(ptA->_petsc, MATOP_DESTROY, (PetscErrorCodeFn *)ShellDestroy< LinearSolver< Dmat > >); + MatShellSetOperation(ptA->_petsc, MATOP_MULT, (PetscErrorCodeFn*)Op_User< LinearSolver< Mat >, Mat >); + MatShellSetOperation(ptA->_petsc, MATOP_DESTROY, (PetscErrorCodeFn*)ShellDestroy< LinearSolver< Dmat > >); } MatSetUp(ptA->_petsc); - if(ptB->_A && ptC->_A) { + if (ptB->_A && ptC->_A) { MatSetOption(ptA->_petsc, MAT_NO_OFF_PROC_ENTRIES, PETSC_TRUE); - if(ptB->_A->getMatrix() && ptC->_A->getMatrix()) { + if (ptB->_A->getMatrix( ) && ptC->_A->getMatrix( )) { ptA->_num = new PetscInt[ptB->_A->getMatrix( )->HPDDM_n + ptC->_A->getMatrix( )->HPDDM_m]; ptA->_cnum = ptA->_num + ptB->_A->getMatrix( )->HPDDM_n; std::copy_n(ptB->_num, ptB->_A->getMatrix( )->HPDDM_n, ptA->_num); std::copy_n(ptC->_num, ptC->_A->getMatrix( )->HPDDM_m, ptA->_cnum); } else { - ptA->_num = new PetscInt[ptB->_A->getDof() + ptC->_A->getDof()]; - ptA->_cnum = ptA->_num + ptB->_A->getDof(); - std::copy_n(ptB->_num, ptB->_A->getDof(), ptA->_num); - std::copy_n(ptC->_num, ptC->_A->getDof(), ptA->_cnum); + ptA->_num = new PetscInt[ptB->_A->getDof( ) + ptC->_A->getDof( )]; + ptA->_cnum = ptA->_num + ptB->_A->getDof( ); + std::copy_n(ptB->_num, ptB->_A->getDof( ), ptA->_num); + std::copy_n(ptC->_num, ptC->_A->getDof( ), ptA->_cnum); } } else { ptA->_num = new PetscInt[ptB->_last - ptB->_first + ptC->_last - ptC->_first]; @@ -4043,19 +3721,20 @@ namespace PETSc { std::copy_n(ptC->_num, ptC->_last - ptC->_first, ptA->_cnum); } } - if(ptB->_A && ptC->_A) { + if (ptB->_A && ptC->_A) { ptA->_exchange = new HPDDM::template Subdomain< PetscScalar >*[2]; ptA->_exchange[0] = new HPDDM::template Subdomain< PetscScalar >(*ptB->_A); ptA->_exchange[0]->setBuffer( ); ptA->_exchange[1] = new HPDDM::template Subdomain< PetscScalar >(*ptC->_A); ptA->_exchange[1]->setBuffer( ); - } else ptA->_exchange = nullptr; + } else + ptA->_exchange = nullptr; } if (c == 0 && nargs[0] && GetAny< bool >((*nargs[0])(stack))) ptK->destroy( ); if (c != 3) - return ptA; + return ptA; else - return 0L; + return 0L; } template< class Type > class NonlinearSolver : public OneOperator { @@ -4072,15 +3751,9 @@ namespace PETSc { mutable Kn x_i; C_F0 c_x_i; Expression mat; - VecF_O(int n, Stack stk, const OneOperator* op) - : stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} - VecF_O(int n, Stack stk, const OneOperator* op, int) - : stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo< PetscReal >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} - VecF_O(int n, Stack stk, const OneOperator* op, int, int ni, int ne) - : stack(stk), x(n), c_x(CPValue(x)), x_e(std::max(0, ne)), c_x_e( ), x_i(std::max(0, ni)), - c_x_i( ), mat( ) { + VecF_O(int n, Stack stk, const OneOperator* op) : stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + VecF_O(int n, Stack stk, const OneOperator* op, int) : stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< PetscReal >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + VecF_O(int n, Stack stk, const OneOperator* op, int, int ni, int ne) : stack(stk), x(n), c_x(CPValue(x)), x_e(std::max(0, ne)), c_x_e( ), x_i(std::max(0, ni)), c_x_i( ), mat( ) { if (ne >= 0) c_x_e = CPValue(x_e); if (ni >= 0) c_x_i = CPValue(x_i); if (op) { @@ -4151,10 +3824,8 @@ namespace PETSc { C_F0 c_a; Expression mat; IVecF_O(int n, Stack stk, const OneOperator* op) - : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), x_t(n), c_x_t(CPValue(x_t)), - a(0), c_a(CPValue(a)), - mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_t, c_x, c_x_t, c_a})), (aType)*op)) - : 0) {} + : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), x_t(n), c_x_t(CPValue(x_t)), a(0), c_a(CPValue(a)), + mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_t, c_x, c_x_t, c_a})), (aType)*op)) : 0) {} ~IVecF_O( ) { delete mat; Expression zzz = c_t; @@ -4187,12 +3858,9 @@ namespace PETSc { C_F0 c_x_t; Expression mat; IMatF_O(int n, Stack stk, const OneOperator* op) - : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), x_t(n), c_x_t(CPValue(x_t)), - mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa({c_t, c_x, c_x_t})), (aType)*op)) - : 0) {} + : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), x_t(n), c_x_t(CPValue(x_t)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa({c_t, c_x, c_x_t})), (aType)*op)) : 0) {} IMatF_O(int n, Stack stk, const OneOperator* op, int) - : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), - mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa({c_t, c_x})), (aType)*op)) : 0) {} + : stack(stk), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa({c_t, c_x})), (aType)*op)) : 0) {} ~IMatF_O( ) { delete mat; Expression zzz = c_t; @@ -4229,9 +3897,7 @@ namespace PETSc { C_F0 c_x; Expression mat; IMonF_O(int n, Stack stk, const OneOperator* op) - : stack(stk), s(0), c_s(CPValue(s)), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), - mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_s, c_t, c_x})), (aType)*op)) : 0) { - } + : stack(stk), s(0), c_s(CPValue(s)), t(0), c_t(CPValue(t)), x(n), c_x(CPValue(x)), mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_s, c_t, c_x})), (aType)*op)) : 0) {} ~IMonF_O( ) { delete mat; Expression zzz = c_s; @@ -4268,12 +3934,8 @@ namespace PETSc { C_F0 c_dx; Expression mat; IConvF_O(int n, Stack stk, const OneOperator* op) - : stack(stk), it(0), c_it(CPValue(it)), xnorm(0), c_xnorm(CPValue(xnorm)), gnorm(0), - c_gnorm(CPValue(gnorm)), f(0), c_f(CPValue(f)), x(n), c_x(CPValue(x)), dx(n), - c_dx(CPValue(dx)), - mat(op ? CastTo< long >(C_F0( - op->code(basicAC_F0_wa({c_it, c_xnorm, c_gnorm, c_f, c_x, c_dx})), (aType)*op)) - : 0) {} + : stack(stk), it(0), c_it(CPValue(it)), xnorm(0), c_xnorm(CPValue(xnorm)), gnorm(0), c_gnorm(CPValue(gnorm)), f(0), c_f(CPValue(f)), x(n), c_x(CPValue(x)), dx(n), c_dx(CPValue(dx)), + mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa({c_it, c_xnorm, c_gnorm, c_f, c_x, c_dx})), (aType)*op)) : 0) {} ~IConvF_O( ) { delete mat; Expression zzz = c_it; @@ -4289,8 +3951,7 @@ namespace PETSc { zzz = c_dx; delete zzz; } - long apply(const long& iit, const double& ixnorm, const double& ignorm, const double& iff, - const Kn_& ix, const Kn_& idx) const { + long apply(const long& iit, const double& ixnorm, const double& ignorm, const double& iff, const Kn_& ix, const Kn_& idx) const { it = iit; xnorm = ixnorm; gnorm = ignorm; @@ -4316,8 +3977,7 @@ namespace PETSc { static const int n_name_param = 13; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - E_NonlinearSolver(const basicAC_F0& args, int d) - : A(0), J(0), r(0), x(0), codeJ(0), codeR(0), codeRHS(0), c(d) { + E_NonlinearSolver(const basicAC_F0& args, int d) : A(0), J(0), r(0), x(0), codeJ(0), codeR(0), codeRHS(0), c(d) { args.SetNameParam(n_name_param, name_param, nargs); A = to< Type* >(args[0]); const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[1].LeftValue( )); @@ -4328,16 +3988,11 @@ namespace PETSc { ffassert(op); codeR = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); } else { - codeJ = - op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( ), atype< double >( ), false)); + codeJ = op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( ), atype< double >( ), false)); op = dynamic_cast< const Polymorphic* >(args[2].LeftValue( )); ffassert(op); - codeR = op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( ), false)); - if (!codeR) - codeRHS = op->Find( - "(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), false)); + codeR = op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( ), false)); + if (!codeR) codeRHS = op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), false)); } if (c == 0 || c == 2 || c == 4) x = to< KN< PetscScalar >* >(args[3]); @@ -4347,8 +4002,7 @@ namespace PETSc { else { op = dynamic_cast< const Polymorphic* >(args[3].LeftValue( )); ffassert(op); - codeRHS = op->Find( - "(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), false)); + codeRHS = op->Find("(", ArrayOfaType(atype< double >( ), atype< KN< PetscScalar >* >( ), false)); } x = to< KN< PetscScalar >* >(args[4]); } @@ -4358,41 +4012,26 @@ namespace PETSc { operator aType( ) const { return atype< long >( ); } }; E_F0* code(const basicAC_F0& args) const { return new E_NonlinearSolver(args, c); } - NonlinearSolver(int I) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), - atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( )), - c(I == 1 ? 0 : 4) {} - NonlinearSolver( ) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), - atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( )), - c(1) {} - NonlinearSolver(int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), - atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( )), - c(2) {} + NonlinearSolver(int I) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( )), c(I == 1 ? 0 : 4) {} + NonlinearSolver( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( )), c(1) {} + NonlinearSolver(int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( )), c(2) {} NonlinearSolver(int, int, int) - : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), - atype< Polymorphic* >( ), atype< Polymorphic* >( ), - atype< KN< PetscScalar >* >( )), - c(3) {} + : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), atype< Polymorphic* >( ), atype< Polymorphic* >( ), atype< KN< PetscScalar >* >( )), c(3) {} }; template< class Type > - basicAC_F0::name_and_type NonlinearSolver< Type >::E_NonlinearSolver::name_param[] = { - {"sparams", &typeid(std::string*)}, - {"xl", &typeid(KN< PetscScalar >*)}, - {"xu", &typeid(KN< PetscScalar >*)}, - {"monitor", &typeid(Polymorphic*)}, - {"HessianRoutine", &typeid(Polymorphic*)}, - {"InequalityConstraints", &typeid(Polymorphic*)}, - {"EqualityConstraints", &typeid(Polymorphic*)}, - {"JacobianInequality", &typeid(Polymorphic*)}, - {"JacobianEquality", &typeid(Polymorphic*)}, - {"JI", &typeid(Type*)}, - {"JE", &typeid(Type*)}, - {"reason", &typeid(long*)}, - {"convergence", &typeid(Polymorphic*)} - }; + basicAC_F0::name_and_type NonlinearSolver< Type >::E_NonlinearSolver::name_param[] = {{"sparams", &typeid(std::string*)}, + {"xl", &typeid(KN< PetscScalar >*)}, + {"xu", &typeid(KN< PetscScalar >*)}, + {"monitor", &typeid(Polymorphic*)}, + {"HessianRoutine", &typeid(Polymorphic*)}, + {"InequalityConstraints", &typeid(Polymorphic*)}, + {"EqualityConstraints", &typeid(Polymorphic*)}, + {"JacobianInequality", &typeid(Polymorphic*)}, + {"JacobianEquality", &typeid(Polymorphic*)}, + {"JI", &typeid(Type*)}, + {"JE", &typeid(Type*)}, + {"reason", &typeid(long*)}, + {"convergence", &typeid(Polymorphic*)}}; template< class Type > PetscErrorCode FormJacobian(SNES snes, Vec x, Mat J, Mat B, void* ctx) { User< Type >* user; @@ -4400,24 +4039,22 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::VecF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >((*user)->op); + typename NonlinearSolver< Type >::VecF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >((*user)->op); VecGetArrayRead(x, &in); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); long ret = mat->apply(xx); VecRestoreArrayRead(x, &in); PetscFunctionReturn(PetscErrorCode(ret)); } - template + template< class Type > PetscErrorCode Monitor(SNES snes, PetscInt it, PetscReal norm, void* ctx) { - User* user; + User< Type >* user; const PetscScalar* in; Vec u; PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IMonF_O* mat = - reinterpret_cast::IMonF_O* >((*user)->mon); + typename NonlinearSolver< Type >::IMonF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IMonF_O* >((*user)->mon); SNESGetSolution(snes, &u); VecGetArrayRead(u, &in); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); @@ -4426,8 +4063,7 @@ namespace PETSc { PetscFunctionReturn(PETSC_SUCCESS); } template< class Type > - PetscErrorCode Convergence(SNES snes, PetscInt it, PetscReal xnorm, PetscReal gnorm, PetscReal f, - SNESConvergedReason* reason, void* ctx) { + PetscErrorCode Convergence(SNES snes, PetscInt it, PetscReal xnorm, PetscReal gnorm, PetscReal f, SNESConvergedReason* reason, void* ctx) { User< Type >* user; const PetscScalar* in; const PetscScalar* din; @@ -4435,8 +4071,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IConvF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::IConvF_O* >((*user)->conv); + typename NonlinearSolver< Type >::IConvF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IConvF_O* >((*user)->conv); SNESGetSolution(snes, &u); SNESGetSolutionUpdate(snes, &du); VecGetArrayRead(u, &in); @@ -4448,8 +4083,7 @@ namespace PETSc { *reason = SNESConvergedReason(mat->apply(it, xnorm, gnorm, f, xx, ww)); else if (*reason > 0) { PetscInt userreason = mat->apply(it, xnorm, gnorm, f, xx, ww); - if (userreason < 0) - *reason = SNESConvergedReason(userreason); + if (userreason < 0) *reason = SNESConvergedReason(userreason); } VecRestoreArrayRead(du, &din); VecRestoreArrayRead(u, &in); @@ -4462,9 +4096,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::VecF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >( - I == 0 ? (*user)->icJ : (I == 1 ? (*user)->ecJ : (*user)->op)); + typename NonlinearSolver< Type >::VecF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >(I == 0 ? (*user)->icJ : (I == 1 ? (*user)->ecJ : (*user)->op)); VecGetArrayRead(x, &in); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); long ret; @@ -4503,9 +4135,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename LinearSolver< Type >::MatF_O* mat = - reinterpret_cast< typename LinearSolver< Type >::MatF_O* >(I == 0 ? (*user)->ic - : (*user)->ec); + typename LinearSolver< Type >::MatF_O* mat = reinterpret_cast< typename LinearSolver< Type >::MatF_O* >(I == 0 ? (*user)->ic : (*user)->ec); VecGetArrayRead(x, &in); VecGetArray(c, &out); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->N); @@ -4523,8 +4153,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename LinearSolver< Type >::MatF_O* mat = - reinterpret_cast< typename LinearSolver< Type >::MatF_O* >((*user)->r); + typename LinearSolver< Type >::MatF_O* mat = reinterpret_cast< typename LinearSolver< Type >::MatF_O* >((*user)->r); VecGetArrayRead(x, &in); VecGetArray(f, &out); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->N); @@ -4541,8 +4170,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::VecF_O* J = - reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >((*user)->J); + typename NonlinearSolver< Type >::VecF_O* J = reinterpret_cast< typename NonlinearSolver< Type >::VecF_O* >((*user)->J); VecGetArrayRead(x, &in); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), J->x.n); J->apply(xx, f); @@ -4550,15 +4178,13 @@ namespace PETSc { PetscFunctionReturn(PETSC_SUCCESS); } template< class Type > - PetscErrorCode FormIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat J, Mat B, - void* ctx) { + PetscErrorCode FormIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat J, Mat B, void* ctx) { User< Type >* user; const PetscScalar *in, *in_t; PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IVecF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::IVecF_O* >((*user)->op); + typename NonlinearSolver< Type >::IVecF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IVecF_O* >((*user)->op); VecGetArrayRead(u, &in); VecGetArrayRead(u_t, &in_t); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); @@ -4576,8 +4202,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IMatF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::IMatF_O* >((*user)->r); + typename NonlinearSolver< Type >::IMatF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IMatF_O* >((*user)->r); VecGetArrayRead(u, &in); VecGetArrayRead(u_t, &in_t); VecGetArray(F, &out); @@ -4598,8 +4223,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IMatF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::IMatF_O* >((*user)->rhs); + typename NonlinearSolver< Type >::IMatF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IMatF_O* >((*user)->rhs); VecGetArrayRead(u, &in); VecGetArray(F, &out); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); @@ -4616,8 +4240,7 @@ namespace PETSc { PetscFunctionBeginUser; user = reinterpret_cast< User< Type >* >(ctx); - typename NonlinearSolver< Type >::IMonF_O* mat = - reinterpret_cast< typename NonlinearSolver< Type >::IMonF_O* >((*user)->mon); + typename NonlinearSolver< Type >::IMonF_O* mat = reinterpret_cast< typename NonlinearSolver< Type >::IMonF_O* >((*user)->mon); VecGetArrayRead(u, &in); KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->x.n); mat->apply(step, time, xx); @@ -4634,9 +4257,9 @@ namespace PETSc { if (!ptA->_num) MatGetOwnershipRange(ptA->_petsc, &first, &last); ffassert(in->n == 0 || in->n == last - first); if (in->n == 0) in->resize(last - first); - if(nargs[0]) { + if (nargs[0]) { std::string* options = GetAny< std::string* >((*nargs[0])(stack)); - PetscOptionsInsertString(NULL, options->c_str()); + PetscOptionsInsertString(NULL, options->c_str( )); } Vec r, x; MatCreateVecs(ptA->_petsc, &r, NULL); @@ -4647,11 +4270,9 @@ namespace PETSc { } KSP ksp; if (c < 2 || c == 4) { - KN< PetscScalar >* fl = - nargs[1] ? GetAny< KN< PetscScalar >* >((*nargs[1])(stack)) : nullptr; + KN< PetscScalar >* fl = nargs[1] ? GetAny< KN< PetscScalar >* >((*nargs[1])(stack)) : nullptr; bool setXl = (fl && fl->n == in->n); - KN< PetscScalar >* fu = - nargs[2] ? GetAny< KN< PetscScalar >* >((*nargs[2])(stack)) : nullptr; + KN< PetscScalar >* fu = nargs[2] ? GetAny< KN< PetscScalar >* >((*nargs[2])(stack)) : nullptr; bool setXu = (fu && fu->n == in->n); Vec xu, xl = nullptr; if (setXl || setXu) { @@ -4691,16 +4312,14 @@ namespace PETSc { const OneOperator* code = op->Find("(", ArrayOfaType(atype< Kn* >( ), false)); user->ic = new typename LinearSolver< Type >::MatF_O(in->n, stack, code, sizeI); VecCreateMPI(PETSC_COMM_WORLD, sizeI, PETSC_DECIDE, &ci); - TaoSetInequalityConstraintsRoutine(tao, ci, - FormConstraintsTao< TaoSolver< Type >, 0 >, &user); + TaoSetInequalityConstraintsRoutine(tao, ci, FormConstraintsTao< TaoSolver< Type >, 0 >, &user); } if (user->ic) { op = nargs[7] ? dynamic_cast< const Polymorphic* >(nargs[7]) : nullptr; if (op && pt && pt->_petsc) { const OneOperator* code = op->Find("(", ArrayOfaType(atype< Kn* >( ), false)); user->icJ = new NonlinearSolver< Type >::VecF_O(in->n, stack, code); - TaoSetJacobianInequalityRoutine(tao, pt->_petsc, pt->_petsc, - FormJacobianTao< TaoSolver< Type >, 0 >, &user); + TaoSetJacobianInequalityRoutine(tao, pt->_petsc, pt->_petsc, FormJacobianTao< TaoSolver< Type >, 0 >, &user); } } } @@ -4712,44 +4331,35 @@ namespace PETSc { const OneOperator* code = op->Find("(", ArrayOfaType(atype< Kn* >( ), false)); user->ec = new typename LinearSolver< Type >::MatF_O(in->n, stack, code, sizeE); VecCreateMPI(PETSC_COMM_WORLD, sizeE, PETSC_DECIDE, &ce); - TaoSetEqualityConstraintsRoutine(tao, ce, FormConstraintsTao< TaoSolver< Type >, 1 >, - &user); + TaoSetEqualityConstraintsRoutine(tao, ce, FormConstraintsTao< TaoSolver< Type >, 1 >, &user); } if (user->ec) { op = nargs[8] ? dynamic_cast< const Polymorphic* >(nargs[8]) : nullptr; if (op) { const OneOperator* code = op->Find("(", ArrayOfaType(atype< Kn* >( ), false)); user->ecJ = new NonlinearSolver< Type >::VecF_O(in->n, stack, code); - TaoSetJacobianEqualityRoutine(tao, pt->_petsc, pt->_petsc, - FormJacobianTao< TaoSolver< Type >, 1 >, &user); + TaoSetJacobianEqualityRoutine(tao, pt->_petsc, pt->_petsc, FormJacobianTao< TaoSolver< Type >, 1 >, &user); } } } op = nargs[4] ? dynamic_cast< const Polymorphic* >(nargs[4]) : nullptr; if (op) { if (user->icJ && user->ecJ) { - const OneOperator* codeH = op->Find( - "(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), atype< Kn* >( ), false)); + const OneOperator* codeH = op->Find("(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), atype< Kn* >( ), false)); user->op = new NonlinearSolver< Type >::VecF_O(in->n, stack, codeH, 2, sizeI, sizeE); - TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, - FormJacobianTao< TaoSolver< Type >, 5 >, &user); + TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, FormJacobianTao< TaoSolver< Type >, 5 >, &user); } else if (user->icJ) { - const OneOperator* codeH = - op->Find("(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), false)); + const OneOperator* codeH = op->Find("(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), false)); user->op = new NonlinearSolver< Type >::VecF_O(in->n, stack, codeH, 2, sizeI, -1); - TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, - FormJacobianTao< TaoSolver< Type >, 3 >, &user); + TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, FormJacobianTao< TaoSolver< Type >, 3 >, &user); } else if (user->ecJ) { - const OneOperator* codeH = - op->Find("(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), false)); + const OneOperator* codeH = op->Find("(", ArrayOfaType(atype< Kn* >( ), atype< Kn* >( ), false)); user->op = new NonlinearSolver< Type >::VecF_O(in->n, stack, codeH, 2, -1, sizeE); - TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, - FormJacobianTao< TaoSolver< Type >, 4 >, &user); + TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, FormJacobianTao< TaoSolver< Type >, 4 >, &user); } else { const OneOperator* codeH = op->Find("(", ArrayOfaType(atype< Kn* >( ), false)); user->op = new NonlinearSolver< Type >::VecF_O(in->n, stack, codeH); - TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, - FormJacobianTao< TaoSolver< Type >, 2 >, &user); + TaoSetHessian(tao, ptA->_petsc, ptA->_petsc, FormJacobianTao< TaoSolver< Type >, 2 >, &user); } } TaoSetFromOptions(tao); @@ -4776,8 +4386,7 @@ namespace PETSc { SNESCreate(PETSC_COMM_WORLD, &snes); Vec f; SNESSetFunction(snes, r, FormFunction< SNES, NonlinearSolver< Type > >, &user); - SNESSetJacobian(snes, ptA->_petsc, ptA->_petsc, FormJacobian< NonlinearSolver< Type > >, - &user); + SNESSetJacobian(snes, ptA->_petsc, ptA->_petsc, FormJacobian< NonlinearSolver< Type > >, &user); if (setXl || setXu) SNESVISetVariableBounds(snes, xl, xu); SNESSetFromOptions(snes); if (ptA->_ksp) { @@ -4790,15 +4399,12 @@ namespace PETSc { VecGetSize(r, &n); KN< PetscScalar >* fb = GetAny< KN< PetscScalar >* >((*b)(stack)); ffassert(fb->n == last - first); - VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, fb->n, n, static_cast< PetscScalar* >(*fb), - &f); + VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, fb->n, n, static_cast< PetscScalar* >(*fb), &f); } const Polymorphic* op = nargs[3] ? dynamic_cast< const Polymorphic* >(nargs[3]) : nullptr; if (op) { ffassert(op); - const OneOperator* codeM = - op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), - atype< KN< PetscScalar >* >( ), false)); + const OneOperator* codeM = op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), atype< KN< PetscScalar >* >( ), false)); user->mon = new NonlinearSolver< Type >::IMonF_O(in->n, stack, codeM); SNESMonitorSet(snes, Monitor< NonlinearSolver< Type > >, &user, NULL); } @@ -4806,9 +4412,7 @@ namespace PETSc { if (op) { ffassert(op); const OneOperator* codeC = - op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), atype< double >( ), - atype< double >( ), atype< KN< PetscScalar >* >( ), - atype< KN< PetscScalar >* >( ), false)); + op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), atype< double >( ), atype< double >( ), atype< KN< PetscScalar >* >( ), atype< KN< PetscScalar >* >( ), false)); user->conv = new NonlinearSolver< Type >::IConvF_O(in->n, stack, codeC); SNESSetConvergenceTest(snes, Convergence< NonlinearSolver< Type > >, &user, NULL); } @@ -4818,11 +4422,11 @@ namespace PETSc { SNESSetKSP(snes, ksp); KSPDestroy(&ksp); } - if(nargs[11]) { + if (nargs[11]) { SNESConvergedReason reason; SNESGetConvergedReason(snes, &reason); long* ret = GetAny< long* >((*nargs[11])(stack)); - *ret = static_cast(reason); + *ret = static_cast< long >(reason); } SNESDestroy(&snes); delete user->conv; @@ -4840,9 +4444,7 @@ namespace PETSc { PetscNew(&user); user->op = new NonlinearSolver< Type >::IVecF_O(in->n, stack, codeJ); user->r = (codeR ? new NonlinearSolver< Type >::IMatF_O(in->n, stack, codeR) : nullptr); - user->rhs = - (c == 3 || !codeR ? new NonlinearSolver< Type >::IMatF_O(in->n, stack, codeRHS, 1) - : nullptr); + user->rhs = (c == 3 || !codeR ? new NonlinearSolver< Type >::IMatF_O(in->n, stack, codeRHS, 1) : nullptr); user->mon = nullptr; TS ts; TSCreate(PetscObjectComm((PetscObject)ptA->_petsc), &ts); @@ -4860,8 +4462,7 @@ namespace PETSc { const Polymorphic* op = nargs[3] ? dynamic_cast< const Polymorphic* >(nargs[3]) : nullptr; if (op) { ffassert(op); - const OneOperator* codeM = op->Find( - "(", ArrayOfaType(atype< long >( ), atype< double >( ), atype< Kn* >( ), false)); + const OneOperator* codeM = op->Find("(", ArrayOfaType(atype< long >( ), atype< double >( ), atype< Kn* >( ), false)); user->mon = new NonlinearSolver< Type >::IMonF_O(in->n, stack, codeM); TSMonitorSet(ts, Monitor< TimeStepper< Type > >, &user, NULL); } @@ -4871,11 +4472,11 @@ namespace PETSc { SNESSetKSP(snes, ksp); KSPDestroy(&ksp); } - if(nargs[11]) { + if (nargs[11]) { TSConvergedReason reason; TSGetConvergedReason(ts, &reason); long* ret = GetAny< long* >((*nargs[11])(stack)); - *ret = static_cast(reason); + *ret = static_cast< long >(reason); } TSDestroy(&ts); delete user->mon; @@ -4888,39 +4489,37 @@ namespace PETSc { } return 0L; } - template< class Type, class Container, - typename std::enable_if< std::is_same< Container, Mat >::value >::type* = nullptr > + template< class Type, class Container, typename std::enable_if< std::is_same< Container, Mat >::value >::type* = nullptr > static PetscErrorCode ContainerGetContext(Container A, Type& user) { return MatShellGetContext(A, &user); } - template< class Type, class Container, - typename std::enable_if< std::is_same< Container, PC >::value >::type* = nullptr > + template< class Type, class Container, typename std::enable_if< std::is_same< Container, PC >::value >::type* = nullptr > static PetscErrorCode ContainerGetContext(Container A, Type& user) { return PCShellGetContext(A, (void**)&user); } template< class Type, class Container, char N > static PetscErrorCode Op_User(Container A, Vec x, Vec y) { - static_assert(std::is_same::value || N == 'N', "Wrong types"); + static_assert(std::is_same< Container, Mat >::value || N == 'N', "Wrong types"); User< Type > user; const PetscScalar* in; PetscScalar* out; PetscErrorCode ierr; PetscFunctionBeginUser; - ierr = ContainerGetContext(A, user);CHKERRQ(ierr); - typename LinearSolver< Type >::MatF_O* mat = - reinterpret_cast< typename LinearSolver< Type >::MatF_O* >(user->op); + ierr = ContainerGetContext(A, user); + CHKERRQ(ierr); + typename LinearSolver< Type >::MatF_O* mat = reinterpret_cast< typename LinearSolver< Type >::MatF_O* >(user->op); VecGetArrayRead(x, &in); VecGetArray(y, &out); - if(N == 'N') { - KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->N); - KN_< PetscScalar > yy(out, mat->M); - yy = *mat * xx; + if (N == 'N') { + KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->N); + KN_< PetscScalar > yy(out, mat->M); + yy = *mat * xx; } else { - KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->M); - KN_< PetscScalar > yy(out, mat->N); - typename LinearSolver< Type >::MatF_O::plusAtx Atxx(mat, xx); - yy = Atxx; + KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->M); + KN_< PetscScalar > yy(out, mat->N); + typename LinearSolver< Type >::MatF_O::plusAtx Atxx(mat, xx); + yy = Atxx; } VecRestoreArray(y, &out); VecRestoreArrayRead(x, &in); @@ -4928,91 +4527,86 @@ namespace PETSc { } template< bool U, char T, class K > - void loopDistributedVec(Mat nest, HPDDM::Subdomain** exchange, KN_>* const& in, K* out) { - Mat** mat; - PetscInt M, N; - MatNestGetSubMats(nest, &M, &N, &mat); - Dmat** cast = reinterpret_cast(exchange); - PetscScalar* ptr = reinterpret_cast(in->operator upscaled_type*()); - MatType type; - PetscBool isType; - if(T == 'N') { - for(PetscInt i = 0; i < M; ++i) { - for(PetscInt j = 0; j < N; ++j) { - if(mat[i][j]) { - MatGetType(mat[i][j], &type); - PetscObjectTypeCompareAny((PetscObject)mat[i][j], &isType, MATMPIDENSE, MATSEQDENSE, ""); - PetscInt n = 0, m = 0; - if(!isType) { - Mat C = NULL; - PetscStrcmp(type, MATHERMITIANTRANSPOSEVIRTUAL, &isType); - if(isType) - MatHermitianTransposeGetMat(mat[i][j], &C); - else if(PetscDefined(USE_COMPLEX)) { - PetscStrcmp(type, MATTRANSPOSEVIRTUAL, &isType); - if(isType) - MatTransposeGetMat(mat[i][j], &C); - } - if(C) { - PetscObjectTypeCompareAny((PetscObject)C, &isType, MATMPIDENSE, MATSEQDENSE, ""); - if(isType) MatGetSize(C, &m, &n); - type = MATHERMITIANTRANSPOSEVIRTUAL; - } - } else MatGetSize(mat[i][j], &n, &m); - if(isType && m >= n && !(cast[i * N + j] && cast[i * N + j]->_num)) { - PetscMPIInt rank; - MPI_Comm_rank(PetscObjectComm((PetscObject)mat[i][j]), &rank); - if(rank == 0) { - for(int m = 0; m < n; ++m) { - if(U) - *ptr++ = *out++; - else - *out++ = *ptr++; - } - } - break; - } - else if(cast[i * N + j]) { - PetscStrcmp(type, MATHERMITIANTRANSPOSEVIRTUAL, &isType); - PetscInt* num = nullptr, first, last, n; - const HPDDM::Subdomain* A = nullptr; - if(cast[i * N + j]->_cnum) { - if(isType) { - num = cast[i * N + j]->_cnum; - first = cast[i * N + j]->_cfirst; - last = cast[i * N + j]->_clast; - } - else { - num = cast[i * N + j]->_num; - first = cast[i * N + j]->_first; - last = cast[i * N + j]->_last; - } - if(cast[i * N + j]->_exchange) A = cast[i * N + j]->_exchange[isType ? 1 : 0]; - n = A ? A->getDof() : 0; - } - else { - num = cast[i * N + j]->_num; - first = cast[i * N + j]->_first; - last = cast[i * N + j]->_last; - A = cast[i * N + j]->_A; - n = A ? A->getDof() : 0; - } - if(num) { - HPDDM::Subdomain< K >::template distributedVec< U >(num, first, last, ptr, out, n, 1); - if (U && A) - A->exchange(ptr); - ptr += n; - out += last - first; - break; - } - } - } + void loopDistributedVec(Mat nest, HPDDM::Subdomain< PetscScalar >** exchange, KN_< upscaled_type< K > >* const& in, K* out) { + Mat** mat; + PetscInt M, N; + MatNestGetSubMats(nest, &M, &N, &mat); + Dmat** cast = reinterpret_cast< Dmat** >(exchange); + PetscScalar* ptr = reinterpret_cast< PetscScalar* >(in->operator upscaled_type< PetscScalar >*( )); + MatType type; + PetscBool isType; + if (T == 'N') { + for (PetscInt i = 0; i < M; ++i) { + for (PetscInt j = 0; j < N; ++j) { + if (mat[i][j]) { + MatGetType(mat[i][j], &type); + PetscObjectTypeCompareAny((PetscObject)mat[i][j], &isType, MATMPIDENSE, MATSEQDENSE, ""); + PetscInt n = 0, m = 0; + if (!isType) { + Mat C = NULL; + PetscStrcmp(type, MATHERMITIANTRANSPOSEVIRTUAL, &isType); + if (isType) + MatHermitianTransposeGetMat(mat[i][j], &C); + else if (PetscDefined(USE_COMPLEX)) { + PetscStrcmp(type, MATTRANSPOSEVIRTUAL, &isType); + if (isType) MatTransposeGetMat(mat[i][j], &C); + } + if (C) { + PetscObjectTypeCompareAny((PetscObject)C, &isType, MATMPIDENSE, MATSEQDENSE, ""); + if (isType) MatGetSize(C, &m, &n); + type = MATHERMITIANTRANSPOSEVIRTUAL; + } + } else + MatGetSize(mat[i][j], &n, &m); + if (isType && m >= n && !(cast[i * N + j] && cast[i * N + j]->_num)) { + PetscMPIInt rank; + MPI_Comm_rank(PetscObjectComm((PetscObject)mat[i][j]), &rank); + if (rank == 0) { + for (int m = 0; m < n; ++m) { + if (U) + *ptr++ = *out++; + else + *out++ = *ptr++; + } + } + break; + } else if (cast[i * N + j]) { + PetscStrcmp(type, MATHERMITIANTRANSPOSEVIRTUAL, &isType); + PetscInt *num = nullptr, first, last, n; + const HPDDM::Subdomain< PetscScalar >* A = nullptr; + if (cast[i * N + j]->_cnum) { + if (isType) { + num = cast[i * N + j]->_cnum; + first = cast[i * N + j]->_cfirst; + last = cast[i * N + j]->_clast; + } else { + num = cast[i * N + j]->_num; + first = cast[i * N + j]->_first; + last = cast[i * N + j]->_last; + } + if (cast[i * N + j]->_exchange) A = cast[i * N + j]->_exchange[isType ? 1 : 0]; + n = A ? A->getDof( ) : 0; + } else { + num = cast[i * N + j]->_num; + first = cast[i * N + j]->_first; + last = cast[i * N + j]->_last; + A = cast[i * N + j]->_A; + n = A ? A->getDof( ) : 0; } + if (num) { + HPDDM::Subdomain< K >::template distributedVec< U >(num, first, last, ptr, out, n, 1); + if (U && A) A->exchange(ptr); + ptr += n; + out += last - first; + break; + } + } } + } } - else { - ffassert(0); - } + } else { + ffassert(0); + } } template< class T, class U, class K, char trans > @@ -5029,30 +4623,29 @@ namespace PETSc { Vec x, y; double timing = MPI_Wtime( ); MatCreateVecs((*t)._petsc, &x, &y); - ffassert(out->N() == u->N() && out->M() == u->M()); + ffassert(out->N( ) == u->N( ) && out->M( ) == u->M( )); PetscScalar* ptr; MatType type; PetscBool isType; MatGetType((*t)._petsc, &type); PetscStrcmp(type, MATNEST, &isType); - PetscScalar* p = reinterpret_cast(u->operator upscaled_type*()); + PetscScalar* p = reinterpret_cast< PetscScalar* >(u->operator upscaled_type< PetscScalar >*( )); if ((*t)._vector_global) { - ffassert(out->M() == 1); - for(int i = 0; i < u->n; ++i) - p[i] = u->operator[](i); - MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper::mpi_type(), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); + ffassert(out->M( ) == 1); + for (int i = 0; i < u->n; ++i) p[i] = u->operator[](i); + MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper< K >::mpi_type( ), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); VecGetArray(x, &ptr); - if(isType) { // case nested matrix + if (isType) { // case nested matrix Mat** mat; PetscInt M, N; PetscInt Mi = 0, Ni = 0; MatNestGetSubMats((*t)._petsc, &M, &N, &mat); PetscInt offset_cols = 0; PetscInt offset_local_cols = 0; - for(PetscInt j = 0; j < N; ++j) { // cols - for(PetscInt i = 0; i < M; ++i) { // rows + for (PetscInt j = 0; j < N; ++j) { // cols + for (PetscInt i = 0; i < M; ++i) { // rows Ni = 0, Mi = 0; - if(mat[i][j]) { + if (mat[i][j]) { MatGetSize(mat[i][j], &Mi, &Ni); PetscInt cbegin; @@ -5060,61 +4653,50 @@ namespace PETSc { MatGetLocalSize(mat[i][j], &mi, &ni); MatGetOwnershipRangeColumn(mat[i][j], &cbegin, NULL); - for(PetscInt i = 0; i < ni; ++i) - ptr[i + offset_local_cols] = p[i + cbegin + offset_cols]; + for (PetscInt i = 0; i < ni; ++i) ptr[i + offset_local_cols] = p[i + cbegin + offset_cols]; offset_cols += Ni; offset_local_cols += ni; break; - } // if mat[i][j] - } // loop rows - } // loop cols - } // if nested matrix + } // if mat[i][j] + } // loop rows + } // loop cols + } // if nested matrix else { // case not nested matrix PetscInt cbegin, n, m, N, M; - MatGetLocalSize( (*t)._petsc, &m, &n); - MatGetOwnershipRangeColumn( (*t)._petsc, &cbegin, NULL); - for(PetscInt i = 0; i < n; ++i) - ptr[i] = p[i + cbegin]; + MatGetLocalSize((*t)._petsc, &m, &n); + MatGetOwnershipRangeColumn((*t)._petsc, &cbegin, NULL); + for (PetscInt i = 0; i < n; ++i) ptr[i] = p[i + cbegin]; } VecRestoreArray(x, &ptr); - } - else if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, - HpSchwarz< PetscScalar > >::value) { + } else if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, HpSchwarz< PetscScalar > >::value) { #if !defined(PETSC_USE_REAL_DOUBLE) - for(int j = 0; j < out->M(); ++j) - for(int i = 0; i < u->N(); ++i) - p[i + j * u->N()] = u->operator[](i, j); + for (int j = 0; j < out->M( ); ++j) + for (int i = 0; i < u->N( ); ++i) p[i + j * u->N( )] = u->operator[](i, j); #else - static_assert(std::is_same>::value, "Wrong types"); + static_assert(std::is_same< PetscReal, upscaled_type< PetscReal > >::value, "Wrong types"); #endif - if (out->M() == 1) { + if (out->M( ) == 1) { VecGetArray(x, &ptr); - if(isType) { - ffassert((std::is_same>::value)); - loopDistributedVec<0, 'N'>((*t)._petsc, (*t)._exchange, u, ptr); - } - else - HPDDM::Subdomain< K >::template distributedVec< 0 >((*t)._num, (*t)._first, (*t)._last, - p, ptr, - static_cast(u->N()), 1); + if (isType) { + ffassert((std::is_same< PetscReal, upscaled_type< PetscReal > >::value)); + loopDistributedVec< 0, 'N' >((*t)._petsc, (*t)._exchange, u, ptr); + } else + HPDDM::Subdomain< K >::template distributedVec< 0 >((*t)._num, (*t)._first, (*t)._last, p, ptr, static_cast< PetscInt >(u->N( )), 1); VecRestoreArray(x, &ptr); - } - else { + } else { ffassert(!isType); PetscInt m, M; MatGetLocalSize((*t)._petsc, &m, nullptr); MatGetSize((*t)._petsc, &M, nullptr); - MatCreateDense(PetscObjectComm((PetscObject)(*t)._petsc), m, PETSC_DECIDE, M, out->M(), nullptr, &X); - MatCreateDense(PetscObjectComm((PetscObject)(*t)._petsc), m, PETSC_DECIDE, M, out->M(), nullptr, &Y); + MatCreateDense(PetscObjectComm((PetscObject)(*t)._petsc), m, PETSC_DECIDE, M, out->M( ), nullptr, &X); + MatCreateDense(PetscObjectComm((PetscObject)(*t)._petsc), m, PETSC_DECIDE, M, out->M( ), nullptr, &Y); MatDenseGetArrayWrite(X, &ptr); - for(int j = 0; j < out->M(); ++j) { - PetscScalar* in = p + j * u->N(); + for (int j = 0; j < out->M( ); ++j) { + PetscScalar* in = p + j * u->N( ); PetscScalar* out = ptr + j * m; - HPDDM::Subdomain< K >::template distributedVec< 0 >((*t)._num, (*t)._first, (*t)._last, - in, out, - static_cast(u->N()), 1); + HPDDM::Subdomain< K >::template distributedVec< 0 >((*t)._num, (*t)._first, (*t)._last, in, out, static_cast< PetscInt >(u->N( )), 1); } MatDenseRestoreArrayWrite(X, &ptr); } @@ -5122,29 +4704,25 @@ namespace PETSc { PetscBool nonZero; KSPGetInitialGuessNonzero((*t)._ksp, &nonZero); if (nonZero) { - ffassert(out->M() == 1); + ffassert(out->M( ) == 1); VecGetArray(y, &ptr); - p = reinterpret_cast(out->operator upscaled_type*()); + p = reinterpret_cast< PetscScalar* >(out->operator upscaled_type< PetscScalar >*( )); #if !defined(PETSC_USE_REAL_DOUBLE) - for(int i = 0; i < out->n; ++i) - p[i] = out->operator[](i); + for (int i = 0; i < out->n; ++i) p[i] = out->operator[](i); #endif - if(isType) - loopDistributedVec<0, 'N'>((*t)._petsc, (*t)._exchange, out, ptr); + if (isType) + loopDistributedVec< 0, 'N' >((*t)._petsc, (*t)._exchange, out, ptr); else - HPDDM::Subdomain< K >::template distributedVec< 0 >( - (*t)._num, (*t)._first, (*t)._last, p, ptr, - static_cast(out->n), 1); + HPDDM::Subdomain< K >::template distributedVec< 0 >((*t)._num, (*t)._first, (*t)._last, p, ptr, static_cast< PetscInt >(out->n), 1); VecRestoreArray(y, &ptr); } } - *out = K(); + *out = K( ); } else { - ffassert(out->M() == 1); + ffassert(out->M( ) == 1); VecSet(x, PetscScalar( )); Vec isVec; - VecCreateMPIWithArray(PETSC_COMM_SELF, 1, (*t)._A->getMatrix( )->HPDDM_n, - (*t)._A->getMatrix( )->HPDDM_n, p, &isVec); + VecCreateMPIWithArray(PETSC_COMM_SELF, 1, (*t)._A->getMatrix( )->HPDDM_n, (*t)._A->getMatrix( )->HPDDM_n, p, &isVec); VecScatterBegin((*t)._scatter, isVec, x, ADD_VALUES, SCATTER_REVERSE); VecScatterEnd((*t)._scatter, isVec, x, ADD_VALUES, SCATTER_REVERSE); VecDestroy(&isVec); @@ -5170,11 +4748,12 @@ namespace PETSc { } } if (trans == 'N') { - if (out->M() == 1) KSPSolve((*t)._ksp, x, y); - else KSPMatSolve((*t)._ksp, X, Y); - } - else { - if (out->M() == 1) { + if (out->M( ) == 1) + KSPSolve((*t)._ksp, x, y); + else + KSPMatSolve((*t)._ksp, X, Y); + } else { + if (out->M( ) == 1) { if (!std::is_same< PetscScalar, PetscReal >::value && t.conjugate) VecConjugate(x); KSPSolveTranspose((*t)._ksp, x, y); if (!std::is_same< PetscScalar, PetscReal >::value && t.conjugate) VecConjugate(y); @@ -5184,12 +4763,11 @@ namespace PETSc { if (!std::is_same< PetscScalar, PetscReal >::value && t.conjugate) MatConjugate(Y); } } - if (verbosity > 0 && mpirank == 0) - cout << " --- system solved with PETSc (in " << MPI_Wtime( ) - timing << ")" << endl; - p = reinterpret_cast(out->operator upscaled_type*()); + if (verbosity > 0 && mpirank == 0) cout << " --- system solved with PETSc (in " << MPI_Wtime( ) - timing << ")" << endl; + p = reinterpret_cast< PetscScalar* >(out->operator upscaled_type< PetscScalar >*( )); if ((*t)._vector_global) { VecGetArray(y, &ptr); - if(isType) { + if (isType) { Mat** mat; PetscInt M, N; PetscInt Mi = 0, Ni = 0; @@ -5197,58 +4775,52 @@ namespace PETSc { PetscInt offset_rows = 0; PetscInt offset_local_rows = 0; - for(PetscInt i = 0; i < M; ++i) { // rows - for(PetscInt j = 0; j < N; ++j) { // cols + for (PetscInt i = 0; i < M; ++i) { // rows + for (PetscInt j = 0; j < N; ++j) { // cols Ni = 0, Mi = 0; - if(mat[i][j]) { + if (mat[i][j]) { MatGetSize(mat[i][j], &Mi, &Ni); PetscInt rbegin; - PetscInt ni,mi; + PetscInt ni, mi; MatGetLocalSize(mat[i][j], &mi, &ni); MatGetOwnershipRange(mat[i][j], &rbegin, NULL); - for(PetscInt i = 0; i < mi; ++i) - p[i + rbegin + offset_rows] = ptr[i + offset_local_rows]; + for (PetscInt i = 0; i < mi; ++i) p[i + rbegin + offset_rows] = ptr[i + offset_local_rows]; offset_rows += Mi; offset_local_rows += mi; break; - } // if mat[i][j] - } // loop rows - } // loop cols - } // if nested matrix + } // if mat[i][j] + } // loop rows + } // loop cols + } // if nested matrix else { // case not nested matrix PetscInt rbegin, n, m, N, M; MatGetOwnershipRange((*t)._petsc, &rbegin, NULL); MatGetLocalSize((*t)._petsc, &m, &n); std::fill_n(p, u->n, 0.0); - for(PetscInt i = 0; i < m; ++i) - p[i + rbegin] = ptr[i]; + for (PetscInt i = 0; i < m; ++i) p[i + rbegin] = ptr[i]; } VecRestoreArray(y, &ptr); - MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper::mpi_type(), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); - } - else if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, - HpSchwarz< PetscScalar > >::value) { - if (out->M() == 1) { + MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper< K >::mpi_type( ), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); + } else if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, HpSchwarz< PetscScalar > >::value) { + if (out->M( ) == 1) { VecGetArray(y, &ptr); - if(isType) - loopDistributedVec<1, 'N'>((*t)._petsc, (*t)._exchange, out, ptr); + if (isType) + loopDistributedVec< 1, 'N' >((*t)._petsc, (*t)._exchange, out, ptr); else - HPDDM::Subdomain< K >::template distributedVec< 1 >((*t)._num, (*t)._first, (*t)._last, p, - ptr, static_cast(out->N()), 1); + HPDDM::Subdomain< K >::template distributedVec< 1 >((*t)._num, (*t)._first, (*t)._last, p, ptr, static_cast< PetscInt >(out->N( )), 1); VecRestoreArray(y, &ptr); } else { PetscInt m; MatGetLocalSize((*t)._petsc, &m, nullptr); MatDenseGetArrayWrite(Y, &ptr); - for(int j = 0; j < out->M(); ++j) { - PetscScalar* in = p + j * u->N(); + for (int j = 0; j < out->M( ); ++j) { + PetscScalar* in = p + j * u->N( ); PetscScalar* out = ptr + j * m; - HPDDM::Subdomain< K >::template distributedVec< 1 >((*t)._num, (*t)._first, (*t)._last, in, - out, static_cast(u->N()), 1); + HPDDM::Subdomain< K >::template distributedVec< 1 >((*t)._num, (*t)._first, (*t)._last, in, out, static_cast< PetscInt >(u->N( )), 1); } MatDenseRestoreArrayWrite(Y, &ptr); MatDestroy(&X); @@ -5256,25 +4828,19 @@ namespace PETSc { } } else { Vec isVec; - VecCreateMPIWithArray(PETSC_COMM_SELF, 1, (*t)._A->getMatrix( )->HPDDM_n, - (*t)._A->getMatrix( )->HPDDM_n, p, &isVec); + VecCreateMPIWithArray(PETSC_COMM_SELF, 1, (*t)._A->getMatrix( )->HPDDM_n, (*t)._A->getMatrix( )->HPDDM_n, p, &isVec); VecScatterBegin((*t)._scatter, y, isVec, INSERT_VALUES, SCATTER_FORWARD); VecScatterEnd((*t)._scatter, y, isVec, INSERT_VALUES, SCATTER_FORWARD); VecDestroy(&isVec); } VecDestroy(&x); VecDestroy(&y); - if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, - HpSchwarz< PetscScalar > >::value && - t.A->_A) - (*t)._A->exchange(p, out->M()); - if(!std::is_same>::value) { - ffassert(out->M() == 1); - for(int i = out->N() - 1; i >= 0; --i) - out->operator[](i) = p[i]; - p = reinterpret_cast(u->operator upscaled_type*()); - for(int i = u->N() - 1; i >= 0; --i) - u->operator[](i) = p[i]; + if (std::is_same< typename std::remove_reference< decltype(*t.A->_A) >::type, HpSchwarz< PetscScalar > >::value && t.A->_A) (*t)._A->exchange(p, out->M( )); + if (!std::is_same< PetscReal, upscaled_type< PetscReal > >::value) { + ffassert(out->M( ) == 1); + for (int i = out->N( ) - 1; i >= 0; --i) out->operator[](i) = p[i]; + p = reinterpret_cast< PetscScalar* >(u->operator upscaled_type< PetscScalar >*( )); + for (int i = u->N( ) - 1; i >= 0; --i) u->operator[](i) = p[i]; } } }; @@ -5314,12 +4880,12 @@ namespace PETSc { MatType type; MatGetType((*t)._petsc, &type); PetscBool isType; - PetscScalar* p = reinterpret_cast(u->operator upscaled_type*()); + PetscScalar* p = reinterpret_cast< PetscScalar* >(u->operator upscaled_type< PetscScalar >*( )); PetscStrcmp(type, MATNEST, &isType); - if((*t)._vector_global) { - MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper::mpi_type(), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); + if ((*t)._vector_global) { + MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper< K >::mpi_type( ), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); // VecGetArray(x, &ptr) is defined before - if(isType) { // case nested matrix + if (isType) { // case nested matrix Mat** mat; PetscInt Mb, Nb; PetscInt Mi = 0, Ni = 0; @@ -5327,10 +4893,10 @@ namespace PETSc { PetscInt offset_cols = 0; PetscInt offset_local_cols = 0; - for(PetscInt j = 0; j < Nb; ++j) { // cols - for(PetscInt i = 0; i < Mb; ++i) { // rows + for (PetscInt j = 0; j < Nb; ++j) { // cols + for (PetscInt i = 0; i < Mb; ++i) { // rows Ni = 0, Mi = 0; - if(mat[i][j]) { + if (mat[i][j]) { MatGetSize(mat[i][j], &Mi, &Ni); PetscInt cbegin; @@ -5338,47 +4904,40 @@ namespace PETSc { MatGetLocalSize(mat[i][j], &mi, &ni); MatGetOwnershipRangeColumn(mat[i][j], &cbegin, NULL); - for(PetscInt i = 0; i < ni; ++i) - ptr[i + offset_local_cols] = p[i + cbegin + offset_cols]; + for (PetscInt i = 0; i < ni; ++i) ptr[i + offset_local_cols] = p[i + cbegin + offset_cols]; offset_cols += Ni; offset_local_cols += ni; break; - } // if mat[i][j] - } // loop rows - } // loop cols - } // if nested matrix + } // if mat[i][j] + } // loop rows + } // loop cols + } // if nested matrix else { // case not nested matrix - PetscInt cbegin, n,m; + PetscInt cbegin, n, m; MatGetLocalSize((*t)._petsc, &m, &n); MatGetOwnershipRangeColumn((*t)._petsc, &cbegin, NULL); - for(PetscInt i = 0; i < n; ++i) - ptr[i] = p[i + cbegin]; + for (PetscInt i = 0; i < n; ++i) ptr[i] = p[i + cbegin]; } - } - else if (isType) { - ffassert((std::is_same>::value)); - loopDistributedVec<0, N>(t->_petsc, t->_exchange, u, ptr); + } else if (isType) { + ffassert((std::is_same< PetscReal, upscaled_type< PetscReal > >::value)); + loopDistributedVec< 0, N >(t->_petsc, t->_exchange, u, ptr); } else { - if(t->_A) - ffassert(u->n == t->_A->getDof() && out->n == t->_A->getDof()); + if (t->_A) + ffassert(u->n == t->_A->getDof( ) && out->n == t->_A->getDof( )); else if (t->_exchange) { if (N == 'T') { - ffassert(u->n == t->_exchange[0]->getDof() && out->n == t->_exchange[1]->getDof()); + ffassert(u->n == t->_exchange[0]->getDof( ) && out->n == t->_exchange[1]->getDof( )); } else { - ffassert(u->n == t->_exchange[1]->getDof() && out->n == t->_exchange[0]->getDof()); + ffassert(u->n == t->_exchange[1]->getDof( ) && out->n == t->_exchange[0]->getDof( )); } } - for(int i = 0; i < u->n; ++i) - p[i] = u->operator[](i); + for (int i = 0; i < u->n; ++i) p[i] = u->operator[](i); if (!t->_cnum || N == 'T') { - if (t->_num) - HPDDM::Subdomain< K >::template distributedVec< 0 >( - t->_num, t->_first, t->_last, p, ptr, static_cast(u->n), 1); + if (t->_num) HPDDM::Subdomain< K >::template distributedVec< 0 >(t->_num, t->_first, t->_last, p, ptr, static_cast< PetscInt >(u->n), 1); } else - HPDDM::Subdomain< K >::template distributedVec< 0 >( - t->_cnum, t->_cfirst, t->_clast, p, ptr, static_cast(u->n), 1); + HPDDM::Subdomain< K >::template distributedVec< 0 >(t->_cnum, t->_cfirst, t->_clast, p, ptr, static_cast< PetscInt >(u->n), 1); } VecRestoreArray(x, &ptr); if (N == 'T') @@ -5388,9 +4947,9 @@ namespace PETSc { VecDestroy(&x); VecGetArray(y, &ptr); - if((*t)._vector_global){ - p = reinterpret_cast(out->operator upscaled_type*()); - if(isType) { + if ((*t)._vector_global) { + p = reinterpret_cast< PetscScalar* >(out->operator upscaled_type< PetscScalar >*( )); + if (isType) { Mat** mat; PetscInt Mb, Nb; PetscInt Mi = 0, Ni = 0; @@ -5398,77 +4957,67 @@ namespace PETSc { PetscInt offset_rows = 0; PetscInt offset_local_rows = 0; - for(PetscInt i = 0; i < Mb; ++i) { // rows - for(PetscInt j = 0; j < Nb; ++j) { // cols + for (PetscInt i = 0; i < Mb; ++i) { // rows + for (PetscInt j = 0; j < Nb; ++j) { // cols Ni = 0, Mi = 0; - if(mat[i][j]) { + if (mat[i][j]) { MatGetSize(mat[i][j], &Mi, &Ni); PetscInt rbegin, ni, mi; MatGetLocalSize(mat[i][j], &mi, &ni); MatGetOwnershipRange(mat[i][j], &rbegin, NULL); - for(PetscInt i = 0; i < mi; ++i) - p[i + rbegin + offset_rows] = ptr[i + offset_local_rows]; + for (PetscInt i = 0; i < mi; ++i) p[i + rbegin + offset_rows] = ptr[i + offset_local_rows]; offset_rows += Mi; offset_local_rows += mi; break; - } // if mat[i][j] - } // loop rows - } // loop cols - } // if nested matrix - else{ + } // if mat[i][j] + } // loop rows + } // loop cols + } // if nested matrix + else { // case not nested matrix PetscInt rbegin, n, m; MatGetOwnershipRange((*t)._petsc, &rbegin, NULL); MatGetLocalSize((*t)._petsc, &m, &n); std::fill_n(p, u->n, 0.0); - for(PetscInt i = 0; i < m; ++i) - p[i + rbegin] = ptr[i]; + for (PetscInt i = 0; i < m; ++i) p[i + rbegin] = ptr[i]; } VecRestoreArray(y, &ptr); - MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper::mpi_type(), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); - for(int i = out->n - 1; i >= 0; --i) - out->operator[](i) = p[i]; - if(!std::is_same>::value) { - p = reinterpret_cast(u->operator upscaled_type*()); - for(int i = u->n - 1; i >= 0; --i) - u->operator[](i) = p[i]; + MPI_Allreduce(MPI_IN_PLACE, p, u->n, HPDDM::Wrapper< K >::mpi_type( ), MPI_SUM, PetscObjectComm((PetscObject)(*t)._petsc)); + for (int i = out->n - 1; i >= 0; --i) out->operator[](i) = p[i]; + if (!std::is_same< PetscReal, upscaled_type< PetscReal > >::value) { + p = reinterpret_cast< PetscScalar* >(u->operator upscaled_type< PetscScalar >*( )); + for (int i = u->n - 1; i >= 0; --i) u->operator[](i) = p[i]; } - } - else{ - if (!t->_A) std::fill_n(out->operator upscaled_type*(), out->n, 0.0); - if (isType) { - loopDistributedVec<1, N>(t->_petsc, t->_exchange, out, ptr); } else { - p = reinterpret_cast(out->operator upscaled_type*()); - if (!t->_cnum || N == 'N') { - if (t->_num) - HPDDM::Subdomain< K >::template distributedVec< 1 >(t->_num, t->_first, t->_last, p, - ptr, static_cast(out->n), 1); - } else - HPDDM::Subdomain< K >::template distributedVec< 1 >(t->_cnum, t->_cfirst, t->_clast, p, - ptr, static_cast(out->n), 1); - if (t->_A) - (*t)._A->exchange(p); - else if (t->_exchange) { - if (N == 'N') - (*t)._exchange[0]->exchange(p); - else - (*t)._exchange[1]->exchange(p); - } - for(int i = out->n - 1; i >= 0; --i) - out->operator[](i) = p[i]; - if(!std::is_same>::value) { - p = reinterpret_cast(u->operator upscaled_type*()); - for(int i = u->n - 1; i >= 0; --i) - u->operator[](i) = p[i]; + if (!t->_A) std::fill_n(out->operator upscaled_type< PetscScalar >*( ), out->n, 0.0); + if (isType) { + loopDistributedVec< 1, N >(t->_petsc, t->_exchange, out, ptr); + } else { + p = reinterpret_cast< PetscScalar* >(out->operator upscaled_type< PetscScalar >*( )); + if (!t->_cnum || N == 'N') { + if (t->_num) HPDDM::Subdomain< K >::template distributedVec< 1 >(t->_num, t->_first, t->_last, p, ptr, static_cast< PetscInt >(out->n), 1); + } else + HPDDM::Subdomain< K >::template distributedVec< 1 >(t->_cnum, t->_cfirst, t->_clast, p, ptr, static_cast< PetscInt >(out->n), 1); + if (t->_A) + (*t)._A->exchange(p); + else if (t->_exchange) { + if (N == 'N') + (*t)._exchange[0]->exchange(p); + else + (*t)._exchange[1]->exchange(p); + } + for (int i = out->n - 1; i >= 0; --i) out->operator[](i) = p[i]; + if (!std::is_same< PetscReal, upscaled_type< PetscReal > >::value) { + p = reinterpret_cast< PetscScalar* >(u->operator upscaled_type< PetscScalar >*( )); + for (int i = u->n - 1; i >= 0; --i) u->operator[](i) = p[i]; + } } } - } VecRestoreArray(y, &ptr); VecDestroy(&y); } @@ -5480,19 +5029,18 @@ namespace PETSc { return Ax; } static U init(U Ax, ProdPETSc< T, U, K, N > A) { - if( A.t->_vector_global ){ + if (A.t->_vector_global) { // case rhs and sol are global in freefem Ax->init(A.u->n); - } - else{ + } else { if (A.t->_A) Ax->init(A.u->n); else { if (A.t->_exchange) { if (N == 'T') - Ax->init(A.t->_exchange[1]->getDof()); + Ax->init(A.t->_exchange[1]->getDof( )); else - Ax->init(A.t->_exchange[0]->getDof()); + Ax->init(A.t->_exchange[0]->getDof( )); } } } @@ -5501,35 +5049,34 @@ namespace PETSc { }; long destroyCSR(Dmat* p) { ffassert(p); - p->dtor(); + p->dtor( ); return 0L; } - KN_ Dmat_D(Dmat* p) { + KN_< double > Dmat_D(Dmat* p) { throwassert(p && p->_A); - KN_ D(reinterpret_cast*>(const_cast(p->_A->getScaling())), p->_A->getDof()); + KN_< double > D(reinterpret_cast< upscaled_type< PetscReal >* >(const_cast< PetscReal* >(p->_A->getScaling( ))), p->_A->getDof( )); return D; } long Dmat_n(Dmat* p) { throwassert(p); PetscInt n = 0; - if(p->_petsc) - MatGetLocalSize(p->_petsc, &n, NULL); - return static_cast(n); + if (p->_petsc) MatGetLocalSize(p->_petsc, &n, NULL); + return static_cast< long >(n); } - KN_ Dmat_range(Stack stack, Dmat* const& p) { + KN_< long > Dmat_range(Stack stack, Dmat* const& p) { throwassert(p); PetscInt m, n; - long* ptr = Add2StackOfPtr2FreeA(stack, new long[2]); - KN_ ret(ptr, 2); - if(p->_petsc) { - MatGetOwnershipRange(p->_petsc, &m, &n); - ptr[0] = m; - ptr[1] = n; + long* ptr = Add2StackOfPtr2FreeA< long >(stack, new long[2]); + KN_< long > ret(ptr, 2); + if (p->_petsc) { + MatGetOwnershipRange(p->_petsc, &m, &n); + ptr[0] = m; + ptr[1] = n; } return ret; } - template>::value>::type* = nullptr> - static void init() { + template< class K, typename std::enable_if< std::is_same< K, upscaled_type< K > >::value >::type* = nullptr > + static void init( ) { #if !defined(PETSC_USE_REAL_SINGLE) if (std::is_same< PetscInt, int >::value) { TheOperators->Add("<-", new PETSc::initCSRfromMatrix< HpSchwarz< PetscScalar > >); @@ -5546,39 +5093,22 @@ namespace PETSc { Global.Add("ChangeNumbering", "(", new PETSc::changeNumbering< Dmat, KNM >( )); Global.Add("ChangeNumbering", "(", new PETSc::changeNumbering< Dmat, KNM >(1, 1)); Global.Add("ChangeNumbering", "(", new PETSc::changeNumbering< Dmat, KNM >(1, 1, 1, 1)); - Global.Add("MatMult", "(", - new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >( - PETSc::MatMult< 'N' >)); - Global.Add("MatMatMult", "(", - new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >( - PETSc::MatMatMult< 'N' >)); - Global.Add("MatMatMult", "(", - new OneOperator3_< long, Dmat*, Dmat*, Dmat* >( - PETSc::MatMatMult< 'N' >)); - Global.Add("MatMultTranspose", "(", - new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >( - PETSc::MatMult< 'T' >)); - Global.Add("MatTransposeMatMult", "(", - new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >( - PETSc::MatMatMult< 'T' >)); + Global.Add("MatMult", "(", new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >(PETSc::MatMult< 'N' >)); + Global.Add("MatMatMult", "(", new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >(PETSc::MatMatMult< 'N' >)); + Global.Add("MatMatMult", "(", new OneOperator3_< long, Dmat*, Dmat*, Dmat* >(PETSc::MatMatMult< 'N' >)); + Global.Add("MatMultTranspose", "(", new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >(PETSc::MatMult< 'T' >)); + Global.Add("MatTransposeMatMult", "(", new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >(PETSc::MatMatMult< 'T' >)); if (!std::is_same< PetscScalar, PetscReal >::value) { - Global.Add("MatMultHermitianTranspose", "(", - new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >( - PETSc::MatMult< 'H' >)); - Global.Add("MatHermitianTransposeMatMult", "(", - new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >( - PETSc::MatMatMult< 'H' >)); + Global.Add("MatMultHermitianTranspose", "(", new OneOperator3_< long, Dmat*, KN< PetscScalar >*, KN< PetscScalar >* >(PETSc::MatMult< 'H' >)); + Global.Add("MatHermitianTransposeMatMult", "(", new OneOperator3_< long, Dmat*, KNM< PetscScalar >*, KNM< PetscScalar >* >(PETSc::MatMatMult< 'H' >)); } - Global.Add("MatPtAP", "(", - new OneOperator3_< long, Dmat*, Dmat*, Dmat* >(PETSc::MatPtAP)); + Global.Add("MatPtAP", "(", new OneOperator3_< long, Dmat*, Dmat*, Dmat* >(PETSc::MatPtAP)); Global.Add("MatConvert", "(", new PETSc::convert< Dmat >); - Global.Add("MatZeroRows", "(", - new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::MatZeroRows)); + Global.Add("MatZeroRows", "(", new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::MatZeroRows)); Global.Add("KSPSolve", "(", new PETSc::LinearSolver< Dmat >( )); Global.Add("KSPSolve", "(", new PETSc::LinearSolver< Dmat >(1)); Global.Add("KSPSolve", "(", new PETSc::LinearSolver< Dmat >(1, 1)); - if (!std::is_same< PetscScalar, PetscReal >::value) - Global.Add("KSPSolveHermitianTranspose", "(", new PETSc::LinearSolver< Dmat >(1, 1, 1)); + if (!std::is_same< PetscScalar, PetscReal >::value) Global.Add("KSPSolveHermitianTranspose", "(", new PETSc::LinearSolver< Dmat >(1, 1, 1)); Global.Add("KSPSolve", "(", new PETSc::LinearSolver< Dmat >(1, 1, 1, 1)); Global.Add("KSPSolveTranspose", "(", new PETSc::LinearSolver< Dmat >(1, 1, 1, 1, 1)); Global.Add("KSPSolveTranspose", "(", new PETSc::LinearSolver< Dmat >(1, 1, 1, 1, 1, 1)); @@ -5590,27 +5120,17 @@ namespace PETSc { Global.Add("TSSolve", "(", new PETSc::NonlinearSolver< Dmat >(1, 1)); Global.Add("TSSolve", "(", new PETSc::NonlinearSolver< Dmat >(1, 1, 1)); Global.Add("TaoSolve", "(", new PETSc::NonlinearSolver< Dmat >(4)); - Global.Add("GlobalNumbering", "(", - new OneOperator2_< long, Dmat*, KN< long >* >(PETSc::globalNumbering< Dmat >)); - Global.Add("GlobalNumbering", "(", - new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::globalNumbering< Dmat >)); - Global.Add("GlobalNumbering", "(", - new OneOperator2_< long, Dbddc*, KN< long >* >(PETSc::globalNumbering< Dbddc >)); - Global.Add("ParMmgCommunicators", "(", - new OneOperator4_< long, Dmat*, KN< double >*, KN< long >*, KN< KN< long >>*>(PETSc::ParMmgCommunicators< Dmat >)); - Global.Add("ChangeSchur", "(", - new OneOperator3_< long, Dmat*, KN< Matrice_Creuse< upscaled_type > >*, KN< double >* >( - PETSc::changeSchur)); + Global.Add("GlobalNumbering", "(", new OneOperator2_< long, Dmat*, KN< long >* >(PETSc::globalNumbering< Dmat >)); + Global.Add("GlobalNumbering", "(", new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::globalNumbering< Dmat >)); + Global.Add("GlobalNumbering", "(", new OneOperator2_< long, Dbddc*, KN< long >* >(PETSc::globalNumbering< Dbddc >)); + Global.Add("ParMmgCommunicators", "(", new OneOperator4_< long, Dmat*, KN< double >*, KN< long >*, KN< KN< long > >* >(PETSc::ParMmgCommunicators< Dmat >)); + Global.Add("ChangeSchur", "(", new OneOperator3_< long, Dmat*, KN< Matrice_Creuse< upscaled_type< PetscScalar > > >*, KN< double >* >(PETSc::changeSchur)); Global.Add("ObjectView", "(", new PETSc::view< Dmat, 0 >); - Global.Add("ObjectView", "(", new PETSc::view< KNM, 0 >); + Global.Add("ObjectView", "(", new PETSc::view< KNM< PetscScalar >, 0 >); Global.Add("MatLoad", "(", new PETSc::view< Dmat, 1 >); - Global.Add("MatLoad", "(", new PETSc::view< KNM, 1 >); - Global.Add( - "OriginalNumbering", "(", - new OneOperator3_< long, Dbddc*, KN< PetscScalar >*, KN< long >* >(PETSc::originalNumbering)); - Global.Add("renumber", "(", - new OneOperator3_< long, KN< PetscScalar >*, KN< long >*, KN< PetscScalar >* >( - PETSc::renumber)); + Global.Add("MatLoad", "(", new PETSc::view< KNM< PetscScalar >, 1 >); + Global.Add("OriginalNumbering", "(", new OneOperator3_< long, Dbddc*, KN< PetscScalar >*, KN< long >* >(PETSc::originalNumbering)); + Global.Add("renumber", "(", new OneOperator3_< long, KN< PetscScalar >*, KN< long >*, KN< PetscScalar >* >(PETSc::renumber)); Global.Add("set", "(", new PETSc::setOptions< Dbddc >( )); addInv< Dbddc, PETSc::InvPETSc, KN< PetscScalar >, PetscScalar >( ); #ifdef GENERATE_DEPRECATED_FUNCTIONS @@ -5619,139 +5139,122 @@ namespace PETSc { Global.Add("changeNumbering", "(", new PETSc::changeNumbering< Dmat, KN >(1, 1)); Global.Add("changeNumbering", "(", new PETSc::changeNumbering< Dmat, KN >(1, 1, 1)); Global.Add("changeNumbering", "(", new PETSc::changeNumbering< Dmat, KNM >( )); - Global.Add("globalNumbering", "(", - new OneOperator2_< long, Dmat*, KN< long >* >(PETSc::globalNumbering< Dmat >)); - Global.Add("globalNumbering", "(", - new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::globalNumbering< Dmat >)); - Global.Add("globalNumbering", "(", - new OneOperator2_< long, Dbddc*, KN< long >* >(PETSc::globalNumbering< Dbddc >)); - Global.Add( - "originalNumbering", "(", - new OneOperator3_< long, Dbddc*, KN< PetscScalar >*, KN< long >* >(PETSc::originalNumbering)); + Global.Add("globalNumbering", "(", new OneOperator2_< long, Dmat*, KN< long >* >(PETSc::globalNumbering< Dmat >)); + Global.Add("globalNumbering", "(", new OneOperator2_< long, Dmat*, KN< double >* >(PETSc::globalNumbering< Dmat >)); + Global.Add("globalNumbering", "(", new OneOperator2_< long, Dbddc*, KN< long >* >(PETSc::globalNumbering< Dbddc >)); + Global.Add("originalNumbering", "(", new OneOperator3_< long, Dbddc*, KN< PetscScalar >*, KN< long >* >(PETSc::originalNumbering)); #endif } - template>::value>::type* = nullptr> - static void init() { } + template< class K, typename std::enable_if< !std::is_same< K, upscaled_type< K > >::value >::type* = nullptr > + static void init( ) {} class initDM_Op : public E_F0mps { - public: - Expression A; - Expression B; - static const int n_name_param = 6; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - initDM_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), B(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } + public: + Expression A; + Expression B; + static const int n_name_param = 6; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + initDM_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), B(param2) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; - }; - basicAC_F0::name_and_type initDM_Op::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"overlap", &typeid(long)}, - {"neighbors", &typeid(KN*)}, - {"sparams", &typeid(string*)}, - {"partition", &typeid(KN*)}, - {"prefix", &typeid(string*)} + AnyType operator( )(Stack stack) const; }; + basicAC_F0::name_and_type initDM_Op::name_param[] = {{"communicator", &typeid(pcommworld)}, {"overlap", &typeid(long)}, {"neighbors", &typeid(KN< long >*)}, + {"sparams", &typeid(string*)}, {"partition", &typeid(KN< long >*)}, {"prefix", &typeid(string*)}}; class initDM : public OneOperator { - public: - initDM() : OneOperator(atype(), atype(), atype()) { } + public: + initDM( ) : OneOperator(atype< DMPlex* >( ), atype< DMPlex* >( ), atype< string* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new initDM_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0* code(const basicAC_F0& args) const { return new initDM_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } }; - AnyType initDM_Op::operator()(Stack stack) const { - DMPlex* pA = GetAny((*A)(stack)); - std::string* pB = GetAny((*B)(stack)); - std::string* prefix = nargs[5] ? GetAny< std::string* >((*nargs[5])(stack)) : NULL; - KN* part = nargs[4] ? GetAny< KN* >((*nargs[4])(stack)) : NULL; - KN* neighbors = nargs[2] ? GetAny< KN* >((*nargs[2])(stack)) : NULL; - if(nargs[3]) { - std::string* options = GetAny< std::string* >((*nargs[3])(stack)); - PetscOptionsInsertString(NULL, options->c_str()); + AnyType initDM_Op::operator( )(Stack stack) const { + DMPlex* pA = GetAny< DMPlex* >((*A)(stack)); + std::string* pB = GetAny< std::string* >((*B)(stack)); + std::string* prefix = nargs[5] ? GetAny< std::string* >((*nargs[5])(stack)) : NULL; + KN< long >* part = nargs[4] ? GetAny< KN< long >* >((*nargs[4])(stack)) : NULL; + KN< long >* neighbors = nargs[2] ? GetAny< KN< long >* >((*nargs[2])(stack)) : NULL; + if (nargs[3]) { + std::string* options = GetAny< std::string* >((*nargs[3])(stack)); + PetscOptionsInsertString(NULL, options->c_str( )); + } + PetscInt overlap = nargs[1] ? GetAny< long >((*nargs[1])(stack)) : 0; + MPI_Comm comm = nargs[0] ? *static_cast< MPI_Comm* >(GetAny< pcommworld >((*nargs[0])(stack))) : PETSC_COMM_WORLD; + int size; + MPI_Comm_size(comm, &size); + DMPlexCreateFromFile(comm, pB->c_str( ), NULL, PETSC_TRUE, &pA->_dm); + if (prefix) DMSetOptionsPrefix(pA->_dm, prefix->c_str( )); + DMSetFromOptions(pA->_dm); + PetscPartitioner partitioner; + DMPlexGetPartitioner(pA->_dm, &partitioner); + PetscPartitionerSetFromOptions(partitioner); + DM pdm; + DMPlexDistribute(pA->_dm, 0, NULL, &pdm); + if (pdm) { + if (overlap == 0) { + DM idm; + DMPlexInterpolate(pdm, &idm); + DMDestroy(&pdm); + pdm = idm; } - PetscInt overlap = nargs[1] ? GetAny< long >((*nargs[1])(stack)) : 0; - MPI_Comm comm = nargs[0] ? *static_cast< MPI_Comm* >(GetAny< pcommworld >((*nargs[0])(stack))) : PETSC_COMM_WORLD; - int size; - MPI_Comm_size(comm, &size); - DMPlexCreateFromFile(comm, pB->c_str(), NULL, PETSC_TRUE, &pA->_dm); - if(prefix) - DMSetOptionsPrefix(pA->_dm, prefix->c_str()); - DMSetFromOptions(pA->_dm); - PetscPartitioner partitioner; - DMPlexGetPartitioner(pA->_dm, &partitioner); - PetscPartitionerSetFromOptions(partitioner); - DM pdm; - DMPlexDistribute(pA->_dm, 0, NULL, &pdm); - if (pdm) { - if(overlap == 0) { - DM idm; - DMPlexInterpolate(pdm, &idm); - DMDestroy(&pdm); - pdm = idm; - } - DMLabel label; - DMGetLabel(pdm, "Face Sets", &label); - if (!label) { - DMCreateLabel(pdm, "Face Sets"); - DMGetLabel(pdm, "Face Sets", &label); - } -#if PETSC_VERSION_GE(3,19,0) - PetscSF sf; - DMGetPointSF(pdm, &sf); - DMSetPointSF(pdm, NULL); + DMLabel label; + DMGetLabel(pdm, "Face Sets", &label); + if (!label) { + DMCreateLabel(pdm, "Face Sets"); + DMGetLabel(pdm, "Face Sets", &label); + } +#if PETSC_VERSION_GE(3, 19, 0) + PetscSF sf; + DMGetPointSF(pdm, &sf); + DMSetPointSF(pdm, NULL); #endif - DMPlexMarkBoundaryFaces(pdm, 111111, label); -#if PETSC_VERSION_GE(3,19,0) - DMSetPointSF(pdm, sf); + DMPlexMarkBoundaryFaces(pdm, 111111, label); +#if PETSC_VERSION_GE(3, 19, 0) + DMSetPointSF(pdm, sf); #endif - DMDestroy(&pA->_dm); - pA->_dm = pdm; - if(neighbors) { - PetscInt nranks; - const PetscMPIInt *ranks; - DMGetNeighbors(pA->_dm, &nranks, &ranks); - neighbors->resize(nranks); - std::copy_n(ranks, nranks, neighbors->operator long*()); - } - } else if(neighbors) neighbors->resize(0); - if(part) { - PetscSection rootSection, leafSection; - PetscSectionCreate(comm, &rootSection); - PetscSectionCreate(comm, &leafSection); - { - PetscInt pStart, pEnd, cStart, cEnd; - DMPlexGetChart(pA->_dm, &pStart, &pEnd); - DMPlexGetHeightStratum(pA->_dm, 0, &cStart, &cEnd); - PetscSectionSetChart(rootSection, pStart, pEnd); - for(PetscInt c = cStart; c < cEnd; ++c) - PetscSectionSetDof(rootSection, c, 1); - PetscSectionSetUp(rootSection); - PetscSectionCopy(rootSection, leafSection); - DMSetLocalSection(pA->_dm, rootSection); - DMSetLocalSection(pA->_dm, leafSection); - } - Vec ranks, local; - DMPlexCreateRankField(pA->_dm, &ranks); - DMCreateLocalVector(pA->_dm, &local); - DMGlobalToLocal(pA->_dm, ranks, INSERT_VALUES, local); - const PetscScalar* val; - VecGetArrayRead(local, &val); - PetscInt n; - VecGetLocalSize(local, &n); - part->resize(n); - for(PetscInt i = 0; i < n; ++i) - part->operator[](i) = PetscRealPart(val[i]); - VecRestoreArrayRead(local, &val); - VecDestroy(&ranks); - VecDestroy(&local); - PetscSectionDestroy(&rootSection); - PetscSectionDestroy(&leafSection); + DMDestroy(&pA->_dm); + pA->_dm = pdm; + if (neighbors) { + PetscInt nranks; + const PetscMPIInt* ranks; + DMGetNeighbors(pA->_dm, &nranks, &ranks); + neighbors->resize(nranks); + std::copy_n(ranks, nranks, neighbors->operator long*( )); } - return pA; + } else if (neighbors) + neighbors->resize(0); + if (part) { + PetscSection rootSection, leafSection; + PetscSectionCreate(comm, &rootSection); + PetscSectionCreate(comm, &leafSection); + { + PetscInt pStart, pEnd, cStart, cEnd; + DMPlexGetChart(pA->_dm, &pStart, &pEnd); + DMPlexGetHeightStratum(pA->_dm, 0, &cStart, &cEnd); + PetscSectionSetChart(rootSection, pStart, pEnd); + for (PetscInt c = cStart; c < cEnd; ++c) PetscSectionSetDof(rootSection, c, 1); + PetscSectionSetUp(rootSection); + PetscSectionCopy(rootSection, leafSection); + DMSetLocalSection(pA->_dm, rootSection); + DMSetLocalSection(pA->_dm, leafSection); + } + Vec ranks, local; + DMPlexCreateRankField(pA->_dm, &ranks); + DMCreateLocalVector(pA->_dm, &local); + DMGlobalToLocal(pA->_dm, ranks, INSERT_VALUES, local); + const PetscScalar* val; + VecGetArrayRead(local, &val); + PetscInt n; + VecGetLocalSize(local, &n); + part->resize(n); + for (PetscInt i = 0; i < n; ++i) part->operator[](i) = PetscRealPart(val[i]); + VecRestoreArrayRead(local, &val); + VecDestroy(&ranks); + VecDestroy(&local); + PetscSectionDestroy(&rootSection); + PetscSectionDestroy(&leafSection); + } + return pA; } - static void findPerm(int *ivt, int *pivt, Vertex3 *v) { + static void findPerm(int* ivt, int* pivt, Vertex3* v) { std::copy(ivt, ivt + 4, pivt); R3 AB(v[ivt[0]], v[ivt[1]]); R3 AC(v[ivt[0]], v[ivt[2]]); @@ -5764,13 +5267,12 @@ namespace PETSc { std::swap(pivt[1], pivt[2]); } } - static void findPerm(int *ivt, int *pivt, Vertex *v) { + static void findPerm(int* ivt, int* pivt, Vertex* v) { std::copy(ivt, ivt + 3, pivt); R2 A(v[ivt[0]]); R2 B(v[ivt[1]]); R2 C(v[ivt[2]]); - if (((B-A)^(C-A)) < 0) - std::swap(pivt[1], pivt[2]); + if (((B - A) ^ (C - A)) < 0) std::swap(pivt[1], pivt[2]); } class DMPlexToFF : public OneOperator { public: @@ -5781,286 +5283,278 @@ namespace PETSc { Expression B; const int c; DMPlexToFF_Op(const basicAC_F0& args, int d) : A(0), B(0), c(d) { - B = to(args[1]); - if(c == 0) - A = to< Mesh const** >(args[0]); + B = to< DMPlex* >(args[1]); + if (c == 0) + A = to< Mesh const** >(args[0]); else - A = to< Mesh3 const** >(args[0]); + A = to< Mesh3 const** >(args[0]); } AnyType operator( )(Stack stack) const; - operator aType( ) const { return c == 0 ? atype< Mesh const** >( ) : atype < Mesh3 const** >( ); } + operator aType( ) const { return c == 0 ? atype< Mesh const** >( ) : atype< Mesh3 const** >( ); } }; E_F0* code(const basicAC_F0& args) const { return new DMPlexToFF_Op(args, c); } - DMPlexToFF( ) - : OneOperator(atype< Mesh const** >( ), atype< Mesh const** >( ), atype< DMPlex* >( )), c(0) {} - DMPlexToFF(int) - : OneOperator(atype< Mesh3 const** >( ), atype< Mesh3 const** >( ), atype< DMPlex* >( )), c(1) {} + DMPlexToFF( ) : OneOperator(atype< Mesh const** >( ), atype< Mesh const** >( ), atype< DMPlex* >( )), c(0) {} + DMPlexToFF(int) : OneOperator(atype< Mesh3 const** >( ), atype< Mesh3 const** >( ), atype< DMPlex* >( )), c(1) {} }; AnyType DMPlexToFF::DMPlexToFF_Op::operator( )(Stack stack) const { - DMPlex* p = GetAny((*B)(stack)); - PetscSection coordSection; - Vec coordinates; - DMLabel label; - const PetscScalar *a; - PetscInt dim, pStart, pEnd, cStart, cEnd, vStart, vEnd, depth, numValues; - IS valueIS; - const PetscInt *values; - DMGetDimension(p->_dm, &dim); - DMGetCoordinatesLocal(p->_dm, &coordinates); - DMGetCoordinateSection(p->_dm, &coordSection); - DMPlexGetDepth(p->_dm, &depth); - DMPlexGetHeightStratum(p->_dm, depth, &vStart, &vEnd); - DMPlexGetHeightStratum(p->_dm, 0, &cStart, &cEnd); - PetscSectionGetChart(coordSection, &pStart, &pEnd); - VecGetArrayRead(coordinates, &a); - if(c == 1) { - Mesh3** pA = GetAny((*A)(stack)); - (*pA)->destroy(); - if(!p->_dm) return pA; - ffassert(dim == 3); - Vertex3 *v = new Vertex3[vEnd - vStart]; - Tet *t = new Tet[cEnd - cStart]; - Tet *tt = t; - for (PetscInt i = 0; i < vEnd - vStart; ++i) { - v[i].x = PetscRealPart(a[3 * i + 0]); - v[i].y = PetscRealPart(a[3 * i + 1]); - v[i].z = PetscRealPart(a[3 * i + 2]); - v[i].lab = 0; - } - VecRestoreArrayRead(coordinates, &a); - DMGetLabel(p->_dm, "Face Sets", &label); - DMLabelGetNumValues(label, &numValues); - DMLabelGetValueIS(label, &valueIS); - ISGetIndices(valueIS, &values); - PetscInt interface = -1; - std::unordered_set set; - for (PetscInt v = 0; v < numValues; ++v) { - if (values[v] == 111111) { - interface = v; - continue; - } - IS face; - PetscInt size; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[v], &face); - ISGetLocalSize(face, &size); - ISGetIndices(face, &indices); - for(PetscInt i = 0; i < size;++i) - set.insert(indices[i]); - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - PetscInt size = set.size(); - if (interface != -1) { - IS face; - PetscInt iss; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[interface], &face); - ISGetLocalSize(face, &iss); - ISGetIndices(face, &indices); - for(PetscInt i = 0; i < iss;++i) { - if (set.find(indices[i]) == set.end()) - ++size; - } - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - Triangle3 *b = new Triangle3[size]; - Triangle3 *bb = b; - for (PetscInt j = 0; j < numValues; ++j) { - IS face; - PetscInt size; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[j], &face); - ISGetLocalSize(face, &size); - ISGetIndices(face, &indices); - for (PetscInt c = 0; c < size; ++c) { - if (set.find(indices[c]) != set.end() && j == interface) continue; - const PetscInt *points, *orientations; - PetscInt size, i; - - DMPlexGetConeSize(p->_dm, indices[c], &size); - DMPlexGetCone(p->_dm, indices[c], &points); - std::set set; - for (PetscInt j = 0; j < size; ++j) { - const PetscInt *vertex; - PetscInt size, i; - - DMPlexGetConeSize(p->_dm, points[j], &size); - DMPlexGetCone(p->_dm, points[j], &vertex); - for (PetscInt w = 0; w < size; ++w) - set.insert(vertex[w]); - } - std::vector conv(set.begin(), set.end()); - ffassert(conv.size() == 3); - int iv[3]; - for (PetscInt j = 0; j < conv.size(); ++j) - iv[j] = conv[j] - vStart; - int lab = values[j] == 111111 ? -111111 : values[j]; - bb++->set(v, iv, lab); - } - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - ISRestoreIndices(valueIS, &values); - ISDestroy(&valueIS); - for (PetscInt c = cStart; c < cEnd; ++c) { - PetscInt *closure = NULL; - PetscInt closureSize, cl; - DMPlexGetTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); - int iv[4]; - PetscInt lab; - DMGetLabel(p->_dm, "Cell Sets", &label); - if (label) DMGetLabelValue(p->_dm, "Cell Sets", c, &lab); - else { - DMGetLabel(p->_dm, "celltype", &label); - if (label) DMGetLabelValue(p->_dm, "celltype", c, &lab); - } - if (lab == -1) lab = 0; - int* ivv = iv; - for (cl = 0; cl < 2 * closureSize; cl += 2) { - PetscInt point = closure[cl], dof, off, d, p; - - if ((point < pStart) || (point >= pEnd)) continue; - PetscSectionGetDof(coordSection, point, &dof); - if (!dof) continue; - PetscSectionGetOffset(coordSection, point, &off); - *ivv++ = point - cEnd; - } - ffassert(ivv - iv == 4); - int pivt[4]; - findPerm(iv, pivt, v); - tt++->set(v, pivt, lab); - DMPlexRestoreTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); + DMPlex* p = GetAny< DMPlex* >((*B)(stack)); + PetscSection coordSection; + Vec coordinates; + DMLabel label; + const PetscScalar* a; + PetscInt dim, pStart, pEnd, cStart, cEnd, vStart, vEnd, depth, numValues; + IS valueIS; + const PetscInt* values; + DMGetDimension(p->_dm, &dim); + DMGetCoordinatesLocal(p->_dm, &coordinates); + DMGetCoordinateSection(p->_dm, &coordSection); + DMPlexGetDepth(p->_dm, &depth); + DMPlexGetHeightStratum(p->_dm, depth, &vStart, &vEnd); + DMPlexGetHeightStratum(p->_dm, 0, &cStart, &cEnd); + PetscSectionGetChart(coordSection, &pStart, &pEnd); + VecGetArrayRead(coordinates, &a); + if (c == 1) { + Mesh3** pA = GetAny< Mesh3** >((*A)(stack)); + (*pA)->destroy( ); + if (!p->_dm) return pA; + ffassert(dim == 3); + Vertex3* v = new Vertex3[vEnd - vStart]; + Tet* t = new Tet[cEnd - cStart]; + Tet* tt = t; + for (PetscInt i = 0; i < vEnd - vStart; ++i) { + v[i].x = PetscRealPart(a[3 * i + 0]); + v[i].y = PetscRealPart(a[3 * i + 1]); + v[i].z = PetscRealPart(a[3 * i + 2]); + v[i].lab = 0; + } + VecRestoreArrayRead(coordinates, &a); + DMGetLabel(p->_dm, "Face Sets", &label); + DMLabelGetNumValues(label, &numValues); + DMLabelGetValueIS(label, &valueIS); + ISGetIndices(valueIS, &values); + PetscInt interface = -1; + std::unordered_set< PetscInt > set; + for (PetscInt v = 0; v < numValues; ++v) { + if (values[v] == 111111) { + interface = v; + continue; + } + IS face; + PetscInt size; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[v], &face); + ISGetLocalSize(face, &size); + ISGetIndices(face, &indices); + for (PetscInt i = 0; i < size; ++i) set.insert(indices[i]); + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + PetscInt size = set.size( ); + if (interface != -1) { + IS face; + PetscInt iss; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[interface], &face); + ISGetLocalSize(face, &iss); + ISGetIndices(face, &indices); + for (PetscInt i = 0; i < iss; ++i) { + if (set.find(indices[i]) == set.end( )) ++size; + } + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + Triangle3* b = new Triangle3[size]; + Triangle3* bb = b; + for (PetscInt j = 0; j < numValues; ++j) { + IS face; + PetscInt size; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[j], &face); + ISGetLocalSize(face, &size); + ISGetIndices(face, &indices); + for (PetscInt c = 0; c < size; ++c) { + if (set.find(indices[c]) != set.end( ) && j == interface) continue; + const PetscInt *points, *orientations; + PetscInt size, i; + + DMPlexGetConeSize(p->_dm, indices[c], &size); + DMPlexGetCone(p->_dm, indices[c], &points); + std::set< PetscInt > set; + for (PetscInt j = 0; j < size; ++j) { + const PetscInt* vertex; + PetscInt size, i; + + DMPlexGetConeSize(p->_dm, points[j], &size); + DMPlexGetCone(p->_dm, points[j], &vertex); + for (PetscInt w = 0; w < size; ++w) set.insert(vertex[w]); } - *pA = new Mesh3(vEnd - vStart, cEnd - cStart, size, v, t, b); - (*pA)->BuildGTree(); - return pA; + std::vector< PetscInt > conv(set.begin( ), set.end( )); + ffassert(conv.size( ) == 3); + int iv[3]; + for (PetscInt j = 0; j < conv.size( ); ++j) iv[j] = conv[j] - vStart; + int lab = values[j] == 111111 ? -111111 : values[j]; + bb++->set(v, iv, lab); + } + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + ISRestoreIndices(valueIS, &values); + ISDestroy(&valueIS); + for (PetscInt c = cStart; c < cEnd; ++c) { + PetscInt* closure = NULL; + PetscInt closureSize, cl; + DMPlexGetTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); + int iv[4]; + PetscInt lab; + DMGetLabel(p->_dm, "Cell Sets", &label); + if (label) + DMGetLabelValue(p->_dm, "Cell Sets", c, &lab); + else { + DMGetLabel(p->_dm, "celltype", &label); + if (label) DMGetLabelValue(p->_dm, "celltype", c, &lab); + } + if (lab == -1) lab = 0; + int* ivv = iv; + for (cl = 0; cl < 2 * closureSize; cl += 2) { + PetscInt point = closure[cl], dof, off, d, p; + + if ((point < pStart) || (point >= pEnd)) continue; + PetscSectionGetDof(coordSection, point, &dof); + if (!dof) continue; + PetscSectionGetOffset(coordSection, point, &off); + *ivv++ = point - cEnd; + } + ffassert(ivv - iv == 4); + int pivt[4]; + findPerm(iv, pivt, v); + tt++->set(v, pivt, lab); + DMPlexRestoreTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); } + *pA = new Mesh3(vEnd - vStart, cEnd - cStart, size, v, t, b); + (*pA)->BuildGTree( ); + return pA; + } else { + Mesh const** pA = GetAny< Mesh const** >((*A)(stack)); + (*pA)->destroy( ); + if (!p->_dm) return pA; + ffassert(dim == 2); + Vertex* v = new Vertex[vEnd - vStart]; + Triangle* t = new Triangle[cEnd - cStart]; + Triangle* tt = t; + for (PetscInt i = 0; i < vEnd - vStart; ++i) { + v[i].x = PetscRealPart(a[2 * i + 0]); + v[i].y = PetscRealPart(a[2 * i + 1]); + v[i].lab = 0; + } + VecRestoreArrayRead(coordinates, &a); + DMGetLabel(p->_dm, "Face Sets", &label); + DMLabelGetNumValues(label, &numValues); + DMLabelGetValueIS(label, &valueIS); + ISGetIndices(valueIS, &values); + PetscInt interface = -1; + std::unordered_set< PetscInt > set; + for (PetscInt v = 0; v < numValues; ++v) { + if (values[v] == 111111) { + interface = v; + continue; + } + IS face; + PetscInt size; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[v], &face); + ISGetLocalSize(face, &size); + ISGetIndices(face, &indices); + for (PetscInt i = 0; i < size; ++i) set.insert(indices[i]); + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + PetscInt size = set.size( ); + if (interface != -1) { + IS face; + PetscInt iss; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[interface], &face); + ISGetLocalSize(face, &iss); + ISGetIndices(face, &indices); + for (PetscInt i = 0; i < iss; ++i) { + if (set.find(indices[i]) == set.end( )) ++size; + } + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + BoundaryEdge* b = new BoundaryEdge[size]; + BoundaryEdge* bb = b; + for (PetscInt j = 0; j < numValues; ++j) { + IS face; + PetscInt size; + const PetscInt* indices; + + DMLabelGetStratumIS(label, values[j], &face); + ISGetLocalSize(face, &size); + ISGetIndices(face, &indices); + for (PetscInt c = 0; c < size; ++c) { + if (set.find(indices[c]) != set.end( ) && j == interface) continue; + const PetscInt *points, *orientations; + PetscInt size, i; + + DMPlexGetConeSize(p->_dm, indices[c], &size); + DMPlexGetCone(p->_dm, indices[c], &points); + ffassert(size == 2); + int iv[2]; + for (PetscInt j = 0; j < size; ++j) iv[j] = points[j] - vStart; + int lab = values[j] == 111111 ? -111111 : values[j]; + *bb++ = BoundaryEdge(v, iv[0], iv[1], lab); + } + ISRestoreIndices(face, &indices); + ISDestroy(&face); + } + ISRestoreIndices(valueIS, &values); + ISDestroy(&valueIS); + DMGetLabel(p->_dm, "Cell Sets", &label); + if (label) + DMLabelSetDefaultValue(label, 0); else { - Mesh const** pA = GetAny((*A)(stack)); - (*pA)->destroy(); - if(!p->_dm) return pA; - ffassert(dim == 2); - Vertex *v = new Vertex[vEnd - vStart]; - Triangle *t = new Triangle[cEnd - cStart]; - Triangle *tt = t; - for (PetscInt i = 0; i < vEnd - vStart; ++i) { - v[i].x = PetscRealPart(a[2 * i + 0]); - v[i].y = PetscRealPart(a[2 * i + 1]); - v[i].lab = 0; - } - VecRestoreArrayRead(coordinates, &a); - DMGetLabel(p->_dm, "Face Sets", &label); - DMLabelGetNumValues(label, &numValues); - DMLabelGetValueIS(label, &valueIS); - ISGetIndices(valueIS, &values); - PetscInt interface = -1; - std::unordered_set set; - for (PetscInt v = 0; v < numValues; ++v) { - if (values[v] == 111111) { - interface = v; - continue; - } - IS face; - PetscInt size; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[v], &face); - ISGetLocalSize(face, &size); - ISGetIndices(face, &indices); - for(PetscInt i = 0; i < size;++i) - set.insert(indices[i]); - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - PetscInt size = set.size(); - if (interface != -1) { - IS face; - PetscInt iss; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[interface], &face); - ISGetLocalSize(face, &iss); - ISGetIndices(face, &indices); - for(PetscInt i = 0; i < iss;++i) { - if (set.find(indices[i]) == set.end()) - ++size; - } - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - BoundaryEdge *b = new BoundaryEdge[size]; - BoundaryEdge *bb = b; - for (PetscInt j = 0; j < numValues; ++j) { - IS face; - PetscInt size; - const PetscInt* indices; - - DMLabelGetStratumIS(label, values[j], &face); - ISGetLocalSize(face, &size); - ISGetIndices(face, &indices); - for (PetscInt c = 0; c < size; ++c) { - if (set.find(indices[c]) != set.end() && j == interface) continue; - const PetscInt *points, *orientations; - PetscInt size, i; - - DMPlexGetConeSize(p->_dm, indices[c], &size); - DMPlexGetCone(p->_dm, indices[c], &points); - ffassert(size == 2); - int iv[2]; - for (PetscInt j = 0; j < size; ++j) - iv[j] = points[j] - vStart; - int lab = values[j] == 111111 ? -111111 : values[j]; - *bb++ = BoundaryEdge(v, iv[0], iv[1], lab); - } - ISRestoreIndices(face, &indices); - ISDestroy(&face); - } - ISRestoreIndices(valueIS, &values); - ISDestroy(&valueIS); - DMGetLabel(p->_dm, "Cell Sets", &label); - if (label) DMLabelSetDefaultValue(label, 0); - else { - DMGetLabel(p->_dm, "celltype", &label); - if (label) DMLabelSetDefaultValue(label, 0); - } - for (PetscInt c = cStart; c < cEnd; ++c) { - PetscInt *closure = NULL; - PetscInt closureSize, cl; - DMPlexGetTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); - int iv[3], lab = 0; - if (label) { - DMLabelGetValue(label, c, &cl); - lab = cl; - } - int* ivv = iv; - for (cl = 0; cl < 2 * closureSize; cl += 2) { - PetscInt point = closure[cl], dof, off, d, p; - - if ((point < pStart) || (point >= pEnd)) continue; - PetscSectionGetDof(coordSection, point, &dof); - if (!dof) continue; - PetscSectionGetOffset(coordSection, point, &off); - *ivv++ = point - cEnd; - } - ffassert(ivv - iv == 3); - int pivt[3]; - findPerm(iv, pivt, v); - tt++->set(v, pivt[0], pivt[1], pivt[2], lab); - DMPlexRestoreTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); - } - Mesh* m = new Mesh(vEnd - vStart, cEnd - cStart, size, v, t, b); - R2 Pn, Px; - m->BoundingBox(Pn, Px); - m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); - *pA = m; - return pA; + DMGetLabel(p->_dm, "celltype", &label); + if (label) DMLabelSetDefaultValue(label, 0); } + for (PetscInt c = cStart; c < cEnd; ++c) { + PetscInt* closure = NULL; + PetscInt closureSize, cl; + DMPlexGetTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); + int iv[3], lab = 0; + if (label) { + DMLabelGetValue(label, c, &cl); + lab = cl; + } + int* ivv = iv; + for (cl = 0; cl < 2 * closureSize; cl += 2) { + PetscInt point = closure[cl], dof, off, d, p; + + if ((point < pStart) || (point >= pEnd)) continue; + PetscSectionGetDof(coordSection, point, &dof); + if (!dof) continue; + PetscSectionGetOffset(coordSection, point, &off); + *ivv++ = point - cEnd; + } + ffassert(ivv - iv == 3); + int pivt[3]; + findPerm(iv, pivt, v); + tt++->set(v, pivt[0], pivt[1], pivt[2], lab); + DMPlexRestoreTransitiveClosure(p->_dm, c, PETSC_TRUE, &closureSize, &closure); + } + Mesh* m = new Mesh(vEnd - vStart, cEnd - cStart, size, v, t, b); + R2 Pn, Px; + m->BoundingBox(Pn, Px); + m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); + *pA = m; + return pA; + } } class buildSolution : public OneOperator { public: @@ -6069,163 +5563,155 @@ namespace PETSc { Expression A; Expression B; buildSolution_Op(const basicAC_F0& args) : A(0), B(0) { - A = to(args[0]); - B = to>*>(args[1]); + A = to< Dmat* >(args[0]); + B = to< KN< upscaled_type< PetscScalar > >* >(args[1]); } AnyType operator( )(Stack stack) const; operator aType( ) const { return atype< long >( ); } }; E_F0* code(const basicAC_F0& args) const { return new buildSolution_Op(args); } - buildSolution( ) - : OneOperator(atype( ), atype( ), atype>*>( )) {} + buildSolution( ) : OneOperator(atype< long >( ), atype< Dmat* >( ), atype< KN< upscaled_type< PetscScalar > >* >( )) {} }; AnyType buildSolution::buildSolution_Op::operator( )(Stack stack) const { - Dmat* ptA = GetAny((*A)(stack)); - KN>* ptKN = GetAny>*>((*B)(stack)); - ffassert(ptA->_ksp); - Mat A; - KSPGetOperators(ptA->_ksp, &A, NULL); - PetscInt n, N; - MatGetLocalSize(A, &n, NULL); - MatGetSize(A, &N, NULL); - ptKN->resize(n); - Vec v; - PetscScalar* p = reinterpret_cast(ptKN->operator upscaled_type*()); - VecCreateMPIWithArray(PetscObjectComm((PetscObject)A), 1, n, N, p, &v); - KSPBuildSolution(ptA->_ksp, v, NULL); - if(!std::is_same, PetscReal>::value) { - for(int i = n - 1; i >= 0; --i) - ptKN->operator[](i) = p[i]; - } - VecDestroy(&v); - return 0L; + Dmat* ptA = GetAny< Dmat* >((*A)(stack)); + KN< upscaled_type< PetscScalar > >* ptKN = GetAny< KN< upscaled_type< PetscScalar > >* >((*B)(stack)); + ffassert(ptA->_ksp); + Mat A; + KSPGetOperators(ptA->_ksp, &A, NULL); + PetscInt n, N; + MatGetLocalSize(A, &n, NULL); + MatGetSize(A, &N, NULL); + ptKN->resize(n); + Vec v; + PetscScalar* p = reinterpret_cast< PetscScalar* >(ptKN->operator upscaled_type< PetscScalar >*( )); + VecCreateMPIWithArray(PetscObjectComm((PetscObject)A), 1, n, N, p, &v); + KSPBuildSolution(ptA->_ksp, v, NULL); + if (!std::is_same< upscaled_type< PetscReal >, PetscReal >::value) { + for (int i = n - 1; i >= 0; --i) ptKN->operator[](i) = p[i]; + } + VecDestroy(&v); + return 0L; } template< class R, class FESpaceT1, class FESpaceT2 > - Matrice_Creuse * PETSC_buildMatrixInterpolationForCompositeFESpace(const FESpaceT1 * Uh ,const FESpaceT2 * Vh, bool transpose=false){ + Matrice_Creuse< R >* PETSC_buildMatrixInterpolationForCompositeFESpace(const FESpaceT1* Uh, const FESpaceT2* Vh, bool transpose = false) { ffassert(Uh); ffassert(Vh); int NUh = Uh->N; int NVh = Vh->N; - if(verbosity>3) cout << "NUh=" << NUh << ", NVh=" << NVh << endl; - Matrice_Creuse * sparse_mat= new Matrice_Creuse(); + if (verbosity > 3) cout << "NUh=" << NUh << ", NVh=" << NVh << endl; + Matrice_Creuse< R >* sparse_mat = new Matrice_Creuse< R >( ); // Remarque pas de U2Vc pour l'instant int* data = new int[4 + NUh]; // default value for the interpolation matrix - data[0]=transpose; // transpose not - data[1]=(long) op_id; // get just value - data[2]=false; // get just value - data[3]=0L; // get just value + data[0] = transpose; // transpose not + data[1] = (long)op_id; // get just value + data[2] = false; // get just value + data[3] = 0L; // get just value - for(int i=0;i3){ - for(int i=0;i " << data[4+i] << " Componante of Vh " < 3) { + for (int i = 0; i < NUh; ++i) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " Componante of Vh " << endl; } } - for(int i=0;i=NVh) - { - cout << "The Uh componante " << i << " -> " << data[4+i] << " >= " << NVh << " number of Vh Componante " <= NVh) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " >= " << NVh << " number of Vh Componante " << endl; ExecError("Interpolation incompability between componante "); } } - const FESpaceT1 &rUh = *Uh; - const FESpaceT2 &rVh = *Vh; + const FESpaceT1& rUh = *Uh; + const FESpaceT2& rVh = *Vh; - MatriceMorse* titi=buildInterpolationMatrixT(rUh,rVh,data); + MatriceMorse< R >* titi = buildInterpolationMatrixT< FESpaceT1, FESpaceT2 >(rUh, rVh, data); - sparse_mat->init(); - sparse_mat->typemat=0;//(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master( titi ); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); - if(verbosity>3){ + sparse_mat->init( ); + sparse_mat->typemat = 0; //(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(titi); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); + if (verbosity > 3) { cout << "sparse_mat->typemat=" << sparse_mat->typemat << endl; cout << "N=" << sparse_mat->A->n << endl; cout << "M=" << sparse_mat->A->m << endl; } - delete [] data; + delete[] data; return sparse_mat; } - template // to make A=linearform(x) - struct OpMatrixtoBilinearFormVGPETSc - : public OneOperator - { - typedef typename Call_CompositeFormBilinear::const_iterator const_iterator; + template< class HpddmType > // to make A=linearform(x) + struct OpMatrixtoBilinearFormVGPETSc : public OneOperator { + typedef typename Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >::const_iterator const_iterator; int init; class Op : public E_F0mps { - public: - Call_CompositeFormBilinear *b; - Expression a; - int init; - //AnyType operator()(Stack s) const; - Op(Expression aa,Expression bb,int initt) - : b(new Call_CompositeFormBilinear(* dynamic_cast *>(bb))),a(aa),init(initt) - { + public: + Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >* b; + Expression a; + int init; + // AnyType operator()(Stack s) const; + Op(Expression aa, Expression bb, int initt) + : b(new Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >(*dynamic_cast< const Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >* >(bb))), a(aa), + init(initt) { ffassert(b && b->nargs); - int NN = (int) b->euh->componentNbitem().size(); - int MM = (int) b->evh->componentNbitem().size(); + int NN = (int)b->euh->componentNbitem( ).size( ); + int MM = (int)b->evh->componentNbitem( ).size( ); - bool total_iscmplx=false; + bool total_iscmplx = false; // loop over block - for(int i=0; iblock_largs(i,j),IsComplexType::value) ; + bool iscmplx = FieldOfForm(b->block_largs(i, j), IsComplexType< PetscScalar >::value); // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; - ffassert( (iscmplx) == IsComplexType::value); - if( !total_iscmplx ) total_iscmplx=iscmplx; + ffassert((iscmplx) == IsComplexType< PetscScalar >::value); + if (!total_iscmplx) total_iscmplx = iscmplx; } } } - operator aType () const { return atype*>();} + operator aType( ) const { return atype< PETSc::DistributedCSR< HpddmType >* >( ); } - AnyType operator()(Stack s) const; + AnyType operator( )(Stack s) const; }; - E_F0 * code(const basicAC_F0 & args) const - { return new Op(to*>(args[0]),args[1],init); } - OpMatrixtoBilinearFormVGPETSc(int initt=0) : - OneOperator(atype*>(),atype*>(),atype*>()), - init(initt){}; - + E_F0* code(const basicAC_F0& args) const { return new Op(to< PETSc::DistributedCSR< HpddmType >* >(args[0]), args[1], init); } + OpMatrixtoBilinearFormVGPETSc(int initt = 0) + : OneOperator(atype< PETSc::DistributedCSR< HpddmType >* >( ), atype< PETSc::DistributedCSR< HpddmType >* >( ), + atype< const Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >* >( )), + init(initt) {}; }; // function to transform freefem matrix in matIS. - void ff_createMatIS( MatriceMorse &ff_mat, Mat &matIS, MPI_Comm comm){ - ff_mat.CSR(); // transform the matrix to CSR format - - std::vector indices_row(ff_mat.n), perm_row(ff_mat.n,-1); - std::vector indices_col(ff_mat.m), perm_col(ff_mat.m,-1); - - for (int ii=0; ii < ff_mat.n; ii++) { - for (int la = ff_mat.p[ii]; la < ff_mat.p[ii+1]; la++) { - perm_row[ii] = 1; - perm_col[ff_mat.j[la]] = 1; - if( la > ff_mat.p[ii]){ - // - if( !( ff_mat.j[la] > ff_mat.j[ff_mat.p[ii]]) ){ - cerr << " The column index must be croissant :: Error " << ff_mat.j[la] << " " << ff_mat.j[ff_mat.p[ii]] < ff_mat.j[ff_mat.p[ii]] ); + void ff_createMatIS(MatriceMorse< PetscScalar >& ff_mat, Mat& matIS, MPI_Comm comm) { + ff_mat.CSR( ); // transform the matrix to CSR format + + std::vector< PetscInt > indices_row(ff_mat.n), perm_row(ff_mat.n, -1); + std::vector< PetscInt > indices_col(ff_mat.m), perm_col(ff_mat.m, -1); + + for (int ii = 0; ii < ff_mat.n; ii++) { + for (int la = ff_mat.p[ii]; la < ff_mat.p[ii + 1]; la++) { + perm_row[ii] = 1; + perm_col[ff_mat.j[la]] = 1; + if (la > ff_mat.p[ii]) { + // + if (!(ff_mat.j[la] > ff_mat.j[ff_mat.p[ii]])) { + cerr << " The column index must be croissant :: Error " << ff_mat.j[la] << " " << ff_mat.j[ff_mat.p[ii]] << endl; } + ffassert(ff_mat.j[la] > ff_mat.j[ff_mat.p[ii]]); } } + } - if(verbosity> 2) - for(int ii=0; ii<10; ii++) - cout << "perm_row["< 2) + for (int ii = 0; ii < 10; ii++) cout << "perm_row[" << ii << "]=" << perm_row[ii] << endl; // construction of indices_row int cpt = 0; - for (int ii=0; ii < ff_mat.n; ii++) + for (int ii = 0; ii < ff_mat.n; ii++) if (perm_row[ii] == 1) { perm_row[ii] = cpt; indices_row[cpt++] = ii; @@ -6234,41 +5720,41 @@ namespace PETSc { // construction of indices_col cpt = 0; - for (int ii=0; ii < ff_mat.m; ii++) + for (int ii = 0; ii < ff_mat.m; ii++) if (perm_col[ii] == 1) { perm_col[ii] = cpt; indices_col[cpt++] = ii; } indices_col.resize(cpt); - PetscInt *IA = new PetscInt[indices_row.size()+1]; - PetscInt *JA = new PetscInt[ff_mat.nnz]; + PetscInt* IA = new PetscInt[indices_row.size( ) + 1]; + PetscInt* JA = new PetscInt[ff_mat.nnz]; PetscScalar* aa = new PetscScalar[ff_mat.nnz]; cpt = 0; IA[0] = 0; - for (int ii=0; ii < ff_mat.n; ii++) - if (ff_mat.p[ii] != ff_mat.p[ii+1]){ + for (int ii = 0; ii < ff_mat.n; ii++) + if (ff_mat.p[ii] != ff_mat.p[ii + 1]) { IA[cpt] = ff_mat.p[ii]; - ffassert( perm_row[ii] == cpt); + ffassert(perm_row[ii] == cpt); cpt++; } - IA[ cpt ] = ff_mat.nnz; - ffassert( IA[cpt] == ff_mat.nnz); - ffassert(cpt==indices_row.size()); + IA[cpt] = ff_mat.nnz; + ffassert(IA[cpt] == ff_mat.nnz); + ffassert(cpt == indices_row.size( )); - for (int ii=0; ii < ff_mat.nnz; ii++) { + for (int ii = 0; ii < ff_mat.nnz; ii++) { JA[ii] = perm_col[ff_mat.j[ii]]; } std::copy_n(ff_mat.aij, ff_mat.nnz, aa); ISLocalToGlobalMapping mapping_row; - ISLocalToGlobalMappingCreate(comm, 1, indices_row.size(), indices_row.data(), PETSC_COPY_VALUES, &mapping_row); + ISLocalToGlobalMappingCreate(comm, 1, indices_row.size( ), indices_row.data( ), PETSC_COPY_VALUES, &mapping_row); ISLocalToGlobalMapping mapping_col; - ISLocalToGlobalMappingCreate(comm, 1, indices_col.size(), indices_col.data(), PETSC_COPY_VALUES, &mapping_col); + ISLocalToGlobalMappingCreate(comm, 1, indices_col.size( ), indices_col.data( ), PETSC_COPY_VALUES, &mapping_col); Mat matISlocal, matIJ; @@ -6284,13 +5770,13 @@ namespace PETSc { // This 4 lines are equivalent to MatCreateSeqAIJ MatCreate(PETSC_COMM_SELF, &matISlocal); - MatSetType(matISlocal,MATSEQAIJ); - MatSetSizes(matISlocal, indices_row.size(), indices_col.size(), indices_row.size(), indices_col.size()); + MatSetType(matISlocal, MATSEQAIJ); + MatSetSizes(matISlocal, indices_row.size( ), indices_col.size( ), indices_row.size( ), indices_col.size( )); // nullptr can be replaced by the vector of nnz MatSeqAIJSetPreallocation(matISlocal, 0, nullptr); MatSeqAIJSetPreallocationCSR(matISlocal, IA, JA, aa); - //MatMPIAIJSetPreallocationCSR(matISlocal, IA, JA, aa); + // MatMPIAIJSetPreallocationCSR(matISlocal, IA, JA, aa); MatISSetLocalMat(matIS, matISlocal); @@ -6302,58 +5788,57 @@ namespace PETSc { MatDestroy(&matISlocal); // delete IA,JA aa - delete [] IA; - delete [] JA; - delete [] aa; + delete[] IA; + delete[] JA; + delete[] aa; } - template - AnyType OpMatrixtoBilinearFormVGPETSc::Op::operator()(Stack stack) const - { + template< class HpddmType > + AnyType OpMatrixtoBilinearFormVGPETSc< HpddmType >::Op::operator( )(Stack stack) const { typedef PetscScalar R; ffassert(b && b->nargs); - pvectgenericfes * pUh= GetAny((*b->euh)(stack)); - pvectgenericfes * pVh= GetAny((*b->evh)(stack)); + pvectgenericfes* pUh = GetAny< pvectgenericfes* >((*b->euh)(stack)); + pvectgenericfes* pVh = GetAny< pvectgenericfes* >((*b->evh)(stack)); - ffassert( *pUh && *pVh ); + ffassert(*pUh && *pVh); // Update is necessary when we get "pvectgenericfes" to take account a new mesh. - (*pUh)->update(); - (*pVh)->update(); + (*pUh)->update( ); + (*pVh)->update( ); - if( verbosity > 5){ - (*pUh)->printPointer(); - (*pVh)->printPointer(); + if (verbosity > 5) { + (*pUh)->printPointer( ); + (*pVh)->printPointer( ); } - int NpUh = (*pUh)->N; // number of fespace in pUh - int NpVh = (*pVh)->N; // number of fespace in pVh + int NpUh = (*pUh)->N; // number of fespace in pUh + int NpVh = (*pVh)->N; // number of fespace in pVh - KN UhNbOfDf = (*pUh)->vectOfNbOfDF(); // A changer en long - KN VhNbOfDf = (*pVh)->vectOfNbOfDF(); + KN< int > UhNbOfDf = (*pUh)->vectOfNbOfDF( ); // A changer en long + KN< int > VhNbOfDf = (*pVh)->vectOfNbOfDF( ); - KN UhNbItem = (*pUh)->vectOfNbitem(); - KN VhNbItem = (*pVh)->vectOfNbitem(); + KN< int > UhNbItem = (*pUh)->vectOfNbitem( ); + KN< int > VhNbItem = (*pVh)->vectOfNbitem( ); // - const KNM> & block_largs=b->block_largs; + const KNM< list< C_F0 > >& block_largs = b->block_largs; // check if we have a square matrix - bool A_is_square= (void*)pUh == (void*)pVh || ((*pUh)->totalNbOfDF()) == ( (*pVh)->totalNbOfDF()) ; + bool A_is_square = (void*)pUh == (void*)pVh || ((*pUh)->totalNbOfDF( )) == ((*pVh)->totalNbOfDF( )); // === simple check if A is symetrical === // // voir avec les autres. bool A_is_maybe_sym = (void*)pUh == (void*)pVh; // VF == true => VF type of Matrix - //bool VF=isVF(b->block_largs); //=== used to set the solver ??? block matrix ??? ===/ + // bool VF=isVF(b->block_largs); //=== used to set the solver ??? block matrix ??? ===/ bool VF = 0; // set parameteer of the matrix : Data_Sparse_Solver ds; - ds.factorize=0; - ds.initmat=true; + ds.factorize = 0; + ds.initmat = true; int np = OpCall_FormBilinear_np::n_name_param - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver(stack,ds, b->nargs,np); + SetEnd_Data_Sparse_Solver< R >(stack, ds, b->nargs, np); MPI_Comm comm = ds.commworld ? *static_cast< MPI_Comm* >(ds.commworld) : PETSC_COMM_WORLD; @@ -6363,129 +5848,129 @@ namespace PETSc { // set ds.sym = 0 ds.sym = 0; - if(verbosity>3) - cout << " === we consider the block matrix as a non symetric matrix === (to be change in the future)" << endl; + if (verbosity > 3) cout << " === we consider the block matrix as a non symetric matrix === (to be change in the future)" << endl; - if (! A_is_square ) - { - if(verbosity>3) cout << " -- the solver is un set on rectangular matrix " << endl; - } + if (!A_is_square) { + if (verbosity > 3) cout << " -- the solver is un set on rectangular matrix " << endl; + } // A quoi cela correspond?? Gestion du stack + autre - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH aout 2007 + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH aout 2007 - PETSc::DistributedCSR< HpddmType > * Ares( GetAny*>((*a)(stack))); + PETSc::DistributedCSR< HpddmType >* Ares(GetAny< PETSc::DistributedCSR< HpddmType >* >((*a)(stack))); // test function (Vh) are the line // inconnu function (Uh) are the column // Assemble the variationnal form - int maxJVh=NpVh; + int maxJVh = NpVh; - Mat* a = new Mat[NpUh * maxJVh](); - std::vector> destroy; + Mat* a = new Mat[NpUh * maxJVh]( ); + std::vector< std::pair< int, int > > destroy; destroy.reserve(NpUh * maxJVh); int offsetMatrixUh = 0; // loop over the block - for( int i=0; i 0 ){ maxJVh=(i+1); ffassert(maxJVh3){ - cout << "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; - cout << "construction of block i,j=" << i << ","<< j << endl; - cout << " " << endl; + if (ds.sym > 0) { + maxJVh = (i + 1); + ffassert(maxJVh < NpVh); + } + for (int j = 0; j < maxJVh; j++) { + if (mpirank == 0 && verbosity > 3) { + cout << "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; + cout << "construction of block i,j=" << i << "," << j << endl; + cout << " " << endl; } // construction du block (i,j) - const list & b_largs=block_largs(i,j); + const list< C_F0 >& b_largs = block_largs(i, j); // size of the block int N_block = UhNbOfDf[i]; int M_block = VhNbOfDf[j]; // initialise the bem block and fem block - Matrice_Creuse Afem; - Afem.init(); - Afem.resize(M_block,N_block); + Matrice_Creuse< R > Afem; + Afem.init( ); + Afem.resize(M_block, N_block); int nsparseblocks = 0; Mat Abem = nullptr; - if(verbosity>2) cout << "size_block =" << b_largs.size() << endl; - if( b_largs.size()> 0){ + if (verbosity > 2) cout << "size_block =" << b_largs.size( ) << endl; + if (b_largs.size( ) > 0) { // compute largs due BEM and FEM part - list largs_FEM; - list largs_BEM; - largs_FEM.clear(); - largs_BEM.clear(); - separateFEMpartBemPart( b_largs, largs_FEM, largs_BEM ); - - if(verbosity>2){ - cout << " FEM.size()=" << largs_FEM.size() << endl; - cout << " BEM.size()=" << largs_BEM.size() << endl; + list< C_F0 > largs_FEM; + list< C_F0 > largs_BEM; + largs_FEM.clear( ); + largs_BEM.clear( ); + separateFEMpartBemPart(b_largs, largs_FEM, largs_BEM); + + if (verbosity > 2) { + cout << " FEM.size()=" << largs_FEM.size( ) << endl; + cout << " BEM.size()=" << largs_BEM.size( ) << endl; } - if( largs_BEM.size() >0 ){ + if (largs_BEM.size( ) > 0) { // compute of BEM par - #if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) +#if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) // need bemtool, htool - const list & b_largs_zz = largs_BEM; + const list< C_F0 >& b_largs_zz = largs_BEM; - int VFBEM = typeVFBEM(b_largs_zz,stack); - if(VFBEM == 2){ cerr << " not implemented with BEM POTENTIAL" << endl; ffassert(0);} + int VFBEM = typeVFBEM(b_largs_zz, stack); + if (VFBEM == 2) { + cerr << " not implemented with BEM POTENTIAL" << endl; + ffassert(0); + } // // avoir dans le futur si la difference entre bloc diagonal et bloc non diagonal a un sens. // - if( i==j ){ + if (i == j) { - bool samemesh = (void*) (*pUh)->vect[i]->getppTh() == (void*) (*pVh)->vect[j]->getppTh(); // same Fem2D::Mesh +++ pot or kernel - if (VFBEM==1) - ffassert (samemesh); + bool samemesh = (void*)(*pUh)->vect[i]->getppTh( ) == (void*)(*pVh)->vect[j]->getppTh( ); // same Fem2D::Mesh +++ pot or kernel + if (VFBEM == 1) ffassert(samemesh); - PETSc::DistributedCSR< HpddmType > *Abemblocki = nullptr, *Abemblock = nullptr; + PETSc::DistributedCSR< HpddmType >*Abemblocki = nullptr, *Abemblock = nullptr; // block diagonal matrix - for (list::const_iterator ii=b_largs_zz.begin(); ii!=b_largs_zz.end(); ii++) { - list bi; - bi.clear(); + for (list< C_F0 >::const_iterator ii = b_largs_zz.begin( ); ii != b_largs_zz.end( ); ii++) { + list< C_F0 > bi; + bi.clear( ); bi.push_back(*ii); - if( (*pUh)->typeFE[i] == 4 && (*pVh)->typeFE[j] == 4 ){ - ffassert( i==j ); // If not a block diagonal not coded yet + if ((*pUh)->typeFE[i] == 4 && (*pVh)->typeFE[j] == 4) { + ffassert(i == j); // If not a block diagonal not coded yet // MeshS --- MeshS // ==== FESpace 3d Surf: inconnue et test === - const FESpaceS * PUh = (FESpaceS *) (*pUh)->vect[i]->getpVh(); - const FESpaceS * PVh = (FESpaceS *) (*pVh)->vect[j]->getpVh(); + const FESpaceS* PUh = (FESpaceS*)(*pUh)->vect[i]->getpVh( ); + const FESpaceS* PVh = (FESpaceS*)(*pVh)->vect[j]->getpVh( ); Abemblocki = new PETSc::DistributedCSR< HpddmType >; - MatCreateAIJ(comm,PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF,0,NULL,0,NULL,&Abemblocki->_petsc); - varfBem(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); - } - else if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 5 ){ - ffassert( i==j ); // If not a block diagonal not coded yet + MatCreateAIJ(comm, PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF, 0, NULL, 0, NULL, &Abemblocki->_petsc); + varfBem< v_fesS, v_fesS >(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); + } else if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 5) { + ffassert(i == j); // If not a block diagonal not coded yet // MeshL --- MeshL // ==== FESpace 3d Curve: inconnue et test === - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); - const FESpaceL * PVh = (FESpaceL *) (*pVh)->vect[j]->getpVh(); + const FESpaceL* PUh = (FESpaceL*)(*pUh)->vect[i]->getpVh( ); + const FESpaceL* PVh = (FESpaceL*)(*pVh)->vect[j]->getpVh( ); Abemblocki = new PETSc::DistributedCSR< HpddmType >; - MatCreateAIJ(comm,PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF,0,NULL,0,NULL,&Abemblocki->_petsc); - varfBem(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); - } - else{ + MatCreateAIJ(comm, PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF, 0, NULL, 0, NULL, &Abemblocki->_petsc); + varfBem< v_fesL, v_fesL >(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); + } else { cerr << " BEM bilinear form " << endl; - cerr << " Block ("<< i <<" ,"<< j << ")" << endl; - cerr << " =: Pas prise en compte des FESpace inconnue de type := "<< typeFEtoString( (*pUh)->typeFE[i] ) << endl; - cerr << " =: avec des FESpace test de type := "<< typeFEtoString( (*pVh)->typeFE[j] ) << endl; + cerr << " Block (" << i << " ," << j << ")" << endl; + cerr << " =: Pas prise en compte des FESpace inconnue de type := " << typeFEtoString((*pUh)->typeFE[i]) << endl; + cerr << " =: avec des FESpace test de type := " << typeFEtoString((*pVh)->typeFE[j]) << endl; ffassert(0); } if (Abemblock == nullptr) { Abemblock = Abemblocki; - } - else { - Mat mats[2] = { Abemblocki->_petsc, Abemblock->_petsc }; + } else { + Mat mats[2] = {Abemblocki->_petsc, Abemblock->_petsc}; Mat C; MatCreateComposite(PetscObjectComm((PetscObject)Abemblock->_petsc), 2, mats, &C); MatCompositeSetType(C, MAT_COMPOSITE_ADDITIVE); @@ -6495,51 +5980,47 @@ namespace PETSc { } } Abem = Abemblock->_petsc; - } - else{ + } else { - bool samemesh = (void*) (*pUh)->vect[i]->getppTh() == (void*) (*pVh)->vect[j]->getppTh(); // same Fem2D::Mesh +++ pot or kernel + bool samemesh = (void*)(*pUh)->vect[i]->getppTh( ) == (void*)(*pVh)->vect[j]->getppTh( ); // same Fem2D::Mesh +++ pot or kernel - PETSc::DistributedCSR< HpddmType > *Abemblocki = nullptr, *Abemblock = nullptr; + PETSc::DistributedCSR< HpddmType >*Abemblocki = nullptr, *Abemblock = nullptr; // block non diagonal matrix - for (list::const_iterator ii=b_largs_zz.begin(); ii!=b_largs_zz.end(); ii++) { - list bi; - bi.clear(); + for (list< C_F0 >::const_iterator ii = b_largs_zz.begin( ); ii != b_largs_zz.end( ); ii++) { + list< C_F0 > bi; + bi.clear( ); bi.push_back(*ii); - if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2 ){ + if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2) { // case Uh[i] == MeshL et Vh[j] = Mesh2 - if(verbosity >3) cout << " === creation de la matrice BEM pour un bloc non diagonal === " << endl; - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonal === " << endl; + const FESpaceL* PUh = (FESpaceL*)(*pUh)->vect[i]->getpVh( ); Abemblocki = new PETSc::DistributedCSR< HpddmType >; - MatCreateAIJ(comm,PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF,0,NULL,0,NULL,&Abemblocki->_petsc); - varfBem(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); - } - else if( (*pUh)->typeFE[i] == 2 && (*pVh)->typeFE[j] == 5 ){ + MatCreateAIJ(comm, PETSC_DECIDE, PETSC_DECIDE, PUh->NbOfDF, PUh->NbOfDF, 0, NULL, 0, NULL, &Abemblocki->_petsc); + varfBem< v_fesL, v_fesL >(PUh, PUh, 1, VFBEM, stack, bi, ds, Abemblocki); + } else if ((*pUh)->typeFE[i] == 2 && (*pVh)->typeFE[j] == 5) { // case Uh[i] == Mesh2 et Vh[j] = MeshL - if(verbosity >3) cout << " === creation de la matrice BEM pour un bloc non diagonal === " << endl; - const FESpaceL * PVh = (FESpaceL *) (*pVh)->vect[j]->getpVh(); + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonal === " << endl; + const FESpaceL* PVh = (FESpaceL*)(*pVh)->vect[j]->getpVh( ); Abemblocki = new PETSc::DistributedCSR< HpddmType >; - MatCreateAIJ(comm,PETSC_DECIDE, PETSC_DECIDE, PVh->NbOfDF, PVh->NbOfDF,0,NULL,0,NULL,&Abemblocki->_petsc); - varfBem(PVh, PVh, 1, VFBEM, stack, bi, ds, Abemblocki); - } - else{ + MatCreateAIJ(comm, PETSC_DECIDE, PETSC_DECIDE, PVh->NbOfDF, PVh->NbOfDF, 0, NULL, 0, NULL, &Abemblocki->_petsc); + varfBem< v_fesL, v_fesL >(PVh, PVh, 1, VFBEM, stack, bi, ds, Abemblocki); + } else { cerr << " BEM bilinear form " << endl; - cerr << " Block ("<< i <<" ,"<< j << ")" << endl; - cerr << " =: Pas prise en compte des FESpace inconnue de type := "<< typeFEtoString( (*pUh)->typeFE[i] ) << endl; - cerr << " =: avec des FESpace test de type := "<< typeFEtoString( (*pVh)->typeFE[j] ) << endl; + cerr << " Block (" << i << " ," << j << ")" << endl; + cerr << " =: Pas prise en compte des FESpace inconnue de type := " << typeFEtoString((*pUh)->typeFE[i]) << endl; + cerr << " =: avec des FESpace test de type := " << typeFEtoString((*pVh)->typeFE[j]) << endl; ffassert(0); } if (Abemblock == nullptr) { Abemblock = Abemblocki; - } - else { - Mat mats[2] = { Abemblocki->_petsc, Abemblock->_petsc }; + } else { + Mat mats[2] = {Abemblocki->_petsc, Abemblock->_petsc}; Mat C; MatCreateComposite(PetscObjectComm((PetscObject)Abemblock->_petsc), 2, mats, &C); MatCompositeSetType(C, MAT_COMPOSITE_ADDITIVE); @@ -6551,159 +6032,150 @@ namespace PETSc { // creation de la matrice dense // BEM matrix is constructed with different FESpace - ffassert( (*pUh)->vect[i]->getpVh() != (*pVh)->vect[j]->getpVh() ) ; + ffassert((*pUh)->vect[i]->getpVh( ) != (*pVh)->vect[j]->getpVh( )); - if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2 ){ + if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2) { // case Uh[i] == MeshL et Vh[j] = Mesh2 - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); - const FESpace * PVh = (FESpace *) (*pVh)->vect[j]->getpVh(); + const FESpaceL* PUh = (FESpaceL*)(*pUh)->vect[i]->getpVh( ); + const FESpace* PVh = (FESpace*)(*pVh)->vect[j]->getpVh( ); // construction of the matrix of interpolation // The transpose is in the build matrix now bool transpose_MI = false; - Matrice_Creuse * MI_BBB = PETSC_buildMatrixInterpolationForCompositeFESpace( PUh, PVh, transpose_MI ); - MatriceMorse * mr =MI_BBB->pHM(); + Matrice_Creuse< double >* MI_BBB = PETSC_buildMatrixInterpolationForCompositeFESpace< double, FESpaceL, FESpace >(PUh, PVh, transpose_MI); + MatriceMorse< double >* mr = MI_BBB->pHM( ); // Transform Real Matrix in Complex Matrix - MatriceMorse * mA = new MatriceMorse(mr->n,mr->m,0,0); + MatriceMorse< R >* mA = new MatriceMorse< R >(mr->n, mr->m, 0, 0); // we divide by mpisize because the interpolation matrix is computed in sequential int size; MPI_Comm_size(comm, &size); - *mr *= 1.0/size; + *mr *= 1.0 / size; *mA = *mr; // transform intrerpolation matrix to matrix IS Mat matIS_MI; - ff_createMatIS( *mA, matIS_MI, comm); + ff_createMatIS(*mA, matIS_MI, comm); - if( transpose_MI) ffassert(0); // transpose ==true doesn't work. Error Matrice Interpolation + if (transpose_MI) ffassert(0); // transpose ==true doesn't work. Error Matrice Interpolation Mat mAAT; - if (std::is_same< PetscScalar, PetscReal >::value) MatCreateTranspose(matIS_MI, &mAAT); - else MatCreateHermitianTranspose(matIS_MI, &mAAT); + if (std::is_same< PetscScalar, PetscReal >::value) + MatCreateTranspose(matIS_MI, &mAAT); + else + MatCreateHermitianTranspose(matIS_MI, &mAAT); MatDestroy(&matIS_MI); // create composite - Mat mats[2] = { Abemblock->_petsc , mAAT}; + Mat mats[2] = {Abemblock->_petsc, mAAT}; Mat C; MatCreateComposite(PetscObjectComm((PetscObject)Abemblock->_petsc), 2, mats, &C); MatCompositeSetType(C, MAT_COMPOSITE_MULTIPLICATIVE); Abem = C; // Abemblock->dtor(); // ??? - MatDestroy(&mAAT); // ??? + MatDestroy(&mAAT); // ??? // we need to do that because R=Complex with BEM - MI_BBB->destroy(); + MI_BBB->destroy( ); delete MI_BBB; - } - else if( (*pUh)->typeFE[i] == 2 && (*pVh)->typeFE[j] == 5 ){ + } else if ((*pUh)->typeFE[i] == 2 && (*pVh)->typeFE[j] == 5) { // case Uh[i] == Mesh2 et Vh[j] = MeshL - const FESpace * PUh = (FESpace *) (*pUh)->vect[i]->getpVh(); - const FESpaceL * PVh = (FESpaceL *) (*pVh)->vect[j]->getpVh(); + const FESpace* PUh = (FESpace*)(*pUh)->vect[i]->getpVh( ); + const FESpaceL* PVh = (FESpaceL*)(*pVh)->vect[j]->getpVh( ); // construction of the matrix of interpolation bool transpose_MI = false; - Matrice_Creuse * MI_BBB = PETSC_buildMatrixInterpolationForCompositeFESpace( PVh, PUh, transpose_MI ); - MatriceMorse * mr =MI_BBB->pHM(); + Matrice_Creuse< double >* MI_BBB = PETSC_buildMatrixInterpolationForCompositeFESpace< double, FESpaceL, FESpace >(PVh, PUh, transpose_MI); + MatriceMorse< double >* mr = MI_BBB->pHM( ); // Transform Real Matrix in Complex Matrix - MatriceMorse * mA = new MatriceMorse(mr->n,mr->m,0,0); + MatriceMorse< R >* mA = new MatriceMorse< R >(mr->n, mr->m, 0, 0); // we divide by mpisize because the interpolation matrix is computed in sequential int size; MPI_Comm_size(comm, &size); - *mr *= 1.0/size; + *mr *= 1.0 / size; *mA = *mr; // transform intrerpolation matrix to matrix IS Mat matIS_MI; - ff_createMatIS( *mA, matIS_MI, comm); + ff_createMatIS(*mA, matIS_MI, comm); // create composite - Mat mats[2] = { matIS_MI, Abemblock->_petsc }; + Mat mats[2] = {matIS_MI, Abemblock->_petsc}; Mat C; MatCreateComposite(PetscObjectComm((PetscObject)Abemblock->_petsc), 2, mats, &C); MatCompositeSetType(C, MAT_COMPOSITE_MULTIPLICATIVE); Abem = C; MatDestroy(&matIS_MI); - MI_BBB->destroy(); + MI_BBB->destroy( ); delete MI_BBB; - } - else{ + } else { cerr << "==== to do ==== " << endl; ffassert(0); } - - } - #endif +#endif } - if( largs_FEM.size() >0){ - const list & b_largs_zz = largs_FEM; + if (largs_FEM.size( ) > 0) { + const list< C_F0 >& b_largs_zz = largs_FEM; - varfToCompositeBlockLinearSystemALLCASE_pfes( i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], - 0, 0, (*pUh)->vect[i], (*pVh)->vect[j], - true, false, ds.sym, ds.tgv, ds.commworld, - b_largs_zz, stack, - 0, 0, Afem.pHM()); + varfToCompositeBlockLinearSystemALLCASE_pfes< R >(i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], 0, 0, (*pUh)->vect[i], (*pVh)->vect[j], true, false, ds.sym, ds.tgv, ds.commworld, b_largs_zz, + stack, 0, 0, Afem.pHM( )); nsparseblocks++; } } - offsetMatrixVh += VhNbOfDf[j]; + offsetMatrixVh += VhNbOfDf[j]; - if(b_largs.size()> 0){ - Afem.pHM()->half = ds.sym; + if (b_largs.size( ) > 0) { + Afem.pHM( )->half = ds.sym; - Mat matIS; - if(nsparseblocks){ - ff_createMatIS( *(Afem.pHM()), matIS, comm); - Afem.destroy(); - } - - if (Abem != nullptr) { - if (!nsparseblocks) { - a[j * maxJVh + i] = Abem; + Mat matIS; + if (nsparseblocks) { + ff_createMatIS(*(Afem.pHM( )), matIS, comm); + Afem.destroy( ); } - else { - Mat mats[2] = { matIS, Abem }; - Mat C; - MatCreateComposite(PetscObjectComm((PetscObject)matIS), 2, mats, &C); - MatCompositeSetType(C, MAT_COMPOSITE_ADDITIVE); - a[j * maxJVh + i] = C; + + if (Abem != nullptr) { + if (!nsparseblocks) { + a[j * maxJVh + i] = Abem; + } else { + Mat mats[2] = {matIS, Abem}; + Mat C; + MatCreateComposite(PetscObjectComm((PetscObject)matIS), 2, mats, &C); + MatCompositeSetType(C, MAT_COMPOSITE_ADDITIVE); + a[j * maxJVh + i] = C; + } + } else { + a[j * maxJVh + i] = matIS; } + destroy.emplace_back(j, i); } - else { - a[j * maxJVh + i] = matIS; - } - destroy.emplace_back(j, i); - } - } // end loop j + } // end loop j offsetMatrixUh += UhNbOfDf[i]; - } // end loop i - if(verbosity>3) cout << "Ares->_vector_global=" << Ares->_vector_global << endl; + } // end loop i + if (verbosity > 3) cout << "Ares->_vector_global=" << Ares->_vector_global << endl; - if( NpUh==1 && maxJVh==1 ){ + if (NpUh == 1 && maxJVh == 1) { Ares->_petsc = a[0]; - Ares->_vector_global = (PetscBool) 1; - a = nullptr; // ??? - }else{ + Ares->_vector_global = (PetscBool)1; + a = nullptr; // ??? + } else { MatCreateNest(comm, NpUh, NULL, maxJVh, NULL, a, &Ares->_petsc); - Ares->_vector_global = (PetscBool) 1; - for(std::pair p : destroy) - MatDestroy(a + p.first * maxJVh + p.second); + Ares->_vector_global = (PetscBool)1; + for (std::pair< int, int > p : destroy) MatDestroy(a + p.first * maxJVh + p.second); delete[] a; } - return SetAny*>(Ares); + return SetAny< PETSc::DistributedCSR< HpddmType >* >(Ares); } -} // namespace PETSc +} // namespace PETSc static void Init_PETSc( ) { - if (verbosity > 1 && mpirank == 0) - cout << " PETSc (" << typeid(PetscScalar).name( ) << ")" << endl; + if (verbosity > 1 && mpirank == 0) cout << " PETSc (" << typeid(PetscScalar).name( ) << ")" << endl; if (exist_type< DmatC* >( )) { - if(mpirank == 0) cout << "Cannot load both \"PETSc\" and \"PETSc-complex\", please pick a single one" << endl; + if (mpirank == 0) cout << "Cannot load both \"PETSc\" and \"PETSc-complex\", please pick a single one" << endl; ffassert(0); } int argc = pkarg->n; @@ -6745,10 +6217,10 @@ static void Init_PETSc( ) { Global.Add("constructor", "(", new PETSc::initCSR< HpSchwarz< PetscScalar >, true >(1)); Global.Add("constructor", "(", new PETSc::initCSR< HpSchwarz< PetscScalar >, true >(1, 1, 1)); Global.Add("MatDestroy", "(", new OneOperator1< long, Dmat* >(PETSc::destroyCSR)); - zzzfff->Add("PetscScalar", atype::value, double, Complex>::type*>()); - Add< Dmat* >("D", ".", new OneOperator1< KN_, Dmat* >(PETSc::Dmat_D)); + zzzfff->Add("PetscScalar", atype< std::conditional< std::is_same< PetscScalar, PetscReal >::value, double, Complex >::type* >( )); + Add< Dmat* >("D", ".", new OneOperator1< KN_< double >, Dmat* >(PETSc::Dmat_D)); Add< Dmat* >("n", ".", new OneOperator1< long, Dmat* >(PETSc::Dmat_n)); - Add< Dmat* >("range", ".", new OneOperator1s_< KN_, Dmat* >(PETSc::Dmat_range)); + Add< Dmat* >("range", ".", new OneOperator1s_< KN_< long >, Dmat* >(PETSc::Dmat_range)); #if !defined(PETSC_USE_REAL_SINGLE) TheOperators->Add("<-", new PETSc::initCSRfromArray< HpSchwarz< PetscScalar > >); #endif @@ -6760,55 +6232,52 @@ static void Init_PETSc( ) { TheOperators->Add("<-", new PETSc::initRectangularCSRfromDMatrix< HpSchwarz< PetscScalar >, 1 >); TheOperators->Add("<-", new PETSc::initRectangularCSRfromDMatrix< HpSchwarz< PetscScalar >, 0 >(1)); Global.Add("constructor", "(", new PETSc::initRectangularCSRfromDMatrix< HpSchwarz< PetscScalar >, 0 >(1, 1)); - TheOperators->Add( - "<-", new OneOperatorCode< PETSc::initCSRfromBlockMatrix< HpSchwarz< PetscScalar > > >( )); - TheOperators->Add("<-", new PETSc::OpMatrixtoBilinearFormVGPETSc< HpSchwarz< PetscScalar> >(1)); - TheOperators->Add( - "=", new OneOperatorCode< PETSc::assignBlockMatrix< HpSchwarz< PetscScalar > > >( ), - new PETSc::varfToMat< PetscScalar, Mesh , v_fes , v_fes >, - new PETSc::varfToMat< PetscScalar, Mesh3, v_fes3, v_fes3 >, - new PETSc::varfToMat< PetscScalar, MeshS, v_fesS, v_fesS >, - new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fesL >, - new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fes >, - new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fesS >, - new PETSc::varfToMat< PetscScalar, MeshL, v_fes , v_fesL > - ); + TheOperators->Add("<-", new OneOperatorCode< PETSc::initCSRfromBlockMatrix< HpSchwarz< PetscScalar > > >( )); + TheOperators->Add("<-", new PETSc::OpMatrixtoBilinearFormVGPETSc< HpSchwarz< PetscScalar > >(1)); + TheOperators->Add("=", new OneOperatorCode< PETSc::assignBlockMatrix< HpSchwarz< PetscScalar > > >( ), new PETSc::varfToMat< PetscScalar, Mesh, v_fes, v_fes >, + new PETSc::varfToMat< PetscScalar, Mesh3, v_fes3, v_fes3 >, new PETSc::varfToMat< PetscScalar, MeshS, v_fesS, v_fesS >, new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fesL >, + new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fes >, new PETSc::varfToMat< PetscScalar, MeshL, v_fesL, v_fesS >, new PETSc::varfToMat< PetscScalar, MeshL, v_fes, v_fesL >); #if defined(WITH_bemtool) && defined(WITH_htool) && defined(PETSC_HAVE_HTOOL) typedef const BemKernel fkernel; - if (!exist_type< fkernel* >( )) map_type[typeid(const BemFormBilinear *).name( )] = new TypeFormBEM; + if (!exist_type< fkernel* >( )) map_type[typeid(const BemFormBilinear*).name( )] = new TypeFormBEM; #endif - addProd< Dmat, PETSc::ProdPETSc, KN< upscaled_type >, PetscScalar, 'N' >( ); - addProd< Dmat, PETSc::ProdPETSc, KN< upscaled_type >, PetscScalar, 'T' >( ); - addInv< Dmat, PETSc::InvPETSc, KN< upscaled_type >, PetscScalar, 'N' >( ); - addInv< Dmat, PETSc::InvPETSc, KN< upscaled_type >, PetscScalar, 'T' >( ); - Dcl_Type, KNM< upscaled_type >*, PetscScalar, 'N'>>(); - TheOperators->Add("*", new OneBinaryOperator_st, KNM< upscaled_type >*, PetscScalar, 'N'>, pwr, KNM< upscaled_type >*>>); - TheOperators->Add("=", new OneOperator2 >*, KNM< upscaled_type >*, PETSc::InvPETSc, KNM< upscaled_type >*, PetscScalar, 'N'>>(PETSc::InvPETSc, KNM< upscaled_type >*, PetscScalar, 'N'>::inv)); - TheOperators->Add("<-", new OneOperator2 >*, KNM< upscaled_type >*, PETSc::InvPETSc, KNM< upscaled_type >*, PetscScalar, 'N'>>(PETSc::InvPETSc, KNM< upscaled_type >*, PetscScalar, 'N'>::init)); + addProd< Dmat, PETSc::ProdPETSc, KN< upscaled_type< PetscScalar > >, PetscScalar, 'N' >( ); + addProd< Dmat, PETSc::ProdPETSc, KN< upscaled_type< PetscScalar > >, PetscScalar, 'T' >( ); + addInv< Dmat, PETSc::InvPETSc, KN< upscaled_type< PetscScalar > >, PetscScalar, 'N' >( ); + addInv< Dmat, PETSc::InvPETSc, KN< upscaled_type< PetscScalar > >, PetscScalar, 'T' >( ); + Dcl_Type< PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' > >( ); + TheOperators->Add("*", + new OneBinaryOperator_st< assign< PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' >, pwr< Dmat >, KNM< upscaled_type< PetscScalar > >* > >); + TheOperators->Add( + "=", new OneOperator2< KNM< upscaled_type< PetscScalar > >*, KNM< upscaled_type< PetscScalar > >*, PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' > >( + PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' >::inv)); + TheOperators->Add( + "<-", new OneOperator2< KNM< upscaled_type< PetscScalar > >*, KNM< upscaled_type< PetscScalar > >*, PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' > >( + PETSc::InvPETSc< pwr< Dmat >, KNM< upscaled_type< PetscScalar > >*, PetscScalar, 'N' >::init)); Global.Add("set", "(", new PETSc::setOptions< Dmat >( )); Global.Add("set", "(", new PETSc::setOptions< Dmat >(1)); Global.Add("set", "(", new PETSc::setOptions< Dmat >(1, 1)); Global.Add("set", "(", new PETSc::setOptions< Dmat >(1, 1, 1)); Global.Add("exchange", "(", new exchangeIn< Dmat, PetscScalar >); Global.Add("exchange", "(", new exchangeInOut< Dmat, PetscScalar >); - PETSc::init(); + PETSc::init< PetscReal >( ); Global.Add("ChangeOperator", "(", new PETSc::changeOperator< Dmat >( )); Global.Add("ChangeOperator", "(", new PETSc::changeOperator< Dmat >(1)); - TheOperators->Add("=", new OneOperator2_< Dmat*, Dmat*, Matrice_Creuse< upscaled_type >* >(PETSc::changeOperatorSimple)); + TheOperators->Add("=", new OneOperator2_< Dmat*, Dmat*, Matrice_Creuse< upscaled_type< PetscScalar > >* >(PETSc::changeOperatorSimple)); TheOperators->Add("=", new OneOperator2_< Dmat*, Dmat*, Dmat* >(PETSc::changeOperatorSimple)); - TheOperators->Add("*=", new OneBinaryOperator< PETSc::scale> >); - Dcl_Type< std::pair, Dmat*>* >(); - Dcl_Type< std::pair* >(); - atype, Dmat*>*>()->AddCast(new E_F1_funcT, Dmat*>*, Dmat*>(PETSc::M2P)); - TheOperators->Add("+=", new OneBinaryOperator< PETSc::AXPY >, - new OneOperator2_< Dmat*, Dmat*, std::pair, Dmat*>*, E_F_StackF0F0>(PETSc::AddCombDmat)); - TheOperators->Add("*", new OneBinaryOperator>>); - TheOperators->Add("*", new OneBinaryOperator>); + TheOperators->Add("*=", new OneBinaryOperator< PETSc::scale< Dmat*, upscaled_type< PetscScalar > > >); + Dcl_Type< std::pair< upscaled_type< PetscScalar >, Dmat* >* >( ); + Dcl_Type< std::pair< Dmat*, Dmat* >* >( ); + atype< std::pair< upscaled_type< PetscScalar >, Dmat* >* >( )->AddCast(new E_F1_funcT< std::pair< upscaled_type< PetscScalar >, Dmat* >*, Dmat* >(PETSc::M2P)); + TheOperators->Add("+=", new OneBinaryOperator< PETSc::AXPY< Dmat*, Dmat* > >, + new OneOperator2_< Dmat*, Dmat*, std::pair< upscaled_type< PetscScalar >, Dmat* >*, E_F_StackF0F0 >(PETSc::AddCombDmat< PetscScalar >)); + TheOperators->Add("*", new OneBinaryOperator< PETSc::Op2< upscaled_type< PetscScalar > > >); + TheOperators->Add("*", new OneBinaryOperator< PETSc::Op2< Dmat* > >); Global.Add("PetscLogStagePush", "(", new OneOperator1_< long, string* >(PETSc::stagePush)); Global.Add("PetscLogStagePop", "(", new OneOperator0< long >(PETSc::stagePop)); Global.Add("PetscMemoryGetCurrentUsage", "(", new OneOperator0< double >(PETSc::memoryGetCurrentUsage)); Global.Add("HasType", "(", new OneOperator2_< long, string*, string* >(PETSc::hasType)); - Global.Add("KSPBuildSolution", "(", new PETSc::buildSolution()); + Global.Add("KSPBuildSolution", "(", new PETSc::buildSolution( )); Init_Common( ); Dcl_Type< PETSc::DMPlex* >(Initialize< PETSc::DMPlex >, DeleteDTOR< PETSc::DMPlex >); zzzfff->Add("DM", atype< PETSc::DMPlex* >( )); diff --git a/plugin/mpi/PETSc-complex.cpp b/plugin/mpi/PETSc-complex.cpp index 590d9779b..abe3a7546 100644 --- a/plugin/mpi/PETSc-complex.cpp +++ b/plugin/mpi/PETSc-complex.cpp @@ -1,19 +1,21 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: [slepccomplex petsccomplex|petsccomplex] [mkl|blas] [htool bemtool boost] hpddm mpi //ff-c++-cpp-dep: +/* clang-format on */ -#define PETScandSLEPc 1 +#define PETScandSLEPc 1 #if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-result" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-result" #elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-result" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" #endif #include "PETSc-code.hpp" #include "SLEPc-code.hpp" #if defined(__clang__) - #pragma clang diagnostic pop +#pragma clang diagnostic pop #elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif LOADFUNC(Init) diff --git a/plugin/mpi/PETSc.cpp b/plugin/mpi/PETSc.cpp index 716a6796b..f7d91e4f6 100644 --- a/plugin/mpi/PETSc.cpp +++ b/plugin/mpi/PETSc.cpp @@ -1,18 +1,20 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: [slepc petsc|petsc] [mkl|blas] hpddm mpi //ff-c++-cpp-dep: -#define PETScandSLEPc 1 +/* clang-format on */ +#define PETScandSLEPc 1 #if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-result" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-result" #elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-result" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" #endif #include "PETSc-code.hpp" #include "SLEPc-code.hpp" #if defined(__clang__) - #pragma clang diagnostic pop +#pragma clang diagnostic pop #elif defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif LOADFUNC(Init) diff --git a/plugin/mpi/PETSc.hpp b/plugin/mpi/PETSc.hpp index 3b995a6d0..e232d43b0 100644 --- a/plugin/mpi/PETSc.hpp +++ b/plugin/mpi/PETSc.hpp @@ -1,319 +1,304 @@ #ifndef PETSC_HPP_ #define PETSC_HPP_ -#define HPDDM_PETSC 1 +#define HPDDM_PETSC 1 #include "common_hpddm.hpp" namespace PETSc { -template -class DistributedCSR { - public: - HpddmType* _A; - KN* _D; - Mat _petsc; - std::vector* _vS; - VecScatter _scatter; - KSP _ksp; - HPDDM::Subdomain** _exchange; - PetscInt* _num; - PetscInt _first; - PetscInt _last; - PetscInt* _cnum; - PetscInt _cfirst; - PetscInt _clast; - PetscBool _vector_global; // In case of the rhs and solution of freefem are not distributed - DistributedCSR() : _A(), _D(), _petsc(), _vS(), _ksp(), _exchange(), _num(), _first(), _last(), _cnum(), _cfirst(), _clast(), _vector_global() { } - ~DistributedCSR() { - dtor(); + template< class HpddmType > + class DistributedCSR { + public: + HpddmType* _A; + KN< PetscReal >* _D; + Mat _petsc; + std::vector< Mat >* _vS; + VecScatter _scatter; + KSP _ksp; + HPDDM::Subdomain< PetscScalar >** _exchange; + PetscInt* _num; + PetscInt _first; + PetscInt _last; + PetscInt* _cnum; + PetscInt _cfirst; + PetscInt _clast; + PetscBool _vector_global; // In case of the rhs and solution of freefem are not distributed + DistributedCSR( ) : _A( ), _D( ), _petsc( ), _vS( ), _ksp( ), _exchange( ), _num( ), _first( ), _last( ), _cnum( ), _cfirst( ), _clast( ), _vector_global( ) {} + ~DistributedCSR( ) { dtor( ); } + void dtor( ) { + if (_petsc) { + MatType type; + PetscBool isType; + MatGetType(_petsc, &type); + PetscStrcmp(type, MATNEST, &isType); + if (isType) { + delete[] reinterpret_cast< decltype(this)* >(_exchange); + _exchange = nullptr; } - void dtor() { - if(_petsc) { - MatType type; - PetscBool isType; - MatGetType(_petsc, &type); - PetscStrcmp(type, MATNEST, &isType); - if(isType) { - delete [] reinterpret_cast(_exchange); - _exchange = nullptr; - } - PetscContainer ptr; - PetscObjectQuery((PetscObject)_petsc, "HtoolCtx", (PetscObject*)&ptr); - PetscContainerDestroy(&ptr); - MatDestroy(&_petsc); - } - if(_vS) { - for(int i = 0; i < _vS->size(); ++i) - MatDestroy(&(*_vS)[i]); - delete _vS; - _vS = nullptr; - } - KSPDestroy(&_ksp); - if(_exchange) { - _exchange[0]->clearBuffer(); - delete _exchange[0]; - if(_exchange[1]) { - _exchange[1]->clearBuffer(); - delete _exchange[1]; - } - delete [] _exchange; - _exchange = nullptr; - } - if(_A) { - if(!std::is_same>::value) - VecScatterDestroy(&_scatter); - else - _A->clearBuffer(); - delete _A; - _A = nullptr; - } - delete [] _num; - _num = nullptr; - if(_D) { - _D->destroy(); - delete _D; - _D = nullptr; - } + PetscContainer ptr; + PetscObjectQuery((PetscObject)_petsc, "HtoolCtx", (PetscObject*)&ptr); + PetscContainerDestroy(&ptr); + MatDestroy(&_petsc); + } + if (_vS) { + for (int i = 0; i < _vS->size( ); ++i) MatDestroy(&(*_vS)[i]); + delete _vS; + _vS = nullptr; + } + KSPDestroy(&_ksp); + if (_exchange) { + _exchange[0]->clearBuffer( ); + delete _exchange[0]; + if (_exchange[1]) { + _exchange[1]->clearBuffer( ); + delete _exchange[1]; } -}; + delete[] _exchange; + _exchange = nullptr; + } + if (_A) { + if (!std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value) + VecScatterDestroy(&_scatter); + else + _A->clearBuffer( ); + delete _A; + _A = nullptr; + } + delete[] _num; + _num = nullptr; + if (_D) { + _D->destroy( ); + delete _D; + _D = nullptr; + } + } + }; -class DMPlex { - public: - DM _dm; - DMPlex() : _dm() { } - ~DMPlex() { - dtor(); - } - void dtor() { - DMDestroy(&_dm); - } -}; + class DMPlex { + public: + DM _dm; + DMPlex( ) : _dm( ) {} + ~DMPlex( ) { dtor( ); } + void dtor( ) { DMDestroy(&_dm); } + }; -template>::value>::type* = nullptr> -void globalMapping(HpddmType* const& A, PetscInt*& num, PetscInt& start, PetscInt& end, long long& global, PetscInt* const list) { - num = new PetscInt[A->getDof()]; - A->template globalMapping<'C'>(num, num + A->getDof(), start, end, global, A->getScaling(), list); -} -template>::value>::type* = nullptr> -void globalMapping(HpddmType* const& A, PetscInt* const& num, PetscInt& start, PetscInt& end, long long& global, PetscInt* const list) { } -template>>::value>::type* = nullptr> -void setVectorSchur(Type* ptA, KN* const& mT, KN* const& pL) { + template< class HpddmType, typename std::enable_if< std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value >::type* = nullptr > + void globalMapping(HpddmType* const& A, PetscInt*& num, PetscInt& start, PetscInt& end, long long& global, PetscInt* const list) { + num = new PetscInt[A->getDof( )]; + A->template globalMapping< 'C' >(num, num + A->getDof( ), start, end, global, A->getScaling( ), list); + } + template< class HpddmType, typename std::enable_if< !std::is_same< HpddmType, HpSchwarz< PetscScalar > >::value >::type* = nullptr > + void globalMapping(HpddmType* const& A, PetscInt* const& num, PetscInt& start, PetscInt& end, long long& global, PetscInt* const list) {} + template< class Type, class Tab, typename std::enable_if< !std::is_same< Tab, PETSc::DistributedCSR< HpSchwarz< PetscScalar > > >::value >::type* = nullptr > + void setVectorSchur(Type* ptA, KN< Tab >* const& mT, KN< double >* const& pL) { int *is, *js; - PetscScalar *s; + PetscScalar* s; PetscInt* re = new PetscInt[pL->n]; PetscInt nbSchur = 1; - for(int i = 0; i < pL->n; ++i) - re[i] = std::abs((*pL)[i]) > 1.0e-12 ? nbSchur++ : 0; + for (int i = 0; i < pL->n; ++i) re[i] = std::abs((*pL)[i]) > 1.0e-12 ? nbSchur++ : 0; nbSchur--; PetscInt* num; PetscInt start, end; long long global; - ptA->_A->clearBuffer(); + ptA->_A->clearBuffer( ); globalMapping(ptA->_A, num, start, end, global, re); - delete [] re; + delete[] re; re = new PetscInt[2 * nbSchur]; PetscInt* numSchur = re + nbSchur; - for(int i = 0, j = 0; i < pL->n; ++i) { - if(std::abs((*pL)[i]) > 1.0e-12) { - *numSchur++ = num[i]; - re[std::lround((*pL)[i]) - 1] = j++; - } + for (int i = 0, j = 0; i < pL->n; ++i) { + if (std::abs((*pL)[i]) > 1.0e-12) { + *numSchur++ = num[i]; + re[std::lround((*pL)[i]) - 1] = j++; + } } numSchur -= nbSchur; - delete [] num; - for(int k = 0; k < mT->n; ++k) { - MatriceMorse>* mS = (mT->operator[](k)).A ? static_cast>*>(&(*(mT->operator[](k)).A)) : nullptr; - int n = mS ? mS->n : 0; - std::vector>> tmp(n); - if(mS) { - ffassert(!mS->half); - mS->CSR(); - } - int nnz = mS ? mS->nnz : 0; - for(int i = 0; i < n; ++i) { - PetscInt row = re[i]; - tmp[row].reserve(mS->p[i + 1] - mS->p[i]); - for(int j = mS->p[i]; j < mS->p[i + 1]; ++j) - tmp[row].emplace_back(re[mS->j[j]], mS->aij[j]); - std::sort(tmp[row].begin(), tmp[row].end(), [](const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; }); - } - is = new int[n + 1]; - js = new int[nnz]; - s = new PetscScalar[nnz]; - is[0] = 0; - for(int i = 0; i < n; ++i) { - for(int j = 0; j < tmp[i].size(); ++j) { - *js++ = tmp[i][j].first; - *s++ = tmp[i][j].second; - } - is[i + 1] = is[i] + tmp[i].size(); - } - js -= nnz; - s -= nnz; - PetscInt *ia, *ja; - PetscScalar* c; - ia = ja = nullptr; - c = nullptr; - HPDDM::MatrixCSR* dN = new_HPDDM_MatrixCSR(mS, true, s, is, js); - bool free = dN ? ptA->_A->HPDDM::template Subdomain::distributedCSR(numSchur, start, end, ia, ja, c, dN) : false; - if(!ia && !ja && !c) { - ia = new PetscInt[2](); - free = true; + delete[] num; + for (int k = 0; k < mT->n; ++k) { + MatriceMorse< upscaled_type< PetscScalar > >* mS = (mT->operator[](k)).A ? static_cast< MatriceMorse< upscaled_type< PetscScalar > >* >(&(*(mT->operator[](k)).A)) : nullptr; + int n = mS ? mS->n : 0; + std::vector< std::vector< std::pair< int, PetscScalar > > > tmp(n); + if (mS) { + ffassert(!mS->half); + mS->CSR( ); + } + int nnz = mS ? mS->nnz : 0; + for (int i = 0; i < n; ++i) { + PetscInt row = re[i]; + tmp[row].reserve(mS->p[i + 1] - mS->p[i]); + for (int j = mS->p[i]; j < mS->p[i + 1]; ++j) tmp[row].emplace_back(re[mS->j[j]], mS->aij[j]); + std::sort(tmp[row].begin( ), tmp[row].end( ), [](const std::pair< int, PetscScalar >& lhs, const std::pair< int, PetscScalar >& rhs) { return lhs.first < rhs.first; }); + } + is = new int[n + 1]; + js = new int[nnz]; + s = new PetscScalar[nnz]; + is[0] = 0; + for (int i = 0; i < n; ++i) { + for (int j = 0; j < tmp[i].size( ); ++j) { + *js++ = tmp[i][j].first; + *s++ = tmp[i][j].second; } - if(!(*ptA->_vS)[k]) { - MatCreate(ptA->_A->getCommunicator(), &(*ptA->_vS)[k]); - MatSetSizes((*ptA->_vS)[k], end - start, end - start, global, global); - MatSetType((*ptA->_vS)[k], MATAIJ); - MatSeqAIJSetPreallocationCSR((*ptA->_vS)[k], reinterpret_cast(ia), reinterpret_cast(ja), c); - MatMPIAIJSetPreallocationCSR((*ptA->_vS)[k], reinterpret_cast(ia), reinterpret_cast(ja), c); - MatSetOption((*ptA->_vS)[k], MAT_NO_OFF_PROC_ENTRIES, PETSC_TRUE); + is[i + 1] = is[i] + tmp[i].size( ); + } + js -= nnz; + s -= nnz; + PetscInt *ia, *ja; + PetscScalar* c; + ia = ja = nullptr; + c = nullptr; + HPDDM::MatrixCSR< PetscScalar >* dN = new_HPDDM_MatrixCSR< PetscScalar >(mS, true, s, is, js); + bool free = dN ? ptA->_A->HPDDM::template Subdomain< PetscScalar >::distributedCSR(numSchur, start, end, ia, ja, c, dN) : false; + if (!ia && !ja && !c) { + ia = new PetscInt[2]( ); + free = true; + } + if (!(*ptA->_vS)[k]) { + MatCreate(ptA->_A->getCommunicator( ), &(*ptA->_vS)[k]); + MatSetSizes((*ptA->_vS)[k], end - start, end - start, global, global); + MatSetType((*ptA->_vS)[k], MATAIJ); + MatSeqAIJSetPreallocationCSR((*ptA->_vS)[k], reinterpret_cast< PetscInt* >(ia), reinterpret_cast< PetscInt* >(ja), c); + MatMPIAIJSetPreallocationCSR((*ptA->_vS)[k], reinterpret_cast< PetscInt* >(ia), reinterpret_cast< PetscInt* >(ja), c); + MatSetOption((*ptA->_vS)[k], MAT_NO_OFF_PROC_ENTRIES, PETSC_TRUE); + } else { + PetscBool update = (mS && ptA->_ksp ? PETSC_TRUE : PETSC_FALSE); + MPI_Allreduce(MPI_IN_PLACE, &update, 1, MPI_C_BOOL, MPI_MAX, ptA->_A->getCommunicator( )); + if (update) { + Mat S; + MatCreate(PetscObjectComm((PetscObject)ptA->_ksp), &S); + MatSetSizes(S, end - start, end - start, global, global); + MatSetType(S, MATAIJ); + MatSeqAIJSetPreallocationCSR(S, reinterpret_cast< PetscInt* >(ia), reinterpret_cast< PetscInt* >(ja), c); + MatMPIAIJSetPreallocationCSR(S, reinterpret_cast< PetscInt* >(ia), reinterpret_cast< PetscInt* >(ja), c); + MatDestroy(&((*ptA->_vS)[k])); + PetscInt nsplits; + KSP* subksp; + PC pc; + KSPGetPC(ptA->_ksp, &pc); + PCFieldSplitGetSubKSP(pc, &nsplits, &subksp); + PC pcS; + KSPGetPC(subksp[nsplits - 1], &pcS); + if (mT->n > 1) { + PC subpc; + PCCompositeGetPC(pcS, k, &subpc); + PCSetOperators(subpc, S, S); + } else { + PCSetOperators(pcS, S, S); + } + (*ptA->_vS)[k] = S; } - else { - PetscBool update = (mS && ptA->_ksp ? PETSC_TRUE : PETSC_FALSE); - MPI_Allreduce(MPI_IN_PLACE, &update, 1, MPI_C_BOOL, MPI_MAX, ptA->_A->getCommunicator()); - if(update) { - Mat S; - MatCreate(PetscObjectComm((PetscObject)ptA->_ksp), &S); - MatSetSizes(S, end - start, end - start, global, global); - MatSetType(S, MATAIJ); - MatSeqAIJSetPreallocationCSR(S, reinterpret_cast(ia), reinterpret_cast(ja), c); - MatMPIAIJSetPreallocationCSR(S, reinterpret_cast(ia), reinterpret_cast(ja), c); - MatDestroy(&((*ptA->_vS)[k])); - PetscInt nsplits; - KSP* subksp; - PC pc; - KSPGetPC(ptA->_ksp, &pc); - PCFieldSplitGetSubKSP(pc, &nsplits, &subksp); - PC pcS; - KSPGetPC(subksp[nsplits - 1], &pcS); - if (mT->n > 1) { - PC subpc; - PCCompositeGetPC(pcS, k, &subpc); - PCSetOperators(subpc, S, S); - } else { - PCSetOperators(pcS, S, S); - } - (*ptA->_vS)[k] = S; - } - } - if(free) { - delete [] ia; - delete [] ja; - delete [] c; - } - delete dN; + } + if (free) { + delete[] ia; + delete[] ja; + delete[] c; + } + delete dN; } - delete [] re; - ptA->_A->setBuffer(); -} -template>>::value>::type* = nullptr> -void setVectorSchur(Type* ptA, KN* const& mT, KN* const& pL) { + delete[] re; + ptA->_A->setBuffer( ); + } + template< class Type, class Tab, typename std::enable_if< std::is_same< Tab, PETSc::DistributedCSR< HpSchwarz< PetscScalar > > >::value >::type* = nullptr > + void setVectorSchur(Type* ptA, KN< Tab >* const& mT, KN< double >* const& pL) { assert(pL == nullptr); - for(int k = 0; k < mT->n; ++k) { - (*ptA->_vS)[k] = mT->operator[](k)._petsc; - PetscObjectReference((PetscObject)mT->operator[](k)._petsc); + for (int k = 0; k < mT->n; ++k) { + (*ptA->_vS)[k] = mT->operator[](k)._petsc; + PetscObjectReference((PetscObject)mT->operator[](k)._petsc); } -} -template -void setFieldSplitPC(Type* ptA, KSP ksp, KN* const& fields, KN* const& names, KN* const& mT, KN* const& pL = nullptr) { - if(fields) { - PC pc; - KSPGetPC(ksp, &pc); - PCSetType(pc, PCFIELDSPLIT); - PetscInt first = ptA->_first; - PetscInt last = ptA->_last; - if(!ptA->_num) { - Mat A; - KSPGetOperators(ksp, &A, NULL); - MatGetOwnershipRange(A, &first, &last); - } - unsigned short* local = new unsigned short[fields->n + last - first](); - for(int i = 0; i < fields->n; ++i) - local[i] = std::lround(fields->operator[](i)); - unsigned short nb = fields->n > 0 ? *std::max_element(local, local + fields->n) : 0; - MPI_Allreduce(MPI_IN_PLACE, &nb, 1, MPI_UNSIGNED_SHORT, MPI_MAX, PetscObjectComm((PetscObject)ksp)); - local += fields->n; - if(fields->n) { - if(ptA->_num) - HPDDM::Subdomain::template distributedVec<0>(ptA->_num, first, last, local - fields->n, local, static_cast(fields->n)); - else - std::copy_n(local - fields->n, fields->n, local); - } - unsigned long* counts = new unsigned long[nb](); - unsigned int remove = 0; - for(unsigned int i = 0; i < last - first; ++i) { - if(local[i]) - ++counts[local[i] - 1]; - else - ++remove; + } + template< class Type, class Tab > + void setFieldSplitPC(Type* ptA, KSP ksp, KN< double >* const& fields, KN< String >* const& names, KN< Tab >* const& mT, KN< double >* const& pL = nullptr) { + if (fields) { + PC pc; + KSPGetPC(ksp, &pc); + PCSetType(pc, PCFIELDSPLIT); + PetscInt first = ptA->_first; + PetscInt last = ptA->_last; + if (!ptA->_num) { + Mat A; + KSPGetOperators(ksp, &A, NULL); + MatGetOwnershipRange(A, &first, &last); + } + unsigned short* local = new unsigned short[fields->n + last - first]( ); + for (int i = 0; i < fields->n; ++i) local[i] = std::lround(fields->operator[](i)); + unsigned short nb = fields->n > 0 ? *std::max_element(local, local + fields->n) : 0; + MPI_Allreduce(MPI_IN_PLACE, &nb, 1, MPI_UNSIGNED_SHORT, MPI_MAX, PetscObjectComm((PetscObject)ksp)); + local += fields->n; + if (fields->n) { + if (ptA->_num) + HPDDM::Subdomain< PetscScalar >::template distributedVec< 0 >(ptA->_num, first, last, local - fields->n, local, static_cast< PetscInt >(fields->n)); + else + std::copy_n(local - fields->n, fields->n, local); + } + unsigned long* counts = new unsigned long[nb]( ); + unsigned int remove = 0; + for (unsigned int i = 0; i < last - first; ++i) { + if (local[i]) + ++counts[local[i] - 1]; + else + ++remove; + } + unsigned int firstFS = 0; + if (ptA->_ksp != ksp) { + MPI_Exscan(&remove, &firstFS, 1, MPI_UNSIGNED, MPI_SUM, PetscObjectComm((PetscObject)ksp)); + if (mpirank == 0) firstFS = 0; + } + PetscInt* idx = new PetscInt[*std::max_element(counts, counts + nb)]; + for (unsigned short j = 0; j < nb; ++j) { + IS is; + unsigned short* pt = local; + remove = firstFS; + for (unsigned int i = 0; i < counts[j]; ++pt) { + if (*pt == j + 1) + idx[i++] = first + std::distance(local, pt) - remove; + else if (*pt == 0) + ++remove; } - unsigned int firstFS = 0; - if(ptA->_ksp != ksp) { - MPI_Exscan(&remove, &firstFS, 1, MPI_UNSIGNED, MPI_SUM, PetscObjectComm((PetscObject)ksp)); - if(mpirank == 0) - firstFS = 0; + ISCreateGeneral(PetscObjectComm((PetscObject)ksp), counts[j], idx, PETSC_COPY_VALUES, &is); + PCFieldSplitSetIS(pc, names && j < names->size( ) ? (*(names->operator[](j))).c_str( ) : NULL, is); + ISDestroy(&is); + } + if (mT && mT->n > 0 && (pL || std::is_same< Tab, PETSc::DistributedCSR< HpSchwarz< PetscScalar > > >::value)) { + if (ptA->_vS) { + for (int i = 0; i < ptA->_vS->size( ); ++i) MatDestroy(&(*ptA->_vS)[i]); + delete ptA->_vS; + ptA->_vS = nullptr; } - PetscInt* idx = new PetscInt[*std::max_element(counts, counts + nb)]; - for(unsigned short j = 0; j < nb; ++j) { - IS is; - unsigned short* pt = local; - remove = firstFS; - for(unsigned int i = 0; i < counts[j]; ++pt) { - if(*pt == j + 1) - idx[i++] = first + std::distance(local, pt) - remove; - else if(*pt == 0) - ++remove; - } - ISCreateGeneral(PetscObjectComm((PetscObject)ksp), counts[j], idx, PETSC_COPY_VALUES, &is); - PCFieldSplitSetIS(pc, names && j < names->size() ? (*(names->operator[](j))).c_str() : NULL, is); - ISDestroy(&is); - } - if(mT && mT->n > 0 && (pL || std::is_same>>::value)) { - if(ptA->_vS) { - for(int i = 0; i < ptA->_vS->size(); ++i) - MatDestroy(&(*ptA->_vS)[i]); - delete ptA->_vS; - ptA->_vS = nullptr; - } - ptA->_vS = new std::vector(); - ptA->_vS->resize(mT->n); - setVectorSchur(ptA, mT, pL); - } - delete [] idx; - delete [] counts; - local -= fields->n; - delete [] local; + ptA->_vS = new std::vector< Mat >( ); + ptA->_vS->resize(mT->n); + setVectorSchur(ptA, mT, pL); + } + delete[] idx; + delete[] counts; + local -= fields->n; + delete[] local; } -} -void setCompositePC(PC pc, const std::vector* S) { - if(S && !S->empty()) { - PetscInt nsplits; - KSP* subksp; - PCFieldSplitGetSubKSP(pc, &nsplits, &subksp); - KSPSetOperators(subksp[nsplits - 1], (*S)[0], (*S)[0]); - if(S->size() == 1) { - IS is; - PCFieldSplitGetISByIndex(pc, nsplits - 1, &is); - PetscObjectCompose((PetscObject)is, "pmat", (PetscObject)(*S)[0]); - } - else { - PC pcS; - KSPGetPC(subksp[nsplits - 1], &pcS); - PCSetType(pcS, PCCOMPOSITE); - PetscInt j; - PCCompositeGetNumberPC(pcS, &j); - for(int i = j; i < S->size(); ++i) - PCCompositeAddPCType(pcS, PCNONE); - PCSetUp(pcS); - for(int i = 0; i < S->size(); ++i) { - PC subpc; - PCCompositeGetPC(pcS, i, &subpc); - PCSetOperators(subpc, (*S)[i], (*S)[i]); - PCSetFromOptions(subpc); - } + } + void setCompositePC(PC pc, const std::vector< Mat >* S) { + if (S && !S->empty( )) { + PetscInt nsplits; + KSP* subksp; + PCFieldSplitGetSubKSP(pc, &nsplits, &subksp); + KSPSetOperators(subksp[nsplits - 1], (*S)[0], (*S)[0]); + if (S->size( ) == 1) { + IS is; + PCFieldSplitGetISByIndex(pc, nsplits - 1, &is); + PetscObjectCompose((PetscObject)is, "pmat", (PetscObject)(*S)[0]); + } else { + PC pcS; + KSPGetPC(subksp[nsplits - 1], &pcS); + PCSetType(pcS, PCCOMPOSITE); + PetscInt j; + PCCompositeGetNumberPC(pcS, &j); + for (int i = j; i < S->size( ); ++i) PCCompositeAddPCType(pcS, PCNONE); + PCSetUp(pcS); + for (int i = 0; i < S->size( ); ++i) { + PC subpc; + PCCompositeGetPC(pcS, i, &subpc); + PCSetOperators(subpc, (*S)[i], (*S)[i]); + PCSetFromOptions(subpc); } - PetscFree(subksp); + } + PetscFree(subksp); } -} -} + } +} // namespace PETSc #endif diff --git a/plugin/mpi/RadiativeTransfer_htool.cpp b/plugin/mpi/RadiativeTransfer_htool.cpp index f372553ee..81395128c 100644 --- a/plugin/mpi/RadiativeTransfer_htool.cpp +++ b/plugin/mpi/RadiativeTransfer_htool.cpp @@ -1,373 +1,348 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: mpi pthread htool +/* clang-format on */ #include #include #include using namespace htool; -double dic = 0.03; // make dic=1 if kappa is constant to speed up +double dic = 0.03; // make dic=1 if kappa is constant to speed up class KappaGrid { -public: - KNMK * tab; + public: + KNMK< float > *tab; - int nx, ny, nz; - double xend, xstart; - double yend, ystart; - double zend, zstart; - double dx, dy, dz; + int nx, ny, nz; + double xend, xstart; + double yend, ystart; + double zend, zstart; + double dx, dy, dz; - void init() {tab = 0;} - void destroy() {delete tab;} + void init( ) { tab = 0; } + void destroy( ) { delete tab; } }; -KappaGrid *init_KappaGrid(Stack stack, KappaGrid *const &a, KN *const& bounds, double const& h, Expression kappa0) { - KN& bndsg = *bounds; - - int ixu = (int)ceil((bndsg[1]-bndsg[0])/h); - int iyu = (int)ceil((bndsg[3]-bndsg[2])/h); - int izu = (int)ceil((bndsg[5]-bndsg[4])/h); - - a->nx = ixu+1; - a->ny = iyu+1; - a->nz = izu+1; - - int sz = a->nx * a->ny * a->nz; - a->xstart = bndsg[0]; - a->xend = bndsg[0] + ixu*h; - a->dx = (a->xend - a->xstart)/(a->nx-1); - a->ystart = bndsg[2]; - a->yend = bndsg[2] + iyu*h; - a->dy = (a->yend - a->ystart)/(a->ny-1); - a->zstart = bndsg[4]; - a->zend = bndsg[4] + izu*h; - a->dz = (a->zend - a->zstart)/(a->nz-1); - - a->tab = new KNMK< float >(a->nx, a->ny, a->nz); - - MeshPoint* mp(Fem2D::MeshPointStack(stack)); - - int ix, iy, iz; - double xs, ys, zs; - for (iy = 0; iy < a->ny; iy++) { - ys = a->ystart + a->dy * iy; - for (ix = 0; ix < a->nx; ix++) { - xs = a->xstart + a->dx * ix; - for (iz = 0; iz < a->nz; iz++) { - zs = a->zstart + a->dz * iz; - mp->set(xs, ys, zs); - (*a->tab)(ix, iy, iz) = GetAny( (*kappa0)(stack) ); - } - } +KappaGrid *init_KappaGrid(Stack stack, KappaGrid *const &a, KN< double > *const &bounds, double const &h, Expression kappa0) { + KN< double > &bndsg = *bounds; + + int ixu = (int)ceil((bndsg[1] - bndsg[0]) / h); + int iyu = (int)ceil((bndsg[3] - bndsg[2]) / h); + int izu = (int)ceil((bndsg[5] - bndsg[4]) / h); + + a->nx = ixu + 1; + a->ny = iyu + 1; + a->nz = izu + 1; + + int sz = a->nx * a->ny * a->nz; + a->xstart = bndsg[0]; + a->xend = bndsg[0] + ixu * h; + a->dx = (a->xend - a->xstart) / (a->nx - 1); + a->ystart = bndsg[2]; + a->yend = bndsg[2] + iyu * h; + a->dy = (a->yend - a->ystart) / (a->ny - 1); + a->zstart = bndsg[4]; + a->zend = bndsg[4] + izu * h; + a->dz = (a->zend - a->zstart) / (a->nz - 1); + + a->tab = new KNMK< float >(a->nx, a->ny, a->nz); + + MeshPoint *mp(Fem2D::MeshPointStack(stack)); + + int ix, iy, iz; + double xs, ys, zs; + for (iy = 0; iy < a->ny; iy++) { + ys = a->ystart + a->dy * iy; + for (ix = 0; ix < a->nx; ix++) { + xs = a->xstart + a->dx * ix; + for (iz = 0; iz < a->nz; iz++) { + zs = a->zstart + a->dz * iz; + mp->set(xs, ys, zs); + (*a->tab)(ix, iy, iz) = GetAny< double >((*kappa0)(stack)); + } } + } - return a; + return a; } double KappaGrid_eval(KappaGrid *const &a, const double &xi, const double &yi, const double &zi) { - int ix = (a->nx-1) * (xi - a->xstart + a->dx/2) / (a->xend - a->xstart); - int iy = (a->ny-1) * (yi - a->ystart + a->dy/2) / (a->yend - a->ystart); - int iz = (a->nz-1) * (zi - a->zstart + a->dz/2) / (a->zend - a->zstart); - ix = max(0, min(ix, a->nx - 1)); - iy = max(0, min(iy, a->ny - 1)); - iz = max(0, min(iz, a->nz - 1)); - - return (*a->tab)(ix, iy, iz); + int ix = (a->nx - 1) * (xi - a->xstart + a->dx / 2) / (a->xend - a->xstart); + int iy = (a->ny - 1) * (yi - a->ystart + a->dy / 2) / (a->yend - a->ystart); + int iz = (a->nz - 1) * (zi - a->zstart + a->dz / 2) / (a->zend - a->zstart); + ix = max(0, min(ix, a->nx - 1)); + iy = max(0, min(iy, a->ny - 1)); + iz = max(0, min(iz, a->nz - 1)); + + return (*a->tab)(ix, iy, iz); } //////////////////////////// used for the volume integral //////////////////////////// -class Generator_Volume: public VirtualGenerator{ -public: - const Mesh3& Th; - KN heade,nexte; - KappaGrid* kappa0; - - typedef SortArray SortArray2; - mutable HashTable edges; - const int e2[10][2] = {{ 0,0},{ 0,1},{ 0,2},{ 0,3}, {1,1}, {1,2}, {1,3}, {2,2},{2,3}, {3,3}}; - - Generator_Volume(pmesh3 pth3, KappaGrid* k): - VirtualGenerator(), Th(*pth3), kappa0(k), - edges(pth3->nt*3+pth3->nv,pth3->nv), heade(), nexte(pth3->nt*10) { - // pour i,j -> liste de tet de sommet i,j - // i,j -> liste des tet contenant i et j ?? - // k, e -> i,j -> numero d'arete - // inverse tableau i,j -> e -> - int ne=0; - for(int k=0; kCastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3])); // extend - } - OneOperator3es_(func ff) : // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()]), // extend - f(ff) {} +template< class R, class A = R, class B = A, class C = B, class D = C, class CODE = E_F_F0F0F0es_< R, A, B, C, D, E_F0 > > +class OneOperator3es_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError("They are used Named parameter"); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), + t[3]->CastTo(args[3])); // extend + } + OneOperator3es_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], + map_type[typeid(D).name( )]), // extend + f(ff) {} }; -double Bnu(double nu, double T) { - return nu*nu*nu/(exp(nu/T)-1); -} +double Bnu(double nu, double T) { return nu * nu * nu / (exp(nu / T) - 1); } -static void Init_RT() { - Global.Add("Bnu","(",new OneOperator2(Bnu)); +static void Init_RT( ) { + Global.Add("Bnu", "(", new OneOperator2< double >(Bnu)); - Dcl_Type< KappaGrid * >(InitP< KappaGrid >, Destroy< KappaGrid >); - zzzfff->Add("KappaGrid", atype< KappaGrid * >( )); + Dcl_Type< KappaGrid * >(InitP< KappaGrid >, Destroy< KappaGrid >); + zzzfff->Add("KappaGrid", atype< KappaGrid * >( )); - TheOperators->Add("<-", new OneOperator3_ **, VirtualGenerator **, - pmesh3, KappaGrid *>(init_Generator_Volume)); - TheOperators->Add("<-", new OneOperator5_ **, VirtualGenerator **, - pmesh3, pmeshS, KN*, KappaGrid *>(init_Generator_Boundary)); + TheOperators->Add("<-", new OneOperator3_< VirtualGenerator< double > **, VirtualGenerator< double > **, pmesh3, KappaGrid * >(init_Generator_Volume)); + TheOperators->Add("<-", new OneOperator5_< VirtualGenerator< double > **, VirtualGenerator< double > **, pmesh3, pmeshS, KN< double > *, KappaGrid * >(init_Generator_Boundary)); - TheOperators->Add( - "<-", new OneOperator3es_*, double, double>(init_KappaGrid)); - atype< KappaGrid * >()->Add( - "(", "", new OneOperator4_(KappaGrid_eval)); + TheOperators->Add("<-", new OneOperator3es_< KappaGrid *, KappaGrid *, KN< double > *, double, double >(init_KappaGrid)); + atype< KappaGrid * >( )->Add("(", "", new OneOperator4_< double, KappaGrid *, double, double, double >(KappaGrid_eval)); } LOADFUNC(Init_RT) diff --git a/plugin/mpi/SLEPc-code.hpp b/plugin/mpi/SLEPc-code.hpp index 8f48aa8d2..384af2523 100644 --- a/plugin/mpi/SLEPc-code.hpp +++ b/plugin/mpi/SLEPc-code.hpp @@ -12,662 +12,611 @@ #include "slepc.h" namespace SLEPc { -template -struct _m_User; -template -struct _n_User; -template -using User = typename std::conditional::value, _n_User*, _m_User*>::type; -template -static PetscErrorCode MatMult_User(Mat A, Vec x, Vec y); -template::value || !std::is_same::value>::type* = nullptr> -void copy(K* pt, PetscInt n, PetscScalar* xr, PetscScalar* xi) { } -template::value && std::is_same::value>::type* = nullptr> -void copy(K* pt, PetscInt n, PetscScalar* xr, PetscScalar* xi) { - for(int i = 0; i < n; ++i) - pt[i] = K(xr[i], xi[i]); -} -template::value && (std::is_same::value || !std::is_same::value)>::type* = nullptr> -void assign(K* pt, PetscScalar& kr, PetscScalar& ki) { + template< class Type, class K > + struct _m_User; + template< class Type, class K, class SType > + struct _n_User; + template< class Type, class K, class SType > + using User = typename std::conditional< !std::is_same< SType, NEP >::value, _n_User< Type, K, SType >*, _m_User< Type, K >* >::type; + template< class Type, class K, class SType > + static PetscErrorCode MatMult_User(Mat A, Vec x, Vec y); + template< class K, typename std::enable_if< std::is_same< K, double >::value || !std::is_same< PetscScalar, double >::value >::type* = nullptr > + void copy(K* pt, PetscInt n, PetscScalar* xr, PetscScalar* xi) {} + template< class K, typename std::enable_if< !std::is_same< K, double >::value && std::is_same< PetscScalar, double >::value >::type* = nullptr > + void copy(K* pt, PetscInt n, PetscScalar* xr, PetscScalar* xi) { + for (int i = 0; i < n; ++i) pt[i] = K(xr[i], xi[i]); + } + template< class SType, class K, typename std::enable_if< !std::is_same< SType, SVD >::value && (std::is_same< K, double >::value || !std::is_same< PetscScalar, double >::value) >::type* = nullptr > + void assign(K* pt, PetscScalar& kr, PetscScalar& ki) { *pt = kr; -} -template::value && (!std::is_same::value && std::is_same::value)>::type* = nullptr> -void assign(K* pt, PetscScalar& kr, PetscScalar& ki) { + } + template< class SType, class K, typename std::enable_if< !std::is_same< SType, SVD >::value && (!std::is_same< K, double >::value && std::is_same< PetscScalar, double >::value) >::type* = nullptr > + void assign(K* pt, PetscScalar& kr, PetscScalar& ki) { *pt = K(kr, ki); -} -template::value>::type* = nullptr> -void assign(K* pt, PetscScalar& kr, PetscScalar& ki) { } -template::value && std::is_same>::value)>::type* = nullptr> -void distributedVec(PetscInt* num, PetscInt first, PetscInt last, K* const in, PetscScalar* pt, PetscInt n) { } -template::value && std::is_same>::value)>::type* = nullptr> -void distributedVec(PetscInt* num, PetscInt first, PetscInt last, K* const in, PetscScalar* pt, PetscInt n) { - HPDDM::Subdomain::template distributedVec<0>(num, first, last, in, pt, n, 1); -} -template -class eigensolver : public OneOperator { - public: - typedef KN Kn; - typedef KN_ Kn_; - class MatF_O : public RNM_VirtualMatrix { - public: - Stack stack; - mutable Kn x; - C_F0 c_x; - Expression mat; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - MatF_O(int n, Stack stk, const OneOperator* op) : - RNM_VirtualMatrix(n), stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) { } - ~MatF_O() { - delete mat; - Expression zzz = c_x; - delete zzz; - } - void addMatMul(const Kn_& xx, Kn_& Ax) const { - ffassert(xx.N() == Ax.N()); - x = xx; - Ax += GetAny((*mat)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - } - plusAx operator*(const Kn& x) const { return plusAx(this, x); } - }; - class ScalarF_O { - public: - Stack stack; - mutable PetscScalar x; - C_F0 c_x; - Expression mat; - ScalarF_O(Stack stk, const OneOperator* op) - : stack(stk), x(0), c_x(CPValue(x)), - mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} - ~ScalarF_O( ) { - delete mat; - Expression zzz = c_x; - delete zzz; - } - long apply(const PetscScalar xx, int* f) const { - x = xx; - ffassert(mat); - int ret = GetAny< int >((*mat)(stack)); - *f = ret; - WhereStackOfPtr2Free(stack)->clean( ); - return 0; - } - }; - const int c; - class E_eigensolver : public E_F0mps { - public: - Expression A; - Expression B; - const OneOperator* codeA, *codeB; - const int c; - static const int n_name_param = 13; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - E_eigensolver(const basicAC_F0& args, int d) : A(0), B(0), codeA(0), codeB(0), c(d) { - args.SetNameParam(n_name_param, name_param, nargs); - if(c != 4) { - A = to(args[0]); - if(c == 1 || c == 3) { - const Polymorphic* op = dynamic_cast(args[1].LeftValue()); - ffassert(op); - if(c == 3) { - codeA = op->Find("(", ArrayOfaType(atype(), false)); - ffassert(codeA); - B = to(args[2]); - op = dynamic_cast(args[3].LeftValue()); - ffassert(op); - codeB = op->Find("(", ArrayOfaType(atype(), false)); - ffassert(codeB); - } - else - codeA = op->Find("(", ArrayOfaType(atype*>(), false)); - } - else if(c == 0) { - B = to(args[1]); - } - } - else { - A = to*>(args[0]); - } - } + } + template< class SType, class K, typename std::enable_if< std::is_same< SType, SVD >::value >::type* = nullptr > + void assign(K* pt, PetscScalar& kr, PetscScalar& ki) {} + template< class K, typename std::enable_if< (std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value) >::type* = nullptr > + void distributedVec(PetscInt* num, PetscInt first, PetscInt last, K* const in, PetscScalar* pt, PetscInt n) {} + template< class K, typename std::enable_if< !(std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value) >::type* = nullptr > + void distributedVec(PetscInt* num, PetscInt first, PetscInt last, K* const in, PetscScalar* pt, PetscInt n) { + HPDDM::Subdomain< K >::template distributedVec< 0 >(num, first, last, in, pt, n, 1); + } + template< class Type, class K, class SType > + class eigensolver : public OneOperator { + public: + typedef KN< PetscScalar > Kn; + typedef KN_< PetscScalar > Kn_; + class MatF_O : public RNM_VirtualMatrix< PetscScalar > { + public: + Stack stack; + mutable Kn x; + C_F0 c_x; + Expression mat; + typedef typename RNM_VirtualMatrix< PetscScalar >::plusAx plusAx; + MatF_O(int n, Stack stk, const OneOperator* op) + : RNM_VirtualMatrix< PetscScalar >(n), stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + ~MatF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + } + void addMatMul(const Kn_& xx, Kn_& Ax) const { + ffassert(xx.N( ) == Ax.N( )); + x = xx; + Ax += GetAny< Kn_ >((*mat)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + } + plusAx operator*(const Kn& x) const { return plusAx(this, x); } + }; + class ScalarF_O { + public: + Stack stack; + mutable PetscScalar x; + C_F0 c_x; + Expression mat; + ScalarF_O(Stack stk, const OneOperator* op) : stack(stk), x(0), c_x(CPValue(x)), mat(op ? CastTo< long >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + ~ScalarF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + } + long apply(const PetscScalar xx, int* f) const { + x = xx; + ffassert(mat); + int ret = GetAny< int >((*mat)(stack)); + *f = ret; + WhereStackOfPtr2Free(stack)->clean( ); + return 0; + } + }; + const int c; + class E_eigensolver : public E_F0mps { + public: + Expression A; + Expression B; + const OneOperator *codeA, *codeB; + const int c; + static const int n_name_param = 13; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + E_eigensolver(const basicAC_F0& args, int d) : A(0), B(0), codeA(0), codeB(0), c(d) { + args.SetNameParam(n_name_param, name_param, nargs); + if (c != 4) { + A = to< Type* >(args[0]); + if (c == 1 || c == 3) { + const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[1].LeftValue( )); + ffassert(op); + if (c == 3) { + codeA = op->Find("(", ArrayOfaType(atype< PetscScalar >( ), false)); + ffassert(codeA); + B = to< Type* >(args[2]); + op = dynamic_cast< const Polymorphic* >(args[3].LeftValue( )); + ffassert(op); + codeB = op->Find("(", ArrayOfaType(atype< PetscScalar >( ), false)); + ffassert(codeB); + } else + codeA = op->Find("(", ArrayOfaType(atype< KN< PetscScalar >* >( ), false)); + } else if (c == 0) { + B = to< Type* >(args[1]); + } + } else { + A = to< KN< Type >* >(args[0]); + } + } - AnyType operator()(Stack stack) const; - operator aType() const { return atype(); } - }; - E_F0* code(const basicAC_F0 & args) const { return new E_eigensolver(args, c); } - eigensolver() : OneOperator(atype(), atype(), atype()), c(0) { } - eigensolver(int) : OneOperator(atype(), atype(), atype()), c(1) { } - eigensolver(int, int) : OneOperator(atype(), atype()), c(2) { } - eigensolver(int, int, int) : OneOperator(atype(), atype(), atype(), atype(), atype()), c(3) { } - eigensolver(int, int, int, int) : OneOperator(atype(), atype*>()), c(4) { } -}; -template -basicAC_F0::name_and_type eigensolver::E_eigensolver::name_param[] = { + AnyType operator( )(Stack stack) const; + operator aType( ) const { return atype< long >( ); } + }; + E_F0* code(const basicAC_F0& args) const { return new E_eigensolver(args, c); } + eigensolver( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Type* >( )), c(0) {} + eigensolver(int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( )), c(1) {} + eigensolver(int, int) : OneOperator(atype< long >( ), atype< Type* >( )), c(2) {} + eigensolver(int, int, int) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Polymorphic* >( ), atype< Type* >( ), atype< Polymorphic* >( )), c(3) {} + eigensolver(int, int, int, int) : OneOperator(atype< long >( ), atype< KN< Type >* >( )), c(4) {} + }; + template< class Type, class K, class SType > + basicAC_F0::name_and_type eigensolver< Type, K, SType >::E_eigensolver::name_param[] = { {"sparams", &typeid(std::string*)}, {"prefix", &typeid(std::string*)}, - {"values", &typeid(KN::value, K, PetscReal>::type>*)}, - {!std::is_same::value ? "vectors" : "lvectors", &typeid(FEbaseArrayKn*)}, - {!std::is_same::value ? "array" : "larray", &typeid(KNM*)}, - {"fields", &typeid(KN*)}, - {"names", &typeid(KN*)}, - {!std::is_same::value ? "lvectors" : "rvectors", &typeid(FEbaseArrayKn*)}, - {!std::is_same::value ? "larray" : "rarray", &typeid(KNM*)}, - {"deflation", &typeid(KNM*)}, - {"errorestimate", &typeid(KN*)}, - {"schurPreconditioner", &typeid(KN>>*)}, - {"schurList", &typeid(KN*)}, -}; -template -struct _n_User { - typename eigensolver::MatF_O* mat; -}; -template -struct _m_User { - typename eigensolver::ScalarF_O* F; - typename eigensolver::ScalarF_O* J; -}; -PetscErrorCode FormFun(NEP nep, PetscScalar lambda, Mat F, Mat P, void* ctx) { - User>, PetscScalar, NEP>* user; + {"values", &typeid(KN< typename std::conditional< !std::is_same< SType, SVD >::value, K, PetscReal >::type >*)}, + {!std::is_same< SType, SVD >::value ? "vectors" : "lvectors", &typeid(FEbaseArrayKn< K >*)}, + {!std::is_same< SType, SVD >::value ? "array" : "larray", &typeid(KNM< K >*)}, + {"fields", &typeid(KN< double >*)}, + {"names", &typeid(KN< String >*)}, + {!std::is_same< SType, SVD >::value ? "lvectors" : "rvectors", &typeid(FEbaseArrayKn< K >*)}, + {!std::is_same< SType, SVD >::value ? "larray" : "rarray", &typeid(KNM< K >*)}, + {"deflation", &typeid(KNM< PetscScalar >*)}, + {"errorestimate", &typeid(KN< PetscReal >*)}, + {"schurPreconditioner", &typeid(KN< Matrice_Creuse< upscaled_type< PetscScalar > > >*)}, + {"schurList", &typeid(KN< double >*)}, + }; + template< class Type, class K, class SType > + struct _n_User { + typename eigensolver< Type, K, SType >::MatF_O* mat; + }; + template< class Type, class K > + struct _m_User { + typename eigensolver< Type, K, NEP >::ScalarF_O* F; + typename eigensolver< Type, K, NEP >::ScalarF_O* J; + }; + PetscErrorCode FormFun(NEP nep, PetscScalar lambda, Mat F, Mat P, void* ctx) { + User< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >* user; PetscFunctionBeginUser; - user = reinterpret_cast< User< PETSc::DistributedCSR>, PetscScalar, NEP >* >(ctx); - typename eigensolver>, PetscScalar, NEP>::ScalarF_O* f = - reinterpret_cast< typename eigensolver>, PetscScalar, NEP>::ScalarF_O* >((*user)->F); + user = reinterpret_cast< User< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >* >(ctx); + typename eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >::ScalarF_O* f = + reinterpret_cast< typename eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >::ScalarF_O* >((*user)->F); int ret; f->apply(lambda, &ret); PetscFunctionReturn(PetscErrorCode(ret)); -} -PetscErrorCode FormJac(NEP nep, PetscScalar lambda, Mat J, void* ctx) { - User>, PetscScalar, NEP>* user; + } + PetscErrorCode FormJac(NEP nep, PetscScalar lambda, Mat J, void* ctx) { + User< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >* user; PetscFunctionBeginUser; - user = reinterpret_cast< User< PETSc::DistributedCSR>, PetscScalar, NEP >* >(ctx); - typename eigensolver>, PetscScalar, NEP>::ScalarF_O* f = - reinterpret_cast< typename eigensolver>, PetscScalar, NEP>::ScalarF_O* >((*user)->J); + user = reinterpret_cast< User< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >* >(ctx); + typename eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >::ScalarF_O* f = + reinterpret_cast< typename eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >::ScalarF_O* >((*user)->J); int ret; f->apply(lambda, &ret); PetscFunctionReturn(PetscErrorCode(ret)); -} -template -AnyType eigensolver::E_eigensolver::operator()(Stack stack) const { - if(A && (c == 2 || c == 4 || B || codeA)) { - KN* ptTab; - Type* ptA; - if(c != 4) - ptA = GetAny((*A)(stack)); - else { - ptTab = GetAny*>((*A)(stack)); - ffassert(ptTab && ptTab->N()); - ptA = &(ptTab->operator[](0)); + } + template< class Type, class K, class SType > + AnyType eigensolver< Type, K, SType >::E_eigensolver::operator( )(Stack stack) const { + if (A && (c == 2 || c == 4 || B || codeA)) { + KN< Type >* ptTab; + Type* ptA; + if (c != 4) + ptA = GetAny< Type* >((*A)(stack)); + else { + ptTab = GetAny< KN< Type >* >((*A)(stack)); + ffassert(ptTab && ptTab->N( )); + ptA = &(ptTab->operator[](0)); + } + if (ptA->_petsc) { + EPS eps; + SVD svd; + NEP nep; + PEP pep; + if (std::is_same< SType, EPS >::value) + EPSCreate(PetscObjectComm((PetscObject)ptA->_petsc), &eps); + else if (std::is_same< SType, SVD >::value) + SVDCreate(PetscObjectComm((PetscObject)ptA->_petsc), &svd); + else if (std::is_same< SType, NEP >::value) + NEPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &nep); + else + PEPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &pep); + Mat S; + User< Type, K, typename std::conditional< std::is_same< SType, NEP >::value, EPS, SType >::type > user = nullptr; + User< Type, K, NEP > func = nullptr; + MatType type; + PetscBool isType; + PetscBool isTwoSided; + MatGetType(ptA->_petsc, &type); + PetscStrcmp(type, MATNEST, &isType); + PetscInt m; + MatGetLocalSize(ptA->_petsc, &m, NULL); + if (!codeA) { + Type* ptB = (c == 0 ? GetAny< Type* >((*B)(stack)) : NULL); + if (std::is_same< SType, EPS >::value) + EPSSetOperators(eps, ptA->_petsc, c == 0 && ptB ? ptB->_petsc : NULL); + else if (std::is_same< SType, SVD >::value) + SVDSetOperators(svd, ptA->_petsc, NULL); + else if (std::is_same< SType, PEP >::value) { + Mat* tab = new Mat[ptTab->N( )]; + for (int i = 0; i < ptTab->N( ); ++i) tab[i] = ptTab->operator[](i)._petsc; + PEPSetOperators(pep, ptTab->N( ), tab); + delete[] tab; + } + } else { + PetscInt M; + MatGetSize(ptA->_petsc, &M, NULL); + if (!std::is_same< SType, NEP >::value) { + PetscNew(&user); + user->mat = new typename eigensolver< Type, K, typename std::conditional< std::is_same< SType, NEP >::value, EPS, SType >::type >::MatF_O(m, stack, codeA); + MatCreateShell(PetscObjectComm((PetscObject)ptA->_petsc), m, m, M, M, user, &S); + MatShellSetOperation(S, MATOP_MULT, (PetscErrorCodeFn*)MatMult_User< Type, K, typename std::conditional< std::is_same< SType, NEP >::value, EPS, SType >::type >); + if (std::is_same< SType, EPS >::value) + EPSSetOperators(eps, S, NULL); + else if (std::is_same< SType, SVD >::value) + SVDSetOperators(svd, S, NULL); + } else { + Type* ptB = GetAny< Type* >((*B)(stack)); + PetscNew(&func); + func->F = new typename eigensolver< Type, K, NEP >::ScalarF_O(stack, codeA); + func->J = new typename eigensolver< Type, K, NEP >::ScalarF_O(stack, codeB); + NEPSetFunction(nep, ptA->_petsc, ptA->_petsc, FormFun, &func); + NEPSetJacobian(nep, ptB->_petsc, FormJac, &func); + } } - if(ptA->_petsc) { - EPS eps; - SVD svd; - NEP nep; - PEP pep; - if(std::is_same::value) - EPSCreate(PetscObjectComm((PetscObject)ptA->_petsc), &eps); - else if(std::is_same::value) - SVDCreate(PetscObjectComm((PetscObject)ptA->_petsc), &svd); - else if(std::is_same::value) - NEPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &nep); - else - PEPCreate(PetscObjectComm((PetscObject)ptA->_petsc), &pep); - Mat S; - User::value, EPS, SType>::type> user = nullptr; - User func = nullptr; - MatType type; - PetscBool isType; - PetscBool isTwoSided; - MatGetType(ptA->_petsc, &type); - PetscStrcmp(type, MATNEST, &isType); - PetscInt m; - MatGetLocalSize(ptA->_petsc, &m, NULL); - if(!codeA) { - Type* ptB = (c == 0 ? GetAny((*B)(stack)) : NULL); - if(std::is_same::value) - EPSSetOperators(eps, ptA->_petsc, c == 0 && ptB ? ptB->_petsc : NULL); - else if(std::is_same::value) - SVDSetOperators(svd, ptA->_petsc, NULL); - else if(std::is_same::value) { - Mat* tab = new Mat[ptTab->N()]; - for(int i = 0; i < ptTab->N(); ++i) - tab[i] = ptTab->operator[](i)._petsc; - PEPSetOperators(pep, ptTab->N(), tab); - delete [] tab; - } - } - else { - PetscInt M; - MatGetSize(ptA->_petsc, &M, NULL); - if(!std::is_same::value) { - PetscNew(&user); - user->mat = new typename eigensolver::value, EPS, SType>::type>::MatF_O(m, stack, codeA); - MatCreateShell(PetscObjectComm((PetscObject)ptA->_petsc), m, m, M, M, user, &S); - MatShellSetOperation(S, MATOP_MULT, (PetscErrorCodeFn *)MatMult_User::value, EPS, SType>::type>); - if(std::is_same::value) - EPSSetOperators(eps, S, NULL); - else if(std::is_same::value) - SVDSetOperators(svd, S, NULL); - } - else { - Type* ptB = GetAny((*B)(stack)); - PetscNew(&func); - func->F = new typename eigensolver::ScalarF_O(stack, codeA); - func->J = new typename eigensolver::ScalarF_O(stack, codeB); - NEPSetFunction(nep, ptA->_petsc, ptA->_petsc, FormFun, &func); - NEPSetJacobian(nep, ptB->_petsc, FormJac, &func); - } - } - if (nargs[0]) { - std::string* options = GetAny< std::string* >((*nargs[0])(stack)); - PetscOptionsInsertString(NULL, options->c_str()); - } - if(nargs[1]) { - if(std::is_same::value) - EPSSetOptionsPrefix(eps, GetAny((*nargs[1])(stack))->c_str()); - else if(std::is_same::value) - SVDSetOptionsPrefix(svd, GetAny((*nargs[1])(stack))->c_str()); - else if(std::is_same::value) - NEPSetOptionsPrefix(nep, GetAny((*nargs[1])(stack))->c_str()); - else - PEPSetOptionsPrefix(pep, GetAny((*nargs[1])(stack))->c_str()); - } - KSP empty = NULL; - if(std::is_same::value) { - EPSSetFromOptions(eps); - ST st; - EPSGetST(eps, &st); - if(ptA->_ksp) { - STGetKSP(st, &empty); - PetscObjectReference((PetscObject)empty); - STSetKSP(st, ptA->_ksp); - } - else { - KSP ksp; - PC pc; - STGetKSP(st, &ksp); - KSPGetPC(ksp, &pc); - PCSetFromOptions(pc); - PCType type; - PCGetType(pc, &type); - PetscBool isFieldSplit; - PetscStrcmp(type, PCFIELDSPLIT, &isFieldSplit); - if(isFieldSplit) { - KN* fields = nargs[5] ? GetAny*>((*nargs[5])(stack)) : 0; - KN* names = nargs[6] ? GetAny*>((*nargs[6])(stack)) : 0; - KN>>* mS = nargs[11] ? GetAny>>*>((*nargs[11])(stack)) : 0; - KN* pL = nargs[12] ? GetAny*>((*nargs[12])(stack)) : 0; - STGetKSP(st, &ksp); - KSPSetOperators(ksp, ptA->_petsc, ptA->_petsc); - setFieldSplitPC(ptA, ksp, fields, names, mS, pL); - EPSSetUp(eps); - if(ptA->_vS && !ptA->_vS->empty()) { - PC pc; - KSPGetPC(ksp, &pc); - PCSetUp(pc); - PETSc::setCompositePC(pc, ptA->_vS); - } - } - } + if (nargs[0]) { + std::string* options = GetAny< std::string* >((*nargs[0])(stack)); + PetscOptionsInsertString(NULL, options->c_str( )); + } + if (nargs[1]) { + if (std::is_same< SType, EPS >::value) + EPSSetOptionsPrefix(eps, GetAny< std::string* >((*nargs[1])(stack))->c_str( )); + else if (std::is_same< SType, SVD >::value) + SVDSetOptionsPrefix(svd, GetAny< std::string* >((*nargs[1])(stack))->c_str( )); + else if (std::is_same< SType, NEP >::value) + NEPSetOptionsPrefix(nep, GetAny< std::string* >((*nargs[1])(stack))->c_str( )); + else + PEPSetOptionsPrefix(pep, GetAny< std::string* >((*nargs[1])(stack))->c_str( )); + } + KSP empty = NULL; + if (std::is_same< SType, EPS >::value) { + EPSSetFromOptions(eps); + ST st; + EPSGetST(eps, &st); + if (ptA->_ksp) { + STGetKSP(st, &empty); + PetscObjectReference((PetscObject)empty); + STSetKSP(st, ptA->_ksp); + } else { + KSP ksp; + PC pc; + STGetKSP(st, &ksp); + KSPGetPC(ksp, &pc); + PCSetFromOptions(pc); + PCType type; + PCGetType(pc, &type); + PetscBool isFieldSplit; + PetscStrcmp(type, PCFIELDSPLIT, &isFieldSplit); + if (isFieldSplit) { + KN< double >* fields = nargs[5] ? GetAny< KN< double >* >((*nargs[5])(stack)) : 0; + KN< String >* names = nargs[6] ? GetAny< KN< String >* >((*nargs[6])(stack)) : 0; + KN< Matrice_Creuse< upscaled_type< PetscScalar > > >* mS = nargs[11] ? GetAny< KN< Matrice_Creuse< upscaled_type< PetscScalar > > >* >((*nargs[11])(stack)) : 0; + KN< double >* pL = nargs[12] ? GetAny< KN< double >* >((*nargs[12])(stack)) : 0; + STGetKSP(st, &ksp); + KSPSetOperators(ksp, ptA->_petsc, ptA->_petsc); + setFieldSplitPC(ptA, ksp, fields, names, mS, pL); + EPSSetUp(eps); + if (ptA->_vS && !ptA->_vS->empty( )) { + PC pc; + KSPGetPC(ksp, &pc); + PCSetUp(pc); + PETSc::setCompositePC(pc, ptA->_vS); + } } - else if(std::is_same::value) { - SVDSetFromOptions(svd); - SVDSetUp(svd); + } + } else if (std::is_same< SType, SVD >::value) { + SVDSetFromOptions(svd); + SVDSetUp(svd); + } else if (std::is_same< SType, NEP >::value) { + NEPSetFromOptions(nep); + NEPSetUp(nep); + } else { + PEPSetFromOptions(pep); + PEPSetUp(pep); + } + FEbaseArrayKn< K >* eigenvectors = nargs[3] ? GetAny< FEbaseArrayKn< K >* >((*nargs[3])(stack)) : nullptr; + Vec* basis = nullptr; + PetscInt n = 0; + if (eigenvectors) { + ffassert(!isType); + if (eigenvectors->N > 0 && eigenvectors->get(0) && eigenvectors->get(0)->n > 0) { + n = eigenvectors->N; + basis = new Vec[n]; + for (int i = 0; i < n; ++i) { + MatCreateVecs(ptA->_petsc, &basis[i], NULL); + PetscScalar* pt; + VecGetArray(basis[i], &pt); + if (!(std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value)) + distributedVec(ptA->_num, ptA->_first, ptA->_last, static_cast< K* >(*(eigenvectors->get(i))), pt, eigenvectors->get(i)->n); + VecRestoreArray(basis[i], &pt); } - else if(std::is_same::value) { - NEPSetFromOptions(nep); - NEPSetUp(nep); + } + eigenvectors->resize(0); + } + FEbaseArrayKn< K >* othervectors = nargs[7] ? GetAny< FEbaseArrayKn< K >* >((*nargs[7])(stack)) : nullptr; + Vec* otherbasis = nullptr; + PetscInt othern = 0; + if (othervectors) { + ffassert(!isType); + if (othervectors->N > 0 && othervectors->get(0) && othervectors->get(0)->n > 0) { + othern = othervectors->N; + otherbasis = new Vec[othern]; + for (int i = 0; i < othern; ++i) { + MatCreateVecs(ptA->_petsc, &otherbasis[i], NULL); + PetscScalar* pt; + VecGetArray(otherbasis[i], &pt); + if (!(std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value)) + distributedVec(ptA->_num, ptA->_first, ptA->_last, static_cast< K* >(*(othervectors->get(i))), pt, othervectors->get(i)->n); + VecRestoreArray(otherbasis[i], &pt); } - else { - PEPSetFromOptions(pep); - PEPSetUp(pep); + } + othervectors->resize(0); + } + if (std::is_same< SType, EPS >::value) { + EPSGetTwoSided(eps, &isTwoSided); + if (n) EPSSetInitialSpace(eps, n, basis); + if (othern && isTwoSided) EPSSetLeftInitialSpace(eps, othern, otherbasis); + KNM< PetscScalar >* ptDeflation = nargs[9] ? GetAny< KNM< PetscScalar >* >((*nargs[9])(stack)) : NULL; + if (ptDeflation && ptDeflation->M( )) { + PetscInt m; + MatGetLocalSize(ptA->_petsc, &m, NULL); + ffassert(m == ptDeflation->N( )); + Vec* deflation = new Vec[ptDeflation->M( )]; + for (int i = 0; i < ptDeflation->M( ); ++i) + VecCreateMPIWithArray(PetscObjectComm((PetscObject)ptA->_petsc), 1, ptDeflation->N( ), PETSC_DECIDE, &ptDeflation->operator( )(0, i), deflation + i); + EPSSetDeflationSpace(eps, ptDeflation->M( ), deflation); + for (int i = 0; i < ptDeflation->M( ); ++i) VecDestroy(deflation + i); + delete[] deflation; + } + EPSSolve(eps); + } else if (std::is_same< SType, SVD >::value) { + SVDSetInitialSpaces(svd, othern, otherbasis, n, basis); + SVDSolve(svd); + } else if (std::is_same< SType, NEP >::value) { + if (n) NEPSetInitialSpace(nep, n, basis); + NEPSolve(nep); + } else { + if (n) PEPSetInitialSpace(pep, n, basis); + PEPSolve(pep); + } + for (int i = 0; i < n; ++i) VecDestroy(&basis[i]); + delete[] basis; + for (int i = 0; i < othern; ++i) VecDestroy(&otherbasis[i]); + delete[] otherbasis; + PetscInt nconv; + if (std::is_same< SType, EPS >::value) + EPSGetConverged(eps, &nconv); + else if (std::is_same< SType, SVD >::value) + SVDGetConverged(svd, &nconv); + else if (std::is_same< SType, NEP >::value) + NEPGetConverged(nep, &nconv); + else + PEPGetConverged(pep, &nconv); + if (nconv > 0 && ((nargs[2] || nargs[3] || nargs[4]) || ((std::is_same< SType, SVD >::value || (std::is_same< SType, EPS >::value && isTwoSided)) && (nargs[7] || nargs[8])))) { + KN< typename std::conditional< !std::is_same< SType, SVD >::value, K, PetscReal >::type >* eigenvalues = + nargs[2] ? GetAny< KN< typename std::conditional< !std::is_same< SType, SVD >::value, K, PetscReal >::type >* >((*nargs[2])(stack)) : nullptr; + KN< PetscReal >* errorestimate = nargs[10] ? GetAny< KN< PetscReal >* >((*nargs[10])(stack)) : nullptr; + KNM< K >* eigenarray = nargs[4] ? GetAny< KNM< K >* >((*nargs[4])(stack)) : nullptr; + KNM< K >* otherarray = nargs[8] ? GetAny< KNM< K >* >((*nargs[8])(stack)) : nullptr; + if (eigenvalues) eigenvalues->resize(nconv); + if (eigenvectors && !isType) eigenvectors->resize(nconv); + if (othervectors && !isType) othervectors->resize(nconv); + if (errorestimate) errorestimate->resize(nconv); + if (eigenarray) eigenarray->resize(m, nconv); + Vec xr, xi, yr, yi; + PetscInt n, nr; + if (eigenvectors || eigenarray || othervectors || otherarray) { + MatCreateVecs(ptA->_petsc, &xi, &xr); + VecGetLocalSize(xi, &nr); + if (otherarray) otherarray->resize(nr, nconv); + VecGetLocalSize(xr, &n); + } else + xr = xi = NULL; + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) + MatCreateVecs(ptA->_petsc, &yi, &yr); + else + yr = yi = NULL; + for (PetscInt i = 0; i < nconv; ++i) { + PetscScalar kr, ki = 0; + PetscReal sigma; + PetscReal errest; + if (std::is_same< SType, EPS >::value) { + EPSGetEigenpair(eps, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, + (eigenvectors || eigenarray) && std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value ? xi : NULL); + if ((othervectors || otherarray) && isTwoSided) EPSGetLeftEigenvector(eps, i, yr, yi); + if (errorestimate) EPSGetErrorEstimate(eps, i, &errest); + } else if (std::is_same< SType, SVD >::value) + SVDGetSingularTriplet(svd, i, &sigma, xr, xi); + else if (std::is_same< SType, NEP >::value) { + NEPGetEigenpair(nep, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, + (eigenvectors || eigenarray) && std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value ? xi : NULL); + if (errorestimate) NEPGetErrorEstimate(nep, i, &errest); + } else { + PEPGetEigenpair(pep, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, + (eigenvectors || eigenarray) && std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value ? xi : NULL); + if (errorestimate) PEPGetErrorEstimate(pep, i, &errest); } - FEbaseArrayKn* eigenvectors = nargs[3] ? GetAny*>((*nargs[3])(stack)) : nullptr; - Vec* basis = nullptr; - PetscInt n = 0; - if(eigenvectors) { - ffassert(!isType); - if(eigenvectors->N > 0 && eigenvectors->get(0) && eigenvectors->get(0)->n > 0) { - n = eigenvectors->N; - basis = new Vec[n]; - for(int i = 0; i < n; ++i) { - MatCreateVecs(ptA->_petsc, &basis[i], NULL); - PetscScalar* pt; - VecGetArray(basis[i], &pt); - if(!(std::is_same::value && std::is_same>::value)) - distributedVec(ptA->_num, ptA->_first, ptA->_last, static_cast(*(eigenvectors->get(i))), pt, eigenvectors->get(i)->n); - VecRestoreArray(basis[i], &pt); - } + if (eigenvectors || eigenarray || othervectors || otherarray) { + PetscScalar* tmpr; + PetscScalar* tmpi; + PetscScalar* tmp2r; + PetscScalar* tmp2i; + VecGetArray(xr, &tmpr); + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) VecGetArray(yr, &tmp2r); + K *pt, *pti; + if (!std::is_same< SType, SVD >::value) { + if (std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value) { + VecGetArray(xi, &tmpi); + pt = new K[n]; + copy(pt, n, tmpr, tmpi); + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) { + VecGetArray(yi, &tmp2i); + pti = new K[nr]; + copy(pti, nr, tmp2r, tmp2i); + } + } else { + pt = reinterpret_cast< K* >(tmpr); + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) pti = reinterpret_cast< K* >(tmp2r); } - eigenvectors->resize(0); - } - FEbaseArrayKn* othervectors = nargs[7] ? GetAny*>((*nargs[7])(stack)) : nullptr; - Vec* otherbasis = nullptr; - PetscInt othern = 0; - if(othervectors) { - ffassert(!isType); - if(othervectors->N > 0 && othervectors->get(0) && othervectors->get(0)->n > 0) { - othern = othervectors->N; - otherbasis = new Vec[othern]; - for(int i = 0; i < othern; ++i) { - MatCreateVecs(ptA->_petsc, &otherbasis[i], NULL); - PetscScalar* pt; - VecGetArray(otherbasis[i], &pt); - if(!(std::is_same::value && std::is_same>::value)) - distributedVec(ptA->_num, ptA->_first, ptA->_last, static_cast(*(othervectors->get(i))), pt, othervectors->get(i)->n); - VecRestoreArray(otherbasis[i], &pt); - } + } else { + pt = reinterpret_cast< K* >(tmpr); + VecGetArray(xi, reinterpret_cast< PetscScalar** >(&pti)); + tmpi = reinterpret_cast< PetscScalar* >(pti); + } + if (!isType && (ptA->_A || ptA->_exchange)) { + KN< K > cpy(ptA->_A ? ptA->_A->getDof( ) : ptA->_exchange[0]->getDof( )); + cpy = K(0.0); + HPDDM::Subdomain< K >::template distributedVec< 1 >(ptA->_num, ptA->_first, ptA->_last, static_cast< K* >(cpy), pt, static_cast< PetscInt >(cpy.n), 1); + if (ptA->_A) + ptA->_A->HPDDM::template Subdomain< PetscScalar >::exchange(static_cast< K* >(cpy)); + else + ptA->_exchange[0]->HPDDM::template Subdomain< PetscScalar >::exchange(static_cast< K* >(cpy)); + if (eigenvectors) eigenvectors->set(i, cpy); + if (eigenarray && !codeA) { + KN< K > cpy(m, pt); + (*eigenarray)(':', i) = cpy; } - othervectors->resize(0); - } - if(std::is_same::value) { - EPSGetTwoSided(eps, &isTwoSided); - if(n) - EPSSetInitialSpace(eps, n, basis); - if(othern && isTwoSided) - EPSSetLeftInitialSpace(eps, othern, otherbasis); - KNM* ptDeflation = nargs[9] ? GetAny*>((*nargs[9])(stack)) : NULL; - if(ptDeflation && ptDeflation->M()) { - PetscInt m; - MatGetLocalSize(ptA->_petsc, &m, NULL); - ffassert(m == ptDeflation->N()); - Vec* deflation = new Vec[ptDeflation->M()]; - for(int i = 0; i < ptDeflation->M(); ++i) - VecCreateMPIWithArray(PetscObjectComm((PetscObject)ptA->_petsc), 1, ptDeflation->N(), PETSC_DECIDE, &ptDeflation->operator( )(0, i), deflation + i); - EPSSetDeflationSpace(eps, ptDeflation->M(), deflation); - for(int i = 0; i < ptDeflation->M(); ++i) - VecDestroy(deflation + i); - delete [] deflation; + if (std::is_same< SType, SVD >::value || (std::is_same< SType, EPS >::value && (othervectors || otherarray) && isTwoSided)) { + KN< K > cpy(ptA->_cnum && ptA->_exchange[1] ? ptA->_exchange[1]->getDof( ) : (ptA->_A ? ptA->_A->getDof( ) : 0)); + cpy = K(0.0); + if (ptA->_cnum && ptA->_exchange[1]) { + HPDDM::Subdomain< K >::template distributedVec< 1 >(ptA->_cnum, ptA->_cfirst, ptA->_clast, static_cast< K* >(cpy), pti, static_cast< PetscInt >(cpy.n), 1); + ptA->_exchange[1]->HPDDM::template Subdomain< PetscScalar >::exchange(static_cast< K* >(cpy)); + } else if (ptA->_A) { + HPDDM::Subdomain< K >::template distributedVec< 1 >(ptA->_num, ptA->_first, ptA->_last, static_cast< K* >(cpy), pti, static_cast< PetscInt >(cpy.n), 1); + ptA->_A->HPDDM::template Subdomain< PetscScalar >::exchange(static_cast< K* >(cpy)); + } else + ffassert(0); + if (othervectors) othervectors->set(i, cpy); + if (otherarray && !codeA) { + KN< K > cpy(nr, pti); + (*otherarray)(':', i) = cpy; + } } - EPSSolve(eps); - } - else if(std::is_same::value) { - SVDSetInitialSpaces(svd, othern, otherbasis, n, basis); - SVDSolve(svd); - } - else if(std::is_same::value) { - if(n) - NEPSetInitialSpace(nep, n, basis); - NEPSolve(nep); - } - else { - if(n) - PEPSetInitialSpace(pep, n, basis); - PEPSolve(pep); - } - for(int i = 0; i < n; ++i) - VecDestroy(&basis[i]); - delete [] basis; - for(int i = 0; i < othern; ++i) - VecDestroy(&otherbasis[i]); - delete [] otherbasis; - PetscInt nconv; - if(std::is_same::value) - EPSGetConverged(eps, &nconv); - else if(std::is_same::value) - SVDGetConverged(svd, &nconv); - else if(std::is_same::value) - NEPGetConverged(nep, &nconv); - else - PEPGetConverged(pep, &nconv); - if(nconv > 0 && ((nargs[2] || nargs[3] || nargs[4]) || ((std::is_same::value || (std::is_same::value && isTwoSided)) && (nargs[7] || nargs[8])))) { - KN::value, K, PetscReal>::type>* eigenvalues = nargs[2] ? GetAny::value, K, PetscReal>::type>*>((*nargs[2])(stack)) : nullptr; - KN* errorestimate = nargs[10] ? GetAny*>((*nargs[10])(stack)) : nullptr; - KNM* eigenarray = nargs[4] ? GetAny*>((*nargs[4])(stack)) : nullptr; - KNM* otherarray = nargs[8] ? GetAny*>((*nargs[8])(stack)) : nullptr; - if(eigenvalues) - eigenvalues->resize(nconv); - if(eigenvectors && !isType) - eigenvectors->resize(nconv); - if(othervectors && !isType) - othervectors->resize(nconv); - if(errorestimate) - errorestimate->resize(nconv); - if(eigenarray) - eigenarray->resize(m, nconv); - Vec xr, xi, yr, yi; - PetscInt n, nr; - if(eigenvectors || eigenarray || othervectors || otherarray) { - MatCreateVecs(ptA->_petsc, &xi, &xr); - VecGetLocalSize(xi, &nr); - if(otherarray) - otherarray->resize(nr, nconv); - VecGetLocalSize(xr, &n); - } else xr = xi = NULL; - if(std::is_same::value && (othervectors || otherarray)) - MatCreateVecs(ptA->_petsc, &yi, &yr); - else yr = yi = NULL; - for(PetscInt i = 0; i < nconv; ++i) { - PetscScalar kr, ki = 0; - PetscReal sigma; - PetscReal errest; - if(std::is_same::value) { - EPSGetEigenpair(eps, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, (eigenvectors || eigenarray) && std::is_same::value && std::is_same>::value ? xi : NULL); - if((othervectors || otherarray) && isTwoSided) - EPSGetLeftEigenvector(eps, i, yr, yi); - if(errorestimate) - EPSGetErrorEstimate(eps, i, &errest); - } - else if(std::is_same::value) - SVDGetSingularTriplet(svd, i, &sigma, xr, xi); - else if(std::is_same::value) { - NEPGetEigenpair(nep, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, (eigenvectors || eigenarray) && std::is_same::value && std::is_same>::value ? xi : NULL); - if(errorestimate) - NEPGetErrorEstimate(nep, i, &errest); - } - else { - PEPGetEigenpair(pep, i, &kr, &ki, (eigenvectors || eigenarray) ? xr : NULL, (eigenvectors || eigenarray) && std::is_same::value && std::is_same>::value ? xi : NULL); - if(errorestimate) - PEPGetErrorEstimate(pep, i, &errest); - } - if(eigenvectors || eigenarray || othervectors || otherarray) { - PetscScalar* tmpr; - PetscScalar* tmpi; - PetscScalar* tmp2r; - PetscScalar* tmp2i; - VecGetArray(xr, &tmpr); - if(std::is_same::value && (othervectors || otherarray)) - VecGetArray(yr, &tmp2r); - K* pt, *pti; - if(!std::is_same::value) { - if(std::is_same::value && std::is_same>::value) { - VecGetArray(xi, &tmpi); - pt = new K[n]; - copy(pt, n, tmpr, tmpi); - if(std::is_same::value && (othervectors || otherarray)) { - VecGetArray(yi, &tmp2i); - pti = new K[nr]; - copy(pti, nr, tmp2r, tmp2i); - } - } - else { - pt = reinterpret_cast(tmpr); - if(std::is_same::value && (othervectors || otherarray)) - pti = reinterpret_cast(tmp2r); - } - } - else { - pt = reinterpret_cast(tmpr); - VecGetArray(xi, reinterpret_cast(&pti)); - tmpi = reinterpret_cast(pti); - } - if(!isType && (ptA->_A || ptA->_exchange)) { - KN cpy(ptA->_A ? ptA->_A->getDof() : ptA->_exchange[0]->getDof()); - cpy = K(0.0); - HPDDM::Subdomain::template distributedVec<1>(ptA->_num, ptA->_first, ptA->_last, static_cast(cpy), pt, static_cast(cpy.n), 1); - if(ptA->_A) - ptA->_A->HPDDM::template Subdomain::exchange(static_cast(cpy)); - else - ptA->_exchange[0]->HPDDM::template Subdomain::exchange(static_cast(cpy)); - if(eigenvectors) - eigenvectors->set(i, cpy); - if(eigenarray && !codeA) { - KN cpy(m, pt); - (*eigenarray)(':', i) = cpy; - } - if(std::is_same::value || (std::is_same::value && (othervectors || otherarray) && isTwoSided)) { - KN cpy(ptA->_cnum && ptA->_exchange[1] ? ptA->_exchange[1]->getDof() : (ptA->_A ? ptA->_A->getDof() : 0)); - cpy = K(0.0); - if(ptA->_cnum && ptA->_exchange[1]) { - HPDDM::Subdomain::template distributedVec<1>(ptA->_cnum, ptA->_cfirst, ptA->_clast, static_cast(cpy), pti, static_cast(cpy.n), 1); - ptA->_exchange[1]->HPDDM::template Subdomain::exchange(static_cast(cpy)); - } - else if(ptA->_A) { - HPDDM::Subdomain::template distributedVec<1>(ptA->_num, ptA->_first, ptA->_last, static_cast(cpy), pti, static_cast(cpy.n), 1); - ptA->_A->HPDDM::template Subdomain::exchange(static_cast(cpy)); - } - else - ffassert(0); - if(othervectors) - othervectors->set(i, cpy); - if(otherarray && !codeA) { - KN cpy(nr, pti); - (*otherarray)(':', i) = cpy; - } - } - } - if(codeA || isType || !ptA->_A) { - if(eigenarray) { - KN cpy(m, pt); - (*eigenarray)(':', i) = cpy; - } - if(otherarray) { - KN cpy(nr, pti); - (*otherarray)(':', i) = cpy; - } - } - if(!std::is_same::value && std::is_same::value && std::is_same>::value) { - delete [] pt; - delete [] pti; - } - if(std::is_same::value || (std::is_same::value && std::is_same>::value)) { - VecRestoreArray(xi, &tmpi); - if(std::is_same::value && (othervectors || otherarray)) - VecRestoreArray(yi, &tmp2i); - } - if(std::is_same::value && (othervectors || otherarray)) - VecRestoreArray(yr, &tmp2r); - VecRestoreArray(xr, &tmpr); - } - if(eigenvalues) { - if(!std::is_same::value) - assign(static_cast::value, K*, PetscReal*>::type>(*eigenvalues + i), kr, ki); - else - eigenvalues->operator[](i) = sigma; - } - if(errorestimate) - errorestimate->operator[](i) = errest; + } + if (codeA || isType || !ptA->_A) { + if (eigenarray) { + KN< K > cpy(m, pt); + (*eigenarray)(':', i) = cpy; } - if(eigenvectors || eigenarray || othervectors || otherarray) { - VecDestroy(&xr); - VecDestroy(&xi); - VecDestroy(&yr); - VecDestroy(&yi); + if (otherarray) { + KN< K > cpy(nr, pti); + (*otherarray)(':', i) = cpy; } + } + if (!std::is_same< SType, SVD >::value && std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value) { + delete[] pt; + delete[] pti; + } + if (std::is_same< SType, SVD >::value || (std::is_same< PetscScalar, double >::value && std::is_same< K, std::complex< double > >::value)) { + VecRestoreArray(xi, &tmpi); + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) VecRestoreArray(yi, &tmp2i); + } + if (std::is_same< SType, EPS >::value && (othervectors || otherarray)) VecRestoreArray(yr, &tmp2r); + VecRestoreArray(xr, &tmpr); } - if(user) { - MatDestroy(&S); - delete user->mat; - PetscFree(user); + if (eigenvalues) { + if (!std::is_same< SType, SVD >::value) + assign< SType >(static_cast< typename std::conditional< !std::is_same< SType, SVD >::value, K*, PetscReal* >::type >(*eigenvalues + i), kr, ki); + else + eigenvalues->operator[](i) = sigma; } - if(std::is_same::value) { - if(empty) { - ST st; - EPSGetST(eps, &st); - STSetKSP(st, empty); - PetscObjectDereference((PetscObject)empty); - } - EPSDestroy(&eps); - } - else if(std::is_same::value) - SVDDestroy(&svd); - else if(std::is_same::value) - NEPDestroy(&nep); - else - PEPDestroy(&pep); - return static_cast(nconv); + if (errorestimate) errorestimate->operator[](i) = errest; + } + if (eigenvectors || eigenarray || othervectors || otherarray) { + VecDestroy(&xr); + VecDestroy(&xi); + VecDestroy(&yr); + VecDestroy(&yi); + } + } + if (user) { + MatDestroy(&S); + delete user->mat; + PetscFree(user); } + if (std::is_same< SType, EPS >::value) { + if (empty) { + ST st; + EPSGetST(eps, &st); + STSetKSP(st, empty); + PetscObjectDereference((PetscObject)empty); + } + EPSDestroy(&eps); + } else if (std::is_same< SType, SVD >::value) + SVDDestroy(&svd); + else if (std::is_same< SType, NEP >::value) + NEPDestroy(&nep); else - return 0L; - } - else + PEPDestroy(&pep); + return static_cast< long >(nconv); + } else return 0L; -} -template -static PetscErrorCode MatMult_User(Mat A, Vec x, Vec y) { - User user; - const PetscScalar* in; - PetscScalar* out; - PetscErrorCode ierr; + } else + return 0L; + } + template< class Type, class K, class SType > + static PetscErrorCode MatMult_User(Mat A, Vec x, Vec y) { + User< Type, K, SType > user; + const PetscScalar* in; + PetscScalar* out; + PetscErrorCode ierr; PetscFunctionBegin; - ierr = MatShellGetContext(A, &user); CHKERRQ(ierr); - typename SLEPc::eigensolver::MatF_O* mat = reinterpret_cast::MatF_O*>(user->mat); + ierr = MatShellGetContext(A, &user); + CHKERRQ(ierr); + typename SLEPc::eigensolver< Type, K, SType >::MatF_O* mat = reinterpret_cast< typename SLEPc::eigensolver< Type, K, SType >::MatF_O* >(user->mat); VecGetArrayRead(x, &in); VecGetArray(y, &out); - KN_ xx(const_cast(in), mat->N); - KN_ yy(out, mat->N); + KN_< PetscScalar > xx(const_cast< PetscScalar* >(in), mat->N); + KN_< PetscScalar > yy(out, mat->N); yy = *mat * xx; VecRestoreArray(y, &out); VecRestoreArrayRead(x, &in); PetscFunctionReturn(PETSC_SUCCESS); -} -void finalizeSLEPc() { - SlepcFinalize(); -} -template::value>::type* = nullptr> -void addSLEPc() { - Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver>, std::complex, EPS>()); - Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver>, std::complex, EPS>(1)); - Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver>, std::complex, EPS>(1, 1)); -} -template::value>::type* = nullptr> -void addSLEPc() { } -} + } + void finalizeSLEPc( ) { SlepcFinalize( ); } + template< class K, typename std::enable_if< std::is_same< K, double >::value >::type* = nullptr > + void addSLEPc( ) { + Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, std::complex< double >, EPS >( )); + Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, std::complex< double >, EPS >(1)); + Global.Add("EPSSolveComplex", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, std::complex< double >, EPS >(1, 1)); + } + template< class K, typename std::enable_if< !std::is_same< K, double >::value >::type* = nullptr > + void addSLEPc( ) {} +} // namespace SLEPc -static void Init() { - // to load only once - aType t; - int r; +static void Init( ) { + // to load only once + aType t; + int r; #ifdef WITH_slepccomplex - const char * mmmm= "Petsc Slepc complex"; + const char* mmmm = "Petsc Slepc complex"; #else - const char * mmmm= "Petsc Slepc real"; + const char* mmmm = "Petsc Slepc real"; #endif - if(!zzzfff->InMotClef(mmmm,t,r)) - { + if (!zzzfff->InMotClef(mmmm, t, r)) { #ifdef PETScandSLEPc - Init_PETSc(); + Init_PETSc( ); #endif - int argc = pkarg->n; - char** argv = new char*[argc]; - for(int i = 0; i < argc; ++i) - argv[i] = const_cast((*(*pkarg)[i].getap())->c_str()); - PetscBool isInitialized; - PetscInitialized(&isInitialized); - if(!isInitialized && mpirank == 0) - std::cout << "PetscInitialize has not been called, do not forget to load PETSc before loading SLEPc" << std::endl; - SlepcInitialize(&argc, &argv, 0, ""); - delete [] argv; - ff_atend(SLEPc::finalizeSLEPc); - SLEPc::addSLEPc(); - Global.Add("EPSSolve", "(", new SLEPc::eigensolver>, PetscScalar, EPS>()); - Global.Add("EPSSolve", "(", new SLEPc::eigensolver>, PetscScalar, EPS>(1)); - Global.Add("EPSSolve", "(", new SLEPc::eigensolver>, PetscScalar, EPS>(1, 1)); - Global.Add("SVDSolve", "(", new SLEPc::eigensolver>, PetscScalar, SVD>(1, 1)); - Global.Add("NEPSolve", "(", new SLEPc::eigensolver>, PetscScalar, NEP>(1, 1, 1)); - Global.Add("PEPSolve", "(", new SLEPc::eigensolver>, PetscScalar, PEP>(1, 1, 1, 1)); - if(verbosity>1)cout << "*** End:: load PETSc & SELPc "<< typeid(PetscScalar).name() <<"\n\n"<Add(mmmm, atype()); - } - else { - if(verbosity>1)cout << "*** reload and skip load PETSc & SELPc "<< typeid(PetscScalar).name() <<"\n\n"<n; + char** argv = new char*[argc]; + for (int i = 0; i < argc; ++i) argv[i] = const_cast< char* >((*(*pkarg)[i].getap( ))->c_str( )); + PetscBool isInitialized; + PetscInitialized(&isInitialized); + if (!isInitialized && mpirank == 0) std::cout << "PetscInitialize has not been called, do not forget to load PETSc before loading SLEPc" << std::endl; + SlepcInitialize(&argc, &argv, 0, ""); + delete[] argv; + ff_atend(SLEPc::finalizeSLEPc); + SLEPc::addSLEPc< PetscScalar >( ); + Global.Add("EPSSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, EPS >( )); + Global.Add("EPSSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, EPS >(1)); + Global.Add("EPSSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, EPS >(1, 1)); + Global.Add("SVDSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, SVD >(1, 1)); + Global.Add("NEPSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, NEP >(1, 1, 1)); + Global.Add("PEPSolve", "(", new SLEPc::eigensolver< PETSc::DistributedCSR< HpSchwarz< PetscScalar > >, PetscScalar, PEP >(1, 1, 1, 1)); + if (verbosity > 1) cout << "*** End:: load PETSc & SELPc " << typeid(PetscScalar).name( ) << "\n\n" << endl; + zzzfff->Add(mmmm, atype< Dmat* >( )); + } else { + if (verbosity > 1) cout << "*** reload and skip load PETSc & SELPc " << typeid(PetscScalar).name( ) << "\n\n" << endl; + } } #else -static void Init() { - Init_PETSc(); -} +static void Init( ) { Init_PETSc( ); } #endif diff --git a/plugin/mpi/SLEPc-complex.cpp b/plugin/mpi/SLEPc-complex.cpp index fd040c9d2..6deab9f37 100644 --- a/plugin/mpi/SLEPc-complex.cpp +++ b/plugin/mpi/SLEPc-complex.cpp @@ -1,11 +1,12 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: cxx11 //ff-c++-cpp-dep: +/* clang-format on */ #include "ff++.hpp" -static void Load_Init() { - if (mpirank == 0) - cerr << " ++ WARNING: SLEPc-complex has been superseded by PETSc-complex" << endl; +static void Load_Init( ) { + if (mpirank == 0) cerr << " ++ WARNING: SLEPc-complex has been superseded by PETSc-complex" << endl; } LOADFUNC(Load_Init) diff --git a/plugin/mpi/SLEPc.cpp b/plugin/mpi/SLEPc.cpp index ae22b41cf..fb77355fb 100644 --- a/plugin/mpi/SLEPc.cpp +++ b/plugin/mpi/SLEPc.cpp @@ -1,11 +1,12 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: cxx11 //ff-c++-cpp-dep: +/* clang-format on */ #include "ff++.hpp" -static void Load_Init() { - if (mpirank == 0) - cerr << " ++ WARNING: SLEPc has been superseded by PETSc" << endl; +static void Load_Init( ) { + if (mpirank == 0) cerr << " ++ WARNING: SLEPc has been superseded by PETSc" << endl; } LOADFUNC(Load_Init) diff --git a/plugin/mpi/bem.cpp b/plugin/mpi/bem.cpp index 92b4b5f2f..21a047c05 100644 --- a/plugin/mpi/bem.cpp +++ b/plugin/mpi/bem.cpp @@ -1,6 +1,8 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: htool [mkl|blas] mpi pthread bemtool boost [metis] //ff-c++-cpp-dep: -// for def M_PI under windows in +/* clang-format on */ +// for def M_PI under windows in #define _USE_MATH_DEFINES #define BOOST_NO_CXX17_IF_CONSTEXPR @@ -11,7 +13,7 @@ #include // include the bemtool library .... path define in where library -//#include +// #include #include #include #include @@ -32,665 +34,611 @@ using namespace bemtool; template< class K > AnyType AddIncrement(Stack stack, const AnyType &a) { - K m = GetAny< K >(a); - m->increment( ); - Add2StackOfPtr2FreeRC(stack, m); - if (mpirank==0 && verbosity > 1) cout << "AddIncrement:: increment + Add2StackOfPtr2FreeRC " << endl; - return a; + K m = GetAny< K >(a); + m->increment( ); + Add2StackOfPtr2FreeRC(stack, m); + if (mpirank == 0 && verbosity > 1) cout << "AddIncrement:: increment + Add2StackOfPtr2FreeRC " << endl; + return a; } -template -AnyType To(Stack stack,Expression emat,Expression einter,int init) -{ - ffassert(einter); - HMatrixVirt** Hmat = GetAny** >((*einter)(stack)); - ffassert(Hmat && *Hmat); - HMatrixVirt& H = **Hmat; - if(std::is_same>::value) { - Matrix mdense = H.get_local_dense(); - KNM* M = GetAny*>((*emat)(stack)); - for (int i=0; i< H.nb_rows(); i++) - for (int j=0; j< H.nb_cols(); j++) - (*M)(i,j) = 0; - for (int i=0; i< mdense.nb_rows(); i++) - for (int j=0; j< mdense.nb_cols(); j++) - (*M)(H.get_permt(i+H.get_local_offset()),H.get_perms(j)) = mdense(i,j); - - return M; - } - else { - ffassert(0); - } +template< class Type, class K > +AnyType To(Stack stack, Expression emat, Expression einter, int init) { + ffassert(einter); + HMatrixVirt< K > **Hmat = GetAny< HMatrixVirt< K > ** >((*einter)(stack)); + ffassert(Hmat && *Hmat); + HMatrixVirt< K > &H = **Hmat; + if (std::is_same< Type, KNM< K > >::value) { + Matrix< K > mdense = H.get_local_dense( ); + KNM< K > *M = GetAny< KNM< K > * >((*emat)(stack)); + for (int i = 0; i < H.nb_rows( ); i++) + for (int j = 0; j < H.nb_cols( ); j++) (*M)(i, j) = 0; + for (int i = 0; i < mdense.nb_rows( ); i++) + for (int j = 0; j < mdense.nb_cols( ); j++) (*M)(H.get_permt(i + H.get_local_offset( )), H.get_perms(j)) = mdense(i, j); + + return M; + } else { + ffassert(0); + } } -template -AnyType To(Stack stack,Expression emat,Expression einter) -{ return To(stack,emat,einter,init);} +template< class Type, class K, int init > +AnyType To(Stack stack, Expression emat, Expression einter) { + return To< Type, K >(stack, emat, einter, init); +} -template +template< class V, class K > class Prod { -public: - const HMatrixVirt* h; - const V u; - Prod(HMatrixVirt** v, V w) : h(*v), u(w) {} - - void prod(V x) const {int mu = this->u->n/h->nb_cols(); h->mvprod_global(*(this->u), *x, mu);}; - - static V mv(V Ax, Prod A) { - *Ax = K(); - A.prod(Ax); - return Ax; - } - static V init(V Ax, Prod A) { - Ax->init(A.u->n); - return mv(Ax, A); - } - + public: + const HMatrixVirt< K > *h; + const V u; + Prod(HMatrixVirt< K > **v, V w) : h(*v), u(w) {} + + void prod(V x) const { + int mu = this->u->n / h->nb_cols( ); + h->mvprod_global(*(this->u), *x, mu); + }; + + static V mv(V Ax, Prod< V, K > A) { + *Ax = K( ); + A.prod(Ax); + return Ax; + } + static V init(V Ax, Prod< V, K > A) { + Ax->init(A.u->n); + return mv(Ax, A); + } }; - // post treatment for HMatrix -template -std::map* get_infos(HMatrixVirt** const& H) { - return new std::map((*H)->get_infos()); +template< class K > +std::map< std::string, std::string > *get_infos(HMatrixVirt< K > **const &H) { + return new std::map< std::string, std::string >((*H)->get_infos( )); } -string* get_info(std::map* const& infos, string* const& s){ - return new string((*infos)[*s]); -} +string *get_info(std::map< std::string, std::string > *const &infos, string *const &s) { return new string((*infos)[*s]); } -ostream & operator << (ostream &out, const std::map & infos) -{ - for (std::map::const_iterator it = infos.begin() ; it != infos.end() ; ++it){ - out<first<<"\t"<second< &infos) { + for (std::map< std::string, std::string >::const_iterator it = infos.begin( ); it != infos.end( ); ++it) { + out << it->first << "\t" << it->second << std::endl; + } + out << std::endl; + return out; } -template +template< class A > struct PrintPinfos { - using first_argument_type = ostream*; - using second_argument_type = A; - using result_type = ostream*; - static ostream* f(ostream* const & a,const A & b) { *a << *b; - return a; - } + using first_argument_type = ostream *; + using second_argument_type = A; + using result_type = ostream *; + static ostream *f(ostream *const &a, const A &b) { + *a << *b; + return a; + } }; -template +template< class K > class plotHMatrix : public OneOperator { -public: - - class Op : public E_F0info { - public: - Expression a; - - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long argl(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - public: - Op(const basicAC_F0 & args,Expression aa) : a(aa) { - args.SetNameParam(n_name_param,name_param,nargs); + public: + class Op : public E_F0info { + public: + Expression a; + + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + long argl(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + public: + Op(const basicAC_F0 &args, Expression aa) : a(aa) { args.SetNameParam(n_name_param, name_param, nargs); } + + AnyType operator( )(Stack stack) const { + + bool wait = arg(0, stack, false); + long dim = argl(1, stack, 2); + + HMatrixVirt< K > **H = GetAny< HMatrixVirt< K > ** >((*a)(stack)); + + PlotStream theplot(ThePlotStream); + + if (mpirank == 0 && ThePlotStream) { + theplot.SendNewPlot( ); + theplot << 3L; + theplot <= wait; + theplot << 17L; + theplot <= dim; + theplot << 4L; + theplot <= true; + theplot.SendEndArgPlot( ); + theplot.SendMeshes( ); + theplot << 0L; + theplot.SendPlots( ); + theplot << 1L; + theplot << 31L; + } + + if (!H || !(*H)) { + if (mpirank == 0 && ThePlotStream) { + theplot << 0; + theplot << 0; + theplot << 0L; + theplot << 0L; } - - AnyType operator()(Stack stack) const{ - - bool wait = arg(0,stack,false); - long dim = argl(1,stack,2); - - HMatrixVirt** H =GetAny** >((*a)(stack)); - - PlotStream theplot(ThePlotStream); - - if (mpirank == 0 && ThePlotStream) { - theplot.SendNewPlot(); - theplot << 3L; - theplot <= wait; - theplot << 17L; - theplot <= dim; - theplot << 4L; - theplot <= true; - theplot.SendEndArgPlot(); - theplot.SendMeshes(); - theplot << 0L; - theplot.SendPlots(); - theplot << 1L; - theplot << 31L; - } - - if (!H || !(*H)) { - if (mpirank == 0&& ThePlotStream) { - theplot << 0; - theplot << 0; - theplot << 0L; - theplot << 0L; - } - } - else { - std::vector *> dmats = (*H)->get_dense_blocks(); - std::vector *> lrmats = (*H)->get_low_rank_blocks(); - int nbdense = dmats.size(); - int nblr = lrmats.size(); - - int sizeworld = (*H)->get_sizeworld(); - int rankworld = (*H)->get_rankworld(); - - int nbdenseworld[sizeworld]; - int nblrworld[sizeworld]; - MPI_Allgather(&nbdense, 1, MPI_INT, nbdenseworld, 1, MPI_INT, (*H)->get_comm()); - MPI_Allgather(&nblr, 1, MPI_INT, nblrworld, 1, MPI_INT, (*H)->get_comm()); - int nbdenseg = 0; - int nblrg = 0; - for (int i=0; i& l = *(dmats[i]); - buf[4*i] = l.get_target_cluster().get_offset(); - buf[4*i+1] = l.get_source_cluster().get_offset(); - buf[4*i+2] = l.get_target_cluster().get_size(); - buf[4*i+3] = l.get_source_cluster().get_size(); - } - - int displs[sizeworld]; - int recvcounts[sizeworld]; - displs[0] = 0; - - for (int i=0; i 0) displs[i] = displs[i-1] + recvcounts[i-1]; - } - MPI_Gatherv(rankworld==0?MPI_IN_PLACE:buf, recvcounts[rankworld], MPI_INT, buf, recvcounts, displs, MPI_INT, 0, (*H)->get_comm()); - - int* buflr = buf + 4*(mpirank==0?nbdenseg:nbdense); - double* bufcomp = new double[mpirank==0?nblrg:nblr]; - - for (int i=0;i& l = *lrmats[i]; - buflr[5*i] = l.get_target_cluster().get_offset(); - buflr[5*i+1] = l.get_source_cluster().get_offset(); - buflr[5*i+2] = l.get_target_cluster().get_size(); - buflr[5*i+3] = l.get_source_cluster().get_size(); - buflr[5*i+4] = l.get_low_rank_data()->rank_of(); - bufcomp[i] = l.get_low_rank_data()->space_saving(); - } - - for (int i=0; i 0) displs[i] = displs[i-1] + recvcounts[i-1]; - } - - MPI_Gatherv(rankworld==0?MPI_IN_PLACE:buflr, recvcounts[rankworld], MPI_INT, buflr, recvcounts, displs, MPI_INT, 0, (*H)->get_comm()); - - for (int i=0; i 0) displs[i] = displs[i-1] + recvcounts[i-1]; - } - - MPI_Gatherv(rankworld==0?MPI_IN_PLACE:bufcomp, recvcounts[rankworld], MPI_DOUBLE, bufcomp, recvcounts, displs, MPI_DOUBLE, 0, (*H)->get_comm()); - - if (mpirank == 0 && ThePlotStream ) { - - int si = (*H)->nb_rows(); - int sj = (*H)->nb_cols(); - - theplot << si; - theplot << sj; - theplot << (long)nbdenseg; - theplot << (long)nblrg; - - for (int i=0;i * > dmats = (*H)->get_dense_blocks( ); + std::vector< const HMatrix< K > * > lrmats = (*H)->get_low_rank_blocks( ); + int nbdense = dmats.size( ); + int nblr = lrmats.size( ); + + int sizeworld = (*H)->get_sizeworld( ); + int rankworld = (*H)->get_rankworld( ); + + int nbdenseworld[sizeworld]; + int nblrworld[sizeworld]; + MPI_Allgather(&nbdense, 1, MPI_INT, nbdenseworld, 1, MPI_INT, (*H)->get_comm( )); + MPI_Allgather(&nblr, 1, MPI_INT, nblrworld, 1, MPI_INT, (*H)->get_comm( )); + int nbdenseg = 0; + int nblrg = 0; + for (int i = 0; i < sizeworld; i++) { + nbdenseg += nbdenseworld[i]; + nblrg += nblrworld[i]; + } + int *buf = new int[4 * (mpirank == 0 ? nbdenseg : nbdense) + 5 * (mpirank == 0 ? nblrg : nblr)]; + + for (int i = 0; i < nbdense; i++) { + const HMatrix< K > &l = *(dmats[i]); + buf[4 * i] = l.get_target_cluster( ).get_offset( ); + buf[4 * i + 1] = l.get_source_cluster( ).get_offset( ); + buf[4 * i + 2] = l.get_target_cluster( ).get_size( ); + buf[4 * i + 3] = l.get_source_cluster( ).get_size( ); } - }; - - plotHMatrix() : OneOperator(atype(),atype **>()) {} - - E_F0 * code(const basicAC_F0 & args) const - { - return new Op(args,t[0]->CastTo(args[0])); - } -}; -template -basicAC_F0::name_and_type plotHMatrix::Op::name_param[]= { - { "wait", &typeid(bool)}, - { "dim", &typeid(long)} -}; + int displs[sizeworld]; + int recvcounts[sizeworld]; + displs[0] = 0; -template -class HMatrixInv { -public: - const T t; - const U u; - - struct HMatVirt: CGMatVirt { - const T tt; - - HMatVirt(T ttt) : tt(ttt), CGMatVirt((*ttt)->nb_rows()) {} - K* addmatmul(K* x,K* Ax) const { (*tt)->mvprod_global(x, Ax); return Ax;} - }; - - struct HMatVirtPrec: CGMatVirt { - const T tt; - std::vector invdiag; - - HMatVirtPrec(T ttt) : tt(ttt), CGMatVirt((*ttt)->nb_rows()), invdiag((*ttt)->nb_rows(),0) { - std::vector*> diagblocks = (*tt)->get_diagonal_blocks(); - std::vector tmp((*ttt)->nb_rows(),0); - for (int j=0;j& submat = *(diagblocks[j]); - const Matrix& subdensemat= *submat.get_dense_data(); - int local_nr = submat.get_target_cluster().get_size(); - int local_nc = submat.get_source_cluster().get_size(); - int offset_i = submat.get_target_cluster().get_offset(); - int offset_j = submat.get_source_cluster().get_offset(); - for (int i=offset_i;icluster_to_target_permutation(tmp.data(),invdiag.data()); - MPI_Allreduce(MPI_IN_PLACE, &(invdiag[0]), (*ttt)->nb_rows(), wrapper_mpi::mpi_type(), MPI_SUM, (*tt)->get_comm()); + for (int i = 0; i < sizeworld; i++) { + recvcounts[i] = 4 * nbdenseworld[i]; + if (i > 0) displs[i] = displs[i - 1] + recvcounts[i - 1]; + } + MPI_Gatherv(rankworld == 0 ? MPI_IN_PLACE : buf, recvcounts[rankworld], MPI_INT, buf, recvcounts, displs, MPI_INT, 0, (*H)->get_comm( )); + + int *buflr = buf + 4 * (mpirank == 0 ? nbdenseg : nbdense); + double *bufcomp = new double[mpirank == 0 ? nblrg : nblr]; + + for (int i = 0; i < nblr; i++) { + const HMatrix< K > &l = *lrmats[i]; + buflr[5 * i] = l.get_target_cluster( ).get_offset( ); + buflr[5 * i + 1] = l.get_source_cluster( ).get_offset( ); + buflr[5 * i + 2] = l.get_target_cluster( ).get_size( ); + buflr[5 * i + 3] = l.get_source_cluster( ).get_size( ); + buflr[5 * i + 4] = l.get_low_rank_data( )->rank_of( ); + bufcomp[i] = l.get_low_rank_data( )->space_saving( ); } - - K* addmatmul(K* x,K* Ax) const { - for (int i=0; i<(*tt)->nb_rows(); i++) - Ax[i] = invdiag[i] * x[i]; - return Ax; + + for (int i = 0; i < sizeworld; i++) { + recvcounts[i] = 5 * nblrworld[i]; + if (i > 0) displs[i] = displs[i - 1] + recvcounts[i - 1]; } - }; - - HMatrixInv(T v, U w) : t(v), u(w) {} - - void solve(U out) const { - if ((*t)->solver == "HLU") { - (*t)->factorization(); - std::copy_n((K*)*u,(*t)->nb_rows(),(K*)*out); - htool::MatrixView out_view((*t)->nb_rows(),1,(K*)*out); - (*t)->solve(out_view); + + MPI_Gatherv(rankworld == 0 ? MPI_IN_PLACE : buflr, recvcounts[rankworld], MPI_INT, buflr, recvcounts, displs, MPI_INT, 0, (*H)->get_comm( )); + + for (int i = 0; i < sizeworld; i++) { + recvcounts[i] = nblrworld[i]; + if (i > 0) displs[i] = displs[i - 1] + recvcounts[i - 1]; } - else { - HMatVirt A(t); - HMatVirtPrec P(t); - double eps =1e-6; - int niterx=3000; - bool res=fgmres(A,P,1,(K*)*u,(K*)*out,eps,niterx,niterx,(mpirank==0)*verbosity); - //bool res=fgmres(A,P,1,(K*)*u,(K*)*out,eps,niterx,200,(mpirank==0)*verbosity); + + MPI_Gatherv(rankworld == 0 ? MPI_IN_PLACE : bufcomp, recvcounts[rankworld], MPI_DOUBLE, bufcomp, recvcounts, displs, MPI_DOUBLE, 0, (*H)->get_comm( )); + + if (mpirank == 0 && ThePlotStream) { + + int si = (*H)->nb_rows( ); + int sj = (*H)->nb_cols( ); + + theplot << si; + theplot << sj; + theplot << (long)nbdenseg; + theplot << (long)nblrg; + + for (int i = 0; i < nbdenseg; i++) { + theplot << buf[4 * i]; + theplot << buf[4 * i + 1]; + theplot << buf[4 * i + 2]; + theplot << buf[4 * i + 3]; + } + + for (int i = 0; i < nblrg; i++) { + theplot << buflr[5 * i]; + theplot << buflr[5 * i + 1]; + theplot << buflr[5 * i + 2]; + theplot << buflr[5 * i + 3]; + theplot << buflr[5 * i + 4]; + theplot << bufcomp[i]; + } + + theplot.SendEndPlot( ); } + delete[] buf; + delete[] bufcomp; + } + + return 0L; } - - static U inv(U Ax, HMatrixInv A) { - A.solve(Ax); - return Ax; - } - static U init(U Ax, HMatrixInv A) { - Ax->init(A.u->n); - return inv(Ax, A); - } -}; + }; -template -class CompressMat : public OneOperator { - public: - class Op : public E_F0info { - public: - Expression a,b,c,d; - - static const int n_name_param = 8; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - long argl(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - bool argb(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - string* args(int i,Stack stack,string* a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - double arg(int i,Stack stack,double a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - pcommworld argc(int i,Stack stack,pcommworld a ) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - Op(const basicAC_F0 & args,Expression aa,Expression bb,Expression cc, Expression dd) : a(aa),b(bb),c(cc),d(dd) { - args.SetNameParam(n_name_param,name_param,nargs); - } - }; - - CompressMat() : OneOperator(atype::Op *>(), - atype*>(), - atype*>(), - atype*>(), - atype*>()) {} - - E_F0 * code(const basicAC_F0 & args) const { - return new Op(args,t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3])); - } -}; + plotHMatrix( ) : OneOperator(atype< long >( ), atype< HMatrixVirt< K > ** >( )) {} -template -basicAC_F0::name_and_type CompressMat::Op::name_param[]= { - { "eps", &typeid(double)}, - { "commworld", &typeid(pcommworld)}, - { "eta", &typeid(double)}, - { "maxleafsize", &typeid(long)}, - { "mintargetdepth", &typeid(long)}, - { "minsourcedepth", &typeid(long)}, - { "compressor", &typeid(string*)}, - { "recompress", &typeid(bool)} + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0])); } }; -template -class MyMatrix: public VirtualGenerator{ - const KNM &M; +template< class K > +basicAC_F0::name_and_type plotHMatrix< K >::Op::name_param[] = {{"wait", &typeid(bool)}, {"dim", &typeid(long)}}; -public: - MyMatrix(const KNM &mat):M(mat) {} +template< class T, class U, class K, char trans > +class HMatrixInv { + public: + const T t; + const U u; - K get_coef(const int& i, const int& j)const {return M(i,j);} - void copy_submatrix(int m, int n, const int *const rows, const int *const cols, K *ptr) const { - std::fill_n(ptr,m*n,0); - for (int i=0;i { + const T tt; - } + HMatVirt(T ttt) : tt(ttt), CGMatVirt< int, K >((*ttt)->nb_rows( )) {} + K *addmatmul(K *x, K *Ax) const { + (*tt)->mvprod_global(x, Ax); + return Ax; + } + }; + + struct HMatVirtPrec : CGMatVirt< int, K > { + const T tt; + std::vector< K > invdiag; + + HMatVirtPrec(T ttt) : tt(ttt), CGMatVirt< int, K >((*ttt)->nb_rows( )), invdiag((*ttt)->nb_rows( ), 0) { + std::vector< const HMatrix< K > * > diagblocks = (*tt)->get_diagonal_blocks( ); + std::vector< K > tmp((*ttt)->nb_rows( ), 0); + for (int j = 0; j < diagblocks.size( ); j++) { + const HMatrix< K > &submat = *(diagblocks[j]); + const Matrix< K > &subdensemat = *submat.get_dense_data( ); + int local_nr = submat.get_target_cluster( ).get_size( ); + int local_nc = submat.get_source_cluster( ).get_size( ); + int offset_i = submat.get_target_cluster( ).get_offset( ); + int offset_j = submat.get_source_cluster( ).get_offset( ); + for (int i = offset_i; i < offset_i + std::min(local_nr, local_nc); i++) { + tmp[i] = 1. / subdensemat(i - offset_i, i - offset_i); } + } + (*tt)->cluster_to_target_permutation(tmp.data( ), invdiag.data( )); + MPI_Allreduce(MPI_IN_PLACE, &(invdiag[0]), (*ttt)->nb_rows( ), wrapper_mpi< K >::mpi_type( ), MPI_SUM, (*tt)->get_comm( )); + } + + K *addmatmul(K *x, K *Ax) const { + for (int i = 0; i < (*tt)->nb_rows( ); i++) Ax[i] = invdiag[i] * x[i]; + return Ax; + } + }; + + HMatrixInv(T v, U w) : t(v), u(w) {} + + void solve(U out) const { + if ((*t)->solver == "HLU") { + (*t)->factorization( ); + std::copy_n((K *)*u, (*t)->nb_rows( ), (K *)*out); + htool::MatrixView< K > out_view((*t)->nb_rows( ), 1, (K *)*out); + (*t)->solve(out_view); + } else { + HMatVirt A(t); + HMatVirtPrec P(t); + double eps = 1e-6; + int niterx = 3000; + bool res = fgmres(A, P, 1, (K *)*u, (K *)*out, eps, niterx, niterx, (mpirank == 0) * verbosity); + // bool res=fgmres(A,P,1,(K*)*u,(K*)*out,eps,niterx,200,(mpirank==0)*verbosity); + } + } + + static U inv(U Ax, HMatrixInv< T, U, K, trans > A) { + A.solve(Ax); + return Ax; + } + static U init(U Ax, HMatrixInv< T, U, K, trans > A) { + Ax->init(A.u->n); + return inv(Ax, A); + } +}; + +template< class K > +class CompressMat : public OneOperator { + public: + class Op : public E_F0info { + public: + Expression a, b, c, d; + + static const int n_name_param = 8; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + long argl(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool argb(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + string *args(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + pcommworld argc(int i, Stack stack, pcommworld a) const { return nargs[i] ? GetAny< pcommworld >((*nargs[i])(stack)) : a; } + + Op(const basicAC_F0 &args, Expression aa, Expression bb, Expression cc, Expression dd) : a(aa), b(bb), c(cc), d(dd) { args.SetNameParam(n_name_param, name_param, nargs); } + }; + + CompressMat( ) : OneOperator(atype< const typename CompressMat< K >::Op * >( ), atype< KNM< K > * >( ), atype< KN< double > * >( ), atype< KN< double > * >( ), atype< KN< double > * >( )) {} + + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } }; -template -AnyType SetCompressMat(Stack stack,Expression emat,Expression einter) -{ return SetCompressMat(stack,emat,einter,init);} - -template -AnyType SetCompressMat(Stack stack,Expression emat,Expression einter,int init) -{ - HMatrixVirt** Hmat =GetAny** >((*emat)(stack)); - const typename CompressMat::Op * mi(dynamic_cast::Op *>(einter)); - - double epsilon=mi->arg(0,stack,ff_htoolEpsilon); - pcommworld pcomm=mi->argc(1,stack,nullptr); - double eta=mi->arg(2,stack,ff_htoolEta); - int maxleafsize=mi->argl(3,stack,ff_htoolMaxleafsize); - int mintargetdepth=mi->argl(4,stack,ff_htoolMintargetdepth); - int minsourcedepth=mi->argl(5,stack,ff_htoolMinsourcedepth); - string* pcompressor=mi->args(6,stack,0); - bool recompress=mi->argb(7,stack,false); +template< class K > +basicAC_F0::name_and_type CompressMat< K >::Op::name_param[] = {{"eps", &typeid(double)}, {"commworld", &typeid(pcommworld)}, {"eta", &typeid(double)}, + {"maxleafsize", &typeid(long)}, {"mintargetdepth", &typeid(long)}, {"minsourcedepth", &typeid(long)}, + {"compressor", &typeid(string *)}, {"recompress", &typeid(bool)}}; + +template< class K > +class MyMatrix : public VirtualGenerator< K > { + const KNM< K > &M; + + public: + MyMatrix(const KNM< K > &mat) : M(mat) {} + + K get_coef(const int &i, const int &j) const { return M(i, j); } + void copy_submatrix(int m, int n, const int *const rows, const int *const cols, K *ptr) const { + std::fill_n(ptr, m * n, 0); + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + ptr[i + m * j] = M(rows[i], cols[j]); + } + } + } +}; + +template< class K, int init > +AnyType SetCompressMat(Stack stack, Expression emat, Expression einter) { + return SetCompressMat< K >(stack, emat, einter, init); +} + +template< class K > +AnyType SetCompressMat(Stack stack, Expression emat, Expression einter, int init) { + HMatrixVirt< K > **Hmat = GetAny< HMatrixVirt< K > ** >((*emat)(stack)); + const typename CompressMat< K >::Op *mi(dynamic_cast< const typename CompressMat< K >::Op * >(einter)); + + double epsilon = mi->arg(0, stack, ff_htoolEpsilon); + pcommworld pcomm = mi->argc(1, stack, nullptr); + double eta = mi->arg(2, stack, ff_htoolEta); + int maxleafsize = mi->argl(3, stack, ff_htoolMaxleafsize); + int mintargetdepth = mi->argl(4, stack, ff_htoolMintargetdepth); + int minsourcedepth = mi->argl(5, stack, ff_htoolMinsourcedepth); + string *pcompressor = mi->args(6, stack, 0); + bool recompress = mi->argb(7, stack, false); string compressor = pcompressor ? *pcompressor : "partialACA"; - MPI_Comm comm = pcomm ? *(MPI_Comm*)pcomm : MPI_COMM_WORLD; + MPI_Comm comm = pcomm ? *(MPI_Comm *)pcomm : MPI_COMM_WORLD; ffassert(einter); - KNM * pM = GetAny< KNM * >((* mi->a)(stack)); - KNM & M = *pM; + KNM< K > *pM = GetAny< KNM< K > * >((*mi->a)(stack)); + KNM< K > &M = *pM; - KN * px = GetAny< KN * >((* mi->b)(stack)); - KN & xx = *px; + KN< double > *px = GetAny< KN< double > * >((*mi->b)(stack)); + KN< double > &xx = *px; - KN * py = GetAny< KN * >((* mi->c)(stack)); - KN & yy = *py; + KN< double > *py = GetAny< KN< double > * >((*mi->c)(stack)); + KN< double > &yy = *py; - KN * pz = GetAny< KN * >((* mi->d)(stack)); - KN & zz = *pz; + KN< double > *pz = GetAny< KN< double > * >((*mi->d)(stack)); + KN< double > &zz = *pz; - MyMatrix A(M); + MyMatrix< K > A(M); - ffassert(xx.n == M.N()); - ffassert(yy.n == M.N()); - ffassert(zz.n == M.N()); + ffassert(xx.n == M.N( )); + ffassert(yy.n == M.N( )); + ffassert(zz.n == M.N( )); - std::vector p(3*xx.n); - for (int i=0; i p(3 * xx.n); + for (int i = 0; i < xx.n; i++) { + p[3 * i + 0] = xx[i]; + p[3 * i + 1] = yy[i]; + p[3 * i + 2] = zz[i]; } - - int sizeWorld,rankWorld; + + int sizeWorld, rankWorld; MPI_Comm_size(comm, &sizeWorld); MPI_Comm_rank(comm, &rankWorld); - htool::ClusterTreeBuilder cluster_builder; - std::shared_ptr> t; + htool::ClusterTreeBuilder< double > cluster_builder; + std::shared_ptr< Cluster< double > > t; cluster_builder.set_maximal_leaf_size(maxleafsize); - t = std::make_shared>(cluster_builder.create_cluster_tree(xx.n,3,p.data(),2,sizeWorld)); + t = std::make_shared< htool::Cluster< double > >(cluster_builder.create_cluster_tree(xx.n, 3, p.data( ), 2, sizeWorld)); - //cout << M.N() << " " << xx.M() << " " << yy.n << " " << zz.n<< endl; + // cout << M.N() << " " << xx.M() << " " << yy.n << " " << zz.n<< endl; if (init) delete *Hmat; - - auto hmatrix_builder = htool::HMatrixTreeBuilder(epsilon, eta, 'N','N', -1); - std::shared_ptr> LowRankGenerator = nullptr; - - - if ( compressor == "" || compressor == "partialACA") - LowRankGenerator = std::make_shared>(A, t->get_permutation().data(), t->get_permutation().data()); - else if (compressor == "fullACA") - LowRankGenerator = std::make_shared>(A, t->get_permutation().data(), t->get_permutation().data()); - else if (compressor == "SVD") - LowRankGenerator = std::make_shared>(A, t->get_permutation().data(), t->get_permutation().data()); - else { - cerr << "Error: unknown htool compressor \""+compressor+"\"" << endl; - ffassert(0); - } - if (recompress){ - std::shared_ptr> RecompressedLowRankGenerator = std::make_shared>(*LowRankGenerator,std::function &)>(htool::SVD_recompression)); - hmatrix_builder.set_low_rank_generator(RecompressedLowRankGenerator); - }else{ - hmatrix_builder.set_low_rank_generator(LowRankGenerator); - } + + auto hmatrix_builder = htool::HMatrixTreeBuilder< K, double >(epsilon, eta, 'N', 'N', -1); + std::shared_ptr< htool::VirtualInternalLowRankGenerator< K > > LowRankGenerator = nullptr; + + if (compressor == "" || compressor == "partialACA") + LowRankGenerator = std::make_shared< htool::partialACA< K > >(A, t->get_permutation( ).data( ), t->get_permutation( ).data( )); + else if (compressor == "fullACA") + LowRankGenerator = std::make_shared< htool::fullACA< K > >(A, t->get_permutation( ).data( ), t->get_permutation( ).data( )); + else if (compressor == "SVD") + LowRankGenerator = std::make_shared< htool::SVD< K > >(A, t->get_permutation( ).data( ), t->get_permutation( ).data( )); + else { + cerr << "Error: unknown htool compressor \"" + compressor + "\"" << endl; + ffassert(0); + } + if (recompress) { + std::shared_ptr< htool::VirtualInternalLowRankGenerator< K > > RecompressedLowRankGenerator = + std::make_shared< htool::RecompressedLowRankGenerator< K > >(*LowRankGenerator, std::function< void(htool::LowRankMatrix< K > &) >(htool::SVD_recompression< K >)); + hmatrix_builder.set_low_rank_generator(RecompressedLowRankGenerator); + } else { + hmatrix_builder.set_low_rank_generator(LowRankGenerator); + } hmatrix_builder.set_minimal_target_depth(mintargetdepth); hmatrix_builder.set_minimal_source_depth(minsourcedepth); - *Hmat = new HMatrixImpl(A, t,t,hmatrix_builder,"HLU",comm); + *Hmat = new HMatrixImpl< K >(A, t, t, hmatrix_builder, "HLU", comm); return Hmat; } -template -void addHmat() { - // Dcl_Type**>(Initialize*>, Delete*>); - Dcl_TypeandPtr*>(0,0,::InitializePtr*>,::DeletePtr*>); - //atype**>()->Add("(","",new OneOperator2_**, string*>(get_infos)); - - Add**>("infos",".",new OneOperator1_*, HMatrixVirt**>(get_infos)); - - Dcl_Type*, K>>(); - TheOperators->Add("*", new OneOperator2*, K>, HMatrixVirt**, KN*>(Build)); - TheOperators->Add("=", new OneOperator2*, KN*, Prod*, K>>(Prod*, K>::mv)); - TheOperators->Add("<-", new OneOperator2*, KN*, Prod*, K>>(Prod*, K>::init)); - - addInv*, HMatrixInv, KN, K>(); - - Global.Add("display","(",new plotHMatrix); - - // to dense: - TheOperators->Add("=", - new OneOperator2_*, KNM*, HMatrixVirt**,E_F_StackF0F0>(To, K, 1>)); - TheOperators->Add("<-", - new OneOperator2_*, KNM*, HMatrixVirt**,E_F_StackF0F0>(To, K, 0>)); - Dcl_Type::Op *>(); - //Add::Op *>("<-","(", new assembleHMatrix); - - TheOperators->Add("=", - new OneOperator2_**,HMatrixVirt**,const typename CompressMat::Op*,E_F_StackF0F0>(SetCompressMat)); - TheOperators->Add("<-", - new OneOperator2_**,HMatrixVirt**,const typename CompressMat::Op*,E_F_StackF0F0>(SetCompressMat)); - - Global.Add("compress","(",new CompressMat); +template< class K > +void addHmat( ) { + // Dcl_Type**>(Initialize*>, Delete*>); + Dcl_TypeandPtr< HMatrixVirt< K > * >(0, 0, ::InitializePtr< HMatrixVirt< K > * >, ::DeletePtr< HMatrixVirt< K > * >); + // atype**>()->Add("(","",new OneOperator2_**, string*>(get_infos)); + + Add< HMatrixVirt< K > ** >("infos", ".", new OneOperator1_< std::map< std::string, std::string > *, HMatrixVirt< K > ** >(get_infos)); + + Dcl_Type< Prod< KN< K > *, K > >( ); + TheOperators->Add("*", new OneOperator2< Prod< KN< K > *, K >, HMatrixVirt< K > **, KN< K > * >(Build)); + TheOperators->Add("=", new OneOperator2< KN< K > *, KN< K > *, Prod< KN< K > *, K > >(Prod< KN< K > *, K >::mv)); + TheOperators->Add("<-", new OneOperator2< KN< K > *, KN< K > *, Prod< KN< K > *, K > >(Prod< KN< K > *, K >::init)); + + addInv< HMatrixVirt< K > *, HMatrixInv, KN< K >, K >( ); + + Global.Add("display", "(", new plotHMatrix< K >); + + // to dense: + TheOperators->Add("=", new OneOperator2_< KNM< K > *, KNM< K > *, HMatrixVirt< K > **, E_F_StackF0F0 >(To< KNM< K >, K, 1 >)); + TheOperators->Add("<-", new OneOperator2_< KNM< K > *, KNM< K > *, HMatrixVirt< K > **, E_F_StackF0F0 >(To< KNM< K >, K, 0 >)); + Dcl_Type< const typename CompressMat< K >::Op * >( ); + // Add::Op *>("<-","(", new assembleHMatrix); + + TheOperators->Add("=", new OneOperator2_< HMatrixVirt< K > **, HMatrixVirt< K > **, const typename CompressMat< K >::Op *, E_F_StackF0F0 >(SetCompressMat< K, 1 >)); + TheOperators->Add("<-", new OneOperator2_< HMatrixVirt< K > **, HMatrixVirt< K > **, const typename CompressMat< K >::Op *, E_F_StackF0F0 >(SetCompressMat< K, 0 >)); + + Global.Add("compress", "(", new CompressMat< K >); } -template -struct OpHMatrixtoBEMForm -: public OneOperator -{ - typedef typename Call_FormBilinear::const_iterator const_iterator; +template< class R, class MMesh, class v_fes1, class v_fes2 > +struct OpHMatrixtoBEMForm : public OneOperator { + typedef typename Call_FormBilinear< v_fes1, v_fes2 >::const_iterator const_iterator; + int init; + class Op : public E_F0mps { + public: + Call_FormBilinear< v_fes1, v_fes2 > *b; + Expression a; int init; - class Op : public E_F0mps { - public: - Call_FormBilinear *b; - Expression a; - int init; - AnyType operator()(Stack s) const ; - - Op(Expression aa,Expression bb,int initt) - : b(new Call_FormBilinear(* dynamic_cast *>(bb))),a(aa),init(initt) - { - assert(b && b->nargs); - - // Check the nbitem of inconnu and test in BemFormBilinear - checkNbItemFEspacesInconnuAndTest(b->largs,b->N,b->M); - } - operator aType () const { return atype **>();} - - }; - - E_F0 * code(const basicAC_F0 & args) const - { - Expression p=args[1]; - Call_FormBilinear *t( new Call_FormBilinear(* dynamic_cast *>(p))) ; - return new Op(to **>(args[0]),args[1],init);} - - OpHMatrixtoBEMForm(int initt=0) : - OneOperator(atype **>(),atype **>(),atype*>()), - init(initt) - {} - + AnyType operator( )(Stack s) const; + + Op(Expression aa, Expression bb, int initt) : b(new Call_FormBilinear< v_fes1, v_fes2 >(*dynamic_cast< const Call_FormBilinear< v_fes1, v_fes2 > * >(bb))), a(aa), init(initt) { + assert(b && b->nargs); + + // Check the nbitem of inconnu and test in BemFormBilinear + checkNbItemFEspacesInconnuAndTest(b->largs, b->N, b->M); + } + operator aType( ) const { return atype< HMatrixVirt< R > ** >( ); } + }; + + E_F0 *code(const basicAC_F0 &args) const { + Expression p = args[1]; + Call_FormBilinear< v_fes1, v_fes2 > *t(new Call_FormBilinear< v_fes1, v_fes2 >(*dynamic_cast< const Call_FormBilinear< v_fes1, v_fes2 > * >(p))); + return new Op(to< HMatrixVirt< R > ** >(args[0]), args[1], init); + } + + OpHMatrixtoBEMForm(int initt = 0) : OneOperator(atype< HMatrixVirt< R > ** >( ), atype< HMatrixVirt< R > ** >( ), atype< const Call_FormBilinear< v_fes1, v_fes2 > * >( )), init(initt) {} }; // the operator -template -AnyType OpHMatrixtoBEMForm::Op::operator()(Stack stack) const -{ - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes2::pfes pfes2; - typedef typename v_fes1::FESpace FESpace1; - typedef typename v_fes2::FESpace FESpace2; - typedef typename FESpace1::Mesh SMesh; - typedef typename FESpace2::Mesh TMesh; - typedef typename SMesh::RdHat SRdHat; - typedef typename TMesh::RdHat TRdHat; - - - typedef typename std::conditional::type MeshBemtool; - typedef typename std::conditional::type P0; - typedef typename std::conditional::type P1; - typedef typename std::conditional::type P2; - - assert(b && b->nargs); - const list & largs=b->largs; - - // FE space - pfes1 * pUh= GetAny((*b->euh)(stack)); - FESpace1 * Uh = **pUh; - - pfes2 * pVh= GetAny((*b->evh)(stack)); - FESpace2 * Vh = **pVh; - - int NUh =Uh->N; - int NVh =Vh->N; - - ffassert(Vh); - ffassert(Uh); - - int n=Uh->NbOfDF; - int m=Vh->NbOfDF; - - // VFBEM =1 kernel VF =2 Potential VF - int VFBEM = typeVFBEM(largs,stack); - if (mpirank == 0 && verbosity>5) - cout << "test VFBEM type (1 kernel / 2 potential) " << VFBEM << endl; - - - HMatrixVirt** Hmat =GetAny** >((*a)(stack)); - - // info about HMatrix and type solver - Data_Bem_Solver ds; - ds.factorize=0; - ds.initmat=true; - SetEnd_Data_Bem_Solver(stack,ds, b->nargs,OpCall_FormBilinear_np::n_name_param); // LIST_NAME_PARM_HMAT - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack); - - bool samemesh = (void*)&Uh->Th == (void*)&Vh->Th; // same Fem2D::Mesh +++ pot or kernel - if (VFBEM==1) - ffassert (samemesh); - if(init) - *Hmat =0; - *Hmat =0; - if( *Hmat) - delete *Hmat; - *Hmat =0; - - creationHMatrixtoBEMForm( Uh, Vh, VFBEM, largs, stack, ds, Hmat); - - return Hmat; +template< class R, class MMesh, class v_fes1, class v_fes2 > +AnyType OpHMatrixtoBEMForm< R, MMesh, v_fes1, v_fes2 >::Op::operator( )(Stack stack) const { + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes2::pfes pfes2; + typedef typename v_fes1::FESpace FESpace1; + typedef typename v_fes2::FESpace FESpace2; + typedef typename FESpace1::Mesh SMesh; + typedef typename FESpace2::Mesh TMesh; + typedef typename SMesh::RdHat SRdHat; + typedef typename TMesh::RdHat TRdHat; + + typedef typename std::conditional< SMesh::RdHat::d == 1, Mesh1D, Mesh2D >::type MeshBemtool; + typedef typename std::conditional< SMesh::RdHat::d == 1, P0_1D, P0_2D >::type P0; + typedef typename std::conditional< SMesh::RdHat::d == 1, P1_1D, P1_2D >::type P1; + typedef typename std::conditional< SMesh::RdHat::d == 1, P2_1D, P2_2D >::type P2; + + assert(b && b->nargs); + const list< C_F0 > &largs = b->largs; + + // FE space + pfes1 *pUh = GetAny< pfes1 * >((*b->euh)(stack)); + FESpace1 *Uh = **pUh; + + pfes2 *pVh = GetAny< pfes2 * >((*b->evh)(stack)); + FESpace2 *Vh = **pVh; + + int NUh = Uh->N; + int NVh = Vh->N; + + ffassert(Vh); + ffassert(Uh); + + int n = Uh->NbOfDF; + int m = Vh->NbOfDF; + + // VFBEM =1 kernel VF =2 Potential VF + int VFBEM = typeVFBEM(largs, stack); + if (mpirank == 0 && verbosity > 5) cout << "test VFBEM type (1 kernel / 2 potential) " << VFBEM << endl; + + HMatrixVirt< R > **Hmat = GetAny< HMatrixVirt< R > ** >((*a)(stack)); + + // info about HMatrix and type solver + Data_Bem_Solver ds; + ds.factorize = 0; + ds.initmat = true; + SetEnd_Data_Bem_Solver< R >(stack, ds, b->nargs, OpCall_FormBilinear_np::n_name_param); // LIST_NAME_PARM_HMAT + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); + + bool samemesh = (void *)&Uh->Th == (void *)&Vh->Th; // same Fem2D::Mesh +++ pot or kernel + if (VFBEM == 1) ffassert(samemesh); + if (init) *Hmat = 0; + *Hmat = 0; + if (*Hmat) delete *Hmat; + *Hmat = 0; + + creationHMatrixtoBEMForm< R, MMesh, FESpace1, FESpace2 >(Uh, Vh, VFBEM, largs, stack, ds, Hmat); + + return Hmat; } -bool C_args::IsBemBilinearOperator() const { -for (const_iterator i=largs.begin(); i != largs.end();i++) { - C_F0 c= *i; - aType r=c.left(); - if ( r!= atype() ) - return false; +bool C_args::IsBemBilinearOperator( ) const { + for (const_iterator i = largs.begin( ); i != largs.end( ); i++) { + C_F0 c = *i; + aType r = c.left( ); + if (r != atype< const class BemFormBilinear * >( )) return false; + } + return true; } -return true;} // bem + fem -bool C_args::IsMixedBilinearOperator() const { -if ( this->IsBilinearOperator() && this->IsBemBilinearOperator() ) return true; - -return false;} - - - +bool C_args::IsMixedBilinearOperator( ) const { + if (this->IsBilinearOperator( ) && this->IsBemBilinearOperator( )) return true; + return false; +} +EquationEnum whatEquationEnum(BemKernel *K, int i) { + int nk = 2; // restriction, max 2 kernels for combined + int type[2] = {-1, -1}; + EquationEnum equation[3] = {LA, HE, YU}; + double wavenumRe, wavenumImag; + + for (int i = 0; i < nk; i++) { + wavenumRe = K->wavenum[i].real( ); + wavenumImag = K->wavenum[i].imag( ); + if (wavenumRe == 0 && wavenumImag == 0) + type[i] = 0; + else if (wavenumRe > 0 && wavenumImag == 0) + type[i] = 1; + else if (wavenumRe == 0 && wavenumImag > 0) + type[i] = 2; + } + if (type[0] - type[1]) { + cerr << "Error, the combined kernels must be the same equation " << equation[type[0]] << " " << equation[type[1]] << endl; + throw(ErrorExec("exit", 1)); + } -EquationEnum whatEquationEnum(BemKernel *K,int i) { - int nk=2; // restriction, max 2 kernels for combined - int type[2]={-1,-1}; - EquationEnum equation[3] = {LA,HE,YU}; - double wavenumRe, wavenumImag; - - for (int i=0;iwavenum[i].real(); wavenumImag=K->wavenum[i].imag(); - if(wavenumRe==0 && wavenumImag==0) type[i] = 0; - else if(wavenumRe>0 && wavenumImag==0) type[i] = 1; - else if(wavenumRe==0 && wavenumImag>0) type[i] = 2; - } - if(type[0]-type[1]) { - cerr << "Error, the combined kernels must be the same equation " << equation[type[0]] << " " << equation[type[1]] << endl; - throw(ErrorExec("exit",1));} - - const EquationEnum equEnum = equation[0]; - return equEnum; - + const EquationEnum equEnum = equation[0]; + return equEnum; } // Begin Array of HMatrix[int] template< class A > @@ -705,8 +653,7 @@ inline AnyType DestroyKNmat(Stack, const AnyType &x) { template< class RR, class A, class B > RR *get_elementp_(const A &a, const B &b) { if (b < 0 || a->N( ) <= b) { - cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) - << endl; + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) << endl; ExecError("Out of bound in operator []"); } return &((*a)[b]); @@ -720,352 +667,327 @@ R *set_initinit(R *const &a, const long &n) { return a; } -template -void ArrayofHmat() -{ - typedef HMatrixVirt< R > *Mat; - typedef Mat *PMat; - typedef KN< Mat > AMat; - - Dcl_Type< AMat * >(0, ::DestroyKNmat< Mat >); - // to declare HMatrix[int] - map_type_of_map[make_pair(atype< long >( ), atype< PMat >( )->right())] = atype< AMat * >( ); - atype< AMat * >( )->Add( - "[", "", - new OneOperator2_< PMat, AMat *, long >(get_elementp_< Mat, AMat *, long >)); - - TheOperators->Add("<-", new OneOperator2_< AMat*, AMat* , long >(&set_initinit)); - - - // resize mars 2006 v2.4-1 - Dcl_Type< Resize< AMat > >( ); - Add< AMat *>("resize", ".", - new OneOperator1< Resize< AMat >, AMat * >(to_Resize)); - Add< Resize< AMat > >( - "(", "", new OneOperator2_< AMat*, Resize< AMat >, long >(resizeandclean1)); - +template< class R > +void ArrayofHmat( ) { + typedef HMatrixVirt< R > *Mat; + typedef Mat *PMat; + typedef KN< Mat > AMat; + + Dcl_Type< AMat * >(0, ::DestroyKNmat< Mat >); + // to declare HMatrix[int] + map_type_of_map[make_pair(atype< long >( ), atype< PMat >( )->right( ))] = atype< AMat * >( ); + atype< AMat * >( )->Add("[", "", new OneOperator2_< PMat, AMat *, long >(get_elementp_< Mat, AMat *, long >)); + + TheOperators->Add("<-", new OneOperator2_< AMat *, AMat *, long >(&set_initinit)); + + // resize mars 2006 v2.4-1 + Dcl_Type< Resize< AMat > >( ); + Add< AMat * >("resize", ".", new OneOperator1< Resize< AMat >, AMat * >(to_Resize)); + Add< Resize< AMat > >("(", "", new OneOperator2_< AMat *, Resize< AMat >, long >(resizeandclean1)); } // End Array of HMatrix[int] -template -class OpHMatrixUser : public OneOperator -{ - public: - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes2::pfes pfes2; - class Op : public E_F0info { - public: - Expression g, uh1, uh2; - static const int n_name_param = 11; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - long argl(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long argb(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - string* args(int i,Stack stack,string* a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - double arg(int i,Stack stack,double a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - pcommworld argc(int i,Stack stack,pcommworld a ) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - Op(const basicAC_F0 & args, Expression bb, Expression cc, Expression dd) : g(bb),uh1(cc), uh2(dd) { - args.SetNameParam(n_name_param,name_param,nargs); - } - }; - - E_F0 * code(const basicAC_F0 & args) const { - return new Op(args,t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2])); - } - - OpHMatrixUser() : - OneOperator(atype::Op*>(),atype**>(),atype(),atype()) {} +template< class R, class v_fes1, class v_fes2 > +class OpHMatrixUser : public OneOperator { + public: + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes2::pfes pfes2; + class Op : public E_F0info { + public: + Expression g, uh1, uh2; + static const int n_name_param = 11; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + long argl(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + long argb(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + string *args(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + pcommworld argc(int i, Stack stack, pcommworld a) const { return nargs[i] ? GetAny< pcommworld >((*nargs[i])(stack)) : a; } + Op(const basicAC_F0 &args, Expression bb, Expression cc, Expression dd) : g(bb), uh1(cc), uh2(dd) { args.SetNameParam(n_name_param, name_param, nargs); } + }; + + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + + OpHMatrixUser( ) : OneOperator(atype< const typename OpHMatrixUser< R, v_fes1, v_fes2 >::Op * >( ), atype< VirtualGenerator< R > ** >( ), atype< pfes1 * >( ), atype< pfes2 * >( )) {} }; -template -basicAC_F0::name_and_type OpHMatrixUser::Op::name_param[]= { - { "eps", &typeid(double)}, - { "commworld", &typeid(pcommworld)}, - { "eta", &typeid(double)}, - { "maxleafsize", &typeid(long)}, - { "mintargetdepth", &typeid(long)}, - { "minsourcedepth", &typeid(long)}, - { "compressor", &typeid(string*)}, - { "recompress", &typeid(bool)}, - { "initialclustering", &typeid(string*)}, - { "clusteringdirections", &typeid(string*)}, - { "adaptiveclustering", &typeid(bool)} -}; - -template -AnyType SetOpHMatrixUser(Stack stack,Expression emat, Expression eop) -{ - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes2::pfes pfes2; - typedef typename v_fes1::FESpace FESpace1; - typedef typename v_fes2::FESpace FESpace2; - typedef typename FESpace1::Mesh SMesh; - typedef typename FESpace2::Mesh TMesh; - typedef typename SMesh::RdHat SRdHat; - typedef typename TMesh::RdHat TRdHat; - - typedef typename OpHMatrixUser::Op UOp; - const UOp * op(dynamic_cast(eop)); - pfes1 * pUh= GetAny((*op->uh1)(stack)); - FESpace1 * Uh = **pUh; - int NUh =Uh->N; - pfes2 * pVh= GetAny((*op->uh2)(stack)); - FESpace2 * Vh = **pVh; - int NVh =Vh->N; - ffassert(Vh); - ffassert(Uh); - - int m=Uh->NbOfDF; - int n=Vh->NbOfDF; - - HMatrixVirt** Hmat =GetAny** >((*emat)(stack)); - - Data_Bem_Solver ds; - ds.factorize=0; - ds.initmat=true; - - ds.epsilon = op->arg(0,stack,ds.epsilon); - ds.commworld = op->argc(1,stack,ds.commworld); - ds.eta = op->arg(2,stack,ds.eta); - ds.maxleafsize = op->argl(3,stack,ds.maxleafsize); - ds.mintargetdepth = op->argl(4,stack,ds.mintargetdepth); - ds.minsourcedepth = op->argl(5,stack,ds.minsourcedepth); - ds.compressor = *(op->args(6,stack,&ds.compressor)); - ds.recompress = op->argb(7,stack,ds.recompress); - ds.initialclustering = *(op->args(8,stack,&ds.initialclustering)); - ds.clusteringdirections = *(op->args(9,stack,&ds.clusteringdirections)); - ds.adaptiveclustering = op->argb(10,stack,ds.adaptiveclustering); - - const SMesh & ThU =Uh->Th; - const TMesh & ThV =Vh->Th; - bool samemesh = (void*)&Uh->Th == (void*)&Vh->Th; - - if(init) - *Hmat =0; - *Hmat =0; - if( *Hmat) - delete *Hmat; - - *Hmat =0; - - vector pt(3*n); - vector ps(3*m); - Fem2D::R3 pp; - bemtool::R3 p; - SRdHat pbs; - TRdHat pbt; - pbs[0] = 1./(SRdHat::d+1); - pbs[1] = 1./(SRdHat::d+1); - if (SRdHat::d == 3) pbs[2] = 1./(SRdHat::d+1); - pbt[0] = 1./(TRdHat::d+1); - pbt[1] = 1./(TRdHat::d+1); - if (TRdHat::d == 3) pbt[2] = 1./(TRdHat::d+1); - - int Snbv = Uh->TFE[0]->ndfonVertex; - int Snbe = Uh->TFE[0]->ndfonEdge; - int Snbt = Uh->TFE[0]->ndfonFace; - bool SP0 = SRdHat::d == 1 ? (Snbv == 0) && (Snbe == 1) && (Snbt == 0) : (Snbv == 0) && (Snbe == 0) && (Snbt == 1); - bool SP1 = (Snbv == 1) && (Snbe == 0) && (Snbt == 0); - - int Tnbv = Vh->TFE[0]->ndfonVertex; - int Tnbe = Vh->TFE[0]->ndfonEdge; - int Tnbt = Vh->TFE[0]->ndfonFace; - bool TP0 = TRdHat::d == 1 ? (Tnbv == 0) && (Tnbe == 1) && (Tnbt == 0) : (Tnbv == 0) && (Tnbe == 0) && (Tnbt == 1); - bool TP1 = (Tnbv == 1) && (Tnbe == 0) && (Tnbt == 0); - - for (int i=0; i +basicAC_F0::name_and_type OpHMatrixUser< K, v_fes1, v_fes2 >::Op::name_param[] = {{"eps", &typeid(double)}, + {"commworld", &typeid(pcommworld)}, + {"eta", &typeid(double)}, + {"maxleafsize", &typeid(long)}, + {"mintargetdepth", &typeid(long)}, + {"minsourcedepth", &typeid(long)}, + {"compressor", &typeid(string *)}, + {"recompress", &typeid(bool)}, + {"initialclustering", &typeid(string *)}, + {"clusteringdirections", &typeid(string *)}, + {"adaptiveclustering", &typeid(bool)}}; + +template< class R, class v_fes1, class v_fes2, int init > +AnyType SetOpHMatrixUser(Stack stack, Expression emat, Expression eop) { + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes2::pfes pfes2; + typedef typename v_fes1::FESpace FESpace1; + typedef typename v_fes2::FESpace FESpace2; + typedef typename FESpace1::Mesh SMesh; + typedef typename FESpace2::Mesh TMesh; + typedef typename SMesh::RdHat SRdHat; + typedef typename TMesh::RdHat TRdHat; + + typedef typename OpHMatrixUser< R, v_fes1, v_fes2 >::Op UOp; + const UOp *op(dynamic_cast< const UOp * >(eop)); + pfes1 *pUh = GetAny< pfes1 * >((*op->uh1)(stack)); + FESpace1 *Uh = **pUh; + int NUh = Uh->N; + pfes2 *pVh = GetAny< pfes2 * >((*op->uh2)(stack)); + FESpace2 *Vh = **pVh; + int NVh = Vh->N; + ffassert(Vh); + ffassert(Uh); + + int m = Uh->NbOfDF; + int n = Vh->NbOfDF; + + HMatrixVirt< R > **Hmat = GetAny< HMatrixVirt< R > ** >((*emat)(stack)); + + Data_Bem_Solver ds; + ds.factorize = 0; + ds.initmat = true; + + ds.epsilon = op->arg(0, stack, ds.epsilon); + ds.commworld = op->argc(1, stack, ds.commworld); + ds.eta = op->arg(2, stack, ds.eta); + ds.maxleafsize = op->argl(3, stack, ds.maxleafsize); + ds.mintargetdepth = op->argl(4, stack, ds.mintargetdepth); + ds.minsourcedepth = op->argl(5, stack, ds.minsourcedepth); + ds.compressor = *(op->args(6, stack, &ds.compressor)); + ds.recompress = op->argb(7, stack, ds.recompress); + ds.initialclustering = *(op->args(8, stack, &ds.initialclustering)); + ds.clusteringdirections = *(op->args(9, stack, &ds.clusteringdirections)); + ds.adaptiveclustering = op->argb(10, stack, ds.adaptiveclustering); + + const SMesh &ThU = Uh->Th; + const TMesh &ThV = Vh->Th; + bool samemesh = (void *)&Uh->Th == (void *)&Vh->Th; + + if (init) *Hmat = 0; + *Hmat = 0; + if (*Hmat) delete *Hmat; + + *Hmat = 0; + + vector< double > pt(3 * n); + vector< double > ps(3 * m); + Fem2D::R3 pp; + bemtool::R3 p; + SRdHat pbs; + TRdHat pbt; + pbs[0] = 1. / (SRdHat::d + 1); + pbs[1] = 1. / (SRdHat::d + 1); + if (SRdHat::d == 3) pbs[2] = 1. / (SRdHat::d + 1); + pbt[0] = 1. / (TRdHat::d + 1); + pbt[1] = 1. / (TRdHat::d + 1); + if (TRdHat::d == 3) pbt[2] = 1. / (TRdHat::d + 1); + + int Snbv = Uh->TFE[0]->ndfonVertex; + int Snbe = Uh->TFE[0]->ndfonEdge; + int Snbt = Uh->TFE[0]->ndfonFace; + bool SP0 = SRdHat::d == 1 ? (Snbv == 0) && (Snbe == 1) && (Snbt == 0) : (Snbv == 0) && (Snbe == 0) && (Snbt == 1); + bool SP1 = (Snbv == 1) && (Snbe == 0) && (Snbt == 0); + + int Tnbv = Vh->TFE[0]->ndfonVertex; + int Tnbe = Vh->TFE[0]->ndfonEdge; + int Tnbt = Vh->TFE[0]->ndfonFace; + bool TP0 = TRdHat::d == 1 ? (Tnbv == 0) && (Tnbe == 1) && (Tnbt == 0) : (Tnbv == 0) && (Tnbe == 0) && (Tnbt == 1); + bool TP1 = (Tnbv == 1) && (Tnbe == 0) && (Tnbt == 0); + + for (int i = 0; i < m; i++) { + if (SP1) + pp = ThU.vertices[i]; + else if (SP0) + pp = ThU[i](pbs); + else { + if (mpirank == 0) std::cerr << "ff-Htool error: only P0 and P1 discretizations are available for now." << std::endl; + ffassert(0); } + ps[3 * i + 0] = pp.x; + ps[3 * i + 1] = pp.y; + ps[3 * i + 2] = pp.z; + } - if(!samemesh) { - for (int i=0; i** generator = GetAny**>((*op->g)(stack)); + VirtualGenerator< R > **generator = GetAny< VirtualGenerator< R > ** >((*op->g)(stack)); - MPI_Comm comm = ds.commworld ? *(MPI_Comm*)ds.commworld : MPI_COMM_WORLD; - std::shared_ptr> t, s; - s = build_clustering(m, Uh, ps, ds, comm); - t = build_clustering(n, Vh, pt, ds, comm); - buildHmat(Hmat, *generator, ds, t, s, pt, ps, comm); + MPI_Comm comm = ds.commworld ? *(MPI_Comm *)ds.commworld : MPI_COMM_WORLD; + std::shared_ptr< Cluster< double > > t, s; + s = build_clustering(m, Uh, ps, ds, comm); + t = build_clustering(n, Vh, pt, ds, comm); + buildHmat(Hmat, *generator, ds, t, s, pt, ps, comm); - return Hmat; + return Hmat; } -template -void AddHMatrixUser() { - typedef typename OpHMatrixUser< R, v_fes1, v_fes2 >::Op OpT; - Dcl_Type(); - Global.Add("Build","(", new OpHMatrixUser< R, v_fes1, v_fes2 >); - Add("<-","(", new OpHMatrixUser< R, v_fes1, v_fes2 >); - TheOperators->Add("<-", new OneOperator2_**,HMatrixVirt**,const OpT*,E_F_StackF0F0>(SetOpHMatrixUser)); - TheOperators->Add("=", new OneOperator2_**,HMatrixVirt**,const OpT*,E_F_StackF0F0>(SetOpHMatrixUser)); +template< class R, class v_fes1, class v_fes2 > +void AddHMatrixUser( ) { + typedef typename OpHMatrixUser< R, v_fes1, v_fes2 >::Op OpT; + Dcl_Type< const OpT * >( ); + Global.Add("Build", "(", new OpHMatrixUser< R, v_fes1, v_fes2 >); + Add< const OpT * >("<-", "(", new OpHMatrixUser< R, v_fes1, v_fes2 >); + TheOperators->Add("<-", new OneOperator2_< HMatrixVirt< R > **, HMatrixVirt< R > **, const OpT *, E_F_StackF0F0 >(SetOpHMatrixUser< R, v_fes1, v_fes2, 0 >)); + TheOperators->Add("=", new OneOperator2_< HMatrixVirt< R > **, HMatrixVirt< R > **, const OpT *, E_F_StackF0F0 >(SetOpHMatrixUser< R, v_fes1, v_fes2, 1 >)); } -static void Init_Bem() { - if(mpirank == 0 && verbosity > 0) cout << "\nInit_Bem\n"; - - map_type[typeid(const BemFormBilinear *).name( )] = new TypeFormBEM; - - map_type[typeid(const BemKFormBilinear *).name( )] = new ForEachType< BemKFormBilinear >; - map_type[typeid(const BemPFormBilinear *).name( )] = new ForEachType< BemPFormBilinear >; - - basicForEachType *t_BEM = atype< const C_args * >( ); //atype< const BemFormBilinear * >( ); - basicForEachType *t_fbem = atype< const BemFormBilinear * >( ); - aType t_C_args = map_type[typeid(const C_args *).name( )]; - atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, t_fbem) ); // bad - - typedef const BemKernel fkernel; - typedef const BemPotential fpotential; - // new type for bem - typedef const BemKernel *pBemKernel; - typedef const BemPotential *pBemPotential; - - - // Dcl_Type< fkernel * >( ); // a bem kernel - // Dcl_Type< fpotential * >( ); // a bem potential - Dcl_Type< const OP_MakeBemKernelFunc::Op * >( ); - Dcl_Type< const OP_MakeBemPotentialFunc::Op * >( ); - - Dcl_TypeandPtr< pBemKernel >(0, 0, ::InitializePtr< pBemKernel >, ::DestroyPtr< pBemKernel >, - AddIncrement< pBemKernel >, NotReturnOfthisType); - // pBemPotential initialize - Dcl_TypeandPtr< pBemPotential >(0, 0, ::InitializePtr< pBemPotential >, ::DestroyPtr< pBemPotential >, - AddIncrement< pBemPotential >, NotReturnOfthisType); - - - zzzfff->Add("BemKernel", atype< pBemKernel * >( )); - zzzfff->Add("BemPotential", atype< pBemPotential * >( )); - - // pBemKernel initialize - atype()->AddCast( new E_F1_funcT(UnRef)); - // BemPotential - atype()->AddCast( new E_F1_funcT(UnRef)); - - - // simplified type/function to define varf bem - Dcl_Type< const FoperatorKBEM * >( ); - Dcl_Type< const FoperatorPBEM * >( ); - Dcl_Type*>( ); - - TheOperators->Add("<<",new OneBinaryOperator*>>); - Add*>("[","",new OneOperator2_*, string*>(get_info)); - - addHmat(); - addHmat>(); - - //BemKernel - TheOperators->Add("<-", new OneOperatorCode< OP_MakeBemKernel >); - //BemPotential - TheOperators->Add("<-", new OneOperatorCode< OP_MakeBemPotential >); - - zzzfff->Add("HMatrix", atype **>()); - map_type_of_map[make_pair(atype**>(), atype())] = atype**>(); - map_type_of_map[make_pair(atype**>(), atype())] = atype >**>(); - // bem integration space/target space must be review Axel 08/2020 - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fesS > (1) ); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fesS > ); - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fes3 > (1) ); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fes3 > ); - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fesL > (1) ); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fesL > ); - - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fes > (1) ); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fes > ); - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fesS > (1) ); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshL, v_fesL, v_fesS > ); - - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fes > (1)); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fes > ); - TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fesL > (1)); - TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex, MeshS, v_fesS, v_fesL > ); - - // operation on BemKernel - Dcl_Type (); - TheOperators->Add("+",new OneBinaryOperator_st< Op_addBemKernel >); - //TheOperators->Add("+",new OneBinaryOperator_st< Op_addBemKernel >); // no need is the combinaison is only with 2 kernels - - TheOperators->Add("=",new OneBinaryOperator_st< Op_setBemKernel >); - TheOperators->Add("<-", new OneBinaryOperator_st< Op_setBemKernel >); - - TheOperators->Add("=",new OneBinaryOperator_st< Op_setCombBemKernel >); - TheOperators->Add("<-", new OneBinaryOperator_st< Op_setCombBemKernel >); - - TheOperators->Add("*",new OneBinaryOperator_st< Op_coeffBemKernel1 >); - - Dcl_Type< const CBemDomainOfIntegration * >( ); - Dcl_Type< const CPartBemDI * >( ); - - Add< const CPartBemDI * >("(", "", new OneOperatorCode< CBemDomainOfIntegration >); - - Add< const CBemDomainOfIntegration * >("(", "", new OneOperatorCode< BemKFormBilinear >); - Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< BemPFormBilinear >); - - Global.Add("BEM","(",new FormalKBEMcode); - Global.Add("BEM","(",new FormalKBEMcodeArray); - Global.Add("POT","(",new FormalPBEMcode); - Global.Add("POT","(",new FormalPBEMcodeArray); - // Global.Add("Kernel","(",new FormalBemKernel); - Add< pBemKernel >("<--","(",new FormalBemKernel); -// Global.Add("Potential","(",new FormalBemPotential); - Add< pBemPotential >("<--","(",new FormalBemPotential); - - Global.Add("int2dx2d","(",new OneOperatorCode); - Global.Add("int1dx1d","(",new OneOperatorCode); - Global.Add("int1dx2d","(",new OneOperatorCode); - Global.Add("int2dx1d","(",new OneOperatorCode); - - Global.New("htoolEta",CPValue(ff_htoolEta)); - Global.New("htoolEpsilon",CPValue(ff_htoolEpsilon)); - Global.New("htoolMaxleafsize",CPValue(ff_htoolMaxleafsize)); - Global.New("htoolMintargetdepth",CPValue(ff_htoolMintargetdepth)); - Global.New("htoolMinsourcedepth",CPValue(ff_htoolMinsourcedepth)); - ArrayofHmat(); - ArrayofHmat>(); - - // Build HMatrix from custom user generator - Dcl_TypeandPtr< VirtualGenerator* >(0, 0,::InitializePtr< VirtualGenerator* >, ::DeletePtr< VirtualGenerator*> ); - Dcl_TypeandPtr< VirtualGenerator>* >(0, 0,::InitializePtr< VirtualGenerator>* >, ::DeletePtr< VirtualGenerator>*> ); - zzzfff->Add("Generator", atype** >( )); - map_type_of_map[make_pair(atype**>(), atype())] = atype**>(); - map_type_of_map[make_pair(atype**>(), atype())] = atype >**>(); - - AddHMatrixUser(); - AddHMatrixUser(); - AddHMatrixUser(); - AddHMatrixUser,v_fesL, v_fesL>(); - AddHMatrixUser,v_fesS, v_fesS>(); - AddHMatrixUser,v_fes3, v_fes3>(); - AddHMatrixUser(); - AddHMatrixUser(); - AddHMatrixUser,v_fesL, v_fesS>(); - AddHMatrixUser,v_fesS, v_fes3>(); +static void Init_Bem( ) { + if (mpirank == 0 && verbosity > 0) cout << "\nInit_Bem\n"; + + map_type[typeid(const BemFormBilinear *).name( )] = new TypeFormBEM; + + map_type[typeid(const BemKFormBilinear *).name( )] = new ForEachType< BemKFormBilinear >; + map_type[typeid(const BemPFormBilinear *).name( )] = new ForEachType< BemPFormBilinear >; + + basicForEachType *t_BEM = atype< const C_args * >( ); // atype< const BemFormBilinear * >( ); + basicForEachType *t_fbem = atype< const BemFormBilinear * >( ); + aType t_C_args = map_type[typeid(const C_args *).name( )]; + atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, t_fbem)); // bad + + typedef const BemKernel fkernel; + typedef const BemPotential fpotential; + // new type for bem + typedef const BemKernel *pBemKernel; + typedef const BemPotential *pBemPotential; + + // Dcl_Type< fkernel * >( ); // a bem kernel + // Dcl_Type< fpotential * >( ); // a bem potential + Dcl_Type< const OP_MakeBemKernelFunc::Op * >( ); + Dcl_Type< const OP_MakeBemPotentialFunc::Op * >( ); + + Dcl_TypeandPtr< pBemKernel >(0, 0, ::InitializePtr< pBemKernel >, ::DestroyPtr< pBemKernel >, AddIncrement< pBemKernel >, NotReturnOfthisType); + // pBemPotential initialize + Dcl_TypeandPtr< pBemPotential >(0, 0, ::InitializePtr< pBemPotential >, ::DestroyPtr< pBemPotential >, AddIncrement< pBemPotential >, NotReturnOfthisType); + + zzzfff->Add("BemKernel", atype< pBemKernel * >( )); + zzzfff->Add("BemPotential", atype< pBemPotential * >( )); + + // pBemKernel initialize + atype< pBemKernel >( )->AddCast(new E_F1_funcT< pBemKernel, pBemKernel * >(UnRef< pBemKernel >)); + // BemPotential + atype< pBemPotential >( )->AddCast(new E_F1_funcT< pBemPotential, pBemPotential * >(UnRef< pBemPotential >)); + + // simplified type/function to define varf bem + Dcl_Type< const FoperatorKBEM * >( ); + Dcl_Type< const FoperatorPBEM * >( ); + Dcl_Type< std::map< std::string, std::string > * >( ); + + TheOperators->Add("<<", new OneBinaryOperator< PrintPinfos< std::map< std::string, std::string > * > >); + Add< std::map< std::string, std::string > * >("[", "", new OneOperator2_< string *, std::map< std::string, std::string > *, string * >(get_info)); + + addHmat< double >( ); + addHmat< std::complex< double > >( ); + + // BemKernel + TheOperators->Add("<-", new OneOperatorCode< OP_MakeBemKernel >); + // BemPotential + TheOperators->Add("<-", new OneOperatorCode< OP_MakeBemPotential >); + + zzzfff->Add("HMatrix", atype< HMatrixVirt< double > ** >( )); + map_type_of_map[make_pair(atype< HMatrixVirt< double > ** >( ), atype< double * >( ))] = atype< HMatrixVirt< double > ** >( ); + map_type_of_map[make_pair(atype< HMatrixVirt< double > ** >( ), atype< Complex * >( ))] = atype< HMatrixVirt< std::complex< double > > ** >( ); + // bem integration space/target space must be review Axel 08/2020 + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fesS >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fesS >); + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fes3 >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fes3 >); + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fesL >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fesL >); + + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fes >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fes >); + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fesS >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshL, v_fesL, v_fesS >); + + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fes >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fes >); + TheOperators->Add("<-", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fesL >(1)); + TheOperators->Add("=", new OpHMatrixtoBEMForm< std::complex< double >, MeshS, v_fesS, v_fesL >); + + // operation on BemKernel + Dcl_Type< listBemKernel >( ); + TheOperators->Add("+", new OneBinaryOperator_st< Op_addBemKernel< listBemKernel, pBemKernel, pBemKernel > >); + // TheOperators->Add("+",new OneBinaryOperator_st< Op_addBemKernel >); // no need is the combinaison is only with 2 kernels + + TheOperators->Add("=", new OneBinaryOperator_st< Op_setBemKernel< false, pBemKernel *, pBemKernel *, pBemKernel > >); + TheOperators->Add("<-", new OneBinaryOperator_st< Op_setBemKernel< true, pBemKernel *, pBemKernel *, pBemKernel > >); + + TheOperators->Add("=", new OneBinaryOperator_st< Op_setCombBemKernel< false, pBemKernel *, pBemKernel *, listBemKernel > >); + TheOperators->Add("<-", new OneBinaryOperator_st< Op_setCombBemKernel< true, pBemKernel *, pBemKernel *, listBemKernel > >); + + TheOperators->Add("*", new OneBinaryOperator_st< Op_coeffBemKernel1< pBemKernel, Complex, pBemKernel > >); + + Dcl_Type< const CBemDomainOfIntegration * >( ); + Dcl_Type< const CPartBemDI * >( ); + + Add< const CPartBemDI * >("(", "", new OneOperatorCode< CBemDomainOfIntegration >); + + Add< const CBemDomainOfIntegration * >("(", "", new OneOperatorCode< BemKFormBilinear >); + Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< BemPFormBilinear >); + + Global.Add("BEM", "(", new FormalKBEMcode); + Global.Add("BEM", "(", new FormalKBEMcodeArray); + Global.Add("POT", "(", new FormalPBEMcode); + Global.Add("POT", "(", new FormalPBEMcodeArray); + // Global.Add("Kernel","(",new FormalBemKernel); + Add< pBemKernel >("<--", "(", new FormalBemKernel); + // Global.Add("Potential","(",new FormalBemPotential); + Add< pBemPotential >("<--", "(", new FormalBemPotential); + + Global.Add("int2dx2d", "(", new OneOperatorCode< CPartBemDI2d2d >); + Global.Add("int1dx1d", "(", new OneOperatorCode< CPartBemDI1d1d >); + Global.Add("int1dx2d", "(", new OneOperatorCode< CPartBemDI1d2d >); + Global.Add("int2dx1d", "(", new OneOperatorCode< CPartBemDI2d1d >); + + Global.New("htoolEta", CPValue< double >(ff_htoolEta)); + Global.New("htoolEpsilon", CPValue< double >(ff_htoolEpsilon)); + Global.New("htoolMaxleafsize", CPValue< long >(ff_htoolMaxleafsize)); + Global.New("htoolMintargetdepth", CPValue< long >(ff_htoolMintargetdepth)); + Global.New("htoolMinsourcedepth", CPValue< long >(ff_htoolMinsourcedepth)); + ArrayofHmat< double >( ); + ArrayofHmat< complex< double > >( ); + + // Build HMatrix from custom user generator + Dcl_TypeandPtr< VirtualGenerator< double > * >(0, 0, ::InitializePtr< VirtualGenerator< double > * >, ::DeletePtr< VirtualGenerator< double > * >); + Dcl_TypeandPtr< VirtualGenerator< std::complex< double > > * >(0, 0, ::InitializePtr< VirtualGenerator< std::complex< double > > * >, ::DeletePtr< VirtualGenerator< std::complex< double > > * >); + zzzfff->Add("Generator", atype< VirtualGenerator< double > ** >( )); + map_type_of_map[make_pair(atype< VirtualGenerator< double > ** >( ), atype< double * >( ))] = atype< VirtualGenerator< double > ** >( ); + map_type_of_map[make_pair(atype< VirtualGenerator< double > ** >( ), atype< Complex * >( ))] = atype< VirtualGenerator< std::complex< double > > ** >( ); + + AddHMatrixUser< double, v_fesL, v_fesL >( ); + AddHMatrixUser< double, v_fesS, v_fesS >( ); + AddHMatrixUser< double, v_fes3, v_fes3 >( ); + AddHMatrixUser< std::complex< double >, v_fesL, v_fesL >( ); + AddHMatrixUser< std::complex< double >, v_fesS, v_fesS >( ); + AddHMatrixUser< std::complex< double >, v_fes3, v_fes3 >( ); + AddHMatrixUser< double, v_fesL, v_fesS >( ); + AddHMatrixUser< double, v_fesS, v_fes3 >( ); + AddHMatrixUser< std::complex< double >, v_fesL, v_fesS >( ); + AddHMatrixUser< std::complex< double >, v_fesS, v_fes3 >( ); } LOADFUNC(Init_Bem) - diff --git a/plugin/mpi/bem.hpp b/plugin/mpi/bem.hpp index 5b20dd42e..8da6d6bcf 100644 --- a/plugin/mpi/bem.hpp +++ b/plugin/mpi/bem.hpp @@ -13,686 +13,677 @@ extern "C" { #ifdef METIS_VER_MAJOR extern "C" { -real_t libmetis__ComputeElementBalance(idx_t ne, idx_t nparts, idx_t *where); +real_t libmetis__ComputeElementBalance(idx_t ne, idx_t nparts, idx_t* where); } #else typedef idxtype idx_t; #endif template< class FESPACE, int NO, typename R > -KN< R > *partmetis( KN< R > *const &part, const FESPACE * pVh, long const &lparts) { +KN< R >* partmetis(KN< R >* const& part, const FESPACE* pVh, long const& lparts) { ffassert(pVh); - const FESPACE &Vh(*pVh); - int nve = Vh[0].NbDoF( ); - const typename FESPACE::Mesh & Th = Vh.Th; - idx_t nt = Th.nt, nv = Vh.NbOfDF; + const FESPACE& Vh(*pVh); + int nve = Vh[0].NbDoF( ); + const typename FESPACE::Mesh& Th = Vh.Th; + idx_t nt = Th.nt, nv = Vh.NbOfDF; KN< idx_t > eptr(nt + 1), elmnts(nve * nt), epart(nt), npart(nv); - if(lparts > 1) { - for (idx_t k = 0, i = 0; k < nt; ++k) { - eptr[k] = i; - for (idx_t j = 0; j < nve; j++) { - elmnts[i++] = Vh(k, j); - } - eptr[k + 1] = i; + if (lparts > 1) { + for (idx_t k = 0, i = 0; k < nt; ++k) { + eptr[k] = i; + for (idx_t j = 0; j < nve; j++) { + elmnts[i++] = Vh(k, j); } + eptr[k + 1] = i; + } - idx_t numflag = 0; - idx_t nparts = lparts; - idx_t edgecut; - idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 - idx_t ncommon = 1; + idx_t numflag = 0; + idx_t nparts = lparts; + idx_t edgecut; + idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 + idx_t ncommon = 1; #ifdef METIS_VER_MAJOR - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } else { - METIS_PartMeshDual(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t*)elmnts, 0, 0, &nparts, 0, 0, &edgecut, (idx_t*)epart, (idx_t*)npart); + } else { + METIS_PartMeshDual(&nt, &nv, eptr, (idx_t*)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, (idx_t*)epart, (idx_t*)npart); + } - if (verbosity) { - printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - libmetis__ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, libmetis__ComputeElementBalance(nt, nparts, epart), NO); + } #else - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } else { - METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } else { + METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } - if (verbosity) { - printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, ComputeElementBalance(nt, nparts, epart), NO); + } #endif - } else npart = 0; + } else + npart = 0; part->resize(nv); *part = npart; return part; } #endif -double ff_htoolEta=10., ff_htoolEpsilon=1e-3; -long ff_htoolMaxleafsize=100, ff_htoolMintargetdepth=0, ff_htoolMinsourcedepth=0; +double ff_htoolEta = 10., ff_htoolEpsilon = 1e-3; +long ff_htoolMaxleafsize = 100, ff_htoolMintargetdepth = 0, ff_htoolMinsourcedepth = 0; -template +template< class K > class HMatrixVirt { -public: - string solver = "fgmres"; - int state = 0; - virtual const std::map& get_infos() const = 0; - virtual void mvprod_global(const K* const in, K* const out,const int& mu=1) const = 0; - virtual int nb_rows() const = 0; - virtual int nb_cols() const = 0; - virtual void cluster_to_target_permutation(const K* const in, K* const out) const = 0; - virtual void source_to_cluster_permutation(const K* const in, K* const out) const = 0; - virtual MPI_Comm get_comm() const = 0; - virtual int get_rankworld() const = 0; - virtual int get_sizeworld() const = 0; - virtual int get_local_size() const = 0; - virtual int get_local_offset() const = 0; - virtual std::vector*> get_dense_blocks() const = 0; - virtual std::vector*> get_low_rank_blocks() const = 0; - virtual std::vector*> get_diagonal_blocks() const = 0; - virtual htool::Matrix get_local_dense() const = 0; - virtual int get_permt(int) const = 0; - virtual int get_perms(int) const = 0; - virtual void factorization() = 0; - virtual void solve(htool::MatrixView) = 0; - - virtual ~HMatrixVirt() {}; + public: + string solver = "fgmres"; + int state = 0; + virtual const std::map< std::string, std::string >& get_infos( ) const = 0; + virtual void mvprod_global(const K* const in, K* const out, const int& mu = 1) const = 0; + virtual int nb_rows( ) const = 0; + virtual int nb_cols( ) const = 0; + virtual void cluster_to_target_permutation(const K* const in, K* const out) const = 0; + virtual void source_to_cluster_permutation(const K* const in, K* const out) const = 0; + virtual MPI_Comm get_comm( ) const = 0; + virtual int get_rankworld( ) const = 0; + virtual int get_sizeworld( ) const = 0; + virtual int get_local_size( ) const = 0; + virtual int get_local_offset( ) const = 0; + virtual std::vector< const htool::HMatrix< K >* > get_dense_blocks( ) const = 0; + virtual std::vector< const htool::HMatrix< K >* > get_low_rank_blocks( ) const = 0; + virtual std::vector< const htool::HMatrix< K >* > get_diagonal_blocks( ) const = 0; + virtual htool::Matrix< K > get_local_dense( ) const = 0; + virtual int get_permt(int) const = 0; + virtual int get_perms(int) const = 0; + virtual void factorization( ) = 0; + virtual void solve(htool::MatrixView< K >) = 0; + + virtual ~HMatrixVirt( ) {}; }; - -template -class HMatrixImpl : public HMatrixVirt { -private: - std::shared_ptr> target_cluster; - std::shared_ptr> source_cluster; - htool::DefaultApproximationBuilder distributed_operator_holder; - - -public: - htool::HMatrix& H; - const htool::DistributedOperator& distributed_operator; - std::map infos; - HMatrixImpl(htool::VirtualGenerator &mat, std::shared_ptr> t, std::shared_ptr> s,const htool::HMatrixTreeBuilder& hmatrix_tree_builder,string slvr,MPI_Comm comm) : target_cluster(t), source_cluster(s), distributed_operator_holder(mat,*target_cluster,*source_cluster,hmatrix_tree_builder,comm),distributed_operator(distributed_operator_holder.distributed_operator), H(distributed_operator_holder.hmatrix), infos(htool::get_distributed_hmatrix_information(H,distributed_operator.get_comm())){this->solver=slvr;} - const std::map& get_infos() const { return infos; } - void mvprod_global(const K* const in, K* const out,const int& mu=1) const { - K* work=nullptr; - if (mu==1){ - add_distributed_operator_vector_product_global_to_global('N',K(1),distributed_operator,in,K(0),out,work); - } else{ - htool::MatrixView out_view(distributed_operator.get_target_partition().get_global_size() ,mu,out); - htool::MatrixView< const K> in_view(distributed_operator.get_source_partition().get_global_size() ,mu,in); - add_distributed_operator_matrix_product_global_to_global('N',K(1),distributed_operator,in_view,K(0),out_view,work); - } +template< class K > +class HMatrixImpl : public HMatrixVirt< K > { + private: + std::shared_ptr< htool::Cluster< double > > target_cluster; + std::shared_ptr< htool::Cluster< double > > source_cluster; + htool::DefaultApproximationBuilder< K > distributed_operator_holder; + + public: + htool::HMatrix< K >& H; + const htool::DistributedOperator< K >& distributed_operator; + std::map< std::string, std::string > infos; + HMatrixImpl(htool::VirtualGenerator< K >& mat, std::shared_ptr< htool::Cluster< double > > t, std::shared_ptr< htool::Cluster< double > > s, + const htool::HMatrixTreeBuilder< K, double >& hmatrix_tree_builder, string slvr, MPI_Comm comm) + : target_cluster(t), source_cluster(s), distributed_operator_holder(mat, *target_cluster, *source_cluster, hmatrix_tree_builder, comm), + distributed_operator(distributed_operator_holder.distributed_operator), H(distributed_operator_holder.hmatrix), + infos(htool::get_distributed_hmatrix_information(H, distributed_operator.get_comm( ))) { + this->solver = slvr; + } + const std::map< std::string, std::string >& get_infos( ) const { return infos; } + void mvprod_global(const K* const in, K* const out, const int& mu = 1) const { + K* work = nullptr; + if (mu == 1) { + add_distributed_operator_vector_product_global_to_global('N', K(1), distributed_operator, in, K(0), out, work); + } else { + htool::MatrixView< K > out_view(distributed_operator.get_target_partition( ).get_global_size( ), mu, out); + htool::MatrixView< const K > in_view(distributed_operator.get_source_partition( ).get_global_size( ), mu, in); + add_distributed_operator_matrix_product_global_to_global('N', K(1), distributed_operator, in_view, K(0), out_view, work); } - int nb_rows() const { return distributed_operator.get_target_partition().get_global_size();} - int nb_cols() const { return distributed_operator.get_source_partition().get_global_size();} - void cluster_to_target_permutation(const K* const in, K* const out) const {return htool::cluster_to_user(*target_cluster,in,out);} - void source_to_cluster_permutation(const K* const in, K* const out) const {return htool::user_to_cluster(*source_cluster,in,out);} - MPI_Comm get_comm() const {return distributed_operator.get_comm();} - int get_rankworld() const {int rankworld; MPI_Comm_rank(distributed_operator.get_comm(),&rankworld); return rankworld;} - int get_sizeworld() const {int sizeworld; MPI_Comm_size(distributed_operator.get_comm(),&sizeworld); return sizeworld;} - int get_local_size() const {int rankworld; MPI_Comm_rank(distributed_operator.get_comm(),&rankworld); return distributed_operator.get_target_partition().get_size_of_partition(rankworld);} - int get_local_offset() const {int rankworld; MPI_Comm_rank(distributed_operator.get_comm(),&rankworld); return distributed_operator.get_target_partition().get_offset_of_partition(rankworld);} - std::vector*> get_dense_blocks()const{ - std::vector*> dense_blocks; - preorder_tree_traversal( - H, - [&dense_blocks](const htool::HMatrix ¤t_hmatrix) { - if (current_hmatrix.is_leaf() && current_hmatrix.is_dense()) { - dense_blocks.push_back(¤t_hmatrix); - } - }); - return dense_blocks;} - std::vector*> get_low_rank_blocks()const{ - std::vector*> low_rank_blocks; - preorder_tree_traversal( - H, - [&low_rank_blocks](const htool::HMatrix ¤t_hmatrix) { - if (current_hmatrix.is_leaf() && current_hmatrix.is_low_rank()) { - low_rank_blocks.push_back(¤t_hmatrix); - } - }); - return low_rank_blocks;} - std::vector*> get_diagonal_blocks() const{ - std::vector*> diagonal_blocks; - preorder_tree_traversal( - H, - [&diagonal_blocks](const htool::HMatrix ¤t_hmatrix) { - if (current_hmatrix.is_dense() && current_hmatrix.get_target_cluster().get_offset()==current_hmatrix.get_source_cluster().get_offset()) { - diagonal_blocks.push_back(¤t_hmatrix); - } - }); - return diagonal_blocks;} - htool::Matrix get_local_dense() const {htool::Matrix dense(H.nb_rows(),H.nb_cols());htool::copy_to_dense(H,dense.data());return dense;} - int get_permt(int i) const {return H.get_target_cluster().get_permutation()[i];} - int get_perms(int i) const {return H.get_source_cluster().get_permutation()[i];} - void factorization() {if (!this->state) {htool::lu_factorization(H); this->state=3;}} - void solve(htool::MatrixView b) {if (!this->state) factorization(); htool::lu_solve('N',H,b);} + } + int nb_rows( ) const { return distributed_operator.get_target_partition( ).get_global_size( ); } + int nb_cols( ) const { return distributed_operator.get_source_partition( ).get_global_size( ); } + void cluster_to_target_permutation(const K* const in, K* const out) const { return htool::cluster_to_user(*target_cluster, in, out); } + void source_to_cluster_permutation(const K* const in, K* const out) const { return htool::user_to_cluster(*source_cluster, in, out); } + MPI_Comm get_comm( ) const { return distributed_operator.get_comm( ); } + int get_rankworld( ) const { + int rankworld; + MPI_Comm_rank(distributed_operator.get_comm( ), &rankworld); + return rankworld; + } + int get_sizeworld( ) const { + int sizeworld; + MPI_Comm_size(distributed_operator.get_comm( ), &sizeworld); + return sizeworld; + } + int get_local_size( ) const { + int rankworld; + MPI_Comm_rank(distributed_operator.get_comm( ), &rankworld); + return distributed_operator.get_target_partition( ).get_size_of_partition(rankworld); + } + int get_local_offset( ) const { + int rankworld; + MPI_Comm_rank(distributed_operator.get_comm( ), &rankworld); + return distributed_operator.get_target_partition( ).get_offset_of_partition(rankworld); + } + std::vector< const htool::HMatrix< K >* > get_dense_blocks( ) const { + std::vector< const htool::HMatrix< K >* > dense_blocks; + preorder_tree_traversal(H, [&dense_blocks](const htool::HMatrix< K >& current_hmatrix) { + if (current_hmatrix.is_leaf( ) && current_hmatrix.is_dense( )) { + dense_blocks.push_back(¤t_hmatrix); + } + }); + return dense_blocks; + } + std::vector< const htool::HMatrix< K >* > get_low_rank_blocks( ) const { + std::vector< const htool::HMatrix< K >* > low_rank_blocks; + preorder_tree_traversal(H, [&low_rank_blocks](const htool::HMatrix< K >& current_hmatrix) { + if (current_hmatrix.is_leaf( ) && current_hmatrix.is_low_rank( )) { + low_rank_blocks.push_back(¤t_hmatrix); + } + }); + return low_rank_blocks; + } + std::vector< const htool::HMatrix< K >* > get_diagonal_blocks( ) const { + std::vector< const htool::HMatrix< K >* > diagonal_blocks; + preorder_tree_traversal(H, [&diagonal_blocks](const htool::HMatrix< K >& current_hmatrix) { + if (current_hmatrix.is_dense( ) && current_hmatrix.get_target_cluster( ).get_offset( ) == current_hmatrix.get_source_cluster( ).get_offset( )) { + diagonal_blocks.push_back(¤t_hmatrix); + } + }); + return diagonal_blocks; + } + htool::Matrix< K > get_local_dense( ) const { + htool::Matrix< K > dense(H.nb_rows( ), H.nb_cols( )); + htool::copy_to_dense(H, dense.data( )); + return dense; + } + int get_permt(int i) const { return H.get_target_cluster( ).get_permutation( )[i]; } + int get_perms(int i) const { return H.get_source_cluster( ).get_permutation( )[i]; } + void factorization( ) { + if (!this->state) { + htool::lu_factorization(H); + this->state = 3; + } + } + void solve(htool::MatrixView< K > b) { + if (!this->state) factorization( ); + htool::lu_solve('N', H, b); + } }; +struct Data_Bem_Solver : public Data_Sparse_Solver { + double eta; + int maxleafsize, mintargetdepth, minsourcedepth; + string compressor, initialclustering, clusteringdirections; + bool recompress, adaptiveclustering; + + Data_Bem_Solver( ) + : Data_Sparse_Solver( ), eta(ff_htoolEta), maxleafsize(ff_htoolMaxleafsize), mintargetdepth(ff_htoolMintargetdepth), minsourcedepth(ff_htoolMinsourcedepth), compressor("partialACA"), + recompress(false), initialclustering("default"), clusteringdirections("pca"), adaptiveclustering(true) + + { + epsilon = ff_htoolEpsilon; + } -struct Data_Bem_Solver -: public Data_Sparse_Solver { - double eta; - int maxleafsize,mintargetdepth,minsourcedepth; - string compressor, initialclustering, clusteringdirections; - bool recompress, adaptiveclustering; - - Data_Bem_Solver() - : Data_Sparse_Solver(), - eta(ff_htoolEta), - maxleafsize(ff_htoolMaxleafsize), - mintargetdepth(ff_htoolMintargetdepth), - minsourcedepth(ff_htoolMinsourcedepth), - compressor("partialACA"), - recompress(false), - initialclustering("default"), - clusteringdirections("pca"), - adaptiveclustering(true) - - {epsilon=ff_htoolEpsilon;} - - template - void Init_sym_positive_var(); - - private: - Data_Bem_Solver(const Data_Bem_Solver& ); // pas de copie - + template< class R > + void Init_sym_positive_var( ); + + private: + Data_Bem_Solver(const Data_Bem_Solver&); // pas de copie }; -template -void Data_Bem_Solver::Init_sym_positive_var() -{ - - Data_Sparse_Solver::Init_sym_positive_var(-1); - +template< class R > +void Data_Bem_Solver::Init_sym_positive_var( ) { + + Data_Sparse_Solver::Init_sym_positive_var< R >(-1); } -template -inline void SetEnd_Data_Bem_Solver(Stack stack,Data_Bem_Solver & ds,Expression const *nargs ,int n_name_param) -{ - - { - bool unset_eps=true; - ds.initmat=true; - ds.factorize=0; - int kk = n_name_param-(NB_NAME_PARM_MAT+NB_NAME_PARM_HMAT)-1; - if (nargs[++kk]) ds.initmat= ! GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.solver= * GetAny((*nargs[kk])(stack)); - ds.Init_sym_positive_var();// set def value of sym and posi - if (nargs[++kk]) ds.epsilon= GetAny((*nargs[kk])(stack)),unset_eps=false; - if (nargs[++kk]) - {// modif FH fev 2010 ... - const Polymorphic * op= dynamic_cast(nargs[kk]); - if(op) - { - ds.precon = op->Find("(",ArrayOfaType(atype* >(),false)); // strange bug in g++ is R become a double - ffassert(ds.precon); - } // add miss - } - - if (nargs[++kk]) ds.NbSpace= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tgv= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.factorize= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.strategy = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tol_pivot = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tol_pivot_sym = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.itmax = GetAny((*nargs[kk])(stack)); // frev 2007 OK - if (nargs[++kk]) ds.data_filename = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.lparams = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.dparams = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.smap = GetAny *>((*nargs[kk])(stack)); - if (nargs[++kk]) ds.perm_r = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.perm_c = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.scale_r = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.scale_c = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.sparams = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.commworld = GetAny((*nargs[kk])(stack)); +template< class R > +inline void SetEnd_Data_Bem_Solver(Stack stack, Data_Bem_Solver& ds, Expression const* nargs, int n_name_param) { + + { + bool unset_eps = true; + ds.initmat = true; + ds.factorize = 0; + int kk = n_name_param - (NB_NAME_PARM_MAT + NB_NAME_PARM_HMAT) - 1; + if (nargs[++kk]) ds.initmat = !GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.solver = *GetAny< string* >((*nargs[kk])(stack)); + ds.Init_sym_positive_var< R >( ); // set def value of sym and posi + if (nargs[++kk]) ds.epsilon = GetAny< double >((*nargs[kk])(stack)), unset_eps = false; + if (nargs[++kk]) { // modif FH fev 2010 ... + const Polymorphic* op = dynamic_cast< const Polymorphic* >(nargs[kk]); + if (op) { + ds.precon = op->Find("(", ArrayOfaType(atype< KN< R >* >( ), false)); // strange bug in g++ is R become a double + ffassert(ds.precon); + } // add miss + } + + if (nargs[++kk]) ds.NbSpace = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tgv = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.factorize = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.strategy = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tol_pivot = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tol_pivot_sym = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.itmax = GetAny< long >((*nargs[kk])(stack)); // frev 2007 OK + if (nargs[++kk]) ds.data_filename = *GetAny< string* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.lparams = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.dparams = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.smap = GetAny< MyMap< String, String >* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.perm_r = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.perm_c = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.scale_r = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.scale_c = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.sparams = *GetAny< string* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.commworld = GetAny< pcommworld >((*nargs[kk])(stack)); #ifdef VDATASPARSESOLVER - if (nargs[++kk]) ds.master = GetAny((*nargs[kk])(stack)); + if (nargs[++kk]) ds.master = GetAny< long >((*nargs[kk])(stack)); #else - ++kk; + ++kk; #endif - if (nargs[++kk]) ds.rinfo = GetAny* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.info = GetAny* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.kerneln = GetAny< KNM* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.kernelt = GetAny< KNM* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.kerneldim = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.verb = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.x0 = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.veps= GetAny((*nargs[kk])(stack)); - if( unset_eps && ds.veps) ds.epsilon = *ds.veps;// if veps and no def value => veps def value of epsilon. - if (nargs[++kk]) ds.rightprecon= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.sym= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.positive= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) { ds.getnbiter= GetAny((*nargs[kk])(stack)); - if( ds.getnbiter) *ds.getnbiter=-1; //undef - } - if(ds.solver == "") { // SET DEFAULT SOLVER TO HRE ... - if( ds.sym && ds.positive ) ds.solver=*def_solver_sym_dp; - else if( ds.sym ) ds.solver=*def_solver_sym; - else ds.solver=*def_solver; - if(mpirank==0 && verbosity>4) cout << " **Warning: set default solver to " << ds.solver << endl; - } - if (nargs[++kk]) ds.eta = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.maxleafsize = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.mintargetdepth = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.minsourcedepth = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.compressor = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.recompress = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.initialclustering = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.clusteringdirections = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.adaptiveclustering = GetAny((*nargs[kk])(stack)); - ffassert(++kk == n_name_param); - } + if (nargs[++kk]) ds.rinfo = GetAny< KN< double >* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.info = GetAny< KN< long >* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.kerneln = GetAny< KNM< double >* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.kernelt = GetAny< KNM< double >* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.kerneldim = GetAny< long* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.verb = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.x0 = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.veps = GetAny< double* >((*nargs[kk])(stack)); + if (unset_eps && ds.veps) ds.epsilon = *ds.veps; // if veps and no def value => veps def value of epsilon. + if (nargs[++kk]) ds.rightprecon = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.sym = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.positive = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) { + ds.getnbiter = GetAny< long* >((*nargs[kk])(stack)); + if (ds.getnbiter) *ds.getnbiter = -1; // undef + } + if (ds.solver == "") { // SET DEFAULT SOLVER TO HRE ... + if (ds.sym && ds.positive) + ds.solver = *def_solver_sym_dp; + else if (ds.sym) + ds.solver = *def_solver_sym; + else + ds.solver = *def_solver; + if (mpirank == 0 && verbosity > 4) cout << " **Warning: set default solver to " << ds.solver << endl; + } + if (nargs[++kk]) ds.eta = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.maxleafsize = GetAny< int >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.mintargetdepth = GetAny< int >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.minsourcedepth = GetAny< int >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.compressor = *GetAny< string* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.recompress = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.initialclustering = *GetAny< string* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.clusteringdirections = *GetAny< string* >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.adaptiveclustering = GetAny< bool >((*nargs[kk])(stack)); + ffassert(++kk == n_name_param); + } } -template +template< class K > class HMatrixVirt; -template -KNM* HMatrixVirtToDense(HMatrixVirt **Hmat) -{ - ffassert(Hmat && *Hmat); - HMatrixVirt& H = **Hmat; - if(std::is_same>::value) { - - htool::Matrix mdense = H.get_local_dense(); - KNM* M = new KNM( (long) H.nb_rows(), (long) H.nb_cols() ); - for (int i=0; i< H.nb_rows(); i++) - for (int j=0; j< H.nb_cols(); j++) - (*M)(i,j) = 0; - for (int i=0; i< mdense.nb_rows(); i++) - for (int j=0; j< mdense.nb_cols(); j++) - (*M)(H.get_permt(i+H.get_local_offset()),H.get_perms(j)) = mdense(i,j); - return M; - } - else { - std::cerr << " Error of value type HMatrixVirt and KNM " << std::endl; - ffassert(0); - } +template< class Type, class K > +KNM< K >* HMatrixVirtToDense(HMatrixVirt< K >** Hmat) { + ffassert(Hmat && *Hmat); + HMatrixVirt< K >& H = **Hmat; + if (std::is_same< Type, KNM< K > >::value) { + + htool::Matrix< K > mdense = H.get_local_dense( ); + KNM< K >* M = new KNM< K >((long)H.nb_rows( ), (long)H.nb_cols( )); + for (int i = 0; i < H.nb_rows( ); i++) + for (int j = 0; j < H.nb_cols( ); j++) (*M)(i, j) = 0; + for (int i = 0; i < mdense.nb_rows( ); i++) + for (int j = 0; j < mdense.nb_cols( ); j++) (*M)(H.get_permt(i + H.get_local_offset( )), H.get_perms(j)) = mdense(i, j); + return M; + } else { + std::cerr << " Error of value type HMatrixVirt and KNM " << std::endl; + ffassert(0); + } } -template< class FESPACE> -std::shared_ptr> build_clustering(int n, const FESPACE * Uh, const std::vector & p, const Data_Bem_Solver& ds, MPI_Comm comm) { - htool::ClusterTreeBuilder cluster_builder; - std::shared_ptr> cluster; - - if (ds.clusteringdirections == "pca") { - if (ds.adaptiveclustering) - cluster_builder.set_partitioning_strategy(std::make_shared, htool::RegularSplitting>>()); - else - cluster_builder.set_partitioning_strategy(std::make_shared, htool::RegularSplitting>>()); - } else if (ds.clusteringdirections == "boundingbox") { - if (ds.adaptiveclustering) - cluster_builder.set_partitioning_strategy(std::make_shared, htool::RegularSplitting>>()); - else - cluster_builder.set_partitioning_strategy(std::make_shared, htool::RegularSplitting>>()); - } - else { - if (mpirank == 0) std::cerr << "Error: unknown choice of clustering directions \"" << ds.clusteringdirections << "\", please use \"pca\" or \"boundingbox\"" << std::endl; - ffassert(0); - } - cluster_builder.set_maximal_leaf_size(ds.maxleafsize); - // std::shared_ptr> c = std::make_shared>(); +template< class FESPACE > +std::shared_ptr< htool::Cluster< double > > build_clustering(int n, const FESPACE* Uh, const std::vector< double >& p, const Data_Bem_Solver& ds, MPI_Comm comm) { + htool::ClusterTreeBuilder< double > cluster_builder; + std::shared_ptr< htool::Cluster< double > > cluster; - int sizeWorld; - MPI_Comm_size(comm, &sizeWorld); - if (ds.initialclustering == "" || ds.initialclustering == "default") { - cluster = std::make_shared>(cluster_builder.create_cluster_tree(n,3,p.data(),2,sizeWorld)); - } - else if (ds.initialclustering == "metis") { - #if defined(HTOOL_VERSION_GE) - #if HTOOL_VERSION_GE(0,8,1) - #if defined(WITH_metis) - KN parts(n); + if (ds.clusteringdirections == "pca") { + if (ds.adaptiveclustering) + cluster_builder.set_partitioning_strategy(std::make_shared< htool::Partitioning_N< double, htool::ComputeLargestExtent< double >, htool::RegularSplitting< double > > >( )); + else + cluster_builder.set_partitioning_strategy(std::make_shared< htool::Partitioning< double, htool::ComputeLargestExtent< double >, htool::RegularSplitting< double > > >( )); + } else if (ds.clusteringdirections == "boundingbox") { + if (ds.adaptiveclustering) + cluster_builder.set_partitioning_strategy(std::make_shared< htool::Partitioning_N< double, htool::ComputeBoundingBox< double >, htool::RegularSplitting< double > > >( )); + else + cluster_builder.set_partitioning_strategy(std::make_shared< htool::Partitioning< double, htool::ComputeBoundingBox< double >, htool::RegularSplitting< double > > >( )); + } else { + if (mpirank == 0) std::cerr << "Error: unknown choice of clustering directions \"" << ds.clusteringdirections << "\", please use \"pca\" or \"boundingbox\"" << std::endl; + ffassert(0); + } + cluster_builder.set_maximal_leaf_size(ds.maxleafsize); + // std::shared_ptr> c = std::make_shared>(); + + int sizeWorld; + MPI_Comm_size(comm, &sizeWorld); + if (ds.initialclustering == "" || ds.initialclustering == "default") { + cluster = std::make_shared< htool::Cluster< double > >(cluster_builder.create_cluster_tree(n, 3, p.data( ), 2, sizeWorld)); + } else if (ds.initialclustering == "metis") { +#if defined(HTOOL_VERSION_GE) +#if HTOOL_VERSION_GE(0, 8, 1) +#if defined(WITH_metis) + KN< double > parts(n); int npart; int rank; MPI_Comm_size(comm, &npart); MPI_Comm_rank(comm, &rank); - std::vector part(n); + std::vector< int > part(n); if (npart > 1) { - if (rank == 0) { - partmetis(&parts, Uh, npart); - for (int i=0; i>(cluster_builder.create_cluster_tree_from_global_partition(n,3,p.data(),2,sizeWorld,part.data())); - #else + if (rank == 0) { + partmetis< FESPACE, 0, double >(&parts, Uh, npart); + for (int i = 0; i < n; i++) part[i] = parts[i]; + } + MPI_Bcast(part.data( ), n, MPI_INT, 0, comm); + } else + std::fill(part.begin( ), part.end( ), 0); + + cluster = std::make_shared< htool::Cluster< double > >(cluster_builder.create_cluster_tree_from_global_partition(n, 3, p.data( ), 2, sizeWorld, part.data( ))); +#else if (mpirank == 0) std::cerr << "Error: cannot use metis for initial htool clustering ; no metis library" << std::endl; ffassert(0); - #endif - #else +#endif +#else if (mpirank == 0) std::cerr << "Error: cannot use metis for initial htool clustering ; need htool 0.8.1 or later" << std::endl; ffassert(0); - #endif - #else +#endif +#else if (mpirank == 0) std::cerr << "Error: cannot use metis for initial htool clustering ; need htool 0.8.1 or later" << std::endl; ffassert(0); - #endif - } - else { - if (mpirank == 0) std::cerr << "Error: unknown initial clustering \"" << ds.initialclustering << "\", please use \"default\" or \"metis\"" << std::endl; - ffassert(0); - } - return cluster; +#endif + } else { + if (mpirank == 0) std::cerr << "Error: unknown initial clustering \"" << ds.initialclustering << "\", please use \"default\" or \"metis\"" << std::endl; + ffassert(0); + } + return cluster; } -template -void buildHmat(HMatrixVirt** Hmat, htool::VirtualGenerator* generatorP,const Data_Bem_Solver& data, - std::shared_ptr> t, std::shared_ptr> s, - vector &pt,vector &ps,MPI_Comm comm) { - - int sizeWorld; - MPI_Comm_size(comm, &sizeWorld); - auto hmatrix_builder = htool::HMatrixTreeBuilder(data.epsilon, data.eta, data.sym?'S':'N',data.sym?'U':'N', -1); - std::shared_ptr> LowRankGenerator = nullptr; - if (data.compressor=="" || data.compressor == "partialACA") - LowRankGenerator = std::make_shared>(*generatorP, t->get_permutation().data(), s->get_permutation().data()); - else if (data.compressor == "fullACA") - LowRankGenerator = std::make_shared>(*generatorP, t->get_permutation().data(), s->get_permutation().data()); - else if (data.compressor == "SVD") - LowRankGenerator = std::make_shared>(*generatorP, t->get_permutation().data(), s->get_permutation().data()); - else { - cerr << "Error: unknown htool compressor \""+data.compressor+"\"" << endl; - ffassert(0); - } - - if (data.recompress){ - std::shared_ptr> RecompressedLowRankGenerator = std::make_shared>(*LowRankGenerator,std::function &)>(htool::SVD_recompression)); - hmatrix_builder.set_low_rank_generator(RecompressedLowRankGenerator); - }else{ - hmatrix_builder.set_low_rank_generator(LowRankGenerator); - } - - - hmatrix_builder.set_minimal_target_depth(data.mintargetdepth); - hmatrix_builder.set_minimal_source_depth(data.minsourcedepth); - if ((sizeWorld > 1) || (t != s)) - hmatrix_builder.set_block_tree_consistency(false); - HMatrixImpl* test =new HMatrixImpl(*generatorP, t,s,hmatrix_builder,data.solver,comm); - if (data.factorize && (data.solver == "HLU")) - test->factorization(); - *Hmat = test; +template< class R > +void buildHmat(HMatrixVirt< R >** Hmat, htool::VirtualGenerator< R >* generatorP, const Data_Bem_Solver& data, std::shared_ptr< htool::Cluster< double > > t, + std::shared_ptr< htool::Cluster< double > > s, vector< double >& pt, vector< double >& ps, MPI_Comm comm) { + + int sizeWorld; + MPI_Comm_size(comm, &sizeWorld); + auto hmatrix_builder = htool::HMatrixTreeBuilder< R, double >(data.epsilon, data.eta, data.sym ? 'S' : 'N', data.sym ? 'U' : 'N', -1); + std::shared_ptr< htool::VirtualInternalLowRankGenerator< R > > LowRankGenerator = nullptr; + if (data.compressor == "" || data.compressor == "partialACA") + LowRankGenerator = std::make_shared< htool::partialACA< R > >(*generatorP, t->get_permutation( ).data( ), s->get_permutation( ).data( )); + else if (data.compressor == "fullACA") + LowRankGenerator = std::make_shared< htool::fullACA< R > >(*generatorP, t->get_permutation( ).data( ), s->get_permutation( ).data( )); + else if (data.compressor == "SVD") + LowRankGenerator = std::make_shared< htool::SVD< R > >(*generatorP, t->get_permutation( ).data( ), s->get_permutation( ).data( )); + else { + cerr << "Error: unknown htool compressor \"" + data.compressor + "\"" << endl; + ffassert(0); + } + + if (data.recompress) { + std::shared_ptr< htool::VirtualInternalLowRankGenerator< R > > RecompressedLowRankGenerator = + std::make_shared< htool::RecompressedLowRankGenerator< R > >(*LowRankGenerator, std::function< void(htool::LowRankMatrix< R >&) >(htool::SVD_recompression< R >)); + hmatrix_builder.set_low_rank_generator(RecompressedLowRankGenerator); + } else { + hmatrix_builder.set_low_rank_generator(LowRankGenerator); + } + + hmatrix_builder.set_minimal_target_depth(data.mintargetdepth); + hmatrix_builder.set_minimal_source_depth(data.minsourcedepth); + if ((sizeWorld > 1) || (t != s)) hmatrix_builder.set_block_tree_consistency(false); + HMatrixImpl< R >* test = new HMatrixImpl< R >(*generatorP, t, s, hmatrix_builder, data.solver, comm); + if (data.factorize && (data.solver == "HLU")) test->factorization( ); + *Hmat = test; } -template -void creationHMatrixtoBEMForm(const FESpace1 * Uh, const FESpace2 * Vh, const int & VFBEM, - const list & largs, Stack stack, const Data_Bem_Solver &ds, HMatrixVirt** Hmat){ - - - typedef typename FESpace1::Mesh SMesh; - typedef typename FESpace2::Mesh TMesh; - typedef typename SMesh::RdHat SRdHat; - typedef typename TMesh::RdHat TRdHat; - - typedef typename std::conditional::type MeshBemtool; - typedef typename std::conditional::type P0; - typedef typename std::conditional::type P1; - typedef typename std::conditional::type P2; - - // size of the matrix - int m=Uh->NbOfDF; - int n=Vh->NbOfDF; - - /* - int VFBEM = typeVFBEM(largs,stack); - if (mpirank == 0 && verbosity>5) - cout << "test VFBEM type (1 kernel / 2 potential) " << VFBEM << endl; - */ - - // compression infogfg - - MPI_Comm comm = ds.commworld ? *(MPI_Comm*)ds.commworld : MPI_COMM_WORLD; - - // source/target meshes - const SMesh & ThU =Uh->Th; // line - const TMesh & ThV =Vh->Th; // colunm - bool samemesh = (void*)&Uh->Th == (void*)&Vh->Th; // same Fem2D::Mesh +++ pot or kernel - - bemtool::Geometry node; MeshBemtool mesh; - Mesh2Bemtool(ThU, node, mesh); - - - vector pt(3*n); - vector ps(3*m); - Fem2D::R3 pp; - bemtool::R3 p; - SRdHat pbs; - TRdHat pbt; - pbs[0] = 1./(SRdHat::d+1); - pbs[1] = 1./(SRdHat::d+1); - if (SRdHat::d == 3) pbs[2] = 1./(SRdHat::d+1); - pbt[0] = 1./(TRdHat::d+1); - pbt[1] = 1./(TRdHat::d+1); - if (TRdHat::d == 3) pbt[2] = 1./(TRdHat::d+1); - - int Snbv = Uh->TFE[0]->ndfonVertex; - int Snbe = Uh->TFE[0]->ndfonEdge; - int Snbt = Uh->TFE[0]->ndfonFace; - bool SP0 = SRdHat::d == 1 ? (Snbv == 0) && (Snbe == 1) && (Snbt == 0) : (Snbv == 0) && (Snbe == 0) && (Snbt == 1); - bool SP1 = (Snbv == 1) && (Snbe == 0) && (Snbt == 0); - bool SP2 = (Snbv == 1) && (Snbe == 1) && (Snbt == 0); - bool SRT0 = (SRdHat::d == 2) && (Snbv == 0) && (Snbe == 1) && (Snbt == 0); - - if (SP2) { - bemtool::Dof dof(mesh,true); - for (int i=0; i& jj = dof.ToElt(i); - p = dof(jj[0][0])[jj[0][1]]; - ps[3*i+0] = p[0]; - ps[3*i+1] = p[1]; - ps[3*i+2] = p[2]; - } +template< class R, class MMesh, class FESpace1, class FESpace2 > +void creationHMatrixtoBEMForm(const FESpace1* Uh, const FESpace2* Vh, const int& VFBEM, const list< C_F0 >& largs, Stack stack, const Data_Bem_Solver& ds, HMatrixVirt< R >** Hmat) { + + typedef typename FESpace1::Mesh SMesh; + typedef typename FESpace2::Mesh TMesh; + typedef typename SMesh::RdHat SRdHat; + typedef typename TMesh::RdHat TRdHat; + + typedef typename std::conditional< SMesh::RdHat::d == 1, bemtool::Mesh1D, bemtool::Mesh2D >::type MeshBemtool; + typedef typename std::conditional< SMesh::RdHat::d == 1, bemtool::P0_1D, bemtool::P0_2D >::type P0; + typedef typename std::conditional< SMesh::RdHat::d == 1, bemtool::P1_1D, bemtool::P1_2D >::type P1; + typedef typename std::conditional< SMesh::RdHat::d == 1, bemtool::P2_1D, bemtool::P2_2D >::type P2; + + // size of the matrix + int m = Uh->NbOfDF; + int n = Vh->NbOfDF; + + /* + int VFBEM = typeVFBEM(largs,stack); + if (mpirank == 0 && verbosity>5) + cout << "test VFBEM type (1 kernel / 2 potential) " << VFBEM << endl; + */ + + // compression infogfg + + MPI_Comm comm = ds.commworld ? *(MPI_Comm*)ds.commworld : MPI_COMM_WORLD; + + // source/target meshes + const SMesh& ThU = Uh->Th; // line + const TMesh& ThV = Vh->Th; // colunm + bool samemesh = (void*)&Uh->Th == (void*)&Vh->Th; // same Fem2D::Mesh +++ pot or kernel + + bemtool::Geometry node; + MeshBemtool mesh; + Mesh2Bemtool(ThU, node, mesh); + + vector< double > pt(3 * n); + vector< double > ps(3 * m); + Fem2D::R3 pp; + bemtool::R3 p; + SRdHat pbs; + TRdHat pbt; + pbs[0] = 1. / (SRdHat::d + 1); + pbs[1] = 1. / (SRdHat::d + 1); + if (SRdHat::d == 3) pbs[2] = 1. / (SRdHat::d + 1); + pbt[0] = 1. / (TRdHat::d + 1); + pbt[1] = 1. / (TRdHat::d + 1); + if (TRdHat::d == 3) pbt[2] = 1. / (TRdHat::d + 1); + + int Snbv = Uh->TFE[0]->ndfonVertex; + int Snbe = Uh->TFE[0]->ndfonEdge; + int Snbt = Uh->TFE[0]->ndfonFace; + bool SP0 = SRdHat::d == 1 ? (Snbv == 0) && (Snbe == 1) && (Snbt == 0) : (Snbv == 0) && (Snbe == 0) && (Snbt == 1); + bool SP1 = (Snbv == 1) && (Snbe == 0) && (Snbt == 0); + bool SP2 = (Snbv == 1) && (Snbe == 1) && (Snbt == 0); + bool SRT0 = (SRdHat::d == 2) && (Snbv == 0) && (Snbe == 1) && (Snbt == 0); + + if (SP2) { + bemtool::Dof< P2 > dof(mesh, true); + for (int i = 0; i < m; i++) { + const std::vector< bemtool::N2 >& jj = dof.ToElt(i); + p = dof(jj[0][0])[jj[0][1]]; + ps[3 * i + 0] = p[0]; + ps[3 * i + 1] = p[1]; + ps[3 * i + 2] = p[2]; } - else if (SRT0) { - bemtool::Dof dof(mesh); - for (int i=0; i& jj = dof.ToElt(i); - p = dof(jj[0][0])[jj[0][1]]; - ps[3*i+0] = p[0]; - ps[3*i+1] = p[1]; - ps[3*i+2] = p[2]; - } + } else if (SRT0) { + bemtool::Dof< bemtool::RT0_2D > dof(mesh); + for (int i = 0; i < m; i++) { + const std::vector< bemtool::N2 >& jj = dof.ToElt(i); + p = dof(jj[0][0])[jj[0][1]]; + ps[3 * i + 0] = p[0]; + ps[3 * i + 1] = p[1]; + ps[3 * i + 2] = p[2]; } - else - for (int i=0; i> t, s; - s = build_clustering(m, Uh, ps, ds, comm); - - if(!samemesh) { - if( Vh->TFE[0]->N == 1){ - // case the target FE is scalar - for (int i=0; iMaxNbNodePerElement == TRdHat::d + 1) - pp = ThV.vertices[i]; - else if (Vh->MaxNbNodePerElement == 1) - pp = ThV[i](pbt); - else { - if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; - ffassert(0); - } - pt[3*i+0] = pp.x; - pt[3*i+1] = pp.y; - pt[3*i+2] = pp.z; - } - } - else{ - // hack for Maxwell case to have one Hmatrix to avoid one Hmatrix by direction - ffassert(SRT0 && SRdHat::d == 2 && VFBEM==2); - - // Dans un espace vectoriel, [P1,P1,P1] pour les targets, on a: - // n correspond au nombre de dof du FEM space - // Or dans ce cas, on veut que n = mesh_Target.nv - // - // ==> on n'a pas besoin de resize les points p2 - int nnn= Vh->TFE[0]->N; // the size of the vector FESpace. For [P1,P1,P1], nnn=3; - - int nDofScalar = n/nnn; // computation of the dof of one component - - for (int i=0; iMaxNbNodePerElement == TRdHat::d + 1) - pp = ThV.vertices[i]; - else if (Vh->MaxNbNodePerElement == 1) - pp = ThV[i](pbt); - else { - if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; - ffassert(0); - } - - for(int iii=0; iii kernel = getBemKernel(stack,largs); - BemKernel *Ker = kernel.first; - Complex alpha = kernel.second; - - // check for Maxwell case - if (SRT0 && SRdHat::d == 2) { - if( Ker->typeKernel[1] >0 ){ - cerr << "vector BEM Maxwell is not valid for combined field formulation."<< endl; - ffassert(0); - } - // BemKernel->typeKernel[0] == 6 :: MA_SL - ffassert( Ker->typeKernel[0] == 6 ); // check MA_SL - } - - if(mpirank == 0 && verbosity >5) { - int nk=-1; - iscombinedKernel(Ker) ? nk=2 : nk=1; - //for(int i=0;itypeKernel[i] << " wave number: " << Ker->wavenum[i] << " coeffcombi: " << Ker->coeffcombi[i] <* generator; - - if(mpirank == 0 && verbosity>5) - std::cout << "Creating dof" << std::endl; + std::shared_ptr< htool::Cluster< double > > t, s; + s = build_clustering(m, Uh, ps, ds, comm); - if (SP0) { - bemtool::Dof dof(mesh); - ff_BIO_Generator(generator,Ker,dof,alpha); - } - else if (SP1) { - bemtool::Dof dof(mesh,true); - ff_BIO_Generator(generator,Ker,dof,alpha); - } - else if (SP2) { - bemtool::Dof dof(mesh,true); - ff_BIO_Generator(generator,Ker,dof,alpha); - } - else if (SRT0 && SRdHat::d == 2) { - // BemKernel->typeKernel[0] == 6 :: MA_SL - bemtool::Dof dof(mesh); - ff_BIO_Generator_Maxwell(generator,Ker,dof,alpha); + if (!samemesh) { + if (Vh->TFE[0]->N == 1) { + // case the target FE is scalar + for (int i = 0; i < n; i++) { + if (Vh->MaxNbNodePerElement == TRdHat::d + 1) + pp = ThV.vertices[i]; + else if (Vh->MaxNbNodePerElement == 1) + pp = ThV[i](pbt); + else { + if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; + ffassert(0); } - else - ffassert(0); - - // build the Hmat - buildHmat(Hmat, generator, ds, t, s, pt, ps, comm); + pt[3 * i + 0] = pp.x; + pt[3 * i + 1] = pp.y; + pt[3 * i + 2] = pp.z; + } + } else { + // hack for Maxwell case to have one Hmatrix to avoid one Hmatrix by direction + ffassert(SRT0 && SRdHat::d == 2 && VFBEM == 2); - delete generator; - } - else if (VFBEM==2) { - BemPotential *Pot = getBemPotential(stack,largs); - bemtool::Geometry node_output; + // Dans un espace vectoriel, [P1,P1,P1] pour les targets, on a: + // n correspond au nombre de dof du FEM space + // Or dans ce cas, on veut que n = mesh_Target.nv + // + // ==> on n'a pas besoin de resize les points p2 + int nnn = Vh->TFE[0]->N; // the size of the vector FESpace. For [P1,P1,P1], nnn=3; - if (SRT0 && SRdHat::d == 2) { - // check if we have the good FE space for vector BEM - ffassert( Pot->typePotential == 4 ); // check MA_SL - } + int nDofScalar = n / nnn; // computation of the dof of one component + for (int i = 0; i < nDofScalar; i++) { if (Vh->MaxNbNodePerElement == TRdHat::d + 1) - Mesh2Bemtool(ThV,node_output); - else if (Vh->MaxNbNodePerElement == 1) { - for (int i=0; iMaxNbNodePerElement == 1) + pp = ThV[i](pbt); + else { + if (mpirank == 0) std::cerr << "ff-BemTool error: only P0 and P1 FEspaces are available for reconstructions." << std::endl; + ffassert(0); } - else - ffassert(0); - htool::VirtualGenerator* generator; - if (SP0) { - bemtool::Dof dof(mesh); - ff_POT_Generator(generator,Pot,dof,mesh,node_output); - } - else if (SP1) { - bemtool::Dof dof(mesh,true); - ff_POT_Generator(generator,Pot,dof,mesh,node_output); - } - else if (SP2) { - bemtool::Dof dof(mesh,true); - ff_POT_Generator(generator,Pot,dof,mesh,node_output); - } - else if (SRT0 && SRdHat::d == 2) { - bemtool::Dof dof(mesh); - ff_POT_Generator_Maxwell(generator,Pot,dof,mesh,node_output); + for (int iii = 0; iii < nnn; iii++) { + ffassert(nnn * 3 * i + 3 * iii + 2 < nnn * 3 * n); + pt[nnn * 3 * i + 3 * iii + 0] = pp.x; + pt[nnn * 3 * i + 3 * iii + 1] = pp.y; + pt[nnn * 3 * i + 3 * iii + 2] = pp.z; } - else - ffassert(0); - - buildHmat(Hmat, generator, ds, t, s, pt, ps, comm); + } + } + t = build_clustering(n, Vh, pt, ds, comm); + } else { + pt = ps; + t = s; + } + + // creation of the generator for htool and creation the matrix + if (VFBEM == 1) { + // info kernel + pair< BemKernel*, Complex > kernel = getBemKernel(stack, largs); + BemKernel* Ker = kernel.first; + Complex alpha = kernel.second; + + // check for Maxwell case + if (SRT0 && SRdHat::d == 2) { + if (Ker->typeKernel[1] > 0) { + cerr << "vector BEM Maxwell is not valid for combined field formulation." << endl; + ffassert(0); + } + // BemKernel->typeKernel[0] == 6 :: MA_SL + ffassert(Ker->typeKernel[0] == 6); // check MA_SL + } - delete generator; + if (mpirank == 0 && verbosity > 5) { + int nk = -1; + iscombinedKernel(Ker) ? nk = 2 : nk = 1; + // for(int i=0;itypeKernel[i] << " wave number: " << Ker->wavenum[i] << " coeffcombi: " << Ker->coeffcombi[i] <* generator; + + if (mpirank == 0 && verbosity > 5) std::cout << "Creating dof" << std::endl; + + if (SP0) { + bemtool::Dof< P0 > dof(mesh); + ff_BIO_Generator< R, P0, SMesh >(generator, Ker, dof, alpha); + } else if (SP1) { + bemtool::Dof< P1 > dof(mesh, true); + ff_BIO_Generator< R, P1, SMesh >(generator, Ker, dof, alpha); + } else if (SP2) { + bemtool::Dof< P2 > dof(mesh, true); + ff_BIO_Generator< R, P2, SMesh >(generator, Ker, dof, alpha); + } else if (SRT0 && SRdHat::d == 2) { + // BemKernel->typeKernel[0] == 6 :: MA_SL + bemtool::Dof< bemtool::RT0_2D > dof(mesh); + ff_BIO_Generator_Maxwell< R >(generator, Ker, dof, alpha); + } else + ffassert(0); + + // build the Hmat + buildHmat(Hmat, generator, ds, t, s, pt, ps, comm); + + delete generator; + } else if (VFBEM == 2) { + BemPotential* Pot = getBemPotential(stack, largs); + bemtool::Geometry node_output; + + if (SRT0 && SRdHat::d == 2) { + // check if we have the good FE space for vector BEM + ffassert(Pot->typePotential == 4); // check MA_SL + } + + if (Vh->MaxNbNodePerElement == TRdHat::d + 1) + Mesh2Bemtool(ThV, node_output); + else if (Vh->MaxNbNodePerElement == 1) { + for (int i = 0; i < n; i++) { + pp = ThV[i](pbt); + p[0] = pp.x; + p[1] = pp.y; + p[2] = pp.z; + node_output.setnodes(p); + } + } else + ffassert(0); + + htool::VirtualGenerator< R >* generator; + if (SP0) { + bemtool::Dof< P0 > dof(mesh); + ff_POT_Generator< R, P0, MeshBemtool, SMesh >(generator, Pot, dof, mesh, node_output); + } else if (SP1) { + bemtool::Dof< P1 > dof(mesh, true); + ff_POT_Generator< R, P1, MeshBemtool, SMesh >(generator, Pot, dof, mesh, node_output); + } else if (SP2) { + bemtool::Dof< P2 > dof(mesh, true); + ff_POT_Generator< R, P2, MeshBemtool, SMesh >(generator, Pot, dof, mesh, node_output); + } else if (SRT0 && SRdHat::d == 2) { + bemtool::Dof< bemtool::RT0_2D > dof(mesh); + ff_POT_Generator_Maxwell< R, bemtool::RT0_2D >(generator, Pot, dof, mesh, node_output); + } else + ffassert(0); + + buildHmat(Hmat, generator, ds, t, s, pt, ps, comm); + + delete generator; + } } -template<> void creationHMatrixtoBEMForm(const FESpaceS * Uh, const FESpaceS * Vh, const int & VFBEM, - const std::list & largs, Stack stack, const Data_Bem_Solver &ds, HMatrixVirt **Hmat){ - cerr << "we can't use bemtool with Real type." << endl; - ffassert(0); - } - -template<> void creationHMatrixtoBEMForm(const FESpaceL * Uh, const FESpaceL * Vh, const int & VFBEM, - const std::list & largs, Stack stack, const Data_Bem_Solver &ds, HMatrixVirt **Hmat){ - cerr << "we can't use bemtool with Real type." << endl; - ffassert(0); - } +template<> +void creationHMatrixtoBEMForm< double, MeshS, FESpaceS, FESpaceS >(const FESpaceS* Uh, const FESpaceS* Vh, const int& VFBEM, const std::list< C_F0 >& largs, Stack stack, const Data_Bem_Solver& ds, + HMatrixVirt< double >** Hmat) { + cerr << "we can't use bemtool with Real type." << endl; + ffassert(0); +} + +template<> +void creationHMatrixtoBEMForm< double, MeshL, FESpaceL, FESpaceL >(const FESpaceL* Uh, const FESpaceL* Vh, const int& VFBEM, const std::list< C_F0 >& largs, Stack stack, const Data_Bem_Solver& ds, + HMatrixVirt< double >** Hmat) { + cerr << "we can't use bemtool with Real type." << endl; + ffassert(0); +} #endif ; diff --git a/plugin/mpi/common.hpp b/plugin/mpi/common.hpp index 1d08d354a..2bd71eeef 100644 --- a/plugin/mpi/common.hpp +++ b/plugin/mpi/common.hpp @@ -1,97 +1,93 @@ #ifndef _COMMON_ #define _COMMON_ -template R Build(A a, B b) { - return R(a, b); +template< class R, class A, class B > +R Build(A a, B b) { + return R(a, b); } -template +template< class RR, class AA = RR, class BB = AA > struct BinaryOp { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack s, const AA& a, const BB& b) { return RR(s, a, b); } + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack s, const AA& a, const BB& b) { return RR(s, a, b); } }; -template +template< class Op, char trans = 'N' > class pwr { - public: - Op* A; - pwr(Op* B) : A(B) { assert(A); } - const typename std::conditional::type c; - static constexpr char tr = trans; - mutable bool conjugate; - pwr(Stack s, Op* const& d, const typename std::conditional::type e) : A(d), c(e), conjugate(false) { } - operator Op* () const { return A; } + public: + Op* A; + pwr(Op* B) : A(B) { assert(A); } + const typename std::conditional< trans == 'T', std::string*, long >::type c; + static constexpr char tr = trans; + mutable bool conjugate; + pwr(Stack s, Op* const& d, const typename std::conditional< trans == 'T', std::string*, long >::type e) : A(d), c(e), conjugate(false) {} + operator Op*( ) const { return A; } }; -template +template< class RR, class AA = RR, class BB = AA > struct assign { -using first_argument_type = AA; -using second_argument_type = BB; -using result_type = RR; -template -static T check(T* t, typename std::enable_if::type* = 0) { + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + template< class V, class T > + static T check(T* t, typename std::enable_if< T::tr == 'H' >::type* = 0) { t->conjugate = true; - if(t->c != -1) - CompileError("A'^p, the p must be a constant == -1, sorry"); + if (t->c != -1) CompileError("A'^p, the p must be a constant == -1, sorry"); return *t; -} -template -static T check(T* t, typename std::enable_if::type* = 0) { - if(t->c != -1) - CompileError("A^p, the p must be a constant == -1 or == \"-T\" or == \"-H\", sorry"); + } + template< class V, class T > + static T check(T* t, typename std::enable_if< T::tr == 'N' >::type* = 0) { + if (t->c != -1) CompileError("A^p, the p must be a constant == -1 or == \"-T\" or == \"-H\", sorry"); return *t; -} -template -static T check(T* t, typename std::enable_if::type* = 0) { - if(t->c->compare("-H") == 0) - t->conjugate = true; - if(t->c->compare("-T") != 0 && !t->conjugate) - CompileError("A^p, the p must be a constant == -1 or == \"-T\" or == \"-H\", sorry"); + } + template< class V, class T > + static T check(T* t, typename std::enable_if< T::tr == 'T' >::type* = 0) { + if (t->c->compare("-H") == 0) t->conjugate = true; + if (t->c->compare("-T") != 0 && !t->conjugate) CompileError("A^p, the p must be a constant == -1 or == \"-T\" or == \"-H\", sorry"); return *t; -} -static RR f(Stack stack, const AA& a, const BB& b) { + } + static RR f(Stack stack, const AA& a, const BB& b) { ffassert(a); - check(&a); + check< BB >(&a); RR p(a, b); return p; -} + } }; -template +template< class Op > class OpTrans { - public: - Op* A; - OpTrans(Op* B) : A(B) { assert(A); } - operator Op& () const { return *A; } - operator Op* () const { return A; } + public: + Op* A; + OpTrans(Op* B) : A(B) { assert(A); } + operator Op&( ) const { return *A; } + operator Op*( ) const { return A; } }; -template class Inv, class V, class K = double, char trans = 'N'> -void addInv() { - Dcl_Type>(); - Dcl_Type, V*, K, trans>>(); - if(trans == 'T') { - Dcl_Type>(); - Dcl_Type, V*, K, 'T'>>(); - TheOperators->Add("^", new OneBinaryOperator_st, OpTrans, typename std::conditional<'N' == 'N', long, std::string*>::type>>); - TheOperators->Add("*", new OneBinaryOperator_st, V*, K, 'T'>, pwr, V*>>); - TheOperators->Add("=", new OneOperator2, V*, K, 'T'>>(Inv, V*, K, 'T'>::inv)); - TheOperators->Add("<-", new OneOperator2, V*, K, 'T'>>(Inv, V*, K, 'T'>::init)); - } - TheOperators->Add("^", new OneBinaryOperator_st, Op*, typename std::conditional::type>>); - TheOperators->Add("*", new OneBinaryOperator_st, V*, K, trans>, pwr, V*>>); - TheOperators->Add("=", new OneOperator2, V*, K, trans>>(Inv, V*, K, trans>::inv)); - TheOperators->Add("<-", new OneOperator2, V*, K, trans>>(Inv, V*, K, trans>::init)); +template< class Op, template< class, class, class, char > class Inv, class V, class K = double, char trans = 'N' > +void addInv( ) { + Dcl_Type< pwr< Op, trans > >( ); + Dcl_Type< Inv< pwr< Op, trans >, V*, K, trans > >( ); + if (trans == 'T') { + Dcl_Type< pwr< Op, 'H' > >( ); + Dcl_Type< Inv< pwr< Op, 'H' >, V*, K, 'T' > >( ); + TheOperators->Add("^", new OneBinaryOperator_st< BinaryOp< pwr< Op, 'H' >, OpTrans< Op >, typename std::conditional< 'N' == 'N', long, std::string* >::type > >); + TheOperators->Add("*", new OneBinaryOperator_st< assign< Inv< pwr< Op, 'H' >, V*, K, 'T' >, pwr< Op, 'H' >, V* > >); + TheOperators->Add("=", new OneOperator2< V*, V*, Inv< pwr< Op, 'H' >, V*, K, 'T' > >(Inv< pwr< Op, 'H' >, V*, K, 'T' >::inv)); + TheOperators->Add("<-", new OneOperator2< V*, V*, Inv< pwr< Op, 'H' >, V*, K, 'T' > >(Inv< pwr< Op, 'H' >, V*, K, 'T' >::init)); + } + TheOperators->Add("^", new OneBinaryOperator_st< BinaryOp< pwr< Op, trans >, Op*, typename std::conditional< trans == 'N', long, std::string* >::type > >); + TheOperators->Add("*", new OneBinaryOperator_st< assign< Inv< pwr< Op, trans >, V*, K, trans >, pwr< Op, trans >, V* > >); + TheOperators->Add("=", new OneOperator2< V*, V*, Inv< pwr< Op, trans >, V*, K, trans > >(Inv< pwr< Op, trans >, V*, K, trans >::inv)); + TheOperators->Add("<-", new OneOperator2< V*, V*, Inv< pwr< Op, trans >, V*, K, trans > >(Inv< pwr< Op, trans >, V*, K, trans >::init)); } -template class Prod, class V, class K = double, char N = 'N'> -void addProd() { - Dcl_Type>(); - if(N == 'T') { - Dcl_Type>(); - TheOperators->Add("\'", new OneOperator1, Op*>(Build)); - TheOperators->Add("*", new OneOperator2, OpTrans, V*>(Build)); - } - else - TheOperators->Add("*", new OneOperator2, Op*, V*>(Build)); - TheOperators->Add("=", new OneOperator2>(Prod::mv)); - TheOperators->Add("<-", new OneOperator2>(Prod::init)); +template< class Op, template< class, class, class, char > class Prod, class V, class K = double, char N = 'N' > +void addProd( ) { + Dcl_Type< Prod< Op*, V*, K, N > >( ); + if (N == 'T') { + Dcl_Type< OpTrans< Op > >( ); + TheOperators->Add("\'", new OneOperator1< OpTrans< Op >, Op* >(Build)); + TheOperators->Add("*", new OneOperator2< Prod< Op*, V*, K, N >, OpTrans< Op >, V* >(Build)); + } else + TheOperators->Add("*", new OneOperator2< Prod< Op*, V*, K, N >, Op*, V* >(Build)); + TheOperators->Add("=", new OneOperator2< V*, V*, Prod< Op*, V*, K, N > >(Prod< Op*, V*, K, N >::mv)); + TheOperators->Add("<-", new OneOperator2< V*, V*, Prod< Op*, V*, K, N > >(Prod< Op*, V*, K, N >::init)); } -#endif // _COMMON_ +#endif // _COMMON_ diff --git a/plugin/mpi/common_bem.hpp b/plugin/mpi/common_bem.hpp index 124fdf3f2..3a5a859f7 100644 --- a/plugin/mpi/common_bem.hpp +++ b/plugin/mpi/common_bem.hpp @@ -4,392 +4,378 @@ class BemKernel; class BemPotential; class BemKernel : public RefCounter { -public: - int typeKernel[2]={0,0}; // Laplace, Helmholtz, Yukawa - // typeKernel ={SL, DL, HS, TDL} and determine equation Laplace, Helmholtz if k==0 or not - std::complex wavenum[2]={0,0}; // parameter to Helmholtz - std::complex coeffcombi[2]={0,0}; - BemKernel(){} - BemKernel(string *tkernel, Complex alpha , Complex k) { - - coeffcombi[0]=alpha; - wavenum[0]=k; - - if(!tkernel->compare("SL")) - typeKernel[0] = 1; - else if(!tkernel->compare("DL")) - typeKernel[0] = 2; - else if(!tkernel->compare("HS")) - typeKernel[0] = 3; - else if(!tkernel->compare("TDL")) - typeKernel[0] = 4; - else if(!tkernel->compare("CST")) - typeKernel[0] = 5; - else if(!tkernel->compare("MA_SL")) - typeKernel[0] = 6; - else - ExecError("unknown BEM kernel type "); - - if(mpirank==0 && verbosity>5) - cout << "type BEM kernel " << *tkernel <<": " << typeKernel[0] << " coeff combi " << coeffcombi[0] << " wave number "<< wavenum[0] << endl; + public: + int typeKernel[2] = {0, 0}; // Laplace, Helmholtz, Yukawa + // typeKernel ={SL, DL, HS, TDL} and determine equation Laplace, Helmholtz if k==0 or not + std::complex< double > wavenum[2] = {0, 0}; // parameter to Helmholtz + std::complex< double > coeffcombi[2] = {0, 0}; + BemKernel( ) {} + BemKernel(string *tkernel, Complex alpha, Complex k) { + + coeffcombi[0] = alpha; + wavenum[0] = k; + + if (!tkernel->compare("SL")) + typeKernel[0] = 1; + else if (!tkernel->compare("DL")) + typeKernel[0] = 2; + else if (!tkernel->compare("HS")) + typeKernel[0] = 3; + else if (!tkernel->compare("TDL")) + typeKernel[0] = 4; + else if (!tkernel->compare("CST")) + typeKernel[0] = 5; + else if (!tkernel->compare("MA_SL")) + typeKernel[0] = 6; + else + ExecError("unknown BEM kernel type "); + + if (mpirank == 0 && verbosity > 5) cout << "type BEM kernel " << *tkernel << ": " << typeKernel[0] << " coeff combi " << coeffcombi[0] << " wave number " << wavenum[0] << endl; + } + ~BemKernel( ) {} + + BemKernel(const BemKernel &Bk) { + for (int i = 0; i < 2; i++) { + typeKernel[i] = Bk.typeKernel[i]; + wavenum[i] = Bk.wavenum[i]; + coeffcombi[i] = Bk.coeffcombi[i]; + } + }; + // alpha * ker + BemKernel(Stack s, const BemKernel &Bk, Complex alpha) { + for (int i = 0; i < 2; i++) { + typeKernel[i] = Bk.typeKernel[i]; + wavenum[i] = Bk.wavenum[i]; + coeffcombi[i] = alpha * Bk.coeffcombi[i]; } - ~BemKernel() {} - - BemKernel(const BemKernel &Bk) { - for(int i=0;i<2;i++) {typeKernel[i]=Bk.typeKernel[i]; wavenum[i]=Bk.wavenum[i]; coeffcombi[i]=Bk.coeffcombi[i]; } } ; - // alpha * ker - BemKernel(Stack s,const BemKernel &Bk, Complex alpha) { - for(int i=0;i<2;i++) {typeKernel[i]=Bk.typeKernel[i]; wavenum[i]=Bk.wavenum[i]; coeffcombi[i]=alpha*Bk.coeffcombi[i]; } } ; - - -private: - //BemKernel(const BemKernel &); - void operator=(const BemKernel &); + }; + + private: + // BemKernel(const BemKernel &); + void operator=(const BemKernel &); }; -//class FoperatorKBEM; -// new type for bem +// class FoperatorKBEM; +// new type for bem typedef const BemKernel *pBemKernel; typedef const BemPotential *pBemPotential; -typedef const BemKernel fkernel; -typedef const BemPotential fpotential; - -template -void Mesh2Bemtool(const ffmesh &Th, bemtool::Geometry &node, bemtoolmesh &mesh ) { - - typedef typename ffmesh::RdHat RdHat; - typedef typename ffmesh::Element E; - const int dHat = RdHat::d; - - // create the geometry; - - bemtool::R3 p; - for(int iv=0 ; iv10) std::cout << "Creating mesh domain (nodes)" << std::endl; - - mesh.set_elt(node); - bemtool::array I; - if(mpirank==0 && verbosity>10) std::cout << "End creating mesh domain mesh" << std::endl; - - if(mpirank==0 && verbosity>10) std::cout << "Creating geometry domain (elements)" << std::endl; - for(int it=0; it N(mesh); - for(int it=0; it10) std::cout << "end creating geometry domain" << std::endl; +typedef const BemKernel fkernel; +typedef const BemPotential fpotential; + +template< class ffmesh, class bemtoolmesh > +void Mesh2Bemtool(const ffmesh &Th, bemtool::Geometry &node, bemtoolmesh &mesh) { + + typedef typename ffmesh::RdHat RdHat; + typedef typename ffmesh::Element E; + const int dHat = RdHat::d; + + // create the geometry; + + bemtool::R3 p; + for (int iv = 0; iv < Th.nv; iv++) { + p[0] = Th.vertices[iv].x; + p[1] = Th.vertices[iv].y; + p[2] = Th.vertices[iv].z; + node.setnodes(p); + } + + node.initEltData( ); + + if (mpirank == 0 && verbosity > 10) std::cout << "Creating mesh domain (nodes)" << std::endl; + + mesh.set_elt(node); + bemtool::array< dHat + 1, int > I; + if (mpirank == 0 && verbosity > 10) std::cout << "End creating mesh domain mesh" << std::endl; + + if (mpirank == 0 && verbosity > 10) std::cout << "Creating geometry domain (elements)" << std::endl; + for (int it = 0; it < Th.nt; it++) { + const E &K(Th[it]); + for (int j = 0; j < dHat + 1; j++) I[j] = Th.operator( )(K[j]); + mesh.setOneElt(node, I); + } + + // mesh = unbounded; + // Orienting(mesh); + bemtool::Normal< dHat > N(mesh); + for (int it = 0; it < Th.nt; it++) { + const E &K(Th[it]); + Fem2D::R3 nn = K.NormalTUnitaire( ); + bemtool::R3 mm; + mm[0] = nn.x; + mm[1] = nn.y; + mm[2] = nn.z; + N.set(it, mm); + } + mesh.Orienting(N); + + if (mpirank == 0 && verbosity > 10) std::cout << "end creating geometry domain" << std::endl; } -template +template< class ffmesh > void Mesh2Bemtool(const ffmesh &Th, bemtool::Geometry &node) { - if(mpirank==0 && verbosity>10) std::cout << "Creating mesh output" << std::endl; - bemtool::R3 p; - Fem2D::R3 pp; - for(int iv=0 ; iv 10) std::cout << "Creating mesh output" << std::endl; + bemtool::R3 p; + Fem2D::R3 pp; + for (int iv = 0; iv < Th.nv; iv++) { + pp = Th.vertices[iv]; + p[0] = pp.x; + p[1] = pp.y; + p[2] = pp.z; + node.setnodes(p); + } } +/// Domain integration - operator +class CPartBemDI : public E_F0mps { + public: + static const int n_name_param = 3; // 12; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + enum typeofkind { int1dx1d = 0, int2dx2d = 1, int2dx1d = 2, int1dx2d = 3 }; + typeofkind kind; // 0 + int d, dHat; // 3d + typedef const CPartBemDI *Result; + Expression Th; + vector< Expression > what; + vector< int > whatis; // 0 -> long , 1 -> array ??? + + CPartBemDI(const basicAC_F0 &args, typeofkind b = int1dx1d, int ddim = 3, int ddimHat = 1) // always ddim=3d + : kind(b), d(ddim), dHat(ddimHat), Th(0), what(args.size( ) - 1), whatis(args.size( ) - 1) + + { + args.SetNameParam(n_name_param, name_param, nargs); + + if (d == 3 && dHat == 1) + Th = CastTo< pmeshL >(args[0]); + else if (d == 3 && dHat == 2) + Th = CastTo< pmeshS >(args[0]); + else + ffassert(0); // a faire + + int n = args.size( ); + for (int i = 1; i < n; i++) + if (!BCastTo< KN_< long > >(args[i])) { + whatis[i - 1] = 0; + what[i - 1] = CastTo< long >(args[i]); + } else { + whatis[i - 1] = 1; + what[i - 1] = CastTo< KN_< long > >(args[i]); + } + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), true); } // all type + AnyType operator( )(Stack) const { return SetAny< const CPartBemDI * >(this); } -/// Domain integration - operator + operator aType( ) const { return atype< const CPartBemDI * >( ); } + static E_F0 *f(const basicAC_F0 &args) { return new CPartBemDI(args); } + const Fem2D::QuadratureFormular &FIT(Stack) const; + const Fem2D::QuadratureFormular1d &FIE(Stack) const; + const Fem2D::GQuadratureFormular< Fem2D::R3 > &FIV(Stack) const; // 3d +}; -class CPartBemDI: public E_F0mps { -public: - - static const int n_name_param =3; //12; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs [n_name_param]; - enum typeofkind { int1dx1d=0, int2dx2d=1, int2dx1d=2, int1dx2d=3 } ; - typeofkind kind; // 0 - int d, dHat; // 3d - typedef const CPartBemDI* Result; - Expression Th; - vector what; - vector whatis; // 0 -> long , 1 -> array ??? - - - CPartBemDI(const basicAC_F0 & args,typeofkind b=int1dx1d,int ddim=3, int ddimHat=1) // always ddim=3d - :kind(b),d(ddim),dHat(ddimHat), - Th(0), what(args.size()-1), whatis(args.size()-1) - - { - args.SetNameParam(n_name_param,name_param,nargs); - - if(d==3 && dHat==1) - Th=CastTo(args[0]); - else if(d==3 && dHat==2) - Th=CastTo(args[0]); - else ffassert(0); // a faire - - int n=args.size(); - for (int i=1;i >(args[i]) ) { - whatis[i-1]=0; - what[i-1]=CastTo(args[i]); - } - else { - whatis[i-1]=1; - what[i-1]=CastTo >(args[i]); - } - +class CBemDomainOfIntegration : public E_F0mps { + public: + static const int n_name_param = 3; // 12; + static basicAC_F0::name_and_type name_param[]; + Expression nargs_t[n_name_param]; + // typeofkind kind; // 0 + int d_s, dHat_s, d_t, dHat_t; // 3d + typedef const CBemDomainOfIntegration *Result; + Expression Th_s, Th_t, BemPartDI; + vector< Expression > what_s, what_t; + vector< int > whatis_s, whatis_t; + // CBemDomainOfIntegration(); + CBemDomainOfIntegration(const basicAC_F0 &args_t, int ddim = 3, int ddimHat = 1) // always ddim=3d + : d_s(0), dHat_s(0), d_t(ddim), dHat_t(ddimHat), Th_s(0), what_s(0), whatis_s(0), Th_t(0), what_t(args_t.size( ) - 1), whatis_t(args_t.size( ) - 1) + + { + args_t.SetNameParam(n_name_param, name_param, nargs_t); + // acces to the value of the fist di Th_s + const CPartBemDI *sourceDI(dynamic_cast< const CPartBemDI * >((Expression)args_t[0])); + + CPartBemDI::typeofkind kind_s = sourceDI->kind; // int1dx1d=0, int2dx2d=1, int2dx1d=2, int1dx2d=3 + d_s = sourceDI->d; + dHat_s = sourceDI->dHat; + + // check the integral operator integral + if (kind_s == 0 || kind_s == 2) + Th_t = CastTo< pmeshL >(args_t[1]); + else if (kind_s == 1 || kind_s == 3) + Th_t = CastTo< pmeshS >(args_t[1]); + else if (kind_s == 0 || kind_s == 3) + Th_s = sourceDI->Th; // Th_s=CastTo(sourceDI->Th); + else if (kind_s == 1 || kind_s == 2) + Th_s = sourceDI->Th; + else + ffassert(0); // a faire + + if (mpirank == 0 && verbosity > 5) + cout << " CBemDomainOfIntegration " << kind_s << " Th_s: " << &Th_s << " d_s= " << d_s << " dHat_s= " << dHat_s << " " << " Th_t: " << &Th_t << " d_t= " << d_t << " dHat_t= " << dHat_t << " " + << endl; + + // read the argument (Th_t,.....) + int n_t = args_t.size( ); + for (int i = 2; i < n_t; i++) + if (!BCastTo< KN_< long > >(args_t[i])) { + whatis_t[i - 1] = 0; + what_t[i - 1] = CastTo< long >(args_t[i]); + } else { + whatis_t[i - 1] = 1; + what_t[i - 1] = CastTo< KN_< long > >(args_t[i]); + } + int n_s = (sourceDI->what).size( ); + for (int i = 1; i < n_s; i++) { + + whatis_s[i - 1] = sourceDI->whatis[i - 1]; + what_s[i - 1] = sourceDI->what[i - 1]; } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type - AnyType operator()(Stack ) const { return SetAny(this);} - - operator aType () const { return atype();} - - static E_F0 * f(const basicAC_F0 & args) { return new CPartBemDI(args);} - - const Fem2D::QuadratureFormular & FIT(Stack) const ; - const Fem2D::QuadratureFormular1d & FIE(Stack) const ; - const Fem2D::GQuadratureFormular & FIV(Stack) const ; // 3d - -}; + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const CPartBemDI * >( ), true); } // all type + AnyType operator( )(Stack) const { return SetAny< const CBemDomainOfIntegration * >(this); } + operator aType( ) const { return atype< const CBemDomainOfIntegration * >( ); } + // static E_F0 * f(const basicAC_F0 & args_s,const basicAC_F0 & args_t) { return new CBemDomainOfIntegration(args_s,args_t);} + static E_F0 *f(const basicAC_F0 &args_s) { return new CBemDomainOfIntegration(args_s); } -class CBemDomainOfIntegration: public E_F0mps { -public: - - static const int n_name_param =3; //12; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs_t [n_name_param]; - // typeofkind kind; // 0 - int d_s, dHat_s, d_t, dHat_t; // 3d - typedef const CBemDomainOfIntegration* Result; - Expression Th_s, Th_t, BemPartDI; - vector what_s, what_t; - vector whatis_s, whatis_t; - //CBemDomainOfIntegration(); - CBemDomainOfIntegration(const basicAC_F0 & args_t, int ddim=3, int ddimHat=1) // always ddim=3d - :d_s(0),dHat_s(0),d_t(ddim),dHat_t(ddimHat), - Th_s(0), what_s(0), whatis_s(0), - Th_t(0), what_t(args_t.size()-1), whatis_t(args_t.size()-1) - - { - args_t.SetNameParam(n_name_param,name_param,nargs_t); - // acces to the value of the fist di Th_s - const CPartBemDI * sourceDI(dynamic_cast((Expression) args_t[0])); - - CPartBemDI::typeofkind kind_s= sourceDI->kind; // int1dx1d=0, int2dx2d=1, int2dx1d=2, int1dx2d=3 - d_s=sourceDI->d; - dHat_s=sourceDI->dHat; - - // check the integral operator integral - if(kind_s==0 || kind_s==2) - Th_t=CastTo(args_t[1]); - else if(kind_s==1 || kind_s==3) - Th_t=CastTo(args_t[1]); - else if(kind_s==0 || kind_s==3) - Th_s=sourceDI->Th; //Th_s=CastTo(sourceDI->Th); - else if(kind_s==1 || kind_s==2) - Th_s=sourceDI->Th; - else ffassert(0); // a faire - - if (mpirank==0 && verbosity >5) - cout << " CBemDomainOfIntegration " << kind_s << " Th_s: " << &Th_s << " d_s= " << d_s << " dHat_s= " << dHat_s << " " << - " Th_t: " << &Th_t << " d_t= " << d_t << " dHat_t= " << dHat_t << " " << endl; - - // read the argument (Th_t,.....) - int n_t=args_t.size(); - for (int i=2;i >(args_t[i]) ) { - whatis_t[i-1]=0; - what_t[i-1]=CastTo(args_t[i]); - } - else { - whatis_t[i-1]=1; - what_t[i-1]=CastTo >(args_t[i]); - } - int n_s=(sourceDI->what).size(); - for (int i=1;iwhatis[i-1]; - what_s[i-1]=sourceDI->what[i-1]; - } - - } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type - AnyType operator()(Stack ) const { return SetAny(this);} - - operator aType () const { return atype();} - - //static E_F0 * f(const basicAC_F0 & args_s,const basicAC_F0 & args_t) { return new CBemDomainOfIntegration(args_s,args_t);} - static E_F0 * f(const basicAC_F0 & args_s) { return new CBemDomainOfIntegration(args_s);} - - const Fem2D::QuadratureFormular & FIT(Stack) const ; - const Fem2D::QuadratureFormular1d & FIE(Stack) const ; - const Fem2D::GQuadratureFormular & FIV(Stack) const ; // 3d - + const Fem2D::QuadratureFormular &FIT(Stack) const; + const Fem2D::QuadratureFormular1d &FIE(Stack) const; + const Fem2D::GQuadratureFormular< Fem2D::R3 > &FIV(Stack) const; // 3d }; +basicAC_F0::name_and_type CPartBemDI::name_param[] = { + {"qft", &typeid(const Fem2D::QuadratureFormular *)}, // 0 + {"qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, + {"qforder", &typeid(long)}, // 2 + //{ "qfnbpT",&typeid(long)}, + //{ "qfnbpE",&typeid(long)}, + //{ "optimize",&typeid(long)}, + //{ "binside",&typeid(double)}, + //{ "mortar",&typeid(bool)}, + {"qfV", &typeid(const Fem2D::GQuadratureFormular< Fem2D::R3 > *)}, // 8 -> 3 + //{ "levelset",&typeid(double)}, + //{ "mapt",&typeid(E_Array)}, + //{ "mapu",&typeid(E_Array)} - -basicAC_F0::name_and_type CPartBemDI::name_param[]= { - { "qft", &typeid(const Fem2D::QuadratureFormular *)}, //0 - { "qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, - { "qforder",&typeid(long)}, // 2 - //{ "qfnbpT",&typeid(long)}, - //{ "qfnbpE",&typeid(long)}, - //{ "optimize",&typeid(long)}, - //{ "binside",&typeid(double)}, - //{ "mortar",&typeid(bool)}, - { "qfV", &typeid(const Fem2D::GQuadratureFormular *)}, // 8 -> 3 - //{ "levelset",&typeid(double)}, - //{ "mapt",&typeid(E_Array)}, - //{ "mapu",&typeid(E_Array)} - - -}; -basicAC_F0::name_and_type CBemDomainOfIntegration::name_param[]= { - { "qft", &typeid(const Fem2D::QuadratureFormular *)}, //0 - { "qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, - { "qforder",&typeid(long)}, // 2 - //{ "qfnbpT",&typeid(long)}, - //{ "qfnbpE",&typeid(long)}, - //{ "optimize",&typeid(long)}, - //{ "binside",&typeid(double)}, - //{ "mortar",&typeid(bool)}, - { "qfV", &typeid(const Fem2D::GQuadratureFormular *)}, // 8 -> 3 - //{ "levelset",&typeid(double)}, - //{ "mapt",&typeid(E_Array)}, - //{ "mapu",&typeid(E_Array)} - - }; +basicAC_F0::name_and_type CBemDomainOfIntegration::name_param[] = { + {"qft", &typeid(const Fem2D::QuadratureFormular *)}, // 0 + {"qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, + {"qforder", &typeid(long)}, // 2 + //{ "qfnbpT",&typeid(long)}, + //{ "qfnbpE",&typeid(long)}, + //{ "optimize",&typeid(long)}, + //{ "binside",&typeid(double)}, + //{ "mortar",&typeid(bool)}, + {"qfV", &typeid(const Fem2D::GQuadratureFormular< Fem2D::R3 > *)}, // 8 -> 3 + //{ "levelset",&typeid(double)}, + //{ "mapt",&typeid(E_Array)}, + //{ "mapu",&typeid(E_Array)} +}; - -class CPartBemDI1d1d: public CPartBemDI { -public: - CPartBemDI1d1d( const basicAC_F0 & args_s) :CPartBemDI(args_s,int1dx1d,3,1) {} - static E_F0 * f(const basicAC_F0 & args_s) { return new CPartBemDI(args_s,int1dx1d,3,1);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CPartBemDI1d1d : public CPartBemDI { + public: + CPartBemDI1d1d(const basicAC_F0 &args_s) : CPartBemDI(args_s, int1dx1d, 3, 1) {} + static E_F0 *f(const basicAC_F0 &args_s) { return new CPartBemDI(args_s, int1dx1d, 3, 1); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshL >( ), true); } // all type }; -class CPartBemDI2d2d: public CPartBemDI { -public: - CPartBemDI2d2d(const basicAC_F0 & args_s) :CPartBemDI(args_s,int2dx2d,3,2) {} - static E_F0 * f(const basicAC_F0 & args_s) { return new CPartBemDI(args_s,int2dx2d,3,2);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CPartBemDI2d2d : public CPartBemDI { + public: + CPartBemDI2d2d(const basicAC_F0 &args_s) : CPartBemDI(args_s, int2dx2d, 3, 2) {} + static E_F0 *f(const basicAC_F0 &args_s) { return new CPartBemDI(args_s, int2dx2d, 3, 2); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; -class CPartBemDI1d2d: public CPartBemDI { -public: - CPartBemDI1d2d(const basicAC_F0 & args_s) :CPartBemDI(args_s,int1dx2d,3,1) {} - static E_F0 * f(const basicAC_F0 & args_s) { return new CPartBemDI(args_s,int2dx2d,3,1);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CPartBemDI1d2d : public CPartBemDI { + public: + CPartBemDI1d2d(const basicAC_F0 &args_s) : CPartBemDI(args_s, int1dx2d, 3, 1) {} + static E_F0 *f(const basicAC_F0 &args_s) { return new CPartBemDI(args_s, int2dx2d, 3, 1); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; -class CPartBemDI2d1d: public CPartBemDI { -public: - CPartBemDI2d1d(const basicAC_F0 & args_s) :CPartBemDI(args_s,int2dx1d,3,2) {} - static E_F0 * f(const basicAC_F0 & args_s) { return new CPartBemDI(args_s,int2dx2d,3,2);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CPartBemDI2d1d : public CPartBemDI { + public: + CPartBemDI2d1d(const basicAC_F0 &args_s) : CPartBemDI(args_s, int2dx1d, 3, 2) {} + static E_F0 *f(const basicAC_F0 &args_s) { return new CPartBemDI(args_s, int2dx2d, 3, 2); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; //// begin type BEM kernel / potential - - class listBemKernel { -public: - list *lbk; - void init() { lbk=new list;} - void destroy() { delete lbk;} - listBemKernel(Stack s,BemKernel const*bk) : lbk(Add2StackOfPtr2Free(s,new list)) { lbk->push_back(bk);} - listBemKernel(Stack s,BemKernel const*const bka,BemKernel const* const bkb) : lbk(Add2StackOfPtr2Free(s,new list)) { lbk->push_back(bka);lbk->push_back(bkb);} - listBemKernel(Stack s,const listBemKernel &l,BemKernel const*const bk) : lbk(Add2StackOfPtr2Free(s,new list(*l.lbk))) { lbk->push_back(bk);} - listBemKernel(){}; + public: + list< BemKernel const * > *lbk; + void init( ) { lbk = new list< BemKernel const * >; } + void destroy( ) { delete lbk; } + listBemKernel(Stack s, BemKernel const *bk) : lbk(Add2StackOfPtr2Free(s, new list< BemKernel const * >)) { lbk->push_back(bk); } + listBemKernel(Stack s, BemKernel const *const bka, BemKernel const *const bkb) : lbk(Add2StackOfPtr2Free(s, new list< BemKernel const * >)) { + lbk->push_back(bka); + lbk->push_back(bkb); + } + listBemKernel(Stack s, const listBemKernel &l, BemKernel const *const bk) : lbk(Add2StackOfPtr2Free(s, new list< BemKernel const * >(*l.lbk))) { lbk->push_back(bk); } + listBemKernel( ) {}; }; - -template +template< class RR, class AA = RR, class BB = AA > struct Op_addBemKernel { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack s,const AA & a,const BB & b) { - if (mpirank==0 && verbosity>10) cout << "test " < 10) cout << "test " << typeid(RR).name( ) << " " << typeid(AA).name( ) << " " << typeid(BB).name( ) << endl; + return RR(s, a, b); + } }; - -template +template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op_setBemKernel { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack stack, const AA & a,const BB & b) - { - ffassert(a); - const pBemKernel p=new BemKernel(*b); - - if (!INIT && *a) - (**a).destroy( ); - *a = p; - return a; - } + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack stack, const AA &a, const BB &b) { + ffassert(a); + const pBemKernel p = new BemKernel(*b); + + if (!INIT && *a) (**a).destroy( ); + *a = p; + return a; + } }; - -template +template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op_setCombBemKernel { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack stack, const AA & a,const BB & b) - { - ffassert(a); - const pBemKernel p=combKernel(b); - - if (!INIT && *a) - (**a).destroy( ); - *a = p; - return a; - } + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack stack, const AA &a, const BB &b) { + ffassert(a); + const pBemKernel p = combKernel(b); + + if (!INIT && *a) (**a).destroy( ); + *a = p; + return a; + } }; - -template +template< class RR, class AA = RR, class BB = AA > struct Op_coeffBemKernel1 { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack s,const AA & a,const BB & b) { - if (mpirank==0 && verbosity>10) cout << "test " < 10) cout << "test " << typeid(RR).name( ) << " " << typeid(AA).name( ) << " " << typeid(BB).name( ) << endl; + + RR ker = new BemKernel(s, *b, a); + Add2StackOfPtr2Free(s, ker); + return ker; + } }; // version ok class OP_MakeBemKernel { public: - class Op : public E_F0mps { public: static const int n_name_param = 1; @@ -400,38 +386,30 @@ class OP_MakeBemKernel { typedef pBemKernel *A; typedef string *B; Expression a, b; - + Op(const basicAC_F0 &args); AnyType operator( )(Stack s) const { A bemker = GetAny< A >((*a)(s)); B type = GetAny< B >((*b)(s)); - Complex alpha(1.0,0.0);//(arg(0, s, 1)); - Complex k(arg(0, s, Complex(0.,0.))); - *bemker = new BemKernel(type,alpha,k); + Complex alpha(1.0, 0.0); //(arg(0, s, 1)); + Complex k(arg(0, s, Complex(0., 0.))); + *bemker = new BemKernel(type, alpha, k); return SetAny< R >(bemker); } }; typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), false); } }; +OP_MakeBemKernel::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])) { args.SetNameParam(n_name_param, name_param, nargs); } - -OP_MakeBemKernel::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])) { - args.SetNameParam(n_name_param, name_param, nargs); -} - -basicAC_F0::name_and_type OP_MakeBemKernel::Op::name_param[] = { {"k", &typeid(Complex)} }; +basicAC_F0::name_and_type OP_MakeBemKernel::Op::name_param[] = {{"k", &typeid(Complex)}}; class OP_MakeBemKernelFunc { public: - class Op : public E_F0mps { public: static const int n_name_param = 1; @@ -441,93 +419,88 @@ class OP_MakeBemKernelFunc { typedef pBemKernel A; typedef string *B; Expression b; - + Op(const basicAC_F0 &args); AnyType operator( )(Stack s) const { B type = GetAny< B >((*b)(s)); - Complex alpha=1.;//(arg(0, s, 1)); - Complex k(arg(0, s, Complex(0.,0.))); - A bemker = new BemKernel(type,alpha,k); - Add2StackOfPtr2Free(s,bemker); + Complex alpha = 1.; //(arg(0, s, 1)); + Complex k(arg(0, s, Complex(0., 0.))); + A bemker = new BemKernel(type, alpha, k); + Add2StackOfPtr2Free(s, bemker); return SetAny< A >(bemker); } }; typedef Op::A Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::B >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::B >( ), false); } }; -OP_MakeBemKernelFunc::Op::Op(const basicAC_F0 &args) - : b(to< B >(args[0])) { - // cout << "\n\n **** OP_MakeBemKernelFunc::Op::Op() \n\n" << endl; +OP_MakeBemKernelFunc::Op::Op(const basicAC_F0 &args) : b(to< B >(args[0])) { + // cout << "\n\n **** OP_MakeBemKernelFunc::Op::Op() \n\n" << endl; args.SetNameParam(n_name_param, name_param, nargs); } -basicAC_F0::name_and_type OP_MakeBemKernelFunc::Op::name_param[] = { {"k", &typeid(Complex)} }; +basicAC_F0::name_and_type OP_MakeBemKernelFunc::Op::name_param[] = {{"k", &typeid(Complex)}}; +class FormalBemKernel : public OneOperator { + public: + FormalBemKernel( ) : OneOperator(atype< C_F0 >( ), atype< string * >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new OP_MakeBemKernelFunc::Op(args); + aType r = atype< const BemKernel * >( ); + return C_F0(e, r); + } -class FormalBemKernel : public OneOperator{ -public: - - FormalBemKernel( ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new OP_MakeBemKernelFunc::Op(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; class BemPotential : public RefCounter { -public: - - int typePotential; // Laplace, Helmholtz, Yukawa - // typePotential ={SL=0, DL=1, HS=2, TDL=3} and determine equation Laplace, Helmholtz if k==0 or not - std::complex wavenum; // parameter to Helmholtz - - BemPotential(){} - - BemPotential(string *tpotential, Complex k) : typePotential(-1), wavenum(k) { - - if(!tpotential->compare("SL")) - typePotential = 1; - else if(!tpotential->compare("DL")) - typePotential = 2; - else if(!tpotential->compare("CST")) - typePotential = 3; - else if(!tpotential->compare("MA_SL")) - typePotential = 4; - else - ExecError("unknown BEM Potential type "); - - if(mpirank==0 && verbosity>5) - cout << "type BEM Potential " << *tpotential <<": "<< tpotential <<": " << typePotential << " wave number "<< wavenum << endl; - } + public: + int typePotential; // Laplace, Helmholtz, Yukawa + // typePotential ={SL=0, DL=1, HS=2, TDL=3} and determine equation Laplace, Helmholtz if k==0 or not + std::complex< double > wavenum; // parameter to Helmholtz + + BemPotential( ) {} + + BemPotential(string *tpotential, Complex k) : typePotential(-1), wavenum(k) { + + if (!tpotential->compare("SL")) + typePotential = 1; + else if (!tpotential->compare("DL")) + typePotential = 2; + else if (!tpotential->compare("CST")) + typePotential = 3; + else if (!tpotential->compare("MA_SL")) + typePotential = 4; + else + ExecError("unknown BEM Potential type "); + + if (mpirank == 0 && verbosity > 5) cout << "type BEM Potential " << *tpotential << ": " << tpotential << ": " << typePotential << " wave number " << wavenum << endl; + } - ~BemPotential() {} - -private: - BemPotential(const BemPotential &); - void operator=(const BemPotential &); -}; + ~BemPotential( ) {} + private: + BemPotential(const BemPotential &); + void operator=(const BemPotential &); +}; class OP_MakeBemPotential { public: class Op : public E_F0mps { public: static const int n_name_param = 1; - + static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; Complex arg(int i, Stack stack, Complex a) const { return nargs[i] ? GetAny< Complex >((*nargs[i])(stack)) : a; } - + typedef pBemPotential *R; typedef pBemPotential *A; typedef string *B; @@ -537,29 +510,23 @@ class OP_MakeBemPotential { AnyType operator( )(Stack s) const { A bempot = GetAny< A >((*a)(s)); B type = GetAny< B >((*b)(s)); - Complex k(arg(0, s, Complex(0.0,0.0))); - *bempot = new BemPotential(type,k); + Complex k(arg(0, s, Complex(0.0, 0.0))); + *bempot = new BemPotential(type, k); return SetAny< R >(bempot); } }; // end Op class typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), false); } }; -OP_MakeBemPotential::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])) { - args.SetNameParam(n_name_param, name_param, nargs); -} +OP_MakeBemPotential::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])) { args.SetNameParam(n_name_param, name_param, nargs); } -basicAC_F0::name_and_type OP_MakeBemPotential::Op::name_param[] = { {"k", &typeid(Complex)} }; +basicAC_F0::name_and_type OP_MakeBemPotential::Op::name_param[] = {{"k", &typeid(Complex)}}; class OP_MakeBemPotentialFunc { public: - class Op : public E_F0mps { public: static const int n_name_param = 1; @@ -569,1021 +536,1318 @@ class OP_MakeBemPotentialFunc { typedef pBemPotential A; typedef string *B; Expression b; - + Op(const basicAC_F0 &args); AnyType operator( )(Stack s) const { B type = GetAny< B >((*b)(s)); - Complex k(arg(0, s, Complex(0.0,0.0))); - A bempot = new BemPotential(type,k); + Complex k(arg(0, s, Complex(0.0, 0.0))); + A bempot = new BemPotential(type, k); return SetAny< A >(bempot); } }; typedef Op::A Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::B >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::B >( ), false); } }; -OP_MakeBemPotentialFunc::Op::Op(const basicAC_F0 &args) - : b(to< B >(args[0])) { - args.SetNameParam(n_name_param, name_param, nargs); -} - -basicAC_F0::name_and_type OP_MakeBemPotentialFunc::Op::name_param[] = { {"k", &typeid(Complex)} }; +OP_MakeBemPotentialFunc::Op::Op(const basicAC_F0 &args) : b(to< B >(args[0])) { args.SetNameParam(n_name_param, name_param, nargs); } +basicAC_F0::name_and_type OP_MakeBemPotentialFunc::Op::name_param[] = {{"k", &typeid(Complex)}}; -class FormalBemPotential : public OneOperator{ -public: - - FormalBemPotential( ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new OP_MakeBemPotentialFunc::Op(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} +class FormalBemPotential : public OneOperator { + public: + FormalBemPotential( ) : OneOperator(atype< C_F0 >( ), atype< string * >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new OP_MakeBemPotentialFunc::Op(args); + aType r = atype< const BemPotential * >( ); + return C_F0(e, r); + } + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; - // fusion of Bem Kernel in case combined kernels -BemKernel *combKernel (listBemKernel const &lbemker){ - int kk=0; - bool LaplaceK=false, HelmholtzK=false; - const list< const BemKernel * > lbk(*lbemker.lbk); - BemKernel *combBemKernel=new BemKernel(); - for (list< const BemKernel * >::const_iterator i = lbk.begin( ); i != lbk.end( ); i++) { - if (!*i) continue; - const BemKernel &bkb(**i); - combBemKernel->typeKernel[kk] = bkb.typeKernel[0]; - // test same equation kernel - (combBemKernel->wavenum[kk]!=0.) ? HelmholtzK=true : LaplaceK=true; - - // ExecError(" combined kernel have to be the same type equation Laplace or Helmholtz"); - combBemKernel->coeffcombi[kk] = bkb.coeffcombi[0]; - combBemKernel->wavenum[kk] = bkb.wavenum[0]; - if(kk>4) ExecError(" combined kernel: 4 max kernels "); - kk++; - } - // check the same wave number ? - if( HelmholtzK== LaplaceK) ExecError(" combined kernel: must be same equation kernels Laplace or Helmholtz"); - if (mpirank==0 && verbosity>5) - for (int i=0;itypeKernel[i] << " coeff combi " << - combBemKernel->coeffcombi[i] << " wave number "<< combBemKernel->wavenum[i] << endl; - - return combBemKernel; -} +BemKernel *combKernel(listBemKernel const &lbemker) { + int kk = 0; + bool LaplaceK = false, HelmholtzK = false; + const list< const BemKernel * > lbk(*lbemker.lbk); + BemKernel *combBemKernel = new BemKernel( ); + for (list< const BemKernel * >::const_iterator i = lbk.begin( ); i != lbk.end( ); i++) { + if (!*i) continue; + const BemKernel &bkb(**i); + combBemKernel->typeKernel[kk] = bkb.typeKernel[0]; + // test same equation kernel + (combBemKernel->wavenum[kk] != 0.) ? HelmholtzK = true : LaplaceK = true; + + // ExecError(" combined kernel have to be the same type equation Laplace or Helmholtz"); + combBemKernel->coeffcombi[kk] = bkb.coeffcombi[0]; + combBemKernel->wavenum[kk] = bkb.wavenum[0]; + if (kk > 4) ExecError(" combined kernel: 4 max kernels "); + kk++; + } + // check the same wave number ? + if (HelmholtzK == LaplaceK) ExecError(" combined kernel: must be same equation kernels Laplace or Helmholtz"); + if (mpirank == 0 && verbosity > 5) + for (int i = 0; i < kk; i++) + cout << "combined type BEM kernel " << combBemKernel->typeKernel[i] << " coeff combi " << combBemKernel->coeffcombi[i] << " wave number " << combBemKernel->wavenum[i] << endl; + return combBemKernel; +} // BEM variational form // define a bilinear form for BEM -class FoperatorKBEM : public E_F0mps { public: - typedef const FoperatorKBEM* Result; - typedef finconnue * Fi; - typedef ftest * Ft; - typedef fkernel * KBem; - - Fi fi; - Ft ft; - Expression kbem; - // Morice : Ils ne sont pas utilises dans cette version. - // Mais sont rajoutes pour clarifier la valeur "fi->v[0].first.first;" - //int nb_component_FEspace_inc; - //int nb_component_FEspace_test; - - FoperatorKBEM(const basicAC_F0 & args) :fi(0),ft(0),kbem(0) { - aType t_a = atype< E_Array >( ); - ffassert(args.size()==3); - - kbem= CastTo(args[0]); - // only BEM(bemkernel,u0,v0); - // BEM(bemkernel,[u0,..,un],[v0,..,vm]); - // are valid - if( args[1].left( ) == t_a && args[2].left( ) == t_a ){ - // case BEM(bemkernel,[u0,..,un],[v0,..,vm]) - // Here, we are in the compilation step - // so we can't check if the size of ea.size is correct - const E_Array &ea = *dynamic_cast< const E_Array * >(args[1].LeftValue( )); - ffassert(&ea); - ffassert(ea.size() == 3); // hack for "MA_SL" - fi = dynamic_cast(CastTo(ea[ea.size()-1])); - - const E_Array &et = *dynamic_cast< const E_Array * >(args[2].LeftValue( )); - ffassert(&et); - ffassert(et.size() == 3); // hack for "MA_SL" - ft = dynamic_cast(CastTo(et[et.size()-1])); - - // Remark: n = fi->v[0].first.first; - // Remark: m = ft->v[0].first.first; - } - else if( args[1].left( ) != t_a && args[2].left( ) != t_a ){ - // case BEM(bemkernel,u0,v0); - fi= dynamic_cast(CastTo(args[1])); - ft = dynamic_cast(CastTo(args[2])); - } - else{ - CompileError("The BEM keyword inside an integral must be : BEM(bemkernel,u0,v0); or BEM(bemkernel,[u0,..,un],[v0,..,vm]); "); - } - // nb_component_FEspace_inc = fi->v[0].first.first+1; - // nb_component_FEspace_test = ft->v[0].first.first+1; - ffassert(kbem && fi && ft); - } - - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - FoperatorKBEM(const FoperatorKBEM & fk) : kbem(fk.kbem),fi(fk.fi),ft(fk.ft) {} - FoperatorKBEM( Expression o_kbem, const Finconnue &o_fi, const Ftest & o_ft) : kbem(o_kbem){ - fi = new Finconnue(o_fi); - ft = new Ftest(o_ft); +class FoperatorKBEM : public E_F0mps { + public: + typedef const FoperatorKBEM *Result; + typedef finconnue *Fi; + typedef ftest *Ft; + typedef fkernel *KBem; + + Fi fi; + Ft ft; + Expression kbem; + // Morice : Ils ne sont pas utilises dans cette version. + // Mais sont rajoutes pour clarifier la valeur "fi->v[0].first.first;" + // int nb_component_FEspace_inc; + // int nb_component_FEspace_test; + + FoperatorKBEM(const basicAC_F0 &args) : fi(0), ft(0), kbem(0) { + aType t_a = atype< E_Array >( ); + ffassert(args.size( ) == 3); + + kbem = CastTo< KBem >(args[0]); + // only BEM(bemkernel,u0,v0); + // BEM(bemkernel,[u0,..,un],[v0,..,vm]); + // are valid + if (args[1].left( ) == t_a && args[2].left( ) == t_a) { + // case BEM(bemkernel,[u0,..,un],[v0,..,vm]) + // Here, we are in the compilation step + // so we can't check if the size of ea.size is correct + const E_Array &ea = *dynamic_cast< const E_Array * >(args[1].LeftValue( )); + ffassert(&ea); + ffassert(ea.size( ) == 3); // hack for "MA_SL" + fi = dynamic_cast< Fi >(CastTo< Fi >(ea[ea.size( ) - 1])); + + const E_Array &et = *dynamic_cast< const E_Array * >(args[2].LeftValue( )); + ffassert(&et); + ffassert(et.size( ) == 3); // hack for "MA_SL" + ft = dynamic_cast< Ft >(CastTo< Ft >(et[et.size( ) - 1])); + + // Remark: n = fi->v[0].first.first; + // Remark: m = ft->v[0].first.first; + } else if (args[1].left( ) != t_a && args[2].left( ) != t_a) { + // case BEM(bemkernel,u0,v0); + fi = dynamic_cast< Fi >(CastTo< Fi >(args[1])); + ft = dynamic_cast< Ft >(CastTo< Ft >(args[2])); + } else { + CompileError("The BEM keyword inside an integral must be : BEM(bemkernel,u0,v0); or BEM(bemkernel,[u0,..,un],[v0,..,vm]); "); } + // nb_component_FEspace_inc = fi->v[0].first.first+1; + // nb_component_FEspace_test = ft->v[0].first.first+1; + ffassert(kbem && fi && ft); + } + + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + FoperatorKBEM(const FoperatorKBEM &fk) : kbem(fk.kbem), fi(fk.fi), ft(fk.ft) {} + FoperatorKBEM(Expression o_kbem, const Finconnue &o_fi, const Ftest &o_ft) : kbem(o_kbem) { + fi = new Finconnue(o_fi); + ft = new Ftest(o_ft); + } }; // define a bilinear form for BEM - - -class BemFormBilinear : virtual public E_F0mps { public: - int type=-1; - static E_F0 * f(const basicAC_F0 & args); +class BemFormBilinear : virtual public E_F0mps { + public: + int type = -1; + static E_F0 *f(const basicAC_F0 &args); }; +class BemKFormBilinear : public BemFormBilinear { + public: + typedef const BemFormBilinear *Result; + typedef const CBemDomainOfIntegration *A; + typedef const FoperatorKBEM *B; + A di; + FoperatorKBEM *b; + + BemKFormBilinear(const basicAC_F0 &args) { + di = dynamic_cast< A >(CastTo< A >(args[0])); + B Kb = dynamic_cast< B >(CastTo< B >(args[1])); + b = new FoperatorKBEM(*Kb); + ffassert(di && Kb); + type = 1; + }; -class BemKFormBilinear : public BemFormBilinear { public: - typedef const BemFormBilinear* Result; - typedef const CBemDomainOfIntegration * A; - typedef const FoperatorKBEM * B; - A di; - FoperatorKBEM * b; - - BemKFormBilinear(const basicAC_F0 & args) { - di= dynamic_cast(CastTo(args[0])); - B Kb= dynamic_cast(CastTo(args[1])); - b= new FoperatorKBEM(*Kb); - ffassert(di && Kb); - type=1; - }; - - void checkNbItemFEspaceInconnuAndTest(const int & nbitem_inconnu, const int & nbitem_test ){ - // check the size of the FEspace - if( (b->fi->v[0].first.first +1) != nbitem_inconnu ){ - cerr << " " << endl; - cerr << "\nThe size of unknown FEspace is " << nbitem_inconnu << endl; - cerr << "The nbitem of unknown Function in BEM (defined in varf) is " << b->fi->v[0].first.first +1 << endl; - cerr << "These two quantities must be the same." << endl; - ffassert(0); - } - if( (b->ft->v[0].first.first +1) != nbitem_test ){ - cerr << " " << endl; - cerr << "\nThe size of test FEspace is " << nbitem_test << endl; - cerr << "The nbitem of test Function in BEM (defined in varf) is " << b->ft->v[0].first.first +1 << endl; - cerr << "These two quantities must be the same." << endl; - ffassert(0); - } + void checkNbItemFEspaceInconnuAndTest(const int &nbitem_inconnu, const int &nbitem_test) { + // check the size of the FEspace + if ((b->fi->v[0].first.first + 1) != nbitem_inconnu) { + cerr << " " << endl; + cerr << "\nThe size of unknown FEspace is " << nbitem_inconnu << endl; + cerr << "The nbitem of unknown Function in BEM (defined in varf) is " << b->fi->v[0].first.first + 1 << endl; + cerr << "These two quantities must be the same." << endl; + ffassert(0); } + if ((b->ft->v[0].first.first + 1) != nbitem_test) { + cerr << " " << endl; + cerr << "\nThe size of test FEspace is " << nbitem_test << endl; + cerr << "The nbitem of test Function in BEM (defined in varf) is " << b->ft->v[0].first.first + 1 << endl; + cerr << "These two quantities must be the same." << endl; + ffassert(0); + } + } + static E_F0 *f(const basicAC_F0 &args) { return new BemKFormBilinear(args); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >( ), atype< B >( )); } + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } - static E_F0 * f(const basicAC_F0 & args) { return new BemKFormBilinear(args);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());} - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - - - BemKFormBilinear(A a,Expression bb) : di(a),b(new FoperatorKBEM(*dynamic_cast(bb))) - {ffassert(b);} - BemKFormBilinear operator-() const { return BemKFormBilinear(di,C_F0(TheOperators,"-",C_F0(b,atype())));} - - BemKFormBilinear(const BemKFormBilinear & fb) : di(fb.di),b(new FoperatorKBEM(*fb.b) ){ type=1;} + BemKFormBilinear(A a, Expression bb) : di(a), b(new FoperatorKBEM(*dynamic_cast< FoperatorKBEM * >(bb))) { ffassert(b); } + BemKFormBilinear operator-( ) const { return BemKFormBilinear(di, C_F0(TheOperators, "-", C_F0(b, atype< FoperatorKBEM >( )))); } - BemKFormBilinear(A a, const FoperatorKBEM &fb) : di(a),b(new FoperatorKBEM(fb)) { type=1;} + BemKFormBilinear(const BemKFormBilinear &fb) : di(fb.di), b(new FoperatorKBEM(*fb.b)) { type = 1; } + + BemKFormBilinear(A a, const FoperatorKBEM &fb) : di(a), b(new FoperatorKBEM(fb)) { type = 1; } }; +class TypeFormBEM : public ForEachType< const BemFormBilinear * > { + public: + TypeFormBEM( ) : ForEachType< const BemFormBilinear * >(0, 0) {} + void SetArgs(const ListOfId *lid) const { SetArgsFormLinear(lid, 2); } + + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { return Type_Expr(this, CastTo(c)); } -class TypeFormBEM: public ForEachType { -public: - TypeFormBEM() : ForEachType(0,0) {} - void SetArgs(const ListOfId *lid) const { - SetArgsFormLinear(lid,2); } - - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { return Type_Expr(this,CastTo(c));} - - - C_F0 Initialization(const Type_Expr & e) const - { - return C_F0(); } - Type_Expr construct(const Type_Expr & e) const - { - return e; } - + C_F0 Initialization(const Type_Expr &e) const { return C_F0( ); } + Type_Expr construct(const Type_Expr &e) const { return e; } }; // define the function BEM(k,u,v) -class FormalKBEMcode : public OneOperator{ -public: - - FormalKBEMcode( ): OneOperator(atype(),atype(), atype(), atype()) {} - FormalKBEMcode(int ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new FoperatorKBEM(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - +class FormalKBEMcode : public OneOperator { + public: + FormalKBEMcode( ) : OneOperator(atype< C_F0 >( ), atype< pBemKernel >( ), atype< finconnue * >( ), atype< ftest * >( )) {} + FormalKBEMcode(int) : OneOperator(atype< C_F0 >( ), atype< pBemKernel >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new FoperatorKBEM(args); + aType r = atype< const FoperatorKBEM * >( ); + return C_F0(e, r); + } + + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; // define the function BEM(k,[u1,u2,u3],[v1,v2,v3]) -class FormalKBEMcodeArray : public OneOperator{ -public: - - FormalKBEMcodeArray( ): OneOperator(atype(),atype(), atype(), atype()) {} - FormalKBEMcodeArray(int ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new FoperatorKBEM(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - -}; +class FormalKBEMcodeArray : public OneOperator { + public: + FormalKBEMcodeArray( ) : OneOperator(atype< C_F0 >( ), atype< pBemKernel >( ), atype< E_Array >( ), atype< E_Array >( )) {} + FormalKBEMcodeArray(int) : OneOperator(atype< C_F0 >( ), atype< pBemKernel >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new FoperatorKBEM(args); + aType r = atype< const FoperatorKBEM * >( ); + return C_F0(e, r); + } + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } +}; +// define the function POT(k,u,v) +class FoperatorPBEM : public E_F0mps { + public: + typedef const FoperatorPBEM *Result; + typedef finconnue *Fi; + typedef ftest *Ft; + typedef fpotential *Pot; + + Fi fi; + Ft ft; + Expression pot; + + // int nb_component_FEspace_inc; + // int nb_component_FEspace_test; + + FoperatorPBEM(const basicAC_F0 &args) : fi(0), ft(0), pot(0) { + aType t_a = atype< E_Array >( ); + ffassert(args.size( ) == 3); + + pot = CastTo< Pot >(args[0]); + // only POT(bemkernel,u0,v0); + // POT(bemkernel,[u0,..,un],[v0,..,vm]); + // are valid + if (args[1].left( ) == t_a && args[2].left( ) == t_a) { + // case POT(bemkernel,[u0,..,un],[v0,..,vm]) + // Here, we are in the compilation step + // so we can't check if the size of ea.size is correct + const E_Array &ea = *dynamic_cast< const E_Array * >(args[1].LeftValue( )); + ffassert(&ea); + ffassert(ea.size( ) == 3); // hack for "MA_SL" + fi = dynamic_cast< Fi >(CastTo< Fi >(ea[ea.size( ) - 1])); + + const E_Array &et = *dynamic_cast< const E_Array * >(args[2].LeftValue( )); + ffassert(&et); + ffassert(et.size( ) == 3); // hack for "MA_SL" + ft = dynamic_cast< Ft >(CastTo< Ft >(et[et.size( ) - 1])); + + // Remark: n = fi->v[0].first.first; + // Remark: m = ft->v[0].first.first; + } else if (args[1].left( ) != t_a && args[2].left( ) != t_a) { + // case POT(bemkernel,u0,v0)]) + fi = dynamic_cast< Fi >(CastTo< Fi >(args[1])); + ft = dynamic_cast< Ft >(CastTo< Ft >(args[2])); + } else { + CompileError("The POT keyword inside an integral must be : POT(bemkernel,u0,v0); or POT(bemkernel,[u0,..,un],[v0,..,vm]); "); + } + // nb_component_FEspace_inc = fi->v[0].first.first+1; + // nb_component_FEspace_test = ft->v[0].first.first+1; -// define the function POT(k,u,v) -class FoperatorPBEM : public E_F0mps { public: - typedef const FoperatorPBEM* Result; - typedef finconnue * Fi; - typedef ftest * Ft; - typedef fpotential * Pot; - - Fi fi; - Ft ft; - Expression pot; - - //int nb_component_FEspace_inc; - //int nb_component_FEspace_test; - - FoperatorPBEM(const basicAC_F0 & args) :fi(0),ft(0),pot(0) { - aType t_a = atype< E_Array >( ); - ffassert(args.size()==3); - - pot= CastTo(args[0]); - // only POT(bemkernel,u0,v0); - // POT(bemkernel,[u0,..,un],[v0,..,vm]); - // are valid - if( args[1].left( ) == t_a && args[2].left( ) == t_a ){ - // case POT(bemkernel,[u0,..,un],[v0,..,vm]) - // Here, we are in the compilation step - // so we can't check if the size of ea.size is correct - const E_Array &ea = *dynamic_cast< const E_Array * >(args[1].LeftValue( )); - ffassert(&ea); - ffassert(ea.size() == 3); // hack for "MA_SL" - fi = dynamic_cast(CastTo(ea[ea.size()-1])); - - const E_Array &et = *dynamic_cast< const E_Array * >(args[2].LeftValue( )); - ffassert(&et); - ffassert(et.size() == 3); // hack for "MA_SL" - ft = dynamic_cast(CastTo(et[et.size()-1])); - - // Remark: n = fi->v[0].first.first; - // Remark: m = ft->v[0].first.first; - } - else if( args[1].left( ) != t_a && args[2].left( ) != t_a ){ - // case POT(bemkernel,u0,v0)]) - fi= dynamic_cast(CastTo(args[1])); - ft= dynamic_cast(CastTo(args[2])); - } - else{ - CompileError("The POT keyword inside an integral must be : POT(bemkernel,u0,v0); or POT(bemkernel,[u0,..,un],[v0,..,vm]); "); - } + ffassert(pot && fi && ft); + } - // nb_component_FEspace_inc = fi->v[0].first.first+1; - // nb_component_FEspace_test = ft->v[0].first.first+1; - - ffassert(pot && fi && ft); - } - - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - FoperatorPBEM(const FoperatorPBEM & fk) : pot(fk.pot),fi(fk.fi),ft(fk.ft){} - + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + FoperatorPBEM(const FoperatorPBEM &fk) : pot(fk.pot), fi(fk.fi), ft(fk.ft) {} }; - // define a bilinear form for BEM -class BemPFormBilinear : public BemFormBilinear { public: - typedef const BemFormBilinear* Result; - typedef const CDomainOfIntegration * A; - typedef const FoperatorPBEM * B; - A di; - FoperatorPBEM * b; - BemPFormBilinear(const basicAC_F0 & args) { - di= dynamic_cast(CastTo(args[0])); - B Kb= dynamic_cast(CastTo(args[1])); - b= new FoperatorPBEM(*Kb); - ffassert(di && Kb); - type=2; - } +class BemPFormBilinear : public BemFormBilinear { + public: + typedef const BemFormBilinear *Result; + typedef const CDomainOfIntegration *A; + typedef const FoperatorPBEM *B; + A di; + FoperatorPBEM *b; + BemPFormBilinear(const basicAC_F0 &args) { + di = dynamic_cast< A >(CastTo< A >(args[0])); + B Kb = dynamic_cast< B >(CastTo< B >(args[1])); + b = new FoperatorPBEM(*Kb); + ffassert(di && Kb); + type = 2; + } - void checkNbItemFEspaceInconnuAndTest(const int & nbitem_inconnu, const int & nbitem_test ){ - // check the size of the FEspace - - if( (b->fi->v[0].first.first +1) != nbitem_inconnu ){ - cerr << "\nThe size of unknown FEspace is " << nbitem_inconnu << endl; - cerr << "The nbitem of unknown Function in POT(defined in varf) is " << b->fi->v[0].first.first +1 << endl; - cerr << "These two quantities must be the same." << endl; - ffassert(0); - } - if( (b->ft->v[0].first.first +1) != nbitem_test ){ - cerr << "\nThe size of test FEspace is " << nbitem_test << endl; - cerr << "The nbitem of test in POT(defined in varf) is " << b->ft->v[0].first.first +1 << endl; - cerr << "These two quantities must be the same." << endl; - ffassert(0); - } + void checkNbItemFEspaceInconnuAndTest(const int &nbitem_inconnu, const int &nbitem_test) { + // check the size of the FEspace + + if ((b->fi->v[0].first.first + 1) != nbitem_inconnu) { + cerr << "\nThe size of unknown FEspace is " << nbitem_inconnu << endl; + cerr << "The nbitem of unknown Function in POT(defined in varf) is " << b->fi->v[0].first.first + 1 << endl; + cerr << "These two quantities must be the same." << endl; + ffassert(0); + } + if ((b->ft->v[0].first.first + 1) != nbitem_test) { + cerr << "\nThe size of test FEspace is " << nbitem_test << endl; + cerr << "The nbitem of test in POT(defined in varf) is " << b->ft->v[0].first.first + 1 << endl; + cerr << "These two quantities must be the same." << endl; + ffassert(0); } - - static E_F0 * f(const basicAC_F0 & args) { return new BemPFormBilinear(args);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());}// all type - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - - - BemPFormBilinear(A a,Expression bb) : di(a),b(new FoperatorPBEM(*dynamic_cast(bb))/*->Optimize(currentblock) FH1004 */) - {ffassert(b);} - BemPFormBilinear operator-() const { return BemPFormBilinear(di,C_F0(TheOperators,"-",C_F0(b,atype())));} - - BemPFormBilinear(const BemPFormBilinear & fb) : di(fb.di),b(new FoperatorPBEM(*fb.b) ) {type=2;} - + } + + static E_F0 *f(const basicAC_F0 &args) { return new BemPFormBilinear(args); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >( ), atype< B >( )); } // all type + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + + BemPFormBilinear(A a, Expression bb) : di(a), b(new FoperatorPBEM(*dynamic_cast< FoperatorPBEM * >(bb)) /*->Optimize(currentblock) FH1004 */) { ffassert(b); } + BemPFormBilinear operator-( ) const { return BemPFormBilinear(di, C_F0(TheOperators, "-", C_F0(b, atype< FoperatorPBEM >( )))); } + + BemPFormBilinear(const BemPFormBilinear &fb) : di(fb.di), b(new FoperatorPBEM(*fb.b)) { type = 2; } }; // define the function POT(k,u1,v1) -class FormalPBEMcode : public OneOperator{ -public: - - FormalPBEMcode( ): OneOperator(atype(),atype(), atype(), atype()) {} - FormalPBEMcode(int ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new FoperatorPBEM(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - +class FormalPBEMcode : public OneOperator { + public: + FormalPBEMcode( ) : OneOperator(atype< C_F0 >( ), atype< pBemPotential >( ), atype< finconnue * >( ), atype< ftest * >( )) {} + FormalPBEMcode(int) : OneOperator(atype< C_F0 >( ), atype< pBemPotential >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new FoperatorPBEM(args); + aType r = atype< const FoperatorPBEM * >( ); + return C_F0(e, r); + } + + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; // define the function POT(k,[u1,u2,u3],[v1,v2,v3]) -class FormalPBEMcodeArray : public OneOperator{ -public: - - FormalPBEMcodeArray( ): OneOperator(atype(),atype(), atype(), atype()){} - FormalPBEMcodeArray(int ): OneOperator(atype(),atype()) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { - Expression e=new FoperatorPBEM(args); - aType r=atype(); - return C_F0(e,r) ;} - - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - +class FormalPBEMcodeArray : public OneOperator { + public: + FormalPBEMcodeArray( ) : OneOperator(atype< C_F0 >( ), atype< pBemPotential >( ), atype< E_Array >( ), atype< E_Array >( )) {} + FormalPBEMcodeArray(int) : OneOperator(atype< C_F0 >( ), atype< pBemPotential >( )) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { + Expression e = new FoperatorPBEM(args); + aType r = atype< const FoperatorPBEM * >( ); + return C_F0(e, r); + } + + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; +//// end type BEM kernel / potential +int typeVFBEM(const list< C_F0 > &largs, Stack stack) { + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + int VVFBEM = -1, ik = -1; + ; + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); -//// end type BEM kernel / potential -int typeVFBEM(const list & largs, Stack stack) -{ - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - - int VVFBEM =-1, ik=-1;; - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - - if (r==atype()) { - - BemFormBilinear * bb= GetAny((*e)(0)); - VVFBEM = bb->type; - } - ffassert(ik); + if (r == atype< const BemFormBilinear * >( )) { + + BemFormBilinear *bb = GetAny< BemFormBilinear * >((*e)(0)); + VVFBEM = bb->type; } - return VVFBEM; + ffassert(ik); + } + return VVFBEM; } -void checkNbItemFEspacesInconnuAndTest(const list & largs,const int & nbitem_inconnu, const int & nbitem_test){ - - // Loop to check the nbitem of inconnu and test in BemFormBilinear - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); - ffassert(bbtmp); - int VVFBEM = bbtmp->type; - - if(VVFBEM ==1){ - BemKFormBilinear * bk = dynamic_cast< BemKFormBilinear *>(e); - ffassert(bk); - bk->checkNbItemFEspaceInconnuAndTest( nbitem_inconnu, nbitem_test ); - - }else if(VVFBEM ==2){ - BemPFormBilinear *bp = dynamic_cast< BemPFormBilinear *>(e); - ffassert(bp); - bp->checkNbItemFEspaceInconnuAndTest( nbitem_inconnu, nbitem_test); - } - } +void checkNbItemFEspacesInconnuAndTest(const list< C_F0 > &largs, const int &nbitem_inconnu, const int &nbitem_test) { + + // Loop to check the nbitem of inconnu and test in BemFormBilinear + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); + ffassert(bbtmp); + int VVFBEM = bbtmp->type; + + if (VVFBEM == 1) { + BemKFormBilinear *bk = dynamic_cast< BemKFormBilinear * >(e); + ffassert(bk); + bk->checkNbItemFEspaceInconnuAndTest(nbitem_inconnu, nbitem_test); + + } else if (VVFBEM == 2) { + BemPFormBilinear *bp = dynamic_cast< BemPFormBilinear * >(e); + ffassert(bp); + bp->checkNbItemFEspaceInconnuAndTest(nbitem_inconnu, nbitem_test); + } } + } } -bool iscombinedKernel(BemKernel *K ) { - bool iscombined=false; - for (int i=0;i<2;i++) - iscombined= K->coeffcombi[i]!=0. ? 1 : 0; - return iscombined; +bool iscombinedKernel(BemKernel *K) { + bool iscombined = false; + for (int i = 0; i < 2; i++) iscombined = K->coeffcombi[i] != 0. ? 1 : 0; + return iscombined; } -bemtool::BIOpKernelEnum whatTypeEnum(BemKernel *K,int i) { - bemtool::BIOpKernelEnum pKernel; - switch(K->typeKernel[i]) { - case 1: pKernel=bemtool::SL_OP ; break; - case 2: pKernel=bemtool::DL_OP ; break; - case 3: pKernel=bemtool::HS_OP ; break; - case 4: pKernel=bemtool::TDL_OP ; break; - case 6: pKernel=bemtool::SL_OP ; break; // MA_SL - } - const bemtool::BIOpKernelEnum cpKernel=pKernel; - return cpKernel; +bemtool::BIOpKernelEnum whatTypeEnum(BemKernel *K, int i) { + bemtool::BIOpKernelEnum pKernel; + switch (K->typeKernel[i]) { + case 1: + pKernel = bemtool::SL_OP; + break; + case 2: + pKernel = bemtool::DL_OP; + break; + case 3: + pKernel = bemtool::HS_OP; + break; + case 4: + pKernel = bemtool::TDL_OP; + break; + case 6: + pKernel = bemtool::SL_OP; + break; // MA_SL + } + const bemtool::BIOpKernelEnum cpKernel = pKernel; + return cpKernel; } -bool checkVectorBemKernel(Stack stack, const list & largs){ - // return true if the bem kernel - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - - if ( r==atype() ){ - BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; - ffassert(0); - } - else{ - BemKernel* K=GetAny((*b->kbem)(stack)); - // verification vector BEM - if( b->fi->v[0].first.first > 0 || b->ft->v[0].first.first > 0 ){ - if( b->fi->v[0].first.first+1 == 3 && b->ft->v[0].first.first+1 == 3 ){ - ffassert( K->typeKernel[0] == 6 ); // case MA_SL - // vector BEM Maxwell in 3d - ffassert( K->typeKernel[1] == 0); // not combined kernel available - } - else{ - cerr << "Error in the definition of the varf for vector BEM equation" << endl; - ffassert(0); - } - } - // verification reciproque de vector BEM - if( K->typeKernel[0] == 6 ){ - // :: case MA_SL :: - ffassert( b->fi->v[0].first.first+1 == 3 && b->ft->v[0].first.first+1 == 3 ); - ffassert( K->typeKernel[1] == 0); // not combined kernel available - return true; - } - } +bool checkVectorBemKernel(Stack stack, const list< C_F0 > &largs) { + // return true if the bem kernel + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + + if (r == atype< const BemFormBilinear * >( )) { + BemKFormBilinear *bb = new BemKFormBilinear(*dynamic_cast< const BemKFormBilinear * >(e)); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + ffassert(0); + } else { + BemKernel *K = GetAny< BemKernel * >((*b->kbem)(stack)); + // verification vector BEM + if (b->fi->v[0].first.first > 0 || b->ft->v[0].first.first > 0) { + if (b->fi->v[0].first.first + 1 == 3 && b->ft->v[0].first.first + 1 == 3) { + ffassert(K->typeKernel[0] == 6); // case MA_SL + // vector BEM Maxwell in 3d + ffassert(K->typeKernel[1] == 0); // not combined kernel available + } else { + cerr << "Error in the definition of the varf for vector BEM equation" << endl; + ffassert(0); + } + } + // verification reciproque de vector BEM + if (K->typeKernel[0] == 6) { + // :: case MA_SL :: + ffassert(b->fi->v[0].first.first + 1 == 3 && b->ft->v[0].first.first + 1 == 3); + ffassert(K->typeKernel[1] == 0); // not combined kernel available + return true; } + } } - return false; + } + return false; } -pair getBemKernel(Stack stack, const list & largs) { - bool IsVectorBem =checkVectorBemKernel(stack, largs); - // need to do that before to allow to add mass matrix in the scalar case - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - - BemKernel* K; - Complex alpha=0.; - - bool haveBemBilinearOperator=false, haveBilinearOperator=false; - - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - - if (r==atype() && !haveBemBilinearOperator) { - BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; } - else - K=GetAny((*b->kbem)(stack)); - haveBemBilinearOperator=true; - } - else if (r==atype() && !haveBilinearOperator && !IsVectorBem) { - // These lines are not valid for vectorial BEM - - const FormBilinear * bb=dynamic_cast(e); - const CDomainOfIntegration & di= *bb->di; - // check the integration (keyword) - ffassert( (di.kind == CDomainOfIntegration::int1d && di.dHat==1) || (di.kind == CDomainOfIntegration::int2d && di.dHat==2) ); //check only necessary in surface case - - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); - if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; } - - - - BilinearOperator::const_iterator l=Op->v.begin(); - - BilinearOperator::K ll(*l); // LinearComb,C_F0> BilinearOperator; - pair finc(ll.first.first),ftest(ll.first.second); - - // TODO use FieldofForm to convert largs to complex instead - bool isComplex = ll.second.right() == atype(); - if (isComplex) - alpha = GetAny(ll.second.eval(stack)); - else - alpha = GetAny(ll.second.eval(stack)); - - if(mpirank == 0 && verbosity>5) cout << " test coeff mass matrix " << alpha << endl; - - if(mpirank == 0 && verbosity>5) { - cout << "FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; - cout << "FormBilinear: operator order finc=" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 - } - ffassert(finc.first==0 && ftest.first==0); // only valid for scalar BEM - ffassert(finc.second==0 && ftest.second==0); - haveBilinearOperator=true; // or ffassert(Op->v.size()==1); // check size 1 - } - else if (r==atype()){ - if(verbosity>3) cout << "getBemKernel: FormLinear in variational form" << endl; - } - else - ffassert(0); - } - return std::make_pair(K, alpha); //K; +pair< BemKernel *, Complex > getBemKernel(Stack stack, const list< C_F0 > &largs) { + bool IsVectorBem = checkVectorBemKernel(stack, largs); + // need to do that before to allow to add mass matrix in the scalar case + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + + BemKernel *K; + Complex alpha = 0.; + + bool haveBemBilinearOperator = false, haveBilinearOperator = false; + + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + + if (r == atype< const BemFormBilinear * >( ) && !haveBemBilinearOperator) { + BemKFormBilinear *bb = new BemKFormBilinear(*dynamic_cast< const BemKFormBilinear * >(e)); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } else + K = GetAny< BemKernel * >((*b->kbem)(stack)); + haveBemBilinearOperator = true; + } else if (r == atype< const FormBilinear * >( ) && !haveBilinearOperator && !IsVectorBem) { + // These lines are not valid for vectorial BEM + + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const CDomainOfIntegration &di = *bb->di; + // check the integration (keyword) + ffassert((di.kind == CDomainOfIntegration::int1d && di.dHat == 1) || (di.kind == CDomainOfIntegration::int2d && di.dHat == 2)); // check only necessary in surface case + + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } + + BilinearOperator::const_iterator l = Op->v.begin( ); + + BilinearOperator::K ll(*l); // LinearComb,C_F0> BilinearOperator; + pair< int, int > finc(ll.first.first), ftest(ll.first.second); + + // TODO use FieldofForm to convert largs to complex instead + bool isComplex = ll.second.right( ) == atype< Complex >( ); + if (isComplex) + alpha = GetAny< Complex >(ll.second.eval(stack)); + else + alpha = GetAny< double >(ll.second.eval(stack)); + + if (mpirank == 0 && verbosity > 5) cout << " test coeff mass matrix " << alpha << endl; + + if (mpirank == 0 && verbosity > 5) { + cout << "FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; + cout << "FormBilinear: operator order finc=" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 + } + ffassert(finc.first == 0 && ftest.first == 0); // only valid for scalar BEM + ffassert(finc.second == 0 && ftest.second == 0); + haveBilinearOperator = true; // or ffassert(Op->v.size()==1); // check size 1 + } else if (r == atype< const FormLinear * >( )) { + if (verbosity > 3) cout << "getBemKernel: FormLinear in variational form" << endl; + } else + ffassert(0); + } + return std::make_pair(K, alpha); // K; } -BemPotential* getBemPotential(Stack stack, const list & largs) { - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - - BemPotential* P; - - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - ffassert (r==atype()); - - BemPFormBilinear * bb=new BemPFormBilinear(*dynamic_cast(e)); - FoperatorPBEM * b=const_cast< FoperatorPBEM *>(bb->b); - if (b == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; } - else{ - P=GetAny((*b->pot)(stack)); - if( b->fi->v[0].first.first > 0 || b->ft->v[0].first.first > 0 ){ - if( b->fi->v[0].first.first+1 == 3 && b->ft->v[0].first.first+1 == 3 ){ - ffassert( P->typePotential == 4 ); // case MA_SL - // vector BEM Maxwell in 3d - } - else{ - cerr << "Error in the definition of the varf with BEM kernel for Potential" << endl; - ffassert(0); - } - } +BemPotential *getBemPotential(Stack stack, const list< C_F0 > &largs) { + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + + BemPotential *P; + + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + ffassert(r == atype< const BemFormBilinear * >( )); + + BemPFormBilinear *bb = new BemPFormBilinear(*dynamic_cast< const BemPFormBilinear * >(e)); + FoperatorPBEM *b = const_cast< FoperatorPBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } else { + P = GetAny< BemPotential * >((*b->pot)(stack)); + if (b->fi->v[0].first.first > 0 || b->ft->v[0].first.first > 0) { + if (b->fi->v[0].first.first + 1 == 3 && b->ft->v[0].first.first + 1 == 3) { + ffassert(P->typePotential == 4); // case MA_SL + // vector BEM Maxwell in 3d + } else { + cerr << "Error in the definition of the varf with BEM kernel for Potential" << endl; + ffassert(0); } + } } - return P; + } + return P; } bemtool::PotKernelEnum whatTypeEnum(BemPotential *P) { - bemtool::PotKernelEnum pPotential; - switch(P->typePotential) { - case 1: pPotential=bemtool::SL_POT ; break; - case 2: pPotential=bemtool::DL_POT ; break; - case 3: pPotential=bemtool::CST_POT ; break; - //case 4: pPotential=TDL_POT ; break; - case 4: pPotential=bemtool::SL_POT ; break; // MA_SL - } - const bemtool::PotKernelEnum cpPotential=pPotential; - return cpPotential; + bemtool::PotKernelEnum pPotential; + switch (P->typePotential) { + case 1: + pPotential = bemtool::SL_POT; + break; + case 2: + pPotential = bemtool::DL_POT; + break; + case 3: + pPotential = bemtool::CST_POT; + break; + // case 4: pPotential=TDL_POT ; break; + case 4: + pPotential = bemtool::SL_POT; + break; // MA_SL + } + const bemtool::PotKernelEnum cpPotential = pPotential; + return cpPotential; } +template< class K, typename P, class MMesh > +void ff_BIO_Generator(htool::VirtualGenerator< K > *&generator, BemKernel *typeKernel, bemtool::Dof< P > &dof, Complex alpha) { + + bemtool::BIOpKernelEnum ker1 = whatTypeEnum(typeKernel, 0), ker2 = whatTypeEnum(typeKernel, 1); + ; + double kappaRe1 = typeKernel->wavenum[0].real( ), kappaRe2 = typeKernel->wavenum[1].real( ); + double kappaIm1 = typeKernel->wavenum[0].imag( ), kappaIm2 = typeKernel->wavenum[1].imag( ); + + bool iscombined = iscombinedKernel(typeKernel); + if (iscombined) ffassert((kappaRe1 == kappaRe2) && (kappaIm1 == kappaIm2)); + std::complex< double > coeff1 = typeKernel->coeffcombi[0], coeff2 = typeKernel->coeffcombi[1]; + + if (mpirank == 0 && verbosity > 3) cout << "ff_BIO::LaplaceHelmoltz:: alpha=" << alpha << ", coeff1=" << coeff1 << endl; + + // BIO_Generator -> single kernel + // Equ Helmholtz kappa1.real() > 0 et kappa1.imag() == 0 + if ((kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0.) { + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator< bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << " call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel 5) cout << " no tested BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaRe1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel 5) cout << " no tested BIOpKernel 0 + else if ((!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0.) { + //(!kappa1 && !iscombined && !kappa2 && alpha == 0. ){ + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator< bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >(dof, kappaIm1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaIm1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaIm1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel, P >(dof, kappaIm1, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIOpKernel 5) cout << " no tested BIOpKernel -void ff_BIO_Generator(htool::VirtualGenerator*& generator, BemKernel *typeKernel, bemtool::Dof

& dof, Complex alpha) { - - bemtool::BIOpKernelEnum ker1 = whatTypeEnum(typeKernel,0), ker2 = whatTypeEnum(typeKernel,1);; - double kappaRe1 = typeKernel->wavenum[0].real(), kappaRe2 = typeKernel->wavenum[1].real(); - double kappaIm1 = typeKernel->wavenum[0].imag(), kappaIm2 = typeKernel->wavenum[1].imag(); - - bool iscombined = iscombinedKernel(typeKernel); - if(iscombined) ffassert( (kappaRe1==kappaRe2) && (kappaIm1==kappaIm2) ); - std::complex coeff1=typeKernel->coeffcombi[0], coeff2=typeKernel->coeffcombi[1]; - - if(mpirank == 0 && verbosity>3) cout << "ff_BIO::LaplaceHelmoltz:: alpha=" << alpha << ", coeff1=" << coeff1 << endl; - - // BIO_Generator -> single kernel - // Equ Helmholtz kappa1.real() > 0 et kappa1.imag() == 0 - if ( (kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0. ) { - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << " call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel5) cout << " no tested BIOpKernel 0 et kappa1.imag() == 0 + else if ((kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha != 0.) { + // if (kappa1 && !iscombined && !kappa2 && alpha != 0.) { + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator_w_mass< bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >(dof, kappaRe1, alpha, coeff1); + if (mpirank == 0 && verbosity > 5) cout << " call bemtool func BIO_Generator_w_mass,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaRe1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel5) cout << " no tested BIOpKernel, P >(dof, kappaRe1, alpha, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIO_Generator_w_mass 0 - else if ( (!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0. ) { - //(!kappa1 && !iscombined && !kappa2 && alpha == 0. ){ - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator,P>(dof,kappaIm1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaIm1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaIm1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel,P>(dof,kappaIm1,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIOpKernel5) cout << " no tested BIOpKernel 0 + else if ((!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha != 0.) { // if (!kappa1 && !iscombined && !kappa2 && alpha != 0.){ + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator_w_mass< bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >(dof, kappaIm1, alpha, coeff1); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func BIO_Generator_w_mass 0 et kappa1.imag() == 0 - else if ( (kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha != 0. ) { - //if (kappa1 && !iscombined && !kappa2 && alpha != 0.) { - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator_w_mass,P>(dof,kappaRe1,alpha,coeff1); - if(mpirank == 0 && verbosity>5) cout << " call bemtool func BIO_Generator_w_mass, bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator,P>(dof,kappaRe1,alpha,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIO_Generator_w_mass, bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< HE, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator 5) cout << " no tested BIOpKernel 0 - else if ( (!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha != 0. ) { //if (!kappa1 && !iscombined && !kappa2 && alpha != 0.){ - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator_w_mass,P>(dof,kappaIm1,alpha,coeff1); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func BIO_Generator_w_mass,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator5) cout << " no tested BIOpKernel, bemtool::BIOpKernel< LA, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no testedCombined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no testedCombined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no testedCombined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no testedCombined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaRe1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no testedCombined_BIO_Generator5) cout << " no testedCombined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no testedCombined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no testedCombined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< LA, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaRe1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no testedCombined_BIO_Generator 5) cout << " no testedCombined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator,bemtool::BIOpKernel,P>(dof,kappaIm1,coeff1,coeff2,alpha); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func Combined_BIO_Generator5) cout << " no tested Combined_BIO_Generator5) cout << " no tested BIOpKernel, bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::SL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::DL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::HS_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator, bemtool::BIOpKernel< YU, bemtool::TDL_OP, MMesh::RdHat::d + 1, P, P >, P >( + dof, kappaIm1, coeff1, coeff2, alpha); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func Combined_BIO_Generator 5) cout << " no tested Combined_BIO_Generator 5) cout << " no tested BIOpKernel -void ff_BIO_Generator_Maxwell(htool::VirtualGenerator*& generator, BemKernel *typeKernel, bemtool::Dof& dof, Complex alpha) { - cout << " mettre un msg d erreur pour dire que cette combi n existe pas" << endl; - return; + else { + if (mpirank == 0) cout << "Laplace Helmoltz:: kernel definition error" << endl; + ffassert(0); + } } -template -void ff_BIO_Generator_Maxwell(htool::VirtualGenerator*& generator, BemKernel *typeKernel, bemtool::Dof& dof, Complex alpha) { - - bemtool::BIOpKernelEnum ker1 = whatTypeEnum(typeKernel,0), ker2 = whatTypeEnum(typeKernel,1);; - double kappaRe1 = typeKernel->wavenum[0].real(), kappaRe2 = typeKernel->wavenum[1].real(); - double kappaIm1 = typeKernel->wavenum[0].imag(), kappaIm2 = typeKernel->wavenum[1].imag(); - - bool iscombined = iscombinedKernel(typeKernel); - if(iscombined) ffassert( (kappaRe1==kappaRe2) && (kappaIm1==kappaIm2) ); - std::complex coeff1=typeKernel->coeffcombi[0], coeff2=typeKernel->coeffcombi[1]; - - if(mpirank == 0 && verbosity >3) cout << "ff_BIO::Maxwell:: k=" << kappaRe1 << " + i " << kappaRe2 << endl; +template< class K, class mesh > +void ff_BIO_Generator_Maxwell(htool::VirtualGenerator< K > *&generator, BemKernel *typeKernel, bemtool::Dof< bemtool::RT0_2D > &dof, Complex alpha) { + cout << " mettre un msg d erreur pour dire que cette combi n existe pas" << endl; + return; +} - // BIO_Generator -> single kernel - // Equ Helmholtz kappa1.real() > 0 et kappa1.imag() == 0 - if ( (kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0. ) { - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator,bemtool::RT0_2D>(dof,kappaRe1); - if(mpirank == 0 && verbosity>5) cout << " call bemtool func BIOpKernel +void ff_BIO_Generator_Maxwell(htool::VirtualGenerator< K > *&generator, BemKernel *typeKernel, bemtool::Dof< bemtool::RT0_2D > &dof, Complex alpha) { + + bemtool::BIOpKernelEnum ker1 = whatTypeEnum(typeKernel, 0), ker2 = whatTypeEnum(typeKernel, 1); + ; + double kappaRe1 = typeKernel->wavenum[0].real( ), kappaRe2 = typeKernel->wavenum[1].real( ); + double kappaIm1 = typeKernel->wavenum[0].imag( ), kappaIm2 = typeKernel->wavenum[1].imag( ); + + bool iscombined = iscombinedKernel(typeKernel); + if (iscombined) ffassert((kappaRe1 == kappaRe2) && (kappaIm1 == kappaIm2)); + std::complex< double > coeff1 = typeKernel->coeffcombi[0], coeff2 = typeKernel->coeffcombi[1]; + + if (mpirank == 0 && verbosity > 3) cout << "ff_BIO::Maxwell:: k=" << kappaRe1 << " + i " << kappaRe2 << endl; + + // BIO_Generator -> single kernel + // Equ Helmholtz kappa1.real() > 0 et kappa1.imag() == 0 + if ((kappaRe1 && !kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0.) { + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator< bemtool::BIOpKernel< MA, bemtool::SL_OP, 3, bemtool::RT0_2D, bemtool::RT0_2D >, bemtool::RT0_2D >(dof, kappaRe1); + if (mpirank == 0 && verbosity > 5) cout << " call bemtool func BIOpKernel 0 - else if ( (!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0. ) { - switch (ker1) { - case bemtool::SL_OP : generator=new bemtool::BIO_Generator,bemtool::RT0_2D>(dof,kappaIm1); - if(mpirank == 0 && verbosity>5) cout << " call bemtool func BIOpKernel 0 + else if ((!kappaRe1 && kappaIm1) && !iscombined && (!kappaRe2 && !kappaIm2) && alpha == 0.) { + switch (ker1) { + case bemtool::SL_OP: + generator = new bemtool::BIO_Generator< bemtool::BIOpKernel< MA_YU, bemtool::SL_OP, 3, bemtool::RT0_2D, bemtool::RT0_2D >, bemtool::RT0_2D >(dof, kappaIm1); + if (mpirank == 0 && verbosity > 5) cout << " call bemtool func BIOpKernel -void ff_POT_Generator(htool::VirtualGenerator*& generator,BemPotential *typePot, bemtool::Dof

&dof, MeshBemtool &mesh, bemtool::Geometry &node_output) { - - bemtool::PotKernelEnum pot = whatTypeEnum(typePot); - double kappaRe = typePot->wavenum.real(),kappaIm = typePot->wavenum.imag(); - - switch (pot) { - case bemtool::SL_POT : - if (kappaRe && !kappaIm) { - generator = new bemtool::POT_Generator,P>(dof,node_output,kappaRe); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator,P>(dof,node_output,kappaIm); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator,P>(dof,node_output,kappaRe); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator,P>(dof,node_output,kappaRe); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator,P>(dof,node_output,kappaIm); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator,P>(dof,node_output,kappaRe); - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator5) cout << " no POT_Generator5) cout << " no POT_Generator5) cout << " no POT_Generator +void ff_POT_Generator(htool::VirtualGenerator< R > *&generator, BemPotential *typePot, bemtool::Dof< P > &dof, MeshBemtool &mesh, bemtool::Geometry &node_output) { + + bemtool::PotKernelEnum pot = whatTypeEnum(typePot); + double kappaRe = typePot->wavenum.real( ), kappaIm = typePot->wavenum.imag( ); + + switch (pot) { + case bemtool::SL_POT: + if (kappaRe && !kappaIm) { + generator = new bemtool::POT_Generator< bemtool::PotKernel< HE, bemtool::SL_POT, MMesh::RdHat::d + 1, P >, P >(dof, node_output, kappaRe); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator, P >(dof, node_output, kappaIm); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator, P >(dof, node_output, kappaRe); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator, P >(dof, node_output, kappaRe); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator, P >(dof, node_output, kappaIm); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator, P >(dof, node_output, kappaRe); + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator 5) cout << " no POT_Generator 5) cout << " no POT_Generator 5) cout << " no POT_Generator -void ff_POT_Generator_Maxwell(htool::VirtualGenerator*& generator,BemPotential *typePot, bemtool::Dof

&dof, MeshBemtool &mesh, bemtool::Geometry &node_output ){ - cout << " mettre un msg d erreur pour dire que cette combi n existe pas" << endl; - return; +template< class R, typename P, typename MeshBemtool > +void ff_POT_Generator_Maxwell(htool::VirtualGenerator< R > *&generator, BemPotential *typePot, bemtool::Dof< P > &dof, MeshBemtool &mesh, bemtool::Geometry &node_output) { + cout << " mettre un msg d erreur pour dire que cette combi n existe pas" << endl; + return; } -template -void ff_POT_Generator_Maxwell(htool::VirtualGenerator*& generator,BemPotential *typePot, bemtool::Dof

&dof, bemtool::Mesh2D &mesh, bemtool::Geometry &node_output ) { - - bemtool::PotKernelEnum pot = whatTypeEnum(typePot); - double kappaRe = typePot->wavenum.real(),kappaIm = typePot->wavenum.imag(); - if(mpirank == 0 && verbosity > 5) cout << "typePot->wavenum=" << typePot->wavenum << endl; - - switch (pot) { - case bemtool::SL_POT : - if (kappaRe && !kappaIm) { - - generator = new bemtool::POT_Generator,bemtool::RT0_2D>(dof,node_output,kappaRe); - - if(mpirank == 0 && verbosity>5) cout << "call bemtool func POT_Generator +void ff_POT_Generator_Maxwell(htool::VirtualGenerator< R > *&generator, BemPotential *typePot, bemtool::Dof< P > &dof, bemtool::Mesh2D &mesh, bemtool::Geometry &node_output) { + + bemtool::PotKernelEnum pot = whatTypeEnum(typePot); + double kappaRe = typePot->wavenum.real( ), kappaIm = typePot->wavenum.imag( ); + if (mpirank == 0 && verbosity > 5) cout << "typePot->wavenum=" << typePot->wavenum << endl; + + switch (pot) { + case bemtool::SL_POT: + if (kappaRe && !kappaIm) { + + generator = new bemtool::POT_Generator< bemtool::PotKernel< MA, bemtool::SL_POT, 3, bemtool::RT0_2D >, bemtool::RT0_2D >(dof, node_output, kappaRe); + + if (mpirank == 0 && verbosity > 5) cout << "call bemtool func POT_Generator -#define MKL_Complex16 std::complex +#define MKL_Complex8 std::complex< float > +#define MKL_Complex16 std::complex< double > #include #endif @@ -83,514 +83,486 @@ #include "common.hpp" -template -using upscaled_type = typename std::conditional::is_complex, double, std::complex>::type; - -template K* newCopy(bool mfree,K *p,int n) -{ if( !mfree) return p; - K *q= new K[n]; - copy(p,p+n,q); - return q; -} -template using MatriceMorse=HashMatrix; - -template -struct ff_HPDDM_MatrixCSR : public HPDDM::MatrixCSR -{ - ff_HPDDM_MatrixCSR(MatriceMorse>* mA) : - HPDDM::MatrixCSR(mA->n, mA->m, mA->nnz, nullptr, mA->p, mA->j, mA->half > 0) { - mA->CSR(); - HPDDM::MatrixCSR::HPDDM_ia=mA->p; - K* a = reinterpret_cast(mA->aij); - HPDDM::MatrixCSR::HPDDM_a=a; - if(!std::is_same, K>::value) { - for(int i = 0; i < mA->nnz; ++i) - a[i] = mA->aij[i]; - } +template< class T > +using upscaled_type = typename std::conditional< !HPDDM::Wrapper< T >::is_complex, double, std::complex< double > >::type; + +template< class K > +K* newCopy(bool mfree, K* p, int n) { + if (!mfree) return p; + K* q = new K[n]; + copy(p, p + n, q); + return q; +} +template< class K > +using MatriceMorse = HashMatrix< int, K >; + +template< class K > +struct ff_HPDDM_MatrixCSR : public HPDDM::MatrixCSR< K > { + ff_HPDDM_MatrixCSR(MatriceMorse< upscaled_type< K > >* mA) : HPDDM::MatrixCSR< K >(mA->n, mA->m, mA->nnz, nullptr, mA->p, mA->j, mA->half > 0) { + mA->CSR( ); + HPDDM::MatrixCSR< K >::HPDDM_ia = mA->p; + K* a = reinterpret_cast< K* >(mA->aij); + HPDDM::MatrixCSR< K >::HPDDM_a = a; + if (!std::is_same< upscaled_type< K >, K >::value) { + for (int i = 0; i < mA->nnz; ++i) a[i] = mA->aij[i]; } + } }; -template -HPDDM::MatrixCSR * new_HPDDM_MatrixCSR(MatriceMorse>* mA, bool mfree = false, K* s = nullptr, int* is = nullptr, int* js = nullptr) { - if(mA) { - int nnz = mA->nnz, n = mA->n; - mA->CSR(); - K* a; - if(!s) a = reinterpret_cast(newCopy(mfree, mA->aij, nnz)); - else a = reinterpret_cast(s); - if(!std::is_same, K>::value) { - for(int i = 0; i < nnz; ++i) - a[i] = mA->aij[i]; - } - if(!is) is = newCopy(mfree, mA->p, n+1); - if(!js) js = newCopy(mfree, mA->j, nnz); - - return new HPDDM::MatrixCSR(mA->n, mA->m, mA->nnz, a, is, js, mA->half > 0, false); - } +template< class K > +HPDDM::MatrixCSR< K >* new_HPDDM_MatrixCSR(MatriceMorse< upscaled_type< K > >* mA, bool mfree = false, K* s = nullptr, int* is = nullptr, int* js = nullptr) { + if (mA) { + int nnz = mA->nnz, n = mA->n; + mA->CSR( ); + K* a; + if (!s) + a = reinterpret_cast< K* >(newCopy(mfree, mA->aij, nnz)); else - return nullptr; -} -template -HPDDM::MatrixCSR * new_HPDDM_MatrixCSRvoid(MatriceMorse* mA,bool mfree=false,int *is=0,int *js=0) -{ if(mA) -{ - mA->CSR(); - if(!js) js=mA->j; - if(!is) is=mA->p; - return new HPDDM::MatrixCSR(mA->n, mA->m, mA->nnz, is, js , mA->half > 0,mfree); -} -else + a = reinterpret_cast< K* >(s); + if (!std::is_same< upscaled_type< K >, K >::value) { + for (int i = 0; i < nnz; ++i) a[i] = mA->aij[i]; + } + if (!is) is = newCopy(mfree, mA->p, n + 1); + if (!js) js = newCopy(mfree, mA->j, nnz); + + return new HPDDM::MatrixCSR< K >(mA->n, mA->m, mA->nnz, a, is, js, mA->half > 0, false); + } else + return nullptr; +} +template< class K > +HPDDM::MatrixCSR< void >* new_HPDDM_MatrixCSRvoid(MatriceMorse< K >* mA, bool mfree = false, int* is = 0, int* js = 0) { + if (mA) { + mA->CSR( ); + if (!js) js = mA->j; + if (!is) is = mA->p; + return new HPDDM::MatrixCSR< void >(mA->n, mA->m, mA->nnz, is, js, mA->half > 0, mfree); + } else return 0; } -template -void set_ff_matrix(MatriceMorse>* mA,const HPDDM::MatrixCSR &dA) -{ - //void HashMatrix::set(I nn,I mm,int hhalf,size_t nnnz, I *ii, I*jj, R *aa,,int f77,int tcsr) - if(verbosity>99) cout << " set_ff_matrix " < not del in HashMatrix - mA->j=0; - mA->p=0; - mA->aij=0; - - mA->set(dA.HPDDM_n,dA.HPDDM_m,dA.HPDDM_sym,dA.HPDDM_nnz,dA.HPDDM_ia,dA.HPDDM_ja,reinterpret_cast*>(dA.HPDDM_a),0,1); +template< class K > +void set_ff_matrix(MatriceMorse< upscaled_type< K > >* mA, const HPDDM::MatrixCSR< K >& dA) { + // void HashMatrix::set(I nn,I mm,int hhalf,size_t nnnz, I *ii, I*jj, R *aa,,int f77,int tcsr) + if (verbosity > 99) cout << " set_ff_matrix " << endl; + // Warning this pointeur a change or not in hpddm => not del in HashMatrix + mA->j = 0; + mA->p = 0; + mA->aij = 0; + + mA->set(dA.HPDDM_n, dA.HPDDM_m, dA.HPDDM_sym, dA.HPDDM_nnz, dA.HPDDM_ia, dA.HPDDM_ja, reinterpret_cast< upscaled_type< K >* >(dA.HPDDM_a), 0, 1); } -template -inline bool exist_type() { - map::iterator ir = map_type.find(typeid(T).name()); - return ir != map_type.end(); +template< typename T > +inline bool exist_type( ) { + map< const string, basicForEachType* >::iterator ir = map_type.find(typeid(T).name( )); + return ir != map_type.end( ); } -template +template< class T > class STL { - T* const _it; - const int _size; - public: - STL(const KN& v) : _it(v), _size(v.size()) { }; - int size() const { - return _size; - } - T* begin() const { - return _it; - } - T* end() const { - return _it + _size; - } - bool empty() const { return _size <= 0; } - T& operator[](std::size_t idx) { return _it[idx]; } - const T& operator[](std::size_t idx) const { return _it[idx]; } - T& back() { return _it[_size - 1]; } - const T& back() const { return _it[_size - 1]; } + T* const _it; + const int _size; + + public: + STL(const KN< T >& v) : _it(v), _size(v.size( )) {}; + int size( ) const { return _size; } + T* begin( ) const { return _it; } + T* end( ) const { return _it + _size; } + bool empty( ) const { return _size <= 0; } + T& operator[](std::size_t idx) { return _it[idx]; } + const T& operator[](std::size_t idx) const { return _it[idx]; } + T& back( ) { return _it[_size - 1]; } + const T& back( ) const { return _it[_size - 1]; } }; -template +template< class K > class Pair { - public: - Pair() : p() { }; - std::pair* p; - void init() { } - void destroy() { - delete p; - p = nullptr; - } + public: + Pair( ) : p( ) {}; + std::pair< MPI_Request, const K* >* p; + void init( ) {} + void destroy( ) { + delete p; + p = nullptr; + } }; -template inline AnyType DeleteDTOR(Stack, const AnyType& x) { - A* a = PGetAny(x); - a->dtor(); - a = NULL; - return Nothing; +template< class A > +inline AnyType DeleteDTOR(Stack, const AnyType& x) { + A* a = PGetAny< A >(x); + a->dtor( ); + a = NULL; + return Nothing; }; -extern KN* pkarg; +extern KN< String >* pkarg; -template::value == 1>::type* = nullptr> +template< class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value == 1 >::type* = nullptr > void exchange(Type* const& pA, K* pin, unsigned short mu, bool allocate) { - if(allocate) - pA->template exchange(pin, mu); + if (allocate) + pA->template exchange< true >(pin, mu); + else + pA->template exchange< false >(pin, mu); +} +template< class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value != 1 >::type* = nullptr > +void exchange(Type* const& pA, K* pin, unsigned short mu, bool allocate) {} +template< class U, class Type, class K > +void exchange_dispatched(Type* const& pA, KN< K >* pin, bool scaled) { + if (pA) { + unsigned short mu = pA->getDof( ) ? pin->n / pA->getDof( ) : 1; + const auto& map = pA->getMap( ); + bool allocate = map.size( ) > 0 && pA->getBuffer( )[0] == nullptr ? pA->setBuffer( ) : false; + U* x = reinterpret_cast< U* >((upscaled_type< U >*)*pin); + if (!std::is_same< upscaled_type< U >, U >::value) { + for (int i = 0; i < pin->n; ++i) x[i] = pin->operator[](i); + } + if (scaled) + exchange(pA, x, mu, false); else - pA->template exchange(pin, mu); -} -template::value != 1>::type* = nullptr> -void exchange(Type* const& pA, K* pin, unsigned short mu, bool allocate) { } -template -void exchange_dispatched(Type* const& pA, KN* pin, bool scaled) { - if(pA) { - unsigned short mu = pA->getDof() ? pin->n / pA->getDof() : 1; - const auto& map = pA->getMap(); - bool allocate = map.size() > 0 && pA->getBuffer()[0] == nullptr ? pA->setBuffer() : false; - U* x = reinterpret_cast((upscaled_type*)*pin); - if(!std::is_same, U>::value) { - for(int i = 0; i < pin->n; ++i) - x[i] = pin->operator[](i); - } - if(scaled) - exchange(pA, x, mu, false); - else - pA->HPDDM::template Subdomain::exchange(x, mu); - pA->clearBuffer(allocate); - if(!std::is_same, U>::value) { - for(int i = pin->n - 1; i >= 0; --i) - pin->operator[](i) = x[i]; - } + pA->HPDDM::template Subdomain< U >::exchange(x, mu); + pA->clearBuffer(allocate); + if (!std::is_same< upscaled_type< U >, U >::value) { + for (int i = pin->n - 1; i >= 0; --i) pin->operator[](i) = x[i]; } + } } -template::value != 0>::type* = nullptr> -void exchange(Type* const& pA, KN* pin, bool scaled) { - exchange_dispatched(pA, pin, scaled); +template< class U, class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value != 0 >::type* = nullptr > +void exchange(Type* const& pA, KN< K >* pin, bool scaled) { + exchange_dispatched< U >(pA, pin, scaled); } -template::value == 0>::type* = nullptr> -void exchange(Type* const& pA, KN* pin, bool scaled) { - if(pA) - exchange_dispatched(pA->_A, pin, scaled); +template< class U, class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value == 0 >::type* = nullptr > +void exchange(Type* const& pA, KN< K >* pin, bool scaled) { + if (pA) exchange_dispatched< U >(pA->_A, pin, scaled); } -template::value != 0>::type* = nullptr> -void exchange_restriction(Type* const&, KN*, KN*, MatriceMorse*) { } +template< class U, class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value != 0 >::type* = nullptr > +void exchange_restriction(Type* const&, KN< K >*, KN< K >*, MatriceMorse< double >*) {} namespace PETSc { -template - void changeNumbering_func(Type*, KN*, KN*, bool){ ffassert(0); } -} -template::value == 0>::type* = nullptr> -void exchange_restriction(Type* const& pA, KN* pin, KN* pout, MatriceMorse* mR) { - if(pA->_exchange && !pA->_exchange[1]) { - ffassert((!mR && pA->_exchange[0]->getDof() == pout->n) || (mR && mR->n == pin->n && mR->m == pout->n)); - PETSc::changeNumbering_func(pA, pin, pout, false); - PETSc::changeNumbering_func(pA, pin, pout, true); - pout->resize(pA->_exchange[0]->getDof()); - *pout = K(); - - if(mR) { - // out += A^t in - for(int k = 0; k < mR->nnz; ++k) - pout->operator[](mR->j[k]) += mR->aij[k] * pin->operator[](mR->i[k]); - } - exchange_dispatched(pA->_exchange[0], pout, false); + template< class Type, class K > + void changeNumbering_func(Type*, KN< K >*, KN< K >*, bool) { + ffassert(0); + } +} // namespace PETSc +template< class U, class Type, class K, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value == 0 >::type* = nullptr > +void exchange_restriction(Type* const& pA, KN< K >* pin, KN< K >* pout, MatriceMorse< double >* mR) { + if (pA->_exchange && !pA->_exchange[1]) { + ffassert((!mR && pA->_exchange[0]->getDof( ) == pout->n) || (mR && mR->n == pin->n && mR->m == pout->n)); + PETSc::changeNumbering_func(pA, pin, pout, false); + PETSc::changeNumbering_func(pA, pin, pout, true); + pout->resize(pA->_exchange[0]->getDof( )); + *pout = K( ); + + if (mR) { + // out += A^t in + for (int k = 0; k < mR->nnz; ++k) pout->operator[](mR->j[k]) += mR->aij[k] * pin->operator[](mR->i[k]); } + exchange_dispatched< U >(pA->_exchange[0], pout, false); + } } -template +template< class Type, class K > class exchangeIn_Op : public E_F0mps { - public: - Expression A; - Expression in; - static const int n_name_param = 1; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - exchangeIn_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), in(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } - - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type exchangeIn_Op::name_param[] = { - {"scaled", &typeid(bool)} + public: + Expression A; + Expression in; + static const int n_name_param = 1; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + exchangeIn_Op< Type, K >(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), in(param2) { args.SetNameParam(n_name_param, name_param, nargs); } + + AnyType operator( )(Stack stack) const; }; -template +template< class Type, class K > +basicAC_F0::name_and_type exchangeIn_Op< Type, K >::name_param[] = {{"scaled", &typeid(bool)}}; +template< class Type, class K > class exchangeIn : public OneOperator { - public: - exchangeIn() : OneOperator(atype(), atype(), atype>*>()) { } + public: + exchangeIn( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< upscaled_type< K > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new exchangeIn_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0* code(const basicAC_F0& args) const { return new exchangeIn_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } }; -template -AnyType exchangeIn_Op::operator()(Stack stack) const { - Type* pA = GetAny((*A)(stack)); - KN>* pin = GetAny>*>((*in)(stack)); - const bool scaled = mpisize > 1 && nargs[0] && GetAny((*nargs[0])(stack)); - exchange(pA, pin, scaled); - return 0L; -} -template +template< class Type, class K > +AnyType exchangeIn_Op< Type, K >::operator( )(Stack stack) const { + Type* pA = GetAny< Type* >((*A)(stack)); + KN< upscaled_type< K > >* pin = GetAny< KN< upscaled_type< K > >* >((*in)(stack)); + const bool scaled = mpisize > 1 && nargs[0] && GetAny< bool >((*nargs[0])(stack)); + exchange< K >(pA, pin, scaled); + return 0L; +} +template< class Type, class K > class exchangeInOut_Op : public E_F0mps { - public: - Expression A; - Expression in; - Expression out; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - exchangeInOut_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), in(param2), out(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + public: + Expression A; + Expression in; + Expression out; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + exchangeInOut_Op< Type, K >(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), in(param2), out(param3) { + args.SetNameParam(n_name_param, name_param, nargs); + } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type exchangeInOut_Op::name_param[] = { - {"scaled", &typeid(bool)}, - {"restriction", &typeid(Matrice_Creuse*)} + AnyType operator( )(Stack stack) const; }; -template +template< class Type, class K > +basicAC_F0::name_and_type exchangeInOut_Op< Type, K >::name_param[] = {{"scaled", &typeid(bool)}, {"restriction", &typeid(Matrice_Creuse< double >*)}}; +template< class Type, class K > class exchangeInOut : public OneOperator { - public: - exchangeInOut() : OneOperator(atype(), atype(), atype>*>(), atype>*>()) { } + public: + exchangeInOut( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< upscaled_type< K > >* >( ), atype< KN< upscaled_type< K > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new exchangeInOut_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } + E_F0* code(const basicAC_F0& args) const { return new exchangeInOut_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; -template -AnyType exchangeInOut_Op::operator()(Stack stack) const { - Type* pA = GetAny((*A)(stack)); - KN>* pin = GetAny>*>((*in)(stack)); - KN>* pout = GetAny>*>((*out)(stack)); - const bool scaled = mpisize > 1 && nargs[0] && GetAny((*nargs[0])(stack)); - Matrice_Creuse* pR = nargs[1] ? GetAny*>((*nargs[1])(stack)) : nullptr; - MatriceMorse* mR = pR ? static_cast*>(&(*pR->A)) : nullptr; - if(pR) { - ffassert(!scaled); - exchange_restriction(pA, pin, pout, mR); - } - else if(pin->n == pout->n) { - *pout = *pin; - exchange(pA, pout, scaled); - } - return 0L; +template< class Type, class K > +AnyType exchangeInOut_Op< Type, K >::operator( )(Stack stack) const { + Type* pA = GetAny< Type* >((*A)(stack)); + KN< upscaled_type< K > >* pin = GetAny< KN< upscaled_type< K > >* >((*in)(stack)); + KN< upscaled_type< K > >* pout = GetAny< KN< upscaled_type< K > >* >((*out)(stack)); + const bool scaled = mpisize > 1 && nargs[0] && GetAny< bool >((*nargs[0])(stack)); + Matrice_Creuse< double >* pR = nargs[1] ? GetAny< Matrice_Creuse< double >* >((*nargs[1])(stack)) : nullptr; + MatriceMorse< double >* mR = pR ? static_cast< MatriceMorse< double >* >(&(*pR->A)) : nullptr; + if (pR) { + ffassert(!scaled); + exchange_restriction< K >(pA, pin, pout, mR); + } else if (pin->n == pout->n) { + *pout = *pin; + exchange< K >(pA, pout, scaled); + } + return 0L; } #if !HPDDM_PETSC || !defined(HPDDM_SLEPC) -double getOpt(string* const& ss) { - return HPDDM::Option::get()->val(*ss); -} -bool isSetOpt(string* const& ss) { - return HPDDM::Option::get()->set(*ss); -} +double getOpt(string* const& ss) { return HPDDM::Option::get( )->val(*ss); } +bool isSetOpt(string* const& ss) { return HPDDM::Option::get( )->set(*ss); } #endif -template +template< class Type, class K > bool destroyRecycling(Type* const& Op) { #ifndef HPDDM_SLEPC - HPDDM::Recycling::get()->destroy(Op->prefix()); + HPDDM::Recycling< K >::get( )->destroy(Op->prefix( )); #else - Op->destroy(); + Op->destroy( ); #endif - return false; + return false; } -template +template< class Type > bool statistics(Type* const& Op) { - Op->statistics(); - return false; + Op->statistics( ); + return false; } -template::value == 1>::type* = nullptr> +template< class K, class Type, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value == 1 >::type* = nullptr > const K* getScaling(Type* const& pA) { - if(pA) - return pA->getScaling(); - else - return nullptr; + if (pA) + return pA->getScaling( ); + else + return nullptr; } -template::value != 1>::type* = nullptr> +template< class K, class Type, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value != 1 >::type* = nullptr > const K* getScaling(Type* const& pA) { - if(pA) - return getScaling(pA->_A); - else - return nullptr; + if (pA) + return getScaling< K >(pA->_A); + else + return nullptr; } -template::value == 1>::type* = nullptr> +template< class Type, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value == 1 >::type* = nullptr > MPI_Comm getCommunicator(Type* const& pA) { - if(pA) - return pA->getCommunicator(); - else - return MPI_COMM_WORLD; + if (pA) + return pA->getCommunicator( ); + else + return MPI_COMM_WORLD; } -template::value != 1>::type* = nullptr> +template< class Type, typename std::enable_if< HPDDM::hpddm_method_id< Type >::value != 1 >::type* = nullptr > MPI_Comm getCommunicator(Type* const& pA) { - if(pA) - return getCommunicator(pA->_A); - else - return MPI_COMM_WORLD; -} -template>::value>::type* = nullptr> -inline K prod(K u, HPDDM::underlying_type d, K v) { - return std::conj(u) * d * v; -} -template>::value>::type* = nullptr> -inline K prod(K u, HPDDM::underlying_type d, K v) { - return u * d * v; -} -template -K scalarProduct(Type* const& Op, KN* const& u, KN* const& v) { - const HPDDM::underlying_type* const d = getScaling>(Op); - MPI_Comm comm = getCommunicator(Op); - K val = 0; - if(d) { - for(int i = 0; i < u->n; ++i) - val += prod(u->operator[](i), d[i], v->operator[](i)); - } - else - val = (*u, *v); - MPI_Allreduce(MPI_IN_PLACE, &val, 1, HPDDM::Wrapper::mpi_type(), MPI_SUM, comm); - return val; -} -template -void addScalarProduct() { - atype()->Add("(", "", new OneOperator3_*, KN*>(scalarProduct)); -} - -template -T* resizeClean(const Resize& t, const long &m) { - long M = t.v->N(); - if(M != m) { - M = std::min(M, m); - typename T::K* array = new typename T::K[M](); - for(long j = 0; j < M; ++j) { + if (pA) + return getCommunicator(pA->_A); + else + return MPI_COMM_WORLD; +} +template< class K, typename std::enable_if< !std::is_same< K, HPDDM::underlying_type< K > >::value >::type* = nullptr > +inline K prod(K u, HPDDM::underlying_type< K > d, K v) { + return std::conj(u) * d * v; +} +template< class K, typename std::enable_if< std::is_same< K, HPDDM::underlying_type< K > >::value >::type* = nullptr > +inline K prod(K u, HPDDM::underlying_type< K > d, K v) { + return u * d * v; +} +template< class Type, class K > +K scalarProduct(Type* const& Op, KN< K >* const& u, KN< K >* const& v) { + const HPDDM::underlying_type< K >* const d = getScaling< HPDDM::underlying_type< K > >(Op); + MPI_Comm comm = getCommunicator(Op); + K val = 0; + if (d) { + for (int i = 0; i < u->n; ++i) val += prod(u->operator[](i), d[i], v->operator[](i)); + } else + val = (*u, *v); + MPI_Allreduce(MPI_IN_PLACE, &val, 1, HPDDM::Wrapper< K >::mpi_type( ), MPI_SUM, comm); + return val; +} +template< class Op, class K > +void addScalarProduct( ) { + atype< Op* >( )->Add("(", "", new OneOperator3_< K, Op*, KN< K >*, KN< K >* >(scalarProduct< Op, K >)); +} + +template< class T > +T* resizeClean(const Resize< T >& t, const long& m) { + long M = t.v->N( ); + if (M != m) { + M = std::min(M, m); + typename T::K* array = new typename T::K[M]( ); + for (long j = 0; j < M; ++j) { #if defined(WITH_petsc) || defined(WITH_petsccomplex) - if((*t.v)[j]._petsc) { + if ((*t.v)[j]._petsc) { #endif - array[j] = (*t.v)[j]; - (*t.v)[j] = typename T::K(); + array[j] = (*t.v)[j]; + (*t.v)[j] = typename T::K( ); #if defined(WITH_petsc) || defined(WITH_petsccomplex) - } -#endif } - t.v->resize(m); - for(long j = 0; j < M; ++j) { -#if defined(WITH_petsc) || defined(WITH_petsccomplex) - if(array[j]._petsc) { #endif - (*t.v)[j] = array[j]; - array[j] = typename T::K(); + } + t.v->resize(m); + for (long j = 0; j < M; ++j) { #if defined(WITH_petsc) || defined(WITH_petsccomplex) - } + if (array[j]._petsc) { #endif + (*t.v)[j] = array[j]; + array[j] = typename T::K( ); +#if defined(WITH_petsc) || defined(WITH_petsccomplex) } - delete [] array; +#endif } - return t.v; -} - -template -T* resizeClean(const Resize& t, const long &n, const long &m) { - long N = t.v->N(); - long M = t.v->M(); - if (N != n || M != m) { - N = std::min(N, n); - M = std::min(M, m); - typename T::K* array = new typename T::K[N * M](); - for(long i = 0; i < N; ++i) - for(long j = 0; j < M; ++j) { + delete[] array; + } + return t.v; +} + +template< class T > +T* resizeClean(const Resize< T >& t, const long& n, const long& m) { + long N = t.v->N( ); + long M = t.v->M( ); + if (N != n || M != m) { + N = std::min(N, n); + M = std::min(M, m); + typename T::K* array = new typename T::K[N * M]( ); + for (long i = 0; i < N; ++i) + for (long j = 0; j < M; ++j) { #if defined(WITH_petsc) || defined(WITH_petsccomplex) - if((*t.v)(i, j)._petsc) { + if ((*t.v)(i, j)._petsc) { #endif - array[i * M + j] = (*t.v)(i, j); - (*t.v)(i, j) = typename T::K(); + array[i * M + j] = (*t.v)(i, j); + (*t.v)(i, j) = typename T::K( ); #if defined(WITH_petsc) || defined(WITH_petsccomplex) - } -#endif } - t.v->resize(n, m); - for(long i = 0; i < N; ++i) - for(long j = 0; j < M; ++j) { -#if defined(WITH_petsc) || defined(WITH_petsccomplex) - if(array[i * M + j]._petsc) { #endif - (*t.v)(i, j) = array[i * M + j]; - array[i * M + j] = typename T::K(); + } + t.v->resize(n, m); + for (long i = 0; i < N; ++i) + for (long j = 0; j < M; ++j) { #if defined(WITH_petsc) || defined(WITH_petsccomplex) - } + if (array[i * M + j]._petsc) { #endif + (*t.v)(i, j) = array[i * M + j]; + array[i * M + j] = typename T::K( ); +#if defined(WITH_petsc) || defined(WITH_petsccomplex) } - delete [] array; - } - return t.v; -} - -template -void addArray() { - Dcl_Type*>(InitP>, Destroy>); - TheOperators->Add("<-", new OneOperator2_*, KN*, long>(&set_init)); - atype*>()->Add("[", "", new OneOperator2_*, long>(get_elementp_*, long>)); - Dcl_Type>>(); - Add*>("resize", ".", new OneOperator1>, KN*>(to_Resize)); - Add>>("(", "", new OneOperator2_*, Resize>, long>(resizeClean)); - map_type_of_map[make_pair(atype(), atype())] = atype*>(); - Add*>("n", ".", new OneOperator1*>(get_n)); - - Dcl_Type*>(InitP>, Destroy>); - TheOperators->Add("<-", new OneOperator3_*, KNM*, long, long>(&set_init2)); - atype*>()->Add("(", "", new OneOperator3_*, long, long>(get_elementp2_*, long, long>)); - Dcl_Type>>(); - Add*>("resize", ".", new OneOperator1>, KNM*>(to_Resize)); - Add>>("(", "", new OneOperator3_*, Resize>, long, long>(resizeClean)); - map_type_of_map[make_pair(atype>(), atype())] = atype*>(); - Add*>("n", ".", new OneOperator1*>(get_n)); - Add*>("m", ".", new OneOperator1*>(get_m)); +#endif + } + delete[] array; + } + return t.v; +} + +template< class Op > +void addArray( ) { + Dcl_Type< KN< Op >* >(InitP< KN< Op > >, Destroy< KN< Op > >); + TheOperators->Add("<-", new OneOperator2_< KN< Op >*, KN< Op >*, long >(&set_init)); + atype< KN< Op >* >( )->Add("[", "", new OneOperator2_< Op*, KN< Op >*, long >(get_elementp_< Op, KN< Op >*, long >)); + Dcl_Type< Resize< KN< Op > > >( ); + Add< KN< Op >* >("resize", ".", new OneOperator1< Resize< KN< Op > >, KN< Op >* >(to_Resize)); + Add< Resize< KN< Op > > >("(", "", new OneOperator2_< KN< Op >*, Resize< KN< Op > >, long >(resizeClean)); + map_type_of_map[make_pair(atype< long >( ), atype< Op* >( ))] = atype< KN< Op >* >( ); + Add< KN< Op >* >("n", ".", new OneOperator1< long, KN< Op >* >(get_n)); + + Dcl_Type< KNM< Op >* >(InitP< KNM< Op > >, Destroy< KN< Op > >); + TheOperators->Add("<-", new OneOperator3_< KNM< Op >*, KNM< Op >*, long, long >(&set_init2)); + atype< KNM< Op >* >( )->Add("(", "", new OneOperator3_< Op*, KNM< Op >*, long, long >(get_elementp2_< Op, KNM< Op >*, long, long >)); + Dcl_Type< Resize< KNM< Op > > >( ); + Add< KNM< Op >* >("resize", ".", new OneOperator1< Resize< KNM< Op > >, KNM< Op >* >(to_Resize)); + Add< Resize< KNM< Op > > >("(", "", new OneOperator3_< KNM< Op >*, Resize< KNM< Op > >, long, long >(resizeClean)); + map_type_of_map[make_pair(atype< pair< long, long > >( ), atype< Op* >( ))] = atype< KNM< Op >* >( ); + Add< KNM< Op >* >("n", ".", new OneOperator1< long, KNM< Op >* >(get_n)); + Add< KNM< Op >* >("m", ".", new OneOperator1< long, KNM< Op >* >(get_m)); } void parallelIO(string*& name, MPI_Comm* const& comm, bool const& append, int& T, int& size, std::string& base_filename) { - base_filename = *name; - std::string::size_type p(base_filename.find_last_of('.')); - std::string file_without_extension = base_filename.substr(0, p); - std::string extension; - if(p == std::string::npos) - extension = "vtu"; - else - extension = base_filename.substr(p + 1, std::string::npos); - p = base_filename.find_last_of("/\\"); - if(p == std::string::npos) - base_filename = file_without_extension; - else - base_filename = file_without_extension.substr(p + 1, std::string::npos); - int rank; - MPI_Comm_rank(comm ? *comm : MPI_COMM_WORLD, &rank); - MPI_Comm_size(comm ? *comm : MPI_COMM_WORLD, &size); - std::ostringstream str[3]; - str[2] << size; - str[1] << std::setw(str[2].str().length()) << std::setfill('0') << rank; - ofstream pvd; - T = 0; - if(append) { - if(rank == 0) { - ifstream input; - input.open(file_without_extension + (size > 1 ? "_" + str[2].str() : "") + ".pvd"); - if(input.peek() != std::ifstream::traits_type::eof()) { - std::string line; - std::getline(input, line); - std::getline(input, line); - std::string delimiter = "\""; - p = line.find(delimiter); - line = line.substr(p + 1, std::string::npos); - p = line.find(delimiter); - T = std::stoi(line.substr(0, p)) + 1; - } - } - MPI_Bcast(&T, 1, MPI_INT, 0, comm ? *comm : MPI_COMM_WORLD); + base_filename = *name; + std::string::size_type p(base_filename.find_last_of('.')); + std::string file_without_extension = base_filename.substr(0, p); + std::string extension; + if (p == std::string::npos) + extension = "vtu"; + else + extension = base_filename.substr(p + 1, std::string::npos); + p = base_filename.find_last_of("/\\"); + if (p == std::string::npos) + base_filename = file_without_extension; + else + base_filename = file_without_extension.substr(p + 1, std::string::npos); + int rank; + MPI_Comm_rank(comm ? *comm : MPI_COMM_WORLD, &rank); + MPI_Comm_size(comm ? *comm : MPI_COMM_WORLD, &size); + std::ostringstream str[3]; + str[2] << size; + str[1] << std::setw(str[2].str( ).length( )) << std::setfill('0') << rank; + ofstream pvd; + T = 0; + if (append) { + if (rank == 0) { + ifstream input; + input.open(file_without_extension + (size > 1 ? "_" + str[2].str( ) : "") + ".pvd"); + if (input.peek( ) != std::ifstream::traits_type::eof( )) { + std::string line; + std::getline(input, line); + std::getline(input, line); + std::string delimiter = "\""; + p = line.find(delimiter); + line = line.substr(p + 1, std::string::npos); + p = line.find(delimiter); + T = std::stoi(line.substr(0, p)) + 1; + } } - str[0] << std::setw(4) << std::setfill('0') << T; - *name = file_without_extension + "_" + (size > 1 ? str[2].str() + "_" : "") + str[0].str() + (size > 1 ? "_" + str[1].str() : "") + "." + extension; -} - -long periodicity(Matrice_Creuse* const& R, KN< KN< long > >* const& interaction, KN< double >* const& D) { - if(R->A) { - MatriceMorse< double >* mR = static_cast< MatriceMorse< double >* >(&*(R->A)); - mR->COO(); - KN< double > restriction(mR->n); - std::unordered_map map; - map.reserve(mR->nnz); - for(int k = 0; k < mR->nnz; ++k) { - if(std::abs(mR->aij[k]) > 1e-12) { - restriction[mR->i[k]] = D->operator[](mR->j[k]); - map[mR->j[k]] = mR->i[k]; - } - } - D->resize(mR->n); - *D = restriction; - if(interaction->N() > 0) { - for(int i = 0; i < interaction->operator[](0).N(); ++i) { - int nnz = 0; - for(int j = 0; j < interaction->operator[](1 + i).N(); ++j) { - std::unordered_map::iterator it = map.find(interaction->operator[](1 + i)[j]); - if(it != map.end()) { - interaction->operator[](1 + i)[nnz] = it->second; - ++nnz; - } - } - interaction->operator[](1 + i).resize(nnz); - } + MPI_Bcast(&T, 1, MPI_INT, 0, comm ? *comm : MPI_COMM_WORLD); + } + str[0] << std::setw(4) << std::setfill('0') << T; + *name = file_without_extension + "_" + (size > 1 ? str[2].str( ) + "_" : "") + str[0].str( ) + (size > 1 ? "_" + str[1].str( ) : "") + "." + extension; +} + +long periodicity(Matrice_Creuse< double >* const& R, KN< KN< long > >* const& interaction, KN< double >* const& D) { + if (R->A) { + MatriceMorse< double >* mR = static_cast< MatriceMorse< double >* >(&*(R->A)); + mR->COO( ); + KN< double > restriction(mR->n); + std::unordered_map< int, int > map; + map.reserve(mR->nnz); + for (int k = 0; k < mR->nnz; ++k) { + if (std::abs(mR->aij[k]) > 1e-12) { + restriction[mR->i[k]] = D->operator[](mR->j[k]); + map[mR->j[k]] = mR->i[k]; + } + } + D->resize(mR->n); + *D = restriction; + if (interaction->N( ) > 0) { + for (int i = 0; i < interaction->operator[](0).N( ); ++i) { + int nnz = 0; + for (int j = 0; j < interaction->operator[](1 + i).N( ); ++j) { + std::unordered_map< int, int >::iterator it = map.find(interaction->operator[](1 + i)[j]); + if (it != map.end( )) { + interaction->operator[](1 + i)[nnz] = it->second; + ++nnz; + } } + interaction->operator[](1 + i).resize(nnz); + } } - return 0L; + } + return 0L; } #define COMMON_HPDDM_PARALLEL_IO @@ -603,79 +575,75 @@ namespace PETSc { PetscFinalized(&isFinalized); if (!isFinalized) PetscFinalize( ); } -} +} // namespace PETSc #endif #if defined(MU_SLEPC) namespace PETSc { - void finalizeSLEPc( ) { - SlepcFinalize( ); - } -} + void finalizeSLEPc( ) { SlepcFinalize( ); } +} // namespace PETSc #endif -template -MatriceMorse* kron_impl(Matrice_Creuse* const& A, Matrice_Creuse* const& B) { - ffassert(A->A && B->A); - MatriceMorse* mA = static_cast*>(&(*A->A)); - MatriceMorse* mB = static_cast*>(&(*B->A)); - MatriceMorse& C = *new MatriceMorse(A->A->n * B->A->n, A->A->m * B->A->m, mA->nnz * mB->nnz, 0); - mA->CSR(); - mB->CSR(); - C.CSR(); - C.p[0] = 0; - for(int i = 0; i < mA->n; ++i) - for(int j = 0; j < mB->n; ++j) - C.p[i * mB->n + j + 1] = C.p[i * mB->n + j] + (mA->p[i + 1] - mA->p[i]) * (mB->p[j + 1] - mB->p[j]); - C.nnz = mA->nnz * mB->nnz; - int k = 0; - for(int i = 0; i < mA->n; ++i) - for(int p = 0; p < mB->n; ++p) { - for(int j = mA->p[i]; j < mA->p[i + 1]; ++j) { - for(int q = mB->p[p]; q < mB->p[p + 1]; ++q) { - C.j[k] = mA->j[j] * mB->m + mB->j[q]; - C.aij[k] = mA->aij[j] * mB->aij[q]; - ++k; - } - } +template< class K > +MatriceMorse< K >* kron_impl(Matrice_Creuse< K >* const& A, Matrice_Creuse< K >* const& B) { + ffassert(A->A && B->A); + MatriceMorse< K >* mA = static_cast< MatriceMorse< K >* >(&(*A->A)); + MatriceMorse< K >* mB = static_cast< MatriceMorse< K >* >(&(*B->A)); + MatriceMorse< K >& C = *new MatriceMorse< K >(A->A->n * B->A->n, A->A->m * B->A->m, mA->nnz * mB->nnz, 0); + mA->CSR( ); + mB->CSR( ); + C.CSR( ); + C.p[0] = 0; + for (int i = 0; i < mA->n; ++i) + for (int j = 0; j < mB->n; ++j) C.p[i * mB->n + j + 1] = C.p[i * mB->n + j] + (mA->p[i + 1] - mA->p[i]) * (mB->p[j + 1] - mB->p[j]); + C.nnz = mA->nnz * mB->nnz; + int k = 0; + for (int i = 0; i < mA->n; ++i) + for (int p = 0; p < mB->n; ++p) { + for (int j = mA->p[i]; j < mA->p[i + 1]; ++j) { + for (int q = mB->p[p]; q < mB->p[p + 1]; ++q) { + C.j[k] = mA->j[j] * mB->m + mB->j[q]; + C.aij[k] = mA->aij[j] * mB->aij[q]; + ++k; } - return &C; + } + } + return &C; } -template -newpMatrice_Creuse kron(Stack stack, Matrice_Creuse* const& A, Matrice_Creuse* const& B) { - return newpMatrice_Creuse(stack, kron_impl(A, B)); +template< class K > +newpMatrice_Creuse< K > kron(Stack stack, Matrice_Creuse< K >* const& A, Matrice_Creuse< K >* const& B) { + return newpMatrice_Creuse< K >(stack, kron_impl(A, B)); } -static void Init_Common() { - if(!Global.Find("savevtk").NotNull()) { - Global.Add("savevtk", "(", new OneOperatorCode ); - Global.Add("savevtk", "(", new OneOperatorCode ); - Global.Add("savevtk", "(", new OneOperatorCode< VTK_WriteMeshT_Op< MeshS > >); - } - if(!Global.Find("periodicity").NotNull()) { - Global.Add("periodicity", "(", new OneOperator3_*, KN< KN< long > >*, KN< double >*>(periodicity)); - Global.Add("kron", "(", new OneOperator2s_, Matrice_Creuse*, Matrice_Creuse*>(kron)); - Global.Add("kron", "(", new OneOperator2s_>, Matrice_Creuse>*, Matrice_Creuse>*>(kron)); - } +static void Init_Common( ) { + if (!Global.Find("savevtk").NotNull( )) { + Global.Add("savevtk", "(", new OneOperatorCode< VTK_WriteMesh_Op >); + Global.Add("savevtk", "(", new OneOperatorCode< VTK_WriteMesh3_Op >); + Global.Add("savevtk", "(", new OneOperatorCode< VTK_WriteMeshT_Op< MeshS > >); + } + if (!Global.Find("periodicity").NotNull( )) { + Global.Add("periodicity", "(", new OneOperator3_< long, Matrice_Creuse< double >*, KN< KN< long > >*, KN< double >* >(periodicity)); + Global.Add("kron", "(", new OneOperator2s_< newpMatrice_Creuse< double >, Matrice_Creuse< double >*, Matrice_Creuse< double >* >(kron)); + Global.Add("kron", "(", new OneOperator2s_< newpMatrice_Creuse< std::complex< double > >, Matrice_Creuse< std::complex< double > >*, Matrice_Creuse< std::complex< double > >* >(kron)); + } #if HPDDM_SCHWARZ || HPDDM_FETI || HPDDM_BDD - aType t; - int r; - if(!zzzfff->InMotClef("pair", t, r)) { - Global.Add("getOption", "(", new OneOperator1_(getOpt)); - Global.Add("isSetOption", "(", new OneOperator1_(isSetOpt)); - int argc = pkarg->n; - const char** argv = new const char*[argc]; - for(int i = 0; i < argc; ++i) - argv[i] = (*((*pkarg)[i].getap()))->data(); - HPDDM::Option::get()->parse(argc, argv, mpirank == 0); + aType t; + int r; + if (!zzzfff->InMotClef("pair", t, r)) { + Global.Add("getOption", "(", new OneOperator1_< double, string* >(getOpt)); + Global.Add("isSetOption", "(", new OneOperator1_< bool, string* >(isSetOpt)); + int argc = pkarg->n; + const char** argv = new const char*[argc]; + for (int i = 0; i < argc; ++i) argv[i] = (*((*pkarg)[i].getap( )))->data( ); + HPDDM::Option::get( )->parse(argc, argv, mpirank == 0); #if defined(MU_SLEPC) - SlepcInitialize(&argc, const_cast(&argv), 0, ""); - ff_atend(PETSc::finalizeSLEPc); + SlepcInitialize(&argc, const_cast< char*** >(&argv), 0, ""); + ff_atend(PETSc::finalizeSLEPc); #elif defined(PETSCSUB) - PetscInitialize(&argc, const_cast(&argv), 0, ""); - ff_atend(PETSc::finalizePETSc); + PetscInitialize(&argc, const_cast< char*** >(&argv), 0, ""); + ff_atend(PETSc::finalizePETSc); #endif - delete [] argv; - } + delete[] argv; + } #endif } -#endif // _COMMON_HPDDM_ +#endif // _COMMON_HPDDM_ diff --git a/plugin/mpi/function-PETSc.cpp b/plugin/mpi/function-PETSc.cpp index 44e82aa78..3842eba0e 100644 --- a/plugin/mpi/function-PETSc.cpp +++ b/plugin/mpi/function-PETSc.cpp @@ -1,22 +1,22 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: petsc mpi +/* clang-format on */ #include #include -long initialized() { - PetscBool isInitialized; - PetscErrorCode ierr = PetscInitialized(&isInitialized); +long initialized( ) { + PetscBool isInitialized; + PetscErrorCode ierr = PetscInitialized(&isInitialized); #ifdef _WIN32 - if(!isInitialized) { - ierr = PetscInitializeNoArguments(); - ierr = PetscInitialized(&isInitialized); - } + if (!isInitialized) { + ierr = PetscInitializeNoArguments( ); + ierr = PetscInitialized(&isInitialized); + } #endif - (void)ierr; - return static_cast(isInitialized); + (void)ierr; + return static_cast< long >(isInitialized); } -static void Init_function( ) { - Global.Add("PetscInitialized", "(", new OneOperator0< long >(initialized)); -} +static void Init_function( ) { Global.Add("PetscInitialized", "(", new OneOperator0< long >(initialized)); } LOADFUNC(Init_function) diff --git a/plugin/mpi/generaldefs.h b/plugin/mpi/generaldefs.h old mode 100755 new mode 100644 index 802cef4f5..3c90d53c5 --- a/plugin/mpi/generaldefs.h +++ b/plugin/mpi/generaldefs.h @@ -1,11 +1,11 @@ #if defined(AIX) #define wreadmtc wreadmtc -#define userread userread +#define userread userread #define nod2dom nod2dom #define roscal roscal #define coscal coscal #define csrcsc csrcsc -#define aplb aplb +#define aplb aplb #define expnddom expnddom #elif defined(BGL) #define wreadmtc wreadmtc @@ -14,16 +14,16 @@ #define roscal roscal #define coscal coscal #define csrcsc csrcsc -#define aplb aplb +#define aplb aplb #define expnddom expnddom #elif defined(LINUX) #define wreadmtc wreadmtc_ -#define userread userread_ +#define userread userread_ #define nod2dom nod2dom_ #define roscal roscal_ #define coscal coscal_ #define csrcsc csrcsc_ -#define aplb aplb_ +#define aplb aplb_ #define expnddom expnddom_ #elif defined(CRAY) #define wreadmtc WREADMTC @@ -32,7 +32,7 @@ #define roscal ROSCAL #define coscal COSCAL #define csrcsc CSRCSC -#define aplb APLB +#define aplb APLB #define expnddom EXPNDDOM #else #define wreadmtc wreadmtc_ @@ -41,42 +41,25 @@ #define roscal roscal_ #define coscal coscal_ #define csrcsc csrcsc_ -#define aplb aplb_ +#define aplb aplb_ #define expnddom expnddom_ #endif /* for outer and inner functions */ -extern void setpar(char *filename, char *matrix, int *iov, int *scale, - int *unsym, int *method, PrePar prepar, IterPar ipar, - DistMatrix dm) ; +extern void setpar(char *filename, char *matrix, int *iov, int *scale, int *unsym, int *method, PrePar prepar, IterPar ipar, DistMatrix dm); -int assignprecon( char *precon_str, DistMatrix dm); +int assignprecon(char *precon_str, DistMatrix dm); -void set_def_params(PrePar prepar, IterPar ipar) ; +void set_def_params(PrePar prepar, IterPar ipar); -extern void userread(char *fname, int *len, int *job, int *n, int - *nnz, double *a, int *ja, int *ia, int *nrhs, - double *rhs, int *ierr); -extern void wreadmtc(int *nmax, int *nzmax, int *job, char *fname,int - *len, double *a, int *ja, int *ia, double *rhs, - int *nrhs, char *guesol, int *nrow, int *ncol, - int *nnz, char *title, char *key, char *type, int - *ierr) ; -extern void nod2dom(int *n, int *ndom, int *nodes, int *pointer, int - *map, int *mapsize, int *ier); -extern void roscal(int *n, int *job, int *nrm, double *a, int *ja, int - *ia, double *diag, double *b, int *jb, int *ib, int - *ierr); -extern void coscal(int *n, int *job, int *nrm, double *a, int *ja, int - *ia, double *diag, double *b, int *jb, int *ib, int - *ierr); -extern void csrcsc(int *n, int *job, int *ipos, double *a, int *ja, - int *ia, double *ao, int *jao, int *iao); -extern void aplb(int *nrow, int *ncol, int *job, double *a, int *ja, - int *ia, double *b, int *jb, int *ib, double *c, int - *jc, int *ic, int *nnzmax, int *iw, int *ierr); -extern void expnddom(int *, int *, int *, int *, int *, int *, int - *, int *, int *, int *); +extern void userread(char *fname, int *len, int *job, int *n, int *nnz, double *a, int *ja, int *ia, int *nrhs, double *rhs, int *ierr); +extern void wreadmtc(int *nmax, int *nzmax, int *job, char *fname, int *len, double *a, int *ja, int *ia, double *rhs, int *nrhs, char *guesol, int *nrow, int *ncol, int *nnz, char *title, char *key, + char *type, int *ierr); +extern void nod2dom(int *n, int *ndom, int *nodes, int *pointer, int *map, int *mapsize, int *ier); +extern void roscal(int *n, int *job, int *nrm, double *a, int *ja, int *ia, double *diag, double *b, int *jb, int *ib, int *ierr); +extern void coscal(int *n, int *job, int *nrm, double *a, int *ja, int *ia, double *diag, double *b, int *jb, int *ib, int *ierr); +extern void csrcsc(int *n, int *job, int *ipos, double *a, int *ja, int *ia, double *ao, int *jao, int *iao); +extern void aplb(int *nrow, int *ncol, int *job, double *a, int *ja, int *ia, double *b, int *jb, int *ib, double *c, int *jc, int *ic, int *nnzmax, int *iw, int *ierr); +extern void expnddom(int *, int *, int *, int *, int *, int *, int *, int *, int *, int *); /*-----------------------------------------------------------------------*/ - diff --git a/plugin/mpi/hpddm.cpp b/plugin/mpi/hpddm.cpp index a984421aa..8d5ef8306 100644 --- a/plugin/mpi/hpddm.cpp +++ b/plugin/mpi/hpddm.cpp @@ -1,1036 +1,971 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: hpddm [mumps parmetis metis ptscotch scotch scalapack mpifc fc|umfpack] [mkl|blas] mpi //ff-c++-cpp-dep: +/* clang-format on */ -#define HPDDM_PRECISION 2 +#define HPDDM_PRECISION 2 -#define HPDDM_SCHWARZ 1 -#define HPDDM_FETI 0 -#define HPDDM_BDD 0 +#define HPDDM_SCHWARZ 1 +#define HPDDM_FETI 0 +#define HPDDM_BDD 0 #if PRECISION == 2 -#define HPDDM_INEXACT_COARSE_OPERATOR 1 +#define HPDDM_INEXACT_COARSE_OPERATOR 1 #else -#define HPDDM_INEXACT_COARSE_OPERATOR 0 +#define HPDDM_INEXACT_COARSE_OPERATOR 0 #endif #include "common_hpddm.hpp" namespace Schwarz { -template -class initDDM : public OneOperator { - public: - const int c; - class E_initDDM : public E_F0mps { - public: - Expression A; - Expression Mat; - Expression R; - Expression D; - const int c; - static const int n_name_param = 3; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - E_initDDM(const basicAC_F0& args, int d) : A(0), Mat(0), R(0), D(0), c(d) { - args.SetNameParam(n_name_param, name_param, nargs); - A = to(args[0]); - if(c == 0 || c == 2) - Mat = to>*>(args[1]); - else - Mat = to(args[1]); - if(c == 0 || c == 1) { - R = to>*>(args[2]); - D = to>>*>(args[3]); - } - } + template< class Type, class K > + class initDDM : public OneOperator { + public: + const int c; + class E_initDDM : public E_F0mps { + public: + Expression A; + Expression Mat; + Expression R; + Expression D; + const int c; + static const int n_name_param = 3; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + E_initDDM(const basicAC_F0& args, int d) : A(0), Mat(0), R(0), D(0), c(d) { + args.SetNameParam(n_name_param, name_param, nargs); + A = to< Type* >(args[0]); + if (c == 0 || c == 2) + Mat = to< Matrice_Creuse< HPDDM::upscaled_type< K > >* >(args[1]); + else + Mat = to< long >(args[1]); + if (c == 0 || c == 1) { + R = to< KN< KN< long > >* >(args[2]); + D = to< KN< HPDDM::underlying_type< HPDDM::upscaled_type< K > > >* >(args[3]); + } + } - AnyType operator()(Stack stack) const; - operator aType() const { return atype(); } - }; - E_F0* code(const basicAC_F0 & args) const { return new E_initDDM(args, c); } - initDDM() : OneOperator(atype(), atype(), atype>*>(), atype>*>(), atype>>*>()), c(0) { } - initDDM(int) : OneOperator(atype(), atype(), atype(), atype>*>(), atype>>*>()), c(1) { } - initDDM(int, int) : OneOperator(atype(), atype(), atype>*>()), c(2) { } - initDDM(int, int, int) : OneOperator(atype(), atype(), atype()), c(3) { } -}; -template -basicAC_F0::name_and_type initDDM::E_initDDM::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"scaled", &typeid(bool)}, - {"level", &typeid(long)} -}; -template -AnyType initDDM::E_initDDM::operator()(Stack stack) const { - Type* ptA = GetAny((*A)(stack)); - HPDDM::MatrixCSR* dA; - if(c == 0 || c == 2) { - MatriceMorse>* mA = static_cast>*>(&(*GetAny>*>((*Mat)(stack))->A)); - dA = new_HPDDM_MatrixCSR(mA); - } - else { - int dof = GetAny((*Mat)(stack)); - dA = new HPDDM::MatrixCSR(dof, dof, 0, nullptr, nullptr, nullptr, false); + AnyType operator( )(Stack stack) const; + operator aType( ) const { return atype< Type* >( ); } + }; + E_F0* code(const basicAC_F0& args) const { return new E_initDDM(args, c); } + initDDM( ) + : OneOperator(atype< Type* >( ), atype< Type* >( ), atype< Matrice_Creuse< HPDDM::upscaled_type< K > >* >( ), atype< KN< KN< long > >* >( ), + atype< KN< HPDDM::underlying_type< HPDDM::upscaled_type< K > > >* >( )), + c(0) {} + initDDM(int) : OneOperator(atype< Type* >( ), atype< Type* >( ), atype< long >( ), atype< KN< KN< long > >* >( ), atype< KN< HPDDM::underlying_type< HPDDM::upscaled_type< K > > >* >( )), c(1) {} + initDDM(int, int) : OneOperator(atype< Type* >( ), atype< Type* >( ), atype< Matrice_Creuse< HPDDM::upscaled_type< K > >* >( )), c(2) {} + initDDM(int, int, int) : OneOperator(atype< Type* >( ), atype< Type* >( ), atype< long >( )), c(3) {} + }; + template< class Type, class K > + basicAC_F0::name_and_type initDDM< Type, K >::E_initDDM::name_param[] = {{"communicator", &typeid(pcommworld)}, {"scaled", &typeid(bool)}, {"level", &typeid(long)}}; + template< class Type, class K > + AnyType initDDM< Type, K >::E_initDDM::operator( )(Stack stack) const { + Type* ptA = GetAny< Type* >((*A)(stack)); + HPDDM::MatrixCSR< K >* dA; + if (c == 0 || c == 2) { + MatriceMorse< HPDDM::upscaled_type< K > >* mA = static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*Mat)(stack))->A)); + dA = new_HPDDM_MatrixCSR< K >(mA); + } else { + int dof = GetAny< long >((*Mat)(stack)); + dA = new HPDDM::MatrixCSR< K >(dof, dof, 0, nullptr, nullptr, nullptr, false); } - if(c == 0 || c == 1) { - KN>* ptR = GetAny>*>((*R)(stack)); - int level = nargs[2] ? std::abs(GetAny< long >((*nargs[2])(stack))) : 0; - KN>>* ptD = GetAny>>*>((*D)(stack)); - if(ptR) { - KN_> sub(ptR->n > 0 && ptR->operator[](0).n > 0 ? (*ptR)(FromTo(1 + level * ptR->operator[](0).n, 1 + (level + 1) * ptR->operator[](0).n - 1)) : KN>()); - ptA->HPDDM::template Subdomain::initialize(dA, STL(ptR->n > 0 ? ptR->operator[](0) : KN()), sub, nargs[0] ? (MPI_Comm*)GetAny((*nargs[0])(stack)) : 0); + if (c == 0 || c == 1) { + KN< KN< long > >* ptR = GetAny< KN< KN< long > >* >((*R)(stack)); + int level = nargs[2] ? std::abs(GetAny< long >((*nargs[2])(stack))) : 0; + KN< HPDDM::underlying_type< HPDDM::upscaled_type< K > > >* ptD = GetAny< KN< HPDDM::underlying_type< HPDDM::upscaled_type< K > > >* >((*D)(stack)); + if (ptR) { + KN_< KN< long > > sub(ptR->n > 0 && ptR->operator[](0).n > 0 ? (*ptR)(FromTo(1 + level * ptR->operator[](0).n, 1 + (level + 1) * ptR->operator[](0).n - 1)) : KN< KN< long > >( )); + ptA->HPDDM::template Subdomain< K >::initialize(dA, STL< long >(ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), sub, nargs[0] ? (MPI_Comm*)GetAny< pcommworld >((*nargs[0])(stack)) : 0); + } + if (ptD) { + HPDDM::underlying_type< K >* d = reinterpret_cast< HPDDM::underlying_type< K >* >(ptD->operator HPDDM::upscaled_type< HPDDM::underlying_type< K > >*( )); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = 0; i < ptD->n; ++i) d[i] = ptD->operator[](i); } - if(ptD) { - HPDDM::underlying_type* d = reinterpret_cast*>(ptD->operator HPDDM::upscaled_type>*()); - if(!std::is_same, K>::value) { - for(int i = 0; i < ptD->n; ++i) - d[i] = ptD->operator[](i); - } - ptA->initialize(d); - } - else - std::cerr << "Something is really wrong here!" << std::endl; - if(c == 0 && (!nargs[1] || GetAny((*nargs[1])(stack)))) - ptA->exchange(); - } - else { - const MPI_Comm& comm = MPI_COMM_SELF; - ptA->HPDDM::template Subdomain::initialize(dA, STL( KN()), KN>(), const_cast(&comm)); + ptA->initialize(d); + } else + std::cerr << "Something is really wrong here!" << std::endl; + if (c == 0 && (!nargs[1] || GetAny< bool >((*nargs[1])(stack)))) ptA->exchange( ); + } else { + const MPI_Comm& comm = MPI_COMM_SELF; + ptA->HPDDM::template Subdomain< K >::initialize(dA, STL< long >(KN< long >( )), KN< KN< long > >( ), const_cast< MPI_Comm* >(&comm)); } return ptA; -} + } -template -class attachCoarseOperator : public OneOperator { - public: - typedef KN> Kn; - typedef KN_> Kn_; - class MatF_O : public RNM_VirtualMatrix>, public Type::super::CoarseCorrection { - public: - typedef typename Type::super::CoarseCorrection super; - Stack stack; - mutable Kn x; - C_F0 c_x; - Expression mat; - typedef typename RNM_VirtualMatrix>::plusAx plusAx; - MatF_O(int n, Stack stk, const OneOperator* op) : - RNM_VirtualMatrix>(n), stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) { } - ~MatF_O() { - delete mat; - Expression zzz = c_x; - delete zzz; - } - virtual void operator()(const K* const in, K* const out) { - KN_ xx(const_cast(in), this->N); - KN_ yy(out, this->N); - addMatMul(xx, yy); - } - void addMatMul(const Kn_& xx, Kn_& Ax) const { - ffassert(xx.N() == this->N && Ax.N() == this->M); - x = xx; - Ax = GetAny((*mat)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - } - template>::value>::type* = nullptr> - void addMatMul(const KN_& xx, KN_& Ax) const { - ffassert(xx.N() == this->N && Ax.N() == this->M); - x = xx; - { - KN> res(this->M, 0.0); - res = GetAny((*mat)(stack)); - for(int i = 0; i < this->M; ++i) - Ax[i] = res[i]; - } - WhereStackOfPtr2Free(stack)->clean(); - } - plusAx operator*(const Kn& x) const { return plusAx(this, x); } - bool ChecknbLine(int) const { return true; } - bool ChecknbColumn(int) const { return true; } - }; - class MatMatF_O : public RNM_VirtualMatrix>, public Type::super::CoarseCorrection { - public: - typedef typename Type::super::CoarseCorrection super; - Stack stack; - mutable Kn x; - C_F0 c_x; - mutable long mu; - C_F0 c_mu; - Expression mat; - typedef typename RNM_VirtualMatrix>::plusAx plusAx; - MatMatF_O(int n, Stack stk, const OneOperator* op) : - RNM_VirtualMatrix>(n), stack(stk), x(0), c_x(CPValue(x)), mu(1), c_mu(CPValue(mu)), - mat(op ? CastTo(C_F0(op->code(basicAC_F0_wa({ c_x, c_mu })), (aType)*op)) : 0) { } - ~MatMatF_O() { - delete mat; - Expression zzz = c_x; - delete zzz; - zzz = c_mu; - delete zzz; - } - virtual void operator()(const K* const in, K* const out) { - mu = 1; - KN_ xx(const_cast(in), this->N); - KN_ yy(out, this->N); - addMatMul(xx, yy); - } - virtual void operator()(const K* const in, K* const out, int n, unsigned short nu) { - mu = nu; - KN_ xx(const_cast(in), this->N * mu); - KN_ yy(out, this->N * mu); - addMatMul(xx, yy); - } - void addMatMul(const Kn_& xx, Kn_& Ax) const { - ffassert(xx.N() == this->N * mu && Ax.N() == this->M * mu); - HPDDM::upscaled_type* backup = x; - x.set(xx, this->N * mu); - Ax = GetAny((*mat)(stack)); - x.set(backup, 0); - WhereStackOfPtr2Free(stack)->clean(); - } - template>::value>::type* = nullptr> - void addMatMul(const KN_& xx, KN_& Ax) const { - ffassert(xx.N() == this->N * mu && Ax.N() == this->M * mu); - HPDDM::upscaled_type* backup = x; - { - KN> in(this->N * mu, 0.0); - KN> res(this->M * mu, 0.0); - x.set(in, this->N * mu); - for(int i = 0; i < this->N * mu; ++i) - x[i] = xx[i]; - res = GetAny((*mat)(stack)); - for(int i = 0; i < this->M * mu; ++i) - Ax[i] = res[i]; - x.set(backup, 0); - } - WhereStackOfPtr2Free(stack)->clean(); - } - plusAx operator*(const Kn& x) const { return plusAx(this, x); } - bool ChecknbLine(int) const { return true; } - bool ChecknbColumn(int) const { return true; } - }; - const int c; - class E_attachCoarseOperator : public E_F0mps { - public: - Expression A; - Expression comm; - const OneOperator *codeC; - const OneOperator *codeMatC; - const int c; - static const int n_name_param = 7; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - E_attachCoarseOperator(const basicAC_F0& args, int d) : A(0), comm(0), codeC(0), codeMatC(0), c(d) { - args.SetNameParam(n_name_param, name_param, nargs); - comm = to(args[0]); - A = to(args[1]); - if(c == 1) { - const Polymorphic* op = dynamic_cast(args[2].LeftValue()); - ffassert(op); - codeMatC = op->Find("(", ArrayOfaType(atype>*>(), atype(), false)); - if(!codeMatC) - codeC = op->Find("(", ArrayOfaType(atype>*>(), false)); - } - } + template< class Type, class K > + class attachCoarseOperator : public OneOperator { + public: + typedef KN< HPDDM::upscaled_type< K > > Kn; + typedef KN_< HPDDM::upscaled_type< K > > Kn_; + class MatF_O : public RNM_VirtualMatrix< HPDDM::upscaled_type< K > >, public Type::super::CoarseCorrection { + public: + typedef typename Type::super::CoarseCorrection super; + Stack stack; + mutable Kn x; + C_F0 c_x; + Expression mat; + typedef typename RNM_VirtualMatrix< HPDDM::upscaled_type< K > >::plusAx plusAx; + MatF_O(int n, Stack stk, const OneOperator* op) + : RNM_VirtualMatrix< HPDDM::upscaled_type< K > >(n), stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + ~MatF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + } + virtual void operator( )(const K* const in, K* const out) { + KN_< K > xx(const_cast< K* >(in), this->N); + KN_< K > yy(out, this->N); + addMatMul(xx, yy); + } + void addMatMul(const Kn_& xx, Kn_& Ax) const { + ffassert(xx.N( ) == this->N && Ax.N( ) == this->M); + x = xx; + Ax = GetAny< Kn_ >((*mat)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + } + template< class T, typename std::enable_if< !std::is_same< T, HPDDM::upscaled_type< T > >::value >::type* = nullptr > + void addMatMul(const KN_< T >& xx, KN_< T >& Ax) const { + ffassert(xx.N( ) == this->N && Ax.N( ) == this->M); + x = xx; + { + KN< HPDDM::upscaled_type< K > > res(this->M, 0.0); + res = GetAny< Kn_ >((*mat)(stack)); + for (int i = 0; i < this->M; ++i) Ax[i] = res[i]; + } + WhereStackOfPtr2Free(stack)->clean( ); + } + plusAx operator*(const Kn& x) const { return plusAx(this, x); } + bool ChecknbLine(int) const { return true; } + bool ChecknbColumn(int) const { return true; } + }; + class MatMatF_O : public RNM_VirtualMatrix< HPDDM::upscaled_type< K > >, public Type::super::CoarseCorrection { + public: + typedef typename Type::super::CoarseCorrection super; + Stack stack; + mutable Kn x; + C_F0 c_x; + mutable long mu; + C_F0 c_mu; + Expression mat; + typedef typename RNM_VirtualMatrix< HPDDM::upscaled_type< K > >::plusAx plusAx; + MatMatF_O(int n, Stack stk, const OneOperator* op) + : RNM_VirtualMatrix< HPDDM::upscaled_type< K > >(n), stack(stk), x(0), c_x(CPValue(x)), mu(1), c_mu(CPValue(mu)), + mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa({c_x, c_mu})), (aType)*op)) : 0) {} + ~MatMatF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + zzz = c_mu; + delete zzz; + } + virtual void operator( )(const K* const in, K* const out) { + mu = 1; + KN_< K > xx(const_cast< K* >(in), this->N); + KN_< K > yy(out, this->N); + addMatMul(xx, yy); + } + virtual void operator( )(const K* const in, K* const out, int n, unsigned short nu) { + mu = nu; + KN_< K > xx(const_cast< K* >(in), this->N * mu); + KN_< K > yy(out, this->N * mu); + addMatMul(xx, yy); + } + void addMatMul(const Kn_& xx, Kn_& Ax) const { + ffassert(xx.N( ) == this->N * mu && Ax.N( ) == this->M * mu); + HPDDM::upscaled_type< K >* backup = x; + x.set(xx, this->N * mu); + Ax = GetAny< Kn_ >((*mat)(stack)); + x.set(backup, 0); + WhereStackOfPtr2Free(stack)->clean( ); + } + template< class T, typename std::enable_if< !std::is_same< T, HPDDM::upscaled_type< T > >::value >::type* = nullptr > + void addMatMul(const KN_< T >& xx, KN_< T >& Ax) const { + ffassert(xx.N( ) == this->N * mu && Ax.N( ) == this->M * mu); + HPDDM::upscaled_type< K >* backup = x; + { + KN< HPDDM::upscaled_type< K > > in(this->N * mu, 0.0); + KN< HPDDM::upscaled_type< K > > res(this->M * mu, 0.0); + x.set(in, this->N * mu); + for (int i = 0; i < this->N * mu; ++i) x[i] = xx[i]; + res = GetAny< Kn_ >((*mat)(stack)); + for (int i = 0; i < this->M * mu; ++i) Ax[i] = res[i]; + x.set(backup, 0); + } + WhereStackOfPtr2Free(stack)->clean( ); + } + plusAx operator*(const Kn& x) const { return plusAx(this, x); } + bool ChecknbLine(int) const { return true; } + bool ChecknbColumn(int) const { return true; } + }; + const int c; + class E_attachCoarseOperator : public E_F0mps { + public: + Expression A; + Expression comm; + const OneOperator* codeC; + const OneOperator* codeMatC; + const int c; + static const int n_name_param = 7; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + E_attachCoarseOperator(const basicAC_F0& args, int d) : A(0), comm(0), codeC(0), codeMatC(0), c(d) { + args.SetNameParam(n_name_param, name_param, nargs); + comm = to< pcommworld >(args[0]); + A = to< Type* >(args[1]); + if (c == 1) { + const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[2].LeftValue( )); + ffassert(op); + codeMatC = op->Find("(", ArrayOfaType(atype< KN< HPDDM::upscaled_type< K > >* >( ), atype< long >( ), false)); + if (!codeMatC) codeC = op->Find("(", ArrayOfaType(atype< KN< HPDDM::upscaled_type< K > >* >( ), false)); + } + } - AnyType operator()(Stack stack) const; - operator aType() const { return atype(); } - }; - E_F0* code(const basicAC_F0 & args) const { return new E_attachCoarseOperator(args, c); } - attachCoarseOperator() : OneOperator(atype(), atype(), atype()), c(0) { } - attachCoarseOperator(int) : OneOperator(atype(), atype(), atype(), atype()), c(1) { } -}; -template -basicAC_F0::name_and_type attachCoarseOperator::E_attachCoarseOperator::name_param[] = { - {"A", &typeid(Matrice_Creuse>*)}, - {"B", &typeid(Matrice_Creuse>*)}, - {"pattern", &typeid(Matrice_Creuse>*)}, - {"threshold", &typeid(HPDDM::underlying_type>)}, - {"timing", &typeid(KN*)}, - {"ret", &typeid(Pair*)}, - {"deflation", &typeid(FEbaseArrayKn>*)} -}; -template -AnyType attachCoarseOperator::E_attachCoarseOperator::operator()(Stack stack) const { - pcommworld ptComm = GetAny((*comm)(stack)); + AnyType operator( )(Stack stack) const; + operator aType( ) const { return atype< long >( ); } + }; + E_F0* code(const basicAC_F0& args) const { return new E_attachCoarseOperator(args, c); } + attachCoarseOperator( ) : OneOperator(atype< long >( ), atype< pcommworld >( ), atype< Type* >( )), c(0) {} + attachCoarseOperator(int) : OneOperator(atype< long >( ), atype< pcommworld >( ), atype< Type* >( ), atype< Polymorphic* >( )), c(1) {} + }; + template< class Type, class K > + basicAC_F0::name_and_type attachCoarseOperator< Type, K >::E_attachCoarseOperator::name_param[] = {{"A", &typeid(Matrice_Creuse< HPDDM::upscaled_type< K > >*)}, + {"B", &typeid(Matrice_Creuse< HPDDM::upscaled_type< K > >*)}, + {"pattern", &typeid(Matrice_Creuse< HPDDM::upscaled_type< K > >*)}, + {"threshold", &typeid(HPDDM::underlying_type< HPDDM::upscaled_type< K > >)}, + {"timing", &typeid(KN< double >*)}, + {"ret", &typeid(Pair< K >*)}, + {"deflation", &typeid(FEbaseArrayKn< HPDDM::upscaled_type< K > >*)}}; + template< class Type, class K > + AnyType attachCoarseOperator< Type, K >::E_attachCoarseOperator::operator( )(Stack stack) const { + pcommworld ptComm = GetAny< pcommworld >((*comm)(stack)); MPI_Comm comm = *(MPI_Comm*)ptComm; - Type* ptA = GetAny((*A)(stack)); - if(ptA->HPDDM_cc) { - delete ptA->HPDDM_cc; - ptA->HPDDM_cc = nullptr; + Type* ptA = GetAny< Type* >((*A)(stack)); + if (ptA->HPDDM_cc) { + delete ptA->HPDDM_cc; + ptA->HPDDM_cc = nullptr; } - if(c == 0) { - MatriceMorse>* mA = nargs[0] ? static_cast>*>(&(*GetAny>*>((*nargs[0])(stack))->A)) : 0; - Pair* pair = nargs[5] ? GetAny*>((*nargs[5])(stack)) : 0; - FEbaseArrayKn>* deflation = nargs[6] ? GetAny>*>((*nargs[6])(stack)) : 0; - HPDDM::Option& opt = *HPDDM::Option::get(); - KN* timing = nargs[4] ? GetAny*>((*nargs[4])(stack)) : 0; - std::pair* ret = nullptr; - if(mA) { - ff_HPDDM_MatrixCSR dA(mA);//->n, mA->m, mA->nbcoef, mA->a, mA->lg, mA->cl, mA->symetrique); - MatriceMorse>* mB = nargs[1] ? static_cast>*>(&(*GetAny>*>((*nargs[1])(stack))->A)) : nullptr; - MatriceMorse>* mP = nargs[2] && opt.any_of("schwarz_method", { 1, 2, 4 }) ? static_cast>*>(&(*GetAny>*>((*nargs[2])(stack))->A)) : nullptr; - if(dA.HPDDM_n == dA.HPDDM_m && !deflation) { - if(timing) { // tic - timing->resize(timing->n + 1); - (*timing)[timing->n - 1] = MPI_Wtime(); - } - const HPDDM::MatrixCSR* const dP = new_HPDDM_MatrixCSR(mP); + if (c == 0) { + MatriceMorse< HPDDM::upscaled_type< K > >* mA = + nargs[0] ? static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*nargs[0])(stack))->A)) : 0; + Pair< K >* pair = nargs[5] ? GetAny< Pair< K >* >((*nargs[5])(stack)) : 0; + FEbaseArrayKn< HPDDM::upscaled_type< K > >* deflation = nargs[6] ? GetAny< FEbaseArrayKn< HPDDM::upscaled_type< K > >* >((*nargs[6])(stack)) : 0; + HPDDM::Option& opt = *HPDDM::Option::get( ); + KN< double >* timing = nargs[4] ? GetAny< KN< double >* >((*nargs[4])(stack)) : 0; + std::pair< MPI_Request, const K* >* ret = nullptr; + if (mA) { + ff_HPDDM_MatrixCSR< K > dA(mA); //->n, mA->m, mA->nbcoef, mA->a, mA->lg, mA->cl, mA->symetrique); + MatriceMorse< HPDDM::upscaled_type< K > >* mB = + nargs[1] ? static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*nargs[1])(stack))->A)) : nullptr; + MatriceMorse< HPDDM::upscaled_type< K > >* mP = nargs[2] && opt.any_of("schwarz_method", {1, 2, 4}) + ? static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*nargs[2])(stack))->A)) + : nullptr; + if (dA.HPDDM_n == dA.HPDDM_m && !deflation) { + if (timing) { // tic + timing->resize(timing->n + 1); + (*timing)[timing->n - 1] = MPI_Wtime( ); + } + const HPDDM::MatrixCSR< K >* const dP = new_HPDDM_MatrixCSR< K >(mP); #ifdef EIGENSOLVER - if(mB) { - ff_HPDDM_MatrixCSR dB(mB); - ptA->template solveGEVP(&dA, &dB, dP); - } - else - ptA->template solveGEVP(&dA, nullptr, dP); + if (mB) { + ff_HPDDM_MatrixCSR< K > dB(mB); + ptA->template solveGEVP< EIGENSOLVER >(&dA, &dB, dP); + } else + ptA->template solveGEVP< EIGENSOLVER >(&dA, nullptr, dP); #endif - if(mP) - set_ff_matrix(mA, dA); - delete dP; - if(timing) { // toc - (*timing)[timing->n - 1] = MPI_Wtime() - (*timing)[timing->n - 1]; - } - } - else if(deflation && deflation->N > 0 && !ptA->getVectors()) { - K** ev = new K*[deflation->N]; - *ev = new K[deflation->N * deflation->get(0)->n]; - for(int i = 0; i < deflation->N; ++i) { - ev[i] = *ev + i * deflation->get(0)->n; - std::copy_n(&(*deflation->get(i))[0], deflation->get(i)->n, ev[i]); - } - ptA->setVectors(ev); - ptA->Type::super::initialize(deflation->N); - } - if(timing) { // tic - MPI_Barrier(comm); - timing->resize(timing->n + 1); - (*timing)[timing->n - 1] = MPI_Wtime(); - } - if(ptA->exclusion(comm)) { - if(pair) - pair->p = ptA->template buildTwo<1>(comm, &dA); - else - ret = ptA->template buildTwo<1>(comm, &dA); - } - else { - if(pair) - pair->p = ptA->template buildTwo<0>(comm, &dA); - else - ret = ptA->template buildTwo<0>(comm, &dA); - } - if(timing) { // toc - (*timing)[timing->n - 1] = MPI_Wtime() - (*timing)[timing->n - 1]; - } + if (mP) set_ff_matrix(mA, dA); + delete dP; + if (timing) { // toc + (*timing)[timing->n - 1] = MPI_Wtime( ) - (*timing)[timing->n - 1]; + } + } else if (deflation && deflation->N > 0 && !ptA->getVectors( )) { + K** ev = new K*[deflation->N]; + *ev = new K[deflation->N * deflation->get(0)->n]; + for (int i = 0; i < deflation->N; ++i) { + ev[i] = *ev + i * deflation->get(0)->n; + std::copy_n(&(*deflation->get(i))[0], deflation->get(i)->n, ev[i]); + } + ptA->setVectors(ev); + ptA->Type::super::initialize(deflation->N); } - else { - if(timing) - MPI_Barrier(comm); - if(!ptA->getVectors()) - ret = ptA->template buildTwo<2>(comm); - else if(ptA->exclusion(comm)) - ret = ptA->template buildTwo<1>(comm); - else - ret = ptA->template buildTwo<0>(comm); + if (timing) { // tic + MPI_Barrier(comm); + timing->resize(timing->n + 1); + (*timing)[timing->n - 1] = MPI_Wtime( ); } - if(ret) - delete ret; - return 0L; - } - else { - if(codeMatC) - ptA->HPDDM_cc = new attachCoarseOperator::MatMatF_O(ptA->getDof(), stack, codeMatC); - else if(codeC) - ptA->HPDDM_cc = new attachCoarseOperator::MatF_O(ptA->getDof(), stack, codeC); + if (ptA->exclusion(comm)) { + if (pair) + pair->p = ptA->template buildTwo< 1 >(comm, &dA); + else + ret = ptA->template buildTwo< 1 >(comm, &dA); + } else { + if (pair) + pair->p = ptA->template buildTwo< 0 >(comm, &dA); + else + ret = ptA->template buildTwo< 0 >(comm, &dA); + } + if (timing) { // toc + (*timing)[timing->n - 1] = MPI_Wtime( ) - (*timing)[timing->n - 1]; + } + } else { + if (timing) MPI_Barrier(comm); + if (!ptA->getVectors( )) + ret = ptA->template buildTwo< 2 >(comm); + else if (ptA->exclusion(comm)) + ret = ptA->template buildTwo< 1 >(comm); else - ffassert(0); - return 0L; + ret = ptA->template buildTwo< 0 >(comm); + } + if (ret) delete ret; + return 0L; + } else { + if (codeMatC) + ptA->HPDDM_cc = new attachCoarseOperator< Type, K >::MatMatF_O(ptA->getDof( ), stack, codeMatC); + else if (codeC) + ptA->HPDDM_cc = new attachCoarseOperator< Type, K >::MatF_O(ptA->getDof( ), stack, codeC); + else + ffassert(0); + return 0L; } -} + } -template -class solveDDM_Op : public E_F0mps { - public: - Expression A; - Expression rhs; - Expression x; - static const int n_name_param = 5; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - solveDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), rhs(param2), x(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class solveDDM_Op : public E_F0mps { + public: + Expression A; + Expression rhs; + Expression x; + static const int n_name_param = 5; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + solveDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), rhs(param2), x(param3) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type solveDDM_Op::name_param[] = { - {"timing", &typeid(KN*)}, - {"excluded", &typeid(bool)}, - {"ret", &typeid(Pair*)}, - {"O", &typeid(Matrice_Creuse>*)}, - {"communicator", &typeid(pcommworld)} -}; -template -class solveDDM : public OneOperator { - public: - solveDDM() : OneOperator(atype(), atype(), atype>*>(), atype>*>()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type solveDDM_Op< Type, K >::name_param[] = { + {"timing", &typeid(KN< double >*)}, {"excluded", &typeid(bool)}, {"ret", &typeid(Pair< K >*)}, {"O", &typeid(Matrice_Creuse< HPDDM::upscaled_type< K > >*)}, {"communicator", &typeid(pcommworld)}}; + template< class Type, class K > + class solveDDM : public OneOperator { + public: + solveDDM( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< HPDDM::upscaled_type< K > >* >( ), atype< KN< HPDDM::upscaled_type< K > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new solveDDM_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } -}; -template -AnyType solveDDM_Op::operator()(Stack stack) const { - KN>* ptRHS = GetAny>*>((*rhs)(stack)); - KN>* ptX = GetAny>*>((*x)(stack)); - Type* ptA = GetAny((*A)(stack)); - if(ptX->n != ptRHS->n || ptRHS->n < ptA->getDof()) - return 0L; - HPDDM::Option& opt = *HPDDM::Option::get(); - const std::string& prefix = ptA->prefix(); - KN* timing = nargs[0] ? GetAny*>((*nargs[0])(stack)) : 0; - Pair* pair = nargs[2] ? GetAny*>((*nargs[2])(stack)) : 0; - if(opt.set(prefix + "schwarz_coarse_correction") && pair) - if(pair->p) { - int flag; - MPI_Test(&(pair->p->first), &flag, MPI_STATUS_IGNORE); - } - MatriceMorse>* mA = nargs[3] ? static_cast>*>(&(*GetAny>*>((*nargs[3])(stack))->A)) : 0; - unsigned short mu = ptX->n / ptA->getDof(); - MPI_Allreduce(MPI_IN_PLACE, &mu, 1, MPI_UNSIGNED_SHORT, MPI_MAX, ptA->getCommunicator()); - const HPDDM::MatrixCSR* A = ptA->getMatrix(); + E_F0* code(const basicAC_F0& args) const { return new solveDDM_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + }; + template< class Type, class K > + AnyType solveDDM_Op< Type, K >::operator( )(Stack stack) const { + KN< HPDDM::upscaled_type< K > >* ptRHS = GetAny< KN< HPDDM::upscaled_type< K > >* >((*rhs)(stack)); + KN< HPDDM::upscaled_type< K > >* ptX = GetAny< KN< HPDDM::upscaled_type< K > >* >((*x)(stack)); + Type* ptA = GetAny< Type* >((*A)(stack)); + if (ptX->n != ptRHS->n || ptRHS->n < ptA->getDof( )) return 0L; + HPDDM::Option& opt = *HPDDM::Option::get( ); + const std::string& prefix = ptA->prefix( ); + KN< double >* timing = nargs[0] ? GetAny< KN< double >* >((*nargs[0])(stack)) : 0; + Pair< K >* pair = nargs[2] ? GetAny< Pair< K >* >((*nargs[2])(stack)) : 0; + if (opt.set(prefix + "schwarz_coarse_correction") && pair) + if (pair->p) { + int flag; + MPI_Test(&(pair->p->first), &flag, MPI_STATUS_IGNORE); + } + MatriceMorse< HPDDM::upscaled_type< K > >* mA = + nargs[3] ? static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*nargs[3])(stack))->A)) : 0; + unsigned short mu = ptX->n / ptA->getDof( ); + MPI_Allreduce(MPI_IN_PLACE, &mu, 1, MPI_UNSIGNED_SHORT, MPI_MAX, ptA->getCommunicator( )); + const HPDDM::MatrixCSR< K >* A = ptA->getMatrix( ); bool alreadyRenumbered = false; - if(HPDDM::Wrapper::I == 'F' && SUBDOMAIN::HPDDM_numbering == 'F' && mu > 1) { - alreadyRenumbered = true; - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); - } - if(timing) { // tic - timing->resize(timing->n + 1); - (*timing)[timing->n - 1] = MPI_Wtime(); + if (HPDDM::Wrapper< K >::I == 'F' && SUBDOMAIN< K >::HPDDM_numbering == 'F' && mu > 1) { + alreadyRenumbered = true; + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); } - if(mpisize > 1 && (mA && opt.any_of(prefix + "schwarz_method", { 1, 2, 4 }))) { - ff_HPDDM_MatrixCSR dA(mA);//->n, mA->m, mA->nbcoef, mA->a, mA->lg, mA->cl, mA->symetrique); - ptA->callNumfact(&dA); + if (timing) { // tic + timing->resize(timing->n + 1); + (*timing)[timing->n - 1] = MPI_Wtime( ); } - else { - if(!alreadyRenumbered) - ptA->callNumfact(); + if (mpisize > 1 && (mA && opt.any_of(prefix + "schwarz_method", {1, 2, 4}))) { + ff_HPDDM_MatrixCSR< K > dA(mA); //->n, mA->m, mA->nbcoef, mA->a, mA->lg, mA->cl, mA->symetrique); + ptA->callNumfact(&dA); + } else { + if (!alreadyRenumbered) ptA->callNumfact( ); #ifndef SUITESPARSESUB - else - ptA->template callNumfact<'F'>(); + else + ptA->template callNumfact< 'F' >( ); #endif } - if(timing) { // toc - (*timing)[timing->n - 1] = MPI_Wtime() - (*timing)[timing->n - 1]; + if (timing) { // toc + (*timing)[timing->n - 1] = MPI_Wtime( ) - (*timing)[timing->n - 1]; } - if(HPDDM::Wrapper::I == 'F' && SUBDOMAIN::HPDDM_numbering == 'C' && mu > 1) { - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); + if (HPDDM::Wrapper< K >::I == 'F' && SUBDOMAIN< K >::HPDDM_numbering == 'C' && mu > 1) { + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); } - bool excluded = nargs[1] && GetAny((*nargs[1])(stack)); - if(excluded) - opt[prefix + "level_2_exclude"]; - if(pair) - if(pair->p) { - MPI_Wait(&(pair->p->first), MPI_STATUS_IGNORE); - delete [] pair->p->second; - pair->destroy(); - pair = nullptr; - } - MPI_Comm comm = nargs[4] ? *(MPI_Comm*)GetAny((*nargs[4])(stack)) : MPI_COMM_WORLD; + bool excluded = nargs[1] && GetAny< bool >((*nargs[1])(stack)); + if (excluded) opt[prefix + "level_2_exclude"]; + if (pair) + if (pair->p) { + MPI_Wait(&(pair->p->first), MPI_STATUS_IGNORE); + delete[] pair->p->second; + pair->destroy( ); + pair = nullptr; + } + MPI_Comm comm = nargs[4] ? *(MPI_Comm*)GetAny< pcommworld >((*nargs[4])(stack)) : MPI_COMM_WORLD; int rank; - MPI_Comm_rank(ptA->getCommunicator(), &rank); - if(rank != mpirank || rank != 0) { - opt.remove("verbosity"); - if(prefix.size() > 0) - opt.remove(prefix + "verbosity"); + MPI_Comm_rank(ptA->getCommunicator( ), &rank); + if (rank != mpirank || rank != 0) { + opt.remove("verbosity"); + if (prefix.size( ) > 0) opt.remove(prefix + "verbosity"); } double timer; - if(timing) { // tic - MPI_Barrier(comm); - timer = MPI_Wtime(); - timing->resize(timing->n + 1); - (*timing)[timing->n - 1] = timer; + if (timing) { // tic + MPI_Barrier(comm); + timer = MPI_Wtime( ); + timing->resize(timing->n + 1); + (*timing)[timing->n - 1] = timer; } - if(!excluded) { - const auto& map = ptA->getMap(); - bool allocate = map.size() > 0 && ptA->getBuffer()[0] == nullptr ? ptA->setBuffer() : false; - K* rhs = reinterpret_cast(ptRHS->operator HPDDM::upscaled_type*()); - K* x = reinterpret_cast(ptX->operator HPDDM::upscaled_type*()); - if(!std::is_same, K>::value) { - for(int i = 0; i < ptRHS->n; ++i) { - rhs[i] = ptRHS->operator[](i); - x[i] = ptX->operator[](i); - } + if (!excluded) { + const auto& map = ptA->getMap( ); + bool allocate = map.size( ) > 0 && ptA->getBuffer( )[0] == nullptr ? ptA->setBuffer( ) : false; + K* rhs = reinterpret_cast< K* >(ptRHS->operator HPDDM::upscaled_type< K >*( )); + K* x = reinterpret_cast< K* >(ptX->operator HPDDM::upscaled_type< K >*( )); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = 0; i < ptRHS->n; ++i) { + rhs[i] = ptRHS->operator[](i); + x[i] = ptX->operator[](i); } - ptA->exchange(rhs, mu); - ptA->clearBuffer(allocate); - HPDDM::IterativeMethod::solve(*ptA, rhs, x, mu, comm); - if(!std::is_same, K>::value) { - for(int i = ptRHS->n - 1; i >= 0; --i) { - ptRHS->operator[](i) = rhs[i]; - ptX->operator[](i) = x[i]; - } + } + ptA->exchange(rhs, mu); + ptA->clearBuffer(allocate); + HPDDM::IterativeMethod::solve(*ptA, rhs, x, mu, comm); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = ptRHS->n - 1; i >= 0; --i) { + ptRHS->operator[](i) = rhs[i]; + ptX->operator[](i) = x[i]; } + } + } else + HPDDM::IterativeMethod::solve< true >(*ptA, (K*)nullptr, (K*)nullptr, mu, comm); + timer = MPI_Wtime( ) - timer; + if (timing) { // toc + (*timing)[timing->n - 1] = timer; } - else - HPDDM::IterativeMethod::solve(*ptA, (K*)nullptr, (K*)nullptr, mu, comm); - timer = MPI_Wtime() - timer; - if(timing) { // toc - (*timing)[timing->n - 1] = timer; - } - if(!excluded && verbosity > 0 && rank == 0) - std::cout << std::scientific << " --- system solved (in " << timer << ")" << std::endl; - if(HPDDM::Wrapper::I == 'F' && mu > 1) { - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { --i; }); - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { --i; }); + if (!excluded && verbosity > 0 && rank == 0) std::cout << std::scientific << " --- system solved (in " << timer << ")" << std::endl; + if (HPDDM::Wrapper< K >::I == 'F' && mu > 1) { + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { --i; }); + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { --i; }); } return 0L; -} + } -template -class changeOperator_Op : public E_F0mps { - public: - Expression A; - Expression mat; - static const int n_name_param = 1; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - changeOperator_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), mat(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class changeOperator_Op : public E_F0mps { + public: + Expression A; + Expression mat; + static const int n_name_param = 1; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + changeOperator_Op(const basicAC_F0& args, Expression param1, Expression param2) : A(param1), mat(param2) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type changeOperator_Op::name_param[] = { - {"scaled", &typeid(bool)} -}; -template -class changeOperator : public OneOperator { - public: - changeOperator() : OneOperator(atype(), atype(), atype>*>()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type changeOperator_Op< Type, K >::name_param[] = {{"scaled", &typeid(bool)}}; + template< class Type, class K > + class changeOperator : public OneOperator { + public: + changeOperator( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Matrice_Creuse< HPDDM::upscaled_type< K > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new changeOperator_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } -}; -template -AnyType changeOperator_Op::operator()(Stack stack) const { - MatriceMorse>* mN = static_cast>*>(&(*GetAny>*>((*mat)(stack))->A)); - HPDDM::MatrixCSR* dN = new_HPDDM_MatrixCSR(mN); - Type* ptA = GetAny((*A)(stack)); + E_F0* code(const basicAC_F0& args) const { return new changeOperator_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } + }; + template< class Type, class K > + AnyType changeOperator_Op< Type, K >::operator( )(Stack stack) const { + MatriceMorse< HPDDM::upscaled_type< K > >* mN = static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*mat)(stack))->A)); + HPDDM::MatrixCSR< K >* dN = new_HPDDM_MatrixCSR< K >(mN); + Type* ptA = GetAny< Type* >((*A)(stack)); ptA->setMatrix(dN); - if(!nargs[0] || GetAny((*nargs[0])(stack))) - ptA->exchange(); + if (!nargs[0] || GetAny< bool >((*nargs[0])(stack))) ptA->exchange( ); return 0L; -} + } -template -class set_Op : public E_F0mps { - public: - Expression A; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - set_Op(const basicAC_F0& args, Expression param) : A(param) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class set_Op : public E_F0mps { + public: + Expression A; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + set_Op(const basicAC_F0& args, Expression param) : A(param) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type set_Op::name_param[] = { - {"sparams", &typeid(string*)}, - {"prefix", &typeid(string*)} -}; -template -class set : public OneOperator { - public: - set() : OneOperator(atype(), atype()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type set_Op< Type, K >::name_param[] = {{"sparams", &typeid(string*)}, {"prefix", &typeid(string*)}}; + template< class Type, class K > + class set : public OneOperator { + public: + set( ) : OneOperator(atype< long >( ), atype< Type* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new set_Op(args, t[0]->CastTo(args[0])); - } -}; -template -AnyType set_Op::operator()(Stack stack) const { - if(nargs[0]) { - HPDDM::Option::get()->parse(*(GetAny((*nargs[0])(stack)))); + E_F0* code(const basicAC_F0& args) const { return new set_Op< Type, K >(args, t[0]->CastTo(args[0])); } + }; + template< class Type, class K > + AnyType set_Op< Type, K >::operator( )(Stack stack) const { + if (nargs[0]) { + HPDDM::Option::get( )->parse(*(GetAny< string* >((*nargs[0])(stack)))); #ifdef PETSCSUB - PetscOptionsInsertString(NULL, (GetAny((*nargs[0])(stack)))->c_str()); + PetscOptionsInsertString(NULL, (GetAny< string* >((*nargs[0])(stack)))->c_str( )); #endif } - if(nargs[1]) { - Type* ptA = GetAny((*A)(stack)); - ptA->setPrefix(*(GetAny((*nargs[1])(stack)))); + if (nargs[1]) { + Type* ptA = GetAny< Type* >((*A)(stack)); + ptA->setPrefix(*(GetAny< string* >((*nargs[1])(stack)))); } return 0L; -} + } -template -class distributedMV_Op : public E_F0mps { - public: - Expression A; - Expression Mat; - Expression in; - Expression out; - static const int n_name_param = 0; - distributedMV_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3, Expression param4) : A(param1), Mat(param2), in(param3), out(param4) { - args.SetNameParam(n_name_param, nullptr, nullptr); - } + template< class Type, class K > + class distributedMV_Op : public E_F0mps { + public: + Expression A; + Expression Mat; + Expression in; + Expression out; + static const int n_name_param = 0; + distributedMV_Op< Type, K >(const basicAC_F0& args, Expression param1, Expression param2, Expression param3, Expression param4) : A(param1), Mat(param2), in(param3), out(param4) { + args.SetNameParam(n_name_param, nullptr, nullptr); + } - AnyType operator()(Stack stack) const; -}; -template -class distributedMV : public OneOperator { - public: - distributedMV() : OneOperator(atype(), atype(), atype>*>(), atype>*>(), atype>*>()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + class distributedMV : public OneOperator { + public: + distributedMV( ) + : OneOperator(atype< long >( ), atype< Type* >( ), atype< Matrice_Creuse< HPDDM::upscaled_type< K > >* >( ), atype< KN< HPDDM::upscaled_type< K > >* >( ), + atype< KN< HPDDM::upscaled_type< K > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new distributedMV_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); - } -}; -template -AnyType distributedMV_Op::operator()(Stack stack) const { - Type* pA = GetAny((*A)(stack)); - KN>* pin = GetAny>*>((*in)(stack)); - KN>* pout = GetAny>*>((*out)(stack)); + E_F0* code(const basicAC_F0& args) const { return new distributedMV_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } + }; + template< class Type, class K > + AnyType distributedMV_Op< Type, K >::operator( )(Stack stack) const { + Type* pA = GetAny< Type* >((*A)(stack)); + KN< HPDDM::upscaled_type< K > >* pin = GetAny< KN< HPDDM::upscaled_type< K > >* >((*in)(stack)); + KN< HPDDM::upscaled_type< K > >* pout = GetAny< KN< HPDDM::upscaled_type< K > >* >((*out)(stack)); pout->resize(pin->n); - unsigned short mu = pin->n / pA->getDof(); - MatriceMorse>* mA = static_cast>*>(&(*GetAny>*>((*Mat)(stack))->A)); - ff_HPDDM_MatrixCSR dA(mA); - bool allocate = pA->setBuffer(); - K* in = reinterpret_cast(pin->operator HPDDM::upscaled_type*()); - K* out = reinterpret_cast(pout->operator HPDDM::upscaled_type*()); - if(!std::is_same, K>::value) { - for(int i = 0; i < pin->n; ++i) { - in[i] = pin->operator[](i); - out[i] = pout->operator[](i); - } + unsigned short mu = pin->n / pA->getDof( ); + MatriceMorse< HPDDM::upscaled_type< K > >* mA = static_cast< MatriceMorse< HPDDM::upscaled_type< K > >* >(&(*GetAny< Matrice_Creuse< HPDDM::upscaled_type< K > >* >((*Mat)(stack))->A)); + ff_HPDDM_MatrixCSR< K > dA(mA); + bool allocate = pA->setBuffer( ); + K* in = reinterpret_cast< K* >(pin->operator HPDDM::upscaled_type< K >*( )); + K* out = reinterpret_cast< K* >(pout->operator HPDDM::upscaled_type< K >*( )); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = 0; i < pin->n; ++i) { + in[i] = pin->operator[](i); + out[i] = pout->operator[](i); + } } pA->GMV(in, out, mu, &dA); - if(!std::is_same, K>::value) { - for(int i = pin->n - 1; i >= 0; --i) { - pin->operator[](i) = in[i]; - pout->operator[](i) = out[i]; - } + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = pin->n - 1; i >= 0; --i) { + pin->operator[](i) = in[i]; + pout->operator[](i) = out[i]; + } } pA->clearBuffer(allocate); return 0L; -} + } -template -class ProdSchwarz { - public: - const T t; - const U u; - ProdSchwarz(T v, U w) : t(v), u(w) {} - void prod(U x) const { - bool allocate = t->setBuffer(); - K* in = reinterpret_cast(u->operator HPDDM::upscaled_type*()); - K* out = reinterpret_cast(x->operator HPDDM::upscaled_type*()); - if(!std::is_same, K>::value) { - for(int i = 0; i < x->n; ++i) { - in[i] = this->u->operator[](i); - out[i] = x->operator[](i); - } - } - t->GMV(in, out); - if(!std::is_same, K>::value) { - for(int i = x->n - 1; i >= 0; --i) { - this->u->operator[](i) = in[i]; - x->operator[](i) = out[i]; - } - } - t->clearBuffer(allocate); - }; - static U mv(U Ax, ProdSchwarz A) { - *Ax = K(); - A.prod(Ax); - return Ax; + template< class T, class U, class K, char N > + class ProdSchwarz { + public: + const T t; + const U u; + ProdSchwarz(T v, U w) : t(v), u(w) {} + void prod(U x) const { + bool allocate = t->setBuffer( ); + K* in = reinterpret_cast< K* >(u->operator HPDDM::upscaled_type< K >*( )); + K* out = reinterpret_cast< K* >(x->operator HPDDM::upscaled_type< K >*( )); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = 0; i < x->n; ++i) { + in[i] = this->u->operator[](i); + out[i] = x->operator[](i); } - static U init(U Ax, ProdSchwarz A) { - Ax->init(A.u->n); - return mv(Ax, A); + } + t->GMV(in, out); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = x->n - 1; i >= 0; --i) { + this->u->operator[](i) = in[i]; + x->operator[](i) = out[i]; } -}; + } + t->clearBuffer(allocate); + }; + static U mv(U Ax, ProdSchwarz< T, U, K, N > A) { + *Ax = K( ); + A.prod(Ax); + return Ax; + } + static U init(U Ax, ProdSchwarz< T, U, K, N > A) { + Ax->init(A.u->n); + return mv(Ax, A); + } + }; -template -class InvSchwarz { - public: - const T t; - const U u; - InvSchwarz(T v, U w) : t(v), u(w) {} - void solve(U out) const { - if(out->n != u->n || u->n < (*t).getDof()) - return; - unsigned short mu = u->n / (*t).getDof(); - MPI_Allreduce(MPI_IN_PLACE, &mu, 1, MPI_UNSIGNED_SHORT, MPI_MAX, (*t).getCommunicator()); - const HPDDM::MatrixCSR* A = (*t).getMatrix(); - bool alreadyRenumbered = false; - if(HPDDM::Wrapper::I == 'F' && SUBDOMAIN::HPDDM_numbering == 'F' && mu > 1) { - alreadyRenumbered = true; - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); - } - if(!alreadyRenumbered) - (*t).callNumfact(); + template< class T, class U, class K, char trans > + class InvSchwarz { + public: + const T t; + const U u; + InvSchwarz(T v, U w) : t(v), u(w) {} + void solve(U out) const { + if (out->n != u->n || u->n < (*t).getDof( )) return; + unsigned short mu = u->n / (*t).getDof( ); + MPI_Allreduce(MPI_IN_PLACE, &mu, 1, MPI_UNSIGNED_SHORT, MPI_MAX, (*t).getCommunicator( )); + const HPDDM::MatrixCSR< K >* A = (*t).getMatrix( ); + bool alreadyRenumbered = false; + if (HPDDM::Wrapper< K >::I == 'F' && SUBDOMAIN< K >::HPDDM_numbering == 'F' && mu > 1) { + alreadyRenumbered = true; + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); + } + if (!alreadyRenumbered) (*t).callNumfact( ); #ifndef SUITESPARSESUB - else - (*t).template callNumfact<'F'>(); + else + (*t).template callNumfact< 'F' >( ); #endif - if(HPDDM::Wrapper::I == 'F' && SUBDOMAIN::HPDDM_numbering == 'C' && mu > 1) { - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); - } - if(mpirank != 0) - HPDDM::Option::get()->remove((*t).prefix("verbosity")); - const auto& map = (*t).getMap(); - bool allocate = map.size() > 0 && (*t).getBuffer()[0] == nullptr ? (*t).setBuffer() : false; - K* rhs = reinterpret_cast(u->operator HPDDM::upscaled_type*()); - K* x = reinterpret_cast(out->operator HPDDM::upscaled_type*()); - if(!std::is_same, K>::value) { - for(int i = 0; i < u->n; ++i) { - rhs[i] = u->operator[](i); - x[i] = out->operator[](i); - } - } - (*t).exchange(rhs, mu); - (*t).clearBuffer(allocate); - HPDDM::IterativeMethod::solve(*t, rhs, x, mu, MPI_COMM_WORLD); - if(!std::is_same, K>::value) { - for(int i = u->n - 1; i >= 0; --i) { - u->operator[](i) = rhs[i]; - out->operator[](i) = x[i]; - } - } - if(HPDDM::Wrapper::I == 'F' && mu > 1) { - std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { --i; }); - std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { --i; }); - } - } - static U inv(U Ax, InvSchwarz A) { - A.solve(Ax); - return Ax; + if (HPDDM::Wrapper< K >::I == 'F' && SUBDOMAIN< K >::HPDDM_numbering == 'C' && mu > 1) { + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { ++i; }); + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { ++i; }); + } + if (mpirank != 0) HPDDM::Option::get( )->remove((*t).prefix("verbosity")); + const auto& map = (*t).getMap( ); + bool allocate = map.size( ) > 0 && (*t).getBuffer( )[0] == nullptr ? (*t).setBuffer( ) : false; + K* rhs = reinterpret_cast< K* >(u->operator HPDDM::upscaled_type< K >*( )); + K* x = reinterpret_cast< K* >(out->operator HPDDM::upscaled_type< K >*( )); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = 0; i < u->n; ++i) { + rhs[i] = u->operator[](i); + x[i] = out->operator[](i); } - static U init(U Ax, InvSchwarz A) { - Ax->init(A.u->n); - return inv(Ax, A); + } + (*t).exchange(rhs, mu); + (*t).clearBuffer(allocate); + HPDDM::IterativeMethod::solve(*t, rhs, x, mu, MPI_COMM_WORLD); + if (!std::is_same< HPDDM::upscaled_type< K >, K >::value) { + for (int i = u->n - 1; i >= 0; --i) { + u->operator[](i) = rhs[i]; + out->operator[](i) = x[i]; } -}; + } + if (HPDDM::Wrapper< K >::I == 'F' && mu > 1) { + std::for_each(A->HPDDM_ja, A->HPDDM_ja + A->HPDDM_nnz, [](int& i) { --i; }); + std::for_each(A->HPDDM_ia, A->HPDDM_ia + A->HPDDM_n + 1, [](int& i) { --i; }); + } + } + static U inv(U Ax, InvSchwarz< T, U, K, trans > A) { + A.solve(Ax); + return Ax; + } + static U init(U Ax, InvSchwarz< T, U, K, trans > A) { + Ax->init(A.u->n); + return inv(Ax, A); + } + }; -template -class IterativeMethod : public OneOperator { - public: - const int c; - typedef KN Kn; - typedef KN_ Kn_; - class MatF_O : RNM_VirtualMatrix { - public: - Stack stack; - mutable Kn x; - C_F0 c_x; - Expression mat; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - MatF_O(int n, Stack stk, const OneOperator* op) : - RNM_VirtualMatrix(n), stack(stk), x(n), c_x(CPValue(x)), - mat(op ? CastTo(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) { } - ~MatF_O() { - delete mat; - Expression zzz = c_x; - delete zzz; - } - void addMatMul(const Kn_& xx, Kn_& Ax) const { - ffassert(xx.N() == Ax.N()); - x = xx; - Ax += GetAny((*mat)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - } - void mv(const R* const in, const int& n, const int& m, R* const out) const { - ffassert(m == 1); - KN_ xx(const_cast(in), n); - KN_ yy(out, n); - yy = R(); - addMatMul(xx,yy); - } - bool ChecknbLine(int) const { return true; } - bool ChecknbColumn(int) const { return true; } - }; - class MatMatF_O : RNM_VirtualMatrix { - public: - Stack stack; - mutable KNM x; - C_F0 c_x; - Expression mat; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - MatMatF_O(int n, int m, Stack stk, const OneOperator* op) : - RNM_VirtualMatrix(n), stack(stk), x(n, m), c_x(CPValue(x)), - mat(op ? CastTo>(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) /* */ { } - ~MatMatF_O() { - delete mat; - Expression zzz = c_x; - delete zzz; - } - void addMatMul(const KN_& xx, KN_& Ax) const { } - void addMatMul(const KNM_& xx, KNM_& Ax) const { - ffassert(xx.N() == Ax.N()); - ffassert(xx.M() == Ax.M()); - x.resize(xx.N(), xx.M()); - x = xx; - Ax = GetAny>((*mat)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - } - void mv(const R* const in, const int& n, const int& m, R* const out) const { - KNM_ xx(const_cast(in), n, m); - KNM_ yy(out, n, m); - yy = R(); - addMatMul(xx,yy); - } - bool ChecknbLine(int) const { return true; } - bool ChecknbColumn(int) const { return true; } - }; - template - class Operator : public HPDDM::EmptyOperator { - public: - Op& mat; - Op& prec; - Operator(Op& m, Op& p) : HPDDM::EmptyOperator(m.x.N()), mat(m), prec(p) { } - int GMV(const R* const in, R* const out, const int& mu = 1) const { - mat.mv(in, HPDDM::EmptyOperator::HPDDM_n, mu, out); - return 0; - } - template - int apply(const R* const in, R* const out, const unsigned short& mu = 1, R* = nullptr, const unsigned short& = 0) const { - if(prec.mat) - prec.mv(in, HPDDM::EmptyOperator::HPDDM_n, mu, out); - else - std::copy_n(in, HPDDM::EmptyOperator::HPDDM_n * mu, out); - return 0; - } - }; - template - class SchwarzOperator : public HpSchwarz { - public: - Op& prec; - SchwarzOperator(HpSchwarz* m, Op& p) : prec(p) { *reinterpret_cast*>(this) = *m; } - template - int apply(const R* const in, R* const out, const unsigned short& mu = 1, R* = nullptr, const unsigned short& = 0) const { - if(prec.mat) - prec.mv(in, HPDDM::Subdomain::HPDDM_dof, mu, out); - else - std::copy_n(in, HPDDM::Subdomain::HPDDM_dof * mu, out); - return 0; - } - }; - class E_LCG : public E_F0mps { - public: - static const int n_name_param = 4; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - const OneOperator *A, *C; - Expression Op; - Expression B, X; - const int c; - E_LCG(const basicAC_F0& args, int d) : Op(0), c(d) { - args.SetNameParam(n_name_param, name_param, nargs); - if(c == 0 || c == 2) { - const Polymorphic* op = dynamic_cast(args[0].LeftValue()); - ffassert(op); - A = (c == 0 || c == 1 ? op->Find("(", ArrayOfaType(atype(), false)) : op->Find("(", ArrayOfaType(atype*>(), false))); - } - else { - Op = to*>(args[0]); - } - if(nargs[0]) { - const Polymorphic* op = dynamic_cast(nargs[0]); - ffassert(op); - C = (c == 0 || c == 1 ? op->Find("(", ArrayOfaType(atype(), false)) : op->Find("(", ArrayOfaType(atype*>(), false))); - } - else - C = 0; - if(c == 0 || c == 1) { - B = to(args[1]); - X = to(args[2]); - } - else { - B = to*>(args[1]); - X = to*>(args[2]); - } - } - virtual AnyType operator()(Stack stack) const { - int ret = -1; - try { - MPI_Comm comm = nargs[3] ? *(MPI_Comm*)GetAny((*nargs[3])(stack)) : MPI_COMM_WORLD; - if(nargs[2]) - HPDDM::Option::get()->parse(*(GetAny((*nargs[2])(stack)))); - if(c == 0 || c == 1) { - Kn& x = *GetAny((*X)(stack)); - int n = x.N(); - Kn& b = *GetAny((*B)(stack)); - MatF_O PP(n, stack, C); - if(c == 0) { - MatF_O AA(n, stack, A); - Operator Op(AA, PP); - if(nargs[1]) - Op.setPrefix(*(GetAny((*nargs[1])(stack)))); - ret = HPDDM::IterativeMethod::solve(Op, b.operator R*(), x.operator R*(), 1, comm); - } - else { - HpSchwarz* op = GetAny*>((*Op)(stack)); - SchwarzOperator SchwarzOp(op, PP); - ret = HPDDM::IterativeMethod::solve(SchwarzOp, b.operator R*(), x.operator R*(), 1, comm); - } - } - else { - KNM& x = *GetAny*>((*X)(stack)); - int n = x.N(); - int m = x.M(); - KNM& b = *GetAny*>((*B)(stack)); - MatMatF_O PP(n, m, stack, C); - if(c == 2) { - MatMatF_O AA(n, m, stack, A); - Operator Op(AA, PP); - if(nargs[1]) - Op.setPrefix(*(GetAny((*nargs[1])(stack)))); - ret = HPDDM::IterativeMethod::solve(Op, b.operator R*(), x.operator R*(), m, comm); - } - else { - HpSchwarz* op = GetAny*>((*Op)(stack)); - SchwarzOperator SchwarzOp(op, PP); - ret = HPDDM::IterativeMethod::solve(SchwarzOp, b.operator R*(), x.operator R*(), m, comm); - } - } - } - catch(...) { - throw; - } - return SetAny(ret); - } - operator aType() const { return atype(); } - }; - E_F0* code(const basicAC_F0& args) const { return new E_LCG(args, c); } - IterativeMethod() : OneOperator(atype(), atype(), atype*>(), atype*>()), c(0) { } - IterativeMethod(int) : OneOperator(atype(), atype*>(), atype*>(), atype*>()), c(1) { } - IterativeMethod(int, int) : OneOperator(atype(), atype(), atype*>(), atype*>()), c(2) { } - IterativeMethod(int, int, int) : OneOperator(atype(), atype*>(), atype*>(), atype*>()), c(3) { } -}; + template< class R, char S > + class IterativeMethod : public OneOperator { + public: + const int c; + typedef KN< R > Kn; + typedef KN_< R > Kn_; + class MatF_O : RNM_VirtualMatrix< R > { + public: + Stack stack; + mutable Kn x; + C_F0 c_x; + Expression mat; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + MatF_O(int n, Stack stk, const OneOperator* op) : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} + ~MatF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + } + void addMatMul(const Kn_& xx, Kn_& Ax) const { + ffassert(xx.N( ) == Ax.N( )); + x = xx; + Ax += GetAny< Kn_ >((*mat)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + } + void mv(const R* const in, const int& n, const int& m, R* const out) const { + ffassert(m == 1); + KN_< R > xx(const_cast< R* >(in), n); + KN_< R > yy(out, n); + yy = R( ); + addMatMul(xx, yy); + } + bool ChecknbLine(int) const { return true; } + bool ChecknbColumn(int) const { return true; } + }; + class MatMatF_O : RNM_VirtualMatrix< R > { + public: + Stack stack; + mutable KNM< R > x; + C_F0 c_x; + Expression mat; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + MatMatF_O(int n, int m, Stack stk, const OneOperator* op) + : RNM_VirtualMatrix< R >(n), stack(stk), x(n, m), c_x(CPValue(x)), mat(op ? CastTo< KNM_< R > >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) /* */ {} + ~MatMatF_O( ) { + delete mat; + Expression zzz = c_x; + delete zzz; + } + void addMatMul(const KN_< R >& xx, KN_< R >& Ax) const {} + void addMatMul(const KNM_< R >& xx, KNM_< R >& Ax) const { + ffassert(xx.N( ) == Ax.N( )); + ffassert(xx.M( ) == Ax.M( )); + x.resize(xx.N( ), xx.M( )); + x = xx; + Ax = GetAny< KNM_< R > >((*mat)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + } + void mv(const R* const in, const int& n, const int& m, R* const out) const { + KNM_< R > xx(const_cast< R* >(in), n, m); + KNM_< R > yy(out, n, m); + yy = R( ); + addMatMul(xx, yy); + } + bool ChecknbLine(int) const { return true; } + bool ChecknbColumn(int) const { return true; } + }; + template< class Op > + class Operator : public HPDDM::EmptyOperator< R > { + public: + Op& mat; + Op& prec; + Operator(Op& m, Op& p) : HPDDM::EmptyOperator< R >(m.x.N( )), mat(m), prec(p) {} + int GMV(const R* const in, R* const out, const int& mu = 1) const { + mat.mv(in, HPDDM::EmptyOperator< R >::HPDDM_n, mu, out); + return 0; + } + template< bool > + int apply(const R* const in, R* const out, const unsigned short& mu = 1, R* = nullptr, const unsigned short& = 0) const { + if (prec.mat) + prec.mv(in, HPDDM::EmptyOperator< R >::HPDDM_n, mu, out); + else + std::copy_n(in, HPDDM::EmptyOperator< R >::HPDDM_n * mu, out); + return 0; + } + }; + template< class Op > + class SchwarzOperator : public HpSchwarz< R, S > { + public: + Op& prec; + SchwarzOperator(HpSchwarz< R, S >* m, Op& p) : prec(p) { *reinterpret_cast< HpSchwarz< R, S >* >(this) = *m; } + template< bool > + int apply(const R* const in, R* const out, const unsigned short& mu = 1, R* = nullptr, const unsigned short& = 0) const { + if (prec.mat) + prec.mv(in, HPDDM::Subdomain< R >::HPDDM_dof, mu, out); + else + std::copy_n(in, HPDDM::Subdomain< R >::HPDDM_dof * mu, out); + return 0; + } + }; + class E_LCG : public E_F0mps { + public: + static const int n_name_param = 4; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + const OneOperator *A, *C; + Expression Op; + Expression B, X; + const int c; + E_LCG(const basicAC_F0& args, int d) : Op(0), c(d) { + args.SetNameParam(n_name_param, name_param, nargs); + if (c == 0 || c == 2) { + const Polymorphic* op = dynamic_cast< const Polymorphic* >(args[0].LeftValue( )); + ffassert(op); + A = (c == 0 || c == 1 ? op->Find("(", ArrayOfaType(atype< Kn* >( ), false)) : op->Find("(", ArrayOfaType(atype< KNM< R >* >( ), false))); + } else { + Op = to< HpSchwarz< R, S >* >(args[0]); + } + if (nargs[0]) { + const Polymorphic* op = dynamic_cast< const Polymorphic* >(nargs[0]); + ffassert(op); + C = (c == 0 || c == 1 ? op->Find("(", ArrayOfaType(atype< Kn* >( ), false)) : op->Find("(", ArrayOfaType(atype< KNM< R >* >( ), false))); + } else + C = 0; + if (c == 0 || c == 1) { + B = to< Kn* >(args[1]); + X = to< Kn* >(args[2]); + } else { + B = to< KNM< R >* >(args[1]); + X = to< KNM< R >* >(args[2]); + } + } + virtual AnyType operator( )(Stack stack) const { + int ret = -1; + try { + MPI_Comm comm = nargs[3] ? *(MPI_Comm*)GetAny< pcommworld >((*nargs[3])(stack)) : MPI_COMM_WORLD; + if (nargs[2]) HPDDM::Option::get( )->parse(*(GetAny< string* >((*nargs[2])(stack)))); + if (c == 0 || c == 1) { + Kn& x = *GetAny< Kn* >((*X)(stack)); + int n = x.N( ); + Kn& b = *GetAny< Kn* >((*B)(stack)); + MatF_O PP(n, stack, C); + if (c == 0) { + MatF_O AA(n, stack, A); + Operator< MatF_O > Op(AA, PP); + if (nargs[1]) Op.setPrefix(*(GetAny< string* >((*nargs[1])(stack)))); + ret = HPDDM::IterativeMethod::solve(Op, b.operator R*( ), x.operator R*( ), 1, comm); + } else { + HpSchwarz< R, S >* op = GetAny< HpSchwarz< R, S >* >((*Op)(stack)); + SchwarzOperator< MatF_O > SchwarzOp(op, PP); + ret = HPDDM::IterativeMethod::solve(SchwarzOp, b.operator R*( ), x.operator R*( ), 1, comm); + } + } else { + KNM< R >& x = *GetAny< KNM< R >* >((*X)(stack)); + int n = x.N( ); + int m = x.M( ); + KNM< R >& b = *GetAny< KNM< R >* >((*B)(stack)); + MatMatF_O PP(n, m, stack, C); + if (c == 2) { + MatMatF_O AA(n, m, stack, A); + Operator< MatMatF_O > Op(AA, PP); + if (nargs[1]) Op.setPrefix(*(GetAny< string* >((*nargs[1])(stack)))); + ret = HPDDM::IterativeMethod::solve(Op, b.operator R*( ), x.operator R*( ), m, comm); + } else { + HpSchwarz< R, S >* op = GetAny< HpSchwarz< R, S >* >((*Op)(stack)); + SchwarzOperator< MatMatF_O > SchwarzOp(op, PP); + ret = HPDDM::IterativeMethod::solve(SchwarzOp, b.operator R*( ), x.operator R*( ), m, comm); + } + } + } catch (...) { + throw; + } + return SetAny< long >(ret); + } + operator aType( ) const { return atype< long >( ); } + }; + E_F0* code(const basicAC_F0& args) const { return new E_LCG(args, c); } + IterativeMethod( ) : OneOperator(atype< long >( ), atype< Polymorphic* >( ), atype< KN< R >* >( ), atype< KN< R >* >( )), c(0) {} + IterativeMethod(int) : OneOperator(atype< long >( ), atype< HpSchwarz< R, S >* >( ), atype< KN< R >* >( ), atype< KN< R >* >( )), c(1) {} + IterativeMethod(int, int) : OneOperator(atype< long >( ), atype< Polymorphic* >( ), atype< KNM< R >* >( ), atype< KNM< R >* >( )), c(2) {} + IterativeMethod(int, int, int) : OneOperator(atype< long >( ), atype< HpSchwarz< R, S >* >( ), atype< KNM< R >* >( ), atype< KNM< R >* >( )), c(3) {} + }; -template -basicAC_F0::name_and_type IterativeMethod::E_LCG::name_param[] = { - {"precon", &typeid(Polymorphic*)}, - {"prefix", &typeid(string*)}, - {"sparams", &typeid(string*)}, - {"communicator", &typeid(pcommworld)} -}; + template< class R, char S > + basicAC_F0::name_and_type IterativeMethod< R, S >::E_LCG::name_param[] = { + {"precon", &typeid(Polymorphic*)}, {"prefix", &typeid(string*)}, {"sparams", &typeid(string*)}, {"communicator", &typeid(pcommworld)}}; -template -long globalNumbering(Type* const& A, KN* const& numbering) { - if(A) { - numbering->resize(2 + A->getMatrix()->HPDDM_n); - long long g; - long* num = numbering->operator long*(); - A->distributedNumbering(num + 2, num[0], num[1], g); + template< class Type > + long globalNumbering(Type* const& A, KN< long >* const& numbering) { + if (A) { + numbering->resize(2 + A->getMatrix( )->HPDDM_n); + long long g; + long* num = numbering->operator long*( ); + A->distributedNumbering(num + 2, num[0], num[1], g); } return 0L; -} + } -template -Type* changeOperatorSimple(Type* const& A, Type* const& B) { + template< class Type, class K > + Type* changeOperatorSimple(Type* const& A, Type* const& B) { *A = *B; return A; -} + } -template class Type, class K, char S, char U = S> -void add() { - Dcl_Type*>(Initialize>, DeleteDTOR>); + template< template< class, char > class Type, class K, char S, char U = S > + void add( ) { + Dcl_Type< Type< K, S >* >(Initialize< Type< K, S > >, DeleteDTOR< Type< K, S > >); #if !defined(PETSCSUB) && !defined(MU_SLEPC) - if(std::is_same>::value) + if (std::is_same< K, HPDDM::underlying_type< K > >::value) #endif - zzzfff->Add("schwarz", atype*>()); + zzzfff->Add("schwarz", atype< HpSchwarz< K, S >* >( )); #if !defined(PETSCSUB) && !defined(MU_SLEPC) - map_type_of_map[make_pair(atype, U>*>(), atype*>())] = atype*>(); + map_type_of_map[make_pair(atype< Type< HPDDM::underlying_type< K >, U >* >( ), atype< HPDDM::upscaled_type< K >* >( ))] = atype< Type< K, S >* >( ); #else - map_type_of_map[make_pair(atype*>(), atype*>())] = atype*>(); + map_type_of_map[make_pair(atype< Type< K, U >* >( ), atype< HPDDM::upscaled_type< K >* >( ))] = atype< Type< K, S >* >( ); #endif - TheOperators->Add("<-", new initDDM, K>); - TheOperators->Add("<-", new initDDM, K>(1)); - TheOperators->Add("<-", new initDDM, K>(1, 1)); - TheOperators->Add("<-", new initDDM, K>(1, 1, 1)); + TheOperators->Add("<-", new initDDM< Type< K, S >, K >); + TheOperators->Add("<-", new initDDM< Type< K, S >, K >(1)); + TheOperators->Add("<-", new initDDM< Type< K, S >, K >(1, 1)); + TheOperators->Add("<-", new initDDM< Type< K, S >, K >(1, 1, 1)); Global.Add("constructor", "(", new initDDM< Type< K, S >, K >); Global.Add("constructor", "(", new initDDM< Type< K, S >, K >(1)); Global.Add("constructor", "(", new initDDM< Type< K, S >, K >(1, 1)); Global.Add("constructor", "(", new initDDM< Type< K, S >, K >(1, 1, 1)); - TheOperators->Add("=", new OneOperator2_*, Type*, Type*>(Schwarz::changeOperatorSimple, K>)); - Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator, K>); - Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator, K>(1)); - Global.Add("DDM", "(", new solveDDM, K>); - Global.Add("ChangeOperator", "(", new changeOperator, K>); - Global.Add("set", "(", new set, K>); - addProd, ProdSchwarz, KN>, K>(); - addInv, InvSchwarz, KN>, K>(); - addArray>(); - Global.Add("dmv", "(", new distributedMV, K>); - Global.Add("DestroyRecycling", "(", new OneOperator1_*>(destroyRecycling, K>)); - Global.Add("statistics", "(", new OneOperator1_*>(statistics>)); - Global.Add("exchange", "(", new exchangeIn, K>); - Global.Add("exchange", "(", new exchangeInOut, K>); + TheOperators->Add("=", new OneOperator2_< Type< K, S >*, Type< K, S >*, Type< K, S >* >(Schwarz::changeOperatorSimple< Type< K, S >, K >)); + Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >); + Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >(1)); + Global.Add("DDM", "(", new solveDDM< Type< K, S >, K >); + Global.Add("ChangeOperator", "(", new changeOperator< Type< K, S >, K >); + Global.Add("set", "(", new set< Type< K, S >, K >); + addProd< Type< K, S >, ProdSchwarz, KN< HPDDM::upscaled_type< K > >, K >( ); + addInv< Type< K, S >, InvSchwarz, KN< HPDDM::upscaled_type< K > >, K >( ); + addArray< Type< K, S > >( ); + Global.Add("dmv", "(", new distributedMV< Type< K, S >, K >); + Global.Add("DestroyRecycling", "(", new OneOperator1_< bool, Type< K, S >* >(destroyRecycling< Type< K, S >, K >)); + Global.Add("statistics", "(", new OneOperator1_< bool, Type< K, S >* >(statistics< Type< K, S > >)); + Global.Add("exchange", "(", new exchangeIn< Type< K, S >, K >); + Global.Add("exchange", "(", new exchangeInOut< Type< K, S >, K >); #if !(defined(PETSCSUB) && defined(PETSC_USE_REAL_SINGLE)) - Global.Add("IterativeMethod","(",new IterativeMethod, S>()); - Global.Add("IterativeMethod","(",new IterativeMethod, S>(1, 1)); + Global.Add("IterativeMethod", "(", new IterativeMethod< HPDDM::upscaled_type< K >, S >( )); + Global.Add("IterativeMethod", "(", new IterativeMethod< HPDDM::upscaled_type< K >, S >(1, 1)); #endif - if(std::is_same>::value) { - addScalarProduct< Type, K >( ); + if (std::is_same< K, HPDDM::upscaled_type< K > >::value) { + addScalarProduct< Type< K, S >, K >( ); #if !(defined(PETSCSUB) && defined(PETSC_USE_REAL_SINGLE)) - Global.Add("IterativeMethod","(",new IterativeMethod, S>(1)); - Global.Add("IterativeMethod","(",new IterativeMethod, S>(1, 1, 1)); + Global.Add("IterativeMethod", "(", new IterativeMethod< HPDDM::upscaled_type< K >, S >(1)); + Global.Add("IterativeMethod", "(", new IterativeMethod< HPDDM::upscaled_type< K >, S >(1, 1, 1)); #endif } - Global.Add("GlobalNumbering", "(", new OneOperator2_*, KN*>(globalNumbering>)); + Global.Add("GlobalNumbering", "(", new OneOperator2_< long, Type< K, S >*, KN< long >* >(globalNumbering< Type< K, S > >)); - if(!exist_type*>()) { - Dcl_Type*>(InitP>, Destroy>); + if (!exist_type< Pair< K >* >( )) { + Dcl_Type< Pair< K >* >(InitP< Pair< K > >, Destroy< Pair< K > >); #if !defined(PETSCSUB) && !defined(MU_SLEPC) - map_type_of_map[make_pair(atype>*>(), atype*>())] = atype*>(); + map_type_of_map[make_pair(atype< Pair< HPDDM::underlying_type< K > >* >( ), atype< HPDDM::upscaled_type< K >* >( ))] = atype< Pair< K >* >( ); #else - map_type_of_map[make_pair(atype*>(), atype*>())] = atype*>(); + map_type_of_map[make_pair(atype< Pair< K >* >( ), atype< HPDDM::upscaled_type< K >* >( ))] = atype< Pair< K >* >( ); #endif } aType t; int r; - if(!zzzfff->InMotClef("pair", t, r) && std::is_same>::value) - zzzfff->Add("pair", atype*>()); + if (!zzzfff->InMotClef("pair", t, r) && std::is_same< K, HPDDM::underlying_type< K > >::value) zzzfff->Add("pair", atype< Pair< K >* >( )); #ifdef GENERATE_DEPRECATED_FUNCTIONS - Global.Add("attachCoarseOperator", "(", new attachCoarseOperator, K>); - Global.Add("attachCoarseOperator", "(", new attachCoarseOperator, K>(1)); - Global.Add("changeOperator", "(", new changeOperator, K>); - Global.Add("destroyRecycling", "(", new OneOperator1_*>(destroyRecycling, K>)); - Global.Add("globalNumbering", "(", new OneOperator2_*, KN*>(globalNumbering>)); + Global.Add("attachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >); + Global.Add("attachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >(1)); + Global.Add("changeOperator", "(", new changeOperator< Type< K, S >, K >); + Global.Add("destroyRecycling", "(", new OneOperator1_< bool, Type< K, S >* >(destroyRecycling< Type< K, S >, K >)); + Global.Add("globalNumbering", "(", new OneOperator2_< long, Type< K, S >*, KN< long >* >(globalNumbering< Type< K, S > >)); #endif -} -} + } +} // namespace Schwarz -static void Init_Schwarz() { - Init_Common(); +static void Init_Schwarz( ) { + Init_Common( ); #if defined(DSUITESPARSE) || defined(DHYPRE) || defined(PETSCSUB) - constexpr char ds = 'G'; + constexpr char ds = 'G'; #else - constexpr char ds = 'S'; + constexpr char ds = 'S'; #endif - constexpr char zs = 'G'; + constexpr char zs = 'G'; #if HPDDM_PRECISION == 2 - typedef double real; + typedef double real; #else - typedef float real; + typedef float real; #endif #if !defined(PETSCSUB) && !defined(MU_SLEPC) - Schwarz::add(); + Schwarz::add< HpSchwarz, real, ds >( ); #ifndef DHYPRE - Schwarz::add, zs, ds>(); - // Schwarz::add(); - // Schwarz::add, zs>(); + Schwarz::add< HpSchwarz, std::complex< real >, zs, ds >( ); + // Schwarz::add(); + // Schwarz::add, zs>(); #endif #else - Schwarz::add::value ? ds : zs>(); + Schwarz::add< HpSchwarz, PetscScalar, std::is_same< PetscScalar, PetscReal >::value ? ds : zs >( ); #endif } diff --git a/plugin/mpi/hpddm_substructuring.cpp b/plugin/mpi/hpddm_substructuring.cpp index f4bfcdf9c..38e162fd2 100644 --- a/plugin/mpi/hpddm_substructuring.cpp +++ b/plugin/mpi/hpddm_substructuring.cpp @@ -1,653 +1,577 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: hpddm [mumps parmetis metis ptscotch scotch scalapack mpifc fc|umfpack] [mkl|blas] mpi //ff-c++-cpp-dep: +/* clang-format on */ #define HPDDM_SCHWARZ 0 -#define HPDDM_FETI 1 -#define HPDDM_BDD 1 +#define HPDDM_FETI 1 +#define HPDDM_BDD 1 #include "common_hpddm.hpp" namespace Substructuring { -class Skeleton_Op : public E_F0mps { - public: - Expression interface; - Expression restriction; - Expression outInterface; - static const int n_name_param = 3; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - Skeleton_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : interface(param1), restriction(param2), outInterface(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } - AnyType operator()(Stack stack) const; -}; -basicAC_F0::name_and_type Skeleton_Op::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"interface", &typeid(KN*)}, - {"redundancy", &typeid(bool)} -}; -class Skeleton : public OneOperator { - public: - Skeleton() : OneOperator(atype(), atype*>(), atype >*>(), atype >*>()) {} + class Skeleton_Op : public E_F0mps { + public: + Expression interface; + Expression restriction; + Expression outInterface; + static const int n_name_param = 3; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + Skeleton_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : interface(param1), restriction(param2), outInterface(param3) { + args.SetNameParam(n_name_param, name_param, nargs); + } + AnyType operator( )(Stack stack) const; + }; + basicAC_F0::name_and_type Skeleton_Op::name_param[] = {{"communicator", &typeid(pcommworld)}, {"interface", &typeid(KN< long >*)}, {"redundancy", &typeid(bool)}}; + class Skeleton : public OneOperator { + public: + Skeleton( ) : OneOperator(atype< long >( ), atype< KN< double >* >( ), atype< KN< Matrice_Creuse< double > >* >( ), atype< KN< KN< long > >* >( )) {} - E_F0* code(const basicAC_F0& args) const - { - return new Skeleton_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } -}; -AnyType Skeleton_Op::operator()(Stack stack) const { - KN* in = GetAny*>((*interface)(stack)); - KN >* out = GetAny >*>((*outInterface)(stack)); - KN >* interpolation = GetAny >*>((*restriction)(stack)); - MPI_Comm* comm = nargs[0] ? (MPI_Comm*)GetAny((*nargs[0])(stack)) : 0; + E_F0* code(const basicAC_F0& args) const { return new Skeleton_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + }; + AnyType Skeleton_Op::operator( )(Stack stack) const { + KN< double >* in = GetAny< KN< double >* >((*interface)(stack)); + KN< KN< long > >* out = GetAny< KN< KN< long > >* >((*outInterface)(stack)); + KN< Matrice_Creuse< double > >* interpolation = GetAny< KN< Matrice_Creuse< double > >* >((*restriction)(stack)); + MPI_Comm* comm = nargs[0] ? (MPI_Comm*)GetAny< pcommworld >((*nargs[0])(stack)) : 0; unsigned short n = out->operator[](0).n; MPI_Request* rq = new MPI_Request[2 * n]; - std::vector send(n); - std::vector recv(n); + std::vector< unsigned char* > send(n); + std::vector< unsigned char* > recv(n); unsigned short neighborAfter = 0; - if(out->n != 1 + n) - out->resize(1 + n); - for(unsigned short i = 0; i < n; ++i) { - MatriceMorse* pt = static_cast*>(&(*interpolation->operator[](i).A)); + if (out->n != 1 + n) out->resize(1 + n); + for (unsigned short i = 0; i < n; ++i) { + MatriceMorse< double >* pt = static_cast< MatriceMorse< double >* >(&(*interpolation->operator[](i).A)); #ifdef VERSION_MATRICE_CREUSE - pt->CSR(); + pt->CSR( ); #endif - send[i] = new unsigned char[pt->n]; - recv[i] = new unsigned char[pt->n]; - unsigned int dest = out->operator[](0).operator[](i); - if(dest < mpirank) { - unsigned int col = 0; - for(unsigned int j = 0; j < pt->n; ++j) { + send[i] = new unsigned char[pt->n]; + recv[i] = new unsigned char[pt->n]; + unsigned int dest = out->operator[](0).operator[](i); + if (dest < mpirank) { + unsigned int col = 0; + for (unsigned int j = 0; j < pt->n; ++j) { #ifndef VERSION_MATRICE_CREUSE - if(pt->lg[j + 1] != pt->lg[j]) { - if(std::abs(in->operator[](pt->cl[col++]) - 1.0) < 0.1) + if (pt->lg[j + 1] != pt->lg[j]) { + if (std::abs(in->operator[](pt->cl[col++]) - 1.0) < 0.1) #else - if(pt->p[j + 1] != pt->p[j]) { - if(std::abs(in->operator[](pt->j[col++]) - 1.0) < 0.1) + if (pt->p[j + 1] != pt->p[j]) { + if (std::abs(in->operator[](pt->j[col++]) - 1.0) < 0.1) #endif - send[i][j] = '1'; - else - send[i][j] = '0'; - } - else - send[i][j] = '0'; - } - MPI_Isend(send[i], pt->n, MPI_UNSIGNED_CHAR, dest, 0, *comm, rq + i); - ++neighborAfter; + send[i][j] = '1'; + else + send[i][j] = '0'; + } else + send[i][j] = '0'; } - else - MPI_Irecv(recv[i], pt->n, MPI_UNSIGNED_CHAR, dest, 0, *comm, rq + i); + MPI_Isend(send[i], pt->n, MPI_UNSIGNED_CHAR, dest, 0, *comm, rq + i); + ++neighborAfter; + } else + MPI_Irecv(recv[i], pt->n, MPI_UNSIGNED_CHAR, dest, 0, *comm, rq + i); } - for(unsigned short i = 0; i < neighborAfter; ++i) { - MatriceMorse* pt = static_cast*>(&(*interpolation->operator[](i).A)); - // cout << mpirank << " receives from " << arrayNeighbor->operator[](i) << ", " << pt->n << "." << endl; - MPI_Irecv(recv[i], pt->n, MPI_UNSIGNED_CHAR, out->operator[](0).operator[](i), 0, *comm, rq + n + i); + for (unsigned short i = 0; i < neighborAfter; ++i) { + MatriceMorse< double >* pt = static_cast< MatriceMorse< double >* >(&(*interpolation->operator[](i).A)); + // cout << mpirank << " receives from " << arrayNeighbor->operator[](i) << ", " << pt->n << "." << endl; + MPI_Irecv(recv[i], pt->n, MPI_UNSIGNED_CHAR, out->operator[](0).operator[](i), 0, *comm, rq + n + i); } - for(unsigned short i = neighborAfter; i < n; ++i) { - int index; - MPI_Waitany(n - neighborAfter, rq + neighborAfter, &index, MPI_STATUS_IGNORE); - unsigned short dest = neighborAfter + index; - MatriceMorse* pt = static_cast*>(&(*interpolation->operator[](dest).A)); - KN& resOut = out->operator[](1 + dest); - + for (unsigned short i = neighborAfter; i < n; ++i) { + int index; + MPI_Waitany(n - neighborAfter, rq + neighborAfter, &index, MPI_STATUS_IGNORE); + unsigned short dest = neighborAfter + index; + MatriceMorse< double >* pt = static_cast< MatriceMorse< double >* >(&(*interpolation->operator[](dest).A)); + KN< long >& resOut = out->operator[](1 + dest); #ifdef VERSION_MATRICE_CREUSE - pt->CSR(); - resOut.resize(pt->nnz); + pt->CSR( ); + resOut.resize(pt->nnz); #else - resOut.resize(pt->nbcoef); + resOut.resize(pt->nbcoef); #endif - unsigned int nnz = 0; - unsigned int col = 0; - for(unsigned int j = 0; j < pt->n; ++j) { + unsigned int nnz = 0; + unsigned int col = 0; + for (unsigned int j = 0; j < pt->n; ++j) { #ifndef VERSION_MATRICE_CREUSE - if(pt->lg[j + 1] != pt->lg[j]) { - if(std::abs(in->operator[](pt->cl[col]) - 1.0) < 0.1 && recv[dest][j] == '1') { - send[dest][j] = '1'; - resOut[(int)nnz++] = pt->cl[col++]; - } + if (pt->lg[j + 1] != pt->lg[j]) { + if (std::abs(in->operator[](pt->cl[col]) - 1.0) < 0.1 && recv[dest][j] == '1') { + send[dest][j] = '1'; + resOut[(int)nnz++] = pt->cl[col++]; + } #else - if(pt->p[j + 1] != pt->p[j]) { - if(std::abs(in->operator[](pt->j[col]) - 1.0) < 0.1 && recv[dest][j] == '1') { - send[dest][j] = '1'; - resOut[(int)nnz++] = pt->j[col++]; - } + if (pt->p[j + 1] != pt->p[j]) { + if (std::abs(in->operator[](pt->j[col]) - 1.0) < 0.1 && recv[dest][j] == '1') { + send[dest][j] = '1'; + resOut[(int)nnz++] = pt->j[col++]; + } #endif - - else { - ++col; - send[dest][j] = '0'; - } - } - else - send[dest][j] = '0'; - } - // cout << mpirank << " sends to " << arrayNeighbor->operator[](dest) << ", " << pt->n << "." << endl; - MPI_Isend(send[dest], pt->n, MPI_UNSIGNED_CHAR, out->operator[](0).operator[](dest), 0, *comm, rq + n + dest); - resOut.resize(nnz); + + else { + ++col; + send[dest][j] = '0'; + } + } else + send[dest][j] = '0'; + } + // cout << mpirank << " sends to " << arrayNeighbor->operator[](dest) << ", " << pt->n << "." << endl; + MPI_Isend(send[dest], pt->n, MPI_UNSIGNED_CHAR, out->operator[](0).operator[](dest), 0, *comm, rq + n + dest); + resOut.resize(nnz); } - for(unsigned short i = 0; i < neighborAfter; ++i) { - int index; - MPI_Waitany(neighborAfter, rq + n, &index, MPI_STATUS_IGNORE); - KN& resOut = out->operator[](1 + index); - MatriceMorse* pt = static_cast*>(&(*interpolation->operator[](index).A)); + for (unsigned short i = 0; i < neighborAfter; ++i) { + int index; + MPI_Waitany(neighborAfter, rq + n, &index, MPI_STATUS_IGNORE); + KN< long >& resOut = out->operator[](1 + index); + MatriceMorse< double >* pt = static_cast< MatriceMorse< double >* >(&(*interpolation->operator[](index).A)); #ifndef VERSION_MATRICE_CREUSE - resOut.resize(pt->nbcoef); + resOut.resize(pt->nbcoef); #else - resOut.resize(pt->nnz); + resOut.resize(pt->nnz); #endif - unsigned int nnz = 0; - unsigned int col = 0; - for(unsigned int j = 0; j < pt->n; ++j) { - if(recv[index][j] == '1') { + unsigned int nnz = 0; + unsigned int col = 0; + for (unsigned int j = 0; j < pt->n; ++j) { + if (recv[index][j] == '1') { #ifndef VERSION_MATRICE_CREUSE - if(pt->lg[j + 1] != pt->lg[j]) - resOut[(int)nnz++] = pt->cl[col++]; - } - else if(pt->lg[j + 1] != pt->lg[j]) - ++col; + if (pt->lg[j + 1] != pt->lg[j]) resOut[(int)nnz++] = pt->cl[col++]; + } else if (pt->lg[j + 1] != pt->lg[j]) + ++col; #else - if(pt->p[j + 1] != pt->p[j]) - resOut[(int)nnz++] = pt->j[col++]; - } - else if(pt->p[j + 1] != pt->p[j]) - ++col; + if (pt->p[j + 1] != pt->p[j]) resOut[(int)nnz++] = pt->j[col++]; + } else if (pt->p[j + 1] != pt->p[j]) + ++col; #endif - } - resOut.resize(nnz); + } + resOut.resize(nnz); } MPI_Waitall(neighborAfter, rq, MPI_STATUSES_IGNORE); MPI_Waitall(n - neighborAfter, rq + n + neighborAfter, MPI_STATUSES_IGNORE); - for(unsigned short i = 0; i < n; ++i) { - delete [] recv[i]; - delete [] send[i]; - // cout << mpirank << " <=> " << arrayNeighbor->operator[](i) << " : " << out->operator[](i).n << endl; + for (unsigned short i = 0; i < n; ++i) { + delete[] recv[i]; + delete[] send[i]; + // cout << mpirank << " <=> " << arrayNeighbor->operator[](i) << " : " << out->operator[](i).n << endl; } - delete [] rq; - KN* interfaceNb = nargs[1] ? GetAny* >((*nargs[1])(stack)) : (KN*) 0; - if(interfaceNb) { - std::vector vec; - vec.reserve(in->n); - for(int i = 0; i < in->n; ++i) { - if(in->operator[](i) != 0.0) - vec.emplace_back(i); + delete[] rq; + KN< long >* interfaceNb = nargs[1] ? GetAny< KN< long >* >((*nargs[1])(stack)) : (KN< long >*)0; + if (interfaceNb) { + std::vector< unsigned int > vec; + vec.reserve(in->n); + for (int i = 0; i < in->n; ++i) { + if (in->operator[](i) != 0.0) vec.emplace_back(i); + } + std::sort(vec.begin( ), vec.end( )); + if (interfaceNb->n != vec.size( )) interfaceNb->resize(vec.size( )); + for (signed int i = 0; i < vec.size( ); ++i) interfaceNb->operator[](i) = vec[i]; + for (unsigned short i = 0; i < n; ++i) { + KN< long >& res = out->operator[](1 + i); + for (signed int j = 0; j < res.n; ++j) { + std::vector< unsigned int >::const_iterator idx = std::lower_bound(vec.cbegin( ), vec.cend( ), (unsigned int)res[j]); + if (idx == vec.cend( ) || res[j] < *idx) { + std::cout << "Problem !" << std::endl; + res[j] = -1; + } else + res[j] = std::distance(vec.cbegin( ), idx); + } + } + bool redundancy = nargs[2] ? GetAny< bool >((*nargs[2])(stack)) : 1; + if (!redundancy) { + std::vector< std::pair< unsigned short, unsigned int > >* array = new std::vector< std::pair< unsigned short, unsigned int > >[interfaceNb->n]; + for (unsigned short i = 0; i < n; ++i) { + KN< long >& res = out->operator[](1 + i); + for (signed int j = 0; j < res.n; ++j) array[res[j]].push_back(std::make_pair(i, res[j])); } - std::sort(vec.begin(), vec.end()); - if(interfaceNb->n != vec.size()) - interfaceNb->resize(vec.size()); - for( signed int i = 0; i < vec.size(); ++i) - interfaceNb->operator[](i) = vec[i]; - for(unsigned short i = 0; i < n; ++i) { - KN& res = out->operator[](1 + i); - for( signed int j = 0; j < res.n; ++j) { - std::vector::const_iterator idx = std::lower_bound(vec.cbegin(), vec.cend(), (unsigned int)res[j]); - if(idx == vec.cend() || res[j] < *idx) { - std::cout << "Problem !" << std::endl; - res[j] = -1; - } - else - res[j] = std::distance(vec.cbegin(), idx); - } + for (unsigned int i = 0; i < interfaceNb->n; ++i) { + if (array[i].size( ) > 1) { + if (mpirank > out->operator[](0).operator[](array[i].back( ).first)) + array[i].erase(array[i].begin( )); + else if (mpirank < out->operator[](0).operator[](array[i].front( ).first)) + array[i].pop_back( ); + } else if (array[i].size( ) < 1) + std::cout << "Problem !" << std::endl; } - bool redundancy = nargs[2] ? GetAny((*nargs[2])(stack)) : 1; - if(!redundancy) { - std::vector >* array = new std::vector >[interfaceNb->n]; - for(unsigned short i = 0; i < n; ++i) { - KN& res = out->operator[](1 + i); - for( signed int j = 0; j < res.n; ++j) - array[res[j]].push_back(std::make_pair(i, res[j])); - } - for(unsigned int i = 0; i < interfaceNb->n; ++i) { - if(array[i].size() > 1) { - if(mpirank > out->operator[](0).operator[](array[i].back().first)) - array[i].erase(array[i].begin()); - else if(mpirank < out->operator[](0).operator[](array[i].front().first)) - array[i].pop_back(); - } - else if (array[i].size() < 1) - std::cout << "Problem !" << std::endl; - } - std::vector* copy = new std::vector[n]; - for(unsigned short i = 0; i < n; ++i) - copy[i].reserve(out->operator[](1 + i).n); - for(unsigned int i = 0; i < interfaceNb->n; ++i) { - for(std::vector >::const_iterator it = array[i].cbegin(); it != array[i].cend(); ++it) { - copy[it->first].push_back(it->second); - } - } - for(unsigned short i = 0; i < n; ++i) { - unsigned int sizeVec = copy[i].size(); - if(sizeVec != out->operator[](1 + i).n) { - out->operator[](1 + i).resize(sizeVec); - long* pt = (static_cast >(out->operator[](1 + i))); - std::reverse_copy(copy[i].begin(), copy[i].end(), pt); - } - } - delete [] copy; - delete [] array; + std::vector< long >* copy = new std::vector< long >[n]; + for (unsigned short i = 0; i < n; ++i) copy[i].reserve(out->operator[](1 + i).n); + for (unsigned int i = 0; i < interfaceNb->n; ++i) { + for (std::vector< std::pair< unsigned short, unsigned int > >::const_iterator it = array[i].cbegin( ); it != array[i].cend( ); ++it) { + copy[it->first].push_back(it->second); + } } + for (unsigned short i = 0; i < n; ++i) { + unsigned int sizeVec = copy[i].size( ); + if (sizeVec != out->operator[](1 + i).n) { + out->operator[](1 + i).resize(sizeVec); + long* pt = (static_cast< KN_< long > >(out->operator[](1 + i))); + std::reverse_copy(copy[i].begin( ), copy[i].end( ), pt); + } + } + delete[] copy; + delete[] array; + } } return 0L; -} + } + template< class Type, class K > + class initDDM_Op : public E_F0mps { + public: + Expression A; + Expression Mat; + Expression R; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + initDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), Mat(param2), R(param3) { args.SetNameParam(n_name_param, name_param, nargs); } -template -class initDDM_Op : public E_F0mps { - public: - Expression A; - Expression Mat; - Expression R; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - initDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), Mat(param2), R(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } - - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type initDDM_Op::name_param[] = { + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type initDDM_Op< Type, K >::name_param[] = { {"communicator", &typeid(pcommworld)}, - {"deflation", &typeid(FEbaseArrayKn*)}, -}; -template -class initDDM : public OneOperator { - public: - initDDM() : OneOperator(atype(), atype(), atype*>(), atype>*>()) { } + {"deflation", &typeid(FEbaseArrayKn< K >*)}, + }; + template< class Type, class K > + class initDDM : public OneOperator { + public: + initDDM( ) : OneOperator(atype< Type* >( ), atype< Type* >( ), atype< Matrice_Creuse< K >* >( ), atype< KN< KN< long > >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new initDDM_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } -}; -template -AnyType initDDM_Op::operator()(Stack stack) const { - Type* ptA = GetAny((*A)(stack)); - Matrice_Creuse* pA = GetAny*>((*Mat)(stack)); - MatriceMorse* mA = pA->A ? static_cast*>(&(*pA->A)) : nullptr; - KN>* ptR = GetAny>*>((*R)(stack)); - if(ptR) { - KN_> sub(ptR->n > 0 && ptR->operator[](0).n > 0 ? (*ptR)(FromTo(1, ptR->n - 1)) : KN>()); - ptA->HPDDM::template Subdomain::initialize(new_HPDDM_MatrixCSR(mA), STL(ptR->n > 0 ? ptR->operator[](0) : KN()), sub, nargs[0] ? (MPI_Comm*)GetAny((*nargs[0])(stack)) : 0); + E_F0* code(const basicAC_F0& args) const { return new initDDM_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + }; + template< class Type, class K > + AnyType initDDM_Op< Type, K >::operator( )(Stack stack) const { + Type* ptA = GetAny< Type* >((*A)(stack)); + Matrice_Creuse< K >* pA = GetAny< Matrice_Creuse< K >* >((*Mat)(stack)); + MatriceMorse< K >* mA = pA->A ? static_cast< MatriceMorse< K >* >(&(*pA->A)) : nullptr; + KN< KN< long > >* ptR = GetAny< KN< KN< long > >* >((*R)(stack)); + if (ptR) { + KN_< KN< long > > sub(ptR->n > 0 && ptR->operator[](0).n > 0 ? (*ptR)(FromTo(1, ptR->n - 1)) : KN< KN< long > >( )); + ptA->HPDDM::template Subdomain< K >::initialize(new_HPDDM_MatrixCSR< K >(mA), STL< long >(ptR->n > 0 ? ptR->operator[](0) : KN< long >( )), sub, + nargs[0] ? (MPI_Comm*)GetAny< pcommworld >((*nargs[0])(stack)) : 0); } - FEbaseArrayKn* deflation = nargs[1] ? GetAny*>((*nargs[1])(stack)) : 0; - if(deflation && deflation->N > 0 && !ptA->getVectors()) { - K** ev = new K*[deflation->N]; - *ev = new K[deflation->N * deflation->get(0)->n]; - for(int i = 0; i < deflation->N; ++i) { - ev[i] = *ev + i * deflation->get(0)->n; - std::copy(&(*deflation->get(i))[0], &(*deflation->get(i))[deflation->get(i)->n], ev[i]); - } - ptA->setVectors(ev); - ptA->Type::super::super::initialize(deflation->N); + FEbaseArrayKn< K >* deflation = nargs[1] ? GetAny< FEbaseArrayKn< K >* >((*nargs[1])(stack)) : 0; + if (deflation && deflation->N > 0 && !ptA->getVectors( )) { + K** ev = new K*[deflation->N]; + *ev = new K[deflation->N * deflation->get(0)->n]; + for (int i = 0; i < deflation->N; ++i) { + ev[i] = *ev + i * deflation->get(0)->n; + std::copy(&(*deflation->get(i))[0], &(*deflation->get(i))[deflation->get(i)->n], ev[i]); + } + ptA->setVectors(ev); + ptA->Type::super::super::initialize(deflation->N); } return ptA; -} + } -template -class attachCoarseOperator_Op : public E_F0mps { - public: - Expression comm; - Expression A; - static const int n_name_param = 4; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - attachCoarseOperator_Op(const basicAC_F0& args, Expression param1, Expression param2) : comm(param1), A(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class attachCoarseOperator_Op : public E_F0mps { + public: + Expression comm; + Expression A; + static const int n_name_param = 4; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + attachCoarseOperator_Op(const basicAC_F0& args, Expression param1, Expression param2) : comm(param1), A(param2) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type attachCoarseOperator_Op::name_param[] = { - {"R", &typeid(FEbaseArrayKn*)}, - {"threshold", &typeid(HPDDM::underlying_type)}, - {"timing", &typeid(KN*)}, - {"ret", &typeid(Pair*)} -}; -template -class attachCoarseOperator : public OneOperator { - public: - attachCoarseOperator() : OneOperator(atype(), atype(), atype()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type attachCoarseOperator_Op< Type, K >::name_param[] = { + {"R", &typeid(FEbaseArrayKn< K >*)}, {"threshold", &typeid(HPDDM::underlying_type< K >)}, {"timing", &typeid(KN< double >*)}, {"ret", &typeid(Pair< K >*)}}; + template< class Type, class K > + class attachCoarseOperator : public OneOperator { + public: + attachCoarseOperator( ) : OneOperator(atype< long >( ), atype< pcommworld >( ), atype< Type* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new attachCoarseOperator_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } -}; -template -AnyType attachCoarseOperator_Op::operator()(Stack stack) const { - pcommworld ptComm = GetAny((*comm)(stack)); + E_F0* code(const basicAC_F0& args) const { return new attachCoarseOperator_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } + }; + template< class Type, class K > + AnyType attachCoarseOperator_Op< Type, K >::operator( )(Stack stack) const { + pcommworld ptComm = GetAny< pcommworld >((*comm)(stack)); MPI_Comm comm = *(MPI_Comm*)ptComm; - Type* ptA = GetAny((*A)(stack)); - FEbaseArrayKn* R = nargs[0] ? GetAny*>((*nargs[0])(stack)) : 0; - Pair* pair = nargs[3] ? GetAny*>((*nargs[3])(stack)) : 0; - unsigned short nu = R ? static_cast(R->N) : 0; - HPDDM::Option& opt = *HPDDM::Option::get(); - HPDDM::underlying_type threshold = opt.val("geneo_threshold", 0.0); - KN* timing = nargs[2] ? GetAny*>((*nargs[2])(stack)) : 0; - std::pair* ret = nullptr; + Type* ptA = GetAny< Type* >((*A)(stack)); + FEbaseArrayKn< K >* R = nargs[0] ? GetAny< FEbaseArrayKn< K >* >((*nargs[0])(stack)) : 0; + Pair< K >* pair = nargs[3] ? GetAny< Pair< K >* >((*nargs[3])(stack)) : 0; + unsigned short nu = R ? static_cast< unsigned short >(R->N) : 0; + HPDDM::Option& opt = *HPDDM::Option::get( ); + HPDDM::underlying_type< K > threshold = opt.val("geneo_threshold", 0.0); + KN< double >* timing = nargs[2] ? GetAny< KN< double >* >((*nargs[2])(stack)) : 0; + std::pair< MPI_Request, const K* >* ret = nullptr; bool adaptive = opt.set("geneo_nu") || threshold > 0.0; - if(!adaptive) - ptA->setDeficiency(nu); - double t = MPI_Wtime(); - if(R) { - if(adaptive) - ptA->computeSchurComplement(); - ptA->callNumfactPreconditioner(); - if(timing) - (*timing)[3] = MPI_Wtime() - t; - if(adaptive) { - if(opt.set("geneo_nu")) - nu = opt["geneo_nu"]; + if (!adaptive) ptA->setDeficiency(nu); + double t = MPI_Wtime( ); + if (R) { + if (adaptive) ptA->computeSchurComplement( ); + ptA->callNumfactPreconditioner( ); + if (timing) (*timing)[3] = MPI_Wtime( ) - t; + if (adaptive) { + if (opt.set("geneo_nu")) nu = opt["geneo_nu"]; #if defined(MUMPSSUB) || defined(PASTIXSUB) || defined(MKL_PARDISOSUB) - t = MPI_Wtime(); - ptA->solveGEVP(); - if(timing) - (*timing)[5] = MPI_Wtime() - t; + t = MPI_Wtime( ); + ptA->solveGEVP( ); + if (timing) (*timing)[5] = MPI_Wtime( ) - t; #else - cout << "Please change your solver" << endl; + cout << "Please change your solver" << endl; #endif + } + if (!R && !ptA->getVectors( )) cout << "Problem !" << endl; + R->resize(0); + MPI_Barrier(MPI_COMM_WORLD); + if (timing) t = MPI_Wtime( ); + if (ptA->exclusion(comm)) { + if (pair) + pair->p = ptA->template buildTwo< 1 >(comm); + else + ret = ptA->template buildTwo< 1 >(comm); + } else { + if (pair) + pair->p = ptA->template buildTwo< 0 >(comm); + else + ret = ptA->template buildTwo< 0 >(comm); + } + if (timing) (*timing)[4] = MPI_Wtime( ) - t; + if (pair) + if (pair->p) { + int flag; + MPI_Test(&(pair->p->first), &flag, MPI_STATUS_IGNORE); } - if(!R && !ptA->getVectors()) - cout << "Problem !" << endl; - R->resize(0); - MPI_Barrier(MPI_COMM_WORLD); - if(timing) - t = MPI_Wtime(); - if(ptA->exclusion(comm)) { - if(pair) - pair->p = ptA->template buildTwo<1>(comm); - else - ret = ptA->template buildTwo<1>(comm); - } - else { - if(pair) - pair->p = ptA->template buildTwo<0>(comm); - else - ret = ptA->template buildTwo<0>(comm); - } - if(timing) - (*timing)[4] = MPI_Wtime() - t; - if(pair) - if(pair->p) { - int flag; - MPI_Test(&(pair->p->first), &flag, MPI_STATUS_IGNORE); - } - t = MPI_Wtime(); - ptA->callNumfact(); - } - else { - MPI_Barrier(MPI_COMM_WORLD); - ret = ptA->template buildTwo<2>(comm); + t = MPI_Wtime( ); + ptA->callNumfact( ); + } else { + MPI_Barrier(MPI_COMM_WORLD); + ret = ptA->template buildTwo< 2 >(comm); } - if(timing) - (*timing)[2] = MPI_Wtime() - t; - if(ret) - delete ret; - if(pair) - if(pair->p) { - if(timing) - t = MPI_Wtime(); - MPI_Wait(&(pair->p->first), MPI_STATUS_IGNORE); - if(timing) - (*timing)[timing->n - 1] = MPI_Wtime() - t; - delete [] pair->p->second; - pair->destroy(); - pair = nullptr; - } + if (timing) (*timing)[2] = MPI_Wtime( ) - t; + if (ret) delete ret; + if (pair) + if (pair->p) { + if (timing) t = MPI_Wtime( ); + MPI_Wait(&(pair->p->first), MPI_STATUS_IGNORE); + if (timing) (*timing)[timing->n - 1] = MPI_Wtime( ) - t; + delete[] pair->p->second; + pair->destroy( ); + pair = nullptr; + } return 0L; -} + } -template -class solveDDM_Op : public E_F0mps { - public: - Expression A; - Expression rhs; - Expression x; - static const int n_name_param = 3; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - solveDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), rhs(param2), x(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class solveDDM_Op : public E_F0mps { + public: + Expression A; + Expression rhs; + Expression x; + static const int n_name_param = 3; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + solveDDM_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), rhs(param2), x(param3) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type solveDDM_Op::name_param[] = { - {"timing", &typeid(KN*)}, - {"excluded", &typeid(bool)}, - {"ret", &typeid(Pair*)} -}; -template -class solveDDM : public OneOperator { - public: - solveDDM() : OneOperator(atype(), atype(), atype*>(), atype*>()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type solveDDM_Op< Type, K >::name_param[] = {{"timing", &typeid(KN< double >*)}, {"excluded", &typeid(bool)}, {"ret", &typeid(Pair< K >*)}}; + template< class Type, class K > + class solveDDM : public OneOperator { + public: + solveDDM( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< KN< K >* >( ), atype< KN< K >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new solveDDM_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } -}; -template -AnyType solveDDM_Op::operator()(Stack stack) const { - KN* ptRHS = GetAny*>((*rhs)(stack)); - KN* ptX = GetAny*>((*x)(stack)); - Type* ptA = GetAny((*A)(stack)); - if(ptX->n != ptRHS->n) - return 0L; - HPDDM::Option& opt = *HPDDM::Option::get(); - KN* timing = nargs[0] ? GetAny*>((*nargs[0])(stack)) : 0; - bool excluded = nargs[1] && GetAny((*nargs[1])(stack)); - if(excluded) - opt["level_2_exclude"]; - double timer = MPI_Wtime(); - if(mpisize == 1) { - ptA->computeSchurComplement(); - ptA->callNumfactPreconditioner(); - if(timing) - (*timing)[3] = MPI_Wtime() - timer; - timer = MPI_Wtime(); - ptA->callNumfact(); - if(timing) - (*timing)[2] = MPI_Wtime() - timer; + E_F0* code(const basicAC_F0& args) const { return new solveDDM_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + }; + template< class Type, class K > + AnyType solveDDM_Op< Type, K >::operator( )(Stack stack) const { + KN< K >* ptRHS = GetAny< KN< K >* >((*rhs)(stack)); + KN< K >* ptX = GetAny< KN< K >* >((*x)(stack)); + Type* ptA = GetAny< Type* >((*A)(stack)); + if (ptX->n != ptRHS->n) return 0L; + HPDDM::Option& opt = *HPDDM::Option::get( ); + KN< double >* timing = nargs[0] ? GetAny< KN< double >* >((*nargs[0])(stack)) : 0; + bool excluded = nargs[1] && GetAny< bool >((*nargs[1])(stack)); + if (excluded) opt["level_2_exclude"]; + double timer = MPI_Wtime( ); + if (mpisize == 1) { + ptA->computeSchurComplement( ); + ptA->callNumfactPreconditioner( ); + if (timing) (*timing)[3] = MPI_Wtime( ) - timer; + timer = MPI_Wtime( ); + ptA->callNumfact( ); + if (timing) (*timing)[2] = MPI_Wtime( ) - timer; } MPI_Barrier(MPI_COMM_WORLD); - if(!excluded && timing && mpisize > 1) - (*timing)[timing->n - 1] += MPI_Wtime() - timer; - timer = MPI_Wtime(); + if (!excluded && timing && mpisize > 1) (*timing)[timing->n - 1] += MPI_Wtime( ) - timer; + timer = MPI_Wtime( ); int rank; - MPI_Comm_rank(ptA->getCommunicator(), &rank); - if(rank != mpirank || rank != 0) - opt.remove("verbosity"); - timer = MPI_Wtime(); - if(!excluded) - HPDDM::IterativeMethod::solve(*ptA, (K*)*ptRHS, (K*)*ptX, 1, MPI_COMM_WORLD); + MPI_Comm_rank(ptA->getCommunicator( ), &rank); + if (rank != mpirank || rank != 0) opt.remove("verbosity"); + timer = MPI_Wtime( ); + if (!excluded) + HPDDM::IterativeMethod::solve(*ptA, (K*)*ptRHS, (K*)*ptX, 1, MPI_COMM_WORLD); else - HPDDM::IterativeMethod::solve(*ptA, (K*)nullptr, (K*)nullptr, 1, MPI_COMM_WORLD); - timer = MPI_Wtime() - timer; - if(!excluded && verbosity > 0 && rank == 0) - std::cout << scientific << " --- system solved (in " << timer << ")" << std::endl; + HPDDM::IterativeMethod::solve< true >(*ptA, (K*)nullptr, (K*)nullptr, 1, MPI_COMM_WORLD); + timer = MPI_Wtime( ) - timer; + if (!excluded && verbosity > 0 && rank == 0) std::cout << scientific << " --- system solved (in " << timer << ")" << std::endl; return 0L; -} + } -template -class renumber_Op : public E_F0mps { - public: - Expression A; - Expression Mat; - Expression interface; - static const int n_name_param = 4; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - renumber_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), Mat(param2), interface(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + template< class Type, class K > + class renumber_Op : public E_F0mps { + public: + Expression A; + Expression Mat; + Expression interface; + static const int n_name_param = 4; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + renumber_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : A(param1), Mat(param2), interface(param3) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type renumber_Op::name_param[] = { - {"R", &typeid(FEbaseArrayKn*)}, - {"effort", &typeid(KN*)}, - {"rho", &typeid(KN*)}, - {"timing", &typeid(KN*)} -}; -template -class renumber : public OneOperator { - public: - renumber() : OneOperator(atype(), atype(), atype*>(), atype*>()) { } + AnyType operator( )(Stack stack) const; + }; + template< class Type, class K > + basicAC_F0::name_and_type renumber_Op< Type, K >::name_param[] = {{"R", &typeid(FEbaseArrayKn< K >*)}, {"effort", &typeid(KN< K >*)}, {"rho", &typeid(KN< K >*)}, {"timing", &typeid(KN< double >*)}}; + template< class Type, class K > + class renumber : public OneOperator { + public: + renumber( ) : OneOperator(atype< long >( ), atype< Type* >( ), atype< Matrice_Creuse< K >* >( ), atype< KN< long >* >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new renumber_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } -}; - template - AnyType renumber_Op::operator()(Stack stack) const { - Type* ptA = GetAny((*A)(stack)); - KN* ptInterface = GetAny*>((*interface)(stack)); - FEbaseArrayKn* deflation = nargs[0] ? GetAny*>((*nargs[0])(stack)) : 0; - KN* ptEffort = nargs[1] ? GetAny*>((*nargs[1])(stack)) : 0; - KN* rho = nargs[2] ? GetAny*>((*nargs[2])(stack)) : 0; - KN* timing = nargs[3] ? GetAny*>((*nargs[3])(stack)) : 0; - double t = MPI_Wtime(); - K** ev; - if(deflation && deflation->N > 0) { - ev = new K*[deflation->N]; - *ev = new K[deflation->N * deflation->get(0)->n]; - for(int i = 0; i < deflation->N; ++i) { - ev[i] = *ev + i * deflation->get(0)->n; - std::copy(static_cast(*(deflation->get(i))), static_cast(*(deflation->get(i))) + deflation->get(i)->n, ev[i]); - } - ptA->setVectors(ev); - ptA->Type::super::super::initialize(deflation->N); - } + E_F0* code(const basicAC_F0& args) const { return new renumber_Op< Type, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + }; + template< class Type, class K > + AnyType renumber_Op< Type, K >::operator( )(Stack stack) const { + Type* ptA = GetAny< Type* >((*A)(stack)); + KN< long >* ptInterface = GetAny< KN< long >* >((*interface)(stack)); + FEbaseArrayKn< K >* deflation = nargs[0] ? GetAny< FEbaseArrayKn< K >* >((*nargs[0])(stack)) : 0; + KN< K >* ptEffort = nargs[1] ? GetAny< KN< K >* >((*nargs[1])(stack)) : 0; + KN< K >* rho = nargs[2] ? GetAny< KN< K >* >((*nargs[2])(stack)) : 0; + KN< double >* timing = nargs[3] ? GetAny< KN< double >* >((*nargs[3])(stack)) : 0; + double t = MPI_Wtime( ); + K** ev; + if (deflation && deflation->N > 0) { + ev = new K*[deflation->N]; + *ev = new K[deflation->N * deflation->get(0)->n]; + for (int i = 0; i < deflation->N; ++i) { + ev[i] = *ev + i * deflation->get(0)->n; + std::copy(static_cast< K* >(*(deflation->get(i))), static_cast< K* >(*(deflation->get(i))) + deflation->get(i)->n, ev[i]); + } + ptA->setVectors(ev); + ptA->Type::super::super::initialize(deflation->N); + } - ptA->renumber(STL(*ptInterface), ptEffort ? static_cast(*ptEffort) : nullptr); - MatriceMorse* mA = static_cast*>(&(*GetAny*>((*Mat)(stack))->A)); - if(mA) { - const HPDDM::MatrixCSR* dA = ptA->getMatrix(); - - #ifndef VERSION_MATRICE_CREUSE - mA->lg = dA->_ia; - #else - set_ff_matrix(mA,*dA); - #endif - } + ptA->renumber(STL< long >(*ptInterface), ptEffort ? static_cast< K* >(*ptEffort) : nullptr); + MatriceMorse< K >* mA = static_cast< MatriceMorse< K >* >(&(*GetAny< Matrice_Creuse< K >* >((*Mat)(stack))->A)); + if (mA) { + const HPDDM::MatrixCSR< K >* dA = ptA->getMatrix( ); - HPDDM::Option& opt = *HPDDM::Option::get(); - char scaling = opt.val("substructuring_scaling", 0); - if(scaling == 2 && rho) { - ptA->renumber(STL(*ptInterface), *rho); - ptA->buildScaling(scaling, *rho); +#ifndef VERSION_MATRICE_CREUSE + mA->lg = dA->_ia; +#else + set_ff_matrix< K >(mA, *dA); +#endif } - else - ptA->buildScaling(scaling); - if(timing) { - (*timing)[1] = MPI_Wtime() - t; - t = MPI_Wtime(); + HPDDM::Option& opt = *HPDDM::Option::get( ); + char scaling = opt.val< char >("substructuring_scaling", 0); + if (scaling == 2 && rho) { + ptA->renumber(STL< long >(*ptInterface), *rho); + ptA->buildScaling(scaling, *rho); + } else + ptA->buildScaling(scaling); + + if (timing) { + (*timing)[1] = MPI_Wtime( ) - t; + t = MPI_Wtime( ); } - if(deflation && deflation->N > 0) - for(int i = 0; i < deflation->N; ++i) - std::copy(ev[i], ev[i] + deflation->get(i)->n, static_cast(*(deflation->get(i)))); + if (deflation && deflation->N > 0) + for (int i = 0; i < deflation->N; ++i) std::copy(ev[i], ev[i] + deflation->get(i)->n, static_cast< K* >(*(deflation->get(i)))); return 0L; -} + } -template -long originalNumbering(Type* const& A, KN* const& in, KN* const& interface) { - A->originalNumbering(STL(*interface), *in); + template< class Type, class K > + long originalNumbering(Type* const& A, KN< K >* const& in, KN< long >* const& interface) { + A->originalNumbering(STL< long >(*interface), *in); return 0; -} + } -template -class InvSubstructuring { - public: - const T t; - const U u; - InvSubstructuring(T v, U w) : t(v), u(w) {} - void solve(U out) const { - if(out->n != u->n) - return; - if(mpisize == 1) { - (*t).computeSchurComplement(); - (*t).callNumfactPreconditioner(); - (*t).callNumfact(); - } - HPDDM::Option& opt = *HPDDM::Option::get(); - if(mpirank != 0) - opt.remove("verbosity"); - HPDDM::IterativeMethod::solve(*t, (K*)*u, (K*)*out, 1, MPI_COMM_WORLD); - } - static U inv(U Ax, InvSubstructuring A) { - A.solve(Ax); - return Ax; - } - static U init(U Ax, InvSubstructuring A) { - Ax->init(A.u->n); - return Ax; - } -}; + template< class T, class U, class K, char trans > + class InvSubstructuring { + public: + const T t; + const U u; + InvSubstructuring(T v, U w) : t(v), u(w) {} + void solve(U out) const { + if (out->n != u->n) return; + if (mpisize == 1) { + (*t).computeSchurComplement( ); + (*t).callNumfactPreconditioner( ); + (*t).callNumfact( ); + } + HPDDM::Option& opt = *HPDDM::Option::get( ); + if (mpirank != 0) opt.remove("verbosity"); + HPDDM::IterativeMethod::solve(*t, (K*)*u, (K*)*out, 1, MPI_COMM_WORLD); + } + static U inv(U Ax, InvSubstructuring< T, U, K, trans > A) { + A.solve(Ax); + return Ax; + } + static U init(U Ax, InvSubstructuring< T, U, K, trans > A) { + Ax->init(A.u->n); + return Ax; + } + }; -template -using HpFetiPrec = HpFeti; -template class Type, class K, char S, char U = S> -void add() { - Dcl_Type*>(Initialize>, DeleteDTOR>); - if(std::is_same>::value) { - static_assert(std::is_same, HpBdd>::value || std::is_same, HpFetiPrec>::value, "What are you trying to do?"); - if(std::is_same, HpBdd>::value) - zzzfff->Add("bdd", atype*>()); - else - zzzfff->Add("feti", atype*>()); + template< class K, char S > + using HpFetiPrec = HpFeti< HPDDM::FetiPrcndtnr::DIRICHLET, K, S >; + template< template< class, char > class Type, class K, char S, char U = S > + void add( ) { + Dcl_Type< Type< K, S >* >(Initialize< Type< K, S > >, DeleteDTOR< Type< K, S > >); + if (std::is_same< K, HPDDM::underlying_type< K > >::value) { + static_assert(std::is_same< Type< K, S >, HpBdd< K, S > >::value || std::is_same< Type< K, S >, HpFetiPrec< K, S > >::value, "What are you trying to do?"); + if (std::is_same< Type< K, S >, HpBdd< K, S > >::value) + zzzfff->Add("bdd", atype< Type< K, S >* >( )); + else + zzzfff->Add("feti", atype< Type< K, S >* >( )); } - map_type_of_map[make_pair(atype, U>*>(), atype())] = atype*>(); + map_type_of_map[make_pair(atype< Type< HPDDM::underlying_type< K >, U >* >( ), atype< K* >( ))] = atype< Type< K, S >* >( ); - TheOperators->Add("<-", new initDDM, K>); - Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator, K>); - Global.Add("DDM", "(", new solveDDM, K>); - Global.Add("renumber", "(", new renumber, K>); - Global.Add("OriginalNumbering", "(", new OneOperator3_*, KN*, KN*>(originalNumbering)); - addInv, InvSubstructuring, KN, K>(); - Global.Add("statistics", "(", new OneOperator1_*>(statistics>)); - Global.Add("exchange", "(", new exchangeInOut, K>); + TheOperators->Add("<-", new initDDM< Type< K, S >, K >); + Global.Add("AttachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >); + Global.Add("DDM", "(", new solveDDM< Type< K, S >, K >); + Global.Add("renumber", "(", new renumber< Type< K, S >, K >); + Global.Add("OriginalNumbering", "(", new OneOperator3_< long, Type< K, S >*, KN< K >*, KN< long >* >(originalNumbering)); + addInv< Type< K, S >, InvSubstructuring, KN< K >, K >( ); + Global.Add("statistics", "(", new OneOperator1_< bool, Type< K, S >* >(statistics< Type< K, S > >)); + Global.Add("exchange", "(", new exchangeInOut< Type< K, S >, K >); - if(!exist_type*>()) { - Dcl_Type*>(InitP>, Destroy>); - map_type_of_map[make_pair(atype>*>(), atype())] = atype*>(); + if (!exist_type< Pair< K >* >( )) { + Dcl_Type< Pair< K >* >(InitP< Pair< K > >, Destroy< Pair< K > >); + map_type_of_map[make_pair(atype< Pair< HPDDM::underlying_type< K > >* >( ), atype< K* >( ))] = atype< Pair< K >* >( ); } aType t; int r; - if(!zzzfff->InMotClef("pair", t, r) && std::is_same>::value) - zzzfff->Add("pair", atype*>()); + if (!zzzfff->InMotClef("pair", t, r) && std::is_same< K, HPDDM::underlying_type< K > >::value) zzzfff->Add("pair", atype< Pair< K >* >( )); #ifdef GENERATE_DEPRECATED_FUNCTIONS - Global.Add("originalNumbering", "(", new OneOperator3_*, KN*, KN*>(originalNumbering)); - Global.Add("attachCoarseOperator", "(", new attachCoarseOperator, K>); + Global.Add("originalNumbering", "(", new OneOperator3_< long, Type< K, S >*, KN< K >*, KN< long >* >(originalNumbering)); + Global.Add("attachCoarseOperator", "(", new attachCoarseOperator< Type< K, S >, K >); #endif -} -} + } +} // namespace Substructuring -static void Init_Substructuring() { - Init_Common(); - Global.Add("buildSkeleton", "(", new Substructuring::Skeleton); +static void Init_Substructuring( ) { + Init_Common( ); + Global.Add("buildSkeleton", "(", new Substructuring::Skeleton); #if defined(DSUITESPARSE) || defined(DHYPRE) - constexpr char ds = 'G'; + constexpr char ds = 'G'; #else - constexpr char ds = 'S'; + constexpr char ds = 'S'; #endif - constexpr char zs = 'G'; - Substructuring::add(); + constexpr char zs = 'G'; + Substructuring::add< HpBdd, double, ds >( ); #ifndef DHYPRE - Substructuring::add, zs, ds>(); - // Substructuring::add(); - // Substructuring::add, zs>(); + Substructuring::add< HpBdd, std::complex< double >, zs, ds >( ); + // Substructuring::add(); + // Substructuring::add, zs>(); #endif - Substructuring::add(); + Substructuring::add< Substructuring::HpFetiPrec, double, ds >( ); #ifndef DHYPRE - Substructuring::add, zs, ds>(); - // Substructuring::add(); - // Substructuring::add, zs>(); + Substructuring::add< Substructuring::HpFetiPrec, std::complex< double >, zs, ds >( ); + // Substructuring::add(); + // Substructuring::add, zs>(); #endif } diff --git a/plugin/mpi/mpi-cmaes.cpp b/plugin/mpi/mpi-cmaes.cpp index c80ee72ef..5895eb6a4 100644 --- a/plugin/mpi/mpi-cmaes.cpp +++ b/plugin/mpi/mpi-cmaes.cpp @@ -26,368 +26,343 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* clang-format off */ //ff-c++-LIBRARY-dep: mpi //ff-c++-cpp-dep: ../seq/cmaes.cpp -I../seq +/* clang-format on */ /* - This is a freefem interface of the Hansen's CMA-ES C optimizer. - The class CMAES is a quick C++ interface for the contents of the C files - then follow the real FreeFem++ stuff. + This is a freefem interface of the Hansen's CMA-ES C optimizer. + The class CMAES is a quick C++ interface for the contents of the C files + then follow the real FreeFem++ stuff. */ - -#include +#include using namespace std; #include "ff++.hpp" #include "mpi.h" #include "cmaes_interface.h" +template< class T > +struct MPI_TYPE {}; +template<> +struct MPI_TYPE< long > { + static MPI_Datatype TYPE( ) { return MPI_LONG; } +}; +template<> +struct MPI_TYPE< int > { + static MPI_Datatype TYPE( ) { return MPI_INT; } +}; +template<> +struct MPI_TYPE< double > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE; } +}; +template<> +struct MPI_TYPE< char > { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; - -template struct MPI_TYPE {}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_LONG;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_INT;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_DOUBLE;}}; -template<> struct MPI_TYPE {static MPI_Datatype TYPE(){return MPI_BYTE;}}; - - -class CMAES //Abstract class, because the fitness function prototype may differ from users to users +class CMAES // Abstract class, because the fitness function prototype may differ from users to users { - public: - //typedef double (*FFT)(double const *); //Fitness Function Type - CMAES() : pop(0),fitvals(0),evo() {} - CMAES(int d,double *xstart,double *stddev,long seed,int lambda,const char *ipf="initials.par") : pop(0),fitvals(0),evo() - { - fitvals = init(d,xstart,stddev,seed,lambda,ipf); - cout << SayHello() << endl; - } - virtual ~CMAES() {exit();} - - void resume_distribution(char *filename) {return cmaes_resume_distribution(&evo, filename);} - double * const * & SamplePopulation() {return pop = cmaes_SamplePopulation(&evo);} - double * UpdateDistribution() {return cmaes_UpdateDistribution(&evo,fitvals);} - const char * TestForTermination() const {return cmaes_TestForTermination(&evo);} - double * const * & ReSampleSingle(int index) {return pop = cmaes_ReSampleSingle(&evo,index);} - double const * ReSampleSingle_old(double *rgx) {return cmaes_ReSampleSingle_old(&evo,rgx);} - void UpdateEigensystem(int flgforce) {return cmaes_UpdateEigensystem(&evo, flgforce);} - virtual void PopEval() =0; - //{for(int i=0;i(cmaes_GetPtr(&evo,"diag(C)"));} - double * diagD() const {return const_cast(cmaes_GetPtr(&evo,"diag(D)"));} - double * stddev() const {return const_cast(cmaes_GetPtr(&evo,"stddev"));} - double * xbestever() const {return const_cast(cmaes_GetPtr(&evo,"xbestever"));} - double * xbest() const {return const_cast(cmaes_GetPtr(&evo,"xbest"));} - double * xmean() const {return const_cast(cmaes_GetPtr(&evo,"xmean"));} - - void ReadSignals(char const * filename) const {cmaes_ReadSignals(&evo,filename);} - char * SayHello() const {return cmaes_SayHello(&evo);} - void WriteToFile(char const * keyword,char const * output_filename) const {cmaes_WriteToFile(&evo,keyword,output_filename);} - - virtual double * operator() () - { - //ReadSignals("signals.par"); - while(!TestForTermination()) - { - SamplePopulation(); - PopEval(); - UpdateDistribution(); - //ReadSignals("signals.par"); - } - cout << "Stop : " << TestForTermination() << endl; - return xmean(); - } - cmaes_t& optimizer() {return evo;} - protected: - double * const * pop; - double * fitvals; - double*& init(int dimension,double *xstart,double *stddev,long seed,int lambda,const char *input_parameter_filename) - {return fitvals = cmaes_init(&evo,dimension,xstart,stddev,seed,lambda,input_parameter_filename);} - private: - void exit() {cmaes_exit(&evo);} - mutable cmaes_t evo; + public: + // typedef double (*FFT)(double const *); //Fitness Function Type + CMAES( ) : pop(0), fitvals(0), evo( ) {} + CMAES(int d, double *xstart, double *stddev, long seed, int lambda, const char *ipf = "initials.par") : pop(0), fitvals(0), evo( ) { + fitvals = init(d, xstart, stddev, seed, lambda, ipf); + cout << SayHello( ) << endl; + } + virtual ~CMAES( ) { exit( ); } + + void resume_distribution(char *filename) { return cmaes_resume_distribution(&evo, filename); } + double *const *&SamplePopulation( ) { return pop = cmaes_SamplePopulation(&evo); } + double *UpdateDistribution( ) { return cmaes_UpdateDistribution(&evo, fitvals); } + const char *TestForTermination( ) const { return cmaes_TestForTermination(&evo); } + double *const *&ReSampleSingle(int index) { return pop = cmaes_ReSampleSingle(&evo, index); } + double const *ReSampleSingle_old(double *rgx) { return cmaes_ReSampleSingle_old(&evo, rgx); } + void UpdateEigensystem(int flgforce) { return cmaes_UpdateEigensystem(&evo, flgforce); } + virtual void PopEval( ) = 0; + //{for(int i=0;i(cmaes_GetPtr(&evo, "diag(C)")); } + double *diagD( ) const { return const_cast< double * >(cmaes_GetPtr(&evo, "diag(D)")); } + double *stddev( ) const { return const_cast< double * >(cmaes_GetPtr(&evo, "stddev")); } + double *xbestever( ) const { return const_cast< double * >(cmaes_GetPtr(&evo, "xbestever")); } + double *xbest( ) const { return const_cast< double * >(cmaes_GetPtr(&evo, "xbest")); } + double *xmean( ) const { return const_cast< double * >(cmaes_GetPtr(&evo, "xmean")); } + + void ReadSignals(char const *filename) const { cmaes_ReadSignals(&evo, filename); } + char *SayHello( ) const { return cmaes_SayHello(&evo); } + void WriteToFile(char const *keyword, char const *output_filename) const { cmaes_WriteToFile(&evo, keyword, output_filename); } + + virtual double *operator( )( ) { + // ReadSignals("signals.par"); + while (!TestForTermination( )) { + SamplePopulation( ); + PopEval( ); + UpdateDistribution( ); + // ReadSignals("signals.par"); + } + cout << "Stop : " << TestForTermination( ) << endl; + return xmean( ); + } + cmaes_t &optimizer( ) { return evo; } + + protected: + double *const *pop; + double *fitvals; + double *&init(int dimension, double *xstart, double *stddev, long seed, int lambda, const char *input_parameter_filename) { + return fitvals = cmaes_init(&evo, dimension, xstart, stddev, seed, lambda, input_parameter_filename); + } + + private: + void exit( ) { cmaes_exit(&evo); } + mutable cmaes_t evo; }; - - - /* - Now comes the FreeFem ++ part : + Now comes the FreeFem ++ part : */ extern Block *currentblock; typedef double R; -class OptimCMA_ES : public OneOperator -{ - public: - typedef KN Kn; - typedef KN_ Kn_; - const int cas; - - - class ffcalfunc // to call the freefem function .. J - { - public: - Stack stack; - Expression JJ,theparame; - mutable int counter; - - ffcalfunc(Stack s,Expression JJJ,Expression epar) : stack(s),JJ(JJJ), theparame(epar), counter(0) {} - double J(Kn_ x) const - { - ++counter; - KN *p=GetAny *>( (*theparame)(stack) ); - *p=x; - double ret= GetAny( (*JJ)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - return ret; - } - }; - - - class CMA_ES_MPI : public CMAES - { - public: - typedef KN Rn; - typedef KN_ Rn_; - - - //CMA_ES_MPI() : CMAES(),x(0),fit(0) {} - /*CMA_ES(ffcalfunc &_ff,int d,Rn &xstart,double *stddev,long seed,int lambda) - : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {} - CMA_ES(ffcalfunc &_ff,int d,Rn &xstart,const Rn &stddev,long seed,int lambda) - : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {}*/ - - CMA_ES_MPI(ffcalfunc &_ff,Rn &xstart,const Rn &stddev,long seed,int lambda,MPI_Comm *_com) - : CMAES(),x(0),fit(&_ff),com(_com),myid(0),nproc(1),my_number_of_fitness_eval(0),index(0) - { - MPI_Comm_size(*com,&nproc); - MPI_Comm_rank(*com,&myid); - x = &xstart; - init(x->n,xstart.n ? xstart:0,stddev,seed,lambda,"non"); - my_number_of_fitness_eval = (lambda/nproc) + (myid < (lambda%nproc) ? 1:0); - index = new int[nproc]; - for(int i=0;i0 ? index[i-1]+inofe : 0; - } - if(myid==0) cout << SayHello() << endl; - } - CMA_ES_MPI(ffcalfunc &_ff,Rn &xstart,const Rn &stddev,long seed,int lambda,MPI_Comm *_com,const char *ifname) - : CMAES(),x(0),fit(&_ff),com(_com),myid(0),nproc(1),my_number_of_fitness_eval(0),index(0) - { - MPI_Comm_size(*com,&nproc); - MPI_Comm_rank(*com,&myid); - x = &xstart; - init(x->n,xstart.n ? xstart:0,stddev,seed,lambda,ifname); - my_number_of_fitness_eval = (lambda/nproc) + (myid < (lambda%nproc) ? 1:0); - index = new int[nproc]; - for(int i=0;i0 ? index[i-1]+inofe : 0; - } - if(myid==0) cout << SayHello() << endl; - } - ~CMA_ES_MPI() - { - if(index) delete [] index; - index=0; - } - - void PopEval() - { - //cout << endl << "***** in popeval myid = " << myid << "*****" << endl; - for(int i=0;iJ(popi); - } - } - double * operator() () - { - while(!TestForTermination()) - { - MPI_Barrier(*com); - SamplePopulation();//Every proc samples its own population... but only the one from proc 0 is used. Fortunately, this is a quick computation regarding the time spent on fitness function evaluation - for(int i=0;i( (*nargs[i])(stack) ): a;} - R arg(int i,Stack stack,R a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - E_CMA_ES(const basicAC_F0 & args,int cc) : cas(cc) - { - int nbj= args.size()-1; - Block::open(currentblock); // make a new block to - X = to(args[nbj]); - C_F0 X_n(args[nbj],"n"); - // the expression to init the theparam of all - inittheparam = currentblock->NewVar("the parameter",atype *>(),X_n); - theparam = currentblock->Find("the parameter"); // the expression for the parameter - args.SetNameParam(n_name_param,name_param,nargs); - const Polymorphic * opJ=0; - if (nbj>0) - { - opJ= dynamic_cast(args[0].LeftValue()); - assert(opJ); - } - JJ= to(C_F0(opJ,"(",theparam)); - closetheparam=C_F0((Expression) Block::snewclose(currentblock),atype()) ; - //closetheparam=currentblock->close(currentblock); // the cleanning block expression - } - - virtual AnyType operator()(Stack stack) const - { - double cost = 1e100; - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 - Kn &x = *GetAny((*X)(stack)); - long n=x.N(); - long seed = arg(0,stack,0L); //The seed for random numbers generation - double initialStdDev = arg(1,stack,0.3); //Initial standard deviation - KN iSD(n,1.); - iSD *= initialStdDev; - KN initialStdDevs(nargs[2] ? GetAny >((*nargs[2])(stack)) : (KN_)iSD); - //cout << "dans le dylib :" << initialStdDevs << endl; - double stopTolFun = arg(3,stack,1.E-12); - double stopTolFunHist = arg(4,stack,0.); - double stopTolX = arg(5,stack,0.); - double stopTolUpXFactor = arg(6,stack,1.E3); - long popsize = arg(7,stack,4 + (long) floor(3*log(n))); - pcommworld vcommworld=0; - if (nargs[8]) vcommworld = GetAny((*nargs[8])(stack)); - - MPI_Comm mpiCommWorld = MPI_COMM_WORLD; - MPI_Comm * commworld= vcommworld ? (MPI_Comm *) vcommworld : & mpiCommWorld ; - //long mu = arg(8,stack,popsize/2); - - long iprint = verbosity; - ffcalfunc ffJ(stack,JJ,theparam); - - //cout << endl << "ATTENTION : " << *commworld << endl; - - int myid=0,nproc=1; - - MPI_Comm_size(*commworld,&nproc); - MPI_Comm_rank(*commworld,&myid); - - - - //cout << endl << "nbr de proc : " << nproc << " -- myid=" << myid << " -- world id=" << wr << endl; - - CMA_ES_MPI *optim=0; - if(nargs[9]) optim = new CMA_ES_MPI(ffJ,x,initialStdDevs,seed,popsize,commworld,(GetAny((*nargs[9])(stack)))->c_str()); - else optim = new CMA_ES_MPI(ffJ,x,initialStdDevs,seed,popsize,commworld); - if(!nargs[9]) - { - optim->optimizer().sp.stopTolFun = stopTolFun; - optim->optimizer().sp.stopTolFunHist = stopTolFunHist; - optim->optimizer().sp.stopTolX = stopTolX; - optim->optimizer().sp.stopTolUpXFactor = stopTolUpXFactor; - long meval = arg(10,stack,static_cast(optim->maxeval())); - long mgen = arg(11,stack,static_cast(optim->maxgen())); - optim->optimizer().sp.stopMaxFunEvals = meval; - optim->optimizer().sp.stopMaxIter = mgen; - } - - (*optim)(); - cost = optim->fitness(); - x = KN_(optim->xbestever(),optim->dimension()); - - delete optim; - closetheparam.eval(stack); // clean memory - WhereStackOfPtr2Free(stack)->clean(); // FH mars 2005 - return cost; //SetAny(0); Modif FH july 2005 - } - - operator aType () const { return atype();} - }; - - E_F0 * code(const basicAC_F0 & args) const {return new E_CMA_ES(args,cas);} - - OptimCMA_ES(int c) : OneOperator(atype(),atype(),atype *>()),cas(c){} +class OptimCMA_ES : public OneOperator { + public: + typedef KN< R > Kn; + typedef KN_< R > Kn_; + const int cas; + + class ffcalfunc // to call the freefem function .. J + { + public: + Stack stack; + Expression JJ, theparame; + mutable int counter; + + ffcalfunc(Stack s, Expression JJJ, Expression epar) : stack(s), JJ(JJJ), theparame(epar), counter(0) {} + double J(Kn_ x) const { + ++counter; + KN< double > *p = GetAny< KN< double > * >((*theparame)(stack)); + *p = x; + double ret = GetAny< R >((*JJ)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + return ret; + } + }; + + class CMA_ES_MPI : public CMAES { + public: + typedef KN< double > Rn; + typedef KN_< double > Rn_; + + // CMA_ES_MPI() : CMAES(),x(0),fit(0) {} + /*CMA_ES(ffcalfunc &_ff,int d,Rn &xstart,double *stddev,long seed,int lambda) + : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {} + CMA_ES(ffcalfunc &_ff,int d,Rn &xstart,const Rn &stddev,long seed,int lambda) + : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {}*/ + + CMA_ES_MPI(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda, MPI_Comm *_com) : CMAES( ), x(0), fit(&_ff), com(_com), myid(0), nproc(1), my_number_of_fitness_eval(0), index(0) { + MPI_Comm_size(*com, &nproc); + MPI_Comm_rank(*com, &myid); + x = &xstart; + init(x->n, xstart.n ? xstart : 0, stddev, seed, lambda, "non"); + my_number_of_fitness_eval = (lambda / nproc) + (myid < (lambda % nproc) ? 1 : 0); + index = new int[nproc]; + for (int i = 0; i < nproc; ++i) { + int inofe = lambda / nproc + ((i - 1) < (lambda % nproc) ? 1 : 0); + index[i] = i > 0 ? index[i - 1] + inofe : 0; + } + if (myid == 0) cout << SayHello( ) << endl; + } + CMA_ES_MPI(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda, MPI_Comm *_com, const char *ifname) + : CMAES( ), x(0), fit(&_ff), com(_com), myid(0), nproc(1), my_number_of_fitness_eval(0), index(0) { + MPI_Comm_size(*com, &nproc); + MPI_Comm_rank(*com, &myid); + x = &xstart; + init(x->n, xstart.n ? xstart : 0, stddev, seed, lambda, ifname); + my_number_of_fitness_eval = (lambda / nproc) + (myid < (lambda % nproc) ? 1 : 0); + index = new int[nproc]; + for (int i = 0; i < nproc; ++i) { + int inofe = lambda / nproc + ((i - 1) < (lambda % nproc) ? 1 : 0); + index[i] = i > 0 ? index[i - 1] + inofe : 0; + } + if (myid == 0) cout << SayHello( ) << endl; + } + ~CMA_ES_MPI( ) { + if (index) delete[] index; + index = 0; + } + + void PopEval( ) { + // cout << endl << "***** in popeval myid = " << myid << "*****" << endl; + for (int i = 0; i < my_number_of_fitness_eval; ++i) { + Rn_ popi(pop[i + index[myid]], dimension( )); + fitvals[i + index[myid]] = fit->J(popi); + } + } + double *operator( )( ) { + while (!TestForTermination( )) { + MPI_Barrier(*com); + SamplePopulation( ); // Every proc samples its own population... but only the one from proc 0 is used. Fortunately, this is a quick computation regarding the time spent on fitness function + // evaluation + for (int i = 0; i < popsize( ); ++i) MPI_Bcast(pop[i], dimension( ), MPI_DOUBLE, 0, *com); // send the population to every proc + PopEval( ); // each proc do its work gently + for (int i = 0; i < nproc; ++i) { + int nn = i < nproc - 1 ? index[i + 1] - index[i] : popsize( ) / nproc; + MPI_Bcast(&fitvals[index[i]], nn, MPI_DOUBLE, i, *com); + } + UpdateDistribution( ); // There again, only proc 0 would really need to update its distribution + } + if (myid == 0) cout << "Stop : " << TestForTermination( ) << endl; + return xmean( ); + } + + private: + CMA_ES_MPI(const CMA_ES_MPI &); + CMA_ES_MPI &operator=(const CMA_ES_MPI &); + ffcalfunc *fit; + Rn *x; + MPI_Comm *com; + int nproc, myid, my_number_of_fitness_eval; + int *index; + }; + + class E_CMA_ES : public E_F0mps { + public: + const int cas; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 12; + Expression nargs[n_name_param]; + Expression X; + C_F0 inittheparam, theparam, closetheparam; + Expression JJ; + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } + + E_CMA_ES(const basicAC_F0 &args, int cc) : cas(cc) { + int nbj = args.size( ) - 1; + Block::open(currentblock); // make a new block to + X = to< Kn * >(args[nbj]); + C_F0 X_n(args[nbj], "n"); + // the expression to init the theparam of all + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + theparam = currentblock->Find("the parameter"); // the expression for the parameter + args.SetNameParam(n_name_param, name_param, nargs); + const Polymorphic *opJ = 0; + if (nbj > 0) { + opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )); + assert(opJ); + } + JJ = to< R >(C_F0(opJ, "(", theparam)); + closetheparam = C_F0((Expression)Block::snewclose(currentblock), atype< void >( )); + // closetheparam=currentblock->close(currentblock); // the cleanning block expression + } + + virtual AnyType operator( )(Stack stack) const { + double cost = 1e100; + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 + Kn &x = *GetAny< Kn * >((*X)(stack)); + long n = x.N( ); + long seed = arg(0, stack, 0L); // The seed for random numbers generation + double initialStdDev = arg(1, stack, 0.3); // Initial standard deviation + KN< double > iSD(n, 1.); + iSD *= initialStdDev; + KN< double > initialStdDevs(nargs[2] ? GetAny< KN_< double > >((*nargs[2])(stack)) : (KN_< double >)iSD); + // cout << "dans le dylib :" << initialStdDevs << endl; + double stopTolFun = arg(3, stack, 1.E-12); + double stopTolFunHist = arg(4, stack, 0.); + double stopTolX = arg(5, stack, 0.); + double stopTolUpXFactor = arg(6, stack, 1.E3); + long popsize = arg(7, stack, 4 + (long)floor(3 * log(n))); + pcommworld vcommworld = 0; + if (nargs[8]) vcommworld = GetAny< pcommworld >((*nargs[8])(stack)); + + MPI_Comm mpiCommWorld = MPI_COMM_WORLD; + MPI_Comm *commworld = vcommworld ? (MPI_Comm *)vcommworld : &mpiCommWorld; + // long mu = arg(8,stack,popsize/2); + + long iprint = verbosity; + ffcalfunc ffJ(stack, JJ, theparam); + + // cout << endl << "ATTENTION : " << *commworld << endl; + + int myid = 0, nproc = 1; + + MPI_Comm_size(*commworld, &nproc); + MPI_Comm_rank(*commworld, &myid); + + // cout << endl << "nbr de proc : " << nproc << " -- myid=" << myid << " -- world id=" << wr << endl; + + CMA_ES_MPI *optim = 0; + if (nargs[9]) + optim = new CMA_ES_MPI(ffJ, x, initialStdDevs, seed, popsize, commworld, (GetAny< string * >((*nargs[9])(stack)))->c_str( )); + else + optim = new CMA_ES_MPI(ffJ, x, initialStdDevs, seed, popsize, commworld); + if (!nargs[9]) { + optim->optimizer( ).sp.stopTolFun = stopTolFun; + optim->optimizer( ).sp.stopTolFunHist = stopTolFunHist; + optim->optimizer( ).sp.stopTolX = stopTolX; + optim->optimizer( ).sp.stopTolUpXFactor = stopTolUpXFactor; + long meval = arg(10, stack, static_cast< long >(optim->maxeval( ))); + long mgen = arg(11, stack, static_cast< long >(optim->maxgen( ))); + optim->optimizer( ).sp.stopMaxFunEvals = meval; + optim->optimizer( ).sp.stopMaxIter = mgen; + } + + (*optim)( ); + cost = optim->fitness( ); + x = KN_< double >(optim->xbestever( ), optim->dimension( )); + + delete optim; + closetheparam.eval(stack); // clean memory + WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 + return cost; // SetAny(0); Modif FH july 2005 + } + + operator aType( ) const { return atype< double >( ); } + }; + + E_F0 *code(const basicAC_F0 &args) const { return new E_CMA_ES(args, cas); } + + OptimCMA_ES(int c) : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; -basicAC_F0::name_and_type OptimCMA_ES::E_CMA_ES::name_param[]= -{ - {"seed", &typeid(long) }, - {"initialStdDev", &typeid(double) }, - {"initialStdDevs", &typeid(KN_) }, - {"stopTolFun", &typeid(double) }, - {"stopTolFunHist", &typeid(double) }, - {"stopTolX", &typeid(double) }, - {"stopTolUpXFactor",&typeid(double) }, - {"popsize", &typeid(long) }, - {"comm", &typeid(pcommworld)}, - {"paramFile", &typeid(string*) }, - {"stopMaxFunEval", &typeid(long) }, - {"stopMaxIter", &typeid(long) } - - //{"mu", &typeid(long) } +basicAC_F0::name_and_type OptimCMA_ES::E_CMA_ES::name_param[] = { + {"seed", &typeid(long)}, + {"initialStdDev", &typeid(double)}, + {"initialStdDevs", &typeid(KN_< double >)}, + {"stopTolFun", &typeid(double)}, + {"stopTolFunHist", &typeid(double)}, + {"stopTolX", &typeid(double)}, + {"stopTolUpXFactor", &typeid(double)}, + {"popsize", &typeid(long)}, + {"comm", &typeid(pcommworld)}, + {"paramFile", &typeid(string *)}, + {"stopMaxFunEval", &typeid(long)}, + {"stopMaxIter", &typeid(long)} + + //{"mu", &typeid(long) } }; /* --FH: class Init { public: Init(); };*/ +static void Load_Init( ) { Global.Add("cmaesMPI", "(", new OptimCMA_ES(1)); } -static void Load_Init() -{ - Global.Add("cmaesMPI","(",new OptimCMA_ES(1)); - -} - - - - - - - LOADFUNC(Load_Init) +LOADFUNC(Load_Init) diff --git a/plugin/mpi/parmetis.cpp b/plugin/mpi/parmetis.cpp index 243750fd5..268e27773 100644 --- a/plugin/mpi/parmetis.cpp +++ b/plugin/mpi/parmetis.cpp @@ -22,8 +22,10 @@ // E-MAIL : P. Jolivet // *INDENT-OFF* // +/* clang-format off */ //ff-c++-LIBRARY-dep: parmetis metis mpi //ff-c++-cpp-dep: +/* clang-format on */ // *INDENT-ON* // #include @@ -33,88 +35,79 @@ #define IDX_T MPI_INT #endif -template +template< class Type, class Mesh > class ParMETIS_Op : public E_F0mps { -public: - Expression part; - Expression pTh; - Expression lparts; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - ParMETIS_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : part(param1), pTh(param2), lparts(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } - AnyType operator()(Stack stack) const; -}; -template -basicAC_F0::name_and_type ParMETIS_Op::name_param[] = { - {"communicator", &typeid(pcommworld)}, - {"worker", &typeid(long)} + public: + Expression part; + Expression pTh; + Expression lparts; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + ParMETIS_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : part(param1), pTh(param2), lparts(param3) { args.SetNameParam(n_name_param, name_param, nargs); } + AnyType operator( )(Stack stack) const; }; -template +template< class Type, class Mesh > +basicAC_F0::name_and_type ParMETIS_Op< Type, Mesh >::name_param[] = {{"communicator", &typeid(pcommworld)}, {"worker", &typeid(long)}}; +template< class Type, class Mesh > class ParMETIS : public OneOperator { -public: - ParMETIS() : OneOperator(atype(), atype*>(), atype(), atype()) { } - E_F0* code(const basicAC_F0& args) const { - return new ParMETIS_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } + public: + ParMETIS( ) : OneOperator(atype< long >( ), atype< KN< Type >* >( ), atype< const Mesh* >( ), atype< long >( )) {} + E_F0* code(const basicAC_F0& args) const { return new ParMETIS_Op< Type, Mesh >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; -template -AnyType ParMETIS_Op::operator()(Stack stack) const { - KN* ptKN = GetAny*>((*part)(stack)); - idx_t nparts = GetAny((*lparts)(stack)); - Type* pt = *ptKN; - long n = ptKN->n; +template< class Type, class Mesh > +AnyType ParMETIS_Op< Type, Mesh >::operator( )(Stack stack) const { + KN< Type >* ptKN = GetAny< KN< Type >* >((*part)(stack)); + idx_t nparts = GetAny< long >((*lparts)(stack)); + Type* pt = *ptKN; + long n = ptKN->n; #ifdef __clang__ - idx_t* ptInt = new idx_t[n]; + idx_t* ptInt = new idx_t[n]; #else - idx_t* ptInt = sizeof(idx_t) <= sizeof(Type) ? reinterpret_cast(pt) : new idx_t[n]; + idx_t* ptInt = sizeof(idx_t) <= sizeof(Type) ? reinterpret_cast< idx_t* >(pt) : new idx_t[n]; #endif - std::fill_n(ptInt, n, 0); - MPI_Comm comm = nargs[0] ? *((MPI_Comm*)GetAny((*nargs[0])(stack))) : MPI_COMM_WORLD; - int worker = nargs[1] ? GetAny((*nargs[1])(stack)) : 0; - MPI_Comm workComm = comm; - if(worker == 0) - MPI_Comm_size(comm, &worker); - else { - int size; - MPI_Comm_size(comm, &size); - worker = std::min(size, worker); - MPI_Group worldGroup, workGroup; - MPI_Comm_group(workComm, &worldGroup); - int ranges[1][3]; - ranges[0][0] = 0; - ranges[0][1] = worker - 1; - ranges[0][2] = 1; - MPI_Group_range_incl(worldGroup, 1, ranges, &workGroup); - MPI_Comm_create(comm, workGroup, &workComm); - MPI_Group_free(&worldGroup); + std::fill_n(ptInt, n, 0); + MPI_Comm comm = nargs[0] ? *((MPI_Comm*)GetAny< pcommworld >((*nargs[0])(stack))) : MPI_COMM_WORLD; + int worker = nargs[1] ? GetAny< long >((*nargs[1])(stack)) : 0; + MPI_Comm workComm = comm; + if (worker == 0) + MPI_Comm_size(comm, &worker); + else { + int size; + MPI_Comm_size(comm, &size); + worker = std::min(size, worker); + MPI_Group worldGroup, workGroup; + MPI_Comm_group(workComm, &worldGroup); + int ranges[1][3]; + ranges[0][0] = 0; + ranges[0][1] = worker - 1; + ranges[0][2] = 1; + MPI_Group_range_incl(worldGroup, 1, ranges, &workGroup); + MPI_Comm_create(comm, workGroup, &workComm); + MPI_Group_free(&worldGroup); + } + int rank; + MPI_Comm_rank(comm, &rank); + if (rank < worker) { + idx_t* vtxdist = new idx_t[worker + 1]; + vtxdist[0] = 0; + for (int i = 1; i < worker; ++i) vtxdist[i] = vtxdist[i - 1] + n / worker; + vtxdist[worker] = n; + int loc = vtxdist[rank + 1] - vtxdist[rank]; + idx_t* xadg = new idx_t[loc + 1]; + const Mesh& Th(*GetAny< const Mesh* >((*pTh)(stack))); + idx_t nve = Mesh::Rd::d + 1; + std::vector< idx_t > adjncy; + adjncy.reserve(loc * nve); + xadg[0] = 0; + for (int k = vtxdist[rank]; k < vtxdist[rank + 1]; ++k) { + for (idx_t j = 0; j < nve; ++j) { + int l = j; + idx_t m = Th.ElementAdj(k, l); + if (k != m && m > 0) adjncy.push_back(m); + } + xadg[k + 1 - vtxdist[rank]] = adjncy.size( ); } - int rank; - MPI_Comm_rank(comm, &rank); - if(rank < worker) { - idx_t* vtxdist = new idx_t[worker + 1]; - vtxdist[0] = 0; - for(int i = 1; i < worker; ++i) - vtxdist[i] = vtxdist[i - 1] + n / worker; - vtxdist[worker] = n; - int loc = vtxdist[rank + 1] - vtxdist[rank]; - idx_t* xadg = new idx_t[loc + 1]; - const Mesh& Th(*GetAny((*pTh)(stack))); - idx_t nve = Mesh::Rd::d + 1; - std::vector adjncy; - adjncy.reserve(loc * nve); - xadg[0] = 0; - for(int k = vtxdist[rank]; k < vtxdist[rank + 1]; ++k) { - for(idx_t j = 0; j < nve; ++j) { - int l = j; - idx_t m = Th.ElementAdj(k, l); - if(k != m && m > 0) - adjncy.push_back(m); - } - xadg[k + 1 - vtxdist[rank]] = adjncy.size(); - } #if 0 for(int i = 0; i < worker; ++i) { MPI_Barrier(workComm); @@ -135,36 +128,33 @@ AnyType ParMETIS_Op::operator()(Stack stack) const { MPI_Barrier(workComm); } #endif - idx_t wgtflag = 0; - idx_t ncon = 1; - idx_t edgecut; - real_t* tpwgts = new real_t[nparts]; - for(int i = 0; i < nparts; ++i) - tpwgts[i] = 1.0 / static_cast(nparts); - real_t ubvec = 1.05; - idx_t* part = ptInt + vtxdist[rank]; - ParMETIS_V3_PartKway(vtxdist, xadg, adjncy.data(), NULL, NULL, &wgtflag, &wgtflag, &ncon, &nparts, tpwgts, &ubvec, &wgtflag, &edgecut, part, &workComm); - delete [] tpwgts; - delete [] xadg; - delete [] vtxdist; - } - MPI_Allreduce(MPI_IN_PLACE, ptInt, n, IDX_T, MPI_SUM, comm); - for(int i = n; i-- > 0; ) - pt[i] = ptInt[i]; + idx_t wgtflag = 0; + idx_t ncon = 1; + idx_t edgecut; + real_t* tpwgts = new real_t[nparts]; + for (int i = 0; i < nparts; ++i) tpwgts[i] = 1.0 / static_cast< real_t >(nparts); + real_t ubvec = 1.05; + idx_t* part = ptInt + vtxdist[rank]; + ParMETIS_V3_PartKway(vtxdist, xadg, adjncy.data( ), NULL, NULL, &wgtflag, &wgtflag, &ncon, &nparts, tpwgts, &ubvec, &wgtflag, &edgecut, part, &workComm); + delete[] tpwgts; + delete[] xadg; + delete[] vtxdist; + } + MPI_Allreduce(MPI_IN_PLACE, ptInt, n, IDX_T, MPI_SUM, comm); + for (int i = n; i-- > 0;) pt[i] = ptInt[i]; #if !defined(__clang__) - if(sizeof(idx_t) > sizeof(Type)) + if (sizeof(idx_t) > sizeof(Type)) #endif - delete [] ptInt; - if(nargs[1] && workComm != MPI_COMM_NULL) - MPI_Comm_free(&workComm); - return 0L; + delete[] ptInt; + if (nargs[1] && workComm != MPI_COMM_NULL) MPI_Comm_free(&workComm); + return 0L; } -static void Load_Init() { - Global.Add("parmetis", "(", new ParMETIS); - Global.Add("parmetis", "(", new ParMETIS); - Global.Add("parmetis", "(", new ParMETIS); - Global.Add("parmetis", "(", new ParMETIS); +static void Load_Init( ) { + Global.Add("parmetis", "(", new ParMETIS< long, Mesh >); + Global.Add("parmetis", "(", new ParMETIS< double, Mesh >); + Global.Add("parmetis", "(", new ParMETIS< long, Mesh3 >); + Global.Add("parmetis", "(", new ParMETIS< double, Mesh3 >); } LOADFUNC(Load_Init) diff --git a/plugin/mpi/parmmg.cpp b/plugin/mpi/parmmg.cpp index 32e240911..548cf2a3e 100644 --- a/plugin/mpi/parmmg.cpp +++ b/plugin/mpi/parmmg.cpp @@ -1,5 +1,7 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: parmmg mmg mpi metis scotch //ff-c++-cpp-dep: +/* clang-format on */ #include "ff++.hpp" #include "memory.h" @@ -8,39 +10,35 @@ using namespace Fem2D; -int ffmesh_to_PMMG_pParMesh(const Mesh3 &Th, PMMG_pParMesh& mesh, bool distributed) { - int nVertices = Th.nv; - int nTetrahedra = Th.nt; - int nPrisms = 0; - int nTriangles = Th.nbe; +int ffmesh_to_PMMG_pParMesh(const Mesh3 &Th, PMMG_pParMesh &mesh, bool distributed) { + int nVertices = Th.nv; + int nTetrahedra = Th.nt; + int nPrisms = 0; + int nTriangles = Th.nbe; int nQuadrilaterals = 0; - int nEdges = 0; + int nEdges = 0; - if(mesh->myrank == mesh->info.root || distributed) { - if ( PMMG_Set_meshSize(mesh,nVertices,nTetrahedra,nPrisms,nTriangles, - nQuadrilaterals,nEdges) != 1 ) { + if (mesh->myrank == mesh->info.root || distributed) { + if (PMMG_Set_meshSize(mesh, nVertices, nTetrahedra, nPrisms, nTriangles, nQuadrilaterals, nEdges) != 1) { exit(EXIT_FAILURE); } for (int k = 0; k < Th.nv; k++) { - if ( PMMG_Set_vertex(mesh,Th.vertices[k].x,Th.vertices[k].y, - Th.vertices[k].z, Th.vertices[k].lab, k+1) != 1 ) { + if (PMMG_Set_vertex(mesh, Th.vertices[k].x, Th.vertices[k].y, Th.vertices[k].z, Th.vertices[k].lab, k + 1) != 1) { exit(EXIT_FAILURE); } } for (int k = 0; k < Th.nt; k++) { const Tet &K(Th.elements[k]); - if ( PMMG_Set_tetrahedron(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1, - Th.operator()(K[2])+1,Th.operator()(K[3])+1,K.lab,k+1) != 1 ) { + if (PMMG_Set_tetrahedron(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, Th.operator( )(K[3]) + 1, K.lab, k + 1) != 1) { exit(EXIT_FAILURE); } } for (int k = 0; k < Th.nbe; k++) { const Triangle3 &K(Th.be(k)); - if ( PMMG_Set_triangle(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1,Th.operator()(K[2])+1, - K.lab,k+1) != 1 ) { + if (PMMG_Set_triangle(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, K.lab, k + 1) != 1) { exit(EXIT_FAILURE); } } @@ -48,77 +46,67 @@ int ffmesh_to_PMMG_pParMesh(const Mesh3 &Th, PMMG_pParMesh& mesh, bool distribut return 0; } -int PMMG_pParMesh_to_ffmesh(const PMMG_pParMesh& mesh, Mesh3 *&T_TH3, bool distributed) { - int ier; +int PMMG_pParMesh_to_ffmesh(const PMMG_pParMesh &mesh, Mesh3 *&T_TH3, bool distributed) { + int ier; - int nVertices = 0; - int nTetrahedra = 0; - int nTriangles = 0; - int nEdges = 0; + int nVertices = 0; + int nTetrahedra = 0; + int nTriangles = 0; + int nEdges = 0; - if(mesh->myrank == mesh->info.root || distributed) { - if ( PMMG_Get_meshSize(mesh,&nVertices,&nTetrahedra,NULL,&nTriangles,NULL, - &nEdges) !=1 ) { - ier = MMG5_STRONGFAILURE; - } + if (mesh->myrank == mesh->info.root || distributed) { + if (PMMG_Get_meshSize(mesh, &nVertices, &nTetrahedra, NULL, &nTriangles, NULL, &nEdges) != 1) { + ier = MMG5_STRONGFAILURE; + } - Vertex3 *v = new Vertex3[nVertices]; - Tet *t = new Tet[nTetrahedra]; - Tet *tt = t; - Triangle3 *b = new Triangle3[nTriangles]; - Triangle3 *bb = b; - int k; + Vertex3 *v = new Vertex3[nVertices]; + Tet *t = new Tet[nTetrahedra]; + Tet *tt = t; + Triangle3 *b = new Triangle3[nTriangles]; + Triangle3 *bb = b; + int k; - int corner, required; + int corner, required; - for (k = 0; k < nVertices; k++) { - if ( PMMG_Get_vertex(mesh,&(v[k].x),&(v[k].y),&(v[k].z), - &(v[k].lab),&(corner),&(required)) != 1 ) { - cout << "Unable to get mesh vertex " << k << endl; - ier = MMG5_STRONGFAILURE; - } + for (k = 0; k < nVertices; k++) { + if (PMMG_Get_vertex(mesh, &(v[k].x), &(v[k].y), &(v[k].z), &(v[k].lab), &(corner), &(required)) != 1) { + cout << "Unable to get mesh vertex " << k << endl; + ier = MMG5_STRONGFAILURE; } + } - for ( k=0; kset(v, iv, lab); + for (k = 0; k < nTetrahedra; k++) { + int iv[4], lab; + if (PMMG_Get_tetrahedron(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(iv[3]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh tetra " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 4; i++) iv[i]--; + tt++->set(v, iv, lab); + } - for ( k=0; kset(v, iv, lab); + for (k = 0; k < nTriangles; k++) { + int iv[3], lab; + if (PMMG_Get_triangle(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh triangle " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 3; i++) iv[i]--; + if (lab == 0 && distributed) lab = -111111; + bb++->set(v, iv, lab); + } - T_TH3 = new Mesh3(nVertices, nTetrahedra, nTriangles, v, t, b, 1, 1); + T_TH3 = new Mesh3(nVertices, nTetrahedra, nTriangles, v, t, b, 1, 1); - if (verbosity > 1) { - cout << "transformation maillage --> mesh3 " << endl; - cout << "vertices =" << nVertices << endl; - cout << "tetrahedrons =" << nTetrahedra << endl; - cout << "triangles =" << nTriangles << endl; - cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; - } + if (verbosity > 1) { + cout << "transformation maillage --> mesh3 " << endl; + cout << "vertices =" << nVertices << endl; + cout << "tetrahedrons =" << nTetrahedra << endl; + cout << "triangles =" << nTriangles << endl; + cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; } - return 0; + } + return 0; } class parmmg_Op : public E_F0mps { @@ -128,25 +116,15 @@ class parmmg_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: parmmg_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -160,48 +138,46 @@ class parmmg_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type parmmg_Op::name_param[] = { -{"metric" , &typeid(KN< double > *)}, -{"comm" , &typeid(pcommworld)}, -{"verbose" , &typeid(long)},/*!< [-10..10], Tune level of verbosity */ -{"mmgVerbose" , &typeid(long)},/*!< [-10..10], Tune level of verbosity of Mmg */ -{"mem" , &typeid(long)},/*!< [n/-1], Set memory size to n Mbytes or keep the default value */ -{"debug" , &typeid(bool)},/*!< [1/0], Turn on/off debug mode */ -{"mmgDebug" , &typeid(bool)},/*!< [1/0], Turn on/off debug mode */ -{"angle" , &typeid(bool)},/*!< [1/0], Turn on/off angle detection */ -{"iso" , &typeid(bool)},/*!< [1/0], Level-set meshing */ -{"lag" , &typeid(long)},/*!< [-1/0/1/2], Lagrangian option */ -{"opnbdy" , &typeid(bool)},/*!< [0/1], Enable preservation of open boundaries */ -{"optim" , &typeid(bool)},/*!< [1/0], Optimize mesh keeping its initial edge sizes */ -{"optimLES" , &typeid(bool)},/*!< [1/0], Strong mesh optimization for Les computations */ -{"noinsert" , &typeid(bool)},/*!< [1/0], Avoid/allow point insertion */ -{"noswap" , &typeid(bool)},/*!< [1/0], Avoid/allow edge or face flipping */ -{"nomove" , &typeid(bool)},/*!< [1/0], Avoid/allow point relocation */ -{"nosurf" , &typeid(bool)},/*!< [1/0], Avoid/allow surface modifications */ -{"anisosize" , &typeid(bool)},/*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ -{"octree" , &typeid(long)},/*!< [n], Specify the max number of points per octree cell (DELAUNAY) */ -{"meshSize" , &typeid(long)},/*!< [n], Target mesh size of Mmg (advanced use) */ -{"metisRatio" , &typeid(long)},/*!< [n], wanted ratio # mesh / # metis super nodes (advanced use) */ -{"ifcLayers" , &typeid(long)},/*!< [n], Number of layers of interface displacement */ -{"groupsRatio" , &typeid(double)},/*!< [val], Allowed imbalance between current and desired groups size */ -{"niter" , &typeid(long)},/*!< [n], Set the number of remeshing iterations */ -{"angleDetection" , &typeid(double)},/*!< [val], Value for angle detection */ -{"hmin" , &typeid(double)},/*!< [val], Minimal mesh size */ -{"hmax" , &typeid(double)},/*!< [val], Maximal mesh size */ -{"hsiz" , &typeid(double)},/*!< [val], Constant mesh size */ -{"hausd" , &typeid(double)},/*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ -{"hgrad" , &typeid(double)},/*!< [val], Control gradation */ -{"hgradreq" , &typeid(double)},/*!< [val], Control gradation from required entities */ -{"ls" , &typeid(double)},/*!< [val], Value of level-set */ -{"requiredTriangle" , &typeid(KN*)},/*!< [val], References of surfaces with required triangles */ -{"localParameter" , &typeid(KNM*)},/*!< [val], Local parameters on given surfaces */ -{"nodeCommunicators" , &typeid(KN>*)}, -{"neighbors" , &typeid(KN*)} -}; +basicAC_F0::name_and_type parmmg_Op::name_param[] = {{"metric", &typeid(KN< double > *)}, + {"comm", &typeid(pcommworld)}, + {"verbose", &typeid(long)}, /*!< [-10..10], Tune level of verbosity */ + {"mmgVerbose", &typeid(long)}, /*!< [-10..10], Tune level of verbosity of Mmg */ + {"mem", &typeid(long)}, /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + {"debug", &typeid(bool)}, /*!< [1/0], Turn on/off debug mode */ + {"mmgDebug", &typeid(bool)}, /*!< [1/0], Turn on/off debug mode */ + {"angle", &typeid(bool)}, /*!< [1/0], Turn on/off angle detection */ + {"iso", &typeid(bool)}, /*!< [1/0], Level-set meshing */ + {"lag", &typeid(long)}, /*!< [-1/0/1/2], Lagrangian option */ + {"opnbdy", &typeid(bool)}, /*!< [0/1], Enable preservation of open boundaries */ + {"optim", &typeid(bool)}, /*!< [1/0], Optimize mesh keeping its initial edge sizes */ + {"optimLES", &typeid(bool)}, /*!< [1/0], Strong mesh optimization for Les computations */ + {"noinsert", &typeid(bool)}, /*!< [1/0], Avoid/allow point insertion */ + {"noswap", &typeid(bool)}, /*!< [1/0], Avoid/allow edge or face flipping */ + {"nomove", &typeid(bool)}, /*!< [1/0], Avoid/allow point relocation */ + {"nosurf", &typeid(bool)}, /*!< [1/0], Avoid/allow surface modifications */ + {"anisosize", &typeid(bool)}, /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ + {"octree", &typeid(long)}, /*!< [n], Specify the max number of points per octree cell (DELAUNAY) */ + {"meshSize", &typeid(long)}, /*!< [n], Target mesh size of Mmg (advanced use) */ + {"metisRatio", &typeid(long)}, /*!< [n], wanted ratio # mesh / # metis super nodes (advanced use) */ + {"ifcLayers", &typeid(long)}, /*!< [n], Number of layers of interface displacement */ + {"groupsRatio", &typeid(double)}, /*!< [val], Allowed imbalance between current and desired groups size */ + {"niter", &typeid(long)}, /*!< [n], Set the number of remeshing iterations */ + {"angleDetection", &typeid(double)}, /*!< [val], Value for angle detection */ + {"hmin", &typeid(double)}, /*!< [val], Minimal mesh size */ + {"hmax", &typeid(double)}, /*!< [val], Maximal mesh size */ + {"hsiz", &typeid(double)}, /*!< [val], Constant mesh size */ + {"hausd", &typeid(double)}, /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + {"hgrad", &typeid(double)}, /*!< [val], Control gradation */ + {"hgradreq", &typeid(double)}, /*!< [val], Control gradation from required entities */ + {"ls", &typeid(double)}, /*!< [val], Value of level-set */ + {"requiredTriangle", &typeid(KN< long > *)}, /*!< [val], References of surfaces with required triangles */ + {"localParameter", &typeid(KNM< double > *)}, /*!< [val], Local parameters on given surfaces */ + {"nodeCommunicators", &typeid(KN< KN< long > > *)}, + {"neighbors", &typeid(KN< long > *)}}; class parmmg_ff : public OneOperator { public: - parmmg_ff( ) : OneOperator(atype< const Mesh3* >( ), atype< const Mesh3* >( )) {} + parmmg_ff( ) : OneOperator(atype< const Mesh3 * >( ), atype< const Mesh3 * >( )) {} E_F0 *code(const basicAC_F0 &args) const { return new parmmg_Op(args, t[0]->CastTo(args[0])); } }; @@ -226,10 +202,10 @@ AnyType parmmg_Op::operator( )(Stack stack) const { pcommworld pcomm = 0; if (nargs[1]) { - pcomm = GetAny((*nargs[1])(stack)); + pcomm = GetAny< pcommworld >((*nargs[1])(stack)); } - MPI_Comm comm = pcomm ? *(MPI_Comm*)pcomm : MPI_COMM_WORLD; + MPI_Comm comm = pcomm ? *(MPI_Comm *)pcomm : MPI_COMM_WORLD; PMMG_pParMesh mesh; MMG5_pSol sol; @@ -239,69 +215,63 @@ AnyType parmmg_Op::operator( )(Stack stack) const { sol = nullptr; met = nullptr; - PMMG_Init_parMesh(PMMG_ARG_start, - PMMG_ARG_ppParMesh,&mesh, - PMMG_ARG_pMesh,PMMG_ARG_pMet, - PMMG_ARG_dim,3,PMMG_ARG_MPIComm,comm, - PMMG_ARG_end); + PMMG_Init_parMesh(PMMG_ARG_start, PMMG_ARG_ppParMesh, &mesh, PMMG_ARG_pMesh, PMMG_ARG_pMet, PMMG_ARG_dim, 3, PMMG_ARG_MPIComm, comm, PMMG_ARG_end); - KN< KN< long > >* communicators = nargs[34] ? GetAny< KN< KN< long > >* >((*nargs[34])(stack)) : 0; + KN< KN< long > > *communicators = nargs[34] ? GetAny< KN< KN< long > > * >((*nargs[34])(stack)) : 0; ffmesh_to_PMMG_pParMesh(Th, mesh, communicators != NULL); int root = mesh->info.root; int myrank = mesh->myrank; - if(myrank == root || communicators != NULL) { + if (myrank == root || communicators != NULL) { if (pmetric && pmetric->N( ) > 0) { const KN< double > &metric = *pmetric; if (metric.N( ) == Th.nv) { - if ( PMMG_Set_metSize(mesh,MMG5_Vertex,Th.nv,MMG5_Scalar) != 1 ) { + if (PMMG_Set_metSize(mesh, MMG5_Vertex, Th.nv, MMG5_Scalar) != 1) { printf("Unable to allocate the metric array.\n"); exit(EXIT_FAILURE); } - if ( PMMG_Set_scalarMets(mesh,metric) != 1 ) { + if (PMMG_Set_scalarMets(mesh, metric) != 1) { printf("Unable to set metric.\n"); exit(EXIT_FAILURE); } - } - else { - if ( PMMG_Set_metSize(mesh,MMG5_Vertex,Th.nv,MMG5_Tensor) != 1 ) { + } else { + if (PMMG_Set_metSize(mesh, MMG5_Vertex, Th.nv, MMG5_Tensor) != 1) { printf("Unable to allocate the metric array.\n"); exit(EXIT_FAILURE); } static const int perm[6] = {0, 1, 3, 2, 4, 5}; - for (int k=0; k *prequiredTriangle = 0; - KNM< double > *plocalParameter = 0; - if (nargs[32]) { - prequiredTriangle = GetAny< KN< long > * >((*nargs[32])(stack)); - } - if (nargs[33]) { - plocalParameter = GetAny< KNM< double > * >((*nargs[33])(stack)); - } + KN< long > *prequiredTriangle = 0; + KNM< double > *plocalParameter = 0; + if (nargs[32]) { + prequiredTriangle = GetAny< KN< long > * >((*nargs[32])(stack)); + } + if (nargs[33]) { + plocalParameter = GetAny< KNM< double > * >((*nargs[33])(stack)); + } if (prequiredTriangle && prequiredTriangle->N( ) > 0) { const KN< long > &requiredTriangle = *prequiredTriangle; - std::sort(requiredTriangle + 0, requiredTriangle + requiredTriangle.N()); + std::sort(requiredTriangle + 0, requiredTriangle + requiredTriangle.N( )); int nt; - if ( PMMG_Get_meshSize(mesh,NULL,NULL,NULL,&nt,NULL,NULL) !=1 ) { + if (PMMG_Get_meshSize(mesh, NULL, NULL, NULL, &nt, NULL, NULL) != 1) { exit(EXIT_FAILURE); } - for (int k=1; k<=nt; k++) { + for (int k = 1; k <= nt; k++) { int ref, dummy; - if ( PMMG_Get_triangle(mesh,&dummy,&dummy,&dummy, - &ref,NULL) != 1 ) { + if (PMMG_Get_triangle(mesh, &dummy, &dummy, &dummy, &ref, NULL) != 1) { exit(EXIT_FAILURE); } - if (std::binary_search(requiredTriangle + 0, requiredTriangle + requiredTriangle.N(), ref)) { - if ( PMMG_Set_requiredTriangle(mesh,k) != 1 ) { + if (std::binary_search(requiredTriangle + 0, requiredTriangle + requiredTriangle.N( ), ref)) { + if (PMMG_Set_requiredTriangle(mesh, k) != 1) { exit(EXIT_FAILURE); } } @@ -309,105 +279,129 @@ AnyType parmmg_Op::operator( )(Stack stack) const { } if (plocalParameter && plocalParameter->M( ) > 0) { const KNM< double > &localParameter = *plocalParameter; - ffassert(localParameter.N() == 4); - if ( PMMG_Set_iparameter(mesh,/*sol,*/PMMG_IPARAM_numberOfLocalParam,localParameter.M()) != 1 ) { + ffassert(localParameter.N( ) == 4); + if (PMMG_Set_iparameter(mesh, /*sol,*/ PMMG_IPARAM_numberOfLocalParam, localParameter.M( )) != 1) { exit(EXIT_FAILURE); } - for(int j = 0; j < localParameter.M(); ++j) { - if ( PMMG_Set_localParameter(mesh,/*sol,*/MMG5_Triangle,localParameter(0,j),localParameter(1,j),localParameter(2,j),localParameter(3,j)) != 1 ) { + for (int j = 0; j < localParameter.M( ); ++j) { + if (PMMG_Set_localParameter(mesh, /*sol,*/ MMG5_Triangle, localParameter(0, j), localParameter(1, j), localParameter(2, j), localParameter(3, j)) != 1) { exit(EXIT_FAILURE); } } } } - int i=2; + int i = 2; if (!verbosity) { - PMMG_Set_iparameter(mesh,PMMG_IPARAM_verbose, -1); - PMMG_Set_iparameter(mesh,PMMG_IPARAM_mmgVerbose, -1); + PMMG_Set_iparameter(mesh, PMMG_IPARAM_verbose, -1); + PMMG_Set_iparameter(mesh, PMMG_IPARAM_mmgVerbose, -1); } - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_verbose, arg(i,stack,0L)); i++; /*!< [-10..10], Tune level of verbosity */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_mmgVerbose, arg(i,stack,0L)); i++; /*!< [-10..10], Tune level of verbosity of Mmg */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_mem, arg(i,stack,0L)); i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_debug, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off debug mode */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_mmgDebug, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off debug mode */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_angle, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off angle detection */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_iso, arg(i,stack,false)); i++; /*!< [1/0], Level-set meshing */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_lag, arg(i,stack,0L)); i++; /*!< [-1/0/1/2], Lagrangian option */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_opnbdy, arg(i,stack,false)); i++; /*!< [0/1], Enable preservation of open boundaries */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_optim, arg(i,stack,false)); i++; /*!< [1/0], Optimize mesh keeping its initial edge sizes */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_optimLES, arg(i,stack,false)); i++; /*!< [1/0], Strong mesh optimization for Les computations */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_noinsert, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point insertion */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_noswap, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow edge or face flipping */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_nomove, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point relocation */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_nosurf, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow surface modifications */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_anisosize, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_octree, arg(i,stack,0L)); i++; /*!< [n], Specify the max number of points per octree cell (DELAUNAY) */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_meshSize, arg(i,stack,0L)); i++; /*!< [n], Target mesh size of Mmg (advanced use) */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_metisRatio, arg(i,stack,0L)); i++; /*!< [n], wanted ratio # mesh / # metis super nodes (advanced use) */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_ifcLayers, arg(i,stack,0L)); i++; /*!< [n], Number of layers of interface displacement */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_groupsRatio, arg(i,stack,0.)); i++; /*!< [val], Allowed imbalance between current and desired groups size */ - if (nargs[i]) PMMG_Set_iparameter(mesh,PMMG_IPARAM_niter, arg(i,stack,0L)); i++; /*!< [n], Set the number of remeshing iterations */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_angleDetection,arg(i,stack,0.)); i++; /*!< [val], Value for angle detection */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hmin, arg(i,stack,0.)); i++; /*!< [val], Minimal mesh size */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hmax, arg(i,stack,0.)); i++; /*!< [val], Maximal mesh size */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hsiz, arg(i,stack,0.)); i++; /*!< [val], Constant mesh size */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hausd, arg(i,stack,0.)); i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hgrad, arg(i,stack,0.)); i++; /*!< [val], Control gradation */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_hgradreq, arg(i,stack,0.)); i++; /*!< [val], Control gradation from required entities */ - if (nargs[i]) PMMG_Set_dparameter(mesh,PMMG_DPARAM_ls, arg(i,stack,0.)); i++; /*!< [val], Value of level-set */ - - if(communicators != NULL) { + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_verbose, arg(i, stack, 0L)); + i++; /*!< [-10..10], Tune level of verbosity */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_mmgVerbose, arg(i, stack, 0L)); + i++; /*!< [-10..10], Tune level of verbosity of Mmg */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_mem, arg(i, stack, 0L)); + i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_debug, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off debug mode */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_mmgDebug, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off debug mode */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_angle, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off angle detection */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_iso, arg(i, stack, false)); + i++; /*!< [1/0], Level-set meshing */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_lag, arg(i, stack, 0L)); + i++; /*!< [-1/0/1/2], Lagrangian option */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_opnbdy, arg(i, stack, false)); + i++; /*!< [0/1], Enable preservation of open boundaries */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_optim, arg(i, stack, false)); + i++; /*!< [1/0], Optimize mesh keeping its initial edge sizes */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_optimLES, arg(i, stack, false)); + i++; /*!< [1/0], Strong mesh optimization for Les computations */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_noinsert, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point insertion */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_noswap, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow edge or face flipping */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_nomove, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point relocation */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_nosurf, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow surface modifications */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_anisosize, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_octree, arg(i, stack, 0L)); + i++; /*!< [n], Specify the max number of points per octree cell (DELAUNAY) */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_meshSize, arg(i, stack, 0L)); + i++; /*!< [n], Target mesh size of Mmg (advanced use) */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_metisRatio, arg(i, stack, 0L)); + i++; /*!< [n], wanted ratio # mesh / # metis super nodes (advanced use) */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_ifcLayers, arg(i, stack, 0L)); + i++; /*!< [n], Number of layers of interface displacement */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_groupsRatio, arg(i, stack, 0.)); + i++; /*!< [val], Allowed imbalance between current and desired groups size */ + if (nargs[i]) PMMG_Set_iparameter(mesh, PMMG_IPARAM_niter, arg(i, stack, 0L)); + i++; /*!< [n], Set the number of remeshing iterations */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_angleDetection, arg(i, stack, 0.)); + i++; /*!< [val], Value for angle detection */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hmin, arg(i, stack, 0.)); + i++; /*!< [val], Minimal mesh size */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hmax, arg(i, stack, 0.)); + i++; /*!< [val], Maximal mesh size */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hsiz, arg(i, stack, 0.)); + i++; /*!< [val], Constant mesh size */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hausd, arg(i, stack, 0.)); + i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hgrad, arg(i, stack, 0.)); + i++; /*!< [val], Control gradation */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_hgradreq, arg(i, stack, 0.)); + i++; /*!< [val], Control gradation from required entities */ + if (nargs[i]) PMMG_Set_dparameter(mesh, PMMG_DPARAM_ls, arg(i, stack, 0.)); + i++; /*!< [val], Value of level-set */ + + if (communicators != NULL) { /* Set API mode */ - if( !PMMG_Set_iparameter( mesh, PMMG_IPARAM_APImode, PMMG_APIDISTRIB_nodes ) ) { + if (!PMMG_Set_iparameter(mesh, PMMG_IPARAM_APImode, PMMG_APIDISTRIB_nodes)) { exit(EXIT_FAILURE); } /* Set the number of interfaces */ - if( !PMMG_Set_numberOfNodeCommunicators(mesh, communicators->operator[](0).N()) ) { + if (!PMMG_Set_numberOfNodeCommunicators(mesh, communicators->operator[](0).N( ))) { exit(EXIT_FAILURE); } /* Loop on each interface (proc pair) seen by the current rank) */ - for(int icomm=0; icommoperator[](0).N(); icomm++ ) { + for (int icomm = 0; icomm < communicators->operator[](0).N( ); icomm++) { /* Set nb. of entities on interface and rank of the outward proc */ - if( !PMMG_Set_ithNodeCommunicatorSize(mesh, icomm, - communicators->operator[](0)[icomm], - communicators->operator[](1 + 2 * icomm).N()) ) { + if (!PMMG_Set_ithNodeCommunicatorSize(mesh, icomm, communicators->operator[](0)[icomm], communicators->operator[](1 + 2 * icomm).N( ))) { exit(EXIT_FAILURE); } /* Set local and global index for each entity on the interface */ - KN local = communicators->operator[](1 + 2 * icomm); - KN global = communicators->operator[](2 + 2 * icomm); - if( !PMMG_Set_ithNodeCommunicator_nodes(mesh, icomm, - local.operator int*(), - global.operator int*(), 1) ) { + KN< int > local = communicators->operator[](1 + 2 * icomm); + KN< int > global = communicators->operator[](2 + 2 * icomm); + if (!PMMG_Set_ithNodeCommunicator_nodes(mesh, icomm, local.operator int *( ), global.operator int *( ), 1)) { exit(EXIT_FAILURE); } } } int ier = communicators == NULL ? PMMG_parmmglib_centralized(mesh) : PMMG_parmmglib_distributed(mesh); - if( ier == PMMG_STRONGFAILURE ) exit(EXIT_FAILURE); + if (ier == PMMG_STRONGFAILURE) exit(EXIT_FAILURE); KN< long > *pneighbors = 0; if (nargs[35]) { pneighbors = GetAny< KN< long > * >((*nargs[35])(stack)); - int icomm,i; + int icomm, i; int n_node_comm_out; int nitem_node_comm_out; int color_node_out; /* Get number of node interfaces */ - ier = PMMG_Get_numberOfNodeCommunicators(mesh,&n_node_comm_out); + ier = PMMG_Get_numberOfNodeCommunicators(mesh, &n_node_comm_out); pneighbors->resize(n_node_comm_out); /* Get outward proc rank and number of nodes on each interface */ - for( icomm = 0; icomm < n_node_comm_out; icomm++ ) { - ier = PMMG_Get_ithNodeCommunicatorSize(mesh, icomm, - &color_node_out, - &nitem_node_comm_out); + for (icomm = 0; icomm < n_node_comm_out; icomm++) { + ier = PMMG_Get_ithNodeCommunicatorSize(mesh, icomm, &color_node_out, &nitem_node_comm_out); pneighbors->operator[](icomm) = color_node_out; } } @@ -415,27 +409,23 @@ AnyType parmmg_Op::operator( )(Stack stack) const { PMMG_pParMesh_to_ffmesh(mesh, Th_T, communicators != NULL); - PMMG_Free_all(PMMG_ARG_start, - PMMG_ARG_ppParMesh, &mesh, - PMMG_ARG_end); - if(communicators == NULL) { + PMMG_Free_all(PMMG_ARG_start, PMMG_ARG_ppParMesh, &mesh, PMMG_ARG_end); + if (communicators == NULL) { Serialize *buf = 0; long nbsize = 0; if (myrank == root) { - buf = new Serialize((*Th_T).serialize()); - nbsize = buf->size(); + buf = new Serialize((*Th_T).serialize( )); + nbsize = buf->size( ); } - MPI_Bcast(reinterpret_cast(&nbsize), 1, MPI_LONG, root, comm); - if (myrank != root) - buf = new Serialize(nbsize, Fem2D::GenericMesh_magicmesh); - MPI_Bcast(reinterpret_cast((char *)(*buf)), nbsize, MPI_BYTE, root, comm); - if (myrank != root) - Th_T = new Fem2D::Mesh3(*buf); + MPI_Bcast(reinterpret_cast< void * >(&nbsize), 1, MPI_LONG, root, comm); + if (myrank != root) buf = new Serialize(nbsize, Fem2D::GenericMesh_magicmesh); + MPI_Bcast(reinterpret_cast< void * >((char *)(*buf)), nbsize, MPI_BYTE, root, comm); + if (myrank != root) Th_T = new Fem2D::Mesh3(*buf); delete buf; } - Th_T->BuildGTree(); + Th_T->BuildGTree( ); Add2StackOfPtr2FreeRC(stack, Th_T); return Th_T; diff --git a/plugin/seq/BEC.cpp b/plugin/seq/BEC.cpp index 61ec62997..80e883d80 100644 --- a/plugin/seq/BEC.cpp +++ b/plugin/seq/BEC.cpp @@ -155,26 +155,11 @@ static void init( ) { cout << "LOAD: BEC" << endl; } - Global.Add( - "BECtrap", "(", - new OneOperator1s_< double, KN< double > *, E_F_F0s_< double, KN< double > *, E_F0mps > >( - BECtrap)); - Global.Add( - "GPvortex", "(", - new OneOperator3s_< Complex, double, double, double, - E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(GPvortex)); - Global.Add( - "GPvortices", "(", - new OneOperator1s_< Complex, KNM_< double >, E_F_F0s_< Complex, KNM_< double >, E_F0mps > >( - GPvortices)); - Global.Add( - "dxGPvortex", "(", - new OneOperator3s_< Complex, double, double, double, - E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(dxGPvortex)); - Global.Add( - "dyGPvortex", "(", - new OneOperator3s_< Complex, double, double, double, - E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(dyGPvortex)); + Global.Add("BECtrap", "(", new OneOperator1s_< double, KN< double > *, E_F_F0s_< double, KN< double > *, E_F0mps > >(BECtrap)); + Global.Add("GPvortex", "(", new OneOperator3s_< Complex, double, double, double, E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(GPvortex)); + Global.Add("GPvortices", "(", new OneOperator1s_< Complex, KNM_< double >, E_F_F0s_< Complex, KNM_< double >, E_F0mps > >(GPvortices)); + Global.Add("dxGPvortex", "(", new OneOperator3s_< Complex, double, double, double, E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(dxGPvortex)); + Global.Add("dyGPvortex", "(", new OneOperator3s_< Complex, double, double, double, E_F_F0F0F0s_< Complex, double, double, double, E_F0mps > >(dyGPvortex)); } LOADFUNC(init); diff --git a/plugin/seq/BasicMath.h b/plugin/seq/BasicMath.h index 894578968..3cc605666 100644 --- a/plugin/seq/BasicMath.h +++ b/plugin/seq/BasicMath.h @@ -84,9 +84,13 @@ inline int smallmod(int a, int N) { #else #define assert_msg(condition, message) assert(condition) #define try_debug_msg(instructions, message) \ - { instructions; } + { \ + instructions; \ + } #define try_debug(instructions) \ - { instructions; } + { \ + instructions; \ + } #endif /*! @@ -158,8 +162,7 @@ inline ostream_math operator<<(ostream_math f, double x) { } template< class ForwardIterator > -void print_array(ostream_math f, ForwardIterator first, ForwardIterator last, - bool one_per_line = false) { +void print_array(ostream_math f, ForwardIterator first, ForwardIterator last, bool one_per_line = false) { string sep = one_per_line ? ",\n" : ","; f << "{"; diff --git a/plugin/seq/BernardiRaugel.cpp b/plugin/seq/BernardiRaugel.cpp index 611b77fac..5b4840a1b 100644 --- a/plugin/seq/BernardiRaugel.cpp +++ b/plugin/seq/BernardiRaugel.cpp @@ -52,7 +52,7 @@ namespace Fem2D { 1, // Number of sub finite element 6 + 3 * (2 + 2), // Number kPi of coefficients to build the interpolation 9, // number nPi of integration points to build the interpolation - 0 // Array to store the coefficient alpha_k to build the interpolator + 0 // Array to store the coefficient alpha_k to build the interpolator ) { const double gauss1 = (1. - sqrt(1. / 3.)) / 2; const double gauss2 = 1. - gauss1; @@ -89,15 +89,12 @@ namespace Fem2D { assert(pij_alpha.N( ) == kk); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; // Data array - int TypeOfFE_P2BRLagrange::Data[] = {0, 0, 1, 1, 2, 2, 3, 4, 5, 0, 1, 0, 1, 0, 1, 0, 0, - 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 9, 9}; + int TypeOfFE_P2BRLagrange::Data[] = {0, 0, 1, 1, 2, 2, 3, 4, 5, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 9, 9}; /*! * \brief Define alpha k @@ -134,8 +131,7 @@ namespace Fem2D { * \param val RNMK_ */ // Shape function - void TypeOfFE_P2BRLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P2BRLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; // int_e_1 l0*l0 = |e_1|/3 and int_e_1 l0*l1 = |e_1|/6 @@ -144,8 +140,7 @@ namespace Fem2D { double l2E[3] = {(E[0], E[0]), (E[1], E[1]), (E[2], E[2])}; // double lE[3] = {sqrt(l2E[0]), sqrt(l2E[1]), sqrt(l2E[2])}; double sgE[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; - R2 cN[3] = {E[0].perp( ) * (6. * sgE[0] / l2E[0]), E[1].perp( ) * (6. * sgE[1] / l2E[1]), - E[2].perp( ) * (6. * sgE[2] / l2E[2])}; + R2 cN[3] = {E[0].perp( ) * (6. * sgE[0] / l2E[0]), E[1].perp( ) * (6. * sgE[1] / l2E[1]), E[2].perp( ) * (6. * sgE[2] / l2E[2])}; val = 0; @@ -251,12 +246,11 @@ namespace Fem2D { { int k[6] = {6 + 1, 6 + 1, 6 + 2, 6 + 2, 6 + 0, 6 + 0}; int l[6] = {6 + 2, 6 + 2, 6 + 0, 6 + 0, 6 + 1, 6 + 1}; - R2 eN[3] = {E[0].perp( ) * (0.5 * sgE[0]), E[1].perp( ) * (0.5 * sgE[1]), - E[2].perp( ) * (0.5 * sgE[2])}; + R2 eN[3] = {E[0].perp( ) * (0.5 * sgE[0]), E[1].perp( ) * (0.5 * sgE[1]), E[2].perp( ) * (0.5 * sgE[2])}; double a[6] = {eN[1].x, eN[1].y, eN[2].x, eN[2].y, eN[0].x, eN[0].y}; double b[6] = {eN[2].x, eN[2].y, eN[0].x, eN[0].y, eN[1].x, eN[1].y}; int nop = 0; - int vop[last_operatortype] = {}; + int vop[last_operatortype] = { }; for (int j = 0; j < last_operatortype; j++) { if (whatd[j]) { diff --git a/plugin/seq/CircumCenter.cpp b/plugin/seq/CircumCenter.cpp index 6db2e8ee2..da824b264 100644 --- a/plugin/seq/CircumCenter.cpp +++ b/plugin/seq/CircumCenter.cpp @@ -7,8 +7,7 @@ * \param pcy KN * const * \return 0L */ -long CircumCenter(Fem2D::Mesh const *const &pTh, KN< double > *const &pcx, - KN< double > *const &pcy) { +long CircumCenter(Fem2D::Mesh const *const &pTh, KN< double > *const &pcx, KN< double > *const &pcy) { KN< double > &cx = *pcx; KN< double > &cy = *pcy; const Mesh &Th = *pTh; @@ -37,7 +36,6 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme cout << " lood: CircumCenter " << endl; } - Global.Add("CircumCenter", "(", - new OneOperator3_< long, pmesh, KN< double > *, KN< double > * >(CircumCenter)); + Global.Add("CircumCenter", "(", new OneOperator3_< long, pmesh, KN< double > *, KN< double > * >(CircumCenter)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/ClosePoints.cpp b/plugin/seq/ClosePoints.cpp index 4f23d646d..b029a5102 100644 --- a/plugin/seq/ClosePoints.cpp +++ b/plugin/seq/ClosePoints.cpp @@ -37,16 +37,11 @@ class R2close { typedef double *Point; long n, nx, offset; Point *P; - const double EPSILON,epscase; + const double EPSILON, epscase; double x0, y0, x1, y1, coef; // boundin box - R2close( ) : data(0), n(0), nx(1000000), P(new Point[nx]), EPSILON(1e-6),epscase(EPSILON*2), offset(0) { - InitialiserListe( ); - } + R2close( ) : data(0), n(0), nx(1000000), P(new Point[nx]), EPSILON(1e-6), epscase(EPSILON * 2), offset(0) { InitialiserListe( ); } - R2close(double *dd, int mx, double eps = 1e-6, int offsett = 1) - : data(dd), n(0), nx(mx), P(new Point[nx]), EPSILON(eps),epscase(EPSILON*2), offset(offsett) { - InitialiserListe( ); - } + R2close(double *dd, int mx, double eps = 1e-6, int offsett = 1) : data(dd), n(0), nx(mx), P(new Point[nx]), EPSILON(eps), epscase(EPSILON * 2), offset(offsett) { InitialiserListe( ); } Point operator[](int i) const { return P[i]; } @@ -69,9 +64,8 @@ class R2close { coef = 1. / max(x1 - x0, y1 - y0); if (verbosity > 10) { - cout << " bounding box ClosePoints Pmin=[" << x0 << ", " << y0 << "], Pmax=[ " << x1 - << " " << y1 << "] " - << "eps= " << EPSILON << " offset:" << offset < 9) { cout << " ClosePoints R2.: Bug ??? : " << k << " : "; - for (int i = 0; i < max(k,10); ++i) { + for (int i = 0; i < max(k, 10); ++i) { cout << " " << kk[i]; } @@ -273,8 +264,7 @@ class R2close { if (x < x0 || x >= x1 || y < y0 || y >= y1) { return -1; // dehors } else { - return long((x - x0) / epscase) + - long((y - y0) / epscase) * N; // indice de la case contenant (x,y). + return long((x - x0) / epscase) + long((y - y0) / epscase) * N; // indice de la case contenant (x,y). } } @@ -292,99 +282,93 @@ class R2close { }; class R3close { - // cube Nx,Ny,Nz : numbering (hx,hy,hz) step in x,y or z direction . - // x : i * hx, y : j * hy , z : k*hz - // I(i,j,k) = i + j*Nx + k*Nx*Ny global number + // cube Nx,Ny,Nz : numbering (hx,hy,hz) step in x,y or z direction . + // x : i * hx, y : j * hy , z : k*hz + // I(i,j,k) = i + j*Nx + k*Nx*Ny global number // so offset in x,y,z are 1, Nx,Nx*Ny public: double *data; // minimal points+ delta typedef double *Point; - long n, nx, offsetx,offsety,offsetz; - Point *P;// Warning double pointeur - const double EPSILON,epscase; - double x0, y0, x1, y1, z0,z1, coef; // boundin box - R3close( ) : data(0), n(0), nx(1000000), P(new Point[nx]), EPSILON(1e-6),epscase(EPSILON*2),offsetx(0), offsety(1),offsetz(2) { - InitialiserListe( ); - } + long n, nx, offsetx, offsety, offsetz; + Point *P; // Warning double pointeur + const double EPSILON, epscase; + double x0, y0, x1, y1, z0, z1, coef; // boundin box + R3close( ) : data(0), n(0), nx(1000000), P(new Point[nx]), EPSILON(1e-6), epscase(EPSILON * 2), offsetx(0), offsety(1), offsetz(2) { InitialiserListe( ); } - R3close(double *dd, int nxx, double eps = 1e-6, int *o = 0, int *Ng=0) - : data(dd), n(0), nx(nxx), P(new Point[nx]), EPSILON(eps),epscase(EPSILON*2), offsetx(o?o[0]:0), offsety(o?o[1]:1),offsetz(o?o[2]:2) { - InitialiserListe(Ng ); + R3close(double *dd, int nxx, double eps = 1e-6, int *o = 0, int *Ng = 0) + : data(dd), n(0), nx(nxx), P(new Point[nx]), EPSILON(eps), epscase(EPSILON * 2), offsetx(o ? o[0] : 0), offsety(o ? o[1] : 1), offsetz(o ? o[2] : 2) { + InitialiserListe(Ng); } Point operator[](int i) const { return P[i]; } - int Nxc,Nyc,Nzc, m; // le nombre de code = ncase()%n - int Nx,Nxy; // for ncase ... - int *head; // pointeur tableau de dimension m contenant les tete de liste pour chaque code - int *next; // pointeur tableau de dimension nx donnant le point suivant de mÃme code + int Nxc, Nyc, Nzc, m; // le nombre de code = ncase()%n + int Nx, Nxy; // for ncase ... + int *head; // pointeur tableau de dimension m contenant les tete de liste pour chaque code + int *next; // pointeur tableau de dimension nx donnant le point suivant de mÃme code static const int NotaPoint = -1; - void InitialiserListe(int *Ng=0 ) { - int slong = sizeof(long); - int nlong = slong*8; - int nlong3 = nlong/3; - long mxN = (1L<0); - ffassert(EPSILON>1e-30); - if (data) { - x0 = data[0]; - y0 = data[1]; - z0 = data[2]; - x1 = data[3]; - y1 = data[4]; - z1 = data[5]; - } else { - x0 = 0; - y0 = 1; - x1 = 0; - y1 = 1; - z1 = 0; - z1 = 1; - } - - Nxc=min(long( (x1-x0)/EPSILON),mxN) ; - Nyc=min(long( (y1-y0)/EPSILON),mxN) ; - Nzc=min(long( (z1-z0)/EPSILON),mxN) ; - - if(Ng) - { - Nxc=Ng[0]; - Nyc=Ng[1]; - Nzc=Ng[2]; - } - Nx=Nxc; - Nxy = Nxc*Nyc; - coef = 1. / max(max(x1 - x0, y1 - y0),z1-z0); - if (verbosity > 10) { - cout << " bounding box ClosePoints Pmin=[" << x0 << ", " << y0 << ", "<< z0 << "], Pmax=[ " << x1 - << ", " << y1 << ", " << z1 << "] " - << "\n\teps= " << EPSILON << " offset:" << offsetx << " "< 0); + ffassert(EPSILON > 1e-30); + if (data) { + x0 = data[0]; + y0 = data[1]; + z0 = data[2]; + x1 = data[3]; + y1 = data[4]; + z1 = data[5]; + } else { + x0 = 0; + y0 = 1; + x1 = 0; + y1 = 1; + z1 = 0; + z1 = 1; + } + + Nxc = min(long((x1 - x0) / EPSILON), mxN); + Nyc = min(long((y1 - y0) / EPSILON), mxN); + Nzc = min(long((z1 - z0) / EPSILON), mxN); + + if (Ng) { + Nxc = Ng[0]; + Nyc = Ng[1]; + Nzc = Ng[2]; + } + Nx = Nxc; + Nxy = Nxc * Nyc; + coef = 1. / max(max(x1 - x0, y1 - y0), z1 - z0); + if (verbosity > 10) { + cout << " bounding box ClosePoints Pmin=[" << x0 << ", " << y0 << ", " << z0 << "], Pmax=[ " << x1 << ", " << y1 << ", " << z1 << "] " + << "\n\teps= " << EPSILON << " offset:" << offsetx << " " << offsety << " " << offsetz << ", Nxyz = " << Nxc << " " << Nyc << " Nzc " << endl; } + m = nx; // nombre de code ???? + next = new int[nx]; + head = new int[m]; + + for (int i = 0; i < m; ++i) { + head[i] = NotaPoint; + } + } + int AddSimple(double *p) { double x = p[offsetx], y = p[offsety], z = p[offsetz]; assert(n < nx); P[n] = p; - int k = ncase(x, y, z ) % m; + int k = ncase(x, y, z) % m; assert(k >= 0); next[n] = head[k]; head[k] = n; if (debug) { - cout << " AddSimple " << n << " <- " << k << " / " << x << " " << y << " "<< z << " / " << offsety << " "<< offsetz - << endl; + cout << " AddSimple " << n << " <- " << k << " / " << x << " " << y << " " << z << " / " << offsety << " " << offsetz << endl; } return n++; @@ -392,7 +376,7 @@ class R3close { private: Point *Exist(double *p) const { - double x = p[offsetx], y = p[offsety], z = p[offsetz] ; + double x = p[offsetx], y = p[offsety], z = p[offsetz]; for (int i = 0; i < n; ++i) { if (Equivalent(x, y, z, P[i])) { @@ -405,13 +389,10 @@ class R3close { public: bool Equivalent(double x0, double y0, double z0, const Point Q) const { - return ( (x0 - Q[offsetx]) * (x0 - Q[offsetx]) - + (y0 - Q[offsety]) * (y0 - Q[offsety]) - + (z0 - Q[offsetz]) * (z0 - Q[offsetz]) - ) < EPSILON * EPSILON; + return ((x0 - Q[offsetx]) * (x0 - Q[offsetx]) + (y0 - Q[offsety]) * (y0 - Q[offsety]) + (z0 - Q[offsetz]) * (z0 - Q[offsetz])) < EPSILON * EPSILON; } - Point *Exist(double x, double y,double z, int k) const { + Point *Exist(double x, double y, double z, int k) const { for (int i = head[k % m]; i != NotaPoint; i = next[i]) { if (Equivalent(x, y, z, P[i])) { return P + i; @@ -439,29 +420,27 @@ class R3close { } Point *q = 0; - int kk[27] = {}, ik = 0, nc; + int kk[27] = { }, ik = 0, nc; for (int i = -1; i < 2; ++i) { for (int j = -1; j < 2; ++j) { for (int k = -1; k < 2; ++k) { - nc = ncase(x + epscase * i, y + epscase * j, z + epscase * k); - if (nc >= 0) { - for (int i = 0; i < ik; ++i) { // remove double cas .. - if (kk[i] == nc) { - nc = -1; - break; + nc = ncase(x + epscase * i, y + epscase * j, z + epscase * k); + if (nc >= 0) { + for (int i = 0; i < ik; ++i) { // remove double cas .. + if (kk[i] == nc) { + nc = -1; + break; + } } } - } - if (nc >= 0) { - kk[ik++] = nc; + if (nc >= 0) { + kk[ik++] = nc; + } } } } -} - - for (int i = 0; i < ik; ++i) { int ik = kk[i]; @@ -478,36 +457,35 @@ class R3close { Point *Find(double x, double y, double z) { if (debug) { - cout << " Find " << x << " " << y << " " << z <<" " << EPSILON << " " << ncase(x, y, z) << ": "; + cout << " Find " << x << " " << y << " " << z << " " << EPSILON << " " << ncase(x, y, z) << ": "; } // double x = p[0], y=p[offset]; - //double eps = EPSILON ; + // double eps = EPSILON ; Point *q = 0; - int kk[27] = {}, ik = 0, nc; + int kk[27] = { }, ik = 0, nc; for (int i = -1; i < 2; ++i) { for (int j = -1; j < 2; ++j) { for (int k = -1; k < 2; ++k) { - nc = ncase(x + epscase * i, y + epscase * j, z + epscase * k); - // cout <= 0) { - for (int i = 0; i < ik; ++i) { // remove double cas e.. - if (kk[i] == nc) { - nc = -1; - break; + nc = ncase(x + epscase * i, y + epscase * j, z + epscase * k); + // cout <= 0) { + for (int i = 0; i < ik; ++i) { // remove double cas e.. + if (kk[i] == nc) { + nc = -1; + break; + } } } - } - if (nc >= 0) { - kk[ik++] = nc; + if (nc >= 0) { + kk[ik++] = nc; + } } } } - } - for (int i = 0; i < ik; ++i) { q = Exist(x, y, z, kk[i]); @@ -531,7 +509,7 @@ class R3close { } } - Point *Find(double *p) { return Find(*(p + offsetz) , *(p + offsety) , *(p + offsetz)); } + Point *Find(double *p) { return Find(*(p + offsetz), *(p + offsety), *(p + offsetz)); } int AddOpt(double *p) { Point *q = Find(p); @@ -544,13 +522,11 @@ class R3close { } long ncase(double x, double y, double z) { - // warning over flow long !!! - if (x < x0 || x >= x1 || y < y0 || y >= y1|| z < z0 || z >= z1 ) { + // warning over flow long !!! + if (x < x0 || x >= x1 || y < y0 || y >= y1 || z < z0 || z >= z1) { return -1; // dehors } else { - return long((x - x0) / epscase) + - long((y - y0) / epscase) * Nx + - long((z - z0) / epscase) * Nxy; // indice de la case contenant (x,y,z). + return long((x - x0) / epscase) + long((y - y0) / epscase) * Nx + long((z - z0) / epscase) * Nxy; // indice de la case contenant (x,y,z). } } @@ -565,7 +541,7 @@ class R3close { private: R3close(const R3close &); R3close &operator=(const R3close &); -}; // END R3close ... +}; // END R3close ... double dist2(int n, double *p, double *q) { double s = 0; @@ -579,8 +555,7 @@ double dist2(int n, double *p, double *q) { long Hcode(int n, double eps, double *p, double *p0); -KN< long > *CloseTo2(Stack stack, double const &eps, KNM_< double > const &P, - KNM_< double > const &Q) { +KN< long > *CloseTo2(Stack stack, double const &eps, KNM_< double > const &P, KNM_< double > const &Q) { long Pm0 = P.M( ); long Qm0 = Q.M( ); int po10 = P.step * P.shapei.step; @@ -625,17 +600,16 @@ KN< long > *CloseTo2(Stack stack, double const &eps, KNM_< double > const &P, return Add2StackOfPtr2FreeRC(stack, pr); } -KN< long > *CloseTo3(Stack stack, double const &eps, KNM_< double > const &P, - KNM_< double > const &Q) { +KN< long > *CloseTo3(Stack stack, double const &eps, KNM_< double > const &P, KNM_< double > const &Q) { long Pm0 = P.M( ); long Qm0 = Q.M( ); - long Pn0 = P.N( ); - long Qn0 = Q.N( ); - ffassert(Pn0>=3 && Qn0>=3); + long Pn0 = P.N( ); + long Qn0 = Q.N( ); + ffassert(Pn0 >= 3 && Qn0 >= 3); int po00 = 0; int po10 = P.step * P.shapei.step; - int po20 = P.step * P.shapei.step*2; - int offset[3]={po00,po10,po20}; + int po20 = P.step * P.shapei.step * 2; + int offset[3] = {po00, po10, po20}; double x0 = P(0, ':').min( ); double y0 = P(1, ':').min( ); double z0 = P(2, ':').min( ); @@ -644,17 +618,17 @@ KN< long > *CloseTo3(Stack stack, double const &eps, KNM_< double > const &P, double z1 = P(2, ':').max( ); // add cc - double dd = max(max(x1 - x0, y1 - y0),z1-z0) * 0.01; + double dd = max(max(x1 - x0, y1 - y0), z1 - z0) * 0.01; if (dd == 0) { - dd = max(max(abs(x0), abs(y0)), abs(z0))* 1e-8; + dd = max(max(abs(x0), abs(y0)), abs(z0)) * 1e-8; } if (dd == 0) { dd = 1e-8; } - double data[] = {x0 - dd, y0 - dd,z0 - dd, x1 + dd, y1 + dd,z1 + dd}; + double data[] = {x0 - dd, y0 - dd, z0 - dd, x1 + dd, y1 + dd, z1 + dd}; R3close S(data, Pm0, eps, offset); for (int i = 0; i < Pm0; ++i) { @@ -679,13 +653,9 @@ KN< long > *CloseTo3(Stack stack, double const &eps, KNM_< double > const &P, return Add2StackOfPtr2FreeRC(stack, pr); } -KN< long > *CloseTo2t(Stack stack, double const &eps, KNM_< double > const &P, - KNM_< double > const &Q) { - return CloseTo2(stack, eps, P.t( ), Q.t( )); -} +KN< long > *CloseTo2t(Stack stack, double const &eps, KNM_< double > const &P, KNM_< double > const &Q) { return CloseTo2(stack, eps, P.t( ), Q.t( )); } -KN< long > *CloseTo(Stack stack, double const &eps, KNM_< double > const &P, - KNM< double > *const &q, bool tq, bool inv = 0) { +KN< long > *CloseTo(Stack stack, double const &eps, KNM_< double > const &P, KNM< double > *const &q, bool tq, bool inv = 0) { long n0 = P.N( ); long m0 = P.M( ); @@ -708,7 +678,7 @@ KN< long > *CloseTo(Stack stack, double const &eps, KNM_< double > const &P, double y0 = P(1, ':').min( ); double x1 = P(0, ':').max( ); double y1 = P(1, ':').max( ); - if(verbosity>4) cout << " ClosePoints bb: x " << x0 << " " << x1 << " y " << y0 << " " << y1 << endl; + if (verbosity > 4) cout << " ClosePoints bb: x " << x0 << " " << x1 << " y " << y0 << " " << y1 << endl; // add cc double dd = max(x1 - x0, y1 - y0) * 0.01; double data[] = {x0 - dd, y0 - dd, x1 + dd, y1 + dd}; @@ -768,29 +738,25 @@ KN< long > *CloseTo(Stack stack, double const &eps, KNM_< double > const &P, } template< bool inv > -KN< long > *CloseTo(Stack stack, double const &eps, KNM< double > *const &p, - KNM< double > *const &q) { +KN< long > *CloseTo(Stack stack, double const &eps, KNM< double > *const &p, KNM< double > *const &q) { KNM_< double > P(*p); return CloseTo(stack, eps, P, q, false, inv); } template< bool inv > -KN< long > *CloseTo(Stack stack, double const &eps, Transpose< KNM< double > * > const &p, - KNM< double > *const &q) { +KN< long > *CloseTo(Stack stack, double const &eps, Transpose< KNM< double > * > const &p, KNM< double > *const &q) { KNM_< double > P(p.t->t( )); return CloseTo(stack, eps, P, q, false, inv); } template< bool inv > -KN< long > *CloseTo(Stack stack, double const &eps, Transpose< KNM< double > * > const &p, - Transpose< KNM< double > * > const &q) { +KN< long > *CloseTo(Stack stack, double const &eps, Transpose< KNM< double > * > const &p, Transpose< KNM< double > * > const &q) { KNM_< double > P(p.t->t( )); return CloseTo(stack, eps, P, q, true, inv); } template< bool inv > -KN< long > *CloseTo(Stack stack, double const &eps, KNM< double > *const &p, - Transpose< KNM< double > * > const &q) { +KN< long > *CloseTo(Stack stack, double const &eps, KNM< double > *const &p, Transpose< KNM< double > * > const &q) { KNM_< double > P(*p); return CloseTo(stack, eps, P, q.t, true, inv); } @@ -844,11 +810,10 @@ KN< long > *CloseTo(Stack stack, double const &eps, pmesh const &pTh, KNM< doubl Th.BoundingBox(Pmin, Pmax); int nv = b.sum( ); if (verbosity > 9) { - cout << " CloseTo (border): Th.nv " << Th.nv << " " << nv<< " "<< b.sum() << "/ " << Pmin << " " << Pmax << endl; + cout << " CloseTo (border): Th.nv " << Th.nv << " " << nv << " " << b.sum( ) << "/ " << Pmin << " " << Pmax << endl; } - FQuadTree *quadtree = - new FQuadTree(pTh, Pmin, Pmax, nv); // put all the old vertices in the quadtree + FQuadTree *quadtree = new FQuadTree(pTh, Pmin, Pmax, nv); // put all the old vertices in the quadtree // copy of the old vertices for (int i = 0; i < Th.nv; i++) { @@ -859,7 +824,7 @@ KN< long > *CloseTo(Stack stack, double const &eps, pmesh const &pTh, KNM< doubl } cout << " After quadterr pr=" << pr << endl; - int kk=0; + int kk = 0; for (int j = 0; j < np; ++j) { R2 P(Q(j, 0), Q(j, 1)); Vertex *pV = quadtree->ToClose(P, eps); @@ -874,7 +839,7 @@ KN< long > *CloseTo(Stack stack, double const &eps, pmesh const &pTh, KNM< doubl } } } - cout << " nb point to close "<< kk << endl; + cout << " nb point to close " << kk << endl; delete quadtree; return Add2StackOfPtr2FreeRC(stack, pr); @@ -941,8 +906,7 @@ void Clean(KN< long > &I) { } } -long Voisinage(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, - KN< KN< long > > *const &IJ) { +long Voisinage(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, KN< KN< long > > *const &IJ) { debug = (verbosity > 999); int np = P.N( ); int nq = Q.N( ); @@ -957,10 +921,8 @@ long Voisinage(KNM_< double > const &P, KNM_< double > const &Q, double const &e IJ->resize(nq); - if (verbosity > 99) { - cout << " offset01 " << offset01 << " " << offset10 << " p" << p << " " << np << " " << P.M( ) - << endl; + cout << " offset01 " << offset01 << " " << offset10 << " p" << p << " " << np << " " << P.M( ) << endl; } // store - the size in last value of IJ[i][j] @@ -990,13 +952,12 @@ long Voisinage(KNM_< double > const &P, KNM_< double > const &Q, double const &e for (int j = 0; j < nq; ++j) { int nlp = SP.FindAll(Q(j, 0), Q(j, 1), lp); (*IJ)[j].resize(nlp); - if (verbosity > 99) - cout << " Add to j=" << j << " "<< nlp << " : "; + if (verbosity > 99) cout << " Add to j=" << j << " " << nlp << " : "; for (int k = 0; k < nlp; ++k) { int i = lp[k]; - if (verbosity > 99) cout << i<< " "; - (*IJ)[j][k]=i; + if (verbosity > 99) cout << i << " "; + (*IJ)[j][k] = i; } if (verbosity > 99) cout << endl; } @@ -1005,8 +966,7 @@ long Voisinage(KNM_< double > const &P, KNM_< double > const &Q, double const &e return 0; } -long Voisinage3(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, - KN< KN< long > > *const &IJ) { +long Voisinage3(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, KN< KN< long > > *const &IJ) { debug = (verbosity > 999); int np = P.N( ); int nq = Q.N( ); @@ -1021,36 +981,34 @@ long Voisinage3(KNM_< double > const &P, KNM_< double > const &Q, double const & IJ->resize(nq); - if (verbosity > 99) { - cout << " offset01 " << offset01 << " " << offset10 << " p" << p << " " << np << " " << P.M( ) - << endl; + cout << " offset01 " << offset01 << " " << offset10 << " p" << p << " " << np << " " << P.M( ) << endl; } // store - the size in last value of IJ[i][j] double data[6]; data[0] = data[3] = p[0]; data[1] = data[4] = p[offset01]; - data[2] = data[5] = p[offset01*2]; + data[2] = data[5] = p[offset01 * 2]; for (int i = 0, k = 0; i < np; ++i, k += offset10) { data[0] = min(data[0], p[k]); data[3] = max(data[3], p[k]); data[1] = min(data[1], p[k + offset01]); data[4] = max(data[4], p[k + offset01]); - data[2] = min(data[2], p[k + offset01*2]); - data[5] = max(data[5], p[k + offset01*2]); - } + data[2] = min(data[2], p[k + offset01 * 2]); + data[5] = max(data[5], p[k + offset01 * 2]); + } double eps2 = eps + eps; data[0] -= eps2; data[3] += eps2; data[1] -= eps2; data[4] += eps2; - + data[2] -= eps2; data[5] += eps2; - int offs[]={0,offset01,offset01*2}; + int offs[] = {0, offset01, offset01 * 2}; R3close SP(data, np, eps, offs); for (int i = 0; i < np; ++i) { @@ -1058,15 +1016,14 @@ long Voisinage3(KNM_< double > const &P, KNM_< double > const &Q, double const & } for (int j = 0; j < nq; ++j) { - int nlp = SP.FindAll(Q(j, 0), Q(j, 1),Q(j, 2), lp); + int nlp = SP.FindAll(Q(j, 0), Q(j, 1), Q(j, 2), lp); (*IJ)[j].resize(nlp); - if (verbosity > 99) - cout << " Add to j=" << j << " "<< nlp << " : "; + if (verbosity > 99) cout << " Add to j=" << j << " " << nlp << " : "; for (int k = 0; k < nlp; ++k) { int i = lp[k]; - if (verbosity > 99) cout << i<< " "; - (*IJ)[j][k]=i; + if (verbosity > 99) cout << i << " "; + (*IJ)[j][k] = i; } if (verbosity > 99) cout << endl; } @@ -1077,8 +1034,7 @@ long Voisinage3(KNM_< double > const &P, KNM_< double > const &Q, double const & #ifdef WITH_flann #include -long ff_flann_search(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, - KN< KN< long > > *const &pIJ) { +long ff_flann_search(KNM_< double > const &P, KNM_< double > const &Q, double const &eps, KN< KN< long > > *const &pIJ) { KN< KN< long > > &IJ = *pIJ; int mp = P.M( ); int mq = Q.M( ); @@ -1091,8 +1047,7 @@ long ff_flann_search(KNM_< double > const &P, KNM_< double > const &Q, double co int qoffset01 = Q.step * Q.shapej.step; int qoffset10 = Q.step * Q.shapei.step; - cout << np << " " << nq << " po 01,10 =:" << offset01 << ", " << offset10 << ", " << &P(0, 1) - p - << " qo 01,10 =:" << qoffset01 << ", " << qoffset10 << ", " << &Q(0, 1) - q << endl; + cout << np << " " << nq << " po 01,10 =:" << offset01 << ", " << offset10 << ", " << &P(0, 1) - p << " qo 01,10 =:" << qoffset01 << ", " << qoffset10 << ", " << &Q(0, 1) - q << endl; cout << np << " " << mp << endl; cout << nq << " " << mq << endl; @@ -1229,8 +1184,7 @@ BoundaryEdge *Cut(const Mesh &Th, R2 P, R2 &PF) { } return 0; } -long BorderIntersect(pmesh const &pTh, KN_< double > const &IX, KN_< double > const &IY, - KN_< double > const &OX, KN_< double > const &OY, KN_< long > const &cL) { +long BorderIntersect(pmesh const &pTh, KN_< double > const &IX, KN_< double > const &IY, KN_< double > const &OX, KN_< double > const &OY, KN_< long > const &cL) { const Mesh &Th = *pTh; KN_< double > ox = OX, oy = OY; KN_< long > L = cL; @@ -1253,36 +1207,20 @@ long BorderIntersect(pmesh const &pTh, KN_< double > const &IX, KN_< double > co static void init( ) { #ifdef WITH_flann - Global.Add("radiusSearch", "(", - new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >( - ff_flann_search)); + Global.Add("radiusSearch", "(", new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >(ff_flann_search)); #endif - Global.Add("Voisinage", "(", - new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >( - Voisinage)); - Global.Add("Voisinage3", "(", - new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >( - Voisinage3)); - Global.Add("neighborhood", "(", - new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >( - Voisinage)); - Global.Add("ClosePoints2", "(", - new OneOperator3s_< KN< long > *, double, KNM_< double >, KNM_< double > >(CloseTo2)); - Global.Add("ClosePoints3", "(", - new OneOperator3s_< KN< long > *, double, KNM_< double >, KNM_< double > >(CloseTo3)); + Global.Add("Voisinage", "(", new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >(Voisinage)); + Global.Add("Voisinage3", "(", new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >(Voisinage3)); + Global.Add("neighborhood", "(", new OneOperator4_< long, KNM_< double >, KNM_< double >, double, KN< KN< long > > * >(Voisinage)); + Global.Add("ClosePoints2", "(", new OneOperator3s_< KN< long > *, double, KNM_< double >, KNM_< double > >(CloseTo2)); + Global.Add("ClosePoints3", "(", new OneOperator3s_< KN< long > *, double, KNM_< double >, KNM_< double > >(CloseTo3)); // numbering .. - Global.Add("ClosePoints", "(", - new OneOperator2s_< KN< long > *, double, KNM_< double > >(CloseTo< false >)); - Global.Add("ClosePoints", "(", - new OneOperator3s_< KN< long > *, double, pmesh, KNM< double > * >(CloseTo< false >)); - Global.Add("ClosePoints1", "(", - new OneOperator2s_< KN< long > *, double, KNM_< double > >(CloseTo< true >)); - Global.Add("ClosePoints1", "(", - new OneOperator3s_< KN< long > *, double, pmesh, KNM< double > * >(CloseTo< true >)); - Global.Add("BorderIntersect", "(", - new OneOperator6_< long, pmesh, KN_< double >, KN_< double >, KN_< double >, - KN_< double >, KN_< long > >(BorderIntersect)); + Global.Add("ClosePoints", "(", new OneOperator2s_< KN< long > *, double, KNM_< double > >(CloseTo< false >)); + Global.Add("ClosePoints", "(", new OneOperator3s_< KN< long > *, double, pmesh, KNM< double > * >(CloseTo< false >)); + Global.Add("ClosePoints1", "(", new OneOperator2s_< KN< long > *, double, KNM_< double > >(CloseTo< true >)); + Global.Add("ClosePoints1", "(", new OneOperator3s_< KN< long > *, double, pmesh, KNM< double > * >(CloseTo< true >)); + Global.Add("BorderIntersect", "(", new OneOperator6_< long, pmesh, KN_< double >, KN_< double >, KN_< double >, KN_< double >, KN_< long > >(BorderIntersect)); } LOADFUNC(init); diff --git a/plugin/seq/Curvature.cpp b/plugin/seq/Curvature.cpp index 0cf00f415..0f35a2e4d 100644 --- a/plugin/seq/Curvature.cpp +++ b/plugin/seq/Curvature.cpp @@ -68,11 +68,10 @@ using namespace Fem2D; // fonction determinant les points d'intersection static int debug = 0; -R3 *courbe(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, - long *const &pi) { +R3 *courbe(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, long *const &pi) { assert(b.N( ) >= 3); - const int d = b.N( )==3 ? 2 : 3; - auto z = [&b,d](int i)->double { return (d==3) ? b(2,i) : 0.;}; + const int d = b.N( ) == 3 ? 2 : 3; + auto z = [&b, d](int i) -> double { return (d == 3) ? b(2, i) : 0.; }; int i0 = li0, i1 = li1; if (i0 < 0) { @@ -92,7 +91,7 @@ R3 *courbe(Stack stack, const KNM_< double > &b, const long &li0, const long &li while (i0 < i1 - 1) { int im; - ffassert(k++ < k1 && (b(d,i0) < b(d,i1-1))); + ffassert(k++ < k1 && (b(d, i0) < b(d, i1 - 1))); im = (i0 + i1) / 2; if (s < b(d, im)) { i1 = im; @@ -108,8 +107,8 @@ R3 *courbe(Stack stack, const KNM_< double > &b, const long &li0, const long &li if (i0 < i1) { ffassert(b(d, i0) <= s); ffassert(b(d, i1) >= s); - R3 A(b(0, i0), b(1, i0),z(i0)); - R3 B(b(0, i1), b(1, i1),z(i0)); + R3 A(b(0, i0), b(1, i0), z(i0)); + R3 B(b(0, i1), b(1, i1), z(i0)); double l1 = (b(d, i1) - s); double l0 = s - b(d, i0); Q = (l1 * A + l0 * B) / (l1 + l0); @@ -123,9 +122,7 @@ R3 *courbe(Stack stack, const KNM_< double > &b, const long &li0, const long &li return pQ; } -R3 *courbe(Stack stack, const KNM_< double > &b, const double &ss) { - return courbe(stack, b, -1, -1, ss, 0); -} +R3 *courbe(Stack stack, const KNM_< double > &b, const double &ss) { return courbe(stack, b, -1, -1, ss, 0); } /* * Remarque sur la courbure 2d @@ -218,8 +215,7 @@ KN< double > *courbure(Stack stack, pmesh const &pTh, KN< long > *const &lab, bo double Nr = nr[i] / (1. + cos(abs(c[i]))); // ok double r = Th(i).x; if (verbosity > 9999) { - cout << " R1 " << r / Nr << " R2 " << 1 / (c[i] / (le[i] / 2.)) << " da=" << c[i] - << " le " << le[i] / 2 << endl; + cout << " R1 " << r / Nr << " R2 " << 1 / (c[i] / (le[i] / 2.)) << " da=" << c[i] << " le " << le[i] / 2 << endl; } c[i] = r * c[i] / (le[i] / 2.) + Nr; @@ -235,8 +231,7 @@ KN< double > *courbure(Stack stack, pmesh const &pTh, KN< long > *const &lab, bo ci *= 2; double rm = le[i] * sqrt(1 - nr[i] * nr[i]) / 2; if (verbosity > 999) { - cout << Th(i).y << " R1 " << ci / le[i] << " ci " << ci << " le " << le[i] << " cn " - << cn[i] << " " << c[i] << " " << nr[i] << " " << asin(nr[i]) << endl; + cout << Th(i).y << " R1 " << ci / le[i] << " ci " << ci << " le " << le[i] << " cn " << cn[i] << " " << c[i] << " " << nr[i] << " " << asin(nr[i]) << endl; } c[i] = ci * 2 * rm; @@ -248,9 +243,7 @@ KN< double > *courbure(Stack stack, pmesh const &pTh, KN< long > *const &lab, bo return Add2StackOfPtr2FreeRC(stack, pc); } -KN< double > *courbure(Stack stack, pmesh const &pTh, KN< long > *const &lab) { - return courbure(stack, pTh, lab, 0); -} +KN< double > *courbure(Stack stack, pmesh const &pTh, KN< long > *const &lab) { return courbure(stack, pTh, lab, 0); } KN< double > *courbure(Stack stack, pmesh const &pTh, const long &lab) { KN< long > ll(1); @@ -258,9 +251,7 @@ KN< double > *courbure(Stack stack, pmesh const &pTh, const long &lab) { return courbure(stack, pTh, &ll, 0); } -KN< double > *courbureaxi(Stack stack, pmesh const &pTh, KN< long > *const &lab) { - return courbure(stack, pTh, lab, 1); -} +KN< double > *courbureaxi(Stack stack, pmesh const &pTh, KN< long > *const &lab) { return courbure(stack, pTh, lab, 1); } KN< double > *courbureaxi(Stack stack, pmesh const &pTh, const long &lab) { KN< long > ll(1); @@ -268,19 +259,19 @@ KN< double > *courbureaxi(Stack stack, pmesh const &pTh, const long &lab) { return courbure(stack, pTh, &ll, 1); } -double reparametrage(Stack stack, const KNM_< double > &bb,const long &l0,const long &l1) { - int i0=l0, i1=l1; +double reparametrage(Stack stack, const KNM_< double > &bb, const long &l0, const long &l1) { + int i0 = l0, i1 = l1; KNM_< double > b = bb; - - const int d = b.N( )==3 ? 2 : 3; - auto z = [&b,d](int i)->double { return (d==3) ? b(2,i) : 0.;}; + + const int d = b.N( ) == 3 ? 2 : 3; + auto z = [&b, d](int i) -> double { return (d == 3) ? b(2, i) : 0.; }; ffassert(b.N( ) >= 3); - R3 P(b(0, i0), b(1, i0),z(i0)); + R3 P(b(0, i0), b(1, i0), z(i0)); double s = 0; - b(d, i0) = s;// Bug 6/12/23 FH.. + b(d, i0) = s; // Bug 6/12/23 FH.. - for (int i = i0+1; i <= i1 ; ++i) { - R3 Q(b(0, i), b(1, i),z(i)); + for (int i = i0 + 1; i <= i1; ++i) { + R3 Q(b(0, i), b(1, i), z(i)); s += R3(P, Q).norme( ); b(d, i) = s; P = Q; @@ -288,25 +279,23 @@ double reparametrage(Stack stack, const KNM_< double > &bb,const long &l0,const return s; } -double reparametrage(Stack stack, const KNM_< double > &bb) { - return reparametrage(stack,bb,0,bb.M()-1); -} +double reparametrage(Stack stack, const KNM_< double > &bb) { return reparametrage(stack, bb, 0, bb.M( ) - 1); } KNM< double > *equiparametre(Stack stack, const KNM_< double > &bb, const long &n) { double lg = reparametrage(stack, bb); - + KNM_< double > b = bb; - const int d = b.N( )==3 ? 2 : 3; - KNM< double > *pc = new KNM< double >(d+1, n); + const int d = b.N( ) == 3 ? 2 : 3; + KNM< double > *pc = new KNM< double >(d + 1, n); - auto z = [&b,d](int i)->double { return (d==3) ? b(2,i) : 0.;}; + auto z = [&b, d](int i) -> double { return (d == 3) ? b(2, i) : 0.; }; KNM< double > &c = *pc; int m = b.M( ); int n1 = n - 1, m1 = m - 1; double delta = 1. / n1; ffassert(b.N( ) == 3); - R3 P(b(0, 0), b(1, 0),z(0)); + R3 P(b(0, 0), b(1, 0), z(0)); // double s = 0; c(':', 0) = b(':', 0); c(':', n1) = b(':', m1); @@ -316,7 +305,7 @@ KNM< double > *equiparametre(Stack stack, const KNM_< double > &bb, const long & R3 P = *courbe(stack, bb, s); c(0, i) = P.x; c(1, i) = P.y; - if(d==3) c(2, i) = P.z; + if (d == 3) c(2, i) = P.z; c(d, i) = s * lg; if (debug) { cout << i << " " << P << " " << s << endl; @@ -326,8 +315,7 @@ KNM< double > *equiparametre(Stack stack, const KNM_< double > &bb, const long & return Add2StackOfPtr2FreeRC(stack, pc); } -double ExtractBorder(Stack stack, pmesh const &pTh, KN_< long > const &lab, - KNM< double > *const &bb) { +double ExtractBorder(Stack stack, pmesh const &pTh, KN_< long > const &lab, KNM< double > *const &bb) { const Mesh &Th = *pTh; map< long, int > mlab; @@ -438,10 +426,7 @@ double ExtractBorder(Stack stack, pmesh const &pTh, long const &lab, KNM< double #define EPSX2 2.e-06 #define MAXTOU 50 /* check if numbers are equal */ -#define egal(x, y) \ - ((((x) == 0.0f) \ - ? (fabs(y) < EPS) \ - : (((y) == 0.0f) ? (fabs(x) < EPS) : (fabs((x) - (y)) / (fabs(x) + fabs(y)) < EPSX2)))) +#define egal(x, y) ((((x) == 0.0f) ? (fabs(y) < EPS) : (((y) == 0.0f) ? (fabs(x) < EPS) : (fabs((x) - (y)) / (fabs(x) + fabs(y)) < EPSX2)))) double vp1(const double &a11, const double &a12, const double &a22) { double vp[2][2]; @@ -469,16 +454,14 @@ double Tresca(const double &arr, const double &arz, const double &azz, const dou return max(fabs(l[0] - l[1]), max(fabs(l[0] - l[2]), fabs(l[1] - l[2]))); } -double Tresca(const double &a11, const double &a22, const double &a33, const double &a12, - const double &a23, const double &a13) { +double Tresca(const double &a11, const double &a22, const double &a33, const double &a12, const double &a23, const double &a13) { double vp[3][3]; double l[3]; double m[6] = {a11, a12, a13, a22, a23, a33}; return max(fabs(l[0] - l[1]), max(fabs(l[0] - l[2]), fabs(l[1] - l[2]))); } -double VonMises(const double &a11, const double &a22, const double &a33, const double &a12, - const double &a23, const double &a13) { +double VonMises(const double &a11, const double &a22, const double &a33, const double &a12, const double &a23, const double &a13) { double vp[3][3]; double l[3]; double m[6] = {a11, a12, a13, a22, a23, a33}; @@ -510,21 +493,17 @@ double VonMises(const double &arr, const double &arz, const double &azz, const d } static void finit( ) { - Global.Add("extractborder", "(", - new OneOperator3s_< double, pmesh, KN_< long >, KNM< double > * >(ExtractBorder)); - Global.Add("extractborder", "(", - new OneOperator3s_< double, pmesh, long, KNM< double > * >(ExtractBorder)); + Global.Add("extractborder", "(", new OneOperator3s_< double, pmesh, KN_< long >, KNM< double > * >(ExtractBorder)); + Global.Add("extractborder", "(", new OneOperator3s_< double, pmesh, long, KNM< double > * >(ExtractBorder)); Global.Add("curvature", "(", new OneOperator2s_< KN< double > *, pmesh, KN< long > * >(courbure)); Global.Add("curvature", "(", new OneOperator2s_< KN< double > *, pmesh, long >(courbure)); - Global.Add("raxicurvature", "(", - new OneOperator2s_< KN< double > *, pmesh, KN< long > * >(courbureaxi)); + Global.Add("raxicurvature", "(", new OneOperator2s_< KN< double > *, pmesh, KN< long > * >(courbureaxi)); Global.Add("raxicurvature", "(", new OneOperator2s_< KN< double > *, pmesh, long >(courbureaxi)); Global.Add("curves", "(", new OneOperator2s_< R3 *, KNM_< double >, double >(courbe)); Global.Add("setcurveabcisse", "(", new OneOperator1s_< double, KNM_< double > >(reparametrage)); - Global.Add("setcurveabcisse", "(", new OneOperator3s_< double, KNM_< double > , long , long >(reparametrage)); - Global.Add("equiparameter", "(", - new OneOperator2s_< KNM< double > *, KNM_< double >, long >(equiparametre)); + Global.Add("setcurveabcisse", "(", new OneOperator3s_< double, KNM_< double >, long, long >(reparametrage)); + Global.Add("equiparameter", "(", new OneOperator2s_< KNM< double > *, KNM_< double >, long >(equiparametre)); Global.Add("Tresca", "(", new OneOperator3_< double, double >(Tresca)); Global.Add("VonMises", "(", new OneOperator3_< double, double >(VonMises)); Global.Add("Tresca", "(", new OneOperator4_< double, double >(Tresca)); diff --git a/plugin/seq/DxWriter.cpp b/plugin/seq/DxWriter.cpp index e30cea540..7c1a74487 100644 --- a/plugin/seq/DxWriter.cpp +++ b/plugin/seq/DxWriter.cpp @@ -76,9 +76,7 @@ class DxWriter { _ofts << "object \"" << _vecofts[i].name << "\" class series" << std::endl; for (int j = 0; j < _vecofts[i].vecistant.size( ); ++j) { - _ofts << "member " << j << " value file \"" << _nameofdatafile << "\",\"" - << _vecofts[i].name << "_" << j << "\" position " << _vecofts[i].vecistant[j] - << std::endl; + _ofts << "member " << j << " value file \"" << _nameofdatafile << "\",\"" << _vecofts[i].name << "_" << j << "\" position " << _vecofts[i].vecistant[j] << std::endl; } _ofts << std::endl; @@ -113,9 +111,7 @@ class DxWriter { _vecmesh.push_back(mesh); _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); - _ofdata << "object \"pos_" << _vecmesh.size( ) - 1 - << "\" class array type float rank 1 shape 2 items " << Th.nv << " data follows" - << std::endl; + _ofdata << "object \"pos_" << _vecmesh.size( ) - 1 << "\" class array type float rank 1 shape 2 items " << Th.nv << " data follows" << std::endl; for (int k = 0; k < Th.nv; ++k) { // Scorre tutti i vertici _ofdata << Th(k).x << " " << Th(k).y << endl; @@ -123,8 +119,7 @@ class DxWriter { _ofdata << std::endl; _ofdata.flags(std::ios_base::fixed); - _ofdata << "object \"conn_" << _vecmesh.size( ) - 1 - << "\" class array type int rank 1 shape 3 items " << Th.nt << " data follows " << endl; + _ofdata << "object \"conn_" << _vecmesh.size( ) - 1 << "\" class array type int rank 1 shape 3 items " << Th.nt << " data follows " << endl; for (int i = 0; i < Th.nt; i++) { for (int j = 0; j < 3; j++) { @@ -143,8 +138,7 @@ class DxWriter { tsinfo ts; ts.name = nameofts; - std::vector< const Fem2D::Mesh * >::const_iterator first = _vecmesh.begin( ), - last = _vecmesh.end( ); + std::vector< const Fem2D::Mesh * >::const_iterator first = _vecmesh.begin( ), last = _vecmesh.end( ); if (std::find(first, last, mesh) == last) { addmesh(mesh); @@ -169,30 +163,24 @@ class DxWriter { _vecofts[jj].vecistant.push_back(t); _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); - _ofdata << "object \"" << nameofts << "_data_" << _vecofts[jj].vecistant.size( ) - 1 - << "\" class array type float rank 0 items " << val.size( ) << " data follows" - << std::endl; + _ofdata << "object \"" << nameofts << "_data_" << _vecofts[jj].vecistant.size( ) - 1 << "\" class array type float rank 0 items " << val.size( ) << " data follows" << std::endl; for (int i = 0; i < val.size( ); ++i) { _ofdata << val[i] << std::endl; } _ofdata << "attribute \"dep\" string \"positions\"" << std::endl << std::endl; - _ofdata << "object \"" << nameofts << "_" << _vecofts[jj].vecistant.size( ) - 1 - << "\" class field" << std::endl; + _ofdata << "object \"" << nameofts << "_" << _vecofts[jj].vecistant.size( ) - 1 << "\" class field" << std::endl; _ofdata << "component \"positions\" value \"pos_" << _vecofts[jj].imesh << "\"" << std::endl; _ofdata << "component \"connections\" value \"conn_" << _vecofts[jj].imesh << "\"" << std::endl; - _ofdata << "component \"data\" value \"" << nameofts << "_data_" - << _vecofts[jj].vecistant.size( ) - 1 << "\"" << std::endl - << std::endl; + _ofdata << "component \"data\" value \"" << nameofts << "_data_" << _vecofts[jj].vecistant.size( ) - 1 << "\"" << std::endl << std::endl; _ofdata.flush( ); save_header( ); } /*!Add a field*/ void addfield(const string &nameoffield, const Fem2D::Mesh *mesh, const KN< double > &val) { - std::vector< const Fem2D::Mesh * >::const_iterator first = _vecmesh.begin( ), - last = _vecmesh.end( ); + std::vector< const Fem2D::Mesh * >::const_iterator first = _vecmesh.begin( ), last = _vecmesh.end( ); int im; if (std::find(first, last, mesh) == last) { @@ -204,8 +192,7 @@ class DxWriter { _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); - _ofdata << "object \"" << nameoffield << "_data\" class array type float rank 0 items " - << val.size( ) << " data follows" << std::endl; + _ofdata << "object \"" << nameoffield << "_data\" class array type float rank 0 items " << val.size( ) << " data follows" << std::endl; for (int i = 0; i < val.size( ); ++i) { _ofdata << val[i] << std::endl; @@ -290,9 +277,7 @@ class Dxwritesol_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< DxWriter * >( ), atype< string * >( ), atype< double >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< DxWriter * >( ), atype< string * >( ), atype< double >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new Dxwritesol_Op(args); } @@ -357,19 +342,15 @@ void *call_addtimeseries(DxWriter *const &mt, string *const &name, const Fem2D:: // Add the function name to the freefem++ table static void Load_Init( ) { - Dcl_Type< DxWriter * >( - InitP< DxWriter >, - Destroy< DxWriter >); // declare deux nouveau type pour freefem++ un pointeur et + Dcl_Type< DxWriter * >(InitP< DxWriter >, + Destroy< DxWriter >); // declare deux nouveau type pour freefem++ un pointeur et zzzfff->Add("DxWriter", atype< DxWriter * >( )); // ajoute le type myType a freefem++ // constructeur d'un type myType dans freefem TheOperators->Add("<-", new OneOperator2_< DxWriter *, DxWriter *, string * >(&init_DxWriter)); - Global.Add("Dxaddmesh", "(", - new OneOperator2_< void *, DxWriter *, const Fem2D::Mesh * >(call_addmesh)); - Global.Add("Dxaddtimeseries", "(", - new OneOperator3_< void *, DxWriter *, std::string *, const Fem2D::Mesh * >( - call_addtimeseries)); + Global.Add("Dxaddmesh", "(", new OneOperator2_< void *, DxWriter *, const Fem2D::Mesh * >(call_addmesh)); + Global.Add("Dxaddtimeseries", "(", new OneOperator3_< void *, DxWriter *, std::string *, const Fem2D::Mesh * >(call_addtimeseries)); Global.Add("Dxaddsol2ts", "(", new OneOperatorCode< Dxwritesol_Op >); diff --git a/plugin/seq/Element_HCT.cpp b/plugin/seq/Element_HCT.cpp index 7c596190b..48903a337 100644 --- a/plugin/seq/Element_HCT.cpp +++ b/plugin/seq/Element_HCT.cpp @@ -114,13 +114,10 @@ namespace Fem2D { } } -#define P3(a, b, c) a *b *c -#define P3abcx(x, a, b, c) a##x *b *c + a *b##x *c + a *b *c##x -#define P3abcxy(x, y, a, b, c) \ - a##x *b##y *c + a##y *b##x *c + a##y *b *c##x + a##x *b *c##y + a *b##x *c##y + a *b##y *c##x -#define P3abcxyz(x, y, z, a, b, c) \ - a##x *b##y *c##z + a##y *b##x *c##z + a##y *b##z *c##x + a##x *b##z *c##y + a##z *b##x *c##y + \ - a##z *b##y *c##x +#define P3(a, b, c) a * b * c +#define P3abcx(x, a, b, c) a##x * b * c + a *b##x *c + a * b * c##x +#define P3abcxy(x, y, a, b, c) a##x *b##y *c + a##y *b##x *c + a##y * b * c##x + a##x * b * c##y + a *b##x *c##y + a *b##y *c##x +#define P3abcxyz(x, y, z, a, b, c) a##x *b##y *c##z + a##y *b##x *c##z + a##y *b##z *c##x + a##x *b##z *c##y + a##z *b##x *c##y + a##z *b##y *c##x #define P3X(a, b, c) P3abcx(x, a, b, c) #define P3Y(a, b, c) P3abcx(y, a, b, c) @@ -132,14 +129,9 @@ namespace Fem2D { #define P3XXY(a, b, c) P3abcxyz(x, x, y, a, b, c) #define P3XYY(a, b, c) P3abcxyz(x, y, y, a, b, c) -#define LL10(P3) \ - { \ - P3(li, li, li), P3(li1, li1, li1), P3(li2, li2, li2), P3(li, li, li2), P3(li, li, li1), \ - P3(li1, li1, li), P3(li1, li1, li2), P3(li2, li2, li1), P3(li2, li2, li), P3(li, li1, li2) \ - } +#define LL10(P3) {P3(li, li, li), P3(li1, li1, li1), P3(li2, li2, li2), P3(li, li, li2), P3(li, li, li1), P3(li1, li1, li), P3(li1, li1, li2), P3(li2, li2, li1), P3(li2, li2, li), P3(li, li1, li2)} - void TypeOfFE_HCT::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, - RNMK_ &val) const { + void TypeOfFE_HCT::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { typedef double R; double area = K.area; int Nop = val.K( ); @@ -171,9 +163,7 @@ namespace Fem2D { double lix = Dl[i0].x, li1x = Dl[i1].x, li2x = Dl[i2].x; double liy = Dl[i0].y, li1y = Dl[i1].y, li2y = Dl[i2].y; // i0,i1,i2, - int p12[12] = { - 3 * i0, 3 * i1, 3 * i2, 3 * i0 + 2, 3 * i0 + 1, 3 * i1 + 2, 3 * i1 + 1, - 3 * i2 + 2, 3 * i2 + 1, 9 + i0, 9 + i1, 9 + i2}; // renumerotation DL .. ff-> paper + int p12[12] = {3 * i0, 3 * i1, 3 * i2, 3 * i0 + 2, 3 * i0 + 1, 3 * i1 + 2, 3 * i1 + 1, 3 * i2 + 2, 3 * i2 + 1, 9 + i0, 9 + i1, 9 + i2}; // renumerotation DL .. ff-> paper /* * double ll[10]={ P3(li,li,li), P3(li1,li1,li1), P3(li2,li2,li2), @@ -187,23 +177,18 @@ namespace Fem2D { // Warning // double ccc[] = { 1./(Dl[0],Ne[0]), 1./(Dl[1],Ne[1]), 1./(Dl[2],Ne[2]) }; double c12 = 1. / 12.; - double Ai[12][10] = { - {(-0.5) * (etai1 - etai2), 0, 0, (1.5) * (3 + etai1), (1.5) * (3 - etai2), 0, 0, 0, 0, 0}, - {(0.5) * (1 - 2 * etai - etai2), 1, 0, (-1.5) * (1 - etai), (1.5) * (etai + etai2), 3, 3, 0, - 0, 3 * (1 - etai)}, - {(0.5) * (1 + 2 * etai + etai1), 0, 1, (-1.5) * (etai + etai1), (-1.5) * (1 + etai), 0, 0, 3, - 3, 3 * (1 + etai)}, - {(-c12) * (1 + etai1), 0, 0, (0.25) * (7 + etai1), (-0.5), 0, 0, 0, 0, 0}, - {(-c12) * (1 - etai2), 0, 0, (-0.5), (0.25) * (7 - etai2), 0, 0, 0, 0, 0}, - {(-c12) * (7 + etai2), 0, 0, (0.5), (0.25) * (5 + etai2), 1, 0, 0, 0, -1}, - {(1. / 6.) * (4 - etai), 0, 0, (-0.25) * (3 - etai), (-0.25) * (5 - etai), 0, 1, 0, 0, - (0.5) * (3 - etai)}, - {(1. / 6.) * (4 + etai), 0, 0, (-0.25) * (5 + etai), (-0.25) * (3 + etai), 0, 0, 1, 0, - (0.5) * (3 + etai)}, - {(-c12) * (7 - etai1), 0, 0, (0.25) * (5 - etai1), (0.5), 0, 0, 0, 1, -1}, - {(4. / 3.), 0, 0, -2, -2, 0, 0, 0, 0, 4}, - {(-2. / 3.), 0, 0, 2, 0, 0, 0, 0, 0, 0}, - {(-2. / 3.), 0, 0, 0, 2, 0, 0, 0, 0, 0}}; + double Ai[12][10] = {{(-0.5) * (etai1 - etai2), 0, 0, (1.5) * (3 + etai1), (1.5) * (3 - etai2), 0, 0, 0, 0, 0}, + {(0.5) * (1 - 2 * etai - etai2), 1, 0, (-1.5) * (1 - etai), (1.5) * (etai + etai2), 3, 3, 0, 0, 3 * (1 - etai)}, + {(0.5) * (1 + 2 * etai + etai1), 0, 1, (-1.5) * (etai + etai1), (-1.5) * (1 + etai), 0, 0, 3, 3, 3 * (1 + etai)}, + {(-c12) * (1 + etai1), 0, 0, (0.25) * (7 + etai1), (-0.5), 0, 0, 0, 0, 0}, + {(-c12) * (1 - etai2), 0, 0, (-0.5), (0.25) * (7 - etai2), 0, 0, 0, 0, 0}, + {(-c12) * (7 + etai2), 0, 0, (0.5), (0.25) * (5 + etai2), 1, 0, 0, 0, -1}, + {(1. / 6.) * (4 - etai), 0, 0, (-0.25) * (3 - etai), (-0.25) * (5 - etai), 0, 1, 0, 0, (0.5) * (3 - etai)}, + {(1. / 6.) * (4 + etai), 0, 0, (-0.25) * (5 + etai), (-0.25) * (3 + etai), 0, 0, 1, 0, (0.5) * (3 + etai)}, + {(-c12) * (7 - etai1), 0, 0, (0.25) * (5 - etai1), (0.5), 0, 0, 0, 1, -1}, + {(4. / 3.), 0, 0, -2, -2, 0, 0, 0, 0, 4}, + {(-2. / 3.), 0, 0, 2, 0, 0, 0, 0, 0, 0}, + {(-2. / 3.), 0, 0, 0, 2, 0, 0, 0, 0, 0}}; const int nnzdd = 6 * 3; // nb coef.. double add[] = {1., 1., 0., 0., 1., 1., 1., 0., 0., 1., 1., 1., 0., 0., 1., 1., 1., 1.}; int idd[] = {0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 11}; diff --git a/plugin/seq/Element_Mixte.cpp b/plugin/seq/Element_Mixte.cpp index fa1739f47..547baeae5 100644 --- a/plugin/seq/Element_Mixte.cpp +++ b/plugin/seq/Element_Mixte.cpp @@ -44,8 +44,10 @@ // lame-TD-NSS.edp // test-ElementMixte.edp -// ff-c++-LIBRARY-dep: lapack blas -// lapack: dgetrf and dgetri +/* clang-format off */ +//ff-c++-LIBRARY-dep: lapack blas +/* clang-format on */ +// lapack: dgetrf and dgetri #include "ff++.hpp" #include "AddNewFE.h" @@ -98,8 +100,7 @@ namespace Fem2D { assert(pij_alpha.N( ) == kk); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; @@ -125,8 +126,7 @@ namespace Fem2D { assert(k == 9); } - void TypeOfFE_TD_NNS0::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_TD_NNS0::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { typedef double R; R cK = 2 * K.area; R2 Rl[3] = {K.Edge(0) / cK, K.Edge(1) / cK, K.Edge(2) / cK}; // @@ -165,11 +165,10 @@ namespace Fem2D { const GQuadratureFormular< R2 > &QFK; TypeOfFE_TD_NNS1( ) - : TypeOfFE( - 3 * 2 + 3, 3, Data, 2, 1, - 3 + 6 * 3 * QF_GaussLegendre2.n, // nb coef to build interpolation - QuadratureFormular_T_1.n + 3 * QF_GaussLegendre2.n, // np point to build interpolation - 0), + : TypeOfFE(3 * 2 + 3, 3, Data, 2, 1, + 3 + 6 * 3 * QF_GaussLegendre2.n, // nb coef to build interpolation + QuadratureFormular_T_1.n + 3 * QF_GaussLegendre2.n, // np point to build interpolation + 0), QFE(QF_GaussLegendre2), QFK(QuadratureFormular_T_1) { int kk = 0, kp = 0; @@ -205,8 +204,7 @@ namespace Fem2D { ffassert(pij_alpha.N( ) == kk); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; @@ -260,8 +258,7 @@ namespace Fem2D { ffassert(pij_alpha.N( ) == k); } - void TypeOfFE_TD_NNS1::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_TD_NNS1::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { typedef double R; R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R ll[3] = {l0, l1, l2}; @@ -329,8 +326,7 @@ namespace Fem2D { cout << Rl[0] << " " << Rl[1] << ", " << Rl[2] << endl; for (int i = 0; i < 3; ++i) { - cout << " ***** " << BB[i][0] << " " << BB[i][1] << " " << BB[i][2] << "\t l " << ll[i] - << endl; + cout << " ***** " << BB[i][0] << " " << BB[i][1] << " " << BB[i][2] << "\t l " << ll[i] << endl; } } @@ -412,9 +408,7 @@ namespace Fem2D { KN< int > Data; // data of TypeOfFE const QuadratureFormular1d QFE; const GQuadratureFormular< R2 > &QFK; - InitTypeOfRTk_2d(int KK) - : k(KK), ndfi((k + 1) * (k)), npe(k + 1), ndf(3 * npe + ndfi), Data(5 * ndf + 6), - QFE(-1 + 2 * npe, npe, GaussLegendre(npe), true), QFK(QuadratureFormular_T_5) { + InitTypeOfRTk_2d(int KK) : k(KK), ndfi((k + 1) * (k)), npe(k + 1), ndf(3 * npe + ndfi), Data(5 * ndf + 6), QFE(-1 + 2 * npe, npe, GaussLegendre(npe), true), QFK(QuadratureFormular_T_5) { // int j = 0; int ndfe = ndf - ndfi; // int o[6]; @@ -543,14 +537,12 @@ namespace Fem2D { assert(k == this->pij_alpha.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; // ENDOFCLASS TypeOfFE_PkEdge - void TypeOfFE_RT1_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &Phat, - RNMK_ &val) const { + void TypeOfFE_RT1_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &Phat, RNMK_ &val) const { R2 X = K(Phat); R2 Q[] = {R2(K[0]), R2(K[1]), R2(K[2])}; R l0 = 1 - Phat.x - Phat.y, l1 = Phat.x, l2 = Phat.y; @@ -826,12 +818,10 @@ namespace Fem2D { assert(k == this->pij_alpha.N( )); } - void FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &Phat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &Phat, RNMK_ &val) const; }; - void TypeOfFE_RT2_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &Phat, - RNMK_ &val) const { + void TypeOfFE_RT2_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &Phat, RNMK_ &val) const { R2 X = K(Phat); R2 Q[] = {R2(K[0]), R2(K[1]), R2(K[2])}; R l0 = 1 - Phat.x - Phat.y, l1 = Phat.x, l2 = Phat.y; @@ -842,29 +832,14 @@ namespace Fem2D { assert(val.M( ) == 2); val = 0; - int p[15] = {0, 1, 2, 5, 4, 3, 6, 7, - 8, 9, 10, 11, 12, 13, 14}; // Permutation for orinatation - R2 Pm[18]; // all the momome function .. - double cf[][6] = {{0, -5.5, 0, -2.5, -0.5, -1.5} /* 0 */, - {-1.25, -1.25, 0.25, -1, 0.25, -1} /* 1 */, - {-5.5, 0, -0.5, -1.5, 0, -2.5} /* 2 */, - {0, -2.5, 0, -5.5, -1.5, -0.5} /* 3 */, - {0.25, -1, -1.25, -1.25, -1, 0.25} /* 4 */, - {-0.5, -1.5, -5.5, 0, -2.5, 0} /* 5 */, - {-2.5, 0, -1.5, -0.5, 0, -5.5} /* 6 */, - {-1, 0.25, -1, 0.25, -1.25, -1.25} /* 7 */, - {-1.5, -0.5, -2.5, 0, -5.5, 0} /* 8 */, - {30, 90, -30, 180, 30, 60} /* 9 */, - {90, 30, 30, 60, -30, 180} /* 10 */, - {30, -180, -30, -90, -60, -30} /* 11 */, - {60, -120, 60, -60, 120, -60} /* 12 */, - {-120, 60, 120, -60, 60, -60} /* 13 */, - {-180, 30, -60, -30, -30, -90} /* 14 */}; - int Bii[][3] = {{0, 0, 0} /* 0 */, {0, 1, 1} /* 1 */, {0, 2, 2} /* 2 */, {0, 1, 2} /* 3 */, - {0, 2, 0} /* 4 */, {0, 0, 1} /* 5 */, {1, 0, 0} /* 6 */, {1, 1, 1} /* 7 */, - {1, 2, 2} /* 8 */, {1, 1, 2} /* 9 */, {1, 2, 0} /* 10 */, {1, 0, 1} /* 11 */, - {2, 0, 0} /* 12 */, {2, 1, 1} /* 13 */, {2, 2, 2} /* 14 */, {2, 1, 2} /* 15 */, - {2, 2, 0} /* 16 */, {2, 0, 1} /* 17 */}; + int p[15] = {0, 1, 2, 5, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14}; // Permutation for orinatation + R2 Pm[18]; // all the momome function .. + double cf[][6] = {{0, -5.5, 0, -2.5, -0.5, -1.5} /* 0 */, {-1.25, -1.25, 0.25, -1, 0.25, -1} /* 1 */, {-5.5, 0, -0.5, -1.5, 0, -2.5} /* 2 */, {0, -2.5, 0, -5.5, -1.5, -0.5} /* 3 */, + {0.25, -1, -1.25, -1.25, -1, 0.25} /* 4 */, {-0.5, -1.5, -5.5, 0, -2.5, 0} /* 5 */, {-2.5, 0, -1.5, -0.5, 0, -5.5} /* 6 */, {-1, 0.25, -1, 0.25, -1.25, -1.25} /* 7 */, + {-1.5, -0.5, -2.5, 0, -5.5, 0} /* 8 */, {30, 90, -30, 180, 30, 60} /* 9 */, {90, 30, 30, 60, -30, 180} /* 10 */, {30, -180, -30, -90, -60, -30} /* 11 */, + {60, -120, 60, -60, 120, -60} /* 12 */, {-120, 60, 120, -60, 60, -60} /* 13 */, {-180, 30, -60, -30, -30, -90} /* 14 */}; + int Bii[][3] = {{0, 0, 0} /* 0 */, {0, 1, 1} /* 1 */, {0, 2, 2} /* 2 */, {0, 1, 2} /* 3 */, {0, 2, 0} /* 4 */, {0, 0, 1} /* 5 */, {1, 0, 0} /* 6 */, {1, 1, 1} /* 7 */, {1, 2, 2} /* 8 */, + {1, 1, 2} /* 9 */, {1, 2, 0} /* 10 */, {1, 0, 1} /* 11 */, {2, 0, 0} /* 12 */, {2, 1, 1} /* 13 */, {2, 2, 2} /* 14 */, {2, 1, 2} /* 15 */, {2, 2, 0} /* 16 */, {2, 0, 1} /* 17 */}; int fe[] = {1, 3, 2, 6, 10, 8, 12, 17, 13}; int k6[] = {4, 5, 9, 11, 15, 16}; R CKK = K.area * 2; @@ -896,8 +871,7 @@ namespace Fem2D { Exchange(p[6], p[8]); } - double sg[15] = {eo[0], eo[0], eo[0], eo[1], eo[1], eo[1], eo[2], eo[2], - eo[2], 1., 1., 1., 1., 1., 1.}; + double sg[15] = {eo[0], eo[0], eo[0], eo[1], eo[1], eo[1], eo[2], eo[2], eo[2], 1., 1., 1., 1., 1., 1.}; if (whatd[op_id]) { for (int pdf = 0; pdf < 15; ++pdf) { @@ -1041,8 +1015,7 @@ namespace Fem2D { assert(k == this->pij_alpha.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; // ENDOFCLASS TypeOfFE_PkEdge @@ -1052,8 +1025,7 @@ namespace Fem2D { 0, 0, 0, 0, 0, 0, // df previou FE 0, 1, 2, 3, 4, 5, // which df on prev 0, 0, 0, 0, 6, 6}; - void TypeOfFE_BDM1_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_BDM1_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 X = K(PHat); R2 Q[] = {R2(K[0]), R2(K[1]), R2(K[2])}; R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; @@ -1124,340 +1096,297 @@ namespace Fem2D { } } -class TypeOfFE_RTdc : public TypeOfFE { public: - static int Data[]; - TypeOfFE_RTdc(): TypeOfFE(0,0,3,2,Data,1,1,6,3) - {const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int p=0,kk=0;p<3;p++) - { P_Pi_h[p]=Pt[p]; - for (int j=0;j<2;j++) - pij_alpha[kk++]= IPJ(p,p,j); - }} - void FB(const bool * watdd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - void Pi_h_alpha(const baseFElement & K,KN_ & v) const ; -} ; -// on what nu df on node node of df - int TypeOfFE_RTdc::Data[]={6,6,6, 0,1,2, 0,0,0, 0,0,0, 0,1,2, 0,0, 0,0,3,3}; - - void TypeOfFE_RTdc::FB(const bool *whatd,const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // -// const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - if (val.N() <3) - throwassert(val.N() >=3); - throwassert(val.M()==2 ); - val=0; - R a=1./(2*K.area); - R a0= a ; - R a1= a ; - R a2= a ; - // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; - - // ------------ - if (whatd[op_id]) - { - assert(val.K()>op_id); - RN_ f0(val('.',0,0)); - RN_ f1(val('.',1,0)); - f0[0] = (P.x-A.x)*a0; - f1[0] = (P.y-A.y)*a0; - - f0[1] = (P.x-B.x)*a1; - f1[1] = (P.y-B.y)*a1; - - f0[2] = (P.x-C.x)*a2; - f1[2] = (P.y-C.y)*a2; - } - if (whatd[op_dx]) - { - assert(val.K()>op_dx); - val(0,0,op_dx) = a0; - val(1,0,op_dx) = a1; - val(2,0,op_dx) = a2; + class TypeOfFE_RTdc : public TypeOfFE { + public: + static int Data[]; + TypeOfFE_RTdc( ) : TypeOfFE(0, 0, 3, 2, Data, 1, 1, 6, 3) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int p = 0, kk = 0; p < 3; p++) { + P_Pi_h[p] = Pt[p]; + for (int j = 0; j < 2; j++) pij_alpha[kk++] = IPJ(p, p, j); + } + } + void FB(const bool *watdd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; + }; + // on what nu df on node node of df + int TypeOfFE_RTdc::Data[] = {6, 6, 6, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 3, 3}; + + void TypeOfFE_RTdc::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &PHat, RNMK_ &val) const { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]), C(K[2]); + if (val.N( ) < 3) throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 2); + val = 0; + R a = 1. / (2 * K.area); + R a0 = a; + R a1 = a; + R a2 = a; + // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; + + // ------------ + if (whatd[op_id]) { + assert(val.K( ) > op_id); + RN_ f0(val('.', 0, 0)); + RN_ f1(val('.', 1, 0)); + f0[0] = (P.x - A.x) * a0; + f1[0] = (P.y - A.y) * a0; + + f0[1] = (P.x - B.x) * a1; + f1[1] = (P.y - B.y) * a1; + + f0[2] = (P.x - C.x) * a2; + f1[2] = (P.y - C.y) * a2; + } + if (whatd[op_dx]) { + assert(val.K( ) > op_dx); + val(0, 0, op_dx) = a0; + val(1, 0, op_dx) = a1; + val(2, 0, op_dx) = a2; + } + if (whatd[op_dy]) { + assert(val.K( ) > op_dy); + val(0, 1, op_dy) = a0; + val(1, 1, op_dy) = a1; + val(2, 1, op_dy) = a2; + } } - if (whatd[op_dy]) - { - assert(val.K()>op_dy); - val(0,1,op_dy) = a0; - val(1,1,op_dy) = a1; - val(2,1,op_dy) = a2; + + void TypeOfFE_RTdc::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + const Triangle &T(K.T); + + for (int i = 0, k = 0; i < 3; i++) { + R2 E(T.Edge(i)); + R signe = 1; + v[k++] = signe * E.y; + v[k++] = -signe * E.x; + } } -} - -void TypeOfFE_RTdc::Pi_h_alpha(const baseFElement & K,KN_ & v) const -{ - const Triangle & T(K.T); - - for (int i=0,k=0;i<3;i++) - { - R2 E(T.Edge(i)); - R signe = 1; - v[k++]= signe*E.y; - v[k++]=-signe*E.x; - } -} - -// Add jun 2023 FH... in test -class TypeOfFE_BDM2_2d : public TypeOfFE { -public: + + // Add jun 2023 FH... in test + class TypeOfFE_BDM2_2d : public TypeOfFE { + public: static int Data[]; static double Pi_h_coef[]; bool Ortho; const QuadratureFormular1d &QFE; const QuadratureFormular &QFT; TypeOfFE_BDM2_2d(bool ortho) - : TypeOfFE(12, 2, Data, 1, 1, - 6*(3*3+7) - , // nb coef mat interpole - 3*3+7, // nb P interpolation - 0), - QFE(QF_GaussLegendre3),QFT(QuadratureFormular_T_5), Ortho(ortho) { - int kkk = 0, i = 0; - // point on edge - for (int e = 0; e < 3; ++e) { - for (int p = 0; p < QFE.n; ++p) { - R2 A(TriangleHat[VerticesOfTriangularEdge[e][0]]); - R2 B(TriangleHat[VerticesOfTriangularEdge[e][1]]); - // 3 dof per edge and 2 componante - pij_alpha[kkk++] = IPJ(3 * e, i, 0); - pij_alpha[kkk++] = IPJ(3 * e, i, 1); - pij_alpha[kkk++] = IPJ(3 * e + 1, i, 0); - pij_alpha[kkk++] = IPJ(3 * e + 1, i, 1); - pij_alpha[kkk++] = IPJ(3 * e + 2, i, 0); - pij_alpha[kkk++] = IPJ(3 * e + 2, i, 1); - - P_Pi_h[i++] = B * (QFE[p].x) + A * (1. - QFE[p].x); // X=0 => A X=1 => B; - } - } - // kkk = 3*QFE.n*6 (QFE.n == 5) - // point on triangle (QFT.n == 7) - // kkk += QFT.n * 6 - for (int p = 0; p < QFT.n; ++p) { - // 3 dof per edge and 2 componante - pij_alpha[kkk++] = IPJ(9, i, 0); - pij_alpha[kkk++] = IPJ(9, i, 1); - pij_alpha[kkk++] = IPJ(9 + 1, i, 0); - pij_alpha[kkk++] = IPJ(9 + 1, i, 1); - pij_alpha[kkk++] = IPJ(9 + 2, i, 0); - pij_alpha[kkk++] = IPJ(9 + 2, i, 1); - - P_Pi_h[i++] = QFT[p]; // X=0 => A X=1 => B; - } - if(verbosity>99) - { - cout << "\n kkk " << kkk << " " << this->pij_alpha.N( ) << " /"<< QFE.n << " " << QFT.n <P_Pi_h.N( ) << endl; + : TypeOfFE(12, 2, Data, 1, 1, + 6 * (3 * 3 + 7), // nb coef mat interpole + 3 * 3 + 7, // nb P interpolation + 0), + QFE(QF_GaussLegendre3), QFT(QuadratureFormular_T_5), Ortho(ortho) { + int kkk = 0, i = 0; + // point on edge + for (int e = 0; e < 3; ++e) { + for (int p = 0; p < QFE.n; ++p) { + R2 A(TriangleHat[VerticesOfTriangularEdge[e][0]]); + R2 B(TriangleHat[VerticesOfTriangularEdge[e][1]]); + // 3 dof per edge and 2 componante + pij_alpha[kkk++] = IPJ(3 * e, i, 0); + pij_alpha[kkk++] = IPJ(3 * e, i, 1); + pij_alpha[kkk++] = IPJ(3 * e + 1, i, 0); + pij_alpha[kkk++] = IPJ(3 * e + 1, i, 1); + pij_alpha[kkk++] = IPJ(3 * e + 2, i, 0); + pij_alpha[kkk++] = IPJ(3 * e + 2, i, 1); + + P_Pi_h[i++] = B * (QFE[p].x) + A * (1. - QFE[p].x); // X=0 => A X=1 => B; } - ffassert(kkk == this->pij_alpha.N( )); - ffassert(i == this->P_Pi_h.N( )); + } + // kkk = 3*QFE.n*6 (QFE.n == 5) + // point on triangle (QFT.n == 7) + // kkk += QFT.n * 6 + for (int p = 0; p < QFT.n; ++p) { + // 3 dof per edge and 2 componante + pij_alpha[kkk++] = IPJ(9, i, 0); + pij_alpha[kkk++] = IPJ(9, i, 1); + pij_alpha[kkk++] = IPJ(9 + 1, i, 0); + pij_alpha[kkk++] = IPJ(9 + 1, i, 1); + pij_alpha[kkk++] = IPJ(9 + 2, i, 0); + pij_alpha[kkk++] = IPJ(9 + 2, i, 1); + + P_Pi_h[i++] = QFT[p]; // X=0 => A X=1 => B; + } + if (verbosity > 99) { + cout << "\n kkk " << kkk << " " << this->pij_alpha.N( ) << " /" << QFE.n << " " << QFT.n << endl; + cout << " i " << i << " " << this->P_Pi_h.N( ) << endl; + } + ffassert(kkk == this->pij_alpha.N( )); + ffassert(i == this->P_Pi_h.N( )); } - + void Pi_h_alpha(const baseFElement &K, - KN_< double > &v) const - { // compute the coef of interpolation ... - const Triangle &T(K.T); - int k = 0; - double c1[][3] = {{9, -18, 3} /* 0 */, {-18, 84, -18} /* 1 */, {3, -18, 9} /* 2 */}; - // QuadratureFormular1d QFe=QF_GaussLegendre3; - for (int i = 0; i < 3; i++) { - R2 E(Ortho ? T.Edge(i) : -T.Edge(i).perp( )); - R s = T.EdgeOrientation(i); - - for (int p = 0; p < QFE.n; ++p) { - R l1 = QFE[p].x, l2 = 1 - QFE[p].x; - - R p0 = l1 ; - R p1 = l1 * l2; - R p2 = l2 ; - R sa = QFE[p].a*s; - R cc2 = sa * p0; // - R cc1 = sa * p1; // - R cc0 = sa * p2; // - if (s < 0) { - swap(cc0, cc2); - } - - v[k++] = cc0 * E.x; - v[k++] = cc0 * E.y; - v[k++] = cc1 * E.x; - v[k++] = cc1 * E.y; - v[k++] = cc2 * E.x; - v[k++] = cc2 * E.y; - } + KN_< double > &v) const { // compute the coef of interpolation ... + const Triangle &T(K.T); + int k = 0; + double c1[][3] = {{9, -18, 3} /* 0 */, {-18, 84, -18} /* 1 */, {3, -18, 9} /* 2 */}; + // QuadratureFormular1d QFe=QF_GaussLegendre3; + for (int i = 0; i < 3; i++) { + R2 E(Ortho ? T.Edge(i) : -T.Edge(i).perp( )); + R s = T.EdgeOrientation(i); + + for (int p = 0; p < QFE.n; ++p) { + R l1 = QFE[p].x, l2 = 1 - QFE[p].x; + + R p0 = l1; + R p1 = l1 * l2; + R p2 = l2; + R sa = QFE[p].a * s; + R cc2 = sa * p0; // + R cc1 = sa * p1; // + R cc0 = sa * p2; // + if (s < 0) { + swap(cc0, cc2); + } + + v[k++] = cc0 * E.x; + v[k++] = cc0 * E.y; + v[k++] = cc1 * E.x; + v[k++] = cc1 * E.y; + v[k++] = cc2 * E.x; + v[k++] = cc2 * E.y; } - // cout << " " << k << " == " << this->pij_alpha.N( ) << " " << QFE.n << endl; - // maintenant les 3 dof interne ... - for (int p = 0; p < QFT.n; ++p) { - R2 Q=T(QFT[p]); - for(int e=0; e<3;++e) - { - R a = QFT[p].a; - R2 P= (Q-(R2) T[e]).perp()/2; - if(Ortho) - P=P.perp( );// correction 4 sep 2023 FH.. - v[k++] = a * P.x ; - v[k++] = a * P.y ; - } - } - // cout << " " << k << " == " << this->pij_alpha.N( ) << " " << QFT.n <pij_alpha.N( )); - + } + // cout << " " << k << " == " << this->pij_alpha.N( ) << " " << QFE.n << endl; + // maintenant les 3 dof interne ... + for (int p = 0; p < QFT.n; ++p) { + R2 Q = T(QFT[p]); + for (int e = 0; e < 3; ++e) { + R a = QFT[p].a; + R2 P = (Q - (R2)T[e]).perp( ) / 2; + if (Ortho) P = P.perp( ); // correction 4 sep 2023 FH.. + v[k++] = a * P.x; + v[k++] = a * P.y; + } + } + // cout << " " << k << " == " << this->pij_alpha.N( ) << " " << QFT.n <pij_alpha.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; - -}; - -// ENDOFCLASS TypeOfFE_PkEdge -int TypeOfFE_BDM2_2d::Data[] = {3, 3, 3, 4,4,4, 5,5,5, 6,6,6, // support on what - 0, 1, 2, 0,1,2, 0,1,2, 0,1,2, // df on node - 0, 0, 0, 1,1,1, 2,2,2, 3,3,3, // th node of df - 0, 0, 0, 0,0,0, 0,0,0, 0,0,0, // df previou FE - 0, 1, 2, 3,4,5, 6,7,8, 9,10,11 , // which df on prev - 0,0,0,0, 12, 12}; -void TypeOfFE_BDM2_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { - R2 X = K(PHat); - R2 Q[] = {R2(K[0]), R2(K[1]), R2(K[2])}; - R det = K.area*2; - - R2 AB(Q[0],Q[1]),AC(Q[0],Q[2]),Piola[2]={R2(AB.x,AC.x)/det,R2(AB.y,AC.y)/det}; - // cout << " Piola : " << Piola[0] << " , " << Piola[1] << " " << det << endl; - R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; - R L[6] = {l0, l1, l2, l1*l2, l2*l0, l0*l1}; - R2 Dl[3] = {K.H(0), K.H(1), K.H(2)}; - R2 DL[6] = {Dl[0],Dl[1],Dl[2],l2*Dl[1]+l1*Dl[2], l2*Dl[0]+l0*Dl[2],l0*Dl[1]+l1*Dl[0] }; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + }; + + // ENDOFCLASS TypeOfFE_PkEdge + int TypeOfFE_BDM2_2d::Data[] = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // support on what + 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, // df on node + 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, // th node of df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // df previou FE + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, // which df on prev + 0, 0, 0, 0, 12, 12}; + void TypeOfFE_BDM2_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + R2 X = K(PHat); + R2 Q[] = {R2(K[0]), R2(K[1]), R2(K[2])}; + R det = K.area * 2; + + R2 AB(Q[0], Q[1]), AC(Q[0], Q[2]), Piola[2] = {R2(AB.x, AC.x) / det, R2(AB.y, AC.y) / det}; + // cout << " Piola : " << Piola[0] << " , " << Piola[1] << " " << det << endl; + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + R L[6] = {l0, l1, l2, l1 * l2, l2 * l0, l0 * l1}; + R2 Dl[3] = {K.H(0), K.H(1), K.H(2)}; + R2 DL[6] = {Dl[0], Dl[1], Dl[2], l2 * Dl[1] + l1 * Dl[2], l2 * Dl[0] + l0 * Dl[2], l0 * Dl[1] + l1 * Dl[0]}; R2 O; - R2 DDLx[6] = {O,O,O,Dl[2].x*Dl[1]+Dl[1].x*Dl[2], Dl[2].x*Dl[0]+Dl[0].x*Dl[2],Dl[1].x*Dl[2]+Dl[2].x*Dl[1] }; - R2 DDLy[6] = {O,O,O,Dl[2].y*Dl[1]+Dl[1].y*Dl[2], Dl[2].y*Dl[0]+Dl[0].y*Dl[2],Dl[1].y*Dl[2]+Dl[2].y*Dl[1] }; - - double C1[12][12] = { - {0, 0, 9, 0, 0, 3, -18, -12, 0, 0, -18, 0}, - {0, 0, -30, 0, 0, -30, 90, 90, 0, 30, 30, 0}, - {0, 0, 3, 0, 0, 9, -12, -18, 0, -18, 0, 0}, - - {9, 0, 0, 0, 3, -3, 0, 0, -30, 12, -18, 0}, - {-30, 0, 0, 0, -30, 30, 30, -30, 180, -90, 30, 0}, - {3, 0, 0, 0, 9, -9, -18, 18, -30, 18, 0, 0}, - - {0, -9, 3, -3, 0, 0, 0, 0, 0, 18, -12, 30}, - {0, 30, -30, 30, 0, 0, 30, -30, 0, -30, 90, -180}, - {0, -3, 9, -9, 0, 0, -18, 18, 0, 0, -18, 30}, - - {0, 0, 0, 0, 0, 0, -36, 36, 0, -12, 12, 0}, - {0, 0, 0, 0, 0, 0, -12, 12, 0, -36, 12, 0}, - {0, 0, 0, 0, 0, 0, -12, 12, 0, -12, 36, 0}}; - - - assert(val.N( ) >= 12); - assert(val.M( ) == 2); - - val = 0; - int p[12]={0,1,2,3,4,5,6,7,8,9,10,11}; - double oe[4]={K.EdgeOrientation(0),-K.EdgeOrientation(1),K.EdgeOrientation(2),1.}; - if (oe[0] < 0) swap(p[0],p[2]); - if (oe[1] < 0) swap(p[3],p[5]); - if (oe[2] < 0) swap(p[6],p[8]); - - if (whatd[op_id]) { + R2 DDLx[6] = {O, O, O, Dl[2].x * Dl[1] + Dl[1].x * Dl[2], Dl[2].x * Dl[0] + Dl[0].x * Dl[2], Dl[1].x * Dl[2] + Dl[2].x * Dl[1]}; + R2 DDLy[6] = {O, O, O, Dl[2].y * Dl[1] + Dl[1].y * Dl[2], Dl[2].y * Dl[0] + Dl[0].y * Dl[2], Dl[1].y * Dl[2] + Dl[2].y * Dl[1]}; + + double C1[12][12] = {{0, 0, 9, 0, 0, 3, -18, -12, 0, 0, -18, 0}, {0, 0, -30, 0, 0, -30, 90, 90, 0, 30, 30, 0}, {0, 0, 3, 0, 0, 9, -12, -18, 0, -18, 0, 0}, + + {9, 0, 0, 0, 3, -3, 0, 0, -30, 12, -18, 0}, {-30, 0, 0, 0, -30, 30, 30, -30, 180, -90, 30, 0}, {3, 0, 0, 0, 9, -9, -18, 18, -30, 18, 0, 0}, + + {0, -9, 3, -3, 0, 0, 0, 0, 0, 18, -12, 30}, {0, 30, -30, 30, 0, 0, 30, -30, 0, -30, 90, -180}, {0, -3, 9, -9, 0, 0, -18, 18, 0, 0, -18, 30}, + + {0, 0, 0, 0, 0, 0, -36, 36, 0, -12, 12, 0}, {0, 0, 0, 0, 0, 0, -12, 12, 0, -36, 12, 0}, {0, 0, 0, 0, 0, 0, -12, 12, 0, -12, 36, 0}}; + + assert(val.N( ) >= 12); + assert(val.M( ) == 2); + + val = 0; + int p[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + double oe[4] = {K.EdgeOrientation(0), -K.EdgeOrientation(1), K.EdgeOrientation(2), 1.}; + if (oe[0] < 0) swap(p[0], p[2]); + if (oe[1] < 0) swap(p[3], p[5]); + if (oe[2] < 0) swap(p[6], p[8]); + + if (whatd[op_id]) { R2 fb[12]; - for( int df =0; df <12; ++df) - { - R2 f; - for( int i =0; i <6; ++i)// - { - R2 fC(C1[df][2*i] , C1[df][2*i+1]); - f += L[i]*fC; - } - f*=oe[df/3];// signe du dof * fb[df] - fb[df]= R2((Piola[0],f),(Piola[1],f)); - if(Ortho) - fb[df]= fb[df].perp(); + for (int df = 0; df < 12; ++df) { + R2 f; + for (int i = 0; i < 6; ++i) // + { + R2 fC(C1[df][2 * i], C1[df][2 * i + 1]); + f += L[i] * fC; + } + f *= oe[df / 3]; // signe du dof * fb[df] + fb[df] = R2((Piola[0], f), (Piola[1], f)); + if (Ortho) fb[df] = fb[df].perp( ); } - - for( int df =0; df <12; ++df) - { + + for (int df = 0; df < 12; ++df) { val(df, 0, op_id) = fb[p[df]].x; val(df, 1, op_id) = fb[p[df]].y; + } } - } if (whatd[op_dx] || whatd[op_dy]) { - R2 fbx[12],fby[12];// Dx, Dy of f - for( int df =0; df <12; ++df) + R2 fbx[12], fby[12]; // Dx, Dy of f + for (int df = 0; df < 12; ++df) { + R2 fx, fy; + for (int i = 0; i < 6; ++i) // { - R2 fx,fy; - for( int i =0; i <6; ++i)// - { - R2 fC(C1[df][2*i] , C1[df][2*i+1]); - // cout << df << " "<< i <<" " << R2(ci,cii)<< endl; - fx += DL[i].x * fC; - fy += DL[i].y * fC; - } - fx*=oe[df/3];// signe ;du dof * fb[df] - fy*=oe[df/3];// signe du dof * fb[df] - R2 gx= R2((Piola[0],fx),(Piola[1],fx)); - R2 gy= R2((Piola[0],fy),(Piola[1],fy)); - if(Ortho) gx=gx.perp(),gy=gy.perp(); - fbx[df]= gx; - fby[df]= gy; - // cout << df << " -- gx : " << gx << " gy :" << gy << endl; - // for(int k=9; k<12;++k) cout<< k << " " << fb[k] << endl; + R2 fC(C1[df][2 * i], C1[df][2 * i + 1]); + // cout << df << " "<< i <<" " << R2(ci,cii)<< endl; + fx += DL[i].x * fC; + fy += DL[i].y * fC; } - if (whatd[op_dx]) { - for( int df =0; df <12; ++df) - { - val(df, 0, op_dx) = fbx[p[df]].x; - val(df, 1, op_dx) = fbx[p[df]].y; - } - + fx *= oe[df / 3]; // signe ;du dof * fb[df] + fy *= oe[df / 3]; // signe du dof * fb[df] + R2 gx = R2((Piola[0], fx), (Piola[1], fx)); + R2 gy = R2((Piola[0], fy), (Piola[1], fy)); + if (Ortho) gx = gx.perp( ), gy = gy.perp( ); + fbx[df] = gx; + fby[df] = gy; + // cout << df << " -- gx : " << gx << " gy :" << gy << endl; + // for(int k=9; k<12;++k) cout<< k << " " << fb[k] << endl; + } + if (whatd[op_dx]) { + for (int df = 0; df < 12; ++df) { + val(df, 0, op_dx) = fbx[p[df]].x; + val(df, 1, op_dx) = fbx[p[df]].y; } - if (whatd[op_dy]) { - for( int df =0; df <12; ++df) - { - val(df, 0, op_dy) = fby[p[df]].x; - val(df, 1, op_dy) = fby[p[df]].y; - } - + } + if (whatd[op_dy]) { + for (int df = 0; df < 12; ++df) { + val(df, 0, op_dy) = fby[p[df]].x; + val(df, 1, op_dy) = fby[p[df]].y; } + } } - if ( whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { - R2 fbxx[12],fbyy[12],fbxy[12];// Dx, Dy of f - ffassert(0); // To Do - if (whatd[op_dyy]) { - for( int df =0; df <12; ++df) - { - val(df, 0, op_dyy) = fbyy[p[df]].x; - val(df, 1, op_dyy) = fbyy[p[df]].y; - } - - } - if (whatd[op_dxx]) { - for( int df =0; df <12; ++df) - { - val(df, 0, op_dxx) = fbxx[p[df]].x; - val(df, 1, op_dxx) = fbxx[p[df]].y; - } - - } - if (whatd[op_dxy]) { - for( int df =0; df <12; ++df) - { - val(df, 0, op_dxy) = fbxy[p[df]].x; - val(df, 1, op_dxy) = fbxy[p[df]].y; - } - - } + if (whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 fbxx[12], fbyy[12], fbxy[12]; // Dx, Dy of f + ffassert(0); // To Do + if (whatd[op_dyy]) { + for (int df = 0; df < 12; ++df) { + val(df, 0, op_dyy) = fbyy[p[df]].x; + val(df, 1, op_dyy) = fbyy[p[df]].y; + } } - - + if (whatd[op_dxx]) { + for (int df = 0; df < 12; ++df) { + val(df, 0, op_dxx) = fbxx[p[df]].x; + val(df, 1, op_dxx) = fbxx[p[df]].y; + } + } + if (whatd[op_dxy]) { + for (int df = 0; df < 12; ++df) { + val(df, 0, op_dxy) = fbxy[p[df]].x; + val(df, 1, op_dxy) = fbxy[p[df]].y; + } + } + } } - - // a static variable to add the finite element to freefem++ - static TypeOfFE_RTdc Elm_TypeOfFE_RT0dc_2d; // RT0dc + static TypeOfFE_RTdc Elm_TypeOfFE_RT0dc_2d; // RT0dc static TypeOfFE_RT1_2d Elm_TypeOfFE_RT1_2d(false); // RT1 static TypeOfFE_RT1_2d Elm_TypeOfFE_RT1_2dOrtho(true); // RT1ortho @@ -1476,10 +1405,10 @@ void TypeOfFE_BDM2_2d::FB(const bool *whatd, const Mesh &, const Triangle &K, co static AddNewFE Elm__TypeOfFE_RT2_2dOrtho("RT2Ortho", &Elm_TypeOfFE_RT2_2dOrtho); static AddNewFE Elm__TypeOfFE_BDM1_2d("BDM1", &Elm_TypeOfFE_BDM1_2d); static AddNewFE Elm__TypeOfFE_BDM1_2dOrtho("BDM1Ortho", &Elm_TypeOfFE_BDM1_2dOrtho); -static TypeOfFE_BDM2_2d Elm_TypeOfFE_BDM2_2d(false); // BDM1 -static TypeOfFE_BDM2_2d Elm_TypeOfFE_BDM2_2dOrtho(true); // BDM1ortho -static AddNewFE Elm__TypeOfFE_BDM2_2d("BDM2", &Elm_TypeOfFE_BDM2_2d); -static AddNewFE Elm__TypeOfFE_BDM2_2dOrtho("BDM2Ortho", &Elm_TypeOfFE_BDM2_2dOrtho); + static TypeOfFE_BDM2_2d Elm_TypeOfFE_BDM2_2d(false); // BDM1 + static TypeOfFE_BDM2_2d Elm_TypeOfFE_BDM2_2dOrtho(true); // BDM1ortho + static AddNewFE Elm__TypeOfFE_BDM2_2d("BDM2", &Elm_TypeOfFE_BDM2_2d); + static AddNewFE Elm__TypeOfFE_BDM2_2dOrtho("BDM2Ortho", &Elm_TypeOfFE_BDM2_2dOrtho); } // namespace Fem2D // --- fin -- diff --git a/plugin/seq/Element_Mixte3d.cpp b/plugin/seq/Element_Mixte3d.cpp index 735107d1a..50399b7a2 100644 --- a/plugin/seq/Element_Mixte3d.cpp +++ b/plugin/seq/Element_Mixte3d.cpp @@ -56,10 +56,8 @@ namespace Fem2D { static const GQuadratureFormular< R1 > QFe; // quadrature formula on an edge static const GQuadratureFormular< R2 > QFf; // quadrature formula on a face TypeOfFE_Edge1_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; }; int TypeOfFE_Edge1_3d::dfon[] = {0, 2, 2, 0}; // 2 dofs on each edge, 2 dofs on each face @@ -71,10 +69,8 @@ namespace Fem2D { // Quadrature formula on a face, exact for degree 2 (ok: int_f (deg2*t)), internal quadrature // points - static GQuadraturePoint< R2 > P_QuadratureFormular_T_2_intp[3] = { - GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 4. / 6.)), - GQuadraturePoint< R2 >(1. / 3., R2(4. / 6., 1. / 6.)), - GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 1. / 6.))}; + static GQuadraturePoint< R2 > P_QuadratureFormular_T_2_intp[3] = {GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 4. / 6.)), GQuadraturePoint< R2 >(1. / 3., R2(4. / 6., 1. / 6.)), + GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 1. / 6.))}; const GQuadratureFormular< R2 > TypeOfFE_Edge1_3d::QFf(2, 3, P_QuadratureFormular_T_2_intp); // In Mesh3dn.cpp: @@ -97,13 +93,10 @@ namespace Fem2D { // npPi = NbPtforInterpolation = ne*QFe.n+nf*QFf.n // invariantinterpolationMatrix = false (i.e. it depends on the tetrahedron), discon=true TypeOfFE_Edge1_3d::TypeOfFE_Edge1_3d( ) - : GTypeOfFE< Mesh3 >(TypeOfFE_Edge1_3d::dfon, d, 1, - Element::ne * 2 * 3 * QFe.n + Element::nf * 2 * 3 * QFf.n, - Element::ne * QFe.n + Element::nf * QFf.n, false, true) { + : GTypeOfFE< Mesh3 >(TypeOfFE_Edge1_3d::dfon, d, 1, Element::ne * 2 * 3 * QFe.n + Element::nf * 2 * 3 * QFf.n, Element::ne * QFe.n + Element::nf * QFf.n, false, true) { assert(QFe.n); assert(QFf.n); - R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices { // We build the interpolation pts on the edges of the reference tetrahedron: @@ -113,8 +106,7 @@ namespace Fem2D { for (int e = 0; e < Element::ne; ++e) { for (int q = 0; q < QFe.n; ++q, ++i) { double x = QFe[q].x; - this->PtInterpolation[i] = - Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); + this->PtInterpolation[i] = Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); } } @@ -124,8 +116,7 @@ namespace Fem2D { for (int q = 0; q < QFf.n; ++q, ++i) { double x = QFf[q].x; double y = QFf[q].y; - this->PtInterpolation[i] = Pt[Element::nvface[f][0]] * (1. - x - y) + - Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; + this->PtInterpolation[i] = Pt[Element::nvface[f][0]] * (1. - x - y) + Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; } } } @@ -134,7 +125,7 @@ namespace Fem2D { int i = 0, p = 0; // i is the k in (13.1) (chapter 13 ff++doc) int e; // we will need e also below, in the part referred to faces - for (e = 0; e < (Element::ne)*2; e++) { // loop on the 12 dofs + for (e = 0; e < (Element::ne) * 2; e++) { // loop on the 12 dofs if (e % 2 == 1) { p = p - QFe.n; } // if I consider an 'even' dof, the quad pts are the ones of the previous dof (they @@ -153,7 +144,7 @@ namespace Fem2D { // We build the indices in (13.1) : face dofs // (the indices i and p mustn't be reinitialised) - for (int f = 0; f < (Element::nf)*2; f++) { // loop on the 8 dofs + for (int f = 0; f < (Element::nf) * 2; f++) { // loop on the 8 dofs if (f % 2 == 1) { p = p - QFf.n; } // if I consider an 'even' dof, the quad pts are the ones of the previous dof (they @@ -173,17 +164,16 @@ namespace Fem2D { } // For the coefficients of interpolation alphak in (13.1) - void TypeOfFE_Edge1_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_Edge1_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { int i = ocoef, p = 0; // 12 edge dofs int e; - for (e = 0; e < (Element::ne)*2; e++) { + for (e = 0; e < (Element::ne) * 2; e++) { int ee = e / 2; int eo = K.EdgeOrientation(ee) > 0; // change FH; jan 2019 - R3 E = K.Edge(ee); // the edge local number is given by the integer division betweeand + R3 E = K.Edge(ee); // the edge local number is given by the integer division betweeand if (!eo) { E = -E; } @@ -212,11 +202,10 @@ namespace Fem2D { // (the indices i and p mustn't be reinitialised) // 8 face dofs - for (int f = 0; f < (Element::nf)*2; f++) { // loop on the 8 face dofs - int ff = f / 2; // the face number - int iff = f % 2; // 1st or 2nd dof of the face - const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), - &K.at(Element::nvface[ff][2])}; + for (int f = 0; f < (Element::nf) * 2; f++) { // loop on the 8 face dofs + int ff = f / 2; // the face number + int iff = f % 2; // 1st or 2nd dof of the face + const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), &K.at(Element::nvface[ff][2])}; // We 'order' the 3 vertices of the face according to their global numbers: // i0 will be the local number in the FACE of the vertex with the smallest global number // i1 will be the local number in the face of the vertex with the second smallest global @@ -289,8 +278,7 @@ namespace Fem2D { // val contains the values of the basis functions and of their derivatives at the point of K // corresponding to the point P of the reference tetrahedron, by components - void TypeOfFE_Edge1_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_Edge1_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 20); // 20 degrees of freedom assert(val.M( ) == 3); // 3 components // ------------- @@ -332,8 +320,7 @@ namespace Fem2D { // ------------- // If [a,b] is the i-th edge (where a,b are its vertices local numbers), edgesMap[(a+1)*(b+1)] = // i - int edgesMap[13] = {-1, -1, 0, 1, 2, -1, 3, - -1, 4, -1, -1, -1, 5}; // a map would be more slow + int edgesMap[13] = {-1, -1, 0, 1, 2, -1, 3, -1, 4, -1, -1, -1, 5}; // a map would be more slow // ------------- // the 4 barycentric coordinates for the reference tetrahedron evaluated at the point P // (they have the same value at the real tetrahedron's point corresponding to the reference @@ -401,30 +388,18 @@ namespace Fem2D { // Now, the functions phi that really constitute a dual basis R3 phi[20]; - phi[p20[0]] = +4 * omega[0] - 2 * omega[1] - 4 * omega[16] + 2 * omega[17] - 4 * omega[18] + - 2 * omega[19]; - phi[p20[1]] = -2 * omega[0] + 4 * omega[1] - 2 * omega[16] - 2 * omega[17] - 2 * omega[18] - - 2 * omega[19]; - phi[p20[2]] = +4 * omega[2] - 2 * omega[3] - 4 * omega[14] + 2 * omega[15] + 2 * omega[18] - - 4 * omega[19]; - phi[p20[3]] = -2 * omega[2] + 4 * omega[3] - 2 * omega[14] - 2 * omega[15] - 2 * omega[18] - - 2 * omega[19]; - phi[p20[4]] = +4 * omega[4] - 2 * omega[5] + 2 * omega[14] - 4 * omega[15] + 2 * omega[16] - - 4 * omega[17]; - phi[p20[5]] = -2 * omega[4] + 4 * omega[5] - 2 * omega[14] - 2 * omega[15] - 2 * omega[16] - - 2 * omega[17]; - phi[p20[6]] = +4 * omega[6] - 2 * omega[7] - 4 * omega[12] + 2 * omega[13] + 2 * omega[18] - - 4 * omega[19]; - phi[p20[7]] = -2 * omega[6] + 4 * omega[7] - 2 * omega[12] - 2 * omega[13] + 4 * omega[18] - - 2 * omega[19]; - phi[p20[8]] = +4 * omega[8] - 2 * omega[9] + 2 * omega[12] - 4 * omega[13] + 2 * omega[16] - - 4 * omega[17]; - phi[p20[9]] = -2 * omega[8] + 4 * omega[9] - 2 * omega[12] - 2 * omega[13] + 4 * omega[16] - - 2 * omega[17]; - phi[p20[10]] = +4 * omega[10] - 2 * omega[11] + 2 * omega[12] - 4 * omega[13] + - 2 * omega[14] - 4 * omega[15]; - phi[p20[11]] = -2 * omega[10] + 4 * omega[11] + 4 * omega[12] - 2 * omega[13] + - 4 * omega[14] - 2 * omega[15]; + phi[p20[0]] = +4 * omega[0] - 2 * omega[1] - 4 * omega[16] + 2 * omega[17] - 4 * omega[18] + 2 * omega[19]; + phi[p20[1]] = -2 * omega[0] + 4 * omega[1] - 2 * omega[16] - 2 * omega[17] - 2 * omega[18] - 2 * omega[19]; + phi[p20[2]] = +4 * omega[2] - 2 * omega[3] - 4 * omega[14] + 2 * omega[15] + 2 * omega[18] - 4 * omega[19]; + phi[p20[3]] = -2 * omega[2] + 4 * omega[3] - 2 * omega[14] - 2 * omega[15] - 2 * omega[18] - 2 * omega[19]; + phi[p20[4]] = +4 * omega[4] - 2 * omega[5] + 2 * omega[14] - 4 * omega[15] + 2 * omega[16] - 4 * omega[17]; + phi[p20[5]] = -2 * omega[4] + 4 * omega[5] - 2 * omega[14] - 2 * omega[15] - 2 * omega[16] - 2 * omega[17]; + phi[p20[6]] = +4 * omega[6] - 2 * omega[7] - 4 * omega[12] + 2 * omega[13] + 2 * omega[18] - 4 * omega[19]; + phi[p20[7]] = -2 * omega[6] + 4 * omega[7] - 2 * omega[12] - 2 * omega[13] + 4 * omega[18] - 2 * omega[19]; + phi[p20[8]] = +4 * omega[8] - 2 * omega[9] + 2 * omega[12] - 4 * omega[13] + 2 * omega[16] - 4 * omega[17]; + phi[p20[9]] = -2 * omega[8] + 4 * omega[9] - 2 * omega[12] - 2 * omega[13] + 4 * omega[16] - 2 * omega[17]; + phi[p20[10]] = +4 * omega[10] - 2 * omega[11] + 2 * omega[12] - 4 * omega[13] + 2 * omega[14] - 4 * omega[15]; + phi[p20[11]] = -2 * omega[10] + 4 * omega[11] + 4 * omega[12] - 2 * omega[13] + 4 * omega[14] - 2 * omega[15]; phi[p20[12]] = +8 * omega[12] - 4 * omega[13]; phi[p20[13]] = -4 * omega[12] + 8 * omega[13]; phi[p20[14]] = +8 * omega[14] - 4 * omega[15]; @@ -454,24 +429,18 @@ namespace Fem2D { // using perm, [i0,i1] is already from the smallest global number to the greatest global // number, since nvedge always gives indices which read perm from left to right if (whatd & Fop_dx) { - omegadx[i * 2] = - D[i0].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadx[i * 2 + 1] = - D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadx[i * 2] = D[i0].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadx[i * 2 + 1] = D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dy) { - omegady[i * 2] = - D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegady[i * 2 + 1] = - D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegady[i * 2] = D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegady[i * 2 + 1] = D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); } if (whatd & Fop_dz) { - omegadz[i * 2] = - D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omegadz[i * 2 + 1] = - D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadz[i * 2] = D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadz[i * 2 + 1] = D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); } } @@ -488,53 +457,35 @@ namespace Fem2D { int i1 = perm[ii1]; int i2 = perm[ii2]; if (whatd & Fop_dx) { - omegadx[12 + j * 2] = - D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadx[12 + j * 2 + 1] = - D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omegadx[12 + j * 2] = D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadx[12 + j * 2 + 1] = D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dy) { - omegady[12 + j * 2] = - D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegady[12 + j * 2 + 1] = - D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omegady[12 + j * 2] = D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegady[12 + j * 2 + 1] = D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); } if (whatd & Fop_dz) { - omegadz[12 + j * 2] = - D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omegadz[12 + j * 2 + 1] = - D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omegadz[12 + j * 2] = D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadz[12 + j * 2 + 1] = D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); } } R3 phidx[20]; if (whatd & Fop_dx) { - phidx[p20[0]] = +4 * omegadx[0] - 2 * omegadx[1] - 4 * omegadx[16] + 2 * omegadx[17] - - 4 * omegadx[18] + 2 * omegadx[19]; - phidx[p20[1]] = -2 * omegadx[0] + 4 * omegadx[1] - 2 * omegadx[16] - 2 * omegadx[17] - - 2 * omegadx[18] - 2 * omegadx[19]; - phidx[p20[2]] = +4 * omegadx[2] - 2 * omegadx[3] - 4 * omegadx[14] + 2 * omegadx[15] + - 2 * omegadx[18] - 4 * omegadx[19]; - phidx[p20[3]] = -2 * omegadx[2] + 4 * omegadx[3] - 2 * omegadx[14] - 2 * omegadx[15] - - 2 * omegadx[18] - 2 * omegadx[19]; - phidx[p20[4]] = +4 * omegadx[4] - 2 * omegadx[5] + 2 * omegadx[14] - 4 * omegadx[15] + - 2 * omegadx[16] - 4 * omegadx[17]; - phidx[p20[5]] = -2 * omegadx[4] + 4 * omegadx[5] - 2 * omegadx[14] - 2 * omegadx[15] - - 2 * omegadx[16] - 2 * omegadx[17]; - phidx[p20[6]] = +4 * omegadx[6] - 2 * omegadx[7] - 4 * omegadx[12] + 2 * omegadx[13] + - 2 * omegadx[18] - 4 * omegadx[19]; - phidx[p20[7]] = -2 * omegadx[6] + 4 * omegadx[7] - 2 * omegadx[12] - 2 * omegadx[13] + - 4 * omegadx[18] - 2 * omegadx[19]; - phidx[p20[8]] = +4 * omegadx[8] - 2 * omegadx[9] + 2 * omegadx[12] - 4 * omegadx[13] + - 2 * omegadx[16] - 4 * omegadx[17]; - phidx[p20[9]] = -2 * omegadx[8] + 4 * omegadx[9] - 2 * omegadx[12] - 2 * omegadx[13] + - 4 * omegadx[16] - 2 * omegadx[17]; - phidx[p20[10]] = +4 * omegadx[10] - 2 * omegadx[11] + 2 * omegadx[12] - 4 * omegadx[13] + - 2 * omegadx[14] - 4 * omegadx[15]; - phidx[p20[11]] = -2 * omegadx[10] + 4 * omegadx[11] + 4 * omegadx[12] - 2 * omegadx[13] + - 4 * omegadx[14] - 2 * omegadx[15]; + phidx[p20[0]] = +4 * omegadx[0] - 2 * omegadx[1] - 4 * omegadx[16] + 2 * omegadx[17] - 4 * omegadx[18] + 2 * omegadx[19]; + phidx[p20[1]] = -2 * omegadx[0] + 4 * omegadx[1] - 2 * omegadx[16] - 2 * omegadx[17] - 2 * omegadx[18] - 2 * omegadx[19]; + phidx[p20[2]] = +4 * omegadx[2] - 2 * omegadx[3] - 4 * omegadx[14] + 2 * omegadx[15] + 2 * omegadx[18] - 4 * omegadx[19]; + phidx[p20[3]] = -2 * omegadx[2] + 4 * omegadx[3] - 2 * omegadx[14] - 2 * omegadx[15] - 2 * omegadx[18] - 2 * omegadx[19]; + phidx[p20[4]] = +4 * omegadx[4] - 2 * omegadx[5] + 2 * omegadx[14] - 4 * omegadx[15] + 2 * omegadx[16] - 4 * omegadx[17]; + phidx[p20[5]] = -2 * omegadx[4] + 4 * omegadx[5] - 2 * omegadx[14] - 2 * omegadx[15] - 2 * omegadx[16] - 2 * omegadx[17]; + phidx[p20[6]] = +4 * omegadx[6] - 2 * omegadx[7] - 4 * omegadx[12] + 2 * omegadx[13] + 2 * omegadx[18] - 4 * omegadx[19]; + phidx[p20[7]] = -2 * omegadx[6] + 4 * omegadx[7] - 2 * omegadx[12] - 2 * omegadx[13] + 4 * omegadx[18] - 2 * omegadx[19]; + phidx[p20[8]] = +4 * omegadx[8] - 2 * omegadx[9] + 2 * omegadx[12] - 4 * omegadx[13] + 2 * omegadx[16] - 4 * omegadx[17]; + phidx[p20[9]] = -2 * omegadx[8] + 4 * omegadx[9] - 2 * omegadx[12] - 2 * omegadx[13] + 4 * omegadx[16] - 2 * omegadx[17]; + phidx[p20[10]] = +4 * omegadx[10] - 2 * omegadx[11] + 2 * omegadx[12] - 4 * omegadx[13] + 2 * omegadx[14] - 4 * omegadx[15]; + phidx[p20[11]] = -2 * omegadx[10] + 4 * omegadx[11] + 4 * omegadx[12] - 2 * omegadx[13] + 4 * omegadx[14] - 2 * omegadx[15]; phidx[p20[12]] = +8 * omegadx[12] - 4 * omegadx[13]; phidx[p20[13]] = -4 * omegadx[12] + 8 * omegadx[13]; phidx[p20[14]] = +8 * omegadx[14] - 4 * omegadx[15]; @@ -553,30 +504,18 @@ namespace Fem2D { R3 phidy[20]; if (whatd & Fop_dy) { - phidy[p20[0]] = +4 * omegady[0] - 2 * omegady[1] - 4 * omegady[16] + 2 * omegady[17] - - 4 * omegady[18] + 2 * omegady[19]; - phidy[p20[1]] = -2 * omegady[0] + 4 * omegady[1] - 2 * omegady[16] - 2 * omegady[17] - - 2 * omegady[18] - 2 * omegady[19]; - phidy[p20[2]] = +4 * omegady[2] - 2 * omegady[3] - 4 * omegady[14] + 2 * omegady[15] + - 2 * omegady[18] - 4 * omegady[19]; - phidy[p20[3]] = -2 * omegady[2] + 4 * omegady[3] - 2 * omegady[14] - 2 * omegady[15] - - 2 * omegady[18] - 2 * omegady[19]; - phidy[p20[4]] = +4 * omegady[4] - 2 * omegady[5] + 2 * omegady[14] - 4 * omegady[15] + - 2 * omegady[16] - 4 * omegady[17]; - phidy[p20[5]] = -2 * omegady[4] + 4 * omegady[5] - 2 * omegady[14] - 2 * omegady[15] - - 2 * omegady[16] - 2 * omegady[17]; - phidy[p20[6]] = +4 * omegady[6] - 2 * omegady[7] - 4 * omegady[12] + 2 * omegady[13] + - 2 * omegady[18] - 4 * omegady[19]; - phidy[p20[7]] = -2 * omegady[6] + 4 * omegady[7] - 2 * omegady[12] - 2 * omegady[13] + - 4 * omegady[18] - 2 * omegady[19]; - phidy[p20[8]] = +4 * omegady[8] - 2 * omegady[9] + 2 * omegady[12] - 4 * omegady[13] + - 2 * omegady[16] - 4 * omegady[17]; - phidy[p20[9]] = -2 * omegady[8] + 4 * omegady[9] - 2 * omegady[12] - 2 * omegady[13] + - 4 * omegady[16] - 2 * omegady[17]; - phidy[p20[10]] = +4 * omegady[10] - 2 * omegady[11] + 2 * omegady[12] - 4 * omegady[13] + - 2 * omegady[14] - 4 * omegady[15]; - phidy[p20[11]] = -2 * omegady[10] + 4 * omegady[11] + 4 * omegady[12] - 2 * omegady[13] + - 4 * omegady[14] - 2 * omegady[15]; + phidy[p20[0]] = +4 * omegady[0] - 2 * omegady[1] - 4 * omegady[16] + 2 * omegady[17] - 4 * omegady[18] + 2 * omegady[19]; + phidy[p20[1]] = -2 * omegady[0] + 4 * omegady[1] - 2 * omegady[16] - 2 * omegady[17] - 2 * omegady[18] - 2 * omegady[19]; + phidy[p20[2]] = +4 * omegady[2] - 2 * omegady[3] - 4 * omegady[14] + 2 * omegady[15] + 2 * omegady[18] - 4 * omegady[19]; + phidy[p20[3]] = -2 * omegady[2] + 4 * omegady[3] - 2 * omegady[14] - 2 * omegady[15] - 2 * omegady[18] - 2 * omegady[19]; + phidy[p20[4]] = +4 * omegady[4] - 2 * omegady[5] + 2 * omegady[14] - 4 * omegady[15] + 2 * omegady[16] - 4 * omegady[17]; + phidy[p20[5]] = -2 * omegady[4] + 4 * omegady[5] - 2 * omegady[14] - 2 * omegady[15] - 2 * omegady[16] - 2 * omegady[17]; + phidy[p20[6]] = +4 * omegady[6] - 2 * omegady[7] - 4 * omegady[12] + 2 * omegady[13] + 2 * omegady[18] - 4 * omegady[19]; + phidy[p20[7]] = -2 * omegady[6] + 4 * omegady[7] - 2 * omegady[12] - 2 * omegady[13] + 4 * omegady[18] - 2 * omegady[19]; + phidy[p20[8]] = +4 * omegady[8] - 2 * omegady[9] + 2 * omegady[12] - 4 * omegady[13] + 2 * omegady[16] - 4 * omegady[17]; + phidy[p20[9]] = -2 * omegady[8] + 4 * omegady[9] - 2 * omegady[12] - 2 * omegady[13] + 4 * omegady[16] - 2 * omegady[17]; + phidy[p20[10]] = +4 * omegady[10] - 2 * omegady[11] + 2 * omegady[12] - 4 * omegady[13] + 2 * omegady[14] - 4 * omegady[15]; + phidy[p20[11]] = -2 * omegady[10] + 4 * omegady[11] + 4 * omegady[12] - 2 * omegady[13] + 4 * omegady[14] - 2 * omegady[15]; phidy[p20[12]] = +8 * omegady[12] - 4 * omegady[13]; phidy[p20[13]] = -4 * omegady[12] + 8 * omegady[13]; phidy[p20[14]] = +8 * omegady[14] - 4 * omegady[15]; @@ -595,30 +534,18 @@ namespace Fem2D { R3 phidz[20]; if (whatd & Fop_dz) { - phidz[p20[0]] = +4 * omegadz[0] - 2 * omegadz[1] - 4 * omegadz[16] + 2 * omegadz[17] - - 4 * omegadz[18] + 2 * omegadz[19]; - phidz[p20[1]] = -2 * omegadz[0] + 4 * omegadz[1] - 2 * omegadz[16] - 2 * omegadz[17] - - 2 * omegadz[18] - 2 * omegadz[19]; - phidz[p20[2]] = +4 * omegadz[2] - 2 * omegadz[3] - 4 * omegadz[14] + 2 * omegadz[15] + - 2 * omegadz[18] - 4 * omegadz[19]; - phidz[p20[3]] = -2 * omegadz[2] + 4 * omegadz[3] - 2 * omegadz[14] - 2 * omegadz[15] - - 2 * omegadz[18] - 2 * omegadz[19]; - phidz[p20[4]] = +4 * omegadz[4] - 2 * omegadz[5] + 2 * omegadz[14] - 4 * omegadz[15] + - 2 * omegadz[16] - 4 * omegadz[17]; - phidz[p20[5]] = -2 * omegadz[4] + 4 * omegadz[5] - 2 * omegadz[14] - 2 * omegadz[15] - - 2 * omegadz[16] - 2 * omegadz[17]; - phidz[p20[6]] = +4 * omegadz[6] - 2 * omegadz[7] - 4 * omegadz[12] + 2 * omegadz[13] + - 2 * omegadz[18] - 4 * omegadz[19]; - phidz[p20[7]] = -2 * omegadz[6] + 4 * omegadz[7] - 2 * omegadz[12] - 2 * omegadz[13] + - 4 * omegadz[18] - 2 * omegadz[19]; - phidz[p20[8]] = +4 * omegadz[8] - 2 * omegadz[9] + 2 * omegadz[12] - 4 * omegadz[13] + - 2 * omegadz[16] - 4 * omegadz[17]; - phidz[p20[9]] = -2 * omegadz[8] + 4 * omegadz[9] - 2 * omegadz[12] - 2 * omegadz[13] + - 4 * omegadz[16] - 2 * omegadz[17]; - phidz[p20[10]] = +4 * omegadz[10] - 2 * omegadz[11] + 2 * omegadz[12] - 4 * omegadz[13] + - 2 * omegadz[14] - 4 * omegadz[15]; - phidz[p20[11]] = -2 * omegadz[10] + 4 * omegadz[11] + 4 * omegadz[12] - 2 * omegadz[13] + - 4 * omegadz[14] - 2 * omegadz[15]; + phidz[p20[0]] = +4 * omegadz[0] - 2 * omegadz[1] - 4 * omegadz[16] + 2 * omegadz[17] - 4 * omegadz[18] + 2 * omegadz[19]; + phidz[p20[1]] = -2 * omegadz[0] + 4 * omegadz[1] - 2 * omegadz[16] - 2 * omegadz[17] - 2 * omegadz[18] - 2 * omegadz[19]; + phidz[p20[2]] = +4 * omegadz[2] - 2 * omegadz[3] - 4 * omegadz[14] + 2 * omegadz[15] + 2 * omegadz[18] - 4 * omegadz[19]; + phidz[p20[3]] = -2 * omegadz[2] + 4 * omegadz[3] - 2 * omegadz[14] - 2 * omegadz[15] - 2 * omegadz[18] - 2 * omegadz[19]; + phidz[p20[4]] = +4 * omegadz[4] - 2 * omegadz[5] + 2 * omegadz[14] - 4 * omegadz[15] + 2 * omegadz[16] - 4 * omegadz[17]; + phidz[p20[5]] = -2 * omegadz[4] + 4 * omegadz[5] - 2 * omegadz[14] - 2 * omegadz[15] - 2 * omegadz[16] - 2 * omegadz[17]; + phidz[p20[6]] = +4 * omegadz[6] - 2 * omegadz[7] - 4 * omegadz[12] + 2 * omegadz[13] + 2 * omegadz[18] - 4 * omegadz[19]; + phidz[p20[7]] = -2 * omegadz[6] + 4 * omegadz[7] - 2 * omegadz[12] - 2 * omegadz[13] + 4 * omegadz[18] - 2 * omegadz[19]; + phidz[p20[8]] = +4 * omegadz[8] - 2 * omegadz[9] + 2 * omegadz[12] - 4 * omegadz[13] + 2 * omegadz[16] - 4 * omegadz[17]; + phidz[p20[9]] = -2 * omegadz[8] + 4 * omegadz[9] - 2 * omegadz[12] - 2 * omegadz[13] + 4 * omegadz[16] - 2 * omegadz[17]; + phidz[p20[10]] = +4 * omegadz[10] - 2 * omegadz[11] + 2 * omegadz[12] - 4 * omegadz[13] + 2 * omegadz[14] - 4 * omegadz[15]; + phidz[p20[11]] = -2 * omegadz[10] + 4 * omegadz[11] + 4 * omegadz[12] - 2 * omegadz[13] + 4 * omegadz[14] - 2 * omegadz[15]; phidz[p20[12]] = +8 * omegadz[12] - 4 * omegadz[13]; phidz[p20[13]] = -4 * omegadz[12] + 8 * omegadz[13]; phidz[p20[14]] = +8 * omegadz[14] - 4 * omegadz[15]; @@ -652,45 +579,33 @@ namespace Fem2D { // using perm, [i0,i1] is already from the smallest global number to the greatest global // number, since nvedge always gives indices which read perm from left to right if (whatd & Fop_dxx) { - omegadxx[i * 2] = D[i0].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + - D[i0].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxx[i * 2 + 1] = D[i1].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + - D[i1].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxx[i * 2] = D[i0].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + D[i0].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxx[i * 2 + 1] = D[i1].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + D[i1].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dyy) { - omegadyy[i * 2] = D[i0].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i0].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegadyy[i * 2 + 1] = D[i1].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i1].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyy[i * 2] = D[i0].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i0].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyy[i * 2 + 1] = D[i1].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i1].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); } if (whatd & Fop_dzz) { - omegadzz[i * 2] = D[i0].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i0].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omegadzz[i * 2 + 1] = D[i1].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i1].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadzz[i * 2] = D[i0].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i0].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadzz[i * 2 + 1] = D[i1].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i1].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); } if (whatd & Fop_dxy) { - omegadxy[i * 2] = D[i0].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i0].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxy[i * 2 + 1] = D[i1].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i1].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxy[i * 2] = D[i0].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i0].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxy[i * 2 + 1] = D[i1].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i1].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dxz) { - omegadxz[i * 2] = D[i0].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i0].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxz[i * 2 + 1] = D[i1].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i1].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxz[i * 2] = D[i0].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i0].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxz[i * 2 + 1] = D[i1].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i1].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dyz) { - omegadyz[i * 2] = D[i0].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i0].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegadyz[i * 2 + 1] = D[i1].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i1].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyz[i * 2] = D[i0].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i0].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyz[i * 2 + 1] = D[i1].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i1].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); } } @@ -707,74 +622,50 @@ namespace Fem2D { int i1 = perm[ii1]; int i2 = perm[ii2]; if (whatd & Fop_dxx) { - omegadxx[12 + j * 2] = D[i2].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + - D[i2].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxx[12 + j * 2 + 1] = D[i1].x * (D[i0].x * D[i2] - D[i2].x * D[i0]) + - D[i1].x * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omegadxx[12 + j * 2] = D[i2].x * (D[i0].x * D[i1] - D[i1].x * D[i0]) + D[i2].x * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxx[12 + j * 2 + 1] = D[i1].x * (D[i0].x * D[i2] - D[i2].x * D[i0]) + D[i1].x * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dyy) { - omegadyy[12 + j * 2] = D[i2].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i2].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegadyy[12 + j * 2 + 1] = D[i1].y * (D[i0].y * D[i2] - D[i2].y * D[i0]) + - D[i1].y * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omegadyy[12 + j * 2] = D[i2].y * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i2].y * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyy[12 + j * 2 + 1] = D[i1].y * (D[i0].y * D[i2] - D[i2].y * D[i0]) + D[i1].y * (D[i0].y * D[i2] - D[i2].y * D[i0]); } if (whatd & Fop_dzz) { - omegadzz[12 + j * 2] = D[i2].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i2].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omegadzz[12 + j * 2 + 1] = D[i1].z * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - D[i1].z * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omegadzz[12 + j * 2] = D[i2].z * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i2].z * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omegadzz[12 + j * 2 + 1] = D[i1].z * (D[i0].z * D[i2] - D[i2].z * D[i0]) + D[i1].z * (D[i0].z * D[i2] - D[i2].z * D[i0]); } if (whatd & Fop_dxy) { - omegadxy[12 + j * 2] = D[i2].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - D[i2].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxy[12 + j * 2 + 1] = D[i1].x * (D[i0].y * D[i2] - D[i2].y * D[i0]) + - D[i1].y * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omegadxy[12 + j * 2] = D[i2].x * (D[i0].y * D[i1] - D[i1].y * D[i0]) + D[i2].y * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxy[12 + j * 2 + 1] = D[i1].x * (D[i0].y * D[i2] - D[i2].y * D[i0]) + D[i1].y * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dxz) { - omegadxz[12 + j * 2] = D[i2].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i2].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omegadxz[12 + j * 2 + 1] = D[i1].x * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - D[i1].z * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omegadxz[12 + j * 2] = D[i2].x * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i2].z * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omegadxz[12 + j * 2 + 1] = D[i1].x * (D[i0].z * D[i2] - D[i2].z * D[i0]) + D[i1].z * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dyz) { - omegadyz[12 + j * 2] = D[i2].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - D[i2].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omegadyz[12 + j * 2 + 1] = D[i1].y * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - D[i1].z * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omegadyz[12 + j * 2] = D[i2].y * (D[i0].z * D[i1] - D[i1].z * D[i0]) + D[i2].z * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omegadyz[12 + j * 2 + 1] = D[i1].y * (D[i0].z * D[i2] - D[i2].z * D[i0]) + D[i1].z * (D[i0].y * D[i2] - D[i2].y * D[i0]); } } R3 phidxx[20]; if (whatd & Fop_dxx) { - phidxx[p20[0]] = +4 * omegadxx[0] - 2 * omegadxx[1] - 4 * omegadxx[16] + 2 * omegadxx[17] - - 4 * omegadxx[18] + 2 * omegadxx[19]; - phidxx[p20[1]] = -2 * omegadxx[0] + 4 * omegadxx[1] - 2 * omegadxx[16] - 2 * omegadxx[17] - - 2 * omegadxx[18] - 2 * omegadxx[19]; - phidxx[p20[2]] = +4 * omegadxx[2] - 2 * omegadxx[3] - 4 * omegadxx[14] + 2 * omegadxx[15] + - 2 * omegadxx[18] - 4 * omegadxx[19]; - phidxx[p20[3]] = -2 * omegadxx[2] + 4 * omegadxx[3] - 2 * omegadxx[14] - 2 * omegadxx[15] - - 2 * omegadxx[18] - 2 * omegadxx[19]; - phidxx[p20[4]] = +4 * omegadxx[4] - 2 * omegadxx[5] + 2 * omegadxx[14] - 4 * omegadxx[15] + - 2 * omegadxx[16] - 4 * omegadxx[17]; - phidxx[p20[5]] = -2 * omegadxx[4] + 4 * omegadxx[5] - 2 * omegadxx[14] - 2 * omegadxx[15] - - 2 * omegadxx[16] - 2 * omegadxx[17]; - phidxx[p20[6]] = +4 * omegadxx[6] - 2 * omegadxx[7] - 4 * omegadxx[12] + 2 * omegadxx[13] + - 2 * omegadxx[18] - 4 * omegadxx[19]; - phidxx[p20[7]] = -2 * omegadxx[6] + 4 * omegadxx[7] - 2 * omegadxx[12] - 2 * omegadxx[13] + - 4 * omegadxx[18] - 2 * omegadxx[19]; - phidxx[p20[8]] = +4 * omegadxx[8] - 2 * omegadxx[9] + 2 * omegadxx[12] - 4 * omegadxx[13] + - 2 * omegadxx[16] - 4 * omegadxx[17]; - phidxx[p20[9]] = -2 * omegadxx[8] + 4 * omegadxx[9] - 2 * omegadxx[12] - 2 * omegadxx[13] + - 4 * omegadxx[16] - 2 * omegadxx[17]; - phidxx[p20[10]] = +4 * omegadxx[10] - 2 * omegadxx[11] + 2 * omegadxx[12] - - 4 * omegadxx[13] + 2 * omegadxx[14] - 4 * omegadxx[15]; - phidxx[p20[11]] = -2 * omegadxx[10] + 4 * omegadxx[11] + 4 * omegadxx[12] - - 2 * omegadxx[13] + 4 * omegadxx[14] - 2 * omegadxx[15]; + phidxx[p20[0]] = +4 * omegadxx[0] - 2 * omegadxx[1] - 4 * omegadxx[16] + 2 * omegadxx[17] - 4 * omegadxx[18] + 2 * omegadxx[19]; + phidxx[p20[1]] = -2 * omegadxx[0] + 4 * omegadxx[1] - 2 * omegadxx[16] - 2 * omegadxx[17] - 2 * omegadxx[18] - 2 * omegadxx[19]; + phidxx[p20[2]] = +4 * omegadxx[2] - 2 * omegadxx[3] - 4 * omegadxx[14] + 2 * omegadxx[15] + 2 * omegadxx[18] - 4 * omegadxx[19]; + phidxx[p20[3]] = -2 * omegadxx[2] + 4 * omegadxx[3] - 2 * omegadxx[14] - 2 * omegadxx[15] - 2 * omegadxx[18] - 2 * omegadxx[19]; + phidxx[p20[4]] = +4 * omegadxx[4] - 2 * omegadxx[5] + 2 * omegadxx[14] - 4 * omegadxx[15] + 2 * omegadxx[16] - 4 * omegadxx[17]; + phidxx[p20[5]] = -2 * omegadxx[4] + 4 * omegadxx[5] - 2 * omegadxx[14] - 2 * omegadxx[15] - 2 * omegadxx[16] - 2 * omegadxx[17]; + phidxx[p20[6]] = +4 * omegadxx[6] - 2 * omegadxx[7] - 4 * omegadxx[12] + 2 * omegadxx[13] + 2 * omegadxx[18] - 4 * omegadxx[19]; + phidxx[p20[7]] = -2 * omegadxx[6] + 4 * omegadxx[7] - 2 * omegadxx[12] - 2 * omegadxx[13] + 4 * omegadxx[18] - 2 * omegadxx[19]; + phidxx[p20[8]] = +4 * omegadxx[8] - 2 * omegadxx[9] + 2 * omegadxx[12] - 4 * omegadxx[13] + 2 * omegadxx[16] - 4 * omegadxx[17]; + phidxx[p20[9]] = -2 * omegadxx[8] + 4 * omegadxx[9] - 2 * omegadxx[12] - 2 * omegadxx[13] + 4 * omegadxx[16] - 2 * omegadxx[17]; + phidxx[p20[10]] = +4 * omegadxx[10] - 2 * omegadxx[11] + 2 * omegadxx[12] - 4 * omegadxx[13] + 2 * omegadxx[14] - 4 * omegadxx[15]; + phidxx[p20[11]] = -2 * omegadxx[10] + 4 * omegadxx[11] + 4 * omegadxx[12] - 2 * omegadxx[13] + 4 * omegadxx[14] - 2 * omegadxx[15]; phidxx[p20[12]] = +8 * omegadxx[12] - 4 * omegadxx[13]; phidxx[p20[13]] = -4 * omegadxx[12] + 8 * omegadxx[13]; phidxx[p20[14]] = +8 * omegadxx[14] - 4 * omegadxx[15]; @@ -793,30 +684,18 @@ namespace Fem2D { R3 phidyy[20]; if (whatd & Fop_dyy) { - phidyy[p20[0]] = +4 * omegadyy[0] - 2 * omegadyy[1] - 4 * omegadyy[16] + 2 * omegadyy[17] - - 4 * omegadyy[18] + 2 * omegadyy[19]; - phidyy[p20[1]] = -2 * omegadyy[0] + 4 * omegadyy[1] - 2 * omegadyy[16] - 2 * omegadyy[17] - - 2 * omegadyy[18] - 2 * omegadyy[19]; - phidyy[p20[2]] = +4 * omegadyy[2] - 2 * omegadyy[3] - 4 * omegadyy[14] + 2 * omegadyy[15] + - 2 * omegadyy[18] - 4 * omegadyy[19]; - phidyy[p20[3]] = -2 * omegadyy[2] + 4 * omegadyy[3] - 2 * omegadyy[14] - 2 * omegadyy[15] - - 2 * omegadyy[18] - 2 * omegadyy[19]; - phidyy[p20[4]] = +4 * omegadyy[4] - 2 * omegadyy[5] + 2 * omegadyy[14] - 4 * omegadyy[15] + - 2 * omegadyy[16] - 4 * omegadyy[17]; - phidyy[p20[5]] = -2 * omegadyy[4] + 4 * omegadyy[5] - 2 * omegadyy[14] - 2 * omegadyy[15] - - 2 * omegadyy[16] - 2 * omegadyy[17]; - phidyy[p20[6]] = +4 * omegadyy[6] - 2 * omegadyy[7] - 4 * omegadyy[12] + 2 * omegadyy[13] + - 2 * omegadyy[18] - 4 * omegadyy[19]; - phidyy[p20[7]] = -2 * omegadyy[6] + 4 * omegadyy[7] - 2 * omegadyy[12] - 2 * omegadyy[13] + - 4 * omegadyy[18] - 2 * omegadyy[19]; - phidyy[p20[8]] = +4 * omegadyy[8] - 2 * omegadyy[9] + 2 * omegadyy[12] - 4 * omegadyy[13] + - 2 * omegadyy[16] - 4 * omegadyy[17]; - phidyy[p20[9]] = -2 * omegadyy[8] + 4 * omegadyy[9] - 2 * omegadyy[12] - 2 * omegadyy[13] + - 4 * omegadyy[16] - 2 * omegadyy[17]; - phidyy[p20[10]] = +4 * omegadyy[10] - 2 * omegadyy[11] + 2 * omegadyy[12] - - 4 * omegadyy[13] + 2 * omegadyy[14] - 4 * omegadyy[15]; - phidyy[p20[11]] = -2 * omegadyy[10] + 4 * omegadyy[11] + 4 * omegadyy[12] - - 2 * omegadyy[13] + 4 * omegadyy[14] - 2 * omegadyy[15]; + phidyy[p20[0]] = +4 * omegadyy[0] - 2 * omegadyy[1] - 4 * omegadyy[16] + 2 * omegadyy[17] - 4 * omegadyy[18] + 2 * omegadyy[19]; + phidyy[p20[1]] = -2 * omegadyy[0] + 4 * omegadyy[1] - 2 * omegadyy[16] - 2 * omegadyy[17] - 2 * omegadyy[18] - 2 * omegadyy[19]; + phidyy[p20[2]] = +4 * omegadyy[2] - 2 * omegadyy[3] - 4 * omegadyy[14] + 2 * omegadyy[15] + 2 * omegadyy[18] - 4 * omegadyy[19]; + phidyy[p20[3]] = -2 * omegadyy[2] + 4 * omegadyy[3] - 2 * omegadyy[14] - 2 * omegadyy[15] - 2 * omegadyy[18] - 2 * omegadyy[19]; + phidyy[p20[4]] = +4 * omegadyy[4] - 2 * omegadyy[5] + 2 * omegadyy[14] - 4 * omegadyy[15] + 2 * omegadyy[16] - 4 * omegadyy[17]; + phidyy[p20[5]] = -2 * omegadyy[4] + 4 * omegadyy[5] - 2 * omegadyy[14] - 2 * omegadyy[15] - 2 * omegadyy[16] - 2 * omegadyy[17]; + phidyy[p20[6]] = +4 * omegadyy[6] - 2 * omegadyy[7] - 4 * omegadyy[12] + 2 * omegadyy[13] + 2 * omegadyy[18] - 4 * omegadyy[19]; + phidyy[p20[7]] = -2 * omegadyy[6] + 4 * omegadyy[7] - 2 * omegadyy[12] - 2 * omegadyy[13] + 4 * omegadyy[18] - 2 * omegadyy[19]; + phidyy[p20[8]] = +4 * omegadyy[8] - 2 * omegadyy[9] + 2 * omegadyy[12] - 4 * omegadyy[13] + 2 * omegadyy[16] - 4 * omegadyy[17]; + phidyy[p20[9]] = -2 * omegadyy[8] + 4 * omegadyy[9] - 2 * omegadyy[12] - 2 * omegadyy[13] + 4 * omegadyy[16] - 2 * omegadyy[17]; + phidyy[p20[10]] = +4 * omegadyy[10] - 2 * omegadyy[11] + 2 * omegadyy[12] - 4 * omegadyy[13] + 2 * omegadyy[14] - 4 * omegadyy[15]; + phidyy[p20[11]] = -2 * omegadyy[10] + 4 * omegadyy[11] + 4 * omegadyy[12] - 2 * omegadyy[13] + 4 * omegadyy[14] - 2 * omegadyy[15]; phidyy[p20[12]] = +8 * omegadyy[12] - 4 * omegadyy[13]; phidyy[p20[13]] = -4 * omegadyy[12] + 8 * omegadyy[13]; phidyy[p20[14]] = +8 * omegadyy[14] - 4 * omegadyy[15]; @@ -835,30 +714,18 @@ namespace Fem2D { R3 phidzz[20]; if (whatd & Fop_dzz) { - phidzz[p20[0]] = +4 * omegadzz[0] - 2 * omegadzz[1] - 4 * omegadzz[16] + 2 * omegadzz[17] - - 4 * omegadzz[18] + 2 * omegadzz[19]; - phidzz[p20[1]] = -2 * omegadzz[0] + 4 * omegadzz[1] - 2 * omegadzz[16] - 2 * omegadzz[17] - - 2 * omegadzz[18] - 2 * omegadzz[19]; - phidzz[p20[2]] = +4 * omegadzz[2] - 2 * omegadzz[3] - 4 * omegadzz[14] + 2 * omegadzz[15] + - 2 * omegadzz[18] - 4 * omegadzz[19]; - phidzz[p20[3]] = -2 * omegadzz[2] + 4 * omegadzz[3] - 2 * omegadzz[14] - 2 * omegadzz[15] - - 2 * omegadzz[18] - 2 * omegadzz[19]; - phidzz[p20[4]] = +4 * omegadzz[4] - 2 * omegadzz[5] + 2 * omegadzz[14] - 4 * omegadzz[15] + - 2 * omegadzz[16] - 4 * omegadzz[17]; - phidzz[p20[5]] = -2 * omegadzz[4] + 4 * omegadzz[5] - 2 * omegadzz[14] - 2 * omegadzz[15] - - 2 * omegadzz[16] - 2 * omegadzz[17]; - phidzz[p20[6]] = +4 * omegadzz[6] - 2 * omegadzz[7] - 4 * omegadzz[12] + 2 * omegadzz[13] + - 2 * omegadzz[18] - 4 * omegadzz[19]; - phidzz[p20[7]] = -2 * omegadzz[6] + 4 * omegadzz[7] - 2 * omegadzz[12] - 2 * omegadzz[13] + - 4 * omegadzz[18] - 2 * omegadzz[19]; - phidzz[p20[8]] = +4 * omegadzz[8] - 2 * omegadzz[9] + 2 * omegadzz[12] - 4 * omegadzz[13] + - 2 * omegadzz[16] - 4 * omegadzz[17]; - phidzz[p20[9]] = -2 * omegadzz[8] + 4 * omegadzz[9] - 2 * omegadzz[12] - 2 * omegadzz[13] + - 4 * omegadzz[16] - 2 * omegadzz[17]; - phidzz[p20[10]] = +4 * omegadzz[10] - 2 * omegadzz[11] + 2 * omegadzz[12] - - 4 * omegadzz[13] + 2 * omegadzz[14] - 4 * omegadzz[15]; - phidzz[p20[11]] = -2 * omegadzz[10] + 4 * omegadzz[11] + 4 * omegadzz[12] - - 2 * omegadzz[13] + 4 * omegadzz[14] - 2 * omegadzz[15]; + phidzz[p20[0]] = +4 * omegadzz[0] - 2 * omegadzz[1] - 4 * omegadzz[16] + 2 * omegadzz[17] - 4 * omegadzz[18] + 2 * omegadzz[19]; + phidzz[p20[1]] = -2 * omegadzz[0] + 4 * omegadzz[1] - 2 * omegadzz[16] - 2 * omegadzz[17] - 2 * omegadzz[18] - 2 * omegadzz[19]; + phidzz[p20[2]] = +4 * omegadzz[2] - 2 * omegadzz[3] - 4 * omegadzz[14] + 2 * omegadzz[15] + 2 * omegadzz[18] - 4 * omegadzz[19]; + phidzz[p20[3]] = -2 * omegadzz[2] + 4 * omegadzz[3] - 2 * omegadzz[14] - 2 * omegadzz[15] - 2 * omegadzz[18] - 2 * omegadzz[19]; + phidzz[p20[4]] = +4 * omegadzz[4] - 2 * omegadzz[5] + 2 * omegadzz[14] - 4 * omegadzz[15] + 2 * omegadzz[16] - 4 * omegadzz[17]; + phidzz[p20[5]] = -2 * omegadzz[4] + 4 * omegadzz[5] - 2 * omegadzz[14] - 2 * omegadzz[15] - 2 * omegadzz[16] - 2 * omegadzz[17]; + phidzz[p20[6]] = +4 * omegadzz[6] - 2 * omegadzz[7] - 4 * omegadzz[12] + 2 * omegadzz[13] + 2 * omegadzz[18] - 4 * omegadzz[19]; + phidzz[p20[7]] = -2 * omegadzz[6] + 4 * omegadzz[7] - 2 * omegadzz[12] - 2 * omegadzz[13] + 4 * omegadzz[18] - 2 * omegadzz[19]; + phidzz[p20[8]] = +4 * omegadzz[8] - 2 * omegadzz[9] + 2 * omegadzz[12] - 4 * omegadzz[13] + 2 * omegadzz[16] - 4 * omegadzz[17]; + phidzz[p20[9]] = -2 * omegadzz[8] + 4 * omegadzz[9] - 2 * omegadzz[12] - 2 * omegadzz[13] + 4 * omegadzz[16] - 2 * omegadzz[17]; + phidzz[p20[10]] = +4 * omegadzz[10] - 2 * omegadzz[11] + 2 * omegadzz[12] - 4 * omegadzz[13] + 2 * omegadzz[14] - 4 * omegadzz[15]; + phidzz[p20[11]] = -2 * omegadzz[10] + 4 * omegadzz[11] + 4 * omegadzz[12] - 2 * omegadzz[13] + 4 * omegadzz[14] - 2 * omegadzz[15]; phidzz[p20[12]] = +8 * omegadzz[12] - 4 * omegadzz[13]; phidzz[p20[13]] = -4 * omegadzz[12] + 8 * omegadzz[13]; phidzz[p20[14]] = +8 * omegadzz[14] - 4 * omegadzz[15]; @@ -877,30 +744,18 @@ namespace Fem2D { R3 phidxy[20]; if (whatd & Fop_dxy) { - phidxy[p20[0]] = +4 * omegadxy[0] - 2 * omegadxy[1] - 4 * omegadxy[16] + 2 * omegadxy[17] - - 4 * omegadxy[18] + 2 * omegadxy[19]; - phidxy[p20[1]] = -2 * omegadxy[0] + 4 * omegadxy[1] - 2 * omegadxy[16] - 2 * omegadxy[17] - - 2 * omegadxy[18] - 2 * omegadxy[19]; - phidxy[p20[2]] = +4 * omegadxy[2] - 2 * omegadxy[3] - 4 * omegadxy[14] + 2 * omegadxy[15] + - 2 * omegadxy[18] - 4 * omegadxy[19]; - phidxy[p20[3]] = -2 * omegadxy[2] + 4 * omegadxy[3] - 2 * omegadxy[14] - 2 * omegadxy[15] - - 2 * omegadxy[18] - 2 * omegadxy[19]; - phidxy[p20[4]] = +4 * omegadxy[4] - 2 * omegadxy[5] + 2 * omegadxy[14] - 4 * omegadxy[15] + - 2 * omegadxy[16] - 4 * omegadxy[17]; - phidxy[p20[5]] = -2 * omegadxy[4] + 4 * omegadxy[5] - 2 * omegadxy[14] - 2 * omegadxy[15] - - 2 * omegadxy[16] - 2 * omegadxy[17]; - phidxy[p20[6]] = +4 * omegadxy[6] - 2 * omegadxy[7] - 4 * omegadxy[12] + 2 * omegadxy[13] + - 2 * omegadxy[18] - 4 * omegadxy[19]; - phidxy[p20[7]] = -2 * omegadxy[6] + 4 * omegadxy[7] - 2 * omegadxy[12] - 2 * omegadxy[13] + - 4 * omegadxy[18] - 2 * omegadxy[19]; - phidxy[p20[8]] = +4 * omegadxy[8] - 2 * omegadxy[9] + 2 * omegadxy[12] - 4 * omegadxy[13] + - 2 * omegadxy[16] - 4 * omegadxy[17]; - phidxy[p20[9]] = -2 * omegadxy[8] + 4 * omegadxy[9] - 2 * omegadxy[12] - 2 * omegadxy[13] + - 4 * omegadxy[16] - 2 * omegadxy[17]; - phidxy[p20[10]] = +4 * omegadxy[10] - 2 * omegadxy[11] + 2 * omegadxy[12] - - 4 * omegadxy[13] + 2 * omegadxy[14] - 4 * omegadxy[15]; - phidxy[p20[11]] = -2 * omegadxy[10] + 4 * omegadxy[11] + 4 * omegadxy[12] - - 2 * omegadxy[13] + 4 * omegadxy[14] - 2 * omegadxy[15]; + phidxy[p20[0]] = +4 * omegadxy[0] - 2 * omegadxy[1] - 4 * omegadxy[16] + 2 * omegadxy[17] - 4 * omegadxy[18] + 2 * omegadxy[19]; + phidxy[p20[1]] = -2 * omegadxy[0] + 4 * omegadxy[1] - 2 * omegadxy[16] - 2 * omegadxy[17] - 2 * omegadxy[18] - 2 * omegadxy[19]; + phidxy[p20[2]] = +4 * omegadxy[2] - 2 * omegadxy[3] - 4 * omegadxy[14] + 2 * omegadxy[15] + 2 * omegadxy[18] - 4 * omegadxy[19]; + phidxy[p20[3]] = -2 * omegadxy[2] + 4 * omegadxy[3] - 2 * omegadxy[14] - 2 * omegadxy[15] - 2 * omegadxy[18] - 2 * omegadxy[19]; + phidxy[p20[4]] = +4 * omegadxy[4] - 2 * omegadxy[5] + 2 * omegadxy[14] - 4 * omegadxy[15] + 2 * omegadxy[16] - 4 * omegadxy[17]; + phidxy[p20[5]] = -2 * omegadxy[4] + 4 * omegadxy[5] - 2 * omegadxy[14] - 2 * omegadxy[15] - 2 * omegadxy[16] - 2 * omegadxy[17]; + phidxy[p20[6]] = +4 * omegadxy[6] - 2 * omegadxy[7] - 4 * omegadxy[12] + 2 * omegadxy[13] + 2 * omegadxy[18] - 4 * omegadxy[19]; + phidxy[p20[7]] = -2 * omegadxy[6] + 4 * omegadxy[7] - 2 * omegadxy[12] - 2 * omegadxy[13] + 4 * omegadxy[18] - 2 * omegadxy[19]; + phidxy[p20[8]] = +4 * omegadxy[8] - 2 * omegadxy[9] + 2 * omegadxy[12] - 4 * omegadxy[13] + 2 * omegadxy[16] - 4 * omegadxy[17]; + phidxy[p20[9]] = -2 * omegadxy[8] + 4 * omegadxy[9] - 2 * omegadxy[12] - 2 * omegadxy[13] + 4 * omegadxy[16] - 2 * omegadxy[17]; + phidxy[p20[10]] = +4 * omegadxy[10] - 2 * omegadxy[11] + 2 * omegadxy[12] - 4 * omegadxy[13] + 2 * omegadxy[14] - 4 * omegadxy[15]; + phidxy[p20[11]] = -2 * omegadxy[10] + 4 * omegadxy[11] + 4 * omegadxy[12] - 2 * omegadxy[13] + 4 * omegadxy[14] - 2 * omegadxy[15]; phidxy[p20[12]] = +8 * omegadxy[12] - 4 * omegadxy[13]; phidxy[p20[13]] = -4 * omegadxy[12] + 8 * omegadxy[13]; phidxy[p20[14]] = +8 * omegadxy[14] - 4 * omegadxy[15]; @@ -919,30 +774,18 @@ namespace Fem2D { R3 phidxz[20]; if (whatd & Fop_dxz) { - phidxz[p20[0]] = +4 * omegadxz[0] - 2 * omegadxz[1] - 4 * omegadxz[16] + 2 * omegadxz[17] - - 4 * omegadxz[18] + 2 * omegadxz[19]; - phidxz[p20[1]] = -2 * omegadxz[0] + 4 * omegadxz[1] - 2 * omegadxz[16] - 2 * omegadxz[17] - - 2 * omegadxz[18] - 2 * omegadxz[19]; - phidxz[p20[2]] = +4 * omegadxz[2] - 2 * omegadxz[3] - 4 * omegadxz[14] + 2 * omegadxz[15] + - 2 * omegadxz[18] - 4 * omegadxz[19]; - phidxz[p20[3]] = -2 * omegadxz[2] + 4 * omegadxz[3] - 2 * omegadxz[14] - 2 * omegadxz[15] - - 2 * omegadxz[18] - 2 * omegadxz[19]; - phidxz[p20[4]] = +4 * omegadxz[4] - 2 * omegadxz[5] + 2 * omegadxz[14] - 4 * omegadxz[15] + - 2 * omegadxz[16] - 4 * omegadxz[17]; - phidxz[p20[5]] = -2 * omegadxz[4] + 4 * omegadxz[5] - 2 * omegadxz[14] - 2 * omegadxz[15] - - 2 * omegadxz[16] - 2 * omegadxz[17]; - phidxz[p20[6]] = +4 * omegadxz[6] - 2 * omegadxz[7] - 4 * omegadxz[12] + 2 * omegadxz[13] + - 2 * omegadxz[18] - 4 * omegadxz[19]; - phidxz[p20[7]] = -2 * omegadxz[6] + 4 * omegadxz[7] - 2 * omegadxz[12] - 2 * omegadxz[13] + - 4 * omegadxz[18] - 2 * omegadxz[19]; - phidxz[p20[8]] = +4 * omegadxz[8] - 2 * omegadxz[9] + 2 * omegadxz[12] - 4 * omegadxz[13] + - 2 * omegadxz[16] - 4 * omegadxz[17]; - phidxz[p20[9]] = -2 * omegadxz[8] + 4 * omegadxz[9] - 2 * omegadxz[12] - 2 * omegadxz[13] + - 4 * omegadxz[16] - 2 * omegadxz[17]; - phidxz[p20[10]] = +4 * omegadxz[10] - 2 * omegadxz[11] + 2 * omegadxz[12] - - 4 * omegadxz[13] + 2 * omegadxz[14] - 4 * omegadxz[15]; - phidxz[p20[11]] = -2 * omegadxz[10] + 4 * omegadxz[11] + 4 * omegadxz[12] - - 2 * omegadxz[13] + 4 * omegadxz[14] - 2 * omegadxz[15]; + phidxz[p20[0]] = +4 * omegadxz[0] - 2 * omegadxz[1] - 4 * omegadxz[16] + 2 * omegadxz[17] - 4 * omegadxz[18] + 2 * omegadxz[19]; + phidxz[p20[1]] = -2 * omegadxz[0] + 4 * omegadxz[1] - 2 * omegadxz[16] - 2 * omegadxz[17] - 2 * omegadxz[18] - 2 * omegadxz[19]; + phidxz[p20[2]] = +4 * omegadxz[2] - 2 * omegadxz[3] - 4 * omegadxz[14] + 2 * omegadxz[15] + 2 * omegadxz[18] - 4 * omegadxz[19]; + phidxz[p20[3]] = -2 * omegadxz[2] + 4 * omegadxz[3] - 2 * omegadxz[14] - 2 * omegadxz[15] - 2 * omegadxz[18] - 2 * omegadxz[19]; + phidxz[p20[4]] = +4 * omegadxz[4] - 2 * omegadxz[5] + 2 * omegadxz[14] - 4 * omegadxz[15] + 2 * omegadxz[16] - 4 * omegadxz[17]; + phidxz[p20[5]] = -2 * omegadxz[4] + 4 * omegadxz[5] - 2 * omegadxz[14] - 2 * omegadxz[15] - 2 * omegadxz[16] - 2 * omegadxz[17]; + phidxz[p20[6]] = +4 * omegadxz[6] - 2 * omegadxz[7] - 4 * omegadxz[12] + 2 * omegadxz[13] + 2 * omegadxz[18] - 4 * omegadxz[19]; + phidxz[p20[7]] = -2 * omegadxz[6] + 4 * omegadxz[7] - 2 * omegadxz[12] - 2 * omegadxz[13] + 4 * omegadxz[18] - 2 * omegadxz[19]; + phidxz[p20[8]] = +4 * omegadxz[8] - 2 * omegadxz[9] + 2 * omegadxz[12] - 4 * omegadxz[13] + 2 * omegadxz[16] - 4 * omegadxz[17]; + phidxz[p20[9]] = -2 * omegadxz[8] + 4 * omegadxz[9] - 2 * omegadxz[12] - 2 * omegadxz[13] + 4 * omegadxz[16] - 2 * omegadxz[17]; + phidxz[p20[10]] = +4 * omegadxz[10] - 2 * omegadxz[11] + 2 * omegadxz[12] - 4 * omegadxz[13] + 2 * omegadxz[14] - 4 * omegadxz[15]; + phidxz[p20[11]] = -2 * omegadxz[10] + 4 * omegadxz[11] + 4 * omegadxz[12] - 2 * omegadxz[13] + 4 * omegadxz[14] - 2 * omegadxz[15]; phidxz[p20[12]] = +8 * omegadxz[12] - 4 * omegadxz[13]; phidxz[p20[13]] = -4 * omegadxz[12] + 8 * omegadxz[13]; phidxz[p20[14]] = +8 * omegadxz[14] - 4 * omegadxz[15]; @@ -961,30 +804,18 @@ namespace Fem2D { R3 phidyz[20]; if (whatd & Fop_dyz) { - phidyz[p20[0]] = +4 * omegadyz[0] - 2 * omegadyz[1] - 4 * omegadyz[16] + 2 * omegadyz[17] - - 4 * omegadyz[18] + 2 * omegadyz[19]; - phidyz[p20[1]] = -2 * omegadyz[0] + 4 * omegadyz[1] - 2 * omegadyz[16] - 2 * omegadyz[17] - - 2 * omegadyz[18] - 2 * omegadyz[19]; - phidyz[p20[2]] = +4 * omegadyz[2] - 2 * omegadyz[3] - 4 * omegadyz[14] + 2 * omegadyz[15] + - 2 * omegadyz[18] - 4 * omegadyz[19]; - phidyz[p20[3]] = -2 * omegadyz[2] + 4 * omegadyz[3] - 2 * omegadyz[14] - 2 * omegadyz[15] - - 2 * omegadyz[18] - 2 * omegadyz[19]; - phidyz[p20[4]] = +4 * omegadyz[4] - 2 * omegadyz[5] + 2 * omegadyz[14] - 4 * omegadyz[15] + - 2 * omegadyz[16] - 4 * omegadyz[17]; - phidyz[p20[5]] = -2 * omegadyz[4] + 4 * omegadyz[5] - 2 * omegadyz[14] - 2 * omegadyz[15] - - 2 * omegadyz[16] - 2 * omegadyz[17]; - phidyz[p20[6]] = +4 * omegadyz[6] - 2 * omegadyz[7] - 4 * omegadyz[12] + 2 * omegadyz[13] + - 2 * omegadyz[18] - 4 * omegadyz[19]; - phidyz[p20[7]] = -2 * omegadyz[6] + 4 * omegadyz[7] - 2 * omegadyz[12] - 2 * omegadyz[13] + - 4 * omegadyz[18] - 2 * omegadyz[19]; - phidyz[p20[8]] = +4 * omegadyz[8] - 2 * omegadyz[9] + 2 * omegadyz[12] - 4 * omegadyz[13] + - 2 * omegadyz[16] - 4 * omegadyz[17]; - phidyz[p20[9]] = -2 * omegadyz[8] + 4 * omegadyz[9] - 2 * omegadyz[12] - 2 * omegadyz[13] + - 4 * omegadyz[16] - 2 * omegadyz[17]; - phidyz[p20[10]] = +4 * omegadyz[10] - 2 * omegadyz[11] + 2 * omegadyz[12] - - 4 * omegadyz[13] + 2 * omegadyz[14] - 4 * omegadyz[15]; - phidyz[p20[11]] = -2 * omegadyz[10] + 4 * omegadyz[11] + 4 * omegadyz[12] - - 2 * omegadyz[13] + 4 * omegadyz[14] - 2 * omegadyz[15]; + phidyz[p20[0]] = +4 * omegadyz[0] - 2 * omegadyz[1] - 4 * omegadyz[16] + 2 * omegadyz[17] - 4 * omegadyz[18] + 2 * omegadyz[19]; + phidyz[p20[1]] = -2 * omegadyz[0] + 4 * omegadyz[1] - 2 * omegadyz[16] - 2 * omegadyz[17] - 2 * omegadyz[18] - 2 * omegadyz[19]; + phidyz[p20[2]] = +4 * omegadyz[2] - 2 * omegadyz[3] - 4 * omegadyz[14] + 2 * omegadyz[15] + 2 * omegadyz[18] - 4 * omegadyz[19]; + phidyz[p20[3]] = -2 * omegadyz[2] + 4 * omegadyz[3] - 2 * omegadyz[14] - 2 * omegadyz[15] - 2 * omegadyz[18] - 2 * omegadyz[19]; + phidyz[p20[4]] = +4 * omegadyz[4] - 2 * omegadyz[5] + 2 * omegadyz[14] - 4 * omegadyz[15] + 2 * omegadyz[16] - 4 * omegadyz[17]; + phidyz[p20[5]] = -2 * omegadyz[4] + 4 * omegadyz[5] - 2 * omegadyz[14] - 2 * omegadyz[15] - 2 * omegadyz[16] - 2 * omegadyz[17]; + phidyz[p20[6]] = +4 * omegadyz[6] - 2 * omegadyz[7] - 4 * omegadyz[12] + 2 * omegadyz[13] + 2 * omegadyz[18] - 4 * omegadyz[19]; + phidyz[p20[7]] = -2 * omegadyz[6] + 4 * omegadyz[7] - 2 * omegadyz[12] - 2 * omegadyz[13] + 4 * omegadyz[18] - 2 * omegadyz[19]; + phidyz[p20[8]] = +4 * omegadyz[8] - 2 * omegadyz[9] + 2 * omegadyz[12] - 4 * omegadyz[13] + 2 * omegadyz[16] - 4 * omegadyz[17]; + phidyz[p20[9]] = -2 * omegadyz[8] + 4 * omegadyz[9] - 2 * omegadyz[12] - 2 * omegadyz[13] + 4 * omegadyz[16] - 2 * omegadyz[17]; + phidyz[p20[10]] = +4 * omegadyz[10] - 2 * omegadyz[11] + 2 * omegadyz[12] - 4 * omegadyz[13] + 2 * omegadyz[14] - 4 * omegadyz[15]; + phidyz[p20[11]] = -2 * omegadyz[10] + 4 * omegadyz[11] + 4 * omegadyz[12] - 2 * omegadyz[13] + 4 * omegadyz[14] - 2 * omegadyz[15]; phidyz[p20[12]] = +8 * omegadyz[12] - 4 * omegadyz[13]; phidyz[p20[13]] = -4 * omegadyz[12] + 8 * omegadyz[13]; phidyz[p20[14]] = +8 * omegadyz[14] - 4 * omegadyz[15]; @@ -1019,14 +850,11 @@ namespace Fem2D { static const GQuadratureFormular< R2 > QFf; // quadrature formula on a face static const GQuadratureFormular< R3 > QFv; // quadrature formula on a tetrahedron TypeOfFE_Edge2_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; }; - int TypeOfFE_Edge2_3d::dfon[] = { - 0, 3, 6, 3}; // 3 dofs on each edge, 6 dofs on each face, 3 dofs on the tetrahedron + int TypeOfFE_Edge2_3d::dfon[] = {0, 3, 6, 3}; // 3 dofs on each edge, 6 dofs on each face, 3 dofs on the tetrahedron // Quadrature formula on an edge, exact for degree 5 (ok: int_e (deg3*t *lambda*lambda)) const GQuadratureFormular< R1 > TypeOfFE_Edge2_3d::QFe(2 * 3 - 1, 3, GaussLegendre(3), true); @@ -1037,23 +865,17 @@ namespace Fem2D { // (From Mark A. Taylor, Beth A. Wingate, Len P. Bos, // Several new quadrature formulas for polynomial integration in the triangle) static GQuadraturePoint< R2 > P_QuadratureFormular_T_4_TWB[6] = { - GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.0915762135098, 0.0915762135098)), - GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.8168475729805, 0.0915762135098)), - GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.0915762135098, 0.8168475729805)), - GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.1081030181681, 0.4459484909160)), - GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.4459484909160, 0.1081030181681)), - GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.4459484909160, 0.4459484909160))}; + GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.0915762135098, 0.0915762135098)), GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.8168475729805, 0.0915762135098)), + GQuadraturePoint< R2 >(0.2199034873106 / 2, R2(0.0915762135098, 0.8168475729805)), GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.1081030181681, 0.4459484909160)), + GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.4459484909160, 0.1081030181681)), GQuadraturePoint< R2 >(0.4467631793560 / 2, R2(0.4459484909160, 0.4459484909160))}; const GQuadratureFormular< R2 > TypeOfFE_Edge2_3d::QFf(4, 6, P_QuadratureFormular_T_4_TWB); // Quadrature formula on a tetrahedron, exact for degree 3 (ok: int_v (deg3*t)) // (From Table 4.57 pag 247 Solin HOFEM, coords trasformed like on pag 68, // weights multiplied by 6/8 so that their sum is equal to 1) - static GQuadraturePoint< R3 > P_QuadratureFormular_Tet_3_solin[5] = { - GQuadraturePoint< R3 >(R3(0.25, 0.25, 0.25), -0.8), - GQuadraturePoint< R3 >(R3(1. / 6., 1. / 6., 1. / 6.), 0.45), - GQuadraturePoint< R3 >(R3(1. / 6., 1. / 6., 0.5), 0.45), - GQuadraturePoint< R3 >(R3(1. / 6., 0.5, 1. / 6.), 0.45), - GQuadraturePoint< R3 >(R3(0.5, 1. / 6., 1. / 6.), 0.45)}; + static GQuadraturePoint< R3 > P_QuadratureFormular_Tet_3_solin[5] = {GQuadraturePoint< R3 >(R3(0.25, 0.25, 0.25), -0.8), GQuadraturePoint< R3 >(R3(1. / 6., 1. / 6., 1. / 6.), 0.45), + GQuadraturePoint< R3 >(R3(1. / 6., 1. / 6., 0.5), 0.45), GQuadraturePoint< R3 >(R3(1. / 6., 0.5, 1. / 6.), 0.45), + GQuadraturePoint< R3 >(R3(0.5, 1. / 6., 1. / 6.), 0.45)}; const GQuadratureFormular< R3 > TypeOfFE_Edge2_3d::QFv(3, 5, P_QuadratureFormular_Tet_3_solin); // In Mesh3dn.cpp: @@ -1077,14 +899,11 @@ namespace Fem2D { // npPi = NbPtforInterpolation = ne*QFe.n+nf*QFf.n+QFv.n // invariantinterpolationMatrix = false (i.e. it depends on the tetrahedron), discon=true TypeOfFE_Edge2_3d::TypeOfFE_Edge2_3d( ) - : GTypeOfFE< Mesh3 >(TypeOfFE_Edge2_3d::dfon, d, 1, - 3 * QFe.n * 3 * Element::ne + 3 * QFf.n * 6 * Element::nf + 3 * QFv.n * 3, - Element::ne * QFe.n + Element::nf * QFf.n + QFv.n, false, true) { + : GTypeOfFE< Mesh3 >(TypeOfFE_Edge2_3d::dfon, d, 1, 3 * QFe.n * 3 * Element::ne + 3 * QFf.n * 6 * Element::nf + 3 * QFv.n * 3, Element::ne * QFe.n + Element::nf * QFf.n + QFv.n, false, true) { assert(QFe.n); assert(QFf.n); assert(QFv.n); - R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices { // We build the interpolation pts on the edges of the reference tetrahedron: @@ -1094,8 +913,7 @@ namespace Fem2D { for (int e = 0; e < Element::ne; ++e) { for (int q = 0; q < QFe.n; ++q, ++p) { double x = QFe[q].x; - this->PtInterpolation[p] = - Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); + this->PtInterpolation[p] = Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); } } @@ -1105,8 +923,7 @@ namespace Fem2D { for (int q = 0; q < QFf.n; ++q, ++p) { double x = QFf[q].x; double y = QFf[q].y; - this->PtInterpolation[p] = Pt[Element::nvface[f][0]] * (1. - x - y) + - Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; + this->PtInterpolation[p] = Pt[Element::nvface[f][0]] * (1. - x - y) + Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; } } @@ -1124,7 +941,7 @@ namespace Fem2D { int i = 0, p = 0; // i is the k in (13.1) (chapter 13 ff++doc) int e; // we will need e also below, in the parts referred to faces and volumes - for (e = 0; e < (Element::ne)*3; e++) { // loop on the 18 edge dofs + for (e = 0; e < (Element::ne) * 3; e++) { // loop on the 18 edge dofs if (e % 3 != 0) { p = p - QFe.n; } // for 3 successive dofs the quad pts are the same (they correspond to the same edge) @@ -1144,7 +961,7 @@ namespace Fem2D { // (the indices i and p mustn't be reinitialised) int f; // we will need f also below, in the part referred to volumes - for (f = 0; f < (Element::nf)*6; f++) { // loop on the 24 face dofs + for (f = 0; f < (Element::nf) * 6; f++) { // loop on the 24 face dofs if (f % 6 != 0) { p = p - QFf.n; } // for 6 successive dofs the quad pts are the same (they correspond to the same face) @@ -1172,8 +989,8 @@ namespace Fem2D { this->pInterpolation[i] = p; // pk in (13.1) this->cInterpolation[i] = c; // jk in (13.1) this->dofInterpolation[i] = e + f + v; // ik in (13.1) - this->coefInterpolation[i] = 0.; // alphak: we will fill them with 'set' (below) - // because they depend on the tetrahedron + this->coefInterpolation[i] = 0.; // alphak: we will fill them with 'set' (below) + // because they depend on the tetrahedron } } } @@ -1181,8 +998,7 @@ namespace Fem2D { } // For the coefficients of interpolation alphak in (13.1) - void TypeOfFE_Edge2_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_Edge2_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { int i = ocoef, p = 0; // (p is used only to check) @@ -1259,8 +1075,7 @@ namespace Fem2D { // (the indices i and p mustn't be reinitialised) for (int ff = 0; ff < Element::nf; ff++) { // loop on the 24 face dofs - const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), - &K.at(Element::nvface[ff][2])}; + const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), &K.at(Element::nvface[ff][2])}; // We 'order' the 3 vertices of the face according to their global numbers: // i0f will be the local number in the FACE of the vertex with the smallest global number // i1f will be the local number in the face of the vertex with the second smallest global @@ -1279,8 +1094,7 @@ namespace Fem2D { } // now local numbers in the tetrahedron: - int i0 = Element::nvface[ff][i0f], i1 = Element::nvface[ff][i1f], - i2 = Element::nvface[ff][i2f]; + int i0 = Element::nvface[ff][i0f], i1 = Element::nvface[ff][i1f], i2 = Element::nvface[ff][i2f]; for (int fdof = 0; fdof < 6; ++fdof) { // 6 dofs for each face int ie0 = i0, @@ -1291,9 +1105,8 @@ namespace Fem2D { p = p - QFf.n; } - for (int q = 0; q < QFf.n; ++q, ++p) { // loop on the face quadrature pts - double ll3[3] = {1. - QFf[q].x - QFf[q].y, QFf[q].x, - QFf[q].y}; // the 3 lambdas of the face + for (int q = 0; q < QFf.n; ++q, ++p) { // loop on the face quadrature pts + double ll3[3] = {1. - QFf[q].x - QFf[q].y, QFf[q].x, QFf[q].y}; // the 3 lambdas of the face double ll; if (fdof % 3 == 0) { ll = ll3[i0f]; @@ -1366,8 +1179,7 @@ namespace Fem2D { // val contains the values of the basis functions and of their derivatives at the point of K // corresponding to the point P of the reference tetrahedron, by components - void TypeOfFE_Edge2_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_Edge2_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 45); // 45 degrees of freedom assert(val.M( ) == 3); // 3 components // ------------- @@ -1409,8 +1221,7 @@ namespace Fem2D { // ------------- // If [a,b] is the i-th edge (where a,b are its vertices local numbers), edgesMap[(a+1)*(b+1)] = // i - int edgesMap[13] = {-1, -1, 0, 1, 2, -1, 3, - -1, 4, -1, -1, -1, 5}; // a map would be more slow + int edgesMap[13] = {-1, -1, 0, 1, 2, -1, 3, -1, 4, -1, -1, -1, 5}; // a map would be more slow // ------------- // the 4 barycentric coordinates for the reference tetrahedron evaluated at the point P // (they have the same value at the real tetrahedron's point corresponding to the reference @@ -1500,115 +1311,66 @@ namespace Fem2D { // Now, the functions phi that really constitute a dual basis R3 phi[45]; - phi[p45[0]] = +9 * om[0] - 18 * om[1] + 3 * om[2] - 27 * om[30] + 12 * om[31] + 9 * om[32] + - 9 * om[33] - 6 * om[34] - 6 * om[35] - 27 * om[36] + 12 * om[37] + 9 * om[38] + - 9 * om[39] - 6 * om[40] - 6 * om[41] + 18 * om[42] - 6 * om[43] - 6 * om[44]; - phi[p45[1]] = -18 * om[0] + 84 * om[1] - 18 * om[2] - 6 * om[30] - 36 * om[31] + 12 * om[32] - - 30 * om[33] + 30 * om[34] - 6 * om[36] - 36 * om[37] + 12 * om[38] - - 30 * om[39] + 30 * om[40] + 24 * om[42]; - phi[p45[2]] = +3 * om[0] - 18 * om[1] + 9 * om[2] + 6 * om[30] - 18 * om[31] + 3 * om[32] + - 6 * om[33] - 9 * om[34] + 6 * om[35] + 6 * om[36] - 18 * om[37] + 3 * om[38] + - 6 * om[39] - 9 * om[40] + 6 * om[41] + 6 * om[42] + 6 * om[43] + 6 * om[44]; - phi[p45[3]] = +9 * om[3] - 18 * om[4] + 3 * om[5] - 27 * om[24] + 12 * om[25] + 9 * om[26] + - 9 * om[27] - 6 * om[28] - 6 * om[29] + 9 * om[36] - 6 * om[37] - 6 * om[38] - - 27 * om[39] + 9 * om[40] + 12 * om[41] - 6 * om[42] + 18 * om[43] - 6 * om[44]; - phi[p45[4]] = -18 * om[3] + 84 * om[4] - 18 * om[5] - 6 * om[24] - 36 * om[25] + 12 * om[26] - - 30 * om[27] + 30 * om[28] - 30 * om[36] + 30 * om[38] - 6 * om[39] + - 12 * om[40] - 36 * om[41] + 24 * om[43]; - phi[p45[5]] = +3 * om[3] - 18 * om[4] + 9 * om[5] + 6 * om[24] - 18 * om[25] + 3 * om[26] + - 6 * om[27] - 9 * om[28] + 6 * om[29] + 6 * om[36] + 6 * om[37] - 9 * om[38] + - 6 * om[39] + 3 * om[40] - 18 * om[41] + 6 * om[42] + 6 * om[43] + 6 * om[44]; - phi[p45[6]] = +9 * om[6] - 18 * om[7] + 3 * om[8] + 9 * om[24] - 6 * om[25] - 6 * om[26] - - 27 * om[27] + 9 * om[28] + 12 * om[29] + 9 * om[30] - 6 * om[31] - 6 * om[32] - - 27 * om[33] + 9 * om[34] + 12 * om[35] - 6 * om[42] - 6 * om[43] + 18 * om[44]; - phi[p45[7]] = -18 * om[6] + 84 * om[7] - 18 * om[8] - 30 * om[24] + 30 * om[26] - 6 * om[27] + - 12 * om[28] - 36 * om[29] - 30 * om[30] + 30 * om[32] - 6 * om[33] + - 12 * om[34] - 36 * om[35] + 24 * om[44]; - phi[p45[8]] = +3 * om[6] - 18 * om[7] + 9 * om[8] + 6 * om[24] + 6 * om[25] - 9 * om[26] + - 6 * om[27] + 3 * om[28] - 18 * om[29] + 6 * om[30] + 6 * om[31] - 9 * om[32] + - 6 * om[33] + 3 * om[34] - 18 * om[35] + 6 * om[42] + 6 * om[43] + 6 * om[44]; - phi[p45[9]] = +9 * om[9] - 18 * om[10] + 3 * om[11] - 27 * om[18] + 12 * om[19] + 9 * om[20] + - 9 * om[21] - 6 * om[22] - 6 * om[23] - 3 * om[36] + 18 * om[37] - 6 * om[38] + - 9 * om[39] - 27 * om[40] + 12 * om[41] - 6 * om[42] + 18 * om[43] - 6 * om[44]; - phi[p45[10]] = -18 * om[9] + 84 * om[10] - 18 * om[11] - 6 * om[18] - 36 * om[19] + - 12 * om[20] - 30 * om[21] + 30 * om[22] - 12 * om[36] + 36 * om[37] + - 6 * om[38] + 12 * om[39] - 6 * om[40] - 36 * om[41] - 24 * om[42] + - 24 * om[43]; - phi[p45[11]] = +3 * om[9] - 18 * om[10] + 9 * om[11] + 6 * om[18] - 18 * om[19] + 3 * om[20] + - 6 * om[21] - 9 * om[22] + 6 * om[23] - 9 * om[36] - 12 * om[37] + 27 * om[38] + - 3 * om[39] + 6 * om[40] - 18 * om[41] - 18 * om[42] + 6 * om[43] + 6 * om[44]; - phi[p45[12]] = +9 * om[12] - 18 * om[13] + 3 * om[14] + 9 * om[18] - 6 * om[19] - 6 * om[20] - - 27 * om[21] + 9 * om[22] + 12 * om[23] - 3 * om[30] + 18 * om[31] - - 6 * om[32] + 9 * om[33] - 27 * om[34] + 12 * om[35] - 6 * om[42] - 6 * om[43] + - 18 * om[44]; - phi[p45[13]] = -18 * om[12] + 84 * om[13] - 18 * om[14] - 30 * om[18] + 30 * om[20] - - 6 * om[21] + 12 * om[22] - 36 * om[23] - 12 * om[30] + 36 * om[31] + - 6 * om[32] + 12 * om[33] - 6 * om[34] - 36 * om[35] - 24 * om[42] + - 24 * om[44]; - phi[p45[14]] = +3 * om[12] - 18 * om[13] + 9 * om[14] + 6 * om[18] + 6 * om[19] - 9 * om[20] + - 6 * om[21] + 3 * om[22] - 18 * om[23] - 9 * om[30] - 12 * om[31] + - 27 * om[32] + 3 * om[33] + 6 * om[34] - 18 * om[35] - 18 * om[42] + - 6 * om[43] + 6 * om[44]; - phi[p45[15]] = +9 * om[15] - 18 * om[16] + 3 * om[17] - 3 * om[18] + 18 * om[19] - - 6 * om[20] + 9 * om[21] - 27 * om[22] + 12 * om[23] - 3 * om[24] + - 18 * om[25] - 6 * om[26] + 9 * om[27] - 27 * om[28] + 12 * om[29] - - 6 * om[42] - 6 * om[43] + 18 * om[44]; - phi[p45[16]] = -18 * om[15] + 84 * om[16] - 18 * om[17] - 12 * om[18] + 36 * om[19] + - 6 * om[20] + 12 * om[21] - 6 * om[22] - 36 * om[23] - 12 * om[24] + - 36 * om[25] + 6 * om[26] + 12 * om[27] - 6 * om[28] - 36 * om[29] - - 24 * om[43] + 24 * om[44]; - phi[p45[17]] = +3 * om[15] - 18 * om[16] + 9 * om[17] - 9 * om[18] - 12 * om[19] + - 27 * om[20] + 3 * om[21] + 6 * om[22] - 18 * om[23] - 9 * om[24] - - 12 * om[25] + 27 * om[26] + 3 * om[27] + 6 * om[28] - 18 * om[29] + - 6 * om[42] - 18 * om[43] + 6 * om[44]; - phi[p45[18]] = +90 * om[18] - 30 * om[19] - 45 * om[20] - 30 * om[21] + 15 * om[22] + - 30 * om[23] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[19]] = -30 * om[18] + 120 * om[19] - 30 * om[20] + 30 * om[21] - 60 * om[22] + - 30 * om[42] - 30 * om[43] + 30 * om[44]; - phi[p45[20]] = -45 * om[18] - 30 * om[19] + 90 * om[20] + 15 * om[21] + 15 * om[22] - - 60 * om[23] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[21]] = -30 * om[18] + 30 * om[19] + 15 * om[20] + 90 * om[21] - 45 * om[22] - - 30 * om[23] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[22]] = +15 * om[18] - 60 * om[19] + 15 * om[20] - 45 * om[21] + 90 * om[22] - - 30 * om[23] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[23]] = +30 * om[18] - 60 * om[20] - 30 * om[21] - 30 * om[22] + 120 * om[23] + - 30 * om[42] + 30 * om[43] - 30 * om[44]; - phi[p45[24]] = +90 * om[24] - 30 * om[25] - 45 * om[26] - 30 * om[27] + 15 * om[28] + - 30 * om[29] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[25]] = -30 * om[24] + 120 * om[25] - 30 * om[26] + 30 * om[27] - 60 * om[28] - - 30 * om[42] - 30 * om[43] + 30 * om[44]; - phi[p45[26]] = -45 * om[24] - 30 * om[25] + 90 * om[26] + 15 * om[27] + 15 * om[28] - - 60 * om[29] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[27]] = -30 * om[24] + 30 * om[25] + 15 * om[26] + 90 * om[27] - 45 * om[28] - - 30 * om[29] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[28]] = +15 * om[24] - 60 * om[25] + 15 * om[26] - 45 * om[27] + 90 * om[28] - - 30 * om[29] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[29]] = +30 * om[24] - 60 * om[26] - 30 * om[27] - 30 * om[28] + 120 * om[29] - - 30 * om[42] + 30 * om[43] - 30 * om[44]; - phi[p45[30]] = +90 * om[30] - 30 * om[31] - 45 * om[32] - 30 * om[33] + 15 * om[34] + - 30 * om[35] - 45 * om[42] + 15 * om[43] + 15 * om[44]; - phi[p45[31]] = -30 * om[30] + 120 * om[31] - 30 * om[32] + 30 * om[33] - 60 * om[34] - - 30 * om[42] - 30 * om[43] + 30 * om[44]; - phi[p45[32]] = -45 * om[30] - 30 * om[31] + 90 * om[32] + 15 * om[33] + 15 * om[34] - - 60 * om[35] - 45 * om[42] + 15 * om[43] + 15 * om[44]; - phi[p45[33]] = -30 * om[30] + 30 * om[31] + 15 * om[32] + 90 * om[33] - 45 * om[34] - - 30 * om[35] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[34]] = +15 * om[30] - 60 * om[31] + 15 * om[32] - 45 * om[33] + 90 * om[34] - - 30 * om[35] + 15 * om[42] + 15 * om[43] - 45 * om[44]; - phi[p45[35]] = +30 * om[30] - 60 * om[32] - 30 * om[33] - 30 * om[34] + 120 * om[35] + - 30 * om[42] - 30 * om[43] - 30 * om[44]; - phi[p45[36]] = +90 * om[36] - 30 * om[37] - 45 * om[38] - 30 * om[39] + 15 * om[40] + - 30 * om[41] - 45 * om[42] + 15 * om[43] + 15 * om[44]; - phi[p45[37]] = -30 * om[36] + 120 * om[37] - 30 * om[38] + 30 * om[39] - 60 * om[40] - - 30 * om[42] + 30 * om[43] - 30 * om[44]; - phi[p45[38]] = -45 * om[36] - 30 * om[37] + 90 * om[38] + 15 * om[39] + 15 * om[40] - - 60 * om[41] - 45 * om[42] + 15 * om[43] + 15 * om[44]; - phi[p45[39]] = -30 * om[36] + 30 * om[37] + 15 * om[38] + 90 * om[39] - 45 * om[40] - - 30 * om[41] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[40]] = +15 * om[36] - 60 * om[37] + 15 * om[38] - 45 * om[39] + 90 * om[40] - - 30 * om[41] + 15 * om[42] - 45 * om[43] + 15 * om[44]; - phi[p45[41]] = +30 * om[36] - 60 * om[38] - 30 * om[39] - 30 * om[40] + 120 * om[41] + - 30 * om[42] - 30 * om[43] - 30 * om[44]; + phi[p45[0]] = +9 * om[0] - 18 * om[1] + 3 * om[2] - 27 * om[30] + 12 * om[31] + 9 * om[32] + 9 * om[33] - 6 * om[34] - 6 * om[35] - 27 * om[36] + 12 * om[37] + 9 * om[38] + 9 * om[39] - + 6 * om[40] - 6 * om[41] + 18 * om[42] - 6 * om[43] - 6 * om[44]; + phi[p45[1]] = + -18 * om[0] + 84 * om[1] - 18 * om[2] - 6 * om[30] - 36 * om[31] + 12 * om[32] - 30 * om[33] + 30 * om[34] - 6 * om[36] - 36 * om[37] + 12 * om[38] - 30 * om[39] + 30 * om[40] + 24 * om[42]; + phi[p45[2]] = +3 * om[0] - 18 * om[1] + 9 * om[2] + 6 * om[30] - 18 * om[31] + 3 * om[32] + 6 * om[33] - 9 * om[34] + 6 * om[35] + 6 * om[36] - 18 * om[37] + 3 * om[38] + 6 * om[39] - + 9 * om[40] + 6 * om[41] + 6 * om[42] + 6 * om[43] + 6 * om[44]; + phi[p45[3]] = +9 * om[3] - 18 * om[4] + 3 * om[5] - 27 * om[24] + 12 * om[25] + 9 * om[26] + 9 * om[27] - 6 * om[28] - 6 * om[29] + 9 * om[36] - 6 * om[37] - 6 * om[38] - 27 * om[39] + + 9 * om[40] + 12 * om[41] - 6 * om[42] + 18 * om[43] - 6 * om[44]; + phi[p45[4]] = + -18 * om[3] + 84 * om[4] - 18 * om[5] - 6 * om[24] - 36 * om[25] + 12 * om[26] - 30 * om[27] + 30 * om[28] - 30 * om[36] + 30 * om[38] - 6 * om[39] + 12 * om[40] - 36 * om[41] + 24 * om[43]; + phi[p45[5]] = +3 * om[3] - 18 * om[4] + 9 * om[5] + 6 * om[24] - 18 * om[25] + 3 * om[26] + 6 * om[27] - 9 * om[28] + 6 * om[29] + 6 * om[36] + 6 * om[37] - 9 * om[38] + 6 * om[39] + + 3 * om[40] - 18 * om[41] + 6 * om[42] + 6 * om[43] + 6 * om[44]; + phi[p45[6]] = +9 * om[6] - 18 * om[7] + 3 * om[8] + 9 * om[24] - 6 * om[25] - 6 * om[26] - 27 * om[27] + 9 * om[28] + 12 * om[29] + 9 * om[30] - 6 * om[31] - 6 * om[32] - 27 * om[33] + + 9 * om[34] + 12 * om[35] - 6 * om[42] - 6 * om[43] + 18 * om[44]; + phi[p45[7]] = + -18 * om[6] + 84 * om[7] - 18 * om[8] - 30 * om[24] + 30 * om[26] - 6 * om[27] + 12 * om[28] - 36 * om[29] - 30 * om[30] + 30 * om[32] - 6 * om[33] + 12 * om[34] - 36 * om[35] + 24 * om[44]; + phi[p45[8]] = +3 * om[6] - 18 * om[7] + 9 * om[8] + 6 * om[24] + 6 * om[25] - 9 * om[26] + 6 * om[27] + 3 * om[28] - 18 * om[29] + 6 * om[30] + 6 * om[31] - 9 * om[32] + 6 * om[33] + + 3 * om[34] - 18 * om[35] + 6 * om[42] + 6 * om[43] + 6 * om[44]; + phi[p45[9]] = +9 * om[9] - 18 * om[10] + 3 * om[11] - 27 * om[18] + 12 * om[19] + 9 * om[20] + 9 * om[21] - 6 * om[22] - 6 * om[23] - 3 * om[36] + 18 * om[37] - 6 * om[38] + 9 * om[39] - + 27 * om[40] + 12 * om[41] - 6 * om[42] + 18 * om[43] - 6 * om[44]; + phi[p45[10]] = -18 * om[9] + 84 * om[10] - 18 * om[11] - 6 * om[18] - 36 * om[19] + 12 * om[20] - 30 * om[21] + 30 * om[22] - 12 * om[36] + 36 * om[37] + 6 * om[38] + 12 * om[39] - 6 * om[40] - + 36 * om[41] - 24 * om[42] + 24 * om[43]; + phi[p45[11]] = +3 * om[9] - 18 * om[10] + 9 * om[11] + 6 * om[18] - 18 * om[19] + 3 * om[20] + 6 * om[21] - 9 * om[22] + 6 * om[23] - 9 * om[36] - 12 * om[37] + 27 * om[38] + 3 * om[39] + + 6 * om[40] - 18 * om[41] - 18 * om[42] + 6 * om[43] + 6 * om[44]; + phi[p45[12]] = +9 * om[12] - 18 * om[13] + 3 * om[14] + 9 * om[18] - 6 * om[19] - 6 * om[20] - 27 * om[21] + 9 * om[22] + 12 * om[23] - 3 * om[30] + 18 * om[31] - 6 * om[32] + 9 * om[33] - + 27 * om[34] + 12 * om[35] - 6 * om[42] - 6 * om[43] + 18 * om[44]; + phi[p45[13]] = -18 * om[12] + 84 * om[13] - 18 * om[14] - 30 * om[18] + 30 * om[20] - 6 * om[21] + 12 * om[22] - 36 * om[23] - 12 * om[30] + 36 * om[31] + 6 * om[32] + 12 * om[33] - 6 * om[34] - + 36 * om[35] - 24 * om[42] + 24 * om[44]; + phi[p45[14]] = +3 * om[12] - 18 * om[13] + 9 * om[14] + 6 * om[18] + 6 * om[19] - 9 * om[20] + 6 * om[21] + 3 * om[22] - 18 * om[23] - 9 * om[30] - 12 * om[31] + 27 * om[32] + 3 * om[33] + + 6 * om[34] - 18 * om[35] - 18 * om[42] + 6 * om[43] + 6 * om[44]; + phi[p45[15]] = +9 * om[15] - 18 * om[16] + 3 * om[17] - 3 * om[18] + 18 * om[19] - 6 * om[20] + 9 * om[21] - 27 * om[22] + 12 * om[23] - 3 * om[24] + 18 * om[25] - 6 * om[26] + 9 * om[27] - + 27 * om[28] + 12 * om[29] - 6 * om[42] - 6 * om[43] + 18 * om[44]; + phi[p45[16]] = -18 * om[15] + 84 * om[16] - 18 * om[17] - 12 * om[18] + 36 * om[19] + 6 * om[20] + 12 * om[21] - 6 * om[22] - 36 * om[23] - 12 * om[24] + 36 * om[25] + 6 * om[26] + 12 * om[27] - + 6 * om[28] - 36 * om[29] - 24 * om[43] + 24 * om[44]; + phi[p45[17]] = +3 * om[15] - 18 * om[16] + 9 * om[17] - 9 * om[18] - 12 * om[19] + 27 * om[20] + 3 * om[21] + 6 * om[22] - 18 * om[23] - 9 * om[24] - 12 * om[25] + 27 * om[26] + 3 * om[27] + + 6 * om[28] - 18 * om[29] + 6 * om[42] - 18 * om[43] + 6 * om[44]; + phi[p45[18]] = +90 * om[18] - 30 * om[19] - 45 * om[20] - 30 * om[21] + 15 * om[22] + 30 * om[23] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[19]] = -30 * om[18] + 120 * om[19] - 30 * om[20] + 30 * om[21] - 60 * om[22] + 30 * om[42] - 30 * om[43] + 30 * om[44]; + phi[p45[20]] = -45 * om[18] - 30 * om[19] + 90 * om[20] + 15 * om[21] + 15 * om[22] - 60 * om[23] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[21]] = -30 * om[18] + 30 * om[19] + 15 * om[20] + 90 * om[21] - 45 * om[22] - 30 * om[23] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[22]] = +15 * om[18] - 60 * om[19] + 15 * om[20] - 45 * om[21] + 90 * om[22] - 30 * om[23] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[23]] = +30 * om[18] - 60 * om[20] - 30 * om[21] - 30 * om[22] + 120 * om[23] + 30 * om[42] + 30 * om[43] - 30 * om[44]; + phi[p45[24]] = +90 * om[24] - 30 * om[25] - 45 * om[26] - 30 * om[27] + 15 * om[28] + 30 * om[29] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[25]] = -30 * om[24] + 120 * om[25] - 30 * om[26] + 30 * om[27] - 60 * om[28] - 30 * om[42] - 30 * om[43] + 30 * om[44]; + phi[p45[26]] = -45 * om[24] - 30 * om[25] + 90 * om[26] + 15 * om[27] + 15 * om[28] - 60 * om[29] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[27]] = -30 * om[24] + 30 * om[25] + 15 * om[26] + 90 * om[27] - 45 * om[28] - 30 * om[29] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[28]] = +15 * om[24] - 60 * om[25] + 15 * om[26] - 45 * om[27] + 90 * om[28] - 30 * om[29] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[29]] = +30 * om[24] - 60 * om[26] - 30 * om[27] - 30 * om[28] + 120 * om[29] - 30 * om[42] + 30 * om[43] - 30 * om[44]; + phi[p45[30]] = +90 * om[30] - 30 * om[31] - 45 * om[32] - 30 * om[33] + 15 * om[34] + 30 * om[35] - 45 * om[42] + 15 * om[43] + 15 * om[44]; + phi[p45[31]] = -30 * om[30] + 120 * om[31] - 30 * om[32] + 30 * om[33] - 60 * om[34] - 30 * om[42] - 30 * om[43] + 30 * om[44]; + phi[p45[32]] = -45 * om[30] - 30 * om[31] + 90 * om[32] + 15 * om[33] + 15 * om[34] - 60 * om[35] - 45 * om[42] + 15 * om[43] + 15 * om[44]; + phi[p45[33]] = -30 * om[30] + 30 * om[31] + 15 * om[32] + 90 * om[33] - 45 * om[34] - 30 * om[35] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[34]] = +15 * om[30] - 60 * om[31] + 15 * om[32] - 45 * om[33] + 90 * om[34] - 30 * om[35] + 15 * om[42] + 15 * om[43] - 45 * om[44]; + phi[p45[35]] = +30 * om[30] - 60 * om[32] - 30 * om[33] - 30 * om[34] + 120 * om[35] + 30 * om[42] - 30 * om[43] - 30 * om[44]; + phi[p45[36]] = +90 * om[36] - 30 * om[37] - 45 * om[38] - 30 * om[39] + 15 * om[40] + 30 * om[41] - 45 * om[42] + 15 * om[43] + 15 * om[44]; + phi[p45[37]] = -30 * om[36] + 120 * om[37] - 30 * om[38] + 30 * om[39] - 60 * om[40] - 30 * om[42] + 30 * om[43] - 30 * om[44]; + phi[p45[38]] = -45 * om[36] - 30 * om[37] + 90 * om[38] + 15 * om[39] + 15 * om[40] - 60 * om[41] - 45 * om[42] + 15 * om[43] + 15 * om[44]; + phi[p45[39]] = -30 * om[36] + 30 * om[37] + 15 * om[38] + 90 * om[39] - 45 * om[40] - 30 * om[41] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[40]] = +15 * om[36] - 60 * om[37] + 15 * om[38] - 45 * om[39] + 90 * om[40] - 30 * om[41] + 15 * om[42] - 45 * om[43] + 15 * om[44]; + phi[p45[41]] = +30 * om[36] - 60 * om[38] - 30 * om[39] - 30 * om[40] + 120 * om[41] + 30 * om[42] - 30 * om[43] - 30 * om[44]; phi[p45[42]] = +90 * om[42] - 30 * om[43] - 30 * om[44]; phi[p45[43]] = -30 * om[42] + 90 * om[43] - 30 * om[44]; phi[p45[44]] = -30 * om[42] - 30 * om[43] + 90 * om[44]; @@ -1631,30 +1393,21 @@ namespace Fem2D { int i0 = perm[ii0]; int i1 = perm[ii1]; if (whatd & Fop_dx) { - omdx[i * 3] = 2 * D[i0].x * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdx[i * 3 + 1] = (D[i0].x * l[i1] + l[i0] * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdx[i * 3 + 2] = 2 * D[i1].x * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[i * 3] = 2 * D[i0].x * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[i * 3 + 1] = (D[i0].x * l[i1] + l[i0] * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[i * 3 + 2] = 2 * D[i1].x * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dy) { - omdy[i * 3] = 2 * D[i0].y * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdy[i * 3 + 1] = (D[i0].y * l[i1] + l[i0] * D[i1].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdy[i * 3 + 2] = 2 * D[i1].y * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[i * 3] = 2 * D[i0].y * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[i * 3 + 1] = (D[i0].y * l[i1] + l[i0] * D[i1].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[i * 3 + 2] = 2 * D[i1].y * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); } if (whatd & Fop_dz) { - omdz[i * 3] = 2 * D[i0].z * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdz[i * 3 + 1] = (D[i0].z * l[i1] + l[i0] * D[i1].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdz[i * 3 + 2] = 2 * D[i1].z * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[i * 3] = 2 * D[i0].z * l[i0] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[i * 3 + 1] = (D[i0].z * l[i1] + l[i0] * D[i1].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[i * 3 + 2] = 2 * D[i1].z * l[i1] * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); } } @@ -1667,254 +1420,123 @@ namespace Fem2D { int i1 = perm[ii1]; int i2 = perm[ii2]; if (whatd & Fop_dx) { - omdx[18 + j * 6] = (D[i0].x * l[i2] + l[i0] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdx[18 + j * 6 + 1] = - (D[i1].x * l[i2] + l[i1] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdx[18 + j * 6 + 2] = - (D[i2].x * l[i2] + l[i2] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i2] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdx[18 + j * 6 + 3] = - (D[i0].x * l[i1] + l[i0] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i0] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdx[18 + j * 6 + 4] = - (D[i1].x * l[i1] + l[i1] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i1] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdx[18 + j * 6 + 5] = - (D[i2].x * l[i1] + l[i2] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i2] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdx[18 + j * 6] = (D[i0].x * l[i2] + l[i0] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[18 + j * 6 + 1] = (D[i1].x * l[i2] + l[i1] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[18 + j * 6 + 2] = (D[i2].x * l[i2] + l[i2] * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * l[i2] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdx[18 + j * 6 + 3] = (D[i0].x * l[i1] + l[i0] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i0] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdx[18 + j * 6 + 4] = (D[i1].x * l[i1] + l[i1] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdx[18 + j * 6 + 5] = (D[i2].x * l[i1] + l[i2] * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i2] * l[i1] * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dy) { - omdy[18 + j * 6] = (D[i0].y * l[i2] + l[i0] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdy[18 + j * 6 + 1] = - (D[i1].y * l[i2] + l[i1] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdy[18 + j * 6 + 2] = - (D[i2].y * l[i2] + l[i2] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i2] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdy[18 + j * 6 + 3] = - (D[i0].y * l[i1] + l[i0] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i0] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdy[18 + j * 6 + 4] = - (D[i1].y * l[i1] + l[i1] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i1] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdy[18 + j * 6 + 5] = - (D[i2].y * l[i1] + l[i2] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i2] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdy[18 + j * 6] = (D[i0].y * l[i2] + l[i0] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[18 + j * 6 + 1] = (D[i1].y * l[i2] + l[i1] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[18 + j * 6 + 2] = (D[i2].y * l[i2] + l[i2] * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * l[i2] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdy[18 + j * 6 + 3] = (D[i0].y * l[i1] + l[i0] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i0] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdy[18 + j * 6 + 4] = (D[i1].y * l[i1] + l[i1] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdy[18 + j * 6 + 5] = (D[i2].y * l[i1] + l[i2] * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i2] * l[i1] * (D[i0].y * D[i2] - D[i2].y * D[i0]); } if (whatd & Fop_dz) { - omdz[18 + j * 6] = (D[i0].z * l[i2] + l[i0] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i0] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdz[18 + j * 6 + 1] = - (D[i1].z * l[i2] + l[i1] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i1] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdz[18 + j * 6 + 2] = - (D[i2].z * l[i2] + l[i2] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + - l[i2] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdz[18 + j * 6 + 3] = - (D[i0].z * l[i1] + l[i0] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i0] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); - omdz[18 + j * 6 + 4] = - (D[i1].z * l[i1] + l[i1] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i1] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); - omdz[18 + j * 6 + 5] = - (D[i2].z * l[i1] + l[i2] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + - l[i2] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdz[18 + j * 6] = (D[i0].z * l[i2] + l[i0] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i0] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[18 + j * 6 + 1] = (D[i1].z * l[i2] + l[i1] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i1] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[18 + j * 6 + 2] = (D[i2].z * l[i2] + l[i2] * D[i2].z) * (l[i0] * D[i1] - l[i1] * D[i0]) + l[i2] * l[i2] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdz[18 + j * 6 + 3] = (D[i0].z * l[i1] + l[i0] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i0] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdz[18 + j * 6 + 4] = (D[i1].z * l[i1] + l[i1] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i1] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdz[18 + j * 6 + 5] = (D[i2].z * l[i1] + l[i2] * D[i1].z) * (l[i0] * D[i2] - l[i2] * D[i0]) + l[i2] * l[i1] * (D[i0].z * D[i2] - D[i2].z * D[i0]); } } // 3 volume functions if (whatd & Fop_dx) { - omdx[42] = - (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - l[perm[2]] * l[perm[3]] * (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); - omdx[43] = - (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - l[perm[1]] * l[perm[3]] * (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); - omdx[44] = - (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - l[perm[1]] * l[perm[2]] * (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); + omdx[42] = (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + l[perm[2]] * l[perm[3]] * (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); + omdx[43] = (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + l[perm[1]] * l[perm[3]] * (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); + omdx[44] = (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + l[perm[1]] * l[perm[2]] * (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); } if (whatd & Fop_dy) { - omdy[42] = - (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - l[perm[2]] * l[perm[3]] * (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); - omdy[43] = - (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - l[perm[1]] * l[perm[3]] * (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); - omdy[44] = - (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - l[perm[1]] * l[perm[2]] * (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); + omdy[42] = (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + l[perm[2]] * l[perm[3]] * (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); + omdy[43] = (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + l[perm[1]] * l[perm[3]] * (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); + omdy[44] = (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + l[perm[1]] * l[perm[2]] * (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); } if (whatd & Fop_dz) { - omdz[42] = - (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - l[perm[2]] * l[perm[3]] * (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]); - omdz[43] = - (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - l[perm[1]] * l[perm[3]] * (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]); - omdz[44] = - (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - l[perm[1]] * l[perm[2]] * (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]); + omdz[42] = (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + l[perm[2]] * l[perm[3]] * (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]); + omdz[43] = (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + l[perm[1]] * l[perm[3]] * (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]); + omdz[44] = (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + l[perm[1]] * l[perm[2]] * (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]); } R3 phidx[45]; if (whatd & Fop_dx) { - phidx[p45[0]] = +9 * omdx[0] - 18 * omdx[1] + 3 * omdx[2] - 27 * omdx[30] + 12 * omdx[31] + - 9 * omdx[32] + 9 * omdx[33] - 6 * omdx[34] - 6 * omdx[35] - 27 * omdx[36] + - 12 * omdx[37] + 9 * omdx[38] + 9 * omdx[39] - 6 * omdx[40] - 6 * omdx[41] + - 18 * omdx[42] - 6 * omdx[43] - 6 * omdx[44]; - phidx[p45[1]] = -18 * omdx[0] + 84 * omdx[1] - 18 * omdx[2] - 6 * omdx[30] - 36 * omdx[31] + - 12 * omdx[32] - 30 * omdx[33] + 30 * omdx[34] - 6 * omdx[36] - - 36 * omdx[37] + 12 * omdx[38] - 30 * omdx[39] + 30 * omdx[40] + - 24 * omdx[42]; - phidx[p45[2]] = +3 * omdx[0] - 18 * omdx[1] + 9 * omdx[2] + 6 * omdx[30] - 18 * omdx[31] + - 3 * omdx[32] + 6 * omdx[33] - 9 * omdx[34] + 6 * omdx[35] + 6 * omdx[36] - - 18 * omdx[37] + 3 * omdx[38] + 6 * omdx[39] - 9 * omdx[40] + 6 * omdx[41] + - 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; - phidx[p45[3]] = +9 * omdx[3] - 18 * omdx[4] + 3 * omdx[5] - 27 * omdx[24] + 12 * omdx[25] + - 9 * omdx[26] + 9 * omdx[27] - 6 * omdx[28] - 6 * omdx[29] + 9 * omdx[36] - - 6 * omdx[37] - 6 * omdx[38] - 27 * omdx[39] + 9 * omdx[40] + 12 * omdx[41] - - 6 * omdx[42] + 18 * omdx[43] - 6 * omdx[44]; - phidx[p45[4]] = -18 * omdx[3] + 84 * omdx[4] - 18 * omdx[5] - 6 * omdx[24] - 36 * omdx[25] + - 12 * omdx[26] - 30 * omdx[27] + 30 * omdx[28] - 30 * omdx[36] + - 30 * omdx[38] - 6 * omdx[39] + 12 * omdx[40] - 36 * omdx[41] + - 24 * omdx[43]; - phidx[p45[5]] = +3 * omdx[3] - 18 * omdx[4] + 9 * omdx[5] + 6 * omdx[24] - 18 * omdx[25] + - 3 * omdx[26] + 6 * omdx[27] - 9 * omdx[28] + 6 * omdx[29] + 6 * omdx[36] + - 6 * omdx[37] - 9 * omdx[38] + 6 * omdx[39] + 3 * omdx[40] - 18 * omdx[41] + - 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; - phidx[p45[6]] = +9 * omdx[6] - 18 * omdx[7] + 3 * omdx[8] + 9 * omdx[24] - 6 * omdx[25] - - 6 * omdx[26] - 27 * omdx[27] + 9 * omdx[28] + 12 * omdx[29] + 9 * omdx[30] - - 6 * omdx[31] - 6 * omdx[32] - 27 * omdx[33] + 9 * omdx[34] + 12 * omdx[35] - - 6 * omdx[42] - 6 * omdx[43] + 18 * omdx[44]; - phidx[p45[7]] = -18 * omdx[6] + 84 * omdx[7] - 18 * omdx[8] - 30 * omdx[24] + - 30 * omdx[26] - 6 * omdx[27] + 12 * omdx[28] - 36 * omdx[29] - - 30 * omdx[30] + 30 * omdx[32] - 6 * omdx[33] + 12 * omdx[34] - - 36 * omdx[35] + 24 * omdx[44]; - phidx[p45[8]] = +3 * omdx[6] - 18 * omdx[7] + 9 * omdx[8] + 6 * omdx[24] + 6 * omdx[25] - - 9 * omdx[26] + 6 * omdx[27] + 3 * omdx[28] - 18 * omdx[29] + 6 * omdx[30] + - 6 * omdx[31] - 9 * omdx[32] + 6 * omdx[33] + 3 * omdx[34] - 18 * omdx[35] + - 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; - phidx[p45[9]] = +9 * omdx[9] - 18 * omdx[10] + 3 * omdx[11] - 27 * omdx[18] + - 12 * omdx[19] + 9 * omdx[20] + 9 * omdx[21] - 6 * omdx[22] - 6 * omdx[23] - - 3 * omdx[36] + 18 * omdx[37] - 6 * omdx[38] + 9 * omdx[39] - 27 * omdx[40] + - 12 * omdx[41] - 6 * omdx[42] + 18 * omdx[43] - 6 * omdx[44]; - phidx[p45[10]] = -18 * omdx[9] + 84 * omdx[10] - 18 * omdx[11] - 6 * omdx[18] - - 36 * omdx[19] + 12 * omdx[20] - 30 * omdx[21] + 30 * omdx[22] - - 12 * omdx[36] + 36 * omdx[37] + 6 * omdx[38] + 12 * omdx[39] - - 6 * omdx[40] - 36 * omdx[41] - 24 * omdx[42] + 24 * omdx[43]; - phidx[p45[11]] = +3 * omdx[9] - 18 * omdx[10] + 9 * omdx[11] + 6 * omdx[18] - - 18 * omdx[19] + 3 * omdx[20] + 6 * omdx[21] - 9 * omdx[22] + 6 * omdx[23] - - 9 * omdx[36] - 12 * omdx[37] + 27 * omdx[38] + 3 * omdx[39] + - 6 * omdx[40] - 18 * omdx[41] - 18 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; - phidx[p45[12]] = +9 * omdx[12] - 18 * omdx[13] + 3 * omdx[14] + 9 * omdx[18] - - 6 * omdx[19] - 6 * omdx[20] - 27 * omdx[21] + 9 * omdx[22] + - 12 * omdx[23] - 3 * omdx[30] + 18 * omdx[31] - 6 * omdx[32] + - 9 * omdx[33] - 27 * omdx[34] + 12 * omdx[35] - 6 * omdx[42] - - 6 * omdx[43] + 18 * omdx[44]; - phidx[p45[13]] = -18 * omdx[12] + 84 * omdx[13] - 18 * omdx[14] - 30 * omdx[18] + - 30 * omdx[20] - 6 * omdx[21] + 12 * omdx[22] - 36 * omdx[23] - - 12 * omdx[30] + 36 * omdx[31] + 6 * omdx[32] + 12 * omdx[33] - - 6 * omdx[34] - 36 * omdx[35] - 24 * omdx[42] + 24 * omdx[44]; - phidx[p45[14]] = +3 * omdx[12] - 18 * omdx[13] + 9 * omdx[14] + 6 * omdx[18] + - 6 * omdx[19] - 9 * omdx[20] + 6 * omdx[21] + 3 * omdx[22] - 18 * omdx[23] - - 9 * omdx[30] - 12 * omdx[31] + 27 * omdx[32] + 3 * omdx[33] + - 6 * omdx[34] - 18 * omdx[35] - 18 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; - phidx[p45[15]] = +9 * omdx[15] - 18 * omdx[16] + 3 * omdx[17] - 3 * omdx[18] + - 18 * omdx[19] - 6 * omdx[20] + 9 * omdx[21] - 27 * omdx[22] + - 12 * omdx[23] - 3 * omdx[24] + 18 * omdx[25] - 6 * omdx[26] + - 9 * omdx[27] - 27 * omdx[28] + 12 * omdx[29] - 6 * omdx[42] - - 6 * omdx[43] + 18 * omdx[44]; - phidx[p45[16]] = -18 * omdx[15] + 84 * omdx[16] - 18 * omdx[17] - 12 * omdx[18] + - 36 * omdx[19] + 6 * omdx[20] + 12 * omdx[21] - 6 * omdx[22] - - 36 * omdx[23] - 12 * omdx[24] + 36 * omdx[25] + 6 * omdx[26] + - 12 * omdx[27] - 6 * omdx[28] - 36 * omdx[29] - 24 * omdx[43] + - 24 * omdx[44]; - phidx[p45[17]] = +3 * omdx[15] - 18 * omdx[16] + 9 * omdx[17] - 9 * omdx[18] - - 12 * omdx[19] + 27 * omdx[20] + 3 * omdx[21] + 6 * omdx[22] - - 18 * omdx[23] - 9 * omdx[24] - 12 * omdx[25] + 27 * omdx[26] + - 3 * omdx[27] + 6 * omdx[28] - 18 * omdx[29] + 6 * omdx[42] - - 18 * omdx[43] + 6 * omdx[44]; - phidx[p45[18]] = +90 * omdx[18] - 30 * omdx[19] - 45 * omdx[20] - 30 * omdx[21] + - 15 * omdx[22] + 30 * omdx[23] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[19]] = -30 * omdx[18] + 120 * omdx[19] - 30 * omdx[20] + 30 * omdx[21] - - 60 * omdx[22] + 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; - phidx[p45[20]] = -45 * omdx[18] - 30 * omdx[19] + 90 * omdx[20] + 15 * omdx[21] + - 15 * omdx[22] - 60 * omdx[23] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[21]] = -30 * omdx[18] + 30 * omdx[19] + 15 * omdx[20] + 90 * omdx[21] - - 45 * omdx[22] - 30 * omdx[23] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[22]] = +15 * omdx[18] - 60 * omdx[19] + 15 * omdx[20] - 45 * omdx[21] + - 90 * omdx[22] - 30 * omdx[23] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[23]] = +30 * omdx[18] - 60 * omdx[20] - 30 * omdx[21] - 30 * omdx[22] + - 120 * omdx[23] + 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; - phidx[p45[24]] = +90 * omdx[24] - 30 * omdx[25] - 45 * omdx[26] - 30 * omdx[27] + - 15 * omdx[28] + 30 * omdx[29] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[25]] = -30 * omdx[24] + 120 * omdx[25] - 30 * omdx[26] + 30 * omdx[27] - - 60 * omdx[28] - 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; - phidx[p45[26]] = -45 * omdx[24] - 30 * omdx[25] + 90 * omdx[26] + 15 * omdx[27] + - 15 * omdx[28] - 60 * omdx[29] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[27]] = -30 * omdx[24] + 30 * omdx[25] + 15 * omdx[26] + 90 * omdx[27] - - 45 * omdx[28] - 30 * omdx[29] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[28]] = +15 * omdx[24] - 60 * omdx[25] + 15 * omdx[26] - 45 * omdx[27] + - 90 * omdx[28] - 30 * omdx[29] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[29]] = +30 * omdx[24] - 60 * omdx[26] - 30 * omdx[27] - 30 * omdx[28] + - 120 * omdx[29] - 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; - phidx[p45[30]] = +90 * omdx[30] - 30 * omdx[31] - 45 * omdx[32] - 30 * omdx[33] + - 15 * omdx[34] + 30 * omdx[35] - 45 * omdx[42] + 15 * omdx[43] + - 15 * omdx[44]; - phidx[p45[31]] = -30 * omdx[30] + 120 * omdx[31] - 30 * omdx[32] + 30 * omdx[33] - - 60 * omdx[34] - 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; - phidx[p45[32]] = -45 * omdx[30] - 30 * omdx[31] + 90 * omdx[32] + 15 * omdx[33] + - 15 * omdx[34] - 60 * omdx[35] - 45 * omdx[42] + 15 * omdx[43] + - 15 * omdx[44]; - phidx[p45[33]] = -30 * omdx[30] + 30 * omdx[31] + 15 * omdx[32] + 90 * omdx[33] - - 45 * omdx[34] - 30 * omdx[35] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[34]] = +15 * omdx[30] - 60 * omdx[31] + 15 * omdx[32] - 45 * omdx[33] + - 90 * omdx[34] - 30 * omdx[35] + 15 * omdx[42] + 15 * omdx[43] - - 45 * omdx[44]; - phidx[p45[35]] = +30 * omdx[30] - 60 * omdx[32] - 30 * omdx[33] - 30 * omdx[34] + - 120 * omdx[35] + 30 * omdx[42] - 30 * omdx[43] - 30 * omdx[44]; - phidx[p45[36]] = +90 * omdx[36] - 30 * omdx[37] - 45 * omdx[38] - 30 * omdx[39] + - 15 * omdx[40] + 30 * omdx[41] - 45 * omdx[42] + 15 * omdx[43] + - 15 * omdx[44]; - phidx[p45[37]] = -30 * omdx[36] + 120 * omdx[37] - 30 * omdx[38] + 30 * omdx[39] - - 60 * omdx[40] - 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; - phidx[p45[38]] = -45 * omdx[36] - 30 * omdx[37] + 90 * omdx[38] + 15 * omdx[39] + - 15 * omdx[40] - 60 * omdx[41] - 45 * omdx[42] + 15 * omdx[43] + - 15 * omdx[44]; - phidx[p45[39]] = -30 * omdx[36] + 30 * omdx[37] + 15 * omdx[38] + 90 * omdx[39] - - 45 * omdx[40] - 30 * omdx[41] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[40]] = +15 * omdx[36] - 60 * omdx[37] + 15 * omdx[38] - 45 * omdx[39] + - 90 * omdx[40] - 30 * omdx[41] + 15 * omdx[42] - 45 * omdx[43] + - 15 * omdx[44]; - phidx[p45[41]] = +30 * omdx[36] - 60 * omdx[38] - 30 * omdx[39] - 30 * omdx[40] + - 120 * omdx[41] + 30 * omdx[42] - 30 * omdx[43] - 30 * omdx[44]; + phidx[p45[0]] = +9 * omdx[0] - 18 * omdx[1] + 3 * omdx[2] - 27 * omdx[30] + 12 * omdx[31] + 9 * omdx[32] + 9 * omdx[33] - 6 * omdx[34] - 6 * omdx[35] - 27 * omdx[36] + 12 * omdx[37] + + 9 * omdx[38] + 9 * omdx[39] - 6 * omdx[40] - 6 * omdx[41] + 18 * omdx[42] - 6 * omdx[43] - 6 * omdx[44]; + phidx[p45[1]] = -18 * omdx[0] + 84 * omdx[1] - 18 * omdx[2] - 6 * omdx[30] - 36 * omdx[31] + 12 * omdx[32] - 30 * omdx[33] + 30 * omdx[34] - 6 * omdx[36] - 36 * omdx[37] + 12 * omdx[38] - + 30 * omdx[39] + 30 * omdx[40] + 24 * omdx[42]; + phidx[p45[2]] = +3 * omdx[0] - 18 * omdx[1] + 9 * omdx[2] + 6 * omdx[30] - 18 * omdx[31] + 3 * omdx[32] + 6 * omdx[33] - 9 * omdx[34] + 6 * omdx[35] + 6 * omdx[36] - 18 * omdx[37] + + 3 * omdx[38] + 6 * omdx[39] - 9 * omdx[40] + 6 * omdx[41] + 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; + phidx[p45[3]] = +9 * omdx[3] - 18 * omdx[4] + 3 * omdx[5] - 27 * omdx[24] + 12 * omdx[25] + 9 * omdx[26] + 9 * omdx[27] - 6 * omdx[28] - 6 * omdx[29] + 9 * omdx[36] - 6 * omdx[37] - + 6 * omdx[38] - 27 * omdx[39] + 9 * omdx[40] + 12 * omdx[41] - 6 * omdx[42] + 18 * omdx[43] - 6 * omdx[44]; + phidx[p45[4]] = -18 * omdx[3] + 84 * omdx[4] - 18 * omdx[5] - 6 * omdx[24] - 36 * omdx[25] + 12 * omdx[26] - 30 * omdx[27] + 30 * omdx[28] - 30 * omdx[36] + 30 * omdx[38] - 6 * omdx[39] + + 12 * omdx[40] - 36 * omdx[41] + 24 * omdx[43]; + phidx[p45[5]] = +3 * omdx[3] - 18 * omdx[4] + 9 * omdx[5] + 6 * omdx[24] - 18 * omdx[25] + 3 * omdx[26] + 6 * omdx[27] - 9 * omdx[28] + 6 * omdx[29] + 6 * omdx[36] + 6 * omdx[37] - + 9 * omdx[38] + 6 * omdx[39] + 3 * omdx[40] - 18 * omdx[41] + 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; + phidx[p45[6]] = +9 * omdx[6] - 18 * omdx[7] + 3 * omdx[8] + 9 * omdx[24] - 6 * omdx[25] - 6 * omdx[26] - 27 * omdx[27] + 9 * omdx[28] + 12 * omdx[29] + 9 * omdx[30] - 6 * omdx[31] - + 6 * omdx[32] - 27 * omdx[33] + 9 * omdx[34] + 12 * omdx[35] - 6 * omdx[42] - 6 * omdx[43] + 18 * omdx[44]; + phidx[p45[7]] = -18 * omdx[6] + 84 * omdx[7] - 18 * omdx[8] - 30 * omdx[24] + 30 * omdx[26] - 6 * omdx[27] + 12 * omdx[28] - 36 * omdx[29] - 30 * omdx[30] + 30 * omdx[32] - 6 * omdx[33] + + 12 * omdx[34] - 36 * omdx[35] + 24 * omdx[44]; + phidx[p45[8]] = +3 * omdx[6] - 18 * omdx[7] + 9 * omdx[8] + 6 * omdx[24] + 6 * omdx[25] - 9 * omdx[26] + 6 * omdx[27] + 3 * omdx[28] - 18 * omdx[29] + 6 * omdx[30] + 6 * omdx[31] - + 9 * omdx[32] + 6 * omdx[33] + 3 * omdx[34] - 18 * omdx[35] + 6 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; + phidx[p45[9]] = +9 * omdx[9] - 18 * omdx[10] + 3 * omdx[11] - 27 * omdx[18] + 12 * omdx[19] + 9 * omdx[20] + 9 * omdx[21] - 6 * omdx[22] - 6 * omdx[23] - 3 * omdx[36] + 18 * omdx[37] - + 6 * omdx[38] + 9 * omdx[39] - 27 * omdx[40] + 12 * omdx[41] - 6 * omdx[42] + 18 * omdx[43] - 6 * omdx[44]; + phidx[p45[10]] = -18 * omdx[9] + 84 * omdx[10] - 18 * omdx[11] - 6 * omdx[18] - 36 * omdx[19] + 12 * omdx[20] - 30 * omdx[21] + 30 * omdx[22] - 12 * omdx[36] + 36 * omdx[37] + 6 * omdx[38] + + 12 * omdx[39] - 6 * omdx[40] - 36 * omdx[41] - 24 * omdx[42] + 24 * omdx[43]; + phidx[p45[11]] = +3 * omdx[9] - 18 * omdx[10] + 9 * omdx[11] + 6 * omdx[18] - 18 * omdx[19] + 3 * omdx[20] + 6 * omdx[21] - 9 * omdx[22] + 6 * omdx[23] - 9 * omdx[36] - 12 * omdx[37] + + 27 * omdx[38] + 3 * omdx[39] + 6 * omdx[40] - 18 * omdx[41] - 18 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; + phidx[p45[12]] = +9 * omdx[12] - 18 * omdx[13] + 3 * omdx[14] + 9 * omdx[18] - 6 * omdx[19] - 6 * omdx[20] - 27 * omdx[21] + 9 * omdx[22] + 12 * omdx[23] - 3 * omdx[30] + 18 * omdx[31] - + 6 * omdx[32] + 9 * omdx[33] - 27 * omdx[34] + 12 * omdx[35] - 6 * omdx[42] - 6 * omdx[43] + 18 * omdx[44]; + phidx[p45[13]] = -18 * omdx[12] + 84 * omdx[13] - 18 * omdx[14] - 30 * omdx[18] + 30 * omdx[20] - 6 * omdx[21] + 12 * omdx[22] - 36 * omdx[23] - 12 * omdx[30] + 36 * omdx[31] + 6 * omdx[32] + + 12 * omdx[33] - 6 * omdx[34] - 36 * omdx[35] - 24 * omdx[42] + 24 * omdx[44]; + phidx[p45[14]] = +3 * omdx[12] - 18 * omdx[13] + 9 * omdx[14] + 6 * omdx[18] + 6 * omdx[19] - 9 * omdx[20] + 6 * omdx[21] + 3 * omdx[22] - 18 * omdx[23] - 9 * omdx[30] - 12 * omdx[31] + + 27 * omdx[32] + 3 * omdx[33] + 6 * omdx[34] - 18 * omdx[35] - 18 * omdx[42] + 6 * omdx[43] + 6 * omdx[44]; + phidx[p45[15]] = +9 * omdx[15] - 18 * omdx[16] + 3 * omdx[17] - 3 * omdx[18] + 18 * omdx[19] - 6 * omdx[20] + 9 * omdx[21] - 27 * omdx[22] + 12 * omdx[23] - 3 * omdx[24] + 18 * omdx[25] - + 6 * omdx[26] + 9 * omdx[27] - 27 * omdx[28] + 12 * omdx[29] - 6 * omdx[42] - 6 * omdx[43] + 18 * omdx[44]; + phidx[p45[16]] = -18 * omdx[15] + 84 * omdx[16] - 18 * omdx[17] - 12 * omdx[18] + 36 * omdx[19] + 6 * omdx[20] + 12 * omdx[21] - 6 * omdx[22] - 36 * omdx[23] - 12 * omdx[24] + 36 * omdx[25] + + 6 * omdx[26] + 12 * omdx[27] - 6 * omdx[28] - 36 * omdx[29] - 24 * omdx[43] + 24 * omdx[44]; + phidx[p45[17]] = +3 * omdx[15] - 18 * omdx[16] + 9 * omdx[17] - 9 * omdx[18] - 12 * omdx[19] + 27 * omdx[20] + 3 * omdx[21] + 6 * omdx[22] - 18 * omdx[23] - 9 * omdx[24] - 12 * omdx[25] + + 27 * omdx[26] + 3 * omdx[27] + 6 * omdx[28] - 18 * omdx[29] + 6 * omdx[42] - 18 * omdx[43] + 6 * omdx[44]; + phidx[p45[18]] = +90 * omdx[18] - 30 * omdx[19] - 45 * omdx[20] - 30 * omdx[21] + 15 * omdx[22] + 30 * omdx[23] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[19]] = -30 * omdx[18] + 120 * omdx[19] - 30 * omdx[20] + 30 * omdx[21] - 60 * omdx[22] + 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; + phidx[p45[20]] = -45 * omdx[18] - 30 * omdx[19] + 90 * omdx[20] + 15 * omdx[21] + 15 * omdx[22] - 60 * omdx[23] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[21]] = -30 * omdx[18] + 30 * omdx[19] + 15 * omdx[20] + 90 * omdx[21] - 45 * omdx[22] - 30 * omdx[23] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[22]] = +15 * omdx[18] - 60 * omdx[19] + 15 * omdx[20] - 45 * omdx[21] + 90 * omdx[22] - 30 * omdx[23] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[23]] = +30 * omdx[18] - 60 * omdx[20] - 30 * omdx[21] - 30 * omdx[22] + 120 * omdx[23] + 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; + phidx[p45[24]] = +90 * omdx[24] - 30 * omdx[25] - 45 * omdx[26] - 30 * omdx[27] + 15 * omdx[28] + 30 * omdx[29] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[25]] = -30 * omdx[24] + 120 * omdx[25] - 30 * omdx[26] + 30 * omdx[27] - 60 * omdx[28] - 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; + phidx[p45[26]] = -45 * omdx[24] - 30 * omdx[25] + 90 * omdx[26] + 15 * omdx[27] + 15 * omdx[28] - 60 * omdx[29] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[27]] = -30 * omdx[24] + 30 * omdx[25] + 15 * omdx[26] + 90 * omdx[27] - 45 * omdx[28] - 30 * omdx[29] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[28]] = +15 * omdx[24] - 60 * omdx[25] + 15 * omdx[26] - 45 * omdx[27] + 90 * omdx[28] - 30 * omdx[29] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[29]] = +30 * omdx[24] - 60 * omdx[26] - 30 * omdx[27] - 30 * omdx[28] + 120 * omdx[29] - 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; + phidx[p45[30]] = +90 * omdx[30] - 30 * omdx[31] - 45 * omdx[32] - 30 * omdx[33] + 15 * omdx[34] + 30 * omdx[35] - 45 * omdx[42] + 15 * omdx[43] + 15 * omdx[44]; + phidx[p45[31]] = -30 * omdx[30] + 120 * omdx[31] - 30 * omdx[32] + 30 * omdx[33] - 60 * omdx[34] - 30 * omdx[42] - 30 * omdx[43] + 30 * omdx[44]; + phidx[p45[32]] = -45 * omdx[30] - 30 * omdx[31] + 90 * omdx[32] + 15 * omdx[33] + 15 * omdx[34] - 60 * omdx[35] - 45 * omdx[42] + 15 * omdx[43] + 15 * omdx[44]; + phidx[p45[33]] = -30 * omdx[30] + 30 * omdx[31] + 15 * omdx[32] + 90 * omdx[33] - 45 * omdx[34] - 30 * omdx[35] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[34]] = +15 * omdx[30] - 60 * omdx[31] + 15 * omdx[32] - 45 * omdx[33] + 90 * omdx[34] - 30 * omdx[35] + 15 * omdx[42] + 15 * omdx[43] - 45 * omdx[44]; + phidx[p45[35]] = +30 * omdx[30] - 60 * omdx[32] - 30 * omdx[33] - 30 * omdx[34] + 120 * omdx[35] + 30 * omdx[42] - 30 * omdx[43] - 30 * omdx[44]; + phidx[p45[36]] = +90 * omdx[36] - 30 * omdx[37] - 45 * omdx[38] - 30 * omdx[39] + 15 * omdx[40] + 30 * omdx[41] - 45 * omdx[42] + 15 * omdx[43] + 15 * omdx[44]; + phidx[p45[37]] = -30 * omdx[36] + 120 * omdx[37] - 30 * omdx[38] + 30 * omdx[39] - 60 * omdx[40] - 30 * omdx[42] + 30 * omdx[43] - 30 * omdx[44]; + phidx[p45[38]] = -45 * omdx[36] - 30 * omdx[37] + 90 * omdx[38] + 15 * omdx[39] + 15 * omdx[40] - 60 * omdx[41] - 45 * omdx[42] + 15 * omdx[43] + 15 * omdx[44]; + phidx[p45[39]] = -30 * omdx[36] + 30 * omdx[37] + 15 * omdx[38] + 90 * omdx[39] - 45 * omdx[40] - 30 * omdx[41] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[40]] = +15 * omdx[36] - 60 * omdx[37] + 15 * omdx[38] - 45 * omdx[39] + 90 * omdx[40] - 30 * omdx[41] + 15 * omdx[42] - 45 * omdx[43] + 15 * omdx[44]; + phidx[p45[41]] = +30 * omdx[36] - 60 * omdx[38] - 30 * omdx[39] - 30 * omdx[40] + 120 * omdx[41] + 30 * omdx[42] - 30 * omdx[43] - 30 * omdx[44]; phidx[p45[42]] = +90 * omdx[42] - 30 * omdx[43] - 30 * omdx[44]; phidx[p45[43]] = -30 * omdx[42] + 90 * omdx[43] - 30 * omdx[44]; phidx[p45[44]] = -30 * omdx[42] - 30 * omdx[43] + 90 * omdx[44]; @@ -1928,146 +1550,66 @@ namespace Fem2D { R3 phidy[45]; if (whatd & Fop_dy) { - phidy[p45[0]] = +9 * omdy[0] - 18 * omdy[1] + 3 * omdy[2] - 27 * omdy[30] + 12 * omdy[31] + - 9 * omdy[32] + 9 * omdy[33] - 6 * omdy[34] - 6 * omdy[35] - 27 * omdy[36] + - 12 * omdy[37] + 9 * omdy[38] + 9 * omdy[39] - 6 * omdy[40] - 6 * omdy[41] + - 18 * omdy[42] - 6 * omdy[43] - 6 * omdy[44]; - phidy[p45[1]] = -18 * omdy[0] + 84 * omdy[1] - 18 * omdy[2] - 6 * omdy[30] - 36 * omdy[31] + - 12 * omdy[32] - 30 * omdy[33] + 30 * omdy[34] - 6 * omdy[36] - - 36 * omdy[37] + 12 * omdy[38] - 30 * omdy[39] + 30 * omdy[40] + - 24 * omdy[42]; - phidy[p45[2]] = +3 * omdy[0] - 18 * omdy[1] + 9 * omdy[2] + 6 * omdy[30] - 18 * omdy[31] + - 3 * omdy[32] + 6 * omdy[33] - 9 * omdy[34] + 6 * omdy[35] + 6 * omdy[36] - - 18 * omdy[37] + 3 * omdy[38] + 6 * omdy[39] - 9 * omdy[40] + 6 * omdy[41] + - 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; - phidy[p45[3]] = +9 * omdy[3] - 18 * omdy[4] + 3 * omdy[5] - 27 * omdy[24] + 12 * omdy[25] + - 9 * omdy[26] + 9 * omdy[27] - 6 * omdy[28] - 6 * omdy[29] + 9 * omdy[36] - - 6 * omdy[37] - 6 * omdy[38] - 27 * omdy[39] + 9 * omdy[40] + 12 * omdy[41] - - 6 * omdy[42] + 18 * omdy[43] - 6 * omdy[44]; - phidy[p45[4]] = -18 * omdy[3] + 84 * omdy[4] - 18 * omdy[5] - 6 * omdy[24] - 36 * omdy[25] + - 12 * omdy[26] - 30 * omdy[27] + 30 * omdy[28] - 30 * omdy[36] + - 30 * omdy[38] - 6 * omdy[39] + 12 * omdy[40] - 36 * omdy[41] + - 24 * omdy[43]; - phidy[p45[5]] = +3 * omdy[3] - 18 * omdy[4] + 9 * omdy[5] + 6 * omdy[24] - 18 * omdy[25] + - 3 * omdy[26] + 6 * omdy[27] - 9 * omdy[28] + 6 * omdy[29] + 6 * omdy[36] + - 6 * omdy[37] - 9 * omdy[38] + 6 * omdy[39] + 3 * omdy[40] - 18 * omdy[41] + - 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; - phidy[p45[6]] = +9 * omdy[6] - 18 * omdy[7] + 3 * omdy[8] + 9 * omdy[24] - 6 * omdy[25] - - 6 * omdy[26] - 27 * omdy[27] + 9 * omdy[28] + 12 * omdy[29] + 9 * omdy[30] - - 6 * omdy[31] - 6 * omdy[32] - 27 * omdy[33] + 9 * omdy[34] + 12 * omdy[35] - - 6 * omdy[42] - 6 * omdy[43] + 18 * omdy[44]; - phidy[p45[7]] = -18 * omdy[6] + 84 * omdy[7] - 18 * omdy[8] - 30 * omdy[24] + - 30 * omdy[26] - 6 * omdy[27] + 12 * omdy[28] - 36 * omdy[29] - - 30 * omdy[30] + 30 * omdy[32] - 6 * omdy[33] + 12 * omdy[34] - - 36 * omdy[35] + 24 * omdy[44]; - phidy[p45[8]] = +3 * omdy[6] - 18 * omdy[7] + 9 * omdy[8] + 6 * omdy[24] + 6 * omdy[25] - - 9 * omdy[26] + 6 * omdy[27] + 3 * omdy[28] - 18 * omdy[29] + 6 * omdy[30] + - 6 * omdy[31] - 9 * omdy[32] + 6 * omdy[33] + 3 * omdy[34] - 18 * omdy[35] + - 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; - phidy[p45[9]] = +9 * omdy[9] - 18 * omdy[10] + 3 * omdy[11] - 27 * omdy[18] + - 12 * omdy[19] + 9 * omdy[20] + 9 * omdy[21] - 6 * omdy[22] - 6 * omdy[23] - - 3 * omdy[36] + 18 * omdy[37] - 6 * omdy[38] + 9 * omdy[39] - 27 * omdy[40] + - 12 * omdy[41] - 6 * omdy[42] + 18 * omdy[43] - 6 * omdy[44]; - phidy[p45[10]] = -18 * omdy[9] + 84 * omdy[10] - 18 * omdy[11] - 6 * omdy[18] - - 36 * omdy[19] + 12 * omdy[20] - 30 * omdy[21] + 30 * omdy[22] - - 12 * omdy[36] + 36 * omdy[37] + 6 * omdy[38] + 12 * omdy[39] - - 6 * omdy[40] - 36 * omdy[41] - 24 * omdy[42] + 24 * omdy[43]; - phidy[p45[11]] = +3 * omdy[9] - 18 * omdy[10] + 9 * omdy[11] + 6 * omdy[18] - - 18 * omdy[19] + 3 * omdy[20] + 6 * omdy[21] - 9 * omdy[22] + 6 * omdy[23] - - 9 * omdy[36] - 12 * omdy[37] + 27 * omdy[38] + 3 * omdy[39] + - 6 * omdy[40] - 18 * omdy[41] - 18 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; - phidy[p45[12]] = +9 * omdy[12] - 18 * omdy[13] + 3 * omdy[14] + 9 * omdy[18] - - 6 * omdy[19] - 6 * omdy[20] - 27 * omdy[21] + 9 * omdy[22] + - 12 * omdy[23] - 3 * omdy[30] + 18 * omdy[31] - 6 * omdy[32] + - 9 * omdy[33] - 27 * omdy[34] + 12 * omdy[35] - 6 * omdy[42] - - 6 * omdy[43] + 18 * omdy[44]; - phidy[p45[13]] = -18 * omdy[12] + 84 * omdy[13] - 18 * omdy[14] - 30 * omdy[18] + - 30 * omdy[20] - 6 * omdy[21] + 12 * omdy[22] - 36 * omdy[23] - - 12 * omdy[30] + 36 * omdy[31] + 6 * omdy[32] + 12 * omdy[33] - - 6 * omdy[34] - 36 * omdy[35] - 24 * omdy[42] + 24 * omdy[44]; - phidy[p45[14]] = +3 * omdy[12] - 18 * omdy[13] + 9 * omdy[14] + 6 * omdy[18] + - 6 * omdy[19] - 9 * omdy[20] + 6 * omdy[21] + 3 * omdy[22] - 18 * omdy[23] - - 9 * omdy[30] - 12 * omdy[31] + 27 * omdy[32] + 3 * omdy[33] + - 6 * omdy[34] - 18 * omdy[35] - 18 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; - phidy[p45[15]] = +9 * omdy[15] - 18 * omdy[16] + 3 * omdy[17] - 3 * omdy[18] + - 18 * omdy[19] - 6 * omdy[20] + 9 * omdy[21] - 27 * omdy[22] + - 12 * omdy[23] - 3 * omdy[24] + 18 * omdy[25] - 6 * omdy[26] + - 9 * omdy[27] - 27 * omdy[28] + 12 * omdy[29] - 6 * omdy[42] - - 6 * omdy[43] + 18 * omdy[44]; - phidy[p45[16]] = -18 * omdy[15] + 84 * omdy[16] - 18 * omdy[17] - 12 * omdy[18] + - 36 * omdy[19] + 6 * omdy[20] + 12 * omdy[21] - 6 * omdy[22] - - 36 * omdy[23] - 12 * omdy[24] + 36 * omdy[25] + 6 * omdy[26] + - 12 * omdy[27] - 6 * omdy[28] - 36 * omdy[29] - 24 * omdy[43] + - 24 * omdy[44]; - phidy[p45[17]] = +3 * omdy[15] - 18 * omdy[16] + 9 * omdy[17] - 9 * omdy[18] - - 12 * omdy[19] + 27 * omdy[20] + 3 * omdy[21] + 6 * omdy[22] - - 18 * omdy[23] - 9 * omdy[24] - 12 * omdy[25] + 27 * omdy[26] + - 3 * omdy[27] + 6 * omdy[28] - 18 * omdy[29] + 6 * omdy[42] - - 18 * omdy[43] + 6 * omdy[44]; - phidy[p45[18]] = +90 * omdy[18] - 30 * omdy[19] - 45 * omdy[20] - 30 * omdy[21] + - 15 * omdy[22] + 30 * omdy[23] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[19]] = -30 * omdy[18] + 120 * omdy[19] - 30 * omdy[20] + 30 * omdy[21] - - 60 * omdy[22] + 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; - phidy[p45[20]] = -45 * omdy[18] - 30 * omdy[19] + 90 * omdy[20] + 15 * omdy[21] + - 15 * omdy[22] - 60 * omdy[23] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[21]] = -30 * omdy[18] + 30 * omdy[19] + 15 * omdy[20] + 90 * omdy[21] - - 45 * omdy[22] - 30 * omdy[23] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[22]] = +15 * omdy[18] - 60 * omdy[19] + 15 * omdy[20] - 45 * omdy[21] + - 90 * omdy[22] - 30 * omdy[23] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[23]] = +30 * omdy[18] - 60 * omdy[20] - 30 * omdy[21] - 30 * omdy[22] + - 120 * omdy[23] + 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; - phidy[p45[24]] = +90 * omdy[24] - 30 * omdy[25] - 45 * omdy[26] - 30 * omdy[27] + - 15 * omdy[28] + 30 * omdy[29] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[25]] = -30 * omdy[24] + 120 * omdy[25] - 30 * omdy[26] + 30 * omdy[27] - - 60 * omdy[28] - 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; - phidy[p45[26]] = -45 * omdy[24] - 30 * omdy[25] + 90 * omdy[26] + 15 * omdy[27] + - 15 * omdy[28] - 60 * omdy[29] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[27]] = -30 * omdy[24] + 30 * omdy[25] + 15 * omdy[26] + 90 * omdy[27] - - 45 * omdy[28] - 30 * omdy[29] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[28]] = +15 * omdy[24] - 60 * omdy[25] + 15 * omdy[26] - 45 * omdy[27] + - 90 * omdy[28] - 30 * omdy[29] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[29]] = +30 * omdy[24] - 60 * omdy[26] - 30 * omdy[27] - 30 * omdy[28] + - 120 * omdy[29] - 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; - phidy[p45[30]] = +90 * omdy[30] - 30 * omdy[31] - 45 * omdy[32] - 30 * omdy[33] + - 15 * omdy[34] + 30 * omdy[35] - 45 * omdy[42] + 15 * omdy[43] + - 15 * omdy[44]; - phidy[p45[31]] = -30 * omdy[30] + 120 * omdy[31] - 30 * omdy[32] + 30 * omdy[33] - - 60 * omdy[34] - 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; - phidy[p45[32]] = -45 * omdy[30] - 30 * omdy[31] + 90 * omdy[32] + 15 * omdy[33] + - 15 * omdy[34] - 60 * omdy[35] - 45 * omdy[42] + 15 * omdy[43] + - 15 * omdy[44]; - phidy[p45[33]] = -30 * omdy[30] + 30 * omdy[31] + 15 * omdy[32] + 90 * omdy[33] - - 45 * omdy[34] - 30 * omdy[35] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[34]] = +15 * omdy[30] - 60 * omdy[31] + 15 * omdy[32] - 45 * omdy[33] + - 90 * omdy[34] - 30 * omdy[35] + 15 * omdy[42] + 15 * omdy[43] - - 45 * omdy[44]; - phidy[p45[35]] = +30 * omdy[30] - 60 * omdy[32] - 30 * omdy[33] - 30 * omdy[34] + - 120 * omdy[35] + 30 * omdy[42] - 30 * omdy[43] - 30 * omdy[44]; - phidy[p45[36]] = +90 * omdy[36] - 30 * omdy[37] - 45 * omdy[38] - 30 * omdy[39] + - 15 * omdy[40] + 30 * omdy[41] - 45 * omdy[42] + 15 * omdy[43] + - 15 * omdy[44]; - phidy[p45[37]] = -30 * omdy[36] + 120 * omdy[37] - 30 * omdy[38] + 30 * omdy[39] - - 60 * omdy[40] - 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; - phidy[p45[38]] = -45 * omdy[36] - 30 * omdy[37] + 90 * omdy[38] + 15 * omdy[39] + - 15 * omdy[40] - 60 * omdy[41] - 45 * omdy[42] + 15 * omdy[43] + - 15 * omdy[44]; - phidy[p45[39]] = -30 * omdy[36] + 30 * omdy[37] + 15 * omdy[38] + 90 * omdy[39] - - 45 * omdy[40] - 30 * omdy[41] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[40]] = +15 * omdy[36] - 60 * omdy[37] + 15 * omdy[38] - 45 * omdy[39] + - 90 * omdy[40] - 30 * omdy[41] + 15 * omdy[42] - 45 * omdy[43] + - 15 * omdy[44]; - phidy[p45[41]] = +30 * omdy[36] - 60 * omdy[38] - 30 * omdy[39] - 30 * omdy[40] + - 120 * omdy[41] + 30 * omdy[42] - 30 * omdy[43] - 30 * omdy[44]; + phidy[p45[0]] = +9 * omdy[0] - 18 * omdy[1] + 3 * omdy[2] - 27 * omdy[30] + 12 * omdy[31] + 9 * omdy[32] + 9 * omdy[33] - 6 * omdy[34] - 6 * omdy[35] - 27 * omdy[36] + 12 * omdy[37] + + 9 * omdy[38] + 9 * omdy[39] - 6 * omdy[40] - 6 * omdy[41] + 18 * omdy[42] - 6 * omdy[43] - 6 * omdy[44]; + phidy[p45[1]] = -18 * omdy[0] + 84 * omdy[1] - 18 * omdy[2] - 6 * omdy[30] - 36 * omdy[31] + 12 * omdy[32] - 30 * omdy[33] + 30 * omdy[34] - 6 * omdy[36] - 36 * omdy[37] + 12 * omdy[38] - + 30 * omdy[39] + 30 * omdy[40] + 24 * omdy[42]; + phidy[p45[2]] = +3 * omdy[0] - 18 * omdy[1] + 9 * omdy[2] + 6 * omdy[30] - 18 * omdy[31] + 3 * omdy[32] + 6 * omdy[33] - 9 * omdy[34] + 6 * omdy[35] + 6 * omdy[36] - 18 * omdy[37] + + 3 * omdy[38] + 6 * omdy[39] - 9 * omdy[40] + 6 * omdy[41] + 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; + phidy[p45[3]] = +9 * omdy[3] - 18 * omdy[4] + 3 * omdy[5] - 27 * omdy[24] + 12 * omdy[25] + 9 * omdy[26] + 9 * omdy[27] - 6 * omdy[28] - 6 * omdy[29] + 9 * omdy[36] - 6 * omdy[37] - + 6 * omdy[38] - 27 * omdy[39] + 9 * omdy[40] + 12 * omdy[41] - 6 * omdy[42] + 18 * omdy[43] - 6 * omdy[44]; + phidy[p45[4]] = -18 * omdy[3] + 84 * omdy[4] - 18 * omdy[5] - 6 * omdy[24] - 36 * omdy[25] + 12 * omdy[26] - 30 * omdy[27] + 30 * omdy[28] - 30 * omdy[36] + 30 * omdy[38] - 6 * omdy[39] + + 12 * omdy[40] - 36 * omdy[41] + 24 * omdy[43]; + phidy[p45[5]] = +3 * omdy[3] - 18 * omdy[4] + 9 * omdy[5] + 6 * omdy[24] - 18 * omdy[25] + 3 * omdy[26] + 6 * omdy[27] - 9 * omdy[28] + 6 * omdy[29] + 6 * omdy[36] + 6 * omdy[37] - + 9 * omdy[38] + 6 * omdy[39] + 3 * omdy[40] - 18 * omdy[41] + 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; + phidy[p45[6]] = +9 * omdy[6] - 18 * omdy[7] + 3 * omdy[8] + 9 * omdy[24] - 6 * omdy[25] - 6 * omdy[26] - 27 * omdy[27] + 9 * omdy[28] + 12 * omdy[29] + 9 * omdy[30] - 6 * omdy[31] - + 6 * omdy[32] - 27 * omdy[33] + 9 * omdy[34] + 12 * omdy[35] - 6 * omdy[42] - 6 * omdy[43] + 18 * omdy[44]; + phidy[p45[7]] = -18 * omdy[6] + 84 * omdy[7] - 18 * omdy[8] - 30 * omdy[24] + 30 * omdy[26] - 6 * omdy[27] + 12 * omdy[28] - 36 * omdy[29] - 30 * omdy[30] + 30 * omdy[32] - 6 * omdy[33] + + 12 * omdy[34] - 36 * omdy[35] + 24 * omdy[44]; + phidy[p45[8]] = +3 * omdy[6] - 18 * omdy[7] + 9 * omdy[8] + 6 * omdy[24] + 6 * omdy[25] - 9 * omdy[26] + 6 * omdy[27] + 3 * omdy[28] - 18 * omdy[29] + 6 * omdy[30] + 6 * omdy[31] - + 9 * omdy[32] + 6 * omdy[33] + 3 * omdy[34] - 18 * omdy[35] + 6 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; + phidy[p45[9]] = +9 * omdy[9] - 18 * omdy[10] + 3 * omdy[11] - 27 * omdy[18] + 12 * omdy[19] + 9 * omdy[20] + 9 * omdy[21] - 6 * omdy[22] - 6 * omdy[23] - 3 * omdy[36] + 18 * omdy[37] - + 6 * omdy[38] + 9 * omdy[39] - 27 * omdy[40] + 12 * omdy[41] - 6 * omdy[42] + 18 * omdy[43] - 6 * omdy[44]; + phidy[p45[10]] = -18 * omdy[9] + 84 * omdy[10] - 18 * omdy[11] - 6 * omdy[18] - 36 * omdy[19] + 12 * omdy[20] - 30 * omdy[21] + 30 * omdy[22] - 12 * omdy[36] + 36 * omdy[37] + 6 * omdy[38] + + 12 * omdy[39] - 6 * omdy[40] - 36 * omdy[41] - 24 * omdy[42] + 24 * omdy[43]; + phidy[p45[11]] = +3 * omdy[9] - 18 * omdy[10] + 9 * omdy[11] + 6 * omdy[18] - 18 * omdy[19] + 3 * omdy[20] + 6 * omdy[21] - 9 * omdy[22] + 6 * omdy[23] - 9 * omdy[36] - 12 * omdy[37] + + 27 * omdy[38] + 3 * omdy[39] + 6 * omdy[40] - 18 * omdy[41] - 18 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; + phidy[p45[12]] = +9 * omdy[12] - 18 * omdy[13] + 3 * omdy[14] + 9 * omdy[18] - 6 * omdy[19] - 6 * omdy[20] - 27 * omdy[21] + 9 * omdy[22] + 12 * omdy[23] - 3 * omdy[30] + 18 * omdy[31] - + 6 * omdy[32] + 9 * omdy[33] - 27 * omdy[34] + 12 * omdy[35] - 6 * omdy[42] - 6 * omdy[43] + 18 * omdy[44]; + phidy[p45[13]] = -18 * omdy[12] + 84 * omdy[13] - 18 * omdy[14] - 30 * omdy[18] + 30 * omdy[20] - 6 * omdy[21] + 12 * omdy[22] - 36 * omdy[23] - 12 * omdy[30] + 36 * omdy[31] + 6 * omdy[32] + + 12 * omdy[33] - 6 * omdy[34] - 36 * omdy[35] - 24 * omdy[42] + 24 * omdy[44]; + phidy[p45[14]] = +3 * omdy[12] - 18 * omdy[13] + 9 * omdy[14] + 6 * omdy[18] + 6 * omdy[19] - 9 * omdy[20] + 6 * omdy[21] + 3 * omdy[22] - 18 * omdy[23] - 9 * omdy[30] - 12 * omdy[31] + + 27 * omdy[32] + 3 * omdy[33] + 6 * omdy[34] - 18 * omdy[35] - 18 * omdy[42] + 6 * omdy[43] + 6 * omdy[44]; + phidy[p45[15]] = +9 * omdy[15] - 18 * omdy[16] + 3 * omdy[17] - 3 * omdy[18] + 18 * omdy[19] - 6 * omdy[20] + 9 * omdy[21] - 27 * omdy[22] + 12 * omdy[23] - 3 * omdy[24] + 18 * omdy[25] - + 6 * omdy[26] + 9 * omdy[27] - 27 * omdy[28] + 12 * omdy[29] - 6 * omdy[42] - 6 * omdy[43] + 18 * omdy[44]; + phidy[p45[16]] = -18 * omdy[15] + 84 * omdy[16] - 18 * omdy[17] - 12 * omdy[18] + 36 * omdy[19] + 6 * omdy[20] + 12 * omdy[21] - 6 * omdy[22] - 36 * omdy[23] - 12 * omdy[24] + 36 * omdy[25] + + 6 * omdy[26] + 12 * omdy[27] - 6 * omdy[28] - 36 * omdy[29] - 24 * omdy[43] + 24 * omdy[44]; + phidy[p45[17]] = +3 * omdy[15] - 18 * omdy[16] + 9 * omdy[17] - 9 * omdy[18] - 12 * omdy[19] + 27 * omdy[20] + 3 * omdy[21] + 6 * omdy[22] - 18 * omdy[23] - 9 * omdy[24] - 12 * omdy[25] + + 27 * omdy[26] + 3 * omdy[27] + 6 * omdy[28] - 18 * omdy[29] + 6 * omdy[42] - 18 * omdy[43] + 6 * omdy[44]; + phidy[p45[18]] = +90 * omdy[18] - 30 * omdy[19] - 45 * omdy[20] - 30 * omdy[21] + 15 * omdy[22] + 30 * omdy[23] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[19]] = -30 * omdy[18] + 120 * omdy[19] - 30 * omdy[20] + 30 * omdy[21] - 60 * omdy[22] + 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; + phidy[p45[20]] = -45 * omdy[18] - 30 * omdy[19] + 90 * omdy[20] + 15 * omdy[21] + 15 * omdy[22] - 60 * omdy[23] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[21]] = -30 * omdy[18] + 30 * omdy[19] + 15 * omdy[20] + 90 * omdy[21] - 45 * omdy[22] - 30 * omdy[23] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[22]] = +15 * omdy[18] - 60 * omdy[19] + 15 * omdy[20] - 45 * omdy[21] + 90 * omdy[22] - 30 * omdy[23] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[23]] = +30 * omdy[18] - 60 * omdy[20] - 30 * omdy[21] - 30 * omdy[22] + 120 * omdy[23] + 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; + phidy[p45[24]] = +90 * omdy[24] - 30 * omdy[25] - 45 * omdy[26] - 30 * omdy[27] + 15 * omdy[28] + 30 * omdy[29] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[25]] = -30 * omdy[24] + 120 * omdy[25] - 30 * omdy[26] + 30 * omdy[27] - 60 * omdy[28] - 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; + phidy[p45[26]] = -45 * omdy[24] - 30 * omdy[25] + 90 * omdy[26] + 15 * omdy[27] + 15 * omdy[28] - 60 * omdy[29] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[27]] = -30 * omdy[24] + 30 * omdy[25] + 15 * omdy[26] + 90 * omdy[27] - 45 * omdy[28] - 30 * omdy[29] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[28]] = +15 * omdy[24] - 60 * omdy[25] + 15 * omdy[26] - 45 * omdy[27] + 90 * omdy[28] - 30 * omdy[29] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[29]] = +30 * omdy[24] - 60 * omdy[26] - 30 * omdy[27] - 30 * omdy[28] + 120 * omdy[29] - 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; + phidy[p45[30]] = +90 * omdy[30] - 30 * omdy[31] - 45 * omdy[32] - 30 * omdy[33] + 15 * omdy[34] + 30 * omdy[35] - 45 * omdy[42] + 15 * omdy[43] + 15 * omdy[44]; + phidy[p45[31]] = -30 * omdy[30] + 120 * omdy[31] - 30 * omdy[32] + 30 * omdy[33] - 60 * omdy[34] - 30 * omdy[42] - 30 * omdy[43] + 30 * omdy[44]; + phidy[p45[32]] = -45 * omdy[30] - 30 * omdy[31] + 90 * omdy[32] + 15 * omdy[33] + 15 * omdy[34] - 60 * omdy[35] - 45 * omdy[42] + 15 * omdy[43] + 15 * omdy[44]; + phidy[p45[33]] = -30 * omdy[30] + 30 * omdy[31] + 15 * omdy[32] + 90 * omdy[33] - 45 * omdy[34] - 30 * omdy[35] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[34]] = +15 * omdy[30] - 60 * omdy[31] + 15 * omdy[32] - 45 * omdy[33] + 90 * omdy[34] - 30 * omdy[35] + 15 * omdy[42] + 15 * omdy[43] - 45 * omdy[44]; + phidy[p45[35]] = +30 * omdy[30] - 60 * omdy[32] - 30 * omdy[33] - 30 * omdy[34] + 120 * omdy[35] + 30 * omdy[42] - 30 * omdy[43] - 30 * omdy[44]; + phidy[p45[36]] = +90 * omdy[36] - 30 * omdy[37] - 45 * omdy[38] - 30 * omdy[39] + 15 * omdy[40] + 30 * omdy[41] - 45 * omdy[42] + 15 * omdy[43] + 15 * omdy[44]; + phidy[p45[37]] = -30 * omdy[36] + 120 * omdy[37] - 30 * omdy[38] + 30 * omdy[39] - 60 * omdy[40] - 30 * omdy[42] + 30 * omdy[43] - 30 * omdy[44]; + phidy[p45[38]] = -45 * omdy[36] - 30 * omdy[37] + 90 * omdy[38] + 15 * omdy[39] + 15 * omdy[40] - 60 * omdy[41] - 45 * omdy[42] + 15 * omdy[43] + 15 * omdy[44]; + phidy[p45[39]] = -30 * omdy[36] + 30 * omdy[37] + 15 * omdy[38] + 90 * omdy[39] - 45 * omdy[40] - 30 * omdy[41] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[40]] = +15 * omdy[36] - 60 * omdy[37] + 15 * omdy[38] - 45 * omdy[39] + 90 * omdy[40] - 30 * omdy[41] + 15 * omdy[42] - 45 * omdy[43] + 15 * omdy[44]; + phidy[p45[41]] = +30 * omdy[36] - 60 * omdy[38] - 30 * omdy[39] - 30 * omdy[40] + 120 * omdy[41] + 30 * omdy[42] - 30 * omdy[43] - 30 * omdy[44]; phidy[p45[42]] = +90 * omdy[42] - 30 * omdy[43] - 30 * omdy[44]; phidy[p45[43]] = -30 * omdy[42] + 90 * omdy[43] - 30 * omdy[44]; phidy[p45[44]] = -30 * omdy[42] - 30 * omdy[43] + 90 * omdy[44]; @@ -2081,146 +1623,66 @@ namespace Fem2D { R3 phidz[45]; if (whatd & Fop_dz) { - phidz[p45[0]] = +9 * omdz[0] - 18 * omdz[1] + 3 * omdz[2] - 27 * omdz[30] + 12 * omdz[31] + - 9 * omdz[32] + 9 * omdz[33] - 6 * omdz[34] - 6 * omdz[35] - 27 * omdz[36] + - 12 * omdz[37] + 9 * omdz[38] + 9 * omdz[39] - 6 * omdz[40] - 6 * omdz[41] + - 18 * omdz[42] - 6 * omdz[43] - 6 * omdz[44]; - phidz[p45[1]] = -18 * omdz[0] + 84 * omdz[1] - 18 * omdz[2] - 6 * omdz[30] - 36 * omdz[31] + - 12 * omdz[32] - 30 * omdz[33] + 30 * omdz[34] - 6 * omdz[36] - - 36 * omdz[37] + 12 * omdz[38] - 30 * omdz[39] + 30 * omdz[40] + - 24 * omdz[42]; - phidz[p45[2]] = +3 * omdz[0] - 18 * omdz[1] + 9 * omdz[2] + 6 * omdz[30] - 18 * omdz[31] + - 3 * omdz[32] + 6 * omdz[33] - 9 * omdz[34] + 6 * omdz[35] + 6 * omdz[36] - - 18 * omdz[37] + 3 * omdz[38] + 6 * omdz[39] - 9 * omdz[40] + 6 * omdz[41] + - 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; - phidz[p45[3]] = +9 * omdz[3] - 18 * omdz[4] + 3 * omdz[5] - 27 * omdz[24] + 12 * omdz[25] + - 9 * omdz[26] + 9 * omdz[27] - 6 * omdz[28] - 6 * omdz[29] + 9 * omdz[36] - - 6 * omdz[37] - 6 * omdz[38] - 27 * omdz[39] + 9 * omdz[40] + 12 * omdz[41] - - 6 * omdz[42] + 18 * omdz[43] - 6 * omdz[44]; - phidz[p45[4]] = -18 * omdz[3] + 84 * omdz[4] - 18 * omdz[5] - 6 * omdz[24] - 36 * omdz[25] + - 12 * omdz[26] - 30 * omdz[27] + 30 * omdz[28] - 30 * omdz[36] + - 30 * omdz[38] - 6 * omdz[39] + 12 * omdz[40] - 36 * omdz[41] + - 24 * omdz[43]; - phidz[p45[5]] = +3 * omdz[3] - 18 * omdz[4] + 9 * omdz[5] + 6 * omdz[24] - 18 * omdz[25] + - 3 * omdz[26] + 6 * omdz[27] - 9 * omdz[28] + 6 * omdz[29] + 6 * omdz[36] + - 6 * omdz[37] - 9 * omdz[38] + 6 * omdz[39] + 3 * omdz[40] - 18 * omdz[41] + - 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; - phidz[p45[6]] = +9 * omdz[6] - 18 * omdz[7] + 3 * omdz[8] + 9 * omdz[24] - 6 * omdz[25] - - 6 * omdz[26] - 27 * omdz[27] + 9 * omdz[28] + 12 * omdz[29] + 9 * omdz[30] - - 6 * omdz[31] - 6 * omdz[32] - 27 * omdz[33] + 9 * omdz[34] + 12 * omdz[35] - - 6 * omdz[42] - 6 * omdz[43] + 18 * omdz[44]; - phidz[p45[7]] = -18 * omdz[6] + 84 * omdz[7] - 18 * omdz[8] - 30 * omdz[24] + - 30 * omdz[26] - 6 * omdz[27] + 12 * omdz[28] - 36 * omdz[29] - - 30 * omdz[30] + 30 * omdz[32] - 6 * omdz[33] + 12 * omdz[34] - - 36 * omdz[35] + 24 * omdz[44]; - phidz[p45[8]] = +3 * omdz[6] - 18 * omdz[7] + 9 * omdz[8] + 6 * omdz[24] + 6 * omdz[25] - - 9 * omdz[26] + 6 * omdz[27] + 3 * omdz[28] - 18 * omdz[29] + 6 * omdz[30] + - 6 * omdz[31] - 9 * omdz[32] + 6 * omdz[33] + 3 * omdz[34] - 18 * omdz[35] + - 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; - phidz[p45[9]] = +9 * omdz[9] - 18 * omdz[10] + 3 * omdz[11] - 27 * omdz[18] + - 12 * omdz[19] + 9 * omdz[20] + 9 * omdz[21] - 6 * omdz[22] - 6 * omdz[23] - - 3 * omdz[36] + 18 * omdz[37] - 6 * omdz[38] + 9 * omdz[39] - 27 * omdz[40] + - 12 * omdz[41] - 6 * omdz[42] + 18 * omdz[43] - 6 * omdz[44]; - phidz[p45[10]] = -18 * omdz[9] + 84 * omdz[10] - 18 * omdz[11] - 6 * omdz[18] - - 36 * omdz[19] + 12 * omdz[20] - 30 * omdz[21] + 30 * omdz[22] - - 12 * omdz[36] + 36 * omdz[37] + 6 * omdz[38] + 12 * omdz[39] - - 6 * omdz[40] - 36 * omdz[41] - 24 * omdz[42] + 24 * omdz[43]; - phidz[p45[11]] = +3 * omdz[9] - 18 * omdz[10] + 9 * omdz[11] + 6 * omdz[18] - - 18 * omdz[19] + 3 * omdz[20] + 6 * omdz[21] - 9 * omdz[22] + 6 * omdz[23] - - 9 * omdz[36] - 12 * omdz[37] + 27 * omdz[38] + 3 * omdz[39] + - 6 * omdz[40] - 18 * omdz[41] - 18 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; - phidz[p45[12]] = +9 * omdz[12] - 18 * omdz[13] + 3 * omdz[14] + 9 * omdz[18] - - 6 * omdz[19] - 6 * omdz[20] - 27 * omdz[21] + 9 * omdz[22] + - 12 * omdz[23] - 3 * omdz[30] + 18 * omdz[31] - 6 * omdz[32] + - 9 * omdz[33] - 27 * omdz[34] + 12 * omdz[35] - 6 * omdz[42] - - 6 * omdz[43] + 18 * omdz[44]; - phidz[p45[13]] = -18 * omdz[12] + 84 * omdz[13] - 18 * omdz[14] - 30 * omdz[18] + - 30 * omdz[20] - 6 * omdz[21] + 12 * omdz[22] - 36 * omdz[23] - - 12 * omdz[30] + 36 * omdz[31] + 6 * omdz[32] + 12 * omdz[33] - - 6 * omdz[34] - 36 * omdz[35] - 24 * omdz[42] + 24 * omdz[44]; - phidz[p45[14]] = +3 * omdz[12] - 18 * omdz[13] + 9 * omdz[14] + 6 * omdz[18] + - 6 * omdz[19] - 9 * omdz[20] + 6 * omdz[21] + 3 * omdz[22] - 18 * omdz[23] - - 9 * omdz[30] - 12 * omdz[31] + 27 * omdz[32] + 3 * omdz[33] + - 6 * omdz[34] - 18 * omdz[35] - 18 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; - phidz[p45[15]] = +9 * omdz[15] - 18 * omdz[16] + 3 * omdz[17] - 3 * omdz[18] + - 18 * omdz[19] - 6 * omdz[20] + 9 * omdz[21] - 27 * omdz[22] + - 12 * omdz[23] - 3 * omdz[24] + 18 * omdz[25] - 6 * omdz[26] + - 9 * omdz[27] - 27 * omdz[28] + 12 * omdz[29] - 6 * omdz[42] - - 6 * omdz[43] + 18 * omdz[44]; - phidz[p45[16]] = -18 * omdz[15] + 84 * omdz[16] - 18 * omdz[17] - 12 * omdz[18] + - 36 * omdz[19] + 6 * omdz[20] + 12 * omdz[21] - 6 * omdz[22] - - 36 * omdz[23] - 12 * omdz[24] + 36 * omdz[25] + 6 * omdz[26] + - 12 * omdz[27] - 6 * omdz[28] - 36 * omdz[29] - 24 * omdz[43] + - 24 * omdz[44]; - phidz[p45[17]] = +3 * omdz[15] - 18 * omdz[16] + 9 * omdz[17] - 9 * omdz[18] - - 12 * omdz[19] + 27 * omdz[20] + 3 * omdz[21] + 6 * omdz[22] - - 18 * omdz[23] - 9 * omdz[24] - 12 * omdz[25] + 27 * omdz[26] + - 3 * omdz[27] + 6 * omdz[28] - 18 * omdz[29] + 6 * omdz[42] - - 18 * omdz[43] + 6 * omdz[44]; - phidz[p45[18]] = +90 * omdz[18] - 30 * omdz[19] - 45 * omdz[20] - 30 * omdz[21] + - 15 * omdz[22] + 30 * omdz[23] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[19]] = -30 * omdz[18] + 120 * omdz[19] - 30 * omdz[20] + 30 * omdz[21] - - 60 * omdz[22] + 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; - phidz[p45[20]] = -45 * omdz[18] - 30 * omdz[19] + 90 * omdz[20] + 15 * omdz[21] + - 15 * omdz[22] - 60 * omdz[23] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[21]] = -30 * omdz[18] + 30 * omdz[19] + 15 * omdz[20] + 90 * omdz[21] - - 45 * omdz[22] - 30 * omdz[23] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[22]] = +15 * omdz[18] - 60 * omdz[19] + 15 * omdz[20] - 45 * omdz[21] + - 90 * omdz[22] - 30 * omdz[23] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[23]] = +30 * omdz[18] - 60 * omdz[20] - 30 * omdz[21] - 30 * omdz[22] + - 120 * omdz[23] + 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; - phidz[p45[24]] = +90 * omdz[24] - 30 * omdz[25] - 45 * omdz[26] - 30 * omdz[27] + - 15 * omdz[28] + 30 * omdz[29] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[25]] = -30 * omdz[24] + 120 * omdz[25] - 30 * omdz[26] + 30 * omdz[27] - - 60 * omdz[28] - 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; - phidz[p45[26]] = -45 * omdz[24] - 30 * omdz[25] + 90 * omdz[26] + 15 * omdz[27] + - 15 * omdz[28] - 60 * omdz[29] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[27]] = -30 * omdz[24] + 30 * omdz[25] + 15 * omdz[26] + 90 * omdz[27] - - 45 * omdz[28] - 30 * omdz[29] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[28]] = +15 * omdz[24] - 60 * omdz[25] + 15 * omdz[26] - 45 * omdz[27] + - 90 * omdz[28] - 30 * omdz[29] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[29]] = +30 * omdz[24] - 60 * omdz[26] - 30 * omdz[27] - 30 * omdz[28] + - 120 * omdz[29] - 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; - phidz[p45[30]] = +90 * omdz[30] - 30 * omdz[31] - 45 * omdz[32] - 30 * omdz[33] + - 15 * omdz[34] + 30 * omdz[35] - 45 * omdz[42] + 15 * omdz[43] + - 15 * omdz[44]; - phidz[p45[31]] = -30 * omdz[30] + 120 * omdz[31] - 30 * omdz[32] + 30 * omdz[33] - - 60 * omdz[34] - 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; - phidz[p45[32]] = -45 * omdz[30] - 30 * omdz[31] + 90 * omdz[32] + 15 * omdz[33] + - 15 * omdz[34] - 60 * omdz[35] - 45 * omdz[42] + 15 * omdz[43] + - 15 * omdz[44]; - phidz[p45[33]] = -30 * omdz[30] + 30 * omdz[31] + 15 * omdz[32] + 90 * omdz[33] - - 45 * omdz[34] - 30 * omdz[35] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[34]] = +15 * omdz[30] - 60 * omdz[31] + 15 * omdz[32] - 45 * omdz[33] + - 90 * omdz[34] - 30 * omdz[35] + 15 * omdz[42] + 15 * omdz[43] - - 45 * omdz[44]; - phidz[p45[35]] = +30 * omdz[30] - 60 * omdz[32] - 30 * omdz[33] - 30 * omdz[34] + - 120 * omdz[35] + 30 * omdz[42] - 30 * omdz[43] - 30 * omdz[44]; - phidz[p45[36]] = +90 * omdz[36] - 30 * omdz[37] - 45 * omdz[38] - 30 * omdz[39] + - 15 * omdz[40] + 30 * omdz[41] - 45 * omdz[42] + 15 * omdz[43] + - 15 * omdz[44]; - phidz[p45[37]] = -30 * omdz[36] + 120 * omdz[37] - 30 * omdz[38] + 30 * omdz[39] - - 60 * omdz[40] - 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; - phidz[p45[38]] = -45 * omdz[36] - 30 * omdz[37] + 90 * omdz[38] + 15 * omdz[39] + - 15 * omdz[40] - 60 * omdz[41] - 45 * omdz[42] + 15 * omdz[43] + - 15 * omdz[44]; - phidz[p45[39]] = -30 * omdz[36] + 30 * omdz[37] + 15 * omdz[38] + 90 * omdz[39] - - 45 * omdz[40] - 30 * omdz[41] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[40]] = +15 * omdz[36] - 60 * omdz[37] + 15 * omdz[38] - 45 * omdz[39] + - 90 * omdz[40] - 30 * omdz[41] + 15 * omdz[42] - 45 * omdz[43] + - 15 * omdz[44]; - phidz[p45[41]] = +30 * omdz[36] - 60 * omdz[38] - 30 * omdz[39] - 30 * omdz[40] + - 120 * omdz[41] + 30 * omdz[42] - 30 * omdz[43] - 30 * omdz[44]; + phidz[p45[0]] = +9 * omdz[0] - 18 * omdz[1] + 3 * omdz[2] - 27 * omdz[30] + 12 * omdz[31] + 9 * omdz[32] + 9 * omdz[33] - 6 * omdz[34] - 6 * omdz[35] - 27 * omdz[36] + 12 * omdz[37] + + 9 * omdz[38] + 9 * omdz[39] - 6 * omdz[40] - 6 * omdz[41] + 18 * omdz[42] - 6 * omdz[43] - 6 * omdz[44]; + phidz[p45[1]] = -18 * omdz[0] + 84 * omdz[1] - 18 * omdz[2] - 6 * omdz[30] - 36 * omdz[31] + 12 * omdz[32] - 30 * omdz[33] + 30 * omdz[34] - 6 * omdz[36] - 36 * omdz[37] + 12 * omdz[38] - + 30 * omdz[39] + 30 * omdz[40] + 24 * omdz[42]; + phidz[p45[2]] = +3 * omdz[0] - 18 * omdz[1] + 9 * omdz[2] + 6 * omdz[30] - 18 * omdz[31] + 3 * omdz[32] + 6 * omdz[33] - 9 * omdz[34] + 6 * omdz[35] + 6 * omdz[36] - 18 * omdz[37] + + 3 * omdz[38] + 6 * omdz[39] - 9 * omdz[40] + 6 * omdz[41] + 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; + phidz[p45[3]] = +9 * omdz[3] - 18 * omdz[4] + 3 * omdz[5] - 27 * omdz[24] + 12 * omdz[25] + 9 * omdz[26] + 9 * omdz[27] - 6 * omdz[28] - 6 * omdz[29] + 9 * omdz[36] - 6 * omdz[37] - + 6 * omdz[38] - 27 * omdz[39] + 9 * omdz[40] + 12 * omdz[41] - 6 * omdz[42] + 18 * omdz[43] - 6 * omdz[44]; + phidz[p45[4]] = -18 * omdz[3] + 84 * omdz[4] - 18 * omdz[5] - 6 * omdz[24] - 36 * omdz[25] + 12 * omdz[26] - 30 * omdz[27] + 30 * omdz[28] - 30 * omdz[36] + 30 * omdz[38] - 6 * omdz[39] + + 12 * omdz[40] - 36 * omdz[41] + 24 * omdz[43]; + phidz[p45[5]] = +3 * omdz[3] - 18 * omdz[4] + 9 * omdz[5] + 6 * omdz[24] - 18 * omdz[25] + 3 * omdz[26] + 6 * omdz[27] - 9 * omdz[28] + 6 * omdz[29] + 6 * omdz[36] + 6 * omdz[37] - + 9 * omdz[38] + 6 * omdz[39] + 3 * omdz[40] - 18 * omdz[41] + 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; + phidz[p45[6]] = +9 * omdz[6] - 18 * omdz[7] + 3 * omdz[8] + 9 * omdz[24] - 6 * omdz[25] - 6 * omdz[26] - 27 * omdz[27] + 9 * omdz[28] + 12 * omdz[29] + 9 * omdz[30] - 6 * omdz[31] - + 6 * omdz[32] - 27 * omdz[33] + 9 * omdz[34] + 12 * omdz[35] - 6 * omdz[42] - 6 * omdz[43] + 18 * omdz[44]; + phidz[p45[7]] = -18 * omdz[6] + 84 * omdz[7] - 18 * omdz[8] - 30 * omdz[24] + 30 * omdz[26] - 6 * omdz[27] + 12 * omdz[28] - 36 * omdz[29] - 30 * omdz[30] + 30 * omdz[32] - 6 * omdz[33] + + 12 * omdz[34] - 36 * omdz[35] + 24 * omdz[44]; + phidz[p45[8]] = +3 * omdz[6] - 18 * omdz[7] + 9 * omdz[8] + 6 * omdz[24] + 6 * omdz[25] - 9 * omdz[26] + 6 * omdz[27] + 3 * omdz[28] - 18 * omdz[29] + 6 * omdz[30] + 6 * omdz[31] - + 9 * omdz[32] + 6 * omdz[33] + 3 * omdz[34] - 18 * omdz[35] + 6 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; + phidz[p45[9]] = +9 * omdz[9] - 18 * omdz[10] + 3 * omdz[11] - 27 * omdz[18] + 12 * omdz[19] + 9 * omdz[20] + 9 * omdz[21] - 6 * omdz[22] - 6 * omdz[23] - 3 * omdz[36] + 18 * omdz[37] - + 6 * omdz[38] + 9 * omdz[39] - 27 * omdz[40] + 12 * omdz[41] - 6 * omdz[42] + 18 * omdz[43] - 6 * omdz[44]; + phidz[p45[10]] = -18 * omdz[9] + 84 * omdz[10] - 18 * omdz[11] - 6 * omdz[18] - 36 * omdz[19] + 12 * omdz[20] - 30 * omdz[21] + 30 * omdz[22] - 12 * omdz[36] + 36 * omdz[37] + 6 * omdz[38] + + 12 * omdz[39] - 6 * omdz[40] - 36 * omdz[41] - 24 * omdz[42] + 24 * omdz[43]; + phidz[p45[11]] = +3 * omdz[9] - 18 * omdz[10] + 9 * omdz[11] + 6 * omdz[18] - 18 * omdz[19] + 3 * omdz[20] + 6 * omdz[21] - 9 * omdz[22] + 6 * omdz[23] - 9 * omdz[36] - 12 * omdz[37] + + 27 * omdz[38] + 3 * omdz[39] + 6 * omdz[40] - 18 * omdz[41] - 18 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; + phidz[p45[12]] = +9 * omdz[12] - 18 * omdz[13] + 3 * omdz[14] + 9 * omdz[18] - 6 * omdz[19] - 6 * omdz[20] - 27 * omdz[21] + 9 * omdz[22] + 12 * omdz[23] - 3 * omdz[30] + 18 * omdz[31] - + 6 * omdz[32] + 9 * omdz[33] - 27 * omdz[34] + 12 * omdz[35] - 6 * omdz[42] - 6 * omdz[43] + 18 * omdz[44]; + phidz[p45[13]] = -18 * omdz[12] + 84 * omdz[13] - 18 * omdz[14] - 30 * omdz[18] + 30 * omdz[20] - 6 * omdz[21] + 12 * omdz[22] - 36 * omdz[23] - 12 * omdz[30] + 36 * omdz[31] + 6 * omdz[32] + + 12 * omdz[33] - 6 * omdz[34] - 36 * omdz[35] - 24 * omdz[42] + 24 * omdz[44]; + phidz[p45[14]] = +3 * omdz[12] - 18 * omdz[13] + 9 * omdz[14] + 6 * omdz[18] + 6 * omdz[19] - 9 * omdz[20] + 6 * omdz[21] + 3 * omdz[22] - 18 * omdz[23] - 9 * omdz[30] - 12 * omdz[31] + + 27 * omdz[32] + 3 * omdz[33] + 6 * omdz[34] - 18 * omdz[35] - 18 * omdz[42] + 6 * omdz[43] + 6 * omdz[44]; + phidz[p45[15]] = +9 * omdz[15] - 18 * omdz[16] + 3 * omdz[17] - 3 * omdz[18] + 18 * omdz[19] - 6 * omdz[20] + 9 * omdz[21] - 27 * omdz[22] + 12 * omdz[23] - 3 * omdz[24] + 18 * omdz[25] - + 6 * omdz[26] + 9 * omdz[27] - 27 * omdz[28] + 12 * omdz[29] - 6 * omdz[42] - 6 * omdz[43] + 18 * omdz[44]; + phidz[p45[16]] = -18 * omdz[15] + 84 * omdz[16] - 18 * omdz[17] - 12 * omdz[18] + 36 * omdz[19] + 6 * omdz[20] + 12 * omdz[21] - 6 * omdz[22] - 36 * omdz[23] - 12 * omdz[24] + 36 * omdz[25] + + 6 * omdz[26] + 12 * omdz[27] - 6 * omdz[28] - 36 * omdz[29] - 24 * omdz[43] + 24 * omdz[44]; + phidz[p45[17]] = +3 * omdz[15] - 18 * omdz[16] + 9 * omdz[17] - 9 * omdz[18] - 12 * omdz[19] + 27 * omdz[20] + 3 * omdz[21] + 6 * omdz[22] - 18 * omdz[23] - 9 * omdz[24] - 12 * omdz[25] + + 27 * omdz[26] + 3 * omdz[27] + 6 * omdz[28] - 18 * omdz[29] + 6 * omdz[42] - 18 * omdz[43] + 6 * omdz[44]; + phidz[p45[18]] = +90 * omdz[18] - 30 * omdz[19] - 45 * omdz[20] - 30 * omdz[21] + 15 * omdz[22] + 30 * omdz[23] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[19]] = -30 * omdz[18] + 120 * omdz[19] - 30 * omdz[20] + 30 * omdz[21] - 60 * omdz[22] + 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; + phidz[p45[20]] = -45 * omdz[18] - 30 * omdz[19] + 90 * omdz[20] + 15 * omdz[21] + 15 * omdz[22] - 60 * omdz[23] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[21]] = -30 * omdz[18] + 30 * omdz[19] + 15 * omdz[20] + 90 * omdz[21] - 45 * omdz[22] - 30 * omdz[23] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[22]] = +15 * omdz[18] - 60 * omdz[19] + 15 * omdz[20] - 45 * omdz[21] + 90 * omdz[22] - 30 * omdz[23] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[23]] = +30 * omdz[18] - 60 * omdz[20] - 30 * omdz[21] - 30 * omdz[22] + 120 * omdz[23] + 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; + phidz[p45[24]] = +90 * omdz[24] - 30 * omdz[25] - 45 * omdz[26] - 30 * omdz[27] + 15 * omdz[28] + 30 * omdz[29] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[25]] = -30 * omdz[24] + 120 * omdz[25] - 30 * omdz[26] + 30 * omdz[27] - 60 * omdz[28] - 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; + phidz[p45[26]] = -45 * omdz[24] - 30 * omdz[25] + 90 * omdz[26] + 15 * omdz[27] + 15 * omdz[28] - 60 * omdz[29] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[27]] = -30 * omdz[24] + 30 * omdz[25] + 15 * omdz[26] + 90 * omdz[27] - 45 * omdz[28] - 30 * omdz[29] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[28]] = +15 * omdz[24] - 60 * omdz[25] + 15 * omdz[26] - 45 * omdz[27] + 90 * omdz[28] - 30 * omdz[29] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[29]] = +30 * omdz[24] - 60 * omdz[26] - 30 * omdz[27] - 30 * omdz[28] + 120 * omdz[29] - 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; + phidz[p45[30]] = +90 * omdz[30] - 30 * omdz[31] - 45 * omdz[32] - 30 * omdz[33] + 15 * omdz[34] + 30 * omdz[35] - 45 * omdz[42] + 15 * omdz[43] + 15 * omdz[44]; + phidz[p45[31]] = -30 * omdz[30] + 120 * omdz[31] - 30 * omdz[32] + 30 * omdz[33] - 60 * omdz[34] - 30 * omdz[42] - 30 * omdz[43] + 30 * omdz[44]; + phidz[p45[32]] = -45 * omdz[30] - 30 * omdz[31] + 90 * omdz[32] + 15 * omdz[33] + 15 * omdz[34] - 60 * omdz[35] - 45 * omdz[42] + 15 * omdz[43] + 15 * omdz[44]; + phidz[p45[33]] = -30 * omdz[30] + 30 * omdz[31] + 15 * omdz[32] + 90 * omdz[33] - 45 * omdz[34] - 30 * omdz[35] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[34]] = +15 * omdz[30] - 60 * omdz[31] + 15 * omdz[32] - 45 * omdz[33] + 90 * omdz[34] - 30 * omdz[35] + 15 * omdz[42] + 15 * omdz[43] - 45 * omdz[44]; + phidz[p45[35]] = +30 * omdz[30] - 60 * omdz[32] - 30 * omdz[33] - 30 * omdz[34] + 120 * omdz[35] + 30 * omdz[42] - 30 * omdz[43] - 30 * omdz[44]; + phidz[p45[36]] = +90 * omdz[36] - 30 * omdz[37] - 45 * omdz[38] - 30 * omdz[39] + 15 * omdz[40] + 30 * omdz[41] - 45 * omdz[42] + 15 * omdz[43] + 15 * omdz[44]; + phidz[p45[37]] = -30 * omdz[36] + 120 * omdz[37] - 30 * omdz[38] + 30 * omdz[39] - 60 * omdz[40] - 30 * omdz[42] + 30 * omdz[43] - 30 * omdz[44]; + phidz[p45[38]] = -45 * omdz[36] - 30 * omdz[37] + 90 * omdz[38] + 15 * omdz[39] + 15 * omdz[40] - 60 * omdz[41] - 45 * omdz[42] + 15 * omdz[43] + 15 * omdz[44]; + phidz[p45[39]] = -30 * omdz[36] + 30 * omdz[37] + 15 * omdz[38] + 90 * omdz[39] - 45 * omdz[40] - 30 * omdz[41] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[40]] = +15 * omdz[36] - 60 * omdz[37] + 15 * omdz[38] - 45 * omdz[39] + 90 * omdz[40] - 30 * omdz[41] + 15 * omdz[42] - 45 * omdz[43] + 15 * omdz[44]; + phidz[p45[41]] = +30 * omdz[36] - 60 * omdz[38] - 30 * omdz[39] - 30 * omdz[40] + 120 * omdz[41] + 30 * omdz[42] - 30 * omdz[43] - 30 * omdz[44]; phidz[p45[42]] = +90 * omdz[42] - 30 * omdz[43] - 30 * omdz[44]; phidz[p45[43]] = -30 * omdz[42] + 90 * omdz[43] - 30 * omdz[44]; phidz[p45[44]] = -30 * omdz[42] - 30 * omdz[43] + 90 * omdz[44]; @@ -2247,72 +1709,48 @@ namespace Fem2D { int i0 = perm[ii0]; int i1 = perm[ii1]; if (whatd & Fop_dxx) { - omdxx[i * 3] = 2 * D[i0].x * D[i0].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i0].x * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxx[i * 3 + 1] = - 2 * D[i0].x * D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxx[i * 3 + 2] = 2 * D[i1].x * D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i1].x * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[i * 3] = 2 * D[i0].x * D[i0].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i0].x * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[i * 3 + 1] = 2 * D[i0].x * D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[i * 3 + 2] = 2 * D[i1].x * D[i1].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i1].x * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dyy) { - omdyy[i * 3] = 2 * D[i0].y * D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i0].y * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyy[i * 3 + 1] = - 2 * D[i0].y * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyy[i * 3 + 2] = 2 * D[i1].y * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i1].y * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[i * 3] = 2 * D[i0].y * D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i0].y * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[i * 3 + 1] = 2 * D[i0].y * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[i * 3 + 2] = 2 * D[i1].y * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i1].y * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); } if (whatd & Fop_dzz) { - omdzz[i * 3] = 2 * D[i0].z * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i0].z * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdzz[i * 3 + 1] = - 2 * D[i0].z * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdzz[i * 3 + 2] = 2 * D[i1].z * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 4 * D[i1].z * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[i * 3] = 2 * D[i0].z * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i0].z * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[i * 3 + 1] = 2 * D[i0].z * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[i * 3 + 2] = 2 * D[i1].z * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 4 * D[i1].z * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]); } if (whatd & Fop_dxy) { - omdxy[i * 3] = 2 * D[i0].x * D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i0].x * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - 2 * D[i0].y * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxy[i * 3 + 1] = - (D[i0].x * D[i1].y + D[i0].y * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxy[i * 3 + 2] = 2 * D[i1].x * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i1].x * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - 2 * D[i1].y * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[i * 3] = + 2 * D[i0].x * D[i0].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i0].x * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]) + 2 * D[i0].y * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[i * 3 + 1] = (D[i0].x * D[i1].y + D[i0].y * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + + (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[i * 3 + 2] = + 2 * D[i1].x * D[i1].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i1].x * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]) + 2 * D[i1].y * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dxz) { - omdxz[i * 3] = 2 * D[i0].x * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i0].x * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - 2 * D[i0].z * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxz[i * 3 + 1] = - (D[i0].x * D[i1].z + D[i0].z * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxz[i * 3 + 2] = 2 * D[i1].x * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i1].x * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - 2 * D[i1].z * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[i * 3] = + 2 * D[i0].x * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i0].x * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + 2 * D[i0].z * l[i0] * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[i * 3 + 1] = (D[i0].x * D[i1].z + D[i0].z * D[i1].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[i * 3 + 2] = + 2 * D[i1].x * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i1].x * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + 2 * D[i1].z * l[i1] * (D[i0].x * D[i1] - D[i1].x * D[i0]); } if (whatd & Fop_dyz) { - omdyz[i * 3] = 2 * D[i0].y * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i0].y * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - 2 * D[i0].z * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyz[i * 3 + 1] = - (D[i0].y * D[i1].z + D[i0].z * D[i1].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyz[i * 3 + 2] = 2 * D[i1].y * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * D[i1].y * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - 2 * D[i1].z * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[i * 3] = + 2 * D[i0].y * D[i0].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i0].y * l[i0] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + 2 * D[i0].z * l[i0] * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[i * 3 + 1] = (D[i0].y * D[i1].z + D[i0].z * D[i1].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[i * 3 + 2] = + 2 * D[i1].y * D[i1].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * D[i1].y * l[i1] * (D[i0].z * D[i1] - D[i1].z * D[i0]) + 2 * D[i1].z * l[i1] * (D[i0].y * D[i1] - D[i1].y * D[i0]); } } @@ -2325,416 +1763,210 @@ namespace Fem2D { int i1 = perm[ii1]; int i2 = perm[ii2]; if (whatd & Fop_dxx) { - omdxx[18 + j * 6] = - 2 * D[i0].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxx[18 + j * 6 + 1] = - 2 * D[i1].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxx[18 + j * 6 + 2] = - 2 * D[i2].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxx[18 + j * 6 + 3] = - 2 * D[i0].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxx[18 + j * 6 + 4] = - 2 * D[i1].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxx[18 + j * 6 + 5] = - 2 * D[i2].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxx[18 + j * 6] = 2 * D[i0].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[18 + j * 6 + 1] = 2 * D[i1].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[18 + j * 6 + 2] = 2 * D[i2].x * D[i2].x * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxx[18 + j * 6 + 3] = 2 * D[i0].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxx[18 + j * 6 + 4] = 2 * D[i1].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxx[18 + j * 6 + 5] = 2 * D[i2].x * D[i1].x * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dyy) { - omdyy[18 + j * 6] = - 2 * D[i0].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyy[18 + j * 6 + 1] = - 2 * D[i1].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyy[18 + j * 6 + 2] = - 2 * D[i2].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyy[18 + j * 6 + 3] = - 2 * D[i0].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdyy[18 + j * 6 + 4] = - 2 * D[i1].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdyy[18 + j * 6 + 5] = - 2 * D[i2].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyy[18 + j * 6] = 2 * D[i0].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[18 + j * 6 + 1] = 2 * D[i1].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[18 + j * 6 + 2] = 2 * D[i2].y * D[i2].y * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyy[18 + j * 6 + 3] = 2 * D[i0].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyy[18 + j * 6 + 4] = 2 * D[i1].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyy[18 + j * 6 + 5] = 2 * D[i2].y * D[i1].y * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].y * D[i2] - D[i2].y * D[i0]); } if (whatd & Fop_dzz) { - omdzz[18 + j * 6] = - 2 * D[i0].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdzz[18 + j * 6 + 1] = - 2 * D[i1].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdzz[18 + j * 6 + 2] = - 2 * D[i2].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + - 2 * (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); - omdzz[18 + j * 6 + 3] = - 2 * D[i0].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); - omdzz[18 + j * 6 + 4] = - 2 * D[i1].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); - omdzz[18 + j * 6 + 5] = - 2 * D[i2].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + - 2 * (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdzz[18 + j * 6] = 2 * D[i0].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[18 + j * 6 + 1] = 2 * D[i1].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[18 + j * 6 + 2] = 2 * D[i2].z * D[i2].z * (l[i0] * D[i1] - l[i1] * D[i0]) + 2 * (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].z * D[i1] - D[i1].z * D[i0]); + omdzz[18 + j * 6 + 3] = 2 * D[i0].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdzz[18 + j * 6 + 4] = 2 * D[i1].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); + omdzz[18 + j * 6 + 5] = 2 * D[i2].z * D[i1].z * (l[i0] * D[i2] - l[i2] * D[i0]) + 2 * (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].z * D[i2] - D[i2].z * D[i0]); } if (whatd & Fop_dxy) { - omdxy[18 + j * 6] = - (D[i0].x * D[i2].y + D[i0].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxy[18 + j * 6 + 1] = - (D[i1].x * D[i2].y + D[i1].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxy[18 + j * 6 + 2] = - (D[i2].x * D[i2].y + D[i2].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + - (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxy[18 + j * 6 + 3] = - (D[i0].x * D[i1].y + D[i0].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + - (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxy[18 + j * 6 + 4] = - (D[i1].x * D[i1].y + D[i1].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + - (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxy[18 + j * 6 + 5] = - (D[i2].x * D[i1].y + D[i2].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + - (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxy[18 + j * 6] = (D[i0].x * D[i2].y + D[i0].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + + (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[18 + j * 6 + 1] = (D[i1].x * D[i2].y + D[i1].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + + (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[18 + j * 6 + 2] = (D[i2].x * D[i2].y + D[i2].y * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].y * D[i1] - D[i1].y * D[i0]) + + (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxy[18 + j * 6 + 3] = (D[i0].x * D[i1].y + D[i0].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + + (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxy[18 + j * 6 + 4] = (D[i1].x * D[i1].y + D[i1].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + + (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxy[18 + j * 6 + 5] = (D[i2].x * D[i1].y + D[i2].y * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].y * D[i2] - D[i2].y * D[i0]) + + (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dxz) { - omdxz[18 + j * 6] = - (D[i0].x * D[i2].z + D[i0].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxz[18 + j * 6 + 1] = - (D[i1].x * D[i2].z + D[i1].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxz[18 + j * 6 + 2] = - (D[i2].x * D[i2].z + D[i2].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); - omdxz[18 + j * 6 + 3] = - (D[i0].x * D[i1].z + D[i0].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxz[18 + j * 6 + 4] = - (D[i1].x * D[i1].z + D[i1].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); - omdxz[18 + j * 6 + 5] = - (D[i2].x * D[i1].z + D[i2].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxz[18 + j * 6] = (D[i0].x * D[i2].z + D[i0].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].x * l[i2] + l[i0] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[18 + j * 6 + 1] = (D[i1].x * D[i2].z + D[i1].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i1].x * l[i2] + l[i1] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[18 + j * 6 + 2] = (D[i2].x * D[i2].z + D[i2].z * D[i2].x) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i2].x * l[i2] + l[i2] * D[i2].x) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].x * D[i1] - D[i1].x * D[i0]); + omdxz[18 + j * 6 + 3] = (D[i0].x * D[i1].z + D[i0].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i0].x * l[i1] + l[i0] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxz[18 + j * 6 + 4] = (D[i1].x * D[i1].z + D[i1].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i1].x * l[i1] + l[i1] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); + omdxz[18 + j * 6 + 5] = (D[i2].x * D[i1].z + D[i2].z * D[i1].x) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i2].x * l[i1] + l[i2] * D[i1].x) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].x * D[i2] - D[i2].x * D[i0]); } if (whatd & Fop_dyz) { - omdyz[18 + j * 6] = - (D[i0].y * D[i2].z + D[i0].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyz[18 + j * 6 + 1] = - (D[i1].y * D[i2].z + D[i1].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyz[18 + j * 6 + 2] = - (D[i2].y * D[i2].z + D[i2].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + - (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + - (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); - omdyz[18 + j * 6 + 3] = - (D[i0].y * D[i1].z + D[i0].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdyz[18 + j * 6 + 4] = - (D[i1].y * D[i1].z + D[i1].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); - omdyz[18 + j * 6 + 5] = - (D[i2].y * D[i1].z + D[i2].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + - (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + - (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyz[18 + j * 6] = (D[i0].y * D[i2].z + D[i0].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i0].y * l[i2] + l[i0] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i0].z * l[i2] + l[i0] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[18 + j * 6 + 1] = (D[i1].y * D[i2].z + D[i1].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i1].y * l[i2] + l[i1] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i1].z * l[i2] + l[i1] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[18 + j * 6 + 2] = (D[i2].y * D[i2].z + D[i2].z * D[i2].y) * (l[i0] * D[i1] - l[i1] * D[i0]) + (D[i2].y * l[i2] + l[i2] * D[i2].y) * (D[i0].z * D[i1] - D[i1].z * D[i0]) + + (D[i2].z * l[i2] + l[i2] * D[i2].z) * (D[i0].y * D[i1] - D[i1].y * D[i0]); + omdyz[18 + j * 6 + 3] = (D[i0].y * D[i1].z + D[i0].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i0].y * l[i1] + l[i0] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i0].z * l[i1] + l[i0] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyz[18 + j * 6 + 4] = (D[i1].y * D[i1].z + D[i1].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i1].y * l[i1] + l[i1] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i1].z * l[i1] + l[i1] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); + omdyz[18 + j * 6 + 5] = (D[i2].y * D[i1].z + D[i2].z * D[i1].y) * (l[i0] * D[i2] - l[i2] * D[i0]) + (D[i2].y * l[i1] + l[i2] * D[i1].y) * (D[i0].z * D[i2] - D[i2].z * D[i0]) + + (D[i2].z * l[i1] + l[i2] * D[i1].z) * (D[i0].y * D[i2] - D[i2].y * D[i0]); } } // 3 volume functions if (whatd & Fop_dxx) { - omdxx[42] = - 2 * D[perm[2]].x * D[perm[3]].x * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - 2 * (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * - (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); - omdxx[43] = - 2 * D[perm[1]].x * D[perm[3]].x * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - 2 * (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * - (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); - omdxx[44] = - 2 * D[perm[1]].x * D[perm[2]].x * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - 2 * (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * - (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); + omdxx[42] = 2 * D[perm[2]].x * D[perm[3]].x * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + 2 * (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); + omdxx[43] = 2 * D[perm[1]].x * D[perm[3]].x * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + 2 * (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); + omdxx[44] = 2 * D[perm[1]].x * D[perm[2]].x * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + 2 * (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); } if (whatd & Fop_dyy) { - omdyy[42] = - 2 * D[perm[2]].y * D[perm[3]].y * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - 2 * (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * - (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); - omdyy[43] = - 2 * D[perm[1]].y * D[perm[3]].y * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - 2 * (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * - (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); - omdyy[44] = - 2 * D[perm[1]].y * D[perm[2]].y * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - 2 * (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * - (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); + omdyy[42] = 2 * D[perm[2]].y * D[perm[3]].y * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + 2 * (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); + omdyy[43] = 2 * D[perm[1]].y * D[perm[3]].y * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + 2 * (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); + omdyy[44] = 2 * D[perm[1]].y * D[perm[2]].y * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + 2 * (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); } if (whatd & Fop_dzz) { - omdzz[42] = - 2 * D[perm[2]].z * D[perm[3]].z * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - 2 * (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * - (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]); - omdzz[43] = - 2 * D[perm[1]].z * D[perm[3]].z * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - 2 * (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * - (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]); - omdzz[44] = - 2 * D[perm[1]].z * D[perm[2]].z * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - 2 * (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * - (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]); + omdzz[42] = 2 * D[perm[2]].z * D[perm[3]].z * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + 2 * (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]); + omdzz[43] = 2 * D[perm[1]].z * D[perm[3]].z * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + 2 * (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]); + omdzz[44] = 2 * D[perm[1]].z * D[perm[2]].z * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + 2 * (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]); } if (whatd & Fop_dxy) { - omdxy[42] = (D[perm[2]].x * D[perm[3]].y + D[perm[2]].y * D[perm[3]].x) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * - (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]) + - (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * - (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); - - omdxy[43] = (D[perm[1]].x * D[perm[3]].y + D[perm[1]].y * D[perm[3]].x) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * - (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]) + - (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * - (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); - - omdxy[44] = (D[perm[1]].x * D[perm[2]].y + D[perm[1]].y * D[perm[2]].x) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * - (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]) + - (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * - (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); + omdxy[42] = (D[perm[2]].x * D[perm[3]].y + D[perm[2]].y * D[perm[3]].x) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]) + + (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); + + omdxy[43] = (D[perm[1]].x * D[perm[3]].y + D[perm[1]].y * D[perm[3]].x) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]) + + (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); + + omdxy[44] = (D[perm[1]].x * D[perm[2]].y + D[perm[1]].y * D[perm[2]].x) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]) + + (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); } if (whatd & Fop_dxz) { - omdxz[42] = (D[perm[2]].x * D[perm[3]].z + D[perm[2]].z * D[perm[3]].x) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * - (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]) + - (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * - (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); - - omdxz[43] = (D[perm[1]].x * D[perm[3]].z + D[perm[1]].z * D[perm[3]].x) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * - (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]) + - (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * - (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); - - omdxz[44] = (D[perm[1]].x * D[perm[2]].z + D[perm[1]].z * D[perm[2]].x) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * - (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]) + - (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * - (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); + omdxz[42] = (D[perm[2]].x * D[perm[3]].z + D[perm[2]].z * D[perm[3]].x) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + (D[perm[2]].x * l[perm[3]] + l[perm[2]] * D[perm[3]].x) * (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]) + + (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * (D[perm[0]].x * D[perm[1]] - D[perm[1]].x * D[perm[0]]); + + omdxz[43] = (D[perm[1]].x * D[perm[3]].z + D[perm[1]].z * D[perm[3]].x) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + (D[perm[1]].x * l[perm[3]] + l[perm[1]] * D[perm[3]].x) * (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]) + + (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * (D[perm[0]].x * D[perm[2]] - D[perm[2]].x * D[perm[0]]); + + omdxz[44] = (D[perm[1]].x * D[perm[2]].z + D[perm[1]].z * D[perm[2]].x) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + (D[perm[1]].x * l[perm[2]] + l[perm[1]] * D[perm[2]].x) * (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]) + + (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * (D[perm[0]].x * D[perm[3]] - D[perm[3]].x * D[perm[0]]); } if (whatd & Fop_dyz) { - omdyz[42] = (D[perm[2]].y * D[perm[3]].z + D[perm[2]].z * D[perm[3]].y) * - (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + - (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * - (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]) + - (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * - (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); - - omdyz[43] = (D[perm[1]].y * D[perm[3]].z + D[perm[1]].z * D[perm[3]].y) * - (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + - (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * - (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]) + - (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * - (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); - - omdyz[44] = (D[perm[1]].y * D[perm[2]].z + D[perm[1]].z * D[perm[2]].y) * - (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + - (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * - (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]) + - (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * - (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); + omdyz[42] = (D[perm[2]].y * D[perm[3]].z + D[perm[2]].z * D[perm[3]].y) * (l[perm[0]] * D[perm[1]] - l[perm[1]] * D[perm[0]]) + + (D[perm[2]].y * l[perm[3]] + l[perm[2]] * D[perm[3]].y) * (D[perm[0]].z * D[perm[1]] - D[perm[1]].z * D[perm[0]]) + + (D[perm[2]].z * l[perm[3]] + l[perm[2]] * D[perm[3]].z) * (D[perm[0]].y * D[perm[1]] - D[perm[1]].y * D[perm[0]]); + + omdyz[43] = (D[perm[1]].y * D[perm[3]].z + D[perm[1]].z * D[perm[3]].y) * (l[perm[0]] * D[perm[2]] - l[perm[2]] * D[perm[0]]) + + (D[perm[1]].y * l[perm[3]] + l[perm[1]] * D[perm[3]].y) * (D[perm[0]].z * D[perm[2]] - D[perm[2]].z * D[perm[0]]) + + (D[perm[1]].z * l[perm[3]] + l[perm[1]] * D[perm[3]].z) * (D[perm[0]].y * D[perm[2]] - D[perm[2]].y * D[perm[0]]); + + omdyz[44] = (D[perm[1]].y * D[perm[2]].z + D[perm[1]].z * D[perm[2]].y) * (l[perm[0]] * D[perm[3]] - l[perm[3]] * D[perm[0]]) + + (D[perm[1]].y * l[perm[2]] + l[perm[1]] * D[perm[2]].y) * (D[perm[0]].z * D[perm[3]] - D[perm[3]].z * D[perm[0]]) + + (D[perm[1]].z * l[perm[2]] + l[perm[1]] * D[perm[2]].z) * (D[perm[0]].y * D[perm[3]] - D[perm[3]].y * D[perm[0]]); } R3 phidxx[45]; if (whatd & Fop_dxx) { - phidxx[p45[0]] = +9 * omdxx[0] - 18 * omdxx[1] + 3 * omdxx[2] - 27 * omdxx[30] + - 12 * omdxx[31] + 9 * omdxx[32] + 9 * omdxx[33] - 6 * omdxx[34] - - 6 * omdxx[35] - 27 * omdxx[36] + 12 * omdxx[37] + 9 * omdxx[38] + - 9 * omdxx[39] - 6 * omdxx[40] - 6 * omdxx[41] + 18 * omdxx[42] - - 6 * omdxx[43] - 6 * omdxx[44]; - phidxx[p45[1]] = -18 * omdxx[0] + 84 * omdxx[1] - 18 * omdxx[2] - 6 * omdxx[30] - - 36 * omdxx[31] + 12 * omdxx[32] - 30 * omdxx[33] + 30 * omdxx[34] - - 6 * omdxx[36] - 36 * omdxx[37] + 12 * omdxx[38] - 30 * omdxx[39] + - 30 * omdxx[40] + 24 * omdxx[42]; - phidxx[p45[2]] = +3 * omdxx[0] - 18 * omdxx[1] + 9 * omdxx[2] + 6 * omdxx[30] - - 18 * omdxx[31] + 3 * omdxx[32] + 6 * omdxx[33] - 9 * omdxx[34] + - 6 * omdxx[35] + 6 * omdxx[36] - 18 * omdxx[37] + 3 * omdxx[38] + - 6 * omdxx[39] - 9 * omdxx[40] + 6 * omdxx[41] + 6 * omdxx[42] + - 6 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[3]] = +9 * omdxx[3] - 18 * omdxx[4] + 3 * omdxx[5] - 27 * omdxx[24] + - 12 * omdxx[25] + 9 * omdxx[26] + 9 * omdxx[27] - 6 * omdxx[28] - - 6 * omdxx[29] + 9 * omdxx[36] - 6 * omdxx[37] - 6 * omdxx[38] - - 27 * omdxx[39] + 9 * omdxx[40] + 12 * omdxx[41] - 6 * omdxx[42] + - 18 * omdxx[43] - 6 * omdxx[44]; - phidxx[p45[4]] = -18 * omdxx[3] + 84 * omdxx[4] - 18 * omdxx[5] - 6 * omdxx[24] - - 36 * omdxx[25] + 12 * omdxx[26] - 30 * omdxx[27] + 30 * omdxx[28] - - 30 * omdxx[36] + 30 * omdxx[38] - 6 * omdxx[39] + 12 * omdxx[40] - - 36 * omdxx[41] + 24 * omdxx[43]; - phidxx[p45[5]] = +3 * omdxx[3] - 18 * omdxx[4] + 9 * omdxx[5] + 6 * omdxx[24] - - 18 * omdxx[25] + 3 * omdxx[26] + 6 * omdxx[27] - 9 * omdxx[28] + - 6 * omdxx[29] + 6 * omdxx[36] + 6 * omdxx[37] - 9 * omdxx[38] + - 6 * omdxx[39] + 3 * omdxx[40] - 18 * omdxx[41] + 6 * omdxx[42] + - 6 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[6]] = +9 * omdxx[6] - 18 * omdxx[7] + 3 * omdxx[8] + 9 * omdxx[24] - - 6 * omdxx[25] - 6 * omdxx[26] - 27 * omdxx[27] + 9 * omdxx[28] + - 12 * omdxx[29] + 9 * omdxx[30] - 6 * omdxx[31] - 6 * omdxx[32] - - 27 * omdxx[33] + 9 * omdxx[34] + 12 * omdxx[35] - 6 * omdxx[42] - - 6 * omdxx[43] + 18 * omdxx[44]; - phidxx[p45[7]] = -18 * omdxx[6] + 84 * omdxx[7] - 18 * omdxx[8] - 30 * omdxx[24] + - 30 * omdxx[26] - 6 * omdxx[27] + 12 * omdxx[28] - 36 * omdxx[29] - - 30 * omdxx[30] + 30 * omdxx[32] - 6 * omdxx[33] + 12 * omdxx[34] - - 36 * omdxx[35] + 24 * omdxx[44]; - phidxx[p45[8]] = +3 * omdxx[6] - 18 * omdxx[7] + 9 * omdxx[8] + 6 * omdxx[24] + - 6 * omdxx[25] - 9 * omdxx[26] + 6 * omdxx[27] + 3 * omdxx[28] - - 18 * omdxx[29] + 6 * omdxx[30] + 6 * omdxx[31] - 9 * omdxx[32] + - 6 * omdxx[33] + 3 * omdxx[34] - 18 * omdxx[35] + 6 * omdxx[42] + - 6 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[9]] = +9 * omdxx[9] - 18 * omdxx[10] + 3 * omdxx[11] - 27 * omdxx[18] + - 12 * omdxx[19] + 9 * omdxx[20] + 9 * omdxx[21] - 6 * omdxx[22] - - 6 * omdxx[23] - 3 * omdxx[36] + 18 * omdxx[37] - 6 * omdxx[38] + - 9 * omdxx[39] - 27 * omdxx[40] + 12 * omdxx[41] - 6 * omdxx[42] + - 18 * omdxx[43] - 6 * omdxx[44]; - phidxx[p45[10]] = -18 * omdxx[9] + 84 * omdxx[10] - 18 * omdxx[11] - 6 * omdxx[18] - - 36 * omdxx[19] + 12 * omdxx[20] - 30 * omdxx[21] + 30 * omdxx[22] - - 12 * omdxx[36] + 36 * omdxx[37] + 6 * omdxx[38] + 12 * omdxx[39] - - 6 * omdxx[40] - 36 * omdxx[41] - 24 * omdxx[42] + 24 * omdxx[43]; - phidxx[p45[11]] = +3 * omdxx[9] - 18 * omdxx[10] + 9 * omdxx[11] + 6 * omdxx[18] - - 18 * omdxx[19] + 3 * omdxx[20] + 6 * omdxx[21] - 9 * omdxx[22] + - 6 * omdxx[23] - 9 * omdxx[36] - 12 * omdxx[37] + 27 * omdxx[38] + - 3 * omdxx[39] + 6 * omdxx[40] - 18 * omdxx[41] - 18 * omdxx[42] + - 6 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[12]] = +9 * omdxx[12] - 18 * omdxx[13] + 3 * omdxx[14] + 9 * omdxx[18] - - 6 * omdxx[19] - 6 * omdxx[20] - 27 * omdxx[21] + 9 * omdxx[22] + - 12 * omdxx[23] - 3 * omdxx[30] + 18 * omdxx[31] - 6 * omdxx[32] + - 9 * omdxx[33] - 27 * omdxx[34] + 12 * omdxx[35] - 6 * omdxx[42] - - 6 * omdxx[43] + 18 * omdxx[44]; - phidxx[p45[13]] = -18 * omdxx[12] + 84 * omdxx[13] - 18 * omdxx[14] - 30 * omdxx[18] + - 30 * omdxx[20] - 6 * omdxx[21] + 12 * omdxx[22] - 36 * omdxx[23] - - 12 * omdxx[30] + 36 * omdxx[31] + 6 * omdxx[32] + 12 * omdxx[33] - - 6 * omdxx[34] - 36 * omdxx[35] - 24 * omdxx[42] + 24 * omdxx[44]; - phidxx[p45[14]] = +3 * omdxx[12] - 18 * omdxx[13] + 9 * omdxx[14] + 6 * omdxx[18] + - 6 * omdxx[19] - 9 * omdxx[20] + 6 * omdxx[21] + 3 * omdxx[22] - - 18 * omdxx[23] - 9 * omdxx[30] - 12 * omdxx[31] + 27 * omdxx[32] + - 3 * omdxx[33] + 6 * omdxx[34] - 18 * omdxx[35] - 18 * omdxx[42] + - 6 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[15]] = +9 * omdxx[15] - 18 * omdxx[16] + 3 * omdxx[17] - 3 * omdxx[18] + - 18 * omdxx[19] - 6 * omdxx[20] + 9 * omdxx[21] - 27 * omdxx[22] + - 12 * omdxx[23] - 3 * omdxx[24] + 18 * omdxx[25] - 6 * omdxx[26] + - 9 * omdxx[27] - 27 * omdxx[28] + 12 * omdxx[29] - 6 * omdxx[42] - - 6 * omdxx[43] + 18 * omdxx[44]; - phidxx[p45[16]] = -18 * omdxx[15] + 84 * omdxx[16] - 18 * omdxx[17] - 12 * omdxx[18] + - 36 * omdxx[19] + 6 * omdxx[20] + 12 * omdxx[21] - 6 * omdxx[22] - - 36 * omdxx[23] - 12 * omdxx[24] + 36 * omdxx[25] + 6 * omdxx[26] + - 12 * omdxx[27] - 6 * omdxx[28] - 36 * omdxx[29] - 24 * omdxx[43] + - 24 * omdxx[44]; - phidxx[p45[17]] = +3 * omdxx[15] - 18 * omdxx[16] + 9 * omdxx[17] - 9 * omdxx[18] - - 12 * omdxx[19] + 27 * omdxx[20] + 3 * omdxx[21] + 6 * omdxx[22] - - 18 * omdxx[23] - 9 * omdxx[24] - 12 * omdxx[25] + 27 * omdxx[26] + - 3 * omdxx[27] + 6 * omdxx[28] - 18 * omdxx[29] + 6 * omdxx[42] - - 18 * omdxx[43] + 6 * omdxx[44]; - phidxx[p45[18]] = +90 * omdxx[18] - 30 * omdxx[19] - 45 * omdxx[20] - 30 * omdxx[21] + - 15 * omdxx[22] + 30 * omdxx[23] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[19]] = -30 * omdxx[18] + 120 * omdxx[19] - 30 * omdxx[20] + 30 * omdxx[21] - - 60 * omdxx[22] + 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; - phidxx[p45[20]] = -45 * omdxx[18] - 30 * omdxx[19] + 90 * omdxx[20] + 15 * omdxx[21] + - 15 * omdxx[22] - 60 * omdxx[23] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[21]] = -30 * omdxx[18] + 30 * omdxx[19] + 15 * omdxx[20] + 90 * omdxx[21] - - 45 * omdxx[22] - 30 * omdxx[23] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[22]] = +15 * omdxx[18] - 60 * omdxx[19] + 15 * omdxx[20] - 45 * omdxx[21] + - 90 * omdxx[22] - 30 * omdxx[23] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[23]] = +30 * omdxx[18] - 60 * omdxx[20] - 30 * omdxx[21] - 30 * omdxx[22] + - 120 * omdxx[23] + 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; - phidxx[p45[24]] = +90 * omdxx[24] - 30 * omdxx[25] - 45 * omdxx[26] - 30 * omdxx[27] + - 15 * omdxx[28] + 30 * omdxx[29] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[25]] = -30 * omdxx[24] + 120 * omdxx[25] - 30 * omdxx[26] + 30 * omdxx[27] - - 60 * omdxx[28] - 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; - phidxx[p45[26]] = -45 * omdxx[24] - 30 * omdxx[25] + 90 * omdxx[26] + 15 * omdxx[27] + - 15 * omdxx[28] - 60 * omdxx[29] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[27]] = -30 * omdxx[24] + 30 * omdxx[25] + 15 * omdxx[26] + 90 * omdxx[27] - - 45 * omdxx[28] - 30 * omdxx[29] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[28]] = +15 * omdxx[24] - 60 * omdxx[25] + 15 * omdxx[26] - 45 * omdxx[27] + - 90 * omdxx[28] - 30 * omdxx[29] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[29]] = +30 * omdxx[24] - 60 * omdxx[26] - 30 * omdxx[27] - 30 * omdxx[28] + - 120 * omdxx[29] - 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; - phidxx[p45[30]] = +90 * omdxx[30] - 30 * omdxx[31] - 45 * omdxx[32] - 30 * omdxx[33] + - 15 * omdxx[34] + 30 * omdxx[35] - 45 * omdxx[42] + 15 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[31]] = -30 * omdxx[30] + 120 * omdxx[31] - 30 * omdxx[32] + 30 * omdxx[33] - - 60 * omdxx[34] - 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; - phidxx[p45[32]] = -45 * omdxx[30] - 30 * omdxx[31] + 90 * omdxx[32] + 15 * omdxx[33] + - 15 * omdxx[34] - 60 * omdxx[35] - 45 * omdxx[42] + 15 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[33]] = -30 * omdxx[30] + 30 * omdxx[31] + 15 * omdxx[32] + 90 * omdxx[33] - - 45 * omdxx[34] - 30 * omdxx[35] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[34]] = +15 * omdxx[30] - 60 * omdxx[31] + 15 * omdxx[32] - 45 * omdxx[33] + - 90 * omdxx[34] - 30 * omdxx[35] + 15 * omdxx[42] + 15 * omdxx[43] - - 45 * omdxx[44]; - phidxx[p45[35]] = +30 * omdxx[30] - 60 * omdxx[32] - 30 * omdxx[33] - 30 * omdxx[34] + - 120 * omdxx[35] + 30 * omdxx[42] - 30 * omdxx[43] - 30 * omdxx[44]; - phidxx[p45[36]] = +90 * omdxx[36] - 30 * omdxx[37] - 45 * omdxx[38] - 30 * omdxx[39] + - 15 * omdxx[40] + 30 * omdxx[41] - 45 * omdxx[42] + 15 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[37]] = -30 * omdxx[36] + 120 * omdxx[37] - 30 * omdxx[38] + 30 * omdxx[39] - - 60 * omdxx[40] - 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; - phidxx[p45[38]] = -45 * omdxx[36] - 30 * omdxx[37] + 90 * omdxx[38] + 15 * omdxx[39] + - 15 * omdxx[40] - 60 * omdxx[41] - 45 * omdxx[42] + 15 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[39]] = -30 * omdxx[36] + 30 * omdxx[37] + 15 * omdxx[38] + 90 * omdxx[39] - - 45 * omdxx[40] - 30 * omdxx[41] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[40]] = +15 * omdxx[36] - 60 * omdxx[37] + 15 * omdxx[38] - 45 * omdxx[39] + - 90 * omdxx[40] - 30 * omdxx[41] + 15 * omdxx[42] - 45 * omdxx[43] + - 15 * omdxx[44]; - phidxx[p45[41]] = +30 * omdxx[36] - 60 * omdxx[38] - 30 * omdxx[39] - 30 * omdxx[40] + - 120 * omdxx[41] + 30 * omdxx[42] - 30 * omdxx[43] - 30 * omdxx[44]; + phidxx[p45[0]] = +9 * omdxx[0] - 18 * omdxx[1] + 3 * omdxx[2] - 27 * omdxx[30] + 12 * omdxx[31] + 9 * omdxx[32] + 9 * omdxx[33] - 6 * omdxx[34] - 6 * omdxx[35] - 27 * omdxx[36] + + 12 * omdxx[37] + 9 * omdxx[38] + 9 * omdxx[39] - 6 * omdxx[40] - 6 * omdxx[41] + 18 * omdxx[42] - 6 * omdxx[43] - 6 * omdxx[44]; + phidxx[p45[1]] = -18 * omdxx[0] + 84 * omdxx[1] - 18 * omdxx[2] - 6 * omdxx[30] - 36 * omdxx[31] + 12 * omdxx[32] - 30 * omdxx[33] + 30 * omdxx[34] - 6 * omdxx[36] - 36 * omdxx[37] + + 12 * omdxx[38] - 30 * omdxx[39] + 30 * omdxx[40] + 24 * omdxx[42]; + phidxx[p45[2]] = +3 * omdxx[0] - 18 * omdxx[1] + 9 * omdxx[2] + 6 * omdxx[30] - 18 * omdxx[31] + 3 * omdxx[32] + 6 * omdxx[33] - 9 * omdxx[34] + 6 * omdxx[35] + 6 * omdxx[36] - + 18 * omdxx[37] + 3 * omdxx[38] + 6 * omdxx[39] - 9 * omdxx[40] + 6 * omdxx[41] + 6 * omdxx[42] + 6 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[3]] = +9 * omdxx[3] - 18 * omdxx[4] + 3 * omdxx[5] - 27 * omdxx[24] + 12 * omdxx[25] + 9 * omdxx[26] + 9 * omdxx[27] - 6 * omdxx[28] - 6 * omdxx[29] + 9 * omdxx[36] - + 6 * omdxx[37] - 6 * omdxx[38] - 27 * omdxx[39] + 9 * omdxx[40] + 12 * omdxx[41] - 6 * omdxx[42] + 18 * omdxx[43] - 6 * omdxx[44]; + phidxx[p45[4]] = -18 * omdxx[3] + 84 * omdxx[4] - 18 * omdxx[5] - 6 * omdxx[24] - 36 * omdxx[25] + 12 * omdxx[26] - 30 * omdxx[27] + 30 * omdxx[28] - 30 * omdxx[36] + 30 * omdxx[38] - + 6 * omdxx[39] + 12 * omdxx[40] - 36 * omdxx[41] + 24 * omdxx[43]; + phidxx[p45[5]] = +3 * omdxx[3] - 18 * omdxx[4] + 9 * omdxx[5] + 6 * omdxx[24] - 18 * omdxx[25] + 3 * omdxx[26] + 6 * omdxx[27] - 9 * omdxx[28] + 6 * omdxx[29] + 6 * omdxx[36] + 6 * omdxx[37] - + 9 * omdxx[38] + 6 * omdxx[39] + 3 * omdxx[40] - 18 * omdxx[41] + 6 * omdxx[42] + 6 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[6]] = +9 * omdxx[6] - 18 * omdxx[7] + 3 * omdxx[8] + 9 * omdxx[24] - 6 * omdxx[25] - 6 * omdxx[26] - 27 * omdxx[27] + 9 * omdxx[28] + 12 * omdxx[29] + 9 * omdxx[30] - + 6 * omdxx[31] - 6 * omdxx[32] - 27 * omdxx[33] + 9 * omdxx[34] + 12 * omdxx[35] - 6 * omdxx[42] - 6 * omdxx[43] + 18 * omdxx[44]; + phidxx[p45[7]] = -18 * omdxx[6] + 84 * omdxx[7] - 18 * omdxx[8] - 30 * omdxx[24] + 30 * omdxx[26] - 6 * omdxx[27] + 12 * omdxx[28] - 36 * omdxx[29] - 30 * omdxx[30] + 30 * omdxx[32] - + 6 * omdxx[33] + 12 * omdxx[34] - 36 * omdxx[35] + 24 * omdxx[44]; + phidxx[p45[8]] = +3 * omdxx[6] - 18 * omdxx[7] + 9 * omdxx[8] + 6 * omdxx[24] + 6 * omdxx[25] - 9 * omdxx[26] + 6 * omdxx[27] + 3 * omdxx[28] - 18 * omdxx[29] + 6 * omdxx[30] + 6 * omdxx[31] - + 9 * omdxx[32] + 6 * omdxx[33] + 3 * omdxx[34] - 18 * omdxx[35] + 6 * omdxx[42] + 6 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[9]] = +9 * omdxx[9] - 18 * omdxx[10] + 3 * omdxx[11] - 27 * omdxx[18] + 12 * omdxx[19] + 9 * omdxx[20] + 9 * omdxx[21] - 6 * omdxx[22] - 6 * omdxx[23] - 3 * omdxx[36] + + 18 * omdxx[37] - 6 * omdxx[38] + 9 * omdxx[39] - 27 * omdxx[40] + 12 * omdxx[41] - 6 * omdxx[42] + 18 * omdxx[43] - 6 * omdxx[44]; + phidxx[p45[10]] = -18 * omdxx[9] + 84 * omdxx[10] - 18 * omdxx[11] - 6 * omdxx[18] - 36 * omdxx[19] + 12 * omdxx[20] - 30 * omdxx[21] + 30 * omdxx[22] - 12 * omdxx[36] + 36 * omdxx[37] + + 6 * omdxx[38] + 12 * omdxx[39] - 6 * omdxx[40] - 36 * omdxx[41] - 24 * omdxx[42] + 24 * omdxx[43]; + phidxx[p45[11]] = +3 * omdxx[9] - 18 * omdxx[10] + 9 * omdxx[11] + 6 * omdxx[18] - 18 * omdxx[19] + 3 * omdxx[20] + 6 * omdxx[21] - 9 * omdxx[22] + 6 * omdxx[23] - 9 * omdxx[36] - + 12 * omdxx[37] + 27 * omdxx[38] + 3 * omdxx[39] + 6 * omdxx[40] - 18 * omdxx[41] - 18 * omdxx[42] + 6 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[12]] = +9 * omdxx[12] - 18 * omdxx[13] + 3 * omdxx[14] + 9 * omdxx[18] - 6 * omdxx[19] - 6 * omdxx[20] - 27 * omdxx[21] + 9 * omdxx[22] + 12 * omdxx[23] - 3 * omdxx[30] + + 18 * omdxx[31] - 6 * omdxx[32] + 9 * omdxx[33] - 27 * omdxx[34] + 12 * omdxx[35] - 6 * omdxx[42] - 6 * omdxx[43] + 18 * omdxx[44]; + phidxx[p45[13]] = -18 * omdxx[12] + 84 * omdxx[13] - 18 * omdxx[14] - 30 * omdxx[18] + 30 * omdxx[20] - 6 * omdxx[21] + 12 * omdxx[22] - 36 * omdxx[23] - 12 * omdxx[30] + 36 * omdxx[31] + + 6 * omdxx[32] + 12 * omdxx[33] - 6 * omdxx[34] - 36 * omdxx[35] - 24 * omdxx[42] + 24 * omdxx[44]; + phidxx[p45[14]] = +3 * omdxx[12] - 18 * omdxx[13] + 9 * omdxx[14] + 6 * omdxx[18] + 6 * omdxx[19] - 9 * omdxx[20] + 6 * omdxx[21] + 3 * omdxx[22] - 18 * omdxx[23] - 9 * omdxx[30] - + 12 * omdxx[31] + 27 * omdxx[32] + 3 * omdxx[33] + 6 * omdxx[34] - 18 * omdxx[35] - 18 * omdxx[42] + 6 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[15]] = +9 * omdxx[15] - 18 * omdxx[16] + 3 * omdxx[17] - 3 * omdxx[18] + 18 * omdxx[19] - 6 * omdxx[20] + 9 * omdxx[21] - 27 * omdxx[22] + 12 * omdxx[23] - 3 * omdxx[24] + + 18 * omdxx[25] - 6 * omdxx[26] + 9 * omdxx[27] - 27 * omdxx[28] + 12 * omdxx[29] - 6 * omdxx[42] - 6 * omdxx[43] + 18 * omdxx[44]; + phidxx[p45[16]] = -18 * omdxx[15] + 84 * omdxx[16] - 18 * omdxx[17] - 12 * omdxx[18] + 36 * omdxx[19] + 6 * omdxx[20] + 12 * omdxx[21] - 6 * omdxx[22] - 36 * omdxx[23] - 12 * omdxx[24] + + 36 * omdxx[25] + 6 * omdxx[26] + 12 * omdxx[27] - 6 * omdxx[28] - 36 * omdxx[29] - 24 * omdxx[43] + 24 * omdxx[44]; + phidxx[p45[17]] = +3 * omdxx[15] - 18 * omdxx[16] + 9 * omdxx[17] - 9 * omdxx[18] - 12 * omdxx[19] + 27 * omdxx[20] + 3 * omdxx[21] + 6 * omdxx[22] - 18 * omdxx[23] - 9 * omdxx[24] - + 12 * omdxx[25] + 27 * omdxx[26] + 3 * omdxx[27] + 6 * omdxx[28] - 18 * omdxx[29] + 6 * omdxx[42] - 18 * omdxx[43] + 6 * omdxx[44]; + phidxx[p45[18]] = +90 * omdxx[18] - 30 * omdxx[19] - 45 * omdxx[20] - 30 * omdxx[21] + 15 * omdxx[22] + 30 * omdxx[23] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[19]] = -30 * omdxx[18] + 120 * omdxx[19] - 30 * omdxx[20] + 30 * omdxx[21] - 60 * omdxx[22] + 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; + phidxx[p45[20]] = -45 * omdxx[18] - 30 * omdxx[19] + 90 * omdxx[20] + 15 * omdxx[21] + 15 * omdxx[22] - 60 * omdxx[23] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[21]] = -30 * omdxx[18] + 30 * omdxx[19] + 15 * omdxx[20] + 90 * omdxx[21] - 45 * omdxx[22] - 30 * omdxx[23] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[22]] = +15 * omdxx[18] - 60 * omdxx[19] + 15 * omdxx[20] - 45 * omdxx[21] + 90 * omdxx[22] - 30 * omdxx[23] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[23]] = +30 * omdxx[18] - 60 * omdxx[20] - 30 * omdxx[21] - 30 * omdxx[22] + 120 * omdxx[23] + 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; + phidxx[p45[24]] = +90 * omdxx[24] - 30 * omdxx[25] - 45 * omdxx[26] - 30 * omdxx[27] + 15 * omdxx[28] + 30 * omdxx[29] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[25]] = -30 * omdxx[24] + 120 * omdxx[25] - 30 * omdxx[26] + 30 * omdxx[27] - 60 * omdxx[28] - 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; + phidxx[p45[26]] = -45 * omdxx[24] - 30 * omdxx[25] + 90 * omdxx[26] + 15 * omdxx[27] + 15 * omdxx[28] - 60 * omdxx[29] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[27]] = -30 * omdxx[24] + 30 * omdxx[25] + 15 * omdxx[26] + 90 * omdxx[27] - 45 * omdxx[28] - 30 * omdxx[29] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[28]] = +15 * omdxx[24] - 60 * omdxx[25] + 15 * omdxx[26] - 45 * omdxx[27] + 90 * omdxx[28] - 30 * omdxx[29] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[29]] = +30 * omdxx[24] - 60 * omdxx[26] - 30 * omdxx[27] - 30 * omdxx[28] + 120 * omdxx[29] - 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; + phidxx[p45[30]] = +90 * omdxx[30] - 30 * omdxx[31] - 45 * omdxx[32] - 30 * omdxx[33] + 15 * omdxx[34] + 30 * omdxx[35] - 45 * omdxx[42] + 15 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[31]] = -30 * omdxx[30] + 120 * omdxx[31] - 30 * omdxx[32] + 30 * omdxx[33] - 60 * omdxx[34] - 30 * omdxx[42] - 30 * omdxx[43] + 30 * omdxx[44]; + phidxx[p45[32]] = -45 * omdxx[30] - 30 * omdxx[31] + 90 * omdxx[32] + 15 * omdxx[33] + 15 * omdxx[34] - 60 * omdxx[35] - 45 * omdxx[42] + 15 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[33]] = -30 * omdxx[30] + 30 * omdxx[31] + 15 * omdxx[32] + 90 * omdxx[33] - 45 * omdxx[34] - 30 * omdxx[35] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[34]] = +15 * omdxx[30] - 60 * omdxx[31] + 15 * omdxx[32] - 45 * omdxx[33] + 90 * omdxx[34] - 30 * omdxx[35] + 15 * omdxx[42] + 15 * omdxx[43] - 45 * omdxx[44]; + phidxx[p45[35]] = +30 * omdxx[30] - 60 * omdxx[32] - 30 * omdxx[33] - 30 * omdxx[34] + 120 * omdxx[35] + 30 * omdxx[42] - 30 * omdxx[43] - 30 * omdxx[44]; + phidxx[p45[36]] = +90 * omdxx[36] - 30 * omdxx[37] - 45 * omdxx[38] - 30 * omdxx[39] + 15 * omdxx[40] + 30 * omdxx[41] - 45 * omdxx[42] + 15 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[37]] = -30 * omdxx[36] + 120 * omdxx[37] - 30 * omdxx[38] + 30 * omdxx[39] - 60 * omdxx[40] - 30 * omdxx[42] + 30 * omdxx[43] - 30 * omdxx[44]; + phidxx[p45[38]] = -45 * omdxx[36] - 30 * omdxx[37] + 90 * omdxx[38] + 15 * omdxx[39] + 15 * omdxx[40] - 60 * omdxx[41] - 45 * omdxx[42] + 15 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[39]] = -30 * omdxx[36] + 30 * omdxx[37] + 15 * omdxx[38] + 90 * omdxx[39] - 45 * omdxx[40] - 30 * omdxx[41] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[40]] = +15 * omdxx[36] - 60 * omdxx[37] + 15 * omdxx[38] - 45 * omdxx[39] + 90 * omdxx[40] - 30 * omdxx[41] + 15 * omdxx[42] - 45 * omdxx[43] + 15 * omdxx[44]; + phidxx[p45[41]] = +30 * omdxx[36] - 60 * omdxx[38] - 30 * omdxx[39] - 30 * omdxx[40] + 120 * omdxx[41] + 30 * omdxx[42] - 30 * omdxx[43] - 30 * omdxx[44]; phidxx[p45[42]] = +90 * omdxx[42] - 30 * omdxx[43] - 30 * omdxx[44]; phidxx[p45[43]] = -30 * omdxx[42] + 90 * omdxx[43] - 30 * omdxx[44]; phidxx[p45[44]] = -30 * omdxx[42] - 30 * omdxx[43] + 90 * omdxx[44]; @@ -2748,155 +1980,66 @@ namespace Fem2D { R3 phidyy[45]; if (whatd & Fop_dyy) { - phidyy[p45[0]] = +9 * omdyy[0] - 18 * omdyy[1] + 3 * omdyy[2] - 27 * omdyy[30] + - 12 * omdyy[31] + 9 * omdyy[32] + 9 * omdyy[33] - 6 * omdyy[34] - - 6 * omdyy[35] - 27 * omdyy[36] + 12 * omdyy[37] + 9 * omdyy[38] + - 9 * omdyy[39] - 6 * omdyy[40] - 6 * omdyy[41] + 18 * omdyy[42] - - 6 * omdyy[43] - 6 * omdyy[44]; - phidyy[p45[1]] = -18 * omdyy[0] + 84 * omdyy[1] - 18 * omdyy[2] - 6 * omdyy[30] - - 36 * omdyy[31] + 12 * omdyy[32] - 30 * omdyy[33] + 30 * omdyy[34] - - 6 * omdyy[36] - 36 * omdyy[37] + 12 * omdyy[38] - 30 * omdyy[39] + - 30 * omdyy[40] + 24 * omdyy[42]; - phidyy[p45[2]] = +3 * omdyy[0] - 18 * omdyy[1] + 9 * omdyy[2] + 6 * omdyy[30] - - 18 * omdyy[31] + 3 * omdyy[32] + 6 * omdyy[33] - 9 * omdyy[34] + - 6 * omdyy[35] + 6 * omdyy[36] - 18 * omdyy[37] + 3 * omdyy[38] + - 6 * omdyy[39] - 9 * omdyy[40] + 6 * omdyy[41] + 6 * omdyy[42] + - 6 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[3]] = +9 * omdyy[3] - 18 * omdyy[4] + 3 * omdyy[5] - 27 * omdyy[24] + - 12 * omdyy[25] + 9 * omdyy[26] + 9 * omdyy[27] - 6 * omdyy[28] - - 6 * omdyy[29] + 9 * omdyy[36] - 6 * omdyy[37] - 6 * omdyy[38] - - 27 * omdyy[39] + 9 * omdyy[40] + 12 * omdyy[41] - 6 * omdyy[42] + - 18 * omdyy[43] - 6 * omdyy[44]; - phidyy[p45[4]] = -18 * omdyy[3] + 84 * omdyy[4] - 18 * omdyy[5] - 6 * omdyy[24] - - 36 * omdyy[25] + 12 * omdyy[26] - 30 * omdyy[27] + 30 * omdyy[28] - - 30 * omdyy[36] + 30 * omdyy[38] - 6 * omdyy[39] + 12 * omdyy[40] - - 36 * omdyy[41] + 24 * omdyy[43]; - phidyy[p45[5]] = +3 * omdyy[3] - 18 * omdyy[4] + 9 * omdyy[5] + 6 * omdyy[24] - - 18 * omdyy[25] + 3 * omdyy[26] + 6 * omdyy[27] - 9 * omdyy[28] + - 6 * omdyy[29] + 6 * omdyy[36] + 6 * omdyy[37] - 9 * omdyy[38] + - 6 * omdyy[39] + 3 * omdyy[40] - 18 * omdyy[41] + 6 * omdyy[42] + - 6 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[6]] = +9 * omdyy[6] - 18 * omdyy[7] + 3 * omdyy[8] + 9 * omdyy[24] - - 6 * omdyy[25] - 6 * omdyy[26] - 27 * omdyy[27] + 9 * omdyy[28] + - 12 * omdyy[29] + 9 * omdyy[30] - 6 * omdyy[31] - 6 * omdyy[32] - - 27 * omdyy[33] + 9 * omdyy[34] + 12 * omdyy[35] - 6 * omdyy[42] - - 6 * omdyy[43] + 18 * omdyy[44]; - phidyy[p45[7]] = -18 * omdyy[6] + 84 * omdyy[7] - 18 * omdyy[8] - 30 * omdyy[24] + - 30 * omdyy[26] - 6 * omdyy[27] + 12 * omdyy[28] - 36 * omdyy[29] - - 30 * omdyy[30] + 30 * omdyy[32] - 6 * omdyy[33] + 12 * omdyy[34] - - 36 * omdyy[35] + 24 * omdyy[44]; - phidyy[p45[8]] = +3 * omdyy[6] - 18 * omdyy[7] + 9 * omdyy[8] + 6 * omdyy[24] + - 6 * omdyy[25] - 9 * omdyy[26] + 6 * omdyy[27] + 3 * omdyy[28] - - 18 * omdyy[29] + 6 * omdyy[30] + 6 * omdyy[31] - 9 * omdyy[32] + - 6 * omdyy[33] + 3 * omdyy[34] - 18 * omdyy[35] + 6 * omdyy[42] + - 6 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[9]] = +9 * omdyy[9] - 18 * omdyy[10] + 3 * omdyy[11] - 27 * omdyy[18] + - 12 * omdyy[19] + 9 * omdyy[20] + 9 * omdyy[21] - 6 * omdyy[22] - - 6 * omdyy[23] - 3 * omdyy[36] + 18 * omdyy[37] - 6 * omdyy[38] + - 9 * omdyy[39] - 27 * omdyy[40] + 12 * omdyy[41] - 6 * omdyy[42] + - 18 * omdyy[43] - 6 * omdyy[44]; - phidyy[p45[10]] = -18 * omdyy[9] + 84 * omdyy[10] - 18 * omdyy[11] - 6 * omdyy[18] - - 36 * omdyy[19] + 12 * omdyy[20] - 30 * omdyy[21] + 30 * omdyy[22] - - 12 * omdyy[36] + 36 * omdyy[37] + 6 * omdyy[38] + 12 * omdyy[39] - - 6 * omdyy[40] - 36 * omdyy[41] - 24 * omdyy[42] + 24 * omdyy[43]; - phidyy[p45[11]] = +3 * omdyy[9] - 18 * omdyy[10] + 9 * omdyy[11] + 6 * omdyy[18] - - 18 * omdyy[19] + 3 * omdyy[20] + 6 * omdyy[21] - 9 * omdyy[22] + - 6 * omdyy[23] - 9 * omdyy[36] - 12 * omdyy[37] + 27 * omdyy[38] + - 3 * omdyy[39] + 6 * omdyy[40] - 18 * omdyy[41] - 18 * omdyy[42] + - 6 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[12]] = +9 * omdyy[12] - 18 * omdyy[13] + 3 * omdyy[14] + 9 * omdyy[18] - - 6 * omdyy[19] - 6 * omdyy[20] - 27 * omdyy[21] + 9 * omdyy[22] + - 12 * omdyy[23] - 3 * omdyy[30] + 18 * omdyy[31] - 6 * omdyy[32] + - 9 * omdyy[33] - 27 * omdyy[34] + 12 * omdyy[35] - 6 * omdyy[42] - - 6 * omdyy[43] + 18 * omdyy[44]; - phidyy[p45[13]] = -18 * omdyy[12] + 84 * omdyy[13] - 18 * omdyy[14] - 30 * omdyy[18] + - 30 * omdyy[20] - 6 * omdyy[21] + 12 * omdyy[22] - 36 * omdyy[23] - - 12 * omdyy[30] + 36 * omdyy[31] + 6 * omdyy[32] + 12 * omdyy[33] - - 6 * omdyy[34] - 36 * omdyy[35] - 24 * omdyy[42] + 24 * omdyy[44]; - phidyy[p45[14]] = +3 * omdyy[12] - 18 * omdyy[13] + 9 * omdyy[14] + 6 * omdyy[18] + - 6 * omdyy[19] - 9 * omdyy[20] + 6 * omdyy[21] + 3 * omdyy[22] - - 18 * omdyy[23] - 9 * omdyy[30] - 12 * omdyy[31] + 27 * omdyy[32] + - 3 * omdyy[33] + 6 * omdyy[34] - 18 * omdyy[35] - 18 * omdyy[42] + - 6 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[15]] = +9 * omdyy[15] - 18 * omdyy[16] + 3 * omdyy[17] - 3 * omdyy[18] + - 18 * omdyy[19] - 6 * omdyy[20] + 9 * omdyy[21] - 27 * omdyy[22] + - 12 * omdyy[23] - 3 * omdyy[24] + 18 * omdyy[25] - 6 * omdyy[26] + - 9 * omdyy[27] - 27 * omdyy[28] + 12 * omdyy[29] - 6 * omdyy[42] - - 6 * omdyy[43] + 18 * omdyy[44]; - phidyy[p45[16]] = -18 * omdyy[15] + 84 * omdyy[16] - 18 * omdyy[17] - 12 * omdyy[18] + - 36 * omdyy[19] + 6 * omdyy[20] + 12 * omdyy[21] - 6 * omdyy[22] - - 36 * omdyy[23] - 12 * omdyy[24] + 36 * omdyy[25] + 6 * omdyy[26] + - 12 * omdyy[27] - 6 * omdyy[28] - 36 * omdyy[29] - 24 * omdyy[43] + - 24 * omdyy[44]; - phidyy[p45[17]] = +3 * omdyy[15] - 18 * omdyy[16] + 9 * omdyy[17] - 9 * omdyy[18] - - 12 * omdyy[19] + 27 * omdyy[20] + 3 * omdyy[21] + 6 * omdyy[22] - - 18 * omdyy[23] - 9 * omdyy[24] - 12 * omdyy[25] + 27 * omdyy[26] + - 3 * omdyy[27] + 6 * omdyy[28] - 18 * omdyy[29] + 6 * omdyy[42] - - 18 * omdyy[43] + 6 * omdyy[44]; - phidyy[p45[18]] = +90 * omdyy[18] - 30 * omdyy[19] - 45 * omdyy[20] - 30 * omdyy[21] + - 15 * omdyy[22] + 30 * omdyy[23] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[19]] = -30 * omdyy[18] + 120 * omdyy[19] - 30 * omdyy[20] + 30 * omdyy[21] - - 60 * omdyy[22] + 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; - phidyy[p45[20]] = -45 * omdyy[18] - 30 * omdyy[19] + 90 * omdyy[20] + 15 * omdyy[21] + - 15 * omdyy[22] - 60 * omdyy[23] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[21]] = -30 * omdyy[18] + 30 * omdyy[19] + 15 * omdyy[20] + 90 * omdyy[21] - - 45 * omdyy[22] - 30 * omdyy[23] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[22]] = +15 * omdyy[18] - 60 * omdyy[19] + 15 * omdyy[20] - 45 * omdyy[21] + - 90 * omdyy[22] - 30 * omdyy[23] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[23]] = +30 * omdyy[18] - 60 * omdyy[20] - 30 * omdyy[21] - 30 * omdyy[22] + - 120 * omdyy[23] + 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; - phidyy[p45[24]] = +90 * omdyy[24] - 30 * omdyy[25] - 45 * omdyy[26] - 30 * omdyy[27] + - 15 * omdyy[28] + 30 * omdyy[29] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[25]] = -30 * omdyy[24] + 120 * omdyy[25] - 30 * omdyy[26] + 30 * omdyy[27] - - 60 * omdyy[28] - 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; - phidyy[p45[26]] = -45 * omdyy[24] - 30 * omdyy[25] + 90 * omdyy[26] + 15 * omdyy[27] + - 15 * omdyy[28] - 60 * omdyy[29] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[27]] = -30 * omdyy[24] + 30 * omdyy[25] + 15 * omdyy[26] + 90 * omdyy[27] - - 45 * omdyy[28] - 30 * omdyy[29] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[28]] = +15 * omdyy[24] - 60 * omdyy[25] + 15 * omdyy[26] - 45 * omdyy[27] + - 90 * omdyy[28] - 30 * omdyy[29] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[29]] = +30 * omdyy[24] - 60 * omdyy[26] - 30 * omdyy[27] - 30 * omdyy[28] + - 120 * omdyy[29] - 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; - phidyy[p45[30]] = +90 * omdyy[30] - 30 * omdyy[31] - 45 * omdyy[32] - 30 * omdyy[33] + - 15 * omdyy[34] + 30 * omdyy[35] - 45 * omdyy[42] + 15 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[31]] = -30 * omdyy[30] + 120 * omdyy[31] - 30 * omdyy[32] + 30 * omdyy[33] - - 60 * omdyy[34] - 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; - phidyy[p45[32]] = -45 * omdyy[30] - 30 * omdyy[31] + 90 * omdyy[32] + 15 * omdyy[33] + - 15 * omdyy[34] - 60 * omdyy[35] - 45 * omdyy[42] + 15 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[33]] = -30 * omdyy[30] + 30 * omdyy[31] + 15 * omdyy[32] + 90 * omdyy[33] - - 45 * omdyy[34] - 30 * omdyy[35] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[34]] = +15 * omdyy[30] - 60 * omdyy[31] + 15 * omdyy[32] - 45 * omdyy[33] + - 90 * omdyy[34] - 30 * omdyy[35] + 15 * omdyy[42] + 15 * omdyy[43] - - 45 * omdyy[44]; - phidyy[p45[35]] = +30 * omdyy[30] - 60 * omdyy[32] - 30 * omdyy[33] - 30 * omdyy[34] + - 120 * omdyy[35] + 30 * omdyy[42] - 30 * omdyy[43] - 30 * omdyy[44]; - phidyy[p45[36]] = +90 * omdyy[36] - 30 * omdyy[37] - 45 * omdyy[38] - 30 * omdyy[39] + - 15 * omdyy[40] + 30 * omdyy[41] - 45 * omdyy[42] + 15 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[37]] = -30 * omdyy[36] + 120 * omdyy[37] - 30 * omdyy[38] + 30 * omdyy[39] - - 60 * omdyy[40] - 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; - phidyy[p45[38]] = -45 * omdyy[36] - 30 * omdyy[37] + 90 * omdyy[38] + 15 * omdyy[39] + - 15 * omdyy[40] - 60 * omdyy[41] - 45 * omdyy[42] + 15 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[39]] = -30 * omdyy[36] + 30 * omdyy[37] + 15 * omdyy[38] + 90 * omdyy[39] - - 45 * omdyy[40] - 30 * omdyy[41] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[40]] = +15 * omdyy[36] - 60 * omdyy[37] + 15 * omdyy[38] - 45 * omdyy[39] + - 90 * omdyy[40] - 30 * omdyy[41] + 15 * omdyy[42] - 45 * omdyy[43] + - 15 * omdyy[44]; - phidyy[p45[41]] = +30 * omdyy[36] - 60 * omdyy[38] - 30 * omdyy[39] - 30 * omdyy[40] + - 120 * omdyy[41] + 30 * omdyy[42] - 30 * omdyy[43] - 30 * omdyy[44]; + phidyy[p45[0]] = +9 * omdyy[0] - 18 * omdyy[1] + 3 * omdyy[2] - 27 * omdyy[30] + 12 * omdyy[31] + 9 * omdyy[32] + 9 * omdyy[33] - 6 * omdyy[34] - 6 * omdyy[35] - 27 * omdyy[36] + + 12 * omdyy[37] + 9 * omdyy[38] + 9 * omdyy[39] - 6 * omdyy[40] - 6 * omdyy[41] + 18 * omdyy[42] - 6 * omdyy[43] - 6 * omdyy[44]; + phidyy[p45[1]] = -18 * omdyy[0] + 84 * omdyy[1] - 18 * omdyy[2] - 6 * omdyy[30] - 36 * omdyy[31] + 12 * omdyy[32] - 30 * omdyy[33] + 30 * omdyy[34] - 6 * omdyy[36] - 36 * omdyy[37] + + 12 * omdyy[38] - 30 * omdyy[39] + 30 * omdyy[40] + 24 * omdyy[42]; + phidyy[p45[2]] = +3 * omdyy[0] - 18 * omdyy[1] + 9 * omdyy[2] + 6 * omdyy[30] - 18 * omdyy[31] + 3 * omdyy[32] + 6 * omdyy[33] - 9 * omdyy[34] + 6 * omdyy[35] + 6 * omdyy[36] - + 18 * omdyy[37] + 3 * omdyy[38] + 6 * omdyy[39] - 9 * omdyy[40] + 6 * omdyy[41] + 6 * omdyy[42] + 6 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[3]] = +9 * omdyy[3] - 18 * omdyy[4] + 3 * omdyy[5] - 27 * omdyy[24] + 12 * omdyy[25] + 9 * omdyy[26] + 9 * omdyy[27] - 6 * omdyy[28] - 6 * omdyy[29] + 9 * omdyy[36] - + 6 * omdyy[37] - 6 * omdyy[38] - 27 * omdyy[39] + 9 * omdyy[40] + 12 * omdyy[41] - 6 * omdyy[42] + 18 * omdyy[43] - 6 * omdyy[44]; + phidyy[p45[4]] = -18 * omdyy[3] + 84 * omdyy[4] - 18 * omdyy[5] - 6 * omdyy[24] - 36 * omdyy[25] + 12 * omdyy[26] - 30 * omdyy[27] + 30 * omdyy[28] - 30 * omdyy[36] + 30 * omdyy[38] - + 6 * omdyy[39] + 12 * omdyy[40] - 36 * omdyy[41] + 24 * omdyy[43]; + phidyy[p45[5]] = +3 * omdyy[3] - 18 * omdyy[4] + 9 * omdyy[5] + 6 * omdyy[24] - 18 * omdyy[25] + 3 * omdyy[26] + 6 * omdyy[27] - 9 * omdyy[28] + 6 * omdyy[29] + 6 * omdyy[36] + 6 * omdyy[37] - + 9 * omdyy[38] + 6 * omdyy[39] + 3 * omdyy[40] - 18 * omdyy[41] + 6 * omdyy[42] + 6 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[6]] = +9 * omdyy[6] - 18 * omdyy[7] + 3 * omdyy[8] + 9 * omdyy[24] - 6 * omdyy[25] - 6 * omdyy[26] - 27 * omdyy[27] + 9 * omdyy[28] + 12 * omdyy[29] + 9 * omdyy[30] - + 6 * omdyy[31] - 6 * omdyy[32] - 27 * omdyy[33] + 9 * omdyy[34] + 12 * omdyy[35] - 6 * omdyy[42] - 6 * omdyy[43] + 18 * omdyy[44]; + phidyy[p45[7]] = -18 * omdyy[6] + 84 * omdyy[7] - 18 * omdyy[8] - 30 * omdyy[24] + 30 * omdyy[26] - 6 * omdyy[27] + 12 * omdyy[28] - 36 * omdyy[29] - 30 * omdyy[30] + 30 * omdyy[32] - + 6 * omdyy[33] + 12 * omdyy[34] - 36 * omdyy[35] + 24 * omdyy[44]; + phidyy[p45[8]] = +3 * omdyy[6] - 18 * omdyy[7] + 9 * omdyy[8] + 6 * omdyy[24] + 6 * omdyy[25] - 9 * omdyy[26] + 6 * omdyy[27] + 3 * omdyy[28] - 18 * omdyy[29] + 6 * omdyy[30] + 6 * omdyy[31] - + 9 * omdyy[32] + 6 * omdyy[33] + 3 * omdyy[34] - 18 * omdyy[35] + 6 * omdyy[42] + 6 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[9]] = +9 * omdyy[9] - 18 * omdyy[10] + 3 * omdyy[11] - 27 * omdyy[18] + 12 * omdyy[19] + 9 * omdyy[20] + 9 * omdyy[21] - 6 * omdyy[22] - 6 * omdyy[23] - 3 * omdyy[36] + + 18 * omdyy[37] - 6 * omdyy[38] + 9 * omdyy[39] - 27 * omdyy[40] + 12 * omdyy[41] - 6 * omdyy[42] + 18 * omdyy[43] - 6 * omdyy[44]; + phidyy[p45[10]] = -18 * omdyy[9] + 84 * omdyy[10] - 18 * omdyy[11] - 6 * omdyy[18] - 36 * omdyy[19] + 12 * omdyy[20] - 30 * omdyy[21] + 30 * omdyy[22] - 12 * omdyy[36] + 36 * omdyy[37] + + 6 * omdyy[38] + 12 * omdyy[39] - 6 * omdyy[40] - 36 * omdyy[41] - 24 * omdyy[42] + 24 * omdyy[43]; + phidyy[p45[11]] = +3 * omdyy[9] - 18 * omdyy[10] + 9 * omdyy[11] + 6 * omdyy[18] - 18 * omdyy[19] + 3 * omdyy[20] + 6 * omdyy[21] - 9 * omdyy[22] + 6 * omdyy[23] - 9 * omdyy[36] - + 12 * omdyy[37] + 27 * omdyy[38] + 3 * omdyy[39] + 6 * omdyy[40] - 18 * omdyy[41] - 18 * omdyy[42] + 6 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[12]] = +9 * omdyy[12] - 18 * omdyy[13] + 3 * omdyy[14] + 9 * omdyy[18] - 6 * omdyy[19] - 6 * omdyy[20] - 27 * omdyy[21] + 9 * omdyy[22] + 12 * omdyy[23] - 3 * omdyy[30] + + 18 * omdyy[31] - 6 * omdyy[32] + 9 * omdyy[33] - 27 * omdyy[34] + 12 * omdyy[35] - 6 * omdyy[42] - 6 * omdyy[43] + 18 * omdyy[44]; + phidyy[p45[13]] = -18 * omdyy[12] + 84 * omdyy[13] - 18 * omdyy[14] - 30 * omdyy[18] + 30 * omdyy[20] - 6 * omdyy[21] + 12 * omdyy[22] - 36 * omdyy[23] - 12 * omdyy[30] + 36 * omdyy[31] + + 6 * omdyy[32] + 12 * omdyy[33] - 6 * omdyy[34] - 36 * omdyy[35] - 24 * omdyy[42] + 24 * omdyy[44]; + phidyy[p45[14]] = +3 * omdyy[12] - 18 * omdyy[13] + 9 * omdyy[14] + 6 * omdyy[18] + 6 * omdyy[19] - 9 * omdyy[20] + 6 * omdyy[21] + 3 * omdyy[22] - 18 * omdyy[23] - 9 * omdyy[30] - + 12 * omdyy[31] + 27 * omdyy[32] + 3 * omdyy[33] + 6 * omdyy[34] - 18 * omdyy[35] - 18 * omdyy[42] + 6 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[15]] = +9 * omdyy[15] - 18 * omdyy[16] + 3 * omdyy[17] - 3 * omdyy[18] + 18 * omdyy[19] - 6 * omdyy[20] + 9 * omdyy[21] - 27 * omdyy[22] + 12 * omdyy[23] - 3 * omdyy[24] + + 18 * omdyy[25] - 6 * omdyy[26] + 9 * omdyy[27] - 27 * omdyy[28] + 12 * omdyy[29] - 6 * omdyy[42] - 6 * omdyy[43] + 18 * omdyy[44]; + phidyy[p45[16]] = -18 * omdyy[15] + 84 * omdyy[16] - 18 * omdyy[17] - 12 * omdyy[18] + 36 * omdyy[19] + 6 * omdyy[20] + 12 * omdyy[21] - 6 * omdyy[22] - 36 * omdyy[23] - 12 * omdyy[24] + + 36 * omdyy[25] + 6 * omdyy[26] + 12 * omdyy[27] - 6 * omdyy[28] - 36 * omdyy[29] - 24 * omdyy[43] + 24 * omdyy[44]; + phidyy[p45[17]] = +3 * omdyy[15] - 18 * omdyy[16] + 9 * omdyy[17] - 9 * omdyy[18] - 12 * omdyy[19] + 27 * omdyy[20] + 3 * omdyy[21] + 6 * omdyy[22] - 18 * omdyy[23] - 9 * omdyy[24] - + 12 * omdyy[25] + 27 * omdyy[26] + 3 * omdyy[27] + 6 * omdyy[28] - 18 * omdyy[29] + 6 * omdyy[42] - 18 * omdyy[43] + 6 * omdyy[44]; + phidyy[p45[18]] = +90 * omdyy[18] - 30 * omdyy[19] - 45 * omdyy[20] - 30 * omdyy[21] + 15 * omdyy[22] + 30 * omdyy[23] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[19]] = -30 * omdyy[18] + 120 * omdyy[19] - 30 * omdyy[20] + 30 * omdyy[21] - 60 * omdyy[22] + 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; + phidyy[p45[20]] = -45 * omdyy[18] - 30 * omdyy[19] + 90 * omdyy[20] + 15 * omdyy[21] + 15 * omdyy[22] - 60 * omdyy[23] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[21]] = -30 * omdyy[18] + 30 * omdyy[19] + 15 * omdyy[20] + 90 * omdyy[21] - 45 * omdyy[22] - 30 * omdyy[23] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[22]] = +15 * omdyy[18] - 60 * omdyy[19] + 15 * omdyy[20] - 45 * omdyy[21] + 90 * omdyy[22] - 30 * omdyy[23] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[23]] = +30 * omdyy[18] - 60 * omdyy[20] - 30 * omdyy[21] - 30 * omdyy[22] + 120 * omdyy[23] + 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; + phidyy[p45[24]] = +90 * omdyy[24] - 30 * omdyy[25] - 45 * omdyy[26] - 30 * omdyy[27] + 15 * omdyy[28] + 30 * omdyy[29] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[25]] = -30 * omdyy[24] + 120 * omdyy[25] - 30 * omdyy[26] + 30 * omdyy[27] - 60 * omdyy[28] - 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; + phidyy[p45[26]] = -45 * omdyy[24] - 30 * omdyy[25] + 90 * omdyy[26] + 15 * omdyy[27] + 15 * omdyy[28] - 60 * omdyy[29] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[27]] = -30 * omdyy[24] + 30 * omdyy[25] + 15 * omdyy[26] + 90 * omdyy[27] - 45 * omdyy[28] - 30 * omdyy[29] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[28]] = +15 * omdyy[24] - 60 * omdyy[25] + 15 * omdyy[26] - 45 * omdyy[27] + 90 * omdyy[28] - 30 * omdyy[29] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[29]] = +30 * omdyy[24] - 60 * omdyy[26] - 30 * omdyy[27] - 30 * omdyy[28] + 120 * omdyy[29] - 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; + phidyy[p45[30]] = +90 * omdyy[30] - 30 * omdyy[31] - 45 * omdyy[32] - 30 * omdyy[33] + 15 * omdyy[34] + 30 * omdyy[35] - 45 * omdyy[42] + 15 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[31]] = -30 * omdyy[30] + 120 * omdyy[31] - 30 * omdyy[32] + 30 * omdyy[33] - 60 * omdyy[34] - 30 * omdyy[42] - 30 * omdyy[43] + 30 * omdyy[44]; + phidyy[p45[32]] = -45 * omdyy[30] - 30 * omdyy[31] + 90 * omdyy[32] + 15 * omdyy[33] + 15 * omdyy[34] - 60 * omdyy[35] - 45 * omdyy[42] + 15 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[33]] = -30 * omdyy[30] + 30 * omdyy[31] + 15 * omdyy[32] + 90 * omdyy[33] - 45 * omdyy[34] - 30 * omdyy[35] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[34]] = +15 * omdyy[30] - 60 * omdyy[31] + 15 * omdyy[32] - 45 * omdyy[33] + 90 * omdyy[34] - 30 * omdyy[35] + 15 * omdyy[42] + 15 * omdyy[43] - 45 * omdyy[44]; + phidyy[p45[35]] = +30 * omdyy[30] - 60 * omdyy[32] - 30 * omdyy[33] - 30 * omdyy[34] + 120 * omdyy[35] + 30 * omdyy[42] - 30 * omdyy[43] - 30 * omdyy[44]; + phidyy[p45[36]] = +90 * omdyy[36] - 30 * omdyy[37] - 45 * omdyy[38] - 30 * omdyy[39] + 15 * omdyy[40] + 30 * omdyy[41] - 45 * omdyy[42] + 15 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[37]] = -30 * omdyy[36] + 120 * omdyy[37] - 30 * omdyy[38] + 30 * omdyy[39] - 60 * omdyy[40] - 30 * omdyy[42] + 30 * omdyy[43] - 30 * omdyy[44]; + phidyy[p45[38]] = -45 * omdyy[36] - 30 * omdyy[37] + 90 * omdyy[38] + 15 * omdyy[39] + 15 * omdyy[40] - 60 * omdyy[41] - 45 * omdyy[42] + 15 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[39]] = -30 * omdyy[36] + 30 * omdyy[37] + 15 * omdyy[38] + 90 * omdyy[39] - 45 * omdyy[40] - 30 * omdyy[41] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[40]] = +15 * omdyy[36] - 60 * omdyy[37] + 15 * omdyy[38] - 45 * omdyy[39] + 90 * omdyy[40] - 30 * omdyy[41] + 15 * omdyy[42] - 45 * omdyy[43] + 15 * omdyy[44]; + phidyy[p45[41]] = +30 * omdyy[36] - 60 * omdyy[38] - 30 * omdyy[39] - 30 * omdyy[40] + 120 * omdyy[41] + 30 * omdyy[42] - 30 * omdyy[43] - 30 * omdyy[44]; phidyy[p45[42]] = +90 * omdyy[42] - 30 * omdyy[43] - 30 * omdyy[44]; phidyy[p45[43]] = -30 * omdyy[42] + 90 * omdyy[43] - 30 * omdyy[44]; phidyy[p45[44]] = -30 * omdyy[42] - 30 * omdyy[43] + 90 * omdyy[44]; @@ -2910,155 +2053,66 @@ namespace Fem2D { R3 phidzz[45]; if (whatd & Fop_dzz) { - phidzz[p45[0]] = +9 * omdzz[0] - 18 * omdzz[1] + 3 * omdzz[2] - 27 * omdzz[30] + - 12 * omdzz[31] + 9 * omdzz[32] + 9 * omdzz[33] - 6 * omdzz[34] - - 6 * omdzz[35] - 27 * omdzz[36] + 12 * omdzz[37] + 9 * omdzz[38] + - 9 * omdzz[39] - 6 * omdzz[40] - 6 * omdzz[41] + 18 * omdzz[42] - - 6 * omdzz[43] - 6 * omdzz[44]; - phidzz[p45[1]] = -18 * omdzz[0] + 84 * omdzz[1] - 18 * omdzz[2] - 6 * omdzz[30] - - 36 * omdzz[31] + 12 * omdzz[32] - 30 * omdzz[33] + 30 * omdzz[34] - - 6 * omdzz[36] - 36 * omdzz[37] + 12 * omdzz[38] - 30 * omdzz[39] + - 30 * omdzz[40] + 24 * omdzz[42]; - phidzz[p45[2]] = +3 * omdzz[0] - 18 * omdzz[1] + 9 * omdzz[2] + 6 * omdzz[30] - - 18 * omdzz[31] + 3 * omdzz[32] + 6 * omdzz[33] - 9 * omdzz[34] + - 6 * omdzz[35] + 6 * omdzz[36] - 18 * omdzz[37] + 3 * omdzz[38] + - 6 * omdzz[39] - 9 * omdzz[40] + 6 * omdzz[41] + 6 * omdzz[42] + - 6 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[3]] = +9 * omdzz[3] - 18 * omdzz[4] + 3 * omdzz[5] - 27 * omdzz[24] + - 12 * omdzz[25] + 9 * omdzz[26] + 9 * omdzz[27] - 6 * omdzz[28] - - 6 * omdzz[29] + 9 * omdzz[36] - 6 * omdzz[37] - 6 * omdzz[38] - - 27 * omdzz[39] + 9 * omdzz[40] + 12 * omdzz[41] - 6 * omdzz[42] + - 18 * omdzz[43] - 6 * omdzz[44]; - phidzz[p45[4]] = -18 * omdzz[3] + 84 * omdzz[4] - 18 * omdzz[5] - 6 * omdzz[24] - - 36 * omdzz[25] + 12 * omdzz[26] - 30 * omdzz[27] + 30 * omdzz[28] - - 30 * omdzz[36] + 30 * omdzz[38] - 6 * omdzz[39] + 12 * omdzz[40] - - 36 * omdzz[41] + 24 * omdzz[43]; - phidzz[p45[5]] = +3 * omdzz[3] - 18 * omdzz[4] + 9 * omdzz[5] + 6 * omdzz[24] - - 18 * omdzz[25] + 3 * omdzz[26] + 6 * omdzz[27] - 9 * omdzz[28] + - 6 * omdzz[29] + 6 * omdzz[36] + 6 * omdzz[37] - 9 * omdzz[38] + - 6 * omdzz[39] + 3 * omdzz[40] - 18 * omdzz[41] + 6 * omdzz[42] + - 6 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[6]] = +9 * omdzz[6] - 18 * omdzz[7] + 3 * omdzz[8] + 9 * omdzz[24] - - 6 * omdzz[25] - 6 * omdzz[26] - 27 * omdzz[27] + 9 * omdzz[28] + - 12 * omdzz[29] + 9 * omdzz[30] - 6 * omdzz[31] - 6 * omdzz[32] - - 27 * omdzz[33] + 9 * omdzz[34] + 12 * omdzz[35] - 6 * omdzz[42] - - 6 * omdzz[43] + 18 * omdzz[44]; - phidzz[p45[7]] = -18 * omdzz[6] + 84 * omdzz[7] - 18 * omdzz[8] - 30 * omdzz[24] + - 30 * omdzz[26] - 6 * omdzz[27] + 12 * omdzz[28] - 36 * omdzz[29] - - 30 * omdzz[30] + 30 * omdzz[32] - 6 * omdzz[33] + 12 * omdzz[34] - - 36 * omdzz[35] + 24 * omdzz[44]; - phidzz[p45[8]] = +3 * omdzz[6] - 18 * omdzz[7] + 9 * omdzz[8] + 6 * omdzz[24] + - 6 * omdzz[25] - 9 * omdzz[26] + 6 * omdzz[27] + 3 * omdzz[28] - - 18 * omdzz[29] + 6 * omdzz[30] + 6 * omdzz[31] - 9 * omdzz[32] + - 6 * omdzz[33] + 3 * omdzz[34] - 18 * omdzz[35] + 6 * omdzz[42] + - 6 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[9]] = +9 * omdzz[9] - 18 * omdzz[10] + 3 * omdzz[11] - 27 * omdzz[18] + - 12 * omdzz[19] + 9 * omdzz[20] + 9 * omdzz[21] - 6 * omdzz[22] - - 6 * omdzz[23] - 3 * omdzz[36] + 18 * omdzz[37] - 6 * omdzz[38] + - 9 * omdzz[39] - 27 * omdzz[40] + 12 * omdzz[41] - 6 * omdzz[42] + - 18 * omdzz[43] - 6 * omdzz[44]; - phidzz[p45[10]] = -18 * omdzz[9] + 84 * omdzz[10] - 18 * omdzz[11] - 6 * omdzz[18] - - 36 * omdzz[19] + 12 * omdzz[20] - 30 * omdzz[21] + 30 * omdzz[22] - - 12 * omdzz[36] + 36 * omdzz[37] + 6 * omdzz[38] + 12 * omdzz[39] - - 6 * omdzz[40] - 36 * omdzz[41] - 24 * omdzz[42] + 24 * omdzz[43]; - phidzz[p45[11]] = +3 * omdzz[9] - 18 * omdzz[10] + 9 * omdzz[11] + 6 * omdzz[18] - - 18 * omdzz[19] + 3 * omdzz[20] + 6 * omdzz[21] - 9 * omdzz[22] + - 6 * omdzz[23] - 9 * omdzz[36] - 12 * omdzz[37] + 27 * omdzz[38] + - 3 * omdzz[39] + 6 * omdzz[40] - 18 * omdzz[41] - 18 * omdzz[42] + - 6 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[12]] = +9 * omdzz[12] - 18 * omdzz[13] + 3 * omdzz[14] + 9 * omdzz[18] - - 6 * omdzz[19] - 6 * omdzz[20] - 27 * omdzz[21] + 9 * omdzz[22] + - 12 * omdzz[23] - 3 * omdzz[30] + 18 * omdzz[31] - 6 * omdzz[32] + - 9 * omdzz[33] - 27 * omdzz[34] + 12 * omdzz[35] - 6 * omdzz[42] - - 6 * omdzz[43] + 18 * omdzz[44]; - phidzz[p45[13]] = -18 * omdzz[12] + 84 * omdzz[13] - 18 * omdzz[14] - 30 * omdzz[18] + - 30 * omdzz[20] - 6 * omdzz[21] + 12 * omdzz[22] - 36 * omdzz[23] - - 12 * omdzz[30] + 36 * omdzz[31] + 6 * omdzz[32] + 12 * omdzz[33] - - 6 * omdzz[34] - 36 * omdzz[35] - 24 * omdzz[42] + 24 * omdzz[44]; - phidzz[p45[14]] = +3 * omdzz[12] - 18 * omdzz[13] + 9 * omdzz[14] + 6 * omdzz[18] + - 6 * omdzz[19] - 9 * omdzz[20] + 6 * omdzz[21] + 3 * omdzz[22] - - 18 * omdzz[23] - 9 * omdzz[30] - 12 * omdzz[31] + 27 * omdzz[32] + - 3 * omdzz[33] + 6 * omdzz[34] - 18 * omdzz[35] - 18 * omdzz[42] + - 6 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[15]] = +9 * omdzz[15] - 18 * omdzz[16] + 3 * omdzz[17] - 3 * omdzz[18] + - 18 * omdzz[19] - 6 * omdzz[20] + 9 * omdzz[21] - 27 * omdzz[22] + - 12 * omdzz[23] - 3 * omdzz[24] + 18 * omdzz[25] - 6 * omdzz[26] + - 9 * omdzz[27] - 27 * omdzz[28] + 12 * omdzz[29] - 6 * omdzz[42] - - 6 * omdzz[43] + 18 * omdzz[44]; - phidzz[p45[16]] = -18 * omdzz[15] + 84 * omdzz[16] - 18 * omdzz[17] - 12 * omdzz[18] + - 36 * omdzz[19] + 6 * omdzz[20] + 12 * omdzz[21] - 6 * omdzz[22] - - 36 * omdzz[23] - 12 * omdzz[24] + 36 * omdzz[25] + 6 * omdzz[26] + - 12 * omdzz[27] - 6 * omdzz[28] - 36 * omdzz[29] - 24 * omdzz[43] + - 24 * omdzz[44]; - phidzz[p45[17]] = +3 * omdzz[15] - 18 * omdzz[16] + 9 * omdzz[17] - 9 * omdzz[18] - - 12 * omdzz[19] + 27 * omdzz[20] + 3 * omdzz[21] + 6 * omdzz[22] - - 18 * omdzz[23] - 9 * omdzz[24] - 12 * omdzz[25] + 27 * omdzz[26] + - 3 * omdzz[27] + 6 * omdzz[28] - 18 * omdzz[29] + 6 * omdzz[42] - - 18 * omdzz[43] + 6 * omdzz[44]; - phidzz[p45[18]] = +90 * omdzz[18] - 30 * omdzz[19] - 45 * omdzz[20] - 30 * omdzz[21] + - 15 * omdzz[22] + 30 * omdzz[23] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[19]] = -30 * omdzz[18] + 120 * omdzz[19] - 30 * omdzz[20] + 30 * omdzz[21] - - 60 * omdzz[22] + 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; - phidzz[p45[20]] = -45 * omdzz[18] - 30 * omdzz[19] + 90 * omdzz[20] + 15 * omdzz[21] + - 15 * omdzz[22] - 60 * omdzz[23] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[21]] = -30 * omdzz[18] + 30 * omdzz[19] + 15 * omdzz[20] + 90 * omdzz[21] - - 45 * omdzz[22] - 30 * omdzz[23] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[22]] = +15 * omdzz[18] - 60 * omdzz[19] + 15 * omdzz[20] - 45 * omdzz[21] + - 90 * omdzz[22] - 30 * omdzz[23] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[23]] = +30 * omdzz[18] - 60 * omdzz[20] - 30 * omdzz[21] - 30 * omdzz[22] + - 120 * omdzz[23] + 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; - phidzz[p45[24]] = +90 * omdzz[24] - 30 * omdzz[25] - 45 * omdzz[26] - 30 * omdzz[27] + - 15 * omdzz[28] + 30 * omdzz[29] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[25]] = -30 * omdzz[24] + 120 * omdzz[25] - 30 * omdzz[26] + 30 * omdzz[27] - - 60 * omdzz[28] - 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; - phidzz[p45[26]] = -45 * omdzz[24] - 30 * omdzz[25] + 90 * omdzz[26] + 15 * omdzz[27] + - 15 * omdzz[28] - 60 * omdzz[29] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[27]] = -30 * omdzz[24] + 30 * omdzz[25] + 15 * omdzz[26] + 90 * omdzz[27] - - 45 * omdzz[28] - 30 * omdzz[29] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[28]] = +15 * omdzz[24] - 60 * omdzz[25] + 15 * omdzz[26] - 45 * omdzz[27] + - 90 * omdzz[28] - 30 * omdzz[29] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[29]] = +30 * omdzz[24] - 60 * omdzz[26] - 30 * omdzz[27] - 30 * omdzz[28] + - 120 * omdzz[29] - 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; - phidzz[p45[30]] = +90 * omdzz[30] - 30 * omdzz[31] - 45 * omdzz[32] - 30 * omdzz[33] + - 15 * omdzz[34] + 30 * omdzz[35] - 45 * omdzz[42] + 15 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[31]] = -30 * omdzz[30] + 120 * omdzz[31] - 30 * omdzz[32] + 30 * omdzz[33] - - 60 * omdzz[34] - 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; - phidzz[p45[32]] = -45 * omdzz[30] - 30 * omdzz[31] + 90 * omdzz[32] + 15 * omdzz[33] + - 15 * omdzz[34] - 60 * omdzz[35] - 45 * omdzz[42] + 15 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[33]] = -30 * omdzz[30] + 30 * omdzz[31] + 15 * omdzz[32] + 90 * omdzz[33] - - 45 * omdzz[34] - 30 * omdzz[35] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[34]] = +15 * omdzz[30] - 60 * omdzz[31] + 15 * omdzz[32] - 45 * omdzz[33] + - 90 * omdzz[34] - 30 * omdzz[35] + 15 * omdzz[42] + 15 * omdzz[43] - - 45 * omdzz[44]; - phidzz[p45[35]] = +30 * omdzz[30] - 60 * omdzz[32] - 30 * omdzz[33] - 30 * omdzz[34] + - 120 * omdzz[35] + 30 * omdzz[42] - 30 * omdzz[43] - 30 * omdzz[44]; - phidzz[p45[36]] = +90 * omdzz[36] - 30 * omdzz[37] - 45 * omdzz[38] - 30 * omdzz[39] + - 15 * omdzz[40] + 30 * omdzz[41] - 45 * omdzz[42] + 15 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[37]] = -30 * omdzz[36] + 120 * omdzz[37] - 30 * omdzz[38] + 30 * omdzz[39] - - 60 * omdzz[40] - 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; - phidzz[p45[38]] = -45 * omdzz[36] - 30 * omdzz[37] + 90 * omdzz[38] + 15 * omdzz[39] + - 15 * omdzz[40] - 60 * omdzz[41] - 45 * omdzz[42] + 15 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[39]] = -30 * omdzz[36] + 30 * omdzz[37] + 15 * omdzz[38] + 90 * omdzz[39] - - 45 * omdzz[40] - 30 * omdzz[41] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[40]] = +15 * omdzz[36] - 60 * omdzz[37] + 15 * omdzz[38] - 45 * omdzz[39] + - 90 * omdzz[40] - 30 * omdzz[41] + 15 * omdzz[42] - 45 * omdzz[43] + - 15 * omdzz[44]; - phidzz[p45[41]] = +30 * omdzz[36] - 60 * omdzz[38] - 30 * omdzz[39] - 30 * omdzz[40] + - 120 * omdzz[41] + 30 * omdzz[42] - 30 * omdzz[43] - 30 * omdzz[44]; + phidzz[p45[0]] = +9 * omdzz[0] - 18 * omdzz[1] + 3 * omdzz[2] - 27 * omdzz[30] + 12 * omdzz[31] + 9 * omdzz[32] + 9 * omdzz[33] - 6 * omdzz[34] - 6 * omdzz[35] - 27 * omdzz[36] + + 12 * omdzz[37] + 9 * omdzz[38] + 9 * omdzz[39] - 6 * omdzz[40] - 6 * omdzz[41] + 18 * omdzz[42] - 6 * omdzz[43] - 6 * omdzz[44]; + phidzz[p45[1]] = -18 * omdzz[0] + 84 * omdzz[1] - 18 * omdzz[2] - 6 * omdzz[30] - 36 * omdzz[31] + 12 * omdzz[32] - 30 * omdzz[33] + 30 * omdzz[34] - 6 * omdzz[36] - 36 * omdzz[37] + + 12 * omdzz[38] - 30 * omdzz[39] + 30 * omdzz[40] + 24 * omdzz[42]; + phidzz[p45[2]] = +3 * omdzz[0] - 18 * omdzz[1] + 9 * omdzz[2] + 6 * omdzz[30] - 18 * omdzz[31] + 3 * omdzz[32] + 6 * omdzz[33] - 9 * omdzz[34] + 6 * omdzz[35] + 6 * omdzz[36] - + 18 * omdzz[37] + 3 * omdzz[38] + 6 * omdzz[39] - 9 * omdzz[40] + 6 * omdzz[41] + 6 * omdzz[42] + 6 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[3]] = +9 * omdzz[3] - 18 * omdzz[4] + 3 * omdzz[5] - 27 * omdzz[24] + 12 * omdzz[25] + 9 * omdzz[26] + 9 * omdzz[27] - 6 * omdzz[28] - 6 * omdzz[29] + 9 * omdzz[36] - + 6 * omdzz[37] - 6 * omdzz[38] - 27 * omdzz[39] + 9 * omdzz[40] + 12 * omdzz[41] - 6 * omdzz[42] + 18 * omdzz[43] - 6 * omdzz[44]; + phidzz[p45[4]] = -18 * omdzz[3] + 84 * omdzz[4] - 18 * omdzz[5] - 6 * omdzz[24] - 36 * omdzz[25] + 12 * omdzz[26] - 30 * omdzz[27] + 30 * omdzz[28] - 30 * omdzz[36] + 30 * omdzz[38] - + 6 * omdzz[39] + 12 * omdzz[40] - 36 * omdzz[41] + 24 * omdzz[43]; + phidzz[p45[5]] = +3 * omdzz[3] - 18 * omdzz[4] + 9 * omdzz[5] + 6 * omdzz[24] - 18 * omdzz[25] + 3 * omdzz[26] + 6 * omdzz[27] - 9 * omdzz[28] + 6 * omdzz[29] + 6 * omdzz[36] + 6 * omdzz[37] - + 9 * omdzz[38] + 6 * omdzz[39] + 3 * omdzz[40] - 18 * omdzz[41] + 6 * omdzz[42] + 6 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[6]] = +9 * omdzz[6] - 18 * omdzz[7] + 3 * omdzz[8] + 9 * omdzz[24] - 6 * omdzz[25] - 6 * omdzz[26] - 27 * omdzz[27] + 9 * omdzz[28] + 12 * omdzz[29] + 9 * omdzz[30] - + 6 * omdzz[31] - 6 * omdzz[32] - 27 * omdzz[33] + 9 * omdzz[34] + 12 * omdzz[35] - 6 * omdzz[42] - 6 * omdzz[43] + 18 * omdzz[44]; + phidzz[p45[7]] = -18 * omdzz[6] + 84 * omdzz[7] - 18 * omdzz[8] - 30 * omdzz[24] + 30 * omdzz[26] - 6 * omdzz[27] + 12 * omdzz[28] - 36 * omdzz[29] - 30 * omdzz[30] + 30 * omdzz[32] - + 6 * omdzz[33] + 12 * omdzz[34] - 36 * omdzz[35] + 24 * omdzz[44]; + phidzz[p45[8]] = +3 * omdzz[6] - 18 * omdzz[7] + 9 * omdzz[8] + 6 * omdzz[24] + 6 * omdzz[25] - 9 * omdzz[26] + 6 * omdzz[27] + 3 * omdzz[28] - 18 * omdzz[29] + 6 * omdzz[30] + 6 * omdzz[31] - + 9 * omdzz[32] + 6 * omdzz[33] + 3 * omdzz[34] - 18 * omdzz[35] + 6 * omdzz[42] + 6 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[9]] = +9 * omdzz[9] - 18 * omdzz[10] + 3 * omdzz[11] - 27 * omdzz[18] + 12 * omdzz[19] + 9 * omdzz[20] + 9 * omdzz[21] - 6 * omdzz[22] - 6 * omdzz[23] - 3 * omdzz[36] + + 18 * omdzz[37] - 6 * omdzz[38] + 9 * omdzz[39] - 27 * omdzz[40] + 12 * omdzz[41] - 6 * omdzz[42] + 18 * omdzz[43] - 6 * omdzz[44]; + phidzz[p45[10]] = -18 * omdzz[9] + 84 * omdzz[10] - 18 * omdzz[11] - 6 * omdzz[18] - 36 * omdzz[19] + 12 * omdzz[20] - 30 * omdzz[21] + 30 * omdzz[22] - 12 * omdzz[36] + 36 * omdzz[37] + + 6 * omdzz[38] + 12 * omdzz[39] - 6 * omdzz[40] - 36 * omdzz[41] - 24 * omdzz[42] + 24 * omdzz[43]; + phidzz[p45[11]] = +3 * omdzz[9] - 18 * omdzz[10] + 9 * omdzz[11] + 6 * omdzz[18] - 18 * omdzz[19] + 3 * omdzz[20] + 6 * omdzz[21] - 9 * omdzz[22] + 6 * omdzz[23] - 9 * omdzz[36] - + 12 * omdzz[37] + 27 * omdzz[38] + 3 * omdzz[39] + 6 * omdzz[40] - 18 * omdzz[41] - 18 * omdzz[42] + 6 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[12]] = +9 * omdzz[12] - 18 * omdzz[13] + 3 * omdzz[14] + 9 * omdzz[18] - 6 * omdzz[19] - 6 * omdzz[20] - 27 * omdzz[21] + 9 * omdzz[22] + 12 * omdzz[23] - 3 * omdzz[30] + + 18 * omdzz[31] - 6 * omdzz[32] + 9 * omdzz[33] - 27 * omdzz[34] + 12 * omdzz[35] - 6 * omdzz[42] - 6 * omdzz[43] + 18 * omdzz[44]; + phidzz[p45[13]] = -18 * omdzz[12] + 84 * omdzz[13] - 18 * omdzz[14] - 30 * omdzz[18] + 30 * omdzz[20] - 6 * omdzz[21] + 12 * omdzz[22] - 36 * omdzz[23] - 12 * omdzz[30] + 36 * omdzz[31] + + 6 * omdzz[32] + 12 * omdzz[33] - 6 * omdzz[34] - 36 * omdzz[35] - 24 * omdzz[42] + 24 * omdzz[44]; + phidzz[p45[14]] = +3 * omdzz[12] - 18 * omdzz[13] + 9 * omdzz[14] + 6 * omdzz[18] + 6 * omdzz[19] - 9 * omdzz[20] + 6 * omdzz[21] + 3 * omdzz[22] - 18 * omdzz[23] - 9 * omdzz[30] - + 12 * omdzz[31] + 27 * omdzz[32] + 3 * omdzz[33] + 6 * omdzz[34] - 18 * omdzz[35] - 18 * omdzz[42] + 6 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[15]] = +9 * omdzz[15] - 18 * omdzz[16] + 3 * omdzz[17] - 3 * omdzz[18] + 18 * omdzz[19] - 6 * omdzz[20] + 9 * omdzz[21] - 27 * omdzz[22] + 12 * omdzz[23] - 3 * omdzz[24] + + 18 * omdzz[25] - 6 * omdzz[26] + 9 * omdzz[27] - 27 * omdzz[28] + 12 * omdzz[29] - 6 * omdzz[42] - 6 * omdzz[43] + 18 * omdzz[44]; + phidzz[p45[16]] = -18 * omdzz[15] + 84 * omdzz[16] - 18 * omdzz[17] - 12 * omdzz[18] + 36 * omdzz[19] + 6 * omdzz[20] + 12 * omdzz[21] - 6 * omdzz[22] - 36 * omdzz[23] - 12 * omdzz[24] + + 36 * omdzz[25] + 6 * omdzz[26] + 12 * omdzz[27] - 6 * omdzz[28] - 36 * omdzz[29] - 24 * omdzz[43] + 24 * omdzz[44]; + phidzz[p45[17]] = +3 * omdzz[15] - 18 * omdzz[16] + 9 * omdzz[17] - 9 * omdzz[18] - 12 * omdzz[19] + 27 * omdzz[20] + 3 * omdzz[21] + 6 * omdzz[22] - 18 * omdzz[23] - 9 * omdzz[24] - + 12 * omdzz[25] + 27 * omdzz[26] + 3 * omdzz[27] + 6 * omdzz[28] - 18 * omdzz[29] + 6 * omdzz[42] - 18 * omdzz[43] + 6 * omdzz[44]; + phidzz[p45[18]] = +90 * omdzz[18] - 30 * omdzz[19] - 45 * omdzz[20] - 30 * omdzz[21] + 15 * omdzz[22] + 30 * omdzz[23] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[19]] = -30 * omdzz[18] + 120 * omdzz[19] - 30 * omdzz[20] + 30 * omdzz[21] - 60 * omdzz[22] + 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; + phidzz[p45[20]] = -45 * omdzz[18] - 30 * omdzz[19] + 90 * omdzz[20] + 15 * omdzz[21] + 15 * omdzz[22] - 60 * omdzz[23] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[21]] = -30 * omdzz[18] + 30 * omdzz[19] + 15 * omdzz[20] + 90 * omdzz[21] - 45 * omdzz[22] - 30 * omdzz[23] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[22]] = +15 * omdzz[18] - 60 * omdzz[19] + 15 * omdzz[20] - 45 * omdzz[21] + 90 * omdzz[22] - 30 * omdzz[23] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[23]] = +30 * omdzz[18] - 60 * omdzz[20] - 30 * omdzz[21] - 30 * omdzz[22] + 120 * omdzz[23] + 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; + phidzz[p45[24]] = +90 * omdzz[24] - 30 * omdzz[25] - 45 * omdzz[26] - 30 * omdzz[27] + 15 * omdzz[28] + 30 * omdzz[29] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[25]] = -30 * omdzz[24] + 120 * omdzz[25] - 30 * omdzz[26] + 30 * omdzz[27] - 60 * omdzz[28] - 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; + phidzz[p45[26]] = -45 * omdzz[24] - 30 * omdzz[25] + 90 * omdzz[26] + 15 * omdzz[27] + 15 * omdzz[28] - 60 * omdzz[29] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[27]] = -30 * omdzz[24] + 30 * omdzz[25] + 15 * omdzz[26] + 90 * omdzz[27] - 45 * omdzz[28] - 30 * omdzz[29] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[28]] = +15 * omdzz[24] - 60 * omdzz[25] + 15 * omdzz[26] - 45 * omdzz[27] + 90 * omdzz[28] - 30 * omdzz[29] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[29]] = +30 * omdzz[24] - 60 * omdzz[26] - 30 * omdzz[27] - 30 * omdzz[28] + 120 * omdzz[29] - 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; + phidzz[p45[30]] = +90 * omdzz[30] - 30 * omdzz[31] - 45 * omdzz[32] - 30 * omdzz[33] + 15 * omdzz[34] + 30 * omdzz[35] - 45 * omdzz[42] + 15 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[31]] = -30 * omdzz[30] + 120 * omdzz[31] - 30 * omdzz[32] + 30 * omdzz[33] - 60 * omdzz[34] - 30 * omdzz[42] - 30 * omdzz[43] + 30 * omdzz[44]; + phidzz[p45[32]] = -45 * omdzz[30] - 30 * omdzz[31] + 90 * omdzz[32] + 15 * omdzz[33] + 15 * omdzz[34] - 60 * omdzz[35] - 45 * omdzz[42] + 15 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[33]] = -30 * omdzz[30] + 30 * omdzz[31] + 15 * omdzz[32] + 90 * omdzz[33] - 45 * omdzz[34] - 30 * omdzz[35] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[34]] = +15 * omdzz[30] - 60 * omdzz[31] + 15 * omdzz[32] - 45 * omdzz[33] + 90 * omdzz[34] - 30 * omdzz[35] + 15 * omdzz[42] + 15 * omdzz[43] - 45 * omdzz[44]; + phidzz[p45[35]] = +30 * omdzz[30] - 60 * omdzz[32] - 30 * omdzz[33] - 30 * omdzz[34] + 120 * omdzz[35] + 30 * omdzz[42] - 30 * omdzz[43] - 30 * omdzz[44]; + phidzz[p45[36]] = +90 * omdzz[36] - 30 * omdzz[37] - 45 * omdzz[38] - 30 * omdzz[39] + 15 * omdzz[40] + 30 * omdzz[41] - 45 * omdzz[42] + 15 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[37]] = -30 * omdzz[36] + 120 * omdzz[37] - 30 * omdzz[38] + 30 * omdzz[39] - 60 * omdzz[40] - 30 * omdzz[42] + 30 * omdzz[43] - 30 * omdzz[44]; + phidzz[p45[38]] = -45 * omdzz[36] - 30 * omdzz[37] + 90 * omdzz[38] + 15 * omdzz[39] + 15 * omdzz[40] - 60 * omdzz[41] - 45 * omdzz[42] + 15 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[39]] = -30 * omdzz[36] + 30 * omdzz[37] + 15 * omdzz[38] + 90 * omdzz[39] - 45 * omdzz[40] - 30 * omdzz[41] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[40]] = +15 * omdzz[36] - 60 * omdzz[37] + 15 * omdzz[38] - 45 * omdzz[39] + 90 * omdzz[40] - 30 * omdzz[41] + 15 * omdzz[42] - 45 * omdzz[43] + 15 * omdzz[44]; + phidzz[p45[41]] = +30 * omdzz[36] - 60 * omdzz[38] - 30 * omdzz[39] - 30 * omdzz[40] + 120 * omdzz[41] + 30 * omdzz[42] - 30 * omdzz[43] - 30 * omdzz[44]; phidzz[p45[42]] = +90 * omdzz[42] - 30 * omdzz[43] - 30 * omdzz[44]; phidzz[p45[43]] = -30 * omdzz[42] + 90 * omdzz[43] - 30 * omdzz[44]; phidzz[p45[44]] = -30 * omdzz[42] - 30 * omdzz[43] + 90 * omdzz[44]; @@ -3072,155 +2126,66 @@ namespace Fem2D { R3 phidxy[45]; if (whatd & Fop_dxy) { - phidxy[p45[0]] = +9 * omdxy[0] - 18 * omdxy[1] + 3 * omdxy[2] - 27 * omdxy[30] + - 12 * omdxy[31] + 9 * omdxy[32] + 9 * omdxy[33] - 6 * omdxy[34] - - 6 * omdxy[35] - 27 * omdxy[36] + 12 * omdxy[37] + 9 * omdxy[38] + - 9 * omdxy[39] - 6 * omdxy[40] - 6 * omdxy[41] + 18 * omdxy[42] - - 6 * omdxy[43] - 6 * omdxy[44]; - phidxy[p45[1]] = -18 * omdxy[0] + 84 * omdxy[1] - 18 * omdxy[2] - 6 * omdxy[30] - - 36 * omdxy[31] + 12 * omdxy[32] - 30 * omdxy[33] + 30 * omdxy[34] - - 6 * omdxy[36] - 36 * omdxy[37] + 12 * omdxy[38] - 30 * omdxy[39] + - 30 * omdxy[40] + 24 * omdxy[42]; - phidxy[p45[2]] = +3 * omdxy[0] - 18 * omdxy[1] + 9 * omdxy[2] + 6 * omdxy[30] - - 18 * omdxy[31] + 3 * omdxy[32] + 6 * omdxy[33] - 9 * omdxy[34] + - 6 * omdxy[35] + 6 * omdxy[36] - 18 * omdxy[37] + 3 * omdxy[38] + - 6 * omdxy[39] - 9 * omdxy[40] + 6 * omdxy[41] + 6 * omdxy[42] + - 6 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[3]] = +9 * omdxy[3] - 18 * omdxy[4] + 3 * omdxy[5] - 27 * omdxy[24] + - 12 * omdxy[25] + 9 * omdxy[26] + 9 * omdxy[27] - 6 * omdxy[28] - - 6 * omdxy[29] + 9 * omdxy[36] - 6 * omdxy[37] - 6 * omdxy[38] - - 27 * omdxy[39] + 9 * omdxy[40] + 12 * omdxy[41] - 6 * omdxy[42] + - 18 * omdxy[43] - 6 * omdxy[44]; - phidxy[p45[4]] = -18 * omdxy[3] + 84 * omdxy[4] - 18 * omdxy[5] - 6 * omdxy[24] - - 36 * omdxy[25] + 12 * omdxy[26] - 30 * omdxy[27] + 30 * omdxy[28] - - 30 * omdxy[36] + 30 * omdxy[38] - 6 * omdxy[39] + 12 * omdxy[40] - - 36 * omdxy[41] + 24 * omdxy[43]; - phidxy[p45[5]] = +3 * omdxy[3] - 18 * omdxy[4] + 9 * omdxy[5] + 6 * omdxy[24] - - 18 * omdxy[25] + 3 * omdxy[26] + 6 * omdxy[27] - 9 * omdxy[28] + - 6 * omdxy[29] + 6 * omdxy[36] + 6 * omdxy[37] - 9 * omdxy[38] + - 6 * omdxy[39] + 3 * omdxy[40] - 18 * omdxy[41] + 6 * omdxy[42] + - 6 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[6]] = +9 * omdxy[6] - 18 * omdxy[7] + 3 * omdxy[8] + 9 * omdxy[24] - - 6 * omdxy[25] - 6 * omdxy[26] - 27 * omdxy[27] + 9 * omdxy[28] + - 12 * omdxy[29] + 9 * omdxy[30] - 6 * omdxy[31] - 6 * omdxy[32] - - 27 * omdxy[33] + 9 * omdxy[34] + 12 * omdxy[35] - 6 * omdxy[42] - - 6 * omdxy[43] + 18 * omdxy[44]; - phidxy[p45[7]] = -18 * omdxy[6] + 84 * omdxy[7] - 18 * omdxy[8] - 30 * omdxy[24] + - 30 * omdxy[26] - 6 * omdxy[27] + 12 * omdxy[28] - 36 * omdxy[29] - - 30 * omdxy[30] + 30 * omdxy[32] - 6 * omdxy[33] + 12 * omdxy[34] - - 36 * omdxy[35] + 24 * omdxy[44]; - phidxy[p45[8]] = +3 * omdxy[6] - 18 * omdxy[7] + 9 * omdxy[8] + 6 * omdxy[24] + - 6 * omdxy[25] - 9 * omdxy[26] + 6 * omdxy[27] + 3 * omdxy[28] - - 18 * omdxy[29] + 6 * omdxy[30] + 6 * omdxy[31] - 9 * omdxy[32] + - 6 * omdxy[33] + 3 * omdxy[34] - 18 * omdxy[35] + 6 * omdxy[42] + - 6 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[9]] = +9 * omdxy[9] - 18 * omdxy[10] + 3 * omdxy[11] - 27 * omdxy[18] + - 12 * omdxy[19] + 9 * omdxy[20] + 9 * omdxy[21] - 6 * omdxy[22] - - 6 * omdxy[23] - 3 * omdxy[36] + 18 * omdxy[37] - 6 * omdxy[38] + - 9 * omdxy[39] - 27 * omdxy[40] + 12 * omdxy[41] - 6 * omdxy[42] + - 18 * omdxy[43] - 6 * omdxy[44]; - phidxy[p45[10]] = -18 * omdxy[9] + 84 * omdxy[10] - 18 * omdxy[11] - 6 * omdxy[18] - - 36 * omdxy[19] + 12 * omdxy[20] - 30 * omdxy[21] + 30 * omdxy[22] - - 12 * omdxy[36] + 36 * omdxy[37] + 6 * omdxy[38] + 12 * omdxy[39] - - 6 * omdxy[40] - 36 * omdxy[41] - 24 * omdxy[42] + 24 * omdxy[43]; - phidxy[p45[11]] = +3 * omdxy[9] - 18 * omdxy[10] + 9 * omdxy[11] + 6 * omdxy[18] - - 18 * omdxy[19] + 3 * omdxy[20] + 6 * omdxy[21] - 9 * omdxy[22] + - 6 * omdxy[23] - 9 * omdxy[36] - 12 * omdxy[37] + 27 * omdxy[38] + - 3 * omdxy[39] + 6 * omdxy[40] - 18 * omdxy[41] - 18 * omdxy[42] + - 6 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[12]] = +9 * omdxy[12] - 18 * omdxy[13] + 3 * omdxy[14] + 9 * omdxy[18] - - 6 * omdxy[19] - 6 * omdxy[20] - 27 * omdxy[21] + 9 * omdxy[22] + - 12 * omdxy[23] - 3 * omdxy[30] + 18 * omdxy[31] - 6 * omdxy[32] + - 9 * omdxy[33] - 27 * omdxy[34] + 12 * omdxy[35] - 6 * omdxy[42] - - 6 * omdxy[43] + 18 * omdxy[44]; - phidxy[p45[13]] = -18 * omdxy[12] + 84 * omdxy[13] - 18 * omdxy[14] - 30 * omdxy[18] + - 30 * omdxy[20] - 6 * omdxy[21] + 12 * omdxy[22] - 36 * omdxy[23] - - 12 * omdxy[30] + 36 * omdxy[31] + 6 * omdxy[32] + 12 * omdxy[33] - - 6 * omdxy[34] - 36 * omdxy[35] - 24 * omdxy[42] + 24 * omdxy[44]; - phidxy[p45[14]] = +3 * omdxy[12] - 18 * omdxy[13] + 9 * omdxy[14] + 6 * omdxy[18] + - 6 * omdxy[19] - 9 * omdxy[20] + 6 * omdxy[21] + 3 * omdxy[22] - - 18 * omdxy[23] - 9 * omdxy[30] - 12 * omdxy[31] + 27 * omdxy[32] + - 3 * omdxy[33] + 6 * omdxy[34] - 18 * omdxy[35] - 18 * omdxy[42] + - 6 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[15]] = +9 * omdxy[15] - 18 * omdxy[16] + 3 * omdxy[17] - 3 * omdxy[18] + - 18 * omdxy[19] - 6 * omdxy[20] + 9 * omdxy[21] - 27 * omdxy[22] + - 12 * omdxy[23] - 3 * omdxy[24] + 18 * omdxy[25] - 6 * omdxy[26] + - 9 * omdxy[27] - 27 * omdxy[28] + 12 * omdxy[29] - 6 * omdxy[42] - - 6 * omdxy[43] + 18 * omdxy[44]; - phidxy[p45[16]] = -18 * omdxy[15] + 84 * omdxy[16] - 18 * omdxy[17] - 12 * omdxy[18] + - 36 * omdxy[19] + 6 * omdxy[20] + 12 * omdxy[21] - 6 * omdxy[22] - - 36 * omdxy[23] - 12 * omdxy[24] + 36 * omdxy[25] + 6 * omdxy[26] + - 12 * omdxy[27] - 6 * omdxy[28] - 36 * omdxy[29] - 24 * omdxy[43] + - 24 * omdxy[44]; - phidxy[p45[17]] = +3 * omdxy[15] - 18 * omdxy[16] + 9 * omdxy[17] - 9 * omdxy[18] - - 12 * omdxy[19] + 27 * omdxy[20] + 3 * omdxy[21] + 6 * omdxy[22] - - 18 * omdxy[23] - 9 * omdxy[24] - 12 * omdxy[25] + 27 * omdxy[26] + - 3 * omdxy[27] + 6 * omdxy[28] - 18 * omdxy[29] + 6 * omdxy[42] - - 18 * omdxy[43] + 6 * omdxy[44]; - phidxy[p45[18]] = +90 * omdxy[18] - 30 * omdxy[19] - 45 * omdxy[20] - 30 * omdxy[21] + - 15 * omdxy[22] + 30 * omdxy[23] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[19]] = -30 * omdxy[18] + 120 * omdxy[19] - 30 * omdxy[20] + 30 * omdxy[21] - - 60 * omdxy[22] + 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; - phidxy[p45[20]] = -45 * omdxy[18] - 30 * omdxy[19] + 90 * omdxy[20] + 15 * omdxy[21] + - 15 * omdxy[22] - 60 * omdxy[23] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[21]] = -30 * omdxy[18] + 30 * omdxy[19] + 15 * omdxy[20] + 90 * omdxy[21] - - 45 * omdxy[22] - 30 * omdxy[23] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[22]] = +15 * omdxy[18] - 60 * omdxy[19] + 15 * omdxy[20] - 45 * omdxy[21] + - 90 * omdxy[22] - 30 * omdxy[23] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[23]] = +30 * omdxy[18] - 60 * omdxy[20] - 30 * omdxy[21] - 30 * omdxy[22] + - 120 * omdxy[23] + 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; - phidxy[p45[24]] = +90 * omdxy[24] - 30 * omdxy[25] - 45 * omdxy[26] - 30 * omdxy[27] + - 15 * omdxy[28] + 30 * omdxy[29] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[25]] = -30 * omdxy[24] + 120 * omdxy[25] - 30 * omdxy[26] + 30 * omdxy[27] - - 60 * omdxy[28] - 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; - phidxy[p45[26]] = -45 * omdxy[24] - 30 * omdxy[25] + 90 * omdxy[26] + 15 * omdxy[27] + - 15 * omdxy[28] - 60 * omdxy[29] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[27]] = -30 * omdxy[24] + 30 * omdxy[25] + 15 * omdxy[26] + 90 * omdxy[27] - - 45 * omdxy[28] - 30 * omdxy[29] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[28]] = +15 * omdxy[24] - 60 * omdxy[25] + 15 * omdxy[26] - 45 * omdxy[27] + - 90 * omdxy[28] - 30 * omdxy[29] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[29]] = +30 * omdxy[24] - 60 * omdxy[26] - 30 * omdxy[27] - 30 * omdxy[28] + - 120 * omdxy[29] - 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; - phidxy[p45[30]] = +90 * omdxy[30] - 30 * omdxy[31] - 45 * omdxy[32] - 30 * omdxy[33] + - 15 * omdxy[34] + 30 * omdxy[35] - 45 * omdxy[42] + 15 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[31]] = -30 * omdxy[30] + 120 * omdxy[31] - 30 * omdxy[32] + 30 * omdxy[33] - - 60 * omdxy[34] - 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; - phidxy[p45[32]] = -45 * omdxy[30] - 30 * omdxy[31] + 90 * omdxy[32] + 15 * omdxy[33] + - 15 * omdxy[34] - 60 * omdxy[35] - 45 * omdxy[42] + 15 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[33]] = -30 * omdxy[30] + 30 * omdxy[31] + 15 * omdxy[32] + 90 * omdxy[33] - - 45 * omdxy[34] - 30 * omdxy[35] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[34]] = +15 * omdxy[30] - 60 * omdxy[31] + 15 * omdxy[32] - 45 * omdxy[33] + - 90 * omdxy[34] - 30 * omdxy[35] + 15 * omdxy[42] + 15 * omdxy[43] - - 45 * omdxy[44]; - phidxy[p45[35]] = +30 * omdxy[30] - 60 * omdxy[32] - 30 * omdxy[33] - 30 * omdxy[34] + - 120 * omdxy[35] + 30 * omdxy[42] - 30 * omdxy[43] - 30 * omdxy[44]; - phidxy[p45[36]] = +90 * omdxy[36] - 30 * omdxy[37] - 45 * omdxy[38] - 30 * omdxy[39] + - 15 * omdxy[40] + 30 * omdxy[41] - 45 * omdxy[42] + 15 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[37]] = -30 * omdxy[36] + 120 * omdxy[37] - 30 * omdxy[38] + 30 * omdxy[39] - - 60 * omdxy[40] - 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; - phidxy[p45[38]] = -45 * omdxy[36] - 30 * omdxy[37] + 90 * omdxy[38] + 15 * omdxy[39] + - 15 * omdxy[40] - 60 * omdxy[41] - 45 * omdxy[42] + 15 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[39]] = -30 * omdxy[36] + 30 * omdxy[37] + 15 * omdxy[38] + 90 * omdxy[39] - - 45 * omdxy[40] - 30 * omdxy[41] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[40]] = +15 * omdxy[36] - 60 * omdxy[37] + 15 * omdxy[38] - 45 * omdxy[39] + - 90 * omdxy[40] - 30 * omdxy[41] + 15 * omdxy[42] - 45 * omdxy[43] + - 15 * omdxy[44]; - phidxy[p45[41]] = +30 * omdxy[36] - 60 * omdxy[38] - 30 * omdxy[39] - 30 * omdxy[40] + - 120 * omdxy[41] + 30 * omdxy[42] - 30 * omdxy[43] - 30 * omdxy[44]; + phidxy[p45[0]] = +9 * omdxy[0] - 18 * omdxy[1] + 3 * omdxy[2] - 27 * omdxy[30] + 12 * omdxy[31] + 9 * omdxy[32] + 9 * omdxy[33] - 6 * omdxy[34] - 6 * omdxy[35] - 27 * omdxy[36] + + 12 * omdxy[37] + 9 * omdxy[38] + 9 * omdxy[39] - 6 * omdxy[40] - 6 * omdxy[41] + 18 * omdxy[42] - 6 * omdxy[43] - 6 * omdxy[44]; + phidxy[p45[1]] = -18 * omdxy[0] + 84 * omdxy[1] - 18 * omdxy[2] - 6 * omdxy[30] - 36 * omdxy[31] + 12 * omdxy[32] - 30 * omdxy[33] + 30 * omdxy[34] - 6 * omdxy[36] - 36 * omdxy[37] + + 12 * omdxy[38] - 30 * omdxy[39] + 30 * omdxy[40] + 24 * omdxy[42]; + phidxy[p45[2]] = +3 * omdxy[0] - 18 * omdxy[1] + 9 * omdxy[2] + 6 * omdxy[30] - 18 * omdxy[31] + 3 * omdxy[32] + 6 * omdxy[33] - 9 * omdxy[34] + 6 * omdxy[35] + 6 * omdxy[36] - + 18 * omdxy[37] + 3 * omdxy[38] + 6 * omdxy[39] - 9 * omdxy[40] + 6 * omdxy[41] + 6 * omdxy[42] + 6 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[3]] = +9 * omdxy[3] - 18 * omdxy[4] + 3 * omdxy[5] - 27 * omdxy[24] + 12 * omdxy[25] + 9 * omdxy[26] + 9 * omdxy[27] - 6 * omdxy[28] - 6 * omdxy[29] + 9 * omdxy[36] - + 6 * omdxy[37] - 6 * omdxy[38] - 27 * omdxy[39] + 9 * omdxy[40] + 12 * omdxy[41] - 6 * omdxy[42] + 18 * omdxy[43] - 6 * omdxy[44]; + phidxy[p45[4]] = -18 * omdxy[3] + 84 * omdxy[4] - 18 * omdxy[5] - 6 * omdxy[24] - 36 * omdxy[25] + 12 * omdxy[26] - 30 * omdxy[27] + 30 * omdxy[28] - 30 * omdxy[36] + 30 * omdxy[38] - + 6 * omdxy[39] + 12 * omdxy[40] - 36 * omdxy[41] + 24 * omdxy[43]; + phidxy[p45[5]] = +3 * omdxy[3] - 18 * omdxy[4] + 9 * omdxy[5] + 6 * omdxy[24] - 18 * omdxy[25] + 3 * omdxy[26] + 6 * omdxy[27] - 9 * omdxy[28] + 6 * omdxy[29] + 6 * omdxy[36] + 6 * omdxy[37] - + 9 * omdxy[38] + 6 * omdxy[39] + 3 * omdxy[40] - 18 * omdxy[41] + 6 * omdxy[42] + 6 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[6]] = +9 * omdxy[6] - 18 * omdxy[7] + 3 * omdxy[8] + 9 * omdxy[24] - 6 * omdxy[25] - 6 * omdxy[26] - 27 * omdxy[27] + 9 * omdxy[28] + 12 * omdxy[29] + 9 * omdxy[30] - + 6 * omdxy[31] - 6 * omdxy[32] - 27 * omdxy[33] + 9 * omdxy[34] + 12 * omdxy[35] - 6 * omdxy[42] - 6 * omdxy[43] + 18 * omdxy[44]; + phidxy[p45[7]] = -18 * omdxy[6] + 84 * omdxy[7] - 18 * omdxy[8] - 30 * omdxy[24] + 30 * omdxy[26] - 6 * omdxy[27] + 12 * omdxy[28] - 36 * omdxy[29] - 30 * omdxy[30] + 30 * omdxy[32] - + 6 * omdxy[33] + 12 * omdxy[34] - 36 * omdxy[35] + 24 * omdxy[44]; + phidxy[p45[8]] = +3 * omdxy[6] - 18 * omdxy[7] + 9 * omdxy[8] + 6 * omdxy[24] + 6 * omdxy[25] - 9 * omdxy[26] + 6 * omdxy[27] + 3 * omdxy[28] - 18 * omdxy[29] + 6 * omdxy[30] + 6 * omdxy[31] - + 9 * omdxy[32] + 6 * omdxy[33] + 3 * omdxy[34] - 18 * omdxy[35] + 6 * omdxy[42] + 6 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[9]] = +9 * omdxy[9] - 18 * omdxy[10] + 3 * omdxy[11] - 27 * omdxy[18] + 12 * omdxy[19] + 9 * omdxy[20] + 9 * omdxy[21] - 6 * omdxy[22] - 6 * omdxy[23] - 3 * omdxy[36] + + 18 * omdxy[37] - 6 * omdxy[38] + 9 * omdxy[39] - 27 * omdxy[40] + 12 * omdxy[41] - 6 * omdxy[42] + 18 * omdxy[43] - 6 * omdxy[44]; + phidxy[p45[10]] = -18 * omdxy[9] + 84 * omdxy[10] - 18 * omdxy[11] - 6 * omdxy[18] - 36 * omdxy[19] + 12 * omdxy[20] - 30 * omdxy[21] + 30 * omdxy[22] - 12 * omdxy[36] + 36 * omdxy[37] + + 6 * omdxy[38] + 12 * omdxy[39] - 6 * omdxy[40] - 36 * omdxy[41] - 24 * omdxy[42] + 24 * omdxy[43]; + phidxy[p45[11]] = +3 * omdxy[9] - 18 * omdxy[10] + 9 * omdxy[11] + 6 * omdxy[18] - 18 * omdxy[19] + 3 * omdxy[20] + 6 * omdxy[21] - 9 * omdxy[22] + 6 * omdxy[23] - 9 * omdxy[36] - + 12 * omdxy[37] + 27 * omdxy[38] + 3 * omdxy[39] + 6 * omdxy[40] - 18 * omdxy[41] - 18 * omdxy[42] + 6 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[12]] = +9 * omdxy[12] - 18 * omdxy[13] + 3 * omdxy[14] + 9 * omdxy[18] - 6 * omdxy[19] - 6 * omdxy[20] - 27 * omdxy[21] + 9 * omdxy[22] + 12 * omdxy[23] - 3 * omdxy[30] + + 18 * omdxy[31] - 6 * omdxy[32] + 9 * omdxy[33] - 27 * omdxy[34] + 12 * omdxy[35] - 6 * omdxy[42] - 6 * omdxy[43] + 18 * omdxy[44]; + phidxy[p45[13]] = -18 * omdxy[12] + 84 * omdxy[13] - 18 * omdxy[14] - 30 * omdxy[18] + 30 * omdxy[20] - 6 * omdxy[21] + 12 * omdxy[22] - 36 * omdxy[23] - 12 * omdxy[30] + 36 * omdxy[31] + + 6 * omdxy[32] + 12 * omdxy[33] - 6 * omdxy[34] - 36 * omdxy[35] - 24 * omdxy[42] + 24 * omdxy[44]; + phidxy[p45[14]] = +3 * omdxy[12] - 18 * omdxy[13] + 9 * omdxy[14] + 6 * omdxy[18] + 6 * omdxy[19] - 9 * omdxy[20] + 6 * omdxy[21] + 3 * omdxy[22] - 18 * omdxy[23] - 9 * omdxy[30] - + 12 * omdxy[31] + 27 * omdxy[32] + 3 * omdxy[33] + 6 * omdxy[34] - 18 * omdxy[35] - 18 * omdxy[42] + 6 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[15]] = +9 * omdxy[15] - 18 * omdxy[16] + 3 * omdxy[17] - 3 * omdxy[18] + 18 * omdxy[19] - 6 * omdxy[20] + 9 * omdxy[21] - 27 * omdxy[22] + 12 * omdxy[23] - 3 * omdxy[24] + + 18 * omdxy[25] - 6 * omdxy[26] + 9 * omdxy[27] - 27 * omdxy[28] + 12 * omdxy[29] - 6 * omdxy[42] - 6 * omdxy[43] + 18 * omdxy[44]; + phidxy[p45[16]] = -18 * omdxy[15] + 84 * omdxy[16] - 18 * omdxy[17] - 12 * omdxy[18] + 36 * omdxy[19] + 6 * omdxy[20] + 12 * omdxy[21] - 6 * omdxy[22] - 36 * omdxy[23] - 12 * omdxy[24] + + 36 * omdxy[25] + 6 * omdxy[26] + 12 * omdxy[27] - 6 * omdxy[28] - 36 * omdxy[29] - 24 * omdxy[43] + 24 * omdxy[44]; + phidxy[p45[17]] = +3 * omdxy[15] - 18 * omdxy[16] + 9 * omdxy[17] - 9 * omdxy[18] - 12 * omdxy[19] + 27 * omdxy[20] + 3 * omdxy[21] + 6 * omdxy[22] - 18 * omdxy[23] - 9 * omdxy[24] - + 12 * omdxy[25] + 27 * omdxy[26] + 3 * omdxy[27] + 6 * omdxy[28] - 18 * omdxy[29] + 6 * omdxy[42] - 18 * omdxy[43] + 6 * omdxy[44]; + phidxy[p45[18]] = +90 * omdxy[18] - 30 * omdxy[19] - 45 * omdxy[20] - 30 * omdxy[21] + 15 * omdxy[22] + 30 * omdxy[23] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[19]] = -30 * omdxy[18] + 120 * omdxy[19] - 30 * omdxy[20] + 30 * omdxy[21] - 60 * omdxy[22] + 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; + phidxy[p45[20]] = -45 * omdxy[18] - 30 * omdxy[19] + 90 * omdxy[20] + 15 * omdxy[21] + 15 * omdxy[22] - 60 * omdxy[23] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[21]] = -30 * omdxy[18] + 30 * omdxy[19] + 15 * omdxy[20] + 90 * omdxy[21] - 45 * omdxy[22] - 30 * omdxy[23] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[22]] = +15 * omdxy[18] - 60 * omdxy[19] + 15 * omdxy[20] - 45 * omdxy[21] + 90 * omdxy[22] - 30 * omdxy[23] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[23]] = +30 * omdxy[18] - 60 * omdxy[20] - 30 * omdxy[21] - 30 * omdxy[22] + 120 * omdxy[23] + 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; + phidxy[p45[24]] = +90 * omdxy[24] - 30 * omdxy[25] - 45 * omdxy[26] - 30 * omdxy[27] + 15 * omdxy[28] + 30 * omdxy[29] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[25]] = -30 * omdxy[24] + 120 * omdxy[25] - 30 * omdxy[26] + 30 * omdxy[27] - 60 * omdxy[28] - 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; + phidxy[p45[26]] = -45 * omdxy[24] - 30 * omdxy[25] + 90 * omdxy[26] + 15 * omdxy[27] + 15 * omdxy[28] - 60 * omdxy[29] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[27]] = -30 * omdxy[24] + 30 * omdxy[25] + 15 * omdxy[26] + 90 * omdxy[27] - 45 * omdxy[28] - 30 * omdxy[29] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[28]] = +15 * omdxy[24] - 60 * omdxy[25] + 15 * omdxy[26] - 45 * omdxy[27] + 90 * omdxy[28] - 30 * omdxy[29] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[29]] = +30 * omdxy[24] - 60 * omdxy[26] - 30 * omdxy[27] - 30 * omdxy[28] + 120 * omdxy[29] - 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; + phidxy[p45[30]] = +90 * omdxy[30] - 30 * omdxy[31] - 45 * omdxy[32] - 30 * omdxy[33] + 15 * omdxy[34] + 30 * omdxy[35] - 45 * omdxy[42] + 15 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[31]] = -30 * omdxy[30] + 120 * omdxy[31] - 30 * omdxy[32] + 30 * omdxy[33] - 60 * omdxy[34] - 30 * omdxy[42] - 30 * omdxy[43] + 30 * omdxy[44]; + phidxy[p45[32]] = -45 * omdxy[30] - 30 * omdxy[31] + 90 * omdxy[32] + 15 * omdxy[33] + 15 * omdxy[34] - 60 * omdxy[35] - 45 * omdxy[42] + 15 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[33]] = -30 * omdxy[30] + 30 * omdxy[31] + 15 * omdxy[32] + 90 * omdxy[33] - 45 * omdxy[34] - 30 * omdxy[35] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[34]] = +15 * omdxy[30] - 60 * omdxy[31] + 15 * omdxy[32] - 45 * omdxy[33] + 90 * omdxy[34] - 30 * omdxy[35] + 15 * omdxy[42] + 15 * omdxy[43] - 45 * omdxy[44]; + phidxy[p45[35]] = +30 * omdxy[30] - 60 * omdxy[32] - 30 * omdxy[33] - 30 * omdxy[34] + 120 * omdxy[35] + 30 * omdxy[42] - 30 * omdxy[43] - 30 * omdxy[44]; + phidxy[p45[36]] = +90 * omdxy[36] - 30 * omdxy[37] - 45 * omdxy[38] - 30 * omdxy[39] + 15 * omdxy[40] + 30 * omdxy[41] - 45 * omdxy[42] + 15 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[37]] = -30 * omdxy[36] + 120 * omdxy[37] - 30 * omdxy[38] + 30 * omdxy[39] - 60 * omdxy[40] - 30 * omdxy[42] + 30 * omdxy[43] - 30 * omdxy[44]; + phidxy[p45[38]] = -45 * omdxy[36] - 30 * omdxy[37] + 90 * omdxy[38] + 15 * omdxy[39] + 15 * omdxy[40] - 60 * omdxy[41] - 45 * omdxy[42] + 15 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[39]] = -30 * omdxy[36] + 30 * omdxy[37] + 15 * omdxy[38] + 90 * omdxy[39] - 45 * omdxy[40] - 30 * omdxy[41] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[40]] = +15 * omdxy[36] - 60 * omdxy[37] + 15 * omdxy[38] - 45 * omdxy[39] + 90 * omdxy[40] - 30 * omdxy[41] + 15 * omdxy[42] - 45 * omdxy[43] + 15 * omdxy[44]; + phidxy[p45[41]] = +30 * omdxy[36] - 60 * omdxy[38] - 30 * omdxy[39] - 30 * omdxy[40] + 120 * omdxy[41] + 30 * omdxy[42] - 30 * omdxy[43] - 30 * omdxy[44]; phidxy[p45[42]] = +90 * omdxy[42] - 30 * omdxy[43] - 30 * omdxy[44]; phidxy[p45[43]] = -30 * omdxy[42] + 90 * omdxy[43] - 30 * omdxy[44]; phidxy[p45[44]] = -30 * omdxy[42] - 30 * omdxy[43] + 90 * omdxy[44]; @@ -3234,155 +2199,66 @@ namespace Fem2D { R3 phidxz[45]; if (whatd & Fop_dxz) { - phidxz[p45[0]] = +9 * omdxz[0] - 18 * omdxz[1] + 3 * omdxz[2] - 27 * omdxz[30] + - 12 * omdxz[31] + 9 * omdxz[32] + 9 * omdxz[33] - 6 * omdxz[34] - - 6 * omdxz[35] - 27 * omdxz[36] + 12 * omdxz[37] + 9 * omdxz[38] + - 9 * omdxz[39] - 6 * omdxz[40] - 6 * omdxz[41] + 18 * omdxz[42] - - 6 * omdxz[43] - 6 * omdxz[44]; - phidxz[p45[1]] = -18 * omdxz[0] + 84 * omdxz[1] - 18 * omdxz[2] - 6 * omdxz[30] - - 36 * omdxz[31] + 12 * omdxz[32] - 30 * omdxz[33] + 30 * omdxz[34] - - 6 * omdxz[36] - 36 * omdxz[37] + 12 * omdxz[38] - 30 * omdxz[39] + - 30 * omdxz[40] + 24 * omdxz[42]; - phidxz[p45[2]] = +3 * omdxz[0] - 18 * omdxz[1] + 9 * omdxz[2] + 6 * omdxz[30] - - 18 * omdxz[31] + 3 * omdxz[32] + 6 * omdxz[33] - 9 * omdxz[34] + - 6 * omdxz[35] + 6 * omdxz[36] - 18 * omdxz[37] + 3 * omdxz[38] + - 6 * omdxz[39] - 9 * omdxz[40] + 6 * omdxz[41] + 6 * omdxz[42] + - 6 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[3]] = +9 * omdxz[3] - 18 * omdxz[4] + 3 * omdxz[5] - 27 * omdxz[24] + - 12 * omdxz[25] + 9 * omdxz[26] + 9 * omdxz[27] - 6 * omdxz[28] - - 6 * omdxz[29] + 9 * omdxz[36] - 6 * omdxz[37] - 6 * omdxz[38] - - 27 * omdxz[39] + 9 * omdxz[40] + 12 * omdxz[41] - 6 * omdxz[42] + - 18 * omdxz[43] - 6 * omdxz[44]; - phidxz[p45[4]] = -18 * omdxz[3] + 84 * omdxz[4] - 18 * omdxz[5] - 6 * omdxz[24] - - 36 * omdxz[25] + 12 * omdxz[26] - 30 * omdxz[27] + 30 * omdxz[28] - - 30 * omdxz[36] + 30 * omdxz[38] - 6 * omdxz[39] + 12 * omdxz[40] - - 36 * omdxz[41] + 24 * omdxz[43]; - phidxz[p45[5]] = +3 * omdxz[3] - 18 * omdxz[4] + 9 * omdxz[5] + 6 * omdxz[24] - - 18 * omdxz[25] + 3 * omdxz[26] + 6 * omdxz[27] - 9 * omdxz[28] + - 6 * omdxz[29] + 6 * omdxz[36] + 6 * omdxz[37] - 9 * omdxz[38] + - 6 * omdxz[39] + 3 * omdxz[40] - 18 * omdxz[41] + 6 * omdxz[42] + - 6 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[6]] = +9 * omdxz[6] - 18 * omdxz[7] + 3 * omdxz[8] + 9 * omdxz[24] - - 6 * omdxz[25] - 6 * omdxz[26] - 27 * omdxz[27] + 9 * omdxz[28] + - 12 * omdxz[29] + 9 * omdxz[30] - 6 * omdxz[31] - 6 * omdxz[32] - - 27 * omdxz[33] + 9 * omdxz[34] + 12 * omdxz[35] - 6 * omdxz[42] - - 6 * omdxz[43] + 18 * omdxz[44]; - phidxz[p45[7]] = -18 * omdxz[6] + 84 * omdxz[7] - 18 * omdxz[8] - 30 * omdxz[24] + - 30 * omdxz[26] - 6 * omdxz[27] + 12 * omdxz[28] - 36 * omdxz[29] - - 30 * omdxz[30] + 30 * omdxz[32] - 6 * omdxz[33] + 12 * omdxz[34] - - 36 * omdxz[35] + 24 * omdxz[44]; - phidxz[p45[8]] = +3 * omdxz[6] - 18 * omdxz[7] + 9 * omdxz[8] + 6 * omdxz[24] + - 6 * omdxz[25] - 9 * omdxz[26] + 6 * omdxz[27] + 3 * omdxz[28] - - 18 * omdxz[29] + 6 * omdxz[30] + 6 * omdxz[31] - 9 * omdxz[32] + - 6 * omdxz[33] + 3 * omdxz[34] - 18 * omdxz[35] + 6 * omdxz[42] + - 6 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[9]] = +9 * omdxz[9] - 18 * omdxz[10] + 3 * omdxz[11] - 27 * omdxz[18] + - 12 * omdxz[19] + 9 * omdxz[20] + 9 * omdxz[21] - 6 * omdxz[22] - - 6 * omdxz[23] - 3 * omdxz[36] + 18 * omdxz[37] - 6 * omdxz[38] + - 9 * omdxz[39] - 27 * omdxz[40] + 12 * omdxz[41] - 6 * omdxz[42] + - 18 * omdxz[43] - 6 * omdxz[44]; - phidxz[p45[10]] = -18 * omdxz[9] + 84 * omdxz[10] - 18 * omdxz[11] - 6 * omdxz[18] - - 36 * omdxz[19] + 12 * omdxz[20] - 30 * omdxz[21] + 30 * omdxz[22] - - 12 * omdxz[36] + 36 * omdxz[37] + 6 * omdxz[38] + 12 * omdxz[39] - - 6 * omdxz[40] - 36 * omdxz[41] - 24 * omdxz[42] + 24 * omdxz[43]; - phidxz[p45[11]] = +3 * omdxz[9] - 18 * omdxz[10] + 9 * omdxz[11] + 6 * omdxz[18] - - 18 * omdxz[19] + 3 * omdxz[20] + 6 * omdxz[21] - 9 * omdxz[22] + - 6 * omdxz[23] - 9 * omdxz[36] - 12 * omdxz[37] + 27 * omdxz[38] + - 3 * omdxz[39] + 6 * omdxz[40] - 18 * omdxz[41] - 18 * omdxz[42] + - 6 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[12]] = +9 * omdxz[12] - 18 * omdxz[13] + 3 * omdxz[14] + 9 * omdxz[18] - - 6 * omdxz[19] - 6 * omdxz[20] - 27 * omdxz[21] + 9 * omdxz[22] + - 12 * omdxz[23] - 3 * omdxz[30] + 18 * omdxz[31] - 6 * omdxz[32] + - 9 * omdxz[33] - 27 * omdxz[34] + 12 * omdxz[35] - 6 * omdxz[42] - - 6 * omdxz[43] + 18 * omdxz[44]; - phidxz[p45[13]] = -18 * omdxz[12] + 84 * omdxz[13] - 18 * omdxz[14] - 30 * omdxz[18] + - 30 * omdxz[20] - 6 * omdxz[21] + 12 * omdxz[22] - 36 * omdxz[23] - - 12 * omdxz[30] + 36 * omdxz[31] + 6 * omdxz[32] + 12 * omdxz[33] - - 6 * omdxz[34] - 36 * omdxz[35] - 24 * omdxz[42] + 24 * omdxz[44]; - phidxz[p45[14]] = +3 * omdxz[12] - 18 * omdxz[13] + 9 * omdxz[14] + 6 * omdxz[18] + - 6 * omdxz[19] - 9 * omdxz[20] + 6 * omdxz[21] + 3 * omdxz[22] - - 18 * omdxz[23] - 9 * omdxz[30] - 12 * omdxz[31] + 27 * omdxz[32] + - 3 * omdxz[33] + 6 * omdxz[34] - 18 * omdxz[35] - 18 * omdxz[42] + - 6 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[15]] = +9 * omdxz[15] - 18 * omdxz[16] + 3 * omdxz[17] - 3 * omdxz[18] + - 18 * omdxz[19] - 6 * omdxz[20] + 9 * omdxz[21] - 27 * omdxz[22] + - 12 * omdxz[23] - 3 * omdxz[24] + 18 * omdxz[25] - 6 * omdxz[26] + - 9 * omdxz[27] - 27 * omdxz[28] + 12 * omdxz[29] - 6 * omdxz[42] - - 6 * omdxz[43] + 18 * omdxz[44]; - phidxz[p45[16]] = -18 * omdxz[15] + 84 * omdxz[16] - 18 * omdxz[17] - 12 * omdxz[18] + - 36 * omdxz[19] + 6 * omdxz[20] + 12 * omdxz[21] - 6 * omdxz[22] - - 36 * omdxz[23] - 12 * omdxz[24] + 36 * omdxz[25] + 6 * omdxz[26] + - 12 * omdxz[27] - 6 * omdxz[28] - 36 * omdxz[29] - 24 * omdxz[43] + - 24 * omdxz[44]; - phidxz[p45[17]] = +3 * omdxz[15] - 18 * omdxz[16] + 9 * omdxz[17] - 9 * omdxz[18] - - 12 * omdxz[19] + 27 * omdxz[20] + 3 * omdxz[21] + 6 * omdxz[22] - - 18 * omdxz[23] - 9 * omdxz[24] - 12 * omdxz[25] + 27 * omdxz[26] + - 3 * omdxz[27] + 6 * omdxz[28] - 18 * omdxz[29] + 6 * omdxz[42] - - 18 * omdxz[43] + 6 * omdxz[44]; - phidxz[p45[18]] = +90 * omdxz[18] - 30 * omdxz[19] - 45 * omdxz[20] - 30 * omdxz[21] + - 15 * omdxz[22] + 30 * omdxz[23] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[19]] = -30 * omdxz[18] + 120 * omdxz[19] - 30 * omdxz[20] + 30 * omdxz[21] - - 60 * omdxz[22] + 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; - phidxz[p45[20]] = -45 * omdxz[18] - 30 * omdxz[19] + 90 * omdxz[20] + 15 * omdxz[21] + - 15 * omdxz[22] - 60 * omdxz[23] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[21]] = -30 * omdxz[18] + 30 * omdxz[19] + 15 * omdxz[20] + 90 * omdxz[21] - - 45 * omdxz[22] - 30 * omdxz[23] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[22]] = +15 * omdxz[18] - 60 * omdxz[19] + 15 * omdxz[20] - 45 * omdxz[21] + - 90 * omdxz[22] - 30 * omdxz[23] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[23]] = +30 * omdxz[18] - 60 * omdxz[20] - 30 * omdxz[21] - 30 * omdxz[22] + - 120 * omdxz[23] + 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; - phidxz[p45[24]] = +90 * omdxz[24] - 30 * omdxz[25] - 45 * omdxz[26] - 30 * omdxz[27] + - 15 * omdxz[28] + 30 * omdxz[29] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[25]] = -30 * omdxz[24] + 120 * omdxz[25] - 30 * omdxz[26] + 30 * omdxz[27] - - 60 * omdxz[28] - 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; - phidxz[p45[26]] = -45 * omdxz[24] - 30 * omdxz[25] + 90 * omdxz[26] + 15 * omdxz[27] + - 15 * omdxz[28] - 60 * omdxz[29] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[27]] = -30 * omdxz[24] + 30 * omdxz[25] + 15 * omdxz[26] + 90 * omdxz[27] - - 45 * omdxz[28] - 30 * omdxz[29] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[28]] = +15 * omdxz[24] - 60 * omdxz[25] + 15 * omdxz[26] - 45 * omdxz[27] + - 90 * omdxz[28] - 30 * omdxz[29] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[29]] = +30 * omdxz[24] - 60 * omdxz[26] - 30 * omdxz[27] - 30 * omdxz[28] + - 120 * omdxz[29] - 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; - phidxz[p45[30]] = +90 * omdxz[30] - 30 * omdxz[31] - 45 * omdxz[32] - 30 * omdxz[33] + - 15 * omdxz[34] + 30 * omdxz[35] - 45 * omdxz[42] + 15 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[31]] = -30 * omdxz[30] + 120 * omdxz[31] - 30 * omdxz[32] + 30 * omdxz[33] - - 60 * omdxz[34] - 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; - phidxz[p45[32]] = -45 * omdxz[30] - 30 * omdxz[31] + 90 * omdxz[32] + 15 * omdxz[33] + - 15 * omdxz[34] - 60 * omdxz[35] - 45 * omdxz[42] + 15 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[33]] = -30 * omdxz[30] + 30 * omdxz[31] + 15 * omdxz[32] + 90 * omdxz[33] - - 45 * omdxz[34] - 30 * omdxz[35] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[34]] = +15 * omdxz[30] - 60 * omdxz[31] + 15 * omdxz[32] - 45 * omdxz[33] + - 90 * omdxz[34] - 30 * omdxz[35] + 15 * omdxz[42] + 15 * omdxz[43] - - 45 * omdxz[44]; - phidxz[p45[35]] = +30 * omdxz[30] - 60 * omdxz[32] - 30 * omdxz[33] - 30 * omdxz[34] + - 120 * omdxz[35] + 30 * omdxz[42] - 30 * omdxz[43] - 30 * omdxz[44]; - phidxz[p45[36]] = +90 * omdxz[36] - 30 * omdxz[37] - 45 * omdxz[38] - 30 * omdxz[39] + - 15 * omdxz[40] + 30 * omdxz[41] - 45 * omdxz[42] + 15 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[37]] = -30 * omdxz[36] + 120 * omdxz[37] - 30 * omdxz[38] + 30 * omdxz[39] - - 60 * omdxz[40] - 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; - phidxz[p45[38]] = -45 * omdxz[36] - 30 * omdxz[37] + 90 * omdxz[38] + 15 * omdxz[39] + - 15 * omdxz[40] - 60 * omdxz[41] - 45 * omdxz[42] + 15 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[39]] = -30 * omdxz[36] + 30 * omdxz[37] + 15 * omdxz[38] + 90 * omdxz[39] - - 45 * omdxz[40] - 30 * omdxz[41] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[40]] = +15 * omdxz[36] - 60 * omdxz[37] + 15 * omdxz[38] - 45 * omdxz[39] + - 90 * omdxz[40] - 30 * omdxz[41] + 15 * omdxz[42] - 45 * omdxz[43] + - 15 * omdxz[44]; - phidxz[p45[41]] = +30 * omdxz[36] - 60 * omdxz[38] - 30 * omdxz[39] - 30 * omdxz[40] + - 120 * omdxz[41] + 30 * omdxz[42] - 30 * omdxz[43] - 30 * omdxz[44]; + phidxz[p45[0]] = +9 * omdxz[0] - 18 * omdxz[1] + 3 * omdxz[2] - 27 * omdxz[30] + 12 * omdxz[31] + 9 * omdxz[32] + 9 * omdxz[33] - 6 * omdxz[34] - 6 * omdxz[35] - 27 * omdxz[36] + + 12 * omdxz[37] + 9 * omdxz[38] + 9 * omdxz[39] - 6 * omdxz[40] - 6 * omdxz[41] + 18 * omdxz[42] - 6 * omdxz[43] - 6 * omdxz[44]; + phidxz[p45[1]] = -18 * omdxz[0] + 84 * omdxz[1] - 18 * omdxz[2] - 6 * omdxz[30] - 36 * omdxz[31] + 12 * omdxz[32] - 30 * omdxz[33] + 30 * omdxz[34] - 6 * omdxz[36] - 36 * omdxz[37] + + 12 * omdxz[38] - 30 * omdxz[39] + 30 * omdxz[40] + 24 * omdxz[42]; + phidxz[p45[2]] = +3 * omdxz[0] - 18 * omdxz[1] + 9 * omdxz[2] + 6 * omdxz[30] - 18 * omdxz[31] + 3 * omdxz[32] + 6 * omdxz[33] - 9 * omdxz[34] + 6 * omdxz[35] + 6 * omdxz[36] - + 18 * omdxz[37] + 3 * omdxz[38] + 6 * omdxz[39] - 9 * omdxz[40] + 6 * omdxz[41] + 6 * omdxz[42] + 6 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[3]] = +9 * omdxz[3] - 18 * omdxz[4] + 3 * omdxz[5] - 27 * omdxz[24] + 12 * omdxz[25] + 9 * omdxz[26] + 9 * omdxz[27] - 6 * omdxz[28] - 6 * omdxz[29] + 9 * omdxz[36] - + 6 * omdxz[37] - 6 * omdxz[38] - 27 * omdxz[39] + 9 * omdxz[40] + 12 * omdxz[41] - 6 * omdxz[42] + 18 * omdxz[43] - 6 * omdxz[44]; + phidxz[p45[4]] = -18 * omdxz[3] + 84 * omdxz[4] - 18 * omdxz[5] - 6 * omdxz[24] - 36 * omdxz[25] + 12 * omdxz[26] - 30 * omdxz[27] + 30 * omdxz[28] - 30 * omdxz[36] + 30 * omdxz[38] - + 6 * omdxz[39] + 12 * omdxz[40] - 36 * omdxz[41] + 24 * omdxz[43]; + phidxz[p45[5]] = +3 * omdxz[3] - 18 * omdxz[4] + 9 * omdxz[5] + 6 * omdxz[24] - 18 * omdxz[25] + 3 * omdxz[26] + 6 * omdxz[27] - 9 * omdxz[28] + 6 * omdxz[29] + 6 * omdxz[36] + 6 * omdxz[37] - + 9 * omdxz[38] + 6 * omdxz[39] + 3 * omdxz[40] - 18 * omdxz[41] + 6 * omdxz[42] + 6 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[6]] = +9 * omdxz[6] - 18 * omdxz[7] + 3 * omdxz[8] + 9 * omdxz[24] - 6 * omdxz[25] - 6 * omdxz[26] - 27 * omdxz[27] + 9 * omdxz[28] + 12 * omdxz[29] + 9 * omdxz[30] - + 6 * omdxz[31] - 6 * omdxz[32] - 27 * omdxz[33] + 9 * omdxz[34] + 12 * omdxz[35] - 6 * omdxz[42] - 6 * omdxz[43] + 18 * omdxz[44]; + phidxz[p45[7]] = -18 * omdxz[6] + 84 * omdxz[7] - 18 * omdxz[8] - 30 * omdxz[24] + 30 * omdxz[26] - 6 * omdxz[27] + 12 * omdxz[28] - 36 * omdxz[29] - 30 * omdxz[30] + 30 * omdxz[32] - + 6 * omdxz[33] + 12 * omdxz[34] - 36 * omdxz[35] + 24 * omdxz[44]; + phidxz[p45[8]] = +3 * omdxz[6] - 18 * omdxz[7] + 9 * omdxz[8] + 6 * omdxz[24] + 6 * omdxz[25] - 9 * omdxz[26] + 6 * omdxz[27] + 3 * omdxz[28] - 18 * omdxz[29] + 6 * omdxz[30] + 6 * omdxz[31] - + 9 * omdxz[32] + 6 * omdxz[33] + 3 * omdxz[34] - 18 * omdxz[35] + 6 * omdxz[42] + 6 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[9]] = +9 * omdxz[9] - 18 * omdxz[10] + 3 * omdxz[11] - 27 * omdxz[18] + 12 * omdxz[19] + 9 * omdxz[20] + 9 * omdxz[21] - 6 * omdxz[22] - 6 * omdxz[23] - 3 * omdxz[36] + + 18 * omdxz[37] - 6 * omdxz[38] + 9 * omdxz[39] - 27 * omdxz[40] + 12 * omdxz[41] - 6 * omdxz[42] + 18 * omdxz[43] - 6 * omdxz[44]; + phidxz[p45[10]] = -18 * omdxz[9] + 84 * omdxz[10] - 18 * omdxz[11] - 6 * omdxz[18] - 36 * omdxz[19] + 12 * omdxz[20] - 30 * omdxz[21] + 30 * omdxz[22] - 12 * omdxz[36] + 36 * omdxz[37] + + 6 * omdxz[38] + 12 * omdxz[39] - 6 * omdxz[40] - 36 * omdxz[41] - 24 * omdxz[42] + 24 * omdxz[43]; + phidxz[p45[11]] = +3 * omdxz[9] - 18 * omdxz[10] + 9 * omdxz[11] + 6 * omdxz[18] - 18 * omdxz[19] + 3 * omdxz[20] + 6 * omdxz[21] - 9 * omdxz[22] + 6 * omdxz[23] - 9 * omdxz[36] - + 12 * omdxz[37] + 27 * omdxz[38] + 3 * omdxz[39] + 6 * omdxz[40] - 18 * omdxz[41] - 18 * omdxz[42] + 6 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[12]] = +9 * omdxz[12] - 18 * omdxz[13] + 3 * omdxz[14] + 9 * omdxz[18] - 6 * omdxz[19] - 6 * omdxz[20] - 27 * omdxz[21] + 9 * omdxz[22] + 12 * omdxz[23] - 3 * omdxz[30] + + 18 * omdxz[31] - 6 * omdxz[32] + 9 * omdxz[33] - 27 * omdxz[34] + 12 * omdxz[35] - 6 * omdxz[42] - 6 * omdxz[43] + 18 * omdxz[44]; + phidxz[p45[13]] = -18 * omdxz[12] + 84 * omdxz[13] - 18 * omdxz[14] - 30 * omdxz[18] + 30 * omdxz[20] - 6 * omdxz[21] + 12 * omdxz[22] - 36 * omdxz[23] - 12 * omdxz[30] + 36 * omdxz[31] + + 6 * omdxz[32] + 12 * omdxz[33] - 6 * omdxz[34] - 36 * omdxz[35] - 24 * omdxz[42] + 24 * omdxz[44]; + phidxz[p45[14]] = +3 * omdxz[12] - 18 * omdxz[13] + 9 * omdxz[14] + 6 * omdxz[18] + 6 * omdxz[19] - 9 * omdxz[20] + 6 * omdxz[21] + 3 * omdxz[22] - 18 * omdxz[23] - 9 * omdxz[30] - + 12 * omdxz[31] + 27 * omdxz[32] + 3 * omdxz[33] + 6 * omdxz[34] - 18 * omdxz[35] - 18 * omdxz[42] + 6 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[15]] = +9 * omdxz[15] - 18 * omdxz[16] + 3 * omdxz[17] - 3 * omdxz[18] + 18 * omdxz[19] - 6 * omdxz[20] + 9 * omdxz[21] - 27 * omdxz[22] + 12 * omdxz[23] - 3 * omdxz[24] + + 18 * omdxz[25] - 6 * omdxz[26] + 9 * omdxz[27] - 27 * omdxz[28] + 12 * omdxz[29] - 6 * omdxz[42] - 6 * omdxz[43] + 18 * omdxz[44]; + phidxz[p45[16]] = -18 * omdxz[15] + 84 * omdxz[16] - 18 * omdxz[17] - 12 * omdxz[18] + 36 * omdxz[19] + 6 * omdxz[20] + 12 * omdxz[21] - 6 * omdxz[22] - 36 * omdxz[23] - 12 * omdxz[24] + + 36 * omdxz[25] + 6 * omdxz[26] + 12 * omdxz[27] - 6 * omdxz[28] - 36 * omdxz[29] - 24 * omdxz[43] + 24 * omdxz[44]; + phidxz[p45[17]] = +3 * omdxz[15] - 18 * omdxz[16] + 9 * omdxz[17] - 9 * omdxz[18] - 12 * omdxz[19] + 27 * omdxz[20] + 3 * omdxz[21] + 6 * omdxz[22] - 18 * omdxz[23] - 9 * omdxz[24] - + 12 * omdxz[25] + 27 * omdxz[26] + 3 * omdxz[27] + 6 * omdxz[28] - 18 * omdxz[29] + 6 * omdxz[42] - 18 * omdxz[43] + 6 * omdxz[44]; + phidxz[p45[18]] = +90 * omdxz[18] - 30 * omdxz[19] - 45 * omdxz[20] - 30 * omdxz[21] + 15 * omdxz[22] + 30 * omdxz[23] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[19]] = -30 * omdxz[18] + 120 * omdxz[19] - 30 * omdxz[20] + 30 * omdxz[21] - 60 * omdxz[22] + 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; + phidxz[p45[20]] = -45 * omdxz[18] - 30 * omdxz[19] + 90 * omdxz[20] + 15 * omdxz[21] + 15 * omdxz[22] - 60 * omdxz[23] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[21]] = -30 * omdxz[18] + 30 * omdxz[19] + 15 * omdxz[20] + 90 * omdxz[21] - 45 * omdxz[22] - 30 * omdxz[23] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[22]] = +15 * omdxz[18] - 60 * omdxz[19] + 15 * omdxz[20] - 45 * omdxz[21] + 90 * omdxz[22] - 30 * omdxz[23] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[23]] = +30 * omdxz[18] - 60 * omdxz[20] - 30 * omdxz[21] - 30 * omdxz[22] + 120 * omdxz[23] + 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; + phidxz[p45[24]] = +90 * omdxz[24] - 30 * omdxz[25] - 45 * omdxz[26] - 30 * omdxz[27] + 15 * omdxz[28] + 30 * omdxz[29] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[25]] = -30 * omdxz[24] + 120 * omdxz[25] - 30 * omdxz[26] + 30 * omdxz[27] - 60 * omdxz[28] - 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; + phidxz[p45[26]] = -45 * omdxz[24] - 30 * omdxz[25] + 90 * omdxz[26] + 15 * omdxz[27] + 15 * omdxz[28] - 60 * omdxz[29] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[27]] = -30 * omdxz[24] + 30 * omdxz[25] + 15 * omdxz[26] + 90 * omdxz[27] - 45 * omdxz[28] - 30 * omdxz[29] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[28]] = +15 * omdxz[24] - 60 * omdxz[25] + 15 * omdxz[26] - 45 * omdxz[27] + 90 * omdxz[28] - 30 * omdxz[29] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[29]] = +30 * omdxz[24] - 60 * omdxz[26] - 30 * omdxz[27] - 30 * omdxz[28] + 120 * omdxz[29] - 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; + phidxz[p45[30]] = +90 * omdxz[30] - 30 * omdxz[31] - 45 * omdxz[32] - 30 * omdxz[33] + 15 * omdxz[34] + 30 * omdxz[35] - 45 * omdxz[42] + 15 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[31]] = -30 * omdxz[30] + 120 * omdxz[31] - 30 * omdxz[32] + 30 * omdxz[33] - 60 * omdxz[34] - 30 * omdxz[42] - 30 * omdxz[43] + 30 * omdxz[44]; + phidxz[p45[32]] = -45 * omdxz[30] - 30 * omdxz[31] + 90 * omdxz[32] + 15 * omdxz[33] + 15 * omdxz[34] - 60 * omdxz[35] - 45 * omdxz[42] + 15 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[33]] = -30 * omdxz[30] + 30 * omdxz[31] + 15 * omdxz[32] + 90 * omdxz[33] - 45 * omdxz[34] - 30 * omdxz[35] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[34]] = +15 * omdxz[30] - 60 * omdxz[31] + 15 * omdxz[32] - 45 * omdxz[33] + 90 * omdxz[34] - 30 * omdxz[35] + 15 * omdxz[42] + 15 * omdxz[43] - 45 * omdxz[44]; + phidxz[p45[35]] = +30 * omdxz[30] - 60 * omdxz[32] - 30 * omdxz[33] - 30 * omdxz[34] + 120 * omdxz[35] + 30 * omdxz[42] - 30 * omdxz[43] - 30 * omdxz[44]; + phidxz[p45[36]] = +90 * omdxz[36] - 30 * omdxz[37] - 45 * omdxz[38] - 30 * omdxz[39] + 15 * omdxz[40] + 30 * omdxz[41] - 45 * omdxz[42] + 15 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[37]] = -30 * omdxz[36] + 120 * omdxz[37] - 30 * omdxz[38] + 30 * omdxz[39] - 60 * omdxz[40] - 30 * omdxz[42] + 30 * omdxz[43] - 30 * omdxz[44]; + phidxz[p45[38]] = -45 * omdxz[36] - 30 * omdxz[37] + 90 * omdxz[38] + 15 * omdxz[39] + 15 * omdxz[40] - 60 * omdxz[41] - 45 * omdxz[42] + 15 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[39]] = -30 * omdxz[36] + 30 * omdxz[37] + 15 * omdxz[38] + 90 * omdxz[39] - 45 * omdxz[40] - 30 * omdxz[41] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[40]] = +15 * omdxz[36] - 60 * omdxz[37] + 15 * omdxz[38] - 45 * omdxz[39] + 90 * omdxz[40] - 30 * omdxz[41] + 15 * omdxz[42] - 45 * omdxz[43] + 15 * omdxz[44]; + phidxz[p45[41]] = +30 * omdxz[36] - 60 * omdxz[38] - 30 * omdxz[39] - 30 * omdxz[40] + 120 * omdxz[41] + 30 * omdxz[42] - 30 * omdxz[43] - 30 * omdxz[44]; phidxz[p45[42]] = +90 * omdxz[42] - 30 * omdxz[43] - 30 * omdxz[44]; phidxz[p45[43]] = -30 * omdxz[42] + 90 * omdxz[43] - 30 * omdxz[44]; phidxz[p45[44]] = -30 * omdxz[42] - 30 * omdxz[43] + 90 * omdxz[44]; @@ -3396,155 +2272,66 @@ namespace Fem2D { R3 phidyz[45]; if (whatd & Fop_dyz) { - phidyz[p45[0]] = +9 * omdyz[0] - 18 * omdyz[1] + 3 * omdyz[2] - 27 * omdyz[30] + - 12 * omdyz[31] + 9 * omdyz[32] + 9 * omdyz[33] - 6 * omdyz[34] - - 6 * omdyz[35] - 27 * omdyz[36] + 12 * omdyz[37] + 9 * omdyz[38] + - 9 * omdyz[39] - 6 * omdyz[40] - 6 * omdyz[41] + 18 * omdyz[42] - - 6 * omdyz[43] - 6 * omdyz[44]; - phidyz[p45[1]] = -18 * omdyz[0] + 84 * omdyz[1] - 18 * omdyz[2] - 6 * omdyz[30] - - 36 * omdyz[31] + 12 * omdyz[32] - 30 * omdyz[33] + 30 * omdyz[34] - - 6 * omdyz[36] - 36 * omdyz[37] + 12 * omdyz[38] - 30 * omdyz[39] + - 30 * omdyz[40] + 24 * omdyz[42]; - phidyz[p45[2]] = +3 * omdyz[0] - 18 * omdyz[1] + 9 * omdyz[2] + 6 * omdyz[30] - - 18 * omdyz[31] + 3 * omdyz[32] + 6 * omdyz[33] - 9 * omdyz[34] + - 6 * omdyz[35] + 6 * omdyz[36] - 18 * omdyz[37] + 3 * omdyz[38] + - 6 * omdyz[39] - 9 * omdyz[40] + 6 * omdyz[41] + 6 * omdyz[42] + - 6 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[3]] = +9 * omdyz[3] - 18 * omdyz[4] + 3 * omdyz[5] - 27 * omdyz[24] + - 12 * omdyz[25] + 9 * omdyz[26] + 9 * omdyz[27] - 6 * omdyz[28] - - 6 * omdyz[29] + 9 * omdyz[36] - 6 * omdyz[37] - 6 * omdyz[38] - - 27 * omdyz[39] + 9 * omdyz[40] + 12 * omdyz[41] - 6 * omdyz[42] + - 18 * omdyz[43] - 6 * omdyz[44]; - phidyz[p45[4]] = -18 * omdyz[3] + 84 * omdyz[4] - 18 * omdyz[5] - 6 * omdyz[24] - - 36 * omdyz[25] + 12 * omdyz[26] - 30 * omdyz[27] + 30 * omdyz[28] - - 30 * omdyz[36] + 30 * omdyz[38] - 6 * omdyz[39] + 12 * omdyz[40] - - 36 * omdyz[41] + 24 * omdyz[43]; - phidyz[p45[5]] = +3 * omdyz[3] - 18 * omdyz[4] + 9 * omdyz[5] + 6 * omdyz[24] - - 18 * omdyz[25] + 3 * omdyz[26] + 6 * omdyz[27] - 9 * omdyz[28] + - 6 * omdyz[29] + 6 * omdyz[36] + 6 * omdyz[37] - 9 * omdyz[38] + - 6 * omdyz[39] + 3 * omdyz[40] - 18 * omdyz[41] + 6 * omdyz[42] + - 6 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[6]] = +9 * omdyz[6] - 18 * omdyz[7] + 3 * omdyz[8] + 9 * omdyz[24] - - 6 * omdyz[25] - 6 * omdyz[26] - 27 * omdyz[27] + 9 * omdyz[28] + - 12 * omdyz[29] + 9 * omdyz[30] - 6 * omdyz[31] - 6 * omdyz[32] - - 27 * omdyz[33] + 9 * omdyz[34] + 12 * omdyz[35] - 6 * omdyz[42] - - 6 * omdyz[43] + 18 * omdyz[44]; - phidyz[p45[7]] = -18 * omdyz[6] + 84 * omdyz[7] - 18 * omdyz[8] - 30 * omdyz[24] + - 30 * omdyz[26] - 6 * omdyz[27] + 12 * omdyz[28] - 36 * omdyz[29] - - 30 * omdyz[30] + 30 * omdyz[32] - 6 * omdyz[33] + 12 * omdyz[34] - - 36 * omdyz[35] + 24 * omdyz[44]; - phidyz[p45[8]] = +3 * omdyz[6] - 18 * omdyz[7] + 9 * omdyz[8] + 6 * omdyz[24] + - 6 * omdyz[25] - 9 * omdyz[26] + 6 * omdyz[27] + 3 * omdyz[28] - - 18 * omdyz[29] + 6 * omdyz[30] + 6 * omdyz[31] - 9 * omdyz[32] + - 6 * omdyz[33] + 3 * omdyz[34] - 18 * omdyz[35] + 6 * omdyz[42] + - 6 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[9]] = +9 * omdyz[9] - 18 * omdyz[10] + 3 * omdyz[11] - 27 * omdyz[18] + - 12 * omdyz[19] + 9 * omdyz[20] + 9 * omdyz[21] - 6 * omdyz[22] - - 6 * omdyz[23] - 3 * omdyz[36] + 18 * omdyz[37] - 6 * omdyz[38] + - 9 * omdyz[39] - 27 * omdyz[40] + 12 * omdyz[41] - 6 * omdyz[42] + - 18 * omdyz[43] - 6 * omdyz[44]; - phidyz[p45[10]] = -18 * omdyz[9] + 84 * omdyz[10] - 18 * omdyz[11] - 6 * omdyz[18] - - 36 * omdyz[19] + 12 * omdyz[20] - 30 * omdyz[21] + 30 * omdyz[22] - - 12 * omdyz[36] + 36 * omdyz[37] + 6 * omdyz[38] + 12 * omdyz[39] - - 6 * omdyz[40] - 36 * omdyz[41] - 24 * omdyz[42] + 24 * omdyz[43]; - phidyz[p45[11]] = +3 * omdyz[9] - 18 * omdyz[10] + 9 * omdyz[11] + 6 * omdyz[18] - - 18 * omdyz[19] + 3 * omdyz[20] + 6 * omdyz[21] - 9 * omdyz[22] + - 6 * omdyz[23] - 9 * omdyz[36] - 12 * omdyz[37] + 27 * omdyz[38] + - 3 * omdyz[39] + 6 * omdyz[40] - 18 * omdyz[41] - 18 * omdyz[42] + - 6 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[12]] = +9 * omdyz[12] - 18 * omdyz[13] + 3 * omdyz[14] + 9 * omdyz[18] - - 6 * omdyz[19] - 6 * omdyz[20] - 27 * omdyz[21] + 9 * omdyz[22] + - 12 * omdyz[23] - 3 * omdyz[30] + 18 * omdyz[31] - 6 * omdyz[32] + - 9 * omdyz[33] - 27 * omdyz[34] + 12 * omdyz[35] - 6 * omdyz[42] - - 6 * omdyz[43] + 18 * omdyz[44]; - phidyz[p45[13]] = -18 * omdyz[12] + 84 * omdyz[13] - 18 * omdyz[14] - 30 * omdyz[18] + - 30 * omdyz[20] - 6 * omdyz[21] + 12 * omdyz[22] - 36 * omdyz[23] - - 12 * omdyz[30] + 36 * omdyz[31] + 6 * omdyz[32] + 12 * omdyz[33] - - 6 * omdyz[34] - 36 * omdyz[35] - 24 * omdyz[42] + 24 * omdyz[44]; - phidyz[p45[14]] = +3 * omdyz[12] - 18 * omdyz[13] + 9 * omdyz[14] + 6 * omdyz[18] + - 6 * omdyz[19] - 9 * omdyz[20] + 6 * omdyz[21] + 3 * omdyz[22] - - 18 * omdyz[23] - 9 * omdyz[30] - 12 * omdyz[31] + 27 * omdyz[32] + - 3 * omdyz[33] + 6 * omdyz[34] - 18 * omdyz[35] - 18 * omdyz[42] + - 6 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[15]] = +9 * omdyz[15] - 18 * omdyz[16] + 3 * omdyz[17] - 3 * omdyz[18] + - 18 * omdyz[19] - 6 * omdyz[20] + 9 * omdyz[21] - 27 * omdyz[22] + - 12 * omdyz[23] - 3 * omdyz[24] + 18 * omdyz[25] - 6 * omdyz[26] + - 9 * omdyz[27] - 27 * omdyz[28] + 12 * omdyz[29] - 6 * omdyz[42] - - 6 * omdyz[43] + 18 * omdyz[44]; - phidyz[p45[16]] = -18 * omdyz[15] + 84 * omdyz[16] - 18 * omdyz[17] - 12 * omdyz[18] + - 36 * omdyz[19] + 6 * omdyz[20] + 12 * omdyz[21] - 6 * omdyz[22] - - 36 * omdyz[23] - 12 * omdyz[24] + 36 * omdyz[25] + 6 * omdyz[26] + - 12 * omdyz[27] - 6 * omdyz[28] - 36 * omdyz[29] - 24 * omdyz[43] + - 24 * omdyz[44]; - phidyz[p45[17]] = +3 * omdyz[15] - 18 * omdyz[16] + 9 * omdyz[17] - 9 * omdyz[18] - - 12 * omdyz[19] + 27 * omdyz[20] + 3 * omdyz[21] + 6 * omdyz[22] - - 18 * omdyz[23] - 9 * omdyz[24] - 12 * omdyz[25] + 27 * omdyz[26] + - 3 * omdyz[27] + 6 * omdyz[28] - 18 * omdyz[29] + 6 * omdyz[42] - - 18 * omdyz[43] + 6 * omdyz[44]; - phidyz[p45[18]] = +90 * omdyz[18] - 30 * omdyz[19] - 45 * omdyz[20] - 30 * omdyz[21] + - 15 * omdyz[22] + 30 * omdyz[23] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[19]] = -30 * omdyz[18] + 120 * omdyz[19] - 30 * omdyz[20] + 30 * omdyz[21] - - 60 * omdyz[22] + 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; - phidyz[p45[20]] = -45 * omdyz[18] - 30 * omdyz[19] + 90 * omdyz[20] + 15 * omdyz[21] + - 15 * omdyz[22] - 60 * omdyz[23] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[21]] = -30 * omdyz[18] + 30 * omdyz[19] + 15 * omdyz[20] + 90 * omdyz[21] - - 45 * omdyz[22] - 30 * omdyz[23] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[22]] = +15 * omdyz[18] - 60 * omdyz[19] + 15 * omdyz[20] - 45 * omdyz[21] + - 90 * omdyz[22] - 30 * omdyz[23] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[23]] = +30 * omdyz[18] - 60 * omdyz[20] - 30 * omdyz[21] - 30 * omdyz[22] + - 120 * omdyz[23] + 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; - phidyz[p45[24]] = +90 * omdyz[24] - 30 * omdyz[25] - 45 * omdyz[26] - 30 * omdyz[27] + - 15 * omdyz[28] + 30 * omdyz[29] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[25]] = -30 * omdyz[24] + 120 * omdyz[25] - 30 * omdyz[26] + 30 * omdyz[27] - - 60 * omdyz[28] - 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; - phidyz[p45[26]] = -45 * omdyz[24] - 30 * omdyz[25] + 90 * omdyz[26] + 15 * omdyz[27] + - 15 * omdyz[28] - 60 * omdyz[29] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[27]] = -30 * omdyz[24] + 30 * omdyz[25] + 15 * omdyz[26] + 90 * omdyz[27] - - 45 * omdyz[28] - 30 * omdyz[29] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[28]] = +15 * omdyz[24] - 60 * omdyz[25] + 15 * omdyz[26] - 45 * omdyz[27] + - 90 * omdyz[28] - 30 * omdyz[29] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[29]] = +30 * omdyz[24] - 60 * omdyz[26] - 30 * omdyz[27] - 30 * omdyz[28] + - 120 * omdyz[29] - 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; - phidyz[p45[30]] = +90 * omdyz[30] - 30 * omdyz[31] - 45 * omdyz[32] - 30 * omdyz[33] + - 15 * omdyz[34] + 30 * omdyz[35] - 45 * omdyz[42] + 15 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[31]] = -30 * omdyz[30] + 120 * omdyz[31] - 30 * omdyz[32] + 30 * omdyz[33] - - 60 * omdyz[34] - 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; - phidyz[p45[32]] = -45 * omdyz[30] - 30 * omdyz[31] + 90 * omdyz[32] + 15 * omdyz[33] + - 15 * omdyz[34] - 60 * omdyz[35] - 45 * omdyz[42] + 15 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[33]] = -30 * omdyz[30] + 30 * omdyz[31] + 15 * omdyz[32] + 90 * omdyz[33] - - 45 * omdyz[34] - 30 * omdyz[35] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[34]] = +15 * omdyz[30] - 60 * omdyz[31] + 15 * omdyz[32] - 45 * omdyz[33] + - 90 * omdyz[34] - 30 * omdyz[35] + 15 * omdyz[42] + 15 * omdyz[43] - - 45 * omdyz[44]; - phidyz[p45[35]] = +30 * omdyz[30] - 60 * omdyz[32] - 30 * omdyz[33] - 30 * omdyz[34] + - 120 * omdyz[35] + 30 * omdyz[42] - 30 * omdyz[43] - 30 * omdyz[44]; - phidyz[p45[36]] = +90 * omdyz[36] - 30 * omdyz[37] - 45 * omdyz[38] - 30 * omdyz[39] + - 15 * omdyz[40] + 30 * omdyz[41] - 45 * omdyz[42] + 15 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[37]] = -30 * omdyz[36] + 120 * omdyz[37] - 30 * omdyz[38] + 30 * omdyz[39] - - 60 * omdyz[40] - 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; - phidyz[p45[38]] = -45 * omdyz[36] - 30 * omdyz[37] + 90 * omdyz[38] + 15 * omdyz[39] + - 15 * omdyz[40] - 60 * omdyz[41] - 45 * omdyz[42] + 15 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[39]] = -30 * omdyz[36] + 30 * omdyz[37] + 15 * omdyz[38] + 90 * omdyz[39] - - 45 * omdyz[40] - 30 * omdyz[41] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[40]] = +15 * omdyz[36] - 60 * omdyz[37] + 15 * omdyz[38] - 45 * omdyz[39] + - 90 * omdyz[40] - 30 * omdyz[41] + 15 * omdyz[42] - 45 * omdyz[43] + - 15 * omdyz[44]; - phidyz[p45[41]] = +30 * omdyz[36] - 60 * omdyz[38] - 30 * omdyz[39] - 30 * omdyz[40] + - 120 * omdyz[41] + 30 * omdyz[42] - 30 * omdyz[43] - 30 * omdyz[44]; + phidyz[p45[0]] = +9 * omdyz[0] - 18 * omdyz[1] + 3 * omdyz[2] - 27 * omdyz[30] + 12 * omdyz[31] + 9 * omdyz[32] + 9 * omdyz[33] - 6 * omdyz[34] - 6 * omdyz[35] - 27 * omdyz[36] + + 12 * omdyz[37] + 9 * omdyz[38] + 9 * omdyz[39] - 6 * omdyz[40] - 6 * omdyz[41] + 18 * omdyz[42] - 6 * omdyz[43] - 6 * omdyz[44]; + phidyz[p45[1]] = -18 * omdyz[0] + 84 * omdyz[1] - 18 * omdyz[2] - 6 * omdyz[30] - 36 * omdyz[31] + 12 * omdyz[32] - 30 * omdyz[33] + 30 * omdyz[34] - 6 * omdyz[36] - 36 * omdyz[37] + + 12 * omdyz[38] - 30 * omdyz[39] + 30 * omdyz[40] + 24 * omdyz[42]; + phidyz[p45[2]] = +3 * omdyz[0] - 18 * omdyz[1] + 9 * omdyz[2] + 6 * omdyz[30] - 18 * omdyz[31] + 3 * omdyz[32] + 6 * omdyz[33] - 9 * omdyz[34] + 6 * omdyz[35] + 6 * omdyz[36] - + 18 * omdyz[37] + 3 * omdyz[38] + 6 * omdyz[39] - 9 * omdyz[40] + 6 * omdyz[41] + 6 * omdyz[42] + 6 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[3]] = +9 * omdyz[3] - 18 * omdyz[4] + 3 * omdyz[5] - 27 * omdyz[24] + 12 * omdyz[25] + 9 * omdyz[26] + 9 * omdyz[27] - 6 * omdyz[28] - 6 * omdyz[29] + 9 * omdyz[36] - + 6 * omdyz[37] - 6 * omdyz[38] - 27 * omdyz[39] + 9 * omdyz[40] + 12 * omdyz[41] - 6 * omdyz[42] + 18 * omdyz[43] - 6 * omdyz[44]; + phidyz[p45[4]] = -18 * omdyz[3] + 84 * omdyz[4] - 18 * omdyz[5] - 6 * omdyz[24] - 36 * omdyz[25] + 12 * omdyz[26] - 30 * omdyz[27] + 30 * omdyz[28] - 30 * omdyz[36] + 30 * omdyz[38] - + 6 * omdyz[39] + 12 * omdyz[40] - 36 * omdyz[41] + 24 * omdyz[43]; + phidyz[p45[5]] = +3 * omdyz[3] - 18 * omdyz[4] + 9 * omdyz[5] + 6 * omdyz[24] - 18 * omdyz[25] + 3 * omdyz[26] + 6 * omdyz[27] - 9 * omdyz[28] + 6 * omdyz[29] + 6 * omdyz[36] + 6 * omdyz[37] - + 9 * omdyz[38] + 6 * omdyz[39] + 3 * omdyz[40] - 18 * omdyz[41] + 6 * omdyz[42] + 6 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[6]] = +9 * omdyz[6] - 18 * omdyz[7] + 3 * omdyz[8] + 9 * omdyz[24] - 6 * omdyz[25] - 6 * omdyz[26] - 27 * omdyz[27] + 9 * omdyz[28] + 12 * omdyz[29] + 9 * omdyz[30] - + 6 * omdyz[31] - 6 * omdyz[32] - 27 * omdyz[33] + 9 * omdyz[34] + 12 * omdyz[35] - 6 * omdyz[42] - 6 * omdyz[43] + 18 * omdyz[44]; + phidyz[p45[7]] = -18 * omdyz[6] + 84 * omdyz[7] - 18 * omdyz[8] - 30 * omdyz[24] + 30 * omdyz[26] - 6 * omdyz[27] + 12 * omdyz[28] - 36 * omdyz[29] - 30 * omdyz[30] + 30 * omdyz[32] - + 6 * omdyz[33] + 12 * omdyz[34] - 36 * omdyz[35] + 24 * omdyz[44]; + phidyz[p45[8]] = +3 * omdyz[6] - 18 * omdyz[7] + 9 * omdyz[8] + 6 * omdyz[24] + 6 * omdyz[25] - 9 * omdyz[26] + 6 * omdyz[27] + 3 * omdyz[28] - 18 * omdyz[29] + 6 * omdyz[30] + 6 * omdyz[31] - + 9 * omdyz[32] + 6 * omdyz[33] + 3 * omdyz[34] - 18 * omdyz[35] + 6 * omdyz[42] + 6 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[9]] = +9 * omdyz[9] - 18 * omdyz[10] + 3 * omdyz[11] - 27 * omdyz[18] + 12 * omdyz[19] + 9 * omdyz[20] + 9 * omdyz[21] - 6 * omdyz[22] - 6 * omdyz[23] - 3 * omdyz[36] + + 18 * omdyz[37] - 6 * omdyz[38] + 9 * omdyz[39] - 27 * omdyz[40] + 12 * omdyz[41] - 6 * omdyz[42] + 18 * omdyz[43] - 6 * omdyz[44]; + phidyz[p45[10]] = -18 * omdyz[9] + 84 * omdyz[10] - 18 * omdyz[11] - 6 * omdyz[18] - 36 * omdyz[19] + 12 * omdyz[20] - 30 * omdyz[21] + 30 * omdyz[22] - 12 * omdyz[36] + 36 * omdyz[37] + + 6 * omdyz[38] + 12 * omdyz[39] - 6 * omdyz[40] - 36 * omdyz[41] - 24 * omdyz[42] + 24 * omdyz[43]; + phidyz[p45[11]] = +3 * omdyz[9] - 18 * omdyz[10] + 9 * omdyz[11] + 6 * omdyz[18] - 18 * omdyz[19] + 3 * omdyz[20] + 6 * omdyz[21] - 9 * omdyz[22] + 6 * omdyz[23] - 9 * omdyz[36] - + 12 * omdyz[37] + 27 * omdyz[38] + 3 * omdyz[39] + 6 * omdyz[40] - 18 * omdyz[41] - 18 * omdyz[42] + 6 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[12]] = +9 * omdyz[12] - 18 * omdyz[13] + 3 * omdyz[14] + 9 * omdyz[18] - 6 * omdyz[19] - 6 * omdyz[20] - 27 * omdyz[21] + 9 * omdyz[22] + 12 * omdyz[23] - 3 * omdyz[30] + + 18 * omdyz[31] - 6 * omdyz[32] + 9 * omdyz[33] - 27 * omdyz[34] + 12 * omdyz[35] - 6 * omdyz[42] - 6 * omdyz[43] + 18 * omdyz[44]; + phidyz[p45[13]] = -18 * omdyz[12] + 84 * omdyz[13] - 18 * omdyz[14] - 30 * omdyz[18] + 30 * omdyz[20] - 6 * omdyz[21] + 12 * omdyz[22] - 36 * omdyz[23] - 12 * omdyz[30] + 36 * omdyz[31] + + 6 * omdyz[32] + 12 * omdyz[33] - 6 * omdyz[34] - 36 * omdyz[35] - 24 * omdyz[42] + 24 * omdyz[44]; + phidyz[p45[14]] = +3 * omdyz[12] - 18 * omdyz[13] + 9 * omdyz[14] + 6 * omdyz[18] + 6 * omdyz[19] - 9 * omdyz[20] + 6 * omdyz[21] + 3 * omdyz[22] - 18 * omdyz[23] - 9 * omdyz[30] - + 12 * omdyz[31] + 27 * omdyz[32] + 3 * omdyz[33] + 6 * omdyz[34] - 18 * omdyz[35] - 18 * omdyz[42] + 6 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[15]] = +9 * omdyz[15] - 18 * omdyz[16] + 3 * omdyz[17] - 3 * omdyz[18] + 18 * omdyz[19] - 6 * omdyz[20] + 9 * omdyz[21] - 27 * omdyz[22] + 12 * omdyz[23] - 3 * omdyz[24] + + 18 * omdyz[25] - 6 * omdyz[26] + 9 * omdyz[27] - 27 * omdyz[28] + 12 * omdyz[29] - 6 * omdyz[42] - 6 * omdyz[43] + 18 * omdyz[44]; + phidyz[p45[16]] = -18 * omdyz[15] + 84 * omdyz[16] - 18 * omdyz[17] - 12 * omdyz[18] + 36 * omdyz[19] + 6 * omdyz[20] + 12 * omdyz[21] - 6 * omdyz[22] - 36 * omdyz[23] - 12 * omdyz[24] + + 36 * omdyz[25] + 6 * omdyz[26] + 12 * omdyz[27] - 6 * omdyz[28] - 36 * omdyz[29] - 24 * omdyz[43] + 24 * omdyz[44]; + phidyz[p45[17]] = +3 * omdyz[15] - 18 * omdyz[16] + 9 * omdyz[17] - 9 * omdyz[18] - 12 * omdyz[19] + 27 * omdyz[20] + 3 * omdyz[21] + 6 * omdyz[22] - 18 * omdyz[23] - 9 * omdyz[24] - + 12 * omdyz[25] + 27 * omdyz[26] + 3 * omdyz[27] + 6 * omdyz[28] - 18 * omdyz[29] + 6 * omdyz[42] - 18 * omdyz[43] + 6 * omdyz[44]; + phidyz[p45[18]] = +90 * omdyz[18] - 30 * omdyz[19] - 45 * omdyz[20] - 30 * omdyz[21] + 15 * omdyz[22] + 30 * omdyz[23] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[19]] = -30 * omdyz[18] + 120 * omdyz[19] - 30 * omdyz[20] + 30 * omdyz[21] - 60 * omdyz[22] + 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; + phidyz[p45[20]] = -45 * omdyz[18] - 30 * omdyz[19] + 90 * omdyz[20] + 15 * omdyz[21] + 15 * omdyz[22] - 60 * omdyz[23] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[21]] = -30 * omdyz[18] + 30 * omdyz[19] + 15 * omdyz[20] + 90 * omdyz[21] - 45 * omdyz[22] - 30 * omdyz[23] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[22]] = +15 * omdyz[18] - 60 * omdyz[19] + 15 * omdyz[20] - 45 * omdyz[21] + 90 * omdyz[22] - 30 * omdyz[23] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[23]] = +30 * omdyz[18] - 60 * omdyz[20] - 30 * omdyz[21] - 30 * omdyz[22] + 120 * omdyz[23] + 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; + phidyz[p45[24]] = +90 * omdyz[24] - 30 * omdyz[25] - 45 * omdyz[26] - 30 * omdyz[27] + 15 * omdyz[28] + 30 * omdyz[29] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[25]] = -30 * omdyz[24] + 120 * omdyz[25] - 30 * omdyz[26] + 30 * omdyz[27] - 60 * omdyz[28] - 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; + phidyz[p45[26]] = -45 * omdyz[24] - 30 * omdyz[25] + 90 * omdyz[26] + 15 * omdyz[27] + 15 * omdyz[28] - 60 * omdyz[29] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[27]] = -30 * omdyz[24] + 30 * omdyz[25] + 15 * omdyz[26] + 90 * omdyz[27] - 45 * omdyz[28] - 30 * omdyz[29] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[28]] = +15 * omdyz[24] - 60 * omdyz[25] + 15 * omdyz[26] - 45 * omdyz[27] + 90 * omdyz[28] - 30 * omdyz[29] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[29]] = +30 * omdyz[24] - 60 * omdyz[26] - 30 * omdyz[27] - 30 * omdyz[28] + 120 * omdyz[29] - 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; + phidyz[p45[30]] = +90 * omdyz[30] - 30 * omdyz[31] - 45 * omdyz[32] - 30 * omdyz[33] + 15 * omdyz[34] + 30 * omdyz[35] - 45 * omdyz[42] + 15 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[31]] = -30 * omdyz[30] + 120 * omdyz[31] - 30 * omdyz[32] + 30 * omdyz[33] - 60 * omdyz[34] - 30 * omdyz[42] - 30 * omdyz[43] + 30 * omdyz[44]; + phidyz[p45[32]] = -45 * omdyz[30] - 30 * omdyz[31] + 90 * omdyz[32] + 15 * omdyz[33] + 15 * omdyz[34] - 60 * omdyz[35] - 45 * omdyz[42] + 15 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[33]] = -30 * omdyz[30] + 30 * omdyz[31] + 15 * omdyz[32] + 90 * omdyz[33] - 45 * omdyz[34] - 30 * omdyz[35] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[34]] = +15 * omdyz[30] - 60 * omdyz[31] + 15 * omdyz[32] - 45 * omdyz[33] + 90 * omdyz[34] - 30 * omdyz[35] + 15 * omdyz[42] + 15 * omdyz[43] - 45 * omdyz[44]; + phidyz[p45[35]] = +30 * omdyz[30] - 60 * omdyz[32] - 30 * omdyz[33] - 30 * omdyz[34] + 120 * omdyz[35] + 30 * omdyz[42] - 30 * omdyz[43] - 30 * omdyz[44]; + phidyz[p45[36]] = +90 * omdyz[36] - 30 * omdyz[37] - 45 * omdyz[38] - 30 * omdyz[39] + 15 * omdyz[40] + 30 * omdyz[41] - 45 * omdyz[42] + 15 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[37]] = -30 * omdyz[36] + 120 * omdyz[37] - 30 * omdyz[38] + 30 * omdyz[39] - 60 * omdyz[40] - 30 * omdyz[42] + 30 * omdyz[43] - 30 * omdyz[44]; + phidyz[p45[38]] = -45 * omdyz[36] - 30 * omdyz[37] + 90 * omdyz[38] + 15 * omdyz[39] + 15 * omdyz[40] - 60 * omdyz[41] - 45 * omdyz[42] + 15 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[39]] = -30 * omdyz[36] + 30 * omdyz[37] + 15 * omdyz[38] + 90 * omdyz[39] - 45 * omdyz[40] - 30 * omdyz[41] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[40]] = +15 * omdyz[36] - 60 * omdyz[37] + 15 * omdyz[38] - 45 * omdyz[39] + 90 * omdyz[40] - 30 * omdyz[41] + 15 * omdyz[42] - 45 * omdyz[43] + 15 * omdyz[44]; + phidyz[p45[41]] = +30 * omdyz[36] - 60 * omdyz[38] - 30 * omdyz[39] - 30 * omdyz[40] + 120 * omdyz[41] + 30 * omdyz[42] - 30 * omdyz[43] - 30 * omdyz[44]; phidyz[p45[42]] = +90 * omdyz[42] - 30 * omdyz[43] - 30 * omdyz[44]; phidyz[p45[43]] = -30 * omdyz[42] + 90 * omdyz[43] - 30 * omdyz[44]; phidyz[p45[44]] = -30 * omdyz[42] - 30 * omdyz[43] + 90 * omdyz[44]; @@ -3583,8 +2370,7 @@ namespace Fem2D { TypeOfFE_P0Edge3ds0( ); - void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const; ~TypeOfFE_P0Edge3ds0( ) {} @@ -3593,8 +2379,7 @@ namespace Fem2D { void operator=(const TypeOfFE_P0Edge3ds0 &); }; - TypeOfFE_P0Edge3ds0::TypeOfFE_P0Edge3ds0( ) - : GTypeOfFE< Mesh3 >(A4( ), 1, 1, Element::ne, Element::ne, false, true) { + TypeOfFE_P0Edge3ds0::TypeOfFE_P0Edge3ds0( ) : GTypeOfFE< Mesh3 >(A4( ), 1, 1, Element::ne, Element::ne, false, true) { R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; for (int e = 0; e < Element::ne; ++e) { @@ -3611,10 +2396,7 @@ namespace Fem2D { } } - void TypeOfFE_P0Edge3ds0::FB(const What_d whatd, const Mesh &, const Element &K, - const RdHat &PHat, RNMK_ &val) const { - assert(0); - } + void TypeOfFE_P0Edge3ds0::FB(const What_d whatd, const Mesh &, const Element &K, const RdHat &PHat, RNMK_ &val) const { assert(0); } // FE space Edge13ds0 useful to build a partition of unity for the FE space Edge13d of // edge elements of degree 2 in 3d @@ -3640,8 +2422,7 @@ namespace Fem2D { TypeOfFE_P1Edge3ds0( ); - void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const; ~TypeOfFE_P1Edge3ds0( ) {} @@ -3650,9 +2431,7 @@ namespace Fem2D { void operator=(const TypeOfFE_P1Edge3ds0 &); }; - TypeOfFE_P1Edge3ds0::TypeOfFE_P1Edge3ds0( ) - : GTypeOfFE< Mesh3 >(A4( ), 1, 1, Element::ne * 2 + Element::nf * 2, Element::ne + Element::nf, - false, true) { + TypeOfFE_P1Edge3ds0::TypeOfFE_P1Edge3ds0( ) : GTypeOfFE< Mesh3 >(A4( ), 1, 1, Element::ne * 2 + Element::nf * 2, Element::ne + Element::nf, false, true) { R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; { @@ -3663,15 +2442,13 @@ namespace Fem2D { } for (int f = 0; f < Element::nf; ++f, ++i) { - this->PtInterpolation[i] = - 1. / 3. * - (Pt[Element::nvface[f][0]] + Pt[Element::nvface[f][1]] + Pt[Element::nvface[f][2]]); + this->PtInterpolation[i] = 1. / 3. * (Pt[Element::nvface[f][0]] + Pt[Element::nvface[f][1]] + Pt[Element::nvface[f][2]]); } } int i = 0, p = 0; int e; - for (e = 0; e < (Element::ne)*2; e++) { + for (e = 0; e < (Element::ne) * 2; e++) { if (e % 2 == 1) { p = p - 1; } @@ -3684,7 +2461,7 @@ namespace Fem2D { p++; } - for (int f = 0; f < (Element::nf)*2; f++) { + for (int f = 0; f < (Element::nf) * 2; f++) { if (f % 2 == 1) { p = p - 1; } @@ -3698,10 +2475,7 @@ namespace Fem2D { } } - void TypeOfFE_P1Edge3ds0::FB(const What_d whatd, const Mesh &, const Element &K, - const RdHat &PHat, RNMK_ &val) const { - assert(0); - } + void TypeOfFE_P1Edge3ds0::FB(const What_d whatd, const Mesh &, const Element &K, const RdHat &PHat, RNMK_ &val) const { assert(0); } // FE space Edge23ds0 useful to build a partition of unity for the FE space Edge23d of // edge elements of degree 3 in 3d @@ -3729,8 +2503,7 @@ namespace Fem2D { TypeOfFE_P2Edge3ds0( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; ~TypeOfFE_P2Edge3ds0( ) {} @@ -3739,11 +2512,8 @@ namespace Fem2D { void operator=(const TypeOfFE_P2Edge3ds0 &); }; - TypeOfFE_P2Edge3ds0::TypeOfFE_P2Edge3ds0( ) - : GTypeOfFE< Mesh3 >(A4( ), 1, 1, 3 * Element::ne + 6 * Element::nf + 3, - Element::ne + Element::nf + 1, false, true) { - R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + TypeOfFE_P2Edge3ds0::TypeOfFE_P2Edge3ds0( ) : GTypeOfFE< Mesh3 >(A4( ), 1, 1, 3 * Element::ne + 6 * Element::nf + 3, Element::ne + Element::nf + 1, false, true) { + R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices { // We build the interpolation pts on the edges of the reference tetrahedron: @@ -3756,9 +2526,7 @@ namespace Fem2D { // We build the interpolation pts on the faces of the reference tetrahedron: // (the index i mustn't be reinitialised!) for (int f = 0; f < Element::nf; ++f, ++i) { - this->PtInterpolation[i] = - 1. / 3. * - (Pt[Element::nvface[f][0]] + Pt[Element::nvface[f][1]] + Pt[Element::nvface[f][2]]); + this->PtInterpolation[i] = 1. / 3. * (Pt[Element::nvface[f][0]] + Pt[Element::nvface[f][1]] + Pt[Element::nvface[f][2]]); } // We build the interpolation pts on the tetrahedron: @@ -3769,7 +2537,7 @@ namespace Fem2D { int i = 0, p = 0; // i is the k in (13.1) (chapter 13 ff++doc) int e; // we will need e also below, in the parts referred to faces and volumes - for (e = 0; e < (Element::ne)*3; e++) { // loop on the 18 edge dofs + for (e = 0; e < (Element::ne) * 3; e++) { // loop on the 18 edge dofs if (e % 3 != 0) { p = p - 1; } // for 3 successive basis fcts the quad pts are the same (they correspond to the same @@ -3789,7 +2557,7 @@ namespace Fem2D { // (the indices i and p mustn't be reinitialised) int f; // we will need f also below, in the part referred to volumes - for (f = 0; f < (Element::nf)*6; f++) { // loop on the 24 face dofs + for (f = 0; f < (Element::nf) * 6; f++) { // loop on the 24 face dofs if (f % 6 != 0) { p = p - 1; } // for 6 successive basis fcts the quad pts are the same (they correspond to the same @@ -3823,10 +2591,7 @@ namespace Fem2D { } } - void TypeOfFE_P2Edge3ds0::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { - assert(0); - } + void TypeOfFE_P2Edge3ds0::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(0); } class TypeOfFE_RT1_3d : public GTypeOfFE< Mesh3 > { public: @@ -3841,10 +2606,8 @@ namespace Fem2D { static const GQuadratureFormular< R3 > QFtetra; TypeOfFE_RT1_3d( ); int edgeface[4][3]; - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; }; int TypeOfFE_RT1_3d::dfon[] = {0, 0, 3, 3}; // dofs per vertice, edge, face, volume @@ -3855,9 +2618,7 @@ namespace Fem2D { // Quadrature formula on the tetraedron const GQuadratureFormular< R3 > TypeOfFE_RT1_3d::QFtetra(QuadratureFormular_Tet_2); - TypeOfFE_RT1_3d::TypeOfFE_RT1_3d( ) - : GTypeOfFE< Mesh3 >(dfon, d, 1, 3 * QFface.n * 3 * Element::nf + 3 * QFtetra.n * 3, - Element::nf * QFface.n + QFtetra.n, false, true) { + TypeOfFE_RT1_3d::TypeOfFE_RT1_3d( ) : GTypeOfFE< Mesh3 >(dfon, d, 1, 3 * QFface.n * 3 * Element::nf + 3 * QFtetra.n * 3, Element::nf * QFface.n + QFtetra.n, false, true) { assert(QFface.n); assert(QFtetra.n); // 4 ref tetra vertices @@ -3870,8 +2631,7 @@ namespace Fem2D { for (int q = 0; q < QFface.n; ++q, ++p) { double x = QFface[q].x; double y = QFface[q].y; - this->PtInterpolation[p] = Pt[Element::nvface[f][0]] * (1. - x - y) + - Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; + this->PtInterpolation[p] = Pt[Element::nvface[f][0]] * (1. - x - y) + Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; } } @@ -3921,8 +2681,7 @@ namespace Fem2D { // For the coefficients of interpolation alphak in (13.1) - void TypeOfFE_RT1_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_RT1_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { int i = ocoef; // ******************************************* @@ -3938,25 +2697,24 @@ namespace Fem2D { double coefK = -3. * K.mesure( ); for (int ff = 0; ff < Element::nf; ff++) { // loop on the 4 face dofs - const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), - &K.at(Element::nvface[ff][2])}; + const Element::Vertex *fV[3] = {&K.at(Element::nvface[ff][0]), &K.at(Element::nvface[ff][1]), &K.at(Element::nvface[ff][2])}; int p[] = {0, 1, 2}; int fp = K.facePermutation(ff); - SetNumPerm<3>(fp,p); - - /* - if (fp & 1) { - Exchange(p[0], p[1]); - } + SetNumPerm< 3 >(fp, p); - if (fp & 2) { - Exchange(p[1], p[2]); - } + /* + if (fp & 1) { + Exchange(p[0], p[1]); + } - if (fp & 4) { - Exchange(p[0], p[1]); - } -*/ + if (fp & 2) { + Exchange(p[1], p[2]); + } + + if (fp & 4) { + Exchange(p[0], p[1]); + } + */ R3 N = NK[ff]; N *= coefK * K.faceOrient(ff); @@ -3965,8 +2723,7 @@ namespace Fem2D { double lambda[3] = {1. - QFface[q].x - QFface[q].y, QFface[q].x, QFface[q].y}; R sa = QFface[q].a; - R cp[3] = {(c1[0][0] * lambda[0] + c1[0][1] * lambda[1] + c1[0][2] * lambda[2]) * sa, - (c1[1][0] * lambda[0] + c1[1][1] * lambda[1] + c1[1][2] * lambda[2]) * sa, + R cp[3] = {(c1[0][0] * lambda[0] + c1[0][1] * lambda[1] + c1[0][2] * lambda[2]) * sa, (c1[1][0] * lambda[0] + c1[1][1] * lambda[1] + c1[1][2] * lambda[2]) * sa, (c1[2][0] * lambda[0] + c1[2][1] * lambda[1] + c1[2][2] * lambda[2]) * sa}; for (int idof = 0; idof < 3; idof++) { // loop sur 3 dof de la face @@ -3997,8 +2754,7 @@ namespace Fem2D { } // end set function // here the basis functions and theirs derivates - void TypeOfFE_RT1_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_RT1_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 15); assert(val.M( ) == 3); @@ -4012,46 +2768,39 @@ namespace Fem2D { R3 phi[4] = {X - K[0], X - K[1], X - K[2], X - K[3]}; // phi * area *6 // fo contain just the sign about permutation ----- 1perm=-1 / 2perm=1 / 3perm=-1 - double fo[4] = {(double)K.faceOrient(0), (double)K.faceOrient(1), (double)K.faceOrient(2), - (double)K.faceOrient(3)}; - int p[15] = {2, 1, 0, 3, 4, 5, 8, 7, - 6, 9, 10, 11, 12, 13, 14}; // Permutation for orientation to dof - R3 Pm[16]; // all the momome function .. + double fo[4] = {(double)K.faceOrient(0), (double)K.faceOrient(1), (double)K.faceOrient(2), (double)K.faceOrient(3)}; + int p[15] = {2, 1, 0, 3, 4, 5, 8, 7, 6, 9, 10, 11, 12, 13, 14}; // Permutation for orientation to dof + R3 Pm[16]; // all the momome function .. for (int ff = 0, k = 0; ff < Element::nf; ff++, k += 3) { // orientation de la face a envert int fp = K.facePermutation(ff); - int i0= fp/2, sp = fp%2; - if(!i0) { - if(!sp) Exchange(p[k+1], p[k +2]); - Exchange(p[k], p[k + i0]);// i0 en 0 + int i0 = fp / 2, sp = fp % 2; + if (!i0) { + if (!sp) Exchange(p[k + 1], p[k + 2]); + Exchange(p[k], p[k + i0]); // i0 en 0 + } else if (sp) + Exchange(p[k + 1], p[k + 2]); + /* + if (fp & 1) { + Exchange(p[k], p[k + 1]); } - else if(sp) Exchange(p[k+1], p[k + 2]); -/* - if (fp & 1) { - Exchange(p[k], p[k + 1]); - } - if (fp & 2) { - Exchange(p[k + 1], p[k + 2]); - } + if (fp & 2) { + Exchange(p[k + 1], p[k + 2]); + } - if (fp & 4) { - Exchange(p[k], p[k + 1]); - } - */ + if (fp & 4) { + Exchange(p[k], p[k + 1]); + } + */ } - double cf[][3] = { - {-1.25, 0.25, 0} /* 0 */, {-1.25, 0, 0.25} /* 1 */, {-1.5, -0.25, -0.25} /* 2 */, - {0.25, -1.25, 0} /* 3 */, {0, -1.25, 0.25} /* 4 */, {-0.25, -1.5, -0.25} /* 5 */, - {0.25, 0, -1.25} /* 6 */, {0, 0.25, -1.25} /* 7 */, {-0.25, -0.25, -1.5} /* 8 */, - {1.5, 1.25, 1.25} /* 9 */, {1.25, 1.5, 1.25} /* 10 */, {1.25, 1.25, 1.5} /* 11 */, - {-15, 15, 0} /* 12 */, {-15, 0, 15} /* 13 */, {-30, -15, -15} /* 14 */}; - int Bii[][2] = {{0, 0} /* 0 */, {0, 1} /* 1 */, {0, 2} /* 2 */, {0, 3} /* 3 */, - {1, 0} /* 4 */, {1, 1} /* 5 */, {1, 2} /* 6 */, {1, 3} /* 7 */, - {2, 0} /* 8 */, {2, 1} /* 9 */, {2, 2} /* 10 */, {2, 3} /* 11 */, - {3, 0} /* 12 */, {3, 1} /* 13 */, {3, 2} /* 14 */, {3, 3} /* 15 */}; + double cf[][3] = {{-1.25, 0.25, 0} /* 0 */, {-1.25, 0, 0.25} /* 1 */, {-1.5, -0.25, -0.25} /* 2 */, {0.25, -1.25, 0} /* 3 */, {0, -1.25, 0.25} /* 4 */, + {-0.25, -1.5, -0.25} /* 5 */, {0.25, 0, -1.25} /* 6 */, {0, 0.25, -1.25} /* 7 */, {-0.25, -0.25, -1.5} /* 8 */, {1.5, 1.25, 1.25} /* 9 */, + {1.25, 1.5, 1.25} /* 10 */, {1.25, 1.25, 1.5} /* 11 */, {-15, 15, 0} /* 12 */, {-15, 0, 15} /* 13 */, {-30, -15, -15} /* 14 */}; + int Bii[][2] = {{0, 0} /* 0 */, {0, 1} /* 1 */, {0, 2} /* 2 */, {0, 3} /* 3 */, {1, 0} /* 4 */, {1, 1} /* 5 */, {1, 2} /* 6 */, {1, 3} /* 7 */, + {2, 0} /* 8 */, {2, 1} /* 9 */, {2, 2} /* 10 */, {2, 3} /* 11 */, {3, 0} /* 12 */, {3, 1} /* 13 */, {3, 2} /* 14 */, {3, 3} /* 15 */}; int fe[] = {1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14}; int k6[] = {0, 5, 10}; @@ -4065,8 +2814,7 @@ namespace Fem2D { // caution to the numbering of the nodes of the face to the numbering of the basis function // cci - double sg[15] = {fo[0], fo[0], fo[0], fo[1], fo[1], fo[1], fo[2], fo[2], - fo[2], fo[3], fo[3], fo[3], 1., 1., 1.}; + double sg[15] = {fo[0], fo[0], fo[0], fo[1], fo[1], fo[1], fo[2], fo[2], fo[2], fo[3], fo[3], fo[3], 1., 1., 1.}; if (whatd & Fop_D0) { for (int pdf = 0; pdf < 15; ++pdf) { @@ -4175,11 +2923,10 @@ namespace Fem2D { } } // end basis functions declaration - - // RT1 surf + // RT1 surf - class TypeOfFE_RT1_surf : public GTypeOfFE { - public: + class TypeOfFE_RT1_surf : public GTypeOfFE< MeshS > { + public: typedef MeshS Mesh; typedef MeshS::Element Element; typedef GFElement< MeshS > FElement; @@ -4187,257 +2934,229 @@ namespace Fem2D { static const int d = Mesh::Rd::d; // quadrature Formula on an edge static const QuadratureFormular1d QFE; - //static const GQuadratureFormular< R2 > QFface; - // quadrature Formula on an element + // static const GQuadratureFormular< R2 > QFface; + // quadrature Formula on an element static const GQuadratureFormular< R2 > QFK; - //static const GQuadratureFormular< R3 > QFtetra; + // static const GQuadratureFormular< R3 > QFtetra; TypeOfFE_RT1_surf( ); - void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; - }; + void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; - int TypeOfFE_RT1_surf::dfon[] = {0, 2, 2, 0}; // dofs per vertice, edge, face, volume - // Quadrature formula on a edge, - const QuadratureFormular1d TypeOfFE_RT1_surf::QFE(3, 2, GaussLegendre(2), true); // (QF_GaussLegendre2); - // Quadrature formula on the triangle - const GQuadratureFormular< R2 > TypeOfFE_RT1_surf::QFK(QuadratureFormular_T_5); - TypeOfFE_RT1_surf::TypeOfFE_RT1_surf( ) - : GTypeOfFE< MeshS >(dfon, d, 2, 3 * QFE.n * 2 * Element::ne + 2 * QFK.n * 3, - Element::ne * QFE.n + QFK.n, false, true) { - - assert(QFK.n); - assert(QFE.n); - // 3 ref triangle vertices - R2 Pt[] = {R2(0., 0.), R2(1., 0.), R2(0., 1.)}; - - // the interpolation pts on the faces - int p = 0; - for (int e = 0; e < Element::ne; ++e) { - for (int q = 0; q < QFE.n; ++q,++p) { - RdHat A(TriangleHat[VerticesOfTriangularEdge[e][0]]); // a remplacer - RdHat B(TriangleHat[VerticesOfTriangularEdge[e][1]]); // a remplacer - - this->PtInterpolation[p] = Pt[Element::nvedge[e][0]] * (1. - QFE[q].x) + - Pt[Element::nvedge[e][1]] * QFE[q].x; + int TypeOfFE_RT1_surf::dfon[] = {0, 2, 2, 0}; // dofs per vertice, edge, face, volume + // Quadrature formula on a edge, + const QuadratureFormular1d TypeOfFE_RT1_surf::QFE(3, 2, GaussLegendre(2), true); // (QF_GaussLegendre2); + // Quadrature formula on the triangle + const GQuadratureFormular< R2 > TypeOfFE_RT1_surf::QFK(QuadratureFormular_T_5); + TypeOfFE_RT1_surf::TypeOfFE_RT1_surf( ) : GTypeOfFE< MeshS >(dfon, d, 2, 3 * QFE.n * 2 * Element::ne + 2 * QFK.n * 3, Element::ne * QFE.n + QFK.n, false, true) { + + assert(QFK.n); + assert(QFE.n); + // 3 ref triangle vertices + R2 Pt[] = {R2(0., 0.), R2(1., 0.), R2(0., 1.)}; + + // the interpolation pts on the faces + int p = 0; + for (int e = 0; e < Element::ne; ++e) { + for (int q = 0; q < QFE.n; ++q, ++p) { + RdHat A(TriangleHat[VerticesOfTriangularEdge[e][0]]); // a remplacer + RdHat B(TriangleHat[VerticesOfTriangularEdge[e][1]]); // a remplacer + + this->PtInterpolation[p] = Pt[Element::nvedge[e][0]] * (1. - QFE[q].x) + Pt[Element::nvedge[e][1]] * QFE[q].x; + } + } + // the interpolation bubble pts + for (int q = 0; q < QFK.n; ++q, ++p) this->PtInterpolation[p] = QFK[q]; + + int i = 0; + p = 0; + + for (int e = 0; e < Element::ne; e++) { // loop on the 3 edges + for (int q = 0; q < QFE.n; ++q, p++) { // loop on the face quadrature pts + for (int df = 0; df < 2; df++) { // 2 dof per edge + int dof = 2 * e + df; // numero du dof 2 dof / edge + + for (int c = 0; c < 3; c++, i++) { // loop on the 3 components + this->pInterpolation[i] = p; // pk + this->cInterpolation[i] = c; // jk + this->dofInterpolation[i] = dof; // ik + this->coefInterpolation[i] = 0.; } } - // the interpolation bubble pts - for (int q = 0; q < QFK.n; ++q, ++p) - this->PtInterpolation[p] = QFK[q]; - - int i = 0; - p = 0; - - for (int e = 0; e < Element::ne; e++) { // loop on the 3 edges - for (int q = 0; q < QFE.n; ++q, p++) { // loop on the face quadrature pts - for (int df = 0; df < 2; df++) { // 2 dof per edge - int dof = 2 * e + df; // numero du dof 2 dof / edge - - for (int c = 0; c < 3; c++, i++) { // loop on the 3 components - this->pInterpolation[i] = p; // pk - this->cInterpolation[i] = c; // jk - this->dofInterpolation[i] = dof; // ik - this->coefInterpolation[i] = 0.; - } - } - } + } + } + + p = Element::ne * QFE.n; + + for (int q = 0; q < QFK.n; ++q, ++p) { // loop on the volume quadrature pts + for (int v = 6; v < 8; v++) { // loop on the 2 volume dofs + for (int c = 0; c < 3; c++, i++) { // loop on the 3 components + this->pInterpolation[i] = p; // pk + this->cInterpolation[i] = c; // jk + this->dofInterpolation[i] = v; // ik + this->coefInterpolation[i] = 0.; } + } + } + ffassert(p == this->PtInterpolation.N( )); + } - p = Element::ne * QFE.n; + void TypeOfFE_RT1_surf::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { + int i = ocoef; - for (int q = 0; q < QFK.n; ++q, ++p) { // loop on the volume quadrature pts - for (int v = 6; v < 8; v++) { // loop on the 2 volume dofs - for (int c = 0; c < 3; c++, i++) { // loop on the 3 components - this->pInterpolation[i] = p; // pk - this->cInterpolation[i] = c; // jk - this->dofInterpolation[i] = v; // ik - this->coefInterpolation[i] = 0.; - } - } + // 2dofs per edges + for (int e = 0; e < 3; e++) { + R3 N = K.N(e); + R s = K.EdgeOrientation(e); + for (int q = 0; q < QFE.n; ++q) { + R l0 = QFE[q].x, l1 = 1 - QFE[q].x; + R p[2] = {(2 * l0 - l1) * 2, (2 * l1 - l0) * 2}; // poly othogonaux to \lambda_1, to \lambda_0 + R cp[2] = {s * p[0] * QFE[q].a, s * p[1] * QFE[q].a}; + + if (s < 0) swap(cp[0], cp[1]); + for (int idof = 0; idof < 2; idof++) { + for (int c = 0; c < 3; c++, i++) M.coef[i] = N[c] * cp[idof]; } - ffassert(p == this->PtInterpolation.N( )); } + } - - void TypeOfFE_RT1_surf::set(const Mesh & Th,const Element & K,InterpolationMatrix & M ,int ocoef,int odf,int *nump) const - { - int i = ocoef; - - - // 2dofs per edges - for (int e = 0; e < 3; e++) { - R3 N=K.N(e); - R s = K.EdgeOrientation(e) ; - for (int q = 0; q < QFE.n; ++q) { - R l0 = QFE[q].x, l1 = 1 - QFE[q].x; - R p[2] = { (2 * l0 - l1) * 2, (2 * l1 - l0) * 2 } ; // poly othogonaux to \lambda_1, to \lambda_0 - R cp[2] = { s * p[0] * QFE[q].a, s * p[1] * QFE[q].a}; - - if (s < 0) - swap(cp[0], cp[1]); - for (int idof = 0; idof < 2; idof++) { - for (int c = 0; c < 3; c++, i++) - M.coef[i] = N[c] * cp[idof]; - } - } - } + // 2 dofs on the triangle + double CK = -K.mesure( ); // dof U= [u1,u2,u3] > |K| int_K ( B_i.U ) + R3 N[2] = {K.N(1), K.N(2)}; + for (int q = 0; q < QFK.n; ++q) { + double w = QFK[q].a * CK; + for (int l = 0; l < 2; ++l) { + M.coef[i++] = w * N[l].x; + M.coef[i++] = w * N[l].y; + M.coef[i++] = w * N[l].z; + } + } + } - // 2 dofs on the triangle - double CK = -K.mesure( ); // dof U= [u1,u2,u3] > |K| int_K ( B_i.U ) - R3 N[2] = {K.N(1), K.N(2)}; - for (int q = 0; q < QFK.n; ++q) { - double w = QFK[q].a * CK; - for (int l = 0; l < 2; ++l) { - M.coef[i++] = w * N[l].x; - M.coef[i++] = w * N[l].y; - M.coef[i++] = w * N[l].z; - } - } - + void TypeOfFE_RT1_surf::FB(const What_d whatd, const Mesh &Th, const MeshS::Element &K, const RdHat &PHat, RNMK_ &val) const { + assert(val.N( ) >= 8); + assert(val.M( ) == 3); + + val = 0; + R3 A(K[0]), B(K[1]), C(K[2]); + R l[] = {1. - PHat.sum( ), PHat.x, PHat.y}; + R3 D[3]; + K.Gradlambda(D); + + // loc basis + R3 AB(A, B), AC(A, C), BA(B, A), BC(B, C), CA(C, A), CB(C, B); + int eo[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; + R c[3]; + c[0] = 1. / (((AB, D[1]) + (AC, D[2])) * K.mesure( )); // c[0]*= eo[0] ; + c[1] = 1. / (((BA, D[0]) + (BC, D[2])) * K.mesure( )); // c[1]*= eo[1]; + c[2] = 1. / (((CA, D[0]) + (CB, D[1])) * K.mesure( )); // c[2]*= eo[2]; + + R3 phi[3]; + phi[0] = AB * (l[1] * c[0]) + AC * (l[2] * c[0]); + phi[1] = BA * (l[0] * c[1]) + BC * (l[2] * c[1]); + phi[2] = CA * (l[0] * c[2]) + CB * (l[1] * c[2]); + + int pI[8][3]; // store p_k + int lI[8][3]; // store l_k + R cI[8][3]; // store c_k + int df = 0; + R CKK = 2 * K.mesure( ); + + for (int e = 0; e < 3; ++e) { + int i = e; + int ii[2] = {(e + 1) % 3, (e + 2) % 3}; + R s = eo[e] / CKK; + if (s < 0) swap(ii[0], ii[1]); + + for (int k = 0; k < 2; ++k, df++) { + pI[df][0] = i; + lI[df][0] = ii[k]; + cI[df][0] = s; + + pI[df][1] = i; + lI[df][1] = i; + cI[df][1] = -s * 4. / 3.; + + pI[df][2] = ii[k]; + lI[df][2] = ii[k]; + cI[df][2] = s / 3.; } - - - void TypeOfFE_RT1_surf::FB(const What_d whatd,const Mesh & Th,const MeshS::Element & K,const RdHat &PHat, RNMK_ & val) const - { - assert(val.N( ) >= 8); - assert(val.M() == 3); - - val = 0; - R3 A(K[0]),B(K[1]),C(K[2]); - R l[]={1.-PHat.sum(),PHat.x,PHat.y}; - R3 D[3]; - K.Gradlambda(D); - - //loc basis - R3 AB(A,B),AC(A,C),BA(B,A),BC(B,C),CA(C,A),CB(C,B); - int eo[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; - R c[3]; - c[0] = 1./(((AB,D[1]) + (AC,D[2])) *K.mesure()) ; //c[0]*= eo[0] ; - c[1] = 1./(((BA,D[0]) + (BC,D[2])) *K.mesure()) ; //c[1]*= eo[1]; - c[2] = 1./(((CA,D[0]) + (CB,D[1])) *K.mesure()) ; //c[2]*= eo[2]; - - R3 phi[3]; - phi[0] = AB*(l[1]*c[0]) + AC*(l[2]*c[0]); - phi[1] = BA*(l[0]*c[1]) + BC*(l[2]*c[1]); - phi[2] = CA*(l[0]*c[2]) + CB*(l[1]*c[2]); - - int pI[8][3]; // store p_k - int lI[8][3]; // store l_k - R cI[8][3]; // store c_k - int df = 0; - R CKK = 2 * K.mesure(); - - for (int e = 0; e < 3; ++e) { - int i = e; - int ii[2] = {(e + 1) % 3, (e + 2) % 3}; - R s = eo[e] / CKK; - if (s < 0) - swap(ii[0], ii[1]); - - for (int k = 0; k < 2; ++k, df++) { - pI[df][0] = i; - lI[df][0] = ii[k]; - cI[df][0] = s; - - pI[df][1] = i; - lI[df][1] = i; - cI[df][1] = -s * 4. / 3.; - - pI[df][2] = ii[k]; - lI[df][2] = ii[k]; - cI[df][2] = s / 3.; - } - } + } - R s8 = 8 / CKK, s01 = s8; - R cbb[] = {s8, 2 * s01, -s01, s8}; // { [ 8, 16], [ -8, 8] } + R s8 = 8 / CKK, s01 = s8; + R cbb[] = {s8, 2 * s01, -s01, s8}; // { [ 8, 16], [ -8, 8] } - // the 2 bubbles - for (int k = 0; k < 2; ++k, df++) { - pI[df][0] = 0; - lI[df][0] = 0; - cI[df][0] = cbb[k]; + // the 2 bubbles + for (int k = 0; k < 2; ++k, df++) { + pI[df][0] = 0; + lI[df][0] = 0; + cI[df][0] = cbb[k]; - pI[df][1] = 1; // i - lI[df][1] = 1; - cI[df][1] = cbb[k + 2]; + pI[df][1] = 1; // i + lI[df][1] = 1; + cI[df][1] = cbb[k + 2]; - pI[df][2] = 2; - lI[df][2] = 2; - cI[df][2] = 0; - } + pI[df][2] = 2; + lI[df][2] = 2; + cI[df][2] = 0; + } - ffassert(df == 8); + ffassert(df == 8); - if (whatd & Fop_D0){ - for (int df = 0; df < 8; ++df) { - R3 fd(0., 0., 0.); - for (int k = 0; k < 3; ++k) - fd += (cI[df][k] * l[lI[df][k]]) * phi[pI[df][k]]; - val(df, 0, op_id) = fd.x; - val(df, 1, op_id) = fd.y; - val(df, 2, op_id) = fd.z; - } - } + if (whatd & Fop_D0) { + for (int df = 0; df < 8; ++df) { + R3 fd(0., 0., 0.); + for (int k = 0; k < 3; ++k) fd += (cI[df][k] * l[lI[df][k]]) * phi[pI[df][k]]; + val(df, 0, op_id) = fd.x; + val(df, 1, op_id) = fd.y; + val(df, 2, op_id) = fd.z; + } + } - if (whatd & Fop_D1) { - R3 D[3]; - K.Gradlambda(D); - if (whatd & Fop_dx) { - R3 Dphix[3] = { AB*(D[1].x*c[0]) + AC*(D[2].x*c[0]), - BA*(D[0].x*c[1]) + BC*(D[2].x*c[1]), - CA*(D[0].x*c[2]) + CB*(D[1].x*c[2])}; - for (int df = 0; df < 8; ++df) { - R3 fd(0., 0.,0.); - - for (int k = 0; k < 3; ++k) - fd += cI[df][k] * (D[lI[df][k]].x * phi[pI[df][k]] + l[lI[df][k]] * Dphix[k]); - val(df, 0, op_dx) = fd.x; - val(df, 1, op_dx) = fd.y; - val(df, 2, op_dx) = fd.z; - } - } + if (whatd & Fop_D1) { + R3 D[3]; + K.Gradlambda(D); + if (whatd & Fop_dx) { + R3 Dphix[3] = {AB * (D[1].x * c[0]) + AC * (D[2].x * c[0]), BA * (D[0].x * c[1]) + BC * (D[2].x * c[1]), CA * (D[0].x * c[2]) + CB * (D[1].x * c[2])}; + for (int df = 0; df < 8; ++df) { + R3 fd(0., 0., 0.); - if (whatd & Fop_dy) { - R3 Dphiy[3] = { AB*(D[1].y*c[0]) + AC*(D[2].y*c[0]), - BA*(D[0].y*c[1]) + BC*(D[2].y*c[1]), - CA*(D[0].y*c[2]) + CB*(D[1].y*c[2])}; - for (int df = 0; df < 8; ++df) { - R3 fd(0., 0.,0.); - - for (int k = 0; k < 3; ++k) - fd += cI[df][k] * (D[lI[df][k]].y * phi[pI[df][k]] + l[lI[df][k]] * Dphiy[k]); - val(df, 0, op_dy) = fd.x; - val(df, 1, op_dy) = fd.y; - val(df, 2, op_dy) = fd.z; - } - } + for (int k = 0; k < 3; ++k) fd += cI[df][k] * (D[lI[df][k]].x * phi[pI[df][k]] + l[lI[df][k]] * Dphix[k]); + val(df, 0, op_dx) = fd.x; + val(df, 1, op_dx) = fd.y; + val(df, 2, op_dx) = fd.z; + } + } - if (whatd & Fop_dz) { - R3 Dphiz[3] = { AB*(D[1].z*c[0]) + AC*(D[2].z*c[0]), - BA*(D[0].z*c[1]) + BC*(D[2].z*c[1]), - CA*(D[0].z*c[2]) + CB*(D[1].z*c[2])}; - for (int df = 0; df < 8; ++df) { - R3 fd(0., 0.,0.); - - for (int k = 0; k < 3; ++k) - fd += cI[df][k] * (D[lI[df][k]].z * phi[pI[df][k]] + l[lI[df][k]] * Dphiz[k]); - - val(df, 0, op_dz) = fd.x; - val(df, 1, op_dz) = fd.y; - val(df, 2, op_dz) = fd.z; - } - } + if (whatd & Fop_dy) { + R3 Dphiy[3] = {AB * (D[1].y * c[0]) + AC * (D[2].y * c[0]), BA * (D[0].y * c[1]) + BC * (D[2].y * c[1]), CA * (D[0].y * c[2]) + CB * (D[1].y * c[2])}; + for (int df = 0; df < 8; ++df) { + R3 fd(0., 0., 0.); + + for (int k = 0; k < 3; ++k) fd += cI[df][k] * (D[lI[df][k]].y * phi[pI[df][k]] + l[lI[df][k]] * Dphiy[k]); + val(df, 0, op_dy) = fd.x; + val(df, 1, op_dy) = fd.y; + val(df, 2, op_dy) = fd.z; } - if (whatd & Fop_D2) - ffassert(0); - + } + + if (whatd & Fop_dz) { + R3 Dphiz[3] = {AB * (D[1].z * c[0]) + AC * (D[2].z * c[0]), BA * (D[0].z * c[1]) + BC * (D[2].z * c[1]), CA * (D[0].z * c[2]) + CB * (D[1].z * c[2])}; + for (int df = 0; df < 8; ++df) { + R3 fd(0., 0., 0.); + + for (int k = 0; k < 3; ++k) fd += cI[df][k] * (D[lI[df][k]].z * phi[pI[df][k]] + l[lI[df][k]] * Dphiz[k]); + + val(df, 0, op_dz) = fd.x; + val(df, 1, op_dz) = fd.y; + val(df, 2, op_dz) = fd.z; + } + } } - - - // add new FEs for DDM to build the partition of unity + if (whatd & Fop_D2) ffassert(0); + } + + // add new FEs for DDM to build the partition of unity static TypeOfFE_P2Edge3ds0 Elm_P2Edge3ds0; // a static variable to add the finite element to freefem++ static AddNewFE3 P2Edge3ds0("Edge23ds0", &Elm_P2Edge3ds0); @@ -4449,7 +3168,7 @@ namespace Fem2D { static TypeOfFE_P0Edge3ds0 Elm_P0Edge3ds0; // a static variable to add the finite element to freefem++ static AddNewFE3 P0Edge3d("Edge03ds0", &Elm_P0Edge3ds0); - static TypeOfFE_Edge1_3d Edge1_3d; // TypeOfFE_Edge1_3d is the name of the class we defined + static TypeOfFE_Edge1_3d Edge1_3d; // TypeOfFE_Edge1_3d is the name of the class we defined GTypeOfFE< Mesh3 > &GEdge13d(Edge1_3d); // GTypeOfFE is the mother class static AddNewFE3 TypeOfFE_Edge1_3d("Edge13d", &GEdge13d); // Edge13d will be the name used by the user @@ -4464,8 +3183,6 @@ namespace Fem2D { GTypeOfFE< MeshS > &RT1S(RT1_S); static AddNewFES TypeOfFE_RT1_surf("RT1S", &RT1S); - - } // namespace Fem2D // --- fin -- diff --git a/plugin/seq/Element_P1bl.cpp b/plugin/seq/Element_P1bl.cpp index c0937512a..14563ba3f 100644 --- a/plugin/seq/Element_P1bl.cpp +++ b/plugin/seq/Element_P1bl.cpp @@ -44,15 +44,12 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; - int TypeOfFE_P1Bubble2::Data[] = {0, 1, 2, 6, 0, 0, 0, 0, 0, 1, 2, 3, - 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 4}; + int TypeOfFE_P1Bubble2::Data[] = {0, 1, 2, 6, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 4}; double TypeOfFE_P1Bubble2::Pi_h_coef[] = {1., 1., 1., 1.}; - void TypeOfFE_P1Bubble2::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P1Bubble2::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { // const Triangle & K(FE.T); R2 A(K[0]), B(K[1]), C(K[2]); R l[] = {1 - PHat.x - PHat.y, PHat.x, PHat.y}; // lb=l0*l1*l2*9.; @@ -110,12 +107,10 @@ namespace Fem2D { typedef GFElement< Mesh3 > FElement; TypeOfFE_P1blLagrange3d( ) : TypeOfFE_Lagrange< Mesh3 >(-1) {} - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; }; - void TypeOfFE_P1blLagrange3d::FB(const What_d whatd, const Mesh &, const Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P1blLagrange3d::FB(const What_d whatd, const Mesh &, const Element &K, const RdHat &PHat, RNMK_ &val) const { R l[] = {1. - PHat.sum( ), PHat.x, PHat.y, PHat.z}; const R d1 = dHat + 1.; const R d13 = d1 * d1 * d1; diff --git a/plugin/seq/Element_P1dc1.cpp b/plugin/seq/Element_P1dc1.cpp index d18bdd32b..768b8b3fe 100644 --- a/plugin/seq/Element_P1dc1.cpp +++ b/plugin/seq/Element_P1dc1.cpp @@ -60,10 +60,8 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; - virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, - int op) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; }; const R2 TypeOfFE_P1ttdc1_::G(1. / 3., 1. / 3.); @@ -82,8 +80,7 @@ namespace Fem2D { static R2 Shrink1(const R2 &P) { return (P - G) * cshrink1 + G; } TypeOfFE_P2ttdc1_( ) : TypeOfFE(0, 0, 6, 1, Data, 3, 1, 6, 6, Pi_h_coef) { - const R2 Pt[] = {Shrink(R2(0, 0)), Shrink(R2(1, 0)), Shrink(R2(0, 1)), - Shrink(R2(0.5, 0.5)), Shrink(R2(0, 0.5)), Shrink(R2(0.5, 0))}; + const R2 Pt[] = {Shrink(R2(0, 0)), Shrink(R2(1, 0)), Shrink(R2(0, 1)), Shrink(R2(0.5, 0.5)), Shrink(R2(0, 0.5)), Shrink(R2(0.5, 0))}; for (int i = 0; i < NbDoF; i++) { pij_alpha[i] = IPJ(i, i, 0); @@ -91,21 +88,18 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; // on what nu df on node node of df int TypeOfFE_P1ttdc1_::Data[] = {6, 6, 6, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 3}; - int TypeOfFE_P2ttdc1_::Data[] = {6, 6, 6, 6, 6, 6, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6}; + int TypeOfFE_P2ttdc1_::Data[] = {6, 6, 6, 6, 6, 6, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6}; double TypeOfFE_P1ttdc1_::Pi_h_coef[] = {1., 1., 1.}; double TypeOfFE_P2ttdc1_::Pi_h_coef[] = {1., 1., 1., 1., 1., 1.}; const R2 TypeOfFE_P2ttdc1_::G(1. / 3., 1. / 3.); const R TypeOfFE_P2ttdc1_::cshrink = 1; const R TypeOfFE_P2ttdc1_::cshrink1 = 1. / TypeOfFE_P2ttdc1_::cshrink; - R TypeOfFE_P1ttdc1_::operator( )(const FElement &K, const R2 &P1Hat, const KN_< R > &u, - int componante, int op) const { + R TypeOfFE_P1ttdc1_::operator( )(const FElement &K, const R2 &P1Hat, const KN_< R > &u, int componante, int op) const { R2 PHat = Shrink1(P1Hat); R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); R r = 0; @@ -126,8 +120,7 @@ namespace Fem2D { return r; } - void TypeOfFE_P1ttdc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P1ttdc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 P = Shrink1(PHat); // const Triangle & K(FE.T); @@ -168,8 +161,7 @@ namespace Fem2D { } } - void TypeOfFE_P2ttdc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P2ttdc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 P = Shrink1(PHat); // const Triangle & K(FE.T); @@ -251,14 +243,12 @@ namespace Fem2D { // // end ttdc1_ - - // 3d - template - void SetPtPkDC(typename MMesh::Element::RdHat *Pt, int kk, int nn, R cc = 1) ; - //volume + template< class MMesh > + void SetPtPkDC(typename MMesh::Element::RdHat *Pt, int kk, int nn, R cc = 1); + // volume template<> - void SetPtPkDC(R3 *Pt, int kk, int nn, R cc) { // P0 P1 et P2 , P1b + void SetPtPkDC< Mesh3 >(R3 *Pt, int kk, int nn, R cc) { // P0 P1 et P2 , P1b const int d = 3; int n = 0; double dK = kk; @@ -280,56 +270,52 @@ namespace Fem2D { cout << " Pkdc = " << KN_< R3 >(Pt, nn) << "\n"; } } - - //surface + + // surface template<> - void SetPtPkDC(R2 *Pt, int kk, int nn, R cc) { + void SetPtPkDC< MeshS >(R2 *Pt, int kk, int nn, R cc) { const int dHat = 2; int n = 0; double dK = kk; - double cc1 = 1 - cc; + double cc1 = 1 - cc; const R2 G = R2::diag(1. / (dHat + 1)); // barycenter - for (int i = 0; i <= kk; ++i) - for (int j = 0; j <= kk - i; ++j) - Pt[n++] = R2(j / dK, i / dK) * cc + G * cc1; + for (int i = 0; i <= kk; ++i) + for (int j = 0; j <= kk - i; ++j) Pt[n++] = R2(j / dK, i / dK) * cc + G * cc1; ffassert(n == nn); if (verbosity > 9) { cout << " Pkdc = " << KN_< R2 >(Pt, nn) << "\n"; } } - - //curve + + // curve template<> - void SetPtPkDC(R1 *Pt, int kk, int nn, R cc) { + void SetPtPkDC< MeshL >(R1 *Pt, int kk, int nn, R cc) { const int dHat = 2; int n = 0; double dK = kk; - double cc1 = 1 - cc; - const R G = R(1./2.); // barycenter + double cc1 = 1 - cc; + const R G = R(1. / 2.); // barycenter - for (int i = 0; i <= kk; ++i) - Pt[n++] = R1(i / dK) * cc + G * cc1; + for (int i = 0; i <= kk; ++i) Pt[n++] = R1(i / dK) * cc + G * cc1; ffassert(n == nn); if (verbosity > 9) { cout << " Pkdc = " << KN_< R1 >(Pt, nn) << "\n"; } - } - + } - // 3d - template + template< class MMesh > class TypeOfFE_LagrangeDC3d : public GTypeOfFE< MMesh > { // typedef typename MMesh Mesh; - public: - typedef GFElement FElement; + public: + typedef GFElement< MMesh > FElement; typedef typename MMesh::Element Element; typedef typename Element::Rd Rd; typedef typename Element::RdHat RdHat; static const int d = Rd::d; - static const int dHat = RdHat::d; + static const int dHat = RdHat::d; const R cshrink; const R cshrink1; static const RdHat G; @@ -343,8 +329,7 @@ namespace Fem2D { int dfon[4]; A4(int k) { - int ndf = (dHat == 3) ? ((k + 3) * (k + 2) * (k + 1) / 6) - : ((dHat == 2) ? ((k + 2) * (k + 1) / 2) : k + 1); + int ndf = (dHat == 3) ? ((k + 3) * (k + 2) * (k + 1) / 6) : ((dHat == 2) ? ((k + 2) * (k + 1) / 2) : k + 1); dfon[0] = dfon[1] = dfon[2] = dfon[3] = 0; dfon[dHat] = ndf; @@ -359,18 +344,15 @@ namespace Fem2D { RdHat *Pt; TypeOfFE_LagrangeDC3d(int kk, R cc) : // dfon ,N,nsub(graphique) , const mat interpolation , discontinuous - GTypeOfFE< MMesh >(A4(kk), 1, Max(kk, 1), true, true), cshrink(cc), cshrink1(1. / cc), - k(kk) { + GTypeOfFE< MMesh >(A4(kk), 1, Max(kk, 1), true, true), cshrink(cc), cshrink1(1. / cc), k(kk) { int n = this->NbDoF; if (verbosity > 9) { cout << "\n +++ Pdc" << k << " : ndof : " << n << endl; } - SetPtPkDC(this->PtInterpolation, k, this->NbDoF, cc); - if (verbosity > 9) - cout << " ppppp " << this->PtInterpolation << endl; - + SetPtPkDC< MMesh >(this->PtInterpolation, k, this->NbDoF, cc); + if (verbosity > 9) cout << " ppppp " << this->PtInterpolation << endl; { for (int i = 0; i < n; i++) { @@ -384,21 +366,18 @@ namespace Fem2D { ~TypeOfFE_LagrangeDC3d( ) {} + void FB(const What_d whatd, const MMesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const; + R operator( )(const FElement &K, const RdHat &PHat, const KN_< R > &u, int componante, int op) const; - void FB(const What_d whatd, const MMesh &Th, const Element &K, const RdHat &PHat,RNMK_ &val) const; - R operator( )(const FElement &K, const RdHat &PHat, const KN_< R > &u, int componante,int op) const; - private: TypeOfFE_LagrangeDC3d(const TypeOfFE_LagrangeDC3d &); void operator=(const TypeOfFE_LagrangeDC3d &); }; - - - + template<> - void TypeOfFE_LagrangeDC3d::FB(const What_d whatd, const Mesh3 &Th, const Mesh3::Element &K,const RdHat &PHat, RNMK_ &val) const { - - R3 P = this->Shrink1(PHat); + void TypeOfFE_LagrangeDC3d< Mesh3 >::FB(const What_d whatd, const Mesh3 &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { + + R3 P = this->Shrink1(PHat); R l[] = {1. - P.sum( ), P.x, P.y, P.z}; assert(val.N( ) >= Element::nv); @@ -448,10 +427,8 @@ namespace Fem2D { } } - - template<> - R TypeOfFE_LagrangeDC3d::operator( )(const FElement &K, const R3 &PHat1, const KN_< R > &u,int componante, int op) const { + R TypeOfFE_LagrangeDC3d< Mesh3 >::operator( )(const FElement &K, const R3 &PHat1, const KN_< R > &u, int componante, int op) const { R3 PHat = Shrink1(PHat1); R r = 0; @@ -486,12 +463,10 @@ namespace Fem2D { } template<> - const R3 TypeOfFE_LagrangeDC3d::G(1. / 4., 1. / 4., 1. / 4.); - - + const R3 TypeOfFE_LagrangeDC3d< Mesh3 >::G(1. / 4., 1. / 4., 1. / 4.); template<> - void TypeOfFE_LagrangeDC3d::FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K,const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_LagrangeDC3d< MeshS >::FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K, const RdHat &PHat, RNMK_ &val) const { R2 P = this->Shrink1(PHat); R l[] = {1. - P.sum( ), P.x, P.y}; @@ -539,7 +514,7 @@ namespace Fem2D { } template<> - R TypeOfFE_LagrangeDC3d::operator( )(const FElement &K, const R2 &PHat1, const KN_< R > &u,int componante, int op) const { + R TypeOfFE_LagrangeDC3d< MeshS >::operator( )(const FElement &K, const R2 &PHat1, const KN_< R > &u, int componante, int op) const { R2 PHat = Shrink1(PHat1); R r = 0; @@ -549,7 +524,7 @@ namespace Fem2D { if (op == 0) { R l[3]; PHat.toBary(l); - r = u0 * l[0] + u1 * l[1] + l[2] * u2 ; + r = u0 * l[0] + u1 * l[1] + l[2] * u2; } else if (op == op_dx || op == op_dy || op == op_dz) { const Element &T = K.T; R3 D[3]; @@ -560,11 +535,11 @@ namespace Fem2D { } if (op == op_dx) { - r = D[0].x * u0 + D[1].x * u1 + D[2].x * u2 ; + r = D[0].x * u0 + D[1].x * u1 + D[2].x * u2; } else if (op == op_dy) { - r = D[0].y * u0 + D[1].y * u1 + D[2].y * u2 ; + r = D[0].y * u0 + D[1].y * u1 + D[2].y * u2; } else { - r = D[0].z * u0 + D[1].z * u1 + D[2].z * u2 ; + r = D[0].z * u0 + D[1].z * u1 + D[2].z * u2; } } } else { @@ -574,11 +549,10 @@ namespace Fem2D { return r; } template<> - const R2 TypeOfFE_LagrangeDC3d::G(1. / 3., 1. / 3.); - - + const R2 TypeOfFE_LagrangeDC3d< MeshS >::G(1. / 3., 1. / 3.); + template<> - void TypeOfFE_LagrangeDC3d::FB(const What_d whatd, const MeshL &Th, const MeshL::Element &K,const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_LagrangeDC3d< MeshL >::FB(const What_d whatd, const MeshL &Th, const MeshL::Element &K, const RdHat &PHat, RNMK_ &val) const { R1 P = this->Shrink1(PHat); R l[] = {1. - P.x, P.x}; @@ -622,7 +596,7 @@ namespace Fem2D { } template<> - R TypeOfFE_LagrangeDC3d::operator( )(const FElement &K, const R1 &PHat1, const KN_< R > &u,int componante, int op) const { + R TypeOfFE_LagrangeDC3d< MeshL >::operator( )(const FElement &K, const R1 &PHat1, const KN_< R > &u, int componante, int op) const { R1 PHat = Shrink1(PHat1); R r = 0; @@ -632,7 +606,7 @@ namespace Fem2D { if (op == 0) { R l[2]; PHat.toBary(l); - r = u0 * l[0] + u1 * l[1] ; + r = u0 * l[0] + u1 * l[1]; } else if (op == op_dx || op == op_dy || op == op_dz) { const Element &T = K.T; R3 D[2]; @@ -643,11 +617,11 @@ namespace Fem2D { } if (op == op_dx) { - r = D[0].x * u0 + D[1].x * u1 ; + r = D[0].x * u0 + D[1].x * u1; } else if (op == op_dy) { - r = D[0].y * u0 + D[1].y * u1 ; + r = D[0].y * u0 + D[1].y * u1; } else { - r = D[0].z * u0 + D[1].z * u1 ; + r = D[0].z * u0 + D[1].z * u1; } } } else { @@ -656,40 +630,38 @@ namespace Fem2D { return r; } - + template<> - const R1 TypeOfFE_LagrangeDC3d::G(1. / 2.); - - + const R1 TypeOfFE_LagrangeDC3d< MeshL >::G(1. / 2.); + } // namespace Fem2D static void finit( ) { // link with FreeFem++ static TypeOfFE_P1ttdc1_ P1dc1LagrangeP1dc1; static TypeOfFE_P2ttdc1_ P2dc1LagrangeP2dc1; - - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dtt(1, 0.999); - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dtt1(1, 1.); - - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dStt(1, 0.999); - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dStt1(1, 1.); - - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dLtt(1, 0.999); - static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dLtt1(1, 1.); - + + static TypeOfFE_LagrangeDC3d< Mesh3 > TypeOfFE_LagrangeDC3dtt(1, 0.999); + static TypeOfFE_LagrangeDC3d< Mesh3 > TypeOfFE_LagrangeDC3dtt1(1, 1.); + + static TypeOfFE_LagrangeDC3d< MeshS > TypeOfFE_LagrangeDC3dStt(1, 0.999); + static TypeOfFE_LagrangeDC3d< MeshS > TypeOfFE_LagrangeDC3dStt1(1, 1.); + + static TypeOfFE_LagrangeDC3d< MeshL > TypeOfFE_LagrangeDC3dLtt(1, 0.999); + static TypeOfFE_LagrangeDC3d< MeshL > TypeOfFE_LagrangeDC3dLtt1(1, 1.); + // a static variable to add the finite element to freefem++ static AddNewFE P1dcLagrange("P1dc1", &P1dc1LagrangeP1dc1); static AddNewFE P2dcLagrange("P2dc1", &P2dc1LagrangeP2dc1); - - static AddNewFE3 P1dttLagrange3d("P1dc3d2", &TypeOfFE_LagrangeDC3dtt);// deja code + + static AddNewFE3 P1dttLagrange3d("P1dc3d2", &TypeOfFE_LagrangeDC3dtt); // deja code static AddNewFE3 P1dttLagrange3d1("P1dc3d1", &TypeOfFE_LagrangeDC3dtt1); - + static AddNewFES P1dttLagrange3dS("P1dcS2", &TypeOfFE_LagrangeDC3dStt); static AddNewFES P1dttLagrange3dS1("P1dcS1", &TypeOfFE_LagrangeDC3dStt1); - + static AddNewFEL P1dttLagrange3dL("P1dcL2", &TypeOfFE_LagrangeDC3dLtt); static AddNewFEL P1dttLagrange3dL1("P1dcL1", &TypeOfFE_LagrangeDC3dLtt1); - } LOADFUNC(finit) diff --git a/plugin/seq/Element_P1ncdc.cpp b/plugin/seq/Element_P1ncdc.cpp index 6969e163b..b9bb52431 100644 --- a/plugin/seq/Element_P1ncdc.cpp +++ b/plugin/seq/Element_P1ncdc.cpp @@ -53,19 +53,16 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; - virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, - int op) const; + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; }; // on what nu df on node node of df int TypeOfFE_P1ttdcnc1_::Data[] = {6, 6, 6, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 3}; ; double TypeOfFE_P1ttdcnc1_::Pi_h_coef[] = {1., 1., 1.}; - R TypeOfFE_P1ttdcnc1_::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, - int componante, int op) const { + R TypeOfFE_P1ttdcnc1_::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); R r = 0; @@ -86,8 +83,7 @@ namespace Fem2D { return r; } - void TypeOfFE_P1ttdcnc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P1ttdcnc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { // const Triangle & K(FE.T); R2 A(K[0]), B(K[1]), C(K[2]); // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 @@ -124,160 +120,153 @@ namespace Fem2D { } } } -// P1nc ttdc + bulle -class TypeOfFE_P1bttdcnc1_ : public TypeOfFE { - public: - static int Data[]; - static double Pi_h_coef[]; - - TypeOfFE_P1bttdcnc1_( ) : TypeOfFE(0, 0, 4, 1, Data, 4, 1, 4, 4, Pi_h_coef) { - const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0),R2(1./3., 1./3.)}; - - for (int i = 0; i < NbDoF; i++) { - pij_alpha[i] = IPJ(i, i, 0); - P_Pi_h[i] = Pt[i]; + // P1nc ttdc + bulle + class TypeOfFE_P1bttdcnc1_ : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + + TypeOfFE_P1bttdcnc1_( ) : TypeOfFE(0, 0, 4, 1, Data, 4, 1, 4, 4, Pi_h_coef) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0), R2(1. / 3., 1. / 3.)}; + + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } } - } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; - - virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, - int op) const; -}; - -// on what nu df on node node of df -int TypeOfFE_P1bttdcnc1_::Data[] = {6, 6, 6, 6, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 4}; -; -double TypeOfFE_P1bttdcnc1_::Pi_h_coef[] = {1., 1., 1.,1.}; -R TypeOfFE_P1bttdcnc1_::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, - int componante, int op) const { - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))),u3(u(K(3))); -// cout << " U " << u0 << " " << u1 << " " << u2 << " "<< u3 << endl; - R r = 0; - R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; - R lb = 27*l0*l1*l2; - - R llb = lb * 1./3; - if (op == 0) { - R ll0 = 1 - l0 * 2 -llb , ll1 = 1 - l1 * 2 -llb , ll2 = 1 - l2 * 2 -llb ; - r = u0 * ll0 + u1 * ll1 + ll2 * u2 + lb * u3 ; - } else { - const Triangle &T = K.T; - R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); - R2 Dlb = 27.*(D0*l1*l2 +l0*D1*l2 +l0*l1*D2); - - if (op == 1) { - r = -(D0.x * u0 + D1.x * u1 + D2.x * u2) * 2 + (-(u0+u1+u2)/3.+u3)*Dlb.x ; - } else if(op == 2) { - r = -(D0.y * u0 + D1.y * u1 + D2.y * u2) * 2 + (-(u0+u1+u2)/3.+u3)*Dlb.y ; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + }; + + // on what nu df on node node of df + int TypeOfFE_P1bttdcnc1_::Data[] = {6, 6, 6, 6, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 4}; + ; + double TypeOfFE_P1bttdcnc1_::Pi_h_coef[] = {1., 1., 1., 1.}; + R TypeOfFE_P1bttdcnc1_::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))), u3(u(K(3))); + // cout << " U " << u0 << " " << u1 << " " << u2 << " "<< u3 << endl; + R r = 0; + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + R lb = 27 * l0 * l1 * l2; + + R llb = lb * 1. / 3; + if (op == 0) { + R ll0 = 1 - l0 * 2 - llb, ll1 = 1 - l1 * 2 - llb, ll2 = 1 - l2 * 2 - llb; + r = u0 * ll0 + u1 * ll1 + ll2 * u2 + lb * u3; + } else { + const Triangle &T = K.T; + R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); + R2 Dlb = 27. * (D0 * l1 * l2 + l0 * D1 * l2 + l0 * l1 * D2); + + if (op == 1) { + r = -(D0.x * u0 + D1.x * u1 + D2.x * u2) * 2 + (-(u0 + u1 + u2) / 3. + u3) * Dlb.x; + } else if (op == 2) { + r = -(D0.y * u0 + D1.y * u1 + D2.y * u2) * 2 + (-(u0 + u1 + u2) / 3. + u3) * Dlb.y; + } else if (op > 2) + ffassert(0); // to do .. } - else if(op>2) ffassert(0); // to do .. - } - return r; -} - -void TypeOfFE_P1bttdcnc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { - // const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]), C(K[2]); - // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 - R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; - R lb = 27*l0*l1*l2; - R clb = (1-2./3.); - if (val.N( ) < 4) { - throwassert(val.N( ) >= 4); + return r; } - throwassert(val.M( ) == 1); + void TypeOfFE_P1bttdcnc1_::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + R lb = 27 * l0 * l1 * l2; + R clb = (1 - 2. / 3.); + if (val.N( ) < 4) { + throwassert(val.N( ) >= 4); + } - val = 0; - if (whatd[op_id]) { - RN_ f0(val('.', 0, 0)); - f0[0] = 1 - l0 * 2 - clb*lb; - f0[1] = 1 - l1 * 2 - clb*lb; - f0[2] = 1 - l2 * 2 - clb*lb ; - f0[3] = lb; - } + throwassert(val.M( ) == 1); - if (whatd[op_dx] || whatd[op_dy]) { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - R2 Dlb = 27.*(Dl0*l1*l2 +l0*Dl1*l2 +l0*l1*Dl2); - if (whatd[op_dx]) { - RN_ f0x(val('.', 0, op_dx)); - f0x[0] = -Dl0.x * 2 - clb*Dlb.x; - f0x[1] = -Dl1.x * 2 - clb*Dlb.x; - f0x[2] = -Dl2.x * 2 - clb*Dlb.x; - f0x[3] = Dlb.x; + val = 0; + if (whatd[op_id]) { + RN_ f0(val('.', 0, 0)); + f0[0] = 1 - l0 * 2 - clb * lb; + f0[1] = 1 - l1 * 2 - clb * lb; + f0[2] = 1 - l2 * 2 - clb * lb; + f0[3] = lb; } - if (whatd[op_dy]) { - RN_ f0y(val('.', 0, op_dy)); - f0y[0] = -Dl0.y * 2 - clb*Dlb.y; - f0y[1] = -Dl1.y * 2 - clb*Dlb.y; - f0y[2] = -Dl2.y * 2 - clb*Dlb.y; + if (whatd[op_dx] || whatd[op_dy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + R2 Dlb = 27. * (Dl0 * l1 * l2 + l0 * Dl1 * l2 + l0 * l1 * Dl2); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = -Dl0.x * 2 - clb * Dlb.x; + f0x[1] = -Dl1.x * 2 - clb * Dlb.x; + f0x[2] = -Dl2.x * 2 - clb * Dlb.x; + f0x[3] = Dlb.x; + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = -Dl0.y * 2 - clb * Dlb.y; + f0y[1] = -Dl1.y * 2 - clb * Dlb.y; + f0y[2] = -Dl2.y * 2 - clb * Dlb.y; f0y[3] = Dlb.y; + } } } -} - -class TypeOfFE_P1bncLagrange : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P1bncLagrange(): TypeOfFE(0,1,1,1,Data,4,1,4,4,Pi_h_coef) - { - const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0),R2(1./3.,1./3.) }; - for (int i=0;i &u, - int componante, int op) const; -} ; - -// on what nu df on node node of df - int TypeOfFE_P1bncLagrange::Data[]={3,4,5,6, 0,0,0,0, 0,1,2,3, 0,0,0,0, 0,1,2,3, 0, 0,4}; -double TypeOfFE_P1bncLagrange::Pi_h_coef[]={1.,1.,1.,1.}; - -R TypeOfFE_P1bncLagrange::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, - int componante, int op) const { - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))),u3(u(K(3))); - R r = 0; - R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; - R lb = 27*l0*l1*l2; - - R llb = lb * 1./3; - if (op == 0) { - R ll0 = 1 - l0 * 2 -llb , ll1 = 1 - l1 * 2 -llb , ll2 = 1 - l2 * 2 -llb ; - r = u0 * ll0 + u1 * ll1 + ll2 * u2 + lb * u3 ; - } else { - const Triangle &T = K.T; - R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); - R2 Dlb = 27.*(D0*l1*l2 +l0*D1*l2 +l0*l1*D2); - - if (op == 1) { - r = -(D0.x * u0 + D1.x * u1 + D2.x * u2) * 2 + (-(u0+u1+u2)/3.+u3)*Dlb.x ; - } else if(op == 2) { - r = -(D0.y * u0 + D1.y * u1 + D2.y * u2) * 2 + (-(u0+u1+u2)/3.+u3)*Dlb.y ; + class TypeOfFE_P1bncLagrange : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + TypeOfFE_P1bncLagrange( ) : TypeOfFE(0, 1, 1, 1, Data, 4, 1, 4, 4, Pi_h_coef) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0), R2(1. / 3., 1. / 3.)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } } - else if(op>2) ffassert(0); // to do .. - } - // cout << " U " << u0 << " " << u1 << " " << u2 << " "<< u3 << " / " << l0 << " "<< l1 << " "<< l2 << "=> " << r << endl; - return r; -} -void TypeOfFE_P1bncLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const -{ + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + }; + + // on what nu df on node node of df + int TypeOfFE_P1bncLagrange::Data[] = {3, 4, 5, 6, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 4}; + double TypeOfFE_P1bncLagrange::Pi_h_coef[] = {1., 1., 1., 1.}; + + R TypeOfFE_P1bncLagrange::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))), u3(u(K(3))); + R r = 0; + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + R lb = 27 * l0 * l1 * l2; + + R llb = lb * 1. / 3; + if (op == 0) { + R ll0 = 1 - l0 * 2 - llb, ll1 = 1 - l1 * 2 - llb, ll2 = 1 - l2 * 2 - llb; + r = u0 * ll0 + u1 * ll1 + ll2 * u2 + lb * u3; + } else { + const Triangle &T = K.T; + R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); + R2 Dlb = 27. * (D0 * l1 * l2 + l0 * D1 * l2 + l0 * l1 * D2); + + if (op == 1) { + r = -(D0.x * u0 + D1.x * u1 + D2.x * u2) * 2 + (-(u0 + u1 + u2) / 3. + u3) * Dlb.x; + } else if (op == 2) { + r = -(D0.y * u0 + D1.y * u1 + D2.y * u2) * 2 + (-(u0 + u1 + u2) / 3. + u3) * Dlb.y; + } else if (op > 2) + ffassert(0); // to do .. + } + // cout << " U " << u0 << " " << u1 << " " << u2 << " "<< u3 << " / " << l0 << " "<< l1 << " "<< l2 << "=> " << r << endl; + + return r; + } + void TypeOfFE_P1bncLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { // const Triangle & K(FE.T); R2 A(K[0]), B(K[1]), C(K[2]); // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; - R lb = 27*l0*l1*l2; - R clb = (1-2./3.); + R lb = 27 * l0 * l1 * l2; + R clb = (1 - 2. / 3.); if (val.N( ) < 4) { throwassert(val.N( ) >= 4); } @@ -287,47 +276,45 @@ void TypeOfFE_P1bncLagrange::FB(const bool *whatd, const Mesh &, const Triangle val = 0; if (whatd[op_id]) { RN_ f0(val('.', 0, 0)); - f0[0] = 1 - l0 * 2 - clb*lb; - f0[1] = 1 - l1 * 2 - clb*lb; - f0[2] = 1 - l2 * 2 - clb*lb ; + f0[0] = 1 - l0 * 2 - clb * lb; + f0[1] = 1 - l1 * 2 - clb * lb; + f0[2] = 1 - l2 * 2 - clb * lb; f0[3] = lb; } if (whatd[op_dx] || whatd[op_dy]) { R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - R2 Dlb = 27.*(Dl0*l1*l2 +l0*Dl1*l2 +l0*l1*Dl2); + R2 Dlb = 27. * (Dl0 * l1 * l2 + l0 * Dl1 * l2 + l0 * l1 * Dl2); if (whatd[op_dx]) { RN_ f0x(val('.', 0, op_dx)); - f0x[0] = -Dl0.x * 2 - clb*Dlb.x; - f0x[1] = -Dl1.x * 2 - clb*Dlb.x; - f0x[2] = -Dl2.x * 2 - clb*Dlb.x; - f0x[3] = Dlb.x; + f0x[0] = -Dl0.x * 2 - clb * Dlb.x; + f0x[1] = -Dl1.x * 2 - clb * Dlb.x; + f0x[2] = -Dl2.x * 2 - clb * Dlb.x; + f0x[3] = Dlb.x; } if (whatd[op_dy]) { RN_ f0y(val('.', 0, op_dy)); - f0y[0] = -Dl0.y * 2 - clb*Dlb.y; - f0y[1] = -Dl1.y * 2 - clb*Dlb.y; - f0y[2] = -Dl2.y * 2 - clb*Dlb.y; - f0y[3] = Dlb.y; + f0y[0] = -Dl0.y * 2 - clb * Dlb.y; + f0y[1] = -Dl1.y * 2 - clb * Dlb.y; + f0y[2] = -Dl2.y * 2 - clb * Dlb.y; + f0y[3] = Dlb.y; } } -} - - + } // link with FreeFem++ static TypeOfFE_P1ttdcnc1_ P1dc1LagrangeP1dc1; static TypeOfFE_P1bttdcnc1_ P1bdc1LagrangeP1dc1; - static TypeOfFE_P1bncLagrange P1bncLagrangeP1; + static TypeOfFE_P1bncLagrange P1bncLagrangeP1; // static TypeOfFE_LagrangeDC3d TypeOfFE_LagrangeDC3dtt(1); // a static variable to add the finite element to freefem++ static AddNewFE P1dcLagrange("P1dcnc", &P1dc1LagrangeP1dc1); -static AddNewFE P1bdcncLagrange("P1bdcnc", &P1bdc1LagrangeP1dc1); -static AddNewFE P1bncLagrange("P1bnc", &P1bncLagrangeP1); + static AddNewFE P1bdcncLagrange("P1bdcnc", &P1bdc1LagrangeP1dc1); + static AddNewFE P1bncLagrange("P1bnc", &P1bncLagrangeP1); - // static AddNewFE3 P1dttLagrange3d("P1dcnc3d",&TypeOfFE_LagrangeDC3dtt,"P1dcnc"); + // static AddNewFE3 P1dttLagrange3d("P1dcnc3d",&TypeOfFE_LagrangeDC3dtt,"P1dcnc"); } // namespace Fem2D // --- fin -- diff --git a/plugin/seq/Element_P2bulle3.cpp b/plugin/seq/Element_P2bulle3.cpp index cab25c8f8..aaab5d3ff 100644 --- a/plugin/seq/Element_P2bulle3.cpp +++ b/plugin/seq/Element_P2bulle3.cpp @@ -48,16 +48,13 @@ namespace Fem2D { static const GQuadratureFormular< R1 > QFe; // quadrature formula on an edge static const GQuadratureFormular< R2 > QFf; // quadrature formula on a face TypeOfFE_P2_bulle3_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; }; int TypeOfFE_P2_bulle3_3d::dfon[] = {1, 1, 3, 1}; // 2 dofs on each edge, 2 dofs on each face - TypeOfFE_P2_bulle3_3d::TypeOfFE_P2_bulle3_3d( ) - : GTypeOfFE< Mesh >(TypeOfFE_P2_bulle3_3d::dfon, 1, 3, false, false) { + TypeOfFE_P2_bulle3_3d::TypeOfFE_P2_bulle3_3d( ) : GTypeOfFE< Mesh >(TypeOfFE_P2_bulle3_3d::dfon, 1, 3, false, false) { typedef Element E; const R alpha = 0.1885804846964451; // ; (7.-sqrt(13.))/18.; const double a1 = alpha, a0 = (1 - 2 * a1); @@ -88,8 +85,7 @@ namespace Fem2D { for (int i = 0; i < E::nf; ++i) { for (int j = 0; j < 3; ++j) { int j1 = (j + 1) % 3, j2 = (j + 2) % 3; - Pt[k++] = - Pt[E::nvface[i][j]] * a0 + Pt[E::nvface[i][j1]] * a1 + Pt[E::nvface[i][j2]] * a1; + Pt[k++] = Pt[E::nvface[i][j]] * a0 + Pt[E::nvface[i][j1]] * a1 + Pt[E::nvface[i][j2]] * a1; } } @@ -108,50 +104,50 @@ namespace Fem2D { } } - void TypeOfFE_P2_bulle3_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_P2_bulle3_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { int n = this->NbDoF; - int *p = M.p+odf;// correction FH mai 2020 ... + int *p = M.p + odf; // correction FH mai 2020 ... for (int i = 0; i < n; ++i) { M.p[i] = i; } - - ffassert(M.p.N() >= odf+n); + + ffassert(M.p.N( ) >= odf + n); int k = 10; if (verbosity > 9) { - cout << " P2 3 bulle set: "<< odf << endl; ; + cout << " P2 3 bulle set: " << odf << endl; + ; } // attention facePermutation a change !!!!! etait code faux for (int ff = 0; ff < Element::nf; ff++, k += 3) { // oriantation de la face a endroit int fp = K.facePermutation(ff); - int i0= fp/2, sp = fp%2; - if(!i0) { - Exchange(p[k], p[k + i0]);// i0 en 0 - if(!sp) Exchange(p[k+1], p[k +2]);} - else if(sp) Exchange(p[k+1], p[k + 2]); - - // 0 2 1 (sp =1) - // 0 1 2 ( sp ==0) -/* - if (fp & 1) { - Exchange(p[k], p[k + 1]); - } - - if (fp & 2) { + int i0 = fp / 2, sp = fp % 2; + if (!i0) { + Exchange(p[k], p[k + i0]); // i0 en 0 + if (!sp) Exchange(p[k + 1], p[k + 2]); + } else if (sp) Exchange(p[k + 1], p[k + 2]); - } - if (fp & 4) { - Exchange(p[k], p[k + 1]); - } - */ + // 0 2 1 (sp =1) + // 0 1 2 ( sp ==0) + /* + if (fp & 1) { + Exchange(p[k], p[k + 1]); + } + + if (fp & 2) { + Exchange(p[k + 1], p[k + 2]); + } + + if (fp & 4) { + Exchange(p[k], p[k + 1]); + } + */ } } - void TypeOfFE_P2_bulle3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P2_bulle3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 10 + 3 * 4 + 1); // 23 degrees of freedom assert(val.M( ) == 1); // 3 components // ------------- @@ -178,26 +174,26 @@ namespace Fem2D { for (int ff = 0; ff < Element::nf; ff++, k += 3) { // orientation de la face a envert int fp = K.facePermutation(ff); - int i0= fp/2, sp = fp%2; - if(!i0) { - if(!sp) Exchange(p[k+1], p[k +2]); - Exchange(p[k], p[k + i0]);// i0 en 0 + int i0 = fp / 2, sp = fp % 2; + if (!i0) { + if (!sp) Exchange(p[k + 1], p[k + 2]); + Exchange(p[k], p[k + i0]); // i0 en 0 + } else if (sp) + Exchange(p[k + 1], p[k + 2]); + /* + // fp=0; // No perm + if (fp & 4) { + Exchange(p[k], p[k + 1]); } - else if(sp) Exchange(p[k+1], p[k + 2]); -/* - // fp=0; // No perm - if (fp & 4) { - Exchange(p[k], p[k + 1]); - } - if (fp & 2) { - Exchange(p[k + 1], p[k + 2]); - } + if (fp & 2) { + Exchange(p[k + 1], p[k + 2]); + } - if (fp & 1) { - Exchange(p[k], p[k + 1]); - } - */ + if (fp & 1) { + Exchange(p[k], p[k + 1]); + } + */ } assert(val.N( ) >= E::nv + E::ne); @@ -257,27 +253,17 @@ namespace Fem2D { RN_ f0(val('.', 0, op_id)); if (whatd & Fop_D0) { // corner - f0[p[0]] = l[0] + beta1 * (l[13] + l[18] + l[19]) + - beta2 * (l[14] + l[15] + l[16] + l[17] + l[20] + l[21]) + beta3 * l[22]; - f0[p[1]] = l[1] + beta1 * (l[12] + l[17] + l[20]) + - beta2 * (l[10] + l[11] + l[16] + l[18] + l[19] + l[21]) + beta3 * l[22]; - f0[p[2]] = l[2] + beta1 * (l[11] + l[14] + l[21]) + - beta2 * (l[10] + l[12] + l[13] + l[15] + l[19] + l[20]) + beta3 * l[22]; - f0[p[3]] = l[3] + beta1 * (l[10] + l[15] + l[16]) + - beta2 * (l[11] + l[12] + l[13] + l[14] + l[17] + l[18]) + beta3 * l[22]; + f0[p[0]] = l[0] + beta1 * (l[13] + l[18] + l[19]) + beta2 * (l[14] + l[15] + l[16] + l[17] + l[20] + l[21]) + beta3 * l[22]; + f0[p[1]] = l[1] + beta1 * (l[12] + l[17] + l[20]) + beta2 * (l[10] + l[11] + l[16] + l[18] + l[19] + l[21]) + beta3 * l[22]; + f0[p[2]] = l[2] + beta1 * (l[11] + l[14] + l[21]) + beta2 * (l[10] + l[12] + l[13] + l[15] + l[19] + l[20]) + beta3 * l[22]; + f0[p[3]] = l[3] + beta1 * (l[10] + l[15] + l[16]) + beta2 * (l[11] + l[12] + l[13] + l[14] + l[17] + l[18]) + beta3 * l[22]; // edge - f0[p[4]] = l[4] + beta4 * (l[16] + l[21]) + beta5 * (l[17] + l[18] + l[19] + l[20]) + - beta6 * l[22]; // 01 faces 2, 3 - f0[p[5]] = l[5] + beta4 * (l[15] + l[20]) + beta5 * (l[13] + l[14] + l[19] + l[21]) + - beta6 * l[22]; // 02 faces 1, 3 - f0[p[6]] = l[6] + beta4 * (l[14] + l[17]) + beta5 * (l[13] + l[15] + l[16] + l[18]) + - beta6 * l[22]; // 03 faces 1, 2 - f0[p[7]] = l[7] + beta4 * (l[10] + l[19]) + beta5 * (l[11] + l[12] + l[20] + l[21]) + - beta6 * l[22]; // 12 faces 0, 3 - f0[p[8]] = l[8] + beta4 * (l[11] + l[18]) + beta5 * (l[10] + l[12] + l[16] + l[17]) + - beta6 * l[22]; // 13 faces 0, 2 - f0[p[9]] = l[9] + beta4 * (l[12] + l[13]) + beta5 * (l[10] + l[11] + l[14] + l[15]) + - beta6 * l[22]; // 23 faces 0, 1 + f0[p[4]] = l[4] + beta4 * (l[16] + l[21]) + beta5 * (l[17] + l[18] + l[19] + l[20]) + beta6 * l[22]; // 01 faces 2, 3 + f0[p[5]] = l[5] + beta4 * (l[15] + l[20]) + beta5 * (l[13] + l[14] + l[19] + l[21]) + beta6 * l[22]; // 02 faces 1, 3 + f0[p[6]] = l[6] + beta4 * (l[14] + l[17]) + beta5 * (l[13] + l[15] + l[16] + l[18]) + beta6 * l[22]; // 03 faces 1, 2 + f0[p[7]] = l[7] + beta4 * (l[10] + l[19]) + beta5 * (l[11] + l[12] + l[20] + l[21]) + beta6 * l[22]; // 12 faces 0, 3 + f0[p[8]] = l[8] + beta4 * (l[11] + l[18]) + beta5 * (l[10] + l[12] + l[16] + l[17]) + beta6 * l[22]; // 13 faces 0, 2 + f0[p[9]] = l[9] + beta4 * (l[12] + l[13]) + beta5 * (l[10] + l[11] + l[14] + l[15]) + beta6 * l[22]; // 23 faces 0, 1 // face for (int i = 10; i < 22; i++) { @@ -318,14 +304,10 @@ namespace Fem2D { c * P.y * P.z * (alpha - P.y), c * P.y * P.z * (alpha - P.z), c * P.x * P.z * (alpha - P.z) + c * P.z * (alpha - P.z) * (P.x + P.y + P.z - 1), - c * P.x * P.z * (alpha - P.x) - c * P.x * P.z * (P.x + P.y + P.z - 1) + - c * P.z * (alpha - P.x) * (P.x + P.y + P.z - 1), - c * P.z * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * P.z * (alpha + P.x + P.y + P.z - 1), - c * P.y * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * P.y * (alpha + P.x + P.y + P.z - 1), - c * P.x * P.y * (alpha - P.x) - c * P.x * P.y * (P.x + P.y + P.z - 1) + - c * P.y * (alpha - P.x) * (P.x + P.y + P.z - 1), + c * P.x * P.z * (alpha - P.x) - c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.z * (alpha - P.x) * (P.x + P.y + P.z - 1), + c * P.z * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * P.z * (alpha + P.x + P.y + P.z - 1), + c * P.y * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * P.y * (alpha + P.x + P.y + P.z - 1), + c * P.x * P.y * (alpha - P.x) - c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.y * (alpha - P.x) * (P.x + P.y + P.z - 1), c * P.x * P.y * (alpha - P.y) + c * P.y * (alpha - P.y) * (P.x + P.y + P.z - 1), -P.y * P.z * (256 * P.x + 256 * P.y + 256 * P.z - 256) - 256 * P.x * P.y * P.z, }; @@ -343,19 +325,15 @@ namespace Fem2D { -c * P.x * P.z * (alpha - P.z), c * P.x * P.y * P.z - c * P.x * P.z * (alpha - P.y), -c * P.x * P.z * (alpha - P.x), - c * P.z * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.y * P.z * (alpha + P.x + P.y + P.z - 1), - c * P.y * P.z * (alpha - P.y) - c * P.y * P.z * (P.x + P.y + P.z - 1) + - c * P.z * (alpha - P.y) * (P.x + P.y + P.z - 1), + c * P.z * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.y * P.z * (alpha + P.x + P.y + P.z - 1), + c * P.y * P.z * (alpha - P.y) - c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.z * (alpha - P.y) * (P.x + P.y + P.z - 1), c * P.y * P.z * (alpha - P.z) + c * P.z * (alpha - P.z) * (P.x + P.y + P.z - 1), c * P.x * P.z * (alpha - P.z), c * P.x * P.z * (alpha - P.x), c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * P.z * (alpha + P.x + P.y + P.z - 1), - c * P.x * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * P.y * (alpha + P.x + P.y + P.z - 1), + c * P.x * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * P.y * (alpha + P.x + P.y + P.z - 1), c * P.x * P.y * (alpha - P.x) + c * P.x * (alpha - P.x) * (P.x + P.y + P.z - 1), - c * P.x * P.y * (alpha - P.y) - c * P.x * P.y * (P.x + P.y + P.z - 1) + - c * P.x * (alpha - P.y) * (P.x + P.y + P.z - 1), + c * P.x * P.y * (alpha - P.y) - c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * (alpha - P.y) * (P.x + P.y + P.z - 1), -P.x * P.z * (256 * P.x + 256 * P.y + 256 * P.z - 256) - 256 * P.x * P.y * P.z, }; R lz[] = { @@ -372,16 +350,12 @@ namespace Fem2D { c * P.x * P.y * P.z - c * P.x * P.y * (alpha - P.z), -c * P.x * P.y * (alpha - P.y), -c * P.x * P.y * (alpha - P.x), - c * P.y * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.y * P.z * (alpha + P.x + P.y + P.z - 1), + c * P.y * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.y * P.z * (alpha + P.x + P.y + P.z - 1), c * P.y * P.z * (alpha - P.y) + c * P.y * (alpha - P.y) * (P.x + P.y + P.z - 1), - c * P.y * P.z * (alpha - P.z) - c * P.y * P.z * (P.x + P.y + P.z - 1) + - c * P.y * (alpha - P.z) * (P.x + P.y + P.z - 1), - c * P.x * P.z * (alpha - P.z) - c * P.x * P.z * (P.x + P.y + P.z - 1) + - c * P.x * (alpha - P.z) * (P.x + P.y + P.z - 1), + c * P.y * P.z * (alpha - P.z) - c * P.y * P.z * (P.x + P.y + P.z - 1) + c * P.y * (alpha - P.z) * (P.x + P.y + P.z - 1), + c * P.x * P.z * (alpha - P.z) - c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * (alpha - P.z) * (P.x + P.y + P.z - 1), c * P.x * P.z * (alpha - P.x) + c * P.x * (alpha - P.x) * (P.x + P.y + P.z - 1), - c * P.x * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + - c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * P.z * (alpha + P.x + P.y + P.z - 1), + c * P.x * (P.x + P.y + P.z - 1) * (alpha + P.x + P.y + P.z - 1) + c * P.x * P.z * (P.x + P.y + P.z - 1) + c * P.x * P.z * (alpha + P.x + P.y + P.z - 1), c * P.x * P.y * (P.x + P.y + P.z - 1) + c * P.x * P.y * (alpha + P.x + P.y + P.z - 1), c * P.x * P.y * (alpha - P.x), c * P.x * P.y * (alpha - P.y), @@ -394,67 +368,37 @@ namespace Fem2D { // * * * * * * * * * * * * * * * * * * * * * * * * * * R ff0x[23], ff0y[23], ff0z[23]; // corner - ff0x[p[0]] = lx[0] + beta1 * (lx[13] + lx[18] + lx[19]) + - beta2 * (lx[14] + lx[15] + lx[16] + lx[17] + lx[20] + lx[21]) + beta3 * lx[22]; - ff0y[p[0]] = ly[0] + beta1 * (ly[13] + ly[18] + ly[19]) + - beta2 * (ly[14] + ly[15] + ly[16] + ly[17] + ly[20] + ly[21]) + beta3 * ly[22]; - ff0z[p[0]] = lz[0] + beta1 * (lz[13] + lz[18] + lz[19]) + - beta2 * (lz[14] + lz[15] + lz[16] + lz[17] + lz[20] + lz[21]) + beta3 * lz[22]; - ff0x[p[1]] = lx[1] + beta1 * (lx[12] + lx[17] + lx[20]) + - beta2 * (lx[10] + lx[11] + lx[16] + lx[18] + lx[19] + lx[21]) + beta3 * lx[22]; - ff0y[p[1]] = ly[1] + beta1 * (ly[12] + ly[17] + ly[20]) + - beta2 * (ly[10] + ly[11] + ly[16] + ly[18] + ly[19] + ly[21]) + beta3 * ly[22]; - ff0z[p[1]] = lz[1] + beta1 * (lz[12] + lz[17] + lz[20]) + - beta2 * (lz[10] + lz[11] + lz[16] + lz[18] + lz[19] + lz[21]) + beta3 * lz[22]; - ff0x[p[2]] = lx[2] + beta1 * (lx[11] + lx[14] + lx[21]) + - beta2 * (lx[10] + lx[12] + lx[13] + lx[15] + lx[19] + lx[20]) + beta3 * lx[22]; - ff0y[p[2]] = ly[2] + beta1 * (ly[11] + ly[14] + ly[21]) + - beta2 * (ly[10] + ly[12] + ly[13] + ly[15] + ly[19] + ly[20]) + beta3 * ly[22]; - ff0z[p[2]] = lz[2] + beta1 * (lz[11] + lz[14] + lz[21]) + - beta2 * (lz[10] + lz[12] + lz[13] + lz[15] + lz[19] + lz[20]) + beta3 * lz[22]; - ff0x[p[3]] = lx[3] + beta1 * (lx[10] + lx[15] + lx[16]) + - beta2 * (lx[11] + lx[12] + lx[13] + lx[14] + lx[17] + lx[18]) + beta3 * lx[22]; - ff0y[p[3]] = ly[3] + beta1 * (ly[10] + ly[15] + ly[16]) + - beta2 * (ly[11] + ly[12] + ly[13] + ly[14] + ly[17] + ly[18]) + beta3 * ly[22]; - ff0z[p[3]] = lz[3] + beta1 * (lz[10] + lz[15] + lz[16]) + - beta2 * (lz[11] + lz[12] + lz[13] + lz[14] + lz[17] + lz[18]) + beta3 * lz[22]; + ff0x[p[0]] = lx[0] + beta1 * (lx[13] + lx[18] + lx[19]) + beta2 * (lx[14] + lx[15] + lx[16] + lx[17] + lx[20] + lx[21]) + beta3 * lx[22]; + ff0y[p[0]] = ly[0] + beta1 * (ly[13] + ly[18] + ly[19]) + beta2 * (ly[14] + ly[15] + ly[16] + ly[17] + ly[20] + ly[21]) + beta3 * ly[22]; + ff0z[p[0]] = lz[0] + beta1 * (lz[13] + lz[18] + lz[19]) + beta2 * (lz[14] + lz[15] + lz[16] + lz[17] + lz[20] + lz[21]) + beta3 * lz[22]; + ff0x[p[1]] = lx[1] + beta1 * (lx[12] + lx[17] + lx[20]) + beta2 * (lx[10] + lx[11] + lx[16] + lx[18] + lx[19] + lx[21]) + beta3 * lx[22]; + ff0y[p[1]] = ly[1] + beta1 * (ly[12] + ly[17] + ly[20]) + beta2 * (ly[10] + ly[11] + ly[16] + ly[18] + ly[19] + ly[21]) + beta3 * ly[22]; + ff0z[p[1]] = lz[1] + beta1 * (lz[12] + lz[17] + lz[20]) + beta2 * (lz[10] + lz[11] + lz[16] + lz[18] + lz[19] + lz[21]) + beta3 * lz[22]; + ff0x[p[2]] = lx[2] + beta1 * (lx[11] + lx[14] + lx[21]) + beta2 * (lx[10] + lx[12] + lx[13] + lx[15] + lx[19] + lx[20]) + beta3 * lx[22]; + ff0y[p[2]] = ly[2] + beta1 * (ly[11] + ly[14] + ly[21]) + beta2 * (ly[10] + ly[12] + ly[13] + ly[15] + ly[19] + ly[20]) + beta3 * ly[22]; + ff0z[p[2]] = lz[2] + beta1 * (lz[11] + lz[14] + lz[21]) + beta2 * (lz[10] + lz[12] + lz[13] + lz[15] + lz[19] + lz[20]) + beta3 * lz[22]; + ff0x[p[3]] = lx[3] + beta1 * (lx[10] + lx[15] + lx[16]) + beta2 * (lx[11] + lx[12] + lx[13] + lx[14] + lx[17] + lx[18]) + beta3 * lx[22]; + ff0y[p[3]] = ly[3] + beta1 * (ly[10] + ly[15] + ly[16]) + beta2 * (ly[11] + ly[12] + ly[13] + ly[14] + ly[17] + ly[18]) + beta3 * ly[22]; + ff0z[p[3]] = lz[3] + beta1 * (lz[10] + lz[15] + lz[16]) + beta2 * (lz[11] + lz[12] + lz[13] + lz[14] + lz[17] + lz[18]) + beta3 * lz[22]; // edge - ff0x[p[4]] = lx[4] + beta4 * (lx[16] + lx[21]) + beta5 * (lx[17] + lx[18] + lx[19] + lx[20]) + - beta6 * lx[22]; - ff0y[p[4]] = ly[4] + beta4 * (ly[16] + ly[21]) + beta5 * (ly[17] + ly[18] + ly[19] + ly[20]) + - beta6 * ly[22]; - ff0z[p[4]] = lz[4] + beta4 * (lz[16] + lz[21]) + beta5 * (lz[17] + lz[18] + lz[19] + lz[20]) + - beta6 * lz[22]; - ff0x[p[5]] = lx[5] + beta4 * (lx[15] + lx[20]) + beta5 * (lx[13] + lx[14] + lx[19] + lx[21]) + - beta6 * lx[22]; - ff0y[p[5]] = ly[5] + beta4 * (ly[15] + ly[20]) + beta5 * (ly[13] + ly[14] + ly[19] + ly[21]) + - beta6 * ly[22]; - ff0z[p[5]] = lz[5] + beta4 * (lz[15] + lz[20]) + beta5 * (lz[13] + lz[14] + lz[19] + lz[21]) + - beta6 * lz[22]; - ff0x[p[6]] = lx[6] + beta4 * (lx[14] + lx[17]) + beta5 * (lx[13] + lx[15] + lx[16] + lx[18]) + - beta6 * lx[22]; - ff0y[p[6]] = ly[6] + beta4 * (ly[14] + ly[17]) + beta5 * (ly[13] + ly[15] + ly[16] + ly[18]) + - beta6 * ly[22]; - ff0z[p[6]] = lz[6] + beta4 * (lz[14] + lz[17]) + beta5 * (lz[13] + lz[15] + lz[16] + lz[18]) + - beta6 * lz[22]; - ff0x[p[7]] = lx[7] + beta4 * (lx[10] + lx[19]) + beta5 * (lx[11] + lx[12] + lx[20] + lx[21]) + - beta6 * lx[22]; - ff0y[p[7]] = ly[7] + beta4 * (ly[10] + ly[19]) + beta5 * (ly[11] + ly[12] + ly[20] + ly[21]) + - beta6 * ly[22]; - ff0z[p[7]] = lz[7] + beta4 * (lz[10] + lz[19]) + beta5 * (lz[11] + lz[12] + lz[20] + lz[21]) + - beta6 * lz[22]; - ff0x[p[8]] = lx[8] + beta4 * (lx[11] + lx[18]) + beta5 * (lx[10] + lx[12] + lx[16] + lx[17]) + - beta6 * lx[22]; - ff0y[p[8]] = ly[8] + beta4 * (ly[11] + ly[18]) + beta5 * (ly[10] + ly[12] + ly[16] + ly[17]) + - beta6 * ly[22]; - ff0z[p[8]] = lz[8] + beta4 * (lz[11] + lz[18]) + beta5 * (lz[10] + lz[12] + lz[16] + lz[17]) + - beta6 * lz[22]; - ff0x[p[9]] = lx[9] + beta4 * (lx[12] + lx[13]) + beta5 * (lx[10] + lx[11] + lx[14] + lx[15]) + - beta6 * lx[22]; - ff0y[p[9]] = ly[9] + beta4 * (ly[12] + ly[13]) + beta5 * (ly[10] + ly[11] + ly[14] + ly[15]) + - beta6 * ly[22]; - ff0z[p[9]] = lz[9] + beta4 * (lz[12] + lz[13]) + beta5 * (lz[10] + lz[11] + lz[14] + lz[15]) + - beta6 * lz[22]; + ff0x[p[4]] = lx[4] + beta4 * (lx[16] + lx[21]) + beta5 * (lx[17] + lx[18] + lx[19] + lx[20]) + beta6 * lx[22]; + ff0y[p[4]] = ly[4] + beta4 * (ly[16] + ly[21]) + beta5 * (ly[17] + ly[18] + ly[19] + ly[20]) + beta6 * ly[22]; + ff0z[p[4]] = lz[4] + beta4 * (lz[16] + lz[21]) + beta5 * (lz[17] + lz[18] + lz[19] + lz[20]) + beta6 * lz[22]; + ff0x[p[5]] = lx[5] + beta4 * (lx[15] + lx[20]) + beta5 * (lx[13] + lx[14] + lx[19] + lx[21]) + beta6 * lx[22]; + ff0y[p[5]] = ly[5] + beta4 * (ly[15] + ly[20]) + beta5 * (ly[13] + ly[14] + ly[19] + ly[21]) + beta6 * ly[22]; + ff0z[p[5]] = lz[5] + beta4 * (lz[15] + lz[20]) + beta5 * (lz[13] + lz[14] + lz[19] + lz[21]) + beta6 * lz[22]; + ff0x[p[6]] = lx[6] + beta4 * (lx[14] + lx[17]) + beta5 * (lx[13] + lx[15] + lx[16] + lx[18]) + beta6 * lx[22]; + ff0y[p[6]] = ly[6] + beta4 * (ly[14] + ly[17]) + beta5 * (ly[13] + ly[15] + ly[16] + ly[18]) + beta6 * ly[22]; + ff0z[p[6]] = lz[6] + beta4 * (lz[14] + lz[17]) + beta5 * (lz[13] + lz[15] + lz[16] + lz[18]) + beta6 * lz[22]; + ff0x[p[7]] = lx[7] + beta4 * (lx[10] + lx[19]) + beta5 * (lx[11] + lx[12] + lx[20] + lx[21]) + beta6 * lx[22]; + ff0y[p[7]] = ly[7] + beta4 * (ly[10] + ly[19]) + beta5 * (ly[11] + ly[12] + ly[20] + ly[21]) + beta6 * ly[22]; + ff0z[p[7]] = lz[7] + beta4 * (lz[10] + lz[19]) + beta5 * (lz[11] + lz[12] + lz[20] + lz[21]) + beta6 * lz[22]; + ff0x[p[8]] = lx[8] + beta4 * (lx[11] + lx[18]) + beta5 * (lx[10] + lx[12] + lx[16] + lx[17]) + beta6 * lx[22]; + ff0y[p[8]] = ly[8] + beta4 * (ly[11] + ly[18]) + beta5 * (ly[10] + ly[12] + ly[16] + ly[17]) + beta6 * ly[22]; + ff0z[p[8]] = lz[8] + beta4 * (lz[11] + lz[18]) + beta5 * (lz[10] + lz[12] + lz[16] + lz[17]) + beta6 * lz[22]; + ff0x[p[9]] = lx[9] + beta4 * (lx[12] + lx[13]) + beta5 * (lx[10] + lx[11] + lx[14] + lx[15]) + beta6 * lx[22]; + ff0y[p[9]] = ly[9] + beta4 * (ly[12] + ly[13]) + beta5 * (ly[10] + ly[11] + ly[14] + ly[15]) + beta6 * ly[22]; + ff0z[p[9]] = lz[9] + beta4 * (lz[12] + lz[13]) + beta5 * (lz[10] + lz[11] + lz[14] + lz[15]) + beta6 * lz[22]; // face for (int i = 10; i < 22; i++) { diff --git a/plugin/seq/Element_P2pnc.cpp b/plugin/seq/Element_P2pnc.cpp index 035c45ed8..e304263d5 100644 --- a/plugin/seq/Element_P2pnc.cpp +++ b/plugin/seq/Element_P2pnc.cpp @@ -67,8 +67,7 @@ namespace Fem2D { ffassert(p == this->P_Pi_h.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; @@ -80,10 +79,9 @@ namespace Fem2D { 0, 0, 1, 1, 2, 2, 3, // the node of the df 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) 0, 1, 2, 3, 4, 5, 6, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated + 0, // for each compontant $j=0,N-1$ it give the sub FE associated 0, 7}; - void TypeOfFE_P2pnc::Pi_h_alpha( - const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... + void TypeOfFE_P2pnc::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... const Triangle &T(K.T); int k = 0; R oe[3] = {T.EdgeOrientation(0), T.EdgeOrientation(1), T.EdgeOrientation(2)}; @@ -120,17 +118,13 @@ namespace Fem2D { ffassert(k == this->pij_alpha.N( )); } - void TypeOfFE_P2pnc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P2pnc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R oe[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; - R l7[] = { - l0, l1, l2, l1 * l2, l0 * l2, l0 * l1, (l0 - l1) * (l1 - l2) * (l2 - l0)}; // 7 monome - double C1[][7] = {{1, 1, -1, 3, 3, -1, -2} /* 0 */, {3, -1, 1, 1, -1, 3, -2} /* 1 */, - {-1, 3, 3, -1, 1, 1, -2} /* 2 */, {0, 0, -12, 0, 0, -12, 12} /* 3 */, - {0, -12, 0, -0, -12, 0, 12} /* 4 */, {-12, 0, -0, -12, -0, 0, 12} /* 5 */, - {-10, 10, -10, 10, -10, 10, 0} /* 6 */}; + R l7[] = {l0, l1, l2, l1 * l2, l0 * l2, l0 * l1, (l0 - l1) * (l1 - l2) * (l2 - l0)}; // 7 monome + double C1[][7] = {{1, 1, -1, 3, 3, -1, -2} /* 0 */, {3, -1, 1, 1, -1, 3, -2} /* 1 */, {-1, 3, 3, -1, 1, 1, -2} /* 2 */, {0, 0, -12, 0, 0, -12, 12} /* 3 */, + {0, -12, 0, -0, -12, 0, 12} /* 4 */, {-12, 0, -0, -12, -0, 0, 12} /* 5 */, {-10, 10, -10, 10, -10, 10, 0} /* 6 */}; if (val.N( ) < 7) { throwassert(val.N( ) >= 7); @@ -163,14 +157,7 @@ namespace Fem2D { if (whatd[op_dx] || whatd[op_dy]) { R2 D0 = K.H(0), D1 = K.H(1), D2 = K.H(2); - R2 D7[] = {D0, - D1, - D2, - D1 * l2 + D2 * l1, - D0 * l2 + D2 * l0, - D0 * l1 + D1 * l0, - ((D0 - D1) * (l1 - l2) * (l2 - l0) + (l0 - l1) * (D1 - D2) * (l2 - l0) + - (l0 - l1) * (l1 - l2) * (D2 - D0))}; + R2 D7[] = {D0, D1, D2, D1 * l2 + D2 * l1, D0 * l2 + D2 * l0, D0 * l1 + D1 * l0, ((D0 - D1) * (l1 - l2) * (l2 - l0) + (l0 - l1) * (D1 - D2) * (l2 - l0) + (l0 - l1) * (l1 - l2) * (D2 - D0))}; if (whatd[op_dx]) { RN_ f0x(val('.', 0, op_dx)); diff --git a/plugin/seq/Element_P2pnc_3d.cpp b/plugin/seq/Element_P2pnc_3d.cpp index 09962307e..86bcacff7 100644 --- a/plugin/seq/Element_P2pnc_3d.cpp +++ b/plugin/seq/Element_P2pnc_3d.cpp @@ -39,293 +39,256 @@ namespace Fem2D { class TypeOfFE_P2pnc_3d : public GTypeOfFE< Mesh3 > { public: - typedef Mesh3 Mesh; - typedef Mesh3::Element Element; - typedef GFElement< Mesh3 > FElement; - static int dfon[]; - static const int d = Mesh::Rd::d; - static const GQuadratureFormular< R2 > &QFf; // quadrature formula on a face - static const GQuadratureFormular< R3 > &QFt; // quadrature formula on a face - TypeOfFE_P2pnc_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; - }; -int TypeOfFE_P2pnc_3d::dfon[] = {0, 0, 3, 1}; // 2 dofs on each edge, 2 dofs on each face + typedef Mesh3 Mesh; + typedef Mesh3::Element Element; + typedef GFElement< Mesh3 > FElement; + static int dfon[]; + static const int d = Mesh::Rd::d; + static const GQuadratureFormular< R2 > &QFf; // quadrature formula on a face + static const GQuadratureFormular< R3 > &QFt; // quadrature formula on a face + TypeOfFE_P2pnc_3d( ); // constructor + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + int TypeOfFE_P2pnc_3d::dfon[] = {0, 0, 3, 1}; // 2 dofs on each edge, 2 dofs on each face + const GQuadratureFormular< R2 > &TypeOfFE_P2pnc_3d::QFf = QuadratureFormular_T_5; + const GQuadratureFormular< R3 > &TypeOfFE_P2pnc_3d::QFt = QuadratureFormular_Tet_5; -const GQuadratureFormular< R2 > &TypeOfFE_P2pnc_3d::QFf= QuadratureFormular_T_5 ; -const GQuadratureFormular< R3 > &TypeOfFE_P2pnc_3d::QFt= QuadratureFormular_Tet_5 ; + TypeOfFE_P2pnc_3d::TypeOfFE_P2pnc_3d( ) + : GTypeOfFE< Mesh3 >(TypeOfFE_P2pnc_3d::dfon, 1, 3, + 4 * QFf.n * 3 + QFt.n, // N coef InterPP + 4 * QFf.n + QFt.n, // N Pt Inter + false, true) { + static R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + static const int nvfo[4][3] = {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}; + if (verbosity > 0 && mpirank == 0) cout << "TypeOfFE_P2pnc_3d QFf exact:" << QFf.exact << ", QFt exact " << QFt.exact << endl; + int ipt = 0; + int doft = 4 * 3; // last dof -TypeOfFE_P2pnc_3d::TypeOfFE_P2pnc_3d( ) -: GTypeOfFE< Mesh3 >(TypeOfFE_P2pnc_3d::dfon, 1, 3, - 4 * QFf.n * 3 + QFt.n,// N coef InterPP - 4 * QFf.n + QFt.n,// N Pt Inter - false, true) { - static R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices - static const int nvfo[4][3] ={{1,2,3}, {0,2,3},{0,1,3},{ 0,1,2}}; - if(verbosity > 0 && mpirank == 0) cout << "TypeOfFE_P2pnc_3d QFf exact:"<< QFf.exact << ", QFt exact " <PtInterpolation[ipt] = Pt[nvfo[f][0]] * (1. - x - y) + Pt[nvfo[f][1]] * x + Pt[nvfo[f][2]] * y; - }} - - for (int q = 0; q < QFt.n; ++q, ++ipt) - this->PtInterpolation[ipt] = QFt[q]; + for (int q = 0; q < QFf.n; ++q, ++ipt) { + double x = QFf[q].x; + double y = QFf[q].y; + this->PtInterpolation[ipt] = Pt[nvfo[f][0]] * (1. - x - y) + Pt[nvfo[f][1]] * x + Pt[nvfo[f][2]] * y; + } + } + + for (int q = 0; q < QFt.n; ++q, ++ipt) this->PtInterpolation[ipt] = QFt[q]; - ffassert(ipt == this->NbPtforInterpolation); // verif - if(verbosity>99 && mpirank == 0) - for( int i=0; i< ipt;++i) - cout << i << " P/i " << this->PtInterpolation[i] << endl; + ffassert(ipt == this->NbPtforInterpolation); // verif + if (verbosity > 99 && mpirank == 0) + for (int i = 0; i < ipt; ++i) cout << i << " P/i " << this->PtInterpolation[i] << endl; { - int i =0,ipt=0; // - - - // coef d'interpolation ... sur les face ... - // int li*f - for (int f = 0; f < Element::nf; ++f) - for (int qq = 0; qq < QFf.n; qq++,++ipt) - { - double ll[4]; // dans Khat - this->PtInterpolation[ipt].toBary(ll); + int i = 0, ipt = 0; // - for (int kf = 0; kf < 3; ++kf,i++) - { - int kfK = nvfo[f][kf];// vertex dans K .. - int dof = 3*f+kf; - if(qq==0) - if (verbosity > 0 && mpirank == 0) cout << " dof " << dof << " " << f << " "<< kfK << endl; - { - this->pInterpolation[i] = ipt; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = dof; // ik in (13.1) - this->coefInterpolation[i] = QFf[qq].a*ll[kfK]; - - } - } - } - - for (int q = 0; q < QFt.n; ++q, ++i,ipt++) - { - this->pInterpolation[i] = ipt; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = doft; // ik in (13.1) - this->coefInterpolation[i] = QFt[q].a; // alfak: we will fill them with 'set' (below) + // coef d'interpolation ... sur les face ... + // int li*f + for (int f = 0; f < Element::nf; ++f) + for (int qq = 0; qq < QFf.n; qq++, ++ipt) { + double ll[4]; // dans Khat + this->PtInterpolation[ipt].toBary(ll); + + for (int kf = 0; kf < 3; ++kf, i++) { + int kfK = nvfo[f][kf]; // vertex dans K .. + int dof = 3 * f + kf; + if (qq == 0) + if (verbosity > 0 && mpirank == 0) cout << " dof " << dof << " " << f << " " << kfK << endl; + { + this->pInterpolation[i] = ipt; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = dof; // ik in (13.1) + this->coefInterpolation[i] = QFf[qq].a * ll[kfK]; + } + } } - ffassert(i==this->NbcoefforInterpolation); - + for (int q = 0; q < QFt.n; ++q, ++i, ipt++) { + this->pInterpolation[i] = ipt; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = doft; // ik in (13.1) + this->coefInterpolation[i] = QFt[q].a; // alfak: we will fill them with 'set' (below) + } + + ffassert(i == this->NbcoefforInterpolation); } -} + } -void Setp3(int *p,int n) { -// n = signe + depart*2 - int i=n/2, j= n%2, k = 3-i; - if( i==0){ if(j==1) swap(p[1],p[2]); } - else { - swap(p[0],p[i]); - int k =3 -i;// autre - if(j==0) swap(p[i],p[k]); - } -} -void TypeOfFE_P2pnc_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { - static int count =0;count++; + void Setp3(int *p, int n) { + // n = signe + depart*2 + int i = n / 2, j = n % 2, k = 3 - i; + if (i == 0) { + if (j == 1) swap(p[1], p[2]); + } else { + swap(p[0], p[i]); + int k = 3 - i; // autre + if (j == 0) swap(p[i], p[k]); + } + } + void TypeOfFE_P2pnc_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { + static int count = 0; + count++; int k = Th(K); - int verb = (mpirank == 0 && (verbosity>99 || (verbosity>9 && count < 4 )));//|| ocoef+odf || nump ; + int verb = (mpirank == 0 && (verbosity > 99 || (verbosity > 9 && count < 4))); //|| ocoef+odf || nump ; int n = this->NbDoF; - int np=M.np; - int ncoef=M.ncoef; - //int *p = M.p+odf;// correction FH mai 2020 ... - // update the coef to be ajdacent compatible + int np = M.np; + int ncoef = M.ncoef; + // int *p = M.p+odf;// correction FH mai 2020 ... + // update the coef to be ajdacent compatible // - int i =ocoef; // - - // cout << " set " << Th(K) << endl; - + int i = ocoef; // + + // cout << " set " << Th(K) << endl; + // coef d'interpolation ... sur les face ... // int li*f - int ip=0; - for (int f = 0; f < Element::nf; ++f) - { - int fp = K.facePermutation(f);// orientation de la face .. - int p3[3]={0,1,2}; - SetNumPerm<3>(fp,p3); - if(verb ) cout << " set: " << f << " " << p3[0] << " "<< p3[1] << " " << p3[2] - << " ::: " << Th(k,Element::nvface[f][p3[0]]) << " " << Th(k,Element::nvface[f][p3[1]]) << " " << Th(k,Element::nvface[f][p3[2]]) << " " << endl; - for (int qq = 0; qq < QFf.n; qq++,ip++) - { - - int ipt = nump ? nump[ip] : ip; - ffassert(ipt<=np); - //cout << ip << " -> "<< ipt << " f= " << f <<" " << qq << " i "<< i << " " << this->pInterpolation[i] - //<< "ipt: " << this->PtInterpolation[ipt] << " ::ip "<< this->PtInterpolation[ip] <pInterpolation[i]) ; ce ne marche pas !!!!!! mais le point sont les memem - double ll[4]; // dans Khat - M.P[ipt].toBary(ll);// point sur la face f ???? - if(verb) cout << " P " << M.P[ipt] << " " << i << endl; - for (int kf = 0; kf < 3; ++kf,i++) - { - if(verb) cout << i << " " <pInterpolation[i]); - ffassert(abs(ll[f])<1e-10); + int ip = 0; + for (int f = 0; f < Element::nf; ++f) { + int fp = K.facePermutation(f); // orientation de la face .. + int p3[3] = {0, 1, 2}; + SetNumPerm< 3 >(fp, p3); + if (verb) + cout << " set: " << f << " " << p3[0] << " " << p3[1] << " " << p3[2] << " ::: " << Th(k, Element::nvface[f][p3[0]]) << " " << Th(k, Element::nvface[f][p3[1]]) << " " + << Th(k, Element::nvface[f][p3[2]]) << " " << endl; + for (int qq = 0; qq < QFf.n; qq++, ip++) { + + int ipt = nump ? nump[ip] : ip; + ffassert(ipt <= np); + // cout << ip << " -> "<< ipt << " f= " << f <<" " << qq << " i "<< i << " " << this->pInterpolation[i] + //<< "ipt: " << this->PtInterpolation[ipt] << " ::ip "<< this->PtInterpolation[ip] <pInterpolation[i]) ; ce ne marche pas !!!!!! mais le point sont les memem + double ll[4]; // dans Khat + M.P[ipt].toBary(ll); // point sur la face f ???? + if (verb) cout << " P " << M.P[ipt] << " " << i << endl; + for (int kf = 0; kf < 3; ++kf, i++) { + if (verb) cout << i << " " << f << kf << " " << ipt << " " << ll[f] << " " << M.p[i] << " // " << ocoef << " " << odf << " " << nump << endl; + // ffassert(ipt == this->pInterpolation[i]); + ffassert(abs(ll[f]) < 1e-10); - int kfK = Element::nvface[f][p3[kf]];// vertex dans K .. - M.coef[i] = QFf[qq].a*ll[kfK]; - } + int kfK = Element::nvface[f][p3[kf]]; // vertex dans K .. + M.coef[i] = QFf[qq].a * ll[kfK]; } + } } - - for (int q = 0; q < QFt.n; ++q, ++i) - { - M.coef[i] = QFt[q].a; // alfak: we will fill them with 'set' (below) + + for (int q = 0; q < QFt.n; ++q, ++i) { + M.coef[i] = QFt[q].a; // alfak: we will fill them with 'set' (below) } - - ffassert(i<= ncoef); -} -void TypeOfFE_P2pnc_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { - + ffassert(i <= ncoef); + } + void TypeOfFE_P2pnc_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { + assert(val.N( ) >= 13); // 13 degrees of freedom assert(val.M( ) == 1); // 1 components -/* - Dof Numbering 3 dof / face the dof a associated to a vertex face - and the vertex a numbering in increase way. - - we have to numbering î on ref element with - - So we need of a permutation p to insure the compatibilit between adjacent element - - */ + /* + Dof Numbering 3 dof / face the dof a associated to a vertex face + and the vertex a numbering in increase way. + + we have to numbering î on ref element with + + So we need of a permutation p to insure the compatibilit between adjacent element + + */ // generated with file Element_P2pnc_3d.edp // Warning p(^i) =i - // CC(i,j) = dof(j)(mo(i)); // - // phi_k =sum_i C1(k,i) mo_i - double C1[13][13] = { - {9, -15, -15, 3, -60, -60, 60, -30, 30, 30, 0, 180, 180}, - {0, 0, 18, 0, 0, 30, -30, 0, 0, -30, 0, -180, 0}, - {0, 18, 0, 0, 30, 0, -30, 0, -30, 0, 0, 0, -180}, - - {9, -9, -3, -3, -90, 0, 30, 0, 30, 0, 0, 0, 180}, - {0, 0, 18, 0, 0, -30, 30, 0, 0, -30, -180, 0, 0}, - {-6, 18, -12, 6, 60, 30, -90, 0, -60, 30, 180, 0, -180}, - - {-3, -3, 27, 9, 0, 30, 30, 0, 0, -90, -180, -180, 0}, - {-3, 9, -9, -3, 0, 30, -90, 0, 0, 30, 180, 0, 0}, - {9, -3, -9, -3, 0, -90, 30, 0, 0, 30, 0, 180, 0}, - - {0, 12, 12, 6, 60, 60, -60, -30, -30, -30, 0, -180, -180}, - {3, -9, 9, 3, -60, -30, 90, 0, 0, -30, -180, 0, 180}, - {0, 0, -18, 0, 0, -30, -30, 0, 0, 30, 180, 180, 0}, - - {-5, -5, -5, -5, 20, 20, 20, 20, 20, 20, 0, 0, 0}}; + // CC(i,j) = dof(j)(mo(i)); // + // phi_k =sum_i C1(k,i) mo_i + double C1[13][13] = {{9, -15, -15, 3, -60, -60, 60, -30, 30, 30, 0, 180, 180}, {0, 0, 18, 0, 0, 30, -30, 0, 0, -30, 0, -180, 0}, {0, 18, 0, 0, 30, 0, -30, 0, -30, 0, 0, 0, -180}, + {9, -9, -3, -3, -90, 0, 30, 0, 30, 0, 0, 0, 180}, {0, 0, 18, 0, 0, -30, 30, 0, 0, -30, -180, 0, 0}, {-6, 18, -12, 6, 60, 30, -90, 0, -60, 30, 180, 0, -180}, - int pp[13]={0,1,2,3,4,5,6,7,8,9,10,11,12}; // Permutaion de dof - int p[13]; // Permutaion de dof - p[12]=pp[12]; - static int ccount =0; ccount++; - int verb = (ccount < 2 && verbosity>9 ) || ( verbosity>99); - for (int ff = 0,k=0; ff < Element::nf; ff++, k+=3 ) { + {-3, -3, 27, 9, 0, 30, 30, 0, 0, -90, -180, -180, 0}, {-3, 9, -9, -3, 0, 30, -90, 0, 0, 30, 180, 0, 0}, {9, -3, -9, -3, 0, -90, 30, 0, 0, 30, 0, 180, 0}, + + {0, 12, 12, 6, 60, 60, -60, -30, -30, -30, 0, -180, -180}, {3, -9, 9, 3, -60, -30, 90, 0, 0, -30, -180, 0, 180}, {0, 0, -18, 0, 0, -30, -30, 0, 0, 30, 180, 180, 0}, + + {-5, -5, -5, -5, 20, 20, 20, 20, 20, 20, 0, 0, 0}}; + + int pp[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; // Permutaion de dof + int p[13]; // Permutaion de dof + p[12] = pp[12]; + static int ccount = 0; + ccount++; + int verb = (ccount < 2 && verbosity > 9) || (verbosity > 99); + for (int ff = 0, k = 0; ff < Element::nf; ff++, k += 3) { // orientation de la face a envert - int fp = K.facePermutation(ff); - int p3[3]={0,1,2}; - SetNumPerm<3>(fp,p3); - if( verb) - { - int i3[3]={Th(K[Element::nvface[ff][p3[0]]]),Th(K[Element::nvface[ff][p3[1]]]),Th(K[Element::nvface[ff][p3[2]]])}; - cout << "k " << k <<" " << ff << " / "<< p3[0] << " "<< p3[1] << " "<< p3[2] - << " / " << i3[0] << " " << i3[1] << " " << i3[2] - // << " / " << Element::nvface[ff][p3[0]]<< " " <(fp, p3); + if (verb) { + int i3[3] = {Th(K[Element::nvface[ff][p3[0]]]), Th(K[Element::nvface[ff][p3[1]]]), Th(K[Element::nvface[ff][p3[2]]])}; + cout << "k " << k << " " << ff << " / " << p3[0] << " " << p3[1] << " " << p3[2] << " / " << i3[0] << " " << i3[1] << " " + << i3[2] + // << " / " << Element::nvface[ff][p3[0]]<< " " < &Elm_P2pnc_3d(P2pnc_3d); -} - static TypeOfFE_P2pnc_3d P2pnc_3d; - GTypeOfFE< Mesh3 > &Elm_P2pnc_3d(P2pnc_3d); + static AddNewFE3 TFE_P2pnc_3d("P2pnc3d", &Elm_P2pnc_3d); - static AddNewFE3 TFE_P2pnc_3d("P2pnc3d", &Elm_P2pnc_3d); - } // namespace Fem2D // --- fin -- diff --git a/plugin/seq/Element_P3.cpp b/plugin/seq/Element_P3.cpp index fbff7d389..e1c6bd36d 100644 --- a/plugin/seq/Element_P3.cpp +++ b/plugin/seq/Element_P3.cpp @@ -36,9 +36,9 @@ // /// --------------------------------------------------------------- namespace Fem2D { -// ------ P3 Hierarchical (just remove P1 node of the P2 finite element) -------- -class TypeOfFE_P3Lagrange : public TypeOfFE { -public: + // ------ P3 Hierarchical (just remove P1 node of the P2 finite element) -------- + class TypeOfFE_P3Lagrange : public TypeOfFE { + public: static const int k = 3; static const int ndf = (k + 2) * (k + 1) / 2; static int Data[]; @@ -49,74 +49,69 @@ class TypeOfFE_P3Lagrange : public TypeOfFE { static const int il[10]; static const int jl[10]; static const int kl[10]; - + TypeOfFE_P3Lagrange( ) : TypeOfFE(3 + 2 * 3 + 1, 1, Data, 4, 1, 16, 10, 0) { - static const R2 Pt[10] = {R2(0 / 3., 0 / 3.), R2(3 / 3., 0 / 3.), R2(0 / 3., 3 / 3.), - R2(2 / 3., 1 / 3.), R2(1 / 3., 2 / 3.), R2(0 / 3., 2 / 3.), - R2(0 / 3., 1 / 3.), R2(1 / 3., 0 / 3.), R2(2 / 3., 0 / 3.), - R2(1 / 3., 1 / 3.)}; - // 3,4,5,6,7,8 - int other[10] = {-1, -1, -1, 4, 3, 6, 5, 8, 7, -1}; - int kk = 0; - - for (int i = 0; i < NbDoF; i++) { - pij_alpha[kk++] = IPJ(i, i, 0); - if (other[i] >= 0) { - pij_alpha[kk++] = IPJ(i, other[i], 0); - } - - P_Pi_h[i] = Pt[i]; + static const R2 Pt[10] = {R2(0 / 3., 0 / 3.), R2(3 / 3., 0 / 3.), R2(0 / 3., 3 / 3.), R2(2 / 3., 1 / 3.), R2(1 / 3., 2 / 3.), + R2(0 / 3., 2 / 3.), R2(0 / 3., 1 / 3.), R2(1 / 3., 0 / 3.), R2(2 / 3., 0 / 3.), R2(1 / 3., 1 / 3.)}; + // 3,4,5,6,7,8 + int other[10] = {-1, -1, -1, 4, 3, 6, 5, 8, 7, -1}; + int kk = 0; + + for (int i = 0; i < NbDoF; i++) { + pij_alpha[kk++] = IPJ(i, i, 0); + if (other[i] >= 0) { + pij_alpha[kk++] = IPJ(i, other[i], 0); } - - assert(P_Pi_h.N( ) == NbDoF); - assert(pij_alpha.N( ) == kk); + + P_Pi_h[i] = Pt[i]; + } + + assert(P_Pi_h.N( ) == NbDoF); + assert(pij_alpha.N( ) == kk); } - - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { - for (int i = 0; i < 16; ++i) { - v[i] = 1; - } - - int e0 = K.EdgeOrientation(0); - int e1 = K.EdgeOrientation(1); - int e2 = K.EdgeOrientation(2); - int ooo[6] = {e0, e0, e1, e1, e2, e2}; - int iii[6] = {}; - int jjj[6] = {}; - - for (int i = 0; i < 6; ++i) { - iii[i] = 3 + 2 * i; // si orient = 1 - jjj[i] = 4 + 2 * i; // si orient = -1 - } - - for (int i = 0; i < 6; ++i) { - if (ooo[i] == 1) { - v[jjj[i]] = 0; - } else { - v[iii[i]] = 0; - } + for (int i = 0; i < 16; ++i) { + v[i] = 1; + } + + int e0 = K.EdgeOrientation(0); + int e1 = K.EdgeOrientation(1); + int e2 = K.EdgeOrientation(2); + int ooo[6] = {e0, e0, e1, e1, e2, e2}; + int iii[6] = { }; + int jjj[6] = { }; + + for (int i = 0; i < 6; ++i) { + iii[i] = 3 + 2 * i; // si orient = 1 + jjj[i] = 4 + 2 * i; // si orient = -1 + } + + for (int i = 0; i < 6; ++i) { + if (ooo[i] == 1) { + v[jjj[i]] = 0; + } else { + v[iii[i]] = 0; } + } } -}; - -// on what nu df on node node of df -int TypeOfFE_P3Lagrange::Data[] = { - 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, // the support number of the node of the df - 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, // the number of the df on the node - 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated - 0, 10}; -double TypeOfFE_P3Lagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; -void TypeOfFE_P3Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { + }; + + // on what nu df on node node of df + int TypeOfFE_P3Lagrange::Data[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, // the support number of the node of the df + 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, // the number of the df on the node + 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated + 0, 10}; + double TypeOfFE_P3Lagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; + void TypeOfFE_P3Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R L[3] = {l0 * k, l1 * k, l2 * k}; - + throwassert(val.N( ) >= 10); throwassert(val.M( ) == 1); // Attention il faut renumeroter les fonction de bases @@ -124,106 +119,106 @@ void TypeOfFE_P3Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, // et la numerotation naturelle mais 2 noud pas arete // donc p est la perumation // echange de numerotation si les arete sont dans le mauvais sens - int p[10] = {}; - + int p[10] = { }; + for (int i = 0; i < 10; ++i) { - p[i] = i; + p[i] = i; } - + if (K.EdgeOrientation(0) < 0) { - Exchange(p[3], p[4]); // 3,4 + Exchange(p[3], p[4]); // 3,4 } - + if (K.EdgeOrientation(1) < 0) { - Exchange(p[5], p[6]); // 5,6 + Exchange(p[5], p[6]); // 5,6 } - + if (K.EdgeOrientation(2) < 0) { - Exchange(p[7], p[8]); // 7,8 + Exchange(p[7], p[8]); // 7,8 } - + val = 0; - + if (whatd[op_id]) { - RN_ f0(val('.', 0, op_id)); - - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R f = 1. / ff[df]; - - for (int i = 0; i < k; ++i) { - f *= L[nn[df][i]] - aa[df][i]; - } - - f0[pdf] = f; + RN_ f0(val('.', 0, op_id)); + + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R f = 1. / ff[df]; + + for (int i = 0; i < k; ++i) { + f *= L[nn[df][i]] - aa[df][i]; } + + f0[pdf] = f; + } } - + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { - R2 D[] = {K.H(0) * k, K.H(1) * k, K.H(2) * k}; - if (whatd[op_dx] || whatd[op_dy]) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0., f = 1. / ff[df]; - - for (int i = 0; i < k; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - f = f * Ln; - } - - if (whatd[op_dx]) { - val(pdf, 0, op_dx) = fx; - } - - if (whatd[op_dy]) { - val(pdf, 0, op_dy) = fy; - } - } + R2 D[] = {K.H(0) * k, K.H(1) * k, K.H(2) * k}; + if (whatd[op_dx] || whatd[op_dy]) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., f = 1. / ff[df]; + + for (int i = 0; i < k; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + f = f * Ln; + } + + if (whatd[op_dx]) { + val(pdf, 0, op_dx) = fx; + } + + if (whatd[op_dy]) { + val(pdf, 0, op_dy) = fy; + } } - - if (whatd[op_dyy] || whatd[op_dxy] || whatd[op_dxx]) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0., f = 1. / ff[df]; - R fxx = 0., fyy = 0., fxy = 0.; - - for (int i = 0; i < k; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fxx = fxx * Ln + 2. * fx * D[n].x; - fyy = fyy * Ln + 2. * fy * D[n].y; - fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - f = f * Ln; - } - - if (whatd[op_dxx]) { - val(pdf, 0, op_dxx) = fxx; - } - - if (whatd[op_dyy]) { - val(pdf, 0, op_dyy) = fyy; - } - - if (whatd[op_dxy]) { - val(pdf, 0, op_dxy) = fxy; - } - } + } + + if (whatd[op_dyy] || whatd[op_dxy] || whatd[op_dxx]) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., f = 1. / ff[df]; + R fxx = 0., fyy = 0., fxy = 0.; + + for (int i = 0; i < k; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fxx = fxx * Ln + 2. * fx * D[n].x; + fyy = fyy * Ln + 2. * fy * D[n].y; + fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + f = f * Ln; + } + + if (whatd[op_dxx]) { + val(pdf, 0, op_dxx) = fxx; + } + + if (whatd[op_dyy]) { + val(pdf, 0, op_dyy) = fyy; + } + + if (whatd[op_dxy]) { + val(pdf, 0, op_dxy) = fxy; + } } + } } -} + } #include "Element_P3.hpp" -// Author: F. Hecht , P-H Tournier, Jet Hoe Tang jethoe.tang@googlemail.com -// Jan 2017 -// in tets -class TypeOfFE_P3_3d : public GTypeOfFE< Mesh3 > { -public: + // Author: F. Hecht , P-H Tournier, Jet Hoe Tang jethoe.tang@googlemail.com + // Jan 2017 + // in tets + class TypeOfFE_P3_3d : public GTypeOfFE< Mesh3 > { + public: typedef Mesh3 Mesh; typedef Mesh3::Element Element; typedef GFElement< Mesh3 > FElement; @@ -235,114 +230,99 @@ class TypeOfFE_P3_3d : public GTypeOfFE< Mesh3 > { static int cp[20]; static int pp[20][4]; static const int d = Mesh::Rd::d; - + TypeOfFE_P3_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; -}; - -int TypeOfFE_P3_3d::nl[20][3] = { - {0, 0, 0} /* 0 */, {1, 1, 1} /* 1 */, {2, 2, 2} /* 2 */, {3, 3, 3} /* 3 */, - {0, 0, 1} /* 4 */, {0, 1, 1} /* 5 */, {0, 0, 2} /* 6 */, {0, 2, 2} /* 7 */, - {0, 0, 3} /* 8 */, {0, 3, 3} /* 9 */, {1, 1, 2} /* 10 */, {1, 2, 2} /* 11 */, - {1, 1, 3} /* 12 */, {1, 3, 3} /* 13 */, {2, 2, 3} /* 14 */, {2, 3, 3} /* 15 */, - {1, 2, 3} /* 16 */, {0, 2, 3} /* 17 */, {0, 1, 3} /* 18 */, {0, 1, 2} /* 19 */}; -int TypeOfFE_P3_3d::cl[20][3] = { - {0, 1, 2} /* 0 */, {0, 1, 2} /* 1 */, {0, 1, 2} /* 2 */, {0, 1, 2} /* 3 */, - {0, 1, 0} /* 4 */, {0, 0, 1} /* 5 */, {0, 1, 0} /* 6 */, {0, 0, 1} /* 7 */, - {0, 1, 0} /* 8 */, {0, 0, 1} /* 9 */, {0, 1, 0} /* 10 */, {0, 0, 1} /* 11 */, - {0, 1, 0} /* 12 */, {0, 0, 1} /* 13 */, {0, 1, 0} /* 14 */, {0, 0, 1} /* 15 */, - {0, 0, 0} /* 16 */, {0, 0, 0} /* 17 */, {0, 0, 0} /* 18 */, {0, 0, 0} /* 19 */}; -int TypeOfFE_P3_3d::cp[20] = {6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1}; -int TypeOfFE_P3_3d::pp[20][4] = { - {3, 0, 0, 0} /* 0 */, {0, 3, 0, 0} /* 1 */, {0, 0, 3, 0} /* 2 */, {0, 0, 0, 3} /* 3 */, - {2, 1, 0, 0} /* 4 */, {1, 2, 0, 0} /* 5 */, {2, 0, 1, 0} /* 6 */, {1, 0, 2, 0} /* 7 */, - {2, 0, 0, 1} /* 8 */, {1, 0, 0, 2} /* 9 */, {0, 2, 1, 0} /* 10 */, {0, 1, 2, 0} /* 11 */, - {0, 2, 0, 1} /* 12 */, {0, 1, 0, 2} /* 13 */, {0, 0, 2, 1} /* 14 */, {0, 0, 1, 2} /* 15 */, - {0, 1, 1, 1} /* 16 */, {1, 0, 1, 1} /* 17 */, {1, 1, 0, 1} /* 18 */, {1, 1, 1, 0} /* 19 */}; -int TypeOfFE_P3_3d::dfon[] = {1, 2, 1, 0}; // 2 dofs on each edge, 2 dofs on each face - -TypeOfFE_P3_3d::TypeOfFE_P3_3d( ) : GTypeOfFE< Mesh >(TypeOfFE_P3_3d::dfon, 1, 3, false, false) -{ + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + + int TypeOfFE_P3_3d::nl[20][3] = {{0, 0, 0} /* 0 */, {1, 1, 1} /* 1 */, {2, 2, 2} /* 2 */, {3, 3, 3} /* 3 */, {0, 0, 1} /* 4 */, {0, 1, 1} /* 5 */, {0, 0, 2} /* 6 */, + {0, 2, 2} /* 7 */, {0, 0, 3} /* 8 */, {0, 3, 3} /* 9 */, {1, 1, 2} /* 10 */, {1, 2, 2} /* 11 */, {1, 1, 3} /* 12 */, {1, 3, 3} /* 13 */, + {2, 2, 3} /* 14 */, {2, 3, 3} /* 15 */, {1, 2, 3} /* 16 */, {0, 2, 3} /* 17 */, {0, 1, 3} /* 18 */, {0, 1, 2} /* 19 */}; + int TypeOfFE_P3_3d::cl[20][3] = {{0, 1, 2} /* 0 */, {0, 1, 2} /* 1 */, {0, 1, 2} /* 2 */, {0, 1, 2} /* 3 */, {0, 1, 0} /* 4 */, {0, 0, 1} /* 5 */, {0, 1, 0} /* 6 */, + {0, 0, 1} /* 7 */, {0, 1, 0} /* 8 */, {0, 0, 1} /* 9 */, {0, 1, 0} /* 10 */, {0, 0, 1} /* 11 */, {0, 1, 0} /* 12 */, {0, 0, 1} /* 13 */, + {0, 1, 0} /* 14 */, {0, 0, 1} /* 15 */, {0, 0, 0} /* 16 */, {0, 0, 0} /* 17 */, {0, 0, 0} /* 18 */, {0, 0, 0} /* 19 */}; + int TypeOfFE_P3_3d::cp[20] = {6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1}; + int TypeOfFE_P3_3d::pp[20][4] = {{3, 0, 0, 0} /* 0 */, {0, 3, 0, 0} /* 1 */, {0, 0, 3, 0} /* 2 */, {0, 0, 0, 3} /* 3 */, {2, 1, 0, 0} /* 4 */, {1, 2, 0, 0} /* 5 */, {2, 0, 1, 0} /* 6 */, + {1, 0, 2, 0} /* 7 */, {2, 0, 0, 1} /* 8 */, {1, 0, 0, 2} /* 9 */, {0, 2, 1, 0} /* 10 */, {0, 1, 2, 0} /* 11 */, {0, 2, 0, 1} /* 12 */, {0, 1, 0, 2} /* 13 */, + {0, 0, 2, 1} /* 14 */, {0, 0, 1, 2} /* 15 */, {0, 1, 1, 1} /* 16 */, {1, 0, 1, 1} /* 17 */, {1, 1, 0, 1} /* 18 */, {1, 1, 1, 0} /* 19 */}; + int TypeOfFE_P3_3d::dfon[] = {1, 2, 1, 0}; // 2 dofs on each edge, 2 dofs on each face + + TypeOfFE_P3_3d::TypeOfFE_P3_3d( ) : GTypeOfFE< Mesh >(TypeOfFE_P3_3d::dfon, 1, 3, false, false) { typedef Element E; int n = this->NbDoF; bool dd = verbosity > 5; if (dd) { - cout << "\n +++ P3 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + cout << "\n +++ P3 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; } - + R3 *Pt = this->PtInterpolation; // construction of interpolation ppoint - + { - double cc = 1. / 3.; - - for (int i = 0; i < ndof; ++i) { - Pt[i] = R3::KHat[0] * cc * pp[i][0] + R3::KHat[1] * cc * pp[i][1] + - R3::KHat[2] * cc * pp[i][2] + R3::KHat[3] * cc * pp[i][3]; - } - - if (dd) { - cout << this->PtInterpolation << endl; - } + double cc = 1. / 3.; + + for (int i = 0; i < ndof; ++i) { + Pt[i] = R3::KHat[0] * cc * pp[i][0] + R3::KHat[1] * cc * pp[i][1] + R3::KHat[2] * cc * pp[i][2] + R3::KHat[3] * cc * pp[i][3]; + } + + if (dd) { + cout << this->PtInterpolation << endl; + } } - + for (int i = 0; i < n; i++) { - this->pInterpolation[i] = i; - this->cInterpolation[i] = 0; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + this->pInterpolation[i] = i; + this->cInterpolation[i] = 0; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; } -} + } -void TypeOfFE_P3_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_P3_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { // faux nump don la numerotation des p -> local // ne marche que le cas scalaire ??? FH... /* for (int k=0;kNbDoF; int *p = M.p; - + // for (int i = 0; i < n; ++i) { // M.p[i] = i; // } - + if (verbosity > 9) { - cout << " P3 set:" << odf << " : "; + cout << " P3 set:" << odf << " : "; } - - int dof = 4+odf; - + + int dof = 4 + odf; + for (int e = 0; e < 6; ++e) { - int oe = K.EdgeOrientation(e); - int i1=dof; - int i2=dof+1; - //cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; - ffassert( i1>=0 && i2 >=0); - ffassert( i1 0) && (p[i1] > p[i2])) { - swap(p[i1], p[i2]); - } - - dof += 2; + int oe = K.EdgeOrientation(e); + int i1 = dof; + int i2 = dof + 1; + // cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; + ffassert(i1 >= 0 && i2 >= 0); + ffassert(i1 < Np && i2 < Np); + + if ((oe < 0) && (p[i1] < p[i2])) { + swap(p[i1], p[i2]); + } else if ((oe > 0) && (p[i1] > p[i2])) { + swap(p[i1], p[i2]); + } + + dof += 2; } if (verbosity > 99) { - cout << " " << M.p << endl; ; + cout << " " << M.p << endl; + ; } - -} + } -void TypeOfFE_P3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 20); // 23 degrees of freedom assert(val.M( ) == 1); // 3 components // int n = this->NbDoF; @@ -357,20 +337,20 @@ void TypeOfFE_P3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element ld[1] *= 3.; ld[2] *= 3.; ld[3] *= 3.; - + int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; - + { - int dof = 4; - - for (int e = 0; e < 6; ++e) { - int oe = K.EdgeOrientation(e); - if (oe < 0) { - swap(p[dof], p[dof + 1]); - } - - dof += 2; + int dof = 4; + + for (int e = 0; e < 6; ++e) { + int oe = K.EdgeOrientation(e); + if (oe < 0) { + swap(p[dof], p[dof + 1]); } + + dof += 2; + } } // static int ddd = 100; // ddd++; @@ -379,187 +359,169 @@ void TypeOfFE_P3_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element // if (ddd < 20) { // cout << ld[0] << " " << ld[1] << " " << ld[2] << " " << ld[3] << " ::"; // } - + if (whatd & Fop_D0) { - for (int i = 0; i < 20; ++i) { - R fi = 1. / cp[i]; - - for (int l = 0; l < 3; ++l) { - fi *= ld[nl[i][l]] - cl[i][l]; - } - - // if (ddd < 20) { - // cout << " " << fi; - // } - - f0[p[i]] = fi; + for (int i = 0; i < 20; ++i) { + R fi = 1. / cp[i]; + + for (int l = 0; l < 3; ++l) { + fi *= ld[nl[i][l]] - cl[i][l]; } - - /// if (ddd < 20) { - /// cout << endl; - /// } + + // if (ddd < 20) { + // cout << " " << fi; + // } + + f0[p[i]] = fi; + } + + /// if (ddd < 20) { + /// cout << endl; + /// } } - + if (whatd & (Fop_D1 | Fop_D2)) { - R3 Dld[4], Df[20]; - K.Gradlambda(Dld); - Dld[0] *= 3.; - Dld[1] *= 3.; - Dld[2] *= 3.; - Dld[3] *= 3.; - - for (int i = 0; i < 20; ++i) { - R fi = 1. / cp[i]; - R3 &dfi = Df[p[i]]; - - for (int l = 0; l < 3; ++l) { - double ci = ld[nl[i][l]] - cl[i][l]; - dfi *= ci; - dfi += fi * Dld[nl[i][l]]; - fi *= ci; - } - - RN_ f0x(val('.', 0, op_dx)); - RN_ f0y(val('.', 0, op_dy)); - RN_ f0z(val('.', 0, op_dz)); - if (whatd & Fop_dx) { - for (int i = 0; i < 20; ++i) { - f0x[i] = Df[i].x; - } - } - - if (whatd & Fop_dy) { - for (int i = 0; i < 20; ++i) { - f0y[i] = Df[i].y; - } - } - - if (whatd & Fop_dz) { - for (int i = 0; i < 20; ++i) { - f0z[i] = Df[i].z; - } - } - - ffassert(!(whatd & Fop_D2)); // no D2 to do !!! + R3 Dld[4], Df[20]; + K.Gradlambda(Dld); + Dld[0] *= 3.; + Dld[1] *= 3.; + Dld[2] *= 3.; + Dld[3] *= 3.; + + for (int i = 0; i < 20; ++i) { + R fi = 1. / cp[i]; + R3 &dfi = Df[p[i]]; + + for (int l = 0; l < 3; ++l) { + double ci = ld[nl[i][l]] - cl[i][l]; + dfi *= ci; + dfi += fi * Dld[nl[i][l]]; + fi *= ci; } - } -} + RN_ f0x(val('.', 0, op_dx)); + RN_ f0y(val('.', 0, op_dy)); + RN_ f0z(val('.', 0, op_dz)); + if (whatd & Fop_dx) { + for (int i = 0; i < 20; ++i) { + f0x[i] = Df[i].x; + } + } + if (whatd & Fop_dy) { + for (int i = 0; i < 20; ++i) { + f0y[i] = Df[i].y; + } + } + + if (whatd & Fop_dz) { + for (int i = 0; i < 20; ++i) { + f0z[i] = Df[i].z; + } + } + ffassert(!(whatd & Fop_D2)); // no D2 to do !!! + } + } + } -class TypeOfFE_P3_S : public GTypeOfFE< MeshS > { -public: + class TypeOfFE_P3_S : public GTypeOfFE< MeshS > { + public: typedef MeshS Mesh; typedef MeshS::Element Element; typedef GFElement< MeshS > FElement; typedef Mesh::RdHat RdHat; typedef Mesh::Rd Rd; - - static const int kp = 3; // P3 - static const int ndof = (kp + 2) * (kp + 1) / 2;// 10 - constexpr static int dfon[]= {1, 2, 1, 0}; - - - + + static const int kp = 3; // P3 + static const int ndof = (kp + 2) * (kp + 1) / 2; // 10 + constexpr static int dfon[] = {1, 2, 1, 0}; + static const int d = Rd::d; - + constexpr static const int dHat = RdHat::d; - + TypeOfFE_P3_S( ); // constructor - void FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const MeshS &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; -}; -TypeOfFE_P3_S::TypeOfFE_P3_S( ) : GTypeOfFE< MeshS >(TypeOfFE_P3_3d::dfon, 1, 3, false, false) -{ - static int pp[3][ndof] = - {{3, 0, 0, 0, 0, 1, 2, 2, 1, 1}, - {0, 3, 0, 2, 1, 0, 0, 1, 2, 1}, - {0, 0, 3, 1, 2, 2, 1, 0, 0, 1} }; - + void FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const MeshS &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + TypeOfFE_P3_S::TypeOfFE_P3_S( ) : GTypeOfFE< MeshS >(TypeOfFE_P3_3d::dfon, 1, 3, false, false) { + static int pp[3][ndof] = {{3, 0, 0, 0, 0, 1, 2, 2, 1, 1}, {0, 3, 0, 2, 1, 0, 0, 1, 2, 1}, {0, 0, 3, 1, 2, 2, 1, 0, 0, 1}}; + typedef Element E; int n = this->NbDoF; bool dd = verbosity > 5; if (dd) { - cout << "\n +++ P3 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + cout << "\n +++ P3 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; } - + RdHat *Pt = this->PtInterpolation; // construction of interpolation ppoint - + { - double cc = 1. / 3.; - - for (int i = 0; i < ndof; ++i) - Pt[i] = RdHat::KHat[0] * cc * pp[0][i] + RdHat::KHat[1] * cc * pp[1][i] + RdHat::KHat[2] * cc * pp[2][i] ; - - - if (dd) { - cout << this->PtInterpolation << endl; - } + double cc = 1. / 3.; + + for (int i = 0; i < ndof; ++i) Pt[i] = RdHat::KHat[0] * cc * pp[0][i] + RdHat::KHat[1] * cc * pp[1][i] + RdHat::KHat[2] * cc * pp[2][i]; + + if (dd) { + cout << this->PtInterpolation << endl; + } } - + for (int i = 0; i < n; i++) { - this->pInterpolation[i] = i; - this->cInterpolation[i] = 0; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + this->pInterpolation[i] = i; + this->cInterpolation[i] = 0; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; } -} + } -void TypeOfFE_P3_S::set(const MeshS &Th, const TypeOfFE_P3_S::Element &K, InterpolationMatrix< TypeOfFE_P3_S::RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_P3_S::set(const MeshS &Th, const TypeOfFE_P3_S::Element &K, InterpolationMatrix< TypeOfFE_P3_S::RdHat > &M, int ocoef, int odf, int *nump) const { // faux nump don la numerotation des p -> local // ne marche que le cas scalaire ??? FH... /* for (int k=0;kNbDoF; int *p = M.p; - + if (verbosity > 9) { - cout << " P3_S set:" << odf << " : "; + cout << " P3_S set:" << odf << " : "; } - - int dof = 3+odf; - + + int dof = 3 + odf; + for (int e = 0; e < 3; ++e) { - int oe = K.EdgeOrientation(e); - int i1=dof; - int i2=dof+1; - //cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; - ffassert( i1>=0 && i2 >=0); - ffassert( i1 0) && (p[i1] > p[i2])) { - swap(p[i1], p[i2]); - } - - dof += 2; + int oe = K.EdgeOrientation(e); + int i1 = dof; + int i2 = dof + 1; + // cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; + ffassert(i1 >= 0 && i2 >= 0); + ffassert(i1 < Np && i2 < Np); + + if ((oe < 0) && (p[i1] < p[i2])) { + swap(p[i1], p[i2]); + } else if ((oe > 0) && (p[i1] > p[i2])) { + swap(p[i1], p[i2]); + } + + dof += 2; } if (verbosity > 99) { - cout << " " << M.p << endl; ; + cout << " " << M.p << endl; + ; } - -} - -void TypeOfFE_P3_S::FB(const What_d whatd, const TypeOfFE_P3_S::Mesh &Th, const TypeOfFE_P3_S::Element &K, - const TypeOfFE_P3_S::RdHat &PHat, RNMK_ &val) const { - - static int nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, {1, 2, 2}, - {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, {0, 1, 1}, {0, 1, 2}}; - static int aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, {0, 0, 1}, - {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; - - static int ff[10] = {6, 6, 6, 2, 2, 2, 2, 2, 2, 1}; - - + } + + void TypeOfFE_P3_S::FB(const What_d whatd, const TypeOfFE_P3_S::Mesh &Th, const TypeOfFE_P3_S::Element &K, const TypeOfFE_P3_S::RdHat &PHat, RNMK_ &val) const { + + static int nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, {1, 2, 2}, {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, {0, 1, 1}, {0, 1, 2}}; + static int aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; + + static int ff[10] = {6, 6, 6, 2, 2, 2, 2, 2, 2, 1}; + assert(val.N( ) >= 10); // 10 degrees of freedom assert(val.M( ) == 1); // 1 components // int n = this->NbDoF; @@ -568,14 +530,13 @@ void TypeOfFE_P3_S::FB(const What_d whatd, const TypeOfFE_P3_S::Mesh &Th, const // number (i.e. perm[0] is the local number of the vertex with the smallest global number, ... // perm[3] is the local number of the vertex with the biggest global number.) // ------------- - const int ndf=10; + const int ndf = 10; R L[3]; PHat.toBary(L); L[0] *= 3.; L[1] *= 3.; L[2] *= 3.; - - + throwassert(val.N( ) >= 10); throwassert(val.M( ) == 1); // Attention il faut renumeroter les fonction de bases @@ -583,132 +544,131 @@ void TypeOfFE_P3_S::FB(const What_d whatd, const TypeOfFE_P3_S::Mesh &Th, const // et la numerotation naturelle mais 2 noud pas arete // donc p est la perumation // echange de numerotation si les arete sont dans le mauvais sens - int p[10] = {}; - + int p[10] = { }; + for (int i = 0; i < 10; ++i) { - p[i] = i; + p[i] = i; } - + if (K.EdgeOrientation(0) < 0) { - Exchange(p[3], p[4]); // 3,4 + Exchange(p[3], p[4]); // 3,4 } - + if (K.EdgeOrientation(1) < 0) { - Exchange(p[5], p[6]); // 5,6 + Exchange(p[5], p[6]); // 5,6 } - + if (K.EdgeOrientation(2) < 0) { - Exchange(p[7], p[8]); // 7,8 + Exchange(p[7], p[8]); // 7,8 } - + val = 0; - + if (whatd & Fop_D0) { - RN_ f0(val('.', 0, op_id)); - - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R f = 1. / ff[df]; - - for (int i = 0; i < kp; ++i) { - f *= L[nn[df][i]] - aa[df][i]; - } - - f0[pdf] = f; + RN_ f0(val('.', 0, op_id)); + + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R f = 1. / ff[df]; + + for (int i = 0; i < kp; ++i) { + f *= L[nn[df][i]] - aa[df][i]; } + + f0[pdf] = f; + } } - - if(whatd & (Fop_D1|Fop_D2)) - { - - R3 D[3] ; - K.Gradlambda(D); - D[0]*= kp; - D[1]*= kp; - D[2]*= kp; - if (whatd & (Fop_D1|Fop_D2)) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0.,fz = 0., f = 1. / ff[df]; - - for (int i = 0; i < kp; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - fz = fz * Ln + f * D[n].z; - f = f * Ln; - } - - if (whatd & Fop_dx) { - val(pdf, 0, op_dx) = fx; - } - - if (whatd & Fop_dy) { - val(pdf, 0, op_dy) = fy; - } - if (whatd & Fop_dz) { - val(pdf, 0, op_dz) = fz; - } - } + + if (whatd & (Fop_D1 | Fop_D2)) { + + R3 D[3]; + K.Gradlambda(D); + D[0] *= kp; + D[1] *= kp; + D[2] *= kp; + if (whatd & (Fop_D1 | Fop_D2)) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., fz = 0., f = 1. / ff[df]; + + for (int i = 0; i < kp; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + fz = fz * Ln + f * D[n].z; + f = f * Ln; + } + + if (whatd & Fop_dx) { + val(pdf, 0, op_dx) = fx; + } + + if (whatd & Fop_dy) { + val(pdf, 0, op_dy) = fy; + } + if (whatd & Fop_dz) { + val(pdf, 0, op_dz) = fz; + } } - - if (whatd &Fop_D2) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0.,fz=0., f = 1. / ff[df]; - R fxx = 0., fyy = 0., fzz=0., fxy = 0., fxz = 0., fyz = 0. ; - - for (int i = 0; i < kp; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fxx = fxx * Ln + 2. * fx * D[n].x; - fyy = fyy * Ln + 2. * fy * D[n].y; - fzz = fzz * Ln + 2. * fz * D[n].z; - fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; - fxz = fxz * Ln + fx * D[n].z + fz * D[n].x; - fyz = fyz * Ln + fy * D[n].z + fz * D[n].y; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - fz = fz * Ln + f * D[n].z; - f = f * Ln; - } - - if (whatd & Fop_dxx) { - val(pdf, 0, op_dxx) = fxx; - } - - if (whatd & Fop_dyy) { - val(pdf, 0, op_dyy) = fyy; - } - if (whatd & Fop_dzz) { - val(pdf, 0, op_dzz) = fzz; - } - - if (whatd & Fop_dxy) { - val(pdf, 0, op_dxy) = fxy; - } - if (whatd & Fop_dxz) { - val(pdf, 0, op_dxz) = fxz; - } - if (whatd & Fop_dyz) { - val(pdf, 0, op_dyz) = fyz; - } - } + } + + if (whatd & Fop_D2) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., fz = 0., f = 1. / ff[df]; + R fxx = 0., fyy = 0., fzz = 0., fxy = 0., fxz = 0., fyz = 0.; + + for (int i = 0; i < kp; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fxx = fxx * Ln + 2. * fx * D[n].x; + fyy = fyy * Ln + 2. * fy * D[n].y; + fzz = fzz * Ln + 2. * fz * D[n].z; + fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; + fxz = fxz * Ln + fx * D[n].z + fz * D[n].x; + fyz = fyz * Ln + fy * D[n].z + fz * D[n].y; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + fz = fz * Ln + f * D[n].z; + f = f * Ln; + } + + if (whatd & Fop_dxx) { + val(pdf, 0, op_dxx) = fxx; + } + + if (whatd & Fop_dyy) { + val(pdf, 0, op_dyy) = fyy; + } + if (whatd & Fop_dzz) { + val(pdf, 0, op_dzz) = fzz; + } + + if (whatd & Fop_dxy) { + val(pdf, 0, op_dxy) = fxy; + } + if (whatd & Fop_dxz) { + val(pdf, 0, op_dxz) = fxz; + } + if (whatd & Fop_dyz) { + val(pdf, 0, op_dyz) = fyz; + } } + } } -} + } -/* P3 hermite - c1 = x * x * (3 - 2 * x); - c0 = 1 - cb; - c0d = (1 - x) * (1 - x) * x; - c1d = (x - 1) * x * x; + /* P3 hermite + c1 = x * x * (3 - 2 * x); + c0 = 1 - cb; + c0d = (1 - x) * (1 - x) * x; + c1d = (x - 1) * x * x; - */ + */ -class TypeOfFE_P3Hermite : public GTypeOfFE< MeshL > { -public: + class TypeOfFE_P3Hermite : public GTypeOfFE< MeshL > { + public: typedef MeshL Mesh; typedef MeshL::Element Element; typedef GFElement< MeshL > FElement; @@ -716,166 +676,152 @@ class TypeOfFE_P3Hermite : public GTypeOfFE< MeshL > { typedef R3 Rd; static const int dHat = 1; static const int d = 3; - + struct A4 { - int dfon[4]; - A4() { - dfon[0] = dfon[1] = dfon[2] = dfon[3] = 0; - dfon[0] = 2; - } - operator const int * () const {return dfon;} + int dfon[4]; + A4( ) { + dfon[0] = dfon[1] = dfon[2] = dfon[3] = 0; + dfon[0] = 2; + } + operator const int *( ) const { return dfon; } }; - TypeOfFE_P3Hermite( )// 2 composate u and u' - : GTypeOfFE< Mesh >(A4(), 2, 3,4,2, true, false) - { - typedef Element E; - int n = this->NbDoF; - bool dd = verbosity > 5; + TypeOfFE_P3Hermite( ) // 2 composate u and u' + : GTypeOfFE< Mesh >(A4( ), 2, 3, 4, 2, true, false) { + typedef Element E; + int n = this->NbDoF; + bool dd = verbosity > 5; + if (dd) { + cout << "\n +++ P Hermite" << 3 << " L : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + } + ffassert(n == 4); + ffassert(this->PtInterpolation.N( ) == 2); + RdHat *Pt = this->PtInterpolation; + KN< int > pdof(n); + // construction of interpolation ppoint + { + Pt[0] = R1(0); + Pt[1] = R1(1.); if (dd) { - cout << "\n +++ P Hermite"<< 3 <<" L : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; - } - ffassert( n == 4); - ffassert(this->PtInterpolation.N( )==2); - RdHat *Pt = this->PtInterpolation; - KN pdof(n); - // construction of interpolation ppoint - { - Pt[0] = R1(0); - Pt[1] = R1(1.); - if (dd) { - cout << this->PtInterpolation << endl; - } + cout << this->PtInterpolation << endl; } - - for (int i = 0; i < 4; i++) { - this->pInterpolation[i] = i/2; - this->cInterpolation[i] = i%2; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + } + + for (int i = 0; i < 4; i++) { + this->pInterpolation[i] = i / 2; + this->cInterpolation[i] = i % 2; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; + } + } + void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const { + /* Warning no affine independant !!!!!! + c1 = x * x * (3 - 2 * x); + c0 = 1 - c1; + c0d = (1 - x) * (1 - x) * x; + c1d = (x - 1) * x * x; + */ + double h = K.mesure( ), h1 = 1. / h; + const int k = 3; + double l[dHat + 1]; + PHat.toBary(l); + double l0 = l[0], l1 = l[1]; // l0 = 1-x, l1 = x + const double l11 = l1 * l1, l111 = l11 * l1, l01 = l0 * l1, l00 = l0 * l0; + const double dl11 = 2 * l1, dl00 = -2 * l0, dl111 = 3. * l11, dl01 = l0 - l1; + const double ddl11 = 2, ddl00 = 2, ddl111 = 6 * l1; + double fb[4], dfb[4], ddfb[4], dddfb[4]; + fb[2] = l11 * 3. - 2. * l111; + fb[1] = l00 * l1 * h; + fb[0] = 1. - fb[2]; + fb[3] = -l0 * l11 * h; + + dfb[2] = (dl11 * 3. - 2. * dl111); + dfb[1] = (dl00 * l1 + l00) * h; + dfb[0] = -dfb[2]; + dfb[3] = -(dl11 * l0 - l11) * h; + + ddfb[2] = (ddl11 * 3. - 2. * ddl111); + ddfb[1] = (ddl00 * l1 + dl00 + dl00) * h; + ddfb[0] = -ddfb[2]; + ddfb[3] = -(ddl11 * l0 - dl11 - dl11) * h; + + dddfb[2] = -12.; + dddfb[1] = 6. * h; + dddfb[0] = 12.; + dddfb[3] = 6 * h; + + if (whatd & Fop_D0) { + double ff0; + int dof = 0; + RN_ f0(val('.', 0, op_id)); + RN_ f1(val('.', 1, op_id)); + for (int i = 0; i < 4; ++i) { + val(i, 0, op_id) = fb[i]; + val(i, 1, op_id) = dfb[i] * h1; } - } - void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, RNMK_ &val) const - { - /* Warning no affine independant !!!!!! - c1 = x * x * (3 - 2 * x); - c0 = 1 - c1; - c0d = (1 - x) * (1 - x) * x; - c1d = (x - 1) * x * x; -*/ - double h =K.mesure(), h1=1./h; - const int k =3; - double l[dHat+1]; - PHat.toBary(l); - double l0 = l[0], l1=l[1];// l0 = 1-x, l1 = x - const double l11=l1*l1,l111=l11*l1, l01 = l0*l1 , l00=l0*l0; - const double dl11= 2*l1,dl00= -2*l0,dl111=3.*l11, dl01 = l0 - l1; - const double ddl11 = 2,ddl00= 2,ddl111= 6*l1; - double fb[4],dfb[4],ddfb[4], dddfb[4]; - fb[2] = l11*3.-2.*l111; - fb[1] = l00*l1*h; - fb[0] = 1.-fb[2]; - fb[3] = -l0*l11*h; - - dfb[2] = (dl11*3.-2.*dl111); - dfb[1] = (dl00*l1 +l00)*h; - dfb[0] = -dfb[2]; - dfb[3] = -(dl11*l0 -l11)*h; - - ddfb[2] = (ddl11*3.-2.*ddl111); - ddfb[1] = (ddl00*l1+ dl00 +dl00)*h; - ddfb[0] = -ddfb[2]; - ddfb[3] = -(ddl11*l0 -dl11 -dl11)*h; - - dddfb[2] = -12.; - dddfb[1] = 6.*h; - dddfb[0] = 12.; - dddfb[3] = 6*h; - - - if (whatd & Fop_D0) - { double ff0; - int dof =0; - RN_ f0(val('.',0,op_id)); - RN_ f1(val('.',1,op_id)); - for(int i=0; i<4;++i) - { - val(i,0,op_id)= fb[i]; - val(i,1,op_id)= dfb[i]*h1; + // cout<<" P3H L :" << PHat << " / " << f0 << " / " << f1 << endl; + } + + if (whatd & (Fop_D1 | Fop_D2)) { + Rd Dl[dHat + 1]; + Rd DDl[dHat + 1][d]; + K.Gradlambda(Dl); + bool d2 = Fop_D2 && k > 1; // calcul de + const unsigned int fop[3] = {Fop_dx, Fop_dy, Fop_dz}; + const int op[3] = {op_dx, op_dy, op_dz}; + const int dop[9] = {op_dxx, op_dxy, op_dxz, op_dyx, op_dyy, op_dyz, op_dzx, op_dzy, op_dzz}; + + Rd dX, ddX(d); + dX = Dl[1]; + + // copy data d D + for (int dd = 0; dd < Rd::d; ++dd) { + if (whatd & fop[dd]) + for (int i = 0; i < this->NbDoF; ++i) { + val(i, 0, op[dd]) = dX[dd] * dfb[i]; + val(i, 1, op[dd]) = dX[dd] * ddfb[i] * h1; } - // cout<<" P3H L :" << PHat << " / " << f0 << " / " << f1 << endl; } - - - if(whatd & (Fop_D1|Fop_D2)) - { - Rd Dl[dHat+1]; - Rd DDl[dHat+1][d]; - K.Gradlambda(Dl); - - bool d2= Fop_D2 && k>1;// calcul de - const unsigned int fop[3]={Fop_dx,Fop_dy,Fop_dz}; - const int op[3]={op_dx,op_dy,op_dz}; - const int dop[9]={op_dxx,op_dxy,op_dxz, op_dyx,op_dyy,op_dyz, op_dzx,op_dzy,op_dzz}; - - Rd dX,ddX(d); - dX=Dl[1]; - - // copy data d D - for (int dd=0; dd< Rd::d;++dd) - { - if (whatd & fop[dd]) - for(int i=0;iNbDoF;++i) - { - val(i,0,op[dd]) = dX[dd]*dfb[i]; - val(i,1,op[dd]) = dX[dd]*ddfb[i]*h1; - } - } - // copy data DD - if(d2) - { - for (int id=0; id< Rd::d;++id) - for (int jd=0; jd<= id;++jd) - { - double ddx = dX[id]*dX[jd]; - int op = dop[id*3+jd]; - const unsigned int fopij= 1<< op; - if (whatd & fopij) - { - for(int i=0;iNbDoF;++i) - { - val(i,0,op) = ddx*ddfb[i]; - val(i,1,op) = ddx*dddfb[i]*h1; - } - } + // copy data DD + if (d2) { + for (int id = 0; id < Rd::d; ++id) + for (int jd = 0; jd <= id; ++jd) { + double ddx = dX[id] * dX[jd]; + int op = dop[id * 3 + jd]; + const unsigned int fopij = 1 << op; + if (whatd & fopij) { + for (int i = 0; i < this->NbDoF; ++i) { + val(i, 0, op) = ddx * ddfb[i]; + val(i, 1, op) = ddx * dddfb[i] * h1; } + } } - } + } } -}; + }; #include "Element_PkL.hpp" -// link with FreeFem++ -static TypeOfFE_P3Lagrange P3LagrangeP3; -// a static variable to add the finite element to freefem++ -static TypeOfFE_P3_3d P3_3d; -static TypeOfFE_Pk_L P3_L(3); -static TypeOfFE_P3_S P3_S; -static TypeOfFE_P3Hermite P3H_L; - -GTypeOfFE< Mesh3 > &Elm_P3_3d(P3_3d); -GTypeOfFE< MeshL > &Elm_P3_L(P3_L); -GTypeOfFE< MeshS > &Elm_P3_S(P3_S); -GTypeOfFE< MeshL > &Elm_P3H_L(P3H_L); - -static void init( ) { + // link with FreeFem++ + static TypeOfFE_P3Lagrange P3LagrangeP3; + // a static variable to add the finite element to freefem++ + static TypeOfFE_P3_3d P3_3d; + static TypeOfFE_Pk_L P3_L(3); + static TypeOfFE_P3_S P3_S; + static TypeOfFE_P3Hermite P3H_L; + + GTypeOfFE< Mesh3 > &Elm_P3_3d(P3_3d); + GTypeOfFE< MeshL > &Elm_P3_L(P3_L); + GTypeOfFE< MeshS > &Elm_P3_S(P3_S); + GTypeOfFE< MeshL > &Elm_P3H_L(P3H_L); + + static void init( ) { AddNewFE("P3", &P3LagrangeP3); - static ListOfTFE FE_P3("P3", &P3LagrangeP3); // to add P3 in list of Common FE - AddNewFE3("P33d", &Elm_P3_3d,"P3"); - AddNewFEL("P3L", &Elm_P3_L,"P3"); + static ListOfTFE FE_P3("P3", &P3LagrangeP3); // to add P3 in list of Common FE + AddNewFE3("P33d", &Elm_P3_3d, "P3"); + AddNewFEL("P3L", &Elm_P3_L, "P3"); AddNewFEL("P3HL", &Elm_P3H_L); - AddNewFES("P3S", &Elm_P3_S,"P3"); -} + AddNewFES("P3S", &Elm_P3_S, "P3"); + } } // namespace Fem2D LOADFUNC(Fem2D::init); diff --git a/plugin/seq/Element_P3.hpp b/plugin/seq/Element_P3.hpp index 12313dfec..195aabd29 100644 --- a/plugin/seq/Element_P3.hpp +++ b/plugin/seq/Element_P3.hpp @@ -20,10 +20,8 @@ // AUTHORS : ... // E-MAIL : ... -const int TypeOfFE_P3Lagrange::nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, {1, 2, 2}, - {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, {0, 1, 1}, {0, 1, 2}}; -const int TypeOfFE_P3Lagrange::aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, {0, 0, 1}, - {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; +const int TypeOfFE_P3Lagrange::nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, {1, 2, 2}, {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, {0, 1, 1}, {0, 1, 2}}; +const int TypeOfFE_P3Lagrange::aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; const int TypeOfFE_P3Lagrange::ff[10] = {6, 6, 6, 2, 2, 2, 2, 2, 2, 1}; const int TypeOfFE_P3Lagrange::il[10] = {3, 0, 0, 0, 0, 1, 2, 2, 1, 1}; const int TypeOfFE_P3Lagrange::jl[10] = {0, 3, 0, 2, 1, 0, 0, 1, 2, 1}; diff --git a/plugin/seq/Element_P3dc.cpp b/plugin/seq/Element_P3dc.cpp index ae6b17957..690fd56e8 100644 --- a/plugin/seq/Element_P3dc.cpp +++ b/plugin/seq/Element_P3dc.cpp @@ -57,10 +57,8 @@ namespace Fem2D { static R2 Shrink1(const R2 &P) { return (P - G) * cshrink1 + G; } TypeOfFE_P3dcLagrange( ) : TypeOfFE(3 + 2 * 3 + 1, 1, Data, 4, 1, 10, 10, Pi_h_coef) { - static const R2 Pt[10] = {R2(0 / 3., 0 / 3.), R2(3 / 3., 0 / 3.), R2(0 / 3., 3 / 3.), - R2(2 / 3., 1 / 3.), R2(1 / 3., 2 / 3.), R2(0 / 3., 2 / 3.), - R2(0 / 3., 1 / 3.), R2(1 / 3., 0 / 3.), R2(2 / 3., 0 / 3.), - R2(1 / 3., 1 / 3.)}; + static const R2 Pt[10] = {R2(0 / 3., 0 / 3.), R2(3 / 3., 0 / 3.), R2(0 / 3., 3 / 3.), R2(2 / 3., 1 / 3.), R2(1 / 3., 2 / 3.), + R2(0 / 3., 2 / 3.), R2(0 / 3., 1 / 3.), R2(1 / 3., 0 / 3.), R2(2 / 3., 0 / 3.), R2(1 / 3., 1 / 3.)}; // 3,4,5,6,7,8 for (int i = 0; i < NbDoF; i++) { @@ -69,8 +67,7 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &P1, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &P1, RNMK_ &val) const; }; const R2 TypeOfFE_P3dcLagrange::G(1. / 3., 1. / 3.); @@ -78,17 +75,15 @@ namespace Fem2D { const R TypeOfFE_P3dcLagrange::cshrink1 = 1. / TypeOfFE_P3dcLagrange::cshrink; // on what nu df on node node of df - int TypeOfFE_P3dcLagrange::Data[] = { - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // the support number of the node of the df - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // the number of the df on the node - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated - 0, 10}; + int TypeOfFE_P3dcLagrange::Data[] = {6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // the support number of the node of the df + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // the number of the df on the node + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated + 0, 10}; double TypeOfFE_P3dcLagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; - void TypeOfFE_P3dcLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &P1, RNMK_ &val) const { + void TypeOfFE_P3dcLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &P1, RNMK_ &val) const { R2 P = Shrink1(P1); R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; diff --git a/plugin/seq/Element_P3dc.hpp b/plugin/seq/Element_P3dc.hpp index a7e4ba663..66637e00f 100644 --- a/plugin/seq/Element_P3dc.hpp +++ b/plugin/seq/Element_P3dc.hpp @@ -20,12 +20,8 @@ // AUTHORS : ... // E-MAIL : ... -const int TypeOfFE_P3dcLagrange::nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, - {1, 2, 2}, {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, - {0, 1, 1}, {0, 1, 2}}; -const int TypeOfFE_P3dcLagrange::aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, - {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, - {0, 0, 1}, {0, 0, 0}}; +const int TypeOfFE_P3dcLagrange::nn[10][3] = {{0, 0, 0}, {1, 1, 1}, {2, 2, 2}, {1, 1, 2}, {1, 2, 2}, {0, 2, 2}, {0, 0, 2}, {0, 0, 1}, {0, 1, 1}, {0, 1, 2}}; +const int TypeOfFE_P3dcLagrange::aa[10][3] = {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}, {0, 1, 0}, {0, 0, 1}, {0, 0, 1}, {0, 1, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}; const int TypeOfFE_P3dcLagrange::ff[10] = {6, 6, 6, 2, 2, 2, 2, 2, 2, 1}; const int TypeOfFE_P3dcLagrange::il[10] = {3, 0, 0, 0, 0, 1, 2, 2, 1, 1}; const int TypeOfFE_P3dcLagrange::jl[10] = {0, 3, 0, 2, 1, 0, 0, 1, 2, 1}; diff --git a/plugin/seq/Element_P3nc.cpp b/plugin/seq/Element_P3nc.cpp index 9cef5a623..67a89d0f5 100644 --- a/plugin/seq/Element_P3nc.cpp +++ b/plugin/seq/Element_P3nc.cpp @@ -17,7 +17,7 @@ // SUMMARY : ... // LICENSE : LGPLv3 // ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE, CEA -// AUTHORS : BALAZI ATCHY NILLAMA Loïc et HECHT Frédéric +// AUTHORS : BALAZI ATCHY NILLAMA Loïc et HECHT Frédéric // E-MAIL : loic.balaziatchynillama@cea.fr et rederic.hecht@sorbonne-universite.fr /* clang-format off */ @@ -32,7 +32,7 @@ 3 Dof on triangle K int_(K) \lambda_0 v, int_(e) \lambda_1 v, int_(e) \lambda_2 where \lambda_0 , \lambda_1, \lambda_2 is the barycentric coordinate on traingle K - + and the Pk polynomial space is : P3 + span( bk \lambda_0 , bk \lambda_1) bk = (\lambda_0 - \lambda_1) * (\lambda_1 - \lambda_2) * (\lambda_2 - \lambda_0); */ @@ -54,7 +54,7 @@ namespace Fem2D { public: static int Data[]; - TypeOfFE_P3nc( ) : TypeOfFE(10, 1, Data, 4, 1, 3 * 3 * QFE.n + QFK.n, 3 * QFE.n + QFK.n, 0) { + TypeOfFE_P3nc( ) : TypeOfFE(10, 1, Data, 4, 1, 3 * 3 * QFE.n + QFK.n, 3 * QFE.n + QFK.n, 0) { int p = 0, k = 0; const R2 Ph[] = {R2(0, 0), R2(1, 0), R2(0, 1)}; @@ -62,7 +62,7 @@ namespace Fem2D { R2 A = Ph[(i + 1) % 3], B = Ph[(i + 2) % 3]; for (int j = 0; j < QFE.n; j++) { R l0 = QFE[j].x, l1 = 1 - l0; - if(verbosity>4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + if (verbosity > 4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; pij_alpha[k++] = IPJ(3 * i, p, 0); pij_alpha[k++] = IPJ(3 * i + 1, p, 0); pij_alpha[k++] = IPJ(3 * i + 2, p, 0); @@ -71,38 +71,35 @@ namespace Fem2D { } for (int i = 0; i < QFK.n; i++) { - if(verbosity>4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + if (verbosity > 4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; pij_alpha[k++] = IPJ(9, p, 0); P_Pi_h[p++] = QFK[i]; } - if(verbosity>4) - { - cout << " QFE.n " << QFE.n << endl; - cout << " QFK.n " << QFK.n << endl; - cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; - cout << "p = " << p << " AND P_Pi_h = " << P_Pi_h.N( )<< endl; -} + if (verbosity > 4) { + cout << " QFE.n " << QFE.n << endl; + cout << " QFK.n " << QFK.n << endl; + cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + cout << "p = " << p << " AND P_Pi_h = " << P_Pi_h.N( ) << endl; + } ffassert(k == this->pij_alpha.N( )); ffassert(p == this->P_Pi_h.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; // const QuadratureFormular1d & TypeOfFE_P2pnc::QFE=QF_GaussLegendre3; // const GQuadratureFormular & TypeOfFE_P2pnc::QFK=QuadratureFormular_T_5; - int TypeOfFE_P3nc::Data[] = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, // the support number of the node of the df - 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, // the number of the df on the node - 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated - 0, 10}; - void TypeOfFE_P3nc::Pi_h_alpha( - const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... + int TypeOfFE_P3nc::Data[] = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, // the support number of the node of the df + 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, // the number of the df on the node + 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated + 0, 10}; + void TypeOfFE_P3nc::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... const Triangle &T(K.T); int k = 0; R oe[3] = {T.EdgeOrientation(0), T.EdgeOrientation(1), T.EdgeOrientation(2)}; @@ -112,10 +109,10 @@ namespace Fem2D { for (int i = 0; i < 3; i++) { for (int p = 0; p < QFE.n; ++p) { - double x = QFE[p].x; - R L0 = QFE[p].x , L1 = 1-QFE[p].x , L2 = L0*L1 ; + double x = QFE[p].x; + R L0 = QFE[p].x, L1 = 1 - QFE[p].x, L2 = L0 * L1; if (oe[i] < 0) { - swap(L0, L1); //depend on edge orientation //No need to swap L2 since symmetric + swap(L0, L1); // depend on edge orientation //No need to swap L2 since symmetric } if (ddd < 3) { @@ -131,65 +128,54 @@ namespace Fem2D { } } - for (int p = 0; p < QFK.n; ++p) - v[k++] = QFK[p].a; - + for (int p = 0; p < QFK.n; ++p) v[k++] = QFK[p].a; ffassert(k == this->pij_alpha.N( )); } - void TypeOfFE_P3nc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P3nc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R oe[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; R l12[] = { - l0 * l0 * l0, l1 * l1 * l1, l2 * l2 * l2, //3 - l0 * l0 * l1, l0 * l0 * l2, l1 * l1 * l0, l1 * l1 * l2, l2 * l2 * l0, l2 * l2 * l1, //6 - l0 * l1 * l2 //2 - - }; // 10 monome - - /* - -6 -6 30 6 6 -30 6 6 -30 0 - 6 6 -30 -6 -6 30 6 6 -30 0 - 6 6 -30 6 6 -30 -6 -6 30 0 - 54 54 -270 -54 -54 270 18 -42 90 0 - 54 54 -270 -42 18 90 -54 -54 270 0 - -54 -54 270 54 54 -270 -42 18 90 0 - 18 -42 90 54 54 -270 -54 -54 270 0 - -54 -54 270 18 -42 90 54 54 -270 0 - -42 18 90 -54 -54 270 54 54 -270 0 - 12 12 -180 12 12 -180 12 12 -180 60 -*/ - double C1[10][10] ={{-6,-6,30,6,6,-30,6,6,-30,0}, - {6,6,-30,-6,-6,30,6,6,-30,0}, - {6,6,-30,6,6,-30,-6,-6,30,0}, - {54,54,-270,-54,-54,270,18,-42,90,0}, - {54,54,-270,-42,18,90,-54,-54,270,0}, - {-54,-54,270,54,54,-270,-42,18,90,0}, - {18,-42,90,54,54,-270,-54,-54,270,0}, - {-54,-54,270,18,-42,90,54,54,-270,0}, - {-42,18,90,-54,-54,270,54,54,-270,0}, - {12,12,-180,12,12,-180,12,12,-180,60}} -; - + l0 * l0 * l0, l1 * l1 * l1, l2 * l2 * l2, // 3 + l0 * l0 * l1, l0 * l0 * l2, l1 * l1 * l0, l1 * l1 * l2, l2 * l2 * l0, l2 * l2 * l1, // 6 + l0 * l1 * l2 // 2 + + }; // 10 monome + + /* + -6 -6 30 6 6 -30 6 6 -30 0 + 6 6 -30 -6 -6 30 6 6 -30 0 + 6 6 -30 6 6 -30 -6 -6 30 0 + 54 54 -270 -54 -54 270 18 -42 90 0 + 54 54 -270 -42 18 90 -54 -54 270 0 + -54 -54 270 54 54 -270 -42 18 90 0 + 18 -42 90 54 54 -270 -54 -54 270 0 + -54 -54 270 18 -42 90 54 54 -270 0 + -42 18 90 -54 -54 270 54 54 -270 0 + 12 12 -180 12 12 -180 12 12 -180 60 + */ + double C1[10][10] = {{-6, -6, 30, 6, 6, -30, 6, 6, -30, 0}, {6, 6, -30, -6, -6, 30, 6, 6, -30, 0}, {6, 6, -30, 6, 6, -30, -6, -6, 30, 0}, + {54, 54, -270, -54, -54, 270, 18, -42, 90, 0}, {54, 54, -270, -42, 18, 90, -54, -54, 270, 0}, {-54, -54, 270, 54, 54, -270, -42, 18, 90, 0}, + {18, -42, 90, 54, 54, -270, -54, -54, 270, 0}, {-54, -54, 270, 18, -42, 90, 54, 54, -270, 0}, {-42, 18, 90, -54, -54, 270, 54, 54, -270, 0}, + {12, 12, -180, 12, 12, -180, 12, 12, -180, 60}}; // C1 = C^1 // C(i,j) = dof(i,mom_j) // dof(k,sum_j C1(j,i)*mom_j) = delta_ik // sum_j C1(j,i)*dof(k,mom_j) = Id - // sum_j C_kj C1(j,i) = Id - // sum_j dof(k,mom_j) C1(j,i) = Id - // C_kj= dof(k,mom_j) + // sum_j C_kj C1(j,i) = Id + // sum_j dof(k,mom_j) C1(j,i) = Id + // C_kj= dof(k,mom_j) - // formule magic : - // sur un simplex en dim d , l_0, , .. l_d coord barycentric + // formule magic : + // sur un simplex en dim d , l_0, , .. l_d coord barycentric // int_K (\Prod_i=0^d l_i^n_i) = |K| ( d! \Prod_i n_i! / (d+ sum_i n_i)!) // n_i == 0 , - // n_i = delta_ik => int_K l_k = |K|/(d+1) - // int_K l_k l_j = |K|(1+delta_kj) /((d+1)((d+2)) - // + // n_i = delta_ik => int_K l_k = |K|/(d+1) + // int_K l_k l_j = |K|(1+delta_kj) /((d+1)((d+2)) + // if (val.N( ) < 10) { ffassert(val.N( ) >= 10); @@ -199,8 +185,7 @@ namespace Fem2D { val = 0; RN_ f0(val('.', 0, op_id)); - int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; //no need to swap 2, 5, 8 since symmetric - + int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; // no need to swap 2, 5, 8 since symmetric if (oe[0] < 0) { swap(p[0], p[1]); @@ -214,7 +199,7 @@ namespace Fem2D { swap(p[6], p[7]); } - //No need to swap elemet 2, 5 and 8 since they are symmetric = do not depends on edge orientation + // No need to swap elemet 2, 5 and 8 since they are symmetric = do not depends on edge orientation if (whatd[op_id]) { for (int i = 0; i < 10; ++i) { @@ -227,17 +212,17 @@ namespace Fem2D { if (whatd[op_dx] || whatd[op_dy]) { R2 D0 = K.H(0), D1 = K.H(1), D2 = K.H(2); R2 D12[] = { - D0 * (l0 * l0*3.), - D1 * (l1 * l1*3.), - D2 * (l2 * l2*3.), - D0 * (l0 * l1 *2.) + D1 * (l0 * l0), - D0 * (l0 * l2 *2.) + D2 * (l0 * l0), - D1 * (l1 * l0 *2.) + D0 * (l1 * l1), - D1 * (l1 * l2 *2.) + D2 * (l1 * l1), - D2 * (l2 * l0 *2.) + D0 * (l2 * l2), - D2 * (l2 * l1 *2.) + D1 * (l2 * l2), - D0 * (l1 * l2) + D1* (l0 * l2) + D2* (l0 * l1) , - }; + D0 * (l0 * l0 * 3.), + D1 * (l1 * l1 * 3.), + D2 * (l2 * l2 * 3.), + D0 * (l0 * l1 * 2.) + D1 * (l0 * l0), + D0 * (l0 * l2 * 2.) + D2 * (l0 * l0), + D1 * (l1 * l0 * 2.) + D0 * (l1 * l1), + D1 * (l1 * l2 * 2.) + D2 * (l1 * l1), + D2 * (l2 * l0 * 2.) + D0 * (l2 * l2), + D2 * (l2 * l1 * 2.) + D1 * (l2 * l2), + D0 * (l1 * l2) + D1 * (l0 * l2) + D2 * (l0 * l1), + }; if (whatd[op_dx]) { RN_ f0x(val('.', 0, op_dx)); diff --git a/plugin/seq/Element_P3pnc.cpp b/plugin/seq/Element_P3pnc.cpp index 46a038861..40a0afb94 100644 --- a/plugin/seq/Element_P3pnc.cpp +++ b/plugin/seq/Element_P3pnc.cpp @@ -17,7 +17,7 @@ // SUMMARY : ... // LICENSE : LGPLv3 // ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE, CEA -// AUTHORS : BALAZI ATCHY NILLAMA Loïc et HECHT Frédéric +// AUTHORS : BALAZI ATCHY NILLAMA Loïc et HECHT Frédéric // E-MAIL : loic.balaziatchynillama@cea.fr et rederic.hecht@sorbonne-universite.fr /* clang-format off */ @@ -32,7 +32,7 @@ 3 Dof on triangle K int_(K) \lambda_0 v, int_(e) \lambda_1 v, int_(e) \lambda_2 where \lambda_0 , \lambda_1, \lambda_2 is the barycentric coordinate on traingle K - + and the Pk polynomial space is : P3 + span( bk \lambda_0 , bk \lambda_1) bk = (\lambda_0 - \lambda_1) * (\lambda_1 - \lambda_2) * (\lambda_2 - \lambda_0); */ @@ -62,7 +62,7 @@ namespace Fem2D { R2 A = Ph[(i + 1) % 3], B = Ph[(i + 2) % 3]; for (int j = 0; j < QFE.n; j++) { R l0 = QFE[j].x, l1 = 1 - l0; - if(verbosity>4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + if (verbosity > 4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; pij_alpha[k++] = IPJ(3 * i, p, 0); pij_alpha[k++] = IPJ(3 * i + 1, p, 0); pij_alpha[k++] = IPJ(3 * i + 2, p, 0); @@ -71,40 +71,37 @@ namespace Fem2D { } for (int i = 0; i < QFK.n; i++) { - if(verbosity>4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + if (verbosity > 4) cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; pij_alpha[k++] = IPJ(9, p, 0); pij_alpha[k++] = IPJ(10, p, 0); pij_alpha[k++] = IPJ(11, p, 0); P_Pi_h[p++] = QFK[i]; } - if(verbosity>4) - { - cout << " QFE.n " << QFE.n << endl; - cout << " QFK.n " << QFK.n << endl; - cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; - cout << "p = " << p << " AND P_Pi_h = " << P_Pi_h.N( )<< endl; -} + if (verbosity > 4) { + cout << " QFE.n " << QFE.n << endl; + cout << " QFK.n " << QFK.n << endl; + cout << "k = " << k << " AND pij = " << pij_alpha.N( ) << endl; + cout << "p = " << p << " AND P_Pi_h = " << P_Pi_h.N( ) << endl; + } ffassert(k == this->pij_alpha.N( )); ffassert(p == this->P_Pi_h.N( )); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; }; // const QuadratureFormular1d & TypeOfFE_P2pnc::QFE=QF_GaussLegendre3; // const GQuadratureFormular & TypeOfFE_P2pnc::QFK=QuadratureFormular_T_5; - int TypeOfFE_P3pnc::Data[] = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the support number of the node of the df - 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, // the number of the df on the node - 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated + int TypeOfFE_P3pnc::Data[] = {3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the support number of the node of the df + 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, // the number of the df on the node + 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated 0, 12}; - void TypeOfFE_P3pnc::Pi_h_alpha( - const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... + void TypeOfFE_P3pnc::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { // compute the coef of interpolation ... const Triangle &T(K.T); int k = 0; R oe[3] = {T.EdgeOrientation(0), T.EdgeOrientation(1), T.EdgeOrientation(2)}; @@ -114,10 +111,10 @@ namespace Fem2D { for (int i = 0; i < 3; i++) { for (int p = 0; p < QFE.n; ++p) { - double x = QFE[p].x; - R L0 = QFE[p].x , L1 = 1-QFE[p].x , L2 = L0*L1 ; + double x = QFE[p].x; + R L0 = QFE[p].x, L1 = 1 - QFE[p].x, L2 = L0 * L1; if (oe[i] < 0) { - swap(L0, L1); //depend on edge orientation //No need to swap L2 since symmetric + swap(L0, L1); // depend on edge orientation //No need to swap L2 since symmetric } if (ddd < 3) { @@ -144,18 +141,17 @@ namespace Fem2D { ffassert(k == this->pij_alpha.N( )); } - void TypeOfFE_P3pnc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_P3pnc::FB(const bool *whatd, const Mesh &TH, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R bk = (l0 - l1) * (l1 - l2) * (l2 - l0); R oe[3] = {K.EdgeOrientation(0), K.EdgeOrientation(1), K.EdgeOrientation(2)}; R l12[] = { - l0 * l0 * l0, l1 * l1 * l1, l2 * l2 * l2, //3 - l0 * l0 * l1, l0 * l0 * l2, l1 * l1 * l0, l1 * l1 * l2, l2 * l2 * l0, l2 * l2 * l1, //6 - l0 * l1 * l2, //2 - bk * l0, bk * l1 // P4 element - }; // 12 monome + l0 * l0 * l0, l1 * l1 * l1, l2 * l2 * l2, // 3 + l0 * l0 * l1, l0 * l0 * l2, l1 * l1 * l0, l1 * l1 * l2, l2 * l2 * l0, l2 * l2 * l1, // 6 + l0 * l1 * l2, // 2 + bk * l0, bk * l1 // P4 element + }; // 12 monome /* double C1[12][12] ={ @@ -173,38 +169,36 @@ namespace Fem2D { {4.8, 4.8, -9.6, 2.4, -108, 2.4, -108, 105.6, 105.6, 60, 84, -84 }, }; */ - - double C1[12][12] ={ - { -1.2, -1.2, 1.2, 1.2, 6., -15.6, 6., 1.2, -15.6, -9.6, 4.8, 4.8 }, //dof 1 - { 6., 1.2, -15.6, -1.2, -1.2, 1.2, 1.2, 6., -15.6, 4.8, -9.6, 4.8 }, //dof 2 - { 1.2, 6., -15.6, 6., 1.2, -15.6, -1.2, -1.2, 1.2, 4.8 , 4.8, -9.6 }, //dof 3 - { -8.4, -73.2, 298.8, 73.2, 10.8, -306., -46.8, 20.4, 97.2, 189.6, -192., 2.4 }, //dof 4 - { 10.8, 75.6, -205.2, -63.6, -46.8, 349.2, 10.8, -10.8, -54., 21.6, 86.4, -108. }, //dof 5 - { 10.8, 73.2, -306., -73.2, -8.4, 298.8, 20.4, -46.8, 97.2, -192., 189.6, 2.4 }, //dof 6 - { -46.8, -63.6, 349.2, 75.6, 10.8, -205.2, -10.8, 10.8, -54., 86.4 , 21.6, -108. }, //dof 7 - { -10.8, -73.2, 198., 37.2, 20.4, -154.8, -8.4, 10.8, 46.8, -24. , -81.6, 105.6 }, //dof 8 - { 20.4, 37.2, -154.8, -73.2, -10.8, 198., 10.8, -8.4, 46.8, -81.6 , -24., 105.6 }, //dof 9 - { 12., 12., -180., 12., 12., -180., 12., 12., -180., 60. , 60., 60. }, //dof 10 - { 0., -84., 252., 84., 84., -504., -84., 0., 252., 84., -168., 84. }, //dof 11 - { -84., -84., 504., 84., 0., -252., -0., 84., -252., 168., -84., -84. }, //dof 12 + double C1[12][12] = { + {-1.2, -1.2, 1.2, 1.2, 6., -15.6, 6., 1.2, -15.6, -9.6, 4.8, 4.8}, // dof 1 + {6., 1.2, -15.6, -1.2, -1.2, 1.2, 1.2, 6., -15.6, 4.8, -9.6, 4.8}, // dof 2 + {1.2, 6., -15.6, 6., 1.2, -15.6, -1.2, -1.2, 1.2, 4.8, 4.8, -9.6}, // dof 3 + {-8.4, -73.2, 298.8, 73.2, 10.8, -306., -46.8, 20.4, 97.2, 189.6, -192., 2.4}, // dof 4 + {10.8, 75.6, -205.2, -63.6, -46.8, 349.2, 10.8, -10.8, -54., 21.6, 86.4, -108.}, // dof 5 + {10.8, 73.2, -306., -73.2, -8.4, 298.8, 20.4, -46.8, 97.2, -192., 189.6, 2.4}, // dof 6 + {-46.8, -63.6, 349.2, 75.6, 10.8, -205.2, -10.8, 10.8, -54., 86.4, 21.6, -108.}, // dof 7 + {-10.8, -73.2, 198., 37.2, 20.4, -154.8, -8.4, 10.8, 46.8, -24., -81.6, 105.6}, // dof 8 + {20.4, 37.2, -154.8, -73.2, -10.8, 198., 10.8, -8.4, 46.8, -81.6, -24., 105.6}, // dof 9 + {12., 12., -180., 12., 12., -180., 12., 12., -180., 60., 60., 60.}, // dof 10 + {0., -84., 252., 84., 84., -504., -84., 0., 252., 84., -168., 84.}, // dof 11 + {-84., -84., 504., 84., 0., -252., -0., 84., -252., 168., -84., -84.}, // dof 12 }; - // C1 = C^1 // C(i,j) = dof(i,mom_j) // dof(k,sum_j C1(j,i)*mom_j) = delta_ik // sum_j C1(j,i)*dof(k,mom_j) = Id - // sum_j C_kj C1(j,i) = Id - // sum_j dof(k,mom_j) C1(j,i) = Id - // C_kj= dof(k,mom_j) + // sum_j C_kj C1(j,i) = Id + // sum_j dof(k,mom_j) C1(j,i) = Id + // C_kj= dof(k,mom_j) - // formule magic : - // sur un simplex en dim d , l_0, , .. l_d coord barycentric + // formule magic : + // sur un simplex en dim d , l_0, , .. l_d coord barycentric // int_K (\Prod_i=0^d l_i^n_i) = |K| ( d! \Prod_i n_i! / (d+ sum_i n_i)!) // n_i == 0 , - // n_i = delta_ik => int_K l_k = |K|/(d+1) - // int_K l_k l_j = |K|(1+delta_kj) /((d+1)((d+2)) - // + // n_i = delta_ik => int_K l_k = |K|/(d+1) + // int_K l_k l_j = |K|(1+delta_kj) /((d+1)((d+2)) + // if (val.N( ) < 12) { throwassert(val.N( ) >= 12); @@ -214,8 +208,7 @@ namespace Fem2D { val = 0; RN_ f0(val('.', 0, op_id)); - int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; //no need to swap 2, 5, 8 since symmetric - + int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // no need to swap 2, 5, 8 since symmetric if (oe[0] < 0) { swap(p[0], p[1]); @@ -229,7 +222,7 @@ namespace Fem2D { swap(p[6], p[7]); } - //No need to swap elemet 2, 5 and 8 since they are symmetric = do not depends on edge orientation + // No need to swap elemet 2, 5 and 8 since they are symmetric = do not depends on edge orientation if (whatd[op_id]) { for (int i = 0; i < 12; ++i) { @@ -241,22 +234,19 @@ namespace Fem2D { if (whatd[op_dx] || whatd[op_dy]) { R2 D0 = K.H(0), D1 = K.H(1), D2 = K.H(2); - R2 Dbk = (l1 - l2) * (l2 - l0) * (D0 - D1) - + (l0 - l1) * (l2 - l0) * (D1 - D2) - + (l0 - l1) * (l1 - l2) * (D2 - D0); - R2 D12[] = { - D0 * (l0 * l0*3.), - D1 * (l1 * l1*3.), - D2 * (l2 * l2*3.), - D0 * (l0 * l1 *2.) + D1 * (l0 * l0), - D0 * (l0 * l2 *2.) + D2 * (l0 * l0), - D1 * (l1 * l0 *2.) + D0 * (l1 * l1), - D1 * (l1 * l2 *2.) + D2 * (l1 * l1), - D2 * (l2 * l0 *2.) + D0 * (l2 * l2), - D2 * (l2 * l1 *2.) + D1 * (l2 * l2), - D0 * (l1 * l2) + D1* (l0 * l2) + D2* (l0 * l1) , - Dbk*l0 + D0 *bk, Dbk*l1 + D1 *bk - }; + R2 Dbk = (l1 - l2) * (l2 - l0) * (D0 - D1) + (l0 - l1) * (l2 - l0) * (D1 - D2) + (l0 - l1) * (l1 - l2) * (D2 - D0); + R2 D12[] = {D0 * (l0 * l0 * 3.), + D1 * (l1 * l1 * 3.), + D2 * (l2 * l2 * 3.), + D0 * (l0 * l1 * 2.) + D1 * (l0 * l0), + D0 * (l0 * l2 * 2.) + D2 * (l0 * l0), + D1 * (l1 * l0 * 2.) + D0 * (l1 * l1), + D1 * (l1 * l2 * 2.) + D2 * (l1 * l1), + D2 * (l2 * l0 * 2.) + D0 * (l2 * l2), + D2 * (l2 * l1 * 2.) + D1 * (l2 * l2), + D0 * (l1 * l2) + D1 * (l0 * l2) + D2 * (l0 * l1), + Dbk * l0 + D0 * bk, + Dbk * l1 + D1 * bk}; if (whatd[op_dx]) { RN_ f0x(val('.', 0, op_dx)); diff --git a/plugin/seq/Element_P3pnc_3d.cpp b/plugin/seq/Element_P3pnc_3d.cpp index 82d67f7fe..ba14939f7 100644 --- a/plugin/seq/Element_P3pnc_3d.cpp +++ b/plugin/seq/Element_P3pnc_3d.cpp @@ -39,360 +39,343 @@ namespace Fem2D { class TypeOfFE_P3pnc_3d : public GTypeOfFE< Mesh3 > { public: - typedef Mesh3 Mesh; - typedef Mesh3::Element Element; - typedef GFElement< Mesh3 > FElement; - static int dfon[]; - static const int d = Mesh::Rd::d; - static const GQuadratureFormular< R2 > &QFf; // quadrature formula on a face - static const GQuadratureFormular< R3 > &QFt; // quadrature formula on a face - TypeOfFE_P3pnc_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; - }; -int TypeOfFE_P3pnc_3d::dfon[] = {0, 0, 6, 4}; //0 dof on node, 0 on edge, 6 on face, 4 on element// - -const GQuadratureFormular< R2 > &TypeOfFE_P3pnc_3d::QFf= QuadratureFormular_T_7 ; -const GQuadratureFormular< R3 > &TypeOfFE_P3pnc_3d::QFt= QuadratureFormular_Tet_5 ; - -TypeOfFE_P3pnc_3d::TypeOfFE_P3pnc_3d( ) -: GTypeOfFE< Mesh3 >(TypeOfFE_P3pnc_3d::dfon, 1, 3, - 4 * QFf.n * 6 + 4 * QFt.n,// N coef InterPP - 4 * QFf.n + 1 * QFt.n,// N Pt Inter - false, true) { - static R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices - static const int nvfo[4][3] ={{1,2,3}, {0,2,3},{0,1,3},{ 0,1,2}}; - int ipt=0; - int doft0 = 4*6; // nb dof on face + typedef Mesh3 Mesh; + typedef Mesh3::Element Element; + typedef GFElement< Mesh3 > FElement; + static int dfon[]; + static const int d = Mesh::Rd::d; + static const GQuadratureFormular< R2 > &QFf; // quadrature formula on a face + static const GQuadratureFormular< R3 > &QFt; // quadrature formula on a face + TypeOfFE_P3pnc_3d( ); // constructor + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + int TypeOfFE_P3pnc_3d::dfon[] = {0, 0, 6, 4}; // 0 dof on node, 0 on edge, 6 on face, 4 on element// + + const GQuadratureFormular< R2 > &TypeOfFE_P3pnc_3d::QFf = QuadratureFormular_T_7; + const GQuadratureFormular< R3 > &TypeOfFE_P3pnc_3d::QFt = QuadratureFormular_Tet_5; + + TypeOfFE_P3pnc_3d::TypeOfFE_P3pnc_3d( ) + : GTypeOfFE< Mesh3 >(TypeOfFE_P3pnc_3d::dfon, 1, 3, + 4 * QFf.n * 6 + 4 * QFt.n, // N coef InterPP + 4 * QFf.n + 1 * QFt.n, // N Pt Inter + false, true) { + static R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + static const int nvfo[4][3] = {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}; + int ipt = 0; + int doft0 = 4 * 6; // nb dof on face // construction de point d'interpolation sur les face for (int f = 0; f < Element::nf; ++f) { - for (int q = 0; q < QFf.n; ++q, ++ipt) { - double x = QFf[q].x; - double y = QFf[q].y; - this->PtInterpolation[ipt] = Pt[nvfo[f][0]] * (1. - x - y) + Pt[nvfo[f][1]] * x + Pt[nvfo[f][2]] * y; - }} - - for (int q = 0; q < QFt.n; ++q, ++ipt) - this->PtInterpolation[ipt] = QFt[q]; - - ffassert(ipt == this->NbPtforInterpolation); // verif - if(verbosity>99) - for( int i=0; i< ipt;++i) - cout << i << " P/i " << this->PtInterpolation[i] << endl; - { - int i =0,ipt=0; // + for (int q = 0; q < QFf.n; ++q, ++ipt) { + double x = QFf[q].x; + double y = QFf[q].y; + this->PtInterpolation[ipt] = Pt[nvfo[f][0]] * (1. - x - y) + Pt[nvfo[f][1]] * x + Pt[nvfo[f][2]] * y; + } + } + for (int q = 0; q < QFt.n; ++q, ++ipt) this->PtInterpolation[ipt] = QFt[q]; - // coef d'interpolation ... sur les face ... - // int li*f - for (int f = 0; f < Element::nf; ++f) //loop on the 4 faces - for (int qq = 0; qq < QFf.n; qq++,++ipt) + ffassert(ipt == this->NbPtforInterpolation); // verif + if (verbosity > 99) + for (int i = 0; i < ipt; ++i) cout << i << " P/i " << this->PtInterpolation[i] << endl; + { + int i = 0, ipt = 0; // + + // coef d'interpolation ... sur les face ... + // int li*f + for (int f = 0; f < Element::nf; ++f) // loop on the 4 faces + for (int qq = 0; qq < QFf.n; qq++, ++ipt) { + double ll[4]; // dans Khat + this->PtInterpolation[ipt].toBary(ll); + + for (int kf = 0; kf < 3; ++kf, i++) { + int kfK = nvfo[f][kf]; // vertex dans K .. + int dof = 6 * f + kf; { - double ll[4]; // dans Khat - this->PtInterpolation[ipt].toBary(ll); - - for (int kf = 0; kf < 3; ++kf,i++) - { - int kfK = nvfo[f][kf];// vertex dans K .. - int dof = 6*f+kf; - { - this->pInterpolation[i] = ipt; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = dof; // ik in (13.1) - this->coefInterpolation[i] = QFf[qq].a*ll[kfK]; - } - } - - for (int kf = 0; kf < 3; ++kf,i++) - { //edge next of vertex .. kf. pas terrible pour la numerotation !!! - int kfK = nvfo[f][(kf+2)%3];// vertex dans K opose a kf - int kfK1 = nvfo[f][(kf+1)%3];// vertex dans K .. - int dof = 6*f+kf+3; - { - this->pInterpolation[i] = ipt; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = dof; // ik in (13.1) - this->coefInterpolation[i] = QFf[qq].a*ll[kfK]*ll[kfK1]; - } - } - - } // end loop on face - for (int q = 0; q < QFt.n; ++q,ipt++) //loop on quadrature point on element - { double ll[4]; // dans Khat - this->PtInterpolation[ipt].toBary(ll); - for (int kt = 0; kt < 4; ++kt,i++) //loop on the 4 dof in the element - { - this->pInterpolation[i] = ipt; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = doft0+kt; // ik in (13.1) - this->coefInterpolation[i] = QFt[q].a*ll[kt]; // alfak: we will fill them with 'set' (below) + this->pInterpolation[i] = ipt; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = dof; // ik in (13.1) + this->coefInterpolation[i] = QFf[qq].a * ll[kfK]; + } } + + for (int kf = 0; kf < 3; ++kf, i++) { // edge next of vertex .. kf. pas terrible pour la numerotation !!! + int kfK = nvfo[f][(kf + 2) % 3]; // vertex dans K opose a kf + int kfK1 = nvfo[f][(kf + 1) % 3]; // vertex dans K .. + int dof = 6 * f + kf + 3; + { + this->pInterpolation[i] = ipt; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = dof; // ik in (13.1) + this->coefInterpolation[i] = QFf[qq].a * ll[kfK] * ll[kfK1]; + } + } + + } // end loop on face + for (int q = 0; q < QFt.n; ++q, ipt++) // loop on quadrature point on element + { + double ll[4]; // dans Khat + this->PtInterpolation[ipt].toBary(ll); + for (int kt = 0; kt < 4; ++kt, i++) // loop on the 4 dof in the element + { + this->pInterpolation[i] = ipt; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = doft0 + kt; // ik in (13.1) + this->coefInterpolation[i] = QFt[q].a * ll[kt]; // alfak: we will fill them with 'set' (below) } - ffassert(i==this->NbcoefforInterpolation); - -} -} - -void Setp3(int *p,int n) { -// n = signe + depart*2 - int i=n/2, j= n%2, k = 3-i; - if( i==0){ if(j==1) swap(p[1],p[2]); } - else { - swap(p[0],p[i]); - int k =3 -i;// autre - if(j==0) swap(p[i],p[k]); - } -} -void TypeOfFE_P3pnc_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { - static int count =0;count++; + } + ffassert(i == this->NbcoefforInterpolation); + } + } + + void Setp3(int *p, int n) { + // n = signe + depart*2 + int i = n / 2, j = n % 2, k = 3 - i; + if (i == 0) { + if (j == 1) swap(p[1], p[2]); + } else { + swap(p[0], p[i]); + int k = 3 - i; // autre + if (j == 0) swap(p[i], p[k]); + } + } + void TypeOfFE_P3pnc_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { + static int count = 0; + count++; int k = Th(K); - int verb = verbosity>99 || (verbosity>9 && count < 4 ) ;//|| ocoef+odf || nump ; + int verb = verbosity > 99 || (verbosity > 9 && count < 4); //|| ocoef+odf || nump ; int n = this->NbDoF; - int np=M.np; - int ncoef=M.ncoef; - //int *p = M.p+odf;// correction FH mai 2020 ... - // update the coef to be ajdacent compatible + int np = M.np; + int ncoef = M.ncoef; + // int *p = M.p+odf;// correction FH mai 2020 ... + // update the coef to be ajdacent compatible // - int i =ocoef; // + int i = ocoef; // - // cout << " set " << Th(K) << endl; + // cout << " set " << Th(K) << endl; // coef d'interpolation ... sur les face ... // int li*f - int ip=0; - for (int f = 0; f < Element::nf; ++f) - { - int fp = K.facePermutation(f);// orientation de la face .. - int p3[3]={0,1,2}; - SetNumPerm<3>(fp,p3); - if(verb ) cout << " set: " << f << " " << p3[0] << " "<< p3[1] << " " << p3[2] - << " ::: " << Th(k,Element::nvface[f][p3[0]]) << " " << Th(k,Element::nvface[f][p3[1]]) << " " << Th(k,Element::nvface[f][p3[2]]) << " " << endl; - for (int qq = 0; qq < QFf.n; qq++,ip++) - { - - int ipt = nump ? nump[ip] : ip; - ffassert(ipt<=np); - //cout << ip << " -> "<< ipt << " f= " << f <<" " << qq << " i "<< i << " " << this->pInterpolation[i] - //<< "ipt: " << this->PtInterpolation[ipt] << " ::ip "<< this->PtInterpolation[ip] <pInterpolation[i]) ; ce ne marche pas !!!!!! mais le point sont les memem - double ll[4]; // dans Khat - M.P[ipt].toBary(ll);// point sur la face f ???? - if(verb) cout << " P " << M.P[ipt] << " " << i << endl; - for (int kf = 0; kf < 3; ++kf,i++) - { - if(verb) cout << i << " " <pInterpolation[i]); - ffassert(abs(ll[f])<1e-10); - int kfK = Element::nvface[f][p3[kf]];// vertex dans K .. - M.coef[i] = QFf[qq].a*ll[kfK]; - } - //func p2 on face - for (int kf = 0; kf < 3; ++kf,i++){ - int kfK = Element::nvface[f][p3[(kf+2)%3]];// vertex dans K .. - int kfK1 = Element::nvface[f][p3[(kf+1)%3]];// vertex dans K .. - M.coef[i] = QFf[qq].a*ll[kfK]*ll[kfK1]; - } + int ip = 0; + for (int f = 0; f < Element::nf; ++f) { + int fp = K.facePermutation(f); // orientation de la face .. + int p3[3] = {0, 1, 2}; + SetNumPerm< 3 >(fp, p3); + if (verb) + cout << " set: " << f << " " << p3[0] << " " << p3[1] << " " << p3[2] << " ::: " << Th(k, Element::nvface[f][p3[0]]) << " " << Th(k, Element::nvface[f][p3[1]]) << " " + << Th(k, Element::nvface[f][p3[2]]) << " " << endl; + for (int qq = 0; qq < QFf.n; qq++, ip++) { + + int ipt = nump ? nump[ip] : ip; + ffassert(ipt <= np); + // cout << ip << " -> "<< ipt << " f= " << f <<" " << qq << " i "<< i << " " << this->pInterpolation[i] + //<< "ipt: " << this->PtInterpolation[ipt] << " ::ip "<< this->PtInterpolation[ip] <pInterpolation[i]) ; ce ne marche pas !!!!!! mais le point sont les memem + double ll[4]; // dans Khat + M.P[ipt].toBary(ll); // point sur la face f ???? + if (verb) cout << " P " << M.P[ipt] << " " << i << endl; + for (int kf = 0; kf < 3; ++kf, i++) { + if (verb) cout << i << " " << f << kf << " " << ipt << " " << ll[f] << " " << M.p[i] << " // " << ocoef << " " << odf << " " << nump << endl; + // ffassert(ipt == this->pInterpolation[i]); + ffassert(abs(ll[f]) < 1e-10); + int kfK = Element::nvface[f][p3[kf]]; // vertex dans K .. + M.coef[i] = QFf[qq].a * ll[kfK]; + } + // func p2 on face + for (int kf = 0; kf < 3; ++kf, i++) { + int kfK = Element::nvface[f][p3[(kf + 2) % 3]]; // vertex dans K .. + int kfK1 = Element::nvface[f][p3[(kf + 1) % 3]]; // vertex dans K .. + M.coef[i] = QFf[qq].a * ll[kfK] * ll[kfK1]; + } - } //end loop en quadrature - } //end loop on the four faces + } // end loop en quadrature + } // end loop on the four faces - double ll[4]; // dans Khat + double ll[4]; // dans Khat - for (int q = 0; q < QFt.n; ++q, ++ip) - { int ipt = nump ? nump[ip] : ip;// Correct aug 2023 FH. - double ll[4]; // dans Khat - M.P[ipt].toBary(ll);// - M.coef[i++] = QFt[q].a*ll[0]; - M.coef[i++] = QFt[q].a*ll[1]; - M.coef[i++] = QFt[q].a*ll[2]; - M.coef[i++] = QFt[q].a*ll[3]; // alfak: we will fill them with 'set' (below) + for (int q = 0; q < QFt.n; ++q, ++ip) { + int ipt = nump ? nump[ip] : ip; // Correct aug 2023 FH. + double ll[4]; // dans Khat + M.P[ipt].toBary(ll); // + M.coef[i++] = QFt[q].a * ll[0]; + M.coef[i++] = QFt[q].a * ll[1]; + M.coef[i++] = QFt[q].a * ll[2]; + M.coef[i++] = QFt[q].a * ll[3]; // alfak: we will fill them with 'set' (below) } - // ffassert(i== ncoef+ocoef); - //if(verbosity>1000) cout << " M = @@@@ \n"<< M << endl; - -} -void TypeOfFE_P3pnc_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + // ffassert(i== ncoef+ocoef); + // if(verbosity>1000) cout << " M = @@@@ \n"<< M << endl; + } + void TypeOfFE_P3pnc_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 28); // 28 degrees of freedom assert(val.M( ) == 1); // 1 components -/* - Dof Numbering 3 dof / face the dof a associated to a vertex face - and the vertex a numbering in increase way. - - we have to numbering î on ref element with - - So we need of a permutation p to insure the compatibilit between adjacent element - - */ + /* + Dof Numbering 3 dof / face the dof a associated to a vertex face + and the vertex a numbering in increase way. + + we have to numbering î on ref element with + + So we need of a permutation p to insure the compatibilit between adjacent element + + */ // generated with file Element_P2pnc_3d.edp // Warning p(^i) =i - // CC(i,j) = dof(j)(mo(i)); // - // phi_k =sum_i C1(k,i) mo_i - - double C1[28][28] = { - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -150, -120, 30, -120, 60, 30, 960, -120, -120, 60, 0, 0, 0, -1680, 0, 0, 0, 0}, - {0, 0, 0, 0, -30, 120, 150, 120, -960, -60, 0, 0, 0, 120, 300, -960, 0, 0, 150, 0, 0, 0, 1680, 0, 0, 0, 0, 1680}, - {0, -150, 960, 60, 0, -120, -120, 0, 30, 0, 0, -120, -120, 0, 60, 0, 0, 30, 0, 0, 0, 0, 0, 0, -1680, 0, 0, 0}, - - {-96, 882, -3168, -156, 522, -576, -18, -648, 2862, 204, -2628, 504, 432, -216, -936, 2952, 2592, -378, -738, 84, 0, 0, -5040, -3360, 5040, 3360, 0, -5040}, - {144, 2562, -3408, -156, -708, 504, 672, 672, -2058, -156, 2562, -336, 342, 504, 264, -2058, -3408, 342, 672, -156, -3360, 0, 3360, 5040, 5040, -3360, 0, 3360}, - {-96, -2628, 2592, 84, 522, -216, -738, -648, 2952, 204, 882, 504, -378, -576, -936, 2862, -3168, 432, -18, -156, 3360, 0, -5040, 5040, -3360, 0, 0, -5040}, - - {60, 960, -150, 0, -120, -120, 0, 30, 0, 0, -120, -120, 0, 60, 0, 0, 30, 0, 0, 0, -1680, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 30, -120, -150, -120, 960, 60, 0, 0, 0, 60, -120, -120, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, -1680}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 120, -30, 300, 120, 150, -960, 120, -960, -60, 0, 0, 0, 1680, 0, 0, 1680, 0}, - - {84, 2592, -2628, -96, -378, 504, 882, 432, -3168, -156, -738, -216, 522, -936, -576, -18, 2952, -648, 2862, 204, -3360, 0, 0, -5040, 3360, 0, -5040, 5040}, - {-156, -3168, 882, -96, 432, 504, -2628, -378, 2592, 84, -18, -576, 522, -936, -216, -738, 2862, -648, 2952, 204, 5040, 3360, 0, -5040, 0, 0, -5040, -3360}, - {-156, -3408, 2562, 144, 342, -336, 2562, 342, -3408, -156, 672, 504, -708, 264, 504, 672, -2058, 672, -2058, -156, 5040, -3360, 0, 3360, -3360, 0, 3360, 5040}, - - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 60, 30, -120, -120, -150, -120, -120, 960, 60, 0, 0, 0, 0, 0, 0, -1680, 0}, - {0, 30, -120, 60, 0, -120, 960, 0, -150, 0, 0, 60, -120, 0, -120, 0, 0, 30, 0, 0, 0, -1680, 0, 0, 0, 0, 0, 0}, - {-60, -960, 150, 0, 120, 120, 0, -30, 0, 0, -960, 300, 0, 120, 0, 0, 150, 0, 0, 0, 1680, 0, 0, 0, 0, 1680, 0, 0}, - - {204, 2862, -18, -156, -648, -576, -3168, 522, 882, -96, 2952, -936, 432, -216, 504, -2628, -738, -378, 2592, 84, -5040, 5040, 3360, 0, 0, -5040, -3360, 0}, - {204, 2952, -738, 84, -648, -216, 2592, 522, -2628, -96, 2862, -936, -378, -576, 504, 882, -18, 432, -3168, -156, -5040, -3360, 0, 0, 0, -5040, 5040, 3360}, - {-156, -2058, 672, -156, 672, 504, -3408, -708, 2562, 144, -2058, 264, 342, 504, -336, 2562, 672, 342, -3408, -156, 3360, 5040, -3360, 0, 0, 3360, 5040, -3360}, - - {60, -120, 30, 0, -120, 60, 0, 30, 0, 0, 960, -120, 0, -120, 0, 0, -150, 0, 0, 0, 0, 0, 0, 0, 0, -1680, 0, 0}, - {0, 150, -960, -60, 0, 300, -960, 0, 150, 0, 0, 120, 120, 0, 120, 0, 0, -30, 0, 0, 0, 1680, 0, 0, 1680, 0, 0, 0}, - {0, 0, 0, 0, 30, 60, 30, -120, -120, 60, 0, 0, 0, -120, -120, 960, 0, 0, -150, 0, 0, 0, -1680, 0, 0, 0, 0, 0}, - - {84, -738, 2952, 204, -378, -936, 2862, 432, -18, -156, 2592, -216, -648, 504, -576, -3168, -2628, 522, 882, -96, 0, -5040, 5040, 3360, -5040, -3360, 0, 0}, - {-156, 672, -2058, -156, 342, 264, -2058, 342, 672, -156, -3408, 504, 672, -336, 504, -3408, 2562, -708, 2562, 144, 0, 3360, 5040, -3360, 3360, 5040, -3360, 0}, - {-156, -18, 2862, 204, 432, -936, 2952, -378, -738, 84, -3168, -576, -648, 504, -216, 2592, 882, 522, -2628, -96, 0, -5040, -3360, 0, -5040, 5040, 3360, 0}, - - {-48, 316, -904, -8, 236, 192, -44, -344, 596, 72, 316, 352, 36, 192, -448, 596, -904, 36, -44, -8, 0, 0, -1120, 1120, 1120, 0, 0, -1120}, - {-8, -904, 316, -48, 36, 352, 316, 36, -904, -8, -44, 192, 236, -448, 192, -44, 596, -344, 596, 72, 1120, 0, 0, -1120, 0, 0, -1120, 1120}, - {72, 596, -44, -8, -344, 192, -904, 236, 316, -48, 596, -448, 36, 192, 352, 316, -44, 36, -904, -8, -1120, 1120, 0, 0, 0, -1120, 1120, 0}, - - {-8, -44, 596, 72, 36, -448, 596, 36, -44, -8, -904, 192, -344, 352, 192, -904, 316, 236, 316, -48, 0, -1120, 1120, 0, -1120, 1120, 0, 0}}; - - - - int pp[28]={0,1,2,3,4,5,6,7,8,9,10,11,12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; // Permutaion de dof - int p[28]; // Permutaion de dof - for(int k=24;k<28;++k) // internal dof !!! - p[k]=pp[k]; - static int ccount =0; ccount++; - int verb = (ccount < 2 && verbosity>9 ) || ( verbosity>99); - for (int ff = 0,k=0; ff < Element::nf; ff++, k+=6 ) {// face dof .. - // orientation de la face a envert - int fp = K.facePermutation(ff); - int p3[3]={0,1,2}; - SetNumPerm<3>(fp,p3); - if( verb) - { - int i3[3]={Th(K[Element::nvface[ff][p3[0]]]),Th(K[Element::nvface[ff][p3[1]]]),Th(K[Element::nvface[ff][p3[2]]])}; - cout << "k " << k <<" " << ff << " / "<< p3[0] << " "<< p3[1] << " "<< p3[2] - << " / " << i3[0] << " " << i3[1] << " " << i3[2] - // << " / " << Element::nvface[ff][p3[0]]<< " " < 9) || (verbosity > 99); + for (int ff = 0, k = 0; ff < Element::nf; ff++, k += 6) { // face dof .. + // orientation de la face a envert + int fp = K.facePermutation(ff); + int p3[3] = {0, 1, 2}; + SetNumPerm< 3 >(fp, p3); + if (verb) { + int i3[3] = {Th(K[Element::nvface[ff][p3[0]]]), Th(K[Element::nvface[ff][p3[1]]]), Th(K[Element::nvface[ff][p3[2]]])}; + cout << "k " << k << " " << ff << " / " << p3[0] << " " << p3[1] << " " << p3[2] << " / " << i3[0] << " " << i3[1] << " " + << i3[2] + // << " / " << Element::nvface[ff][p3[0]]<< " " < p1(28); + KN< int > p1(28); p1 = -1; - for( int i=0; i< 28;++i) - p1[p[i]]=1; - ffassert(p1.min()>=0); - double l[4],mo[28]; + for (int i = 0; i < 28; ++i) p1[p[i]] = 1; + ffassert(p1.min( ) >= 0); + double l[4], mo[28]; PHat.toBary(l); - {// construction des monone - int k=0; - for(int i=0;i<4;i++){ - for(int j=0;j &Elm_P3pnc_3d(P3pnc_3d); -} - static TypeOfFE_P3pnc_3d P3pnc_3d; - GTypeOfFE< Mesh3 > &Elm_P3pnc_3d(P3pnc_3d); - - static AddNewFE3 TFE_P3pnc_3d("P3pnc3d", &Elm_P3pnc_3d); + static AddNewFE3 TFE_P3pnc_3d("P3pnc3d", &Elm_P3pnc_3d); } // namespace Fem2D diff --git a/plugin/seq/Element_P4.cpp b/plugin/seq/Element_P4.cpp index 715ed25a9..c882ff9be 100644 --- a/plugin/seq/Element_P4.cpp +++ b/plugin/seq/Element_P4.cpp @@ -50,11 +50,8 @@ namespace Fem2D { static const int kl[15]; TypeOfFE_P4Lagrange( ) : TypeOfFE(3 + 3 * 3 + 3, 1, Data, 4, 1, 15 + 6, 15, 0) { - static const R2 Pt[15] = {R2(0 / 4., 0 / 4.), R2(4 / 4., 0 / 4.), R2(0 / 4., 4 / 4.), - R2(3 / 4., 1 / 4.), R2(2 / 4., 2 / 4.), R2(1 / 4., 3 / 4.), - R2(0 / 4., 3 / 4.), R2(0 / 4., 2 / 4.), R2(0 / 4., 1 / 4.), - R2(1 / 4., 0 / 4.), R2(2 / 4., 0 / 4.), R2(3 / 4., 0 / 4.), - R2(1 / 4., 2 / 4.), R2(2 / 4., 1 / 4.), R2(1 / 4., 1 / 4.)}; + static const R2 Pt[15] = {R2(0 / 4., 0 / 4.), R2(4 / 4., 0 / 4.), R2(0 / 4., 4 / 4.), R2(3 / 4., 1 / 4.), R2(2 / 4., 2 / 4.), R2(1 / 4., 3 / 4.), R2(0 / 4., 3 / 4.), R2(0 / 4., 2 / 4.), + R2(0 / 4., 1 / 4.), R2(1 / 4., 0 / 4.), R2(2 / 4., 0 / 4.), R2(3 / 4., 0 / 4.), R2(1 / 4., 2 / 4.), R2(2 / 4., 1 / 4.), R2(1 / 4., 1 / 4.)}; // 3,4,5, 6,7,8, 9,10,11, int other[15] = {0, 1, 2, 5, 4, 3, 8, 7, 6, 11, 10, 9, 12, 13, 14}; @@ -73,8 +70,7 @@ namespace Fem2D { assert(pij_alpha.N( ) == kk); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { for (int i = 0; i < 15 + 6; ++i) { v[i] = 1; @@ -95,7 +91,7 @@ namespace Fem2D { * 16,17 */ int iii[6] = {3, 6, 8, 11, 13, 16}; - int jjj[6] = {}; + int jjj[6] = { }; for (int i = 0; i < 6; ++i) { jjj[i] = iii[i] + 1; // si orient = -1 @@ -112,16 +108,14 @@ namespace Fem2D { }; // on what nu df on node node of df - int TypeOfFE_P4Lagrange::Data[] = { - 0, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the support number of the node of the df - 0, 0, 0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, // the number of the df on the node - 0, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated - 0, 15}; - void TypeOfFE_P4Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { + int TypeOfFE_P4Lagrange::Data[] = {0, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the support number of the node of the df + 0, 0, 0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, // the number of the df on the node + 0, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated + 0, 15}; + void TypeOfFE_P4Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1. - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R L[3] = {l0 * k, l1 * k, l2 * k}; @@ -133,7 +127,7 @@ namespace Fem2D { // et la numerotation naturelle mais 2 noud pas arete // donc p est la perumation // echange de numerotation si les arete sont dans le mauvais sens - int p[15] = {}; + int p[15] = { }; for (int i = 0; i < 15; ++i) { p[i] = i; @@ -229,17 +223,15 @@ namespace Fem2D { } } +#include "Element_PkL.hpp" // for Pk_L + static TypeOfFE_Pk_L P4_L(4); + GTypeOfFE< MeshL > &Elm_P4_L(P4_L); -#include "Element_PkL.hpp" // for Pk_L -static TypeOfFE_Pk_L P4_L(4); -GTypeOfFE< MeshL > &Elm_P4_L(P4_L); - - -// Author: F. Hecht , P-H Tournier, Jet Hoe Tang jethoe.tang@googlemail.com -// Jan 2017 -// in tets -class TypeOfFE_P4_3d : public GTypeOfFE< Mesh3 > { -public: + // Author: F. Hecht , P-H Tournier, Jet Hoe Tang jethoe.tang@googlemail.com + // Jan 2017 + // in tets + class TypeOfFE_P4_3d : public GTypeOfFE< Mesh3 > { + public: typedef Mesh3 Mesh; typedef Mesh3::Element Element; typedef GFElement< Mesh3 > FElement; @@ -251,257 +243,149 @@ class TypeOfFE_P4_3d : public GTypeOfFE< Mesh3 > { static int cp[ndof]; static int pp[ndof][4]; static const int d = Mesh::Rd::d; - - TypeOfFE_P4_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; - void OrientDoFOfFace(int odf,const Element &K,int f,int *pp,int inv) const - { - const int doff = odf+22+3*f; // first dof of face f - int np=K.facePermutation(f); - int i=np/2, j= np%2 ? 2:1; - int i0=i,i1=(i+j)%3,i2=(i+j+j)%3; - if( inv) - { - pp[doff+i0] = doff+0; - pp[doff+i1] = doff+1; - pp[doff+i2] = doff+2; - } - else - { - pp[doff+0] = doff+i0; - pp[doff+1] = doff+i1; - pp[doff+2] = doff+i2; - } -/* static int count = 0; - if( count++ < 8) - cout << " OrientDoFOfFace " << np << " " << inv << " f " << " " << f << " ::::" << i0 << i1 << i2 << " : " << pp[doff+0] << " " << pp[doff+1] << " " << pp[doff+2] << endl;*/ + TypeOfFE_P4_3d( ); // constructor + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + void OrientDoFOfFace(int odf, const Element &K, int f, int *pp, int inv) const { + const int doff = odf + 22 + 3 * f; // first dof of face f + int np = K.facePermutation(f); + int i = np / 2, j = np % 2 ? 2 : 1; + int i0 = i, i1 = (i + j) % 3, i2 = (i + j + j) % 3; + if (inv) { + pp[doff + i0] = doff + 0; + pp[doff + i1] = doff + 1; + pp[doff + i2] = doff + 2; + } else { + pp[doff + 0] = doff + i0; + pp[doff + 1] = doff + i1; + pp[doff + 2] = doff + i2; + } + /* static int count = 0; + if( count++ < 8) + cout << " OrientDoFOfFace " << np << " " << inv << " f " << " " << f << " ::::" << i0 << i1 << i2 << " : " << pp[doff+0] << " " << pp[doff+1] << " " << pp[doff+2] << endl;*/ } - -}; - -int TypeOfFE_P4_3d::pp[35][4] = { - {4, 0, 0, 0}, - {0, 4, 0, 0}, - {0, 0, 4, 0}, - {0, 0, 0, 4}, - - {1, 3, 0, 0}, - {2, 2, 0, 0}, - {3, 1, 0, 0}, - - {1, 0, 3, 0}, - {2, 0, 2, 0}, - {3, 0, 1, 0}, - - {1, 0, 0, 3}, - {2, 0, 0, 2}, - {3, 0, 0, 1}, - - {0, 1, 3, 0}, - {0, 2, 2, 0}, - {0, 3, 1, 0}, - - {0, 1, 0, 3}, - {0, 2, 0, 2}, - {0, 3, 0, 1}, - - {0, 0, 1, 3}, - {0, 0, 2, 2}, - {0, 0, 3, 1}, - - {0, 2, 1, 1}, - {0, 1, 2, 1}, - {0, 1, 1, 2}, - - {1, 0, 1, 2}, - {1, 0, 2, 1}, - {2, 0, 1, 1}, - - {2, 1, 0, 1}, - {1, 2, 0, 1}, - {1, 1, 0, 2}, - - {1, 1, 2, 0}, - {1, 2, 1, 0}, - {2, 1, 1, 0}, - - {1, 1, 1, 1}}; - - - -int TypeOfFE_P4_3d::nl[35][4] = { - {0, 0, 0, 0}, - {1, 1, 1, 1}, - {2, 2, 2, 2}, - {3, 3, 3, 3}, - {0, 1, 1, 1}, - {0, 0, 1, 1}, - {0, 0, 0, 1}, - {0, 2, 2, 2}, - {0, 0, 2, 2}, - {0, 0, 0, 2}, - - {0, 3, 3, 3}, - {0, 0, 3, 3}, - {0, 0, 0, 3}, - {1, 2, 2, 2}, - {1, 1, 2, 2}, - {1, 1, 1, 2}, - {1, 3, 3, 3}, - {1, 1, 3, 3}, - {1, 1, 1, 3}, - {2, 3, 3, 3}, - - {2, 2, 3, 3}, - {2, 2, 2, 3}, - {1, 1, 2, 3}, - {1, 2, 2, 3}, - {1, 2, 3, 3}, - {0, 2, 3, 3}, - {0, 2, 2, 3}, - {0, 0, 2, 3}, - {0, 0, 1, 3}, - {0, 1, 1, 3}, - - {0, 1, 3, 3}, - {0, 1, 2, 2}, - {0, 1, 1, 2}, - {0, 0, 1, 2}, - {0, 1, 2, 3}}; - - - -int TypeOfFE_P4_3d::cl[35][4] = { - {0, 1, 2, 3}, - {0, 1, 2, 3}, - {0, 1, 2, 3}, - {0, 1, 2, 3}, - {0, 0, 1, 2}, - {0, 1, 0, 1}, - {0, 1, 2, 0}, - {0, 0, 1, 2}, - {0, 1, 0, 1}, - {0, 1, 2, 0}, - - {0, 0, 1, 2}, - {0, 1, 0, 1}, - {0, 1, 2, 0}, - {0, 0, 1, 2}, - {0, 1, 0, 1}, - {0, 1, 2, 0}, - {0, 0, 1, 2}, - {0, 1, 0, 1}, - {0, 1, 2, 0}, - {0, 0, 1, 2}, - - {0, 1, 0, 1}, - {0, 1, 2, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 0, 1}, - {0, 0, 0, 1}, - {0, 0, 1, 0}, - {0, 1, 0, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - - {0, 0, 0, 1}, - {0, 0, 0, 1}, - {0, 0, 1, 0}, - {0, 1, 0, 0}, - {0, 0, 0, 0}}; - - - -int TypeOfFE_P4_3d::cp[35] = { -24, 24, 24, 24, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}; -int TypeOfFE_P4_3d::dfon[] = {1, 3, 3, 1}; // 2 dofs on each edge, 2 dofs on each face - -TypeOfFE_P4_3d::TypeOfFE_P4_3d( ) : GTypeOfFE< Mesh >(TypeOfFE_P4_3d::dfon, 1, 3, false, false) -{ + }; + + int TypeOfFE_P4_3d::pp[35][4] = {{4, 0, 0, 0}, {0, 4, 0, 0}, {0, 0, 4, 0}, {0, 0, 0, 4}, + + {1, 3, 0, 0}, {2, 2, 0, 0}, {3, 1, 0, 0}, + + {1, 0, 3, 0}, {2, 0, 2, 0}, {3, 0, 1, 0}, + + {1, 0, 0, 3}, {2, 0, 0, 2}, {3, 0, 0, 1}, + + {0, 1, 3, 0}, {0, 2, 2, 0}, {0, 3, 1, 0}, + + {0, 1, 0, 3}, {0, 2, 0, 2}, {0, 3, 0, 1}, + + {0, 0, 1, 3}, {0, 0, 2, 2}, {0, 0, 3, 1}, + + {0, 2, 1, 1}, {0, 1, 2, 1}, {0, 1, 1, 2}, + + {1, 0, 1, 2}, {1, 0, 2, 1}, {2, 0, 1, 1}, + + {2, 1, 0, 1}, {1, 2, 0, 1}, {1, 1, 0, 2}, + + {1, 1, 2, 0}, {1, 2, 1, 0}, {2, 1, 1, 0}, + + {1, 1, 1, 1}}; + + int TypeOfFE_P4_3d::nl[35][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {3, 3, 3, 3}, {0, 1, 1, 1}, {0, 0, 1, 1}, {0, 0, 0, 1}, {0, 2, 2, 2}, {0, 0, 2, 2}, {0, 0, 0, 2}, + + {0, 3, 3, 3}, {0, 0, 3, 3}, {0, 0, 0, 3}, {1, 2, 2, 2}, {1, 1, 2, 2}, {1, 1, 1, 2}, {1, 3, 3, 3}, {1, 1, 3, 3}, {1, 1, 1, 3}, {2, 3, 3, 3}, + + {2, 2, 3, 3}, {2, 2, 2, 3}, {1, 1, 2, 3}, {1, 2, 2, 3}, {1, 2, 3, 3}, {0, 2, 3, 3}, {0, 2, 2, 3}, {0, 0, 2, 3}, {0, 0, 1, 3}, {0, 1, 1, 3}, + + {0, 1, 3, 3}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}, {0, 1, 2, 3}}; + + int TypeOfFE_P4_3d::cl[35][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, + + {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 0, 1, 2}, + + {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, + + {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}}; + + int TypeOfFE_P4_3d::cp[35] = {24, 24, 24, 24, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 6, 4, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}; + int TypeOfFE_P4_3d::dfon[] = {1, 3, 3, 1}; // 2 dofs on each edge, 2 dofs on each face + + TypeOfFE_P4_3d::TypeOfFE_P4_3d( ) : GTypeOfFE< Mesh >(TypeOfFE_P4_3d::dfon, 1, 3, false, false) { typedef Element E; int n = this->NbDoF; bool dd = verbosity > 5; if (dd) { - cout << "\n +++ P4 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + cout << "\n +++ P4 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; } - + R3 *Pt = this->PtInterpolation; // construction of interpolation ppoint - + { - double cc = 1. / 4.; - - for (int i = 0; i < ndof; ++i) { - Pt[i] = R3::KHat[0] * cc * pp[i][0] + R3::KHat[1] * cc * pp[i][1] + - R3::KHat[2] * cc * pp[i][2] + R3::KHat[3] * cc * pp[i][3]; - } - - if (dd) { - cout << this->PtInterpolation << endl; - } + double cc = 1. / 4.; + + for (int i = 0; i < ndof; ++i) { + Pt[i] = R3::KHat[0] * cc * pp[i][0] + R3::KHat[1] * cc * pp[i][1] + R3::KHat[2] * cc * pp[i][2] + R3::KHat[3] * cc * pp[i][3]; + } + + if (dd) { + cout << this->PtInterpolation << endl; + } } - + for (int i = 0; i < n; i++) { - this->pInterpolation[i] = i; - this->cInterpolation[i] = 0; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + this->pInterpolation[i] = i; + this->cInterpolation[i] = 0; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; } -} + } -void TypeOfFE_P4_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_P4_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { // faux nump don la numerotation des p -> local // ne marche que le cas scalaire ??? FH... /* for (int k=0;kNbDoF; int *p = M.p; - + // for (int i = 0; i < n; ++i) { // M.p[i] = i; // } - + if (verbosity > 9) { - cout << " P4 set:" << odf << " : "; + cout << " P4 set:" << odf << " : "; } - - int dof = 4+odf; - + + int dof = 4 + odf; + for (int e = 0; e < 6; ++e) { - int oe = K.EdgeOrientation(e); - int i1=dof; - int i2=dof+2; - //cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; - ffassert( i1>=0 && i2 >=0); - ffassert( i1 0) && (p[i1] > p[i2])) { - swap(p[i1], p[i2]); - } - dof += 3; + int oe = K.EdgeOrientation(e); + int i1 = dof; + int i2 = dof + 2; + // cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; + ffassert(i1 >= 0 && i2 >= 0); + ffassert(i1 < Np && i2 < Np); + + if ((oe < 0) && (p[i1] < p[i2])) { + swap(p[i1], p[i2]); + } else if ((oe > 0) && (p[i1] > p[i2])) { + swap(p[i1], p[i2]); + } + dof += 3; } - for (int f = 0; f < 4; ++f) - OrientDoFOfFace(odf,K,f,p,1); + for (int f = 0; f < 4; ++f) OrientDoFOfFace(odf, K, f, p, 1); if (verbosity > 99) { - cout << " " << M.p << endl; ; + cout << " " << M.p << endl; + ; } - -} + } -void TypeOfFE_P4_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_P4_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 35); // 23 degrees of freedom assert(val.M( ) == 1); // 3 components // int n = this->NbDoF; @@ -516,25 +400,22 @@ void TypeOfFE_P4_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element ld[1] *= 4.; ld[2] *= 4.; ld[3] *= 4.; - + int p[35]; - for(int i=0; i<35;++i) - p[i]=i; - + for (int i = 0; i < 35; ++i) p[i] = i; + { - int dof = 4; - - for (int e = 0; e < 6; ++e) { - int oe = K.EdgeOrientation(e); - if (oe < 0) { - swap(p[dof], p[dof + 2]); - } - - dof += 3; + int dof = 4; + + for (int e = 0; e < 6; ++e) { + int oe = K.EdgeOrientation(e); + if (oe < 0) { + swap(p[dof], p[dof + 2]); } - for (int f = 0; f < 4; ++f) - OrientDoFOfFace(0,K,f,p,0); + dof += 3; + } + for (int f = 0; f < 4; ++f) OrientDoFOfFace(0, K, f, p, 0); } // static int ddd = 100; // ddd++; @@ -543,86 +424,84 @@ void TypeOfFE_P4_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element // if (ddd < 20) { // cout << ld[0] << " " << ld[1] << " " << ld[2] << " " << ld[3] << " ::"; // } - + if (whatd & Fop_D0) { - for (int i = 0; i < 35; ++i) { - R fi = 1. / cp[i]; - - for (int l = 0; l < 4; ++l) { - fi *= ld[nl[i][l]] - cl[i][l]; - } - - // if (ddd < 20) { - // cout << " " << fi; - // } - - f0[p[i]] = fi; + for (int i = 0; i < 35; ++i) { + R fi = 1. / cp[i]; + + for (int l = 0; l < 4; ++l) { + fi *= ld[nl[i][l]] - cl[i][l]; } - - /// if (ddd < 20) { - /// cout << endl; - /// } + + // if (ddd < 20) { + // cout << " " << fi; + // } + + f0[p[i]] = fi; + } + + /// if (ddd < 20) { + /// cout << endl; + /// } } - + if (whatd & (Fop_D1 | Fop_D2)) { - R3 Dld[4], Df[35]; - K.Gradlambda(Dld); - Dld[0] *= 4.; - Dld[1] *= 4.; - Dld[2] *= 4.; - Dld[3] *= 4.; - - for (int i = 0; i < 35; ++i) { - R fi = 1. / cp[i]; - R3 &dfi = Df[p[i]]; - - for (int l = 0; l < 4; ++l) { - double ci = ld[nl[i][l]] - cl[i][l]; - dfi *= ci; - dfi += fi * Dld[nl[i][l]]; - fi *= ci; - } - - RN_ f0x(val('.', 0, op_dx)); - RN_ f0y(val('.', 0, op_dy)); - RN_ f0z(val('.', 0, op_dz)); - if (whatd & Fop_dx) { - for (int i = 0; i < 35; ++i) { - f0x[i] = Df[i].x; - } - } - - if (whatd & Fop_dy) { - for (int i = 0; i < 35; ++i) { - f0y[i] = Df[i].y; - } - } - - if (whatd & Fop_dz) { - for (int i = 0; i < 35; ++i) { - f0z[i] = Df[i].z; - } - } - - ffassert(!(whatd & Fop_D2)); // no D2 to do !!! + R3 Dld[4], Df[35]; + K.Gradlambda(Dld); + Dld[0] *= 4.; + Dld[1] *= 4.; + Dld[2] *= 4.; + Dld[3] *= 4.; + + for (int i = 0; i < 35; ++i) { + R fi = 1. / cp[i]; + R3 &dfi = Df[p[i]]; + + for (int l = 0; l < 4; ++l) { + double ci = ld[nl[i][l]] - cl[i][l]; + dfi *= ci; + dfi += fi * Dld[nl[i][l]]; + fi *= ci; } + + RN_ f0x(val('.', 0, op_dx)); + RN_ f0y(val('.', 0, op_dy)); + RN_ f0z(val('.', 0, op_dz)); + if (whatd & Fop_dx) { + for (int i = 0; i < 35; ++i) { + f0x[i] = Df[i].x; + } + } + + if (whatd & Fop_dy) { + for (int i = 0; i < 35; ++i) { + f0y[i] = Df[i].y; + } + } + + if (whatd & Fop_dz) { + for (int i = 0; i < 35; ++i) { + f0z[i] = Df[i].z; + } + } + + ffassert(!(whatd & Fop_D2)); // no D2 to do !!! + } } -} + } -class TypeOfFE_P4_S : public GTypeOfFE< MeshS > { -public: + class TypeOfFE_P4_S : public GTypeOfFE< MeshS > { + public: typedef MeshS Mesh; typedef MeshS::Element Element; typedef GFElement< MeshS > FElement; typedef Mesh::RdHat RdHat; typedef Mesh::Rd Rd; - - static const int kp = 4; // P4 - static const int ndof = (kp + 2) * (kp + 1) / 2;// 15 - constexpr static int dfon[]= {1, 3, 3, 0}; - - - + + static const int kp = 4; // P4 + static const int ndof = (kp + 2) * (kp + 1) / 2; // 15 + constexpr static int dfon[] = {1, 3, 3, 0}; + static const int d = Rd::d; static const int nn[15][4]; static const int aa[15][4]; @@ -631,94 +510,83 @@ class TypeOfFE_P4_S : public GTypeOfFE< MeshS > { static const int jl[15]; static const int kl[15]; - constexpr static const int dHat = RdHat::d; - + TypeOfFE_P4_S( ); // constructor - void FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const MeshS &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; -}; -TypeOfFE_P4_S::TypeOfFE_P4_S( ) : GTypeOfFE< MeshS >(TypeOfFE_P4_3d::dfon, 1, 3, false, false) -{ - - + void FB(const What_d whatd, const MeshS &Th, const MeshS::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const MeshS &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + TypeOfFE_P4_S::TypeOfFE_P4_S( ) : GTypeOfFE< MeshS >(TypeOfFE_P4_3d::dfon, 1, 3, false, false) { + typedef Element E; int n = this->NbDoF; bool dd = verbosity > 5; if (dd) { - cout << "\n +++ P4 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + cout << "\n +++ P4 : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; } - + RdHat *Pt = this->PtInterpolation; // construction of interpolation ppoint - + { - double cc = 1. / 4.; - - for (int i = 0; i < ndof; ++i) - Pt[i] = RdHat::KHat[0] * cc * il[i]+ RdHat::KHat[1] * cc * jl[i] + RdHat::KHat[2] * cc * kl[i] ; - - - if (dd) { - cout << this->PtInterpolation << endl; - } + double cc = 1. / 4.; + + for (int i = 0; i < ndof; ++i) Pt[i] = RdHat::KHat[0] * cc * il[i] + RdHat::KHat[1] * cc * jl[i] + RdHat::KHat[2] * cc * kl[i]; + + if (dd) { + cout << this->PtInterpolation << endl; + } } - + for (int i = 0; i < n; i++) { - this->pInterpolation[i] = i; - this->cInterpolation[i] = 0; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + this->pInterpolation[i] = i; + this->cInterpolation[i] = 0; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; } -} + } -void TypeOfFE_P4_S::set(const MeshS &Th, const TypeOfFE_P4_S::Element &K, InterpolationMatrix< TypeOfFE_P4_S::RdHat > &M, - int ocoef, int odf, int *nump) const { + void TypeOfFE_P4_S::set(const MeshS &Th, const TypeOfFE_P4_S::Element &K, InterpolationMatrix< TypeOfFE_P4_S::RdHat > &M, int ocoef, int odf, int *nump) const { // faux nump don la numerotation des p -> local // ne marche que le cas scalaire ??? FH... /* for (int k=0;kNbDoF; int *p = M.p; - + if (verbosity > 9) { - cout << " P4_S set:" << odf << " : "; + cout << " P4_S set:" << odf << " : "; } - - int dof = 3+odf; - + + int dof = 3 + odf; + for (int e = 0; e < 3; ++e) { - int oe = K.EdgeOrientation(e); - int i1=dof; - int i2=dof+2; - //cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; - ffassert( i1>=0 && i2 >=0); - ffassert( i1 0) && (p[i1] > p[i2])) { - swap(p[i1], p[i2]); - } - - dof += 3; + int oe = K.EdgeOrientation(e); + int i1 = dof; + int i2 = dof + 2; + // cout << e <<" "<< i1 << " " << i2 << " , " << oe <<" p: " << p[i1] << " " << p[i2] <<" " << Np << endl; + ffassert(i1 >= 0 && i2 >= 0); + ffassert(i1 < Np && i2 < Np); + + if ((oe < 0) && (p[i1] < p[i2])) { + swap(p[i1], p[i2]); + } else if ((oe > 0) && (p[i1] > p[i2])) { + swap(p[i1], p[i2]); + } + + dof += 3; } if (verbosity > 99) { - cout << " " << M.p << endl; ; + cout << " " << M.p << endl; + ; } - -} - -void TypeOfFE_P4_S::FB(const What_d whatd, const TypeOfFE_P4_S::Mesh &Th, const TypeOfFE_P4_S::Element &K, - const TypeOfFE_P4_S::RdHat &PHat, RNMK_ &val) const { - - - + } + + void TypeOfFE_P4_S::FB(const What_d whatd, const TypeOfFE_P4_S::Mesh &Th, const TypeOfFE_P4_S::Element &K, const TypeOfFE_P4_S::RdHat &PHat, RNMK_ &val) const { + assert(val.N( ) >= 15); // 10 degrees of freedom assert(val.M( ) == 1); // 1 components // int n = this->NbDoF; @@ -727,14 +595,13 @@ void TypeOfFE_P4_S::FB(const What_d whatd, const TypeOfFE_P4_S::Mesh &Th, const // number (i.e. perm[0] is the local number of the vertex with the smallest global number, ... // perm[3] is the local number of the vertex with the biggest global number.) // ------------- - const int ndf=15; + const int ndf = 15; R L[3]; PHat.toBary(L); L[0] *= 4.; L[1] *= 4.; L[2] *= 4.; - - + throwassert(val.N( ) >= 15); throwassert(val.M( ) == 1); // Attention il faut renumeroter les fonction de bases @@ -742,146 +609,141 @@ void TypeOfFE_P4_S::FB(const What_d whatd, const TypeOfFE_P4_S::Mesh &Th, const // et la numerotation naturelle mais 2 noud pas arete // donc p est la perumation // echange de numerotation si les arete sont dans le mauvais sens - int p[15] = {}; - + int p[15] = { }; + for (int i = 0; i < 15; ++i) { - p[i] = i; + p[i] = i; } - + if (K.EdgeOrientation(0) < 0) { - Exchange(p[3], p[5]); // 3,5 + Exchange(p[3], p[5]); // 3,5 } - + if (K.EdgeOrientation(1) < 0) { - Exchange(p[6], p[8]); // 6,8 + Exchange(p[6], p[8]); // 6,8 } - + if (K.EdgeOrientation(2) < 0) { - Exchange(p[9], p[11]); // 9,11 + Exchange(p[9], p[11]); // 9,11 } - + val = 0; - + if (whatd & Fop_D0) { - RN_ f0(val('.', 0, op_id)); - - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R f = 1. / ff[df]; - - for (int i = 0; i < kp; ++i) { - f *= L[nn[df][i]] - aa[df][i]; - } - - f0[pdf] = f; + RN_ f0(val('.', 0, op_id)); + + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R f = 1. / ff[df]; + + for (int i = 0; i < kp; ++i) { + f *= L[nn[df][i]] - aa[df][i]; } + + f0[pdf] = f; + } } - - if(whatd & (Fop_D1|Fop_D2)) - { - - R3 D[3] ; - K.Gradlambda(D); - D[0]*= kp; - D[1]*= kp; - D[2]*= kp; - if (whatd & (Fop_D1|Fop_D2)) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0.,fz = 0., f = 1. / ff[df]; - - for (int i = 0; i < kp; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - fz = fz * Ln + f * D[n].z; - f = f * Ln; - } - - if (whatd & Fop_dx) { - val(pdf, 0, op_dx) = fx; - } - - if (whatd & Fop_dy) { - val(pdf, 0, op_dy) = fy; - } - if (whatd & Fop_dz) { - val(pdf, 0, op_dz) = fz; - } - } - } - - if (whatd &Fop_D2) { - for (int df = 0; df < ndf; df++) { - int pdf = p[df]; - R fx = 0., fy = 0.,fz=0., f = 1. / ff[df]; - R fxx = 0., fyy = 0., fzz=0., fxy = 0., fxz = 0., fyz = 0. ; - - for (int i = 0; i < kp; ++i) { - int n = nn[df][i]; - R Ln = L[n] - aa[df][i]; - fxx = fxx * Ln + 2. * fx * D[n].x; - fyy = fyy * Ln + 2. * fy * D[n].y; - fzz = fzz * Ln + 2. * fz * D[n].z; - fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; - fxz = fxz * Ln + fx * D[n].z + fz * D[n].x; - fyz = fyz * Ln + fy * D[n].z + fz * D[n].y; - fx = fx * Ln + f * D[n].x; - fy = fy * Ln + f * D[n].y; - fz = fz * Ln + f * D[n].z; - f = f * Ln; - } - - if (whatd & Fop_dxx) { - val(pdf, 0, op_dxx) = fxx; - } - - if (whatd & Fop_dyy) { - val(pdf, 0, op_dyy) = fyy; - } - if (whatd & Fop_dzz) { - val(pdf, 0, op_dzz) = fzz; - } - - if (whatd & Fop_dxy) { - val(pdf, 0, op_dxy) = fxy; - } - if (whatd & Fop_dxz) { - val(pdf, 0, op_dxz) = fxz; - } - if (whatd & Fop_dyz) { - val(pdf, 0, op_dyz) = fyz; - } - } + + if (whatd & (Fop_D1 | Fop_D2)) { + + R3 D[3]; + K.Gradlambda(D); + D[0] *= kp; + D[1] *= kp; + D[2] *= kp; + if (whatd & (Fop_D1 | Fop_D2)) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., fz = 0., f = 1. / ff[df]; + + for (int i = 0; i < kp; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + fz = fz * Ln + f * D[n].z; + f = f * Ln; + } + + if (whatd & Fop_dx) { + val(pdf, 0, op_dx) = fx; + } + + if (whatd & Fop_dy) { + val(pdf, 0, op_dy) = fy; + } + if (whatd & Fop_dz) { + val(pdf, 0, op_dz) = fz; + } } - } -} -#include "Element_P4.hpp" + } + if (whatd & Fop_D2) { + for (int df = 0; df < ndf; df++) { + int pdf = p[df]; + R fx = 0., fy = 0., fz = 0., f = 1. / ff[df]; + R fxx = 0., fyy = 0., fzz = 0., fxy = 0., fxz = 0., fyz = 0.; -// link with FreeFem++ -static TypeOfFE_P4Lagrange P4LagrangeP4; -// a static variable to add the finite element to freefem++ -// static AddNewFE P4Lagrange("P4", &P4LagrangeP4); -static TypeOfFE_P4_3d P4_3d; -static TypeOfFE_P4_S P4_S; + for (int i = 0; i < kp; ++i) { + int n = nn[df][i]; + R Ln = L[n] - aa[df][i]; + fxx = fxx * Ln + 2. * fx * D[n].x; + fyy = fyy * Ln + 2. * fy * D[n].y; + fzz = fzz * Ln + 2. * fz * D[n].z; + fxy = fxy * Ln + fx * D[n].y + fy * D[n].x; + fxz = fxz * Ln + fx * D[n].z + fz * D[n].x; + fyz = fyz * Ln + fy * D[n].z + fz * D[n].y; + fx = fx * Ln + f * D[n].x; + fy = fy * Ln + f * D[n].y; + fz = fz * Ln + f * D[n].z; + f = f * Ln; + } -GTypeOfFE< Mesh3 > &Elm_P4_3d(P4_3d); -GTypeOfFE< MeshS > &Elm_P4_S(P4_S); + if (whatd & Fop_dxx) { + val(pdf, 0, op_dxx) = fxx; + } + if (whatd & Fop_dyy) { + val(pdf, 0, op_dyy) = fyy; + } + if (whatd & Fop_dzz) { + val(pdf, 0, op_dzz) = fzz; + } + if (whatd & Fop_dxy) { + val(pdf, 0, op_dxy) = fxy; + } + if (whatd & Fop_dxz) { + val(pdf, 0, op_dxz) = fxz; + } + if (whatd & Fop_dyz) { + val(pdf, 0, op_dyz) = fyz; + } + } + } + } + } +#include "Element_P4.hpp" + + // link with FreeFem++ + static TypeOfFE_P4Lagrange P4LagrangeP4; + // a static variable to add the finite element to freefem++ + // static AddNewFE P4Lagrange("P4", &P4LagrangeP4); + static TypeOfFE_P4_3d P4_3d; + static TypeOfFE_P4_S P4_S; -static void init( ) { - if(verbosity && mpirank ==0 ) - cout << " load : P4 "; - AddNewFE("P4", &P4LagrangeP4); - static ListOfTFE FE_P4("P4", &P4LagrangeP4); // to add P4 in list of Common FE + GTypeOfFE< Mesh3 > &Elm_P4_3d(P4_3d); + GTypeOfFE< MeshS > &Elm_P4_S(P4_S); - AddNewFE3("P43d", &Elm_P4_3d,"P4"); - AddNewFES("P4S", &Elm_P4_S,"P4"); - AddNewFEL("P4L", &Elm_P4_L,"P4"); -} + static void init( ) { + if (verbosity && mpirank == 0) cout << " load : P4 "; + AddNewFE("P4", &P4LagrangeP4); + static ListOfTFE FE_P4("P4", &P4LagrangeP4); // to add P4 in list of Common FE + + AddNewFE3("P43d", &Elm_P4_3d, "P4"); + AddNewFES("P4S", &Elm_P4_S, "P4"); + AddNewFEL("P4L", &Elm_P4_L, "P4"); + } } // namespace Fem2D LOADFUNC(Fem2D::init); diff --git a/plugin/seq/Element_P4.hpp b/plugin/seq/Element_P4.hpp index ab8198064..11162d596 100644 --- a/plugin/seq/Element_P4.hpp +++ b/plugin/seq/Element_P4.hpp @@ -20,27 +20,19 @@ // AUTHORS : ... // E-MAIL : ... -const int TypeOfFE_P4Lagrange::nn[15][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, - {1, 1, 2, 2}, {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, - {0, 0, 0, 2}, {0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}, - {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; -const int TypeOfFE_P4Lagrange::aa[15][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, - {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, - {0, 1, 2, 0}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, - {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; +const int TypeOfFE_P4Lagrange::nn[15][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, {1, 1, 2, 2}, {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, + {0, 0, 0, 2}, {0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; +const int TypeOfFE_P4Lagrange::aa[15][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, + {0, 1, 2, 0}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; const int TypeOfFE_P4Lagrange::ff[15] = {24, 24, 24, 6, 4, 6, 6, 4, 6, 6, 4, 6, 2, 2, 2}; const int TypeOfFE_P4Lagrange::il[15] = {4, 0, 0, 0, 0, 0, 1, 2, 3, 3, 2, 1, 1, 1, 2}; const int TypeOfFE_P4Lagrange::jl[15] = {0, 4, 0, 3, 2, 1, 0, 0, 0, 1, 2, 3, 1, 2, 1}; const int TypeOfFE_P4Lagrange::kl[15] = {0, 0, 4, 1, 2, 3, 3, 2, 1, 0, 0, 0, 2, 1, 1}; -const int TypeOfFE_P4_S::nn[15][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, - {1, 1, 2, 2}, {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, - {0, 0, 0, 2}, {0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}, - {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; -const int TypeOfFE_P4_S::aa[15][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, - {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, - {0, 1, 2, 0}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, - {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; +const int TypeOfFE_P4_S::nn[15][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, {1, 1, 2, 2}, {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, + {0, 0, 0, 2}, {0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; +const int TypeOfFE_P4_S::aa[15][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, + {0, 1, 2, 0}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; const int TypeOfFE_P4_S::ff[15] = {24, 24, 24, 6, 4, 6, 6, 4, 6, 6, 4, 6, 2, 2, 2}; const int TypeOfFE_P4_S::il[15] = {4, 0, 0, 0, 0, 0, 1, 2, 3, 3, 2, 1, 1, 1, 2}; const int TypeOfFE_P4_S::jl[15] = {0, 4, 0, 3, 2, 1, 0, 0, 0, 1, 2, 3, 1, 2, 1}; diff --git a/plugin/seq/Element_P4dc.cpp b/plugin/seq/Element_P4dc.cpp index 6107c2667..2187c6b20 100644 --- a/plugin/seq/Element_P4dc.cpp +++ b/plugin/seq/Element_P4dc.cpp @@ -58,11 +58,8 @@ namespace Fem2D { static R2 Shrink1(const R2 &P) { return (P - G) * cshrink1 + G; } TypeOfFE_P4dcLagrange( ) : TypeOfFE(3 + 3 * 3 + 3, 1, Data, 4, 1, 15, 15, Pi_h_coef) { - static const R2 Pt[15] = {R2(0 / 4., 0 / 4.), R2(4 / 4., 0 / 4.), R2(0 / 4., 4 / 4.), - R2(3 / 4., 1 / 4.), R2(2 / 4., 2 / 4.), R2(1 / 4., 3 / 4.), - R2(0 / 4., 3 / 4.), R2(0 / 4., 2 / 4.), R2(0 / 4., 1 / 4.), - R2(1 / 4., 0 / 4.), R2(2 / 4., 0 / 4.), R2(3 / 4., 0 / 4.), - R2(1 / 4., 2 / 4.), R2(2 / 4., 1 / 4.), R2(1 / 4., 1 / 4.)}; + static const R2 Pt[15] = {R2(0 / 4., 0 / 4.), R2(4 / 4., 0 / 4.), R2(0 / 4., 4 / 4.), R2(3 / 4., 1 / 4.), R2(2 / 4., 2 / 4.), R2(1 / 4., 3 / 4.), R2(0 / 4., 3 / 4.), R2(0 / 4., 2 / 4.), + R2(0 / 4., 1 / 4.), R2(1 / 4., 0 / 4.), R2(2 / 4., 0 / 4.), R2(3 / 4., 0 / 4.), R2(1 / 4., 2 / 4.), R2(2 / 4., 1 / 4.), R2(1 / 4., 1 / 4.)}; for (int i = 0; i < NbDoF; i++) { pij_alpha[i] = IPJ(i, i, 0); @@ -72,8 +69,7 @@ namespace Fem2D { // 3,4,5, 6,7,8, 9,10,11, } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; const R2 TypeOfFE_P4dcLagrange::G(1. / 3., 1. / 3.); @@ -81,19 +77,16 @@ namespace Fem2D { const R TypeOfFE_P4dcLagrange::cshrink1 = 1. / TypeOfFE_P4dcLagrange::cshrink; // on what nu df on node node of df - int TypeOfFE_P4dcLagrange::Data[] = { - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // the support number of the node of the df - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // the number of the df on the node - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the node of the df - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // which are de df on sub FE - 0, // for each compontant $j=0,N-1$ it give the sub FE associated - - 0, 15}; - double TypeOfFE_P4dcLagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1., 1., 1., - 1., 1., 1., 1., 1., 1., 1.}; - void TypeOfFE_P4dcLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, - const RdHat &PHat, RNMK_ &val) const { + int TypeOfFE_P4dcLagrange::Data[] = {6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // the support number of the node of the df + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // the number of the df on the node + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the node of the df + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // the df come from which FE (generaly 0) + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // which are de df on sub FE + 0, // for each compontant $j=0,N-1$ it give the sub FE associated + + 0, 15}; + double TypeOfFE_P4dcLagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}; + void TypeOfFE_P4dcLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 P = Shrink1(PHat); R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1. - P.x - P.y, l1 = P.x, l2 = P.y; @@ -106,7 +99,7 @@ namespace Fem2D { // et la numerotation naturelle mais 2 noud pas arete // donc p est la perumation // echange de numerotation si les arete sont dans le mauvais sens - int p[15] = {}; + int p[15] = { }; for (int i = 0; i < 15; ++i) { p[i] = i; diff --git a/plugin/seq/Element_P4dc.hpp b/plugin/seq/Element_P4dc.hpp index ba765df8f..c26c37ba3 100644 --- a/plugin/seq/Element_P4dc.hpp +++ b/plugin/seq/Element_P4dc.hpp @@ -20,14 +20,10 @@ // AUTHORS : ... // E-MAIL : ... -const int TypeOfFE_P4dcLagrange::nn[15][4] = { - {0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, {1, 1, 2, 2}, - {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, {0, 0, 0, 2}, {0, 0, 0, 1}, - {0, 0, 1, 1}, {0, 1, 1, 1}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; -const int TypeOfFE_P4dcLagrange::aa[15][4] = { - {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, {0, 1, 0, 1}, - {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, {0, 1, 2, 0}, {0, 1, 2, 0}, - {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; +const int TypeOfFE_P4dcLagrange::nn[15][4] = {{0, 0, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2}, {1, 1, 1, 2}, {1, 1, 2, 2}, {1, 2, 2, 2}, {0, 2, 2, 2}, {0, 0, 2, 2}, + {0, 0, 0, 2}, {0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 0, 1, 2}}; +const int TypeOfFE_P4dcLagrange::aa[15][4] = {{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 1, 2}, {0, 1, 0, 1}, + {0, 1, 2, 0}, {0, 1, 2, 0}, {0, 1, 0, 1}, {0, 0, 1, 2}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}; const int TypeOfFE_P4dcLagrange::ff[15] = {24, 24, 24, 6, 4, 6, 6, 4, 6, 6, 4, 6, 2, 2, 2}; const int TypeOfFE_P4dcLagrange::il[15] = {4, 0, 0, 0, 0, 0, 1, 2, 3, 3, 2, 1, 1, 1, 2}; const int TypeOfFE_P4dcLagrange::jl[15] = {0, 4, 0, 3, 2, 1, 0, 0, 0, 1, 2, 3, 1, 2, 1}; diff --git a/plugin/seq/Element_PkEdge.cpp b/plugin/seq/Element_PkEdge.cpp index 6400ab920..9378d7dc5 100644 --- a/plugin/seq/Element_PkEdge.cpp +++ b/plugin/seq/Element_PkEdge.cpp @@ -78,8 +78,7 @@ namespace Fem2D { public: static double Pi_h_coef[]; - TypeOfFE_PkEdge(int KK) - : InitTypeOfFE_PkEdge(KK), TypeOfFE(ndf, 1, Data, -k, 1, ndf * 2, ndf, 0) { + TypeOfFE_PkEdge(int KK) : InitTypeOfFE_PkEdge(KK), TypeOfFE(ndf, 1, Data, -k, 1, ndf * 2, ndf, 0) { int kkk = 0; for (int i = 0; i < NbDoF; i++) { @@ -113,14 +112,12 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; // ENDOFCLASS TypeOfFE_PkEdge - void TypeOfFE_PkEdge::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_PkEdge::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R L[3] = {l0, l1, l2}; @@ -248,8 +245,7 @@ namespace Fem2D { public: static double Pi_h_coef[]; - TypeOfFE_PkEdgedc(int KK) - : InitTypeOfFE_PkEdgedc(KK), TypeOfFE(ndf, 1, Data, -2, 1, ndf * 2, ndf, 0) { + TypeOfFE_PkEdgedc(int KK) : InitTypeOfFE_PkEdgedc(KK), TypeOfFE(ndf, 1, Data, -2, 1, ndf * 2, ndf, 0) { int kkk = 0; for (int i = 0; i < NbDoF; i++) { @@ -283,14 +279,12 @@ namespace Fem2D { } } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; }; // ENDOFCLASS TypeOfFE_PkEdge - void TypeOfFE_PkEdgedc::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void TypeOfFE_PkEdgedc::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; R L[3] = {l0, l1, l2}; @@ -344,8 +338,7 @@ namespace Fem2D { static TypeOfFE_PkEdgedc PkEdgeP2dc(2); static TypeOfFE_PkEdgedc PkEdgeP3dc(3); static TypeOfFE_PkEdgedc PkEdgeP4dc(4); - static TypeOfFE_PkEdgedc PkEdgeP5dc( - 5); // a static variable to add the finite element to freefem++ + static TypeOfFE_PkEdgedc PkEdgeP5dc(5); // a static variable to add the finite element to freefem++ static AddNewFE P0Edgedc("P0edgedc", &PkEdgeP0dc); static AddNewFE P1Edgedc("P1edgedc", &PkEdgeP1dc); static AddNewFE P2Edgedc("P2edgedc", &PkEdgeP2dc); diff --git a/plugin/seq/Element_PkL.hpp b/plugin/seq/Element_PkL.hpp index 5b59cbb53..e896c8354 100644 --- a/plugin/seq/Element_PkL.hpp +++ b/plugin/seq/Element_PkL.hpp @@ -21,187 +21,157 @@ // E-MAIL : ... class TypeOfFE_Pk_L : public GTypeOfFE< MeshL > { -public: - typedef MeshL Mesh; - typedef MeshL::Element Element; - typedef GFElement< MeshL > FElement; - typedef R1 RdHat; - typedef R3 Rd; - static const int dHat = 1; - static const int d = 3; - const int kp ; - KN mi ; - KN ml,mc; - - struct A4 { - int dfon[4]; - A4(int k) { - dfon[0] = dfon[1] = dfon[2] = dfon[3] = 0; - ffassert(k>0); - dfon[0] = 1; - dfon[1] = k-1; - } - operator const int * () const {return dfon;} - }; - TypeOfFE_Pk_L( int kk) - : GTypeOfFE< Mesh >(A4(kk), 1, kk, true, false), kp(kk), mi((kk+1)*kk), ml((kk+1)*kk), mc((kk+1)*kk) + public: + typedef MeshL Mesh; + typedef MeshL::Element Element; + typedef GFElement< MeshL > FElement; + typedef R1 RdHat; + typedef R3 Rd; + static const int dHat = 1; + static const int d = 3; + const int kp; + KN< int > mi; + KN< double > ml, mc; + + struct A4 { + int dfon[4]; + A4(int k) { + dfon[0] = dfon[1] = dfon[2] = dfon[3] = 0; + ffassert(k > 0); + dfon[0] = 1; + dfon[1] = k - 1; + } + operator const int *( ) const { return dfon; } + }; + TypeOfFE_Pk_L(int kk) : GTypeOfFE< Mesh >(A4(kk), 1, kk, true, false), kp(kk), mi((kk + 1) * kk), ml((kk + 1) * kk), mc((kk + 1) * kk) { + typedef Element E; + int n = this->NbDoF; + bool dd = verbosity > 5; + if (dd) { + cout << "\n +++ P" << kp << " L : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; + } + ffassert(n == kp + 1); + ffassert(this->PtInterpolation.N( ) == kp + 1); + RdHat *Pt = this->PtInterpolation; + KN< int > pdof(n); + // construction of interpolation ppoint { - typedef Element E; - int n = this->NbDoF; - bool dd = verbosity > 5; - if (dd) { - cout << "\n +++ P"<< kp <<" L : ndof : " << n << " " << this->PtInterpolation.N( ) << endl; - } - ffassert( n == kp+1); - ffassert(this->PtInterpolation.N( )==kp+1); - RdHat *Pt = this->PtInterpolation; - KN pdof(n); - // construction of interpolation ppoint - { - double cc = 1. / kp; - Pt[0] = R1(0); - Pt[1] = R1(1.); - pdof[0] = 0; - pdof[1]= kp; - - for(int i=1; iPtInterpolation << endl; - } - } - - for (int i = 0; i < n; i++) { - this->pInterpolation[i] = i; - this->cInterpolation[i] = 0; - this->dofInterpolation[i] = i; - this->coefInterpolation[i] = 1.; + double cc = 1. / kp; + Pt[0] = R1(0); + Pt[1] = R1(1.); + pdof[0] = 0; + pdof[1] = kp; + + for (int i = 1; i < kp; ++i) { + Pt[i + 1] = R1(cc * i); + pdof[i + 1] = i; + } + + if (dd) { + cout << this->PtInterpolation << endl; + } + } + + for (int i = 0; i < n; i++) { + this->pInterpolation[i] = i; + this->cInterpolation[i] = 0; + this->dofInterpolation[i] = i; + this->coefInterpolation[i] = 1.; + } + // constructon de + // // (k*l[li]-i)/(ii-i);; + int km = 0; + for (int dof = 0; dof < n; ++dof) { + int ii = pdof[dof]; // point associaed to dof + // cout << " dof " << dof << "km=" < monome : ( k*l - i )/( ii-i) ok.. + RN_ f0(val('.', 0, op_id)); + if (whatd & Fop_D0) { + double s = 0.; + for (int dof = 0, m = 0; dof < this->NbDoF; ++dof) { + double f = 1.; + for (int i = 0; i < k; ++i, ++m) f *= (ml[m] * l[mi[m]] + mc[m]); + f0[dof] = f; + s += f; + } + + ffassert(abs(s - 1.) < 1e-7); + } + if (whatd & (Fop_D1 | Fop_D2)) { + bool d2 = Fop_D2 && k > 1; // calcul de + const unsigned int fop[3] = {Fop_dx, Fop_dy, Fop_dz}; + const int op[3] = {op_dx, op_dy, op_dz}; + const int dop[9] = {op_dxx, op_dxy, op_dxz, op_dyx, op_dyy, op_dyz, op_dzx, op_dzy, op_dzz}; + + Rd Dl[dHat + 1]; + Rd DDl[dHat + 1][d]; + K.Gradlambda(Dl); + KN< Rd > df(this->NbDoF), ddf(this->NbDoF * d); + + for (int dof = 0, m = 0; dof < this->NbDoF; ++dof) { + double f = 1.; + Rd Df; + Rd DDf[d]; + for (int i = 0; i < k; ++i, ++m) { // f = f*b // df = df*b+db*f; ddf = ddf*b + 2*df*db + f * ddb + int im = mi[m]; + double b = (ml[m] * l[im] + mc[m]); + Rd Db = ml[m] * Dl[im]; + if (d2) + for (int l = 0; l < d; ++l) DDf[l] = b * DDf[l] + Db[l] * Df + Db * Df[l]; + Df = b * Df + (f * Db); + f *= b; } - if(verbosity>9) - { - cout << " km == " << km << "kp = " << kp << " " << n << endl; - - for(int dof=0,m=0; dof monome : ( k*l - i )/( ii-i) ok.. - RN_ f0(val('.',0,op_id)); - if (whatd & Fop_D0) - { double s=0.; - for( int dof = 0,m=0; dof < this->NbDoF; ++dof) - { - double f=1.; - for(int i=0; iNbDoF; ++i) dfdd[i] = df[i][dd]; } - if(whatd & (Fop_D1|Fop_D2)) - { - bool d2= Fop_D2 && k>1;// calcul de - const unsigned int fop[3]={Fop_dx,Fop_dy,Fop_dz}; - const int op[3]={op_dx,op_dy,op_dz}; - const int dop[9]={op_dxx,op_dxy,op_dxz, op_dyx,op_dyy,op_dyz, op_dzx,op_dzy,op_dzz}; - - Rd Dl[dHat+1]; - Rd DDl[dHat+1][d]; - K.Gradlambda(Dl); - KN df(this->NbDoF),ddf(this->NbDoF*d); - - for( int dof = 0,m=0; dof < this->NbDoF; ++dof) - { - double f=1.; - Rd Df; - Rd DDf[d] ; - for(int i=0; iNbDoF; ++i) dfdd[i] = ddf[i * 3 + id][jd]; } - // copy data d D - for (int dd=0; dd< Rd::d;++dd) - { - if (whatd & fop[dd]) - { - RN_ dfdd(val('.',0,op[dd])); - for(int i=0;iNbDoF;++i) - dfdd[i]= df[i][dd]; - } - } - // copy data DD - if(d2) - { - for (int id=0; id< Rd::d;++id) - for (int jd=0; jd<= id;++jd) - { - int op = dop[id*3+jd]; - const unsigned int fopij= 1<< op; - if (whatd & fopij) - { - RN_ dfdd(val('.',0,op)); - for(int i=0;iNbDoF;++i) - dfdd[i]= ddf[i*3+id][jd]; - } - } - } - - } + } + } } + } }; diff --git a/plugin/seq/Element_QF.cpp b/plugin/seq/Element_QF.cpp index 66f5db92f..af46011da 100644 --- a/plugin/seq/Element_QF.cpp +++ b/plugin/seq/Element_QF.cpp @@ -69,9 +69,7 @@ namespace Fem2D { int m; KN< int > w; - TypeOfFE_QF2d(const QF *qf) - : TypeOfFE(0, 0, qf->n, 1, DataQF2d(qf->n), 1, 1, qf->n, qf->n, new double[qf->n]), m(2), - w(m * m) { + TypeOfFE_QF2d(const QF *qf) : TypeOfFE(0, 0, qf->n, 1, DataQF2d(qf->n), 1, 1, qf->n, qf->n, new double[qf->n]), m(2), w(m * m) { int debug = verbosity > 99; for (int i = 0; i < NbDoF; i++) { @@ -108,8 +106,7 @@ namespace Fem2D { } if (debug) { - cout << k << " " << i << " " << j << " : " << w[k] << " ( " << P_Pi_h[w[k]] << " )" - << dd << " || " << P << endl; + cout << k << " " << i << " " << j << " : " << w[k] << " ( " << P_Pi_h[w[k]] << " )" << dd << " || " << P << endl; } } } @@ -147,8 +144,7 @@ namespace Fem2D { return w(i * m + j); } - void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, - RNMK_ &val) const { + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { int k = ijP(PHat); val = 0; @@ -171,8 +167,7 @@ namespace Fem2D { typedef GQuadratureFormular< R2 > QFf; // quadrature formule on a face typedef GQuadratureFormular< R3 > QFk; // quadrature formule on a element TypeOfFE_QF3d(const TypeOfFE_QF3d::QFk &qf); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; // void set(const Mesh & Th,const Element & K,InterpolationMatrix & M,int ocoef,int // odf,int *nump) const; static int *pdfon(int n); @@ -197,9 +192,7 @@ namespace Fem2D { return p; } - TypeOfFE_QF3d::TypeOfFE_QF3d(const TypeOfFE_QF3d::QFk &qf) - : GTypeOfFE< Mesh3 >(dfon = pdfon(qf.n), 1, 1, qf.n, qf.n, true, true), np(qf.n), m(2), - w(m * m * m) { + TypeOfFE_QF3d::TypeOfFE_QF3d(const TypeOfFE_QF3d::QFk &qf) : GTypeOfFE< Mesh3 >(dfon = pdfon(qf.n), 1, 1, qf.n, qf.n, true, true), np(qf.n), m(2), w(m * m * m) { for (int i = 0; i < np; ++i) { this->PtInterpolation[i] = qf[i]; this->pInterpolation[i] = i; @@ -239,8 +232,7 @@ namespace Fem2D { } if (debug) { - cout << kk << " " << i << " " << j << " " << k << " : " << w[k] << " ( " - << this->PtInterpolation[w[kk]] << " )" << dd << " || " << P << endl; + cout << kk << " " << i << " " << j << " " << k << " : " << w[k] << " ( " << this->PtInterpolation[w[kk]] << " )" << dd << " || " << P << endl; } } } @@ -278,8 +270,7 @@ namespace Fem2D { } } - void TypeOfFE_QF3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { + void TypeOfFE_QF3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { assert(val.N( ) >= 4); assert(val.M( ) == 1); int kqf = ijP(PHat); @@ -329,7 +320,6 @@ static void finit( ) { // equivalent2d 3d EFQF static AddNewFE3 AddNewFE_QF3d5("FEQF53d", &TypeOfFE_QF3d5); static AddNewFE3 AddNewFE_QF3ddef("FEQF3d", &TypeOfFE_QF3d5); - Dcl_Type< pEF2d * >(::InitializePtr< pEF2d >, ::DeletePtr< pEF2d >); if (verbosity > 9) { cout << "\n add FE2d\n"; @@ -337,8 +327,7 @@ static void finit( ) { // equivalent2d 3d EFQF zzzfff->Add("FiniteElement2d", atype< pEF2d * >( )); map_type[typeid(pEF2d).name( )]->AddCast(new E_F1_funcT< pEF2d, pEF2d * >(UnRef< pEF2d >)); - TheOperators->Add("<-", - new OneOperator2< pEF2d *, pEF2d *, const GQuadratureFormular< R2 > * >(EFQF2)); + TheOperators->Add("<-", new OneOperator2< pEF2d *, pEF2d *, const GQuadratureFormular< R2 > * >(EFQF2)); Dcl_Type< pEF3d * >(::InitializePtr< pEF3d >, ::DeletePtr< pEF3d >); if (verbosity > 9) { @@ -347,8 +336,7 @@ static void finit( ) { // equivalent2d 3d EFQF zzzfff->Add("FiniteElement3d", atype< pEF3d * >( )); map_type[typeid(pEF3d).name( )]->AddCast(new E_F1_funcT< pEF3d, pEF3d * >(UnRef< pEF3d >)); - TheOperators->Add("<-", - new OneOperator2< pEF3d *, pEF3d *, const GQuadratureFormular< R3 > * >(EFQF3)); + TheOperators->Add("<-", new OneOperator2< pEF3d *, pEF3d *, const GQuadratureFormular< R3 > * >(EFQF3)); } LOADFUNC(finit); // une variable globale qui serat construite au chargement dynamique diff --git a/plugin/seq/ExampleMetrics.h b/plugin/seq/ExampleMetrics.h index 4683b4f1d..917c22df8 100644 --- a/plugin/seq/ExampleMetrics.h +++ b/plugin/seq/ExampleMetrics.h @@ -78,16 +78,14 @@ const sym2 ExampleMetric< 4 >(const R2 &P) { } // diagonal template<> -const sym2 ExampleMetric< 5 >( - const R2 &P) { // High anisotropy along the spiral r=k(theta+2 mu Pi), mu in {0,1,2}. +const sym2 ExampleMetric< 5 >(const R2 &P) { // High anisotropy along the spiral r=k(theta+2 mu Pi), mu in {0,1,2}. const double pi = 4 * atan(1); const double width = 0.006; const double k = 0.4 / (6 * pi); const double mu = 100.; const R2 Q = P - R2(0.5, 0.5); const double r = Q.norm( ); - double theta = - Q.x == -r ? pi : 2 * atan(Q.y / (r + Q.x)); // theta = theta >= 0 ? theta : theta+pi; + double theta = Q.x == -r ? pi : 2 * atan(Q.y / (r + Q.x)); // theta = theta >= 0 ? theta : theta+pi; if (fabs(r - k * theta) <= width) theta = theta + 0 * pi; @@ -165,8 +163,7 @@ const sym3 ExampleMetric3D< 3 >(const R3 &P) { // tire bouchon... return sym3( ); } - if (square(Q.x - r * cos(theta0 * Q.z)) + square(Q.y - r * sin(theta0 * Q.z)) > - square(r * delta0)) { + if (square(Q.x - r * cos(theta0 * Q.z)) + square(Q.y - r * sin(theta0 * Q.z)) > square(r * delta0)) { return sym3( ); } diff --git a/plugin/seq/FreeFemQA.cpp b/plugin/seq/FreeFemQA.cpp index 95a1b8718..a37f27332 100644 --- a/plugin/seq/FreeFemQA.cpp +++ b/plugin/seq/FreeFemQA.cpp @@ -63,27 +63,18 @@ class MeshGenQA : public E_F0mps { expM22 = to< double >(args[3]); } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - KN< double > *arg(int i, Stack stack, KN< double > *a) const { - return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : a; - } + KN< double > *arg(int i, Stack stack, KN< double > *a) const { return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : a; } ~MeshGenQA( ) {} static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< pmesh >( ), atype< double >( ), atype< double >( ), - atype< double >( )); + return ArrayOfaType(atype< pmesh >( ), atype< double >( ), atype< double >( ), atype< double >( )); ; } @@ -92,14 +83,9 @@ class MeshGenQA : public E_F0mps { AnyType operator( )(Stack s) const; // la vraie fonction qui fait faire le boulot }; -basicAC_F0::name_and_type MeshGenQA::name_param[MeshGenQA::n_name_param] = { - {"noIsoRef", &typeid(bool)}, - {"finalRefine", &typeid(bool)}, - {"exportIntermediateData", &typeid(bool)}, - {"Lip", &typeid(double)}, - {"exportToMathematica", &typeid(bool)}, - {"exportMetricToMathematica", &typeid(bool)}, - {"noRef", &typeid(bool)}}; +basicAC_F0::name_and_type MeshGenQA::name_param[MeshGenQA::n_name_param] = {{"noIsoRef", &typeid(bool)}, {"finalRefine", &typeid(bool)}, {"exportIntermediateData", &typeid(bool)}, + {"Lip", &typeid(double)}, {"exportToMathematica", &typeid(bool)}, {"exportMetricToMathematica", &typeid(bool)}, + {"noRef", &typeid(bool)}}; AnyType MeshGenQA::operator( )(Stack stack) const { const bool noIsoRef = arg(0, stack, false); const bool finalRefine = arg(1, stack, false); @@ -131,17 +117,13 @@ AnyType MeshGenQA::operator( )(Stack stack) const { Stack stack_; public: - FFMetric2(const MeshGenQA &MGQA, Stack stack, double Lip) : MGQA_(MGQA), stack_(stack) { - lip = Lip; - } + FFMetric2(const MeshGenQA &MGQA, Stack stack, double Lip) : MGQA_(MGQA), stack_(stack) { lip = Lip; } const mir::sym2 operator( )(const mir::R2 &P) const { MeshPointStack(stack_)->set(P.x, P.y); // needs to be done three times ? MeshPointStack(stack_)->set(P.x, P.y); MeshPointStack(stack_)->set(P.x, P.y); - return mir::sym2(GetAny< double >((*MGQA_.expM11)(stack_)), - GetAny< double >((*MGQA_.expM12)(stack_)), - GetAny< double >((*MGQA_.expM22)(stack_))); + return mir::sym2(GetAny< double >((*MGQA_.expM11)(stack_)), GetAny< double >((*MGQA_.expM12)(stack_)), GetAny< double >((*MGQA_.expM22)(stack_))); } }; diff --git a/plugin/seq/Geometry.hpp b/plugin/seq/Geometry.hpp index f087314d3..78a7843d9 100644 --- a/plugin/seq/Geometry.hpp +++ b/plugin/seq/Geometry.hpp @@ -36,7 +36,7 @@ class Vertex : public R2 { // heritage is perhaps not totally justified here, // friend int main(int argc, const char * argv[]); //for Debug purposes public: - Vertex( ) : R2( ), m( ){}; + Vertex( ) : R2( ), m( ) {}; Vertex(R2 u, int Gen, sym2 metric = sym2( )) : R2(u), gen(Gen), m(metric) {} Vertex(R2 u, int Gen, const Metric2 &metric) : R2(u), gen(Gen), m(metric(u)) {} @@ -61,38 +61,31 @@ class Vertex : public R2 { // heritage is perhaps not totally justified here, */ inline ostream &operator<<(ostream &f, const Vertex &u) { return f << R2(u); } -inline ostream_math operator<<(ostream_math f, const Vertex &u) { - return f << "{" << R2(u) << "," << u.getGen( ) << "," << u.getm( ) << "}"; -} +inline ostream_math operator<<(ostream_math f, const Vertex &u) { return f << "{" << R2(u) << "," << u.getGen( ) << "," << u.getm( ) << "}"; } /****************** Edge ****************/ class Edge { // edges are oriented. t is on the left. // bool refinable; Vertex const *u; - Vertex const * - v; // Note : routines tend to leave v constant when possible (i.e. except construct and flip) + Vertex const *v; // Note : routines tend to leave v constant when possible (i.e. except construct and flip) Edge *next, *sister; // next edge on triangle and reversed edge Edge *prev( ) const { return next->next; } - bool cut(Vertex const *start, Vertex const *end, Edge *oldSister, Tab< Edge > &EdgeAllocator, - Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned); + bool cut(Vertex const *start, Vertex const *end, Edge *oldSister, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned); // friend int main(int argc, const char * argv[]); //for Debug purposes #ifdef _FLAGGED_BOUNDARY_ int onBoundary_; #endif public: - Edge( ) : u(NULL), v(NULL), next(NULL), sister(NULL){}; + Edge( ) : u(NULL), v(NULL), next(NULL), sister(NULL) {}; #ifdef _FLAGGED_BOUNDARY_ - Edge(Vertex const *U, Vertex const *V, Edge *S, Edge *N, int OnBoundary_ = 0) - : u(U), v(V), sister(S), next(N), onBoundary_(OnBoundary_){}; - int onBoundary( ) const { - return onBoundary_; - } // {if(sister!=NULL) return 0; if(onBoundary_>0) return onBoundary_; return 10;} + Edge(Vertex const *U, Vertex const *V, Edge *S, Edge *N, int OnBoundary_ = 0) : u(U), v(V), sister(S), next(N), onBoundary_(OnBoundary_) {}; + int onBoundary( ) const { return onBoundary_; } // {if(sister!=NULL) return 0; if(onBoundary_>0) return onBoundary_; return 10;} #else - Edge(Vertex const *U, Vertex const *V, Edge *S, Edge *N) : u(U), v(V), next(N), sister(S){}; + Edge(Vertex const *U, Vertex const *V, Edge *S, Edge *N) : u(U), v(V), next(N), sister(S) {}; bool onBoundary( ) const { return sister == NULL; } #endif @@ -108,9 +101,7 @@ class Edge { // edges are oriented. t is on the left. R2 vec( ) const { return *v - *u; } // R2(v->x - u->x, v->y - u->y) - bool isRepresentative( ) const { - return (sister == NULL) || (u->x < v->x) || (u->x == v->x && u->y < v->y); - } + bool isRepresentative( ) const { return (sister == NULL) || (u->x < v->x) || (u->x == v->x && u->y < v->y); } Edge *representative( ) { return isRepresentative( ) ? this : sister; } @@ -126,35 +117,25 @@ class Edge { // edges are oriented. t is on the left. return isRepresentative3( ); } - enum refinement_priority { - selected_edge_first, - newest_vertex_first, - euclidean_longest_edge_first - }; + enum refinement_priority { selected_edge_first, newest_vertex_first, euclidean_longest_edge_first }; Edge *which_first(refinement_priority priority); // refine splits the edge and returns a pointer to the other half of the splitted edge //bool // newestVertexFirst=true - Edge *refine(Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, - refinement_priority priority); + Edge *refine(Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, refinement_priority priority); // splits associated triangle if larger than size h/sqrt(smallEigenVal) (metric taken at the worst // point on the triangle). Non recursive. - bool hRefine3(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, - const Metric2 &metric, refinement_priority priority); + bool hRefine3(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, refinement_priority priority); // splits the edge if its length in the metric (taken at the worst point on the edge) is larger // than h. - Edge *hRefine2(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, - const Metric2 &metric, safe_vector< Edge * > *recursive = NULL, - bool exaggerate = false); + Edge *hRefine2(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, safe_vector< Edge * > *recursive = NULL, bool exaggerate = false); bool check( ) const; Edge *getNext( ) const { return next; } Edge *getSister( ) const { return sister; } - bool cut(Vertex const *start, Vertex const *end, Tab< Edge > &EdgeAllocator, - Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned); - Vertex *intersect(Vertex const *start, Vertex const *end, Tab< Vertex > &VertexAllocator, - const Metric2 &metric); + bool cut(Vertex const *start, Vertex const *end, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned); + Vertex *intersect(Vertex const *start, Vertex const *end, Tab< Vertex > &VertexAllocator, const Metric2 &metric); }; inline ostream &operator<<(ostream &f, const Edge &e) { @@ -204,10 +185,7 @@ inline bool Edge::check( ) const { return false; } -inline bool Edge::flipable( ) const { - return !onBoundary( ) && det(sister->prev( )->vec( ), next->vec( )) > 0 && - det(prev( )->vec( ), sister->next->vec( )) > 0; -} +inline bool Edge::flipable( ) const { return !onBoundary( ) && det(sister->prev( )->vec( ), next->vec( )) > 0 && det(prev( )->vec( ), sister->next->vec( )) > 0; } inline double Edge::flipGain( ) const { // edge is assumed to be flipable, hence angles are flip increases minimum angle. @@ -219,10 +197,8 @@ inline double Edge::flipGain( ) const { // edge is assumed to be flipable, he Vertex const *t = sister->next->v; const R2 uv = *v - *u, st = *t - *s, vs = *s - *v, su = *u - *s, ut = *t - *u, tv = *v - *t; const sym2 &mu = u->getm( ), &mv = v->getm( ), ms = s->getm( ), mt = t->getm( ); - return min(min(min(-ms.cos(st, vs), ms.cos(st, su)), min(mt.cos(st, ut), -mt.cos(st, tv))), - min(-mu.cos(su, ut), -mv.cos(tv, vs))) - - min(min(min(-mu.cos(uv, su), mu.cos(uv, ut)), min(mv.cos(uv, tv), -mv.cos(uv, vs))), - min(-ms.cos(vs, su), -mt.cos(ut, tv))); + return min(min(min(-ms.cos(st, vs), ms.cos(st, su)), min(mt.cos(st, ut), -mt.cos(st, tv))), min(-mu.cos(su, ut), -mv.cos(tv, vs))) - + min(min(min(-mu.cos(uv, su), mu.cos(uv, ut)), min(mv.cos(uv, tv), -mv.cos(uv, vs))), min(-ms.cos(vs, su), -mt.cos(ut, tv))); } inline bool Edge::flip( ) { @@ -321,8 +297,7 @@ class Triangulation { for (int i = 0; i < ne_oriented( ); ++i) { if (edges[i].isRepresentative( )) { - connectivity[counter++] = - Z2(vertices.index(edges[i].getu( )), vertices.index(edges[i].getv( ))); + connectivity[counter++] = Z2(vertices.index(edges[i].getu( )), vertices.index(edges[i].getv( ))); } } @@ -330,8 +305,7 @@ class Triangulation { } // Refines triangles isotropically, based on the small eigenvalue of the metric. - void hRefine(double h = 1, - Edge::refinement_priority priority = Edge::euclidean_longest_edge_first) { + void hRefine(double h = 1, Edge::refinement_priority priority = Edge::euclidean_longest_edge_first) { if (h <= 0) { return; } @@ -343,8 +317,7 @@ class Triangulation { } } - void hRefineQA(double h = 1, unsigned int flag = 0, - Edge::refinement_priority priority = Edge::euclidean_longest_edge_first); + void hRefineQA(double h = 1, unsigned int flag = 0, Edge::refinement_priority priority = Edge::euclidean_longest_edge_first); enum hRefineQA_opt { hRQA_finalRefine = 1, hRQA_exportIntermediateData = 2, hRQA_noIsoRef = 4 }; // Affects only the position, not the metric diff --git a/plugin/seq/GeometryQA.cpp b/plugin/seq/GeometryQA.cpp index be3a5b0b3..39b54f22b 100644 --- a/plugin/seq/GeometryQA.cpp +++ b/plugin/seq/GeometryQA.cpp @@ -45,9 +45,8 @@ namespace mir { template<> const string Z2::name = "Z2"; template<> - const R2 R2::NABiDim = - R2(DBL_MAX, - DBL_MAX); // NAN could be a better alternative, but equality tests become problematic, + const R2 R2::NABiDim = R2(DBL_MAX, + DBL_MAX); // NAN could be a better alternative, but equality tests become problematic, template<> const Z2 Z2::NABiDim = Z2(INT_MAX, INT_MAX); // and NAN does not exists for integers. template<> @@ -57,8 +56,7 @@ namespace mir { #include "ExampleMetrics.h" - Edge *Edge::refine(Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, - const Metric2 &metric, refinement_priority priority) { + Edge *Edge::refine(Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, refinement_priority priority) { Edge *const wf = which_first(priority); if (wf != this) { @@ -74,12 +72,9 @@ namespace mir { Vertex const *w = next->v; Vertex *t = VertexAllocator.next( ); - const int newGen = - 1 + max(max(u->getGen( ), v->getGen( )), - max(next->v->getGen( ), sister == NULL ? -1 : sister->next->v->getGen( ))); + const int newGen = 1 + max(max(u->getGen( ), v->getGen( )), max(next->v->getGen( ), sister == NULL ? -1 : sister->next->v->getGen( ))); *t = Vertex((*u + *v) / 2, newGen, metric); - Edge *const wt = EdgeAllocator.next( ), *const tw = EdgeAllocator.next( ), - *const ut = EdgeAllocator.next( ); + Edge *const wt = EdgeAllocator.next( ), *const tw = EdgeAllocator.next( ), *const ut = EdgeAllocator.next( ); *wt = Edge(w, t, tw, this); *tw = Edge(t, w, wt, prev( )); @@ -119,8 +114,7 @@ namespace mir { return ut; } - bool Edge::hRefine3(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, - const Metric2 &metric, refinement_priority priority) { + bool Edge::hRefine3(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, refinement_priority priority) { Edge *const wf = which_first(priority); if (this != wf) { @@ -142,16 +136,14 @@ namespace mir { // If the metric is not constant, it is sampled until resolution allows to make a sensible // choice. Smallest eigenvalue used only. - for (int pow = 1; h * (minSize - metric.lip * maxLen / (2 * pow)) < maxLen / 2; - pow *= 2) { // !!! condition should be checked + for (int pow = 1; h * (minSize - metric.lip * maxLen / (2 * pow)) < maxLen / 2; pow *= 2) { // !!! condition should be checked for (int i = 0; i <= pow; i++) { for (int j = 0; i + j <= pow; j++) { if (i % 2 == 0 && j % 2 == 0) { continue; } - minSize = - min(minSize, sqrt(metric((*u * i + *v * j + *w * (pow - i - j)) / pow).invNorm( ))); + minSize = min(minSize, sqrt(metric((*u * i + *v * j + *w * (pow - i - j)) / pow).invNorm( ))); if (h * minSize < maxLen) { refine(EdgeAllocator, VertexAllocator, metric, priority); return true; @@ -163,8 +155,7 @@ namespace mir { return false; } - Edge *Edge::hRefine2(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, - const Metric2 &metric, safe_vector< Edge * > *recursive, bool exaggerate) { + Edge *Edge::hRefine2(double h, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, safe_vector< Edge * > *recursive, bool exaggerate) { // in the case recursive=!NULL of a recursive split, the safe_vector recursive contains all // newly created edges which are oriented like *this. const R2 Vec = vec( ); @@ -193,8 +184,7 @@ namespace mir { // If the metric is not constant, it is sampled until resolution allows to make a sensible // choice (based on lip constant). Smallest eigenvalue used only. - for (int pow = 1; h * (minSize - metric.lip / (2 * pow)) < 0.5; - pow *= 2) { // !!! condition should be checked + for (int pow = 1; h * (minSize - metric.lip / (2 * pow)) < 0.5; pow *= 2) { // !!! condition should be checked for (int i = 0; i <= pow; i++) { if (i % 2 == 0) { continue; @@ -229,15 +219,12 @@ namespace mir { const int ugen = u->getGen( ), vgen = v->getGen( ), wgen = next->v->getGen( ); return ugen > vgen ? (ugen > wgen ? next : this) : (vgen > wgen ? prev( ) : this); } else { // euclidean_longest_edge_first - const double this_len = vec( ).norm( ), next_len = next->vec( ).norm( ), - prev_len = prev( )->vec( ).norm( ); - return next_len > prev_len ? (next_len > this_len ? next : this) - : (prev_len > this_len ? prev( ) : this); + const double this_len = vec( ).norm( ), next_len = next->vec( ).norm( ), prev_len = prev( )->vec( ).norm( ); + return next_len > prev_len ? (next_len > this_len ? next : this) : (prev_len > this_len ? prev( ) : this); } } - bool Edge::cut(Vertex const *start, Vertex const *end, Tab< Edge > &EdgeAllocator, - Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned) { + bool Edge::cut(Vertex const *start, Vertex const *end, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned) { // aligned collects created edges which are aligned with the cut if (start == v) { return next->cut(start, end, EdgeAllocator, VertexAllocator, metric, @@ -258,8 +245,7 @@ namespace mir { currentDet = -prevDet; prevDet = det(currentEdge->prev( )->vec( ), se); if (currentDet > 0 && prevDet > 0) { - return currentEdge->cut(start, end, NULL, EdgeAllocator, VertexAllocator, metric, - aligned); + return currentEdge->cut(start, end, NULL, EdgeAllocator, VertexAllocator, metric, aligned); } currentEdge = currentEdge->prev( )->sister; @@ -280,8 +266,7 @@ namespace mir { prevDet = -currentDet; currentDet = det(currentEdge->vec( ), se); if (currentDet > 0 && prevDet > 0) { - return currentEdge->cut(start, end, NULL, EdgeAllocator, VertexAllocator, metric, - aligned); + return currentEdge->cut(start, end, NULL, EdgeAllocator, VertexAllocator, metric, aligned); } } } @@ -289,9 +274,7 @@ namespace mir { return false; // not supposed to happen } - bool Edge::cut(Vertex const *start, Vertex const *end, Edge *oldSister, - Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, - vector< Edge * > &aligned) { + bool Edge::cut(Vertex const *start, Vertex const *end, Edge *oldSister, Tab< Edge > &EdgeAllocator, Tab< Vertex > &VertexAllocator, const Metric2 &metric, vector< Edge * > &aligned) { Vertex *t = next->intersect(start, end, VertexAllocator, metric); if (oldSister == NULL) { @@ -398,8 +381,7 @@ namespace mir { return false; } - Vertex *Edge::intersect(Vertex const *start, Vertex const *end, Tab< Vertex > &VertexAllocator, - const Metric2 &metric) { + Vertex *Edge::intersect(Vertex const *start, Vertex const *end, Tab< Vertex > &VertexAllocator, const Metric2 &metric) { if (start == end || start == u || start == v || end == u || end == v || u == v) { return NULL; } @@ -415,8 +397,7 @@ namespace mir { return NULL; } - *VertexAllocator.next( ) = Vertex(*u * (1 - coef.x) / 2 + *v * (1 + coef.x) / 2, - 1 + max(u->getGen( ), v->getGen( )), metric); + *VertexAllocator.next( ) = Vertex(*u * (1 - coef.x) / 2 + *v * (1 + coef.x) / 2, 1 + max(u->getGen( ), v->getGen( )), metric); return &VertexAllocator[VertexAllocator.max_accessed_pos]; } @@ -431,8 +412,7 @@ namespace mir { Triangulation::Triangulation(int N, const Metric2 &Metric) : metric(Metric) { for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { - vertices[i + (N + 1) * j] = - Vertex(R2(i / double(N), j / double(N)), abs(N - i - j), metric); + vertices[i + (N + 1) * j] = Vertex(R2(i / double(N), j / double(N)), abs(N - i - j), metric); } } @@ -440,44 +420,19 @@ namespace mir { for (int j = 0; j < N; j++) { const int index = i + N * j; #ifdef _FLAGGED_BOUNDARY_ - edges[6 * index + 0] = - Edge(&vertices[i + (N + 1) * j], &vertices[i + 1 + (N + 1) * j], - j > 0 ? &edges[6 * (index - N) + 3] : NULL, &edges[6 * index + 1], j == 0 ? 1 : 0); - edges[6 * index + 1] = - Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + (N + 1) * (j + 1)], - &edges[6 * index + 4], &edges[6 * index + 2]); - edges[6 * index + 2] = - Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + (N + 1) * j], - i > 0 ? &edges[6 * (index - 1) + 5] : NULL, &edges[6 * index + 0], i == 0 ? 4 : 0); - edges[6 * index + 3] = Edge( - &vertices[i + 1 + (N + 1) * (j + 1)], &vertices[i + (N + 1) * (j + 1)], - j + 1 < N ? &edges[6 * (index + N)] : NULL, &edges[6 * index + 4], j + 1 == N ? 3 : 0); - edges[6 * index + 4] = - Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + 1 + (N + 1) * j], - &edges[6 * index + 1], &edges[6 * index + 5]); - edges[6 * index + 5] = - Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + 1 + (N + 1) * (j + 1)], - i + 1 < N ? &edges[6 * (index + 1) + 2] : NULL, &edges[6 * index + 3], - i + 1 == N ? 2 : 0); + edges[6 * index + 0] = Edge(&vertices[i + (N + 1) * j], &vertices[i + 1 + (N + 1) * j], j > 0 ? &edges[6 * (index - N) + 3] : NULL, &edges[6 * index + 1], j == 0 ? 1 : 0); + edges[6 * index + 1] = Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + (N + 1) * (j + 1)], &edges[6 * index + 4], &edges[6 * index + 2]); + edges[6 * index + 2] = Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + (N + 1) * j], i > 0 ? &edges[6 * (index - 1) + 5] : NULL, &edges[6 * index + 0], i == 0 ? 4 : 0); + edges[6 * index + 3] = Edge(&vertices[i + 1 + (N + 1) * (j + 1)], &vertices[i + (N + 1) * (j + 1)], j + 1 < N ? &edges[6 * (index + N)] : NULL, &edges[6 * index + 4], j + 1 == N ? 3 : 0); + edges[6 * index + 4] = Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + 1 + (N + 1) * j], &edges[6 * index + 1], &edges[6 * index + 5]); + edges[6 * index + 5] = Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + 1 + (N + 1) * (j + 1)], i + 1 < N ? &edges[6 * (index + 1) + 2] : NULL, &edges[6 * index + 3], i + 1 == N ? 2 : 0); #else - edges[6 * index + 0] = - Edge(&vertices[i + (N + 1) * j], &vertices[i + 1 + (N + 1) * j], - j > 0 ? &edges[6 * (index - N) + 3] : NULL, &edges[6 * index + 1]); - edges[6 * index + 1] = - Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + (N + 1) * (j + 1)], - &edges[6 * index + 4], &edges[6 * index + 2]); - edges[6 * index + 2] = - Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + (N + 1) * j], - i > 0 ? &edges[6 * (index - 1) + 5] : NULL, &edges[6 * index + 0]); - edges[6 * index + 3] = - Edge(&vertices[i + 1 + (N + 1) * (j + 1)], &vertices[i + (N + 1) * (j + 1)], - j + 1 < N ? &edges[6 * (index + N)] : NULL, &edges[6 * index + 4]); - edges[6 * index + 4] = - Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + 1 + (N + 1) * j], - &edges[6 * index + 1], &edges[6 * index + 5]); - edges[6 * index + 5] = - Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + 1 + (N + 1) * (j + 1)], - i + 1 < N ? &edges[6 * (index + 1) + 2] : NULL, &edges[6 * index + 3]); + edges[6 * index + 0] = Edge(&vertices[i + (N + 1) * j], &vertices[i + 1 + (N + 1) * j], j > 0 ? &edges[6 * (index - N) + 3] : NULL, &edges[6 * index + 1]); + edges[6 * index + 1] = Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + (N + 1) * (j + 1)], &edges[6 * index + 4], &edges[6 * index + 2]); + edges[6 * index + 2] = Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + (N + 1) * j], i > 0 ? &edges[6 * (index - 1) + 5] : NULL, &edges[6 * index + 0]); + edges[6 * index + 3] = Edge(&vertices[i + 1 + (N + 1) * (j + 1)], &vertices[i + (N + 1) * (j + 1)], j + 1 < N ? &edges[6 * (index + N)] : NULL, &edges[6 * index + 4]); + edges[6 * index + 4] = Edge(&vertices[i + (N + 1) * (j + 1)], &vertices[i + 1 + (N + 1) * j], &edges[6 * index + 1], &edges[6 * index + 5]); + edges[6 * index + 5] = Edge(&vertices[i + 1 + (N + 1) * j], &vertices[i + 1 + (N + 1) * (j + 1)], i + 1 < N ? &edges[6 * (index + 1) + 2] : NULL, &edges[6 * index + 3]); #endif } } @@ -551,8 +506,7 @@ namespace mir { // collecting the extremal edges associated to each vertex. const int nv_iso = nv( ); const int ne_iso = ne_oriented( ); - cout << "Triangulation::hRefineQA : Intermediate isotropic triangulation contains " << nt( ) - << " triangles" << endl; + cout << "Triangulation::hRefineQA : Intermediate isotropic triangulation contains " << nt( ) << " triangles" << endl; double *minDet = new double[nv_iso]( ); // set to zero double *maxDet = new double[nv_iso]( ); @@ -594,8 +548,7 @@ namespace mir { // refining these edges Tab< Edge > halfEdges; Tab< int > endVertex; - safe_vector< Edge * > - toExcludePtr; // these edges should be excluded from the flipping process + safe_vector< Edge * > toExcludePtr; // these edges should be excluded from the flipping process for (int i = 0; i < ne_iso; i++) { Edge *e = &edges[i]; @@ -617,9 +570,7 @@ namespace mir { continue; } - const int indexw = - vertices - .max_accessed_pos; // index of the mid point between u and v that was just created + const int indexw = vertices.max_accessed_pos; // index of the mid point between u and v that was just created if (exportIntermediateData) { if (extru) { @@ -633,8 +584,7 @@ namespace mir { if (finalRefine) { if (extru && !extrv) { - endVertex[indexw] = - indexv + 1; // "+1" required to distinguish from values initialized to zero + endVertex[indexw] = indexv + 1; // "+1" required to distinguish from values initialized to zero } if (extrv && !extru) { @@ -664,14 +614,12 @@ namespace mir { edges.export_content("edgesBeforeDelaunay.txt"); } - cout << "Triangulation::hRefineQA : Intermediate anisotropic triangulation contains " << nt( ) - << " triangles." << endl; + cout << "Triangulation::hRefineQA : Intermediate anisotropic triangulation contains " << nt( ) << " triangles." << endl; vector< bool > toExclude; toExclude.resize(ne_oriented( )); - for (vector< Edge * >::const_iterator e = toExcludePtr.begin( ); e != toExcludePtr.end( ); - ++e) { + for (vector< Edge * >::const_iterator e = toExcludePtr.begin( ); e != toExcludePtr.end( ); ++e) { if (!(*e)->onBoundary( )) { toExclude[edges.index(*e)] = true; toExclude[edges.index((*e)->getSister( ))] = true; @@ -694,16 +642,13 @@ namespace mir { Edge *e = &edges[i]; const int indexw = vertices.index(e->getu( )); if (endVertex[indexw] > 0) { - e->cut(e->getu( ), &vertices[endVertex[indexw] - 1], edges, vertices, metric, - toExcludePtr); + e->cut(e->getu( ), &vertices[endVertex[indexw] - 1], edges, vertices, metric, toExcludePtr); endVertex[indexw] = 0; movie_frame( ); } } - cout << "Triangulation::hRefineQA : Triangulation contains " << nt( ) - << " triangles after optional refinement (which eliminates the remaining large angles.)" - << endl; + cout << "Triangulation::hRefineQA : Triangulation contains " << nt( ) << " triangles after optional refinement (which eliminates the remaining large angles.)" << endl; } // return; @@ -718,8 +663,7 @@ namespace mir { toExclude.resize(ne_oriented( )); - for (vector< Edge * >::const_iterator e = toExcludePtr.begin( ); e != toExcludePtr.end( ); - ++e) { + for (vector< Edge * >::const_iterator e = toExcludePtr.begin( ); e != toExcludePtr.end( ); ++e) { if (!(*e)->onBoundary( )) { toExclude[edges.index(*e)] = true; toExclude[edges.index((*e)->getSister( ))] = true; @@ -727,8 +671,7 @@ namespace mir { } Delaunay_ordered(toExclude); - cout << "Triangulation::hRefineQA : Final triangulation contains " << nt( ) - << " triangles after refinement of the boundary." << endl; + cout << "Triangulation::hRefineQA : Final triangulation contains " << nt( ) << " triangles after refinement of the boundary." << endl; } Fem2D::Mesh *Triangulation::export_to_Mesh( ) const { @@ -840,8 +783,7 @@ namespace mir { for (int i = 0; i < ne_oriented( ); i++) { if (edges[i].isRepresentative3(triangle)) { - data_out << 1 + vertices.index(triangle[0]) << " " << 1 + vertices.index(triangle[1]) << " " - << 1 + vertices.index(triangle[2]) << " " << 0 << endl; + data_out << 1 + vertices.index(triangle[0]) << " " << 1 + vertices.index(triangle[1]) << " " << 1 + vertices.index(triangle[2]) << " " << 0 << endl; } } @@ -855,11 +797,9 @@ namespace mir { } #ifdef _FLAGGED_BOUNDARY_ - data_out << 1 + vertices.index(e.getu( )) << " " << 1 + vertices.index(e.getv( )) << " " - << e.onBoundary( ) << endl; + data_out << 1 + vertices.index(e.getu( )) << " " << 1 + vertices.index(e.getv( )) << " " << e.onBoundary( ) << endl; #else - data_out << 1 + vertices.index(e.getu( )) << " " << 1 + vertices.index(e.getv( )) << " " << 1 - << endl; + data_out << 1 + vertices.index(e.getu( )) << " " << 1 + vertices.index(e.getv( )) << " " << 1 << endl; #endif } @@ -914,14 +854,11 @@ namespace mir { #ifdef _FLAGGED_BOUNDARY_ Edge *const sister = (i == ip) ? NULL : &edges[3 * ip + jp]; const int ui = Th(i, (j + 1) % 3), vi = Th(i, (j + 2) % 3); - const std::map< pair< int, int >, int >::iterator it = - BorderElementLabels.find(pair< int, int >(ui, vi)); + const std::map< pair< int, int >, int >::iterator it = BorderElementLabels.find(pair< int, int >(ui, vi)); const int label = (it == BorderElementLabels.end( )) ? 0 : it->second; - edges[3 * i + j] = - Edge(&vertices[ui], &vertices[vi], sister, &edges[3 * i + (j + 1) % 3], label); + edges[3 * i + j] = Edge(&vertices[ui], &vertices[vi], sister, &edges[3 * i + (j + 1) % 3], label); #else - edges[3 * i + j] = Edge(&vertices[Th(i, (j + 1) % 3)], &vertices[Th(i, (j + 2) % 3)], - i == ip ? NULL : &edges[3 * ip + jp], &edges[3 * i + (j + 1) % 3]); + edges[3 * i + j] = Edge(&vertices[Th(i, (j + 1) % 3)], &vertices[Th(i, (j + 2) % 3)], i == ip ? NULL : &edges[3 * ip + jp], &edges[3 * i + (j + 1) % 3]); #endif } } diff --git a/plugin/seq/Helmholtz_FD.cpp b/plugin/seq/Helmholtz_FD.cpp index 644453dec..1c669de70 100644 --- a/plugin/seq/Helmholtz_FD.cpp +++ b/plugin/seq/Helmholtz_FD.cpp @@ -11,753 +11,446 @@ #include "ff++.hpp" double wtab[2752] = { -3.00, 0.697262824, 0.007167050, 0.015915025, 0.008594321, 0.307393283, 0.627489984, 0.065116704, -3.05, 0.628711581, 0.019996662, 0.020661540, 0.000421245, 0.196920782, 0.647126138, 0.155953109, -3.10, 0.702129424, 0.007504661, 0.015171047, 0.008848755, 0.301299810, 0.633790970, 0.064909220, -3.15, 0.597348213, 0.041101128, 0.008118212, 0.007328309, 0.093332671, 0.824724078, 0.081943274, -3.20, 0.661647201, 0.027431741, 0.006051943, 0.012642380, 0.182384640, 0.794680238, 0.022935152, -3.25, 0.590004981, 0.035895996, 0.015874669, 0.000515377, 0.099336565, 0.759529948, 0.141133487, -3.30, 0.684338808, 0.015859213, 0.012579773, 0.008693581, 0.233117074, 0.703543723, 0.063339174, -3.35, 0.669184208, 0.011757366, 0.020814210, 0.001312636, 0.247642487, 0.613769174, 0.138588309, -3.40, 0.605685830, 0.037952259, 0.010843948, 0.004559156, 0.106312215, 0.794963479, 0.098724306, -3.45, 0.577374458, 0.051351979, 0.004654191, 0.007332921, 0.049069352, 0.873899043, 0.077031612, -3.50, 0.730903447, 0.008098722, 0.009822279, 0.012829609, 0.288530648, 0.673810482, 0.037658870, -3.55, 0.732483745, 0.009664774, 0.008094728, 0.014048859, 0.271239400, 0.705184042, 0.023576558, -3.60, 0.549728930, 0.054577745, 0.009134758, 0.001648435, 0.037431475, 0.838261247, 0.124307275, -3.65, 0.588351130, 0.043233294, 0.011057518, 0.002444860, 0.092888221, 0.790881932, 0.116229832, -3.70, 0.593093634, 0.045007516, 0.008323755, 0.004622025, 0.089279830, 0.814085007, 0.096635163, -3.75, 0.705916226, 0.023702361, 0.001588978, 0.016600234, 0.207035929, 0.783495188, 0.009468913, -3.80, 0.644065440, 0.033188105, 0.007746205, 0.007981434, 0.152613044, 0.772635043, 0.074751914, -3.85, 0.686284721, 0.022006951, 0.008582693, 0.009835158, 0.199806958, 0.739966452, 0.060226619, -3.90, 0.723992169, 0.011347204, 0.009974223, 0.011029242, 0.241037920, 0.706667662, 0.052294433, -3.95, 0.740161359, 0.010516703, 0.006949648, 0.014167830, 0.250821084, 0.716488242, 0.032690644, -4.00, 0.642623544, 0.039591655, 0.002390578, 0.011392448, 0.130669326, 0.820143163, 0.049187481, -4.05, 0.751542628, 0.013616130, 0.001332268, 0.018846672, 0.239774108, 0.758091807, 0.002134085, -4.10, 0.661690295, 0.024728056, 0.012804141, 0.004536461, 0.177133024, 0.727850020, 0.095016956, -4.15, 0.705562830, 0.019282497, 0.007421181, 0.011211002, 0.205830038, 0.740188360, 0.053981602, -4.20, 0.705840707, 0.019233696, 0.007550273, 0.011019230, 0.204900950, 0.739971042, 0.055127978, -4.25, 0.739306688, 0.015376367, 0.003157761, 0.016317748, 0.224924207, 0.749649525, 0.025426269, -4.30, 0.739022791, 0.014730528, 0.004004352, 0.015567727, 0.226050586, 0.742380440, 0.031568944, -4.35, 0.709601521, 0.021181472, 0.005025975, 0.012874743, 0.197820157, 0.756129682, 0.046050131, -4.40, 0.669521511, 0.030052802, 0.006280851, 0.009348935, 0.167438671, 0.764807403, 0.067753911, -4.45, 0.728317499, 0.012321327, 0.009424124, 0.010583131, 0.221986711, 0.716708302, 0.061304986, -4.50, 0.672598481, 0.025759801, 0.010038640, 0.006547378, 0.177590564, 0.739277303, 0.083132148, -4.55, 0.637889147, 0.032052111, 0.012512553, 0.002455944, 0.157799035, 0.735930085, 0.106270909, -4.60, 0.679027796, 0.019366715, 0.015022421, 0.003062855, 0.189626575, 0.710654736, 0.099718690, -4.65, 0.755430341, 0.002795290, 0.012594124, 0.009583555, 0.242896020, 0.689434111, 0.067669868, -4.70, 0.735527098, 0.009054719, 0.011400590, 0.009167189, 0.223600373, 0.706640780, 0.069758832, -4.75, 0.685611308, 0.024061970, 0.008955622, 0.007818676, 0.184873581, 0.736821055, 0.078305364, -4.80, 0.661247611, 0.027647898, 0.011559054, 0.004269544, 0.168490216, 0.738675535, 0.092834234, -4.85, 0.649699926, 0.038785405, 0.003384510, 0.009621690, 0.145459771, 0.786229610, 0.068310618, -4.90, 0.600613177, 0.043000001, 0.011522740, 0.000389241, 0.128073946, 0.761512101, 0.110413969, -4.95, 0.731156349, 0.010320447, 0.011637069, 0.008409517, 0.216091290, 0.708488405, 0.075420320, -5.00, 0.643246651, 0.035132140, 0.008888522, 0.004912280, 0.153290153, 0.756346762, 0.090363085, -5.05, 0.718462586, 0.023937641, 0.001353388, 0.015208865, 0.189178646, 0.763775110, 0.047046244, -5.10, 0.728470743, 0.006253866, 0.016604763, 0.004343614, 0.218121752, 0.690121174, 0.091757059, -5.15, 0.677486539, 0.027201064, 0.008469470, 0.007209180, 0.175213560, 0.743366539, 0.081419885, -5.20, 0.736674428, 0.007843078, 0.013100819, 0.007382160, 0.216894522, 0.702840269, 0.080265224, -5.25, 0.730766773, 0.001002725, 0.021477260, 0.000686221, 0.225052625, 0.668507040, 0.106440365, -5.30, 0.686039031, 0.024262933, 0.009459300, 0.006858972, 0.181184858, 0.735759377, 0.083055735, -5.35, 0.720685959, 0.006757588, 0.018372390, 0.002287479, 0.213174522, 0.687094331, 0.099731147, -5.40, 0.643997490, 0.035632249, 0.008720243, 0.004695763, 0.155371577, 0.753929377, 0.090699077, -5.45, 0.593268335, 0.055888854, 0.001214772, 0.007102661, 0.115290038, 0.804074764, 0.080635190, -5.50, 0.716838837, 0.005793421, 0.020465158, 0.000352343, 0.212645128, 0.680675685, 0.106679201, -5.55, 0.697915971, 0.022620669, 0.008426502, 0.008155249, 0.181773081, 0.741187036, 0.077039897, -5.60, 0.592262268, 0.050731108, 0.006785112, 0.002741219, 0.126978710, 0.776069999, 0.096951306, -5.65, 0.734041989, 0.003035368, 0.019082792, 0.002344036, 0.215238228, 0.687019885, 0.097741902, -5.70, 0.556647241, 0.063052624, 0.003463144, 0.002934910, 0.107175194, 0.796392262, 0.096432567, -5.75, 0.710051417, 0.016367614, 0.011842607, 0.006203953, 0.193122923, 0.721730053, 0.085147023, -5.80, 0.706029475, 0.012037156, 0.017226923, 0.001878064, 0.196718752, 0.704768419, 0.098512828, -5.85, 0.654612601, 0.036256686, 0.005908306, 0.007118452, 0.158143133, 0.759888172, 0.081968665, -5.90, 0.638387680, 0.045784108, 0.000482990, 0.010138975, 0.145752400, 0.780688822, 0.073558748, -5.95, 0.765625477, 0.009006737, 0.005495900, 0.014297913, 0.209866196, 0.729331076, 0.060802758, -6.00, 0.644492924, 0.038544871, 0.006277613, 0.006113311, 0.156966522, 0.756561697, 0.086471796, -6.05, 0.699514270, 0.014493953, 0.016615160, 0.001767512, 0.191459492, 0.710442722, 0.098097801, -6.10, 0.735310376, 0.000916126, 0.021286702, 0.000469059, 0.213263273, 0.684441924, 0.102294803, -6.15, 0.737085044, 0.019869011, 0.001928771, 0.015069457, 0.193129137, 0.745510876, 0.061360002, -6.20, 0.635766864, 0.033920370, 0.013246342, 0.000219352, 0.160126776, 0.737914145, 0.101959050, -6.25, 0.694312274, 0.017446823, 0.015117271, 0.002449943, 0.185918257, 0.718855798, 0.095225930, -6.30, 0.716026843, 0.015522248, 0.011648934, 0.006381558, 0.190181285, 0.725651085, 0.084167659, -6.35, 0.725953043, 0.008335987, 0.016386669, 0.003423875, 0.200004071, 0.707276762, 0.092719138, -6.40, 0.671939135, 0.030642044, 0.007625898, 0.006587229, 0.170570269, 0.744471550, 0.084958196, -6.45, 0.731507123, 0.006026622, 0.017375994, 0.002977652, 0.205093756, 0.699757218, 0.095149040, -6.50, 0.775374591, 0.009834517, 0.002630318, 0.016756810, 0.205848545, 0.734423161, 0.059728265, -6.55, 0.737466514, 0.001978302, 0.020002356, 0.001329426, 0.208096489, 0.693314075, 0.098589420, -6.60, 0.724905312, 0.007886129, 0.017260177, 0.002581974, 0.201022938, 0.703096569, 0.095880508, -6.65, 0.642845452, 0.031919204, 0.013781587, 0.000032535, 0.163961738, 0.736084521, 0.099953711, -6.70, 0.627521098, 0.039608911, 0.009952100, 0.001925030, 0.155569673, 0.748877347, 0.095552981, -6.75, 0.727513790, 0.021901295, 0.002691241, 0.013597943, 0.186210811, 0.745026588, 0.068762600, -6.80, 0.736520290, 0.021667169, 0.000693249, 0.015644714, 0.189341038, 0.745036721, 0.065622211, -6.85, 0.703413725, 0.026231050, 0.004436190, 0.010745712, 0.180602312, 0.742578208, 0.076819479, -6.90, 0.707485795, 0.029000759, 0.000674026, 0.013802667, 0.176528722, 0.754408419, 0.069062889, -6.95, 0.683170557, 0.019828230, 0.015959816, 0.000792783, 0.180165887, 0.722622693, 0.097211421, -7.00, 0.741733968, 0.000309452, 0.020857314, 0.000765193, 0.205371931, 0.696482182, 0.098145902, -7.05, 0.733277380, 0.018847374, 0.004457326, 0.012518808, 0.189332068, 0.737355947, 0.073311985, -7.10, 0.686947584, 0.020329216, 0.014589685, 0.002000112, 0.181159586, 0.723943591, 0.094896793, -7.15, 0.763238966, 0.008346494, 0.007512387, 0.012066679, 0.201269120, 0.723774552, 0.074956298, -7.20, 0.755818844, 0.016949568, 0.000800188, 0.016610187, 0.190597326, 0.745290041, 0.064112663, -7.25, 0.684460104, 0.033079147, 0.002528107, 0.010840966, 0.172526523, 0.749671519, 0.077801943, -7.30, 0.780553758, 0.005270217, 0.006330614, 0.013982195, 0.201851696, 0.728019595, 0.070128679, -7.35, 0.720273495, 0.017769041, 0.008928446, 0.008246363, 0.190375119, 0.725288272, 0.084336638, -7.40, 0.691181540, 0.033674657, 0.000313735, 0.012875712, 0.170473114, 0.756505847, 0.073021054, -7.45, 0.724639952, 0.017434690, 0.008219006, 0.009015479, 0.185226962, 0.734799385, 0.079973638, -7.50, 0.650077581, 0.035191968, 0.009118620, 0.003668396, 0.170341194, 0.736124039, 0.093534768, -7.55, 0.698249280, 0.018233035, 0.014053045, 0.002964497, 0.182294697, 0.725737393, 0.091967881, -7.60, 0.732726693, 0.003651323, 0.020039063, 0.000612076, 0.198038265, 0.704833031, 0.097128689, -7.65, 0.785859823, 0.010407180, 0.000015683, 0.018938612, 0.203314006, 0.730436444, 0.066249549, -7.70, 0.592862785, 0.049690478, 0.009004613, 0.000117376, 0.144601583, 0.761113882, 0.094284534, -7.75, 0.605973721, 0.051153421, 0.004281623, 0.004465784, 0.155343205, 0.752932906, 0.091723919, -7.80, 0.789317489, 0.002593447, 0.007029239, 0.013846369, 0.205384582, 0.720143259, 0.074472129, -7.85, 0.706174791, 0.016937090, 0.013491407, 0.003788223, 0.182299182, 0.728245080, 0.089455724, -7.90, 0.666150868, 0.038350385, 0.002098883, 0.009820030, 0.162583888, 0.759026945, 0.078389168, -7.95, 0.799540281, 0.003311466, 0.003811127, 0.016857177, 0.200973064, 0.731083333, 0.067943633, -8.00, 0.680162311, 0.022954039, 0.014026556, 0.001724347, 0.172286659, 0.736675143, 0.091038227, -8.05, 0.759831607, 0.004041791, 0.013042748, 0.007425584, 0.194693774, 0.722206652, 0.083099544, -8.10, 0.718426704, 0.026699424, 0.000747219, 0.014051266, 0.178020686, 0.748722494, 0.073256791, -8.15, 0.651540279, 0.037407469, 0.006764994, 0.005354373, 0.165006176, 0.747445941, 0.087547898, -8.20, 0.614697039, 0.043270975, 0.010134578, 0.000507772, 0.162323758, 0.740480542, 0.097195685, -8.25, 0.625735939, 0.049280617, 0.001384329, 0.007746050, 0.159123883, 0.755485237, 0.085390866, -8.30, 0.725445449, 0.019521395, 0.006236922, 0.010322889, 0.184575632, 0.734737873, 0.080686510, -8.35, 0.653648674, 0.039499819, 0.004212866, 0.007349753, 0.161582902, 0.755483210, 0.082933903, -8.40, 0.697551310, 0.032635413, 0.000126698, 0.013139479, 0.174316034, 0.749188185, 0.076495767, -8.45, 0.756601036, 0.007870061, 0.010133540, 0.009322015, 0.195246026, 0.721213520, 0.083540440, -8.50, 0.686896741, 0.019905558, 0.015535688, 0.000905208, 0.182542026, 0.721521914, 0.095936060, -8.55, 0.692634821, 0.028701732, 0.005328579, 0.008901480, 0.168360725, 0.752613902, 0.079025388, -8.60, 0.709603131, 0.025053587, 0.004741546, 0.010397101, 0.176766813, 0.743414402, 0.079818785, -8.65, 0.562588334, 0.062730834, 0.003832389, 0.001879750, 0.144731358, 0.763089716, 0.092178941, -8.70, 0.709370255, 0.015403642, 0.014482113, 0.003052816, 0.176666811, 0.736030579, 0.087302625, -8.75, 0.567155123, 0.058938250, 0.006502643, 0.000147957, 0.153613403, 0.748631060, 0.097755551, -8.80, 0.757969081, 0.005018137, 0.012737557, 0.007383926, 0.196088552, 0.717094302, 0.086817145, -8.85, 0.637681782, 0.041443706, 0.006406926, 0.004596610, 0.167452842, 0.742133498, 0.090413690, -8.90, 0.696166277, 0.022483753, 0.010752261, 0.004988009, 0.171393678, 0.744028687, 0.084577620, -8.95, 0.641492724, 0.038330950, 0.008586541, 0.003185386, 0.164259881, 0.746261537, 0.089478552, -9.00, 0.744261920, 0.014480891, 0.006752837, 0.010977335, 0.185281217, 0.734718859, 0.079999924, -9.05, 0.604861915, 0.054672804, 0.001425516, 0.006249385, 0.154924199, 0.758761585, 0.086314201, -9.10, 0.734394789, 0.011045747, 0.012673132, 0.005906643, 0.182829916, 0.732042849, 0.085127234, -9.15, 0.627262056, 0.046458948, 0.004051410, 0.005670916, 0.164540574, 0.746340811, 0.089118600, -9.20, 0.644625247, 0.042768665, 0.003425462, 0.007207151, 0.162356779, 0.753559232, 0.084083974, -9.25, 0.674772859, 0.029341169, 0.009332273, 0.004649106, 0.165553004, 0.750079751, 0.084367275, -9.30, 0.655452967, 0.033674210, 0.009829640, 0.003068261, 0.180664375, 0.723415256, 0.095920384, -9.35, 0.611765504, 0.053841263, 0.000584934, 0.007270964, 0.162311241, 0.749586463, 0.088102281, -9.40, 0.606882989, 0.054846037, 0.000811920, 0.006787218, 0.162672743, 0.748103857, 0.089223385, -9.45, 0.632426262, 0.038748465, 0.010535475, 0.001082156, 0.171522275, 0.732932031, 0.095545709, -9.50, 0.729691505, 0.020070985, 0.004907718, 0.011373746, 0.187783867, 0.728058815, 0.084157348, -9.55, 0.670830190, 0.033085611, 0.006625537, 0.006393714, 0.175327137, 0.736235499, 0.088437378, -9.60, 0.687369466, 0.034159482, 0.001422087, 0.011326076, 0.172774851, 0.745992362, 0.081232786, -9.65, 0.731532156, 0.006324587, 0.018232957, 0.001465606, 0.182184324, 0.728429914, 0.089385748, -9.70, 0.647118330, 0.033703547, 0.011964437, 0.000885895, 0.167865753, 0.740575910, 0.091558337, -9.75, 0.720653296, 0.013443928, 0.013856275, 0.004050981, 0.176564664, 0.737988055, 0.085447252, -9.80, 0.733275950, 0.005911957, 0.018226840, 0.001566280, 0.203884900, 0.695576549, 0.100538552, -9.85, 0.560077786, 0.063379243, 0.004070256, 0.001350461, 0.144632742, 0.766947985, 0.088419259, -9.90, 0.762389541, 0.009851214, 0.007040165, 0.011752650, 0.180735469, 0.741924822, 0.077339709, -9.95, 0.724952698, 0.014183916, 0.012079667, 0.005623475, 0.172745883, 0.745286882, 0.081967235, -10.00, 0.798044562, 0.007615812, 0.000370339, 0.018977063, 0.180253074, 0.751583099, 0.068163812, -10.05, 0.707427442, 0.020877384, 0.009771857, 0.006255746, 0.173551977, 0.742345214, 0.084102809, -10.10, 0.714741707, 0.015042767, 0.013780370, 0.003704656, 0.178732216, 0.733217955, 0.088049829, -10.15, 0.796544731, 0.007786527, 0.000610150, 0.018676788, 0.189338237, 0.736833274, 0.073828518, -10.20, 0.752726078, 0.003241500, 0.016112743, 0.004309002, 0.186903670, 0.725375235, 0.087721109, -10.25, 0.600836337, 0.050188489, 0.007147860, 0.001532299, 0.166097417, 0.739989996, 0.093912601, -10.30, 0.624425650, 0.045098323, 0.006333862, 0.003622258, 0.155066222, 0.760279775, 0.084653974, -10.35, 0.622179627, 0.051377967, 0.000629879, 0.007749252, 0.176270604, 0.731271684, 0.092457712, -10.40, 0.687915444, 0.032495048, 0.003079327, 0.010020294, 0.189899549, 0.718322694, 0.091777742, -10.45, 0.510093689, 0.079129308, 0.000900544, 0.000540491, 0.157060981, 0.744453490, 0.098485529, -10.50, 0.775071323, 0.006995384, 0.006808441, 0.012656884, 0.198624194, 0.715105593, 0.086270213, -10.55, 0.759528875, 0.014222167, 0.003486849, 0.014161991, 0.191726848, 0.725146830, 0.083126307, -10.60, 0.671943724, 0.027052635, 0.012567002, 0.001867054, 0.156989917, 0.761320829, 0.081689239, -10.65, 0.735664845, 0.016404569, 0.007293276, 0.009798553, 0.177687928, 0.741255939, 0.081056118, -10.70, 0.687610447, 0.031170320, 0.004536416, 0.008866331, 0.163551867, 0.757252872, 0.079195261, -10.75, 0.674482584, 0.034131497, 0.004854865, 0.007808756, 0.160787880, 0.759333372, 0.079878747, -10.80, 0.713703215, 0.019295909, 0.009910833, 0.006448917, 0.187074989, 0.722675264, 0.090249717, -10.85, 0.666478634, 0.039197810, 0.001810361, 0.009576272, 0.193670183, 0.710409224, 0.095920622, -10.90, 0.538286209, 0.070543654, 0.002511822, 0.001038749, 0.170275599, 0.728904247, 0.100820184, -10.95, 0.722132862, 0.019914761, 0.007202789, 0.008993138, 0.179133967, 0.736895561, 0.083970487, -11.00, 0.775188446, 0.002110202, 0.011726528, 0.008928999, 0.179489613, 0.740018725, 0.080491662, -11.05, 0.660312831, 0.034631196, 0.007956591, 0.004552612, 0.164969057, 0.750347555, 0.084683359, -11.10, 0.570146918, 0.064826190, 0.000298418, 0.004664365, 0.154196918, 0.759139419, 0.086663663, -11.15, 0.763172686, 0.010062631, 0.006793454, 0.011866260, 0.185430080, 0.731678963, 0.082890987, -11.20, 0.714733124, 0.023543930, 0.005441414, 0.009838291, 0.169459432, 0.750653207, 0.079887331, -11.25, 0.604502499, 0.054907538, 0.001629133, 0.005812833, 0.176099509, 0.729095876, 0.094804585, -11.30, 0.641456842, 0.041145757, 0.006178096, 0.004691433, 0.161805794, 0.753731728, 0.084462464, -11.35, 0.728042305, 0.011284340, 0.014400549, 0.003930632, 0.206198439, 0.692909837, 0.100891709, -11.40, 0.771990716, 0.006124873, 0.008567598, 0.011056108, 0.211238742, 0.692720175, 0.096041083, -11.45, 0.741813183, 0.018255446, 0.003990404, 0.012596160, 0.170166343, 0.753319442, 0.076514184, -11.50, 0.653191566, 0.034932330, 0.009476501, 0.002937054, 0.183023959, 0.721411407, 0.095564663, -11.55, 0.664150715, 0.037255630, 0.004418969, 0.007410984, 0.183044419, 0.725021720, 0.091933846, -11.60, 0.758137107, 0.010300789, 0.007876605, 0.010692362, 0.161637321, 0.766097665, 0.072265029, -11.65, 0.697066844, 0.027567523, 0.005878599, 0.008373103, 0.193790779, 0.711349308, 0.094859898, -11.70, 0.664852500, 0.035381313, 0.006123699, 0.006171905, 0.167638406, 0.747312129, 0.085049450, -11.75, 0.730120420, 0.022711206, 0.002495445, 0.012958374, 0.180838555, 0.736388803, 0.082772613, -11.80, 0.706266522, 0.013552571, 0.017629609, 0.000107843, 0.182957873, 0.724156797, 0.092885315, -11.85, 0.675682306, 0.029335268, 0.009470142, 0.004333047, 0.186431378, 0.718340933, 0.095227659, -11.90, 0.604786634, 0.053452924, 0.003083225, 0.004687140, 0.164481729, 0.746950388, 0.088567853, -11.95, 0.692369878, 0.020273544, 0.014371768, 0.001690956, 0.161582887, 0.755657673, 0.082759440, -12.00, 0.694708109, 0.024061449, 0.010019578, 0.005086033, 0.196226329, 0.705950379, 0.097823262, -12.05, 0.732194602, 0.018152002, 0.006576806, 0.009996463, 0.162121847, 0.762985051, 0.074893117, -12.10, 0.704596221, 0.024311692, 0.007303685, 0.007736176, 0.176067069, 0.738277316, 0.085655630, -12.15, 0.656632245, 0.032063607, 0.011563718, 0.001527686, 0.182731122, 0.722112954, 0.095155895, -12.20, 0.657639384, 0.030910037, 0.012439933, 0.000952650, 0.170832738, 0.739240587, 0.089926660, -12.25, 0.660332799, 0.042318996, 0.000362214, 0.010175833, 0.201920643, 0.697218537, 0.100860834, -12.30, 0.651309133, 0.035345394, 0.009614673, 0.002655303, 0.154171154, 0.765324533, 0.080504298, -12.35, 0.725657940, 0.007373217, 0.019000620, 0.000261914, 0.150716364, 0.773906052, 0.075377584, -12.40, 0.568968117, 0.064499371, 0.001060508, 0.003913697, 0.176366925, 0.727344036, 0.096289039, -12.45, 0.744530499, 0.012033693, 0.009616859, 0.008483129, 0.191205174, 0.718115389, 0.090679467, -12.50, 0.741482973, 0.020216513, 0.002212025, 0.013834205, 0.212230474, 0.689047694, 0.098721862, -12.55, 0.614267528, 0.046104338, 0.008125730, 0.001449712, 0.135747001, 0.789840996, 0.074411988, -12.60, 0.567347109, 0.064327240, 0.001639552, 0.003376853, 0.132098824, 0.793565631, 0.074335575, -12.65, 0.673445702, 0.031689785, 0.007764861, 0.005404657, 0.184797153, 0.721658289, 0.093544543, -12.70, 0.652556658, 0.039481007, 0.005214557, 0.005997827, 0.140404761, 0.788059235, 0.071536005, -12.75, 0.725125432, 0.019086789, 0.007456597, 0.008859335, 0.192517981, 0.715334713, 0.092147291, -12.80, 0.661961317, 0.036234725, 0.006078526, 0.005961001, 0.193772078, 0.707414925, 0.098812997, -12.85, 0.642713308, 0.040332936, 0.006833710, 0.004160570, 0.175249681, 0.734277964, 0.090472341, -12.90, 0.738380969, 0.022402726, 0.000840865, 0.014639037, 0.181741714, 0.734712362, 0.083545923, -12.95, 0.704517722, 0.029127352, 0.002580315, 0.011219298, 0.192632750, 0.714637876, 0.092729390, -13.00, 0.630471587, 0.042491749, 0.007730529, 0.002726447, 0.201483369, 0.692733884, 0.105782747, -13.05, 0.710673630, 0.013418403, 0.016751640, 0.000974536, 0.182054922, 0.725996017, 0.091949046, -13.10, 0.614334285, 0.047275580, 0.006991714, 0.002263956, 0.135865241, 0.790625811, 0.073508978, -13.15, 0.721841455, 0.013219237, 0.014152825, 0.003626153, 0.209482580, 0.686300099, 0.104217350, -13.20, 0.691670477, 0.027179100, 0.007770687, 0.006500835, 0.196792960, 0.705630720, 0.097576320, -13.25, 0.687379479, 0.026573107, 0.009438056, 0.004990650, 0.184179202, 0.723533928, 0.092286885, -13.30, 0.585538507, 0.055487428, 0.006006163, 0.001182871, 0.170805782, 0.736575484, 0.092618704, -13.35, 0.557284057, 0.065956786, 0.002590083, 0.001986779, 0.115980469, 0.817647934, 0.066371620, -13.40, 0.629613340, 0.046451196, 0.004014723, 0.005437851, 0.216535300, 0.671440601, 0.112024069, -13.45, 0.694086432, 0.025263757, 0.009069107, 0.005687717, 0.177962780, 0.733235180, 0.088802040, -13.50, 0.699766278, 0.031556524, 0.001361847, 0.011819052, 0.183224946, 0.728090286, 0.088684797, -13.55, 0.786130905, 0.005859770, 0.005491737, 0.014101204, 0.181184083, 0.737541556, 0.081274390, -13.60, 0.652902365, 0.033395275, 0.011283882, 0.001414925, 0.180976197, 0.725486219, 0.093537569, -13.65, 0.766006589, 0.004718501, 0.011646405, 0.008240692, 0.178020373, 0.737867415, 0.084112227, -13.70, 0.638251364, 0.038967464, 0.009348910, 0.001969615, 0.176437631, 0.731100321, 0.092462063, -13.75, 0.772822976, 0.012917720, 0.001787543, 0.016027523, 0.160995126, 0.768132389, 0.070872486, -13.80, 0.795924425, 0.000001829, 0.008934669, 0.012106072, 0.190788224, 0.722572505, 0.086639285, -13.85, 0.712637007, 0.016933046, 0.012837119, 0.003964910, 0.147839814, 0.779684186, 0.072476029, -13.90, 0.760183096, 0.012833025, 0.005038776, 0.012794182, 0.207206726, 0.696023166, 0.096770108, -13.95, 0.762026608, 0.006793361, 0.010581672, 0.008779146, 0.176248670, 0.740152180, 0.083599150, -14.00, 0.622943103, 0.049167890, 0.002990570, 0.005770339, 0.192139506, 0.708034217, 0.099826276, -14.05, 0.655722380, 0.034870993, 0.009125449, 0.003193285, 0.160878703, 0.756313086, 0.082808197, -14.10, 0.749844611, 0.001728453, 0.018717691, 0.001896547, 0.207903415, 0.689705551, 0.102391064, -14.15, 0.661753058, 0.037709214, 0.004778191, 0.006831670, 0.127366021, 0.808602035, 0.064031959, -14.20, 0.739294708, 0.011356346, 0.011732958, 0.006471464, 0.234153181, 0.651235938, 0.114610910, -14.25, 0.634925187, 0.040906936, 0.008267399, 0.002553051, 0.216608196, 0.670806050, 0.112585783, -14.30, 0.701252997, 0.030390240, 0.002241876, 0.011187881, 0.131804764, 0.806049347, 0.062145889, -14.35, 0.693837583, 0.027424246, 0.007052854, 0.007122837, 0.187389433, 0.719810724, 0.092799842, -14.40, 0.740905762, 0.012758359, 0.009970337, 0.007862505, 0.139310777, 0.795475006, 0.065214217, -14.45, 0.557903051, 0.064275920, 0.004200913, 0.000753809, 0.118169531, 0.815466285, 0.066364169, -14.50, 0.731989861, 0.023698390, 0.001226645, 0.013887508, 0.204852939, 0.697666109, 0.097480953, -14.55, 0.691941023, 0.021373324, 0.013592146, 0.002089160, 0.192151889, 0.710774899, 0.097073197, -14.60, 0.715600729, 0.018532384, 0.010501079, 0.005899001, 0.238085568, 0.643515944, 0.118398488, -14.65, 0.665756524, 0.037001684, 0.004498050, 0.007282097, 0.221598089, 0.666820526, 0.111581385, -14.70, 0.813443482, 0.002553128, 0.002032824, 0.018355483, 0.107158706, 0.850097120, 0.042744160, -14.75, 0.654727817, 0.036766671, 0.007522210, 0.004300704, 0.131008983, 0.802157104, 0.066833913, -14.80, 0.712311208, 0.019010223, 0.010858625, 0.005415494, 0.237628162, 0.643984616, 0.118387222, -14.85, 0.631842852, 0.044723153, 0.005263939, 0.004581369, 0.176134318, 0.732930183, 0.090935469, -14.90, 0.788987398, 0.005129345, 0.005603261, 0.014124675, 0.113090716, 0.838817120, 0.048092186, -14.95, 0.731478393, 0.011042636, 0.014062844, 0.004188959, 0.204681426, 0.694767416, 0.100551188, -15.00, 0.610909045, 0.052865371, 0.002360716, 0.005446266, 0.269968808, 0.590892971, 0.139138222, -15.05, 0.681244493, 0.034889691, 0.002788819, 0.009493941, 0.122827619, 0.817575455, 0.059596896, -15.10, 0.657367587, 0.035538077, 0.008087836, 0.004043739, 0.211652040, 0.680156767, 0.108191192, -15.15, 0.705144286, 0.024954692, 0.006725430, 0.008052800, 0.230219781, 0.655712485, 0.114067733, -15.20, 0.585954130, 0.059651062, 0.001803875, 0.004311625, 0.230894089, 0.647958457, 0.121147454, -15.25, 0.734103143, 0.010396499, 0.014068563, 0.004336888, 0.096027374, 0.858532667, 0.045439959, -15.30, 0.762889147, 0.012897201, 0.004345894, 0.013447115, 0.238814890, 0.647345304, 0.113839805, -15.35, 0.785427213, 0.001071531, 0.010575417, 0.010154823, 0.105150782, 0.849067211, 0.045782030, -15.40, 0.599935174, 0.054319710, 0.003700614, 0.003717400, 0.192676768, 0.707337499, 0.099985719, -15.45, 0.702837944, 0.022892334, 0.009386800, 0.005895806, 0.138957024, 0.792599559, 0.068443418, -15.50, 0.717270851, 0.019445341, 0.009251539, 0.006879831, 0.105226934, 0.844815135, 0.049957931, -15.55, 0.643918097, 0.034871936, 0.012149259, 0.000132397, 0.169413224, 0.742629766, 0.087957025, -15.60, 0.657019794, 0.030519485, 0.013233595, 0.000132520, 0.206523865, 0.687374592, 0.106101513, -15.65, 0.820778728, 0.002432294, 0.000391729, 0.019990845, 0.214031368, 0.689449608, 0.096519053, -15.70, 0.712360203, 0.014742196, 0.015155707, 0.002164768, 0.086967207, 0.869690895, 0.043341875, -15.75, 0.758473217, 0.014070660, 0.004303962, 0.013181910, 0.117252827, 0.829569757, 0.053177416, -15.80, 0.797629535, 0.003610317, 0.005003586, 0.015083190, 0.085234165, 0.880431414, 0.034334421, -15.85, 0.606994927, 0.049409047, 0.006832600, 0.001819950, 0.259119332, 0.606001198, 0.134879470, -15.90, 0.728422642, 0.021804363, 0.004080050, 0.011473823, 0.167868003, 0.751412511, 0.080719471, -15.95, 0.660934091, 0.029669285, 0.013116829, 0.000456031, 0.101408489, 0.845859706, 0.052731812, -16.00, 0.583330154, 0.059098411, 0.003092103, 0.003121767, 0.065101810, 0.898198545, 0.036699653, -16.05, 0.729344666, 0.009877689, 0.015782207, 0.002750339, 0.097509377, 0.854663551, 0.047827065, -16.10, 0.664115787, 0.036239594, 0.005744293, 0.006189391, 0.253785998, 0.618475318, 0.127738714, -16.15, 0.665620923, 0.040300131, 0.001300715, 0.009621214, 0.122263148, 0.816855431, 0.060881436, -16.20, 0.635851383, 0.039581127, 0.009472668, 0.001623729, 0.186156929, 0.717675388, 0.096167684, -16.25, 0.685067058, 0.028111853, 0.008652397, 0.005304134, 0.254521728, 0.617781579, 0.127696693, -16.30, 0.671372652, 0.030012012, 0.010172911, 0.003310043, 0.114655226, 0.827525616, 0.057819128, -16.35, 0.726615489, 0.015679982, 0.010661013, 0.006421559, 0.284637600, 0.573571861, 0.141790569, -16.40, 0.721436799, 0.013165165, 0.014492884, 0.003207199, 0.074668199, 0.888910353, 0.036421478, -16.45, 0.730993748, 0.008924253, 0.016367376, 0.002381528, 0.100111321, 0.851383686, 0.048505008, -16.50, 0.744230330, 0.009316154, 0.012625471, 0.006045887, 0.228459418, 0.658753753, 0.112786829, -16.55, 0.656634033, 0.033359539, 0.010486320, 0.002171613, 0.192051321, 0.709297061, 0.098651648, -16.60, 0.586481631, 0.059042878, 0.002377570, 0.003841281, 0.132757336, 0.797203362, 0.070039332, -16.65, 0.556891322, 0.064664468, 0.004135080, 0.000687614, 0.133038789, 0.794020951, 0.072940290, -16.70, 0.609965086, 0.047400743, 0.008161463, 0.000961613, 0.113637187, 0.826101661, 0.060261130, -16.75, 0.703126192, 0.027283851, 0.004968520, 0.009193556, 0.314621598, 0.528775275, 0.156603158, -16.80, 0.707181990, 0.020819128, 0.010396242, 0.005393542, 0.158002302, 0.762849987, 0.079147696, -16.85, 0.586543202, 0.060893610, 0.000508472, 0.005249184, 0.242736101, 0.631703854, 0.125560045, -16.90, 0.671847463, 0.029319562, 0.010761410, 0.002887281, 0.266909748, 0.598013699, 0.135076582, -16.95, 0.677711248, 0.027613297, 0.010978378, 0.003108554, 0.200138867, 0.698033094, 0.101828039, -17.00, 0.614473045, 0.047937885, 0.006457590, 0.002551071, 0.224051937, 0.659330189, 0.116617858, -17.05, 0.657729983, 0.040971756, 0.002631158, 0.008108199, 0.178897902, 0.730648160, 0.090453923, -17.10, 0.645247698, 0.036719680, 0.010039009, 0.001745764, 0.128549740, 0.804984808, 0.066465437, -17.15, 0.692725956, 0.027247034, 0.007633924, 0.006523093, 0.073470548, 0.891232729, 0.035296738, -17.20, 0.797381878, 0.005097494, 0.003592685, 0.016115118, 0.094806060, 0.864059865, 0.041134059, -17.25, 0.660030425, 0.041451745, 0.001566984, 0.009056913, 0.159856588, 0.759766281, 0.080377162, -17.30, 0.656274498, 0.031263046, 0.012724653, 0.000431424, 0.148459122, 0.774573863, 0.076967001, -17.35, 0.591632664, 0.054071508, 0.006068319, 0.001389809, 0.287512511, 0.563623309, 0.148864150, -17.40, 0.645229876, 0.035259917, 0.011514872, 0.000629019, 0.124189734, 0.812191665, 0.063618600, -17.45, 0.767431259, 0.004138738, 0.012089640, 0.007832579, 0.207188711, 0.692833364, 0.099977911, -17.50, 0.552409530, 0.066802211, 0.003159411, 0.001108032, 0.103992119, 0.839100063, 0.056907833, -17.55, 0.707447410, 0.013888985, 0.017325327, 0.000164345, 0.027229413, 0.959326029, 0.013444543, -17.60, 0.680527985, 0.031931154, 0.006010443, 0.006969972, 0.270029068, 0.594751656, 0.135219276, -17.65, 0.593147099, 0.059047580, 0.000703789, 0.005515244, 0.249358714, 0.622303665, 0.128337622, -17.70, 0.791372776, 0.001141690, 0.009060048, 0.011632064, 0.309629112, 0.539429247, 0.150941670, -17.75, 0.636191726, 0.039019272, 0.009968549, 0.001258757, 0.284562230, 0.569141746, 0.146296024, -17.80, 0.634177327, 0.047534734, 0.001960412, 0.007136166, 0.189328521, 0.714039862, 0.096631587, -17.85, 0.751469970, 0.009154446, 0.011038139, 0.007643210, 0.026480488, 0.963086367, 0.010433137, -17.90, 0.740025282, 0.010362968, 0.012711003, 0.005658109, 0.316992164, 0.525839865, 0.157167971, -17.95, 0.757209301, 0.013814263, 0.004944399, 0.012571542, 0.330267519, 0.507805765, 0.161926687, -18.00, 0.734100580, 0.022811241, 0.001734763, 0.013526851, 0.121345371, 0.821706414, 0.056948185, -18.05, 0.671925068, 0.030377023, 0.009718709, 0.003648536, 0.308862180, 0.534928679, 0.156209111, -18.10, 0.697446406, 0.028571874, 0.005172521, 0.008631513, 0.261955917, 0.608244121, 0.129799962, -18.15, 0.594167173, 0.051826194, 0.007691681, 0.000321936, 0.266372532, 0.595948577, 0.137678862, -18.20, 0.716311574, 0.018721588, 0.010304630, 0.005962918, 0.055592142, 0.918762624, 0.025645256, -18.25, 0.627494872, 0.044425517, 0.006783403, 0.003068898, 0.021238402, 0.966043234, 0.012718379, -18.30, 0.741219163, 0.014386337, 0.008400612, 0.008956935, 0.316946596, 0.526587188, 0.156466186, -18.35, 0.619465053, 0.044087432, 0.009092562, 0.000862453, 0.297963977, 0.548621953, 0.153414071, -18.40, 0.668275893, 0.029096261, 0.011898503, 0.001795564, 0.152027801, 0.769684196, 0.078288019, -18.45, 0.607787192, 0.052782476, 0.003359668, 0.004400242, 0.324847609, 0.509087801, 0.166064620, -18.50, 0.681842446, 0.025724903, 0.011902027, 0.002622977, 0.146746725, 0.779259026, 0.073994219, -18.55, 0.602584243, 0.054031804, 0.003436208, 0.003998805, 0.227249205, 0.656445622, 0.116305172, -18.60, 0.725293398, 0.012602329, 0.014182538, 0.003612772, 0.243743211, 0.635292530, 0.120964289, -18.65, 0.744948864, 0.005532205, 0.016361281, 0.003190316, 0.185577959, 0.723366737, 0.091055274, -18.70, 0.635090709, 0.040398389, 0.008915991, 0.001940884, 0.363265663, 0.451420426, 0.185313940, -18.75, 0.606926322, 0.055156454, 0.001198828, 0.005968627, 0.228418574, 0.654630065, 0.116951346, -18.80, 0.763809443, 0.014296792, 0.002851591, 0.014523840, 0.280339569, 0.583333433, 0.136326969, -18.85, 0.681040287, 0.030004315, 0.007800214, 0.005666407, 0.395757854, 0.404505789, 0.199736357, -18.90, 0.763031721, 0.014851183, 0.002469085, 0.014779020, 0.108509533, 0.840742886, 0.050747573, -18.95, 0.759478509, 0.001530200, 0.016685277, 0.003889620, 0.100917980, 0.849950433, 0.049131572, -19.00, 0.639116704, 0.044296533, 0.004058942, 0.005799599, 0.130327120, 0.803912163, 0.065760732, -19.05, 0.578526258, 0.059787303, 0.003664106, 0.002347581, 0.376217663, 0.430850267, 0.192932069, -19.10, 0.591366351, 0.056888379, 0.003363959, 0.003366981, 0.066996813, 0.896167576, 0.036835611, -19.15, 0.723976731, 0.022388399, 0.004699200, 0.010662809, 0.322976857, 0.516833544, 0.160189629, -19.20, 0.629271090, 0.049999945, 0.000777811, 0.007674441, 0.212360352, 0.679592371, 0.108047247, -19.25, 0.616772532, 0.052926600, 0.001025140, 0.006670773, 0.305292100, 0.540844560, 0.153863311, -19.30, 0.616772532, 0.052926600, 0.001025140, 0.006670773, 0.305292100, 0.540844560, 0.153863311, -19.35, 0.585252821, 0.056075647, 0.005713806, 0.001215953, 0.122264110, 0.812377095, 0.065358818, -19.40, 0.692379653, 0.024560563, 0.010469109, 0.004328458, 0.101609349, 0.847952902, 0.050437748, -19.45, 0.735629797, 0.011300519, 0.012886256, 0.005241502, 0.371529579, 0.442429751, 0.186040670, -19.50, 0.692917943, 0.024151146, 0.010774881, 0.004109576, 0.123248830, 0.815623760, 0.061127424, -19.55, 0.633065999, 0.049031563, 0.000802159, 0.007889837, 0.149906129, 0.774167955, 0.075925887, -19.60, 0.574742436, 0.063080668, 0.001374975, 0.003784232, 0.148704216, 0.774831355, 0.076464415, -19.65, 0.516435742, 0.078251049, 0.000788152, 0.000575017, 0.325059086, 0.507439494, 0.167501450, -19.70, 0.533551931, 0.074311420, 0.000406727, 0.001962353, 0.342934698, 0.480547130, 0.176518142, -19.75, 0.693292737, 0.022411108, 0.012378633, 0.002962127, 0.155473262, 0.766110063, 0.078416705, -19.80, 0.619924605, 0.052569546, 0.000531286, 0.007285334, 0.148478061, 0.774832845, 0.076689124, -19.85, 0.691357553, 0.021407604, 0.013847128, 0.001753911, 0.179279834, 0.730047703, 0.090672493, -19.90, 0.663915038, 0.038511515, 0.003682941, 0.007602572, 0.239249468, 0.641971469, 0.118779063, -19.95, 0.520983577, 0.076073349, 0.001844108, 0.000055879, 0.317512095, 0.519014537, 0.163473368, -20.00, 0.628557563, 0.045759290, 0.005248681, 0.004237816, 0.184951141, 0.720882893, 0.094165981, -20.05, 0.793222070, 0.003329217, 0.006494150, 0.013609104, 0.359128177, 0.464643240, 0.176228583, -20.10, 0.545972228, 0.068722248, 0.002889521, 0.000877503, 0.009620428, 0.981576681, 0.008802891, -20.15 , 0.623136342 , 0.045090564 , 0.007242844 , 0.002425767 , 0.137593195 , 0.791602910 , 0.070803881 -}; + 3.00, 0.697262824, 0.007167050, 0.015915025, 0.008594321, 0.307393283, 0.627489984, 0.065116704, 3.05, 0.628711581, 0.019996662, 0.020661540, 0.000421245, 0.196920782, 0.647126138, 0.155953109, + 3.10, 0.702129424, 0.007504661, 0.015171047, 0.008848755, 0.301299810, 0.633790970, 0.064909220, 3.15, 0.597348213, 0.041101128, 0.008118212, 0.007328309, 0.093332671, 0.824724078, 0.081943274, + 3.20, 0.661647201, 0.027431741, 0.006051943, 0.012642380, 0.182384640, 0.794680238, 0.022935152, 3.25, 0.590004981, 0.035895996, 0.015874669, 0.000515377, 0.099336565, 0.759529948, 0.141133487, + 3.30, 0.684338808, 0.015859213, 0.012579773, 0.008693581, 0.233117074, 0.703543723, 0.063339174, 3.35, 0.669184208, 0.011757366, 0.020814210, 0.001312636, 0.247642487, 0.613769174, 0.138588309, + 3.40, 0.605685830, 0.037952259, 0.010843948, 0.004559156, 0.106312215, 0.794963479, 0.098724306, 3.45, 0.577374458, 0.051351979, 0.004654191, 0.007332921, 0.049069352, 0.873899043, 0.077031612, + 3.50, 0.730903447, 0.008098722, 0.009822279, 0.012829609, 0.288530648, 0.673810482, 0.037658870, 3.55, 0.732483745, 0.009664774, 0.008094728, 0.014048859, 0.271239400, 0.705184042, 0.023576558, + 3.60, 0.549728930, 0.054577745, 0.009134758, 0.001648435, 0.037431475, 0.838261247, 0.124307275, 3.65, 0.588351130, 0.043233294, 0.011057518, 0.002444860, 0.092888221, 0.790881932, 0.116229832, + 3.70, 0.593093634, 0.045007516, 0.008323755, 0.004622025, 0.089279830, 0.814085007, 0.096635163, 3.75, 0.705916226, 0.023702361, 0.001588978, 0.016600234, 0.207035929, 0.783495188, 0.009468913, + 3.80, 0.644065440, 0.033188105, 0.007746205, 0.007981434, 0.152613044, 0.772635043, 0.074751914, 3.85, 0.686284721, 0.022006951, 0.008582693, 0.009835158, 0.199806958, 0.739966452, 0.060226619, + 3.90, 0.723992169, 0.011347204, 0.009974223, 0.011029242, 0.241037920, 0.706667662, 0.052294433, 3.95, 0.740161359, 0.010516703, 0.006949648, 0.014167830, 0.250821084, 0.716488242, 0.032690644, + 4.00, 0.642623544, 0.039591655, 0.002390578, 0.011392448, 0.130669326, 0.820143163, 0.049187481, 4.05, 0.751542628, 0.013616130, 0.001332268, 0.018846672, 0.239774108, 0.758091807, 0.002134085, + 4.10, 0.661690295, 0.024728056, 0.012804141, 0.004536461, 0.177133024, 0.727850020, 0.095016956, 4.15, 0.705562830, 0.019282497, 0.007421181, 0.011211002, 0.205830038, 0.740188360, 0.053981602, + 4.20, 0.705840707, 0.019233696, 0.007550273, 0.011019230, 0.204900950, 0.739971042, 0.055127978, 4.25, 0.739306688, 0.015376367, 0.003157761, 0.016317748, 0.224924207, 0.749649525, 0.025426269, + 4.30, 0.739022791, 0.014730528, 0.004004352, 0.015567727, 0.226050586, 0.742380440, 0.031568944, 4.35, 0.709601521, 0.021181472, 0.005025975, 0.012874743, 0.197820157, 0.756129682, 0.046050131, + 4.40, 0.669521511, 0.030052802, 0.006280851, 0.009348935, 0.167438671, 0.764807403, 0.067753911, 4.45, 0.728317499, 0.012321327, 0.009424124, 0.010583131, 0.221986711, 0.716708302, 0.061304986, + 4.50, 0.672598481, 0.025759801, 0.010038640, 0.006547378, 0.177590564, 0.739277303, 0.083132148, 4.55, 0.637889147, 0.032052111, 0.012512553, 0.002455944, 0.157799035, 0.735930085, 0.106270909, + 4.60, 0.679027796, 0.019366715, 0.015022421, 0.003062855, 0.189626575, 0.710654736, 0.099718690, 4.65, 0.755430341, 0.002795290, 0.012594124, 0.009583555, 0.242896020, 0.689434111, 0.067669868, + 4.70, 0.735527098, 0.009054719, 0.011400590, 0.009167189, 0.223600373, 0.706640780, 0.069758832, 4.75, 0.685611308, 0.024061970, 0.008955622, 0.007818676, 0.184873581, 0.736821055, 0.078305364, + 4.80, 0.661247611, 0.027647898, 0.011559054, 0.004269544, 0.168490216, 0.738675535, 0.092834234, 4.85, 0.649699926, 0.038785405, 0.003384510, 0.009621690, 0.145459771, 0.786229610, 0.068310618, + 4.90, 0.600613177, 0.043000001, 0.011522740, 0.000389241, 0.128073946, 0.761512101, 0.110413969, 4.95, 0.731156349, 0.010320447, 0.011637069, 0.008409517, 0.216091290, 0.708488405, 0.075420320, + 5.00, 0.643246651, 0.035132140, 0.008888522, 0.004912280, 0.153290153, 0.756346762, 0.090363085, 5.05, 0.718462586, 0.023937641, 0.001353388, 0.015208865, 0.189178646, 0.763775110, 0.047046244, + 5.10, 0.728470743, 0.006253866, 0.016604763, 0.004343614, 0.218121752, 0.690121174, 0.091757059, 5.15, 0.677486539, 0.027201064, 0.008469470, 0.007209180, 0.175213560, 0.743366539, 0.081419885, + 5.20, 0.736674428, 0.007843078, 0.013100819, 0.007382160, 0.216894522, 0.702840269, 0.080265224, 5.25, 0.730766773, 0.001002725, 0.021477260, 0.000686221, 0.225052625, 0.668507040, 0.106440365, + 5.30, 0.686039031, 0.024262933, 0.009459300, 0.006858972, 0.181184858, 0.735759377, 0.083055735, 5.35, 0.720685959, 0.006757588, 0.018372390, 0.002287479, 0.213174522, 0.687094331, 0.099731147, + 5.40, 0.643997490, 0.035632249, 0.008720243, 0.004695763, 0.155371577, 0.753929377, 0.090699077, 5.45, 0.593268335, 0.055888854, 0.001214772, 0.007102661, 0.115290038, 0.804074764, 0.080635190, + 5.50, 0.716838837, 0.005793421, 0.020465158, 0.000352343, 0.212645128, 0.680675685, 0.106679201, 5.55, 0.697915971, 0.022620669, 0.008426502, 0.008155249, 0.181773081, 0.741187036, 0.077039897, + 5.60, 0.592262268, 0.050731108, 0.006785112, 0.002741219, 0.126978710, 0.776069999, 0.096951306, 5.65, 0.734041989, 0.003035368, 0.019082792, 0.002344036, 0.215238228, 0.687019885, 0.097741902, + 5.70, 0.556647241, 0.063052624, 0.003463144, 0.002934910, 0.107175194, 0.796392262, 0.096432567, 5.75, 0.710051417, 0.016367614, 0.011842607, 0.006203953, 0.193122923, 0.721730053, 0.085147023, + 5.80, 0.706029475, 0.012037156, 0.017226923, 0.001878064, 0.196718752, 0.704768419, 0.098512828, 5.85, 0.654612601, 0.036256686, 0.005908306, 0.007118452, 0.158143133, 0.759888172, 0.081968665, + 5.90, 0.638387680, 0.045784108, 0.000482990, 0.010138975, 0.145752400, 0.780688822, 0.073558748, 5.95, 0.765625477, 0.009006737, 0.005495900, 0.014297913, 0.209866196, 0.729331076, 0.060802758, + 6.00, 0.644492924, 0.038544871, 0.006277613, 0.006113311, 0.156966522, 0.756561697, 0.086471796, 6.05, 0.699514270, 0.014493953, 0.016615160, 0.001767512, 0.191459492, 0.710442722, 0.098097801, + 6.10, 0.735310376, 0.000916126, 0.021286702, 0.000469059, 0.213263273, 0.684441924, 0.102294803, 6.15, 0.737085044, 0.019869011, 0.001928771, 0.015069457, 0.193129137, 0.745510876, 0.061360002, + 6.20, 0.635766864, 0.033920370, 0.013246342, 0.000219352, 0.160126776, 0.737914145, 0.101959050, 6.25, 0.694312274, 0.017446823, 0.015117271, 0.002449943, 0.185918257, 0.718855798, 0.095225930, + 6.30, 0.716026843, 0.015522248, 0.011648934, 0.006381558, 0.190181285, 0.725651085, 0.084167659, 6.35, 0.725953043, 0.008335987, 0.016386669, 0.003423875, 0.200004071, 0.707276762, 0.092719138, + 6.40, 0.671939135, 0.030642044, 0.007625898, 0.006587229, 0.170570269, 0.744471550, 0.084958196, 6.45, 0.731507123, 0.006026622, 0.017375994, 0.002977652, 0.205093756, 0.699757218, 0.095149040, + 6.50, 0.775374591, 0.009834517, 0.002630318, 0.016756810, 0.205848545, 0.734423161, 0.059728265, 6.55, 0.737466514, 0.001978302, 0.020002356, 0.001329426, 0.208096489, 0.693314075, 0.098589420, + 6.60, 0.724905312, 0.007886129, 0.017260177, 0.002581974, 0.201022938, 0.703096569, 0.095880508, 6.65, 0.642845452, 0.031919204, 0.013781587, 0.000032535, 0.163961738, 0.736084521, 0.099953711, + 6.70, 0.627521098, 0.039608911, 0.009952100, 0.001925030, 0.155569673, 0.748877347, 0.095552981, 6.75, 0.727513790, 0.021901295, 0.002691241, 0.013597943, 0.186210811, 0.745026588, 0.068762600, + 6.80, 0.736520290, 0.021667169, 0.000693249, 0.015644714, 0.189341038, 0.745036721, 0.065622211, 6.85, 0.703413725, 0.026231050, 0.004436190, 0.010745712, 0.180602312, 0.742578208, 0.076819479, + 6.90, 0.707485795, 0.029000759, 0.000674026, 0.013802667, 0.176528722, 0.754408419, 0.069062889, 6.95, 0.683170557, 0.019828230, 0.015959816, 0.000792783, 0.180165887, 0.722622693, 0.097211421, + 7.00, 0.741733968, 0.000309452, 0.020857314, 0.000765193, 0.205371931, 0.696482182, 0.098145902, 7.05, 0.733277380, 0.018847374, 0.004457326, 0.012518808, 0.189332068, 0.737355947, 0.073311985, + 7.10, 0.686947584, 0.020329216, 0.014589685, 0.002000112, 0.181159586, 0.723943591, 0.094896793, 7.15, 0.763238966, 0.008346494, 0.007512387, 0.012066679, 0.201269120, 0.723774552, 0.074956298, + 7.20, 0.755818844, 0.016949568, 0.000800188, 0.016610187, 0.190597326, 0.745290041, 0.064112663, 7.25, 0.684460104, 0.033079147, 0.002528107, 0.010840966, 0.172526523, 0.749671519, 0.077801943, + 7.30, 0.780553758, 0.005270217, 0.006330614, 0.013982195, 0.201851696, 0.728019595, 0.070128679, 7.35, 0.720273495, 0.017769041, 0.008928446, 0.008246363, 0.190375119, 0.725288272, 0.084336638, + 7.40, 0.691181540, 0.033674657, 0.000313735, 0.012875712, 0.170473114, 0.756505847, 0.073021054, 7.45, 0.724639952, 0.017434690, 0.008219006, 0.009015479, 0.185226962, 0.734799385, 0.079973638, + 7.50, 0.650077581, 0.035191968, 0.009118620, 0.003668396, 0.170341194, 0.736124039, 0.093534768, 7.55, 0.698249280, 0.018233035, 0.014053045, 0.002964497, 0.182294697, 0.725737393, 0.091967881, + 7.60, 0.732726693, 0.003651323, 0.020039063, 0.000612076, 0.198038265, 0.704833031, 0.097128689, 7.65, 0.785859823, 0.010407180, 0.000015683, 0.018938612, 0.203314006, 0.730436444, 0.066249549, + 7.70, 0.592862785, 0.049690478, 0.009004613, 0.000117376, 0.144601583, 0.761113882, 0.094284534, 7.75, 0.605973721, 0.051153421, 0.004281623, 0.004465784, 0.155343205, 0.752932906, 0.091723919, + 7.80, 0.789317489, 0.002593447, 0.007029239, 0.013846369, 0.205384582, 0.720143259, 0.074472129, 7.85, 0.706174791, 0.016937090, 0.013491407, 0.003788223, 0.182299182, 0.728245080, 0.089455724, + 7.90, 0.666150868, 0.038350385, 0.002098883, 0.009820030, 0.162583888, 0.759026945, 0.078389168, 7.95, 0.799540281, 0.003311466, 0.003811127, 0.016857177, 0.200973064, 0.731083333, 0.067943633, + 8.00, 0.680162311, 0.022954039, 0.014026556, 0.001724347, 0.172286659, 0.736675143, 0.091038227, 8.05, 0.759831607, 0.004041791, 0.013042748, 0.007425584, 0.194693774, 0.722206652, 0.083099544, + 8.10, 0.718426704, 0.026699424, 0.000747219, 0.014051266, 0.178020686, 0.748722494, 0.073256791, 8.15, 0.651540279, 0.037407469, 0.006764994, 0.005354373, 0.165006176, 0.747445941, 0.087547898, + 8.20, 0.614697039, 0.043270975, 0.010134578, 0.000507772, 0.162323758, 0.740480542, 0.097195685, 8.25, 0.625735939, 0.049280617, 0.001384329, 0.007746050, 0.159123883, 0.755485237, 0.085390866, + 8.30, 0.725445449, 0.019521395, 0.006236922, 0.010322889, 0.184575632, 0.734737873, 0.080686510, 8.35, 0.653648674, 0.039499819, 0.004212866, 0.007349753, 0.161582902, 0.755483210, 0.082933903, + 8.40, 0.697551310, 0.032635413, 0.000126698, 0.013139479, 0.174316034, 0.749188185, 0.076495767, 8.45, 0.756601036, 0.007870061, 0.010133540, 0.009322015, 0.195246026, 0.721213520, 0.083540440, + 8.50, 0.686896741, 0.019905558, 0.015535688, 0.000905208, 0.182542026, 0.721521914, 0.095936060, 8.55, 0.692634821, 0.028701732, 0.005328579, 0.008901480, 0.168360725, 0.752613902, 0.079025388, + 8.60, 0.709603131, 0.025053587, 0.004741546, 0.010397101, 0.176766813, 0.743414402, 0.079818785, 8.65, 0.562588334, 0.062730834, 0.003832389, 0.001879750, 0.144731358, 0.763089716, 0.092178941, + 8.70, 0.709370255, 0.015403642, 0.014482113, 0.003052816, 0.176666811, 0.736030579, 0.087302625, 8.75, 0.567155123, 0.058938250, 0.006502643, 0.000147957, 0.153613403, 0.748631060, 0.097755551, + 8.80, 0.757969081, 0.005018137, 0.012737557, 0.007383926, 0.196088552, 0.717094302, 0.086817145, 8.85, 0.637681782, 0.041443706, 0.006406926, 0.004596610, 0.167452842, 0.742133498, 0.090413690, + 8.90, 0.696166277, 0.022483753, 0.010752261, 0.004988009, 0.171393678, 0.744028687, 0.084577620, 8.95, 0.641492724, 0.038330950, 0.008586541, 0.003185386, 0.164259881, 0.746261537, 0.089478552, + 9.00, 0.744261920, 0.014480891, 0.006752837, 0.010977335, 0.185281217, 0.734718859, 0.079999924, 9.05, 0.604861915, 0.054672804, 0.001425516, 0.006249385, 0.154924199, 0.758761585, 0.086314201, + 9.10, 0.734394789, 0.011045747, 0.012673132, 0.005906643, 0.182829916, 0.732042849, 0.085127234, 9.15, 0.627262056, 0.046458948, 0.004051410, 0.005670916, 0.164540574, 0.746340811, 0.089118600, + 9.20, 0.644625247, 0.042768665, 0.003425462, 0.007207151, 0.162356779, 0.753559232, 0.084083974, 9.25, 0.674772859, 0.029341169, 0.009332273, 0.004649106, 0.165553004, 0.750079751, 0.084367275, + 9.30, 0.655452967, 0.033674210, 0.009829640, 0.003068261, 0.180664375, 0.723415256, 0.095920384, 9.35, 0.611765504, 0.053841263, 0.000584934, 0.007270964, 0.162311241, 0.749586463, 0.088102281, + 9.40, 0.606882989, 0.054846037, 0.000811920, 0.006787218, 0.162672743, 0.748103857, 0.089223385, 9.45, 0.632426262, 0.038748465, 0.010535475, 0.001082156, 0.171522275, 0.732932031, 0.095545709, + 9.50, 0.729691505, 0.020070985, 0.004907718, 0.011373746, 0.187783867, 0.728058815, 0.084157348, 9.55, 0.670830190, 0.033085611, 0.006625537, 0.006393714, 0.175327137, 0.736235499, 0.088437378, + 9.60, 0.687369466, 0.034159482, 0.001422087, 0.011326076, 0.172774851, 0.745992362, 0.081232786, 9.65, 0.731532156, 0.006324587, 0.018232957, 0.001465606, 0.182184324, 0.728429914, 0.089385748, + 9.70, 0.647118330, 0.033703547, 0.011964437, 0.000885895, 0.167865753, 0.740575910, 0.091558337, 9.75, 0.720653296, 0.013443928, 0.013856275, 0.004050981, 0.176564664, 0.737988055, 0.085447252, + 9.80, 0.733275950, 0.005911957, 0.018226840, 0.001566280, 0.203884900, 0.695576549, 0.100538552, 9.85, 0.560077786, 0.063379243, 0.004070256, 0.001350461, 0.144632742, 0.766947985, 0.088419259, + 9.90, 0.762389541, 0.009851214, 0.007040165, 0.011752650, 0.180735469, 0.741924822, 0.077339709, 9.95, 0.724952698, 0.014183916, 0.012079667, 0.005623475, 0.172745883, 0.745286882, 0.081967235, + 10.00, 0.798044562, 0.007615812, 0.000370339, 0.018977063, 0.180253074, 0.751583099, 0.068163812, 10.05, 0.707427442, 0.020877384, 0.009771857, 0.006255746, 0.173551977, 0.742345214, 0.084102809, + 10.10, 0.714741707, 0.015042767, 0.013780370, 0.003704656, 0.178732216, 0.733217955, 0.088049829, 10.15, 0.796544731, 0.007786527, 0.000610150, 0.018676788, 0.189338237, 0.736833274, 0.073828518, + 10.20, 0.752726078, 0.003241500, 0.016112743, 0.004309002, 0.186903670, 0.725375235, 0.087721109, 10.25, 0.600836337, 0.050188489, 0.007147860, 0.001532299, 0.166097417, 0.739989996, 0.093912601, + 10.30, 0.624425650, 0.045098323, 0.006333862, 0.003622258, 0.155066222, 0.760279775, 0.084653974, 10.35, 0.622179627, 0.051377967, 0.000629879, 0.007749252, 0.176270604, 0.731271684, 0.092457712, + 10.40, 0.687915444, 0.032495048, 0.003079327, 0.010020294, 0.189899549, 0.718322694, 0.091777742, 10.45, 0.510093689, 0.079129308, 0.000900544, 0.000540491, 0.157060981, 0.744453490, 0.098485529, + 10.50, 0.775071323, 0.006995384, 0.006808441, 0.012656884, 0.198624194, 0.715105593, 0.086270213, 10.55, 0.759528875, 0.014222167, 0.003486849, 0.014161991, 0.191726848, 0.725146830, 0.083126307, + 10.60, 0.671943724, 0.027052635, 0.012567002, 0.001867054, 0.156989917, 0.761320829, 0.081689239, 10.65, 0.735664845, 0.016404569, 0.007293276, 0.009798553, 0.177687928, 0.741255939, 0.081056118, + 10.70, 0.687610447, 0.031170320, 0.004536416, 0.008866331, 0.163551867, 0.757252872, 0.079195261, 10.75, 0.674482584, 0.034131497, 0.004854865, 0.007808756, 0.160787880, 0.759333372, 0.079878747, + 10.80, 0.713703215, 0.019295909, 0.009910833, 0.006448917, 0.187074989, 0.722675264, 0.090249717, 10.85, 0.666478634, 0.039197810, 0.001810361, 0.009576272, 0.193670183, 0.710409224, 0.095920622, + 10.90, 0.538286209, 0.070543654, 0.002511822, 0.001038749, 0.170275599, 0.728904247, 0.100820184, 10.95, 0.722132862, 0.019914761, 0.007202789, 0.008993138, 0.179133967, 0.736895561, 0.083970487, + 11.00, 0.775188446, 0.002110202, 0.011726528, 0.008928999, 0.179489613, 0.740018725, 0.080491662, 11.05, 0.660312831, 0.034631196, 0.007956591, 0.004552612, 0.164969057, 0.750347555, 0.084683359, + 11.10, 0.570146918, 0.064826190, 0.000298418, 0.004664365, 0.154196918, 0.759139419, 0.086663663, 11.15, 0.763172686, 0.010062631, 0.006793454, 0.011866260, 0.185430080, 0.731678963, 0.082890987, + 11.20, 0.714733124, 0.023543930, 0.005441414, 0.009838291, 0.169459432, 0.750653207, 0.079887331, 11.25, 0.604502499, 0.054907538, 0.001629133, 0.005812833, 0.176099509, 0.729095876, 0.094804585, + 11.30, 0.641456842, 0.041145757, 0.006178096, 0.004691433, 0.161805794, 0.753731728, 0.084462464, 11.35, 0.728042305, 0.011284340, 0.014400549, 0.003930632, 0.206198439, 0.692909837, 0.100891709, + 11.40, 0.771990716, 0.006124873, 0.008567598, 0.011056108, 0.211238742, 0.692720175, 0.096041083, 11.45, 0.741813183, 0.018255446, 0.003990404, 0.012596160, 0.170166343, 0.753319442, 0.076514184, + 11.50, 0.653191566, 0.034932330, 0.009476501, 0.002937054, 0.183023959, 0.721411407, 0.095564663, 11.55, 0.664150715, 0.037255630, 0.004418969, 0.007410984, 0.183044419, 0.725021720, 0.091933846, + 11.60, 0.758137107, 0.010300789, 0.007876605, 0.010692362, 0.161637321, 0.766097665, 0.072265029, 11.65, 0.697066844, 0.027567523, 0.005878599, 0.008373103, 0.193790779, 0.711349308, 0.094859898, + 11.70, 0.664852500, 0.035381313, 0.006123699, 0.006171905, 0.167638406, 0.747312129, 0.085049450, 11.75, 0.730120420, 0.022711206, 0.002495445, 0.012958374, 0.180838555, 0.736388803, 0.082772613, + 11.80, 0.706266522, 0.013552571, 0.017629609, 0.000107843, 0.182957873, 0.724156797, 0.092885315, 11.85, 0.675682306, 0.029335268, 0.009470142, 0.004333047, 0.186431378, 0.718340933, 0.095227659, + 11.90, 0.604786634, 0.053452924, 0.003083225, 0.004687140, 0.164481729, 0.746950388, 0.088567853, 11.95, 0.692369878, 0.020273544, 0.014371768, 0.001690956, 0.161582887, 0.755657673, 0.082759440, + 12.00, 0.694708109, 0.024061449, 0.010019578, 0.005086033, 0.196226329, 0.705950379, 0.097823262, 12.05, 0.732194602, 0.018152002, 0.006576806, 0.009996463, 0.162121847, 0.762985051, 0.074893117, + 12.10, 0.704596221, 0.024311692, 0.007303685, 0.007736176, 0.176067069, 0.738277316, 0.085655630, 12.15, 0.656632245, 0.032063607, 0.011563718, 0.001527686, 0.182731122, 0.722112954, 0.095155895, + 12.20, 0.657639384, 0.030910037, 0.012439933, 0.000952650, 0.170832738, 0.739240587, 0.089926660, 12.25, 0.660332799, 0.042318996, 0.000362214, 0.010175833, 0.201920643, 0.697218537, 0.100860834, + 12.30, 0.651309133, 0.035345394, 0.009614673, 0.002655303, 0.154171154, 0.765324533, 0.080504298, 12.35, 0.725657940, 0.007373217, 0.019000620, 0.000261914, 0.150716364, 0.773906052, 0.075377584, + 12.40, 0.568968117, 0.064499371, 0.001060508, 0.003913697, 0.176366925, 0.727344036, 0.096289039, 12.45, 0.744530499, 0.012033693, 0.009616859, 0.008483129, 0.191205174, 0.718115389, 0.090679467, + 12.50, 0.741482973, 0.020216513, 0.002212025, 0.013834205, 0.212230474, 0.689047694, 0.098721862, 12.55, 0.614267528, 0.046104338, 0.008125730, 0.001449712, 0.135747001, 0.789840996, 0.074411988, + 12.60, 0.567347109, 0.064327240, 0.001639552, 0.003376853, 0.132098824, 0.793565631, 0.074335575, 12.65, 0.673445702, 0.031689785, 0.007764861, 0.005404657, 0.184797153, 0.721658289, 0.093544543, + 12.70, 0.652556658, 0.039481007, 0.005214557, 0.005997827, 0.140404761, 0.788059235, 0.071536005, 12.75, 0.725125432, 0.019086789, 0.007456597, 0.008859335, 0.192517981, 0.715334713, 0.092147291, + 12.80, 0.661961317, 0.036234725, 0.006078526, 0.005961001, 0.193772078, 0.707414925, 0.098812997, 12.85, 0.642713308, 0.040332936, 0.006833710, 0.004160570, 0.175249681, 0.734277964, 0.090472341, + 12.90, 0.738380969, 0.022402726, 0.000840865, 0.014639037, 0.181741714, 0.734712362, 0.083545923, 12.95, 0.704517722, 0.029127352, 0.002580315, 0.011219298, 0.192632750, 0.714637876, 0.092729390, + 13.00, 0.630471587, 0.042491749, 0.007730529, 0.002726447, 0.201483369, 0.692733884, 0.105782747, 13.05, 0.710673630, 0.013418403, 0.016751640, 0.000974536, 0.182054922, 0.725996017, 0.091949046, + 13.10, 0.614334285, 0.047275580, 0.006991714, 0.002263956, 0.135865241, 0.790625811, 0.073508978, 13.15, 0.721841455, 0.013219237, 0.014152825, 0.003626153, 0.209482580, 0.686300099, 0.104217350, + 13.20, 0.691670477, 0.027179100, 0.007770687, 0.006500835, 0.196792960, 0.705630720, 0.097576320, 13.25, 0.687379479, 0.026573107, 0.009438056, 0.004990650, 0.184179202, 0.723533928, 0.092286885, + 13.30, 0.585538507, 0.055487428, 0.006006163, 0.001182871, 0.170805782, 0.736575484, 0.092618704, 13.35, 0.557284057, 0.065956786, 0.002590083, 0.001986779, 0.115980469, 0.817647934, 0.066371620, + 13.40, 0.629613340, 0.046451196, 0.004014723, 0.005437851, 0.216535300, 0.671440601, 0.112024069, 13.45, 0.694086432, 0.025263757, 0.009069107, 0.005687717, 0.177962780, 0.733235180, 0.088802040, + 13.50, 0.699766278, 0.031556524, 0.001361847, 0.011819052, 0.183224946, 0.728090286, 0.088684797, 13.55, 0.786130905, 0.005859770, 0.005491737, 0.014101204, 0.181184083, 0.737541556, 0.081274390, + 13.60, 0.652902365, 0.033395275, 0.011283882, 0.001414925, 0.180976197, 0.725486219, 0.093537569, 13.65, 0.766006589, 0.004718501, 0.011646405, 0.008240692, 0.178020373, 0.737867415, 0.084112227, + 13.70, 0.638251364, 0.038967464, 0.009348910, 0.001969615, 0.176437631, 0.731100321, 0.092462063, 13.75, 0.772822976, 0.012917720, 0.001787543, 0.016027523, 0.160995126, 0.768132389, 0.070872486, + 13.80, 0.795924425, 0.000001829, 0.008934669, 0.012106072, 0.190788224, 0.722572505, 0.086639285, 13.85, 0.712637007, 0.016933046, 0.012837119, 0.003964910, 0.147839814, 0.779684186, 0.072476029, + 13.90, 0.760183096, 0.012833025, 0.005038776, 0.012794182, 0.207206726, 0.696023166, 0.096770108, 13.95, 0.762026608, 0.006793361, 0.010581672, 0.008779146, 0.176248670, 0.740152180, 0.083599150, + 14.00, 0.622943103, 0.049167890, 0.002990570, 0.005770339, 0.192139506, 0.708034217, 0.099826276, 14.05, 0.655722380, 0.034870993, 0.009125449, 0.003193285, 0.160878703, 0.756313086, 0.082808197, + 14.10, 0.749844611, 0.001728453, 0.018717691, 0.001896547, 0.207903415, 0.689705551, 0.102391064, 14.15, 0.661753058, 0.037709214, 0.004778191, 0.006831670, 0.127366021, 0.808602035, 0.064031959, + 14.20, 0.739294708, 0.011356346, 0.011732958, 0.006471464, 0.234153181, 0.651235938, 0.114610910, 14.25, 0.634925187, 0.040906936, 0.008267399, 0.002553051, 0.216608196, 0.670806050, 0.112585783, + 14.30, 0.701252997, 0.030390240, 0.002241876, 0.011187881, 0.131804764, 0.806049347, 0.062145889, 14.35, 0.693837583, 0.027424246, 0.007052854, 0.007122837, 0.187389433, 0.719810724, 0.092799842, + 14.40, 0.740905762, 0.012758359, 0.009970337, 0.007862505, 0.139310777, 0.795475006, 0.065214217, 14.45, 0.557903051, 0.064275920, 0.004200913, 0.000753809, 0.118169531, 0.815466285, 0.066364169, + 14.50, 0.731989861, 0.023698390, 0.001226645, 0.013887508, 0.204852939, 0.697666109, 0.097480953, 14.55, 0.691941023, 0.021373324, 0.013592146, 0.002089160, 0.192151889, 0.710774899, 0.097073197, + 14.60, 0.715600729, 0.018532384, 0.010501079, 0.005899001, 0.238085568, 0.643515944, 0.118398488, 14.65, 0.665756524, 0.037001684, 0.004498050, 0.007282097, 0.221598089, 0.666820526, 0.111581385, + 14.70, 0.813443482, 0.002553128, 0.002032824, 0.018355483, 0.107158706, 0.850097120, 0.042744160, 14.75, 0.654727817, 0.036766671, 0.007522210, 0.004300704, 0.131008983, 0.802157104, 0.066833913, + 14.80, 0.712311208, 0.019010223, 0.010858625, 0.005415494, 0.237628162, 0.643984616, 0.118387222, 14.85, 0.631842852, 0.044723153, 0.005263939, 0.004581369, 0.176134318, 0.732930183, 0.090935469, + 14.90, 0.788987398, 0.005129345, 0.005603261, 0.014124675, 0.113090716, 0.838817120, 0.048092186, 14.95, 0.731478393, 0.011042636, 0.014062844, 0.004188959, 0.204681426, 0.694767416, 0.100551188, + 15.00, 0.610909045, 0.052865371, 0.002360716, 0.005446266, 0.269968808, 0.590892971, 0.139138222, 15.05, 0.681244493, 0.034889691, 0.002788819, 0.009493941, 0.122827619, 0.817575455, 0.059596896, + 15.10, 0.657367587, 0.035538077, 0.008087836, 0.004043739, 0.211652040, 0.680156767, 0.108191192, 15.15, 0.705144286, 0.024954692, 0.006725430, 0.008052800, 0.230219781, 0.655712485, 0.114067733, + 15.20, 0.585954130, 0.059651062, 0.001803875, 0.004311625, 0.230894089, 0.647958457, 0.121147454, 15.25, 0.734103143, 0.010396499, 0.014068563, 0.004336888, 0.096027374, 0.858532667, 0.045439959, + 15.30, 0.762889147, 0.012897201, 0.004345894, 0.013447115, 0.238814890, 0.647345304, 0.113839805, 15.35, 0.785427213, 0.001071531, 0.010575417, 0.010154823, 0.105150782, 0.849067211, 0.045782030, + 15.40, 0.599935174, 0.054319710, 0.003700614, 0.003717400, 0.192676768, 0.707337499, 0.099985719, 15.45, 0.702837944, 0.022892334, 0.009386800, 0.005895806, 0.138957024, 0.792599559, 0.068443418, + 15.50, 0.717270851, 0.019445341, 0.009251539, 0.006879831, 0.105226934, 0.844815135, 0.049957931, 15.55, 0.643918097, 0.034871936, 0.012149259, 0.000132397, 0.169413224, 0.742629766, 0.087957025, + 15.60, 0.657019794, 0.030519485, 0.013233595, 0.000132520, 0.206523865, 0.687374592, 0.106101513, 15.65, 0.820778728, 0.002432294, 0.000391729, 0.019990845, 0.214031368, 0.689449608, 0.096519053, + 15.70, 0.712360203, 0.014742196, 0.015155707, 0.002164768, 0.086967207, 0.869690895, 0.043341875, 15.75, 0.758473217, 0.014070660, 0.004303962, 0.013181910, 0.117252827, 0.829569757, 0.053177416, + 15.80, 0.797629535, 0.003610317, 0.005003586, 0.015083190, 0.085234165, 0.880431414, 0.034334421, 15.85, 0.606994927, 0.049409047, 0.006832600, 0.001819950, 0.259119332, 0.606001198, 0.134879470, + 15.90, 0.728422642, 0.021804363, 0.004080050, 0.011473823, 0.167868003, 0.751412511, 0.080719471, 15.95, 0.660934091, 0.029669285, 0.013116829, 0.000456031, 0.101408489, 0.845859706, 0.052731812, + 16.00, 0.583330154, 0.059098411, 0.003092103, 0.003121767, 0.065101810, 0.898198545, 0.036699653, 16.05, 0.729344666, 0.009877689, 0.015782207, 0.002750339, 0.097509377, 0.854663551, 0.047827065, + 16.10, 0.664115787, 0.036239594, 0.005744293, 0.006189391, 0.253785998, 0.618475318, 0.127738714, 16.15, 0.665620923, 0.040300131, 0.001300715, 0.009621214, 0.122263148, 0.816855431, 0.060881436, + 16.20, 0.635851383, 0.039581127, 0.009472668, 0.001623729, 0.186156929, 0.717675388, 0.096167684, 16.25, 0.685067058, 0.028111853, 0.008652397, 0.005304134, 0.254521728, 0.617781579, 0.127696693, + 16.30, 0.671372652, 0.030012012, 0.010172911, 0.003310043, 0.114655226, 0.827525616, 0.057819128, 16.35, 0.726615489, 0.015679982, 0.010661013, 0.006421559, 0.284637600, 0.573571861, 0.141790569, + 16.40, 0.721436799, 0.013165165, 0.014492884, 0.003207199, 0.074668199, 0.888910353, 0.036421478, 16.45, 0.730993748, 0.008924253, 0.016367376, 0.002381528, 0.100111321, 0.851383686, 0.048505008, + 16.50, 0.744230330, 0.009316154, 0.012625471, 0.006045887, 0.228459418, 0.658753753, 0.112786829, 16.55, 0.656634033, 0.033359539, 0.010486320, 0.002171613, 0.192051321, 0.709297061, 0.098651648, + 16.60, 0.586481631, 0.059042878, 0.002377570, 0.003841281, 0.132757336, 0.797203362, 0.070039332, 16.65, 0.556891322, 0.064664468, 0.004135080, 0.000687614, 0.133038789, 0.794020951, 0.072940290, + 16.70, 0.609965086, 0.047400743, 0.008161463, 0.000961613, 0.113637187, 0.826101661, 0.060261130, 16.75, 0.703126192, 0.027283851, 0.004968520, 0.009193556, 0.314621598, 0.528775275, 0.156603158, + 16.80, 0.707181990, 0.020819128, 0.010396242, 0.005393542, 0.158002302, 0.762849987, 0.079147696, 16.85, 0.586543202, 0.060893610, 0.000508472, 0.005249184, 0.242736101, 0.631703854, 0.125560045, + 16.90, 0.671847463, 0.029319562, 0.010761410, 0.002887281, 0.266909748, 0.598013699, 0.135076582, 16.95, 0.677711248, 0.027613297, 0.010978378, 0.003108554, 0.200138867, 0.698033094, 0.101828039, + 17.00, 0.614473045, 0.047937885, 0.006457590, 0.002551071, 0.224051937, 0.659330189, 0.116617858, 17.05, 0.657729983, 0.040971756, 0.002631158, 0.008108199, 0.178897902, 0.730648160, 0.090453923, + 17.10, 0.645247698, 0.036719680, 0.010039009, 0.001745764, 0.128549740, 0.804984808, 0.066465437, 17.15, 0.692725956, 0.027247034, 0.007633924, 0.006523093, 0.073470548, 0.891232729, 0.035296738, + 17.20, 0.797381878, 0.005097494, 0.003592685, 0.016115118, 0.094806060, 0.864059865, 0.041134059, 17.25, 0.660030425, 0.041451745, 0.001566984, 0.009056913, 0.159856588, 0.759766281, 0.080377162, + 17.30, 0.656274498, 0.031263046, 0.012724653, 0.000431424, 0.148459122, 0.774573863, 0.076967001, 17.35, 0.591632664, 0.054071508, 0.006068319, 0.001389809, 0.287512511, 0.563623309, 0.148864150, + 17.40, 0.645229876, 0.035259917, 0.011514872, 0.000629019, 0.124189734, 0.812191665, 0.063618600, 17.45, 0.767431259, 0.004138738, 0.012089640, 0.007832579, 0.207188711, 0.692833364, 0.099977911, + 17.50, 0.552409530, 0.066802211, 0.003159411, 0.001108032, 0.103992119, 0.839100063, 0.056907833, 17.55, 0.707447410, 0.013888985, 0.017325327, 0.000164345, 0.027229413, 0.959326029, 0.013444543, + 17.60, 0.680527985, 0.031931154, 0.006010443, 0.006969972, 0.270029068, 0.594751656, 0.135219276, 17.65, 0.593147099, 0.059047580, 0.000703789, 0.005515244, 0.249358714, 0.622303665, 0.128337622, + 17.70, 0.791372776, 0.001141690, 0.009060048, 0.011632064, 0.309629112, 0.539429247, 0.150941670, 17.75, 0.636191726, 0.039019272, 0.009968549, 0.001258757, 0.284562230, 0.569141746, 0.146296024, + 17.80, 0.634177327, 0.047534734, 0.001960412, 0.007136166, 0.189328521, 0.714039862, 0.096631587, 17.85, 0.751469970, 0.009154446, 0.011038139, 0.007643210, 0.026480488, 0.963086367, 0.010433137, + 17.90, 0.740025282, 0.010362968, 0.012711003, 0.005658109, 0.316992164, 0.525839865, 0.157167971, 17.95, 0.757209301, 0.013814263, 0.004944399, 0.012571542, 0.330267519, 0.507805765, 0.161926687, + 18.00, 0.734100580, 0.022811241, 0.001734763, 0.013526851, 0.121345371, 0.821706414, 0.056948185, 18.05, 0.671925068, 0.030377023, 0.009718709, 0.003648536, 0.308862180, 0.534928679, 0.156209111, + 18.10, 0.697446406, 0.028571874, 0.005172521, 0.008631513, 0.261955917, 0.608244121, 0.129799962, 18.15, 0.594167173, 0.051826194, 0.007691681, 0.000321936, 0.266372532, 0.595948577, 0.137678862, + 18.20, 0.716311574, 0.018721588, 0.010304630, 0.005962918, 0.055592142, 0.918762624, 0.025645256, 18.25, 0.627494872, 0.044425517, 0.006783403, 0.003068898, 0.021238402, 0.966043234, 0.012718379, + 18.30, 0.741219163, 0.014386337, 0.008400612, 0.008956935, 0.316946596, 0.526587188, 0.156466186, 18.35, 0.619465053, 0.044087432, 0.009092562, 0.000862453, 0.297963977, 0.548621953, 0.153414071, + 18.40, 0.668275893, 0.029096261, 0.011898503, 0.001795564, 0.152027801, 0.769684196, 0.078288019, 18.45, 0.607787192, 0.052782476, 0.003359668, 0.004400242, 0.324847609, 0.509087801, 0.166064620, + 18.50, 0.681842446, 0.025724903, 0.011902027, 0.002622977, 0.146746725, 0.779259026, 0.073994219, 18.55, 0.602584243, 0.054031804, 0.003436208, 0.003998805, 0.227249205, 0.656445622, 0.116305172, + 18.60, 0.725293398, 0.012602329, 0.014182538, 0.003612772, 0.243743211, 0.635292530, 0.120964289, 18.65, 0.744948864, 0.005532205, 0.016361281, 0.003190316, 0.185577959, 0.723366737, 0.091055274, + 18.70, 0.635090709, 0.040398389, 0.008915991, 0.001940884, 0.363265663, 0.451420426, 0.185313940, 18.75, 0.606926322, 0.055156454, 0.001198828, 0.005968627, 0.228418574, 0.654630065, 0.116951346, + 18.80, 0.763809443, 0.014296792, 0.002851591, 0.014523840, 0.280339569, 0.583333433, 0.136326969, 18.85, 0.681040287, 0.030004315, 0.007800214, 0.005666407, 0.395757854, 0.404505789, 0.199736357, + 18.90, 0.763031721, 0.014851183, 0.002469085, 0.014779020, 0.108509533, 0.840742886, 0.050747573, 18.95, 0.759478509, 0.001530200, 0.016685277, 0.003889620, 0.100917980, 0.849950433, 0.049131572, + 19.00, 0.639116704, 0.044296533, 0.004058942, 0.005799599, 0.130327120, 0.803912163, 0.065760732, 19.05, 0.578526258, 0.059787303, 0.003664106, 0.002347581, 0.376217663, 0.430850267, 0.192932069, + 19.10, 0.591366351, 0.056888379, 0.003363959, 0.003366981, 0.066996813, 0.896167576, 0.036835611, 19.15, 0.723976731, 0.022388399, 0.004699200, 0.010662809, 0.322976857, 0.516833544, 0.160189629, + 19.20, 0.629271090, 0.049999945, 0.000777811, 0.007674441, 0.212360352, 0.679592371, 0.108047247, 19.25, 0.616772532, 0.052926600, 0.001025140, 0.006670773, 0.305292100, 0.540844560, 0.153863311, + 19.30, 0.616772532, 0.052926600, 0.001025140, 0.006670773, 0.305292100, 0.540844560, 0.153863311, 19.35, 0.585252821, 0.056075647, 0.005713806, 0.001215953, 0.122264110, 0.812377095, 0.065358818, + 19.40, 0.692379653, 0.024560563, 0.010469109, 0.004328458, 0.101609349, 0.847952902, 0.050437748, 19.45, 0.735629797, 0.011300519, 0.012886256, 0.005241502, 0.371529579, 0.442429751, 0.186040670, + 19.50, 0.692917943, 0.024151146, 0.010774881, 0.004109576, 0.123248830, 0.815623760, 0.061127424, 19.55, 0.633065999, 0.049031563, 0.000802159, 0.007889837, 0.149906129, 0.774167955, 0.075925887, + 19.60, 0.574742436, 0.063080668, 0.001374975, 0.003784232, 0.148704216, 0.774831355, 0.076464415, 19.65, 0.516435742, 0.078251049, 0.000788152, 0.000575017, 0.325059086, 0.507439494, 0.167501450, + 19.70, 0.533551931, 0.074311420, 0.000406727, 0.001962353, 0.342934698, 0.480547130, 0.176518142, 19.75, 0.693292737, 0.022411108, 0.012378633, 0.002962127, 0.155473262, 0.766110063, 0.078416705, + 19.80, 0.619924605, 0.052569546, 0.000531286, 0.007285334, 0.148478061, 0.774832845, 0.076689124, 19.85, 0.691357553, 0.021407604, 0.013847128, 0.001753911, 0.179279834, 0.730047703, 0.090672493, + 19.90, 0.663915038, 0.038511515, 0.003682941, 0.007602572, 0.239249468, 0.641971469, 0.118779063, 19.95, 0.520983577, 0.076073349, 0.001844108, 0.000055879, 0.317512095, 0.519014537, 0.163473368, + 20.00, 0.628557563, 0.045759290, 0.005248681, 0.004237816, 0.184951141, 0.720882893, 0.094165981, 20.05, 0.793222070, 0.003329217, 0.006494150, 0.013609104, 0.359128177, 0.464643240, 0.176228583, + 20.10, 0.545972228, 0.068722248, 0.002889521, 0.000877503, 0.009620428, 0.981576681, 0.008802891, 20.15, 0.623136342, 0.045090564, 0.007242844, 0.002425767, 0.137593195, 0.791602910, 0.070803881}; double wtab2[3192] = { - 2.49999994E-03 , 0.578033745 , 3.99446450E-02 , 2.38903537E-02 , -1.30482316E-02 , 0.179515034 , 0.731100619 , 8.93843472E-02, - 3.50000011E-03 , 0.577869534 , 3.99689302E-02 , 2.39049532E-02 , -1.30678229E-02 , 0.179440185 , 0.731137991 , 8.94218087E-02, - 4.49999981E-03 , 0.577705383 , 3.99932154E-02 , 2.39195526E-02 , -1.30874133E-02 , 0.179365337 , 0.731175423 , 8.94592628E-02, - 5.49999997E-03 , 0.577541232 , 4.00174968E-02 , 2.39341483E-02 , -1.31069971E-02 , 0.179290488 , 0.731212795 , 8.94967243E-02, - 6.50000013E-03 , 0.577377021 , 4.00417708E-02 , 2.39487402E-02 , -1.31265689E-02 , 0.179215625 , 0.731250167 , 8.95342156E-02, - 7.49999983E-03 , 0.577212870 , 4.00660373E-02 , 2.39633210E-02 , -1.31461201E-02 , 0.179140732 , 0.731287539 , 8.95717517E-02, - 8.50000046E-03 , 0.577048659 , 4.00902927E-02 , 2.39778906E-02 , -1.31656425E-02 , 0.179065749 , 0.731324852 , 8.96094143E-02, - 9.49999969E-03 , 0.576884508 , 4.01145332E-02 , 2.39924453E-02 , -1.31851304E-02 , 0.178990647 , 0.731362045 , 8.96473005E-02, - 1.04999999E-02 , 0.576720297 , 4.01387550E-02 , 2.40069814E-02 , -1.32045783E-02 , 0.178915322 , 0.731399119 , 8.96855593E-02, - 1.15000000E-02 , 0.576556087 , 4.01629582E-02 , 2.40214970E-02 , -1.32239787E-02 , 0.178839639 , 0.731435955 , 8.97244066E-02, - 1.25000002E-02 , 0.576391935 , 4.01871353E-02 , 2.40359865E-02 , -1.32433213E-02 , 0.178763434 , 0.731472433 , 8.97641182E-02, - 1.35000004E-02 , 0.576227725 , 4.02112827E-02 , 2.40504444E-02 , -1.32625941E-02 , 0.178686514 , 0.731508434 , 8.98050219E-02, - 1.44999996E-02 , 0.576063514 , 4.02353965E-02 , 2.40648650E-02 , -1.32817822E-02 , 0.178608656 , 0.731543839 , 8.98475125E-02, - 1.54999997E-02 , 0.575899243 , 4.02594656E-02 , 2.40792390E-02 , -1.33008687E-02 , 0.178529590 , 0.731578410 , 8.98919925E-02, - 1.64999999E-02 , 0.575735033 , 4.02834900E-02 , 2.40935609E-02 , -1.33198369E-02 , 0.178449064 , 0.731612027 , 8.99389088E-02, - 1.75000001E-02 , 0.575570762 , 4.03074548E-02 , 2.41078213E-02 , -1.33386711E-02 , 0.178366825 , 0.731644511 , 8.99886861E-02, - 1.85000002E-02 , 0.575406551 , 4.03313600E-02 , 2.41220128E-02 , -1.33573553E-02 , 0.178282633 , 0.731675625 , 9.00417194E-02, - 1.95000004E-02 , 0.575242221 , 4.03551981E-02 , 2.41361316E-02 , -1.33758765E-02 , 0.178196281 , 0.731705368 , 9.00983587E-02, - 2.05000006E-02 , 0.575077951 , 4.03789654E-02 , 2.41501704E-02 , -1.33942226E-02 , 0.178107575 , 0.731733561 , 9.01588872E-02, - 2.15000007E-02 , 0.574913621 , 4.04026546E-02 , 2.41641272E-02 , -1.34123880E-02 , 0.178016424 , 0.731760025 , 9.02235359E-02, - 2.25000009E-02 , 0.574749291 , 4.04262692E-02 , 2.41780002E-02 , -1.34303654E-02 , 0.177922696 , 0.731784880 , 9.02924463E-02, - 2.34999992E-02 , 0.574584961 , 4.04497981E-02 , 2.41917893E-02 , -1.34481536E-02 , 0.177826360 , 0.731807947 , 9.03657228E-02, - 2.44999994E-02 , 0.574420631 , 4.04732488E-02 , 2.42054947E-02 , -1.34657528E-02 , 0.177727371 , 0.731829226 , 9.04433951E-02, - 2.54999995E-02 , 0.574256241 , 4.04966101E-02 , 2.42191181E-02 , -1.34831630E-02 , 0.177625760 , 0.731848776 , 9.05254781E-02, - 2.64999997E-02 , 0.574091792 , 4.05198894E-02 , 2.42326632E-02 , -1.35003878E-02 , 0.177521497 , 0.731866539 , 9.06119570E-02, - 2.74999999E-02 , 0.573927343 , 4.05430831E-02 , 2.42461301E-02 , -1.35174291E-02 , 0.177414611 , 0.731882572 , 9.07028094E-02, - 2.85000000E-02 , 0.573762894 , 4.05661911E-02 , 2.42595226E-02 , -1.35342898E-02 , 0.177305117 , 0.731896877 , 9.07979980E-02, - 2.95000002E-02 , 0.573598444 , 4.05892096E-02 , 2.42728423E-02 , -1.35509735E-02 , 0.177193031 , 0.731909454 , 9.08975154E-02, - 3.05000003E-02 , 0.573433876 , 4.06121388E-02 , 2.42860932E-02 , -1.35674803E-02 , 0.177078366 , 0.731920302 , 9.10013393E-02, - 3.15000005E-02 , 0.573269367 , 4.06349748E-02 , 2.42992751E-02 , -1.35838138E-02 , 0.176961109 , 0.731929421 , 9.11094695E-02, - 3.24999988E-02 , 0.573104799 , 4.06577215E-02 , 2.43123900E-02 , -1.35999750E-02 , 0.176841274 , 0.731936812 , 9.12219137E-02, - 3.35000008E-02 , 0.572940171 , 4.06803750E-02 , 2.43254397E-02 , -1.36159649E-02 , 0.176718846 , 0.731942475 , 9.13386792E-02, - 3.44999991E-02 , 0.572775543 , 4.07029316E-02 , 2.43384279E-02 , -1.36317844E-02 , 0.176593810 , 0.731946409 , 9.14597660E-02, - 3.55000012E-02 , 0.572610915 , 4.07253951E-02 , 2.43513510E-02 , -1.36474352E-02 , 0.176466182 , 0.731948614 , 9.15851891E-02, - 3.64999995E-02 , 0.572446167 , 4.07477617E-02 , 2.43642144E-02 , -1.36629166E-02 , 0.176335946 , 0.731949091 , 9.17149633E-02, - 3.75000015E-02 , 0.572281480 , 4.07700278E-02 , 2.43770182E-02 , -1.36782313E-02 , 0.176203087 , 0.731947839 , 9.18490961E-02, - 3.84999998E-02 , 0.572116673 , 4.07921970E-02 , 2.43897643E-02 , -1.36933802E-02 , 0.176067606 , 0.731944799 , 9.19876024E-02, - 3.95000018E-02 , 0.571951866 , 4.08142619E-02 , 2.44024526E-02 , -1.37083633E-02 , 0.175929502 , 0.731940031 , 9.21304747E-02, - 4.05000001E-02 , 0.571787059 , 4.08362262E-02 , 2.44150888E-02 , -1.37231825E-02 , 0.175788775 , 0.731933475 , 9.22777429E-02, - 4.14999984E-02 , 0.571622133 , 4.08580862E-02 , 2.44276691E-02 , -1.37378387E-02 , 0.175645396 , 0.731925189 , 9.24293920E-02, - 4.25000004E-02 , 0.571457267 , 4.08798419E-02 , 2.44401973E-02 , -1.37523329E-02 , 0.175499380 , 0.731915176 , 9.25854519E-02, - 4.34999987E-02 , 0.571292281 , 4.09014896E-02 , 2.44526770E-02 , -1.37666669E-02 , 0.175350726 , 0.731903374 , 9.27459151E-02, - 4.45000008E-02 , 0.571127295 , 4.09230292E-02 , 2.44651064E-02 , -1.37808416E-02 , 0.175199404 , 0.731889784 , 9.29107890E-02, - 4.54999991E-02 , 0.570962250 , 4.09444608E-02 , 2.44774893E-02 , -1.37948571E-02 , 0.175045431 , 0.731874466 , 9.30800810E-02, - 4.65000011E-02 , 0.570797145 , 4.09657806E-02 , 2.44898256E-02 , -1.38087161E-02 , 0.174888805 , 0.731857359 , 9.32538062E-02, - 4.74999994E-02 , 0.570631981 , 4.09869850E-02 , 2.45021190E-02 , -1.38224186E-02 , 0.174729496 , 0.731838524 , 9.34319720E-02, - 4.85000014E-02 , 0.570466816 , 4.10080776E-02 , 2.45143697E-02 , -1.38359666E-02 , 0.174567536 , 0.731817901 , 9.36145708E-02, - 4.94999997E-02 , 0.570301592 , 4.10290547E-02 , 2.45265793E-02 , -1.38493609E-02 , 0.174402878 , 0.731795490 , 9.38016176E-02, - 5.05000018E-02 , 0.570136309 , 4.10499126E-02 , 2.45387498E-02 , -1.38626024E-02 , 0.174235553 , 0.731771350 , 9.39931199E-02, - 5.15000001E-02 , 0.569971025 , 4.10706550E-02 , 2.45508850E-02 , -1.38756940E-02 , 0.174065530 , 0.731745422 , 9.41890776E-02, - 5.24999984E-02 , 0.569805622 , 4.10912707E-02 , 2.45629847E-02 , -1.38886357E-02 , 0.173892811 , 0.731717706 , 9.43894982E-02, - 5.35000004E-02 , 0.569640219 , 4.11117673E-02 , 2.45750509E-02 , -1.39014283E-02 , 0.173717394 , 0.731688201 , 9.45943892E-02, - 5.44999987E-02 , 0.569474757 , 4.11321409E-02 , 2.45870855E-02 , -1.39140757E-02 , 0.173539281 , 0.731656969 , 9.48037580E-02, - 5.55000007E-02 , 0.569309235 , 4.11523841E-02 , 2.45990921E-02 , -1.39265768E-02 , 0.173358455 , 0.731623948 , 9.50176045E-02, - 5.64999990E-02 , 0.569143653 , 4.11725007E-02 , 2.46110708E-02 , -1.39389345E-02 , 0.173174903 , 0.731589139 , 9.52359363E-02, - 5.75000010E-02 , 0.568978012 , 4.11924832E-02 , 2.46230271E-02 , -1.39511507E-02 , 0.172988623 , 0.731552601 , 9.54587534E-02, - 5.84999993E-02 , 0.568812311 , 4.12123352E-02 , 2.46349592E-02 , -1.39632262E-02 , 0.172799632 , 0.731514335 , 9.56860632E-02, - 5.95000014E-02 , 0.568646550 , 4.12320495E-02 , 2.46468727E-02 , -1.39751639E-02 , 0.172607884 , 0.731474280 , 9.59178656E-02, - 6.04999997E-02 , 0.568480730 , 4.12516259E-02 , 2.46587694E-02 , -1.39869656E-02 , 0.172413394 , 0.731432438 , 9.61541682E-02, - 6.15000017E-02 , 0.568314850 , 4.12710607E-02 , 2.46706530E-02 , -1.39986323E-02 , 0.172216147 , 0.731388867 , 9.63949710E-02, - 6.25000000E-02 , 0.568148911 , 4.12903503E-02 , 2.46825255E-02 , -1.40101677E-02 , 0.172016144 , 0.731343567 , 9.66402814E-02, - 6.35000020E-02 , 0.567982912 , 4.13094945E-02 , 2.46943906E-02 , -1.40215736E-02 , 0.171813369 , 0.731296539 , 9.68900993E-02, - 6.44999966E-02 , 0.567816854 , 4.13284861E-02 , 2.47062519E-02 , -1.40328519E-02 , 0.171607807 , 0.731247783 , 9.71444249E-02, - 6.54999986E-02 , 0.567650735 , 4.13473211E-02 , 2.47181114E-02 , -1.40440054E-02 , 0.171399474 , 0.731197238 , 9.74032655E-02, - 6.65000007E-02 , 0.567484558 , 4.13659997E-02 , 2.47299764E-02 , -1.40550369E-02 , 0.171188325 , 0.731145084 , 9.76666138E-02, - 6.75000027E-02 , 0.567318320 , 4.13845181E-02 , 2.47418471E-02 , -1.40659502E-02 , 0.170974374 , 0.731091142 , 9.79344845E-02, - 6.84999973E-02 , 0.567152023 , 4.14028689E-02 , 2.47537289E-02 , -1.40767479E-02 , 0.170757592 , 0.731035531 , 9.82068628E-02, - 6.94999993E-02 , 0.566985607 , 4.14210483E-02 , 2.47656275E-02 , -1.40874321E-02 , 0.170537993 , 0.730978251 , 9.84837636E-02, - 7.05000013E-02 , 0.566819191 , 4.14390527E-02 , 2.47775484E-02 , -1.40980082E-02 , 0.170315534 , 0.730919302 , 9.87651795E-02, - 7.15000033E-02 , 0.566652656 , 4.14568745E-02 , 2.47894935E-02 , -1.41084781E-02 , 0.170090228 , 0.730858624 , 9.90511179E-02, - 7.24999979E-02 , 0.566486061 , 4.14745137E-02 , 2.48014685E-02 , -1.41188465E-02 , 0.169862062 , 0.730796397 , 9.93415713E-02, - 7.34999999E-02 , 0.566319406 , 4.14919592E-02 , 2.48134807E-02 , -1.41291162E-02 , 0.169631004 , 0.730732441 , 9.96365473E-02, - 7.45000020E-02 , 0.566152692 , 4.15092111E-02 , 2.48255339E-02 , -1.41392928E-02 , 0.169397056 , 0.730666876 , 9.99360383E-02, - 7.54999965E-02 , 0.565985858 , 4.15262580E-02 , 2.48376355E-02 , -1.41493799E-02 , 0.169160202 , 0.730599761 , 0.100240052 , - 7.64999986E-02 , 0.565818965 , 4.15431000E-02 , 2.48497911E-02 , -1.41593814E-02 , 0.168920428 , 0.730530977 , 0.100548580 , - 7.75000006E-02 , 0.565652013 , 4.15597260E-02 , 2.48620044E-02 , -1.41693018E-02 , 0.168677703 , 0.730460644 , 0.100861631 , - 7.85000026E-02 , 0.565485001 , 4.15761322E-02 , 2.48742830E-02 , -1.41791450E-02 , 0.168432042 , 0.730388761 , 0.101179205 , - 7.94999972E-02 , 0.565317869 , 4.15923111E-02 , 2.48866342E-02 , -1.41889164E-02 , 0.168183401 , 0.730315328 , 0.101501293 , - 8.04999992E-02 , 0.565150678 , 4.16082591E-02 , 2.48990618E-02 , -1.41986208E-02 , 0.167931795 , 0.730240285 , 0.101827897 , - 8.15000013E-02 , 0.564983428 , 4.16239686E-02 , 2.49115750E-02 , -1.42082619E-02 , 0.167677179 , 0.730163813 , 0.102159023 , - 8.25000033E-02 , 0.564816058 , 4.16394323E-02 , 2.49241758E-02 , -1.42178452E-02 , 0.167419568 , 0.730085790 , 0.102494672 , - 8.34999979E-02 , 0.564648628 , 4.16546427E-02 , 2.49368753E-02 , -1.42273735E-02 , 0.167158917 , 0.730006218 , 0.102834836 , - 8.44999999E-02 , 0.564481139 , 4.16695997E-02 , 2.49496773E-02 , -1.42368525E-02 , 0.166895241 , 0.729925215 , 0.103179514 , - 8.55000019E-02 , 0.564313531 , 4.16842923E-02 , 2.49625854E-02 , -1.42462859E-02 , 0.166628510 , 0.729842782 , 0.103528716 , - 8.64999965E-02 , 0.564145863 , 4.16987166E-02 , 2.49756072E-02 , -1.42556773E-02 , 0.166358709 , 0.729758859 , 0.103882439 , - 8.74999985E-02 , 0.563978076 , 4.17128652E-02 , 2.49887481E-02 , -1.42650316E-02 , 0.166085824 , 0.729673505 , 0.104240686 , - 8.85000005E-02 , 0.563810229 , 4.17267382E-02 , 2.50020120E-02 , -1.42743504E-02 , 0.165809840 , 0.729586720 , 0.104603447 , - 8.95000026E-02 , 0.563642263 , 4.17403281E-02 , 2.50154026E-02 , -1.42836375E-02 , 0.165530771 , 0.729498506 , 0.104970731 , - 9.04999971E-02 , 0.563474238 , 4.17536348E-02 , 2.50289254E-02 , -1.42928958E-02 , 0.165248573 , 0.729408920 , 0.105342537 , - 9.14999992E-02 , 0.563306153 , 4.17666472E-02 , 2.50425823E-02 , -1.43021280E-02 , 0.164963245 , 0.729317904 , 0.105718873 , - 9.25000012E-02 , 0.563137949 , 4.17793691E-02 , 2.50563771E-02 , -1.43113350E-02 , 0.164674789 , 0.729225457 , 0.106099732 , - 9.35000032E-02 , 0.562969625 , 4.17917967E-02 , 2.50703096E-02 , -1.43205188E-02 , 0.164383188 , 0.729131699 , 0.106485114 , - 9.44999978E-02 , 0.562801242 , 4.18039300E-02 , 2.50843819E-02 , -1.43296793E-02 , 0.164088428 , 0.729036570 , 0.106875025 , - 9.54999998E-02 , 0.562632799 , 4.18157689E-02 , 2.50985958E-02 , -1.43388184E-02 , 0.163790509 , 0.728940010 , 0.107269473 , - 9.65000018E-02 , 0.562464178 , 4.18273099E-02 , 2.51129512E-02 , -1.43479342E-02 , 0.163489416 , 0.728842139 , 0.107668452 , - 9.74999964E-02 , 0.562295556 , 4.18385565E-02 , 2.51274444E-02 , -1.43570267E-02 , 0.163185149 , 0.728742898 , 0.108071961 , - 9.84999985E-02 , 0.562126756 , 4.18495089E-02 , 2.51420774E-02 , -1.43660940E-02 , 0.162877724 , 0.728642285 , 0.108480006 , - 9.95000005E-02 , 0.561957896 , 4.18601707E-02 , 2.51568444E-02 , -1.43751344E-02 , 0.162567109 , 0.728540301 , 0.108892590 , - 0.100500003 , 0.561788917 , 4.18705493E-02 , 2.51717456E-02 , -1.43841449E-02 , 0.162253320 , 0.728436947 , 0.109309711 , - 0.101499997 , 0.561619878 , 4.18806411E-02 , 2.51867734E-02 , -1.43931238E-02 , 0.161936343 , 0.728332281 , 0.109731369 , - 0.102499999 , 0.561450660 , 4.18904535E-02 , 2.52019260E-02 , -1.44020654E-02 , 0.161616191 , 0.728226244 , 0.110157572 , - 0.103500001 , 0.561281383 , 4.18999940E-02 , 2.52171978E-02 , -1.44109679E-02 , 0.161292851 , 0.728118837 , 0.110588312 , - 0.104500003 , 0.561111987 , 4.19092700E-02 , 2.52325814E-02 , -1.44198257E-02 , 0.160966352 , 0.728010058 , 0.111023597 , - 0.105499998 , 0.560942531 , 4.19182815E-02 , 2.52480730E-02 , -1.44286342E-02 , 0.160636663 , 0.727899909 , 0.111463428 , - 0.106500000 , 0.560772896 , 4.19270396E-02 , 2.52636634E-02 , -1.44373877E-02 , 0.160303816 , 0.727788389 , 0.111907795 , - 0.107500002 , 0.560603201 , 4.19355519E-02 , 2.52793469E-02 , -1.44460816E-02 , 0.159967795 , 0.727675498 , 0.112356707 , - 0.108499996 , 0.560433328 , 4.19438221E-02 , 2.52951160E-02 , -1.44547094E-02 , 0.159628630 , 0.727561235 , 0.112810157 , - 0.109499998 , 0.560263395 , 4.19518650E-02 , 2.53109634E-02 , -1.44632664E-02 , 0.159286290 , 0.727445543 , 0.113268152 , - 0.110500000 , 0.560093284 , 4.19596806E-02 , 2.53268816E-02 , -1.44717460E-02 , 0.158940807 , 0.727328479 , 0.113730676 , - 0.111500002 , 0.559923112 , 4.19672839E-02 , 2.53428612E-02 , -1.44801419E-02 , 0.158592194 , 0.727210045 , 0.114197746 , - 0.112499997 , 0.559752762 , 4.19746749E-02 , 2.53588986E-02 , -1.44884493E-02 , 0.158240438 , 0.727090240 , 0.114669345 , - 0.113499999 , 0.559582293 , 4.19818684E-02 , 2.53749806E-02 , -1.44966627E-02 , 0.157885551 , 0.726969004 , 0.115145475 , - 0.114500001 , 0.559411705 , 4.19888683E-02 , 2.53911037E-02 , -1.45047745E-02 , 0.157527551 , 0.726846337 , 0.115626127 , - 0.115500003 , 0.559240997 , 4.19956855E-02 , 2.54072603E-02 , -1.45127801E-02 , 0.157166421 , 0.726722240 , 0.116111316 , - 0.116499998 , 0.559070170 , 4.20023203E-02 , 2.54234429E-02 , -1.45206749E-02 , 0.156802192 , 0.726596773 , 0.116601013 , - 0.117500000 , 0.558899164 , 4.20087874E-02 , 2.54396442E-02 , -1.45284534E-02 , 0.156434864 , 0.726469874 , 0.117095232 , - 0.118500002 , 0.558728039 , 4.20150906E-02 , 2.54558586E-02 , -1.45361116E-02 , 0.156064436 , 0.726341605 , 0.117593966 , - 0.119499996 , 0.558556795 , 4.20212336E-02 , 2.54720822E-02 , -1.45436432E-02 , 0.155690923 , 0.726211846 , 0.118097201 , - 0.120499998 , 0.558385372 , 4.20272239E-02 , 2.54883058E-02 , -1.45510444E-02 , 0.155314341 , 0.726080716 , 0.118604943 , - 0.121500000 , 0.558213770 , 4.20330651E-02 , 2.55045276E-02 , -1.45583125E-02 , 0.154934675 , 0.725948155 , 0.119117178 , - 0.122500002 , 0.558042049 , 4.20387648E-02 , 2.55207419E-02 , -1.45654436E-02 , 0.154551938 , 0.725814164 , 0.119633906 , - 0.123499997 , 0.557870209 , 4.20443267E-02 , 2.55369432E-02 , -1.45724332E-02 , 0.154166147 , 0.725678742 , 0.120155126 , - 0.124499999 , 0.557698190 , 4.20497544E-02 , 2.55531278E-02 , -1.45792784E-02 , 0.153777301 , 0.725541890 , 0.120680816 , - 0.125499994 , 0.557525992 , 4.20550518E-02 , 2.55692918E-02 , -1.45859765E-02 , 0.153385401 , 0.725403607 , 0.121210985 , - 0.126499996 , 0.557353675 , 4.20602225E-02 , 2.55854335E-02 , -1.45925246E-02 , 0.152990445 , 0.725263953 , 0.121745616 , - 0.127499998 , 0.557181180 , 4.20652702E-02 , 2.56015491E-02 , -1.45989209E-02 , 0.152592465 , 0.725122809 , 0.122284710 , - 0.128500000 , 0.557008505 , 4.20701988E-02 , 2.56176349E-02 , -1.46051617E-02 , 0.152191460 , 0.724980295 , 0.122828253 , - 0.129500002 , 0.556835651 , 4.20750119E-02 , 2.56336872E-02 , -1.46112461E-02 , 0.151787415 , 0.724836349 , 0.123376250 , - 0.130500004 , 0.556662619 , 4.20797132E-02 , 2.56497059E-02 , -1.46171711E-02 , 0.151380345 , 0.724690974 , 0.123928681 , - 0.131500006 , 0.556489468 , 4.20842990E-02 , 2.56656855E-02 , -1.46229351E-02 , 0.150970280 , 0.724544168 , 0.124485545 , - 0.132499993 , 0.556316078 , 4.20887768E-02 , 2.56816279E-02 , -1.46285370E-02 , 0.150557190 , 0.724395990 , 0.125046834 , - 0.133499995 , 0.556142569 , 4.20931503E-02 , 2.56975275E-02 , -1.46339731E-02 , 0.150141105 , 0.724246383 , 0.125612542 , - 0.134499997 , 0.555968821 , 4.20974195E-02 , 2.57133823E-02 , -1.46392426E-02 , 0.149722025 , 0.724095345 , 0.126182646 , - 0.135499999 , 0.555794954 , 4.21015881E-02 , 2.57291906E-02 , -1.46443443E-02 , 0.149299949 , 0.723942876 , 0.126757160 , - 0.136500001 , 0.555620849 , 4.21056561E-02 , 2.57449523E-02 , -1.46492757E-02 , 0.148874894 , 0.723789036 , 0.127336055 , - 0.137500003 , 0.555446565 , 4.21096273E-02 , 2.57606637E-02 , -1.46540357E-02 , 0.148446858 , 0.723633826 , 0.127919346 , - 0.138500005 , 0.555272102 , 4.21135016E-02 , 2.57763229E-02 , -1.46586224E-02 , 0.148015857 , 0.723477125 , 0.128507003 , - 0.139500007 , 0.555097401 , 4.21172827E-02 , 2.57919300E-02 , -1.46630351E-02 , 0.147581875 , 0.723319113 , 0.129099011 , - 0.140499994 , 0.554922581 , 4.21209745E-02 , 2.58074813E-02 , -1.46672716E-02 , 0.147144958 , 0.723159671 , 0.129695386 , - 0.141499996 , 0.554747462 , 4.21245769E-02 , 2.58229747E-02 , -1.46713303E-02 , 0.146705076 , 0.722998798 , 0.130296111 , - 0.142499998 , 0.554572225 , 4.21280898E-02 , 2.58384105E-02 , -1.46752102E-02 , 0.146262258 , 0.722836554 , 0.130901158 , - 0.143500000 , 0.554396749 , 4.21315171E-02 , 2.58537866E-02 , -1.46789113E-02 , 0.145816505 , 0.722672939 , 0.131510541 , - 0.144500002 , 0.554221034 , 4.21348624E-02 , 2.58691013E-02 , -1.46824298E-02 , 0.145367816 , 0.722507954 , 0.132124230 , - 0.145500004 , 0.554045141 , 4.21381257E-02 , 2.58843526E-02 , -1.46857658E-02 , 0.144916207 , 0.722341537 , 0.132742241 , - 0.146500006 , 0.553869009 , 4.21413071E-02 , 2.58995406E-02 , -1.46889184E-02 , 0.144461691 , 0.722173810 , 0.133364528 , - 0.147499993 , 0.553692698 , 4.21444103E-02 , 2.59146634E-02 , -1.46918865E-02 , 0.144004270 , 0.722004652 , 0.133991092 , - 0.148499995 , 0.553516090 , 4.21474315E-02 , 2.59297192E-02 , -1.46946684E-02 , 0.143543944 , 0.721834123 , 0.134621933 , - 0.149499997 , 0.553339303 , 4.21503820E-02 , 2.59447079E-02 , -1.46972630E-02 , 0.143080726 , 0.721662223 , 0.135257050 , - 0.150500000 , 0.553162277 , 4.21532542E-02 , 2.59596296E-02 , -1.46996705E-02 , 0.142614633 , 0.721488953 , 0.135896400 , - 0.151500002 , 0.552985013 , 4.21560518E-02 , 2.59744786E-02 , -1.47018880E-02 , 0.142145663 , 0.721314371 , 0.136539981 , - 0.152500004 , 0.552807570 , 4.21587788E-02 , 2.59892587E-02 , -1.47039173E-02 , 0.141673833 , 0.721138358 , 0.137187794 , - 0.153500006 , 0.552629828 , 4.21614349E-02 , 2.60039680E-02 , -1.47057548E-02 , 0.141199127 , 0.720961034 , 0.137839824 , - 0.154499993 , 0.552451849 , 4.21640202E-02 , 2.60186046E-02 , -1.47074014E-02 , 0.140721589 , 0.720782340 , 0.138496056 , - 0.155499995 , 0.552273631 , 4.21665348E-02 , 2.60331687E-02 , -1.47088561E-02 , 0.140241206 , 0.720602334 , 0.139156476 , - 0.156499997 , 0.552095175 , 4.21689823E-02 , 2.60476582E-02 , -1.47101181E-02 , 0.139757991 , 0.720420957 , 0.139821067 , - 0.157499999 , 0.551916420 , 4.21713628E-02 , 2.60620750E-02 , -1.47111872E-02 , 0.139271945 , 0.720238209 , 0.140489817 , - 0.158500001 , 0.551737428 , 4.21736762E-02 , 2.60764156E-02 , -1.47120617E-02 , 0.138783082 , 0.720054209 , 0.141162723 , - 0.159500003 , 0.551558197 , 4.21759263E-02 , 2.60906816E-02 , -1.47127407E-02 , 0.138291419 , 0.719868779 , 0.141839772 , - 0.160500005 , 0.551378667 , 4.21781093E-02 , 2.61048712E-02 , -1.47132259E-02 , 0.137796968 , 0.719682097 , 0.142520949 , - 0.161500007 , 0.551198900 , 4.21802290E-02 , 2.61189863E-02 , -1.47135137E-02 , 0.137299716 , 0.719494045 , 0.143206224 , - 0.162499994 , 0.551018834 , 4.21822853E-02 , 2.61330232E-02 , -1.47136068E-02 , 0.136799678 , 0.719304740 , 0.143895596 , - 0.163499996 , 0.550838530 , 4.21842821E-02 , 2.61469819E-02 , -1.47135016E-02 , 0.136296883 , 0.719114065 , 0.144589067 , - 0.164499998 , 0.550657928 , 4.21862155E-02 , 2.61608642E-02 , -1.47131998E-02 , 0.135791332 , 0.718922079 , 0.145286590 , - 0.165500000 , 0.550477028 , 4.21880856E-02 , 2.61746701E-02 , -1.47127006E-02 , 0.135283023 , 0.718728781 , 0.145988181 , - 0.166500002 , 0.550295889 , 4.21898961E-02 , 2.61883959E-02 , -1.47120031E-02 , 0.134771973 , 0.718534231 , 0.146693811 , - 0.167500004 , 0.550114393 , 4.21916507E-02 , 2.62020454E-02 , -1.47111062E-02 , 0.134258181 , 0.718338370 , 0.147403464 , - 0.168500006 , 0.549932659 , 4.21933420E-02 , 2.62156148E-02 , -1.47100110E-02 , 0.133741677 , 0.718141198 , 0.148117140 , - 0.169499993 , 0.549750566 , 4.21949774E-02 , 2.62291078E-02 , -1.47087174E-02 , 0.133222461 , 0.717942715 , 0.148834810 , - 0.170499995 , 0.549568236 , 4.21965532E-02 , 2.62425207E-02 , -1.47072235E-02 , 0.132700548 , 0.717742980 , 0.149556458 , - 0.171499997 , 0.549385548 , 4.21980694E-02 , 2.62558535E-02 , -1.47055294E-02 , 0.132175937 , 0.717541993 , 0.150282085 , - 0.172499999 , 0.549202561 , 4.21995334E-02 , 2.62691099E-02 , -1.47036361E-02 , 0.131648645 , 0.717339694 , 0.151011661 , - 0.173500001 , 0.549019277 , 4.22009379E-02 , 2.62822863E-02 , -1.47015424E-02 , 0.131118685 , 0.717136145 , 0.151745170 , - 0.174500003 , 0.548835695 , 4.22022827E-02 , 2.62953825E-02 , -1.46992477E-02 , 0.130586058 , 0.716931343 , 0.152482614 , - 0.175500005 , 0.548651755 , 4.22035754E-02 , 2.63084024E-02 , -1.46967527E-02 , 0.130050778 , 0.716725290 , 0.153223962 , - 0.176499993 , 0.548467457 , 4.22048122E-02 , 2.63213422E-02 , -1.46940565E-02 , 0.129512861 , 0.716517925 , 0.153969198 , - 0.177499995 , 0.548282862 , 4.22059931E-02 , 2.63342019E-02 , -1.46911591E-02 , 0.128972322 , 0.716309369 , 0.154718310 , - 0.178499997 , 0.548097968 , 4.22071218E-02 , 2.63469853E-02 , -1.46880616E-02 , 0.128429160 , 0.716099560 , 0.155471295 , - 0.179499999 , 0.547912657 , 4.22081910E-02 , 2.63596885E-02 , -1.46847609E-02 , 0.127883375 , 0.715888500 , 0.156228110 , - 0.180500001 , 0.547727048 , 4.22092117E-02 , 2.63723135E-02 , -1.46812601E-02 , 0.127335012 , 0.715676248 , 0.156988755 , - 0.181500003 , 0.547541082 , 4.22101729E-02 , 2.63848603E-02 , -1.46775572E-02 , 0.126784056 , 0.715462744 , 0.157753214 , - 0.182500005 , 0.547354758 , 4.22110856E-02 , 2.63973288E-02 , -1.46736521E-02 , 0.126230523 , 0.715247989 , 0.158521473 , - 0.183500007 , 0.547168076 , 4.22119386E-02 , 2.64097210E-02 , -1.46695459E-02 , 0.125674441 , 0.715032041 , 0.159293503 , - 0.184499994 , 0.546981037 , 4.22127433E-02 , 2.64220331E-02 , -1.46652376E-02 , 0.125115797 , 0.714814901 , 0.160069302 , - 0.185499996 , 0.546793640 , 4.22134921E-02 , 2.64342688E-02 , -1.46607272E-02 , 0.124554612 , 0.714596570 , 0.160848841 , - 0.186499998 , 0.546605825 , 4.22141925E-02 , 2.64464281E-02 , -1.46560147E-02 , 0.123990893 , 0.714376986 , 0.161632121 , - 0.187500000 , 0.546417654 , 4.22148369E-02 , 2.64585093E-02 , -1.46511002E-02 , 0.123424664 , 0.714156270 , 0.162419096 , - 0.188500002 , 0.546229124 , 4.22154292E-02 , 2.64705140E-02 , -1.46459844E-02 , 0.122855924 , 0.713934302 , 0.163209766 , - 0.189500004 , 0.546040177 , 4.22159694E-02 , 2.64824443E-02 , -1.46406656E-02 , 0.122284696 , 0.713711202 , 0.164004117 , - 0.190500006 , 0.545850873 , 4.22164537E-02 , 2.64942963E-02 , -1.46351457E-02 , 0.121710978 , 0.713486910 , 0.164802134 , - 0.191499993 , 0.545661151 , 4.22168896E-02 , 2.65060738E-02 , -1.46294227E-02 , 0.121134795 , 0.713261425 , 0.165603787 , - 0.192499995 , 0.545471013 , 4.22172733E-02 , 2.65177749E-02 , -1.46234985E-02 , 0.120556153 , 0.713034809 , 0.166409060 , - 0.193499997 , 0.545280516 , 4.22176085E-02 , 2.65294015E-02 , -1.46173723E-02 , 0.119975068 , 0.712807000 , 0.167217940 , - 0.194499999 , 0.545089543 , 4.22178879E-02 , 2.65409537E-02 , -1.46110430E-02 , 0.119391546 , 0.712578058 , 0.168030411 , - 0.195500001 , 0.544898212 , 4.22181152E-02 , 2.65524331E-02 , -1.46045135E-02 , 0.118805602 , 0.712347925 , 0.168846458 , - 0.196500003 , 0.544706464 , 4.22182940E-02 , 2.65638363E-02 , -1.45977810E-02 , 0.118217252 , 0.712116718 , 0.169666052 , - 0.197500005 , 0.544514239 , 4.22184207E-02 , 2.65751686E-02 , -1.45908464E-02 , 0.117626503 , 0.711884320 , 0.170489177 , - 0.198500007 , 0.544321597 , 4.22184952E-02 , 2.65864264E-02 , -1.45837115E-02 , 0.117033370 , 0.711650848 , 0.171315819 , - 0.199499995 , 0.544128537 , 4.22185212E-02 , 2.65976116E-02 , -1.45763736E-02 , 0.116437860 , 0.711416185 , 0.172145948 , - 0.200499997 , 0.543935001 , 4.22184914E-02 , 2.66087260E-02 , -1.45688346E-02 , 0.115840003 , 0.711180449 , 0.172979563 , - 0.201499999 , 0.543741047 , 4.22184132E-02 , 2.66197678E-02 , -1.45610943E-02 , 0.115239792 , 0.710943580 , 0.173816636 , - 0.202500001 , 0.543546617 , 4.22182865E-02 , 2.66307388E-02 , -1.45531520E-02 , 0.114637248 , 0.710705578 , 0.174657151 , - 0.203500003 , 0.543351769 , 4.22181077E-02 , 2.66416389E-02 , -1.45450085E-02 , 0.114032388 , 0.710466564 , 0.175501078 , - 0.204500005 , 0.543156445 , 4.22178768E-02 , 2.66524702E-02 , -1.45366648E-02 , 0.113425218 , 0.710226357 , 0.176348418 , - 0.205500007 , 0.542960644 , 4.22175936E-02 , 2.66632307E-02 , -1.45281190E-02 , 0.112815753 , 0.709985137 , 0.177199125 , - 0.206499994 , 0.542764366 , 4.22172621E-02 , 2.66739223E-02 , -1.45193730E-02 , 0.112204015 , 0.709742785 , 0.178053215 , - 0.207499996 , 0.542567611 , 4.22168784E-02 , 2.66845450E-02 , -1.45104248E-02 , 0.111589998 , 0.709499359 , 0.178910628 , - 0.208499998 , 0.542370319 , 4.22164463E-02 , 2.66951006E-02 , -1.45012774E-02 , 0.110973738 , 0.709254861 , 0.179771379 , - 0.209500000 , 0.542172611 , 4.22159620E-02 , 2.67055873E-02 , -1.44919287E-02 , 0.110355228 , 0.709009349 , 0.180635437 , - 0.210500002 , 0.541974366 , 4.22154255E-02 , 2.67160088E-02 , -1.44823790E-02 , 0.109734498 , 0.708762705 , 0.181502774 , - 0.211500004 , 0.541775644 , 4.22148407E-02 , 2.67263632E-02 , -1.44726299E-02 , 0.109111555 , 0.708515048 , 0.182373375 , - 0.212500006 , 0.541576385 , 4.22142036E-02 , 2.67366506E-02 , -1.44626806E-02 , 0.108486407 , 0.708266377 , 0.183247223 , - 0.213499993 , 0.541376650 , 4.22135182E-02 , 2.67468747E-02 , -1.44525301E-02 , 0.107859075 , 0.708016634 , 0.184124291 , - 0.214499995 , 0.541176379 , 4.22127806E-02 , 2.67570335E-02 , -1.44421812E-02 , 0.107229568 , 0.707765877 , 0.185004577 , - 0.215499997 , 0.540975571 , 4.22119945E-02 , 2.67671291E-02 , -1.44316312E-02 , 0.106597908 , 0.707514048 , 0.185888037 , - 0.216499999 , 0.540774226 , 4.22111526E-02 , 2.67771594E-02 , -1.44208828E-02 , 0.105964102 , 0.707261264 , 0.186774656 , - 0.217500001 , 0.540572345 , 4.22102660E-02 , 2.67871283E-02 , -1.44099342E-02 , 0.105328165 , 0.707007408 , 0.187664434 , - 0.218500003 , 0.540369928 , 4.22093272E-02 , 2.67970338E-02 , -1.43987862E-02 , 0.104690112 , 0.706752539 , 0.188557327 , - 0.219500005 , 0.540166974 , 4.22083363E-02 , 2.68068779E-02 , -1.43874399E-02 , 0.104049951 , 0.706496716 , 0.189453319 , - 0.220500007 , 0.539963424 , 4.22072932E-02 , 2.68166624E-02 , -1.43758943E-02 , 0.103407711 , 0.706239879 , 0.190352395 , - 0.221499994 , 0.539759338 , 4.22062017E-02 , 2.68263854E-02 , -1.43641494E-02 , 0.102763392 , 0.705982089 , 0.191254541 , - 0.222499996 , 0.539554715 , 4.22050618E-02 , 2.68360488E-02 , -1.43522071E-02 , 0.102117017 , 0.705723286 , 0.192159727 , - 0.223499998 , 0.539349496 , 4.22038659E-02 , 2.68456545E-02 , -1.43400654E-02 , 0.101468593 , 0.705463469 , 0.193067923 , - 0.224500000 , 0.539143682 , 4.22026254E-02 , 2.68552005E-02 , -1.43277254E-02 , 0.100818135 , 0.705202758 , 0.193979114 , - 0.225500003 , 0.538937271 , 4.22013290E-02 , 2.68646888E-02 , -1.43151879E-02 , 0.100165673 , 0.704941034 , 0.194893301 , - 0.226500005 , 0.538730264 , 4.21999842E-02 , 2.68741194E-02 , -1.43024521E-02 , 9.95111987E-02 , 0.704678357 , 0.195810437 , - 0.227500007 , 0.538522661 , 4.21985872E-02 , 2.68834941E-02 , -1.42895188E-02 , 9.88547429E-02 , 0.704414785 , 0.196730494 , - 0.228499994 , 0.538314521 , 4.21971418E-02 , 2.68928129E-02 , -1.42763881E-02 , 9.81963128E-02 , 0.704150200 , 0.197653487 , - 0.229499996 , 0.538105667 , 4.21956442E-02 , 2.69020777E-02 , -1.42630599E-02 , 9.75359231E-02 , 0.703884721 , 0.198579356 , - 0.230499998 , 0.537896276 , 4.21940945E-02 , 2.69112866E-02 , -1.42495343E-02 , 9.68735963E-02 , 0.703618288 , 0.199508101 , - 0.231500000 , 0.537686229 , 4.21924964E-02 , 2.69204434E-02 , -1.42358113E-02 , 9.62093398E-02 , 0.703350961 , 0.200439692 , - 0.232500002 , 0.537475526 , 4.21908461E-02 , 2.69295461E-02 , -1.42218927E-02 , 9.55431685E-02 , 0.703082740 , 0.201374114 , - 0.233500004 , 0.537264168 , 4.21891436E-02 , 2.69385949E-02 , -1.42077766E-02 , 9.48751047E-02 , 0.702813566 , 0.202311352 , - 0.234500006 , 0.537052214 , 4.21873927E-02 , 2.69475952E-02 , -1.41934641E-02 , 9.42051560E-02 , 0.702543497 , 0.203251362 , - 0.235499993 , 0.536839604 , 4.21855897E-02 , 2.69565415E-02 , -1.41789550E-02 , 9.35333371E-02 , 0.702272534 , 0.204194129 , - 0.236499995 , 0.536626339 , 4.21837345E-02 , 2.69654393E-02 , -1.41642503E-02 , 9.28596705E-02 , 0.702000678 , 0.205139652 , - 0.237499997 , 0.536412358 , 4.21818309E-02 , 2.69742869E-02 , -1.41493501E-02 , 9.21841636E-02 , 0.701727986 , 0.206087872 , - 0.238499999 , 0.536197782 , 4.21798714E-02 , 2.69830860E-02 , -1.41342534E-02 , 9.15068388E-02 , 0.701454341 , 0.207038805 , - 0.239500001 , 0.535982430 , 4.21778634E-02 , 2.69918367E-02 , -1.41189611E-02 , 9.08277035E-02 , 0.701179922 , 0.207992405 , - 0.240500003 , 0.535766482 , 4.21758071E-02 , 2.70005409E-02 , -1.41034732E-02 , 9.01467726E-02 , 0.700904548 , 0.208948657 , - 0.241500005 , 0.535549819 , 4.21736948E-02 , 2.70091966E-02 , -1.40877906E-02 , 8.94640759E-02 , 0.700628400 , 0.209907547 , - 0.242500007 , 0.535332441 , 4.21715342E-02 , 2.70178076E-02 , -1.40719134E-02 , 8.87796134E-02 , 0.700351357 , 0.210869029 , - 0.243499994 , 0.535114348 , 4.21693213E-02 , 2.70263720E-02 , -1.40558407E-02 , 8.80934075E-02 , 0.700073481 , 0.211833104 , - 0.244499996 , 0.534895539 , 4.21670564E-02 , 2.70348936E-02 , -1.40395733E-02 , 8.74054730E-02 , 0.699794769 , 0.212799743 , - 0.245499998 , 0.534676015 , 4.21647392E-02 , 2.70433705E-02 , -1.40231112E-02 , 8.67158249E-02 , 0.699515283 , 0.213768914 , - 0.246500000 , 0.534455717 , 4.21623737E-02 , 2.70518046E-02 , -1.40064554E-02 , 8.60244855E-02 , 0.699234903 , 0.214740604 , - 0.247500002 , 0.534234762 , 4.21599559E-02 , 2.70601958E-02 , -1.39896050E-02 , 8.53314549E-02 , 0.698953748 , 0.215714797 , - 0.248500004 , 0.534013033 , 4.21574824E-02 , 2.70685460E-02 , -1.39725609E-02 , 8.46367627E-02 , 0.698671758 , 0.216691449 , - 0.249500006 , 0.533790529 , 4.21549603E-02 , 2.70768553E-02 , -1.39553221E-02 , 8.39404240E-02 , 0.698389053 , 0.217670560 , - 0.250499994 , 0.533567309 , 4.21523899E-02 , 2.70851254E-02 , -1.39378905E-02 , 8.32424462E-02 , 0.698105454 , 0.218652084 , - 0.251500010 , 0.533343315 , 4.21497636E-02 , 2.70933546E-02 , -1.39202652E-02 , 8.25428441E-02 , 0.697821140 , 0.219636023 , - 0.252499998 , 0.533118486 , 4.21470851E-02 , 2.71015447E-02 , -1.39024463E-02 , 8.18416476E-02 , 0.697536051 , 0.220622331 , - 0.253500015 , 0.532892942 , 4.21443544E-02 , 2.71096993E-02 , -1.38844345E-02 , 8.11388642E-02 , 0.697250128 , 0.221610993 , - 0.254500002 , 0.532666624 , 4.21415754E-02 , 2.71178149E-02 , -1.38662299E-02 , 8.04345086E-02 , 0.696963489 , 0.222601995 , - 0.255499989 , 0.532439470 , 4.21387404E-02 , 2.71258950E-02 , -1.38478316E-02 , 7.97285959E-02 , 0.696676075 , 0.223595306 , - 0.256500006 , 0.532211542 , 4.21358570E-02 , 2.71339398E-02 , -1.38292415E-02 , 7.90211484E-02 , 0.696387947 , 0.224590912 , - 0.257499993 , 0.531982780 , 4.21329178E-02 , 2.71419492E-02 , -1.38104586E-02 , 7.83121809E-02 , 0.696099043 , 0.225588784 , - 0.258500010 , 0.531753182 , 4.21299301E-02 , 2.71499250E-02 , -1.37914829E-02 , 7.76017085E-02 , 0.695809424 , 0.226588875 , - 0.259499997 , 0.531522810 , 4.21268865E-02 , 2.71578673E-02 , -1.37723153E-02 , 7.68897384E-02 , 0.695519030 , 0.227591202 , - 0.260500014 , 0.531291544 , 4.21237908E-02 , 2.71657761E-02 , -1.37529559E-02 , 7.61763006E-02 , 0.695227981 , 0.228595719 , - 0.261500001 , 0.531059504 , 4.21206467E-02 , 2.71736551E-02 , -1.37334038E-02 , 7.54614100E-02 , 0.694936216 , 0.229602396 , - 0.262499988 , 0.530826569 , 4.21174467E-02 , 2.71815024E-02 , -1.37136597E-02 , 7.47450739E-02 , 0.694643676 , 0.230611220 , - 0.263500005 , 0.530592799 , 4.21141945E-02 , 2.71893200E-02 , -1.36937248E-02 , 7.40273148E-02 , 0.694350481 , 0.231622174 , - 0.264499992 , 0.530358136 , 4.21108902E-02 , 2.71971077E-02 , -1.36735979E-02 , 7.33081475E-02 , 0.694056630 , 0.232635230 , - 0.265500009 , 0.530122638 , 4.21075337E-02 , 2.72048656E-02 , -1.36532793E-02 , 7.25875869E-02 , 0.693762064 , 0.233650357 , - 0.266499996 , 0.529886246 , 4.21041250E-02 , 2.72125974E-02 , -1.36327697E-02 , 7.18656555E-02 , 0.693466783 , 0.234667540 , - 0.267500013 , 0.529648960 , 4.21006605E-02 , 2.72203013E-02 , -1.36120692E-02 , 7.11423680E-02 , 0.693170905 , 0.235686749 , - 0.268500000 , 0.529410779 , 4.20971438E-02 , 2.72279792E-02 , -1.35911768E-02 , 7.04177320E-02 , 0.692874312 , 0.236707956 , - 0.269499987 , 0.529171705 , 4.20935750E-02 , 2.72356328E-02 , -1.35700945E-02 , 6.96917772E-02 , 0.692577064 , 0.237731144 , - 0.270500004 , 0.528931737 , 4.20899540E-02 , 2.72432603E-02 , -1.35488203E-02 , 6.89645112E-02 , 0.692279220 , 0.238756284 , - 0.271499991 , 0.528690815 , 4.20862809E-02 , 2.72508636E-02 , -1.35273561E-02 , 6.82359561E-02 , 0.691980660 , 0.239783362 , - 0.272500008 , 0.528448939 , 4.20825519E-02 , 2.72584446E-02 , -1.35057010E-02 , 6.75061271E-02 , 0.691681504 , 0.240812346 , - 0.273499995 , 0.528206170 , 4.20787707E-02 , 2.72660032E-02 , -1.34838549E-02 , 6.67750388E-02 , 0.691381752 , 0.241843224 , - 0.274500012 , 0.527962446 , 4.20749336E-02 , 2.72735413E-02 , -1.34618189E-02 , 6.60427138E-02 , 0.691081345 , 0.242875949 , - 0.275500000 , 0.527717769 , 4.20710482E-02 , 2.72810571E-02 , -1.34395920E-02 , 6.53091595E-02 , 0.690780342 , 0.243910506 , - 0.276499987 , 0.527472138 , 4.20671031E-02 , 2.72885542E-02 , -1.34171750E-02 , 6.45743981E-02 , 0.690478742 , 0.244946882 , - 0.277500004 , 0.527225554 , 4.20631096E-02 , 2.72960309E-02 , -1.33945681E-02 , 6.38384521E-02 , 0.690176487 , 0.245985046 , - 0.278499991 , 0.526977956 , 4.20590565E-02 , 2.73034889E-02 , -1.33717712E-02 , 6.31013289E-02 , 0.689873695 , 0.247024968 , - 0.279500008 , 0.526729345 , 4.20549549E-02 , 2.73109321E-02 , -1.33487834E-02 , 6.23630472E-02 , 0.689570308 , 0.248066634 , - 0.280499995 , 0.526479781 , 4.20507975E-02 , 2.73183566E-02 , -1.33256065E-02 , 6.16236292E-02 , 0.689266384 , 0.249110013 , - 0.281500012 , 0.526229262 , 4.20465842E-02 , 2.73257643E-02 , -1.33022396E-02 , 6.08830862E-02 , 0.688961864 , 0.250155061 , - 0.282499999 , 0.525977671 , 4.20423187E-02 , 2.73331590E-02 , -1.32786818E-02 , 6.01414405E-02 , 0.688656747 , 0.251201808 , - 0.283499986 , 0.525725067 , 4.20379974E-02 , 2.73405369E-02 , -1.32549349E-02 , 5.93987070E-02 , 0.688351154 , 0.252250165 , - 0.284500003 , 0.525471449 , 4.20336202E-02 , 2.73479037E-02 , -1.32309990E-02 , 5.86549044E-02 , 0.688044965 , 0.253300160 , - 0.285499990 , 0.525216758 , 4.20291908E-02 , 2.73552556E-02 , -1.32068722E-02 , 5.79100475E-02 , 0.687738240 , 0.254351735 , - 0.286500007 , 0.524961054 , 4.20247056E-02 , 2.73625981E-02 , -1.31825563E-02 , 5.71641549E-02 , 0.687430978 , 0.255404860 , - 0.287499994 , 0.524704278 , 4.20201644E-02 , 2.73699276E-02 , -1.31580504E-02 , 5.64172417E-02 , 0.687123239 , 0.256459534 , - 0.288500011 , 0.524446487 , 4.20155674E-02 , 2.73772478E-02 , -1.31333554E-02 , 5.56693263E-02 , 0.686814964 , 0.257515728 , - 0.289499998 , 0.524187565 , 4.20109183E-02 , 2.73845587E-02 , -1.31084705E-02 , 5.49204275E-02 , 0.686506152 , 0.258573413 , - 0.290499985 , 0.523927569 , 4.20062132E-02 , 2.73918603E-02 , -1.30833965E-02 , 5.41705601E-02 , 0.686196864 , 0.259632587 , - 0.291500002 , 0.523666501 , 4.20014523E-02 , 2.73991544E-02 , -1.30581316E-02 , 5.34197465E-02 , 0.685887098 , 0.260693163 , - 0.292499989 , 0.523404360 , 4.19966318E-02 , 2.74064410E-02 , -1.30326785E-02 , 5.26679978E-02 , 0.685576797 , 0.261755168 , - 0.293500006 , 0.523141086 , 4.19917591E-02 , 2.74137203E-02 , -1.30070355E-02 , 5.19153364E-02 , 0.685266078 , 0.262818575 , - 0.294499993 , 0.522876680 , 4.19868305E-02 , 2.74209958E-02 , -1.29812025E-02 , 5.11617772E-02 , 0.684954882 , 0.263883352 , - 0.295500010 , 0.522611141 , 4.19818461E-02 , 2.74282675E-02 , -1.29551804E-02 , 5.04073389E-02 , 0.684643209 , 0.264949441 , - 0.296499997 , 0.522344530 , 4.19768058E-02 , 2.74355337E-02 , -1.29289683E-02 , 4.96520363E-02 , 0.684331059 , 0.266016871 , - 0.297500014 , 0.522076726 , 4.19717059E-02 , 2.74427980E-02 , -1.29025662E-02 , 4.88958918E-02 , 0.684018493 , 0.267085582 , - 0.298500001 , 0.521807790 , 4.19665501E-02 , 2.74500586E-02 , -1.28759751E-02 , 4.81389202E-02 , 0.683705509 , 0.268155575 , - 0.299499989 , 0.521537662 , 4.19613384E-02 , 2.74573192E-02 , -1.28491949E-02 , 4.73811366E-02 , 0.683392048 , 0.269226789 , - 0.300500005 , 0.521266401 , 4.19560708E-02 , 2.74645798E-02 , -1.28222238E-02 , 4.66225632E-02 , 0.683078229 , 0.270299226 , - 0.301499993 , 0.520993948 , 4.19507436E-02 , 2.74718404E-02 , -1.27950637E-02 , 4.58632149E-02 , 0.682763934 , 0.271372855 , - 0.302500010 , 0.520720303 , 4.19453606E-02 , 2.74791010E-02 , -1.27677135E-02 , 4.51031104E-02 , 0.682449222 , 0.272447646 , - 0.303499997 , 0.520445526 , 4.19399180E-02 , 2.74863653E-02 , -1.27401734E-02 , 4.43422683E-02 , 0.682134151 , 0.273523569 , - 0.304500014 , 0.520169437 , 4.19344194E-02 , 2.74936315E-02 , -1.27124442E-02 , 4.35807072E-02 , 0.681818664 , 0.274600625 , - 0.305500001 , 0.519892216 , 4.19288613E-02 , 2.75009014E-02 , -1.26845241E-02 , 4.28184420E-02 , 0.681502819 , 0.275678754 , - 0.306499988 , 0.519613743 , 4.19232473E-02 , 2.75081750E-02 , -1.26564140E-02 , 4.20554914E-02 , 0.681186557 , 0.276757926 , - 0.307500005 , 0.519334018 , 4.19175737E-02 , 2.75154542E-02 , -1.26281139E-02 , 4.12918739E-02 , 0.680869937 , 0.277838171 , - 0.308499992 , 0.519053042 , 4.19118404E-02 , 2.75227409E-02 , -1.25996238E-02 , 4.05276045E-02 , 0.680553019 , 0.278919399 , - 0.309500009 , 0.518770874 , 4.19060476E-02 , 2.75300331E-02 , -1.25709428E-02 , 3.97627093E-02 , 0.680235684 , 0.280001611 , - 0.310499996 , 0.518487394 , 4.19001952E-02 , 2.75373347E-02 , -1.25420718E-02 , 3.89971957E-02 , 0.679917991 , 0.281084806 , - 0.311500013 , 0.518202662 , 4.18942869E-02 , 2.75446437E-02 , -1.25130098E-02 , 3.82310897E-02 , 0.679600000 , 0.282168925 , - 0.312500000 , 0.517916620 , 4.18883152E-02 , 2.75519621E-02 , -1.24837579E-02 , 3.74644063E-02 , 0.679281652 , 0.283253938 , - 0.313499987 , 0.517629325 , 4.18822877E-02 , 2.75592916E-02 , -1.24543151E-02 , 3.66971642E-02 , 0.678963006 , 0.284339845 , - 0.314500004 , 0.517340720 , 4.18761969E-02 , 2.75666323E-02 , -1.24246813E-02 , 3.59293781E-02 , 0.678644001 , 0.285426617 , - 0.315499991 , 0.517050743 , 4.18700427E-02 , 2.75739841E-02 , -1.23948557E-02 , 3.51610705E-02 , 0.678324699 , 0.286514223 , - 0.316500008 , 0.516759515 , 4.18638326E-02 , 2.75813490E-02 , -1.23648401E-02 , 3.43922600E-02 , 0.678005099 , 0.287602603 , - 0.317499995 , 0.516466975 , 4.18575592E-02 , 2.75887288E-02 , -1.23346327E-02 , 3.36229615E-02 , 0.677685261 , 0.288691789 , - 0.318500012 , 0.516173065 , 4.18512262E-02 , 2.75961217E-02 , -1.23042343E-02 , 3.28531936E-02 , 0.677365065 , 0.289781719 , - 0.319499999 , 0.515877783 , 4.18448299E-02 , 2.76035313E-02 , -1.22736441E-02 , 3.20829749E-02 , 0.677044630 , 0.290872365 , - 0.320499986 , 0.515581191 , 4.18383740E-02 , 2.76109558E-02 , -1.22428620E-02 , 3.13123241E-02 , 0.676723957 , 0.291963726 , - 0.321500003 , 0.515283227 , 4.18318547E-02 , 2.76183989E-02 , -1.22118872E-02 , 3.05412598E-02 , 0.676402986 , 0.293055773 , - 0.322499990 , 0.514983833 , 4.18252721E-02 , 2.76258588E-02 , -1.21807214E-02 , 2.97698006E-02 , 0.676081777 , 0.294148445 , - 0.323500007 , 0.514683127 , 4.18186262E-02 , 2.76333373E-02 , -1.21493628E-02 , 2.89979633E-02 , 0.675760269 , 0.295241743 , - 0.324499995 , 0.514380932 , 4.18119170E-02 , 2.76408363E-02 , -1.21178124E-02 , 2.82257665E-02 , 0.675438583 , 0.296335667 , - 0.325500011 , 0.514077425 , 4.18051481E-02 , 2.76483558E-02 , -1.20860683E-02 , 2.74532288E-02 , 0.675116658 , 0.297430128 , - 0.326499999 , 0.513772428 , 4.17983122E-02 , 2.76558958E-02 , -1.20541323E-02 , 2.66803708E-02 , 0.674794495 , 0.298525155 , - 0.327499986 , 0.513466060 , 4.17914130E-02 , 2.76634600E-02 , -1.20220026E-02 , 2.59072073E-02 , 0.674472094 , 0.299620688 , - 0.328500003 , 0.513158202 , 4.17844467E-02 , 2.76710447E-02 , -1.19896792E-02 , 2.51337588E-02 , 0.674149573 , 0.300716698 , - 0.329499990 , 0.512848914 , 4.17774208E-02 , 2.76786555E-02 , -1.19571630E-02 , 2.43600421E-02 , 0.673826754 , 0.301813185 , - 0.330500007 , 0.512538195 , 4.17703241E-02 , 2.76862904E-02 , -1.19244531E-02 , 2.35860776E-02 , 0.673503816 , 0.302910119 , - 0.331499994 , 0.512225986 , 4.17631678E-02 , 2.76939515E-02 , -1.18915485E-02 , 2.28118841E-02 , 0.673180640 , 0.304007441 , - 0.332500011 , 0.511912286 , 4.17559408E-02 , 2.77016386E-02 , -1.18584502E-02 , 2.20374782E-02 , 0.672857344 , 0.305105180 , - 0.333499998 , 0.511597157 , 4.17486504E-02 , 2.77093519E-02 , -1.18251573E-02 , 2.12628786E-02 , 0.672533870 , 0.306203276 , - 0.334500015 , 0.511280477 , 4.17412929E-02 , 2.77170949E-02 , -1.17916698E-02 , 2.04881039E-02 , 0.672210217 , 0.307301700 , - 0.335500002 , 0.510962248 , 4.17338684E-02 , 2.77248677E-02 , -1.17579866E-02 , 1.97131746E-02 , 0.671886384 , 0.308400422 , - 0.336499989 , 0.510642588 , 4.17263731E-02 , 2.77326703E-02 , -1.17241079E-02 , 1.89381093E-02 , 0.671562493 , 0.309499413 , - 0.337500006 , 0.510321379 , 4.17188145E-02 , 2.77405027E-02 , -1.16900345E-02 , 1.81629229E-02 , 0.671238422 , 0.310598671 , - 0.338499993 , 0.509998560 , 4.17111851E-02 , 2.77483687E-02 , -1.16557647E-02 , 1.73876379E-02 , 0.670914173 , 0.311698169 , - 0.339500010 , 0.509674251 , 4.17034887E-02 , 2.77562663E-02 , -1.16212983E-02 , 1.66122708E-02 , 0.670589864 , 0.312797844 , - 0.340499997 , 0.509348392 , 4.16957214E-02 , 2.77641974E-02 , -1.15866354E-02 , 1.58368424E-02 , 0.670265436 , 0.313897699 , - 0.341500014 , 0.509020925 , 4.16878872E-02 , 2.77721621E-02 , -1.15517760E-02 , 1.50613701E-02 , 0.669940948 , 0.314997703 , - 0.342500001 , 0.508691907 , 4.16799821E-02 , 2.77801640E-02 , -1.15167182E-02 , 1.42858727E-02 , 0.669616282 , 0.316097826 , - 0.343499988 , 0.508361280 , 4.16720062E-02 , 2.77882013E-02 , -1.14814639E-02 , 1.35103688E-02 , 0.669291556 , 0.317198038 , - 0.344500005 , 0.508029044 , 4.16639596E-02 , 2.77962759E-02 , -1.14460113E-02 , 1.27348779E-02 , 0.668966770 , 0.318298340 , - 0.345499992 , 0.507695198 , 4.16558385E-02 , 2.78043877E-02 , -1.14103612E-02 , 1.19594187E-02 , 0.668641925 , 0.319398671 , - 0.346500009 , 0.507359743 , 4.16476503E-02 , 2.78125387E-02 , -1.13745118E-02 , 1.11840088E-02 , 0.668317020 , 0.320499003 , - 0.347499996 , 0.507022619 , 4.16393876E-02 , 2.78207306E-02 , -1.13384631E-02 , 1.04086697E-02 , 0.667991996 , 0.321599305 , - 0.348500013 , 0.506683886 , 4.16310504E-02 , 2.78289616E-02 , -1.13022150E-02 , 9.63341817E-03 , 0.667666972 , 0.322699606 , - 0.349500000 , 0.506343424 , 4.16226424E-02 , 2.78372355E-02 , -1.12657677E-02 , 8.85827467E-03 , 0.667341948 , 0.323799819 , - 0.350499988 , 0.506001353 , 4.16141599E-02 , 2.78455522E-02 , -1.12291202E-02 , 8.08325689E-03 , 0.667016804 , 0.324899912 , - 0.351500005 , 0.505657613 , 4.16056067E-02 , 2.78539099E-02 , -1.11922715E-02 , 7.30838394E-03 , 0.666691720 , 0.325999916 , - 0.352499992 , 0.505312145 , 4.15969752E-02 , 2.78623141E-02 , -1.11552216E-02 , 6.53367583E-03 , 0.666366577 , 0.327099770 , - 0.353500009 , 0.504965007 , 4.15882654E-02 , 2.78707631E-02 , -1.11179706E-02 , 5.75915119E-03 , 0.666041434 , 0.328199416 , - 0.354499996 , 0.504616141 , 4.15794849E-02 , 2.78792568E-02 , -1.10805174E-02 , 4.98482911E-03 , 0.665716290 , 0.329298884 , - 0.355500013 , 0.504265547 , 4.15706262E-02 , 2.78877988E-02 , -1.10428622E-02 , 4.21072822E-03 , 0.665391147 , 0.330398113 , - 0.356500000 , 0.503913224 , 4.15616892E-02 , 2.78963875E-02 , -1.10050039E-02 , 3.43686831E-03 , 0.665066063 , 0.331497073 , - 0.357499987 , 0.503559172 , 4.15526740E-02 , 2.79050265E-02 , -1.09669426E-02 , 2.66326847E-03 , 0.664740980 , 0.332595766 , - 0.358500004 , 0.503203332 , 4.15435843E-02 , 2.79137138E-02 , -1.09286774E-02 , 1.88994757E-03 , 0.664415896 , 0.333694130 , - 0.359499991 , 0.502845764 , 4.15344127E-02 , 2.79224515E-02 , -1.08902073E-02 , 1.11692504E-03 , 0.664090931 , 0.334792167 , - 0.360500008 , 0.502486408 , 4.15251628E-02 , 2.79312432E-02 , -1.08515332E-02 , 3.44220141E-04 , 0.663765967 , 0.335889846 , - 0.361499995 , 0.502125204 , 4.15158309E-02 , 2.79400852E-02 , -1.08126532E-02 , -4.28147963E-04 , 0.663441062 , 0.336987108 , - 0.362500012 , 0.501762271 , 4.15064208E-02 , 2.79489812E-02 , -1.07735675E-02 , -1.20016001E-03 , 0.663116217 , 0.338083953 , - 0.363499999 , 0.501397491 , 4.14969288E-02 , 2.79579312E-02 , -1.07342759E-02 , -1.97179662E-03 , 0.662791431 , 0.339180350 , - 0.364499986 , 0.501030862 , 4.14873548E-02 , 2.79669352E-02 , -1.06947776E-02 , -2.74303835E-03 , 0.662466764 , 0.340276241 , - 0.365500003 , 0.500662386 , 4.14776988E-02 , 2.79759970E-02 , -1.06550716E-02 , -3.51386587E-03 , 0.662142217 , 0.341371655 , - 0.366499990 , 0.500292122 , 4.14679609E-02 , 2.79851165E-02 , -1.06151570E-02 , -4.28425986E-03 , 0.661817729 , 0.342466533 , - 0.367500007 , 0.499919951 , 4.14581373E-02 , 2.79942919E-02 , -1.05750347E-02 , -5.05420053E-03 , 0.661493361 , 0.343560845 , - 0.368499994 , 0.499545932 , 4.14482281E-02 , 2.80035269E-02 , -1.05347028E-02 , -5.82366902E-03 , 0.661169112 , 0.344654590 , - 0.369500011 , 0.499170005 , 4.14382331E-02 , 2.80128233E-02 , -1.04941614E-02 , -6.59264531E-03 , 0.660844982 , 0.345747679 , - 0.370499998 , 0.498792201 , 4.14281562E-02 , 2.80221794E-02 , -1.04534104E-02 , -7.36111077E-03 , 0.660520971 , 0.346840173 , - 0.371499985 , 0.498412490 , 4.14179899E-02 , 2.80315969E-02 , -1.04124472E-02 , -8.12904444E-03 , 0.660197079 , 0.347931951 , - 0.372500002 , 0.498030841 , 4.14077379E-02 , 2.80410778E-02 , -1.03712734E-02 , -8.89642816E-03 , 0.659873366 , 0.349023044 , - 0.373499990 , 0.497647285 , 4.13973965E-02 , 2.80506201E-02 , -1.03298873E-02 , -9.66324192E-03 , 0.659549832 , 0.350113422 , - 0.374500006 , 0.497261763 , 4.13869657E-02 , 2.80602295E-02 , -1.02882879E-02 , -1.04294661E-02 , 0.659226418 , 0.351203024 , - 0.375499994 , 0.496874303 , 4.13764454E-02 , 2.80699041E-02 , -1.02464762E-02 , -1.11950804E-02 , 0.658903241 , 0.352291852 , - 0.376500010 , 0.496484846 , 4.13658358E-02 , 2.80796438E-02 , -1.02044493E-02 , -1.19600659E-02 , 0.658580184 , 0.353379875 , - 0.377499998 , 0.496093452 , 4.13551331E-02 , 2.80894525E-02 , -1.01622082E-02 , -1.27244033E-02 , 0.658257365 , 0.354467064 , - 0.378500015 , 0.495700032 , 4.13443409E-02 , 2.80993283E-02 , -1.01197511E-02 , -1.34880729E-02 , 0.657934725 , 0.355553359 , - 0.379500002 , 0.495304614 , 4.13334519E-02 , 2.81092748E-02 , -1.00770779E-02 , -1.42510533E-02 , 0.657612264 , 0.356638789 , - 0.380499989 , 0.494907200 , 4.13224734E-02 , 2.81192902E-02 , -1.00341886E-02 , -1.50133269E-02 , 0.657290041 , 0.357723266 , - 0.381500006 , 0.494507730 , 4.13113981E-02 , 2.81293783E-02 , -9.99108143E-03 , -1.57748722E-02 , 0.656968057 , 0.358806819 , - 0.382499993 , 0.494106233 , 4.13002297E-02 , 2.81395372E-02 , -9.94775537E-03 , -1.65356714E-02 , 0.656646311 , 0.359889358 , - 0.383500010 , 0.493702680 , 4.12889645E-02 , 2.81497706E-02 , -9.90421139E-03 , -1.72957033E-02 , 0.656324804 , 0.360970914 , - 0.384499997 , 0.493297040 , 4.12776023E-02 , 2.81600766E-02 , -9.86044668E-03 , -1.80549473E-02 , 0.656003535 , 0.362051427 , - 0.385500014 , 0.492889345 , 4.12661396E-02 , 2.81704590E-02 , -9.81646124E-03 , -1.88133847E-02 , 0.655682504 , 0.363130897 , - 0.386500001 , 0.492479533 , 4.12545800E-02 , 2.81809177E-02 , -9.77225509E-03 , -1.95709951E-02 , 0.655361772 , 0.364209235 , - 0.387499988 , 0.492067635 , 4.12429236E-02 , 2.81914528E-02 , -9.72782727E-03 , -2.03277599E-02 , 0.655041277 , 0.365286469 , - 0.388500005 , 0.491653621 , 4.12311628E-02 , 2.82020662E-02 , -9.68317594E-03 , -2.10836567E-02 , 0.654721081 , 0.366362572 , - 0.389499992 , 0.491237491 , 4.12193015E-02 , 2.82127578E-02 , -9.63830110E-03 , -2.18386669E-02 , 0.654401183 , 0.367437482 , - 0.390500009 , 0.490819186 , 4.12073396E-02 , 2.82235313E-02 , -9.59320087E-03 , -2.25927718E-02 , 0.654081583 , 0.368511170 , - 0.391499996 , 0.490398765 , 4.11952734E-02 , 2.82343850E-02 , -9.54787619E-03 , -2.33459491E-02 , 0.653762281 , 0.369583637 , - 0.392500013 , 0.489976138 , 4.11831029E-02 , 2.82453205E-02 , -9.50232521E-03 , -2.40981784E-02 , 0.653443336 , 0.370654851 , - 0.393500000 , 0.489551336 , 4.11708243E-02 , 2.82563400E-02 , -9.45654698E-03 , -2.48494428E-02 , 0.653124690 , 0.371724755 , - 0.394499987 , 0.489124358 , 4.11584415E-02 , 2.82674432E-02 , -9.41054057E-03 , -2.55997181E-02 , 0.652806401 , 0.372793347 , - 0.395500004 , 0.488695145 , 4.11459506E-02 , 2.82786321E-02 , -9.36430506E-03 , -2.63489876E-02 , 0.652488410 , 0.373860598 , - 0.396499991 , 0.488263756 , 4.11333516E-02 , 2.82899048E-02 , -9.31784045E-03 , -2.70972289E-02 , 0.652170777 , 0.374926448 , - 0.397500008 , 0.487830102 , 4.11206447E-02 , 2.83012670E-02 , -9.27114487E-03 , -2.78444234E-02 , 0.651853502 , 0.375990897 , - 0.398499995 , 0.487394184 , 4.11078297E-02 , 2.83127148E-02 , -9.22421645E-03 , -2.85905469E-02 , 0.651536644 , 0.377053916 , - 0.399500012 , 0.486956030 , 4.10948917E-02 , 2.83242576E-02 , -9.17705987E-03 , -2.93355919E-02 , 0.651220083 , 0.378115475 , - 0.400000006 , 0.486532003 , 4.11139540E-02 , 2.83555184E-02 , -9.18524247E-03 , -3.00840233E-02 , 0.650901794 , 0.379182220 -}; + 2.49999994E-03, 0.578033745, 3.99446450E-02, 2.38903537E-02, -1.30482316E-02, 0.179515034, 0.731100619, 8.93843472E-02, 3.50000011E-03, 0.577869534, 3.99689302E-02, 2.39049532E-02, + -1.30678229E-02, 0.179440185, 0.731137991, 8.94218087E-02, 4.49999981E-03, 0.577705383, 3.99932154E-02, 2.39195526E-02, -1.30874133E-02, 0.179365337, 0.731175423, 8.94592628E-02, + 5.49999997E-03, 0.577541232, 4.00174968E-02, 2.39341483E-02, -1.31069971E-02, 0.179290488, 0.731212795, 8.94967243E-02, 6.50000013E-03, 0.577377021, 4.00417708E-02, 2.39487402E-02, + -1.31265689E-02, 0.179215625, 0.731250167, 8.95342156E-02, 7.49999983E-03, 0.577212870, 4.00660373E-02, 2.39633210E-02, -1.31461201E-02, 0.179140732, 0.731287539, 8.95717517E-02, + 8.50000046E-03, 0.577048659, 4.00902927E-02, 2.39778906E-02, -1.31656425E-02, 0.179065749, 0.731324852, 8.96094143E-02, 9.49999969E-03, 0.576884508, 4.01145332E-02, 2.39924453E-02, + -1.31851304E-02, 0.178990647, 0.731362045, 8.96473005E-02, 1.04999999E-02, 0.576720297, 4.01387550E-02, 2.40069814E-02, -1.32045783E-02, 0.178915322, 0.731399119, 8.96855593E-02, + 1.15000000E-02, 0.576556087, 4.01629582E-02, 2.40214970E-02, -1.32239787E-02, 0.178839639, 0.731435955, 8.97244066E-02, 1.25000002E-02, 0.576391935, 4.01871353E-02, 2.40359865E-02, + -1.32433213E-02, 0.178763434, 0.731472433, 8.97641182E-02, 1.35000004E-02, 0.576227725, 4.02112827E-02, 2.40504444E-02, -1.32625941E-02, 0.178686514, 0.731508434, 8.98050219E-02, + 1.44999996E-02, 0.576063514, 4.02353965E-02, 2.40648650E-02, -1.32817822E-02, 0.178608656, 0.731543839, 8.98475125E-02, 1.54999997E-02, 0.575899243, 4.02594656E-02, 2.40792390E-02, + -1.33008687E-02, 0.178529590, 0.731578410, 8.98919925E-02, 1.64999999E-02, 0.575735033, 4.02834900E-02, 2.40935609E-02, -1.33198369E-02, 0.178449064, 0.731612027, 8.99389088E-02, + 1.75000001E-02, 0.575570762, 4.03074548E-02, 2.41078213E-02, -1.33386711E-02, 0.178366825, 0.731644511, 8.99886861E-02, 1.85000002E-02, 0.575406551, 4.03313600E-02, 2.41220128E-02, + -1.33573553E-02, 0.178282633, 0.731675625, 9.00417194E-02, 1.95000004E-02, 0.575242221, 4.03551981E-02, 2.41361316E-02, -1.33758765E-02, 0.178196281, 0.731705368, 9.00983587E-02, + 2.05000006E-02, 0.575077951, 4.03789654E-02, 2.41501704E-02, -1.33942226E-02, 0.178107575, 0.731733561, 9.01588872E-02, 2.15000007E-02, 0.574913621, 4.04026546E-02, 2.41641272E-02, + -1.34123880E-02, 0.178016424, 0.731760025, 9.02235359E-02, 2.25000009E-02, 0.574749291, 4.04262692E-02, 2.41780002E-02, -1.34303654E-02, 0.177922696, 0.731784880, 9.02924463E-02, + 2.34999992E-02, 0.574584961, 4.04497981E-02, 2.41917893E-02, -1.34481536E-02, 0.177826360, 0.731807947, 9.03657228E-02, 2.44999994E-02, 0.574420631, 4.04732488E-02, 2.42054947E-02, + -1.34657528E-02, 0.177727371, 0.731829226, 9.04433951E-02, 2.54999995E-02, 0.574256241, 4.04966101E-02, 2.42191181E-02, -1.34831630E-02, 0.177625760, 0.731848776, 9.05254781E-02, + 2.64999997E-02, 0.574091792, 4.05198894E-02, 2.42326632E-02, -1.35003878E-02, 0.177521497, 0.731866539, 9.06119570E-02, 2.74999999E-02, 0.573927343, 4.05430831E-02, 2.42461301E-02, + -1.35174291E-02, 0.177414611, 0.731882572, 9.07028094E-02, 2.85000000E-02, 0.573762894, 4.05661911E-02, 2.42595226E-02, -1.35342898E-02, 0.177305117, 0.731896877, 9.07979980E-02, + 2.95000002E-02, 0.573598444, 4.05892096E-02, 2.42728423E-02, -1.35509735E-02, 0.177193031, 0.731909454, 9.08975154E-02, 3.05000003E-02, 0.573433876, 4.06121388E-02, 2.42860932E-02, + -1.35674803E-02, 0.177078366, 0.731920302, 9.10013393E-02, 3.15000005E-02, 0.573269367, 4.06349748E-02, 2.42992751E-02, -1.35838138E-02, 0.176961109, 0.731929421, 9.11094695E-02, + 3.24999988E-02, 0.573104799, 4.06577215E-02, 2.43123900E-02, -1.35999750E-02, 0.176841274, 0.731936812, 9.12219137E-02, 3.35000008E-02, 0.572940171, 4.06803750E-02, 2.43254397E-02, + -1.36159649E-02, 0.176718846, 0.731942475, 9.13386792E-02, 3.44999991E-02, 0.572775543, 4.07029316E-02, 2.43384279E-02, -1.36317844E-02, 0.176593810, 0.731946409, 9.14597660E-02, + 3.55000012E-02, 0.572610915, 4.07253951E-02, 2.43513510E-02, -1.36474352E-02, 0.176466182, 0.731948614, 9.15851891E-02, 3.64999995E-02, 0.572446167, 4.07477617E-02, 2.43642144E-02, + -1.36629166E-02, 0.176335946, 0.731949091, 9.17149633E-02, 3.75000015E-02, 0.572281480, 4.07700278E-02, 2.43770182E-02, -1.36782313E-02, 0.176203087, 0.731947839, 9.18490961E-02, + 3.84999998E-02, 0.572116673, 4.07921970E-02, 2.43897643E-02, -1.36933802E-02, 0.176067606, 0.731944799, 9.19876024E-02, 3.95000018E-02, 0.571951866, 4.08142619E-02, 2.44024526E-02, + -1.37083633E-02, 0.175929502, 0.731940031, 9.21304747E-02, 4.05000001E-02, 0.571787059, 4.08362262E-02, 2.44150888E-02, -1.37231825E-02, 0.175788775, 0.731933475, 9.22777429E-02, + 4.14999984E-02, 0.571622133, 4.08580862E-02, 2.44276691E-02, -1.37378387E-02, 0.175645396, 0.731925189, 9.24293920E-02, 4.25000004E-02, 0.571457267, 4.08798419E-02, 2.44401973E-02, + -1.37523329E-02, 0.175499380, 0.731915176, 9.25854519E-02, 4.34999987E-02, 0.571292281, 4.09014896E-02, 2.44526770E-02, -1.37666669E-02, 0.175350726, 0.731903374, 9.27459151E-02, + 4.45000008E-02, 0.571127295, 4.09230292E-02, 2.44651064E-02, -1.37808416E-02, 0.175199404, 0.731889784, 9.29107890E-02, 4.54999991E-02, 0.570962250, 4.09444608E-02, 2.44774893E-02, + -1.37948571E-02, 0.175045431, 0.731874466, 9.30800810E-02, 4.65000011E-02, 0.570797145, 4.09657806E-02, 2.44898256E-02, -1.38087161E-02, 0.174888805, 0.731857359, 9.32538062E-02, + 4.74999994E-02, 0.570631981, 4.09869850E-02, 2.45021190E-02, -1.38224186E-02, 0.174729496, 0.731838524, 9.34319720E-02, 4.85000014E-02, 0.570466816, 4.10080776E-02, 2.45143697E-02, + -1.38359666E-02, 0.174567536, 0.731817901, 9.36145708E-02, 4.94999997E-02, 0.570301592, 4.10290547E-02, 2.45265793E-02, -1.38493609E-02, 0.174402878, 0.731795490, 9.38016176E-02, + 5.05000018E-02, 0.570136309, 4.10499126E-02, 2.45387498E-02, -1.38626024E-02, 0.174235553, 0.731771350, 9.39931199E-02, 5.15000001E-02, 0.569971025, 4.10706550E-02, 2.45508850E-02, + -1.38756940E-02, 0.174065530, 0.731745422, 9.41890776E-02, 5.24999984E-02, 0.569805622, 4.10912707E-02, 2.45629847E-02, -1.38886357E-02, 0.173892811, 0.731717706, 9.43894982E-02, + 5.35000004E-02, 0.569640219, 4.11117673E-02, 2.45750509E-02, -1.39014283E-02, 0.173717394, 0.731688201, 9.45943892E-02, 5.44999987E-02, 0.569474757, 4.11321409E-02, 2.45870855E-02, + -1.39140757E-02, 0.173539281, 0.731656969, 9.48037580E-02, 5.55000007E-02, 0.569309235, 4.11523841E-02, 2.45990921E-02, -1.39265768E-02, 0.173358455, 0.731623948, 9.50176045E-02, + 5.64999990E-02, 0.569143653, 4.11725007E-02, 2.46110708E-02, -1.39389345E-02, 0.173174903, 0.731589139, 9.52359363E-02, 5.75000010E-02, 0.568978012, 4.11924832E-02, 2.46230271E-02, + -1.39511507E-02, 0.172988623, 0.731552601, 9.54587534E-02, 5.84999993E-02, 0.568812311, 4.12123352E-02, 2.46349592E-02, -1.39632262E-02, 0.172799632, 0.731514335, 9.56860632E-02, + 5.95000014E-02, 0.568646550, 4.12320495E-02, 2.46468727E-02, -1.39751639E-02, 0.172607884, 0.731474280, 9.59178656E-02, 6.04999997E-02, 0.568480730, 4.12516259E-02, 2.46587694E-02, + -1.39869656E-02, 0.172413394, 0.731432438, 9.61541682E-02, 6.15000017E-02, 0.568314850, 4.12710607E-02, 2.46706530E-02, -1.39986323E-02, 0.172216147, 0.731388867, 9.63949710E-02, + 6.25000000E-02, 0.568148911, 4.12903503E-02, 2.46825255E-02, -1.40101677E-02, 0.172016144, 0.731343567, 9.66402814E-02, 6.35000020E-02, 0.567982912, 4.13094945E-02, 2.46943906E-02, + -1.40215736E-02, 0.171813369, 0.731296539, 9.68900993E-02, 6.44999966E-02, 0.567816854, 4.13284861E-02, 2.47062519E-02, -1.40328519E-02, 0.171607807, 0.731247783, 9.71444249E-02, + 6.54999986E-02, 0.567650735, 4.13473211E-02, 2.47181114E-02, -1.40440054E-02, 0.171399474, 0.731197238, 9.74032655E-02, 6.65000007E-02, 0.567484558, 4.13659997E-02, 2.47299764E-02, + -1.40550369E-02, 0.171188325, 0.731145084, 9.76666138E-02, 6.75000027E-02, 0.567318320, 4.13845181E-02, 2.47418471E-02, -1.40659502E-02, 0.170974374, 0.731091142, 9.79344845E-02, + 6.84999973E-02, 0.567152023, 4.14028689E-02, 2.47537289E-02, -1.40767479E-02, 0.170757592, 0.731035531, 9.82068628E-02, 6.94999993E-02, 0.566985607, 4.14210483E-02, 2.47656275E-02, + -1.40874321E-02, 0.170537993, 0.730978251, 9.84837636E-02, 7.05000013E-02, 0.566819191, 4.14390527E-02, 2.47775484E-02, -1.40980082E-02, 0.170315534, 0.730919302, 9.87651795E-02, + 7.15000033E-02, 0.566652656, 4.14568745E-02, 2.47894935E-02, -1.41084781E-02, 0.170090228, 0.730858624, 9.90511179E-02, 7.24999979E-02, 0.566486061, 4.14745137E-02, 2.48014685E-02, + -1.41188465E-02, 0.169862062, 0.730796397, 9.93415713E-02, 7.34999999E-02, 0.566319406, 4.14919592E-02, 2.48134807E-02, -1.41291162E-02, 0.169631004, 0.730732441, 9.96365473E-02, + 7.45000020E-02, 0.566152692, 4.15092111E-02, 2.48255339E-02, -1.41392928E-02, 0.169397056, 0.730666876, 9.99360383E-02, 7.54999965E-02, 0.565985858, 4.15262580E-02, 2.48376355E-02, + -1.41493799E-02, 0.169160202, 0.730599761, 0.100240052, 7.64999986E-02, 0.565818965, 4.15431000E-02, 2.48497911E-02, -1.41593814E-02, 0.168920428, 0.730530977, 0.100548580, + 7.75000006E-02, 0.565652013, 4.15597260E-02, 2.48620044E-02, -1.41693018E-02, 0.168677703, 0.730460644, 0.100861631, 7.85000026E-02, 0.565485001, 4.15761322E-02, 2.48742830E-02, + -1.41791450E-02, 0.168432042, 0.730388761, 0.101179205, 7.94999972E-02, 0.565317869, 4.15923111E-02, 2.48866342E-02, -1.41889164E-02, 0.168183401, 0.730315328, 0.101501293, + 8.04999992E-02, 0.565150678, 4.16082591E-02, 2.48990618E-02, -1.41986208E-02, 0.167931795, 0.730240285, 0.101827897, 8.15000013E-02, 0.564983428, 4.16239686E-02, 2.49115750E-02, + -1.42082619E-02, 0.167677179, 0.730163813, 0.102159023, 8.25000033E-02, 0.564816058, 4.16394323E-02, 2.49241758E-02, -1.42178452E-02, 0.167419568, 0.730085790, 0.102494672, + 8.34999979E-02, 0.564648628, 4.16546427E-02, 2.49368753E-02, -1.42273735E-02, 0.167158917, 0.730006218, 0.102834836, 8.44999999E-02, 0.564481139, 4.16695997E-02, 2.49496773E-02, + -1.42368525E-02, 0.166895241, 0.729925215, 0.103179514, 8.55000019E-02, 0.564313531, 4.16842923E-02, 2.49625854E-02, -1.42462859E-02, 0.166628510, 0.729842782, 0.103528716, + 8.64999965E-02, 0.564145863, 4.16987166E-02, 2.49756072E-02, -1.42556773E-02, 0.166358709, 0.729758859, 0.103882439, 8.74999985E-02, 0.563978076, 4.17128652E-02, 2.49887481E-02, + -1.42650316E-02, 0.166085824, 0.729673505, 0.104240686, 8.85000005E-02, 0.563810229, 4.17267382E-02, 2.50020120E-02, -1.42743504E-02, 0.165809840, 0.729586720, 0.104603447, + 8.95000026E-02, 0.563642263, 4.17403281E-02, 2.50154026E-02, -1.42836375E-02, 0.165530771, 0.729498506, 0.104970731, 9.04999971E-02, 0.563474238, 4.17536348E-02, 2.50289254E-02, + -1.42928958E-02, 0.165248573, 0.729408920, 0.105342537, 9.14999992E-02, 0.563306153, 4.17666472E-02, 2.50425823E-02, -1.43021280E-02, 0.164963245, 0.729317904, 0.105718873, + 9.25000012E-02, 0.563137949, 4.17793691E-02, 2.50563771E-02, -1.43113350E-02, 0.164674789, 0.729225457, 0.106099732, 9.35000032E-02, 0.562969625, 4.17917967E-02, 2.50703096E-02, + -1.43205188E-02, 0.164383188, 0.729131699, 0.106485114, 9.44999978E-02, 0.562801242, 4.18039300E-02, 2.50843819E-02, -1.43296793E-02, 0.164088428, 0.729036570, 0.106875025, + 9.54999998E-02, 0.562632799, 4.18157689E-02, 2.50985958E-02, -1.43388184E-02, 0.163790509, 0.728940010, 0.107269473, 9.65000018E-02, 0.562464178, 4.18273099E-02, 2.51129512E-02, + -1.43479342E-02, 0.163489416, 0.728842139, 0.107668452, 9.74999964E-02, 0.562295556, 4.18385565E-02, 2.51274444E-02, -1.43570267E-02, 0.163185149, 0.728742898, 0.108071961, + 9.84999985E-02, 0.562126756, 4.18495089E-02, 2.51420774E-02, -1.43660940E-02, 0.162877724, 0.728642285, 0.108480006, 9.95000005E-02, 0.561957896, 4.18601707E-02, 2.51568444E-02, + -1.43751344E-02, 0.162567109, 0.728540301, 0.108892590, 0.100500003, 0.561788917, 4.18705493E-02, 2.51717456E-02, -1.43841449E-02, 0.162253320, 0.728436947, 0.109309711, + 0.101499997, 0.561619878, 4.18806411E-02, 2.51867734E-02, -1.43931238E-02, 0.161936343, 0.728332281, 0.109731369, 0.102499999, 0.561450660, 4.18904535E-02, 2.52019260E-02, + -1.44020654E-02, 0.161616191, 0.728226244, 0.110157572, 0.103500001, 0.561281383, 4.18999940E-02, 2.52171978E-02, -1.44109679E-02, 0.161292851, 0.728118837, 0.110588312, + 0.104500003, 0.561111987, 4.19092700E-02, 2.52325814E-02, -1.44198257E-02, 0.160966352, 0.728010058, 0.111023597, 0.105499998, 0.560942531, 4.19182815E-02, 2.52480730E-02, + -1.44286342E-02, 0.160636663, 0.727899909, 0.111463428, 0.106500000, 0.560772896, 4.19270396E-02, 2.52636634E-02, -1.44373877E-02, 0.160303816, 0.727788389, 0.111907795, + 0.107500002, 0.560603201, 4.19355519E-02, 2.52793469E-02, -1.44460816E-02, 0.159967795, 0.727675498, 0.112356707, 0.108499996, 0.560433328, 4.19438221E-02, 2.52951160E-02, + -1.44547094E-02, 0.159628630, 0.727561235, 0.112810157, 0.109499998, 0.560263395, 4.19518650E-02, 2.53109634E-02, -1.44632664E-02, 0.159286290, 0.727445543, 0.113268152, + 0.110500000, 0.560093284, 4.19596806E-02, 2.53268816E-02, -1.44717460E-02, 0.158940807, 0.727328479, 0.113730676, 0.111500002, 0.559923112, 4.19672839E-02, 2.53428612E-02, + -1.44801419E-02, 0.158592194, 0.727210045, 0.114197746, 0.112499997, 0.559752762, 4.19746749E-02, 2.53588986E-02, -1.44884493E-02, 0.158240438, 0.727090240, 0.114669345, + 0.113499999, 0.559582293, 4.19818684E-02, 2.53749806E-02, -1.44966627E-02, 0.157885551, 0.726969004, 0.115145475, 0.114500001, 0.559411705, 4.19888683E-02, 2.53911037E-02, + -1.45047745E-02, 0.157527551, 0.726846337, 0.115626127, 0.115500003, 0.559240997, 4.19956855E-02, 2.54072603E-02, -1.45127801E-02, 0.157166421, 0.726722240, 0.116111316, + 0.116499998, 0.559070170, 4.20023203E-02, 2.54234429E-02, -1.45206749E-02, 0.156802192, 0.726596773, 0.116601013, 0.117500000, 0.558899164, 4.20087874E-02, 2.54396442E-02, + -1.45284534E-02, 0.156434864, 0.726469874, 0.117095232, 0.118500002, 0.558728039, 4.20150906E-02, 2.54558586E-02, -1.45361116E-02, 0.156064436, 0.726341605, 0.117593966, + 0.119499996, 0.558556795, 4.20212336E-02, 2.54720822E-02, -1.45436432E-02, 0.155690923, 0.726211846, 0.118097201, 0.120499998, 0.558385372, 4.20272239E-02, 2.54883058E-02, + -1.45510444E-02, 0.155314341, 0.726080716, 0.118604943, 0.121500000, 0.558213770, 4.20330651E-02, 2.55045276E-02, -1.45583125E-02, 0.154934675, 0.725948155, 0.119117178, + 0.122500002, 0.558042049, 4.20387648E-02, 2.55207419E-02, -1.45654436E-02, 0.154551938, 0.725814164, 0.119633906, 0.123499997, 0.557870209, 4.20443267E-02, 2.55369432E-02, + -1.45724332E-02, 0.154166147, 0.725678742, 0.120155126, 0.124499999, 0.557698190, 4.20497544E-02, 2.55531278E-02, -1.45792784E-02, 0.153777301, 0.725541890, 0.120680816, + 0.125499994, 0.557525992, 4.20550518E-02, 2.55692918E-02, -1.45859765E-02, 0.153385401, 0.725403607, 0.121210985, 0.126499996, 0.557353675, 4.20602225E-02, 2.55854335E-02, + -1.45925246E-02, 0.152990445, 0.725263953, 0.121745616, 0.127499998, 0.557181180, 4.20652702E-02, 2.56015491E-02, -1.45989209E-02, 0.152592465, 0.725122809, 0.122284710, + 0.128500000, 0.557008505, 4.20701988E-02, 2.56176349E-02, -1.46051617E-02, 0.152191460, 0.724980295, 0.122828253, 0.129500002, 0.556835651, 4.20750119E-02, 2.56336872E-02, + -1.46112461E-02, 0.151787415, 0.724836349, 0.123376250, 0.130500004, 0.556662619, 4.20797132E-02, 2.56497059E-02, -1.46171711E-02, 0.151380345, 0.724690974, 0.123928681, + 0.131500006, 0.556489468, 4.20842990E-02, 2.56656855E-02, -1.46229351E-02, 0.150970280, 0.724544168, 0.124485545, 0.132499993, 0.556316078, 4.20887768E-02, 2.56816279E-02, + -1.46285370E-02, 0.150557190, 0.724395990, 0.125046834, 0.133499995, 0.556142569, 4.20931503E-02, 2.56975275E-02, -1.46339731E-02, 0.150141105, 0.724246383, 0.125612542, + 0.134499997, 0.555968821, 4.20974195E-02, 2.57133823E-02, -1.46392426E-02, 0.149722025, 0.724095345, 0.126182646, 0.135499999, 0.555794954, 4.21015881E-02, 2.57291906E-02, + -1.46443443E-02, 0.149299949, 0.723942876, 0.126757160, 0.136500001, 0.555620849, 4.21056561E-02, 2.57449523E-02, -1.46492757E-02, 0.148874894, 0.723789036, 0.127336055, + 0.137500003, 0.555446565, 4.21096273E-02, 2.57606637E-02, -1.46540357E-02, 0.148446858, 0.723633826, 0.127919346, 0.138500005, 0.555272102, 4.21135016E-02, 2.57763229E-02, + -1.46586224E-02, 0.148015857, 0.723477125, 0.128507003, 0.139500007, 0.555097401, 4.21172827E-02, 2.57919300E-02, -1.46630351E-02, 0.147581875, 0.723319113, 0.129099011, + 0.140499994, 0.554922581, 4.21209745E-02, 2.58074813E-02, -1.46672716E-02, 0.147144958, 0.723159671, 0.129695386, 0.141499996, 0.554747462, 4.21245769E-02, 2.58229747E-02, + -1.46713303E-02, 0.146705076, 0.722998798, 0.130296111, 0.142499998, 0.554572225, 4.21280898E-02, 2.58384105E-02, -1.46752102E-02, 0.146262258, 0.722836554, 0.130901158, + 0.143500000, 0.554396749, 4.21315171E-02, 2.58537866E-02, -1.46789113E-02, 0.145816505, 0.722672939, 0.131510541, 0.144500002, 0.554221034, 4.21348624E-02, 2.58691013E-02, + -1.46824298E-02, 0.145367816, 0.722507954, 0.132124230, 0.145500004, 0.554045141, 4.21381257E-02, 2.58843526E-02, -1.46857658E-02, 0.144916207, 0.722341537, 0.132742241, + 0.146500006, 0.553869009, 4.21413071E-02, 2.58995406E-02, -1.46889184E-02, 0.144461691, 0.722173810, 0.133364528, 0.147499993, 0.553692698, 4.21444103E-02, 2.59146634E-02, + -1.46918865E-02, 0.144004270, 0.722004652, 0.133991092, 0.148499995, 0.553516090, 4.21474315E-02, 2.59297192E-02, -1.46946684E-02, 0.143543944, 0.721834123, 0.134621933, + 0.149499997, 0.553339303, 4.21503820E-02, 2.59447079E-02, -1.46972630E-02, 0.143080726, 0.721662223, 0.135257050, 0.150500000, 0.553162277, 4.21532542E-02, 2.59596296E-02, + -1.46996705E-02, 0.142614633, 0.721488953, 0.135896400, 0.151500002, 0.552985013, 4.21560518E-02, 2.59744786E-02, -1.47018880E-02, 0.142145663, 0.721314371, 0.136539981, + 0.152500004, 0.552807570, 4.21587788E-02, 2.59892587E-02, -1.47039173E-02, 0.141673833, 0.721138358, 0.137187794, 0.153500006, 0.552629828, 4.21614349E-02, 2.60039680E-02, + -1.47057548E-02, 0.141199127, 0.720961034, 0.137839824, 0.154499993, 0.552451849, 4.21640202E-02, 2.60186046E-02, -1.47074014E-02, 0.140721589, 0.720782340, 0.138496056, + 0.155499995, 0.552273631, 4.21665348E-02, 2.60331687E-02, -1.47088561E-02, 0.140241206, 0.720602334, 0.139156476, 0.156499997, 0.552095175, 4.21689823E-02, 2.60476582E-02, + -1.47101181E-02, 0.139757991, 0.720420957, 0.139821067, 0.157499999, 0.551916420, 4.21713628E-02, 2.60620750E-02, -1.47111872E-02, 0.139271945, 0.720238209, 0.140489817, + 0.158500001, 0.551737428, 4.21736762E-02, 2.60764156E-02, -1.47120617E-02, 0.138783082, 0.720054209, 0.141162723, 0.159500003, 0.551558197, 4.21759263E-02, 2.60906816E-02, + -1.47127407E-02, 0.138291419, 0.719868779, 0.141839772, 0.160500005, 0.551378667, 4.21781093E-02, 2.61048712E-02, -1.47132259E-02, 0.137796968, 0.719682097, 0.142520949, + 0.161500007, 0.551198900, 4.21802290E-02, 2.61189863E-02, -1.47135137E-02, 0.137299716, 0.719494045, 0.143206224, 0.162499994, 0.551018834, 4.21822853E-02, 2.61330232E-02, + -1.47136068E-02, 0.136799678, 0.719304740, 0.143895596, 0.163499996, 0.550838530, 4.21842821E-02, 2.61469819E-02, -1.47135016E-02, 0.136296883, 0.719114065, 0.144589067, + 0.164499998, 0.550657928, 4.21862155E-02, 2.61608642E-02, -1.47131998E-02, 0.135791332, 0.718922079, 0.145286590, 0.165500000, 0.550477028, 4.21880856E-02, 2.61746701E-02, + -1.47127006E-02, 0.135283023, 0.718728781, 0.145988181, 0.166500002, 0.550295889, 4.21898961E-02, 2.61883959E-02, -1.47120031E-02, 0.134771973, 0.718534231, 0.146693811, + 0.167500004, 0.550114393, 4.21916507E-02, 2.62020454E-02, -1.47111062E-02, 0.134258181, 0.718338370, 0.147403464, 0.168500006, 0.549932659, 4.21933420E-02, 2.62156148E-02, + -1.47100110E-02, 0.133741677, 0.718141198, 0.148117140, 0.169499993, 0.549750566, 4.21949774E-02, 2.62291078E-02, -1.47087174E-02, 0.133222461, 0.717942715, 0.148834810, + 0.170499995, 0.549568236, 4.21965532E-02, 2.62425207E-02, -1.47072235E-02, 0.132700548, 0.717742980, 0.149556458, 0.171499997, 0.549385548, 4.21980694E-02, 2.62558535E-02, + -1.47055294E-02, 0.132175937, 0.717541993, 0.150282085, 0.172499999, 0.549202561, 4.21995334E-02, 2.62691099E-02, -1.47036361E-02, 0.131648645, 0.717339694, 0.151011661, + 0.173500001, 0.549019277, 4.22009379E-02, 2.62822863E-02, -1.47015424E-02, 0.131118685, 0.717136145, 0.151745170, 0.174500003, 0.548835695, 4.22022827E-02, 2.62953825E-02, + -1.46992477E-02, 0.130586058, 0.716931343, 0.152482614, 0.175500005, 0.548651755, 4.22035754E-02, 2.63084024E-02, -1.46967527E-02, 0.130050778, 0.716725290, 0.153223962, + 0.176499993, 0.548467457, 4.22048122E-02, 2.63213422E-02, -1.46940565E-02, 0.129512861, 0.716517925, 0.153969198, 0.177499995, 0.548282862, 4.22059931E-02, 2.63342019E-02, + -1.46911591E-02, 0.128972322, 0.716309369, 0.154718310, 0.178499997, 0.548097968, 4.22071218E-02, 2.63469853E-02, -1.46880616E-02, 0.128429160, 0.716099560, 0.155471295, + 0.179499999, 0.547912657, 4.22081910E-02, 2.63596885E-02, -1.46847609E-02, 0.127883375, 0.715888500, 0.156228110, 0.180500001, 0.547727048, 4.22092117E-02, 2.63723135E-02, + -1.46812601E-02, 0.127335012, 0.715676248, 0.156988755, 0.181500003, 0.547541082, 4.22101729E-02, 2.63848603E-02, -1.46775572E-02, 0.126784056, 0.715462744, 0.157753214, + 0.182500005, 0.547354758, 4.22110856E-02, 2.63973288E-02, -1.46736521E-02, 0.126230523, 0.715247989, 0.158521473, 0.183500007, 0.547168076, 4.22119386E-02, 2.64097210E-02, + -1.46695459E-02, 0.125674441, 0.715032041, 0.159293503, 0.184499994, 0.546981037, 4.22127433E-02, 2.64220331E-02, -1.46652376E-02, 0.125115797, 0.714814901, 0.160069302, + 0.185499996, 0.546793640, 4.22134921E-02, 2.64342688E-02, -1.46607272E-02, 0.124554612, 0.714596570, 0.160848841, 0.186499998, 0.546605825, 4.22141925E-02, 2.64464281E-02, + -1.46560147E-02, 0.123990893, 0.714376986, 0.161632121, 0.187500000, 0.546417654, 4.22148369E-02, 2.64585093E-02, -1.46511002E-02, 0.123424664, 0.714156270, 0.162419096, + 0.188500002, 0.546229124, 4.22154292E-02, 2.64705140E-02, -1.46459844E-02, 0.122855924, 0.713934302, 0.163209766, 0.189500004, 0.546040177, 4.22159694E-02, 2.64824443E-02, + -1.46406656E-02, 0.122284696, 0.713711202, 0.164004117, 0.190500006, 0.545850873, 4.22164537E-02, 2.64942963E-02, -1.46351457E-02, 0.121710978, 0.713486910, 0.164802134, + 0.191499993, 0.545661151, 4.22168896E-02, 2.65060738E-02, -1.46294227E-02, 0.121134795, 0.713261425, 0.165603787, 0.192499995, 0.545471013, 4.22172733E-02, 2.65177749E-02, + -1.46234985E-02, 0.120556153, 0.713034809, 0.166409060, 0.193499997, 0.545280516, 4.22176085E-02, 2.65294015E-02, -1.46173723E-02, 0.119975068, 0.712807000, 0.167217940, + 0.194499999, 0.545089543, 4.22178879E-02, 2.65409537E-02, -1.46110430E-02, 0.119391546, 0.712578058, 0.168030411, 0.195500001, 0.544898212, 4.22181152E-02, 2.65524331E-02, + -1.46045135E-02, 0.118805602, 0.712347925, 0.168846458, 0.196500003, 0.544706464, 4.22182940E-02, 2.65638363E-02, -1.45977810E-02, 0.118217252, 0.712116718, 0.169666052, + 0.197500005, 0.544514239, 4.22184207E-02, 2.65751686E-02, -1.45908464E-02, 0.117626503, 0.711884320, 0.170489177, 0.198500007, 0.544321597, 4.22184952E-02, 2.65864264E-02, + -1.45837115E-02, 0.117033370, 0.711650848, 0.171315819, 0.199499995, 0.544128537, 4.22185212E-02, 2.65976116E-02, -1.45763736E-02, 0.116437860, 0.711416185, 0.172145948, + 0.200499997, 0.543935001, 4.22184914E-02, 2.66087260E-02, -1.45688346E-02, 0.115840003, 0.711180449, 0.172979563, 0.201499999, 0.543741047, 4.22184132E-02, 2.66197678E-02, + -1.45610943E-02, 0.115239792, 0.710943580, 0.173816636, 0.202500001, 0.543546617, 4.22182865E-02, 2.66307388E-02, -1.45531520E-02, 0.114637248, 0.710705578, 0.174657151, + 0.203500003, 0.543351769, 4.22181077E-02, 2.66416389E-02, -1.45450085E-02, 0.114032388, 0.710466564, 0.175501078, 0.204500005, 0.543156445, 4.22178768E-02, 2.66524702E-02, + -1.45366648E-02, 0.113425218, 0.710226357, 0.176348418, 0.205500007, 0.542960644, 4.22175936E-02, 2.66632307E-02, -1.45281190E-02, 0.112815753, 0.709985137, 0.177199125, + 0.206499994, 0.542764366, 4.22172621E-02, 2.66739223E-02, -1.45193730E-02, 0.112204015, 0.709742785, 0.178053215, 0.207499996, 0.542567611, 4.22168784E-02, 2.66845450E-02, + -1.45104248E-02, 0.111589998, 0.709499359, 0.178910628, 0.208499998, 0.542370319, 4.22164463E-02, 2.66951006E-02, -1.45012774E-02, 0.110973738, 0.709254861, 0.179771379, + 0.209500000, 0.542172611, 4.22159620E-02, 2.67055873E-02, -1.44919287E-02, 0.110355228, 0.709009349, 0.180635437, 0.210500002, 0.541974366, 4.22154255E-02, 2.67160088E-02, + -1.44823790E-02, 0.109734498, 0.708762705, 0.181502774, 0.211500004, 0.541775644, 4.22148407E-02, 2.67263632E-02, -1.44726299E-02, 0.109111555, 0.708515048, 0.182373375, + 0.212500006, 0.541576385, 4.22142036E-02, 2.67366506E-02, -1.44626806E-02, 0.108486407, 0.708266377, 0.183247223, 0.213499993, 0.541376650, 4.22135182E-02, 2.67468747E-02, + -1.44525301E-02, 0.107859075, 0.708016634, 0.184124291, 0.214499995, 0.541176379, 4.22127806E-02, 2.67570335E-02, -1.44421812E-02, 0.107229568, 0.707765877, 0.185004577, + 0.215499997, 0.540975571, 4.22119945E-02, 2.67671291E-02, -1.44316312E-02, 0.106597908, 0.707514048, 0.185888037, 0.216499999, 0.540774226, 4.22111526E-02, 2.67771594E-02, + -1.44208828E-02, 0.105964102, 0.707261264, 0.186774656, 0.217500001, 0.540572345, 4.22102660E-02, 2.67871283E-02, -1.44099342E-02, 0.105328165, 0.707007408, 0.187664434, + 0.218500003, 0.540369928, 4.22093272E-02, 2.67970338E-02, -1.43987862E-02, 0.104690112, 0.706752539, 0.188557327, 0.219500005, 0.540166974, 4.22083363E-02, 2.68068779E-02, + -1.43874399E-02, 0.104049951, 0.706496716, 0.189453319, 0.220500007, 0.539963424, 4.22072932E-02, 2.68166624E-02, -1.43758943E-02, 0.103407711, 0.706239879, 0.190352395, + 0.221499994, 0.539759338, 4.22062017E-02, 2.68263854E-02, -1.43641494E-02, 0.102763392, 0.705982089, 0.191254541, 0.222499996, 0.539554715, 4.22050618E-02, 2.68360488E-02, + -1.43522071E-02, 0.102117017, 0.705723286, 0.192159727, 0.223499998, 0.539349496, 4.22038659E-02, 2.68456545E-02, -1.43400654E-02, 0.101468593, 0.705463469, 0.193067923, + 0.224500000, 0.539143682, 4.22026254E-02, 2.68552005E-02, -1.43277254E-02, 0.100818135, 0.705202758, 0.193979114, 0.225500003, 0.538937271, 4.22013290E-02, 2.68646888E-02, + -1.43151879E-02, 0.100165673, 0.704941034, 0.194893301, 0.226500005, 0.538730264, 4.21999842E-02, 2.68741194E-02, -1.43024521E-02, 9.95111987E-02, 0.704678357, 0.195810437, + 0.227500007, 0.538522661, 4.21985872E-02, 2.68834941E-02, -1.42895188E-02, 9.88547429E-02, 0.704414785, 0.196730494, 0.228499994, 0.538314521, 4.21971418E-02, 2.68928129E-02, + -1.42763881E-02, 9.81963128E-02, 0.704150200, 0.197653487, 0.229499996, 0.538105667, 4.21956442E-02, 2.69020777E-02, -1.42630599E-02, 9.75359231E-02, 0.703884721, 0.198579356, + 0.230499998, 0.537896276, 4.21940945E-02, 2.69112866E-02, -1.42495343E-02, 9.68735963E-02, 0.703618288, 0.199508101, 0.231500000, 0.537686229, 4.21924964E-02, 2.69204434E-02, + -1.42358113E-02, 9.62093398E-02, 0.703350961, 0.200439692, 0.232500002, 0.537475526, 4.21908461E-02, 2.69295461E-02, -1.42218927E-02, 9.55431685E-02, 0.703082740, 0.201374114, + 0.233500004, 0.537264168, 4.21891436E-02, 2.69385949E-02, -1.42077766E-02, 9.48751047E-02, 0.702813566, 0.202311352, 0.234500006, 0.537052214, 4.21873927E-02, 2.69475952E-02, + -1.41934641E-02, 9.42051560E-02, 0.702543497, 0.203251362, 0.235499993, 0.536839604, 4.21855897E-02, 2.69565415E-02, -1.41789550E-02, 9.35333371E-02, 0.702272534, 0.204194129, + 0.236499995, 0.536626339, 4.21837345E-02, 2.69654393E-02, -1.41642503E-02, 9.28596705E-02, 0.702000678, 0.205139652, 0.237499997, 0.536412358, 4.21818309E-02, 2.69742869E-02, + -1.41493501E-02, 9.21841636E-02, 0.701727986, 0.206087872, 0.238499999, 0.536197782, 4.21798714E-02, 2.69830860E-02, -1.41342534E-02, 9.15068388E-02, 0.701454341, 0.207038805, + 0.239500001, 0.535982430, 4.21778634E-02, 2.69918367E-02, -1.41189611E-02, 9.08277035E-02, 0.701179922, 0.207992405, 0.240500003, 0.535766482, 4.21758071E-02, 2.70005409E-02, + -1.41034732E-02, 9.01467726E-02, 0.700904548, 0.208948657, 0.241500005, 0.535549819, 4.21736948E-02, 2.70091966E-02, -1.40877906E-02, 8.94640759E-02, 0.700628400, 0.209907547, + 0.242500007, 0.535332441, 4.21715342E-02, 2.70178076E-02, -1.40719134E-02, 8.87796134E-02, 0.700351357, 0.210869029, 0.243499994, 0.535114348, 4.21693213E-02, 2.70263720E-02, + -1.40558407E-02, 8.80934075E-02, 0.700073481, 0.211833104, 0.244499996, 0.534895539, 4.21670564E-02, 2.70348936E-02, -1.40395733E-02, 8.74054730E-02, 0.699794769, 0.212799743, + 0.245499998, 0.534676015, 4.21647392E-02, 2.70433705E-02, -1.40231112E-02, 8.67158249E-02, 0.699515283, 0.213768914, 0.246500000, 0.534455717, 4.21623737E-02, 2.70518046E-02, + -1.40064554E-02, 8.60244855E-02, 0.699234903, 0.214740604, 0.247500002, 0.534234762, 4.21599559E-02, 2.70601958E-02, -1.39896050E-02, 8.53314549E-02, 0.698953748, 0.215714797, + 0.248500004, 0.534013033, 4.21574824E-02, 2.70685460E-02, -1.39725609E-02, 8.46367627E-02, 0.698671758, 0.216691449, 0.249500006, 0.533790529, 4.21549603E-02, 2.70768553E-02, + -1.39553221E-02, 8.39404240E-02, 0.698389053, 0.217670560, 0.250499994, 0.533567309, 4.21523899E-02, 2.70851254E-02, -1.39378905E-02, 8.32424462E-02, 0.698105454, 0.218652084, + 0.251500010, 0.533343315, 4.21497636E-02, 2.70933546E-02, -1.39202652E-02, 8.25428441E-02, 0.697821140, 0.219636023, 0.252499998, 0.533118486, 4.21470851E-02, 2.71015447E-02, + -1.39024463E-02, 8.18416476E-02, 0.697536051, 0.220622331, 0.253500015, 0.532892942, 4.21443544E-02, 2.71096993E-02, -1.38844345E-02, 8.11388642E-02, 0.697250128, 0.221610993, + 0.254500002, 0.532666624, 4.21415754E-02, 2.71178149E-02, -1.38662299E-02, 8.04345086E-02, 0.696963489, 0.222601995, 0.255499989, 0.532439470, 4.21387404E-02, 2.71258950E-02, + -1.38478316E-02, 7.97285959E-02, 0.696676075, 0.223595306, 0.256500006, 0.532211542, 4.21358570E-02, 2.71339398E-02, -1.38292415E-02, 7.90211484E-02, 0.696387947, 0.224590912, + 0.257499993, 0.531982780, 4.21329178E-02, 2.71419492E-02, -1.38104586E-02, 7.83121809E-02, 0.696099043, 0.225588784, 0.258500010, 0.531753182, 4.21299301E-02, 2.71499250E-02, + -1.37914829E-02, 7.76017085E-02, 0.695809424, 0.226588875, 0.259499997, 0.531522810, 4.21268865E-02, 2.71578673E-02, -1.37723153E-02, 7.68897384E-02, 0.695519030, 0.227591202, + 0.260500014, 0.531291544, 4.21237908E-02, 2.71657761E-02, -1.37529559E-02, 7.61763006E-02, 0.695227981, 0.228595719, 0.261500001, 0.531059504, 4.21206467E-02, 2.71736551E-02, + -1.37334038E-02, 7.54614100E-02, 0.694936216, 0.229602396, 0.262499988, 0.530826569, 4.21174467E-02, 2.71815024E-02, -1.37136597E-02, 7.47450739E-02, 0.694643676, 0.230611220, + 0.263500005, 0.530592799, 4.21141945E-02, 2.71893200E-02, -1.36937248E-02, 7.40273148E-02, 0.694350481, 0.231622174, 0.264499992, 0.530358136, 4.21108902E-02, 2.71971077E-02, + -1.36735979E-02, 7.33081475E-02, 0.694056630, 0.232635230, 0.265500009, 0.530122638, 4.21075337E-02, 2.72048656E-02, -1.36532793E-02, 7.25875869E-02, 0.693762064, 0.233650357, + 0.266499996, 0.529886246, 4.21041250E-02, 2.72125974E-02, -1.36327697E-02, 7.18656555E-02, 0.693466783, 0.234667540, 0.267500013, 0.529648960, 4.21006605E-02, 2.72203013E-02, + -1.36120692E-02, 7.11423680E-02, 0.693170905, 0.235686749, 0.268500000, 0.529410779, 4.20971438E-02, 2.72279792E-02, -1.35911768E-02, 7.04177320E-02, 0.692874312, 0.236707956, + 0.269499987, 0.529171705, 4.20935750E-02, 2.72356328E-02, -1.35700945E-02, 6.96917772E-02, 0.692577064, 0.237731144, 0.270500004, 0.528931737, 4.20899540E-02, 2.72432603E-02, + -1.35488203E-02, 6.89645112E-02, 0.692279220, 0.238756284, 0.271499991, 0.528690815, 4.20862809E-02, 2.72508636E-02, -1.35273561E-02, 6.82359561E-02, 0.691980660, 0.239783362, + 0.272500008, 0.528448939, 4.20825519E-02, 2.72584446E-02, -1.35057010E-02, 6.75061271E-02, 0.691681504, 0.240812346, 0.273499995, 0.528206170, 4.20787707E-02, 2.72660032E-02, + -1.34838549E-02, 6.67750388E-02, 0.691381752, 0.241843224, 0.274500012, 0.527962446, 4.20749336E-02, 2.72735413E-02, -1.34618189E-02, 6.60427138E-02, 0.691081345, 0.242875949, + 0.275500000, 0.527717769, 4.20710482E-02, 2.72810571E-02, -1.34395920E-02, 6.53091595E-02, 0.690780342, 0.243910506, 0.276499987, 0.527472138, 4.20671031E-02, 2.72885542E-02, + -1.34171750E-02, 6.45743981E-02, 0.690478742, 0.244946882, 0.277500004, 0.527225554, 4.20631096E-02, 2.72960309E-02, -1.33945681E-02, 6.38384521E-02, 0.690176487, 0.245985046, + 0.278499991, 0.526977956, 4.20590565E-02, 2.73034889E-02, -1.33717712E-02, 6.31013289E-02, 0.689873695, 0.247024968, 0.279500008, 0.526729345, 4.20549549E-02, 2.73109321E-02, + -1.33487834E-02, 6.23630472E-02, 0.689570308, 0.248066634, 0.280499995, 0.526479781, 4.20507975E-02, 2.73183566E-02, -1.33256065E-02, 6.16236292E-02, 0.689266384, 0.249110013, + 0.281500012, 0.526229262, 4.20465842E-02, 2.73257643E-02, -1.33022396E-02, 6.08830862E-02, 0.688961864, 0.250155061, 0.282499999, 0.525977671, 4.20423187E-02, 2.73331590E-02, + -1.32786818E-02, 6.01414405E-02, 0.688656747, 0.251201808, 0.283499986, 0.525725067, 4.20379974E-02, 2.73405369E-02, -1.32549349E-02, 5.93987070E-02, 0.688351154, 0.252250165, + 0.284500003, 0.525471449, 4.20336202E-02, 2.73479037E-02, -1.32309990E-02, 5.86549044E-02, 0.688044965, 0.253300160, 0.285499990, 0.525216758, 4.20291908E-02, 2.73552556E-02, + -1.32068722E-02, 5.79100475E-02, 0.687738240, 0.254351735, 0.286500007, 0.524961054, 4.20247056E-02, 2.73625981E-02, -1.31825563E-02, 5.71641549E-02, 0.687430978, 0.255404860, + 0.287499994, 0.524704278, 4.20201644E-02, 2.73699276E-02, -1.31580504E-02, 5.64172417E-02, 0.687123239, 0.256459534, 0.288500011, 0.524446487, 4.20155674E-02, 2.73772478E-02, + -1.31333554E-02, 5.56693263E-02, 0.686814964, 0.257515728, 0.289499998, 0.524187565, 4.20109183E-02, 2.73845587E-02, -1.31084705E-02, 5.49204275E-02, 0.686506152, 0.258573413, + 0.290499985, 0.523927569, 4.20062132E-02, 2.73918603E-02, -1.30833965E-02, 5.41705601E-02, 0.686196864, 0.259632587, 0.291500002, 0.523666501, 4.20014523E-02, 2.73991544E-02, + -1.30581316E-02, 5.34197465E-02, 0.685887098, 0.260693163, 0.292499989, 0.523404360, 4.19966318E-02, 2.74064410E-02, -1.30326785E-02, 5.26679978E-02, 0.685576797, 0.261755168, + 0.293500006, 0.523141086, 4.19917591E-02, 2.74137203E-02, -1.30070355E-02, 5.19153364E-02, 0.685266078, 0.262818575, 0.294499993, 0.522876680, 4.19868305E-02, 2.74209958E-02, + -1.29812025E-02, 5.11617772E-02, 0.684954882, 0.263883352, 0.295500010, 0.522611141, 4.19818461E-02, 2.74282675E-02, -1.29551804E-02, 5.04073389E-02, 0.684643209, 0.264949441, + 0.296499997, 0.522344530, 4.19768058E-02, 2.74355337E-02, -1.29289683E-02, 4.96520363E-02, 0.684331059, 0.266016871, 0.297500014, 0.522076726, 4.19717059E-02, 2.74427980E-02, + -1.29025662E-02, 4.88958918E-02, 0.684018493, 0.267085582, 0.298500001, 0.521807790, 4.19665501E-02, 2.74500586E-02, -1.28759751E-02, 4.81389202E-02, 0.683705509, 0.268155575, + 0.299499989, 0.521537662, 4.19613384E-02, 2.74573192E-02, -1.28491949E-02, 4.73811366E-02, 0.683392048, 0.269226789, 0.300500005, 0.521266401, 4.19560708E-02, 2.74645798E-02, + -1.28222238E-02, 4.66225632E-02, 0.683078229, 0.270299226, 0.301499993, 0.520993948, 4.19507436E-02, 2.74718404E-02, -1.27950637E-02, 4.58632149E-02, 0.682763934, 0.271372855, + 0.302500010, 0.520720303, 4.19453606E-02, 2.74791010E-02, -1.27677135E-02, 4.51031104E-02, 0.682449222, 0.272447646, 0.303499997, 0.520445526, 4.19399180E-02, 2.74863653E-02, + -1.27401734E-02, 4.43422683E-02, 0.682134151, 0.273523569, 0.304500014, 0.520169437, 4.19344194E-02, 2.74936315E-02, -1.27124442E-02, 4.35807072E-02, 0.681818664, 0.274600625, + 0.305500001, 0.519892216, 4.19288613E-02, 2.75009014E-02, -1.26845241E-02, 4.28184420E-02, 0.681502819, 0.275678754, 0.306499988, 0.519613743, 4.19232473E-02, 2.75081750E-02, + -1.26564140E-02, 4.20554914E-02, 0.681186557, 0.276757926, 0.307500005, 0.519334018, 4.19175737E-02, 2.75154542E-02, -1.26281139E-02, 4.12918739E-02, 0.680869937, 0.277838171, + 0.308499992, 0.519053042, 4.19118404E-02, 2.75227409E-02, -1.25996238E-02, 4.05276045E-02, 0.680553019, 0.278919399, 0.309500009, 0.518770874, 4.19060476E-02, 2.75300331E-02, + -1.25709428E-02, 3.97627093E-02, 0.680235684, 0.280001611, 0.310499996, 0.518487394, 4.19001952E-02, 2.75373347E-02, -1.25420718E-02, 3.89971957E-02, 0.679917991, 0.281084806, + 0.311500013, 0.518202662, 4.18942869E-02, 2.75446437E-02, -1.25130098E-02, 3.82310897E-02, 0.679600000, 0.282168925, 0.312500000, 0.517916620, 4.18883152E-02, 2.75519621E-02, + -1.24837579E-02, 3.74644063E-02, 0.679281652, 0.283253938, 0.313499987, 0.517629325, 4.18822877E-02, 2.75592916E-02, -1.24543151E-02, 3.66971642E-02, 0.678963006, 0.284339845, + 0.314500004, 0.517340720, 4.18761969E-02, 2.75666323E-02, -1.24246813E-02, 3.59293781E-02, 0.678644001, 0.285426617, 0.315499991, 0.517050743, 4.18700427E-02, 2.75739841E-02, + -1.23948557E-02, 3.51610705E-02, 0.678324699, 0.286514223, 0.316500008, 0.516759515, 4.18638326E-02, 2.75813490E-02, -1.23648401E-02, 3.43922600E-02, 0.678005099, 0.287602603, + 0.317499995, 0.516466975, 4.18575592E-02, 2.75887288E-02, -1.23346327E-02, 3.36229615E-02, 0.677685261, 0.288691789, 0.318500012, 0.516173065, 4.18512262E-02, 2.75961217E-02, + -1.23042343E-02, 3.28531936E-02, 0.677365065, 0.289781719, 0.319499999, 0.515877783, 4.18448299E-02, 2.76035313E-02, -1.22736441E-02, 3.20829749E-02, 0.677044630, 0.290872365, + 0.320499986, 0.515581191, 4.18383740E-02, 2.76109558E-02, -1.22428620E-02, 3.13123241E-02, 0.676723957, 0.291963726, 0.321500003, 0.515283227, 4.18318547E-02, 2.76183989E-02, + -1.22118872E-02, 3.05412598E-02, 0.676402986, 0.293055773, 0.322499990, 0.514983833, 4.18252721E-02, 2.76258588E-02, -1.21807214E-02, 2.97698006E-02, 0.676081777, 0.294148445, + 0.323500007, 0.514683127, 4.18186262E-02, 2.76333373E-02, -1.21493628E-02, 2.89979633E-02, 0.675760269, 0.295241743, 0.324499995, 0.514380932, 4.18119170E-02, 2.76408363E-02, + -1.21178124E-02, 2.82257665E-02, 0.675438583, 0.296335667, 0.325500011, 0.514077425, 4.18051481E-02, 2.76483558E-02, -1.20860683E-02, 2.74532288E-02, 0.675116658, 0.297430128, + 0.326499999, 0.513772428, 4.17983122E-02, 2.76558958E-02, -1.20541323E-02, 2.66803708E-02, 0.674794495, 0.298525155, 0.327499986, 0.513466060, 4.17914130E-02, 2.76634600E-02, + -1.20220026E-02, 2.59072073E-02, 0.674472094, 0.299620688, 0.328500003, 0.513158202, 4.17844467E-02, 2.76710447E-02, -1.19896792E-02, 2.51337588E-02, 0.674149573, 0.300716698, + 0.329499990, 0.512848914, 4.17774208E-02, 2.76786555E-02, -1.19571630E-02, 2.43600421E-02, 0.673826754, 0.301813185, 0.330500007, 0.512538195, 4.17703241E-02, 2.76862904E-02, + -1.19244531E-02, 2.35860776E-02, 0.673503816, 0.302910119, 0.331499994, 0.512225986, 4.17631678E-02, 2.76939515E-02, -1.18915485E-02, 2.28118841E-02, 0.673180640, 0.304007441, + 0.332500011, 0.511912286, 4.17559408E-02, 2.77016386E-02, -1.18584502E-02, 2.20374782E-02, 0.672857344, 0.305105180, 0.333499998, 0.511597157, 4.17486504E-02, 2.77093519E-02, + -1.18251573E-02, 2.12628786E-02, 0.672533870, 0.306203276, 0.334500015, 0.511280477, 4.17412929E-02, 2.77170949E-02, -1.17916698E-02, 2.04881039E-02, 0.672210217, 0.307301700, + 0.335500002, 0.510962248, 4.17338684E-02, 2.77248677E-02, -1.17579866E-02, 1.97131746E-02, 0.671886384, 0.308400422, 0.336499989, 0.510642588, 4.17263731E-02, 2.77326703E-02, + -1.17241079E-02, 1.89381093E-02, 0.671562493, 0.309499413, 0.337500006, 0.510321379, 4.17188145E-02, 2.77405027E-02, -1.16900345E-02, 1.81629229E-02, 0.671238422, 0.310598671, + 0.338499993, 0.509998560, 4.17111851E-02, 2.77483687E-02, -1.16557647E-02, 1.73876379E-02, 0.670914173, 0.311698169, 0.339500010, 0.509674251, 4.17034887E-02, 2.77562663E-02, + -1.16212983E-02, 1.66122708E-02, 0.670589864, 0.312797844, 0.340499997, 0.509348392, 4.16957214E-02, 2.77641974E-02, -1.15866354E-02, 1.58368424E-02, 0.670265436, 0.313897699, + 0.341500014, 0.509020925, 4.16878872E-02, 2.77721621E-02, -1.15517760E-02, 1.50613701E-02, 0.669940948, 0.314997703, 0.342500001, 0.508691907, 4.16799821E-02, 2.77801640E-02, + -1.15167182E-02, 1.42858727E-02, 0.669616282, 0.316097826, 0.343499988, 0.508361280, 4.16720062E-02, 2.77882013E-02, -1.14814639E-02, 1.35103688E-02, 0.669291556, 0.317198038, + 0.344500005, 0.508029044, 4.16639596E-02, 2.77962759E-02, -1.14460113E-02, 1.27348779E-02, 0.668966770, 0.318298340, 0.345499992, 0.507695198, 4.16558385E-02, 2.78043877E-02, + -1.14103612E-02, 1.19594187E-02, 0.668641925, 0.319398671, 0.346500009, 0.507359743, 4.16476503E-02, 2.78125387E-02, -1.13745118E-02, 1.11840088E-02, 0.668317020, 0.320499003, + 0.347499996, 0.507022619, 4.16393876E-02, 2.78207306E-02, -1.13384631E-02, 1.04086697E-02, 0.667991996, 0.321599305, 0.348500013, 0.506683886, 4.16310504E-02, 2.78289616E-02, + -1.13022150E-02, 9.63341817E-03, 0.667666972, 0.322699606, 0.349500000, 0.506343424, 4.16226424E-02, 2.78372355E-02, -1.12657677E-02, 8.85827467E-03, 0.667341948, 0.323799819, + 0.350499988, 0.506001353, 4.16141599E-02, 2.78455522E-02, -1.12291202E-02, 8.08325689E-03, 0.667016804, 0.324899912, 0.351500005, 0.505657613, 4.16056067E-02, 2.78539099E-02, + -1.11922715E-02, 7.30838394E-03, 0.666691720, 0.325999916, 0.352499992, 0.505312145, 4.15969752E-02, 2.78623141E-02, -1.11552216E-02, 6.53367583E-03, 0.666366577, 0.327099770, + 0.353500009, 0.504965007, 4.15882654E-02, 2.78707631E-02, -1.11179706E-02, 5.75915119E-03, 0.666041434, 0.328199416, 0.354499996, 0.504616141, 4.15794849E-02, 2.78792568E-02, + -1.10805174E-02, 4.98482911E-03, 0.665716290, 0.329298884, 0.355500013, 0.504265547, 4.15706262E-02, 2.78877988E-02, -1.10428622E-02, 4.21072822E-03, 0.665391147, 0.330398113, + 0.356500000, 0.503913224, 4.15616892E-02, 2.78963875E-02, -1.10050039E-02, 3.43686831E-03, 0.665066063, 0.331497073, 0.357499987, 0.503559172, 4.15526740E-02, 2.79050265E-02, + -1.09669426E-02, 2.66326847E-03, 0.664740980, 0.332595766, 0.358500004, 0.503203332, 4.15435843E-02, 2.79137138E-02, -1.09286774E-02, 1.88994757E-03, 0.664415896, 0.333694130, + 0.359499991, 0.502845764, 4.15344127E-02, 2.79224515E-02, -1.08902073E-02, 1.11692504E-03, 0.664090931, 0.334792167, 0.360500008, 0.502486408, 4.15251628E-02, 2.79312432E-02, + -1.08515332E-02, 3.44220141E-04, 0.663765967, 0.335889846, 0.361499995, 0.502125204, 4.15158309E-02, 2.79400852E-02, -1.08126532E-02, -4.28147963E-04, 0.663441062, 0.336987108, + 0.362500012, 0.501762271, 4.15064208E-02, 2.79489812E-02, -1.07735675E-02, -1.20016001E-03, 0.663116217, 0.338083953, 0.363499999, 0.501397491, 4.14969288E-02, 2.79579312E-02, + -1.07342759E-02, -1.97179662E-03, 0.662791431, 0.339180350, 0.364499986, 0.501030862, 4.14873548E-02, 2.79669352E-02, -1.06947776E-02, -2.74303835E-03, 0.662466764, 0.340276241, + 0.365500003, 0.500662386, 4.14776988E-02, 2.79759970E-02, -1.06550716E-02, -3.51386587E-03, 0.662142217, 0.341371655, 0.366499990, 0.500292122, 4.14679609E-02, 2.79851165E-02, + -1.06151570E-02, -4.28425986E-03, 0.661817729, 0.342466533, 0.367500007, 0.499919951, 4.14581373E-02, 2.79942919E-02, -1.05750347E-02, -5.05420053E-03, 0.661493361, 0.343560845, + 0.368499994, 0.499545932, 4.14482281E-02, 2.80035269E-02, -1.05347028E-02, -5.82366902E-03, 0.661169112, 0.344654590, 0.369500011, 0.499170005, 4.14382331E-02, 2.80128233E-02, + -1.04941614E-02, -6.59264531E-03, 0.660844982, 0.345747679, 0.370499998, 0.498792201, 4.14281562E-02, 2.80221794E-02, -1.04534104E-02, -7.36111077E-03, 0.660520971, 0.346840173, + 0.371499985, 0.498412490, 4.14179899E-02, 2.80315969E-02, -1.04124472E-02, -8.12904444E-03, 0.660197079, 0.347931951, 0.372500002, 0.498030841, 4.14077379E-02, 2.80410778E-02, + -1.03712734E-02, -8.89642816E-03, 0.659873366, 0.349023044, 0.373499990, 0.497647285, 4.13973965E-02, 2.80506201E-02, -1.03298873E-02, -9.66324192E-03, 0.659549832, 0.350113422, + 0.374500006, 0.497261763, 4.13869657E-02, 2.80602295E-02, -1.02882879E-02, -1.04294661E-02, 0.659226418, 0.351203024, 0.375499994, 0.496874303, 4.13764454E-02, 2.80699041E-02, + -1.02464762E-02, -1.11950804E-02, 0.658903241, 0.352291852, 0.376500010, 0.496484846, 4.13658358E-02, 2.80796438E-02, -1.02044493E-02, -1.19600659E-02, 0.658580184, 0.353379875, + 0.377499998, 0.496093452, 4.13551331E-02, 2.80894525E-02, -1.01622082E-02, -1.27244033E-02, 0.658257365, 0.354467064, 0.378500015, 0.495700032, 4.13443409E-02, 2.80993283E-02, + -1.01197511E-02, -1.34880729E-02, 0.657934725, 0.355553359, 0.379500002, 0.495304614, 4.13334519E-02, 2.81092748E-02, -1.00770779E-02, -1.42510533E-02, 0.657612264, 0.356638789, + 0.380499989, 0.494907200, 4.13224734E-02, 2.81192902E-02, -1.00341886E-02, -1.50133269E-02, 0.657290041, 0.357723266, 0.381500006, 0.494507730, 4.13113981E-02, 2.81293783E-02, + -9.99108143E-03, -1.57748722E-02, 0.656968057, 0.358806819, 0.382499993, 0.494106233, 4.13002297E-02, 2.81395372E-02, -9.94775537E-03, -1.65356714E-02, 0.656646311, 0.359889358, + 0.383500010, 0.493702680, 4.12889645E-02, 2.81497706E-02, -9.90421139E-03, -1.72957033E-02, 0.656324804, 0.360970914, 0.384499997, 0.493297040, 4.12776023E-02, 2.81600766E-02, + -9.86044668E-03, -1.80549473E-02, 0.656003535, 0.362051427, 0.385500014, 0.492889345, 4.12661396E-02, 2.81704590E-02, -9.81646124E-03, -1.88133847E-02, 0.655682504, 0.363130897, + 0.386500001, 0.492479533, 4.12545800E-02, 2.81809177E-02, -9.77225509E-03, -1.95709951E-02, 0.655361772, 0.364209235, 0.387499988, 0.492067635, 4.12429236E-02, 2.81914528E-02, + -9.72782727E-03, -2.03277599E-02, 0.655041277, 0.365286469, 0.388500005, 0.491653621, 4.12311628E-02, 2.82020662E-02, -9.68317594E-03, -2.10836567E-02, 0.654721081, 0.366362572, + 0.389499992, 0.491237491, 4.12193015E-02, 2.82127578E-02, -9.63830110E-03, -2.18386669E-02, 0.654401183, 0.367437482, 0.390500009, 0.490819186, 4.12073396E-02, 2.82235313E-02, + -9.59320087E-03, -2.25927718E-02, 0.654081583, 0.368511170, 0.391499996, 0.490398765, 4.11952734E-02, 2.82343850E-02, -9.54787619E-03, -2.33459491E-02, 0.653762281, 0.369583637, + 0.392500013, 0.489976138, 4.11831029E-02, 2.82453205E-02, -9.50232521E-03, -2.40981784E-02, 0.653443336, 0.370654851, 0.393500000, 0.489551336, 4.11708243E-02, 2.82563400E-02, + -9.45654698E-03, -2.48494428E-02, 0.653124690, 0.371724755, 0.394499987, 0.489124358, 4.11584415E-02, 2.82674432E-02, -9.41054057E-03, -2.55997181E-02, 0.652806401, 0.372793347, + 0.395500004, 0.488695145, 4.11459506E-02, 2.82786321E-02, -9.36430506E-03, -2.63489876E-02, 0.652488410, 0.373860598, 0.396499991, 0.488263756, 4.11333516E-02, 2.82899048E-02, + -9.31784045E-03, -2.70972289E-02, 0.652170777, 0.374926448, 0.397500008, 0.487830102, 4.11206447E-02, 2.83012670E-02, -9.27114487E-03, -2.78444234E-02, 0.651853502, 0.375990897, + 0.398499995, 0.487394184, 4.11078297E-02, 2.83127148E-02, -9.22421645E-03, -2.85905469E-02, 0.651536644, 0.377053916, 0.399500012, 0.486956030, 4.10948917E-02, 2.83242576E-02, + -9.17705987E-03, -2.93355919E-02, 0.651220083, 0.378115475, 0.400000006, 0.486532003, 4.11139540E-02, 2.83555184E-02, -9.18524247E-03, -3.00840233E-02, 0.650901794, 0.379182220}; class HelmholtzFD_Op : public E_F0mps { public: @@ -773,126 +466,123 @@ class HelmholtzFD_Op : public E_F0mps { expmu = to< Complex >(args[2]); } - long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a;} - string* arg(int i, Stack stack, string* a) const { return nargs[i] ? GetAny< string* >((*nargs[i])(stack)) : a;} - KN_ arg(int i,Stack stack, KN_ a ) const { return nargs[i] ? GetAny >((*nargs[i])(stack)): a;} + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type HelmholtzFD_Op::name_param[] = { - {"npml", &typeid(KN_)} -}; +basicAC_F0::name_and_type HelmholtzFD_Op::name_param[] = {{"npml", &typeid(KN_< long >)}}; -class HelmholtzFD : public OneOperator { - public: - HelmholtzFD() : OneOperator(atype< newpMatrice_Creuse< Complex > >( ), atype< const Mesh3 * >( ), atype< Complex >( ), atype< Complex >( )) {}; - E_F0 *code(const basicAC_F0 &args) const { return new HelmholtzFD_Op(args, t[0]->CastTo(args[0])); } +class HelmholtzFD : public OneOperator { + public: + HelmholtzFD( ) : OneOperator(atype< newpMatrice_Creuse< Complex > >( ), atype< const Mesh3 * >( ), atype< Complex >( ), atype< Complex >( )) {}; + E_F0 *code(const basicAC_F0 &args) const { return new HelmholtzFD_Op(args, t[0]->CastTo(args[0])); } }; -long kkindex(long i1, long i2, long i3, long n1, long n2, long n3) { - return i2*n3*n1+i1*n3+i3; -} +long kkindex(long i1, long i2, long i3, long n1, long n2, long n3) { return i2 * n3 * n1 + i1 * n3 + i3; } -void subdamp(long n,int npmll, int npmlu, int apml, double h, double omega, std::vector>& damp, std::vector>& dampb, int sides) { +void subdamp(long n, int npmll, int npmlu, int apml, double h, double omega, std::vector< std::complex< double > > &damp, std::vector< std::complex< double > > &dampb, int sides) { double half_pi = 1.570796327; - std::complex ci(0,1); - - for (int i=0; i<=n+1; i++) { + std::complex< double > ci(0, 1); + + for (int i = 0; i <= n + 1; i++) { damp[i] = 1.; dampb[i] = 1.; } - double xpmll = npmll*h; - double xpmlu = npmlu*h; - double xmax = (n-1)*h; + double xpmll = npmll * h; + double xpmlu = npmlu * h; + double xmax = (n - 1) * h; double x, xb, eps, epsb; if (sides & 1) - for (int i=1; i<=npmll; i++) { - x = (i-1)*h; - xb = (i-1)*h+0.5*h; - eps = apml*(1.-cos((xpmll-x)*half_pi/xpmll)); - epsb = apml*(1.-cos((xpmll-xb)*half_pi/xpmll)); - damp[i] = 1./(1.+ci*eps/omega); - dampb[i] = 1./(1.+ci*epsb/omega); - } + for (int i = 1; i <= npmll; i++) { + x = (i - 1) * h; + xb = (i - 1) * h + 0.5 * h; + eps = apml * (1. - cos((xpmll - x) * half_pi / xpmll)); + epsb = apml * (1. - cos((xpmll - xb) * half_pi / xpmll)); + damp[i] = 1. / (1. + ci * eps / omega); + dampb[i] = 1. / (1. + ci * epsb / omega); + } if (sides & 2) - for (int i=1; i<=npmlu; i++) { - x = (i-1)*h; - xb = (i-1)*h+0.5*h; - eps = apml*(1.-cos((xpmlu-x)*half_pi/xpmlu)); - epsb = apml*(1.-cos((xpmlu-xb)*half_pi/xpmlu)); - damp[n-i+1] = 1./(1.+ci*eps/omega); - } + for (int i = 1; i <= npmlu; i++) { + x = (i - 1) * h; + xb = (i - 1) * h + 0.5 * h; + eps = apml * (1. - cos((xpmlu - x) * half_pi / xpmlu)); + epsb = apml * (1. - cos((xpmlu - xb) * half_pi / xpmlu)); + damp[n - i + 1] = 1. / (1. + ci * eps / omega); + } damp[0] = damp[1]; - damp[n+1] = damp[n]; + damp[n + 1] = damp[n]; if (sides & 2) - for (int i=1; i<=npmlu+1; i++) { - xb = xmax+0.5*h-(i-1)*h; - epsb = apml*(1.-cos((xb-(xmax-xpmlu))*half_pi/xpmlu)); - dampb[n-i+1] = 1./(1.+ci*epsb/omega); - } + for (int i = 1; i <= npmlu + 1; i++) { + xb = xmax + 0.5 * h - (i - 1) * h; + epsb = apml * (1. - cos((xb - (xmax - xpmlu)) * half_pi / xpmlu)); + dampb[n - i + 1] = 1. / (1. + ci * epsb / omega); + } dampb[0] = dampb[1]; - dampb[n+1] = dampb[n]; + dampb[n + 1] = dampb[n]; } -template -MatriceMorse * buildInterpolationMatrixT1(const FESpaceT & Uh,const KN_ & xx,const KN_ & yy ,const KN_ & zz) -{ +template< class FESpaceT > +MatriceMorse< double > *buildInterpolationMatrixT1(const FESpaceT &Uh, const KN_< double > &xx, const KN_< double > &yy, const KN_< double > &zz) { typedef typename FESpaceT::Mesh MeshT; typedef typename FESpaceT::FElement FElementT; typedef typename MeshT::Element ElementT; typedef typename FESpaceT::Rd RdT; typedef typename ElementT::RdHat RdHatT; - int op=op_id; // value of the function - int icomp=0; - bool inside=false; + int op = op_id; // value of the function + int icomp = 0; + bool inside = false; - int n=Uh.NbOfDF; - int mm=xx.N(); - int nbxx= mm; - const MeshT & ThU = Uh.Th; // line + int n = Uh.NbOfDF; + int mm = xx.N( ); + int nbxx = mm; + const MeshT &ThU = Uh.Th; // line FElementT Uh0 = Uh[0]; - int nbdfUK= Uh0.NbDoF(); - int NUh= Uh0.N; + int nbdfUK = Uh0.NbDoF( ); + int NUh = Uh0.N; - const int sfb1=Uh0.N*last_operatortype*Uh0.NbDoF(); - KN kv(sfb1); - R * v = kv; + const int sfb1 = Uh0.N * last_operatortype * Uh0.NbDoF( ); + KN< double > kv(sfb1); + R *v = kv; const R eps = 1e-10; - What_d whatd= 1 << op; - MatriceMorse * m = new MatriceMorse(n,mm,0,0); + What_d whatd = 1 << op; + MatriceMorse< double > *m = new MatriceMorse< double >(n, mm, 0, 0); RdHatT Phat; bool outside; - for(int ii=0;ii9) cout << " Find ThU " < 9) cout << " Find ThU " << ii << ":" << RdT(xx[ii], yy[ii], zz[ii]) << endl; + const ElementT *ts = ThU.Find(RdT(xx[ii], yy[ii], zz[ii]), Phat, outside); + if (outside && !inside) continue; int it = ThU(ts); FElementT KU(Uh[it]); - KNMK_ fb(v,nbdfUK,NUh,last_operatortype); - Uh0.tfe->FB(whatd,ThU,ThU[it],Phat,fb); - KN_ Fwi(fb('.',icomp,op)); - for (int idfu=0;idfu fb(v, nbdfUK, NUh, last_operatortype); + Uh0.tfe->FB(whatd, ThU, ThU[it], Phat, fb); + KN_< double > Fwi(fb('.', icomp, op)); + for (int idfu = 0; idfu < nbdfUK; idfu++) { + int j = ii; + int i = KU(idfu); R c = Fwi(idfu); - if(Abs(c)>eps) - (*m)(i,j) += c; + if (Abs(c) > eps) (*m)(i, j) += c; } } return m; } -template bool cmp(const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; } +template< class T > +bool cmp(const std::pair< unsigned int, T > &lhs, const std::pair< unsigned int, T > &rhs) { + return lhs.first < rhs.first; +} AnyType HelmholtzFD_Op::operator( )(Stack stack) const { @@ -910,307 +600,296 @@ AnyType HelmholtzFD_Op::operator( )(Stack stack) const { ffassert(pTh); const Mesh3 &Th(*pTh); - double lx = 1e+30, ly=1e+30, lz=1e+30, ux=-1e+30, uy=-1e+30, uz=-1e+30, h = 1e+30; - - for (int i=0; i defnpml(6,8); - KN npml(arg(0,stack,defnpml)); + KN< long > defnpml(6, 8); + KN< long > npml(arg(0, stack, defnpml)); - KN pmlsides(6,1); - for (int i=0; i<6; i++) pmlsides[i] = (npml[i] > 0L); + KN< long > pmlsides(6, 1); + for (int i = 0; i < 6; i++) pmlsides[i] = (npml[i] > 0L); - KN> mu(n1*n2*n3); - KN xx(n1*n2*n3), yy(n1*n2*n3), zz(n1*n2*n3); - KN boundarynodesFD(n1*n2*n3,0L); + KN< std::complex< double > > mu(n1 * n2 * n3); + KN< double > xx(n1 * n2 * n3), yy(n1 * n2 * n3), zz(n1 * n2 * n3); + KN< long > boundarynodesFD(n1 * n2 * n3, 0L); int cpt = 0; for (long i2 = 0; i2 < n2; i2++) - for (long i1 = 0; i1 < n1; i1++) - for (long i3 = 0; i3 < n3; i3++) { - xx[cpt] = lx + i1*h; yy[cpt] = ly + i2*h; zz[cpt] = lz + i3*h; - MeshPoint* mp(Fem2D::MeshPointStack(stack)); - mp->set(xx[cpt], yy[cpt], zz[cpt]); - mu[cpt] = GetAny>( (*expmu)(stack) ); - if ((i1 == 0 && !npml[0]) || (i1 == n1-1 && !npml[1]) - || (i2 == 0 && !npml[2]) || (i2 == n2-1 && !npml[3]) - || (i3 == 0 && !npml[4]) || (i3 == n3-1 && !npml[5])) - boundarynodesFD[kkindex(i1,i2,i3,n1,n2,n3)] = 1; - cpt++; - } + for (long i1 = 0; i1 < n1; i1++) + for (long i3 = 0; i3 < n3; i3++) { + xx[cpt] = lx + i1 * h; + yy[cpt] = ly + i2 * h; + zz[cpt] = lz + i3 * h; + MeshPoint *mp(Fem2D::MeshPointStack(stack)); + mp->set(xx[cpt], yy[cpt], zz[cpt]); + mu[cpt] = GetAny< std::complex< double > >((*expmu)(stack)); + if ((i1 == 0 && !npml[0]) || (i1 == n1 - 1 && !npml[1]) || (i2 == 0 && !npml[2]) || (i2 == n2 - 1 && !npml[3]) || (i3 == 0 && !npml[4]) || (i3 == n3 - 1 && !npml[5])) + boundarynodesFD[kkindex(i1, i2, i3, n1, n2, n3)] = 1; + cpt++; + } { - std::vector>> dd(3), db(3); - - dd[0].resize(n1+2); dd[1].resize(n2+2); dd[2].resize(n3+2); - db[0].resize(n1+2); db[1].resize(n2+2); db[2].resize(n3+2); + std::vector< std::vector< std::complex< double > > > dd(3), db(3); + + dd[0].resize(n1 + 2); + dd[1].resize(n2 + 2); + dd[2].resize(n3 + 2); + db[0].resize(n1 + 2); + db[1].resize(n2 + 2); + db[2].resize(n3 + 2); - subdamp(n1,npml[0],npml[1],90,h,omega.real(),dd[0],db[0],pmlsides[0]+2*pmlsides[1]); - subdamp(n2,npml[2],npml[3],90,h,omega.real(),dd[1],db[1],pmlsides[2]+2*pmlsides[3]); - subdamp(n3,npml[4],npml[5],90,h,omega.real(),dd[2],db[2],pmlsides[4]+2*pmlsides[5]); + subdamp(n1, npml[0], npml[1], 90, h, omega.real( ), dd[0], db[0], pmlsides[0] + 2 * pmlsides[1]); + subdamp(n2, npml[2], npml[3], 90, h, omega.real( ), dd[1], db[1], pmlsides[2] + 2 * pmlsides[3]); + subdamp(n3, npml[4], npml[5], 90, h, omega.real( ), dd[2], db[2], pmlsides[4] + 2 * pmlsides[5]); - MatriceMorse< Complex > *pAij = new MatriceMorse< Complex >(n1*n2*n3, n1*n2*n3, 0, 0), &Aij = *pAij; - - std::complex omega2 = omega*omega; + MatriceMorse< Complex > *pAij = new MatriceMorse< Complex >(n1 * n2 * n3, n1 * n2 * n3, 0, 0), &Aij = *pAij; - double c, d, e, f, w1 ,w2, w3; // weights of the mixed grid stencil + std::complex< double > omega2 = omega * omega; + + double c, d, e, f, w1, w2, w3; // weights of the mixed grid stencil double w2u, w3u; - double h2 = 1./(h*h); + double h2 = 1. / (h * h); long k, l, l1, l2, l3, ll[3], li, lj, lk, ii, ij, ik; - long ind6[6][3] = {{1,0,0},{0,1,0},{0,0,1}, - {-1,0,0},{0,-1,0},{0,0,-1}}; - long ind12[12][3] = {{1,1,0},{0,1,1},{1,0,1}, - {-1,-1,0},{0,-1,-1},{-1,0,-1}, - {-1,1,0},{1,-1,0}, - {0,-1,1},{0,1,-1}, - {1,0,-1},{-1,0,1}}; - long ik12[12] = {2,0,1,2,0,1,2,2,0,0,1,1}; - long ind8[8][3] = {{1,1,1},{-1,-1,-1}, - {-1,1,1},{1,-1,-1}, - {1,-1,1},{-1,1,-1}, - {1,1,-1},{-1,-1,1}}; + long ind6[6][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, 0, 0}, {0, -1, 0}, {0, 0, -1}}; + long ind12[12][3] = {{1, 1, 0}, {0, 1, 1}, {1, 0, 1}, {-1, -1, 0}, {0, -1, -1}, {-1, 0, -1}, {-1, 1, 0}, {1, -1, 0}, {0, -1, 1}, {0, 1, -1}, {1, 0, -1}, {-1, 0, 1}}; + long ik12[12] = {2, 0, 1, 2, 0, 1, 2, 2, 0, 0, 1, 1}; + long ind8[8][3] = {{1, 1, 1}, {-1, -1, -1}, {-1, 1, 1}, {1, -1, -1}, {1, -1, 1}, {-1, 1, -1}, {1, 1, -1}, {-1, -1, 1}}; double lambda, ppwl1, pi = 3.14159265358979323846; for (long i3 = 0; i3 < n3; i3++) - for (long i2 = 0; i2 < n2; i2++) - for (long i1 = 0; i1 < n1; i1++) { - l1 = i1; - l2 = i2; - l3 = i3; - k = kkindex(i1,i2,i3,n1,n2,n3); - - lambda = 2 * pi / omega.real() * sqrt(mu[k].real()); - //ppwl = lambda/h; - //int ntab = max(0.,min(343.,(ppwl-3)/(20.15-3)*343 + 0.5)); - - ppwl1 = h/lambda; - int ntab = 0; - while ((ppwl1 > wtab2[8*ntab]) && (ntab<398)) - ntab++; - if (ntab > 0) - if (abs(ppwl1-wtab2[8*ntab]) > abs(ppwl1-wtab2[8*(ntab-1)])) - ntab--; - - c=wtab2[8*ntab+1]; - d=wtab2[8*ntab+2]; - e=wtab2[8*ntab+3]; - f=wtab2[8*ntab+4]; - w1=wtab2[8*ntab+5]; - w2=wtab2[8*ntab+6]; - w3=wtab2[8*ntab+7]; - -/* - c=0; d=0; e=0; f=0; w1=0; w2=0; w3=0; - for (int j3=-1;j3<=1;j3++) - for (int j2=-1;j2<=1;j2++) - for (int j1=-1;j1<=1;j1++) { - long k3 = max(0L,min(n3-1,i3+j3)); - long k2 = max(0L,min(n2-1,i2+j2)); - long k1 = max(0L,min(n1-1,i1+j1)); - long kk = kkindex(k1,k2,k3,n1,n2,n3); - lambda = 2 * pi / omega.real() * sqrt(mu[kk]); - ppwl = lambda/h; - ntab = max(0.,min(343.,(ppwl-3)/(20.15-3)*343 + 0.5)); - c +=wtab[8*ntab+1]; - d +=wtab[8*ntab+2]; - e +=wtab[8*ntab+3]; - f +=wtab[8*ntab+4]; - w1+=wtab[8*ntab+5]; - w2+=wtab[8*ntab+6]; - w3+=wtab[8*ntab+7]; - } - c/=27; d/=27; e/=27; f/=27; w1/=27; w2/=27; w3/=27; -*/ - -/* - // G=4 - c=0.5915900; - d=4.9653493E-02; - e=5.1085097E-03; - f=6.1483691E-03; - w1=8.8075437E-02; - w2=0.8266806; - w3=8.5243940E-02; -*/ -/* - // G=4810 - c=0.4966390; - d=7.5123318E-02; - e=4.3846383E-03; - f=6.7614019E-07; - w1=5.0247996E-05; - w2=0.8900359; - w3=0.1099138; -*/ - - w2u=w2/3.; - w3u=w3/4.; - - /* Node 000 */ - l = k; - - Aij(k, l) = c*omega2/mu[k] - -w1*h2*( - dd[1][l2+1]*(db[1][l2+1]+db[1][l2]) - +dd[2][l3+1]*(db[2][l3+1]+db[2][l3]) - +dd[0][l1+1]*(db[0][l1+1]+db[0][l1]) // (6) - ) //R1 - -w2u*h2*2*( - dd[0][l1+1]*(db[0][l1+1]+db[0][l1]) - +dd[1][l2+1]*(db[1][l2+1]+db[1][l2]) - +dd[2][l3+1]*(db[2][l3+1]+db[2][l3]) // (0.75*8+6) - )//R2-R4 - -w3u*h2*0.5*4*( - dd[1][l2+1]*(db[1][l2+1]+db[1][l2]) - +dd[2][l3+1]*(db[2][l3+1]+db[2][l3]) - +dd[0][l1+1]*(db[0][l1+1]+db[0][l1]) // (0.5*24) - ); //B1-B4 - - /* 6 nodes */ - for (int q=0; q < 6; q++) { - l1 = i1+ind6[q][0]; - l2 = i2+ind6[q][1]; - l3 = i3+ind6[q][2]; - - ii = q%3; - ij = (ii+1)%3; - ik = (ij+1)%3; - - ll[0] = i1; ll[1] = i2; ll[2] = i3; - li = ll[ii]; lj = ll[ij]; lk = ll[ik]; - - if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { - l = kkindex(l1,l2,l3,n1,n2,n3); - Aij(k, l) = d*omega2/mu[l] - - +w1*h2*dd[ii][li+1]*db[ii][li+1*(q<3)] //R1 - - +w2u*0.25*h2*( - dd[ii][li+1]*db[ii][li+1*(q<3)]*4. - -dd[ij][lj+1]*(db[ij][lj+1]+db[ij][lj]) - -dd[ik][lk+1]*(db[ik][lk+1]+db[ik][lk]) - ) - +w2u*h2*dd[ii][li+1]*db[ii][li+1*(q<3)] //R2-R4 - - +w3u*h2*0.5*4*dd[ii][li+1]*db[ii][li+1*(q<3)]; //B2-B4 - } - } - - /* 12 nodes */ - for (int q=0; q < 12; q++) { - l1 = i1+ind12[q][0]; - l2 = i2+ind12[q][1]; - l3 = i3+ind12[q][2]; - - ik = ik12[q]; - ii = (ik+1)%3; - ij = (ii+1)%3; - - ll[0] = i1; ll[1] = i2; ll[2] = i3; - li = ll[ii]; lj = ll[ij]; lk = ll[ik]; - - long si = ind12[q][ii] == 1; - long sj = ind12[q][ij] == 1; - - if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { - l = kkindex(l1,l2,l3,n1,n2,n3); - Aij(k, l) = e*omega2/mu[l] - +w2u*h2*0.25*(dd[ii][li+1]*db[ii][li+si]+dd[ij][lj+1]*db[ij][lj+sj]) //R2-R4 0.25*2 - -w3u*h2*0.5*dd[ik][lk+1]*(db[ik][lk]+db[ik][lk+1]); //B1-B4 0.5*2 + for (long i2 = 0; i2 < n2; i2++) + for (long i1 = 0; i1 < n1; i1++) { + l1 = i1; + l2 = i2; + l3 = i3; + k = kkindex(i1, i2, i3, n1, n2, n3); + + lambda = 2 * pi / omega.real( ) * sqrt(mu[k].real( )); + // ppwl = lambda/h; + // int ntab = max(0.,min(343.,(ppwl-3)/(20.15-3)*343 + 0.5)); + + ppwl1 = h / lambda; + int ntab = 0; + while ((ppwl1 > wtab2[8 * ntab]) && (ntab < 398)) ntab++; + if (ntab > 0) + if (abs(ppwl1 - wtab2[8 * ntab]) > abs(ppwl1 - wtab2[8 * (ntab - 1)])) ntab--; + + c = wtab2[8 * ntab + 1]; + d = wtab2[8 * ntab + 2]; + e = wtab2[8 * ntab + 3]; + f = wtab2[8 * ntab + 4]; + w1 = wtab2[8 * ntab + 5]; + w2 = wtab2[8 * ntab + 6]; + w3 = wtab2[8 * ntab + 7]; + + /* + c=0; d=0; e=0; f=0; w1=0; w2=0; w3=0; + for (int j3=-1;j3<=1;j3++) + for (int j2=-1;j2<=1;j2++) + for (int j1=-1;j1<=1;j1++) { + long k3 = max(0L,min(n3-1,i3+j3)); + long k2 = max(0L,min(n2-1,i2+j2)); + long k1 = max(0L,min(n1-1,i1+j1)); + long kk = kkindex(k1,k2,k3,n1,n2,n3); + lambda = 2 * pi / omega.real() * sqrt(mu[kk]); + ppwl = lambda/h; + ntab = max(0.,min(343.,(ppwl-3)/(20.15-3)*343 + 0.5)); + c +=wtab[8*ntab+1]; + d +=wtab[8*ntab+2]; + e +=wtab[8*ntab+3]; + f +=wtab[8*ntab+4]; + w1+=wtab[8*ntab+5]; + w2+=wtab[8*ntab+6]; + w3+=wtab[8*ntab+7]; + } + c/=27; d/=27; e/=27; f/=27; w1/=27; w2/=27; w3/=27; + */ + + /* + // G=4 + c=0.5915900; + d=4.9653493E-02; + e=5.1085097E-03; + f=6.1483691E-03; + w1=8.8075437E-02; + w2=0.8266806; + w3=8.5243940E-02; + */ + /* + // G=4810 + c=0.4966390; + d=7.5123318E-02; + e=4.3846383E-03; + f=6.7614019E-07; + w1=5.0247996E-05; + w2=0.8900359; + w3=0.1099138; + */ + + w2u = w2 / 3.; + w3u = w3 / 4.; + + /* Node 000 */ + l = k; + + Aij(k, l) = c * omega2 / mu[k] - + w1 * h2 * + (dd[1][l2 + 1] * (db[1][l2 + 1] + db[1][l2]) + dd[2][l3 + 1] * (db[2][l3 + 1] + db[2][l3]) + dd[0][l1 + 1] * (db[0][l1 + 1] + db[0][l1]) // (6) + ) // R1 + - w2u * h2 * 2 * + (dd[0][l1 + 1] * (db[0][l1 + 1] + db[0][l1]) + dd[1][l2 + 1] * (db[1][l2 + 1] + db[1][l2]) + dd[2][l3 + 1] * (db[2][l3 + 1] + db[2][l3]) // (0.75*8+6) + ) // R2-R4 + - w3u * h2 * 0.5 * 4 * + (dd[1][l2 + 1] * (db[1][l2 + 1] + db[1][l2]) + dd[2][l3 + 1] * (db[2][l3 + 1] + db[2][l3]) + dd[0][l1 + 1] * (db[0][l1 + 1] + db[0][l1]) // (0.5*24) + ); // B1-B4 + + /* 6 nodes */ + for (int q = 0; q < 6; q++) { + l1 = i1 + ind6[q][0]; + l2 = i2 + ind6[q][1]; + l3 = i3 + ind6[q][2]; + + ii = q % 3; + ij = (ii + 1) % 3; + ik = (ij + 1) % 3; + + ll[0] = i1; + ll[1] = i2; + ll[2] = i3; + li = ll[ii]; + lj = ll[ij]; + lk = ll[ik]; + + if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { + l = kkindex(l1, l2, l3, n1, n2, n3); + Aij(k, l) = d * omega2 / mu[l] + + + w1 * h2 * dd[ii][li + 1] * db[ii][li + 1 * (q < 3)] // R1 + + + w2u * 0.25 * h2 * (dd[ii][li + 1] * db[ii][li + 1 * (q < 3)] * 4. - dd[ij][lj + 1] * (db[ij][lj + 1] + db[ij][lj]) - dd[ik][lk + 1] * (db[ik][lk + 1] + db[ik][lk])) + + w2u * h2 * dd[ii][li + 1] * db[ii][li + 1 * (q < 3)] // R2-R4 + + + w3u * h2 * 0.5 * 4 * dd[ii][li + 1] * db[ii][li + 1 * (q < 3)]; // B2-B4 + } + } + + /* 12 nodes */ + for (int q = 0; q < 12; q++) { + l1 = i1 + ind12[q][0]; + l2 = i2 + ind12[q][1]; + l3 = i3 + ind12[q][2]; + + ik = ik12[q]; + ii = (ik + 1) % 3; + ij = (ii + 1) % 3; + + ll[0] = i1; + ll[1] = i2; + ll[2] = i3; + li = ll[ii]; + lj = ll[ij]; + lk = ll[ik]; + + long si = ind12[q][ii] == 1; + long sj = ind12[q][ij] == 1; + + if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { + l = kkindex(l1, l2, l3, n1, n2, n3); + Aij(k, l) = e * omega2 / mu[l] + w2u * h2 * 0.25 * (dd[ii][li + 1] * db[ii][li + si] + dd[ij][lj + 1] * db[ij][lj + sj]) // R2-R4 0.25*2 + - w3u * h2 * 0.5 * dd[ik][lk + 1] * (db[ik][lk] + db[ik][lk + 1]); // B1-B4 0.5*2 + } + } + + /* 8 nodes */ + for (int q = 0; q < 8; q++) { + l1 = i1 + ind8[q][0]; + l2 = i2 + ind8[q][1]; + l3 = i3 + ind8[q][2]; + if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { + l = kkindex(l1, l2, l3, n1, n2, n3); + Aij(k, l) = f * omega2 / mu[l] + + w3u * h2 * 0.5 * (dd[0][i1 + 1] * db[0][i1 + (ind8[q][0] > 0)] + dd[1][i2 + 1] * db[1][i2 + (ind8[q][1] > 0)] + dd[2][i3 + 1] * db[2][i3 + (ind8[q][2] > 0)]); // B1-B4 + } + } } - } - - /* 8 nodes */ - for (int q=0; q < 8; q++) { - l1 = i1+ind8[q][0]; - l2 = i2+ind8[q][1]; - l3 = i3+ind8[q][2]; - if (l1 >= 0 && l1 < n1 && l2 >= 0 && l2 < n2 && l3 >= 0 && l3 < n3) { - l = kkindex(l1,l2,l3,n1,n2,n3); - Aij(k, l) = f*omega2/mu[l] - +w3u*h2*0.5*(dd[0][i1+1]*db[0][i1+(ind8[q][0] > 0)] - +dd[1][i2+1]*db[1][i2+(ind8[q][1] > 0)] - +dd[2][i3+1]*db[2][i3+(ind8[q][2] > 0)]); //B1-B4 - } - } - } amorse = pAij; } FESpace3 Uh(Th); - MatriceMorse* R = buildInterpolationMatrixT1(Uh, xx, yy, zz); + MatriceMorse< double > *R = buildInterpolationMatrixT1< FESpace3 >(Uh, xx, yy, zz); - //if (mpirank == 0) std::cout << n1*n2*n3 << " " << Th.nv << " " << R->n << " " << R->m << " " << R->nnz << " " << amorse->n << " " << amorse->m << endl; + // if (mpirank == 0) std::cout << n1*n2*n3 << " " << Th.nv << " " << R->n << " " << R->m << " " << R->nnz << " " << amorse->n << " " << amorse->m << endl; - std::vector boundarynodesTh(Th.nv,0); + std::vector< char > boundarynodesTh(Th.nv, 0); - R->COO(); - amorse->CSR(); + R->COO( ); + amorse->CSR( ); unsigned int m = R->nnz; - KN lg(m+1,0); - std::vector tmpVec; + KN< int > lg(m + 1, 0); + std::vector< signed int > tmpVec; tmpVec.resize(amorse->m); - for(long i = 0; i < m; ++i) - tmpVec[R->j[i]] = i + 1; + for (long i = 0; i < m; ++i) tmpVec[R->j[i]] = i + 1; - std::vector> > tmp; + std::vector< std::pair< int, std::complex< double > > > tmp; tmp.reserve(amorse->nnz); lg[0] = 0; - for(long i = 0; i < m; ++i) { - for(long j = amorse->p[R->j[i]]; j < amorse->p[R->j[i] + 1]; ++j) { + for (long i = 0; i < m; ++i) { + for (long j = amorse->p[R->j[i]]; j < amorse->p[R->j[i] + 1]; ++j) { long col = tmpVec[amorse->j[j]]; - if(col != 0) - tmp.push_back(std::make_pair(col - 1, amorse->aij[j])); + if (col != 0) tmp.push_back(std::make_pair(col - 1, amorse->aij[j])); } - std::sort(tmp.begin() + lg[i], tmp.end(),cmp>); - lg[i + 1] = tmp.size(); + std::sort(tmp.begin( ) + lg[i], tmp.end( ), cmp< std::complex< double > >); + lg[i + 1] = tmp.size( ); boundarynodesTh[i] = boundarynodesFD[R->j[i]]; } delete R; - amorse->clear(); - amorse->resize(m,m); - MatriceMorse> &MA = *amorse; + amorse->clear( ); + amorse->resize(m, m); + MatriceMorse< std::complex< double > > &MA = *amorse; MA.half = 0; - for(int i=0; i aij = tmp[k].second; - MA(i,j) = aij; - } + for (int i = 0; i < m; ++i) + for (int k = lg[i]; k < lg[i + 1]; ++k) { + int j = tmp[k].first; + std::complex< double > aij = tmp[k].second; + MA(i, j) = aij; + } MA.SetBC(&boundarynodesTh[0], -1); - return SetAny>>(newpMatrice_Creuse>(stack, &MA)); + return SetAny< newpMatrice_Creuse< std::complex< double > > >(newpMatrice_Creuse< std::complex< double > >(stack, &MA)); } -static void Load_Init( ) { - Global.Add("HelmholtzFD", "(", new HelmholtzFD); -} +static void Load_Init( ) { Global.Add("HelmholtzFD", "(", new HelmholtzFD); } LOADFUNC(Load_Init) diff --git a/plugin/seq/IncompleteCholesky.cpp b/plugin/seq/IncompleteCholesky.cpp index 057effcb9..f44b2da1d 100644 --- a/plugin/seq/IncompleteCholesky.cpp +++ b/plugin/seq/IncompleteCholesky.cpp @@ -54,26 +54,23 @@ typedef void VOID; #undef complex // warning code duplicated from lgmat.cpp -template -MatriceMorse * removeHalf(MatriceMorse & A,long half,double tol) -{ - - // half < 0 => keep U - // half > 0 => keep L - // half = 0 => L and the result will be sym - int nnz =0; - - if( A.half ) - return new MatriceMorse(A);// copy - // do alloc - MatriceMorse *r=new MatriceMorse(A); - r->RemoveHalf(half,tol); - if(verbosity ) - cout << " removeHalf: new nnz = "<< r->nnz << " "<< r->half << endl; - - return r; +template< class R > +MatriceMorse< R > *removeHalf(MatriceMorse< R > &A, long half, double tol) { + + // half < 0 => keep U + // half > 0 => keep L + // half = 0 => L and the result will be sym + int nnz = 0; + + if (A.half) return new MatriceMorse< R >(A); // copy + // do alloc + MatriceMorse< R > *r = new MatriceMorse< R >(A); + r->RemoveHalf(half, tol); + if (verbosity) cout << " removeHalf: new nnz = " << r->nnz << " " << r->half << endl; + + return r; } -template +template< typename R > long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { // cf https://en.wikipedia.org/wiki/Incomplete_Cholesky_factorization cout << " tgv " << tgv << endl; @@ -86,8 +83,7 @@ long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { for (int k = 0; k < L.nnz; ++k) L.aij[k] = nan; int BC = 0; long err = 0; - if(verbosity>9) cout << " ichol: &L, &A " << &L << " " << &A << endl - << " ||L|| " << L.norminfty() << " ||A|| " << A.norminfty() << endl; + if (verbosity > 9) cout << " ichol: &L, &A " << &L << " " << &A << endl << " ||L|| " << L.norminfty( ) << " ||A|| " << A.norminfty( ) << endl; A.CSR( ); L.CSR( ); for (int i = 0; i < n; ++i) { @@ -95,7 +91,7 @@ long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { int li1 = L.p[i + 1] - 1; int li0 = L.p[i]; R Aii = A.aij[ai1]; - if (abs(Aii) > tgve) { // B.C + if (abs(Aii) > tgve) { // B.C for (kk = li0; kk < li1; kk++) L.aij[kk] = 0; // remove row and col L.aij[li1] = 1; BC++; @@ -108,12 +104,12 @@ long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { int lj0 = L.p[j]; R *pAij = A.pij(i, j); - R Lij = pAij ? *pAij : R(), Aij = Lij; + R Lij = pAij ? *pAij : R( ), Aij = Lij; for (int kkk = lj0; kkk < lj1; ++kkk) // loop row j { int k = L.j[kkk]; ffassert(k >= 0 && k < j); - R Ljk = L.aij[kkk], *pLik = L.pij(i, k), Lik = pLik ? *pLik : R(); + R Ljk = L.aij[kkk], *pLik = L.pij(i, k), Lik = pLik ? *pLik : R( ); Lij -= Lik * Ljk; } Lij /= L(j, j); @@ -121,8 +117,7 @@ long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { } for (int k = li0; k < li1; ++k) Aii -= L.aij[k] * L.aij[k]; if (abs(Aii) <= 1e-30) { - if (err < 10 && verbosity) - cout << " ichol neg pivot:" << i << " " << Aii << " " << A.aij[ai1] << endl; + if (err < 10 && verbosity) cout << " ichol neg pivot:" << i << " " << Aii << " " << A.aij[ai1] << endl; Aii = 1; // Bof Bof !!! err++; } @@ -130,11 +125,11 @@ long ichol(MatriceMorse< R > &A, MatriceMorse< R > &L, double tgv) { L.aij[li1] = Lii; } } - if (verbosity > 2) cout << " -- ichol: N BC = " << BC << " nberr " << err << " A.half " << A.half << " ||L|| " << L.norminfty() << " ||A|| " << A.norminfty() << endl; + if (verbosity > 2) cout << " -- ichol: N BC = " << BC << " nberr " << err << " A.half " << A.half << " ||L|| " << L.norminfty( ) << " ||A|| " << A.norminfty( ) << endl; return err; } -template +template< typename R > inline R pscal(R *L, int *cl, int kl, int kl1, int i, MatriceMorse< R > &Ut, int j) { int k = min(i, j); // common part R r = 0; @@ -152,16 +147,20 @@ inline R pscal(R *L, int *cl, int kl, int kl1, int i, MatriceMorse< R > &Ut, int return r; } -template -double Real(R a){return a;} +template< typename R > +double Real(R a) { + return a; +} template<> -double Real(complex< double > a){return a.real();} +double Real(complex< double > a) { + return a.real( ); +} -template +template< typename R > long iLU(MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMorse< R > &Ut, double tgv) { A.CSR( ); L.CSR( ); - Ut.dotranspose( 0 ); + Ut.dotranspose(0); Ut.CSR( ); if (verbosity > 4) cout << " - ILU fact: tgv " << tgv << endl; ffassert(A.n == L.n); @@ -226,9 +225,8 @@ long iLU(MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMorse< R > &Ut, doub Ut(i, i) = Uii; } } - if (verbosity > 2 || err) - cout << " - ILU: Nb BC = " << BC << "nb err =" << err << " main Uii " << mUii << endl; - Ut.dotranspose( 0);// warning do conj by default (0=> no conj) + if (verbosity > 2 || err) cout << " - ILU: Nb BC = " << BC << "nb err =" << err << " main Uii " << mUii << endl; + Ut.dotranspose(0); // warning do conj by default (0=> no conj) Ut.CSC( ); L.CSR( ); return err; @@ -264,8 +262,7 @@ double *MatVect(int n, double *a, double *x, double *y) { // F. Hecht try to make block ILU preconditinneur // the matrix U must have the full diagonal bloc // Store Diag bloc of inv Diag block ???? -long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMorse< R > &Ut, - double tgv) { +long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMorse< R > &Ut, double tgv) { /* Algo LU block : L = L + I, U = U+D @@ -281,8 +278,8 @@ long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMor A.CSR( ); L.CSR( ); - Ut.dotranspose( 0);// no conj .. - + Ut.dotranspose(0); // no conj .. + Ut.CSR( ); if (verbosity > 4) cout << " - ILU fact: tgv " << tgv << endl; ffassert(A.n == L.n); @@ -316,8 +313,7 @@ long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMor pD1[nb] = lD1; KN< double > DD1(ld1), DD(ld1), Lb(nbi), Ub(nbi); // to store the inverse of Diag block KN< double > Aii(nbix * nbix); // to store the bigest block - KN< int > ai1(nbix), ai0(nbix), li1(nbix), ui1(nbix), - ui0(nbix) : for (int ib = 0; ib < nb; ++ib) { + KN< int > ai1(nbix), ai0(nbix), li1(nbix), ui1(nbix), ui0(nbix) : for (int ib = 0; ib < nb; ++ib) { int i0 = b[i0], i1 = b[ib + 1], nbi = i1 - n0, ; for (int i = i0; i < i1; ++i) { @@ -352,10 +348,9 @@ long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMor int jl = j - ib[ij]; // offset dans le bloc R *pAij = A.pij(i, j), Aij = pAij ? *pAij : 0.; Lb[jl] = (Aij - pscal(L.aij, L.j, li0[il], li1[il], i, Ut, j)); // * D1(; - if (jb == bn[jnext]) // last term of the bloc because next is not same + if (jb == bn[jnext]) // last term of the bloc because next is not same { - int fb = ib[jb + 1] - ib[jb] - - 1 MatVect(fd, &D1[pD1[jb]], &Lb[0], y) for (int jl = 0; jl < fb; ++jl) { + int fb = ib[jb + 1] - ib[jb] - 1 MatVect(fd, &D1[pD1[jb]], &Lb[0], y) for (int jl = 0; jl < fb; ++jl) { int j = ib[jb] + jl; R *p = L.pij(i, j); if (p) *p = y[jl]; @@ -404,36 +399,30 @@ long iLUB(int nb, int *b, MatriceMorse< R > &A, MatriceMorse< R > &L, MatriceMor Ut(i, i) = Uii; } - if (verbosity > 2 || err) - cout << " - ILU: Nb BC = " << BC << "nb err =" << err << " main Uii " << mUii << endl; - Ut.dotranspose(0 );// no conj + if (verbosity > 2 || err) cout << " - ILU: Nb BC = " << BC << "nb err =" << err << " main Uii " << mUii << endl; + Ut.dotranspose(0); // no conj Ut.CSC( ); L.CSR( ); return err; } #endif -template -long ff_ilu(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, - Matrice_Creuse< R > *const &pcU, double const &tgv) { +template< typename R > +long ff_ilu(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, Matrice_Creuse< R > *const &pcU, double const &tgv) { MatriceCreuse< R > *pa = pcA->A; MatriceCreuse< R > *pl = pcL->A; MatriceCreuse< R > *pu = pcU->A; - if(pl==0) - { - MatriceMorse *pma= dynamic_cast* > (pa); - MatriceCreuse * pr= removeHalf(*pma,1,-1.);// L - pcL->A.master(pr); - pl = pcL->A; - - } - if(pu==0) - { - MatriceMorse *pma= dynamic_cast* > (pa); - MatriceCreuse * pr= removeHalf(*pma,-1,-1.);// L - pcU->A.master(pr); - pu = pcU->A; - - } + if (pl == 0) { + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + MatriceCreuse< R > *pr = removeHalf(*pma, 1, -1.); // L + pcL->A.master(pr); + pl = pcL->A; + } + if (pu == 0) { + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + MatriceCreuse< R > *pr = removeHalf(*pma, -1, -1.); // L + pcU->A.master(pr); + pu = pcU->A; + } ffassert(pa && pl && pu); MatriceMorse< R > *pA = dynamic_cast< MatriceMorse< R > * >(pa); @@ -443,37 +432,34 @@ long ff_ilu(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, return iLU(*pA, *pL, *pU, tgv); } -template +template< typename R > long ff_ichol(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, double const &tgv) { MatriceCreuse< R > *pa = pcA->A; MatriceCreuse< R > *pl = pcL->A; - if(verbosity>9 ) cout << "ff_ichol " << pa << " " << pl << endl; - - if(pl==0) - { - MatriceMorse *pma= dynamic_cast* > (pa); - MatriceCreuse * pr= removeHalf(*pma,1,-1.);// L - pcL->A.master(pr); - pl = pcL->A; + if (verbosity > 9) cout << "ff_ichol " << pa << " " << pl << endl; + if (pl == 0) { + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + MatriceCreuse< R > *pr = removeHalf(*pma, 1, -1.); // L + pcL->A.master(pr); + pl = pcL->A; } ffassert(pa && pl); MatriceMorse< R > *pA = dynamic_cast< MatriceMorse< R > * >(pa); MatriceMorse< R > *pL = dynamic_cast< MatriceMorse< R > * >(pl); ffassert(pL && pA); - if(verbosity>9 ) cout << "ff_ichol " << pA << " " << pL << endl; + if (verbosity > 9) cout << "ff_ichol " << pA << " " << pL << endl; return ichol(*pA, *pL, tgv); } -template -long ff_ilu(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, - Matrice_Creuse< R > *const &pcU) { +template< typename R > +long ff_ilu(Matrice_Creuse< R > *const &pcA, Matrice_Creuse< R > *const &pcL, Matrice_Creuse< R > *const &pcU) { return ff_ilu(pcA, pcL, pcU, ff_tgv); } -template +template< typename R > long ff_ichol(Matrice_Creuse< R > *pcA, Matrice_Creuse< R > *pcL) { return ff_ichol(pcA, pcL, ff_tgv); } -template +template< typename R > void LU_solve(MatriceMorse< R > &T, int cas, KN< R > &b, bool trans) { int n = T.n, i, j, k, k1, k0; if (cas < 0) @@ -512,7 +498,7 @@ void LU_solve(MatriceMorse< R > &T, int cas, KN< R > &b, bool trans) { } } } -template +template< typename R > bool ff_ichol_solve(Matrice_Creuse< R > *pcL, KN< R > *b) { MatriceCreuse< R > *pl = pcL->A; ffassert(pl); @@ -523,9 +509,8 @@ bool ff_ichol_solve(Matrice_Creuse< R > *pcL, KN< R > *b) { return true; } -template -bool ff_ilu_solve(Matrice_Creuse< R > *const &pcL, Matrice_Creuse< R > *const &pcU, - KN< R > *const &b) { +template< typename R > +bool ff_ilu_solve(Matrice_Creuse< R > *const &pcL, Matrice_Creuse< R > *const &pcU, KN< R > *const &b) { MatriceCreuse< R > *pl = pcL->A; ffassert(pl); MatriceMorse< R > *pL = dynamic_cast< MatriceMorse< R > * >(pl); @@ -542,43 +527,19 @@ bool ff_ilu_solve(Matrice_Creuse< R > *const &pcL, Matrice_Creuse< R > *const &p static void Load_Init( ) { cout << " load: init Incomplete Cholesky " << endl; - Global.Add("ichol", "(", - new OneOperator2< long, Matrice_Creuse< R > *, Matrice_Creuse< R > * >(ff_ichol)); - Global.Add( - "ichol", "(", - new OneOperator3_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, double >(ff_ichol)); - Global.Add("iLU", "(", - new OneOperator4_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, - Matrice_Creuse< R > *, double >(ff_ilu)); - Global.Add( - "iLU", "(", - new OneOperator3_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse< R > * >( - ff_ilu)); - Global.Add("iluSolve", "(", - new OneOperator3_< bool, Matrice_Creuse< R > *, Matrice_Creuse< R > *, KN< R > * >( - ff_ilu_solve)); - Global.Add("icholSolve", "(", - new OneOperator2< bool, Matrice_Creuse< R > *, KN< R > * >(ff_ichol_solve)); - typedef Complex C; - Global.Add("ichol", "(", - new OneOperator2< long, Matrice_Creuse< C > *, Matrice_Creuse< C > * >(ff_ichol)); - Global.Add( - "ichol", "(", - new OneOperator3_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, double >(ff_ichol)); - Global.Add("iLU", "(", - new OneOperator4_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, - Matrice_Creuse< C > *, double >(ff_ilu)); - Global.Add( - "iLU", "(", - new OneOperator3_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, Matrice_Creuse< C > * >( - ff_ilu)); - Global.Add("iluSolve", "(", - new OneOperator3_< bool, Matrice_Creuse< C > *, Matrice_Creuse< C > *, KN< C > * >( - ff_ilu_solve)); - Global.Add("icholSolve", "(", - new OneOperator2< bool, Matrice_Creuse< C > *, KN< C > * >(ff_ichol_solve)); - - + Global.Add("ichol", "(", new OneOperator2< long, Matrice_Creuse< R > *, Matrice_Creuse< R > * >(ff_ichol)); + Global.Add("ichol", "(", new OneOperator3_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, double >(ff_ichol)); + Global.Add("iLU", "(", new OneOperator4_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse< R > *, double >(ff_ilu)); + Global.Add("iLU", "(", new OneOperator3_< long, Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse< R > * >(ff_ilu)); + Global.Add("iluSolve", "(", new OneOperator3_< bool, Matrice_Creuse< R > *, Matrice_Creuse< R > *, KN< R > * >(ff_ilu_solve)); + Global.Add("icholSolve", "(", new OneOperator2< bool, Matrice_Creuse< R > *, KN< R > * >(ff_ichol_solve)); + typedef Complex C; + Global.Add("ichol", "(", new OneOperator2< long, Matrice_Creuse< C > *, Matrice_Creuse< C > * >(ff_ichol)); + Global.Add("ichol", "(", new OneOperator3_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, double >(ff_ichol)); + Global.Add("iLU", "(", new OneOperator4_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, Matrice_Creuse< C > *, double >(ff_ilu)); + Global.Add("iLU", "(", new OneOperator3_< long, Matrice_Creuse< C > *, Matrice_Creuse< C > *, Matrice_Creuse< C > * >(ff_ilu)); + Global.Add("iluSolve", "(", new OneOperator3_< bool, Matrice_Creuse< C > *, Matrice_Creuse< C > *, KN< C > * >(ff_ilu_solve)); + Global.Add("icholSolve", "(", new OneOperator2< bool, Matrice_Creuse< C > *, KN< C > * >(ff_ichol_solve)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/LayerMesh.cpp b/plugin/seq/LayerMesh.cpp index 5cdb077cb..6cfb7aaba 100644 --- a/plugin/seq/LayerMesh.cpp +++ b/plugin/seq/LayerMesh.cpp @@ -119,8 +119,7 @@ void discretisation_max_mesh(const int choix, const Mesh &Th2, int &Nmax) { } } -void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, - double *tab_zmax, int *tab_Ni) { +void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, double *tab_zmax, int *tab_Ni) { Nmax = 0; for (int ii = 0; ii < Th2.nv; ii++) { @@ -175,8 +174,7 @@ void build_layer_map_tetrahedra(const Mesh &Th2, map< int, int > &maptet) { cout << "number of tetraedra label=" << numero_label << endl; } -void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, - map< int, int > &maptrizmax, map< int, int > &maptrizmin) { +void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, map< int, int > &maptrizmax, map< int, int > &maptrizmin) { int numero_label = 0; for (int ii = 0; ii < Th2.nt; ii++) { @@ -225,8 +223,7 @@ void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, cout << "number of triangle label =" << numero_label << endl; } -void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, - map< int, int > &mapezmin) { +void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, map< int, int > &mapezmin) { int numero_label = 0; for (int ii = 0; ii < Th2.neb; ii++) { @@ -252,11 +249,8 @@ void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, i } } -Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, - const double *tab_zmax, const map< int, int > &maptet, - const map< int, int > &maptrimil, const map< int, int > &maptrizmax, - const map< int, int > &maptrizmin, const map< int, int > &mapemil, - const map< int, int > &mapezmax, const map< int, int > &mapezmin) { +Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const map< int, int > &maptet, const map< int, int > &maptrimil, + const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin) { int MajSom, MajElem, MajBord2D; Mesh3 *Th3 = new Mesh3; @@ -271,15 +265,11 @@ Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const dou cout << "debut : Som3D_mesh_product_Version_Sommet_mesh_tab( Nmax, tab_Ni, tab_zmin, tab_zmax, " "Th2, Th3); " << endl; - Som3D_mesh_product_Version_Sommet_mesh_tab(Nmax, tab_Ni, tab_zmin, tab_zmax, Th2, maptet, - maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, - mapezmin, *Th3); + Som3D_mesh_product_Version_Sommet_mesh_tab(Nmax, tab_Ni, tab_zmin, tab_zmax, Th2, maptet, maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, mapezmin, *Th3); return Th3; } -void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, - const Mesh &Th2, int &MajSom, int &MajElem, - int &MajBord2D) { +void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, const Mesh &Th2, int &MajSom, int &MajElem, int &MajBord2D) { int i; MajSom = 0; @@ -314,12 +304,9 @@ void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int * } } -void Som3D_mesh_product_Version_Sommet_mesh_tab( - const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, - const Mesh &Th2, const map< int, int > &maptet, const map< int, int > &maptrimil, - const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, - const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin, - Mesh3 &Th3) { +void Som3D_mesh_product_Version_Sommet_mesh_tab(const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const Mesh &Th2, const map< int, int > &maptet, + const map< int, int > &maptrimil, const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, + const map< int, int > &mapezmax, const map< int, int > &mapezmin, Mesh3 &Th3) { int NumSommet; int NumElement; @@ -989,8 +976,7 @@ void dpent1_mesh(int idl[3], int nu[12], int &nbe, int &option) { for (i2 = 1; i2 <= 2; i2++) { for (i1 = 1; i1 <= 2; i1++) { idf = idf + 1; - if ((pdd[idf] != 0) && (idl[0] == 0 || idl[0] == i1) && (idl[1] == 0 || idl[1] == i2) && - (idl[2] == 0 || idl[2] == i3)) { + if ((pdd[idf] != 0) && (idl[0] == 0 || idl[0] == i1) && (idl[1] == 0 || idl[1] == i2) && (idl[2] == 0 || idl[2] == i3)) { // nbdp=nbdp+1; idp[nbdp] = idf; nbdp = nbdp + 1; diff --git a/plugin/seq/LayerMesh.hpp b/plugin/seq/LayerMesh.hpp index 6254147dc..2f57f15ff 100644 --- a/plugin/seq/LayerMesh.hpp +++ b/plugin/seq/LayerMesh.hpp @@ -33,36 +33,23 @@ double zmin_func_mesh(const int choix, const double x, const double y); double zmax_func_mesh(const int choix, const double x, const double y); int Ni_func_mesh(const int choix, const double x, const double y); -void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, - double *tab_zmax, int *tab_Ni); +void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, double *tab_zmax, int *tab_Ni); void Tet_mesh3_mes_neg(Mesh3 &Th3); void build_layer_map_tetrahedra(const Mesh &Th2, map< int, int > &maptet); -void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, - map< int, int > &maptrizmax, map< int, int > &maptrizmin); -void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, - map< int, int > &mapezmin); +void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, map< int, int > &maptrizmax, map< int, int > &maptrizmin); +void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, map< int, int > &mapezmin); -void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, - const Mesh &Th, int &MajSom, int &MajElem, - int &MajBord2D); +void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, const Mesh &Th, int &MajSom, int &MajElem, int &MajBord2D); -void Som3D_mesh_product_Version_Sommet_mesh_tab( - const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, - const Mesh &Th2, const map< int, int > &maptet, const map< int, int > &maptrimil, - const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, - const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin, - Mesh3 &Th3); +void Som3D_mesh_product_Version_Sommet_mesh_tab(const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const Mesh &Th2, const map< int, int > &maptet, + const map< int, int > &maptrimil, const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, + const map< int, int > &mapezmax, const map< int, int > &mapezmin, Mesh3 &Th3); -void transformation_2D_3D_maillage_mesh_tab(const Mesh &Th2, const int Nmax, const int *tab_Ni, - const double *tab_zmin, const double *tab_zmax, - Mesh3 &Th3); +void transformation_2D_3D_maillage_mesh_tab(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, Mesh3 &Th3); -Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, - const double *tab_zmax, const map< int, int > &maptet, - const map< int, int > &maptrimil, const map< int, int > &maptrizmax, - const map< int, int > &maptrizmin, const map< int, int > &mapemil, - const map< int, int > &mapezmax, const map< int, int > &mapezmin); +Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const map< int, int > &maptet, const map< int, int > &maptrimil, + const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin); #endif diff --git a/plugin/seq/MUMPS.cpp b/plugin/seq/MUMPS.cpp index 1dce8c572..8b9f82296 100644 --- a/plugin/seq/MUMPS.cpp +++ b/plugin/seq/MUMPS.cpp @@ -96,14 +96,13 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { double &RINFOG(int i) const { return id.rinfog[i - 1]; } void SetVerb( ) const { - ICNTL(1) = 6; // output stream for error messages. - ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. - ICNTL(3) = 6; // output stream global information, collected on the host. + ICNTL(1) = 6; // output stream for error messages. + ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. + ICNTL(3) = 6; // output stream global information, collected on the host. ICNTL(4) = min(max(verb - 2, 1L), 4L); // the level of printing for error, warning, and diag if (verb == 0) ICNTL(4) = 0; - ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). - if (id.job == JOB_SOLVE && - verb > 99) { // computes statistics related to an error analysis of the linear system + ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). + if (id.job == JOB_SOLVE && verb > 99) { // computes statistics related to an error analysis of the linear system if (verb > 999) ICNTL(11) = 1; // All Stat (veryexpensive) else @@ -185,9 +184,7 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { } } } - SolveMUMPS_seq(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) - : A(AA), verb(ds.verb), eps(ds.epsilon), epsr(0), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), - infog(ds.info) { + SolveMUMPS_seq(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) : A(AA), verb(ds.verb), eps(ds.epsilon), epsr(0), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), infog(ds.info) { int myid = 0; @@ -219,26 +216,23 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { void dosolver(K *x, K *b, int N, int trans) { if (verbosity > 1) { - cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n - << " sym =" << id.sym << " trans = " << trans << endl; + cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n << " sym =" << id.sym << " trans = " << trans << endl; } ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase id.nrhs = N; id.lrhs = id.n; - myscopy(N*id.n, b, x); + myscopy(N * id.n, b, x); - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < N*id.n; ++k) - x[k] = RNM::conj(x[k]); + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < N * id.n; ++k) x[k] = RNM::conj(x[k]); id.rhs = (MR *)(void *)(R *)x; id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. SetVerb( ); mumps_c(&id); - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < N*id.n; ++k) - x[k] = RNM::conj(x[k]); + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < N * id.n; ++k) x[k] = RNM::conj(x[k]); Check("MUMPS_seq dosolver"); @@ -297,8 +291,10 @@ struct InitEnd { static InitEnd global; // To init SEQ MPI ???? // 1 unsym , 2 herm, 4 sym, 8 pos , 16 nopos, 32 seq, 64 ompi, 128 mpi -template<> const int SolveMUMPS_seq::orTypeSol = 1|2|4|8|16|32; -template<> const int SolveMUMPS_seq>::orTypeSol = 1|4|8|16|32; +template<> +const int SolveMUMPS_seq< double >::orTypeSol = 1 | 2 | 4 | 8 | 16 | 32; +template<> +const int SolveMUMPS_seq< std::complex< double > >::orTypeSol = 1 | 4 | 8 | 16 | 32; static void Load_Init( ) { addsolver< SolveMUMPS_seq< double > >("MUMPS", 50, 1); diff --git a/plugin/seq/MUMPS_seq.cpp b/plugin/seq/MUMPS_seq.cpp index 1dce8c572..8b9f82296 100644 --- a/plugin/seq/MUMPS_seq.cpp +++ b/plugin/seq/MUMPS_seq.cpp @@ -96,14 +96,13 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { double &RINFOG(int i) const { return id.rinfog[i - 1]; } void SetVerb( ) const { - ICNTL(1) = 6; // output stream for error messages. - ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. - ICNTL(3) = 6; // output stream global information, collected on the host. + ICNTL(1) = 6; // output stream for error messages. + ICNTL(2) = 6; // stream for diagnostic printing, statistics, and warning messages. + ICNTL(3) = 6; // output stream global information, collected on the host. ICNTL(4) = min(max(verb - 2, 1L), 4L); // the level of printing for error, warning, and diag if (verb == 0) ICNTL(4) = 0; - ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). - if (id.job == JOB_SOLVE && - verb > 99) { // computes statistics related to an error analysis of the linear system + ICNTL(11) = 0; // noerroranalysisisperformed(nostatistics). + if (id.job == JOB_SOLVE && verb > 99) { // computes statistics related to an error analysis of the linear system if (verb > 999) ICNTL(11) = 1; // All Stat (veryexpensive) else @@ -185,9 +184,7 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { } } } - SolveMUMPS_seq(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) - : A(AA), verb(ds.verb), eps(ds.epsilon), epsr(0), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), - infog(ds.info) { + SolveMUMPS_seq(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) : A(AA), verb(ds.verb), eps(ds.epsilon), epsr(0), tgv(ds.tgv), cn(0), cs(0), rinfog(ds.rinfo), infog(ds.info) { int myid = 0; @@ -219,26 +216,23 @@ class SolveMUMPS_seq : public VirtualSolver< int, R > { void dosolver(K *x, K *b, int N, int trans) { if (verbosity > 1) { - cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n - << " sym =" << id.sym << " trans = " << trans << endl; + cout << " -- MUMPS solve, peak Mem : " << INFOG(22) << " Mb, n = " << id.n << " sym =" << id.sym << " trans = " << trans << endl; } ICNTL(9) = trans == 0; // 1: A x = b, !1 : tA x = b during slove phase id.nrhs = N; id.lrhs = id.n; - myscopy(N*id.n, b, x); + myscopy(N * id.n, b, x); - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < N*id.n; ++k) - x[k] = RNM::conj(x[k]); + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < N * id.n; ++k) x[k] = RNM::conj(x[k]); id.rhs = (MR *)(void *)(R *)x; id.job = JOB_SOLVE; // performs the analysis. and performs the factorization. SetVerb( ); mumps_c(&id); - if (trans && is_same::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x - for (int k = 0; k < N*id.n; ++k) - x[k] = RNM::conj(x[k]); + if (trans && is_same< R, Complex >::value) // for tA x = b MUMPS does not conjugate, so we conjugate b and x + for (int k = 0; k < N * id.n; ++k) x[k] = RNM::conj(x[k]); Check("MUMPS_seq dosolver"); @@ -297,8 +291,10 @@ struct InitEnd { static InitEnd global; // To init SEQ MPI ???? // 1 unsym , 2 herm, 4 sym, 8 pos , 16 nopos, 32 seq, 64 ompi, 128 mpi -template<> const int SolveMUMPS_seq::orTypeSol = 1|2|4|8|16|32; -template<> const int SolveMUMPS_seq>::orTypeSol = 1|4|8|16|32; +template<> +const int SolveMUMPS_seq< double >::orTypeSol = 1 | 2 | 4 | 8 | 16 | 32; +template<> +const int SolveMUMPS_seq< std::complex< double > >::orTypeSol = 1 | 4 | 8 | 16 | 32; static void Load_Init( ) { addsolver< SolveMUMPS_seq< double > >("MUMPS", 50, 1); diff --git a/plugin/seq/MatD-VFP0.cpp b/plugin/seq/MatD-VFP0.cpp index 25d1fde4a..d1de387c7 100644 --- a/plugin/seq/MatD-VFP0.cpp +++ b/plugin/seq/MatD-VFP0.cpp @@ -24,438 +24,394 @@ // E-MAIL : ... // *INDENT-OFF* // +/* clang-format off */ //ff-c++-LIBRARY-dep: //ff-c++-cpp-dep: +/* clang-format on */ // *INDENT-ON* // #include "ff++.hpp" #include "AFunction_ext.hpp" typedef const Fem2D::Mesh *pMesh; -namespace Fem2D { -// code Georges Sadaka -typedef double R; +namespace Fem2D { + // code Georges Sadaka + typedef double R; -class LeastSq2 { -public: - R2 l1x,l1y; + class LeastSq2 { + public: + R2 l1x, l1y; R w2[3]; int order; -}; + }; -void ComputeCoefs (const Mesh &Th,KN &geom,long order) -{ + void ComputeCoefs(const Mesh &Th, KN< LeastSq2 > &geom, long order) { // order : 1 => order 1 // order : 2 => order 2 // order : 3= 1|3 => order 1 if one point on boundary, order 2 other R d1, d2, d3; R w1, w2, w3, sum; - R2 GH(1./3.,1/3.); + R2 GH(1. / 3., 1 / 3.); R2 Pi[3]; - R w[3],di[3]; - int no1=0,no2=0,no3=0; + R w[3], di[3]; + int no1 = 0, no2 = 0, no3 = 0; // search vexter on true boundaty - KN vb(Th.nv,0); - for (int k=0; k vb(Th.nv, 0); + for (int k = 0; k < Th.nt; k++) + for (int e = 0; e < 3; ++e) { // search of the edge on the bdy - int ee=e,ke=Th.ElementAdj(k,ee); - if(ke==k || ke<0) {// - vb[Th(k,(e+1)%3)]=1; - vb[Th(k,(e+2)%3)]=1; + int ee = e, ke = Th.ElementAdj(k, ee); + if (ke == k || ke < 0) { // + vb[Th(k, (e + 1) % 3)] = 1; + vb[Th(k, (e + 2) % 3)] = 1; } - } - for (int k=0; k2) &&!nvonb); - if(edgeonbdy>=2 || abs(sum) < 1e-100){no3++;oo2=2;} // Bof Bof .... Voir G. Sadaka ... - if(oo2) - { // order 2 - no2++; - R2 P1= K[0]-G, P2=K[1]-G, P3= K[2]-G; - d1 = P1.norme(); - d2 = P2.norme(); - d3 = P3.norme(); - sum = 1.0/d1 + 1.0/d2 + 1.0/d3; - w1 = 1.0/(d1*sum); - w2 = 1.0/(d2*sum); - w3 = 1.0/(d3*sum); - R l11 = w1*P1.x*w1*P1.x + w2*P2.x*w2*P2.x + w3*P3.x*w3*P3.x; - R l12 = w1*P1.x*w1*P1.y + w2*P2.x*w2*P2.y + w3*P3.x*w3*P3.y; - R l21 = l12; - R l22 = w1*P1.y*w1*P1.y + w2*P2.y*w2*P2.y + w3*P3.y*w3*P3.y; - R det = l11*l22 - l12*l21; - geom[k].w2[0] = w1*w1; - geom[k].w2[1] = w2*w2; - geom[k].w2[2] = w3*w3; - geom[k].l1x =R2(l22/det,-l12/det); - geom[k].l1y =R2(-l21/det,l11/det); - geom[k].order = 2; - } - else - {// order 1 - no1 ++; - assert(edgeonbdy<2 &&sum > 1e-100); - w[0] = di[0]/sum; - w[1] = di[1]/sum; - w[2] = di[2]/sum; - if(verbosity>99 &&!mpirank) - cout << k << " **" << sum << " " << di[0] << " " << di[1] << " " << di[2] - << " :: " << Pi[0] << " " << Pi[1]<< " " << Pi[2] << " // " - << w[0] << " " << w[1] << " " << w[2]<< endl; - - // K : X_1 is the coordinate of the 3 vertex of the triangle k - - R2 WP[3]={ w[0]*Pi[0], w[1]*Pi[1], w[2]*Pi[2]}; - // f = u_ke - u_k - // L = w .*Pi => L1 = L.x , L2 = L.y, L 2x3 - // F = w.*f - // L g = F => L'L = LF ; LF = Pi .*w^2 f - - R l11 = WP[0].x*WP[0].x + WP[1].x*WP[1].x + WP[2].x*WP[2].x; - R l12 = WP[0].x*WP[0].y + WP[1].x*WP[1].y + WP[2].x*WP[2].y; - R l22 = WP[0].y*WP[0].y + WP[1].y*WP[1].y + WP[2].y*WP[2].y; - - R det = l11*l22 - l12*l12; - geom[k].w2[0] = w[0]*w[0]; - geom[k].w2[1] = w[1]*w[1]; - geom[k].w2[2] = w[2]*w[2]; - geom[k].l1x =R2(l22/det,-l12/det); - geom[k].l1y =R2(-l12/det,l11/det); - geom[k].order = 1; - if(verbosity>99 &&!mpirank) - cout << k << " : "< 2) && !nvonb); + if (edgeonbdy >= 2 || abs(sum) < 1e-100) { + no3++; + oo2 = 2; + } // Bof Bof .... Voir G. Sadaka ... + if (oo2) { // order 2 + no2++; + R2 P1 = K[0] - G, P2 = K[1] - G, P3 = K[2] - G; + d1 = P1.norme( ); + d2 = P2.norme( ); + d3 = P3.norme( ); + sum = 1.0 / d1 + 1.0 / d2 + 1.0 / d3; + w1 = 1.0 / (d1 * sum); + w2 = 1.0 / (d2 * sum); + w3 = 1.0 / (d3 * sum); + R l11 = w1 * P1.x * w1 * P1.x + w2 * P2.x * w2 * P2.x + w3 * P3.x * w3 * P3.x; + R l12 = w1 * P1.x * w1 * P1.y + w2 * P2.x * w2 * P2.y + w3 * P3.x * w3 * P3.y; + R l21 = l12; + R l22 = w1 * P1.y * w1 * P1.y + w2 * P2.y * w2 * P2.y + w3 * P3.y * w3 * P3.y; + R det = l11 * l22 - l12 * l21; + geom[k].w2[0] = w1 * w1; + geom[k].w2[1] = w2 * w2; + geom[k].w2[2] = w3 * w3; + geom[k].l1x = R2(l22 / det, -l12 / det); + geom[k].l1y = R2(-l21 / det, l11 / det); + geom[k].order = 2; + } else { // order 1 + no1++; + assert(edgeonbdy < 2 && sum > 1e-100); + w[0] = di[0] / sum; + w[1] = di[1] / sum; + w[2] = di[2] / sum; + if (verbosity > 99 && !mpirank) + cout << k << " **" << sum << " " << di[0] << " " << di[1] << " " << di[2] << " :: " << Pi[0] << " " << Pi[1] << " " << Pi[2] << " // " << w[0] << " " << w[1] << " " << w[2] << endl; + + // K : X_1 is the coordinate of the 3 vertex of the triangle k + + R2 WP[3] = {w[0] * Pi[0], w[1] * Pi[1], w[2] * Pi[2]}; + // f = u_ke - u_k + // L = w .*Pi => L1 = L.x , L2 = L.y, L 2x3 + // F = w.*f + // L g = F => L'L = LF ; LF = Pi .*w^2 f + + R l11 = WP[0].x * WP[0].x + WP[1].x * WP[1].x + WP[2].x * WP[2].x; + R l12 = WP[0].x * WP[0].y + WP[1].x * WP[1].y + WP[2].x * WP[2].y; + R l22 = WP[0].y * WP[0].y + WP[1].y * WP[1].y + WP[2].y * WP[2].y; + + R det = l11 * l22 - l12 * l12; + geom[k].w2[0] = w[0] * w[0]; + geom[k].w2[1] = w[1] * w[1]; + geom[k].w2[2] = w[2] * w[2]; + geom[k].l1x = R2(l22 / det, -l12 / det); + geom[k].l1y = R2(-l12 / det, l11 / det); + geom[k].order = 1; + if (verbosity > 99 && !mpirank) cout << k << " : " << det << " " << geom[k].l1x << " ; " << geom[k].l1y << " : " << geom[k].w2[0] << " " << geom[k].w2[1] << " " << geom[k].w2[2] << endl; + } } - if(verbosity>1&&!mpirank) cout << "ComputeCoefs:: nb Triangle order1 :"<< no1 << " , order2 : "<< no2 << endl; - if(verbosity &&no3 ) - cout <<" on mpirank: " << mpirank << " ComputeCoefs:: WARNING put order 2: due to 2 edge border !!! number of case: " << no3 << endl; -} + if (verbosity > 1 && !mpirank) cout << "ComputeCoefs:: nb Triangle order1 :" << no1 << " , order2 : " << no2 << endl; + if (verbosity && no3) cout << " on mpirank: " << mpirank << " ComputeCoefs:: WARNING put order 2: due to 2 edge border !!! number of case: " << no3 << endl; + } -MatriceMorse *MatVFM01 (const Mesh *pTh ) -{ + MatriceMorse< R > *MatVFM01(const Mesh *pTh) { // U0 entre P0 // u1 sortie P1 // u1 = A *u0 ffassert(pTh); - const Mesh &Th=*pTh; - MatriceMorse &A = *new MatriceMorse(Th.nv,Th.nt,0,0); - vector > lst(Th.nv); - vector > w(Th.nv); - for(int k=0; k &A = *new MatriceMorse< R >(Th.nv, Th.nt, 0, 0); + vector< vector< int > > lst(Th.nv); + vector< vector< double > > w(Th.nv); + for (int k = 0; k < Th.nt; ++k) + for (int j = 0; j < 3; ++j) lst[Th(k, j)].push_back(k); R2 barycenter; static const double EPS = 1.e-10; int degr; R ww; R Ixx, Iyy, Ixy, ri2; R lambda, mu; - double *sumW=new double[Th.nv]; - R2 GH(1./3.,1/3.); - for (int i=0; i 1 && !mpirank) cout << "Matgrads:: nb Triangle order1 :" << no1 << " , order2 : " << no2 << endl; return &A; -} + } -} -newpMatrice_Creuse Mat_VFD(Stack stack,const Mesh *const &pTh ,const long &order) -{ - return newpMatrice_Creuse(stack,Matgrads(pTh,order)); -} -newpMatrice_Creuse Mat_VFD(Stack stack,const Mesh *const &pTh ) -{ - return newpMatrice_Creuse(stack,Matgrads(pTh,3)); -} -newpMatrice_Creuse Mat_VFM01(Stack stack,const Mesh *const &pTh ) -{ - return newpMatrice_Creuse(stack,MatVFM01(pTh)); -} +} // namespace Fem2D +newpMatrice_Creuse< R > Mat_VFD(Stack stack, const Mesh *const &pTh, const long &order) { return newpMatrice_Creuse< R >(stack, Matgrads(pTh, order)); } +newpMatrice_Creuse< R > Mat_VFD(Stack stack, const Mesh *const &pTh) { return newpMatrice_Creuse< R >(stack, Matgrads(pTh, 3)); } +newpMatrice_Creuse< R > Mat_VFM01(Stack stack, const Mesh *const &pTh) { return newpMatrice_Creuse< R >(stack, MatVFM01(pTh)); } -KN*OrderVF(Stack stack,const Mesh *const &pTh, KN*const &pkb , const long &order) -{ - KN &kb = *pkb; - const Mesh &Th = *pTh; - // double *pkb= Add2StackOfPtr2Free(stack, new double(Th.nt)); - // KN_ kb(pkb,Th.nt); - ffassert(kb.N()==Th.nt);// verif size - kb = double(order); - if( order >= 3) - { - // search vexter on true boundaty - KN vb(Th.nv,0); - for (int k=0; k0)){ - kb[k] = 1. ; - } +KN< double > *OrderVF(Stack stack, const Mesh *const &pTh, KN< double > *const &pkb, const long &order) { + KN< double > &kb = *pkb; + const Mesh &Th = *pTh; + // double *pkb= Add2StackOfPtr2Free(stack, new double(Th.nt)); + // KN_ kb(pkb,Th.nt); + ffassert(kb.N( ) == Th.nt); // verif size + kb = double(order); + if (order >= 3) { + // search vexter on true boundaty + KN< int > vb(Th.nv, 0); + for (int k = 0; k < Th.nt; k++) + for (int e = 0; e < 3; ++e) { + // search of the edge on the bdy + int ee = e, ke = Th.ElementAdj(k, ee); + if (ke == k || ke < 0) { // + vb[Th(k, (e + 1) % 3)] = 1; + vb[Th(k, (e + 2) % 3)] = 1; } + } + double oo[] = {2., 1., 1., 2.}; + for (int k = 0; k < Th.nt; k++) { + kb[k] = oo[vb[Th(k, 0)] + vb[Th(k, 1)] + vb[Th(k, 2)]]; + if ((order == 4) && (vb[Th(k, 0)] + vb[Th(k, 1)] + vb[Th(k, 2)] > 0)) { + kb[k] = 1.; + } } - return pkb; + } + return pkb; } -KN *OrderVF(Stack stack,const Mesh *const &pTh, KN*const &pkb ) -{ return OrderVF(stack,pTh,pkb, 3L);} +KN< double > *OrderVF(Stack stack, const Mesh *const &pTh, KN< double > *const &pkb) { return OrderVF(stack, pTh, pkb, 3L); } -KN *SlopeLimiterVF(Stack stack,const Mesh *const &pTh, KN*const &pw,KN*const &pGw, KN*const &palpha ) -{ - KN &w = *pw; - KN &Gw = *pGw; - const Mesh &Th = *pTh; - KN &alpha = *palpha; - assert( w.N() == Th.nt); - assert( Gw.N() == Th.nt*2); - assert( alpha.N() == Th.nt); - R2 GH(1./3.,1/3.),PE[3]={R2(0.5,0.5),R2(0.,0.5),R2(0.5,0.)}; - for(int k=0; k< Th.nt;++k) - { - const Triangle &K = Th[k]; - R2 G=K(GH); +KN< double > *SlopeLimiterVF(Stack stack, const Mesh *const &pTh, KN< double > *const &pw, KN< double > *const &pGw, KN< double > *const &palpha) { + KN< double > &w = *pw; + KN< double > &Gw = *pGw; + const Mesh &Th = *pTh; + KN< double > &alpha = *palpha; + assert(w.N( ) == Th.nt); + assert(Gw.N( ) == Th.nt * 2); + assert(alpha.N( ) == Th.nt); + R2 GH(1. / 3., 1 / 3.), PE[3] = {R2(0.5, 0.5), R2(0., 0.5), R2(0.5, 0.)}; + for (int k = 0; k < Th.nt; ++k) { + const Triangle &K = Th[k]; + R2 G = K(GH); - double wk=w[k], wmink = wk, wmaxk = wk; - for(int e=0;e<3;++e) - { - // search of the edge on the bdy - int ee=e,ke=Th.ElementAdj(k,ee); - if( ke>=0 &&ke != k) // real adj .. - { - wmink = min(wmink,w[ke]); - wmaxk = max(wmaxk,w[ke]); - } - } - R2 Gk(Gw[2*k],Gw[2*k+1]); - double nGk2=Gk.norme2(); - double a = 1; - if(nGk2 > K.area*1e-10) - for(int e=0;e<3;++e) - { - double ae=1; - - R2 E(K(PE[e])), GE(G,E);// G au bary of edge e - // calcu de we - double we = wk + (Gk,GE); - if (we > wmaxk) ae = (wmaxk-wk)/(we-wk); - else if(we < wmink ) ae = (wmink-wk)/(we-wk); - a = min(a,ae); - if(verbosity>99 &&!mpirank) cout << " -- "<< e << " ::: " << we << " "<< wk << " " << we-wk << " " << ae << endl; - } - if(verbosity>99&&!mpirank) cout << k << " a " << a << " " << wmink << " " << wmaxk << " |G| " - << G.norme()<< " : " << " : " << Gk.norme() << endl; - alpha[k]=a; + double wk = w[k], wmink = wk, wmaxk = wk; + for (int e = 0; e < 3; ++e) { + // search of the edge on the bdy + int ee = e, ke = Th.ElementAdj(k, ee); + if (ke >= 0 && ke != k) // real adj .. + { + wmink = min(wmink, w[ke]); + wmaxk = max(wmaxk, w[ke]); + } } - return palpha; + R2 Gk(Gw[2 * k], Gw[2 * k + 1]); + double nGk2 = Gk.norme2( ); + double a = 1; + if (nGk2 > K.area * 1e-10) + for (int e = 0; e < 3; ++e) { + double ae = 1; + + R2 E(K(PE[e])), GE(G, E); // G au bary of edge e + // calcu de we + double we = wk + (Gk, GE); + if (we > wmaxk) + ae = (wmaxk - wk) / (we - wk); + else if (we < wmink) + ae = (wmink - wk) / (we - wk); + a = min(a, ae); + if (verbosity > 99 && !mpirank) cout << " -- " << e << " ::: " << we << " " << wk << " " << we - wk << " " << ae << endl; + } + if (verbosity > 99 && !mpirank) cout << k << " a " << a << " " << wmink << " " << wmaxk << " |G| " << G.norme( ) << " : " << " : " << Gk.norme( ) << endl; + alpha[k] = a; + } + return palpha; } -static void Load_Init () { - if(!mpirank) cout << " load: init MAT_D of VF (G. Sadaka) " << endl; - Global.Add("MatVFD", "(", new OneOperator1s_ , const Mesh *> (Mat_VFD)); - Global.Add("MatVFD", "(", new OneOperator2s_ , const Mesh *,long> (Mat_VFD)); - Global.Add("MatVFM01", "(", new OneOperator1s_ , const Mesh *> (Mat_VFM01)); - Global.Add("OrderVF", "(", new OneOperator3s_* , const Mesh *,KN *,long > (OrderVF)); - Global.Add("OrderVF", "(", new OneOperator2s_* , const Mesh *,KN *> (OrderVF)); - Global.Add("SlopeLimiterVF", "(", new OneOperator4s_* , const Mesh *,KN *,KN *,KN *> (SlopeLimiterVF)); +static void Load_Init( ) { + if (!mpirank) cout << " load: init MAT_D of VF (G. Sadaka) " << endl; + Global.Add("MatVFD", "(", new OneOperator1s_< newpMatrice_Creuse< R >, const Mesh * >(Mat_VFD)); + Global.Add("MatVFD", "(", new OneOperator2s_< newpMatrice_Creuse< R >, const Mesh *, long >(Mat_VFD)); + Global.Add("MatVFM01", "(", new OneOperator1s_< newpMatrice_Creuse< R >, const Mesh * >(Mat_VFM01)); + Global.Add("OrderVF", "(", new OneOperator3s_< KN< double > *, const Mesh *, KN< double > *, long >(OrderVF)); + Global.Add("OrderVF", "(", new OneOperator2s_< KN< double > *, const Mesh *, KN< double > * >(OrderVF)); + Global.Add("SlopeLimiterVF", "(", new OneOperator4s_< KN< double > *, const Mesh *, KN< double > *, KN< double > *, KN< double > * >(SlopeLimiterVF)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/MatrixMarket.cpp b/plugin/seq/MatrixMarket.cpp index f1b43fcfc..5c1180441 100644 --- a/plugin/seq/MatrixMarket.cpp +++ b/plugin/seq/MatrixMarket.cpp @@ -37,66 +37,59 @@ int mm_write_banner(FILE *f, MM_typecode matcode); int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz); int mm_write_mtx_array_size(FILE *f, int M, int N); - /********************* MM_typecode query fucntions ***************************/ -#define mm_is_matrix(typecode) ((typecode)[0]=='M') - -#define mm_is_sparse(typecode) ((typecode)[1]=='C') -#define mm_is_coordinate(typecode)((typecode)[1]=='C') -#define mm_is_dense(typecode) ((typecode)[1]=='A') -#define mm_is_array(typecode) ((typecode)[1]=='A') +#define mm_is_matrix(typecode) ((typecode)[0] == 'M') -#define mm_is_complex(typecode) ((typecode)[2]=='C') -#define mm_is_real(typecode) ((typecode)[2]=='R') -#define mm_is_pattern(typecode) ((typecode)[2]=='P') -#define mm_is_integer(typecode) ((typecode)[2]=='I') +#define mm_is_sparse(typecode) ((typecode)[1] == 'C') +#define mm_is_coordinate(typecode) ((typecode)[1] == 'C') +#define mm_is_dense(typecode) ((typecode)[1] == 'A') +#define mm_is_array(typecode) ((typecode)[1] == 'A') -#define mm_is_symmetric(typecode)((typecode)[3]=='S') -#define mm_is_general(typecode) ((typecode)[3]=='G') -#define mm_is_skew(typecode) ((typecode)[3]=='K') -#define mm_is_hermitian(typecode)((typecode)[3]=='H') +#define mm_is_complex(typecode) ((typecode)[2] == 'C') +#define mm_is_real(typecode) ((typecode)[2] == 'R') +#define mm_is_pattern(typecode) ((typecode)[2] == 'P') +#define mm_is_integer(typecode) ((typecode)[2] == 'I') -int mm_is_valid(MM_typecode matcode); /* too complex for a macro */ +#define mm_is_symmetric(typecode) ((typecode)[3] == 'S') +#define mm_is_general(typecode) ((typecode)[3] == 'G') +#define mm_is_skew(typecode) ((typecode)[3] == 'K') +#define mm_is_hermitian(typecode) ((typecode)[3] == 'H') +int mm_is_valid(MM_typecode matcode); /* too complex for a macro */ /********************* MM_typecode modify fucntions ***************************/ -#define mm_set_matrix(typecode) ((*typecode)[0]='M') -#define mm_set_coordinate(typecode) ((*typecode)[1]='C') -#define mm_set_array(typecode) ((*typecode)[1]='A') -#define mm_set_dense(typecode) mm_set_array(typecode) -#define mm_set_sparse(typecode) mm_set_coordinate(typecode) +#define mm_set_matrix(typecode) ((*typecode)[0] = 'M') +#define mm_set_coordinate(typecode) ((*typecode)[1] = 'C') +#define mm_set_array(typecode) ((*typecode)[1] = 'A') +#define mm_set_dense(typecode) mm_set_array(typecode) +#define mm_set_sparse(typecode) mm_set_coordinate(typecode) -#define mm_set_complex(typecode)((*typecode)[2]='C') -#define mm_set_real(typecode) ((*typecode)[2]='R') -#define mm_set_pattern(typecode)((*typecode)[2]='P') -#define mm_set_integer(typecode)((*typecode)[2]='I') +#define mm_set_complex(typecode) ((*typecode)[2] = 'C') +#define mm_set_real(typecode) ((*typecode)[2] = 'R') +#define mm_set_pattern(typecode) ((*typecode)[2] = 'P') +#define mm_set_integer(typecode) ((*typecode)[2] = 'I') +#define mm_set_symmetric(typecode) ((*typecode)[3] = 'S') +#define mm_set_general(typecode) ((*typecode)[3] = 'G') +#define mm_set_skew(typecode) ((*typecode)[3] = 'K') +#define mm_set_hermitian(typecode) ((*typecode)[3] = 'H') -#define mm_set_symmetric(typecode)((*typecode)[3]='S') -#define mm_set_general(typecode)((*typecode)[3]='G') -#define mm_set_skew(typecode) ((*typecode)[3]='K') -#define mm_set_hermitian(typecode)((*typecode)[3]='H') - -#define mm_clear_typecode(typecode) ((*typecode)[0]=(*typecode)[1]= \ - (*typecode)[2]=' ',(*typecode)[3]='G') +#define mm_clear_typecode(typecode) ((*typecode)[0] = (*typecode)[1] = (*typecode)[2] = ' ', (*typecode)[3] = 'G') #define mm_initialize_typecode(typecode) mm_clear_typecode(typecode) - /********************* Matrix Market error codes ***************************/ - -#define MM_COULD_NOT_READ_FILE 11 -#define MM_PREMATURE_EOF 12 -#define MM_NOT_MTX 13 -#define MM_NO_HEADER 14 -#define MM_UNSUPPORTED_TYPE 15 -#define MM_LINE_TOO_LONG 16 -#define MM_COULD_NOT_WRITE_FILE 17 -#define MM_BINARY_FILE 99 - +#define MM_COULD_NOT_READ_FILE 11 +#define MM_PREMATURE_EOF 12 +#define MM_NOT_MTX 13 +#define MM_NO_HEADER 14 +#define MM_UNSUPPORTED_TYPE 15 +#define MM_LINE_TOO_LONG 16 +#define MM_COULD_NOT_WRITE_FILE 17 +#define MM_BINARY_FILE 99 /******************** Matrix Market internal definitions ******************** @@ -114,294 +107,246 @@ int mm_is_valid(MM_typecode matcode); /* too complex for a macro */ ***********************************************************************/ -#define MM_MTX_STR "matrix" -#define MM_ARRAY_STR "array" -#define MM_DENSE_STR "array" +#define MM_MTX_STR "matrix" +#define MM_ARRAY_STR "array" +#define MM_DENSE_STR "array" #define MM_COORDINATE_STR "coordinate" -#define MM_SPARSE_STR "coordinate" -#define MM_COMPLEX_STR "complex" -#define MM_REAL_STR "real" -#define MM_INT_STR "integer" -#define MM_GENERAL_STR "general" -#define MM_SYMM_STR "symmetric" -#define MM_HERM_STR "hermitian" -#define MM_SKEW_STR "skew-symmetric" -#define MM_PATTERN_STR "pattern" - +#define MM_SPARSE_STR "coordinate" +#define MM_COMPLEX_STR "complex" +#define MM_REAL_STR "real" +#define MM_INT_STR "integer" +#define MM_GENERAL_STR "general" +#define MM_SYMM_STR "symmetric" +#define MM_HERM_STR "hermitian" +#define MM_SKEW_STR "skew-symmetric" +#define MM_PATTERN_STR "pattern" /* high level routines */ -int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], - double val[], MM_typecode matcode,bool bin); -int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], - double val[], MM_typecode matcode); -int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img, - MM_typecode matcode); - -int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, - double **val_, int **I_, int **J_); - +int mm_write_mtx_crd(char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode, bool bin); +int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode); +int mm_read_mtx_crd_entry(FILE *f, int *I, int *J, double *real, double *img, MM_typecode matcode); +int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, double **val_, int **I_, int **J_); #include #include #include #include - //#include "mmio.h" +// #include "mmio.h" // for binary file -struct IJR { int i,j; double v;}; -struct IJC { int i,j; double v, iv;}; - -int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_, - double **val_, int **I_, int **J_) -{ - FILE *f; - MM_typecode matcode; - int M, N, nz; - int i; - double *val; - int *I, *J; - - if ((f = fopen(fname, "rb")) == NULL) - return -1; - - - if (mm_read_banner(f, &matcode) != 0) - { - printf("mm_read_unsymetric: Could not process Matrix Market banner "); - printf(" in file [%s]\n", fname); - return -1; - } - - - - if ( !(mm_is_real(matcode) && mm_is_matrix(matcode) && - mm_is_sparse(matcode))) - { - fprintf(stderr, "Sorry, this application does not support "); - fprintf(stderr, "Market Market type: [%s]\n", - mm_typecode_to_str(matcode)); - return -1; - } - - /* find out size of sparse matrix: M, N, nz .... */ - - if (mm_read_mtx_crd_size(f, &M, &N, &nz) !=0) - { - fprintf(stderr, "read_unsymmetric_sparse(): could not parse matrix size.\n"); - return -1; - } - - *M_ = M; - *N_ = N; - *nz_ = nz; - - /* reseve memory for matrices */ - - I = (int *) malloc(nz * sizeof(int)); - J = (int *) malloc(nz * sizeof(int)); - val = (double *) malloc(nz * sizeof(double)); - - *val_ = val; - *I_ = I; - *J_ = J; - - /* NOTE: when reading in doubles, ANSI C requires the use of the "l" */ - /* specifier as in "%lg", "%lf", "%le", otherwise errors will occur */ - /* (ANSI C X3.159-1989, Sec. 4.9.6.2, p. 136 lines 13-15) */ - - for (i=0; i999) cout << " banner = "<< banner << " " - << strncmp(banner, MatrixMarketBannerBinary, strlen(MatrixMarketBannerBinary)) << " " - << strncmp(banner, MatrixMarketBanner , strlen(MatrixMarketBanner)) - << endl; - if (strncmp(banner, MatrixMarketBannerBinary, strlen(MatrixMarketBannerBinary)) == 0) - { binary= MM_BINARY_FILE; } - else if (strncmp(banner, MatrixMarketBanner, strlen(MatrixMarketBanner)) == 0) - { binary=0; } - else - return MM_NO_HEADER; - - /* first field should be "mtx" */ - if (strcmp(mtx, MM_MTX_STR) != 0) - return MM_UNSUPPORTED_TYPE; - mm_set_matrix(matcode); - - - /* second field describes whether this is a sparse matrix (in coordinate - storgae) or a dense array */ - - - if (strcmp(crd, MM_SPARSE_STR) == 0) - mm_set_sparse(matcode); - else - if (strcmp(crd, MM_DENSE_STR) == 0) - mm_set_dense(matcode); - else - return MM_UNSUPPORTED_TYPE; - - - /* third field */ - - if (strcmp(data_type, MM_REAL_STR) == 0) - mm_set_real(matcode); - else - if (strcmp(data_type, MM_COMPLEX_STR) == 0) - mm_set_complex(matcode); - else - if (strcmp(data_type, MM_PATTERN_STR) == 0) - mm_set_pattern(matcode); - else - if (strcmp(data_type, MM_INT_STR) == 0) - mm_set_integer(matcode); - else - return MM_UNSUPPORTED_TYPE; - - - /* fourth field */ - - if (strcmp(storage_scheme, MM_GENERAL_STR) == 0) - mm_set_general(matcode); - else - if (strcmp(storage_scheme, MM_SYMM_STR) == 0) - mm_set_symmetric(matcode); - else - if (strcmp(storage_scheme, MM_HERM_STR) == 0) - mm_set_hermitian(matcode); - else - if (strcmp(storage_scheme, MM_SKEW_STR) == 0) - mm_set_skew(matcode); - else - return MM_UNSUPPORTED_TYPE; - + if ((f = fopen(fname, "rb")) == NULL) return -1; + + if (mm_read_banner(f, &matcode) != 0) { + printf("mm_read_unsymetric: Could not process Matrix Market banner "); + printf(" in file [%s]\n", fname); + return -1; + } + + if (!(mm_is_real(matcode) && mm_is_matrix(matcode) && mm_is_sparse(matcode))) { + fprintf(stderr, "Sorry, this application does not support "); + fprintf(stderr, "Market Market type: [%s]\n", mm_typecode_to_str(matcode)); + return -1; + } + + /* find out size of sparse matrix: M, N, nz .... */ - return binary; + if (mm_read_mtx_crd_size(f, &M, &N, &nz) != 0) { + fprintf(stderr, "read_unsymmetric_sparse(): could not parse matrix size.\n"); + return -1; + } + + *M_ = M; + *N_ = N; + *nz_ = nz; + + /* reseve memory for matrices */ + + I = (int *)malloc(nz * sizeof(int)); + J = (int *)malloc(nz * sizeof(int)); + val = (double *)malloc(nz * sizeof(double)); + + *val_ = val; + *I_ = I; + *J_ = J; + + /* NOTE: when reading in doubles, ANSI C requires the use of the "l" */ + /* specifier as in "%lg", "%lf", "%le", otherwise errors will occur */ + /* (ANSI C X3.159-1989, Sec. 4.9.6.2, p. 136 lines 13-15) */ + + for (i = 0; i < nz; i++) { + fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]); + I[i]--; /* adjust from 1-based to 0-based */ + J[i]--; + } + fclose(f); + + return 0; } -int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz) -{ - if (fprintf(f, "%d %d %d\n", M, N, nz) != 3) - return MM_COULD_NOT_WRITE_FILE; - else - return 0; +int mm_is_valid(MM_typecode matcode) { + if (!mm_is_matrix(matcode)) return 0; + if (mm_is_dense(matcode) && mm_is_pattern(matcode)) return 0; + if (mm_is_real(matcode) && mm_is_hermitian(matcode)) return 0; + if (mm_is_pattern(matcode) && (mm_is_hermitian(matcode) || mm_is_skew(matcode))) return 0; + return 1; } -int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz ) -{ - char line[MM_MAX_LINE_LENGTH]; - int num_items_read; - - /* set return null parameter values, in case we exit with errors */ - *M = *N = *nz = 0; - - /* now continue scanning until you reach the end-of-comments */ - do - { - if (fgets(line,MM_MAX_LINE_LENGTH,f) == NULL) - return MM_PREMATURE_EOF; - }while (line[0] == '%'); - - /* line[] is either blank or has M,N, nz */ - if (sscanf(line, "%d %d %d", M, N, nz) == 3) - return 0; - - else - do - { - num_items_read = fscanf(f, "%d %d %d", M, N, nz); - if (num_items_read == EOF) return MM_PREMATURE_EOF; - } - while (num_items_read != 3); +int mm_read_banner(FILE *f, MM_typecode *matcode) { + char line[MM_MAX_LINE_LENGTH]; + char banner[MM_MAX_TOKEN_LENGTH]; + char mtx[MM_MAX_TOKEN_LENGTH]; + char crd[MM_MAX_TOKEN_LENGTH]; + char data_type[MM_MAX_TOKEN_LENGTH]; + char storage_scheme[MM_MAX_TOKEN_LENGTH]; + char *p; + int binary = 0; + + mm_clear_typecode(matcode); + + if (fgets(line, MM_MAX_LINE_LENGTH, f) == NULL) return MM_PREMATURE_EOF; + + if (sscanf(line, "%s %s %s %s %s", banner, mtx, crd, data_type, storage_scheme) != 5) return MM_PREMATURE_EOF; + + for (p = mtx; *p != '\0'; *p = tolower(*p), p++); /* convert to lower case */ + for (p = crd; *p != '\0'; *p = tolower(*p), p++); + for (p = data_type; *p != '\0'; *p = tolower(*p), p++); + for (p = storage_scheme; *p != '\0'; *p = tolower(*p), p++); + + /* check for banner */ + if (verbosity > 999) + cout << " banner = " << banner << " " << strncmp(banner, MatrixMarketBannerBinary, strlen(MatrixMarketBannerBinary)) << " " << strncmp(banner, MatrixMarketBanner, strlen(MatrixMarketBanner)) + << endl; + if (strncmp(banner, MatrixMarketBannerBinary, strlen(MatrixMarketBannerBinary)) == 0) { + binary = MM_BINARY_FILE; + } else if (strncmp(banner, MatrixMarketBanner, strlen(MatrixMarketBanner)) == 0) { + binary = 0; + } else + return MM_NO_HEADER; + + /* first field should be "mtx" */ + if (strcmp(mtx, MM_MTX_STR) != 0) return MM_UNSUPPORTED_TYPE; + mm_set_matrix(matcode); + + /* second field describes whether this is a sparse matrix (in coordinate + storgae) or a dense array */ + + if (strcmp(crd, MM_SPARSE_STR) == 0) + mm_set_sparse(matcode); + else if (strcmp(crd, MM_DENSE_STR) == 0) + mm_set_dense(matcode); + else + return MM_UNSUPPORTED_TYPE; + + /* third field */ + + if (strcmp(data_type, MM_REAL_STR) == 0) + mm_set_real(matcode); + else if (strcmp(data_type, MM_COMPLEX_STR) == 0) + mm_set_complex(matcode); + else if (strcmp(data_type, MM_PATTERN_STR) == 0) + mm_set_pattern(matcode); + else if (strcmp(data_type, MM_INT_STR) == 0) + mm_set_integer(matcode); + else + return MM_UNSUPPORTED_TYPE; + + /* fourth field */ + + if (strcmp(storage_scheme, MM_GENERAL_STR) == 0) + mm_set_general(matcode); + else if (strcmp(storage_scheme, MM_SYMM_STR) == 0) + mm_set_symmetric(matcode); + else if (strcmp(storage_scheme, MM_HERM_STR) == 0) + mm_set_hermitian(matcode); + else if (strcmp(storage_scheme, MM_SKEW_STR) == 0) + mm_set_skew(matcode); + else + return MM_UNSUPPORTED_TYPE; + + return binary; +} +int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz) { + if (fprintf(f, "%d %d %d\n", M, N, nz) != 3) + return MM_COULD_NOT_WRITE_FILE; + else return 0; } +int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz) { + char line[MM_MAX_LINE_LENGTH]; + int num_items_read; -int mm_read_mtx_array_size(FILE *f, int *M, int *N) -{ - char line[MM_MAX_LINE_LENGTH]; - int num_items_read; - /* set return null parameter values, in case we exit with errors */ - *M = *N = 0; - - /* now continue scanning until you reach the end-of-comments */ - do - { - if (fgets(line,MM_MAX_LINE_LENGTH,f) == NULL) - return MM_PREMATURE_EOF; - }while (line[0] == '%'); - - /* line[] is either blank or has M,N, nz */ - if (sscanf(line, "%d %d", M, N) == 2) - return 0; - - else /* we have a blank line */ - do - { - num_items_read = fscanf(f, "%d %d", M, N); - if (num_items_read == EOF) return MM_PREMATURE_EOF; - } - while (num_items_read != 2); + /* set return null parameter values, in case we exit with errors */ + *M = *N = *nz = 0; + + /* now continue scanning until you reach the end-of-comments */ + do { + if (fgets(line, MM_MAX_LINE_LENGTH, f) == NULL) return MM_PREMATURE_EOF; + } while (line[0] == '%'); + /* line[] is either blank or has M,N, nz */ + if (sscanf(line, "%d %d %d", M, N, nz) == 3) return 0; -} -int mm_write_mtx_array_size(FILE *f, int M, int N) -{ - if (fprintf(f, "%d %d\n", M, N) != 2) - return MM_COULD_NOT_WRITE_FILE; - else - return 0; + else + do { + num_items_read = fscanf(f, "%d %d %d", M, N, nz); + if (num_items_read == EOF) return MM_PREMATURE_EOF; + } while (num_items_read != 3); + + return 0; } +int mm_read_mtx_array_size(FILE *f, int *M, int *N) { + char line[MM_MAX_LINE_LENGTH]; + int num_items_read; + /* set return null parameter values, in case we exit with errors */ + *M = *N = 0; + /* now continue scanning until you reach the end-of-comments */ + do { + if (fgets(line, MM_MAX_LINE_LENGTH, f) == NULL) return MM_PREMATURE_EOF; + } while (line[0] == '%'); + + /* line[] is either blank or has M,N, nz */ + if (sscanf(line, "%d %d", M, N) == 2) + return 0; + + else /* we have a blank line */ + do { + num_items_read = fscanf(f, "%d %d", M, N); + if (num_items_read == EOF) return MM_PREMATURE_EOF; + } while (num_items_read != 2); + + return 0; +} + +int mm_write_mtx_array_size(FILE *f, int M, int N) { + if (fprintf(f, "%d %d\n", M, N) != 2) + return MM_COULD_NOT_WRITE_FILE; + else + return 0; +} /*-------------------------------------------------------------------------*/ @@ -409,125 +354,97 @@ int mm_write_mtx_array_size(FILE *f, int M, int N) /* use when I[], J[], and val[]J, and val[] are already allocated */ /******************************************************************/ -int mm_read_mtx_crd_data(FILE *f, int M, int N, int nz, int I[], int J[], - double val[], MM_typecode matcode) -{ - int i; - if (mm_is_complex(matcode)) - { - for (i=0; i 9999) cout << ijc.i << " " << ijc.j << " " << ijc.v << " :: " << *I << " " << *J << " " << *real << " " << *imag << endl; + + } else if (mm_is_real(matcode)) { + lgr = fread(&ijr, sizeof(IJR), 1, f); + if (lgr != 1) return MM_PREMATURE_EOF; + *I = ijr.i; + *J = ijr.j; + *real = ijr.v; + if (verbosity > 9999) cout << ijr.i << " " << ijr.j << " " << ijr.v << " :: " << *I << " " << *J << " " << *real << " " << sizeof(IJR) << endl; -int mm_readb_mtx_crd_entry(FILE *f, int *I, int *J, - double *real, double *imag, MM_typecode matcode) -{ - long lgr; - IJC ijc; - IJR ijr; - struct IJ { int i,j;}; - IJ ij; - - if (mm_is_complex(matcode)) - { - - if(fread(&ijc,sizeof(IJC),1,f) != 1) - return MM_PREMATURE_EOF; - *I=ijc.i; - *J=ijc.j; - *real=ijc.v; - *imag=ijc.iv; - if(verbosity>9999) cout << ijc.i <<" " << ijc.j << " " << ijc.v << " :: " << *I << " " << *J << " " << *real << " " << *imag << endl; - - } - else if (mm_is_real(matcode)) - { - lgr=fread(&ijr,sizeof(IJR),1,f); - if( lgr != 1) - return MM_PREMATURE_EOF; - *I=ijr.i; - *J=ijr.j; - *real=ijr.v; - if(verbosity>9999) cout << ijr.i <<" " << ijr.j << " " << ijr.v << " :: " << *I << " " << *J << " " << *real << " " << sizeof(IJR) << endl; - - } + } - else if (mm_is_pattern(matcode)) - { - if(fread(&ij,sizeof(IJ),1,f) != 1) - return MM_PREMATURE_EOF; - *I=ij.i; - *J=ij.j; - } - else - return MM_UNSUPPORTED_TYPE; + else if (mm_is_pattern(matcode)) { + if (fread(&ij, sizeof(IJ), 1, f) != 1) return MM_PREMATURE_EOF; + *I = ij.i; + *J = ij.j; + } else + return MM_UNSUPPORTED_TYPE; - return 0; - + return 0; } -int mm_read_mtx_crd_entry(bool bin, FILE *f, int *I, int *J,double *v, MM_typecode matcode) -{ double vi; - if(bin) return mm_readb_mtx_crd_entry(f,I,J,v,&vi,matcode); - else return mm_read_mtx_crd_entry(f,I,J,v,&vi,matcode); +int mm_read_mtx_crd_entry(bool bin, FILE *f, int *I, int *J, double *v, MM_typecode matcode) { + double vi; + if (bin) + return mm_readb_mtx_crd_entry(f, I, J, v, &vi, matcode); + else + return mm_read_mtx_crd_entry(f, I, J, v, &vi, matcode); } -int mm_read_mtx_crd_entry(bool bin, FILE *f, int *I, int *J,complex *v, MM_typecode matcode) -{ - double vr,vi; - int rt=0; - if(bin) rt= mm_readb_mtx_crd_entry(f,I,J,&vr,&vi,matcode); - else rt= mm_read_mtx_crd_entry(f,I,J,&vr,&vi,matcode); - if(rt==0) *v = complex(vr,vi); - else *v =complex(); - return rt; +int mm_read_mtx_crd_entry(bool bin, FILE *f, int *I, int *J, complex< double > *v, MM_typecode matcode) { + double vr, vi; + int rt = 0; + if (bin) + rt = mm_readb_mtx_crd_entry(f, I, J, &vr, &vi, matcode); + else + rt = mm_read_mtx_crd_entry(f, I, J, &vr, &vi, matcode); + if (rt == 0) + *v = complex< double >(vr, vi); + else + *v = complex< double >( ); + return rt; } /************************************************************************ @@ -538,361 +455,290 @@ int mm_read_mtx_crd_entry(bool bin, FILE *f, int *I, int *J,complex *v, (nz pairs of real/imaginary values) ************************************************************************/ -int mm_read_mtx_crd(const char *fname, int *M, int *N, int *nz, int **I, int **J, - double **val, MM_typecode *matcode) -{ - int ret_code; - FILE *f; +int mm_read_mtx_crd(const char *fname, int *M, int *N, int *nz, int **I, int **J, double **val, MM_typecode *matcode) { + int ret_code; + FILE *f; - if (strcmp(fname, "stdin") == 0) f=stdin; - else - if ((f = fopen(fname, "rb")) == NULL) - return MM_COULD_NOT_READ_FILE; + if (strcmp(fname, "stdin") == 0) + f = stdin; + else if ((f = fopen(fname, "rb")) == NULL) + return MM_COULD_NOT_READ_FILE; + if ((ret_code = mm_read_banner(f, matcode)) != 0) return ret_code; - if ((ret_code = mm_read_banner(f, matcode)) != 0) - return ret_code; + if (!(mm_is_valid(*matcode) && mm_is_sparse(*matcode) && mm_is_matrix(*matcode))) return MM_UNSUPPORTED_TYPE; - if (!(mm_is_valid(*matcode) && mm_is_sparse(*matcode) && - mm_is_matrix(*matcode))) - return MM_UNSUPPORTED_TYPE; + if ((ret_code = mm_read_mtx_crd_size(f, M, N, nz)) != 0) return ret_code; - if ((ret_code = mm_read_mtx_crd_size(f, M, N, nz)) != 0) - return ret_code; + *I = (int *)malloc(*nz * sizeof(int)); + *J = (int *)malloc(*nz * sizeof(int)); + *val = NULL; + if (mm_is_complex(*matcode)) { + *val = (double *)malloc(*nz * 2 * sizeof(double)); + ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, *matcode); + if (ret_code != 0) return ret_code; + } else if (mm_is_real(*matcode)) { + *val = (double *)malloc(*nz * sizeof(double)); + ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, *matcode); + if (ret_code != 0) return ret_code; + } - *I = (int *) malloc(*nz * sizeof(int)); - *J = (int *) malloc(*nz * sizeof(int)); - *val = NULL; + else if (mm_is_pattern(*matcode)) { + ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, *matcode); + if (ret_code != 0) return ret_code; + } - if (mm_is_complex(*matcode)) - { - *val = (double *) malloc(*nz * 2 * sizeof(double)); - ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, - *matcode); - if (ret_code != 0) return ret_code; - } - else if (mm_is_real(*matcode)) - { - *val = (double *) malloc(*nz * sizeof(double)); - ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, - *matcode); - if (ret_code != 0) return ret_code; - } + if (f != stdin) fclose(f); + return 0; +} - else if (mm_is_pattern(*matcode)) - { - ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, - *matcode); - if (ret_code != 0) return ret_code; - } +int mm_write_banner(FILE *f, MM_typecode matcode) { + char *str = mm_typecode_to_str(matcode); + int ret_code; - if (f != stdin) fclose(f); + ret_code = fprintf(f, "%s %s\n", MatrixMarketBanner, str); + free(str); + if (ret_code != 2) + return MM_COULD_NOT_WRITE_FILE; + else return 0; } -int mm_write_banner(FILE *f, MM_typecode matcode) -{ - char *str = mm_typecode_to_str(matcode); - int ret_code; - - ret_code = fprintf(f, "%s %s\n", MatrixMarketBanner, str); - free(str); - if (ret_code !=2 ) - return MM_COULD_NOT_WRITE_FILE; - else - return 0; -} +int mm_write_mtx_crd(const char fname[], int M, int N, int nz, int I[], int J[], double val[], MM_typecode matcode, bool bin) { -int mm_write_mtx_crd(const char fname[], int M, int N, int nz, int I[], int J[], - double val[], MM_typecode matcode,bool bin) -{ - - FILE *f; - int i; - - if (strcmp(fname, "stdout") == 0) - f = stdout; - else - if ((f = fopen(fname, "wb")) == NULL) - return MM_COULD_NOT_WRITE_FILE; - - /* print banner followed by typecode */ - if(bin) - fprintf(f, "%s ", MatrixMarketBannerBinary); - else - fprintf(f, "%s ", MatrixMarketBanner); - - - fprintf(f, "%s\n", mm_typecode_to_str(matcode)); - - /* print matrix sizes and nonzeros */ - fprintf(f, "%d %d %d\n", M, N, nz); - - /* print values */ - if (mm_is_pattern(matcode)) - for (i=0; i -long savemtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat,bool const & bin) { +long savemtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat, bool const &bin) { - MatriceMorse< R > *A = sparse_mat->pHM( ); const bool isDouble = sizeof(R) == sizeof(double); // std::is_floating_point::value; - std::cout << "Savemtx : filename = " << hb_filename->c_str( ) << " " << isDouble <N; - const int M = A->M; - - if(verbosity) std::cout << "SaveMTX : # of unknowns = " << N << std::endl; - - const int nz = A->nnz; - - if(verbosity) std::cout << "SaveMTX : # of non-zero entries in A = " << nz << std::endl; - int *I, *J; - R *valr; - A->COO(I, J, valr); - double *val = reinterpret_cast( valr); - - MM_typecode matcode; - int i; - - mm_initialize_typecode(&matcode); - mm_set_matrix(&matcode); - mm_set_coordinate(&matcode); - if( isDouble ) - mm_set_real(&matcode); - else - mm_set_complex(&matcode); - - mm_write_mtx_crd(hb_filename->c_str( ),N,M,nz,I,J,val,matcode,bin); - - return nz; - + std::cout << "Savemtx : filename = " << hb_filename->c_str( ) << " " << isDouble << std::endl; + const int N = A->N; + const int M = A->M; + + if (verbosity) std::cout << "SaveMTX : # of unknowns = " << N << std::endl; + + const int nz = A->nnz; + + if (verbosity) std::cout << "SaveMTX : # of non-zero entries in A = " << nz << std::endl; + int *I, *J; + R *valr; + A->COO(I, J, valr); + double *val = reinterpret_cast< double * >(valr); + + MM_typecode matcode; + int i; + + mm_initialize_typecode(&matcode); + mm_set_matrix(&matcode); + mm_set_coordinate(&matcode); + if (isDouble) + mm_set_real(&matcode); + else + mm_set_complex(&matcode); + + mm_write_mtx_crd(hb_filename->c_str( ), N, M, nz, I, J, val, matcode, bin); + + return nz; } template< typename R > long savemtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat) { - return savemtx(hb_filename,sparse_mat,false); + return savemtx(hb_filename, sparse_mat, false); }; template< typename R > -long readmtx(const char *fname, MatriceMorse *&pA,bool bin) -{ - // - ffassert(pA==0);// matrice vide - const bool isDouble = sizeof(R) == sizeof(double); - int N,M,nz; - int ret_code; - FILE *f; - MM_typecode matcode; - - if (strcmp(fname, "stdin") == 0) f=stdin; - else - if ((f = fopen(fname, "rb")) == NULL) - return MM_COULD_NOT_READ_FILE; - - - ret_code = mm_read_banner(f, &matcode); - - if( ret_code == MM_BINARY_FILE ) bin = true; - else if( ret_code != 0 ) - return ret_code; - - if (!(mm_is_valid(matcode) && mm_is_sparse(matcode) && - mm_is_matrix(matcode))) - return MM_UNSUPPORTED_TYPE; - - if ((ret_code = mm_read_mtx_crd_size(f, &M, &N, &nz)) != 0) - return ret_code; - cout << " build matrix "<< M << "x" << N << " nnz =" << nz << " bin = " << bin << " fname = " << fname << endl; - pA = new MatriceMorse(M,N,nz,0); - - int I,J,val,vali; - { R V; - - for(int k=0; k< nz; ++k) - { - - int code= mm_read_mtx_crd_entry(bin,f,&I,&J,&V,matcode); - if(verbosity >999) cout <<" error code " << code << " " << k << endl; - ffassert(code ==0); - ffassert(I>0 && J >0); - if(verbosity >1999) cout << " -- " < *&pA, bool bin) { + // + ffassert(pA == 0); // matrice vide + const bool isDouble = sizeof(R) == sizeof(double); + int N, M, nz; + int ret_code; + FILE *f; + MM_typecode matcode; + + if (strcmp(fname, "stdin") == 0) + f = stdin; + else if ((f = fopen(fname, "rb")) == NULL) + return MM_COULD_NOT_READ_FILE; + + ret_code = mm_read_banner(f, &matcode); + + if (ret_code == MM_BINARY_FILE) + bin = true; + else if (ret_code != 0) + return ret_code; + + if (!(mm_is_valid(matcode) && mm_is_sparse(matcode) && mm_is_matrix(matcode))) return MM_UNSUPPORTED_TYPE; + + if ((ret_code = mm_read_mtx_crd_size(f, &M, &N, &nz)) != 0) return ret_code; + cout << " build matrix " << M << "x" << N << " nnz =" << nz << " bin = " << bin << " fname = " << fname << endl; + pA = new MatriceMorse< R >(M, N, nz, 0); + + int I, J, val, vali; + { + R V; + + for (int k = 0; k < nz; ++k) { + + int code = mm_read_mtx_crd_entry(bin, f, &I, &J, &V, matcode); + if (verbosity > 999) cout << " error code " << code << " " << k << endl; + ffassert(code == 0); + ffassert(I > 0 && J > 0); + if (verbosity > 1999) cout << " -- " << k << " " << I << " " << J << " " << V << endl; + assert(I <= M && J <= N); + + (*pA)(I - 1, J - 1) = V; } - return 0; + } + return 0; }; template< typename R > -long readmtx(const char *fname, Matrice_Creuse< R > *const &sparse_mat,bool bin) -{ - sparse_mat->typemat=0; //TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) - MatriceMorse< R > * pm=0; - ffassert(readmtx(fname,pm,bin)==0); - sparse_mat->A.master(pm); - return 0; +long readmtx(const char *fname, Matrice_Creuse< R > *const &sparse_mat, bool bin) { + sparse_mat->typemat = 0; // TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + MatriceMorse< R > *pm = 0; + ffassert(readmtx(fname, pm, bin) == 0); + sparse_mat->A.master(pm); + return 0; } template< typename R > -long readmtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat,bool const & bin) -{ - return readmtx(hb_filename->c_str(),sparse_mat,bin); +long readmtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat, bool const &bin) { + return readmtx(hb_filename->c_str( ), sparse_mat, bin); } template< typename R > long readmtx(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat) { - return readmtx(hb_filename->c_str(),sparse_mat,false); - }; + return readmtx(hb_filename->c_str( ), sparse_mat, false); +}; static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ if (verbosity) { cout << " load: SaveHB " << endl; } - Global.Add( - "savemtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< double > * >( - savemtx)); - Global.Add( - "savemtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< double > *, bool >( - savemtx)); - Global.Add( - "readmtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< double > * >( - readmtx)); - Global.Add( - "readmtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< double > * , bool>( - readmtx)); - - Global.Add( - "savemtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< Complex > * >( - savemtx)); - Global.Add( - "savemtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< Complex > *, bool >( - savemtx)); - Global.Add( - "readmtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< Complex > * >( - readmtx)); - Global.Add( - "readmtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< Complex > * , bool>( - readmtx)); + Global.Add("savemtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< double > * >(savemtx)); + Global.Add("savemtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< double > *, bool >(savemtx)); + Global.Add("readmtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< double > * >(readmtx)); + Global.Add("readmtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< double > *, bool >(readmtx)); + Global.Add("savemtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< Complex > * >(savemtx)); + Global.Add("savemtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< Complex > *, bool >(savemtx)); + Global.Add("readmtx", "(", new OneOperator2_< long, string *, Matrice_Creuse< Complex > * >(readmtx)); + Global.Add("readmtx", "(", new OneOperator3_< long, string *, Matrice_Creuse< Complex > *, bool >(readmtx)); } LOADFUNC(Load_Init) //---------------------------------------------------------------------- diff --git a/plugin/seq/MetricKuate.cpp b/plugin/seq/MetricKuate.cpp index 25f7c521d..e78970093 100644 --- a/plugin/seq/MetricKuate.cpp +++ b/plugin/seq/MetricKuate.cpp @@ -216,14 +216,8 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { // -----racines du polynome en b � minimiser---------------------------- - R bb1 = - (1. / pow(detXY, 2)) * - (pow(X0 * Ri, 2) + pow(Xi * R0, 2) - - 2. * abs(Xi * X0) * sqrt(pow(R0 * Ri, 2) - pow(detXY / (Rmax * (r0 - epsilon0)), 2))); - R bb2 = - (1. / pow(detXY, 2)) * - (pow(X0 * Ri, 2) + pow(Xi * R0, 2) + - 2. * abs(Xi * X0) * sqrt(pow(R0 * Ri, 2) - pow(detXY / (Rmax * (r0 - epsilon0)), 2))); + R bb1 = (1. / pow(detXY, 2)) * (pow(X0 * Ri, 2) + pow(Xi * R0, 2) - 2. * abs(Xi * X0) * sqrt(pow(R0 * Ri, 2) - pow(detXY / (Rmax * (r0 - epsilon0)), 2))); + R bb2 = (1. / pow(detXY, 2)) * (pow(X0 * Ri, 2) + pow(Xi * R0, 2) + 2. * abs(Xi * X0) * sqrt(pow(R0 * Ri, 2) - pow(detXY / (Rmax * (r0 - epsilon0)), 2))); // --fin----racines du polynome en b � minimiser-------------------- @@ -237,8 +231,7 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { // bornes de b----------------------------------------------------------- // cas: majoration de c -------------------------------------------- - R Li = X0 * Xi * (pow(Rmax / pow(r0 - epsilon0min, 2), 2) - 1. / pow(Rmax, 2)) + - (pow(Ri * X0, 2) - pow(R0 * Xi, 2)) / detXY; + R Li = X0 * Xi * (pow(Rmax / pow(r0 - epsilon0min, 2), 2) - 1. / pow(Rmax, 2)) + (pow(Ri * X0, 2) - pow(R0 * Xi, 2)) / detXY; R LiXY = Xi * Y0 + Yi * X0; if (abs(LiXY) >= precision) { @@ -266,8 +259,7 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { } // cas minoration de c -------------------------------------------- - Li = X0 * Xi * (-pow(Rmax / pow(r0 - epsilon0min, 2), 2) + 1. / pow(Rmax, 2)) + - (pow(Ri * X0, 2) - pow(R0 * Xi, 2)) / detXY; + Li = X0 * Xi * (-pow(Rmax / pow(r0 - epsilon0min, 2), 2) + 1. / pow(Rmax, 2)) + (pow(Ri * X0, 2) - pow(R0 * Xi, 2)) / detXY; LiXY = Xi * Y0 + Yi * X0; if (abs(LiXY) >= precision) { @@ -298,8 +290,7 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { int test = -1; // --cas : minoration de a----------------------------------------------- - R Gi = - ((Xi * Yi * R0 * R0 - X0 * Y0 * Ri * Ri) / detXY + Xi * X0 / (Rmax * Rmax)) / (Yi * Y0); + R Gi = ((Xi * Yi * R0 * R0 - X0 * Y0 * Ri * Ri) / detXY + Xi * X0 / (Rmax * Rmax)) / (Yi * Y0); if (Xi * X0 > 0) { if (Yi * Y0 > 0) { @@ -317,9 +308,7 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { // cas :majoration de a------------------------------------------------ - R Hi = (Xi * X0 * Rmax * Rmax / pow((r0 - epsilon0min), 4) + - (Xi * Yi * R0 * R0 - X0 * Y0 * Ri * Ri) / detXY) / - (Yi * Y0); + R Hi = (Xi * X0 * Rmax * Rmax / pow((r0 - epsilon0min), 4) + (Xi * Yi * R0 * R0 - X0 * Y0 * Ri * Ri) / detXY) / (Yi * Y0); if (Xi * X0 > 0) { if (Yi * Y0 > 0) { bmax = Min(bmax, Hi); @@ -342,9 +331,7 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { Xk = Point[k].x; Yk = Point[k].y; Bk = (Yk * Yk * Xi * X0 + Xk * (Xk * Yi * Y0 - Yk * (Yi * X0 + Xi * Y0))) / (Xi * X0); - Ck = (X0 * Xi * detXY - - Xk * (Xi * R0 * R0 * (Yk * Xi - Yi * Xk) + X0 * Ri * Ri * (-Yk * X0 + Y0 * Xk))) / - (Xi * X0 * detXY); + Ck = (X0 * Xi * detXY - Xk * (Xi * R0 * R0 * (Yk * Xi - Yi * Xk) + X0 * Ri * Ri * (-Yk * X0 + Y0 * Xk))) / (Xi * X0 * detXY); assert(abs(Xi * X0 * Y0 * Yi * Xk * Yk) >= pow(precision, 5)); if (abs(Bk) > precision) { // non nul @@ -380,14 +367,11 @@ void metrique(int nbpoints, R2 *Point, R &A, R &B, R &C, R epsilon) { bik = bmin; } - aik = - (Ri * Ri * Y0 * X0 - R0 * R0 * Yi * Xi + bik * Yi * Y0 * detXY) / (detXY * Xi * X0); - cik = (-Ri * Ri * X0 * X0 + R0 * R0 * Xi * Xi - bik * (Yi * X0 + Y0 * Xi) * detXY) / - (detXY * Xi * X0); + aik = (Ri * Ri * Y0 * X0 - R0 * R0 * Yi * Xi + bik * Yi * Y0 * detXY) / (detXY * Xi * X0); + cik = (-Ri * Ri * X0 * X0 + R0 * R0 * Xi * Xi - bik * (Yi * X0 + Y0 * Xi) * detXY) / (detXY * Xi * X0); - assert((4. * aik * bik - cik * cik) >= 0.); // aire positive - assert(abs((4. * aik * bik - cik * cik) - pow(2. / (Rmax * (r0 - epsilon0)), 2)) > - 0); // aire positive + assert((4. * aik * bik - cik * cik) >= 0.); // aire positive + assert(abs((4. * aik * bik - cik * cik) - pow(2. / (Rmax * (r0 - epsilon0)), 2)) > 0); // aire positive if ((4. * aik * bik - cik * cik) <= (4. * A * B - C * C)) { A = aik; B = bik; @@ -489,10 +473,7 @@ class MetricKuate : public E_F0mps { ~MetricKuate( ) {} - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< pmesh >( ), atype< long >( ), atype< double >( ), atype< double >( ), - atype< double >( ), atype< E_Array >( ), atype< E_Array >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), atype< long >( ), atype< double >( ), atype< double >( ), atype< double >( ), atype< E_Array >( ), atype< E_Array >( )); } static E_F0 *f(const basicAC_F0 &args) { return new MetricKuate(args); } @@ -517,8 +498,7 @@ AnyType MetricKuate::operator( )(Stack stack) const { ffassert(pTh); KN< R2 > Pt(np); const Mesh &Th(*pTh); - cout << " MetricKuate " << np << " hmin = " << hmin << " hmax = " << hmax << " nv = " << Th.nv - << endl; + cout << " MetricKuate " << np << " hmin = " << hmin << " hmax = " << hmax << " nv = " << Th.nv << endl; ffassert(pm11->N( ) == Th.nv); ffassert(pm12->N( ) == Th.nv); @@ -545,9 +525,7 @@ AnyType MetricKuate::operator( )(Stack stack) const { Pt[i].x = *pxx * c / M_E; Pt[i].y = *pyy * c / M_E; if (iv == 0) { - cout << Pt[i] << " ++++ " << i << " " << t << " " << p - << " c = " << R2(*pxx * c / M_E, *pyy * c / M_E) << "e= " << ee << " " << eee << " " - << c << endl; + cout << Pt[i] << " ++++ " << i << " " << t << " " << p << " c = " << R2(*pxx * c / M_E, *pyy * c / M_E) << "e= " << ee << " " << eee << " " << c << endl; } } diff --git a/plugin/seq/MetricPk.cpp b/plugin/seq/MetricPk.cpp index 669e63f85..871b22b07 100644 --- a/plugin/seq/MetricPk.cpp +++ b/plugin/seq/MetricPk.cpp @@ -55,21 +55,13 @@ class MetricPk : public E_F0mps { expu = to< double >(args[1]); // a the expression to get the mesh } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - KN< double > *arg(int i, Stack stack, KN< double > *a) const { - return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : a; - } + KN< double > *arg(int i, Stack stack, KN< double > *a) const { return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : a; } ~MetricPk( ) {} @@ -84,49 +76,28 @@ class MetricPk : public E_F0mps { }; basicAC_F0::name_and_type MetricPk::name_param[MetricPk::n_name_param] = { - {"kDeg", &typeid(long)}, - {"rDeg", &typeid(long)}, - {"iterJacobiDeriv", &typeid(long)}, - {"iterJacobiMetric", &typeid(long)}, - {"Derivatives", &typeid(KN< double > *)}, - {"rmax", &typeid(double)}, - {"mass", &typeid(double)}, - {"TriangulationType", &typeid(long)}, - {"MetricType", &typeid(long)}, - {"pExp", &typeid(double)}}; + {"kDeg", &typeid(long)}, {"rDeg", &typeid(long)}, {"iterJacobiDeriv", &typeid(long)}, {"iterJacobiMetric", &typeid(long)}, {"Derivatives", &typeid(KN< double > *)}, + {"rmax", &typeid(double)}, {"mass", &typeid(double)}, {"TriangulationType", &typeid(long)}, {"MetricType", &typeid(long)}, {"pExp", &typeid(double)}}; AnyType MetricPk::operator( )(Stack stack) const { /************* r�cup�ration des arguments ****************/ - const long k_deg = - arg(0, stack, 2L); // Finite element of degree k_deg will be used for approximation. - const long m_deg = k_deg + 1; // Derivatives of degree m_deg = k_deg+1 will be estimated. - const long m_dim = - m_deg + 1; // The description of these derivatives requires m_dim = m_deg+1 coefficients. - const long nDOFt = - ((k_deg + 1) * (k_deg + 2)) / 2; // Number of Lagrange points on each triangle. - const long r_deg = - arg(1, stack, 1L); // The function is approximated in the W^r,p Sobolev semi-norm. + const long k_deg = arg(0, stack, 2L); // Finite element of degree k_deg will be used for approximation. + const long m_deg = k_deg + 1; // Derivatives of degree m_deg = k_deg+1 will be estimated. + const long m_dim = m_deg + 1; // The description of these derivatives requires m_dim = m_deg+1 coefficients. + const long nDOFt = ((k_deg + 1) * (k_deg + 2)) / 2; // Number of Lagrange points on each triangle. + const long r_deg = arg(1, stack, 1L); // The function is approximated in the W^r,p Sobolev semi-norm. const double p_exp = arg(9, stack, 2.); - const long iterJacobiDeriv = - arg(2, stack, 3L); // The derivatives are slightly smoothed before use. - const long iterJacobiMetric = - arg(3, stack, 3L); // The riemannian metric is slightly smoothed before being returned. - const double rmax = arg(5, stack, 1.); // Not used yet. (Lower bound for the metric) - const double mass = - arg(6, stack, 1000.); // Mass of the metric returned, i.e. mass = int sqrt(det M). + const long iterJacobiDeriv = arg(2, stack, 3L); // The derivatives are slightly smoothed before use. + const long iterJacobiMetric = arg(3, stack, 3L); // The riemannian metric is slightly smoothed before being returned. + const double rmax = arg(5, stack, 1.); // Not used yet. (Lower bound for the metric) + const double mass = arg(6, stack, 1000.); // Mass of the metric returned, i.e. mass = int sqrt(det M). // In practice, bamg produces a mesh with nt=2*mass elements. - const TensorK::triangulation_type ttype = TensorK::triangulation_type( - arg(7, stack, long(0))); // Type of triangulation on which approx will be done. - const TensorK::which_matrix wmat = - TensorK::which_matrix(arg(8, stack, long(1))); // Type of metric. Do not change. + const TensorK::triangulation_type ttype = TensorK::triangulation_type(arg(7, stack, long(0))); // Type of triangulation on which approx will be done. + const TensorK::which_matrix wmat = TensorK::which_matrix(arg(8, stack, long(1))); // Type of metric. Do not change. TensorK tk(m_deg, r_deg, ttype, wmat, p_exp); - cout << "Approximation of " << r_deg << "th derivatives using finite elements of degree " << k_deg - << ", in the L^" << p_exp << " norm.\n"; - cout - << "Triangulation type : " << ttype - << "; Graded=0, Quasi_Acute(refined)=1, Quasi_Acute_Unrefined=2, Quasi_Acute_Proved(refined)=3" - << endl; + cout << "Approximation of " << r_deg << "th derivatives using finite elements of degree " << k_deg << ", in the L^" << p_exp << " norm.\n"; + cout << "Triangulation type : " << ttype << "; Graded=0, Quasi_Acute(refined)=1, Quasi_Acute_Unrefined=2, Quasi_Acute_Proved(refined)=3" << endl; const Mesh *pTh = GetAny< pmesh >((*expTh)(stack)); ffassert(pTh); @@ -143,20 +114,16 @@ AnyType MetricPk::operator( )(Stack stack) const { if (!tk.is_valid) { cout << "Error : Unsupported parameters for MetricPk!\n"; Add2StackOfPtr2Free(stack, pMetric); - return SetAny< KN< double > >( - metric); // identically zero metric is returned in case of error + return SetAny< KN< double > >(metric); // identically zero metric is returned in case of error } // Lagrange points. - const R2 QLagrange[5][15] = { - {R2(1. / 3., 1. / 3.)}, // k_deg=0, barycenter. - {R2(0, 0), R2(1, 0), R2(0, 1)}, - {R2(0, 0), R2(1, 0), R2(0, 1), R2(0.5, 0.5), R2(0, 0.5), R2(0.5, 0)}, - {R2(0, 0), R2(1, 0), R2(0, 1), R2(2. / 3., 1. / 3.), R2(1. / 3., 2. / 3.), R2(0, 2. / 3.), - R2(0, 1. / 3.), R2(1. / 3., 0), R2(2. / 3., 0), R2(1 / 3., 1 / 3.)}, - {R2(0, 0), R2(1, 0), R2(0, 1), R2(3. / 4., 1. / 4.), R2(1. / 2., 1. / 2.), R2(1. / 4., 3. / 4.), - R2(0., 3. / 4.), R2(0., 1. / 2.), R2(0., 1. / 4.), R2(1. / 4., 0), R2(1. / 2., 0), - R2(3. / 4., 0), R2(1. / 4., 1. / 2.), R2(1. / 2., 1. / 4.), R2(1. / 4., 1. / 4.)}}; + const R2 QLagrange[5][15] = {{R2(1. / 3., 1. / 3.)}, // k_deg=0, barycenter. + {R2(0, 0), R2(1, 0), R2(0, 1)}, + {R2(0, 0), R2(1, 0), R2(0, 1), R2(0.5, 0.5), R2(0, 0.5), R2(0.5, 0)}, + {R2(0, 0), R2(1, 0), R2(0, 1), R2(2. / 3., 1. / 3.), R2(1. / 3., 2. / 3.), R2(0, 2. / 3.), R2(0, 1. / 3.), R2(1. / 3., 0), R2(2. / 3., 0), R2(1 / 3., 1 / 3.)}, + {R2(0, 0), R2(1, 0), R2(0, 1), R2(3. / 4., 1. / 4.), R2(1. / 2., 1. / 2.), R2(1. / 4., 3. / 4.), R2(0., 3. / 4.), R2(0., 1. / 2.), R2(0., 1. / 4.), R2(1. / 4., 0), + R2(1. / 2., 0), R2(3. / 4., 0), R2(1. / 4., 1. / 2.), R2(1. / 2., 1. / 4.), R2(1. / 4., 1. / 4.)}}; std::vector< R > aires; aires.resize(nv); // area of the "cell" surrounding a point std::vector< R > Deriv; @@ -180,8 +147,7 @@ AnyType MetricPk::operator( )(Stack stack) const { int iee = ie; const int j = Th.ElementAdj(i, iee); if (j == i || j < 0) { - nextv[Th(i, (ie + 1) % 3)] = - Th(i, (ie + 2) % 3); // nextv[Th(i,(ie+1)%3)]=Th(i,(ie+2)%3); + nextv[Th(i, (ie + 1) % 3)] = Th(i, (ie + 2) % 3); // nextv[Th(i,(ie+1)%3)]=Th(i,(ie+2)%3); } } } @@ -191,9 +157,7 @@ AnyType MetricPk::operator( )(Stack stack) const { const Triangle &K = Th[i]; const R2 sommets[3] = {K(R2(0, 0)), K(R2(1, 0)), K(R2(0, 1))}; const R aire = det(sommets[0], sommets[1], sommets[2]) / 2; - const R2 invHauteur[3] = {perp(sommets[1] - sommets[2]) / (2 * aire), - perp(sommets[2] - sommets[0]) / (2 * aire), - perp(sommets[0] - sommets[1]) / (2 * aire)}; + const R2 invHauteur[3] = {perp(sommets[1] - sommets[2]) / (2 * aire), perp(sommets[2] - sommets[0]) / (2 * aire), perp(sommets[0] - sommets[1]) / (2 * aire)}; for (int dof = 0; dof < nDOFt; ++dof) { // Degrees of freedom on the triangle const R2 Point = K(QLagrange[k_deg][dof]); @@ -209,11 +173,9 @@ AnyType MetricPk::operator( )(Stack stack) const { tk.getDerivatives(DOFt, invHauteur, f); // f={fx,fy} for (int j = 0; j < 3; ++j) { - const int s = Th(i, j); // le sommet j du triangle i - Deriv[m_dim * s + 0] += - aire * f[0] * invHauteur[j].x; // contribution � l'estimation des d�riv�es secondes. - Deriv[m_dim * s + 1] += - aire * (f[0] * invHauteur[j].y / 2. + f[1] * invHauteur[j].x / 2.); + const int s = Th(i, j); // le sommet j du triangle i + Deriv[m_dim * s + 0] += aire * f[0] * invHauteur[j].x; // contribution � l'estimation des d�riv�es secondes. + Deriv[m_dim * s + 1] += aire * (f[0] * invHauteur[j].y / 2. + f[1] * invHauteur[j].x / 2.); Deriv[m_dim * s + 2] += aire * f[1] * invHauteur[j].y; aires[s] += aire; } @@ -226,13 +188,9 @@ AnyType MetricPk::operator( )(Stack stack) const { for (int j = 0; j < 3; ++j) { const int s = Th(i, j); - Deriv[m_dim * s + 0] += - aire * f[0] * - invHauteur[j].x; // contribution � l'estimation des d�riv�es troisi�mes. - Deriv[m_dim * s + 1] += - aire * (f[0] * invHauteur[j].y / 3. + f[1] * invHauteur[j].x * 2. / 3.); - Deriv[m_dim * s + 2] += - aire * (f[2] * invHauteur[j].x / 3. + f[1] * invHauteur[j].y * 2. / 3.); + Deriv[m_dim * s + 0] += aire * f[0] * invHauteur[j].x; // contribution � l'estimation des d�riv�es troisi�mes. + Deriv[m_dim * s + 1] += aire * (f[0] * invHauteur[j].y / 3. + f[1] * invHauteur[j].x * 2. / 3.); + Deriv[m_dim * s + 2] += aire * (f[2] * invHauteur[j].x / 3. + f[1] * invHauteur[j].y * 2. / 3.); Deriv[m_dim * s + 3] += aire * f[2] * invHauteur[j].y; aires[s] += aire; } @@ -245,14 +203,10 @@ AnyType MetricPk::operator( )(Stack stack) const { for (int j = 0; j < 3; ++j) { const int s = Th(i, j); - Deriv[m_dim * s + 0] += f[0] * invHauteur[j].x * - aire; // contribution � l'estimation des d�riv�es quatri�mes. - Deriv[m_dim * s + 1] += - (f[0] * invHauteur[j].y / 4. + f[1] * invHauteur[j].x * 3. / 4.) * aire; - Deriv[m_dim * s + 2] += - (f[1] * invHauteur[j].y / 2. + f[2] * invHauteur[j].x / 2.) * aire; - Deriv[m_dim * s + 3] += - (f[2] * invHauteur[j].y * 3. / 4. + f[3] * invHauteur[j].x / 4.) * aire; + Deriv[m_dim * s + 0] += f[0] * invHauteur[j].x * aire; // contribution � l'estimation des d�riv�es quatri�mes. + Deriv[m_dim * s + 1] += (f[0] * invHauteur[j].y / 4. + f[1] * invHauteur[j].x * 3. / 4.) * aire; + Deriv[m_dim * s + 2] += (f[1] * invHauteur[j].y / 2. + f[2] * invHauteur[j].x / 2.) * aire; + Deriv[m_dim * s + 3] += (f[2] * invHauteur[j].y * 3. / 4. + f[3] * invHauteur[j].x / 4.) * aire; Deriv[m_dim * s + 4] += f[3] * invHauteur[j].y * aire; aires[s] += aire; } @@ -265,22 +219,17 @@ AnyType MetricPk::operator( )(Stack stack) const { for (int j = 0; j < 3; ++j) { const int s = Th(i, j); - Deriv[m_dim * s + 0] += f[0] * invHauteur[j].x * - aire; // contribution � l'estimation des d�riv�es quatri�mes. - Deriv[m_dim * s + 1] += - (f[0] * invHauteur[j].y / 5. + f[1] * invHauteur[j].x * 4. / 5.) * aire; - Deriv[m_dim * s + 2] += - (f[1] * invHauteur[j].y * 2. / 5. + f[2] * invHauteur[j].x * 3. / 5.) * aire; - Deriv[m_dim * s + 3] += - (f[2] * invHauteur[j].y * 3. / 5. + f[3] * invHauteur[j].x * 2. / 5.) * aire; - Deriv[m_dim * s + 4] += - (f[3] * invHauteur[j].y * 4. / 5. + f[4] * invHauteur[j].x / 5.) * aire; + Deriv[m_dim * s + 0] += f[0] * invHauteur[j].x * aire; // contribution � l'estimation des d�riv�es quatri�mes. + Deriv[m_dim * s + 1] += (f[0] * invHauteur[j].y / 5. + f[1] * invHauteur[j].x * 4. / 5.) * aire; + Deriv[m_dim * s + 2] += (f[1] * invHauteur[j].y * 2. / 5. + f[2] * invHauteur[j].x * 3. / 5.) * aire; + Deriv[m_dim * s + 3] += (f[2] * invHauteur[j].y * 3. / 5. + f[3] * invHauteur[j].x * 2. / 5.) * aire; + Deriv[m_dim * s + 4] += (f[3] * invHauteur[j].y * 4. / 5. + f[4] * invHauteur[j].x / 5.) * aire; Deriv[m_dim * s + 5] += f[4] * invHauteur[j].y * aire; aires[s] += aire; } } // case m_deg==5 - } // switch m_deg - } // for i triangle + } // switch m_deg + } // for i triangle for (int i = 0; i < nv; ++i) { for (int j = 0; j < m_dim; ++j) { @@ -324,8 +273,7 @@ AnyType MetricPk::operator( )(Stack stack) const { const int u = dist[i].first; const int du = dist[i].second; computed.insert(u); - const pair< multimap< int, int >::iterator, multimap< int, int >::iterator > ret = - connectivity.equal_range(u); + const pair< multimap< int, int >::iterator, multimap< int, int >::iterator > ret = connectivity.equal_range(u); for (multimap< int, int >::iterator it = ret.first; it != ret.second; ++it) { const int v = it->second; @@ -345,8 +293,7 @@ AnyType MetricPk::operator( )(Stack stack) const { continue; } - const pair< multimap< int, int >::iterator, multimap< int, int >::iterator > neighbors = - connectivity.equal_range(u); + const pair< multimap< int, int >::iterator, multimap< int, int >::iterator > neighbors = connectivity.equal_range(u); int closer_neighbors = 0; for (multimap< int, int >::iterator it = neighbors.first; it != neighbors.second; ++it) { @@ -397,7 +344,7 @@ AnyType MetricPk::operator( )(Stack stack) const { DerivNew[m_dim * v + k] += sum; DerivNew[m_dim * w + k] += sum; } // for k - } // for i triangles + } // for i triangles for (int i = 0; i < nv; ++i) { for (int k = 0; k < m_dim; ++k) { @@ -458,7 +405,7 @@ AnyType MetricPk::operator( )(Stack stack) const { ih_metricNew[3 * v + k] += sum; ih_metricNew[3 * w + k] += sum; } // for k - } // for i triangles + } // for i triangles for (int i = 0; i < nv; ++i) { for (int k = 0; k < 3; ++k) { @@ -478,11 +425,8 @@ AnyType MetricPk::operator( )(Stack stack) const { const long d_dim = 2; // Space Dimension : 2 // M : Metric for the L^p norm, M_0 metric for the L^infty norm - const R alpha = -1. / ((m_deg - r_deg) * p_exp + d_dim); // M = (det M_0)^alpha M_0 - const R beta = - (m_deg - r_deg) * p_exp / - (((m_deg - r_deg) * p_exp + d_dim) * - 2.); // integrate sqrt(det M) = integrate (det M_0)^beta; beta = (alpha*d_dim+1)/2. + const R alpha = -1. / ((m_deg - r_deg) * p_exp + d_dim); // M = (det M_0)^alpha M_0 + const R beta = (m_deg - r_deg) * p_exp / (((m_deg - r_deg) * p_exp + d_dim) * 2.); // integrate sqrt(det M) = integrate (det M_0)^beta; beta = (alpha*d_dim+1)/2. for (int i = 0; i < nv; ++i) { aires[i] /= 3; @@ -497,13 +441,11 @@ AnyType MetricPk::operator( )(Stack stack) const { R totalMass = 0; for (int i = 0; i < nv; ++i) { - totalMass += - aires[i] * pow(TensorK::det(&ih_metric[3 * i]), beta); // Eigen[i][0]*Eigen[i][1] + totalMass += aires[i] * pow(TensorK::det(&ih_metric[3 * i]), beta); // Eigen[i][0]*Eigen[i][1] } - const R gamma = - pow(mass / totalMass, - 1. / (beta * d_dim)); // gamma satisfies integrate (det (gamma M_0) )^beta = mass + const R gamma = pow(mass / totalMass, + 1. / (beta * d_dim)); // gamma satisfies integrate (det (gamma M_0) )^beta = mass for (int i = 0; i < nv; ++i) { const R lambda = gamma * pow(square(gamma) * TensorK::det(&ih_metric[3 * i]), diff --git a/plugin/seq/Morley.cpp b/plugin/seq/Morley.cpp index c2a56a965..289a18d6c 100644 --- a/plugin/seq/Morley.cpp +++ b/plugin/seq/Morley.cpp @@ -90,8 +90,7 @@ namespace Fem2D { }; // on what nu df on node node of df - int TypeOfFE_P2Morley::Data[] = {0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, - 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 6, 6, 6}; + int TypeOfFE_P2Morley::Data[] = {0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 6, 6, 6}; void TypeOfFE_P2Morley::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { const Triangle &T(K.T); int k = 0; @@ -110,8 +109,7 @@ namespace Fem2D { } } - void TypeOfFE_P2Morley::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, - RNMK_ &val) const { + void TypeOfFE_P2Morley::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { typedef double R; R2 A(K[0]), B(K[1]), C(K[2]); R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; @@ -232,7 +230,7 @@ namespace Fem2D { } { - int vop[last_operatortype] = {}, nop = 0; + int vop[last_operatortype] = { }, nop = 0; for (int j = 0; j < last_operatortype; j++) { if (wd[j]) { @@ -291,123 +289,112 @@ namespace Fem2D { } } -//Morley 3d - -class TypeOfFE_Morley_3d : public GTypeOfFE< Mesh3 > { - public: - typedef Mesh3 Mesh; - typedef Mesh3::Element Element; - typedef GFElement< Mesh3 > FElement; - - static int dfon[]; - static const int d = Mesh::Rd::d; - static const GQuadratureFormular< R1 > QFe; // quadrature formula on an edge - static const GQuadratureFormular< R2 > QFf; // quadrature formula on a face - TypeOfFE_Morley_3d( ); // constructor - void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, - RNMK_ &val) const; - void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, - int *nump) const; -}; - -int TypeOfFE_Morley_3d::dfon[] = {0, 1, 1, 0}; // 1 dofs on each edge, 1 dofs on each face - -// Quadrature formula on an edge, exact for degree 2 (ok: int_e (deg2*t *lambda)) -const GQuadratureFormular< R1 > TypeOfFE_Morley_3d::QFe(-1 + 2 * 2, 2, GaussLegendre(2), true); -// arguments: exact, num of integration pts, integration pts, clean (~GQuadratureFormular() -// {if(clean) delete [] p;}) GaussLegendre defined in QuadratureFormular.cpp - -// Quadrature formula on a face, exact for degree 2 (ok: int_f (deg2*t)), internal quadrature -// points -static GQuadraturePoint< R2 > P_QuadratureFormular_T_2_intp[3] = { - GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 4. / 6.)), - GQuadraturePoint< R2 >(1. / 3., R2(4. / 6., 1. / 6.)), - GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 1. / 6.))}; -const GQuadratureFormular< R2 > TypeOfFE_Morley_3d::QFf(2, 3, P_QuadratureFormular_T_2_intp); - -TypeOfFE_Morley_3d::TypeOfFE_Morley_3d( ) - : GTypeOfFE< Mesh3 >(TypeOfFE_Morley_3d::dfon, d+1, 1, - Element::ne * QFe.n + Element::nf * 3 * QFf.n, - Element::ne * QFe.n + Element::nf * QFf.n, false, true) { - assert(QFe.n); - assert(QFf.n); - R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), - R3(0., 0., 1.)}; // 4 ref tetrahedron vertices - - { - // We build the interpolation pts on the edges of the reference tetrahedron: - int i; - i = 0; - - for (int e = 0; e < Element::ne; ++e) { - for (int q = 0; q < QFe.n; ++q, ++i) { - double x = QFe[q].x; - this->PtInterpolation[i] = - Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); + // Morley 3d + + class TypeOfFE_Morley_3d : public GTypeOfFE< Mesh3 > { + public: + typedef Mesh3 Mesh; + typedef Mesh3::Element Element; + typedef GFElement< Mesh3 > FElement; + + static int dfon[]; + static const int d = Mesh::Rd::d; + static const GQuadratureFormular< R1 > QFe; // quadrature formula on an edge + static const GQuadratureFormular< R2 > QFf; // quadrature formula on a face + TypeOfFE_Morley_3d( ); // constructor + void FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; + }; + + int TypeOfFE_Morley_3d::dfon[] = {0, 1, 1, 0}; // 1 dofs on each edge, 1 dofs on each face + + // Quadrature formula on an edge, exact for degree 2 (ok: int_e (deg2*t *lambda)) + const GQuadratureFormular< R1 > TypeOfFE_Morley_3d::QFe(-1 + 2 * 2, 2, GaussLegendre(2), true); + // arguments: exact, num of integration pts, integration pts, clean (~GQuadratureFormular() + // {if(clean) delete [] p;}) GaussLegendre defined in QuadratureFormular.cpp + + // Quadrature formula on a face, exact for degree 2 (ok: int_f (deg2*t)), internal quadrature + // points + static GQuadraturePoint< R2 > P_QuadratureFormular_T_2_intp[3] = {GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 4. / 6.)), GQuadraturePoint< R2 >(1. / 3., R2(4. / 6., 1. / 6.)), + GQuadraturePoint< R2 >(1. / 3., R2(1. / 6., 1. / 6.))}; + const GQuadratureFormular< R2 > TypeOfFE_Morley_3d::QFf(2, 3, P_QuadratureFormular_T_2_intp); + + TypeOfFE_Morley_3d::TypeOfFE_Morley_3d( ) + : GTypeOfFE< Mesh3 >(TypeOfFE_Morley_3d::dfon, d + 1, 1, Element::ne * QFe.n + Element::nf * 3 * QFf.n, Element::ne * QFe.n + Element::nf * QFf.n, false, true) { + assert(QFe.n); + assert(QFf.n); + R3 Pt[] = {R3(0., 0., 0.), R3(1., 0., 0.), R3(0., 1., 0.), R3(0., 0., 1.)}; // 4 ref tetrahedron vertices + + { + // We build the interpolation pts on the edges of the reference tetrahedron: + int i; + i = 0; + + for (int e = 0; e < Element::ne; ++e) { + for (int q = 0; q < QFe.n; ++q, ++i) { + double x = QFe[q].x; + this->PtInterpolation[i] = Pt[Element::nvedge[e][0]] * (1. - x) + Pt[Element::nvedge[e][1]] * (x); + } } - } - // We build the interpolation pts on the faces of the reference tetrahedron: - // (the index i mustn't be reinitialised!) - for (int f = 0; f < Element::nf; ++f) { - for (int q = 0; q < QFf.n; ++q, ++i) { - double x = QFf[q].x; - double y = QFf[q].y; - this->PtInterpolation[i] = Pt[Element::nvface[f][0]] * (1. - x - y) + - Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; + // We build the interpolation pts on the faces of the reference tetrahedron: + // (the index i mustn't be reinitialised!) + for (int f = 0; f < Element::nf; ++f) { + for (int q = 0; q < QFf.n; ++q, ++i) { + double x = QFf[q].x; + double y = QFf[q].y; + this->PtInterpolation[i] = Pt[Element::nvface[f][0]] * (1. - x - y) + Pt[Element::nvface[f][1]] * x + Pt[Element::nvface[f][2]] * y; + } } } - } - { - // We build the indices in (13.1) : edge dofs - int i = 0, p = 0; // i is the k in (13.1) (chapter 13 ff++doc) - int e; // we will need e also below, in the part referred to faces - - for (e = 0; e < (Element::ne); e++) { // loop on the 6 dofs - - for (int q = 0; q < QFe.n; ++q, ++p) { // loop on the 2 edge quadrature pts - { // loop on the 3 components - this->pInterpolation[i] = p; // pk in (13.1) - this->cInterpolation[i] = 0; // jk in (13.1) - this->dofInterpolation[i] = e; // ik in (13.1) - this->coefInterpolation[i] = 0.; // alfak: we will fill them with 'set' (below) - // because they depend on the tetrahedron + { + // We build the indices in (13.1) : edge dofs + int i = 0, p = 0; // i is the k in (13.1) (chapter 13 ff++doc) + int e; // we will need e also below, in the part referred to faces + + for (e = 0; e < (Element::ne); e++) { // loop on the 6 dofs + + for (int q = 0; q < QFe.n; ++q, ++p) { // loop on the 2 edge quadrature pts + { // loop on the 3 components + this->pInterpolation[i] = p; // pk in (13.1) + this->cInterpolation[i] = 0; // jk in (13.1) + this->dofInterpolation[i] = e; // ik in (13.1) + this->coefInterpolation[i] = 0.; // alfak: we will fill them with 'set' (below) + // because they depend on the tetrahedron + } } } - } - // We build the indices in (13.1) : face dofs - // (the indices i and p mustn't be reinitialised) - for (int f = 0; f < (Element::nf); f++) { // loop on the 4 dofs - - for (int q = 0; q < QFf.n; ++q, ++p) { // loop on the 3 face quadrature pts - for (int c = 0; c < 3; c++, i++) { // loop on the 3 components - this->pInterpolation[i] = p; // pk in (13.1) - this->cInterpolation[i] = 1+c; // jk in (13.1) - this->dofInterpolation[i] = e + f; // ik in (13.1) - this->coefInterpolation[i] = 0.; // alphak: we will fill them with 'set' (below) - // because they depend on the tetrahedron + // We build the indices in (13.1) : face dofs + // (the indices i and p mustn't be reinitialised) + for (int f = 0; f < (Element::nf); f++) { // loop on the 4 dofs + + for (int q = 0; q < QFf.n; ++q, ++p) { // loop on the 3 face quadrature pts + for (int c = 0; c < 3; c++, i++) { // loop on the 3 components + this->pInterpolation[i] = p; // pk in (13.1) + this->cInterpolation[i] = 1 + c; // jk in (13.1) + this->dofInterpolation[i] = e + f; // ik in (13.1) + this->coefInterpolation[i] = 0.; // alphak: we will fill them with 'set' (below) + // because they depend on the tetrahedron + } } } } } -} -void TypeOfFE_Morley_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, - int ocoef, int odf, int *nump) const { - ffassert(0); // to do F. Hecht -} -void TypeOfFE_Morley_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, - const RdHat &PHat, RNMK_ &val) const { - ffassert(0); // to do F. Hecht -} + void TypeOfFE_Morley_3d::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const { + ffassert(0); // to do F. Hecht + } + void TypeOfFE_Morley_3d::FB(const What_d whatd, const Mesh &Th, const Mesh3::Element &K, const RdHat &PHat, RNMK_ &val) const { + ffassert(0); // to do F. Hecht + } // a static variable to add the finite element to freefem++ static TypeOfFE_P2Morley P2LagrangeP2Morley; static AddNewFE P2Morley("P2Morley", &P2LagrangeP2Morley); -static TypeOfFE_Morley_3d Morley_3d; // TypeOfFE_Edge1_3d is the name of the class we defined -GTypeOfFE< Mesh3 > &GMorley3d(Morley_3d); // GTypeOfFE is the mother class -static AddNewFE3 AddGMorley3d("Morley3d", &GMorley3d); // Edge13d will be the name used by the user + static TypeOfFE_Morley_3d Morley_3d; // TypeOfFE_Edge1_3d is the name of the class we defined + GTypeOfFE< Mesh3 > &GMorley3d(Morley_3d); // GTypeOfFE is the mother class + static AddNewFE3 AddGMorley3d("Morley3d", &GMorley3d); // Edge13d will be the name used by the user } // namespace Fem2D // --- fin -- diff --git a/plugin/seq/PARDISO.cpp b/plugin/seq/PARDISO.cpp index 401597bcf..f3b6c6f4d 100644 --- a/plugin/seq/PARDISO.cpp +++ b/plugin/seq/PARDISO.cpp @@ -42,43 +42,38 @@ extern void omp_set_num_threads(int); template< typename RR > struct PARDISO_STRUC_TRAIT { - typedef void R; - static const int unSYM = 0; - static const int HERM = 0; - static const int SPD = 0; - static const int SYM = 0; - static const char * name(){return "";} + typedef void R; + static const int unSYM = 0; + static const int HERM = 0; + static const int SPD = 0; + static const int SYM = 0; + static const char *name( ) { return ""; } }; template<> struct PARDISO_STRUC_TRAIT< double > { - typedef double R; - static const int unSYM = 11; - static const int SYM = -2;// Real symmetric matrix undef (2: def ...) - static const int SPD = 2;// - static const int HERM = -2;// same as SYM - static const char * name(){return "double";} - - + typedef double R; + static const int unSYM = 11; + static const int SYM = -2; // Real symmetric matrix undef (2: def ...) + static const int SPD = 2; // + static const int HERM = -2; // same as SYM + static const char *name( ) { return "double"; } }; template<> struct PARDISO_STRUC_TRAIT< Complex > { typedef Complex R; static const int unSYM = 13; - static const int HERM = -4;// Complex and Hermitian indefinite - static const int SPD = 4;// Complex and Hermitian positive definite - static const int SYM = 6;// Complex and symmetric matrix + static const int HERM = -4; // Complex and Hermitian indefinite + static const int SPD = 4; // Complex and Hermitian positive definite + static const int SYM = 6; // Complex and symmetric matrix - static const char * name(){return "complex";} + static const char *name( ) { return "complex"; } }; -void mkl_csrcsc(MKL_INT *job, MKL_INT *n, Complex *Acsr, MKL_INT *AJ0, MKL_INT *AI0, Complex *Acsc, - MKL_INT *AJ1, MKL_INT *AI1, MKL_INT *info) { - mkl_zcsrcsc(job, n, reinterpret_cast< MKL_Complex16 * >(Acsr), AJ0, AI0, - reinterpret_cast< MKL_Complex16 * >(Acsc), AJ1, AI1, info); +void mkl_csrcsc(MKL_INT *job, MKL_INT *n, Complex *Acsr, MKL_INT *AJ0, MKL_INT *AI0, Complex *Acsc, MKL_INT *AJ1, MKL_INT *AI1, MKL_INT *info) { + mkl_zcsrcsc(job, n, reinterpret_cast< MKL_Complex16 * >(Acsr), AJ0, AI0, reinterpret_cast< MKL_Complex16 * >(Acsc), AJ1, AI1, info); } -void mkl_csrcsc(MKL_INT *job, MKL_INT *n, double *Acsr, MKL_INT *AJ0, MKL_INT *AI0, double *Acsc, - MKL_INT *AJ1, MKL_INT *AI1, MKL_INT *info) { +void mkl_csrcsc(MKL_INT *job, MKL_INT *n, double *Acsr, MKL_INT *AJ0, MKL_INT *AI0, double *Acsc, MKL_INT *AJ1, MKL_INT *AI1, MKL_INT *info) { mkl_dcsrcsc(job, n, Acsr, AJ0, AI0, Acsc, AJ1, AI1, info); } @@ -107,55 +102,50 @@ class SolverPardiso : public VirtualSolver< int, R > { static const int orTypeSol = 1 | 2 | 4 | 8 | 16 | 32; // Do all static const MKL_INT pmtype_unset = -1000000000; typedef typename PARDISO_STRUC_TRAIT< R >::R MR; - SolverPardiso(HMat &AH, const Data_Sparse_Solver &ds, Stack stack) - : ptA(&AH), ia(0), ja(0), a(0), verb(ds.verb), cn(0), cs(0), pmtype(pmtype_unset) { + SolverPardiso(HMat &AH, const Data_Sparse_Solver &ds, Stack stack) : ptA(&AH), ia(0), ja(0), a(0), verb(ds.verb), cn(0), cs(0), pmtype(pmtype_unset) { if (verb > 2) - cout << " SolverPardiso " << this << " mat: " << ptA << "sym " << ds.sym << " half " - << ptA->half << " spd " << ds.positive << " on type: " << PARDISO_STRUC_TRAIT< R >::name() << endl; + cout << " SolverPardiso " << this << " mat: " << ptA << "sym " << ds.sym << " half " << ptA->half << " spd " << ds.positive << " on type: " << PARDISO_STRUC_TRAIT< R >::name( ) << endl; if (ds.lparams.N( ) > 1) pmtype = ds.lparams[0]; // bof bof ... fill(iparm, iparm + 64, 0); fill(pt, pt + 64, (void *)0); - iparm[0] = 1; /* No solver default */ - iparm[1] = 2; /* Fill-in reordering from METIS */ - iparm[3] = 0; /* No iterative-direct algorithm */ - iparm[4] = 0; /* No user fill-in reducing permutation */ - iparm[5] = 0; /* Write solution into x */ - iparm[6] = 0; /* Not in use */ - iparm[7] = 2; /* Max numbers of iterative refinement steps */ - iparm[8] = 0; /* Not in use */ - iparm[9] = 13; /* Perturb the pivot elements with 1E-13 */ - iparm[10] = 1; /* Use nonsymmetric permutation and scaling MPS */ - iparm[11] = 0; /* Not in use */ - iparm[12] = 0; /* Maximum weighted matching algorithm is switched-off (default for symmetric). - Try iparm[12] = 1 in case of inappropriate accuracy */ - iparm[13] = 0; /* Output: Number of perturbed pivots */ - iparm[14] = 0; /* Not in use */ - iparm[15] = 0; /* Not in use */ - iparm[16] = 0; /* Not in use */ - iparm[17] = -1; /* Output: Number of nonzeros in the factor LU */ - iparm[18] = -1; /* Output: Mflops for LU factorization */ - iparm[19] = 0; /* Output: Numbers of CG Iterations */ - maxfct = 1; /* Maximum number of numerical factorizations. */ - mnum = 1; /* Which factorization to use. */ + iparm[0] = 1; /* No solver default */ + iparm[1] = 2; /* Fill-in reordering from METIS */ + iparm[3] = 0; /* No iterative-direct algorithm */ + iparm[4] = 0; /* No user fill-in reducing permutation */ + iparm[5] = 0; /* Write solution into x */ + iparm[6] = 0; /* Not in use */ + iparm[7] = 2; /* Max numbers of iterative refinement steps */ + iparm[8] = 0; /* Not in use */ + iparm[9] = 13; /* Perturb the pivot elements with 1E-13 */ + iparm[10] = 1; /* Use nonsymmetric permutation and scaling MPS */ + iparm[11] = 0; /* Not in use */ + iparm[12] = 0; /* Maximum weighted matching algorithm is switched-off (default for symmetric). + Try iparm[12] = 1 in case of inappropriate accuracy */ + iparm[13] = 0; /* Output: Number of perturbed pivots */ + iparm[14] = 0; /* Not in use */ + iparm[15] = 0; /* Not in use */ + iparm[16] = 0; /* Not in use */ + iparm[17] = -1; /* Output: Number of nonzeros in the factor LU */ + iparm[18] = -1; /* Output: Mflops for LU factorization */ + iparm[19] = 0; /* Output: Numbers of CG Iterations */ + maxfct = 1; /* Maximum number of numerical factorizations. */ + mnum = 1; /* Which factorization to use. */ msglvl = verb > 4; /* Print statistical information in file */ error = 0; //(const MatriceMorse &A, KN ¶m_int, KN ¶m_double) { if (ptA->half) - if ( ds.positive) { - ffassert(ptA->half == 1); - mtype = PARDISO_STRUC_TRAIT< R >::SPD; /* Real symmetric matrix undef*/ - } - else - mtype = ptA->half == 1 ? PARDISO_STRUC_TRAIT< R >::HERM : PARDISO_STRUC_TRAIT< R >::SYM ; /* Real symmetric matrix undef*/ + if (ds.positive) { + ffassert(ptA->half == 1); + mtype = PARDISO_STRUC_TRAIT< R >::SPD; /* Real symmetric matrix undef*/ + } else + mtype = ptA->half == 1 ? PARDISO_STRUC_TRAIT< R >::HERM : PARDISO_STRUC_TRAIT< R >::SYM; /* Real symmetric matrix undef*/ else - mtype = PARDISO_STRUC_TRAIT< R >::unSYM; // Real 11/ complex 13 CSR + mtype = PARDISO_STRUC_TRAIT< R >::unSYM; // Real 11/ complex 13 CSR nrhs = 0; } void UpdateState( ) { - if (verb > 2 || verbosity > 9) - std::cout << " UpdateState " << ptA->re_do_numerics << " " << ptA->re_do_symbolic - << std::endl; + if (verb > 2 || verbosity > 9) std::cout << " UpdateState " << ptA->re_do_numerics << " " << ptA->re_do_symbolic << std::endl; if (ptA->GetReDoNumerics( )) cn++; if (ptA->GetReDoSymbolic( )) cs++; this->ChangeCodeState(ptA->n, cs, cn); @@ -170,14 +160,12 @@ class SolverPardiso : public VirtualSolver< int, R > { } if (verb > 99) for (int i = 0; i < n; ++i) - for (int k = ia[i] - 1; k < ia[i + 1]; ++k) - cout << i + 1 << " " << ja[k] << " " << a[k] << endl; + for (int k = ia[i] - 1; k < ia[i + 1]; ++k) cout << i + 1 << " " << ja[k] << " " << a[k] << endl; } void fac_symbolic( ) { // phase 11 phase = 11; - PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, - &ddum, &error); + PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error); if (error != 0) { printf("\nERROR during symbolic factorization: %d\n", error); exit(1); @@ -190,8 +178,7 @@ class SolverPardiso : public VirtualSolver< int, R > { } void fac_numeric( ) { phase = 22; - PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, - &ddum, &error); + PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error); if (error != 0) { printf("\nERROR during numerical factorization: %d", error); exit(2); @@ -205,8 +192,7 @@ class SolverPardiso : public VirtualSolver< int, R > { iparm[11] = trans; // /* Set right hand side to one. */ - PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, b, x, - &error); + PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, a, ia, ja, &idum, &nrhs, iparm, &msglvl, b, x, &error); if (error != 0) { printf("\nERROR during solution: %d", error); exit(3); @@ -216,8 +202,7 @@ class SolverPardiso : public VirtualSolver< int, R > { ~SolverPardiso( ) { // Warning the solver is del afer the Matrix ptA; - if (verb > 99) - cout << " ~SolverPardiso" << this << " " << ptA << " " << ptA->type_state << endl; + if (verb > 99) cout << " ~SolverPardiso" << this << " " << ptA << " " << ptA->type_state << endl; if (ptA->type_state != HMat::type_isdeleted) { ptA->setfortran(false); ptA->HM( ); @@ -225,8 +210,7 @@ class SolverPardiso : public VirtualSolver< int, R > { nrhs = 0; phase = -1; /* Release internal memory. */ - PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, &ddum, ia, ja, &idum, &nrhs, iparm, &msglvl, - &ddum, &ddum, &error); + PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &n, &ddum, ia, ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error); } }; diff --git a/plugin/seq/RZ.h b/plugin/seq/RZ.h index 9f00eb44b..28a6d30f9 100644 --- a/plugin/seq/RZ.h +++ b/plugin/seq/RZ.h @@ -127,9 +127,7 @@ class RZ : totally_ordered< RZ > { // could have used std::pair but too late bool operator==(const RZ &L) const { return distance == L.distance && number == L.number; } - bool operator<(const RZ &L) const { - return distance < L.distance || (distance == L.distance && number < L.number); - } + bool operator<(const RZ &L) const { return distance < L.distance || (distance == L.distance && number < L.number); } RZ MIN( ) { return RZ(-DBL_MAX, INT_MIN); } @@ -152,8 +150,8 @@ template< class ring > class BiDim : vector_space< BiDim< ring >, ring >, totally_ordered< BiDim< ring > > { public: ring x, y; - BiDim( ) : x(0), y(0){}; - BiDim(ring X, ring Y) : x(X), y(Y){}; + BiDim( ) : x(0), y(0) {}; + BiDim(ring X, ring Y) : x(X), y(Y) {}; BiDim &operator*=(ring c) { x *= c; y *= c; @@ -186,15 +184,10 @@ class BiDim : vector_space< BiDim< ring >, ring >, totally_ordered< BiDim< ring const BiDim operator-( ) const { return BiDim(-x, -y); } - const BiDim lin_sum(const BiDim &P, const BiDim &Q) const { - return BiDim(x * P.x + y * Q.x, x * P.y + y * Q.y); - }; // produit [P,Q] *this - const TriDim< ring > lin_sum(const TriDim< ring > &P, const TriDim< ring > &Q) const { - return TriDim< ring >(x * P.x + y * Q.x, x * P.y + y * Q.y, x * P.z + y * Q.z); - } + const BiDim lin_sum(const BiDim &P, const BiDim &Q) const { return BiDim(x * P.x + y * Q.x, x * P.y + y * Q.y); }; // produit [P,Q] *this + const TriDim< ring > lin_sum(const TriDim< ring > &P, const TriDim< ring > &Q) const { return TriDim< ring >(x * P.x + y * Q.x, x * P.y + y * Q.y, x * P.z + y * Q.z); } - const BiDim lin_solve(const BiDim &P, const BiDim &Q) - const; // coefficients de *this dans la base (P,Q) : [P,Q]^{-1} *this. + const BiDim lin_solve(const BiDim &P, const BiDim &Q) const; // coefficients de *this dans la base (P,Q) : [P,Q]^{-1} *this. ring prod( ) const { return x * y; } @@ -253,8 +246,7 @@ ring det(const BiDim< ring > &P, const BiDim< ring > &Q) { inline R2 ZdtoRd(const Z2 &P) { return R2(P.x, P.y); } template< class ring > -const BiDim< ring > BiDim< ring >::lin_solve(const BiDim< ring > &P, const BiDim< ring > &Q) - const { // coefficients de *this dans la base (P,Q) : [P,Q]^{-1} *this. +const BiDim< ring > BiDim< ring >::lin_solve(const BiDim< ring > &P, const BiDim< ring > &Q) const { // coefficients de *this dans la base (P,Q) : [P,Q]^{-1} *this. ring Det = P.x * Q.y - P.y * Q.x; if (Det == 0) { @@ -264,8 +256,7 @@ const BiDim< ring > BiDim< ring >::lin_solve(const BiDim< ring > &P, const BiDim ring invDet = 1 / Det; if (invDet == 0) { - cout << name << "::lin_solve error : determinant is not invertible " << Det << "; " << P << "; " - << Q << endl; + cout << name << "::lin_solve error : determinant is not invertible " << Det << "; " << P << "; " << Q << endl; return NABiDim; } @@ -283,7 +274,7 @@ class sym2 : vector_space< sym2, double > { sym2(double lambda, double mu, const R2 &P); sym2(const sym2 &S) : xx(S.xx), xy(S.xy), yy(S.yy) {} - explicit sym2(double s) : xx(s), xy(0), yy(s){}; + explicit sym2(double s) : xx(s), xy(0), yy(s) {}; template< class ring > double norm2(const BiDim< ring > &P) const { @@ -399,8 +390,7 @@ inline sym2::sym2(double lambda, double mu, const R2 &P) { yy = nu * Q.y * Q.y + mu; } -inline R2 sym2::eigensys(double E[2]) - const { // petite puis grande vap. vecteur propre associé à la petite valeur propre +inline R2 sym2::eigensys(double E[2]) const { // petite puis grande vap. vecteur propre associé à la petite valeur propre eigen(E); const double div = E[0] * E[0] - E[1] * E[1]; if (div == 0.) { @@ -436,8 +426,7 @@ inline sym2 sym2::sqrtSym( ) const { eigen(E); sym2 Sq(*this); - assert_msg(E[0] >= 0 && E[1] > 0, - "sym2::sqrtSym error : non positive definite matrix. " << *this); + assert_msg(E[0] >= 0 && E[1] > 0, "sym2::sqrtSym error : non positive definite matrix. " << *this); double a = 1 / (sqrt(E[0]) + sqrt(E[1])); double b = a * sqrt(E[0] * E[1]); Sq *= a; @@ -462,9 +451,8 @@ inline sym2 sym2::exaggerate( ) const { // returns a symmetric matrix with th return sym2(a) + b * Ex; } -inline sym2 sym2::tame( ) - const { // returns a symmetric matrix with the same eigenvectors, but with the largest - // eigenvalue divided by 4 or equal to the smallest +inline sym2 sym2::tame( ) const { // returns a symmetric matrix with the same eigenvectors, but with the largest + // eigenvalue divided by 4 or equal to the smallest double E[2]; eigen(E); @@ -514,8 +502,8 @@ template< class ring > class TriDim : vector_space< TriDim< ring >, ring >, totally_ordered< TriDim< ring > > { public: ring x, y, z; - TriDim( ) : x( ), y( ), z( ){}; - TriDim(ring X, ring Y, ring Z) : x(X), y(Y), z(Z){}; + TriDim( ) : x( ), y( ), z( ) {}; + TriDim(ring X, ring Y, ring Z) : x(X), y(Y), z(Z) {}; explicit TriDim(int i) : x( ), y( ), z( ) { assert_msg(0 <= i && i <= 2, "TriDim::Tridim(int i) error : out of bounds " << i); if (i == 0) { @@ -558,18 +546,13 @@ class TriDim : vector_space< TriDim< ring >, ring >, totally_ordered< TriDim< ri bool operator==(const Z3 &P) const { return x == P.x && y == P.y && z == P.z; } - TriDim operator^(const TriDim &P) const { - return TriDim(y * P.z - z * P.y, z * P.x - x * P.z, x * P.y - y * P.x); - } + TriDim operator^(const TriDim &P) const { return TriDim(y * P.z - z * P.y, z * P.x - x * P.z, x * P.y - y * P.x); } - bool operator<(const TriDim &P) const { - return x < P.x || (x == P.x && (y < P.y || (y == P.y && z < P.z))); - } + bool operator<(const TriDim &P) const { return x < P.x || (x == P.x && (y < P.y || (y == P.y && z < P.z))); } TriDim lin_sum(const TriDim &P, const TriDim &Q, const TriDim &R) const // [P,Q,R]*this { - return TriDim(x * P.x + y * Q.x + z * R.x, x * P.y + y * Q.y + z * R.y, - x * P.z + y * Q.z + z * R.z); + return TriDim(x * P.x + y * Q.x + z * R.x, x * P.y + y * Q.y + z * R.y, x * P.z + y * Q.z + z * R.z); } TriDim lin_solve(const TriDim &P, const TriDim &Q, const TriDim &R) const; // [P,Q,R]^{-1}*this @@ -622,27 +605,20 @@ inline R3 ZdtoRd(const Z3 &P) { return R3(P.x, P.y, P.z); } template< class ring > inline double determinant(TriDim< ring > &P, TriDim< ring > &Q, TriDim< ring > &R) { - return P.x * Q.y * R.z + P.y * Q.z * R.x + P.z * Q.x * R.y - P.z * Q.y * R.x - P.y * Q.x * R.z - - P.x * Q.z * R.y; + return P.x * Q.y * R.z + P.y * Q.z * R.x + P.z * Q.x * R.y - P.z * Q.y * R.x - P.y * Q.x * R.z - P.x * Q.z * R.y; } template< class ring > -TriDim< ring > TriDim< ring >::lin_solve(const TriDim< ring > &P, const TriDim< ring > &Q, - const TriDim< ring > &R) const { - const ring Det = P.x * Q.y * R.z + P.y * Q.z * R.x + P.z * Q.x * R.y - P.z * Q.y * R.x - - P.y * Q.x * R.z - P.x * Q.z * R.y; +TriDim< ring > TriDim< ring >::lin_solve(const TriDim< ring > &P, const TriDim< ring > &Q, const TriDim< ring > &R) const { + const ring Det = P.x * Q.y * R.z + P.y * Q.z * R.x + P.z * Q.x * R.y - P.z * Q.y * R.x - P.y * Q.x * R.z - P.x * Q.z * R.y; - assert_msg(Det != 0, name << "::lin_solve error : matrix is not invertible" << P << "; " << Q - << "; " + assert_msg(Det != 0, name << "::lin_solve error : matrix is not invertible" << P << "; " << Q << "; " << "; " << R); const ring invDet = 1 / Det; - assert_msg(invDet != 0, name << "::lin_solve error : determinant is not invertible" << Det << "; " - << P << "; " << Q << "; " + assert_msg(invDet != 0, name << "::lin_solve error : determinant is not invertible" << Det << "; " << P << "; " << Q << "; " << "; " << R); - return R3((Q.y * R.z - Q.z * R.y) * x + (Q.z * R.x - Q.x * R.z) * y + (Q.x * R.y - Q.y * R.x) * z, - (R.y * P.z - R.z * P.y) * x + (R.z * P.x - R.x * P.z) * y + (R.x * P.y - R.y * P.x) * z, - (P.y * Q.z - P.z * Q.y) * x + (P.z * Q.x - P.x * Q.z) * y + - (P.x * Q.y - P.y * Q.x) * z) * + return R3((Q.y * R.z - Q.z * R.y) * x + (Q.z * R.x - Q.x * R.z) * y + (Q.x * R.y - Q.y * R.x) * z, (R.y * P.z - R.z * P.y) * x + (R.z * P.x - R.x * P.z) * y + (R.x * P.y - R.y * P.x) * z, + (P.y * Q.z - P.z * Q.y) * x + (P.z * Q.x - P.x * Q.z) * y + (P.x * Q.y - P.y * Q.x) * z) * invDet; } @@ -654,8 +630,7 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { explicit sym3(double lambda) : xx(lambda), yy(lambda), zz(lambda), xy(0), yz(0), zx(0) {} - sym3(double XX, double YY, double ZZ, double XY, double YZ, double ZX) - : xx(XX), yy(YY), zz(ZZ), xy(XY), yz(YZ), zx(ZX) {} + sym3(double XX, double YY, double ZZ, double XY, double YZ, double ZX) : xx(XX), yy(YY), zz(ZZ), xy(XY), yz(YZ), zx(ZX) {} sym3(double lambda, double mu, const R3 &P) { const R3 Q = P / P.norm( ); @@ -671,8 +646,7 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { template< class ring > double norm2(const TriDim< ring > &P) const { - return xx * (P.x * P.x) + yy * (P.y * P.y) + zz * (P.z * P.z) + 2 * xy * (P.x * P.y) + - 2 * yz * (P.y * P.z) + 2 * zx * (P.z * P.x); + return xx * (P.x * P.x) + yy * (P.y * P.y) + zz * (P.z * P.z) + 2 * xy * (P.x * P.y) + 2 * yz * (P.y * P.z) + 2 * zx * (P.z * P.x); } template< class ring > @@ -682,13 +656,10 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { template< class ring > double scal(const TriDim< ring > &P, const TriDim< ring > &Q) const { - return xx * (P.x * Q.x) + yy * (P.y * Q.y) + zz * (P.z * Q.z) + xy * (P.x * Q.y + P.y * Q.x) + - yz * (P.y * Q.z + P.z * Q.y) + zx * (P.z * Q.x + P.x * Q.z); + return xx * (P.x * Q.x) + yy * (P.y * Q.y) + zz * (P.z * Q.z) + xy * (P.x * Q.y + P.y * Q.x) + yz * (P.y * Q.z + P.z * Q.y) + zx * (P.z * Q.x + P.x * Q.z); } - double det( ) const { - return xx * yy * zz + 2 * xy * yz * zx - xx * yz * yz - yy * zx * zx - zz * xy * xy; - } + double det( ) const { return xx * yy * zz + 2 * xy * yz * zx - xx * yz * yz - yy * zx * zx - zz * xy * xy; } double trace( ) const { return xx + yy + zz; } @@ -699,9 +670,7 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { bool isPositiveDefinite( ) const { return det( ) > 0 && trace( ) > 0 && invariant( ) > 0; } void reduced_basis(Z3 Basis[3]) const; - bool operator==(const sym3 &S) const { - return xx == S.xx && yy == S.yy && zz == S.zz && xy == S.xy && yz == S.yz && zx == S.zx; - } + bool operator==(const sym3 &S) const { return xx == S.xx && yy == S.yy && zz == S.zz && xy == S.xy && yz == S.yz && zx == S.zx; } sym3 &operator+=(double mu) { xx += mu; @@ -745,10 +714,7 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { return *this; } - const R3 operator*(const R3 &P) const { - return R3(xx * P.x + xy * P.y + zx * P.z, xy * P.x + yy * P.y + yz * P.z, - zx * P.x + yz * P.y + zz * P.z); - } + const R3 operator*(const R3 &P) const { return R3(xx * P.x + xy * P.y + zx * P.z, xy * P.x + yy * P.y + yz * P.z, zx * P.x + yz * P.y + zz * P.z); } const sym3 comatrix( ) const; const R3 KernelRep( ) const; // matrix needs to be rank 2, otherwise a null vector is returned. @@ -759,10 +725,7 @@ class sym3 : vector_space< sym3, double >, equality_comparable< sym3 > { } }; -inline const sym3 sym3::comatrix( ) const { - return sym3(yy * zz - square(yz), xx * zz - square(zx), xx * yy - square(xy), yz * zx - xy * zz, - zx * xy - xx * yz, xy * yz - yy * zx); -} +inline const sym3 sym3::comatrix( ) const { return sym3(yy * zz - square(yz), xx * zz - square(zx), xx * yy - square(xy), yz * zx - xy * zz, zx * xy - xx * yz, xy * yz - yy * zx); } inline const sym3 sym3::inverse( ) const { const double Det = det( ); @@ -849,13 +812,9 @@ inline void sym3::reduced_basis(Z3 Basis[3]) const { inline const R3 sym3::KernelRep( ) const { const sym3 co = comatrix( ); - const double norms2[3] = {square(co.xx) + square(co.xy) + square(co.zx), - square(co.xy) + square(co.yy) + square(co.yz), - square(co.zx) + square(co.yz) + square(co.zz)}; + const double norms2[3] = {square(co.xx) + square(co.xy) + square(co.zx), square(co.xy) + square(co.yy) + square(co.yz), square(co.zx) + square(co.yz) + square(co.zz)}; - return norms2[1] > norms2[2] - ? (norms2[0] > norms2[1] ? R3(co.xx, co.xy, co.zx) : R3(co.xy, co.yy, co.yz)) - : (norms2[0] > norms2[2] ? R3(co.xx, co.xy, co.zx) : R3(co.zx, co.yz, co.zz)); + return norms2[1] > norms2[2] ? (norms2[0] > norms2[1] ? R3(co.xx, co.xy, co.zx) : R3(co.xy, co.yy, co.yz)) : (norms2[0] > norms2[2] ? R3(co.xx, co.xy, co.zx) : R3(co.zx, co.yz, co.zz)); } /************************** affichage de variables et tableaux **********************/ @@ -917,8 +876,7 @@ inline ostream &operator<<(ostream &f, const sym3 &S) { inline ostream_math operator<<(ostream_math f, const sym3 &S) { if (f.format == Mathematica) { - f << "{{" << S.xx << "," << S.xy << "," << S.zx << "},{" << S.xy << "," << S.yy << "," << S.yz - << "},{" << S.zx << "," << S.yz << "," << S.zz << "}}"; + f << "{{" << S.xx << "," << S.xy << "," << S.zx << "},{" << S.xy << "," << S.yy << "," << S.yz << "},{" << S.zx << "," << S.yz << "," << S.zz << "}}"; } else { f.os << S; } @@ -928,8 +886,7 @@ inline ostream_math operator<<(ostream_math f, const sym3 &S) { // affichage de tableaux template< class ForwardIterator, class Zd > -void print_array(ostream_math f, ForwardIterator first, ForwardIterator last, Zd N, - bool one_per_line = false) { +void print_array(ostream_math f, ForwardIterator first, ForwardIterator last, Zd N, bool one_per_line = false) { int prod[N.dim]; prod[0] = N[0]; @@ -982,7 +939,7 @@ void print_array(ostream_math f, ForwardIterator first, ForwardIterator last, Zd class Metric2 { public: double lip; - Metric2( ) : lip(0){}; // ?? value -1 is reserved to identify the euclidean metric ?? Useful ?? + Metric2( ) : lip(0) {}; // ?? value -1 is reserved to identify the euclidean metric ?? Useful ?? virtual const sym2 operator( )(const R2 &P) const { return sym2(1, 0, 1); } virtual ~Metric2( ) {} @@ -1000,7 +957,7 @@ class FctMetric2 : public Metric2 { class Metric3 { public: double lip; - Metric3( ) : lip(0){}; + Metric3( ) : lip(0) {}; virtual const sym3 operator( )(const R3 &P) const { return sym3(1, 1, 1, 0, 0, 0); } virtual ~Metric3( ) {} diff --git a/plugin/seq/SaveHB.cpp b/plugin/seq/SaveHB.cpp index 89b585ec0..6e8dd4ecd 100644 --- a/plugin/seq/SaveHB.cpp +++ b/plugin/seq/SaveHB.cpp @@ -20,8 +20,7 @@ #include "ff++.hpp" #include "AFunction_ext.hpp" -void output_matrix_entries(ofstream &fout, const int N, const double *const ccs_val, - const int nnzero, const double *const b) { +void output_matrix_entries(ofstream &fout, const int N, const double *const ccs_val, const int nnzero, const double *const b) { for (int i = 0; i < nnzero; i++) { fout << setw(20) << setprecision(17) << setiosflags(ios::scientific) << ccs_val[i]; @@ -41,12 +40,10 @@ void output_matrix_entries(ofstream &fout, const int N, const double *const ccs_ return; } -void output_matrix_entries(ofstream &fout, const int N, const complex< double > *const ccs_val, - const int nnzero, const complex< double > *const b) { +void output_matrix_entries(ofstream &fout, const int N, const complex< double > *const ccs_val, const int nnzero, const complex< double > *const b) { for (int i = 0; i < nnzero; i++) { - fout << setw(20) << setprecision(17) << setiosflags(ios::scientific) << ccs_val[i].real( ) - << setw(20) << setprecision(17) << setiosflags(ios::scientific) << ccs_val[i].imag( ); + fout << setw(20) << setprecision(17) << setiosflags(ios::scientific) << ccs_val[i].real( ) << setw(20) << setprecision(17) << setiosflags(ios::scientific) << ccs_val[i].imag( ); if ((i + 1) % 2 == 0) fout << std::endl; } @@ -54,8 +51,7 @@ void output_matrix_entries(ofstream &fout, const int N, const complex< double > for (int i = 0; i < N; i++) { - fout << setw(20) << setprecision(17) << setiosflags(ios::scientific) << b[i].real( ) << setw(20) - << setprecision(17) << setiosflags(ios::scientific) << b[i].imag( ); + fout << setw(20) << setprecision(17) << setiosflags(ios::scientific) << b[i].real( ) << setw(20) << setprecision(17) << setiosflags(ios::scientific) << b[i].imag( ); if ((i + 1) % 2 == 0) fout << std::endl; } @@ -65,8 +61,7 @@ void output_matrix_entries(ofstream &fout, const int N, const complex< double > } template< typename R > -long SaveHB(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat, - KN_< R > const &b, std::string *const &hb_title) { +long SaveHB(std::string *const &hb_filename, Matrice_Creuse< R > *const &sparse_mat, KN_< R > const &b, std::string *const &hb_title) { MatriceMorse< R > *A = sparse_mat->pHM( ); const bool isDouble = sizeof(R) == sizeof(double); // std::is_floating_point::value; @@ -192,13 +187,8 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme cout << " load: SaveHB " << endl; } - Global.Add( - "SaveHB", "(", - new OneOperator4_< long, string *, Matrice_Creuse< double > *, KN_< double >, string * >( - SaveHB)); - Global.Add("SaveHB", "(", - new OneOperator4_< long, string *, Matrice_Creuse< std::complex< double > > *, - KN_< std::complex< double > >, string * >(SaveHB)); + Global.Add("SaveHB", "(", new OneOperator4_< long, string *, Matrice_Creuse< double > *, KN_< double >, string * >(SaveHB)); + Global.Add("SaveHB", "(", new OneOperator4_< long, string *, Matrice_Creuse< std::complex< double > > *, KN_< std::complex< double > >, string * >(SaveHB)); } LOADFUNC(Load_Init) //---------------------------------------------------------------------- diff --git a/plugin/seq/Schur-Complement.cpp b/plugin/seq/Schur-Complement.cpp index 9036f0aaf..d6b870e2a 100644 --- a/plugin/seq/Schur-Complement.cpp +++ b/plugin/seq/Schur-Complement.cpp @@ -55,8 +55,7 @@ typedef void VOID; // KN*CloseTo (Stack stack, double const &eps, KNM *const &p, KNM *const &q) { template< class R > -long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN_< long > const &I, - Data_Sparse_Solver &ds, KNM< R > *pV = 0); +long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN_< long > const &I, Data_Sparse_Solver &ds, KNM< R > *pV = 0); template< class R > class SchurComplement_OP : public E_F0mps { @@ -64,8 +63,7 @@ class SchurComplement_OP : public E_F0mps { Expression ess, eaa, eii, epV; static aType btype; - static const int n_name_param = - NB_NAME_PARM_MAT; // +1; // add nbiter FH 30/01/2007 11 -> 12 //add var MUMPS+autre + static const int n_name_param = NB_NAME_PARM_MAT; // +1; // add nbiter FH 30/01/2007 11 -> 12 //add var MUMPS+autre static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; const OneOperator *precon; @@ -76,9 +74,7 @@ class SchurComplement_OP : public E_F0mps { return nargs[i] ? GetAny< T >((*nargs[i])(stack)) : a; } - SchurComplement_OP(const basicAC_F0 &args, Expression s, Expression a, Expression i, - Expression ev = 0) - : ess(s), eaa(a), eii(i), epV(ev) { + SchurComplement_OP(const basicAC_F0 &args, Expression s, Expression a, Expression i, Expression ev = 0) : ess(s), eaa(a), eii(i), epV(ev) { args.SetNameParam(n_name_param, name_param, nargs); precon = 0; // a changer if (nargs[3]) { @@ -95,22 +91,14 @@ template< class R > class SchurComplement : public OneOperator { public: int cas; - SchurComplement( ) - : OneOperator(atype< long >( ), atype< KNM< R > * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< long > * >( )), - cas(0) {} - SchurComplement(int) - : OneOperator(atype< long >( ), atype< KNM< R > * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< long > * >( ), atype< KNM< R > * >( )), - cas(1) {} + SchurComplement( ) : OneOperator(atype< long >( ), atype< KNM< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< long > * >( )), cas(0) {} + SchurComplement(int) : OneOperator(atype< long >( ), atype< KNM< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< long > * >( ), atype< KNM< R > * >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 0) - return new SchurComplement_OP< R >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new SchurComplement_OP< R >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); else - return new SchurComplement_OP< R >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + return new SchurComplement_OP< R >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } }; @@ -137,8 +125,7 @@ AnyType SchurComplement_OP< R >::operator( )(Stack stack) const { return ff_SchurComplement(stack, pE, pA, *pII, ds, pV); } template< class R > -long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN_< long > const &I, - Data_Sparse_Solver &ds, KNM< R > *pV) { +long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN_< long > const &I, Data_Sparse_Solver &ds, KNM< R > *pV) { // I given numbering of Schur complement I[i] is the index in A of the i in S if I[i] >=0 // the matrix A in splited in 4 blocks [[AII,AIJ],[AJI, AJJ]] where @@ -174,20 +161,14 @@ long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN } } - if (nn != imx + 1) - cerr << " Error SchurComplement the positive full numbering is not surjective " << nn - << " <> " << imx + 1 << endl; + if (nn != imx + 1) cerr << " Error SchurComplement the positive full numbering is not surjective " << nn << " <> " << imx + 1 << endl; ffassert(nn == imx + 1); ni = nn; - if (verbosity) - cout << " SchurComplement with full non negative full shur complement numbering " << endl - << " size of compl. " << ni << " < size of mat. " << n << endl; + if (verbosity) cout << " SchurComplement with full non negative full shur complement numbering " << endl << " size of compl. " << ni << " < size of mat. " << n << endl; } else { ni = Ni; - if (verbosity) - cout << " SchurComplement with just the shur complement numbering (injection)" << endl - << " size of compl. " << ni << " < size of mat. " << n << endl; + if (verbosity) cout << " SchurComplement with just the shur complement numbering (injection)" << endl << " size of compl. " << ni << " < size of mat. " << n << endl; for (int i = 0; i < Ni; ++i) { int Ii = I[i]; ffassert(Ii >= 0 && Ii < n); @@ -198,8 +179,7 @@ long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN // build numbering of no in shur complement .. -2 - number if (err) { if (Ni != n) - cerr << " SchurComplement get all numbering i -> j if i in [0,n[ if I[i]>=0 j=I[i] " << Ni - << " == " << n << endl; + cerr << " SchurComplement get all numbering i -> j if i in [0,n[ if I[i]>=0 j=I[i] " << Ni << " == " << n << endl; else cerr << " SchurComplement get all numbering i -> j if i in [0,ni[ , j = I[i] " << endl; cerr << " Fatal Error in SchurComplement def numbering : nb err= " << err << endl; @@ -214,16 +194,14 @@ long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN if (pV) pV->resize(n, ni); // S = zero; ffassert(n > ni); - if (ni + nj < n && verbosity > 2) - cout << " - warning the SchurComplement numbering is not injectif !" << ni << " +" << nj - << " ==" << ni + nj << " < " << n << endl; + if (ni + nj < n && verbosity > 2) cout << " - warning the SchurComplement numbering is not injectif !" << ni << " +" << nj << " ==" << ni + nj << " < " << n << endl; ffassert(ni > 0 && nj > 0); // KN J(nj); // for(int i=0; i AII(ni, ni,0,false), AIJ(ni, nj,0,false), AJI(nj, ni,0,false), AJJ(nj, nj,0,false); + MatriceMorse< R > AII(ni, ni, 0, false), AIJ(ni, nj, 0, false), AJI(nj, ni, 0, false), AJJ(nj, nj, 0, false); int nstep = A.half; ffassert(nstep == 0 || nstep == 1); for (int step = 0; step <= nstep; ++step) @@ -290,8 +268,7 @@ long ff_SchurComplement(Stack stack, KNM< R > *pS, Matrice_Creuse< R > *pmcA, KN } sI = AIJ * sJ; S(':', k) = -sI; - for (int l = AII.p[k]; l < AII.p[k + 1]; ++l) - S(AII.i[l], k) += AII.aij[l], err += AII.j[l] != k; + for (int l = AII.p[k]; l < AII.p[k + 1]; ++l) S(AII.i[l], k) += AII.aij[l], err += AII.j[l] != k; } ffassert(err == 0); err = 0; @@ -325,8 +302,7 @@ static void Load_Init( ) { Global.Add("SchurComplement", "(", new SchurComplement< R >(1)); Global.Add("SchurComplement", "(", new SchurComplement< Complex >(1)); Global.Add("copy", "(", new OneOperator2< long, KNM< R > *, Matrice_Creuse< R > * >(copy_mat)); - Global.Add("copy", "(", - new OneOperator2< long, KNM< Complex > *, Matrice_Creuse< Complex > * >(copy_mat)); + Global.Add("copy", "(", new OneOperator2< long, KNM< Complex > *, Matrice_Creuse< Complex > * >(copy_mat)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/SortedList.h b/plugin/seq/SortedList.h index 75e366e94..7f0820b70 100644 --- a/plugin/seq/SortedList.h +++ b/plugin/seq/SortedList.h @@ -57,12 +57,9 @@ class RBTree; template< class TabElement > class Tab { public: - Tab( ) : cardMax(startCard), growIndex(0), max_accessed_pos(-1) { - elements[growIndex++].resize(startCard); - }; + Tab( ) : cardMax(startCard), growIndex(0), max_accessed_pos(-1) { elements[growIndex++].resize(startCard); }; Tab(const Tab< TabElement > &tab) : max_accessed_pos(tab.max_accessed_pos) { - cout << "Tab constructor Warning : copying Tab of cardinality " << tab.cardMax - << "; max accessed pos : " << tab.max_accessed_pos << endl; + cout << "Tab constructor Warning : copying Tab of cardinality " << tab.cardMax << "; max accessed pos : " << tab.max_accessed_pos << endl; elements[growIndex++].resize(startCard); for (int i = 0; i < tab.cardMax; i++) { @@ -94,8 +91,7 @@ class Tab { }; const TabElement &operator[](int pos) const { assert_msg(pos >= 0, "Tab::Element Error : Negative index " << pos); - assert_msg(pos <= max_accessed_pos, - "Tab::Element const Error : max_accessed_pos exceeded. " << pos); + assert_msg(pos <= max_accessed_pos, "Tab::Element const Error : max_accessed_pos exceeded. " << pos); if (pos < startCard) { return elements[0][pos]; } @@ -108,8 +104,7 @@ class Tab { ; return elements[i][pos - pow]; }; - void export_content(const char *filename, Format_Math format = Mathematica, - bool one_per_line = false) const { + void export_content(const char *filename, Format_Math format = Mathematica, bool one_per_line = false) const { ofstream data_out; data_out.open(filename); diff --git a/plugin/seq/SuperLu.cpp b/plugin/seq/SuperLu.cpp index 351090cae..7837484f6 100644 --- a/plugin/seq/SuperLu.cpp +++ b/plugin/seq/SuperLu.cpp @@ -40,52 +40,36 @@ struct SuperLUDriver< double > { static Dtype_t R_SLU_T( ) { return SLU_D; } static trans_t trans( ) { return TRANS; } - static void gssv(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, SuperMatrix *p5, - SuperMatrix *p6, SuperMatrix *p7, SuperLUStat_t *p8, int *p9) { + static void gssv(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, SuperMatrix *p5, SuperMatrix *p6, SuperMatrix *p7, SuperLUStat_t *p8, int *p9) { dgssv(p1, p2, p3, p4, p5, p6, p7, p8, p9); } - static void gssvx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, - double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, - SuperMatrix *p13, SuperMatrix *p14, double *p15, double *p16, double *p17, - double *p18, GlobalLU_t *pGlu, mem_usage_t *p19, SuperLUStat_t *p20, int *p21) { - dgssvx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, pGlu, - p19, p20, p21); + static void gssvx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, SuperMatrix *p13, + SuperMatrix *p14, double *p15, double *p16, double *p17, double *p18, GlobalLU_t *pGlu, mem_usage_t *p19, SuperLUStat_t *p20, int *p21) { + dgssvx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, pGlu, p19, p20, p21); } - static void gsisx(superlu_options_t * p1, SuperMatrix * p2, int * p3, int * p4, int * p5, - char * p6, double * p7, double * p8, SuperMatrix * p9, SuperMatrix * p10, - void * p11, int p12, SuperMatrix * p13, SuperMatrix * p14, - double * p15, double * p16, GlobalLU_t *pGlu, mem_usage_t * p17, SuperLUStat_t * p18, int * p19) { - dgsisx( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,pGlu,p17,p18,p19); + static void gsisx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, SuperMatrix *p13, + SuperMatrix *p14, double *p15, double *p16, GlobalLU_t *pGlu, mem_usage_t *p17, SuperLUStat_t *p18, int *p19) { + dgsisx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, pGlu, p17, p18, p19); } /* Supernodal LU factor related */ - static void Create_CompCol_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, - int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { + static void Create_CompCol_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { dCreate_CompCol_Matrix(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } - static void Create_CompRow_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, - int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { + static void Create_CompRow_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { dCreate_CompRow_Matrix(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } - static void Create_Dense_Matrix(SuperMatrix *p1, int p2, int p3, double *p4, int p5, Stype_t p6, - Dtype_t p7, Mtype_t p8) { - dCreate_Dense_Matrix(p1, p2, p3, p4, p5, p6, p7, p8); - } + static void Create_Dense_Matrix(SuperMatrix *p1, int p2, int p3, double *p4, int p5, Stype_t p6, Dtype_t p7, Mtype_t p8) { dCreate_Dense_Matrix(p1, p2, p3, p4, p5, p6, p7, p8); } - static void Create_SuperNode_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, - int *p7, int *p8, int *p9, int *p10, Stype_t p11, Dtype_t p12, - Mtype_t p13) { + static void Create_SuperNode_Matrix(SuperMatrix *p1, int p2, int p3, int p4, double *p5, int *p6, int *p7, int *p8, int *p9, int *p10, Stype_t p11, Dtype_t p12, Mtype_t p13) { dCreate_SuperNode_Matrix(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); } - static void CompRow_to_CompCol(int p1, int p2, int p3, double *p4, int *p5, int *p6, double **p7, - int **p8, int **p9) { - dCompRow_to_CompCol(p1, p2, p3, p4, p5, p6, p7, p8, p9); - } + static void CompRow_to_CompCol(int p1, int p2, int p3, double *p4, int *p5, int *p6, double **p7, int **p8, int **p9) { dCompRow_to_CompCol(p1, p2, p3, p4, p5, p6, p7, p8, p9); } }; template<> @@ -98,52 +82,36 @@ struct SuperLUDriver< Complex > { static doublecomplex **dc(Complex **p) { return (doublecomplex **)(void *)p; } - static void gssv(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, SuperMatrix *p5, - SuperMatrix *p6, SuperMatrix *p7, SuperLUStat_t *p8, int *p9) { + static void gssv(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, SuperMatrix *p5, SuperMatrix *p6, SuperMatrix *p7, SuperLUStat_t *p8, int *p9) { zgssv(p1, p2, p3, p4, p5, p6, p7, p8, p9); } - static void gssvx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, - double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, - SuperMatrix *p13, SuperMatrix *p14, double *p15, double *p16, double *p17, - double *p18, GlobalLU_t *pGlu, mem_usage_t *p19, SuperLUStat_t *p20, int *p21) { - zgssvx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, pGlu, - p19, p20, p21); + static void gssvx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, SuperMatrix *p13, + SuperMatrix *p14, double *p15, double *p16, double *p17, double *p18, GlobalLU_t *pGlu, mem_usage_t *p19, SuperLUStat_t *p20, int *p21) { + zgssvx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, pGlu, p19, p20, p21); } - static void gsisx(superlu_options_t * p1, SuperMatrix * p2, int * p3, int * p4, int * p5, - char * p6, double * p7, double * p8, SuperMatrix * p9, SuperMatrix * p10, - void * p11, int p12, SuperMatrix * p13, SuperMatrix * p14, - double * p15, double * p16, GlobalLU_t *pGlu, mem_usage_t * p17, SuperLUStat_t * p18, int * p19) { - zgsisx( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,pGlu,p17,p18,p19); + static void gsisx(superlu_options_t *p1, SuperMatrix *p2, int *p3, int *p4, int *p5, char *p6, double *p7, double *p8, SuperMatrix *p9, SuperMatrix *p10, void *p11, int p12, SuperMatrix *p13, + SuperMatrix *p14, double *p15, double *p16, GlobalLU_t *pGlu, mem_usage_t *p17, SuperLUStat_t *p18, int *p19) { + zgsisx(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, pGlu, p17, p18, p19); } /* Supernodal LU factor related */ - static void Create_CompCol_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, - int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { + static void Create_CompCol_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { zCreate_CompCol_Matrix(p1, p2, p3, p4, dc(p5), p6, p7, p8, p9, p10); } - static void Create_CompRow_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, - int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { + static void Create_CompRow_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, int *p7, Stype_t p8, Dtype_t p9, Mtype_t p10) { zCreate_CompRow_Matrix(p1, p2, p3, p4, dc(p5), p6, p7, p8, p9, p10); } - static void Create_Dense_Matrix(SuperMatrix *p1, int p2, int p3, Complex *p4, int p5, Stype_t p6, - Dtype_t p7, Mtype_t p8) { - zCreate_Dense_Matrix(p1, p2, p3, dc(p4), p5, p6, p7, p8); - } + static void Create_Dense_Matrix(SuperMatrix *p1, int p2, int p3, Complex *p4, int p5, Stype_t p6, Dtype_t p7, Mtype_t p8) { zCreate_Dense_Matrix(p1, p2, p3, dc(p4), p5, p6, p7, p8); } - static void Create_SuperNode_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, - int *p7, int *p8, int *p9, int *p10, Stype_t p11, Dtype_t p12, - Mtype_t p13) { + static void Create_SuperNode_Matrix(SuperMatrix *p1, int p2, int p3, int p4, Complex *p5, int *p6, int *p7, int *p8, int *p9, int *p10, Stype_t p11, Dtype_t p12, Mtype_t p13) { zCreate_SuperNode_Matrix(p1, p2, p3, p4, dc(p5), p6, p7, p8, p9, p10, p11, p12, p13); } - static void CompRow_to_CompCol(int p1, int p2, int p3, Complex *p4, int *p5, int *p6, - Complex **p7, int **p8, int **p9) { - zCompRow_to_CompCol(p1, p2, p3, dc(p4), p5, p6, dc(p7), p8, p9); - } + static void CompRow_to_CompCol(int p1, int p2, int p3, Complex *p4, int *p5, int *p6, Complex **p7, int **p8, int **p9) { zCompRow_to_CompCol(p1, p2, p3, dc(p4), p5, p6, dc(p7), p8, p9); } }; int s_(char *str, const char *cmp[]) { @@ -167,15 +135,11 @@ void read_options_freefem(string string_option, superlu_options_t *options) { static const trans_t enumtrans_t[3] = {NOTRANS, TRANS, CONJ}; static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA}; static const char *compyes_no_t[] = {"NO", "YES", 0}; - static const char *compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED", - 0}; - static const char *compcolperm_t[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", - "COLAMD", "MY_PERMC", 0}; + static const char *compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED", 0}; + static const char *compcolperm_t[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; static const char *comptrans_t[] = {"NOTRANS", "TRANS", "CONJ", 0}; static const char *compIterRefine_t[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; - static const char *comp[] = { - "Fact", "Equil", "ColPerm", "DiagPivotThresh", "Trans", "IterRefine", - "SymmetricMode", "PivotGrowth", "ConditionNumber", "PrintStat", 0}; + static const char *comp[] = {"Fact", "Equil", "ColPerm", "DiagPivotThresh", "Trans", "IterRefine", "SymmetricMode", "PivotGrowth", "ConditionNumber", "PrintStat", 0}; /* Set the default values for options argument: * options.Fact = DOFACT; @@ -299,29 +263,27 @@ void read_options_freefem(string string_option, superlu_options_t *options) { // #endif } -void read_options_freefem_ilu(string string_option, superlu_options_t *options){ - static const yes_no_t enumyes_no_t[2] = {NO, YES}; - static const fact_t enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED}; - static const colperm_t enumcolperm_t[5] = {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}; - static const rowperm_t enumrowperm_t[3] = {NOROWPERM, LargeDiag_MC64, MY_PERMR}; - static const trans_t enumtrans_t[3] = {NOTRANS, TRANS, CONJ}; - static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA}; - static const milu_t enummilu_t[4] = {SILU, SMILU_1,SMILU_2 ,SMILU_3}; - static const norm_t enumnorm_t[3] = {ONE_NORM, TWO_NORM, INF_NORM}; - - static const char* compyes_no_t[] = {"NO", "YES",0}; - static const char* compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0}; - static const char* compcolperm_t[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC",0}; - static const char* comprowperm_t[] = {"NOROWPERM", "LargeDiag_MC64", "MY_PERMR",0}; - static const char* comptrans_t[] = {"NOTRANS", "TRANS", "CONJ",0}; - static const char* compIterRefine_t[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA",0}; - static const char* compmilu_t[] = {"SILU", "SMILU_1", "SMILU_2", "SMILU_3",0}; - static const char* compnorm_t[] = {"ONE_NORM", "TWO_NORM", "INF_NORM",0}; - - static const char* comp[] = {"Fact", "Equil","ColPerm", - "DiagPivotThresh","Trans","IterRefine", - "SymmetricMode","PivotGrowth","ConditionNumber", - "PrintStat","RowPerm","ILU_DropTol","ILU_FillTol","ILU_FillFactor","ILU_DropRule","ILU_Norm","ILU_MILU",0}; +void read_options_freefem_ilu(string string_option, superlu_options_t *options) { + static const yes_no_t enumyes_no_t[2] = {NO, YES}; + static const fact_t enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED}; + static const colperm_t enumcolperm_t[5] = {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}; + static const rowperm_t enumrowperm_t[3] = {NOROWPERM, LargeDiag_MC64, MY_PERMR}; + static const trans_t enumtrans_t[3] = {NOTRANS, TRANS, CONJ}; + static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA}; + static const milu_t enummilu_t[4] = {SILU, SMILU_1, SMILU_2, SMILU_3}; + static const norm_t enumnorm_t[3] = {ONE_NORM, TWO_NORM, INF_NORM}; + + static const char *compyes_no_t[] = {"NO", "YES", 0}; + static const char *compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED", 0}; + static const char *compcolperm_t[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; + static const char *comprowperm_t[] = {"NOROWPERM", "LargeDiag_MC64", "MY_PERMR", 0}; + static const char *comptrans_t[] = {"NOTRANS", "TRANS", "CONJ", 0}; + static const char *compIterRefine_t[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; + static const char *compmilu_t[] = {"SILU", "SMILU_1", "SMILU_2", "SMILU_3", 0}; + static const char *compnorm_t[] = {"ONE_NORM", "TWO_NORM", "INF_NORM", 0}; + + static const char *comp[] = {"Fact", "Equil", "ColPerm", "DiagPivotThresh", "Trans", "IterRefine", "SymmetricMode", "PivotGrowth", "ConditionNumber", + "PrintStat", "RowPerm", "ILU_DropTol", "ILU_FillTol", "ILU_FillFactor", "ILU_DropRule", "ILU_Norm", "ILU_MILU", 0}; /* Set the default values for options argument: options.Fact = DOFACT; @@ -343,153 +305,152 @@ void read_options_freefem_ilu(string string_option, superlu_options_t *options){ options.ILU_MILU = SILU; */ - //cout << "string_option" << *string_option << endl; - KN kdata(string_option.size()+1); - - char * data=kdata; - strcpy( data, string_option.c_str()); - //cout << "data=" << data << endl; - char * tictac; - tictac = strtok(data," =,\t\n"); - //cout << "tictac=" << data << endl; - while(tictac != NULL){ - //char* comp[] = {"Fact", "Equil","ColPerm", + // cout << "string_option" << *string_option << endl; + KN< char > kdata(string_option.size( ) + 1); + + char *data = kdata; + strcpy(data, string_option.c_str( )); + // cout << "data=" << data << endl; + char *tictac; + tictac = strtok(data, " =,\t\n"); + // cout << "tictac=" << data << endl; + while (tictac != NULL) { + // char* comp[] = {"Fact", "Equil","ColPerm", //"DiagPivotThresh","Trans","IterRefine", //"SymmetricMode","PivotGrowth","ConditionNumber", //"PrintStat",0 }; int id_option = s_(tictac, comp); - tictac = strtok(NULL," =,\t\n"); + tictac = strtok(NULL, " =,\t\n"); int val_options; - switch (id_option) - { - case 1 : // Fact - //char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0}; - val_options= s_(tictac,compfact_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","Fact"); + switch (id_option) { + case 1: // Fact + // char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0}; + val_options = s_(tictac, compfact_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "Fact"); exit(1); } - options->Fact = enumfact_t[val_options-1]; + options->Fact = enumfact_t[val_options - 1]; break; - case 2: // Equil - //char* comp2[] = {"NO", "YES", 0}; - val_options= s_(tictac,compyes_no_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","Equil"); + case 2: // Equil + // char* comp2[] = {"NO", "YES", 0}; + val_options = s_(tictac, compyes_no_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "Equil"); exit(1); } - options->Equil = enumyes_no_t[val_options-1]; + options->Equil = enumyes_no_t[val_options - 1]; break; - case 3: // ColPerm - //char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; - val_options= s_(tictac,compcolperm_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","ColPerm"); + case 3: // ColPerm + // char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0}; + val_options = s_(tictac, compcolperm_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "ColPerm"); exit(1); } - options->ColPerm = enumcolperm_t[val_options-1]; + options->ColPerm = enumcolperm_t[val_options - 1]; break; - case 4: // DiagPivotThresh - options->DiagPivotThresh= strtod(tictac,&tictac); + case 4: // DiagPivotThresh + options->DiagPivotThresh = strtod(tictac, &tictac); break; - case 5: // Trans - //char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0}; - val_options= s_(tictac, comptrans_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","Trans"); + case 5: // Trans + // char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0}; + val_options = s_(tictac, comptrans_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "Trans"); exit(1); } - options->Trans = enumtrans_t[val_options-1]; + options->Trans = enumtrans_t[val_options - 1]; break; - case 6: // IterRefine - //char* comp6[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; - val_options= s_(tictac, compIterRefine_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","IterRefine"); + case 6: // IterRefine + // char* comp6[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0}; + val_options = s_(tictac, compIterRefine_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "IterRefine"); exit(1); } - options->IterRefine = enumIterRefine_t[val_options-1]; + options->IterRefine = enumIterRefine_t[val_options - 1]; break; - case 7: // SymmetricMode - //char* comp7[] = {"NO","YES", 0}; - val_options= s_(tictac, compyes_no_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","SymmetricMode"); + case 7: // SymmetricMode + // char* comp7[] = {"NO","YES", 0}; + val_options = s_(tictac, compyes_no_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "SymmetricMode"); exit(1); } - options->SymmetricMode= enumyes_no_t[val_options-1]; + options->SymmetricMode = enumyes_no_t[val_options - 1]; break; - case 8: // PivotGrowth - //char* comp8[] = {"NO","YES", 0}; - val_options= s_(tictac,compyes_no_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","PivotGrowth"); + case 8: // PivotGrowth + // char* comp8[] = {"NO","YES", 0}; + val_options = s_(tictac, compyes_no_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "PivotGrowth"); exit(1); } - options->PivotGrowth = enumyes_no_t[val_options-1]; + options->PivotGrowth = enumyes_no_t[val_options - 1]; break; - case 9: // ConditionNumber - //char* comp9[] = {"NO","YES", 0}; - val_options= s_(tictac, compyes_no_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","ConditionNumber"); + case 9: // ConditionNumber + // char* comp9[] = {"NO","YES", 0}; + val_options = s_(tictac, compyes_no_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "ConditionNumber"); exit(1); } - options->ConditionNumber = enumyes_no_t[val_options-1]; + options->ConditionNumber = enumyes_no_t[val_options - 1]; break; - case 10: // PrintStat - val_options= s_(tictac, compyes_no_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","PrintStat"); + case 10: // PrintStat + val_options = s_(tictac, compyes_no_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "PrintStat"); exit(1); } - options->PrintStat = enumyes_no_t[val_options-1]; + options->PrintStat = enumyes_no_t[val_options - 1]; break; - case 11: // RowPerm - val_options= s_(tictac, comprowperm_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","RowPerm"); + case 11: // RowPerm + val_options = s_(tictac, comprowperm_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "RowPerm"); exit(1); } - options->RowPerm = enumrowperm_t[val_options-1]; + options->RowPerm = enumrowperm_t[val_options - 1]; break; - case 12: // ILU_DropTol - options->ILU_DropTol= strtod(tictac,&tictac); + case 12: // ILU_DropTol + options->ILU_DropTol = strtod(tictac, &tictac); break; - case 13: // ILU_FillTol - options->ILU_FillTol= strtod(tictac,&tictac); + case 13: // ILU_FillTol + options->ILU_FillTol = strtod(tictac, &tictac); break; - case 14: // ILU_FillFactor - options->ILU_FillFactor= strtod(tictac,&tictac); + case 14: // ILU_FillFactor + options->ILU_FillFactor = strtod(tictac, &tictac); break; - case 15 : // ILU_DropRule - options->ILU_DropRule = strtol(tictac,&tictac,0); + case 15: // ILU_DropRule + options->ILU_DropRule = strtol(tictac, &tictac, 0); break; - case 16 : // ILU_Norm - val_options= s_(tictac,compnorm_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","ILU_Norm"); + case 16: // ILU_Norm + val_options = s_(tictac, compnorm_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "ILU_Norm"); exit(1); } - options->ILU_Norm = enumnorm_t[val_options-1]; + options->ILU_Norm = enumnorm_t[val_options - 1]; break; - case 17 : // ILU_MILU - val_options= s_(tictac,compmilu_t); - if( val_options == 0){ - printf("value given for SuperLU for options %s is not correct\n","ILU_MILU"); + case 17: // ILU_MILU + val_options = s_(tictac, compmilu_t); + if (val_options == 0) { + printf("value given for SuperLU for options %s is not correct\n", "ILU_MILU"); exit(1); } - options->ILU_MILU = enummilu_t[val_options-1]; + options->ILU_MILU = enummilu_t[val_options - 1]; break; - case 0: // Equivalent of case default + case 0: // Equivalent of case default break; } - tictac = strtok(NULL," =,\t\n"); + tictac = strtok(NULL, " =,\t\n"); } } -template< typename R , int t > +template< typename R, int t > class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDriver< R > { public: // 1 unsym , 2 sym, 4 pos , 8 nopos, 16 seq, 32 ompi, 64 mpi , @@ -521,18 +482,17 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive int cs, cn; SuperLUStat_t stat; VirtualSolverSuperLU(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) - : AH(&AA), etree(0), string_option(ds.sparams), perm_r(ds.perm_r), perm_c(ds.perm_c), RR(0), - CC(0), tol_pivot_sym(ds.tol_pivot_sym), tol_pivot(ds.tol_pivot), verb(ds.verb), cn(0), cs(0) { + : AH(&AA), etree(0), string_option(ds.sparams), perm_r(ds.perm_r), perm_c(ds.perm_c), RR(0), CC(0), tol_pivot_sym(ds.tol_pivot_sym), tol_pivot(ds.tol_pivot), verb(ds.verb), cn(0), cs(0) { A.Store = 0; L.Store = 0; U.Store = 0; set_default_options(&options); - if (t == 1) { // ILU + if (t == 1) { // ILU ilu_set_default_options(&options); - //options.RowPerm = NOROWPERM; - if(!string_option.empty()) read_options_freefem_ilu(string_option, &options); + // options.RowPerm = NOROWPERM; + if (!string_option.empty( )) read_options_freefem_ilu(string_option, &options); } if (AH->half) { @@ -544,8 +504,7 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive StatInit(&stat); } void dosolver(R *x, R *b, int N, int trans) { - if (verb > 2 || verbosity > 9) - cout << "dosolver SuperLU double/int " << N << " " << trans << endl; + if (verb > 2 || verbosity > 9) cout << "dosolver SuperLU double/int " << N << " " << trans << endl; ffassert(trans == 0); options.Trans = trans ? SuperLUDriver< R >::trans( ) : NOTRANS; int info = 0, lwork = 0; @@ -559,13 +518,10 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive this->Create_Dense_Matrix(&B, m, N, b, m, SLU_DN, R_SLU, SLU_GE); this->Create_Dense_Matrix(&X, m, N, x, m, SLU_DN, R_SLU, SLU_GE); - if (t==0) // LU - SuperLUDriver< R >::gssvx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, - lwork, &B, &X, &rpg, &rcond, ferr, berr, &Glu, &mem_usage, &stat, - &info); - else // ILU - SuperLUDriver::gsisx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, - &L, &U, work, lwork, &B, &X, &rpg, &rcond, &Glu, &mem_usage, &stat, &info); + if (t == 0) // LU + SuperLUDriver< R >::gssvx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &Glu, &mem_usage, &stat, &info); + else // ILU + SuperLUDriver< R >::gsisx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, lwork, &B, &X, &rpg, &rcond, &Glu, &mem_usage, &stat, &info); if (verbosity > 2) printf("Triangular solve: dgssvx() returns info %d\n", info); if (verbosity > 3) { @@ -589,8 +545,7 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive } void UpdateState( ) { - if (verb > 2 || verbosity > 9) - std::cout << " UpdateState " << AH->re_do_numerics << " " << AH->re_do_symbolic << std::endl; + if (verb > 2 || verbosity > 9) std::cout << " UpdateState " << AH->re_do_numerics << " " << AH->re_do_symbolic << std::endl; if (AH->GetReDoNumerics( )) cn++; if (AH->GetReDoSymbolic( )) cs++; this->ChangeCodeState(AH->n, cs, cn); @@ -643,13 +598,10 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive this->Create_Dense_Matrix(&X, m, 0, 0, m, SLU_DN, R_SLU, SLU_GE); B.ncol = 0; options.Fact = DOFACT; - if (t == 0) // LU - SuperLUDriver< R >::gssvx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, - lwork, &B, &X, &rpg, &rcond, ferr, berr, &Glu, &mem_usage, &stat, - &info); - else // ILU - SuperLUDriver::gsisx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, - &L, &U, work, lwork, &B, &X, &rpg, &rcond, &Glu, &mem_usage, &stat, &info); + if (t == 0) // LU + SuperLUDriver< R >::gssvx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &Glu, &mem_usage, &stat, &info); + else // ILU + SuperLUDriver< R >::gsisx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, lwork, &B, &X, &rpg, &rcond, &Glu, &mem_usage, &stat, &info); options.Fact = FACTORED; if (B.Store) Destroy_SuperMatrix_Store(&B); @@ -666,11 +618,11 @@ class VirtualSolverSuperLU : public VirtualSolver< int, R >, public SuperLUDrive }; static void Load_Init( ) { - addsolver< VirtualSolverSuperLU< double , 0 > >("SuperLU", 50, 1); - addsolver< VirtualSolverSuperLU< Complex , 0 > >("SuperLU", 50, 1); + addsolver< VirtualSolverSuperLU< double, 0 > >("SuperLU", 50, 1); + addsolver< VirtualSolverSuperLU< Complex, 0 > >("SuperLU", 50, 1); setptrstring(def_solver, "SuperLU"); - addsolver< VirtualSolverSuperLU< double , 1 > >("SuperILU", 50, 1); - addsolver< VirtualSolverSuperLU< Complex , 1 > >("SuperILU", 50, 1); + addsolver< VirtualSolverSuperLU< double, 1 > >("SuperILU", 50, 1); + addsolver< VirtualSolverSuperLU< Complex, 1 > >("SuperILU", 50, 1); setptrstring(def_solver, "SuperILU"); } LOADFUNC(Load_Init) diff --git a/plugin/seq/TensorK.hpp b/plugin/seq/TensorK.hpp index 9abfa8d9c..d79c47d1b 100644 --- a/plugin/seq/TensorK.hpp +++ b/plugin/seq/TensorK.hpp @@ -47,13 +47,9 @@ inline double max(double a, double b) { return a > b ? a : b; } inline double max(double a, double b, double c) { return a > c ? max(a, b) : max(b, c); } -inline double max(double a, double b, double c, double d) { - return a > d ? max(a, b, c) : max(b, c, d); -} +inline double max(double a, double b, double c, double d) { return a > d ? max(a, b, c) : max(b, c, d); } -inline double max(double a, double b, double c, double d, double e) { - return a > e ? max(a, b, c, d) : max(b, c, d, e); -} +inline double max(double a, double b, double c, double d, double e) { return a > e ? max(a, b, c, d) : max(b, c, d, e); } // ***************** Prototypes ******************** @@ -75,12 +71,7 @@ class TensorK { public: const int m_deg; const int r_deg; - enum triangulation_type { - Graded = 0, - Quasi_Acute = 1, - Quasi_Acute_Unrefined = 2, - Quasi_Acute_Proved = 3 - }; + enum triangulation_type { Graded = 0, Quasi_Acute = 1, Quasi_Acute_Unrefined = 2, Quasi_Acute_Proved = 3 }; const triangulation_type ttype; const double p_exp; enum which_matrix { M0_alone = 0, M1_alone = 1, M0_M1_weighted_sum = 2 }; @@ -92,8 +83,7 @@ class TensorK { TensorK(int m_deg_, int r_deg_, triangulation_type ttype_, which_matrix wmat, double p_exp_); - void getM(const double *D, double M[3]) - const; // L^Infinity metric // size required : D[m_deg+1], m_deg+1 == m_dim + void getM(const double *D, double M[3]) const; // L^Infinity metric // size required : D[m_deg+1], m_deg+1 == m_dim void equilibrate(const double M[3], double Me[3]) const; // Me = (det M)^(-1/((m-r)p+d)) M = (det M)^gamma_exp M. @@ -132,14 +122,10 @@ class TensorK { // **************** Constructor ******************** -TensorK::TensorK(int m_deg_, int r_deg_, triangulation_type ttype_ = Graded, - which_matrix wmat_ = M1_alone, double p_exp_ = 2) - : m_deg(m_deg_), r_deg(r_deg_), ttype(ttype_), wmat(wmat_), p_exp(p_exp_), - t_deg((ttype_ == Quasi_Acute_Proved) ? 2 * (m_deg_ - r_deg_) : m_deg_), - gamma_exp(-1. / ((m_deg_ - r_deg_) * p_exp_ + d_dim)), - homog_exp(1. / ((m_deg_ - r_deg_) * (ttype_ == Quasi_Acute_Proved ? 2. : 1.))), - is_valid(m_deg_ >= 2 && m_deg_ <= 5 && r_deg_ >= 0 && r_deg_ <= m_deg_ - 1 && ttype_ >= 0 && - ttype_ <= 3 && wmat_ >= 0 && wmat_ <= 2 && p_exp_ >= 0) { +TensorK::TensorK(int m_deg_, int r_deg_, triangulation_type ttype_ = Graded, which_matrix wmat_ = M1_alone, double p_exp_ = 2) + : m_deg(m_deg_), r_deg(r_deg_), ttype(ttype_), wmat(wmat_), p_exp(p_exp_), t_deg((ttype_ == Quasi_Acute_Proved) ? 2 * (m_deg_ - r_deg_) : m_deg_), + gamma_exp(-1. / ((m_deg_ - r_deg_) * p_exp_ + d_dim)), homog_exp(1. / ((m_deg_ - r_deg_) * (ttype_ == Quasi_Acute_Proved ? 2. : 1.))), + is_valid(m_deg_ >= 2 && m_deg_ <= 5 && r_deg_ >= 0 && r_deg_ <= m_deg_ - 1 && ttype_ >= 0 && ttype_ <= 3 && wmat_ >= 0 && wmat_ <= 2 && p_exp_ >= 0) { factorials.resize(t_deg + 1); factorials[0] = 1; @@ -299,8 +285,7 @@ void TensorK::getSquare(const double *D, double *Ds) const { for (int p = 0; p <= diff_deg; ++p) { for (int q = 0; q <= diff_deg; ++q) { - Ds[p + q] += - binomial(diff_deg, p) * binomial(diff_deg, q) / binomial(t_deg, p + q) * Dr[p] * Dr[q]; + Ds[p + q] += binomial(diff_deg, p) * binomial(diff_deg, q) / binomial(t_deg, p + q) * Dr[p] * Dr[q]; } } } @@ -340,8 +325,7 @@ void TensorK::rotate(const double *D, double *Dr, double c, double s) const { for (int u = 0; u <= j; ++u) { const int v = j - u; - Dr[p + u] += D[i] * binomial(t_deg, i) * binomial(i, p) * binomial(j, u) / - binomial(t_deg, p + u) * cpow[p + v] * spow[q + u] * parity[q]; + Dr[p + u] += D[i] * binomial(t_deg, i) * binomial(i, p) * binomial(j, u) / binomial(t_deg, p + u) * cpow[p + v] * spow[q + u] * parity[q]; } } } @@ -443,329 +427,173 @@ void TensorK::PowSym(double S[3], double p) { // ********************* Derivatives estimation ******************** template<> -void TensorK::Derivatives< 2 >(const std::vector< double > &DOFt, const R2 invHauteur[3], - double f[2]) const { +void TensorK::Derivatives< 2 >(const std::vector< double > &DOFt, const R2 invHauteur[3], double f[2]) const { f[0] = -DOFt[0] * invHauteur[0].x - DOFt[1] * invHauteur[1].x - DOFt[2] * invHauteur[2].x; f[1] = -DOFt[0] * invHauteur[0].y - DOFt[1] * invHauteur[1].y - DOFt[2] * invHauteur[2].y; } template<> -void TensorK::Derivatives< 3 >(const std::vector< double > &DOFt, const R2 invHauteur[3], - double f[3]) const { - f[0] = 4 * DOFt[0] * invHauteur[0].x * invHauteur[0].x + - 4 * DOFt[1] * invHauteur[1].x * invHauteur[1].x + - 4 * DOFt[2] * invHauteur[2].x * invHauteur[2].x + - 8 * DOFt[3] * invHauteur[1].x * invHauteur[2].x + - 8 * DOFt[4] * invHauteur[2].x * invHauteur[0].x + - 8 * DOFt[5] * invHauteur[0].x * - invHauteur[1].x; // dérivée seconde en x de la fonction P2 sur le triangle d'intérêt. - - f[1] = 4 * DOFt[0] * invHauteur[0].x * invHauteur[0].y + - 4 * DOFt[1] * invHauteur[1].x * invHauteur[1].y + - 4 * DOFt[2] * invHauteur[2].x * invHauteur[2].y + - 4 * DOFt[3] * (invHauteur[1].x * invHauteur[2].y + invHauteur[1].y * invHauteur[2].x) + - 4 * DOFt[4] * (invHauteur[2].x * invHauteur[0].y + invHauteur[2].y * invHauteur[0].x) + +void TensorK::Derivatives< 3 >(const std::vector< double > &DOFt, const R2 invHauteur[3], double f[3]) const { + f[0] = 4 * DOFt[0] * invHauteur[0].x * invHauteur[0].x + 4 * DOFt[1] * invHauteur[1].x * invHauteur[1].x + 4 * DOFt[2] * invHauteur[2].x * invHauteur[2].x + + 8 * DOFt[3] * invHauteur[1].x * invHauteur[2].x + 8 * DOFt[4] * invHauteur[2].x * invHauteur[0].x + + 8 * DOFt[5] * invHauteur[0].x * invHauteur[1].x; // dérivée seconde en x de la fonction P2 sur le triangle d'intérêt. + + f[1] = 4 * DOFt[0] * invHauteur[0].x * invHauteur[0].y + 4 * DOFt[1] * invHauteur[1].x * invHauteur[1].y + 4 * DOFt[2] * invHauteur[2].x * invHauteur[2].y + + 4 * DOFt[3] * (invHauteur[1].x * invHauteur[2].y + invHauteur[1].y * invHauteur[2].x) + 4 * DOFt[4] * (invHauteur[2].x * invHauteur[0].y + invHauteur[2].y * invHauteur[0].x) + 4 * DOFt[5] * (invHauteur[0].x * invHauteur[1].y + invHauteur[0].y * invHauteur[1].x); - f[2] = 4 * DOFt[0] * invHauteur[0].y * invHauteur[0].y + - 4 * DOFt[1] * invHauteur[1].y * invHauteur[1].y + - 4 * DOFt[2] * invHauteur[2].y * invHauteur[2].y + - 8 * DOFt[3] * invHauteur[1].y * invHauteur[2].y + - 8 * DOFt[4] * invHauteur[2].y * invHauteur[0].y + - 8 * DOFt[5] * invHauteur[0].y * invHauteur[1].y; + f[2] = 4 * DOFt[0] * invHauteur[0].y * invHauteur[0].y + 4 * DOFt[1] * invHauteur[1].y * invHauteur[1].y + 4 * DOFt[2] * invHauteur[2].y * invHauteur[2].y + + 8 * DOFt[3] * invHauteur[1].y * invHauteur[2].y + 8 * DOFt[4] * invHauteur[2].y * invHauteur[0].y + 8 * DOFt[5] * invHauteur[0].y * invHauteur[1].y; } template<> -void TensorK::Derivatives< 4 >(const std::vector< double > &DOFt, const R2 invHauteur[3], - double f[4]) const { - f[0] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x + - (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x + - (9. / 2.) * DOFt[2] * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x + - (27. / 2.) * DOFt[3] * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x + - (27. / 2.) * DOFt[4] * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + - (27. / 2.) * DOFt[5] * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x + - (27. / 2.) * DOFt[6] * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x + - (27. / 2.) * DOFt[7] * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x + - (27. / 2.) * DOFt[8] * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + - 27. * DOFt[9] * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x); - - f[1] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y + - (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y + +void TensorK::Derivatives< 4 >(const std::vector< double > &DOFt, const R2 invHauteur[3], double f[4]) const { + f[0] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x + (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x + + (9. / 2.) * DOFt[2] * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x + (27. / 2.) * DOFt[3] * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x + + (27. / 2.) * DOFt[4] * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + (27. / 2.) * DOFt[5] * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x + + (27. / 2.) * DOFt[6] * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x + (27. / 2.) * DOFt[7] * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x + + (27. / 2.) * DOFt[8] * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + 27. * DOFt[9] * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x); + + f[1] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y + (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y + (9. / 2.) * DOFt[2] * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y + - (27. / 2.) * DOFt[3] * - (invHauteur[1].x * invHauteur[1].x * invHauteur[2].y * (1. / 3.) + - invHauteur[1].y * invHauteur[1].x * invHauteur[2].x * (2. / 3.)) + - (27. / 2.) * DOFt[4] * - (invHauteur[1].x * invHauteur[2].x * invHauteur[2].y * (2. / 3.) + - invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * (1. / 3.)) + - (27. / 2.) * DOFt[5] * - (invHauteur[2].x * invHauteur[2].x * invHauteur[0].y * (1. / 3.) + - invHauteur[2].y * invHauteur[2].x * invHauteur[0].x * (2. / 3.)) + - (27. / 2.) * DOFt[6] * - (invHauteur[2].x * invHauteur[0].x * invHauteur[0].y * (2. / 3.) + - invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * (1. / 3.)) + - (27. / 2.) * DOFt[7] * - (invHauteur[0].x * invHauteur[0].x * invHauteur[1].y * (1. / 3.) + - invHauteur[0].y * invHauteur[0].x * invHauteur[1].x * (2. / 3.)) + - (27. / 2.) * DOFt[8] * - (invHauteur[0].x * invHauteur[1].x * invHauteur[1].y * (2. / 3.) + - invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * (1. / 3.)) + + (27. / 2.) * DOFt[3] * (invHauteur[1].x * invHauteur[1].x * invHauteur[2].y * (1. / 3.) + invHauteur[1].y * invHauteur[1].x * invHauteur[2].x * (2. / 3.)) + + (27. / 2.) * DOFt[4] * (invHauteur[1].x * invHauteur[2].x * invHauteur[2].y * (2. / 3.) + invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * (1. / 3.)) + + (27. / 2.) * DOFt[5] * (invHauteur[2].x * invHauteur[2].x * invHauteur[0].y * (1. / 3.) + invHauteur[2].y * invHauteur[2].x * invHauteur[0].x * (2. / 3.)) + + (27. / 2.) * DOFt[6] * (invHauteur[2].x * invHauteur[0].x * invHauteur[0].y * (2. / 3.) + invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * (1. / 3.)) + + (27. / 2.) * DOFt[7] * (invHauteur[0].x * invHauteur[0].x * invHauteur[1].y * (1. / 3.) + invHauteur[0].y * invHauteur[0].x * invHauteur[1].x * (2. / 3.)) + + (27. / 2.) * DOFt[8] * (invHauteur[0].x * invHauteur[1].x * invHauteur[1].y * (2. / 3.) + invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * (1. / 3.)) + 27. * DOFt[9] * - (invHauteur[0].x * invHauteur[1].x * invHauteur[2].y / 3. + - invHauteur[0].x * invHauteur[1].y * invHauteur[2].x / 3. + - invHauteur[0].y * invHauteur[1].x * invHauteur[2].x / 3.)); - f[2] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y + - (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y + + (invHauteur[0].x * invHauteur[1].x * invHauteur[2].y / 3. + invHauteur[0].x * invHauteur[1].y * invHauteur[2].x / 3. + invHauteur[0].y * invHauteur[1].x * invHauteur[2].x / 3.)); + f[2] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y + (9. / 2.) * DOFt[1] * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y + (9. / 2.) * DOFt[2] * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y + - (27. / 2.) * DOFt[3] * - (invHauteur[1].y * invHauteur[1].y * invHauteur[2].x * (1. / 3.) + - invHauteur[1].x * invHauteur[1].y * invHauteur[2].y * (2. / 3.)) + - (27. / 2.) * DOFt[4] * - (invHauteur[1].y * invHauteur[2].y * invHauteur[2].x * (2. / 3.) + - invHauteur[1].x * invHauteur[2].y * invHauteur[2].y * (1. / 3.)) + - (27. / 2.) * DOFt[5] * - (invHauteur[2].y * invHauteur[2].y * invHauteur[0].x * (1. / 3.) + - invHauteur[2].x * invHauteur[2].y * invHauteur[0].y * (2. / 3.)) + - (27. / 2.) * DOFt[6] * - (invHauteur[2].y * invHauteur[0].y * invHauteur[0].x * (2. / 3.) + - invHauteur[2].x * invHauteur[0].y * invHauteur[0].y * (1. / 3.)) + - (27. / 2.) * DOFt[7] * - (invHauteur[0].y * invHauteur[0].y * invHauteur[1].x * (1. / 3.) + - invHauteur[0].x * invHauteur[0].y * invHauteur[1].y * (2. / 3.)) + - (27. / 2.) * DOFt[8] * - (invHauteur[0].y * invHauteur[1].y * invHauteur[1].x * (2. / 3.) + - invHauteur[0].x * invHauteur[1].y * invHauteur[1].y * (1. / 3.)) + + (27. / 2.) * DOFt[3] * (invHauteur[1].y * invHauteur[1].y * invHauteur[2].x * (1. / 3.) + invHauteur[1].x * invHauteur[1].y * invHauteur[2].y * (2. / 3.)) + + (27. / 2.) * DOFt[4] * (invHauteur[1].y * invHauteur[2].y * invHauteur[2].x * (2. / 3.) + invHauteur[1].x * invHauteur[2].y * invHauteur[2].y * (1. / 3.)) + + (27. / 2.) * DOFt[5] * (invHauteur[2].y * invHauteur[2].y * invHauteur[0].x * (1. / 3.) + invHauteur[2].x * invHauteur[2].y * invHauteur[0].y * (2. / 3.)) + + (27. / 2.) * DOFt[6] * (invHauteur[2].y * invHauteur[0].y * invHauteur[0].x * (2. / 3.) + invHauteur[2].x * invHauteur[0].y * invHauteur[0].y * (1. / 3.)) + + (27. / 2.) * DOFt[7] * (invHauteur[0].y * invHauteur[0].y * invHauteur[1].x * (1. / 3.) + invHauteur[0].x * invHauteur[0].y * invHauteur[1].y * (2. / 3.)) + + (27. / 2.) * DOFt[8] * (invHauteur[0].y * invHauteur[1].y * invHauteur[1].x * (2. / 3.) + invHauteur[0].x * invHauteur[1].y * invHauteur[1].y * (1. / 3.)) + 27. * DOFt[9] * - (invHauteur[0].y * invHauteur[1].y * invHauteur[2].x / 3. + - invHauteur[0].y * invHauteur[1].x * invHauteur[2].y / 3. + - invHauteur[0].x * invHauteur[1].y * invHauteur[2].y / 3.)); - - f[3] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y + - (9. / 2.) * DOFt[1] * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y + - (9. / 2.) * DOFt[2] * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y + - (27. / 2.) * DOFt[3] * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y + - (27. / 2.) * DOFt[4] * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + - (27. / 2.) * DOFt[5] * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y + - (27. / 2.) * DOFt[6] * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y + - (27. / 2.) * DOFt[7] * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y + - (27. / 2.) * DOFt[8] * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + - 27. * DOFt[9] * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y); + (invHauteur[0].y * invHauteur[1].y * invHauteur[2].x / 3. + invHauteur[0].y * invHauteur[1].x * invHauteur[2].y / 3. + invHauteur[0].x * invHauteur[1].y * invHauteur[2].y / 3.)); + + f[3] = -6. * ((9. / 2.) * DOFt[0] * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y + (9. / 2.) * DOFt[1] * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y + + (9. / 2.) * DOFt[2] * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y + (27. / 2.) * DOFt[3] * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y + + (27. / 2.) * DOFt[4] * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + (27. / 2.) * DOFt[5] * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y + + (27. / 2.) * DOFt[6] * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y + (27. / 2.) * DOFt[7] * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y + + (27. / 2.) * DOFt[8] * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + 27. * DOFt[9] * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y); } template<> -void TensorK::Derivatives< 5 >(const std::vector< double > &DOFt, const R2 invHauteur[3], - double f[5]) const { +void TensorK::Derivatives< 5 >(const std::vector< double > &DOFt, const R2 invHauteur[3], double f[5]) const { f[0] = - (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * - invHauteur[0].x + - (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * - invHauteur[1].x + - (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * - invHauteur[2].x + - (128. / 3.) * DOFt[3] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * - invHauteur[2].x + - 64 * DOFt[4] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + - (128. / 3.) * DOFt[5] * 24 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x * - invHauteur[2].x + - (128. / 3.) * DOFt[6] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * - invHauteur[0].x + - 64 * DOFt[7] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x + - (128. / 3.) * DOFt[8] * 24 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x * - invHauteur[0].x + - (128. / 3.) * DOFt[9] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * - invHauteur[1].x + - 64 * DOFt[10] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + - (128. / 3.) * DOFt[11] * 24 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x * - invHauteur[1].x + - 128. * DOFt[12] * 24 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + - 128. * DOFt[13] * 24 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + - 128. * DOFt[14] * 24 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x; - - f[1] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * - invHauteur[0].y + - (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * - invHauteur[1].y + - (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * - invHauteur[2].y + - - (128. / 3.) * DOFt[3] * - (6 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * invHauteur[2].y + - 18 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x) + - 64 * DOFt[4] * - (12 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y + - 12 * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x) + - (128. / 3.) * DOFt[5] * - (18 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y + - 6 * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x) + - - (128. / 3.) * DOFt[6] * - (6 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * invHauteur[0].y + - 18 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x) + - 64 * DOFt[7] * - (12 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y + - 12 * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x) + - (128. / 3.) * DOFt[8] * - (18 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y + - 6 * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x) + - - (128. / 3.) * DOFt[9] * - (6 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * invHauteur[1].y + - 18 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x) + - 64 * DOFt[10] * - (12 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y + - 12 * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x) + - (128. / 3.) * DOFt[11] * - (18 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y + - 6 * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x) + + (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x + + (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x + + (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x + + (128. / 3.) * DOFt[3] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x + 64 * DOFt[4] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + + (128. / 3.) * DOFt[5] * 24 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x + + (128. / 3.) * DOFt[6] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x + 64 * DOFt[7] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x + + (128. / 3.) * DOFt[8] * 24 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x + + (128. / 3.) * DOFt[9] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x + 64 * DOFt[10] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + + (128. / 3.) * DOFt[11] * 24 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x + 128. * DOFt[12] * 24 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x + + 128. * DOFt[13] * 24 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x + 128. * DOFt[14] * 24 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x; + + f[1] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y + + (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y + + (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y + + + (128. / 3.) * DOFt[3] * (6 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x * invHauteur[2].y + 18 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x) + + 64 * DOFt[4] * (12 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y + 12 * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x) + + (128. / 3.) * DOFt[5] * (18 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y + 6 * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x) + + + (128. / 3.) * DOFt[6] * (6 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].x * invHauteur[0].y + 18 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x) + + 64 * DOFt[7] * (12 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y + 12 * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x) + + (128. / 3.) * DOFt[8] * (18 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y + 6 * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x) + + + (128. / 3.) * DOFt[9] * (6 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].x * invHauteur[1].y + 18 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x) + + 64 * DOFt[10] * (12 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y + 12 * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x) + + (128. / 3.) * DOFt[11] * (18 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y + 6 * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * invHauteur[1].x) + 128. * DOFt[12] * - (12 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y + - 6 * invHauteur[0].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x + + (12 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y + 6 * invHauteur[0].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x + 6 * invHauteur[0].y * invHauteur[1].x * invHauteur[2].x * invHauteur[2].x) + 128. * DOFt[13] * - (12 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y + - 6 * invHauteur[2].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x + + (12 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y + 6 * invHauteur[2].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x + 6 * invHauteur[2].y * invHauteur[0].x * invHauteur[1].x * invHauteur[1].x) + 128. * DOFt[14] * - (12 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y + - 6 * invHauteur[1].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x + + (12 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y + 6 * invHauteur[1].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x + 6 * invHauteur[1].y * invHauteur[2].x * invHauteur[0].x * invHauteur[0].x); - f[2] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * - invHauteur[0].y + - (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * - invHauteur[1].y + - (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * - invHauteur[2].y + + f[2] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y + + (32. / 3.) * DOFt[1] * 24 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y + + (32. / 3.) * DOFt[2] * 24 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y + - (128. / 3.) * DOFt[3] * - (12 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * invHauteur[2].y + - 12 * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y * invHauteur[2].x) + + (128. / 3.) * DOFt[3] * (12 * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y * invHauteur[2].y + 12 * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y * invHauteur[2].x) + 64 * DOFt[4] * - (4 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + - 16 * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].y + + (4 * invHauteur[1].x * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + 16 * invHauteur[1].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].y + 4 * invHauteur[1].y * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x) + - (128. / 3.) * DOFt[5] * - (12 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y + - 12 * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y) + + (128. / 3.) * DOFt[5] * (12 * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y + 12 * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y) + - (128. / 3.) * DOFt[6] * - (12 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * invHauteur[0].y + - 12 * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y * invHauteur[0].x) + + (128. / 3.) * DOFt[6] * (12 * invHauteur[2].x * invHauteur[2].x * invHauteur[2].y * invHauteur[0].y + 12 * invHauteur[2].x * invHauteur[2].y * invHauteur[2].y * invHauteur[0].x) + 64 * DOFt[7] * - (4 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + - 16 * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].y + + (4 * invHauteur[2].x * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + 16 * invHauteur[2].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].y + 4 * invHauteur[2].y * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x) + - (128. / 3.) * DOFt[8] * - (12 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y + - 12 * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y) + + (128. / 3.) * DOFt[8] * (12 * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y + 12 * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y) + - (128. / 3.) * DOFt[9] * - (12 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * invHauteur[1].y + - 12 * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y * invHauteur[1].x) + + (128. / 3.) * DOFt[9] * (12 * invHauteur[0].x * invHauteur[0].x * invHauteur[0].y * invHauteur[1].y + 12 * invHauteur[0].x * invHauteur[0].y * invHauteur[0].y * invHauteur[1].x) + 64 * DOFt[10] * - (4 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + - 16 * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].y + + (4 * invHauteur[0].x * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + 16 * invHauteur[0].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].y + 4 * invHauteur[0].y * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x) + - (128. / 3.) * DOFt[11] * - (12 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y + - 12 * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y) + + (128. / 3.) * DOFt[11] * (12 * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y * invHauteur[1].y + 12 * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x * invHauteur[1].y) + 128. * DOFt[12] * - (4 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + - 4 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x + - 8 * invHauteur[0].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].y + - 8 * invHauteur[0].y * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y) + + (4 * invHauteur[0].x * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + 4 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].x * invHauteur[2].x + + 8 * invHauteur[0].x * invHauteur[1].y * invHauteur[2].x * invHauteur[2].y + 8 * invHauteur[0].y * invHauteur[1].x * invHauteur[2].x * invHauteur[2].y) + 128. * DOFt[13] * - (4 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + - 4 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x + - 8 * invHauteur[2].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].y + - 8 * invHauteur[2].y * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y) + + (4 * invHauteur[2].x * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + 4 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].x * invHauteur[1].x + + 8 * invHauteur[2].x * invHauteur[0].y * invHauteur[1].x * invHauteur[1].y + 8 * invHauteur[2].y * invHauteur[0].x * invHauteur[1].x * invHauteur[1].y) + 128. * DOFt[14] * - (4 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + - 4 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x + - 8 * invHauteur[1].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].y + - 8 * invHauteur[1].y * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y); - - f[3] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * - invHauteur[0].x + - (32. / 3.) * DOFt[1] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * - invHauteur[1].x + - (32. / 3.) * DOFt[2] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * - invHauteur[2].x + - - (128. / 3.) * DOFt[3] * - (6 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * invHauteur[2].x + - 18 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].x * invHauteur[2].y) + - 64 * DOFt[4] * - (12 * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].x + - 12 * invHauteur[1].y * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y) + - (128. / 3.) * DOFt[5] * - (18 * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y * invHauteur[2].x + - 6 * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y) + - - (128. / 3.) * DOFt[6] * - (6 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * invHauteur[0].x + - 18 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].x * invHauteur[0].y) + - 64 * DOFt[7] * - (12 * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].x + - 12 * invHauteur[2].y * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y) + - (128. / 3.) * DOFt[8] * - (18 * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y * invHauteur[0].x + - 6 * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y) + - - (128. / 3.) * DOFt[9] * - (6 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * invHauteur[1].x + - 18 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].x * invHauteur[1].y) + - 64 * DOFt[10] * - (12 * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].x + - 12 * invHauteur[0].y * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y) + - (128. / 3.) * DOFt[11] * - (18 * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y * invHauteur[1].x + - 6 * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y) + + (4 * invHauteur[1].x * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + 4 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].x * invHauteur[0].x + + 8 * invHauteur[1].x * invHauteur[2].y * invHauteur[0].x * invHauteur[0].y + 8 * invHauteur[1].y * invHauteur[2].x * invHauteur[0].x * invHauteur[0].y); + + f[3] = (32. / 3.) * DOFt[0] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * invHauteur[0].x + + (32. / 3.) * DOFt[1] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * invHauteur[1].x + + (32. / 3.) * DOFt[2] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * invHauteur[2].x + + + (128. / 3.) * DOFt[3] * (6 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * invHauteur[2].x + 18 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].x * invHauteur[2].y) + + 64 * DOFt[4] * (12 * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].x + 12 * invHauteur[1].y * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y) + + (128. / 3.) * DOFt[5] * (18 * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y * invHauteur[2].x + 6 * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y) + + + (128. / 3.) * DOFt[6] * (6 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * invHauteur[0].x + 18 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].x * invHauteur[0].y) + + 64 * DOFt[7] * (12 * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].x + 12 * invHauteur[2].y * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y) + + (128. / 3.) * DOFt[8] * (18 * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y * invHauteur[0].x + 6 * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y) + + + (128. / 3.) * DOFt[9] * (6 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * invHauteur[1].x + 18 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].x * invHauteur[1].y) + + 64 * DOFt[10] * (12 * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].x + 12 * invHauteur[0].y * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y) + + (128. / 3.) * DOFt[11] * (18 * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y * invHauteur[1].x + 6 * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y) + 128. * DOFt[12] * - (12 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].x + - 6 * invHauteur[0].y * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + + (12 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].x + 6 * invHauteur[0].y * invHauteur[1].x * invHauteur[2].y * invHauteur[2].y + 6 * invHauteur[0].x * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y) + 128. * DOFt[13] * - (12 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].x + - 6 * invHauteur[2].y * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + + (12 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].x + 6 * invHauteur[2].y * invHauteur[0].x * invHauteur[1].y * invHauteur[1].y + 6 * invHauteur[2].x * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y) + 128. * DOFt[14] * - (12 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].x + - 6 * invHauteur[1].y * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + + (12 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].x + 6 * invHauteur[1].y * invHauteur[2].x * invHauteur[0].y * invHauteur[0].y + 6 * invHauteur[1].x * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y); f[4] = - (32. / 3.) * DOFt[0] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * - invHauteur[0].y + - (32. / 3.) * DOFt[1] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * - invHauteur[1].y + - (32. / 3.) * DOFt[2] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * - invHauteur[2].y + - (128. / 3.) * DOFt[3] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * - invHauteur[2].y + - 64 * DOFt[4] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + - (128. / 3.) * DOFt[5] * 24 * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y * - invHauteur[2].y + - (128. / 3.) * DOFt[6] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * - invHauteur[0].y + - 64 * DOFt[7] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y + - (128. / 3.) * DOFt[8] * 24 * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y * - invHauteur[0].y + - (128. / 3.) * DOFt[9] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * - invHauteur[1].y + - 64 * DOFt[10] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + - (128. / 3.) * DOFt[11] * 24 * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y * - invHauteur[1].y + - 128. * DOFt[12] * 24 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + - 128. * DOFt[13] * 24 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + - 128. * DOFt[14] * 24 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y; + (32. / 3.) * DOFt[0] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y + + (32. / 3.) * DOFt[1] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y + + (32. / 3.) * DOFt[2] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y + + (128. / 3.) * DOFt[3] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y + 64 * DOFt[4] * 24 * invHauteur[1].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + + (128. / 3.) * DOFt[5] * 24 * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y + + (128. / 3.) * DOFt[6] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y + 64 * DOFt[7] * 24 * invHauteur[2].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y + + (128. / 3.) * DOFt[8] * 24 * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y + + (128. / 3.) * DOFt[9] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y + 64 * DOFt[10] * 24 * invHauteur[0].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + + (128. / 3.) * DOFt[11] * 24 * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y * invHauteur[1].y + 128. * DOFt[12] * 24 * invHauteur[0].y * invHauteur[1].y * invHauteur[2].y * invHauteur[2].y + + 128. * DOFt[13] * 24 * invHauteur[2].y * invHauteur[0].y * invHauteur[1].y * invHauteur[1].y + 128. * DOFt[14] * 24 * invHauteur[1].y * invHauteur[2].y * invHauteur[0].y * invHauteur[0].y; } -void TensorK::getDerivatives(const std::vector< double > &DOFt, const R2 invHauteur[3], - double *f) const { +void TensorK::getDerivatives(const std::vector< double > &DOFt, const R2 invHauteur[3], double *f) const { assert(DOFt.size( ) == ((m_deg + 1) * m_deg) / 2); // [((m+1)*(m+2))/2] diff --git a/plugin/seq/TransfoMesh_v2.cpp b/plugin/seq/TransfoMesh_v2.cpp index 068f8dab6..68c30d8ba 100644 --- a/plugin/seq/TransfoMesh_v2.cpp +++ b/plugin/seq/TransfoMesh_v2.cpp @@ -48,9 +48,8 @@ using namespace Fem2D; #include "TransfoMesh_v2.hpp" -Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_element, int &recollement_border, int &point_confondus_ok) { +Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_element, int &recollement_border, + int &point_confondus_ok) { // cas besoin memoire important Mesh3 *T_Th3 = new Mesh3; @@ -80,9 +79,8 @@ Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double * cout << " debut: SamePointElement " << endl; - SamePointElement(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_element, - recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, - ind_nbe_t, label_nt_t, label_nbe_t, nv_t, nt_t, nbe_t); + SamePointElement(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_element, recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nt_t, label_nbe_t, nv_t, + nt_t, nbe_t); cout << " fin: SamePointElement " << endl; @@ -175,11 +173,8 @@ Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double * return T_Th3; } -void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, - int &recollement_border, int &point_confondus_ok, int *Numero_Som, - int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, - int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { +void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { double hmin; R3 bmin, bmax; @@ -198,8 +193,7 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou bmax3[1] = bmax.y; bmax3[2] = bmax.z; cout << " OrderVertexTransfo_hcode gtree " << endl; - OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, - ind_nv_t, nv_t); + OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, ind_nv_t, nv_t); cout << "fin order vertex gtree: nv_t=" << nv_t << endl; cout << " =============================== " << endl; @@ -347,15 +341,9 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou iv[jj] = Th3.operator( )(K[jj]); } - Cdg_be[i_border][0] = - (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; - Cdg_be[i_border][1] = - (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; - Cdg_be[i_border][2] = - (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; + Cdg_be[i_border][0] = (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; + Cdg_be[i_border][1] = (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; + Cdg_be[i_border][2] = (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; label_be[i_border] = K.lab; } @@ -366,8 +354,7 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou cout << "appele de PointCommun_hcode := " << point_confondus_ok << endl; // PointCommun_hcode( dim, nbe_t, point_confondus_ok, Cdg_be, bmin3, bmax3, hmin_border, ind_np, // np); - PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, - hmin_border, ind_np, label_nbe_t, np); + PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, hmin_border, ind_np, label_nbe_t, np); cout << "fin appele de PointCommun_hcode" << endl; assert(np <= nbe_t); @@ -400,9 +387,7 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou // 3D surface -Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &recollement_border, - int &point_confondus_ok) { +Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &recollement_border, int &point_confondus_ok) { // cas besoin memoire important Mesh3 *T_Th3 = new Mesh3; @@ -429,9 +414,7 @@ Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const dou cout << " debut: SamePointElement " << endl; - SamePointElement_surf(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_border, - point_confondus_ok, Numero_Som, ind_nv_t, ind_nbe_t, label_nbe_t, nv_t, - nbe_t); + SamePointElement_surf(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nbe_t, label_nbe_t, nv_t, nbe_t); cout << " fin: SamePointElement " << endl; @@ -496,10 +479,8 @@ Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const dou return T_Th3; } -void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nbe_t, - int *label_nbe_t, int &nv_t, int &nbe_t) { +void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nbe_t) { int Elem_ok; double hmin, hmin_elem; R3 bmin, bmax; @@ -518,8 +499,7 @@ void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, cons bmax3[2] = bmax.z; cout << " OrderVertexTransfo_hcode gtree " << endl; - OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, - ind_nv_t, nv_t); + OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, ind_nv_t, nv_t); cout << "fin order vertex gtree: nv_t=" << nv_t << endl; cout << " =============================== " << endl; @@ -580,15 +560,9 @@ void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, cons iv[jj] = Th3.operator( )(K[jj]); } - Cdg_be[i_border][0] = - (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; - Cdg_be[i_border][1] = - (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; - Cdg_be[i_border][2] = - (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; + Cdg_be[i_border][0] = (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; + Cdg_be[i_border][1] = (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; + Cdg_be[i_border][2] = (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; label_be[i_border] = K.lab; } @@ -599,8 +573,7 @@ void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, cons cout << "appele de PointCommun_hcode := " << point_confondus_ok << endl; // PointCommun_hcode( dim, nbe_t, point_confondus_ok, Cdg_be, bmin3, bmax3, hmin_border, ind_np, // np); - PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, - hmin_border, ind_np, label_nbe_t, np); + PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, hmin_border, ind_np, label_nbe_t, np); cout << "fin appele de PointCommun_hcode" << endl; assert(np <= nbe_t); @@ -728,9 +701,8 @@ void Transfo_Mesh2_map_face(const Mesh &Th2, map< int, int > &maptri) { } } -Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_border, int &point_confondus_ok) { +Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_border, + int &point_confondus_ok) { Mesh3 *T_Th3; //= new Mesh3; int nv_t, nt_t, nbe_t; int *Numero_Som; @@ -744,8 +716,7 @@ Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * ind_nbe_t = new int[Th2.nt]; label_nbe_t = new int[Th2.nt]; - cout << "2D: Mesh::Vertex triangle2 border " << Th2.nv << " " << Th2.nt << " " << Th2.neb - << endl; + cout << "2D: Mesh::Vertex triangle2 border " << Th2.nv << " " << Th2.nt << " " << Th2.neb << endl; for (int ii = 0; ii < Th2.nv; ii++) { Numero_Som[ii] = ii; @@ -753,22 +724,18 @@ Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * cout << " debut: SamePointElement " << endl; - SamePointElement_Mesh2(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th2, recollement_border, - point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nbe_t, - nv_t, nt_t, nbe_t); + SamePointElement_Mesh2(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th2, recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nbe_t, nv_t, nt_t, nbe_t); cout << " fin: SamePointElement " << endl; - cout << "2D transfo: Mesh::Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t - << endl; + cout << "2D transfo: Mesh::Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t << endl; T_Th3->set(nv_t, 0, nbe_t); for (int nnv = 0; nnv < nv_t; nnv++) { int ii = ind_nv_t[nnv]; assert(Numero_Som[ii] == nnv); - const Mesh::Vertex &K = - Th2.vertices[ii]; // const Vertex2 & K(Th2.vertices[ii]); //Version Mesh2 + const Mesh::Vertex &K = Th2.vertices[ii]; // const Vertex2 & K(Th2.vertices[ii]); //Version Mesh2 T_Th3->vertices[nnv].x = tab_XX[ii]; T_Th3->vertices[nnv].y = tab_YY[ii]; T_Th3->vertices[nnv].z = tab_ZZ[ii]; @@ -780,8 +747,7 @@ Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * int iv[3]; int ii = ind_nbe_t[ibe]; // creation of elements - const Mesh::Triangle &K( - Th2.t(ii)); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 + const Mesh::Triangle &K(Th2.t(ii)); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 iv[0] = Numero_Som[Th2.operator( )(K[0])]; iv[1] = Numero_Som[Th2.operator( )(K[1])]; iv[2] = Numero_Som[Th2.operator( )(K[2])]; @@ -988,10 +954,8 @@ Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * * } */ -void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, - int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { +void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { R3 bmin, bmax; double hmin; @@ -1009,8 +973,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con bmax3[1] = bmax.y; bmax3[2] = bmax.z; cout << "debut: OrderVertexTransfo_hcode_gtree " << endl; - OrderVertexTransfo_hcode_nv_gtree(Th2.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, - ind_nv_t, nv_t); + OrderVertexTransfo_hcode_nv_gtree(Th2.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, ind_nv_t, nv_t); cout << "fin: OrderVertexTransfo_hcode_gtree " << endl; /* determination de nt_t et de nbe_t*/ @@ -1062,8 +1025,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con for (int i_border = 0; i_border < nbe_t; i_border++) { int &ii = ind_nbe_t[i_border]; - const Mesh::Triangle &K( - Th2.t(ii)); // const Triangle2 & K(Th2.elements[ii]); // avant Mesh2 + const Mesh::Triangle &K(Th2.t(ii)); // const Triangle2 & K(Th2.elements[ii]); // avant Mesh2 int iv[3]; for (int jj = 0; jj < 3; jj++) { @@ -1081,8 +1043,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con cout << "points commun " << endl; // PointCommun_hcode( dim, nbe_t, point_confondus_ok, Cdg_be, bmin3, bmax3, hmin_border, ind_np, // np); // ancien - PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, - hmin_border, ind_np, label_nbe_t, np); // new + PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, hmin_border, ind_np, label_nbe_t, np); // new cout << "points commun finis " << endl; assert(np <= nbe_t); @@ -1173,9 +1134,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con // Fin cas 2D //= ===================== // version Mesh2 -void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, - double &hmin) { +void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin) { // determination de la boite englobante double precispt; @@ -1226,8 +1185,7 @@ void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, cons for (int kk = jj + 1; kk < 3; kk++) { int &i1 = iv[jj]; int &i2 = iv[kk]; - longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + - pow(tab_ZZ[i1] - tab_ZZ[i2], 2); + longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + pow(tab_ZZ[i1] - tab_ZZ[i2], 2); longedge = sqrt(longedge); // cout << "longedge=" << longedge << endl; if (longedge > precispt) { @@ -1248,9 +1206,7 @@ void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, cons // version Mesh3 -void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, - double &hmin) { +void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, double &hmin) { // determination de la boite englobante double precispt; @@ -1306,8 +1262,7 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons for (int kk = jj + 1; kk < 4; kk++) { int &i1 = iv[jj]; int &i2 = iv[kk]; - longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + - pow(tab_ZZ[i1] - tab_ZZ[i2], 2); + longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + pow(tab_ZZ[i1] - tab_ZZ[i2], 2); longedge = sqrt(longedge); if (longedge > precispt) { hmin = min(hmin, longedge); @@ -1329,9 +1284,8 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons //= ===================== // //= ===================== -void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const double *bmin, const double *bmax, - const double hmin, int *Numero_Som, int *ind_nv_t, int &nv_t) { +void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const double *bmin, const double *bmax, const double hmin, int *Numero_Som, + int *ind_nv_t, int &nv_t) { size_t j[3]; size_t k[3]; size_t NbCode = 100000; @@ -1351,9 +1305,8 @@ void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const numberofpointsdiff = 0; for (int jj = ii + 1; jj < tab_nv; jj++) { - double dist; // = 0.; - dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + - pow(tab_ZZ[jj] - tab_ZZ[ii], 2); // pow(Coord_Point[jj][kk]-Coord_Point[ii][kk],2); + double dist; // = 0.; + dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + pow(tab_ZZ[jj] - tab_ZZ[ii], 2); // pow(Coord_Point[jj][kk]-Coord_Point[ii][kk],2); if (sqrt(dist) < epsilon) { numberofpointsdiff = 1; } @@ -1425,8 +1378,7 @@ void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const continue; } - dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + - pow(tab_ZZ[jj] - tab_ZZ[ii], 2); + dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + pow(tab_ZZ[jj] - tab_ZZ[ii], 2); if (sqrt(dist) < epsilon) { // point semblable @@ -1447,9 +1399,7 @@ void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const delete[] posv; } -void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const double *bmin, const double *bmax, - const double hmin, int *ind_np, int &np) { +void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const double *bmin, const double *bmax, const double hmin, int *ind_np, int &np) { size_t j[dim]; size_t k[dim]; size_t NbCode = 100000; @@ -1564,9 +1514,8 @@ void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_con } } - ind_np[np] = - ii; // min(ii,minimum_np); // Remarque on donne a np le plus petit element - np++; // nv_t = nvt+1; + ind_np[np] = ii; // min(ii,minimum_np); // Remarque on donne a np le plus petit element + np++; // nv_t = nvt+1; } } @@ -1606,9 +1555,8 @@ void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_con } if (point_multiple == 0) { - ind_np[np] = - ii; // min(ii,minimum_np); // Remarque on donne a np le plus petit element - np++; // nv_t = nvt+1; + ind_np[np] = ii; // min(ii,minimum_np); // Remarque on donne a np le plus petit element + np++; // nv_t = nvt+1; } } } @@ -1626,9 +1574,7 @@ void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_con // fonction avec Gtree pour FreeFem++ -void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, - const double &hmin, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int *Numero_Som, +void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, const double &hmin, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int *Numero_Som, int *ind_nv_t, int &nv_t) { size_t i; size_t j[3]; @@ -1683,10 +1629,8 @@ void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const numberofpointsdiff = 0; for (int jj = ii + 1; jj < tab_nv; jj++) { - double dist; // = 0.; - dist = - pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + - pow(tab_ZZ[jj] - tab_ZZ[ii], 2); // pow(Coord_Point[jj][kk]-Coord_Point[ii][kk],2); + double dist; // = 0.; + dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + pow(tab_ZZ[jj] - tab_ZZ[ii], 2); // pow(Coord_Point[jj][kk]-Coord_Point[ii][kk],2); if (sqrt(dist) < hseuil) { numberofpointsdiff = 1; } @@ -1706,10 +1650,8 @@ void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const delete gtree; } -void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const int *label_point, const R3 &bmin, - const R3 &bmax, const double &hmin, int *ind_np, int *ind_label, - int &np) { +void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const int *label_point, const R3 &bmin, const R3 &bmax, const double &hmin, + int *ind_np, int *ind_label, int &np) { double hseuil = hmin / 10.; Vertex3 *v = new Vertex3[NbPoints]; EF23::GTree< Vertex3 > *gtree = new EF23::GTree< Vertex3 >(v, bmin, bmax, 0); diff --git a/plugin/seq/TransfoMesh_v2.hpp b/plugin/seq/TransfoMesh_v2.hpp index 021027c8f..c94791bee 100644 --- a/plugin/seq/TransfoMesh_v2.hpp +++ b/plugin/seq/TransfoMesh_v2.hpp @@ -32,62 +32,40 @@ using namespace std; -void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin); -void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, - double &hmin); - -void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const double *bmin, const double *bmax, - const double hmin, int *ind_np, int &np); - -void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const int *label_point, const R3 &bmin, - const R3 &bmax, const double &hmin, int *ind_np, int *ind_label, - int &np); - -void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const double *bmin, const double *bmax, - const double hmin, int *Numero_Som, int *ind_nv_t, int &nv_t); - -void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, - const double &hmin, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int *Numero_Som, +void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin); +void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, double &hmin); + +void PointCommun_hcode(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const double *bmin, const double *bmax, const double hmin, int *ind_np, int &np); + +void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const int *label_point, const R3 &bmin, const R3 &bmax, const double &hmin, + int *ind_np, int *ind_label, int &np); + +void OrderVertexTransfo_hcode_nv(const int &tab_nv, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const double *bmin, const double *bmax, const double hmin, int *Numero_Som, + int *ind_nv_t, int &nv_t); + +void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, const double &hmin, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int *Numero_Som, int *ind_nv_t, int &nv_t); -void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, - int &recollement_border, int &point_confondus_ok, int *Numero_Som, - int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, - int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); +void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); -Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_element, int &recollement_border, int &point_confondus_ok); +Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_element, int &recollement_border, + int &point_confondus_ok); // CAS 3D surfacique -void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nbe_t, - int *label_nbe_t, int &nv_t, int &nbe_t); +void SamePointElement_surf(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nbe_t); -Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &recollement_border, - int &point_confondus_ok); +Mesh3 *Transfo_Mesh3_surf(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &recollement_border, int &point_confondus_ok); // fonction pour le cas 2D -void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, - int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); +void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); void Transfo_Mesh2_map_face(const Mesh &Th2, map< int, int > &maptri); -Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_border, int &point_confondus_ok); +Mesh3 *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_border, int &point_confondus_ok); #endif diff --git a/plugin/seq/UMFPACK64.cpp b/plugin/seq/UMFPACK64.cpp index f955c5976..df983a681 100644 --- a/plugin/seq/UMFPACK64.cpp +++ b/plugin/seq/UMFPACK64.cpp @@ -31,7 +31,7 @@ using namespace std; #include "ff++.hpp" #ifdef _WIN32 -typedef long long int64; +typedef long long int64; #else typedef long long int64; #endif @@ -47,8 +47,7 @@ class VirtualSolverUMFPACK64 : public VirtualSolver< int, K > { HMat64 *pA64; VirtualSolverUMFPACK< SuiteSparse_long, K > v64; - VirtualSolverUMFPACK64(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) - : pA(&AA), pA64(new HashMatrix< SuiteSparse_long, K >(AA)), v64(*pA64, ds, stack) {} + VirtualSolverUMFPACK64(HMat &AA, const Data_Sparse_Solver &ds, Stack stack) : pA(&AA), pA64(new HashMatrix< SuiteSparse_long, K >(AA)), v64(*pA64, ds, stack) {} void dosolver(K *x, K *b, int N, int trans) { return v64.dosolver(x, b, N, trans); } void fac_init( ) { v64.fac_init( ); } // n, nzz fixe diff --git a/plugin/seq/VTK_writer.cpp b/plugin/seq/VTK_writer.cpp index 2fbe577d7..3d9c72bc8 100644 --- a/plugin/seq/VTK_writer.cpp +++ b/plugin/seq/VTK_writer.cpp @@ -87,8 +87,7 @@ class VtkWriter { _ofdata << ""; _ofdata << std::endl; _ofdata << "" << std::endl; - _ofdata - << ""; + _ofdata << ""; _ofdata << std::endl; for (int k = 0; k < Th.nv; ++k) { @@ -110,8 +109,7 @@ class VtkWriter { _ofdata << std::endl; _ofdata << "" << std::endl; - _ofdata - << ""; + _ofdata << ""; _ofdata << std::endl; for (int i = 0; i < Th.nt; ++i) { @@ -120,8 +118,7 @@ class VtkWriter { _ofdata << std::endl; _ofdata << "" << std::endl; - _ofdata - << ""; + _ofdata << ""; _ofdata << std::endl; for (int i = 0; i < Th.nt; ++i) { @@ -164,8 +161,7 @@ class VtkWriter { } /*!Add a field*/ - void addvector(const string &nameoffield, const Fem2D::Mesh *mesh, const KN< double > &val, - const KN< double > &val2) { + void addvector(const string &nameoffield, const Fem2D::Mesh *mesh, const KN< double > &val, const KN< double > &val2) { _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); @@ -174,8 +170,7 @@ class VtkWriter { _ofdata << std::endl; for (int i = 0; i < val.size( ); ++i) { - _ofdata << checkprecision(val[i]) << " " << checkprecision(val2[i]) << " " << 0.0 - << std::endl; + _ofdata << checkprecision(val[i]) << " " << checkprecision(val2[i]) << " " << 0.0 << std::endl; } _ofdata << "" << std::endl; @@ -262,9 +257,7 @@ class Vtkwritesol_Op : public E_F0mps { } // all type - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< VtkWriter * >( ), atype< string * >( ), true); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< VtkWriter * >( ), atype< string * >( ), true); } static E_F0 *f(const basicAC_F0 &args) { return new Vtkwritesol_Op(args); } @@ -355,8 +348,7 @@ static void Load_Init( ) { zzzfff->Add("VtkWriter", atype< VtkWriter * >( )); // ajoute le type myType a freefem++ // constructeur d'un type myType dans freefem TheOperators->Add("<-", new OneOperator2_< VtkWriter *, VtkWriter *, string * >(&init_VtkWriter)); - Global.Add("Vtkaddmesh", "(", - new OneOperator2_< void *, VtkWriter *, const Fem2D::Mesh * >(call_addmesh)); + Global.Add("Vtkaddmesh", "(", new OneOperator2_< void *, VtkWriter *, const Fem2D::Mesh * >(call_addmesh)); Global.Add("Vtkaddscalar", "(", new OneOperatorCode< Vtkwritesol_Op >); } diff --git a/plugin/seq/VTK_writer_3d.cpp b/plugin/seq/VTK_writer_3d.cpp index c6cc96663..647f47740 100644 --- a/plugin/seq/VTK_writer_3d.cpp +++ b/plugin/seq/VTK_writer_3d.cpp @@ -81,15 +81,11 @@ class VtkWriter { _ofdata.precision(17); _ofdata << "" << std::endl; - _ofdata << "" - << std::endl; + _ofdata << "" << std::endl; _ofdata << "" << std::endl; - _ofdata << "" - << std::endl; + _ofdata << "" << std::endl; _ofdata << "" << std::endl; - _ofdata - << "" - << std::endl; + _ofdata << "" << std::endl; for (int k = 0; k < Th.nv; ++k) { _ofdata << Th(k).x << " " << Th(k).y << " " << Th(k).z << std::endl; @@ -110,9 +106,7 @@ class VtkWriter { _ofdata << std::endl; _ofdata << "" << std::endl; - _ofdata - << "" - << std::endl; + _ofdata << "" << std::endl; for (int i = 0; i < Th.nt; ++i) { _ofdata << 4 + 4 * (i) << " "; @@ -120,8 +114,7 @@ class VtkWriter { _ofdata << std::endl; _ofdata << "" << std::endl; - _ofdata << "" - << std::endl; + _ofdata << "" << std::endl; for (int i = 0; i < Th.nt; ++i) { _ofdata << 10 << " "; @@ -138,8 +131,7 @@ class VtkWriter { _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); - _ofdata << "" << std::endl; + _ofdata << "" << std::endl; for (int i = 0; i < val.size( ); ++i) { _ofdata << checkprecision(val[i]) << std::endl; @@ -162,17 +154,14 @@ class VtkWriter { } /*!Add a field*/ - void addvector(const string &nameoffield, const Mesh3 *mesh, const KN< double > &val, - const KN< double > &val2, const KN< double > &val3) { + void addvector(const string &nameoffield, const Mesh3 *mesh, const KN< double > &val, const KN< double > &val2, const KN< double > &val3) { _ofdata.flags(std::ios_base::scientific); _ofdata.precision(17); - _ofdata << "" << std::endl; + _ofdata << "" << std::endl; for (int i = 0; i < val.size( ); ++i) { - _ofdata << checkprecision(val[i]) << " " << checkprecision(val2[i]) << " " - << checkprecision(val3[i]) << std::endl; + _ofdata << checkprecision(val[i]) << " " << checkprecision(val2[i]) << " " << checkprecision(val3[i]) << std::endl; } _ofdata << "" << std::endl; @@ -267,9 +256,7 @@ class Vtkwritesol_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< VtkWriter * >( ), atype< string * >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< VtkWriter * >( ), atype< string * >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new Vtkwritesol_Op(args); } @@ -376,15 +363,13 @@ void *call_addmesh(VtkWriter *const &mt, const Mesh3 *const &pTh) { // Add the function name to the freefem++ table static void Load_Init( ) { - Dcl_Type< VtkWriter * >( - InitP< VtkWriter >, - Destroy< VtkWriter >); // declare deux nouveau type pour freefem++ un pointeur et + Dcl_Type< VtkWriter * >(InitP< VtkWriter >, + Destroy< VtkWriter >); // declare deux nouveau type pour freefem++ un pointeur et zzzfff->Add("VtkWriter", atype< VtkWriter * >( )); // ajoute le type myType a freefem++ // constructeur d'un type myType dans freefem TheOperators->Add("<-", new OneOperator2_< VtkWriter *, VtkWriter *, string * >(&init_VtkWriter)); - Global.Add("Vtkaddmesh", "(", - new OneOperator2_< void *, VtkWriter *, const Mesh3 * >(call_addmesh)); + Global.Add("Vtkaddmesh", "(", new OneOperator2_< void *, VtkWriter *, const Mesh3 * >(call_addmesh)); Global.Add("Vtkaddscalar", "(", new OneOperatorCode< Vtkwritesol_Op >); } diff --git a/plugin/seq/addNewType.cpp b/plugin/seq/addNewType.cpp index 354c8d893..eebec7bd9 100644 --- a/plugin/seq/addNewType.cpp +++ b/plugin/seq/addNewType.cpp @@ -77,9 +77,7 @@ myType *init_MyType(myType *const &a, string *const &s) { * \param v const double & * \return myType_uv(mt, u, v); */ -myType_uv set_myType_uv(myType *const &mt, const double &u, const double &v) { - return myType_uv(mt, u, v); -} +myType_uv set_myType_uv(myType *const &mt, const double &u, const double &v) { return myType_uv(mt, u, v); } /*! * \brief Set a type @@ -122,8 +120,7 @@ static void Load_Init( ) { // two steps: // add the method x on myType_uv // add function on myType_uv - atype< myType * >( )->Add( - "(", "", new OneOperator3_< myType_uv, myType *, double, double >(set_myType_uv)); + atype< myType * >( )->Add("(", "", new OneOperator3_< myType_uv, myType *, double, double >(set_myType_uv)); Add< myType_uv >("x", ".", new OneOperator1_< double, myType_uv >(get_myType_uv_x)); Add< myType_uv >("N", ".", new OneOperator1_< R3 *, myType_uv >(get_myType_uv_N)); diff --git a/plugin/seq/aniso.cpp b/plugin/seq/aniso.cpp index 247b7487f..877eaf082 100644 --- a/plugin/seq/aniso.cpp +++ b/plugin/seq/aniso.cpp @@ -112,8 +112,7 @@ int BoundAniso3d(double mff[6], double cmin) { for (int k = 0, i = 0; i < 3; i++) { for (int j = i; j < 3; j++) { - m[k++] = - l[0] * vp[0][i] * vp[0][j] + l[1] * vp[1][i] * vp[1][j] + l[2] * vp[2][i] * vp[2][j]; + m[k++] = l[0] * vp[0][i] * vp[0][j] + l[1] * vp[1][i] * vp[1][j] + l[2] * vp[2][i] * vp[2][j]; } } } @@ -156,8 +155,7 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme cout << " load: aniso " << endl; } - Global.Add("boundaniso", "(", - new OneOperator3_< long, long, KN< double > *, double >(Boundaniso)); + Global.Add("boundaniso", "(", new OneOperator3_< long, long, KN< double > *, double >(Boundaniso)); } #define WITH_NO_INIT diff --git a/plugin/seq/bfstream.cpp b/plugin/seq/bfstream.cpp index 790928cd6..bd633b53b 100644 --- a/plugin/seq/bfstream.cpp +++ b/plugin/seq/bfstream.cpp @@ -33,78 +33,72 @@ #include #include #include -template -struct swap_bytes -{ - static char * swap(char *t) - { - throw std::out_of_range("data size"); - } +template< size_t sz > +struct swap_bytes { + static char *swap(char *t) { throw std::out_of_range("data size"); } }; template<> -struct swap_bytes<1> -{ - static inline char * swap(char *t) - { - return t; - } +struct swap_bytes< 1 > { + static inline char *swap(char *t) { return t; } }; template<> -struct swap_bytes<2> -{ - static inline char * swap(char *t) - { - std::swap(t[0],t[1]); - return t; - } +struct swap_bytes< 2 > { + static inline char *swap(char *t) { + std::swap(t[0], t[1]); + return t; + } }; -void dumpb(char *t,int sz) -{ - for(int k=0; k< sz; ++k) - cout << (int) t[k] << " "; - cout << "\n"; +void dumpb(char *t, int sz) { + for (int k = 0; k < sz; ++k) cout << (int)t[k] << " "; + cout << "\n"; } template<> -struct swap_bytes<4> -{ - static inline char * swap(char *t) - { - dumpb(t,4); - std::swap(t[0],t[3]); - std::swap(t[1],t[2]); - dumpb(t,4); - return t; - } +struct swap_bytes< 4 > { + static inline char *swap(char *t) { + dumpb(t, 4); + std::swap(t[0], t[3]); + std::swap(t[1], t[2]); + dumpb(t, 4); + return t; + } }; template<> -struct swap_bytes<8> -{ - static inline char * swap(char *t) - { - std::swap(t[0],t[7]); - std::swap(t[1],t[6]); - std::swap(t[2],t[5]); - std::swap(t[3],t[4]); - return t; - } +struct swap_bytes< 8 > { + static inline char *swap(char *t) { + std::swap(t[0], t[7]); + std::swap(t[1], t[6]); + std::swap(t[2], t[5]); + std::swap(t[3], t[4]); + return t; + } }; -bool islittleendian() { uint32_t i=1,ii = (i <<8); return ii==256;} -bool isbigendian() { uint32_t i=1,ii = (i <<8);return ii!=256;} +bool islittleendian( ) { + uint32_t i = 1, ii = (i << 8); + return ii == 256; +} +bool isbigendian( ) { + uint32_t i = 1, ii = (i << 8); + return ii != 256; +} -template T swapbyte(T val) { swap_bytes::swap( reinterpret_cast< char * >( &val));return val;} +template< typename T > +T swapbyte(T val) { + swap_bytes< sizeof(T) >::swap(reinterpret_cast< char * >(&val)); + return val; +} template< class T > class Stream_b { -public: - Stream_b(T *ff) : f(ff) {} - - Stream_b(T **ff) : f(*ff) { ffassert(f); } - - Stream_b(const Stream_b &io) : f(io.f) {} - - T *f; + public: + Stream_b(T *ff) : f(ff) {} + + Stream_b(T **ff) : f(*ff) { ffassert(f); } + + Stream_b(const Stream_b &io) : f(io.f) {} + + T *f; }; /*! @@ -114,7 +108,7 @@ class Stream_b { */ template< class T > Stream_b< T > pto_stream_b(T **f) { - return Stream_b< T >(f); + return Stream_b< T >(f); } /*! @@ -124,7 +118,7 @@ Stream_b< T > pto_stream_b(T **f) { */ template< class T > Stream_b< T > to_stream_b(T *f) { - return Stream_b< T >(f); + return Stream_b< T >(f); } /*! @@ -133,16 +127,16 @@ Stream_b< T > to_stream_b(T *f) { * \param data T *const & * \return istream * */ -template< class T,class TF=T > +template< class T, class TF = T > istream *Read(Stream_b< istream > const &io, T *const &data) { - if(is_same::value) - io.f->read(reinterpret_cast< char * >(data), sizeof(*data)); - else { - TF dataf; - io.f->read(reinterpret_cast< char * >(&dataf), sizeof(dataf)); - *data=dataf; - } - return io.f; + if (is_same< T, TF >::value) + io.f->read(reinterpret_cast< char * >(data), sizeof(*data)); + else { + TF dataf; + io.f->read(reinterpret_cast< char * >(&dataf), sizeof(dataf)); + *data = dataf; + } + return io.f; } /*! @@ -151,28 +145,27 @@ istream *Read(Stream_b< istream > const &io, T *const &data) { * \param data KN * const & * \return istream * */ -template< class T ,class TF=T > +template< class T, class TF = T > istream *Read(Stream_b< istream > const &io, KN< T > *const &data) { - int64_t n; - - io.f->read(reinterpret_cast< char * >(&n), sizeof(int64_t)); - if (verbosity > 0) cout << " read n =" << n << " " << n * sizeof(sizeof(T)) << " " << endl; - if (n != data->N( )) { - data->resize(n); - } - - T *p = *data; - if(is_same::value) - io.f->read(reinterpret_cast< char * >(p), n * sizeof(T)); - else { - TF pf; - for(int i=0; i< n;++i) - { - io.f->read(reinterpret_cast< char * >(&pf), sizeof(TF)); - p[i]= pf; - } + int64_t n; + + io.f->read(reinterpret_cast< char * >(&n), sizeof(int64_t)); + if (verbosity > 0) cout << " read n =" << n << " " << n * sizeof(sizeof(T)) << " " << endl; + if (n != data->N( )) { + data->resize(n); + } + + T *p = *data; + if (is_same< T, TF >::value) + io.f->read(reinterpret_cast< char * >(p), n * sizeof(T)); + else { + TF pf; + for (int i = 0; i < n; ++i) { + io.f->read(reinterpret_cast< char * >(&pf), sizeof(TF)); + p[i] = pf; } - return io.f; + } + return io.f; } /*! @@ -181,31 +174,30 @@ istream *Read(Stream_b< istream > const &io, KN< T > *const &data) { * \param data KNM * const & * \return istream * */ -template -istream *Read(Stream_b const &io, KNM *const &data) { - int64_t m, n; - - io.f->read(reinterpret_cast(&n), sizeof(int64_t)); - io.f->read(reinterpret_cast(&m), sizeof(int64_t)); - - if (verbosity > 0) - cout << "Read matrix of size (" << n << ", " << m << ")" << endl; - - data->resize(n, m); - T *p = *data; - - if (is_same::value) { - io.f->read(reinterpret_cast(p), m * n * sizeof(T)); - } else { - TF pf; - for (int i = 0; i < m * n; ++i) { - io.f->read(reinterpret_cast(&pf), sizeof(TF)); - p[i] = pf; - } +template< class T, class TF = T > +istream *Read(Stream_b< istream > const &io, KNM< T > *const &data) { + int64_t m, n; + + io.f->read(reinterpret_cast< char * >(&n), sizeof(int64_t)); + io.f->read(reinterpret_cast< char * >(&m), sizeof(int64_t)); + + if (verbosity > 0) cout << "Read matrix of size (" << n << ", " << m << ")" << endl; + + data->resize(n, m); + T *p = *data; + + if (is_same< T, TF >::value) { + io.f->read(reinterpret_cast< char * >(p), m * n * sizeof(T)); + } else { + TF pf; + for (int i = 0; i < m * n; ++i) { + io.f->read(reinterpret_cast< char * >(&pf), sizeof(TF)); + p[i] = pf; } - - return io.f; -} + } + + return io.f; +} /*! * \brief Write @@ -213,24 +205,23 @@ istream *Read(Stream_b const &io, KNM *const &data) { * \param data KN * const * \return ostream * */ -template< class T,class TR=T > +template< class T, class TR = T > ostream *Write(Stream_b< ostream > const &io, KN< T > *const &data) { - T *p = *data; - int64_t n = data->N( ); - - if (verbosity > 0) cout << " write n =" << n << " " << n * sizeof(T) << " " << p << endl; - io.f->write(reinterpret_cast< const char * >(&n), sizeof(int64_t)); - if(is_same::value) - io.f->write(reinterpret_cast< const char * >(p), n * sizeof(T)); - else { - for( long i=0;i< n; ++i) - { - TR b= p[i]; - io.f->write(reinterpret_cast< const char * >(&b), sizeof(TR)); - if (verbosity > 5) cout << " write entry " << i << " p[i]=" << p[i] << endl; - } + T *p = *data; + int64_t n = data->N( ); + + if (verbosity > 0) cout << " write n =" << n << " " << n * sizeof(T) << " " << p << endl; + io.f->write(reinterpret_cast< const char * >(&n), sizeof(int64_t)); + if (is_same< T, TR >::value) + io.f->write(reinterpret_cast< const char * >(p), n * sizeof(T)); + else { + for (long i = 0; i < n; ++i) { + TR b = p[i]; + io.f->write(reinterpret_cast< const char * >(&b), sizeof(TR)); + if (verbosity > 5) cout << " write entry " << i << " p[i]=" << p[i] << endl; } - return io.f; + } + return io.f; } /*! @@ -239,15 +230,15 @@ ostream *Write(Stream_b< ostream > const &io, KN< T > *const &data) { * \param data T * const & * \return ostream * */ -template< class T ,class TF> +template< class T, class TF > ostream *Write(Stream_b< ostream > const &io, T *const &data) { - if(is_same::value) + if (is_same< T, TF >::value) io.f->write(reinterpret_cast< const char * >(data), sizeof(*data)); - else { - TF dataf=*data; - io.f->write(reinterpret_cast< const char * >(&dataf), sizeof(dataf)); - } - return io.f; + else { + TF dataf = *data; + io.f->write(reinterpret_cast< const char * >(&dataf), sizeof(dataf)); + } + return io.f; } /*! @@ -256,15 +247,15 @@ ostream *Write(Stream_b< ostream > const &io, T *const &data) { * \param data T * const & * \return ostream * */ -template< class T,class TF > +template< class T, class TF > ostream *Write(Stream_b< ostream > const &io, T const &data) { - if(is_same::value) + if (is_same< T, TF >::value) io.f->write(reinterpret_cast< const char * >(&data), sizeof(data)); - else { - TF dataf=data; - io.f->write(reinterpret_cast< const char * >(&dataf), sizeof(dataf)); - } - return io.f; + else { + TF dataf = data; + io.f->write(reinterpret_cast< const char * >(&dataf), sizeof(dataf)); + } + return io.f; } /*! @@ -273,71 +264,66 @@ ostream *Write(Stream_b< ostream > const &io, T const &data) { * \param data KNM * const & * \return ostream * */ -template -ostream *Write(Stream_b const &io, KNM *const &data) { - int64_t m = data->M(); - int64_t n = data->N(); - - if (verbosity > 0) - cout << "Write matrix of size (" << n << ", " << m << ")" << endl; - - io.f->write(reinterpret_cast(&n), sizeof(int64_t)); - io.f->write(reinterpret_cast(&m), sizeof(int64_t)); - - T *p = *data; - if (is_same::value) { - io.f->write(reinterpret_cast(p), m * n * sizeof(T)); - } else { - for (long i = 0; i < m * n; ++i) { - TR b = p[i]; - io.f->write(reinterpret_cast(&b), sizeof(TR)); - } +template< class T, class TR = T > +ostream *Write(Stream_b< ostream > const &io, KNM< T > *const &data) { + int64_t m = data->M( ); + int64_t n = data->N( ); + + if (verbosity > 0) cout << "Write matrix of size (" << n << ", " << m << ")" << endl; + + io.f->write(reinterpret_cast< const char * >(&n), sizeof(int64_t)); + io.f->write(reinterpret_cast< const char * >(&m), sizeof(int64_t)); + + T *p = *data; + if (is_same< T, TR >::value) { + io.f->write(reinterpret_cast< const char * >(p), m * n * sizeof(T)); + } else { + for (long i = 0; i < m * n; ++i) { + TR b = p[i]; + io.f->write(reinterpret_cast< const char * >(&b), sizeof(TR)); } - - return io.f; + } + + return io.f; } -template< class T,class TW > -ostream *Write( ostream * f, T data) { - TW dataw=data; - f->write(reinterpret_cast< const char * >(&dataw), sizeof(T)); - return f; +template< class T, class TW > +ostream *Write(ostream *f, T data) { + TW dataw = data; + f->write(reinterpret_cast< const char * >(&dataw), sizeof(T)); + return f; } // correction 27/09/24 FH.. -template< class T,class TR=T > -istream * Reada( istream * f, KN_ a) { - if(verbosity>9) cout << " reada " << (a.contiguous() && is_same::value ) << endl; - if( a.contiguous() && is_same::value ) - f->read(reinterpret_cast< char * >((T*) a), sizeof(T)*a.N()); - else - { - TR b; - for(long i=0; iread(reinterpret_cast< char * >(&b), sizeof(TR)); - a[i]=b; - if(i<256 && (verbosity>19)) - cout << "Reada cmp " << i << " "<< b << " " << a[i]<< endl; - } - +template< class T, class TR = T > +istream *Reada(istream *f, KN_< T > a) { + if (verbosity > 9) cout << " reada " << (a.contiguous( ) && is_same< T, TR >::value) << endl; + if (a.contiguous( ) && is_same< T, TR >::value) + f->read(reinterpret_cast< char * >((T *)a), sizeof(T) * a.N( )); + else { + TR b; + for (long i = 0; i < a.N( ); ++i) { + f->read(reinterpret_cast< char * >(&b), sizeof(TR)); + a[i] = b; + if (i < 256 && (verbosity > 19)) cout << "Reada cmp " << i << " " << b << " " << a[i] << endl; } - return f; + } + return f; } template< class T, class TR > -istream * Read( istream * f, T * data) { - TR datar; - f->read(reinterpret_cast< char * >(&datar), sizeof(TR)); - *data = datar; - return f; +istream *Read(istream *f, T *data) { + TR datar; + f->read(reinterpret_cast< char * >(&datar), sizeof(TR)); + *data = datar; + return f; } template< class T, class TR > -istream * readswapbyte( istream * f, T * data) { - TR datar; - f->read(reinterpret_cast< char * >(&datar), sizeof(TR)); - datar= swapbyte(datar); - *data = datar; - return f; +istream *readswapbyte(istream *f, T *data) { + TR datar; + f->read(reinterpret_cast< char * >(&datar), sizeof(TR)); + datar = swapbyte(datar); + *data = datar; + return f; } /*! @@ -346,71 +332,48 @@ istream * readswapbyte( istream * f, T * data) { * \param data T * const & * \return ostream * */ -template< class K ,class KF=K> +template< class K, class KF = K > void initK( ) { - typedef Stream_b< ostream > OB; - typedef Stream_b< istream > IB; - Add< IB >("(", "", new OneOperator2_< istream *, IB, K * >(Read)); - Add< OB >("(", "", new OneOperator2_< ostream *, OB, K * >(10,Write)); - Add< OB >("(", "", new OneOperator2_< ostream *, OB, K >(Write)); - Add< IB >("(", "", new OneOperator2_< istream *, IB, KN< K > * >(Read)); - Add< OB >("(", "", new OneOperator2_< ostream *, OB, KN< K > * >(Write)); - Add< IB >("(", "", new OneOperator2_ * >(Read)); - Add< OB >("(", "", new OneOperator2_ * >(Write)); + typedef Stream_b< ostream > OB; + typedef Stream_b< istream > IB; + Add< IB >("(", "", new OneOperator2_< istream *, IB, K * >(Read< K, KF >)); + Add< OB >("(", "", new OneOperator2_< ostream *, OB, K * >(10, Write< K, KF >)); + Add< OB >("(", "", new OneOperator2_< ostream *, OB, K >(Write< K, KF >)); + Add< IB >("(", "", new OneOperator2_< istream *, IB, KN< K > * >(Read< K, KF >)); + Add< OB >("(", "", new OneOperator2_< ostream *, OB, KN< K > * >(Write< K, KF >)); + Add< IB >("(", "", new OneOperator2_< istream *, IB, KNM< K > * >(Read< K, KF >)); + Add< OB >("(", "", new OneOperator2_< ostream *, OB, KNM< K > * >(Write< K, KF >)); } static void inittt( ) { - typedef Stream_b< ostream > OB; - typedef Stream_b< istream > IB; - Dcl_Type< OB >( ); - Dcl_Type< IB >( ); - - Add< istream ** >("read", ".", new OneOperator1< IB, istream ** >(pto_stream_b< istream >)); - Add< ostream ** >("write", ".", new OneOperator1< OB, ostream ** >(pto_stream_b< ostream >)); - initK< long,int64_t >( ); - initK< double >( ); - initK< complex< double > >( ); - - Global.Add("read", "(", - new OneOperator2(Read) , - new OneOperator2(Read) , - new OneOperator2(Read), - new OneOperator2 >(Reada) , - new OneOperator2 >(Reada) , - new OneOperator2 >(Reada) - ); - - Global.Add("readswapbyte", "(", - new OneOperator2(readswapbyte) , - new OneOperator2(readswapbyte) - ); - Global.Add("readint", "(", - new OneOperator2(Read), - new OneOperator2 >(Reada), - new OneOperator2 >(Reada) - ); - Global.Add("readshort", "(", - new OneOperator2(Read), - new OneOperator2 >(Reada) , - new OneOperator2 >(Reada) - - ); - Global.Add("readfloat", "(", - new OneOperator2(Read) - ); - Global.Add("writeint", "(", - new OneOperator2(Write) - ); - Global.Add("writefloat", "(", - new OneOperator2(Write) - ); - Global.Add("readintswapbyte", "(", - new OneOperator2(readswapbyte) - ); - - if(verbosity> 9) - cout << "\n islittleendian =" << islittleendian() << endl - << " or isbigeendian =" << isbigendian() << " sizeof long = "<< sizeof(long) << endl; + typedef Stream_b< ostream > OB; + typedef Stream_b< istream > IB; + Dcl_Type< OB >( ); + Dcl_Type< IB >( ); + + Add< istream ** >("read", ".", new OneOperator1< IB, istream ** >(pto_stream_b< istream >)); + Add< ostream ** >("write", ".", new OneOperator1< OB, ostream ** >(pto_stream_b< ostream >)); + initK< long, int64_t >( ); + initK< double >( ); + initK< complex< double > >( ); + + Global.Add("read", "(", new OneOperator2< istream *, istream *, Complex * >(Read< Complex, Complex >), new OneOperator2< istream *, istream *, double * >(Read< double, double >), + new OneOperator2< istream *, istream *, long * >(Read< long, int64_t >), new OneOperator2< istream *, istream *, KN_< Complex > >(Reada< Complex >), + new OneOperator2< istream *, istream *, KN_< double > >(Reada< double >), new OneOperator2< istream *, istream *, KN_< long > >(Reada< long, int64_t >)); + + Global.Add("readswapbyte", "(", new OneOperator2< istream *, istream *, double * >(readswapbyte< double, double >), new OneOperator2< istream *, istream *, long * >(readswapbyte< long, int64_t >)); + Global.Add("readint", "(", new OneOperator2< istream *, istream *, long * >(Read< long, int >), new OneOperator2< istream *, istream *, KN_< long > >(Reada< long, int >), + new OneOperator2< istream *, istream *, KN_< double > >(Reada< double, int >)); + Global.Add("readshort", "(", new OneOperator2< istream *, istream *, long * >(Read< long, short >), new OneOperator2< istream *, istream *, KN_< double > >(Reada< double, short >), + new OneOperator2< istream *, istream *, KN_< long > >(Reada< long, short >) + + ); + Global.Add("readfloat", "(", new OneOperator2< istream *, istream *, double * >(Read< double, float >)); + Global.Add("writeint", "(", new OneOperator2< ostream *, ostream *, long >(Write< long, int >)); + Global.Add("writefloat", "(", new OneOperator2< ostream *, ostream *, double >(Write< double, float >)); + Global.Add("readintswapbyte", "(", new OneOperator2< istream *, istream *, long * >(readswapbyte< long, int >)); + + if (verbosity > 9) cout << "\n islittleendian =" << islittleendian( ) << endl << " or isbigeendian =" << isbigendian( ) << " sizeof long = " << sizeof(long) << endl; } LOADFUNC(inittt); diff --git a/plugin/seq/biofunc.cpp b/plugin/seq/biofunc.cpp index 5764184c5..08cda9957 100644 --- a/plugin/seq/biofunc.cpp +++ b/plugin/seq/biofunc.cpp @@ -35,52 +35,45 @@ double fmonod(const double &xx, const double &k, const double &kb) { return (k * x) / (kb + x); } // on array .. -KN * fmonod( KN * const& pf , KN *const & px, const double &k, const double &kb) -{ - KN &f = *pf, &xx=*px; - long n = f.N(); - ffassert(n == xx.N()); - for( int i=0; i *fmonod(KN< double > *const &pf, KN< double > *const &px, const double &k, const double &kb) { + KN< double > &f = *pf, &xx = *px; + long n = f.N( ); + ffassert(n == xx.N( )); + for (int i = 0; i < n; ++i) { double x = max(xx[i], 0.); - f[i]= (k * x) / (kb + x); - } - return pf; + f[i] = (k * x) / (kb + x); + } + return pf; } -KN * fmonod( KN * const& pf , KN *const & px, KN *const &pk, const double &kb) -{ - KN &f = *pf, &xx=*px , & k= *pk; - long n = f.N(); - ffassert(n == xx.N() && n == k.N()); - for( int i=0; i *fmonod(KN< double > *const &pf, KN< double > *const &px, KN< double > *const &pk, const double &kb) { + KN< double > &f = *pf, &xx = *px, &k = *pk; + long n = f.N( ); + ffassert(n == xx.N( ) && n == k.N( )); + for (int i = 0; i < n; ++i) { + double x = max(xx[i], 0.); + f[i] = (k[i] * x) / (kb + x); + } + return pf; } -KN * dfmonod( KN * const& pf , KN *const & px, const double &k, const double &kb) -{ - KN &f = *pf, &xx=*px; - long n = f.N(); - ffassert(n == xx.N()); - for( int i=0; i *dfmonod(KN< double > *const &pf, KN< double > *const &px, const double &k, const double &kb) { + KN< double > &f = *pf, &xx = *px; + long n = f.N( ); + ffassert(n == xx.N( )); + for (int i = 0; i < n; ++i) { + double x = max(xx[i], 0.), a = kb + x; + f[i] = k / a - k * x / (a * a); + } + return pf; } -KN * dfmonod( KN * const& pf , KN *const & px,KN *const &pk, const double &kb) -{ - KN &f = *pf, &xx=*px , & k= *pk; - long n = f.N(); - ffassert(n == xx.N() && n == k.N()); for( int i=0; i *dfmonod(KN< double > *const &pf, KN< double > *const &px, KN< double > *const &pk, const double &kb) { + KN< double > &f = *pf, &xx = *px, &k = *pk; + long n = f.N( ); + ffassert(n == xx.N( ) && n == k.N( )); + for (int i = 0; i < n; ++i) { + double x = max(xx[i], 0.), a = kb + x; + f[i] = k[i] / a - k[i] * x / (a * a); + } + return pf; } double dfmonod(const double &xx, const double &k, const double &kb) { double x = max(xx, 0.), a = kb + x; @@ -96,10 +89,10 @@ double dfmonod(const double &xx, const double &kb) { } static void init( ) { - Global.Add("fmonod", "(", new OneOperator4_< KN *, KN *, KN *, R, R >(fmonod)); - Global.Add("fmonod", "(", new OneOperator4_< KN *, KN *, KN *, KN *, R >(fmonod)); - Global.Add("dfmonod", "(", new OneOperator4_< KN *, KN *, KN *, R, R >(dfmonod)); - Global.Add("dfmonod", "(", new OneOperator4_< KN *, KN *, KN *, KN *, R >(dfmonod)); + Global.Add("fmonod", "(", new OneOperator4_< KN< double > *, KN< double > *, KN< double > *, R, R >(fmonod)); + Global.Add("fmonod", "(", new OneOperator4_< KN< double > *, KN< double > *, KN< double > *, KN< double > *, R >(fmonod)); + Global.Add("dfmonod", "(", new OneOperator4_< KN< double > *, KN< double > *, KN< double > *, R, R >(dfmonod)); + Global.Add("dfmonod", "(", new OneOperator4_< KN< double > *, KN< double > *, KN< double > *, KN< double > *, R >(dfmonod)); Global.Add("fmonod", "(", new OneOperator3_< R, R, R, R >(fmonod)); Global.Add("dfmonod", "(", new OneOperator3_< R, R, R, R >(dfmonod)); Global.Add("fmonod", "(", new OneOperator2_< R, R, R >(fmonod)); diff --git a/plugin/seq/bmo.cpp b/plugin/seq/bmo.cpp index 6a17d7c78..b9b373fb6 100644 --- a/plugin/seq/bmo.cpp +++ b/plugin/seq/bmo.cpp @@ -101,8 +101,7 @@ double BijanMO::main(Vect &xx, Vect &xxmin, Vect &xxmax) { double costsave; integer irestart; double f; - Vect v(ndim), v0(ndim), x1(ndim), hgc(ndim), fpx(ndim), fpx0(ndim), temp(ndim), xmin(ndim), - xmax(ndim), xsave(ndim), vinit(ndim), xsave0(ndim); + Vect v(ndim), v0(ndim), x1(ndim), hgc(ndim), fpx(ndim), fpx0(ndim), temp(ndim), xmin(ndim), xmax(ndim), xsave(ndim), vinit(ndim), xsave0(ndim); double rho; double rho0; double rho00; @@ -180,8 +179,7 @@ double BijanMO::main(Vect &xx, Vect &xxmin, Vect &xxmax) { x1 = v; rho = rho0 / iterbvp2; if (debug > 4) { - cout << "MM " << irestart << " " << iter1 << " " << iterbvp << " " << rho - << " ------------------------------ \n"; + cout << "MM " << irestart << " " << iter1 << " " << iterbvp << " " << rho << " ------------------------------ \n"; } gradopt(x1, fpx, temp, rho, f, gnorm, fpx0, hgc); @@ -301,8 +299,7 @@ void BijanMO::rand(Vect &v) { * \param fpx0 Vect & * \param hgc Vect & */ -int BijanMO::gradopt(Vect &x1, Vect &fpx, Vect &temp, double &rho, double &f, double &gnorm, - Vect &fpx0, Vect &hgc) { +int BijanMO::gradopt(Vect &x1, Vect &fpx, Vect &temp, double &rho, double &f, double &gnorm, Vect &fpx0, Vect &hgc) { /* Local variables */ integer ii; integer igc, igr; @@ -387,8 +384,7 @@ int BijanMO::gradopt(Vect &x1, Vect &fpx, Vect &temp, double &rho, double &f, do } if (debug > 2) { - cout << "\t\t\t " << f << " " << gnorm * gnorm0 << " " << x1[0] << " " << x1[1] << " /J/ " - << endl; + cout << "\t\t\t " << f << " " << gnorm * gnorm0 << " " << x1[0] << " " << x1[1] << " /J/ " << endl; } if (f < costsaveming) { diff --git a/plugin/seq/bmo.hpp b/plugin/seq/bmo.hpp index d25bfaa20..6b4682f12 100644 --- a/plugin/seq/bmo.hpp +++ b/plugin/seq/bmo.hpp @@ -48,15 +48,11 @@ class BijanMO { int typealgo; // 1 CG string *histpath; // 0 => no file string *histcpath; // 0 => no file - BijanMO(int nndim, int wnbrestart = 1, int wnbext1 = 1, int wnbbvp = 5, int wnbgrad = 5, - double wepsfd = 1e-5, double wrho000 = 100, double wepsloc = 1e-4, double wepsij = 1e-6, - int nn100 = 100) + BijanMO(int nndim, int wnbrestart = 1, int wnbext1 = 1, int wnbbvp = 5, int wnbgrad = 5, double wepsfd = 1e-5, double wrho000 = 100, double wepsloc = 1e-4, double wepsij = 1e-6, int nn100 = 100) : debug(1), diagrand(1), // choix of diag rand vector or not. - ndim(nndim), n100(nn100), nbsol(1000), cstr(n100), cstropt(n100), feval(nbsol), xoptg(ndim), - xopt1(ndim), xfeval(nbsol, ndim), xmin(ndim), xmax(ndim), nbrestart(wnbrestart), - nbext1(wnbext1), nbbvp(wnbbvp), nbgrad(wnbgrad), // ifd(wifd), - epsfd(wepsfd), rho000(wrho000), epsloc(wepsloc), epsij(wepsij), typealgo(1), histpath(0), - histcpath(0) { + ndim(nndim), n100(nn100), nbsol(1000), cstr(n100), cstropt(n100), feval(nbsol), xoptg(ndim), xopt1(ndim), xfeval(nbsol, ndim), xmin(ndim), xmax(ndim), nbrestart(wnbrestart), nbext1(wnbext1), + nbbvp(wnbbvp), nbgrad(wnbgrad), // ifd(wifd), + epsfd(wepsfd), rho000(wrho000), epsloc(wepsloc), epsij(wepsij), typealgo(1), histpath(0), histcpath(0) { cout << nbrestart << " == " << wnbrestart << endl; } @@ -65,8 +61,7 @@ class BijanMO { void funcp(Vect &x, Vect &fpx, double f); double fun(Vect &x, Vect &temp, Vect &g, double ro); double ropt_dicho(Vect x, Vect temp, double &ro, Vect g, double ccout); - int gradopt(Vect &x1, Vect &fpx, Vect &temp, double &rho, double &f, double &gnorm, Vect &fpx0, - Vect &hgc); + int gradopt(Vect &x1, Vect &fpx, Vect &temp, double &rho, double &f, double &gnorm, Vect &fpx0, Vect &hgc); void tir(Vect &v, Vect &fpx); void rand(Vect &v); diff --git a/plugin/seq/buildlayer.cpp b/plugin/seq/buildlayer.cpp index 9cbfe87ad..62150c55b 100644 --- a/plugin/seq/buildlayer.cpp +++ b/plugin/seq/buildlayer.cpp @@ -67,21 +67,14 @@ class BuildLayeMesh_Op : public E_F0mps { static const int n_name_param = 9; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: - BuildLayeMesh_Op(const basicAC_F0 &args, Expression tth, Expression nmaxx) - : eTh(tth), enmax(nmaxx), ezmin(0), ezmax(0), xx(0), yy(0), zz(0) { + BuildLayeMesh_Op(const basicAC_F0 &args, Expression tth, Expression nmaxx) : eTh(tth), enmax(nmaxx), ezmin(0), ezmax(0), xx(0), yy(0), zz(0) { cout << "construction par BuilLayeMesh_Op" << endl; args.SetNameParam(n_name_param, name_param, nargs); const E_Array *a2 = 0, *a1 = 0; @@ -117,15 +110,9 @@ class BuildLayeMesh_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type BuildLayeMesh_Op::name_param[] = {{"zbound", &typeid(E_Array)}, - {"transfo", &typeid(E_Array)}, - {"coef", &typeid(double)}, - {"reftet", &typeid(KN_< long >)}, - {"reffacemid", &typeid(KN_< long >)}, - {"reffaceup", &typeid(KN_< long >)}, - {"reffacelow", &typeid(KN_< long >)}, - {"facemerge", &typeid(long)}, - {"ptmerge", &typeid(double)}}; +basicAC_F0::name_and_type BuildLayeMesh_Op::name_param[] = {{"zbound", &typeid(E_Array)}, {"transfo", &typeid(E_Array)}, {"coef", &typeid(double)}, + {"reftet", &typeid(KN_< long >)}, {"reffacemid", &typeid(KN_< long >)}, {"reffaceup", &typeid(KN_< long >)}, + {"reffacelow", &typeid(KN_< long >)}, {"facemerge", &typeid(long)}, {"ptmerge", &typeid(double)}}; class BuildLayerMesh : public OneOperator { public: @@ -243,8 +230,7 @@ AnyType BuildLayeMesh_Op::operator( )(Stack stack) const { ni[i] = Max(0, Min(nlayer, (int)lrint(nlayer * clayer[i]))); } - Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, - mapemil, mapezmax, mapezmin); + Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, mapezmin); if (!(xx) && !(yy) && !(zz)) { Th3->BuildBound( ); @@ -288,8 +274,7 @@ AnyType BuildLayeMesh_Op::operator( )(Stack stack) const { int border_only = 0; int recollement_elem = 0, recollement_border = 1; - Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, rTh3, txx, tyy, tzz, border_only, recollement_elem, - recollement_border, point_confondus_ok); + Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, rTh3, txx, tyy, tzz, border_only, recollement_elem, recollement_border, point_confondus_ok); T_Th3->BuildBound( ); T_Th3->BuildAdj( ); diff --git a/plugin/seq/clapack.h b/plugin/seq/clapack.h index 23f04f415..088d67dfe 100644 --- a/plugin/seq/clapack.h +++ b/plugin/seq/clapack.h @@ -27,224 +27,151 @@ extern "C" { #endif -/* Subroutine */ int caxpy_(integer *n, complex *ca, complex *cx, integer *incx, complex *cy, - integer *incy); +/* Subroutine */ int caxpy_(integer *n, complex *ca, complex *cx, integer *incx, complex *cy, integer *incy); /* Subroutine */ int ccopy_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy); -/* Complex */ VOID cdotc_(complex *ret_val, integer *n, complex *cx, integer *incx, complex *cy, - integer *incy); +/* Complex */ VOID cdotc_(complex *ret_val, integer *n, complex *cx, integer *incx, complex *cy, integer *incy); -/* Complex */ VOID cdotu_(complex *ret_val, integer *n, complex *cx, integer *incx, complex *cy, - integer *incy); +/* Complex */ VOID cdotu_(complex *ret_val, integer *n, complex *cx, integer *incx, complex *cy, integer *incy); -/* Subroutine */ int cgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - complex *alpha, complex *a, integer *lda, complex *x, integer *incx, - complex *beta, complex *y, integer *incy); +/* Subroutine */ int cgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, complex *alpha, complex *a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, + integer *incy); -/* Subroutine */ int cgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, - complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, - complex *beta, complex *c__, integer *ldc); +/* Subroutine */ int cgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, complex *beta, complex *c__, + integer *ldc); -/* Subroutine */ int cgemv_(char *trans, integer *m, integer *n, complex *alpha, complex *a, - integer *lda, complex *x, integer *incx, complex *beta, complex *y, - integer *incy); +/* Subroutine */ int cgemv_(char *trans, integer *m, integer *n, complex *alpha, complex *a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int cgerc_(integer *m, integer *n, complex *alpha, complex *x, integer *incx, - complex *y, integer *incy, complex *a, integer *lda); +/* Subroutine */ int cgerc_(integer *m, integer *n, complex *alpha, complex *x, integer *incx, complex *y, integer *incy, complex *a, integer *lda); -/* Subroutine */ int cgeru_(integer *m, integer *n, complex *alpha, complex *x, integer *incx, - complex *y, integer *incy, complex *a, integer *lda); +/* Subroutine */ int cgeru_(integer *m, integer *n, complex *alpha, complex *x, integer *incx, complex *y, integer *incy, complex *a, integer *lda); -/* Subroutine */ int chbmv_(char *uplo, integer *n, integer *k, complex *alpha, complex *a, - integer *lda, complex *x, integer *incx, complex *beta, complex *y, - integer *incy); +/* Subroutine */ int chbmv_(char *uplo, integer *n, integer *k, complex *alpha, complex *a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int chemm_(char *side, char *uplo, integer *m, integer *n, complex *alpha, - complex *a, integer *lda, complex *b, integer *ldb, complex *beta, - complex *c__, integer *ldc); +/* Subroutine */ int chemm_(char *side, char *uplo, integer *m, integer *n, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, complex *beta, complex *c__, integer *ldc); -/* Subroutine */ int chemv_(char *uplo, integer *n, complex *alpha, complex *a, integer *lda, - complex *x, integer *incx, complex *beta, complex *y, integer *incy); +/* Subroutine */ int chemv_(char *uplo, integer *n, complex *alpha, complex *a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int cher_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, - complex *a, integer *lda); +/* Subroutine */ int cher_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, complex *a, integer *lda); -/* Subroutine */ int cher2_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, - complex *y, integer *incy, complex *a, integer *lda); +/* Subroutine */ int cher2_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, complex *y, integer *incy, complex *a, integer *lda); -/* Subroutine */ int cher2k_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, - complex *a, integer *lda, complex *b, integer *ldb, real *beta, - complex *c__, integer *ldc); +/* Subroutine */ int cher2k_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, real *beta, complex *c__, integer *ldc); -/* Subroutine */ int cherk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, - complex *a, integer *lda, real *beta, complex *c__, integer *ldc); +/* Subroutine */ int cherk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, complex *a, integer *lda, real *beta, complex *c__, integer *ldc); -/* Subroutine */ int chpmv_(char *uplo, integer *n, complex *alpha, complex *ap, complex *x, - integer *incx, complex *beta, complex *y, integer *incy); +/* Subroutine */ int chpmv_(char *uplo, integer *n, complex *alpha, complex *ap, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int chpr_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, - complex *ap); +/* Subroutine */ int chpr_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, complex *ap); -/* Subroutine */ int chpr2_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, - complex *y, integer *incy, complex *ap); +/* Subroutine */ int chpr2_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, complex *y, integer *incy, complex *ap); /* Subroutine */ int crotg_(complex *ca, complex *cb, real *c__, complex *s); /* Subroutine */ int cscal_(integer *n, complex *ca, complex *cx, integer *incx); -/* Subroutine */ int csrot_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, - real *c__, real *s); +/* Subroutine */ int csrot_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, real *c__, real *s); /* Subroutine */ int csscal_(integer *n, real *sa, complex *cx, integer *incx); /* Subroutine */ int cswap_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy); -/* Subroutine */ int csymm_(char *side, char *uplo, integer *m, integer *n, complex *alpha, - complex *a, integer *lda, complex *b, integer *ldb, complex *beta, - complex *c__, integer *ldc); +/* Subroutine */ int csymm_(char *side, char *uplo, integer *m, integer *n, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, complex *beta, complex *c__, integer *ldc); -/* Subroutine */ int csyr2k_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, - complex *a, integer *lda, complex *b, integer *ldb, complex *beta, - complex *c__, integer *ldc); +/* Subroutine */ int csyr2k_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb, complex *beta, complex *c__, integer *ldc); -/* Subroutine */ int csyrk_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, - complex *a, integer *lda, complex *beta, complex *c__, integer *ldc); +/* Subroutine */ int csyrk_(char *uplo, char *trans, integer *n, integer *k, complex *alpha, complex *a, integer *lda, complex *beta, complex *c__, integer *ldc); -/* Subroutine */ int ctbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, complex *a, - integer *lda, complex *x, integer *incx); +/* Subroutine */ int ctbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, complex *a, integer *lda, complex *x, integer *incx); -/* Subroutine */ int ctbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, complex *a, - integer *lda, complex *x, integer *incx); +/* Subroutine */ int ctbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, complex *a, integer *lda, complex *x, integer *incx); -/* Subroutine */ int ctpmv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, - complex *x, integer *incx); +/* Subroutine */ int ctpmv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, complex *x, integer *incx); -/* Subroutine */ int ctpsv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, - complex *x, integer *incx); +/* Subroutine */ int ctpsv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, complex *x, integer *incx); -/* Subroutine */ int ctrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb); +/* Subroutine */ int ctrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb); -/* Subroutine */ int ctrmv_(char *uplo, char *trans, char *diag, integer *n, complex *a, - integer *lda, complex *x, integer *incx); +/* Subroutine */ int ctrmv_(char *uplo, char *trans, char *diag, integer *n, complex *a, integer *lda, complex *x, integer *incx); -/* Subroutine */ int ctrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb); +/* Subroutine */ int ctrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, complex *alpha, complex *a, integer *lda, complex *b, integer *ldb); -/* Subroutine */ int ctrsv_(char *uplo, char *trans, char *diag, integer *n, complex *a, - integer *lda, complex *x, integer *incx); +/* Subroutine */ int ctrsv_(char *uplo, char *trans, char *diag, integer *n, complex *a, integer *lda, complex *x, integer *incx); doublereal dasum_(integer *n, doublereal *dx, integer *incx); -/* Subroutine */ int daxpy_(integer *n, doublereal *da, doublereal *dx, integer *incx, - doublereal *dy, integer *incy); +/* Subroutine */ int daxpy_(integer *n, doublereal *da, doublereal *dx, integer *incx, doublereal *dy, integer *incy); doublereal dcabs1_(doublecomplex *z__); -/* Subroutine */ int dcopy_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy); +/* Subroutine */ int dcopy_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy); doublereal ddot_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy); -/* Subroutine */ int dgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - doublereal *alpha, doublereal *a, integer *lda, doublereal *x, - integer *incx, doublereal *beta, doublereal *y, integer *incy); +/* Subroutine */ int dgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, + doublereal *y, integer *incy); -/* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, - doublereal *alpha, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *beta, doublereal *c__, integer *ldc); +/* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *beta, + doublereal *c__, integer *ldc); -/* Subroutine */ int dgemv_(char *trans, integer *m, integer *n, doublereal *alpha, doublereal *a, - integer *lda, doublereal *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy); +/* Subroutine */ int dgemv_(char *trans, integer *m, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -/* Subroutine */ int dger_(integer *m, integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *y, integer *incy, doublereal *a, integer *lda); +/* Subroutine */ int dger_(integer *m, integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *a, integer *lda); doublereal dnrm2_(integer *n, doublereal *x, integer *incx); -/* Subroutine */ int drot_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy, - doublereal *c__, doublereal *s); +/* Subroutine */ int drot_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy, doublereal *c__, doublereal *s); /* Subroutine */ int drotg_(doublereal *da, doublereal *db, doublereal *c__, doublereal *s); -/* Subroutine */ int drotm_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy, doublereal *dparam); +/* Subroutine */ int drotm_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy, doublereal *dparam); -/* Subroutine */ int drotmg_(doublereal *dd1, doublereal *dd2, doublereal *dx1, doublereal *dy1, - doublereal *dparam); +/* Subroutine */ int drotmg_(doublereal *dd1, doublereal *dd2, doublereal *dx1, doublereal *dy1, doublereal *dparam); -/* Subroutine */ int dsbmv_(char *uplo, integer *n, integer *k, doublereal *alpha, doublereal *a, - integer *lda, doublereal *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy); +/* Subroutine */ int dsbmv_(char *uplo, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); /* Subroutine */ int dscal_(integer *n, doublereal *da, doublereal *dx, integer *incx); doublereal dsdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy); -/* Subroutine */ int dspmv_(char *uplo, integer *n, doublereal *alpha, doublereal *ap, - doublereal *x, integer *incx, doublereal *beta, doublereal *y, - integer *incy); +/* Subroutine */ int dspmv_(char *uplo, integer *n, doublereal *alpha, doublereal *ap, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -/* Subroutine */ int dspr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *ap); +/* Subroutine */ int dspr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *ap); -/* Subroutine */ int dspr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *y, integer *incy, doublereal *ap); +/* Subroutine */ int dspr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *ap); -/* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy); +/* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx, doublereal *dy, integer *incy); -/* Subroutine */ int dsymm_(char *side, char *uplo, integer *m, integer *n, doublereal *alpha, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *beta, doublereal *c__, integer *ldc); +/* Subroutine */ int dsymm_(char *side, char *uplo, integer *m, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *beta, doublereal *c__, + integer *ldc); -/* Subroutine */ int dsymv_(char *uplo, integer *n, doublereal *alpha, doublereal *a, integer *lda, - doublereal *x, integer *incx, doublereal *beta, doublereal *y, - integer *incy); +/* Subroutine */ int dsymv_(char *uplo, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -/* Subroutine */ int dsyr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *a, integer *lda); +/* Subroutine */ int dsyr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *a, integer *lda); -/* Subroutine */ int dsyr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *y, integer *incy, doublereal *a, integer *lda); +/* Subroutine */ int dsyr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *a, integer *lda); -/* Subroutine */ int dsyr2k_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *beta, doublereal *c__, integer *ldc); +/* Subroutine */ int dsyr2k_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *beta, doublereal *c__, + integer *ldc); -/* Subroutine */ int dsyrk_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, - doublereal *a, integer *lda, doublereal *beta, doublereal *c__, - integer *ldc); +/* Subroutine */ int dsyrk_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *beta, doublereal *c__, integer *ldc); -/* Subroutine */ int dtbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *x, integer *incx); +/* Subroutine */ int dtbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, doublereal *a, integer *lda, doublereal *x, integer *incx); -/* Subroutine */ int dtbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *x, integer *incx); +/* Subroutine */ int dtbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, doublereal *a, integer *lda, doublereal *x, integer *incx); -/* Subroutine */ int dtpmv_(char *uplo, char *trans, char *diag, integer *n, doublereal *ap, - doublereal *x, integer *incx); +/* Subroutine */ int dtpmv_(char *uplo, char *trans, char *diag, integer *n, doublereal *ap, doublereal *x, integer *incx); -/* Subroutine */ int dtpsv_(char *uplo, char *trans, char *diag, integer *n, doublereal *ap, - doublereal *x, integer *incx); +/* Subroutine */ int dtpsv_(char *uplo, char *trans, char *diag, integer *n, doublereal *ap, doublereal *x, integer *incx); -/* Subroutine */ int dtrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb); +/* Subroutine */ int dtrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb); -/* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, integer *n, doublereal *a, - integer *lda, doublereal *x, integer *incx); +/* Subroutine */ int dtrmv_(char *uplo, char *trans, char *diag, integer *n, doublereal *a, integer *lda, doublereal *x, integer *incx); -/* Subroutine */ int dtrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb); +/* Subroutine */ int dtrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb); -/* Subroutine */ int dtrsv_(char *uplo, char *trans, char *diag, integer *n, doublereal *a, - integer *lda, doublereal *x, integer *incx); +/* Subroutine */ int dtrsv_(char *uplo, char *trans, char *diag, integer *n, doublereal *a, integer *lda, doublereal *x, integer *incx); doublereal dzasum_(integer *n, doublecomplex *zx, integer *incx); @@ -276,961 +203,601 @@ doublereal sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy); doublereal sdsdot_(integer *n, real *sb, real *sx, integer *incx, real *sy, integer *incy); -/* Subroutine */ int sgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, - real *y, integer *incy); +/* Subroutine */ int sgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); -/* Subroutine */ int sgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, - real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta, - real *c__, integer *ldc); +/* Subroutine */ int sgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta, real *c__, integer *ldc); -/* Subroutine */ int sgemv_(char *trans, integer *m, integer *n, real *alpha, real *a, integer *lda, - real *x, integer *incx, real *beta, real *y, integer *incy); +/* Subroutine */ int sgemv_(char *trans, integer *m, integer *n, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); -/* Subroutine */ int sger_(integer *m, integer *n, real *alpha, real *x, integer *incx, real *y, - integer *incy, real *a, integer *lda); +/* Subroutine */ int sger_(integer *m, integer *n, real *alpha, real *x, integer *incx, real *y, integer *incy, real *a, integer *lda); doublereal snrm2_(integer *n, real *x, integer *incx); -/* Subroutine */ int srot_(integer *n, real *sx, integer *incx, real *sy, integer *incy, real *c__, - real *s); +/* Subroutine */ int srot_(integer *n, real *sx, integer *incx, real *sy, integer *incy, real *c__, real *s); /* Subroutine */ int srotg_(real *sa, real *sb, real *c__, real *s); -/* Subroutine */ int srotm_(integer *n, real *sx, integer *incx, real *sy, integer *incy, - real *sparam); +/* Subroutine */ int srotm_(integer *n, real *sx, integer *incx, real *sy, integer *incy, real *sparam); /* Subroutine */ int srotmg_(real *sd1, real *sd2, real *sx1, real *sy1, real *sparam); -/* Subroutine */ int ssbmv_(char *uplo, integer *n, integer *k, real *alpha, real *a, integer *lda, - real *x, integer *incx, real *beta, real *y, integer *incy); +/* Subroutine */ int ssbmv_(char *uplo, integer *n, integer *k, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); /* Subroutine */ int sscal_(integer *n, real *sa, real *sx, integer *incx); -/* Subroutine */ int sspmv_(char *uplo, integer *n, real *alpha, real *ap, real *x, integer *incx, - real *beta, real *y, integer *incy); +/* Subroutine */ int sspmv_(char *uplo, integer *n, real *alpha, real *ap, real *x, integer *incx, real *beta, real *y, integer *incy); /* Subroutine */ int sspr_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *ap); -/* Subroutine */ int sspr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *y, - integer *incy, real *ap); +/* Subroutine */ int sspr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *y, integer *incy, real *ap); /* Subroutine */ int sswap_(integer *n, real *sx, integer *incx, real *sy, integer *incy); -/* Subroutine */ int ssymm_(char *side, char *uplo, integer *m, integer *n, real *alpha, real *a, - integer *lda, real *b, integer *ldb, real *beta, real *c__, - integer *ldc); +/* Subroutine */ int ssymm_(char *side, char *uplo, integer *m, integer *n, real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta, real *c__, integer *ldc); -/* Subroutine */ int ssymv_(char *uplo, integer *n, real *alpha, real *a, integer *lda, real *x, - integer *incx, real *beta, real *y, integer *incy); +/* Subroutine */ int ssymv_(char *uplo, integer *n, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); -/* Subroutine */ int ssyr_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *a, - integer *lda); +/* Subroutine */ int ssyr_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *a, integer *lda); -/* Subroutine */ int ssyr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *y, - integer *incy, real *a, integer *lda); +/* Subroutine */ int ssyr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, real *y, integer *incy, real *a, integer *lda); -/* Subroutine */ int ssyr2k_(char *uplo, char *trans, integer *n, integer *k, real *alpha, real *a, - integer *lda, real *b, integer *ldb, real *beta, real *c__, - integer *ldc); +/* Subroutine */ int ssyr2k_(char *uplo, char *trans, integer *n, integer *k, real *alpha, real *a, integer *lda, real *b, integer *ldb, real *beta, real *c__, integer *ldc); -/* Subroutine */ int ssyrk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, real *a, - integer *lda, real *beta, real *c__, integer *ldc); +/* Subroutine */ int ssyrk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, real *a, integer *lda, real *beta, real *c__, integer *ldc); -/* Subroutine */ int stbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, real *a, - integer *lda, real *x, integer *incx); +/* Subroutine */ int stbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, real *a, integer *lda, real *x, integer *incx); -/* Subroutine */ int stbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, real *a, - integer *lda, real *x, integer *incx); +/* Subroutine */ int stbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, real *a, integer *lda, real *x, integer *incx); -/* Subroutine */ int stpmv_(char *uplo, char *trans, char *diag, integer *n, real *ap, real *x, - integer *incx); +/* Subroutine */ int stpmv_(char *uplo, char *trans, char *diag, integer *n, real *ap, real *x, integer *incx); -/* Subroutine */ int stpsv_(char *uplo, char *trans, char *diag, integer *n, real *ap, real *x, - integer *incx); +/* Subroutine */ int stpsv_(char *uplo, char *trans, char *diag, integer *n, real *ap, real *x, integer *incx); -/* Subroutine */ int strmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, real *alpha, real *a, integer *lda, real *b, integer *ldb); +/* Subroutine */ int strmm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, real *alpha, real *a, integer *lda, real *b, integer *ldb); -/* Subroutine */ int strmv_(char *uplo, char *trans, char *diag, integer *n, real *a, integer *lda, - real *x, integer *incx); +/* Subroutine */ int strmv_(char *uplo, char *trans, char *diag, integer *n, real *a, integer *lda, real *x, integer *incx); -/* Subroutine */ int strsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, real *alpha, real *a, integer *lda, real *b, integer *ldb); +/* Subroutine */ int strsm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, real *alpha, real *a, integer *lda, real *b, integer *ldb); -/* Subroutine */ int strsv_(char *uplo, char *trans, char *diag, integer *n, real *a, integer *lda, - real *x, integer *incx); +/* Subroutine */ int strsv_(char *uplo, char *trans, char *diag, integer *n, real *a, integer *lda, real *x, integer *incx); /* Subroutine */ int xerbla_(char *srname, integer *info); -/* Subroutine */ int xerbla_array__(char *srname_array__, integer *srname_len__, integer *info, - ftnlen srname_array_len); +/* Subroutine */ int xerbla_array__(char *srname_array__, integer *srname_len__, integer *info, ftnlen srname_array_len); -/* Subroutine */ int zaxpy_(integer *n, doublecomplex *za, doublecomplex *zx, integer *incx, - doublecomplex *zy, integer *incy); +/* Subroutine */ int zaxpy_(integer *n, doublecomplex *za, doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy); -/* Subroutine */ int zcopy_(integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, - integer *incy); +/* Subroutine */ int zcopy_(integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy); -/* Double Complex */ VOID zdotc_(doublecomplex *ret_val, integer *n, doublecomplex *zx, - integer *incx, doublecomplex *zy, integer *incy); +/* Double Complex */ VOID zdotc_(doublecomplex *ret_val, integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy); -/* Double Complex */ VOID zdotu_(doublecomplex *ret_val, integer *n, doublecomplex *zx, - integer *incx, doublecomplex *zy, integer *incy); +/* Double Complex */ VOID zdotu_(doublecomplex *ret_val, integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy); -/* Subroutine */ int zdrot_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, - integer *incy, doublereal *c__, doublereal *s); +/* Subroutine */ int zdrot_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, integer *incy, doublereal *c__, doublereal *s); /* Subroutine */ int zdscal_(integer *n, doublereal *da, doublecomplex *zx, integer *incx); -/* Subroutine */ int zgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, doublecomplex *beta, doublecomplex *y, integer *incy); +/* Subroutine */ int zgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, + doublecomplex *y, integer *incy); -/* Subroutine */ int zgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, - doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *beta, doublecomplex *c__, integer *ldc); +/* Subroutine */ int zgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *beta, + doublecomplex *c__, integer *ldc); -/* Subroutine */ int zgemv_(char *trans, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, - doublecomplex *beta, doublecomplex *y, integer *incy); +/* Subroutine */ int zgemv_(char *trans, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, + integer *incy); -/* Subroutine */ int zgerc_(integer *m, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, - integer *lda); +/* Subroutine */ int zgerc_(integer *m, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, integer *lda); -/* Subroutine */ int zgeru_(integer *m, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, - integer *lda); +/* Subroutine */ int zgeru_(integer *m, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, integer *lda); -/* Subroutine */ int zhbmv_(char *uplo, integer *n, integer *k, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, - doublecomplex *beta, doublecomplex *y, integer *incy); +/* Subroutine */ int zhbmv_(char *uplo, integer *n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, + integer *incy); -/* Subroutine */ int zhemm_(char *side, char *uplo, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *beta, doublecomplex *c__, integer *ldc); +/* Subroutine */ int zhemm_(char *side, char *uplo, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *beta, + doublecomplex *c__, integer *ldc); -/* Subroutine */ int zhemv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, - doublecomplex *y, integer *incy); +/* Subroutine */ int zhemv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, integer *incy); -/* Subroutine */ int zher_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, - integer *incx, doublecomplex *a, integer *lda); +/* Subroutine */ int zher_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, integer *incx, doublecomplex *a, integer *lda); -/* Subroutine */ int zher2_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, - integer *lda); +/* Subroutine */ int zher2_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublecomplex *a, integer *lda); -/* Subroutine */ int zher2k_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublereal *beta, doublecomplex *c__, integer *ldc); +/* Subroutine */ int zher2k_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *beta, + doublecomplex *c__, integer *ldc); -/* Subroutine */ int zherk_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, - doublecomplex *a, integer *lda, doublereal *beta, doublecomplex *c__, - integer *ldc); +/* Subroutine */ int zherk_(char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, doublecomplex *a, integer *lda, doublereal *beta, doublecomplex *c__, integer *ldc); -/* Subroutine */ int zhpmv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *ap, - doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy); +/* Subroutine */ int zhpmv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *ap, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, integer *incy); -/* Subroutine */ int zhpr_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, - integer *incx, doublecomplex *ap); +/* Subroutine */ int zhpr_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, integer *incx, doublecomplex *ap); -/* Subroutine */ int zhpr2_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *y, integer *incy, doublecomplex *ap); +/* Subroutine */ int zhpr2_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublecomplex *ap); -/* Subroutine */ int zrotg_(doublecomplex *ca, doublecomplex *cb, doublereal *c__, - doublecomplex *s); +/* Subroutine */ int zrotg_(doublecomplex *ca, doublecomplex *cb, doublereal *c__, doublecomplex *s); /* Subroutine */ int zscal_(integer *n, doublecomplex *za, doublecomplex *zx, integer *incx); -/* Subroutine */ int zswap_(integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, - integer *incy); +/* Subroutine */ int zswap_(integer *n, doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy); -/* Subroutine */ int zsymm_(char *side, char *uplo, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *beta, doublecomplex *c__, integer *ldc); +/* Subroutine */ int zsymm_(char *side, char *uplo, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *beta, + doublecomplex *c__, integer *ldc); -/* Subroutine */ int zsyr2k_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *beta, doublecomplex *c__, integer *ldc); +/* Subroutine */ int zsyr2k_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *beta, + doublecomplex *c__, integer *ldc); -/* Subroutine */ int zsyrk_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *beta, doublecomplex *c__, - integer *ldc); +/* Subroutine */ int zsyrk_(char *uplo, char *trans, integer *n, integer *k, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *beta, doublecomplex *c__, integer *ldc); -/* Subroutine */ int ztbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); +/* Subroutine */ int ztbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); -/* Subroutine */ int ztbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); +/* Subroutine */ int ztbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); -/* Subroutine */ int ztpmv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *ap, - doublecomplex *x, integer *incx); +/* Subroutine */ int ztpmv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *ap, doublecomplex *x, integer *incx); -/* Subroutine */ int ztpsv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *ap, - doublecomplex *x, integer *incx); +/* Subroutine */ int ztpsv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *ap, doublecomplex *x, integer *incx); -/* Subroutine */ int ztrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb); +/* Subroutine */ int ztrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb); -/* Subroutine */ int ztrmv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx); +/* Subroutine */ int ztrmv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); -/* Subroutine */ int ztrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb); +/* Subroutine */ int ztrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb); -/* Subroutine */ int ztrsv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx); +/* Subroutine */ int ztrsv_(char *uplo, char *trans, char *diag, integer *n, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx); -/* Subroutine */ int cbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, - real *d__, real *e, complex *vt, integer *ldvt, complex *u, - integer *ldu, complex *c__, integer *ldc, real *rwork, integer *info); +/* Subroutine */ int cbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, real *d__, real *e, complex *vt, integer *ldvt, complex *u, integer *ldu, complex *c__, integer *ldc, + real *rwork, integer *info); -/* Subroutine */ int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, - integer *ku, complex *ab, integer *ldab, real *d__, real *e, - complex *q, integer *ldq, complex *pt, integer *ldpt, complex *c__, - integer *ldc, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, integer *ku, complex *ab, integer *ldab, real *d__, real *e, complex *q, integer *ldq, complex *pt, + integer *ldpt, complex *c__, integer *ldc, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbcon_(char *norm, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, integer *ipiv, real *anorm, real *rcond, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cgbcon_(char *norm, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, integer *ipiv, real *anorm, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbequ_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, integer *info); +/* Subroutine */ int cgbequ_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int cgbequb_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, integer *info); +/* Subroutine */ int cgbequb_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int cgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - complex *ab, integer *ldab, complex *afb, integer *ldafb, - integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, complex *b, integer *ldb, + complex *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, - integer *nrhs, complex *ab, integer *ldab, complex *afb, - integer *ldafb, integer *ipiv, real *r__, real *c__, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, real *berr, - integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, - integer *nparams, real *params, complex *work, real *rwork, - integer *info); +/* Subroutine */ int cgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, real *r__, + real *c__, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, + integer *nparams, real *params, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, - integer *ldab, integer *ipiv, complex *b, integer *ldb, integer *info); +/* Subroutine */ int cgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, complex *ab, integer *ldab, complex *afb, - integer *ldafb, integer *ipiv, char *equed, real *r__, real *c__, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, char *equed, + real *r__, real *c__, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, complex *ab, integer *ldab, complex *afb, - integer *ldafb, integer *ipiv, char *equed, real *r__, real *c__, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, char *equed, + real *r__, real *c__, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, + real *err_bnds_comp__, integer *nparams, real *params, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgbtf2_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int cgbtf2_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int cgbtrf_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int cgbtrf_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int cgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - complex *ab, integer *ldab, integer *ipiv, complex *b, integer *ldb, - integer *info); +/* Subroutine */ int cgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - real *scale, integer *m, complex *v, integer *ldv, integer *info); +/* Subroutine */ int cgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, real *scale, integer *m, complex *v, integer *ldv, integer *info); -/* Subroutine */ int cgebal_(char *job, integer *n, complex *a, integer *lda, integer *ilo, - integer *ihi, real *scale, integer *info); +/* Subroutine */ int cgebal_(char *job, integer *n, complex *a, integer *lda, integer *ilo, integer *ihi, real *scale, integer *info); -/* Subroutine */ int cgebd2_(integer *m, integer *n, complex *a, integer *lda, real *d__, real *e, - complex *tauq, complex *taup, complex *work, integer *info); +/* Subroutine */ int cgebd2_(integer *m, integer *n, complex *a, integer *lda, real *d__, real *e, complex *tauq, complex *taup, complex *work, integer *info); -/* Subroutine */ int cgebrd_(integer *m, integer *n, complex *a, integer *lda, real *d__, real *e, - complex *tauq, complex *taup, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int cgebrd_(integer *m, integer *n, complex *a, integer *lda, real *d__, real *e, complex *tauq, complex *taup, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgecon_(char *norm, integer *n, complex *a, integer *lda, real *anorm, - real *rcond, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgecon_(char *norm, integer *n, complex *a, integer *lda, real *anorm, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgeequ_(integer *m, integer *n, complex *a, integer *lda, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, integer *info); +/* Subroutine */ int cgeequ_(integer *m, integer *n, complex *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int cgeequb_(integer *m, integer *n, complex *a, integer *lda, real *r__, - real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); +/* Subroutine */ int cgeequb_(integer *m, integer *n, complex *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int cgees_(char *jobvs, char *sort, L_fp select, integer *n, complex *a, - integer *lda, integer *sdim, complex *w, complex *vs, integer *ldvs, - complex *work, integer *lwork, real *rwork, logical *bwork, - integer *info); +/* Subroutine */ int cgees_(char *jobvs, char *sort, L_fp select, integer *n, complex *a, integer *lda, integer *sdim, complex *w, complex *vs, integer *ldvs, complex *work, integer *lwork, + real *rwork, logical *bwork, integer *info); -/* Subroutine */ int cgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, - complex *a, integer *lda, integer *sdim, complex *w, complex *vs, - integer *ldvs, real *rconde, real *rcondv, complex *work, - integer *lwork, real *rwork, logical *bwork, integer *info); +/* Subroutine */ int cgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, complex *a, integer *lda, integer *sdim, complex *w, complex *vs, integer *ldvs, real *rconde, real *rcondv, + complex *work, integer *lwork, real *rwork, logical *bwork, integer *info); -/* Subroutine */ int cgeev_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, - complex *w, complex *vl, integer *ldvl, complex *vr, integer *ldvr, - complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cgeev_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, complex *w, complex *vl, integer *ldvl, complex *vr, integer *ldvr, complex *work, integer *lwork, + real *rwork, integer *info); -/* Subroutine */ int cgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - complex *a, integer *lda, complex *w, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, integer *ilo, integer *ihi, real *scale, - real *abnrm, real *rconde, real *rcondv, complex *work, integer *lwork, - real *rwork, integer *info); +/* Subroutine */ int cgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, complex *a, integer *lda, complex *w, complex *vl, integer *ldvl, complex *vr, integer *ldvr, + integer *ilo, integer *ihi, real *scale, real *abnrm, real *rconde, real *rcondv, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cgegs_(char *jobvsl, char *jobvsr, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *alpha, complex *beta, complex *vsl, - integer *ldvsl, complex *vsr, integer *ldvsr, complex *work, - integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cgegs_(char *jobvsl, char *jobvsr, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, complex *beta, complex *vsl, integer *ldvsl, complex *vsr, + integer *ldvsr, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cgegv_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *alpha, complex *beta, complex *vl, - integer *ldvl, complex *vr, integer *ldvr, complex *work, - integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cgegv_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, complex *beta, complex *vl, integer *ldvl, complex *vr, + integer *ldvr, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cgehd2_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, - complex *tau, complex *work, integer *info); +/* Subroutine */ int cgehd2_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgehrd_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cgehrd_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgelq2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *info); +/* Subroutine */ int cgelq2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgelqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cgelqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgels_(char *trans, integer *m, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int cgels_(char *trans, integer *m, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgelsd_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, real *s, real *rcond, integer *rank, - complex *work, integer *lwork, real *rwork, integer *iwork, - integer *info); +/* Subroutine */ int cgelsd_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, real *s, real *rcond, integer *rank, complex *work, integer *lwork, real *rwork, + integer *iwork, integer *info); -/* Subroutine */ int cgelss_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, real *s, real *rcond, integer *rank, - complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cgelss_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, real *s, real *rcond, integer *rank, complex *work, integer *lwork, real *rwork, + integer *info); -/* Subroutine */ int cgelsx_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, - complex *work, real *rwork, integer *info); +/* Subroutine */ int cgelsx_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, complex *work, real *rwork, + integer *info); -/* Subroutine */ int cgelsy_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, - complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cgelsy_(integer *m, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, complex *work, integer *lwork, + real *rwork, integer *info); -/* Subroutine */ int cgeql2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *info); +/* Subroutine */ int cgeql2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgeqlf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cgeqlf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgeqp3_(integer *m, integer *n, complex *a, integer *lda, integer *jpvt, - complex *tau, complex *work, integer *lwork, real *rwork, - integer *info); +/* Subroutine */ int cgeqp3_(integer *m, integer *n, complex *a, integer *lda, integer *jpvt, complex *tau, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cgeqpf_(integer *m, integer *n, complex *a, integer *lda, integer *jpvt, - complex *tau, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgeqpf_(integer *m, integer *n, complex *a, integer *lda, integer *jpvt, complex *tau, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgeqr2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *info); +/* Subroutine */ int cgeqr2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgeqrf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cgeqrf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgerfs_(char *trans, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cgerfs_(char *trans, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, + real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, real *r__, - real *c__, complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, complex *work, +/* Subroutine */ int cgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *r__, real *c__, complex *b, integer *ldb, + complex *x, integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgerq2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *info); - -/* Subroutine */ int cgerqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cgerq2_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgesc2_(integer *n, complex *a, integer *lda, complex *rhs, integer *ipiv, - integer *jpiv, real *scale); +/* Subroutine */ int cgerqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgesdd_(char *jobz, integer *m, integer *n, complex *a, integer *lda, real *s, - complex *u, integer *ldu, complex *vt, integer *ldvt, complex *work, - integer *lwork, real *rwork, integer *iwork, integer *info); +/* Subroutine */ int cgesc2_(integer *n, complex *a, integer *lda, complex *rhs, integer *ipiv, integer *jpiv, real *scale); -/* Subroutine */ int cgesv_(integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cgesdd_(char *jobz, integer *m, integer *n, complex *a, integer *lda, real *s, complex *u, integer *ldu, complex *vt, integer *ldvt, complex *work, integer *lwork, real *rwork, + integer *iwork, integer *info); -/* Subroutine */ int cgesvd_(char *jobu, char *jobvt, integer *m, integer *n, complex *a, - integer *lda, real *s, complex *u, integer *ldu, complex *vt, - integer *ldvt, complex *work, integer *lwork, real *rwork, - integer *info); +/* Subroutine */ int cgesv_(integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cgesvx_(char *fact, char *trans, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, - real *r__, real *c__, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, complex *work, +/* Subroutine */ int cgesvd_(char *jobu, char *jobvt, integer *m, integer *n, complex *a, integer *lda, real *s, complex *u, integer *ldu, complex *vt, integer *ldvt, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, - real *r__, real *c__, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *rpvgrw, real *berr, - integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, - integer *nparams, real *params, complex *work, real *rwork, - integer *info); - -/* Subroutine */ int cgetc2_(integer *n, complex *a, integer *lda, integer *ipiv, integer *jpiv, - integer *info); +/* Subroutine */ int cgesvx_(char *fact, char *trans, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, real *r__, real *c__, complex *b, + integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgetf2_(integer *m, integer *n, complex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int cgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, real *r__, real *c__, complex *b, + integer *ldb, complex *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, + real *params, complex *work, real *rwork, integer *info); -/* Subroutine */ int cgetrf_(integer *m, integer *n, complex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int cgetc2_(integer *n, complex *a, integer *lda, integer *ipiv, integer *jpiv, integer *info); -/* Subroutine */ int cgetri_(integer *n, complex *a, integer *lda, integer *ipiv, complex *work, - integer *lwork, integer *info); +/* Subroutine */ int cgetf2_(integer *m, integer *n, complex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int cgetrs_(char *trans, integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, integer *info); +/* Subroutine */ int cgetrf_(integer *m, integer *n, complex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int cggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - real *lscale, real *rscale, integer *m, complex *v, integer *ldv, - integer *info); +/* Subroutine */ int cgetri_(integer *n, complex *a, integer *lda, integer *ipiv, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cggbal_(char *job, integer *n, complex *a, integer *lda, complex *b, - integer *ldb, integer *ilo, integer *ihi, real *lscale, real *rscale, - real *work, integer *info); +/* Subroutine */ int cgetrs_(char *trans, integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, integer *sdim, - complex *alpha, complex *beta, complex *vsl, integer *ldvsl, - complex *vsr, integer *ldvsr, complex *work, integer *lwork, - real *rwork, logical *bwork, integer *info); +/* Subroutine */ int cggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, real *lscale, real *rscale, integer *m, complex *v, integer *ldv, integer *info); -/* Subroutine */ int cggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, - integer *n, complex *a, integer *lda, complex *b, integer *ldb, - integer *sdim, complex *alpha, complex *beta, complex *vsl, - integer *ldvsl, complex *vsr, integer *ldvsr, real *rconde, - real *rcondv, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *liwork, logical *bwork, integer *info); - -/* Subroutine */ int cggev_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *alpha, complex *beta, complex *vl, - integer *ldvl, complex *vr, integer *ldvr, complex *work, - integer *lwork, real *rwork, integer *info); - -/* Subroutine */ int cggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, - complex *beta, complex *vl, integer *ldvl, complex *vr, integer *ldvr, - integer *ilo, integer *ihi, real *lscale, real *rscale, real *abnrm, - real *bbnrm, real *rconde, real *rcondv, complex *work, integer *lwork, - real *rwork, integer *iwork, logical *bwork, integer *info); - -/* Subroutine */ int cggglm_(integer *n, integer *m, integer *p, complex *a, integer *lda, - complex *b, integer *ldb, complex *d__, complex *x, complex *y, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cggbal_(char *job, integer *n, complex *a, integer *lda, complex *b, integer *ldb, integer *ilo, integer *ihi, real *lscale, real *rscale, real *work, integer *info); -/* Subroutine */ int cgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, - complex *a, integer *lda, complex *b, integer *ldb, complex *q, - integer *ldq, complex *z__, integer *ldz, integer *info); +/* Subroutine */ int cgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, complex *a, integer *lda, complex *b, integer *ldb, integer *sdim, complex *alpha, complex *beta, + complex *vsl, integer *ldvsl, complex *vsr, integer *ldvsr, complex *work, integer *lwork, real *rwork, logical *bwork, integer *info); -/* Subroutine */ int cgglse_(integer *m, integer *n, integer *p, complex *a, integer *lda, - complex *b, integer *ldb, complex *c__, complex *d__, complex *x, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, integer *n, complex *a, integer *lda, complex *b, integer *ldb, integer *sdim, complex *alpha, + complex *beta, complex *vsl, integer *ldvsl, complex *vsr, integer *ldvsr, real *rconde, real *rcondv, complex *work, integer *lwork, real *rwork, integer *iwork, + integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int cggqrf_(integer *n, integer *m, integer *p, complex *a, integer *lda, - complex *taua, complex *b, integer *ldb, complex *taub, complex *work, - integer *lwork, integer *info); +/* Subroutine */ int cggev_(char *jobvl, char *jobvr, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, complex *beta, complex *vl, integer *ldvl, complex *vr, + integer *ldvr, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int cggrqf_(integer *m, integer *p, integer *n, complex *a, integer *lda, - complex *taua, complex *b, integer *ldb, complex *taub, complex *work, - integer *lwork, integer *info); +/* Subroutine */ int cggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, complex *beta, complex *vl, + integer *ldvl, complex *vr, integer *ldvr, integer *ilo, integer *ihi, real *lscale, real *rscale, real *abnrm, real *bbnrm, real *rconde, real *rcondv, complex *work, + integer *lwork, real *rwork, integer *iwork, logical *bwork, integer *info); -/* Subroutine */ int cggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, - integer *k, integer *l, complex *a, integer *lda, complex *b, - integer *ldb, real *alpha, real *beta, complex *u, integer *ldu, - complex *v, integer *ldv, complex *q, integer *ldq, complex *work, - real *rwork, integer *iwork, integer *info); +/* Subroutine */ int cggglm_(integer *n, integer *m, integer *p, complex *a, integer *lda, complex *b, integer *ldb, complex *d__, complex *x, complex *y, complex *work, integer *lwork, + integer *info); -/* Subroutine */ int cggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, real *tola, - real *tolb, integer *k, integer *l, complex *u, integer *ldu, - complex *v, integer *ldv, complex *q, integer *ldq, integer *iwork, - real *rwork, complex *tau, complex *work, integer *info); +/* Subroutine */ int cgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, complex *b, integer *ldb, complex *q, integer *ldq, complex *z__, integer *ldz, + integer *info); -/* Subroutine */ int cgtcon_(char *norm, integer *n, complex *dl, complex *d__, complex *du, - complex *du2, integer *ipiv, real *anorm, real *rcond, complex *work, +/* Subroutine */ int cgglse_(integer *m, integer *n, integer *p, complex *a, integer *lda, complex *b, integer *ldb, complex *c__, complex *d__, complex *x, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgtrfs_(char *trans, integer *n, integer *nrhs, complex *dl, complex *d__, - complex *du, complex *dlf, complex *df, complex *duf, complex *du2, - integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cggqrf_(integer *n, integer *m, integer *p, complex *a, integer *lda, complex *taua, complex *b, integer *ldb, complex *taub, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgtsv_(integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cggrqf_(integer *m, integer *p, integer *n, complex *a, integer *lda, complex *taua, complex *b, integer *ldb, complex *taub, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, complex *dl, - complex *d__, complex *du, complex *dlf, complex *df, complex *duf, - complex *du2, integer *ipiv, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, integer *k, integer *l, complex *a, integer *lda, complex *b, integer *ldb, real *alpha, + real *beta, complex *u, integer *ldu, complex *v, integer *ldv, complex *q, integer *ldq, complex *work, real *rwork, integer *iwork, integer *info); -/* Subroutine */ int cgttrf_(integer *n, complex *dl, complex *d__, complex *du, complex *du2, - integer *ipiv, integer *info); +/* Subroutine */ int cggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, complex *a, integer *lda, complex *b, integer *ldb, real *tola, real *tolb, integer *k, integer *l, + complex *u, integer *ldu, complex *v, integer *ldv, complex *q, integer *ldq, integer *iwork, real *rwork, complex *tau, complex *work, integer *info); -/* Subroutine */ int cgttrs_(char *trans, integer *n, integer *nrhs, complex *dl, complex *d__, - complex *du, complex *du2, integer *ipiv, complex *b, integer *ldb, - integer *info); +/* Subroutine */ int cgtcon_(char *norm, integer *n, complex *dl, complex *d__, complex *du, complex *du2, integer *ipiv, real *anorm, real *rcond, complex *work, integer *info); -/* Subroutine */ int cgtts2_(integer *itrans, integer *n, integer *nrhs, complex *dl, complex *d__, - complex *du, complex *du2, integer *ipiv, complex *b, integer *ldb); +/* Subroutine */ int cgtrfs_(char *trans, integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, complex *dlf, complex *df, complex *duf, complex *du2, integer *ipiv, complex *b, + integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int chbev_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *w, complex *z__, integer *ldz, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cgtsv_(integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, complex *b, integer *ldb, integer *info); -/* Subroutine */ int chbevd_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *w, complex *z__, integer *ldz, complex *work, - integer *lwork, real *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int cgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, complex *dlf, complex *df, complex *duf, complex *du2, integer *ipiv, + complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int chbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - complex *ab, integer *ldab, complex *q, integer *ldq, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int cgttrf_(integer *n, complex *dl, complex *d__, complex *du, complex *du2, integer *ipiv, integer *info); -/* Subroutine */ int chbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, complex *x, - integer *ldx, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgttrs_(char *trans, integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, complex *du2, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int chbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, integer *info); +/* Subroutine */ int cgtts2_(integer *itrans, integer *n, integer *nrhs, complex *dl, complex *d__, complex *du, complex *du2, integer *ipiv, complex *b, integer *ldb); -/* Subroutine */ int chbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, real *w, - complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, +/* Subroutine */ int chbev_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *w, complex *z__, integer *ldz, complex *work, real *rwork, integer *info); + +/* Subroutine */ int chbevd_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *w, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int chbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, - complex *q, integer *ldq, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int chbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, complex *q, integer *ldq, real *vl, real *vu, integer *il, integer *iu, + real *abstol, integer *m, real *w, complex *z__, integer *ldz, complex *work, real *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int chbtrd_(char *vect, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *d__, real *e, complex *q, integer *ldq, - complex *work, integer *info); +/* Subroutine */ int chbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, complex *x, integer *ldx, complex *work, real *rwork, + integer *info); -/* Subroutine */ int checon_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - real *anorm, real *rcond, complex *work, integer *info); +/* Subroutine */ int chbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, real *w, complex *z__, integer *ldz, complex *work, + real *rwork, integer *info); -/* Subroutine */ int cheequb_(char *uplo, integer *n, complex *a, integer *lda, real *s, - real *scond, real *amax, complex *work, integer *info); +/* Subroutine */ int chbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, real *w, complex *z__, integer *ldz, complex *work, + integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int cheev_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, real *w, - complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int chbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, integer *kb, complex *ab, integer *ldab, complex *bb, integer *ldbb, complex *q, integer *ldq, real *vl, + real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, complex *z__, integer *ldz, complex *work, real *rwork, integer *iwork, integer *ifail, + integer *info); -/* Subroutine */ int cheevd_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, real *w, - complex *work, integer *lwork, real *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int chbtrd_(char *vect, char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *d__, real *e, complex *q, integer *ldq, complex *work, integer *info); -/* Subroutine */ int cheevr_(char *jobz, char *range, char *uplo, integer *n, complex *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, integer *ldz, - integer *isuppz, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int checon_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, real *anorm, real *rcond, complex *work, integer *info); -/* Subroutine */ int cheevx_(char *jobz, char *range, char *uplo, integer *n, complex *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, integer *ldz, - complex *work, integer *lwork, real *rwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int cheequb_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, complex *work, integer *info); -/* Subroutine */ int chegs2_(integer *itype, char *uplo, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cheev_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, real *w, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int chegst_(integer *itype, char *uplo, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cheevd_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, real *w, complex *work, integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, + integer *info); -/* Subroutine */ int chegv_(integer *itype, char *jobz, char *uplo, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, real *w, complex *work, - integer *lwork, real *rwork, integer *info); +/* Subroutine */ int cheevr_(char *jobz, char *range, char *uplo, integer *n, complex *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, complex *z__, + integer *ldz, integer *isuppz, complex *work, integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int chegvd_(integer *itype, char *jobz, char *uplo, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, real *w, complex *work, - integer *lwork, real *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int cheevx_(char *jobz, char *range, char *uplo, integer *n, complex *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, complex *z__, + integer *ldz, complex *work, integer *lwork, real *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int chegvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int chegs2_(integer *itype, char *uplo, integer *n, complex *a, integer *lda, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cherfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int chegst_(integer *itype, char *uplo, integer *n, complex *a, integer *lda, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cherfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, real *s, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, complex *work, - real *rwork, integer *info); +/* Subroutine */ int chegv_(integer *itype, char *jobz, char *uplo, integer *n, complex *a, integer *lda, complex *b, integer *ldb, real *w, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int chesv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int chegvd_(integer *itype, char *jobz, char *uplo, integer *n, complex *a, integer *lda, complex *b, integer *ldb, real *w, complex *work, integer *lwork, real *rwork, + integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int chesvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, - real *berr, complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int chegvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, complex *a, integer *lda, complex *b, integer *ldb, real *vl, real *vu, integer *il, integer *iu, + real *abstol, integer *m, real *w, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int chesvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, - real *s, complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, complex *work, real *rwork, integer *info); +/* Subroutine */ int cherfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, + real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int chetd2_(char *uplo, integer *n, complex *a, integer *lda, real *d__, real *e, - complex *tau, integer *info); +/* Subroutine */ int cherfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *s, complex *b, integer *ldb, complex *x, + integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, complex *work, real *rwork, + integer *info); -/* Subroutine */ int chetf2_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int chesv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, complex *work, integer *lwork, integer *info); -/* Subroutine */ int chetrd_(char *uplo, integer *n, complex *a, integer *lda, real *d__, real *e, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int chesvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, + real *rcond, real *ferr, real *berr, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int chetrf_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int chesvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, real *s, complex *b, integer *ldb, + complex *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, + complex *work, real *rwork, integer *info); -/* Subroutine */ int chetri_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - complex *work, integer *info); +/* Subroutine */ int chetd2_(char *uplo, integer *n, complex *a, integer *lda, real *d__, real *e, complex *tau, integer *info); -/* Subroutine */ int chetrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, integer *info); +/* Subroutine */ int chetf2_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int chfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, - real *alpha, complex *a, integer *lda, real *beta, complex *c__); +/* Subroutine */ int chetrd_(char *uplo, integer *n, complex *a, integer *lda, real *d__, real *e, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int chgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, complex *h__, integer *ldh, complex *t, integer *ldt, - complex *alpha, complex *beta, complex *q, integer *ldq, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *info); +/* Subroutine */ int chetrf_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, complex *work, integer *lwork, integer *info); -/* Character */ VOID chla_transtype__(char *ret_val, ftnlen ret_val_len, integer *trans); +/* Subroutine */ int chetri_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, complex *work, integer *info); -/* Subroutine */ int chpcon_(char *uplo, integer *n, complex *ap, integer *ipiv, real *anorm, - real *rcond, complex *work, integer *info); +/* Subroutine */ int chetrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int chpev_(char *jobz, char *uplo, integer *n, complex *ap, real *w, complex *z__, - integer *ldz, complex *work, real *rwork, integer *info); +/* Subroutine */ int chfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, real *alpha, complex *a, integer *lda, real *beta, complex *c__); -/* Subroutine */ int chpevd_(char *jobz, char *uplo, integer *n, complex *ap, real *w, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int chgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *t, integer *ldt, complex *alpha, complex *beta, + complex *q, integer *ldq, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int chpevx_(char *jobz, char *range, char *uplo, integer *n, complex *ap, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, integer *iwork, - integer *ifail, integer *info); +/* Character */ VOID chla_transtype__(char *ret_val, ftnlen ret_val_len, integer *trans); -/* Subroutine */ int chpgst_(integer *itype, char *uplo, integer *n, complex *ap, complex *bp, - integer *info); +/* Subroutine */ int chpcon_(char *uplo, integer *n, complex *ap, integer *ipiv, real *anorm, real *rcond, complex *work, integer *info); -/* Subroutine */ int chpgv_(integer *itype, char *jobz, char *uplo, integer *n, complex *ap, - complex *bp, real *w, complex *z__, integer *ldz, complex *work, - real *rwork, integer *info); +/* Subroutine */ int chpev_(char *jobz, char *uplo, integer *n, complex *ap, real *w, complex *z__, integer *ldz, complex *work, real *rwork, integer *info); -/* Subroutine */ int chpgvd_(integer *itype, char *jobz, char *uplo, integer *n, complex *ap, - complex *bp, real *w, complex *z__, integer *ldz, complex *work, - integer *lwork, real *rwork, integer *lrwork, integer *iwork, +/* Subroutine */ int chpevd_(char *jobz, char *uplo, integer *n, complex *ap, real *w, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int chpgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - complex *ap, complex *bp, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int chpevx_(char *jobz, char *range, char *uplo, integer *n, complex *ap, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, complex *z__, integer *ldz, + complex *work, real *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int chprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, - integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int chpgst_(integer *itype, char *uplo, integer *n, complex *ap, complex *bp, integer *info); + +/* Subroutine */ int chpgv_(integer *itype, char *jobz, char *uplo, integer *n, complex *ap, complex *bp, real *w, complex *z__, integer *ldz, complex *work, real *rwork, integer *info); -/* Subroutine */ int chpsv_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int chpgvd_(integer *itype, char *jobz, char *uplo, integer *n, complex *ap, complex *bp, real *w, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, + integer *lrwork, integer *iwork, integer *liwork, integer *info); + +/* Subroutine */ int chpgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, complex *ap, complex *bp, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, + complex *z__, integer *ldz, complex *work, real *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int chpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, complex *work, +/* Subroutine */ int chprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int chptrd_(char *uplo, integer *n, complex *ap, real *d__, real *e, complex *tau, - integer *info); +/* Subroutine */ int chpsv_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int chptrf_(char *uplo, integer *n, complex *ap, integer *ipiv, integer *info); +/* Subroutine */ int chpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, + real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int chptri_(char *uplo, integer *n, complex *ap, integer *ipiv, complex *work, - integer *info); +/* Subroutine */ int chptrd_(char *uplo, integer *n, complex *ap, real *d__, real *e, complex *tau, integer *info); -/* Subroutine */ int chptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int chptrf_(char *uplo, integer *n, complex *ap, integer *ipiv, integer *info); -/* Subroutine */ int chsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, - complex *h__, integer *ldh, complex *w, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, integer *mm, integer *m, complex *work, - real *rwork, integer *ifaill, integer *ifailr, integer *info); +/* Subroutine */ int chptri_(char *uplo, integer *n, complex *ap, integer *ipiv, complex *work, integer *info); -/* Subroutine */ int chseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, - complex *h__, integer *ldh, complex *w, complex *z__, integer *ldz, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int chptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, - real *alpha, complex *ab, integer *ldab, complex *x, integer *incx, - real *beta, real *y, integer *incy); +/* Subroutine */ int chsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, complex *h__, integer *ldh, complex *w, complex *vl, integer *ldvl, complex *vr, integer *ldvr, + integer *mm, integer *m, complex *work, real *rwork, integer *ifaill, integer *ifailr, integer *info); -doublereal cla_gbrcond_c__(char *trans, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, complex *afb, integer *ldafb, integer *ipiv, real *c__, - logical *capply, integer *info, complex *work, real *rwork, - ftnlen trans_len); +/* Subroutine */ int chseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *w, complex *z__, integer *ldz, complex *work, integer *lwork, + integer *info); -doublereal cla_gbrcond_x__(char *trans, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, complex *afb, integer *ldafb, integer *ipiv, complex *x, - integer *info, complex *work, real *rwork, ftnlen trans_len); - -/* Subroutine */ int cla_gbrfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, - integer *kl, integer *ku, integer *nrhs, complex *ab, - integer *ldab, complex *afb, integer *ldafb, - integer *ipiv, logical *colequ, real *c__, complex *b, - integer *ldb, complex *y, integer *ldy, real *berr_out__, - integer *n_norms__, real *errs_n__, real *errs_c__, - complex *res, real *ayb, complex *dy, complex *y_tail__, - real *rcond, integer *ithresh, real *rthresh, - real *dz_ub__, logical *ignore_cwise__, integer *info); - -doublereal cla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, complex *ab, - integer *ldab, complex *afb, integer *ldafb); - -/* Subroutine */ int cla_geamv__(integer *trans, integer *m, integer *n, real *alpha, complex *a, - integer *lda, complex *x, integer *incx, real *beta, real *y, +/* Subroutine */ int cla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, real *alpha, complex *ab, integer *ldab, complex *x, integer *incx, real *beta, real *y, integer *incy); -doublereal cla_gercond_c__(char *trans, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, +doublereal cla_gbrcond_c__(char *trans, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, real *c__, logical *capply, integer *info, complex *work, real *rwork, ftnlen trans_len); -doublereal cla_gercond_x__(char *trans, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, +doublereal cla_gbrcond_x__(char *trans, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *ipiv, complex *x, integer *info, complex *work, real *rwork, ftnlen trans_len); -/* Subroutine */ int cla_gerfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, complex *b, integer *ldb, - complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, - complex *res, real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *ithresh, - real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info); +/* Subroutine */ int cla_gbrfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, + integer *ipiv, logical *colequ, real *c__, complex *b, integer *ldb, complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, + real *errs_c__, complex *res, real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, + logical *ignore_cwise__, integer *info); -/* Subroutine */ int cla_heamv__(integer *uplo, integer *n, real *alpha, complex *a, integer *lda, - complex *x, integer *incx, real *beta, real *y, integer *incy); +doublereal cla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, complex *ab, integer *ldab, complex *afb, integer *ldafb); -doublereal cla_hercond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, - complex *work, real *rwork, ftnlen uplo_len); +/* Subroutine */ int cla_geamv__(integer *trans, integer *m, integer *n, real *alpha, complex *a, integer *lda, complex *x, integer *incx, real *beta, real *y, integer *incy); -doublereal cla_hercond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, - real *rwork, ftnlen uplo_len); - -/* Subroutine */ int cla_herfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, complex *b, integer *ldb, - complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, - complex *res, real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *ithresh, - real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); +doublereal cla_gercond_c__(char *trans, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, complex *work, real *rwork, + ftnlen trans_len); -doublereal cla_herpvgrw__(char *uplo, integer *n, integer *info, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); +doublereal cla_gercond_x__(char *trans, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, real *rwork, ftnlen trans_len); -/* Subroutine */ int cla_lin_berr__(integer *n, integer *nz, integer *nrhs, complex *res, real *ayb, - real *berr); +/* Subroutine */ int cla_gerfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, logical *colequ, + real *c__, complex *b, integer *ldb, complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, real *ayb, + complex *dy, complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info); -doublereal cla_porcond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, real *c__, logical *capply, integer *info, complex *work, - real *rwork, ftnlen uplo_len); +/* Subroutine */ int cla_heamv__(integer *uplo, integer *n, real *alpha, complex *a, integer *lda, complex *x, integer *incx, real *beta, real *y, integer *incy); -doublereal cla_porcond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, complex *x, integer *info, complex *work, real *rwork, +doublereal cla_hercond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, complex *work, real *rwork, ftnlen uplo_len); -/* Subroutine */ int cla_porfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, logical *colequ, real *c__, complex *b, integer *ldb, complex *y, - integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, - real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, - real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); +doublereal cla_hercond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, real *rwork, ftnlen uplo_len); -doublereal cla_porpvgrw__(char *uplo, integer *ncols, complex *a, integer *lda, complex *af, - integer *ldaf, real *work, ftnlen uplo_len); +/* Subroutine */ int cla_herfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, + complex *b, integer *ldb, complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, real *ayb, + complex *dy, complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal cla_rpvgrw__(integer *n, integer *ncols, complex *a, integer *lda, complex *af, - integer *ldaf); +doublereal cla_herpvgrw__(char *uplo, integer *n, integer *info, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); -/* Subroutine */ int cla_syamv__(integer *uplo, integer *n, real *alpha, complex *a, integer *lda, - complex *x, integer *incx, real *beta, real *y, integer *incy); +/* Subroutine */ int cla_lin_berr__(integer *n, integer *nz, integer *nrhs, complex *res, real *ayb, real *berr); -doublereal cla_syrcond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, - complex *work, real *rwork, ftnlen uplo_len); +doublereal cla_porcond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, real *c__, logical *capply, integer *info, complex *work, real *rwork, ftnlen uplo_len); -doublereal cla_syrcond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, - integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, - real *rwork, ftnlen uplo_len); +doublereal cla_porcond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, complex *x, integer *info, complex *work, real *rwork, ftnlen uplo_len); -/* Subroutine */ int cla_syrfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, complex *b, integer *ldb, - complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, - complex *res, real *ayb, complex *dy, complex *y_tail__, real *rcond, integer *ithresh, - real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); +/* Subroutine */ int cla_porfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, logical *colequ, real *c__, complex *b, + integer *ldb, complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, real *ayb, complex *dy, + complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal cla_syrpvgrw__(char *uplo, integer *n, integer *info, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); +doublereal cla_porpvgrw__(char *uplo, integer *ncols, complex *a, integer *lda, complex *af, integer *ldaf, real *work, ftnlen uplo_len); + +doublereal cla_rpvgrw__(integer *n, integer *ncols, complex *a, integer *lda, complex *af, integer *ldaf); + +/* Subroutine */ int cla_syamv__(integer *uplo, integer *n, real *alpha, complex *a, integer *lda, complex *x, integer *incx, real *beta, real *y, integer *incy); + +doublereal cla_syrcond_c__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *c__, logical *capply, integer *info, complex *work, real *rwork, + ftnlen uplo_len); + +doublereal cla_syrcond_x__(char *uplo, integer *n, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *x, integer *info, complex *work, real *rwork, ftnlen uplo_len); + +/* Subroutine */ int cla_syrfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, + complex *b, integer *ldb, complex *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, complex *res, real *ayb, + complex *dy, complex *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); + +doublereal cla_syrpvgrw__(char *uplo, integer *n, integer *info, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); /* Subroutine */ int cla_wwaddw__(integer *n, complex *x, complex *y, complex *w); -/* Subroutine */ int clabrd_(integer *m, integer *n, integer *nb, complex *a, integer *lda, - real *d__, real *e, complex *tauq, complex *taup, complex *x, - integer *ldx, complex *y, integer *ldy); +/* Subroutine */ int clabrd_(integer *m, integer *n, integer *nb, complex *a, integer *lda, real *d__, real *e, complex *tauq, complex *taup, complex *x, integer *ldx, complex *y, integer *ldy); /* Subroutine */ int clacgv_(integer *n, complex *x, integer *incx); -/* Subroutine */ int clacn2_(integer *n, complex *v, complex *x, real *est, integer *kase, - integer *isave); +/* Subroutine */ int clacn2_(integer *n, complex *v, complex *x, real *est, integer *kase, integer *isave); /* Subroutine */ int clacon_(integer *n, complex *v, complex *x, real *est, integer *kase); -/* Subroutine */ int clacp2_(char *uplo, integer *m, integer *n, real *a, integer *lda, complex *b, - integer *ldb); +/* Subroutine */ int clacp2_(char *uplo, integer *m, integer *n, real *a, integer *lda, complex *b, integer *ldb); -/* Subroutine */ int clacpy_(char *uplo, integer *m, integer *n, complex *a, integer *lda, - complex *b, integer *ldb); +/* Subroutine */ int clacpy_(char *uplo, integer *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb); -/* Subroutine */ int clacrm_(integer *m, integer *n, complex *a, integer *lda, real *b, - integer *ldb, complex *c__, integer *ldc, real *rwork); +/* Subroutine */ int clacrm_(integer *m, integer *n, complex *a, integer *lda, real *b, integer *ldb, complex *c__, integer *ldc, real *rwork); -/* Subroutine */ int clacrt_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, - complex *c__, complex *s); +/* Subroutine */ int clacrt_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, complex *c__, complex *s); /* Complex */ VOID cladiv_(complex *ret_val, complex *x, complex *y); -/* Subroutine */ int claed0_(integer *qsiz, integer *n, real *d__, real *e, complex *q, - integer *ldq, complex *qstore, integer *ldqs, real *rwork, - integer *iwork, integer *info); +/* Subroutine */ int claed0_(integer *qsiz, integer *n, real *d__, real *e, complex *q, integer *ldq, complex *qstore, integer *ldqs, real *rwork, integer *iwork, integer *info); -/* Subroutine */ int claed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, real *d__, complex *q, integer *ldq, - real *rho, integer *indxq, real *qstore, integer *qptr, - integer *prmptr, integer *perm, integer *givptr, integer *givcol, - real *givnum, complex *work, real *rwork, integer *iwork, - integer *info); +/* Subroutine */ int claed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, integer *curlvl, integer *curpbm, real *d__, complex *q, integer *ldq, real *rho, integer *indxq, real *qstore, + integer *qptr, integer *prmptr, integer *perm, integer *givptr, integer *givcol, real *givnum, complex *work, real *rwork, integer *iwork, integer *info); -/* Subroutine */ int claed8_(integer *k, integer *n, integer *qsiz, complex *q, integer *ldq, - real *d__, real *rho, integer *cutpnt, real *z__, real *dlamda, - complex *q2, integer *ldq2, real *w, integer *indxp, integer *indx, - integer *indxq, integer *perm, integer *givptr, integer *givcol, - real *givnum, integer *info); +/* Subroutine */ int claed8_(integer *k, integer *n, integer *qsiz, complex *q, integer *ldq, real *d__, real *rho, integer *cutpnt, real *z__, real *dlamda, complex *q2, integer *ldq2, real *w, + integer *indxp, integer *indx, integer *indxq, integer *perm, integer *givptr, integer *givcol, real *givnum, integer *info); + +/* Subroutine */ int claein_(logical *rightv, logical *noinit, integer *n, complex *h__, integer *ldh, complex *w, complex *v, complex *b, integer *ldb, real *rwork, real *eps3, real *smlnum, + integer *info); -/* Subroutine */ int claein_(logical *rightv, logical *noinit, integer *n, complex *h__, - integer *ldh, complex *w, complex *v, complex *b, integer *ldb, - real *rwork, real *eps3, real *smlnum, integer *info); +/* Subroutine */ int claesy_(complex *a, complex *b, complex *c__, complex *rt1, complex *rt2, complex *evscal, complex *cs1, complex *sn1); -/* Subroutine */ int claesy_(complex *a, complex *b, complex *c__, complex *rt1, complex *rt2, - complex *evscal, complex *cs1, complex *sn1); +/* Subroutine */ int claev2_(complex *a, complex *b, complex *c__, real *rt1, real *rt2, real *cs1, complex *sn1); -/* Subroutine */ int claev2_(complex *a, complex *b, complex *c__, real *rt1, real *rt2, real *cs1, - complex *sn1); +/* Subroutine */ int clag2z_(integer *m, integer *n, complex *sa, integer *ldsa, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int clag2z_(integer *m, integer *n, complex *sa, integer *ldsa, doublecomplex *a, - integer *lda, integer *info); +/* Subroutine */ int clags2_(logical *upper, real *a1, complex *a2, real *a3, real *b1, complex *b2, real *b3, real *csu, complex *snu, real *csv, complex *snv, real *csq, complex *snq); -/* Subroutine */ int clags2_(logical *upper, real *a1, complex *a2, real *a3, real *b1, complex *b2, - real *b3, real *csu, complex *snu, real *csv, complex *snv, real *csq, - complex *snq); +/* Subroutine */ int clagtm_(char *trans, integer *n, integer *nrhs, real *alpha, complex *dl, complex *d__, complex *du, complex *x, integer *ldx, real *beta, complex *b, integer *ldb); -/* Subroutine */ int clagtm_(char *trans, integer *n, integer *nrhs, real *alpha, complex *dl, - complex *d__, complex *du, complex *x, integer *ldx, real *beta, - complex *b, integer *ldb); +/* Subroutine */ int clahef_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, integer *lda, integer *ipiv, complex *w, integer *ldw, integer *info); -/* Subroutine */ int clahef_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, - integer *lda, integer *ipiv, complex *w, integer *ldw, integer *info); +/* Subroutine */ int clahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, complex *z__, integer *ldz, + integer *info); -/* Subroutine */ int clahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, - complex *z__, integer *ldz, integer *info); +/* Subroutine */ int clahr2_(integer *n, integer *k, integer *nb, complex *a, integer *lda, complex *tau, complex *t, integer *ldt, complex *y, integer *ldy); -/* Subroutine */ int clahr2_(integer *n, integer *k, integer *nb, complex *a, integer *lda, - complex *tau, complex *t, integer *ldt, complex *y, integer *ldy); +/* Subroutine */ int clahrd_(integer *n, integer *k, integer *nb, complex *a, integer *lda, complex *tau, complex *t, integer *ldt, complex *y, integer *ldy); -/* Subroutine */ int clahrd_(integer *n, integer *k, integer *nb, complex *a, integer *lda, - complex *tau, complex *t, integer *ldt, complex *y, integer *ldy); +/* Subroutine */ int claic1_(integer *job, integer *j, complex *x, real *sest, complex *w, complex *gamma, real *sestpr, complex *s, complex *c__); -/* Subroutine */ int claic1_(integer *job, integer *j, complex *x, real *sest, complex *w, - complex *gamma, real *sestpr, complex *s, complex *c__); +/* Subroutine */ int clals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *nrhs, complex *b, integer *ldb, complex *bx, integer *ldbx, integer *perm, integer *givptr, + integer *givcol, integer *ldgcol, real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, real *z__, integer *k, real *c__, real *s, real *rwork, + integer *info); -/* Subroutine */ int clals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, complex *b, integer *ldb, complex *bx, integer *ldbx, - integer *perm, integer *givptr, integer *givcol, integer *ldgcol, - real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *rwork, integer *info); +/* Subroutine */ int clalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, complex *b, integer *ldb, complex *bx, integer *ldbx, real *u, integer *ldu, real *vt, integer *k, real *difl, + real *difr, real *z__, real *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, real *givnum, real *c__, real *s, real *rwork, integer *iwork, + integer *info); -/* Subroutine */ int clalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - complex *b, integer *ldb, complex *bx, integer *ldbx, real *u, - integer *ldu, real *vt, integer *k, real *difl, real *difr, real *z__, - real *poles, integer *givptr, integer *givcol, integer *ldgcol, - integer *perm, real *givnum, real *c__, real *s, real *rwork, +/* Subroutine */ int clalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, real *d__, real *e, complex *b, integer *ldb, real *rcond, integer *rank, complex *work, real *rwork, integer *iwork, integer *info); -/* Subroutine */ int clalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, real *d__, - real *e, complex *b, integer *ldb, real *rcond, integer *rank, - complex *work, real *rwork, integer *iwork, integer *info); - -doublereal clangb_(char *norm, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, - real *work); +doublereal clangb_(char *norm, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, real *work); doublereal clange_(char *norm, integer *m, integer *n, complex *a, integer *lda, real *work); doublereal clangt_(char *norm, integer *n, complex *dl, complex *d__, complex *du); -doublereal clanhb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, integer *ldab, - real *work); +doublereal clanhb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, integer *ldab, real *work); doublereal clanhe_(char *norm, char *uplo, integer *n, complex *a, integer *lda, real *work); @@ -1242,273 +809,181 @@ doublereal clanhs_(char *norm, integer *n, complex *a, integer *lda, real *work) doublereal clanht_(char *norm, integer *n, real *d__, complex *e); -doublereal clansb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, integer *ldab, - real *work); +doublereal clansb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, integer *ldab, real *work); doublereal clansp_(char *norm, char *uplo, integer *n, complex *ap, real *work); doublereal clansy_(char *norm, char *uplo, integer *n, complex *a, integer *lda, real *work); -doublereal clantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, complex *ab, - integer *ldab, real *work); +doublereal clantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, complex *ab, integer *ldab, real *work); doublereal clantp_(char *norm, char *uplo, char *diag, integer *n, complex *ap, real *work); -doublereal clantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, complex *a, - integer *lda, real *work); +doublereal clantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, complex *a, integer *lda, real *work); -/* Subroutine */ int clapll_(integer *n, complex *x, integer *incx, complex *y, integer *incy, - real *ssmin); +/* Subroutine */ int clapll_(integer *n, complex *x, integer *incx, complex *y, integer *incy, real *ssmin); -/* Subroutine */ int clapmt_(logical *forwrd, integer *m, integer *n, complex *x, integer *ldx, - integer *k); +/* Subroutine */ int clapmt_(logical *forwrd, integer *m, integer *n, complex *x, integer *ldx, integer *k); -/* Subroutine */ int claqgb_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, char *equed); +/* Subroutine */ int claqgb_(integer *m, integer *n, integer *kl, integer *ku, complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, char *equed); -/* Subroutine */ int claqge_(integer *m, integer *n, complex *a, integer *lda, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, char *equed); +/* Subroutine */ int claqge_(integer *m, integer *n, complex *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, char *equed); -/* Subroutine */ int claqhb_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - real *s, real *scond, real *amax, char *equed); +/* Subroutine */ int claqhb_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int claqhe_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, - real *amax, char *equed); +/* Subroutine */ int claqhe_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int claqhp_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, - char *equed); +/* Subroutine */ int claqhp_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int claqp2_(integer *m, integer *n, integer *offset, complex *a, integer *lda, - integer *jpvt, complex *tau, real *vn1, real *vn2, complex *work); +/* Subroutine */ int claqp2_(integer *m, integer *n, integer *offset, complex *a, integer *lda, integer *jpvt, complex *tau, real *vn1, real *vn2, complex *work); -/* Subroutine */ int claqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, - complex *a, integer *lda, integer *jpvt, complex *tau, real *vn1, - real *vn2, complex *auxv, complex *f, integer *ldf); +/* Subroutine */ int claqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, complex *a, integer *lda, integer *jpvt, complex *tau, real *vn1, real *vn2, complex *auxv, complex *f, + integer *ldf); -/* Subroutine */ int claqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, - complex *z__, integer *ldz, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int claqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, complex *z__, integer *ldz, + complex *work, integer *lwork, integer *info); -/* Subroutine */ int claqr1_(integer *n, complex *h__, integer *ldh, complex *s1, complex *s2, - complex *v); - -/* Subroutine */ int claqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, complex *h__, integer *ldh, integer *iloz, - integer *ihiz, complex *z__, integer *ldz, integer *ns, integer *nd, - complex *sh, complex *v, integer *ldv, integer *nh, complex *t, - integer *ldt, integer *nv, complex *wv, integer *ldwv, complex *work, - integer *lwork); - -/* Subroutine */ int claqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, complex *h__, integer *ldh, integer *iloz, - integer *ihiz, complex *z__, integer *ldz, integer *ns, integer *nd, - complex *sh, complex *v, integer *ldv, integer *nh, complex *t, - integer *ldt, integer *nv, complex *wv, integer *ldwv, complex *work, - integer *lwork); - -/* Subroutine */ int claqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, - complex *z__, integer *ldz, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int claqr1_(integer *n, complex *h__, integer *ldh, complex *s1, complex *s2, complex *v); + +/* Subroutine */ int claqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, complex *h__, integer *ldh, integer *iloz, integer *ihiz, complex *z__, + integer *ldz, integer *ns, integer *nd, complex *sh, complex *v, integer *ldv, integer *nh, complex *t, integer *ldt, integer *nv, complex *wv, integer *ldwv, + complex *work, integer *lwork); + +/* Subroutine */ int claqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, complex *h__, integer *ldh, integer *iloz, integer *ihiz, complex *z__, + integer *ldz, integer *ns, integer *nd, complex *sh, complex *v, integer *ldv, integer *nh, complex *t, integer *ldt, integer *nv, complex *wv, integer *ldwv, + complex *work, integer *lwork); + +/* Subroutine */ int claqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *w, integer *iloz, integer *ihiz, complex *z__, integer *ldz, + complex *work, integer *lwork, integer *info); -/* Subroutine */ int claqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, - integer *ktop, integer *kbot, integer *nshfts, complex *s, - complex *h__, integer *ldh, integer *iloz, integer *ihiz, complex *z__, - integer *ldz, complex *v, integer *ldv, complex *u, integer *ldu, - integer *nv, complex *wv, integer *ldwv, integer *nh, complex *wh, +/* Subroutine */ int claqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, integer *ktop, integer *kbot, integer *nshfts, complex *s, complex *h__, integer *ldh, integer *iloz, + integer *ihiz, complex *z__, integer *ldz, complex *v, integer *ldv, complex *u, integer *ldu, integer *nv, complex *wv, integer *ldwv, integer *nh, complex *wh, integer *ldwh); -/* Subroutine */ int claqsb_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - real *s, real *scond, real *amax, char *equed); +/* Subroutine */ int claqsb_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int claqsp_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, - char *equed); +/* Subroutine */ int claqsp_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int claqsy_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, - real *amax, char *equed); +/* Subroutine */ int claqsy_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int clar1v_(integer *n, integer *b1, integer *bn, real *lambda, real *d__, real *l, - real *ld, real *lld, real *pivmin, real *gaptol, complex *z__, - logical *wantnc, integer *negcnt, real *ztz, real *mingma, - integer *r__, integer *isuppz, real *nrminv, real *resid, real *rqcorr, - real *work); +/* Subroutine */ int clar1v_(integer *n, integer *b1, integer *bn, real *lambda, real *d__, real *l, real *ld, real *lld, real *pivmin, real *gaptol, complex *z__, logical *wantnc, integer *negcnt, + real *ztz, real *mingma, integer *r__, integer *isuppz, real *nrminv, real *resid, real *rqcorr, real *work); -/* Subroutine */ int clar2v_(integer *n, complex *x, complex *y, complex *z__, integer *incx, - real *c__, complex *s, integer *incc); +/* Subroutine */ int clar2v_(integer *n, complex *x, complex *y, complex *z__, integer *incx, real *c__, complex *s, integer *incc); -/* Subroutine */ int clarcm_(integer *m, integer *n, real *a, integer *lda, complex *b, - integer *ldb, complex *c__, integer *ldc, real *rwork); +/* Subroutine */ int clarcm_(integer *m, integer *n, real *a, integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, real *rwork); -/* Subroutine */ int clarf_(char *side, integer *m, integer *n, complex *v, integer *incv, - complex *tau, complex *c__, integer *ldc, complex *work); +/* Subroutine */ int clarf_(char *side, integer *m, integer *n, complex *v, integer *incv, complex *tau, complex *c__, integer *ldc, complex *work); -/* Subroutine */ int clarfb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, complex *v, integer *ldv, complex *t, - integer *ldt, complex *c__, integer *ldc, complex *work, - integer *ldwork); +/* Subroutine */ int clarfb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, complex *v, integer *ldv, complex *t, integer *ldt, complex *c__, integer *ldc, + complex *work, integer *ldwork); /* Subroutine */ int clarfg_(integer *n, complex *alpha, complex *x, integer *incx, complex *tau); /* Subroutine */ int clarfp_(integer *n, complex *alpha, complex *x, integer *incx, complex *tau); -/* Subroutine */ int clarft_(char *direct, char *storev, integer *n, integer *k, complex *v, - integer *ldv, complex *tau, complex *t, integer *ldt); +/* Subroutine */ int clarft_(char *direct, char *storev, integer *n, integer *k, complex *v, integer *ldv, complex *tau, complex *t, integer *ldt); -/* Subroutine */ int clarfx_(char *side, integer *m, integer *n, complex *v, complex *tau, - complex *c__, integer *ldc, complex *work); +/* Subroutine */ int clarfx_(char *side, integer *m, integer *n, complex *v, complex *tau, complex *c__, integer *ldc, complex *work); -/* Subroutine */ int clargv_(integer *n, complex *x, integer *incx, complex *y, integer *incy, - real *c__, integer *incc); +/* Subroutine */ int clargv_(integer *n, complex *x, integer *incx, complex *y, integer *incy, real *c__, integer *incc); /* Subroutine */ int clarnv_(integer *idist, integer *iseed, integer *n, complex *x); -/* Subroutine */ int clarrv_(integer *n, real *vl, real *vu, real *d__, real *l, real *pivmin, - integer *isplit, integer *m, integer *dol, integer *dou, real *minrgp, - real *rtol1, real *rtol2, real *w, real *werr, real *wgap, - integer *iblock, integer *indexw, real *gers, complex *z__, - integer *ldz, integer *isuppz, real *work, integer *iwork, - integer *info); +/* Subroutine */ int clarrv_(integer *n, real *vl, real *vu, real *d__, real *l, real *pivmin, integer *isplit, integer *m, integer *dol, integer *dou, real *minrgp, real *rtol1, real *rtol2, real *w, + real *werr, real *wgap, integer *iblock, integer *indexw, real *gers, complex *z__, integer *ldz, integer *isuppz, real *work, integer *iwork, integer *info); /* Subroutine */ int clarscl2_(integer *m, integer *n, real *d__, complex *x, integer *ldx); /* Subroutine */ int clartg_(complex *f, complex *g, real *cs, complex *sn, complex *r__); -/* Subroutine */ int clartv_(integer *n, complex *x, integer *incx, complex *y, integer *incy, - real *c__, complex *s, integer *incc); +/* Subroutine */ int clartv_(integer *n, complex *x, integer *incx, complex *y, integer *incy, real *c__, complex *s, integer *incc); -/* Subroutine */ int clarz_(char *side, integer *m, integer *n, integer *l, complex *v, - integer *incv, complex *tau, complex *c__, integer *ldc, complex *work); +/* Subroutine */ int clarz_(char *side, integer *m, integer *n, integer *l, complex *v, integer *incv, complex *tau, complex *c__, integer *ldc, complex *work); -/* Subroutine */ int clarzb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, integer *l, complex *v, integer *ldv, - complex *t, integer *ldt, complex *c__, integer *ldc, complex *work, - integer *ldwork); +/* Subroutine */ int clarzb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, integer *l, complex *v, integer *ldv, complex *t, integer *ldt, complex *c__, + integer *ldc, complex *work, integer *ldwork); -/* Subroutine */ int clarzt_(char *direct, char *storev, integer *n, integer *k, complex *v, - integer *ldv, complex *tau, complex *t, integer *ldt); +/* Subroutine */ int clarzt_(char *direct, char *storev, integer *n, integer *k, complex *v, integer *ldv, complex *tau, complex *t, integer *ldt); -/* Subroutine */ int clascl_(char *type__, integer *kl, integer *ku, real *cfrom, real *cto, - integer *m, integer *n, complex *a, integer *lda, integer *info); +/* Subroutine */ int clascl_(char *type__, integer *kl, integer *ku, real *cfrom, real *cto, integer *m, integer *n, complex *a, integer *lda, integer *info); /* Subroutine */ int clascl2_(integer *m, integer *n, real *d__, complex *x, integer *ldx); -/* Subroutine */ int claset_(char *uplo, integer *m, integer *n, complex *alpha, complex *beta, - complex *a, integer *lda); +/* Subroutine */ int claset_(char *uplo, integer *m, integer *n, complex *alpha, complex *beta, complex *a, integer *lda); -/* Subroutine */ int clasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - real *c__, real *s, complex *a, integer *lda); +/* Subroutine */ int clasr_(char *side, char *pivot, char *direct, integer *m, integer *n, real *c__, real *s, complex *a, integer *lda); /* Subroutine */ int classq_(integer *n, complex *x, integer *incx, real *scale, real *sumsq); -/* Subroutine */ int claswp_(integer *n, complex *a, integer *lda, integer *k1, integer *k2, - integer *ipiv, integer *incx); +/* Subroutine */ int claswp_(integer *n, complex *a, integer *lda, integer *k1, integer *k2, integer *ipiv, integer *incx); -/* Subroutine */ int clasyf_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, - integer *lda, integer *ipiv, complex *w, integer *ldw, integer *info); +/* Subroutine */ int clasyf_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, integer *lda, integer *ipiv, complex *w, integer *ldw, integer *info); -/* Subroutine */ int clatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - integer *kd, complex *ab, integer *ldab, complex *x, real *scale, - real *cnorm, integer *info); +/* Subroutine */ int clatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, integer *kd, complex *ab, integer *ldab, complex *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int clatdf_(integer *ijob, integer *n, complex *z__, integer *ldz, complex *rhs, - real *rdsum, real *rdscal, integer *ipiv, integer *jpiv); +/* Subroutine */ int clatdf_(integer *ijob, integer *n, complex *z__, integer *ldz, complex *rhs, real *rdsum, real *rdscal, integer *ipiv, integer *jpiv); -/* Subroutine */ int clatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, - complex *ap, complex *x, real *scale, real *cnorm, integer *info); +/* Subroutine */ int clatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, complex *ap, complex *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int clatrd_(char *uplo, integer *n, integer *nb, complex *a, integer *lda, real *e, - complex *tau, complex *w, integer *ldw); +/* Subroutine */ int clatrd_(char *uplo, integer *n, integer *nb, complex *a, integer *lda, real *e, complex *tau, complex *w, integer *ldw); -/* Subroutine */ int clatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - complex *a, integer *lda, complex *x, real *scale, real *cnorm, - integer *info); +/* Subroutine */ int clatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, complex *a, integer *lda, complex *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int clatrz_(integer *m, integer *n, integer *l, complex *a, integer *lda, - complex *tau, complex *work); +/* Subroutine */ int clatrz_(integer *m, integer *n, integer *l, complex *a, integer *lda, complex *tau, complex *work); -/* Subroutine */ int clatzm_(char *side, integer *m, integer *n, complex *v, integer *incv, - complex *tau, complex *c1, complex *c2, integer *ldc, complex *work); +/* Subroutine */ int clatzm_(char *side, integer *m, integer *n, complex *v, integer *incv, complex *tau, complex *c1, complex *c2, integer *ldc, complex *work); /* Subroutine */ int clauu2_(char *uplo, integer *n, complex *a, integer *lda, integer *info); /* Subroutine */ int clauum_(char *uplo, integer *n, complex *a, integer *lda, integer *info); -/* Subroutine */ int cpbcon_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - real *anorm, real *rcond, complex *work, real *rwork, integer *info); +/* Subroutine */ int cpbcon_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *anorm, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int cpbequ_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - real *s, real *scond, real *amax, integer *info); +/* Subroutine */ int cpbequ_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int cpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, - integer *ldab, complex *afb, integer *ldafb, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, complex *b, integer *ldb, complex *x, integer *ldx, + real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cpbstf_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - integer *info); +/* Subroutine */ int cpbstf_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, integer *info); -/* Subroutine */ int cpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, - integer *ldab, complex *b, integer *ldb, integer *info); +/* Subroutine */ int cpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, - complex *ab, integer *ldab, complex *afb, integer *ldafb, char *equed, - real *s, complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *ferr, real *berr, complex *work, real *rwork, - integer *info); +/* Subroutine */ int cpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer *ldafb, char *equed, real *s, complex *b, integer *ldb, + complex *x, integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cpbtf2_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - integer *info); +/* Subroutine */ int cpbtf2_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, integer *info); -/* Subroutine */ int cpbtrf_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, - integer *info); +/* Subroutine */ int cpbtrf_(char *uplo, integer *n, integer *kd, complex *ab, integer *ldab, integer *info); -/* Subroutine */ int cpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, - integer *ldab, complex *b, integer *ldb, integer *info); +/* Subroutine */ int cpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, integer *info); /* Subroutine */ int cpftrf_(char *transr, char *uplo, integer *n, complex *a, integer *info); /* Subroutine */ int cpftri_(char *transr, char *uplo, integer *n, complex *a, integer *info); -/* Subroutine */ int cpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, complex *a, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, complex *a, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cpocon_(char *uplo, integer *n, complex *a, integer *lda, real *anorm, - real *rcond, complex *work, real *rwork, integer *info); +/* Subroutine */ int cpocon_(char *uplo, integer *n, complex *a, integer *lda, real *anorm, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int cpoequ_(integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, - integer *info); +/* Subroutine */ int cpoequ_(integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int cpoequb_(integer *n, complex *a, integer *lda, real *s, real *scond, - real *amax, integer *info); +/* Subroutine */ int cpoequb_(integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int cporfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, complex *b, integer *ldb, complex *x, - integer *ldx, real *ferr, real *berr, complex *work, real *rwork, - integer *info); +/* Subroutine */ int cporfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, + complex *work, real *rwork, integer *info); -/* Subroutine */ int cporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, real *s, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, real *berr, - integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, - integer *nparams, real *params, complex *work, real *rwork, - integer *info); +/* Subroutine */ int cporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, real *s, complex *b, integer *ldb, complex *x, integer *ldx, + real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, complex *work, real *rwork, integer *info); -/* Subroutine */ int cposv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cposv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cposvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, char *equed, real *s, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cposvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, char *equed, real *s, complex *b, integer *ldb, complex *x, + integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int cposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, char *equed, real *s, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, complex *work, real *rwork, integer *info); +/* Subroutine */ int cposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, char *equed, real *s, complex *b, integer *ldb, complex *x, + integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, complex *work, + real *rwork, integer *info); /* Subroutine */ int cpotf2_(char *uplo, integer *n, complex *a, integer *lda, integer *info); @@ -1516,1602 +991,992 @@ doublereal clantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, c /* Subroutine */ int cpotri_(char *uplo, integer *n, complex *a, integer *lda, integer *info); -/* Subroutine */ int cpotrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cpotrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cppcon_(char *uplo, integer *n, complex *ap, real *anorm, real *rcond, - complex *work, real *rwork, integer *info); +/* Subroutine */ int cppcon_(char *uplo, integer *n, complex *ap, real *anorm, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int cppequ_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, - integer *info); +/* Subroutine */ int cppequ_(char *uplo, integer *n, complex *ap, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int cpprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, - complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, - real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cpprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork, + integer *info); -/* Subroutine */ int cppsv_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *b, - integer *ldb, integer *info); +/* Subroutine */ int cppsv_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, char *equed, real *s, complex *b, integer *ldb, - complex *x, integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, real *rwork, integer *info); +/* Subroutine */ int cppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, char *equed, real *s, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, + real *ferr, real *berr, complex *work, real *rwork, integer *info); /* Subroutine */ int cpptrf_(char *uplo, integer *n, complex *ap, integer *info); /* Subroutine */ int cpptri_(char *uplo, integer *n, complex *ap, integer *info); -/* Subroutine */ int cpptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *b, - integer *ldb, integer *info); +/* Subroutine */ int cpptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cpstf2_(char *uplo, integer *n, complex *a, integer *lda, integer *piv, - integer *rank, real *tol, real *work, integer *info); +/* Subroutine */ int cpstf2_(char *uplo, integer *n, complex *a, integer *lda, integer *piv, integer *rank, real *tol, real *work, integer *info); -/* Subroutine */ int cpstrf_(char *uplo, integer *n, complex *a, integer *lda, integer *piv, - integer *rank, real *tol, real *work, integer *info); +/* Subroutine */ int cpstrf_(char *uplo, integer *n, complex *a, integer *lda, integer *piv, integer *rank, real *tol, real *work, integer *info); -/* Subroutine */ int cptcon_(integer *n, real *d__, complex *e, real *anorm, real *rcond, - real *rwork, integer *info); +/* Subroutine */ int cptcon_(integer *n, real *d__, complex *e, real *anorm, real *rcond, real *rwork, integer *info); -/* Subroutine */ int cpteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, real *work, integer *info); +/* Subroutine */ int cpteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int cptrfs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, real *df, - complex *ef, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int cptrfs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, real *df, complex *ef, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, + complex *work, real *rwork, integer *info); -/* Subroutine */ int cptsv_(integer *n, integer *nrhs, real *d__, complex *e, complex *b, - integer *ldb, integer *info); +/* Subroutine */ int cptsv_(integer *n, integer *nrhs, real *d__, complex *e, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cptsvx_(char *fact, integer *n, integer *nrhs, real *d__, complex *e, real *df, - complex *ef, complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *ferr, real *berr, complex *work, real *rwork, - integer *info); +/* Subroutine */ int cptsvx_(char *fact, integer *n, integer *nrhs, real *d__, complex *e, real *df, complex *ef, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, + real *berr, complex *work, real *rwork, integer *info); /* Subroutine */ int cpttrf_(integer *n, real *d__, complex *e, integer *info); -/* Subroutine */ int cpttrs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cpttrs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cptts2_(integer *iuplo, integer *n, integer *nrhs, real *d__, complex *e, - complex *b, integer *ldb); +/* Subroutine */ int cptts2_(integer *iuplo, integer *n, integer *nrhs, real *d__, complex *e, complex *b, integer *ldb); -/* Subroutine */ int crot_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, - real *c__, complex *s); +/* Subroutine */ int crot_(integer *n, complex *cx, integer *incx, complex *cy, integer *incy, real *c__, complex *s); -/* Subroutine */ int cspcon_(char *uplo, integer *n, complex *ap, integer *ipiv, real *anorm, - real *rcond, complex *work, integer *info); +/* Subroutine */ int cspcon_(char *uplo, integer *n, complex *ap, integer *ipiv, real *anorm, real *rcond, complex *work, integer *info); -/* Subroutine */ int cspmv_(char *uplo, integer *n, complex *alpha, complex *ap, complex *x, - integer *incx, complex *beta, complex *y, integer *incy); +/* Subroutine */ int cspmv_(char *uplo, integer *n, complex *alpha, complex *ap, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int cspr_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, - complex *ap); +/* Subroutine */ int cspr_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, complex *ap); -/* Subroutine */ int csprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, - integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int csprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, + real *rwork, integer *info); -/* Subroutine */ int cspsv_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int cspsv_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int cspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *ap, complex *afp, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, + real *berr, complex *work, real *rwork, integer *info); /* Subroutine */ int csptrf_(char *uplo, integer *n, complex *ap, integer *ipiv, integer *info); -/* Subroutine */ int csptri_(char *uplo, integer *n, complex *ap, integer *ipiv, complex *work, - integer *info); +/* Subroutine */ int csptri_(char *uplo, integer *n, complex *ap, integer *ipiv, complex *work, integer *info); -/* Subroutine */ int csptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, - complex *b, integer *ldb, integer *info); +/* Subroutine */ int csptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, integer *ipiv, complex *b, integer *ldb, integer *info); /* Subroutine */ int csrscl_(integer *n, real *sa, complex *sx, integer *incx); -/* Subroutine */ int cstedc_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); - -/* Subroutine */ int cstegr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, integer *isuppz, real *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); - -/* Subroutine */ int cstein_(integer *n, real *d__, real *e, integer *m, real *w, integer *iblock, - integer *isplit, complex *z__, integer *ldz, real *work, - integer *iwork, integer *ifail, integer *info); - -/* Subroutine */ int cstemr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, integer *m, real *w, complex *z__, - integer *ldz, integer *nzc, integer *isuppz, logical *tryrac, - real *work, integer *lwork, integer *iwork, integer *liwork, +/* Subroutine */ int cstedc_(char *compz, integer *n, real *d__, real *e, complex *z__, integer *ldz, complex *work, integer *lwork, real *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int csteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, real *work, integer *info); - -/* Subroutine */ int csycon_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - real *anorm, real *rcond, complex *work, integer *info); +/* Subroutine */ int cstegr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, complex *z__, integer *ldz, + integer *isuppz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int csyequb_(char *uplo, integer *n, complex *a, integer *lda, real *s, - real *scond, real *amax, complex *work, integer *info); +/* Subroutine */ int cstein_(integer *n, real *d__, real *e, integer *m, real *w, integer *iblock, integer *isplit, complex *z__, integer *ldz, real *work, integer *iwork, integer *ifail, + integer *info); -/* Subroutine */ int csymv_(char *uplo, integer *n, complex *alpha, complex *a, integer *lda, - complex *x, integer *incx, complex *beta, complex *y, integer *incy); +/* Subroutine */ int cstemr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, integer *m, real *w, complex *z__, integer *ldz, integer *nzc, + integer *isuppz, logical *tryrac, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int csyr_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, - complex *a, integer *lda); +/* Subroutine */ int csteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int csyrfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int csycon_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, real *anorm, real *rcond, complex *work, integer *info); -/* Subroutine */ int csyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, real *s, - complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, - real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, complex *work, - real *rwork, integer *info); +/* Subroutine */ int csyequb_(char *uplo, integer *n, complex *a, integer *lda, real *s, real *scond, real *amax, complex *work, integer *info); -/* Subroutine */ int csysv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int csymv_(char *uplo, integer *n, complex *alpha, complex *a, integer *lda, complex *x, integer *incx, complex *beta, complex *y, integer *incy); -/* Subroutine */ int csysvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, - real *berr, complex *work, integer *lwork, real *rwork, integer *info); +/* Subroutine */ int csyr_(char *uplo, integer *n, complex *alpha, complex *x, integer *incx, complex *a, integer *lda); -/* Subroutine */ int csysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, - real *s, complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, complex *work, real *rwork, integer *info); +/* Subroutine */ int csyrfs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, + real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int csytf2_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int csyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, real *s, complex *b, integer *ldb, complex *x, + integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, complex *work, real *rwork, + integer *info); -/* Subroutine */ int csytrf_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int csysv_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, complex *work, integer *lwork, integer *info); -/* Subroutine */ int csytri_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, - complex *work, integer *info); +/* Subroutine */ int csysvx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, complex *b, integer *ldb, complex *x, integer *ldx, + real *rcond, real *ferr, real *berr, complex *work, integer *lwork, real *rwork, integer *info); -/* Subroutine */ int csytrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, integer *info); +/* Subroutine */ int csysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *ipiv, char *equed, real *s, complex *b, integer *ldb, + complex *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, + complex *work, real *rwork, integer *info); -/* Subroutine */ int ctbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - complex *ab, integer *ldab, real *rcond, complex *work, real *rwork, - integer *info); +/* Subroutine */ int csytf2_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int ctbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info); +/* Subroutine */ int csytrf_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, complex *work, integer *lwork, integer *info); -/* Subroutine */ int ctbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, - integer *info); +/* Subroutine */ int csytri_(char *uplo, integer *n, complex *a, integer *lda, integer *ipiv, complex *work, integer *info); -/* Subroutine */ int ctfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, - integer *m, integer *n, complex *alpha, complex *a, complex *b, - integer *ldb); +/* Subroutine */ int csytrs_(char *uplo, integer *n, integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer *info); -/* Subroutine */ int ctftri_(char *transr, char *uplo, char *diag, integer *n, complex *a, - integer *info); +/* Subroutine */ int ctbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, complex *ab, integer *ldab, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int ctfttp_(char *transr, char *uplo, integer *n, complex *arf, complex *ap, - integer *info); +/* Subroutine */ int ctbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, + real *berr, complex *work, real *rwork, integer *info); -/* Subroutine */ int ctfttr_(char *transr, char *uplo, integer *n, complex *arf, complex *a, - integer *lda, integer *info); +/* Subroutine */ int ctbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *ldb, integer *info); -/* Subroutine */ int ctgevc_(char *side, char *howmny, logical *select, integer *n, complex *s, - integer *lds, complex *p, integer *ldp, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, integer *mm, integer *m, complex *work, - real *rwork, integer *info); +/* Subroutine */ int ctfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, integer *m, integer *n, complex *alpha, complex *a, complex *b, integer *ldb); -/* Subroutine */ int ctgex2_(logical *wantq, logical *wantz, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *q, integer *ldq, complex *z__, - integer *ldz, integer *j1, integer *info); +/* Subroutine */ int ctftri_(char *transr, char *uplo, char *diag, integer *n, complex *a, integer *info); -/* Subroutine */ int ctgexc_(logical *wantq, logical *wantz, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *q, integer *ldq, complex *z__, - integer *ldz, integer *ifst, integer *ilst, integer *info); +/* Subroutine */ int ctfttp_(char *transr, char *uplo, integer *n, complex *arf, complex *ap, integer *info); -/* Subroutine */ int ctgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, - integer *n, complex *a, integer *lda, complex *b, integer *ldb, - complex *alpha, complex *beta, complex *q, integer *ldq, complex *z__, - integer *ldz, integer *m, real *pl, real *pr, real *dif, complex *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int ctfttr_(char *transr, char *uplo, integer *n, complex *arf, complex *a, integer *lda, integer *info); -/* Subroutine */ int ctgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - integer *k, integer *l, complex *a, integer *lda, complex *b, - integer *ldb, real *tola, real *tolb, real *alpha, real *beta, - complex *u, integer *ldu, complex *v, integer *ldv, complex *q, - integer *ldq, complex *work, integer *ncycle, integer *info); +/* Subroutine */ int ctgevc_(char *side, char *howmny, logical *select, integer *n, complex *s, integer *lds, complex *p, integer *ldp, complex *vl, integer *ldvl, complex *vr, integer *ldvr, + integer *mm, integer *m, complex *work, real *rwork, integer *info); -/* Subroutine */ int ctgsna_(char *job, char *howmny, logical *select, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, real *s, real *dif, integer *mm, - integer *m, complex *work, integer *lwork, integer *iwork, +/* Subroutine */ int ctgex2_(logical *wantq, logical *wantz, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *q, integer *ldq, complex *z__, integer *ldz, integer *j1, integer *info); -/* Subroutine */ int ctgsy2_(char *trans, integer *ijob, integer *m, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, - complex *d__, integer *ldd, complex *e, integer *lde, complex *f, - integer *ldf, real *scale, real *rdsum, real *rdscal, integer *info); - -/* Subroutine */ int ctgsyl_(char *trans, integer *ijob, integer *m, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, - complex *d__, integer *ldd, complex *e, integer *lde, complex *f, - integer *ldf, real *scale, real *dif, complex *work, integer *lwork, - integer *iwork, integer *info); +/* Subroutine */ int ctgexc_(logical *wantq, logical *wantz, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *q, integer *ldq, complex *z__, integer *ldz, integer *ifst, + integer *ilst, integer *info); -/* Subroutine */ int ctpcon_(char *norm, char *uplo, char *diag, integer *n, complex *ap, - real *rcond, complex *work, real *rwork, integer *info); +/* Subroutine */ int ctgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *alpha, complex *beta, complex *q, + integer *ldq, complex *z__, integer *ldz, integer *m, real *pl, real *pr, real *dif, complex *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ctprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - complex *ap, complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, integer *info); +/* Subroutine */ int ctgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, integer *k, integer *l, complex *a, integer *lda, complex *b, integer *ldb, real *tola, real *tolb, + real *alpha, real *beta, complex *u, integer *ldu, complex *v, integer *ldv, complex *q, integer *ldq, complex *work, integer *ncycle, integer *info); -/* Subroutine */ int ctptri_(char *uplo, char *diag, integer *n, complex *ap, integer *info); +/* Subroutine */ int ctgsna_(char *job, char *howmny, logical *select, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *vl, integer *ldvl, complex *vr, integer *ldvr, real *s, + real *dif, integer *mm, integer *m, complex *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int ctptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - complex *ap, complex *b, integer *ldb, integer *info); +/* Subroutine */ int ctgsy2_(char *trans, integer *ijob, integer *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, complex *d__, integer *ldd, complex *e, + integer *lde, complex *f, integer *ldf, real *scale, real *rdsum, real *rdscal, integer *info); -/* Subroutine */ int ctpttf_(char *transr, char *uplo, integer *n, complex *ap, complex *arf, - integer *info); +/* Subroutine */ int ctgsyl_(char *trans, integer *ijob, integer *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, complex *d__, integer *ldd, complex *e, + integer *lde, complex *f, integer *ldf, real *scale, real *dif, complex *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int ctpttr_(char *uplo, integer *n, complex *ap, complex *a, integer *lda, - integer *info); +/* Subroutine */ int ctpcon_(char *norm, char *uplo, char *diag, integer *n, complex *ap, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int ctrcon_(char *norm, char *uplo, char *diag, integer *n, complex *a, - integer *lda, real *rcond, complex *work, real *rwork, integer *info); +/* Subroutine */ int ctprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, complex *ap, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, + real *rwork, integer *info); -/* Subroutine */ int ctrevc_(char *side, char *howmny, logical *select, integer *n, complex *t, - integer *ldt, complex *vl, integer *ldvl, complex *vr, integer *ldvr, - integer *mm, integer *m, complex *work, real *rwork, integer *info); +/* Subroutine */ int ctptri_(char *uplo, char *diag, integer *n, complex *ap, integer *info); -/* Subroutine */ int ctrexc_(char *compq, integer *n, complex *t, integer *ldt, complex *q, - integer *ldq, integer *ifst, integer *ilst, integer *info); +/* Subroutine */ int ctptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, complex *ap, complex *b, integer *ldb, integer *info); -/* Subroutine */ int ctrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - complex *a, integer *lda, complex *b, integer *ldb, complex *x, - integer *ldx, real *ferr, real *berr, complex *work, real *rwork, - integer *info); +/* Subroutine */ int ctpttf_(char *transr, char *uplo, integer *n, complex *ap, complex *arf, integer *info); -/* Subroutine */ int ctrsen_(char *job, char *compq, logical *select, integer *n, complex *t, - integer *ldt, complex *q, integer *ldq, complex *w, integer *m, - real *s, real *sep, complex *work, integer *lwork, integer *info); +/* Subroutine */ int ctpttr_(char *uplo, integer *n, complex *ap, complex *a, integer *lda, integer *info); -/* Subroutine */ int ctrsna_(char *job, char *howmny, logical *select, integer *n, complex *t, - integer *ldt, complex *vl, integer *ldvl, complex *vr, integer *ldvr, - real *s, real *sep, integer *mm, integer *m, complex *work, - integer *ldwork, real *rwork, integer *info); +/* Subroutine */ int ctrcon_(char *norm, char *uplo, char *diag, integer *n, complex *a, integer *lda, real *rcond, complex *work, real *rwork, integer *info); -/* Subroutine */ int ctrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, complex *c__, - integer *ldc, real *scale, integer *info); +/* Subroutine */ int ctrevc_(char *side, char *howmny, logical *select, integer *n, complex *t, integer *ldt, complex *vl, integer *ldvl, complex *vr, integer *ldvr, integer *mm, integer *m, + complex *work, real *rwork, integer *info); -/* Subroutine */ int ctrti2_(char *uplo, char *diag, integer *n, complex *a, integer *lda, - integer *info); +/* Subroutine */ int ctrexc_(char *compq, integer *n, complex *t, integer *ldt, complex *q, integer *ldq, integer *ifst, integer *ilst, integer *info); -/* Subroutine */ int ctrtri_(char *uplo, char *diag, integer *n, complex *a, integer *lda, - integer *info); +/* Subroutine */ int ctrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, + complex *work, real *rwork, integer *info); -/* Subroutine */ int ctrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - complex *a, integer *lda, complex *b, integer *ldb, integer *info); +/* Subroutine */ int ctrsen_(char *job, char *compq, logical *select, integer *n, complex *t, integer *ldt, complex *q, integer *ldq, complex *w, integer *m, real *s, real *sep, complex *work, + integer *lwork, integer *info); -/* Subroutine */ int ctrttf_(char *transr, char *uplo, integer *n, complex *a, integer *lda, - complex *arf, integer *info); +/* Subroutine */ int ctrsna_(char *job, char *howmny, logical *select, integer *n, complex *t, integer *ldt, complex *vl, integer *ldvl, complex *vr, integer *ldvr, real *s, real *sep, integer *mm, + integer *m, complex *work, integer *ldwork, real *rwork, integer *info); -/* Subroutine */ int ctrttp_(char *uplo, integer *n, complex *a, integer *lda, complex *ap, +/* Subroutine */ int ctrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *c__, integer *ldc, real *scale, integer *info); -/* Subroutine */ int ctzrqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - integer *info); +/* Subroutine */ int ctrti2_(char *uplo, char *diag, integer *n, complex *a, integer *lda, integer *info); -/* Subroutine */ int ctzrzf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int ctrtri_(char *uplo, char *diag, integer *n, complex *a, integer *lda, integer *info); -/* Subroutine */ int cung2l_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); +/* Subroutine */ int ctrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, complex *a, integer *lda, complex *b, integer *ldb, integer *info); -/* Subroutine */ int cung2r_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); +/* Subroutine */ int ctrttf_(char *transr, char *uplo, integer *n, complex *a, integer *lda, complex *arf, integer *info); -/* Subroutine */ int cungbr_(char *vect, integer *m, integer *n, integer *k, complex *a, - integer *lda, complex *tau, complex *work, integer *lwork, - integer *info); +/* Subroutine */ int ctrttp_(char *uplo, integer *n, complex *a, integer *lda, complex *ap, integer *info); -/* Subroutine */ int cunghr_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int ctzrqf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, integer *info); -/* Subroutine */ int cungl2_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); +/* Subroutine */ int ctzrzf_(integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunglq_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cung2l_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cungql_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cung2r_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cungqr_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cungbr_(char *vect, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cungr2_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); +/* Subroutine */ int cunghr_(integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cungrq_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cungl2_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cungtr_(char *uplo, integer *n, complex *a, integer *lda, complex *tau, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunglq_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *info); +/* Subroutine */ int cungql_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *info); +/* Subroutine */ int cungqr_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cungr2_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *info); -/* Subroutine */ int cunmhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, - integer *ihi, complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cungrq_(integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunml2_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *info); +/* Subroutine */ int cungtr_(char *uplo, integer *n, complex *a, integer *lda, complex *tau, complex *work, integer *lwork, integer *info); -/* Subroutine */ int cunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); -/* Subroutine */ int cunmql_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); -/* Subroutine */ int cunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, + integer *info); -/* Subroutine */ int cunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *info); +/* Subroutine */ int cunmhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, integer *ihi, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, + integer *lwork, integer *info); -/* Subroutine */ int cunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *info); +/* Subroutine */ int cunml2_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); -/* Subroutine */ int cunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, + integer *info); + +/* Subroutine */ int cunmql_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, + integer *info); -/* Subroutine */ int cunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, + integer *info); -/* Subroutine */ int cunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, - complex *work, integer *lwork, integer *info); +/* Subroutine */ int cunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); -/* Subroutine */ int cupgtr_(char *uplo, integer *n, complex *ap, complex *tau, complex *q, - integer *ldq, complex *work, integer *info); +/* Subroutine */ int cunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); -/* Subroutine */ int cupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - complex *ap, complex *tau, complex *c__, integer *ldc, complex *work, +/* Subroutine */ int cunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, integer *info); -/* Subroutine */ int dbdsdc_(char *uplo, char *compq, integer *n, doublereal *d__, doublereal *e, - doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, - doublereal *q, integer *iq, doublereal *work, integer *iwork, +/* Subroutine */ int cunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, integer *info); -/* Subroutine */ int dbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, - doublereal *d__, doublereal *e, doublereal *vt, integer *ldvt, - doublereal *u, integer *ldu, doublereal *c__, integer *ldc, - doublereal *work, integer *info); - -/* Subroutine */ int ddisna_(char *job, integer *m, integer *n, doublereal *d__, doublereal *sep, +/* Subroutine */ int cunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, complex *a, integer *lda, complex *tau, complex *c__, integer *ldc, complex *work, integer *lwork, integer *info); -/* Subroutine */ int dgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, - integer *ku, doublereal *ab, integer *ldab, doublereal *d__, - doublereal *e, doublereal *q, integer *ldq, doublereal *pt, - integer *ldpt, doublereal *c__, integer *ldc, doublereal *work, - integer *info); +/* Subroutine */ int cupgtr_(char *uplo, integer *n, complex *ap, complex *tau, complex *q, integer *ldq, complex *work, integer *info); -/* Subroutine */ int dgbcon_(char *norm, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, integer *ipiv, doublereal *anorm, doublereal *rcond, +/* Subroutine */ int cupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, complex *ap, complex *tau, complex *c__, integer *ldc, complex *work, integer *info); + +/* Subroutine */ int dbdsdc_(char *uplo, char *compq, integer *n, doublereal *d__, doublereal *e, doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, doublereal *q, integer *iq, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgbequ_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int dbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, doublereal *d__, doublereal *e, doublereal *vt, integer *ldvt, doublereal *u, integer *ldu, + doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dgbequb_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int ddisna_(char *job, integer *m, integer *n, doublereal *d__, doublereal *sep, integer *info); -/* Subroutine */ int dgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, - integer *ipiv, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *d__, doublereal *e, doublereal *q, integer *ldq, + doublereal *pt, integer *ldpt, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, - integer *ldafb, integer *ipiv, doublereal *r__, doublereal *c__, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dgbcon_(char *norm, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, + integer *info); -/* Subroutine */ int dgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, - integer *ldab, integer *ipiv, doublereal *b, integer *ldb, - integer *info); +/* Subroutine */ int dgbequ_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, + doublereal *amax, integer *info); -/* Subroutine */ int dgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, - integer *ldafb, integer *ipiv, char *equed, doublereal *r__, - doublereal *c__, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgbequb_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, + doublereal *amax, integer *info); -/* Subroutine */ int dgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, - integer *ldafb, integer *ipiv, char *equed, doublereal *r__, - doublereal *c__, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, doublereal *b, + integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgbtf2_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int dgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, + doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgbtrf_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int dgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - doublereal *ab, integer *ldab, integer *ipiv, doublereal *b, - integer *ldb, integer *info); +/* Subroutine */ int dgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, char *equed, + doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, + integer *iwork, integer *info); -/* Subroutine */ int dgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - doublereal *scale, integer *m, doublereal *v, integer *ldv, - integer *info); +/* Subroutine */ int dgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, char *equed, + doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, + integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgebal_(char *job, integer *n, doublereal *a, integer *lda, integer *ilo, - integer *ihi, doublereal *scale, integer *info); +/* Subroutine */ int dgbtf2_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int dgebd2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *d__, - doublereal *e, doublereal *tauq, doublereal *taup, doublereal *work, - integer *info); +/* Subroutine */ int dgbtrf_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int dgebrd_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *d__, - doublereal *e, doublereal *tauq, doublereal *taup, doublereal *work, - integer *lwork, integer *info); +/* Subroutine */ int dgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dgecon_(char *norm, integer *n, doublereal *a, integer *lda, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, doublereal *scale, integer *m, doublereal *v, integer *ldv, integer *info); -/* Subroutine */ int dgeequ_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, integer *info); +/* Subroutine */ int dgebal_(char *job, integer *n, doublereal *a, integer *lda, integer *ilo, integer *ihi, doublereal *scale, integer *info); -/* Subroutine */ int dgeequb_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, integer *info); +/* Subroutine */ int dgebd2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq, doublereal *taup, doublereal *work, integer *info); -/* Subroutine */ int dgees_(char *jobvs, char *sort, L_fp select, integer *n, doublereal *a, - integer *lda, integer *sdim, doublereal *wr, doublereal *wi, - doublereal *vs, integer *ldvs, doublereal *work, integer *lwork, - logical *bwork, integer *info); +/* Subroutine */ int dgebrd_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq, doublereal *taup, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, - doublereal *a, integer *lda, integer *sdim, doublereal *wr, - doublereal *wi, doublereal *vs, integer *ldvs, doublereal *rconde, - doublereal *rcondv, doublereal *work, integer *lwork, integer *iwork, - integer *liwork, logical *bwork, integer *info); +/* Subroutine */ int dgecon_(char *norm, integer *n, doublereal *a, integer *lda, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgeev_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, - doublereal *wr, doublereal *wi, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dgeequ_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, integer *info); -/* Subroutine */ int dgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - doublereal *a, integer *lda, doublereal *wr, doublereal *wi, - doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, - integer *ilo, integer *ihi, doublereal *scale, doublereal *abnrm, - doublereal *rconde, doublereal *rcondv, doublereal *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int dgeequb_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, integer *info); -/* Subroutine */ int dgegs_(char *jobvsl, char *jobvsr, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, - doublereal *beta, doublereal *vsl, integer *ldvsl, doublereal *vsr, - integer *ldvsr, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgees_(char *jobvs, char *sort, L_fp select, integer *n, doublereal *a, integer *lda, integer *sdim, doublereal *wr, doublereal *wi, doublereal *vs, integer *ldvs, + doublereal *work, integer *lwork, logical *bwork, integer *info); -/* Subroutine */ int dgegv_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, - doublereal *beta, doublereal *vl, integer *ldvl, doublereal *vr, - integer *ldvr, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, doublereal *a, integer *lda, integer *sdim, doublereal *wr, doublereal *wi, doublereal *vs, integer *ldvs, + doublereal *rconde, doublereal *rcondv, doublereal *work, integer *lwork, integer *iwork, integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int dgehd2_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dgeev_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, doublereal *wr, doublereal *wi, doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, + doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgehrd_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, doublereal *a, integer *lda, doublereal *wr, doublereal *wi, doublereal *vl, integer *ldvl, + doublereal *vr, integer *ldvr, integer *ilo, integer *ihi, doublereal *scale, doublereal *abnrm, doublereal *rconde, doublereal *rcondv, doublereal *work, integer *lwork, + integer *iwork, integer *info); -/* Subroutine */ int dgejsv_(char *joba, char *jobu, char *jobv, char *jobr, char *jobt, char *jobp, - integer *m, integer *n, doublereal *a, integer *lda, doublereal *sva, - doublereal *u, integer *ldu, doublereal *v, integer *ldv, - doublereal *work, integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int dgegs_(char *jobvsl, char *jobvsr, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, doublereal *beta, doublereal *vsl, + integer *ldvsl, doublereal *vsr, integer *ldvsr, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgelq2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *info); +/* Subroutine */ int dgegv_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, doublereal *beta, doublereal *vl, + integer *ldvl, doublereal *vr, integer *ldvr, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgelqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgehd2_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgels_(char *trans, integer *m, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *work, - integer *lwork, integer *info); +/* Subroutine */ int dgehrd_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgelsd_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *s, doublereal *rcond, - integer *rank, doublereal *work, integer *lwork, integer *iwork, - integer *info); +/* Subroutine */ int dgejsv_(char *joba, char *jobu, char *jobv, char *jobr, char *jobt, char *jobp, integer *m, integer *n, doublereal *a, integer *lda, doublereal *sva, doublereal *u, integer *ldu, + doublereal *v, integer *ldv, doublereal *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dgelss_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *s, doublereal *rcond, - integer *rank, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgelq2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgelsx_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *jpvt, doublereal *rcond, - integer *rank, doublereal *work, integer *info); +/* Subroutine */ int dgelqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgelsy_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *jpvt, doublereal *rcond, - integer *rank, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgels_(char *trans, integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgeql2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *info); +/* Subroutine */ int dgelsd_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *s, doublereal *rcond, integer *rank, doublereal *work, + integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dgeqlf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgelss_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *s, doublereal *rcond, integer *rank, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgeqp3_(integer *m, integer *n, doublereal *a, integer *lda, integer *jpvt, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgelsx_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *jpvt, doublereal *rcond, integer *rank, doublereal *work, + integer *info); -/* Subroutine */ int dgeqpf_(integer *m, integer *n, doublereal *a, integer *lda, integer *jpvt, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dgelsy_(integer *m, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *jpvt, doublereal *rcond, integer *rank, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgeqr2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *info); +/* Subroutine */ int dgeql2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgeqrf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgeqlf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgerfs_(char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, integer *ipiv, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgeqp3_(integer *m, integer *n, doublereal *a, integer *lda, integer *jpvt, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - doublereal *r__, doublereal *c__, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgeqpf_(integer *m, integer *n, doublereal *a, integer *lda, integer *jpvt, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgerq2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *info); +/* Subroutine */ int dgeqr2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgerqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgeqrf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgesc2_(integer *n, doublereal *a, integer *lda, doublereal *rhs, - integer *ipiv, integer *jpiv, doublereal *scale); +/* Subroutine */ int dgerfs_(char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgesdd_(char *jobz, integer *m, integer *n, doublereal *a, integer *lda, - doublereal *s, doublereal *u, integer *ldu, doublereal *vt, - integer *ldvt, doublereal *work, integer *lwork, integer *iwork, - integer *info); +/* Subroutine */ int dgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *r__, doublereal *c__, + doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, + doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dgerq2_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *s, doublereal *u, integer *ldu, - doublereal *vt, integer *ldvt, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dgerqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgesvj_(char *joba, char *jobu, char *jobv, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *sva, integer *mv, - doublereal *v, integer *ldv, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dgesc2_(integer *n, doublereal *a, integer *lda, doublereal *rhs, integer *ipiv, integer *jpiv, doublereal *scale); -/* Subroutine */ int dgesvx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *r__, doublereal *c__, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dgesdd_(char *jobz, integer *m, integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, doublereal *work, + integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *r__, doublereal *c__, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dgetc2_(integer *n, doublereal *a, integer *lda, integer *ipiv, integer *jpiv, - integer *info); +/* Subroutine */ int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int dgesvj_(char *joba, char *jobu, char *jobv, integer *m, integer *n, doublereal *a, integer *lda, doublereal *sva, integer *mv, doublereal *v, integer *ldv, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgetrf_(integer *m, integer *n, doublereal *a, integer *lda, integer *ipiv, +/* Subroutine */ int dgesvx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, + doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgetri_(integer *n, doublereal *a, integer *lda, integer *ipiv, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, + doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dgetrs_(char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, - integer *ipiv, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dgetc2_(integer *n, doublereal *a, integer *lda, integer *ipiv, integer *jpiv, integer *info); -/* Subroutine */ int dggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, integer *m, doublereal *v, - integer *ldv, integer *info); +/* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int dggbal_(char *job, integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, integer *ilo, integer *ihi, doublereal *lscale, - doublereal *rscale, doublereal *work, integer *info); +/* Subroutine */ int dgetrf_(integer *m, integer *n, doublereal *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int dgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *sdim, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *vsl, integer *ldvsl, doublereal *vsr, integer *ldvsr, - doublereal *work, integer *lwork, logical *bwork, integer *info); +/* Subroutine */ int dgetri_(integer *n, doublereal *a, integer *lda, integer *ipiv, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, - integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, - integer *sdim, doublereal *alphar, doublereal *alphai, - doublereal *beta, doublereal *vsl, integer *ldvsl, doublereal *vsr, - integer *ldvsr, doublereal *rconde, doublereal *rcondv, - doublereal *work, integer *lwork, integer *iwork, integer *liwork, - logical *bwork, integer *info); - -/* Subroutine */ int dggev_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, - doublereal *beta, doublereal *vl, integer *ldvl, doublereal *vr, - integer *ldvr, doublereal *work, integer *lwork, integer *info); - -/* Subroutine */ int dggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, - integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, - doublereal *abnrm, doublereal *bbnrm, doublereal *rconde, - doublereal *rcondv, doublereal *work, integer *lwork, integer *iwork, - logical *bwork, integer *info); - -/* Subroutine */ int dggglm_(integer *n, integer *m, integer *p, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *d__, doublereal *x, - doublereal *y, doublereal *work, integer *lwork, integer *info); - -/* Subroutine */ int dgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *q, integer *ldq, doublereal *z__, integer *ldz, +/* Subroutine */ int dgetrs_(char *trans, integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, integer *info); + +/* Subroutine */ int dggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, integer *m, doublereal *v, integer *ldv, integer *info); + +/* Subroutine */ int dggbal_(char *job, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, doublereal *work, integer *info); -/* Subroutine */ int dgglse_(integer *m, integer *n, integer *p, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *c__, doublereal *d__, - doublereal *x, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *sdim, doublereal *alphar, + doublereal *alphai, doublereal *beta, doublereal *vsl, integer *ldvsl, doublereal *vsr, integer *ldvsr, doublereal *work, integer *lwork, logical *bwork, integer *info); -/* Subroutine */ int dggqrf_(integer *n, integer *m, integer *p, doublereal *a, integer *lda, - doublereal *taua, doublereal *b, integer *ldb, doublereal *taub, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *sdim, doublereal *alphar, + doublereal *alphai, doublereal *beta, doublereal *vsl, integer *ldvsl, doublereal *vsr, integer *ldvsr, doublereal *rconde, doublereal *rcondv, doublereal *work, + integer *lwork, integer *iwork, integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int dggrqf_(integer *m, integer *p, integer *n, doublereal *a, integer *lda, - doublereal *taua, doublereal *b, integer *ldb, doublereal *taub, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dggev_(char *jobvl, char *jobvr, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, doublereal *beta, doublereal *vl, + integer *ldvl, doublereal *vr, integer *ldvr, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, - integer *k, integer *l, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *alpha, doublereal *beta, doublereal *u, - integer *ldu, doublereal *v, integer *ldv, doublereal *q, integer *ldq, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, + doublereal *beta, doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, doublereal *abnrm, + doublereal *bbnrm, doublereal *rconde, doublereal *rcondv, doublereal *work, integer *lwork, integer *iwork, logical *bwork, integer *info); -/* Subroutine */ int dggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *tola, doublereal *tolb, integer *k, integer *l, - doublereal *u, integer *ldu, doublereal *v, integer *ldv, - doublereal *q, integer *ldq, integer *iwork, doublereal *tau, - doublereal *work, integer *info); +/* Subroutine */ int dggglm_(integer *n, integer *m, integer *p, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *d__, doublereal *x, doublereal *y, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgsvj0_(char *jobv, integer *m, integer *n, doublereal *a, integer *lda, - doublereal *d__, doublereal *sva, integer *mv, doublereal *v, - integer *ldv, doublereal *eps, doublereal *sfmin, doublereal *tol, - integer *nsweep, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *q, integer *ldq, doublereal *z__, + integer *ldz, integer *info); -/* Subroutine */ int dgsvj1_(char *jobv, integer *m, integer *n, integer *n1, doublereal *a, - integer *lda, doublereal *d__, doublereal *sva, integer *mv, - doublereal *v, integer *ldv, doublereal *eps, doublereal *sfmin, - doublereal *tol, integer *nsweep, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dgglse_(integer *m, integer *n, integer *p, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *c__, doublereal *d__, doublereal *x, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dgtcon_(char *norm, integer *n, doublereal *dl, doublereal *d__, - doublereal *du, doublereal *du2, integer *ipiv, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dggqrf_(integer *n, integer *m, integer *p, doublereal *a, integer *lda, doublereal *taua, doublereal *b, integer *ldb, doublereal *taub, doublereal *work, integer *lwork, + integer *info); -/* Subroutine */ int dgtrfs_(char *trans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *dlf, doublereal *df, - doublereal *duf, doublereal *du2, integer *ipiv, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dggrqf_(integer *m, integer *p, integer *n, doublereal *a, integer *lda, doublereal *taua, doublereal *b, integer *ldb, doublereal *taub, doublereal *work, integer *lwork, + integer *info); -/* Subroutine */ int dgtsv_(integer *n, integer *nrhs, doublereal *dl, doublereal *d__, - doublereal *du, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, integer *k, integer *l, doublereal *a, integer *lda, doublereal *b, integer *ldb, + doublereal *alpha, doublereal *beta, doublereal *u, integer *ldu, doublereal *v, integer *ldv, doublereal *q, integer *ldq, doublereal *work, integer *iwork, + integer *info); -/* Subroutine */ int dgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *dlf, doublereal *df, - doublereal *duf, doublereal *du2, integer *ipiv, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, +/* Subroutine */ int dggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *tola, doublereal *tolb, + integer *k, integer *l, doublereal *u, integer *ldu, doublereal *v, integer *ldv, doublereal *q, integer *ldq, integer *iwork, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dgttrf_(integer *n, doublereal *dl, doublereal *d__, doublereal *du, - doublereal *du2, integer *ipiv, integer *info); +/* Subroutine */ int dgsvj0_(char *jobv, integer *m, integer *n, doublereal *a, integer *lda, doublereal *d__, doublereal *sva, integer *mv, doublereal *v, integer *ldv, doublereal *eps, + doublereal *sfmin, doublereal *tol, integer *nsweep, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgttrs_(char *trans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dgsvj1_(char *jobv, integer *m, integer *n, integer *n1, doublereal *a, integer *lda, doublereal *d__, doublereal *sva, integer *mv, doublereal *v, integer *ldv, doublereal *eps, + doublereal *sfmin, doublereal *tol, integer *nsweep, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dgtts2_(integer *itrans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, - doublereal *b, integer *ldb); +/* Subroutine */ int dgtcon_(char *norm, integer *n, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, + integer *iwork, integer *info); -/* Subroutine */ int dhgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, doublereal *h__, integer *ldh, doublereal *t, - integer *ldt, doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *q, integer *ldq, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dgtrfs_(char *trans, integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *dlf, doublereal *df, doublereal *duf, doublereal *du2, integer *ipiv, + doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dhsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, - doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, - doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, - integer *mm, integer *m, doublereal *work, integer *ifaill, - integer *ifailr, integer *info); +/* Subroutine */ int dgtsv_(integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dhseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, - doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, - doublereal *z__, integer *ldz, doublereal *work, integer *lwork, +/* Subroutine */ int dgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *dlf, doublereal *df, doublereal *duf, doublereal *du2, + integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dgttrf_(integer *n, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, integer *info); + +/* Subroutine */ int dgttrs_(char *trans, integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, doublereal *b, integer *ldb, integer *info); + +/* Subroutine */ int dgtts2_(integer *itrans, integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, doublereal *b, integer *ldb); + +/* Subroutine */ int dhgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal *t, integer *ldt, doublereal *alphar, + doublereal *alphai, doublereal *beta, doublereal *q, integer *ldq, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *info); + +/* Subroutine */ int dhsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, doublereal *vl, integer *ldvl, + doublereal *vr, integer *ldvr, integer *mm, integer *m, doublereal *work, integer *ifaill, integer *ifailr, integer *info); + +/* Subroutine */ int dhseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, doublereal *z__, integer *ldz, + doublereal *work, integer *lwork, integer *info); + logical disnan_(doublereal *din); -/* Subroutine */ int dla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, - doublereal *alpha, doublereal *ab, integer *ldab, doublereal *x, - integer *incx, doublereal *beta, doublereal *y, integer *incy); +/* Subroutine */ int dla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, doublereal *alpha, doublereal *ab, integer *ldab, doublereal *x, integer *incx, doublereal *beta, + doublereal *y, integer *incy); + +doublereal dla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, integer *cmode, doublereal *c__, + integer *info, doublereal *work, integer *iwork, ftnlen trans_len); + +/* Subroutine */ int dla_gbrfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, + integer *ldafb, integer *ipiv, logical *colequ, doublereal *c__, doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, + integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublereal *res, doublereal *ayb, doublereal *dy, doublereal *y_tail__, doublereal *rcond, + integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info); + +doublereal dla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb); + +/* Subroutine */ int dla_geamv__(integer *trans, integer *m, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -doublereal dla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, - integer *cmode, doublereal *c__, integer *info, doublereal *work, +doublereal dla_gercond__(char *trans, integer *n, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, integer *cmode, doublereal *c__, integer *info, doublereal *work, integer *iwork, ftnlen trans_len); -/* Subroutine */ int dla_gbrfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, integer *ipiv, logical *colequ, - doublereal *c__, doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, - integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublereal *res, doublereal *ayb, - doublereal *dy, doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, - doublereal *dz_ub__, logical *ignore_cwise__, integer *info); +/* Subroutine */ int dla_gerfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, + logical *colequ, doublereal *c__, doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, + doublereal *errs_c__, doublereal *res, doublereal *ayb, doublereal *dy, doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, + doublereal *dz_ub__, logical *ignore_cwise__, integer *info); -doublereal dla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, doublereal *ab, - integer *ldab, doublereal *afb, integer *ldafb); +/* Subroutine */ int dla_lin_berr__(integer *n, integer *nz, integer *nrhs, doublereal *res, doublereal *ayb, doublereal *berr); -/* Subroutine */ int dla_geamv__(integer *trans, integer *m, integer *n, doublereal *alpha, - doublereal *a, integer *lda, doublereal *x, integer *incx, - doublereal *beta, doublereal *y, integer *incy); +doublereal dla_porcond__(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *cmode, doublereal *c__, integer *info, doublereal *work, integer *iwork, + ftnlen uplo_len); -doublereal dla_gercond__(char *trans, integer *n, doublereal *a, integer *lda, doublereal *af, - integer *ldaf, integer *ipiv, integer *cmode, doublereal *c__, - integer *info, doublereal *work, integer *iwork, ftnlen trans_len); +/* Subroutine */ int dla_porfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, logical *colequ, doublereal *c__, + doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, + doublereal *res, doublereal *ayb, doublereal *dy, doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, + logical *ignore_cwise__, integer *info, ftnlen uplo_len); -/* Subroutine */ int dla_gerfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, logical *colequ, doublereal *c__, - doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, - integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublereal *res, doublereal *ayb, - doublereal *dy, doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, - doublereal *dz_ub__, logical *ignore_cwise__, integer *info); - -/* Subroutine */ int dla_lin_berr__(integer *n, integer *nz, integer *nrhs, doublereal *res, - doublereal *ayb, doublereal *berr); - -doublereal dla_porcond__(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *af, - integer *ldaf, integer *cmode, doublereal *c__, integer *info, - doublereal *work, integer *iwork, ftnlen uplo_len); - -/* Subroutine */ int dla_porfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, logical *colequ, doublereal *c__, doublereal *b, integer *ldb, - doublereal *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, - doublereal *errs_c__, doublereal *res, doublereal *ayb, doublereal *dy, doublereal *y_tail__, - doublereal *rcond, integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, - logical *ignore_cwise__, integer *info, ftnlen uplo_len); - -doublereal dla_porpvgrw__(char *uplo, integer *ncols, doublereal *a, integer *lda, doublereal *af, - integer *ldaf, doublereal *work, ftnlen uplo_len); - -doublereal dla_rpvgrw__(integer *n, integer *ncols, doublereal *a, integer *lda, doublereal *af, - integer *ldaf); - -/* Subroutine */ int dla_syamv__(integer *uplo, integer *n, doublereal *alpha, doublereal *a, - integer *lda, doublereal *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy); +doublereal dla_porpvgrw__(char *uplo, integer *ncols, doublereal *a, integer *lda, doublereal *af, integer *ldaf, doublereal *work, ftnlen uplo_len); -doublereal dla_syrcond__(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *af, - integer *ldaf, integer *ipiv, integer *cmode, doublereal *c__, - integer *info, doublereal *work, integer *iwork, ftnlen uplo_len); +doublereal dla_rpvgrw__(integer *n, integer *ncols, doublereal *a, integer *lda, doublereal *af, integer *ldaf); -/* Subroutine */ int dla_syrfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, integer *ipiv, logical *colequ, doublereal *c__, doublereal *b, - integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, - doublereal *errs_n__, doublereal *errs_c__, doublereal *res, doublereal *ayb, doublereal *dy, - doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, - doublereal *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); +/* Subroutine */ int dla_syamv__(integer *uplo, integer *n, doublereal *alpha, doublereal *a, integer *lda, doublereal *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -doublereal dla_syrpvgrw__(char *uplo, integer *n, integer *info, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, integer *ipiv, doublereal *work, - ftnlen uplo_len); +doublereal dla_syrcond__(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, integer *cmode, doublereal *c__, integer *info, doublereal *work, + integer *iwork, ftnlen uplo_len); + +/* Subroutine */ int dla_syrfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, logical *colequ, + doublereal *c__, doublereal *b, integer *ldb, doublereal *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, + doublereal *errs_c__, doublereal *res, doublereal *ayb, doublereal *dy, doublereal *y_tail__, doublereal *rcond, integer *ithresh, doublereal *rthresh, + doublereal *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); + +doublereal dla_syrpvgrw__(char *uplo, integer *n, integer *info, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *work, ftnlen uplo_len); /* Subroutine */ int dla_wwaddw__(integer *n, doublereal *x, doublereal *y, doublereal *w); /* Subroutine */ int dlabad_(doublereal *small, doublereal *large); -/* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, doublereal *a, integer *lda, - doublereal *d__, doublereal *e, doublereal *tauq, doublereal *taup, - doublereal *x, integer *ldx, doublereal *y, integer *ldy); - -/* Subroutine */ int dlacn2_(integer *n, doublereal *v, doublereal *x, integer *isgn, - doublereal *est, integer *kase, integer *isave); +/* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, doublereal *a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq, doublereal *taup, doublereal *x, integer *ldx, + doublereal *y, integer *ldy); -/* Subroutine */ int dlacon_(integer *n, doublereal *v, doublereal *x, integer *isgn, - doublereal *est, integer *kase); +/* Subroutine */ int dlacn2_(integer *n, doublereal *v, doublereal *x, integer *isgn, doublereal *est, integer *kase, integer *isave); -/* Subroutine */ int dlacpy_(char *uplo, integer *m, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb); +/* Subroutine */ int dlacon_(integer *n, doublereal *v, doublereal *x, integer *isgn, doublereal *est, integer *kase); -/* Subroutine */ int dladiv_(doublereal *a, doublereal *b, doublereal *c__, doublereal *d__, - doublereal *p, doublereal *q); +/* Subroutine */ int dlacpy_(char *uplo, integer *m, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb); -/* Subroutine */ int dlae2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *rt1, - doublereal *rt2); +/* Subroutine */ int dladiv_(doublereal *a, doublereal *b, doublereal *c__, doublereal *d__, doublereal *p, doublereal *q); -/* Subroutine */ int dlaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, - integer *minp, integer *nbmin, doublereal *abstol, doublereal *reltol, - doublereal *pivmin, doublereal *d__, doublereal *e, doublereal *e2, - integer *nval, doublereal *ab, doublereal *c__, integer *mout, - integer *nab, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dlae2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *rt1, doublereal *rt2); -/* Subroutine */ int dlaed0_(integer *icompq, integer *qsiz, integer *n, doublereal *d__, - doublereal *e, doublereal *q, integer *ldq, doublereal *qstore, - integer *ldqs, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dlaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, integer *minp, integer *nbmin, doublereal *abstol, doublereal *reltol, doublereal *pivmin, doublereal *d__, + doublereal *e, doublereal *e2, integer *nval, doublereal *ab, doublereal *c__, integer *mout, integer *nab, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlaed1_(integer *n, doublereal *d__, doublereal *q, integer *ldq, - integer *indxq, doublereal *rho, integer *cutpnt, doublereal *work, +/* Subroutine */ int dlaed0_(integer *icompq, integer *qsiz, integer *n, doublereal *d__, doublereal *e, doublereal *q, integer *ldq, doublereal *qstore, integer *ldqs, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlaed2_(integer *k, integer *n, integer *n1, doublereal *d__, doublereal *q, - integer *ldq, integer *indxq, doublereal *rho, doublereal *z__, - doublereal *dlamda, doublereal *w, doublereal *q2, integer *indx, - integer *indxc, integer *indxp, integer *coltyp, integer *info); +/* Subroutine */ int dlaed1_(integer *n, doublereal *d__, doublereal *q, integer *ldq, integer *indxq, doublereal *rho, integer *cutpnt, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlaed3_(integer *k, integer *n, integer *n1, doublereal *d__, doublereal *q, - integer *ldq, doublereal *rho, doublereal *dlamda, doublereal *q2, - integer *indx, integer *ctot, doublereal *w, doublereal *s, - integer *info); +/* Subroutine */ int dlaed2_(integer *k, integer *n, integer *n1, doublereal *d__, doublereal *q, integer *ldq, integer *indxq, doublereal *rho, doublereal *z__, doublereal *dlamda, doublereal *w, + doublereal *q2, integer *indx, integer *indxc, integer *indxp, integer *coltyp, integer *info); -/* Subroutine */ int dlaed4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *dlam, integer *info); +/* Subroutine */ int dlaed3_(integer *k, integer *n, integer *n1, doublereal *d__, doublereal *q, integer *ldq, doublereal *rho, doublereal *dlamda, doublereal *q2, integer *indx, integer *ctot, + doublereal *w, doublereal *s, integer *info); -/* Subroutine */ int dlaed5_(integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, - doublereal *rho, doublereal *dlam); +/* Subroutine */ int dlaed4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, doublereal *rho, doublereal *dlam, integer *info); -/* Subroutine */ int dlaed6_(integer *kniter, logical *orgati, doublereal *rho, doublereal *d__, - doublereal *z__, doublereal *finit, doublereal *tau, integer *info); +/* Subroutine */ int dlaed5_(integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, doublereal *rho, doublereal *dlam); -/* Subroutine */ int dlaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, doublereal *d__, doublereal *q, - integer *ldq, integer *indxq, doublereal *rho, integer *cutpnt, - doublereal *qstore, integer *qptr, integer *prmptr, integer *perm, - integer *givptr, integer *givcol, doublereal *givnum, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dlaed6_(integer *kniter, logical *orgati, doublereal *rho, doublereal *d__, doublereal *z__, doublereal *finit, doublereal *tau, integer *info); -/* Subroutine */ int dlaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, - doublereal *d__, doublereal *q, integer *ldq, integer *indxq, - doublereal *rho, integer *cutpnt, doublereal *z__, doublereal *dlamda, - doublereal *q2, integer *ldq2, doublereal *w, integer *perm, - integer *givptr, integer *givcol, doublereal *givnum, integer *indxp, - integer *indx, integer *info); +/* Subroutine */ int dlaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, integer *curlvl, integer *curpbm, doublereal *d__, doublereal *q, integer *ldq, integer *indxq, + doublereal *rho, integer *cutpnt, doublereal *qstore, integer *qptr, integer *prmptr, integer *perm, integer *givptr, integer *givcol, doublereal *givnum, + doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlaed9_(integer *k, integer *kstart, integer *kstop, integer *n, - doublereal *d__, doublereal *q, integer *ldq, doublereal *rho, - doublereal *dlamda, doublereal *w, doublereal *s, integer *lds, +/* Subroutine */ int dlaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, doublereal *d__, doublereal *q, integer *ldq, integer *indxq, doublereal *rho, integer *cutpnt, doublereal *z__, + doublereal *dlamda, doublereal *q2, integer *ldq2, doublereal *w, integer *perm, integer *givptr, integer *givcol, doublereal *givnum, integer *indxp, integer *indx, integer *info); -/* Subroutine */ int dlaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, - integer *prmptr, integer *perm, integer *givptr, integer *givcol, - doublereal *givnum, doublereal *q, integer *qptr, doublereal *z__, - doublereal *ztemp, integer *info); +/* Subroutine */ int dlaed9_(integer *k, integer *kstart, integer *kstop, integer *n, doublereal *d__, doublereal *q, integer *ldq, doublereal *rho, doublereal *dlamda, doublereal *w, doublereal *s, + integer *lds, integer *info); -/* Subroutine */ int dlaein_(logical *rightv, logical *noinit, integer *n, doublereal *h__, - integer *ldh, doublereal *wr, doublereal *wi, doublereal *vr, - doublereal *vi, doublereal *b, integer *ldb, doublereal *work, - doublereal *eps3, doublereal *smlnum, doublereal *bignum, - integer *info); +/* Subroutine */ int dlaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, integer *prmptr, integer *perm, integer *givptr, integer *givcol, doublereal *givnum, doublereal *q, + integer *qptr, doublereal *z__, doublereal *ztemp, integer *info); -/* Subroutine */ int dlaev2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *rt1, - doublereal *rt2, doublereal *cs1, doublereal *sn1); +/* Subroutine */ int dlaein_(logical *rightv, logical *noinit, integer *n, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, doublereal *vr, doublereal *vi, doublereal *b, integer *ldb, + doublereal *work, doublereal *eps3, doublereal *smlnum, doublereal *bignum, integer *info); -/* Subroutine */ int dlaexc_(logical *wantq, integer *n, doublereal *t, integer *ldt, doublereal *q, - integer *ldq, integer *j1, integer *n1, integer *n2, doublereal *work, - integer *info); +/* Subroutine */ int dlaev2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *rt1, doublereal *rt2, doublereal *cs1, doublereal *sn1); -/* Subroutine */ int dlag2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *safmin, doublereal *scale1, doublereal *scale2, - doublereal *wr1, doublereal *wr2, doublereal *wi); +/* Subroutine */ int dlaexc_(logical *wantq, integer *n, doublereal *t, integer *ldt, doublereal *q, integer *ldq, integer *j1, integer *n1, integer *n2, doublereal *work, integer *info); -/* Subroutine */ int dlag2s_(integer *m, integer *n, doublereal *a, integer *lda, real *sa, - integer *ldsa, integer *info); +/* Subroutine */ int dlag2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *safmin, doublereal *scale1, doublereal *scale2, doublereal *wr1, doublereal *wr2, doublereal *wi); -/* Subroutine */ int dlags2_(logical *upper, doublereal *a1, doublereal *a2, doublereal *a3, - doublereal *b1, doublereal *b2, doublereal *b3, doublereal *csu, - doublereal *snu, doublereal *csv, doublereal *snv, doublereal *csq, - doublereal *snq); +/* Subroutine */ int dlag2s_(integer *m, integer *n, doublereal *a, integer *lda, real *sa, integer *ldsa, integer *info); -/* Subroutine */ int dlagtf_(integer *n, doublereal *a, doublereal *lambda, doublereal *b, - doublereal *c__, doublereal *tol, doublereal *d__, integer *in, - integer *info); +/* Subroutine */ int dlags2_(logical *upper, doublereal *a1, doublereal *a2, doublereal *a3, doublereal *b1, doublereal *b2, doublereal *b3, doublereal *csu, doublereal *snu, doublereal *csv, + doublereal *snv, doublereal *csq, doublereal *snq); -/* Subroutine */ int dlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, - doublereal *dl, doublereal *d__, doublereal *du, doublereal *x, - integer *ldx, doublereal *beta, doublereal *b, integer *ldb); +/* Subroutine */ int dlagtf_(integer *n, doublereal *a, doublereal *lambda, doublereal *b, doublereal *c__, doublereal *tol, doublereal *d__, integer *in, integer *info); -/* Subroutine */ int dlagts_(integer *job, integer *n, doublereal *a, doublereal *b, - doublereal *c__, doublereal *d__, integer *in, doublereal *y, - doublereal *tol, integer *info); +/* Subroutine */ int dlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, doublereal *dl, doublereal *d__, doublereal *du, doublereal *x, integer *ldx, doublereal *beta, doublereal *b, + integer *ldb); -/* Subroutine */ int dlagv2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *csl, doublereal *snl, doublereal *csr, doublereal *snr); +/* Subroutine */ int dlagts_(integer *job, integer *n, doublereal *a, doublereal *b, doublereal *c__, doublereal *d__, integer *in, doublereal *y, doublereal *tol, integer *info); -/* Subroutine */ int dlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, - integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, - integer *info); +/* Subroutine */ int dlagv2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, doublereal *alphai, doublereal *beta, doublereal *csl, doublereal *snl, doublereal *csr, + doublereal *snr); -/* Subroutine */ int dlahr2_(integer *n, integer *k, integer *nb, doublereal *a, integer *lda, - doublereal *tau, doublereal *t, integer *ldt, doublereal *y, - integer *ldy); +/* Subroutine */ int dlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, integer *iloz, integer *ihiz, + doublereal *z__, integer *ldz, integer *info); -/* Subroutine */ int dlahrd_(integer *n, integer *k, integer *nb, doublereal *a, integer *lda, - doublereal *tau, doublereal *t, integer *ldt, doublereal *y, - integer *ldy); +/* Subroutine */ int dlahr2_(integer *n, integer *k, integer *nb, doublereal *a, integer *lda, doublereal *tau, doublereal *t, integer *ldt, doublereal *y, integer *ldy); -/* Subroutine */ int dlaic1_(integer *job, integer *j, doublereal *x, doublereal *sest, - doublereal *w, doublereal *gamma, doublereal *sestpr, doublereal *s, - doublereal *c__); +/* Subroutine */ int dlahrd_(integer *n, integer *k, integer *nb, doublereal *a, integer *lda, doublereal *tau, doublereal *t, integer *ldt, doublereal *y, integer *ldy); + +/* Subroutine */ int dlaic1_(integer *job, integer *j, doublereal *x, doublereal *sest, doublereal *w, doublereal *gamma, doublereal *sestpr, doublereal *s, doublereal *c__); logical dlaisnan_(doublereal *din1, doublereal *din2); -/* Subroutine */ int dlaln2_(logical *ltrans, integer *na, integer *nw, doublereal *smin, - doublereal *ca, doublereal *a, integer *lda, doublereal *d1, - doublereal *d2, doublereal *b, integer *ldb, doublereal *wr, - doublereal *wi, doublereal *x, integer *ldx, doublereal *scale, - doublereal *xnorm, integer *info); - -/* Subroutine */ int dlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, doublereal *b, integer *ldb, doublereal *bx, - integer *ldbx, integer *perm, integer *givptr, integer *givcol, - integer *ldgcol, doublereal *givnum, integer *ldgnum, - doublereal *poles, doublereal *difl, doublereal *difr, doublereal *z__, - integer *k, doublereal *c__, doublereal *s, doublereal *work, - integer *info); +/* Subroutine */ int dlaln2_(logical *ltrans, integer *na, integer *nw, doublereal *smin, doublereal *ca, doublereal *a, integer *lda, doublereal *d1, doublereal *d2, doublereal *b, integer *ldb, + doublereal *wr, doublereal *wi, doublereal *x, integer *ldx, doublereal *scale, doublereal *xnorm, integer *info); -/* Subroutine */ int dlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - doublereal *b, integer *ldb, doublereal *bx, integer *ldbx, - doublereal *u, integer *ldu, doublereal *vt, integer *k, - doublereal *difl, doublereal *difr, doublereal *z__, doublereal *poles, - integer *givptr, integer *givcol, integer *ldgcol, integer *perm, - doublereal *givnum, doublereal *c__, doublereal *s, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *nrhs, doublereal *b, integer *ldb, doublereal *bx, integer *ldbx, integer *perm, integer *givptr, + integer *givcol, integer *ldgcol, doublereal *givnum, integer *ldgnum, doublereal *poles, doublereal *difl, doublereal *difr, doublereal *z__, integer *k, doublereal *c__, + doublereal *s, doublereal *work, integer *info); -/* Subroutine */ int dlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - doublereal *d__, doublereal *e, doublereal *b, integer *ldb, - doublereal *rcond, integer *rank, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, doublereal *b, integer *ldb, doublereal *bx, integer *ldbx, doublereal *u, integer *ldu, doublereal *vt, + integer *k, doublereal *difl, doublereal *difr, doublereal *z__, doublereal *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, doublereal *givnum, + doublereal *c__, doublereal *s, doublereal *work, integer *iwork, integer *info); + +/* Subroutine */ int dlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *b, integer *ldb, doublereal *rcond, integer *rank, doublereal *work, + integer *iwork, integer *info); -/* Subroutine */ int dlamrg_(integer *n1, integer *n2, doublereal *a, integer *dtrd1, - integer *dtrd2, integer *index); +/* Subroutine */ int dlamrg_(integer *n1, integer *n2, doublereal *a, integer *dtrd1, integer *dtrd2, integer *index); -integer dlaneg_(integer *n, doublereal *d__, doublereal *lld, doublereal *sigma, doublereal *pivmin, - integer *r__); +integer dlaneg_(integer *n, doublereal *d__, doublereal *lld, doublereal *sigma, doublereal *pivmin, integer *r__); -doublereal dlangb_(char *norm, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, - doublereal *work); +doublereal dlangb_(char *norm, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *work); -doublereal dlange_(char *norm, integer *m, integer *n, doublereal *a, integer *lda, - doublereal *work); +doublereal dlange_(char *norm, integer *m, integer *n, doublereal *a, integer *lda, doublereal *work); doublereal dlangt_(char *norm, integer *n, doublereal *dl, doublereal *d__, doublereal *du); doublereal dlanhs_(char *norm, integer *n, doublereal *a, integer *lda, doublereal *work); -doublereal dlansb_(char *norm, char *uplo, integer *n, integer *k, doublereal *ab, integer *ldab, - doublereal *work); +doublereal dlansb_(char *norm, char *uplo, integer *n, integer *k, doublereal *ab, integer *ldab, doublereal *work); -doublereal dlansf_(char *norm, char *transr, char *uplo, integer *n, doublereal *a, - doublereal *work); +doublereal dlansf_(char *norm, char *transr, char *uplo, integer *n, doublereal *a, doublereal *work); doublereal dlansp_(char *norm, char *uplo, integer *n, doublereal *ap, doublereal *work); doublereal dlanst_(char *norm, integer *n, doublereal *d__, doublereal *e); -doublereal dlansy_(char *norm, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *work); +doublereal dlansy_(char *norm, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *work); -doublereal dlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, doublereal *ab, - integer *ldab, doublereal *work); +doublereal dlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, doublereal *ab, integer *ldab, doublereal *work); -doublereal dlantp_(char *norm, char *uplo, char *diag, integer *n, doublereal *ap, - doublereal *work); +doublereal dlantp_(char *norm, char *uplo, char *diag, integer *n, doublereal *ap, doublereal *work); -doublereal dlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *work); +doublereal dlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, doublereal *a, integer *lda, doublereal *work); -/* Subroutine */ int dlanv2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *d__, - doublereal *rt1r, doublereal *rt1i, doublereal *rt2r, doublereal *rt2i, - doublereal *cs, doublereal *sn); +/* Subroutine */ int dlanv2_(doublereal *a, doublereal *b, doublereal *c__, doublereal *d__, doublereal *rt1r, doublereal *rt1i, doublereal *rt2r, doublereal *rt2i, doublereal *cs, doublereal *sn); -/* Subroutine */ int dlapll_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, - doublereal *ssmin); +/* Subroutine */ int dlapll_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *ssmin); -/* Subroutine */ int dlapmt_(logical *forwrd, integer *m, integer *n, doublereal *x, integer *ldx, - integer *k); +/* Subroutine */ int dlapmt_(logical *forwrd, integer *m, integer *n, doublereal *x, integer *ldx, integer *k); doublereal dlapy2_(doublereal *x, doublereal *y); doublereal dlapy3_(doublereal *x, doublereal *y, doublereal *z__); -/* Subroutine */ int dlaqgb_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, char *equed); - -/* Subroutine */ int dlaqge_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, +/* Subroutine */ int dlaqgb_(integer *m, integer *n, integer *kl, integer *ku, doublereal *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, char *equed); -/* Subroutine */ int dlaqp2_(integer *m, integer *n, integer *offset, doublereal *a, integer *lda, - integer *jpvt, doublereal *tau, doublereal *vn1, doublereal *vn2, - doublereal *work); +/* Subroutine */ int dlaqge_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, char *equed); -/* Subroutine */ int dlaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, - doublereal *a, integer *lda, integer *jpvt, doublereal *tau, - doublereal *vn1, doublereal *vn2, doublereal *auxv, doublereal *f, - integer *ldf); +/* Subroutine */ int dlaqp2_(integer *m, integer *n, integer *offset, doublereal *a, integer *lda, integer *jpvt, doublereal *tau, doublereal *vn1, doublereal *vn2, doublereal *work); -/* Subroutine */ int dlaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, - integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dlaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, doublereal *a, integer *lda, integer *jpvt, doublereal *tau, doublereal *vn1, doublereal *vn2, + doublereal *auxv, doublereal *f, integer *ldf); -/* Subroutine */ int dlaqr1_(integer *n, doublereal *h__, integer *ldh, doublereal *sr1, - doublereal *si1, doublereal *sr2, doublereal *si2, doublereal *v); - -/* Subroutine */ int dlaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, doublereal *h__, integer *ldh, - integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, - integer *ns, integer *nd, doublereal *sr, doublereal *si, - doublereal *v, integer *ldv, integer *nh, doublereal *t, integer *ldt, - integer *nv, doublereal *wv, integer *ldwv, doublereal *work, - integer *lwork); - -/* Subroutine */ int dlaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, doublereal *h__, integer *ldh, - integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, - integer *ns, integer *nd, doublereal *sr, doublereal *si, - doublereal *v, integer *ldv, integer *nh, doublereal *t, integer *ldt, - integer *nv, doublereal *wv, integer *ldwv, doublereal *work, - integer *lwork); - -/* Subroutine */ int dlaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, - integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dlaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, integer *iloz, integer *ihiz, + doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dlaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, - integer *ktop, integer *kbot, integer *nshfts, doublereal *sr, - doublereal *si, doublereal *h__, integer *ldh, integer *iloz, - integer *ihiz, doublereal *z__, integer *ldz, doublereal *v, - integer *ldv, doublereal *u, integer *ldu, integer *nv, doublereal *wv, - integer *ldwv, integer *nh, doublereal *wh, integer *ldwh); +/* Subroutine */ int dlaqr1_(integer *n, doublereal *h__, integer *ldh, doublereal *sr1, doublereal *si1, doublereal *sr2, doublereal *si2, doublereal *v); -/* Subroutine */ int dlaqsb_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - doublereal *s, doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int dlaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, doublereal *h__, integer *ldh, integer *iloz, integer *ihiz, doublereal *z__, + integer *ldz, integer *ns, integer *nd, doublereal *sr, doublereal *si, doublereal *v, integer *ldv, integer *nh, doublereal *t, integer *ldt, integer *nv, doublereal *wv, + integer *ldwv, doublereal *work, integer *lwork); -/* Subroutine */ int dlaqsp_(char *uplo, integer *n, doublereal *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int dlaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, doublereal *h__, integer *ldh, integer *iloz, integer *ihiz, doublereal *z__, + integer *ldz, integer *ns, integer *nd, doublereal *sr, doublereal *si, doublereal *v, integer *ldv, integer *nh, doublereal *t, integer *ldt, integer *nv, doublereal *wv, + integer *ldwv, doublereal *work, integer *lwork); -/* Subroutine */ int dlaqsy_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int dlaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, doublereal *wi, integer *iloz, integer *ihiz, + doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dlaqtr_(logical *ltran, logical *lreal, integer *n, doublereal *t, - integer *ldt, doublereal *b, doublereal *w, doublereal *scale, - doublereal *x, doublereal *work, integer *info); +/* Subroutine */ int dlaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, integer *ktop, integer *kbot, integer *nshfts, doublereal *sr, doublereal *si, doublereal *h__, integer *ldh, + integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, doublereal *v, integer *ldv, doublereal *u, integer *ldu, integer *nv, doublereal *wv, integer *ldwv, + integer *nh, doublereal *wh, integer *ldwh); -/* Subroutine */ int dlar1v_(integer *n, integer *b1, integer *bn, doublereal *lambda, - doublereal *d__, doublereal *l, doublereal *ld, doublereal *lld, - doublereal *pivmin, doublereal *gaptol, doublereal *z__, - logical *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma, - integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid, +/* Subroutine */ int dlaqsb_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *s, doublereal *scond, doublereal *amax, char *equed); + +/* Subroutine */ int dlaqsp_(char *uplo, integer *n, doublereal *ap, doublereal *s, doublereal *scond, doublereal *amax, char *equed); + +/* Subroutine */ int dlaqsy_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, char *equed); + +/* Subroutine */ int dlaqtr_(logical *ltran, logical *lreal, integer *n, doublereal *t, integer *ldt, doublereal *b, doublereal *w, doublereal *scale, doublereal *x, doublereal *work, integer *info); + +/* Subroutine */ int dlar1v_(integer *n, integer *b1, integer *bn, doublereal *lambda, doublereal *d__, doublereal *l, doublereal *ld, doublereal *lld, doublereal *pivmin, doublereal *gaptol, + doublereal *z__, logical *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma, integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid, doublereal *rqcorr, doublereal *work); -/* Subroutine */ int dlar2v_(integer *n, doublereal *x, doublereal *y, doublereal *z__, - integer *incx, doublereal *c__, doublereal *s, integer *incc); +/* Subroutine */ int dlar2v_(integer *n, doublereal *x, doublereal *y, doublereal *z__, integer *incx, doublereal *c__, doublereal *s, integer *incc); -/* Subroutine */ int dlarf_(char *side, integer *m, integer *n, doublereal *v, integer *incv, - doublereal *tau, doublereal *c__, integer *ldc, doublereal *work); +/* Subroutine */ int dlarf_(char *side, integer *m, integer *n, doublereal *v, integer *incv, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work); -/* Subroutine */ int dlarfb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, doublereal *v, integer *ldv, doublereal *t, - integer *ldt, doublereal *c__, integer *ldc, doublereal *work, - integer *ldwork); +/* Subroutine */ int dlarfb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, doublereal *v, integer *ldv, doublereal *t, integer *ldt, doublereal *c__, + integer *ldc, doublereal *work, integer *ldwork); -/* Subroutine */ int dlarfg_(integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *tau); +/* Subroutine */ int dlarfg_(integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *tau); -/* Subroutine */ int dlarfp_(integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *tau); +/* Subroutine */ int dlarfp_(integer *n, doublereal *alpha, doublereal *x, integer *incx, doublereal *tau); -/* Subroutine */ int dlarft_(char *direct, char *storev, integer *n, integer *k, doublereal *v, - integer *ldv, doublereal *tau, doublereal *t, integer *ldt); +/* Subroutine */ int dlarft_(char *direct, char *storev, integer *n, integer *k, doublereal *v, integer *ldv, doublereal *tau, doublereal *t, integer *ldt); -/* Subroutine */ int dlarfx_(char *side, integer *m, integer *n, doublereal *v, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work); +/* Subroutine */ int dlarfx_(char *side, integer *m, integer *n, doublereal *v, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work); -/* Subroutine */ int dlargv_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, - doublereal *c__, integer *incc); +/* Subroutine */ int dlargv_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *c__, integer *incc); /* Subroutine */ int dlarnv_(integer *idist, integer *iseed, integer *n, doublereal *x); -/* Subroutine */ int dlarra_(integer *n, doublereal *d__, doublereal *e, doublereal *e2, - doublereal *spltol, doublereal *tnrm, integer *nsplit, integer *isplit, - integer *info); +/* Subroutine */ int dlarra_(integer *n, doublereal *d__, doublereal *e, doublereal *e2, doublereal *spltol, doublereal *tnrm, integer *nsplit, integer *isplit, integer *info); -/* Subroutine */ int dlarrb_(integer *n, doublereal *d__, doublereal *lld, integer *ifirst, - integer *ilast, doublereal *rtol1, doublereal *rtol2, integer *offset, - doublereal *w, doublereal *wgap, doublereal *werr, doublereal *work, - integer *iwork, doublereal *pivmin, doublereal *spdiam, integer *twist, - integer *info); +/* Subroutine */ int dlarrb_(integer *n, doublereal *d__, doublereal *lld, integer *ifirst, integer *ilast, doublereal *rtol1, doublereal *rtol2, integer *offset, doublereal *w, doublereal *wgap, + doublereal *werr, doublereal *work, integer *iwork, doublereal *pivmin, doublereal *spdiam, integer *twist, integer *info); -/* Subroutine */ int dlarrc_(char *jobt, integer *n, doublereal *vl, doublereal *vu, - doublereal *d__, doublereal *e, doublereal *pivmin, integer *eigcnt, - integer *lcnt, integer *rcnt, integer *info); +/* Subroutine */ int dlarrc_(char *jobt, integer *n, doublereal *vl, doublereal *vu, doublereal *d__, doublereal *e, doublereal *pivmin, integer *eigcnt, integer *lcnt, integer *rcnt, integer *info); -/* Subroutine */ int dlarrd_(char *range, char *order, integer *n, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *gers, doublereal *reltol, - doublereal *d__, doublereal *e, doublereal *e2, doublereal *pivmin, - integer *nsplit, integer *isplit, integer *m, doublereal *w, - doublereal *werr, doublereal *wl, doublereal *wu, integer *iblock, +/* Subroutine */ int dlarrd_(char *range, char *order, integer *n, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *gers, doublereal *reltol, doublereal *d__, doublereal *e, + doublereal *e2, doublereal *pivmin, integer *nsplit, integer *isplit, integer *m, doublereal *w, doublereal *werr, doublereal *wl, doublereal *wu, integer *iblock, integer *indexw, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlarre_(char *range, integer *n, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *d__, doublereal *e, doublereal *e2, - doublereal *rtol1, doublereal *rtol2, doublereal *spltol, - integer *nsplit, integer *isplit, integer *m, doublereal *w, - doublereal *werr, doublereal *wgap, integer *iblock, integer *indexw, - doublereal *gers, doublereal *pivmin, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dlarre_(char *range, integer *n, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *d__, doublereal *e, doublereal *e2, doublereal *rtol1, doublereal *rtol2, + doublereal *spltol, integer *nsplit, integer *isplit, integer *m, doublereal *w, doublereal *werr, doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers, + doublereal *pivmin, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlarrf_(integer *n, doublereal *d__, doublereal *l, doublereal *ld, - integer *clstrt, integer *clend, doublereal *w, doublereal *wgap, - doublereal *werr, doublereal *spdiam, doublereal *clgapl, - doublereal *clgapr, doublereal *pivmin, doublereal *sigma, - doublereal *dplus, doublereal *lplus, doublereal *work, integer *info); +/* Subroutine */ int dlarrf_(integer *n, doublereal *d__, doublereal *l, doublereal *ld, integer *clstrt, integer *clend, doublereal *w, doublereal *wgap, doublereal *werr, doublereal *spdiam, + doublereal *clgapl, doublereal *clgapr, doublereal *pivmin, doublereal *sigma, doublereal *dplus, doublereal *lplus, doublereal *work, integer *info); -/* Subroutine */ int dlarrj_(integer *n, doublereal *d__, doublereal *e2, integer *ifirst, - integer *ilast, doublereal *rtol, integer *offset, doublereal *w, - doublereal *werr, doublereal *work, integer *iwork, doublereal *pivmin, - doublereal *spdiam, integer *info); +/* Subroutine */ int dlarrj_(integer *n, doublereal *d__, doublereal *e2, integer *ifirst, integer *ilast, doublereal *rtol, integer *offset, doublereal *w, doublereal *werr, doublereal *work, + integer *iwork, doublereal *pivmin, doublereal *spdiam, integer *info); -/* Subroutine */ int dlarrk_(integer *n, integer *iw, doublereal *gl, doublereal *gu, - doublereal *d__, doublereal *e2, doublereal *pivmin, - doublereal *reltol, doublereal *w, doublereal *werr, integer *info); +/* Subroutine */ int dlarrk_(integer *n, integer *iw, doublereal *gl, doublereal *gu, doublereal *d__, doublereal *e2, doublereal *pivmin, doublereal *reltol, doublereal *w, doublereal *werr, + integer *info); /* Subroutine */ int dlarrr_(integer *n, doublereal *d__, doublereal *e, integer *info); -/* Subroutine */ int dlarrv_(integer *n, doublereal *vl, doublereal *vu, doublereal *d__, - doublereal *l, doublereal *pivmin, integer *isplit, integer *m, - integer *dol, integer *dou, doublereal *minrgp, doublereal *rtol1, - doublereal *rtol2, doublereal *w, doublereal *werr, doublereal *wgap, - integer *iblock, integer *indexw, doublereal *gers, doublereal *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dlarrv_(integer *n, doublereal *vl, doublereal *vu, doublereal *d__, doublereal *l, doublereal *pivmin, integer *isplit, integer *m, integer *dol, integer *dou, + doublereal *minrgp, doublereal *rtol1, doublereal *rtol2, doublereal *w, doublereal *werr, doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers, + doublereal *z__, integer *ldz, integer *isuppz, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlarscl2_(integer *m, integer *n, doublereal *d__, doublereal *x, - integer *ldx); +/* Subroutine */ int dlarscl2_(integer *m, integer *n, doublereal *d__, doublereal *x, integer *ldx); -/* Subroutine */ int dlartg_(doublereal *f, doublereal *g, doublereal *cs, doublereal *sn, - doublereal *r__); +/* Subroutine */ int dlartg_(doublereal *f, doublereal *g, doublereal *cs, doublereal *sn, doublereal *r__); -/* Subroutine */ int dlartv_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, - doublereal *c__, doublereal *s, integer *incc); +/* Subroutine */ int dlartv_(integer *n, doublereal *x, integer *incx, doublereal *y, integer *incy, doublereal *c__, doublereal *s, integer *incc); /* Subroutine */ int dlaruv_(integer *iseed, integer *n, doublereal *x); -/* Subroutine */ int dlarz_(char *side, integer *m, integer *n, integer *l, doublereal *v, - integer *incv, doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work); +/* Subroutine */ int dlarz_(char *side, integer *m, integer *n, integer *l, doublereal *v, integer *incv, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work); -/* Subroutine */ int dlarzb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, integer *l, doublereal *v, integer *ldv, - doublereal *t, integer *ldt, doublereal *c__, integer *ldc, - doublereal *work, integer *ldwork); +/* Subroutine */ int dlarzb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, integer *l, doublereal *v, integer *ldv, doublereal *t, integer *ldt, + doublereal *c__, integer *ldc, doublereal *work, integer *ldwork); -/* Subroutine */ int dlarzt_(char *direct, char *storev, integer *n, integer *k, doublereal *v, - integer *ldv, doublereal *tau, doublereal *t, integer *ldt); +/* Subroutine */ int dlarzt_(char *direct, char *storev, integer *n, integer *k, doublereal *v, integer *ldv, doublereal *tau, doublereal *t, integer *ldt); -/* Subroutine */ int dlas2_(doublereal *f, doublereal *g, doublereal *h__, doublereal *ssmin, - doublereal *ssmax); +/* Subroutine */ int dlas2_(doublereal *f, doublereal *g, doublereal *h__, doublereal *ssmin, doublereal *ssmax); -/* Subroutine */ int dlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, - doublereal *cto, integer *m, integer *n, doublereal *a, integer *lda, - integer *info); +/* Subroutine */ int dlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, doublereal *cto, integer *m, integer *n, doublereal *a, integer *lda, integer *info); /* Subroutine */ int dlascl2_(integer *m, integer *n, doublereal *d__, doublereal *x, integer *ldx); -/* Subroutine */ int dlasd0_(integer *n, integer *sqre, doublereal *d__, doublereal *e, - doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, - integer *smlsiz, integer *iwork, doublereal *work, integer *info); +/* Subroutine */ int dlasd0_(integer *n, integer *sqre, doublereal *d__, doublereal *e, doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, integer *smlsiz, integer *iwork, doublereal *work, + integer *info); -/* Subroutine */ int dlasd1_(integer *nl, integer *nr, integer *sqre, doublereal *d__, - doublereal *alpha, doublereal *beta, doublereal *u, integer *ldu, - doublereal *vt, integer *ldvt, integer *idxq, integer *iwork, - doublereal *work, integer *info); +/* Subroutine */ int dlasd1_(integer *nl, integer *nr, integer *sqre, doublereal *d__, doublereal *alpha, doublereal *beta, doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, integer *idxq, + integer *iwork, doublereal *work, integer *info); -/* Subroutine */ int dlasd2_(integer *nl, integer *nr, integer *sqre, integer *k, doublereal *d__, - doublereal *z__, doublereal *alpha, doublereal *beta, doublereal *u, - integer *ldu, doublereal *vt, integer *ldvt, doublereal *dsigma, - doublereal *u2, integer *ldu2, doublereal *vt2, integer *ldvt2, - integer *idxp, integer *idx, integer *idxc, integer *idxq, +/* Subroutine */ int dlasd2_(integer *nl, integer *nr, integer *sqre, integer *k, doublereal *d__, doublereal *z__, doublereal *alpha, doublereal *beta, doublereal *u, integer *ldu, doublereal *vt, + integer *ldvt, doublereal *dsigma, doublereal *u2, integer *ldu2, doublereal *vt2, integer *ldvt2, integer *idxp, integer *idx, integer *idxc, integer *idxq, integer *coltyp, integer *info); -/* Subroutine */ int dlasd3_(integer *nl, integer *nr, integer *sqre, integer *k, doublereal *d__, - doublereal *q, integer *ldq, doublereal *dsigma, doublereal *u, - integer *ldu, doublereal *u2, integer *ldu2, doublereal *vt, - integer *ldvt, doublereal *vt2, integer *ldvt2, integer *idxc, - integer *ctot, doublereal *z__, integer *info); +/* Subroutine */ int dlasd3_(integer *nl, integer *nr, integer *sqre, integer *k, doublereal *d__, doublereal *q, integer *ldq, doublereal *dsigma, doublereal *u, integer *ldu, doublereal *u2, + integer *ldu2, doublereal *vt, integer *ldvt, doublereal *vt2, integer *ldvt2, integer *idxc, integer *ctot, doublereal *z__, integer *info); + +/* Subroutine */ int dlasd4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, doublereal *rho, doublereal *sigma, doublereal *work, integer *info); + +/* Subroutine */ int dlasd5_(integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, doublereal *rho, doublereal *dsigma, doublereal *work); + +/* Subroutine */ int dlasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, doublereal *d__, doublereal *vf, doublereal *vl, doublereal *alpha, doublereal *beta, integer *idxq, + integer *perm, integer *givptr, integer *givcol, integer *ldgcol, doublereal *givnum, integer *ldgnum, doublereal *poles, doublereal *difl, doublereal *difr, + doublereal *z__, integer *k, doublereal *c__, doublereal *s, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlasd4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *sigma, +/* Subroutine */ int dlasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *k, doublereal *d__, doublereal *z__, doublereal *zw, doublereal *vf, doublereal *vfw, doublereal *vl, + doublereal *vlw, doublereal *alpha, doublereal *beta, doublereal *dsigma, integer *idx, integer *idxp, integer *idxq, integer *perm, integer *givptr, integer *givcol, + integer *ldgcol, doublereal *givnum, integer *ldgnum, doublereal *c__, doublereal *s, integer *info); + +/* Subroutine */ int dlasd8_(integer *icompq, integer *k, doublereal *d__, doublereal *z__, doublereal *vf, doublereal *vl, doublereal *difl, doublereal *difr, integer *lddifr, doublereal *dsigma, doublereal *work, integer *info); -/* Subroutine */ int dlasd5_(integer *i__, doublereal *d__, doublereal *z__, doublereal *delta, - doublereal *rho, doublereal *dsigma, doublereal *work); +/* Subroutine */ int dlasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, doublereal *d__, doublereal *e, doublereal *u, integer *ldu, doublereal *vt, integer *k, doublereal *difl, + doublereal *difr, doublereal *z__, doublereal *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, doublereal *givnum, doublereal *c__, doublereal *s, + doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dlasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, - doublereal *d__, doublereal *vf, doublereal *vl, doublereal *alpha, - doublereal *beta, integer *idxq, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, doublereal *givnum, integer *ldgnum, - doublereal *poles, doublereal *difl, doublereal *difr, doublereal *z__, - integer *k, doublereal *c__, doublereal *s, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dlasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, integer *nru, integer *ncc, doublereal *d__, doublereal *e, doublereal *vt, integer *ldvt, doublereal *u, + integer *ldu, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dlasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *k, - doublereal *d__, doublereal *z__, doublereal *zw, doublereal *vf, - doublereal *vfw, doublereal *vl, doublereal *vlw, doublereal *alpha, - doublereal *beta, doublereal *dsigma, integer *idx, integer *idxp, - integer *idxq, integer *perm, integer *givptr, integer *givcol, - integer *ldgcol, doublereal *givnum, integer *ldgnum, doublereal *c__, - doublereal *s, integer *info); - -/* Subroutine */ int dlasd8_(integer *icompq, integer *k, doublereal *d__, doublereal *z__, - doublereal *vf, doublereal *vl, doublereal *difl, doublereal *difr, - integer *lddifr, doublereal *dsigma, doublereal *work, integer *info); - -/* Subroutine */ int dlasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, - doublereal *d__, doublereal *e, doublereal *u, integer *ldu, - doublereal *vt, integer *k, doublereal *difl, doublereal *difr, - doublereal *z__, doublereal *poles, integer *givptr, integer *givcol, - integer *ldgcol, integer *perm, doublereal *givnum, doublereal *c__, - doublereal *s, doublereal *work, integer *iwork, integer *info); - -/* Subroutine */ int dlasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, integer *nru, - integer *ncc, doublereal *d__, doublereal *e, doublereal *vt, - integer *ldvt, doublereal *u, integer *ldu, doublereal *c__, - integer *ldc, doublereal *work, integer *info); - -/* Subroutine */ int dlasdt_(integer *n, integer *lvl, integer *nd, integer *inode, integer *ndiml, - integer *ndimr, integer *msub); - -/* Subroutine */ int dlaset_(char *uplo, integer *m, integer *n, doublereal *alpha, - doublereal *beta, doublereal *a, integer *lda); - -/* Subroutine */ int dlasq1_(integer *n, doublereal *d__, doublereal *e, doublereal *work, - integer *info); +/* Subroutine */ int dlasdt_(integer *n, integer *lvl, integer *nd, integer *inode, integer *ndiml, integer *ndimr, integer *msub); + +/* Subroutine */ int dlaset_(char *uplo, integer *m, integer *n, doublereal *alpha, doublereal *beta, doublereal *a, integer *lda); + +/* Subroutine */ int dlasq1_(integer *n, doublereal *d__, doublereal *e, doublereal *work, integer *info); /* Subroutine */ int dlasq2_(integer *n, doublereal *z__, integer *info); -/* Subroutine */ int dlasq3_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *dmin__, doublereal *sigma, doublereal *desig, - doublereal *qmax, integer *nfail, integer *iter, integer *ndiv, - logical *ieee, integer *ttype, doublereal *dmin1, doublereal *dmin2, - doublereal *dn, doublereal *dn1, doublereal *dn2, doublereal *g, - doublereal *tau); +/* Subroutine */ int dlasq3_(integer *i0, integer *n0, doublereal *z__, integer *pp, doublereal *dmin__, doublereal *sigma, doublereal *desig, doublereal *qmax, integer *nfail, integer *iter, + integer *ndiv, logical *ieee, integer *ttype, doublereal *dmin1, doublereal *dmin2, doublereal *dn, doublereal *dn1, doublereal *dn2, doublereal *g, doublereal *tau); -/* Subroutine */ int dlasq4_(integer *i0, integer *n0, doublereal *z__, integer *pp, integer *n0in, - doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, - doublereal *dn, doublereal *dn1, doublereal *dn2, doublereal *tau, - integer *ttype, doublereal *g); +/* Subroutine */ int dlasq4_(integer *i0, integer *n0, doublereal *z__, integer *pp, integer *n0in, doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, doublereal *dn, doublereal *dn1, + doublereal *dn2, doublereal *tau, integer *ttype, doublereal *g); -/* Subroutine */ int dlasq5_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *tau, doublereal *dmin__, doublereal *dmin1, - doublereal *dmin2, doublereal *dn, doublereal *dnm1, doublereal *dnm2, - logical *ieee); +/* Subroutine */ int dlasq5_(integer *i0, integer *n0, doublereal *z__, integer *pp, doublereal *tau, doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, doublereal *dn, doublereal *dnm1, + doublereal *dnm2, logical *ieee); -/* Subroutine */ int dlasq6_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, - doublereal *dn, doublereal *dnm1, doublereal *dnm2); +/* Subroutine */ int dlasq6_(integer *i0, integer *n0, doublereal *z__, integer *pp, doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, doublereal *dn, doublereal *dnm1, doublereal *dnm2); -/* Subroutine */ int dlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - doublereal *c__, doublereal *s, doublereal *a, integer *lda); +/* Subroutine */ int dlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, doublereal *c__, doublereal *s, doublereal *a, integer *lda); /* Subroutine */ int dlasrt_(char *id, integer *n, doublereal *d__, integer *info); -/* Subroutine */ int dlassq_(integer *n, doublereal *x, integer *incx, doublereal *scale, - doublereal *sumsq); +/* Subroutine */ int dlassq_(integer *n, doublereal *x, integer *incx, doublereal *scale, doublereal *sumsq); -/* Subroutine */ int dlasv2_(doublereal *f, doublereal *g, doublereal *h__, doublereal *ssmin, - doublereal *ssmax, doublereal *snr, doublereal *csr, doublereal *snl, - doublereal *csl); +/* Subroutine */ int dlasv2_(doublereal *f, doublereal *g, doublereal *h__, doublereal *ssmin, doublereal *ssmax, doublereal *snr, doublereal *csr, doublereal *snl, doublereal *csl); -/* Subroutine */ int dlaswp_(integer *n, doublereal *a, integer *lda, integer *k1, integer *k2, - integer *ipiv, integer *incx); +/* Subroutine */ int dlaswp_(integer *n, doublereal *a, integer *lda, integer *k1, integer *k2, integer *ipiv, integer *incx); -/* Subroutine */ int dlasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, - integer *n2, doublereal *tl, integer *ldtl, doublereal *tr, - integer *ldtr, doublereal *b, integer *ldb, doublereal *scale, - doublereal *x, integer *ldx, doublereal *xnorm, integer *info); +/* Subroutine */ int dlasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, integer *n2, doublereal *tl, integer *ldtl, doublereal *tr, integer *ldtr, doublereal *b, integer *ldb, + doublereal *scale, doublereal *x, integer *ldx, doublereal *xnorm, integer *info); -/* Subroutine */ int dlasyf_(char *uplo, integer *n, integer *nb, integer *kb, doublereal *a, - integer *lda, integer *ipiv, doublereal *w, integer *ldw, - integer *info); +/* Subroutine */ int dlasyf_(char *uplo, integer *n, integer *nb, integer *kb, doublereal *a, integer *lda, integer *ipiv, doublereal *w, integer *ldw, integer *info); -/* Subroutine */ int dlat2s_(char *uplo, integer *n, doublereal *a, integer *lda, real *sa, - integer *ldsa, integer *info); +/* Subroutine */ int dlat2s_(char *uplo, integer *n, doublereal *a, integer *lda, real *sa, integer *ldsa, integer *info); -/* Subroutine */ int dlatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - integer *kd, doublereal *ab, integer *ldab, doublereal *x, - doublereal *scale, doublereal *cnorm, integer *info); +/* Subroutine */ int dlatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *x, doublereal *scale, doublereal *cnorm, + integer *info); -/* Subroutine */ int dlatdf_(integer *ijob, integer *n, doublereal *z__, integer *ldz, - doublereal *rhs, doublereal *rdsum, doublereal *rdscal, integer *ipiv, - integer *jpiv); +/* Subroutine */ int dlatdf_(integer *ijob, integer *n, doublereal *z__, integer *ldz, doublereal *rhs, doublereal *rdsum, doublereal *rdscal, integer *ipiv, integer *jpiv); -/* Subroutine */ int dlatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, - doublereal *ap, doublereal *x, doublereal *scale, doublereal *cnorm, - integer *info); +/* Subroutine */ int dlatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, doublereal *ap, doublereal *x, doublereal *scale, doublereal *cnorm, integer *info); -/* Subroutine */ int dlatrd_(char *uplo, integer *n, integer *nb, doublereal *a, integer *lda, - doublereal *e, doublereal *tau, doublereal *w, integer *ldw); +/* Subroutine */ int dlatrd_(char *uplo, integer *n, integer *nb, doublereal *a, integer *lda, doublereal *e, doublereal *tau, doublereal *w, integer *ldw); -/* Subroutine */ int dlatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - doublereal *a, integer *lda, doublereal *x, doublereal *scale, - doublereal *cnorm, integer *info); +/* Subroutine */ int dlatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, doublereal *a, integer *lda, doublereal *x, doublereal *scale, doublereal *cnorm, integer *info); -/* Subroutine */ int dlatrz_(integer *m, integer *n, integer *l, doublereal *a, integer *lda, - doublereal *tau, doublereal *work); +/* Subroutine */ int dlatrz_(integer *m, integer *n, integer *l, doublereal *a, integer *lda, doublereal *tau, doublereal *work); -/* Subroutine */ int dlatzm_(char *side, integer *m, integer *n, doublereal *v, integer *incv, - doublereal *tau, doublereal *c1, doublereal *c2, integer *ldc, - doublereal *work); +/* Subroutine */ int dlatzm_(char *side, integer *m, integer *n, doublereal *v, integer *incv, doublereal *tau, doublereal *c1, doublereal *c2, integer *ldc, doublereal *work); /* Subroutine */ int dlauu2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *info); /* Subroutine */ int dlauum_(char *uplo, integer *n, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dopgtr_(char *uplo, integer *n, doublereal *ap, doublereal *tau, doublereal *q, - integer *ldq, doublereal *work, integer *info); - -/* Subroutine */ int dopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublereal *ap, doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work, integer *info); +/* Subroutine */ int dopgtr_(char *uplo, integer *n, doublereal *ap, doublereal *tau, doublereal *q, integer *ldq, doublereal *work, integer *info); -/* Subroutine */ int dorg2l_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, doublereal *ap, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dorg2r_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dorg2l_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dorgbr_(char *vect, integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dorg2r_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dorghr_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorgbr_(char *vect, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorgl2_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dorghr_(integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorglq_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorgl2_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dorgql_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorglq_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorgqr_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorgql_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorgr2_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); +/* Subroutine */ int dorgqr_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorgrq_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorgr2_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *info); -/* Subroutine */ int dorgtr_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorgrq_(integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *info); +/* Subroutine */ int dorgtr_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *info); +/* Subroutine */ int dorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dormbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dormhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, - integer *ihi, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dormbr_(char *vect, char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dorml2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *info); +/* Subroutine */ int dormhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, integer *ihi, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dormlq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dorml2_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dormql_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dormlq_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork, + integer *info); -/* Subroutine */ int dormqr_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dormql_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork, + integer *info); -/* Subroutine */ int dormr2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *info); +/* Subroutine */ int dormqr_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork, + integer *info); -/* Subroutine */ int dormr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, integer *info); +/* Subroutine */ int dormr2_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *info); -/* Subroutine */ int dormrq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dormr3_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, + integer *info); -/* Subroutine */ int dormrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, integer *lwork, +/* Subroutine */ int dormrq_(char *side, char *trans, integer *m, integer *n, integer *k, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dormrz_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, + integer *lwork, integer *info); -/* Subroutine */ int dpbcon_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, +/* Subroutine */ int dormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *c__, integer *ldc, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dpbequ_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - doublereal *s, doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int dpbcon_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, - integer *ldab, doublereal *afb, integer *ldafb, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dpbequ_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int dpbstf_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - integer *info); +/* Subroutine */ int dpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, doublereal *b, integer *ldb, doublereal *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, - integer *ldab, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dpbstf_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, integer *info); -/* Subroutine */ int dpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, - char *equed, doublereal *s, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dpbtf2_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - integer *info); +/* Subroutine */ int dpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *afb, integer *ldafb, char *equed, doublereal *s, doublereal *b, + integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dpbtrf_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, - integer *info); +/* Subroutine */ int dpbtf2_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, integer *info); -/* Subroutine */ int dpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, - integer *ldab, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dpbtrf_(char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, integer *info); + +/* Subroutine */ int dpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, integer *ldb, integer *info); /* Subroutine */ int dpftrf_(char *transr, char *uplo, integer *n, doublereal *a, integer *info); /* Subroutine */ int dpftri_(char *transr, char *uplo, integer *n, doublereal *a, integer *info); -/* Subroutine */ int dpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, doublereal *a, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, doublereal *a, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dpocon_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dpocon_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dpoequ_(integer *n, doublereal *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int dpoequ_(integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int dpoequb_(integer *n, doublereal *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int dpoequb_(integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int dporfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dporfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, doublereal *s, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, doublereal *s, doublereal *b, integer *ldb, doublereal *x, + integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, + doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dposv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dposv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dposvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, char *equed, - doublereal *s, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dposvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, char *equed, doublereal *s, doublereal *b, integer *ldb, + doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, char *equed, - doublereal *s, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, char *equed, doublereal *s, doublereal *b, integer *ldb, + doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, + integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); /* Subroutine */ int dpotf2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *info); @@ -3119,479 +1984,288 @@ doublereal dlapy3_(doublereal *x, doublereal *y, doublereal *z__); /* Subroutine */ int dpotri_(char *uplo, integer *n, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dpotrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dpotrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dppcon_(char *uplo, integer *n, doublereal *ap, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dppcon_(char *uplo, integer *n, doublereal *ap, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dppequ_(char *uplo, integer *n, doublereal *ap, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int dppequ_(char *uplo, integer *n, doublereal *ap, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int dpprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dpprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, + doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dppsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *b, - integer *ldb, integer *info); +/* Subroutine */ int dppsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *afp, char *equed, doublereal *s, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, char *equed, doublereal *s, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); /* Subroutine */ int dpptrf_(char *uplo, integer *n, doublereal *ap, integer *info); /* Subroutine */ int dpptri_(char *uplo, integer *n, doublereal *ap, integer *info); -/* Subroutine */ int dpptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *b, - integer *ldb, integer *info); +/* Subroutine */ int dpptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dpstf2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *piv, - integer *rank, doublereal *tol, doublereal *work, integer *info); +/* Subroutine */ int dpstf2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *piv, integer *rank, doublereal *tol, doublereal *work, integer *info); -/* Subroutine */ int dpstrf_(char *uplo, integer *n, doublereal *a, integer *lda, integer *piv, - integer *rank, doublereal *tol, doublereal *work, integer *info); +/* Subroutine */ int dpstrf_(char *uplo, integer *n, doublereal *a, integer *lda, integer *piv, integer *rank, doublereal *tol, doublereal *work, integer *info); -/* Subroutine */ int dptcon_(integer *n, doublereal *d__, doublereal *e, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *info); +/* Subroutine */ int dptcon_(integer *n, doublereal *d__, doublereal *e, doublereal *anorm, doublereal *rcond, doublereal *work, integer *info); -/* Subroutine */ int dpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int dpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int dptrfs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *df, doublereal *ef, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *info); +/* Subroutine */ int dptrfs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *df, doublereal *ef, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublereal *work, integer *info); -/* Subroutine */ int dptsv_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dptsv_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *df, doublereal *ef, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublereal *work, integer *info); +/* Subroutine */ int dptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *df, doublereal *ef, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *info); /* Subroutine */ int dpttrf_(integer *n, doublereal *d__, doublereal *e, integer *info); -/* Subroutine */ int dpttrs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dpttrs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dptts2_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb); +/* Subroutine */ int dptts2_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublereal *b, integer *ldb); /* Subroutine */ int drscl_(integer *n, doublereal *sa, doublereal *sx, integer *incx); -/* Subroutine */ int dsbev_(char *jobz, char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *info); +/* Subroutine */ int dsbev_(char *jobz, char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int dsbevd_(char *jobz, char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int dsbevd_(char *jobz, char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, + integer *iwork, integer *liwork, integer *info); + +/* Subroutine */ int dsbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *q, integer *ldq, doublereal *vl, doublereal *vu, integer *il, + integer *iu, doublereal *abstol, integer *m, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dsbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *q, integer *ldq, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *iwork, integer *ifail, +/* Subroutine */ int dsbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, doublereal *x, integer *ldx, doublereal *work, integer *info); -/* Subroutine */ int dsbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *x, integer *ldx, doublereal *work, integer *info); +/* Subroutine */ int dsbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, doublereal *w, doublereal *z__, integer *ldz, + doublereal *work, integer *info); -/* Subroutine */ int dsbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *w, doublereal *z__, integer *ldz, doublereal *work, - integer *info); +/* Subroutine */ int dsbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, doublereal *w, doublereal *z__, integer *ldz, + doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dsbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *w, doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dsbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, doublereal *q, integer *ldq, + doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *iwork, + integer *ifail, integer *info); -/* Subroutine */ int dsbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, doublereal *ab, integer *ldab, doublereal *bb, - integer *ldbb, doublereal *q, integer *ldq, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int dsbtrd_(char *vect, char *uplo, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *d__, doublereal *e, doublereal *q, integer *ldq, doublereal *work, + integer *info); + +/* Subroutine */ int dsfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *beta, doublereal *c__); -/* Subroutine */ int dsbtrd_(char *vect, char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *d__, doublereal *e, doublereal *q, - integer *ldq, doublereal *work, integer *info); +/* Subroutine */ int dsgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *work, real *swork, + integer *iter, integer *info); -/* Subroutine */ int dsfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, - doublereal *alpha, doublereal *a, integer *lda, doublereal *beta, - doublereal *c__); +/* Subroutine */ int dspcon_(char *uplo, integer *n, doublereal *ap, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *work, real *swork, integer *iter, integer *info); +/* Subroutine */ int dspev_(char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int dspcon_(char *uplo, integer *n, doublereal *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, +/* Subroutine */ int dspevd_(char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dspev_(char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int dspevx_(char *jobz, char *range, char *uplo, integer *n, doublereal *ap, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, doublereal *w, + doublereal *z__, integer *ldz, doublereal *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dspevd_(char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dspgst_(integer *itype, char *uplo, integer *n, doublereal *ap, doublereal *bp, integer *info); -/* Subroutine */ int dspevx_(char *jobz, char *range, char *uplo, integer *n, doublereal *ap, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int dspgv_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *bp, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int dspgst_(integer *itype, char *uplo, integer *n, doublereal *ap, doublereal *bp, - integer *info); +/* Subroutine */ int dspgvd_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *ap, doublereal *bp, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, + integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dspgv_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *ap, - doublereal *bp, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *info); +/* Subroutine */ int dspgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, doublereal *ap, doublereal *bp, doublereal *vl, doublereal *vu, integer *il, integer *iu, + doublereal *abstol, integer *m, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dspgvd_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *ap, - doublereal *bp, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *iwork, integer *liwork, +/* Subroutine */ int dsposv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *work, real *swork, integer *iter, integer *info); -/* Subroutine */ int dspgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - doublereal *ap, doublereal *bp, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, integer *m, - doublereal *w, doublereal *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info); - -/* Subroutine */ int dsposv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *work, real *swork, integer *iter, integer *info); - -/* Subroutine */ int dsprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, - integer *ipiv, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dsprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dspsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, integer *ipiv, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dspsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *afp, integer *ipiv, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *ap, doublereal *afp, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsptrd_(char *uplo, integer *n, doublereal *ap, doublereal *d__, doublereal *e, - doublereal *tau, integer *info); +/* Subroutine */ int dsptrd_(char *uplo, integer *n, doublereal *ap, doublereal *d__, doublereal *e, doublereal *tau, integer *info); /* Subroutine */ int dsptrf_(char *uplo, integer *n, doublereal *ap, integer *ipiv, integer *info); -/* Subroutine */ int dsptri_(char *uplo, integer *n, doublereal *ap, integer *ipiv, - doublereal *work, integer *info); +/* Subroutine */ int dsptri_(char *uplo, integer *n, doublereal *ap, integer *ipiv, doublereal *work, integer *info); -/* Subroutine */ int dsptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, integer *ipiv, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dsptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dstebz_(char *range, char *order, integer *n, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, doublereal *d__, - doublereal *e, integer *m, integer *nsplit, doublereal *w, - integer *iblock, integer *isplit, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dstebz_(char *range, char *order, integer *n, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, doublereal *d__, doublereal *e, integer *m, + integer *nsplit, doublereal *w, integer *iblock, integer *isplit, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dstegr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dstegr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublereal *z__, integer *ldz, integer *isuppz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dstein_(integer *n, doublereal *d__, doublereal *e, integer *m, doublereal *w, - integer *iblock, integer *isplit, doublereal *z__, integer *ldz, - doublereal *work, integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int dstein_(integer *n, doublereal *d__, doublereal *e, integer *m, doublereal *w, integer *iblock, integer *isplit, doublereal *z__, integer *ldz, doublereal *work, integer *iwork, + integer *ifail, integer *info); -/* Subroutine */ int dstemr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, integer *m, - doublereal *w, doublereal *z__, integer *ldz, integer *nzc, - integer *isuppz, logical *tryrac, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dstemr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, integer *m, doublereal *w, doublereal *z__, + integer *ldz, integer *nzc, integer *isuppz, logical *tryrac, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int dsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, integer *ldz, doublereal *work, integer *info); /* Subroutine */ int dsterf_(integer *n, doublereal *d__, doublereal *e, integer *info); -/* Subroutine */ int dstev_(char *jobz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, - integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int dstev_(char *jobz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int dstevd_(char *jobz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dstevd_(char *jobz, integer *n, doublereal *d__, doublereal *e, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dstevr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dstevr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublereal *z__, integer *ldz, integer *isuppz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dstevx_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int dstevx_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dsycon_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dsycon_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsyequb_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, doublereal *work, integer *info); +/* Subroutine */ int dsyequb_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, doublereal *work, integer *info); -/* Subroutine */ int dsyev_(char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *w, doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dsyev_(char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *w, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dsyevd_(char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *w, doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int dsyevd_(char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *w, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dsyevr_(char *jobz, char *range, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dsyevr_(char *jobz, char *range, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublereal *z__, integer *ldz, integer *isuppz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dsyevx_(char *jobz, char *range, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *lwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int dsyevx_(char *jobz, char *range, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dsygs2_(integer *itype, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dsygs2_(integer *itype, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dsygst_(integer *itype, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dsygst_(integer *itype, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dsygv_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *w, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dsygv_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *w, doublereal *work, integer *lwork, + integer *info); + +/* Subroutine */ int dsygvd_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *w, doublereal *work, integer *lwork, + integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dsygvd_(integer *itype, char *jobz, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *w, - doublereal *work, integer *lwork, integer *iwork, integer *liwork, +/* Subroutine */ int dsygvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *vl, doublereal *vu, integer *il, + integer *iu, doublereal *abstol, integer *m, doublereal *w, doublereal *z__, integer *ldz, doublereal *work, integer *lwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int dsygvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *lwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int dsyrfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsyrfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - doublereal *af, integer *ldaf, integer *ipiv, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dsyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *s, doublereal *b, integer *ldb, + doublereal *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, + doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - doublereal *s, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dsysv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dsysv_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - integer *ipiv, doublereal *b, integer *ldb, doublereal *work, - integer *lwork, integer *info); - -/* Subroutine */ int dsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *lwork, integer *iwork, integer *info); - -/* Subroutine */ int dsysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *s, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, - doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, + integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dsytd2_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *d__, - doublereal *e, doublereal *tau, integer *info); +/* Subroutine */ int dsysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *af, integer *ldaf, integer *ipiv, char *equed, doublereal *s, doublereal *b, + integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, + doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dsytf2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int dsytd2_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *d__, doublereal *e, doublereal *tau, integer *info); -/* Subroutine */ int dsytrd_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *d__, - doublereal *e, doublereal *tau, doublereal *work, integer *lwork, - integer *info); +/* Subroutine */ int dsytf2_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int dsytrf_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dsytrd_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *d__, doublereal *e, doublereal *tau, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dsytri_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, - doublereal *work, integer *info); +/* Subroutine */ int dsytrf_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dsytrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, - integer *ipiv, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dsytri_(char *uplo, integer *n, doublereal *a, integer *lda, integer *ipiv, doublereal *work, integer *info); -/* Subroutine */ int dtbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *rcond, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dsytrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dtbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dtbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, doublereal *ab, integer *ldab, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dtbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, - integer *ldb, integer *info); +/* Subroutine */ int dtbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, integer *ldb, doublereal *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dtfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, - integer *m, integer *n, doublereal *alpha, doublereal *a, doublereal *b, - integer *ldb); +/* Subroutine */ int dtbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dtftri_(char *transr, char *uplo, char *diag, integer *n, doublereal *a, - integer *info); +/* Subroutine */ int dtfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, integer *m, integer *n, doublereal *alpha, doublereal *a, doublereal *b, integer *ldb); -/* Subroutine */ int dtfttp_(char *transr, char *uplo, integer *n, doublereal *arf, doublereal *ap, - integer *info); +/* Subroutine */ int dtftri_(char *transr, char *uplo, char *diag, integer *n, doublereal *a, integer *info); -/* Subroutine */ int dtfttr_(char *transr, char *uplo, integer *n, doublereal *arf, doublereal *a, - integer *lda, integer *info); +/* Subroutine */ int dtfttp_(char *transr, char *uplo, integer *n, doublereal *arf, doublereal *ap, integer *info); -/* Subroutine */ int dtgevc_(char *side, char *howmny, logical *select, integer *n, doublereal *s, - integer *lds, doublereal *p, integer *ldp, doublereal *vl, - integer *ldvl, doublereal *vr, integer *ldvr, integer *mm, integer *m, - doublereal *work, integer *info); +/* Subroutine */ int dtfttr_(char *transr, char *uplo, integer *n, doublereal *arf, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dtgex2_(logical *wantq, logical *wantz, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *q, integer *ldq, - doublereal *z__, integer *ldz, integer *j1, integer *n1, integer *n2, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dtgevc_(char *side, char *howmny, logical *select, integer *n, doublereal *s, integer *lds, doublereal *p, integer *ldp, doublereal *vl, integer *ldvl, doublereal *vr, + integer *ldvr, integer *mm, integer *m, doublereal *work, integer *info); -/* Subroutine */ int dtgexc_(logical *wantq, logical *wantz, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *q, integer *ldq, - doublereal *z__, integer *ldz, integer *ifst, integer *ilst, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dtgex2_(logical *wantq, logical *wantz, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *q, integer *ldq, doublereal *z__, integer *ldz, + integer *j1, integer *n1, integer *n2, doublereal *work, integer *lwork, integer *info); -/* Subroutine */ int dtgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, - integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *q, integer *ldq, doublereal *z__, integer *ldz, integer *m, - doublereal *pl, doublereal *pr, doublereal *dif, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int dtgexc_(logical *wantq, logical *wantz, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *q, integer *ldq, doublereal *z__, integer *ldz, + integer *ifst, integer *ilst, doublereal *work, integer *lwork, integer *info); + +/* Subroutine */ int dtgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, + doublereal *alphai, doublereal *beta, doublereal *q, integer *ldq, doublereal *z__, integer *ldz, integer *m, doublereal *pl, doublereal *pr, doublereal *dif, + doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dtgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - integer *k, integer *l, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *tola, doublereal *tolb, doublereal *alpha, - doublereal *beta, doublereal *u, integer *ldu, doublereal *v, - integer *ldv, doublereal *q, integer *ldq, doublereal *work, +/* Subroutine */ int dtgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, integer *k, integer *l, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *tola, + doublereal *tolb, doublereal *alpha, doublereal *beta, doublereal *u, integer *ldu, doublereal *v, integer *ldv, doublereal *q, integer *ldq, doublereal *work, integer *ncycle, integer *info); -/* Subroutine */ int dtgsna_(char *job, char *howmny, logical *select, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *vl, - integer *ldvl, doublereal *vr, integer *ldvr, doublereal *s, - doublereal *dif, integer *mm, integer *m, doublereal *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int dtgsna_(char *job, char *howmny, logical *select, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *vl, integer *ldvl, doublereal *vr, + integer *ldvr, doublereal *s, doublereal *dif, integer *mm, integer *m, doublereal *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dtgsy2_(char *trans, integer *ijob, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *c__, - integer *ldc, doublereal *d__, integer *ldd, doublereal *e, - integer *lde, doublereal *f, integer *ldf, doublereal *scale, - doublereal *rdsum, doublereal *rdscal, integer *iwork, integer *pq, - integer *info); +/* Subroutine */ int dtgsy2_(char *trans, integer *ijob, integer *m, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *c__, integer *ldc, doublereal *d__, integer *ldd, + doublereal *e, integer *lde, doublereal *f, integer *ldf, doublereal *scale, doublereal *rdsum, doublereal *rdscal, integer *iwork, integer *pq, integer *info); -/* Subroutine */ int dtgsyl_(char *trans, integer *ijob, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *c__, - integer *ldc, doublereal *d__, integer *ldd, doublereal *e, - integer *lde, doublereal *f, integer *ldf, doublereal *scale, - doublereal *dif, doublereal *work, integer *lwork, integer *iwork, - integer *info); +/* Subroutine */ int dtgsyl_(char *trans, integer *ijob, integer *m, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *c__, integer *ldc, doublereal *d__, integer *ldd, + doublereal *e, integer *lde, doublereal *f, integer *ldf, doublereal *scale, doublereal *dif, doublereal *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int dtpcon_(char *norm, char *uplo, char *diag, integer *n, doublereal *ap, - doublereal *rcond, doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dtpcon_(char *norm, char *uplo, char *diag, integer *n, doublereal *ap, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dtprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublereal *ap, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info); +/* Subroutine */ int dtprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublereal *work, integer *iwork, integer *info); /* Subroutine */ int dtptri_(char *uplo, char *diag, integer *n, doublereal *ap, integer *info); -/* Subroutine */ int dtptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublereal *ap, doublereal *b, integer *ldb, integer *info); +/* Subroutine */ int dtptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dtpttf_(char *transr, char *uplo, integer *n, doublereal *ap, doublereal *arf, - integer *info); +/* Subroutine */ int dtpttf_(char *transr, char *uplo, integer *n, doublereal *ap, doublereal *arf, integer *info); -/* Subroutine */ int dtpttr_(char *uplo, integer *n, doublereal *ap, doublereal *a, integer *lda, - integer *info); +/* Subroutine */ int dtpttr_(char *uplo, integer *n, doublereal *ap, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dtrcon_(char *norm, char *uplo, char *diag, integer *n, doublereal *a, - integer *lda, doublereal *rcond, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int dtrcon_(char *norm, char *uplo, char *diag, integer *n, doublereal *a, integer *lda, doublereal *rcond, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dtrevc_(char *side, char *howmny, logical *select, integer *n, doublereal *t, - integer *ldt, doublereal *vl, integer *ldvl, doublereal *vr, - integer *ldvr, integer *mm, integer *m, doublereal *work, - integer *info); +/* Subroutine */ int dtrevc_(char *side, char *howmny, logical *select, integer *n, doublereal *t, integer *ldt, doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, integer *mm, integer *m, + doublereal *work, integer *info); -/* Subroutine */ int dtrexc_(char *compq, integer *n, doublereal *t, integer *ldt, doublereal *q, - integer *ldq, integer *ifst, integer *ilst, doublereal *work, - integer *info); +/* Subroutine */ int dtrexc_(char *compq, integer *n, doublereal *t, integer *ldt, doublereal *q, integer *ldq, integer *ifst, integer *ilst, doublereal *work, integer *info); -/* Subroutine */ int dtrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info); +/* Subroutine */ int dtrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int dtrsen_(char *job, char *compq, logical *select, integer *n, doublereal *t, - integer *ldt, doublereal *q, integer *ldq, doublereal *wr, - doublereal *wi, integer *m, doublereal *s, doublereal *sep, - doublereal *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int dtrsen_(char *job, char *compq, logical *select, integer *n, doublereal *t, integer *ldt, doublereal *q, integer *ldq, doublereal *wr, doublereal *wi, integer *m, doublereal *s, + doublereal *sep, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int dtrsna_(char *job, char *howmny, logical *select, integer *n, doublereal *t, - integer *ldt, doublereal *vl, integer *ldvl, doublereal *vr, - integer *ldvr, doublereal *s, doublereal *sep, integer *mm, integer *m, - doublereal *work, integer *ldwork, integer *iwork, integer *info); +/* Subroutine */ int dtrsna_(char *job, char *howmny, logical *select, integer *n, doublereal *t, integer *ldt, doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, doublereal *s, + doublereal *sep, integer *mm, integer *m, doublereal *work, integer *ldwork, integer *iwork, integer *info); -/* Subroutine */ int dtrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *c__, integer *ldc, doublereal *scale, integer *info); +/* Subroutine */ int dtrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *c__, integer *ldc, + doublereal *scale, integer *info); -/* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal *a, integer *lda, - integer *info); +/* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *a, integer *lda, - integer *info); +/* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int dtrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - integer *info); +/* Subroutine */ int dtrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *ldb, integer *info); -/* Subroutine */ int dtrttf_(char *transr, char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *arf, integer *info); +/* Subroutine */ int dtrttf_(char *transr, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *arf, integer *info); -/* Subroutine */ int dtrttp_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *ap, - integer *info); +/* Subroutine */ int dtrttp_(char *uplo, integer *n, doublereal *a, integer *lda, doublereal *ap, integer *info); -/* Subroutine */ int dtzrqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - integer *info); +/* Subroutine */ int dtzrqf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, integer *info); -/* Subroutine */ int dtzrzf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info); +/* Subroutine */ int dtzrzf_(integer *m, integer *n, doublereal *a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, integer *info); doublereal dzsum1_(integer *n, doublecomplex *cx, integer *incx); @@ -3609,8 +2283,7 @@ integer iladlc_(integer *m, integer *n, doublereal *a, integer *lda); integer iladlr_(integer *m, integer *n, doublereal *a, integer *lda); -integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, integer *n2, integer *n3, - integer *n4); +integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, integer *n2, integer *n3, integer *n4); integer ilaprec_(char *prec); @@ -3628,8 +2301,7 @@ integer ilazlc_(integer *m, integer *n, doublecomplex *a, integer *lda); integer ilazlr_(integer *m, integer *n, doublecomplex *a, integer *lda); -integer iparmq_(integer *ispec, char *name__, char *opts, integer *n, integer *ilo, integer *ihi, - integer *lwork); +integer iparmq_(integer *ispec, char *name__, char *opts, integer *n, integer *ilo, integer *ihi, integer *lwork); integer izmax1_(integer *n, doublecomplex *cx, integer *incx); @@ -3637,580 +2309,358 @@ logical lsamen_(integer *n, char *ca, char *cb); integer smaxloc_(real *a, integer *dimm); -/* Subroutine */ int sbdsdc_(char *uplo, char *compq, integer *n, real *d__, real *e, real *u, - integer *ldu, real *vt, integer *ldvt, real *q, integer *iq, - real *work, integer *iwork, integer *info); +/* Subroutine */ int sbdsdc_(char *uplo, char *compq, integer *n, real *d__, real *e, real *u, integer *ldu, real *vt, integer *ldvt, real *q, integer *iq, real *work, integer *iwork, integer *info); -/* Subroutine */ int sbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, - real *d__, real *e, real *vt, integer *ldvt, real *u, integer *ldu, - real *c__, integer *ldc, real *work, integer *info); +/* Subroutine */ int sbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, real *d__, real *e, real *vt, integer *ldvt, real *u, integer *ldu, real *c__, integer *ldc, real *work, + integer *info); doublereal scsum1_(integer *n, complex *cx, integer *incx); -/* Subroutine */ int sdisna_(char *job, integer *m, integer *n, real *d__, real *sep, - integer *info); +/* Subroutine */ int sdisna_(char *job, integer *m, integer *n, real *d__, real *sep, integer *info); -/* Subroutine */ int sgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, - integer *ku, real *ab, integer *ldab, real *d__, real *e, real *q, - integer *ldq, real *pt, integer *ldpt, real *c__, integer *ldc, - real *work, integer *info); +/* Subroutine */ int sgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, integer *ku, real *ab, integer *ldab, real *d__, real *e, real *q, integer *ldq, real *pt, integer *ldpt, + real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sgbcon_(char *norm, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, real *anorm, real *rcond, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sgbcon_(char *norm, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, integer *ipiv, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgbequ_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, integer *info); +/* Subroutine */ int sgbequ_(integer *m, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int sgbequb_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, integer *info); +/* Subroutine */ int sgbequb_(integer *m, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int sgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, - real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info); +/* Subroutine */ int sgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, real *b, integer *ldb, real *x, + integer *ldx, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, - integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, - integer *ipiv, real *r__, real *c__, real *b, integer *ldb, real *x, - integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, +/* Subroutine */ int sgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, real *r__, real *c__, + real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, - integer *ldab, integer *ipiv, real *b, integer *ldb, integer *info); - -/* Subroutine */ int sgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, - integer *ipiv, char *equed, real *r__, real *c__, real *b, - integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, - real *berr, real *work, integer *iwork, integer *info); - -/* Subroutine */ int sgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, - integer *ipiv, char *equed, real *r__, real *c__, real *b, - integer *ldb, real *x, integer *ldx, real *rcond, real *rpvgrw, - real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int sgbtf2_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int sgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, char *equed, real *r__, + real *c__, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgbtrf_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int sgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, char *equed, real *r__, + real *c__, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, + integer *nparams, real *params, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - real *ab, integer *ldab, integer *ipiv, real *b, integer *ldb, - integer *info); +/* Subroutine */ int sgbtf2_(integer *m, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int sgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - real *scale, integer *m, real *v, integer *ldv, integer *info); +/* Subroutine */ int sgbtrf_(integer *m, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int sgebal_(char *job, integer *n, real *a, integer *lda, integer *ilo, - integer *ihi, real *scale, integer *info); +/* Subroutine */ int sgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int sgebd2_(integer *m, integer *n, real *a, integer *lda, real *d__, real *e, - real *tauq, real *taup, real *work, integer *info); +/* Subroutine */ int sgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, real *scale, integer *m, real *v, integer *ldv, integer *info); -/* Subroutine */ int sgebrd_(integer *m, integer *n, real *a, integer *lda, real *d__, real *e, - real *tauq, real *taup, real *work, integer *lwork, integer *info); +/* Subroutine */ int sgebal_(char *job, integer *n, real *a, integer *lda, integer *ilo, integer *ihi, real *scale, integer *info); -/* Subroutine */ int sgecon_(char *norm, integer *n, real *a, integer *lda, real *anorm, - real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int sgebd2_(integer *m, integer *n, real *a, integer *lda, real *d__, real *e, real *tauq, real *taup, real *work, integer *info); -/* Subroutine */ int sgeequ_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, integer *info); +/* Subroutine */ int sgebrd_(integer *m, integer *n, real *a, integer *lda, real *d__, real *e, real *tauq, real *taup, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgeequb_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, integer *info); +/* Subroutine */ int sgecon_(char *norm, integer *n, real *a, integer *lda, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgees_(char *jobvs, char *sort, L_fp select, integer *n, real *a, integer *lda, - integer *sdim, real *wr, real *wi, real *vs, integer *ldvs, real *work, - integer *lwork, logical *bwork, integer *info); +/* Subroutine */ int sgeequ_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int sgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, real *a, - integer *lda, integer *sdim, real *wr, real *wi, real *vs, - integer *ldvs, real *rconde, real *rcondv, real *work, integer *lwork, - integer *iwork, integer *liwork, logical *bwork, integer *info); +/* Subroutine */ int sgeequb_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, integer *info); -/* Subroutine */ int sgeev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *wr, - real *wi, real *vl, integer *ldvl, real *vr, integer *ldvr, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgees_(char *jobvs, char *sort, L_fp select, integer *n, real *a, integer *lda, integer *sdim, real *wr, real *wi, real *vs, integer *ldvs, real *work, integer *lwork, + logical *bwork, integer *info); -/* Subroutine */ int sgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - real *a, integer *lda, real *wr, real *wi, real *vl, integer *ldvl, - real *vr, integer *ldvr, integer *ilo, integer *ihi, real *scale, - real *abnrm, real *rconde, real *rcondv, real *work, integer *lwork, - integer *iwork, integer *info); +/* Subroutine */ int sgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, real *a, integer *lda, integer *sdim, real *wr, real *wi, real *vs, integer *ldvs, real *rconde, + real *rcondv, real *work, integer *lwork, integer *iwork, integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int sgegs_(char *jobvsl, char *jobvsr, integer *n, real *a, integer *lda, real *b, - integer *ldb, real *alphar, real *alphai, real *beta, real *vsl, - integer *ldvsl, real *vsr, integer *ldvsr, real *work, integer *lwork, +/* Subroutine */ int sgeev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *wr, real *wi, real *vl, integer *ldvl, real *vr, integer *ldvr, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgegv_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *b, - integer *ldb, real *alphar, real *alphai, real *beta, real *vl, - integer *ldvl, real *vr, integer *ldvr, real *work, integer *lwork, - integer *info); +/* Subroutine */ int sgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, real *a, integer *lda, real *wr, real *wi, real *vl, integer *ldvl, real *vr, integer *ldvr, integer *ilo, + integer *ihi, real *scale, real *abnrm, real *rconde, real *rcondv, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int sgehd2_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, - real *tau, real *work, integer *info); +/* Subroutine */ int sgegs_(char *jobvsl, char *jobvsr, integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *vsl, integer *ldvsl, real *vsr, + integer *ldvsr, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgehrd_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); +/* Subroutine */ int sgegv_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *vl, integer *ldvl, real *vr, + integer *ldvr, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgejsv_(char *joba, char *jobu, char *jobv, char *jobr, char *jobt, char *jobp, - integer *m, integer *n, real *a, integer *lda, real *sva, real *u, - integer *ldu, real *v, integer *ldv, real *work, integer *lwork, - integer *iwork, integer *info); +/* Subroutine */ int sgehd2_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sgelq2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *info); +/* Subroutine */ int sgehrd_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgelqf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgejsv_(char *joba, char *jobu, char *jobv, char *jobr, char *jobt, char *jobp, integer *m, integer *n, real *a, integer *lda, real *sva, real *u, integer *ldu, real *v, + integer *ldv, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int sgels_(char *trans, integer *m, integer *n, integer *nrhs, real *a, - integer *lda, real *b, integer *ldb, real *work, integer *lwork, - integer *info); +/* Subroutine */ int sgelq2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sgelsd_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, real *s, real *rcond, integer *rank, real *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int sgelqf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgelss_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, real *s, real *rcond, integer *rank, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgels_(char *trans, integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgelsx_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, integer *jpvt, real *rcond, integer *rank, real *work, +/* Subroutine */ int sgelsd_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, real *s, real *rcond, integer *rank, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int sgelsy_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, integer *jpvt, real *rcond, integer *rank, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgelss_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, real *s, real *rcond, integer *rank, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgeql2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *info); +/* Subroutine */ int sgelsx_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, real *work, integer *info); -/* Subroutine */ int sgeqlf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgelsy_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, integer *jpvt, real *rcond, integer *rank, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgeqp3_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, - real *tau, real *work, integer *lwork, integer *info); +/* Subroutine */ int sgeql2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sgeqpf_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, - real *tau, real *work, integer *info); +/* Subroutine */ int sgeqlf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgeqr2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *info); +/* Subroutine */ int sgeqp3_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgeqrf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgeqpf_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, real *tau, real *work, integer *info); -/* Subroutine */ int sgerfs_(char *trans, integer *n, integer *nrhs, real *a, integer *lda, - real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, - integer *ldx, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int sgeqr2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, real *r__, - real *c__, real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sgeqrf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgerq2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *info); +/* Subroutine */ int sgerfs_(char *trans, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *ferr, + real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgerqf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *r__, real *c__, real *b, integer *ldb, real *x, + integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, integer *iwork, + integer *info); -/* Subroutine */ int sgesc2_(integer *n, real *a, integer *lda, real *rhs, integer *ipiv, - integer *jpiv, real *scale); +/* Subroutine */ int sgerq2_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sgesdd_(char *jobz, integer *m, integer *n, real *a, integer *lda, real *s, - real *u, integer *ldu, real *vt, integer *ldvt, real *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int sgerqf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgesv_(integer *n, integer *nrhs, real *a, integer *lda, integer *ipiv, - real *b, integer *ldb, integer *info); +/* Subroutine */ int sgesc2_(integer *n, real *a, integer *lda, real *rhs, integer *ipiv, integer *jpiv, real *scale); -/* Subroutine */ int sgesvd_(char *jobu, char *jobvt, integer *m, integer *n, real *a, integer *lda, - real *s, real *u, integer *ldu, real *vt, integer *ldvt, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgesdd_(char *jobz, integer *m, integer *n, real *a, integer *lda, real *s, real *u, integer *ldu, real *vt, integer *ldvt, real *work, integer *lwork, integer *iwork, + integer *info); -/* Subroutine */ int sgesvj_(char *joba, char *jobu, char *jobv, integer *m, integer *n, real *a, - integer *lda, real *sva, integer *mv, real *v, integer *ldv, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sgesv_(integer *n, integer *nrhs, real *a, integer *lda, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int sgesvx_(char *fact, char *trans, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, - real *r__, real *c__, real *b, integer *ldb, real *x, integer *ldx, - real *rcond, real *ferr, real *berr, real *work, integer *iwork, +/* Subroutine */ int sgesvd_(char *jobu, char *jobvt, integer *m, integer *n, real *a, integer *lda, real *s, real *u, integer *ldu, real *vt, integer *ldvt, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, - real *r__, real *c__, real *b, integer *ldb, real *x, integer *ldx, - real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, real *work, integer *iwork, integer *info); - -/* Subroutine */ int sgetc2_(integer *n, real *a, integer *lda, integer *ipiv, integer *jpiv, +/* Subroutine */ int sgesvj_(char *joba, char *jobu, char *jobv, integer *m, integer *n, real *a, integer *lda, real *sva, integer *mv, real *v, integer *ldv, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgetf2_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int sgesvx_(char *fact, char *trans, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, real *r__, real *c__, real *b, + integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgetrf_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int sgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, real *r__, real *c__, real *b, + integer *ldb, real *x, integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, + real *params, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgetri_(integer *n, real *a, integer *lda, integer *ipiv, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sgetc2_(integer *n, real *a, integer *lda, integer *ipiv, integer *jpiv, integer *info); -/* Subroutine */ int sgetrs_(char *trans, integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, integer *info); +/* Subroutine */ int sgetf2_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int sggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - real *lscale, real *rscale, integer *m, real *v, integer *ldv, - integer *info); +/* Subroutine */ int sgetrf_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int sggbal_(char *job, integer *n, real *a, integer *lda, real *b, integer *ldb, - integer *ilo, integer *ihi, real *lscale, real *rscale, real *work, - integer *info); +/* Subroutine */ int sgetri_(integer *n, real *a, integer *lda, integer *ipiv, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, - real *a, integer *lda, real *b, integer *ldb, integer *sdim, - real *alphar, real *alphai, real *beta, real *vsl, integer *ldvsl, - real *vsr, integer *ldvsr, real *work, integer *lwork, logical *bwork, - integer *info); +/* Subroutine */ int sgetrs_(char *trans, integer *n, integer *nrhs, real *a, integer *lda, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int sggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, - integer *n, real *a, integer *lda, real *b, integer *ldb, - integer *sdim, real *alphar, real *alphai, real *beta, real *vsl, - integer *ldvsl, real *vsr, integer *ldvsr, real *rconde, real *rcondv, - real *work, integer *lwork, integer *iwork, integer *liwork, - logical *bwork, integer *info); +/* Subroutine */ int sggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, real *lscale, real *rscale, integer *m, real *v, integer *ldv, integer *info); -/* Subroutine */ int sggev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *b, - integer *ldb, real *alphar, real *alphai, real *beta, real *vl, - integer *ldvl, real *vr, integer *ldvr, real *work, integer *lwork, - integer *info); +/* Subroutine */ int sggbal_(char *job, integer *n, real *a, integer *lda, real *b, integer *ldb, integer *ilo, integer *ihi, real *lscale, real *rscale, real *work, integer *info); -/* Subroutine */ int sggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *alphar, - real *alphai, real *beta, real *vl, integer *ldvl, real *vr, - integer *ldvr, integer *ilo, integer *ihi, real *lscale, real *rscale, - real *abnrm, real *bbnrm, real *rconde, real *rcondv, real *work, - integer *lwork, integer *iwork, logical *bwork, integer *info); +/* Subroutine */ int sgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, real *a, integer *lda, real *b, integer *ldb, integer *sdim, real *alphar, real *alphai, real *beta, + real *vsl, integer *ldvsl, real *vsr, integer *ldvsr, real *work, integer *lwork, logical *bwork, integer *info); -/* Subroutine */ int sggglm_(integer *n, integer *m, integer *p, real *a, integer *lda, real *b, - integer *ldb, real *d__, real *x, real *y, real *work, integer *lwork, +/* Subroutine */ int sggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, integer *n, real *a, integer *lda, real *b, integer *ldb, integer *sdim, real *alphar, real *alphai, + real *beta, real *vsl, integer *ldvsl, real *vsr, integer *ldvsr, real *rconde, real *rcondv, real *work, integer *lwork, integer *iwork, integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int sgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, - real *a, integer *lda, real *b, integer *ldb, real *q, integer *ldq, - real *z__, integer *ldz, integer *info); +/* Subroutine */ int sggev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *vl, integer *ldvl, real *vr, + integer *ldvr, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgglse_(integer *m, integer *n, integer *p, real *a, integer *lda, real *b, - integer *ldb, real *c__, real *d__, real *x, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *vl, + integer *ldvl, real *vr, integer *ldvr, integer *ilo, integer *ihi, real *lscale, real *rscale, real *abnrm, real *bbnrm, real *rconde, real *rcondv, real *work, + integer *lwork, integer *iwork, logical *bwork, integer *info); -/* Subroutine */ int sggqrf_(integer *n, integer *m, integer *p, real *a, integer *lda, real *taua, - real *b, integer *ldb, real *taub, real *work, integer *lwork, - integer *info); +/* Subroutine */ int sggglm_(integer *n, integer *m, integer *p, real *a, integer *lda, real *b, integer *ldb, real *d__, real *x, real *y, real *work, integer *lwork, integer *info); -/* Subroutine */ int sggrqf_(integer *m, integer *p, integer *n, real *a, integer *lda, real *taua, - real *b, integer *ldb, real *taub, real *work, integer *lwork, +/* Subroutine */ int sgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, real *a, integer *lda, real *b, integer *ldb, real *q, integer *ldq, real *z__, integer *ldz, integer *info); -/* Subroutine */ int sggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, - integer *k, integer *l, real *a, integer *lda, real *b, integer *ldb, - real *alpha, real *beta, real *u, integer *ldu, real *v, integer *ldv, - real *q, integer *ldq, real *work, integer *iwork, integer *info); +/* Subroutine */ int sgglse_(integer *m, integer *n, integer *p, real *a, integer *lda, real *b, integer *ldb, real *c__, real *d__, real *x, real *work, integer *lwork, integer *info); -/* Subroutine */ int sggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *tola, real *tolb, - integer *k, integer *l, real *u, integer *ldu, real *v, integer *ldv, - real *q, integer *ldq, integer *iwork, real *tau, real *work, - integer *info); +/* Subroutine */ int sggqrf_(integer *n, integer *m, integer *p, real *a, integer *lda, real *taua, real *b, integer *ldb, real *taub, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgsvj0_(char *jobv, integer *m, integer *n, real *a, integer *lda, real *d__, - real *sva, integer *mv, real *v, integer *ldv, real *eps, real *sfmin, - real *tol, integer *nsweep, real *work, integer *lwork, integer *info); +/* Subroutine */ int sggrqf_(integer *m, integer *p, integer *n, real *a, integer *lda, real *taua, real *b, integer *ldb, real *taub, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgsvj1_(char *jobv, integer *m, integer *n, integer *n1, real *a, integer *lda, - real *d__, real *sva, integer *mv, real *v, integer *ldv, real *eps, - real *sfmin, real *tol, integer *nsweep, real *work, integer *lwork, - integer *info); +/* Subroutine */ int sggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, integer *k, integer *l, real *a, integer *lda, real *b, integer *ldb, real *alpha, real *beta, + real *u, integer *ldu, real *v, integer *ldv, real *q, integer *ldq, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgtcon_(char *norm, integer *n, real *dl, real *d__, real *du, real *du2, - integer *ipiv, real *anorm, real *rcond, real *work, integer *iwork, - integer *info); +/* Subroutine */ int sggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, real *a, integer *lda, real *b, integer *ldb, real *tola, real *tolb, integer *k, integer *l, + real *u, integer *ldu, real *v, integer *ldv, real *q, integer *ldq, integer *iwork, real *tau, real *work, integer *info); -/* Subroutine */ int sgtrfs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, real *du, - real *dlf, real *df, real *duf, real *du2, integer *ipiv, real *b, - integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info); +/* Subroutine */ int sgsvj0_(char *jobv, integer *m, integer *n, real *a, integer *lda, real *d__, real *sva, integer *mv, real *v, integer *ldv, real *eps, real *sfmin, real *tol, integer *nsweep, + real *work, integer *lwork, integer *info); -/* Subroutine */ int sgtsv_(integer *n, integer *nrhs, real *dl, real *d__, real *du, real *b, - integer *ldb, integer *info); +/* Subroutine */ int sgsvj1_(char *jobv, integer *m, integer *n, integer *n1, real *a, integer *lda, real *d__, real *sva, integer *mv, real *v, integer *ldv, real *eps, real *sfmin, real *tol, + integer *nsweep, real *work, integer *lwork, integer *info); -/* Subroutine */ int sgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, real *dl, - real *d__, real *du, real *dlf, real *df, real *duf, real *du2, - integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, - real *rcond, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int sgtcon_(char *norm, integer *n, real *dl, real *d__, real *du, real *du2, integer *ipiv, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgttrf_(integer *n, real *dl, real *d__, real *du, real *du2, integer *ipiv, - integer *info); +/* Subroutine */ int sgtrfs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, real *du, real *dlf, real *df, real *duf, real *du2, integer *ipiv, real *b, integer *ldb, real *x, + integer *ldx, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sgttrs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, real *du, - real *du2, integer *ipiv, real *b, integer *ldb, integer *info); +/* Subroutine */ int sgtsv_(integer *n, integer *nrhs, real *dl, real *d__, real *du, real *b, integer *ldb, integer *info); -/* Subroutine */ int sgtts2_(integer *itrans, integer *n, integer *nrhs, real *dl, real *d__, - real *du, real *du2, integer *ipiv, real *b, integer *ldb); +/* Subroutine */ int sgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, real *dl, real *d__, real *du, real *dlf, real *df, real *duf, real *du2, integer *ipiv, real *b, integer *ldb, + real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int shgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, real *h__, integer *ldh, real *t, integer *ldt, - real *alphar, real *alphai, real *beta, real *q, integer *ldq, - real *z__, integer *ldz, real *work, integer *lwork, integer *info); +/* Subroutine */ int sgttrf_(integer *n, real *dl, real *d__, real *du, real *du2, integer *ipiv, integer *info); -/* Subroutine */ int shsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, - real *h__, integer *ldh, real *wr, real *wi, real *vl, integer *ldvl, - real *vr, integer *ldvr, integer *mm, integer *m, real *work, - integer *ifaill, integer *ifailr, integer *info); +/* Subroutine */ int sgttrs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, real *du, real *du2, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int shseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, - real *h__, integer *ldh, real *wr, real *wi, real *z__, integer *ldz, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sgtts2_(integer *itrans, integer *n, integer *nrhs, real *dl, real *d__, real *du, real *du2, integer *ipiv, real *b, integer *ldb); + +/* Subroutine */ int shgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, integer *ihi, real *h__, integer *ldh, real *t, integer *ldt, real *alphar, real *alphai, real *beta, + real *q, integer *ldq, real *z__, integer *ldz, real *work, integer *lwork, integer *info); + +/* Subroutine */ int shsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, real *h__, integer *ldh, real *wr, real *wi, real *vl, integer *ldvl, real *vr, integer *ldvr, + integer *mm, integer *m, real *work, integer *ifaill, integer *ifailr, integer *info); + +/* Subroutine */ int shseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, real *h__, integer *ldh, real *wr, real *wi, real *z__, integer *ldz, real *work, integer *lwork, + integer *info); logical sisnan_(real *sin__); -/* Subroutine */ int sla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, - real *alpha, real *ab, integer *ldab, real *x, integer *incx, - real *beta, real *y, integer *incy); +/* Subroutine */ int sla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, real *alpha, real *ab, integer *ldab, real *x, integer *incx, real *beta, real *y, integer *incy); -doublereal sla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, - real *afb, integer *ldafb, integer *ipiv, integer *cmode, real *c__, - integer *info, real *work, integer *iwork, ftnlen trans_len); +doublereal sla_gbrcond__(char *trans, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, integer *cmode, real *c__, integer *info, real *work, + integer *iwork, ftnlen trans_len); -/* Subroutine */ int sla_gbrfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, - real *ab, integer *ldab, real *afb, integer *ldafb, integer *ipiv, logical *colequ, real *c__, - real *b, integer *ldb, real *y, integer *ldy, real *berr_out__, integer *n_norms__, - real *errs_n__, real *errs_c__, real *res, real *ayb, real *dy, real *y_tail__, real *rcond, - integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info); +/* Subroutine */ int sla_gbrfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, + integer *ipiv, logical *colequ, real *c__, real *b, integer *ldb, real *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, + real *errs_c__, real *res, real *ayb, real *dy, real *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, + integer *info); -doublereal sla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, real *ab, - integer *ldab, real *afb, integer *ldafb); +doublereal sla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, real *ab, integer *ldab, real *afb, integer *ldafb); -/* Subroutine */ int sla_geamv__(integer *trans, integer *m, integer *n, real *alpha, real *a, - integer *lda, real *x, integer *incx, real *beta, real *y, - integer *incy); +/* Subroutine */ int sla_geamv__(integer *trans, integer *m, integer *n, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); -doublereal sla_gercond__(char *trans, integer *n, real *a, integer *lda, real *af, integer *ldaf, - integer *ipiv, integer *cmode, real *c__, integer *info, real *work, - integer *iwork, ftnlen trans_len); +doublereal sla_gercond__(char *trans, integer *n, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, integer *cmode, real *c__, integer *info, real *work, integer *iwork, + ftnlen trans_len); -/* Subroutine */ int sla_gerfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, real *a, integer *lda, - real *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, real *b, integer *ldb, - real *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, - real *res, real *ayb, real *dy, real *y_tail__, real *rcond, integer *ithresh, real *rthresh, - real *dz_ub__, logical *ignore_cwise__, integer *info); +/* Subroutine */ int sla_gerfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, logical *colequ, + real *c__, real *b, integer *ldb, real *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, real *res, real *ayb, + real *dy, real *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info); -/* Subroutine */ int sla_lin_berr__(integer *n, integer *nz, integer *nrhs, real *res, real *ayb, - real *berr); +/* Subroutine */ int sla_lin_berr__(integer *n, integer *nz, integer *nrhs, real *res, real *ayb, real *berr); -doublereal sla_porcond__(char *uplo, integer *n, real *a, integer *lda, real *af, integer *ldaf, - integer *cmode, real *c__, integer *info, real *work, integer *iwork, - ftnlen uplo_len); +doublereal sla_porcond__(char *uplo, integer *n, real *a, integer *lda, real *af, integer *ldaf, integer *cmode, real *c__, integer *info, real *work, integer *iwork, ftnlen uplo_len); -/* Subroutine */ int sla_porfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, - integer *ldaf, logical *colequ, real *c__, real *b, integer *ldb, real *y, integer *ldy, - real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, real *res, real *ayb, - real *dy, real *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, - logical *ignore_cwise__, integer *info, ftnlen uplo_len); +/* Subroutine */ int sla_porfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, logical *colequ, real *c__, real *b, + integer *ldb, real *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, real *res, real *ayb, real *dy, real *y_tail__, + real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal sla_porpvgrw__(char *uplo, integer *ncols, real *a, integer *lda, real *af, - integer *ldaf, real *work, ftnlen uplo_len); +doublereal sla_porpvgrw__(char *uplo, integer *ncols, real *a, integer *lda, real *af, integer *ldaf, real *work, ftnlen uplo_len); doublereal sla_rpvgrw__(integer *n, integer *ncols, real *a, integer *lda, real *af, integer *ldaf); -/* Subroutine */ int sla_syamv__(integer *uplo, integer *n, real *alpha, real *a, integer *lda, - real *x, integer *incx, real *beta, real *y, integer *incy); +/* Subroutine */ int sla_syamv__(integer *uplo, integer *n, real *alpha, real *a, integer *lda, real *x, integer *incx, real *beta, real *y, integer *incy); -doublereal sla_syrcond__(char *uplo, integer *n, real *a, integer *lda, real *af, integer *ldaf, - integer *ipiv, integer *cmode, real *c__, integer *info, real *work, - integer *iwork, ftnlen uplo_len); +doublereal sla_syrcond__(char *uplo, integer *n, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, integer *cmode, real *c__, integer *info, real *work, integer *iwork, ftnlen uplo_len); -/* Subroutine */ int sla_syrfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, - integer *ldaf, integer *ipiv, logical *colequ, real *c__, real *b, integer *ldb, real *y, - integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, real *res, - real *ayb, real *dy, real *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, - logical *ignore_cwise__, integer *info, ftnlen uplo_len); +/* Subroutine */ int sla_syrfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, logical *colequ, real *c__, + real *b, integer *ldb, real *y, integer *ldy, real *berr_out__, integer *n_norms__, real *errs_n__, real *errs_c__, real *res, real *ayb, real *dy, + real *y_tail__, real *rcond, integer *ithresh, real *rthresh, real *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal sla_syrpvgrw__(char *uplo, integer *n, integer *info, real *a, integer *lda, real *af, - integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); +doublereal sla_syrpvgrw__(char *uplo, integer *n, integer *info, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *work, ftnlen uplo_len); /* Subroutine */ int sla_wwaddw__(integer *n, real *x, real *y, real *w); /* Subroutine */ int slabad_(real *small, real *large); -/* Subroutine */ int slabrd_(integer *m, integer *n, integer *nb, real *a, integer *lda, real *d__, - real *e, real *tauq, real *taup, real *x, integer *ldx, real *y, - integer *ldy); +/* Subroutine */ int slabrd_(integer *m, integer *n, integer *nb, real *a, integer *lda, real *d__, real *e, real *tauq, real *taup, real *x, integer *ldx, real *y, integer *ldy); -/* Subroutine */ int slacn2_(integer *n, real *v, real *x, integer *isgn, real *est, integer *kase, - integer *isave); +/* Subroutine */ int slacn2_(integer *n, real *v, real *x, integer *isgn, real *est, integer *kase, integer *isave); /* Subroutine */ int slacon_(integer *n, real *v, real *x, integer *isgn, real *est, integer *kase); -/* Subroutine */ int slacpy_(char *uplo, integer *m, integer *n, real *a, integer *lda, real *b, - integer *ldb); +/* Subroutine */ int slacpy_(char *uplo, integer *m, integer *n, real *a, integer *lda, real *b, integer *ldb); /* Subroutine */ int sladiv_(real *a, real *b, real *c__, real *d__, real *p, real *q); /* Subroutine */ int slae2_(real *a, real *b, real *c__, real *rt1, real *rt2); -/* Subroutine */ int slaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, - integer *minp, integer *nbmin, real *abstol, real *reltol, - real *pivmin, real *d__, real *e, real *e2, integer *nval, real *ab, - real *c__, integer *mout, integer *nab, real *work, integer *iwork, - integer *info); +/* Subroutine */ int slaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, integer *minp, integer *nbmin, real *abstol, real *reltol, real *pivmin, real *d__, real *e, real *e2, + integer *nval, real *ab, real *c__, integer *mout, integer *nab, real *work, integer *iwork, integer *info); -/* Subroutine */ int slaed0_(integer *icompq, integer *qsiz, integer *n, real *d__, real *e, - real *q, integer *ldq, real *qstore, integer *ldqs, real *work, - integer *iwork, integer *info); +/* Subroutine */ int slaed0_(integer *icompq, integer *qsiz, integer *n, real *d__, real *e, real *q, integer *ldq, real *qstore, integer *ldqs, real *work, integer *iwork, integer *info); -/* Subroutine */ int slaed1_(integer *n, real *d__, real *q, integer *ldq, integer *indxq, - real *rho, integer *cutpnt, real *work, integer *iwork, integer *info); +/* Subroutine */ int slaed1_(integer *n, real *d__, real *q, integer *ldq, integer *indxq, real *rho, integer *cutpnt, real *work, integer *iwork, integer *info); -/* Subroutine */ int slaed2_(integer *k, integer *n, integer *n1, real *d__, real *q, integer *ldq, - integer *indxq, real *rho, real *z__, real *dlamda, real *w, real *q2, - integer *indx, integer *indxc, integer *indxp, integer *coltyp, - integer *info); +/* Subroutine */ int slaed2_(integer *k, integer *n, integer *n1, real *d__, real *q, integer *ldq, integer *indxq, real *rho, real *z__, real *dlamda, real *w, real *q2, integer *indx, + integer *indxc, integer *indxp, integer *coltyp, integer *info); -/* Subroutine */ int slaed3_(integer *k, integer *n, integer *n1, real *d__, real *q, integer *ldq, - real *rho, real *dlamda, real *q2, integer *indx, integer *ctot, - real *w, real *s, integer *info); +/* Subroutine */ int slaed3_(integer *k, integer *n, integer *n1, real *d__, real *q, integer *ldq, real *rho, real *dlamda, real *q2, integer *indx, integer *ctot, real *w, real *s, integer *info); -/* Subroutine */ int slaed4_(integer *n, integer *i__, real *d__, real *z__, real *delta, real *rho, - real *dlam, integer *info); +/* Subroutine */ int slaed4_(integer *n, integer *i__, real *d__, real *z__, real *delta, real *rho, real *dlam, integer *info); -/* Subroutine */ int slaed5_(integer *i__, real *d__, real *z__, real *delta, real *rho, - real *dlam); +/* Subroutine */ int slaed5_(integer *i__, real *d__, real *z__, real *delta, real *rho, real *dlam); -/* Subroutine */ int slaed6_(integer *kniter, logical *orgati, real *rho, real *d__, real *z__, - real *finit, real *tau, integer *info); +/* Subroutine */ int slaed6_(integer *kniter, logical *orgati, real *rho, real *d__, real *z__, real *finit, real *tau, integer *info); -/* Subroutine */ int slaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, real *d__, real *q, integer *ldq, - integer *indxq, real *rho, integer *cutpnt, real *qstore, - integer *qptr, integer *prmptr, integer *perm, integer *givptr, - integer *givcol, real *givnum, real *work, integer *iwork, - integer *info); +/* Subroutine */ int slaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, integer *curlvl, integer *curpbm, real *d__, real *q, integer *ldq, integer *indxq, real *rho, integer *cutpnt, + real *qstore, integer *qptr, integer *prmptr, integer *perm, integer *givptr, integer *givcol, real *givnum, real *work, integer *iwork, integer *info); -/* Subroutine */ int slaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, real *d__, - real *q, integer *ldq, integer *indxq, real *rho, integer *cutpnt, - real *z__, real *dlamda, real *q2, integer *ldq2, real *w, - integer *perm, integer *givptr, integer *givcol, real *givnum, - integer *indxp, integer *indx, integer *info); +/* Subroutine */ int slaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, real *d__, real *q, integer *ldq, integer *indxq, real *rho, integer *cutpnt, real *z__, real *dlamda, real *q2, + integer *ldq2, real *w, integer *perm, integer *givptr, integer *givcol, real *givnum, integer *indxp, integer *indx, integer *info); -/* Subroutine */ int slaed9_(integer *k, integer *kstart, integer *kstop, integer *n, real *d__, - real *q, integer *ldq, real *rho, real *dlamda, real *w, real *s, - integer *lds, integer *info); +/* Subroutine */ int slaed9_(integer *k, integer *kstart, integer *kstop, integer *n, real *d__, real *q, integer *ldq, real *rho, real *dlamda, real *w, real *s, integer *lds, integer *info); -/* Subroutine */ int slaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, - integer *prmptr, integer *perm, integer *givptr, integer *givcol, - real *givnum, real *q, integer *qptr, real *z__, real *ztemp, - integer *info); +/* Subroutine */ int slaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, integer *prmptr, integer *perm, integer *givptr, integer *givcol, real *givnum, real *q, integer *qptr, + real *z__, real *ztemp, integer *info); -/* Subroutine */ int slaein_(logical *rightv, logical *noinit, integer *n, real *h__, integer *ldh, - real *wr, real *wi, real *vr, real *vi, real *b, integer *ldb, - real *work, real *eps3, real *smlnum, real *bignum, integer *info); +/* Subroutine */ int slaein_(logical *rightv, logical *noinit, integer *n, real *h__, integer *ldh, real *wr, real *wi, real *vr, real *vi, real *b, integer *ldb, real *work, real *eps3, real *smlnum, + real *bignum, integer *info); -/* Subroutine */ int slaev2_(real *a, real *b, real *c__, real *rt1, real *rt2, real *cs1, - real *sn1); +/* Subroutine */ int slaev2_(real *a, real *b, real *c__, real *rt1, real *rt2, real *cs1, real *sn1); -/* Subroutine */ int slaexc_(logical *wantq, integer *n, real *t, integer *ldt, real *q, - integer *ldq, integer *j1, integer *n1, integer *n2, real *work, - integer *info); +/* Subroutine */ int slaexc_(logical *wantq, integer *n, real *t, integer *ldt, real *q, integer *ldq, integer *j1, integer *n1, integer *n2, real *work, integer *info); -/* Subroutine */ int slag2_(real *a, integer *lda, real *b, integer *ldb, real *safmin, - real *scale1, real *scale2, real *wr1, real *wr2, real *wi); +/* Subroutine */ int slag2_(real *a, integer *lda, real *b, integer *ldb, real *safmin, real *scale1, real *scale2, real *wr1, real *wr2, real *wi); -/* Subroutine */ int slag2d_(integer *m, integer *n, real *sa, integer *ldsa, doublereal *a, - integer *lda, integer *info); +/* Subroutine */ int slag2d_(integer *m, integer *n, real *sa, integer *ldsa, doublereal *a, integer *lda, integer *info); -/* Subroutine */ int slags2_(logical *upper, real *a1, real *a2, real *a3, real *b1, real *b2, - real *b3, real *csu, real *snu, real *csv, real *snv, real *csq, - real *snq); +/* Subroutine */ int slags2_(logical *upper, real *a1, real *a2, real *a3, real *b1, real *b2, real *b3, real *csu, real *snu, real *csv, real *snv, real *csq, real *snq); -/* Subroutine */ int slagtf_(integer *n, real *a, real *lambda, real *b, real *c__, real *tol, - real *d__, integer *in, integer *info); +/* Subroutine */ int slagtf_(integer *n, real *a, real *lambda, real *b, real *c__, real *tol, real *d__, integer *in, integer *info); -/* Subroutine */ int slagtm_(char *trans, integer *n, integer *nrhs, real *alpha, real *dl, - real *d__, real *du, real *x, integer *ldx, real *beta, real *b, - integer *ldb); +/* Subroutine */ int slagtm_(char *trans, integer *n, integer *nrhs, real *alpha, real *dl, real *d__, real *du, real *x, integer *ldx, real *beta, real *b, integer *ldb); -/* Subroutine */ int slagts_(integer *job, integer *n, real *a, real *b, real *c__, real *d__, - integer *in, real *y, real *tol, integer *info); +/* Subroutine */ int slagts_(integer *job, integer *n, real *a, real *b, real *c__, real *d__, integer *in, real *y, real *tol, integer *info); -/* Subroutine */ int slagv2_(real *a, integer *lda, real *b, integer *ldb, real *alphar, - real *alphai, real *beta, real *csl, real *snl, real *csr, real *snr); +/* Subroutine */ int slagv2_(real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *csl, real *snl, real *csr, real *snr); -/* Subroutine */ int slahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - real *h__, integer *ldh, real *wr, real *wi, integer *iloz, - integer *ihiz, real *z__, integer *ldz, integer *info); +/* Subroutine */ int slahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, real *h__, integer *ldh, real *wr, real *wi, integer *iloz, integer *ihiz, real *z__, integer *ldz, + integer *info); -/* Subroutine */ int slahr2_(integer *n, integer *k, integer *nb, real *a, integer *lda, real *tau, - real *t, integer *ldt, real *y, integer *ldy); +/* Subroutine */ int slahr2_(integer *n, integer *k, integer *nb, real *a, integer *lda, real *tau, real *t, integer *ldt, real *y, integer *ldy); -/* Subroutine */ int slahrd_(integer *n, integer *k, integer *nb, real *a, integer *lda, real *tau, - real *t, integer *ldt, real *y, integer *ldy); +/* Subroutine */ int slahrd_(integer *n, integer *k, integer *nb, real *a, integer *lda, real *tau, real *t, integer *ldt, real *y, integer *ldy); -/* Subroutine */ int slaic1_(integer *job, integer *j, real *x, real *sest, real *w, real *gamma, - real *sestpr, real *s, real *c__); +/* Subroutine */ int slaic1_(integer *job, integer *j, real *x, real *sest, real *w, real *gamma, real *sestpr, real *s, real *c__); logical slaisnan_(real *sin1, real *sin2); -/* Subroutine */ int slaln2_(logical *ltrans, integer *na, integer *nw, real *smin, real *ca, - real *a, integer *lda, real *d1, real *d2, real *b, integer *ldb, - real *wr, real *wi, real *x, integer *ldx, real *scale, real *xnorm, - integer *info); +/* Subroutine */ int slaln2_(logical *ltrans, integer *na, integer *nw, real *smin, real *ca, real *a, integer *lda, real *d1, real *d2, real *b, integer *ldb, real *wr, real *wi, real *x, + integer *ldx, real *scale, real *xnorm, integer *info); + +/* Subroutine */ int slals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *nrhs, real *b, integer *ldb, real *bx, integer *ldbx, integer *perm, integer *givptr, integer *givcol, + integer *ldgcol, real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, real *z__, integer *k, real *c__, real *s, real *work, integer *info); -/* Subroutine */ int slals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, real *b, integer *ldb, real *bx, integer *ldbx, - integer *perm, integer *givptr, integer *givcol, integer *ldgcol, - real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *work, integer *info); - -/* Subroutine */ int slalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, real *b, - integer *ldb, real *bx, integer *ldbx, real *u, integer *ldu, real *vt, - integer *k, real *difl, real *difr, real *z__, real *poles, - integer *givptr, integer *givcol, integer *ldgcol, integer *perm, - real *givnum, real *c__, real *s, real *work, integer *iwork, +/* Subroutine */ int slalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, real *b, integer *ldb, real *bx, integer *ldbx, real *u, integer *ldu, real *vt, integer *k, real *difl, + real *difr, real *z__, real *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, real *givnum, real *c__, real *s, real *work, integer *iwork, integer *info); -/* Subroutine */ int slalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, real *d__, - real *e, real *b, integer *ldb, real *rcond, integer *rank, real *work, - integer *iwork, integer *info); +/* Subroutine */ int slalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb, real *rcond, integer *rank, real *work, integer *iwork, integer *info); -/* Subroutine */ int slamrg_(integer *n1, integer *n2, real *a, integer *strd1, integer *strd2, - integer *index); +/* Subroutine */ int slamrg_(integer *n1, integer *n2, real *a, integer *strd1, integer *strd2, integer *index); integer slaneg_(integer *n, real *d__, real *lld, real *sigma, real *pivmin, integer *r__); -doublereal slangb_(char *norm, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, - real *work); +doublereal slangb_(char *norm, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, real *work); doublereal slange_(char *norm, integer *m, integer *n, real *a, integer *lda, real *work); @@ -4218,8 +2668,7 @@ doublereal slangt_(char *norm, integer *n, real *dl, real *d__, real *du); doublereal slanhs_(char *norm, integer *n, real *a, integer *lda, real *work); -doublereal slansb_(char *norm, char *uplo, integer *n, integer *k, real *ab, integer *ldab, - real *work); +doublereal slansb_(char *norm, char *uplo, integer *n, integer *k, real *ab, integer *ldab, real *work); doublereal slansf_(char *norm, char *transr, char *uplo, integer *n, real *a, real *work); @@ -4229,476 +2678,308 @@ doublereal slanst_(char *norm, integer *n, real *d__, real *e); doublereal slansy_(char *norm, char *uplo, integer *n, real *a, integer *lda, real *work); -doublereal slantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, real *ab, - integer *ldab, real *work); +doublereal slantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, real *ab, integer *ldab, real *work); doublereal slantp_(char *norm, char *uplo, char *diag, integer *n, real *ap, real *work); -doublereal slantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, real *a, - integer *lda, real *work); +doublereal slantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, real *a, integer *lda, real *work); -/* Subroutine */ int slanv2_(real *a, real *b, real *c__, real *d__, real *rt1r, real *rt1i, - real *rt2r, real *rt2i, real *cs, real *sn); +/* Subroutine */ int slanv2_(real *a, real *b, real *c__, real *d__, real *rt1r, real *rt1i, real *rt2r, real *rt2i, real *cs, real *sn); -/* Subroutine */ int slapll_(integer *n, real *x, integer *incx, real *y, integer *incy, - real *ssmin); +/* Subroutine */ int slapll_(integer *n, real *x, integer *incx, real *y, integer *incy, real *ssmin); -/* Subroutine */ int slapmt_(logical *forwrd, integer *m, integer *n, real *x, integer *ldx, - integer *k); +/* Subroutine */ int slapmt_(logical *forwrd, integer *m, integer *n, real *x, integer *ldx, integer *k); doublereal slapy2_(real *x, real *y); doublereal slapy3_(real *x, real *y, real *z__); -/* Subroutine */ int slaqgb_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, - real *amax, char *equed); +/* Subroutine */ int slaqgb_(integer *m, integer *n, integer *kl, integer *ku, real *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, char *equed); -/* Subroutine */ int slaqge_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, char *equed); +/* Subroutine */ int slaqge_(integer *m, integer *n, real *a, integer *lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, char *equed); -/* Subroutine */ int slaqp2_(integer *m, integer *n, integer *offset, real *a, integer *lda, - integer *jpvt, real *tau, real *vn1, real *vn2, real *work); +/* Subroutine */ int slaqp2_(integer *m, integer *n, integer *offset, real *a, integer *lda, integer *jpvt, real *tau, real *vn1, real *vn2, real *work); -/* Subroutine */ int slaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, - real *a, integer *lda, integer *jpvt, real *tau, real *vn1, real *vn2, - real *auxv, real *f, integer *ldf); +/* Subroutine */ int slaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, real *a, integer *lda, integer *jpvt, real *tau, real *vn1, real *vn2, real *auxv, real *f, + integer *ldf); -/* Subroutine */ int slaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - real *h__, integer *ldh, real *wr, real *wi, integer *iloz, - integer *ihiz, real *z__, integer *ldz, real *work, integer *lwork, - integer *info); +/* Subroutine */ int slaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, real *h__, integer *ldh, real *wr, real *wi, integer *iloz, integer *ihiz, real *z__, integer *ldz, + real *work, integer *lwork, integer *info); -/* Subroutine */ int slaqr1_(integer *n, real *h__, integer *ldh, real *sr1, real *si1, real *sr2, - real *si2, real *v); - -/* Subroutine */ int slaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, real *h__, integer *ldh, integer *iloz, - integer *ihiz, real *z__, integer *ldz, integer *ns, integer *nd, - real *sr, real *si, real *v, integer *ldv, integer *nh, real *t, - integer *ldt, integer *nv, real *wv, integer *ldwv, real *work, - integer *lwork); - -/* Subroutine */ int slaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, real *h__, integer *ldh, integer *iloz, - integer *ihiz, real *z__, integer *ldz, integer *ns, integer *nd, - real *sr, real *si, real *v, integer *ldv, integer *nh, real *t, - integer *ldt, integer *nv, real *wv, integer *ldwv, real *work, - integer *lwork); - -/* Subroutine */ int slaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - real *h__, integer *ldh, real *wr, real *wi, integer *iloz, - integer *ihiz, real *z__, integer *ldz, real *work, integer *lwork, - integer *info); +/* Subroutine */ int slaqr1_(integer *n, real *h__, integer *ldh, real *sr1, real *si1, real *sr2, real *si2, real *v); -/* Subroutine */ int slaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, - integer *ktop, integer *kbot, integer *nshfts, real *sr, real *si, - real *h__, integer *ldh, integer *iloz, integer *ihiz, real *z__, - integer *ldz, real *v, integer *ldv, real *u, integer *ldu, - integer *nv, real *wv, integer *ldwv, integer *nh, real *wh, - integer *ldwh); +/* Subroutine */ int slaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, real *h__, integer *ldh, integer *iloz, integer *ihiz, real *z__, integer *ldz, + integer *ns, integer *nd, real *sr, real *si, real *v, integer *ldv, integer *nh, real *t, integer *ldt, integer *nv, real *wv, integer *ldwv, real *work, integer *lwork); -/* Subroutine */ int slaqsb_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *s, - real *scond, real *amax, char *equed); +/* Subroutine */ int slaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, real *h__, integer *ldh, integer *iloz, integer *ihiz, real *z__, integer *ldz, + integer *ns, integer *nd, real *sr, real *si, real *v, integer *ldv, integer *nh, real *t, integer *ldt, integer *nv, real *wv, integer *ldwv, real *work, integer *lwork); -/* Subroutine */ int slaqsp_(char *uplo, integer *n, real *ap, real *s, real *scond, real *amax, - char *equed); +/* Subroutine */ int slaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, real *h__, integer *ldh, real *wr, real *wi, integer *iloz, integer *ihiz, real *z__, integer *ldz, + real *work, integer *lwork, integer *info); -/* Subroutine */ int slaqsy_(char *uplo, integer *n, real *a, integer *lda, real *s, real *scond, - real *amax, char *equed); +/* Subroutine */ int slaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, integer *ktop, integer *kbot, integer *nshfts, real *sr, real *si, real *h__, integer *ldh, integer *iloz, + integer *ihiz, real *z__, integer *ldz, real *v, integer *ldv, real *u, integer *ldu, integer *nv, real *wv, integer *ldwv, integer *nh, real *wh, integer *ldwh); -/* Subroutine */ int slaqtr_(logical *ltran, logical *lreal, integer *n, real *t, integer *ldt, - real *b, real *w, real *scale, real *x, real *work, integer *info); +/* Subroutine */ int slaqsb_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int slar1v_(integer *n, integer *b1, integer *bn, real *lambda, real *d__, real *l, - real *ld, real *lld, real *pivmin, real *gaptol, real *z__, - logical *wantnc, integer *negcnt, real *ztz, real *mingma, - integer *r__, integer *isuppz, real *nrminv, real *resid, real *rqcorr, - real *work); +/* Subroutine */ int slaqsp_(char *uplo, integer *n, real *ap, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int slar2v_(integer *n, real *x, real *y, real *z__, integer *incx, real *c__, - real *s, integer *incc); +/* Subroutine */ int slaqsy_(char *uplo, integer *n, real *a, integer *lda, real *s, real *scond, real *amax, char *equed); -/* Subroutine */ int slarf_(char *side, integer *m, integer *n, real *v, integer *incv, real *tau, - real *c__, integer *ldc, real *work); +/* Subroutine */ int slaqtr_(logical *ltran, logical *lreal, integer *n, real *t, integer *ldt, real *b, real *w, real *scale, real *x, real *work, integer *info); -/* Subroutine */ int slarfb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, real *v, integer *ldv, real *t, integer *ldt, - real *c__, integer *ldc, real *work, integer *ldwork); +/* Subroutine */ int slar1v_(integer *n, integer *b1, integer *bn, real *lambda, real *d__, real *l, real *ld, real *lld, real *pivmin, real *gaptol, real *z__, logical *wantnc, integer *negcnt, + real *ztz, real *mingma, integer *r__, integer *isuppz, real *nrminv, real *resid, real *rqcorr, real *work); + +/* Subroutine */ int slar2v_(integer *n, real *x, real *y, real *z__, integer *incx, real *c__, real *s, integer *incc); + +/* Subroutine */ int slarf_(char *side, integer *m, integer *n, real *v, integer *incv, real *tau, real *c__, integer *ldc, real *work); + +/* Subroutine */ int slarfb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, real *v, integer *ldv, real *t, integer *ldt, real *c__, integer *ldc, real *work, + integer *ldwork); /* Subroutine */ int slarfg_(integer *n, real *alpha, real *x, integer *incx, real *tau); /* Subroutine */ int slarfp_(integer *n, real *alpha, real *x, integer *incx, real *tau); -/* Subroutine */ int slarft_(char *direct, char *storev, integer *n, integer *k, real *v, - integer *ldv, real *tau, real *t, integer *ldt); +/* Subroutine */ int slarft_(char *direct, char *storev, integer *n, integer *k, real *v, integer *ldv, real *tau, real *t, integer *ldt); -/* Subroutine */ int slarfx_(char *side, integer *m, integer *n, real *v, real *tau, real *c__, - integer *ldc, real *work); +/* Subroutine */ int slarfx_(char *side, integer *m, integer *n, real *v, real *tau, real *c__, integer *ldc, real *work); -/* Subroutine */ int slargv_(integer *n, real *x, integer *incx, real *y, integer *incy, real *c__, - integer *incc); +/* Subroutine */ int slargv_(integer *n, real *x, integer *incx, real *y, integer *incy, real *c__, integer *incc); /* Subroutine */ int slarnv_(integer *idist, integer *iseed, integer *n, real *x); -/* Subroutine */ int slarra_(integer *n, real *d__, real *e, real *e2, real *spltol, real *tnrm, - integer *nsplit, integer *isplit, integer *info); +/* Subroutine */ int slarra_(integer *n, real *d__, real *e, real *e2, real *spltol, real *tnrm, integer *nsplit, integer *isplit, integer *info); -/* Subroutine */ int slarrb_(integer *n, real *d__, real *lld, integer *ifirst, integer *ilast, - real *rtol1, real *rtol2, integer *offset, real *w, real *wgap, - real *werr, real *work, integer *iwork, real *pivmin, real *spdiam, - integer *twist, integer *info); +/* Subroutine */ int slarrb_(integer *n, real *d__, real *lld, integer *ifirst, integer *ilast, real *rtol1, real *rtol2, integer *offset, real *w, real *wgap, real *werr, real *work, integer *iwork, + real *pivmin, real *spdiam, integer *twist, integer *info); -/* Subroutine */ int slarrc_(char *jobt, integer *n, real *vl, real *vu, real *d__, real *e, - real *pivmin, integer *eigcnt, integer *lcnt, integer *rcnt, - integer *info); +/* Subroutine */ int slarrc_(char *jobt, integer *n, real *vl, real *vu, real *d__, real *e, real *pivmin, integer *eigcnt, integer *lcnt, integer *rcnt, integer *info); -/* Subroutine */ int slarrd_(char *range, char *order, integer *n, real *vl, real *vu, integer *il, - integer *iu, real *gers, real *reltol, real *d__, real *e, real *e2, - real *pivmin, integer *nsplit, integer *isplit, integer *m, real *w, - real *werr, real *wl, real *wu, integer *iblock, integer *indexw, - real *work, integer *iwork, integer *info); +/* Subroutine */ int slarrd_(char *range, char *order, integer *n, real *vl, real *vu, integer *il, integer *iu, real *gers, real *reltol, real *d__, real *e, real *e2, real *pivmin, integer *nsplit, + integer *isplit, integer *m, real *w, real *werr, real *wl, real *wu, integer *iblock, integer *indexw, real *work, integer *iwork, integer *info); -/* Subroutine */ int slarre_(char *range, integer *n, real *vl, real *vu, integer *il, integer *iu, - real *d__, real *e, real *e2, real *rtol1, real *rtol2, real *spltol, - integer *nsplit, integer *isplit, integer *m, real *w, real *werr, - real *wgap, integer *iblock, integer *indexw, real *gers, real *pivmin, - real *work, integer *iwork, integer *info); +/* Subroutine */ int slarre_(char *range, integer *n, real *vl, real *vu, integer *il, integer *iu, real *d__, real *e, real *e2, real *rtol1, real *rtol2, real *spltol, integer *nsplit, + integer *isplit, integer *m, real *w, real *werr, real *wgap, integer *iblock, integer *indexw, real *gers, real *pivmin, real *work, integer *iwork, integer *info); -/* Subroutine */ int slarrf_(integer *n, real *d__, real *l, real *ld, integer *clstrt, - integer *clend, real *w, real *wgap, real *werr, real *spdiam, - real *clgapl, real *clgapr, real *pivmin, real *sigma, real *dplus, - real *lplus, real *work, integer *info); +/* Subroutine */ int slarrf_(integer *n, real *d__, real *l, real *ld, integer *clstrt, integer *clend, real *w, real *wgap, real *werr, real *spdiam, real *clgapl, real *clgapr, real *pivmin, + real *sigma, real *dplus, real *lplus, real *work, integer *info); -/* Subroutine */ int slarrj_(integer *n, real *d__, real *e2, integer *ifirst, integer *ilast, - real *rtol, integer *offset, real *w, real *werr, real *work, - integer *iwork, real *pivmin, real *spdiam, integer *info); +/* Subroutine */ int slarrj_(integer *n, real *d__, real *e2, integer *ifirst, integer *ilast, real *rtol, integer *offset, real *w, real *werr, real *work, integer *iwork, real *pivmin, real *spdiam, + integer *info); -/* Subroutine */ int slarrk_(integer *n, integer *iw, real *gl, real *gu, real *d__, real *e2, - real *pivmin, real *reltol, real *w, real *werr, integer *info); +/* Subroutine */ int slarrk_(integer *n, integer *iw, real *gl, real *gu, real *d__, real *e2, real *pivmin, real *reltol, real *w, real *werr, integer *info); /* Subroutine */ int slarrr_(integer *n, real *d__, real *e, integer *info); -/* Subroutine */ int slarrv_(integer *n, real *vl, real *vu, real *d__, real *l, real *pivmin, - integer *isplit, integer *m, integer *dol, integer *dou, real *minrgp, - real *rtol1, real *rtol2, real *w, real *werr, real *wgap, - integer *iblock, integer *indexw, real *gers, real *z__, integer *ldz, - integer *isuppz, real *work, integer *iwork, integer *info); +/* Subroutine */ int slarrv_(integer *n, real *vl, real *vu, real *d__, real *l, real *pivmin, integer *isplit, integer *m, integer *dol, integer *dou, real *minrgp, real *rtol1, real *rtol2, real *w, + real *werr, real *wgap, integer *iblock, integer *indexw, real *gers, real *z__, integer *ldz, integer *isuppz, real *work, integer *iwork, integer *info); /* Subroutine */ int slarscl2_(integer *m, integer *n, real *d__, real *x, integer *ldx); /* Subroutine */ int slartg_(real *f, real *g, real *cs, real *sn, real *r__); -/* Subroutine */ int slartv_(integer *n, real *x, integer *incx, real *y, integer *incy, real *c__, - real *s, integer *incc); +/* Subroutine */ int slartv_(integer *n, real *x, integer *incx, real *y, integer *incy, real *c__, real *s, integer *incc); /* Subroutine */ int slaruv_(integer *iseed, integer *n, real *x); -/* Subroutine */ int slarz_(char *side, integer *m, integer *n, integer *l, real *v, integer *incv, - real *tau, real *c__, integer *ldc, real *work); +/* Subroutine */ int slarz_(char *side, integer *m, integer *n, integer *l, real *v, integer *incv, real *tau, real *c__, integer *ldc, real *work); -/* Subroutine */ int slarzb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, integer *l, real *v, integer *ldv, real *t, - integer *ldt, real *c__, integer *ldc, real *work, integer *ldwork); +/* Subroutine */ int slarzb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, integer *l, real *v, integer *ldv, real *t, integer *ldt, real *c__, integer *ldc, + real *work, integer *ldwork); -/* Subroutine */ int slarzt_(char *direct, char *storev, integer *n, integer *k, real *v, - integer *ldv, real *tau, real *t, integer *ldt); +/* Subroutine */ int slarzt_(char *direct, char *storev, integer *n, integer *k, real *v, integer *ldv, real *tau, real *t, integer *ldt); /* Subroutine */ int slas2_(real *f, real *g, real *h__, real *ssmin, real *ssmax); -/* Subroutine */ int slascl_(char *type__, integer *kl, integer *ku, real *cfrom, real *cto, - integer *m, integer *n, real *a, integer *lda, integer *info); +/* Subroutine */ int slascl_(char *type__, integer *kl, integer *ku, real *cfrom, real *cto, integer *m, integer *n, real *a, integer *lda, integer *info); /* Subroutine */ int slascl2_(integer *m, integer *n, real *d__, real *x, integer *ldx); -/* Subroutine */ int slasd0_(integer *n, integer *sqre, real *d__, real *e, real *u, integer *ldu, - real *vt, integer *ldvt, integer *smlsiz, integer *iwork, real *work, - integer *info); +/* Subroutine */ int slasd0_(integer *n, integer *sqre, real *d__, real *e, real *u, integer *ldu, real *vt, integer *ldvt, integer *smlsiz, integer *iwork, real *work, integer *info); -/* Subroutine */ int slasd1_(integer *nl, integer *nr, integer *sqre, real *d__, real *alpha, - real *beta, real *u, integer *ldu, real *vt, integer *ldvt, - integer *idxq, integer *iwork, real *work, integer *info); +/* Subroutine */ int slasd1_(integer *nl, integer *nr, integer *sqre, real *d__, real *alpha, real *beta, real *u, integer *ldu, real *vt, integer *ldvt, integer *idxq, integer *iwork, real *work, + integer *info); -/* Subroutine */ int slasd2_(integer *nl, integer *nr, integer *sqre, integer *k, real *d__, - real *z__, real *alpha, real *beta, real *u, integer *ldu, real *vt, - integer *ldvt, real *dsigma, real *u2, integer *ldu2, real *vt2, - integer *ldvt2, integer *idxp, integer *idx, integer *idxc, - integer *idxq, integer *coltyp, integer *info); +/* Subroutine */ int slasd2_(integer *nl, integer *nr, integer *sqre, integer *k, real *d__, real *z__, real *alpha, real *beta, real *u, integer *ldu, real *vt, integer *ldvt, real *dsigma, real *u2, + integer *ldu2, real *vt2, integer *ldvt2, integer *idxp, integer *idx, integer *idxc, integer *idxq, integer *coltyp, integer *info); -/* Subroutine */ int slasd3_(integer *nl, integer *nr, integer *sqre, integer *k, real *d__, - real *q, integer *ldq, real *dsigma, real *u, integer *ldu, real *u2, - integer *ldu2, real *vt, integer *ldvt, real *vt2, integer *ldvt2, - integer *idxc, integer *ctot, real *z__, integer *info); +/* Subroutine */ int slasd3_(integer *nl, integer *nr, integer *sqre, integer *k, real *d__, real *q, integer *ldq, real *dsigma, real *u, integer *ldu, real *u2, integer *ldu2, real *vt, + integer *ldvt, real *vt2, integer *ldvt2, integer *idxc, integer *ctot, real *z__, integer *info); -/* Subroutine */ int slasd4_(integer *n, integer *i__, real *d__, real *z__, real *delta, real *rho, - real *sigma, real *work, integer *info); +/* Subroutine */ int slasd4_(integer *n, integer *i__, real *d__, real *z__, real *delta, real *rho, real *sigma, real *work, integer *info); -/* Subroutine */ int slasd5_(integer *i__, real *d__, real *z__, real *delta, real *rho, - real *dsigma, real *work); +/* Subroutine */ int slasd5_(integer *i__, real *d__, real *z__, real *delta, real *rho, real *dsigma, real *work); -/* Subroutine */ int slasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, real *d__, - real *vf, real *vl, real *alpha, real *beta, integer *idxq, - integer *perm, integer *givptr, integer *givcol, integer *ldgcol, - real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *work, integer *iwork, - integer *info); +/* Subroutine */ int slasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, real *d__, real *vf, real *vl, real *alpha, real *beta, integer *idxq, integer *perm, integer *givptr, + integer *givcol, integer *ldgcol, real *givnum, integer *ldgnum, real *poles, real *difl, real *difr, real *z__, integer *k, real *c__, real *s, real *work, + integer *iwork, integer *info); -/* Subroutine */ int slasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *k, - real *d__, real *z__, real *zw, real *vf, real *vfw, real *vl, - real *vlw, real *alpha, real *beta, real *dsigma, integer *idx, - integer *idxp, integer *idxq, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, real *givnum, integer *ldgnum, - real *c__, real *s, integer *info); +/* Subroutine */ int slasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *k, real *d__, real *z__, real *zw, real *vf, real *vfw, real *vl, real *vlw, real *alpha, real *beta, + real *dsigma, integer *idx, integer *idxp, integer *idxq, integer *perm, integer *givptr, integer *givcol, integer *ldgcol, real *givnum, integer *ldgnum, real *c__, + real *s, integer *info); -/* Subroutine */ int slasd8_(integer *icompq, integer *k, real *d__, real *z__, real *vf, real *vl, - real *difl, real *difr, integer *lddifr, real *dsigma, real *work, - integer *info); +/* Subroutine */ int slasd8_(integer *icompq, integer *k, real *d__, real *z__, real *vf, real *vl, real *difl, real *difr, integer *lddifr, real *dsigma, real *work, integer *info); -/* Subroutine */ int slasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, real *d__, - real *e, real *u, integer *ldu, real *vt, integer *k, real *difl, - real *difr, real *z__, real *poles, integer *givptr, integer *givcol, - integer *ldgcol, integer *perm, real *givnum, real *c__, real *s, - real *work, integer *iwork, integer *info); +/* Subroutine */ int slasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, real *d__, real *e, real *u, integer *ldu, real *vt, integer *k, real *difl, real *difr, real *z__, + real *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, real *givnum, real *c__, real *s, real *work, integer *iwork, integer *info); -/* Subroutine */ int slasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, integer *nru, - integer *ncc, real *d__, real *e, real *vt, integer *ldvt, real *u, - integer *ldu, real *c__, integer *ldc, real *work, integer *info); +/* Subroutine */ int slasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, integer *nru, integer *ncc, real *d__, real *e, real *vt, integer *ldvt, real *u, integer *ldu, real *c__, + integer *ldc, real *work, integer *info); -/* Subroutine */ int slasdt_(integer *n, integer *lvl, integer *nd, integer *inode, integer *ndiml, - integer *ndimr, integer *msub); +/* Subroutine */ int slasdt_(integer *n, integer *lvl, integer *nd, integer *inode, integer *ndiml, integer *ndimr, integer *msub); -/* Subroutine */ int slaset_(char *uplo, integer *m, integer *n, real *alpha, real *beta, real *a, - integer *lda); +/* Subroutine */ int slaset_(char *uplo, integer *m, integer *n, real *alpha, real *beta, real *a, integer *lda); /* Subroutine */ int slasq1_(integer *n, real *d__, real *e, real *work, integer *info); /* Subroutine */ int slasq2_(integer *n, real *z__, integer *info); -/* Subroutine */ int slasq3_(integer *i0, integer *n0, real *z__, integer *pp, real *dmin__, - real *sigma, real *desig, real *qmax, integer *nfail, integer *iter, - integer *ndiv, logical *ieee, integer *ttype, real *dmin1, real *dmin2, - real *dn, real *dn1, real *dn2, real *g, real *tau); +/* Subroutine */ int slasq3_(integer *i0, integer *n0, real *z__, integer *pp, real *dmin__, real *sigma, real *desig, real *qmax, integer *nfail, integer *iter, integer *ndiv, logical *ieee, + integer *ttype, real *dmin1, real *dmin2, real *dn, real *dn1, real *dn2, real *g, real *tau); -/* Subroutine */ int slasq4_(integer *i0, integer *n0, real *z__, integer *pp, integer *n0in, - real *dmin__, real *dmin1, real *dmin2, real *dn, real *dn1, real *dn2, - real *tau, integer *ttype, real *g); +/* Subroutine */ int slasq4_(integer *i0, integer *n0, real *z__, integer *pp, integer *n0in, real *dmin__, real *dmin1, real *dmin2, real *dn, real *dn1, real *dn2, real *tau, integer *ttype, + real *g); -/* Subroutine */ int slasq5_(integer *i0, integer *n0, real *z__, integer *pp, real *tau, - real *dmin__, real *dmin1, real *dmin2, real *dn, real *dnm1, - real *dnm2, logical *ieee); +/* Subroutine */ int slasq5_(integer *i0, integer *n0, real *z__, integer *pp, real *tau, real *dmin__, real *dmin1, real *dmin2, real *dn, real *dnm1, real *dnm2, logical *ieee); -/* Subroutine */ int slasq6_(integer *i0, integer *n0, real *z__, integer *pp, real *dmin__, - real *dmin1, real *dmin2, real *dn, real *dnm1, real *dnm2); +/* Subroutine */ int slasq6_(integer *i0, integer *n0, real *z__, integer *pp, real *dmin__, real *dmin1, real *dmin2, real *dn, real *dnm1, real *dnm2); -/* Subroutine */ int slasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - real *c__, real *s, real *a, integer *lda); +/* Subroutine */ int slasr_(char *side, char *pivot, char *direct, integer *m, integer *n, real *c__, real *s, real *a, integer *lda); /* Subroutine */ int slasrt_(char *id, integer *n, real *d__, integer *info); /* Subroutine */ int slassq_(integer *n, real *x, integer *incx, real *scale, real *sumsq); -/* Subroutine */ int slasv2_(real *f, real *g, real *h__, real *ssmin, real *ssmax, real *snr, - real *csr, real *snl, real *csl); +/* Subroutine */ int slasv2_(real *f, real *g, real *h__, real *ssmin, real *ssmax, real *snr, real *csr, real *snl, real *csl); -/* Subroutine */ int slaswp_(integer *n, real *a, integer *lda, integer *k1, integer *k2, - integer *ipiv, integer *incx); +/* Subroutine */ int slaswp_(integer *n, real *a, integer *lda, integer *k1, integer *k2, integer *ipiv, integer *incx); -/* Subroutine */ int slasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, - integer *n2, real *tl, integer *ldtl, real *tr, integer *ldtr, real *b, - integer *ldb, real *scale, real *x, integer *ldx, real *xnorm, - integer *info); +/* Subroutine */ int slasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, integer *n2, real *tl, integer *ldtl, real *tr, integer *ldtr, real *b, integer *ldb, real *scale, real *x, + integer *ldx, real *xnorm, integer *info); -/* Subroutine */ int slasyf_(char *uplo, integer *n, integer *nb, integer *kb, real *a, - integer *lda, integer *ipiv, real *w, integer *ldw, integer *info); +/* Subroutine */ int slasyf_(char *uplo, integer *n, integer *nb, integer *kb, real *a, integer *lda, integer *ipiv, real *w, integer *ldw, integer *info); -/* Subroutine */ int slatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - integer *kd, real *ab, integer *ldab, real *x, real *scale, - real *cnorm, integer *info); +/* Subroutine */ int slatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, integer *kd, real *ab, integer *ldab, real *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int slatdf_(integer *ijob, integer *n, real *z__, integer *ldz, real *rhs, - real *rdsum, real *rdscal, integer *ipiv, integer *jpiv); +/* Subroutine */ int slatdf_(integer *ijob, integer *n, real *z__, integer *ldz, real *rhs, real *rdsum, real *rdscal, integer *ipiv, integer *jpiv); -/* Subroutine */ int slatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, - real *ap, real *x, real *scale, real *cnorm, integer *info); +/* Subroutine */ int slatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, real *ap, real *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int slatrd_(char *uplo, integer *n, integer *nb, real *a, integer *lda, real *e, - real *tau, real *w, integer *ldw); +/* Subroutine */ int slatrd_(char *uplo, integer *n, integer *nb, real *a, integer *lda, real *e, real *tau, real *w, integer *ldw); -/* Subroutine */ int slatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, real *a, - integer *lda, real *x, real *scale, real *cnorm, integer *info); +/* Subroutine */ int slatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, real *a, integer *lda, real *x, real *scale, real *cnorm, integer *info); -/* Subroutine */ int slatrz_(integer *m, integer *n, integer *l, real *a, integer *lda, real *tau, - real *work); +/* Subroutine */ int slatrz_(integer *m, integer *n, integer *l, real *a, integer *lda, real *tau, real *work); -/* Subroutine */ int slatzm_(char *side, integer *m, integer *n, real *v, integer *incv, real *tau, - real *c1, real *c2, integer *ldc, real *work); +/* Subroutine */ int slatzm_(char *side, integer *m, integer *n, real *v, integer *incv, real *tau, real *c1, real *c2, integer *ldc, real *work); /* Subroutine */ int slauu2_(char *uplo, integer *n, real *a, integer *lda, integer *info); /* Subroutine */ int slauum_(char *uplo, integer *n, real *a, integer *lda, integer *info); -/* Subroutine */ int sopgtr_(char *uplo, integer *n, real *ap, real *tau, real *q, integer *ldq, - real *work, integer *info); +/* Subroutine */ int sopgtr_(char *uplo, integer *n, real *ap, real *tau, real *q, integer *ldq, real *work, integer *info); -/* Subroutine */ int sopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, real *ap, - real *tau, real *c__, integer *ldc, real *work, integer *info); +/* Subroutine */ int sopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, real *ap, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sorg2l_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *info); +/* Subroutine */ int sorg2l_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sorg2r_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *info); +/* Subroutine */ int sorg2r_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sorgbr_(char *vect, integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); +/* Subroutine */ int sorgbr_(char *vect, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorghr_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); +/* Subroutine */ int sorghr_(integer *n, integer *ilo, integer *ihi, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorgl2_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *info); +/* Subroutine */ int sorgl2_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sorglq_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sorglq_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorgql_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sorgql_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorgqr_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sorgqr_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorgr2_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *info); +/* Subroutine */ int sorgr2_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *info); -/* Subroutine */ int sorgrq_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sorgrq_(integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorgtr_(char *uplo, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sorgtr_(char *uplo, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int sorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *info); +/* Subroutine */ int sorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *info); - -/* Subroutine */ int sormbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sormhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, - integer *ihi, real *a, integer *lda, real *tau, real *c__, - integer *ldc, real *work, integer *lwork, integer *info); +/* Subroutine */ int sormbr_(char *vect, char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, + integer *info); -/* Subroutine */ int sorml2_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, +/* Subroutine */ int sormhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, integer *ihi, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int sormlq_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sorml2_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sormql_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sormlq_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int sormqr_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sormql_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int sormr2_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *info); +/* Subroutine */ int sormqr_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int sormr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *info); +/* Subroutine */ int sormr2_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sormrq_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sormr3_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *info); -/* Subroutine */ int sormrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info); +/* Subroutine */ int sormrq_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int sormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, real *a, - integer *lda, real *tau, real *c__, integer *ldc, real *work, - integer *lwork, integer *info); +/* Subroutine */ int sormrz_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, + integer *info); -/* Subroutine */ int spbcon_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - real *anorm, real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int sormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info); -/* Subroutine */ int spbequ_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *s, - real *scond, real *amax, integer *info); +/* Subroutine */ int spbcon_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int spbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *afb, integer *ldafb, real *b, integer *ldb, - real *x, integer *ldx, real *ferr, real *berr, real *work, - integer *iwork, integer *info); +/* Subroutine */ int spbequ_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int spbstf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info); +/* Subroutine */ int spbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, real *b, integer *ldb, real *x, integer *ldx, real *ferr, + real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int spbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *b, integer *ldb, integer *info); +/* Subroutine */ int spbstf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, integer *info); -/* Subroutine */ int spbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, - real *ab, integer *ldab, real *afb, integer *ldafb, char *equed, - real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *ferr, real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int spbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, integer *info); -/* Subroutine */ int spbtf2_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info); +/* Subroutine */ int spbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *afb, integer *ldafb, char *equed, real *s, real *b, integer *ldb, real *x, + integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int spbtrf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info); +/* Subroutine */ int spbtf2_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, integer *info); + +/* Subroutine */ int spbtrf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, integer *info); -/* Subroutine */ int spbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *b, integer *ldb, integer *info); +/* Subroutine */ int spbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, integer *info); /* Subroutine */ int spftrf_(char *transr, char *uplo, integer *n, real *a, integer *info); /* Subroutine */ int spftri_(char *transr, char *uplo, integer *n, real *a, integer *info); -/* Subroutine */ int spftrs_(char *transr, char *uplo, integer *n, integer *nrhs, real *a, real *b, - integer *ldb, integer *info); +/* Subroutine */ int spftrs_(char *transr, char *uplo, integer *n, integer *nrhs, real *a, real *b, integer *ldb, integer *info); -/* Subroutine */ int spocon_(char *uplo, integer *n, real *a, integer *lda, real *anorm, - real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int spocon_(char *uplo, integer *n, real *a, integer *lda, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int spoequ_(integer *n, real *a, integer *lda, real *s, real *scond, real *amax, - integer *info); +/* Subroutine */ int spoequ_(integer *n, real *a, integer *lda, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int spoequb_(integer *n, real *a, integer *lda, real *s, real *scond, real *amax, - integer *info); +/* Subroutine */ int spoequb_(integer *n, real *a, integer *lda, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int sporfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, - integer *ldaf, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int sporfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, + integer *iwork, integer *info); -/* Subroutine */ int sporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, real *s, real *b, integer *ldb, - real *x, integer *ldx, real *rcond, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, real *work, integer *iwork, integer *info); +/* Subroutine */ int sporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, + real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, integer *iwork, integer *info); -/* Subroutine */ int sposv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, integer *info); +/* Subroutine */ int sposv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, integer *info); -/* Subroutine */ int sposvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, - integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, - real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int sposvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, + real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info); -/* Subroutine */ int sposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, - integer *ldb, real *x, integer *ldx, real *rcond, real *rpvgrw, - real *berr, integer *n_err_bnds__, real *err_bnds_norm__, - real *err_bnds_comp__, integer *nparams, real *params, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, + real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, integer *iwork, + integer *info); /* Subroutine */ int spotf2_(char *uplo, integer *n, real *a, integer *lda, integer *info); @@ -4706,1296 +2987,781 @@ doublereal slapy3_(real *x, real *y, real *z__); /* Subroutine */ int spotri_(char *uplo, integer *n, real *a, integer *lda, integer *info); -/* Subroutine */ int spotrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *b, - integer *ldb, integer *info); +/* Subroutine */ int spotrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, integer *info); -/* Subroutine */ int sppcon_(char *uplo, integer *n, real *ap, real *anorm, real *rcond, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sppcon_(char *uplo, integer *n, real *ap, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int sppequ_(char *uplo, integer *n, real *ap, real *s, real *scond, real *amax, - integer *info); +/* Subroutine */ int sppequ_(char *uplo, integer *n, real *ap, real *s, real *scond, real *amax, integer *info); -/* Subroutine */ int spprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, real *b, - integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info); +/* Subroutine */ int spprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, integer *iwork, + integer *info); -/* Subroutine */ int sppsv_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, - integer *info); +/* Subroutine */ int sppsv_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, integer *info); -/* Subroutine */ int sppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, real *afp, - char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, - real *rcond, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int sppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, real *afp, char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, + real *berr, real *work, integer *iwork, integer *info); /* Subroutine */ int spptrf_(char *uplo, integer *n, real *ap, integer *info); /* Subroutine */ int spptri_(char *uplo, integer *n, real *ap, integer *info); -/* Subroutine */ int spptrs_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, - integer *info); +/* Subroutine */ int spptrs_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, integer *info); -/* Subroutine */ int spstf2_(char *uplo, integer *n, real *a, integer *lda, integer *piv, - integer *rank, real *tol, real *work, integer *info); +/* Subroutine */ int spstf2_(char *uplo, integer *n, real *a, integer *lda, integer *piv, integer *rank, real *tol, real *work, integer *info); -/* Subroutine */ int spstrf_(char *uplo, integer *n, real *a, integer *lda, integer *piv, - integer *rank, real *tol, real *work, integer *info); +/* Subroutine */ int spstrf_(char *uplo, integer *n, real *a, integer *lda, integer *piv, integer *rank, real *tol, real *work, integer *info); -/* Subroutine */ int sptcon_(integer *n, real *d__, real *e, real *anorm, real *rcond, real *work, - integer *info); +/* Subroutine */ int sptcon_(integer *n, real *d__, real *e, real *anorm, real *rcond, real *work, integer *info); -/* Subroutine */ int spteqr_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, - real *work, integer *info); +/* Subroutine */ int spteqr_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int sptrfs_(integer *n, integer *nrhs, real *d__, real *e, real *df, real *ef, - real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *info); +/* Subroutine */ int sptrfs_(integer *n, integer *nrhs, real *d__, real *e, real *df, real *ef, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, integer *info); -/* Subroutine */ int sptsv_(integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb, - integer *info); +/* Subroutine */ int sptsv_(integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb, integer *info); -/* Subroutine */ int sptsvx_(char *fact, integer *n, integer *nrhs, real *d__, real *e, real *df, - real *ef, real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *ferr, real *berr, real *work, integer *info); +/* Subroutine */ int sptsvx_(char *fact, integer *n, integer *nrhs, real *d__, real *e, real *df, real *ef, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, + real *work, integer *info); /* Subroutine */ int spttrf_(integer *n, real *d__, real *e, integer *info); -/* Subroutine */ int spttrs_(integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb, - integer *info); +/* Subroutine */ int spttrs_(integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb, integer *info); /* Subroutine */ int sptts2_(integer *n, integer *nrhs, real *d__, real *e, real *b, integer *ldb); /* Subroutine */ int srscl_(integer *n, real *sa, real *sx, integer *incx); -/* Subroutine */ int ssbev_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *w, real *z__, integer *ldz, real *work, - integer *info); +/* Subroutine */ int ssbev_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *w, real *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int ssbevd_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *w, real *z__, integer *ldz, real *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); - -/* Subroutine */ int ssbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *q, integer *ldq, real *vl, real *vu, integer *il, - integer *iu, real *abstol, integer *m, real *w, real *z__, - integer *ldz, real *work, integer *iwork, integer *ifail, +/* Subroutine */ int ssbevd_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *w, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ssbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, real *ab, - integer *ldab, real *bb, integer *ldbb, real *x, integer *ldx, - real *work, integer *info); +/* Subroutine */ int ssbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *q, integer *ldq, real *vl, real *vu, integer *il, integer *iu, real *abstol, + integer *m, real *w, real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int ssbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, real *ab, - integer *ldab, real *bb, integer *ldbb, real *w, real *z__, - integer *ldz, real *work, integer *info); +/* Subroutine */ int ssbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, real *ab, integer *ldab, real *bb, integer *ldbb, real *x, integer *ldx, real *work, integer *info); -/* Subroutine */ int ssbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, real *ab, - integer *ldab, real *bb, integer *ldbb, real *w, real *z__, - integer *ldz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int ssbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, real *ab, integer *ldab, real *bb, integer *ldbb, real *w, real *z__, integer *ldz, real *work, + integer *info); -/* Subroutine */ int ssbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, real *ab, integer *ldab, real *bb, integer *ldbb, real *q, - integer *ldq, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, real *z__, integer *ldz, real *work, - integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int ssbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, real *ab, integer *ldab, real *bb, integer *ldbb, real *w, real *z__, integer *ldz, real *work, + integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ssbtrd_(char *vect, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *d__, real *e, real *q, integer *ldq, real *work, - integer *info); +/* Subroutine */ int ssbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, integer *kb, real *ab, integer *ldab, real *bb, integer *ldbb, real *q, integer *ldq, real *vl, real *vu, + integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int ssfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, - real *alpha, real *a, integer *lda, real *beta, real *c__); +/* Subroutine */ int ssbtrd_(char *vect, char *uplo, integer *n, integer *kd, real *ab, integer *ldab, real *d__, real *e, real *q, integer *ldq, real *work, integer *info); -/* Subroutine */ int sspcon_(char *uplo, integer *n, real *ap, integer *ipiv, real *anorm, - real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int ssfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, real *alpha, real *a, integer *lda, real *beta, real *c__); -/* Subroutine */ int sspev_(char *jobz, char *uplo, integer *n, real *ap, real *w, real *z__, - integer *ldz, real *work, integer *info); +/* Subroutine */ int sspcon_(char *uplo, integer *n, real *ap, integer *ipiv, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int sspevd_(char *jobz, char *uplo, integer *n, real *ap, real *w, real *z__, - integer *ldz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int sspev_(char *jobz, char *uplo, integer *n, real *ap, real *w, real *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int sspevx_(char *jobz, char *range, char *uplo, integer *n, real *ap, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int sspevd_(char *jobz, char *uplo, integer *n, real *ap, real *w, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int sspgst_(integer *itype, char *uplo, integer *n, real *ap, real *bp, - integer *info); +/* Subroutine */ int sspevx_(char *jobz, char *range, char *uplo, integer *n, real *ap, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, + real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int sspgv_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, real *bp, - real *w, real *z__, integer *ldz, real *work, integer *info); +/* Subroutine */ int sspgst_(integer *itype, char *uplo, integer *n, real *ap, real *bp, integer *info); -/* Subroutine */ int sspgvd_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, real *bp, - real *w, real *z__, integer *ldz, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int sspgv_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, real *bp, real *w, real *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int sspgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - real *ap, real *bp, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, real *z__, integer *ldz, real *work, - integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int sspgvd_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, real *bp, real *w, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *liwork, + integer *info); -/* Subroutine */ int ssprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, - integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int sspgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, real *ap, real *bp, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, + real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int sspsv_(char *uplo, integer *n, integer *nrhs, real *ap, integer *ipiv, real *b, - integer *ldb, integer *info); +/* Subroutine */ int ssprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, + integer *iwork, integer *info); -/* Subroutine */ int sspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, real *afp, - integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, - real *rcond, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int sspsv_(char *uplo, integer *n, integer *nrhs, real *ap, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int ssptrd_(char *uplo, integer *n, real *ap, real *d__, real *e, real *tau, - integer *info); +/* Subroutine */ int sspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, real *afp, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, + real *work, integer *iwork, integer *info); + +/* Subroutine */ int ssptrd_(char *uplo, integer *n, real *ap, real *d__, real *e, real *tau, integer *info); /* Subroutine */ int ssptrf_(char *uplo, integer *n, real *ap, integer *ipiv, integer *info); -/* Subroutine */ int ssptri_(char *uplo, integer *n, real *ap, integer *ipiv, real *work, - integer *info); +/* Subroutine */ int ssptri_(char *uplo, integer *n, real *ap, integer *ipiv, real *work, integer *info); -/* Subroutine */ int ssptrs_(char *uplo, integer *n, integer *nrhs, real *ap, integer *ipiv, - real *b, integer *ldb, integer *info); +/* Subroutine */ int ssptrs_(char *uplo, integer *n, integer *nrhs, real *ap, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int sstebz_(char *range, char *order, integer *n, real *vl, real *vu, integer *il, - integer *iu, real *abstol, real *d__, real *e, integer *m, - integer *nsplit, real *w, integer *iblock, integer *isplit, real *work, - integer *iwork, integer *info); +/* Subroutine */ int sstebz_(char *range, char *order, integer *n, real *vl, real *vu, integer *il, integer *iu, real *abstol, real *d__, real *e, integer *m, integer *nsplit, real *w, + integer *iblock, integer *isplit, real *work, integer *iwork, integer *info); -/* Subroutine */ int sstedc_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, - real *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int sstedc_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int sstegr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, integer *isuppz, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int sstegr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, + integer *isuppz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int sstein_(integer *n, real *d__, real *e, integer *m, real *w, integer *iblock, - integer *isplit, real *z__, integer *ldz, real *work, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int sstein_(integer *n, real *d__, real *e, integer *m, real *w, integer *iblock, integer *isplit, real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int sstemr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, integer *m, real *w, real *z__, - integer *ldz, integer *nzc, integer *isuppz, logical *tryrac, - real *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int sstemr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, integer *m, real *w, real *z__, integer *ldz, integer *nzc, + integer *isuppz, logical *tryrac, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ssteqr_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, - real *work, integer *info); +/* Subroutine */ int ssteqr_(char *compz, integer *n, real *d__, real *e, real *z__, integer *ldz, real *work, integer *info); /* Subroutine */ int ssterf_(integer *n, real *d__, real *e, integer *info); -/* Subroutine */ int sstev_(char *jobz, integer *n, real *d__, real *e, real *z__, integer *ldz, - real *work, integer *info); +/* Subroutine */ int sstev_(char *jobz, integer *n, real *d__, real *e, real *z__, integer *ldz, real *work, integer *info); -/* Subroutine */ int sstevd_(char *jobz, integer *n, real *d__, real *e, real *z__, integer *ldz, - real *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int sstevd_(char *jobz, integer *n, real *d__, real *e, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int sstevr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, integer *isuppz, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int sstevr_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, + integer *isuppz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int sstevx_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, real *work, integer *iwork, integer *ifail, - integer *info); +/* Subroutine */ int sstevx_(char *jobz, char *range, integer *n, real *d__, real *e, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, + real *work, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int ssycon_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *anorm, real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int ssycon_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, real *anorm, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int ssyequb_(char *uplo, integer *n, real *a, integer *lda, real *s, real *scond, - real *amax, real *work, integer *info); +/* Subroutine */ int ssyequb_(char *uplo, integer *n, real *a, integer *lda, real *s, real *scond, real *amax, real *work, integer *info); -/* Subroutine */ int ssyev_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, - real *work, integer *lwork, integer *info); +/* Subroutine */ int ssyev_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, real *work, integer *lwork, integer *info); -/* Subroutine */ int ssyevd_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, - real *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int ssyevd_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ssyevr_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, - real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, - real *w, real *z__, integer *ldz, integer *isuppz, real *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int ssyevr_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, + integer *ldz, integer *isuppz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int ssyevx_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, - real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, - real *w, real *z__, integer *ldz, real *work, integer *lwork, - integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int ssyevx_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, + integer *ldz, real *work, integer *lwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int ssygs2_(integer *itype, char *uplo, integer *n, real *a, integer *lda, real *b, - integer *ldb, integer *info); +/* Subroutine */ int ssygs2_(integer *itype, char *uplo, integer *n, real *a, integer *lda, real *b, integer *ldb, integer *info); -/* Subroutine */ int ssygst_(integer *itype, char *uplo, integer *n, real *a, integer *lda, real *b, - integer *ldb, integer *info); +/* Subroutine */ int ssygst_(integer *itype, char *uplo, integer *n, real *a, integer *lda, real *b, integer *ldb, integer *info); -/* Subroutine */ int ssygv_(integer *itype, char *jobz, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *w, real *work, - integer *lwork, integer *info); +/* Subroutine */ int ssygv_(integer *itype, char *jobz, char *uplo, integer *n, real *a, integer *lda, real *b, integer *ldb, real *w, real *work, integer *lwork, integer *info); -/* Subroutine */ int ssygvd_(integer *itype, char *jobz, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *w, real *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int ssygvd_(integer *itype, char *jobz, char *uplo, integer *n, real *a, integer *lda, real *b, integer *ldb, real *w, real *work, integer *lwork, integer *iwork, integer *liwork, + integer *info); -/* Subroutine */ int ssygvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, - integer *ldz, real *work, integer *lwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int ssygvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, real *b, integer *ldb, real *vl, real *vu, integer *il, integer *iu, real *abstol, + integer *m, real *w, real *z__, integer *ldz, real *work, integer *lwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int ssyrfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, - integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, - integer *ldx, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int ssyrfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, + real *work, integer *iwork, integer *info); -/* Subroutine */ int ssyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, real *s, - real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *berr, - integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, - integer *nparams, real *params, real *work, integer *iwork, - integer *info); +/* Subroutine */ int ssyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *s, real *b, integer *ldb, real *x, integer *ldx, + real *rcond, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, integer *iwork, integer *info); -/* Subroutine */ int ssysv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, real *work, integer *lwork, - integer *info); +/* Subroutine */ int ssysv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, integer *ipiv, real *b, integer *ldb, real *work, integer *lwork, integer *info); -/* Subroutine */ int ssysvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, - integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, - real *berr, real *work, integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int ssysvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, + real *rcond, real *ferr, real *berr, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int ssysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, - real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *rpvgrw, real *berr, integer *n_err_bnds__, - real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, - real *params, real *work, integer *iwork, integer *info); +/* Subroutine */ int ssysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, char *equed, real *s, real *b, integer *ldb, real *x, + integer *ldx, real *rcond, real *rpvgrw, real *berr, integer *n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *params, real *work, + integer *iwork, integer *info); -/* Subroutine */ int ssytd2_(char *uplo, integer *n, real *a, integer *lda, real *d__, real *e, - real *tau, integer *info); +/* Subroutine */ int ssytd2_(char *uplo, integer *n, real *a, integer *lda, real *d__, real *e, real *tau, integer *info); -/* Subroutine */ int ssytf2_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int ssytf2_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int ssytrd_(char *uplo, integer *n, real *a, integer *lda, real *d__, real *e, - real *tau, real *work, integer *lwork, integer *info); +/* Subroutine */ int ssytrd_(char *uplo, integer *n, real *a, integer *lda, real *d__, real *e, real *tau, real *work, integer *lwork, integer *info); -/* Subroutine */ int ssytrf_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *work, integer *lwork, integer *info); +/* Subroutine */ int ssytrf_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, real *work, integer *lwork, integer *info); -/* Subroutine */ int ssytri_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *work, integer *info); +/* Subroutine */ int ssytri_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, real *work, integer *info); -/* Subroutine */ int ssytrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, integer *info); +/* Subroutine */ int ssytrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, integer *ipiv, real *b, integer *ldb, integer *info); -/* Subroutine */ int stbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, real *ab, - integer *ldab, real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int stbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, real *ab, integer *ldab, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int stbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, real *x, - integer *ldx, real *ferr, real *berr, real *work, integer *iwork, - integer *info); +/* Subroutine */ int stbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, + real *work, integer *iwork, integer *info); -/* Subroutine */ int stbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, - integer *info); +/* Subroutine */ int stbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, real *ab, integer *ldab, real *b, integer *ldb, integer *info); -/* Subroutine */ int stfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, - integer *m, integer *n, real *alpha, real *a, real *b, integer *ldb); +/* Subroutine */ int stfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, integer *m, integer *n, real *alpha, real *a, real *b, integer *ldb); -/* Subroutine */ int stftri_(char *transr, char *uplo, char *diag, integer *n, real *a, - integer *info); +/* Subroutine */ int stftri_(char *transr, char *uplo, char *diag, integer *n, real *a, integer *info); -/* Subroutine */ int stfttp_(char *transr, char *uplo, integer *n, real *arf, real *ap, - integer *info); +/* Subroutine */ int stfttp_(char *transr, char *uplo, integer *n, real *arf, real *ap, integer *info); -/* Subroutine */ int stfttr_(char *transr, char *uplo, integer *n, real *arf, real *a, integer *lda, - integer *info); +/* Subroutine */ int stfttr_(char *transr, char *uplo, integer *n, real *arf, real *a, integer *lda, integer *info); -/* Subroutine */ int stgevc_(char *side, char *howmny, logical *select, integer *n, real *s, - integer *lds, real *p, integer *ldp, real *vl, integer *ldvl, real *vr, - integer *ldvr, integer *mm, integer *m, real *work, integer *info); +/* Subroutine */ int stgevc_(char *side, char *howmny, logical *select, integer *n, real *s, integer *lds, real *p, integer *ldp, real *vl, integer *ldvl, real *vr, integer *ldvr, integer *mm, + integer *m, real *work, integer *info); -/* Subroutine */ int stgex2_(logical *wantq, logical *wantz, integer *n, real *a, integer *lda, - real *b, integer *ldb, real *q, integer *ldq, real *z__, integer *ldz, - integer *j1, integer *n1, integer *n2, real *work, integer *lwork, - integer *info); +/* Subroutine */ int stgex2_(logical *wantq, logical *wantz, integer *n, real *a, integer *lda, real *b, integer *ldb, real *q, integer *ldq, real *z__, integer *ldz, integer *j1, integer *n1, + integer *n2, real *work, integer *lwork, integer *info); -/* Subroutine */ int stgexc_(logical *wantq, logical *wantz, integer *n, real *a, integer *lda, - real *b, integer *ldb, real *q, integer *ldq, real *z__, integer *ldz, - integer *ifst, integer *ilst, real *work, integer *lwork, - integer *info); +/* Subroutine */ int stgexc_(logical *wantq, logical *wantz, integer *n, real *a, integer *lda, real *b, integer *ldb, real *q, integer *ldq, real *z__, integer *ldz, integer *ifst, integer *ilst, + real *work, integer *lwork, integer *info); -/* Subroutine */ int stgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, - integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, - real *alphai, real *beta, real *q, integer *ldq, real *z__, - integer *ldz, integer *m, real *pl, real *pr, real *dif, real *work, - integer *lwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int stgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, integer *n, real *a, integer *lda, real *b, integer *ldb, real *alphar, real *alphai, real *beta, real *q, + integer *ldq, real *z__, integer *ldz, integer *m, real *pl, real *pr, real *dif, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int stgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - integer *k, integer *l, real *a, integer *lda, real *b, integer *ldb, - real *tola, real *tolb, real *alpha, real *beta, real *u, integer *ldu, - real *v, integer *ldv, real *q, integer *ldq, real *work, - integer *ncycle, integer *info); +/* Subroutine */ int stgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, integer *k, integer *l, real *a, integer *lda, real *b, integer *ldb, real *tola, real *tolb, + real *alpha, real *beta, real *u, integer *ldu, real *v, integer *ldv, real *q, integer *ldq, real *work, integer *ncycle, integer *info); -/* Subroutine */ int stgsna_(char *job, char *howmny, logical *select, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *vl, integer *ldvl, real *vr, - integer *ldvr, real *s, real *dif, integer *mm, integer *m, real *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int stgsna_(char *job, char *howmny, logical *select, integer *n, real *a, integer *lda, real *b, integer *ldb, real *vl, integer *ldvl, real *vr, integer *ldvr, real *s, real *dif, + integer *mm, integer *m, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int stgsy2_(char *trans, integer *ijob, integer *m, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *c__, integer *ldc, - real *d__, integer *ldd, real *e, integer *lde, real *f, integer *ldf, - real *scale, real *rdsum, real *rdscal, integer *iwork, integer *pq, - integer *info); +/* Subroutine */ int stgsy2_(char *trans, integer *ijob, integer *m, integer *n, real *a, integer *lda, real *b, integer *ldb, real *c__, integer *ldc, real *d__, integer *ldd, real *e, integer *lde, + real *f, integer *ldf, real *scale, real *rdsum, real *rdscal, integer *iwork, integer *pq, integer *info); -/* Subroutine */ int stgsyl_(char *trans, integer *ijob, integer *m, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *c__, integer *ldc, - real *d__, integer *ldd, real *e, integer *lde, real *f, integer *ldf, - real *scale, real *dif, real *work, integer *lwork, integer *iwork, - integer *info); +/* Subroutine */ int stgsyl_(char *trans, integer *ijob, integer *m, integer *n, real *a, integer *lda, real *b, integer *ldb, real *c__, integer *ldc, real *d__, integer *ldd, real *e, integer *lde, + real *f, integer *ldf, real *scale, real *dif, real *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int stpcon_(char *norm, char *uplo, char *diag, integer *n, real *ap, real *rcond, - real *work, integer *iwork, integer *info); +/* Subroutine */ int stpcon_(char *norm, char *uplo, char *diag, integer *n, real *ap, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int stprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - real *ap, real *b, integer *ldb, real *x, integer *ldx, real *ferr, - real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int stprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, integer *iwork, + integer *info); /* Subroutine */ int stptri_(char *uplo, char *diag, integer *n, real *ap, integer *info); -/* Subroutine */ int stptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - real *ap, real *b, integer *ldb, integer *info); +/* Subroutine */ int stptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, real *ap, real *b, integer *ldb, integer *info); -/* Subroutine */ int stpttf_(char *transr, char *uplo, integer *n, real *ap, real *arf, - integer *info); +/* Subroutine */ int stpttf_(char *transr, char *uplo, integer *n, real *ap, real *arf, integer *info); -/* Subroutine */ int stpttr_(char *uplo, integer *n, real *ap, real *a, integer *lda, - integer *info); +/* Subroutine */ int stpttr_(char *uplo, integer *n, real *ap, real *a, integer *lda, integer *info); -/* Subroutine */ int strcon_(char *norm, char *uplo, char *diag, integer *n, real *a, integer *lda, - real *rcond, real *work, integer *iwork, integer *info); +/* Subroutine */ int strcon_(char *norm, char *uplo, char *diag, integer *n, real *a, integer *lda, real *rcond, real *work, integer *iwork, integer *info); -/* Subroutine */ int strevc_(char *side, char *howmny, logical *select, integer *n, real *t, - integer *ldt, real *vl, integer *ldvl, real *vr, integer *ldvr, - integer *mm, integer *m, real *work, integer *info); +/* Subroutine */ int strevc_(char *side, char *howmny, logical *select, integer *n, real *t, integer *ldt, real *vl, integer *ldvl, real *vr, integer *ldvr, integer *mm, integer *m, real *work, + integer *info); -/* Subroutine */ int strexc_(char *compq, integer *n, real *t, integer *ldt, real *q, integer *ldq, - integer *ifst, integer *ilst, real *work, integer *info); +/* Subroutine */ int strexc_(char *compq, integer *n, real *t, integer *ldt, real *q, integer *ldq, integer *ifst, integer *ilst, real *work, integer *info); -/* Subroutine */ int strrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - real *a, integer *lda, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *iwork, integer *info); +/* Subroutine */ int strrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, real *x, integer *ldx, real *ferr, real *berr, real *work, + integer *iwork, integer *info); -/* Subroutine */ int strsen_(char *job, char *compq, logical *select, integer *n, real *t, - integer *ldt, real *q, integer *ldq, real *wr, real *wi, integer *m, - real *s, real *sep, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int strsen_(char *job, char *compq, logical *select, integer *n, real *t, integer *ldt, real *q, integer *ldq, real *wr, real *wi, integer *m, real *s, real *sep, real *work, + integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int strsna_(char *job, char *howmny, logical *select, integer *n, real *t, - integer *ldt, real *vl, integer *ldvl, real *vr, integer *ldvr, - real *s, real *sep, integer *mm, integer *m, real *work, - integer *ldwork, integer *iwork, integer *info); +/* Subroutine */ int strsna_(char *job, char *howmny, logical *select, integer *n, real *t, integer *ldt, real *vl, integer *ldvl, real *vr, integer *ldvr, real *s, real *sep, integer *mm, integer *m, + real *work, integer *ldwork, integer *iwork, integer *info); -/* Subroutine */ int strsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *c__, integer *ldc, - real *scale, integer *info); +/* Subroutine */ int strsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, real *a, integer *lda, real *b, integer *ldb, real *c__, integer *ldc, real *scale, integer *info); -/* Subroutine */ int strti2_(char *uplo, char *diag, integer *n, real *a, integer *lda, - integer *info); +/* Subroutine */ int strti2_(char *uplo, char *diag, integer *n, real *a, integer *lda, integer *info); -/* Subroutine */ int strtri_(char *uplo, char *diag, integer *n, real *a, integer *lda, - integer *info); +/* Subroutine */ int strtri_(char *uplo, char *diag, integer *n, real *a, integer *lda, integer *info); -/* Subroutine */ int strtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - real *a, integer *lda, real *b, integer *ldb, integer *info); +/* Subroutine */ int strtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, real *a, integer *lda, real *b, integer *ldb, integer *info); -/* Subroutine */ int strttf_(char *transr, char *uplo, integer *n, real *a, integer *lda, real *arf, - integer *info); +/* Subroutine */ int strttf_(char *transr, char *uplo, integer *n, real *a, integer *lda, real *arf, integer *info); -/* Subroutine */ int strttp_(char *uplo, integer *n, real *a, integer *lda, real *ap, - integer *info); +/* Subroutine */ int strttp_(char *uplo, integer *n, real *a, integer *lda, real *ap, integer *info); -/* Subroutine */ int stzrqf_(integer *m, integer *n, real *a, integer *lda, real *tau, - integer *info); +/* Subroutine */ int stzrqf_(integer *m, integer *n, real *a, integer *lda, real *tau, integer *info); -/* Subroutine */ int stzrzf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, - integer *lwork, integer *info); +/* Subroutine */ int stzrzf_(integer *m, integer *n, real *a, integer *lda, real *tau, real *work, integer *lwork, integer *info); /* Subroutine */ int xerbla_(char *srname, integer *info); -/* Subroutine */ int xerbla_array__(char *srname_array__, integer *srname_len__, integer *info, - ftnlen srname_array_len); +/* Subroutine */ int xerbla_array__(char *srname_array__, integer *srname_len__, integer *info, ftnlen srname_array_len); -/* Subroutine */ int zbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, - doublereal *d__, doublereal *e, doublecomplex *vt, integer *ldvt, - doublecomplex *u, integer *ldu, doublecomplex *c__, integer *ldc, - doublereal *rwork, integer *info); +/* Subroutine */ int zbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc, doublereal *d__, doublereal *e, doublecomplex *vt, integer *ldvt, doublecomplex *u, integer *ldu, + doublecomplex *c__, integer *ldc, doublereal *rwork, integer *info); -/* Subroutine */ int zcgesv_(integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublecomplex *work, complex *swork, doublereal *rwork, - integer *iter, integer *info); +/* Subroutine */ int zcgesv_(integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublecomplex *work, + complex *swork, doublereal *rwork, integer *iter, integer *info); -/* Subroutine */ int zcposv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, - doublecomplex *work, complex *swork, doublereal *rwork, integer *iter, - integer *info); +/* Subroutine */ int zcposv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublecomplex *work, complex *swork, + doublereal *rwork, integer *iter, integer *info); /* Subroutine */ int zdrscl_(integer *n, doublereal *sa, doublecomplex *sx, integer *incx); -/* Subroutine */ int zgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, - integer *ku, doublecomplex *ab, integer *ldab, doublereal *d__, - doublereal *e, doublecomplex *q, integer *ldq, doublecomplex *pt, - integer *ldpt, doublecomplex *c__, integer *ldc, doublecomplex *work, +/* Subroutine */ int zgbbrd_(char *vect, integer *m, integer *n, integer *ncc, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublereal *d__, doublereal *e, doublecomplex *q, + integer *ldq, doublecomplex *pt, integer *ldpt, doublecomplex *c__, integer *ldc, doublecomplex *work, doublereal *rwork, integer *info); + +/* Subroutine */ int zgbcon_(char *norm, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, integer *ipiv, doublereal *anorm, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgbcon_(char *norm, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, integer *ipiv, doublereal *anorm, doublereal *rcond, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zgbequ_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, + doublereal *amax, integer *info); -/* Subroutine */ int zgbequ_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int zgbequb_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, + doublereal *amax, integer *info); -/* Subroutine */ int zgbequb_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int zgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, doublecomplex *b, + integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgbrfs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, + doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgbrfsx_(char *trans, char *equed, integer *n, integer *kl, integer *ku, - integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, - integer *ldafb, integer *ipiv, doublereal *r__, doublereal *c__, - doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublecomplex *work, - doublereal *rwork, integer *info); - -/* Subroutine */ int zgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, - integer *ldab, integer *ipiv, doublecomplex *b, integer *ldb, - integer *info); +/* Subroutine */ int zgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, - integer *ldafb, integer *ipiv, char *equed, doublereal *r__, - doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, +/* Subroutine */ int zgbsvx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, + char *equed, doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, - integer *ldafb, integer *ipiv, char *equed, doublereal *r__, - doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zgbsvxx_(char *fact, char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, + char *equed, doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, + integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, + integer *info); -/* Subroutine */ int zgbtf2_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int zgbtf2_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int zgbtrf_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, integer *ipiv, integer *info); +/* Subroutine */ int zgbtrf_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, integer *ipiv, integer *info); -/* Subroutine */ int zgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, - doublecomplex *ab, integer *ldab, integer *ipiv, doublecomplex *b, - integer *ldb, integer *info); +/* Subroutine */ int zgbtrs_(char *trans, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - doublereal *scale, integer *m, doublecomplex *v, integer *ldv, - integer *info); +/* Subroutine */ int zgebak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, doublereal *scale, integer *m, doublecomplex *v, integer *ldv, integer *info); -/* Subroutine */ int zgebal_(char *job, integer *n, doublecomplex *a, integer *lda, integer *ilo, - integer *ihi, doublereal *scale, integer *info); +/* Subroutine */ int zgebal_(char *job, integer *n, doublecomplex *a, integer *lda, integer *ilo, integer *ihi, doublereal *scale, integer *info); -/* Subroutine */ int zgebd2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tauq, - doublecomplex *taup, doublecomplex *work, integer *info); +/* Subroutine */ int zgebd2_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tauq, doublecomplex *taup, doublecomplex *work, integer *info); -/* Subroutine */ int zgebrd_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tauq, - doublecomplex *taup, doublecomplex *work, integer *lwork, +/* Subroutine */ int zgebrd_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tauq, doublecomplex *taup, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgecon_(char *norm, integer *n, doublecomplex *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zgecon_(char *norm, integer *n, doublecomplex *a, integer *lda, doublereal *anorm, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgeequ_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int zgeequ_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, integer *info); -/* Subroutine */ int zgeequb_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); +/* Subroutine */ int zgeequb_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, integer *info); -/* Subroutine */ int zgees_(char *jobvs, char *sort, L_fp select, integer *n, doublecomplex *a, - integer *lda, integer *sdim, doublecomplex *w, doublecomplex *vs, - integer *ldvs, doublecomplex *work, integer *lwork, doublereal *rwork, - logical *bwork, integer *info); +/* Subroutine */ int zgees_(char *jobvs, char *sort, L_fp select, integer *n, doublecomplex *a, integer *lda, integer *sdim, doublecomplex *w, doublecomplex *vs, integer *ldvs, doublecomplex *work, + integer *lwork, doublereal *rwork, logical *bwork, integer *info); -/* Subroutine */ int zgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, - doublecomplex *a, integer *lda, integer *sdim, doublecomplex *w, - doublecomplex *vs, integer *ldvs, doublereal *rconde, - doublereal *rcondv, doublecomplex *work, integer *lwork, - doublereal *rwork, logical *bwork, integer *info); +/* Subroutine */ int zgeesx_(char *jobvs, char *sort, L_fp select, char *sense, integer *n, doublecomplex *a, integer *lda, integer *sdim, doublecomplex *w, doublecomplex *vs, integer *ldvs, + doublereal *rconde, doublereal *rcondv, doublecomplex *work, integer *lwork, doublereal *rwork, logical *bwork, integer *info); -/* Subroutine */ int zgeev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, - doublecomplex *w, doublecomplex *vl, integer *ldvl, doublecomplex *vr, - integer *ldvr, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info); +/* Subroutine */ int zgeev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, doublecomplex *w, doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *ldvr, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - doublecomplex *a, integer *lda, doublecomplex *w, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, integer *ilo, - integer *ihi, doublereal *scale, doublereal *abnrm, doublereal *rconde, - doublereal *rcondv, doublecomplex *work, integer *lwork, +/* Subroutine */ int zgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, doublecomplex *a, integer *lda, doublecomplex *w, doublecomplex *vl, integer *ldvl, doublecomplex *vr, + integer *ldvr, integer *ilo, integer *ihi, doublereal *scale, doublereal *abnrm, doublereal *rconde, doublereal *rcondv, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgegs_(char *jobvsl, char *jobvsr, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *vsl, integer *ldvsl, - doublecomplex *vsr, integer *ldvsr, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info); +/* Subroutine */ int zgegs_(char *jobvsl, char *jobvsr, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *alpha, doublecomplex *beta, doublecomplex *vsl, + integer *ldvsl, doublecomplex *vsr, integer *ldvsr, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgegv_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info); +/* Subroutine */ int zgegv_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *alpha, doublecomplex *beta, doublecomplex *vl, + integer *ldvl, doublecomplex *vr, integer *ldvr, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgehd2_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zgehd2_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgehrd_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgehrd_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgelq2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zgelq2_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgelqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgelqf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgels_(char *trans, integer *m, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *work, - integer *lwork, integer *info); +/* Subroutine */ int zgels_(char *trans, integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgelsd_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublereal *s, doublereal *rcond, - integer *rank, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, integer *info); +/* Subroutine */ int zgelsd_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *s, doublereal *rcond, integer *rank, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, integer *info); -/* Subroutine */ int zgelss_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublereal *s, doublereal *rcond, - integer *rank, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info); +/* Subroutine */ int zgelss_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *s, doublereal *rcond, integer *rank, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgelsx_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *jpvt, doublereal *rcond, - integer *rank, doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zgelsx_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *jpvt, doublereal *rcond, integer *rank, + doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgelsy_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *jpvt, doublereal *rcond, - integer *rank, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info); +/* Subroutine */ int zgelsy_(integer *m, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *jpvt, doublereal *rcond, integer *rank, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgeql2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zgeql2_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgeqlf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgeqlf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgeqp3_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *jpvt, - doublecomplex *tau, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info); +/* Subroutine */ int zgeqp3_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgeqpf_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *jpvt, - doublecomplex *tau, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zgeqpf_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgeqr2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zgeqr2_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgeqrf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgeqrf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgerfs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zgerfs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zgerfsx_(char *trans, char *equed, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *r__, doublereal *c__, + doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, + doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgerq2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zgerq2_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgerqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgerqf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgesc2_(integer *n, doublecomplex *a, integer *lda, doublecomplex *rhs, - integer *ipiv, integer *jpiv, doublereal *scale); +/* Subroutine */ int zgesc2_(integer *n, doublecomplex *a, integer *lda, doublecomplex *rhs, integer *ipiv, integer *jpiv, doublereal *scale); -/* Subroutine */ int zgesdd_(char *jobz, integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *s, doublecomplex *u, integer *ldu, doublecomplex *vt, - integer *ldvt, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, integer *info); +/* Subroutine */ int zgesdd_(char *jobz, integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublecomplex *u, integer *ldu, doublecomplex *vt, integer *ldvt, doublecomplex *work, + integer *lwork, doublereal *rwork, integer *iwork, integer *info); -/* Subroutine */ int zgesv_(integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zgesv_(integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zgesvd_(char *jobu, char *jobvt, integer *m, integer *n, doublecomplex *a, - integer *lda, doublereal *s, doublecomplex *u, integer *ldu, - doublecomplex *vt, integer *ldvt, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info); +/* Subroutine */ int zgesvd_(char *jobu, char *jobvt, integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublecomplex *u, integer *ldu, doublecomplex *vt, integer *ldvt, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgesvx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *r__, doublereal *c__, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, +/* Subroutine */ int zgesvx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, + doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *r__, doublereal *c__, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zgesvxx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, char *equed, doublereal *r__, + doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgetc2_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *jpiv, integer *info); +/* Subroutine */ int zgetc2_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, integer *jpiv, integer *info); -/* Subroutine */ int zgetf2_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int zgetf2_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int zgetrf_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int zgetrf_(integer *m, integer *n, doublecomplex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int zgetri_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zgetri_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zgetrs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zgetrs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, integer *m, doublecomplex *v, - integer *ldv, integer *info); +/* Subroutine */ int zggbak_(char *job, char *side, integer *n, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, integer *m, doublecomplex *v, integer *ldv, integer *info); -/* Subroutine */ int zggbal_(char *job, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, doublereal *work, - integer *info); +/* Subroutine */ int zggbal_(char *job, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, + doublereal *work, integer *info); -/* Subroutine */ int zgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - integer *sdim, doublecomplex *alpha, doublecomplex *beta, - doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, integer *ldvsr, - doublecomplex *work, integer *lwork, doublereal *rwork, logical *bwork, +/* Subroutine */ int zgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *sdim, doublecomplex *alpha, + doublecomplex *beta, doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, integer *ldvsr, doublecomplex *work, integer *lwork, doublereal *rwork, logical *bwork, integer *info); -/* Subroutine */ int zggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, integer *sdim, doublecomplex *alpha, doublecomplex *beta, - doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, integer *ldvsr, - doublereal *rconde, doublereal *rcondv, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *iwork, integer *liwork, - logical *bwork, integer *info); - -/* Subroutine */ int zggev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info); +/* Subroutine */ int zggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, char *sense, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *sdim, + doublecomplex *alpha, doublecomplex *beta, doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, integer *ldvsr, doublereal *rconde, doublereal *rcondv, + doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, integer *liwork, logical *bwork, integer *info); -/* Subroutine */ int zggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *alpha, doublecomplex *beta, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, integer *ilo, - integer *ihi, doublereal *lscale, doublereal *rscale, - doublereal *abnrm, doublereal *bbnrm, doublereal *rconde, - doublereal *rcondv, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *iwork, logical *bwork, integer *info); - -/* Subroutine */ int zggglm_(integer *n, integer *m, integer *p, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *d__, doublecomplex *x, - doublecomplex *y, doublecomplex *work, integer *lwork, integer *info); - -/* Subroutine */ int zgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *q, integer *ldq, doublecomplex *z__, integer *ldz, - integer *info); +/* Subroutine */ int zggev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *alpha, doublecomplex *beta, doublecomplex *vl, + integer *ldvl, doublecomplex *vr, integer *ldvr, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zgglse_(integer *m, integer *n, integer *p, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *c__, doublecomplex *d__, - doublecomplex *x, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *alpha, doublecomplex *beta, + doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *ldvr, integer *ilo, integer *ihi, doublereal *lscale, doublereal *rscale, doublereal *abnrm, + doublereal *bbnrm, doublereal *rconde, doublereal *rcondv, doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, logical *bwork, integer *info); -/* Subroutine */ int zggqrf_(integer *n, integer *m, integer *p, doublecomplex *a, integer *lda, - doublecomplex *taua, doublecomplex *b, integer *ldb, - doublecomplex *taub, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zggglm_(integer *n, integer *m, integer *p, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *d__, doublecomplex *x, doublecomplex *y, + doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zggrqf_(integer *m, integer *p, integer *n, doublecomplex *a, integer *lda, - doublecomplex *taua, doublecomplex *b, integer *ldb, - doublecomplex *taub, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zgghrd_(char *compq, char *compz, integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *q, integer *ldq, + doublecomplex *z__, integer *ldz, integer *info); -/* Subroutine */ int zggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, - integer *k, integer *l, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublereal *alpha, doublereal *beta, - doublecomplex *u, integer *ldu, doublecomplex *v, integer *ldv, - doublecomplex *q, integer *ldq, doublecomplex *work, doublereal *rwork, - integer *iwork, integer *info); +/* Subroutine */ int zgglse_(integer *m, integer *n, integer *p, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, doublecomplex *d__, doublecomplex *x, + doublecomplex *work, integer *lwork, integer *info); + +/* Subroutine */ int zggqrf_(integer *n, integer *m, integer *p, doublecomplex *a, integer *lda, doublecomplex *taua, doublecomplex *b, integer *ldb, doublecomplex *taub, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublereal *tola, doublereal *tolb, integer *k, integer *l, - doublecomplex *u, integer *ldu, doublecomplex *v, integer *ldv, - doublecomplex *q, integer *ldq, integer *iwork, doublereal *rwork, +/* Subroutine */ int zggrqf_(integer *m, integer *p, integer *n, doublecomplex *a, integer *lda, doublecomplex *taua, doublecomplex *b, integer *ldb, doublecomplex *taub, doublecomplex *work, + integer *lwork, integer *info); + +/* Subroutine */ int zggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, integer *p, integer *k, integer *l, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, + doublereal *alpha, doublereal *beta, doublecomplex *u, integer *ldu, doublecomplex *v, integer *ldv, doublecomplex *q, integer *ldq, doublecomplex *work, + doublereal *rwork, integer *iwork, integer *info); + +/* Subroutine */ int zggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *tola, doublereal *tolb, + integer *k, integer *l, doublecomplex *u, integer *ldu, doublecomplex *v, integer *ldv, doublecomplex *q, integer *ldq, integer *iwork, doublereal *rwork, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zgtcon_(char *norm, integer *n, doublecomplex *dl, doublecomplex *d__, - doublecomplex *du, doublecomplex *du2, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info); +/* Subroutine */ int zgtcon_(char *norm, integer *n, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *du2, integer *ipiv, doublereal *anorm, doublereal *rcond, + doublecomplex *work, integer *info); -/* Subroutine */ int zgtrfs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *dlf, - doublecomplex *df, doublecomplex *duf, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, +/* Subroutine */ int zgtrfs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *dlf, doublecomplex *df, doublecomplex *duf, + doublecomplex *du2, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgtsv_(integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, - doublecomplex *du, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zgtsv_(integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *dlf, - doublecomplex *df, doublecomplex *duf, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, +/* Subroutine */ int zgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *dlf, doublecomplex *df, doublecomplex *duf, + doublecomplex *du2, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zgttrf_(integer *n, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, - doublecomplex *du2, integer *ipiv, integer *info); +/* Subroutine */ int zgttrf_(integer *n, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *du2, integer *ipiv, integer *info); -/* Subroutine */ int zgttrs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zgttrs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *du2, integer *ipiv, doublecomplex *b, integer *ldb, + integer *info); -/* Subroutine */ int zgtts2_(integer *itrans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb); +/* Subroutine */ int zgtts2_(integer *itrans, integer *n, integer *nrhs, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *du2, integer *ipiv, doublecomplex *b, integer *ldb); -/* Subroutine */ int zhbev_(char *jobz, char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zhbev_(char *jobz, char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, doublereal *rwork, + integer *info); -/* Subroutine */ int zhbevd_(char *jobz, char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int zhbevd_(char *jobz, char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, + doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zhbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublecomplex *q, integer *ldq, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, doublereal *rwork, integer *iwork, +/* Subroutine */ int zhbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublecomplex *q, integer *ldq, doublereal *vl, doublereal *vu, + integer *il, integer *iu, doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zhbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, - doublecomplex *x, integer *ldx, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zhbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, doublecomplex *x, integer *ldx, + doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, - doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zhbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, doublereal *w, doublecomplex *z__, + integer *ldz, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, - doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info); +/* Subroutine */ int zhbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, doublereal *w, doublecomplex *z__, + integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zhbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, doublecomplex *ab, integer *ldab, doublecomplex *bb, - integer *ldbb, doublecomplex *q, integer *ldq, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, doublereal *rwork, integer *iwork, integer *ifail, - integer *info); - -/* Subroutine */ int zhbtrd_(char *vect, char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *d__, doublereal *e, doublecomplex *q, - integer *ldq, doublecomplex *work, integer *info); +/* Subroutine */ int zhbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, integer *kb, doublecomplex *ab, integer *ldab, doublecomplex *bb, integer *ldbb, doublecomplex *q, + integer *ldq, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, integer *ldz, + doublecomplex *work, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zhecon_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, +/* Subroutine */ int zhbtrd_(char *vect, char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *d__, doublereal *e, doublecomplex *q, integer *ldq, doublecomplex *work, integer *info); -/* Subroutine */ int zheequb_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, doublecomplex *work, - integer *info); +/* Subroutine */ int zhecon_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublereal *anorm, doublereal *rcond, doublecomplex *work, integer *info); -/* Subroutine */ int zheev_(char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *w, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info); +/* Subroutine */ int zheequb_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, doublecomplex *work, integer *info); -/* Subroutine */ int zheevd_(char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *w, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int zheev_(char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *w, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); + +/* Subroutine */ int zheevd_(char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *w, doublecomplex *work, integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, + integer *liwork, integer *info); -/* Subroutine */ int zheevr_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, integer *isuppz, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, +/* Subroutine */ int zheevr_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublecomplex *z__, integer *ldz, integer *isuppz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zheevx_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int zheevx_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zhegs2_(integer *itype, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zhegs2_(integer *itype, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zhegst_(integer *itype, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zhegst_(integer *itype, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zhegv_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublereal *w, - doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); +/* Subroutine */ int zhegv_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *w, doublecomplex *work, integer *lwork, + doublereal *rwork, integer *info); -/* Subroutine */ int zhegvd_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublereal *w, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *lrwork, integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int zhegvd_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *w, doublecomplex *work, integer *lwork, + doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zhegvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, +/* Subroutine */ int zhegvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublereal *vl, doublereal *vu, + integer *il, integer *iu, doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zherfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); - -/* Subroutine */ int zherfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - doublereal *s, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); - -/* Subroutine */ int zhesv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *work, - integer *lwork, integer *info); - -/* Subroutine */ int zhesvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); +/* Subroutine */ int zherfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhesvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *s, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, - doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zherfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *s, doublecomplex *b, + integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, + integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhetd2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tau, integer *info); +/* Subroutine */ int zhesv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zhetf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int zhesvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, + doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zhetrd_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tau, - doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zhesvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, char *equed, doublereal *s, + doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhetrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zhetd2_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tau, integer *info); -/* Subroutine */ int zhetri_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *info); +/* Subroutine */ int zhetf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int zhetrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zhetrd_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zhfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, - doublereal *alpha, doublecomplex *a, integer *lda, doublereal *beta, - doublecomplex *c__); +/* Subroutine */ int zhetrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zhgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *t, - integer *ldt, doublecomplex *alpha, doublecomplex *beta, - doublecomplex *q, integer *ldq, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); +/* Subroutine */ int zhetri_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *work, integer *info); -/* Subroutine */ int zhpcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info); +/* Subroutine */ int zhetrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zhpev_(char *jobz, char *uplo, integer *n, doublecomplex *ap, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *info); - -/* Subroutine */ int zhpevd_(char *jobz, char *uplo, integer *n, doublecomplex *ap, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int zhfrk_(char *transr, char *uplo, char *trans, integer *n, integer *k, doublereal *alpha, doublecomplex *a, integer *lda, doublereal *beta, doublecomplex *c__); -/* Subroutine */ int zhpevx_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *ap, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, doublereal *rwork, integer *iwork, - integer *ifail, integer *info); +/* Subroutine */ int zhgeqz_(char *job, char *compq, char *compz, integer *n, integer *ilo, integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *t, integer *ldt, doublecomplex *alpha, + doublecomplex *beta, doublecomplex *q, integer *ldq, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zhpgst_(integer *itype, char *uplo, integer *n, doublecomplex *ap, - doublecomplex *bp, integer *info); +/* Subroutine */ int zhpcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, doublereal *anorm, doublereal *rcond, doublecomplex *work, integer *info); -/* Subroutine */ int zhpgv_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *ap, - doublecomplex *bp, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zhpev_(char *jobz, char *uplo, integer *n, doublecomplex *ap, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhpgvd_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *ap, - doublecomplex *bp, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, doublereal *rwork, +/* Subroutine */ int zhpevd_(char *jobz, char *uplo, integer *n, doublecomplex *ap, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zhpgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, - doublecomplex *ap, doublecomplex *bp, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, integer *m, - doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *ifail, integer *info); - -/* Subroutine */ int zhprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zhpevx_(char *jobz, char *range, char *uplo, integer *n, doublecomplex *ap, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zhpsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zhpgst_(integer *itype, char *uplo, integer *n, doublecomplex *ap, doublecomplex *bp, integer *info); -/* Subroutine */ int zhpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zhpgv_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *ap, doublecomplex *bp, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, + doublereal *rwork, integer *info); -/* Subroutine */ int zhptrd_(char *uplo, integer *n, doublecomplex *ap, doublereal *d__, - doublereal *e, doublecomplex *tau, integer *info); +/* Subroutine */ int zhpgvd_(integer *itype, char *jobz, char *uplo, integer *n, doublecomplex *ap, doublecomplex *bp, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, + integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zhptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - integer *info); +/* Subroutine */ int zhpgvx_(integer *itype, char *jobz, char *range, char *uplo, integer *n, doublecomplex *ap, doublecomplex *bp, doublereal *vl, doublereal *vu, integer *il, integer *iu, + doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, integer *ldz, doublecomplex *work, doublereal *rwork, integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zhptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublecomplex *work, integer *info); +/* Subroutine */ int zhprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zhpsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zhsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, - doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, integer *mm, - integer *m, doublecomplex *work, doublereal *rwork, integer *ifaill, - integer *ifailr, integer *info); +/* Subroutine */ int zhpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zhseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, - doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zhptrd_(char *uplo, integer *n, doublecomplex *ap, doublereal *d__, doublereal *e, doublecomplex *tau, integer *info); -/* Subroutine */ int zla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, - doublereal *alpha, doublecomplex *ab, integer *ldab, - doublecomplex *x, integer *incx, doublereal *beta, doublereal *y, - integer *incy); +/* Subroutine */ int zhptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, integer *info); -doublereal zla_gbrcond_c__(char *trans, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, - doublereal *c__, logical *capply, integer *info, doublecomplex *work, - doublereal *rwork, ftnlen trans_len); +/* Subroutine */ int zhptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, doublecomplex *work, integer *info); -doublereal zla_gbrcond_x__(char *trans, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, - doublecomplex *x, integer *info, doublecomplex *work, doublereal *rwork, - ftnlen trans_len); +/* Subroutine */ int zhptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zla_gbrfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, - logical *colequ, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, - doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, - doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, - doublereal *rcond, integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, - logical *ignore_cwise__, integer *info); +/* Subroutine */ int zhsein_(char *side, char *eigsrc, char *initv, logical *select, integer *n, doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *vl, integer *ldvl, + doublecomplex *vr, integer *ldvr, integer *mm, integer *m, doublecomplex *work, doublereal *rwork, integer *ifaill, integer *ifailr, integer *info); -doublereal zla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, doublecomplex *ab, - integer *ldab, doublecomplex *afb, integer *ldafb); +/* Subroutine */ int zhseqr_(char *job, char *compz, integer *n, integer *ilo, integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *z__, integer *ldz, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zla_geamv__(integer *trans, integer *m, integer *n, doublereal *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, +/* Subroutine */ int zla_gbamv__(integer *trans, integer *m, integer *n, integer *kl, integer *ku, doublereal *alpha, doublecomplex *ab, integer *ldab, doublecomplex *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -doublereal zla_gercond_c__(char *trans, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, - logical *capply, integer *info, doublecomplex *work, doublereal *rwork, - ftnlen trans_len); - -doublereal zla_gercond_x__(char *trans, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, +doublereal zla_gbrcond_c__(char *trans, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, doublereal *c__, logical *capply, integer *info, doublecomplex *work, doublereal *rwork, ftnlen trans_len); -/* Subroutine */ int zla_gerfsx_extended__( - integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, logical *colequ, doublereal *c__, - doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, - integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, - doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, integer *ithresh, - doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info); +doublereal zla_gbrcond_x__(char *trans, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, integer *ipiv, doublecomplex *x, integer *info, + doublecomplex *work, doublereal *rwork, ftnlen trans_len); -/* Subroutine */ int zla_heamv__(integer *uplo, integer *n, doublereal *alpha, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy); +/* Subroutine */ int zla_gbrfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, + integer *ldafb, integer *ipiv, logical *colequ, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, + integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, + doublereal *rcond, integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info); -doublereal zla_hercond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, - logical *capply, integer *info, doublecomplex *work, doublereal *rwork, - ftnlen uplo_len); +doublereal zla_gbrpvgrw__(integer *n, integer *kl, integer *ku, integer *ncols, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb); -doublereal zla_hercond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, - integer *info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len); +/* Subroutine */ int zla_geamv__(integer *trans, integer *m, integer *n, doublereal *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublereal *beta, doublereal *y, + integer *incy); -/* Subroutine */ int zla_herfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, logical *colequ, doublereal *c__, - doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, - integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, - doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, integer *ithresh, - doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, - ftnlen uplo_len); +doublereal zla_gercond_c__(char *trans, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, logical *capply, integer *info, + doublecomplex *work, doublereal *rwork, ftnlen trans_len); -doublereal zla_herpvgrw__(char *uplo, integer *n, integer *info, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *work, - ftnlen uplo_len); +doublereal zla_gercond_x__(char *trans, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, integer *info, doublecomplex *work, + doublereal *rwork, ftnlen trans_len); -/* Subroutine */ int zla_lin_berr__(integer *n, integer *nz, integer *nrhs, doublecomplex *res, - doublereal *ayb, doublereal *berr); +/* Subroutine */ int zla_gerfsx_extended__(integer *prec_type__, integer *trans_type__, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, + logical *colequ, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, + doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, + integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info); -doublereal zla_porcond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, doublereal *c__, logical *capply, - integer *info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len); +/* Subroutine */ int zla_heamv__(integer *uplo, integer *n, doublereal *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -doublereal zla_porcond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, doublecomplex *x, integer *info, +doublereal zla_hercond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, logical *capply, integer *info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len); -/* Subroutine */ int zla_porfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, logical *colequ, doublereal *c__, doublecomplex *b, - integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, - doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, doublereal *ayb, - doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, integer *ithresh, - doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, - ftnlen uplo_len); +doublereal zla_hercond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, integer *info, doublecomplex *work, + doublereal *rwork, ftnlen uplo_len); -doublereal zla_porpvgrw__(char *uplo, integer *ncols, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, doublereal *work, ftnlen uplo_len); +/* Subroutine */ int zla_herfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, + logical *colequ, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, + doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, + integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal zla_rpvgrw__(integer *n, integer *ncols, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf); +doublereal zla_herpvgrw__(char *uplo, integer *n, integer *info, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *work, ftnlen uplo_len); -/* Subroutine */ int zla_syamv__(integer *uplo, integer *n, doublereal *alpha, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy); +/* Subroutine */ int zla_lin_berr__(integer *n, integer *nz, integer *nrhs, doublecomplex *res, doublereal *ayb, doublereal *berr); + +doublereal zla_porcond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, doublereal *c__, logical *capply, integer *info, doublecomplex *work, + doublereal *rwork, ftnlen uplo_len); -doublereal zla_syrcond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, - logical *capply, integer *info, doublecomplex *work, doublereal *rwork, +doublereal zla_porcond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, doublecomplex *x, integer *info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len); -doublereal zla_syrcond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, - integer *info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len); +/* Subroutine */ int zla_porfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, logical *colequ, + doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, doublereal *errs_n__, + doublereal *errs_c__, doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, integer *ithresh, + doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); + +doublereal zla_porpvgrw__(char *uplo, integer *ncols, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, doublereal *work, ftnlen uplo_len); + +doublereal zla_rpvgrw__(integer *n, integer *ncols, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf); + +/* Subroutine */ int zla_syamv__(integer *uplo, integer *n, doublereal *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublereal *beta, doublereal *y, integer *incy); -/* Subroutine */ int zla_syrfsx_extended__( - integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, logical *colequ, doublereal *c__, - doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, - integer *n_norms__, doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, - doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, integer *ithresh, - doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, - ftnlen uplo_len); +doublereal zla_syrcond_c__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *c__, logical *capply, integer *info, + doublecomplex *work, doublereal *rwork, ftnlen uplo_len); + +doublereal zla_syrcond_x__(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *x, integer *info, doublecomplex *work, + doublereal *rwork, ftnlen uplo_len); + +/* Subroutine */ int zla_syrfsx_extended__(integer *prec_type__, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, + logical *colequ, doublereal *c__, doublecomplex *b, integer *ldb, doublecomplex *y, integer *ldy, doublereal *berr_out__, integer *n_norms__, + doublereal *errs_n__, doublereal *errs_c__, doublecomplex *res, doublereal *ayb, doublecomplex *dy, doublecomplex *y_tail__, doublereal *rcond, + integer *ithresh, doublereal *rthresh, doublereal *dz_ub__, logical *ignore_cwise__, integer *info, ftnlen uplo_len); -doublereal zla_syrpvgrw__(char *uplo, integer *n, integer *info, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *work, - ftnlen uplo_len); +doublereal zla_syrpvgrw__(char *uplo, integer *n, integer *info, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *work, ftnlen uplo_len); /* Subroutine */ int zla_wwaddw__(integer *n, doublecomplex *x, doublecomplex *y, doublecomplex *w); -/* Subroutine */ int zlabrd_(integer *m, integer *n, integer *nb, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tauq, - doublecomplex *taup, doublecomplex *x, integer *ldx, doublecomplex *y, - integer *ldy); +/* Subroutine */ int zlabrd_(integer *m, integer *n, integer *nb, doublecomplex *a, integer *lda, doublereal *d__, doublereal *e, doublecomplex *tauq, doublecomplex *taup, doublecomplex *x, + integer *ldx, doublecomplex *y, integer *ldy); /* Subroutine */ int zlacgv_(integer *n, doublecomplex *x, integer *incx); -/* Subroutine */ int zlacn2_(integer *n, doublecomplex *v, doublecomplex *x, doublereal *est, - integer *kase, integer *isave); +/* Subroutine */ int zlacn2_(integer *n, doublecomplex *v, doublecomplex *x, doublereal *est, integer *kase, integer *isave); -/* Subroutine */ int zlacon_(integer *n, doublecomplex *v, doublecomplex *x, doublereal *est, - integer *kase); +/* Subroutine */ int zlacon_(integer *n, doublecomplex *v, doublecomplex *x, doublereal *est, integer *kase); -/* Subroutine */ int zlacp2_(char *uplo, integer *m, integer *n, doublereal *a, integer *lda, - doublecomplex *b, integer *ldb); +/* Subroutine */ int zlacp2_(char *uplo, integer *m, integer *n, doublereal *a, integer *lda, doublecomplex *b, integer *ldb); -/* Subroutine */ int zlacpy_(char *uplo, integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb); +/* Subroutine */ int zlacpy_(char *uplo, integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb); -/* Subroutine */ int zlacrm_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *b, - integer *ldb, doublecomplex *c__, integer *ldc, doublereal *rwork); +/* Subroutine */ int zlacrm_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *b, integer *ldb, doublecomplex *c__, integer *ldc, doublereal *rwork); -/* Subroutine */ int zlacrt_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, - integer *incy, doublecomplex *c__, doublecomplex *s); +/* Subroutine */ int zlacrt_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, integer *incy, doublecomplex *c__, doublecomplex *s); /* Double Complex */ VOID zladiv_(doublecomplex *ret_val, doublecomplex *x, doublecomplex *y); -/* Subroutine */ int zlaed0_(integer *qsiz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *q, integer *ldq, doublecomplex *qstore, integer *ldqs, - doublereal *rwork, integer *iwork, integer *info); +/* Subroutine */ int zlaed0_(integer *qsiz, integer *n, doublereal *d__, doublereal *e, doublecomplex *q, integer *ldq, doublecomplex *qstore, integer *ldqs, doublereal *rwork, integer *iwork, + integer *info); -/* Subroutine */ int zlaed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, doublereal *d__, doublecomplex *q, - integer *ldq, doublereal *rho, integer *indxq, doublereal *qstore, - integer *qptr, integer *prmptr, integer *perm, integer *givptr, - integer *givcol, doublereal *givnum, doublecomplex *work, +/* Subroutine */ int zlaed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, integer *curlvl, integer *curpbm, doublereal *d__, doublecomplex *q, integer *ldq, doublereal *rho, + integer *indxq, doublereal *qstore, integer *qptr, integer *prmptr, integer *perm, integer *givptr, integer *givcol, doublereal *givnum, doublecomplex *work, doublereal *rwork, integer *iwork, integer *info); -/* Subroutine */ int zlaed8_(integer *k, integer *n, integer *qsiz, doublecomplex *q, integer *ldq, - doublereal *d__, doublereal *rho, integer *cutpnt, doublereal *z__, - doublereal *dlamda, doublecomplex *q2, integer *ldq2, doublereal *w, - integer *indxp, integer *indx, integer *indxq, integer *perm, - integer *givptr, integer *givcol, doublereal *givnum, integer *info); - -/* Subroutine */ int zlaein_(logical *rightv, logical *noinit, integer *n, doublecomplex *h__, - integer *ldh, doublecomplex *w, doublecomplex *v, doublecomplex *b, - integer *ldb, doublereal *rwork, doublereal *eps3, doublereal *smlnum, +/* Subroutine */ int zlaed8_(integer *k, integer *n, integer *qsiz, doublecomplex *q, integer *ldq, doublereal *d__, doublereal *rho, integer *cutpnt, doublereal *z__, doublereal *dlamda, + doublecomplex *q2, integer *ldq2, doublereal *w, integer *indxp, integer *indx, integer *indxq, integer *perm, integer *givptr, integer *givcol, doublereal *givnum, integer *info); -/* Subroutine */ int zlaesy_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, - doublecomplex *rt1, doublecomplex *rt2, doublecomplex *evscal, - doublecomplex *cs1, doublecomplex *sn1); +/* Subroutine */ int zlaein_(logical *rightv, logical *noinit, integer *n, doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *v, doublecomplex *b, integer *ldb, doublereal *rwork, + doublereal *eps3, doublereal *smlnum, integer *info); -/* Subroutine */ int zlaev2_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, - doublereal *rt1, doublereal *rt2, doublereal *cs1, doublecomplex *sn1); +/* Subroutine */ int zlaesy_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, doublecomplex *rt1, doublecomplex *rt2, doublecomplex *evscal, doublecomplex *cs1, doublecomplex *sn1); -/* Subroutine */ int zlag2c_(integer *m, integer *n, doublecomplex *a, integer *lda, complex *sa, - integer *ldsa, integer *info); +/* Subroutine */ int zlaev2_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, doublereal *rt1, doublereal *rt2, doublereal *cs1, doublecomplex *sn1); -/* Subroutine */ int zlags2_(logical *upper, doublereal *a1, doublecomplex *a2, doublereal *a3, - doublereal *b1, doublecomplex *b2, doublereal *b3, doublereal *csu, - doublecomplex *snu, doublereal *csv, doublecomplex *snv, - doublereal *csq, doublecomplex *snq); +/* Subroutine */ int zlag2c_(integer *m, integer *n, doublecomplex *a, integer *lda, complex *sa, integer *ldsa, integer *info); -/* Subroutine */ int zlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, - doublecomplex *dl, doublecomplex *d__, doublecomplex *du, - doublecomplex *x, integer *ldx, doublereal *beta, doublecomplex *b, - integer *ldb); +/* Subroutine */ int zlags2_(logical *upper, doublereal *a1, doublecomplex *a2, doublereal *a3, doublereal *b1, doublecomplex *b2, doublereal *b3, doublereal *csu, doublecomplex *snu, doublereal *csv, + doublecomplex *snv, doublereal *csq, doublecomplex *snq); -/* Subroutine */ int zlahef_(char *uplo, integer *n, integer *nb, integer *kb, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *w, integer *ldw, - integer *info); +/* Subroutine */ int zlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, doublecomplex *dl, doublecomplex *d__, doublecomplex *du, doublecomplex *x, integer *ldx, doublereal *beta, + doublecomplex *b, integer *ldb); -/* Subroutine */ int zlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, - integer *ihiz, doublecomplex *z__, integer *ldz, integer *info); +/* Subroutine */ int zlahef_(char *uplo, integer *n, integer *nb, integer *kb, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *w, integer *ldw, integer *info); -/* Subroutine */ int zlahr2_(integer *n, integer *k, integer *nb, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *t, integer *ldt, doublecomplex *y, - integer *ldy); +/* Subroutine */ int zlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, integer *ihiz, + doublecomplex *z__, integer *ldz, integer *info); -/* Subroutine */ int zlahrd_(integer *n, integer *k, integer *nb, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *t, integer *ldt, doublecomplex *y, - integer *ldy); +/* Subroutine */ int zlahr2_(integer *n, integer *k, integer *nb, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *t, integer *ldt, doublecomplex *y, integer *ldy); -/* Subroutine */ int zlaic1_(integer *job, integer *j, doublecomplex *x, doublereal *sest, - doublecomplex *w, doublecomplex *gamma, doublereal *sestpr, - doublecomplex *s, doublecomplex *c__); +/* Subroutine */ int zlahrd_(integer *n, integer *k, integer *nb, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *t, integer *ldt, doublecomplex *y, integer *ldy); -/* Subroutine */ int zlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, doublecomplex *b, integer *ldb, doublecomplex *bx, - integer *ldbx, integer *perm, integer *givptr, integer *givcol, - integer *ldgcol, doublereal *givnum, integer *ldgnum, - doublereal *poles, doublereal *difl, doublereal *difr, doublereal *z__, - integer *k, doublereal *c__, doublereal *s, doublereal *rwork, - integer *info); +/* Subroutine */ int zlaic1_(integer *job, integer *j, doublecomplex *x, doublereal *sest, doublecomplex *w, doublecomplex *gamma, doublereal *sestpr, doublecomplex *s, doublecomplex *c__); -/* Subroutine */ int zlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - doublecomplex *b, integer *ldb, doublecomplex *bx, integer *ldbx, - doublereal *u, integer *ldu, doublereal *vt, integer *k, - doublereal *difl, doublereal *difr, doublereal *z__, doublereal *poles, - integer *givptr, integer *givcol, integer *ldgcol, integer *perm, - doublereal *givnum, doublereal *c__, doublereal *s, doublereal *rwork, - integer *iwork, integer *info); +/* Subroutine */ int zlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, integer *nrhs, doublecomplex *b, integer *ldb, doublecomplex *bx, integer *ldbx, integer *perm, integer *givptr, + integer *givcol, integer *ldgcol, doublereal *givnum, integer *ldgnum, doublereal *poles, doublereal *difl, doublereal *difr, doublereal *z__, integer *k, doublereal *c__, + doublereal *s, doublereal *rwork, integer *info); -/* Subroutine */ int zlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - doublereal *d__, doublereal *e, doublecomplex *b, integer *ldb, - doublereal *rcond, integer *rank, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *info); +/* Subroutine */ int zlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, doublecomplex *b, integer *ldb, doublecomplex *bx, integer *ldbx, doublereal *u, integer *ldu, doublereal *vt, + integer *k, doublereal *difl, doublereal *difr, doublereal *z__, doublereal *poles, integer *givptr, integer *givcol, integer *ldgcol, integer *perm, doublereal *givnum, + doublereal *c__, doublereal *s, doublereal *rwork, integer *iwork, integer *info); + +/* Subroutine */ int zlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, doublereal *d__, doublereal *e, doublecomplex *b, integer *ldb, doublereal *rcond, integer *rank, + doublecomplex *work, doublereal *rwork, integer *iwork, integer *info); -doublereal zlangb_(char *norm, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublereal *work); +doublereal zlangb_(char *norm, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublereal *work); -doublereal zlange_(char *norm, integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *work); +doublereal zlange_(char *norm, integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *work); -doublereal zlangt_(char *norm, integer *n, doublecomplex *dl, doublecomplex *d__, - doublecomplex *du); +doublereal zlangt_(char *norm, integer *n, doublecomplex *dl, doublecomplex *d__, doublecomplex *du); -doublereal zlanhb_(char *norm, char *uplo, integer *n, integer *k, doublecomplex *ab, integer *ldab, - doublereal *work); +doublereal zlanhb_(char *norm, char *uplo, integer *n, integer *k, doublecomplex *ab, integer *ldab, doublereal *work); -doublereal zlanhe_(char *norm, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *work); +doublereal zlanhe_(char *norm, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *work); -doublereal zlanhf_(char *norm, char *transr, char *uplo, integer *n, doublecomplex *a, - doublereal *work); +doublereal zlanhf_(char *norm, char *transr, char *uplo, integer *n, doublecomplex *a, doublereal *work); doublereal zlanhp_(char *norm, char *uplo, integer *n, doublecomplex *ap, doublereal *work); @@ -6003,304 +3769,189 @@ doublereal zlanhs_(char *norm, integer *n, doublecomplex *a, integer *lda, doubl doublereal zlanht_(char *norm, integer *n, doublereal *d__, doublecomplex *e); -doublereal zlansb_(char *norm, char *uplo, integer *n, integer *k, doublecomplex *ab, integer *ldab, - doublereal *work); +doublereal zlansb_(char *norm, char *uplo, integer *n, integer *k, doublecomplex *ab, integer *ldab, doublereal *work); doublereal zlansp_(char *norm, char *uplo, integer *n, doublecomplex *ap, doublereal *work); -doublereal zlansy_(char *norm, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *work); +doublereal zlansy_(char *norm, char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *work); + +doublereal zlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, doublecomplex *ab, integer *ldab, doublereal *work); -doublereal zlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, doublecomplex *ab, - integer *ldab, doublereal *work); +doublereal zlantp_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *ap, doublereal *work); -doublereal zlantp_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *ap, - doublereal *work); +doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *work); -doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, doublecomplex *a, - integer *lda, doublereal *work); +/* Subroutine */ int zlapll_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublereal *ssmin); -/* Subroutine */ int zlapll_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublereal *ssmin); +/* Subroutine */ int zlapmt_(logical *forwrd, integer *m, integer *n, doublecomplex *x, integer *ldx, integer *k); -/* Subroutine */ int zlapmt_(logical *forwrd, integer *m, integer *n, doublecomplex *x, - integer *ldx, integer *k); +/* Subroutine */ int zlaqgb_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, + doublereal *amax, char *equed); -/* Subroutine */ int zlaqgb_(integer *m, integer *n, integer *kl, integer *ku, doublecomplex *ab, - integer *ldab, doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, char *equed); +/* Subroutine */ int zlaqge_(integer *m, integer *n, doublecomplex *a, integer *lda, doublereal *r__, doublereal *c__, doublereal *rowcnd, doublereal *colcnd, doublereal *amax, char *equed); -/* Subroutine */ int zlaqge_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, char *equed); +/* Subroutine */ int zlaqhb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlaqhb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - doublereal *s, doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqhe_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlaqhe_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqhp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlaqhp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqp2_(integer *m, integer *n, integer *offset, doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, doublereal *vn1, doublereal *vn2, doublecomplex *work); -/* Subroutine */ int zlaqp2_(integer *m, integer *n, integer *offset, doublecomplex *a, - integer *lda, integer *jpvt, doublecomplex *tau, doublereal *vn1, - doublereal *vn2, doublecomplex *work); +/* Subroutine */ int zlaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, doublereal *vn1, doublereal *vn2, + doublecomplex *auxv, doublecomplex *f, integer *ldf); -/* Subroutine */ int zlaqps_(integer *m, integer *n, integer *offset, integer *nb, integer *kb, - doublecomplex *a, integer *lda, integer *jpvt, doublecomplex *tau, - doublereal *vn1, doublereal *vn2, doublecomplex *auxv, - doublecomplex *f, integer *ldf); +/* Subroutine */ int zlaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, integer *ihiz, + doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zlaqr0_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, - integer *ihiz, doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, integer *info); +/* Subroutine */ int zlaqr1_(integer *n, doublecomplex *h__, integer *ldh, doublecomplex *s1, doublecomplex *s2, doublecomplex *v); -/* Subroutine */ int zlaqr1_(integer *n, doublecomplex *h__, integer *ldh, doublecomplex *s1, - doublecomplex *s2, doublecomplex *v); - -/* Subroutine */ int zlaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, doublecomplex *h__, integer *ldh, - integer *iloz, integer *ihiz, doublecomplex *z__, integer *ldz, - integer *ns, integer *nd, doublecomplex *sh, doublecomplex *v, - integer *ldv, integer *nh, doublecomplex *t, integer *ldt, integer *nv, - doublecomplex *wv, integer *ldwv, doublecomplex *work, integer *lwork); - -/* Subroutine */ int zlaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, - integer *kbot, integer *nw, doublecomplex *h__, integer *ldh, - integer *iloz, integer *ihiz, doublecomplex *z__, integer *ldz, - integer *ns, integer *nd, doublecomplex *sh, doublecomplex *v, - integer *ldv, integer *nh, doublecomplex *t, integer *ldt, integer *nv, - doublecomplex *wv, integer *ldwv, doublecomplex *work, integer *lwork); - -/* Subroutine */ int zlaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, - doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, - integer *ihiz, doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, integer *info); +/* Subroutine */ int zlaqr2_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, doublecomplex *h__, integer *ldh, integer *iloz, integer *ihiz, doublecomplex *z__, + integer *ldz, integer *ns, integer *nd, doublecomplex *sh, doublecomplex *v, integer *ldv, integer *nh, doublecomplex *t, integer *ldt, integer *nv, doublecomplex *wv, + integer *ldwv, doublecomplex *work, integer *lwork); -/* Subroutine */ int zlaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, - integer *ktop, integer *kbot, integer *nshfts, doublecomplex *s, - doublecomplex *h__, integer *ldh, integer *iloz, integer *ihiz, - doublecomplex *z__, integer *ldz, doublecomplex *v, integer *ldv, - doublecomplex *u, integer *ldu, integer *nv, doublecomplex *wv, +/* Subroutine */ int zlaqr3_(logical *wantt, logical *wantz, integer *n, integer *ktop, integer *kbot, integer *nw, doublecomplex *h__, integer *ldh, integer *iloz, integer *ihiz, doublecomplex *z__, + integer *ldz, integer *ns, integer *nd, doublecomplex *sh, doublecomplex *v, integer *ldv, integer *nh, doublecomplex *t, integer *ldt, integer *nv, doublecomplex *wv, + integer *ldwv, doublecomplex *work, integer *lwork); + +/* Subroutine */ int zlaqr4_(logical *wantt, logical *wantz, integer *n, integer *ilo, integer *ihi, doublecomplex *h__, integer *ldh, doublecomplex *w, integer *iloz, integer *ihiz, + doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, integer *info); + +/* Subroutine */ int zlaqr5_(logical *wantt, logical *wantz, integer *kacc22, integer *n, integer *ktop, integer *kbot, integer *nshfts, doublecomplex *s, doublecomplex *h__, integer *ldh, + integer *iloz, integer *ihiz, doublecomplex *z__, integer *ldz, doublecomplex *v, integer *ldv, doublecomplex *u, integer *ldu, integer *nv, doublecomplex *wv, integer *ldwv, integer *nh, doublecomplex *wh, integer *ldwh); -/* Subroutine */ int zlaqsb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - doublereal *s, doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqsb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlaqsp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqsp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlaqsy_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, char *equed); +/* Subroutine */ int zlaqsy_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, char *equed); -/* Subroutine */ int zlar1v_(integer *n, integer *b1, integer *bn, doublereal *lambda, - doublereal *d__, doublereal *l, doublereal *ld, doublereal *lld, - doublereal *pivmin, doublereal *gaptol, doublecomplex *z__, - logical *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma, - integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid, +/* Subroutine */ int zlar1v_(integer *n, integer *b1, integer *bn, doublereal *lambda, doublereal *d__, doublereal *l, doublereal *ld, doublereal *lld, doublereal *pivmin, doublereal *gaptol, + doublecomplex *z__, logical *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma, integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid, doublereal *rqcorr, doublereal *work); -/* Subroutine */ int zlar2v_(integer *n, doublecomplex *x, doublecomplex *y, doublecomplex *z__, - integer *incx, doublereal *c__, doublecomplex *s, integer *incc); +/* Subroutine */ int zlar2v_(integer *n, doublecomplex *x, doublecomplex *y, doublecomplex *z__, integer *incx, doublereal *c__, doublecomplex *s, integer *incc); -/* Subroutine */ int zlarcm_(integer *m, integer *n, doublereal *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *c__, integer *ldc, doublereal *rwork); +/* Subroutine */ int zlarcm_(integer *m, integer *n, doublereal *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, integer *ldc, doublereal *rwork); -/* Subroutine */ int zlarf_(char *side, integer *m, integer *n, doublecomplex *v, integer *incv, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work); +/* Subroutine */ int zlarf_(char *side, integer *m, integer *n, doublecomplex *v, integer *incv, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work); -/* Subroutine */ int zlarfb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, doublecomplex *v, integer *ldv, - doublecomplex *t, integer *ldt, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *ldwork); +/* Subroutine */ int zlarfb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, doublecomplex *v, integer *ldv, doublecomplex *t, integer *ldt, + doublecomplex *c__, integer *ldc, doublecomplex *work, integer *ldwork); -/* Subroutine */ int zlarfg_(integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, - doublecomplex *tau); +/* Subroutine */ int zlarfg_(integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *tau); -/* Subroutine */ int zlarfp_(integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, - doublecomplex *tau); +/* Subroutine */ int zlarfp_(integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *tau); -/* Subroutine */ int zlarft_(char *direct, char *storev, integer *n, integer *k, doublecomplex *v, - integer *ldv, doublecomplex *tau, doublecomplex *t, integer *ldt); +/* Subroutine */ int zlarft_(char *direct, char *storev, integer *n, integer *k, doublecomplex *v, integer *ldv, doublecomplex *tau, doublecomplex *t, integer *ldt); -/* Subroutine */ int zlarfx_(char *side, integer *m, integer *n, doublecomplex *v, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work); +/* Subroutine */ int zlarfx_(char *side, integer *m, integer *n, doublecomplex *v, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work); -/* Subroutine */ int zlargv_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublereal *c__, integer *incc); +/* Subroutine */ int zlargv_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublereal *c__, integer *incc); /* Subroutine */ int zlarnv_(integer *idist, integer *iseed, integer *n, doublecomplex *x); -/* Subroutine */ int zlarrv_(integer *n, doublereal *vl, doublereal *vu, doublereal *d__, - doublereal *l, doublereal *pivmin, integer *isplit, integer *m, - integer *dol, integer *dou, doublereal *minrgp, doublereal *rtol1, - doublereal *rtol2, doublereal *w, doublereal *werr, doublereal *wgap, - integer *iblock, integer *indexw, doublereal *gers, doublecomplex *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *iwork, - integer *info); +/* Subroutine */ int zlarrv_(integer *n, doublereal *vl, doublereal *vu, doublereal *d__, doublereal *l, doublereal *pivmin, integer *isplit, integer *m, integer *dol, integer *dou, + doublereal *minrgp, doublereal *rtol1, doublereal *rtol2, doublereal *w, doublereal *werr, doublereal *wgap, integer *iblock, integer *indexw, doublereal *gers, + doublecomplex *z__, integer *ldz, integer *isuppz, doublereal *work, integer *iwork, integer *info); -/* Subroutine */ int zlarscl2_(integer *m, integer *n, doublereal *d__, doublecomplex *x, - integer *ldx); +/* Subroutine */ int zlarscl2_(integer *m, integer *n, doublereal *d__, doublecomplex *x, integer *ldx); -/* Subroutine */ int zlartg_(doublecomplex *f, doublecomplex *g, doublereal *cs, doublecomplex *sn, - doublecomplex *r__); +/* Subroutine */ int zlartg_(doublecomplex *f, doublecomplex *g, doublereal *cs, doublecomplex *sn, doublecomplex *r__); -/* Subroutine */ int zlartv_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublereal *c__, doublecomplex *s, integer *incc); +/* Subroutine */ int zlartv_(integer *n, doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, doublereal *c__, doublecomplex *s, integer *incc); -/* Subroutine */ int zlarz_(char *side, integer *m, integer *n, integer *l, doublecomplex *v, - integer *incv, doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work); +/* Subroutine */ int zlarz_(char *side, integer *m, integer *n, integer *l, doublecomplex *v, integer *incv, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work); -/* Subroutine */ int zlarzb_(char *side, char *trans, char *direct, char *storev, integer *m, - integer *n, integer *k, integer *l, doublecomplex *v, integer *ldv, - doublecomplex *t, integer *ldt, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *ldwork); +/* Subroutine */ int zlarzb_(char *side, char *trans, char *direct, char *storev, integer *m, integer *n, integer *k, integer *l, doublecomplex *v, integer *ldv, doublecomplex *t, integer *ldt, + doublecomplex *c__, integer *ldc, doublecomplex *work, integer *ldwork); -/* Subroutine */ int zlarzt_(char *direct, char *storev, integer *n, integer *k, doublecomplex *v, - integer *ldv, doublecomplex *tau, doublecomplex *t, integer *ldt); +/* Subroutine */ int zlarzt_(char *direct, char *storev, integer *n, integer *k, doublecomplex *v, integer *ldv, doublecomplex *tau, doublecomplex *t, integer *ldt); -/* Subroutine */ int zlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, - doublereal *cto, integer *m, integer *n, doublecomplex *a, - integer *lda, integer *info); +/* Subroutine */ int zlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, doublereal *cto, integer *m, integer *n, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int zlascl2_(integer *m, integer *n, doublereal *d__, doublecomplex *x, - integer *ldx); +/* Subroutine */ int zlascl2_(integer *m, integer *n, doublereal *d__, doublecomplex *x, integer *ldx); -/* Subroutine */ int zlaset_(char *uplo, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *a, integer *lda); +/* Subroutine */ int zlaset_(char *uplo, integer *m, integer *n, doublecomplex *alpha, doublecomplex *beta, doublecomplex *a, integer *lda); -/* Subroutine */ int zlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - doublereal *c__, doublereal *s, doublecomplex *a, integer *lda); +/* Subroutine */ int zlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, doublereal *c__, doublereal *s, doublecomplex *a, integer *lda); -/* Subroutine */ int zlassq_(integer *n, doublecomplex *x, integer *incx, doublereal *scale, - doublereal *sumsq); +/* Subroutine */ int zlassq_(integer *n, doublecomplex *x, integer *incx, doublereal *scale, doublereal *sumsq); -/* Subroutine */ int zlaswp_(integer *n, doublecomplex *a, integer *lda, integer *k1, integer *k2, - integer *ipiv, integer *incx); +/* Subroutine */ int zlaswp_(integer *n, doublecomplex *a, integer *lda, integer *k1, integer *k2, integer *ipiv, integer *incx); -/* Subroutine */ int zlasyf_(char *uplo, integer *n, integer *nb, integer *kb, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *w, integer *ldw, - integer *info); +/* Subroutine */ int zlasyf_(char *uplo, integer *n, integer *nb, integer *kb, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *w, integer *ldw, integer *info); -/* Subroutine */ int zlat2c_(char *uplo, integer *n, doublecomplex *a, integer *lda, complex *sa, - integer *ldsa, integer *info); +/* Subroutine */ int zlat2c_(char *uplo, integer *n, doublecomplex *a, integer *lda, complex *sa, integer *ldsa, integer *info); -/* Subroutine */ int zlatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - integer *kd, doublecomplex *ab, integer *ldab, doublecomplex *x, - doublereal *scale, doublereal *cnorm, integer *info); +/* Subroutine */ int zlatbs_(char *uplo, char *trans, char *diag, char *normin, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublecomplex *x, doublereal *scale, doublereal *cnorm, + integer *info); -/* Subroutine */ int zlatdf_(integer *ijob, integer *n, doublecomplex *z__, integer *ldz, - doublecomplex *rhs, doublereal *rdsum, doublereal *rdscal, - integer *ipiv, integer *jpiv); +/* Subroutine */ int zlatdf_(integer *ijob, integer *n, doublecomplex *z__, integer *ldz, doublecomplex *rhs, doublereal *rdsum, doublereal *rdscal, integer *ipiv, integer *jpiv); -/* Subroutine */ int zlatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, - doublecomplex *ap, doublecomplex *x, doublereal *scale, - doublereal *cnorm, integer *info); +/* Subroutine */ int zlatps_(char *uplo, char *trans, char *diag, char *normin, integer *n, doublecomplex *ap, doublecomplex *x, doublereal *scale, doublereal *cnorm, integer *info); -/* Subroutine */ int zlatrd_(char *uplo, integer *n, integer *nb, doublecomplex *a, integer *lda, - doublereal *e, doublecomplex *tau, doublecomplex *w, integer *ldw); +/* Subroutine */ int zlatrd_(char *uplo, integer *n, integer *nb, doublecomplex *a, integer *lda, doublereal *e, doublecomplex *tau, doublecomplex *w, integer *ldw); -/* Subroutine */ int zlatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, - doublecomplex *a, integer *lda, doublecomplex *x, doublereal *scale, - doublereal *cnorm, integer *info); +/* Subroutine */ int zlatrs_(char *uplo, char *trans, char *diag, char *normin, integer *n, doublecomplex *a, integer *lda, doublecomplex *x, doublereal *scale, doublereal *cnorm, integer *info); -/* Subroutine */ int zlatrz_(integer *m, integer *n, integer *l, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work); +/* Subroutine */ int zlatrz_(integer *m, integer *n, integer *l, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work); -/* Subroutine */ int zlatzm_(char *side, integer *m, integer *n, doublecomplex *v, integer *incv, - doublecomplex *tau, doublecomplex *c1, doublecomplex *c2, integer *ldc, - doublecomplex *work); +/* Subroutine */ int zlatzm_(char *side, integer *m, integer *n, doublecomplex *v, integer *incv, doublecomplex *tau, doublecomplex *c1, doublecomplex *c2, integer *ldc, doublecomplex *work); /* Subroutine */ int zlauu2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *info); /* Subroutine */ int zlauum_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int zpbcon_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zpbcon_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *anorm, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zpbequ_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - doublereal *s, doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int zpbequ_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int zpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, - integer *ldab, doublecomplex *afb, integer *ldafb, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zpbstf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - integer *info); +/* Subroutine */ int zpbstf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, integer *info); -/* Subroutine */ int zpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, - integer *ldab, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, - char *equed, doublereal *s, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, +/* Subroutine */ int zpbsvx_(char *fact, char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb, char *equed, doublereal *s, + doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zpbtf2_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - integer *info); +/* Subroutine */ int zpbtf2_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, integer *info); -/* Subroutine */ int zpbtrf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, - integer *info); +/* Subroutine */ int zpbtrf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, integer *ldab, integer *info); -/* Subroutine */ int zpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, - integer *ldab, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, integer *ldb, integer *info); /* Subroutine */ int zpftrf_(char *transr, char *uplo, integer *n, doublecomplex *a, integer *info); /* Subroutine */ int zpftri_(char *transr, char *uplo, integer *n, doublecomplex *a, integer *info); -/* Subroutine */ int zpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpftrs_(char *transr, char *uplo, integer *n, integer *nrhs, doublecomplex *a, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zpocon_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zpocon_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *anorm, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zpoequ_(integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int zpoequ_(integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int zpoequb_(integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int zpoequb_(integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int zporfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zporfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, doublereal *s, - doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *berr, integer *n_err_bnds__, - doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, - integer *nparams, doublereal *params, doublecomplex *work, - doublereal *rwork, integer *info); - -/* Subroutine */ int zposv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *info); - -/* Subroutine */ int zposvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, char *equed, - doublereal *s, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zporfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, doublereal *s, doublecomplex *b, integer *ldb, + doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, + doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, char *equed, - doublereal *s, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zposv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *info); + +/* Subroutine */ int zposvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, char *equed, doublereal *s, doublecomplex *b, + integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); + +/* Subroutine */ int zposvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, char *equed, doublereal *s, doublecomplex *b, + integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, + doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); /* Subroutine */ int zpotf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *info); @@ -6308,446 +3959,268 @@ doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, d /* Subroutine */ int zpotri_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int zpotrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpotrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zppcon_(char *uplo, integer *n, doublecomplex *ap, doublereal *anorm, - doublereal *rcond, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zppcon_(char *uplo, integer *n, doublecomplex *ap, doublereal *anorm, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zppequ_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); +/* Subroutine */ int zppequ_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, doublereal *scond, doublereal *amax, integer *info); -/* Subroutine */ int zpprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zpprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zppsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zppsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, char *equed, doublereal *s, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, char *equed, doublereal *s, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); /* Subroutine */ int zpptrf_(char *uplo, integer *n, doublecomplex *ap, integer *info); /* Subroutine */ int zpptri_(char *uplo, integer *n, doublecomplex *ap, integer *info); -/* Subroutine */ int zpptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zpstf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *piv, - integer *rank, doublereal *tol, doublereal *work, integer *info); +/* Subroutine */ int zpstf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *piv, integer *rank, doublereal *tol, doublereal *work, integer *info); -/* Subroutine */ int zpstrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *piv, - integer *rank, doublereal *tol, doublereal *work, integer *info); +/* Subroutine */ int zpstrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *piv, integer *rank, doublereal *tol, doublereal *work, integer *info); -/* Subroutine */ int zptcon_(integer *n, doublereal *d__, doublecomplex *e, doublereal *anorm, - doublereal *rcond, doublereal *rwork, integer *info); +/* Subroutine */ int zptcon_(integer *n, doublereal *d__, doublecomplex *e, doublereal *anorm, doublereal *rcond, doublereal *rwork, integer *info); -/* Subroutine */ int zpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int zpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, doublecomplex *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int zptrfs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublereal *df, doublecomplex *ef, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zptrfs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, doublereal *df, doublecomplex *ef, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zptsv_(integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zptsv_(integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublereal *df, doublecomplex *ef, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int zptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, doublereal *df, doublecomplex *ef, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); /* Subroutine */ int zpttrf_(integer *n, doublereal *d__, doublecomplex *e, integer *info); -/* Subroutine */ int zpttrs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zpttrs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zptts2_(integer *iuplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublecomplex *b, integer *ldb); +/* Subroutine */ int zptts2_(integer *iuplo, integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, doublecomplex *b, integer *ldb); -/* Subroutine */ int zrot_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, - integer *incy, doublereal *c__, doublecomplex *s); +/* Subroutine */ int zrot_(integer *n, doublecomplex *cx, integer *incx, doublecomplex *cy, integer *incy, doublereal *c__, doublecomplex *s); -/* Subroutine */ int zspcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info); - -/* Subroutine */ int zspmv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *ap, - doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy); +/* Subroutine */ int zspcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, doublereal *anorm, doublereal *rcond, doublecomplex *work, integer *info); -/* Subroutine */ int zspr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *ap); +/* Subroutine */ int zspmv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *ap, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, integer *incy); -/* Subroutine */ int zsprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zspr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *ap); -/* Subroutine */ int zspsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, - doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zsprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zspsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zsptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - integer *info); +/* Subroutine */ int zspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *afp, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zsptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublecomplex *work, integer *info); +/* Subroutine */ int zsptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, integer *info); -/* Subroutine */ int zsptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zsptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, doublecomplex *work, integer *info); -/* Subroutine */ int zstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int zsptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int zstegr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, doublecomplex *z__, - integer *ldz, integer *isuppz, doublereal *work, integer *lwork, +/* Subroutine */ int zstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, doublecomplex *z__, integer *ldz, doublecomplex *work, integer *lwork, doublereal *rwork, integer *lrwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zstein_(integer *n, doublereal *d__, doublereal *e, integer *m, doublereal *w, - integer *iblock, integer *isplit, doublecomplex *z__, integer *ldz, - doublereal *work, integer *iwork, integer *ifail, integer *info); +/* Subroutine */ int zstegr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, doublereal *abstol, integer *m, + doublereal *w, doublecomplex *z__, integer *ldz, integer *isuppz, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zstemr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, - doublereal *vl, doublereal *vu, integer *il, integer *iu, integer *m, - doublereal *w, doublecomplex *z__, integer *ldz, integer *nzc, - integer *isuppz, logical *tryrac, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); +/* Subroutine */ int zstein_(integer *n, doublereal *d__, doublereal *e, integer *m, doublereal *w, integer *iblock, integer *isplit, doublecomplex *z__, integer *ldz, doublereal *work, + integer *iwork, integer *ifail, integer *info); -/* Subroutine */ int zsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublereal *work, integer *info); +/* Subroutine */ int zstemr_(char *jobz, char *range, integer *n, doublereal *d__, doublereal *e, doublereal *vl, doublereal *vu, integer *il, integer *iu, integer *m, doublereal *w, + doublecomplex *z__, integer *ldz, integer *nzc, integer *isuppz, logical *tryrac, doublereal *work, integer *lwork, integer *iwork, integer *liwork, integer *info); -/* Subroutine */ int zsycon_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info); +/* Subroutine */ int zsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, doublecomplex *z__, integer *ldz, doublereal *work, integer *info); -/* Subroutine */ int zsyequb_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, doublecomplex *work, - integer *info); +/* Subroutine */ int zsycon_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublereal *anorm, doublereal *rcond, doublecomplex *work, integer *info); -/* Subroutine */ int zsymv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *a, - integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, - doublecomplex *y, integer *incy); +/* Subroutine */ int zsyequb_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublereal *s, doublereal *scond, doublereal *amax, doublecomplex *work, integer *info); -/* Subroutine */ int zsyr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *a, integer *lda); +/* Subroutine */ int zsymv_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *a, integer *lda, doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *y, integer *incy); -/* Subroutine */ int zsyrfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zsyr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, integer *incx, doublecomplex *a, integer *lda); -/* Subroutine */ int zsyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - doublereal *s, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *berr, - integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); - -/* Subroutine */ int zsysv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *work, - integer *lwork, integer *info); - -/* Subroutine */ int zsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); +/* Subroutine */ int zsyrfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zsysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, - char *equed, doublereal *s, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, - doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, - doublereal *err_bnds_comp__, integer *nparams, doublereal *params, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zsyrfsx_(char *uplo, char *equed, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublereal *s, doublecomplex *b, + integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, + integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zsytf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *info); +/* Subroutine */ int zsysv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zsytrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, + doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, doublereal *berr, doublecomplex *work, integer *lwork, doublereal *rwork, integer *info); -/* Subroutine */ int zsytri_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *info); +/* Subroutine */ int zsysvxx_(char *fact, char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *af, integer *ldaf, integer *ipiv, char *equed, doublereal *s, + doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, doublereal *berr, integer *n_err_bnds__, + doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *nparams, doublereal *params, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int zsytrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int zsytf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, integer *info); -/* Subroutine */ int ztbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublereal *rcond, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int zsytrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int ztbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int zsytri_(char *uplo, integer *n, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *work, integer *info); -/* Subroutine */ int ztbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, - integer *ldb, integer *info); +/* Subroutine */ int zsytrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int ztfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, - integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, - doublecomplex *b, integer *ldb); +/* Subroutine */ int ztbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, doublecomplex *ab, integer *ldab, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztftri_(char *transr, char *uplo, char *diag, integer *n, doublecomplex *a, - integer *info); +/* Subroutine */ int ztbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, integer *ldb, doublecomplex *x, + integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztfttp_(char *transr, char *uplo, integer *n, doublecomplex *arf, - doublecomplex *ap, integer *info); +/* Subroutine */ int ztbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, integer *nrhs, doublecomplex *ab, integer *ldab, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int ztfttr_(char *transr, char *uplo, integer *n, doublecomplex *arf, - doublecomplex *a, integer *lda, integer *info); +/* Subroutine */ int ztfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, integer *m, integer *n, doublecomplex *alpha, doublecomplex *a, doublecomplex *b, integer *ldb); -/* Subroutine */ int ztgevc_(char *side, char *howmny, logical *select, integer *n, - doublecomplex *s, integer *lds, doublecomplex *p, integer *ldp, - doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *ldvr, - integer *mm, integer *m, doublecomplex *work, doublereal *rwork, - integer *info); +/* Subroutine */ int ztftri_(char *transr, char *uplo, char *diag, integer *n, doublecomplex *a, integer *info); -/* Subroutine */ int ztgex2_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *q, - integer *ldq, doublecomplex *z__, integer *ldz, integer *j1, - integer *info); +/* Subroutine */ int ztfttp_(char *transr, char *uplo, integer *n, doublecomplex *arf, doublecomplex *ap, integer *info); -/* Subroutine */ int ztgexc_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *q, - integer *ldq, doublecomplex *z__, integer *ldz, integer *ifst, - integer *ilst, integer *info); +/* Subroutine */ int ztfttr_(char *transr, char *uplo, integer *n, doublecomplex *arf, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int ztgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *alpha, doublecomplex *beta, - doublecomplex *q, integer *ldq, doublecomplex *z__, integer *ldz, - integer *m, doublereal *pl, doublereal *pr, doublereal *dif, - doublecomplex *work, integer *lwork, integer *iwork, integer *liwork, - integer *info); +/* Subroutine */ int ztgevc_(char *side, char *howmny, logical *select, integer *n, doublecomplex *s, integer *lds, doublecomplex *p, integer *ldp, doublecomplex *vl, integer *ldvl, doublecomplex *vr, + integer *ldvr, integer *mm, integer *m, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, - integer *k, integer *l, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublereal *tola, doublereal *tolb, - doublereal *alpha, doublereal *beta, doublecomplex *u, integer *ldu, - doublecomplex *v, integer *ldv, doublecomplex *q, integer *ldq, +/* Subroutine */ int ztgex2_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *q, integer *ldq, doublecomplex *z__, + integer *ldz, integer *j1, integer *info); + +/* Subroutine */ int ztgexc_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *q, integer *ldq, doublecomplex *z__, + integer *ldz, integer *ifst, integer *ilst, integer *info); + +/* Subroutine */ int ztgsen_(integer *ijob, logical *wantq, logical *wantz, logical *select, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *alpha, + doublecomplex *beta, doublecomplex *q, integer *ldq, doublecomplex *z__, integer *ldz, integer *m, doublereal *pl, doublereal *pr, doublereal *dif, doublecomplex *work, + integer *lwork, integer *iwork, integer *liwork, integer *info); + +/* Subroutine */ int ztgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, integer *n, integer *k, integer *l, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, + doublereal *tola, doublereal *tolb, doublereal *alpha, doublereal *beta, doublecomplex *u, integer *ldu, doublecomplex *v, integer *ldv, doublecomplex *q, integer *ldq, doublecomplex *work, integer *ncycle, integer *info); -/* Subroutine */ int ztgsna_(char *job, char *howmny, logical *select, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, doublereal *s, - doublereal *dif, integer *mm, integer *m, doublecomplex *work, - integer *lwork, integer *iwork, integer *info); +/* Subroutine */ int ztgsna_(char *job, char *howmny, logical *select, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *vl, integer *ldvl, doublecomplex *vr, + integer *ldvr, doublereal *s, doublereal *dif, integer *mm, integer *m, doublecomplex *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int ztgsy2_(char *trans, integer *ijob, integer *m, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, - integer *ldc, doublecomplex *d__, integer *ldd, doublecomplex *e, - integer *lde, doublecomplex *f, integer *ldf, doublereal *scale, - doublereal *rdsum, doublereal *rdscal, integer *info); - -/* Subroutine */ int ztgsyl_(char *trans, integer *ijob, integer *m, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, - integer *ldc, doublecomplex *d__, integer *ldd, doublecomplex *e, - integer *lde, doublecomplex *f, integer *ldf, doublereal *scale, - doublereal *dif, doublecomplex *work, integer *lwork, integer *iwork, - integer *info); +/* Subroutine */ int ztgsy2_(char *trans, integer *ijob, integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, integer *ldc, doublecomplex *d__, + integer *ldd, doublecomplex *e, integer *lde, doublecomplex *f, integer *ldf, doublereal *scale, doublereal *rdsum, doublereal *rdscal, integer *info); -/* Subroutine */ int ztpcon_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *ap, - doublereal *rcond, doublecomplex *work, doublereal *rwork, +/* Subroutine */ int ztgsyl_(char *trans, integer *ijob, integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, integer *ldc, doublecomplex *d__, + integer *ldd, doublecomplex *e, integer *lde, doublecomplex *f, integer *ldf, doublereal *scale, doublereal *dif, doublecomplex *work, integer *lwork, integer *iwork, integer *info); -/* Subroutine */ int ztprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublecomplex *ap, doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int ztpcon_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *ap, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); + +/* Subroutine */ int ztprfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, doublereal *ferr, + doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); /* Subroutine */ int ztptri_(char *uplo, char *diag, integer *n, doublecomplex *ap, integer *info); -/* Subroutine */ int ztptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublecomplex *ap, doublecomplex *b, integer *ldb, integer *info); +/* Subroutine */ int ztptrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublecomplex *ap, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int ztpttf_(char *transr, char *uplo, integer *n, doublecomplex *ap, - doublecomplex *arf, integer *info); +/* Subroutine */ int ztpttf_(char *transr, char *uplo, integer *n, doublecomplex *ap, doublecomplex *arf, integer *info); -/* Subroutine */ int ztpttr_(char *uplo, integer *n, doublecomplex *ap, doublecomplex *a, - integer *lda, integer *info); +/* Subroutine */ int ztpttr_(char *uplo, integer *n, doublecomplex *ap, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int ztrcon_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *a, - integer *lda, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info); +/* Subroutine */ int ztrcon_(char *norm, char *uplo, char *diag, integer *n, doublecomplex *a, integer *lda, doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztrevc_(char *side, char *howmny, logical *select, integer *n, - doublecomplex *t, integer *ldt, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, integer *mm, integer *m, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int ztrevc_(char *side, char *howmny, logical *select, integer *n, doublecomplex *t, integer *ldt, doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *ldvr, integer *mm, + integer *m, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztrexc_(char *compq, integer *n, doublecomplex *t, integer *ldt, - doublecomplex *q, integer *ldq, integer *ifst, integer *ilst, - integer *info); +/* Subroutine */ int ztrexc_(char *compq, integer *n, doublecomplex *t, integer *ldt, doublecomplex *q, integer *ldq, integer *ifst, integer *ilst, integer *info); -/* Subroutine */ int ztrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info); +/* Subroutine */ int ztrrfs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx, + doublereal *ferr, doublereal *berr, doublecomplex *work, doublereal *rwork, integer *info); -/* Subroutine */ int ztrsen_(char *job, char *compq, logical *select, integer *n, doublecomplex *t, - integer *ldt, doublecomplex *q, integer *ldq, doublecomplex *w, - integer *m, doublereal *s, doublereal *sep, doublecomplex *work, - integer *lwork, integer *info); +/* Subroutine */ int ztrsen_(char *job, char *compq, logical *select, integer *n, doublecomplex *t, integer *ldt, doublecomplex *q, integer *ldq, doublecomplex *w, integer *m, doublereal *s, + doublereal *sep, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int ztrsna_(char *job, char *howmny, logical *select, integer *n, doublecomplex *t, - integer *ldt, doublecomplex *vl, integer *ldvl, doublecomplex *vr, - integer *ldvr, doublereal *s, doublereal *sep, integer *mm, integer *m, - doublecomplex *work, integer *ldwork, doublereal *rwork, - integer *info); +/* Subroutine */ int ztrsna_(char *job, char *howmny, logical *select, integer *n, doublecomplex *t, integer *ldt, doublecomplex *vl, integer *ldvl, doublecomplex *vr, integer *ldvr, doublereal *s, + doublereal *sep, integer *mm, integer *m, doublecomplex *work, integer *ldwork, doublereal *rwork, integer *info); -/* Subroutine */ int ztrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *c__, integer *ldc, doublereal *scale, integer *info); +/* Subroutine */ int ztrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, doublecomplex *c__, integer *ldc, + doublereal *scale, integer *info); -/* Subroutine */ int ztrti2_(char *uplo, char *diag, integer *n, doublecomplex *a, integer *lda, - integer *info); +/* Subroutine */ int ztrti2_(char *uplo, char *diag, integer *n, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int ztrtri_(char *uplo, char *diag, integer *n, doublecomplex *a, integer *lda, - integer *info); +/* Subroutine */ int ztrtri_(char *uplo, char *diag, integer *n, doublecomplex *a, integer *lda, integer *info); -/* Subroutine */ int ztrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, - integer *info); +/* Subroutine */ int ztrtrs_(char *uplo, char *trans, char *diag, integer *n, integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, integer *info); -/* Subroutine */ int ztrttf_(char *transr, char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *arf, integer *info); +/* Subroutine */ int ztrttf_(char *transr, char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *arf, integer *info); -/* Subroutine */ int ztrttp_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *ap, integer *info); +/* Subroutine */ int ztrttp_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *ap, integer *info); -/* Subroutine */ int ztzrqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, integer *info); +/* Subroutine */ int ztzrqf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, integer *info); -/* Subroutine */ int ztzrzf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int ztzrzf_(integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zung2l_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zung2l_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zung2r_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zung2r_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zungbr_(char *vect, integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zungbr_(char *vect, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zunghr_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zunghr_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zungl2_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zungl2_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zunglq_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zunglq_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zungql_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zungql_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zungqr_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zungqr_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zungr2_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); +/* Subroutine */ int zungr2_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *info); -/* Subroutine */ int zungrq_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zungrq_(integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zungtr_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, +/* Subroutine */ int zungtr_(char *uplo, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, integer *info); + +/* Subroutine */ int zunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, integer *info); -/* Subroutine */ int zunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info); +/* Subroutine */ int zunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *info); -/* Subroutine */ int zunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info); +/* Subroutine */ int zunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, + doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zunmhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, integer *ihi, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, + doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zunmhr_(char *side, char *trans, integer *m, integer *n, integer *ilo, - integer *ihi, doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, integer *lwork, +/* Subroutine */ int zunml2_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, integer *info); -/* Subroutine */ int zunml2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info); - -/* Subroutine */ int zunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zunmql_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zunmql_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info); +/* Subroutine */ int zunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *info); -/* Subroutine */ int zunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, integer *info); +/* Subroutine */ int zunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, + doublecomplex *work, integer *info); -/* Subroutine */ int zunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, integer *lwork, - integer *info); +/* Subroutine */ int zunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, integer *l, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, + doublecomplex *work, integer *lwork, integer *info); -/* Subroutine */ int zunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *lwork, integer *info); +/* Subroutine */ int zunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, + integer *lwork, integer *info); -/* Subroutine */ int zupgtr_(char *uplo, integer *n, doublecomplex *ap, doublecomplex *tau, - doublecomplex *q, integer *ldq, doublecomplex *work, integer *info); +/* Subroutine */ int zupgtr_(char *uplo, integer *n, doublecomplex *ap, doublecomplex *tau, doublecomplex *q, integer *ldq, doublecomplex *work, integer *info); -/* Subroutine */ int zupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublecomplex *ap, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info); +/* Subroutine */ int zupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, doublecomplex *ap, doublecomplex *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, integer *info); /* Subroutine */ int dlamc1_(integer *beta, integer *t, logical *rnd, logical *ieee1); @@ -6763,32 +4236,27 @@ doublereal slamch_(char *cmach); /* Subroutine */ int slamc1_(integer *beta, integer *t, logical *rnd, logical *ieee1); -/* Subroutine */ int slamc2_(integer *beta, integer *t, logical *rnd, real *eps, integer *emin, - real *rmin, integer *emax, real *rmax); +/* Subroutine */ int slamc2_(integer *beta, integer *t, logical *rnd, real *eps, integer *emin, real *rmin, integer *emax, real *rmax); doublereal slamc3_(real *a, real *b); /* Subroutine */ int slamc4_(integer *emin, real *start, integer *base); -/* Subroutine */ int slamc5_(integer *beta, integer *p, integer *emin, logical *ieee, integer *emax, - real *rmax); +/* Subroutine */ int slamc5_(integer *beta, integer *p, integer *emin, logical *ieee, integer *emax, real *rmax); doublereal dlamch_(char *cmach); /* Subroutine */ int dlamc1_(integer *beta, integer *t, logical *rnd, logical *ieee1); -/* Subroutine */ int dlamc2_(integer *beta, integer *t, logical *rnd, doublereal *eps, - integer *emin, doublereal *rmin, integer *emax, doublereal *rmax); +/* Subroutine */ int dlamc2_(integer *beta, integer *t, logical *rnd, doublereal *eps, integer *emin, doublereal *rmin, integer *emax, doublereal *rmax); doublereal dlamc3_(doublereal *a, doublereal *b); /* Subroutine */ int dlamc4_(integer *emin, doublereal *start, integer *base); -/* Subroutine */ int dlamc5_(integer *beta, integer *p, integer *emin, logical *ieee, integer *emax, - doublereal *rmax); +/* Subroutine */ int dlamc5_(integer *beta, integer *p, integer *emin, logical *ieee, integer *emax, doublereal *rmax); -integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, integer *n2, integer *n3, - integer *n4); +integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, integer *n2, integer *n3, integer *n4); #ifdef __cplusplus } diff --git a/plugin/seq/cmaes.cpp b/plugin/seq/cmaes.cpp index 7b22ee365..2e673061f 100644 --- a/plugin/seq/cmaes.cpp +++ b/plugin/seq/cmaes.cpp @@ -144,8 +144,7 @@ double timings_update(timings_t *timing); void timings_tic(timings_t *timing); double timings_toc(timings_t *timing); -void readpara_init(readpara_t *, int dim, int seed, const double *xstart, const double *sigma, - int lambda, const char *filename); +void readpara_init(readpara_t *, int dim, int seed, const double *xstart, const double *sigma, int lambda, const char *filename); void readpara_exit(readpara_t *); void readpara_ReadFromFile(readpara_t *, const char *szFileName); void readpara_SupplementDefaults(readpara_t *); @@ -204,8 +203,7 @@ char *cmaes_SayHello(cmaes_t *t) { sprintf(t->sOutString, "(%d,%d)-CMA-ES(mu_eff=%.1f), Ver=\"%s\", dimension=%d, diagonalIterations=%ld, " "randomSeed=%d (%s)", - t->sp.mu, t->sp.lambda, t->sp.mueff, t->version, t->sp.N, (long)t->sp.diagonalCov, - t->sp.seed, getTimeStr( )); + t->sp.mu, t->sp.lambda, t->sp.mueff, t->version, t->sp.N, (long)t->sp.diagonalCov, t->sp.seed, getTimeStr( )); return t->sOutString; } @@ -245,8 +243,7 @@ double *cmaes_init(cmaes_t *t, /* "this } } - t->dMaxSignifKond = - dtest / 1000.; /* not sure whether this is really save, 100 does not work well enough */ + t->dMaxSignifKond = dtest / 1000.; /* not sure whether this is really save, 100 does not work well enough */ t->gen = 0; t->countevals = 0; @@ -569,8 +566,7 @@ double const *cmaes_SetMean(cmaes_t *t, const double *xmean) { int i, N = t->sp.N; if (t->state >= 1 && t->state < 3) { - FATAL("cmaes_SetMean: mean cannot be set inbetween the calls of ", - "SamplePopulation and UpdateDistribution", 0, 0); + FATAL("cmaes_SetMean: mean cannot be set inbetween the calls of ", "SamplePopulation and UpdateDistribution", 0, 0); } if (xmean != 0 && xmean != t->rgxmean) { @@ -765,8 +761,7 @@ double *cmaes_UpdateDistribution(cmaes_t *t, const double *rgFunVal) { double psxps; if (t->state == 3) { - FATAL("cmaes_UpdateDistribution(): You need to call \n", - "SamplePopulation() before update can take place.", 0, 0); + FATAL("cmaes_UpdateDistribution(): You need to call \n", "SamplePopulation() before update can take place.", 0, 0); } if (rgFunVal == 0) { @@ -790,13 +785,11 @@ double *cmaes_UpdateDistribution(cmaes_t *t, const double *rgFunVal) { /* Test if function values are identical, escape flat fitness */ if (t->rgFuncValue[t->index[0]] == t->rgFuncValue[t->index[(int)t->sp.lambda / 2]]) { t->sigma *= exp(0.2 + t->sp.cs / t->sp.damps); - ERRORMESSAGE("Warning: sigma increased due to equal function values\n", - " Reconsider the formulation of the objective function", 0, 0); + ERRORMESSAGE("Warning: sigma increased due to equal function values\n", " Reconsider the formulation of the objective function", 0, 0); } /* update function value history */ - for (i = (int)*(t->arFuncValueHist - 1) - 1; i > 0; - --i) { /* for(i = t->arFuncValueHist[-1]-1; i > 0; --i) */ + for (i = (int)*(t->arFuncValueHist - 1) - 1; i > 0; --i) { /* for(i = t->arFuncValueHist[-1]-1; i > 0; --i) */ t->arFuncValueHist[i] = t->arFuncValueHist[i - 1]; } @@ -870,8 +863,7 @@ double *cmaes_UpdateDistribution(cmaes_t *t, const double *rgFunVal) { hsig = sqrt(psxps) / sqrt(1. - pow(1. - t->sp.cs, 2 * t->gen)) / t->chiN < 1.4 + 2. / (N + 1); for (i = 0; i < N; ++i) { - t->rgpc[i] = (1. - t->sp.ccumcov) * t->rgpc[i] + - hsig * sqrt(t->sp.ccumcov * (2. - t->sp.ccumcov)) * t->rgBDz[i]; + t->rgpc[i] = (1. - t->sp.ccumcov) * t->rgpc[i] + hsig * sqrt(t->sp.ccumcov * (2. - t->sp.ccumcov)) * t->rgBDz[i]; } /* stop initial phase */ @@ -947,8 +939,7 @@ static void Adapt_C2(cmaes_t *t, int hsig) { if (t->sp.ccov != 0. && t->flgIniphase == 0) { /* definitions for speeding up inner-most loop */ double ccov1 = douMin(t->sp.ccov * (1. / t->sp.mucov) * (flgdiag ? (N + 1.5) / 3. : 1.), 1.); - double ccovmu = - douMin(t->sp.ccov * (1 - 1. / t->sp.mucov) * (flgdiag ? (N + 1.5) / 3. : 1.), 1. - ccov1); + double ccovmu = douMin(t->sp.ccov * (1 - 1. / t->sp.mucov) * (flgdiag ? (N + 1.5) / 3. : 1.), 1. - ccov1); double sigmasquare = t->sigma * t->sigma; t->flgEigensysIsUptodate = 0; @@ -956,13 +947,10 @@ static void Adapt_C2(cmaes_t *t, int hsig) { /* update covariance matrix */ for (i = 0; i < N; ++i) { for (j = flgdiag ? i : 0; j <= i; ++j) { - t->C[i][j] = (1 - ccov1 - ccovmu) * t->C[i][j] + - ccov1 * (t->rgpc[i] * t->rgpc[j] + - (1 - hsig) * t->sp.ccumcov * (2. - t->sp.ccumcov) * t->C[i][j]); + t->C[i][j] = (1 - ccov1 - ccovmu) * t->C[i][j] + ccov1 * (t->rgpc[i] * t->rgpc[j] + (1 - hsig) * t->sp.ccumcov * (2. - t->sp.ccumcov) * t->C[i][j]); for (k = 0; k < t->sp.mu; ++k) { /* additional rank mu update */ - t->C[i][j] += ccovmu * t->sp.weights[k] * (t->rgrgx[t->index[k]][i] - t->rgxold[i]) * - (t->rgrgx[t->index[k]][j] - t->rgxold[j]) / sigmasquare; + t->C[i][j] += ccovmu * t->sp.weights[k] * (t->rgrgx[t->index[k]][i] - t->rgxold[i]) * (t->rgrgx[t->index[k]][j] - t->rgxold[j]) / sigmasquare; } } } @@ -999,9 +987,7 @@ static void TestMinStdDevs(cmaes_t *t) { /* --------------------------------------------------------- */ /* --------------------------------------------------------- */ -void cmaes_WriteToFile(cmaes_t *t, const char *key, const char *name) { - cmaes_WriteToFileAW(t, key, name, "a"); /* default is append */ -} +void cmaes_WriteToFile(cmaes_t *t, const char *key, const char *name) { cmaes_WriteToFileAW(t, key, name, "a"); /* default is append */ } /* --------------------------------------------------------- */ /* --------------------------------------------------------- */ @@ -1100,7 +1086,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { if (strncmp(key, "B", 1) == 0) { /* int j, index[N]; */ int j, *iindex = (int *)(new_void(N, sizeof(int))); /* MT */ - Sorted_index(t->rgD, iindex, N); /* should not be necessary, see end of QLalgo2 */ + Sorted_index(t->rgD, iindex, N); /* should not be necessary, see end of QLalgo2 */ /* One eigenvector per row, sorted: largest eigenvalue first */ for (i = 0; i < N; ++i) { @@ -1150,8 +1136,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { } /* standard deviations in coordinate directions (sigma*sqrt(C[i,i])) */ - if (strncmp(key, "coorstddev", 10) == 0 || - strncmp(key, "stddev", 6) == 0) { /* std dev in coordinate axes */ + if (strncmp(key, "coorstddev", 10) == 0 || strncmp(key, "stddev", 6) == 0) { /* std dev in coordinate axes */ for (i = 0; i < N; ++i) { fprintf(fp, "%s%g", (i == 0) ? "" : "\t", t->sigma * sqrt(t->C[i][i])); } @@ -1232,8 +1217,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { fprintf(fp, " %4.0f ", t->gen); fprintf(fp, " %5.0f ", t->countevals); fprintf(fp, "%.15e", t->rgFuncValue[t->index[0]]); - fprintf(fp, " %.2e %.2e %.2e", t->sigma, t->sigma * sqrt(t->maxdiagC), - t->sigma * sqrt(t->mindiagC)); + fprintf(fp, " %.2e %.2e %.2e", t->sigma, t->sigma * sqrt(t->maxdiagC), t->sigma * sqrt(t->mindiagC)); fprintf(fp, " %.2e %.2e", sqrt(t->maxEW / t->minEW), sqrt(t->minEW)); while (*key != '+' && *key != '\0' && key < keyend) { @@ -1439,8 +1423,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { fprintf(fp, "minimal standard deviation %g\n", t->sigma * sqrt(t->mindiagC)); fprintf(fp, "sigma %g\n", t->sigma); fprintf(fp, "axisratio %g\n", rgdouMax(t->rgD, N) / rgdouMin(t->rgD, N)); - fprintf(fp, "xbestever found after %.0f evaluations, function value %g\n", - t->rgxbestever[N + 1], t->rgxbestever[N]); + fprintf(fp, "xbestever found after %.0f evaluations, function value %g\n", t->rgxbestever[N + 1], t->rgxbestever[N]); for (i = 0; i < N; ++i) { fprintf(fp, " %12g%c", t->rgxbestever[i], (i % 5 == 4 || i == N - 1) ? '\n' : ' '); @@ -1461,8 +1444,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { fprintf(fp, "Standard deviation of coordinate axes (sigma*sqrt(diag(C)))\n"); for (i = 0; i < N; ++i) { - fprintf(fp, " %12g%c", t->sigma * sqrt(t->C[i][i]), - (i % 5 == 4 || i == N - 1) ? '\n' : ' '); + fprintf(fp, " %12g%c", t->sigma * sqrt(t->C[i][i]), (i % 5 == 4 || i == N - 1) ? '\n' : ' '); } fprintf(fp, "Main axis lengths of mutation ellipsoid (sigma*diag(D))\n"); @@ -1474,8 +1456,7 @@ void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { qsort(t->rgdTmp, (unsigned)N, sizeof(double), &SignOfDiff); for (i = 0; i < N; ++i) { - fprintf(fp, " %12g%c", t->sigma * t->rgdTmp[N - 1 - i], - (i % 5 == 4 || i == N - 1) ? '\n' : ' '); + fprintf(fp, " %12g%c", t->sigma * t->rgdTmp[N - 1 - i], (i % 5 == 4 || i == N - 1) ? '\n' : ' '); } fprintf(fp, "Longest axis (b_i where d_ii=max(diag(D))\n"); @@ -1536,19 +1517,15 @@ double cmaes_Get(cmaes_t *t, char const *s) { return rgdouMax(t->rgD, N) / rgdouMin(t->rgD, N); } else if (strncmp(s, "eval", 4) == 0) { /* number of function evaluations */ return t->countevals; - } else if (strncmp(s, "fctvalue", 6) == 0 || strncmp(s, "funcvalue", 6) == 0 || - strncmp(s, "funvalue", 6) == 0 || - strncmp(s, "fitness", 3) == 0) { /* recent best function value */ + } else if (strncmp(s, "fctvalue", 6) == 0 || strncmp(s, "funcvalue", 6) == 0 || strncmp(s, "funvalue", 6) == 0 || strncmp(s, "fitness", 3) == 0) { /* recent best function value */ return t->rgFuncValue[t->index[0]]; } else if (strncmp(s, "fbestever", 7) == 0) { /* ever best function value */ return t->rgxbestever[N]; } else if (strncmp(s, "generation", 3) == 0 || strncmp(s, "iteration", 4) == 0) { return t->gen; - } else if (strncmp(s, "maxeval", 4) == 0 || strncmp(s, "MaxFunEvals", 8) == 0 || - strncmp(s, "stopMaxFunEvals", 12) == 0) { /* maximal number of function evaluations */ + } else if (strncmp(s, "maxeval", 4) == 0 || strncmp(s, "MaxFunEvals", 8) == 0 || strncmp(s, "stopMaxFunEvals", 12) == 0) { /* maximal number of function evaluations */ return t->sp.stopMaxFunEvals; - } else if (strncmp(s, "maxgen", 4) == 0 || strncmp(s, "MaxIter", 7) == 0 || - strncmp(s, "stopMaxIter", 11) == 0) { /* maximal number of generations */ + } else if (strncmp(s, "maxgen", 4) == 0 || strncmp(s, "MaxIter", 7) == 0 || strncmp(s, "stopMaxIter", 11) == 0) { /* maximal number of generations */ return ceil(t->sp.stopMaxIter); } else if (strncmp(s, "maxaxislength", 5) == 0) { /* sigma * max(diag(D)) */ return t->sigma * sqrt(t->maxEW); @@ -1560,8 +1537,7 @@ double cmaes_Get(cmaes_t *t, char const *s) { return t->sigma * sqrt(t->mindiagC); } else if (strncmp(s, "N", 1) == 0 || strcmp(s, "n") == 0 || strncmp(s, "dimension", 3) == 0) { return N; - } else if (strncmp(s, "lambda", 3) == 0 || strncmp(s, "samplesize", 8) == 0 || - strncmp(s, "popsize", 7) == 0) { /* sample size, offspring population size */ + } else if (strncmp(s, "lambda", 3) == 0 || strncmp(s, "samplesize", 8) == 0 || strncmp(s, "popsize", 7) == 0) { /* sample size, offspring population size */ return t->sp.lambda; } else if (strncmp(s, "sigma", 3) == 0) { return t->sigma; @@ -1646,30 +1622,23 @@ const char *cmaes_TestForTermination(cmaes_t *t) { cp[0] = '\0'; /* function value reached */ - if ((t->gen > 1 || t->state > 1) && t->sp.stStopFitness.flg && - t->rgFuncValue[t->index[0]] <= t->sp.stStopFitness.val) { - cp += sprintf(cp, "Fitness: function value %7.2e <= stopFitness (%7.2e)\n", - t->rgFuncValue[t->index[0]], t->sp.stStopFitness.val); + if ((t->gen > 1 || t->state > 1) && t->sp.stStopFitness.flg && t->rgFuncValue[t->index[0]] <= t->sp.stStopFitness.val) { + cp += sprintf(cp, "Fitness: function value %7.2e <= stopFitness (%7.2e)\n", t->rgFuncValue[t->index[0]], t->sp.stStopFitness.val); } /* TolFun */ - range = douMax(rgdouMax(t->arFuncValueHist, (int)douMin(t->gen, *(t->arFuncValueHist - 1))), - rgdouMax(t->rgFuncValue, t->sp.lambda)) - - douMin(rgdouMin(t->arFuncValueHist, (int)douMin(t->gen, *(t->arFuncValueHist - 1))), - rgdouMin(t->rgFuncValue, t->sp.lambda)); + range = douMax(rgdouMax(t->arFuncValueHist, (int)douMin(t->gen, *(t->arFuncValueHist - 1))), rgdouMax(t->rgFuncValue, t->sp.lambda)) - + douMin(rgdouMin(t->arFuncValueHist, (int)douMin(t->gen, *(t->arFuncValueHist - 1))), rgdouMin(t->rgFuncValue, t->sp.lambda)); if (t->gen > 0 && range <= t->sp.stopTolFun) { - cp += sprintf(cp, "TolFun: function value differences %7.2e < stopTolFun=%7.2e\n", range, - t->sp.stopTolFun); + cp += sprintf(cp, "TolFun: function value differences %7.2e < stopTolFun=%7.2e\n", range, t->sp.stopTolFun); } /* TolFunHist */ if (t->gen > *(t->arFuncValueHist - 1)) { - range = rgdouMax(t->arFuncValueHist, (int)*(t->arFuncValueHist - 1)) - - rgdouMin(t->arFuncValueHist, (int)*(t->arFuncValueHist - 1)); + range = rgdouMax(t->arFuncValueHist, (int)*(t->arFuncValueHist - 1)) - rgdouMin(t->arFuncValueHist, (int)*(t->arFuncValueHist - 1)); if (range <= t->sp.stopTolFunHist) { - cp += sprintf(cp, "TolFunHist: history of function value changes %7.2e stopTolFunHist=%7.2e", - range, t->sp.stopTolFunHist); + cp += sprintf(cp, "TolFunHist: history of function value changes %7.2e stopTolFunHist=%7.2e", range, t->sp.stopTolFunHist); } } @@ -1718,20 +1687,16 @@ const char *cmaes_TestForTermination(cmaes_t *t) { } if (iKoo == N) { - cp += sprintf( - cp, "NoEffectAxis: standard deviation 0.1*%7.2e in principal axis %d without effect\n", - fac / 0.1, iAchse); + cp += sprintf(cp, "NoEffectAxis: standard deviation 0.1*%7.2e in principal axis %d without effect\n", fac / 0.1, iAchse); break; } /* if (iKoo == N) */ - } /* for iAchse */ - } /* if flgdiag */ + } /* for iAchse */ + } /* if flgdiag */ /* Component of xmean is not changed anymore */ for (iKoo = 0; iKoo < N; ++iKoo) { if (t->rgxmean[iKoo] == t->rgxmean[iKoo] + 0.2 * t->sigma * sqrt(t->C[iKoo][iKoo])) { - cp += sprintf( - cp, "NoEffectCoordinate: standard deviation 0.2*%7.2e in coordinate %d without effect\n", - t->sigma * sqrt(t->C[iKoo][iKoo]), iKoo); + cp += sprintf(cp, "NoEffectCoordinate: standard deviation 0.2*%7.2e in coordinate %d without effect\n", t->sigma * sqrt(t->C[iKoo][iKoo]), iKoo); break; } } /* for iKoo */ @@ -1739,8 +1704,7 @@ const char *cmaes_TestForTermination(cmaes_t *t) { /* if (flg) t->sigma *= exp(0.05+t->sp.cs/t->sp.damps); */ if (t->countevals >= t->sp.stopMaxFunEvals) { - cp += sprintf(cp, "MaxFunEvals: conducted function evaluations %.0f >= %g\n", t->countevals, - t->sp.stopMaxFunEvals); + cp += sprintf(cp, "MaxFunEvals: conducted function evaluations %.0f >= %g\n", t->countevals, t->sp.stopMaxFunEvals); } if (t->gen >= t->sp.stopMaxIter) { @@ -1751,7 +1715,6 @@ const char *cmaes_TestForTermination(cmaes_t *t) { cp += sprintf(cp, "Manual: stop signal read\n"); } - if (cp - sTestOutString > 320) { ERRORMESSAGE("Bug in cmaes_t:Test(): sTestOutString too short", 0, 0, 0); } @@ -1795,10 +1758,9 @@ void cmaes_ReadFromFilePtr(cmaes_t *t, FILE *fp) { static long maxdiffitertowrite; /* to prevent long gaps at the beginning */ int flgprinted = 0; int flgwritten = 0; - double deltaprinttime = time(0) - t->printtime; /* using clock instead might not be a good */ - double deltawritetime = time(0) - t->writetime; /* idea as disc time is not CPU time? */ - double deltaprinttimefirst = - t->firstprinttime ? time(0) - t->firstprinttime : 0; /* time is in seconds!? */ + double deltaprinttime = time(0) - t->printtime; /* using clock instead might not be a good */ + double deltawritetime = time(0) - t->writetime; /* idea as disc time is not CPU time? */ + double deltaprinttimefirst = t->firstprinttime ? time(0) - t->firstprinttime : 0; /* time is in seconds!? */ double deltawritetimefirst = t->firstwritetime ? time(0) - t->firstwritetime : 0; if (countiterlastwritten > t->gen) { /* probably restarted */ @@ -1932,9 +1894,9 @@ void cmaes_ReadFromFilePtr(cmaes_t *t, FILE *fp) { } break; /* for ikey */ - } /* if line contains keyword */ - } /* for each keyword */ - } /* while not EOF of signals.par */ + } /* if line contains keyword */ + } /* for each keyword */ + } /* while not EOF of signals.par */ if (t->writetime == 0) { t->firstwritetime = time(0); @@ -1985,10 +1947,8 @@ static int Check_Eigen(int N, double **C, double *diag, double **Q) { } /* check here, is the normalization the right one? */ - if (fabs(cc - C[i > j ? i : j][i > j ? j : i]) / sqrt(C[i][i] * C[j][j]) > 1e-10 && - fabs(cc - C[i > j ? i : j][i > j ? j : i]) > 3e-14) { - sprintf(s, "%d %d: %.17e %.17e, %e", i, j, cc, C[i > j ? i : j][i > j ? j : i], - cc - C[i > j ? i : j][i > j ? j : i]); + if (fabs(cc - C[i > j ? i : j][i > j ? j : i]) / sqrt(C[i][i] * C[j][j]) > 1e-10 && fabs(cc - C[i > j ? i : j][i > j ? j : i]) > 3e-14) { + sprintf(s, "%d %d: %.17e %.17e, %e", i, j, cc, C[i > j ? i : j][i > j ? j : i], cc - C[i > j ? i : j][i > j ? j : i]); ERRORMESSAGE("cmaes_t:Eigen(): imprecise result detected ", s, 0, 0); ++res; } @@ -2023,9 +1983,7 @@ void cmaes_UpdateEigensystem(cmaes_t *t, int flgforce) { } /* return on time percentage */ - if (t->sp.updateCmode.maxtime < 1.00 && - t->eigenTimings.tictoctime > t->sp.updateCmode.maxtime * t->eigenTimings.totaltime && - t->eigenTimings.tictoctime > 0.0002) { + if (t->sp.updateCmode.maxtime < 1.00 && t->eigenTimings.tictoctime > t->sp.updateCmode.maxtime * t->eigenTimings.totaltime && t->eigenTimings.tictoctime > 0.0002) { return; } } @@ -2648,8 +2606,7 @@ static char *szCat(const char *sz1, const char *sz2, const char *sz3, const char /* --------------------------------------------------------- */ /* -------------- Functions: readpara_t -------------------- */ /* --------------------------------------------------------- */ -void readpara_init(readpara_t *t, int dim, int inseed, const double *inxstart, - const double *inrgsigma, int lambda, const char *filename) { +void readpara_init(readpara_t *t, int dim, int inseed, const double *inxstart, const double *inrgsigma, int lambda, const char *filename) { int i, N; t->rgsformat = static_cast< const char ** >(new_void(55, sizeof(char *))); @@ -2766,8 +2723,7 @@ void readpara_init(readpara_t *t, int dim, int inseed, const double *inxstart, N = t->N; if (N == 0) { - FATAL("readpara_readpara_t(): problem dimension N undefined.\n", - " (no default value available).", 0, 0); + FATAL("readpara_readpara_t(): problem dimension N undefined.\n", " (no default value available).", 0, 0); } if (t->xstart == 0 && inxstart == 0 && t->typicalX == 0) { @@ -2906,8 +2862,7 @@ void readpara_ReadFromFile(readpara_t *t, const char *filename) { if (i < size && i < t->N) { ERRORMESSAGE("readpara_ReadFromFile ", filename, ": ", 0); - FATAL("'", t->rgskeyar[ipara], "' not enough values found.\n", - " Remove all comments between numbers."); + FATAL("'", t->rgskeyar[ipara], "' not enough values found.\n", " Remove all comments between numbers."); } for (; i < t->N; ++i) { /* recycle */ @@ -3064,11 +3019,10 @@ void readpara_SupplementDefaults(readpara_t *t) { t->damps = 1; /* otherwise a factor was read */ } - t->damps = - t->damps * (1 + 2 * douMax(0., sqrt((t->mueff - 1.) / (N + 1.)) - 1)) /* basic factor */ - * douMax(0.3, 1. - /* modify for short runs */ - (double)N / (1e-6 + douMin(t->stopMaxIter, t->stopMaxFunEvals / t->lambda))) + - t->cs; /* minor increment */ + t->damps = t->damps * (1 + 2 * douMax(0., sqrt((t->mueff - 1.) / (N + 1.)) - 1)) /* basic factor */ + * douMax(0.3, 1. - /* modify for short runs */ + (double)N / (1e-6 + douMin(t->stopMaxIter, t->stopMaxFunEvals / t->lambda))) + + t->cs; /* minor increment */ if (t->updateCmode.modulo < 0) { t->updateCmode.modulo = 1. / t->ccov / (double)(N) / 10.; @@ -3121,8 +3075,7 @@ void readpara_SetWeights(readpara_t *t, const char *mode) { t->weights[i] /= s1; } - if (t->mu < 1 || t->mu > t->lambda || - (t->mu == t->lambda && t->weights[0] == t->weights[t->mu - 1])) { + if (t->mu < 1 || t->mu > t->lambda || (t->mu == t->lambda && t->weights[0] == t->weights[t->mu - 1])) { FATAL("readpara_SetWeights(): invalid setting of mu or lambda", 0, 0, 0); } } /* readpara_SetWeights() */ @@ -3197,9 +3150,7 @@ static double myhypot(double a, double b) { return r; } -static int SignOfDiff(const void *d1, const void *d2) { - return *((double *)d1) > *((double *)d2) ? 1 : -1; -} +static int SignOfDiff(const void *d1, const void *d2) { return *((double *)d1) > *((double *)d2) ? 1 : -1; } #if 1 /* dirty index sort */ @@ -3263,9 +3214,7 @@ void cmaes_FATAL(char const *s1, char const *s2, char const *s3, char const *s4) } /* ========================================================= */ -static void FATAL(char const *s1, char const *s2, char const *s3, char const *s4) { - cmaes_FATAL(s1, s2, s3, s4); -} +static void FATAL(char const *s1, char const *s2, char const *s3, char const *s4) { cmaes_FATAL(s1, s2, s3, s4); } /* ========================================================= */ void ERRORMESSAGE(char const *s1, char const *s2, char const *s3, char const *s4) { @@ -3299,18 +3248,15 @@ char *szCat(const char *sz1, const char *sz2, const char *sz3, const char *sz4) strncpy((char *)szBuf, sz1, (unsigned)intMin((int)strlen(sz1), 698)); szBuf[intMin((int)strlen(sz1), 698)] = '\0'; if (sz2) { - strncat((char *)szBuf, sz2, - (unsigned)intMin((int)strlen(sz2) + 1, 698 - (int)strlen((char const *)szBuf))); + strncat((char *)szBuf, sz2, (unsigned)intMin((int)strlen(sz2) + 1, 698 - (int)strlen((char const *)szBuf))); } if (sz3) { - strncat((char *)szBuf, sz3, - (unsigned)intMin((int)strlen(sz3) + 1, 698 - (int)strlen((char const *)szBuf))); + strncat((char *)szBuf, sz3, (unsigned)intMin((int)strlen(sz3) + 1, 698 - (int)strlen((char const *)szBuf))); } if (sz4) { - strncat((char *)szBuf, sz4, - (unsigned)intMin((int)strlen(sz4) + 1, 698 - (int)strlen((char const *)szBuf))); + strncat((char *)szBuf, sz4, (unsigned)intMin((int)strlen(sz4) + 1, 698 - (int)strlen((char const *)szBuf))); } return (char *)szBuf; diff --git a/plugin/seq/cmaes_interface.h b/plugin/seq/cmaes_interface.h index 48d5fcebb..c6b61bb2a 100644 --- a/plugin/seq/cmaes_interface.h +++ b/plugin/seq/cmaes_interface.h @@ -30,8 +30,7 @@ /* --------------------------------------------------------- */ /* --- initialization, constructors, destructors --- */ -double *cmaes_init(cmaes_t *, int dimension, double *xstart, double *stddev, long seed, int lambda, - const char *input_parameter_filename); +double *cmaes_init(cmaes_t *, int dimension, double *xstart, double *stddev, long seed, int lambda, const char *input_parameter_filename); void cmaes_resume_distribution(cmaes_t *evo_ptr, char *filename); void cmaes_exit(cmaes_t *); diff --git a/plugin/seq/dfft.cpp b/plugin/seq/dfft.cpp index 63ccda6fb..9fdc6e4ab 100644 --- a/plugin/seq/dfft.cpp +++ b/plugin/seq/dfft.cpp @@ -33,84 +33,69 @@ template< class Complex > class DFFT_1d2dor3d { -public: - Complex *x; - int n, m, k; - int sign; - DFFT_1d2dor3d(KN< Complex > *xx, long signn, long nn = 1, long kk = 1) - : x(*xx), n(nn), m(xx->N( ) / (nn * kk)), k(kk), sign(signn) { - cout << xx << " " << signn << " " << nn << " " << xx->N( ) << " n: " << n << " m:" << m - << " k: " << k << endl; - ffassert(n > 0 && (n * m * k == xx->N( ))); - } - - DFFT_1d2dor3d(KNM< Complex > *xx, long signn) : x(*xx), n(xx->M( )), m(xx->N( )), sign(signn) {} + public: + Complex *x; + int n, m, k; + int sign; + DFFT_1d2dor3d(KN< Complex > *xx, long signn, long nn = 1, long kk = 1) : x(*xx), n(nn), m(xx->N( ) / (nn * kk)), k(kk), sign(signn) { + cout << xx << " " << signn << " " << nn << " " << xx->N( ) << " n: " << n << " m:" << m << " k: " << k << endl; + ffassert(n > 0 && (n * m * k == xx->N( ))); + } + + DFFT_1d2dor3d(KNM< Complex > *xx, long signn) : x(*xx), n(xx->M( )), m(xx->N( )), sign(signn) {} }; -DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &sign) { - return DFFT_1d2dor3d< Complex >(x, sign); -} +DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &sign) { return DFFT_1d2dor3d< Complex >(x, sign); } -DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &nn, const long &sign) { - return DFFT_1d2dor3d< Complex >(x, sign, nn); -} +DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &nn, const long &sign) { return DFFT_1d2dor3d< Complex >(x, sign, nn); } -DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &nn, const long &kk, - const long &sign) { - return DFFT_1d2dor3d< Complex >(x, sign, nn, kk); -} +DFFT_1d2dor3d< Complex > dfft(KN< Complex > *const &x, const long &nn, const long &kk, const long &sign) { return DFFT_1d2dor3d< Complex >(x, sign, nn, kk); } -DFFT_1d2dor3d< Complex > dfft(KNM< Complex > *const &x, const long &sign) { - return DFFT_1d2dor3d< Complex >(x, sign); -} +DFFT_1d2dor3d< Complex > dfft(KNM< Complex > *const &x, const long &sign) { return DFFT_1d2dor3d< Complex >(x, sign); } bool ff_execute(fftw_plan *p) { - if (*p) { - fftw_execute(*p); - } - - return 0; + if (*p) { + fftw_execute(*p); + } + + return 0; } bool ff_delete(fftw_plan *p) { - if (*p) { - fftw_destroy_plan(*p); - } - - *p = 0; - return 0; + if (*p) { + fftw_destroy_plan(*p); + } + + *p = 0; + return 0; } KN< Complex > *dfft_eq(KN< Complex > *const &x, const DFFT_1d2dor3d< Complex > &d) { - ffassert(x->N( ) == d.n * d.m * d.k); - Complex *px = *x; - fftw_plan p; - if (d.k == 1) { - if (d.n > 1) { - p = fftw_plan_dft_2d(d.n, d.m, reinterpret_cast< fftw_complex * >(d.x), - reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); - } else { - p = fftw_plan_dft_1d(d.m, reinterpret_cast< fftw_complex * >(d.x), - reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); - } + ffassert(x->N( ) == d.n * d.m * d.k); + Complex *px = *x; + fftw_plan p; + if (d.k == 1) { + if (d.n > 1) { + p = fftw_plan_dft_2d(d.n, d.m, reinterpret_cast< fftw_complex * >(d.x), reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); + } else { + p = fftw_plan_dft_1d(d.m, reinterpret_cast< fftw_complex * >(d.x), reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); + } + } else { + if (d.n > 1) { + p = fftw_plan_dft_3d(d.n, d.m, d.k, reinterpret_cast< fftw_complex * >(d.x), reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); } else { - if (d.n > 1) { - p = fftw_plan_dft_3d(d.n, d.m, d.k, reinterpret_cast< fftw_complex * >(d.x), - reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); - } else { - p = fftw_plan_dft_2d(d.m, d.k, reinterpret_cast< fftw_complex * >(d.x), - reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); - } + p = fftw_plan_dft_2d(d.m, d.k, reinterpret_cast< fftw_complex * >(d.x), reinterpret_cast< fftw_complex * >(px), d.sign, FFTW_ESTIMATE); } - - fftw_execute(p); - fftw_destroy_plan(p); - return x; + } + + fftw_execute(p); + fftw_destroy_plan(p); + return x; } KN< double > *dfft_eq(KN< double > *const &x, const DFFT_1d2dor3d< double > &d) { - ffassert(0); - return x; + ffassert(0); + return x; } /* class Init { public: @@ -123,188 +108,174 @@ struct fftw_plan_s {}; template<> inline AnyType DeletePtr< fftw_plan * >(Stack, const AnyType &x) { - fftw_plan *a = PGetAny< fftw_plan >(x); - - if (*a) { - fftw_destroy_plan(*a); - } - - *a = 0; - return Nothing; + fftw_plan *a = PGetAny< fftw_plan >(x); + + if (*a) { + fftw_destroy_plan(*a); + } + + *a = 0; + return Nothing; }; fftw_plan *plan__eq(fftw_plan *a, fftw_plan b) { - if (*a) { - fftw_destroy_plan(*a); - } - - *a = b; - return a; + if (*a) { + fftw_destroy_plan(*a); + } + + *a = b; + return a; } fftw_plan *plan_set(fftw_plan *a, fftw_plan b) { - *a = b; - return a; + *a = b; + return a; } fftw_plan plan_dfft(KN< Complex > *const &x, KN< Complex > *const &y, const long &sign) { - return fftw_plan_dft_1d(x->N( ), reinterpret_cast< fftw_complex * >(&x[0]), - reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); + return fftw_plan_dft_1d(x->N( ), reinterpret_cast< fftw_complex * >(&x[0]), reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); } fftw_plan plan_dfft(KNM< Complex > *const &x, KNM< Complex > *const &y, const long &sign) { - long m = x->N( ), n = x->M( ); - - fftw_plan_dft_2d(n, m, reinterpret_cast< fftw_complex * >(&x[0]), - reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); - return 0; + long m = x->N( ), n = x->M( ); + + fftw_plan_dft_2d(n, m, reinterpret_cast< fftw_complex * >(&x[0]), reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); + return 0; } -fftw_plan plan_dfft(KN< Complex > *const &x, KN< Complex > *const &y, const long &n, - const long &sign) { - long nn = n, mm = y->N( ) / nn; - - ffassert(mm * nn == y->N( ) && x->N( ) == y->N( )); - - return fftw_plan_dft_2d(nn, mm, reinterpret_cast< fftw_complex * >(&x[0]), - reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); +fftw_plan plan_dfft(KN< Complex > *const &x, KN< Complex > *const &y, const long &n, const long &sign) { + long nn = n, mm = y->N( ) / nn; + + ffassert(mm * nn == y->N( ) && x->N( ) == y->N( )); + + return fftw_plan_dft_2d(nn, mm, reinterpret_cast< fftw_complex * >(&x[0]), reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); } -fftw_plan plan_dfft(KN< Complex > *const &x, KN< Complex > *const &y, const long &n, const long &k, - const long &sign) { - int nn = n, mm = y->N( ) / (k * n), kk = k; - - ffassert(y->N( ) == nn * mm * kk); - if (nn > 1) { - return fftw_plan_dft_3d(nn, mm, kk, reinterpret_cast< fftw_complex * >(&x[0]), - reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); - } else { - return fftw_plan_dft_2d(nn, mm, reinterpret_cast< fftw_complex * >(&x[0]), - reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); - } +fftw_plan plan_dfft(KN< Complex > *const &x, KN< Complex > *const &y, const long &n, const long &k, const long &sign) { + int nn = n, mm = y->N( ) / (k * n), kk = k; + + ffassert(y->N( ) == nn * mm * kk); + if (nn > 1) { + return fftw_plan_dft_3d(nn, mm, kk, reinterpret_cast< fftw_complex * >(&x[0]), reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); + } else { + return fftw_plan_dft_2d(nn, mm, reinterpret_cast< fftw_complex * >(&x[0]), reinterpret_cast< fftw_complex * >(&y[0]), sign, FFTW_ESTIMATE); + } } -template +template< int NP > class Mapkk : public E_F0mps { -public: - typedef Complex R; - typedef KN_< R > Result; - ; - static basicAC_F0::name_and_type *name_param; - static const int n_name_param = 0; - Expression expv, expK, expm, expk, exp; - Expression nargs[n_name_param]; - - Mapkk(const basicAC_F0 &args) : expv(0),expK(0), expm(0), expk(0), exp(0) { - args.SetNameParam(n_name_param, name_param, nargs); - expv = to< KN< R > * >(args[0]); // a the expression to get the mesh - expK = to< R3 * >(args[1]); // a the expression to get the K fourier variable - if(NP>2)expm = to< long >(args[2]);// 2d ... - if(NP==4) - expk = to< long >(args[3]); - exp = to< R >(args[NP]); // a the expression to get the mesh - } - - ~Mapkk( ) {} - - static ArrayOfaType typeargs( ) { - if(NP==2) - return ArrayOfaType(atype< KN< R > * >( ), atype< R3* >( ), atype< R >( )); - else if(NP==3) - return ArrayOfaType(atype< KN< R > * >( ), atype< R3* >( ), atype< long >( ), atype< R >( )); - else if(NP==4) - return ArrayOfaType(atype< KN< R > * >( ), atype< R3* >( ), atype< long >( ),atype< long >( ), atype< R >( )); - else ffassert(0); // - } - - static E_F0 *f(const basicAC_F0 &args) { return new Mapkk(args); } - - AnyType operator( )(Stack s) const; + public: + typedef Complex R; + typedef KN_< R > Result; + ; + static basicAC_F0::name_and_type *name_param; + static const int n_name_param = 0; + Expression expv, expK, expm, expk, exp; + Expression nargs[n_name_param]; + + Mapkk(const basicAC_F0 &args) : expv(0), expK(0), expm(0), expk(0), exp(0) { + args.SetNameParam(n_name_param, name_param, nargs); + expv = to< KN< R > * >(args[0]); // a the expression to get the mesh + expK = to< R3 * >(args[1]); // a the expression to get the K fourier variable + if (NP > 2) expm = to< long >(args[2]); // 2d ... + if (NP == 4) expk = to< long >(args[3]); + exp = to< R >(args[NP]); // a the expression to get the mesh + } + + ~Mapkk( ) {} + + static ArrayOfaType typeargs( ) { + if (NP == 2) + return ArrayOfaType(atype< KN< R > * >( ), atype< R3 * >( ), atype< R >( )); + else if (NP == 3) + return ArrayOfaType(atype< KN< R > * >( ), atype< R3 * >( ), atype< long >( ), atype< R >( )); + else if (NP == 4) + return ArrayOfaType(atype< KN< R > * >( ), atype< R3 * >( ), atype< long >( ), atype< long >( ), atype< R >( )); + else + ffassert(0); // + } + + static E_F0 *f(const basicAC_F0 &args) { return new Mapkk< NP >(args); } + + AnyType operator( )(Stack s) const; }; -template -basicAC_F0::name_and_type *Mapkk::name_param = 0; -template -AnyType Mapkk::operator( )(Stack s) const { - // correct July 2015 ... not tested before.. - MeshPoint *mp(MeshPointStack(s)), mps = *mp; - - KN< R > *pv = GetAny< KN< R > * >((*expv)(s)); - KN< R > & v(*pv); - R3 * pK = GetAny< R3 * >((*expK)(s)); - long nn = v.N( ); - long n2 = expm ?GetAny< long >((*expm)(s)):1; - long n3 = expk ? GetAny< long >((*expk)(s)): 1; - if (verbosity > 9) { - cout << " map: expm " << expm << " n2 = " << n2 << " n3 =" << n3 << " size array:" << nn << endl; - } - long n23 =n2*n3; - long n1 = nn / n23; - double k1 = 1. / n1; - double k2 = 1. / n2; - double k3 = 1. / n3; - - double k10 = 0., k20 = 0, k30 = 0;; - if (verbosity > 9) { - cout << " map: " << n1 << " " << n2 << " " << n3 << " " << nn << " == " << n1 * n2 * n3 << endl; - } - - ffassert(n1 * n2 * n3 == nn); - long n12 = (n1 + 1) / 2, n22 = (n2 + 1) / 2, n32 = (n3 + 1) / 2; - int kkk =0; - for (long i3 = 0; i3 < n3; ++i3) - for (long i2 = 0 ; i2 < n2; ++i2) - for (long i1 = 0; i1 < n1; ++i1,++kkk) - { - int ii1 = i1%n12 - (i1/n12)*n12; - int ii2 = i2%n22 - (i2/n22)*n22; - int ii3 = i3%n32 - (i3/n32)*n32; - R3 P(ii1,ii2, ii3); - *pK = P; // set value of K to P. +template< int NP > +basicAC_F0::name_and_type *Mapkk< NP >::name_param = 0; +template< int NP > +AnyType Mapkk< NP >::operator( )(Stack s) const { + // correct July 2015 ... not tested before.. + MeshPoint *mp(MeshPointStack(s)), mps = *mp; + + KN< R > *pv = GetAny< KN< R > * >((*expv)(s)); + KN< R > &v(*pv); + R3 *pK = GetAny< R3 * >((*expK)(s)); + long nn = v.N( ); + long n2 = expm ? GetAny< long >((*expm)(s)) : 1; + long n3 = expk ? GetAny< long >((*expk)(s)) : 1; + if (verbosity > 9) { + cout << " map: expm " << expm << " n2 = " << n2 << " n3 =" << n3 << " size array:" << nn << endl; + } + long n23 = n2 * n3; + long n1 = nn / n23; + double k1 = 1. / n1; + double k2 = 1. / n2; + double k3 = 1. / n3; + + double k10 = 0., k20 = 0, k30 = 0; + ; + if (verbosity > 9) { + cout << " map: " << n1 << " " << n2 << " " << n3 << " " << nn << " == " << n1 * n2 * n3 << endl; + } + + ffassert(n1 * n2 * n3 == nn); + long n12 = (n1 + 1) / 2, n22 = (n2 + 1) / 2, n32 = (n3 + 1) / 2; + int kkk = 0; + for (long i3 = 0; i3 < n3; ++i3) + for (long i2 = 0; i2 < n2; ++i2) + for (long i1 = 0; i1 < n1; ++i1, ++kkk) { + int ii1 = i1 % n12 - (i1 / n12) * n12; + int ii2 = i2 % n22 - (i2 / n22) * n22; + int ii3 = i3 % n32 - (i3 / n32) * n32; + R3 P(ii1, ii2, ii3); + *pK = P; // set value of K to P. v[kkk] = GetAny< R >((*exp)(s)); - if(verbosity>19) cout << "map" << kkk << " " <( ); - Dcl_Type< DFFT_R >( ); - - Dcl_Type< fftw_plan * >(::InitializePtr< fftw_plan * >, ::DeletePtr< fftw_plan * >); - Dcl_Type< fftw_plan >( ); - zzzfff->Add("fftwplan", atype< fftw_plan * >( )); - - TheOperators->Add("=", new OneOperator2< fftw_plan *, fftw_plan *, fftw_plan >(plan__eq)); - TheOperators->Add("<-", new OneOperator2< fftw_plan *, fftw_plan *, fftw_plan >(plan_set)); - - Global.Add("plandfft", "(", - new OneOperator3_< fftw_plan, KN< Complex > *, KN< Complex > *, long >(plan_dfft)); - Global.Add( - "plandfft", "(", - new OneOperator4_< fftw_plan, KN< Complex > *, KN< Complex > *, long, long >(plan_dfft)); - Global.Add( - "plandfft", "(", - new OneOperator5_< fftw_plan, KN< Complex > *, KN< Complex > *, long, long, long >(plan_dfft)); - Global.Add("plandfft", "(", - new OneOperator3_< fftw_plan, KNM< Complex > *, KNM< Complex > *, long >(plan_dfft)); - - Global.Add("execute", "(", new OneOperator1< bool, fftw_plan * >(ff_execute)); - Global.Add("delete", "(", new OneOperator1< bool, fftw_plan * >(ff_delete)); - - Global.Add("dfft", "(", new OneOperator2_< DFFT_C, KN< Complex > *, long >(dfft)); - Global.Add("dfft", "(", new OneOperator3_< DFFT_C, KN< Complex > *, long, long >(dfft)); - Global.Add("dfft", "(", new OneOperator4_< DFFT_C, KN< Complex > *, long, long, long >(dfft)); - Global.Add("dfft", "(", new OneOperator2_< DFFT_C, KNM< Complex > *, long >(dfft)); - Global.Add("mapk", "(", new OneOperatorCode< Mapkk<2> >( )); - Global.Add("mapkk", "(", new OneOperatorCode< Mapkk<3> >( )); - Global.Add("mapkkk", "(", new OneOperatorCode< Mapkk<4> >( )); - TheOperators->Add("=", new OneOperator2_< KN< Complex > *, KN< Complex > *, DFFT_C >(dfft_eq)); + typedef DFFT_1d2dor3d< Complex > DFFT_C; + typedef DFFT_1d2dor3d< double > DFFT_R; + if (mpirank == 0) cout << " load: init dfft " << endl; + Dcl_Type< DFFT_C >( ); + Dcl_Type< DFFT_R >( ); + + Dcl_Type< fftw_plan * >(::InitializePtr< fftw_plan * >, ::DeletePtr< fftw_plan * >); + Dcl_Type< fftw_plan >( ); + zzzfff->Add("fftwplan", atype< fftw_plan * >( )); + + TheOperators->Add("=", new OneOperator2< fftw_plan *, fftw_plan *, fftw_plan >(plan__eq)); + TheOperators->Add("<-", new OneOperator2< fftw_plan *, fftw_plan *, fftw_plan >(plan_set)); + + Global.Add("plandfft", "(", new OneOperator3_< fftw_plan, KN< Complex > *, KN< Complex > *, long >(plan_dfft)); + Global.Add("plandfft", "(", new OneOperator4_< fftw_plan, KN< Complex > *, KN< Complex > *, long, long >(plan_dfft)); + Global.Add("plandfft", "(", new OneOperator5_< fftw_plan, KN< Complex > *, KN< Complex > *, long, long, long >(plan_dfft)); + Global.Add("plandfft", "(", new OneOperator3_< fftw_plan, KNM< Complex > *, KNM< Complex > *, long >(plan_dfft)); + + Global.Add("execute", "(", new OneOperator1< bool, fftw_plan * >(ff_execute)); + Global.Add("delete", "(", new OneOperator1< bool, fftw_plan * >(ff_delete)); + + Global.Add("dfft", "(", new OneOperator2_< DFFT_C, KN< Complex > *, long >(dfft)); + Global.Add("dfft", "(", new OneOperator3_< DFFT_C, KN< Complex > *, long, long >(dfft)); + Global.Add("dfft", "(", new OneOperator4_< DFFT_C, KN< Complex > *, long, long, long >(dfft)); + Global.Add("dfft", "(", new OneOperator2_< DFFT_C, KNM< Complex > *, long >(dfft)); + Global.Add("mapk", "(", new OneOperatorCode< Mapkk< 2 > >( )); + Global.Add("mapkk", "(", new OneOperatorCode< Mapkk< 3 > >( )); + Global.Add("mapkkk", "(", new OneOperatorCode< Mapkk< 4 > >( )); + TheOperators->Add("=", new OneOperator2_< KN< Complex > *, KN< Complex > *, DFFT_C >(dfft_eq)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/distance.cpp b/plugin/seq/distance.cpp index bf3595b68..28fb83593 100644 --- a/plugin/seq/distance.cpp +++ b/plugin/seq/distance.cpp @@ -66,8 +66,7 @@ double distmin(const Rd &A, const Rd &B, const Rd &Q) { } if (verbosity > 9999) { - cout << " distmin: d =" << d << " /" << lc << " :: " << A << " " << B << " " << Q << " C" << C - << endl; + cout << " distmin: d =" << d << " /" << lc << " :: " << A << " " << B << " " << Q << " C" << C << endl; } return d; @@ -90,8 +89,7 @@ double distmin(const Rd &A, const Rd &B, const Rd &Q, double aq, double bq) { } if (verbosity > 9999) { - cout << " distmin:AB/Q: d =" << d << " /" << lp << " :: A " << A << " B " << B << " Q " << Q - << " P " << (A + lp * AB) << endl; + cout << " distmin:AB/Q: d =" << d << " /" << lp << " :: A " << A << " B " << B << " Q " << Q << " P " << (A + lp * AB) << endl; } return d; @@ -121,8 +119,7 @@ double distmin(const Rd &A, double a, const Rd &B, double b, const Rd &Q, double // lpm in [0,1] if (verbosity > 999) { Rd M = A + lpm * AB; - cout << " lgm " << lpm << " r= " << sqrt(r2) << " M= " << M << " Q =" << Q - << " ::" << a + lpm * ab << " " << ab << endl; + cout << " lgm " << lpm << " r= " << sqrt(r2) << " M= " << M << " Q =" << Q << " ::" << a + lpm * ab << " " << ab << endl; } lpm = max(0., min(1., lpm)); @@ -145,15 +142,13 @@ double distmin(const Rd &A, double a, const Rd &B, double b, const Rd &Q, double } if (verbosity > 99) { - cout << " distmin/ AaBaQ " << A << " " << a << " / " << B << " " << b << " / " << Q - << " / dmin= " << dmin << " cas =" << cas << endl; + cout << " distmin/ AaBaQ " << A << " " << a << " / " << B << " " << b << " / " << Q << " / dmin= " << dmin << " cas =" << cas << endl; } return dmin; } -double distmin(const R3 &A, double a, const R3 &B, double b, const R3 &C, double c, const R3 &Q, - double aq, double bq, double cq) { +double distmin(const R3 &A, double a, const R3 &B, double b, const R3 &C, double c, const R3 &Q, double aq, double bq, double cq) { // let fA the affine function on ABC const int in = 1; int cas = 0, flat = 0; @@ -333,8 +328,7 @@ int DistanceIso0(const Tet &K, double *f, double *fK) { } if (np && debug) { - cout << " np " << np << " " << P[0] << " " << P[1] << " :: " << f[0] << " " << f[1] << " " - << f[2] << " " << f[3] << endl; + cout << " np " << np << " " << P[0] << " " << P[1] << " :: " << f[0] << " " << f[1] << " " << f[2] << " " << f[3] << endl; } if (np == 0) { @@ -356,8 +350,7 @@ int DistanceIso0(const Tet &K, double *f, double *fK) { } if (debug) { - cout << ret << " 3d DistanceIso0 " << np << " " << fK[0] << " " << fK[1] << fK[2] << " " - << fK[3] << endl; + cout << ret << " 3d DistanceIso0 " << np << " " << fK[0] << " " << fK[1] << fK[2] << " " << fK[3] << endl; } return ret; @@ -396,8 +389,7 @@ int DistanceIso0(const Triangle &K, double *f, double *fK) { } if (np && debug) { - cout << " np " << np << " " << P[0] << " " << P[1] << " :: " << f[0] << " " << f[1] << " " - << f[2] << endl; + cout << " np " << np << " " << P[0] << " " << P[1] << " :: " << f[0] << " " << f[1] << " " << f[2] << endl; } if (np == 0) { @@ -442,27 +434,16 @@ class Distance2d_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - KN< long > *arg(int i, Stack stack, KN< long > *a) const { - return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; - } + KN< long > *arg(int i, Stack stack, KN< long > *a) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: - Distance2d_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx) - : eTh(tth), eff(fff), exx(xxx) { - args.SetNameParam(n_name_param, name_param, nargs); - } + Distance2d_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx) : eTh(tth), eff(fff), exx(xxx) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; @@ -478,8 +459,7 @@ pair< double, long > Add(const Mesh &Th, int kk, int ee, double *fv) { double fq = distmin< R2 >(K[a], fv[ia], K[b], fv[ib], K[q]); if (debug) { - cout << iq << " ** add " << kk << " " << ee << " ; " << fq << " :: " << fv[ia] << " " << fv[ib] - << " || " << fv[iq] << endl; + cout << iq << " ** add " << kk << " " << ee << " ; " << fq << " :: " << fv[ia] << " " << fv[ib] << " || " << fv[iq] << endl; } return pair< double, long >(fq, kk * 3 + ee); @@ -495,8 +475,7 @@ pair< double, long > Add(const Mesh3 &Th, int kk, int ee, double *fv) { int ia = Th(kk, a), ib = Th(kk, b), ic = Th(kk, c), iq = Th(kk, q); double fq = distmin(K[a], fv[ia], K[b], fv[ib], K[c], fv[ic], K[q]); if (debug) { - cout << " ** add " << kk << " " << ee << " ; " << fq << " :: " << fv[ia] << " " << fv[ib] << " " - << fv[ic] << " || " << fv[iq] << endl; + cout << " ** add " << kk << " " << ee << " ; " << fq << " :: " << fv[ia] << " " << fv[ib] << " " << fv[ic] << " || " << fv[iq] << endl; } return pair< double, long >(fq, kk * 4 + ee); @@ -518,8 +497,7 @@ int DistanceIso0(const Mesh &Th, int k, double *f, double *fv) { fv[iK[1]] = min(fv[iK[1]], FK[1]); fv[iK[2]] = min(fv[iK[2]], FK[2]); if (debug) { - cout << " DistanceIso0 set K" << cas << " " << iK[0] << " " << iK[1] << " " << iK[2] << " " - << fv[iK[0]] << " " << fv[iK[1]] << " " << fv[iK[2]] << endl; + cout << " DistanceIso0 set K" << cas << " " << iK[0] << " " << iK[1] << " " << iK[2] << " " << fv[iK[0]] << " " << fv[iK[1]] << " " << fv[iK[2]] << endl; } } @@ -614,8 +592,7 @@ AnyType Distance(Stack stack, const Mesh *pTh, Expression eff, KN< double > *pxx // if (verbosity > 3) { - cout << " Distance: nb elemets in queue after init" << pqs.size( ) << " / nb set " << nt0 - << endl; + cout << " Distance: nb elemets in queue after init" << pqs.size( ) << " / nb set " << nt0 << endl; } double fm; @@ -633,8 +610,7 @@ AnyType Distance(Stack stack, const Mesh *pTh, Expression eff, KN< double > *pxx int iq = Th(k, e); if (debug) { - cout << iq << " " << fm << " -- k=" << k << " e=" << e << " fv:" << fv[iq] << " / " - << markT[k] << endl; + cout << iq << " " << fm << " -- k=" << k << " e=" << e << " fv:" << fv[iq] << " / " << markT[k] << endl; } if (markT[k] != 0) { // already done, skeep @@ -689,27 +665,16 @@ class Distance3d_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - KN< long > *arg(int i, Stack stack, KN< long > *a) const { - return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; - } + KN< long > *arg(int i, Stack stack, KN< long > *a) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: - Distance3d_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx) - : eTh(tth), eff(fff), exx(xxx) { - args.SetNameParam(n_name_param, name_param, nargs); - } + Distance3d_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx) : eTh(tth), eff(fff), exx(xxx) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; @@ -733,27 +698,17 @@ AnyType Distance3d_Op::operator( )(Stack stack) const { class Distance2d_P1 : public OneOperator { public: typedef const Mesh *pmesh; - Distance2d_P1( ) - : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), - atype< KN< double > * >( )) {} + Distance2d_P1( ) : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), atype< KN< double > * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Distance2d_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Distance2d_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; class Distance3d_P1 : public OneOperator { public: typedef const Mesh3 *pmesh3; - Distance3d_P1( ) - : OneOperator(atype< long >( ), atype< pmesh3 >( ), atype< double >( ), - atype< KN< double > * >( )) {} + Distance3d_P1( ) : OneOperator(atype< long >( ), atype< pmesh3 >( ), atype< double >( ), atype< KN< double > * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Distance3d_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Distance3d_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; static void finit( ) { diff --git a/plugin/seq/exactpartition.cpp b/plugin/seq/exactpartition.cpp index ff433ce37..f7c23905d 100644 --- a/plugin/seq/exactpartition.cpp +++ b/plugin/seq/exactpartition.cpp @@ -136,11 +136,9 @@ long exactpartition(KN< KN< double > > *const &p, KN< long > *const &pj) { static void Load_Init( ) { // to be sure to have unique add if (!Global.Find("exactpartition").NotNull( )) { - Global.Add("exactpartition", "(", - new OneOperator2_< long, FEbaseArrayKn< double > *, KN< long > * >(exactpartition)); + Global.Add("exactpartition", "(", new OneOperator2_< long, FEbaseArrayKn< double > *, KN< long > * >(exactpartition)); // KN > - Global.Add("exactpartition", "(", - new OneOperator2_< long, KN< KN< double > > *, KN< long > * >(exactpartition)); + Global.Add("exactpartition", "(", new OneOperator2_< long, KN< KN< double > > *, KN< long > * >(exactpartition)); } } diff --git a/plugin/seq/ff-Ipopt.cpp b/plugin/seq/ff-Ipopt.cpp index 69fcb66d5..9fe27ec59 100644 --- a/plugin/seq/ff-Ipopt.cpp +++ b/plugin/seq/ff-Ipopt.cpp @@ -76,9 +76,7 @@ inline void clean(T *p) { } // Pair compare (certainly already implemented in the STL with KeyLess...) -inline bool operator<=(const std::pair< int, int > &l, const std::pair< int, int > &r) { - return (l.first < r.first) || (l.first == r.first && l.second <= r.second); -} +inline bool operator<=(const std::pair< int, int > &l, const std::pair< int, int > &r) { return (l.first < r.first) || (l.first == r.first && l.second <= r.second); } // Some logical operators (exclussive or and its negation) inline bool XOR(bool a, bool b) { return (!a && b) || (a && !b); } @@ -128,8 +126,7 @@ class GeneralFunc : public ffcalfunc< K > { Expression JJ, theparame; GeneralFunc(const GeneralFunc &f) : ffcalfunc< K >(f), JJ(f.JJ), theparame(f.theparame) {} - GeneralFunc(Stack s, Expression JJJ, Expression epar) - : ffcalfunc< K >(s), JJ(JJJ), theparame(epar) {} + GeneralFunc(Stack s, Expression JJJ, Expression epar) : ffcalfunc< K >(s), JJ(JJJ), theparame(epar) {} K J(Rn_ x) const { KN< double > *p = GetAny< KN< double > * >((*theparame)(this->stack)); @@ -157,8 +154,7 @@ class P2ScalarFunc : public ffcalfunc< R > { Expression M, b; // Matrix of the quadratic part, vector of the linear part P2ScalarFunc(const P2ScalarFunc &f) : ffcalfunc< R >(f), M(f.M), b(f.b), vf(f.vf) {} - P2ScalarFunc(Stack s, Expression _M, Expression _b, bool _vf = false) - : ffcalfunc< R >(s), M(_M), b(_b), vf(_vf) {} + P2ScalarFunc(Stack s, Expression _M, Expression _b, bool _vf = false) : ffcalfunc< R >(s), M(_M), b(_b), vf(_vf) {} R J(Rn_ x) const { Rn tmp(x.N( ), 0.); @@ -202,8 +198,7 @@ class P1VectorFunc : public ffcalfunc< Rn > { Expression M, b; P1VectorFunc(const P1VectorFunc &f) : ffcalfunc< Rn >(f), M(f.M), b(f.b), vf(f.vf) {} - P1VectorFunc(Stack s, Expression _M, Expression _b, bool _vf = false) - : ffcalfunc< Rn >(s), M(_M), b(_b), vf(_vf) {} + P1VectorFunc(Stack s, Expression _M, Expression _b, bool _vf = false) : ffcalfunc< Rn >(s), M(_M), b(_b), vf(_vf) {} Rn J(Rn_ x) const { Rn tmp(0); @@ -266,11 +261,8 @@ class GeneralSparseMatFunc : public ffcalfunc< Matrice_Creuse< R > * > { public: Expression JJ, param, paramlm, paramof; - GeneralSparseMatFunc(const GeneralSparseMatFunc &f) - : FFF(f), JJ(f.JJ), param(f.param), paramlm(f.paramlm), paramof(f.paramof){}; - GeneralSparseMatFunc(Stack s, Expression JJJ, Expression epar, Expression eparof = 0, - Expression eparlm = 0) - : FFF(s), JJ(JJJ), param(epar), paramlm(eparlm), paramof(eparof) { + GeneralSparseMatFunc(const GeneralSparseMatFunc &f) : FFF(f), JJ(f.JJ), param(f.param), paramlm(f.paramlm), paramof(f.paramof) {}; + GeneralSparseMatFunc(Stack s, Expression JJJ, Expression epar, Expression eparof = 0, Expression eparlm = 0) : FFF(s), JJ(JJJ), param(epar), paramlm(eparlm), paramof(eparof) { ffassert(NXOR(paramlm, paramof)); } @@ -363,14 +355,10 @@ class SparseMatStructure { SparseMatStructure(bool _sym = 0) : structure( ), sym(_sym), n(0), m(0), raws(0), cols(0) {} - SparseMatStructure(Matrice_Creuse< R > *M, bool _sym = 0) - : structure( ), sym(_sym), n(M->N( )), m(M->M( )), raws(0), cols(0) { - this->AddMatrix(M); - } + SparseMatStructure(Matrice_Creuse< R > *M, bool _sym = 0) : structure( ), sym(_sym), n(M->N( )), m(M->M( )), raws(0), cols(0) { this->AddMatrix(M); } template< class INT > - SparseMatStructure(const KN< INT > &I, const KN< INT > &J, bool _sym = 0) - : structure( ), sym(_sym), n(I.max( )), m(J.max( )), raws(0), cols(0) { + SparseMatStructure(const KN< INT > &I, const KN< INT > &J, bool _sym = 0) : structure( ), sym(_sym), n(I.max( )), m(J.max( )), raws(0), cols(0) { this->AddArrays(I, J); } @@ -529,10 +517,8 @@ class ffNLP : public TNLP { public: ffNLP( ) : xstart(0) {} - ffNLP(Rn &, const Rn &, const Rn &, const Rn &, const Rn &, ScalarFunc *, VectorFunc *, - SparseMatFunc *, VectorFunc *, SparseMatFunc *); - ffNLP(Rn &, const Rn &, const Rn &, const Rn &, const Rn &, ScalarFunc *, VectorFunc *, - SparseMatFunc *, VectorFunc *, SparseMatFunc *, int, int, int); + ffNLP(Rn &, const Rn &, const Rn &, const Rn &, const Rn &, ScalarFunc *, VectorFunc *, SparseMatFunc *, VectorFunc *, SparseMatFunc *); + ffNLP(Rn &, const Rn &, const Rn &, const Rn &, const Rn &, ScalarFunc *, VectorFunc *, SparseMatFunc *, VectorFunc *, SparseMatFunc *, int, int, int); virtual ~ffNLP( ); bool get_nlp_info(Index &, Index &, Index &, Index &, IndexStyleEnum &); // the IPOPT methods @@ -542,10 +528,8 @@ class ffNLP : public TNLP { bool eval_grad_f(Index, const Number *, bool, Number *); bool eval_g(Index, const Number *, bool, Index, Number *); bool eval_jac_g(Index, const Number *, bool, Index, Index, Index *, Index *, Number *); - bool eval_h(Index, const Number *, bool, Number, Index, const Number *, bool, Index, Index *, - Index *, Number *); - void finalize_solution(SolverReturn, Index, const Number *, const Number *, const Number *, Index, - const Number *, const Number *, Number, const IpoptData *ip_data, + bool eval_h(Index, const Number *, bool, Number, Index, const Number *, bool, Index, Index *, Index *, Number *); + void finalize_solution(SolverReturn, Index, const Number *, const Number *, const Number *, Index, const Number *, const Number *, Number, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq); template< class INT > @@ -594,27 +578,19 @@ class ffNLP : public TNLP { } } // Fill a KN with a pointer <-- to avoid the use of const_cast - static int FindIndex(const KN< int > &irow, const KN< int > &jrow, int i, int j, int kmin, - int kmax); + static int FindIndex(const KN< int > &irow, const KN< int > &jrow, int i, int j, int kmin, int kmax); }; -ffNLP::ffNLP(Rn &x, const Rn &_xl, const Rn &_xu, const Rn &_gl, const Rn &_gu, - ScalarFunc *_fitness, VectorFunc *_dfitness, SparseMatFunc *_hessian, - VectorFunc *_constraints, SparseMatFunc *_dconstraints) - : xstart(&x), xl(_xl), xu(_xu), gl(_gl), gu(_gu), - final_value(299792458.), // sym(0),unsymind(), - fitness(_fitness), dfitness(_dfitness), constraints(_constraints), uz_start( ), lz_start( ), - hessian(_hessian), dconstraints(_dconstraints), mm(-1), nnz_jac(-1), nnz_h(-1), HesStruct(true), +ffNLP::ffNLP(Rn &x, const Rn &_xl, const Rn &_xu, const Rn &_gl, const Rn &_gu, ScalarFunc *_fitness, VectorFunc *_dfitness, SparseMatFunc *_hessian, VectorFunc *_constraints, + SparseMatFunc *_dconstraints) + : xstart(&x), xl(_xl), xu(_xu), gl(_gl), gu(_gu), final_value(299792458.), // sym(0),unsymind(), + fitness(_fitness), dfitness(_dfitness), constraints(_constraints), uz_start( ), lz_start( ), hessian(_hessian), dconstraints(_dconstraints), mm(-1), nnz_jac(-1), nnz_h(-1), HesStruct(true), JacStruct(false), sigma_start(1.), lambda_start( ), x_start(x), checkstruct(1) {} -ffNLP::ffNLP(Rn &x, const Rn &_xl, const Rn &_xu, const Rn &_gl, const Rn &_gu, - ScalarFunc *_fitness, VectorFunc *_dfitness, SparseMatFunc *_hessian, - VectorFunc *_constraints, SparseMatFunc *_dconstraints, int _mm, int _nnz_jac, - int _nnz_h) - : xstart(&x), xl(_xl), xu(_xu), gl(_gl), gu(_gu), hessian(_hessian), - final_value(299792458.), // sym(0),unsymind(), - fitness(_fitness), dfitness(_dfitness), constraints(_constraints), dconstraints(_dconstraints), - uz_start( ), lz_start( ), mm(_mm), nnz_jac(_nnz_jac), nnz_h(_nnz_h), HesStruct(true), +ffNLP::ffNLP(Rn &x, const Rn &_xl, const Rn &_xu, const Rn &_gl, const Rn &_gu, ScalarFunc *_fitness, VectorFunc *_dfitness, SparseMatFunc *_hessian, VectorFunc *_constraints, + SparseMatFunc *_dconstraints, int _mm, int _nnz_jac, int _nnz_h) + : xstart(&x), xl(_xl), xu(_xu), gl(_gl), gu(_gu), hessian(_hessian), final_value(299792458.), // sym(0),unsymind(), + fitness(_fitness), dfitness(_dfitness), constraints(_constraints), dconstraints(_dconstraints), uz_start( ), lz_start( ), mm(_mm), nnz_jac(_nnz_jac), nnz_h(_nnz_h), HesStruct(true), JacStruct(false), sigma_start(1.), lambda_start( ), x_start(x), checkstruct(1) {} ffNLP::~ffNLP( ) { @@ -683,8 +659,7 @@ ffNLP &ffNLP::BuildMatrixStructures(Level hlvl, Level jlvl, int _mm) { return *this; } -int ffNLP::FindIndex(const KN< int > &irow, const KN< int > &jcol, int i, int j, int kmin, - int kmax) { +int ffNLP::FindIndex(const KN< int > &irow, const KN< int > &jcol, int i, int j, int kmin, int kmax) { typedef std::pair< int, int > Z2; Z2 ij(i, j), ijmin(irow[kmin], jcol[kmin]), ijmax(irow[kmax], jcol[kmax]); if (abs(kmin - kmax) <= 1) { @@ -706,8 +681,7 @@ int ffNLP::FindIndex(const KN< int > &irow, const KN< int > &jcol, int i, int j, } } -bool ffNLP::get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, - IndexStyleEnum &index_style) { +bool ffNLP::get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style) { bool ret = true; n = xstart ? xstart->N( ) : (ret = 0); @@ -738,8 +712,7 @@ bool ffNLP::get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number * return true; } -bool ffNLP::get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, - Number *z_U, Index m, bool init_lambda, Number *lambda) { +bool ffNLP::get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda) { assert(init_x == true); assert(xstart->N( ) == n); KnToPtr(*xstart, x); @@ -832,8 +805,7 @@ bool ffNLP::eval_g(Index n, const Number *x, bool new_x, Index m, Number *g) { return true; } -bool ffNLP::eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, - Index *jCol, Number *values) { +bool ffNLP::eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values) { assert(n == xstart->N( )); Rn X(n); if (x) { @@ -857,8 +829,7 @@ bool ffNLP::eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele for (int i = 0; i < MM->N; ++i) { for (int k = MM->p[i]; k < MM->p[i + 1]; ++k) { if (checkstruct) { - int kipopt = - FindIndex(JacStruct.Raws( ), JacStruct.Cols( ), i, MM->j[k], 0, nele_jac - 1); + int kipopt = FindIndex(JacStruct.Raws( ), JacStruct.Cols( ), i, MM->j[k], 0, nele_jac - 1); if (kipopt >= 0) { values[kipopt] = MM->aij[k]; } @@ -872,9 +843,7 @@ bool ffNLP::eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele return true; } -bool ffNLP::eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, - const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, - Number *values) { +bool ffNLP::eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values) { Rn X(n), L(m); if (x) { @@ -913,8 +882,7 @@ bool ffNLP::eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Inde if (checkstruct) { for (int i = 0; i < MM->N; ++i) { for (int k = MM->p[i]; k < MM->p[i + 1]; ++k) { - int kipopt = - FindIndex(HesStruct.Raws( ), HesStruct.Cols( ), i, MM->j[k], 0, nele_hess - 1); + int kipopt = FindIndex(HesStruct.Raws( ), HesStruct.Cols( ), i, MM->j[k], 0, nele_hess - 1); if (kipopt >= 0) { values[kipopt] = _obj_factor * (MM->aij[k]); } @@ -942,10 +910,8 @@ bool ffNLP::eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Inde return true; } -void ffNLP::finalize_solution(SolverReturn status, Index n, const Number *x, const Number *z_L, - const Number *z_U, Index m, const Number *g, const Number *lambda, - Number obj_value, const IpoptData *ip_data, - IpoptCalculatedQuantities *ip_cq) { +void ffNLP::finalize_solution(SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, + const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq) { KnFromPtr(*xstart, x); KnFromPtr(lambda_start, lambda); KnFromPtr(lz_start, z_L); @@ -984,15 +950,7 @@ void ffNLP::finalize_solution(SolverReturn status, Index n, const Number *x, con *IPOPT *****************************************************************************************************************************/ -enum AssumptionF { - undeff, - no_assumption_f, - P2_f, - unavailable_hessian, - mv_P2_f, - quadratic_f, - linear_f -}; +enum AssumptionF { undeff, no_assumption_f, P2_f, unavailable_hessian, mv_P2_f, quadratic_f, linear_f }; enum AssumptionG { undefg, without_constraints, no_assumption_g, P1_g, mv_P1_g, linear_g }; template< AssumptionF AF, AssumptionG AG > @@ -1034,39 +992,32 @@ bool CheckMatrixVectorPair(const E_Array *mv, bool &order) { *****************************************************************************************************************************/ class GenericFitnessFunctionDatas { public: - static GenericFitnessFunctionDatas *New(AssumptionF, const basicAC_F0 &, Expression const *, - const C_F0 &, const C_F0 &, const C_F0 &); + static GenericFitnessFunctionDatas *New(AssumptionF, const basicAC_F0 &, Expression const *, const C_F0 &, const C_F0 &, const C_F0 &); bool CompletelyNonLinearConstraints; Expression JJ, GradJ, Hessian; - GenericFitnessFunctionDatas( ) - : CompletelyNonLinearConstraints(true), JJ(0), GradJ(0), Hessian(0) {} + GenericFitnessFunctionDatas( ) : CompletelyNonLinearConstraints(true), JJ(0), GradJ(0), Hessian(0) {} virtual const AssumptionF A( ) const { return undeff; } - virtual void operator( )(Stack, const C_F0 &, const C_F0 &, const C_F0 &, Expression const *, - ScalarFunc *&, VectorFunc *&, SparseMatFunc *&, + virtual void operator( )(Stack, const C_F0 &, const C_F0 &, const C_F0 &, Expression const *, ScalarFunc *&, VectorFunc *&, SparseMatFunc *&, bool) const = 0; // Build the functions virtual ~GenericFitnessFunctionDatas( ) {} }; template< AssumptionF AF > -class FitnessFunctionDatas - : public GenericFitnessFunctionDatas // not really a template, since most of the methods of all - // cases have to be specialized +class FitnessFunctionDatas : public GenericFitnessFunctionDatas // not really a template, since most of the methods of all + // cases have to be specialized { public: - FitnessFunctionDatas(const basicAC_F0 &, Expression const *, const C_F0 &, const C_F0 &, - const C_F0 &); + FitnessFunctionDatas(const basicAC_F0 &, Expression const *, const C_F0 &, const C_F0 &, const C_F0 &); const AssumptionF A( ) const { return AF; } - void operator( )(Stack, const C_F0 &, const C_F0 &, const C_F0 &, Expression const *, - ScalarFunc *&, VectorFunc *&, SparseMatFunc *&, bool) const; + void operator( )(Stack, const C_F0 &, const C_F0 &, const C_F0 &, Expression const *, ScalarFunc *&, VectorFunc *&, SparseMatFunc *&, bool) const; }; class GenericConstraintFunctionDatas { public: - static GenericConstraintFunctionDatas *New(AssumptionG, const basicAC_F0 &, Expression const *, - const C_F0 &); + static GenericConstraintFunctionDatas *New(AssumptionG, const basicAC_F0 &, Expression const *, const C_F0 &); Expression Constraints, GradConstraints; GenericConstraintFunctionDatas( ) : Constraints(0), GradConstraints(0) {} @@ -1086,8 +1037,7 @@ class ConstraintFunctionDatas : public GenericConstraintFunctionDatas { const bool WC( ) const { return AG != without_constraints; } - void operator( )(Stack, const C_F0 &, Expression const *, VectorFunc *&, SparseMatFunc *&, - bool) const; + void operator( )(Stack, const C_F0 &, Expression const *, VectorFunc *&, SparseMatFunc *&, bool) const; }; /***************************************************************************************************************************** @@ -1108,7 +1058,7 @@ class OptimIpopt : public OneOperator { const bool WC; std::set< unsigned short > unused_name_param; // In some case, some parameter are usless, // this is the list of their index in nargs - void InitUNP( ); // Initialize unusued_name_param at freefem compile time + void InitUNP( ); // Initialize unusued_name_param at freefem compile time static basicAC_F0::name_and_type name_param[]; static const int n_name_param = 29; Expression nargs[n_name_param]; @@ -1119,19 +1069,13 @@ class OptimIpopt : public OneOperator { C_F0 initobjfact, objfact; GenericFitnessFunctionDatas *fitness_datas; GenericConstraintFunctionDatas *constraints_datas; - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } - Rn_ arg(int i, Stack stack, Rn_ a) const { - return nargs[i] ? GetAny< Rn_ >((*nargs[i])(stack)) : a; - } + Rn_ arg(int i, Stack stack, Rn_ a) const { return nargs[i] ? GetAny< Rn_ >((*nargs[i])(stack)) : a; } template< typename T > T Arg(int i, Stack s) const { @@ -1139,26 +1083,21 @@ class OptimIpopt : public OneOperator { } E_Ipopt(const basicAC_F0 &args, AssumptionF af, AssumptionG ag) - : lm( ), L_m(CPValue(lm)), AF(af), AG(ag), WC(ag != without_constraints), - unused_name_param( ), spurious_cases(false), fitness_datas(0), constraints_datas(0) { + : lm( ), L_m(CPValue(lm)), AF(af), AG(ag), WC(ag != without_constraints), unused_name_param( ), spurious_cases(false), fitness_datas(0), constraints_datas(0) { InitUNP( ); int nbj = args.size( ) - 1; Block::open(currentblock); // make a new block to X = to< Rn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); initobjfact = currentblock->NewVar< LocalVariable >("objective factor", atype< double * >( )); theparam = currentblock->Find("the parameter"); // the expression for the parameter objfact = currentblock->Find("objective factor"); args.SetNameParam(n_name_param, name_param, nargs); - fitness_datas = GenericFitnessFunctionDatas::New( - AF, args, nargs, theparam, objfact, L_m); // Creates links to the freefem objects - constraints_datas = - GenericConstraintFunctionDatas::New(AG, args, nargs, theparam); // defining the functions - spurious_cases = AG == no_assumption_g && - (AF == P2_f || AF == mv_P2_f || AF == quadratic_f || AF == linear_f); + fitness_datas = GenericFitnessFunctionDatas::New(AF, args, nargs, theparam, objfact, L_m); // Creates links to the freefem objects + constraints_datas = GenericConstraintFunctionDatas::New(AG, args, nargs, theparam); // defining the functions + spurious_cases = AG == no_assumption_g && (AF == P2_f || AF == mv_P2_f || AF == quadratic_f || AF == linear_f); closetheparam = C_F0((Expression)Block::snewclose(currentblock), atype< void >( )); } @@ -1178,8 +1117,8 @@ class OptimIpopt : public OneOperator { WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 Rn &x = *GetAny< Rn * >((*X)(stack)); { - Expression test(theparam); // in some case the KN object associated to the param is never - // initialized, leading to failed assertion in KN::destroy + Expression test(theparam); // in some case the KN object associated to the param is never + // initialized, leading to failed assertion in KN::destroy Rn *tt = GetAny< Rn * >((*test)(stack)); // this lines prevent this to happen *tt = x; } @@ -1196,9 +1135,7 @@ class OptimIpopt : public OneOperator { cout << " - if constraints have computable hessians, use function form for the fitness " "function and all its derivatives" << endl; - cout - << " and check the documentation to know how to express the whole lagrangian hessian." - << endl; + cout << " and check the documentation to know how to express the whole lagrangian hessian." << endl; cout << " - if constraints hessians are difficult to obtain, force the BFGS mode using " "named parameter " << name_param[12].name << '.' << endl; @@ -1217,15 +1154,13 @@ class OptimIpopt : public OneOperator { // Detection of mixed case dependant warnings or error for (int i = 0; i < n_name_param; ++i) { if (nargs[i] && unused_name_param.find(i) != unused_name_param.end( )) { - cout << "ff-IPOPT Warning: named parameter " << name_param[i].name - << " is useless for the problem you have set." << endl; + cout << "ff-IPOPT Warning: named parameter " << name_param[i].name << " is useless for the problem you have set." << endl; warned = true; } } if (nargs[4] && nargs[5] && nargs[7]) { - cout << "ff-IPOPT Warning: both " << name_param[4].name << " and " << name_param[5].name - << " has been defined, so " << name_param[7].name; + cout << "ff-IPOPT Warning: both " << name_param[4].name << " and " << name_param[5].name << " has been defined, so " << name_param[7].name; cout << " will be ignored." << endl; } @@ -1240,36 +1175,27 @@ class OptimIpopt : public OneOperator { << endl; } - if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && - nargs[5]) { + if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && nargs[5]) { cout << " ==> your lagrangian hessian is a constant matrix, so there is no need to " "specify its structure with " << name_param[5].name << endl; cout << " since it is contained in the matrix object." << endl; } - if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && - nargs[7]) { - cout << " ==> " << name_param[7].name - << " will be ignored since all matrices are constants and constraints do not" - << endl; - cout << " contribute to the hessian, matrix structure determination is trivial." - << endl; + if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && nargs[7]) { + cout << " ==> " << name_param[7].name << " will be ignored since all matrices are constants and constraints do not" << endl; + cout << " contribute to the hessian, matrix structure determination is trivial." << endl; } if (AF == unavailable_hessian && AG != no_assumption_g && (nargs[7] || nargs[8])) { - cout << " ==> " << name_param[7].name << " or " << name_param[8].name - << " will be ignored since the only matrix you have passed is constant. " << endl; + cout << " ==> " << name_param[7].name << " or " << name_param[8].name << " will be ignored since the only matrix you have passed is constant. " << endl; cout << " Or maybe did you forget to pass a function (IPOPT will certainly crash if " "so)." << endl; } - if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && - nargs[8]) { - cout << " ==> no need to use " << name_param[8].name - << " since all matrices are constant, structures won't change through the algorithm," - << endl; + if (AF != no_assumption_f && AF != unavailable_hessian && AG != no_assumption_g && nargs[8]) { + cout << " ==> no need to use " << name_param[8].name << " since all matrices are constant, structures won't change through the algorithm," << endl; cout << " it is automatically set to the default disabling value." << endl; } } @@ -1283,8 +1209,7 @@ class OptimIpopt : public OneOperator { warned); // Fill the functions (*constraints_datas)(stack, theparam, nargs, ffC, ffdC, warned); - Rn xl(n), xu(n), gl(nargs[2] ? Arg< Rn_ >(2, stack).N( ) : 0), - gu(nargs[3] ? Arg< Rn_ >(3, stack).N( ) : 0); + Rn xl(n), xu(n), gl(nargs[2] ? Arg< Rn_ >(2, stack).N( ) : 0), gu(nargs[3] ? Arg< Rn_ >(3, stack).N( ) : 0); int mmm = 0; if (WC && (gl.N( ) + gu.N( )) == 0) { cout << "IPOPT Warning : constrained problem without constraints bounds." << endl; @@ -1296,9 +1221,7 @@ class OptimIpopt : public OneOperator { Rn_ *lag_mul = 0, *l_z = 0, *u_z = 0; // Rn(mmm,1.); // int niter=arg(6,stack,100L); int autostructmode = ffNLP::one_evaluation; - bool checkindex = - (AF != no_assumption_f && AG != no_assumption_g) ? false : arg(8, stack, true), - cberror = false; + bool checkindex = (AF != no_assumption_f && AG != no_assumption_g) ? false : arg(8, stack, true), cberror = false; if (nargs[0]) { xl = Arg< Rn_ >(0, stack); @@ -1326,12 +1249,8 @@ class OptimIpopt : public OneOperator { gu = 1.e19; } - const E_Array *ejacstruct = (WC && AF == no_assumption_f && AG == no_assumption_g && nargs[4]) - ? dynamic_cast< const E_Array * >(nargs[4]) - : 0, - *ehesstruct = (AF == no_assumption_f && nargs[5]) - ? dynamic_cast< const E_Array * >(nargs[5]) - : 0; + const E_Array *ejacstruct = (WC && AF == no_assumption_f && AG == no_assumption_g && nargs[4]) ? dynamic_cast< const E_Array * >(nargs[4]) : 0, + *ehesstruct = (AF == no_assumption_f && nargs[5]) ? dynamic_cast< const E_Array * >(nargs[5]) : 0; if (nargs[6] && WC) { lag_mul = new Rn_(GetAny< Rn_ >((*nargs[6])(stack))); @@ -1372,8 +1291,7 @@ class OptimIpopt : public OneOperator { if (ejacstruct) { if (ejacstruct->nbitem( ) != 2) { - ExecError( - "\nSorry, we were expecting an array with two componants in structjac=[iraw,jcol]"); + ExecError("\nSorry, we were expecting an array with two componants in structjac=[iraw,jcol]"); } if ((*ejacstruct)[0].left( ) != atype< KN< long > * >( )) { @@ -1385,14 +1303,12 @@ class OptimIpopt : public OneOperator { } Expression raws = (*ejacstruct)[0], cols = (*ejacstruct)[1]; - _optim->SetJacobianStructure(*GetAny< KN< long > * >((*raws)(stack)), - *GetAny< KN< long > * >((*cols)(stack)), true); + _optim->SetJacobianStructure(*GetAny< KN< long > * >((*raws)(stack)), *GetAny< KN< long > * >((*cols)(stack)), true); } if (ehesstruct) { if (ehesstruct->nbitem( ) != 2) { - ExecError( - "\nSorry, we were expecting an array with two componants in structhess=[iraw,jcol]"); + ExecError("\nSorry, we were expecting an array with two componants in structhess=[iraw,jcol]"); } if ((*ehesstruct)[0].left( ) != atype< KN< long > * >( )) { @@ -1404,12 +1320,10 @@ class OptimIpopt : public OneOperator { } Expression raws = (*ehesstruct)[0], cols = (*ehesstruct)[1]; - _optim->SetHessianStructure(*GetAny< KN< long > * >((*raws)(stack)), - *GetAny< KN< long > * >((*cols)(stack)), true); + _optim->SetHessianStructure(*GetAny< KN< long > * >((*raws)(stack)), *GetAny< KN< long > * >((*cols)(stack)), true); } - ffNLP::Level lh = ehesstruct ? ffNLP::user_defined : ffNLP::Level(autostructmode), - lj = ejacstruct ? ffNLP::user_defined : ffNLP::Level(autostructmode); + ffNLP::Level lh = ehesstruct ? ffNLP::user_defined : ffNLP::Level(autostructmode), lj = ejacstruct ? ffNLP::user_defined : ffNLP::Level(autostructmode); if (AF == unavailable_hessian) { lh = ffNLP::do_nothing; } @@ -1466,18 +1380,15 @@ class OptimIpopt : public OneOperator { } if (nargs[16]) { - app->Options( )->SetNumericValue("derivative_test_perturbation", - GetAny< double >((*nargs[16])(stack))); + app->Options( )->SetNumericValue("derivative_test_perturbation", GetAny< double >((*nargs[16])(stack))); } if (nargs[17]) { - app->Options( )->SetNumericValue("derivative_test_tol", - GetAny< double >((*nargs[17])(stack))); + app->Options( )->SetNumericValue("derivative_test_tol", GetAny< double >((*nargs[17])(stack))); } if (nargs[18]) { - app->Options( )->SetStringValue("fixed_variable_treatment", - GetAny< string * >((*nargs[18])(stack))->c_str( )); + app->Options( )->SetStringValue("fixed_variable_treatment", GetAny< string * >((*nargs[18])(stack))->c_str( )); } if (nargs[19]) { @@ -1486,24 +1397,21 @@ class OptimIpopt : public OneOperator { cout << "ff-IPOPT Warning : warm start for constrained problem without initial " "constraints dual variables (" << name_param[6].name << " parameter)." << endl; - cout << " ==> Starting with " << name_param[6].name << "=(1,1,...,1)." - << endl; + cout << " ==> Starting with " << name_param[6].name << "=(1,1,...,1)." << endl; } if (nargs[0] && !nargs[21]) { cout << "ff-IPOPT Warning : warm start with simple lower bounds without initial lower " "bounds dual variables (" << name_param[21].name << " parameter)." << endl; - cout << " ==> Starting with " << name_param[21].name << "=(1,1,...,1)." - << endl; + cout << " ==> Starting with " << name_param[21].name << "=(1,1,...,1)." << endl; } if (nargs[1] && !nargs[20]) { cout << "ff-IPOPT Warning : warm start with simple upper bounds without initial upper " "bounds dual variables (" << name_param[20].name << " parameter)." << endl; - cout << " ==> Starting with " << name_param[20].name << "=(1,1,...,1)." - << endl; + cout << " ==> Starting with " << name_param[20].name << "=(1,1,...,1)." << endl; } if (l_z) { @@ -1530,13 +1438,11 @@ class OptimIpopt : public OneOperator { } if (nargs[24]) { - app->Options( )->SetNumericValue("bound_relax_factor", - GetAny< double >((*nargs[24])(stack))); + app->Options( )->SetNumericValue("bound_relax_factor", GetAny< double >((*nargs[24])(stack))); } if (nargs[25]) { - app->Options( )->SetStringValue("mu_strategy", - GetAny< string * >((*nargs[25])(stack))->c_str( )); + app->Options( )->SetStringValue("mu_strategy", GetAny< string * >((*nargs[25])(stack))->c_str( )); } if (nargs[27]) { @@ -1605,10 +1511,9 @@ class OptimIpopt : public OneOperator { lm.destroy( ); // clean memory of LM } - closetheparam.eval(stack); // clean memory - WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 - return SetAny< long >(static_cast< long >( - static_cast< int >(status))); // SetAny(0); Modif FH july 2005 + closetheparam.eval(stack); // clean memory + WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 + return SetAny< long >(static_cast< long >(static_cast< int >(status))); // SetAny(0); Modif FH july 2005 } operator aType( ) const { return atype< long >( ); } @@ -1620,158 +1525,96 @@ class OptimIpopt : public OneOperator { // in freefem scripts OptimIpopt(Case< no_assumption_f, no_assumption_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< KN< R > * >( )), + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(no_assumption_f), AG(no_assumption_g) {} OptimIpopt(Case< no_assumption_f, without_constraints >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), - AF(no_assumption_f), AG(without_constraints) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(no_assumption_f), AG(without_constraints) {} OptimIpopt(Case< no_assumption_f, P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), + atype< KN< R > * >( )), AF(no_assumption_f), AG(P1_g) {} OptimIpopt(Case< no_assumption_f, mv_P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< E_Array >( ), atype< KN< R > * >( )), - AF(no_assumption_f), AG(mv_P1_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(no_assumption_f), AG(mv_P1_g) {} OptimIpopt(Case< no_assumption_f, linear_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< R > * >( )), - AF(no_assumption_f), AG(linear_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(no_assumption_f), + AG(linear_g) {} OptimIpopt(Case< P2_f, P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), + atype< KN< R > * >( )), AF(P2_f), AG(P1_g) {} OptimIpopt(Case< P2_f, without_constraints >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(P2_f), AG(without_constraints) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(P2_f), AG(without_constraints) {} OptimIpopt(Case< P2_f, no_assumption_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), + atype< KN< R > * >( )), AF(P2_f), AG(no_assumption_g) {} OptimIpopt(Case< P2_f, mv_P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< E_Array >( ), atype< KN< R > * >( )), - AF(P2_f), AG(mv_P1_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(P2_f), AG(mv_P1_g) {} OptimIpopt(Case< P2_f, linear_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< R > * >( )), - AF(P2_f), AG(linear_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(P2_f), + AG(linear_g) {} OptimIpopt(Case< unavailable_hessian, no_assumption_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), - AF(unavailable_hessian), AG(no_assumption_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(unavailable_hessian), + AG(no_assumption_g) {} OptimIpopt(Case< unavailable_hessian, without_constraints >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< KN< R > * >( )), - AF(unavailable_hessian), AG(without_constraints) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(unavailable_hessian), AG(without_constraints) {} OptimIpopt(Case< unavailable_hessian, P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< R > * >( )), - AF(unavailable_hessian), AG(P1_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(unavailable_hessian), + AG(P1_g) {} OptimIpopt(Case< unavailable_hessian, mv_P1_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< E_Array >( ), atype< KN< R > * >( )), - AF(unavailable_hessian), AG(mv_P1_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(unavailable_hessian), AG(mv_P1_g) {} OptimIpopt(Case< unavailable_hessian, linear_g >) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(unavailable_hessian), AG(linear_g) {} + : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(unavailable_hessian), AG(linear_g) {} OptimIpopt(Case< mv_P2_f, no_assumption_g >) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), - AF(mv_P2_f), AG(no_assumption_g) {} + : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(mv_P2_f), AG(no_assumption_g) {} - OptimIpopt(Case< mv_P2_f, without_constraints >) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(mv_P2_f), - AG(without_constraints) {} + OptimIpopt(Case< mv_P2_f, without_constraints >) : OneOperator(atype< long >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(mv_P2_f), AG(without_constraints) {} - OptimIpopt(Case< mv_P2_f, P1_g >) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(mv_P2_f), AG(P1_g) {} + OptimIpopt(Case< mv_P2_f, P1_g >) : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(mv_P2_f), AG(P1_g) {} - OptimIpopt(Case< mv_P2_f, mv_P1_g >) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< E_Array >( ), - atype< KN< R > * >( )), - AF(mv_P2_f), AG(mv_P1_g) {} + OptimIpopt(Case< mv_P2_f, mv_P1_g >) : OneOperator(atype< long >( ), atype< E_Array >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(mv_P2_f), AG(mv_P1_g) {} - OptimIpopt(Case< mv_P2_f, linear_g >) - : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< R > * >( )), - AF(mv_P2_f), AG(linear_g) {} + OptimIpopt(Case< mv_P2_f, linear_g >) : OneOperator(atype< long >( ), atype< E_Array >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(mv_P2_f), AG(linear_g) {} OptimIpopt(Case< quadratic_f, no_assumption_g >) - : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), - AF(quadratic_f), AG(no_assumption_g) {} + : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(quadratic_f), AG(no_assumption_g) {} - OptimIpopt(Case< quadratic_f, without_constraints >) - : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(quadratic_f), AG(without_constraints) {} + OptimIpopt(Case< quadratic_f, without_constraints >) : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(quadratic_f), AG(without_constraints) {} OptimIpopt(Case< quadratic_f, P1_g >) - : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(quadratic_f), AG(P1_g) {} + : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(quadratic_f), AG(P1_g) {} - OptimIpopt(Case< quadratic_f, mv_P1_g >) - : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< E_Array >( ), - atype< KN< R > * >( )), - AF(quadratic_f), AG(mv_P1_g) {} + OptimIpopt(Case< quadratic_f, mv_P1_g >) : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(quadratic_f), AG(mv_P1_g) {} OptimIpopt(Case< quadratic_f, linear_g >) - : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(quadratic_f), AG(linear_g) {} + : OneOperator(atype< long >( ), atype< Matrice_Creuse< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(quadratic_f), AG(linear_g) {} OptimIpopt(Case< linear_f, no_assumption_g >) - : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), - AF(linear_f), AG(no_assumption_g) {} + : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), AF(linear_f), AG(no_assumption_g) {} - OptimIpopt(Case< linear_f, without_constraints >) - : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), AF(linear_f), - AG(without_constraints) {} + OptimIpopt(Case< linear_f, without_constraints >) : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), AF(linear_f), AG(without_constraints) {} OptimIpopt(Case< linear_f, P1_g >) - : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Polymorphic * >( ), - atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), - AF(linear_f), AG(P1_g) {} + : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Polymorphic * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(linear_f), AG(P1_g) {} - OptimIpopt(Case< linear_f, mv_P1_g >) - : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< E_Array >( ), - atype< KN< R > * >( )), - AF(linear_f), AG(mv_P1_g) {} + OptimIpopt(Case< linear_f, mv_P1_g >) : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< E_Array >( ), atype< KN< R > * >( )), AF(linear_f), AG(mv_P1_g) {} - OptimIpopt(Case< linear_f, linear_g >) - : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Matrice_Creuse< R > * >( ), - atype< KN< R > * >( )), - AF(linear_f), AG(linear_g) {} + OptimIpopt(Case< linear_f, linear_g >) : OneOperator(atype< long >( ), atype< KN< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< KN< R > * >( )), AF(linear_f), AG(linear_g) {} }; /* @@ -1906,39 +1749,38 @@ void OptimIpopt::E_Ipopt::InitUNP( ) { basicAC_F0::name_and_type OptimIpopt::E_Ipopt::name_param[] = { // DONT CHANGE THE ORDER!!!! If some parameters need to be added, add them after the last one // otherwize warning message of this interface will be a mess - {"lb", &typeid(KN_< double >)}, // 0 - lower bound on optimization parameter X - {"ub", &typeid(KN_< double >)}, // 1 - upper bound on optimization parameter X - {"clb", &typeid(KN_< double >)}, // 2 - constraints lower bounds - {"cub", &typeid(KN_< double >)}, // 3 - constraints upper bounds - {"structjacc", &typeid(E_Array)}, // 4 - constraints jacobian structure - {"structhess", &typeid(E_Array)}, // 5 - lagrangian hessian structure - {"lm", &typeid(KN_< double >)}, // 6 - lagrange multiplier (for autostruct or to get their - // value at the end of the algorithm) - {"autostruct", &typeid(long)}, // 7 - automatic structure determination - {"checkindex", &typeid(bool)}, // 8 - whether to use the FindIndex function or not - {"tol", &typeid(double)}, // 9 - stopping criteria tol - {"maxiter", &typeid(long)}, // 10 - stopping criteria : maximum number of iterations - {"maxcputime", &typeid(double)}, // 11 - stopping criteria : maximum CPU time - {"bfgs", &typeid(bool)}, // 12 - force the bfgs hessian approximation + {"lb", &typeid(KN_< double >)}, // 0 - lower bound on optimization parameter X + {"ub", &typeid(KN_< double >)}, // 1 - upper bound on optimization parameter X + {"clb", &typeid(KN_< double >)}, // 2 - constraints lower bounds + {"cub", &typeid(KN_< double >)}, // 3 - constraints upper bounds + {"structjacc", &typeid(E_Array)}, // 4 - constraints jacobian structure + {"structhess", &typeid(E_Array)}, // 5 - lagrangian hessian structure + {"lm", &typeid(KN_< double >)}, // 6 - lagrange multiplier (for autostruct or to get their + // value at the end of the algorithm) + {"autostruct", &typeid(long)}, // 7 - automatic structure determination + {"checkindex", &typeid(bool)}, // 8 - whether to use the FindIndex function or not + {"tol", &typeid(double)}, // 9 - stopping criteria tol + {"maxiter", &typeid(long)}, // 10 - stopping criteria : maximum number of iterations + {"maxcputime", &typeid(double)}, // 11 - stopping criteria : maximum CPU time + {"bfgs", &typeid(bool)}, // 12 - force the bfgs hessian approximation {"derivativetest", &typeid(string *)}, // 13 - call the derivative checker - {"optfile", &typeid(string *)}, // 14 - set the ipopt option file name (default is ipopt.opt) - {"printlevel", &typeid(long)}, // 15 - controls IPOPT print level output - {"dth", &typeid(double)}, // 16 - perturbation for finite difference derivative test - {"dttol", &typeid(double)}, // 17 - relative tolerence for the derivative test error detection - {"fixedvar", &typeid(string *)}, // 18 - remove the equality simple bounds from problem - {"warmstart", &typeid(bool)}, // 19 - do we initialize multipliers with given values - {"uz", &typeid(KN_< double >)}, // 20 - simple upper bounds dual variable - {"lz", &typeid(KN_< double >)}, // 21 - simple lower bounds dual variable - {"muinit", &typeid(double)}, // 22 - barrier parameter initialization - {"pivtol", &typeid(double)}, // 23 - pivot tolerance for the linear solver - {"brf", &typeid(double)}, // 24 - bounds relax factor - {"mustrategy", &typeid(string *)}, // 25 - strategy for barrier parameter update - {"objvalue", &typeid(double *)}, // 26 - to get the last objective function value - {"mumin", &typeid(double)}, // 27 - minimal value for the barrier parameter - {"linesearch", - &typeid(bool)} // 28 - use the line search or not (if no, the usual Newton step is kept) - // {"osf", &typeid(double) } - // //26 - objective function scalling factor + {"optfile", &typeid(string *)}, // 14 - set the ipopt option file name (default is ipopt.opt) + {"printlevel", &typeid(long)}, // 15 - controls IPOPT print level output + {"dth", &typeid(double)}, // 16 - perturbation for finite difference derivative test + {"dttol", &typeid(double)}, // 17 - relative tolerence for the derivative test error detection + {"fixedvar", &typeid(string *)}, // 18 - remove the equality simple bounds from problem + {"warmstart", &typeid(bool)}, // 19 - do we initialize multipliers with given values + {"uz", &typeid(KN_< double >)}, // 20 - simple upper bounds dual variable + {"lz", &typeid(KN_< double >)}, // 21 - simple lower bounds dual variable + {"muinit", &typeid(double)}, // 22 - barrier parameter initialization + {"pivtol", &typeid(double)}, // 23 - pivot tolerance for the linear solver + {"brf", &typeid(double)}, // 24 - bounds relax factor + {"mustrategy", &typeid(string *)}, // 25 - strategy for barrier parameter update + {"objvalue", &typeid(double *)}, // 26 - to get the last objective function value + {"mumin", &typeid(double)}, // 27 - minimal value for the barrier parameter + {"linesearch", &typeid(bool)} // 28 - use the line search or not (if no, the usual Newton step is kept) + // {"osf", &typeid(double) } + // //26 - objective function scalling factor }; static void Load_Init( ) { @@ -1969,16 +1811,11 @@ static void Load_Init( ) { *****************************************************************************************************************************/ template<> -FitnessFunctionDatas< no_assumption_f >::FitnessFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m) +FitnessFunctionDatas< no_assumption_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { - const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), - *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )), + const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )), *opH = dynamic_cast< const Polymorphic * >(args[2].LeftValue( )); - ArrayOfaType hprototype2(atype< KN< R > * >( ), atype< double >( ), atype< KN< R > * >( )), - hprototype1(atype< KN< R > * >( )); + ArrayOfaType hprototype2(atype< KN< R > * >( ), atype< double >( ), atype< KN< R > * >( )), hprototype1(atype< KN< R > * >( )); JJ = to< R >(C_F0(opJ, "(", theparam)); GradJ = to< Rn_ >(C_F0(opdJ, "(", theparam)); @@ -1986,9 +1823,8 @@ FitnessFunctionDatas< no_assumption_f >::FitnessFunctionDatas(const basicAC_F0 & CompletelyNonLinearConstraints = true; Hessian = to< Matrice_Creuse< R > * >(C_F0(opH, "(", theparam, objfact, L_m)); } else if (opH->Find("(", hprototype1)) { - CompletelyNonLinearConstraints = - false; // When constraints are affine, lagrange multipliers are not used in the hessian, - // obj_factor is also hidden to the user + CompletelyNonLinearConstraints = false; // When constraints are affine, lagrange multipliers are not used in the hessian, + // obj_factor is also hidden to the user Hessian = to< Matrice_Creuse< R > * >(C_F0(opH, "(", theparam)); } else { CompileError( @@ -1998,11 +1834,8 @@ FitnessFunctionDatas< no_assumption_f >::FitnessFunctionDatas(const basicAC_F0 & } template<> -void FitnessFunctionDatas< no_assumption_f >::operator( )(Stack stack, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m, - Expression const *nargs, ScalarFunc *&ffJ, - VectorFunc *&ffdJ, SparseMatFunc *&ffH, - bool warned) const { +void FitnessFunctionDatas< no_assumption_f >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { ffJ = new GeneralFunc< R >(stack, JJ, theparam); ffdJ = new GeneralFunc< Rn >(stack, GradJ, theparam); if (CompletelyNonLinearConstraints) { @@ -2013,24 +1846,17 @@ void FitnessFunctionDatas< no_assumption_f >::operator( )(Stack stack, const C_F } template<> -FitnessFunctionDatas< P2_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, - const C_F0 &theparam, const C_F0 &objfact, - const C_F0 &L_m) - : GenericFitnessFunctionDatas( ) { +FitnessFunctionDatas< P2_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { CompletelyNonLinearConstraints = false; - const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), - *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); + const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); JJ = to< R >(C_F0(opJ, "(", theparam)); GradJ = to< Rn_ >(C_F0(opdJ, "(", theparam)); Hessian = to< Matrice_Creuse< R > * >(args[2]); } template<> -void FitnessFunctionDatas< P2_f >::operator( )(Stack stack, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m, - Expression const *nargs, ScalarFunc *&ffJ, - VectorFunc *&ffdJ, SparseMatFunc *&ffH, - bool warned) const { +void FitnessFunctionDatas< P2_f >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { if (warned && nargs[5]) { cout << " ==> your lagrangian hessian is a constant matrix, so there is no need to specify " "its structure with "; @@ -2044,27 +1870,20 @@ void FitnessFunctionDatas< P2_f >::operator( )(Stack stack, const C_F0 &theparam } template<> -FitnessFunctionDatas< unavailable_hessian >::FitnessFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam, - const C_F0 &objfact, - const C_F0 &L_m) +FitnessFunctionDatas< unavailable_hessian >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { CompletelyNonLinearConstraints = false; - const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), - *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); + const Polymorphic *opJ = dynamic_cast< const Polymorphic * >(args[0].LeftValue( )), *opdJ = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); JJ = to< R >(C_F0(opJ, "(", theparam)); GradJ = to< Rn_ >(C_F0(opdJ, "(", theparam)); } template<> -void FitnessFunctionDatas< unavailable_hessian >::operator( )( - Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, - ScalarFunc *&ffJ, VectorFunc *&ffdJ, SparseMatFunc *&ffH, bool warned) const { +void FitnessFunctionDatas< unavailable_hessian >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { if (warned && nargs[5]) { cout << " ==> no hessian has been given, the LBFGS mode has been enabled, thus making "; - cout << OptimIpopt::E_Ipopt::name_param[5].name << " useless. You may also" << endl - << " have forgoten a function (IPOPT will certainly crash if so)." << endl; + cout << OptimIpopt::E_Ipopt::name_param[5].name << " useless. You may also" << endl << " have forgoten a function (IPOPT will certainly crash if so)." << endl; } ffJ = new GeneralFunc< R >(stack, JJ, theparam); @@ -2073,10 +1892,7 @@ void FitnessFunctionDatas< unavailable_hessian >::operator( )( } template<> -FitnessFunctionDatas< mv_P2_f >::FitnessFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m) - : GenericFitnessFunctionDatas( ) { +FitnessFunctionDatas< mv_P2_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { const E_Array *M_b = dynamic_cast< const E_Array * >(args[0].LeftValue( )); if (M_b->nbitem( ) != 2) { @@ -2093,11 +1909,8 @@ FitnessFunctionDatas< mv_P2_f >::FitnessFunctionDatas(const basicAC_F0 &args, } template<> -void FitnessFunctionDatas< mv_P2_f >::operator( )(Stack stack, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m, - Expression const *nargs, ScalarFunc *&ffJ, - VectorFunc *&ffdJ, SparseMatFunc *&ffH, - bool warned) const { +void FitnessFunctionDatas< mv_P2_f >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { if (warned && nargs[5]) { cout << " ==> your lagrangian hessian is a constant matrix, so there is no need to specify " "its structure with "; @@ -2111,20 +1924,14 @@ void FitnessFunctionDatas< mv_P2_f >::operator( )(Stack stack, const C_F0 &thepa } template<> -FitnessFunctionDatas< quadratic_f >::FitnessFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam, const C_F0 &objfact, - const C_F0 &L_m) +FitnessFunctionDatas< quadratic_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { Hessian = to< Matrice_Creuse< R > * >(args[0]); } template<> -void FitnessFunctionDatas< quadratic_f >::operator( )(Stack stack, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m, - Expression const *nargs, ScalarFunc *&ffJ, - VectorFunc *&ffdJ, SparseMatFunc *&ffH, - bool warned) const { +void FitnessFunctionDatas< quadratic_f >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { if (warned && nargs[5]) { cout << " ==> your lagrangian hessian is a constant matrix, so there is no need to specify " "its structure with "; @@ -2138,20 +1945,13 @@ void FitnessFunctionDatas< quadratic_f >::operator( )(Stack stack, const C_F0 &t } template<> -FitnessFunctionDatas< linear_f >::FitnessFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam, const C_F0 &objfact, - const C_F0 &L_m) - : GenericFitnessFunctionDatas( ) { +FitnessFunctionDatas< linear_f >::FitnessFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m) : GenericFitnessFunctionDatas( ) { GradJ = to< Rn * >(args[0]); } template<> -void FitnessFunctionDatas< linear_f >::operator( )(Stack stack, const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &L_m, - Expression const *nargs, ScalarFunc *&ffJ, - VectorFunc *&ffdJ, SparseMatFunc *&ffH, - bool warned) const { +void FitnessFunctionDatas< linear_f >::operator( )(Stack stack, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &L_m, Expression const *nargs, ScalarFunc *&ffJ, VectorFunc *&ffdJ, + SparseMatFunc *&ffH, bool warned) const { if (warned && nargs[5]) { cout << " ==> your lagrangian hessian is a null matrix, so there is no need to specify its " "structure with "; @@ -2165,17 +1965,10 @@ void FitnessFunctionDatas< linear_f >::operator( )(Stack stack, const C_F0 &thep } template<> -ConstraintFunctionDatas< without_constraints >::ConstraintFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) - : GenericConstraintFunctionDatas( ) {} +ConstraintFunctionDatas< without_constraints >::ConstraintFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) : GenericConstraintFunctionDatas( ) {} template<> -void ConstraintFunctionDatas< without_constraints >::operator( )(Stack stack, const C_F0 &theparam, - Expression const *nargs, - VectorFunc *&ffC, - SparseMatFunc *&ffdC, - bool warned) const { +void ConstraintFunctionDatas< without_constraints >::operator( )(Stack stack, const C_F0 &theparam, Expression const *nargs, VectorFunc *&ffC, SparseMatFunc *&ffdC, bool warned) const { if (warned) { if (nargs[2] || nargs[3]) { cout << " ==> Some constraints bounds have been defined while no constraints function has " @@ -2190,9 +1983,7 @@ void ConstraintFunctionDatas< without_constraints >::operator( )(Stack stack, co } if (nargs[6]) { - cout << " ==> Unconstrained problem make the use of " - << OptimIpopt::E_Ipopt::name_param[6].name - << " pointless (see the documentation for more details)." << endl; + cout << " ==> Unconstrained problem make the use of " << OptimIpopt::E_Ipopt::name_param[6].name << " pointless (see the documentation for more details)." << endl; } } @@ -2201,32 +1992,22 @@ void ConstraintFunctionDatas< without_constraints >::operator( )(Stack stack, co } template<> -ConstraintFunctionDatas< no_assumption_g >::ConstraintFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) - : GenericConstraintFunctionDatas( ) { +ConstraintFunctionDatas< no_assumption_g >::ConstraintFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) : GenericConstraintFunctionDatas( ) { int nbj = args.size( ) - 1; - const Polymorphic *opG = dynamic_cast< const Polymorphic * >(args[nbj - 2].LeftValue( )), - *opjG = dynamic_cast< const Polymorphic * >(args[nbj - 1].LeftValue( )); + const Polymorphic *opG = dynamic_cast< const Polymorphic * >(args[nbj - 2].LeftValue( )), *opjG = dynamic_cast< const Polymorphic * >(args[nbj - 1].LeftValue( )); Constraints = to< Rn_ >(C_F0(opG, "(", theparam)); GradConstraints = to< Matrice_Creuse< R > * >(C_F0(opjG, "(", theparam)); } template<> -void ConstraintFunctionDatas< no_assumption_g >::operator( )(Stack stack, const C_F0 &theparam, - Expression const *nargs, - VectorFunc *&ffC, SparseMatFunc *&ffdC, - bool) const { +void ConstraintFunctionDatas< no_assumption_g >::operator( )(Stack stack, const C_F0 &theparam, Expression const *nargs, VectorFunc *&ffC, SparseMatFunc *&ffdC, bool) const { ffC = new GeneralFunc< Rn >(stack, Constraints, theparam); ffdC = new GeneralSparseMatFunc(stack, GradConstraints, theparam); } template<> -ConstraintFunctionDatas< P1_g >::ConstraintFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) - : GenericConstraintFunctionDatas( ) { +ConstraintFunctionDatas< P1_g >::ConstraintFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) : GenericConstraintFunctionDatas( ) { int nbj = args.size( ) - 1; const Polymorphic *opG = dynamic_cast< const Polymorphic * >(args[nbj - 2].LeftValue( )); @@ -2235,9 +2016,7 @@ ConstraintFunctionDatas< P1_g >::ConstraintFunctionDatas(const basicAC_F0 &args, } template<> -void ConstraintFunctionDatas< P1_g >::operator( )(Stack stack, const C_F0 &theparam, - Expression const *nargs, VectorFunc *&ffC, - SparseMatFunc *&ffdC, bool warned) const { +void ConstraintFunctionDatas< P1_g >::operator( )(Stack stack, const C_F0 &theparam, Expression const *nargs, VectorFunc *&ffC, SparseMatFunc *&ffdC, bool warned) const { if (warned && nargs[4]) { cout << " ==> your constraints jacobian is a constant matrix, there is no need to specify its " "structure with " @@ -2250,10 +2029,7 @@ void ConstraintFunctionDatas< P1_g >::operator( )(Stack stack, const C_F0 &thepa } template<> -ConstraintFunctionDatas< mv_P1_g >::ConstraintFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) - : GenericConstraintFunctionDatas( ) { +ConstraintFunctionDatas< mv_P1_g >::ConstraintFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) : GenericConstraintFunctionDatas( ) { int nbj = args.size( ) - 1; const E_Array *M_b = dynamic_cast< const E_Array * >(args[nbj - 1].LeftValue( )); @@ -2275,9 +2051,7 @@ ConstraintFunctionDatas< mv_P1_g >::ConstraintFunctionDatas(const basicAC_F0 &ar } template<> -void ConstraintFunctionDatas< mv_P1_g >::operator( )(Stack stack, const C_F0 &theparam, - Expression const *nargs, VectorFunc *&ffC, - SparseMatFunc *&ffdC, bool warned) const { +void ConstraintFunctionDatas< mv_P1_g >::operator( )(Stack stack, const C_F0 &theparam, Expression const *nargs, VectorFunc *&ffC, SparseMatFunc *&ffdC, bool warned) const { if (warned && nargs[4]) { cout << " ==> your constraints jacobian is a constant matrix, there is no need to specify its " "structure with " @@ -2290,19 +2064,14 @@ void ConstraintFunctionDatas< mv_P1_g >::operator( )(Stack stack, const C_F0 &th } template<> -ConstraintFunctionDatas< linear_g >::ConstraintFunctionDatas(const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) - : GenericConstraintFunctionDatas( ) { +ConstraintFunctionDatas< linear_g >::ConstraintFunctionDatas(const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) : GenericConstraintFunctionDatas( ) { int nbj = args.size( ) - 1; GradConstraints = to< Matrice_Creuse< R > * >(args[nbj - 1]); } template<> -void ConstraintFunctionDatas< linear_g >::operator( )(Stack stack, const C_F0 &theparam, - Expression const *nargs, VectorFunc *&ffC, - SparseMatFunc *&ffdC, bool warned) const { +void ConstraintFunctionDatas< linear_g >::operator( )(Stack stack, const C_F0 &theparam, Expression const *nargs, VectorFunc *&ffC, SparseMatFunc *&ffdC, bool warned) const { if (warned && nargs[4]) { cout << " ==> your constraints jacobian is a constant matrix, there is no need to specify its " "structure with " @@ -2314,11 +2083,7 @@ void ConstraintFunctionDatas< linear_g >::operator( )(Stack stack, const C_F0 &t ffdC = new ConstantSparseMatFunc(stack, GradConstraints); } -GenericFitnessFunctionDatas *GenericFitnessFunctionDatas::New(AssumptionF AF, - const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam, - const C_F0 &objfact, const C_F0 &lm) { +GenericFitnessFunctionDatas *GenericFitnessFunctionDatas::New(AssumptionF AF, const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam, const C_F0 &objfact, const C_F0 &lm) { switch (AF) { case no_assumption_f: return new FitnessFunctionDatas< no_assumption_f >(args, nargs, theparam, objfact, lm); @@ -2344,10 +2109,7 @@ GenericFitnessFunctionDatas *GenericFitnessFunctionDatas::New(AssumptionF AF, } } -GenericConstraintFunctionDatas *GenericConstraintFunctionDatas::New(AssumptionG AG, - const basicAC_F0 &args, - Expression const *nargs, - const C_F0 &theparam) { +GenericConstraintFunctionDatas *GenericConstraintFunctionDatas::New(AssumptionG AG, const basicAC_F0 &args, Expression const *nargs, const C_F0 &theparam) { switch (AG) { case no_assumption_g: return new ConstraintFunctionDatas< no_assumption_g >(args, nargs, theparam); diff --git a/plugin/seq/ff-NLopt.cpp b/plugin/seq/ff-NLopt.cpp index 9bd3facc2..beef0e3e1 100644 --- a/plugin/seq/ff-NLopt.cpp +++ b/plugin/seq/ff-NLopt.cpp @@ -175,16 +175,13 @@ const char *Info< nlopt::GN_DIRECT_L_RAND >::name = "Randomized Locally Biased D template<> const char *Info< nlopt::GN_DIRECT_NOSCAL >::name = "Dividing Rectangles (no scaling)"; template<> -const char *Info< nlopt::GN_DIRECT_L_NOSCAL >::name = - "Locally Biased Dividing Rectangles (no scaling)"; +const char *Info< nlopt::GN_DIRECT_L_NOSCAL >::name = "Locally Biased Dividing Rectangles (no scaling)"; template<> -const char *Info< nlopt::GN_DIRECT_L_RAND_NOSCAL >::name = - "Randomized Locally Biased Dividing Rectangles (no scaling)"; +const char *Info< nlopt::GN_DIRECT_L_RAND_NOSCAL >::name = "Randomized Locally Biased Dividing Rectangles (no scaling)"; template<> const char *Info< nlopt::GN_ORIG_DIRECT >::name = "Original Glabonsky's Dividing Rectangles"; template<> -const char *Info< nlopt::GN_ORIG_DIRECT_L >::name = - "Original Glabonsky's Locally Biased Dividing Rectangles"; +const char *Info< nlopt::GN_ORIG_DIRECT_L >::name = "Original Glabonsky's Locally Biased Dividing Rectangles"; const char *Info< nlopt::GD_STOGO >::name = "StoGO"; const char *Info< nlopt::GD_STOGO_RAND >::name = "Randomized StoGO"; const char *Info< nlopt::LD_LBFGS_NOCEDAL >::name = "Nocedal's Low-Storage BFGS"; @@ -194,20 +191,15 @@ const char *Info< nlopt::LN_PRAXIS >::name = "Principal Axis"; const char *Info< nlopt::LD_VAR1 >::name = "Rank-1 Shifted Limited Memory Variable Metric"; const char *Info< nlopt::LD_VAR2 >::name = "Rank-2 Shifted Limited Memory Variable Metric"; const char *Info< nlopt::LD_TNEWTON >::name = "Truncated Newton"; -const char *Info< nlopt::LD_TNEWTON_RESTART >::name = - "Steepest Descent Restarting Truncated Newton"; +const char *Info< nlopt::LD_TNEWTON_RESTART >::name = "Steepest Descent Restarting Truncated Newton"; const char *Info< nlopt::LD_TNEWTON_PRECOND >::name = "BFGS Preconditionned Truncated Newton"; -const char *Info< nlopt::LD_TNEWTON_PRECOND_RESTART >::name = - "BFGS Precondionned Truncated Newton with Steepest Descent Resrtarting"; +const char *Info< nlopt::LD_TNEWTON_PRECOND_RESTART >::name = "BFGS Precondionned Truncated Newton with Steepest Descent Resrtarting"; template<> const char *Info< nlopt::GN_CRS2_LM >::name = "Controlled Random Search with Local Mutation"; const char *Info< nlopt::GN_MLSL >::name = "Multi-Level Single-Linkage (derivative free)"; -const char *Info< nlopt::GD_MLSL >::name = - "Multi-Level Single-Linkage (with gradient-based local search)"; -const char *Info< nlopt::GN_MLSL_LDS >::name = - "Low Discrepancy Sequence Multi-Level Single-Linkage (derivative free)"; -const char *Info< nlopt::GD_MLSL_LDS >::name = - "Low Discrepancy Sequence Multi-Level Single-Linkage (with gradient-based local search)"; +const char *Info< nlopt::GD_MLSL >::name = "Multi-Level Single-Linkage (with gradient-based local search)"; +const char *Info< nlopt::GN_MLSL_LDS >::name = "Low Discrepancy Sequence Multi-Level Single-Linkage (derivative free)"; +const char *Info< nlopt::GD_MLSL_LDS >::name = "Low Discrepancy Sequence Multi-Level Single-Linkage (with gradient-based local search)"; const char *Info< nlopt::LD_MMA >::name = "Method of Moving Asymptotes"; template<> const char *Info< nlopt::LN_COBYLA >::name = "Constrained Optimization by Linear Approximations"; @@ -219,14 +211,10 @@ template<> const char *Info< nlopt::LN_NELDERMEAD >::name = "Nelder-Mead Simplex"; template<> const char *Info< nlopt::LN_SBPLX >::name = "Subplex"; -const char *Info< nlopt::LN_AUGLAG >::name = - "Inequality/Equality Constraints Augmented Lagrangian (derivative free)"; -const char *Info< nlopt::LD_AUGLAG >::name = - "Inequality/Equality Constraints Augmented Lagrangian (with gradient-based subsidiary search)"; -const char *Info< nlopt::LN_AUGLAG_EQ >::name = - "Equality Constraints Augmented Lagrangian (derivative free)"; -const char *Info< nlopt::LD_AUGLAG_EQ >::name = - "Equality Constraints Augmented Lagrangian (with gradient-based subsidiary search)"; +const char *Info< nlopt::LN_AUGLAG >::name = "Inequality/Equality Constraints Augmented Lagrangian (derivative free)"; +const char *Info< nlopt::LD_AUGLAG >::name = "Inequality/Equality Constraints Augmented Lagrangian (with gradient-based subsidiary search)"; +const char *Info< nlopt::LN_AUGLAG_EQ >::name = "Equality Constraints Augmented Lagrangian (derivative free)"; +const char *Info< nlopt::LD_AUGLAG_EQ >::name = "Equality Constraints Augmented Lagrangian (with gradient-based subsidiary search)"; template<> const char *Info< nlopt::LN_BOBYQA >::name = "BOBYQA"; template<> @@ -288,13 +276,11 @@ typedef ffcalfunc< Rnm > *MatrixFunc; class GenericOptimizer { public: GenericOptimizer(nlopt::algorithm ALGO, int dim = 0) - : opt(ALGO, dim), x(0), econsttol(0), iconsttol(0), econstrained(false), iconstrained(false), - fit(0), d_fit(0), equaconst(0), d_equaconst(0), ineqconst(0), d_ineqconst(0), subopt(0) {} + : opt(ALGO, dim), x(0), econsttol(0), iconsttol(0), econstrained(false), iconstrained(false), fit(0), d_fit(0), equaconst(0), d_equaconst(0), ineqconst(0), d_ineqconst(0), subopt(0) {} GenericOptimizer(nlopt::algorithm ALGO, const ffcalfunc< R > &_ff, Rn &xstart) - : opt(ALGO, xstart.n), x(&xstart), econsttol(0), iconsttol(0), econstrained(false), - iconstrained(false), fit(new ffcalfunc< R >(_ff)), d_fit(0), equaconst(0), d_equaconst(0), - ineqconst(0), d_ineqconst(0), subopt(0) { + : opt(ALGO, xstart.n), x(&xstart), econsttol(0), iconsttol(0), econstrained(false), iconstrained(false), fit(new ffcalfunc< R >(_ff)), d_fit(0), equaconst(0), d_equaconst(0), ineqconst(0), + d_ineqconst(0), subopt(0) { opt.set_min_objective(NLoptFunc, static_cast< void * >(this)); } @@ -459,8 +445,7 @@ class GenericOptimizer { return *this; } - static double NLoptFunc(const std::vector< double > &xx, std::vector< double > &grad, - void *data) { + static double NLoptFunc(const std::vector< double > &xx, std::vector< double > &grad, void *data) { GenericOptimizer *pthis = static_cast< GenericOptimizer * >(data); int n = xx.size( ); Rn X(n); @@ -480,8 +465,7 @@ class GenericOptimizer { return pthis->fit->J(X); } - static void NLoptECDF(unsigned m, double *result, unsigned n, const double *xx, double *grad, - void *data) { + static void NLoptECDF(unsigned m, double *result, unsigned n, const double *xx, double *grad, void *data) { GenericOptimizer *pthis = static_cast< GenericOptimizer * >(data); if (pthis->equaconst) { @@ -521,8 +505,7 @@ class GenericOptimizer { } } - static void NLoptICDF(unsigned m, double *result, unsigned n, const double *xx, double *grad, - void *data) { + static void NLoptICDF(unsigned m, double *result, unsigned n, const double *xx, double *grad, void *data) { GenericOptimizer *pthis = static_cast< GenericOptimizer * >(data); if (pthis->ineqconst) { @@ -616,14 +599,9 @@ struct MyCheck< false > { template< nlopt::algorithm ALGO > class SAOptimizer : public GenericOptimizer { public: - SAOptimizer(int dim = 0) : GenericOptimizer(ALGO, dim), subopt(0) { - MyCheck< Info< ALGO >::SA >( ); - } + SAOptimizer(int dim = 0) : GenericOptimizer(ALGO, dim), subopt(0) { MyCheck< Info< ALGO >::SA >( ); } - SAOptimizer(const ffcalfunc< R > &_ff, Rn &xstart) - : GenericOptimizer(ALGO, _ff, xstart), subopt(0) { - MyCheck< Info< ALGO >::SA >( ); - } + SAOptimizer(const ffcalfunc< R > &_ff, Rn &xstart) : GenericOptimizer(ALGO, _ff, xstart), subopt(0) { MyCheck< Info< ALGO >::SA >( ); } ~SAOptimizer( ) { if (subopt) { @@ -777,8 +755,7 @@ GenericOptimizer &SAOptimizer< ALGO >::SetSubOptimizer(const string &name, bool } else if (name == "SLSQP") { subopt = new Optimizer< nlopt::LD_SLSQP >(x->n); } else { - cout << "Warning: unknown or unauthorized optimizer name passed as sub algorithm to " - << Info< ALGO >::name << endl; + cout << "Warning: unknown or unauthorized optimizer name passed as sub algorithm to " << Info< ALGO >::name << endl; } } @@ -804,15 +781,11 @@ class OptimNLopt : public OneOperator { C_F0 inittheparam, theparam, closetheparam; Expression JJ; Expression GradJ, EIConst, EGradIConst, EEConst, EGradEConst; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } - Rn_ arg(int i, Stack stack, Rn_ a) const { - return nargs[i] ? GetAny< Rn_ >((*nargs[2])(stack)) : a; - } + Rn_ arg(int i, Stack stack, Rn_ a) const { return nargs[i] ? GetAny< Rn_ >((*nargs[2])(stack)) : a; } template< typename T > T Arg(int i, Stack s) const { @@ -826,8 +799,7 @@ class OptimNLopt : public OneOperator { X = to< Rn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -837,10 +809,8 @@ class OptimNLopt : public OneOperator { } JJ = to< R >(C_F0(opJ, "(", theparam)); - const Polymorphic *gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, - *iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, - *gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, - *econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, + const Polymorphic *gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, *iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, + *gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, *econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, *gradeconst = nargs[4] ? dynamic_cast< const Polymorphic * >(nargs[4]) : 0; if (gradient) { GradJ = to< Rn_ >(C_F0(gradient, "(", theparam)); @@ -872,10 +842,8 @@ class OptimNLopt : public OneOperator { WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 Rn &x = *GetAny< Rn * >((*X)(stack)); long n = x.N( ); - const bool gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, - iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, - gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, - econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, + const bool gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, + gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, gradeconst = nargs[4] ? dynamic_cast< const Polymorphic * >(nargs[4]) : 0; long iprint = verbosity; ffcalfunc< double > ffJ(stack, JJ, theparam); @@ -937,8 +905,7 @@ class OptimNLopt : public OneOperator { "derivative free context)." << endl; } else if (ALGO == nlopt::LD_SLSQP || ALGO == nlopt::LD_MMA) { - cout << "Warning: nGradStored can't be used with " << optim.Name( ) - << ", parameter will be ignored." << endl; + cout << "Warning: nGradStored can't be used with " << optim.Name( ) << ", parameter will be ignored." << endl; } } @@ -952,10 +919,7 @@ class OptimNLopt : public OneOperator { if (optim.DF( )) { if (gradient) { - cout - << "Warning: in " << optim.Name( ) - << " algorithm - derivative free algorithm will ignore the objective function gradient." - << endl; + cout << "Warning: in " << optim.Name( ) << " algorithm - derivative free algorithm will ignore the objective function gradient." << endl; } if (gradiconst) { @@ -995,8 +959,7 @@ class OptimNLopt : public OneOperator { if (gradeconst) { optim.SetEqualityConstraintGradient(ffcalfunc< Rnm >(stack, EGradEConst, theparam)); } else { - cout << "Warning: in " << optim.Name( ) - << " algorithm - no equality constraints gradients has been provided." << endl; + cout << "Warning: in " << optim.Name( ) << " algorithm - no equality constraints gradients has been provided." << endl; } } else if (gradeconst) { cout << "Warning: in " << optim.Name( ) @@ -1009,8 +972,7 @@ class OptimNLopt : public OneOperator { if (gradiconst) { optim.SetInequalityConstraintGradient(ffcalfunc< Rnm >(stack, EGradIConst, theparam)); } else { - cout << "Warning: in " << optim.Name( ) - << " algorithm - no inequality constraints gradients has been provided." << endl; + cout << "Warning: in " << optim.Name( ) << " algorithm - no inequality constraints gradients has been provided." << endl; } } else if (gradiconst) { cout << "Warning: in " << optim.Name( ) @@ -1056,30 +1018,15 @@ class OptimNLopt : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_NLopt(args, cas); } - OptimNLopt(int c) - : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + OptimNLopt(int c) : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; template< nlopt::algorithm ALGO, bool SA > basicAC_F0::name_and_type OptimNLopt< ALGO, SA >::E_NLopt::name_param[] = { - {"grad", &typeid(Polymorphic *)}, - {"IConst", &typeid(Polymorphic *)}, - {"gradIConst", &typeid(Polymorphic *)}, - {"EConst", &typeid(Polymorphic *)}, - {"gradEConst", &typeid(Polymorphic *)}, - {"lb", &typeid(KN_< double >)}, - {"ub", &typeid(KN_< double >)}, - {"stopFuncValue", &typeid(double)}, - {"tolEConst", &typeid(KN_< double >)}, - {"stopRelXTol", &typeid(double)}, - {"stopAbsXTol", &typeid(KN_< double >)}, - {"stopRelFTol", &typeid(double)}, - {"stopAbsFTol", &typeid(double)}, - {"stopMaxFEval", &typeid(long)}, - {"stopTime", &typeid(double)}, - {"tolIConst", &typeid(KN_< double >)}, - {"popSize", &typeid(long)}, - {"nGradStored", &typeid(long)}}; + {"grad", &typeid(Polymorphic *)}, {"IConst", &typeid(Polymorphic *)}, {"gradIConst", &typeid(Polymorphic *)}, {"EConst", &typeid(Polymorphic *)}, {"gradEConst", &typeid(Polymorphic *)}, + {"lb", &typeid(KN_< double >)}, {"ub", &typeid(KN_< double >)}, {"stopFuncValue", &typeid(double)}, {"tolEConst", &typeid(KN_< double >)}, {"stopRelXTol", &typeid(double)}, + {"stopAbsXTol", &typeid(KN_< double >)}, {"stopRelFTol", &typeid(double)}, {"stopAbsFTol", &typeid(double)}, {"stopMaxFEval", &typeid(long)}, {"stopTime", &typeid(double)}, + {"tolIConst", &typeid(KN_< double >)}, {"popSize", &typeid(long)}, {"nGradStored", &typeid(long)}}; template< nlopt::algorithm ALGO > class OptimNLopt< ALGO, true > : public OneOperator { @@ -1096,15 +1043,11 @@ class OptimNLopt< ALGO, true > : public OneOperator { C_F0 inittheparam, theparam, closetheparam; Expression JJ; Expression GradJ, EIConst, EGradIConst, EEConst, EGradEConst; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } - Rn_ arg(int i, Stack stack, Rn_ a) const { - return nargs[i] ? GetAny< Rn_ >((*nargs[2])(stack)) : a; - } + Rn_ arg(int i, Stack stack, Rn_ a) const { return nargs[i] ? GetAny< Rn_ >((*nargs[2])(stack)) : a; } template< typename T > T Arg(int i, Stack s) const { @@ -1118,8 +1061,7 @@ class OptimNLopt< ALGO, true > : public OneOperator { X = to< Rn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -1129,10 +1071,8 @@ class OptimNLopt< ALGO, true > : public OneOperator { } JJ = to< R >(C_F0(opJ, "(", theparam)); - const Polymorphic *gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, - *iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, - *gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, - *econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, + const Polymorphic *gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, *iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, + *gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, *econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, *gradeconst = nargs[4] ? dynamic_cast< const Polymorphic * >(nargs[4]) : 0; if (gradient) { GradJ = to< Rn_ >(C_F0(gradient, "(", theparam)); @@ -1163,10 +1103,8 @@ class OptimNLopt< ALGO, true > : public OneOperator { WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 Rn &x = *GetAny< Rn * >((*X)(stack)); long n = x.N( ); - const bool gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, - iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, - gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, - econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, + const bool gradient = nargs[0] ? dynamic_cast< const Polymorphic * >(nargs[0]) : 0, iconst = nargs[1] ? dynamic_cast< const Polymorphic * >(nargs[1]) : 0, + gradiconst = nargs[2] ? dynamic_cast< const Polymorphic * >(nargs[2]) : 0, econst = nargs[3] ? dynamic_cast< const Polymorphic * >(nargs[3]) : 0, gradeconst = nargs[4] ? dynamic_cast< const Polymorphic * >(nargs[4]) : 0; long iprint = verbosity; ffcalfunc< double > ffJ(stack, JJ, theparam); @@ -1268,10 +1206,8 @@ class OptimNLopt< ALGO, true > : public OneOperator { << " algorithm - using nGradStored is pointless (no gradient to store in a " "derivative free context)." << endl; - } else if (optim.subopt->Tag( ) == nlopt::LD_SLSQP || - optim.subopt->Tag( ) == nlopt::LD_MMA) { - cout << "Warning: nGradStored can't be used with " << optim.Name( ) - << ", parameter will be ignored." << endl; + } else if (optim.subopt->Tag( ) == nlopt::LD_SLSQP || optim.subopt->Tag( ) == nlopt::LD_MMA) { + cout << "Warning: nGradStored can't be used with " << optim.Name( ) << ", parameter will be ignored." << endl; } } @@ -1331,8 +1267,7 @@ class OptimNLopt< ALGO, true > : public OneOperator { if (gradeconst) { optim.SetEqualityConstraintGradient(ffcalfunc< Rnm >(stack, EGradEConst, theparam)); } else { - cout << "Warning: in " << optim.Name( ) - << " algorithm - no equality constraints gradients has been provided." << endl; + cout << "Warning: in " << optim.Name( ) << " algorithm - no equality constraints gradients has been provided." << endl; } } else if (gradeconst) { cout << "Warning: in " << optim.Name( ) @@ -1345,8 +1280,7 @@ class OptimNLopt< ALGO, true > : public OneOperator { if (gradiconst) { optim.SetInequalityConstraintGradient(ffcalfunc< Rnm >(stack, EGradIConst, theparam)); } else { - cout << "Warning: in " << optim.Name( ) - << " algorithm - no inequality constraints gradients has been provided." << endl; + cout << "Warning: in " << optim.Name( ) << " algorithm - no inequality constraints gradients has been provided." << endl; } } else if (gradiconst) { cout << "Warning: in " << optim.Name( ) @@ -1393,39 +1327,37 @@ class OptimNLopt< ALGO, true > : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_NLopt(args, cas); } - OptimNLopt(int c) - : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + OptimNLopt(int c) : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; template< nlopt::algorithm ALGO > -basicAC_F0::name_and_type OptimNLopt< ALGO, true >::E_NLopt::name_param[] = { - {"grad", &typeid(Polymorphic *)}, - {"IConst", &typeid(Polymorphic *)}, - {"gradIConst", &typeid(Polymorphic *)}, - {"EConst", &typeid(Polymorphic *)}, - {"gradEConst", &typeid(Polymorphic *)}, - {"lb", &typeid(KN_< double >)}, - {"ub", &typeid(KN_< double >)}, - {"stopFuncValue", &typeid(double)}, - {"tolEConst", &typeid(KN_< double >)}, - {"stopRelXTol", &typeid(double)}, - {"stopAbsXTol", &typeid(KN_< double >)}, - {"stopRelFTol", &typeid(double)}, - {"stopAbsFTol", &typeid(double)}, - {"stopMaxFEval", &typeid(long)}, - {"stopTime", &typeid(double)}, - {"tolIConst", &typeid(KN_< double >)}, - {"popSize", &typeid(long)}, // 16 - {"subOpt", &typeid(string *)}, - {"SOStopFuncValue", &typeid(double)}, - {"SOStopRelXTol", &typeid(double)}, - {"SOStopAbsXTol", &typeid(KN_< double >)}, - {"SOStopRelFTol", &typeid(double)}, - {"SOStopAbsFTol", &typeid(double)}, - {"SOStopMaxFEval", &typeid(long)}, - {"SOStopTime", &typeid(double)}, - {"SOPopSize", &typeid(long)}, - {"nGradStored", &typeid(long)}}; +basicAC_F0::name_and_type OptimNLopt< ALGO, true >::E_NLopt::name_param[] = {{"grad", &typeid(Polymorphic *)}, + {"IConst", &typeid(Polymorphic *)}, + {"gradIConst", &typeid(Polymorphic *)}, + {"EConst", &typeid(Polymorphic *)}, + {"gradEConst", &typeid(Polymorphic *)}, + {"lb", &typeid(KN_< double >)}, + {"ub", &typeid(KN_< double >)}, + {"stopFuncValue", &typeid(double)}, + {"tolEConst", &typeid(KN_< double >)}, + {"stopRelXTol", &typeid(double)}, + {"stopAbsXTol", &typeid(KN_< double >)}, + {"stopRelFTol", &typeid(double)}, + {"stopAbsFTol", &typeid(double)}, + {"stopMaxFEval", &typeid(long)}, + {"stopTime", &typeid(double)}, + {"tolIConst", &typeid(KN_< double >)}, + {"popSize", &typeid(long)}, // 16 + {"subOpt", &typeid(string *)}, + {"SOStopFuncValue", &typeid(double)}, + {"SOStopRelXTol", &typeid(double)}, + {"SOStopAbsXTol", &typeid(KN_< double >)}, + {"SOStopRelFTol", &typeid(double)}, + {"SOStopAbsFTol", &typeid(double)}, + {"SOStopMaxFEval", &typeid(long)}, + {"SOStopTime", &typeid(double)}, + {"SOPopSize", &typeid(long)}, + {"nGradStored", &typeid(long)}}; /* class Init { public: * Init(); @@ -1454,8 +1386,7 @@ static void Load_Init( ) { Global.Add("nloptTNewton", "(", new OptimNLopt< nlopt::LD_TNEWTON >(1)); Global.Add("nloptTNewtonRestart", "(", new OptimNLopt< nlopt::LD_TNEWTON_RESTART >(1)); Global.Add("nloptTNewtonPrecond", "(", new OptimNLopt< nlopt::LD_TNEWTON_PRECOND >(1)); - Global.Add("nloptTNewtonPrecondRestart", "(", - new OptimNLopt< nlopt::LD_TNEWTON_PRECOND_RESTART >(1)); + Global.Add("nloptTNewtonPrecondRestart", "(", new OptimNLopt< nlopt::LD_TNEWTON_PRECOND_RESTART >(1)); Global.Add("nloptCRS2", "(", new OptimNLopt< nlopt::GN_CRS2_LM >(1)); Global.Add("nloptMMA", "(", new OptimNLopt< nlopt::LD_MMA >(1)); Global.Add("nloptCOBYLA", "(", new OptimNLopt< nlopt::LN_COBYLA >(1)); diff --git a/plugin/seq/ff-cmaes.cpp b/plugin/seq/ff-cmaes.cpp index 7f5ec1fec..7f054416e 100644 --- a/plugin/seq/ff-cmaes.cpp +++ b/plugin/seq/ff-cmaes.cpp @@ -44,9 +44,7 @@ class CMAES // Abstract class, because the fitness function prototype may dif // typedef double (*FFT)(double const *); //Fitness Function Type CMAES( ) : pop(0), fitvals(0), evo( ) {} - CMAES(int d, double *xstart, double *stddev, long seed, int lambda, - const char *ipf = "initials.par") - : pop(0), fitvals(0), evo( ) { + CMAES(int d, double *xstart, double *stddev, long seed, int lambda, const char *ipf = "initials.par") : pop(0), fitvals(0), evo( ) { fitvals = init(d, xstart, stddev, seed, lambda, ipf); cout << SayHello( ) << endl; } @@ -69,27 +67,19 @@ class CMAES // Abstract class, because the fitness function prototype may dif virtual void PopEval( ) = 0; - double axisratio( ) const { - return cmaes_Get(&evo, "axisratio"); - } // between lengths of longest and shortest principal axis of the distribution ellipsoid + double axisratio( ) const { return cmaes_Get(&evo, "axisratio"); } // between lengths of longest and shortest principal axis of the distribution ellipsoid int eval( ) const { return floor(cmaes_Get(&evo, "eval")); } // number of function evaluations - double fitness( ) const { - return cmaes_Get(&evo, "fitness"); - } // recent best function evaluation + double fitness( ) const { return cmaes_Get(&evo, "fitness"); } // recent best function evaluation double fbestever( ) const { return cmaes_Get(&evo, "fbestever"); } // ever best function value int generation( ) const { return floor(cmaes_Get(&evo, "generation")); } - int maxeval( ) const { - return floor(cmaes_Get(&evo, "maxeval")); - } // maximal number of function evaluations + int maxeval( ) const { return floor(cmaes_Get(&evo, "maxeval")); } // maximal number of function evaluations - int maxgen( ) const { - return floor(cmaes_Get(&evo, "maxgen")); - } // maximal number of generations + int maxgen( ) const { return floor(cmaes_Get(&evo, "maxgen")); } // maximal number of generations double maxaxislength( ) const { return cmaes_Get(&evo, "maxaxislength"); } @@ -121,9 +111,7 @@ class CMAES // Abstract class, because the fitness function prototype may dif char *SayHello( ) const { return cmaes_SayHello(&evo); } - void WriteToFile(char const *keyword, char const *output_filename) const { - cmaes_WriteToFile(&evo, keyword, output_filename); - } + void WriteToFile(char const *keyword, char const *output_filename) const { cmaes_WriteToFile(&evo, keyword, output_filename); } virtual double *operator( )( ) { // ReadSignals("signals.par"); @@ -147,10 +135,8 @@ class CMAES // Abstract class, because the fitness function prototype may dif private: void exit( ) { cmaes_exit(&evo); } - double *&init(int dimension, double *xstart, double *stddev, long seed, int lambda, - const char *input_parameter_filename) { - return fitvals = - cmaes_init(&evo, dimension, xstart, stddev, seed, lambda, input_parameter_filename); + double *&init(int dimension, double *xstart, double *stddev, long seed, int lambda, const char *input_parameter_filename) { + return fitvals = cmaes_init(&evo, dimension, xstart, stddev, seed, lambda, input_parameter_filename); } mutable cmaes_t evo; @@ -198,11 +184,9 @@ class OptimCMA_ES : public OneOperator { * : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {} * CMA_ES(ffcalfunc &_ff,int d,Rn &xstart,const Rn &stddev,long seed,int lambda) * : CMAES(d,xstart.n ? xstart:0,stddev,seed,lambda,"non"),x(&xstart),fit(&_ff) {}*/ - CMA_ES(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda) - : CMAES(xstart.n, xstart, stddev, seed, lambda, "non"), x(&xstart), fit(&_ff) {} + CMA_ES(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda) : CMAES(xstart.n, xstart, stddev, seed, lambda, "non"), x(&xstart), fit(&_ff) {} - CMA_ES(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda, const string &ipf) - : CMAES(xstart.n, xstart, stddev, seed, lambda, ipf.c_str( )), x(&xstart), fit(&_ff) {} + CMA_ES(ffcalfunc &_ff, Rn &xstart, const Rn &stddev, long seed, int lambda, const string &ipf) : CMAES(xstart.n, xstart, stddev, seed, lambda, ipf.c_str( )), x(&xstart), fit(&_ff) {} void PopEval( ) { for (int i = 0; i < popsize( ); ++i) { @@ -227,9 +211,7 @@ class OptimCMA_ES : public OneOperator { Expression X; C_F0 inittheparam, theparam, closetheparam; Expression JJ; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } @@ -240,8 +222,7 @@ class OptimCMA_ES : public OneOperator { X = to< Kn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -265,8 +246,7 @@ class OptimCMA_ES : public OneOperator { double initialStdDev = arg(1, stack, 0.3); // Initial standard deviation KN< double > iSD(n, 1.); iSD *= initialStdDev; - KN< double > initialStdDevs(nargs[2] ? GetAny< KN_< double > >((*nargs[2])(stack)) - : (KN_< double >)iSD); + KN< double > initialStdDevs(nargs[2] ? GetAny< KN_< double > >((*nargs[2])(stack)) : (KN_< double >)iSD); double stopTolFun = arg(3, stack, 1.E-12); double stopTolFunHist = arg(4, stack, 0.); double stopTolX = arg(5, stack, 0.); @@ -312,22 +292,20 @@ class OptimCMA_ES : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_CMA_ES(args, cas); } - OptimCMA_ES(int c) - : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + OptimCMA_ES(int c) : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; -basicAC_F0::name_and_type OptimCMA_ES::E_CMA_ES::name_param[] = { - {"seed", &typeid(long)}, - {"initialStdDev", &typeid(double)}, - {"initialStdDevs", &typeid(KN_< double >)}, - {"stopTolFun", &typeid(double)}, - {"stopTolFunHist", &typeid(double)}, - {"stopTolX", &typeid(double)}, - {"stopTolUpXFactor", &typeid(double)}, - {"popsize", &typeid(long)}, - {"stopMaxFunEval", &typeid(long)}, - {"stopMaxIter", &typeid(long)}, - {"paramFile", &typeid(string *)}}; +basicAC_F0::name_and_type OptimCMA_ES::E_CMA_ES::name_param[] = {{"seed", &typeid(long)}, + {"initialStdDev", &typeid(double)}, + {"initialStdDevs", &typeid(KN_< double >)}, + {"stopTolFun", &typeid(double)}, + {"stopTolFunHist", &typeid(double)}, + {"stopTolX", &typeid(double)}, + {"stopTolUpXFactor", &typeid(double)}, + {"popsize", &typeid(long)}, + {"stopMaxFunEval", &typeid(long)}, + {"stopMaxIter", &typeid(long)}, + {"paramFile", &typeid(string *)}}; static void Load_Init( ) { Global.Add("cmaes", "(", new OptimCMA_ES(1)); } diff --git a/plugin/seq/ff-mmap-semaphore.cpp b/plugin/seq/ff-mmap-semaphore.cpp index de4426fb8..924b97ba5 100644 --- a/plugin/seq/ff-mmap-semaphore.cpp +++ b/plugin/seq/ff-mmap-semaphore.cpp @@ -98,9 +98,7 @@ long Read(pFF_p_mmap const &map, const long &offset, T *const &pt) { return ffmmap_read(map->map, (void *)pt, sizeof(T), offset); } -long ff_msync(pFF_p_mmap const &map, long const &len, long const &off) { - return ffmmap_msync(map->map, off, len); -} +long ff_msync(pFF_p_mmap const &map, long const &len, long const &off) { return ffmmap_msync(map->map, off, len); } long ff_msync(pFF_p_mmap const &map) { return ffmmap_msync(map->map, 0, 0); } diff --git a/plugin/seq/ff_gsl_awk.hpp b/plugin/seq/ff_gsl_awk.hpp index fd2b18a6f..16c249f47 100644 --- a/plugin/seq/ff_gsl_awk.hpp +++ b/plugin/seq/ff_gsl_awk.hpp @@ -405,665 +405,349 @@ double gsl_cdf_ugaussian_Pinv__(double const &x) { return gsl_cdf_ugaussian_Pinv double gsl_cdf_ugaussian_Qinv__(double const &x) { return gsl_cdf_ugaussian_Qinv((const double)x); } -double gsl_cdf_gaussian_P__(double const &x, double const &y) { - return gsl_cdf_gaussian_P((const double)x, (const double)y); -} +double gsl_cdf_gaussian_P__(double const &x, double const &y) { return gsl_cdf_gaussian_P((const double)x, (const double)y); } -double gsl_cdf_gaussian_Q__(double const &x, double const &y) { - return gsl_cdf_gaussian_Q((const double)x, (const double)y); -} +double gsl_cdf_gaussian_Q__(double const &x, double const &y) { return gsl_cdf_gaussian_Q((const double)x, (const double)y); } -double gsl_cdf_gaussian_Pinv__(double const &x, double const &y) { - return gsl_cdf_gaussian_Pinv((const double)x, (const double)y); -} +double gsl_cdf_gaussian_Pinv__(double const &x, double const &y) { return gsl_cdf_gaussian_Pinv((const double)x, (const double)y); } -double gsl_cdf_gaussian_Qinv__(double const &x, double const &y) { - return gsl_cdf_gaussian_Qinv((const double)x, (const double)y); -} +double gsl_cdf_gaussian_Qinv__(double const &x, double const &y) { return gsl_cdf_gaussian_Qinv((const double)x, (const double)y); } -double gsl_cdf_gamma_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_gamma_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gamma_P__(double const &x, double const &y, double const &z) { return gsl_cdf_gamma_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gamma_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_gamma_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gamma_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_gamma_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gamma_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gamma_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gamma_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gamma_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gamma_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gamma_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gamma_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gamma_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_cauchy_P__(double const &x, double const &y) { - return gsl_cdf_cauchy_P((const double)x, (const double)y); -} +double gsl_cdf_cauchy_P__(double const &x, double const &y) { return gsl_cdf_cauchy_P((const double)x, (const double)y); } -double gsl_cdf_cauchy_Q__(double const &x, double const &y) { - return gsl_cdf_cauchy_Q((const double)x, (const double)y); -} +double gsl_cdf_cauchy_Q__(double const &x, double const &y) { return gsl_cdf_cauchy_Q((const double)x, (const double)y); } -double gsl_cdf_cauchy_Pinv__(double const &x, double const &y) { - return gsl_cdf_cauchy_Pinv((const double)x, (const double)y); -} +double gsl_cdf_cauchy_Pinv__(double const &x, double const &y) { return gsl_cdf_cauchy_Pinv((const double)x, (const double)y); } -double gsl_cdf_cauchy_Qinv__(double const &x, double const &y) { - return gsl_cdf_cauchy_Qinv((const double)x, (const double)y); -} +double gsl_cdf_cauchy_Qinv__(double const &x, double const &y) { return gsl_cdf_cauchy_Qinv((const double)x, (const double)y); } -double gsl_cdf_laplace_P__(double const &x, double const &y) { - return gsl_cdf_laplace_P((const double)x, (const double)y); -} +double gsl_cdf_laplace_P__(double const &x, double const &y) { return gsl_cdf_laplace_P((const double)x, (const double)y); } -double gsl_cdf_laplace_Q__(double const &x, double const &y) { - return gsl_cdf_laplace_Q((const double)x, (const double)y); -} +double gsl_cdf_laplace_Q__(double const &x, double const &y) { return gsl_cdf_laplace_Q((const double)x, (const double)y); } -double gsl_cdf_laplace_Pinv__(double const &x, double const &y) { - return gsl_cdf_laplace_Pinv((const double)x, (const double)y); -} +double gsl_cdf_laplace_Pinv__(double const &x, double const &y) { return gsl_cdf_laplace_Pinv((const double)x, (const double)y); } -double gsl_cdf_laplace_Qinv__(double const &x, double const &y) { - return gsl_cdf_laplace_Qinv((const double)x, (const double)y); -} +double gsl_cdf_laplace_Qinv__(double const &x, double const &y) { return gsl_cdf_laplace_Qinv((const double)x, (const double)y); } -double gsl_cdf_rayleigh_P__(double const &x, double const &y) { - return gsl_cdf_rayleigh_P((const double)x, (const double)y); -} +double gsl_cdf_rayleigh_P__(double const &x, double const &y) { return gsl_cdf_rayleigh_P((const double)x, (const double)y); } -double gsl_cdf_rayleigh_Q__(double const &x, double const &y) { - return gsl_cdf_rayleigh_Q((const double)x, (const double)y); -} +double gsl_cdf_rayleigh_Q__(double const &x, double const &y) { return gsl_cdf_rayleigh_Q((const double)x, (const double)y); } -double gsl_cdf_rayleigh_Pinv__(double const &x, double const &y) { - return gsl_cdf_rayleigh_Pinv((const double)x, (const double)y); -} +double gsl_cdf_rayleigh_Pinv__(double const &x, double const &y) { return gsl_cdf_rayleigh_Pinv((const double)x, (const double)y); } -double gsl_cdf_rayleigh_Qinv__(double const &x, double const &y) { - return gsl_cdf_rayleigh_Qinv((const double)x, (const double)y); -} +double gsl_cdf_rayleigh_Qinv__(double const &x, double const &y) { return gsl_cdf_rayleigh_Qinv((const double)x, (const double)y); } -double gsl_cdf_chisq_P__(double const &x, double const &y) { - return gsl_cdf_chisq_P((const double)x, (const double)y); -} +double gsl_cdf_chisq_P__(double const &x, double const &y) { return gsl_cdf_chisq_P((const double)x, (const double)y); } -double gsl_cdf_chisq_Q__(double const &x, double const &y) { - return gsl_cdf_chisq_Q((const double)x, (const double)y); -} +double gsl_cdf_chisq_Q__(double const &x, double const &y) { return gsl_cdf_chisq_Q((const double)x, (const double)y); } -double gsl_cdf_chisq_Pinv__(double const &x, double const &y) { - return gsl_cdf_chisq_Pinv((const double)x, (const double)y); -} +double gsl_cdf_chisq_Pinv__(double const &x, double const &y) { return gsl_cdf_chisq_Pinv((const double)x, (const double)y); } -double gsl_cdf_chisq_Qinv__(double const &x, double const &y) { - return gsl_cdf_chisq_Qinv((const double)x, (const double)y); -} +double gsl_cdf_chisq_Qinv__(double const &x, double const &y) { return gsl_cdf_chisq_Qinv((const double)x, (const double)y); } -double gsl_cdf_exponential_P__(double const &x, double const &y) { - return gsl_cdf_exponential_P((const double)x, (const double)y); -} +double gsl_cdf_exponential_P__(double const &x, double const &y) { return gsl_cdf_exponential_P((const double)x, (const double)y); } -double gsl_cdf_exponential_Q__(double const &x, double const &y) { - return gsl_cdf_exponential_Q((const double)x, (const double)y); -} +double gsl_cdf_exponential_Q__(double const &x, double const &y) { return gsl_cdf_exponential_Q((const double)x, (const double)y); } -double gsl_cdf_exponential_Pinv__(double const &x, double const &y) { - return gsl_cdf_exponential_Pinv((const double)x, (const double)y); -} +double gsl_cdf_exponential_Pinv__(double const &x, double const &y) { return gsl_cdf_exponential_Pinv((const double)x, (const double)y); } -double gsl_cdf_exponential_Qinv__(double const &x, double const &y) { - return gsl_cdf_exponential_Qinv((const double)x, (const double)y); -} +double gsl_cdf_exponential_Qinv__(double const &x, double const &y) { return gsl_cdf_exponential_Qinv((const double)x, (const double)y); } -double gsl_cdf_exppow_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_exppow_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_exppow_P__(double const &x, double const &y, double const &z) { return gsl_cdf_exppow_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_exppow_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_exppow_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_exppow_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_exppow_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_tdist_P__(double const &x, double const &y) { - return gsl_cdf_tdist_P((const double)x, (const double)y); -} +double gsl_cdf_tdist_P__(double const &x, double const &y) { return gsl_cdf_tdist_P((const double)x, (const double)y); } -double gsl_cdf_tdist_Q__(double const &x, double const &y) { - return gsl_cdf_tdist_Q((const double)x, (const double)y); -} +double gsl_cdf_tdist_Q__(double const &x, double const &y) { return gsl_cdf_tdist_Q((const double)x, (const double)y); } -double gsl_cdf_tdist_Pinv__(double const &x, double const &y) { - return gsl_cdf_tdist_Pinv((const double)x, (const double)y); -} +double gsl_cdf_tdist_Pinv__(double const &x, double const &y) { return gsl_cdf_tdist_Pinv((const double)x, (const double)y); } -double gsl_cdf_tdist_Qinv__(double const &x, double const &y) { - return gsl_cdf_tdist_Qinv((const double)x, (const double)y); -} +double gsl_cdf_tdist_Qinv__(double const &x, double const &y) { return gsl_cdf_tdist_Qinv((const double)x, (const double)y); } -double gsl_cdf_fdist_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_fdist_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_fdist_P__(double const &x, double const &y, double const &z) { return gsl_cdf_fdist_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_fdist_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_fdist_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_fdist_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_fdist_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_fdist_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_fdist_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_fdist_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_fdist_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_fdist_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_fdist_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_fdist_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_fdist_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_beta_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_beta_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_beta_P__(double const &x, double const &y, double const &z) { return gsl_cdf_beta_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_beta_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_beta_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_beta_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_beta_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_beta_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_beta_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_beta_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_beta_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_beta_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_beta_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_beta_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_beta_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_flat_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_flat_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_flat_P__(double const &x, double const &y, double const &z) { return gsl_cdf_flat_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_flat_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_flat_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_flat_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_flat_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_flat_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_flat_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_flat_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_flat_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_flat_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_flat_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_flat_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_flat_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_lognormal_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_lognormal_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_lognormal_P__(double const &x, double const &y, double const &z) { return gsl_cdf_lognormal_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_lognormal_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_lognormal_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_lognormal_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_lognormal_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_lognormal_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_lognormal_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_lognormal_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_lognormal_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_lognormal_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_lognormal_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_lognormal_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_lognormal_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel1_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel1_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel1_P__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel1_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel1_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel1_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel1_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel1_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel1_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel1_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel1_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel1_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel1_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel1_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel1_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel1_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel2_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel2_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel2_P__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel2_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel2_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel2_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel2_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel2_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel2_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel2_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel2_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel2_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_gumbel2_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_gumbel2_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_gumbel2_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_gumbel2_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_weibull_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_weibull_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_weibull_P__(double const &x, double const &y, double const &z) { return gsl_cdf_weibull_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_weibull_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_weibull_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_weibull_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_weibull_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_weibull_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_weibull_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_weibull_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_weibull_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_weibull_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_weibull_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_weibull_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_weibull_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_pareto_P__(double const &x, double const &y, double const &z) { - return gsl_cdf_pareto_P((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_pareto_P__(double const &x, double const &y, double const &z) { return gsl_cdf_pareto_P((const double)x, (const double)y, (const double)z); } -double gsl_cdf_pareto_Q__(double const &x, double const &y, double const &z) { - return gsl_cdf_pareto_Q((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_pareto_Q__(double const &x, double const &y, double const &z) { return gsl_cdf_pareto_Q((const double)x, (const double)y, (const double)z); } -double gsl_cdf_pareto_Pinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_pareto_Pinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_pareto_Pinv__(double const &x, double const &y, double const &z) { return gsl_cdf_pareto_Pinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_pareto_Qinv__(double const &x, double const &y, double const &z) { - return gsl_cdf_pareto_Qinv((const double)x, (const double)y, (const double)z); -} +double gsl_cdf_pareto_Qinv__(double const &x, double const &y, double const &z) { return gsl_cdf_pareto_Qinv((const double)x, (const double)y, (const double)z); } -double gsl_cdf_logistic_P__(double const &x, double const &y) { - return gsl_cdf_logistic_P((const double)x, (const double)y); -} +double gsl_cdf_logistic_P__(double const &x, double const &y) { return gsl_cdf_logistic_P((const double)x, (const double)y); } -double gsl_cdf_logistic_Q__(double const &x, double const &y) { - return gsl_cdf_logistic_Q((const double)x, (const double)y); -} +double gsl_cdf_logistic_Q__(double const &x, double const &y) { return gsl_cdf_logistic_Q((const double)x, (const double)y); } -double gsl_cdf_logistic_Pinv__(double const &x, double const &y) { - return gsl_cdf_logistic_Pinv((const double)x, (const double)y); -} +double gsl_cdf_logistic_Pinv__(double const &x, double const &y) { return gsl_cdf_logistic_Pinv((const double)x, (const double)y); } -double gsl_cdf_logistic_Qinv__(double const &x, double const &y) { - return gsl_cdf_logistic_Qinv((const double)x, (const double)y); -} +double gsl_cdf_logistic_Qinv__(double const &x, double const &y) { return gsl_cdf_logistic_Qinv((const double)x, (const double)y); } -double gsl_cdf_binomial_P__(long const &x, double const &y, long const &z) { - return gsl_cdf_binomial_P((const unsigned int)x, (const double)y, (const unsigned int)z); -} +double gsl_cdf_binomial_P__(long const &x, double const &y, long const &z) { return gsl_cdf_binomial_P((const unsigned int)x, (const double)y, (const unsigned int)z); } -double gsl_cdf_binomial_Q__(long const &x, double const &y, long const &z) { - return gsl_cdf_binomial_Q((const unsigned int)x, (const double)y, (const unsigned int)z); -} +double gsl_cdf_binomial_Q__(long const &x, double const &y, long const &z) { return gsl_cdf_binomial_Q((const unsigned int)x, (const double)y, (const unsigned int)z); } -double gsl_cdf_poisson_P__(long const &x, double const &y) { - return gsl_cdf_poisson_P((const unsigned int)x, (const double)y); -} +double gsl_cdf_poisson_P__(long const &x, double const &y) { return gsl_cdf_poisson_P((const unsigned int)x, (const double)y); } -double gsl_cdf_poisson_Q__(long const &x, double const &y) { - return gsl_cdf_poisson_Q((const unsigned int)x, (const double)y); -} +double gsl_cdf_poisson_Q__(long const &x, double const &y) { return gsl_cdf_poisson_Q((const unsigned int)x, (const double)y); } -double gsl_cdf_geometric_P__(long const &x, double const &y) { - return gsl_cdf_geometric_P((const unsigned int)x, (const double)y); -} +double gsl_cdf_geometric_P__(long const &x, double const &y) { return gsl_cdf_geometric_P((const unsigned int)x, (const double)y); } -double gsl_cdf_geometric_Q__(long const &x, double const &y) { - return gsl_cdf_geometric_Q((const unsigned int)x, (const double)y); -} +double gsl_cdf_geometric_Q__(long const &x, double const &y) { return gsl_cdf_geometric_Q((const unsigned int)x, (const double)y); } -double gsl_cdf_negative_binomial_P__(long const &x, double const &y, double const &z) { - return gsl_cdf_negative_binomial_P((const unsigned int)x, (const double)y, (const double)z); -} +double gsl_cdf_negative_binomial_P__(long const &x, double const &y, double const &z) { return gsl_cdf_negative_binomial_P((const unsigned int)x, (const double)y, (const double)z); } -double gsl_cdf_negative_binomial_Q__(long const &x, double const &y, double const &z) { - return gsl_cdf_negative_binomial_Q((const unsigned int)x, (const double)y, (const double)z); -} +double gsl_cdf_negative_binomial_Q__(long const &x, double const &y, double const &z) { return gsl_cdf_negative_binomial_Q((const unsigned int)x, (const double)y, (const double)z); } -double gsl_cdf_pascal_P__(long const &x, double const &y, long const &z) { - return gsl_cdf_pascal_P((const unsigned int)x, (const double)y, (const unsigned int)z); -} +double gsl_cdf_pascal_P__(long const &x, double const &y, long const &z) { return gsl_cdf_pascal_P((const unsigned int)x, (const double)y, (const unsigned int)z); } -double gsl_cdf_pascal_Q__(long const &x, double const &y, long const &z) { - return gsl_cdf_pascal_Q((const unsigned int)x, (const double)y, (const unsigned int)z); -} +double gsl_cdf_pascal_Q__(long const &x, double const &y, long const &z) { return gsl_cdf_pascal_Q((const unsigned int)x, (const double)y, (const unsigned int)z); } -double gsl_ran_bernoulli_pdf__(long const &x, double const &y) { - return gsl_ran_bernoulli_pdf((const unsigned int)x, (double)y); -} +double gsl_ran_bernoulli_pdf__(long const &x, double const &y) { return gsl_ran_bernoulli_pdf((const unsigned int)x, (double)y); } -double gsl_ran_beta__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_beta((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_beta__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_beta((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_beta_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_beta_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_beta_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_beta_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_binomial_pdf__(long const &x, double const &y, long const &z) { - return gsl_ran_binomial_pdf((const unsigned int)x, (const double)y, (const unsigned int)z); -} +double gsl_ran_binomial_pdf__(long const &x, double const &y, long const &z) { return gsl_ran_binomial_pdf((const unsigned int)x, (const double)y, (const unsigned int)z); } -double gsl_ran_exponential__(gsl_rng **const &x, double const &y) { - return gsl_ran_exponential((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_exponential__(gsl_rng **const &x, double const &y) { return gsl_ran_exponential((const gsl_rng *)*x, (const double)y); } -double gsl_ran_exponential_pdf__(double const &x, double const &y) { - return gsl_ran_exponential_pdf((const double)x, (const double)y); -} +double gsl_ran_exponential_pdf__(double const &x, double const &y) { return gsl_ran_exponential_pdf((const double)x, (const double)y); } -double gsl_ran_exppow__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_exppow((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_exppow__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_exppow((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_exppow_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_exppow_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_exppow_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_exppow_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_cauchy__(gsl_rng **const &x, double const &y) { - return gsl_ran_cauchy((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_cauchy__(gsl_rng **const &x, double const &y) { return gsl_ran_cauchy((const gsl_rng *)*x, (const double)y); } -double gsl_ran_cauchy_pdf__(double const &x, double const &y) { - return gsl_ran_cauchy_pdf((const double)x, (const double)y); -} +double gsl_ran_cauchy_pdf__(double const &x, double const &y) { return gsl_ran_cauchy_pdf((const double)x, (const double)y); } -double gsl_ran_chisq__(gsl_rng **const &x, double const &y) { - return gsl_ran_chisq((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_chisq__(gsl_rng **const &x, double const &y) { return gsl_ran_chisq((const gsl_rng *)*x, (const double)y); } -double gsl_ran_chisq_pdf__(double const &x, double const &y) { - return gsl_ran_chisq_pdf((const double)x, (const double)y); -} +double gsl_ran_chisq_pdf__(double const &x, double const &y) { return gsl_ran_chisq_pdf((const double)x, (const double)y); } -double gsl_ran_erlang__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_erlang((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_erlang__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_erlang((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_erlang_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_erlang_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_erlang_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_erlang_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_fdist__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_fdist((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_fdist__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_fdist((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_fdist_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_fdist_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_fdist_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_fdist_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_flat__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_flat((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_flat__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_flat((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_flat_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_flat_pdf((double)x, (const double)y, (const double)z); -} +double gsl_ran_flat_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_flat_pdf((double)x, (const double)y, (const double)z); } -double gsl_ran_gamma__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gamma((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gamma__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gamma((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gamma_int__(gsl_rng **const &x, long const &y) { - return gsl_ran_gamma_int((const gsl_rng *)*x, (const unsigned int)y); -} +double gsl_ran_gamma_int__(gsl_rng **const &x, long const &y) { return gsl_ran_gamma_int((const gsl_rng *)*x, (const unsigned int)y); } -double gsl_ran_gamma_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_gamma_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_gamma_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_gamma_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_gamma_mt__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gamma_mt((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gamma_mt__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gamma_mt((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gamma_knuth__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gamma_knuth((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gamma_knuth__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gamma_knuth((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gaussian__(gsl_rng **const &x, double const &y) { - return gsl_ran_gaussian((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_gaussian__(gsl_rng **const &x, double const &y) { return gsl_ran_gaussian((const gsl_rng *)*x, (const double)y); } -double gsl_ran_gaussian_ratio_method__(gsl_rng **const &x, double const &y) { - return gsl_ran_gaussian_ratio_method((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_gaussian_ratio_method__(gsl_rng **const &x, double const &y) { return gsl_ran_gaussian_ratio_method((const gsl_rng *)*x, (const double)y); } -double gsl_ran_gaussian_ziggurat__(gsl_rng **const &x, double const &y) { - return gsl_ran_gaussian_ziggurat((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_gaussian_ziggurat__(gsl_rng **const &x, double const &y) { return gsl_ran_gaussian_ziggurat((const gsl_rng *)*x, (const double)y); } -double gsl_ran_gaussian_pdf__(double const &x, double const &y) { - return gsl_ran_gaussian_pdf((const double)x, (const double)y); -} +double gsl_ran_gaussian_pdf__(double const &x, double const &y) { return gsl_ran_gaussian_pdf((const double)x, (const double)y); } double gsl_ran_ugaussian__(gsl_rng **const &x) { return gsl_ran_ugaussian((const gsl_rng *)*x); } -double gsl_ran_ugaussian_ratio_method__(gsl_rng **const &x) { - return gsl_ran_ugaussian_ratio_method((const gsl_rng *)*x); -} +double gsl_ran_ugaussian_ratio_method__(gsl_rng **const &x) { return gsl_ran_ugaussian_ratio_method((const gsl_rng *)*x); } double gsl_ran_ugaussian_pdf__(double const &x) { return gsl_ran_ugaussian_pdf((const double)x); } -double gsl_ran_gaussian_tail__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gaussian_tail((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gaussian_tail__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gaussian_tail((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gaussian_tail_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_gaussian_tail_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_gaussian_tail_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_gaussian_tail_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_ugaussian_tail__(gsl_rng **const &x, double const &y) { - return gsl_ran_ugaussian_tail((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_ugaussian_tail__(gsl_rng **const &x, double const &y) { return gsl_ran_ugaussian_tail((const gsl_rng *)*x, (const double)y); } -double gsl_ran_ugaussian_tail_pdf__(double const &x, double const &y) { - return gsl_ran_ugaussian_tail_pdf((const double)x, (const double)y); -} +double gsl_ran_ugaussian_tail_pdf__(double const &x, double const &y) { return gsl_ran_ugaussian_tail_pdf((const double)x, (const double)y); } double gsl_ran_landau__(gsl_rng **const &x) { return gsl_ran_landau((const gsl_rng *)*x); } double gsl_ran_landau_pdf__(double const &x) { return gsl_ran_landau_pdf((const double)x); } -double gsl_ran_geometric_pdf__(long const &x, double const &y) { - return gsl_ran_geometric_pdf((const unsigned int)x, (const double)y); -} +double gsl_ran_geometric_pdf__(long const &x, double const &y) { return gsl_ran_geometric_pdf((const unsigned int)x, (const double)y); } -double gsl_ran_gumbel1__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gumbel1((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gumbel1__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gumbel1((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gumbel1_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_gumbel1_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_gumbel1_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_gumbel1_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_gumbel2__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_gumbel2((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_gumbel2__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_gumbel2((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_gumbel2_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_gumbel2_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_gumbel2_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_gumbel2_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_logistic__(gsl_rng **const &x, double const &y) { - return gsl_ran_logistic((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_logistic__(gsl_rng **const &x, double const &y) { return gsl_ran_logistic((const gsl_rng *)*x, (const double)y); } -double gsl_ran_logistic_pdf__(double const &x, double const &y) { - return gsl_ran_logistic_pdf((const double)x, (const double)y); -} +double gsl_ran_logistic_pdf__(double const &x, double const &y) { return gsl_ran_logistic_pdf((const double)x, (const double)y); } -double gsl_ran_lognormal__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_lognormal((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_lognormal__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_lognormal((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_lognormal_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_lognormal_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_lognormal_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_lognormal_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_logarithmic_pdf__(long const &x, double const &y) { - return gsl_ran_logarithmic_pdf((const unsigned int)x, (const double)y); -} +double gsl_ran_logarithmic_pdf__(long const &x, double const &y) { return gsl_ran_logarithmic_pdf((const unsigned int)x, (const double)y); } -double gsl_ran_negative_binomial_pdf__(long const &x, double const &y, double const &z) { - return gsl_ran_negative_binomial_pdf((const unsigned int)x, (const double)y, (double)z); -} +double gsl_ran_negative_binomial_pdf__(long const &x, double const &y, double const &z) { return gsl_ran_negative_binomial_pdf((const unsigned int)x, (const double)y, (double)z); } -double gsl_ran_pascal_pdf__(long const &x, double const &y, long const &z) { - return gsl_ran_pascal_pdf((const unsigned int)x, (const double)y, (unsigned int)z); -} +double gsl_ran_pascal_pdf__(long const &x, double const &y, long const &z) { return gsl_ran_pascal_pdf((const unsigned int)x, (const double)y, (unsigned int)z); } -double gsl_ran_pareto__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_pareto((const gsl_rng *)*x, (double)y, (const double)z); -} +double gsl_ran_pareto__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_pareto((const gsl_rng *)*x, (double)y, (const double)z); } -double gsl_ran_pareto_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_pareto_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_pareto_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_pareto_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_poisson_pdf__(long const &x, double const &y) { - return gsl_ran_poisson_pdf((const unsigned int)x, (const double)y); -} +double gsl_ran_poisson_pdf__(long const &x, double const &y) { return gsl_ran_poisson_pdf((const unsigned int)x, (const double)y); } -double gsl_ran_rayleigh__(gsl_rng **const &x, double const &y) { - return gsl_ran_rayleigh((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_rayleigh__(gsl_rng **const &x, double const &y) { return gsl_ran_rayleigh((const gsl_rng *)*x, (const double)y); } -double gsl_ran_rayleigh_pdf__(double const &x, double const &y) { - return gsl_ran_rayleigh_pdf((const double)x, (const double)y); -} +double gsl_ran_rayleigh_pdf__(double const &x, double const &y) { return gsl_ran_rayleigh_pdf((const double)x, (const double)y); } -double gsl_ran_rayleigh_tail__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_rayleigh_tail((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_rayleigh_tail__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_rayleigh_tail((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_rayleigh_tail_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_rayleigh_tail_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_rayleigh_tail_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_rayleigh_tail_pdf((const double)x, (const double)y, (const double)z); } -double gsl_ran_tdist__(gsl_rng **const &x, double const &y) { - return gsl_ran_tdist((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_tdist__(gsl_rng **const &x, double const &y) { return gsl_ran_tdist((const gsl_rng *)*x, (const double)y); } -double gsl_ran_tdist_pdf__(double const &x, double const &y) { - return gsl_ran_tdist_pdf((const double)x, (const double)y); -} +double gsl_ran_tdist_pdf__(double const &x, double const &y) { return gsl_ran_tdist_pdf((const double)x, (const double)y); } -double gsl_ran_laplace__(gsl_rng **const &x, double const &y) { - return gsl_ran_laplace((const gsl_rng *)*x, (const double)y); -} +double gsl_ran_laplace__(gsl_rng **const &x, double const &y) { return gsl_ran_laplace((const gsl_rng *)*x, (const double)y); } -double gsl_ran_laplace_pdf__(double const &x, double const &y) { - return gsl_ran_laplace_pdf((const double)x, (const double)y); -} +double gsl_ran_laplace_pdf__(double const &x, double const &y) { return gsl_ran_laplace_pdf((const double)x, (const double)y); } -double gsl_ran_levy__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_levy((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_levy__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_levy((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_weibull__(gsl_rng **const &x, double const &y, double const &z) { - return gsl_ran_weibull((const gsl_rng *)*x, (const double)y, (const double)z); -} +double gsl_ran_weibull__(gsl_rng **const &x, double const &y, double const &z) { return gsl_ran_weibull((const gsl_rng *)*x, (const double)y, (const double)z); } -double gsl_ran_weibull_pdf__(double const &x, double const &y, double const &z) { - return gsl_ran_weibull_pdf((const double)x, (const double)y, (const double)z); -} +double gsl_ran_weibull_pdf__(double const &x, double const &y, double const &z) { return gsl_ran_weibull_pdf((const double)x, (const double)y, (const double)z); } -double gsl_sf_airy_Ai__(double const &x, long const &y) { - return gsl_sf_airy_Ai((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Ai__(double const &x, long const &y) { return gsl_sf_airy_Ai((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Bi__(double const &x, long const &y) { - return gsl_sf_airy_Bi((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Bi__(double const &x, long const &y) { return gsl_sf_airy_Bi((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Ai_scaled__(double const &x, long const &y) { - return gsl_sf_airy_Ai_scaled((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Ai_scaled__(double const &x, long const &y) { return gsl_sf_airy_Ai_scaled((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Bi_scaled__(double const &x, long const &y) { - return gsl_sf_airy_Bi_scaled((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Bi_scaled__(double const &x, long const &y) { return gsl_sf_airy_Bi_scaled((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Ai_deriv__(double const &x, long const &y) { - return gsl_sf_airy_Ai_deriv((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Ai_deriv__(double const &x, long const &y) { return gsl_sf_airy_Ai_deriv((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Bi_deriv__(double const &x, long const &y) { - return gsl_sf_airy_Bi_deriv((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Bi_deriv__(double const &x, long const &y) { return gsl_sf_airy_Bi_deriv((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Ai_deriv_scaled__(double const &x, long const &y) { - return gsl_sf_airy_Ai_deriv_scaled((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Ai_deriv_scaled__(double const &x, long const &y) { return gsl_sf_airy_Ai_deriv_scaled((const double)x, (gsl_mode_t)y); } -double gsl_sf_airy_Bi_deriv_scaled__(double const &x, long const &y) { - return gsl_sf_airy_Bi_deriv_scaled((const double)x, (gsl_mode_t)y); -} +double gsl_sf_airy_Bi_deriv_scaled__(double const &x, long const &y) { return gsl_sf_airy_Bi_deriv_scaled((const double)x, (gsl_mode_t)y); } double gsl_sf_airy_zero_Ai__(long const &x) { return gsl_sf_airy_zero_Ai((unsigned int)x); } double gsl_sf_airy_zero_Bi__(long const &x) { return gsl_sf_airy_zero_Bi((unsigned int)x); } -double gsl_sf_airy_zero_Ai_deriv__(long const &x) { - return gsl_sf_airy_zero_Ai_deriv((unsigned int)x); -} +double gsl_sf_airy_zero_Ai_deriv__(long const &x) { return gsl_sf_airy_zero_Ai_deriv((unsigned int)x); } -double gsl_sf_airy_zero_Bi_deriv__(long const &x) { - return gsl_sf_airy_zero_Bi_deriv((unsigned int)x); -} +double gsl_sf_airy_zero_Bi_deriv__(long const &x) { return gsl_sf_airy_zero_Bi_deriv((unsigned int)x); } double gsl_sf_bessel_J0__(double const &x) { return gsl_sf_bessel_J0((const double)x); } double gsl_sf_bessel_J1__(double const &x) { return gsl_sf_bessel_J1((const double)x); } -double gsl_sf_bessel_Jn__(long const &x, double const &y) { - return gsl_sf_bessel_Jn((const int)x, (const double)y); -} +double gsl_sf_bessel_Jn__(long const &x, double const &y) { return gsl_sf_bessel_Jn((const int)x, (const double)y); } double gsl_sf_bessel_Y0__(double const &x) { return gsl_sf_bessel_Y0((const double)x); } double gsl_sf_bessel_Y1__(double const &x) { return gsl_sf_bessel_Y1((const double)x); } -double gsl_sf_bessel_Yn__(long const &x, double const &y) { - return gsl_sf_bessel_Yn((const int)x, (const double)y); -} +double gsl_sf_bessel_Yn__(long const &x, double const &y) { return gsl_sf_bessel_Yn((const int)x, (const double)y); } double gsl_sf_bessel_I0__(double const &x) { return gsl_sf_bessel_I0((const double)x); } double gsl_sf_bessel_I1__(double const &x) { return gsl_sf_bessel_I1((const double)x); } -double gsl_sf_bessel_In__(long const &x, double const &y) { - return gsl_sf_bessel_In((const int)x, (const double)y); -} +double gsl_sf_bessel_In__(long const &x, double const &y) { return gsl_sf_bessel_In((const int)x, (const double)y); } -double gsl_sf_bessel_I0_scaled__(double const &x) { - return gsl_sf_bessel_I0_scaled((const double)x); -} +double gsl_sf_bessel_I0_scaled__(double const &x) { return gsl_sf_bessel_I0_scaled((const double)x); } -double gsl_sf_bessel_I1_scaled__(double const &x) { - return gsl_sf_bessel_I1_scaled((const double)x); -} +double gsl_sf_bessel_I1_scaled__(double const &x) { return gsl_sf_bessel_I1_scaled((const double)x); } -double gsl_sf_bessel_In_scaled__(long const &x, double const &y) { - return gsl_sf_bessel_In_scaled((const int)x, (const double)y); -} +double gsl_sf_bessel_In_scaled__(long const &x, double const &y) { return gsl_sf_bessel_In_scaled((const int)x, (const double)y); } double gsl_sf_bessel_K0__(double const &x) { return gsl_sf_bessel_K0((const double)x); } double gsl_sf_bessel_K1__(double const &x) { return gsl_sf_bessel_K1((const double)x); } -double gsl_sf_bessel_Kn__(long const &x, double const &y) { - return gsl_sf_bessel_Kn((const int)x, (const double)y); -} +double gsl_sf_bessel_Kn__(long const &x, double const &y) { return gsl_sf_bessel_Kn((const int)x, (const double)y); } -double gsl_sf_bessel_K0_scaled__(double const &x) { - return gsl_sf_bessel_K0_scaled((const double)x); -} +double gsl_sf_bessel_K0_scaled__(double const &x) { return gsl_sf_bessel_K0_scaled((const double)x); } -double gsl_sf_bessel_K1_scaled__(double const &x) { - return gsl_sf_bessel_K1_scaled((const double)x); -} +double gsl_sf_bessel_K1_scaled__(double const &x) { return gsl_sf_bessel_K1_scaled((const double)x); } -double gsl_sf_bessel_Kn_scaled__(long const &x, double const &y) { - return gsl_sf_bessel_Kn_scaled((const int)x, (const double)y); -} +double gsl_sf_bessel_Kn_scaled__(long const &x, double const &y) { return gsl_sf_bessel_Kn_scaled((const int)x, (const double)y); } double gsl_sf_bessel_j0__(double const &x) { return gsl_sf_bessel_j0((const double)x); } @@ -1071,9 +755,7 @@ double gsl_sf_bessel_j1__(double const &x) { return gsl_sf_bessel_j1((const doub double gsl_sf_bessel_j2__(double const &x) { return gsl_sf_bessel_j2((const double)x); } -double gsl_sf_bessel_jl__(long const &x, double const &y) { - return gsl_sf_bessel_jl((const int)x, (const double)y); -} +double gsl_sf_bessel_jl__(long const &x, double const &y) { return gsl_sf_bessel_jl((const int)x, (const double)y); } double gsl_sf_bessel_y0__(double const &x) { return gsl_sf_bessel_y0((const double)x); } @@ -1081,83 +763,47 @@ double gsl_sf_bessel_y1__(double const &x) { return gsl_sf_bessel_y1((const doub double gsl_sf_bessel_y2__(double const &x) { return gsl_sf_bessel_y2((const double)x); } -double gsl_sf_bessel_yl__(long const &x, double const &y) { - return gsl_sf_bessel_yl((const int)x, (const double)y); -} +double gsl_sf_bessel_yl__(long const &x, double const &y) { return gsl_sf_bessel_yl((const int)x, (const double)y); } -double gsl_sf_bessel_i0_scaled__(double const &x) { - return gsl_sf_bessel_i0_scaled((const double)x); -} +double gsl_sf_bessel_i0_scaled__(double const &x) { return gsl_sf_bessel_i0_scaled((const double)x); } -double gsl_sf_bessel_i1_scaled__(double const &x) { - return gsl_sf_bessel_i1_scaled((const double)x); -} +double gsl_sf_bessel_i1_scaled__(double const &x) { return gsl_sf_bessel_i1_scaled((const double)x); } -double gsl_sf_bessel_i2_scaled__(double const &x) { - return gsl_sf_bessel_i2_scaled((const double)x); -} +double gsl_sf_bessel_i2_scaled__(double const &x) { return gsl_sf_bessel_i2_scaled((const double)x); } -double gsl_sf_bessel_il_scaled__(long const &x, double const &y) { - return gsl_sf_bessel_il_scaled((const int)x, (const double)y); -} +double gsl_sf_bessel_il_scaled__(long const &x, double const &y) { return gsl_sf_bessel_il_scaled((const int)x, (const double)y); } -double gsl_sf_bessel_k0_scaled__(double const &x) { - return gsl_sf_bessel_k0_scaled((const double)x); -} +double gsl_sf_bessel_k0_scaled__(double const &x) { return gsl_sf_bessel_k0_scaled((const double)x); } -double gsl_sf_bessel_k1_scaled__(double const &x) { - return gsl_sf_bessel_k1_scaled((const double)x); -} +double gsl_sf_bessel_k1_scaled__(double const &x) { return gsl_sf_bessel_k1_scaled((const double)x); } -double gsl_sf_bessel_k2_scaled__(double const &x) { - return gsl_sf_bessel_k2_scaled((const double)x); -} +double gsl_sf_bessel_k2_scaled__(double const &x) { return gsl_sf_bessel_k2_scaled((const double)x); } -double gsl_sf_bessel_kl_scaled__(long const &x, double const &y) { - return gsl_sf_bessel_kl_scaled((const int)x, (const double)y); -} +double gsl_sf_bessel_kl_scaled__(long const &x, double const &y) { return gsl_sf_bessel_kl_scaled((const int)x, (const double)y); } -double gsl_sf_bessel_Jnu__(double const &x, double const &y) { - return gsl_sf_bessel_Jnu((const double)x, (const double)y); -} +double gsl_sf_bessel_Jnu__(double const &x, double const &y) { return gsl_sf_bessel_Jnu((const double)x, (const double)y); } -double gsl_sf_bessel_Ynu__(double const &x, double const &y) { - return gsl_sf_bessel_Ynu((const double)x, (const double)y); -} +double gsl_sf_bessel_Ynu__(double const &x, double const &y) { return gsl_sf_bessel_Ynu((const double)x, (const double)y); } -double gsl_sf_bessel_Inu_scaled__(double const &x, double const &y) { - return gsl_sf_bessel_Inu_scaled((double)x, (double)y); -} +double gsl_sf_bessel_Inu_scaled__(double const &x, double const &y) { return gsl_sf_bessel_Inu_scaled((double)x, (double)y); } -double gsl_sf_bessel_Inu__(double const &x, double const &y) { - return gsl_sf_bessel_Inu((double)x, (double)y); -} +double gsl_sf_bessel_Inu__(double const &x, double const &y) { return gsl_sf_bessel_Inu((double)x, (double)y); } -double gsl_sf_bessel_Knu_scaled__(double const &x, double const &y) { - return gsl_sf_bessel_Knu_scaled((const double)x, (const double)y); -} +double gsl_sf_bessel_Knu_scaled__(double const &x, double const &y) { return gsl_sf_bessel_Knu_scaled((const double)x, (const double)y); } -double gsl_sf_bessel_Knu__(double const &x, double const &y) { - return gsl_sf_bessel_Knu((const double)x, (const double)y); -} +double gsl_sf_bessel_Knu__(double const &x, double const &y) { return gsl_sf_bessel_Knu((const double)x, (const double)y); } -double gsl_sf_bessel_lnKnu__(double const &x, double const &y) { - return gsl_sf_bessel_lnKnu((const double)x, (const double)y); -} +double gsl_sf_bessel_lnKnu__(double const &x, double const &y) { return gsl_sf_bessel_lnKnu((const double)x, (const double)y); } double gsl_sf_bessel_zero_J0__(long const &x) { return gsl_sf_bessel_zero_J0((unsigned int)x); } double gsl_sf_bessel_zero_J1__(long const &x) { return gsl_sf_bessel_zero_J1((unsigned int)x); } -double gsl_sf_bessel_zero_Jnu__(double const &x, long const &y) { - return gsl_sf_bessel_zero_Jnu((double)x, (unsigned int)y); -} +double gsl_sf_bessel_zero_Jnu__(double const &x, long const &y) { return gsl_sf_bessel_zero_Jnu((double)x, (unsigned int)y); } double gsl_sf_clausen__(double const &x) { return gsl_sf_clausen((const double)x); } -double gsl_sf_hydrogenicR_1__(double const &x, double const &y) { - return gsl_sf_hydrogenicR_1((const double)x, (const double)y); -} +double gsl_sf_hydrogenicR_1__(double const &x, double const &y) { return gsl_sf_hydrogenicR_1((const double)x, (const double)y); } double gsl_sf_dawson__(double const &x) { return gsl_sf_dawson((double)x); } @@ -1175,37 +821,21 @@ double gsl_sf_debye_6__(double const &x) { return gsl_sf_debye_6((const double)x double gsl_sf_dilog__(double const &x) { return gsl_sf_dilog((const double)x); } -double gsl_sf_multiply__(double const &x, double const &y) { - return gsl_sf_multiply((const double)x, (const double)y); -} +double gsl_sf_multiply__(double const &x, double const &y) { return gsl_sf_multiply((const double)x, (const double)y); } -double gsl_sf_ellint_Kcomp__(double const &x, long const &y) { - return gsl_sf_ellint_Kcomp((double)x, (gsl_mode_t)y); -} +double gsl_sf_ellint_Kcomp__(double const &x, long const &y) { return gsl_sf_ellint_Kcomp((double)x, (gsl_mode_t)y); } -double gsl_sf_ellint_Ecomp__(double const &x, long const &y) { - return gsl_sf_ellint_Ecomp((double)x, (gsl_mode_t)y); -} +double gsl_sf_ellint_Ecomp__(double const &x, long const &y) { return gsl_sf_ellint_Ecomp((double)x, (gsl_mode_t)y); } -double gsl_sf_ellint_Pcomp__(double const &x, double const &y, long const &z) { - return gsl_sf_ellint_Pcomp((double)x, (double)y, (gsl_mode_t)z); -} +double gsl_sf_ellint_Pcomp__(double const &x, double const &y, long const &z) { return gsl_sf_ellint_Pcomp((double)x, (double)y, (gsl_mode_t)z); } -double gsl_sf_ellint_Dcomp__(double const &x, long const &y) { - return gsl_sf_ellint_Dcomp((double)x, (gsl_mode_t)y); -} +double gsl_sf_ellint_Dcomp__(double const &x, long const &y) { return gsl_sf_ellint_Dcomp((double)x, (gsl_mode_t)y); } -double gsl_sf_ellint_F__(double const &x, double const &y, long const &z) { - return gsl_sf_ellint_F((double)x, (double)y, (gsl_mode_t)z); -} +double gsl_sf_ellint_F__(double const &x, double const &y, long const &z) { return gsl_sf_ellint_F((double)x, (double)y, (gsl_mode_t)z); } -double gsl_sf_ellint_E__(double const &x, double const &y, long const &z) { - return gsl_sf_ellint_E((double)x, (double)y, (gsl_mode_t)z); -} +double gsl_sf_ellint_E__(double const &x, double const &y, long const &z) { return gsl_sf_ellint_E((double)x, (double)y, (gsl_mode_t)z); } -double gsl_sf_ellint_RC__(double const &x, double const &y, long const &z) { - return gsl_sf_ellint_RC((double)x, (double)y, (gsl_mode_t)z); -} +double gsl_sf_ellint_RC__(double const &x, double const &y, long const &z) { return gsl_sf_ellint_RC((double)x, (double)y, (gsl_mode_t)z); } double gsl_sf_erfc__(double const &x) { return gsl_sf_erfc((double)x); } @@ -1221,9 +851,7 @@ double gsl_sf_hazard__(double const &x) { return gsl_sf_hazard((double)x); } double gsl_sf_exp__(double const &x) { return gsl_sf_exp((const double)x); } -double gsl_sf_exp_mult__(double const &x, double const &y) { - return gsl_sf_exp_mult((const double)x, (const double)y); -} +double gsl_sf_exp_mult__(double const &x, double const &y) { return gsl_sf_exp_mult((const double)x, (const double)y); } double gsl_sf_expm1__(double const &x) { return gsl_sf_expm1((const double)x); } @@ -1231,35 +859,23 @@ double gsl_sf_exprel__(double const &x) { return gsl_sf_exprel((const double)x); double gsl_sf_exprel_2__(double const &x) { return gsl_sf_exprel_2((const double)x); } -double gsl_sf_exprel_n__(long const &x, double const &y) { - return gsl_sf_exprel_n((const int)x, (const double)y); -} +double gsl_sf_exprel_n__(long const &x, double const &y) { return gsl_sf_exprel_n((const int)x, (const double)y); } double gsl_sf_expint_E1__(double const &x) { return gsl_sf_expint_E1((const double)x); } double gsl_sf_expint_E2__(double const &x) { return gsl_sf_expint_E2((const double)x); } -double gsl_sf_expint_En__(long const &x, double const &y) { - return gsl_sf_expint_En((const int)x, (const double)y); -} +double gsl_sf_expint_En__(long const &x, double const &y) { return gsl_sf_expint_En((const int)x, (const double)y); } -double gsl_sf_expint_E1_scaled__(double const &x) { - return gsl_sf_expint_E1_scaled((const double)x); -} +double gsl_sf_expint_E1_scaled__(double const &x) { return gsl_sf_expint_E1_scaled((const double)x); } -double gsl_sf_expint_E2_scaled__(double const &x) { - return gsl_sf_expint_E2_scaled((const double)x); -} +double gsl_sf_expint_E2_scaled__(double const &x) { return gsl_sf_expint_E2_scaled((const double)x); } -double gsl_sf_expint_En_scaled__(long const &x, double const &y) { - return gsl_sf_expint_En_scaled((const int)x, (const double)y); -} +double gsl_sf_expint_En_scaled__(long const &x, double const &y) { return gsl_sf_expint_En_scaled((const int)x, (const double)y); } double gsl_sf_expint_Ei__(double const &x) { return gsl_sf_expint_Ei((const double)x); } -double gsl_sf_expint_Ei_scaled__(double const &x) { - return gsl_sf_expint_Ei_scaled((const double)x); -} +double gsl_sf_expint_Ei_scaled__(double const &x) { return gsl_sf_expint_Ei_scaled((const double)x); } double gsl_sf_Shi__(double const &x) { return gsl_sf_Shi((const double)x); } @@ -1281,25 +897,15 @@ double gsl_sf_fermi_dirac_1__(double const &x) { return gsl_sf_fermi_dirac_1((co double gsl_sf_fermi_dirac_2__(double const &x) { return gsl_sf_fermi_dirac_2((const double)x); } -double gsl_sf_fermi_dirac_int__(long const &x, double const &y) { - return gsl_sf_fermi_dirac_int((const int)x, (const double)y); -} +double gsl_sf_fermi_dirac_int__(long const &x, double const &y) { return gsl_sf_fermi_dirac_int((const int)x, (const double)y); } -double gsl_sf_fermi_dirac_mhalf__(double const &x) { - return gsl_sf_fermi_dirac_mhalf((const double)x); -} +double gsl_sf_fermi_dirac_mhalf__(double const &x) { return gsl_sf_fermi_dirac_mhalf((const double)x); } -double gsl_sf_fermi_dirac_half__(double const &x) { - return gsl_sf_fermi_dirac_half((const double)x); -} +double gsl_sf_fermi_dirac_half__(double const &x) { return gsl_sf_fermi_dirac_half((const double)x); } -double gsl_sf_fermi_dirac_3half__(double const &x) { - return gsl_sf_fermi_dirac_3half((const double)x); -} +double gsl_sf_fermi_dirac_3half__(double const &x) { return gsl_sf_fermi_dirac_3half((const double)x); } -double gsl_sf_fermi_dirac_inc_0__(double const &x, double const &y) { - return gsl_sf_fermi_dirac_inc_0((const double)x, (const double)y); -} +double gsl_sf_fermi_dirac_inc_0__(double const &x, double const &y) { return gsl_sf_fermi_dirac_inc_0((const double)x, (const double)y); } double gsl_sf_lngamma__(double const &x) { return gsl_sf_lngamma((const double)x); } @@ -1309,9 +915,7 @@ double gsl_sf_gammastar__(double const &x) { return gsl_sf_gammastar((const doub double gsl_sf_gammainv__(double const &x) { return gsl_sf_gammainv((const double)x); } -double gsl_sf_taylorcoeff__(long const &x, double const &y) { - return gsl_sf_taylorcoeff((const int)x, (const double)y); -} +double gsl_sf_taylorcoeff__(long const &x, double const &y) { return gsl_sf_taylorcoeff((const int)x, (const double)y); } double gsl_sf_fact__(long const &x) { return gsl_sf_fact((const unsigned int)x); } @@ -1321,113 +925,61 @@ double gsl_sf_lnfact__(long const &x) { return gsl_sf_lnfact((const unsigned int double gsl_sf_lndoublefact__(long const &x) { return gsl_sf_lndoublefact((const unsigned int)x); } -double gsl_sf_lnchoose__(long const &x, long const &y) { - return gsl_sf_lnchoose((unsigned int)x, (unsigned int)y); -} +double gsl_sf_lnchoose__(long const &x, long const &y) { return gsl_sf_lnchoose((unsigned int)x, (unsigned int)y); } -double gsl_sf_choose__(long const &x, long const &y) { - return gsl_sf_choose((unsigned int)x, (unsigned int)y); -} +double gsl_sf_choose__(long const &x, long const &y) { return gsl_sf_choose((unsigned int)x, (unsigned int)y); } -double gsl_sf_lnpoch__(double const &x, double const &y) { - return gsl_sf_lnpoch((const double)x, (const double)y); -} +double gsl_sf_lnpoch__(double const &x, double const &y) { return gsl_sf_lnpoch((const double)x, (const double)y); } -double gsl_sf_poch__(double const &x, double const &y) { - return gsl_sf_poch((const double)x, (const double)y); -} +double gsl_sf_poch__(double const &x, double const &y) { return gsl_sf_poch((const double)x, (const double)y); } -double gsl_sf_pochrel__(double const &x, double const &y) { - return gsl_sf_pochrel((const double)x, (const double)y); -} +double gsl_sf_pochrel__(double const &x, double const &y) { return gsl_sf_pochrel((const double)x, (const double)y); } -double gsl_sf_gamma_inc_Q__(double const &x, double const &y) { - return gsl_sf_gamma_inc_Q((const double)x, (const double)y); -} +double gsl_sf_gamma_inc_Q__(double const &x, double const &y) { return gsl_sf_gamma_inc_Q((const double)x, (const double)y); } -double gsl_sf_gamma_inc_P__(double const &x, double const &y) { - return gsl_sf_gamma_inc_P((const double)x, (const double)y); -} +double gsl_sf_gamma_inc_P__(double const &x, double const &y) { return gsl_sf_gamma_inc_P((const double)x, (const double)y); } -double gsl_sf_gamma_inc__(double const &x, double const &y) { - return gsl_sf_gamma_inc((const double)x, (const double)y); -} +double gsl_sf_gamma_inc__(double const &x, double const &y) { return gsl_sf_gamma_inc((const double)x, (const double)y); } -double gsl_sf_lnbeta__(double const &x, double const &y) { - return gsl_sf_lnbeta((const double)x, (const double)y); -} +double gsl_sf_lnbeta__(double const &x, double const &y) { return gsl_sf_lnbeta((const double)x, (const double)y); } -double gsl_sf_beta__(double const &x, double const &y) { - return gsl_sf_beta((const double)x, (const double)y); -} +double gsl_sf_beta__(double const &x, double const &y) { return gsl_sf_beta((const double)x, (const double)y); } -double gsl_sf_beta_inc__(double const &x, double const &y, double const &z) { - return gsl_sf_beta_inc((const double)x, (const double)y, (const double)z); -} +double gsl_sf_beta_inc__(double const &x, double const &y, double const &z) { return gsl_sf_beta_inc((const double)x, (const double)y, (const double)z); } -double gsl_sf_gegenpoly_1__(double const &x, double const &y) { - return gsl_sf_gegenpoly_1((double)x, (double)y); -} +double gsl_sf_gegenpoly_1__(double const &x, double const &y) { return gsl_sf_gegenpoly_1((double)x, (double)y); } -double gsl_sf_gegenpoly_2__(double const &x, double const &y) { - return gsl_sf_gegenpoly_2((double)x, (double)y); -} +double gsl_sf_gegenpoly_2__(double const &x, double const &y) { return gsl_sf_gegenpoly_2((double)x, (double)y); } -double gsl_sf_gegenpoly_3__(double const &x, double const &y) { - return gsl_sf_gegenpoly_3((double)x, (double)y); -} +double gsl_sf_gegenpoly_3__(double const &x, double const &y) { return gsl_sf_gegenpoly_3((double)x, (double)y); } -double gsl_sf_gegenpoly_n__(long const &x, double const &y, double const &z) { - return gsl_sf_gegenpoly_n((int)x, (double)y, (double)z); -} +double gsl_sf_gegenpoly_n__(long const &x, double const &y, double const &z) { return gsl_sf_gegenpoly_n((int)x, (double)y, (double)z); } -double gsl_sf_hyperg_0F1__(double const &x, double const &y) { - return gsl_sf_hyperg_0F1((const double)x, (const double)y); -} +double gsl_sf_hyperg_0F1__(double const &x, double const &y) { return gsl_sf_hyperg_0F1((const double)x, (const double)y); } -double gsl_sf_hyperg_1F1_int__(long const &x, long const &y, double const &z) { - return gsl_sf_hyperg_1F1_int((const int)x, (const int)y, (double)z); -} +double gsl_sf_hyperg_1F1_int__(long const &x, long const &y, double const &z) { return gsl_sf_hyperg_1F1_int((const int)x, (const int)y, (double)z); } -double gsl_sf_hyperg_1F1__(double const &x, double const &y, double const &z) { - return gsl_sf_hyperg_1F1((double)x, (double)y, (double)z); -} +double gsl_sf_hyperg_1F1__(double const &x, double const &y, double const &z) { return gsl_sf_hyperg_1F1((double)x, (double)y, (double)z); } -double gsl_sf_hyperg_U_int__(long const &x, long const &y, double const &z) { - return gsl_sf_hyperg_U_int((const int)x, (const int)y, (const double)z); -} +double gsl_sf_hyperg_U_int__(long const &x, long const &y, double const &z) { return gsl_sf_hyperg_U_int((const int)x, (const int)y, (const double)z); } -double gsl_sf_hyperg_U__(double const &x, double const &y, double const &z) { - return gsl_sf_hyperg_U((const double)x, (const double)y, (const double)z); -} +double gsl_sf_hyperg_U__(double const &x, double const &y, double const &z) { return gsl_sf_hyperg_U((const double)x, (const double)y, (const double)z); } -double gsl_sf_hyperg_2F0__(double const &x, double const &y, double const &z) { - return gsl_sf_hyperg_2F0((const double)x, (const double)y, (const double)z); -} +double gsl_sf_hyperg_2F0__(double const &x, double const &y, double const &z) { return gsl_sf_hyperg_2F0((const double)x, (const double)y, (const double)z); } -double gsl_sf_laguerre_1__(double const &x, double const &y) { - return gsl_sf_laguerre_1((double)x, (double)y); -} +double gsl_sf_laguerre_1__(double const &x, double const &y) { return gsl_sf_laguerre_1((double)x, (double)y); } -double gsl_sf_laguerre_2__(double const &x, double const &y) { - return gsl_sf_laguerre_2((double)x, (double)y); -} +double gsl_sf_laguerre_2__(double const &x, double const &y) { return gsl_sf_laguerre_2((double)x, (double)y); } -double gsl_sf_laguerre_3__(double const &x, double const &y) { - return gsl_sf_laguerre_3((double)x, (double)y); -} +double gsl_sf_laguerre_3__(double const &x, double const &y) { return gsl_sf_laguerre_3((double)x, (double)y); } -double gsl_sf_laguerre_n__(long const &x, double const &y, double const &z) { - return gsl_sf_laguerre_n((int)x, (double)y, (double)z); -} +double gsl_sf_laguerre_n__(long const &x, double const &y, double const &z) { return gsl_sf_laguerre_n((int)x, (double)y, (double)z); } double gsl_sf_lambert_W0__(double const &x) { return gsl_sf_lambert_W0((double)x); } double gsl_sf_lambert_Wm1__(double const &x) { return gsl_sf_lambert_Wm1((double)x); } -double gsl_sf_legendre_Pl__(long const &x, double const &y) { - return gsl_sf_legendre_Pl((const int)x, (const double)y); -} +double gsl_sf_legendre_Pl__(long const &x, double const &y) { return gsl_sf_legendre_Pl((const int)x, (const double)y); } double gsl_sf_legendre_P1__(double const &x) { return gsl_sf_legendre_P1((const double)x); } @@ -1439,55 +991,31 @@ double gsl_sf_legendre_Q0__(double const &x) { return gsl_sf_legendre_Q0((const double gsl_sf_legendre_Q1__(double const &x) { return gsl_sf_legendre_Q1((const double)x); } -double gsl_sf_legendre_Ql__(long const &x, double const &y) { - return gsl_sf_legendre_Ql((const int)x, (const double)y); -} +double gsl_sf_legendre_Ql__(long const &x, double const &y) { return gsl_sf_legendre_Ql((const int)x, (const double)y); } -double gsl_sf_legendre_Plm__(long const &x, long const &y, double const &z) { - return gsl_sf_legendre_Plm((const int)x, (const int)y, (const double)z); -} +double gsl_sf_legendre_Plm__(long const &x, long const &y, double const &z) { return gsl_sf_legendre_Plm((const int)x, (const int)y, (const double)z); } -double gsl_sf_legendre_sphPlm__(long const &x, long const &y, double const &z) { - return gsl_sf_legendre_sphPlm((const int)x, (const int)y, (const double)z); -} +double gsl_sf_legendre_sphPlm__(long const &x, long const &y, double const &z) { return gsl_sf_legendre_sphPlm((const int)x, (const int)y, (const double)z); } // long gsl_sf_legendre_array_size__(long const & x , long const & y ){ return // gsl_sf_legendre_array_size( (const int) x , (const int) y );} -double gsl_sf_conicalP_half__(double const &x, double const &y) { - return gsl_sf_conicalP_half((const double)x, (const double)y); -} +double gsl_sf_conicalP_half__(double const &x, double const &y) { return gsl_sf_conicalP_half((const double)x, (const double)y); } -double gsl_sf_conicalP_mhalf__(double const &x, double const &y) { - return gsl_sf_conicalP_mhalf((const double)x, (const double)y); -} +double gsl_sf_conicalP_mhalf__(double const &x, double const &y) { return gsl_sf_conicalP_mhalf((const double)x, (const double)y); } -double gsl_sf_conicalP_0__(double const &x, double const &y) { - return gsl_sf_conicalP_0((const double)x, (const double)y); -} +double gsl_sf_conicalP_0__(double const &x, double const &y) { return gsl_sf_conicalP_0((const double)x, (const double)y); } -double gsl_sf_conicalP_1__(double const &x, double const &y) { - return gsl_sf_conicalP_1((const double)x, (const double)y); -} +double gsl_sf_conicalP_1__(double const &x, double const &y) { return gsl_sf_conicalP_1((const double)x, (const double)y); } -double gsl_sf_conicalP_sph_reg__(long const &x, double const &y, double const &z) { - return gsl_sf_conicalP_sph_reg((const int)x, (const double)y, (const double)z); -} +double gsl_sf_conicalP_sph_reg__(long const &x, double const &y, double const &z) { return gsl_sf_conicalP_sph_reg((const int)x, (const double)y, (const double)z); } -double gsl_sf_conicalP_cyl_reg__(long const &x, double const &y, double const &z) { - return gsl_sf_conicalP_cyl_reg((const int)x, (const double)y, (const double)z); -} +double gsl_sf_conicalP_cyl_reg__(long const &x, double const &y, double const &z) { return gsl_sf_conicalP_cyl_reg((const int)x, (const double)y, (const double)z); } -double gsl_sf_legendre_H3d_0__(double const &x, double const &y) { - return gsl_sf_legendre_H3d_0((const double)x, (const double)y); -} +double gsl_sf_legendre_H3d_0__(double const &x, double const &y) { return gsl_sf_legendre_H3d_0((const double)x, (const double)y); } -double gsl_sf_legendre_H3d_1__(double const &x, double const &y) { - return gsl_sf_legendre_H3d_1((const double)x, (const double)y); -} +double gsl_sf_legendre_H3d_1__(double const &x, double const &y) { return gsl_sf_legendre_H3d_1((const double)x, (const double)y); } -double gsl_sf_legendre_H3d__(long const &x, double const &y, double const &z) { - return gsl_sf_legendre_H3d((const int)x, (const double)y, (const double)z); -} +double gsl_sf_legendre_H3d__(long const &x, double const &y, double const &z) { return gsl_sf_legendre_H3d((const int)x, (const double)y, (const double)z); } double gsl_sf_log__(double const &x) { return gsl_sf_log((const double)x); } @@ -1497,9 +1025,7 @@ double gsl_sf_log_1plusx__(double const &x) { return gsl_sf_log_1plusx((const do double gsl_sf_log_1plusx_mx__(double const &x) { return gsl_sf_log_1plusx_mx((const double)x); } -double gsl_sf_pow_int__(double const &x, long const &y) { - return gsl_sf_pow_int((const double)x, (const int)y); -} +double gsl_sf_pow_int__(double const &x, long const &y) { return gsl_sf_pow_int((const double)x, (const int)y); } double gsl_sf_psi_int__(long const &x) { return gsl_sf_psi_int((const int)x); } @@ -1511,9 +1037,7 @@ double gsl_sf_psi_1_int__(long const &x) { return gsl_sf_psi_1_int((const int)x) double gsl_sf_psi_1__(double const &x) { return gsl_sf_psi_1((const double)x); } -double gsl_sf_psi_n__(long const &x, double const &y) { - return gsl_sf_psi_n((const int)x, (const double)y); -} +double gsl_sf_psi_n__(long const &x, double const &y) { return gsl_sf_psi_n((const int)x, (const double)y); } double gsl_sf_synchrotron_1__(double const &x) { return gsl_sf_synchrotron_1((const double)x); } @@ -1531,9 +1055,7 @@ double gsl_sf_sin__(double const &x) { return gsl_sf_sin((const double)x); } double gsl_sf_cos__(double const &x) { return gsl_sf_cos((const double)x); } -double gsl_sf_hypot__(double const &x, double const &y) { - return gsl_sf_hypot((const double)x, (const double)y); -} +double gsl_sf_hypot__(double const &x, double const &y) { return gsl_sf_hypot((const double)x, (const double)y); } double gsl_sf_sinc__(double const &x) { return gsl_sf_sinc((const double)x); } @@ -1541,13 +1063,9 @@ double gsl_sf_lnsinh__(double const &x) { return gsl_sf_lnsinh((const double)x); double gsl_sf_lncosh__(double const &x) { return gsl_sf_lncosh((const double)x); } -double gsl_sf_angle_restrict_symm__(double const &x) { - return gsl_sf_angle_restrict_symm((const double)x); -} +double gsl_sf_angle_restrict_symm__(double const &x) { return gsl_sf_angle_restrict_symm((const double)x); } -double gsl_sf_angle_restrict_pos__(double const &x) { - return gsl_sf_angle_restrict_pos((const double)x); -} +double gsl_sf_angle_restrict_pos__(double const &x) { return gsl_sf_angle_restrict_pos((const double)x); } double gsl_sf_zeta_int__(long const &x) { return gsl_sf_zeta_int((const int)x); } @@ -1557,9 +1075,7 @@ double gsl_sf_zetam1__(double const &x) { return gsl_sf_zetam1((const double)x); double gsl_sf_zetam1_int__(long const &x) { return gsl_sf_zetam1_int((const int)x); } -double gsl_sf_hzeta__(double const &x, double const &y) { - return gsl_sf_hzeta((const double)x, (const double)y); -} +double gsl_sf_hzeta__(double const &x, double const &y) { return gsl_sf_hzeta((const double)x, (const double)y); } double gsl_sf_eta_int__(long const &x) { return gsl_sf_eta_int((const int)x); } @@ -1570,301 +1086,162 @@ double gsl_sf_eta__(double const &x) { return gsl_sf_eta((const double)x); } void init_gsl_sf( ) { Global.Add("gslcdfugaussianP", "(", new OneOperator1_< double, double >(gsl_cdf_ugaussian_P__)); Global.Add("gslcdfugaussianQ", "(", new OneOperator1_< double, double >(gsl_cdf_ugaussian_Q__)); - Global.Add("gslcdfugaussianPinv", "(", - new OneOperator1_< double, double >(gsl_cdf_ugaussian_Pinv__)); - Global.Add("gslcdfugaussianQinv", "(", - new OneOperator1_< double, double >(gsl_cdf_ugaussian_Qinv__)); - Global.Add("gslcdfgaussianP", "(", - new OneOperator2_< double, double, double >(gsl_cdf_gaussian_P__)); - Global.Add("gslcdfgaussianQ", "(", - new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Q__)); - Global.Add("gslcdfgaussianPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Pinv__)); - Global.Add("gslcdfgaussianQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Qinv__)); - Global.Add("gslcdfgammaP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_P__)); - Global.Add("gslcdfgammaQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Q__)); - Global.Add("gslcdfgammaPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Pinv__)); - Global.Add("gslcdfgammaQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Qinv__)); + Global.Add("gslcdfugaussianPinv", "(", new OneOperator1_< double, double >(gsl_cdf_ugaussian_Pinv__)); + Global.Add("gslcdfugaussianQinv", "(", new OneOperator1_< double, double >(gsl_cdf_ugaussian_Qinv__)); + Global.Add("gslcdfgaussianP", "(", new OneOperator2_< double, double, double >(gsl_cdf_gaussian_P__)); + Global.Add("gslcdfgaussianQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Q__)); + Global.Add("gslcdfgaussianPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Pinv__)); + Global.Add("gslcdfgaussianQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_gaussian_Qinv__)); + Global.Add("gslcdfgammaP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_P__)); + Global.Add("gslcdfgammaQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Q__)); + Global.Add("gslcdfgammaPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Pinv__)); + Global.Add("gslcdfgammaQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gamma_Qinv__)); Global.Add("gslcdfcauchyP", "(", new OneOperator2_< double, double, double >(gsl_cdf_cauchy_P__)); Global.Add("gslcdfcauchyQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_cauchy_Q__)); - Global.Add("gslcdfcauchyPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_cauchy_Pinv__)); - Global.Add("gslcdfcauchyQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_cauchy_Qinv__)); - Global.Add("gslcdflaplaceP", "(", - new OneOperator2_< double, double, double >(gsl_cdf_laplace_P__)); - Global.Add("gslcdflaplaceQ", "(", - new OneOperator2_< double, double, double >(gsl_cdf_laplace_Q__)); - Global.Add("gslcdflaplacePinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_laplace_Pinv__)); - Global.Add("gslcdflaplaceQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_laplace_Qinv__)); - Global.Add("gslcdfrayleighP", "(", - new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_P__)); - Global.Add("gslcdfrayleighQ", "(", - new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Q__)); - Global.Add("gslcdfrayleighPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Pinv__)); - Global.Add("gslcdfrayleighQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Qinv__)); + Global.Add("gslcdfcauchyPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_cauchy_Pinv__)); + Global.Add("gslcdfcauchyQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_cauchy_Qinv__)); + Global.Add("gslcdflaplaceP", "(", new OneOperator2_< double, double, double >(gsl_cdf_laplace_P__)); + Global.Add("gslcdflaplaceQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_laplace_Q__)); + Global.Add("gslcdflaplacePinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_laplace_Pinv__)); + Global.Add("gslcdflaplaceQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_laplace_Qinv__)); + Global.Add("gslcdfrayleighP", "(", new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_P__)); + Global.Add("gslcdfrayleighQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Q__)); + Global.Add("gslcdfrayleighPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Pinv__)); + Global.Add("gslcdfrayleighQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_rayleigh_Qinv__)); Global.Add("gslcdfchisqP", "(", new OneOperator2_< double, double, double >(gsl_cdf_chisq_P__)); Global.Add("gslcdfchisqQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_chisq_Q__)); - Global.Add("gslcdfchisqPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_chisq_Pinv__)); - Global.Add("gslcdfchisqQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_chisq_Qinv__)); - Global.Add("gslcdfexponentialP", "(", - new OneOperator2_< double, double, double >(gsl_cdf_exponential_P__)); - Global.Add("gslcdfexponentialQ", "(", - new OneOperator2_< double, double, double >(gsl_cdf_exponential_Q__)); - Global.Add("gslcdfexponentialPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_exponential_Pinv__)); - Global.Add("gslcdfexponentialQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_exponential_Qinv__)); - Global.Add("gslcdfexppowP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_exppow_P__)); - Global.Add("gslcdfexppowQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_exppow_Q__)); + Global.Add("gslcdfchisqPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_chisq_Pinv__)); + Global.Add("gslcdfchisqQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_chisq_Qinv__)); + Global.Add("gslcdfexponentialP", "(", new OneOperator2_< double, double, double >(gsl_cdf_exponential_P__)); + Global.Add("gslcdfexponentialQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_exponential_Q__)); + Global.Add("gslcdfexponentialPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_exponential_Pinv__)); + Global.Add("gslcdfexponentialQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_exponential_Qinv__)); + Global.Add("gslcdfexppowP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_exppow_P__)); + Global.Add("gslcdfexppowQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_exppow_Q__)); Global.Add("gslcdftdistP", "(", new OneOperator2_< double, double, double >(gsl_cdf_tdist_P__)); Global.Add("gslcdftdistQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_tdist_Q__)); - Global.Add("gslcdftdistPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_tdist_Pinv__)); - Global.Add("gslcdftdistQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_tdist_Qinv__)); - Global.Add("gslcdffdistP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_P__)); - Global.Add("gslcdffdistQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Q__)); - Global.Add("gslcdffdistPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Pinv__)); - Global.Add("gslcdffdistQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Qinv__)); - Global.Add("gslcdfbetaP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_beta_P__)); - Global.Add("gslcdfbetaQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Q__)); - Global.Add("gslcdfbetaPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Pinv__)); - Global.Add("gslcdfbetaQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Qinv__)); - Global.Add("gslcdfflatP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_flat_P__)); - Global.Add("gslcdfflatQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Q__)); - Global.Add("gslcdfflatPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Pinv__)); - Global.Add("gslcdfflatQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Qinv__)); - Global.Add("gslcdflognormalP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_P__)); - Global.Add("gslcdflognormalQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Q__)); - Global.Add("gslcdflognormalPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Pinv__)); - Global.Add("gslcdflognormalQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Qinv__)); - Global.Add("gslcdfgumbel1P", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_P__)); - Global.Add("gslcdfgumbel1Q", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Q__)); - Global.Add("gslcdfgumbel1Pinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Pinv__)); - Global.Add("gslcdfgumbel1Qinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Qinv__)); - Global.Add("gslcdfgumbel2P", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_P__)); - Global.Add("gslcdfgumbel2Q", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Q__)); - Global.Add("gslcdfgumbel2Pinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Pinv__)); - Global.Add("gslcdfgumbel2Qinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Qinv__)); - Global.Add("gslcdfweibullP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_P__)); - Global.Add("gslcdfweibullQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Q__)); - Global.Add("gslcdfweibullPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Pinv__)); - Global.Add("gslcdfweibullQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Qinv__)); - Global.Add("gslcdfparetoP", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_P__)); - Global.Add("gslcdfparetoQ", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Q__)); - Global.Add("gslcdfparetoPinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Pinv__)); - Global.Add("gslcdfparetoQinv", "(", - new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Qinv__)); - Global.Add("gslcdflogisticP", "(", - new OneOperator2_< double, double, double >(gsl_cdf_logistic_P__)); - Global.Add("gslcdflogisticQ", "(", - new OneOperator2_< double, double, double >(gsl_cdf_logistic_Q__)); - Global.Add("gslcdflogisticPinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_logistic_Pinv__)); - Global.Add("gslcdflogisticQinv", "(", - new OneOperator2_< double, double, double >(gsl_cdf_logistic_Qinv__)); - Global.Add("gslcdfbinomialP", "(", - new OneOperator3_< double, long, double, long >(gsl_cdf_binomial_P__)); - Global.Add("gslcdfbinomialQ", "(", - new OneOperator3_< double, long, double, long >(gsl_cdf_binomial_Q__)); + Global.Add("gslcdftdistPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_tdist_Pinv__)); + Global.Add("gslcdftdistQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_tdist_Qinv__)); + Global.Add("gslcdffdistP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_P__)); + Global.Add("gslcdffdistQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Q__)); + Global.Add("gslcdffdistPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Pinv__)); + Global.Add("gslcdffdistQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_fdist_Qinv__)); + Global.Add("gslcdfbetaP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_beta_P__)); + Global.Add("gslcdfbetaQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Q__)); + Global.Add("gslcdfbetaPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Pinv__)); + Global.Add("gslcdfbetaQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_beta_Qinv__)); + Global.Add("gslcdfflatP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_flat_P__)); + Global.Add("gslcdfflatQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Q__)); + Global.Add("gslcdfflatPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Pinv__)); + Global.Add("gslcdfflatQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_flat_Qinv__)); + Global.Add("gslcdflognormalP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_P__)); + Global.Add("gslcdflognormalQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Q__)); + Global.Add("gslcdflognormalPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Pinv__)); + Global.Add("gslcdflognormalQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_lognormal_Qinv__)); + Global.Add("gslcdfgumbel1P", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_P__)); + Global.Add("gslcdfgumbel1Q", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Q__)); + Global.Add("gslcdfgumbel1Pinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Pinv__)); + Global.Add("gslcdfgumbel1Qinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel1_Qinv__)); + Global.Add("gslcdfgumbel2P", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_P__)); + Global.Add("gslcdfgumbel2Q", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Q__)); + Global.Add("gslcdfgumbel2Pinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Pinv__)); + Global.Add("gslcdfgumbel2Qinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_gumbel2_Qinv__)); + Global.Add("gslcdfweibullP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_P__)); + Global.Add("gslcdfweibullQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Q__)); + Global.Add("gslcdfweibullPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Pinv__)); + Global.Add("gslcdfweibullQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_weibull_Qinv__)); + Global.Add("gslcdfparetoP", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_P__)); + Global.Add("gslcdfparetoQ", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Q__)); + Global.Add("gslcdfparetoPinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Pinv__)); + Global.Add("gslcdfparetoQinv", "(", new OneOperator3_< double, double, double, double >(gsl_cdf_pareto_Qinv__)); + Global.Add("gslcdflogisticP", "(", new OneOperator2_< double, double, double >(gsl_cdf_logistic_P__)); + Global.Add("gslcdflogisticQ", "(", new OneOperator2_< double, double, double >(gsl_cdf_logistic_Q__)); + Global.Add("gslcdflogisticPinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_logistic_Pinv__)); + Global.Add("gslcdflogisticQinv", "(", new OneOperator2_< double, double, double >(gsl_cdf_logistic_Qinv__)); + Global.Add("gslcdfbinomialP", "(", new OneOperator3_< double, long, double, long >(gsl_cdf_binomial_P__)); + Global.Add("gslcdfbinomialQ", "(", new OneOperator3_< double, long, double, long >(gsl_cdf_binomial_Q__)); Global.Add("gslcdfpoissonP", "(", new OneOperator2_< double, long, double >(gsl_cdf_poisson_P__)); Global.Add("gslcdfpoissonQ", "(", new OneOperator2_< double, long, double >(gsl_cdf_poisson_Q__)); - Global.Add("gslcdfgeometricP", "(", - new OneOperator2_< double, long, double >(gsl_cdf_geometric_P__)); - Global.Add("gslcdfgeometricQ", "(", - new OneOperator2_< double, long, double >(gsl_cdf_geometric_Q__)); - Global.Add("gslcdfnegativebinomialP", "(", - new OneOperator3_< double, long, double, double >(gsl_cdf_negative_binomial_P__)); - Global.Add("gslcdfnegativebinomialQ", "(", - new OneOperator3_< double, long, double, double >(gsl_cdf_negative_binomial_Q__)); - Global.Add("gslcdfpascalP", "(", - new OneOperator3_< double, long, double, long >(gsl_cdf_pascal_P__)); - Global.Add("gslcdfpascalQ", "(", - new OneOperator3_< double, long, double, long >(gsl_cdf_pascal_Q__)); - Global.Add("gslranbernoullipdf", "(", - new OneOperator2_< double, long, double >(gsl_ran_bernoulli_pdf__)); - Global.Add("gslranbeta", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_beta__)); - Global.Add("gslranbetapdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_beta_pdf__)); - Global.Add("gslranbinomialpdf", "(", - new OneOperator3_< double, long, double, long >(gsl_ran_binomial_pdf__)); - Global.Add("gslranexponential", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_exponential__)); - Global.Add("gslranexponentialpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_exponential_pdf__)); - Global.Add("gslranexppow", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_exppow__)); - Global.Add("gslranexppowpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_exppow_pdf__)); - Global.Add("gslrancauchy", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_cauchy__)); - Global.Add("gslrancauchypdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_cauchy_pdf__)); + Global.Add("gslcdfgeometricP", "(", new OneOperator2_< double, long, double >(gsl_cdf_geometric_P__)); + Global.Add("gslcdfgeometricQ", "(", new OneOperator2_< double, long, double >(gsl_cdf_geometric_Q__)); + Global.Add("gslcdfnegativebinomialP", "(", new OneOperator3_< double, long, double, double >(gsl_cdf_negative_binomial_P__)); + Global.Add("gslcdfnegativebinomialQ", "(", new OneOperator3_< double, long, double, double >(gsl_cdf_negative_binomial_Q__)); + Global.Add("gslcdfpascalP", "(", new OneOperator3_< double, long, double, long >(gsl_cdf_pascal_P__)); + Global.Add("gslcdfpascalQ", "(", new OneOperator3_< double, long, double, long >(gsl_cdf_pascal_Q__)); + Global.Add("gslranbernoullipdf", "(", new OneOperator2_< double, long, double >(gsl_ran_bernoulli_pdf__)); + Global.Add("gslranbeta", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_beta__)); + Global.Add("gslranbetapdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_beta_pdf__)); + Global.Add("gslranbinomialpdf", "(", new OneOperator3_< double, long, double, long >(gsl_ran_binomial_pdf__)); + Global.Add("gslranexponential", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_exponential__)); + Global.Add("gslranexponentialpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_exponential_pdf__)); + Global.Add("gslranexppow", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_exppow__)); + Global.Add("gslranexppowpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_exppow_pdf__)); + Global.Add("gslrancauchy", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_cauchy__)); + Global.Add("gslrancauchypdf", "(", new OneOperator2_< double, double, double >(gsl_ran_cauchy_pdf__)); Global.Add("gslranchisq", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_chisq__)); - Global.Add("gslranchisqpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_chisq_pdf__)); - Global.Add("gslranerlang", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_erlang__)); - Global.Add("gslranerlangpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_erlang_pdf__)); - Global.Add("gslranfdist", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_fdist__)); - Global.Add("gslranfdistpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_fdist_pdf__)); - Global.Add("gslranflat", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_flat__)); - Global.Add("gslranflatpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_flat_pdf__)); - Global.Add("gslrangamma", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma__)); - Global.Add("gslrangammaint", "(", - new OneOperator2_< double, gsl_rng **, long >(gsl_ran_gamma_int__)); - Global.Add("gslrangammapdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_gamma_pdf__)); - Global.Add("gslrangammamt", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma_mt__)); - Global.Add("gslrangammaknuth", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma_knuth__)); - Global.Add("gslrangaussian", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian__)); - Global.Add("gslrangaussianratiomethod", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian_ratio_method__)); - Global.Add("gslrangaussianziggurat", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian_ziggurat__)); - Global.Add("gslrangaussianpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_gaussian_pdf__)); + Global.Add("gslranchisqpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_chisq_pdf__)); + Global.Add("gslranerlang", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_erlang__)); + Global.Add("gslranerlangpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_erlang_pdf__)); + Global.Add("gslranfdist", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_fdist__)); + Global.Add("gslranfdistpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_fdist_pdf__)); + Global.Add("gslranflat", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_flat__)); + Global.Add("gslranflatpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_flat_pdf__)); + Global.Add("gslrangamma", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma__)); + Global.Add("gslrangammaint", "(", new OneOperator2_< double, gsl_rng **, long >(gsl_ran_gamma_int__)); + Global.Add("gslrangammapdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_gamma_pdf__)); + Global.Add("gslrangammamt", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma_mt__)); + Global.Add("gslrangammaknuth", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gamma_knuth__)); + Global.Add("gslrangaussian", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian__)); + Global.Add("gslrangaussianratiomethod", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian_ratio_method__)); + Global.Add("gslrangaussianziggurat", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_gaussian_ziggurat__)); + Global.Add("gslrangaussianpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_gaussian_pdf__)); Global.Add("gslranugaussian", "(", new OneOperator1_< double, gsl_rng ** >(gsl_ran_ugaussian__)); - Global.Add("gslranugaussianratiomethod", "(", - new OneOperator1_< double, gsl_rng ** >(gsl_ran_ugaussian_ratio_method__)); - Global.Add("gslranugaussianpdf", "(", - new OneOperator1_< double, double >(gsl_ran_ugaussian_pdf__)); - Global.Add("gslrangaussiantail", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gaussian_tail__)); - Global.Add("gslrangaussiantailpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_gaussian_tail_pdf__)); - Global.Add("gslranugaussiantail", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_ugaussian_tail__)); - Global.Add("gslranugaussiantailpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_ugaussian_tail_pdf__)); + Global.Add("gslranugaussianratiomethod", "(", new OneOperator1_< double, gsl_rng ** >(gsl_ran_ugaussian_ratio_method__)); + Global.Add("gslranugaussianpdf", "(", new OneOperator1_< double, double >(gsl_ran_ugaussian_pdf__)); + Global.Add("gslrangaussiantail", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gaussian_tail__)); + Global.Add("gslrangaussiantailpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_gaussian_tail_pdf__)); + Global.Add("gslranugaussiantail", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_ugaussian_tail__)); + Global.Add("gslranugaussiantailpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_ugaussian_tail_pdf__)); Global.Add("gslranlandau", "(", new OneOperator1_< double, gsl_rng ** >(gsl_ran_landau__)); Global.Add("gslranlandaupdf", "(", new OneOperator1_< double, double >(gsl_ran_landau_pdf__)); - Global.Add("gslrangeometricpdf", "(", - new OneOperator2_< double, long, double >(gsl_ran_geometric_pdf__)); - Global.Add("gslrangumbel1", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gumbel1__)); - Global.Add("gslrangumbel1pdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_gumbel1_pdf__)); - Global.Add("gslrangumbel2", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gumbel2__)); - Global.Add("gslrangumbel2pdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_gumbel2_pdf__)); - Global.Add("gslranlogistic", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_logistic__)); - Global.Add("gslranlogisticpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_logistic_pdf__)); - Global.Add("gslranlognormal", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_lognormal__)); - Global.Add("gslranlognormalpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_lognormal_pdf__)); - Global.Add("gslranlogarithmicpdf", "(", - new OneOperator2_< double, long, double >(gsl_ran_logarithmic_pdf__)); - Global.Add("gslrannegativebinomialpdf", "(", - new OneOperator3_< double, long, double, double >(gsl_ran_negative_binomial_pdf__)); - Global.Add("gslranpascalpdf", "(", - new OneOperator3_< double, long, double, long >(gsl_ran_pascal_pdf__)); - Global.Add("gslranpareto", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_pareto__)); - Global.Add("gslranparetopdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_pareto_pdf__)); - Global.Add("gslranpoissonpdf", "(", - new OneOperator2_< double, long, double >(gsl_ran_poisson_pdf__)); - Global.Add("gslranrayleigh", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_rayleigh__)); - Global.Add("gslranrayleighpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_rayleigh_pdf__)); - Global.Add("gslranrayleightail", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_rayleigh_tail__)); - Global.Add("gslranrayleightailpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_rayleigh_tail_pdf__)); + Global.Add("gslrangeometricpdf", "(", new OneOperator2_< double, long, double >(gsl_ran_geometric_pdf__)); + Global.Add("gslrangumbel1", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gumbel1__)); + Global.Add("gslrangumbel1pdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_gumbel1_pdf__)); + Global.Add("gslrangumbel2", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_gumbel2__)); + Global.Add("gslrangumbel2pdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_gumbel2_pdf__)); + Global.Add("gslranlogistic", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_logistic__)); + Global.Add("gslranlogisticpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_logistic_pdf__)); + Global.Add("gslranlognormal", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_lognormal__)); + Global.Add("gslranlognormalpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_lognormal_pdf__)); + Global.Add("gslranlogarithmicpdf", "(", new OneOperator2_< double, long, double >(gsl_ran_logarithmic_pdf__)); + Global.Add("gslrannegativebinomialpdf", "(", new OneOperator3_< double, long, double, double >(gsl_ran_negative_binomial_pdf__)); + Global.Add("gslranpascalpdf", "(", new OneOperator3_< double, long, double, long >(gsl_ran_pascal_pdf__)); + Global.Add("gslranpareto", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_pareto__)); + Global.Add("gslranparetopdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_pareto_pdf__)); + Global.Add("gslranpoissonpdf", "(", new OneOperator2_< double, long, double >(gsl_ran_poisson_pdf__)); + Global.Add("gslranrayleigh", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_rayleigh__)); + Global.Add("gslranrayleighpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_rayleigh_pdf__)); + Global.Add("gslranrayleightail", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_rayleigh_tail__)); + Global.Add("gslranrayleightailpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_rayleigh_tail_pdf__)); Global.Add("gslrantdist", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_tdist__)); - Global.Add("gslrantdistpdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_tdist_pdf__)); - Global.Add("gslranlaplace", "(", - new OneOperator2_< double, gsl_rng **, double >(gsl_ran_laplace__)); - Global.Add("gslranlaplacepdf", "(", - new OneOperator2_< double, double, double >(gsl_ran_laplace_pdf__)); - Global.Add("gslranlevy", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_levy__)); - Global.Add("gslranweibull", "(", - new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_weibull__)); - Global.Add("gslranweibullpdf", "(", - new OneOperator3_< double, double, double, double >(gsl_ran_weibull_pdf__)); + Global.Add("gslrantdistpdf", "(", new OneOperator2_< double, double, double >(gsl_ran_tdist_pdf__)); + Global.Add("gslranlaplace", "(", new OneOperator2_< double, gsl_rng **, double >(gsl_ran_laplace__)); + Global.Add("gslranlaplacepdf", "(", new OneOperator2_< double, double, double >(gsl_ran_laplace_pdf__)); + Global.Add("gslranlevy", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_levy__)); + Global.Add("gslranweibull", "(", new OneOperator3_< double, gsl_rng **, double, double >(gsl_ran_weibull__)); + Global.Add("gslranweibullpdf", "(", new OneOperator3_< double, double, double, double >(gsl_ran_weibull_pdf__)); Global.Add("gslsfairyAi", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Ai__)); Global.Add("gslsfairyBi", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Bi__)); - Global.Add("gslsfairyAiscaled", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_scaled__)); - Global.Add("gslsfairyBiscaled", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_scaled__)); - Global.Add("gslsfairyAideriv", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_deriv__)); - Global.Add("gslsfairyBideriv", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_deriv__)); - Global.Add("gslsfairyAiderivscaled", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_deriv_scaled__)); - Global.Add("gslsfairyBiderivscaled", "(", - new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_deriv_scaled__)); + Global.Add("gslsfairyAiscaled", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_scaled__)); + Global.Add("gslsfairyBiscaled", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_scaled__)); + Global.Add("gslsfairyAideriv", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_deriv__)); + Global.Add("gslsfairyBideriv", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_deriv__)); + Global.Add("gslsfairyAiderivscaled", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Ai_deriv_scaled__)); + Global.Add("gslsfairyBiderivscaled", "(", new OneOperator2_< double, double, long >(gsl_sf_airy_Bi_deriv_scaled__)); Global.Add("gslsfairyzeroAi", "(", new OneOperator1_< double, long >(gsl_sf_airy_zero_Ai__)); Global.Add("gslsfairyzeroBi", "(", new OneOperator1_< double, long >(gsl_sf_airy_zero_Bi__)); - Global.Add("gslsfairyzeroAideriv", "(", - new OneOperator1_< double, long >(gsl_sf_airy_zero_Ai_deriv__)); - Global.Add("gslsfairyzeroBideriv", "(", - new OneOperator1_< double, long >(gsl_sf_airy_zero_Bi_deriv__)); + Global.Add("gslsfairyzeroAideriv", "(", new OneOperator1_< double, long >(gsl_sf_airy_zero_Ai_deriv__)); + Global.Add("gslsfairyzeroBideriv", "(", new OneOperator1_< double, long >(gsl_sf_airy_zero_Bi_deriv__)); Global.Add("gslsfbesselJ0", "(", new OneOperator1_< double, double >(gsl_sf_bessel_J0__)); Global.Add("gslsfbesselJ1", "(", new OneOperator1_< double, double >(gsl_sf_bessel_J1__)); Global.Add("gslsfbesselJn", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_Jn__)); @@ -1874,21 +1251,15 @@ void init_gsl_sf( ) { Global.Add("gslsfbesselI0", "(", new OneOperator1_< double, double >(gsl_sf_bessel_I0__)); Global.Add("gslsfbesselI1", "(", new OneOperator1_< double, double >(gsl_sf_bessel_I1__)); Global.Add("gslsfbesselIn", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_In__)); - Global.Add("gslsfbesselI0scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_I0_scaled__)); - Global.Add("gslsfbesselI1scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_I1_scaled__)); - Global.Add("gslsfbesselInscaled", "(", - new OneOperator2_< double, long, double >(gsl_sf_bessel_In_scaled__)); + Global.Add("gslsfbesselI0scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_I0_scaled__)); + Global.Add("gslsfbesselI1scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_I1_scaled__)); + Global.Add("gslsfbesselInscaled", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_In_scaled__)); Global.Add("gslsfbesselK0", "(", new OneOperator1_< double, double >(gsl_sf_bessel_K0__)); Global.Add("gslsfbesselK1", "(", new OneOperator1_< double, double >(gsl_sf_bessel_K1__)); Global.Add("gslsfbesselKn", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_Kn__)); - Global.Add("gslsfbesselK0scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_K0_scaled__)); - Global.Add("gslsfbesselK1scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_K1_scaled__)); - Global.Add("gslsfbesselKnscaled", "(", - new OneOperator2_< double, long, double >(gsl_sf_bessel_Kn_scaled__)); + Global.Add("gslsfbesselK0scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_K0_scaled__)); + Global.Add("gslsfbesselK1scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_K1_scaled__)); + Global.Add("gslsfbesselKnscaled", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_Kn_scaled__)); Global.Add("gslsfbesselj0", "(", new OneOperator1_< double, double >(gsl_sf_bessel_j0__)); Global.Add("gslsfbesselj1", "(", new OneOperator1_< double, double >(gsl_sf_bessel_j1__)); Global.Add("gslsfbesselj2", "(", new OneOperator1_< double, double >(gsl_sf_bessel_j2__)); @@ -1897,43 +1268,26 @@ void init_gsl_sf( ) { Global.Add("gslsfbessely1", "(", new OneOperator1_< double, double >(gsl_sf_bessel_y1__)); Global.Add("gslsfbessely2", "(", new OneOperator1_< double, double >(gsl_sf_bessel_y2__)); Global.Add("gslsfbesselyl", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_yl__)); - Global.Add("gslsfbesseli0scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_i0_scaled__)); - Global.Add("gslsfbesseli1scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_i1_scaled__)); - Global.Add("gslsfbesseli2scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_i2_scaled__)); - Global.Add("gslsfbesselilscaled", "(", - new OneOperator2_< double, long, double >(gsl_sf_bessel_il_scaled__)); - Global.Add("gslsfbesselk0scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_k0_scaled__)); - Global.Add("gslsfbesselk1scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_k1_scaled__)); - Global.Add("gslsfbesselk2scaled", "(", - new OneOperator1_< double, double >(gsl_sf_bessel_k2_scaled__)); - Global.Add("gslsfbesselklscaled", "(", - new OneOperator2_< double, long, double >(gsl_sf_bessel_kl_scaled__)); - Global.Add("gslsfbesselJnu", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Jnu__)); - Global.Add("gslsfbesselYnu", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Ynu__)); - Global.Add("gslsfbesselInuscaled", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Inu_scaled__)); - Global.Add("gslsfbesselInu", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Inu__)); - Global.Add("gslsfbesselKnuscaled", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Knu_scaled__)); - Global.Add("gslsfbesselKnu", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_Knu__)); - Global.Add("gslsfbessellnKnu", "(", - new OneOperator2_< double, double, double >(gsl_sf_bessel_lnKnu__)); + Global.Add("gslsfbesseli0scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_i0_scaled__)); + Global.Add("gslsfbesseli1scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_i1_scaled__)); + Global.Add("gslsfbesseli2scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_i2_scaled__)); + Global.Add("gslsfbesselilscaled", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_il_scaled__)); + Global.Add("gslsfbesselk0scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_k0_scaled__)); + Global.Add("gslsfbesselk1scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_k1_scaled__)); + Global.Add("gslsfbesselk2scaled", "(", new OneOperator1_< double, double >(gsl_sf_bessel_k2_scaled__)); + Global.Add("gslsfbesselklscaled", "(", new OneOperator2_< double, long, double >(gsl_sf_bessel_kl_scaled__)); + Global.Add("gslsfbesselJnu", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Jnu__)); + Global.Add("gslsfbesselYnu", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Ynu__)); + Global.Add("gslsfbesselInuscaled", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Inu_scaled__)); + Global.Add("gslsfbesselInu", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Inu__)); + Global.Add("gslsfbesselKnuscaled", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Knu_scaled__)); + Global.Add("gslsfbesselKnu", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_Knu__)); + Global.Add("gslsfbessellnKnu", "(", new OneOperator2_< double, double, double >(gsl_sf_bessel_lnKnu__)); Global.Add("gslsfbesselzeroJ0", "(", new OneOperator1_< double, long >(gsl_sf_bessel_zero_J0__)); Global.Add("gslsfbesselzeroJ1", "(", new OneOperator1_< double, long >(gsl_sf_bessel_zero_J1__)); - Global.Add("gslsfbesselzeroJnu", "(", - new OneOperator2_< double, double, long >(gsl_sf_bessel_zero_Jnu__)); + Global.Add("gslsfbesselzeroJnu", "(", new OneOperator2_< double, double, long >(gsl_sf_bessel_zero_Jnu__)); Global.Add("gslsfclausen", "(", new OneOperator1_< double, double >(gsl_sf_clausen__)); - Global.Add("gslsfhydrogenicR1", "(", - new OneOperator2_< double, double, double >(gsl_sf_hydrogenicR_1__)); + Global.Add("gslsfhydrogenicR1", "(", new OneOperator2_< double, double, double >(gsl_sf_hydrogenicR_1__)); Global.Add("gslsfdawson", "(", new OneOperator1_< double, double >(gsl_sf_dawson__)); Global.Add("gslsfdebye1", "(", new OneOperator1_< double, double >(gsl_sf_debye_1__)); Global.Add("gslsfdebye2", "(", new OneOperator1_< double, double >(gsl_sf_debye_2__)); @@ -1943,20 +1297,13 @@ void init_gsl_sf( ) { Global.Add("gslsfdebye6", "(", new OneOperator1_< double, double >(gsl_sf_debye_6__)); Global.Add("gslsfdilog", "(", new OneOperator1_< double, double >(gsl_sf_dilog__)); Global.Add("gslsfmultiply", "(", new OneOperator2_< double, double, double >(gsl_sf_multiply__)); - Global.Add("gslsfellintKcomp", "(", - new OneOperator2_< double, double, long >(gsl_sf_ellint_Kcomp__)); - Global.Add("gslsfellintEcomp", "(", - new OneOperator2_< double, double, long >(gsl_sf_ellint_Ecomp__)); - Global.Add("gslsfellintPcomp", "(", - new OneOperator3_< double, double, double, long >(gsl_sf_ellint_Pcomp__)); - Global.Add("gslsfellintDcomp", "(", - new OneOperator2_< double, double, long >(gsl_sf_ellint_Dcomp__)); - Global.Add("gslsfellintF", "(", - new OneOperator3_< double, double, double, long >(gsl_sf_ellint_F__)); - Global.Add("gslsfellintE", "(", - new OneOperator3_< double, double, double, long >(gsl_sf_ellint_E__)); - Global.Add("gslsfellintRC", "(", - new OneOperator3_< double, double, double, long >(gsl_sf_ellint_RC__)); + Global.Add("gslsfellintKcomp", "(", new OneOperator2_< double, double, long >(gsl_sf_ellint_Kcomp__)); + Global.Add("gslsfellintEcomp", "(", new OneOperator2_< double, double, long >(gsl_sf_ellint_Ecomp__)); + Global.Add("gslsfellintPcomp", "(", new OneOperator3_< double, double, double, long >(gsl_sf_ellint_Pcomp__)); + Global.Add("gslsfellintDcomp", "(", new OneOperator2_< double, double, long >(gsl_sf_ellint_Dcomp__)); + Global.Add("gslsfellintF", "(", new OneOperator3_< double, double, double, long >(gsl_sf_ellint_F__)); + Global.Add("gslsfellintE", "(", new OneOperator3_< double, double, double, long >(gsl_sf_ellint_E__)); + Global.Add("gslsfellintRC", "(", new OneOperator3_< double, double, double, long >(gsl_sf_ellint_RC__)); Global.Add("gslsferfc", "(", new OneOperator1_< double, double >(gsl_sf_erfc__)); Global.Add("gslsflogerfc", "(", new OneOperator1_< double, double >(gsl_sf_log_erfc__)); Global.Add("gslsferf", "(", new OneOperator1_< double, double >(gsl_sf_erf__)); @@ -1972,42 +1319,31 @@ void init_gsl_sf( ) { Global.Add("gslsfexpintE1", "(", new OneOperator1_< double, double >(gsl_sf_expint_E1__)); Global.Add("gslsfexpintE2", "(", new OneOperator1_< double, double >(gsl_sf_expint_E2__)); Global.Add("gslsfexpintEn", "(", new OneOperator2_< double, long, double >(gsl_sf_expint_En__)); - Global.Add("gslsfexpintE1scaled", "(", - new OneOperator1_< double, double >(gsl_sf_expint_E1_scaled__)); - Global.Add("gslsfexpintE2scaled", "(", - new OneOperator1_< double, double >(gsl_sf_expint_E2_scaled__)); - Global.Add("gslsfexpintEnscaled", "(", - new OneOperator2_< double, long, double >(gsl_sf_expint_En_scaled__)); + Global.Add("gslsfexpintE1scaled", "(", new OneOperator1_< double, double >(gsl_sf_expint_E1_scaled__)); + Global.Add("gslsfexpintE2scaled", "(", new OneOperator1_< double, double >(gsl_sf_expint_E2_scaled__)); + Global.Add("gslsfexpintEnscaled", "(", new OneOperator2_< double, long, double >(gsl_sf_expint_En_scaled__)); Global.Add("gslsfexpintEi", "(", new OneOperator1_< double, double >(gsl_sf_expint_Ei__)); - Global.Add("gslsfexpintEiscaled", "(", - new OneOperator1_< double, double >(gsl_sf_expint_Ei_scaled__)); + Global.Add("gslsfexpintEiscaled", "(", new OneOperator1_< double, double >(gsl_sf_expint_Ei_scaled__)); Global.Add("gslsfShi", "(", new OneOperator1_< double, double >(gsl_sf_Shi__)); Global.Add("gslsfChi", "(", new OneOperator1_< double, double >(gsl_sf_Chi__)); Global.Add("gslsfexpint3", "(", new OneOperator1_< double, double >(gsl_sf_expint_3__)); Global.Add("gslsfSi", "(", new OneOperator1_< double, double >(gsl_sf_Si__)); Global.Add("gslsfCi", "(", new OneOperator1_< double, double >(gsl_sf_Ci__)); Global.Add("gslsfatanint", "(", new OneOperator1_< double, double >(gsl_sf_atanint__)); - Global.Add("gslsffermidiracm1", "(", - new OneOperator1_< double, double >(gsl_sf_fermi_dirac_m1__)); + Global.Add("gslsffermidiracm1", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_m1__)); Global.Add("gslsffermidirac0", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_0__)); Global.Add("gslsffermidirac1", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_1__)); Global.Add("gslsffermidirac2", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_2__)); - Global.Add("gslsffermidiracint", "(", - new OneOperator2_< double, long, double >(gsl_sf_fermi_dirac_int__)); - Global.Add("gslsffermidiracmhalf", "(", - new OneOperator1_< double, double >(gsl_sf_fermi_dirac_mhalf__)); - Global.Add("gslsffermidirachalf", "(", - new OneOperator1_< double, double >(gsl_sf_fermi_dirac_half__)); - Global.Add("gslsffermidirac3half", "(", - new OneOperator1_< double, double >(gsl_sf_fermi_dirac_3half__)); - Global.Add("gslsffermidiracinc0", "(", - new OneOperator2_< double, double, double >(gsl_sf_fermi_dirac_inc_0__)); + Global.Add("gslsffermidiracint", "(", new OneOperator2_< double, long, double >(gsl_sf_fermi_dirac_int__)); + Global.Add("gslsffermidiracmhalf", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_mhalf__)); + Global.Add("gslsffermidirachalf", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_half__)); + Global.Add("gslsffermidirac3half", "(", new OneOperator1_< double, double >(gsl_sf_fermi_dirac_3half__)); + Global.Add("gslsffermidiracinc0", "(", new OneOperator2_< double, double, double >(gsl_sf_fermi_dirac_inc_0__)); Global.Add("gslsflngamma", "(", new OneOperator1_< double, double >(gsl_sf_lngamma__)); Global.Add("gslsfgamma", "(", new OneOperator1_< double, double >(gsl_sf_gamma__)); Global.Add("gslsfgammastar", "(", new OneOperator1_< double, double >(gsl_sf_gammastar__)); Global.Add("gslsfgammainv", "(", new OneOperator1_< double, double >(gsl_sf_gammainv__)); - Global.Add("gslsftaylorcoeff", "(", - new OneOperator2_< double, long, double >(gsl_sf_taylorcoeff__)); + Global.Add("gslsftaylorcoeff", "(", new OneOperator2_< double, long, double >(gsl_sf_taylorcoeff__)); Global.Add("gslsffact", "(", new OneOperator1_< double, long >(gsl_sf_fact__)); Global.Add("gslsfdoublefact", "(", new OneOperator1_< double, long >(gsl_sf_doublefact__)); Global.Add("gslsflnfact", "(", new OneOperator1_< double, long >(gsl_sf_lnfact__)); @@ -2017,78 +1353,48 @@ void init_gsl_sf( ) { Global.Add("gslsflnpoch", "(", new OneOperator2_< double, double, double >(gsl_sf_lnpoch__)); Global.Add("gslsfpoch", "(", new OneOperator2_< double, double, double >(gsl_sf_poch__)); Global.Add("gslsfpochrel", "(", new OneOperator2_< double, double, double >(gsl_sf_pochrel__)); - Global.Add("gslsfgammaincQ", "(", - new OneOperator2_< double, double, double >(gsl_sf_gamma_inc_Q__)); - Global.Add("gslsfgammaincP", "(", - new OneOperator2_< double, double, double >(gsl_sf_gamma_inc_P__)); + Global.Add("gslsfgammaincQ", "(", new OneOperator2_< double, double, double >(gsl_sf_gamma_inc_Q__)); + Global.Add("gslsfgammaincP", "(", new OneOperator2_< double, double, double >(gsl_sf_gamma_inc_P__)); Global.Add("gslsfgammainc", "(", new OneOperator2_< double, double, double >(gsl_sf_gamma_inc__)); Global.Add("gslsflnbeta", "(", new OneOperator2_< double, double, double >(gsl_sf_lnbeta__)); Global.Add("gslsfbeta", "(", new OneOperator2_< double, double, double >(gsl_sf_beta__)); - Global.Add("gslsfbetainc", "(", - new OneOperator3_< double, double, double, double >(gsl_sf_beta_inc__)); - Global.Add("gslsfgegenpoly1", "(", - new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_1__)); - Global.Add("gslsfgegenpoly2", "(", - new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_2__)); - Global.Add("gslsfgegenpoly3", "(", - new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_3__)); - Global.Add("gslsfgegenpolyn", "(", - new OneOperator3_< double, long, double, double >(gsl_sf_gegenpoly_n__)); - Global.Add("gslsfhyperg0F1", "(", - new OneOperator2_< double, double, double >(gsl_sf_hyperg_0F1__)); - Global.Add("gslsfhyperg1F1int", "(", - new OneOperator3_< double, long, long, double >(gsl_sf_hyperg_1F1_int__)); - Global.Add("gslsfhyperg1F1", "(", - new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_1F1__)); - Global.Add("gslsfhypergUint", "(", - new OneOperator3_< double, long, long, double >(gsl_sf_hyperg_U_int__)); - Global.Add("gslsfhypergU", "(", - new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_U__)); - Global.Add("gslsfhyperg2F0", "(", - new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_2F0__)); - Global.Add("gslsflaguerre1", "(", - new OneOperator2_< double, double, double >(gsl_sf_laguerre_1__)); - Global.Add("gslsflaguerre2", "(", - new OneOperator2_< double, double, double >(gsl_sf_laguerre_2__)); - Global.Add("gslsflaguerre3", "(", - new OneOperator2_< double, double, double >(gsl_sf_laguerre_3__)); - Global.Add("gslsflaguerren", "(", - new OneOperator3_< double, long, double, double >(gsl_sf_laguerre_n__)); + Global.Add("gslsfbetainc", "(", new OneOperator3_< double, double, double, double >(gsl_sf_beta_inc__)); + Global.Add("gslsfgegenpoly1", "(", new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_1__)); + Global.Add("gslsfgegenpoly2", "(", new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_2__)); + Global.Add("gslsfgegenpoly3", "(", new OneOperator2_< double, double, double >(gsl_sf_gegenpoly_3__)); + Global.Add("gslsfgegenpolyn", "(", new OneOperator3_< double, long, double, double >(gsl_sf_gegenpoly_n__)); + Global.Add("gslsfhyperg0F1", "(", new OneOperator2_< double, double, double >(gsl_sf_hyperg_0F1__)); + Global.Add("gslsfhyperg1F1int", "(", new OneOperator3_< double, long, long, double >(gsl_sf_hyperg_1F1_int__)); + Global.Add("gslsfhyperg1F1", "(", new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_1F1__)); + Global.Add("gslsfhypergUint", "(", new OneOperator3_< double, long, long, double >(gsl_sf_hyperg_U_int__)); + Global.Add("gslsfhypergU", "(", new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_U__)); + Global.Add("gslsfhyperg2F0", "(", new OneOperator3_< double, double, double, double >(gsl_sf_hyperg_2F0__)); + Global.Add("gslsflaguerre1", "(", new OneOperator2_< double, double, double >(gsl_sf_laguerre_1__)); + Global.Add("gslsflaguerre2", "(", new OneOperator2_< double, double, double >(gsl_sf_laguerre_2__)); + Global.Add("gslsflaguerre3", "(", new OneOperator2_< double, double, double >(gsl_sf_laguerre_3__)); + Global.Add("gslsflaguerren", "(", new OneOperator3_< double, long, double, double >(gsl_sf_laguerre_n__)); Global.Add("gslsflambertW0", "(", new OneOperator1_< double, double >(gsl_sf_lambert_W0__)); Global.Add("gslsflambertWm1", "(", new OneOperator1_< double, double >(gsl_sf_lambert_Wm1__)); - Global.Add("gslsflegendrePl", "(", - new OneOperator2_< double, long, double >(gsl_sf_legendre_Pl__)); + Global.Add("gslsflegendrePl", "(", new OneOperator2_< double, long, double >(gsl_sf_legendre_Pl__)); Global.Add("gslsflegendreP1", "(", new OneOperator1_< double, double >(gsl_sf_legendre_P1__)); Global.Add("gslsflegendreP2", "(", new OneOperator1_< double, double >(gsl_sf_legendre_P2__)); Global.Add("gslsflegendreP3", "(", new OneOperator1_< double, double >(gsl_sf_legendre_P3__)); Global.Add("gslsflegendreQ0", "(", new OneOperator1_< double, double >(gsl_sf_legendre_Q0__)); Global.Add("gslsflegendreQ1", "(", new OneOperator1_< double, double >(gsl_sf_legendre_Q1__)); - Global.Add("gslsflegendreQl", "(", - new OneOperator2_< double, long, double >(gsl_sf_legendre_Ql__)); - Global.Add("gslsflegendrePlm", "(", - new OneOperator3_< double, long, long, double >(gsl_sf_legendre_Plm__)); - Global.Add("gslsflegendresphPlm", "(", - new OneOperator3_< double, long, long, double >(gsl_sf_legendre_sphPlm__)); + Global.Add("gslsflegendreQl", "(", new OneOperator2_< double, long, double >(gsl_sf_legendre_Ql__)); + Global.Add("gslsflegendrePlm", "(", new OneOperator3_< double, long, long, double >(gsl_sf_legendre_Plm__)); + Global.Add("gslsflegendresphPlm", "(", new OneOperator3_< double, long, long, double >(gsl_sf_legendre_sphPlm__)); // Global.Add("gslsflegendrearraysize","(",new OneOperator2_( // gsl_sf_legendre_array_size__)); - Global.Add("gslsfconicalPhalf", "(", - new OneOperator2_< double, double, double >(gsl_sf_conicalP_half__)); - Global.Add("gslsfconicalPmhalf", "(", - new OneOperator2_< double, double, double >(gsl_sf_conicalP_mhalf__)); - Global.Add("gslsfconicalP0", "(", - new OneOperator2_< double, double, double >(gsl_sf_conicalP_0__)); - Global.Add("gslsfconicalP1", "(", - new OneOperator2_< double, double, double >(gsl_sf_conicalP_1__)); - Global.Add("gslsfconicalPsphreg", "(", - new OneOperator3_< double, long, double, double >(gsl_sf_conicalP_sph_reg__)); - Global.Add("gslsfconicalPcylreg", "(", - new OneOperator3_< double, long, double, double >(gsl_sf_conicalP_cyl_reg__)); - Global.Add("gslsflegendreH3d0", "(", - new OneOperator2_< double, double, double >(gsl_sf_legendre_H3d_0__)); - Global.Add("gslsflegendreH3d1", "(", - new OneOperator2_< double, double, double >(gsl_sf_legendre_H3d_1__)); - Global.Add("gslsflegendreH3d", "(", - new OneOperator3_< double, long, double, double >(gsl_sf_legendre_H3d__)); + Global.Add("gslsfconicalPhalf", "(", new OneOperator2_< double, double, double >(gsl_sf_conicalP_half__)); + Global.Add("gslsfconicalPmhalf", "(", new OneOperator2_< double, double, double >(gsl_sf_conicalP_mhalf__)); + Global.Add("gslsfconicalP0", "(", new OneOperator2_< double, double, double >(gsl_sf_conicalP_0__)); + Global.Add("gslsfconicalP1", "(", new OneOperator2_< double, double, double >(gsl_sf_conicalP_1__)); + Global.Add("gslsfconicalPsphreg", "(", new OneOperator3_< double, long, double, double >(gsl_sf_conicalP_sph_reg__)); + Global.Add("gslsfconicalPcylreg", "(", new OneOperator3_< double, long, double, double >(gsl_sf_conicalP_cyl_reg__)); + Global.Add("gslsflegendreH3d0", "(", new OneOperator2_< double, double, double >(gsl_sf_legendre_H3d_0__)); + Global.Add("gslsflegendreH3d1", "(", new OneOperator2_< double, double, double >(gsl_sf_legendre_H3d_1__)); + Global.Add("gslsflegendreH3d", "(", new OneOperator3_< double, long, double, double >(gsl_sf_legendre_H3d__)); Global.Add("gslsflog", "(", new OneOperator1_< double, double >(gsl_sf_log__)); Global.Add("gslsflogabs", "(", new OneOperator1_< double, double >(gsl_sf_log_abs__)); Global.Add("gslsflog1plusx", "(", new OneOperator1_< double, double >(gsl_sf_log_1plusx__)); @@ -2112,10 +1418,8 @@ void init_gsl_sf( ) { Global.Add("gslsfsinc", "(", new OneOperator1_< double, double >(gsl_sf_sinc__)); Global.Add("gslsflnsinh", "(", new OneOperator1_< double, double >(gsl_sf_lnsinh__)); Global.Add("gslsflncosh", "(", new OneOperator1_< double, double >(gsl_sf_lncosh__)); - Global.Add("gslsfanglerestrictsymm", "(", - new OneOperator1_< double, double >(gsl_sf_angle_restrict_symm__)); - Global.Add("gslsfanglerestrictpos", "(", - new OneOperator1_< double, double >(gsl_sf_angle_restrict_pos__)); + Global.Add("gslsfanglerestrictsymm", "(", new OneOperator1_< double, double >(gsl_sf_angle_restrict_symm__)); + Global.Add("gslsfanglerestrictpos", "(", new OneOperator1_< double, double >(gsl_sf_angle_restrict_pos__)); Global.Add("gslsfzetaint", "(", new OneOperator1_< double, long >(gsl_sf_zeta_int__)); Global.Add("gslsfzeta", "(", new OneOperator1_< double, double >(gsl_sf_zeta__)); Global.Add("gslsfzetam1", "(", new OneOperator1_< double, double >(gsl_sf_zetam1__)); diff --git a/plugin/seq/ffmaster.c b/plugin/seq/ffmaster.c index 3f0b1e2e4..15c63495f 100644 --- a/plugin/seq/ffmaster.c +++ b/plugin/seq/ffmaster.c @@ -8,9 +8,9 @@ * the compile step is * * cc -c libff-mmap-semaphore.c - # on linux, unix, + # on linux, unix, * cc ffmaster.c -o ffmaster libff-mmap-semaphore.o -g - # on win32 + # on win32 * cc ffmaster.c -o ffmaster libff-mmap-semaphore.o -g ../../3rdparty/lib/libpthread-google.a #build the freefem++ plugin @@ -42,17 +42,16 @@ */ #include "libff-mmap-semaphore.h" -#if defined ( _WIN32 ) -# include -# include -# define NO_STDIO_REDIRECT +#if defined(_WIN32) +#include +#include +#define NO_STDIO_REDIRECT #else -# include +#include #endif #include #include - ff_Psem sem_ff, sem_c; // the semaphore for mutex /* * Psemaphore smff("ff-slave"); @@ -67,7 +66,6 @@ int main(int argc, const char **argv) { long status; int i, ret; - if (argc > 1) { debug = atoi(argv[1]); } @@ -88,12 +86,8 @@ int main(int argc, const char **argv) { char ff[1024]; #ifdef _WIN32 - sprintf( ff, "%d", debug ); - ret = spawnl( P_NOWAIT, - "..\\FreeFem++.exe", - "..\\FreeFem++.exe", - "..\\examples\\plugin\\ffslave.edp", - "-nw", "-ns", "-v", ff, NULL ); + sprintf(ff, "%d", debug); + ret = spawnl(P_NOWAIT, "..\\FreeFem++.exe", "..\\FreeFem++.exe", "..\\examples\\plugin\\ffslave.edp", "-nw", "-ns", "-v", ff, NULL); #else sprintf(ff, "FreeFem++ /usr/share/doc/freefem++/examples/plugin/ffslave.edp -nw -ns -v %d&", debug); ret = system(ff); // Lauch FF++ in batch no graphique diff --git a/plugin/seq/ffnewuoa.cpp b/plugin/seq/ffnewuoa.cpp index 2428eae65..e33762b05 100644 --- a/plugin/seq/ffnewuoa.cpp +++ b/plugin/seq/ffnewuoa.cpp @@ -33,8 +33,7 @@ typedef void (*typecalfunc)(integer *, double *, double *f, void *); #define F77newuoa newuoa_ extern "C" { -double F77newuoa(integer *N, integer *NPT, double *x, double *rhob, double *rhog, integer *iprint, - integer *maxfun, double *w, void *iwf, typecalfunc calfun); +double F77newuoa(integer *N, integer *NPT, double *x, double *rhob, double *rhog, integer *iprint, integer *maxfun, double *w, void *iwf, typecalfunc calfun); } void calfun(integer *n, double *x, double *f, void *t); @@ -75,9 +74,7 @@ class OptimNewoa : public OneOperator { Expression X; C_F0 inittheparam, theparam, closetheparam; Expression JJ; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } @@ -88,8 +85,7 @@ class OptimNewoa : public OneOperator { X = to< Kn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -117,8 +113,7 @@ class OptimNewoa : public OneOperator { int lw = (npt + 13) * (npt + n) + 3 * n * (n + 3) / 2; KN< double > w(lw); integer N = n, NPT = npt, IPRINT = iprint, MAXFUN = maxfun; - cost = F77newuoa(&N, &NPT, (double *)x, &rhobeg, &rhoend, &IPRINT, &MAXFUN, (double *)w, - (void *)&ffJ, calfun); + cost = F77newuoa(&N, &NPT, (double *)x, &rhobeg, &rhoend, &IPRINT, &MAXFUN, (double *)w, (void *)&ffJ, calfun); closetheparam.eval(stack); // clean memory WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 return cost; // SetAny(0); Modif FH july 2005 @@ -129,14 +124,10 @@ class OptimNewoa : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_newoa(args, cas); } - OptimNewoa(int c) - : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + OptimNewoa(int c) : OneOperator(atype< double >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; -basicAC_F0::name_and_type OptimNewoa::E_newoa::name_param[] = {{"rhobeg", &typeid(double)}, - {"rhoend", &typeid(double)}, - {"maxfun", &typeid(long)}, - {"npt", &typeid(long)}}; +basicAC_F0::name_and_type OptimNewoa::E_newoa::name_param[] = {{"rhobeg", &typeid(double)}, {"rhoend", &typeid(double)}, {"maxfun", &typeid(long)}, {"npt", &typeid(long)}}; void calfun(integer *n, double *x, double *f, void *t) { OptimNewoa::ffcalfunc *tt = static_cast< OptimNewoa::ffcalfunc * >(t); @@ -147,7 +138,7 @@ void calfun(integer *n, double *x, double *f, void *t) { } } -static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ +static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ Global.Add("newuoa", "(", new OptimNewoa(1)); // j + dJ } diff --git a/plugin/seq/ffrandom.cpp b/plugin/seq/ffrandom.cpp index 9d8a2dc6c..8551ca593 100644 --- a/plugin/seq/ffrandom.cpp +++ b/plugin/seq/ffrandom.cpp @@ -54,7 +54,7 @@ unsigned long good_seed( ) { std::ifstream file("/dev/random", std::ios::binary); if (file.is_open( )) { - unsigned long memblock[10] = {}; + unsigned long memblock[10] = { }; size_t size = sizeof(int); file.read((char *)(void *)memblock, size); file.close( ); diff --git a/plugin/seq/freeyams.cpp b/plugin/seq/freeyams.cpp index a084f3350..cd43d4fc0 100644 --- a/plugin/seq/freeyams.cpp +++ b/plugin/seq/freeyams.cpp @@ -354,8 +354,7 @@ MeshS *yams_pSurfMesh_to_meshS(yams_pSurfMesh sm, int infondang, int infocc, int } // TODO CHECK -void solyams_pSurfMesh(yams_pSurfMesh sm, const int &type, const KN< double > &tabsol, float hmin, - float hmax) { +void solyams_pSurfMesh(yams_pSurfMesh sm, const int &type, const KN< double > &tabsol, float hmin, float hmax) { yams_pPoint ppt; yams_pMetric pm; int i, k; @@ -548,29 +547,17 @@ class yams_Op_meshS : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: yams_Op_meshS(const basicAC_F0 &args) : sol(args.size( ) - 1) { @@ -625,8 +612,7 @@ class yams_Op_meshS : public E_F0mps { break; default: - CompileError( - " 3D solution for yams is a scalar (1 comp) or a symmetric tensor (6 comp)"); + CompileError(" 3D solution for yams is a scalar (1 comp) or a symmetric tensor (6 comp)"); break; } } else { @@ -858,8 +844,7 @@ AnyType yams_Op_meshS::operator( )(Stack stack) const { // recuperer la solution ???? if (verbosity > 10) { - cout << &yamsmesh->point << " " << &yamsmesh->tria << " " << &yamsmesh->geom << " " - << &yamsmesh->tgte << endl; + cout << &yamsmesh->point << " " << &yamsmesh->tria << " " << &yamsmesh->geom << " " << &yamsmesh->tgte << endl; cout << &yamsmesh << endl; } @@ -902,29 +887,17 @@ class yams_Op_mesh3 : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: yams_Op_mesh3(const basicAC_F0 &args) : sol(args.size( ) - 1) { @@ -979,8 +952,7 @@ class yams_Op_mesh3 : public E_F0mps { break; default: - CompileError( - " 3D solution for yams is a scalar (1 comp) or a symmetric tensor (6 comp)"); + CompileError(" 3D solution for yams is a scalar (1 comp) or a symmetric tensor (6 comp)"); break; } } else { @@ -1206,8 +1178,7 @@ AnyType yams_Op_mesh3::operator( )(Stack stack) const { // Th3_T->getTypeMesh3()=1; // recuperer la solution ???? if (verbosity > 10) { - cout << &yamsmesh->point << " " << &yamsmesh->tria << " " << &yamsmesh->geom << " " - << &yamsmesh->tgte << endl; + cout << &yamsmesh->point << " " << &yamsmesh->tria << " " << &yamsmesh->geom << " " << &yamsmesh->tgte << endl; cout << &yamsmesh << endl; } diff --git a/plugin/seq/funcTemplate.cpp b/plugin/seq/funcTemplate.cpp index b9e9a6591..5d9dd2f16 100644 --- a/plugin/seq/funcTemplate.cpp +++ b/plugin/seq/funcTemplate.cpp @@ -105,15 +105,13 @@ double CppModTemplate6(KN< double > *const &A, // OUT double CppModTemplate7(KN< double > *const &A, // OUTPUT KN< double > *const &B, KN< double > *const &C, // INPUTS - KN< double > *const &D, KN< double > *const &E, KN< double > *const &F, - KN< double > *const &G) { + KN< double > *const &D, KN< double > *const &E, KN< double > *const &F, KN< double > *const &G) { int nn = A->N( ); // get number of nodes cout << "nn: " << nn << endl; for (int i = 0; i < nn; i++) { - (*(A[0] + i)) = - (*(B[0] + i)) * (*(C[0] + i)) * (*(D[0] + i)) * (*(E[0] + i)) * (*(F[0] + i)) * (*(G[0] + i)); + (*(A[0] + i)) = (*(B[0] + i)) * (*(C[0] + i)) * (*(D[0] + i)) * (*(E[0] + i)) * (*(F[0] + i)) * (*(G[0] + i)); cout << (*(A[0] + i)) << endl; } @@ -122,15 +120,13 @@ double CppModTemplate7(KN< double > *const &A, // OUT double CppModTemplate8(KN< double > *const &A, // OUTPUT KN< double > *const &B, KN< double > *const &C, // INPUTS - KN< double > *const &D, KN< double > *const &E, KN< double > *const &F, - KN< double > *const &G, KN< double > *const &H) { + KN< double > *const &D, KN< double > *const &E, KN< double > *const &F, KN< double > *const &G, KN< double > *const &H) { int nn = A->N( ); // get number of nodes cout << "nn: " << nn << endl; for (int i = 0; i < nn; i++) { - (*(A[0] + i)) = (*(B[0] + i)) * (*(C[0] + i)) * (*(D[0] + i)) * (*(E[0] + i)) * (*(F[0] + i)) * - (*(G[0] + i)) * (*(H[0] + i)); + (*(A[0] + i)) = (*(B[0] + i)) * (*(C[0] + i)) * (*(D[0] + i)) * (*(E[0] + i)) * (*(F[0] + i)) * (*(G[0] + i)) * (*(H[0] + i)); cout << (*(A[0] + i)) << endl; } @@ -175,28 +171,13 @@ static void Load_Init( ) { Global.Add("funcs1", "(", new OneOperator1s_< double, double >(funcs1)); Global.Add("funcs2", "(", new OneOperator2s_< double, double, double >(funcs2)); Global.Add("funcs3", "(", new OneOperator3s_< double, double, double, double >(funcs3)); - Global.Add( - "CppModTemplate3", "(", - new OneOperator3_< double, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate3)); - Global.Add( - "CppModTemplate4", "(", - new OneOperator4_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > * >( - CppModTemplate4)); - Global.Add("CppModTemplate5", "(", - new OneOperator5_< double, KN< double > *, KN< double > *, KN< double > *, - KN< double > *, KN< double > * >(CppModTemplate5)); - Global.Add("CppModTemplate6", "(", - new OneOperator6_< double, KN< double > *, KN< double > *, KN< double > *, - KN< double > *, KN< double > *, KN< double > * >(CppModTemplate6)); - Global.Add( - "CppModTemplate7", "(", - new OneOperator7_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, - KN< double > *, KN< double > *, KN< double > * >(CppModTemplate7)); - Global.Add( - "CppModTemplate8", "(", - new OneOperator8_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, - KN< double > *, KN< double > *, KN< double > *, KN< double > * >( - CppModTemplate8)); + Global.Add("CppModTemplate3", "(", new OneOperator3_< double, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate3)); + Global.Add("CppModTemplate4", "(", new OneOperator4_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate4)); + Global.Add("CppModTemplate5", "(", new OneOperator5_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate5)); + Global.Add("CppModTemplate6", "(", new OneOperator6_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate6)); + Global.Add("CppModTemplate7", "(", new OneOperator7_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate7)); + Global.Add("CppModTemplate8", "(", + new OneOperator8_< double, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > *, KN< double > * >(CppModTemplate8)); Global.Add("test", "(", new OneOperator1s_< double, pferarray >(mytest)); } diff --git a/plugin/seq/geophysics.cpp b/plugin/seq/geophysics.cpp index 6f6910fd4..8ea81564e 100644 --- a/plugin/seq/geophysics.cpp +++ b/plugin/seq/geophysics.cpp @@ -31,8 +31,7 @@ class Data2D { template< char T > Data2D< T > *init_Data2D(Data2D< T > *const &a, string *const &s) { - if (verbosity) - cout << "Reading " << (T == 'M' ? "Marmousi" : "BPSalt") << " Model file " << *s << endl; + if (verbosity) cout << "Reading " << (T == 'M' ? "Marmousi" : "BPSalt") << " Model file " << *s << endl; a->file = new string(*s); ifstream f((*a->file).c_str( ), ios::in | ios::binary); @@ -69,8 +68,7 @@ Data2D< T > *init_Data2D(Data2D< T > *const &a, string *const &s) { int ix, iy, iz; for (iy = 0; iy < a->mo_file_ny; iy++) - for (ix = 0; ix < a->mo_file_nx; ix++) - (*a->tab)(ix, a->mo_file_ny - 1 - iy) = buff[a->mo_file_ny * ix + iy]; + for (ix = 0; ix < a->mo_file_nx; ix++) (*a->tab)(ix, a->mo_file_ny - 1 - iy) = buff[a->mo_file_ny * ix + iy]; delete[] buff; if (T == 'S') (*a->tab) /= 1000.0; @@ -144,9 +142,7 @@ Overthrust3d *init_Overthrust3d(Overthrust3d *const &a, string *const &s) { for (iz = 0; iz < a->mo_file_nz; iz++) for (iy = 0; iy < a->mo_file_ny; iy++) - for (ix = 0; ix < a->mo_file_nx; ix++) - (*a->tab)(ix, iy, a->mo_file_nz - 1 - iz) = - buff[a->mo_file_nx * a->mo_file_ny * iz + a->mo_file_nx * iy + ix]; + for (ix = 0; ix < a->mo_file_nx; ix++) (*a->tab)(ix, iy, a->mo_file_nz - 1 - iz) = buff[a->mo_file_nx * a->mo_file_ny * iz + a->mo_file_nx * iy + ix]; delete[] buff; @@ -154,8 +150,7 @@ Overthrust3d *init_Overthrust3d(Overthrust3d *const &a, string *const &s) { return a; } -double Overthrust3d_eval(Overthrust3d *const &a, const double &xi, const double &yi, - const double &zi) { +double Overthrust3d_eval(Overthrust3d *const &a, const double &xi, const double &yi, const double &zi) { int ix = a->mo_file_nx * (xi - a->mo_file_xstart) / (a->mo_file_xend - a->mo_file_xstart); int iy = a->mo_file_ny * (yi - a->mo_file_ystart) / (a->mo_file_yend - a->mo_file_ystart); int iz = a->mo_file_nz * (zi - a->mo_file_zstart) / (a->mo_file_zend - a->mo_file_zstart); @@ -187,7 +182,7 @@ class Crustal3d { } }; -Crustal3d *init_Crustal3d(Crustal3d *const &a, string *const &s, KN *const& bounds) { +Crustal3d *init_Crustal3d(Crustal3d *const &a, string *const &s, KN< double > *const &bounds) { if (verbosity) cout << "Reading Crustal Model file " << *s << endl; a->file = new string(*s); @@ -199,45 +194,44 @@ Crustal3d *init_Crustal3d(Crustal3d *const &a, string *const &s, KN *con double h = 0.1; - KN& bnds = *bounds; + KN< double > &bnds = *bounds; - int ixl = max(0,min(1020,(int)floor(bnds[0]/h-1))); - int ixu = max(0,min(1020,(int)ceil(bnds[1]/h+1))); - int iyl = max(0,min(200,(int)floor(bnds[2]/h-1))); - int iyu = max(0,min(200,(int)ceil(bnds[3]/h+1))); - int izl = max(0,min(283,(int)floor((28.3+bnds[4])/h-1))); - int izu = max(0,min(283,(int)ceil((28.3+bnds[5])/h+1))); + int ixl = max(0, min(1020, (int)floor(bnds[0] / h - 1))); + int ixu = max(0, min(1020, (int)ceil(bnds[1] / h + 1))); + int iyl = max(0, min(200, (int)floor(bnds[2] / h - 1))); + int iyu = max(0, min(200, (int)ceil(bnds[3] / h + 1))); + int izl = max(0, min(283, (int)floor((28.3 + bnds[4]) / h - 1))); + int izu = max(0, min(283, (int)ceil((28.3 + bnds[5]) / h + 1))); - int nx = ixu-ixl+1; - int ny = iyu-iyl+1; - int nz = izu-izl+1; + int nx = ixu - ixl + 1; + int ny = iyu - iyl + 1; + int nz = izu - izl + 1; - int sz = nx*ny*nz; + int sz = nx * ny * nz; a->mo_file_nx = nx; - a->mo_file_xstart = ixl*h; - a->mo_file_xend = ixu*h; - a->mo_file_dx = (a->mo_file_xend - a->mo_file_xstart)/(a->mo_file_nx-1); + a->mo_file_xstart = ixl * h; + a->mo_file_xend = ixu * h; + a->mo_file_dx = (a->mo_file_xend - a->mo_file_xstart) / (a->mo_file_nx - 1); a->mo_file_ny = ny; - a->mo_file_ystart = iyl*h; - a->mo_file_yend = iyu*h; - a->mo_file_dy = (a->mo_file_yend - a->mo_file_ystart)/(a->mo_file_ny-1); + a->mo_file_ystart = iyl * h; + a->mo_file_yend = iyu * h; + a->mo_file_dy = (a->mo_file_yend - a->mo_file_ystart) / (a->mo_file_ny - 1); a->mo_file_nz = nz; - a->mo_file_zstart = -28.3+izl*h; - a->mo_file_zend = -28.3+izu*h; - a->mo_file_dz = (a->mo_file_zend - a->mo_file_zstart)/(a->mo_file_nz-1); + a->mo_file_zstart = -28.3 + izl * h; + a->mo_file_zend = -28.3 + izu * h; + a->mo_file_dz = (a->mo_file_zend - a->mo_file_zstart) / (a->mo_file_nz - 1); int ix, iy, iz; - a->tab = new KNMK< float >(nx,ny,nz); + a->tab = new KNMK< float >(nx, ny, nz); float *buff = new float[nz]; for (iy = 0; iy < a->mo_file_ny; iy++) for (ix = 0; ix < a->mo_file_nx; ix++) { - f.seekg((284L * 1021L * (long)(iy+iyl) + 284L * (long)(ix+ixl) + (long)(284 -1 -izu)) * (long)sizeof(float)); + f.seekg((284L * 1021L * (long)(iy + iyl) + 284L * (long)(ix + ixl) + (long)(284 - 1 - izu)) * (long)sizeof(float)); f.read((char *)buff, nz * sizeof(float)); - for (iz = 0; iz < a->mo_file_nz; iz++) - (*a->tab)(ix, iy, nz -1 -iz) = buff[iz]; + for (iz = 0; iz < a->mo_file_nz; iz++) (*a->tab)(ix, iy, nz - 1 - iz) = buff[iz]; } delete[] buff; @@ -246,11 +240,10 @@ Crustal3d *init_Crustal3d(Crustal3d *const &a, string *const &s, KN *con return a; } -double Crustal3d_eval(Crustal3d *const &a, const double &xi, const double &yi, - const double &zi) { - int ix = (a->mo_file_nx-1) * (xi - a->mo_file_xstart + a->mo_file_dx/2) / (a->mo_file_xend - a->mo_file_xstart); - int iy = (a->mo_file_ny-1) * (yi - a->mo_file_ystart + a->mo_file_dy/2) / (a->mo_file_yend - a->mo_file_ystart); - int iz = (a->mo_file_nz-1) * (zi - a->mo_file_zstart + a->mo_file_dz/2) / (a->mo_file_zend - a->mo_file_zstart); +double Crustal3d_eval(Crustal3d *const &a, const double &xi, const double &yi, const double &zi) { + int ix = (a->mo_file_nx - 1) * (xi - a->mo_file_xstart + a->mo_file_dx / 2) / (a->mo_file_xend - a->mo_file_xstart); + int iy = (a->mo_file_ny - 1) * (yi - a->mo_file_ystart + a->mo_file_dy / 2) / (a->mo_file_yend - a->mo_file_ystart); + int iz = (a->mo_file_nz - 1) * (zi - a->mo_file_zstart + a->mo_file_dz / 2) / (a->mo_file_zend - a->mo_file_zstart); ix = max(0, min(ix, a->mo_file_nx - 1)); iy = max(0, min(iy, a->mo_file_ny - 1)); iz = max(0, min(iz, a->mo_file_nz - 1)); @@ -263,31 +256,21 @@ static void Load_Init( ) { Dcl_Type< Data2D< 'M' > * >(InitP< Data2D< 'M' > >, Destroy< Data2D< 'M' > >); zzzfff->Add("Marmousi", atype< Data2D< 'M' > * >( )); - TheOperators->Add( - "<-", new OneOperator2_< Data2D< 'M' > *, Data2D< 'M' > *, string * >(&init_Data2D< 'M' >)); - atype< Data2D< 'M' > * >( )->Add( - "(", "", new OneOperator3_< double, Data2D< 'M' > *, double, double >(Data2D_eval)); + TheOperators->Add("<-", new OneOperator2_< Data2D< 'M' > *, Data2D< 'M' > *, string * >(&init_Data2D< 'M' >)); + atype< Data2D< 'M' > * >( )->Add("(", "", new OneOperator3_< double, Data2D< 'M' > *, double, double >(Data2D_eval)); Dcl_Type< Data2D< 'S' > * >(InitP< Data2D< 'S' > >, Destroy< Data2D< 'S' > >); zzzfff->Add("BPSalt", atype< Data2D< 'S' > * >( )); - TheOperators->Add( - "<-", new OneOperator2_< Data2D< 'S' > *, Data2D< 'S' > *, string * >(&init_Data2D< 'S' >)); - atype< Data2D< 'S' > * >( )->Add( - "(", "", new OneOperator3_< double, Data2D< 'S' > *, double, double >(Data2D_eval)); + TheOperators->Add("<-", new OneOperator2_< Data2D< 'S' > *, Data2D< 'S' > *, string * >(&init_Data2D< 'S' >)); + atype< Data2D< 'S' > * >( )->Add("(", "", new OneOperator3_< double, Data2D< 'S' > *, double, double >(Data2D_eval)); Dcl_Type< Overthrust3d * >(InitP< Overthrust3d >, Destroy< Overthrust3d >); zzzfff->Add("Overthrust", atype< Overthrust3d * >( )); - TheOperators->Add( - "<-", new OneOperator2_< Overthrust3d *, Overthrust3d *, string * >(&init_Overthrust3d)); - atype< Overthrust3d * >( )->Add( - "(", "", - new OneOperator4_< double, Overthrust3d *, double, double, double >(Overthrust3d_eval)); + TheOperators->Add("<-", new OneOperator2_< Overthrust3d *, Overthrust3d *, string * >(&init_Overthrust3d)); + atype< Overthrust3d * >( )->Add("(", "", new OneOperator4_< double, Overthrust3d *, double, double, double >(Overthrust3d_eval)); Dcl_Type< Crustal3d * >(InitP< Crustal3d >, Destroy< Crustal3d >); zzzfff->Add("Crustal", atype< Crustal3d * >( )); - TheOperators->Add( - "<-", new OneOperator3_< Crustal3d *, Crustal3d *, string *, KN * >(&init_Crustal3d)); - atype< Crustal3d * >( )->Add( - "(", "", - new OneOperator4_< double, Crustal3d *, double, double, double >(Crustal3d_eval)); + TheOperators->Add("<-", new OneOperator3_< Crustal3d *, Crustal3d *, string *, KN< double > * >(&init_Crustal3d)); + atype< Crustal3d * >( )->Add("(", "", new OneOperator4_< double, Crustal3d *, double, double, double >(Crustal3d_eval)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/gmsh.cpp b/plugin/seq/gmsh.cpp index 919889e9d..800bb977f 100644 --- a/plugin/seq/gmsh.cpp +++ b/plugin/seq/gmsh.cpp @@ -47,8 +47,7 @@ using namespace Fem2D; // Table of number of vertex for an element type of gmsh -static const int nvElemGmsh[30] = {2, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const int nvElemGmsh[30] = {2, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // we considerer only edges, triangles and tetrahedrons in Freefem++ // 15 :: Vertex Corner // 1 :: Edge/line @@ -88,16 +87,13 @@ class GMSH_LoadMesh_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type GMSH_LoadMesh_Op::name_param[] = {{"reftri", &typeid(long)}, - {"renum", &typeid(long)}}; +basicAC_F0::name_and_type GMSH_LoadMesh_Op::name_param[] = {{"reftri", &typeid(long)}, {"renum", &typeid(long)}}; class GMSH_LoadMesh : public OneOperator { public: GMSH_LoadMesh( ) : OneOperator(atype< pmesh >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new GMSH_LoadMesh_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new GMSH_LoadMesh_Op(args, t[0]->CastTo(args[0])); } }; Mesh *GMSH_Load(const string &filename) { @@ -157,8 +153,7 @@ Mesh *GMSH_Load(const string &filename) { if (verbosity > 1) { cout << " PhysicalNames is not considered in freefem++ " << endl; } - } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || - !strncmp(&str[1], "ParametricNodes", 15)) { + } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || !strncmp(&str[1], "ParametricNodes", 15)) { const bool parametric = !strncmp(&str[1], "ParametricNodes", 15); if (parametric == true) { cerr << " ParametricNodes is not considered yet in freefem++" << endl; @@ -249,7 +244,7 @@ Mesh *GMSH_Load(const string &filename) { // ignore any other tags for now } - if (verbosity > 99) cout << type << endl; + if (verbosity > 99) cout << type << endl; ffassert(type >= 1 && type <= 31); if ((numVertices = nvElemGmsh[type - 1]) == 0) { cerr << "Element of type " << type << " is not considered in Freefem++" << endl; @@ -281,7 +276,7 @@ Mesh *GMSH_Load(const string &filename) { int numElementsPartial = 0; while (numElementsPartial < numElements) { - int header[3] = {}; + int header[3] = { }; if (fread(header, sizeof(int), 3, fp) != 3) { exit(1); } @@ -424,8 +419,7 @@ Mesh *GMSH_Load(const string &filename) { iv1 = mapnumv[indices[1]]; iv2 = mapnumv[indices[2]]; if (verbosity > 2) { - cout << "Triangles " << it + 1 << " " << iv0 + 1 << " " << iv1 + 1 << " " << iv2 + 1 - << endl; + cout << "Triangles " << it + 1 << " " << iv0 + 1 << " " << iv1 + 1 << " " << iv2 + 1 << endl; } (ttff++)->set(vff, iv0, iv1, iv2, physical); @@ -556,15 +550,9 @@ class GMSH_LoadMesh3_Op : public E_F0mps { static const int n_name_param = 5; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } public: GMSH_LoadMesh3_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { @@ -578,11 +566,8 @@ class GMSH_LoadMesh3_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type GMSH_LoadMesh3_Op::name_param[] = {{"reftet", &typeid(long)}, - {"renum", &typeid(long)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)} +basicAC_F0::name_and_type GMSH_LoadMesh3_Op::name_param[] = { + {"reftet", &typeid(long)}, {"renum", &typeid(long)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)} }; @@ -590,13 +575,10 @@ class GMSH_LoadMesh3 : public OneOperator { public: GMSH_LoadMesh3( ) : OneOperator(atype< pmesh3 >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new GMSH_LoadMesh3_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new GMSH_LoadMesh3_Op(args, t[0]->CastTo(args[0])); } }; -Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, - double precisvertice) { +Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, double precisvertice) { // variable freefem++ int nv, nt = 0, nbe = 0, ret; Vertex3 *vff; @@ -650,8 +632,7 @@ Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, if (verbosity > 1) { cout << " PhysicalNames is not considered in freefem++ " << endl; } - } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || - !strncmp(&str[1], "ParametricNodes", 15)) { + } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || !strncmp(&str[1], "ParametricNodes", 15)) { const bool parametric = !strncmp(&str[1], "ParametricNodes", 15); if (parametric == true) { cerr << " ParametricNodes is not considered yet in FreeFem++" << endl; @@ -751,8 +732,7 @@ Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, if (type == 1) { if (i == 0) { if (verbosity > 0) { - cout << "edges in 3D mesh are not considered yet in freefem++, skeep data" - << endl; + cout << "edges in 3D mesh are not considered yet in freefem++, skeep data" << endl; } } } @@ -814,7 +794,7 @@ Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, int *indices = &data[numTags + 1]; if (type == 1 && i == 0) { - if (verbosity>0) cout << " Edges in 3D mesh are not used in FreeFem++; skip data" << endl; + if (verbosity > 0) cout << " Edges in 3D mesh are not used in FreeFem++; skip data" << endl; // exit(1); } @@ -946,7 +926,7 @@ Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, int numElementsPartial = 0; while (numElementsPartial < numElements) { - int header[3] = {}; + int header[3] = { }; if (fread(header, sizeof(int), 3, fp) != 3) { exit(1); } @@ -1030,9 +1010,9 @@ Mesh3 *GMSH_Load3(const string &filename, bool cleanmesh, bool removeduplicate, if (nt == 0) { cout << " Return type false. Your mesh is MeshS type; use gmshloadS function." << endl; ffassert(0); - + } else { - Mesh3 *Th3 = new Mesh3(nv, nt, nbe, vff, tff, bff, cleanmesh|| (nbe==0), removeduplicate,(nbe==0), precisvertice); + Mesh3 *Th3 = new Mesh3(nv, nt, nbe, vff, tff, bff, cleanmesh || (nbe == 0), removeduplicate, (nbe == 0), precisvertice); return Th3; } } @@ -1058,23 +1038,16 @@ AnyType GMSH_LoadMesh3_Op::operator( )(Stack stack) const { return Th3_t; } - -template +template< class MMesh > class GMSH_LoadMeshT_Op : public E_F0mps { public: Expression filename; static const int n_name_param = 6; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } public: GMSH_LoadMeshT_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { @@ -1088,51 +1061,32 @@ class GMSH_LoadMeshT_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -template < > -basicAC_F0::name_and_type GMSH_LoadMeshT_Op::name_param[] = { - {"reftri", &typeid(long)}, - {"renum", &typeid(long)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)}, - {"ridgeangledetection", &typeid(double) }}; - -template < > -basicAC_F0::name_and_type GMSH_LoadMeshT_Op::name_param[] = { - {"refedge", &typeid(long)}, - {"renum", &typeid(long)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)}, - {"ridgeangledetection", &typeid(double) }}; +template<> +basicAC_F0::name_and_type GMSH_LoadMeshT_Op< MeshS >::name_param[] = {{"reftri", &typeid(long)}, {"renum", &typeid(long)}, {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}, {"ridgeangledetection", &typeid(double)}}; +template<> +basicAC_F0::name_and_type GMSH_LoadMeshT_Op< MeshL >::name_param[] = {{"refedge", &typeid(long)}, {"renum", &typeid(long)}, {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}, {"ridgeangledetection", &typeid(double)}}; - -template +template< class MMesh > class GMSH_LoadMeshT : public OneOperator { public: typedef const MMesh *ppmesh; GMSH_LoadMeshT( ) : OneOperator(atype< ppmesh >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new GMSH_LoadMeshT_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new GMSH_LoadMeshT_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; +template< class MMesh > +MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, double precisvertice, double ridgeangledetection) { - -template -MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, - double precisvertice, double ridgeangledetection) { - - typedef typename MMesh::Element T; typedef typename MMesh::BorderElement B; typedef typename MMesh::Vertex V; typedef typename MMesh::Element::RdHat TRdHat; typedef typename MMesh::BorderElement::RdHat BRdHat; - - + int nv, nt = 0, nbe = 0; V *vff; @@ -1183,8 +1137,7 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, if (verbosity > 1) { cout << " PhysicalNames is not considered in freefem++ " << endl; } - } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || - !strncmp(&str[1], "ParametricNodes", 15)) { + } else if (!strncmp(&str[1], "NO", 2) || !strncmp(&str[1], "Nodes", 5) || !strncmp(&str[1], "ParametricNodes", 15)) { const bool parametric = !strncmp(&str[1], "ParametricNodes", 15); if (parametric == true) { cerr << " ParametricNodes is not considered yet in FreeFem++" << endl; @@ -1280,9 +1233,11 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, } } - if(type == 1 && is_same< MMesh, MeshS >::value) nbe++; - else if(type == 1 && is_same< MMesh, MeshL >::value) nt++; - + if (type == 1 && is_same< MMesh, MeshS >::value) + nbe++; + else if (type == 1 && is_same< MMesh, MeshL >::value) + nt++; + if (type == 2 && is_same< MMesh, MeshS >::value) nt++; if (type == 4) { @@ -1337,9 +1292,11 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, int partition = (numTags > 2) ? data[4 - numTags + 2] : 0; int *indices = &data[numTags + 1]; - if(type == 1 && is_same< MMesh, MeshS >::value) nbe++; - else if(type == 1 && is_same< MMesh, MeshL >::value) nt++; - + if (type == 1 && is_same< MMesh, MeshS >::value) + nbe++; + else if (type == 1 && is_same< MMesh, MeshL >::value) + nt++; + if (type == 2 && is_same< MMesh, MeshS >::value) nt++; if (type == 4) { @@ -1436,23 +1393,20 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, cout << "Elem " << ie + 1 << " " << iv[0] + 1 << " " << iv[1] + 1 << endl; } - if(is_same< MMesh, MeshS >::value) { - (bbff++)->set(vff, iv, physical); - ie++; - } - else if(is_same< MMesh, MeshL >::value) { - (ttff++)->set(vff, iv, physical); - it++; - } - + if (is_same< MMesh, MeshS >::value) { + (bbff++)->set(vff, iv, physical); + ie++; + } else if (is_same< MMesh, MeshL >::value) { + (ttff++)->set(vff, iv, physical); + it++; + } } if (type == 2 && is_same< MMesh, MeshS >::value) { int iv[3]; for (int i = 0; i < 3; i++) iv[i] = mapnumv[indices[i]]; if (verbosity > 2) { - cout << "Triangles " << it + 1 << " " << iv[0] + 1 << " " << iv[1] + 1 << " " - << iv[2] + 1 << endl; + cout << "Triangles " << it + 1 << " " << iv[0] + 1 << " " << iv[1] + 1 << " " << iv[2] + 1 << endl; } (ttff++)->set(vff, iv, physical); @@ -1504,9 +1458,7 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, exit(1); } - if (swap) - SwapBytes((char *)data, sizeof(int), n); - + if (swap) SwapBytes((char *)data, sizeof(int), n); int num = data[0]; int physical = (numTags > 0) ? data[4 - numTags] : 0; @@ -1517,26 +1469,25 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, if (type == 1) { int iv[2]; for (int i = 0; i < 2; i++) iv[i] = mapnumv[indices[i]]; - if(is_same< MMesh, MeshS >::value) { - (bbff++)->set(vff, iv, physical); - ie++; - } - else if(is_same< MMesh, MeshL >::value) { - double mes = -1; - (ttff++)->set(vff, iv, physical, mes); - it++; - } + if (is_same< MMesh, MeshS >::value) { + (bbff++)->set(vff, iv, physical); + ie++; + } else if (is_same< MMesh, MeshL >::value) { + double mes = -1; + (ttff++)->set(vff, iv, physical, mes); + it++; + } } if (type == 2) { double mes = -1; int iv[3]; for (int i = 0; i < 3; i++) iv[i] = mapnumv[indices[i]]; - if(is_same< MMesh, MeshS >::value) { - (ttff++)->set(vff, iv, physical, mes); - it++; - } - } + if (is_same< MMesh, MeshS >::value) { + (ttff++)->set(vff, iv, physical, mes); + it++; + } + } } delete[] data; @@ -1564,8 +1515,8 @@ MMesh *GMSH_LoadT(const string &filename, bool cleanmesh, bool removeduplicate, return Th; } -template -AnyType GMSH_LoadMeshT_Op::operator( )(Stack stack) const { +template< class MMesh > +AnyType GMSH_LoadMeshT_Op< MMesh >::operator( )(Stack stack) const { string *pffname = GetAny< string * >((*filename)(stack)); int renumsurf = 0; @@ -1573,11 +1524,11 @@ AnyType GMSH_LoadMeshT_Op::operator( )(Stack stack) const { bool cleanmesh(arg(2, stack, false)); bool removeduplicate(arg(3, stack, false)); double precisvertice(arg(4, stack, 1e-6)); - double ridgeangledetection(arg(5, stack, 8.*atan(1.)/9.)); + double ridgeangledetection(arg(5, stack, 8. * atan(1.) / 9.)); assert(renumsurf <= 1 && renumsurf >= 0); - MMesh *Th_t = GMSH_LoadT(*pffname, cleanmesh, removeduplicate, precisvertice, ridgeangledetection); + MMesh *Th_t = GMSH_LoadT< MMesh >(*pffname, cleanmesh, removeduplicate, precisvertice, ridgeangledetection); Th_t->BuildGTree( ); Add2StackOfPtr2FreeRC(stack, Th_t); @@ -1672,8 +1623,7 @@ bool SaveGMSH(pmesh3 pTh, string *filewoext) { // two tags: the label f1 << "2 " << msh.be(i).lab << " " << msh.be(i).lab << " "; // list of nodes - f1 << msh(msh.be(i)[0]) + 1 << " " << msh(msh.be(i)[1]) + 1 << " " << msh(msh.be(i)[2]) + 1 - << endl; + f1 << msh(msh.be(i)[0]) + 1 << " " << msh(msh.be(i)[1]) + 1 << " " << msh(msh.be(i)[2]) + 1 << endl; } for (int i = 0; i < msh.nt; ++i) { @@ -1682,8 +1632,7 @@ bool SaveGMSH(pmesh3 pTh, string *filewoext) { // two tags: the label f1 << "2 " << msh[i].lab << " " << msh[i].lab << " "; // list of nodes - f1 << msh(msh[i][0]) + 1 << " " << msh(msh[i][1]) + 1 << " " << msh(msh[i][2]) + 1 << " " - << msh(msh[i][3]) + 1 << endl; + f1 << msh(msh[i][0]) + 1 << " " << msh(msh[i][1]) + 1 << " " << msh(msh[i][2]) + 1 << " " << msh(msh[i][3]) + 1 << endl; } f1 << "$EndElements" << endl; @@ -1696,8 +1645,8 @@ bool SaveGMSH(pmeshS pTh, string *filewoext) { ofstream f1(file.c_str( )); if (!f1) { - cout << " Error Opening file " << file << endl; - ExecError("Error Opening file"); + cout << " Error Opening file " << file << endl; + ExecError("Error Opening file"); return 1; } @@ -1767,24 +1716,19 @@ bool SaveGMSH(pmeshL pTh, string *filewoext) { f1 << "$Elements" << endl; f1 << msh.nt << endl; - for (int i = 0; i < msh.nt; ++i) { // 1 is an edge f1 << (i + 1) << " 1 "; // two tags: the label f1 << "1 " << msh[i].lab << " "; // list of nodes - f1 << msh(msh[i][0]) + 1 << " " << msh(msh[i][1]) + 1 << endl; + f1 << msh(msh[i][0]) + 1 << " " << msh(msh[i][1]) + 1 << endl; } f1 << "$EndElements" << endl; return 0; // OK .. } - - - - static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ // if (verbosity) if (verbosity > 1 && (mpirank == 0)) { @@ -1792,13 +1736,12 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme } Global.Add("gmshload3", "(", new GMSH_LoadMesh3); - Global.Add("gmshloadS", "(", new GMSH_LoadMeshT); - Global.Add("gmshloadL", "(", new GMSH_LoadMeshT); + Global.Add("gmshloadS", "(", new GMSH_LoadMeshT< MeshS >); + Global.Add("gmshloadL", "(", new GMSH_LoadMeshT< MeshL >); Global.Add("gmshload", "(", new GMSH_LoadMesh); Global.Add("savegmsh", "(", new OneOperator2< bool, pmesh3, string * >(SaveGMSH)); Global.Add("savegmsh", "(", new OneOperator2< bool, pmeshS, string * >(SaveGMSH)); Global.Add("savegmsh", "(", new OneOperator2< bool, pmeshL, string * >(SaveGMSH)); - } LOADFUNC(Load_Init) diff --git a/plugin/seq/gsl.cpp b/plugin/seq/gsl.cpp index e9b09630a..9163a3e3e 100644 --- a/plugin/seq/gsl.cpp +++ b/plugin/seq/gsl.cpp @@ -93,10 +93,7 @@ struct GSLInterpolation { static const cgsl_interpp gsl_interp_steffen = gsl_interp_cspline; #endif - static cgsl_interpp interp[] = {gsl_interp_cspline, gsl_interp_akima, - gsl_interp_steffen, gsl_interp_linear, - gsl_interp_polynomial, gsl_interp_cspline_periodic, - gsl_interp_akima_periodic}; + static cgsl_interpp interp[] = {gsl_interp_cspline, gsl_interp_akima, gsl_interp_steffen, gsl_interp_linear, gsl_interp_polynomial, gsl_interp_cspline_periodic, gsl_interp_akima_periodic}; if (INIT) { destroy( ); } @@ -115,9 +112,7 @@ struct GSLInterpolation { gsl_spline_init(spline, xy, xy + n, n); } - void init(const KNM_< double > &kxy, bool INIT = false, long cas = 0) { - init(kxy(0, ':'), kxy(1, ':'), INIT, cas); - } + void init(const KNM_< double > &kxy, bool INIT = false, long cas = 0) { init(kxy(0, ':'), kxy(1, ':'), INIT, cas); } void init(GSLInterpolation *g, bool INIT = false) { if (INIT) { @@ -185,20 +180,17 @@ GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, KNM_< doubl return gi; } -GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, KN_< double > const &a, - KN_< double > const &b) { +GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, KN_< double > const &a, KN_< double > const &b) { gi->init(a, b, true); return gi; } -GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, - KNM_< double > const &a) { +GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, KNM_< double > const &a) { gi->init(a, true, cas); return gi; } -GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, - KN_< double > const &a, KN_< double > const &b) { +GSLInterpolation *init_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, KN_< double > const &a, KN_< double > const &b) { gi->init(a, b, true, cas); return gi; } @@ -213,20 +205,17 @@ GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, GSLInterpola return gi; } -GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, KN_< double > const &a, - KN_< double > const &b) { +GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, KN_< double > const &a, KN_< double > const &b) { gi->init(a, b, false); return gi; } -GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, - KNM_< double > const &a) { +GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, KNM_< double > const &a) { gi->init(a, false, cas); return gi; } -GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, - KN_< double > const &a, KN_< double > const &b) { +GSLInterpolation *set_GSLInterpolation(GSLInterpolation *const &gi, long const &cas, KN_< double > const &a, KN_< double > const &b) { gi->init(a, b, false, cas); return gi; } @@ -333,9 +322,7 @@ long gsl_rng_set(gsl_rng **pr, long s) { return 0; } -string *gsl_name(Stack s, const gsl_rng_type *const &pr) { - return Add2StackOfPtr2Free(s, new string((*pr).name)); -} +string *gsl_name(Stack s, const gsl_rng_type *const &pr) { return Add2StackOfPtr2Free(s, new string((*pr).name)); } long ngslrng = 0; long gslabort = 1; @@ -349,8 +336,7 @@ extern "C" { void ffhandler(const char *reason, const char *file, int line, int gsl_errno); } void ffhandler(const char *reason, const char *file, int line, int gsl_errno) { - cerr << "\n GSL Error = " << reason << " in " << file << " at " << line << " err= " << gsl_errno - << endl; + cerr << "\n GSL Error = " << reason << " in " << file << " at " << line << " err= " << gsl_errno << endl; if (gslabort) { ExecError("Gsl errorhandler"); } @@ -358,12 +344,9 @@ void ffhandler(const char *reason, const char *file, int line, int gsl_errno) { using namespace Fem2D; static void Load_Init( ) { - Global.Add("gslpolysolvequadratic", "(", - new OneOperator2< long, KN_< double >, KN_< double > >(gslpolysolvequadratic)); - Global.Add("gslpolysolvecubic", "(", - new OneOperator2< long, KN_< double >, KN_< double > >(gslpolysolvecubic)); - Global.Add("gslpolycomplexsolve", "(", - new OneOperator2< long, KN_< double >, KN_< Complex > >(gslpolycomplexsolve)); + Global.Add("gslpolysolvequadratic", "(", new OneOperator2< long, KN_< double >, KN_< double > >(gslpolysolvequadratic)); + Global.Add("gslpolysolvecubic", "(", new OneOperator2< long, KN_< double >, KN_< double > >(gslpolysolvecubic)); + Global.Add("gslpolycomplexsolve", "(", new OneOperator2< long, KN_< double >, KN_< Complex > >(gslpolycomplexsolve)); /* spline gsl and June 2013 */ /* * Dcl_Type(::InitializePtrAdd("gslrng", atype< gsl_rng ** >( )); zzzfff->Add("gslspline", atype< GSLInterpolation * >( )); - TheOperators->Add( - "<-", new OneOperator2< gsl_rng **, gsl_rng **, const gsl_rng_type * >(init_gsl_rng_type)); - TheOperators->Add("<-", - new OneOperator2_< GSLInterpolation *, GSLInterpolation *, KNM_< double > >( - init_GSLInterpolation)); - TheOperators->Add("=", - new OneOperator2_< GSLInterpolation *, GSLInterpolation *, KNM_< double > >( - set_GSLInterpolation)); - TheOperators->Add("=", - new OneOperator2_< GSLInterpolation *, GSLInterpolation *, GSLInterpolation * >( - set_GSLInterpolation)); - - TheOperators->Add( - "<-", new OneOperator3_< GSLInterpolation *, GSLInterpolation *, KN_< double >, KN_< double > >( - init_GSLInterpolation)); - TheOperators->Add( - "<-", new OneOperator3_< GSLInterpolation *, GSLInterpolation *, long, KNM_< double > >( - init_GSLInterpolation)); - TheOperators->Add( - "<-", - new OneOperator4_< GSLInterpolation *, GSLInterpolation *, long, KN_< double >, KN_< double > >( - init_GSLInterpolation)); - Add< GSLInterpolation * >( - "(", "", new OneOperator2< double, GSLInterpolation *, double >(GSLInterpolationeval)); - Add< GSLInterpolation * >( - "d", ".", new OneOperator1< dGSLInterpolation, GSLInterpolation * >(dGSLInterpolationedef)); - Add< GSLInterpolation * >( - "dd", ".", new OneOperator1< ddGSLInterpolation, GSLInterpolation * >(ddGSLInterpolationedef)); - Add< dGSLInterpolation >( - "(", "", new OneOperator2< double, dGSLInterpolation, double >(dGSLInterpolationeval)); - Add< ddGSLInterpolation >( - "(", "", new OneOperator2< double, ddGSLInterpolation, double >(ddGSLInterpolationeval)); - - TheOperators->Add( - "=", new OneOperator2< gsl_rng **, gsl_rng **, const gsl_rng_type * >(set_gsl_rng_type)); + TheOperators->Add("<-", new OneOperator2< gsl_rng **, gsl_rng **, const gsl_rng_type * >(init_gsl_rng_type)); + TheOperators->Add("<-", new OneOperator2_< GSLInterpolation *, GSLInterpolation *, KNM_< double > >(init_GSLInterpolation)); + TheOperators->Add("=", new OneOperator2_< GSLInterpolation *, GSLInterpolation *, KNM_< double > >(set_GSLInterpolation)); + TheOperators->Add("=", new OneOperator2_< GSLInterpolation *, GSLInterpolation *, GSLInterpolation * >(set_GSLInterpolation)); + + TheOperators->Add("<-", new OneOperator3_< GSLInterpolation *, GSLInterpolation *, KN_< double >, KN_< double > >(init_GSLInterpolation)); + TheOperators->Add("<-", new OneOperator3_< GSLInterpolation *, GSLInterpolation *, long, KNM_< double > >(init_GSLInterpolation)); + TheOperators->Add("<-", new OneOperator4_< GSLInterpolation *, GSLInterpolation *, long, KN_< double >, KN_< double > >(init_GSLInterpolation)); + Add< GSLInterpolation * >("(", "", new OneOperator2< double, GSLInterpolation *, double >(GSLInterpolationeval)); + Add< GSLInterpolation * >("d", ".", new OneOperator1< dGSLInterpolation, GSLInterpolation * >(dGSLInterpolationedef)); + Add< GSLInterpolation * >("dd", ".", new OneOperator1< ddGSLInterpolation, GSLInterpolation * >(ddGSLInterpolationedef)); + Add< dGSLInterpolation >("(", "", new OneOperator2< double, dGSLInterpolation, double >(dGSLInterpolationeval)); + Add< ddGSLInterpolation >("(", "", new OneOperator2< double, ddGSLInterpolation, double >(ddGSLInterpolationeval)); + + TheOperators->Add("=", new OneOperator2< gsl_rng **, gsl_rng **, const gsl_rng_type * >(set_gsl_rng_type)); TheOperators->Add("=", new OneOperator2< gsl_rng **, gsl_rng **, gsl_rng ** >(set_gsl_cpy)); Global.Add("gslrnguniform", "(", new OneOperator1< double, gsl_rng ** >(gslrnguniform)); diff --git a/plugin/seq/ilut.cpp b/plugin/seq/ilut.cpp index 38267779e..e027b54aa 100644 --- a/plugin/seq/ilut.cpp +++ b/plugin/seq/ilut.cpp @@ -55,8 +55,7 @@ class ILUT_Matrix { long _size; public: - ILUT_Matrix(KN< long > *const &i, KN< long > *const &j, KN< double > *const &c) - : _i(*i), _j(*j), _c(*c), _nelem(c->N( )) { + ILUT_Matrix(KN< long > *const &i, KN< long > *const &j, KN< double > *const &c) : _i(*i), _j(*j), _c(*c), _nelem(c->N( )) { _size = max(i->max( ), j->max( )); ++_size; } @@ -132,9 +131,7 @@ KN< double > *apply_ilut_precond_eq(KN< double > *const &x, ILUT_Vector const &v return x; } -ILUT_Matrix make_ilut_precond(KN< long > *const &i, KN< long > *const &j, KN< double > *const &v) { - return ILUT_Matrix(i, j, v); -} +ILUT_Matrix make_ilut_precond(KN< long > *const &i, KN< long > *const &j, KN< double > *const &v) { return ILUT_Matrix(i, j, v); } ILUT_Vector apply_ilut_precond(KN< double > *const &v) { return ILUT_Vector(v); } @@ -145,14 +142,10 @@ static void Load_Init( ) { Dcl_Type< ILUT_Matrix >( ); Dcl_Type< ILUT_Vector >( ); - Global.Add("applyIlutPrecond", "(", - new OneOperator1_< ILUT_Vector, KN< double > * >(apply_ilut_precond)); - Global.Add("makeIlutPrecond", "(", - new OneOperator3_< ILUT_Matrix, KN< long > *, KN< long > *, KN< double > * >( - make_ilut_precond)); + Global.Add("applyIlutPrecond", "(", new OneOperator1_< ILUT_Vector, KN< double > * >(apply_ilut_precond)); + Global.Add("makeIlutPrecond", "(", new OneOperator3_< ILUT_Matrix, KN< long > *, KN< long > *, KN< double > * >(make_ilut_precond)); TheOperators->Add("=", new OneOperator2_< long *, long *, ILUT_Matrix >(make_ilut_precond_eq)); - TheOperators->Add( - "=", new OneOperator2_< KN< double > *, KN< double > *, ILUT_Vector >(apply_ilut_precond_eq)); + TheOperators->Add("=", new OneOperator2_< KN< double > *, KN< double > *, ILUT_Vector >(apply_ilut_precond_eq)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/iohdf5.cpp b/plugin/seq/iohdf5.cpp index f5598c975..00e0a031c 100644 --- a/plugin/seq/iohdf5.cpp +++ b/plugin/seq/iohdf5.cpp @@ -80,9 +80,7 @@ class datasolHDF5Mesh2_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: datasolHDF5Mesh2_Op(const basicAC_F0 &args) : l((args.size( ) - 2) / 2) { @@ -126,8 +124,7 @@ class datasolHDF5Mesh2_Op : public E_F0mps { } else if (args[i].left( ) == atype< E_Array >( )) { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); + CompileError("savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); } if (a0->size( ) == ddim) { @@ -168,9 +165,7 @@ class datasolHDF5Mesh2_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); } static E_F0 *f(const basicAC_F0 &args) { return new datasolHDF5Mesh2_Op(args); } @@ -295,8 +290,7 @@ AnyType datasolHDF5Mesh2_Op::operator( )(Stack stack) const { } } - Hdf5SolFile2D->WriteHdf5SolFile2DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), - tab_vfield); + Hdf5SolFile2D->WriteHdf5SolFile2DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), tab_vfield); delete[] tab_vfield; } else { // Hyp A @@ -363,8 +357,7 @@ AnyType datasolHDF5Mesh2_Op::operator( )(Stack stack) const { } } - Hdf5SolFile2D->WriteHdf5SolFile2DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), - tab_vfield); + Hdf5SolFile2D->WriteHdf5SolFile2DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), tab_vfield); delete[] tab_vfield; } } @@ -410,9 +403,7 @@ class datasolHDF5Mesh3_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: datasolHDF5Mesh3_Op(const basicAC_F0 &args) : l((args.size( ) - 2) / 2) { @@ -454,8 +445,7 @@ class datasolHDF5Mesh3_Op : public E_F0mps { } else if (args[i].left( ) == atype< E_Array >( )) { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 3D: vector solution is 3 composant, tensor solution is 6 composant"); + CompileError("savesol in 3D: vector solution is 3 composant, tensor solution is 6 composant"); } if (a0->size( ) == ddim) { @@ -495,9 +485,7 @@ class datasolHDF5Mesh3_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); } static E_F0 *f(const basicAC_F0 &args) { return new datasolHDF5Mesh3_Op(args); } @@ -595,8 +583,7 @@ AnyType datasolHDF5Mesh3_Op< v_fes >::operator( )(Stack stack) const { } } - Hdf5SolFile3D->WriteHdf5SolFile3DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), - tab_vfield); + Hdf5SolFile3D->WriteHdf5SolFile3DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), tab_vfield); delete[] tab_vfield; } @@ -645,8 +632,7 @@ AnyType datasolHDF5Mesh3_Op< v_fes >::operator( )(Stack stack) const { } } - Hdf5SolFile3D->WriteHdf5SolFile3DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), - tab_vfield); + Hdf5SolFile3D->WriteHdf5SolFile3DAddField(datafieldname, resultorder, trans, (l[ii].what - 1), tab_vfield); delete[] tab_vfield; } } diff --git a/plugin/seq/ioply.cpp b/plugin/seq/ioply.cpp index 408aeafb8..98f6e86f6 100644 --- a/plugin/seq/ioply.cpp +++ b/plugin/seq/ioply.cpp @@ -28,893 +28,796 @@ using namespace Fem2D; // Test for BigEndian // ===================== bool isBigEndian( ) { - unsigned int x = 1; - char *ptr = (char*)&x; - if (ptr[0] == 1) { - if (verbosity>1) cout << "machine is little endian" << endl; - return false; - } - else { - if (verbosity>1) cout << "machine is big endian" << endl; - return true; - } + unsigned int x = 1; + char *ptr = (char *)&x; + if (ptr[0] == 1) { + if (verbosity > 1) cout << "machine is little endian" << endl; + return false; + } else { + if (verbosity > 1) cout << "machine is big endian" << endl; + return true; + } } namespace FreeFEM { -void SwapBytes(char *array, int size, int n) { + void SwapBytes(char *array, int size, int n) { char *x = new char[size]; - + for (int i = 0; i < n; i++) { - char *a = &array[i * size]; - memcpy(x, a, size); - - for (int c = 0; c < size; c++) - a[size - 1 - c] = x[c]; + char *a = &array[i * size]; + memcpy(x, a, size); + + for (int c = 0; c < size; c++) a[size - 1 - c] = x[c]; } delete[] x; -} -} - - + } +} // namespace FreeFEM //= ============================================= // LOAD DE FICHIER .ply for meshS //= ============================================= -template +template< class MMesh > class PLY_LoadMeshT_Op : public E_F0mps { -public: - Expression filename; - static const int n_name_param = 4; // - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } - -public: - PLY_LoadMeshT_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { - if (verbosity) { - cout << "Load mesh given by PLY " << endl; - } - - args.SetNameParam(n_name_param, name_param, nargs); + public: + Expression filename; + static const int n_name_param = 4; // + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + + public: + PLY_LoadMeshT_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { + if (verbosity) { + cout << "Load mesh given by PLY " << endl; } - - AnyType operator( )(Stack stack) const; + + args.SetNameParam(n_name_param, name_param, nargs); + } + + AnyType operator( )(Stack stack) const; }; template<> -basicAC_F0::name_and_type PLY_LoadMeshT_Op< Mesh3 >::name_param[] = { - {"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; +basicAC_F0::name_and_type PLY_LoadMeshT_Op< Mesh3 >::name_param[] = {{"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; template<> -basicAC_F0::name_and_type PLY_LoadMeshT_Op< MeshS >::name_param[] = { - {"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; +basicAC_F0::name_and_type PLY_LoadMeshT_Op< MeshS >::name_param[] = {{"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; template<> -basicAC_F0::name_and_type PLY_LoadMeshT_Op< MeshL >::name_param[] = { - {"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; - - +basicAC_F0::name_and_type PLY_LoadMeshT_Op< MeshL >::name_param[] = {{"swap", &typeid(bool)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precisvertice", &typeid(double)}}; template< class MMesh > class PLY_LoadMeshT : public OneOperator { -public: - typedef const MMesh *ppmesh; - PLY_LoadMeshT( ) : OneOperator(atype< ppmesh >( ), atype< string * >( )) {} - - E_F0 *code(const basicAC_F0 &args) const { - return new PLY_LoadMeshT_Op< MMesh >(args, t[0]->CastTo(args[0])); - } + public: + typedef const MMesh *ppmesh; + PLY_LoadMeshT( ) : OneOperator(atype< ppmesh >( ), atype< string * >( )) {} + + E_F0 *code(const basicAC_F0 &args) const { return new PLY_LoadMeshT_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; template< class MMesh > -MMesh *PLY_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, - double precisvertice) { - - typedef typename MMesh::Element T; - typedef typename MMesh::BorderElement B; - typedef typename MMesh::Vertex V; - - int nv, nt = 0, nbe = 0; - int nerr = 0; - char *res; - char buffer[256], buffer2[256], buffer3[256]; - - FILE *fp = fopen(filename.c_str( ), "rb"); - if (!fp) { - cerr << "Unable to open file " << filename.c_str( ) << endl; - ExecError("Unable to open ply file"); - } - fscanf(fp, "%s", buffer); // file identifiant - if (strcmp(buffer, "ply")){ - cout << "Invalid ply file id" << endl; - ExecError("Invalid ply file id"); - } - - // variable to check info given - bool havelabVert = false, havelabElem = false, havelabBdElem = false; //label - bool havecolorVert = false, havecolorElem = false, havecolorBdElem = false; // color in RGB - bool haveElem = false, haveBdElem = false, indexVertFace = false; // vertice index given by a uchar - bool haveNormal = false, haveMaterialIndex = false;// normals, material property, amount of transparency - bool haveTransparencyVert = false, haveTransparencyElem = false, haveTransparencyBdElem = false; - bool end_header = false; - int datasize=0; // properties of coordinates - - - double version; - if (fscanf(fp, "%s %s %lf", buffer, buffer2, &version) != 3) { - cout << "error in reading header ply file" << endl; - ExecError("error in reading header ply file"); - } - - if (version > 1.){ - cout << "only PLY format version 1.0 supported" << endl; - ExecError("only PLY format version 1.0 supported"); - } - - // data formats: ascii / binary_little_endian / binary_big_endian - // swap = bigEndian or not bigEndian - bool binary = false, swap=false; - - if (!strcmp(buffer2, "binary_little_endian")) { - binary = true; - swap = bigEndian ? 1 : 0; - - } - else if (!strcmp(buffer2, "binary_big_endian")) { - binary = true; - swap = bigEndian ? 0 : 1; +MMesh *PLY_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, double precisvertice) { + + typedef typename MMesh::Element T; + typedef typename MMesh::BorderElement B; + typedef typename MMesh::Vertex V; + + int nv, nt = 0, nbe = 0; + int nerr = 0; + char *res; + char buffer[256], buffer2[256], buffer3[256]; + + FILE *fp = fopen(filename.c_str( ), "rb"); + if (!fp) { + cerr << "Unable to open file " << filename.c_str( ) << endl; + ExecError("Unable to open ply file"); + } + fscanf(fp, "%s", buffer); // file identifiant + if (strcmp(buffer, "ply")) { + cout << "Invalid ply file id" << endl; + ExecError("Invalid ply file id"); + } + + // variable to check info given + bool havelabVert = false, havelabElem = false, havelabBdElem = false; // label + bool havecolorVert = false, havecolorElem = false, havecolorBdElem = false; // color in RGB + bool haveElem = false, haveBdElem = false, indexVertFace = false; // vertice index given by a uchar + bool haveNormal = false, haveMaterialIndex = false; // normals, material property, amount of transparency + bool haveTransparencyVert = false, haveTransparencyElem = false, haveTransparencyBdElem = false; + bool end_header = false; + int datasize = 0; // properties of coordinates + + double version; + if (fscanf(fp, "%s %s %lf", buffer, buffer2, &version) != 3) { + cout << "error in reading header ply file" << endl; + ExecError("error in reading header ply file"); + } + + if (version > 1.) { + cout << "only PLY format version 1.0 supported" << endl; + ExecError("only PLY format version 1.0 supported"); + } + + // data formats: ascii / binary_little_endian / binary_big_endian + // swap = bigEndian or not bigEndian + bool binary = false, swap = false; + + if (!strcmp(buffer2, "binary_little_endian")) { + binary = true; + swap = bigEndian ? 1 : 0; + + } else if (!strcmp(buffer2, "binary_big_endian")) { + binary = true; + swap = bigEndian ? 0 : 1; + } + + // read header + while (!end_header) { + + fscanf(fp, "%s", buffer); + if (!strcmp(buffer, "end_header")) end_header = true; + + // skip comment: information about the data + // element description + if (!strcmp(buffer, "element")) { + fscanf(fp, "%s", buffer); + if (!strcmp(buffer, "vertex")) + fscanf(fp, "%d", &nv); + else if (!strcmp(buffer, "face")) { + if (!haveElem) { + fscanf(fp, "%d", &nt); + haveElem = true; + } else { + fscanf(fp, "%d", &nbe); + haveBdElem = true; + } + + } else if (!strcmp(buffer, "edge")) { + if (haveBdElem) { + cout << "error in format border elements ply file" << endl; + ExecError("error in format border elements ply file"); + } else { + fscanf(fp, "%d", &nbe); + haveBdElem = true; + } + } } - - // read header - while (!end_header) { - + // properties about element section + if (!strcmp(buffer, "property")) { + fscanf(fp, "%s", buffer); + if (!strcmp(buffer, "float") || !strcmp(buffer, "float16")) { + fscanf(fp, "%s", buffer2); + if (!strcmp(buffer2, "x") || !strcmp(buffer, "y") || !strcmp(buffer, "z")) { + if (!datasize) + datasize = sizeof(float); + else if (datasize != sizeof(float)) { + cout << "error in format vertex ply file" << endl; + ExecError("error in reading vertex ply file"); + } + } else if (!strcmp(buffer2, "nx") || !strcmp(buffer, "ny") || !strcmp(buffer, "nz")) + haveNormal = true; + } else if (!strcmp(buffer, "double") || !strcmp(buffer, "float32")) { + fscanf(fp, "%s", buffer2); + if (!strcmp(buffer2, "x") || !strcmp(buffer, "y") || !strcmp(buffer, "z")) { + if (!datasize) + datasize = sizeof(double); + else if (datasize != sizeof(double)) { + cout << "error in format vertex ply file" << endl; + ExecError("error in reading vertex ply file"); + } + } else if (!strcmp(buffer2, "nx") || !strcmp(buffer, "ny") || !strcmp(buffer, "nz")) + haveNormal = true; + } + // description about the list provides by element + else if (!strcmp(buffer, "list")) { + fscanf(fp, "%s %s %s", buffer, buffer2, buffer3); + if (!strcmp(buffer3, "vertex_indices")) indexVertFace = true; // havelabel=true; //number of vertices for each face + } else if (!strcmp(buffer, "int")) { fscanf(fp, "%s", buffer); - if (!strcmp(buffer, "end_header")) end_header = true; - - // skip comment: information about the data - // element description - if (!strcmp(buffer, "element")) { - fscanf(fp, "%s", buffer); - if (!strcmp(buffer, "vertex")) - fscanf(fp, "%d", &nv); - else if (!strcmp(buffer, "face")) { - if(!haveElem) { - fscanf(fp, "%d", &nt); - haveElem=true;} - else { - fscanf(fp, "%d", &nbe); - haveBdElem=true;} - - } - else if (!strcmp(buffer, "edge")) { - if (haveBdElem) { - cout << "error in format border elements ply file" << endl; - ExecError("error in format border elements ply file");} - else { - fscanf(fp, "%d", &nbe); - haveBdElem=true;} - } + if (!strcmp(buffer, "flags")) { + if (nv && !nt && !nbe) + havelabVert = true; + else if (nv && nt && !nbe) + havelabElem = true; + else if (nv && nt && nbe) + havelabBdElem = true; + } + } + + // color given in section element + else if (!strcmp(buffer, "uint8") || !strcmp(buffer, "int") || !strcmp(buffer, "uchar")) { + fscanf(fp, "%s", buffer); + if (!strcmp(buffer, "red") || !strcmp(buffer, "green") || !strcmp(buffer, "blue")) { + if (nv && !nt && !nbe) + havecolorVert = true; + else if (nv && nt && !nbe) + havecolorElem = true; + else if (nv && nt && nbe) + havecolorBdElem = true; + } else if (!strcmp(buffer, "alpha")) { + if (nv && !nt && !nbe) + haveTransparencyVert = true; + else if (nv && nt && !nbe) + haveTransparencyElem = true; + else if (nv && nt && nbe) + haveTransparencyBdElem = true; + } + } + } + } + + if (verbosity > 9) { + cout << " ***** info about ply mesh ***** " << endl; + cout << " havelabVert= " << havelabVert << " havelabElem= " << havelabElem << endl; + cout << " havelabBdElem= " << havelabBdElem << endl; + cout << " havecolorVert= " << havecolorVert << " havecolorElem= " << havecolorElem << " havecolorBdElem= " << havecolorBdElem << endl; + cout << " haveNormal= " << haveNormal << " haveElem= " << haveElem << " haveBdElem= " << haveBdElem << endl; + cout << " haveMaterialIndex= " << haveMaterialIndex << endl; + } + + V *vff = new V[nv]; + T *tff = new T[nt]; + T *ttff = tff; + B *bff = new B[nbe]; + B *bbff = bff; + + // read vertex + if (verbosity > 3) cout << "Reading " << nv << " points, " << nt << " elements, " << nbe << " border element " << endl; + + int numVerts = 0; + + if (binary) { + int hack; + fscanf(fp, "%d", &hack); // hack + } + + for (int i = 0; i < nv; i++) { + if (verbosity > 9) cout << " i=" << i << endl; + double xyz[3], n[3]; + unsigned int color[3]; + if (binary) { + if (datasize == sizeof(float)) { + float f[3], nn[3]; + + if (fread(f, sizeof(float), 3, fp) != 3) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); + } + if (swap) FreeFEM::SwapBytes((char *)f, sizeof(float), 3); + + if (verbosity > 5) printf("-- xyz %d = %lf %lf %lf\n", i, f[0], f[1], f[2]); + for (int j = 0; j < 3; j++) xyz[j] = f[j]; + + // don't need + if (haveNormal) { + if (fread(nn, sizeof(float), 3, fp) != 3) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); + } } - // properties about element section - if (!strcmp(buffer, "property")) { - fscanf(fp, "%s", buffer); - if (!strcmp(buffer, "float") || !strcmp(buffer, "float16")) { - fscanf(fp, "%s", buffer2); - if (!strcmp(buffer2, "x") || !strcmp(buffer, "y") || !strcmp(buffer, "z") ) { - if(!datasize) datasize = sizeof(float); - else if(datasize!=sizeof(float) ) { - cout << "error in format vertex ply file" << endl; - ExecError("error in reading vertex ply file"); - } - } - else if (!strcmp(buffer2, "nx") || !strcmp(buffer, "ny") || !strcmp(buffer, "nz") ) - haveNormal = true; - } - else if (!strcmp(buffer, "double") || !strcmp(buffer, "float32")) { - fscanf(fp, "%s", buffer2); - if (!strcmp(buffer2, "x") || !strcmp(buffer, "y") || !strcmp(buffer, "z") ){ - if(!datasize) datasize = sizeof(double); - else if(datasize!=sizeof(double) ) { - cout << "error in format vertex ply file" << endl; - ExecError("error in reading vertex ply file"); - } - } - else if (!strcmp(buffer2, "nx") || !strcmp(buffer, "ny") || !strcmp(buffer, "nz") ) - haveNormal = true; - } - // description about the list provides by element - else if (!strcmp(buffer, "list")) { - fscanf(fp, "%s %s %s", buffer,buffer2, buffer3); - if (!strcmp(buffer3, "vertex_indices")) indexVertFace=true; //havelabel=true; //number of vertices for each face - } - else if (!strcmp(buffer, "int")) { - fscanf(fp, "%s", buffer); - if (!strcmp(buffer, "flags")) { - if (nv && !nt && !nbe) - havelabVert=true; - else if( nv && nt && !nbe) - havelabElem=true; - else if( nv && nt && nbe) - havelabBdElem=true; - } - } - - // color given in section element - else if (!strcmp(buffer, "uint8") || !strcmp(buffer, "int") || !strcmp(buffer, "uchar") ) { - fscanf(fp, "%s", buffer); - if (!strcmp(buffer, "red") || !strcmp(buffer, "green") || !strcmp(buffer, "blue")) { - if (nv && !nt && !nbe) - havecolorVert=true; - else if( nv && nt && !nbe) - havecolorElem=true; - else if( nv && nt && nbe) - havecolorBdElem=true; - } - else if (!strcmp(buffer, "alpha") ) { - if (nv && !nt && !nbe) - haveTransparencyVert=true; - else if( nv && nt && !nbe) - haveTransparencyElem=true; - else if( nv && nt && nbe) - haveTransparencyBdElem=true; - } - } - } + + } else { + if (fread(xyz, sizeof(double), 3, fp) != 3) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); } - - if (verbosity >9) { - cout << " ***** info about ply mesh ***** " << endl; - cout << " havelabVert= " << havelabVert << " havelabElem= " << havelabElem << endl; - cout << " havelabBdElem= " << havelabBdElem << endl; - cout << " havecolorVert= " << havecolorVert << " havecolorElem= " << havecolorElem << " havecolorBdElem= " << havecolorBdElem << endl; - cout << " haveNormal= " << haveNormal << " haveElem= " << haveElem << " haveBdElem= " << haveBdElem << endl; - cout << " haveMaterialIndex= " << haveMaterialIndex << endl; + if (swap) FreeFEM::SwapBytes((char *)xyz, sizeof(double), 3); + + // don't need + if (haveNormal) { + if (fread(n, sizeof(float), 3, fp) != 3) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); + } } - - V *vff = new V[nv]; - T *tff = new T[nt]; - T *ttff = tff; - B *bff = new B[nbe]; - B *bbff = bff; - - // read vertex - if (verbosity > 3) - cout << "Reading " << nv << " points, " << nt << " elements, " << nbe << " border element " << endl; - - int numVerts=0; - - if (binary) { - int hack; - fscanf(fp, "%d", &hack); // hack + } + + // don't need + if (havecolorVert) { + int color2[3]; + if (fread(color2, sizeof(char), 3, fp) != 3) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); } - - for (int i = 0; i < nv; i++) { - if (verbosity > 9) - cout << " i=" << i << endl; - double xyz[3], n[3]; - unsigned int color[3]; - if (binary) { - if (datasize == sizeof(float)) { - float f[3], nn[3]; - - if (fread(f, sizeof(float), 3, fp) != 3) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - if (swap) - FreeFEM::SwapBytes((char *)f, sizeof(float), 3); - - if (verbosity>5) - printf("-- xyz %d = %lf %lf %lf\n", i , f[0], f[1], f[2] ); - for (int j = 0; j < 3; j++) - xyz[j] = f[j]; - - // don't need - if (haveNormal) { - if (fread(nn, sizeof(float), 3, fp) != 3) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - } - - } - else { - if (fread(xyz, sizeof(double), 3, fp) != 3) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - if (swap) - FreeFEM::SwapBytes((char *)xyz, sizeof(double), 3); - - // don't need - if (haveNormal) { - if (fread(n, sizeof(float), 3, fp) != 3) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - } - } - - // don't need - if (havecolorVert) { - int color2[3]; - if (fread(color2, sizeof(char), 3, fp) != 3) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - } - // don't need - if (haveTransparencyVert) { - char transparencyVert; - if (fread(&transparencyVert, sizeof(char), 1, fp) != 1) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - } - } - else { - if (fscanf(fp, "%lf %lf %lf", &xyz[0], &xyz[1], &xyz[2]) != 3) { - cout << "error in reading PLY file (float)" << endl; - ExecError("error in reading PLY file (float)"); - } - if (haveNormal) { - if (fscanf(fp, "%lf %lf %lf\n", &n[0], &n[1], &n[2]) != 3) { - cout << "error in reading PLY file (normal)" << endl; - ExecError("error in reading PLY file"); - } - } - if (havecolorVert) { - if (fscanf(fp, "%u %u %u\n", &color[0], &color[1], &color[2]) != 3) { - cout << "error in reading ply file (color vert)" << endl; - ExecError("error in reading ply file (color vert"); - } - } - if (haveTransparencyVert) { - int transparencyVert; - if (fscanf(fp, "%d\n", &transparencyVert) != 1) { - cout << "error in reading ply file (alpha)" << endl; - ExecError("error in reading ply file (alpha)"); - } - } - } - int lab=1; - vff[i].x = xyz[0]; - vff[i].y = xyz[1]; - vff[i].z = xyz[2]; - vff[i].lab = lab; - if (verbosity > 9) - printf("xyz %d = %f %f %f\n", i , xyz[0], xyz[1], xyz[2]); + } + // don't need + if (haveTransparencyVert) { + char transparencyVert; + if (fread(&transparencyVert, sizeof(char), 1, fp) != 1) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); } - - int label[nt], ivt[T::nv], ivb[B::nv], color[3]; - - for (int it = 0; it < nt; ++it) { - label[it]=0; - if (verbosity > 9) - cout << "it=" << it << " " << nt << endl; - - if (binary) { - if (indexVertFace && (fread(&numVerts, sizeof(char), 1, fp) != 1)) { - cout << "error in reading PLY file (numVerts element)" << endl; - ExecError("error in reading PLY file (numVerts element)"); - } - if (swap) - FreeFEM::SwapBytes((char *)&numVerts, sizeof(int), 1); - if (verbosity > 9) - cout << "numVerts= " << numVerts << endl; - - if (fread(ivt, sizeof(int), numVerts, fp) != numVerts) { - cout << "error in reading PLY file (element)" << endl; - ExecError("error in reading PLY file (element)"); - } - if(verbosity>5 && T::nv==4) - cout << "test " << ivt[0] << " " <5 && T::nv==3) - cout << "test " << ivt[0] << " " <5) - cout << " numVerts test " << numVerts << endl; - ffassert(numVerts==T::nv); - - for (int j = 0; j < numVerts; ++j) { - if (fscanf(fp, "%d", &ivt[j]) != 1) { - cout << "error in reading PLY file (element)" << endl; - ExecError("error in reading PLY file (element)'"); - } - if (verbosity > 9) - cout << " ivt[j]" << ivt[j] << endl; - } - if (havelabElem && (fscanf(fp, "%d", &label[it]) != 1) ){ - cout << "error in reading PLY file (lab element)" << endl; - ExecError("error in reading PLY file (lab element)"); - } - - if (havelabElem && verbosity > 9) - cout << " label[it]" << label[it] << endl; - if (havecolorElem) - fscanf(fp, "%d %d %d", &color[0], &color[1], &color[2]); - - if (haveTransparencyElem) { - int transparencyElem; - fscanf(fp, "%d", &transparencyElem); - } - } - - (ttff++)->set(vff, ivt, label[it]); + } + } else { + if (fscanf(fp, "%lf %lf %lf", &xyz[0], &xyz[1], &xyz[2]) != 3) { + cout << "error in reading PLY file (float)" << endl; + ExecError("error in reading PLY file (float)"); + } + if (haveNormal) { + if (fscanf(fp, "%lf %lf %lf\n", &n[0], &n[1], &n[2]) != 3) { + cout << "error in reading PLY file (normal)" << endl; + ExecError("error in reading PLY file"); } - - if(B::nv==2) { - for (int ibe = 0; ibe < nbe; ++ibe) { - - if(binary) { - if (fread(ivb, sizeof(int), 2, fp) != 2) { - cout << "error in reading PLY file (edge)" << endl; - ExecError("error in reading PLY file (edge)"); - } - if (swap) - FreeFEM::SwapBytes((char *)ivb, sizeof(int), 2); - // don't need - if (havecolorBdElem && (fread(color, sizeof(int), 3, fp) != 3) ) { - cout << "error in reading PLY file (edge)" << endl; - ExecError("error in reading ply file (edge)"); - } - // don't need - if (haveTransparencyVert) { - int transparencyBdElem; - if (fread(&transparencyBdElem, sizeof(int), 1, fp) != 1) { - cout << "error in reading PLY file" << endl; - ExecError("error in reading PLY file"); - } - } - } - else { - if (fscanf(fp, "%d %d", &ivb[0], &ivb[1]) != 2) { - cout << "error in reading edge PLY files " << endl; - ExecError("error in reading edge PLY file"); - } - if (verbosity>5) - cout << "test ivb " <set(vff, ivb, lab); - } + } + if (havecolorVert) { + if (fscanf(fp, "%u %u %u\n", &color[0], &color[1], &color[2]) != 3) { + cout << "error in reading ply file (color vert)" << endl; + ExecError("error in reading ply file (color vert"); } - else if(B::nv==3) { - - for (int ibe = 0; ibe < nbe; ++ibe) { - label[ibe]=0; - if (verbosity > 9) - cout << "ibe=" << ibe << " " << nbe << endl; - - if (binary) { - if (indexVertFace && (fread(&numVerts, sizeof(char), 1, fp) != 1)) { - cout << "error in reading PLY file (numVerts element)" << endl; - ExecError("error in reading PLY file (numVerts element)"); - } - - if (swap) - FreeFEM::SwapBytes((char *)&numVerts, sizeof(int), 1); - if (verbosity > 9) - cout << "numVerts= " << numVerts << endl; - - if (fread(ivb, sizeof(int), numVerts, fp) != numVerts) { - cout << "error in reading PLY file (element)" << endl; - ExecError("error in reading PLY file (element)"); - } - if(verbosity>5) - cout << "test " << ivb[0] << " " <5) - cout << " numVerts test " << numVerts << endl; - ffassert(numVerts==B::nv); /////// pb - - for (int j = 0; j < numVerts; ++j) { - if (fscanf(fp, "%d", &ivb[j]) != 1) { - cout << "error in reading PLY file (element)" << endl; - ExecError("error in reading PLY file (element)'"); - } - if (verbosity > 9) - cout << " ivb[j]" << ivb[j] << endl; //// - } - if (havelabElem && (fscanf(fp, "%d", &label[ibe]) != 1) ){ - cout << "error in reading PLY file (lab element)" << endl; - ExecError("error in reading PLY file (lab element)"); - } - - if (havelabElem && verbosity > 9) - cout << " label[it]" << label[ibe] << endl; - if (havecolorElem) - fscanf(fp, "%d %d %d", &color[0], &color[1], &color[2]); - - if (haveTransparencyElem) { - int transparencyElem; - fscanf(fp, "%d", &transparencyElem); - } - } - (bbff++)->set(vff, ivb, label[ibe]); - } + } + if (haveTransparencyVert) { + int transparencyVert; + if (fscanf(fp, "%d\n", &transparencyVert) != 1) { + cout << "error in reading ply file (alpha)" << endl; + ExecError("error in reading ply file (alpha)"); + } + } } - fclose(fp); - MMesh *pTh = new MMesh(nv, nt, nbe, vff, tff, bff, cleanmesh, removeduplicate, precisvertice); - return pTh; + int lab = 1; + vff[i].x = xyz[0]; + vff[i].y = xyz[1]; + vff[i].z = xyz[2]; + vff[i].lab = lab; + if (verbosity > 9) printf("xyz %d = %f %f %f\n", i, xyz[0], xyz[1], xyz[2]); + } + + int label[nt], ivt[T::nv], ivb[B::nv], color[3]; + + for (int it = 0; it < nt; ++it) { + label[it] = 0; + if (verbosity > 9) cout << "it=" << it << " " << nt << endl; + + if (binary) { + if (indexVertFace && (fread(&numVerts, sizeof(char), 1, fp) != 1)) { + cout << "error in reading PLY file (numVerts element)" << endl; + ExecError("error in reading PLY file (numVerts element)"); + } + if (swap) FreeFEM::SwapBytes((char *)&numVerts, sizeof(int), 1); + if (verbosity > 9) cout << "numVerts= " << numVerts << endl; + + if (fread(ivt, sizeof(int), numVerts, fp) != numVerts) { + cout << "error in reading PLY file (element)" << endl; + ExecError("error in reading PLY file (element)"); + } + if (verbosity > 5 && T::nv == 4) + cout << "test " << ivt[0] << " " << ivt[1] << " " << ivt[2] << " " << ivt[3] << endl; + else if (verbosity > 5 && T::nv == 3) + cout << "test " << ivt[0] << " " << ivt[1] << " " << ivt[2] << endl; + + if (swap) FreeFEM::SwapBytes((char *)ivt, sizeof(int), numVerts); + + if (havelabElem) { + + if (fread(&label[it], sizeof(int), 1, fp) != 1) { + cout << "error in reading PLY file (lab element) " << endl; + ExecError("error in reading PLY file (lab element)"); + } + if (swap) FreeFEM::SwapBytes((char *)&label[it], sizeof(int), 1); + } + // don't need + if (havecolorElem) { + char color2[3]; + if (fread(color2, sizeof(char), 3, fp) != 3) { + cout << "error in reading PLY file (color element)" << endl; + ExecError("error in reading PLY file (color element)"); + } + } + // don't need + if (haveTransparencyVert) { + char transparencyElem; + if (fread(&transparencyElem, sizeof(char), 1, fp) != 1) { + cout << "error in reading PLY file (transparency element)" << endl; + ExecError("error in reading PLY file (transparency element)"); + } + } } - - - template - AnyType PLY_LoadMeshT_Op< MMesh >::operator( )(Stack stack) const { - string *pffname = GetAny< string * >((*filename)(stack)); - bool swap(arg(0, stack, false)); - bool cleanmesh(arg(1, stack, false)); - bool removeduplicate(arg(2, stack, false)); - double precisvertice(arg(3, stack, 1e-6)); - - MMesh *Th = PLY_LoadT(*pffname, swap, cleanmesh, removeduplicate, precisvertice); - Add2StackOfPtr2FreeRC(stack, Th); - return Th; + + else { + if (indexVertFace && (fscanf(fp, "%d", &numVerts) != 1)) { + + cout << "error in reading PLY file (numVerts element)" << endl; + ExecError("error in reading PLY file (numVerts element)"); + } + if (verbosity > 5) cout << " numVerts test " << numVerts << endl; + ffassert(numVerts == T::nv); + + for (int j = 0; j < numVerts; ++j) { + if (fscanf(fp, "%d", &ivt[j]) != 1) { + cout << "error in reading PLY file (element)" << endl; + ExecError("error in reading PLY file (element)'"); + } + if (verbosity > 9) cout << " ivt[j]" << ivt[j] << endl; + } + if (havelabElem && (fscanf(fp, "%d", &label[it]) != 1)) { + cout << "error in reading PLY file (lab element)" << endl; + ExecError("error in reading PLY file (lab element)"); + } + + if (havelabElem && verbosity > 9) cout << " label[it]" << label[it] << endl; + if (havecolorElem) fscanf(fp, "%d %d %d", &color[0], &color[1], &color[2]); + + if (haveTransparencyElem) { + int transparencyElem; + fscanf(fp, "%d", &transparencyElem); + } } - - template< class MMesh > - class PLY_WriteMeshT_Op : public E_F0mps { - public: - typedef long Result; - Expression eTh; - typedef const MMesh *ppmesh; - Expression filename; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; + + (ttff++)->set(vff, ivt, label[it]); + } + + if (B::nv == 2) { + for (int ibe = 0; ibe < nbe; ++ibe) { + + if (binary) { + if (fread(ivb, sizeof(int), 2, fp) != 2) { + cout << "error in reading PLY file (edge)" << endl; + ExecError("error in reading PLY file (edge)"); } - - public: - PLY_WriteMeshT_Op(const basicAC_F0 &args) { - - if ((std::is_same< MMesh, Mesh3 >::value) && verbosity > 2) - cout << "Write Mesh3 in PLY Format" << endl; - else if ((std::is_same< MMesh, MeshS >::value) && verbosity > 2) - cout << "Write MeshS in PLY Format" << endl; - else if ((std::is_same< MMesh, MeshL >::value) && verbosity > 2) - cout << "Write MeshL in PLY Format" << endl; - args.SetNameParam(n_name_param, name_param, nargs); - if (BCastTo< string * >(args[0])) - filename = CastTo< string * >(args[0]); - if (BCastTo< ppmesh >(args[1])) - eTh = CastTo< ppmesh >(args[1]); + if (swap) FreeFEM::SwapBytes((char *)ivb, sizeof(int), 2); + // don't need + if (havecolorBdElem && (fread(color, sizeof(int), 3, fp) != 3)) { + cout << "error in reading PLY file (edge)" << endl; + ExecError("error in reading ply file (edge)"); } - - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); + // don't need + if (haveTransparencyVert) { + int transparencyBdElem; + if (fread(&transparencyBdElem, sizeof(int), 1, fp) != 1) { + cout << "error in reading PLY file" << endl; + ExecError("error in reading PLY file"); + } } - static E_F0 *f(const basicAC_F0 &args) { return new PLY_WriteMeshT_Op(args); } - - AnyType operator( )(Stack stack) const; - }; - - template<> - basicAC_F0::name_and_type PLY_WriteMeshT_Op::name_param[] = { - {"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; - template<> - basicAC_F0::name_and_type PLY_WriteMeshT_Op::name_param[] = { - {"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; - template<> - basicAC_F0::name_and_type PLY_WriteMeshT_Op::name_param[] = { - {"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; - - - template< class MMesh > - void PLY_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool binary, int datasize, - bool bigEndian) { - - typedef typename MMesh::Element T; - typedef typename MMesh::BorderElement B; - typedef typename MMesh::Vertex V; - - bool swap = bigEndian ? 1 : 0; - - fprintf(fp, "ply\n"); - if (binary && !bigEndian) - fprintf(fp, "format binary_little_endian 1.0\n"); - else if (binary && bigEndian) - fprintf(fp, "format binary_big_endian 1.0\n"); - else - fprintf(fp, "format ascii 1.0\n"); - - fprintf(fp, "comment generated by FreeFEM, %s\n", filename.c_str( )); - fprintf(fp, "element vertex %d\n", Th.nv); - if (datasize == sizeof(float)) { - fprintf(fp, "property float x\n"); - fprintf(fp, "property float y\n"); - fprintf(fp, "property float z\n"); + } else { + if (fscanf(fp, "%d %d", &ivb[0], &ivb[1]) != 2) { + cout << "error in reading edge PLY files " << endl; + ExecError("error in reading edge PLY file"); } - else if (datasize == sizeof(double)) { - fprintf(fp, "property double x\n"); - fprintf(fp, "property double y\n"); - fprintf(fp, "property double z\n"); + if (verbosity > 5) cout << "test ivb " << ivb[0] << " " << ivb[1] << endl; + + if (havecolorBdElem) fscanf(fp, "%d %d %d", &color[0], &color[1], &color[2]); + + if (haveTransparencyBdElem) { + int transparencyBdElem; + fscanf(fp, "%d", &transparencyBdElem); } - fprintf(fp, "element face %d\n", Th.nt); - fprintf(fp, "property list uchar int vertex_indices\n"); - fprintf(fp, "property int flags\n"); - - - if(B::nv == 3) { - fprintf(fp, "element face %d\n", Th.nbe); - fprintf(fp, "property list uchar int vertex_indices\n"); - fprintf(fp, "property int flags\n"); + } + int lab = 1; + (bbff++)->set(vff, ivb, lab); + } + } else if (B::nv == 3) { + + for (int ibe = 0; ibe < nbe; ++ibe) { + label[ibe] = 0; + if (verbosity > 9) cout << "ibe=" << ibe << " " << nbe << endl; + + if (binary) { + if (indexVertFace && (fread(&numVerts, sizeof(char), 1, fp) != 1)) { + cout << "error in reading PLY file (numVerts element)" << endl; + ExecError("error in reading PLY file (numVerts element)"); } - - else if(B::nv == 2) { - fprintf(fp, "element edge %d\n", Th.nbe); - fprintf(fp, "property int vertex1\n"); - fprintf(fp, "property int vertex2\n"); + + if (swap) FreeFEM::SwapBytes((char *)&numVerts, sizeof(int), 1); + if (verbosity > 9) cout << "numVerts= " << numVerts << endl; + + if (fread(ivb, sizeof(int), numVerts, fp) != numVerts) { + cout << "error in reading PLY file (element)" << endl; + ExecError("error in reading PLY file (element)"); } - - fprintf(fp, "end_header\n"); - - // write mesh vertices - if (verbosity > 1) - printf("writing vertex \n"); - if (datasize == sizeof(float)) { - - for (unsigned int i = 0; i < Th.nv; i++) { - const Vertex3 &P = Th.vertices[i]; - float f[3]; - f[0] = P.x; - f[1] = P.y; - f[2] = P.z; - if (binary) { - if (swap) - FreeFEM::SwapBytes((char *)&f, sizeof(float), 3); - fwrite(&f, sizeof(float), 3, fp); - } else - fprintf(fp, "%.8g %.8g %.8g\n", P.x, P.y, P.z); - } + if (verbosity > 5) cout << "test " << ivb[0] << " " << ivb[1] << " " << ivb[2] << endl; + + if (swap) FreeFEM::SwapBytes((char *)ivt, sizeof(int), numVerts); + + if (havelabElem) { + + if (fread(&label[ibe], sizeof(int), 1, fp) != 1) { + cout << "error in reading PLY file (lab element) " << endl; + ExecError("error in reading PLY file (lab element)"); + } + if (swap) FreeFEM::SwapBytes((char *)&label[ibe], sizeof(int), 1); } - else if (datasize == sizeof(double)) { - for (unsigned int i = 0; i < Th.nv; i++) { - const Vertex3 &P = Th.vertices[i]; - double f[3]; - f[0] = P.x; - f[1] = P.y; - f[2] = P.z; - if (binary) { - if (swap) - FreeFEM::SwapBytes((char *)&f, sizeof(double), 3); - fwrite((unsigned char *)&f, sizeof(double), 3, fp); - } else - fprintf(fp, "%.15lg %.15lg %.15lg\n", f[0], f[1], f[2]); - } + // don't need + if (havecolorElem) { + char color2[3]; + if (fread(color2, sizeof(char), 3, fp) != 3) { + cout << "error in reading PLY file (color element)" << endl; + ExecError("error in reading PLY file (color element)"); + } } - // write element - int numVerts=-1; - if(T::nv == 4 ) numVerts = 4; - else if(T::nv == 3 ) numVerts = 3; - else if(T::nv == 2 ) numVerts = 2; - - if (verbosity > 1) printf("writing elements \n"); - if (binary) { - for (int it = 0; it < Th.nt; it++) { - const T &K(Th.t(it)); - if (swap) - FreeFEM::SwapBytes((char *)&numVerts, sizeof(char), 1); - fwrite(&numVerts, sizeof(char), 1, fp); - int iv[numVerts + 1]; - for (int ii = 0; ii < numVerts; ii++) - iv[ii] = Th.operator( )(K[ii]); - iv[numVerts]=K.lab; - if (swap) - FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 1); - fwrite(&iv, sizeof(int), numVerts + 1, fp); - } + // don't need + if (haveTransparencyVert) { + char transparencyElem; + if (fread(&transparencyElem, sizeof(char), 1, fp) != 1) { + cout << "error in reading PLY file (transparency element)" << endl; + ExecError("error in reading PLY file (transparency element)"); + } } - else { - for (int it = 0; it < Th.nt; it++) { - const T &K(Th.t(it)); - int iv[numVerts + 1]; - iv[0] = numVerts; - for (int ii = 0; ii < numVerts; ii++) - iv[ii + 1] = Th.operator( )(K[ii]); - if(T::nv == 4 ) fprintf(fp, "%d %d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], iv[4], K.lab); - if(T::nv == 3 ) fprintf(fp, "%d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], K.lab); - } + } + + else { + if (indexVertFace && (fscanf(fp, "%d", &numVerts) != 1)) { + + cout << "error in reading PLY file (numVerts element)" << endl; + ExecError("error in reading PLY file (numVerts element)"); } - - // border element - // triangle3 - if(B::nv==3) { - - numVerts = 3; - if (verbosity > 1) printf("writing border elements \n"); - if (binary) { - for (int it = 0; it < Th.nbe; it++) { - const B &K(Th.be(it)); - if (swap) - FreeFEM::SwapBytes((char *)&numVerts, sizeof(char), 1); - fwrite(&numVerts, sizeof(char), 1, fp); - int iv[numVerts + 1]; - for (int ii = 0; ii < numVerts; ii++) - iv[ii] = Th.operator( )(K[ii]); - iv[numVerts]=K.lab; - if (swap) - FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 1); - fwrite(&iv, sizeof(int), numVerts + 1, fp); - } - } - else { - for (int it = 0; it < Th.nbe; it++) { - const B &K(Th.be(it)); - int iv[numVerts + 1]; - iv[0] = numVerts; - for (int ii = 0; ii < numVerts; ii++) - iv[ii + 1] = Th.operator( )(K[ii]); - fprintf(fp, "%d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], K.lab); - } - } + if (verbosity > 5) cout << " numVerts test " << numVerts << endl; + ffassert(numVerts == B::nv); /////// pb + + for (int j = 0; j < numVerts; ++j) { + if (fscanf(fp, "%d", &ivb[j]) != 1) { + cout << "error in reading PLY file (element)" << endl; + ExecError("error in reading PLY file (element)'"); + } + if (verbosity > 9) cout << " ivb[j]" << ivb[j] << endl; //// } - // BoundaryEdgeS - if(B::nv==2) { - // write edge bd element - if (verbosity > 1) - printf("writing edge elements \n"); - numVerts = 2; - if (binary) { - for (int ibe = 0; ibe < Th.nbe; ibe++) { - const B &K(Th.be(ibe)); - int iv[numVerts]; - for (int ii = 0; ii < numVerts; ii++) - iv[ii] = Th.operator( )(K[ii]); - if (swap) - FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 2); - fwrite(&iv, sizeof(int), numVerts, fp); - } - } - else { - for (int ibe = 0; ibe < Th.nbe; ibe++) { - const B &K(Th.be(ibe)); - int iv[numVerts]; - for (int ii = 0; ii < numVerts; ii++) - iv[ii] = Th.operator( )(K[ii]); - fprintf(fp, "%d %d\n", iv[0], iv[1]); - } - } - if (verbosity > 1) - printf("end writing ply file\n"); - + if (havelabElem && (fscanf(fp, "%d", &label[ibe]) != 1)) { + cout << "error in reading PLY file (lab element)" << endl; + ExecError("error in reading PLY file (lab element)"); } - - } - - - template< class MMesh > - AnyType PLY_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { - string *pffname = GetAny< string * >((*filename)(stack)); - MMesh *pTh = GetAny< MMesh * >((*eTh)(stack)); - ffassert(pTh); - MMesh &Th = *pTh; - bool bigEndian = isBigEndian( ); - bool swap = bigEndian; - //string *dataname; - bool floatmesh(arg(0, stack, false)); - bool binary(arg(1, stack, true)); - int datasize = floatmesh ? sizeof(float) : sizeof(double); - FILE *fp = fopen((*pffname).c_str( ), "wb"); - if (!fp) { - cerr << "Unable to open file " << (*pffname).c_str( ) << endl; - ExecError("error in reading vtk file"); + + if (havelabElem && verbosity > 9) cout << " label[it]" << label[ibe] << endl; + if (havecolorElem) fscanf(fp, "%d %d %d", &color[0], &color[1], &color[2]); + + if (haveTransparencyElem) { + int transparencyElem; + fscanf(fp, "%d", &transparencyElem); } - PLY_WRITE_MESHT(*pffname, fp, Th, binary, datasize, swap); - return (MMesh *)NULL; + } + (bbff++)->set(vff, ivb, label[ibe]); } - -#ifndef COMMON_HPDDM_PARALLEL_IO - static void Load_Init( ) { - - - // if (verbosity) - if (verbosity && (mpirank == 0)) - cout << " load: ioply " << endl; - - Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op >); - Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op >); - Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op >); - Global.Add("plyload3", "(", new PLY_LoadMeshT ); - Global.Add("plyloadS", "(", new PLY_LoadMeshT ); - Global.Add("plyloadL", "(", new PLY_LoadMeshT ); - + } + fclose(fp); + MMesh *pTh = new MMesh(nv, nt, nbe, vff, tff, bff, cleanmesh, removeduplicate, precisvertice); + return pTh; +} + +template< class MMesh > +AnyType PLY_LoadMeshT_Op< MMesh >::operator( )(Stack stack) const { + string *pffname = GetAny< string * >((*filename)(stack)); + bool swap(arg(0, stack, false)); + bool cleanmesh(arg(1, stack, false)); + bool removeduplicate(arg(2, stack, false)); + double precisvertice(arg(3, stack, 1e-6)); + + MMesh *Th = PLY_LoadT< MMesh >(*pffname, swap, cleanmesh, removeduplicate, precisvertice); + Add2StackOfPtr2FreeRC(stack, Th); + return Th; +} + +template< class MMesh > +class PLY_WriteMeshT_Op : public E_F0mps { + public: + typedef long Result; + Expression eTh; + typedef const MMesh *ppmesh; + Expression filename; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + + public: + PLY_WriteMeshT_Op(const basicAC_F0 &args) { + + if ((std::is_same< MMesh, Mesh3 >::value) && verbosity > 2) + cout << "Write Mesh3 in PLY Format" << endl; + else if ((std::is_same< MMesh, MeshS >::value) && verbosity > 2) + cout << "Write MeshS in PLY Format" << endl; + else if ((std::is_same< MMesh, MeshL >::value) && verbosity > 2) + cout << "Write MeshL in PLY Format" << endl; + args.SetNameParam(n_name_param, name_param, nargs); + if (BCastTo< string * >(args[0])) filename = CastTo< string * >(args[0]); + if (BCastTo< ppmesh >(args[1])) eTh = CastTo< ppmesh >(args[1]); + } + + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); } + static E_F0 *f(const basicAC_F0 &args) { return new PLY_WriteMeshT_Op< MMesh >(args); } + + AnyType operator( )(Stack stack) const; +}; + +template<> +basicAC_F0::name_and_type PLY_WriteMeshT_Op< Mesh3 >::name_param[] = {{"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; +template<> +basicAC_F0::name_and_type PLY_WriteMeshT_Op< MeshS >::name_param[] = {{"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; +template<> +basicAC_F0::name_and_type PLY_WriteMeshT_Op< MeshL >::name_param[] = {{"floatmesh", &typeid(bool)}, {"bin", &typeid(bool)}}; + +template< class MMesh > +void PLY_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool binary, int datasize, bool bigEndian) { + + typedef typename MMesh::Element T; + typedef typename MMesh::BorderElement B; + typedef typename MMesh::Vertex V; + + bool swap = bigEndian ? 1 : 0; + + fprintf(fp, "ply\n"); + if (binary && !bigEndian) + fprintf(fp, "format binary_little_endian 1.0\n"); + else if (binary && bigEndian) + fprintf(fp, "format binary_big_endian 1.0\n"); + else + fprintf(fp, "format ascii 1.0\n"); + + fprintf(fp, "comment generated by FreeFEM, %s\n", filename.c_str( )); + fprintf(fp, "element vertex %d\n", Th.nv); + if (datasize == sizeof(float)) { + fprintf(fp, "property float x\n"); + fprintf(fp, "property float y\n"); + fprintf(fp, "property float z\n"); + } else if (datasize == sizeof(double)) { + fprintf(fp, "property double x\n"); + fprintf(fp, "property double y\n"); + fprintf(fp, "property double z\n"); + } + fprintf(fp, "element face %d\n", Th.nt); + fprintf(fp, "property list uchar int vertex_indices\n"); + fprintf(fp, "property int flags\n"); + + if (B::nv == 3) { + fprintf(fp, "element face %d\n", Th.nbe); + fprintf(fp, "property list uchar int vertex_indices\n"); + fprintf(fp, "property int flags\n"); + } + + else if (B::nv == 2) { + fprintf(fp, "element edge %d\n", Th.nbe); + fprintf(fp, "property int vertex1\n"); + fprintf(fp, "property int vertex2\n"); + } + + fprintf(fp, "end_header\n"); + + // write mesh vertices + if (verbosity > 1) printf("writing vertex \n"); + if (datasize == sizeof(float)) { + + for (unsigned int i = 0; i < Th.nv; i++) { + const Vertex3 &P = Th.vertices[i]; + float f[3]; + f[0] = P.x; + f[1] = P.y; + f[2] = P.z; + if (binary) { + if (swap) FreeFEM::SwapBytes((char *)&f, sizeof(float), 3); + fwrite(&f, sizeof(float), 3, fp); + } else + fprintf(fp, "%.8g %.8g %.8g\n", P.x, P.y, P.z); + } + } else if (datasize == sizeof(double)) { + for (unsigned int i = 0; i < Th.nv; i++) { + const Vertex3 &P = Th.vertices[i]; + double f[3]; + f[0] = P.x; + f[1] = P.y; + f[2] = P.z; + if (binary) { + if (swap) FreeFEM::SwapBytes((char *)&f, sizeof(double), 3); + fwrite((unsigned char *)&f, sizeof(double), 3, fp); + } else + fprintf(fp, "%.15lg %.15lg %.15lg\n", f[0], f[1], f[2]); } - - LOADFUNC(Load_Init) + } + // write element + int numVerts = -1; + if (T::nv == 4) + numVerts = 4; + else if (T::nv == 3) + numVerts = 3; + else if (T::nv == 2) + numVerts = 2; + + if (verbosity > 1) printf("writing elements \n"); + if (binary) { + for (int it = 0; it < Th.nt; it++) { + const T &K(Th.t(it)); + if (swap) FreeFEM::SwapBytes((char *)&numVerts, sizeof(char), 1); + fwrite(&numVerts, sizeof(char), 1, fp); + int iv[numVerts + 1]; + for (int ii = 0; ii < numVerts; ii++) iv[ii] = Th.operator( )(K[ii]); + iv[numVerts] = K.lab; + if (swap) FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 1); + fwrite(&iv, sizeof(int), numVerts + 1, fp); + } + } else { + for (int it = 0; it < Th.nt; it++) { + const T &K(Th.t(it)); + int iv[numVerts + 1]; + iv[0] = numVerts; + for (int ii = 0; ii < numVerts; ii++) iv[ii + 1] = Th.operator( )(K[ii]); + if (T::nv == 4) fprintf(fp, "%d %d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], iv[4], K.lab); + if (T::nv == 3) fprintf(fp, "%d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], K.lab); + } + } + + // border element + // triangle3 + if (B::nv == 3) { + + numVerts = 3; + if (verbosity > 1) printf("writing border elements \n"); + if (binary) { + for (int it = 0; it < Th.nbe; it++) { + const B &K(Th.be(it)); + if (swap) FreeFEM::SwapBytes((char *)&numVerts, sizeof(char), 1); + fwrite(&numVerts, sizeof(char), 1, fp); + int iv[numVerts + 1]; + for (int ii = 0; ii < numVerts; ii++) iv[ii] = Th.operator( )(K[ii]); + iv[numVerts] = K.lab; + if (swap) FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 1); + fwrite(&iv, sizeof(int), numVerts + 1, fp); + } + } else { + for (int it = 0; it < Th.nbe; it++) { + const B &K(Th.be(it)); + int iv[numVerts + 1]; + iv[0] = numVerts; + for (int ii = 0; ii < numVerts; ii++) iv[ii + 1] = Th.operator( )(K[ii]); + fprintf(fp, "%d %d %d %d %d\n", iv[0], iv[1], iv[2], iv[3], K.lab); + } + } + } + // BoundaryEdgeS + if (B::nv == 2) { + // write edge bd element + if (verbosity > 1) printf("writing edge elements \n"); + numVerts = 2; + if (binary) { + for (int ibe = 0; ibe < Th.nbe; ibe++) { + const B &K(Th.be(ibe)); + int iv[numVerts]; + for (int ii = 0; ii < numVerts; ii++) iv[ii] = Th.operator( )(K[ii]); + if (swap) FreeFEM::SwapBytes((char *)&iv, sizeof(int), numVerts + 2); + fwrite(&iv, sizeof(int), numVerts, fp); + } + } else { + for (int ibe = 0; ibe < Th.nbe; ibe++) { + const B &K(Th.be(ibe)); + int iv[numVerts]; + for (int ii = 0; ii < numVerts; ii++) iv[ii] = Th.operator( )(K[ii]); + fprintf(fp, "%d %d\n", iv[0], iv[1]); + } + } + if (verbosity > 1) printf("end writing ply file\n"); + } +} + +template< class MMesh > +AnyType PLY_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { + string *pffname = GetAny< string * >((*filename)(stack)); + MMesh *pTh = GetAny< MMesh * >((*eTh)(stack)); + ffassert(pTh); + MMesh &Th = *pTh; + bool bigEndian = isBigEndian( ); + bool swap = bigEndian; + // string *dataname; + bool floatmesh(arg(0, stack, false)); + bool binary(arg(1, stack, true)); + int datasize = floatmesh ? sizeof(float) : sizeof(double); + FILE *fp = fopen((*pffname).c_str( ), "wb"); + if (!fp) { + cerr << "Unable to open file " << (*pffname).c_str( ) << endl; + ExecError("error in reading vtk file"); + } + PLY_WRITE_MESHT< MMesh >(*pffname, fp, Th, binary, datasize, swap); + return (MMesh *)NULL; +} + +#ifndef COMMON_HPDDM_PARALLEL_IO +static void Load_Init( ) { + + // if (verbosity) + if (verbosity && (mpirank == 0)) cout << " load: ioply " << endl; + + Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op< Mesh3 > >); + Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op< MeshS > >); + Global.Add("saveply", "(", new OneOperatorCode< PLY_WriteMeshT_Op< MeshL > >); + Global.Add("plyload3", "(", new PLY_LoadMeshT< Mesh3 >); + Global.Add("plyloadS", "(", new PLY_LoadMeshT< MeshS >); + Global.Add("plyloadL", "(", new PLY_LoadMeshT< MeshL >); +} + +LOADFUNC(Load_Init) #endif diff --git a/plugin/seq/iovtk.cpp b/plugin/seq/iovtk.cpp index 6a5f27dfe..be28c5efe 100644 --- a/plugin/seq/iovtk.cpp +++ b/plugin/seq/iovtk.cpp @@ -231,8 +231,7 @@ char *newcopy(const string *s) { } // Tables of element type of VTK considered in Freefem++ -static const int nvElemVTK[25] = {1, 0, 2, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const int nvElemVTK[25] = {1, 0, 2, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // we considerer only vertex, edges, triangles and tetrahedrons in Freefem++ // 1 :: Vertex Corner @@ -273,24 +272,24 @@ static const float ColorTable[30][3] = { {0.0, 0.8, 0.0}, /* ??? */ {0.0, 0.8, 0.8}, /* ??? */ {0.0, 0.0, 0.8}, /* ??? */ -}; // a voir F.Hecht +}; // a voir F.Hecht namespace FreeFEM { -void SwapBytes(char *array, int size, int n) { - char *x = new char[size]; + void SwapBytes(char *array, int size, int n) { + char *x = new char[size]; - for (int i = 0; i < n; i++) { - char *a = &array[i * size]; - memcpy(x, a, size); + for (int i = 0; i < n; i++) { + char *a = &array[i * size]; + memcpy(x, a, size); - for (int c = 0; c < size; c++) { - a[size - 1 - c] = x[c]; + for (int c = 0; c < size; c++) { + a[size - 1 - c] = x[c]; + } } - } - delete[] x; -} -} + delete[] x; + } +} // namespace FreeFEM //= ============================================= // Fichier Format .vtu @@ -320,19 +319,17 @@ void VTU_VTKFILE(FILE *fp, bool bigEndian) { // fprintf(fp,"<%s>\n",type.c_str()); } -void VTU_PIECE(FILE *fp, const int &nv, const int &nc) { - fprintf(fp, "\n", nv, nc); -} +void VTU_PIECE(FILE *fp, const int &nv, const int &nc) { fprintf(fp, "\n", nv, nc); } //---------------------------------------------------------------------------------// // A function to output a .pvtu file for ParaView usage when PETSc or HPDDM is used //---------------------------------------------------------------------------------// -void PvtuWriter(string*& pffname, const int size, const int time, const string base_filename, const string CellDataArrayForPvtu, const string PointDataArrayForPvtu) { +void PvtuWriter(string *&pffname, const int size, const int time, const string base_filename, const string CellDataArrayForPvtu, const string PointDataArrayForPvtu) { std::ostringstream marker; - marker << std::setw(to_string(size).length()) << std::setfill('0') << "0"; + marker << std::setw(to_string(size).length( )) << std::setfill('0') << "0"; std::string zero; if (size > 1) - zero = "_" + marker.str() + ".vtu"; + zero = "_" + marker.str( ) + ".vtu"; else zero = ".vtu"; std::string full_filename(*pffname); @@ -340,33 +337,35 @@ void PvtuWriter(string*& pffname, const int size, const int time, const string b if (found != std::string::npos) { std::string file_without_extension; if (size > 1) - file_without_extension = full_filename.substr(0, found - 6 - string(to_string(size)).length()); + file_without_extension = full_filename.substr(0, found - 6 - string(to_string(size)).length( )); else file_without_extension = full_filename.substr(0, found - 5); - std::string T = std::string(4 - string(to_string(time)).length(), '0') + to_string(time); + std::string T = std::string(4 - string(to_string(time)).length( ), '0') + to_string(time); ofstream pvtu; pvtu.open(file_without_extension + (size > 1 ? "_" + to_string(size) : "") + "_" + T + ".pvtu"); pvtu << "\n" "\n" " \n" " \n" - "" + PointDataArrayForPvtu + "" - " \n" - " \n" - " \n" - "" + CellDataArrayForPvtu + "" - " \n" - " \n" - " \n" - " \n"; + "" + + PointDataArrayForPvtu + + "" + " \n" + " \n" + " \n" + "" + + CellDataArrayForPvtu + + "" + " \n" + " \n" + " \n" + " \n"; for (int i = 0; i < size; ++i) { pvtu << " 1) - pvtu << to_string(size) + "_"; + if (size > 1) pvtu << to_string(size) + "_"; pvtu << std::setw(4) << std::setfill('0') << time; - if (size > 1) - pvtu << "_" << std::setw(to_string(size).length()) << std::setfill('0') << i; + if (size > 1) pvtu << "_" << std::setw(to_string(size).length( )) << std::setfill('0') << i; pvtu << ".vtu\"/>\n"; } pvtu << " \n" @@ -377,12 +376,12 @@ void PvtuWriter(string*& pffname, const int size, const int time, const string b //--------------------------------------------------------------------------------// // A function to output a .pvd file for ParaView usage when PETSc or HPDDM is used //--------------------------------------------------------------------------------// -void PvdWriter(string*& pffname, const int size, const int time, const string base_filename, const string CellDataArrayForPvtu, const string PointDataArrayForPvtu) { +void PvdWriter(string *&pffname, const int size, const int time, const string base_filename, const string CellDataArrayForPvtu, const string PointDataArrayForPvtu) { std::ostringstream marker; - marker << std::setw(to_string(size).length()) << std::setfill('0') << "0"; + marker << std::setw(to_string(size).length( )) << std::setfill('0') << "0"; std::string zero; if (size > 1) - zero = "_" + marker.str() + ".vtu"; + zero = "_" + marker.str( ) + ".vtu"; else zero = ".vtu"; std::string full_filename(*pffname); @@ -390,25 +389,29 @@ void PvdWriter(string*& pffname, const int size, const int time, const string ba if (found != std::string::npos) { std::string file_without_extension; if (size > 1) - file_without_extension = full_filename.substr(0, found - 6 - string(to_string(size)).length()); + file_without_extension = full_filename.substr(0, found - 6 - string(to_string(size)).length( )); else file_without_extension = full_filename.substr(0, found - 5); ofstream pvd; pvd.open(file_without_extension + (size > 1 ? "_" + to_string(size) : "") + ".pvd"); pvd << "\n" "\n" - " \n"; + "" + + to_string(time) + + "" + "\" type=\"Collection\" version=\"0.1\"\n" + " byte_order=\"LittleEndian\"\n" + " compressor=\"vtkZLibDataCompressor\">\n" + " \n"; for (int t = 0; t < time + 1; ++t) { - pvd << " 1) - pvd << to_string(size) + "_"; + "" + + base_filename + + "" + "_"; + if (size > 1) pvd << to_string(size) + "_"; pvd << std::setw(4) << std::setfill('0') << t; pvd << ".pvtu\"/>\n"; } @@ -430,8 +433,7 @@ void VTU_DATA_ARRAY(FILE *fp, const string &type, const string &name, bool binar fprintf(fp, ">\n"); } -void VTU_DATA_ARRAY(FILE *fp, const string &type, const string &name, const long &noc, - bool binary) { +void VTU_DATA_ARRAY(FILE *fp, const string &type, const string &name, const long &noc, bool binary) { fprintf(fp, "::value) { - l = runEncodeB64(sizeof(int), (unsigned char *)(ien + (T::nv)*Th.nt + i * (B::nv) + 1), - ElementChars); + l = runEncodeB64(sizeof(int), (unsigned char *)(ien + (T::nv)*Th.nt + i * (B::nv) + 1), ElementChars); ElementChars[l] = 0; fwrite(&ElementChars, l, 1, fp); } @@ -1245,8 +1241,7 @@ void VTU_WRITE_MESHT(FILE *fp, const MMesh &Th, bool binary, int datasize, bool for (long i = (T::nv); i <= (T::nv)*Th.nt; i += (T::nv)) fprintf(fp, "%ld ", i); if (surface) { - for (long i = (B::nv); i <= (B::nv)*Th.nbe; i += (B::nv)) - fprintf(fp, "%ld ", i + (T::nv)*Th.nt); + for (long i = (B::nv); i <= (B::nv)*Th.nbe; i += (B::nv)) fprintf(fp, "%ld ", i + (T::nv)*Th.nt); } } @@ -1365,11 +1360,9 @@ class VTK_LoadMesh_Op : public E_F0mps { static const int n_name_param = 5; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - - KN >* arg(int i, Stack stack,KN >*p) const { - return nargs[i] ? GetAny< KN >* >((*nargs[i])(stack)) : p; - } - + + KN< KN< double > > *arg(int i, Stack stack, KN< KN< double > > *p) const { return nargs[i] ? GetAny< KN< KN< double > > * >((*nargs[i])(stack)) : p; } + public: VTK_LoadMesh_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { if (verbosity) { @@ -1382,22 +1375,17 @@ class VTK_LoadMesh_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type VTK_LoadMesh_Op::name_param[] = {{"reft", &typeid(long)}, - {"swap", &typeid(bool)}, - {"refe", &typeid(long)}, - {"namelabel", &typeid(string*)}, - {"fields", &typeid( KN >*)}}; +basicAC_F0::name_and_type VTK_LoadMesh_Op::name_param[] = { + {"reft", &typeid(long)}, {"swap", &typeid(bool)}, {"refe", &typeid(long)}, {"namelabel", &typeid(string *)}, {"fields", &typeid(KN< KN< double > > *)}}; class VTK_LoadMesh : public OneOperator { public: VTK_LoadMesh( ) : OneOperator(atype< pmesh >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new VTK_LoadMesh_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new VTK_LoadMesh_Op(args, t[0]->CastTo(args[0])); } }; -Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) { +Mesh *VTK_Load(const string &filename, bool bigEndian, KN< KN< double > > *pfields) { // swap = bigEndian or not bigEndian // variable freefem++ int nv, nt = 0, nbe = 0; @@ -1503,8 +1491,7 @@ Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) vff[i].y = xyz[1]; if (abs(xyz[2]) > 1.e-7) { cout << "we are plotted a two dimensional mesh: z coordinate must be 0" << endl; - ExecError( - "error in reading vtk file,we are plotted a two dimensional mesh: z coordinate must be 0"); + ExecError("error in reading vtk file,we are plotted a two dimensional mesh: z coordinate must be 0"); } vff[i].lab = 1; @@ -1522,7 +1509,7 @@ Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) ExecError("error in reading vtk file"); } - if(verbosity>2) cout << "Reading cells" << numElements << endl; + if (verbosity > 2) cout << "Reading cells" << numElements << endl; int *IntCells = new int[totalNumInt - numElements]; int *firstCell = new int[numElements + 1]; @@ -1641,14 +1628,14 @@ Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) } } - int nbp=0,nbf=0, err=0; + int nbp = 0, nbf = 0, err = 0; if (fscanf(fp, "%s %d", buffer, &nbp) != 2) { cout << "error in reading vtk files pfields" << endl; err++; } - int startdatapoint=0; - if(err==0) { - int nf=-1; + int startdatapoint = 0; + if (err == 0) { + int nf = -1; /* CELL_DATA 209726 Scalars Label int 1 @@ -1657,105 +1644,103 @@ Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) LOOKUP_TABLE FreeFempp_table 7 4*7 value */ - if (strcmp(buffer, "CELL_DATA")) { // read region number if exist + if (strcmp(buffer, "CELL_DATA")) { // read region number if exist if (strcmp(buffer, "POINT_DATA")) { - cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer<< " " << nbp<< endl; - err=1; - } - else startdatapoint=1; - } - else { - if ((!err) &&(fscanf(fp, "%s %s %s %d\n", buffer, buffer2,buffer3,&nbf) != 4)) { + cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer << " " << nbp << endl; + err = 1; + } else + startdatapoint = 1; + } else { + if ((!err) && (fscanf(fp, "%s %s %s %d\n", buffer, buffer2, buffer3, &nbf) != 4)) { cout << "error in reading vtk files FIELD FieldData" << endl; err++; } } loadlabs = !strcmp(buffer2, "Label"); - if (loadlabs && err==0) - LabCells = new int[numElements]; - if (strcmp(buffer3, "int") !=0) // not integer - err++; - if ((!err) &&(fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) + if (loadlabs && err == 0) LabCells = new int[numElements]; + if (strcmp(buffer3, "int") != 0) // not integer err++; + if ((!err) && (fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) err++; // read nbf - //cout << " err= " << err << " read nbp "<< nbp << endl; - if(err==0) - for( nf=0 ; nf < nbp; nf++) { + // cout << " err= " << err << " read nbp "<< nbp << endl; + if (err == 0) + for (nf = 0; nf < nbp; nf++) { int ii[1]; if (binary) { if (fread(ii, sizeof(int), 1, fp) != 1) err++; if (!bigEndian) FreeFEM::SwapBytes((char *)&ii[0], sizeof(int), 1); - } - else { + } else { if (fscanf(fp, "%d", ii) != 1) err++; } - if (loadlabs) - LabCells[nf] = ii[0]; - if(err) break; + if (loadlabs) LabCells[nf] = ii[0]; + if (err) break; } - if(err) cout << " err reading CELL_DATA at " << nf << endl; - if ((!err) &&(fscanf(fp, "%s %s %d\n", buffer, buffer2,&nbf) != 3 ) ) err++; - nf =-1; - if(err==0) - for( nf=0 ; nf < nbf; nf++) { + if (err) cout << " err reading CELL_DATA at " << nf << endl; + if ((!err) && (fscanf(fp, "%s %s %d\n", buffer, buffer2, &nbf) != 3)) err++; + nf = -1; + if (err == 0) + for (nf = 0; nf < nbf; nf++) { float f[4]; char cc[4]; if (binary) { - if (fread(cc, sizeof(char), 4, fp) != 4) err++;} - else { - if (fscanf(fp, "%f %f %f %fa",f+0,f+1,f+2,f+3) != 4) err++;} - if(err) break; + if (fread(cc, sizeof(char), 4, fp) != 4) err++; + } else { + if (fscanf(fp, "%f %f %f %fa", f + 0, f + 1, f + 2, f + 3) != 4) err++; + } + if (err) break; } - if(err&& nf>=0) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; - startdatapoint=0; + if (err && nf >= 0) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; + startdatapoint = 0; } - if(pfields) { - if(verbosity>1) cout << " try reading POINT_DATA " << endl; - - int nbp=0,nbf=0,err=0; + if (pfields) { + if (verbosity > 1) cout << " try reading POINT_DATA " << endl; + + int nbp = 0, nbf = 0, err = 0; if (fscanf(fp, "%s %d", buffer, &nbp) != 2) { if (verbosity) cout << "error in reading vtk files pfields" << endl; err++; } - if (strcmp(buffer, "POINT_DATA")) { - if (verbosity) cout << "VTK reader can only read POINT_DATA datasets: not " << buffer<< endl; + if (strcmp(buffer, "POINT_DATA")) { + if (verbosity) cout << "VTK reader can only read POINT_DATA datasets: not " << buffer << endl; err++; } - if ((!err) &&(fscanf(fp, "%s %s %d", buffer, buffer2,&nbf) != 3)) { + if ((!err) && (fscanf(fp, "%s %s %d", buffer, buffer2, &nbf) != 3)) { if (verbosity) cout << "error in reading vtk files FIELD FieldData" << endl; err++; } - if(err) nbf=0; - else pfields->resize(nbf); - for(int nf=0 ; nf < nbf; nf++) { + if (err) + nbf = 0; + else + pfields->resize(nbf); + for (int nf = 0; nf < nbf; nf++) { - int m,nv; + int m, nv; // read mesh vertices - if (fscanf(fp, "%s %d %d %s\n", buffer,&m, &nv, buffer2) != 4) { + if (fscanf(fp, "%s %d %d %s\n", buffer, &m, &nv, buffer2) != 4) { if (verbosity) cout << "error in reading vtk files " << endl; err++; break; } - int n = m*nv; - if(verbosity) cout << " reading "<< buffer << " "<< m << " " << nv << " "<< buffer2 << endl; + int n = m * nv; + if (verbosity) cout << " reading " << buffer << " " << m << " " << nv << " " << buffer2 << endl; int datasize; if (!strncmp(buffer2, "double", 6)) datasize = sizeof(double); else if (!strncmp(buffer2, "float", 5)) datasize = sizeof(float); else { - if (verbosity) cout << "VTK reader only accepts float or double datasets" << endl; - err++; - break; + if (verbosity) cout << "VTK reader only accepts float or double datasets" << endl; + err++; + break; } // read data .. - if(err) break; + if (err) break; (*pfields)[nf].resize(n); - double* pv=&(*pfields)[nf][0]; - for(int i=0; i >* pfields) err++; break; } - if (!bigEndian) - FreeFEM::SwapBytes((char *)f, sizeof(float), 1); - *pv++=*f; - } - else { + if (!bigEndian) FreeFEM::SwapBytes((char *)f, sizeof(float), 1); + *pv++ = *f; + } else { if (fread(pv++, sizeof(double), 1, fp) != 1) { if (verbosity) cout << "error in reading vtk fields double at " << nf << " / " << i << endl; err++; break; } - if (!bigEndian) - FreeFEM::SwapBytes((char *)pv, sizeof(double), 1); + if (!bigEndian) FreeFEM::SwapBytes((char *)pv, sizeof(double), 1); } - } - else { + } else { if (fscanf(fp, "%lf", pv++) != 1) { - if (verbosity) cout << "error in reading vtk files ascii fields" << nf << " / " << i < >* pfields) case 1: // Vertex if (nerr++ < 10 && verbosity) { - cout << "this type of cell (vertex) is not taking account in Freefem++ " << type << " " - << endl; + cout << "this type of cell (vertex) is not taking account in Freefem++ " << type << " " << endl; } break; @@ -1851,9 +1831,9 @@ Mesh *VTK_Load(const string &filename, bool bigEndian, KN >* pfields) Mesh *pTh = new Mesh(nv, nt, nbe, vff, tff, bff); - R2 Pn,Px; - pTh->BoundingBox(Pn,Px); - pTh->quadtree=new Fem2D::FQuadTree(pTh,Pn,Px,pTh->nv); + R2 Pn, Px; + pTh->BoundingBox(Pn, Px); + pTh->quadtree = new Fem2D::FQuadTree(pTh, Pn, Px, pTh->nv); return pTh; } @@ -1879,8 +1859,8 @@ AnyType VTK_LoadMesh_Op::operator( )(Stack stack) const { if (nargs[3]) { DataLabel = GetAny< string * >((*nargs[3])(stack)); } - KN > * pfields=0; - pfields=arg(4, stack,pfields); + KN< KN< double > > *pfields = 0; + pfields = arg(4, stack, pfields); Mesh *Th = VTK_Load(*pffname, swap, pfields); // A faire fonction pour changer le label @@ -1921,9 +1901,8 @@ class VTK_WriteMesh_Op : public E_F0mps { } } - void writesolutionP0_float_binary(FILE *fp, const Mesh &Th, Stack stack, bool surface, - bool bigEndian) const { - MeshPoint *mp3(MeshPointStack(stack)),mps=*mp3; + void writesolutionP0_float_binary(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool bigEndian) const { + MeshPoint *mp3(MeshPointStack(stack)), mps = *mp3; R2 Cdg_hat = R2(1. / 3., 1. / 3.); for (int it = 0; it < Th.nt; it++) { @@ -1962,7 +1941,8 @@ class VTK_WriteMesh_Op : public E_F0mps { } fprintf(fp, "\n"); - *mp3 = mps;} + *mp3 = mps; + } void writesolutionP0_float(FILE *fp, const Mesh &Th, Stack stack, bool surface) const { MeshPoint *mp3(MeshPointStack(stack)); @@ -2051,8 +2031,7 @@ class VTK_WriteMesh_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP0_float(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool binary, - bool bigEndian, bool XML = false) const { + void writesolutionP0_float(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool binary, bool bigEndian, bool XML = false) const { if (binary) { if (!XML) { (*this).writesolutionP0_float_binary(fp, Th, stack, surface, bigEndian); @@ -2064,8 +2043,7 @@ class VTK_WriteMesh_Op : public E_F0mps { } } - void writesolutionP0_double_binary(FILE *fp, const Mesh &Th, Stack stack, bool surface, - bool bigEndian) const { + void writesolutionP0_double_binary(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool bigEndian) const { MeshPoint *mp3(MeshPointStack(stack)); R2 Cdg_hat = R2(1. / 3., 1. / 3.); @@ -2195,8 +2173,7 @@ class VTK_WriteMesh_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP0_double(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool binary, - bool bigEndian, bool XML = false) const { + void writesolutionP0_double(FILE *fp, const Mesh &Th, Stack stack, bool surface, bool binary, bool bigEndian, bool XML = false) const { if (binary) { if (!XML) { (*this).writesolutionP0_double_binary(fp, Th, stack, surface, bigEndian); @@ -2208,8 +2185,7 @@ class VTK_WriteMesh_Op : public E_F0mps { } } - void writesolutionP1_float(FILE *fp, const Mesh &Th, Stack stack, bool binary, bool bigEndian, - bool XML = false) const { + void writesolutionP1_float(FILE *fp, const Mesh &Th, Stack stack, bool binary, bool bigEndian, bool XML = false) const { unsigned char ElementChars[256]; MeshPoint *mp3(MeshPointStack(stack)); @@ -2224,8 +2200,7 @@ class VTK_WriteMesh_Op : public E_F0mps { mp3->setP(&Th, it, iv); for (int j = 0; j < (*this).nbfloat; j++) { - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); } takemesh[i] = takemesh[i] + 1; @@ -2291,8 +2266,7 @@ class VTK_WriteMesh_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP1_double(FILE *fp, const Mesh &Th, Stack stack, bool binary, bool bigEndian, - bool XML = false) const { + void writesolutionP1_double(FILE *fp, const Mesh &Th, Stack stack, bool binary, bool bigEndian, bool XML = false) const { unsigned char ElementChars[256]; MeshPoint *mp3(MeshPointStack(stack)); @@ -2307,8 +2281,7 @@ class VTK_WriteMesh_Op : public E_F0mps { mp3->setP(&Th, it, iv); for (int j = 0; j < (*this).nbfloat; j++) { - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); } takemesh[i] = takemesh[i] + 1; @@ -2382,9 +2355,7 @@ class VTK_WriteMesh_Op : public E_F0mps { #endif static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: VTK_WriteMesh_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -2421,7 +2392,7 @@ class VTK_WriteMesh_Op : public E_F0mps { l[jj][0] = to< double >(args[i]); char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = scas; l[jj].name += number; sca++; @@ -2429,8 +2400,7 @@ class VTK_WriteMesh_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); // cout << "taille" << a0->size() << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); + CompileError("savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); } if (a0->size( ) == ddim) { @@ -2443,7 +2413,7 @@ class VTK_WriteMesh_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = vecs; l[jj].name += number; vec++; @@ -2457,7 +2427,7 @@ class VTK_WriteMesh_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = tens; l[jj].name += number; ten++; @@ -2469,9 +2439,7 @@ class VTK_WriteMesh_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new VTK_WriteMesh_Op(args); } @@ -2491,8 +2459,7 @@ basicAC_F0::name_and_type VTK_WriteMesh_Op::name_param[] = {{"dataname", &typeid #endif {"append", &typeid(bool)}}; -void VTK_WRITE_MESH(const string &filename, FILE *fp, const Mesh &Th, bool binary, int datasize, - bool surface, bool bigEndian) { +void VTK_WRITE_MESH(const string &filename, FILE *fp, const Mesh &Th, bool binary, int datasize, bool surface, bool bigEndian) { fprintf(fp, "# vtk DataFile Version 2.0\n"); fprintf(fp, "%s, Created by Freefem++ \n", filename.c_str( )); if (binary) { @@ -2828,8 +2795,8 @@ void VTK_WRITE_MESH(const string &filename, FILE *fp, const Mesh &Th, bool binar tab[3] = 255; for (int itab = 0; itab < 4; itab++) { - char newvalue[sizeof(int)+1]; - int bid0 = snprintf(newvalue,sizeof(int)+1, "%s", (char *)&tab[itab]); + char newvalue[sizeof(int) + 1]; + int bid0 = snprintf(newvalue, sizeof(int) + 1, "%s", (char *)&tab[itab]); fwrite(&newvalue, sizeof(unsigned char), 1, fp); } } else { @@ -2846,7 +2813,7 @@ void VTK_WRITE_MESH(const string &filename, FILE *fp, const Mesh &Th, bool binar } AnyType VTK_WriteMesh_Op::operator( )(Stack stack) const { - MeshPoint *mps = MeshPointStack(stack), mp = *mps; + MeshPoint *mps = MeshPointStack(stack), mp = *mps; string *pffname = GetAny< string * >((*filename)(stack)); Mesh *pTh = GetAny< Mesh * >((*eTh)(stack)); @@ -2899,10 +2866,9 @@ AnyType VTK_WriteMesh_Op::operator( )(Stack stack) const { #ifdef COMMON_HPDDM_PARALLEL_IO int time, size; string base_filename; - std::string CellDataArrayForPvtu = ""; + std::string CellDataArrayForPvtu = ""; std::string PointDataArrayForPvtu = ""; - parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, - nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); + parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); #endif int datasize = floatmesh ? sizeof(float) : sizeof(double); @@ -3128,7 +3094,7 @@ AnyType VTK_WriteMesh_Op::operator( )(Stack stack) const { l[ii].writesolutionP0_float(fp, Th, stack, surface, binary, swap, 1); } else if (datasize == sizeof(double)) { #ifdef COMMON_HPDDM_PARALLEL_IO - CellDataArrayForPvtu = CellDataArrayForPvtu + " \n"; + CellDataArrayForPvtu = CellDataArrayForPvtu + " \n"; #endif VTU_DATA_ARRAY(fp, "Float64", nameofuser[ii], l[ii].nbfloat, binary); l[ii].writesolutionP0_double(fp, Th, stack, surface, binary, swap, 1); @@ -3186,7 +3152,7 @@ AnyType VTK_WriteMesh_Op::operator( )(Stack stack) const { } delete[] pch; - *mps=mp;// retore state + *mps = mp; // retore state return (Mesh *)NULL; } @@ -3208,18 +3174,10 @@ class VTK_LoadMesh3_Op : public E_F0mps { static const int n_name_param = 8; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } - KN >* arg(int i, Stack stack,KN >*p) const { - return nargs[i] ? GetAny< KN >* >((*nargs[i])(stack)) : p; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + KN< KN< double > > *arg(int i, Stack stack, KN< KN< double > > *p) const { return nargs[i] ? GetAny< KN< KN< double > > * >((*nargs[i])(stack)) : p; } public: VTK_LoadMesh3_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { @@ -3233,26 +3191,25 @@ class VTK_LoadMesh3_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type VTK_LoadMesh3_Op::name_param[] = { - {"reftet", &typeid(long)}, {"swap", &typeid(bool)}, - {"refface", &typeid(long)}, {"namelabel", &typeid(string*)}, - {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)}, - {"fields", &typeid( KN >*)} - +basicAC_F0::name_and_type VTK_LoadMesh3_Op::name_param[] = {{"reftet", &typeid(long)}, + {"swap", &typeid(bool)}, + {"refface", &typeid(long)}, + {"namelabel", &typeid(string *)}, + {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, + {"precisvertice", &typeid(double)}, + {"fields", &typeid(KN< KN< double > > *)} + }; class VTK_LoadMesh3 : public OneOperator { public: VTK_LoadMesh3( ) : OneOperator(atype< pmesh3 >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new VTK_LoadMesh3_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new VTK_LoadMesh3_Op(args, t[0]->CastTo(args[0])); } }; -Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, - double precisvertice,KN >* pfields) { +Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, double precisvertice, KN< KN< double > > *pfields) { // swap = bigEndian or not bigEndian // variable freefem++ int nv, nt = 0, nbe = 0; @@ -3266,7 +3223,7 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re ExecError("error in reading vtk file"); } - char buffer[256], buffer2[256],buffer3[256]; + char buffer[256], buffer2[256], buffer3[256]; res = fgets(buffer, sizeof(buffer), fp); // version line res = fgets(buffer, sizeof(buffer), fp); // title @@ -3276,7 +3233,7 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re if (!strcmp(buffer, "BINARY")) { binary = true; } - if(verbosity>9) cout << " binary = " < 9) cout << " binary = " << binary << " bigEndian: " << bigEndian << endl; if (fscanf(fp, "%s %s", buffer, buffer2) != 2) { cout << "error in reading vtk files" << endl; ExecError("error in reading vtk file"); @@ -3309,12 +3266,11 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re } if (verbosity > 3) { - cout << "Reading points" << nv << " buffer2 " << buffer2 << " binary " << binary << " datasize " - << datasize << " " << sizeof(float) << endl; + cout << "Reading points" << nv << " buffer2 " << buffer2 << " binary " << binary << " datasize " << datasize << " " << sizeof(float) << endl; } Vertex3 *vff = new Vertex3[nv]; - + for (int i = 0; i < nv; i++) { if (verbosity > 19) { cout << " i=" << i << endl; @@ -3325,7 +3281,7 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re if (datasize == sizeof(float)) { float f[3]; if (fread(f, sizeof(float), 3, fp) != 3) { - cout << "error in reading vtk files item: " << i << endl; + cout << "error in reading vtk files item: " << i << endl; ExecError("error in reading vtk file"); } @@ -3338,17 +3294,17 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re } } else { if (fread(xyz, sizeof(double), 3, fp) != 3) { - cout << "error in reading vtk files item " < 10) cout <<" iovtk: datasize " << datasize << " == " << sizeof(float) << endl; + if (verbosity > 10) cout << " iovtk: datasize " << datasize << " == " << sizeof(float) << endl; if (datasize == sizeof(float)) { if (fscanf(fp, "%lf %lf %lf", &xyz[0], &xyz[1], &xyz[2]) != 3) { cout << "error in reading vtk files (float)" << endl; @@ -3367,19 +3323,19 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re vff[i].z = xyz[2]; vff[i].lab = 1; if (verbosity > 9) { - cout << i << " : " << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl; + cout << i << " : " << xyz[0] << " " << xyz[1] << " " << xyz[2] << endl; } } // read mesh elements - int numElements, numElements2, totalNumInt,kk,fpos=ftell(fp); - if ((kk=fscanf(fp, "%s %d %d\n", buffer, &numElements, &totalNumInt)) != 3) { - cout << "error in " << fpos<< " " << buffer << " reading vtk files" << numElements << " " << totalNumInt << " " << kk<< endl; + int numElements, numElements2, totalNumInt, kk, fpos = ftell(fp); + if ((kk = fscanf(fp, "%s %d %d\n", buffer, &numElements, &totalNumInt)) != 3) { + cout << "error in " << fpos << " " << buffer << " reading vtk files" << numElements << " " << totalNumInt << " " << kk << endl; ExecError("error in reading vtk file"); } if (verbosity > 3) { - printf("reading %d parameter %s %d %d\n",fpos, buffer, numElements, totalNumInt); + printf("reading %d parameter %s %d %d\n", fpos, buffer, numElements, totalNumInt); } if (strncmp(buffer, "CELLS", 5) || !numElements) { @@ -3430,7 +3386,7 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re ExecError("error in reading vtk file"); } - // cout << "numVerts" << numVerts << endl; + // cout << "numVerts" << numVerts << endl; for (int j = 0; j < numVerts; j++) { if (fscanf(fp, "%d", &n[j]) != 1) { @@ -3498,13 +3454,12 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re switch (type) { case 1: // Vertex if (nerr++ < 3 && verbosity) { - if (verbosity) cout << "this type of cell (vertex) is not taking account in Freefem++ " << endl; + if (verbosity) cout << "this type of cell (vertex) is not taking account in Freefem++ " << endl; } break; - case 3: // Edge/line - if (verbosity) cout << "this type of cell is not taking account in Freefem++ for a two dimensional mesh" - << endl; // 3D + case 3: // Edge/line + if (verbosity) cout << "this type of cell is not taking account in Freefem++ for a two dimensional mesh" << endl; // 3D break; case 5: // Triangle nbe++; // 3D @@ -3519,168 +3474,162 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re } } - int nbp=0,nbf=0, err=0; - if (fscanf(fp, "%s %d", buffer, &nbp) != 2) - { cout << "error in reading vtk files pfields" << endl; - err++;} - int startdatapoint=0; - if(err==0) - { - int nf=-1; - /* - CELL_DATA 209726 - Scalars Label int 1 - LOOKUP_TABLE FreeFempp_table - .... - LOOKUP_TABLE FreeFempp_table 7 - 4*7 value - */ - - if (strcmp(buffer, "CELL_DATA")) { // read region number if exist - if (strcmp(buffer, "POINT_DATA")) { - if (verbosity)cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer<< " " << nbp<< endl; - err=1; - } - else startdatapoint=1; - } - else { - if ((!err) &&(fscanf(fp, "%s %s %s %d\n", buffer, buffer2,buffer3,&nbf) != 4)) { - if (verbosity)cout << "error in reading vtk files FIELD FieldData" << endl; - err++; - }} - if(startdatapoint==0) - { - if( strcmp(buffer3, "int") !=0)// not integer - err++; - if ((!err) &&(fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) - err++; - // read nbf - if (verbosity)cout << " err= " << err << " read nbp "<< nbp << endl; - if(err==0) - for( nf=0 ; nf < nbp; nf++) - { - int ii[1]; - if (binary) - { if (fread(ii, sizeof(int), 1, fp) != 1) err++;} - else - { if (fscanf(fp, "%d", ii) != 1) err++;} - if(err) break; - } - if(err) cout << " err reading CELL_DATA at " << nf << endl; - - if ((!err) &&(fscanf(fp, "%s %s %d\n", buffer, buffer2,&nbf) != 3 ) ) err++; - nf =-1; - if(err==0) - for( nf=0 ; nf < nbf; nf++) - { - float f[4]; - char cc[4]; - if (binary) - { if (fread(cc, sizeof(char), 4, fp) != 4) err++;} - else - { if (fscanf(fp, "%f %f %f %fa",f+0,f+1,f+2,f+3) != 4) err++;} - if(err) break; - } - if(err&& nf>=0 && verbosity) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; - - startdatapoint=0; + int nbp = 0, nbf = 0, err = 0; + if (fscanf(fp, "%s %d", buffer, &nbp) != 2) { + cout << "error in reading vtk files pfields" << endl; + err++; + } + int startdatapoint = 0; + if (err == 0) { + int nf = -1; + /* + CELL_DATA 209726 + Scalars Label int 1 + LOOKUP_TABLE FreeFempp_table + .... + LOOKUP_TABLE FreeFempp_table 7 + 4*7 value + */ + + if (strcmp(buffer, "CELL_DATA")) { // read region number if exist + if (strcmp(buffer, "POINT_DATA")) { + if (verbosity) cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer << " " << nbp << endl; + err = 1; + } else + startdatapoint = 1; + } else { + if ((!err) && (fscanf(fp, "%s %s %s %d\n", buffer, buffer2, buffer3, &nbf) != 4)) { + if (verbosity) cout << "error in reading vtk files FIELD FieldData" << endl; + err++; + } + } + if (startdatapoint == 0) { + if (strcmp(buffer3, "int") != 0) // not integer + err++; + if ((!err) && (fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) err++; + // read nbf + if (verbosity) cout << " err= " << err << " read nbp " << nbp << endl; + if (err == 0) + for (nf = 0; nf < nbp; nf++) { + int ii[1]; + if (binary) { + if (fread(ii, sizeof(int), 1, fp) != 1) err++; + } else { + if (fscanf(fp, "%d", ii) != 1) err++; + } + if (err) break; } + if (err) cout << " err reading CELL_DATA at " << nf << endl; + + if ((!err) && (fscanf(fp, "%s %s %d\n", buffer, buffer2, &nbf) != 3)) err++; + nf = -1; + if (err == 0) + for (nf = 0; nf < nbf; nf++) { + float f[4]; + char cc[4]; + if (binary) { + if (fread(cc, sizeof(char), 4, fp) != 4) err++; + } else { + if (fscanf(fp, "%f %f %f %fa", f + 0, f + 1, f + 2, f + 3) != 4) err++; + } + if (err) break; } - - + if (err && nf >= 0 && verbosity) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; + + startdatapoint = 0; + } + } - if(pfields && err==0) { - if(verbosity>1) cout << " try reading POINT_DATA " << startdatapoint << endl; + if (pfields && err == 0) { + if (verbosity > 1) cout << " try reading POINT_DATA " << startdatapoint << endl; /* POINT_DATA 32436 FIELD FieldData 2 Velocity 3 32436 float - + */ - nbp =0;// no POINT_DATA - nbf=0; - if (startdatapoint==0) - { + nbp = 0; // no POINT_DATA + nbf = 0; + if (startdatapoint == 0) { if (fscanf(fp, "%s", buffer) != 1) { cout << "error in reading vtk files pfields" << endl; err++; + } else { + if (verbosity) cout << " buff: " << buffer << nbp << endl; } - else {if (verbosity) cout << " buff: "<< buffer << nbp << endl;} } - if (strcmp(buffer, "POINT_DATA")==0) { - if(startdatapoint==0) - if (fscanf(fp, "%d", &nbp) != 1) err++; - if (fscanf(fp, "%s", buffer) != 1) err++; - } - if(err == 0 && strcmp(buffer, "FIELD")!=0) { - cout << "VTK reader can only read FIELD/POINT_DATA datasets: not " << buffer<< endl; + if (strcmp(buffer, "POINT_DATA") == 0) { + if (startdatapoint == 0) + if (fscanf(fp, "%d", &nbp) != 1) err++; + if (fscanf(fp, "%s", buffer) != 1) err++; + } + if (err == 0 && strcmp(buffer, "FIELD") != 0) { + cout << "VTK reader can only read FIELD/POINT_DATA datasets: not " << buffer << endl; + err++; + } + + if ((!err) && (fscanf(fp, "%s %d", buffer2, &nbf) != 2)) { + cout << "error in reading vtk files FIELD FieldData" << endl; + err++; + } + + if (err) + nbf = 0; + else + pfields->resize(nbf); + for (int nf = 0; nf < nbf; nf++) { + + int m, nv; + // read mesh vertices + if (fscanf(fp, "%s %d %d %s\n", buffer, &m, &nv, buffer2) != 4) { + cout << "error in reading vtk files " << endl; err++; + break; } - - if ((!err) &&(fscanf(fp, "%s %d", buffer2,&nbf) != 2)) { - cout << "error in reading vtk files FIELD FieldData" << endl; + int n = m * nv; + if (verbosity) cout << " reading " << buffer << " " << m << " " << nv << " " << buffer2 << endl; + int datasize; + if (!strncmp(buffer2, "double", 6)) + datasize = sizeof(double); + else if (!strncmp(buffer2, "float", 5)) + datasize = sizeof(float); + else { + if (verbosity) cout << "VTK reader only accepts float or double datasets" << endl; err++; + break; } - - if( err) nbf=0; - else pfields->resize(nbf); - for(int nf=0 ; nf < nbf; nf++) { - - int m,nv; - // read mesh vertices - if (fscanf(fp, "%s %d %d %s\n", buffer,&m, &nv, buffer2) != 4) { - cout << "error in reading vtk files " << endl; - err++; - break; - } - int n = m*nv; - if(verbosity) cout << " reading "<< buffer << " "<< m << " " << nv << " "<< buffer2 << endl; - int datasize; - if (!strncmp(buffer2, "double", 6)) - datasize = sizeof(double); - else if (!strncmp(buffer2, "float", 5)) - datasize = sizeof(float); - else { - if (verbosity) cout << "VTK reader only accepts float or double datasets" << endl; - err++; - break; - } - // read data .. - if(err) break; - (*pfields)[nf].resize(n); - double* pv=&(*pfields)[nf][0]; - for(int i=0; i9) cout << i << " " << firstCell[i + 1] << " " << firstCell[i] << endl; + if (verbosity > 9) cout << i << " " << firstCell[i + 1] << " " << firstCell[i] << endl; assert((firstCell[i + 1] - firstCell[i]) == 3); for (int j = firstCell[i]; j < firstCell[i + 1]; j++) { @@ -3728,33 +3677,32 @@ Mesh3 *VTK_Load3(const string &filename, bool bigEndian, bool cleanmesh, bool re } (ttff)->set(vff, ivt, label); - if(ttff->mesure() < 0) { - badorient ++; - - if( verbosity && badorient <11 ) - cout << " ** " << badorient << " bad Tet "<< (ttff-tff) << " : " - << ivt[0]<< " " <setP(&Th, it, iv); for (int j = 0; j < (*this).nbfloat; j++) { - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); } takemesh[i] = takemesh[i] + 1; @@ -4235,8 +4177,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP1_double(FILE *fp, const Mesh3 &Th, Stack stack, bool binary, bool bigEndian, - bool XML = false) const { + void writesolutionP1_double(FILE *fp, const Mesh3 &Th, Stack stack, bool binary, bool bigEndian, bool XML = false) const { unsigned char ElementChars[256]; MeshPoint *mp3(MeshPointStack(stack)); @@ -4251,8 +4192,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { mp3->setP(&Th, it, iv); for (int j = 0; j < (*this).nbfloat; j++) { - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); } takemesh[i] = takemesh[i] + 1; @@ -4326,9 +4266,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { #endif static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: VTK_WriteMesh3_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -4365,7 +4303,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { l[jj][0] = to< double >(args[i]); char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = scas; l[jj].name += number; sca++; @@ -4373,8 +4311,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); // cout << "taille" << a0->size() << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 3D: vector solution is 3 components, tensor solution is 6 components"); + CompileError("savesol in 3D: vector solution is 3 components, tensor solution is 6 components"); } if (a0->size( ) == ddim) { @@ -4387,7 +4324,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = vecs; l[jj].name += number; vec++; @@ -4401,7 +4338,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = tens; l[jj].name += number; ten++; @@ -4413,9 +4350,7 @@ class VTK_WriteMesh3_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new VTK_WriteMesh3_Op(args); } @@ -4435,8 +4370,7 @@ basicAC_F0::name_and_type VTK_WriteMesh3_Op::name_param[] = {{"dataname", &typei #endif {"append", &typeid(bool)}}; -void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool binary, int datasize, - bool surface, bool bigEndian) { +void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool binary, int datasize, bool surface, bool bigEndian) { fprintf(fp, "# vtk DataFile Version 2.0\n"); fprintf(fp, "%s, Created by Freefem++ \n", filename.c_str( )); if (binary) { @@ -4451,12 +4385,10 @@ void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool bin // write mesh vertices if (datasize == sizeof(float)) { fprintf(fp, "POINTS %d float\n", Th.nv); - } - else if (datasize == sizeof(double)) { + } else if (datasize == sizeof(double)) { fprintf(fp, "POINTS %d double\n", Th.nv); - } - else - ffassert(0); + } else + ffassert(0); if (datasize == sizeof(float)) { for (unsigned int i = 0; i < Th.nv; i++) { const Vertex3 &P = Th.vertices[i]; @@ -4481,7 +4413,7 @@ void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool bin f[0] = P.x; f[1] = P.y; f[2] = P.z; // 3D case - if (binary) { + if (binary) { if (!bigEndian) { FreeFEM::SwapBytes((char *)&f, sizeof(double), 3); } @@ -4494,7 +4426,7 @@ void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool bin fprintf(fp, "\n"); if (verbosity > 1) { - printf("writing vertices is finish %ld \n",ftell(fp)); + printf("writing vertices is finish %ld \n", ftell(fp)); } if (verbosity > 1) { @@ -4770,8 +4702,8 @@ void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool bin tab[3] = 255; for (int itab = 0; itab < 4; itab++) { - char newvalue[sizeof(int)+1]; - int bid0 = snprintf(newvalue,sizeof(int)+1, "%s", (char *)&tab[itab]); + char newvalue[sizeof(int) + 1]; + int bid0 = snprintf(newvalue, sizeof(int) + 1, "%s", (char *)&tab[itab]); fwrite(&newvalue, sizeof(unsigned char), 1, fp); } } else { @@ -4791,7 +4723,7 @@ void VTK_WRITE_MESH3(const string &filename, FILE *fp, const Mesh3 &Th, bool bin AnyType VTK_WriteMesh3_Op::operator( )(Stack stack) const { string *pffname = GetAny< string * >((*filename)(stack)); Mesh3 *pTh = GetAny< Mesh3 * >((*eTh)(stack)); - MeshPoint *mp3(MeshPointStack(stack)),mps=*mp3; + MeshPoint *mp3(MeshPointStack(stack)), mps = *mp3; ffassert(pTh); Mesh3 &Th = *pTh; @@ -4842,10 +4774,9 @@ AnyType VTK_WriteMesh3_Op::operator( )(Stack stack) const { #ifdef COMMON_HPDDM_PARALLEL_IO int time, size; std::string base_filename; - std::string CellDataArrayForPvtu = ""; + std::string CellDataArrayForPvtu = ""; std::string PointDataArrayForPvtu = ""; - parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, - nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); + parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); #endif int datasize = floatmesh ? sizeof(float) : sizeof(double); @@ -4886,8 +4817,7 @@ AnyType VTK_WriteMesh3_Op::operator( )(Stack stack) const { if (iii < nbofsol) { if (verbosity) { - cout << " iovtk writeMesh3: The number of data name is too small, we give default name " - << endl; + cout << " iovtk writeMesh3: The number of data name is too small, we give default name " << endl; } } } @@ -5085,7 +5015,7 @@ AnyType VTK_WriteMesh3_Op::operator( )(Stack stack) const { } delete[] pch; - *mp3=mps; + *mp3 = mps; return (Mesh3 *)NULL; } @@ -5137,8 +5067,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { return 0; } - void writesolutionP0_float_binary(FILE *fp, const MMesh &Th, Stack stack, bool surface, - bool bigEndian) const { + void writesolutionP0_float_binary(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool bigEndian) const { MeshPoint *mp3(MeshPointStack(stack)); typedef typename MMesh::Element T; typedef typename MMesh::Element::RdHat TRdHat; @@ -5296,8 +5225,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP0_float(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool binary, - bool bigEndian, bool XML = false) const { + void writesolutionP0_float(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool binary, bool bigEndian, bool XML = false) const { if (binary) { if (!XML) { (*this).writesolutionP0_float_binary(fp, Th, stack, surface, bigEndian); @@ -5309,8 +5237,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { } } - void writesolutionP0_double_binary(FILE *fp, const MMesh &Th, Stack stack, bool surface, - bool bigEndian) const { + void writesolutionP0_double_binary(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool bigEndian) const { MeshPoint *mp3(MeshPointStack(stack)); typedef typename MMesh::Element T; typedef typename MMesh::Element::RdHat TRdHat; @@ -5468,8 +5395,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP0_double(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool binary, - bool bigEndian, bool XML = false) const { + void writesolutionP0_double(FILE *fp, const MMesh &Th, Stack stack, bool surface, bool binary, bool bigEndian, bool XML = false) const { if (binary) if (!XML) (*this).writesolutionP0_double_binary(fp, Th, stack, surface, bigEndian); @@ -5480,8 +5406,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { (*this).writesolutionP0_double(fp, Th, stack, surface); } - void writesolutionP1_float(FILE *fp, const MMesh &Th, Stack stack, bool binary, bool bigEndian, - bool XML = false) const { + void writesolutionP1_float(FILE *fp, const MMesh &Th, Stack stack, bool binary, bool bigEndian, bool XML = false) const { unsigned char ElementChars[256]; MeshPoint *mp3(MeshPointStack(stack)); @@ -5495,9 +5420,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { int i = Th(it, iv); mp3->setP(&Th, it, iv); - for (int j = 0; j < (*this).nbfloat; j++) - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + for (int j = 0; j < (*this).nbfloat; j++) valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); takemesh[i] = takemesh[i] + 1; } @@ -5557,8 +5480,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { fprintf(fp, "\n"); } - void writesolutionP1_double(FILE *fp, const MMesh &Th, Stack stack, bool binary, bool bigEndian, - bool XML = false) const { + void writesolutionP1_double(FILE *fp, const MMesh &Th, Stack stack, bool binary, bool bigEndian, bool XML = false) const { unsigned char ElementChars[256]; MeshPoint *mp3(MeshPointStack(stack)); @@ -5572,9 +5494,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { int i = Th(it, iv); mp3->setP(&Th, it, iv); - for (int j = 0; j < (*this).nbfloat; j++) - valsol[i * (*this).nbfloat + j] = - valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); + for (int j = 0; j < (*this).nbfloat; j++) valsol[i * (*this).nbfloat + j] = valsol[i * (*this).nbfloat + j] + (*this).eval(j, stack); takemesh[i] = takemesh[i] + 1; } @@ -5635,27 +5555,18 @@ class VTK_WriteMeshT_Op : public E_F0mps { vector< Expression2 > l; #ifndef COMMON_HPDDM_PARALLEL_IO - static const int n_name_param = std::is_same::value ? 8 : 7; + static const int n_name_param = std::is_same< MMesh, MeshS >::value ? 8 : 7; #else - static const int n_name_param = std::is_same::value ? 9 : 8;; + static const int n_name_param = std::is_same< MMesh, MeshS >::value ? 9 : 8; + ; #endif static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - string* arg(int i, Stack stack, string* a) const { - return nargs[i] ? GetAny< string* >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } public: VTK_WriteMeshT_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -5689,7 +5600,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { l[jj][0] = to< double >(args[i]); char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = scas; l[jj].name += number; sca++; @@ -5697,8 +5608,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); // cout << "taille" << a0->size() << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 3D: vector solution is 3 components, tensor solution is 3 components"); + CompileError("savesol in 3D: vector solution is 3 components, tensor solution is 3 components"); } if (a0->size( ) == ddim) { @@ -5711,7 +5621,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = vecs; l[jj].name += number; vec++; @@ -5725,7 +5635,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { } char number[16]; - snprintf(number,16, "%li", jj + 1); + snprintf(number, 16, "%li", jj + 1); l[jj].name = tens; l[jj].name += number; ten++; @@ -5737,9 +5647,7 @@ class VTK_WriteMeshT_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new VTK_WriteMeshT_Op< MMesh >(args); } @@ -5747,37 +5655,34 @@ class VTK_WriteMeshT_Op : public E_F0mps { }; template<> -basicAC_F0::name_and_type VTK_WriteMeshT_Op< MeshS >::name_param[] = { - {"dataname", &typeid(string *)}, - {"withsurfacemesh", &typeid(bool)}, - {"order", &typeid(KN_< long >)}, - // A rajouter dans le 3D - {"floatmesh", &typeid(bool)}, - {"floatsol", &typeid(bool)}, - {"bin", &typeid(bool)}, - {"swap", &typeid(bool)}, +basicAC_F0::name_and_type VTK_WriteMeshT_Op< MeshS >::name_param[] = {{"dataname", &typeid(string *)}, + {"withsurfacemesh", &typeid(bool)}, + {"order", &typeid(KN_< long >)}, + // A rajouter dans le 3D + {"floatmesh", &typeid(bool)}, + {"floatsol", &typeid(bool)}, + {"bin", &typeid(bool)}, + {"swap", &typeid(bool)}, #ifdef COMMON_HPDDM_PARALLEL_IO - {"communicator", &typeid(pcommworld)}, + {"communicator", &typeid(pcommworld)}, #endif - {"append", &typeid(bool)}}; + {"append", &typeid(bool)}}; template<> -basicAC_F0::name_and_type VTK_WriteMeshT_Op< MeshL >::name_param[] = { - {"dataname", &typeid(string *)}, - {"withsurfacemesh", &typeid(bool)}, - {"order", &typeid(KN_< long >)}, - // A rajouter dans le 3D - {"floatmesh", &typeid(bool)}, - {"floatsol", &typeid(bool)}, - {"bin", &typeid(bool)}, +basicAC_F0::name_and_type VTK_WriteMeshT_Op< MeshL >::name_param[] = {{"dataname", &typeid(string *)}, + {"withsurfacemesh", &typeid(bool)}, + {"order", &typeid(KN_< long >)}, + // A rajouter dans le 3D + {"floatmesh", &typeid(bool)}, + {"floatsol", &typeid(bool)}, + {"bin", &typeid(bool)}, #ifdef COMMON_HPDDM_PARALLEL_IO - {"communicator", &typeid(pcommworld)}, + {"communicator", &typeid(pcommworld)}, #endif - {"append", &typeid(bool)}}; + {"append", &typeid(bool)}}; template< class MMesh > -void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool binary, int datasize, - bool surface, bool bigEndian) { +void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool binary, int datasize, bool surface, bool bigEndian) { typedef typename MMesh::Element T; typedef typename MMesh::BorderElement B; typedef typename MMesh::Vertex V; @@ -5833,8 +5738,7 @@ void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool bin //= =============== // loop over all elements we need to save and count vertices int numElements = surface ? Th.nt + Th.nbe : Th.nt; - int totalNumInt = - surface ? Th.nt * (T::nv) + Th.nbe * (B::nv) + numElements : Th.nt * (T::nv) + numElements; + int totalNumInt = surface ? Th.nt * (T::nv) + Th.nbe * (B::nv) + numElements : Th.nt * (T::nv) + numElements; if (verbosity > 1) printf("writing cells \n"); @@ -5875,9 +5779,9 @@ void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool bin int iv[(T::nv) + 2]; iv[0] = (T::nv); for (int ii = 0; ii < (T::nv); ii++) iv[ii + 1] = Th.operator( )(K[ii]); - if (T::nv==3) + if (T::nv == 3) fprintf(fp, "%d %d %d %d\n", iv[0], iv[1], iv[2], iv[3]); - else if (T::nv==2) + else if (T::nv == 2) fprintf(fp, "%d %d %d\n", iv[0], iv[1], iv[2]); } if (surface) { @@ -5887,9 +5791,9 @@ void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool bin int iv[(B::nv) + 2]; iv[0] = (B::nv); for (int ii = 0; ii < (B::nv); ii++) iv[ii + 1] = Th.operator( )(K[ii]); - if (B::nv==2) + if (B::nv == 2) fprintf(fp, "%d %d %d\n", iv[0], iv[1], iv[2]); - else if (B::nv==1) + else if (B::nv == 1) fprintf(fp, "%d %d\n", iv[0], iv[1]); } } @@ -6038,8 +5942,8 @@ void VTK_WRITE_MESHT(const string &filename, FILE *fp, const MMesh &Th, bool bin tab[3] = 255; for (int itab = 0; itab < 4; itab++) { - char newvalue[sizeof(int)+1]; - int bid0 = snprintf(newvalue,sizeof(int)+1,"%s", (char *)&tab[itab]); + char newvalue[sizeof(int) + 1]; + int bid0 = snprintf(newvalue, sizeof(int) + 1, "%s", (char *)&tab[itab]); fwrite(&newvalue, sizeof(unsigned char), 1, fp); } } else { @@ -6086,10 +5990,9 @@ AnyType VTK_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { #ifdef COMMON_HPDDM_PARALLEL_IO int time, size; std::string base_filename; - std::string CellDataArrayForPvtu = ""; + std::string CellDataArrayForPvtu = ""; std::string PointDataArrayForPvtu = ""; - parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, - nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); + parallelIO(pffname, nargs[7] ? (MPI_Comm *)GetAny< pcommworld >((*nargs[7])(stack)) : 0, nargs[8] && GetAny< bool >((*nargs[8])(stack)), time, size, base_filename); #endif int iii = 0; @@ -6099,31 +6002,25 @@ AnyType VTK_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { char *name = strtok(data, " \t\n"); nameofuser[iii] = newcopy(name); - if (verbosity > 5) - cout << " iovtk writeMesh: value of iii =" << iii << " \"" << nameofuser[iii] << "\"\n"; + if (verbosity > 5) cout << " iovtk writeMesh: value of iii =" << iii << " \"" << nameofuser[iii] << "\"\n"; iii++; while ((name = strtok(NULL, " \t\n\0"))) { if (iii >= nbofsol) { - if (verbosity > 5) - cout << " iovtk writeMesh: The number of data name is too large " << endl; + if (verbosity > 5) cout << " iovtk writeMesh: The number of data name is too large " << endl; break; } nameofuser[iii] = newcopy(name); - if (verbosity > 5) - cout << " iovtk writeMesh: value of iii =" << iii << " \"" << nameofuser[iii] << "\"\n"; + if (verbosity > 5) cout << " iovtk writeMesh: value of iii =" << iii << " \"" << nameofuser[iii] << "\"\n"; iii++; } if (iii < nbofsol) - if (verbosity) - cout << " iovtk writeMesh: The number of data name is too small, we give default name " - << endl; + if (verbosity) cout << " iovtk writeMesh: The number of data name is too small, we give default name " << endl; } if (iii < nbofsol) - for (int iiii = iii; iiii < nbofsol; iiii++) - nameofuser[iiii] = newcopy(l[iiii].name.c_str( )); // dataff; + for (int iiii = iii; iiii < nbofsol; iiii++) nameofuser[iiii] = newcopy(l[iiii].name.c_str( )); // dataff; // determination of number of order 0 et 1. int Norder0 = 0; @@ -6171,8 +6068,7 @@ AnyType VTK_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { } fprintf(fp, "%s %ld %d float\n", nameofuser[ii], l[ii].nbfloat, nsol); - if (verbosity > 5) - cout << " iovtk writeMesh: name of data(" << ii << ")=" << nameofuser[ii] << endl; + if (verbosity > 5) cout << " iovtk writeMesh: name of data(" << ii << ")=" << nameofuser[ii] << endl; // changement ecriture solution l[ii].writesolutionP0_float(fp, Th, stack, surface, binary, swap); } @@ -6188,8 +6084,7 @@ AnyType VTK_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { // fprintf(fp,"%s %d %d float\n",l[ii].name.c_str(),l[ii].nbfloat,Th.nv); fprintf(fp, "%s %ld %d float\n", nameofuser[ii], l[ii].nbfloat, Th.nv); if (verbosity > 5) { - cout << "iovtk writeMeshS: name of data(" << ii << ")=" << nameofuser[ii] << " " - << l[ii].name << endl; + cout << "iovtk writeMeshS: name of data(" << ii << ")=" << nameofuser[ii] << " " << l[ii].name << endl; } // changement ecriture solution @@ -6213,8 +6108,7 @@ AnyType VTK_WriteMeshT_Op< MMesh >::operator( )(Stack stack) const { } fprintf(fp, "%s %ld %d double\n", nameofuser[ii], l[ii].nbfloat, nsol); - if (verbosity > 5) - cout << " iovtk writeMeshS:name of data(" << ii << ")=" << nameofuser[ii] << endl; + if (verbosity > 5) cout << " iovtk writeMeshS:name of data(" << ii << ")=" << nameofuser[ii] << endl; // changement ecriture solution l[ii].writesolutionP0_double(fp, Th, stack, surface, binary, swap); @@ -6331,20 +6225,12 @@ class VTK_LoadMeshT_Op : public E_F0mps { static const int n_name_param = 9; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } - string* arg(int i, Stack stack, string* a) const { return nargs[i] ? GetAny< string* >((*nargs[i])(stack)) : a;} - KN >* arg(int i, Stack stack,KN >*p) const { - return nargs[i] ? GetAny< KN >* >((*nargs[i])(stack)) : p; - } - + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } + KN< KN< double > > *arg(int i, Stack stack, KN< KN< double > > *p) const { return nargs[i] ? GetAny< KN< KN< double > > * >((*nargs[i])(stack)) : p; } + public: VTK_LoadMeshT_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { if (verbosity) { @@ -6358,30 +6244,26 @@ class VTK_LoadMeshT_Op : public E_F0mps { }; template<> -basicAC_F0::name_and_type VTK_LoadMeshT_Op< MeshS >::name_param[] = { - {"reftri", &typeid(long)}, - {"swap", &typeid(bool)}, - {"refedge", &typeid(long)}, - {"namelabel", &typeid(string*)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)}, - {"ridgeangledetection", &typeid(double)}, - {"fields", &typeid( KN >*)} -}; +basicAC_F0::name_and_type VTK_LoadMeshT_Op< MeshS >::name_param[] = {{"reftri", &typeid(long)}, + {"swap", &typeid(bool)}, + {"refedge", &typeid(long)}, + {"namelabel", &typeid(string *)}, + {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, + {"precisvertice", &typeid(double)}, + {"ridgeangledetection", &typeid(double)}, + {"fields", &typeid(KN< KN< double > > *)}}; template<> -basicAC_F0::name_and_type VTK_LoadMeshT_Op< MeshL >::name_param[] = { - {"refedge", &typeid(long)}, - {"swap", &typeid(bool)}, - {"refbdpoint", &typeid(long)}, - {"namelabel", &typeid(string*)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precisvertice", &typeid(double)}, - {"ridgeangledetection", &typeid(double)}, - {"fields", &typeid( KN >*)} -}; +basicAC_F0::name_and_type VTK_LoadMeshT_Op< MeshL >::name_param[] = {{"refedge", &typeid(long)}, + {"swap", &typeid(bool)}, + {"refbdpoint", &typeid(long)}, + {"namelabel", &typeid(string *)}, + {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, + {"precisvertice", &typeid(double)}, + {"ridgeangledetection", &typeid(double)}, + {"fields", &typeid(KN< KN< double > > *)}}; template< class MMesh > class VTK_LoadMeshT : public OneOperator { @@ -6389,14 +6271,11 @@ class VTK_LoadMeshT : public OneOperator { typedef const MMesh *ppmesh; VTK_LoadMeshT( ) : OneOperator(atype< ppmesh >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new VTK_LoadMeshT_Op< MMesh >(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new VTK_LoadMeshT_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; template< class MMesh > -MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, - double precisvertice, double ridgeangledetection, KN >* pfields) { +MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool removeduplicate, double precisvertice, double ridgeangledetection, KN< KN< double > > *pfields) { // swap = bigEndian or not bigEndian // variable freefem++ typedef typename MMesh::Element T; @@ -6413,7 +6292,8 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re exit(1); } - char buffer[256], buffer2[256], buffer3[256];; + char buffer[256], buffer2[256], buffer3[256]; + ; res = fgets(buffer, sizeof(buffer), fp); // version line res = fgets(buffer, sizeof(buffer), fp); // title @@ -6457,9 +6337,7 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re exit(1); } - if (verbosity > 3) - cout << "Reading points" << nv << ", buffer2 " << buffer2 << ", binary " << binary << " " - << datasize << " " << sizeof(float) << endl; + if (verbosity > 3) cout << "Reading points" << nv << ", buffer2 " << buffer2 << ", binary " << binary << " " << datasize << " " << sizeof(float) << endl; V *vff = new V[nv]; @@ -6635,8 +6513,7 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re break; case 10: // Tetrah�dre if (std::is_same< MMesh, MeshS >::value) - cout << "We are loading a three dimensional SURFACE mesh. Three is no tetrahedron." - << endl; + cout << "We are loading a three dimensional SURFACE mesh. Three is no tetrahedron." << endl; else if (std::is_same< MMesh, MeshL >::value) cout << "We are loading a three dimensional CURVE mesh. Three is no tetrahedron." << endl; ExecError("error in reading vtk file"); @@ -6648,165 +6525,160 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re } } - int nbp=0,nbf=0, err=0; - if (fscanf(fp, "%s %d", buffer, &nbp) != 2) - { cout << "error in reading vtk files pfields" << endl; - err++;} - int startdatapoint=0; - if(err==0) - { - int nf=-1; - /* - CELL_DATA 209726 - Scalars Label int 1 - LOOKUP_TABLE FreeFempp_table - .... - LOOKUP_TABLE FreeFempp_table 7 - 4*7 value - */ - - if (strcmp(buffer, "CELL_DATA")) { // read region number if exist - if (strcmp(buffer, "POINT_DATA")) { - cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer<< " " << nbp<< endl; - err=1; - } - else startdatapoint=1; - } - else { - if ((!err) &&(fscanf(fp, "%s %s %s %d\n", buffer, buffer2,buffer3,&nbf) != 4)) { - cout << "error in reading vtk files FIELD FieldData" << endl; - err++; - }} - - if( strcmp(buffer3, "int") !=0)// not integer - err++; - if ((!err) &&(fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) - err++; - // read nbf - cout << " err= " << err << " read nbp "<< nbp << endl; - if(err==0) - for( nf=0 ; nf < nbp; nf++) - { - int ii[1]; - if (binary) - { if (fread(ii, sizeof(int), 1, fp) != 1) err++;} - else - { if (fscanf(fp, "%d", ii) != 1) err++;} - if(err) break; - } - if(err) cout << " err reading CELL_DATA at " << nf << endl; - if ((!err) &&(fscanf(fp, "%s %s %d\n", buffer, buffer2,&nbf) != 3 ) ) err++; - nf =-1; - if(err==0) - for( nf=0 ; nf < nbf; nf++) - { - float f[4]; - char cc[4]; - if (binary) - { if (fread(cc, sizeof(char), 4, fp) != 4) err++;} - else - { if (fscanf(fp, "%f %f %f %fa",f+0,f+1,f+2,f+3) != 4) err++;} - if(err) break; - } - if(err&& nf>=0) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; - - startdatapoint=0; - } - - - if(pfields && err==0) { - if(verbosity>1) cout << " try reading POINT_DATA " << startdatapoint << endl; + int nbp = 0, nbf = 0, err = 0; + if (fscanf(fp, "%s %d", buffer, &nbp) != 2) { + cout << "error in reading vtk files pfields" << endl; + err++; + } + int startdatapoint = 0; + if (err == 0) { + int nf = -1; + /* + CELL_DATA 209726 + Scalars Label int 1 + LOOKUP_TABLE FreeFempp_table + .... + LOOKUP_TABLE FreeFempp_table 7 + 4*7 value + */ + + if (strcmp(buffer, "CELL_DATA")) { // read region number if exist + if (strcmp(buffer, "POINT_DATA")) { + cout << "VTK reader can only read CELL_DATA or POINT_DATA datasets: not " << buffer << " " << nbp << endl; + err = 1; + } else + startdatapoint = 1; + } else { + if ((!err) && (fscanf(fp, "%s %s %s %d\n", buffer, buffer2, buffer3, &nbf) != 4)) { + cout << "error in reading vtk files FIELD FieldData" << endl; + err++; + } + } + + if (strcmp(buffer3, "int") != 0) // not integer + err++; + if ((!err) && (fscanf(fp, "%s %s\n", buffer, buffer2) != 2)) err++; + // read nbf + cout << " err= " << err << " read nbp " << nbp << endl; + if (err == 0) + for (nf = 0; nf < nbp; nf++) { + int ii[1]; + if (binary) { + if (fread(ii, sizeof(int), 1, fp) != 1) err++; + } else { + if (fscanf(fp, "%d", ii) != 1) err++; + } + if (err) break; + } + if (err) cout << " err reading CELL_DATA at " << nf << endl; + if ((!err) && (fscanf(fp, "%s %s %d\n", buffer, buffer2, &nbf) != 3)) err++; + nf = -1; + if (err == 0) + for (nf = 0; nf < nbf; nf++) { + float f[4]; + char cc[4]; + if (binary) { + if (fread(cc, sizeof(char), 4, fp) != 4) err++; + } else { + if (fscanf(fp, "%f %f %f %fa", f + 0, f + 1, f + 2, f + 3) != 4) err++; + } + if (err) break; + } + if (err && nf >= 0) cout << " err LOOKUP_TABLE FreeFempp_table at " << nf << " " << err << endl; + + startdatapoint = 0; + } + + if (pfields && err == 0) { + if (verbosity > 1) cout << " try reading POINT_DATA " << startdatapoint << endl; /* POINT_DATA 32436 FIELD FieldData 2 Velocity 3 32436 float - + */ - nbp =0;// no POINT_DATA - nbf=0; - if (startdatapoint==0) + nbp = 0; // no POINT_DATA + nbf = 0; + if (startdatapoint == 0) if (fscanf(fp, "%s", buffer) != 1) { cout << "error in reading vtk files pfields" << endl; err++; } - - if (strcmp(buffer, "POINT_DATA")==0) { - if (fscanf(fp, "%d", &nbp) != 1) err++; - if (fscanf(fp, "%s", buffer) != 1) err++; - } - if(err == 0 && strcmp(buffer, "FIELD")!=0) { - cout << "VTK reader can only read FIELD/POINT_DATA datasets: not " << buffer<< endl; + + if (strcmp(buffer, "POINT_DATA") == 0) { + if (fscanf(fp, "%d", &nbp) != 1) err++; + if (fscanf(fp, "%s", buffer) != 1) err++; + } + if (err == 0 && strcmp(buffer, "FIELD") != 0) { + cout << "VTK reader can only read FIELD/POINT_DATA datasets: not " << buffer << endl; + err++; + } + + if ((!err) && (fscanf(fp, "%s %d", buffer2, &nbf) != 2)) { + cout << "error in reading vtk files FIELD FieldData" << endl; + err++; + } + + if (err) + nbf = 0; + else + pfields->resize(nbf); + for (int nf = 0; nf < nbf; nf++) { + + int m, nv; + // read mesh vertices + if (fscanf(fp, "%s %d %d %s\n", buffer, &m, &nv, buffer2) != 4) { + cout << "error in reading vtk files " << endl; err++; + break; } - - if ((!err) &&(fscanf(fp, "%s %d", buffer2,&nbf) != 2)) { - cout << "error in reading vtk files FIELD FieldData" << endl; + int n = m * nv; + if (verbosity) cout << " reading " << buffer << " " << m << " " << nv << " " << buffer2 << endl; + int datasize; + if (!strncmp(buffer2, "double", 6)) + datasize = sizeof(double); + else if (!strncmp(buffer2, "float", 5)) + datasize = sizeof(float); + else { + cout << "VTK reader only accepts float or double datasets" << endl; err++; + break; } - - if( err) nbf=0; - else pfields->resize(nbf); - for(int nf=0 ; nf < nbf; nf++) { - - int m,nv; - // read mesh vertices - if (fscanf(fp, "%s %d %d %s\n", buffer,&m, &nv, buffer2) != 4) { - cout << "error in reading vtk files " << endl; - err++; - break; - } - int n = m*nv; - if(verbosity) cout << " reading "<< buffer << " "<< m << " " << nv << " "<< buffer2 << endl; - int datasize; - if (!strncmp(buffer2, "double", 6)) - datasize = sizeof(double); - else if (!strncmp(buffer2, "float", 5)) - datasize = sizeof(float); - else { - cout << "VTK reader only accepts float or double datasets" << endl; - err++; - break; - } - // read data .. - if(err) break; - (*pfields)[nf].resize(n); - double* pv=&(*pfields)[nf][0]; - for(int i=0; i 0) tff = new T[nt]; @@ -6817,9 +6689,10 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re if (nbe > 0) bff = new B[nbe]; + else if (!std::is_same< MMesh, Mesh3 >::value) + bff = NULL; else - if (!std::is_same< MMesh, Mesh3 >::value) bff=NULL; - else ExecError("error in reading vtk file: Not border element"); + ExecError("error in reading vtk file: Not border element"); B *bbff = bff; for (unsigned int i = 0; i < numElements; i++) { @@ -6858,7 +6731,7 @@ MMesh *VTK_LoadT(const string &filename, bool bigEndian, bool cleanmesh, bool re delete[] firstCell; delete[] TypeCells; - MMesh *pTh = new MMesh(nv, nt, nbe, vff, tff, bff, cleanmesh || (nbe==0), removeduplicate, (nbe==0), precisvertice); + MMesh *pTh = new MMesh(nv, nt, nbe, vff, tff, bff, cleanmesh || (nbe == 0), removeduplicate, (nbe == 0), precisvertice); return pTh; } @@ -6875,11 +6748,11 @@ AnyType VTK_LoadMeshT_Op< MMesh >::operator( )(Stack stack) const { bool cleanmesh(arg(4, stack, false)); bool removeduplicate(arg(5, stack, false)); double precisvertice(arg(6, stack, 1e-6)); - double ridgeangledetection(arg(7, stack, 8.*atan(1.)/9.)); - KN > * pfields=0; - pfields=arg(8, stack,pfields); - - MMesh *Th = VTK_LoadT< MMesh >(*pffname, swap, cleanmesh, removeduplicate, precisvertice,ridgeangledetection, pfields); + double ridgeangledetection(arg(7, stack, 8. * atan(1.) / 9.)); + KN< KN< double > > *pfields = 0; + pfields = arg(8, stack, pfields); + + MMesh *Th = VTK_LoadT< MMesh >(*pffname, swap, cleanmesh, removeduplicate, precisvertice, ridgeangledetection, pfields); // TODO Axel // MMesh *Th = VTK_LoadT< MMesh >(*pffname, swap, cleanmesh || (nbe==0), removeduplicate, (nbe==0), precisvertice,ridgeangledetection, pfields); diff --git a/plugin/seq/isoline.cpp b/plugin/seq/isoline.cpp index 5ec8ede94..5017cd5f1 100644 --- a/plugin/seq/isoline.cpp +++ b/plugin/seq/isoline.cpp @@ -61,38 +61,24 @@ class FINDLOCALMIN_P1_Op : public E_F0mps { static const int n_name_param = 2; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - KN< long > *arg(int i, Stack stack, KN< long > *a) const { - return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; - } + KN< long > *arg(int i, Stack stack, KN< long > *a) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: - FINDLOCALMIN_P1_Op(const basicAC_F0 &args, Expression tth, Expression fu, Expression fr) - : eTh(tth), eu(fu), er(fr) { - args.SetNameParam(n_name_param, name_param, nargs); - } + FINDLOCALMIN_P1_Op(const basicAC_F0 &args, Expression tth, Expression fu, Expression fr) : eTh(tth), eu(fu), er(fr) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type FINDLOCALMIN_P1_Op::name_param[] = {{"eps", &typeid(double)}, - {"convex", &typeid(long)}}; -template +basicAC_F0::name_and_type FINDLOCALMIN_P1_Op::name_param[] = {{"eps", &typeid(double)}, {"convex", &typeid(long)}}; +template< class Mesh > class ISOLINE_P1_Op : public E_F0mps { public: Expression eTh, eff, emat, exx, eyy, exy, iso; @@ -100,47 +86,33 @@ class ISOLINE_P1_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - KN< long > *arg(int i, Stack stack, KN< long > *a) const { - return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; - } + KN< long > *arg(int i, Stack stack, KN< long > *a) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: - ISOLINE_P1_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx, - Expression yyy) - : eTh(tth), eff(fff), emat(0), exx(xxx), eyy(yyy), exy(0) { + ISOLINE_P1_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxx, Expression yyy) : eTh(tth), eff(fff), emat(0), exx(xxx), eyy(yyy), exy(0) { args.SetNameParam(n_name_param, name_param, nargs); } - ISOLINE_P1_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxyy) - : eTh(tth), eff(fff), emat(0), exx(0), eyy(0), exy(xxyy) { + ISOLINE_P1_Op(const basicAC_F0 &args, Expression tth, Expression fff, Expression xxyy) : eTh(tth), eff(fff), emat(0), exx(0), eyy(0), exy(xxyy) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; -template -basicAC_F0::name_and_type ISOLINE_P1_Op::name_param[] = { - {"iso", &typeid(double)}, {"close", &typeid(long)}, {"smoothing", &typeid(double)}, - {"ratio", &typeid(double)}, {"eps", &typeid(double)}, {"beginend", &typeid(KN< long > *)}, - {"file", &typeid(string *)}}; - - - -double twoArea(const R2 &A,const R2 &B,const R2 &C){return det(A,B,C);} -double twoArea(const R3 &A,const R3 &B,const R3 &C){return ((A-B)^(A-C)).norme();} -template +template< class Mesh > +basicAC_F0::name_and_type ISOLINE_P1_Op< Mesh >::name_param[] = {{"iso", &typeid(double)}, {"close", &typeid(long)}, {"smoothing", &typeid(double)}, + {"ratio", &typeid(double)}, {"eps", &typeid(double)}, {"beginend", &typeid(KN< long > *)}, + {"file", &typeid(string *)}}; + +double twoArea(const R2 &A, const R2 &B, const R2 &C) { return det(A, B, C); } +double twoArea(const R3 &A, const R3 &B, const R3 &C) { return ((A - B) ^ (A - C)).norme( ); } +template< class Rd = R2 > int IsoLineK(Rd *P, double *f, Rd *Q, int *i0, int *i1, double eps) { int kv = 0, ke = 0, e = 3; int tv[3], te[3], vk[3]; @@ -245,7 +217,7 @@ int IsoLineK(Rd *P, double *f, Rd *Q, int *i0, int *i1, double eps) { // remark, the left of the line is upper . return 0; } -template +template< class Rd = R2 > int LineBorder(Rd *P, double *f, long close, Rd *Q, int *i1, int *i2, double eps) { int np = 0; @@ -269,7 +241,7 @@ int LineBorder(Rd *P, double *f, long close, Rd *Q, int *i1, int *i2, double eps return np; } -template +template< class Rd = R2 > struct R2_I2 { Rd P; int nx; @@ -336,13 +308,10 @@ int Th_Grid(const KNM_< double > *g, int k, int ii) { return J * (N + 1) + I; } - - - R3 V_Grid(const KNM_< double > *g, int k) { int i = k % g->N( ), j = k / g->N( ); - return R3(i, j,0); + return R3(i, j, 0); } int EA_Grid(const KNM_< double > *g, int k, int &e) { @@ -358,28 +327,27 @@ int EA_Grid(const KNM_< double > *g, int k, int &e) { ffassert(0); return 0; } -template +template< class Mesh > struct SMesh { - typedef typename Mesh::Rd Rd; - static Rd Proj(R3 A){return Rd(&A.x);} + typedef typename Mesh::Rd Rd; + static Rd Proj(R3 A) { return Rd(&A.x); } const Mesh *pTh; const KNM_< double > *g; - int nv, nt;//, neb; + int nv, nt; //, neb; int operator( )(int k, int i) const { return pTh ? (*pTh)(k, i) : Th_Grid(g, k, i); } - Rd operator( )(int i) const { return pTh ? (Rd) (*pTh)(i) : Proj( V_Grid(g, i)); } + Rd operator( )(int i) const { return pTh ? (Rd)(*pTh)(i) : Proj(V_Grid(g, i)); } int ElementAdj(int k, int &e) { return pTh ? pTh->ElementAdj(k, e) : EA_Grid(g, k, e); } - SMesh(const Mesh *PTh) : pTh(PTh), g(0), nv(pTh->nv), nt(pTh->nt)/*, neb(pTh->neb)*/ {} + SMesh(const Mesh *PTh) : pTh(PTh), g(0), nv(pTh->nv), nt(pTh->nt) /*, neb(pTh->neb)*/ {} SMesh(KNM_< double > *gg) : pTh(0), g(gg), nv(gg->N( ) * gg->M( )), nt((gg->N( ) - 1) * (gg->M( ) - 1) * 2) - //,neb((gg->N( ) + gg->M( ) - 2) * 2) - {} + //,neb((gg->N( ) + gg->M( ) - 2) * 2) + {} }; - ::AnyType FINDLOCALMIN_P1_Op::operator( )(Stack stack) const { typedef std::pair< double, int > KEY; typedef std::priority_queue< KEY, std::vector< KEY >, std::greater< KEY > > myPQ; @@ -503,8 +471,7 @@ ::AnyType FINDLOCALMIN_P1_Op::operator( )(Stack stack) const { --nbrv[j2]; if (ddd1) { - cout << "\t\t\t Add " << k << " " << j1 << " " << U[j1] << " / " << j2 << " " - << U[j2] << endl; + cout << "\t\t\t Add " << k << " " << j1 << " " << U[j1] << " / " << j2 << " " << U[j2] << endl; } if (nbrv[j1] > 0) { @@ -539,8 +506,8 @@ ::AnyType FINDLOCALMIN_P1_Op::operator( )(Stack stack) const { KN< long > *ppr = new KN< long >(sm); return Add2StackOfPtr2Free(stack, ppr); } -template -AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { +template< class Mesh > +AnyType ISOLINE_P1_Op< Mesh >::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; typedef typename Mesh::Rd Rd; KNM< double > *pxy = 0; @@ -559,10 +526,10 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { } const int d = Rd::d; ffassert((pxx || pyy) == !pxy); - //if(pxy) cout << " PXY ???? " << pxy->N() << " "<< pxy->M() << " " << pxy << " "<< pxx << " " << pyy <N() << " "<< pxy->M() << " " << pxy << " "<< pxx << " " << pyy <((*eTh)(stack)); ffassert(pTh); - SMesh Th(pTh); + SMesh< Mesh > Th(pTh); int nbv = Th.nv; // nombre de sommet int nbt = Th.nt; // nombre de triangles // int nbe=Th.neb; // nombre d'aretes fontiere @@ -575,7 +542,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { double epsr = arg(4, stack, 1e-10); KN< long > *pbeginend = arg(5, stack, (KN< long > *)0); string *file = arg(6, stack, (string *)0); - vector< R2_I2 > P; + vector< R2_I2< Rd > > P; multimap< int, int > L; if (verbosity >= 1000) { debug = verbosity / 1000; @@ -611,8 +578,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { double tffmax = tff.max( ), tffmin = tff.min( ); if (verbosity) { - cout << " -- isoline close=" << close << " iso= " << isovalue << " " << epsr << endl - << " bound isovalue :" << tffmin << " " << tffmax << " dim " << d << endl; + cout << " -- isoline close=" << close << " iso= " << isovalue << " " << epsr << endl << " bound isovalue :" << tffmin << " " << tffmax << " dim " << d << endl; } double eps = (tffmax - tffmin) * epsr; @@ -652,7 +618,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { pair< int, int > e(i1[i], i2[i]); ii = FP.insert(make_pair(e, P.size( ))); if (ii.second) { - P.push_back(R2_I2(Qk[i])); + P.push_back(R2_I2< Rd >(Qk[i])); } if (debug) { @@ -668,12 +634,12 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { cout << " +++ " << Qk[0] << " -> " << Qk[1] << " :: " << p[0] << " -> " << p[1] << endl; } - /* PB perp en sur meshS - if (fff) { - *fff << Qk[0] << "\n" - << Qk[1] << "\n" - << ((Qk[0] * 0.4 + Qk[1] * .6) + Rd(Qk[0], Qk[1]).perp( ) * .4) << "\n\n"; - }*/ + /* PB perp en sur meshS + if (fff) { + *fff << Qk[0] << "\n" + << Qk[1] << "\n" + << ((Qk[0] * 0.4 + Qk[1] * .6) + Rd(Qk[0], Qk[1]).perp( ) * .4) << "\n\n"; + }*/ } } @@ -697,8 +663,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { Rd Qk[2]; int i1[2], i2[2]; if (debug) { - cout << " LB : " << Pk[0] << ", " << fk[0] << " -> " << Pk[1] << ", " << fk[1] << " : " - << iK[0] << " " << iK[1] << endl; + cout << " LB : " << Pk[0] << ", " << fk[0] << " -> " << Pk[1] << ", " << fk[1] << " : " << iK[0] << " " << iK[1] << endl; } int np = LineBorder(Pk, fk, close, Qk, i1, i2, eps); @@ -714,8 +679,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { } if (debug) { - cout << " add : " << Qk[0] << ", " << i1[0] << ',' << i2[0] << " -> " << Qk[1] - << ", " << i1[1] << ',' << i2[1] << endl; + cout << " add : " << Qk[0] << ", " << i1[0] << ',' << i2[0] << " -> " << Qk[1] << ", " << i1[1] << ',' << i2[1] << endl; } int p[2]; // point number @@ -725,7 +689,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { pair< int, int > ee(i1[i], i2[i]); ii = FP.insert(make_pair(ee, P.size( ))); if (ii.second) { - P.push_back(R2_I2(Qk[i])); + P.push_back(R2_I2< Rd >(Qk[i])); } if (debug) { @@ -738,8 +702,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { // add line k[0], k[1] P[p[0]].add(p[0], p[1], L); if (debug) { - cout << " +++ " << Qk[0] << " -> " << Qk[1] << " :: " << p[0] << " -> " << p[1] - << endl; + cout << " +++ " << Qk[0] << " -> " << Qk[1] << " :: " << p[0] << " -> " << p[1] << endl; } } } @@ -907,8 +870,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { int i1 = iQ[i++] - 1; int nbsmoothing = pow((i1 - i0), ratio) * smoothing; if (verbosity > 2) { - cout << " curve " << i << " size = " << i1 - i0 << " nbsmoothing = " << nbsmoothing - << " " << i0 << " " << i1 << endl; + cout << " curve " << i << " size = " << i1 - i0 << " nbsmoothing = " << nbsmoothing << " " << i0 << " " << i1 << endl; } P2 = P1; @@ -947,14 +909,14 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { for (int i = 0; i < QQ.size( ); ++i) { int j = QQ[i]; - + (*pxx)[i] = P[j].P.x; (*pyy)[i] = P[j].P.y; } } else if (pxy) { - - pxy->resize(d+1, QQ.size( )); - if(verbosity>9) cout << " resize " << " xy " << d+1 << " " << QQ.size() << endl; + + pxy->resize(d + 1, QQ.size( )); + if (verbosity > 9) cout << " resize " << " xy " << d + 1 << " " << QQ.size( ) << endl; for (int k = 0; k < iQ.size( ); k += 2) { int i0 = iQ[k], i1 = iQ[k + 1]; double lg = 0; @@ -962,8 +924,7 @@ AnyType ISOLINE_P1_Op::operator( )(Stack stack) const { for (int i = i0; i < i1; ++i) { int j = QQ[i]; - for(int k=0; k::operator( )(Stack stack) const { return nbc; } -template +template< class Mesh > class ISOLINE_P1 : public OneOperator { public: typedef const Mesh *pmesh; int cas; - ISOLINE_P1( ) - : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), - atype< KN< double > * >( ), atype< KN< double > * >( )), - cas(4) {} + ISOLINE_P1( ) : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), atype< KN< double > * >( ), atype< KN< double > * >( )), cas(4) {} - ISOLINE_P1(int) - : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), - atype< KNM< double > * >( )), - cas(3) {} + ISOLINE_P1(int) : OneOperator(atype< long >( ), atype< pmesh >( ), atype< double >( ), atype< KNM< double > * >( )), cas(3) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 4) { - return new ISOLINE_P1_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + return new ISOLINE_P1_Op< Mesh >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } else if (cas == 3) { - return new ISOLINE_P1_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new ISOLINE_P1_Op< Mesh >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } else { ffassert(0); // bug } @@ -1050,24 +1003,19 @@ class FINDLOCALMIN_P1 : public OneOperator { typedef const Mesh *pmesh; int cas; - FINDLOCALMIN_P1( ) - : OneOperator(atype< KN< long > * >( ), atype< pmesh >( ), atype< KN< double > * >( ), - atype< KN< double > * >( )), - cas(1) {} + FINDLOCALMIN_P1( ) : OneOperator(atype< KN< long > * >( ), atype< pmesh >( ), atype< KN< double > * >( ), atype< KN< double > * >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 1) { - return new FINDLOCALMIN_P1_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new FINDLOCALMIN_P1_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } else { ffassert(0); // bug } } }; -R3 *Curve2(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, - long *const &pi) { - assert(b.N( ) ==2 ); +R3 *Curve2(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, long *const &pi) { + assert(b.N( ) == 2); int i0 = li0, i1 = li1, im; if (i0 < 0) { i0 = 0; @@ -1077,15 +1025,15 @@ R3 *Curve2(Stack stack, const KNM_< double > &b, const long &li0, const long &li i1 = b.M( ) - 1; } - double lg = (i1-i0); + double lg = (i1 - i0); R3 Q; double s = ss * lg; - i1 = min(i1, i0+1+(int) s ); - i0 = i1-1; + i1 = min(i1, i0 + 1 + (int)s); + i0 = i1 - 1; R2 A(b(0, i0), b(1, i0)); R2 B(b(0, i1), b(1, i1)); - double l1 = i1 - s; - double l0 = s - i0; + double l1 = i1 - s; + double l0 = s - i0; Q = (l1 * A + l0 * B) / (l1 + l0); if (pi) { @@ -1095,31 +1043,31 @@ R3 *Curve2(Stack stack, const KNM_< double > &b, const long &li0, const long &li R3 *pQ = Add2StackOfPtr2Free(stack, new R3(Q)); return pQ; } -long Dichotomy( const KN_< double > &b,const double & v) -{ - long i0 = 0, i1 = b.N()-1, im,k=0, k1 = i1; - if( v < b[i0] ) return -1L; - else if( v > b[i1] ) return -2L; - - while (i0 < i1 - 1) { - ffassert(k++ < k1); - im = (i0 + i1) / 2; - if (v < b(im)) { - i1 = im; - } else if (v > b(im)) { - i0 = im; - } else { - i0 = i1 = im; - break; - } +long Dichotomy(const KN_< double > &b, const double &v) { + long i0 = 0, i1 = b.N( ) - 1, im, k = 0, k1 = i1; + if (v < b[i0]) + return -1L; + else if (v > b[i1]) + return -2L; + + while (i0 < i1 - 1) { + ffassert(k++ < k1); + im = (i0 + i1) / 2; + if (v < b(im)) { + i1 = im; + } else if (v > b(im)) { + i0 = im; + } else { + i0 = i1 = im; + break; } - return i0; + } + return i0; } -R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, - long *const &pi) { - if(b.N( )==2) return Curve2(stack,b,li0,li1,ss,pi); +R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss, long *const &pi) { + if (b.N( ) == 2) return Curve2(stack, b, li0, li1, ss, pi); assert(b.N( ) >= 3); - int d = b.N() == 3 ? 2 : 3; + int d = b.N( ) == 3 ? 2 : 3; int i0 = li0, i1 = li1, im; if (i0 < 0) { i0 = 0; @@ -1143,8 +1091,8 @@ R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1 } else if (s > b(d, im)) { i0 = im; } else { - - Q = d==2 ? R3(b(0, im), b(1, im), 0) : R3(b(0, im), b(1, im), b(2, im)); + + Q = d == 2 ? R3(b(0, im), b(1, im), 0) : R3(b(0, im), b(1, im), b(2, im)); i0 = i1 = im; break; } @@ -1153,10 +1101,13 @@ R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1 if (i0 < i1) { ffassert(b(d, i0) <= s); ffassert(b(d, i1) >= s); - double b20=0,b21=0; - if( d==3) {b20=b(2, i0);b21=b(2, i1);} - R3 A(b(0, i0), b(1, i0),b20); - R3 B(b(0, i1), b(1, i1),b21); + double b20 = 0, b21 = 0; + if (d == 3) { + b20 = b(2, i0); + b21 = b(2, i1); + } + R3 A(b(0, i0), b(1, i0), b20); + R3 B(b(0, i1), b(1, i1), b21); double l1 = (b(d, i1) - s); double l0 = s - b(d, i0); Q = (l1 * A + l0 * B) / (l1 + l0); @@ -1170,10 +1121,7 @@ R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1 return pQ; } -R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, - const double &ss) { - return Curve(stack, b, li0, li1, ss, 0); -} +R3 *Curve(Stack stack, const KNM_< double > &b, const long &li0, const long &li1, const double &ss) { return Curve(stack, b, li0, li1, ss, 0); } double mesure(Stack stack, const KNM_< double > &b, const KN_< long > &be) { double mes = 0; @@ -1201,9 +1149,7 @@ double mesure(Stack stack, const KNM_< double > &b, const KN_< long > &be) { return mes / 2.; } -R3 *Curve(Stack stack, const KNM_< double > &b, const double &ss) { - return Curve(stack, b, -1, -1, ss); -} +R3 *Curve(Stack stack, const KNM_< double > &b, const double &ss) { return Curve(stack, b, -1, -1, ss); } template< class R, class A0, class A1, class A2, class A3, class A4, class E = E_F0 > // extend (4th arg.) @@ -1218,20 +1164,15 @@ class E_F_F0F0F0F0F0s_ : public E { : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4) {} // extend (4th arg.) AnyType operator( )(Stack s) const { - return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), - GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)))); + return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)))); } // extend (4th arg.) virtual size_t nbitem( ) const { return a4->nbitem( ); } // modif - bool MeshIndependent( ) const { - return a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && - a3->MeshIndependent( ) && a4->MeshIndependent( ); - } // extend (4th arg.) + bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ) && a4->MeshIndependent( ); } // extend (4th arg.) }; -template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, - class CODE = E_F_F0F0F0F0F0s_< R, A, B, C, D, E, E_F0 > > // extend (4th arg.) +template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, class CODE = E_F_F0F0F0F0F0s_< R, A, B, C, D, E, E_F0 > > // extend (4th arg.) class OneOperator5s_ : public OneOperator { aType r; // return type typedef typename CODE::func func; @@ -1243,15 +1184,12 @@ class OneOperator5s_ : public OneOperator { CompileError(" They are used Named parameter "); } - return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), t[4]->CastTo(args[4])); + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4])); } // extend OneOperator5s_(func ff) : // 3->4 - OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], - map_type[typeid(B).name( )], map_type[typeid(C).name( )], - map_type[typeid(D).name( )], + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )], map_type[typeid(E).name( )]), // extens f(ff) {} }; @@ -1259,19 +1197,18 @@ class OneOperator5s_ : public OneOperator { static void finit( ) { typedef const Mesh *pmesh; - Global.Add("isoline", "(", new ISOLINE_P1); - Global.Add("isoline", "(", new ISOLINE_P1(1)); - Global.Add("isoline", "(", new ISOLINE_P1); - Global.Add("isoline", "(", new ISOLINE_P1(1)); + Global.Add("isoline", "(", new ISOLINE_P1< MeshS >); + Global.Add("isoline", "(", new ISOLINE_P1< MeshS >(1)); + Global.Add("isoline", "(", new ISOLINE_P1< Mesh >); + Global.Add("isoline", "(", new ISOLINE_P1< Mesh >(1)); Global.Add("Curve", "(", new OneOperator2s_< R3 *, KNM_< double >, double >(Curve)); Global.Add("Curve", "(", new OneOperator4s_< R3 *, KNM_< double >, long, long, double >(Curve)); - Global.Add("Curve", "(", - new OneOperator5s_< R3 *, KNM_< double >, long, long, double, long * >(Curve)); + Global.Add("Curve", "(", new OneOperator5s_< R3 *, KNM_< double >, long, long, double, long * >(Curve)); Global.Add("Area", "(", new OneOperator2s_< double, KNM_< double >, KN_< long > >(mesure)); - Global.Add("findalllocalmin", "(", new FINDLOCALMIN_P1); - Global.Add("Dichotomy", "(", new OneOperator2_< long ,KN_< double > , double > (Dichotomy)); + Global.Add("findalllocalmin", "(", new FINDLOCALMIN_P1); + Global.Add("Dichotomy", "(", new OneOperator2_< long, KN_< double >, double >(Dichotomy)); } LOADFUNC(finit); // une variable globale qui serat construite au chargement dynamique diff --git a/plugin/seq/lapack.cpp b/plugin/seq/lapack.cpp index 7dd6896ef..d22283d07 100644 --- a/plugin/seq/lapack.cpp +++ b/plugin/seq/lapack.cpp @@ -230,8 +230,7 @@ long lapack_dgeev(KNM< double > *const &A, KN< Complex > *const &vp, KNM< Comple } // (computation of the eigenvalues and right eigenvectors of a complex nonsymmetric matrix) -long lapack_zgeev(KNM< Complex > *const &A, KN< Complex > *const &vp, - KNM< Complex > *const &vectp) { +long lapack_zgeev(KNM< Complex > *const &A, KN< Complex > *const &vp, KNM< Complex > *const &vectp) { intblas nvp = 0, zero = 0; intblas n = A->N( ); @@ -282,8 +281,7 @@ long lapack_zgeev(KNM< Complex > *const &A, KN< Complex > *const &vp, // Generalized eigenvalue problems // DGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE // matrices double real version -long lapack_dggev(KNM< double > *const &A, KNM< double > *const &B, KN< Complex > *const &vpa, - KN< double > *const &vpb, KNM< Complex > *const &vectp) { +long lapack_dggev(KNM< double > *const &A, KNM< double > *const &B, KN< Complex > *const &vpa, KN< double > *const &vpb, KNM< Complex > *const &vectp) { intblas nvp = 0, zero = 0; intblas n = A->N( ); @@ -354,8 +352,7 @@ long lapack_dggev(KNM< double > *const &A, KNM< double > *const &B, KN< Complex // Generalized eigenvalue problems // DGGEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE // matrices double complex version -long lapack_zggev(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< Complex > *const &vpa, - KN< Complex > *const &vpb, KNM< Complex > *const &vectp) { +long lapack_zggev(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< Complex > *const &vpa, KN< Complex > *const &vpb, KNM< Complex > *const &vectp) { // subroutine ZGGEV ( // 1 character JOBVL, // 2 character JOBVR, @@ -412,8 +409,7 @@ long lapack_zggev(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< Comple // A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. // Here A and B are assumed to be Hermitian and B is also // positive definite. -long lapack_zhegv(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< double > *const &vp, - KNM< Complex > *const &vectp) { +long lapack_zhegv(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< double > *const &vp, KNM< Complex > *const &vectp) { // subroutine ZHEGV ( // 1 integer ITYPE, // 2 character JOBZ, @@ -464,8 +460,7 @@ long lapack_zhegv(KNM< Complex > *const &A, KNM< Complex > *const &B, KN< double // GL, 05/10/2011 (computation of all the eigenvalues and the eigenvectors of a real generalized // symmetric-definite eigenproblem, of the form A*x=(lambda)*B*x) -long lapack_dsygvd(KNM< double > *const &A, KNM< double > *const &B, KN< double > *const &vp, - KNM< double > *const &vectp) { +long lapack_dsygvd(KNM< double > *const &A, KNM< double > *const &B, KN< double > *const &vp, KNM< double > *const &vectp) { /* * SUBROUTINE DSYGVD( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK, LWORK, IWORK, LIWORK, INFO ) * ITYPE (input) INTEGER @@ -606,8 +601,7 @@ long lapack_dsygvd(KNM< double > *const &A, KNM< double > *const &B, KN< double } // GL,27/09/2011 (singular value decomposition of a rectangular real matrix) -long lapack_dgesdd(KNM< double > *const &A, KNM< double > *const &U, KN< double > *const &S, - KNM< double > *const &V) { +long lapack_dgesdd(KNM< double > *const &A, KNM< double > *const &U, KN< double > *const &S, KNM< double > *const &V) { /* * SUBROUTINE DGESDD( JOBZ, M, N, A, LDA, S, U, LDU, VT, LDVT, WORK, LWORK, IWORK, INFO ) * JOBZ (input) CHARACTER*1 @@ -937,8 +931,7 @@ class Mult { template< class K > class OneBinaryOperatorRNM_inv : public OneOperator { public: - OneBinaryOperatorRNM_inv( ) - : OneOperator(atype< Inverse< KNM< K > * > >( ), atype< KNM< K > * >( ), atype< long >( )) {} + OneBinaryOperatorRNM_inv( ) : OneOperator(atype< Inverse< KNM< K > * > >( ), atype< KNM< K > * >( ), atype< long >( )) {} E_F0 *code(const basicAC_F0 &args) const { Expression p = args[1]; @@ -956,8 +949,7 @@ class OneBinaryOperatorRNM_inv : public OneOperator { CompileError(buf); } - return new E_F_F0< Inverse< KNM< K > * >, KNM< K > * >( - Build< Inverse< KNM< K > * >, KNM< K > * >, t[0]->CastTo(args[0])); + return new E_F_F0< Inverse< KNM< K > * >, KNM< K > * >(Build< Inverse< KNM< K > * >, KNM< K > * >, t[0]->CastTo(args[0])); } }; @@ -1023,23 +1015,19 @@ KNM< R > *Solve(KNM< R > *a, Inverse< KNM< R > * > b) { dgesv_(&n, &n, B, &n, p, *a, &n, &info); if (info) { cerr << " error: dgesv_ (not invertible ??) " << info << endl; - ErrorExec("dgesv_",1); - std::abort(); + ErrorExec("dgesv_", 1); + std::abort( ); } return a; } // Template interface -inline int gemm(char transa, char transb, integer *m, integer *n, integer *k, double *alpha, - double *a, integer *lda, double *b, integer *ldb, double *beta, double *c, - integer *ldc) { +inline int gemm(char transa, char transb, integer *m, integer *n, integer *k, double *alpha, double *a, integer *lda, double *b, integer *ldb, double *beta, double *c, integer *ldc) { return dgemm_(&transa, &transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc); } -inline int gemm(char transa, char transb, integer *m, integer *n, integer *k, Complex *alpha, - Complex *a, integer *lda, Complex *b, integer *ldb, Complex *beta, Complex *c, - integer *ldc) { +inline int gemm(char transa, char transb, integer *m, integer *n, integer *k, Complex *alpha, Complex *a, integer *lda, Complex *b, integer *ldb, Complex *beta, Complex *c, integer *ldc) { return zgemm_(&transa, &transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc); } template< class R, bool init = false > @@ -1111,8 +1099,7 @@ KNM< R > *mult_ab(KNM< R > *a, const KNM_< R > &A, const KNM_< R > &B, R alpha = } template< class R > -long ff_SchurComplement(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > const &I, - KNM< R > *const &pV) { +long ff_SchurComplement(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > const &I, KNM< R > *const &pV) { // I given numbering of Schur complement I[i] is the index in A of the i in S R zero(0.); KNM< R > &S = *pS; @@ -1139,20 +1126,14 @@ long ff_SchurComplement(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > co } } - if (nn != imx + 1) - cerr << " Error SchurComplement the positive full numbering is not surjective " << nn - << " <> " << imx + 1 << endl; + if (nn != imx + 1) cerr << " Error SchurComplement the positive full numbering is not surjective " << nn << " <> " << imx + 1 << endl; ffassert(nn == imx + 1); ni = nn; - if (verbosity) - cout << " SchurComplement with full non negative full shur complement numbering " << endl - << " size of compl. " << ni << " < size of mat. " << n << endl; + if (verbosity) cout << " SchurComplement with full non negative full shur complement numbering " << endl << " size of compl. " << ni << " < size of mat. " << n << endl; } else { ni = Ni; - if (verbosity) - cout << " SchurComplement with just the shur complement numbering (injection)" << endl - << " size of compl. " << ni << " < size of mat. " << n << endl; + if (verbosity) cout << " SchurComplement with just the shur complement numbering (injection)" << endl << " size of compl. " << ni << " < size of mat. " << n << endl; for (int i = 0; i < Ni; ++i) { int Ii = I[i]; ffassert(Ii >= 0 && Ii < n); @@ -1163,8 +1144,7 @@ long ff_SchurComplement(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > co // build numbering of no in shur complement .. -2 - number if (err) { if (Ni != n) - cerr << " SchurComplement get all numbering i -> j if i in [0,n[ if I[i]>=0 j=I[i] " << Ni - << " == " << n << endl; + cerr << " SchurComplement get all numbering i -> j if i in [0,n[ if I[i]>=0 j=I[i] " << Ni << " == " << n << endl; else cerr << " SchurComplement get all numbering i -> j if i in [0,ni[ , j = I[i] " << endl; cerr << " Fatal Error in SchurComplement def numbering : nb err= " << err << endl; @@ -1242,8 +1222,7 @@ long ff_SchurComplement(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > co return ff_SchurComplement< R >(pS, pA, I, pV); } template< class R > -KNM< R > *Add4(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > const &I, - KN_< long > const &J) { +KNM< R > *Add4(KNM< R > *const &pS, KNM< R > *const &pA, KN_< long > const &I, KN_< long > const &J) { ffassert(pS); // To do .. int n = I.N( ), m = J.N( ); if (pA) { @@ -1272,24 +1251,33 @@ KNM< R > *mult(KNM< R > *a, Mult< KNM< R > * > bc) { if (init) { a->init( ); } - const KNM_ A = *bc.a, B = *bc.b; + const KNM_< R > A = *bc.a, B = *bc.b; intblas N = A.N( ); intblas M = B.M( ); intblas K = A.M( ); intblas P = B.N( ); - if (bc.ta == 0 && bc.tb == 0) ffassert(K == P); - else if(bc.ta == 0 && bc.tb == 1) ffassert(K == M); - else if(bc.ta == 1 && bc.tb == 1) ffassert(N == M); - else if(bc.ta == 1 && bc.tb == 0) ffassert(N == P); - else ffassert(0); + if (bc.ta == 0 && bc.tb == 0) + ffassert(K == P); + else if (bc.ta == 0 && bc.tb == 1) + ffassert(K == M); + else if (bc.ta == 1 && bc.tb == 1) + ffassert(N == M); + else if (bc.ta == 1 && bc.tb == 0) + ffassert(N == P); + else + ffassert(0); KNM< R > &C = *a; R alpha = 1., beta = R(ibeta); if (!init) { - if(bc.ta == 0) ffassert(C.N() == N); - else ffassert(C.N() == K); - if(bc.tb == 0) ffassert(C.M() == M); - else ffassert(C.M() == P); + if (bc.ta == 0) + ffassert(C.N( ) == N); + else + ffassert(C.N( ) == K); + if (bc.tb == 0) + ffassert(C.M( ) == M); + else + ffassert(C.M( ) == P); } C.resize(bc.ta == 0 ? N : K, bc.tb == 0 ? M : P); R *A00 = &A(0, 0), *A10 = &A(1, 0), *A01 = &A(0, 1); @@ -1302,12 +1290,12 @@ KNM< R > *mult(KNM< R > *a, Mult< KNM< R > * > bc) { cout << lsa << " " << lsb << " " << lsc << " init " << init << endl; cout << lda << " " << ldb << " " << ldc << endl; } - ffassert( C00 != A00); - ffassert( C00 != B00); + ffassert(C00 != A00); + ffassert(C00 != B00); - M = C.N(); - N = C.M(); - K = bc.ta == 0 ? A.M() : A.N(); + M = C.N( ); + N = C.M( ); + K = bc.ta == 0 ? A.M( ) : A.N( ); gemm(bc.ta == 0 ? 'N' : 'T', bc.tb == 0 ? 'N' : 'T', &M, &N, &K, &alpha, A00, &lda, B00, &ldb, &beta, C00, &ldc); return a; } @@ -1396,129 +1384,58 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme Dcl_Type< Mult< KNM< double > * > >( ); TheOperators->Add("^", new OneBinaryOperatorRNM_inv< double >( )); - TheOperators->Add( - "*", new OneOperator2< Mult< KNM< double > * >, KNM< double > *, KNM< double > * >(Build2)); - TheOperators->Add( - "*", new OneOperator2< Mult< KNM< double > * >, Transpose *>, KNM< double > * >(Build2)); - TheOperators->Add( - "*", new OneOperator2< Mult< KNM< double > * >, KNM< double > *, Transpose *> >(Build2)); - TheOperators->Add( - "*", new OneOperator2< Mult< KNM< double > * >, Transpose *>, Transpose *> >(Build2)); - TheOperators->Add( - "*", - new OneOperator2< Mult< KNM< Complex > * >, KNM< Complex > *, KNM< Complex > * >(Build2)); + TheOperators->Add("*", new OneOperator2< Mult< KNM< double > * >, KNM< double > *, KNM< double > * >(Build2)); + TheOperators->Add("*", new OneOperator2< Mult< KNM< double > * >, Transpose< KNM< double > * >, KNM< double > * >(Build2)); + TheOperators->Add("*", new OneOperator2< Mult< KNM< double > * >, KNM< double > *, Transpose< KNM< double > * > >(Build2)); + TheOperators->Add("*", new OneOperator2< Mult< KNM< double > * >, Transpose< KNM< double > * >, Transpose< KNM< double > * > >(Build2)); + TheOperators->Add("*", new OneOperator2< Mult< KNM< Complex > * >, KNM< Complex > *, KNM< Complex > * >(Build2)); TheOperators->Add("^", new OneBinaryOperatorRNM_inv< Complex >( )); - TheOperators->Add( - "=", - new OneOperator2< KNM< double > *, KNM< double > *, Inverse< KNM< double > * > >(Solve< 0 >)); - TheOperators->Add( - "=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Inverse< KNM< Complex > * > >( - SolveC< 0 >)); - TheOperators->Add( - "<-", - new OneOperator2< KNM< double > *, KNM< double > *, Inverse< KNM< double > * > >(Solve< 1 >)); - TheOperators->Add( - "<-", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Inverse< KNM< Complex > * > >( - SolveC< 1 >)); - - TheOperators->Add("=", - new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >( - mult< double, false, 0 >)); - TheOperators->Add( - "=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >( - mult< Complex, false, 0 >)); - - TheOperators->Add("+=", - new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >( - mult< double, false, 1 >)); - TheOperators->Add( - "+=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >( - mult< Complex, false, 1 >)); - - TheOperators->Add("-=", - new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >( - mult< double, false, -1 >)); - TheOperators->Add( - "-=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >( - mult< Complex, false, -1 >)); - - TheOperators->Add("<-", - new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >( - mult< double, true, 0 >)); - TheOperators->Add( - "<-", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >( - mult< Complex, true, 0 >)); + TheOperators->Add("=", new OneOperator2< KNM< double > *, KNM< double > *, Inverse< KNM< double > * > >(Solve< 0 >)); + TheOperators->Add("=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Inverse< KNM< Complex > * > >(SolveC< 0 >)); + TheOperators->Add("<-", new OneOperator2< KNM< double > *, KNM< double > *, Inverse< KNM< double > * > >(Solve< 1 >)); + TheOperators->Add("<-", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Inverse< KNM< Complex > * > >(SolveC< 1 >)); + + TheOperators->Add("=", new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >(mult< double, false, 0 >)); + TheOperators->Add("=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >(mult< Complex, false, 0 >)); + + TheOperators->Add("+=", new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >(mult< double, false, 1 >)); + TheOperators->Add("+=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >(mult< Complex, false, 1 >)); + + TheOperators->Add("-=", new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >(mult< double, false, -1 >)); + TheOperators->Add("-=", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >(mult< Complex, false, -1 >)); + + TheOperators->Add("<-", new OneOperator2< KNM< double > *, KNM< double > *, Mult< KNM< double > * > >(mult< double, true, 0 >)); + TheOperators->Add("<-", new OneOperator2< KNM< Complex > *, KNM< Complex > *, Mult< KNM< Complex > * > >(mult< Complex, true, 0 >)); Global.Add("inv", "(", new OneOperator1< long, KNM< double > * >(lapack_inv)); Global.Add("inv", "(", new OneOperator1< long, KNM< Complex > * >(lapack_inv)); - Global.Add( - "dgeev", "(", - new OneOperator3_< long, KNM< double > *, KN< Complex > *, KNM< Complex > * >(lapack_dgeev)); - Global.Add( - "zgeev", "(", - new OneOperator3_< long, KNM< Complex > *, KN< Complex > *, KNM< Complex > * >(lapack_zgeev)); + Global.Add("dgeev", "(", new OneOperator3_< long, KNM< double > *, KN< Complex > *, KNM< Complex > * >(lapack_dgeev)); + Global.Add("zgeev", "(", new OneOperator3_< long, KNM< Complex > *, KN< Complex > *, KNM< Complex > * >(lapack_zgeev)); // add FH - Global.Add( - "geev", "(", - new OneOperator3_< long, KNM< double > *, KN< Complex > *, KNM< Complex > * >(lapack_dgeev)); - Global.Add( - "geev", "(", - new OneOperator3_< long, KNM< Complex > *, KN< Complex > *, KNM< Complex > * >(lapack_zgeev)); - - Global.Add("dggev", "(", - new OneOperator5_< long, KNM< double > *, KNM< double > *, KN< Complex > *, - KN< double > *, KNM< Complex > * >(lapack_dggev)); - Global.Add("zggev", "(", - new OneOperator5_< long, KNM< Complex > *, KNM< Complex > *, KN< Complex > *, - KN< Complex > *, KNM< Complex > * >(lapack_zggev)); - Global.Add( - "dsygvd", "(", - new OneOperator4_< long, KNM< double > *, KNM< double > *, KN< double > *, KNM< double > * >( - lapack_dsygvd)); - Global.Add( - "dgesdd", "(", - new OneOperator4_< long, KNM< double > *, KNM< double > *, KN< double > *, KNM< double > * >( - lapack_dgesdd)); - Global.Add("zhegv", "(", - new OneOperator4_< long, KNM< Complex > *, KNM< Complex > *, KN< double > *, - KNM< Complex > * >(lapack_zhegv)); - Global.Add( - "dsyev", "(", - new OneOperator3_< long, KNM< double > *, KN< double > *, KNM< double > * >(lapack_dsyev)); - Global.Add( - "zheev", "(", - new OneOperator3_< long, KNM< Complex > *, KN< double > *, KNM< Complex > * >(lapack_zheev)); - Global.Add("dgelsy", "(", - new OneOperator2_< long, KNM< double > *, KN< double > * >(lapack_dgelsy)); - Global.Add("dgelsy", "(", - new OneOperator2_< long, KNM< double > *, KNM< double > * >(lapack_dgelsy)); + Global.Add("geev", "(", new OneOperator3_< long, KNM< double > *, KN< Complex > *, KNM< Complex > * >(lapack_dgeev)); + Global.Add("geev", "(", new OneOperator3_< long, KNM< Complex > *, KN< Complex > *, KNM< Complex > * >(lapack_zgeev)); + + Global.Add("dggev", "(", new OneOperator5_< long, KNM< double > *, KNM< double > *, KN< Complex > *, KN< double > *, KNM< Complex > * >(lapack_dggev)); + Global.Add("zggev", "(", new OneOperator5_< long, KNM< Complex > *, KNM< Complex > *, KN< Complex > *, KN< Complex > *, KNM< Complex > * >(lapack_zggev)); + Global.Add("dsygvd", "(", new OneOperator4_< long, KNM< double > *, KNM< double > *, KN< double > *, KNM< double > * >(lapack_dsygvd)); + Global.Add("dgesdd", "(", new OneOperator4_< long, KNM< double > *, KNM< double > *, KN< double > *, KNM< double > * >(lapack_dgesdd)); + Global.Add("zhegv", "(", new OneOperator4_< long, KNM< Complex > *, KNM< Complex > *, KN< double > *, KNM< Complex > * >(lapack_zhegv)); + Global.Add("dsyev", "(", new OneOperator3_< long, KNM< double > *, KN< double > *, KNM< double > * >(lapack_dsyev)); + Global.Add("zheev", "(", new OneOperator3_< long, KNM< Complex > *, KN< double > *, KNM< Complex > * >(lapack_zheev)); + Global.Add("dgelsy", "(", new OneOperator2_< long, KNM< double > *, KN< double > * >(lapack_dgelsy)); + Global.Add("dgelsy", "(", new OneOperator2_< long, KNM< double > *, KNM< double > * >(lapack_dgelsy)); // Add FH. for P. Ventura... Jun 2019 .. typedef Complex C; - Global.Add( - "SchurComplement", "(", - new OneOperator3_< long, KNM< R > *, KNM< R > *, KN_< long > >(ff_SchurComplement< R >)); - Global.Add("SchurComplement", "(", - new OneOperator3_< long, KNM< Complex > *, KNM< Complex > *, KN_< long > >( - ff_SchurComplement< Complex >)); - Global.Add("SchurComplement", "(", - new OneOperator4_< long, KNM< R > *, KNM< R > *, KN_< long >, KNM< R > * >( - ff_SchurComplement< R >)); - Global.Add( - "SchurComplement", "(", - new OneOperator4_< long, KNM< Complex > *, KNM< Complex > *, KN_< long >, KNM< Complex > * >( - ff_SchurComplement< Complex >)); - Global.Add("Add", "(", - new OneOperator3_< KNM< C > *, KNM< C > *, KNM< C > *, KN_< long > >(Add3< C >)); - Global.Add( - "Add", "(", - new OneOperator4_< KNM< C > *, KNM< C > *, KNM< C > *, KN_< long >, KN_< long > >(Add4< C >)); - Global.Add("Add", "(", - new OneOperator3_< KNM< R > *, KNM< R > *, KNM< R > *, KN_< long > >(Add3< R >)); - Global.Add( - "Add", "(", - new OneOperator4_< KNM< R > *, KNM< R > *, KNM< R > *, KN_< long >, KN_< long > >(Add4< R >)); + Global.Add("SchurComplement", "(", new OneOperator3_< long, KNM< R > *, KNM< R > *, KN_< long > >(ff_SchurComplement< R >)); + Global.Add("SchurComplement", "(", new OneOperator3_< long, KNM< Complex > *, KNM< Complex > *, KN_< long > >(ff_SchurComplement< Complex >)); + Global.Add("SchurComplement", "(", new OneOperator4_< long, KNM< R > *, KNM< R > *, KN_< long >, KNM< R > * >(ff_SchurComplement< R >)); + Global.Add("SchurComplement", "(", new OneOperator4_< long, KNM< Complex > *, KNM< Complex > *, KN_< long >, KNM< Complex > * >(ff_SchurComplement< Complex >)); + Global.Add("Add", "(", new OneOperator3_< KNM< C > *, KNM< C > *, KNM< C > *, KN_< long > >(Add3< C >)); + Global.Add("Add", "(", new OneOperator4_< KNM< C > *, KNM< C > *, KNM< C > *, KN_< long >, KN_< long > >(Add4< C >)); + Global.Add("Add", "(", new OneOperator3_< KNM< R > *, KNM< R > *, KNM< R > *, KN_< long > >(Add3< R >)); + Global.Add("Add", "(", new OneOperator4_< KNM< R > *, KNM< R > *, KNM< R > *, KN_< long >, KN_< long > >(Add4< R >)); } else if (verbosity) { cout << "( load: lapack <=> fflapack , skeep ) "; diff --git a/plugin/seq/lgbmo.cpp b/plugin/seq/lgbmo.cpp index 25ffc5664..c0da972ef 100644 --- a/plugin/seq/lgbmo.cpp +++ b/plugin/seq/lgbmo.cpp @@ -55,15 +55,11 @@ class OptimBMO : public OneOperator { Expression X; C_F0 inittheparam, theparam, closetheparam; Expression JJ, dJJ; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } void Set_arg(int i, Stack stack, Kn_ v) const { if (nargs[i]) { @@ -84,12 +80,10 @@ class OptimBMO : public OneOperator { } public: - lgBMO(Stack s, int n, Expression t, Expression J, Expression dJ, int wnbrestart = 1, - int wnbext1 = 1, int wnbbvp = 5, int wnbgrad = 5, double wepsfd = 1e-5, - double wrho000 = 100, double wepsloc = 1e-4, double wepsij = 1e-6, int nn100 = 100) + lgBMO(Stack s, int n, Expression t, Expression J, Expression dJ, int wnbrestart = 1, int wnbext1 = 1, int wnbbvp = 5, int wnbgrad = 5, double wepsfd = 1e-5, double wrho000 = 100, + double wepsloc = 1e-4, double wepsij = 1e-6, int nn100 = 100) - : BijanMO(n, wnbrestart, wnbext1, wnbbvp, wnbgrad, wepsfd, wrho000, wepsloc, wepsij, nn100), - stack(s), JJ(J), dJJ(dJ), theparame(t) {} + : BijanMO(n, wnbrestart, wnbext1, wnbbvp, wnbgrad, wepsfd, wrho000, wepsloc, wepsij, nn100), stack(s), JJ(J), dJJ(dJ), theparame(t) {} ~lgBMO( ) {} @@ -130,8 +124,7 @@ class OptimBMO : public OneOperator { X = to< Kn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -150,8 +143,7 @@ class OptimBMO : public OneOperator { JJ = to< R >(C_F0(opJ, "(", theparam)); if (opdJ) { - dJJ = to< Kn_ >( - C_F0(opdJ, "(", theparam)); // Modif FH 17102005 (a verifier) to ->to + dJJ = to< Kn_ >(C_F0(opdJ, "(", theparam)); // Modif FH 17102005 (a verifier) to ->to } closetheparam = C_F0((Expression)Block::snewclose(currentblock), atype< void >( )); @@ -204,8 +196,7 @@ class OptimBMO : public OneOperator { KN_< R > param(x); // cout << nbrestart << " ---- \n"; - lgBMO nrj1(stack, n, theparam, JJ, dJJ, nbrestart, nbext1, nbbvp, nbgrad, epsfd, rho000, - epsloc, epsij, n100); + lgBMO nrj1(stack, n, theparam, JJ, dJJ, nbrestart, nbext1, nbbvp, nbgrad, epsfd, rho000, epsloc, epsij, n100); nrj1.diagrand = diagrand; nrj1.debug = verbosity; nrj1.typealgo = typealgo; @@ -242,29 +233,24 @@ class OptimBMO : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_BMO(args, cas); } - OptimBMO(int c) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + OptimBMO(int c) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} - OptimBMO(int c, int cc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< KN< R > * >( )), - cas(c) {} + OptimBMO(int c, int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; basicAC_F0::name_and_type OptimBMO::E_BMO::name_param[] = { - {"eps", &typeid(double)}, {"nbrestart", &typeid(long)}, {"nbbvp", &typeid(long)}, - {"nbgrad", &typeid(long)}, {"epsfd", &typeid(double)}, {"rho000", &typeid(double)}, - {"epsloc", &typeid(double)}, {"epsij", &typeid(double)}, {"n100", &typeid(long)}, // 8 - {"max", &typeid(double)}, // 9 - {"min", &typeid(double)}, // 10 - {"vmax", &typeid(double)}, // 11 - {"vmin", &typeid(double)}, // 12 - {"histfile", &typeid(string *)}, // 13 - {"histcfile", &typeid(string *)}, // 14 - {"algo", &typeid(long)} // 15 + {"eps", &typeid(double)}, {"nbrestart", &typeid(long)}, {"nbbvp", &typeid(long)}, {"nbgrad", &typeid(long)}, {"epsfd", &typeid(double)}, + {"rho000", &typeid(double)}, {"epsloc", &typeid(double)}, {"epsij", &typeid(double)}, {"n100", &typeid(long)}, // 8 + {"max", &typeid(double)}, // 9 + {"min", &typeid(double)}, // 10 + {"vmax", &typeid(double)}, // 11 + {"vmin", &typeid(double)}, // 12 + {"histfile", &typeid(string *)}, // 13 + {"histcfile", &typeid(string *)}, // 14 + {"algo", &typeid(long)} // 15 }; -static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ +static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ Global.Add("bmo", "(", new OptimBMO(1)); // j + dJ Global.Add("bmo", "(", new OptimBMO(1, 1)); // j + dJ } diff --git a/plugin/seq/libff-mmap-semaphore.c b/plugin/seq/libff-mmap-semaphore.c index 74bdc8f32..e7358c183 100644 --- a/plugin/seq/libff-mmap-semaphore.c +++ b/plugin/seq/libff-mmap-semaphore.c @@ -209,19 +209,19 @@ void ffmmap_destroy(ff_Pmmap p) { } if (p->map) { -#if defined( _WIN32 ) - if (UnmapViewOfFile(p->map) == 0) { +#if defined(_WIN32) + if (UnmapViewOfFile(p->map) == 0) { #else - if (munmap(p->map, p->len) == -1) { + if (munmap(p->map, p->len) == -1) { #endif - printf(" **Error munmap %s %zu\n", p->nm, p->len); - perror("munmap"); - ffDoError("munmap", 1005); - } + printf(" **Error munmap %s %zu\n", p->nm, p->len); + perror("munmap"); + ffDoError("munmap", 1005); + } } if (p->fd > 0) { -#if defined ( _WIN32 ) +#if defined(_WIN32) CloseHandle(p->fd); #else close(p->fd); @@ -258,16 +258,14 @@ long ffmmap_msync(ff_Pmmap p, long off, long ln) { ln = p->len - off; } -#if defined ( _WIN32 ) +#if defined(_WIN32) return FlushViewOfFile((char *)p->map + off, ln); #else return msync((char *)p->map + off, ln, MS_SYNC); #endif } -void ffmmap_msync_(long *p, int *off, int *ln, long *ret) { - *ret = ffmmap_msync(*(ff_Pmmap *)p, *off, *ln); -} +void ffmmap_msync_(long *p, int *off, int *ln, long *ret) { *ret = ffmmap_msync(*(ff_Pmmap *)p, *off, *ln); } void ffmmap_init(ff_Pmmap p, const char *nm, long len) { void *addr = 0; @@ -275,14 +273,8 @@ void ffmmap_init(ff_Pmmap p, const char *nm, long len) { p->len = len; p->nm = newstringcpy(nm); // shm_unlink p->map = 0; -#if defined ( _WIN32 ) - p->fd = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, - PAGE_READWRITE, - 0, - len, - nm ); +#if defined(_WIN32) + p->fd = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, len, nm); if (p->fd == NULL) { #else p->fd = open(p->nm, O_RDWR | O_CREAT, (mode_t)0666); @@ -294,13 +286,8 @@ void ffmmap_init(ff_Pmmap p, const char *nm, long len) { ffDoError("opening mmap", 2001); } -#if defined ( _WIN32 ) - p->map = MapViewOfFile( - p->fd, - FILE_MAP_ALL_ACCESS, - 0, - 0, - p->len ); +#if defined(_WIN32) + p->map = MapViewOfFile(p->fd, FILE_MAP_ALL_ACCESS, 0, 0, p->len); if (p->map == NULL) { #else off_t size = lseek(p->fd, 0, SEEK_END); // seek to end of file @@ -335,8 +322,7 @@ void ffmmap_init_(long *pp, const char *nm, int *len, int lennm) { long ffmmap_read(ff_Pmmap p, void *pt, size_t ln, long off) { if (off < 0 || off + ln > p->len) { - printf("Fatal Error: ffmmap_read ff mmap out of bound len = %zu < %lu + %ld \n", p->len, - (unsigned long)ln, off); + printf("Fatal Error: ffmmap_read ff mmap out of bound len = %zu < %lu + %ld \n", p->len, (unsigned long)ln, off); ffDoError(" Error out of bound ", 2004); } @@ -357,8 +343,7 @@ void ffmmap_read_(long *p, void *pt, int *ln, int *off, long *ret) { long ffmmap_write(ff_Pmmap p, void *pt, size_t ln, long off) { if (off < 0 || off + ln > p->len) { - printf("Fatal Error: ffmmap_write ff mmap out of bound len = %zu < %lu + %ld \n", p->len, - (unsigned long)ln, off); + printf("Fatal Error: ffmmap_write ff mmap out of bound len = %zu < %lu + %ld \n", p->len, (unsigned long)ln, off); ffDoError(" Error out of bound ", 2005); } diff --git a/plugin/seq/libff-mmap-semaphore.h b/plugin/seq/libff-mmap-semaphore.h index f979f3f18..73430c597 100644 --- a/plugin/seq/libff-mmap-semaphore.h +++ b/plugin/seq/libff-mmap-semaphore.h @@ -26,8 +26,8 @@ #include #include #include -#if defined ( _WIN32 ) -# include +#if defined(_WIN32) +#include #else #include #include @@ -48,7 +48,7 @@ struct FF_P_sem { struct FF_P_mmap { size_t len; const char *nm; -#if defined( _WIN32 ) +#if defined(_WIN32) HANDLE fd; #else int fd; diff --git a/plugin/seq/marmousi2.cpp b/plugin/seq/marmousi2.cpp index 060f95c91..68b4df80e 100644 --- a/plugin/seq/marmousi2.cpp +++ b/plugin/seq/marmousi2.cpp @@ -57,8 +57,7 @@ Marmousi22d *init_Marmousi22d(Marmousi22d *const &a, string *const &s) { int ix, iy, iz; for (iy = 0; iy < a->mo_file_ny; iy++) - for (ix = 0; ix < a->mo_file_nx; ix++) - (*a->tab)(ix, a->mo_file_ny - 1 - iy) = buff[a->mo_file_ny * ix + iy]; + for (ix = 0; ix < a->mo_file_nx; ix++) (*a->tab)(ix, a->mo_file_ny - 1 - iy) = buff[a->mo_file_ny * ix + iy]; delete[] buff; @@ -79,9 +78,7 @@ static void Load_Init( ) { Dcl_Type< Marmousi22d * >(InitP< Marmousi22d >, Destroy< Marmousi22d >); zzzfff->Add("Marmousi2", atype< Marmousi22d * >( )); - TheOperators->Add("<-", - new OneOperator2_< Marmousi22d *, Marmousi22d *, string * >(&init_Marmousi22d)); - atype< Marmousi22d * >( )->Add( - "(", "", new OneOperator3_< double, Marmousi22d *, double, double >(Marmousi22d_eval)); + TheOperators->Add("<-", new OneOperator2_< Marmousi22d *, Marmousi22d *, string * >(&init_Marmousi22d)); + atype< Marmousi22d * >( )->Add("(", "", new OneOperator3_< double, Marmousi22d *, double, double >(Marmousi22d_eval)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/mat_dervieux.cpp b/plugin/seq/mat_dervieux.cpp index d4e096bda..9d13298de 100644 --- a/plugin/seq/mat_dervieux.cpp +++ b/plugin/seq/mat_dervieux.cpp @@ -55,10 +55,7 @@ class MatrixUpWind0 : public E_F0mps { ~MatrixUpWind0( ) {} - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh >( ), atype< double >( ), - atype< E_Array >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh >( ), atype< double >( ), atype< E_Array >( )); } static E_F0 *f(const basicAC_F0 &args) { return new MatrixUpWind0(args); } @@ -75,9 +72,7 @@ int fvmP1P0(double q[3][2], double u[2], double c[3], double a[3][3], for (int i = 0; i < 3; i++) { int ip = (i + 1) % 3, ipp = (ip + 1) % 3; - double unL = - -((q[ip][1] + q[i][1] - 2 * q[ipp][1]) * u[0] - (q[ip][0] + q[i][0] - 2 * q[ipp][0]) * u[1]) / - 6; + double unL = -((q[ip][1] + q[i][1] - 2 * q[ipp][1]) * u[0] - (q[ip][0] + q[i][0] - 2 * q[ipp][0]) * u[1]) / 6; if (unL > 0) { a[i][i] += unL; a[ip][i] -= unL; @@ -107,7 +102,7 @@ AnyType MatrixUpWind0::operator( )(Stack stack) const { ffassert(pTh); const Mesh &Th(*pTh); { - MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv,-1,0,0), &Aij = *pAij; + MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv, -1, 0, 0), &Aij = *pAij; KN< double > cc(Th.nv); double infini = DBL_MAX; @@ -152,9 +147,8 @@ AnyType MatrixUpWind0::operator( )(Stack stack) const { sparce_mat->Uh = UniqueffId( ); sparce_mat->Vh = UniqueffId( ); sparce_mat->A.master(amorse); - sparce_mat->typemat = - 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : - // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) + sparce_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : + // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) *mp = mps; if (verbosity > 3) { diff --git a/plugin/seq/mat_edgeP1.cpp b/plugin/seq/mat_edgeP1.cpp index 2296bbb49..248a1ce57 100644 --- a/plugin/seq/mat_edgeP1.cpp +++ b/plugin/seq/mat_edgeP1.cpp @@ -42,9 +42,7 @@ class MatrixEdgeP1 : public E_F0 { MatrixEdgeP1( ) {} - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< const Mesh * >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< const Mesh * >( )); } static E_F0 *f(const basicAC_F0 &args) { return new MatrixEdgeP1(args); } @@ -77,7 +75,7 @@ AnyType MatrixEdgeP1< Mesh >::operator( )(Stack stack) const { const int d = RdHat::d; ffassert(d == 2 || d == 3 || d == 1); const int nbedgeE = d * (d + 1) / 2; - const int(*const nvedge)[2] = (d == 1) ? nvedgeSeg : (d == 2 ? nvedgeTria : nvedgeTet); + const int (*const nvedge)[2] = (d == 1) ? nvedgeSeg : (d == 2 ? nvedgeTria : nvedgeTet); Matrice_Creuse< R > *sparce_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); MatriceMorse< R > *amorse = 0; MeshPoint *mp(MeshPointStack(stack)), mps = *mp; @@ -96,8 +94,7 @@ AnyType MatrixEdgeP1< Mesh >::operator( )(Stack stack) const { SortArray< int, 2 > eki(Th(k, i0), Th(k, i1)); if (!e.find(eki)) e.add(eki, ne++); } - if (verbosity > 2 && mpirank == 0) - cout << " ne = " << ne << " " << nbedgeE << " " << Th.nv << endl; + if (verbosity > 2 && mpirank == 0) cout << " ne = " << ne << " " << nbedgeE << " " << Th.nv << endl; MatriceMorse< R > *pAij = new MatriceMorse< R >(ne, Th.nv, 0, 0), &Aij = *pAij; // ffassert(Th.ne==ne); for (int k = 0; k < ne; k++) { @@ -113,9 +110,8 @@ AnyType MatrixEdgeP1< Mesh >::operator( )(Stack stack) const { sparce_mat->Uh = UniqueffId( ); sparce_mat->Vh = UniqueffId( ); sparce_mat->A.master(amorse); - sparce_mat->typemat = - 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : - // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) + sparce_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : + // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) *mp = mps; if (verbosity > 3) { diff --git a/plugin/seq/mat_psi.cpp b/plugin/seq/mat_psi.cpp index 928a2083c..b7edbfd35 100644 --- a/plugin/seq/mat_psi.cpp +++ b/plugin/seq/mat_psi.cpp @@ -50,10 +50,7 @@ class MatrixUpWind0 : public E_F0 { ~MatrixUpWind0( ) {} - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh >( ), atype< double >( ), - atype< E_Array >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh >( ), atype< double >( ), atype< E_Array >( )); } static E_F0 *f(const basicAC_F0 &args) { return new MatrixUpWind0(args); } @@ -83,10 +80,7 @@ class MatrixUpWind3 : public E_F0 { ~MatrixUpWind3( ) {} - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh3 >( ), atype< double >( ), - atype< E_Array >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< pmesh3 >( ), atype< double >( ), atype< E_Array >( )); } static E_F0 *f(const basicAC_F0 &args) { return new MatrixUpWind3(args); } @@ -178,7 +172,7 @@ AnyType MatrixUpWind0::operator( )(Stack stack) const { ffassert(pTh); const Mesh &Th(*pTh); { - MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv,-1,0,0), &Aij = *pAij; + MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv, -1, 0, 0), &Aij = *pAij; KN< double > cc(Th.nv); double infini = DBL_MAX; @@ -223,9 +217,8 @@ AnyType MatrixUpWind0::operator( )(Stack stack) const { sparce_mat->Uh = UniqueffId( ); sparce_mat->Vh = UniqueffId( ); sparce_mat->A.master(amorse); - sparce_mat->typemat = - 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : - // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) + sparce_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : + // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) *mp = mps; if (verbosity > 3) { @@ -248,7 +241,7 @@ AnyType MatrixUpWind3::operator( )(Stack stack) const { ffassert(pTh); const Mesh3 &Th(*pTh); { - MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv,-1,0,0), &Aij = *pAij; + MatriceMorse< R > *pAij = new MatriceMorse< R >(Th.nv, -1, 0, 0), &Aij = *pAij; KN< double > cc(Th.nv); double infini = DBL_MAX; @@ -293,9 +286,8 @@ AnyType MatrixUpWind3::operator( )(Stack stack) const { sparce_mat->Uh = UniqueffId( ); sparce_mat->Vh = UniqueffId( ); sparce_mat->A.master(amorse); - sparce_mat->typemat = - 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : - // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) + sparce_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : + // TypeSolveMat(TypeSolveMat::NONESQUARE);// none square matrice (morse) *mp = mps; if (verbosity > 3) { diff --git a/plugin/seq/medit.cpp b/plugin/seq/medit.cpp index 7fb830e5d..b034c0977 100644 --- a/plugin/seq/medit.cpp +++ b/plugin/seq/medit.cpp @@ -63,9 +63,7 @@ class readsol_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: readsol_Op(const basicAC_F0 &args) { @@ -92,7 +90,7 @@ class readsol_Op : public E_F0mps { basicAC_F0::name_and_type readsol_Op::name_param[] = {{"number", &typeid(long)}}; AnyType readsol_Op::operator( )(Stack stack) const { string *ffname = GetAny< string * >((*filename)(stack)); - int k, i, isol, type, ver, dim, typtab[GmfMaxTyp], offset; + int k, i, isol, type, ver, dim, typtab[GmfMaxTyp], offset; int64_t inm; char *ptr, data[128]; // rajout freefem++ @@ -165,8 +163,7 @@ AnyType readsol_Op::operator( )(Stack stack) const { nbsol = nsol * dim * (dim + 1) / 2; offsettab = dim * (dim + 1) / 2; } else { - cerr << "bug in the definition of type of solution: 1 scalar, 2 vector, 3 symmetric tensor" - << endl; + cerr << "bug in the definition of type of solution: 1 scalar, 2 vector, 3 symmetric tensor" << endl; exit(1); } @@ -179,8 +176,7 @@ AnyType readsol_Op::operator( )(Stack stack) const { firstelem = firstelem + dim * (dim + 1) / 2; ; } else { - cerr << "bug in the definition of type of solution: 1 scalar, 2 vector, 3 symmetric tensor" - << endl; + cerr << "bug in the definition of type of solution: 1 scalar, 2 vector, 3 symmetric tensor" << endl; exit(1); } } @@ -287,9 +283,7 @@ class datasolMesh2_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: datasolMesh2_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -316,8 +310,7 @@ class datasolMesh2_Op : public E_F0mps { } else if (args[i].left( ) == atype< E_Array >( )) { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); + CompileError("savesol in 2D: vector solution is 2 composant, tensor solution is 3 composant"); } if (a0->size( ) == ddim) { @@ -344,9 +337,7 @@ class datasolMesh2_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new datasolMesh2_Op(args); } @@ -369,7 +360,7 @@ AnyType datasolMesh2_Op::operator( )(Stack stack) const { int TypTab[l.size( )]; int resultorder = arg(0, stack, 1L); long longdefault; - int ver = GmfFloat; + int ver = GmfFloat; int64_t outm; // determination de TypTab solnbfloat = 0; @@ -511,9 +502,7 @@ class datasolMeshT_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: datasolMeshT_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -564,9 +553,7 @@ class datasolMeshT_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new datasolMeshT_Op< MMesh, v_fes >(args); } @@ -574,11 +561,9 @@ class datasolMeshT_Op : public E_F0mps { }; template<> -basicAC_F0::name_and_type datasolMeshT_Op< MeshS, v_fesS >::name_param[] = { - {"order", &typeid(long)}}; +basicAC_F0::name_and_type datasolMeshT_Op< MeshS, v_fesS >::name_param[] = {{"order", &typeid(long)}}; template<> -basicAC_F0::name_and_type datasolMeshT_Op< MeshL, v_fesL >::name_param[] = { - {"order", &typeid(long)}}; +basicAC_F0::name_and_type datasolMeshT_Op< MeshL, v_fesL >::name_param[] = {{"order", &typeid(long)}}; template< class MMesh, class v_fes > AnyType datasolMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { @@ -601,7 +586,7 @@ AnyType datasolMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { int TypTab[l.size( )]; int resultorder = arg(0, stack, 1); long longdefault; - int ver = GmfFloat; + int ver = GmfFloat; int64_t outm; // determination de TypTab solnbfloat = 0; @@ -637,7 +622,7 @@ AnyType datasolMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { for (int it = 0; it < nt; it++) { int h = 0; const T &K(Th.elements[it]); - mp3->set(Th, K(Cdg_hat), Cdg_hat, K, K.lab ); + mp3->set(Th, K(Cdg_hat), Cdg_hat, K, K.lab); for (size_t i = 0; i < l.size( ); i++) for (size_t j = 0; j < l[i].nbfloat; j++) { @@ -744,9 +729,7 @@ class datasolMesh3_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: datasolMesh3_Op(const basicAC_F0 &args) : l(args.size( ) - 2) { @@ -769,8 +752,7 @@ class datasolMesh3_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0->size( ) != ddim && a0->size( ) != stsize) { if (a0 == nullptr) cout << "dynamic cast failed" << endl; - CompileError( - "savesol in 3D: vector solution is 3 composant, vector solution is 6 composant"); + CompileError("savesol in 3D: vector solution is 3 composant, vector solution is 6 composant"); } if (a0->size( ) == ddim) { @@ -796,9 +778,7 @@ class datasolMesh3_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new datasolMesh3_Op(args); } @@ -823,7 +803,7 @@ AnyType datasolMesh3_Op< v_fes >::operator( )(Stack stack) const { int TypTab[l.size( )]; int resultorder = arg(0, stack, 1); long longdefault; - int ver = GmfFloat; + int ver = GmfFloat; int64_t outm; // determination de TypTab solnbfloat = 0; @@ -936,8 +916,7 @@ AnyType datasolMesh3_Op< v_fes >::operator( )(Stack stack) const { // // ************************* -static char *meditcmd(long filebin, int nbsol, int smedit, const string &meditff, - const string &ffnn) { +static char *meditcmd(long filebin, int nbsol, int smedit, const string &meditff, const string &ffnn) { string meditcmm = meditff; int ddebug = 0; @@ -982,9 +961,7 @@ static char *meditcmd(long filebin, int nbsol, int smedit, const string &meditff } if (nbstrings != smedit) { - cout - << "The number of string defined in string parameter is different of the number of solution" - << endl; + cout << "The number of string defined in string parameter is different of the number of solution" << endl; if (nbstrings < smedit) { // Add strings while (nbstrings < smedit) { @@ -1008,16 +985,14 @@ void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, K } } -void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, - const KN< double > &v2, KNM< double > &vv) { +void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, const KN< double > &v2, KNM< double > &vv) { for (int i = 0; i < tsize; i++) { vv(nbofsol, i) = v1(i); vv(nbofsol + 1, i) = v2(i); } } -void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, - const KN< double > &v2, const KN< double > &v3, KNM< double > &vv) { +void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, const KN< double > &v2, const KN< double > &v3, KNM< double > &vv) { for (int i = 0; i < tsize; i++) { vv(nbofsol, i) = v1(i); vv(nbofsol + 1, i) = v2(i); @@ -1025,9 +1000,8 @@ void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, } } -void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, - const KN< double > &v2, const KN< double > &v3, const KN< double > &v4, - const KN< double > &v5, const KN< double > &v6, KNM< double > &vv) { +void writetabsol(const int &tsize, const int &nbofsol, const KN< double > &v1, const KN< double > &v2, const KN< double > &v3, const KN< double > &v4, const KN< double > &v5, const KN< double > &v6, + KNM< double > &vv) { for (int i = 0; i < tsize; i++) { vv(nbofsol, i) = v1(i); vv(nbofsol + 1, i) = v2(i); @@ -1076,13 +1050,9 @@ class PopenMeditMesh_Op : public E_F0mps { static const int n_name_param = 5; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: PopenMeditMesh_Op(const basicAC_F0 &args) : l(args.size( ) - 1) { @@ -1108,8 +1078,7 @@ class PopenMeditMesh_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0 == nullptr) cout << "dynamic cast error" << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "medit in 2D: vector solution is 2 composant, tensor solution is 3 composant"); + CompileError("medit in 2D: vector solution is 2 composant, tensor solution is 3 composant"); } if (a0->size( ) == ddim) { @@ -1174,9 +1143,7 @@ class PopenMeditMesh_Op : public E_F0mps { for (size_t jj = offset; jj < l.size( ); jj++) { if (l[jj].what != l[jj % offset].what) { char StringError[256]; - snprintf(StringError, 256, - "compile error :: The solution %ld of mesh 1 and mesh %ld is not the same type", - jj % offset, jj / offset + 1); + snprintf(StringError, 256, "compile error :: The solution %ld of mesh 1 and mesh %ld is not the same type", jj % offset, jj / offset + 1); CompileError(StringError); } } @@ -1185,20 +1152,14 @@ class PopenMeditMesh_Op : public E_F0mps { // verification que la nature des solutions sont identiques pour les differents maillages. } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new PopenMeditMesh_Op(args); } AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type PopenMeditMesh_Op::name_param[] = {{"order", &typeid(long)}, - {"meditff", &typeid(string *)}, - {"save", &typeid(string *)}, - {"wait", &typeid(bool)}, - {"bin", &typeid(long)}}; +basicAC_F0::name_and_type PopenMeditMesh_Op::name_param[] = {{"order", &typeid(long)}, {"meditff", &typeid(string *)}, {"save", &typeid(string *)}, {"wait", &typeid(bool)}, {"bin", &typeid(long)}}; AnyType PopenMeditMesh_Op::operator( )(Stack stack) const { if (NoGraphicWindow) { return Nothing; @@ -1541,8 +1502,7 @@ AnyType PopenMeditMesh_Op::operator( )(Stack stack) const { int i = Th(it, iv); mp3->setP(&Th, it, iv); - vxx[i] = - vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); + vxx[i] = vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); takemesh[i] = takemesh[i] + 1; } } @@ -1730,11 +1690,13 @@ AnyType PopenMeditMesh_Op::operator( )(Stack stack) const { // il faut faire thread qui lance ca de maniere asyncrone ... // a faire .. FH ... // if (wait && !NoWait) - { pclose(popenstream); } + { + pclose(popenstream); + } // rajout pout la sauvegarde de la solution if (boolsave) { - int64_t outm; + int64_t outm; int nbtype = nbsol; float *OutSolTab = new float[solnbfloat]; @@ -1818,13 +1780,9 @@ class PopenMeditMesh3_Op : public E_F0mps { static const int n_name_param = 5; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: PopenMeditMesh3_Op(const basicAC_F0 &args) : l(args.size( ) - 1) { @@ -1848,8 +1806,7 @@ class PopenMeditMesh3_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0 == nullptr) cout << "Dynamic cast error" << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "medit in 3D: vector solution is 3 composant, tensor solution is 6 composant"); + CompileError("medit in 3D: vector solution is 3 composant, tensor solution is 6 composant"); } if (a0->size( ) == ddim) { @@ -1902,9 +1859,7 @@ class PopenMeditMesh3_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< pmesh3 >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new PopenMeditMesh3_Op(args); } @@ -1913,11 +1868,7 @@ class PopenMeditMesh3_Op : public E_F0mps { template< class v_fes > basicAC_F0::name_and_type PopenMeditMesh3_Op< v_fes >::name_param[] = { - {"order", &typeid(long)}, - {"meditff", &typeid(string *)}, - {"save", &typeid(string *)}, - {"wait", &typeid(bool)}, - {"bin", &typeid(long)}}; + {"order", &typeid(long)}, {"meditff", &typeid(string *)}, {"save", &typeid(string *)}, {"wait", &typeid(bool)}, {"bin", &typeid(long)}}; template< class v_fes > AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { @@ -2026,8 +1977,7 @@ AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { assert(iv == nv); assert(ibe = nbe); if (verbosity > 2) { - cout << "meditff :: Value of elements: vertex " << nv << " Tet " << nt << " triangle " << nbe - << endl; + cout << "meditff :: Value of elements: vertex " << nv << " Tet " << nt << " triangle " << nbe << endl; } Mesh3 *pTh = new Mesh3(nv, nt, nbe, v, t, b); @@ -2320,8 +2270,7 @@ AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { } } else { for (int k = 0; k < nt; k++) { - fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], - vzz[k]); + fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], vzz[k]); } } } @@ -2355,8 +2304,7 @@ AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { int i = Th(it, iv); mp3->setP(&Th, it, iv); - vxx[i] = - vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); + vxx[i] = vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); takemesh[i] = takemesh[i] + 1; } @@ -2469,8 +2417,7 @@ AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { vzy[k] = vzy[k] / takemesh[k]; vzz[k] = vzz[k] / takemesh[k]; - fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], - vzz[k]); + fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], vzz[k]); } } } @@ -2509,10 +2456,12 @@ AnyType PopenMeditMesh3_Op< v_fes >::operator( )(Stack stack) const { // drawing part ------------------------------ - { pclose(popenstream); } + { + pclose(popenstream); + } if (boolsave) { - int64_t outm; + int64_t outm; int nbtype = nbsol; float *OutSolTab = new float[solnbfloat]; @@ -2566,7 +2515,15 @@ class PopenMeditMeshT_Op : public E_F0mps { long what; // 0 mesh, 1 scalar, 2 vector, 3 symtensor long nbfloat; // 0 mesh(3D), 1 scalar, 2 vector (3D), 3 symtensor(3D) Expression e[6]; - Expression2( ) { e[0]=0 ; e[1]=0 ; e[2]=0; e[3]=0 ; e[4]=0; e[5]=0 ; what=0; nbfloat=0; + Expression2( ) { + e[0] = 0; + e[1] = 0; + e[2] = 0; + e[3] = 0; + e[4] = 0; + e[5] = 0; + what = 0; + nbfloat = 0; }; Expression &operator[](int i) { return e[i]; } @@ -2588,13 +2545,9 @@ class PopenMeditMeshT_Op : public E_F0mps { static const int n_name_param = 5; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: PopenMeditMeshT_Op(const basicAC_F0 &args) : l(args.size( ) - 1) { @@ -2618,8 +2571,7 @@ class PopenMeditMeshT_Op : public E_F0mps { const E_Array *a0 = dynamic_cast< const E_Array * >(args[i].LeftValue( )); if (a0 == nullptr) cout << "Dynamic cast error" << endl; if (a0->size( ) != ddim && a0->size( ) != stsize) { - CompileError( - "medit in 3D: vector solution is 3 composant, tensor solution is 6 composant"); + CompileError("medit in 3D: vector solution is 3 composant, tensor solution is 6 composant"); } if (a0->size( ) == ddim) { @@ -2672,9 +2624,7 @@ class PopenMeditMeshT_Op : public E_F0mps { } } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); - } // all type + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( ), atype< ppmesh >( ), true); } // all type static E_F0 *f(const basicAC_F0 &args) { return new PopenMeditMeshT_Op< MMesh, v_fes >(args); } @@ -2683,18 +2633,10 @@ class PopenMeditMeshT_Op : public E_F0mps { template<> basicAC_F0::name_and_type PopenMeditMeshT_Op< MeshS, v_fesS >::name_param[] = { - {"order", &typeid(long)}, - {"meditff", &typeid(string *)}, - {"save", &typeid(string *)}, - {"wait", &typeid(bool)}, - {"bin", &typeid(long)}}; + {"order", &typeid(long)}, {"meditff", &typeid(string *)}, {"save", &typeid(string *)}, {"wait", &typeid(bool)}, {"bin", &typeid(long)}}; template<> basicAC_F0::name_and_type PopenMeditMeshT_Op< MeshL, v_fesL >::name_param[] = { - {"order", &typeid(long)}, - {"meditff", &typeid(string *)}, - {"save", &typeid(string *)}, - {"wait", &typeid(bool)}, - {"bin", &typeid(long)}}; + {"order", &typeid(long)}, {"meditff", &typeid(string *)}, {"save", &typeid(string *)}, {"wait", &typeid(bool)}, {"bin", &typeid(long)}}; template< class MMesh, class v_fes > AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { @@ -2791,8 +2733,7 @@ AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { assert(iv == nv); assert(ibe == nbe); if (verbosity > 2) { - cout << "meditff :: Value of elements: vertex " << nv << " surface Triangle " << nt - << " boundary edge " << nbe << endl; + cout << "meditff :: Value of elements: vertex " << nv << " surface Triangle " << nt << " boundary edge " << nbe << endl; } MMesh *pTh = new MMesh(nv, nt, nbe, v, t, b); @@ -3075,8 +3016,7 @@ AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { } } else { for (int k = 0; k < nt; k++) { - fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], - vzz[k]); + fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], vzz[k]); } } } @@ -3110,8 +3050,7 @@ AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { int i = Th(it, iv); mp3->setP(&Th, it, iv); - vxx[i] = - vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); + vxx[i] = vxx[i] + l[jojo1].eval(0, stack); // GetAny< double >( (*nargs[1])(stack) ); takemesh[i] = takemesh[i] + 1; } @@ -3224,8 +3163,7 @@ AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { vzy[k] = vzy[k] / takemesh[k]; vzz[k] = vzz[k] / takemesh[k]; - fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], - vzz[k]); + fprintf(popenstream, "%f %f %f %f %f %f\n", vxx[k], vyx[k], vyy[k], vzx[k], vzy[k], vzz[k]); } } } @@ -3264,10 +3202,12 @@ AnyType PopenMeditMeshT_Op< MMesh, v_fes >::operator( )(Stack stack) const { // drawing part ------------------------------ - { pclose(popenstream); } + { + pclose(popenstream); + } if (boolsave) { - int64_t outm; + int64_t outm; int nbtype = nbsol; float *OutSolTab = new float[solnbfloat]; diff --git a/plugin/seq/meshtools.cpp b/plugin/seq/meshtools.cpp index 9cfa6f37e..d46615896 100644 --- a/plugin/seq/meshtools.cpp +++ b/plugin/seq/meshtools.cpp @@ -31,272 +31,265 @@ #include "ff++.hpp" #include "AFunction_ext.hpp" -template struct nbvertexElement { static const int value = Mesh::Element::nv; }; -template<> struct nbvertexElement { static const int value = Mesh::Element::NbV; }; +template< class Mesh > +struct nbvertexElement { + static const int value = Mesh::Element::nv; +}; +template<> +struct nbvertexElement< Mesh > { + static const int value = Mesh::Element::NbV; +}; -template -long connexecomponantea(const Mesh * pTh,KN* pcc) -{ - const Mesh & Th= *pTh; - const long nv = Th.nv; - const long nt = Th.nt; - const int d = Mesh::Rd::d; - const int dh = Mesh::RdHat::d; +template< class Mesh, class K > +long connexecomponantea(const Mesh* pTh, KN< K >* pcc) { + const Mesh& Th = *pTh; + const long nv = Th.nv; + const long nt = Th.nt; + const int d = Mesh::Rd::d; + const int dh = Mesh::RdHat::d; - const long nvk = nbvertexElement::value; - if(verbosity>9) cout << " nvk ="<< nvk << endl; - if(pcc->N() != Th.nt) pcc->resize(Th.nt); - KN & cc=*pcc; - long nbc =Th.nt; - KN forest(Th.nt,-1);// KrusKal algo - for( int k=0; k< Th.nt;++k) - for( int e =0; e< nvk; ++e ) - { - // element adj - int ee=e,kk = Th.ElementAdj(k,ee); - if( kk== k || kk<0) continue; // no ajd . - // k and kk are in the same cnx. comp. - long r1=k,r2=kk; - // recherche des racines - while( forest[r1]>=0) r1 = forest[r1]; - while( forest[r2]>=0) r2 = forest[r2]; - if(r1 !=r2) - { - nbc--; - if(forest[r1]=0) r = forest[r]; - if( cc[r] <0) cc[r] = nc++; - cc[s]=cc[r]; + const long nvk = nbvertexElement< Mesh >::value; + if (verbosity > 9) cout << " nvk =" << nvk << endl; + if (pcc->N( ) != Th.nt) pcc->resize(Th.nt); + KN< K >& cc = *pcc; + long nbc = Th.nt; + KN< long > forest(Th.nt, -1); // KrusKal algo + for (int k = 0; k < Th.nt; ++k) + for (int e = 0; e < nvk; ++e) { + // element adj + int ee = e, kk = Th.ElementAdj(k, ee); + if (kk == k || kk < 0) continue; // no ajd . + // k and kk are in the same cnx. comp. + long r1 = k, r2 = kk; + // recherche des racines + while (forest[r1] >= 0) r1 = forest[r1]; + while (forest[r2] >= 0) r2 = forest[r2]; + if (r1 != r2) { + nbc--; + if (forest[r1] < forest[r2]) + forest[r2] = r1; // lie arbre r2 sur racine r1 + else if (forest[r2] < forest[r1]) + forest[r1] = r2; // lie arbre r2 sur racine r1 + else + forest[r1] = r2, forest[r2]--; // lie arbre r2 sur racine r1 et incremente al profondeur + } } - ffassert(nc==nbc); - if( verbosity) cout << " The number of connexe componante (by adj) Mesh "<< pTh << " is " << nc << " / " - " dim = " << d << " dim s " << dh << endl; - return nc; + // build cc + cc = -1; // + long nc = 0; + for (long s = 0; s < nt; ++s) { + long r = s; + while (forest[r] >= 0) r = forest[r]; + if (cc[r] < 0) cc[r] = nc++; + cc[s] = cc[r]; + } + ffassert(nc == nbc); + if (verbosity) + cout << " The number of connexe componante (by adj) Mesh " << pTh << " is " << nc + << " / " + " dim = " + << d << " dim s " << dh << endl; + return nc; } -template -long connexecomponantev(const Mesh * pTh,KN* pcc) -{ - const Mesh & Th= *pTh; - const long nv = Th.nv; - const long nt = Th.nt; - const int d = Mesh::Rd::d; - const int dh = Mesh::RdHat::d; +template< class Mesh, class K > +long connexecomponantev(const Mesh* pTh, KN< K >* pcc) { + const Mesh& Th = *pTh; + const long nv = Th.nv; + const long nt = Th.nt; + const int d = Mesh::Rd::d; + const int dh = Mesh::RdHat::d; - const long nvk = nbvertexElement::value; - if(verbosity>9) cout << " nvk ="<< nvk << endl; - if(pcc->N() != Th.nv) pcc->resize(Th.nv); - KN & cc=*pcc; - long nbc =Th.nv; - KN forest(Th.nv,-1);// KrusKal algo - for( int k=0; k< Th.nt;++k) - for( int i1 =0; i1< nvk-1; ++i1 )// small opt because elem is connexe .. - { - long i2= (i1+1)%nvk; - long s1 = Th(k,i1); - long s2 = Th(k,i2); - // s0 and s1 are in the same cnx. comp. - long r1=s1,r2=s2; - // recherche des racines - while( forest[r1]>=0) r1 = forest[r1]; - while( forest[r2]>=0) r2 = forest[r2]; - if(r1 !=r2) - { - nbc--; - if(forest[r1]::value; + if (verbosity > 9) cout << " nvk =" << nvk << endl; + if (pcc->N( ) != Th.nv) pcc->resize(Th.nv); + KN< K >& cc = *pcc; + long nbc = Th.nv; + KN< long > forest(Th.nv, -1); // KrusKal algo + for (int k = 0; k < Th.nt; ++k) + for (int i1 = 0; i1 < nvk - 1; ++i1) // small opt because elem is connexe .. { - long r=s; - while( forest[r]>=0) r = forest[r]; - if( cc[r] <0) cc[r] = nc++; - cc[s]=cc[r]; + long i2 = (i1 + 1) % nvk; + long s1 = Th(k, i1); + long s2 = Th(k, i2); + // s0 and s1 are in the same cnx. comp. + long r1 = s1, r2 = s2; + // recherche des racines + while (forest[r1] >= 0) r1 = forest[r1]; + while (forest[r2] >= 0) r2 = forest[r2]; + if (r1 != r2) { + nbc--; + if (forest[r1] < forest[r2]) + forest[r2] = r1; // lie arbre r2 sur racine r1 + else if (forest[r2] < forest[r1]) + forest[r1] = r2; // lie arbre r2 sur racine r1 + else + forest[r1] = r2, forest[r2]--; // lie arbre r2 sur racine r1 et incremente al profondeur + } } - ffassert(nc==nbc); - if( verbosity) cout << " The number of connexe componante (by vertex) Mesh "<< pTh << " is " << nc << " / " - " dim = " << d << " dim s " << dh << endl; - return nc; + // build cc + cc = -1; // + long nc = 0; + for (long s = 0; s < nv; ++s) { + long r = s; + while (forest[r] >= 0) r = forest[r]; + if (cc[r] < 0) cc[r] = nc++; + cc[s] = cc[r]; + } + ffassert(nc == nbc); + if (verbosity) + cout << " The number of connexe componante (by vertex) Mesh " << pTh << " is " << nc + << " / " + " dim = " + << d << " dim s " << dh << endl; + return nc; } -template -long connexecomponante(const Mesh * pTh,KN* pcc,long flags) -{ - if(verbosity) cout << " ConnectedComponents closure flags "<< flags < cv(pTh->nv); - nbc = connexecomponantev(pTh,&cv); - if( pcc->N() != Th.nv) pcc->resize(Th.nt); - KN & c = *pcc; - const long nvk = nbvertexElement::value; - - for( int k=0; k< Th.nt;++k) - c[k]= cv[Th(k,0)]; - } - else if (flags==2) - nbc = connexecomponantev(pTh,pcc); - else - nbc = connexecomponantea(pTh,pcc); - if(verbosity) cout << " nb. ConnectedComponents "<< nbc << endl; - return nbc; +template< class Mesh, class K > +long connexecomponante(const Mesh* pTh, KN< K >* pcc, long flags) { + if (verbosity) cout << " ConnectedComponents closure flags " << flags << endl; + long nbc = 0; + const Mesh& Th = *pTh; + if (flags == 1) // data on element .. + { + KN< long > cv(pTh->nv); + nbc = connexecomponantev(pTh, &cv); + if (pcc->N( ) != Th.nv) pcc->resize(Th.nt); + KN< K >& c = *pcc; + const long nvk = nbvertexElement< Mesh >::value; + + for (int k = 0; k < Th.nt; ++k) c[k] = cv[Th(k, 0)]; + } else if (flags == 2) + nbc = connexecomponantev(pTh, pcc); + else + nbc = connexecomponantea(pTh, pcc); + if (verbosity) cout << " nb. ConnectedComponents " << nbc << endl; + return nbc; } -template -class ConnectedComponents : public E_F0mps { -public: - // typedef double K; - typedef Mesh const * pmesh; - typedef long Result; - Expression eTh,ecc; - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =2; +template< class Mesh, class K > +class ConnectedComponents : public E_F0mps { + public: + // typedef double K; + typedef Mesh const* pmesh; + typedef long Result; + Expression eTh, ecc; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 2; Expression nargs[n_name_param]; - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - ConnectedComponents(const basicAC_F0 & args) - { - cout << "ConnectedComponents n_name_param" << n_name_param << endl; - args.SetNameParam(n_name_param,name_param,nargs); - eTh=to(args[0]); - ecc=to*>(args[1]); + ConnectedComponents(const basicAC_F0& args) { + cout << "ConnectedComponents n_name_param" << n_name_param << endl; + args.SetNameParam(n_name_param, name_param, nargs); + eTh = to< pmesh >(args[0]); + ecc = to< KN< K >* >(args[1]); } - static ArrayOfaType typeargs() { - return ArrayOfaType(atype(),atype*>(),false);} + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), atype< KN< K >* >( ), false); } /// <> - static E_F0 * f(const basicAC_F0 & args){ - return new ConnectedComponents(args);} + static E_F0* f(const basicAC_F0& args) { return new ConnectedComponents(args); } - AnyType operator()(Stack s) const { - long flags=arg(0,s,0); + AnyType operator( )(Stack s) const { + long flags = arg(0, s, 0); flags = flags != 0; - long flagsv=arg(1,s,0); - if(flagsv) flags=2; - pmesh pTh= GetAny( (*eTh)(s)); - KN* pcc = GetAny*>( (*ecc)(s)); + long flagsv = arg(1, s, 0); + if (flagsv) flags = 2; + pmesh pTh = GetAny< pmesh >((*eTh)(s)); + KN< K >* pcc = GetAny< KN< K >* >((*ecc)(s)); /// calls [[Carre]] - return connexecomponante(pTh,pcc,flags); + return connexecomponante(pTh, pcc, flags); } - operator aType () const { return atype();} + operator aType( ) const { return atype< pmesh >( ); } }; -template > -KN_ iminKP1(Stack stack,const Mesh * const & pTh,KN * const & pu) -{ - const Cmp cmp=Cmp(); - if(verbosity>9) cout << "iminKP1: cmp(1.,2.) =" << cmp(1.,2.)<< endl; - const int d= Mesh::RdHat::d; - const int nbvK = d+1; - ffassert(pu); - const Mesh & Th=*pTh; - KN &u=*pu; - ffassert(u.N()== Th.nv); // P1 ... - long *pi = Add2StackOfPtr2FreeA(stack,new long[Th.nt]); - if(verbosity>1) cout<< " i[min|max]KP1: nbvk ="<< nbvK << " nv " << Th.nv << " nt :" << Th.nt << " cmp: " << cmp(1.,2.) << endl; - for (long k=0;k u[jm] ) im =jm; - if( cmp(u[jm], u[im]) ) im =jm; - } - pi[k]=im; +template< class Mesh, class Cmp = std::less< double > > +KN_< long > iminKP1(Stack stack, const Mesh* const& pTh, KN< double >* const& pu) { + const Cmp cmp = Cmp( ); + if (verbosity > 9) cout << "iminKP1: cmp(1.,2.) =" << cmp(1., 2.) << endl; + const int d = Mesh::RdHat::d; + const int nbvK = d + 1; + ffassert(pu); + const Mesh& Th = *pTh; + KN< double >& u = *pu; + ffassert(u.N( ) == Th.nv); // P1 ... + long* pi = Add2StackOfPtr2FreeA(stack, new long[Th.nt]); + if (verbosity > 1) cout << " i[min|max]KP1: nbvk =" << nbvK << " nv " << Th.nv << " nt :" << Th.nt << " cmp: " << cmp(1., 2.) << endl; + for (long k = 0; k < Th.nt; ++k) { + long im = Th(k, 0); + for (int i = 1; i < nbvK; ++i) { + long jm = Th(k, i); + // if( u[im] > u[jm] ) im =jm; + if (cmp(u[jm], u[im])) im = jm; } - return KN_(pi,Th.nt); + pi[k] = im; + } + return KN_< long >(pi, Th.nt); +} +template< class Mesh > +KN_< long > imaxKP1(Stack stack, const Mesh* const& pTh, KN< double >* const& pu) { + return iminKP1< Mesh, greater< double > >(stack, pTh, pu); } -template -KN_ imaxKP1(Stack stack,const Mesh * const & pTh,KN * const & pu) -{ return iminKP1 >(stack,pTh,pu);} -template -basicAC_F0::name_and_type ConnectedComponents::name_param[]= { - { "closure", &typeid(long) }, - { "vertices", &typeid(long) } -}; +template< class Mesh, class K > +basicAC_F0::name_and_type ConnectedComponents< Mesh, K >::name_param[] = {{"closure", &typeid(long)}, {"vertices", &typeid(long)}}; static void inittt( ) { - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("ConnectedComponents", "(",new OneOperatorCode > ); - Global.Add("iminKP1", "(",new OneOperator2s_,pmesh3,KN * >(iminKP1)); - Global.Add("iminKP1", "(",new OneOperator2s_,pmesh,KN * >(iminKP1)); - Global.Add("iminKP1", "(",new OneOperator2s_,pmeshL,KN * >(iminKP1)); - Global.Add("iminKP1", "(",new OneOperator2s_,pmeshS,KN * >(iminKP1)); - Global.Add("imaxKP1", "(",new OneOperator2s_,pmesh3,KN * >(imaxKP1)); - Global.Add("imaxKP1", "(",new OneOperator2s_,pmesh,KN * >(imaxKP1)); - Global.Add("imaxKP1", "(",new OneOperator2s_,pmeshL,KN * >(imaxKP1)); - Global.Add("imaxKP1", "(",new OneOperator2s_,pmeshS,KN * >(imaxKP1)); -/* - Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); - Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); - Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); - Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< Mesh, double > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< Mesh, long > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< Mesh3, double > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< Mesh3, long > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< MeshL, double > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< MeshL, long > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< MeshS, double > >); + Global.Add("ConnectedComponents", "(", new OneOperatorCode< ConnectedComponents< MeshS, long > >); + Global.Add("iminKP1", "(", new OneOperator2s_< KN_< long >, pmesh3, KN< double >* >(iminKP1)); + Global.Add("iminKP1", "(", new OneOperator2s_< KN_< long >, pmesh, KN< double >* >(iminKP1)); + Global.Add("iminKP1", "(", new OneOperator2s_< KN_< long >, pmeshL, KN< double >* >(iminKP1)); + Global.Add("iminKP1", "(", new OneOperator2s_< KN_< long >, pmeshS, KN< double >* >(iminKP1)); + Global.Add("imaxKP1", "(", new OneOperator2s_< KN_< long >, pmesh3, KN< double >* >(imaxKP1)); + Global.Add("imaxKP1", "(", new OneOperator2s_< KN_< long >, pmesh, KN< double >* >(imaxKP1)); + Global.Add("imaxKP1", "(", new OneOperator2s_< KN_< long >, pmeshL, KN< double >* >(imaxKP1)); + Global.Add("imaxKP1", "(", new OneOperator2s_< KN_< long >, pmeshS, KN< double >* >(imaxKP1)); + /* Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); + new OneOperator2* >(connexecomponantev)); Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); + new OneOperator2* >(connexecomponantev)); Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); + new OneOperator2* >(connexecomponantev)); Global.Add("connexecomponantev", "(", - new OneOperator2* >(connexecomponantev)); - - Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); - Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); + new OneOperator2* >(connexecomponantev)); + Global.Add("connexecomponantev", "(", + new OneOperator2* >(connexecomponantev)); + Global.Add("connexecomponantev", "(", + new OneOperator2* >(connexecomponantev)); + Global.Add("connexecomponantev", "(", + new OneOperator2* >(connexecomponantev)); + Global.Add("connexecomponantev", "(", + new OneOperator2* >(connexecomponantev)); - Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); - Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); + new OneOperator2* >(connexecomponantea)); Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); + new OneOperator2* >(connexecomponantea)); + Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); + new OneOperator2* >(connexecomponantea)); Global.Add("connexecomponantea", "(", - new OneOperator2* >(connexecomponantea)); -*/ + new OneOperator2* >(connexecomponantea)); + Global.Add("connexecomponantea", "(", + new OneOperator2* >(connexecomponantea)); + Global.Add("connexecomponantea", "(", + new OneOperator2* >(connexecomponantea)); + Global.Add("connexecomponantea", "(", + new OneOperator2* >(connexecomponantea)); + Global.Add("connexecomponantea", "(", + new OneOperator2* >(connexecomponantea)); + */ } LOADFUNC(inittt); diff --git a/plugin/seq/metis.cpp b/plugin/seq/metis.cpp index c4b1b5805..e118de9fb 100644 --- a/plugin/seq/metis.cpp +++ b/plugin/seq/metis.cpp @@ -45,59 +45,55 @@ typedef idxtype idx_t; #endif template< class FESPACE, int NO, typename R > -KN< R > *partmetis( KN< R > *const &part, FESPACE *const &pVh, long const &lparts) { +KN< R > *partmetis(KN< R > *const &part, FESPACE *const &pVh, long const &lparts) { ffassert(pVh); const FESPACE &Vh(*pVh); - int nve = Vh[0].NbDoF( ); - const typename FESPACE::Mesh & Th = Vh.Th; - idx_t nt = Th.nt, nv = Vh.NbOfDF; - + int nve = Vh[0].NbDoF( ); + const typename FESPACE::Mesh &Th = Vh.Th; + idx_t nt = Th.nt, nv = Vh.NbOfDF; KN< idx_t > eptr(nt + 1), elmnts(nve * nt), epart(nt), npart(nv); - if(lparts > 1) { - for (idx_t k = 0, i = 0; k < nt; ++k) { - eptr[k] = i; + if (lparts > 1) { + for (idx_t k = 0, i = 0; k < nt; ++k) { + eptr[k] = i; - for (idx_t j = 0; j < nve; j++) { - elmnts[i++] = Vh(k, j); - } - - eptr[k + 1] = i; + for (idx_t j = 0; j < nve; j++) { + elmnts[i++] = Vh(k, j); } - idx_t numflag = 0; - idx_t nparts = lparts; - idx_t edgecut; - idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 - idx_t ncommon = 1; + eptr[k + 1] = i; + } + + idx_t numflag = 0; + idx_t nparts = lparts; + idx_t edgecut; + idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 + idx_t ncommon = 1; #ifdef METIS_VER_MAJOR - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } else { - METIS_PartMeshDual(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &nparts, 0, 0, &edgecut, (idx_t *)epart, (idx_t *)npart); + } else { + METIS_PartMeshDual(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, (idx_t *)epart, (idx_t *)npart); + } - if (verbosity) { - printf(" --metisOA: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - libmetis__ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metisOA: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, libmetis__ComputeElementBalance(nt, nparts, epart), NO); + } #else - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } else { - METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } else { + METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } - if (verbosity) { - printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, ComputeElementBalance(nt, nparts, epart), NO); + } #endif - } else epart = static_cast(0); + } else + epart = static_cast< idx_t >(0); part->resize(nv); *part = npart; return part; @@ -111,50 +107,47 @@ KN< R > *partmetis(Stack s, KN< R > *const &part, Mesh *const &pTh, long const & idx_t nve = Mesh::RdHat::d + 1; KN< idx_t > eptr(nt + 1), elmnts(nve * nt), epart(nt), npart(nv); - if(lparts > 1) { - for (idx_t k = 0, i = 0; k < nt; ++k) { - eptr[k] = i; - - for (idx_t j = 0; j < nve; j++) { - elmnts[i++] = Th(k, j); - } + if (lparts > 1) { + for (idx_t k = 0, i = 0; k < nt; ++k) { + eptr[k] = i; - eptr[k + 1] = i; + for (idx_t j = 0; j < nve; j++) { + elmnts[i++] = Th(k, j); } - idx_t numflag = 0; - idx_t nparts = lparts; - idx_t edgecut; - idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 - idx_t ncommon = 1; + eptr[k + 1] = i; + } + + idx_t numflag = 0; + idx_t nparts = lparts; + idx_t edgecut; + idx_t etype = nve - 2; // triangle or tet . change FH fevr 2010 + idx_t ncommon = 1; #ifdef METIS_VER_MAJOR - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } else { - METIS_PartMeshDual(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, - (idx_t *)epart, (idx_t *)npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &nparts, 0, 0, &edgecut, (idx_t *)epart, (idx_t *)npart); + } else { + METIS_PartMeshDual(&nt, &nv, eptr, (idx_t *)elmnts, 0, 0, &ncommon, &nparts, 0, 0, &edgecut, (idx_t *)epart, (idx_t *)npart); + } - if (verbosity) { - printf(" --metisOA: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - libmetis__ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metisOA: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, libmetis__ComputeElementBalance(nt, nparts, epart), NO); + } #else - if (NO == 0) { - METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } else { - METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); - } + if (NO == 0) { + METIS_PartMeshNodal(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } else { + METIS_PartMeshDual(&nt, &nv, elmnts, &etype, &numflag, &nparts, &edgecut, epart, npart); + } - if (verbosity) { - printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, - ComputeElementBalance(nt, nparts, epart), NO); - } + if (verbosity) { + printf(" --metis: %d-way Edge-Cut: %7d, Balance: %5.2f Nodal=0/Dual %d\n", nparts, nve, ComputeElementBalance(nt, nparts, epart), NO); + } #endif - } else epart = static_cast(0); + } else + epart = static_cast< idx_t >(0); part->resize(nt); *part = epart; return part; @@ -167,66 +160,65 @@ KN< long > *partmetisd(Stack s, KN< long > *const &part, Mesh *const &pTh, long idx_t nve = Mesh::Element::NbV; KN< idx_t > elmnts(nve * nt), epart(nt), npart(nv); - if(lparts > 1) { - for (idx_t k = 0, i = 0; k < nt; ++k) { - for (idx_t j = 0; j < nve; j++) { - elmnts[i++] = Th(k, j); - } + if (lparts > 1) { + for (idx_t k = 0, i = 0; k < nt; ++k) { + for (idx_t j = 0; j < nve; j++) { + elmnts[i++] = Th(k, j); } + } - idx_t numflag = 0; - idx_t nparts = lparts; - idx_t edgecut; + idx_t numflag = 0; + idx_t nparts = lparts; + idx_t edgecut; #ifdef METIS_VER_MAJOR - printf(" %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve, - libmetis__ComputeElementBalance(nt, nparts, epart)); + printf(" %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve, libmetis__ComputeElementBalance(nt, nparts, epart)); #else - printf(" %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve, - ComputeElementBalance(nt, nparts, epart)); + printf(" %d-way Edge-Cut: %7d, Balance: %5.2f\n", nparts, nve, ComputeElementBalance(nt, nparts, epart)); #endif - } else epart = static_cast(0); + } else + epart = static_cast< idx_t >(0); part->resize(nt); *part = epart; return part; } -template -double metisFE( pf3r const & uij,long const &npar){ - // typedef typename v_fes::pfes pfes; +template< typename pf3r, int NO > +double metisFE(pf3r const &uij, long const &npar) { + // typedef typename v_fes::pfes pfes; // typedef typename v_fes::FESpace FESpace; - // typedef pair pf3r ; - typedef typename pf3r::first_type pf3rbase; - typedef typename remove_pointer::type FEbase; - typedef typename FEbase::FESpace FESpace; - typedef typename FESpace::Mesh Mesh; - typedef typename FEbase::pfes pfes; - - // typedef pf3r.pfes; + // typedef pair pf3r ; + typedef typename pf3r::first_type pf3rbase; + typedef typename remove_pointer< typename pf3r::first_type >::type FEbase; + typedef typename FEbase::FESpace FESpace; + typedef typename FESpace::Mesh Mesh; + typedef typename FEbase::pfes pfes; + + // typedef pf3r.pfes; // typedef v_fes3::FESpace FESpace; - typedef double K; - - pf3rbase buij=uij.first; - - int comp =uij.second; - cout << " composant "<< comp << endl; - KN * pux=buij->x(); - FESpace *pVh = uij.first->newVh( ); - ffassert(pVh); - if(pux ==0 || pux->N() != pVh->NbOfDF) { - cout << " FE create or recreate " << pux << endl; - if(pux) delete [] pux; - *uij.first = pux = new KN< K >(pVh->NbOfDF); - *pux = K( ); - } - cout << " nbdot " << pux->N() << endl; - FESpace& Vh= *pVh; - int nbdofK = Vh[0].NbDoF( ); - const Mesh & Th = Vh.Th; - cout << " Th nt "<< Th.nt << " ns "<< Th.nv << endl; - // template< class FESPACE, int NO, typename R > - // KN< R > *partmetis( KN< R > *const &part, FESPACE *const &pVh, long const &lparts) - partmetis (pux,pVh,npar); - return 0; + typedef double K; + + pf3rbase buij = uij.first; + + int comp = uij.second; + cout << " composant " << comp << endl; + KN< K > *pux = buij->x( ); + FESpace *pVh = uij.first->newVh( ); + ffassert(pVh); + if (pux == 0 || pux->N( ) != pVh->NbOfDF) { + cout << " FE create or recreate " << pux << endl; + if (pux) delete[] pux; + *uij.first = pux = new KN< K >(pVh->NbOfDF); + *pux = K( ); + } + cout << " nbdot " << pux->N( ) << endl; + FESpace &Vh = *pVh; + int nbdofK = Vh[0].NbDoF( ); + const Mesh &Th = Vh.Th; + cout << " Th nt " << Th.nt << " ns " << Th.nv << endl; + // template< class FESPACE, int NO, typename R > + // KN< R > *partmetis( KN< R > *const &part, FESPACE *const &pVh, long const &lparts) + partmetis< FESpace, NO, K >(pux, pVh, npar); + return 0; } static void Load_Init( ) { @@ -241,99 +233,45 @@ static void Load_Init( ) { cout << " load: init metis (v 4 )\n"; } #endif - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< long > *, KN< long > *, const Mesh *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh *, long > >( - &partmetis< const Mesh, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< long > *, KN< long > *, const Mesh *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh *, long > >( - &partmetis< const Mesh, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< long > *, KN< long > *, const Mesh3 *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh3 *, long > >( - &partmetis< const Mesh3, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< long > *, KN< long > *, const Mesh3 *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh3 *, long > >( - &partmetis< const Mesh3, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< long > *, KN< long > *, const MeshS *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshS *, long > >( - &partmetis< const MeshS, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< long > *, KN< long > *, const MeshS *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshS *, long > >( - &partmetis< const MeshS, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< long > *, KN< long > *, const MeshL *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshL *, long > >( - &partmetis< const MeshL, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< long > *, KN< long > *, const MeshL *, long, - E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshL *, long > >( - &partmetis< const MeshL, 1 >)); - - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< double > *, KN< double > *, const Mesh *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh *, long > >( - &partmetis< const Mesh, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< double > *, KN< double > *, const Mesh *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh *, long > >( - &partmetis< const Mesh, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< double > *, KN< double > *, const Mesh3 *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh3 *, long > >( - &partmetis< const Mesh3, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< double > *, KN< double > *, const Mesh3 *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh3 *, long > >( - &partmetis< const Mesh3, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< double > *, KN< double > *, const MeshS *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshS *, long > >( - &partmetis< const MeshS, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< double > *, KN< double > *, const MeshS *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshS *, long > >( - &partmetis< const MeshS, 1 >)); - Global.Add( - "metisnodal", "(", - new OneOperator3_< KN< double > *, KN< double > *, const MeshL *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshL *, long > >( - &partmetis< const MeshL, 0 >)); - Global.Add( - "metisdual", "(", - new OneOperator3_< KN< double > *, KN< double > *, const MeshL *, long, - E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshL *, long > >( - &partmetis< const MeshL, 1 >)); - Global.Add("metisnodal","(",new OneOperator2_(metisFE)); - Global.Add("metisdual","(",new OneOperator2_(metisFE)); - - Global.Add("metisnodal","(",new OneOperator2_(metisFE)); - Global.Add("metisdual","(",new OneOperator2_(metisFE)); - - Global.Add("metisnodal","(",new OneOperator2_(metisFE)); - Global.Add("metisdual","(",new OneOperator2_(metisFE)); - - Global.Add("metisnodal","(",new OneOperator2_(metisFE)); - Global.Add("metisdual","(",new OneOperator2_(metisFE)); - + Global.Add("metisnodal", "(", new OneOperator3_< KN< long > *, KN< long > *, const Mesh *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh *, long > >(&partmetis< const Mesh, 0 >)); + Global.Add("metisdual", "(", new OneOperator3_< KN< long > *, KN< long > *, const Mesh *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh *, long > >(&partmetis< const Mesh, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< long > *, KN< long > *, const Mesh3 *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh3 *, long > >(&partmetis< const Mesh3, 0 >)); + Global.Add("metisdual", "(", new OneOperator3_< KN< long > *, KN< long > *, const Mesh3 *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const Mesh3 *, long > >(&partmetis< const Mesh3, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< long > *, KN< long > *, const MeshS *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshS *, long > >(&partmetis< const MeshS, 0 >)); + Global.Add("metisdual", "(", new OneOperator3_< KN< long > *, KN< long > *, const MeshS *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshS *, long > >(&partmetis< const MeshS, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< long > *, KN< long > *, const MeshL *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshL *, long > >(&partmetis< const MeshL, 0 >)); + Global.Add("metisdual", "(", new OneOperator3_< KN< long > *, KN< long > *, const MeshL *, long, E_F_stackF0F0F0_< KN< long > *, KN< long > *, const MeshL *, long > >(&partmetis< const MeshL, 1 >)); + + Global.Add("metisnodal", "(", + new OneOperator3_< KN< double > *, KN< double > *, const Mesh *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh *, long > >(&partmetis< const Mesh, 0 >)); + Global.Add("metisdual", "(", + new OneOperator3_< KN< double > *, KN< double > *, const Mesh *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh *, long > >(&partmetis< const Mesh, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< double > *, KN< double > *, const Mesh3 *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh3 *, long > >(&partmetis< const Mesh3, 0 >)); + Global.Add("metisdual", "(", + new OneOperator3_< KN< double > *, KN< double > *, const Mesh3 *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const Mesh3 *, long > >(&partmetis< const Mesh3, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< double > *, KN< double > *, const MeshS *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshS *, long > >(&partmetis< const MeshS, 0 >)); + Global.Add("metisdual", "(", + new OneOperator3_< KN< double > *, KN< double > *, const MeshS *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshS *, long > >(&partmetis< const MeshS, 1 >)); + Global.Add("metisnodal", "(", + new OneOperator3_< KN< double > *, KN< double > *, const MeshL *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshL *, long > >(&partmetis< const MeshL, 0 >)); + Global.Add("metisdual", "(", + new OneOperator3_< KN< double > *, KN< double > *, const MeshL *, long, E_F_stackF0F0F0_< KN< double > *, KN< double > *, const MeshL *, long > >(&partmetis< const MeshL, 1 >)); + Global.Add("metisnodal", "(", new OneOperator2_< double, pf3r, long >(metisFE< pf3r, 0 >)); + Global.Add("metisdual", "(", new OneOperator2_< double, pf3r, long >(metisFE< pf3r, 1 >)); + + Global.Add("metisnodal", "(", new OneOperator2_< double, pfSr, long >(metisFE< pfSr, 0 >)); + Global.Add("metisdual", "(", new OneOperator2_< double, pfSr, long >(metisFE< pfSr, 1 >)); + + Global.Add("metisnodal", "(", new OneOperator2_< double, pfLr, long >(metisFE< pfLr, 0 >)); + Global.Add("metisdual", "(", new OneOperator2_< double, pfLr, long >(metisFE< pfLr, 1 >)); + + Global.Add("metisnodal", "(", new OneOperator2_< double, pfer, long >(metisFE< pfer, 0 >)); + Global.Add("metisdual", "(", new OneOperator2_< double, pfer, long >(metisFE< pfer, 1 >)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/mmg.cpp b/plugin/seq/mmg.cpp index b34412fa2..b2ad88884 100644 --- a/plugin/seq/mmg.cpp +++ b/plugin/seq/mmg.cpp @@ -1,5 +1,7 @@ +/* clang-format off */ //ff-c++-LIBRARY-dep: mmg scotch //ff-c++-cpp-dep: +/* clang-format on */ #include "ff++.hpp" #include "memory.h" @@ -8,363 +10,319 @@ using namespace Fem2D; -template int ffmesh_to_MMG5_pMesh(const ffmesh &, MMG5_pMesh&); +template< class ffmesh > +int ffmesh_to_MMG5_pMesh(const ffmesh &, MMG5_pMesh &); template<> -int ffmesh_to_MMG5_pMesh(const Mesh &Th, MMG5_pMesh& mesh) { - int nVertices = Th.nv; - int nTriangles = Th.nt; +int ffmesh_to_MMG5_pMesh< Mesh >(const Mesh &Th, MMG5_pMesh &mesh) { + int nVertices = Th.nv; + int nTriangles = Th.nt; int nQuadrilaterals = 0; - int nEdges = Th.neb; + int nEdges = Th.neb; - if ( MMG2D_Set_meshSize(mesh,nVertices,nTriangles, - nQuadrilaterals,nEdges) != 1 ) { - exit(EXIT_FAILURE); - } + if (MMG2D_Set_meshSize(mesh, nVertices, nTriangles, nQuadrilaterals, nEdges) != 1) { + exit(EXIT_FAILURE); + } - for (int k = 0; k < Th.nv; k++) { - if ( MMG2D_Set_vertex(mesh,Th.vertices[k].x,Th.vertices[k].y, - Th.vertices[k].lab, k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nv; k++) { + if (MMG2D_Set_vertex(mesh, Th.vertices[k].x, Th.vertices[k].y, Th.vertices[k].lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.nt; k++) { - const Triangle &K(Th[k]); - if ( MMG2D_Set_triangle(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1, - Th.operator()(K[2])+1,K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nt; k++) { + const Triangle &K(Th[k]); + if (MMG2D_Set_triangle(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.neb; k++) { - const Mesh::BorderElement &K(Th.be(k)); - if ( MMG2D_Set_edge(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1, - K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.neb; k++) { + const Mesh::BorderElement &K(Th.be(k)); + if (MMG2D_Set_edge(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } return 0; } template<> -int ffmesh_to_MMG5_pMesh(const Mesh3 &Th, MMG5_pMesh& mesh) { - int nVertices = Th.nv; - int nTetrahedra = Th.nt; - int nPrisms = 0; - int nTriangles = Th.nbe; +int ffmesh_to_MMG5_pMesh< Mesh3 >(const Mesh3 &Th, MMG5_pMesh &mesh) { + int nVertices = Th.nv; + int nTetrahedra = Th.nt; + int nPrisms = 0; + int nTriangles = Th.nbe; int nQuadrilaterals = 0; - int nEdges = 0; + int nEdges = 0; - if ( MMG3D_Set_meshSize(mesh,nVertices,nTetrahedra,nPrisms,nTriangles, - nQuadrilaterals,nEdges) != 1 ) { - exit(EXIT_FAILURE); - } + if (MMG3D_Set_meshSize(mesh, nVertices, nTetrahedra, nPrisms, nTriangles, nQuadrilaterals, nEdges) != 1) { + exit(EXIT_FAILURE); + } - for (int k = 0; k < Th.nv; k++) { - if ( MMG3D_Set_vertex(mesh,Th.vertices[k].x,Th.vertices[k].y, - Th.vertices[k].z, Th.vertices[k].lab, k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nv; k++) { + if (MMG3D_Set_vertex(mesh, Th.vertices[k].x, Th.vertices[k].y, Th.vertices[k].z, Th.vertices[k].lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.nt; k++) { - const Tet &K(Th.elements[k]); - if ( MMG3D_Set_tetrahedron(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1, - Th.operator()(K[2])+1,Th.operator()(K[3])+1,K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nt; k++) { + const Tet &K(Th.elements[k]); + if (MMG3D_Set_tetrahedron(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, Th.operator( )(K[3]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.nbe; k++) { - const Triangle3 &K(Th.be(k)); - if ( MMG3D_Set_triangle(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1,Th.operator()(K[2])+1, - K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nbe; k++) { + const Triangle3 &K(Th.be(k)); + if (MMG3D_Set_triangle(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } return 0; } template<> -int ffmesh_to_MMG5_pMesh(const MeshS &Th, MMG5_pMesh& mesh) { - int nVertices = Th.nv; - int nTetrahedra = 0; - int nPrisms = 0; - int nTriangles = Th.nt; +int ffmesh_to_MMG5_pMesh< MeshS >(const MeshS &Th, MMG5_pMesh &mesh) { + int nVertices = Th.nv; + int nTetrahedra = 0; + int nPrisms = 0; + int nTriangles = Th.nt; int nQuadrilaterals = 0; - int nEdges = Th.nbe; + int nEdges = Th.nbe; - if ( MMGS_Set_meshSize(mesh,nVertices,nTriangles,nEdges) != 1 ) { - exit(EXIT_FAILURE); - } + if (MMGS_Set_meshSize(mesh, nVertices, nTriangles, nEdges) != 1) { + exit(EXIT_FAILURE); + } - for (int k = 0; k < Th.nv; k++) { - if ( MMGS_Set_vertex(mesh,Th.vertices[k].x,Th.vertices[k].y, - Th.vertices[k].z, Th.vertices[k].lab, k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nv; k++) { + if (MMGS_Set_vertex(mesh, Th.vertices[k].x, Th.vertices[k].y, Th.vertices[k].z, Th.vertices[k].lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.nt; k++) { - const TriangleS &K(Th.elements[k]); - if ( MMGS_Set_triangle(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1,Th.operator()(K[2])+1, - K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nt; k++) { + const TriangleS &K(Th.elements[k]); + if (MMGS_Set_triangle(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, Th.operator( )(K[2]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } - for (int k = 0; k < Th.nbe; k++) { - const BoundaryEdgeS &K(Th.be(k)); - if ( MMGS_Set_edge(mesh,Th.operator()(K[0])+1,Th.operator()(K[1])+1, - K.lab,k+1) != 1 ) { - exit(EXIT_FAILURE); - } + for (int k = 0; k < Th.nbe; k++) { + const BoundaryEdgeS &K(Th.be(k)); + if (MMGS_Set_edge(mesh, Th.operator( )(K[0]) + 1, Th.operator( )(K[1]) + 1, K.lab, k + 1) != 1) { + exit(EXIT_FAILURE); } + } return 0; } -template int MMG5_pMesh_to_ffmesh(const MMG5_pMesh&, ffmesh *&); +template< class ffmesh > +int MMG5_pMesh_to_ffmesh(const MMG5_pMesh &, ffmesh *&); template<> -int MMG5_pMesh_to_ffmesh(const MMG5_pMesh& mesh, Mesh *&T_TH) { - int ier; +int MMG5_pMesh_to_ffmesh< Mesh >(const MMG5_pMesh &mesh, Mesh *&T_TH) { + int ier; - int nVertices = 0; - int nTriangles = 0; - int nEdges = 0; + int nVertices = 0; + int nTriangles = 0; + int nEdges = 0; - if ( MMG2D_Get_meshSize(mesh,&nVertices,&nTriangles,NULL, - &nEdges) !=1 ) { - ier = MMG5_STRONGFAILURE; - } + if (MMG2D_Get_meshSize(mesh, &nVertices, &nTriangles, NULL, &nEdges) != 1) { + ier = MMG5_STRONGFAILURE; + } - Vertex *v = new Vertex[nVertices]; - Triangle *t = new Triangle[nTriangles]; - Triangle *tt = t; - Mesh::BorderElement *b = new Mesh::BorderElement[nEdges]; - Mesh::BorderElement *bb = b; - int k; + Vertex *v = new Vertex[nVertices]; + Triangle *t = new Triangle[nTriangles]; + Triangle *tt = t; + Mesh::BorderElement *b = new Mesh::BorderElement[nEdges]; + Mesh::BorderElement *bb = b; + int k; - int corner, required; + int corner, required; - for (k = 0; k < nVertices; k++) { - if ( MMG2D_Get_vertex(mesh,&(v[k].x),&(v[k].y), - &(v[k].lab),&(corner),&(required)) != 1 ) { - cout << "Unable to get mesh vertex " << k << endl; - ier = MMG5_STRONGFAILURE; - } + for (k = 0; k < nVertices; k++) { + if (MMG2D_Get_vertex(mesh, &(v[k].x), &(v[k].y), &(v[k].lab), &(corner), &(required)) != 1) { + cout << "Unable to get mesh vertex " << k << endl; + ier = MMG5_STRONGFAILURE; } + } - for ( k=0; kset(v, iv[0], iv[1], iv[2], lab); - } - - for ( k=0; kset(v, iv[0], iv[1], lab); + for (k = 0; k < nTriangles; k++) { + int iv[3], lab; + if (MMG2D_Get_triangle(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh triangle " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 3; i++) iv[i]--; + tt++->set(v, iv[0], iv[1], iv[2], lab); + } - T_TH = new Mesh(nVertices, nTriangles, nEdges, v, t, b); - - if (verbosity > 1) { - cout << "transformation maillage --> mesh " << endl; - cout << "vertices =" << nVertices << endl; - cout << "triangles =" << nTriangles << endl; - cout << "edges =" << nEdges << endl; - cout << "T_TH" << T_TH->nv << " " << T_TH->nt << " " << T_TH->neb << endl; + for (k = 0; k < nEdges; k++) { + int iv[2], lab, ridge; + if (MMG2D_Get_edge(mesh, &(iv[0]), &(iv[1]), &(lab), &(ridge), &(required)) != 1) { + cout << "Unable to get mesh edge " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 2; i++) iv[i]--; + bb++->set(v, iv[0], iv[1], lab); + } + + T_TH = new Mesh(nVertices, nTriangles, nEdges, v, t, b); + + if (verbosity > 1) { + cout << "transformation maillage --> mesh " << endl; + cout << "vertices =" << nVertices << endl; + cout << "triangles =" << nTriangles << endl; + cout << "edges =" << nEdges << endl; + cout << "T_TH" << T_TH->nv << " " << T_TH->nt << " " << T_TH->neb << endl; + } return 0; } template<> -int MMG5_pMesh_to_ffmesh(const MMG5_pMesh& mesh, Mesh3 *&T_TH3) { - int ier; +int MMG5_pMesh_to_ffmesh< Mesh3 >(const MMG5_pMesh &mesh, Mesh3 *&T_TH3) { + int ier; - int nVertices = 0; - int nTetrahedra = 0; - int nTriangles = 0; - int nEdges = 0; + int nVertices = 0; + int nTetrahedra = 0; + int nTriangles = 0; + int nEdges = 0; - if ( MMG3D_Get_meshSize(mesh,&nVertices,&nTetrahedra,NULL,&nTriangles,NULL, - &nEdges) !=1 ) { - ier = MMG5_STRONGFAILURE; - } + if (MMG3D_Get_meshSize(mesh, &nVertices, &nTetrahedra, NULL, &nTriangles, NULL, &nEdges) != 1) { + ier = MMG5_STRONGFAILURE; + } - Vertex3 *v = new Vertex3[nVertices]; - Tet *t = new Tet[nTetrahedra]; - Tet *tt = t; - Triangle3 *b = new Triangle3[nTriangles]; - Triangle3 *bb = b; - int k; + Vertex3 *v = new Vertex3[nVertices]; + Tet *t = new Tet[nTetrahedra]; + Tet *tt = t; + Triangle3 *b = new Triangle3[nTriangles]; + Triangle3 *bb = b; + int k; - int corner, required; + int corner, required; - for (k = 0; k < nVertices; k++) { - if ( MMG3D_Get_vertex(mesh,&(v[k].x),&(v[k].y),&(v[k].z), - &(v[k].lab),&(corner),&(required)) != 1 ) { - cout << "Unable to get mesh vertex " << k << endl; - ier = MMG5_STRONGFAILURE; - } + for (k = 0; k < nVertices; k++) { + if (MMG3D_Get_vertex(mesh, &(v[k].x), &(v[k].y), &(v[k].z), &(v[k].lab), &(corner), &(required)) != 1) { + cout << "Unable to get mesh vertex " << k << endl; + ier = MMG5_STRONGFAILURE; } + } - for ( k=0; kset(v, iv, lab); - } - - for ( k=0; kset(v, iv, lab); + for (k = 0; k < nTetrahedra; k++) { + int iv[4], lab; + if (MMG3D_Get_tetrahedron(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(iv[3]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh tetra " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 4; i++) iv[i]--; + tt++->set(v, iv, lab); + } - T_TH3 = new Mesh3(nVertices, nTetrahedra, nTriangles, v, t, b, 1); - - if (verbosity > 1) { - cout << "transformation maillage --> mesh3 " << endl; - cout << "vertices =" << nVertices << endl; - cout << "tetrahedrons =" << nTetrahedra << endl; - cout << "triangles =" << nTriangles << endl; - cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; + for (k = 0; k < nTriangles; k++) { + int iv[3], lab; + if (MMG3D_Get_triangle(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh triangle " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 3; i++) iv[i]--; + bb++->set(v, iv, lab); + } + + T_TH3 = new Mesh3(nVertices, nTetrahedra, nTriangles, v, t, b, 1); + + if (verbosity > 1) { + cout << "transformation maillage --> mesh3 " << endl; + cout << "vertices =" << nVertices << endl; + cout << "tetrahedrons =" << nTetrahedra << endl; + cout << "triangles =" << nTriangles << endl; + cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; + } return 0; } template<> -int MMG5_pMesh_to_ffmesh(const MMG5_pMesh& mesh, MeshS *&T_TH3) { - int ier; +int MMG5_pMesh_to_ffmesh< MeshS >(const MMG5_pMesh &mesh, MeshS *&T_TH3) { + int ier; - int nVertices = 0; - int nTriangles = 0; - int nEdges = 0; + int nVertices = 0; + int nTriangles = 0; + int nEdges = 0; - if ( MMGS_Get_meshSize(mesh,&nVertices,&nTriangles,&nEdges) !=1 ) { - ier = MMG5_STRONGFAILURE; - } + if (MMGS_Get_meshSize(mesh, &nVertices, &nTriangles, &nEdges) != 1) { + ier = MMG5_STRONGFAILURE; + } - Vertex3 *v = new Vertex3[nVertices]; - TriangleS *t = new TriangleS[nTriangles]; - TriangleS *tt = t; - BoundaryEdgeS *b = new BoundaryEdgeS[nEdges]; - BoundaryEdgeS *bb = b; - int k; + Vertex3 *v = new Vertex3[nVertices]; + TriangleS *t = new TriangleS[nTriangles]; + TriangleS *tt = t; + BoundaryEdgeS *b = new BoundaryEdgeS[nEdges]; + BoundaryEdgeS *bb = b; + int k; - int corner, required, ridge; + int corner, required, ridge; - for (k = 0; k < nVertices; k++) { - if ( MMGS_Get_vertex(mesh,&(v[k].x),&(v[k].y),&(v[k].z), - &(v[k].lab),&(corner),&(required)) != 1 ) { - cout << "Unable to get mesh vertex " << k << endl; - ier = MMG5_STRONGFAILURE; - } + for (k = 0; k < nVertices; k++) { + if (MMGS_Get_vertex(mesh, &(v[k].x), &(v[k].y), &(v[k].z), &(v[k].lab), &(corner), &(required)) != 1) { + cout << "Unable to get mesh vertex " << k << endl; + ier = MMG5_STRONGFAILURE; } + } - for ( k=0; kset(v, iv, lab); - } - - for ( k=0; kset(v, iv, lab); + for (k = 0; k < nTriangles; k++) { + int iv[3], lab; + if (MMGS_Get_triangle(mesh, &(iv[0]), &(iv[1]), &(iv[2]), &(lab), &(required)) != 1) { + cout << "Unable to get mesh triangle " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 3; i++) iv[i]--; + tt++->set(v, iv, lab); + } - T_TH3 = new MeshS(nVertices, nTriangles, nEdges, v, t, b, 1); - - if (verbosity > 1) { - cout << "transformation maillage --> meshS " << endl; - cout << "vertices =" << nVertices << endl; - cout << "triangles =" << nTriangles << endl; - cout << "edges =" << nEdges << endl; - cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; + for (k = 0; k < nEdges; k++) { + int iv[2], lab; + if (MMGS_Get_edge(mesh, &(iv[0]), &(iv[1]), &(lab), &(ridge), &(required)) != 1) { + cout << "Unable to get mesh edge " << k << endl; + ier = MMG5_STRONGFAILURE; } + for (int i = 0; i < 2; i++) iv[i]--; + bb++->set(v, iv, lab); + } + + T_TH3 = new MeshS(nVertices, nTriangles, nEdges, v, t, b, 1); + + if (verbosity > 1) { + cout << "transformation maillage --> meshS " << endl; + cout << "vertices =" << nVertices << endl; + cout << "triangles =" << nTriangles << endl; + cout << "edges =" << nEdges << endl; + cout << "T_TH3" << T_TH3->nv << " " << T_TH3->nt << " " << T_TH3->nbe << endl; + } return 0; } -template +template< class ffmesh > class mmg_Op : public E_F0mps { public: Expression eTh; - static const int n_name_param = std::is_same::value ? 30 : 24; + static const int n_name_param = std::is_same< ffmesh, Mesh3 >::value ? 30 : 24; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: mmg_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -373,87 +331,86 @@ class mmg_Op : public E_F0mps { } args.SetNameParam(n_name_param, name_param, nargs); - } AnyType operator( )(Stack stack) const; }; template<> -basicAC_F0::name_and_type mmg_Op::name_param[] = { -{"metric" , &typeid(KN< double > *)}, -{"verbose" , &typeid(long)},/*!< [-1..10], Tune level of verbosity */ -{"mem" , &typeid(long)},/*!< [n/-1], Set memory size to n Mbytes or keep the default value */ -{"debug" , &typeid(bool)},/*!< [1/0], Turn on/off debug mode */ -{"angle" , &typeid(bool)},/*!< [1/0], Turn on/off angle detection */ -{"iso" , &typeid(bool)},/*!< [1/0], Level-set meshing */ -{"nofem" , &typeid(bool)},/*!< [1/0], Generate a non finite element mesh */ -{"opnbdy" , &typeid(bool)},/*!< [1/0], Preserve triangles at interface of 2 domains with same reference */ -{"lag" , &typeid(long)},/*!< [-1/0/1/2], Lagrangian option */ -{"optim" , &typeid(bool)},/*!< [1/0], Optimize mesh keeping its initial edge sizes */ -{"optimLES" , &typeid(bool)},/*!< [1/0], Strong mesh optimization for Les computations */ -{"noinsert" , &typeid(bool)},/*!< [1/0], Avoid/allow point insertion */ -{"noswap" , &typeid(bool)},/*!< [1/0], Avoid/allow edge or face flipping */ -{"nomove" , &typeid(bool)},/*!< [1/0], Avoid/allow point relocation */ -{"nosurf" , &typeid(bool)},/*!< [1/0], Avoid/allow surface modifications */ -//{"nreg" , &typeid(bool)},/*!< [0/1], Enable normal regularization */ -{"renum" , &typeid(bool)},/*!< [1/0], Turn on/off point relocation with Scotch */ -{"anisosize" , &typeid(bool)},/*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ -{"nosizreq" , &typeid(bool)},/*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ -{"octree" , &typeid(long)},/*!< [n], Specify the max number of points per PROctree cell (DELAUNAY) */ -{"angleDetection" , &typeid(double)},/*!< [val], Value for angle detection */ -{"hmin" , &typeid(double)},/*!< [val], Minimal mesh size */ -{"hmax" , &typeid(double)},/*!< [val], Maximal mesh size */ -{"hsiz" , &typeid(double)},/*!< [val], Constant mesh size */ -{"hausd" , &typeid(double)},/*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ -{"hgrad" , &typeid(double)},/*!< [val], Control gradation */ -{"hgradreq" , &typeid(double)},/*!< [val], Control required gradation */ -{"ls" , &typeid(double)},/*!< [val], Value of level-set */ -//{"rmc" , &typeid(double)},/*!< [-1/val], Remove small connex componants in level-set mode */ -{"requiredTriangle" , &typeid(KN*)},/*!< [val], References of surfaces with required triangles */ -{"requiredVertex" , &typeid(KN*)},/*!< [val], Indices of required vertices */ -{"localParameter" , &typeid(KNM*)}/*!< [val], Local parameters on given surfaces */ +basicAC_F0::name_and_type mmg_Op< Mesh3 >::name_param[] = { + {"metric", &typeid(KN< double > *)}, + {"verbose", &typeid(long)}, /*!< [-1..10], Tune level of verbosity */ + {"mem", &typeid(long)}, /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + {"debug", &typeid(bool)}, /*!< [1/0], Turn on/off debug mode */ + {"angle", &typeid(bool)}, /*!< [1/0], Turn on/off angle detection */ + {"iso", &typeid(bool)}, /*!< [1/0], Level-set meshing */ + {"nofem", &typeid(bool)}, /*!< [1/0], Generate a non finite element mesh */ + {"opnbdy", &typeid(bool)}, /*!< [1/0], Preserve triangles at interface of 2 domains with same reference */ + {"lag", &typeid(long)}, /*!< [-1/0/1/2], Lagrangian option */ + {"optim", &typeid(bool)}, /*!< [1/0], Optimize mesh keeping its initial edge sizes */ + {"optimLES", &typeid(bool)}, /*!< [1/0], Strong mesh optimization for Les computations */ + {"noinsert", &typeid(bool)}, /*!< [1/0], Avoid/allow point insertion */ + {"noswap", &typeid(bool)}, /*!< [1/0], Avoid/allow edge or face flipping */ + {"nomove", &typeid(bool)}, /*!< [1/0], Avoid/allow point relocation */ + {"nosurf", &typeid(bool)}, /*!< [1/0], Avoid/allow surface modifications */ + //{"nreg" , &typeid(bool)},/*!< [0/1], Enable normal regularization */ + {"renum", &typeid(bool)}, /*!< [1/0], Turn on/off point relocation with Scotch */ + {"anisosize", &typeid(bool)}, /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ + {"nosizreq", &typeid(bool)}, /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ + {"octree", &typeid(long)}, /*!< [n], Specify the max number of points per PROctree cell (DELAUNAY) */ + {"angleDetection", &typeid(double)}, /*!< [val], Value for angle detection */ + {"hmin", &typeid(double)}, /*!< [val], Minimal mesh size */ + {"hmax", &typeid(double)}, /*!< [val], Maximal mesh size */ + {"hsiz", &typeid(double)}, /*!< [val], Constant mesh size */ + {"hausd", &typeid(double)}, /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + {"hgrad", &typeid(double)}, /*!< [val], Control gradation */ + {"hgradreq", &typeid(double)}, /*!< [val], Control required gradation */ + {"ls", &typeid(double)}, /*!< [val], Value of level-set */ + //{"rmc" , &typeid(double)},/*!< [-1/val], Remove small connex componants in level-set mode */ + {"requiredTriangle", &typeid(KN< long > *)}, /*!< [val], References of surfaces with required triangles */ + {"requiredVertex", &typeid(KN< long > *)}, /*!< [val], Indices of required vertices */ + {"localParameter", &typeid(KNM< double > *)} /*!< [val], Local parameters on given surfaces */ }; -template -basicAC_F0::name_and_type mmg_Op::name_param[] = { -{"metric" , &typeid(KN< double > *)}, -{"verbose" , &typeid(long)},/*!< [-1..10], Tune level of verbosity */ -{"mem" , &typeid(long)},/*!< [n/-1], Set memory size to n Mbytes or keep the default value */ -{"debug" , &typeid(bool)},/*!< [1/0], Turn on/off debug mode */ -{"angle" , &typeid(bool)},/*!< [1/0], Turn on/off angle detection */ -{"iso" , &typeid(bool)},/*!< [1/0], Level-set meshing */ -{"keepRef" , &typeid(bool)},/*!< [1/0], Preserve the initial domain references in level-set mode */ -{"localParameter" , &typeid(KNM*)},/*!< [val], Local parameters on given surfaces */ -{"noinsert" , &typeid(bool)},/*!< [1/0], Avoid/allow point insertion */ -{"noswap" , &typeid(bool)},/*!< [1/0], Avoid/allow edge or face flipping */ -{"nomove" , &typeid(bool)},/*!< [1/0], Avoid/allow point relocation */ -{"nreg" , &typeid(bool)},/*!< [0/1], Disabled/enabled normal regularization */ -{"renum" , &typeid(bool)},/*!< [1/0], Turn on/off point relocation with Scotch */ -{"nosizreq" , &typeid(bool)},/*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ -{"angleDetection" , &typeid(double)},/*!< [val], Value for angle detection */ -{"hmin" , &typeid(double)},/*!< [val], Minimal mesh size */ -{"hmax" , &typeid(double)},/*!< [val], Maximal mesh size */ -{"hsiz" , &typeid(double)},/*!< [val], Constant mesh size */ -{"hausd" , &typeid(double)},/*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ -{"hgrad" , &typeid(double)},/*!< [val], Control gradation */ -{"hgradreq" , &typeid(double)},/*!< [val], Control required gradation */ -{"ls" , &typeid(double)},/*!< [val], Value of level-set */ -{"requiredEdge" , &typeid(KN*)},/*!< [val], References of boundaries with required edges */ -{"requiredVertex" , &typeid(KN*)}/*!< [val], Indices of required vertices */ +template< class Mesh > +basicAC_F0::name_and_type mmg_Op< Mesh >::name_param[] = { + {"metric", &typeid(KN< double > *)}, + {"verbose", &typeid(long)}, /*!< [-1..10], Tune level of verbosity */ + {"mem", &typeid(long)}, /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + {"debug", &typeid(bool)}, /*!< [1/0], Turn on/off debug mode */ + {"angle", &typeid(bool)}, /*!< [1/0], Turn on/off angle detection */ + {"iso", &typeid(bool)}, /*!< [1/0], Level-set meshing */ + {"keepRef", &typeid(bool)}, /*!< [1/0], Preserve the initial domain references in level-set mode */ + {"localParameter", &typeid(KNM< double > *)}, /*!< [val], Local parameters on given surfaces */ + {"noinsert", &typeid(bool)}, /*!< [1/0], Avoid/allow point insertion */ + {"noswap", &typeid(bool)}, /*!< [1/0], Avoid/allow edge or face flipping */ + {"nomove", &typeid(bool)}, /*!< [1/0], Avoid/allow point relocation */ + {"nreg", &typeid(bool)}, /*!< [0/1], Disabled/enabled normal regularization */ + {"renum", &typeid(bool)}, /*!< [1/0], Turn on/off point relocation with Scotch */ + {"nosizreq", &typeid(bool)}, /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ + {"angleDetection", &typeid(double)}, /*!< [val], Value for angle detection */ + {"hmin", &typeid(double)}, /*!< [val], Minimal mesh size */ + {"hmax", &typeid(double)}, /*!< [val], Maximal mesh size */ + {"hsiz", &typeid(double)}, /*!< [val], Constant mesh size */ + {"hausd", &typeid(double)}, /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + {"hgrad", &typeid(double)}, /*!< [val], Control gradation */ + {"hgradreq", &typeid(double)}, /*!< [val], Control required gradation */ + {"ls", &typeid(double)}, /*!< [val], Value of level-set */ + {"requiredEdge", &typeid(KN< long > *)}, /*!< [val], References of boundaries with required edges */ + {"requiredVertex", &typeid(KN< long > *)} /*!< [val], Indices of required vertices */ }; -template +template< class ffmesh > class mmg_ff : public OneOperator { public: - mmg_ff( ) : OneOperator(atype< const ffmesh* >( ), atype< const ffmesh* >( )) {pref=10;} - // to remove ambiguity with mmg3-v4 + mmg_ff( ) : OneOperator(atype< const ffmesh * >( ), atype< const ffmesh * >( )) { pref = 10; } + // to remove ambiguity with mmg3-v4 - E_F0 *code(const basicAC_F0 &args) const { return new mmg_Op(args, t[0]->CastTo(args[0])); } + E_F0 *code(const basicAC_F0 &args) const { return new mmg_Op< ffmesh >(args, t[0]->CastTo(args[0])); } }; template<> -AnyType mmg_Op::operator( )(Stack stack) const { +AnyType mmg_Op< Mesh >::operator( )(Stack stack) const { // initialisation MeshPoint *mp(MeshPointStack(stack)), mps = *mp; Mesh *pTh = GetAny< Mesh * >((*eTh)(stack)); @@ -488,118 +445,132 @@ AnyType mmg_Op::operator( )(Stack stack) const { mesh = nullptr; sol = nullptr; - MMG2D_Init_mesh(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMG2D_Init_mesh(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); ffmesh_to_MMG5_pMesh(Th, mesh); - if (pmetric && pmetric->N( ) > 0) { - const KN< double > &metric = *pmetric; - if (metric.N( ) == Th.nv) { - if ( MMG2D_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Scalar) != 1 ) { - printf("Unable to allocate the metric array.\n"); - exit(EXIT_FAILURE); - } - if ( MMG2D_Set_scalarSols(sol,metric) != 1 ) { - printf("Unable to set metric.\n"); - exit(EXIT_FAILURE); - } + if (pmetric && pmetric->N( ) > 0) { + const KN< double > &metric = *pmetric; + if (metric.N( ) == Th.nv) { + if (MMG2D_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Scalar) != 1) { + printf("Unable to allocate the metric array.\n"); + exit(EXIT_FAILURE); } - else { - if ( MMG2D_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Tensor) != 1 ) { - printf("Unable to allocate the metric array.\n"); - exit(EXIT_FAILURE); - } - static const int perm[3] = {0, 1, 2}; - for (int k=0; kN( ) > 0) { - const KN< long > &requiredEdge = *prequiredEdge; - std::sort(requiredEdge + 0, requiredEdge + requiredEdge.N()); - int na; - if ( MMG2D_Get_meshSize(mesh,NULL,NULL,NULL,&na) !=1 ) { + } else { + if (MMG2D_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Tensor) != 1) { + printf("Unable to allocate the metric array.\n"); exit(EXIT_FAILURE); } - for (int k=1; k<=na; k++) { - int ref, dummy; - if ( MMG2D_Get_edge(mesh, &dummy, &dummy, &ref, - &dummy, &dummy) != 1 ) { + static const int perm[3] = {0, 1, 2}; + for (int k = 0; k < Th.nv; k++) { + if (MMG2D_Set_tensorSol(sol, metric[3 * k + perm[0]], metric[3 * k + perm[1]], metric[3 * k + perm[2]], k + 1) != 1) { + printf("Unable to set metric.\n"); exit(EXIT_FAILURE); } - if (std::binary_search(requiredEdge + 0, requiredEdge + requiredEdge.N(), ref)) { - if ( MMG2D_Set_requiredEdge(mesh,k) != 1 ) { - exit(EXIT_FAILURE); - } - } } } - if (prequiredVertex && prequiredVertex->N( ) > 0) { - const KN< long > &requiredVertex = *prequiredVertex; - for (int k=0; kN( ) > 0) { + const KN< long > &requiredEdge = *prequiredEdge; + std::sort(requiredEdge + 0, requiredEdge + requiredEdge.N( )); + int na; + if (MMG2D_Get_meshSize(mesh, NULL, NULL, NULL, &na) != 1) { + exit(EXIT_FAILURE); + } + for (int k = 1; k <= na; k++) { + int ref, dummy; + if (MMG2D_Get_edge(mesh, &dummy, &dummy, &ref, &dummy, &dummy) != 1) { + exit(EXIT_FAILURE); + } + if (std::binary_search(requiredEdge + 0, requiredEdge + requiredEdge.N( ), ref)) { + if (MMG2D_Set_requiredEdge(mesh, k) != 1) { exit(EXIT_FAILURE); } } } - if (plocalParameter && plocalParameter->M( ) > 0) { - const KNM< double > &localParameter = *plocalParameter; - ffassert(localParameter.N() == 4); - if ( MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_numberOfLocalParam,localParameter.M()) != 1 ) { + } + if (prequiredVertex && prequiredVertex->N( ) > 0) { + const KN< long > &requiredVertex = *prequiredVertex; + for (int k = 0; k < requiredVertex.N( ); k++) { + if (MMG2D_Set_requiredVertex(mesh, requiredVertex[k] + 1) != 1) { exit(EXIT_FAILURE); } - for(int j = 0; j < localParameter.M(); ++j) { - if ( MMG2D_Set_localParameter(mesh,sol,MMG5_Edg,localParameter(0,j),localParameter(1,j),localParameter(2,j),localParameter(3,j)) != 1 ) { - exit(EXIT_FAILURE); - } + } + } + if (plocalParameter && plocalParameter->M( ) > 0) { + const KNM< double > &localParameter = *plocalParameter; + ffassert(localParameter.N( ) == 4); + if (MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_numberOfLocalParam, localParameter.M( )) != 1) { + exit(EXIT_FAILURE); + } + for (int j = 0; j < localParameter.M( ); ++j) { + if (MMG2D_Set_localParameter(mesh, sol, MMG5_Edg, localParameter(0, j), localParameter(1, j), localParameter(2, j), localParameter(3, j)) != 1) { + exit(EXIT_FAILURE); } } + } - long iso=0L; - - int i=1; - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_verbose, arg(i,stack,0L)); i++; /*!< [-1..10], Tune level of verbosity */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_mem, arg(i,stack,0L)); i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_debug, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off debug mode */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_angle, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off angle detection */ - if (nargs[i]) {iso = arg(i,stack,false); MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_iso,iso);} i++; /*!< [1/0], Level-set meshing */ - i++; /*!< [1/0], Preserve the initial domain references in level-set mode */ - i++; /*!< [val], Local parameters on given surfaces */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_noinsert, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point insertion */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_noswap, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow edge or face flipping */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_nomove, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point relocation */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_nreg, arg(i,stack,false)); i++; /*!< [0/1], Disabled/enabled normal regularization */ - i++; /*!< [1/0], Turn on/off point relocation with Scotch */ - if (nargs[i]) MMG2D_Set_iparameter(mesh,sol,MMG2D_IPARAM_nosizreq, arg(i,stack,false)); i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_angleDetection,arg(i,stack,0.)); i++; /*!< [val], Value for angle detection */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hmin, arg(i,stack,0.)); i++; /*!< [val], Minimal mesh size */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hmax, arg(i,stack,0.)); i++; /*!< [val], Maximal mesh size */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hsiz, arg(i,stack,0.)); i++; /*!< [val], Constant mesh size */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hausd, arg(i,stack,0.)); i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hgrad, arg(i,stack,0.)); i++; /*!< [val], Control gradation */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_hgradreq, arg(i,stack,0.)); i++; /*!< [val], Control required gradation */ - if (nargs[i]) MMG2D_Set_dparameter(mesh,sol,MMG2D_DPARAM_ls, arg(i,stack,0.)); i++; /*!< [val], Value of level-set */ + long iso = 0L; + + int i = 1; + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_verbose, arg(i, stack, 0L)); + i++; /*!< [-1..10], Tune level of verbosity */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_mem, arg(i, stack, 0L)); + i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_debug, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off debug mode */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_angle, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off angle detection */ + if (nargs[i]) { + iso = arg(i, stack, false); + MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_iso, iso); + } + i++; /*!< [1/0], Level-set meshing */ + i++; /*!< [1/0], Preserve the initial domain references in level-set mode */ + i++; /*!< [val], Local parameters on given surfaces */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_noinsert, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point insertion */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_noswap, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow edge or face flipping */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_nomove, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point relocation */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_nreg, arg(i, stack, false)); + i++; /*!< [0/1], Disabled/enabled normal regularization */ + i++; /*!< [1/0], Turn on/off point relocation with Scotch */ + if (nargs[i]) MMG2D_Set_iparameter(mesh, sol, MMG2D_IPARAM_nosizreq, arg(i, stack, false)); + i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_angleDetection, arg(i, stack, 0.)); + i++; /*!< [val], Value for angle detection */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hmin, arg(i, stack, 0.)); + i++; /*!< [val], Minimal mesh size */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hmax, arg(i, stack, 0.)); + i++; /*!< [val], Maximal mesh size */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hsiz, arg(i, stack, 0.)); + i++; /*!< [val], Constant mesh size */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hausd, arg(i, stack, 0.)); + i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hgrad, arg(i, stack, 0.)); + i++; /*!< [val], Control gradation */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_hgradreq, arg(i, stack, 0.)); + i++; /*!< [val], Control required gradation */ + if (nargs[i]) MMG2D_Set_dparameter(mesh, sol, MMG2D_DPARAM_ls, arg(i, stack, 0.)); + i++; /*!< [val], Value of level-set */ int ier; if (!iso) - ier = MMG2D_mmg2dlib(mesh,sol); + ier = MMG2D_mmg2dlib(mesh, sol); else - ier = MMG2D_mmg2dls(mesh,sol,NULL); + ier = MMG2D_mmg2dls(mesh, sol, NULL); Mesh *Th_T = nullptr; - MMG5_pMesh_to_ffmesh(mesh,Th_T); + MMG5_pMesh_to_ffmesh(mesh, Th_T); - MMG2D_Free_all(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMG2D_Free_all(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); R2 Pn, Px; Th_T->BoundingBox(Pn, Px); @@ -610,7 +581,7 @@ AnyType mmg_Op::operator( )(Stack stack) const { } template<> -AnyType mmg_Op::operator( )(Stack stack) const { +AnyType mmg_Op< Mesh3 >::operator( )(Stack stack) const { // initialisation MeshPoint *mp(MeshPointStack(stack)), mps = *mp; Mesh3 *pTh = GetAny< Mesh3 * >((*eTh)(stack)); @@ -647,134 +618,154 @@ AnyType mmg_Op::operator( )(Stack stack) const { sol = nullptr; met = nullptr; - MMG3D_Init_mesh(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMG3D_Init_mesh(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); ffmesh_to_MMG5_pMesh(Th, mesh); - if (pmetric && pmetric->N( ) > 0) { - const KN< double > &metric = *pmetric; - if (metric.N( ) == Th.nv) { - if ( MMG3D_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Scalar) != 1 ) { - printf("Unable to allocate the metric array.\n"); - exit(EXIT_FAILURE); - } - if ( MMG3D_Set_scalarSols(sol,metric) != 1 ) { - printf("Unable to set metric.\n"); - exit(EXIT_FAILURE); - } + if (pmetric && pmetric->N( ) > 0) { + const KN< double > &metric = *pmetric; + if (metric.N( ) == Th.nv) { + if (MMG3D_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Scalar) != 1) { + printf("Unable to allocate the metric array.\n"); + exit(EXIT_FAILURE); } - else { - if ( MMG3D_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Tensor) != 1 ) { - printf("Unable to allocate the metric array.\n"); - exit(EXIT_FAILURE); - } - static const int perm[6] = {0, 1, 3, 2, 4, 5}; - for (int k=0; kN( ) > 0) { - const KN< long > &requiredTriangle = *prequiredTriangle; - std::sort(requiredTriangle + 0, requiredTriangle + requiredTriangle.N()); - int nt; - if ( MMG3D_Get_meshSize(mesh,NULL,NULL,NULL,&nt,NULL,NULL) !=1 ) { + } else { + if (MMG3D_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Tensor) != 1) { + printf("Unable to allocate the metric array.\n"); exit(EXIT_FAILURE); } - for (int k=1; k<=nt; k++) { - int ref, dummy; - if ( MMG3D_Get_triangle(mesh,&dummy,&dummy,&dummy, - &ref,NULL) != 1 ) { + static const int perm[6] = {0, 1, 3, 2, 4, 5}; + for (int k = 0; k < Th.nv; k++) { + if (MMG3D_Set_tensorSol(sol, metric[6 * k + perm[0]], metric[6 * k + perm[1]], metric[6 * k + perm[2]], metric[6 * k + perm[3]], metric[6 * k + perm[4]], metric[6 * k + perm[5]], k + 1) != + 1) { + printf("Unable to set metric.\n"); exit(EXIT_FAILURE); } - if (std::binary_search(requiredTriangle + 0, requiredTriangle + requiredTriangle.N(), ref)) { - if ( MMG3D_Set_requiredTriangle(mesh,k) != 1 ) { - exit(EXIT_FAILURE); - } - } } } - if (prequiredVertex && prequiredVertex->N( ) > 0) { - const KN< long > &requiredVertex = *prequiredVertex; - for (int k=0; kN( ) > 0) { + const KN< long > &requiredTriangle = *prequiredTriangle; + std::sort(requiredTriangle + 0, requiredTriangle + requiredTriangle.N( )); + int nt; + if (MMG3D_Get_meshSize(mesh, NULL, NULL, NULL, &nt, NULL, NULL) != 1) { + exit(EXIT_FAILURE); + } + for (int k = 1; k <= nt; k++) { + int ref, dummy; + if (MMG3D_Get_triangle(mesh, &dummy, &dummy, &dummy, &ref, NULL) != 1) { + exit(EXIT_FAILURE); + } + if (std::binary_search(requiredTriangle + 0, requiredTriangle + requiredTriangle.N( ), ref)) { + if (MMG3D_Set_requiredTriangle(mesh, k) != 1) { exit(EXIT_FAILURE); } } } - if (plocalParameter && plocalParameter->M( ) > 0) { - const KNM< double > &localParameter = *plocalParameter; - ffassert(localParameter.N() == 4); - if ( MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_numberOfLocalParam,localParameter.M()) != 1 ) { + } + if (prequiredVertex && prequiredVertex->N( ) > 0) { + const KN< long > &requiredVertex = *prequiredVertex; + for (int k = 0; k < requiredVertex.N( ); k++) { + if (MMG3D_Set_requiredVertex(mesh, requiredVertex[k] + 1) != 1) { exit(EXIT_FAILURE); } - for(int j = 0; j < localParameter.M(); ++j) { - if ( MMG3D_Set_localParameter(mesh,sol,MMG5_Triangle,localParameter(0,j),localParameter(1,j),localParameter(2,j),localParameter(3,j)) != 1 ) { - exit(EXIT_FAILURE); - } + } + } + if (plocalParameter && plocalParameter->M( ) > 0) { + const KNM< double > &localParameter = *plocalParameter; + ffassert(localParameter.N( ) == 4); + if (MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_numberOfLocalParam, localParameter.M( )) != 1) { + exit(EXIT_FAILURE); + } + for (int j = 0; j < localParameter.M( ); ++j) { + if (MMG3D_Set_localParameter(mesh, sol, MMG5_Triangle, localParameter(0, j), localParameter(1, j), localParameter(2, j), localParameter(3, j)) != 1) { + exit(EXIT_FAILURE); } } + } - int i=1; - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_verbose, arg(i,stack,0L)); i++; /*!< [-1..10], Tune level of verbosity */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_mem, arg(i,stack,0L)); i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_debug, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off debug mode */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_angle, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off angle detection */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_iso, arg(i,stack,false)); i++; /*!< [1/0], Level-set meshing */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nofem, arg(i,stack,false)); i++; /*!< [1/0], Generate a non finite element mesh */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_opnbdy, arg(i,stack,false)); i++; /*!< [1/0], Preserve triangles at interface of 2 domains with same reference */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_lag, arg(i,stack,0L)); i++; /*!< [-1/0/1/2], Lagrangian option */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_optim, arg(i,stack,false)); i++; /*!< [1/0], Optimize mesh keeping its initial edge sizes */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_optimLES, arg(i,stack,false)); i++; /*!< [1/0], Strong mesh optimization for Les computations */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_noinsert, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point insertion */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_noswap, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow edge or face flipping */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nomove, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point relocation */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nosurf, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow surface modifications */ - //if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nreg, arg(i,stack,false)); i++; /*!< [0/1], Enable normal regularization */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_renum, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off point relocation with Scotch */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_anisosize, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nosizreq, arg(i,stack,false)); i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ - if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_octree, arg(i,stack,0L)); i++; /*!< [n], Specify the max number of points per PROctree cell (DELAUNAY) */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_angleDetection,arg(i,stack,0.)); i++; /*!< [val], Value for angle detection */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hmin, arg(i,stack,0.)); i++; /*!< [val], Minimal mesh size */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hmax, arg(i,stack,0.)); i++; /*!< [val], Maximal mesh size */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hsiz, arg(i,stack,0.)); i++; /*!< [val], Constant mesh size */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hausd, arg(i,stack,0.)); i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hgrad, arg(i,stack,0.)); i++; /*!< [val], Control gradation */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_hgradreq, arg(i,stack,0.)); i++; /*!< [val], Control required gradation */ - if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_ls, arg(i,stack,0.)); i++; /*!< [val], Value of level-set */ - //if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_rmc, arg(i,stack,0.)); i++; /*!< [-1/val], Remove small connex componants in level-set mode */ - - bool bls = MMG3D_Get_iparameter(mesh,MMG3D_IPARAM_iso); + int i = 1; + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_verbose, arg(i, stack, 0L)); + i++; /*!< [-1..10], Tune level of verbosity */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_mem, arg(i, stack, 0L)); + i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_debug, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off debug mode */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_angle, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off angle detection */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_iso, arg(i, stack, false)); + i++; /*!< [1/0], Level-set meshing */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_nofem, arg(i, stack, false)); + i++; /*!< [1/0], Generate a non finite element mesh */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_opnbdy, arg(i, stack, false)); + i++; /*!< [1/0], Preserve triangles at interface of 2 domains with same reference */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_lag, arg(i, stack, 0L)); + i++; /*!< [-1/0/1/2], Lagrangian option */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_optim, arg(i, stack, false)); + i++; /*!< [1/0], Optimize mesh keeping its initial edge sizes */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_optimLES, arg(i, stack, false)); + i++; /*!< [1/0], Strong mesh optimization for Les computations */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_noinsert, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point insertion */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_noswap, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow edge or face flipping */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_nomove, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point relocation */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_nosurf, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow surface modifications */ + // if (nargs[i]) MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_nreg, arg(i,stack,false)); i++; /*!< [0/1], Enable normal regularization */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_renum, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off point relocation with Scotch */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_anisosize, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off anisotropic metric creation when no metric is provided */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_nosizreq, arg(i, stack, false)); + i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ + if (nargs[i]) MMG3D_Set_iparameter(mesh, sol, MMG3D_IPARAM_octree, arg(i, stack, 0L)); + i++; /*!< [n], Specify the max number of points per PROctree cell (DELAUNAY) */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_angleDetection, arg(i, stack, 0.)); + i++; /*!< [val], Value for angle detection */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hmin, arg(i, stack, 0.)); + i++; /*!< [val], Minimal mesh size */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hmax, arg(i, stack, 0.)); + i++; /*!< [val], Maximal mesh size */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hsiz, arg(i, stack, 0.)); + i++; /*!< [val], Constant mesh size */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hausd, arg(i, stack, 0.)); + i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hgrad, arg(i, stack, 0.)); + i++; /*!< [val], Control gradation */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_hgradreq, arg(i, stack, 0.)); + i++; /*!< [val], Control required gradation */ + if (nargs[i]) MMG3D_Set_dparameter(mesh, sol, MMG3D_DPARAM_ls, arg(i, stack, 0.)); + i++; /*!< [val], Value of level-set */ + // if (nargs[i]) MMG3D_Set_dparameter(mesh,sol,MMG3D_DPARAM_rmc, arg(i,stack,0.)); i++; /*!< [-1/val], Remove small connex componants in level-set mode */ + + bool bls = MMG3D_Get_iparameter(mesh, MMG3D_IPARAM_iso); int ier; if (!bls) - ier = MMG3D_mmg3dlib(mesh,sol); + ier = MMG3D_mmg3dlib(mesh, sol); else - ier = MMG3D_mmg3dls(mesh,sol,met); + ier = MMG3D_mmg3dls(mesh, sol, met); Mesh3 *Th_T = nullptr; - MMG5_pMesh_to_ffmesh(mesh,Th_T); + MMG5_pMesh_to_ffmesh(mesh, Th_T); - MMG3D_Free_all(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMG3D_Free_all(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); - Th_T->BuildGTree(); + Th_T->BuildGTree( ); Add2StackOfPtr2FreeRC(stack, Th_T); return Th_T; } template<> -AnyType mmg_Op::operator( )(Stack stack) const { +AnyType mmg_Op< MeshS >::operator( )(Stack stack) const { // initialisation MeshPoint *mp(MeshPointStack(stack)), mps = *mp; MeshS *pTh = GetAny< MeshS * >((*eTh)(stack)); @@ -805,108 +796,124 @@ AnyType mmg_Op::operator( )(Stack stack) const { mesh = nullptr; sol = nullptr; - MMGS_Init_mesh(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMGS_Init_mesh(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); ffmesh_to_MMG5_pMesh(Th, mesh); - if (pmetric && pmetric->N( ) > 0) { - const KN< double > &metric = *pmetric; - if (metric.N( ) == Th.nv) { - if ( MMGS_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Scalar) != 1 ) { - printf("Unable to allocate the metric array.\n"); - exit(EXIT_FAILURE); - } - if ( MMGS_Set_scalarSols(sol,metric) != 1 ) { - printf("Unable to set metric.\n"); - exit(EXIT_FAILURE); - } + if (pmetric && pmetric->N( ) > 0) { + const KN< double > &metric = *pmetric; + if (metric.N( ) == Th.nv) { + if (MMGS_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Scalar) != 1) { + printf("Unable to allocate the metric array.\n"); + exit(EXIT_FAILURE); } - else { - if ( MMGS_Set_solSize(mesh,sol,MMG5_Vertex,Th.nv,MMG5_Tensor) != 1 ) { - printf("Unable to allocate the metric array.\n"); + if (MMGS_Set_scalarSols(sol, metric) != 1) { + printf("Unable to set metric.\n"); + exit(EXIT_FAILURE); + } + } else { + if (MMGS_Set_solSize(mesh, sol, MMG5_Vertex, Th.nv, MMG5_Tensor) != 1) { + printf("Unable to allocate the metric array.\n"); + exit(EXIT_FAILURE); + } + static const int perm[6] = {0, 1, 3, 2, 4, 5}; + for (int k = 0; k < Th.nv; k++) { + if (MMGS_Set_tensorSol(sol, metric[6 * k + perm[0]], metric[6 * k + perm[1]], metric[6 * k + perm[2]], metric[6 * k + perm[3]], metric[6 * k + perm[4]], metric[6 * k + perm[5]], k + 1) != 1) { + printf("Unable to set metric.\n"); exit(EXIT_FAILURE); } - static const int perm[6] = {0, 1, 3, 2, 4, 5}; - for (int k=0; kN( ) > 0) { - const KN< long > &requiredEdge = *prequiredEdge; - std::sort(requiredEdge + 0, requiredEdge + requiredEdge.N()); - int na; - if ( MMGS_Get_meshSize(mesh,NULL,NULL,&na) !=1 ) { + } + if (prequiredEdge && prequiredEdge->N( ) > 0) { + const KN< long > &requiredEdge = *prequiredEdge; + std::sort(requiredEdge + 0, requiredEdge + requiredEdge.N( )); + int na; + if (MMGS_Get_meshSize(mesh, NULL, NULL, &na) != 1) { + exit(EXIT_FAILURE); + } + for (int k = 1; k <= na; k++) { + int ref, dummy; + if (MMGS_Get_edge(mesh, &dummy, &dummy, &ref, &dummy, &dummy) != 1) { exit(EXIT_FAILURE); } - for (int k=1; k<=na; k++) { - int ref, dummy; - if ( MMGS_Get_edge(mesh, &dummy, &dummy, &ref, - &dummy, &dummy) != 1 ) { + if (std::binary_search(requiredEdge + 0, requiredEdge + requiredEdge.N( ), ref)) { + if (MMGS_Set_requiredEdge(mesh, k) != 1) { exit(EXIT_FAILURE); } - if (std::binary_search(requiredEdge + 0, requiredEdge + requiredEdge.N(), ref)) { - if ( MMGS_Set_requiredEdge(mesh,k) != 1 ) { - exit(EXIT_FAILURE); - } - } } } - if (prequiredVertex && prequiredVertex->N( ) > 0) { - const KN< long > &requiredVertex = *prequiredVertex; - for (int k=0; kN( ) > 0) { + const KN< long > &requiredVertex = *prequiredVertex; + for (int k = 0; k < requiredVertex.N( ); k++) { + if (MMGS_Set_requiredVertex(mesh, requiredVertex[k] + 1) != 1) { + exit(EXIT_FAILURE); } } + } - long iso=0L; - - int i=1; - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_verbose, arg(i,stack,0L)); i++; /*!< [-1..10], Tune level of verbosity */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_mem, arg(i,stack,0L)); i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_debug, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off debug mode */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_angle, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off angle detection */ - if (nargs[i]) {iso = arg(i,stack,false); MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_iso,iso);} i++; /*!< [1/0], Level-set meshing */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_keepRef, arg(i,stack,false)); i++; /*!< [1/0], Preserve the initial domain references in level-set mode */ - i++; /*!< [val], Local parameters on given surfaces */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_noinsert, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point insertion */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_noswap, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow edge or face flipping */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_nomove, arg(i,stack,false)); i++; /*!< [1/0], Avoid/allow point relocation */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_nreg, arg(i,stack,false)); i++; /*!< [0/1], Disabled/enabled normal regularization */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_renum, arg(i,stack,false)); i++; /*!< [1/0], Turn on/off point relocation with Scotch */ - if (nargs[i]) MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_nosizreq, arg(i,stack,false)); i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_angleDetection,arg(i,stack,0.)); i++; /*!< [val], Value for angle detection */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hmin, arg(i,stack,0.)); i++; /*!< [val], Minimal mesh size */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hmax, arg(i,stack,0.)); i++; /*!< [val], Maximal mesh size */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hsiz, arg(i,stack,0.)); i++; /*!< [val], Constant mesh size */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hausd, arg(i,stack,0.)); i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hgrad, arg(i,stack,0.)); i++; /*!< [val], Control gradation */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_hgradreq, arg(i,stack,0.)); i++; /*!< [val], Control required gradation */ - if (nargs[i]) MMGS_Set_dparameter(mesh,sol,MMGS_DPARAM_ls, arg(i,stack,0.)); i++; /*!< [val], Value of level-set */ + long iso = 0L; + + int i = 1; + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_verbose, arg(i, stack, 0L)); + i++; /*!< [-1..10], Tune level of verbosity */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_mem, arg(i, stack, 0L)); + i++; /*!< [n/-1], Set memory size to n Mbytes or keep the default value */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_debug, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off debug mode */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_angle, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off angle detection */ + if (nargs[i]) { + iso = arg(i, stack, false); + MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_iso, iso); + } + i++; /*!< [1/0], Level-set meshing */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_keepRef, arg(i, stack, false)); + i++; /*!< [1/0], Preserve the initial domain references in level-set mode */ + i++; /*!< [val], Local parameters on given surfaces */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_noinsert, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point insertion */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_noswap, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow edge or face flipping */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_nomove, arg(i, stack, false)); + i++; /*!< [1/0], Avoid/allow point relocation */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_nreg, arg(i, stack, false)); + i++; /*!< [0/1], Disabled/enabled normal regularization */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_renum, arg(i, stack, false)); + i++; /*!< [1/0], Turn on/off point relocation with Scotch */ + if (nargs[i]) MMGS_Set_iparameter(mesh, sol, MMGS_IPARAM_nosizreq, arg(i, stack, false)); + i++; /*!< [0/1], Allow/avoid overwritten of sizes at required points (advanced usage) */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_angleDetection, arg(i, stack, 0.)); + i++; /*!< [val], Value for angle detection */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hmin, arg(i, stack, 0.)); + i++; /*!< [val], Minimal mesh size */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hmax, arg(i, stack, 0.)); + i++; /*!< [val], Maximal mesh size */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hsiz, arg(i, stack, 0.)); + i++; /*!< [val], Constant mesh size */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hausd, arg(i, stack, 0.)); + i++; /*!< [val], Control global Hausdorff distance (on all the boundary surfaces of the mesh) */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hgrad, arg(i, stack, 0.)); + i++; /*!< [val], Control gradation */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_hgradreq, arg(i, stack, 0.)); + i++; /*!< [val], Control required gradation */ + if (nargs[i]) MMGS_Set_dparameter(mesh, sol, MMGS_DPARAM_ls, arg(i, stack, 0.)); + i++; /*!< [val], Value of level-set */ int ier; if (!iso) - ier = MMGS_mmgslib(mesh,sol); + ier = MMGS_mmgslib(mesh, sol); else - ier = MMGS_mmgsls(mesh,sol,NULL); + ier = MMGS_mmgsls(mesh, sol, NULL); MeshS *Th_T = nullptr; - MMG5_pMesh_to_ffmesh(mesh,Th_T); + MMG5_pMesh_to_ffmesh(mesh, Th_T); - MMGS_Free_all(MMG5_ARG_start, - MMG5_ARG_ppMesh,&mesh,MMG5_ARG_ppMet,&sol, - MMG5_ARG_end); + MMGS_Free_all(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh, MMG5_ARG_ppMet, &sol, MMG5_ARG_end); - Th_T->BuildGTree(); + Th_T->BuildGTree( ); Add2StackOfPtr2FreeRC(stack, Th_T); return Th_T; @@ -917,9 +924,9 @@ static void Load_Init( ) { cout << " load: mmg " << endl; } - Global.Add("mmg3d", "(", new mmg_ff); - Global.Add("mmg2d", "(", new mmg_ff); - Global.Add("mmgs", "(", new mmg_ff); + Global.Add("mmg3d", "(", new mmg_ff< Mesh3 >); + Global.Add("mmg2d", "(", new mmg_ff< Mesh >); + Global.Add("mmgs", "(", new mmg_ff< MeshS >); } LOADFUNC(Load_Init) diff --git a/plugin/seq/mmg3d-v4.0.cpp b/plugin/seq/mmg3d-v4.0.cpp index fa320eeb0..8163e9470 100644 --- a/plugin/seq/mmg3d-v4.0.cpp +++ b/plugin/seq/mmg3d-v4.0.cpp @@ -102,8 +102,7 @@ void end_mesh(void *dataff) { // end add if (verbosity > 1) { - cout << " -- End of Construct mesh3: mesure = " << Th.mes << " border mesure " << Th.mesb - << endl; + cout << " -- End of Construct mesh3: mesure = " << Th.mes << " border mesure " << Th.mesb << endl; } ffassert(Th.mes >= 0); // add F. Hecht sep 2009. @@ -119,8 +118,7 @@ void set_v(void *dataff, int i, double *xyz, int lab) { Th.vertices[i].z = xyz[2]; Th.vertices[i].lab = lab; if (verbosity > 10) { - cout << " set_v3 " << i << " " << xyz[0] << " " << xyz[1] << " " << xyz[02] << " " << lab - << endl; + cout << " set_v3 " << i << " " << xyz[0] << " " << xyz[1] << " " << xyz[02] << " " << lab << endl; } } @@ -185,8 +183,7 @@ void get_v3(void *dataff, int i, double *xyz, int *lab) { xyz[2] = Th.vertices[i].z; *lab = Th.vertices[i].lab; if (verbosity > 10) { - cout << " get_v3 " << i << " " << xyz[0] << " " << xyz[1] << " " << xyz[2] << " " << *lab - << endl; + cout << " get_v3 " << i << " " << xyz[0] << " " << xyz[1] << " " << xyz[2] << " " << *lab << endl; } } @@ -238,21 +235,13 @@ class mmg3d_Op : public E_F0mps { static const int n_name_param = 5; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > karg(int i, Stack stack) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : KN_< long >((long *)0, 0L); - } + KN_< long > karg(int i, Stack stack) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : KN_< long >((long *)0, 0L); } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - string arg(int i, Stack stack, const char *a) const { - return nargs[i] ? *GetAny< string * >((*nargs[i])(stack)) : a; - } + string arg(int i, Stack stack, const char *a) const { return nargs[i] ? *GetAny< string * >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: mmg3d_Op(const basicAC_F0 &args, Expression tth) : eTh(tth), xx(0), yy(0), zz(0) { diff --git a/plugin/seq/msh3.cpp b/plugin/seq/msh3.cpp index f2656a709..e86fa13bf 100644 --- a/plugin/seq/msh3.cpp +++ b/plugin/seq/msh3.cpp @@ -1,10 +1,8 @@ #include "ff++.hpp" - static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ - // if (verbosity) - if(mpirank==0) - cout << " load: msh3 is obsolete (in kernel of freefem 4/nov/2024 FH" << endl; + // if (verbosity) + if (mpirank == 0) cout << " load: msh3 is obsolete (in kernel of freefem 4/nov/2024 FH" << endl; } LOADFUNC(Load_Init) diff --git a/plugin/seq/mshmet.cpp b/plugin/seq/mshmet.cpp index 0353721dd..10c632181 100644 --- a/plugin/seq/mshmet.cpp +++ b/plugin/seq/mshmet.cpp @@ -199,8 +199,7 @@ MSHMET_pMesh mesh3_to_MSHMET_pMesh(const Mesh3 &Th3) { return meshMSHMET; } -MSHMET_pSol sol_mshmet(const int &dim, const int &np, const int &type, const int &size, int *typtab, - const KN< double > &solutions) { +MSHMET_pSol sol_mshmet(const int &dim, const int &np, const int &type, const int &size, int *typtab, const KN< double > &solutions) { static const int wrapperMetric[6] = {0, 1, 3, 2, 4, 5}; MSHMET_pSol sol; int k, ia, i; @@ -234,8 +233,7 @@ void metric_mshmet(MSHMET_pSol sol, MSHMET_Info *info, const KN< double > &metri static const int wrapperMetric[6] = {0, 1, 3, 2, 4, 5}; int k, ia, i; - if(verbosity > 1) - cout << " info->iso " << info->iso << endl; + if (verbosity > 1) cout << " info->iso " << info->iso << endl; if (info->iso == 1) { cout << " info->iso 11 " << info->iso << endl; sol->met = (double *)M_calloc(sol->np + 1, sizeof(double), "sol->met"); @@ -266,8 +264,8 @@ void metric_mshmet_to_ff_metric(MSHMET_pSol sol, MSHMET_Info *info, KN< double > if (info->iso == 1) { if (verbosity > 1) - cout << " info->iso " - << " metric " << metric.N( ) << " " << sol->np << endl; + cout << " info->iso " + << " metric " << metric.N( ) << " " << sol->np << endl; // isotrope for (k = 1; k <= sol->np; k++) { @@ -298,25 +296,15 @@ class mshmet3d_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: mshmet3d_Op(const basicAC_F0 &args) : sol(args.size( ) - 1) { @@ -589,21 +577,13 @@ class mshmet2d_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: mshmet2d_Op(const basicAC_F0 &args) : sol(args.size( ) - 1) { @@ -676,9 +656,7 @@ class mshmet2d_Op : public E_F0mps { operator aType( ) const { return atype< KN_< double > >( ); } }; -basicAC_F0::name_and_type mshmet2d_Op::name_param[] = {{"loptions", &typeid(KN_< long >)}, - {"doptions", &typeid(KN_< double >)}, - {"metric", &typeid(KN_< double >)}}; +basicAC_F0::name_and_type mshmet2d_Op::name_param[] = {{"loptions", &typeid(KN_< long >)}, {"doptions", &typeid(KN_< double >)}, {"metric", &typeid(KN_< double >)}}; AnyType mshmet2d_Op::operator( )(Stack stack) const { // initialisation MeshPoint *mp(MeshPointStack(stack)), mps = *mp; diff --git a/plugin/seq/netgen.cpp b/plugin/seq/netgen.cpp index f6fdb29ca..c49be1705 100644 --- a/plugin/seq/netgen.cpp +++ b/plugin/seq/netgen.cpp @@ -83,25 +83,15 @@ class RemplissageNetgen_Op : public E_F0mps { static const int n_name_param = 5; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: RemplissageNetgen_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -170,9 +160,7 @@ class RemplissageNetgen : public OneOperator { public: RemplissageNetgen( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new RemplissageNetgen_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new RemplissageNetgen_Op(args, t[0]->CastTo(args[0])); } }; AnyType RemplissageNetgen_Op::operator( )(Stack stack) const { @@ -304,8 +292,7 @@ AnyType RemplissageNetgen_Op::operator( )(Stack stack) const { Tet *tt = t; Triangle3 *bb = b; - cout << " donnee sortie netgen: Vertex" << netgen_nv << " Tetrahedre " << netgen_nt << " " - << netgen_nbe << endl; + cout << " donnee sortie netgen: Vertex" << netgen_nv << " Tetrahedre " << netgen_nt << " " << netgen_nbe << endl; for (int ii = 0; ii < netgen_nv; ii++) { Ng_GetPoint(netgen_mesh, ii + 1, point); @@ -360,25 +347,15 @@ class Netgen_STL_Op : public E_F0mps { static const int n_name_param = 3; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - int arg(int i, Stack stack, int a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: Netgen_STL_Op(const basicAC_F0 &args, Expression ffname) : filename(ffname) { @@ -402,9 +379,7 @@ class Netgen_STL : public OneOperator { public: Netgen_STL( ) : OneOperator(atype< pmesh3 >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Netgen_STL_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Netgen_STL_Op(args, t[0]->CastTo(args[0])); } }; AnyType Netgen_STL_Op::operator( )(Stack stack) const { @@ -483,8 +458,7 @@ AnyType Netgen_STL_Op::operator( )(Stack stack) const { Tet *tt = t; Triangle3 *bb = b; - cout << " donnee sortie netgen: Vertex" << netgen_nv << " Tetrahedre " << netgen_nt << " " - << netgen_nbe << endl; + cout << " donnee sortie netgen: Vertex" << netgen_nv << " Tetrahedre " << netgen_nt << " " << netgen_nbe << endl; for (int ii = 0; ii < netgen_nv; ii++) { double point[3]; @@ -540,7 +514,7 @@ class Netgen_Face { int bcd; Netgen_Face *pp; Netgen_Face( ); - Netgen_Face(int a, int b, int c, int d) : label(a), domin(b), domout(c), bcd(d), pp(0){}; + Netgen_Face(int a, int b, int c, int d) : label(a), domin(b), domout(c), bcd(d), pp(0) {}; int Test_Face(int a, int b, int c, int d) { if (label == a && domin == b && domout == c && bcd == d) { @@ -584,16 +558,13 @@ class Netgen_LoadMesh_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type Netgen_LoadMesh_Op::name_param[] = {{"reftet", &typeid(long)}, - {"renum", &typeid(long)}}; +basicAC_F0::name_and_type Netgen_LoadMesh_Op::name_param[] = {{"reftet", &typeid(long)}, {"renum", &typeid(long)}}; class Netgen_LoadMesh : public OneOperator { public: Netgen_LoadMesh( ) : OneOperator(atype< pmesh3 >( ), atype< string * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Netgen_LoadMesh_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Netgen_LoadMesh_Op(args, t[0]->CastTo(args[0])); } }; Mesh3 *NETGEN_Load(const string &filename, const int &flagsnewlabelsurf) { @@ -802,8 +773,7 @@ Mesh3 *NETGEN_Load(const string &filename, const int &flagsnewlabelsurf) { label = -1; for (j = 0; j < nbfacesnetg; j++) { - if (ngf[4 * j] == surfnr && ngf[4 * j + 1] == bcp && ngf[4 * j + 2] == domin && - ngf[4 * j + 3] == domout) { + if (ngf[4 * j] == surfnr && ngf[4 * j + 1] == bcp && ngf[4 * j + 2] == domin && ngf[4 * j + 3] == domout) { label = j + 1; } } @@ -968,8 +938,7 @@ Mesh3 *NETGEN_Load(const string &filename, const int &flagsnewlabelsurf) { label = -1; for (j = 0; j < nbfacesnetg; j++) { - if (ngf[4 * j] == surfnr && ngf[4 * j + 1] == bcp && ngf[4 * j + 2] == domin && - ngf[4 * j + 3] == domout) { + if (ngf[4 * j] == surfnr && ngf[4 * j + 1] == bcp && ngf[4 * j + 2] == domin && ngf[4 * j + 3] == domout) { label = j + 1; } } diff --git a/plugin/seq/pcm2rnm.cpp b/plugin/seq/pcm2rnm.cpp index b1066c6e8..3345af887 100644 --- a/plugin/seq/pcm2rnm.cpp +++ b/plugin/seq/pcm2rnm.cpp @@ -98,43 +98,42 @@ long read_pcm(string *const &filename, KNM< double > *const &u, KNM< double > *c return (long)pcm.width * pcm.height; } -template inline T max (const T &a,const T & b,const T & c){return max(max(a,b),c);} -template inline T min (const T &a,const T & b,const T & c){return min(min(a,b),c);} - -void rgb2hsv( double r,double g, double b,double & h,double &s, double &v ) -{ - - double vmax = max(r, g, b); - double vmin = min(r, g, b); - double delta =vmax - vmin; - v = vmax; - - - if (vmax == 0.0) { - s = 0; - h = 0; - } - else if (delta < 1e-4) { - s = 0; - h = 0; - } - else { - s = delta / vmax; +template< class T > +inline T max(const T &a, const T &b, const T &c) { + return max(max(a, b), c); +} +template< class T > +inline T min(const T &a, const T &b, const T &c) { + return min(min(a, b), c); +} - if (vmax == r) { - h = ((g - b) / delta) + 0.; - } - else if (vmax == g) { - h = ((b - r) / delta) + 2.; - } - else { - h = ((r - g) / delta) + 4.; - } +void rgb2hsv(double r, double g, double b, double &h, double &s, double &v) { + + double vmax = max(r, g, b); + double vmin = min(r, g, b); + double delta = vmax - vmin; + v = vmax; + + if (vmax == 0.0) { + s = 0; + h = 0; + } else if (delta < 1e-4) { + s = 0; + h = 0; + } else { + s = delta / vmax; + + if (vmax == r) { + h = ((g - b) / delta) + 0.; + } else if (vmax == g) { + h = ((b - r) / delta) + 2.; + } else { + h = ((r - g) / delta) + 4.; } + } - if (h < 0) h += 6.; - h /= 6. ; - + if (h < 0) h += 6.; + h /= 6.; } /* void hsv2rgb(const unsigned char &src_h, const unsigned char &src_s, const unsigned char &src_v, unsigned char &dst_r, unsigned char &dst_g, unsigned char &dst_b) @@ -168,9 +167,7 @@ void hsv2rgb(const unsigned char &src_h, const unsigned char &src_s, const unsig static void Load_Init( ) { cout << " load: init pcm2rmn " << endl; - Global.Add("readpcm", "(", - new OneOperator2< KNM< Complex > *, string *, KNM< Complex > * >(&read_pcm), - new OneOperator3_< long, string *, KNM< double > *, KNM< double > * >(&read_pcm)); + Global.Add("readpcm", "(", new OneOperator2< KNM< Complex > *, string *, KNM< Complex > * >(&read_pcm), new OneOperator3_< long, string *, KNM< double > *, KNM< double > * >(&read_pcm)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/pipe.cpp b/plugin/seq/pipe.cpp index fb22b2dd4..6703be890 100644 --- a/plugin/seq/pipe.cpp +++ b/plugin/seq/pipe.cpp @@ -118,8 +118,7 @@ static pstream **pstream_init(pstream **const &p, string *const &a, string *cons } if (verbosity > 10) { - *ffapi::cout( ) << "pstream_init: om " << om << "(" << ios_base::in << ios_base::out - << ") mode:" << mode << " '" << *a << "'" << endl; + *ffapi::cout( ) << "pstream_init: om " << om << "(" << ios_base::in << ios_base::out << ") mode:" << mode << " '" << *a << "'" << endl; } redi::basic_pstream< char > *pp = new redi::pstream(a->c_str( ), om); @@ -133,9 +132,7 @@ static pstream **pstream_init(pstream **const &p, string *const &a, string *cons return p; }; -static pstream **pstream_init(pstream **const &p, string *const &a) { - return pstream_init(p, a, 0); -}; +static pstream **pstream_init(pstream **const &p, string *const &a) { return pstream_init(p, a, 0); }; #else // VERSION GNU @@ -147,8 +144,7 @@ struct pstream { stdiofilebuf *fb; ostream *os; istream *is; - pstream(FILE *ff, std::ios_base::openmode mode) - : f(ff), fb(new stdiofilebuf(f, mode)), os(0), is(0) { + pstream(FILE *ff, std::ios_base::openmode mode) : f(ff), fb(new stdiofilebuf(f, mode)), os(0), is(0) { if (verbosity > 10) { cout << " mode " << mode << endl; } @@ -220,8 +216,7 @@ static pstream **pstream_init(pstream **const &p, string *const &a, string *cons } if (verbosity > 10) { - *ffapi::cout( ) << "pstream_init: om " << om << "(" << ios_base::in << ios_base::out - << ") mode:" << mode << " '" << *a << "'" << endl; + *ffapi::cout( ) << "pstream_init: om " << om << "(" << ios_base::in << ios_base::out << ") mode:" << mode << " '" << *a << "'" << endl; } #ifdef _WIN32 @@ -238,9 +233,7 @@ static pstream **pstream_init(pstream **const &p, string *const &a, string *cons return p; }; -static pstream **pstream_init(pstream **const &p, string *const &a) { - return pstream_init(p, a, 0); -}; +static pstream **pstream_init(pstream **const &p, string *const &a) { return pstream_init(p, a, 0); }; #endif AnyType pstream2o(Stack, const AnyType &a) { @@ -280,26 +273,24 @@ inline istream_good to_istream_good(pstream **f) { inline bool get_eof(pstream **p) { return (**p).is ? (**p).is->eof( ) : EOF; } static void inittt( ) { - Dcl_TypeandPtr< pstream * >(0, 0, ::InitializePtr< pstream * >, ::DeletePtr< pstream * >); - atype< istream * >( )->AddCast(new E_F1_funcT< istream *, pstream ** >(pstream2i)); - atype< ostream * >( )->AddCast(new E_F1_funcT< ostream *, pstream ** >(pstream2o)); - TheOperators->Add("<-", new OneOperator2_< pstream **, pstream **, string * >(pstream_init)); - TheOperators->Add("<-", - new OneOperator3_< pstream **, pstream **, string *, string * >(pstream_init)); - zzzfff->Add("pstream", atype< pstream ** >( )); - Add< pstream ** >("good", ".", new OneOperator1< istream_good, pstream ** >(to_istream_good)); - Add< pstream ** >("eof", ".", new OneOperator1< bool, pstream ** >(get_eof)); - Global.Add("flush", "(", new OneOperator1< long, pstream ** >(cflush)); - Global.Add("sleep", "(", new OneOperator1< long, long >(ffsleep)); - Global.Add("usleep", "(", new OneOperator1< long, long >(ffusleep)); - if (!Global.Find("onWIN32").NotNull( )) - { + Dcl_TypeandPtr< pstream * >(0, 0, ::InitializePtr< pstream * >, ::DeletePtr< pstream * >); + atype< istream * >( )->AddCast(new E_F1_funcT< istream *, pstream ** >(pstream2i)); + atype< ostream * >( )->AddCast(new E_F1_funcT< ostream *, pstream ** >(pstream2o)); + TheOperators->Add("<-", new OneOperator2_< pstream **, pstream **, string * >(pstream_init)); + TheOperators->Add("<-", new OneOperator3_< pstream **, pstream **, string *, string * >(pstream_init)); + zzzfff->Add("pstream", atype< pstream ** >( )); + Add< pstream ** >("good", ".", new OneOperator1< istream_good, pstream ** >(to_istream_good)); + Add< pstream ** >("eof", ".", new OneOperator1< bool, pstream ** >(get_eof)); + Global.Add("flush", "(", new OneOperator1< long, pstream ** >(cflush)); + Global.Add("sleep", "(", new OneOperator1< long, long >(ffsleep)); + Global.Add("usleep", "(", new OneOperator1< long, long >(ffusleep)); + if (!Global.Find("onWIN32").NotNull( )) { #ifdef _WIN32 - Global.New("onWIN32", CConstant< bool >(true)); + Global.New("onWIN32", CConstant< bool >(true)); #else - Global.New("onWIN32", CConstant< bool >(false)); + Global.New("onWIN32", CConstant< bool >(false)); #endif - } + } } LOADFUNC(inittt); diff --git a/plugin/seq/plotPDF.cpp b/plugin/seq/plotPDF.cpp index f47baa1e9..b4337cf4a 100644 --- a/plugin/seq/plotPDF.cpp +++ b/plugin/seq/plotPDF.cpp @@ -5,25 +5,27 @@ // ORG : Graduate School of Informatics, Kyoto University, Japan // AUTHOR : Hiroshi Fujiwara // E-MAIL : fujiwara@acs.i.kyoto-u.ac.jp -// +// // The newest version is avalilable at: // http://www-an.acs.i.kyoto-u.ac.jp/~fujiwara/ff // //---------------------------------------------------------------------- +/* clang-format off */ //ff-c++-LIBRARY-dep: [zlib] +/* clang-format on */ // Usage: // // (1) bool plotPDF( PDFfilename, mesh Th [, options] ); -// +// // Drawing 'mesh Th' only. // // (2) bool plotPDF( PDFfilename, mesh Th, Vh u [, options] ); -// +// // Drawing both 'mesh Th' and 'FE function u'. // // (3) bool plotPDF( PDFfilename, mesh Th, Vh u [, options] ); -// +// // Drawing both 'mesh Th' and 'FE function u'. // // (4) bool plotPDF( PDFfilename, mesh Th, [Vh u, Vh v] [, options] ); @@ -124,7 +126,7 @@ // // small font // plotPDF( "sample", Th, u, value=false ); // value is omitted in solution pages // -// +// // real[int] visoarray=[-0.02,-0.01,0,0.01,0.02]; // specify isoline-values // plotPDF("sample_with_viso",Th,u, viso=visoarray); // @@ -177,97 +179,95 @@ //---------------------------------------------------------------------- -namespace PLOTPDFVAR -{ - const long DEFAULT_PAGESIZE = 512; - const double DEFAULT_ASPECTRATIO = 0; // "0" means auto - const char AppName[] = "FreeFEM plotPDF module"; - const char SHOW_VERSION[] = "(Ver Oct 8, 2022)"; - - const int NOPTIONS = 34; - - const double PADDING = 20; - const int DEFAULT_MARGIN[4] = { 0, 0, 0, 0 }; // left, bottom, right, top - - const double DEFAULT_INDEX_FONTSIZE = 16; - const double DEFAULT_LEGEND_FONTSIZE = 12; - const double DEFAULT_COMMENT_FONTSIZE = 16; - const double DEFAULT_COMMENT_BASE = DEFAULT_INDEX_FONTSIZE*2; // avoid overlap - - const int NUM_LABELS = 12; // number of labels (values) in fill-style - const long DEFAULT_ISOLINES = 12; - const long DEFAULT_FILL_COLORS = 32; - const double DEFAULT_LINEWIDTH = 1; // for contours, arrows - const double EDGE_WIDTH = 1; - const double MESH_WIDTH = 0.5; - - const bool DEFAULT_MONOCHROME = false; - const bool DEFAULT_SHOW_LEGEND = true; - const bool DEFAULT_LOGSCALE = false; - const double DEFAULT_WITHMESH = 0; // gray scale, 0=white, 1=black - - // Complex-valued function - const bool DEFAULT_ZREAL = true; // draw real part - const bool DEFAULT_ZIMAG = true; // draw imaginary part - const bool DEFAULT_ZABS = false; // draw modulus of complex-valued function - const bool DEFAULT_ZARG = false; // draw argument - - // Vector field - const double DEFAULT_ARROW_SCALE = 1.0; - const double DEFAULT_AHEAD_SCALE = 1.0; - const bool DEFAULT_UNIT_ARROW = false; // draw arrow with its length - const long DEFAULT_ARROW_COLORS = 0; // 0 : unlimited - const double MAX_ARROW_LENGTH = 50; // [pixel] - const double DEFAULT_ARROW_HEAD_SIZE = 8; // [pixel] - const double ARROW_HEAD_ANGLE = 0.23; // 13/180*PI = 0.226893 [rad] - - const bool DEFAULT_SHOW_MESH = true; - const bool DEFAULT_SHOW_INDEX = false; - const bool DEFAULT_SHOW_BELABEL = false; - const bool DEFAULT_SHOW_ISOLINE = true; - const bool DEFAULT_SHOW_FILL = true; - - const bool DEFAULT_SHOW_IDCELL = true; - const bool DEFAULT_SHOW_IDVERT = true; - const bool DEFAULT_SHOW_IDEDGE = false; - const float DEFAULT_IDCELL_MONO[] = { 0, 0, 0 }; // RGB : black - const float DEFAULT_IDCELL_RGB[] = { 0, 0, 0 }; // RGB : black - const float DEFAULT_IDVERT_MONO[] = { 0.5, 0.5, 0.5 }; // RGB - const float DEFAULT_IDVERT_RGB[] = { 0.0/255.0, 90.0/255.0, 255.0/255.0 }; // RGB : blue - const float DEFAULT_IDEDGE_MONO[] = { 0.8, 0.8, 0.8 }; // RGB - const float DEFAULT_IDEDGE_RGB[] = { 255.0/255.0, 75.0/255.0, 0.0/25.0 }; // RGB : red - - const long DEFAULT_PRECISION_LEGEND = 3; // #digits in legend - const double LEGEND_FONTWIDTH = static_cast(PLOTPDFVAR::PADDING)/DEFAULT_PRECISION_LEGEND; // depend on font family and size - - const char DEFAULT_FETYPE[] = "P1"; - const int DEFAULT_P2_INERVALS = 5; - - const int DEFAULT_PALETTE_NCOLORS = 5; - const double DEFAULT_PALETTE[ DEFAULT_PALETTE_NCOLORS ][3] = - { - // color universal design (ver.3, Aug. 2013) - // { 0, 65, 255 }, // RGB at rf=0.09 (blue) - // { 0, 161, 255 }, // RGB at rf=0.25 - // { 53, 161, 107 }, // RGB at rf=0.50 (green) - // { 255, 161, 0 }, // RGB at rf=0.75 - // { 255, 40, 0 } // RGB at rf=1.00 (red) - - // color universal design (ver.4, Apr. 2018) - { 0, 90, 255 }, // RGB at rf=0.00 (blue) - { 0, 175, 255 }, // RGB at rf=0.25 - { 3, 175, 122 }, // RGB at rf=0.50 (green) - { 255, 175, 0 }, // RGB at rf=0.75 - { 255, 75, 0 } // RGB at rf=1.00 (red) - - // if you like vivid color - // { 0, 0, 255 }, // RGB at rf=0.00 (blue) - // { 0, 255, 255 }, // RGB at rf=0.25 - // { 0, 255, 0 }, // RGB at rf=0.50 (green) - // { 255, 255, 0 }, // RGB at rf=0.75 - // { 255, 0, 0 } // RGB at rf=1.00 (red) - }; -} +namespace PLOTPDFVAR { + const long DEFAULT_PAGESIZE = 512; + const double DEFAULT_ASPECTRATIO = 0; // "0" means auto + const char AppName[] = "FreeFEM plotPDF module"; + const char SHOW_VERSION[] = "(Ver Oct 8, 2022)"; + + const int NOPTIONS = 34; + + const double PADDING = 20; + const int DEFAULT_MARGIN[4] = {0, 0, 0, 0}; // left, bottom, right, top + + const double DEFAULT_INDEX_FONTSIZE = 16; + const double DEFAULT_LEGEND_FONTSIZE = 12; + const double DEFAULT_COMMENT_FONTSIZE = 16; + const double DEFAULT_COMMENT_BASE = DEFAULT_INDEX_FONTSIZE * 2; // avoid overlap + + const int NUM_LABELS = 12; // number of labels (values) in fill-style + const long DEFAULT_ISOLINES = 12; + const long DEFAULT_FILL_COLORS = 32; + const double DEFAULT_LINEWIDTH = 1; // for contours, arrows + const double EDGE_WIDTH = 1; + const double MESH_WIDTH = 0.5; + + const bool DEFAULT_MONOCHROME = false; + const bool DEFAULT_SHOW_LEGEND = true; + const bool DEFAULT_LOGSCALE = false; + const double DEFAULT_WITHMESH = 0; // gray scale, 0=white, 1=black + + // Complex-valued function + const bool DEFAULT_ZREAL = true; // draw real part + const bool DEFAULT_ZIMAG = true; // draw imaginary part + const bool DEFAULT_ZABS = false; // draw modulus of complex-valued function + const bool DEFAULT_ZARG = false; // draw argument + + // Vector field + const double DEFAULT_ARROW_SCALE = 1.0; + const double DEFAULT_AHEAD_SCALE = 1.0; + const bool DEFAULT_UNIT_ARROW = false; // draw arrow with its length + const long DEFAULT_ARROW_COLORS = 0; // 0 : unlimited + const double MAX_ARROW_LENGTH = 50; // [pixel] + const double DEFAULT_ARROW_HEAD_SIZE = 8; // [pixel] + const double ARROW_HEAD_ANGLE = 0.23; // 13/180*PI = 0.226893 [rad] + + const bool DEFAULT_SHOW_MESH = true; + const bool DEFAULT_SHOW_INDEX = false; + const bool DEFAULT_SHOW_BELABEL = false; + const bool DEFAULT_SHOW_ISOLINE = true; + const bool DEFAULT_SHOW_FILL = true; + + const bool DEFAULT_SHOW_IDCELL = true; + const bool DEFAULT_SHOW_IDVERT = true; + const bool DEFAULT_SHOW_IDEDGE = false; + const float DEFAULT_IDCELL_MONO[] = {0, 0, 0}; // RGB : black + const float DEFAULT_IDCELL_RGB[] = {0, 0, 0}; // RGB : black + const float DEFAULT_IDVERT_MONO[] = {0.5, 0.5, 0.5}; // RGB + const float DEFAULT_IDVERT_RGB[] = {0.0 / 255.0, 90.0 / 255.0, 255.0 / 255.0}; // RGB : blue + const float DEFAULT_IDEDGE_MONO[] = {0.8, 0.8, 0.8}; // RGB + const float DEFAULT_IDEDGE_RGB[] = {255.0 / 255.0, 75.0 / 255.0, 0.0 / 25.0}; // RGB : red + + const long DEFAULT_PRECISION_LEGEND = 3; // #digits in legend + const double LEGEND_FONTWIDTH = static_cast< double >(PLOTPDFVAR::PADDING) / DEFAULT_PRECISION_LEGEND; // depend on font family and size + + const char DEFAULT_FETYPE[] = "P1"; + const int DEFAULT_P2_INERVALS = 5; + + const int DEFAULT_PALETTE_NCOLORS = 5; + const double DEFAULT_PALETTE[DEFAULT_PALETTE_NCOLORS][3] = { + // color universal design (ver.3, Aug. 2013) + // { 0, 65, 255 }, // RGB at rf=0.09 (blue) + // { 0, 161, 255 }, // RGB at rf=0.25 + // { 53, 161, 107 }, // RGB at rf=0.50 (green) + // { 255, 161, 0 }, // RGB at rf=0.75 + // { 255, 40, 0 } // RGB at rf=1.00 (red) + + // color universal design (ver.4, Apr. 2018) + {0, 90, 255}, // RGB at rf=0.00 (blue) + {0, 175, 255}, // RGB at rf=0.25 + {3, 175, 122}, // RGB at rf=0.50 (green) + {255, 175, 0}, // RGB at rf=0.75 + {255, 75, 0} // RGB at rf=1.00 (red) + + // if you like vivid color + // { 0, 0, 255 }, // RGB at rf=0.00 (blue) + // { 0, 255, 255 }, // RGB at rf=0.25 + // { 0, 255, 0 }, // RGB at rf=0.50 (green) + // { 255, 255, 0 }, // RGB at rf=0.75 + // { 255, 0, 0 } // RGB at rf=1.00 (red) + }; +} // namespace PLOTPDFVAR //---------------------------------------------------------------------- // Simple PDF class @@ -276,1472 +276,1323 @@ namespace PLOTPDFVAR #include #include #include -#include // strlen -#include // exit - -// Change F. Hecht -//#define HAVE_ZLIB // need zlib : CC src.cpp -lz -//#if !defined(NO_ZLIB) && !defined(DISABLE_ZLIB) && !defined(WITHOUT_ZLIB) -//#define HAVE_ZLIB -//#endif +#include // strlen +#include // exit + +// Change F. Hecht +// #define HAVE_ZLIB // need zlib : CC src.cpp -lz +// #if !defined(NO_ZLIB) && !defined(DISABLE_ZLIB) && !defined(WITHOUT_ZLIB) +// #define HAVE_ZLIB +// #endif #if defined(WITH_zlib) #define HAVE_ZLIB #endif +class SimplePDFModule { + int byte_offset; + std::list< int > xref; -class SimplePDFModule -{ - int byte_offset; - std::list xref; - - struct OutlineItem { - int headPageObjectNumber; - char *label; - }; - std::list outline; - - const std::string filename; - const std::string DocumentTitle; - int page_obj_offset, page; - - std::string get_datetime() const - { - std::time_t now = std::time( NULL ); - const std::tm* lt = std::localtime(&now); - - std::stringstream s; - - s << std::setfill('0') << std::right // valid for all operations << - << "20" << std::setw(2) << lt->tm_year-100 - << std::setw(2) << lt->tm_mon+1 // setw() is reset at each ops << - << std::setw(2) << lt->tm_mday - << std::setw(2) << lt->tm_hour - << std::setw(2) << lt->tm_min - << std::setw(2) << lt->tm_sec; - - return s.str(); - } + struct OutlineItem { + int headPageObjectNumber; + char *label; + }; + std::list< OutlineItem > outline; + + const std::string filename; + const std::string DocumentTitle; + int page_obj_offset, page; + + std::string get_datetime( ) const { + std::time_t now = std::time(NULL); + const std::tm *lt = std::localtime(&now); + + std::stringstream s; + + s << std::setfill('0') << std::right // valid for all operations << + << "20" << std::setw(2) << lt->tm_year - 100 << std::setw(2) << lt->tm_mon + 1 // setw() is reset at each ops << + << std::setw(2) << lt->tm_mday << std::setw(2) << lt->tm_hour << std::setw(2) << lt->tm_min << std::setw(2) << lt->tm_sec; + + return s.str( ); + } #ifdef HAVE_ZLIB - int deflate_compress( char* &buf, const std::string &Stream ) const; + int deflate_compress(char *&buf, const std::string &Stream) const; #endif -public: + public: + SimplePDFModule(const char *const filename, const char *const title = ""); - SimplePDFModule( const char *const filename, const char *const title = "" ); + ~SimplePDFModule( ); - ~SimplePDFModule(); + void addPage(const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT, const int *const MARGIN); - void addPage( const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT, const int *const MARGIN ); - - void addBookmark( const char *const BookmarkLabel ); + void addBookmark(const char *const BookmarkLabel); }; -SimplePDFModule::SimplePDFModule( const char *const PDFfilename, const char *const title ) - : filename( PDFfilename ), DocumentTitle( title ), page(0) -{ - std::ofstream fout( filename.c_str(), std::ios::binary ); +SimplePDFModule::SimplePDFModule(const char *const PDFfilename, const char *const title) : filename(PDFfilename), DocumentTitle(title), page(0) { + std::ofstream fout(filename.c_str( ), std::ios::binary); - if( !fout ){ - std::cerr << "plotPDF() : Cannot open the file: " << filename << std::endl; - return; - } + if (!fout) { + std::cerr << "plotPDF() : Cannot open the file: " << filename << std::endl; + return; + } - //-------------------------------------------------- - // Header Section - //-------------------------------------------------- - std::stringstream header; + //-------------------------------------------------- + // Header Section + //-------------------------------------------------- + std::stringstream header; #if 1 - // match to pdflatex & dvipdfmx in texlive 2019 - header << "%PDF-1.5\n" - << '%' << char(0xd0) << char(0xd4) << char(0xc5) << char(0xd8) << '\n'; + // match to pdflatex & dvipdfmx in texlive 2019 + header << "%PDF-1.5\n" << '%' << char(0xd0) << char(0xd4) << char(0xc5) << char(0xd8) << '\n'; #else - header << "%PDF-1.7\n" - << '%' << char(0xe2) << char(0xe3) << char(0xcf) << char(0xd3) << '\n'; + header << "%PDF-1.7\n" << '%' << char(0xe2) << char(0xe3) << char(0xcf) << char(0xd3) << '\n'; #endif - fout << header.str(); - byte_offset = header.str().length(); - - fout.close(); - - //-------------------------------------------------- - // Body Section : Objects - //-------------------------------------------------- - std::list obj; - - std::stringstream strDocumentInfo; - strDocumentInfo << "1 0 obj\n" - << "<<\n"; - - if( strlen( DocumentTitle.c_str() ) > 0 ) - strDocumentInfo << " /Title (" << DocumentTitle << ")\n"; - - strDocumentInfo << " /Creator (" << PLOTPDFVAR::AppName << ")\n" - << " /CreationDate (D:" << get_datetime() << ")\n" - << ">>\n" - << "endobj\n"; - const std::string DocumentInfo = strDocumentInfo.str(); - - // /PageLayout \in { /SinglePage (default), /OneColumn, - // /TwoColumnLeft, /TwoColumnRight, /TwoPageLeft, /TwoPageRight } - // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } - const std::string DocumentCatalog = - "2 0 obj\n" - "<<\n" - " /Pages 3 0 R\n" - " /Type /Catalog\n" - " /PageLayout /SinglePage\n" - " /PageMode 4 0 R\n" - " /Outlines 5 0 R\n" - ">>\n" - "endobj\n"; - - //-------------------------------------------------- - // Object 3 is reserved for PageTree - // Object 4 is reserved for PageMode - // Object 5 is reserved for Outlines - // Object 6 is reserved for Outlines (document title) - //-------------------------------------------------- - - //-------------------------------------------------- - // Roman Fonts - //-------------------------------------------------- - const std::string FontEH = - "7 0 obj\n" - "<<\n" - " /BaseFont /Helvetica\n" - " /Subtype /Type1\n" - " /Type /Font\n" - ">>\n" - "endobj\n"; - - fout.open( filename.c_str(), std::ios::app|std::ios::binary ); - - obj.push_back( &DocumentInfo ); - obj.push_back( &DocumentCatalog ); - obj.push_back( &FontEH ); - - for(std::list::const_iterator itr = obj.begin(); itr != obj.end(); itr++){ - fout << **itr; - xref.push_back( byte_offset ); - byte_offset += (*itr)->length(); - } - - fout.close(); - - page_obj_offset = obj.size()+5; - - return; + fout << header.str( ); + byte_offset = header.str( ).length( ); + + fout.close( ); + + //-------------------------------------------------- + // Body Section : Objects + //-------------------------------------------------- + std::list< const std::string * > obj; + + std::stringstream strDocumentInfo; + strDocumentInfo << "1 0 obj\n" + << "<<\n"; + + if (strlen(DocumentTitle.c_str( )) > 0) strDocumentInfo << " /Title (" << DocumentTitle << ")\n"; + + strDocumentInfo << " /Creator (" << PLOTPDFVAR::AppName << ")\n" + << " /CreationDate (D:" << get_datetime( ) << ")\n" + << ">>\n" + << "endobj\n"; + const std::string DocumentInfo = strDocumentInfo.str( ); + + // /PageLayout \in { /SinglePage (default), /OneColumn, + // /TwoColumnLeft, /TwoColumnRight, /TwoPageLeft, /TwoPageRight } + // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } + const std::string DocumentCatalog = + "2 0 obj\n" + "<<\n" + " /Pages 3 0 R\n" + " /Type /Catalog\n" + " /PageLayout /SinglePage\n" + " /PageMode 4 0 R\n" + " /Outlines 5 0 R\n" + ">>\n" + "endobj\n"; + + //-------------------------------------------------- + // Object 3 is reserved for PageTree + // Object 4 is reserved for PageMode + // Object 5 is reserved for Outlines + // Object 6 is reserved for Outlines (document title) + //-------------------------------------------------- + + //-------------------------------------------------- + // Roman Fonts + //-------------------------------------------------- + const std::string FontEH = + "7 0 obj\n" + "<<\n" + " /BaseFont /Helvetica\n" + " /Subtype /Type1\n" + " /Type /Font\n" + ">>\n" + "endobj\n"; + + fout.open(filename.c_str( ), std::ios::app | std::ios::binary); + + obj.push_back(&DocumentInfo); + obj.push_back(&DocumentCatalog); + obj.push_back(&FontEH); + + for (std::list< const std::string * >::const_iterator itr = obj.begin( ); itr != obj.end( ); itr++) { + fout << **itr; + xref.push_back(byte_offset); + byte_offset += (*itr)->length( ); + } + + fout.close( ); + + page_obj_offset = obj.size( ) + 5; + + return; } -SimplePDFModule::~SimplePDFModule() -{ - std::ofstream fout( filename.c_str(), std::ios::app|std::ios::binary ); - - //---------------------------------------- - // PageTree - //---------------------------------------- - std::stringstream strPageTree; - strPageTree << "3 0 obj\n" - << "<<\n" - << " /Kids ["; - - for(int i = 0; i < page; i++) - strPageTree << ((i == 0)? "": " ") << page_obj_offset+i*2 << " 0 R"; - - strPageTree << "]\n" - << " /Type /Pages\n" - << " /Count " << page << "\n" - << ">>\n" - << "endobj\n"; - - fout << strPageTree.str(); - - std::list::iterator itr = xref.begin(); // obj 1 (DocumentInfo) - itr++; // obj 2 (DocumentCatalog) - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - - byte_offset += strPageTree.str().length(); - - //---------------------------------------- - // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } - //---------------------------------------- - std::stringstream strPageMode; - strPageMode << "4 0 obj\n" - << " " << (outline.empty()? "/UseNone\n": "/UseOutlines\n") - << "endobj\n"; - - fout << strPageMode.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strPageMode.str().length(); - - //---------------------------------------- - // Outlines - //---------------------------------------- - std::stringstream strOutlines; - strOutlines << "5 0 obj\n" - << "<<\n" - << " /Type /Outlines\n" - << " /Count " << 1+outline.size() << "\n" // 1 : Document Title - << " /First 6 0 R\n" - << " /Last 6 0 R\n" - << ">>\n" - << "endobj\n"; - - fout << strOutlines.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strOutlines.str().length(); - - //---------------------------------------- - // the top of outline - //---------------------------------------- - strOutlines.str(""); // clear string buffer - strOutlines.clear( std::stringstream::goodbit ); // clear status - - strOutlines << "6 0 obj\n" - << "<<\n" - << " /Title (" << DocumentTitle << ")\n" - << " /Parent 5 0 R\n" - << " /Count " << outline.size() << "\n"; - - if( !outline.empty() ){ - - const int OutlineItemIdFirst = xref.size()+2; - const int OutlineItemIdLast = xref.size()+outline.size()+1; - - strOutlines << " /First " << OutlineItemIdFirst << " 0 R\n" - << " /Last " << OutlineItemIdLast << " 0 R\n"; - } - - strOutlines << " /Dest [" << outline.front().headPageObjectNumber << " 0 R /Fit]\n" - << ">>\n" - << "endobj\n"; - - fout << strOutlines.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strOutlines.str().length(); - - //---------------------------------------- - // outline items - //---------------------------------------- - for(std::list::iterator itr = outline.begin(); itr != outline.end(); itr++){ - - std::stringstream strOutlineItem; - - const int object_id = xref.size()+1; - - strOutlineItem << object_id << " 0 obj\n" - << "<<\n" - << " /Title (" << itr->label << ")\n" - << " /Parent 6 0 R\n"; +SimplePDFModule::~SimplePDFModule( ) { + std::ofstream fout(filename.c_str( ), std::ios::app | std::ios::binary); + + //---------------------------------------- + // PageTree + //---------------------------------------- + std::stringstream strPageTree; + strPageTree << "3 0 obj\n" + << "<<\n" + << " /Kids ["; + + for (int i = 0; i < page; i++) strPageTree << ((i == 0) ? "" : " ") << page_obj_offset + i * 2 << " 0 R"; + + strPageTree << "]\n" + << " /Type /Pages\n" + << " /Count " << page << "\n" + << ">>\n" + << "endobj\n"; + + fout << strPageTree.str( ); + + std::list< int >::iterator itr = xref.begin( ); // obj 1 (DocumentInfo) + itr++; // obj 2 (DocumentCatalog) + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + + byte_offset += strPageTree.str( ).length( ); - if( itr != outline.begin() ) - strOutlineItem << " /Prev " << object_id-1 << " 0 R\n"; + //---------------------------------------- + // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } + //---------------------------------------- + std::stringstream strPageMode; + strPageMode << "4 0 obj\n" + << " " << (outline.empty( ) ? "/UseNone\n" : "/UseOutlines\n") << "endobj\n"; + + fout << strPageMode.str( ); - std::list::const_iterator succ = itr; - succ++; - if( succ != outline.end() ) - strOutlineItem << " /Next " << object_id+1 << " 0 R\n"; + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strPageMode.str( ).length( ); + + //---------------------------------------- + // Outlines + //---------------------------------------- + std::stringstream strOutlines; + strOutlines << "5 0 obj\n" + << "<<\n" + << " /Type /Outlines\n" + << " /Count " << 1 + outline.size( ) << "\n" // 1 : Document Title + << " /First 6 0 R\n" + << " /Last 6 0 R\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlines.str( ); + + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strOutlines.str( ).length( ); + + //---------------------------------------- + // the top of outline + //---------------------------------------- + strOutlines.str(""); // clear string buffer + strOutlines.clear(std::stringstream::goodbit); // clear status + + strOutlines << "6 0 obj\n" + << "<<\n" + << " /Title (" << DocumentTitle << ")\n" + << " /Parent 5 0 R\n" + << " /Count " << outline.size( ) << "\n"; + + if (!outline.empty( )) { + + const int OutlineItemIdFirst = xref.size( ) + 2; + const int OutlineItemIdLast = xref.size( ) + outline.size( ) + 1; + + strOutlines << " /First " << OutlineItemIdFirst << " 0 R\n" + << " /Last " << OutlineItemIdLast << " 0 R\n"; + } + + strOutlines << " /Dest [" << outline.front( ).headPageObjectNumber << " 0 R /Fit]\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlines.str( ); + + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strOutlines.str( ).length( ); + + //---------------------------------------- + // outline items + //---------------------------------------- + for (std::list< OutlineItem >::iterator itr = outline.begin( ); itr != outline.end( ); itr++) { + + std::stringstream strOutlineItem; + + const int object_id = xref.size( ) + 1; + + strOutlineItem << object_id << " 0 obj\n" + << "<<\n" + << " /Title (" << itr->label << ")\n" + << " /Parent 6 0 R\n"; + + if (itr != outline.begin( )) strOutlineItem << " /Prev " << object_id - 1 << " 0 R\n"; + + std::list< OutlineItem >::const_iterator succ = itr; + succ++; + if (succ != outline.end( )) strOutlineItem << " /Next " << object_id + 1 << " 0 R\n"; + + strOutlineItem << " /Count 0\n" + << " /Dest [" << itr->headPageObjectNumber << " 0 R /Fit]\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlineItem.str( ); + + delete[] itr->label; + + xref.push_back(byte_offset); + byte_offset += strOutlineItem.str( ).length( ); + } + + //---------------------------------------- + // Corss-reference Table Section + //---------------------------------------- + const int nobjs = xref.size( ) + 1; // including 0th object (0 0 obj) + + fout << "xref\n"; + fout << "0 " << nobjs << std::endl; + fout << "0000000000 65535 f \n"; // 0 0 obj + + for (std::list< int >::const_iterator itr = xref.begin( ); itr != xref.end( ); itr++) fout << std::setw(10) << std::setfill('0') << *itr << " 00000 n \n"; + + //---------------------------------------- + // Trailer Section + //---------------------------------------- + fout << "trailer\n" + << "<<\n" + << " /Info 1 0 R\n" + << " /Root 2 0 R\n" + << " /Size " << nobjs << "\n" + << ">>\n" + << "startxref\n" + << byte_offset << std::endl // starting position of 'xref' + << "%%EOF\n"; - strOutlineItem << " /Count 0\n" - << " /Dest [" << itr->headPageObjectNumber << " 0 R /Fit]\n" - << ">>\n" - << "endobj\n"; + fout.close( ); - fout << strOutlineItem.str(); - - delete [] itr->label; - - xref.push_back( byte_offset ); - byte_offset += strOutlineItem.str().length(); - } - - //---------------------------------------- - // Corss-reference Table Section - //---------------------------------------- - const int nobjs = xref.size()+1; // including 0th object (0 0 obj) - - fout << "xref\n"; - fout << "0 " << nobjs << std::endl; - fout << "0000000000 65535 f \n"; // 0 0 obj - - for(std::list::const_iterator itr = xref.begin(); itr != xref.end(); itr++) - fout << std::setw(10) << std::setfill('0') << *itr << " 00000 n \n"; - - //---------------------------------------- - // Trailer Section - //---------------------------------------- - fout << "trailer\n" - << "<<\n" - << " /Info 1 0 R\n" - << " /Root 2 0 R\n" - << " /Size " << nobjs << "\n" - << ">>\n" - << "startxref\n" - << byte_offset << std::endl // starting position of 'xref' - << "%%EOF\n"; - - fout.close(); - - return; + return; } -// +// #ifdef HAVE_ZLIB #include -int SimplePDFModule::deflate_compress( char* &outbuf, const std::string &Stream ) const -{ - char *inbuf = new char [ Stream.length()+1 ]; +int SimplePDFModule::deflate_compress(char *&outbuf, const std::string &Stream) const { + char *inbuf = new char[Stream.length( ) + 1]; - for(size_t i = 0; i < Stream.length(); i++) // strcpy or strncpy - inbuf[i] = Stream[i]; - inbuf[ Stream.length() ] = '\0'; + for (size_t i = 0; i < Stream.length( ); i++) // strcpy or strncpy + inbuf[i] = Stream[i]; + inbuf[Stream.length( )] = '\0'; - z_stream z; - z.zalloc = Z_NULL; - z.zfree = Z_NULL; - z.opaque = Z_NULL; + z_stream z; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; - if( deflateInit(&z, Z_DEFAULT_COMPRESSION) != Z_OK ) { - std::cerr << "zlib: deflateInit(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflateInit(&z, Z_DEFAULT_COMPRESSION) != Z_OK) { + std::cerr << "zlib: deflateInit(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - outbuf = new char [ Stream.length()+1 ]; + outbuf = new char[Stream.length( ) + 1]; - z.next_in = reinterpret_cast(inbuf); - z.avail_in = Stream.length(); - z.next_out = reinterpret_cast(outbuf); - z.avail_out = Stream.length(); + z.next_in = reinterpret_cast< unsigned char * >(inbuf); + z.avail_in = Stream.length( ); + z.next_out = reinterpret_cast< unsigned char * >(outbuf); + z.avail_out = Stream.length( ); - if( deflate(&z, Z_FINISH) != Z_STREAM_END ){ - std::cerr << "zlib: deflate(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflate(&z, Z_FINISH) != Z_STREAM_END) { + std::cerr << "zlib: deflate(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - if( deflateEnd(&z) != Z_OK ){ - std::cerr << "zlib: deflateEnd(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflateEnd(&z) != Z_OK) { + std::cerr << "zlib: deflateEnd(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - delete [] inbuf; + delete[] inbuf; - const int compressed_buf_length = Stream.length() - z.avail_out; + const int compressed_buf_length = Stream.length( ) - z.avail_out; - outbuf[compressed_buf_length] = '\n'; + outbuf[compressed_buf_length] = '\n'; - return compressed_buf_length+1; + return compressed_buf_length + 1; } #endif -void SimplePDFModule::addPage( const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT, const int *const MARGIN ) -{ - const int &marginl = MARGIN[0]; // left - const int &marginb = MARGIN[1]; // bottom - const int &marginr = MARGIN[2]; // right - const int &margint = MARGIN[3]; // top - - //---------------------------------------- - // PageObject - //---------------------------------------- - std::stringstream strPageObject; - - strPageObject << page_obj_offset+2*page << " 0 obj\n" - << "<<\n" - << " /Type /Page\n" - << " /Parent 3 0 R\n" - << " /Resources << /Font << /F1 7 0 R >> >>\n" - << " /MediaBox [0 0 " << WIDTH+marginl+marginr << ' ' << HEIGHT+marginb+margint << "]\n" - << " /Contents " << page_obj_offset+2*page+1 << " 0 R\n" - << ">>\n" - << "endobj\n"; - - const std::string PageObject = strPageObject.str(); - - //---------------------------------------- - // pageContent (stream) - //---------------------------------------- +void SimplePDFModule::addPage(const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT, const int *const MARGIN) { + const int &marginl = MARGIN[0]; // left + const int &marginb = MARGIN[1]; // bottom + const int &marginr = MARGIN[2]; // right + const int &margint = MARGIN[3]; // top + + //---------------------------------------- + // PageObject + //---------------------------------------- + std::stringstream strPageObject; + + strPageObject << page_obj_offset + 2 * page << " 0 obj\n" + << "<<\n" + << " /Type /Page\n" + << " /Parent 3 0 R\n" + << " /Resources << /Font << /F1 7 0 R >> >>\n" + << " /MediaBox [0 0 " << WIDTH + marginl + marginr << ' ' << HEIGHT + marginb + margint << "]\n" + << " /Contents " << page_obj_offset + 2 * page + 1 << " 0 R\n" + << ">>\n" + << "endobj\n"; + + const std::string PageObject = strPageObject.str( ); + + //---------------------------------------- + // pageContent (stream) + //---------------------------------------- #ifdef HAVE_ZLIB - char *buf; - const int compressed_buf_length = deflate_compress( buf, ContentStream.str() ); + char *buf; + const int compressed_buf_length = deflate_compress(buf, ContentStream.str( )); #endif - //---------------------------------------- - // pageContent (object) - //---------------------------------------- - std::stringstream strContent; - strContent << page_obj_offset+2*page+1 << " 0 obj\n" - << "<< /Length "; + //---------------------------------------- + // pageContent (object) + //---------------------------------------- + std::stringstream strContent; + strContent << page_obj_offset + 2 * page + 1 << " 0 obj\n" + << "<< /Length "; #ifdef HAVE_ZLIB - strContent << compressed_buf_length << " /Filter /FlateDecode"; + strContent << compressed_buf_length << " /Filter /FlateDecode"; #else - strContent << ContentStream.str().length(); + strContent << ContentStream.str( ).length( ); #endif - strContent << " >>\n" - << "stream\n"; + strContent << " >>\n" + << "stream\n"; #ifdef HAVE_ZLIB - // Following works well even if buf[] has '\0' - strContent << std::string( buf+0, buf+compressed_buf_length ); - delete [] buf; + // Following works well even if buf[] has '\0' + strContent << std::string(buf + 0, buf + compressed_buf_length); + delete[] buf; #else - strContent << ContentStream.str(); + strContent << ContentStream.str( ); #endif - strContent << "endstream\n" - << "endobj\n"; + strContent << "endstream\n" + << "endobj\n"; - const std::string Content = strContent.str(); + const std::string Content = strContent.str( ); - //---------------------------------------- - // Add Page Objects - //---------------------------------------- - std::ofstream fout( filename.c_str(), std::ios::app|std::ios::binary ); + //---------------------------------------- + // Add Page Objects + //---------------------------------------- + std::ofstream fout(filename.c_str( ), std::ios::app | std::ios::binary); - const std::string*const PageObj[2] = { &PageObject, &Content }; + const std::string *const PageObj[2] = {&PageObject, &Content}; - for(int i = 0; i < 2; i++){ - xref.push_back( byte_offset ); - fout << *PageObj[i]; - byte_offset += PageObj[i]->length(); - } + for (int i = 0; i < 2; i++) { + xref.push_back(byte_offset); + fout << *PageObj[i]; + byte_offset += PageObj[i]->length( ); + } - fout.close(); - page++; + fout.close( ); + page++; - return; + return; } -void SimplePDFModule::addBookmark( const char *const BookmarkLabel ) -{ - OutlineItem item; +void SimplePDFModule::addBookmark(const char *const BookmarkLabel) { + OutlineItem item; - item.headPageObjectNumber = page_obj_offset+2*page; + item.headPageObjectNumber = page_obj_offset + 2 * page; - item.label = new char [ strlen(BookmarkLabel)+1 ]; - strcpy( item.label, BookmarkLabel ); - - outline.push_back( item ); + item.label = new char[strlen(BookmarkLabel) + 1]; + strcpy(item.label, BookmarkLabel); - return; + outline.push_back(item); + + return; } //---------------------------------------------------------------------- // End of SimplePDFModule -//---------------------------------------------------------------------- +//---------------------------------------------------------------------- -void GaussElimination(double *const x, double *const *const a, const int N) -{ - const double EPS = 1e-10; +void GaussElimination(double *const x, double *const *const a, const int N) { + const double EPS = 1e-10; + + // forward elimination + for (int k = 0; k < N - 1; k++) { + + { // begin pivoting + int row = k; + + for (int r = k + 1; r < N; r++) + if (fabs(a[row][k]) < fabs(a[r][k])) row = r; + + if (fabs(a[row][k]) < EPS) { + std::cerr << "singular matrix : " << row << std::endl; + exit(1); + } - // forward elimination - for(int k = 0; k < N-1; k++){ - - { // begin pivoting - int row = k; - - for(int r = k+1; r < N; r++) - if(fabs(a[row][k]) < fabs(a[r][k])) - row = r; - - if(fabs(a[row][k]) < EPS){ - std::cerr << "singular matrix : " << row << std::endl; - exit(1); - } - - // k == row: no pivoting - if(k != row){ - for(int j = 0; j <= N; j++){ - const double tmp = a[k][j]; - a[k][j] = a[row][j]; - a[row][j] = tmp; - } - } - } // end pivoting - - const double d = 1 / a[k][k]; - for(int i = k+1; i < N; i++){ - for(int j = k+1; j <= N; j++) - a[i][j] -= a[i][k] * a[k][j] *d; - a[i][k] = 0; + // k == row: no pivoting + if (k != row) { + for (int j = 0; j <= N; j++) { + const double tmp = a[k][j]; + a[k][j] = a[row][j]; + a[row][j] = tmp; } - } + } + } // end pivoting - // backward substitution - for(int i = N-1; i >= 0; i--){ - for(int j = i+1; j < N; j++) - a[i][N] -= a[i][j]*a[j][N]; - a[i][N] /= a[i][i]; + const double d = 1 / a[k][k]; + for (int i = k + 1; i < N; i++) { + for (int j = k + 1; j <= N; j++) a[i][j] -= a[i][k] * a[k][j] * d; + a[i][k] = 0; } + } - for(int i = 0; i < N; i++) - x[i] = (fabs(a[i][N]) < EPS)? 0: a[i][N]; + // backward substitution + for (int i = N - 1; i >= 0; i--) { + for (int j = i + 1; j < N; j++) a[i][N] -= a[i][j] * a[j][N]; + a[i][N] /= a[i][i]; + } - return; + for (int i = 0; i < N; i++) x[i] = (fabs(a[i][N]) < EPS) ? 0 : a[i][N]; + + return; } -std::string get_string(Stack stack, Expression e, const char *const DEFAULT) -{ - const size_t length = 128; - char *const carg = new char [ length ]; +std::string get_string(Stack stack, Expression e, const char *const DEFAULT) { + const size_t length = 128; + char *const carg = new char[length]; - if( !e ) - strcpy(carg, DEFAULT); - else - strncpy(carg, GetAny((*e)(stack))->c_str(), length); + if (!e) + strcpy(carg, DEFAULT); + else + strncpy(carg, GetAny< string * >((*e)(stack))->c_str( ), length); - return std::string( carg ); + return std::string(carg); } -void setrgbcolor( std::stringstream &st, const double f_, - const KNM &palette, - const double fmin_, const double fmax_, - const bool monochrome, const bool logscale ) -{ - const double EPS = 1e-3; - const double THRESHOLD = -1e10; +void setrgbcolor(std::stringstream &st, const double f_, const KNM< double > &palette, const double fmin_, const double fmax_, const bool monochrome, const bool logscale) { + const double EPS = 1e-3; + const double THRESHOLD = -1e10; - if( (logscale && (fmin_ <= 0)) || (logscale && (f_ <= 0)) ) - cout << "plotPDF(): logscale for non-positive values.\n"; + if ((logscale && (fmin_ <= 0)) || (logscale && (f_ <= 0))) cout << "plotPDF(): logscale for non-positive values.\n"; - const double f = (logscale)? log(fabs(f_)): f_; - const double fmin = (logscale)? log(fabs(fmin_)): fmin_; - const double fmax = (logscale)? log(fabs(fmax_)): fmax_; + const double f = (logscale) ? log(fabs(f_)) : f_; + const double fmin = (logscale) ? log(fabs(fmin_)) : fmin_; + const double fmax = (logscale) ? log(fabs(fmax_)) : fmax_; - if( fabs(fmax-fmin) < EPS ){ - st << 0.5 << ' ' << 0.5 << ' ' << 0.5 << ' '; // middle - return; - } + if (fabs(fmax - fmin) < EPS) { + st << 0.5 << ' ' << 0.5 << ' ' << 0.5 << ' '; // middle + return; + } - double rf = (f - fmin) / (fmax - fmin); + double rf = (f - fmin) / (fmax - fmin); - if( (1 <= rf) && (rf <= 1+EPS) ){ - rf = 1; - } else if( (-EPS <= rf) && (rf <= 0) ){ - rf = 0; - } else if( (rf > 1+EPS) || (rf < -EPS) ){ - st << 1 << ' ' << 1 << ' ' << 1 << ' '; // white - return; - } - - double r(palette(0,0)), g(palette(0,1)), b(palette(0,2)); + if ((1 <= rf) && (rf <= 1 + EPS)) { + rf = 1; + } else if ((-EPS <= rf) && (rf <= 0)) { + rf = 0; + } else if ((rf > 1 + EPS) || (rf < -EPS)) { + st << 1 << ' ' << 1 << ' ' << 1 << ' '; // white + return; + } - if( palette.N() == 1 ){ + double r(palette(0, 0)), g(palette(0, 1)), b(palette(0, 2)); - if(monochrome) - r = g = b = rf; + if (palette.N( ) == 1) { - if(f <= THRESHOLD) - r = b = g = 0; + if (monochrome) r = g = b = rf; - st << r << ' ' << g << ' ' << b << ' '; - return; - } + if (f <= THRESHOLD) r = b = g = 0; - const double step = static_cast(1) / (palette.N()-1); + st << r << ' ' << g << ' ' << b << ' '; + return; + } - for(int i = 0; i < palette.N()-1; i++){ + const double step = static_cast< double >(1) / (palette.N( ) - 1); - const double l = i*step; - const double u = (i == palette.N()-1)? 1: (i+1)*step; + for (int i = 0; i < palette.N( ) - 1; i++) { - if( rf > u ) - continue; + const double l = i * step; + const double u = (i == palette.N( ) - 1) ? 1 : (i + 1) * step; - // linear interpolation - const double p = (rf - l)/step; + if (rf > u) continue; - r = (1-p)*palette(i,0) + p*palette(i+1,0); - g = (1-p)*palette(i,1) + p*palette(i+1,1); - b = (1-p)*palette(i,2) + p*palette(i+1,2); + // linear interpolation + const double p = (rf - l) / step; - break; - } + r = (1 - p) * palette(i, 0) + p * palette(i + 1, 0); + g = (1 - p) * palette(i, 1) + p * palette(i + 1, 1); + b = (1 - p) * palette(i, 2) + p * palette(i + 1, 2); - if(monochrome) - r = g = b = rf; + break; + } - if(f <= THRESHOLD) - r = b = g = 0; + if (monochrome) r = g = b = rf; - st << r << ' ' << g << ' ' << b << ' '; + if (f <= THRESHOLD) r = b = g = 0; - return; + st << r << ' ' << g << ' ' << b << ' '; + + return; } //---------------------------------------------------------------------- -void addComment( std::stringstream &Content, - const double posy, const int marginl, const int marginb, - const double fontscale, const string &comment ) -{ - std::stringstream &st = Content; +void addComment(std::stringstream &Content, const double posy, const int marginl, const int marginb, const double fontscale, const string &comment) { + std::stringstream &st = Content; - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - st << "0 0 0 RG\n"; // black + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; + st << "0 0 0 RG\n"; // black - const int posx = 0; + const int posx = 0; - st << "BT\n"; - st << "/F1 " << PLOTPDFVAR::DEFAULT_COMMENT_FONTSIZE*fontscale << " Tf\n"; - st << "1 0 0 1 " << posx << ' ' << posy+PLOTPDFVAR::DEFAULT_COMMENT_BASE << " Tm " - << "(" << comment << ") Tj\n"; - st << "ET\n"; - st << "Q\n"; + st << "BT\n"; + st << "/F1 " << PLOTPDFVAR::DEFAULT_COMMENT_FONTSIZE * fontscale << " Tf\n"; + st << "1 0 0 1 " << posx << ' ' << posy + PLOTPDFVAR::DEFAULT_COMMENT_BASE << " Tm " + << "(" << comment << ") Tj\n"; + st << "ET\n"; + st << "Q\n"; - return; + return; } -void overlayMesh( std::stringstream &Content, const Fem2D::Mesh &Th, - const double withmesh, - const double scale, const double ar, const double x0, const double y0, - const double marginl, const double marginb ) -{ - std::stringstream &st = Content; +void overlayMesh(std::stringstream &Content, const Fem2D::Mesh &Th, const double withmesh, const double scale, const double ar, const double x0, const double y0, const double marginl, + const double marginb) { + std::stringstream &st = Content; - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm "; - st << PLOTPDFVAR::MESH_WIDTH << " w\n"; // setlinewidth + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm "; + st << PLOTPDFVAR::MESH_WIDTH << " w\n"; // setlinewidth - const double grayscale1 = (withmesh < 1)? withmesh: 1; - const double grayscale = 1-grayscale1; - st << grayscale << ' ' << grayscale << ' ' << grayscale << " RG\n"; + const double grayscale1 = (withmesh < 1) ? withmesh : 1; + const double grayscale = 1 - grayscale1; + st << grayscale << ' ' << grayscale << ' ' << grayscale << " RG\n"; - for(int k = 0; k < Th.nt; k++){ + for (int k = 0; k < Th.nt; k++) { - const int &v0 = Th(k,0); - const int &v1 = Th(k,1); - const int &v2 = Th(k,2); + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - st << scale*ar*(Th(v0).x-x0) << ' ' << scale*(Th(v0).y-y0) << " m "; - st << scale*ar*(Th(v1).x-x0) << ' ' << scale*(Th(v1).y-y0) << " l "; - st << scale*ar*(Th(v2).x-x0) << ' ' << scale*(Th(v2).y-y0) << " l "; - st << "s" << std::endl; - } + st << scale * ar * (Th(v0).x - x0) << ' ' << scale * (Th(v0).y - y0) << " m "; + st << scale * ar * (Th(v1).x - x0) << ' ' << scale * (Th(v1).y - y0) << " l "; + st << scale * ar * (Th(v2).x - x0) << ' ' << scale * (Th(v2).y - y0) << " l "; + st << "s" << std::endl; + } - st << "Q\n"; + st << "Q\n"; - return; + return; } -void drawBoundary( std::stringstream &Content, const Fem2D::Mesh &Th, - const double scale, const double ar, const double x0, const double y0, - const double marginl, const double marginb ) -{ - std::stringstream &st = Content; +void drawBoundary(std::stringstream &Content, const Fem2D::Mesh &Th, const double scale, const double ar, const double x0, const double y0, const double marginl, const double marginb) { + std::stringstream &st = Content; - const int &nEdges = Th.neb; + const int &nEdges = Th.neb; - st << "q\n"; - st << PLOTPDFVAR::EDGE_WIDTH << " w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - st << "0 0 0 RG\n"; + st << "q\n"; + st << PLOTPDFVAR::EDGE_WIDTH << " w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; + st << "0 0 0 RG\n"; - for(int k = 0; k < nEdges; k++){ + for (int k = 0; k < nEdges; k++) { - const int &v0 = Th( Th.bedges[k][0] ); - const int &v1 = Th( Th.bedges[k][1] ); + const int &v0 = Th(Th.bedges[k][0]); + const int &v1 = Th(Th.bedges[k][1]); - // S : stroke, without closepath, s : closepath and stroke - st << scale*ar*(Th(v0).x-x0) << ' ' << scale*(Th(v0).y-y0) << " m " - << scale*ar*(Th(v1).x-x0) << ' ' << scale*(Th(v1).y-y0) << " l S" << std::endl; - } + // S : stroke, without closepath, s : closepath and stroke + st << scale * ar * (Th(v0).x - x0) << ' ' << scale * (Th(v0).y - y0) << " m " << scale * ar * (Th(v1).x - x0) << ' ' << scale * (Th(v1).y - y0) << " l S" << std::endl; + } - st << "Q\n"; + st << "Q\n"; - return; + return; } -void find_isoline_values( std::vector &isoline_val, const double fmax, const double fmin, - const int NISOLINES, const KN*const viso, const bool logscale ) -{ - if( viso ){ +void find_isoline_values(std::vector< double > &isoline_val, const double fmax, const double fmin, const int NISOLINES, const KN< double > *const viso, const bool logscale) { + if (viso) { - for(int m = 0; m < viso->size(); m++) - isoline_val.push_back( (*viso)[m] ); + for (int m = 0; m < viso->size( ); m++) isoline_val.push_back((*viso)[m]); - } else if( logscale && (fmin > 0) ) { + } else if (logscale && (fmin > 0)) { - // fmin * step^N = fmax <=> step^N = fmax/fmin - // <=> N = log_{step}(fmax/fmin) = (log(fmax/fmin))/log(step) - // <=> log(step) = (1/N)(log(fmax/fmin)) - // <=> step = exp( (1/N)(log(fmax/fmin)) ) - const double df = exp( (static_cast(1)/NISOLINES)*(log(fmax/fmin)) ); + // fmin * step^N = fmax <=> step^N = fmax/fmin + // <=> N = log_{step}(fmax/fmin) = (log(fmax/fmin))/log(step) + // <=> log(step) = (1/N)(log(fmax/fmin)) + // <=> step = exp( (1/N)(log(fmax/fmin)) ) + const double df = exp((static_cast< double >(1) / NISOLINES) * (log(fmax / fmin))); - isoline_val.push_back( fmin*sqrt(df) ); - for(int m = 1; m < NISOLINES; m++) - isoline_val.push_back( isoline_val[m-1] * df ); + isoline_val.push_back(fmin * sqrt(df)); + for (int m = 1; m < NISOLINES; m++) isoline_val.push_back(isoline_val[m - 1] * df); - } else { - - if( logscale ) - std::cout << "plotPDF(): logscale for non-positive values.\n"; + } else { + + if (logscale) std::cout << "plotPDF(): logscale for non-positive values.\n"; #if 1 - const double df = (fmax - fmin) / NISOLINES; - for(int m = 0; m < NISOLINES; m++) - isoline_val.push_back( fmin + df/2 + m*df ); + const double df = (fmax - fmin) / NISOLINES; + for (int m = 0; m < NISOLINES; m++) isoline_val.push_back(fmin + df / 2 + m * df); #else - const double df = (fmax - fmin) / (NISOLINES+1); - for(int m = 0; m < NISOLINES; m++) - isoline_val.push_back( fmin + (m+1)*df ); + const double df = (fmax - fmin) / (NISOLINES + 1); + for (int m = 0; m < NISOLINES; m++) isoline_val.push_back(fmin + (m + 1) * df); #endif - } + } - return; + return; } -void drawLegend_contour( std::stringstream &Content, const vector &isoline_val, - const int prec, const KNM &palette, - const double cmin, const double cmax, - const bool monochrome, const bool logscale, - const double sizex, const double textfontsize, - const double scale, const double y1, const double y0, - const double marginl, const double marginb ) -{ - std::stringstream &st = Content; +void drawLegend_contour(std::stringstream &Content, const vector< double > &isoline_val, const int prec, const KNM< double > &palette, const double cmin, const double cmax, const bool monochrome, + const bool logscale, const double sizex, const double textfontsize, const double scale, const double y1, const double y0, const double marginl, const double marginb) { + std::stringstream &st = Content; - st << "q\n"; - st << "1 w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; + st << "q\n"; + st << "1 w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - for(size_t m = 0; m < isoline_val.size(); m++){ + for (size_t m = 0; m < isoline_val.size( ); m++) { - const double &f = isoline_val[m]; + const double &f = isoline_val[m]; - setrgbcolor(st, f, palette, cmin, cmax, monochrome, logscale); - st << "rg\n"; + setrgbcolor(st, f, palette, cmin, cmax, monochrome, logscale); + st << "rg\n"; - st << "BT /F1 " << textfontsize << " Tf " - << "1 0 0 1 " << sizex-PLOTPDFVAR::PADDING << " " << (m+1)*(scale*(y1-y0)-textfontsize)/(isoline_val.size()+1) << " Tm " - << "(" << ((f >= 0)? "\\ ": ""); + st << "BT /F1 " << textfontsize << " Tf " + << "1 0 0 1 " << sizex - PLOTPDFVAR::PADDING << " " << (m + 1) * (scale * (y1 - y0) - textfontsize) / (isoline_val.size( ) + 1) << " Tm " + << "(" << ((f >= 0) ? "\\ " : ""); - if( (fabs(f) > 1e-3) || (fabs(f) < 1e-12) ){ - st << std::setprecision(prec) << std::setfill('0') << f << ") Tj ET\n"; - } else { - st << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) - << std::setprecision(prec) << f << resetiosflags(std::ios::scientific) - << std::setiosflags(std::ios::fixed) << ") Tj ET\n"; - } + if ((fabs(f) > 1e-3) || (fabs(f) < 1e-12)) { + st << std::setprecision(prec) << std::setfill('0') << f << ") Tj ET\n"; + } else { + st << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) << std::setprecision(prec) << f << resetiosflags(std::ios::scientific) << std::setiosflags(std::ios::fixed) + << ") Tj ET\n"; } + } - st << "Q\n"; + st << "Q\n"; - return; + return; } -void drawLegend_fill( std::stringstream &Content, const int nbfill, const double df, - const int prec, const KNM &palette, - const double fmin, const double fmax, - const bool monochrome, const bool logscale, - const double sizex, const double textfontsize, - const double scale, const double y1, const double y0, - const double marginl, const double marginb ) -{ - std::stringstream &st = Content; - st << "q\n"; - st << "1 w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - - const double dy = scale*(y1-y0)/nbfill; +void drawLegend_fill(std::stringstream &Content, const int nbfill, const double df, const int prec, const KNM< double > &palette, const double fmin, const double fmax, const bool monochrome, + const bool logscale, const double sizex, const double textfontsize, const double scale, const double y1, const double y0, const double marginl, const double marginb) { + std::stringstream &st = Content; + st << "q\n"; + st << "1 w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - for(int m = 0; m < nbfill; m++){ + const double dy = scale * (y1 - y0) / nbfill; - if( m == 0 ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( m == nbfill-1 ){ - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); - } else { - const double f = (logscale)? fmin * pow(df,m+0.5): fmin + (m+0.5)*df; - setrgbcolor(st, f, palette, fmin, fmax, monochrome, logscale); - } - st << "rg\n"; + for (int m = 0; m < nbfill; m++) { - st << sizex-PLOTPDFVAR::PADDING << " " << m*dy << " m " - << sizex-PLOTPDFVAR::PADDING/2 << " " << m*dy << " l " - << sizex-PLOTPDFVAR::PADDING/2 << " " << (m+1)*dy << " l " - << sizex-PLOTPDFVAR::PADDING << " " << (m+1)*dy << " l f\n"; + if (m == 0) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (m == nbfill - 1) { + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + } else { + const double f = (logscale) ? fmin * pow(df, m + 0.5) : fmin + (m + 0.5) * df; + setrgbcolor(st, f, palette, fmin, fmax, monochrome, logscale); } + st << "rg\n"; - const double EPS = 1e-10; - const double dl = (logscale)? - pow( fmax/fmin, static_cast(1)/(PLOTPDFVAR::NUM_LABELS-1) ): - (fmax-fmin)/(PLOTPDFVAR::NUM_LABELS-1); + st << sizex - PLOTPDFVAR::PADDING << " " << m * dy << " m " << sizex - PLOTPDFVAR::PADDING / 2 << " " << m * dy << " l " << sizex - PLOTPDFVAR::PADDING / 2 << " " << (m + 1) * dy << " l " + << sizex - PLOTPDFVAR::PADDING << " " << (m + 1) * dy << " l f\n"; + } - for(int m = 0; m < PLOTPDFVAR::NUM_LABELS; m++){ + const double EPS = 1e-10; + const double dl = (logscale) ? pow(fmax / fmin, static_cast< double >(1) / (PLOTPDFVAR::NUM_LABELS - 1)) : (fmax - fmin) / (PLOTPDFVAR::NUM_LABELS - 1); - const double f = (logscale)? fmin * pow(dl,m): fmin + m*dl; + for (int m = 0; m < PLOTPDFVAR::NUM_LABELS; m++) { - if( logscale ){ + const double f = (logscale) ? fmin * pow(dl, m) : fmin + m * dl; - if( f <= fmin*df ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( f >= fmax/df ){ - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); - } else { - const double dc = pow( fmax/fmin, static_cast(1)/nbfill ); - const int mc = static_cast( log(f/fmin) / log(dc) ); - const double c = fmin * pow(dc, mc+0.5); - setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); - } + if (logscale) { - } else { + if (f <= fmin * df) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (f >= fmax / df) { + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + } else { + const double dc = pow(fmax / fmin, static_cast< double >(1) / nbfill); + const int mc = static_cast< int >(log(f / fmin) / log(dc)); + const double c = fmin * pow(dc, mc + 0.5); + setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); + } - if( f <= fmin+df ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( f >= fmax-df ){ - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); - } else { - const double dc = (fmax-fmin) / nbfill; - const int mc = static_cast( (f-fmin)/dc ); - const double c = fmin + (mc+0.5)*dc; - setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); - } - } - st << " rg\n"; + } else { + + if (f <= fmin + df) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (f >= fmax - df) { + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + } else { + const double dc = (fmax - fmin) / nbfill; + const int mc = static_cast< int >((f - fmin) / dc); + const double c = fmin + (mc + 0.5) * dc; + setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); + } + } + st << " rg\n"; - st << "BT /F1 " << textfontsize << " Tf " - << "1 0 0 1 " << sizex << " " << m*(scale*(y1-y0)-textfontsize)/(PLOTPDFVAR::NUM_LABELS-1) << " Tm " - << "(" << ((f >= 0)? "\\ ": ""); + st << "BT /F1 " << textfontsize << " Tf " + << "1 0 0 1 " << sizex << " " << m * (scale * (y1 - y0) - textfontsize) / (PLOTPDFVAR::NUM_LABELS - 1) << " Tm " + << "(" << ((f >= 0) ? "\\ " : ""); - if( (fabs(f) > 1e-3) || (fabs(f) < 1e-12) ){ - st << std::setprecision(prec) << std::setfill('0') << f << ") Tj ET\n"; - } else { - st << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) - << std::setprecision(prec) << f << resetiosflags(std::ios::scientific) - << std::setiosflags(std::ios::fixed) << ") Tj ET\n"; - } + if ((fabs(f) > 1e-3) || (fabs(f) < 1e-12)) { + st << std::setprecision(prec) << std::setfill('0') << f << ") Tj ET\n"; + } else { + st << std::resetiosflags(std::ios::fixed) << std::setiosflags(std::ios::scientific) << std::setprecision(prec) << f << resetiosflags(std::ios::scientific) << std::setiosflags(std::ios::fixed) + << ") Tj ET\n"; } + } - st << "Q\n"; + st << "Q\n"; - return; + return; } //---------------------------------------------------------------------- -void plot_mesh( std::stringstream &Content, const Fem2D::Mesh &Th, - const double scale, const double ar, const double x0, const double y0, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const double withmesh, const double linewidth, - const bool idcell, const bool idvert, const int idedge, - const int mode = 0) -{ - // mode == 0 (default) : without index - // mode == 1 : FreeFEM index - // mode == 2 : Boundary Label - enum { MODE_NOLABEL = 0, MODE_INDEX = 1, MODE_BELABEL = 2 }; - - const int nVertices = Th.nv; - const int nElements = Th.nt; - const int nEdges = Th.neb; - const double &r = scale; - - std::stringstream &st = Content; - st.str(""); - - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - st << linewidth << " w\n"; // setlinewidth - - //------------------------------ - // vertices - //------------------------------ - if( (mode == MODE_INDEX) && idvert ){ - - if(monochrome) - st << PLOTPDFVAR::DEFAULT_IDVERT_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_MONO[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDVERT_MONO[2] << " rg\n" << std::endl; - else - st << PLOTPDFVAR::DEFAULT_IDVERT_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_RGB[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDVERT_RGB[2] << " rg\n" << std::endl; - - int id = mode; - - st << "BT\n"; - st << "/F1 " << textfontsize << " Tf\n"; - for(int n = 0; n < nVertices; n++){ - - st << "1 0 0 1 " << r*ar*(Th(n).x-x0) << ' ' << r*(Th(n).y-y0) << " Tm " - << "(" << id << ") Tj\n"; - id++; - } - st << "ET\n"; - } +void plot_mesh(std::stringstream &Content, const Fem2D::Mesh &Th, const double scale, const double ar, const double x0, const double y0, const int marginl, const int marginb, + const double textfontsize, const bool monochrome, const double withmesh, const double linewidth, const bool idcell, const bool idvert, const int idedge, const int mode = 0) { + // mode == 0 (default) : without index + // mode == 1 : FreeFEM index + // mode == 2 : Boundary Label + enum { MODE_NOLABEL = 0, MODE_INDEX = 1, MODE_BELABEL = 2 }; - //------------------------------ - // element (triangle) - //------------------------------ - if( mode == MODE_BELABEL ){ + const int nVertices = Th.nv; + const int nElements = Th.nt; + const int nEdges = Th.neb; + const double &r = scale; - const double grayscale0 = (withmesh < 0)? 0: withmesh; - const double grayscale1 = (withmesh < 1)? withmesh: 1; - const double grayscale = 1-grayscale1; + std::stringstream &st = Content; + st.str(""); - st << grayscale << ' ' << grayscale << ' ' << grayscale << " RG\n"; + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; + st << linewidth << " w\n"; // setlinewidth - } else { - st << "0 0 0 RG\n"; // black - } - for(int n = 0; n < nElements; n++){ + //------------------------------ + // vertices + //------------------------------ + if ((mode == MODE_INDEX) && idvert) { - const int &v0 = Th(n,0); - const int &v1 = Th(n,1); - const int &v2 = Th(n,2); + if (monochrome) + st << PLOTPDFVAR::DEFAULT_IDVERT_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_MONO[1] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_MONO[2] << " rg\n" << std::endl; + else + st << PLOTPDFVAR::DEFAULT_IDVERT_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_RGB[1] << ' ' << PLOTPDFVAR::DEFAULT_IDVERT_RGB[2] << " rg\n" << std::endl; - st << r*ar*(Th(v0).x-x0) << ' ' << r*(Th(v0).y-y0) << " m "; - st << r*ar*(Th(v1).x-x0) << ' ' << r*(Th(v1).y-y0) << " l "; - st << r*ar*(Th(v2).x-x0) << ' ' << r*(Th(v2).y-y0) << " l "; - st << "s" << std::endl; - } + int id = mode; - if( (mode == MODE_INDEX) && idcell ){ - - if(monochrome) - st << PLOTPDFVAR::DEFAULT_IDCELL_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_MONO[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDCELL_MONO[2] << " rg\n" << std::endl; - else - st << PLOTPDFVAR::DEFAULT_IDCELL_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_RGB[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDCELL_RGB[2] << " rg\n" << std::endl; - - int id = mode; - st << "BT\n"; - st << "/F1 " << textfontsize << " Tf\n"; - - for(int n = 0; n < nElements; n++){ - - const Fem2D::Triangle &t = Th[n]; - const Fem2D::R2 g = ( t[0] + t[1] + t[2] ) / 3; - - st << "1 0 0 1 " << r*ar*(g.x-x0) << ' ' << r*(g.y-y0) << " Tm " - << "(" << id << ") Tj\n"; // show - id++; - } - st << "ET\n"; - } + st << "BT\n"; + st << "/F1 " << textfontsize << " Tf\n"; + for (int n = 0; n < nVertices; n++) { - //------------------------------ - // sides (edges) on the boundary - //------------------------------ - if( (mode == MODE_INDEX) || (mode == MODE_BELABEL) ){ - - if(monochrome) - st << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[2] << " RG\n" << std::endl; - else - st << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[2] << " RG\n" << std::endl; + st << "1 0 0 1 " << r * ar * (Th(n).x - x0) << ' ' << r * (Th(n).y - y0) << " Tm " + << "(" << id << ") Tj\n"; + id++; } + st << "ET\n"; + } + + //------------------------------ + // element (triangle) + //------------------------------ + if (mode == MODE_BELABEL) { + + const double grayscale0 = (withmesh < 0) ? 0 : withmesh; + const double grayscale1 = (withmesh < 1) ? withmesh : 1; + const double grayscale = 1 - grayscale1; + + st << grayscale << ' ' << grayscale << ' ' << grayscale << " RG\n"; + + } else { + st << "0 0 0 RG\n"; // black + } + for (int n = 0; n < nElements; n++) { + + const int &v0 = Th(n, 0); + const int &v1 = Th(n, 1); + const int &v2 = Th(n, 2); + + st << r * ar * (Th(v0).x - x0) << ' ' << r * (Th(v0).y - y0) << " m "; + st << r * ar * (Th(v1).x - x0) << ' ' << r * (Th(v1).y - y0) << " l "; + st << r * ar * (Th(v2).x - x0) << ' ' << r * (Th(v2).y - y0) << " l "; + st << "s" << std::endl; + } + + if ((mode == MODE_INDEX) && idcell) { - for(int n = 0; n < nEdges; n++){ + if (monochrome) + st << PLOTPDFVAR::DEFAULT_IDCELL_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_MONO[1] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_MONO[2] << " rg\n" << std::endl; + else + st << PLOTPDFVAR::DEFAULT_IDCELL_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_RGB[1] << ' ' << PLOTPDFVAR::DEFAULT_IDCELL_RGB[2] << " rg\n" << std::endl; + + int id = mode; + st << "BT\n"; + st << "/F1 " << textfontsize << " Tf\n"; + + for (int n = 0; n < nElements; n++) { - const int &v0 = Th( Th.bedges[n][0] ); - const int &v1 = Th( Th.bedges[n][1] ); + const Fem2D::Triangle &t = Th[n]; + const Fem2D::R2 g = (t[0] + t[1] + t[2]) / 3; - st << r*ar*(Th(v0).x-x0) << ' ' << r*(Th(v0).y-y0) << " m " - << r*ar*(Th(v1).x-x0) << ' ' << r*(Th(v1).y-y0) << " l S\n"; + st << "1 0 0 1 " << r * ar * (g.x - x0) << ' ' << r * (g.y - y0) << " Tm " + << "(" << id << ") Tj\n"; // show + id++; } + st << "ET\n"; + } + + //------------------------------ + // sides (edges) on the boundary + //------------------------------ + if ((mode == MODE_INDEX) || (mode == MODE_BELABEL)) { + + if (monochrome) + st << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[1] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[2] << " RG\n" << std::endl; + else + st << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[1] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[2] << " RG\n" << std::endl; + } - if( ((mode == MODE_INDEX) && idedge) || (mode == MODE_BELABEL) ){ + for (int n = 0; n < nEdges; n++) { - if(monochrome) - st << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[2] << " rg\n" << std::endl; - else - st << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[1] << ' ' - << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[2] << " rg\n" << std::endl; + const int &v0 = Th(Th.bedges[n][0]); + const int &v1 = Th(Th.bedges[n][1]); - int id = mode; + st << r * ar * (Th(v0).x - x0) << ' ' << r * (Th(v0).y - y0) << " m " << r * ar * (Th(v1).x - x0) << ' ' << r * (Th(v1).y - y0) << " l S\n"; + } - st << "BT\n"; - st << "/F1 " << textfontsize << " Tf\n"; + if (((mode == MODE_INDEX) && idedge) || (mode == MODE_BELABEL)) { - for(int n = 0; n < nEdges; n++){ + if (monochrome) + st << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[1] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_MONO[2] << " rg\n" << std::endl; + else + st << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[0] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[1] << ' ' << PLOTPDFVAR::DEFAULT_IDEDGE_RGB[2] << " rg\n" << std::endl; + + int id = mode; - const int &v0 = Th( Th.bedges[n][0] ); - const int &v1 = Th( Th.bedges[n][1] ); + st << "BT\n"; + st << "/F1 " << textfontsize << " Tf\n"; - const double mx = ( Th(v0).x + Th(v1).x ) / 2; - const double my = ( Th(v0).y + Th(v1).y ) / 2; + for (int n = 0; n < nEdges; n++) { - if(mode == MODE_INDEX){ + const int &v0 = Th(Th.bedges[n][0]); + const int &v1 = Th(Th.bedges[n][1]); - st << "1 0 0 1 " << r*ar*(mx-x0) << " " << r*(my-y0) << " Tm " - << "(" << id << ") Tj\n"; + const double mx = (Th(v0).x + Th(v1).x) / 2; + const double my = (Th(v0).y + Th(v1).y) / 2; - } else if(mode == MODE_BELABEL){ + if (mode == MODE_INDEX) { - st << "1 0 0 1 " << r*ar*(mx-x0) << " " << r*(my-y0) << " Tm " - << "(" << Th.be(n) << ") Tj\n"; // same as Th.bedges[n] - } - id++; - } - st << "ET\n"; + st << "1 0 0 1 " << r * ar * (mx - x0) << " " << r * (my - y0) << " Tm " + << "(" << id << ") Tj\n"; + + } else if (mode == MODE_BELABEL) { + + st << "1 0 0 1 " << r * ar * (mx - x0) << " " << r * (my - y0) << " Tm " + << "(" << Th.be(n) << ") Tj\n"; // same as Th.bedges[n] + } + id++; } + st << "ET\n"; + } - st << "Q\n"; - return; -} // + st << "Q\n"; + return; +} // //--------------------------------------------------------------------------- // P1 Finite Element (also used in P1nc : Non-Conforming Finite Element) //--------------------------------------------------------------------------- -void trackP1isoline( std::vector &px, std::vector &py, - const double *const vx, const double *const vy, - const double value, const double *const vf ) -{ - const double TOLERANCE = 1e-12; - - const int nVertices_in_each_Element = 3; - - for(int i = 0; i < nVertices_in_each_Element; i++){ - - const double &x0 = vx[i]; - const double &y0 = vy[i]; - const double &f0 = vf[i]; - - const double &x1 = vx[(i+1)%3]; - const double &y1 = vy[(i+1)%3]; - const double &f1 = vf[(i+1)%3]; - - if( (value < f0) && (value < f1) ) // no cossing point - continue; - - if( (f0 < value) && (f1 < value) ) // no crossing point - continue; - - if( (fabs(f0-f1) < TOLERANCE) && (fabs(f0-value) < TOLERANCE) ){ // coinside: edge is isoline - px.push_back( x0 ); - py.push_back( y0 ); - px.push_back( x1 ); - py.push_back( y1 ); - continue; - } +void trackP1isoline(std::vector< double > &px, std::vector< double > &py, const double *const vx, const double *const vy, const double value, const double *const vf) { + const double TOLERANCE = 1e-12; + + const int nVertices_in_each_Element = 3; + + for (int i = 0; i < nVertices_in_each_Element; i++) { - const double t = (value-f0)/(f1-f0); // (1-t)*f0 + t*f1 = value - const double x = (1-t)*x0 + t*x1; - const double y = (1-t)*y0 + t*y1; + const double &x0 = vx[i]; + const double &y0 = vy[i]; + const double &f0 = vf[i]; - px.push_back( x ); - py.push_back( y ); + const double &x1 = vx[(i + 1) % 3]; + const double &y1 = vy[(i + 1) % 3]; + const double &f1 = vf[(i + 1) % 3]; + + if ((value < f0) && (value < f1)) // no cossing point + continue; + + if ((f0 < value) && (f1 < value)) // no crossing point + continue; + + if ((fabs(f0 - f1) < TOLERANCE) && (fabs(f0 - value) < TOLERANCE)) { // coinside: edge is isoline + px.push_back(x0); + py.push_back(y0); + px.push_back(x1); + py.push_back(y1); + continue; } - if( px.size() == 3 ){ // if f(x,y)==value on either vertex + const double t = (value - f0) / (f1 - f0); // (1-t)*f0 + t*f1 = value + const double x = (1 - t) * x0 + t * x1; + const double y = (1 - t) * y0 + t * y1; - if( (px[0] == px[1]) && (py[0] == py[1]) ){ - px[1] = px[2]; - py[1] = py[2]; - } + px.push_back(x); + py.push_back(y); + } - //if( (px[1] == px[2]) && (py[1] == py[2]) ) // node 0 is differ from node 1 - //if( (px[2] == px[0]) && (py[2] == py[0]) ) // node 0 is differ from node 1 + if (px.size( ) == 3) { // if f(x,y)==value on either vertex + + if ((px[0] == px[1]) && (py[0] == py[1])) { + px[1] = px[2]; + py[1] = py[2]; } - return; + // if( (px[1] == px[2]) && (py[1] == py[2]) ) // node 0 is differ from node 1 + // if( (px[2] == px[0]) && (py[2] == py[0]) ) // node 0 is differ from node 1 + } + + return; } -void plot_P1_isoline_body( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P1, - const std::vector &isoline_val, const double cmin, const double cmax, - const KNM &palette, const double scale, const double ar, - const double x0, const double y0, - const int marginl, const int marginb, - const bool monochrome, const bool logscale, - const int NISOLINES, const double linewidth ) -{ - std::stringstream &st = Content; +void plot_P1_isoline_body(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P1, const std::vector< double > &isoline_val, const double cmin, const double cmax, + const KNM< double > &palette, const double scale, const double ar, const double x0, const double y0, const int marginl, const int marginb, const bool monochrome, + const bool logscale, const int NISOLINES, const double linewidth) { + std::stringstream &st = Content; - st << "q\n"; - st << linewidth << " w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; + st << "q\n"; + st << linewidth << " w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - const int &nTriangles = Th.nt; - for(int k = 0; k < nTriangles; k++){ + const int &nTriangles = Th.nt; + for (int k = 0; k < nTriangles; k++) { - const int &v0 = Th(k,0); - const int &v1 = Th(k,1); - const int &v2 = Th(k,2); + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - const double vx[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double vy[] = { Th(v0).y, Th(v1).y, Th(v2).y }; - const double vf[] = { f_P1[3*k+0], f_P1[3*k+1], f_P1[3*k+2] }; + const double vx[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double vy[] = {Th(v0).y, Th(v1).y, Th(v2).y}; + const double vf[] = {f_P1[3 * k + 0], f_P1[3 * k + 1], f_P1[3 * k + 2]}; - for(size_t m = 0; m < isoline_val.size(); m++){ + for (size_t m = 0; m < isoline_val.size( ); m++) { - const double &value = isoline_val[m]; + const double &value = isoline_val[m]; - std::vector px, py; - trackP1isoline( px, py, vx, vy, value, vf ); + std::vector< double > px, py; + trackP1isoline(px, py, vx, vy, value, vf); - assert( px.size() == py.size() ); + assert(px.size( ) == py.size( )); - if( px.size() == 0 ) continue; // goto next isoline_val + if (px.size( ) == 0) continue; // goto next isoline_val - setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); + setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); - if( px.size() > 3 ){ + if (px.size( ) > 3) { - // f(x,y)==value on all vertices, i.e. f(x,y) \equiv value on the triangle - st << "rg\n"; - st << scale*ar*(vx[0] - x0) << ' ' << scale*(vy[0] - y0) << " m " - << scale*ar*(vx[1] - x0) << ' ' << scale*(vy[1] - y0) << " l " - << scale*ar*(vx[2] - x0) << ' ' << scale*(vy[2] - y0) << " l f\n"; - - } else { + // f(x,y)==value on all vertices, i.e. f(x,y) \equiv value on the triangle + st << "rg\n"; + st << scale * ar * (vx[0] - x0) << ' ' << scale * (vy[0] - y0) << " m " << scale * ar * (vx[1] - x0) << ' ' << scale * (vy[1] - y0) << " l " << scale * ar * (vx[2] - x0) << ' ' + << scale * (vy[2] - y0) << " l f\n"; - // assert( (px.size() == 2) || (px.size() == 3) ); - st << "RG\n"; - st << scale*ar*(px[0] - x0) << ' ' << scale*(py[0] - y0) << " m " - << scale*ar*(px[1] - x0) << ' ' << scale*(py[1] - y0) << " l\n"; - st << "S\n"; - } - } + } else { + + // assert( (px.size() == 2) || (px.size() == 3) ); + st << "RG\n"; + st << scale * ar * (px[0] - x0) << ' ' << scale * (py[0] - y0) << " m " << scale * ar * (px[1] - x0) << ' ' << scale * (py[1] - y0) << " l\n"; + st << "S\n"; + } } - st << "Q\n"; + } + st << "Q\n"; - return; + return; } -void plot_P1_isoline( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P1, - const KNM &palette, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const int NISOLINES, const KN*const viso, - const double linewidth ) -{ - //------------------------------ - // values in plot - //------------------------------ - const double fmax = (viso)? viso->max(): f_P1.max(); - const double fmin = (viso)? viso->min(): f_P1.min(); - std::vector isoline_val; +void plot_P1_isoline(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P1, const KNM< double > &palette, const int sizex, const int sizey, const double scale, const double ar, + const double x0, const double y0, const double y1, const int marginl, const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, + const bool logscale, const double withmesh, const int NISOLINES, const KN< double > *const viso, const double linewidth) { + //------------------------------ + // values in plot + //------------------------------ + const double fmax = (viso) ? viso->max( ) : f_P1.max( ); + const double fmin = (viso) ? viso->min( ) : f_P1.min( ); + std::vector< double > isoline_val; - find_isoline_values( isoline_val, fmax, fmin, NISOLINES, viso, logscale ); + find_isoline_values(isoline_val, fmax, fmin, NISOLINES, viso, logscale); - // color/gray-scale range to plot + // color/gray-scale range to plot #if 0 // If user specifies an irrelevant color range (in viso array), const double cmax = *max_element( isoline_val.begin(), isoline_val.end() ); const double cmin = *min_element( isoline_val.begin(), isoline_val.end() ); #else - // map color/grayscale range to function values - const double cmax = fmax; - const double cmin = fmin; + // map color/grayscale range to function values + const double cmax = fmax; + const double cmin = fmin; #endif - std::stringstream &st = Content; - st.str(""); + std::stringstream &st = Content; + st.str(""); - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); - plot_P1_isoline_body( st, Th, f_P1, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, - marginl, marginb, monochrome, logscale, NISOLINES, linewidth ); + plot_P1_isoline_body(st, Th, f_P1, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, marginl, marginb, monochrome, logscale, NISOLINES, linewidth); - if( legend ) - drawLegend_contour( st, isoline_val, prec, palette, cmin, cmax, - monochrome, logscale, sizex, textfontsize, scale, - y1, y0, marginl, marginb); + if (legend) drawLegend_contour(st, isoline_val, prec, palette, cmin, cmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); - return; + return; } //---------------------------------------------------------------------- -void plot_P1_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P1_, - const KNM &palette, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const long nbfill, const KN *const frange ) -{ - const int &nVertices = Th.nv; - const int &nTriangles = Th.nt; - const int &nEdges = Th.neb; - const double &r = scale; - - const double fmax = (frange)? (*frange)[1]: f_P1_.max(); - const double fmin = (frange)? (*frange)[0]: f_P1_.min(); - const double df = (logscale)? - pow( fmax/fmin, static_cast(1)/nbfill ): - (fmax - fmin)/nbfill; - - std::stringstream &st = Content; - st.str(""); - - //------------------------------ - // element(triangle)-wise process - //------------------------------ - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - - double *const f_P1 = new double [ Th.nv ]; - for(int k = 0; k < nTriangles; k++){ - - const int &v0 = Th(k,0); const double &f0 = f_P1[v0]; - const int &v1 = Th(k,1); const double &f1 = f_P1[v1]; - const int &v2 = Th(k,2); const double &f2 = f_P1[v2]; - - f_P1[v0] = f_P1_[3*k+0]; f_P1[v1] = f_P1_[3*k+1]; f_P1[v2] = f_P1_[3*k+2]; - - // find minimum - int v_min = v2; - int end1 = v0; // destination point - int end2 = v1; // destination point - - if( (f0 <= f1) && (f0 <= f2) ){ - v_min = v0; - end1 = v1; - end2 = v2; - } else if( (f1 <= f0) && (f1 <= f2) ){ - v_min = v1; - end1 = v2; - end2 = v0; - } +void plot_P1_fill(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P1_, const KNM< double > &palette, const int sizex, const int sizey, const double scale, const double ar, + const double x0, const double y0, const double y1, const int marginl, const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, + const bool logscale, const double withmesh, const long nbfill, const KN< double > *const frange) { + const int &nVertices = Th.nv; + const int &nTriangles = Th.nt; + const int &nEdges = Th.neb; + const double &r = scale; + + const double fmax = (frange) ? (*frange)[1] : f_P1_.max( ); + const double fmin = (frange) ? (*frange)[0] : f_P1_.min( ); + const double df = (logscale) ? pow(fmax / fmin, static_cast< double >(1) / nbfill) : (fmax - fmin) / nbfill; + + std::stringstream &st = Content; + st.str(""); + + //------------------------------ + // element(triangle)-wise process + //------------------------------ + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; + + double *const f_P1 = new double[Th.nv]; + for (int k = 0; k < nTriangles; k++) { + + const int &v0 = Th(k, 0); + const double &f0 = f_P1[v0]; + const int &v1 = Th(k, 1); + const double &f1 = f_P1[v1]; + const int &v2 = Th(k, 2); + const double &f2 = f_P1[v2]; + + f_P1[v0] = f_P1_[3 * k + 0]; + f_P1[v1] = f_P1_[3 * k + 1]; + f_P1[v2] = f_P1_[3 * k + 2]; - if( frange && (fmax < f_P1[v_min]) ) - continue; - - if( frange && (f_P1[end1] < fmin) && (f_P1[end2] < fmin) ) - continue; - - int beg1 = v_min; // current point - int beg2 = v_min; // current point - double t1 = 0; // secting parameters on edge beg1--end1 - double t2 = 0; // secting parameters on edge beg2--end2 - - int level = (logscale)? - static_cast( log(f_P1[v_min]/fmin) / log(df) ): - static_cast( (f_P1[v_min]-fmin) / df ); - - double f = (logscale)? (pow(df,level) * fmin) : (level*df + fmin); - - if( frange && (f_P1[v_min] < fmin) ){ - - if( f_P1[end1] < fmin ){ - beg1 = end1; - end1 = end2; - } if( f_P1[end2] < fmin ){ - beg2 = end2; - end2 = end1; - } - - t1 = (fmin - f_P1[beg1]) / (f_P1[end1] - f_P1[beg1]); - t2 = (fmin - f_P1[beg2]) / (f_P1[end2] - f_P1[beg2]); - level = 0; - f = fmin; - } + // find minimum + int v_min = v2; + int end1 = v0; // destination point + int end2 = v1; // destination point + + if ((f0 <= f1) && (f0 <= f2)) { + v_min = v0; + end1 = v1; + end2 = v2; + } else if ((f1 <= f0) && (f1 <= f2)) { + v_min = v1; + end1 = v2; + end2 = v0; + } - do { - const double EPS = 1e-10; - if( (end1 == end2) && (t1 >= 1-EPS) && (t2 >= 1-EPS) ) - break; - - // find points which divide edges by t:(1-t1), t2:(1-t2) respectively - const double p1x = (1-t1)*Th(beg1).x + t1*Th(end1).x; - const double p1y = (1-t1)*Th(beg1).y + t1*Th(end1).y; - const double p2x = (1-t2)*Th(beg2).x + t2*Th(end2).x; - const double p2y = (1-t2)*Th(beg2).y + t2*Th(end2).y; - - const double f_next = (logscale)? f * df: f + df; - - if( frange && (fmax-EPS <= f) ) - break; - - if( level <= 0 ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( level >= nbfill-1 ){ - - // exceptional handling : if local minimum (in triangle) is - // already global maximum, then level == nbfill. - // Thus the condition is not level == nbfill-1, - // but level >= nbfill-1. - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); - - } else { - const double c = (logscale)? - (pow(df,level+0.5)*fmin): ((level+0.5)*df + fmin); - setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); - } - st << "rg\n"; - - if( (f_next >= f_P1[end1]) && (f_next >= f_P1[end2]) ){ - - st << r*ar*(p1x-x0) << ' ' << r*(p1y-y0) << " m " - << r*ar*(Th(end1).x-x0) << ' ' << r*(Th(end1).y-y0) << " l " - << r*ar*(Th(end2).x-x0) << ' ' << r*(Th(end2).y-y0) << " l " - << r*ar*(p2x-x0) << ' ' << r*(p2y-y0) << " l f\n"; - - break; - } - - if( f_next >= f_P1[end1] ){ - - st << r*ar*(p1x-x0) << ' ' << r*(p1y-y0) << " m " - << r*ar*(Th(end1).x-x0) << ' ' << r*(Th(end1).y-y0) << " l " - << r*ar*(p2x-x0) << ' ' << r*(p2y-y0) << " l f\n"; - - beg1 = end1; - end1 = end2; - t1 = 0; - continue; - } - - if( f_next >= f_P1[end2] ){ - - st << r*ar*(p1x-x0) << ' ' << r*(p1y-y0) << " m " - << r*ar*(Th(end2).x-x0) << ' ' << r*(Th(end2).y-y0) << " l " - << r*ar*(p2x-x0) << ' ' << r*(p2y-y0) << " l f\n"; - - beg2 = end2; - end2 = end1; - t2 = 0; - continue; - } - - const double t1_next = (f_next - f_P1[beg1]) / (f_P1[end1] - f_P1[beg1]); - const double t2_next = (f_next - f_P1[beg2]) / (f_P1[end2] - f_P1[beg2]); - - const double q1x = (1-t1_next)*Th(beg1).x + t1_next*Th(end1).x; - const double q1y = (1-t1_next)*Th(beg1).y + t1_next*Th(end1).y; - const double q2x = (1-t2_next)*Th(beg2).x + t2_next*Th(end2).x; - const double q2y = (1-t2_next)*Th(beg2).y + t2_next*Th(end2).y; - - st << r*ar*(p1x-x0) << ' ' << r*(p1y-y0) << " m " - << r*ar*(q1x-x0) << ' ' << r*(q1y-y0) << " l " - << r*ar*(q2x-x0) << ' ' << r*(q2y-y0) << " l " - << r*ar*(p2x-x0) << ' ' << r*(p2y-y0) << " l f\n"; - - // update - f = f_next; - level++; - t1 = t1_next; - t2 = t2_next; - } while(level <= nbfill); - - } // element(triangle)-wise process - - delete [] f_P1; - - st << "Q\n"; - - if( legend ) - drawLegend_fill( st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, - sizex, textfontsize, scale, y1, y0, marginl, marginb ); - - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); - - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + if (frange && (fmax < f_P1[v_min])) continue; - return; -} // + if (frange && (f_P1[end1] < fmin) && (f_P1[end2] < fmin)) continue; + + int beg1 = v_min; // current point + int beg2 = v_min; // current point + double t1 = 0; // secting parameters on edge beg1--end1 + double t2 = 0; // secting parameters on edge beg2--end2 + + int level = (logscale) ? static_cast< int >(log(f_P1[v_min] / fmin) / log(df)) : static_cast< int >((f_P1[v_min] - fmin) / df); + + double f = (logscale) ? (pow(df, level) * fmin) : (level * df + fmin); + + if (frange && (f_P1[v_min] < fmin)) { + + if (f_P1[end1] < fmin) { + beg1 = end1; + end1 = end2; + } + if (f_P1[end2] < fmin) { + beg2 = end2; + end2 = end1; + } + + t1 = (fmin - f_P1[beg1]) / (f_P1[end1] - f_P1[beg1]); + t2 = (fmin - f_P1[beg2]) / (f_P1[end2] - f_P1[beg2]); + level = 0; + f = fmin; + } + + do { + const double EPS = 1e-10; + if ((end1 == end2) && (t1 >= 1 - EPS) && (t2 >= 1 - EPS)) break; + + // find points which divide edges by t:(1-t1), t2:(1-t2) respectively + const double p1x = (1 - t1) * Th(beg1).x + t1 * Th(end1).x; + const double p1y = (1 - t1) * Th(beg1).y + t1 * Th(end1).y; + const double p2x = (1 - t2) * Th(beg2).x + t2 * Th(end2).x; + const double p2y = (1 - t2) * Th(beg2).y + t2 * Th(end2).y; + + const double f_next = (logscale) ? f * df : f + df; + + if (frange && (fmax - EPS <= f)) break; + + if (level <= 0) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (level >= nbfill - 1) { + + // exceptional handling : if local minimum (in triangle) is + // already global maximum, then level == nbfill. + // Thus the condition is not level == nbfill-1, + // but level >= nbfill-1. + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + + } else { + const double c = (logscale) ? (pow(df, level + 0.5) * fmin) : ((level + 0.5) * df + fmin); + setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); + } + st << "rg\n"; + + if ((f_next >= f_P1[end1]) && (f_next >= f_P1[end2])) { + + st << r * ar * (p1x - x0) << ' ' << r * (p1y - y0) << " m " << r * ar * (Th(end1).x - x0) << ' ' << r * (Th(end1).y - y0) << " l " << r * ar * (Th(end2).x - x0) << ' ' << r * (Th(end2).y - y0) + << " l " << r * ar * (p2x - x0) << ' ' << r * (p2y - y0) << " l f\n"; + + break; + } + + if (f_next >= f_P1[end1]) { + + st << r * ar * (p1x - x0) << ' ' << r * (p1y - y0) << " m " << r * ar * (Th(end1).x - x0) << ' ' << r * (Th(end1).y - y0) << " l " << r * ar * (p2x - x0) << ' ' << r * (p2y - y0) << " l f\n"; + + beg1 = end1; + end1 = end2; + t1 = 0; + continue; + } + + if (f_next >= f_P1[end2]) { + + st << r * ar * (p1x - x0) << ' ' << r * (p1y - y0) << " m " << r * ar * (Th(end2).x - x0) << ' ' << r * (Th(end2).y - y0) << " l " << r * ar * (p2x - x0) << ' ' << r * (p2y - y0) << " l f\n"; + + beg2 = end2; + end2 = end1; + t2 = 0; + continue; + } + + const double t1_next = (f_next - f_P1[beg1]) / (f_P1[end1] - f_P1[beg1]); + const double t2_next = (f_next - f_P1[beg2]) / (f_P1[end2] - f_P1[beg2]); + + const double q1x = (1 - t1_next) * Th(beg1).x + t1_next * Th(end1).x; + const double q1y = (1 - t1_next) * Th(beg1).y + t1_next * Th(end1).y; + const double q2x = (1 - t2_next) * Th(beg2).x + t2_next * Th(end2).x; + const double q2y = (1 - t2_next) * Th(beg2).y + t2_next * Th(end2).y; + + st << r * ar * (p1x - x0) << ' ' << r * (p1y - y0) << " m " << r * ar * (q1x - x0) << ' ' << r * (q1y - y0) << " l " << r * ar * (q2x - x0) << ' ' << r * (q2y - y0) << " l " + << r * ar * (p2x - x0) << ' ' << r * (p2y - y0) << " l f\n"; + + // update + f = f_next; + level++; + t1 = t1_next; + t2 = t2_next; + } while (level <= nbfill); + + } // element(triangle)-wise process + + delete[] f_P1; + + st << "Q\n"; + + if (legend) drawLegend_fill(st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); + + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); + + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); + + return; +} // //---------------------------------------------------------------------- // P0 Finite Element //---------------------------------------------------------------------- -void plot_P0_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P0, - const KNM &palette, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const long nbfill, const KN *const frange ) -{ - const int &nVertices = Th.nv; - const int &nTriangles = Th.nt; - const int &nEdges = Th.neb; - const double &r = scale; - - const double fmax = (frange)? (*frange)[1]: f_P0.max(); - const double fmin = (frange)? (*frange)[0]: f_P0.min(); - const double df = (logscale)? - exp( (static_cast(1)/nbfill)*(log(fmax/fmin)) ): - (fmax - fmin)/nbfill; - - std::stringstream &st = Content; - st.str(""); - - //------------------------------ - // element(triangle)-wise process - //------------------------------ - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - - for(int k = 0; k < nTriangles; k++){ - - const int &v0 = Th(k,0); - const int &v1 = Th(k,1); - const int &v2 = Th(k,2); - - const double &f = f_P0[k]; - - if( frange && (f < fmin) ) - continue; - if( frange && (f > fmax) ) - continue; - - int level = (logscale)? - static_cast( log(f/fmin) / log(df) ): - static_cast( (f-fmin) / df ); - - if( level == 0 ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( level >= nbfill-1 ){ - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); - } else { - const double c = (logscale)? (pow(df,level+0.5)*fmin): ((level+0.5)*df + fmin); - setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); - } - st << "rg\n"; - - st << r*ar*(Th(v0).x-x0) << ' ' << r*(Th(v0).y-y0) << " m " - << r*ar*(Th(v1).x-x0) << ' ' << r*(Th(v1).y-y0) << " l " - << r*ar*(Th(v2).x-x0) << ' ' << r*(Th(v2).y-y0) << " l f\n"; +void plot_P0_fill(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P0, const KNM< double > &palette, const int sizex, const int sizey, const double scale, const double ar, + const double x0, const double y0, const double y1, const int marginl, const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, + const bool logscale, const double withmesh, const long nbfill, const KN< double > *const frange) { + const int &nVertices = Th.nv; + const int &nTriangles = Th.nt; + const int &nEdges = Th.neb; + const double &r = scale; - } // element(triangle)-wise process + const double fmax = (frange) ? (*frange)[1] : f_P0.max( ); + const double fmin = (frange) ? (*frange)[0] : f_P0.min( ); + const double df = (logscale) ? exp((static_cast< double >(1) / nbfill) * (log(fmax / fmin))) : (fmax - fmin) / nbfill; - st << "Q\n"; + std::stringstream &st = Content; + st.str(""); - if( legend ) - drawLegend_fill( st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, - sizex, textfontsize, scale, y1, y0, marginl, marginb ); + //------------------------------ + // element(triangle)-wise process + //------------------------------ + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); + for (int k = 0; k < nTriangles; k++) { - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - return; -} // + const double &f = f_P0[k]; + + if (frange && (f < fmin)) continue; + if (frange && (f > fmax)) continue; + + int level = (logscale) ? static_cast< int >(log(f / fmin) / log(df)) : static_cast< int >((f - fmin) / df); + + if (level == 0) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (level >= nbfill - 1) { + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + } else { + const double c = (logscale) ? (pow(df, level + 0.5) * fmin) : ((level + 0.5) * df + fmin); + setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); + } + st << "rg\n"; + + st << r * ar * (Th(v0).x - x0) << ' ' << r * (Th(v0).y - y0) << " m " << r * ar * (Th(v1).x - x0) << ' ' << r * (Th(v1).y - y0) << " l " << r * ar * (Th(v2).x - x0) << ' ' << r * (Th(v2).y - y0) + << " l f\n"; + + } // element(triangle)-wise process + + st << "Q\n"; + + if (legend) drawLegend_fill(st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); + + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); + + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); + + return; +} // //---------------------------------------------------------------------- // P2 Finite Element @@ -1750,2042 +1601,1958 @@ void plot_P0_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN || v1 || = || v2 || = 1, v1 \perp v2 = 0 - // [X;Y] = P^T[x;y] <=> [x;y] = P[X;Y] - // [D;E] = P^T[d;e] <=> [d;e] = P[D;E] - - const double det = (a-c)*(a-c)+b*b; - const double sqdet = sqrt( det ); - - // eigenvalues of [ a, b /2; b/2, c] - double &lambda1 = PHI[0]; double &lambda2 = PHI[1]; - lambda1 = ( (a+c) + sqdet ) / 2; - lambda2 = ( (a+c) - sqdet ) / 2; - - // corresponding eivenvectors - double &v1x = PHI[2]; double &v1y= PHI[3]; - double &v2x = PHI[4]; double &v2y= PHI[5]; - - if( a < c ){ - - const double n = sqrt( 2*det - 2*(a-c)*sqdet ); - v1x = b / n; - v1y = (-(a-c)+sqdet) / n; - v2x = (a-c-sqdet) / n; - v2y = b / n; - - } else if( a > c ){ - - const double n = sqrt( 2*det + 2*(a-c)*sqdet ); - v1x = (a-c+sqdet) / n; - v1y = b / n; - v2x = b / n; - v2y = (-(a-c)-sqdet) / n; - - } else { // a == c - - lambda1 = (2*a+b)/2; - lambda2 = (2*a-b)/2; - v1x = v1y = v2x = v2y = 1/sqrt(static_cast(2)); v2y *= -1; - } +void findCanonicalForm(double *const PHI, const double *const phi) { + const double &a = phi[0]; + const double &b = phi[1]; + const double &c = phi[2]; + const double &d = phi[3]; + const double &e = phi[4]; + const double &f = phi[5]; + + // phi(x,y) = a*x*x + b*x*y + c*y*y + d*x + e*y + f + // = [x,y][ a, b/2; b/2, c ][x;y] + [d,e][x;y] + f + // = [x,y]P P^T [ a, b/2; b/2, c ]P P^T[x;y] + [d,e]P P^T[x;y] + f + // = [X,Y] [lambda1,0;0,lambda2] [X;Y] + [D,E][X;Y] + f + // = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f + // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 + // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f ) + // = PHI(X,Y) + // where + // v1 = [v1x;v1y] (resp. v2 = [v2x;v2y]) is an eigenvector of lambda1 (resp. lambda2) + // P = [v1x, v2x; v1y, v2y], satisfying P^T P = I <=> || v1 || = || v2 || = 1, v1 \perp v2 = 0 + // [X;Y] = P^T[x;y] <=> [x;y] = P[X;Y] + // [D;E] = P^T[d;e] <=> [d;e] = P[D;E] + + const double det = (a - c) * (a - c) + b * b; + const double sqdet = sqrt(det); + + // eigenvalues of [ a, b /2; b/2, c] + double &lambda1 = PHI[0]; + double &lambda2 = PHI[1]; + lambda1 = ((a + c) + sqdet) / 2; + lambda2 = ((a + c) - sqdet) / 2; + + // corresponding eivenvectors + double &v1x = PHI[2]; + double &v1y = PHI[3]; + double &v2x = PHI[4]; + double &v2y = PHI[5]; + + if (a < c) { + + const double n = sqrt(2 * det - 2 * (a - c) * sqdet); + v1x = b / n; + v1y = (-(a - c) + sqdet) / n; + v2x = (a - c - sqdet) / n; + v2y = b / n; + + } else if (a > c) { + + const double n = sqrt(2 * det + 2 * (a - c) * sqdet); + v1x = (a - c + sqdet) / n; + v1y = b / n; + v2x = b / n; + v2y = (-(a - c) - sqdet) / n; + + } else { // a == c + + lambda1 = (2 * a + b) / 2; + lambda2 = (2 * a - b) / 2; + v1x = v1y = v2x = v2y = 1 / sqrt(static_cast< double >(2)); + v2y *= -1; + } + + double &D = PHI[6]; + double &E = PHI[7]; + double &F = PHI[8]; + + // [D;E] = P^T[d;e] + const double p[2][2] = {{v1x, v2x}, {v1y, v2y}}; + const double pT[2][2] = {{p[0][0], p[1][0]}, {p[0][1], p[1][1]}}; + D = pT[0][0] * d + pT[0][1] * e; + E = pT[1][0] * d + pT[1][1] * e; + + const double EPS = 1e-10; + + F = f; + if (fabs(lambda1) > EPS) F -= D * D / (4 * lambda1); + + if (fabs(lambda2) > EPS) F -= E * E / (4 * lambda2); + + return; +} - double &D = PHI[6]; double &E = PHI[7]; double &F = PHI[8]; +void transformTriangle(double *const Vx, double *const Vy, const double *const vx, const double *const vy, const double *const PHI) { + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; - // [D;E] = P^T[d;e] - const double p[2][2] = { { v1x, v2x }, { v1y, v2y } }; - const double pT[2][2] = { { p[0][0], p[1][0] }, { p[0][1], p[1][1] } }; - D = pT[0][0] * d + pT[0][1] * e; - E = pT[1][0] * d + pT[1][1] * e; + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double P[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; + const double PT[2][2] = {{P[0][0], P[1][0]}, {P[0][1], P[1][1]}}; - const double EPS = 1e-10; + const int nVertices = 3; - F = f; - if( fabs(lambda1) > EPS ) - F -= D*D/(4*lambda1); + const double EPS = 1e-10; - if( fabs(lambda2) > EPS ) - F -= E*E/(4*lambda2); + for (int i = 0; i < nVertices; i++) { + Vx[i] = PT[0][0] * vx[i] + PT[0][1] * vy[i]; + if (fabs(lambda1) > EPS) Vx[i] += D / (2 * lambda1); + Vy[i] = PT[1][0] * vx[i] + PT[1][1] * vy[i]; + if (fabs(lambda2) > EPS) Vy[i] += E / (2 * lambda2); + } - return; + return; } -void transformTriangle( double *const Vx, double *const Vy, - const double *const vx, const double *const vy, const double *const PHI ) -{ - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; - - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double P[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; - const double PT[2][2] = { { P[0][0], P[1][0] }, { P[0][1], P[1][1] } }; +void findZeros(std::vector< double > &zx, std::vector< double > &zy, const double v1x, const double v1y, const double v2x, const double v2y, const double *const phi, const double value) { + // crosss points of ax^2 + bxy + cy^2 + dx + ey + f = value + // and segment : [x;y] = (1-t)*[v1x;v1y] + t*[v2x;v2y] with 0 <= t <= 1 + const double &a = phi[0]; + const double &b = phi[1]; + const double &c = phi[2]; + const double &d = phi[3]; + const double &e = phi[4]; + const double &f = phi[5]; - const int nVertices = 3; - - const double EPS = 1e-10; + const double EPS = 1e-10; - for(int i = 0; i < nVertices; i++){ - Vx[i] = PT[0][0] * vx[i] + PT[0][1] * vy[i]; - if( fabs(lambda1) > EPS ) - Vx[i] += D/(2*lambda1); - Vy[i] = PT[1][0] * vx[i] + PT[1][1] * vy[i]; - if( fabs(lambda2) > EPS ) - Vy[i] += E/(2*lambda2); - } + // If phi(x,y) == value at both v1 and v2, then return + const double phi1 = a * v1x * v1x + b * v1x * v1y + c * v1y * v1y + d * v1x + e * v1y + f - value; + const double phi2 = a * v2x * v2x + b * v2x * v2y + c * v2y * v2y + d * v2x + e * v2y + f - value; - return; -} + if (fabs(phi1) + fabs(phi2) < EPS) { -void findZeros( std::vector &zx, std::vector &zy, - const double v1x, const double v1y, const double v2x, const double v2y, - const double *const phi, const double value ) -{ - // crosss points of ax^2 + bxy + cy^2 + dx + ey + f = value - // and segment : [x;y] = (1-t)*[v1x;v1y] + t*[v2x;v2y] with 0 <= t <= 1 - const double &a = phi[0]; const double &b = phi[1]; const double &c = phi[2]; - const double &d = phi[3]; const double &e = phi[4]; const double &f = phi[5]; + // examine phi at mid point of v1 and v2 + const double v3x = (v1x + v2x) / 2; + const double v3y = (v1y + v2y) / 2; + const double phi3 = a * v3x * v3x + b * v3x * v3y + c * v3y * v3y + d * v3x + e * v3y + f - value; - const double EPS = 1e-10; + // If phi(mid point) == 0, then phi(x,y) may vanish on the segment (line) v1--v2. + if (fabs(phi3) < EPS) return; - // If phi(x,y) == value at both v1 and v2, then return - const double phi1 = a*v1x*v1x + b*v1x*v1y + c*v1y*v1y + d*v1x + e*v1y + f - value; - const double phi2 = a*v2x*v2x + b*v2x*v2y + c*v2y*v2y + d*v2x + e*v2y + f - value; + zx.push_back(v1x); + zy.push_back(v1y); + zx.push_back(v2x); + zy.push_back(v2y); + return; + } - if( fabs(phi1) + fabs(phi2) < EPS ){ + // At^2 + Bt + C = 0 + const double A = a * (v1x - v2x) * (v1x - v2x) + b * (v1x - v2x) * (v1y - v2y) + c * (v1y - v2y) * (v1y - v2y); + const double B = 2 * a * v1x * (-v1x + v2x) + b * v1y * (-v1x + v2x) + b * v1x * (-v1y + v2y) + 2 * c * v1y * (-v1y + v2y) + d * (-v1x + v2x) + e * (-v1y + v2y); + const double C = a * v1x * v1x + b * v1x * v1y + c * v1y * v1y + d * v1x + e * v1y + f - value; - // examine phi at mid point of v1 and v2 - const double v3x = (v1x + v2x) / 2; - const double v3y = (v1y + v2y) / 2; - const double phi3 = a*v3x*v3x + b*v3x*v3y + c*v3y*v3y + d*v3x + e*v3y + f - value; - - // If phi(mid point) == 0, then phi(x,y) may vanish on the segment (line) v1--v2. - if( fabs(phi3) < EPS ) - return; + // If A == 0, then solve Bt + C = 0 + if (fabs(A) < EPS) { - zx.push_back( v1x ); zy.push_back( v1y ); - zx.push_back( v2x ); zy.push_back( v2y ); - return; + if (fabs(B) < EPS) { // A == B == 0 + // if(fabs(C) > EPS ){ + // cerr << "findZeros(): no solutions" << endl; + // } + return; } - // At^2 + Bt + C = 0 - const double A = a*(v1x-v2x)*(v1x-v2x) + b*(v1x-v2x)*(v1y-v2y) + c*(v1y-v2y)*(v1y-v2y); - const double B = 2*a*v1x*(-v1x+v2x) + b*v1y*(-v1x+v2x) + b*v1x*(-v1y+v2y) + 2*c*v1y*(-v1y+v2y) - + d*(-v1x+v2x) + e*(-v1y+v2y); - const double C = a*v1x*v1x + b*v1x*v1y + c*v1y*v1y + d*v1x + e*v1y + f - value; - - // If A == 0, then solve Bt + C = 0 - if( fabs(A) < EPS ){ + const double t = -C / B; - if(fabs(B) < EPS){ // A == B == 0 - //if(fabs(C) > EPS ){ - // cerr << "findZeros(): no solutions" << endl; - //} - return; - } + if ((-EPS < t) && (t < 1 + EPS)) { // 0 <= t <= 1 + const double x = (1 - t) * v1x + t * v2x; + const double y = (1 - t) * v1y + t * v2y; + zx.push_back(x); + zy.push_back(y); + } + return; + } - const double t = -C/B; + // solve At^2 + Bt + C = 0 + const double D_ = B * B - 4 * A * C; + const double D = (fabs(D_) < EPS) ? 0 : D_; - if( (-EPS < t) && (t < 1+EPS) ){ // 0 <= t <= 1 - const double x = (1-t)*v1x + t*v2x; - const double y = (1-t)*v1y + t*v2y; - zx.push_back(x); - zy.push_back(y); - } - return; - } + if (D < 0) return; // no cross points - // solve At^2 + Bt + C = 0 - const double D_ = B*B - 4*A*C; - const double D = (fabs(D_) < EPS)? 0: D_; + const double t01[2] = {(-B + sqrt(D)) / (2 * A), (-B - sqrt(D)) / (2 * A)}; + for (int i = 0; i < 2; i++) { - if( D < 0 ) return; // no cross points - - const double t01[2] = { (-B + sqrt(D))/(2*A), (-B - sqrt(D))/(2*A) }; - for(int i = 0; i < 2; i++){ + const double &t = t01[i]; - const double &t = t01[i]; + if ((-EPS < t) && (t < 1 + EPS)) { // 0 <= t <= 1 - if( (-EPS < t) && (t < 1+EPS) ){ // 0 <= t <= 1 - - const double x = (1-t)*v1x + t*v2x; - const double y = (1-t)*v1y + t*v2y; - zx.push_back( x ); - zy.push_back( y ); - } + const double x = (1 - t) * v1x + t * v2x; + const double y = (1 - t) * v1y + t * v2y; + zx.push_back(x); + zy.push_back(y); } - return; + } + return; } -void invTransformCubicBzeirs( std::vector< std::vector > &Cxs, std::vector< std::vector > &Cys, - const double *const PHI ) -{ - const double EPS = 1e-10; +void invTransformCubicBzeirs(std::vector< std::vector< double > > &Cxs, std::vector< std::vector< double > > &Cys, const double *const PHI) { + const double EPS = 1e-10; - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double P[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double P[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; - assert( Cxs.size() == Cys.size() ); + assert(Cxs.size( ) == Cys.size( )); - if( Cxs.size() == 0 ) return; // nothing to transform + if (Cxs.size( ) == 0) return; // nothing to transform - for(size_t k = 0; k < Cxs.size(); k++){ + for (size_t k = 0; k < Cxs.size( ); k++) { - std::vector &Cx = Cxs[k]; - std::vector &Cy = Cys[k]; + std::vector< double > &Cx = Cxs[k]; + std::vector< double > &Cy = Cys[k]; - assert( Cx.size() == Cy.size() ); + assert(Cx.size( ) == Cy.size( )); - for(size_t j = 0; j < Cx.size(); j++){ // j=0 : starting point + for (size_t j = 0; j < Cx.size( ); j++) { // j=0 : starting point - double Px = Cx[j]; - double Py = Cy[j]; + double Px = Cx[j]; + double Py = Cy[j]; - if( fabs(lambda1) > EPS ) - Px -= D/(2*lambda1); - if( fabs(lambda2) > EPS ) - Py -= E/(2*lambda2); + if (fabs(lambda1) > EPS) Px -= D / (2 * lambda1); + if (fabs(lambda2) > EPS) Py -= E / (2 * lambda2); - Cx[j] = P[0][0] * Px + P[0][1] * Py; - Cy[j] = P[1][0] * Px + P[1][1] * Py; - } - } // k - return; + Cx[j] = P[0][0] * Px + P[0][1] * Py; + Cy[j] = P[1][0] * Px + P[1][1] * Py; + } + } // k + return; } -void drawCubicBeziers( std::stringstream &Content, - const std::vector< std::vector > &Cxs, - const std::vector< std::vector > &Cys, - const double scale, const double ar, const double x0, const double y0 ) -{ - const double EPS = 1e-10; +void drawCubicBeziers(std::stringstream &Content, const std::vector< std::vector< double > > &Cxs, const std::vector< std::vector< double > > &Cys, const double scale, const double ar, + const double x0, const double y0) { + const double EPS = 1e-10; - std::stringstream &st = Content; + std::stringstream &st = Content; - assert( Cxs.size() == Cys.size() ); + assert(Cxs.size( ) == Cys.size( )); - if( Cxs.size() == 0 ) return; // nothing to draw + if (Cxs.size( ) == 0) return; // nothing to draw - for(size_t k = 0; k < Cxs.size(); k++){ + for (size_t k = 0; k < Cxs.size( ); k++) { - const std::vector &px = Cxs[k]; - const std::vector &py = Cys[k]; + const std::vector< double > &px = Cxs[k]; + const std::vector< double > &py = Cys[k]; - assert( px.size() == py.size() ); - assert( ( px.size()-1 ) % 3 == 0 ); // ignore the starting point + assert(px.size( ) == py.size( )); + assert((px.size( ) - 1) % 3 == 0); // ignore the starting point - st << scale*ar*(px[0]-x0) << ' ' << scale*(py[0]-y0) << " m\n"; + st << scale * ar * (px[0] - x0) << ' ' << scale * (py[0] - y0) << " m\n"; - // sequential control points - for(size_t j = 1; j < px.size(); j += 3){ // j=0 : starting point + // sequential control points + for (size_t j = 1; j < px.size( ); j += 3) { // j=0 : starting point - for(int i = 0; i < 3; i++) - st << scale*ar*(px[j+i]-x0) << ' ' << scale*(py[j+i]-y0) << ' '; - st << "c\n"; - } - st << "S\n"; - } // k - return; + for (int i = 0; i < 3; i++) st << scale * ar * (px[j + i] - x0) << ' ' << scale * (py[j + i] - y0) << ' '; + st << "c\n"; + } + st << "S\n"; + } // k + return; } -bool isInsideTriangle( const double px, const double py, const double *const vx, const double *const vy ) -{ - // Find a, b \in \Real such that [px;py]-v0 = a (v1-v0) + b (v2-v0). - // if (0 < a < 1) && (0 < b < 1) && (0 < a+b < 1), then p is inside triangle v0--v1--v2 - - // solve (v1x-v0x) * a + (v2x-v0x) * b = px-v0x - // (v1y-v0y) * a + (v2y-v0y) * b = py-v0y - const double EPS = 1e-10; - const double m00 = vx[1] - vx[0]; - const double m01 = vx[2] - vx[0]; - const double rhs0 = px - vx[0]; +bool isInsideTriangle(const double px, const double py, const double *const vx, const double *const vy) { + // Find a, b \in \Real such that [px;py]-v0 = a (v1-v0) + b (v2-v0). + // if (0 < a < 1) && (0 < b < 1) && (0 < a+b < 1), then p is inside triangle v0--v1--v2 - const double m10 = vy[1] - vy[0]; - const double m11 = vy[2] - vy[0]; - const double rhs1 = py - vy[0]; + // solve (v1x-v0x) * a + (v2x-v0x) * b = px-v0x + // (v1y-v0y) * a + (v2y-v0y) * b = py-v0y + const double EPS = 1e-10; + const double m00 = vx[1] - vx[0]; + const double m01 = vx[2] - vx[0]; + const double rhs0 = px - vx[0]; - const double det = m00*m11 - m01*m10; - assert( fabs(det) > EPS ); + const double m10 = vy[1] - vy[0]; + const double m11 = vy[2] - vy[0]; + const double rhs1 = py - vy[0]; - const double a = ( m11 * rhs0 - m01 * rhs1) / det; - const double b = (-m10 * rhs0 + m00 * rhs1) / det; + const double det = m00 * m11 - m01 * m10; + assert(fabs(det) > EPS); - return (0 < a) && (a < 1) && (0 < b) && (b < 1) && (0 < a+b) && (a+b < 1); -} + const double a = (m11 * rhs0 - m01 * rhs1) / det; + const double b = (-m10 * rhs0 + m00 * rhs1) / det; -void trackParabolaCore( std::vector< std::vector > &Cx, std::vector< std::vector > &Cy, - const double a, const double b, std::vector &x, - const double *const Vx, const double *const Vy ) -{ - // y = a * x^2 + b - std::sort( x.begin(), x.end() ); - - // control points: Px[4], Py[4] - // Bezier curve : P(t) = (1-t)^3 P0 + 3(1-t)^2 t P1 + 3(1-t)t^2 P2 + t^3 P3 - // = (-P0+3P1-3P2+P3) t^3 + (3P0-6P1+3P2) t^2 + (-3P0+3P1) t + P0 - // - // parabola between x0 <= x <= x1 : - // P(t) = [ (x1-x0)t + x0 ; a*( (x1-x0)t + x0 )^2 + b*( (x1-x0)t + x0 ) + c ] - // = [ (x1-x0)t + x0 ; a(x1-x0)^2 t^2 + (2*a*x0+b)*(x1-x0) t + (a x_0^2 + bx_0 + c) ] - // - // Therefore - // P0 = [ x0 ; ax_0^2 + bx_0 + c ] - // -3P0+3P1 = [ x1-x0 ; (2*a*x0+b)*(x1-x0) ] - // 3P0-6P1+3P2 = [ 0 ; a(x1-x0)^2 ] - // -P0+3P1-3P2+P3 = [ 0 ; 0 ] - // <=> - // P0 = [ x0 ; ax_0^2 + bx_0 + c ] - // P1 = P0 + [ x1-x0 ; (2*a*x0+b)*(x1-x0) ]/3 - // P2 = -P0 + 2*P1 + [ 0 ; a(x1-x0)^2 ]/3 - // P3 = P0-3P1+3P2 - // From this, P0x = x0, P1x = x0+(x1-x0)/3, P2x = P0x + 2/3*(x1-x0), P3x = x1 - - for(int i = 0; i+1 < x.size(); i++){ - - const double &X0 = x[i]; - const double &X1 = x[i+1]; - const double h = X1 - X0; - - const double EPS = 1e-10; - if( h < EPS) - continue; - - // examine the arc X[i]--X[i+1] is inside triangle or not - const double mX0 = X0 + h/100; - const double mY0 = a*mX0*mX0 + b; - - const double mX1 = X1 - h/100; - const double mY1 = a*mX1*mX1 + b; - if( !(isInsideTriangle( mX0, mY0, Vx, Vy ) && isInsideTriangle( mX1, mY1, Vx, Vy )) ) - continue; - - const double P0y = a*X0*X0 + b; - const double P1y = P0y + (2*a*X0)*h/3; - const double P2y = -P0y + 2*P1y + a*h*h/3; - const double P3y = P0y - 3*P1y + 3*P2y; - - Cx.push_back( std::vector { X0, X0+h/3, X1-h/3, X1 } ); - Cy.push_back( std::vector { P0y, P1y, P2y, P3y } ); - } - return; + return (0 < a) && (a < 1) && (0 < b) && (b < 1) && (0 < a + b) && (a + b < 1); } -void trackParabola( std::vector< std::vector > &Cx, std::vector< std::vector > &Cy, - const double *const PHI, const std::vector &zx, const std::vector &zy, - const double *const Vx, const double *const Vy ) +void trackParabolaCore(std::vector< std::vector< double > > &Cx, std::vector< std::vector< double > > &Cy, const double a, const double b, std::vector< double > &x, const double *const Vx, + const double *const Vy) { + // y = a * x^2 + b + std::sort(x.begin( ), x.end( )); + + // control points: Px[4], Py[4] + // Bezier curve : P(t) = (1-t)^3 P0 + 3(1-t)^2 t P1 + 3(1-t)t^2 P2 + t^3 P3 + // = (-P0+3P1-3P2+P3) t^3 + (3P0-6P1+3P2) t^2 + (-3P0+3P1) t + P0 + // + // parabola between x0 <= x <= x1 : + // P(t) = [ (x1-x0)t + x0 ; a*( (x1-x0)t + x0 )^2 + b*( (x1-x0)t + x0 ) + c ] + // = [ (x1-x0)t + x0 ; a(x1-x0)^2 t^2 + (2*a*x0+b)*(x1-x0) t + (a x_0^2 + bx_0 + c) ] + // + // Therefore + // P0 = [ x0 ; ax_0^2 + bx_0 + c ] + // -3P0+3P1 = [ x1-x0 ; (2*a*x0+b)*(x1-x0) ] + // 3P0-6P1+3P2 = [ 0 ; a(x1-x0)^2 ] + // -P0+3P1-3P2+P3 = [ 0 ; 0 ] + // <=> + // P0 = [ x0 ; ax_0^2 + bx_0 + c ] + // P1 = P0 + [ x1-x0 ; (2*a*x0+b)*(x1-x0) ]/3 + // P2 = -P0 + 2*P1 + [ 0 ; a(x1-x0)^2 ]/3 + // P3 = P0-3P1+3P2 + // From this, P0x = x0, P1x = x0+(x1-x0)/3, P2x = P0x + 2/3*(x1-x0), P3x = x1 + + for (int i = 0; i + 1 < x.size( ); i++) { + + const double &X0 = x[i]; + const double &X1 = x[i + 1]; + const double h = X1 - X0; -{ const double EPS = 1e-10; + if (h < EPS) continue; - // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f - // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 - // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) - // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F - // X' = X + D/(2*lambda1), Y' = Y + E/(2*lambda2) - // They are new variables, (not derivatives of X and Y) - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; const double &F = PHI[8]; - - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double P[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; - const double PT[2][2] = { { P[0][0], P[1][0] }, { P[0][1], P[1][1] } }; - - assert( zx.size() == zy.size() ); -#if 1 - std::vector Zx, Zy; - for(size_t i = 0; i < zx.size(); i++){ - Zx.push_back( PT[0][0]*zx[i] + PT[0][1]*zy[i] ); - Zy.push_back( PT[1][0]*zx[i] + PT[1][1]*zy[i] ); - } -#endif - if( fabs(lambda1) > EPS ){ + // examine the arc X[i]--X[i+1] is inside triangle or not + const double mX0 = X0 + h / 100; + const double mY0 = a * mX0 * mX0 + b; - // lambda1*X^2 + D*X + E*Y + F = 0 - // <=> lambda1*( X + D/(2*lambda1) )^2 + E*Y + F - D*D/(4*lambda1) = 0 - // <=> Y = (-lambda1/E) * (X')^2 - F'/E - if( fabs(E) < EPS ) return; + const double mX1 = X1 - h / 100; + const double mY1 = a * mX1 * mX1 + b; + if (!(isInsideTriangle(mX0, mY0, Vx, Vy) && isInsideTriangle(mX1, mY1, Vx, Vy))) continue; - for(std::vector::iterator itr = Zx.begin(); itr != Zx.end(); itr++) - *itr += D/(2*lambda1); + const double P0y = a * X0 * X0 + b; + const double P1y = P0y + (2 * a * X0) * h / 3; + const double P2y = -P0y + 2 * P1y + a * h * h / 3; + const double P3y = P0y - 3 * P1y + 3 * P2y; - const double a = -lambda1/E; // Y' = a*(X')^2 + b - const double b = -F/E; - - trackParabolaCore( Cx, Cy, a, b, Zx, Vx, Vy ); - - } else { - - assert( fabs(lambda2) > EPS ); - - // D*X + lambda2*Y^2 + E*Y + F = 0 <=> X = (-lambda2/D)*Y^2 - (E/D)*Y - F/D - // <=> D*X + lambda2*(Y - E/(2*lambda2))^2 + F - E*E/(4*lambda2) = 0 - // <=> X = (-lambda2/D)*(Y')^2 - F'/D - if( fabs(D) < EPS ) return; - - for(std::vector::iterator itr = Zy.begin(); itr != Zy.end(); itr++) - *itr += E/(2*lambda2); - - const double a = -lambda2/D; // X' = a*(Y')^2 + b - const double b = -F/D; - - trackParabolaCore( Cy, Cx, a, b, Zy, Vy, Vx ); - } - - return; + Cx.push_back(std::vector< double >{X0, X0 + h / 3, X1 - h / 3, X1}); + Cy.push_back(std::vector< double >{P0y, P1y, P2y, P3y}); + } + return; } -void trackEllipse( std::vector< std::vector > &Cxs, std::vector< std::vector > &Cys, - const double *const PHI, const double *const Vx, const double *const Vy ) -{ - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; const double &F = PHI[8]; - - assert( lambda1*lambda2 > 0 ); +void trackParabola(std::vector< std::vector< double > > &Cx, std::vector< std::vector< double > > &Cy, const double *const PHI, const std::vector< double > &zx, const std::vector< double > &zy, + const double *const Vx, const double *const Vy) - // lambda1*(X')^2 + lambda2*(Y')^2 + F = 0 - // Y' = 0 => X'= sqrt( -F/lambda1 ), it means that -F/lambda1 > 0 - if( -F/lambda1 <= 0 ) - return; - - // lambda1 * X*X + lambda2 * Y*Y + F = 0 - // <=> (-lambda1/F) * X*X + (-lambda2/F) * Y*Y = 1 - // <=> (X/a)^2 + (Y/b)^2 = 1, 1/a = sqrt(-lambda1/F), 1/b = sqrt(-lambda2/F) - const double a = sqrt( -F / lambda1 ); - const double b = sqrt( -F / lambda2 ); +{ + const double EPS = 1e-10; + + // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f + // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 + // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) + // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F + // X' = X + D/(2*lambda1), Y' = Y + E/(2*lambda2) + // They are new variables, (not derivatives of X and Y) + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + const double &F = PHI[8]; + + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double P[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; + const double PT[2][2] = {{P[0][0], P[1][0]}, {P[0][1], P[1][1]}}; + + assert(zx.size( ) == zy.size( )); +#if 1 + std::vector< double > Zx, Zy; + for (size_t i = 0; i < zx.size( ); i++) { + Zx.push_back(PT[0][0] * zx[i] + PT[0][1] * zy[i]); + Zy.push_back(PT[1][0] * zx[i] + PT[1][1] * zy[i]); + } +#endif + if (fabs(lambda1) > EPS) { - // Ellipse is tangent to an edge of the triangle element, and localtes outside of the triangle - // Examine both opposite sides (a,0) and (-a,0) are belong to inside of the triangle element - if( !isInsideTriangle( -a, 0, Vx, Vy ) && !isInsideTriangle( -a, 0, Vx, Vy ) ) - return; + // lambda1*X^2 + D*X + E*Y + F = 0 + // <=> lambda1*( X + D/(2*lambda1) )^2 + E*Y + F - D*D/(4*lambda1) = 0 + // <=> Y = (-lambda1/E) * (X')^2 - F'/E + if (fabs(E) < EPS) return; - const double PI = atan(static_cast(1)) * 4; - const double c = 35*(32/(PI*PI*PI) - 96/(PI*PI*PI*PI)) - static_cast(13)/12; - const double p1 = c*b; - const double p2 = c*a; + for (std::vector< double >::iterator itr = Zx.begin( ); itr != Zx.end( ); itr++) *itr += D / (2 * lambda1); - // X' = X+D/(2*lambda1), Y' = Y+E/(2*lambda2) <=> X = X'-D/(2*lambda1), Y = Y'-E/(2*lambda2) - // [x;y] = P[X;Y] + const double a = -lambda1 / E; // Y' = a*(X')^2 + b + const double b = -F / E; - std::vector Cx, Cy; + trackParabolaCore(Cx, Cy, a, b, Zx, Vx, Vy); - // starting point - Cx.push_back( a ); - Cy.push_back( 0 ); + } else { - // quater 1 - Cx.push_back( a ); Cy.push_back( p1 ); - Cx.push_back( p2 ); Cy.push_back( b ); - Cx.push_back( 0 ); Cy.push_back( b ); + assert(fabs(lambda2) > EPS); - // quater 2 - Cx.push_back( -p2 ); Cy.push_back( b ); - Cx.push_back( -a ); Cy.push_back( p1 ); - Cx.push_back( -a ); Cy.push_back( 0 ); + // D*X + lambda2*Y^2 + E*Y + F = 0 <=> X = (-lambda2/D)*Y^2 - (E/D)*Y - F/D + // <=> D*X + lambda2*(Y - E/(2*lambda2))^2 + F - E*E/(4*lambda2) = 0 + // <=> X = (-lambda2/D)*(Y')^2 - F'/D + if (fabs(D) < EPS) return; - // quater 3 - Cx.push_back( -a ); Cy.push_back( -p1 ); - Cx.push_back( -p2 ); Cy.push_back( -b ); - Cx.push_back( 0 ); Cy.push_back( -b ); + for (std::vector< double >::iterator itr = Zy.begin( ); itr != Zy.end( ); itr++) *itr += E / (2 * lambda2); - // quater 4 - Cx.push_back( p2 ); Cy.push_back( -b ); - Cx.push_back( a ); Cy.push_back( -p1 ); - Cx.push_back( a ); Cy.push_back( 0 ); + const double a = -lambda2 / D; // X' = a*(Y')^2 + b + const double b = -F / D; - Cxs.push_back( Cx ); Cys.push_back( Cy ); + trackParabolaCore(Cy, Cx, a, b, Zy, Vy, Vx); + } - return; + return; } -void trackEllipse( std::vector< std::vector > &Cx, std::vector< std::vector > &Cy, - const double *const PHI, const std::vector &zx, const std::vector &zy, - const double *const Vx, const double *const Vy ) -{ - const double EPS = 1e-10; - const int INTERVALS = PLOTPDFVAR::DEFAULT_P2_INERVALS; - - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; const double &F = PHI[8]; - - assert( lambda1 * lambda2 > 0 ); - assert( fabs(lambda1) + fabs(lambda2) > EPS ); - assert( lambda1 * F < 0 ); - - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double P[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; - const double PT[2][2] = { { P[0][0], P[1][0] }, { P[0][1], P[1][1] } }; +void trackEllipse(std::vector< std::vector< double > > &Cxs, std::vector< std::vector< double > > &Cys, const double *const PHI, const double *const Vx, const double *const Vy) { + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + const double &F = PHI[8]; + + assert(lambda1 * lambda2 > 0); + + // lambda1*(X')^2 + lambda2*(Y')^2 + F = 0 + // Y' = 0 => X'= sqrt( -F/lambda1 ), it means that -F/lambda1 > 0 + if (-F / lambda1 <= 0) return; + + // lambda1 * X*X + lambda2 * Y*Y + F = 0 + // <=> (-lambda1/F) * X*X + (-lambda2/F) * Y*Y = 1 + // <=> (X/a)^2 + (Y/b)^2 = 1, 1/a = sqrt(-lambda1/F), 1/b = sqrt(-lambda2/F) + const double a = sqrt(-F / lambda1); + const double b = sqrt(-F / lambda2); + + // Ellipse is tangent to an edge of the triangle element, and localtes outside of the triangle + // Examine both opposite sides (a,0) and (-a,0) are belong to inside of the triangle element + if (!isInsideTriangle(-a, 0, Vx, Vy) && !isInsideTriangle(-a, 0, Vx, Vy)) return; + + const double PI = atan(static_cast< double >(1)) * 4; + const double c = 35 * (32 / (PI * PI * PI) - 96 / (PI * PI * PI * PI)) - static_cast< double >(13) / 12; + const double p1 = c * b; + const double p2 = c * a; + + // X' = X+D/(2*lambda1), Y' = Y+E/(2*lambda2) <=> X = X'-D/(2*lambda1), Y = Y'-E/(2*lambda2) + // [x;y] = P[X;Y] + + std::vector< double > Cx, Cy; + + // starting point + Cx.push_back(a); + Cy.push_back(0); + + // quater 1 + Cx.push_back(a); + Cy.push_back(p1); + Cx.push_back(p2); + Cy.push_back(b); + Cx.push_back(0); + Cy.push_back(b); + + // quater 2 + Cx.push_back(-p2); + Cy.push_back(b); + Cx.push_back(-a); + Cy.push_back(p1); + Cx.push_back(-a); + Cy.push_back(0); + + // quater 3 + Cx.push_back(-a); + Cy.push_back(-p1); + Cx.push_back(-p2); + Cy.push_back(-b); + Cx.push_back(0); + Cy.push_back(-b); + + // quater 4 + Cx.push_back(p2); + Cy.push_back(-b); + Cx.push_back(a); + Cy.push_back(-p1); + Cx.push_back(a); + Cy.push_back(0); + + Cxs.push_back(Cx); + Cys.push_back(Cy); + + return; +} - assert( zx.size() == zy.size() ); +void trackEllipse(std::vector< std::vector< double > > &Cx, std::vector< std::vector< double > > &Cy, const double *const PHI, const std::vector< double > &zx, const std::vector< double > &zy, + const double *const Vx, const double *const Vy) { + const double EPS = 1e-10; + const int INTERVALS = PLOTPDFVAR::DEFAULT_P2_INERVALS; + + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + const double &F = PHI[8]; + + assert(lambda1 * lambda2 > 0); + assert(fabs(lambda1) + fabs(lambda2) > EPS); + assert(lambda1 * F < 0); + + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double P[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; + const double PT[2][2] = {{P[0][0], P[1][0]}, {P[0][1], P[1][1]}}; + + assert(zx.size( ) == zy.size( )); #if 1 - std::vector Zx, Zy; - for(size_t i = 0; i < zx.size(); i++){ - Zx.push_back( PT[0][0]*zx[i] + PT[0][1]*zy[i] + D/(2*lambda1) ); - Zy.push_back( PT[1][0]*zx[i] + PT[1][1]*zy[i] + E/(2*lambda2) ); - } + std::vector< double > Zx, Zy; + for (size_t i = 0; i < zx.size( ); i++) { + Zx.push_back(PT[0][0] * zx[i] + PT[0][1] * zy[i] + D / (2 * lambda1)); + Zy.push_back(PT[1][0] * zx[i] + PT[1][1] * zy[i] + E / (2 * lambda2)); + } #endif - // lambda1 * (X')^2 + lambda2 * (Y')^2 = -F, with lambda1*F < 0 <=> lambda1*(-F) > 0 - // <=> (X')^2 / lambda2 + (Y')^2 / lambda1 = -F/(lambda1*lambda2) - // <=> X' = sqrt(-F/(lambda1*lambda2))*sqrt(lambda2)*cos(t) = sqrt(-F/lambda1) * cos(t) - // Y' = sqrt(-F/)lambda1*lambda2))*sqrt(lambda1)*sin(t) = sqrt(-F/lambda2) * sin(t) - // <=> cos(t) = X'*sqrt(-lambda1/F), sin(t) = Y'*sqrt(-lambda2/F) + // lambda1 * (X')^2 + lambda2 * (Y')^2 = -F, with lambda1*F < 0 <=> lambda1*(-F) > 0 + // <=> (X')^2 / lambda2 + (Y')^2 / lambda1 = -F/(lambda1*lambda2) + // <=> X' = sqrt(-F/(lambda1*lambda2))*sqrt(lambda2)*cos(t) = sqrt(-F/lambda1) * cos(t) + // Y' = sqrt(-F/)lambda1*lambda2))*sqrt(lambda1)*sin(t) = sqrt(-F/lambda2) * sin(t) + // <=> cos(t) = X'*sqrt(-lambda1/F), sin(t) = Y'*sqrt(-lambda2/F) - // lambda1 * X*X + lambda2 * Y*Y + F = 0 - // <=> (-lambda1/F) * X*X + (-lambda2/F) * Y*Y = 1 - // <=> (X/a)^2 + (Y/b)^2 = 1, 1/a = sqrt(-lambda1/F), 1/b = sqrt(-lambda2/F) - const double a = sqrt( -F / lambda1 ); - const double b = sqrt( -F / lambda2 ); + // lambda1 * X*X + lambda2 * Y*Y + F = 0 + // <=> (-lambda1/F) * X*X + (-lambda2/F) * Y*Y = 1 + // <=> (X/a)^2 + (Y/b)^2 = 1, 1/a = sqrt(-lambda1/F), 1/b = sqrt(-lambda2/F) + const double a = sqrt(-F / lambda1); + const double b = sqrt(-F / lambda2); - std::vector theta; - assert( Zx.size() == Zy.size() ); - for(size_t i = 0; i < Zx.size(); i++) - theta.push_back( atan2( Zy[i]/b, Zx[i]/a ) ); + std::vector< double > theta; + assert(Zx.size( ) == Zy.size( )); + for (size_t i = 0; i < Zx.size( ); i++) theta.push_back(atan2(Zy[i] / b, Zx[i] / a)); - std::sort( theta.begin(), theta.end() ); + std::sort(theta.begin( ), theta.end( )); + const double PI = atan(static_cast< double >(1)) * 4; + theta.push_back(theta[0] + 2 * PI); - const double PI = atan(static_cast(1))*4; - theta.push_back( theta[0] + 2*PI ); + for (size_t i = 0; i < theta.size( ) - 1; i++) { // bug fix, Oct 08, 2022 - for(size_t i = 0; i < theta.size()-1; i++){ // bug fix, Oct 08, 2022 + const double &t0 = theta[i]; + const double &t1 = theta[i + 1]; - const double &t0 = theta[i]; - const double &t1 = theta[i+1]; + if (t1 - t0 < EPS) continue; - if( t1-t0 < EPS ) - continue; + // examine the arc theta[i]--theta[i+1] is inside triangle or not + const double mt0 = t0 + (t1 - t0) / 100; + const double mx0 = a * cos(mt0); + const double my0 = b * sin(mt0); - // examine the arc theta[i]--theta[i+1] is inside triangle or not - const double mt0 = t0 + (t1-t0)/100; - const double mx0 = a * cos(mt0); - const double my0 = b * sin(mt0); + const double mt1 = t1 - (t1 - t0) / 100; + const double mx1 = a * cos(mt1); + const double my1 = b * sin(mt1); + if (!(isInsideTriangle(mx0, my0, Vx, Vy) && isInsideTriangle(mx1, my1, Vx, Vy))) continue; - const double mt1 = t1 - (t1-t0)/100; - const double mx1 = a * cos(mt1); - const double my1 = b * sin(mt1); - if( !(isInsideTriangle( mx0, my0, Vx, Vy ) && isInsideTriangle( mx1, my1, Vx, Vy )) ) - continue; + std::vector< double > Cx_local, Cy_local; - std::vector Cx_local, Cy_local; + const double dt = (t1 - t0) / INTERVALS; - const double dt = (t1 - t0) / INTERVALS; + Cx_local.push_back(a * cos(t0)); + Cy_local.push_back(b * sin(t0)); - Cx_local.push_back( a*cos(t0) ); - Cy_local.push_back( b*sin(t0) ); + for (int k = 0; k < INTERVALS; k++) { - for(int k = 0; k < INTERVALS; k++){ + const double eta1 = t0 + k * dt; + const double eta2 = t0 + (k + 1) * dt; - const double eta1 = t0 + k*dt; - const double eta2 = t0 + (k+1)*dt; + const double P0x = a * cos(eta1); + const double P0y = b * sin(eta1); - const double P0x = a * cos( eta1 ); - const double P0y = b * sin( eta1 ); - - const double P3x = a * cos( eta2 ); - const double P3y = b * sin( eta2 ); + const double P3x = a * cos(eta2); + const double P3y = b * sin(eta2); #if 0 // (X/a)^2 + (Y/b)^2 = 1 // tangent at (X0,Y0) : X0*X/a^2 + Y0*Y/b^2 = 1, whose directional vector is (a*a*Y0,-b*b*X0) const double alpha = 0; // alpha = 0 => segment #else - // L.Maisonobe (2003) Drawing an elliptical arc using polylines, quadratic or cubic Bezier curves - // http://www.spaceroots.org/documents/ellipse/elliptical-arc.pdf - // or - // https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves - const double te = tan( (eta2-eta1)/2 ); - const double alpha = sin(eta2-eta1) * (sqrt(4+3*te*te) - 1) / 3; + // L.Maisonobe (2003) Drawing an elliptical arc using polylines, quadratic or cubic Bezier curves + // http://www.spaceroots.org/documents/ellipse/elliptical-arc.pdf + // or + // https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves + const double te = tan((eta2 - eta1) / 2); + const double alpha = sin(eta2 - eta1) * (sqrt(4 + 3 * te * te) - 1) / 3; #endif - const double P1x = P0x + alpha * ( -a*sin(eta1) ); - const double P1y = P0y + alpha * ( b*cos(eta1) ); - - const double P2x = P3x - alpha * ( -a*sin(eta2) ); - const double P2y = P3y - alpha * ( b*cos(eta2) ); - - Cx_local.push_back( P1x ); Cy_local.push_back( P1y ); - Cx_local.push_back( P2x ); Cy_local.push_back( P2y ); - Cx_local.push_back( P3x ); Cy_local.push_back( P3y ); - } - Cx.push_back( Cx_local ); - Cy.push_back( Cy_local ); + const double P1x = P0x + alpha * (-a * sin(eta1)); + const double P1y = P0y + alpha * (b * cos(eta1)); + + const double P2x = P3x - alpha * (-a * sin(eta2)); + const double P2y = P3y - alpha * (b * cos(eta2)); + + Cx_local.push_back(P1x); + Cy_local.push_back(P1y); + Cx_local.push_back(P2x); + Cy_local.push_back(P2y); + Cx_local.push_back(P3x); + Cy_local.push_back(P3y); } + Cx.push_back(Cx_local); + Cy.push_back(Cy_local); + } - return; + return; } -void trackHyperbolaCore( std::vector< std::vector > &Cx, std::vector< std::vector > &Cy, - const double sign, const double a, const double b, std::vector &x, - const double *const Vx, const double *const Vy ) -{ - const int INTERVALS = PLOTPDFVAR::DEFAULT_P2_INERVALS; - - // y = sign * sqrt( a * x^2 + b ) +void trackHyperbolaCore(std::vector< std::vector< double > > &Cx, std::vector< std::vector< double > > &Cy, const double sign, const double a, const double b, std::vector< double > &x, + const double *const Vx, const double *const Vy) { + const int INTERVALS = PLOTPDFVAR::DEFAULT_P2_INERVALS; - std::sort( x.begin(), x.end() ); + // y = sign * sqrt( a * x^2 + b ) - std::vector Y; - for(size_t i = 0; i < x.size(); i++) - Y.push_back( sign * sqrt( a*x[i]*x[i] + b ) ); - - // algorithm in "Mathematical Illustrations" by Bill Casselman, - // Chapter 7, (2005) Cambridge University Press. - // https://www.cambridge.org/jp/academic/subjects/mathematics/geometry-and-topology/mathematical-illustrations-manual-geometry-and-postscript?format=PB&isbn=9780521547888 - // See also http://www.math.ubc.ca/~cass/graphics/text/www/ + std::sort(x.begin( ), x.end( )); - for(size_t i = 0; i+1 < x.size(); i++){ + std::vector< double > Y; + for (size_t i = 0; i < x.size( ); i++) Y.push_back(sign * sqrt(a * x[i] * x[i] + b)); - std::vector Cx_local, Cy_local; + // algorithm in "Mathematical Illustrations" by Bill Casselman, + // Chapter 7, (2005) Cambridge University Press. + // https://www.cambridge.org/jp/academic/subjects/mathematics/geometry-and-topology/mathematical-illustrations-manual-geometry-and-postscript?format=PB&isbn=9780521547888 + // See also http://www.math.ubc.ca/~cass/graphics/text/www/ - const double &X0 = x[i]; - const double &X1 = x[i+1]; - const double h = (X1 - X0) / INTERVALS; + for (size_t i = 0; i + 1 < x.size( ); i++) { - const double EPS = 1e-10; - if( h < EPS ) - continue; + std::vector< double > Cx_local, Cy_local; - // examine the arc X[i]--X[i+1] is inside triangle or not - const double mX0 = X0 + h/100; - const double mY0 = sign * sqrt( a*mX0*mX0 + b ); + const double &X0 = x[i]; + const double &X1 = x[i + 1]; + const double h = (X1 - X0) / INTERVALS; - const double mX1 = X1 - h/100; - const double mY1 = sign * sqrt( a*mX1*mX1 + b ); - if( !(isInsideTriangle( mX0, mY0, Vx, Vy ) && isInsideTriangle( mX1, mY1, Vx, Vy )) ) - continue; + const double EPS = 1e-10; + if (h < EPS) continue; + + // examine the arc X[i]--X[i+1] is inside triangle or not + const double mX0 = X0 + h / 100; + const double mY0 = sign * sqrt(a * mX0 * mX0 + b); + + const double mX1 = X1 - h / 100; + const double mY1 = sign * sqrt(a * mX1 * mX1 + b); + if (!(isInsideTriangle(mX0, mY0, Vx, Vy) && isInsideTriangle(mX1, mY1, Vx, Vy))) continue; + + Cx_local.push_back(X0); + Cy_local.push_back(Y[i]); + + for (int k = 0; k < INTERVALS; k++) { + + const double P0x = X0 + k * h; + const double P3x = X0 + (k + 1) * h; + const double P1x = P0x + h / 3; + const double P2x = P3x - h / 3; + + const double P0y = sign * sqrt(a * P0x * P0x + b); + const double P3y = sign * sqrt(a * P3x * P3x + b); + // y = f(x) = sqrt(a*x*x + b) + // => f' = 2*a*x / 2 / sqrt(a*x*x+b) = a*x/y + const double dY0 = a * P0x / P0y; + const double dY3 = a * P3x / P3y; + + const double P1y = P0y + h * dY0 / 3; + const double P2y = P3y - h * dY3 / 3; + + Cx_local.push_back(P1x); + Cy_local.push_back(P1y); + Cx_local.push_back(P2x); + Cy_local.push_back(P2y); + Cx_local.push_back(P3x); + Cy_local.push_back(P3y); + } - Cx_local.push_back( X0 ); - Cy_local.push_back( Y[i] ); - - for(int k = 0; k < INTERVALS; k++){ + Cx.push_back(Cx_local); + Cy.push_back(Cy_local); + } - const double P0x = X0 + k*h; - const double P3x = X0 + (k+1)*h; - const double P1x = P0x + h/3; - const double P2x = P3x - h/3; + return; +} - const double P0y = sign * sqrt( a*P0x*P0x + b ); - const double P3y = sign * sqrt( a*P3x*P3x + b ); - // y = f(x) = sqrt(a*x*x + b) - // => f' = 2*a*x / 2 / sqrt(a*x*x+b) = a*x/y - const double dY0 = a * P0x / P0y; - const double dY3 = a * P3x / P3y; +void trackHyperbola(std::vector< std::vector< double > > &Cx, std::vector< std::vector< double > > &Cy, const double *const PHI, const std::vector< double > &zx, const std::vector< double > &zy, + const double *const Vx, const double *const Vy) { + const double EPS = 1e-10; + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + const double &F = PHI[8]; + + assert(lambda1 * lambda2 < 0); + assert(fabs(lambda1) + fabs(lambda2) > EPS); + + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double P[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; + const double PT[2][2] = {{P[0][0], P[1][0]}, {P[0][1], P[1][1]}}; + + assert(zx.size( ) == zy.size( )); +#if 1 + std::vector< double > Zx, Zy; + for (size_t i = 0; i < zx.size( ); i++) { + Zx.push_back(PT[0][0] * zx[i] + PT[0][1] * zy[i] + D / (2 * lambda1)); + Zy.push_back(PT[1][0] * zx[i] + PT[1][1] * zy[i] + E / (2 * lambda2)); + } +#endif - const double P1y = P0y + h*dY0/3; - const double P2y = P3y - h*dY3/3; + if (lambda1 * F > 0) { - Cx_local.push_back( P1x ); Cy_local.push_back( P1y ); - Cx_local.push_back( P2x ); Cy_local.push_back( P2y ); - Cx_local.push_back( P3x ); Cy_local.push_back( P3y ); - } + // lambda1*(X')^2 + lambda2*(Y')^2 + F = 0 <=> Y' = \pm sqrt( (-lambda1*(X')^2 - F)/lambda2 ) + const double a = -lambda1 / lambda2; // Y' = \pm sqrt( a(X')^2 + b ) + const double b = -F / lambda2; - Cx.push_back( Cx_local ); - Cy.push_back( Cy_local ); + std::vector< double > Zx_plus, Zx_minus; + for (size_t i = 0; i < Zy.size( ); i++) { + if (Zy[i] > 0) { + Zx_plus.push_back(Zx[i]); + } else { + Zx_minus.push_back(Zx[i]); + } } - return; -} + // Y' = + sqrt( a(X')^2 + b ) + trackHyperbolaCore(Cx, Cy, +1, a, b, Zx_plus, Vx, Vy); -void trackHyperbola( std::vector< std::vector > &Cx, std::vector< std::vector > &Cy, - const double *const PHI, const std::vector &zx, const std::vector &zy, - const double *const Vx, const double *const Vy ) -{ - const double EPS = 1e-10; - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; const double &F = PHI[8]; + // Y' = - sqrt( a(X')^2 + b ) + trackHyperbolaCore(Cx, Cy, -1, a, b, Zx_minus, Vx, Vy); - assert( lambda1 * lambda2 < 0 ); - assert( fabs(lambda1) + fabs(lambda2) > EPS ); + } else { + static int count = 0; + if (!(lambda2 * F > 0) && verbosity && count++ < 3) cout << " plotPDF: bizarre bug " << lambda2 << " " << F << endl; - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double P[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; - const double PT[2][2] = { { P[0][0], P[1][0] }, { P[0][1], P[1][1] } }; + // lambda1*(X')^2 + lambda2*(Y')^2 + F = 0 <=> X' = \pm sqrt( (-lambda2*(Y')^2 - F) / lambda1 ) + const double a = -lambda2 / lambda1; // X' = \pm sqtt( a(Y')^2 + b ) + const double b = -F / lambda1; - assert( zx.size() == zy.size() ); -#if 1 - std::vector Zx, Zy; - for(size_t i = 0; i < zx.size(); i++){ - Zx.push_back( PT[0][0]*zx[i] + PT[0][1]*zy[i] + D/(2*lambda1) ); - Zy.push_back( PT[1][0]*zx[i] + PT[1][1]*zy[i] + E/(2*lambda2) ); + std::vector< double > Zy_plus, Zy_minus; + for (size_t i = 0; i < Zx.size( ); i++) { + if (Zx[i] > 0) { + Zy_plus.push_back(Zy[i]); + } else { + Zy_minus.push_back(Zy[i]); + } } -#endif - if( lambda1*F > 0 ){ - - // lambda1*(X')^2 + lambda2*(Y')^2 + F = 0 <=> Y' = \pm sqrt( (-lambda1*(X')^2 - F)/lambda2 ) - const double a = -lambda1/lambda2; // Y' = \pm sqrt( a(X')^2 + b ) - const double b = -F/lambda2; - - std::vector Zx_plus, Zx_minus; - for(size_t i = 0; i < Zy.size(); i++){ - if( Zy[i] > 0 ){ - Zx_plus.push_back( Zx[i] ); - } else { - Zx_minus.push_back( Zx[i] ); - } - } + // X' = + sqrt( a(Y')^2 + b ) + trackHyperbolaCore(Cy, Cx, +1, a, b, Zy_plus, Vy, Vx); - // Y' = + sqrt( a(X')^2 + b ) - trackHyperbolaCore( Cx, Cy, +1, a, b, Zx_plus, Vx, Vy ); + // X' = - sqrt( a(Y')^2 + b ) + trackHyperbolaCore(Cy, Cx, -1, a, b, Zy_minus, Vy, Vx); + } + return; +} - // Y' = - sqrt( a(X')^2 + b ) - trackHyperbolaCore( Cx, Cy, -1, a, b, Zx_minus, Vx, Vy ); +void plot_P2_isoline_body(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P2_, const std::vector< double > &isoline_val, const double cmin, const double cmax, + const KNM< double > &palette, const double scale, const double ar, const double x0, const double y0, const int marginl, const int marginb, const bool monochrome, + const bool logscale, const int NISOLINES, const double linewidth) { + const double EPS = 1e-10; - } else { - static int count = 0; - if (!( lambda2*F > 0 ) && verbosity && count++ <3 ) - cout << " plotPDF: bizarre bug "< X' = \pm sqrt( (-lambda2*(Y')^2 - F) / lambda1 ) - const double a = -lambda2/lambda1; // X' = \pm sqtt( a(Y')^2 + b ) - const double b = -F/lambda1; - - std::vector Zy_plus, Zy_minus; - for(size_t i = 0; i < Zx.size(); i++){ - if( Zx[i] > 0 ){ - Zy_plus.push_back( Zy[i] ); - } else { - Zy_minus.push_back( Zy[i] ); - } - } + std::stringstream &st = Content; - // X' = + sqrt( a(Y')^2 + b ) - trackHyperbolaCore( Cy, Cx, +1, a, b, Zy_plus, Vy, Vx ); + const int NQ = 6; // number of coefficients in quadratic polynomial + const int &nTriangles = Th.nt; - // X' = - sqrt( a(Y')^2 + b ) - trackHyperbolaCore( Cy, Cx, -1, a, b, Zy_minus, Vy, Vx ); + st << "q\n"; + st << linewidth << " w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - } - return; -} + for (int k = 0; k < nTriangles; k++) { -void plot_P2_isoline_body( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P2_, - const std::vector &isoline_val, const double cmin, const double cmax, - const KNM &palette, const double scale, const double ar, - const double x0, const double y0, - const int marginl, const int marginb, - const bool monochrome, const bool logscale, - const int NISOLINES, const double linewidth ) -{ - const double EPS = 1e-10; + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - std::stringstream &st = Content; + const double vx[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double vy[] = {Th(v0).y, Th(v1).y, Th(v2).y}; - const int NQ = 6; // number of coefficients in quadratic polynomial - const int &nTriangles = Th.nt; + // f_P2[i] = phi(v[i]), f_P2[i+3] = phi(e[i]), i=0,1,2. + const double *const f_P2 = f_P2_ + k * NQ; + // in vector2flow + // const double f_P2[NQ] = { f2[3*k], f2[3*k+1], f2[3*k+2], f2m[3*k], f2m[3*k+1], f2m[3*k+2] }; - st << "q\n"; - st << linewidth << " w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - - for(int k = 0; k < nTriangles; k++){ + // quadratic polynomials : ax^2 + bxy + cy^2 + dx + ey + f + double phi[NQ]; + const double &a = phi[0]; + const double &b = phi[1]; + const double &c = phi[2]; + const double &d = phi[3]; + const double &e = phi[4]; + const double &f = phi[5]; - const int &v0 = Th(k,0); const int &v1 = Th(k,1); const int &v2 = Th(k,2); + findQuadraticPolynomial(phi, vx, vy, f_P2); - const double vx[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double vy[] = { Th(v0).y, Th(v1).y, Th(v2).y }; + const bool isLinear = (fabs(a) + fabs(b) + fabs(c) < EPS * (fabs(d) + fabs(e) + fabs(f))); - // f_P2[i] = phi(v[i]), f_P2[i+3] = phi(e[i]), i=0,1,2. - const double *const f_P2 = f_P2_ + k*NQ; - // in vector2flow - //const double f_P2[NQ] = { f2[3*k], f2[3*k+1], f2[3*k+2], f2m[3*k], f2m[3*k+1], f2m[3*k+2] }; + // normalize Quadratic Polynomial + double PHI[9]; + findCanonicalForm(PHI, phi); - // quadratic polynomials : ax^2 + bxy + cy^2 + dx + ey + f - double phi[ NQ ]; - const double &a = phi[0]; const double &b = phi[1]; const double &c = phi[2]; - const double &d = phi[3]; const double &e = phi[4]; const double &f = phi[5]; + // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f + // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 + // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) + // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + double &F = PHI[8]; - findQuadraticPolynomial(phi, vx, vy, f_P2); - - const bool isLinear = (fabs(a) + fabs(b) + fabs(c) < EPS * (fabs(d)+fabs(e) + fabs(f))); + // lambda1*X^2 + lambda2*Y^2 + D*X + E*Y + f = value, + // if lambda2 == E == 0, then lambda1*X^2 + D*X + f = value, i.e. X=const + // if lambda1 == D == 0, then lambda2*Y^2 + E*Y + f = value, i.e. Y=const + const bool isParallelY = (fabs(lambda2) + fabs(E) < EPS * (fabs(lambda1) + fabs(D) + fabs(F))); + const bool isParallelX = (fabs(lambda1) + fabs(D) < EPS * (fabs(lambda2) + fabs(E) + fabs(F))); - // normalize Quadratic Polynomial - double PHI[9]; - findCanonicalForm( PHI, phi ); + // Question: If PHI - isovalue = (a1 X + b1 Y + c1)(a2 X + b2 Y + c2) = 0, what happes? + if (isLinear || isParallelX || isParallelY) { // phi(x,y) is linear - // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f - // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 - // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) - // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; double &F = PHI[8]; + for (size_t m = 0; m < isoline_val.size( ); m++) { - // lambda1*X^2 + lambda2*Y^2 + D*X + E*Y + f = value, - // if lambda2 == E == 0, then lambda1*X^2 + D*X + f = value, i.e. X=const - // if lambda1 == D == 0, then lambda2*Y^2 + E*Y + f = value, i.e. Y=const - const bool isParallelY = (fabs(lambda2) + fabs(E) < EPS * (fabs(lambda1)+fabs(D) + fabs(F))); - const bool isParallelX = (fabs(lambda1) + fabs(D) < EPS * (fabs(lambda2)+fabs(E) + fabs(F))); + const double &value = isoline_val[m]; - // Question: If PHI - isovalue = (a1 X + b1 Y + c1)(a2 X + b2 Y + c2) = 0, what happes? - if( isLinear || isParallelX || isParallelY ){ // phi(x,y) is linear + std::vector< double > px, py; + trackP1isoline(px, py, vx, vy, value, f_P2); - for(size_t m = 0; m < isoline_val.size(); m++){ + assert(px.size( ) == py.size( )); - const double &value = isoline_val[m]; - - std::vector px, py; - trackP1isoline( px, py, vx, vy, value, f_P2 ); + if (px.size( ) == 0) continue; // goto next isoline_val - assert( px.size() == py.size() ); + setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); - if( px.size() == 0 ) continue; // goto next isoline_val + if (px.size( ) > 3) { - setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); + // f(x,y)==value on all vertices, i.e. f(x,y) \equiv value on the triangle + st << "rg\n"; + st << scale * ar * (vx[0] - x0) << ' ' << scale * (vy[0] - y0) << " m " << scale * ar * (vx[1] - x0) << ' ' << scale * (vy[1] - y0) << " l " << scale * ar * (vx[2] - x0) << ' ' + << scale * (vy[2] - y0) << " l f\n"; - if( px.size() > 3 ){ + } else { - // f(x,y)==value on all vertices, i.e. f(x,y) \equiv value on the triangle - st << "rg\n"; - st << scale*ar*(vx[0] - x0) << ' ' << scale*(vy[0] - y0) << " m " - << scale*ar*(vx[1] - x0) << ' ' << scale*(vy[1] - y0) << " l " - << scale*ar*(vx[2] - x0) << ' ' << scale*(vy[2] - y0) << " l f\n"; - - } else { + // assert( (px.size() == 2) || (px.size() == 3) ); + st << "RG\n"; + st << scale * ar * (px[0] - x0) << ' ' << scale * (py[0] - y0) << " m " << scale * ar * (px[1] - x0) << ' ' << scale * (py[1] - y0) << " l S\n"; + } + } - // assert( (px.size() == 2) || (px.size() == 3) ); - st << "RG\n"; - st << scale*ar*(px[0] - x0) << ' ' << scale*(py[0] - y0) << " m " - << scale*ar*(px[1] - x0) << ' ' << scale*(py[1] - y0) << " l S\n"; - } - } + continue; // goto next Triangle + } - continue; // goto next Triangle - } + double Vx[3], Vy[3]; + transformTriangle(Vx, Vy, vx, vy, PHI); - double Vx[3], Vy[3]; - transformTriangle( Vx, Vy, vx, vy, PHI ); + const bool isParabolic = (fabs(lambda1) < EPS) || (fabs(lambda2) < EPS); + const bool isElliptic = (!isParabolic) && (lambda1 * lambda2 > 0); + const bool isHyperbolic = (!isParabolic) && (lambda1 * lambda2 < 0); - const bool isParabolic = (fabs(lambda1) < EPS) || (fabs(lambda2) < EPS); - const bool isElliptic = (!isParabolic) && (lambda1*lambda2 > 0); - const bool isHyperbolic = (!isParabolic) && (lambda1*lambda2 < 0); + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double p[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double p[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; + for (size_t m = 0; m < isoline_val.size( ); m++) { - for(size_t m = 0; m < isoline_val.size(); m++){ - - const double &value = isoline_val[m]; + const double &value = isoline_val[m]; - // examine values of phi at all vertices - double phi_vertices[3]; - for(int i = 0; i < 3; i++) - phi_vertices[i] = a*vx[i]*vx[i] + b*vx[i]*vy[i] + c*vy[i]*vy[i] + d*vx[i] + e*vy[i] + f - value; + // examine values of phi at all vertices + double phi_vertices[3]; + for (int i = 0; i < 3; i++) phi_vertices[i] = a * vx[i] * vx[i] + b * vx[i] * vy[i] + c * vy[i] * vy[i] + d * vx[i] + e * vy[i] + f - value; - // If phi == value at all three vertices, then skip - // the curve phi==value is ellipse outside the triangle, - // or two lines (factrization of hyperbola), which coinside with segments. - // BUG: there is exception: two lines case - if( fabs(phi_vertices[0]) + fabs(phi_vertices[1]) + fabs(phi_vertices[2]) < EPS ) - continue; + // If phi == value at all three vertices, then skip + // the curve phi==value is ellipse outside the triangle, + // or two lines (factrization of hyperbola), which coinside with segments. + // BUG: there is exception: two lines case + if (fabs(phi_vertices[0]) + fabs(phi_vertices[1]) + fabs(phi_vertices[2]) < EPS) continue; - std::vector zx, zy; - findZeros( zx, zy, vx[0], vy[0], vx[1], vy[1], phi, value ); - findZeros( zx, zy, vx[1], vy[1], vx[2], vy[2], phi, value ); - findZeros( zx, zy, vx[2], vy[2], vx[0], vy[0], phi, value ); + std::vector< double > zx, zy; + findZeros(zx, zy, vx[0], vy[0], vx[1], vy[1], phi, value); + findZeros(zx, zy, vx[1], vy[1], vx[2], vy[2], phi, value); + findZeros(zx, zy, vx[2], vy[2], vx[0], vy[0], phi, value); - assert( zx.size() == zy.size() ); + assert(zx.size( ) == zy.size( )); - F -= value; // modify constant term in the canonical form - - setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); - st << "RG\n"; + F -= value; // modify constant term in the canonical form - std::vector< std::vector > Cx, Cy; // control points of Bezier curves PHI=0 + setrgbcolor(st, value, palette, cmin, cmax, monochrome, logscale); + st << "RG\n"; - if( isParabolic && (zx.size() >= 2) ){ + std::vector< std::vector< double > > Cx, Cy; // control points of Bezier curves PHI=0 - trackParabola(Cx, Cy, PHI, zx, zy, Vx, Vy); + if (isParabolic && (zx.size( ) >= 2)) { - } else if( isElliptic ){ + trackParabola(Cx, Cy, PHI, zx, zy, Vx, Vy); - if( zx.size() >= 2 ){ + } else if (isElliptic) { - trackEllipse(Cx, Cy, PHI, zx, zy, Vx, Vy); + if (zx.size( ) >= 2) { - } else { + trackEllipse(Cx, Cy, PHI, zx, zy, Vx, Vy); - // Ellipse is included inside triangle (might tangent to an edge) - // draw whole ellipse - trackEllipse(Cx, Cy, PHI, Vx, Vy); - } - - } else if( isHyperbolic && (zx.size() >= 2) ){ + } else { - trackHyperbola(Cx, Cy, PHI, zx, zy, Vx, Vy); - } + // Ellipse is included inside triangle (might tangent to an edge) + // draw whole ellipse + trackEllipse(Cx, Cy, PHI, Vx, Vy); + } - if( Cx.size() > 0 ) { + } else if (isHyperbolic && (zx.size( ) >= 2)) { - invTransformCubicBzeirs( Cx, Cy, PHI ); - drawCubicBeziers( st, Cx, Cy, scale, ar, x0, y0 ); - } + trackHyperbola(Cx, Cy, PHI, zx, zy, Vx, Vy); + } - F += value; // recover the canonical form + if (Cx.size( ) > 0) { - } // for isoline_val - - } // for triangle + invTransformCubicBzeirs(Cx, Cy, PHI); + drawCubicBeziers(st, Cx, Cy, scale, ar, x0, y0); + } - st << "Q\n"; + F += value; // recover the canonical form - return; + } // for isoline_val + + } // for triangle + + st << "Q\n"; + + return; } -void plot_P2_isoline( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P2_, - const KNM &palette, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const int NISOLINES, const KN*const viso, - const double linewidth ) -{ - const double EPS = 1e-10; +void plot_P2_isoline(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P2_, const KNM< double > &palette, const int sizex, const int sizey, const double scale, const double ar, + const double x0, const double y0, const double y1, const int marginl, const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, + const bool logscale, const double withmesh, const int NISOLINES, const KN< double > *const viso, const double linewidth) { + const double EPS = 1e-10; - //------------------------------ - // values to plot - //------------------------------ - const double fmax = (viso)? viso->max(): f_P2_.max(); - const double fmin = (viso)? viso->min(): f_P2_.min(); - std::vector isoline_val; + //------------------------------ + // values to plot + //------------------------------ + const double fmax = (viso) ? viso->max( ) : f_P2_.max( ); + const double fmin = (viso) ? viso->min( ) : f_P2_.min( ); + std::vector< double > isoline_val; - find_isoline_values( isoline_val, fmax, fmin, NISOLINES, viso, logscale ); + find_isoline_values(isoline_val, fmax, fmin, NISOLINES, viso, logscale); - // color/gray-scale range to plot + // color/gray-scale range to plot #if 1 - // If user specifies an irrelevant color range (in viso array), - // we do not take care of it. - const double cmax = *max_element( isoline_val.begin(), isoline_val.end() ); - const double cmin = *min_element( isoline_val.begin(), isoline_val.end() ); + // If user specifies an irrelevant color range (in viso array), + // we do not take care of it. + const double cmax = *max_element(isoline_val.begin( ), isoline_val.end( )); + const double cmin = *min_element(isoline_val.begin( ), isoline_val.end( )); #else - // map color/grayscale range to function values - const double cmax = fmax; - const double cmin = fmin; + // map color/grayscale range to function values + const double cmax = fmax; + const double cmin = fmin; #endif - std::stringstream &st = Content; - st.str(""); + std::stringstream &st = Content; + st.str(""); - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); - - plot_P2_isoline_body( st, Th, f_P2_, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, - marginl, marginb, monochrome, logscale, NISOLINES, linewidth ); + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); - if( legend ) - drawLegend_contour( st, isoline_val, prec, palette, cmin, cmax, - monochrome, logscale, sizex, textfontsize, scale, - y1, y0, marginl, marginb); + plot_P2_isoline_body(st, Th, f_P2_, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, marginl, marginb, monochrome, logscale, NISOLINES, linewidth); - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + if (legend) drawLegend_contour(st, isoline_val, prec, palette, cmin, cmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); - return; -} // + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); -bool isSegment( const std::vector &cx, const std::vector &cy, const int i ) -{ - // examine a part of cubic Bezier curve (i--i+1--i+2--i+3) is a segment or not. - return (cx[i] == cx[i+1]) && (cy[i] == cy[i+1]) && (cx[i+2] == cx[i+3]) && (cy[i+2] == cy[i+3]); + return; +} // + +bool isSegment(const std::vector< double > &cx, const std::vector< double > &cy, const int i) { + // examine a part of cubic Bezier curve (i--i+1--i+2--i+3) is a segment or not. + return (cx[i] == cx[i + 1]) && (cy[i] == cy[i + 1]) && (cx[i + 2] == cx[i + 3]) && (cy[i + 2] == cy[i + 3]); } -int findSegment( const double x, const double y, - const std::vector &cx, const std::vector &cy ) -{ - const double EPS = 1e-10; +int findSegment(const double x, const double y, const std::vector< double > &cx, const std::vector< double > &cy) { + const double EPS = 1e-10; - // cx and cy are control points of cubic Bezier curve. - // (cx[0],cy[0]) -- (cx[1],cy[1]) -- (cx[2],cy[2]) -- (cx[3],cy[3]) : 0 - // -- ... - // -- (cx[3i+1],cy[3i+1]) -- (cx[3i+2],cy[3i+2]) -- (cx[3i+3],cy[3i+3]) : 3i + // cx and cy are control points of cubic Bezier curve. + // (cx[0],cy[0]) -- (cx[1],cy[1]) -- (cx[2],cy[2]) -- (cx[3],cy[3]) : 0 + // -- ... + // -- (cx[3i+1],cy[3i+1]) -- (cx[3i+2],cy[3i+2]) -- (cx[3i+3],cy[3i+3]) : 3i - for(size_t i = 0; i+3 < cx.size(); i += 3){ + for (size_t i = 0; i + 3 < cx.size( ); i += 3) { - if( !isSegment( cx, cy, i ) ) - continue; + if (!isSegment(cx, cy, i)) continue; - const double &x0 = cx[i]; const double &y0 = cy[i]; - const double &x1 = cx[i+3]; const double &y1 = cy[i+3]; - - // if (x,y) \in (x0,y0) -- (x1,y1), then - // x = (1-t)*x0 + t*x1 and y = (1-t)*y0 + t*y1, 0 <= t <= 1 - // <=> x = x0 - t*x0 + t*x1, y = y0 - t*y0 + t*y1 - // <=> t = (x-x0) / (x1-x0) = (y-y0) / (y1-y0) + const double &x0 = cx[i]; + const double &y0 = cy[i]; + const double &x1 = cx[i + 3]; + const double &y1 = cy[i + 3]; - if( fabs( (x-x0)*(y1-y0) - (x1-x0)*(y-y0) ) > EPS ) - continue; + // if (x,y) \in (x0,y0) -- (x1,y1), then + // x = (1-t)*x0 + t*x1 and y = (1-t)*y0 + t*y1, 0 <= t <= 1 + // <=> x = x0 - t*x0 + t*x1, y = y0 - t*y0 + t*y1 + // <=> t = (x-x0) / (x1-x0) = (y-y0) / (y1-y0) - if( fabs( x1-x0 ) > EPS ){ - const double t = (x-x0) / (x1-x0); + if (fabs((x - x0) * (y1 - y0) - (x1 - x0) * (y - y0)) > EPS) continue; - if( (-EPS < t) && (t < 1+EPS) ) - return i; - } + if (fabs(x1 - x0) > EPS) { + const double t = (x - x0) / (x1 - x0); - if( fabs( y1-y0 ) > EPS ){ - const double t = (y-y0) / (y1-y0); - - if( (-EPS < t) && (t < 1+EPS) ) - return i; - } + if ((-EPS < t) && (t < 1 + EPS)) return i; } - return -1; + if (fabs(y1 - y0) > EPS) { + const double t = (y - y0) / (y1 - y0); + + if ((-EPS < t) && (t < 1 + EPS)) return i; + } + } + + return -1; } -void splitByBorder( std::vector< std::vector > &partition_x, std::vector< std::vector > &partition_y, - const std::vector< std::vector > &cxs, const std::vector< std::vector > &cys ) -{ - assert( partition_x.size() == partition_y.size() ); - assert( cxs.size() == cys.size() ); +void splitByBorder(std::vector< std::vector< double > > &partition_x, std::vector< std::vector< double > > &partition_y, const std::vector< std::vector< double > > &cxs, + const std::vector< std::vector< double > > &cys) { + assert(partition_x.size( ) == partition_y.size( )); + assert(cxs.size( ) == cys.size( )); - for(size_t i = 0; i < cxs.size(); i++){ + for (size_t i = 0; i < cxs.size( ); i++) { - std::vector cx = cxs[i]; - std::vector cy = cys[i]; + std::vector< double > cx = cxs[i]; + std::vector< double > cy = cys[i]; - assert( cx.size() == cy.size() ); + assert(cx.size( ) == cy.size( )); - const double &beg_x = cx[0]; - const double &beg_y = cy[0]; - - const double &end_x = cx.back(); // cx[ cx.size()-1 ] - const double &end_y = cy.back(); // cy[ cy.size()-1 ] + const double &beg_x = cx[0]; + const double &beg_y = cy[0]; - for(size_t j = 0; j < partition_x.size(); j++){ + const double &end_x = cx.back( ); // cx[ cx.size()-1 ] + const double &end_y = cy.back( ); // cy[ cy.size()-1 ] - const std::vector &px = partition_x[j]; - const std::vector &py = partition_y[j]; + for (size_t j = 0; j < partition_x.size( ); j++) { - assert( px.size() == py.size() ); + const std::vector< double > &px = partition_x[j]; + const std::vector< double > &py = partition_y[j]; - int beg_id = findSegment( beg_x, beg_y, px, py ); + assert(px.size( ) == py.size( )); - if( beg_id < 0 ) continue; + int beg_id = findSegment(beg_x, beg_y, px, py); - int end_id = findSegment( end_x, end_y, px, py ); + if (beg_id < 0) continue; - if( end_id < 0 ) continue; + int end_id = findSegment(end_x, end_y, px, py); - // findSegment returns 3n ( multiple of 3 ) + if (end_id < 0) continue; - if( end_id < beg_id ){ - int tmp_id = beg_id; - beg_id = end_id; - end_id = tmp_id; - std::reverse(cx.begin(), cx.end()); - std::reverse(cy.begin(), cy.end()); - } + // findSegment returns 3n ( multiple of 3 ) - if( beg_id == end_id ){ + if (end_id < beg_id) { + int tmp_id = beg_id; + beg_id = end_id; + end_id = tmp_id; + std::reverse(cx.begin( ), cx.end( )); + std::reverse(cy.begin( ), cy.end( )); + } - if( (px[beg_id]-beg_x)*(px[beg_id]-beg_x) + (py[beg_id]-beg_y)*(py[beg_id]-beg_y) - > (px[beg_id]-end_x)*(px[beg_id]-end_x) + (py[beg_id]-end_y)*(py[beg_id]-end_y) ){ + if (beg_id == end_id) { - std::reverse(cx.begin(), cx.end()); - std::reverse(cy.begin(), cy.end()); - } - } + if ((px[beg_id] - beg_x) * (px[beg_id] - beg_x) + (py[beg_id] - beg_y) * (py[beg_id] - beg_y) > (px[beg_id] - end_x) * (px[beg_id] - end_x) + (py[beg_id] - end_y) * (py[beg_id] - end_y)) { - // begin and end points are on segment beg_id-component and end_id-component respectively, - // which are parts of boundary of partition. - // partition_x, partition_y are represented as a cubic Bezier curve + std::reverse(cx.begin( ), cx.end( )); + std::reverse(cy.begin( ), cy.end( )); + } + } - std::vector p0x, p0y; + // begin and end points are on segment beg_id-component and end_id-component respectively, + // which are parts of boundary of partition. + // partition_x, partition_y are represented as a cubic Bezier curve - for(size_t k = 0; k <= beg_id+1; k++){ - p0x.push_back( px[k] ); - p0y.push_back( py[k] ); - } + std::vector< double > p0x, p0y; - p0x.push_back( cx[0] ); p0y.push_back( cy[0] ); + for (size_t k = 0; k <= beg_id + 1; k++) { + p0x.push_back(px[k]); + p0y.push_back(py[k]); + } - for(size_t k = 0; k < cx.size(); k++){ - p0x.push_back( cx[k] ); - p0y.push_back( cy[k] ); - } + p0x.push_back(cx[0]); + p0y.push_back(cy[0]); - p0x.push_back( cx.back() ); p0y.push_back( cy.back() ); + for (size_t k = 0; k < cx.size( ); k++) { + p0x.push_back(cx[k]); + p0y.push_back(cy[k]); + } - for(size_t k = end_id+2; k < px.size(); k++){ - p0x.push_back( px[k] ); - p0y.push_back( py[k] ); - } + p0x.push_back(cx.back( )); + p0y.push_back(cy.back( )); - std::vector p1x, p1y; + for (size_t k = end_id + 2; k < px.size( ); k++) { + p0x.push_back(px[k]); + p0y.push_back(py[k]); + } - p1x.push_back( cx[0] ); p1y.push_back( cy[0] ); - p1x.push_back( cx[0] ); p1y.push_back( cy[0] ); + std::vector< double > p1x, p1y; - for(size_t k = beg_id+2; k <= end_id+1; k++){ - p1x.push_back( px[k] ); - p1y.push_back( py[k] ); - } + p1x.push_back(cx[0]); + p1y.push_back(cy[0]); + p1x.push_back(cx[0]); + p1y.push_back(cy[0]); - p1x.push_back( cx.back() ); p1y.push_back( cy.back() ); + for (size_t k = beg_id + 2; k <= end_id + 1; k++) { + p1x.push_back(px[k]); + p1y.push_back(py[k]); + } - for(int k = cx.size()-1; k >= 0; k--){ - p1x.push_back( cx[k] ); - p1y.push_back( cy[k] ); - } + p1x.push_back(cx.back( )); + p1y.push_back(cy.back( )); - partition_x.erase( partition_x.begin() + j ); - partition_y.erase( partition_y.begin() + j ); + for (int k = cx.size( ) - 1; k >= 0; k--) { + p1x.push_back(cx[k]); + p1y.push_back(cy[k]); + } - partition_x.push_back( p0x ); partition_y.push_back( p0y ); - partition_x.push_back( p1x ); partition_y.push_back( p1y ); + partition_x.erase(partition_x.begin( ) + j); + partition_y.erase(partition_y.begin( ) + j); - break; - } + partition_x.push_back(p0x); + partition_y.push_back(p0y); + partition_x.push_back(p1x); + partition_y.push_back(p1y); + + break; } + } - return; + return; } -double findFillValue( const std::vector &cx, const std::vector &cy, const double *const phi ) -{ - const double &a = phi[0]; const double &b = phi[1]; const double &c = phi[2]; - const double &d = phi[3]; const double &e = phi[4]; const double &f = phi[5]; +double findFillValue(const std::vector< double > &cx, const std::vector< double > &cy, const double *const phi) { + const double &a = phi[0]; + const double &b = phi[1]; + const double &c = phi[2]; + const double &d = phi[3]; + const double &e = phi[4]; + const double &f = phi[5]; - int npoints = 0; + int npoints = 0; - // find average of phi at nodal points - double sum = 0; - for(size_t i = 0; i < cx.size(); i += 3){ + // find average of phi at nodal points + double sum = 0; + for (size_t i = 0; i < cx.size( ); i += 3) { - const double &x = cx[i]; - const double &y = cy[i]; + const double &x = cx[i]; + const double &y = cy[i]; - sum += (a*x*x + b*x*y + c*y*y + d*x + e*y + f); - npoints++; + sum += (a * x * x + b * x * y + c * y * y + d * x + e * y + f); + npoints++; - if( (i+3 < cx.size()) && isSegment(cx,cy,i) ){ + if ((i + 3 < cx.size( )) && isSegment(cx, cy, i)) { - const double mx = ( cx[i]+cx[i+3] ) / 2; - const double my = ( cy[i]+cy[i+3] ) / 2; - sum += (a*mx*mx + b*mx*my + c*my*my + d*mx + e*my + f); - npoints++; - } + const double mx = (cx[i] + cx[i + 3]) / 2; + const double my = (cy[i] + cy[i + 3]) / 2; + sum += (a * mx * mx + b * mx * my + c * my * my + d * mx + e * my + f); + npoints++; } + } - return sum / npoints; + return sum / npoints; } -void P2_fill_linear( std::stringstream &Content, - const Fem2D::Mesh &Th, const int triangle_id, - const double *const vf, - const KNM &palette, - const double fmax, const double fmin, const double df, - const int nbfill, const KN *const frange, - const double scale, const double ar, const double x0, const double y0, - const bool monochrome, const bool logscale ) -{ - std::stringstream &st = Content; +void P2_fill_linear(std::stringstream &Content, const Fem2D::Mesh &Th, const int triangle_id, const double *const vf, const KNM< double > &palette, const double fmax, const double fmin, + const double df, const int nbfill, const KN< double > *const frange, const double scale, const double ar, const double x0, const double y0, const bool monochrome, + const bool logscale) { + std::stringstream &st = Content; - const int &v0 = Th(triangle_id,0); - const int &v1 = Th(triangle_id,1); - const int &v2 = Th(triangle_id,2); - const double x[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double y[] = { Th(v0).y, Th(v1).y, Th(v2).y }; - // phi(x,y) = a*x + b*y + c - const double *const &phi = vf; + const int &v0 = Th(triangle_id, 0); + const int &v1 = Th(triangle_id, 1); + const int &v2 = Th(triangle_id, 2); + const double x[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double y[] = {Th(v0).y, Th(v1).y, Th(v2).y}; + // phi(x,y) = a*x + b*y + c + const double *const &phi = vf; - // find minimum - int v_min = 2; - int end1 = 0; // destination point - int end2 = 1; // destination point - - if( (phi[0] <= phi[1]) && (phi[0] <= phi[2]) ){ - v_min = 0; - end1 = 1; - end2 = 2; - } else if( (phi[1] <= phi[0]) && (phi[1] <= phi[2]) ){ - v_min = 1; - end1 = 2; - end2 = 0; + // find minimum + int v_min = 2; + int end1 = 0; // destination point + int end2 = 1; // destination point + + if ((phi[0] <= phi[1]) && (phi[0] <= phi[2])) { + v_min = 0; + end1 = 1; + end2 = 2; + } else if ((phi[1] <= phi[0]) && (phi[1] <= phi[2])) { + v_min = 1; + end1 = 2; + end2 = 0; + } + + if (frange && (fmax < phi[v_min])) return; + + if (frange && (phi[end1] < fmin) && (phi[end2] < fmin)) return; + + int beg1 = v_min; // current point + int beg2 = v_min; // current point + double t1 = 0; // secting parameters on edge beg1--end1 + double t2 = 0; // secting parameters on edge beg2--end2 + + int level = (logscale) ? static_cast< int >(log(phi[v_min] / fmin) / log(df)) : static_cast< int >((phi[v_min] - fmin) / df); + + double f = (logscale) ? (pow(df, level) * fmin) : (level * df + fmin); + + if (frange && (phi[v_min] < fmin)) { + + if (phi[end1] < fmin) { + beg1 = end1; + end1 = end2; + } + if (phi[end2] < fmin) { + beg2 = end2; + end2 = end1; } - if( frange && (fmax < phi[v_min]) ) - return; + t1 = (fmin - phi[beg1]) / (phi[end1] - phi[beg1]); + t2 = (fmin - phi[beg2]) / (phi[end2] - phi[beg2]); + level = 0; + f = fmin; + } - if( frange && (phi[end1] < fmin) && (phi[end2] < fmin) ) - return; + do { + const double EPS = 1e-10; + if ((end1 == end2) && (t1 >= 1 - EPS) && (t2 >= 1 - EPS)) break; - int beg1 = v_min; // current point - int beg2 = v_min; // current point - double t1 = 0; // secting parameters on edge beg1--end1 - double t2 = 0; // secting parameters on edge beg2--end2 + if ((end1 == end2) && (t1 >= 1 - EPS) && (t2 >= 1 - EPS)) break; - int level = (logscale)? - static_cast( log(phi[v_min]/fmin) / log(df) ): - static_cast( (phi[v_min]-fmin) / df ); - - double f = (logscale)? (pow(df,level) * fmin) : (level*df + fmin); + // find points which divide edges by t:(1-t1), t2:(1-t2) respectively + const double p1x = (1 - t1) * x[beg1] + t1 * x[end1]; + const double p1y = (1 - t1) * y[beg1] + t1 * y[end1]; + const double p2x = (1 - t2) * x[beg2] + t2 * x[end2]; + const double p2y = (1 - t2) * y[beg2] + t2 * y[end2]; - if( frange && (phi[v_min] < fmin) ){ + const double f_next = (logscale) ? f * df : f + df; - if( phi[end1] < fmin ){ - beg1 = end1; - end1 = end2; - } if( phi[end2] < fmin ){ - beg2 = end2; - end2 = end1; - } + if (frange && (fmax - EPS <= f)) break; - t1 = (fmin - phi[beg1]) / (phi[end1] - phi[beg1]); - t2 = (fmin - phi[beg2]) / (phi[end2] - phi[beg2]); - level = 0; - f = fmin; + if (level == 0) { + setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); + } else if (level >= nbfill - 1) { + + // exceptional handling : if local minimum (in triangle) is + // already global maximum, then level == nbfill. + // Thus the condition is not level == nbfill-1, + // but level >= nbfill-1. + setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + + } else { + const double c = (logscale) ? (pow(df, level + 0.5) * fmin) : ((level + 0.5) * df + fmin); + setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); } + st << "rg\n"; - do { - const double EPS = 1e-10; - if( (end1 == end2) && (t1 >= 1-EPS) && (t2 >= 1-EPS) ) - break; - - if( (end1 == end2) && (t1 >= 1-EPS) && (t2 >= 1-EPS) ) - break; - - // find points which divide edges by t:(1-t1), t2:(1-t2) respectively - const double p1x = (1-t1)*x[beg1] + t1*x[end1]; - const double p1y = (1-t1)*y[beg1] + t1*y[end1]; - const double p2x = (1-t2)*x[beg2] + t2*x[end2]; - const double p2y = (1-t2)*y[beg2] + t2*y[end2]; - - const double f_next = (logscale)? f * df: f + df; - - if( frange && (fmax-EPS <= f) ) - break; - - if( level == 0 ){ - setrgbcolor(st, fmin, palette, fmin, fmax, monochrome, logscale); - } else if( level >= nbfill-1 ){ - - // exceptional handling : if local minimum (in triangle) is - // already global maximum, then level == nbfill. - // Thus the condition is not level == nbfill-1, - // but level >= nbfill-1. - setrgbcolor(st, fmax, palette, fmin, fmax, monochrome, logscale); + if ((f_next >= phi[end1]) && (f_next >= phi[end2])) { - } else { - const double c = (logscale)? - (pow(df,level+0.5)*fmin): ((level+0.5)*df + fmin); - setrgbcolor(st, c, palette, fmin, fmax, monochrome, logscale); - } - st << "rg\n"; - - if( (f_next >= phi[end1]) && (f_next >= phi[end2]) ){ + st << scale * ar * (p1x - x0) << ' ' << scale * (p1y - y0) << " m " << scale * ar * (x[end1] - x0) << ' ' << scale * (y[end1] - y0) << " l " << scale * ar * (x[end2] - x0) << ' ' + << scale * (y[end2] - y0) << " l " << scale * ar * (p2x - x0) << ' ' << scale * (p2y - y0) << " l f\n"; - st << scale*ar*(p1x-x0) << ' ' << scale*(p1y-y0) << " m " - << scale*ar*(x[end1]-x0) << ' ' << scale*(y[end1]-y0) << " l " - << scale*ar*(x[end2]-x0) << ' ' << scale*(y[end2]-y0) << " l " - << scale*ar*(p2x-x0) << ' ' << scale*(p2y-y0) << " l f\n"; + break; + } - break; - } + if (f_next >= phi[end1]) { - if( f_next >= phi[end1] ){ - - st << scale*ar*(p1x-x0) << ' ' << scale*(p1y-y0) << " m " - << scale*ar*(x[end1]-x0) << ' ' << scale*(y[end1]-y0) << " l " - << scale*ar*(p2x-x0) << ' ' << scale*(p2y-y0) << " l f\n"; - - beg1 = end1; - end1 = end2; - t1 = 0; - continue; - } - - if( f_next >= phi[end2] ){ - - st << scale*ar*(p1x-x0) << ' ' << scale*(p1y-y0) << " m " - << scale*ar*(x[end2]-x0) << ' ' << scale*(y[end2]-y0) << " l " - << scale*ar*(p2x-x0) << ' ' << scale*(p2y-y0) << " l f\n"; - - beg2 = end2; - end2 = end1; - t2 = 0; - continue; - } + st << scale * ar * (p1x - x0) << ' ' << scale * (p1y - y0) << " m " << scale * ar * (x[end1] - x0) << ' ' << scale * (y[end1] - y0) << " l " << scale * ar * (p2x - x0) << ' ' + << scale * (p2y - y0) << " l f\n"; - const double t1_next = (f_next - phi[beg1]) / (phi[end1] - phi[beg1]); - const double t2_next = (f_next - phi[beg2]) / (phi[end2] - phi[beg2]); + beg1 = end1; + end1 = end2; + t1 = 0; + continue; + } - const double q1x = (1-t1_next)*x[beg1] + t1_next*x[end1]; - const double q1y = (1-t1_next)*y[beg1] + t1_next*y[end1]; - const double q2x = (1-t2_next)*x[beg2] + t2_next*x[end2]; - const double q2y = (1-t2_next)*y[beg2] + t2_next*y[end2]; + if (f_next >= phi[end2]) { - st << scale*ar*(p1x-x0) << ' ' << scale*(p1y-y0) << " m " - << scale*ar*(q1x-x0) << ' ' << scale*(q1y-y0) << " l " - << scale*ar*(q2x-x0) << ' ' << scale*(q2y-y0) << " l " - << scale*ar*(p2x-x0) << ' ' << scale*(p2y-y0) << " l f\n"; + st << scale * ar * (p1x - x0) << ' ' << scale * (p1y - y0) << " m " << scale * ar * (x[end2] - x0) << ' ' << scale * (y[end2] - y0) << " l " << scale * ar * (p2x - x0) << ' ' + << scale * (p2y - y0) << " l f\n"; - // update - f = f_next; - level++; - t1 = t1_next; - t2 = t2_next; + beg2 = end2; + end2 = end1; + t2 = 0; + continue; + } - } while(level <= nbfill); + const double t1_next = (f_next - phi[beg1]) / (phi[end1] - phi[beg1]); + const double t2_next = (f_next - phi[beg2]) / (phi[end2] - phi[beg2]); - return; + const double q1x = (1 - t1_next) * x[beg1] + t1_next * x[end1]; + const double q1y = (1 - t1_next) * y[beg1] + t1_next * y[end1]; + const double q2x = (1 - t2_next) * x[beg2] + t2_next * x[end2]; + const double q2y = (1 - t2_next) * y[beg2] + t2_next * y[end2]; + + st << scale * ar * (p1x - x0) << ' ' << scale * (p1y - y0) << " m " << scale * ar * (q1x - x0) << ' ' << scale * (q1y - y0) << " l " << scale * ar * (q2x - x0) << ' ' << scale * (q2y - y0) + << " l " << scale * ar * (p2x - x0) << ' ' << scale * (p2y - y0) << " l f\n"; + + // update + f = f_next; + level++; + t1 = t1_next; + t2 = t2_next; + + } while (level <= nbfill); + + return; } -void plot_P2_fill( std::stringstream &Content, const Fem2D::Mesh &Th, const KN &f_P2_, - const KNM &palette, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const long nbfill, const KN *const frange ) -{ - const double EPS = 1e-10; +void plot_P2_fill(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &f_P2_, const KNM< double > &palette, const int sizex, const int sizey, const double scale, const double ar, + const double x0, const double y0, const double y1, const int marginl, const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, + const bool logscale, const double withmesh, const long nbfill, const KN< double > *const frange) { + const double EPS = 1e-10; - //------------------------------ - // borders to plot - //------------------------------ - const double tmp_fmax = (frange)? (*frange)[1]: f_P2_.max(); - const double tmp_fmin = (frange)? (*frange)[0]: f_P2_.min(); - const double tmp_df = (logscale)? - pow( tmp_fmax/tmp_fmin, static_cast(1)/nbfill ): - (tmp_fmax - tmp_fmin)/nbfill; + //------------------------------ + // borders to plot + //------------------------------ + const double tmp_fmax = (frange) ? (*frange)[1] : f_P2_.max( ); + const double tmp_fmin = (frange) ? (*frange)[0] : f_P2_.min( ); + const double tmp_df = (logscale) ? pow(tmp_fmax / tmp_fmin, static_cast< double >(1) / nbfill) : (tmp_fmax - tmp_fmin) / nbfill; - std::vector border_val; - if( logscale && (tmp_fmin > 0) ){ + std::vector< double > border_val; + if (logscale && (tmp_fmin > 0)) { - border_val.push_back( tmp_fmin ); - for(int m = 1; m <= nbfill; m++) - border_val.push_back( border_val[m-1] * tmp_df ); + border_val.push_back(tmp_fmin); + for (int m = 1; m <= nbfill; m++) border_val.push_back(border_val[m - 1] * tmp_df); - } else { + } else { - if( logscale ) - std::cout << "plotPDF(): logscale for non-positive values.\n"; + if (logscale) std::cout << "plotPDF(): logscale for non-positive values.\n"; - for(int m = 0; m <= nbfill; m++) - border_val.push_back( m*tmp_df + tmp_fmin ); - } + for (int m = 0; m <= nbfill; m++) border_val.push_back(m * tmp_df + tmp_fmin); + } - // considering wider range, since min/max of P2 element are not - // attained at vertices of triangles. - const double fmax = (logscale)? tmp_fmax*tmp_df: tmp_fmax + tmp_df; - const double fmin = (logscale)? tmp_fmin/tmp_df: tmp_fmin - tmp_df; - - std::stringstream &st = Content; - st.str(""); - - //------------------------------ - // element(triangle)-wise process - //------------------------------ - st << "q\n"; - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; - - const int NQ = 6; // number of unknowns in quadratic polynomial - const int &nTriangles = Th.nt; - - for(int k = 0; k < nTriangles; k++){ + // considering wider range, since min/max of P2 element are not + // attained at vertices of triangles. + const double fmax = (logscale) ? tmp_fmax * tmp_df : tmp_fmax + tmp_df; + const double fmin = (logscale) ? tmp_fmin / tmp_df : tmp_fmin - tmp_df; - const int &v0 = Th(k,0); const int &v1 = Th(k,1); const int &v2 = Th(k,2); + std::stringstream &st = Content; + st.str(""); - const double vx[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double vy[] = { Th(v0).y, Th(v1).y, Th(v2).y }; + //------------------------------ + // element(triangle)-wise process + //------------------------------ + st << "q\n"; + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - // f_P2[i] = phi(v[i]), f_P2[i+3] = phi(e[i]), i=0,1,2. - const double *const f_P2 = f_P2_ + k*NQ; + const int NQ = 6; // number of unknowns in quadratic polynomial + const int &nTriangles = Th.nt; - // quadratic polynomials : ax^2 + bxy + cy^2 + dx + ey + f - double phi[ NQ ]; - const double &a = phi[0]; const double &b = phi[1]; const double &c = phi[2]; - const double &d = phi[3]; const double &e = phi[4]; const double &f = phi[5]; + for (int k = 0; k < nTriangles; k++) { - findQuadraticPolynomial(phi, vx, vy, f_P2); - - const bool isLinear = (fabs(a) + fabs(b) + fabs(c) < EPS * (fabs(d)+fabs(e) + fabs(f))); + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - // normalize Quadratic Polynomial - double PHI[9]; - findCanonicalForm( PHI, phi ); + const double vx[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double vy[] = {Th(v0).y, Th(v1).y, Th(v2).y}; - // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f - // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 - // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) - // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F - const double &lambda1 = PHI[0]; const double &lambda2 = PHI[1]; - const double &D = PHI[6]; const double &E = PHI[7]; double &F = PHI[8]; + // f_P2[i] = phi(v[i]), f_P2[i+3] = phi(e[i]), i=0,1,2. + const double *const f_P2 = f_P2_ + k * NQ; - // lambda1*X^2 + lambda2*Y^2 + D*X + E*Y + F = value, - // if lambda2 == E == 0, then lambda1*X^2 + D*X + F = value, i.e. X=const - // if lambda1 == D == 0, then lambda2*Y^2 + E*Y + F = value, i.e. Y=const - const bool isParallelY = (fabs(lambda2) + fabs(E) < EPS * (fabs(lambda1)+fabs(D) + fabs(F))); - const bool isParallelX = (fabs(lambda1) + fabs(D) < EPS * (fabs(lambda2)+fabs(E) + fabs(F))); + // quadratic polynomials : ax^2 + bxy + cy^2 + dx + ey + f + double phi[NQ]; + const double &a = phi[0]; + const double &b = phi[1]; + const double &c = phi[2]; + const double &d = phi[3]; + const double &e = phi[4]; + const double &f = phi[5]; - // Question: If PHI - isovalue = (a1 X + b1 Y + c1)(a2 X + b2 Y + c2) = 0, what happes? - if( isLinear || isParallelX || isParallelY ){ // phi(x,y) is linear + findQuadraticPolynomial(phi, vx, vy, f_P2); - P2_fill_linear( st, Th, k, f_P2, palette, - tmp_fmax, tmp_fmin, tmp_df, nbfill, frange, - scale, ar, x0, y0, monochrome, logscale ); + const bool isLinear = (fabs(a) + fabs(b) + fabs(c) < EPS * (fabs(d) + fabs(e) + fabs(f))); - continue; // goto next Triangle - } + // normalize Quadratic Polynomial + double PHI[9]; + findCanonicalForm(PHI, phi); + + // PHI(X,Y) = lambda1*X*X + lambda2*Y*Y + D*X + E*Y + f + // = lambda1 * (X + D/(2*lambda1))^2 + lambda2 * (Y + E/(2*lambda2))^2 + // + ( -D*D/(4*lambda1) - E*E/(4*lambda2) + f) + // = lambda1*(X + D/(2*lambda1))^2 + lambda2*(Y + E/(2*lambda2))^2 + F + const double &lambda1 = PHI[0]; + const double &lambda2 = PHI[1]; + const double &D = PHI[6]; + const double &E = PHI[7]; + double &F = PHI[8]; + + // lambda1*X^2 + lambda2*Y^2 + D*X + E*Y + F = value, + // if lambda2 == E == 0, then lambda1*X^2 + D*X + F = value, i.e. X=const + // if lambda1 == D == 0, then lambda2*Y^2 + E*Y + F = value, i.e. Y=const + const bool isParallelY = (fabs(lambda2) + fabs(E) < EPS * (fabs(lambda1) + fabs(D) + fabs(F))); + const bool isParallelX = (fabs(lambda1) + fabs(D) < EPS * (fabs(lambda2) + fabs(E) + fabs(F))); + + // Question: If PHI - isovalue = (a1 X + b1 Y + c1)(a2 X + b2 Y + c2) = 0, what happes? + if (isLinear || isParallelX || isParallelY) { // phi(x,y) is linear + + P2_fill_linear(st, Th, k, f_P2, palette, tmp_fmax, tmp_fmin, tmp_df, nbfill, frange, scale, ar, x0, y0, monochrome, logscale); + + continue; // goto next Triangle + } + + double Vx[3], Vy[3]; + transformTriangle(Vx, Vy, vx, vy, PHI); - double Vx[3], Vy[3]; - transformTriangle( Vx, Vy, vx, vy, PHI ); + const bool isParabolic = (fabs(lambda1) < EPS) || (fabs(lambda2) < EPS); + const bool isElliptic = (!isParabolic) && (lambda1 * lambda2 > 0); + const bool isHyperbolic = (!isParabolic) && (lambda1 * lambda2 < 0); - const bool isParabolic = (fabs(lambda1) < EPS) || (fabs(lambda2) < EPS); - const bool isElliptic = (!isParabolic) && (lambda1*lambda2 > 0); - const bool isHyperbolic = (!isParabolic) && (lambda1*lambda2 < 0); + const double &ev1x = PHI[2]; + const double &ev1y = PHI[3]; + const double &ev2x = PHI[4]; + const double &ev2y = PHI[5]; + const double p[2][2] = {{ev1x, ev2x}, {ev1y, ev2y}}; - const double &ev1x = PHI[2]; const double &ev1y = PHI[3]; - const double &ev2x = PHI[4]; const double &ev2y = PHI[5]; - const double p[2][2] = { { ev1x, ev2x }, { ev1y, ev2y } }; + const std::vector< double > Tx{Vx[0], Vx[0], Vx[1], Vx[1], Vx[1], Vx[2], Vx[2], Vx[2], Vx[0], Vx[0]}; + const std::vector< double > Ty{Vy[0], Vy[0], Vy[1], Vy[1], Vy[1], Vy[2], Vy[2], Vy[2], Vy[0], Vy[0]}; - const std::vector Tx { Vx[0], Vx[0], Vx[1], Vx[1], - Vx[1], Vx[2], Vx[2], - Vx[2], Vx[0], Vx[0] }; - const std::vector Ty { Vy[0], Vy[0], Vy[1], Vy[1], - Vy[1], Vy[2], Vy[2], - Vy[2], Vy[0], Vy[0] }; + std::vector< std::vector< double > > partition_x{Tx}; + std::vector< std::vector< double > > partition_y{Ty}; - std::vector< std::vector > partition_x { Tx }; - std::vector< std::vector > partition_y { Ty }; + // divide T by isolines + for (size_t m = 0; m < border_val.size( ); m++) { - // divide T by isolines - for(size_t m = 0; m < border_val.size(); m++){ - - const double &value = border_val[m]; - - // examine values of phi at all vertices - double phi_vertices[3]; - for(int i = 0; i < 3; i++) - phi_vertices[i] = a*vx[i]*vx[i] + b*vx[i]*vy[i] + c*vy[i]*vy[i] + d*vx[i] + e*vy[i] + f - value; + const double &value = border_val[m]; - // If phi == value at all three vertices, then skip - // the curve phi==value is ellipse outside the triangle, - // or two lines (factrization of hyperbola), which coinside with segments. - // BUG: there is exception: two lines case - if( fabs(phi_vertices[0]) + fabs(phi_vertices[1]) + fabs(phi_vertices[2]) < EPS ) - continue; + // examine values of phi at all vertices + double phi_vertices[3]; + for (int i = 0; i < 3; i++) phi_vertices[i] = a * vx[i] * vx[i] + b * vx[i] * vy[i] + c * vy[i] * vy[i] + d * vx[i] + e * vy[i] + f - value; - std::vector zx, zy; - findZeros( zx, zy, vx[0], vy[0], vx[1], vy[1], phi, value ); - findZeros( zx, zy, vx[1], vy[1], vx[2], vy[2], phi, value ); - findZeros( zx, zy, vx[2], vy[2], vx[0], vy[0], phi, value ); + // If phi == value at all three vertices, then skip + // the curve phi==value is ellipse outside the triangle, + // or two lines (factrization of hyperbola), which coinside with segments. + // BUG: there is exception: two lines case + if (fabs(phi_vertices[0]) + fabs(phi_vertices[1]) + fabs(phi_vertices[2]) < EPS) continue; - assert( zx.size() == zy.size() ); + std::vector< double > zx, zy; + findZeros(zx, zy, vx[0], vy[0], vx[1], vy[1], phi, value); + findZeros(zx, zy, vx[1], vy[1], vx[2], vy[2], phi, value); + findZeros(zx, zy, vx[2], vy[2], vx[0], vy[0], phi, value); - F -= value; // modify constant term + assert(zx.size( ) == zy.size( )); - std::vector< std::vector > Cx, Cy; // control points of Bezier curves PHI=0 + F -= value; // modify constant term - if( isParabolic && (zx.size() >= 2) ){ + std::vector< std::vector< double > > Cx, Cy; // control points of Bezier curves PHI=0 - trackParabola(Cx, Cy, PHI, zx, zy, Vx, Vy); + if (isParabolic && (zx.size( ) >= 2)) { - } else if( isElliptic ){ + trackParabola(Cx, Cy, PHI, zx, zy, Vx, Vy); - if( zx.size() >= 2 ){ - trackEllipse(Cx, Cy, PHI, zx, zy, Vx, Vy); - } else { - // Ellipse is included inside triangle (might tangent to an edge) - // draw whole ellipse - trackEllipse(Cx, Cy, PHI, Vx, Vy); - } - - } else if( isHyperbolic && (zx.size() >= 2) ){ + } else if (isElliptic) { - trackHyperbola(Cx, Cy, PHI, zx, zy, Vx, Vy); - } + if (zx.size( ) >= 2) { + trackEllipse(Cx, Cy, PHI, zx, zy, Vx, Vy); + } else { + // Ellipse is included inside triangle (might tangent to an edge) + // draw whole ellipse + trackEllipse(Cx, Cy, PHI, Vx, Vy); + } + + } else if (isHyperbolic && (zx.size( ) >= 2)) { + + trackHyperbola(Cx, Cy, PHI, zx, zy, Vx, Vy); + } + + if (Cx.size( ) > 0) splitByBorder(partition_x, partition_y, Cx, Cy); + + F += value; // correct constant term - if( Cx.size() > 0 ) - splitByBorder( partition_x, partition_y, Cx, Cy ); + } // for each border value - F += value; // correct constant term + assert(partition_x.size( ) == partition_y.size( )); - } // for each border value + invTransformCubicBzeirs(partition_x, partition_y, PHI); - assert( partition_x.size() == partition_y.size() ); + // draw divided partitions + for (size_t i = 0; i < partition_x.size( ); i++) { + + const std::vector< double > &cx = partition_x[i]; + const std::vector< double > &cy = partition_y[i]; + + const double fillvalue = findFillValue(cx, cy, phi); + double fm = (logscale) ? tmp_fmin * pow(tmp_df, static_cast< int >(log(fillvalue / tmp_fmin) / log(tmp_df)) + 0.5) : floor((fillvalue - fmin) / tmp_df) * tmp_df + fmin + tmp_df / 2; + + // Since max/min of P2 approx cannot be obtained from only vertex values, + // the next is not enough for P2 element. + // if( (value < fmin) || (fmax < value) ) + // continue; // goto next sub-triangle + // Following solves the issue. + if (logscale) { + + if (fillvalue < tmp_fmin) { + if (frange) continue; // No color, goto next partition + fm = tmp_fmin; // if range is not specified, truncate fill color + } else if (fillvalue < tmp_fmin * tmp_df) { + fm = tmp_fmin; + } - invTransformCubicBzeirs( partition_x, partition_y, PHI ); + if (fillvalue > tmp_fmax) { + if (frange) continue; // No color, goto next partition + fm = tmp_fmax; // if range is not specified, truncate fill color + } else if (fillvalue > tmp_fmax / tmp_df) { + fm = tmp_fmax; + } - // draw divided partitions - for(size_t i = 0; i < partition_x.size(); i++){ + } else { // if( logscale ) - const std::vector &cx = partition_x[i]; - const std::vector &cy = partition_y[i]; + if (fillvalue < tmp_fmin) { + if (frange) continue; // No color, goto next partition + fm = tmp_fmin; // if range is not specified, truncate fill color + } else if (fillvalue < tmp_fmin + tmp_df) { + fm = tmp_fmin; + } - const double fillvalue = findFillValue( cx, cy, phi ); - double fm = (logscale)? - tmp_fmin*pow(tmp_df, static_cast( log(fillvalue/tmp_fmin) / log(tmp_df) ) + 0.5): - floor((fillvalue - fmin)/tmp_df) * tmp_df + fmin + tmp_df/2; + if (fillvalue > tmp_fmax) { + if (frange) continue; // No color, goto next partition + fm = tmp_fmax; // if range is not specified, truncate fill color + } else if (fillvalue > tmp_fmax - tmp_df) { + fm = tmp_fmax; + } - // Since max/min of P2 approx cannot be obtained from only vertex values, - // the next is not enough for P2 element. - //if( (value < fmin) || (fmax < value) ) - // continue; // goto next sub-triangle - // Following solves the issue. - if( logscale ) { + } // if(logscale) - if( fillvalue < tmp_fmin ){ - if(frange) continue; // No color, goto next partition - fm = tmp_fmin; // if range is not specified, truncate fill color - } else if( fillvalue < tmp_fmin*tmp_df ){ - fm = tmp_fmin; - } - - if( fillvalue > tmp_fmax ){ - if(frange) continue; // No color, goto next partition - fm = tmp_fmax; // if range is not specified, truncate fill color - } else if( fillvalue > tmp_fmax/tmp_df ){ - fm = tmp_fmax; - } - - } else { // if( logscale ) - - if( fillvalue < tmp_fmin ) { - if(frange) continue; // No color, goto next partition - fm = tmp_fmin; // if range is not specified, truncate fill color - } else if( fillvalue < tmp_fmin+tmp_df ){ - fm = tmp_fmin; - } - - if( fillvalue > tmp_fmax ){ - if(frange) continue; // No color, goto next partition - fm = tmp_fmax; // if range is not specified, truncate fill color - } else if( fillvalue > tmp_fmax-tmp_df ){ - fm = tmp_fmax; - } - - } // if(logscale) - - setrgbcolor(st, fm, palette, tmp_fmin, tmp_fmax, monochrome, logscale); + setrgbcolor(st, fm, palette, tmp_fmin, tmp_fmax, monochrome, logscale); #if 1 - st << "rg\n"; - - // assume : curve begin point and end point are conisnde. - st << scale*ar*(cx[0]-x0) << ' ' << scale*(cy[0]-y0) << " m "; - for(size_t i = 1; i < cx.size(); i += 3){ - st << scale*ar*(cx[i+0]-x0) << ' ' << scale*(cy[i+0]-y0) << ' ' - << scale*ar*(cx[i+1]-x0) << ' ' << scale*(cy[i+1]-y0) << ' ' - << scale*ar*(cx[i+2]-x0) << ' ' << scale*(cy[i+2]-y0) << " c "; - } - // f: closing path and fill (without boundary), b: unclosing path and fill (with boundary) - st << "f\n"; + st << "rg\n"; + + // assume : curve begin point and end point are conisnde. + st << scale * ar * (cx[0] - x0) << ' ' << scale * (cy[0] - y0) << " m "; + for (size_t i = 1; i < cx.size( ); i += 3) { + st << scale * ar * (cx[i + 0] - x0) << ' ' << scale * (cy[i + 0] - y0) << ' ' << scale * ar * (cx[i + 1] - x0) << ' ' << scale * (cy[i + 1] - y0) << ' ' << scale * ar * (cx[i + 2] - x0) << ' ' + << scale * (cy[i + 2] - y0) << " c "; + } + // f: closing path and fill (without boundary), b: unclosing path and fill (with boundary) + st << "f\n"; #else - // debug : drawing the borders - st << "RG\n"; - - st << scale*ar*(cx[0]-x0) << ' ' << scale*(cy[0]-y0) << " m "; - for(size_t i = 1; i < cx.size(); i += 3){ - st << scale*ar*(cx[i+0]-x0) << ' ' << scale*(cy[i+0]-y0) << ' ' - << scale*ar*(cx[i+1]-x0) << ' ' << scale*(cy[i+1]-y0) << ' ' - << scale*ar*(cx[i+2]-x0) << ' ' << scale*(cy[i+2]-y0) << " c "; - } - // s: closing path and stroke, S: unclosing path and stroke - st << "S\n"; + // debug : drawing the borders + st << "RG\n"; + + st << scale * ar * (cx[0] - x0) << ' ' << scale * (cy[0] - y0) << " m "; + for (size_t i = 1; i < cx.size( ); i += 3) { + st << scale * ar * (cx[i + 0] - x0) << ' ' << scale * (cy[i + 0] - y0) << ' ' << scale * ar * (cx[i + 1] - x0) << ' ' << scale * (cy[i + 1] - y0) << ' ' << scale * ar * (cx[i + 2] - x0) << ' ' + << scale * (cy[i + 2] - y0) << " c "; + } + // s: closing path and stroke, S: unclosing path and stroke + st << "S\n"; #endif - } + } - } // element(triangle)-wise process + } // element(triangle)-wise process - st << "Q\n"; + st << "Q\n"; - if( legend ) - drawLegend_fill( st, nbfill, tmp_df, prec, palette, tmp_fmin, tmp_fmax, monochrome, logscale, - sizex, textfontsize, scale, y1, y0, marginl, marginb ); + if (legend) drawLegend_fill(st, nbfill, tmp_df, prec, palette, tmp_fmin, tmp_fmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); - return; -} // + return; +} // //---------------------------------------------------------------------- // vector field //---------------------------------------------------------------------- -void plot_vector( std::stringstream &Content, - const double arrow_origin_x, const double arrow_origin_y, - const double vector_x, const double vector_y, const double vector_norm2, - const double alength_scale, const double ahead_scale, - const double x0, const double y0, const double scale, const double ar, - const double fmin, const double fmax, - const bool unit_arrow, const bool logscale, - const KNM &palette, const bool monochrome ) -{ - std::stringstream &st = Content; - const double &r = scale; - - const double &ox = arrow_origin_x; - const double &oy = arrow_origin_y; - - const double AH_SIZE = (alength_scale > 0)? (PLOTPDFVAR::DEFAULT_ARROW_HEAD_SIZE * ahead_scale): (PLOTPDFVAR::DEFAULT_ARROW_HEAD_SIZE * (-ahead_scale)); - const double &AH_ANGLE = PLOTPDFVAR::ARROW_HEAD_ANGLE; - - // what happen if (fmin == 0) && logscale ? - const double favg = logscale? (sqrt(fmax*fmin)): (fmax+fmin)/2; - - // scaled arrow length is arrow_scale * cf2, which is truncated if greater than fmax - const double &as = alength_scale; - const double alength = (unit_arrow)? (as*favg)/fmax*PLOTPDFVAR::MAX_ARROW_LENGTH: - ( (logscale)? as*(log(vector_norm2/fmin))/(log(fmax/fmin))*PLOTPDFVAR::MAX_ARROW_LENGTH: as*vector_norm2/fmax*PLOTPDFVAR::MAX_ARROW_LENGTH); - - // In logscale, vector_norm2 = fmin*(fmax/fmin)^r <=> r = (log(vector_norm2)-log(fmin))/(log(fmax)-log(fmin)) - // Then, alength = alength_scale * r * PLOTPDFVAR::MAX_ARROW_LENGTH. - - const double arrow_head_x = r*ar*(ox-x0) + alength * ar*vector_x/vector_norm2; - const double arrow_head_y = r*(oy-y0) + alength * vector_y/vector_norm2; - - setrgbcolor(st, vector_norm2, palette, fmin, fmax, monochrome, logscale); - st << "RG\n"; - st << r*ar*(ox-x0) << ' ' << r*(oy-y0) << " m "; // arrow origin - st << arrow_head_x << ' ' << arrow_head_y << " l S" << std::endl; // arrow head - - // Need fabs? Yes, if coef = alength < 0, arrows go reverse direction. - if( fabs(alength) > AH_SIZE/2 ){ - - const double theta = atan2( -vector_y, -vector_x ); // reverse of arrow direction - - st << arrow_head_x + AH_SIZE*cos(theta-AH_ANGLE) << ' ' << arrow_head_y + AH_SIZE*sin(theta-AH_ANGLE) << " m " - << arrow_head_x << ' ' << arrow_head_y << " l " - << arrow_head_x + AH_SIZE*cos(theta+AH_ANGLE) << ' ' << arrow_head_y + AH_SIZE*sin(theta+AH_ANGLE) << " l S" << std::endl; - } +void plot_vector(std::stringstream &Content, const double arrow_origin_x, const double arrow_origin_y, const double vector_x, const double vector_y, const double vector_norm2, + const double alength_scale, const double ahead_scale, const double x0, const double y0, const double scale, const double ar, const double fmin, const double fmax, + const bool unit_arrow, const bool logscale, const KNM< double > &palette, const bool monochrome) { + std::stringstream &st = Content; + const double &r = scale; - return; -} + const double &ox = arrow_origin_x; + const double &oy = arrow_origin_y; -void plot_vector2flow( std::stringstream &Content, const Fem2D::Mesh &Th, - const KN &fx, const KN &fy, - const KN &f2, const KN &f2m, const bool isolineP2, - const bool fromVertex, const KNM &palette, - const double alength_scale, const bool unit_arrow, - const double linewidth, const double ahead_scale, - const int nbarrow, const KN *const varrow, - const int sizex, const int sizey, const double scale, const double ar, - const double x0, const double y0, const double y1, - const int marginl, const int marginb, - const double textfontsize, const bool monochrome, - const bool legend, const int prec, const bool logscale, - const double withmesh, - const long nbfill, const KN *const frange, const string &fetype, - const bool isoline, const int NISOLINES, const KN*const viso ) -{ - const double EPS = 1e-10; + const double AH_SIZE = (alength_scale > 0) ? (PLOTPDFVAR::DEFAULT_ARROW_HEAD_SIZE * ahead_scale) : (PLOTPDFVAR::DEFAULT_ARROW_HEAD_SIZE * (-ahead_scale)); + const double &AH_ANGLE = PLOTPDFVAR::ARROW_HEAD_ANGLE; - const int &nVertices = Th.nv; - const int &nTriangles = Th.nt; - const int &nEdges = Th.neb; - const double &r = scale; + // what happen if (fmin == 0) && logscale ? + const double favg = logscale ? (sqrt(fmax * fmin)) : (fmax + fmin) / 2; - const double fmax = (frange)? (*frange)[1]: f2.max(); - const double fmin = (frange)? (*frange)[0]: f2.min(); + // scaled arrow length is arrow_scale * cf2, which is truncated if greater than fmax + const double &as = alength_scale; + const double alength = (unit_arrow) ? (as * favg) / fmax * PLOTPDFVAR::MAX_ARROW_LENGTH + : ((logscale) ? as * (log(vector_norm2 / fmin)) / (log(fmax / fmin)) * PLOTPDFVAR::MAX_ARROW_LENGTH : as * vector_norm2 / fmax * PLOTPDFVAR::MAX_ARROW_LENGTH); - const double df = (logscale)? - exp( (static_cast(1)/nbfill)*(log(fmax/fmin)) ): - (fmax - fmin)/nbfill; + // In logscale, vector_norm2 = fmin*(fmax/fmin)^r <=> r = (log(vector_norm2)-log(fmin))/(log(fmax)-log(fmin)) + // Then, alength = alength_scale * r * PLOTPDFVAR::MAX_ARROW_LENGTH. - if( varrow ) - std::cout << "plotPDF(): Option 'varrow' is not implemented yet." << endl; - if( nbarrow != 0 ) - std::cout << "plotPDF(): Option 'nbarrow' is not implemented yet." << endl; + const double arrow_head_x = r * ar * (ox - x0) + alength * ar * vector_x / vector_norm2; + const double arrow_head_y = r * (oy - y0) + alength * vector_y / vector_norm2; - std::stringstream &st = Content; - st.str(""); + setrgbcolor(st, vector_norm2, palette, fmin, fmax, monochrome, logscale); + st << "RG\n"; + st << r * ar * (ox - x0) << ' ' << r * (oy - y0) << " m "; // arrow origin + st << arrow_head_x << ' ' << arrow_head_y << " l S" << std::endl; // arrow head - if( 0 < withmesh ) - overlayMesh( st, Th, withmesh, scale, ar, x0, y0, marginl, marginb ); + // Need fabs? Yes, if coef = alength < 0, arrows go reverse direction. + if (fabs(alength) > AH_SIZE / 2) { - drawBoundary( st, Th, scale, ar, x0, y0, marginl, marginb ); + const double theta = atan2(-vector_y, -vector_x); // reverse of arrow direction - if( legend ) - drawLegend_fill( st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, - sizex, textfontsize, scale, y1, y0, marginl, marginb ); + st << arrow_head_x + AH_SIZE * cos(theta - AH_ANGLE) << ' ' << arrow_head_y + AH_SIZE * sin(theta - AH_ANGLE) << " m " << arrow_head_x << ' ' << arrow_head_y << " l " + << arrow_head_x + AH_SIZE * cos(theta + AH_ANGLE) << ' ' << arrow_head_y + AH_SIZE * sin(theta + AH_ANGLE) << " l S" << std::endl; + } - //------------------------------ - // isoline - //------------------------------ + return; +} - if( isoline ){ +void plot_vector2flow(std::stringstream &Content, const Fem2D::Mesh &Th, const KN< double > &fx, const KN< double > &fy, const KN< double > &f2, const KN< double > &f2m, const bool isolineP2, + const bool fromVertex, const KNM< double > &palette, const double alength_scale, const bool unit_arrow, const double linewidth, const double ahead_scale, const int nbarrow, + const KN< double > *const varrow, const int sizex, const int sizey, const double scale, const double ar, const double x0, const double y0, const double y1, const int marginl, + const int marginb, const double textfontsize, const bool monochrome, const bool legend, const int prec, const bool logscale, const double withmesh, const long nbfill, + const KN< double > *const frange, const string &fetype, const bool isoline, const int NISOLINES, const KN< double > *const viso) { + const double EPS = 1e-10; - std::vector isoline_val; + const int &nVertices = Th.nv; + const int &nTriangles = Th.nt; + const int &nEdges = Th.neb; + const double &r = scale; - if( viso ){ + const double fmax = (frange) ? (*frange)[1] : f2.max( ); + const double fmin = (frange) ? (*frange)[0] : f2.min( ); - for(int m = 0; m < viso->size(); m++) - isoline_val.push_back( (*viso)[m] ); + const double df = (logscale) ? exp((static_cast< double >(1) / nbfill) * (log(fmax / fmin))) : (fmax - fmin) / nbfill; - } else if( logscale && (fmin > 0) ) { + if (varrow) std::cout << "plotPDF(): Option 'varrow' is not implemented yet." << endl; + if (nbarrow != 0) std::cout << "plotPDF(): Option 'nbarrow' is not implemented yet." << endl; - // fmin * step^N = fmax <=> step^N = fmax/fmin - // <=> N = log_{step}(fmax/fmin) = (log(fmax/fmin))/log(step) - // <=> log(step) = (1/N)(log(fmax/fmin)) - // <=> step = exp( (1/N)(log(fmax/fmin)) ) - const double df = exp( (static_cast(1)/NISOLINES)*(log(fmax/fmin)) ); + std::stringstream &st = Content; + st.str(""); - isoline_val.push_back( fmin*sqrt(df) ); - for(int m = 1; m < NISOLINES; m++) - isoline_val.push_back( isoline_val[m-1] * df ); + if (0 < withmesh) overlayMesh(st, Th, withmesh, scale, ar, x0, y0, marginl, marginb); - } else { - - if( logscale ) - std::cout << "plotPDF(): logscale for non-positive values.\n"; + drawBoundary(st, Th, scale, ar, x0, y0, marginl, marginb); - const double df = (fmax - fmin) / NISOLINES; - for(int m = 0; m < NISOLINES; m++) - isoline_val.push_back( fmin + df/2 + m*df ); - } - // end : making plot values + if (legend) drawLegend_fill(st, nbfill, df, prec, palette, fmin, fmax, monochrome, logscale, sizex, textfontsize, scale, y1, y0, marginl, marginb); - if( isolineP2 ){ + //------------------------------ + // isoline + //------------------------------ - // If user specifies an irrelevant color range (in viso array), - // we do not take care of it. - const double cmax = *max_element( isoline_val.begin(), isoline_val.end() ); - const double cmin = *min_element( isoline_val.begin(), isoline_val.end() ); + if (isoline) { - KN f_P2( 6*nTriangles ); - for(int it = 0; it < nTriangles; it++){ - f_P2[6*it+0] = f2[3*it+0]; - f_P2[6*it+1] = f2[3*it+1]; - f_P2[6*it+2] = f2[3*it+2]; + std::vector< double > isoline_val; - f_P2[6*it+3] = f2m[3*it+0]; - f_P2[6*it+4] = f2m[3*it+1]; - f_P2[6*it+5] = f2m[3*it+2]; - } + if (viso) { - plot_P2_isoline_body( st, Th, f_P2, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, - marginl, marginb, monochrome, logscale, NISOLINES, linewidth ); - - } else { + for (int m = 0; m < viso->size( ); m++) isoline_val.push_back((*viso)[m]); - // copy from main routine in plot_P1_isoline + } else if (logscale && (fmin > 0)) { - if( (fetype != "P1") && (fetype != "P1nc") && (fetype != "P0") ){ - std::cout << "plotPDF() : isoline for vector filed is interpolated as P1 type" << std::endl; - } + // fmin * step^N = fmax <=> step^N = fmax/fmin + // <=> N = log_{step}(fmax/fmin) = (log(fmax/fmin))/log(step) + // <=> log(step) = (1/N)(log(fmax/fmin)) + // <=> step = exp( (1/N)(log(fmax/fmin)) ) + const double df = exp((static_cast< double >(1) / NISOLINES) * (log(fmax / fmin))); - plot_P1_isoline_body( st, Th, f2, isoline_val, fmin, fmax, palette, scale, ar, x0, y0, - marginl, marginb, monochrome, logscale, NISOLINES, linewidth ); + isoline_val.push_back(fmin * sqrt(df)); + for (int m = 1; m < NISOLINES; m++) isoline_val.push_back(isoline_val[m - 1] * df); - } + } else { - } // isoline + if (logscale) std::cout << "plotPDF(): logscale for non-positive values.\n"; - //------------------------------ - // element(triangle)-wise process - // This is final so that the legend does not hide arrows. - //------------------------------ - st << "q\n"; - st << linewidth << " w\n"; // setlinewidth - st << "1 0 0 1 " << PLOTPDFVAR::PADDING+marginl << " " << PLOTPDFVAR::PADDING+marginb << " cm\n"; + const double df = (fmax - fmin) / NISOLINES; + for (int m = 0; m < NISOLINES; m++) isoline_val.push_back(fmin + df / 2 + m * df); + } + // end : making plot values - for(int k = 0; k < nTriangles; k++){ + if (isolineP2) { - const int &v0 = Th(k,0); - const int &v1 = Th(k,1); - const int &v2 = Th(k,2); + // If user specifies an irrelevant color range (in viso array), + // we do not take care of it. + const double cmax = *max_element(isoline_val.begin( ), isoline_val.end( )); + const double cmin = *min_element(isoline_val.begin( ), isoline_val.end( )); - const double vx[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double vy[] = { Th(v0).y, Th(v1).y, Th(v2).y }; - const double vfx[] = { fx[3*k+0], fx[3*k+1], fx[3*k+2] }; - const double vfy[] = { fy[3*k+0], fy[3*k+1], fy[3*k+2] }; + KN< double > f_P2(6 * nTriangles); + for (int it = 0; it < nTriangles; it++) { + f_P2[6 * it + 0] = f2[3 * it + 0]; + f_P2[6 * it + 1] = f2[3 * it + 1]; + f_P2[6 * it + 2] = f2[3 * it + 2]; - if( fromVertex ) { + f_P2[6 * it + 3] = f2m[3 * it + 0]; + f_P2[6 * it + 4] = f2m[3 * it + 1]; + f_P2[6 * it + 5] = f2m[3 * it + 2]; + } - // arrow from triangle vertices - const double vf2[] = { f2[3*k+0], f2[3*k+1], f2[3*k+2] }; + plot_P2_isoline_body(st, Th, f_P2, isoline_val, cmin, cmax, palette, scale, ar, x0, y0, marginl, marginb, monochrome, logscale, NISOLINES, linewidth); - for(int i = 0; i < 3; i++){ + } else { - if( (vf2[i] < fmin) || (fmax < vf2[i]) ) - continue; + // copy from main routine in plot_P1_isoline - plot_vector( st, vx[i],vy[i], vfx[i],vfy[i],vf2[i], alength_scale, ahead_scale, - x0,y0,scale,ar, fmin,fmax, unit_arrow,logscale, palette,monochrome ); - } + if ((fetype != "P1") && (fetype != "P1nc") && (fetype != "P0")) { + std::cout << "plotPDF() : isoline for vector filed is interpolated as P1 type" << std::endl; + } - } else { + plot_P1_isoline_body(st, Th, f2, isoline_val, fmin, fmax, palette, scale, ar, x0, y0, marginl, marginb, monochrome, logscale, NISOLINES, linewidth); + } - // arrow from center of triangles - const double cx = (vx[0] + vx[1] + vx[2])/3; - const double cy = (vy[0] + vy[1] + vy[2])/3; + } // isoline - const double cfx = (vfx[0]+vfx[1]+vfx[2])/3; - const double cfy = (vfy[0]+vfy[1]+vfy[2])/3; - const double cf2 = sqrt( cfx*cfx + cfy*cfy ); + //------------------------------ + // element(triangle)-wise process + // This is final so that the legend does not hide arrows. + //------------------------------ + st << "q\n"; + st << linewidth << " w\n"; // setlinewidth + st << "1 0 0 1 " << PLOTPDFVAR::PADDING + marginl << " " << PLOTPDFVAR::PADDING + marginb << " cm\n"; - if( (cf2 < fmin) || (fmax < cf2) ) - continue; + for (int k = 0; k < nTriangles; k++) { - plot_vector( st, cx,cy, cfx,cfy,cf2, alength_scale, ahead_scale, - x0,y0,scale,ar, fmin,fmax, unit_arrow,logscale, palette,monochrome ); + const int &v0 = Th(k, 0); + const int &v1 = Th(k, 1); + const int &v2 = Th(k, 2); - } + const double vx[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double vy[] = {Th(v0).y, Th(v1).y, Th(v2).y}; + const double vfx[] = {fx[3 * k + 0], fx[3 * k + 1], fx[3 * k + 2]}; + const double vfy[] = {fy[3 * k + 0], fy[3 * k + 1], fy[3 * k + 2]}; - } // element(triangle)-wise process + if (fromVertex) { - st << "Q\n"; + // arrow from triangle vertices + const double vf2[] = {f2[3 * k + 0], f2[3 * k + 1], f2[3 * k + 2]}; - return; -} // + for (int i = 0; i < 3; i++) { -//---------------------------------------------------------------------- -// Interface -//---------------------------------------------------------------------- + if ((vf2[i] < fmin) || (fmax < vf2[i])) continue; -class PLOTPDF_Op : public E_F0mps -{ -public: - Expression eTh, ef, efilename, efx, efy, ez; - static const int n_name_param = PLOTPDFVAR::NOPTIONS; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - - double arg(int i, Stack stack, double defvalue) const { return nargs[i] ? GetAny( (*nargs[i])(stack) ): defvalue; } - long arg(int i, Stack stack, long defvalue) const { return nargs[i] ? GetAny( (*nargs[i])(stack) ): defvalue; } - KN* arg(int i, Stack stack, KN* defvalue) const { return nargs[i] ? GetAny*>( (*nargs[i])(stack) ): defvalue; } - bool arg(int i, Stack stack, bool defvalue) const { return nargs[i] ? GetAny( (*nargs[i])(stack) ): defvalue; } - -public: - // mesh only - PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th ) - : eTh(th), ef(0), efilename(filename), efx(0), efy(0), ez(0) - { - args.SetNameParam( n_name_param, name_param, nargs ); - } + plot_vector(st, vx[i], vy[i], vfx[i], vfy[i], vf2[i], alength_scale, ahead_scale, x0, y0, scale, ar, fmin, fmax, unit_arrow, logscale, palette, monochrome); + } - // real valued function - PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f ) - : eTh(th), ef(f), efilename(filename), efx(0), efy(0), ez(0) - { - args.SetNameParam( n_name_param, name_param, nargs ); - } + } else { - // vector field - PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f, Expression fx, Expression fy) - : eTh(th), ef(0), efilename(filename), efx(fx), efy(fy), ez(0) - { - args.SetNameParam( n_name_param, name_param, nargs ); - } + // arrow from center of triangles + const double cx = (vx[0] + vx[1] + vx[2]) / 3; + const double cy = (vy[0] + vy[1] + vy[2]) / 3; + + const double cfx = (vfx[0] + vfx[1] + vfx[2]) / 3; + const double cfy = (vfy[0] + vfy[1] + vfy[2]) / 3; + const double cf2 = sqrt(cfx * cfx + cfy * cfy); - // complex-valued function - PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f, const Complex z) - : eTh(th), ef(0), efilename(filename), efx(0), efy(0), ez(f) - { - args.SetNameParam( n_name_param, name_param, nargs ); + if ((cf2 < fmin) || (fmax < cf2)) continue; + + plot_vector(st, cx, cy, cfx, cfy, cf2, alength_scale, ahead_scale, x0, y0, scale, ar, fmin, fmax, unit_arrow, logscale, palette, monochrome); } - AnyType operator()(Stack stack) const; + } // element(triangle)-wise process + + st << "Q\n"; + + return; +} // + +//---------------------------------------------------------------------- +// Interface +//---------------------------------------------------------------------- + +class PLOTPDF_Op : public E_F0mps { + public: + Expression eTh, ef, efilename, efx, efy, ez; + static const int n_name_param = PLOTPDFVAR::NOPTIONS; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + + double arg(int i, Stack stack, double defvalue) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : defvalue; } + long arg(int i, Stack stack, long defvalue) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : defvalue; } + KN< double > *arg(int i, Stack stack, KN< double > *defvalue) const { return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : defvalue; } + bool arg(int i, Stack stack, bool defvalue) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : defvalue; } + + public: + // mesh only + PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th) : eTh(th), ef(0), efilename(filename), efx(0), efy(0), ez(0) { args.SetNameParam(n_name_param, name_param, nargs); } + + // real valued function + PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f) : eTh(th), ef(f), efilename(filename), efx(0), efy(0), ez(0) { + args.SetNameParam(n_name_param, name_param, nargs); + } + + // vector field + PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f, Expression fx, Expression fy) : eTh(th), ef(0), efilename(filename), efx(fx), efy(fy), ez(0) { + args.SetNameParam(n_name_param, name_param, nargs); + } + + // complex-valued function + PLOTPDF_Op(const basicAC_F0 &args, Expression filename, Expression th, Expression f, const Complex z) : eTh(th), ef(0), efilename(filename), efx(0), efy(0), ez(f) { + args.SetNameParam(n_name_param, name_param, nargs); + } + + AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type PLOTPDF_Op::name_param[] = -{ - { "size", &typeid(long)}, - { "ar", &typeid(double)}, - { "fontscale", &typeid(double)}, - { "viso", &typeid(KN*)}, - { "nbiso", &typeid(long)}, - { "nbfill", &typeid(long)}, - { "frange", &typeid(KN*)}, - { "gray", &typeid(bool)}, - { "bw", &typeid(bool)}, - { "value", &typeid(bool)}, - { "withmesh", &typeid(double)}, - { "meshpage", &typeid(bool)}, - { "index", &typeid(bool)}, - { "belabel", &typeid(bool)}, - { "isoline", &typeid(bool)}, - { "fill", &typeid(bool)}, - { "fetype", &typeid(string*)}, - { "title", &typeid(string*)}, - { "cmm", &typeid(string*)}, - { "fmargin", &typeid(KN*)}, - { "prec", &typeid(long)}, - { "logscale", &typeid(bool)}, - { "zabs", &typeid(bool)}, - { "zreal", &typeid(bool)}, - { "zimag", &typeid(bool)}, - { "zarg", &typeid(bool)}, - { "coef", &typeid(double)}, // arrow length scale - { "arrowsize", &typeid(double)}, - { "unitarrow", &typeid(bool)}, - { "idcell", &typeid(bool)}, - { "idvert", &typeid(bool)}, - { "idedge", &typeid(bool)}, - { "lw", &typeid(double)}, - { "palette", &typeid(KNM*)} - //---------------------------------------------------------------------- - // If you add new options, modify PLOTPDF_NOPTIONS in global namspace - //---------------------------------------------------------------------- - //{ "nbarrow", &typeid(long)}, // not implemented - //{ "varrow", &typeid(KN*)}, // not implemented +basicAC_F0::name_and_type PLOTPDF_Op::name_param[] = { + {"size", &typeid(long)}, + {"ar", &typeid(double)}, + {"fontscale", &typeid(double)}, + {"viso", &typeid(KN< double > *)}, + {"nbiso", &typeid(long)}, + {"nbfill", &typeid(long)}, + {"frange", &typeid(KN< double > *)}, + {"gray", &typeid(bool)}, + {"bw", &typeid(bool)}, + {"value", &typeid(bool)}, + {"withmesh", &typeid(double)}, + {"meshpage", &typeid(bool)}, + {"index", &typeid(bool)}, + {"belabel", &typeid(bool)}, + {"isoline", &typeid(bool)}, + {"fill", &typeid(bool)}, + {"fetype", &typeid(string *)}, + {"title", &typeid(string *)}, + {"cmm", &typeid(string *)}, + {"fmargin", &typeid(KN< double > *)}, + {"prec", &typeid(long)}, + {"logscale", &typeid(bool)}, + {"zabs", &typeid(bool)}, + {"zreal", &typeid(bool)}, + {"zimag", &typeid(bool)}, + {"zarg", &typeid(bool)}, + {"coef", &typeid(double)}, // arrow length scale + {"arrowsize", &typeid(double)}, + {"unitarrow", &typeid(bool)}, + {"idcell", &typeid(bool)}, + {"idvert", &typeid(bool)}, + {"idedge", &typeid(bool)}, + {"lw", &typeid(double)}, + {"palette", &typeid(KNM< double > *)} + //---------------------------------------------------------------------- + // If you add new options, modify PLOTPDF_NOPTIONS in global namspace + //---------------------------------------------------------------------- + //{ "nbarrow", &typeid(long)}, // not implemented + //{ "varrow", &typeid(KN*)}, // not implemented }; -AnyType PLOTPDF_Op::operator()(Stack stack) const -{ - // options - const long draw_pane_size = arg(0,stack,PLOTPDFVAR::DEFAULT_PAGESIZE); - const double aspectratio = arg(1,stack,PLOTPDFVAR::DEFAULT_ASPECTRATIO); - const double fontscale = arg(2,stack,1.0); - const KN *const viso = arg(3,stack,reinterpret_cast*>(0)); - const long nbiso = arg(4,stack,PLOTPDFVAR::DEFAULT_ISOLINES); - const long nbfill = arg(5,stack,PLOTPDFVAR::DEFAULT_FILL_COLORS); - const KN *const frange = arg(6,stack,reinterpret_cast*>(0)); - const bool gray = arg(7,stack,PLOTPDFVAR::DEFAULT_MONOCHROME); - const bool bw = arg(8,stack,PLOTPDFVAR::DEFAULT_MONOCHROME); - const bool legend = arg(9,stack,PLOTPDFVAR::DEFAULT_SHOW_LEGEND); - const double withmesh = arg(10,stack,PLOTPDFVAR::DEFAULT_WITHMESH); - const bool mesh = arg(11,stack,PLOTPDFVAR::DEFAULT_SHOW_MESH); - const bool index = arg(12,stack,PLOTPDFVAR::DEFAULT_SHOW_INDEX); - const bool belabel = arg(13,stack,PLOTPDFVAR::DEFAULT_SHOW_BELABEL); - const bool isoline = arg(14,stack,PLOTPDFVAR::DEFAULT_SHOW_ISOLINE); - const bool fill = arg(15,stack,PLOTPDFVAR::DEFAULT_SHOW_FILL); - const std::string fetype = get_string(stack,nargs[16],PLOTPDFVAR::DEFAULT_FETYPE); - const std::string title = get_string(stack,nargs[17],PLOTPDFVAR::AppName); - const std::string comment = get_string(stack,nargs[18],""); - const KN *const fmargin = arg(19,stack,reinterpret_cast*>(0)); - const long prec = arg(20,stack,PLOTPDFVAR::DEFAULT_PRECISION_LEGEND); - const bool logscale = arg(21,stack,PLOTPDFVAR::DEFAULT_LOGSCALE); - const bool zabs = arg(22,stack,PLOTPDFVAR::DEFAULT_ZABS); - const bool zreal = arg(23,stack,PLOTPDFVAR::DEFAULT_ZREAL); - const bool zimag = arg(24,stack,PLOTPDFVAR::DEFAULT_ZIMAG); - const bool zarg = arg(25,stack,PLOTPDFVAR::DEFAULT_ZARG); - const double arrow_scale = arg(26,stack,PLOTPDFVAR::DEFAULT_ARROW_SCALE); - const double ahead_scale = arg(27,stack,PLOTPDFVAR::DEFAULT_AHEAD_SCALE); - const bool unit_arrow = arg(28,stack,PLOTPDFVAR::DEFAULT_UNIT_ARROW); - const bool idcell = arg(29,stack,PLOTPDFVAR::DEFAULT_SHOW_IDCELL); - const bool idvert = arg(30,stack,PLOTPDFVAR::DEFAULT_SHOW_IDVERT); - const bool idedge = arg(31,stack,PLOTPDFVAR::DEFAULT_SHOW_IDEDGE); - const double linewidth = arg(32,stack,PLOTPDFVAR::DEFAULT_LINEWIDTH); - //const KNM *const RGBpalette = arg(33,stack,reinterpret_cast*>(nullptr)); - const KNM *const RGBpalette = nargs[33]? - GetAny*>((*nargs[33])(stack)): nullptr; - //const long nbarrow = arg(34,stack,PLOTPDFVAR::DEFAULT_ARROW_COLORS); - //const KN *const varrow = arg(35,stack,reinterpret_cast*>(0)); - const long nbarrow = PLOTPDFVAR::DEFAULT_ARROW_COLORS; - const KN *const varrow = reinterpret_cast*>(0); - - if( verbosity >= 90 ){ - - // invoked by FreeFem++-nw -v 90 users.edp - - std::cout << "plotPDF:options -------------------------" << std::endl; - std::cout << "plotPDF:option: pagesize=" << draw_pane_size << std::endl; - std::cout << "plotPDF:option: aspectratio=" << aspectratio << std::endl; - std::cout << "plotPDF:option: fontscale=" << fontscale << std::endl; - if( viso ) - std::cout << "plotPDF:option: viso->size()=" << viso->size() << std::endl; - else - std::cout << "plotPDF:option: viso[] is empty" << std::endl; - std::cout << "plotPDF:option: nbiso=" << nbiso << std::endl; - std::cout << "plotPDF:option: nbfill=" << nbfill << std::endl; - if( frange ) - std::cout << "plotPDF:option: frange->size()=" << frange->size() << std::endl; - else - std::cout << "plotPDF:option: frange[] is empty" << std::endl; - std::cout << "plotPDF:option: gray=" << gray << std::endl; - std::cout << "plotPDF:option: bw=" << bw << std::endl; - std::cout << "plotPDF:option: value=" << legend << std::endl; - std::cout << "plotPDF:option: withmesh=" << withmesh << std::endl; - std::cout << "plotPDF:option: mesh=" << mesh << std::endl; - std::cout << "plotPDF:option: belabel=" << belabel << std::endl; - std::cout << "plotPDF:option: index=" << index << std::endl; - std::cout << "plotPDF:option: isoline=" << isoline << std::endl; - std::cout << "plotPDF:option: fill=" << fill << std::endl; - std::cout << "plotPDF:option: fetype=" << fetype << std::endl; - std::cout << "plotPDF:option: title=" << title << std::endl; - std::cout << "plotPDF:option: cmm=" << comment << std::endl; - if( fmargin ){ - std::cout << "plotPDF:option: fmargin->size()=" << fmargin->size() << ", ["; - for( int i = 0; i < fmargin->size(); i++) - std::cout << (*fmargin)[i] << ','; - std::cout << "]" << std::endl; - } else { - std::cout << "plotPDF:option: fmargin[] is empty" << std::endl; - } - std::cout << "plotPDF:option: prec=" << prec << std::endl; - std::cout << "plotPDF:option: logscale=" << logscale << std::endl; - std::cout << "plotPDF:option: zabs=" << zabs << std::endl; - std::cout << "plotPDF:option: zreal=" << zreal << std::endl; - std::cout << "plotPDF:option: zimag=" << zimag << std::endl; - std::cout << "plotPDF:option: zarg=" << zarg << std::endl; - std::cout << "plotPDF:option: coef=" << arrow_scale << std::endl; - std::cout << "plotPDF:option: arrowsize=" << ahead_scale << std::endl; - std::cout << "plotPDF:option: unitarrow=" << unit_arrow << std::endl; +AnyType PLOTPDF_Op::operator( )(Stack stack) const { + // options + const long draw_pane_size = arg(0, stack, PLOTPDFVAR::DEFAULT_PAGESIZE); + const double aspectratio = arg(1, stack, PLOTPDFVAR::DEFAULT_ASPECTRATIO); + const double fontscale = arg(2, stack, 1.0); + const KN< double > *const viso = arg(3, stack, reinterpret_cast< KN< double > * >(0)); + const long nbiso = arg(4, stack, PLOTPDFVAR::DEFAULT_ISOLINES); + const long nbfill = arg(5, stack, PLOTPDFVAR::DEFAULT_FILL_COLORS); + const KN< double > *const frange = arg(6, stack, reinterpret_cast< KN< double > * >(0)); + const bool gray = arg(7, stack, PLOTPDFVAR::DEFAULT_MONOCHROME); + const bool bw = arg(8, stack, PLOTPDFVAR::DEFAULT_MONOCHROME); + const bool legend = arg(9, stack, PLOTPDFVAR::DEFAULT_SHOW_LEGEND); + const double withmesh = arg(10, stack, PLOTPDFVAR::DEFAULT_WITHMESH); + const bool mesh = arg(11, stack, PLOTPDFVAR::DEFAULT_SHOW_MESH); + const bool index = arg(12, stack, PLOTPDFVAR::DEFAULT_SHOW_INDEX); + const bool belabel = arg(13, stack, PLOTPDFVAR::DEFAULT_SHOW_BELABEL); + const bool isoline = arg(14, stack, PLOTPDFVAR::DEFAULT_SHOW_ISOLINE); + const bool fill = arg(15, stack, PLOTPDFVAR::DEFAULT_SHOW_FILL); + const std::string fetype = get_string(stack, nargs[16], PLOTPDFVAR::DEFAULT_FETYPE); + const std::string title = get_string(stack, nargs[17], PLOTPDFVAR::AppName); + const std::string comment = get_string(stack, nargs[18], ""); + const KN< double > *const fmargin = arg(19, stack, reinterpret_cast< KN< double > * >(0)); + const long prec = arg(20, stack, PLOTPDFVAR::DEFAULT_PRECISION_LEGEND); + const bool logscale = arg(21, stack, PLOTPDFVAR::DEFAULT_LOGSCALE); + const bool zabs = arg(22, stack, PLOTPDFVAR::DEFAULT_ZABS); + const bool zreal = arg(23, stack, PLOTPDFVAR::DEFAULT_ZREAL); + const bool zimag = arg(24, stack, PLOTPDFVAR::DEFAULT_ZIMAG); + const bool zarg = arg(25, stack, PLOTPDFVAR::DEFAULT_ZARG); + const double arrow_scale = arg(26, stack, PLOTPDFVAR::DEFAULT_ARROW_SCALE); + const double ahead_scale = arg(27, stack, PLOTPDFVAR::DEFAULT_AHEAD_SCALE); + const bool unit_arrow = arg(28, stack, PLOTPDFVAR::DEFAULT_UNIT_ARROW); + const bool idcell = arg(29, stack, PLOTPDFVAR::DEFAULT_SHOW_IDCELL); + const bool idvert = arg(30, stack, PLOTPDFVAR::DEFAULT_SHOW_IDVERT); + const bool idedge = arg(31, stack, PLOTPDFVAR::DEFAULT_SHOW_IDEDGE); + const double linewidth = arg(32, stack, PLOTPDFVAR::DEFAULT_LINEWIDTH); + // const KNM *const RGBpalette = arg(33,stack,reinterpret_cast*>(nullptr)); + const KNM< double > *const RGBpalette = nargs[33] ? GetAny< KNM< double > * >((*nargs[33])(stack)) : nullptr; + // const long nbarrow = arg(34,stack,PLOTPDFVAR::DEFAULT_ARROW_COLORS); + // const KN *const varrow = arg(35,stack,reinterpret_cast*>(0)); + const long nbarrow = PLOTPDFVAR::DEFAULT_ARROW_COLORS; + const KN< double > *const varrow = reinterpret_cast< KN< double > * >(0); + + if (verbosity >= 90) { + + // invoked by FreeFem++-nw -v 90 users.edp + + std::cout << "plotPDF:options -------------------------" << std::endl; + std::cout << "plotPDF:option: pagesize=" << draw_pane_size << std::endl; + std::cout << "plotPDF:option: aspectratio=" << aspectratio << std::endl; + std::cout << "plotPDF:option: fontscale=" << fontscale << std::endl; + if (viso) + std::cout << "plotPDF:option: viso->size()=" << viso->size( ) << std::endl; + else + std::cout << "plotPDF:option: viso[] is empty" << std::endl; + std::cout << "plotPDF:option: nbiso=" << nbiso << std::endl; + std::cout << "plotPDF:option: nbfill=" << nbfill << std::endl; + if (frange) + std::cout << "plotPDF:option: frange->size()=" << frange->size( ) << std::endl; + else + std::cout << "plotPDF:option: frange[] is empty" << std::endl; + std::cout << "plotPDF:option: gray=" << gray << std::endl; + std::cout << "plotPDF:option: bw=" << bw << std::endl; + std::cout << "plotPDF:option: value=" << legend << std::endl; + std::cout << "plotPDF:option: withmesh=" << withmesh << std::endl; + std::cout << "plotPDF:option: mesh=" << mesh << std::endl; + std::cout << "plotPDF:option: belabel=" << belabel << std::endl; + std::cout << "plotPDF:option: index=" << index << std::endl; + std::cout << "plotPDF:option: isoline=" << isoline << std::endl; + std::cout << "plotPDF:option: fill=" << fill << std::endl; + std::cout << "plotPDF:option: fetype=" << fetype << std::endl; + std::cout << "plotPDF:option: title=" << title << std::endl; + std::cout << "plotPDF:option: cmm=" << comment << std::endl; + if (fmargin) { + std::cout << "plotPDF:option: fmargin->size()=" << fmargin->size( ) << ", ["; + for (int i = 0; i < fmargin->size( ); i++) std::cout << (*fmargin)[i] << ','; + std::cout << "]" << std::endl; + } else { + std::cout << "plotPDF:option: fmargin[] is empty" << std::endl; + } + std::cout << "plotPDF:option: prec=" << prec << std::endl; + std::cout << "plotPDF:option: logscale=" << logscale << std::endl; + std::cout << "plotPDF:option: zabs=" << zabs << std::endl; + std::cout << "plotPDF:option: zreal=" << zreal << std::endl; + std::cout << "plotPDF:option: zimag=" << zimag << std::endl; + std::cout << "plotPDF:option: zarg=" << zarg << std::endl; + std::cout << "plotPDF:option: coef=" << arrow_scale << std::endl; + std::cout << "plotPDF:option: arrowsize=" << ahead_scale << std::endl; + std::cout << "plotPDF:option: unitarrow=" << unit_arrow << std::endl; #if 0 // not implemented yet std::cout << "plotPDF:option: nbarrow=" << nbarrow << std::endl; @@ -3798,704 +3565,618 @@ AnyType PLOTPDF_Op::operator()(Stack stack) const std::cout << "plotPDF:option: varrow[] is empty" << std::endl; } #endif - std::cout << "plotPDF:option: idcell=" << idcell << std::endl; - std::cout << "plotPDF:option: idvert=" << idvert << std::endl; - std::cout << "plotPDF:option: idedge=" << idedge << std::endl; - std::cout << "plotPDF:option: lw=" << linewidth << std::endl; - - if( RGBpalette ){ - std::cout << "plotPDF:option: palette[" - << RGBpalette->N() << ',' << RGBpalette->M() << "]="; - // RGBpalette->size() - std::cout << "[ "; - for(int i = 0; i < RGBpalette->N(); i++){ - std::cout << '['; - for(int j = 0; j < RGBpalette->M(); j++){ - std::cout << RGBpalette->operator()(i,j); - if( j != RGBpalette->M()-1 ) - std::cout << ','; - else - std::cout << ']'; - } - if( i != RGBpalette->N()-1 ) - std::cout << ", "; - } - std::cout << " ]" << std::endl; - } else { - std::cout << "plotPDF:option: palette[] is empty" << std::endl; - } - - } - - //---------------------------------------- - // detecting filename ending with ".pdf" - //---------------------------------------- - const std::string *const filename = GetAny((*efilename)(stack)); - ffassert(filename); - - const char PDFextension[] = ".pdf"; - const size_t pos = filename->rfind( PDFextension ); - const bool hasPDFextension = ( (pos != std::string::npos) && (pos == (filename->length() - strlen(PDFextension))) ); - - const std::string filename_with_extension = (hasPDFextension)? *filename: *filename + PDFextension; - - if(! (mesh || index || belabel || (isoline && (nbiso > 0)) || (fill && (nbfill > 0)) || ez ) ){ - std::cerr << "plotPDF() : No file output : " << filename_with_extension << std::endl; - return false; - } - - if(! (mesh || index || belabel || ef || (!ef && efx && efy) || ez ) ){ - std::cerr << "plotPDF() : No file output" << filename_with_extension << std::endl; - return false; - } - - const bool monochrome = bw || gray; - - //const std::string PDFtitle(*filename); - const std::string PDFtitle(title.c_str()); - SimplePDFModule mesh_figure( filename_with_extension.c_str(), PDFtitle.c_str() ); - - //---------------------------------------- - // Lower & Upper Bound of Domain - //---------------------------------------- - const Mesh *const pTh = GetAny((*eTh)(stack)); - ffassert(pTh); - const Fem2D::Mesh & Th(*pTh); - const int nVertices = Th.nv; - const int nTriangles = Th.nt; - - R2 Pmin, Pmax; - Th.BoundingBox(Pmin, Pmax); - - const double &x0 = Pmin.x; - const double &y0 = Pmin.y; - - const double &x1 = Pmax.x; - const double &y1 = Pmax.y; - - //-------------------------------------------------- - // comment - //-------------------------------------------------- - const int comment_height - = (comment.length() == 0)? 0: (PLOTPDFVAR::DEFAULT_COMMENT_FONTSIZE + PLOTPDFVAR::DEFAULT_COMMENT_BASE); - - //---------------------------------------- - // user specific margin (by option) - //---------------------------------------- - const int margin[] = { - ( (fmargin) && (fmargin->size() >= 1) )? static_cast((*fmargin)[0]): PLOTPDFVAR::DEFAULT_MARGIN[0], // left - ( (fmargin) && (fmargin->size() >= 2) )? static_cast((*fmargin)[1]): PLOTPDFVAR::DEFAULT_MARGIN[1], // bottom - ( (fmargin) && (fmargin->size() >= 3) )? static_cast((*fmargin)[2]): PLOTPDFVAR::DEFAULT_MARGIN[2], // right - ( (fmargin) && (fmargin->size() >= 4) )? static_cast((*fmargin)[3]): PLOTPDFVAR::DEFAULT_MARGIN[3] // top - }; - const int &marginl = margin[0]; - const int &marginb = margin[1]; - const int &marginr = margin[2]; - const int &margint = margin[3]; - - const int legend_width = 3*PLOTPDFVAR::PADDING + static_cast(PLOTPDFVAR::LEGEND_FONTWIDTH*prec); - - //-------------------------------------------------- - // scaling factor, [x0,x1]*[y0,y1] -> [0,PAGESIZE]^2 - //-------------------------------------------------- - if( aspectratio < 0 ){ - std::cout << "plotPDF(): ar should be positive." << std::endl; - } - const double ar = (aspectratio <= 0)? 1: (y1-y0)/(x1-x0)*aspectratio; - const double rx = draw_pane_size / ((x1 - x0) * ar); - const double ry = draw_pane_size / (y1 - y0); - const double scale = (rx < ry)? rx: ry; // min(rx,ry) - - const int sizex = static_cast(2*PLOTPDFVAR::PADDING + scale*(x1-x0)*ar); - const int sizey = static_cast(2*PLOTPDFVAR::PADDING + scale*(y1-y0)) + comment_height; - - const double index_fontsize = PLOTPDFVAR::DEFAULT_INDEX_FONTSIZE * fontscale; - - //------------------------------ - // color palette - //------------------------------ - // compile error - // KNM default_palette_array - // = KNM_(PLOTPDFVAR::DEFAULT_PALETTE, PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS, 3); - - const KNM default_palette_array( PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS, 3 ); - - // why can we modify const KNM ? - for(int i = 0; i < PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS; i++) - for(int j = 0; j < 3; j++) - default_palette_array(i,j) = PLOTPDFVAR::DEFAULT_PALETTE[i][j]; - - bool validPalette = RGBpalette; - if( RGBpalette && ((RGBpalette->N() == 0) || (RGBpalette->M() < 3)) ){ - std::cout << "plotPDF(): palette is given with illeagal form." << std::endl; - std::cout << "plotPDF(): using default color palette." << std::endl; - validPalette = false; - } - const KNM palette = (RGBpalette && validPalette)? (*RGBpalette): default_palette_array; - - for(int i = 0; i < palette.N(); i++) - for(int j = 0; j < 3; j++) - palette(i,j) /= 255; // why can we modify const KNM ? - - //-------------------------------------------------- - // PDF Contents - //-------------------------------------------------- - std::stringstream Content; - Content.setf( std::ios::fixed ); // PDF does not support floating-point format - Content.precision(3); - - if( mesh ){ - mesh_figure.addBookmark( "Mesh" ); - plot_mesh( Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, sizex, sizey, margin ); - } - - if( index ){ - mesh_figure.addBookmark( "Mesh with Index" ); - plot_mesh( Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge, 1 ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, sizex, sizey, margin ); - } - - if( belabel ){ - mesh_figure.addBookmark( "Mesh with Boundary Label" ); - plot_mesh( Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge, 2 ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, sizex, sizey, margin ); + std::cout << "plotPDF:option: idcell=" << idcell << std::endl; + std::cout << "plotPDF:option: idvert=" << idvert << std::endl; + std::cout << "plotPDF:option: idedge=" << idedge << std::endl; + std::cout << "plotPDF:option: lw=" << linewidth << std::endl; + + if (RGBpalette) { + std::cout << "plotPDF:option: palette[" << RGBpalette->N( ) << ',' << RGBpalette->M( ) << "]="; + // RGBpalette->size() + std::cout << "[ "; + for (int i = 0; i < RGBpalette->N( ); i++) { + std::cout << '['; + for (int j = 0; j < RGBpalette->M( ); j++) { + std::cout << RGBpalette->operator( )(i, j); + if (j != RGBpalette->M( ) - 1) + std::cout << ','; + else + std::cout << ']'; + } + if (i != RGBpalette->N( ) - 1) std::cout << ", "; + } + std::cout << " ]" << std::endl; + } else { + std::cout << "plotPDF:option: palette[] is empty" << std::endl; } + } + + //---------------------------------------- + // detecting filename ending with ".pdf" + //---------------------------------------- + const std::string *const filename = GetAny< std::string * >((*efilename)(stack)); + ffassert(filename); + + const char PDFextension[] = ".pdf"; + const size_t pos = filename->rfind(PDFextension); + const bool hasPDFextension = ((pos != std::string::npos) && (pos == (filename->length( ) - strlen(PDFextension)))); + + const std::string filename_with_extension = (hasPDFextension) ? *filename : *filename + PDFextension; + + if (!(mesh || index || belabel || (isoline && (nbiso > 0)) || (fill && (nbfill > 0)) || ez)) { + std::cerr << "plotPDF() : No file output : " << filename_with_extension << std::endl; + return false; + } + + if (!(mesh || index || belabel || ef || (!ef && efx && efy) || ez)) { + std::cerr << "plotPDF() : No file output" << filename_with_extension << std::endl; + return false; + } + + const bool monochrome = bw || gray; + + // const std::string PDFtitle(*filename); + const std::string PDFtitle(title.c_str( )); + SimplePDFModule mesh_figure(filename_with_extension.c_str( ), PDFtitle.c_str( )); + + //---------------------------------------- + // Lower & Upper Bound of Domain + //---------------------------------------- + const Mesh *const pTh = GetAny< const Mesh *const >((*eTh)(stack)); + ffassert(pTh); + const Fem2D::Mesh &Th(*pTh); + const int nVertices = Th.nv; + const int nTriangles = Th.nt; + + R2 Pmin, Pmax; + Th.BoundingBox(Pmin, Pmax); + + const double &x0 = Pmin.x; + const double &y0 = Pmin.y; + + const double &x1 = Pmax.x; + const double &y1 = Pmax.y; + + //-------------------------------------------------- + // comment + //-------------------------------------------------- + const int comment_height = (comment.length( ) == 0) ? 0 : (PLOTPDFVAR::DEFAULT_COMMENT_FONTSIZE + PLOTPDFVAR::DEFAULT_COMMENT_BASE); + + //---------------------------------------- + // user specific margin (by option) + //---------------------------------------- + const int margin[] = { + ((fmargin) && (fmargin->size( ) >= 1)) ? static_cast< int >((*fmargin)[0]) : PLOTPDFVAR::DEFAULT_MARGIN[0], // left + ((fmargin) && (fmargin->size( ) >= 2)) ? static_cast< int >((*fmargin)[1]) : PLOTPDFVAR::DEFAULT_MARGIN[1], // bottom + ((fmargin) && (fmargin->size( ) >= 3)) ? static_cast< int >((*fmargin)[2]) : PLOTPDFVAR::DEFAULT_MARGIN[2], // right + ((fmargin) && (fmargin->size( ) >= 4)) ? static_cast< int >((*fmargin)[3]) : PLOTPDFVAR::DEFAULT_MARGIN[3] // top + }; + const int &marginl = margin[0]; + const int &marginb = margin[1]; + const int &marginr = margin[2]; + const int &margint = margin[3]; + + const int legend_width = 3 * PLOTPDFVAR::PADDING + static_cast< int >(PLOTPDFVAR::LEGEND_FONTWIDTH * prec); + + //-------------------------------------------------- + // scaling factor, [x0,x1]*[y0,y1] -> [0,PAGESIZE]^2 + //-------------------------------------------------- + if (aspectratio < 0) { + std::cout << "plotPDF(): ar should be positive." << std::endl; + } + const double ar = (aspectratio <= 0) ? 1 : (y1 - y0) / (x1 - x0) * aspectratio; + const double rx = draw_pane_size / ((x1 - x0) * ar); + const double ry = draw_pane_size / (y1 - y0); + const double scale = (rx < ry) ? rx : ry; // min(rx,ry) + + const int sizex = static_cast< int >(2 * PLOTPDFVAR::PADDING + scale * (x1 - x0) * ar); + const int sizey = static_cast< int >(2 * PLOTPDFVAR::PADDING + scale * (y1 - y0)) + comment_height; + + const double index_fontsize = PLOTPDFVAR::DEFAULT_INDEX_FONTSIZE * fontscale; + + //------------------------------ + // color palette + //------------------------------ + // compile error + // KNM default_palette_array + // = KNM_(PLOTPDFVAR::DEFAULT_PALETTE, PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS, 3); + + const KNM< double > default_palette_array(PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS, 3); + + // why can we modify const KNM ? + for (int i = 0; i < PLOTPDFVAR::DEFAULT_PALETTE_NCOLORS; i++) + for (int j = 0; j < 3; j++) default_palette_array(i, j) = PLOTPDFVAR::DEFAULT_PALETTE[i][j]; + + bool validPalette = RGBpalette; + if (RGBpalette && ((RGBpalette->N( ) == 0) || (RGBpalette->M( ) < 3))) { + std::cout << "plotPDF(): palette is given with illeagal form." << std::endl; + std::cout << "plotPDF(): using default color palette." << std::endl; + validPalette = false; + } + const KNM< double > palette = (RGBpalette && validPalette) ? (*RGBpalette) : default_palette_array; + + for (int i = 0; i < palette.N( ); i++) + for (int j = 0; j < 3; j++) palette(i, j) /= 255; // why can we modify const KNM ? + + //-------------------------------------------------- + // PDF Contents + //-------------------------------------------------- + std::stringstream Content; + Content.setf(std::ios::fixed); // PDF does not support floating-point format + Content.precision(3); + + if (mesh) { + mesh_figure.addBookmark("Mesh"); + plot_mesh(Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, sizex, sizey, margin); + } + + if (index) { + mesh_figure.addBookmark("Mesh with Index"); + plot_mesh(Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge, 1); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, sizex, sizey, margin); + } + + if (belabel) { + mesh_figure.addBookmark("Mesh with Boundary Label"); + plot_mesh(Content, Th, scale, ar, x0, y0, marginl, marginb, index_fontsize, monochrome, withmesh, linewidth, idcell, idvert, idedge, 2); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, sizex, sizey, margin); + } + + if (!ef && !efx && !efy && !ez) return true; + + //---------------------------------------------------------------------- + // vector-valued function + //---------------------------------------------------------------------- + const double legend_fontsize = PLOTPDFVAR::DEFAULT_LEGEND_FONTSIZE; + + if (efx && efy) { + + const bool isolineP2 = (fetype == "P2"); + const bool fromVertex = (fetype == "P1") || (fetype == "P2"); - if( !ef && !efx && !efy && !ez ) - return true; - - //---------------------------------------------------------------------- - // vector-valued function - //---------------------------------------------------------------------- - const double legend_fontsize = PLOTPDFVAR::DEFAULT_LEGEND_FONTSIZE; - - if( efx && efy ){ + const int &nTriangles = Th.nt; + KN< double > fx(3 * nTriangles), fy(3 * nTriangles), f2(3 * nTriangles), f2mid(3 * nTriangles); - const bool isolineP2 = (fetype == "P2"); - const bool fromVertex = (fetype == "P1") || (fetype == "P2"); + // find function values on vertices + for (int it = 0; it < nTriangles; it++) { - const int &nTriangles = Th.nt; - KN fx( 3*nTriangles ), fy( 3*nTriangles ), f2( 3*nTriangles ), f2mid( 3*nTriangles ); + const int &v0 = Th(it, 0); + const int &v1 = Th(it, 1); + const int &v2 = Th(it, 2); - // find function values on vertices - for(int it = 0; it < nTriangles; it++){ - - const int &v0 = Th(it,0); - const int &v1 = Th(it,1); - const int &v2 = Th(it,2); - - const double x[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double y[] = { Th(v0).y, Th(v1).y, Th(v2).y }; + const double x[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double y[] = {Th(v0).y, Th(v1).y, Th(v2).y}; #ifdef P2_BARYCENTER - const double cx = ( x[0] + x[1] + x[2] ) / 3; // barycenter, used in P2 - const double cy = ( y[0] + y[1] + y[2] ) / 3; // barycenter, used in P2 + const double cx = (x[0] + x[1] + x[2]) / 3; // barycenter, used in P2 + const double cy = (y[0] + y[1] + y[2]) / 3; // barycenter, used in P2 #endif - for(int iv = 0; iv < 3; iv++){ - MeshPointStack(stack)->setP(pTh,it,iv); // at the iv-th vertex - fx[3*it+iv] = GetAny( (*efx)(stack) ); // Expression ef is atype() - fy[3*it+iv] = GetAny( (*efy)(stack) ); // Expression ef is atype() - f2[3*it+iv] = sqrt( fx[3*it+iv]*fx[3*it+iv] + fy[3*it+iv]*fy[3*it+iv] ); // Euclidean norm + for (int iv = 0; iv < 3; iv++) { + MeshPointStack(stack)->setP(pTh, it, iv); // at the iv-th vertex + fx[3 * it + iv] = GetAny< double >((*efx)(stack)); // Expression ef is atype() + fy[3 * it + iv] = GetAny< double >((*efy)(stack)); // Expression ef is atype() + f2[3 * it + iv] = sqrt(fx[3 * it + iv] * fx[3 * it + iv] + fy[3 * it + iv] * fy[3 * it + iv]); // Euclidean norm - if( isolineP2 ){ + if (isolineP2) { #if defined(P2_BARYCENTER) && defined(P2_EDGE) - const double mx = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double my = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; - const double ex = 0.99*mx+0.01*cx; - const double ey = 0.99*my+0.01*cy; + const double mx = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double my = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; + const double ex = 0.99 * mx + 0.01 * cx; + const double ey = 0.99 * my + 0.01 * cy; #elif defined(P2_BARYCENTER) - const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex - const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex + const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex + const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex #elif defined(P2_EDGE) - const double ex = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double ey = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; + const double ex = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double ey = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; #endif - MeshPointStack(stack)->set( ex, ey ); - const double ffx = GetAny( (*efx)(stack) ); // Expression ef is atype() - const double ffy = GetAny( (*efy)(stack) ); // Expression ef is atype() - f2mid[3*it+iv] = sqrt( ffx*ffx + ffy*ffy ); // Euclidean norm - } - } - } - - mesh_figure.addBookmark( "Profile : Vector-valued Function" ); + MeshPointStack(stack)->set(ex, ey); + const double ffx = GetAny< double >((*efx)(stack)); // Expression ef is atype() + const double ffy = GetAny< double >((*efy)(stack)); // Expression ef is atype() + f2mid[3 * it + iv] = sqrt(ffx * ffx + ffy * ffy); // Euclidean norm + } + } + } - plot_vector2flow( Content, Th, fx, fy, f2, f2mid, isolineP2, fromVertex, palette, arrow_scale, unit_arrow, - linewidth, ahead_scale, nbarrow, varrow, - sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange, fetype, isoline, nbiso, viso ); + mesh_figure.addBookmark("Profile : Vector-valued Function"); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - return true; - } + plot_vector2flow(Content, Th, fx, fy, f2, f2mid, isolineP2, fromVertex, palette, arrow_scale, unit_arrow, linewidth, ahead_scale, nbarrow, varrow, sizex, sizey, scale, ar, x0, y0, y1, marginl, + marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange, fetype, isoline, nbiso, viso); - //---------------------------------------------------------------------- - // complex-valued function (Interpolate Input Array as P1 function) - //---------------------------------------------------------------------- - if( ez ){ - - if( fetype == "P0" ){ - - const int &nTriangles = Th.nt; - KN fz( nTriangles ); - KN fr( nTriangles ), fi( nTriangles ), fm( nTriangles ), fa( nTriangles ); - - for(int it = 0; it < nTriangles; it++){ - - const int &v0 = Th(it,0); - const int &v1 = Th(it,1); - const int &v2 = Th(it,2); - - const double x = (Th(v0).x+Th(v1).x+Th(v2).x)/3; - const double y = (Th(v0).y+Th(v1).y+Th(v2).y)/3; - MeshPointStack(stack)->set( x, y ); // barycenter - - fz[it] = GetAny( (*ez)(stack) ); // Expression ez is atype() - fr[it] = fz[it].real(); - fi[it] = fz[it].imag(); - fm[it] = abs( fz[it] ); - fa[it] = atan2( fi[it], fr[it] ); - } - - //------------------------------ - // fill-style for P0, complex-valued function - //------------------------------ - if( fill && (nbfill > 0) && zreal ){ - mesh_figure.addBookmark( "Fill : Real Part" ); - plot_P0_fill( Content, Th, fr, // real part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zimag ){ - mesh_figure.addBookmark( "Fill : Imaginary Part" ); - plot_P0_fill( Content, Th, fi, // imaginary part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zabs ){ - mesh_figure.addBookmark( "Fill : Modulus" ); - plot_P0_fill( Content, Th, fm, // modulus - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zarg ){ - mesh_figure.addBookmark( "Fill : Argument" ); - plot_P0_fill( Content, Th, fa, // argument - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - } else if( fetype == "P2" ) { - - // Can this implementation treat P1, P1nc, other types as P2 ? - - const int &nTriangles = Th.nt; - KN fz( 6*nTriangles ); - KN fr( 6*nTriangles ), fi( 6*nTriangles ), fm( 6*nTriangles ), fa( 6*nTriangles ); - - // find function values on vertices - for(int it = 0; it < nTriangles; it++){ - - const int &v0 = Th(it,0); - const int &v1 = Th(it,1); - const int &v2 = Th(it,2); - - const double x[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double y[] = { Th(v0).y, Th(v1).y, Th(v2).y }; + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + return true; + } + + //---------------------------------------------------------------------- + // complex-valued function (Interpolate Input Array as P1 function) + //---------------------------------------------------------------------- + if (ez) { + + if (fetype == "P0") { + + const int &nTriangles = Th.nt; + KN< Complex > fz(nTriangles); + KN< double > fr(nTriangles), fi(nTriangles), fm(nTriangles), fa(nTriangles); + + for (int it = 0; it < nTriangles; it++) { + + const int &v0 = Th(it, 0); + const int &v1 = Th(it, 1); + const int &v2 = Th(it, 2); + + const double x = (Th(v0).x + Th(v1).x + Th(v2).x) / 3; + const double y = (Th(v0).y + Th(v1).y + Th(v2).y) / 3; + MeshPointStack(stack)->set(x, y); // barycenter + + fz[it] = GetAny< Complex >((*ez)(stack)); // Expression ez is atype() + fr[it] = fz[it].real( ); + fi[it] = fz[it].imag( ); + fm[it] = abs(fz[it]); + fa[it] = atan2(fi[it], fr[it]); + } + + //------------------------------ + // fill-style for P0, complex-valued function + //------------------------------ + if (fill && (nbfill > 0) && zreal) { + mesh_figure.addBookmark("Fill : Real Part"); + plot_P0_fill(Content, Th, fr, // real part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zimag) { + mesh_figure.addBookmark("Fill : Imaginary Part"); + plot_P0_fill(Content, Th, fi, // imaginary part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zabs) { + mesh_figure.addBookmark("Fill : Modulus"); + plot_P0_fill(Content, Th, fm, // modulus + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zarg) { + mesh_figure.addBookmark("Fill : Argument"); + plot_P0_fill(Content, Th, fa, // argument + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + } else if (fetype == "P2") { + + // Can this implementation treat P1, P1nc, other types as P2 ? + + const int &nTriangles = Th.nt; + KN< Complex > fz(6 * nTriangles); + KN< double > fr(6 * nTriangles), fi(6 * nTriangles), fm(6 * nTriangles), fa(6 * nTriangles); + + // find function values on vertices + for (int it = 0; it < nTriangles; it++) { + + const int &v0 = Th(it, 0); + const int &v1 = Th(it, 1); + const int &v2 = Th(it, 2); + + const double x[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double y[] = {Th(v0).y, Th(v1).y, Th(v2).y}; #ifdef P2_BARYCENTER - const double cx = ( x[0] + x[1] + x[2] ) / 3; // barycenter, used in P2 - const double cy = ( y[0] + y[1] + y[2] ) / 3; // barycenter, used in P2 + const double cx = (x[0] + x[1] + x[2]) / 3; // barycenter, used in P2 + const double cy = (y[0] + y[1] + y[2]) / 3; // barycenter, used in P2 #endif - for(int iv = 0; iv < 3; iv++){ + for (int iv = 0; iv < 3; iv++) { + + MeshPointStack(stack)->setP(pTh, it, iv); // at the iv-th vertex + fz[6 * it + iv] = GetAny< Complex >((*ez)(stack)); // Expression ez is atype() - MeshPointStack(stack)->setP(pTh,it,iv); // at the iv-th vertex - fz[6*it+iv] = GetAny( (*ez)(stack) ); // Expression ez is atype() - #if defined(P2_BARYCENTER) && defined(P2_EDGE) - const double mx = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double my = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; - const double ex = 0.99*mx+0.01*cx; - const double ey = 0.99*my+0.01*cy; + const double mx = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double my = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; + const double ex = 0.99 * mx + 0.01 * cx; + const double ey = 0.99 * my + 0.01 * cy; #elif defined(P2_BARYCENTER) - const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex - const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex + const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex + const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex #elif defined(P2_EDGE) - const double ex = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double ey = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; + const double ex = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double ey = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; #endif - MeshPointStack(stack)->set( ex, ey ); - fz[ 6*it + 3 + iv ] = GetAny( (*ez)(stack) ); // Expression ef is atype() - } - - for(int i = 0; i < 6; i++){ - fr[6*it+i] = fz[6*it+i].real(); - fi[6*it+i] = fz[6*it+i].imag(); - fm[6*it+i] = abs( fz[6*it+i] ); - fa[6*it+i] = atan2( fi[6*it+i], fr[6*it+i] ); - } - } - - //------------------------------ - // isoline for P2 - //------------------------------ - if( isoline && (nbiso > 0) && zreal ){ - mesh_figure.addBookmark( "Isoline : Real Part" ); - plot_P2_isoline( Content, Th, fr, // real part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zimag ){ - mesh_figure.addBookmark( "Isoline : Imaginary Part" ); - plot_P2_isoline( Content, Th, fi, // imaginary part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zabs ){ - mesh_figure.addBookmark( "Isoline : Modulus" ); - plot_P2_isoline( Content, Th, fm, // modulus - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zarg ){ - mesh_figure.addBookmark( "Isoline : Argument" ); - plot_P2_isoline( Content, Th, fa, // argument - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - //------------------------------ - // fill-style for P2 - //------------------------------ - if( fill && (nbfill > 0) && zreal ){ - mesh_figure.addBookmark( "Fill : Real Part" ); - plot_P2_fill( Content, Th, fr, // real part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zimag ){ - mesh_figure.addBookmark( "Fill : Imaginary Part" ); - plot_P2_fill( Content, Th, fi, // imaginary part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zabs ){ - mesh_figure.addBookmark( "Fill : Modulus" ); - plot_P2_fill( Content, Th, fm, // modulus - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zarg ){ - mesh_figure.addBookmark( "Fill : Argument" ); - plot_P2_fill( Content, Th, fa, // argument - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } + MeshPointStack(stack)->set(ex, ey); + fz[6 * it + 3 + iv] = GetAny< Complex >((*ez)(stack)); // Expression ef is atype() + } - } else { - - if( (fetype != "P1") && (fetype != "P1nc") ){ - std::cout << "plotPDF() : Unknown fetype : " << fetype << std::endl; - std::cout << "plotPDF() : Interpolated as piecewise-linear" << std::endl; - } - - const int &nTriangles = Th.nt; - KN fz( 3*nTriangles ); - KN fr( 3*nTriangles ), fi( 3*nTriangles ), fm( 3*nTriangles ), fa( 3*nTriangles ); - - // find function values on vertices - for(int it = 0; it < nTriangles; it++){ - - for(int iv = 0; iv < 3; iv++){ - MeshPointStack(stack)->setP(pTh,it,iv); // at the iv-th vertex - fz[3*it+iv] = GetAny( (*ez)(stack) ); // Expression ez is atype() - fr[3*it+iv] = fz[3*it+iv].real(); - fi[3*it+iv] = fz[3*it+iv].imag(); - fm[3*it+iv] = abs( fz[3*it+iv] ); - fa[3*it+iv] = atan2( fi[3*it+iv], fr[3*it+iv] ); - } - } - - // P1, P1nc and Other Interpolated Functions - //------------------------------ - // isoline for P1 - //------------------------------ - if( isoline && (nbiso > 0) && zreal ){ - mesh_figure.addBookmark( "Isoline : Real Part" ); - plot_P1_isoline( Content, Th, fr, // real part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zimag ){ - mesh_figure.addBookmark( "Isoline : Imaginary Part" ); - plot_P1_isoline( Content, Th, fi, // imaginary part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zabs ){ - mesh_figure.addBookmark( "Isoline : Modulus" ); - plot_P1_isoline( Content, Th, fm, // modulus - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( isoline && (nbiso > 0) && zarg ){ - mesh_figure.addBookmark( "Isoline : Argument" ); - plot_P1_isoline( Content, Th, fa, // argument - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - //------------------------------ - // fill-style for P1 - //------------------------------ - if( fill && (nbfill > 0) && zreal ){ - mesh_figure.addBookmark( "Fill : Real Part" ); - plot_P1_fill( Content, Th, fr, // real part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zimag ){ - mesh_figure.addBookmark( "Fill : Imaginary Part" ); - plot_P1_fill( Content, Th, fi, // imaginary part - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zabs ){ - mesh_figure.addBookmark( "Fill : Modulus" ); - plot_P1_fill( Content, Th, fm, // modulus - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) && zarg ){ - mesh_figure.addBookmark( "Fill : Argument" ); - plot_P1_fill( Content, Th, fa, // argument - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - } + for (int i = 0; i < 6; i++) { + fr[6 * it + i] = fz[6 * it + i].real( ); + fi[6 * it + i] = fz[6 * it + i].imag( ); + fm[6 * it + i] = abs(fz[6 * it + i]); + fa[6 * it + i] = atan2(fi[6 * it + i], fr[6 * it + i]); + } + } + + //------------------------------ + // isoline for P2 + //------------------------------ + if (isoline && (nbiso > 0) && zreal) { + mesh_figure.addBookmark("Isoline : Real Part"); + plot_P2_isoline(Content, Th, fr, // real part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zimag) { + mesh_figure.addBookmark("Isoline : Imaginary Part"); + plot_P2_isoline(Content, Th, fi, // imaginary part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zabs) { + mesh_figure.addBookmark("Isoline : Modulus"); + plot_P2_isoline(Content, Th, fm, // modulus + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zarg) { + mesh_figure.addBookmark("Isoline : Argument"); + plot_P2_isoline(Content, Th, fa, // argument + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + //------------------------------ + // fill-style for P2 + //------------------------------ + if (fill && (nbfill > 0) && zreal) { + mesh_figure.addBookmark("Fill : Real Part"); + plot_P2_fill(Content, Th, fr, // real part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zimag) { + mesh_figure.addBookmark("Fill : Imaginary Part"); + plot_P2_fill(Content, Th, fi, // imaginary part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zabs) { + mesh_figure.addBookmark("Fill : Modulus"); + plot_P2_fill(Content, Th, fm, // modulus + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zarg) { + mesh_figure.addBookmark("Fill : Argument"); + plot_P2_fill(Content, Th, fa, // argument + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } - return true; + } else { + + if ((fetype != "P1") && (fetype != "P1nc")) { + std::cout << "plotPDF() : Unknown fetype : " << fetype << std::endl; + std::cout << "plotPDF() : Interpolated as piecewise-linear" << std::endl; + } + + const int &nTriangles = Th.nt; + KN< Complex > fz(3 * nTriangles); + KN< double > fr(3 * nTriangles), fi(3 * nTriangles), fm(3 * nTriangles), fa(3 * nTriangles); + + // find function values on vertices + for (int it = 0; it < nTriangles; it++) { + + for (int iv = 0; iv < 3; iv++) { + MeshPointStack(stack)->setP(pTh, it, iv); // at the iv-th vertex + fz[3 * it + iv] = GetAny< Complex >((*ez)(stack)); // Expression ez is atype() + fr[3 * it + iv] = fz[3 * it + iv].real( ); + fi[3 * it + iv] = fz[3 * it + iv].imag( ); + fm[3 * it + iv] = abs(fz[3 * it + iv]); + fa[3 * it + iv] = atan2(fi[3 * it + iv], fr[3 * it + iv]); + } + } + + // P1, P1nc and Other Interpolated Functions + //------------------------------ + // isoline for P1 + //------------------------------ + if (isoline && (nbiso > 0) && zreal) { + mesh_figure.addBookmark("Isoline : Real Part"); + plot_P1_isoline(Content, Th, fr, // real part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zimag) { + mesh_figure.addBookmark("Isoline : Imaginary Part"); + plot_P1_isoline(Content, Th, fi, // imaginary part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zabs) { + mesh_figure.addBookmark("Isoline : Modulus"); + plot_P1_isoline(Content, Th, fm, // modulus + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (isoline && (nbiso > 0) && zarg) { + mesh_figure.addBookmark("Isoline : Argument"); + plot_P1_isoline(Content, Th, fa, // argument + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + //------------------------------ + // fill-style for P1 + //------------------------------ + if (fill && (nbfill > 0) && zreal) { + mesh_figure.addBookmark("Fill : Real Part"); + plot_P1_fill(Content, Th, fr, // real part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zimag) { + mesh_figure.addBookmark("Fill : Imaginary Part"); + plot_P1_fill(Content, Th, fi, // imaginary part + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zabs) { + mesh_figure.addBookmark("Fill : Modulus"); + plot_P1_fill(Content, Th, fm, // modulus + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0) && zarg) { + mesh_figure.addBookmark("Fill : Argument"); + plot_P1_fill(Content, Th, fa, // argument + palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } } - //---------------------------------------------------------------------- - // Output Specific FE-type (scalar function) - //---------------------------------------------------------------------- - if( fetype == "P0" ){ + return true; + } - const int &nTriangles = Th.nt; - KN f_FE( nTriangles ); + //---------------------------------------------------------------------- + // Output Specific FE-type (scalar function) + //---------------------------------------------------------------------- + if (fetype == "P0") { - for(int it = 0; it < nTriangles; it++){ + const int &nTriangles = Th.nt; + KN< double > f_FE(nTriangles); - const int &v0 = Th(it,0); - const int &v1 = Th(it,1); - const int &v2 = Th(it,2); + for (int it = 0; it < nTriangles; it++) { - const double x = (Th(v0).x+Th(v1).x+Th(v2).x)/3; - const double y = (Th(v0).y+Th(v1).y+Th(v2).y)/3; - MeshPointStack(stack)->set( x, y ); // barycenter + const int &v0 = Th(it, 0); + const int &v1 = Th(it, 1); + const int &v2 = Th(it, 2); - f_FE[it] = GetAny( (*ef)(stack) ); // Expression ef is atype() - } + const double x = (Th(v0).x + Th(v1).x + Th(v2).x) / 3; + const double y = (Th(v0).y + Th(v1).y + Th(v2).y) / 3; + MeshPointStack(stack)->set(x, y); // barycenter - mesh_figure.addBookmark( "P0 Profile" ); - plot_P0_fill( Content, Th, f_FE, - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - return true; - } + f_FE[it] = GetAny< double >((*ef)(stack)); // Expression ef is atype() + } - if( fetype == "P2" ){ + mesh_figure.addBookmark("P0 Profile"); + plot_P0_fill(Content, Th, f_FE, palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + return true; + } - KN f_FE( 6*nTriangles ); + if (fetype == "P2") { - // loop over triangle - for(int it = 0; it < nTriangles; it++){ + KN< double > f_FE(6 * nTriangles); - const int &v0 = Th(it,0); - const int &v1 = Th(it,1); - const int &v2 = Th(it,2); + // loop over triangle + for (int it = 0; it < nTriangles; it++) { + + const int &v0 = Th(it, 0); + const int &v1 = Th(it, 1); + const int &v2 = Th(it, 2); - const double x[] = { Th(v0).x, Th(v1).x, Th(v2).x }; - const double y[] = { Th(v0).y, Th(v1).y, Th(v2).y }; + const double x[] = {Th(v0).x, Th(v1).x, Th(v2).x}; + const double y[] = {Th(v0).y, Th(v1).y, Th(v2).y}; #ifdef P2_BARYCENTER - const double cx = ( x[0] + x[1] + x[2] ) / 3; // barycenter, used in P2 - const double cy = ( y[0] + y[1] + y[2] ) / 3; // barycenter, used in P2 + const double cx = (x[0] + x[1] + x[2]) / 3; // barycenter, used in P2 + const double cy = (y[0] + y[1] + y[2]) / 3; // barycenter, used in P2 #endif - // f_FE[i] = func(v[i]), f_FE[i+3] = func(e[i]), i=0,1,2. - for(int iv = 0; iv < 3; iv++){ - - MeshPointStack(stack)->setP(pTh,it,iv); // at the iv-th vertex - f_FE[ 6*it + iv ] = GetAny( (*ef)(stack) ); // Expression ef is atype() + // f_FE[i] = func(v[i]), f_FE[i+3] = func(e[i]), i=0,1,2. + for (int iv = 0; iv < 3; iv++) { + + MeshPointStack(stack)->setP(pTh, it, iv); // at the iv-th vertex + f_FE[6 * it + iv] = GetAny< double >((*ef)(stack)); // Expression ef is atype() #if defined(P2_BARYCENTER) && defined(P2_EDGE) - const double mx = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double my = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; - const double ex = 0.99*mx+0.01*cx; - const double ey = 0.99*my+0.01*cy; + const double mx = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double my = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; + const double ex = 0.99 * mx + 0.01 * cx; + const double ey = 0.99 * my + 0.01 * cy; #elif defined(P2_BARYCENTER) - const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex - const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex + const double ex = (x[iv] + cx) / 2; // mid-point of barycenter and iv-th vertex + const double ey = (y[iv] + cy) / 2; // mid-point of barycenter and iv-th vertex #elif defined(P2_EDGE) - const double ex = (x[(iv+1)%3]+x[(iv+2)%3]) / 2; // mid-point of iv-th edge - const double ey = (y[(iv+1)%3]+y[(iv+2)%3]) / 2; + const double ex = (x[(iv + 1) % 3] + x[(iv + 2) % 3]) / 2; // mid-point of iv-th edge + const double ey = (y[(iv + 1) % 3] + y[(iv + 2) % 3]) / 2; #endif - MeshPointStack(stack)->set( ex, ey ); - f_FE[ 6*it + 3 + iv ] = GetAny( (*ef)(stack) ); // Expression ef is atype() - } - } - - if( isoline && (nbiso > 0) ){ - mesh_figure.addBookmark( "P2 Isoline" ); - plot_P2_isoline( Content, Th, f_FE, - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) ){ - mesh_figure.addBookmark( "P2 Profile" ); - plot_P2_fill( Content, Th, f_FE, - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } + MeshPointStack(stack)->set(ex, ey); + f_FE[6 * it + 3 + iv] = GetAny< double >((*ef)(stack)); // Expression ef is atype() + } + } - return true; + if (isoline && (nbiso > 0)) { + mesh_figure.addBookmark("P2 Isoline"); + plot_P2_isoline(Content, Th, f_FE, palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); } - //---------------------------------------------------------------------- - // Interpolate Input Array as P1 (or P1nc) function - //---------------------------------------------------------------------- - KN f_FE( 3*nTriangles ); - - if( (fetype != "P1") && (fetype != "P1nc") ){ - std::cout << "plotPDF() : Unknown fetype : " << fetype << std::endl; - std::cout << "plotPDF() : Interpolated as piecewise-linear" << std::endl; + if (fill && (nbfill > 0)) { + mesh_figure.addBookmark("P2 Profile"); + plot_P2_fill(Content, Th, f_FE, palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); } - // find function values on vertices - for(int it = 0; it < nTriangles; it++){ - - for(int iv = 0; iv < 3; iv++){ - MeshPointStack(stack)->setP(pTh,it,iv); // at the iv-th vertex - f_FE[3*it+iv] = GetAny( (*ef)(stack) ); // Expression ef is atype() - } + return true; + } + + //---------------------------------------------------------------------- + // Interpolate Input Array as P1 (or P1nc) function + //---------------------------------------------------------------------- + KN< double > f_FE(3 * nTriangles); + + if ((fetype != "P1") && (fetype != "P1nc")) { + std::cout << "plotPDF() : Unknown fetype : " << fetype << std::endl; + std::cout << "plotPDF() : Interpolated as piecewise-linear" << std::endl; + } + + // find function values on vertices + for (int it = 0; it < nTriangles; it++) { + + for (int iv = 0; iv < 3; iv++) { + MeshPointStack(stack)->setP(pTh, it, iv); // at the iv-th vertex + f_FE[3 * it + iv] = GetAny< double >((*ef)(stack)); // Expression ef is atype() } + } #if 0 { // output for GNUPLOT @@ -4521,101 +4202,91 @@ AnyType PLOTPDF_Op::operator()(Stack stack) const } #endif - // P1, P1nc and Other Interpolated Functions - if( isoline && (nbiso > 0) ){ - mesh_figure.addBookmark( "Isoline" ); - plot_P1_isoline( Content, Th, f_FE, - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbiso, viso, linewidth ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - - if( fill && (nbfill > 0) ){ - mesh_figure.addBookmark( "Profile" ); - plot_P1_fill( Content, Th, f_FE, - palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, - legend_fontsize, monochrome, legend, prec, logscale, - withmesh, nbfill, frange ); - if( comment.length() > 0 ) - addComment( Content, scale*(y1-y0), marginl, marginb, fontscale, comment ); - mesh_figure.addPage( Content, (legend? (sizex+legend_width): sizex), sizey, margin ); - } - return true; + // P1, P1nc and Other Interpolated Functions + if (isoline && (nbiso > 0)) { + mesh_figure.addBookmark("Isoline"); + plot_P1_isoline(Content, Th, f_FE, palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbiso, viso, linewidth); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + + if (fill && (nbfill > 0)) { + mesh_figure.addBookmark("Profile"); + plot_P1_fill(Content, Th, f_FE, palette, sizex, sizey, scale, ar, x0, y0, y1, marginl, marginb, legend_fontsize, monochrome, legend, prec, logscale, withmesh, nbfill, frange); + if (comment.length( ) > 0) addComment(Content, scale * (y1 - y0), marginl, marginb, fontscale, comment); + mesh_figure.addPage(Content, (legend ? (sizex + legend_width) : sizex), sizey, margin); + } + return true; } -class PLOTPDF: public OneOperator -{ - const int argc; -public: - PLOTPDF() : OneOperator( atype(), atype(), atype() ), argc(2) {} - PLOTPDF(int) : OneOperator( atype(), atype(), atype(), atype() ), argc(3) {} - //PLOTPDF(int,int) : OneOperator( atype(), atype(), atype(), atype() ), argc(4) {} - // vector field - PLOTPDF(int,int) : OneOperator( atype(), atype(), atype(), atype() ), argc(3) {} - - // complex-valued function - PLOTPDF(int,int,int) : OneOperator( atype(), atype(), atype(), atype() ), argc(5) {} - - E_F0 * code(const basicAC_F0 & args) const - { - if(argc == 2) { - - // mesh - return new PLOTPDF_Op( args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]) ); - - } else if(argc == 3) { - - if( BCastTo( args[2] ) ){ - - // scalar (real-valued) function - return new PLOTPDF_Op( args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]) ); - - } else if( args[2].left() == atype() ) { - - // vector-valued function - const int DimVector = 2; - - const E_Array *const a2 = dynamic_cast( args[2].LeftValue() ); - if( a2->size() != DimVector ){ - std::cerr << "plotPDF() : Error: The size of vector-valued function is not valid." << std::endl; - ffassert(0); - } - Expression fx = to( (*a2)[0] ); - Expression fy = to( (*a2)[1] ); - return new PLOTPDF_Op( args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), fx, fy ); - } - - } else if(argc == 5) { - - // complex-valued function - return new PLOTPDF_Op( args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), static_cast(0) ); - } - ffassert(0); +class PLOTPDF : public OneOperator { + const int argc; + + public: + PLOTPDF( ) : OneOperator(atype< long >( ), atype< std::string * >( ), atype< const Mesh * >( )), argc(2) {} + PLOTPDF(int) : OneOperator(atype< long >( ), atype< std::string * >( ), atype< const Mesh * >( ), atype< double >( )), argc(3) {} + // PLOTPDF(int,int) : OneOperator( atype(), atype(), atype(), atype() ), argc(4) {} + // vector field + PLOTPDF(int, int) : OneOperator(atype< long >( ), atype< std::string * >( ), atype< const Mesh * >( ), atype< E_Array >( )), argc(3) {} + + // complex-valued function + PLOTPDF(int, int, int) : OneOperator(atype< long >( ), atype< std::string * >( ), atype< const Mesh * >( ), atype< Complex >( )), argc(5) {} + + E_F0 *code(const basicAC_F0 &args) const { + if (argc == 2) { + + // mesh + return new PLOTPDF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); + + } else if (argc == 3) { + + if (BCastTo< double >(args[2])) { + + // scalar (real-valued) function + return new PLOTPDF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); + + } else if (args[2].left( ) == atype< E_Array >( )) { + + // vector-valued function + const int DimVector = 2; + + const E_Array *const a2 = dynamic_cast< const E_Array * >(args[2].LeftValue( )); + if (a2->size( ) != DimVector) { + std::cerr << "plotPDF() : Error: The size of vector-valued function is not valid." << std::endl; + ffassert(0); + } + Expression fx = to< double >((*a2)[0]); + Expression fy = to< double >((*a2)[1]); + return new PLOTPDF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), fx, fy); + } + + } else if (argc == 5) { + + // complex-valued function + return new PLOTPDF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), static_cast< Complex >(0)); } + ffassert(0); + } }; //---------------------------------------------------------------------- -static void Load_Init() -{ - if( verbosity && (mpirank == 0) ){ - std::cout << " load: plotPDF " << PLOTPDFVAR::SHOW_VERSION << std::endl; - } +static void Load_Init( ) { + if (verbosity && (mpirank == 0)) { + std::cout << " load: plotPDF " << PLOTPDFVAR::SHOW_VERSION << std::endl; + } - if( verbosity >= 10 ){ - std::cout << "plotPDF: The manual and latest version are found at http://www-an.acs.i.kyoto-u.ac.jp/~fujiwara/ff" << std::endl; - } + if (verbosity >= 10) { + std::cout << "plotPDF: The manual and latest version are found at http://www-an.acs.i.kyoto-u.ac.jp/~fujiwara/ff" << std::endl; + } - Global.Add("plotPDF", "(", new PLOTPDF); // mesh only - Global.Add("plotPDF", "(", new PLOTPDF(0)); // real valued - Global.Add("plotPDF", "(", new PLOTPDF(0,0)); // vector valued - Global.Add("plotPDF", "(", new PLOTPDF(0,0,0)); // complex-valued + Global.Add("plotPDF", "(", new PLOTPDF); // mesh only + Global.Add("plotPDF", "(", new PLOTPDF(0)); // real valued + Global.Add("plotPDF", "(", new PLOTPDF(0, 0)); // vector valued + Global.Add("plotPDF", "(", new PLOTPDF(0, 0, 0)); // complex-valued } -LOADFUNC( Load_Init ); +LOADFUNC(Load_Init); //---------------------------------------------------------------------- // End of file diff --git a/plugin/seq/ppm2rnm.cpp b/plugin/seq/ppm2rnm.cpp index f4e2e1adc..86389be66 100644 --- a/plugin/seq/ppm2rnm.cpp +++ b/plugin/seq/ppm2rnm.cpp @@ -177,8 +177,7 @@ PPMimage *load_PPM(const char *imgName, ubyte quiet) { } if (!quiet) { - fprintf(stdout, "%s Image size: %dx%d - %d bytes\n", DISP_INFO, result->sizeX, result->sizeY, - bitsize); + fprintf(stdout, "%s Image size: %dx%d - %d bytes\n", DISP_INFO, result->sizeX, result->sizeY, bitsize); } result->data = (ubyte *)malloc(1 + bitsize * sizeof(ubyte)); @@ -388,9 +387,7 @@ pRnm readPPM(pRnm const &a, const pstring &imgName) { return a; } - if (verbosity) - cout << DISP_INFO << " Image size: " << image->sizeX << " x " << image->sizeY - << " - Type: " << (int)image->type << endl; + if (verbosity) cout << DISP_INFO << " Image size: " << image->sizeX << " x " << image->sizeY << " - Type: " << (int)image->type << endl; n = image->sizeX; m = image->sizeY; @@ -426,9 +423,7 @@ KNM< double > *readPPM(const pstring &imgName) { return 0; } - if (verbosity) - cout << DISP_INFO << " Image size: " << image->sizeX << " x " << image->sizeY - << " - Type: " << (int)image->type << endl; + if (verbosity) cout << DISP_INFO << " Image size: " << image->sizeX << " x " << image->sizeY << " - Type: " << (int)image->type << endl; imageArray = PPMimage2Rnm(image); if (!imageArray) { @@ -617,15 +612,12 @@ pRn seta(pRn const &a, const pRnm &b) { static void Load_PPM2RNM( ) { cout << " load: ppm2rnm" << endl; - TheOperators->Add("<-", - new OneOperator2_< KNM< double > *, KNM< double > *, string * >(&readPPM)); - TheOperators->Add("=", - new OneOperator2_< KN< double > *, KN< double > *, KNM< double > * >(seta)); + TheOperators->Add("<-", new OneOperator2_< KNM< double > *, KNM< double > *, string * >(&readPPM)); + TheOperators->Add("=", new OneOperator2_< KN< double > *, KN< double > *, KNM< double > * >(seta)); Global.Add("readPPM", "(", new OneOperator1_< KNM< double > *, string * >(&readPPM)); Global.Add("savePPM", "(", new OneOperator2_< bool, string *, KNM< double > * >(&savePPM)); - Global.Add("diffPPM", "(", - new OneOperator2_< KNM< double > *, KNM< double > *, KNM< double > * >(&diffPPM)); + Global.Add("diffPPM", "(", new OneOperator2_< KNM< double > *, KNM< double > *, KNM< double > * >(&diffPPM)); } LOADFUNC(Load_PPM2RNM) diff --git a/plugin/seq/pstream.h b/plugin/seq/pstream.h index 98c5a764e..79554fbeb 100644 --- a/plugin/seq/pstream.h +++ b/plugin/seq/pstream.h @@ -310,9 +310,7 @@ namespace redi { */ template< typename CharT, typename Traits = std::char_traits< CharT > > - class basic_ipstream : public std::basic_istream< CharT, Traits >, - public pstream_common< CharT, Traits >, - virtual public pstreams { + class basic_ipstream : public std::basic_istream< CharT, Traits >, public pstream_common< CharT, Traits >, virtual public pstreams { typedef std::basic_istream< CharT, Traits > istream_type; typedef pstream_common< CharT, Traits > pbase_type; @@ -346,8 +344,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - basic_ipstream(const std::string &command, pmode mode = pstdout) - : istream_type(NULL), pbase_type(command, readable(mode)) {} + basic_ipstream(const std::string &command, pmode mode = pstdout) : istream_type(NULL), pbase_type(command, readable(mode)) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -360,8 +357,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_ipstream(const std::string &file, const argv_type &argv, pmode mode = pstdout) - : istream_type(NULL), pbase_type(file, argv, readable(mode)) {} + basic_ipstream(const std::string &file, const argv_type &argv, pmode mode = pstdout) : istream_type(NULL), pbase_type(file, argv, readable(mode)) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -373,8 +369,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_ipstream(const argv_type &argv, pmode mode = pstdout) - : istream_type(NULL), pbase_type(argv.at(0), argv, mode | pstdout) {} + basic_ipstream(const argv_type &argv, pmode mode = pstdout) : istream_type(NULL), pbase_type(argv.at(0), argv, mode | pstdout) {} /** * @brief Destructor. @@ -392,9 +387,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - void open(const std::string &command, pmode mode = pstdout) { - this->do_open(command, readable(mode)); - } + void open(const std::string &command, pmode mode = pstdout) { this->do_open(command, readable(mode)); } /** * @brief Start a process. @@ -406,9 +399,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - void open(const std::string &file, const argv_type &argv, pmode mode = pstdout) { - this->do_open(file, argv, readable(mode)); - } + void open(const std::string &file, const argv_type &argv, pmode mode = pstdout) { this->do_open(file, argv, readable(mode)); } /** * @brief Set streambuf to read from process' @c stdout. @@ -439,9 +430,7 @@ namespace redi { */ template< typename CharT, typename Traits = std::char_traits< CharT > > - class basic_opstream : public std::basic_ostream< CharT, Traits >, - public pstream_common< CharT, Traits >, - virtual public pstreams { + class basic_opstream : public std::basic_ostream< CharT, Traits >, public pstream_common< CharT, Traits >, virtual public pstreams { typedef std::basic_ostream< CharT, Traits > ostream_type; typedef pstream_common< CharT, Traits > pbase_type; @@ -467,8 +456,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - basic_opstream(const std::string &command, pmode mode = pstdin) - : ostream_type(NULL), pbase_type(command, mode | pstdin) {} + basic_opstream(const std::string &command, pmode mode = pstdin) : ostream_type(NULL), pbase_type(command, mode | pstdin) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -481,8 +469,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_opstream(const std::string &file, const argv_type &argv, pmode mode = pstdin) - : ostream_type(NULL), pbase_type(file, argv, mode | pstdin) {} + basic_opstream(const std::string &file, const argv_type &argv, pmode mode = pstdin) : ostream_type(NULL), pbase_type(file, argv, mode | pstdin) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -494,8 +481,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_opstream(const argv_type &argv, pmode mode = pstdin) - : ostream_type(NULL), pbase_type(argv.at(0), argv, mode | pstdin) {} + basic_opstream(const argv_type &argv, pmode mode = pstdin) : ostream_type(NULL), pbase_type(argv.at(0), argv, mode | pstdin) {} /** * @brief Destructor @@ -513,9 +499,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - void open(const std::string &command, pmode mode = pstdin) { - this->do_open(command, mode | pstdin); - } + void open(const std::string &command, pmode mode = pstdin) { this->do_open(command, mode | pstdin); } /** * @brief Start a process. @@ -527,9 +511,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - void open(const std::string &file, const argv_type &argv, pmode mode = pstdin) { - this->do_open(file, argv, mode | pstdin); - } + void open(const std::string &file, const argv_type &argv, pmode mode = pstdin) { this->do_open(file, argv, mode | pstdin); } }; /** @@ -546,9 +528,7 @@ namespace redi { * unless altered by the command itself. */ template< typename CharT, typename Traits = std::char_traits< CharT > > - class basic_pstream : public std::basic_iostream< CharT, Traits >, - public pstream_common< CharT, Traits >, - virtual public pstreams { + class basic_pstream : public std::basic_iostream< CharT, Traits >, public pstream_common< CharT, Traits >, virtual public pstreams { typedef std::basic_iostream< CharT, Traits > iostream_type; typedef pstream_common< CharT, Traits > pbase_type; @@ -574,8 +554,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - basic_pstream(const std::string &command, pmode mode = pstdout | pstdin) - : iostream_type(NULL), pbase_type(command, mode) {} + basic_pstream(const std::string &command, pmode mode = pstdout | pstdin) : iostream_type(NULL), pbase_type(command, mode) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -588,8 +567,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_pstream(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) - : iostream_type(NULL), pbase_type(file, argv, mode) {} + basic_pstream(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) : iostream_type(NULL), pbase_type(file, argv, mode) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -601,8 +579,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_pstream(const argv_type &argv, pmode mode = pstdout | pstdin) - : iostream_type(NULL), pbase_type(argv.at(0), argv, mode) {} + basic_pstream(const argv_type &argv, pmode mode = pstdout | pstdin) : iostream_type(NULL), pbase_type(argv.at(0), argv, mode) {} /** * @brief Destructor @@ -620,9 +597,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - void open(const std::string &command, pmode mode = pstdout | pstdin) { - this->do_open(command, mode); - } + void open(const std::string &command, pmode mode = pstdout | pstdin) { this->do_open(command, mode); } /** * @brief Start a process. @@ -634,9 +609,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - void open(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) { - this->do_open(file, argv, mode); - } + void open(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) { this->do_open(file, argv, mode); } /** * @brief Set streambuf to read from process' @c stdout. @@ -679,10 +652,7 @@ namespace redi { */ template< typename CharT, typename Traits = std::char_traits< CharT > > - class basic_rpstream : public std::basic_ostream< CharT, Traits >, - private std::basic_istream< CharT, Traits >, - private pstream_common< CharT, Traits >, - virtual public pstreams { + class basic_rpstream : public std::basic_ostream< CharT, Traits >, private std::basic_istream< CharT, Traits >, private pstream_common< CharT, Traits >, virtual public pstreams { typedef std::basic_ostream< CharT, Traits > ostream_type; typedef std::basic_istream< CharT, Traits > istream_type; typedef pstream_common< CharT, Traits > pbase_type; @@ -709,8 +679,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - basic_rpstream(const std::string &command, pmode mode = pstdout | pstdin) - : ostream_type(NULL), istream_type(NULL), pbase_type(command, mode) {} + basic_rpstream(const std::string &command, pmode mode = pstdout | pstdin) : ostream_type(NULL), istream_type(NULL), pbase_type(command, mode) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -723,8 +692,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_rpstream(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) - : ostream_type(NULL), istream_type(NULL), pbase_type(file, argv, mode) {} + basic_rpstream(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) : ostream_type(NULL), istream_type(NULL), pbase_type(file, argv, mode) {} /** * @brief Constructor that initialises the stream by starting a process. @@ -736,8 +704,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - basic_rpstream(const argv_type &argv, pmode mode = pstdout | pstdin) - : ostream_type(NULL), istream_type(NULL), pbase_type(argv.at(0), argv, mode) {} + basic_rpstream(const argv_type &argv, pmode mode = pstdout | pstdin) : ostream_type(NULL), istream_type(NULL), pbase_type(argv.at(0), argv, mode) {} /// Destructor ~basic_rpstream( ) {} @@ -751,9 +718,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, pmode) */ - void open(const std::string &command, pmode mode = pstdout | pstdin) { - this->do_open(command, mode); - } + void open(const std::string &command, pmode mode = pstdout | pstdin) { this->do_open(command, mode); } /** * @brief Start a process. @@ -765,9 +730,7 @@ namespace redi { * @param mode the I/O mode to use when opening the pipe. * @see do_open(const std::string&, const argv_type&, pmode) */ - void open(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) { - this->do_open(file, argv, mode); - } + void open(const std::string &file, const argv_type &argv, pmode mode = pstdout | pstdin) { this->do_open(file, argv, mode); } /** * @brief Obtain a reference to the istream that reads @@ -1012,8 +975,7 @@ namespace redi { * @see execvp(3) */ template< typename C, typename T > - basic_pstreambuf< C, T > *basic_pstreambuf< C, T >::open(const std::string &file, - const argv_type &argv, pmode mode) { + basic_pstreambuf< C, T > *basic_pstreambuf< C, T >::open(const std::string &file, const argv_type &argv, pmode mode) { basic_pstreambuf< C, T > *ret = NULL; if (!is_open( )) { @@ -1022,8 +984,7 @@ namespace redi { // open another pipe and set close-on-exec fd_type ck_exec[] = {-1, -1}; - if (-1 == ::pipe(ck_exec) || -1 == ::fcntl(ck_exec[RD], F_SETFD, FD_CLOEXEC) || - -1 == ::fcntl(ck_exec[WR], F_SETFD, FD_CLOEXEC)) { + if (-1 == ::pipe(ck_exec) || -1 == ::fcntl(ck_exec[RD], F_SETFD, FD_CLOEXEC) || -1 == ::fcntl(ck_exec[WR], F_SETFD, FD_CLOEXEC)) { error_ = errno; close_fd_array(ck_exec); } else { @@ -1306,8 +1267,7 @@ namespace redi { } template< typename C, typename T > - typename basic_pstreambuf< C, T >::buf_read_src basic_pstreambuf< C, T >::switch_read_buffer( - buf_read_src src) { + typename basic_pstreambuf< C, T >::buf_read_src basic_pstreambuf< C, T >::switch_read_buffer(buf_read_src src) { if (rsrc_ != src) { char_type *tmpbufstate[] = {this->eback( ), this->gptr( ), this->egptr( )}; this->setg(rbufstate_[0], rbufstate_[1], rbufstate_[2]); @@ -1772,8 +1732,7 @@ namespace redi { /** Creates an uninitialised stream. */ template< typename C, typename T > - inline pstream_common< C, T >::pstream_common( ) - : std::basic_ios< C, T >(NULL), command_( ), buf_( ) { + inline pstream_common< C, T >::pstream_common( ) : std::basic_ios< C, T >(NULL), command_( ), buf_( ) { this->std::basic_ios< C, T >::rdbuf(&buf_); } @@ -1786,8 +1745,7 @@ namespace redi { * @see do_open(const std::string&, pmode) */ template< typename C, typename T > - inline pstream_common< C, T >::pstream_common(const std::string &command, pmode mode) - : std::basic_ios< C, T >(NULL), command_(command), buf_( ) { + inline pstream_common< C, T >::pstream_common(const std::string &command, pmode mode) : std::basic_ios< C, T >(NULL), command_(command), buf_( ) { this->std::basic_ios< C, T >::rdbuf(&buf_); do_open(command, mode); } @@ -1802,9 +1760,7 @@ namespace redi { * @see do_open(const std::string&, const argv_type&, pmode) */ template< typename C, typename T > - inline pstream_common< C, T >::pstream_common(const std::string &file, const argv_type &argv, - pmode mode) - : std::basic_ios< C, T >(NULL), command_(file), buf_( ) { + inline pstream_common< C, T >::pstream_common(const std::string &file, const argv_type &argv, pmode mode) : std::basic_ios< C, T >(NULL), command_(file), buf_( ) { this->std::basic_ios< C, T >::rdbuf(&buf_); do_open(file, argv, mode); } @@ -1846,8 +1802,7 @@ namespace redi { * @see basic_pstreambuf::open(const std::string&, const argv_type&, pmode) */ template< typename C, typename T > - inline void pstream_common< C, T >::do_open(const std::string &file, const argv_type &argv, - pmode mode) { + inline void pstream_common< C, T >::do_open(const std::string &file, const argv_type &argv, pmode mode) { if (!buf_.open((command_ = file), argv, mode)) { this->setstate(std::ios_base::failbit); } diff --git a/plugin/seq/qf11to25.cpp b/plugin/seq/qf11to25.cpp index e70654d05..90a117f2d 100644 --- a/plugin/seq/qf11to25.cpp +++ b/plugin/seq/qf11to25.cpp @@ -144,654 +144,344 @@ using namespace Fem2D; */ static QuadraturePoint P_QuadratureFormular_T_11[] = { - QuadraturePoint(0.0114082494033 / 2, 0.0000000000000, 0.9451704450174), - QuadraturePoint(0.0114082494033 / 2, 0.9451704450173, 0.0000000000000), - QuadraturePoint(0.0132691285720 / 2, 0.9289002405719, 0.0685505797224), - QuadraturePoint(0.0132691285720 / 2, 0.0685505797224, 0.9289002405717), - QuadraturePoint(0.0155865773350 / 2, 0.0243268355615, 0.0243268355616), - QuadraturePoint(0.0408274780428 / 2, 0.1279662835335, 0.0277838749488), - QuadraturePoint(0.0408274780429 / 2, 0.0277838749488, 0.1279662835337), - QuadraturePoint(0.0579849665116 / 2, 0.0287083428360, 0.7498347588657), - QuadraturePoint(0.0579849665116 / 2, 0.7498347588656, 0.0287083428360), - QuadraturePoint(0.0601385247663 / 2, 0.7228007909707, 0.2497602062385), - QuadraturePoint(0.0601385247663 / 2, 0.2497602062386, 0.7228007909707), - QuadraturePoint(0.0625273888433 / 2, 0.0865562992839, 0.8325513856997), - QuadraturePoint(0.0625273888433 / 2, 0.8325513856998, 0.0865562992839), - QuadraturePoint(0.0639684321504 / 2, 0.3061619157672, 0.0303526617491), - QuadraturePoint(0.0639684321504 / 2, 0.0303526617491, 0.3061619157675), - QuadraturePoint(0.0661325872161 / 2, 0.4868610595047, 0.4868610595047), - QuadraturePoint(0.0668503236820 / 2, 0.6657904293017, 0.1765456154219), - QuadraturePoint(0.0668503236821 / 2, 0.1765456154221, 0.6657904293016), - QuadraturePoint(0.0686904305977 / 2, 0.0293121007360, 0.5295657488669), - QuadraturePoint(0.0686904305977 / 2, 0.5295657488667, 0.0293121007360), - QuadraturePoint(0.1002717543859 / 2, 0.1444673824391, 0.1444673824391), - QuadraturePoint(0.1143136784099 / 2, 0.3299740111411, 0.5361815729050), - QuadraturePoint(0.1143136784099 / 2, 0.5361815729052, 0.3299740111409), - QuadraturePoint(0.1223648146752 / 2, 0.5511507516862, 0.1437790861923), - QuadraturePoint(0.1223648146752 / 2, 0.1437790861923, 0.5511507516862), - QuadraturePoint(0.1394422334178 / 2, 0.3348066587327, 0.1529619437161), - QuadraturePoint(0.1394422334178 / 2, 0.1529619437161, 0.3348066587327), - QuadraturePoint(0.1744377829182 / 2, 0.3430183498147, 0.3430183498147), + QuadraturePoint(0.0114082494033 / 2, 0.0000000000000, 0.9451704450174), QuadraturePoint(0.0114082494033 / 2, 0.9451704450173, 0.0000000000000), + QuadraturePoint(0.0132691285720 / 2, 0.9289002405719, 0.0685505797224), QuadraturePoint(0.0132691285720 / 2, 0.0685505797224, 0.9289002405717), + QuadraturePoint(0.0155865773350 / 2, 0.0243268355615, 0.0243268355616), QuadraturePoint(0.0408274780428 / 2, 0.1279662835335, 0.0277838749488), + QuadraturePoint(0.0408274780429 / 2, 0.0277838749488, 0.1279662835337), QuadraturePoint(0.0579849665116 / 2, 0.0287083428360, 0.7498347588657), + QuadraturePoint(0.0579849665116 / 2, 0.7498347588656, 0.0287083428360), QuadraturePoint(0.0601385247663 / 2, 0.7228007909707, 0.2497602062385), + QuadraturePoint(0.0601385247663 / 2, 0.2497602062386, 0.7228007909707), QuadraturePoint(0.0625273888433 / 2, 0.0865562992839, 0.8325513856997), + QuadraturePoint(0.0625273888433 / 2, 0.8325513856998, 0.0865562992839), QuadraturePoint(0.0639684321504 / 2, 0.3061619157672, 0.0303526617491), + QuadraturePoint(0.0639684321504 / 2, 0.0303526617491, 0.3061619157675), QuadraturePoint(0.0661325872161 / 2, 0.4868610595047, 0.4868610595047), + QuadraturePoint(0.0668503236820 / 2, 0.6657904293017, 0.1765456154219), QuadraturePoint(0.0668503236821 / 2, 0.1765456154221, 0.6657904293016), + QuadraturePoint(0.0686904305977 / 2, 0.0293121007360, 0.5295657488669), QuadraturePoint(0.0686904305977 / 2, 0.5295657488667, 0.0293121007360), + QuadraturePoint(0.1002717543859 / 2, 0.1444673824391, 0.1444673824391), QuadraturePoint(0.1143136784099 / 2, 0.3299740111411, 0.5361815729050), + QuadraturePoint(0.1143136784099 / 2, 0.5361815729052, 0.3299740111409), QuadraturePoint(0.1223648146752 / 2, 0.5511507516862, 0.1437790861923), + QuadraturePoint(0.1223648146752 / 2, 0.1437790861923, 0.5511507516862), QuadraturePoint(0.1394422334178 / 2, 0.3348066587327, 0.1529619437161), + QuadraturePoint(0.1394422334178 / 2, 0.1529619437161, 0.3348066587327), QuadraturePoint(0.1744377829182 / 2, 0.3430183498147, 0.3430183498147), }; const QuadratureFormular QuadratureFormular_T_11(11, 28, P_QuadratureFormular_T_11); static QuadraturePoint P_QuadratureFormular_T_13[] = { - QuadraturePoint(0.0166240998757 / 2, 0.0242935351590, 0.9493059293846), - QuadraturePoint(0.0166811699778 / 2, 0.0265193427722, 0.0242695130640), - QuadraturePoint(0.0166830569067 / 2, 0.9492126023551, 0.0265067966437), - QuadraturePoint(0.0175680870083 / 2, 0.0033775763749, 0.4767316412363), - QuadraturePoint(0.0184474661845 / 2, 0.4757672298101, 0.5198921829102), - QuadraturePoint(0.0197942410188 / 2, 0.5190783193471, 0.0055912706202), - QuadraturePoint(0.0203540395855 / 2, 0.8616839745321, 0.0133996048618), - QuadraturePoint(0.0206852863940 / 2, 0.1249209759926, 0.8613054321334), - QuadraturePoint(0.0208271366086 / 2, 0.0138565453861, 0.1247733717358), - QuadraturePoint(0.0317819778279 / 2, 0.0211887064222, 0.8438438351223), - QuadraturePoint(0.0320472035241 / 2, 0.8432296787219, 0.1354563645830), - QuadraturePoint(0.0320607681146 / 2, 0.1354231797865, 0.0213482820656), - QuadraturePoint(0.0430765959183 / 2, 0.3088853510679, 0.0221919663014), - QuadraturePoint(0.0438473415339 / 2, 0.6685057595169, 0.3089012879389), - QuadraturePoint(0.0439209672733 / 2, 0.0226545012557, 0.6691709943321), - QuadraturePoint(0.0479951923691 / 2, 0.2808515408772, 0.6924718155106), - QuadraturePoint(0.0483806260733 / 2, 0.6922446749051, 0.0268723345026), - QuadraturePoint(0.0484867423375 / 2, 0.0268617447119, 0.2810093973222), - QuadraturePoint(0.0556964488024 / 2, 0.1141778485470, 0.7973581413586), - QuadraturePoint(0.0561026364356 / 2, 0.7974807922061, 0.0879806508791), - QuadraturePoint(0.0565190123693 / 2, 0.0892807293894, 0.1145020561128), - QuadraturePoint(0.0689289890670 / 2, 0.1052487892455, 0.6686904119922), - QuadraturePoint(0.0717213336089 / 2, 0.6663022280740, 0.2275051631832), - QuadraturePoint(0.0727453920976 / 2, 0.2307803737547, 0.1054572561221), - QuadraturePoint(0.0788807336737 / 2, 0.1705059157540, 0.5174064398658), - QuadraturePoint(0.0810114345512 / 2, 0.5086593973043, 0.3170523855209), - QuadraturePoint(0.0825725299055 / 2, 0.3141823862281, 0.1810706361659), - QuadraturePoint(0.0842044567330 / 2, 0.4617460817864, 0.4678594539804), - QuadraturePoint(0.0843585533305 / 2, 0.0693087496081, 0.4622856042085), - QuadraturePoint(0.0851969868488 / 2, 0.4651955259268, 0.0724357805669), - QuadraturePoint(0.0902845328052 / 2, 0.2578625857893, 0.6131395039177), - QuadraturePoint(0.0914283143485 / 2, 0.6112627766779, 0.1300360834609), - QuadraturePoint(0.0916279065409 / 2, 0.1305182135934, 0.2581713828884), - QuadraturePoint(0.1025573374896 / 2, 0.4281437991828, 0.2362005969817), - QuadraturePoint(0.1033159661413 / 2, 0.3356995783730, 0.4311026308588), - QuadraturePoint(0.1035854367193 / 2, 0.2305424298836, 0.3456013949376), + QuadraturePoint(0.0166240998757 / 2, 0.0242935351590, 0.9493059293846), QuadraturePoint(0.0166811699778 / 2, 0.0265193427722, 0.0242695130640), + QuadraturePoint(0.0166830569067 / 2, 0.9492126023551, 0.0265067966437), QuadraturePoint(0.0175680870083 / 2, 0.0033775763749, 0.4767316412363), + QuadraturePoint(0.0184474661845 / 2, 0.4757672298101, 0.5198921829102), QuadraturePoint(0.0197942410188 / 2, 0.5190783193471, 0.0055912706202), + QuadraturePoint(0.0203540395855 / 2, 0.8616839745321, 0.0133996048618), QuadraturePoint(0.0206852863940 / 2, 0.1249209759926, 0.8613054321334), + QuadraturePoint(0.0208271366086 / 2, 0.0138565453861, 0.1247733717358), QuadraturePoint(0.0317819778279 / 2, 0.0211887064222, 0.8438438351223), + QuadraturePoint(0.0320472035241 / 2, 0.8432296787219, 0.1354563645830), QuadraturePoint(0.0320607681146 / 2, 0.1354231797865, 0.0213482820656), + QuadraturePoint(0.0430765959183 / 2, 0.3088853510679, 0.0221919663014), QuadraturePoint(0.0438473415339 / 2, 0.6685057595169, 0.3089012879389), + QuadraturePoint(0.0439209672733 / 2, 0.0226545012557, 0.6691709943321), QuadraturePoint(0.0479951923691 / 2, 0.2808515408772, 0.6924718155106), + QuadraturePoint(0.0483806260733 / 2, 0.6922446749051, 0.0268723345026), QuadraturePoint(0.0484867423375 / 2, 0.0268617447119, 0.2810093973222), + QuadraturePoint(0.0556964488024 / 2, 0.1141778485470, 0.7973581413586), QuadraturePoint(0.0561026364356 / 2, 0.7974807922061, 0.0879806508791), + QuadraturePoint(0.0565190123693 / 2, 0.0892807293894, 0.1145020561128), QuadraturePoint(0.0689289890670 / 2, 0.1052487892455, 0.6686904119922), + QuadraturePoint(0.0717213336089 / 2, 0.6663022280740, 0.2275051631832), QuadraturePoint(0.0727453920976 / 2, 0.2307803737547, 0.1054572561221), + QuadraturePoint(0.0788807336737 / 2, 0.1705059157540, 0.5174064398658), QuadraturePoint(0.0810114345512 / 2, 0.5086593973043, 0.3170523855209), + QuadraturePoint(0.0825725299055 / 2, 0.3141823862281, 0.1810706361659), QuadraturePoint(0.0842044567330 / 2, 0.4617460817864, 0.4678594539804), + QuadraturePoint(0.0843585533305 / 2, 0.0693087496081, 0.4622856042085), QuadraturePoint(0.0851969868488 / 2, 0.4651955259268, 0.0724357805669), + QuadraturePoint(0.0902845328052 / 2, 0.2578625857893, 0.6131395039177), QuadraturePoint(0.0914283143485 / 2, 0.6112627766779, 0.1300360834609), + QuadraturePoint(0.0916279065409 / 2, 0.1305182135934, 0.2581713828884), QuadraturePoint(0.1025573374896 / 2, 0.4281437991828, 0.2362005969817), + QuadraturePoint(0.1033159661413 / 2, 0.3356995783730, 0.4311026308588), QuadraturePoint(0.1035854367193 / 2, 0.2305424298836, 0.3456013949376), }; const QuadratureFormular QuadratureFormular_T_13(13, 36, P_QuadratureFormular_T_13); static QuadraturePoint P_QuadratureFormular_T_14[] = { - QuadraturePoint(0.0010616711990 / 2, 0.0000000000000, 1.0000000000000), - QuadraturePoint(0.0010616711990 / 2, 1.0000000000000, 0.0000000000000), - QuadraturePoint(0.0010616711990 / 2, 0.0000000000000, 0.0000000000000), - QuadraturePoint(0.0131460236101 / 2, 0.0573330873026, 0.0151382269814), - QuadraturePoint(0.0131460236101 / 2, 0.0573330873026, 0.9275286857160), - QuadraturePoint(0.0131460236101 / 2, 0.9275286857160, 0.0573330873026), - QuadraturePoint(0.0131460236101 / 2, 0.0151382269814, 0.0573330873026), - QuadraturePoint(0.0131460236101 / 2, 0.9275286857160, 0.0151382269814), - QuadraturePoint(0.0131460236101 / 2, 0.0151382269814, 0.9275286857160), - QuadraturePoint(0.0242881926949 / 2, 0.8159625040711, 0.1659719969565), - QuadraturePoint(0.0242881926949 / 2, 0.8159625040711, 0.0180654989724), - QuadraturePoint(0.0242881926949 / 2, 0.1659719969565, 0.8159625040711), - QuadraturePoint(0.0242881926949 / 2, 0.0180654989724, 0.8159625040711), - QuadraturePoint(0.0242881926949 / 2, 0.1659719969565, 0.0180654989724), - QuadraturePoint(0.0242881926949 / 2, 0.0180654989724, 0.1659719969565), - QuadraturePoint(0.0316799866332 / 2, 0.3165475556378, 0.0186886898773), - QuadraturePoint(0.0316799866332 / 2, 0.6647637544849, 0.0186886898773), - QuadraturePoint(0.0316799866332 / 2, 0.0186886898773, 0.6647637544849), - QuadraturePoint(0.0316799866332 / 2, 0.0186886898773, 0.3165475556378), - QuadraturePoint(0.0316799866332 / 2, 0.3165475556378, 0.6647637544849), - QuadraturePoint(0.0316799866332 / 2, 0.6647637544849, 0.3165475556378), - QuadraturePoint(0.0349317947036 / 2, 0.0192662192492, 0.4903668903754), - QuadraturePoint(0.0349317947036 / 2, 0.4903668903754, 0.0192662192492), - QuadraturePoint(0.0349317947036 / 2, 0.4903668903754, 0.4903668903754), - QuadraturePoint(0.0383664533945 / 2, 0.0875134669581, 0.8249730660837), - QuadraturePoint(0.0383664533945 / 2, 0.0875134669581, 0.0875134669581), - QuadraturePoint(0.0383664533945 / 2, 0.8249730660837, 0.0875134669581), - QuadraturePoint(0.0578369491210 / 2, 0.0935526036219, 0.2079865423167), - QuadraturePoint(0.0578369491210 / 2, 0.0935526036219, 0.6984608540613), - QuadraturePoint(0.0578369491210 / 2, 0.2079865423167, 0.0935526036219), - QuadraturePoint(0.0578369491210 / 2, 0.6984608540613, 0.0935526036219), - QuadraturePoint(0.0578369491210 / 2, 0.6984608540613, 0.2079865423167), - QuadraturePoint(0.0578369491210 / 2, 0.2079865423167, 0.6984608540613), - QuadraturePoint(0.0725821687394 / 2, 0.0974892983467, 0.5380088595149), - QuadraturePoint(0.0725821687394 / 2, 0.3645018421383, 0.0974892983467), - QuadraturePoint(0.0725821687394 / 2, 0.5380088595149, 0.0974892983467), - QuadraturePoint(0.0725821687394 / 2, 0.5380088595149, 0.3645018421383), - QuadraturePoint(0.0725821687394 / 2, 0.3645018421383, 0.5380088595149), - QuadraturePoint(0.0725821687394 / 2, 0.0974892983467, 0.3645018421383), - QuadraturePoint(0.0897856524107 / 2, 0.2217145894873, 0.5565708210253), - QuadraturePoint(0.0897856524107 / 2, 0.5565708210253, 0.2217145894873), - QuadraturePoint(0.0897856524107 / 2, 0.2217145894873, 0.2217145894873), - QuadraturePoint(0.1034544533617 / 2, 0.3860471669296, 0.2279056661408), - QuadraturePoint(0.1034544533617 / 2, 0.2279056661408, 0.3860471669296), + QuadraturePoint(0.0010616711990 / 2, 0.0000000000000, 1.0000000000000), QuadraturePoint(0.0010616711990 / 2, 1.0000000000000, 0.0000000000000), + QuadraturePoint(0.0010616711990 / 2, 0.0000000000000, 0.0000000000000), QuadraturePoint(0.0131460236101 / 2, 0.0573330873026, 0.0151382269814), + QuadraturePoint(0.0131460236101 / 2, 0.0573330873026, 0.9275286857160), QuadraturePoint(0.0131460236101 / 2, 0.9275286857160, 0.0573330873026), + QuadraturePoint(0.0131460236101 / 2, 0.0151382269814, 0.0573330873026), QuadraturePoint(0.0131460236101 / 2, 0.9275286857160, 0.0151382269814), + QuadraturePoint(0.0131460236101 / 2, 0.0151382269814, 0.9275286857160), QuadraturePoint(0.0242881926949 / 2, 0.8159625040711, 0.1659719969565), + QuadraturePoint(0.0242881926949 / 2, 0.8159625040711, 0.0180654989724), QuadraturePoint(0.0242881926949 / 2, 0.1659719969565, 0.8159625040711), + QuadraturePoint(0.0242881926949 / 2, 0.0180654989724, 0.8159625040711), QuadraturePoint(0.0242881926949 / 2, 0.1659719969565, 0.0180654989724), + QuadraturePoint(0.0242881926949 / 2, 0.0180654989724, 0.1659719969565), QuadraturePoint(0.0316799866332 / 2, 0.3165475556378, 0.0186886898773), + QuadraturePoint(0.0316799866332 / 2, 0.6647637544849, 0.0186886898773), QuadraturePoint(0.0316799866332 / 2, 0.0186886898773, 0.6647637544849), + QuadraturePoint(0.0316799866332 / 2, 0.0186886898773, 0.3165475556378), QuadraturePoint(0.0316799866332 / 2, 0.3165475556378, 0.6647637544849), + QuadraturePoint(0.0316799866332 / 2, 0.6647637544849, 0.3165475556378), QuadraturePoint(0.0349317947036 / 2, 0.0192662192492, 0.4903668903754), + QuadraturePoint(0.0349317947036 / 2, 0.4903668903754, 0.0192662192492), QuadraturePoint(0.0349317947036 / 2, 0.4903668903754, 0.4903668903754), + QuadraturePoint(0.0383664533945 / 2, 0.0875134669581, 0.8249730660837), QuadraturePoint(0.0383664533945 / 2, 0.0875134669581, 0.0875134669581), + QuadraturePoint(0.0383664533945 / 2, 0.8249730660837, 0.0875134669581), QuadraturePoint(0.0578369491210 / 2, 0.0935526036219, 0.2079865423167), + QuadraturePoint(0.0578369491210 / 2, 0.0935526036219, 0.6984608540613), QuadraturePoint(0.0578369491210 / 2, 0.2079865423167, 0.0935526036219), + QuadraturePoint(0.0578369491210 / 2, 0.6984608540613, 0.0935526036219), QuadraturePoint(0.0578369491210 / 2, 0.6984608540613, 0.2079865423167), + QuadraturePoint(0.0578369491210 / 2, 0.2079865423167, 0.6984608540613), QuadraturePoint(0.0725821687394 / 2, 0.0974892983467, 0.5380088595149), + QuadraturePoint(0.0725821687394 / 2, 0.3645018421383, 0.0974892983467), QuadraturePoint(0.0725821687394 / 2, 0.5380088595149, 0.0974892983467), + QuadraturePoint(0.0725821687394 / 2, 0.5380088595149, 0.3645018421383), QuadraturePoint(0.0725821687394 / 2, 0.3645018421383, 0.5380088595149), + QuadraturePoint(0.0725821687394 / 2, 0.0974892983467, 0.3645018421383), QuadraturePoint(0.0897856524107 / 2, 0.2217145894873, 0.5565708210253), + QuadraturePoint(0.0897856524107 / 2, 0.5565708210253, 0.2217145894873), QuadraturePoint(0.0897856524107 / 2, 0.2217145894873, 0.2217145894873), + QuadraturePoint(0.1034544533617 / 2, 0.3860471669296, 0.2279056661408), QuadraturePoint(0.1034544533617 / 2, 0.2279056661408, 0.3860471669296), QuadraturePoint(0.1034544533617 / 2, 0.3860471669296, 0.3860471669296), }; const QuadratureFormular QuadratureFormular_T_14(14, 45, P_QuadratureFormular_T_14); static QuadraturePoint P_QuadratureFormular_T_16[] = { - QuadraturePoint(0.0006202599851 / 2, 1.0000000000000, 0.0000000000000), - QuadraturePoint(0.0006315174712 / 2, 0.0000000000000, 1.0000000000000), - QuadraturePoint(0.0007086601559 / 2, 0.0000000000000, 0.0000000000000), - QuadraturePoint(0.0055163716168 / 2, 0.9398863583577, 0.0049848744634), - QuadraturePoint(0.0062692407656 / 2, 0.0543806683058, 0.9386405618617), - QuadraturePoint(0.0078531408826 / 2, 0.0093940049164, 0.0526424462697), - QuadraturePoint(0.0094551483864 / 2, 0.0164345086362, 0.9469035517351), - QuadraturePoint(0.0097824511271 / 2, 0.9469487269862, 0.0363373677167), - QuadraturePoint(0.0099861643489 / 2, 0.0426604005768, 0.0151224541799), - QuadraturePoint(0.0137553818816 / 2, 0.0122269495439, 0.8693773510664), - QuadraturePoint(0.0140979178040 / 2, 0.8673696521047, 0.1204917285774), - QuadraturePoint(0.0149646864337 / 2, 0.8456744021389, 0.0157763967870), - QuadraturePoint(0.0156097503612 / 2, 0.1395759632103, 0.8448120870375), - QuadraturePoint(0.0157683693348 / 2, 0.1317821743231, 0.0135009605584), - QuadraturePoint(0.0175794546383 / 2, 0.0157955126300, 0.1455274938536), - QuadraturePoint(0.0204113840270 / 2, 0.7365462884436, 0.0155697540908), - QuadraturePoint(0.0209562878616 / 2, 0.0139688430330, 0.7379836894450), - QuadraturePoint(0.0210713412998 / 2, 0.2547895186039, 0.7297615689771), - QuadraturePoint(0.0217646760202 / 2, 0.7316386522555, 0.2543076683315), - QuadraturePoint(0.0222288408699 / 2, 0.0157253728951, 0.2696239795791), - QuadraturePoint(0.0224186693682 / 2, 0.2662302843647, 0.0144783956308), - QuadraturePoint(0.0230122616993 / 2, 0.8673504065214, 0.0591679410400), - QuadraturePoint(0.0236813902500 / 2, 0.0741493666957, 0.8634782575061), - QuadraturePoint(0.0257464643368 / 2, 0.0159285948360, 0.4191238955238), - QuadraturePoint(0.0257956801608 / 2, 0.0156061028068, 0.5809222921146), - QuadraturePoint(0.0258072327610 / 2, 0.5910094817484, 0.0159251452651), - QuadraturePoint(0.0260343232059 / 2, 0.4034771496889, 0.5806700368104), - QuadraturePoint(0.0265768141609 / 2, 0.5694745628526, 0.4149495146302), - QuadraturePoint(0.0265784761831 / 2, 0.0678493700650, 0.0761218678591), - QuadraturePoint(0.0267532329238 / 2, 0.4265968590272, 0.0157509692312), - QuadraturePoint(0.0375787806641 / 2, 0.0670982507890, 0.7741898312421), - QuadraturePoint(0.0383065894195 / 2, 0.7528310231480, 0.0819119495639), - QuadraturePoint(0.0384849695025 / 2, 0.7753727783557, 0.1577128457292), - QuadraturePoint(0.0389619825852 / 2, 0.1689073157787, 0.7503943099742), - QuadraturePoint(0.0394604111547 / 2, 0.1687335832919, 0.0708311507268), - QuadraturePoint(0.0412364778098 / 2, 0.0821244708436, 0.1762996626771), - QuadraturePoint(0.0512872438483 / 2, 0.6288705363345, 0.0807744953317), - QuadraturePoint(0.0516405641935 / 2, 0.0811413015266, 0.3054373589776), - QuadraturePoint(0.0518230042269 / 2, 0.2969112065080, 0.6227485988871), - QuadraturePoint(0.0528527988181 / 2, 0.0767542314171, 0.6247247149546), - QuadraturePoint(0.0538505573027 / 2, 0.6223022333845, 0.3011485821166), - QuadraturePoint(0.0541895329319 / 2, 0.3103786288051, 0.0779098365079), - QuadraturePoint(0.0584737146444 / 2, 0.0819218215187, 0.4603633038351), - QuadraturePoint(0.0592863168363 / 2, 0.4717022665013, 0.0821554006797), - QuadraturePoint(0.0594358276749 / 2, 0.4546603415250, 0.4637565033890), - QuadraturePoint(0.0631800255863 / 2, 0.1701091339237, 0.6422277808188), - QuadraturePoint(0.0632926845153 / 2, 0.6406004329487, 0.1898293537256), - QuadraturePoint(0.0640707361772 / 2, 0.1912267583717, 0.1739955685343), - QuadraturePoint(0.0812040595918 / 2, 0.1885315767070, 0.4798914070406), - QuadraturePoint(0.0814437513530 / 2, 0.4772929957691, 0.3348356598119), - QuadraturePoint(0.0814679201241 / 2, 0.3126974621760, 0.4957972197259), - QuadraturePoint(0.0815050548084 / 2, 0.4961225945946, 0.1927553668904), - QuadraturePoint(0.0815164664939 / 2, 0.1928805312867, 0.3161015807261), - QuadraturePoint(0.0816931059623 / 2, 0.3360041453816, 0.1894892801290), + QuadraturePoint(0.0006202599851 / 2, 1.0000000000000, 0.0000000000000), QuadraturePoint(0.0006315174712 / 2, 0.0000000000000, 1.0000000000000), + QuadraturePoint(0.0007086601559 / 2, 0.0000000000000, 0.0000000000000), QuadraturePoint(0.0055163716168 / 2, 0.9398863583577, 0.0049848744634), + QuadraturePoint(0.0062692407656 / 2, 0.0543806683058, 0.9386405618617), QuadraturePoint(0.0078531408826 / 2, 0.0093940049164, 0.0526424462697), + QuadraturePoint(0.0094551483864 / 2, 0.0164345086362, 0.9469035517351), QuadraturePoint(0.0097824511271 / 2, 0.9469487269862, 0.0363373677167), + QuadraturePoint(0.0099861643489 / 2, 0.0426604005768, 0.0151224541799), QuadraturePoint(0.0137553818816 / 2, 0.0122269495439, 0.8693773510664), + QuadraturePoint(0.0140979178040 / 2, 0.8673696521047, 0.1204917285774), QuadraturePoint(0.0149646864337 / 2, 0.8456744021389, 0.0157763967870), + QuadraturePoint(0.0156097503612 / 2, 0.1395759632103, 0.8448120870375), QuadraturePoint(0.0157683693348 / 2, 0.1317821743231, 0.0135009605584), + QuadraturePoint(0.0175794546383 / 2, 0.0157955126300, 0.1455274938536), QuadraturePoint(0.0204113840270 / 2, 0.7365462884436, 0.0155697540908), + QuadraturePoint(0.0209562878616 / 2, 0.0139688430330, 0.7379836894450), QuadraturePoint(0.0210713412998 / 2, 0.2547895186039, 0.7297615689771), + QuadraturePoint(0.0217646760202 / 2, 0.7316386522555, 0.2543076683315), QuadraturePoint(0.0222288408699 / 2, 0.0157253728951, 0.2696239795791), + QuadraturePoint(0.0224186693682 / 2, 0.2662302843647, 0.0144783956308), QuadraturePoint(0.0230122616993 / 2, 0.8673504065214, 0.0591679410400), + QuadraturePoint(0.0236813902500 / 2, 0.0741493666957, 0.8634782575061), QuadraturePoint(0.0257464643368 / 2, 0.0159285948360, 0.4191238955238), + QuadraturePoint(0.0257956801608 / 2, 0.0156061028068, 0.5809222921146), QuadraturePoint(0.0258072327610 / 2, 0.5910094817484, 0.0159251452651), + QuadraturePoint(0.0260343232059 / 2, 0.4034771496889, 0.5806700368104), QuadraturePoint(0.0265768141609 / 2, 0.5694745628526, 0.4149495146302), + QuadraturePoint(0.0265784761831 / 2, 0.0678493700650, 0.0761218678591), QuadraturePoint(0.0267532329238 / 2, 0.4265968590272, 0.0157509692312), + QuadraturePoint(0.0375787806641 / 2, 0.0670982507890, 0.7741898312421), QuadraturePoint(0.0383065894195 / 2, 0.7528310231480, 0.0819119495639), + QuadraturePoint(0.0384849695025 / 2, 0.7753727783557, 0.1577128457292), QuadraturePoint(0.0389619825852 / 2, 0.1689073157787, 0.7503943099742), + QuadraturePoint(0.0394604111547 / 2, 0.1687335832919, 0.0708311507268), QuadraturePoint(0.0412364778098 / 2, 0.0821244708436, 0.1762996626771), + QuadraturePoint(0.0512872438483 / 2, 0.6288705363345, 0.0807744953317), QuadraturePoint(0.0516405641935 / 2, 0.0811413015266, 0.3054373589776), + QuadraturePoint(0.0518230042269 / 2, 0.2969112065080, 0.6227485988871), QuadraturePoint(0.0528527988181 / 2, 0.0767542314171, 0.6247247149546), + QuadraturePoint(0.0538505573027 / 2, 0.6223022333845, 0.3011485821166), QuadraturePoint(0.0541895329319 / 2, 0.3103786288051, 0.0779098365079), + QuadraturePoint(0.0584737146444 / 2, 0.0819218215187, 0.4603633038351), QuadraturePoint(0.0592863168363 / 2, 0.4717022665013, 0.0821554006797), + QuadraturePoint(0.0594358276749 / 2, 0.4546603415250, 0.4637565033890), QuadraturePoint(0.0631800255863 / 2, 0.1701091339237, 0.6422277808188), + QuadraturePoint(0.0632926845153 / 2, 0.6406004329487, 0.1898293537256), QuadraturePoint(0.0640707361772 / 2, 0.1912267583717, 0.1739955685343), + QuadraturePoint(0.0812040595918 / 2, 0.1885315767070, 0.4798914070406), QuadraturePoint(0.0814437513530 / 2, 0.4772929957691, 0.3348356598119), + QuadraturePoint(0.0814679201241 / 2, 0.3126974621760, 0.4957972197259), QuadraturePoint(0.0815050548084 / 2, 0.4961225945946, 0.1927553668904), + QuadraturePoint(0.0815164664939 / 2, 0.1928805312867, 0.3161015807261), QuadraturePoint(0.0816931059623 / 2, 0.3360041453816, 0.1894892801290), QuadraturePoint(0.0923218334531 / 2, 0.3337280550848, 0.3343571021811), }; const QuadratureFormular QuadratureFormular_T_16(16, 55, P_QuadratureFormular_T_16); static QuadraturePoint P_QuadratureFormular_T_18[] = { - QuadraturePoint(0.0025165756986 / 2, 0.0116731059668, 0.9812565951289), - QuadraturePoint(0.0025273452007 / 2, 0.9810030858388, 0.0071462504863), - QuadraturePoint(0.0033269295333 / 2, 0.0106966317092, 0.0115153933376), - QuadraturePoint(0.0081503492125 / 2, 0.9382476983551, 0.0495570591341), - QuadraturePoint(0.0086135525742 / 2, 0.0126627518417, 0.9370123620615), - QuadraturePoint(0.0087786746179 / 2, 0.0598109409984, 0.0121364578922), - QuadraturePoint(0.0097099585562 / 2, 0.0137363297927, 0.0612783625597), - QuadraturePoint(0.0102466211915 / 2, 0.9229527959405, 0.0141128270602), - QuadraturePoint(0.0108397688341 / 2, 0.0633107354993, 0.9220197291727), - QuadraturePoint(0.0129385390176 / 2, 0.0117265100335, 0.1500520475229), - QuadraturePoint(0.0136339823583 / 2, 0.1554720587323, 0.8325147121589), - QuadraturePoint(0.0138477328147 / 2, 0.8343293888982, 0.0125228158759), - QuadraturePoint(0.0139421540105 / 2, 0.8501638031957, 0.1371997508736), - QuadraturePoint(0.0144121399968 / 2, 0.0128816350522, 0.8477627063479), - QuadraturePoint(0.0153703455534 / 2, 0.1510801608959, 0.0136526924039), - QuadraturePoint(0.0162489802253 / 2, 0.0101917879217, 0.5770438618345), - QuadraturePoint(0.0169718304280 / 2, 0.2813372399303, 0.7066853759623), - QuadraturePoint(0.0170088532421 / 2, 0.7124374628501, 0.0124569780990), - QuadraturePoint(0.0170953520675 / 2, 0.2763025250863, 0.0121741311386), - QuadraturePoint(0.0173888854559 / 2, 0.0109658368561, 0.4194306712466), - QuadraturePoint(0.0174543962439 / 2, 0.4289110517884, 0.5599616067469), - QuadraturePoint(0.0178406757287 / 2, 0.4215420555115, 0.0116475994785), - QuadraturePoint(0.0178446863879 / 2, 0.5711258590444, 0.0118218313989), - QuadraturePoint(0.0179046337552 / 2, 0.5826868270511, 0.4057889581177), - QuadraturePoint(0.0181259756201 / 2, 0.0130567806713, 0.2725023750868), - QuadraturePoint(0.0184784838882 / 2, 0.0130760400964, 0.7224712523233), - QuadraturePoint(0.0185793564371 / 2, 0.7263437062407, 0.2602984019251), - QuadraturePoint(0.0203217151777 / 2, 0.0687230068637, 0.0631417277210), - QuadraturePoint(0.0213771661809 / 2, 0.8652302101529, 0.0720611837338), - QuadraturePoint(0.0231916854098 / 2, 0.0648599071037, 0.8590433543910), - QuadraturePoint(0.0274426710859 / 2, 0.1483494943362, 0.7888788352240), - QuadraturePoint(0.0290301922340 / 2, 0.0624359898396, 0.1493935499354), - QuadraturePoint(0.0294522738505 / 2, 0.7871369011735, 0.0656382042757), - QuadraturePoint(0.0299436251629 / 2, 0.0519104921610, 0.5255635695605), - QuadraturePoint(0.0307026948119 / 2, 0.1543129927444, 0.0716383926917), - QuadraturePoint(0.0325263365863 / 2, 0.2617842745603, 0.0621479485288), - QuadraturePoint(0.0327884208506 / 2, 0.7667257872813, 0.1658211554831), - QuadraturePoint(0.0331234675192 / 2, 0.2582103676627, 0.6800119766139), - QuadraturePoint(0.0346167526875 / 2, 0.0679065925147, 0.7571515437782), - QuadraturePoint(0.0347081373976 / 2, 0.5293578274804, 0.4121503841107), - QuadraturePoint(0.0347372049404 / 2, 0.0666036150484, 0.2612513087886), - QuadraturePoint(0.0348528762454 / 2, 0.0585675461899, 0.3902236114535), - QuadraturePoint(0.0348601561186 / 2, 0.0644535360411, 0.6373626559761), - QuadraturePoint(0.0355471569975 / 2, 0.6748138429151, 0.0637583342061), - QuadraturePoint(0.0360182996383 / 2, 0.3914602310369, 0.5503238090563), - QuadraturePoint(0.0362926285843 / 2, 0.6487701492307, 0.2836728360263), - QuadraturePoint(0.0381897702083 / 2, 0.3946498220408, 0.0605175522554), - QuadraturePoint(0.0392252800118 / 2, 0.5390137151933, 0.0611990176936), - QuadraturePoint(0.0482710125888 / 2, 0.1627895082785, 0.6861322141035), - QuadraturePoint(0.0489912121566 / 2, 0.6812436322641, 0.1567968345899), - QuadraturePoint(0.0497220833872 / 2, 0.1542832878020, 0.1667512624020), - QuadraturePoint(0.0507065736986 / 2, 0.2522727750445, 0.2504803933395), - QuadraturePoint(0.0509771994043 / 2, 0.2547981532407, 0.4994090649043), - QuadraturePoint(0.0521360063667 / 2, 0.1485580549194, 0.5756023096087), - QuadraturePoint(0.0523460874925 / 2, 0.2930239606436, 0.5656897354162), - QuadraturePoint(0.0524440683552 / 2, 0.2808991272310, 0.1437921574248), - QuadraturePoint(0.0527459644823 / 2, 0.4820989592971, 0.2518557535865), - QuadraturePoint(0.0529449063728 / 2, 0.5641878245444, 0.1462966743153), - QuadraturePoint(0.0542395594501 / 2, 0.1307699644344, 0.4489577586117), - QuadraturePoint(0.0543470203419 / 2, 0.1479692221948, 0.3001174386829), - QuadraturePoint(0.0547100548639 / 2, 0.5638684222946, 0.2813772089298), - QuadraturePoint(0.0557288345913 / 2, 0.4361157428790, 0.4252053446420), - QuadraturePoint(0.0577734264233 / 2, 0.3603263935285, 0.2599190004889), - QuadraturePoint(0.0585393781623 / 2, 0.4224188334674, 0.1453238443303), - QuadraturePoint(0.0609039250680 / 2, 0.3719001833052, 0.3780122703567), - QuadraturePoint(0.0637273964449 / 2, 0.2413645006928, 0.3847563284940), + QuadraturePoint(0.0025165756986 / 2, 0.0116731059668, 0.9812565951289), QuadraturePoint(0.0025273452007 / 2, 0.9810030858388, 0.0071462504863), + QuadraturePoint(0.0033269295333 / 2, 0.0106966317092, 0.0115153933376), QuadraturePoint(0.0081503492125 / 2, 0.9382476983551, 0.0495570591341), + QuadraturePoint(0.0086135525742 / 2, 0.0126627518417, 0.9370123620615), QuadraturePoint(0.0087786746179 / 2, 0.0598109409984, 0.0121364578922), + QuadraturePoint(0.0097099585562 / 2, 0.0137363297927, 0.0612783625597), QuadraturePoint(0.0102466211915 / 2, 0.9229527959405, 0.0141128270602), + QuadraturePoint(0.0108397688341 / 2, 0.0633107354993, 0.9220197291727), QuadraturePoint(0.0129385390176 / 2, 0.0117265100335, 0.1500520475229), + QuadraturePoint(0.0136339823583 / 2, 0.1554720587323, 0.8325147121589), QuadraturePoint(0.0138477328147 / 2, 0.8343293888982, 0.0125228158759), + QuadraturePoint(0.0139421540105 / 2, 0.8501638031957, 0.1371997508736), QuadraturePoint(0.0144121399968 / 2, 0.0128816350522, 0.8477627063479), + QuadraturePoint(0.0153703455534 / 2, 0.1510801608959, 0.0136526924039), QuadraturePoint(0.0162489802253 / 2, 0.0101917879217, 0.5770438618345), + QuadraturePoint(0.0169718304280 / 2, 0.2813372399303, 0.7066853759623), QuadraturePoint(0.0170088532421 / 2, 0.7124374628501, 0.0124569780990), + QuadraturePoint(0.0170953520675 / 2, 0.2763025250863, 0.0121741311386), QuadraturePoint(0.0173888854559 / 2, 0.0109658368561, 0.4194306712466), + QuadraturePoint(0.0174543962439 / 2, 0.4289110517884, 0.5599616067469), QuadraturePoint(0.0178406757287 / 2, 0.4215420555115, 0.0116475994785), + QuadraturePoint(0.0178446863879 / 2, 0.5711258590444, 0.0118218313989), QuadraturePoint(0.0179046337552 / 2, 0.5826868270511, 0.4057889581177), + QuadraturePoint(0.0181259756201 / 2, 0.0130567806713, 0.2725023750868), QuadraturePoint(0.0184784838882 / 2, 0.0130760400964, 0.7224712523233), + QuadraturePoint(0.0185793564371 / 2, 0.7263437062407, 0.2602984019251), QuadraturePoint(0.0203217151777 / 2, 0.0687230068637, 0.0631417277210), + QuadraturePoint(0.0213771661809 / 2, 0.8652302101529, 0.0720611837338), QuadraturePoint(0.0231916854098 / 2, 0.0648599071037, 0.8590433543910), + QuadraturePoint(0.0274426710859 / 2, 0.1483494943362, 0.7888788352240), QuadraturePoint(0.0290301922340 / 2, 0.0624359898396, 0.1493935499354), + QuadraturePoint(0.0294522738505 / 2, 0.7871369011735, 0.0656382042757), QuadraturePoint(0.0299436251629 / 2, 0.0519104921610, 0.5255635695605), + QuadraturePoint(0.0307026948119 / 2, 0.1543129927444, 0.0716383926917), QuadraturePoint(0.0325263365863 / 2, 0.2617842745603, 0.0621479485288), + QuadraturePoint(0.0327884208506 / 2, 0.7667257872813, 0.1658211554831), QuadraturePoint(0.0331234675192 / 2, 0.2582103676627, 0.6800119766139), + QuadraturePoint(0.0346167526875 / 2, 0.0679065925147, 0.7571515437782), QuadraturePoint(0.0347081373976 / 2, 0.5293578274804, 0.4121503841107), + QuadraturePoint(0.0347372049404 / 2, 0.0666036150484, 0.2612513087886), QuadraturePoint(0.0348528762454 / 2, 0.0585675461899, 0.3902236114535), + QuadraturePoint(0.0348601561186 / 2, 0.0644535360411, 0.6373626559761), QuadraturePoint(0.0355471569975 / 2, 0.6748138429151, 0.0637583342061), + QuadraturePoint(0.0360182996383 / 2, 0.3914602310369, 0.5503238090563), QuadraturePoint(0.0362926285843 / 2, 0.6487701492307, 0.2836728360263), + QuadraturePoint(0.0381897702083 / 2, 0.3946498220408, 0.0605175522554), QuadraturePoint(0.0392252800118 / 2, 0.5390137151933, 0.0611990176936), + QuadraturePoint(0.0482710125888 / 2, 0.1627895082785, 0.6861322141035), QuadraturePoint(0.0489912121566 / 2, 0.6812436322641, 0.1567968345899), + QuadraturePoint(0.0497220833872 / 2, 0.1542832878020, 0.1667512624020), QuadraturePoint(0.0507065736986 / 2, 0.2522727750445, 0.2504803933395), + QuadraturePoint(0.0509771994043 / 2, 0.2547981532407, 0.4994090649043), QuadraturePoint(0.0521360063667 / 2, 0.1485580549194, 0.5756023096087), + QuadraturePoint(0.0523460874925 / 2, 0.2930239606436, 0.5656897354162), QuadraturePoint(0.0524440683552 / 2, 0.2808991272310, 0.1437921574248), + QuadraturePoint(0.0527459644823 / 2, 0.4820989592971, 0.2518557535865), QuadraturePoint(0.0529449063728 / 2, 0.5641878245444, 0.1462966743153), + QuadraturePoint(0.0542395594501 / 2, 0.1307699644344, 0.4489577586117), QuadraturePoint(0.0543470203419 / 2, 0.1479692221948, 0.3001174386829), + QuadraturePoint(0.0547100548639 / 2, 0.5638684222946, 0.2813772089298), QuadraturePoint(0.0557288345913 / 2, 0.4361157428790, 0.4252053446420), + QuadraturePoint(0.0577734264233 / 2, 0.3603263935285, 0.2599190004889), QuadraturePoint(0.0585393781623 / 2, 0.4224188334674, 0.1453238443303), + QuadraturePoint(0.0609039250680 / 2, 0.3719001833052, 0.3780122703567), QuadraturePoint(0.0637273964449 / 2, 0.2413645006928, 0.3847563284940), }; const QuadratureFormular QuadratureFormular_T_18(18, 66, P_QuadratureFormular_T_18); static QuadraturePoint P_QuadratureFormular_T_20[] = { - QuadraturePoint(0.0021744545399 / 2, 0.0089411337112, 0.0086983293702), - QuadraturePoint(0.0028987135265 / 2, 0.9792622629807, 0.0102644133744), - QuadraturePoint(0.0030846029337 / 2, 0.0105475382112, 0.9785514202515), - QuadraturePoint(0.0034401633104 / 2, 0.0023777061947, 0.0636551098604), - QuadraturePoint(0.0041898472012 / 2, 0.0630425115795, 0.0041506347509), - QuadraturePoint(0.0044738051498 / 2, 0.9308422496730, 0.0048053482263), - QuadraturePoint(0.0047054420814 / 2, 0.0629076555490, 0.9316790069481), - QuadraturePoint(0.0048867935750 / 2, 0.9315962246381, 0.0626264881801), - QuadraturePoint(0.0051927643369 / 2, 0.0061951689415, 0.9293587058564), - QuadraturePoint(0.0074073058981 / 2, 0.0287125819237, 0.0310202122997), - QuadraturePoint(0.0079755410301 / 2, 0.9293844478305, 0.0342152968219), - QuadraturePoint(0.0083550522910 / 2, 0.0375457566621, 0.9257868884669), - QuadraturePoint(0.0096166660864 / 2, 0.0086895739064, 0.1584971251510), - QuadraturePoint(0.0096318257850 / 2, 0.1547597053965, 0.8363606657688), - QuadraturePoint(0.0098577460758 / 2, 0.8331025294185, 0.0089257244824), - QuadraturePoint(0.0102657880301 / 2, 0.8374231073526, 0.1529167304078), - QuadraturePoint(0.0103188103111 / 2, 0.1559362505234, 0.0094966240058), - QuadraturePoint(0.0106291001630 / 2, 0.0098599642095, 0.8342211493596), - QuadraturePoint(0.0106881306895 / 2, 0.4055873733289, 0.0074389302008), - QuadraturePoint(0.0106969021010 / 2, 0.5964727898618, 0.3956330809311), - QuadraturePoint(0.0109026461714 / 2, 0.0080747800416, 0.4031319425903), - QuadraturePoint(0.0109899783575 / 2, 0.0075073977721, 0.5851609594681), - QuadraturePoint(0.0113423055229 / 2, 0.3936764519237, 0.5974896592899), - QuadraturePoint(0.0120535642930 / 2, 0.5846530726212, 0.0087250464968), - QuadraturePoint(0.0139619193821 / 2, 0.4870804112120, 0.0202129229912), - QuadraturePoint(0.0141147991536 / 2, 0.2683512811785, 0.7202340088668), - QuadraturePoint(0.0141930347046 / 2, 0.7223956288748, 0.2662399366456), - QuadraturePoint(0.0144212676268 / 2, 0.2716826742357, 0.0112882698808), - QuadraturePoint(0.0144704346855 / 2, 0.0112580842046, 0.7169695963325), - QuadraturePoint(0.0144949769872 / 2, 0.0115034734370, 0.2740067110166), - QuadraturePoint(0.0145386775694 / 2, 0.7140525900564, 0.0113511560497), - QuadraturePoint(0.0145964190926 / 2, 0.4902871053112, 0.4936491841468), - QuadraturePoint(0.0147314578466 / 2, 0.0201423425209, 0.4832573459601), - QuadraturePoint(0.0167463963304 / 2, 0.0361107464859, 0.0935679501582), - QuadraturePoint(0.0168955500458 / 2, 0.8607998819851, 0.0397379067075), - QuadraturePoint(0.0169422662884 / 2, 0.1005891526001, 0.8586343419352), - QuadraturePoint(0.0173070172095 / 2, 0.0918740717058, 0.0395513001973), - QuadraturePoint(0.0174524546493 / 2, 0.8604888296191, 0.0966224057079), - QuadraturePoint(0.0177217222159 / 2, 0.0439842178673, 0.8561886349107), - QuadraturePoint(0.0282824024023 / 2, 0.2011017606735, 0.7449115835626), - QuadraturePoint(0.0284996712488 / 2, 0.7449993726263, 0.0536865638166), - QuadraturePoint(0.0285005646539 / 2, 0.0532186641310, 0.1963754275935), - QuadraturePoint(0.0300647223478 / 2, 0.7453984647401, 0.1982065805550), - QuadraturePoint(0.0302031277082 / 2, 0.1957289932876, 0.0555713833156), - QuadraturePoint(0.0303987136077 / 2, 0.1092532057988, 0.6100036182413), - QuadraturePoint(0.0305668796074 / 2, 0.0567625702001, 0.7409121894959), - QuadraturePoint(0.0306067413002 / 2, 0.0483837933475, 0.6075135660978), - QuadraturePoint(0.0309330068201 / 2, 0.1080612809760, 0.1122081510437), - QuadraturePoint(0.0309773820835 / 2, 0.6185605900991, 0.2698753703035), - QuadraturePoint(0.0313146250545 / 2, 0.7721296013497, 0.1114117395333), - QuadraturePoint(0.0313573493392 / 2, 0.6115734801133, 0.3389367677931), - QuadraturePoint(0.0314320469287 / 2, 0.3381326103376, 0.0494693938787), - QuadraturePoint(0.0315182143894 / 2, 0.1173084128254, 0.7696451309795), - QuadraturePoint(0.0324248137985 / 2, 0.2674551260596, 0.1115718808154), - QuadraturePoint(0.0347512152386 / 2, 0.6542100160026, 0.1906548314700), - QuadraturePoint(0.0350393454927 / 2, 0.0538297481158, 0.3358616826849), - QuadraturePoint(0.0350717420310 / 2, 0.1848840324117, 0.1551831523851), - QuadraturePoint(0.0352129215334 / 2, 0.3376267104744, 0.6081402596294), - QuadraturePoint(0.0352615504981 / 2, 0.6067102034499, 0.0542632795598), - QuadraturePoint(0.0366403220343 / 2, 0.4612614085496, 0.0688176670722), - QuadraturePoint(0.0367733107670 / 2, 0.1525465365671, 0.6510240845749), - QuadraturePoint(0.0371675662937 / 2, 0.0700582543543, 0.4661904392742), - QuadraturePoint(0.0373371571606 / 2, 0.4704201379032, 0.4634826455353), - QuadraturePoint(0.0403973346588 / 2, 0.1216461693746, 0.2381494875516), - QuadraturePoint(0.0413580040638 / 2, 0.6371404052702, 0.1238399384513), - QuadraturePoint(0.0421957791870 / 2, 0.2379904515119, 0.6370216452326), - QuadraturePoint(0.0495451004037 / 2, 0.1483929857177, 0.4894188577780), - QuadraturePoint(0.0500419261141 / 2, 0.3598069571550, 0.1452880866253), - QuadraturePoint(0.0505794587115 / 2, 0.4941441055095, 0.3610216383818), - QuadraturePoint(0.0520037210188 / 2, 0.1440630687981, 0.3513508341887), - QuadraturePoint(0.0521533567886 / 2, 0.5019764440004, 0.1435491663293), - QuadraturePoint(0.0524899152358 / 2, 0.3555423834298, 0.5016491599502), - QuadraturePoint(0.0599159762516 / 2, 0.2443439540771, 0.2406052129104), - QuadraturePoint(0.0599609997426 / 2, 0.2437064989342, 0.5109017277055), - QuadraturePoint(0.0599915272129 / 2, 0.5122200807321, 0.2452737973543), - QuadraturePoint(0.0634133183449 / 2, 0.2526038315178, 0.3700319555094), - QuadraturePoint(0.0635311861108 / 2, 0.3759895652851, 0.2505406611631), - QuadraturePoint(0.0637206605672 / 2, 0.3729077987144, 0.3753750277549), + QuadraturePoint(0.0021744545399 / 2, 0.0089411337112, 0.0086983293702), QuadraturePoint(0.0028987135265 / 2, 0.9792622629807, 0.0102644133744), + QuadraturePoint(0.0030846029337 / 2, 0.0105475382112, 0.9785514202515), QuadraturePoint(0.0034401633104 / 2, 0.0023777061947, 0.0636551098604), + QuadraturePoint(0.0041898472012 / 2, 0.0630425115795, 0.0041506347509), QuadraturePoint(0.0044738051498 / 2, 0.9308422496730, 0.0048053482263), + QuadraturePoint(0.0047054420814 / 2, 0.0629076555490, 0.9316790069481), QuadraturePoint(0.0048867935750 / 2, 0.9315962246381, 0.0626264881801), + QuadraturePoint(0.0051927643369 / 2, 0.0061951689415, 0.9293587058564), QuadraturePoint(0.0074073058981 / 2, 0.0287125819237, 0.0310202122997), + QuadraturePoint(0.0079755410301 / 2, 0.9293844478305, 0.0342152968219), QuadraturePoint(0.0083550522910 / 2, 0.0375457566621, 0.9257868884669), + QuadraturePoint(0.0096166660864 / 2, 0.0086895739064, 0.1584971251510), QuadraturePoint(0.0096318257850 / 2, 0.1547597053965, 0.8363606657688), + QuadraturePoint(0.0098577460758 / 2, 0.8331025294185, 0.0089257244824), QuadraturePoint(0.0102657880301 / 2, 0.8374231073526, 0.1529167304078), + QuadraturePoint(0.0103188103111 / 2, 0.1559362505234, 0.0094966240058), QuadraturePoint(0.0106291001630 / 2, 0.0098599642095, 0.8342211493596), + QuadraturePoint(0.0106881306895 / 2, 0.4055873733289, 0.0074389302008), QuadraturePoint(0.0106969021010 / 2, 0.5964727898618, 0.3956330809311), + QuadraturePoint(0.0109026461714 / 2, 0.0080747800416, 0.4031319425903), QuadraturePoint(0.0109899783575 / 2, 0.0075073977721, 0.5851609594681), + QuadraturePoint(0.0113423055229 / 2, 0.3936764519237, 0.5974896592899), QuadraturePoint(0.0120535642930 / 2, 0.5846530726212, 0.0087250464968), + QuadraturePoint(0.0139619193821 / 2, 0.4870804112120, 0.0202129229912), QuadraturePoint(0.0141147991536 / 2, 0.2683512811785, 0.7202340088668), + QuadraturePoint(0.0141930347046 / 2, 0.7223956288748, 0.2662399366456), QuadraturePoint(0.0144212676268 / 2, 0.2716826742357, 0.0112882698808), + QuadraturePoint(0.0144704346855 / 2, 0.0112580842046, 0.7169695963325), QuadraturePoint(0.0144949769872 / 2, 0.0115034734370, 0.2740067110166), + QuadraturePoint(0.0145386775694 / 2, 0.7140525900564, 0.0113511560497), QuadraturePoint(0.0145964190926 / 2, 0.4902871053112, 0.4936491841468), + QuadraturePoint(0.0147314578466 / 2, 0.0201423425209, 0.4832573459601), QuadraturePoint(0.0167463963304 / 2, 0.0361107464859, 0.0935679501582), + QuadraturePoint(0.0168955500458 / 2, 0.8607998819851, 0.0397379067075), QuadraturePoint(0.0169422662884 / 2, 0.1005891526001, 0.8586343419352), + QuadraturePoint(0.0173070172095 / 2, 0.0918740717058, 0.0395513001973), QuadraturePoint(0.0174524546493 / 2, 0.8604888296191, 0.0966224057079), + QuadraturePoint(0.0177217222159 / 2, 0.0439842178673, 0.8561886349107), QuadraturePoint(0.0282824024023 / 2, 0.2011017606735, 0.7449115835626), + QuadraturePoint(0.0284996712488 / 2, 0.7449993726263, 0.0536865638166), QuadraturePoint(0.0285005646539 / 2, 0.0532186641310, 0.1963754275935), + QuadraturePoint(0.0300647223478 / 2, 0.7453984647401, 0.1982065805550), QuadraturePoint(0.0302031277082 / 2, 0.1957289932876, 0.0555713833156), + QuadraturePoint(0.0303987136077 / 2, 0.1092532057988, 0.6100036182413), QuadraturePoint(0.0305668796074 / 2, 0.0567625702001, 0.7409121894959), + QuadraturePoint(0.0306067413002 / 2, 0.0483837933475, 0.6075135660978), QuadraturePoint(0.0309330068201 / 2, 0.1080612809760, 0.1122081510437), + QuadraturePoint(0.0309773820835 / 2, 0.6185605900991, 0.2698753703035), QuadraturePoint(0.0313146250545 / 2, 0.7721296013497, 0.1114117395333), + QuadraturePoint(0.0313573493392 / 2, 0.6115734801133, 0.3389367677931), QuadraturePoint(0.0314320469287 / 2, 0.3381326103376, 0.0494693938787), + QuadraturePoint(0.0315182143894 / 2, 0.1173084128254, 0.7696451309795), QuadraturePoint(0.0324248137985 / 2, 0.2674551260596, 0.1115718808154), + QuadraturePoint(0.0347512152386 / 2, 0.6542100160026, 0.1906548314700), QuadraturePoint(0.0350393454927 / 2, 0.0538297481158, 0.3358616826849), + QuadraturePoint(0.0350717420310 / 2, 0.1848840324117, 0.1551831523851), QuadraturePoint(0.0352129215334 / 2, 0.3376267104744, 0.6081402596294), + QuadraturePoint(0.0352615504981 / 2, 0.6067102034499, 0.0542632795598), QuadraturePoint(0.0366403220343 / 2, 0.4612614085496, 0.0688176670722), + QuadraturePoint(0.0367733107670 / 2, 0.1525465365671, 0.6510240845749), QuadraturePoint(0.0371675662937 / 2, 0.0700582543543, 0.4661904392742), + QuadraturePoint(0.0373371571606 / 2, 0.4704201379032, 0.4634826455353), QuadraturePoint(0.0403973346588 / 2, 0.1216461693746, 0.2381494875516), + QuadraturePoint(0.0413580040638 / 2, 0.6371404052702, 0.1238399384513), QuadraturePoint(0.0421957791870 / 2, 0.2379904515119, 0.6370216452326), + QuadraturePoint(0.0495451004037 / 2, 0.1483929857177, 0.4894188577780), QuadraturePoint(0.0500419261141 / 2, 0.3598069571550, 0.1452880866253), + QuadraturePoint(0.0505794587115 / 2, 0.4941441055095, 0.3610216383818), QuadraturePoint(0.0520037210188 / 2, 0.1440630687981, 0.3513508341887), + QuadraturePoint(0.0521533567886 / 2, 0.5019764440004, 0.1435491663293), QuadraturePoint(0.0524899152358 / 2, 0.3555423834298, 0.5016491599502), + QuadraturePoint(0.0599159762516 / 2, 0.2443439540771, 0.2406052129104), QuadraturePoint(0.0599609997426 / 2, 0.2437064989342, 0.5109017277055), + QuadraturePoint(0.0599915272129 / 2, 0.5122200807321, 0.2452737973543), QuadraturePoint(0.0634133183449 / 2, 0.2526038315178, 0.3700319555094), + QuadraturePoint(0.0635311861108 / 2, 0.3759895652851, 0.2505406611631), QuadraturePoint(0.0637206605672 / 2, 0.3729077987144, 0.3753750277549), }; const QuadratureFormular QuadratureFormular_T_20(20, 78, P_QuadratureFormular_T_20); static QuadraturePoint P_QuadratureFormular_T_21[] = { - QuadraturePoint(0.0006704436439 / 2, 0.0035524391922, 0.0035524391922), - QuadraturePoint(0.0006704436439 / 2, 0.0035524391922, 0.9928951216156), - QuadraturePoint(0.0006704436439 / 2, 0.9928951216156, 0.0035524391922), - QuadraturePoint(0.0045472608074 / 2, 0.9553548273730, 0.0087898929093), - QuadraturePoint(0.0045472608074 / 2, 0.0358552797177, 0.0087898929093), - QuadraturePoint(0.0045472608074 / 2, 0.9553548273730, 0.0358552797177), - QuadraturePoint(0.0045472608074 / 2, 0.0087898929093, 0.0358552797177), - QuadraturePoint(0.0045472608074 / 2, 0.0087898929093, 0.9553548273730), - QuadraturePoint(0.0045472608074 / 2, 0.0358552797177, 0.9553548273730), - QuadraturePoint(0.0052077585320 / 2, 0.8865264879047, 0.1082329745017), - QuadraturePoint(0.0052077585320 / 2, 0.8865264879047, 0.0052405375935), - QuadraturePoint(0.0052077585320 / 2, 0.0052405375935, 0.1082329745017), - QuadraturePoint(0.0052077585320 / 2, 0.0052405375935, 0.8865264879047), - QuadraturePoint(0.0052077585320 / 2, 0.1082329745017, 0.8865264879047), - QuadraturePoint(0.0052077585320 / 2, 0.1082329745017, 0.0052405375935), - QuadraturePoint(0.0065435432887 / 2, 0.0466397432150, 0.9067205135700), - QuadraturePoint(0.0065435432887 / 2, 0.0466397432150, 0.0466397432150), - QuadraturePoint(0.0065435432887 / 2, 0.9067205135700, 0.0466397432150), - QuadraturePoint(0.0092737841533 / 2, 0.2075720456946, 0.0082759241284), - QuadraturePoint(0.0092737841533 / 2, 0.2075720456946, 0.7841520301770), - QuadraturePoint(0.0092737841533 / 2, 0.7841520301770, 0.2075720456946), - QuadraturePoint(0.0092737841533 / 2, 0.0082759241284, 0.7841520301770), - QuadraturePoint(0.0092737841533 / 2, 0.0082759241284, 0.2075720456946), - QuadraturePoint(0.0092737841533 / 2, 0.7841520301770, 0.0082759241284), - QuadraturePoint(0.0095937782623 / 2, 0.0858119489725, 0.0314836947701), - QuadraturePoint(0.0095937782623 / 2, 0.8827043562574, 0.0314836947701), - QuadraturePoint(0.0095937782623 / 2, 0.0314836947701, 0.0858119489725), - QuadraturePoint(0.0095937782623 / 2, 0.0858119489725, 0.8827043562574), - QuadraturePoint(0.0095937782623 / 2, 0.8827043562574, 0.0858119489725), - QuadraturePoint(0.0095937782623 / 2, 0.0314836947701, 0.8827043562574), - QuadraturePoint(0.0114247809167 / 2, 0.6688778233826, 0.0095150760625), - QuadraturePoint(0.0114247809167 / 2, 0.0095150760625, 0.3216071005550), - QuadraturePoint(0.0114247809167 / 2, 0.0095150760625, 0.6688778233826), - QuadraturePoint(0.0114247809167 / 2, 0.6688778233826, 0.3216071005550), - QuadraturePoint(0.0114247809167 / 2, 0.3216071005550, 0.6688778233826), - QuadraturePoint(0.0114247809167 / 2, 0.3216071005550, 0.0095150760625), - QuadraturePoint(0.0117216964174 / 2, 0.4379999543113, 0.0099859785681), - QuadraturePoint(0.0117216964174 / 2, 0.0099859785681, 0.5520140671206), - QuadraturePoint(0.0117216964174 / 2, 0.4379999543113, 0.5520140671206), - QuadraturePoint(0.0117216964174 / 2, 0.0099859785681, 0.4379999543113), - QuadraturePoint(0.0117216964174 / 2, 0.5520140671206, 0.4379999543113), - QuadraturePoint(0.0117216964174 / 2, 0.5520140671206, 0.0099859785681), - QuadraturePoint(0.0188197155232 / 2, 0.7974931072148, 0.0405093994119), - QuadraturePoint(0.0188197155232 / 2, 0.0405093994119, 0.1619974933734), - QuadraturePoint(0.0188197155232 / 2, 0.0405093994119, 0.7974931072148), - QuadraturePoint(0.0188197155232 / 2, 0.1619974933734, 0.7974931072148), - QuadraturePoint(0.0188197155232 / 2, 0.7974931072148, 0.1619974933734), - QuadraturePoint(0.0188197155232 / 2, 0.1619974933734, 0.0405093994119), - QuadraturePoint(0.0235260980271 / 2, 0.3864215551955, 0.3864215551955), - QuadraturePoint(0.0235260980271 / 2, 0.3864215551955, 0.2271568896090), - QuadraturePoint(0.0235260980271 / 2, 0.2271568896090, 0.3864215551955), - QuadraturePoint(0.0235571466151 / 2, 0.8090129379329, 0.0954935310336), - QuadraturePoint(0.0235571466151 / 2, 0.0954935310336, 0.8090129379329), - QuadraturePoint(0.0235571466151 / 2, 0.0954935310336, 0.0954935310336), - QuadraturePoint(0.0268246207430 / 2, 0.2745425238718, 0.0479840480721), - QuadraturePoint(0.0268246207430 / 2, 0.0479840480721, 0.6774734280561), - QuadraturePoint(0.0268246207430 / 2, 0.6774734280561, 0.0479840480721), - QuadraturePoint(0.0268246207430 / 2, 0.6774734280561, 0.2745425238718), - QuadraturePoint(0.0268246207430 / 2, 0.2745425238718, 0.6774734280561), - QuadraturePoint(0.0268246207430 / 2, 0.0479840480721, 0.2745425238718), - QuadraturePoint(0.0314289776779 / 2, 0.4053472446667, 0.5429849622344), - QuadraturePoint(0.0314289776779 / 2, 0.0516677930989, 0.4053472446667), - QuadraturePoint(0.0314289776779 / 2, 0.4053472446667, 0.0516677930989), - QuadraturePoint(0.0314289776779 / 2, 0.5429849622344, 0.0516677930989), - QuadraturePoint(0.0314289776779 / 2, 0.0516677930989, 0.5429849622344), - QuadraturePoint(0.0314289776779 / 2, 0.5429849622344, 0.4053472446667), - QuadraturePoint(0.0337196192159 / 2, 0.1877738615539, 0.1068148267588), - QuadraturePoint(0.0337196192159 / 2, 0.7054113116872, 0.1877738615539), - QuadraturePoint(0.0337196192159 / 2, 0.7054113116872, 0.1068148267588), - QuadraturePoint(0.0337196192159 / 2, 0.1068148267588, 0.7054113116872), - QuadraturePoint(0.0337196192159 / 2, 0.1877738615539, 0.7054113116872), - QuadraturePoint(0.0337196192159 / 2, 0.1068148267588, 0.1877738615539), - QuadraturePoint(0.0427745294213 / 2, 0.1195059712009, 0.3057122990643), - QuadraturePoint(0.0427745294213 / 2, 0.1195059712009, 0.5747817297348), - QuadraturePoint(0.0427745294213 / 2, 0.5747817297348, 0.1195059712009), - QuadraturePoint(0.0427745294213 / 2, 0.5747817297348, 0.3057122990643), - QuadraturePoint(0.0427745294213 / 2, 0.3057122990643, 0.5747817297348), - QuadraturePoint(0.0427745294213 / 2, 0.3057122990643, 0.1195059712009), - QuadraturePoint(0.0441138932737 / 2, 0.5981245743363, 0.2009377128319), - QuadraturePoint(0.0441138932737 / 2, 0.2009377128319, 0.5981245743363), - QuadraturePoint(0.0441138932737 / 2, 0.2009377128319, 0.2009377128319), - QuadraturePoint(0.0461469594684 / 2, 0.2160775200005, 0.3121360256673), - QuadraturePoint(0.0461469594684 / 2, 0.3121360256673, 0.2160775200005), - QuadraturePoint(0.0461469594684 / 2, 0.2160775200005, 0.4717864543321), - QuadraturePoint(0.0461469594684 / 2, 0.3121360256673, 0.4717864543321), - QuadraturePoint(0.0461469594684 / 2, 0.4717864543321, 0.3121360256673), - QuadraturePoint(0.0461469594684 / 2, 0.4717864543321, 0.2160775200005), - QuadraturePoint(0.0469152468624 / 2, 0.4376579903849, 0.4376579903849), - QuadraturePoint(0.0469152468624 / 2, 0.4376579903849, 0.1246840192303), - QuadraturePoint(0.0469152468624 / 2, 0.1246840192303, 0.4376579903849), + QuadraturePoint(0.0006704436439 / 2, 0.0035524391922, 0.0035524391922), QuadraturePoint(0.0006704436439 / 2, 0.0035524391922, 0.9928951216156), + QuadraturePoint(0.0006704436439 / 2, 0.9928951216156, 0.0035524391922), QuadraturePoint(0.0045472608074 / 2, 0.9553548273730, 0.0087898929093), + QuadraturePoint(0.0045472608074 / 2, 0.0358552797177, 0.0087898929093), QuadraturePoint(0.0045472608074 / 2, 0.9553548273730, 0.0358552797177), + QuadraturePoint(0.0045472608074 / 2, 0.0087898929093, 0.0358552797177), QuadraturePoint(0.0045472608074 / 2, 0.0087898929093, 0.9553548273730), + QuadraturePoint(0.0045472608074 / 2, 0.0358552797177, 0.9553548273730), QuadraturePoint(0.0052077585320 / 2, 0.8865264879047, 0.1082329745017), + QuadraturePoint(0.0052077585320 / 2, 0.8865264879047, 0.0052405375935), QuadraturePoint(0.0052077585320 / 2, 0.0052405375935, 0.1082329745017), + QuadraturePoint(0.0052077585320 / 2, 0.0052405375935, 0.8865264879047), QuadraturePoint(0.0052077585320 / 2, 0.1082329745017, 0.8865264879047), + QuadraturePoint(0.0052077585320 / 2, 0.1082329745017, 0.0052405375935), QuadraturePoint(0.0065435432887 / 2, 0.0466397432150, 0.9067205135700), + QuadraturePoint(0.0065435432887 / 2, 0.0466397432150, 0.0466397432150), QuadraturePoint(0.0065435432887 / 2, 0.9067205135700, 0.0466397432150), + QuadraturePoint(0.0092737841533 / 2, 0.2075720456946, 0.0082759241284), QuadraturePoint(0.0092737841533 / 2, 0.2075720456946, 0.7841520301770), + QuadraturePoint(0.0092737841533 / 2, 0.7841520301770, 0.2075720456946), QuadraturePoint(0.0092737841533 / 2, 0.0082759241284, 0.7841520301770), + QuadraturePoint(0.0092737841533 / 2, 0.0082759241284, 0.2075720456946), QuadraturePoint(0.0092737841533 / 2, 0.7841520301770, 0.0082759241284), + QuadraturePoint(0.0095937782623 / 2, 0.0858119489725, 0.0314836947701), QuadraturePoint(0.0095937782623 / 2, 0.8827043562574, 0.0314836947701), + QuadraturePoint(0.0095937782623 / 2, 0.0314836947701, 0.0858119489725), QuadraturePoint(0.0095937782623 / 2, 0.0858119489725, 0.8827043562574), + QuadraturePoint(0.0095937782623 / 2, 0.8827043562574, 0.0858119489725), QuadraturePoint(0.0095937782623 / 2, 0.0314836947701, 0.8827043562574), + QuadraturePoint(0.0114247809167 / 2, 0.6688778233826, 0.0095150760625), QuadraturePoint(0.0114247809167 / 2, 0.0095150760625, 0.3216071005550), + QuadraturePoint(0.0114247809167 / 2, 0.0095150760625, 0.6688778233826), QuadraturePoint(0.0114247809167 / 2, 0.6688778233826, 0.3216071005550), + QuadraturePoint(0.0114247809167 / 2, 0.3216071005550, 0.6688778233826), QuadraturePoint(0.0114247809167 / 2, 0.3216071005550, 0.0095150760625), + QuadraturePoint(0.0117216964174 / 2, 0.4379999543113, 0.0099859785681), QuadraturePoint(0.0117216964174 / 2, 0.0099859785681, 0.5520140671206), + QuadraturePoint(0.0117216964174 / 2, 0.4379999543113, 0.5520140671206), QuadraturePoint(0.0117216964174 / 2, 0.0099859785681, 0.4379999543113), + QuadraturePoint(0.0117216964174 / 2, 0.5520140671206, 0.4379999543113), QuadraturePoint(0.0117216964174 / 2, 0.5520140671206, 0.0099859785681), + QuadraturePoint(0.0188197155232 / 2, 0.7974931072148, 0.0405093994119), QuadraturePoint(0.0188197155232 / 2, 0.0405093994119, 0.1619974933734), + QuadraturePoint(0.0188197155232 / 2, 0.0405093994119, 0.7974931072148), QuadraturePoint(0.0188197155232 / 2, 0.1619974933734, 0.7974931072148), + QuadraturePoint(0.0188197155232 / 2, 0.7974931072148, 0.1619974933734), QuadraturePoint(0.0188197155232 / 2, 0.1619974933734, 0.0405093994119), + QuadraturePoint(0.0235260980271 / 2, 0.3864215551955, 0.3864215551955), QuadraturePoint(0.0235260980271 / 2, 0.3864215551955, 0.2271568896090), + QuadraturePoint(0.0235260980271 / 2, 0.2271568896090, 0.3864215551955), QuadraturePoint(0.0235571466151 / 2, 0.8090129379329, 0.0954935310336), + QuadraturePoint(0.0235571466151 / 2, 0.0954935310336, 0.8090129379329), QuadraturePoint(0.0235571466151 / 2, 0.0954935310336, 0.0954935310336), + QuadraturePoint(0.0268246207430 / 2, 0.2745425238718, 0.0479840480721), QuadraturePoint(0.0268246207430 / 2, 0.0479840480721, 0.6774734280561), + QuadraturePoint(0.0268246207430 / 2, 0.6774734280561, 0.0479840480721), QuadraturePoint(0.0268246207430 / 2, 0.6774734280561, 0.2745425238718), + QuadraturePoint(0.0268246207430 / 2, 0.2745425238718, 0.6774734280561), QuadraturePoint(0.0268246207430 / 2, 0.0479840480721, 0.2745425238718), + QuadraturePoint(0.0314289776779 / 2, 0.4053472446667, 0.5429849622344), QuadraturePoint(0.0314289776779 / 2, 0.0516677930989, 0.4053472446667), + QuadraturePoint(0.0314289776779 / 2, 0.4053472446667, 0.0516677930989), QuadraturePoint(0.0314289776779 / 2, 0.5429849622344, 0.0516677930989), + QuadraturePoint(0.0314289776779 / 2, 0.0516677930989, 0.5429849622344), QuadraturePoint(0.0314289776779 / 2, 0.5429849622344, 0.4053472446667), + QuadraturePoint(0.0337196192159 / 2, 0.1877738615539, 0.1068148267588), QuadraturePoint(0.0337196192159 / 2, 0.7054113116872, 0.1877738615539), + QuadraturePoint(0.0337196192159 / 2, 0.7054113116872, 0.1068148267588), QuadraturePoint(0.0337196192159 / 2, 0.1068148267588, 0.7054113116872), + QuadraturePoint(0.0337196192159 / 2, 0.1877738615539, 0.7054113116872), QuadraturePoint(0.0337196192159 / 2, 0.1068148267588, 0.1877738615539), + QuadraturePoint(0.0427745294213 / 2, 0.1195059712009, 0.3057122990643), QuadraturePoint(0.0427745294213 / 2, 0.1195059712009, 0.5747817297348), + QuadraturePoint(0.0427745294213 / 2, 0.5747817297348, 0.1195059712009), QuadraturePoint(0.0427745294213 / 2, 0.5747817297348, 0.3057122990643), + QuadraturePoint(0.0427745294213 / 2, 0.3057122990643, 0.5747817297348), QuadraturePoint(0.0427745294213 / 2, 0.3057122990643, 0.1195059712009), + QuadraturePoint(0.0441138932737 / 2, 0.5981245743363, 0.2009377128319), QuadraturePoint(0.0441138932737 / 2, 0.2009377128319, 0.5981245743363), + QuadraturePoint(0.0441138932737 / 2, 0.2009377128319, 0.2009377128319), QuadraturePoint(0.0461469594684 / 2, 0.2160775200005, 0.3121360256673), + QuadraturePoint(0.0461469594684 / 2, 0.3121360256673, 0.2160775200005), QuadraturePoint(0.0461469594684 / 2, 0.2160775200005, 0.4717864543321), + QuadraturePoint(0.0461469594684 / 2, 0.3121360256673, 0.4717864543321), QuadraturePoint(0.0461469594684 / 2, 0.4717864543321, 0.3121360256673), + QuadraturePoint(0.0461469594684 / 2, 0.4717864543321, 0.2160775200005), QuadraturePoint(0.0469152468624 / 2, 0.4376579903849, 0.4376579903849), + QuadraturePoint(0.0469152468624 / 2, 0.4376579903849, 0.1246840192303), QuadraturePoint(0.0469152468624 / 2, 0.1246840192303, 0.4376579903849), QuadraturePoint(0.0551199980347 / 2, 0.3333333333333, 0.3333333333333), }; const QuadratureFormular QuadratureFormular_T_21(21, 91, P_QuadratureFormular_T_21); static QuadraturePoint P_QuadratureFormular_T_23[] = { - QuadraturePoint(0.0006438298261 / 2, 0.0087809303836, 0.9903676436772), - QuadraturePoint(0.0006438413076 / 2, 0.9903675314220, 0.0087809216232), - QuadraturePoint(0.0010134735710 / 2, 0.0027029276450, 0.0335914404439), - QuadraturePoint(0.0010134752576 / 2, 0.0335909214524, 0.0027028946710), - QuadraturePoint(0.0019679929935 / 2, 0.0091675068606, 0.0091676353051), - QuadraturePoint(0.0033467313784 / 2, 0.9675568182558, 0.0084737176656), - QuadraturePoint(0.0033467339208 / 2, 0.0084737200688, 0.9675569435345), - QuadraturePoint(0.0042873323375 / 2, 0.0078781948792, 0.0676784943862), - QuadraturePoint(0.0042873459885 / 2, 0.0676785477700, 0.0078781659291), - QuadraturePoint(0.0043003801372 / 2, 0.9470266955047, 0.0442974541187), - QuadraturePoint(0.0043003849098 / 2, 0.0442974755680, 0.9470266676487), - QuadraturePoint(0.0056934629205 / 2, 0.9144243214882, 0.0081735455132), - QuadraturePoint(0.0056934640134 / 2, 0.0081735424459, 0.9144244234031), - QuadraturePoint(0.0061643868015 / 2, 0.2497452292741, 0.3833232434720), - QuadraturePoint(0.0061644756418 / 2, 0.3833232646055, 0.2497451268005), - QuadraturePoint(0.0062014513591 / 2, 0.8876850353557, 0.1035328809446), - QuadraturePoint(0.0062014531952 / 2, 0.1035329228297, 0.8876849931840), - QuadraturePoint(0.0069636330294 / 2, 0.0077255923618, 0.1403190991974), - QuadraturePoint(0.0069636331842 / 2, 0.1403192425107, 0.0077255934624), - QuadraturePoint(0.0075066257720 / 2, 0.8104591009652, 0.1809642523926), - QuadraturePoint(0.0075066264565 / 2, 0.1809643003717, 0.8104590515334), - QuadraturePoint(0.0079074768339 / 2, 0.8330767948684, 0.0083010939677), - QuadraturePoint(0.0079074772485 / 2, 0.0083010907126, 0.8330768545392), - QuadraturePoint(0.0080353344623 / 2, 0.0348407706147, 0.0348406969482), - QuadraturePoint(0.0087963441074 / 2, 0.2740287679608, 0.7173981847948), - QuadraturePoint(0.0087963448112 / 2, 0.7173982224778, 0.2740287304386), - QuadraturePoint(0.0091304195716 / 2, 0.2394976858234, 0.0081859182262), - QuadraturePoint(0.0091304213611 / 2, 0.0081859185845, 0.2394975566677), - QuadraturePoint(0.0092821748751 / 2, 0.0068836152075, 0.4843740892687), - QuadraturePoint(0.0092821815662 / 2, 0.4843741485699, 0.0068836232949), - QuadraturePoint(0.0094499806178 / 2, 0.4960767772741, 0.4960767529507), - QuadraturePoint(0.0094627468484 / 2, 0.6112936776245, 0.3804323691239), - QuadraturePoint(0.0094627485294 / 2, 0.3804323980345, 0.6112936466533), - QuadraturePoint(0.0095555772285 / 2, 0.7303890713524, 0.0083987179701), - QuadraturePoint(0.0095555792843 / 2, 0.0083987168639, 0.7303890895407), - QuadraturePoint(0.0096138842488 / 2, 0.6128525675612, 0.0075475979695), - QuadraturePoint(0.0096138846826 / 2, 0.0075475961037, 0.6128525484582), - QuadraturePoint(0.0099991524212 / 2, 0.0079525316513, 0.3559773826721), - QuadraturePoint(0.0099991551850 / 2, 0.3559774870460, 0.0079525358502), - QuadraturePoint(0.0100301319277 / 2, 0.9110236977966, 0.0437233665345), - QuadraturePoint(0.0100301346636 / 2, 0.0437233605166, 0.9110236807446), - QuadraturePoint(0.0124936676185 / 2, 0.0388480061835, 0.0967030908282), - QuadraturePoint(0.0124936726125 / 2, 0.0967032117936, 0.0388479942386), - QuadraturePoint(0.0140197309137 / 2, 0.0873226911312, 0.0873226620391), - QuadraturePoint(0.0143336216896 / 2, 0.0421445202084, 0.8485617789108), - QuadraturePoint(0.0143336272125 / 2, 0.8485617974961, 0.0421445420915), - QuadraturePoint(0.0153604142740 / 2, 0.8477921333864, 0.1067435942472), - QuadraturePoint(0.0153604183425 / 2, 0.1067435889398, 0.8477921328146), - QuadraturePoint(0.0184523825614 / 2, 0.1833966521991, 0.0416340521608), - QuadraturePoint(0.0184523863146 / 2, 0.0416340541167, 0.1833965196930), - QuadraturePoint(0.0195833983573 / 2, 0.7611632251560, 0.1941599202852), - QuadraturePoint(0.0195834019994 / 2, 0.1941599254144, 0.7611632153938), - QuadraturePoint(0.0197632751342 / 2, 0.7579378747173, 0.0439826608586), - QuadraturePoint(0.0197632766677 / 2, 0.0439826512395, 0.7579378242308), - QuadraturePoint(0.0198806391019 / 2, 0.0369760535918, 0.5363186076436), - QuadraturePoint(0.0198806485776 / 2, 0.5363187134342, 0.0369760780935), - QuadraturePoint(0.0207181838484 / 2, 0.1001256948921, 0.7912267093545), - QuadraturePoint(0.0207181934893 / 2, 0.7912266693524, 0.1001257554673), - QuadraturePoint(0.0208943071440 / 2, 0.0379866714177, 0.4157413128558), - QuadraturePoint(0.0208943251956 / 2, 0.4157414028965, 0.0379867061535), - QuadraturePoint(0.0214864573885 / 2, 0.6507106491463, 0.0420141226713), - QuadraturePoint(0.0214864586007 / 2, 0.0420141133438, 0.6507105645084), - QuadraturePoint(0.0222218133036 / 2, 0.0425548444254, 0.2920626023484), - QuadraturePoint(0.0222218160203 / 2, 0.2920627107240, 0.0425548546753), - QuadraturePoint(0.0223345305455 / 2, 0.5389729538180, 0.4193031469005), - QuadraturePoint(0.0223345378739 / 2, 0.4193031828489, 0.5389729093610), - QuadraturePoint(0.0224758924946 / 2, 0.6549472009700, 0.3007352636162), - QuadraturePoint(0.0224758980440 / 2, 0.3007352790917, 0.6549471812731), - QuadraturePoint(0.0229701395845 / 2, 0.3752400771585, 0.3453980130752), - QuadraturePoint(0.0229703394438 / 2, 0.3453980282786, 0.3752400695673), - QuadraturePoint(0.0232798376102 / 2, 0.0994532168761, 0.1598308695187), - QuadraturePoint(0.0232798427506 / 2, 0.1598309359585, 0.0994531960132), - QuadraturePoint(0.0269483199647 / 2, 0.1797326661667, 0.7124585430924), - QuadraturePoint(0.0269483307107 / 2, 0.7124584461943, 0.1797327722240), - QuadraturePoint(0.0280438758010 / 2, 0.1066065678636, 0.7001701784175), - QuadraturePoint(0.0280438764607 / 2, 0.7001701904096, 0.1066065855677), - QuadraturePoint(0.0287526270172 / 2, 0.0993303629801, 0.6065647984796), - QuadraturePoint(0.0287526387271 / 2, 0.6065648052521, 0.0993303896769), - QuadraturePoint(0.0298980829063 / 2, 0.1023223542704, 0.2533381579528), - QuadraturePoint(0.0298980922759 / 2, 0.2533382324938, 0.1023223826189), - QuadraturePoint(0.0309004358516 / 2, 0.6166226715217, 0.2769502060575), - QuadraturePoint(0.0309004385956 / 2, 0.2769500693109, 0.6166227900624), - QuadraturePoint(0.0314031017088 / 2, 0.0904184571873, 0.4981522637001), - QuadraturePoint(0.0314031073955 / 2, 0.4981522767248, 0.0904185045149), - QuadraturePoint(0.0319191553024 / 2, 0.0928231860168, 0.3738418516908), - QuadraturePoint(0.0319191668378 / 2, 0.3738418699229, 0.0928232584790), - QuadraturePoint(0.0321429924062 / 2, 0.2521678840407, 0.2521680925697), - QuadraturePoint(0.0330395601388 / 2, 0.5087500218708, 0.3905580544330), - QuadraturePoint(0.0330395631829 / 2, 0.3905579116731, 0.5087501437661), - QuadraturePoint(0.0356169095589 / 2, 0.1706141469096, 0.5266738039554), - QuadraturePoint(0.0356169276054 / 2, 0.5266737761312, 0.1706142257537), - QuadraturePoint(0.0365741189998 / 2, 0.3487581527629, 0.2588055084886), - QuadraturePoint(0.0365741515204 / 2, 0.2588053596017, 0.3487583491703), - QuadraturePoint(0.0365977646990 / 2, 0.1696614558053, 0.3013522183964), - QuadraturePoint(0.0365978053889 / 2, 0.3013521806875, 0.1696615963219), - QuadraturePoint(0.0369945680114 / 2, 0.2580202409759, 0.4584741774478), - QuadraturePoint(0.0369945775059 / 2, 0.4584740860198, 0.2580203819011), - QuadraturePoint(0.0374053623787 / 2, 0.1848898683498, 0.1848898704551), - QuadraturePoint(0.0375550258317 / 2, 0.6130740338465, 0.1921611994069), - QuadraturePoint(0.0375550312530 / 2, 0.1921611750994, 0.6130740398389), - QuadraturePoint(0.0388887693486 / 2, 0.4180541160599, 0.1650613336416), - QuadraturePoint(0.0388887708342 / 2, 0.1650612642036, 0.4180541199244), - QuadraturePoint(0.0392705643548 / 2, 0.5159205739625, 0.2982719005229), - QuadraturePoint(0.0392705802517 / 2, 0.2982718935750, 0.5159205534362), + QuadraturePoint(0.0006438298261 / 2, 0.0087809303836, 0.9903676436772), QuadraturePoint(0.0006438413076 / 2, 0.9903675314220, 0.0087809216232), + QuadraturePoint(0.0010134735710 / 2, 0.0027029276450, 0.0335914404439), QuadraturePoint(0.0010134752576 / 2, 0.0335909214524, 0.0027028946710), + QuadraturePoint(0.0019679929935 / 2, 0.0091675068606, 0.0091676353051), QuadraturePoint(0.0033467313784 / 2, 0.9675568182558, 0.0084737176656), + QuadraturePoint(0.0033467339208 / 2, 0.0084737200688, 0.9675569435345), QuadraturePoint(0.0042873323375 / 2, 0.0078781948792, 0.0676784943862), + QuadraturePoint(0.0042873459885 / 2, 0.0676785477700, 0.0078781659291), QuadraturePoint(0.0043003801372 / 2, 0.9470266955047, 0.0442974541187), + QuadraturePoint(0.0043003849098 / 2, 0.0442974755680, 0.9470266676487), QuadraturePoint(0.0056934629205 / 2, 0.9144243214882, 0.0081735455132), + QuadraturePoint(0.0056934640134 / 2, 0.0081735424459, 0.9144244234031), QuadraturePoint(0.0061643868015 / 2, 0.2497452292741, 0.3833232434720), + QuadraturePoint(0.0061644756418 / 2, 0.3833232646055, 0.2497451268005), QuadraturePoint(0.0062014513591 / 2, 0.8876850353557, 0.1035328809446), + QuadraturePoint(0.0062014531952 / 2, 0.1035329228297, 0.8876849931840), QuadraturePoint(0.0069636330294 / 2, 0.0077255923618, 0.1403190991974), + QuadraturePoint(0.0069636331842 / 2, 0.1403192425107, 0.0077255934624), QuadraturePoint(0.0075066257720 / 2, 0.8104591009652, 0.1809642523926), + QuadraturePoint(0.0075066264565 / 2, 0.1809643003717, 0.8104590515334), QuadraturePoint(0.0079074768339 / 2, 0.8330767948684, 0.0083010939677), + QuadraturePoint(0.0079074772485 / 2, 0.0083010907126, 0.8330768545392), QuadraturePoint(0.0080353344623 / 2, 0.0348407706147, 0.0348406969482), + QuadraturePoint(0.0087963441074 / 2, 0.2740287679608, 0.7173981847948), QuadraturePoint(0.0087963448112 / 2, 0.7173982224778, 0.2740287304386), + QuadraturePoint(0.0091304195716 / 2, 0.2394976858234, 0.0081859182262), QuadraturePoint(0.0091304213611 / 2, 0.0081859185845, 0.2394975566677), + QuadraturePoint(0.0092821748751 / 2, 0.0068836152075, 0.4843740892687), QuadraturePoint(0.0092821815662 / 2, 0.4843741485699, 0.0068836232949), + QuadraturePoint(0.0094499806178 / 2, 0.4960767772741, 0.4960767529507), QuadraturePoint(0.0094627468484 / 2, 0.6112936776245, 0.3804323691239), + QuadraturePoint(0.0094627485294 / 2, 0.3804323980345, 0.6112936466533), QuadraturePoint(0.0095555772285 / 2, 0.7303890713524, 0.0083987179701), + QuadraturePoint(0.0095555792843 / 2, 0.0083987168639, 0.7303890895407), QuadraturePoint(0.0096138842488 / 2, 0.6128525675612, 0.0075475979695), + QuadraturePoint(0.0096138846826 / 2, 0.0075475961037, 0.6128525484582), QuadraturePoint(0.0099991524212 / 2, 0.0079525316513, 0.3559773826721), + QuadraturePoint(0.0099991551850 / 2, 0.3559774870460, 0.0079525358502), QuadraturePoint(0.0100301319277 / 2, 0.9110236977966, 0.0437233665345), + QuadraturePoint(0.0100301346636 / 2, 0.0437233605166, 0.9110236807446), QuadraturePoint(0.0124936676185 / 2, 0.0388480061835, 0.0967030908282), + QuadraturePoint(0.0124936726125 / 2, 0.0967032117936, 0.0388479942386), QuadraturePoint(0.0140197309137 / 2, 0.0873226911312, 0.0873226620391), + QuadraturePoint(0.0143336216896 / 2, 0.0421445202084, 0.8485617789108), QuadraturePoint(0.0143336272125 / 2, 0.8485617974961, 0.0421445420915), + QuadraturePoint(0.0153604142740 / 2, 0.8477921333864, 0.1067435942472), QuadraturePoint(0.0153604183425 / 2, 0.1067435889398, 0.8477921328146), + QuadraturePoint(0.0184523825614 / 2, 0.1833966521991, 0.0416340521608), QuadraturePoint(0.0184523863146 / 2, 0.0416340541167, 0.1833965196930), + QuadraturePoint(0.0195833983573 / 2, 0.7611632251560, 0.1941599202852), QuadraturePoint(0.0195834019994 / 2, 0.1941599254144, 0.7611632153938), + QuadraturePoint(0.0197632751342 / 2, 0.7579378747173, 0.0439826608586), QuadraturePoint(0.0197632766677 / 2, 0.0439826512395, 0.7579378242308), + QuadraturePoint(0.0198806391019 / 2, 0.0369760535918, 0.5363186076436), QuadraturePoint(0.0198806485776 / 2, 0.5363187134342, 0.0369760780935), + QuadraturePoint(0.0207181838484 / 2, 0.1001256948921, 0.7912267093545), QuadraturePoint(0.0207181934893 / 2, 0.7912266693524, 0.1001257554673), + QuadraturePoint(0.0208943071440 / 2, 0.0379866714177, 0.4157413128558), QuadraturePoint(0.0208943251956 / 2, 0.4157414028965, 0.0379867061535), + QuadraturePoint(0.0214864573885 / 2, 0.6507106491463, 0.0420141226713), QuadraturePoint(0.0214864586007 / 2, 0.0420141133438, 0.6507105645084), + QuadraturePoint(0.0222218133036 / 2, 0.0425548444254, 0.2920626023484), QuadraturePoint(0.0222218160203 / 2, 0.2920627107240, 0.0425548546753), + QuadraturePoint(0.0223345305455 / 2, 0.5389729538180, 0.4193031469005), QuadraturePoint(0.0223345378739 / 2, 0.4193031828489, 0.5389729093610), + QuadraturePoint(0.0224758924946 / 2, 0.6549472009700, 0.3007352636162), QuadraturePoint(0.0224758980440 / 2, 0.3007352790917, 0.6549471812731), + QuadraturePoint(0.0229701395845 / 2, 0.3752400771585, 0.3453980130752), QuadraturePoint(0.0229703394438 / 2, 0.3453980282786, 0.3752400695673), + QuadraturePoint(0.0232798376102 / 2, 0.0994532168761, 0.1598308695187), QuadraturePoint(0.0232798427506 / 2, 0.1598309359585, 0.0994531960132), + QuadraturePoint(0.0269483199647 / 2, 0.1797326661667, 0.7124585430924), QuadraturePoint(0.0269483307107 / 2, 0.7124584461943, 0.1797327722240), + QuadraturePoint(0.0280438758010 / 2, 0.1066065678636, 0.7001701784175), QuadraturePoint(0.0280438764607 / 2, 0.7001701904096, 0.1066065855677), + QuadraturePoint(0.0287526270172 / 2, 0.0993303629801, 0.6065647984796), QuadraturePoint(0.0287526387271 / 2, 0.6065648052521, 0.0993303896769), + QuadraturePoint(0.0298980829063 / 2, 0.1023223542704, 0.2533381579528), QuadraturePoint(0.0298980922759 / 2, 0.2533382324938, 0.1023223826189), + QuadraturePoint(0.0309004358516 / 2, 0.6166226715217, 0.2769502060575), QuadraturePoint(0.0309004385956 / 2, 0.2769500693109, 0.6166227900624), + QuadraturePoint(0.0314031017088 / 2, 0.0904184571873, 0.4981522637001), QuadraturePoint(0.0314031073955 / 2, 0.4981522767248, 0.0904185045149), + QuadraturePoint(0.0319191553024 / 2, 0.0928231860168, 0.3738418516908), QuadraturePoint(0.0319191668378 / 2, 0.3738418699229, 0.0928232584790), + QuadraturePoint(0.0321429924062 / 2, 0.2521678840407, 0.2521680925697), QuadraturePoint(0.0330395601388 / 2, 0.5087500218708, 0.3905580544330), + QuadraturePoint(0.0330395631829 / 2, 0.3905579116731, 0.5087501437661), QuadraturePoint(0.0356169095589 / 2, 0.1706141469096, 0.5266738039554), + QuadraturePoint(0.0356169276054 / 2, 0.5266737761312, 0.1706142257537), QuadraturePoint(0.0365741189998 / 2, 0.3487581527629, 0.2588055084886), + QuadraturePoint(0.0365741515204 / 2, 0.2588053596017, 0.3487583491703), QuadraturePoint(0.0365977646990 / 2, 0.1696614558053, 0.3013522183964), + QuadraturePoint(0.0365978053889 / 2, 0.3013521806875, 0.1696615963219), QuadraturePoint(0.0369945680114 / 2, 0.2580202409759, 0.4584741774478), + QuadraturePoint(0.0369945775059 / 2, 0.4584740860198, 0.2580203819011), QuadraturePoint(0.0374053623787 / 2, 0.1848898683498, 0.1848898704551), + QuadraturePoint(0.0375550258317 / 2, 0.6130740338465, 0.1921611994069), QuadraturePoint(0.0375550312530 / 2, 0.1921611750994, 0.6130740398389), + QuadraturePoint(0.0388887693486 / 2, 0.4180541160599, 0.1650613336416), QuadraturePoint(0.0388887708342 / 2, 0.1650612642036, 0.4180541199244), + QuadraturePoint(0.0392705643548 / 2, 0.5159205739625, 0.2982719005229), QuadraturePoint(0.0392705802517 / 2, 0.2982718935750, 0.5159205534362), QuadraturePoint(0.0398766879831 / 2, 0.4098894602340, 0.4098894317792), }; const QuadratureFormular QuadratureFormular_T_23(23, 105, P_QuadratureFormular_T_23); static QuadraturePoint P_QuadratureFormular_T_25[] = { - QuadraturePoint(0.0014873417859 / 2, 0.0082881595033, 0.9848202768869), - QuadraturePoint(0.0014889035262 / 2, 0.4618422030241, 0.5381577969759), - QuadraturePoint(0.0015005944380 / 2, 0.0071066441239, 0.0080842361390), - QuadraturePoint(0.0015059208313 / 2, 0.9847613141699, 0.0070015755134), - QuadraturePoint(0.0015318868715 / 2, 0.5374447869049, 0.4625552130951), - QuadraturePoint(0.0023032634487 / 2, 0.0000000000000, 0.4887676880140), - QuadraturePoint(0.0023649067042 / 2, 0.4914131929361, 0.0000000000000), - QuadraturePoint(0.0028751143611 / 2, 0.0070345937020, 0.9574158053697), - QuadraturePoint(0.0029862488735 / 2, 0.9564734714228, 0.0364655449485), - QuadraturePoint(0.0030384162737 / 2, 0.0370198792045, 0.0070908577166), - QuadraturePoint(0.0032092459688 / 2, 0.1024124542747, 0.8936125594937), - QuadraturePoint(0.0037029598435 / 2, 0.5928065811509, 0.0049451705600), - QuadraturePoint(0.0037407186035 / 2, 0.0050948422371, 0.0996676659189), - QuadraturePoint(0.0038452543223 / 2, 0.0081562023689, 0.0415561148784), - QuadraturePoint(0.0038670778668 / 2, 0.0424936107568, 0.9494865260352), - QuadraturePoint(0.0039192555178 / 2, 0.9495543500844, 0.0081794507292), - QuadraturePoint(0.0039573282688 / 2, 0.8932787471239, 0.0053224326262), - QuadraturePoint(0.0044032251724 / 2, 0.0069317612927, 0.9065401020433), - QuadraturePoint(0.0045907108173 / 2, 0.9035839030665, 0.0894771171077), - QuadraturePoint(0.0047023669435 / 2, 0.0905665738209, 0.0070525342005), - QuadraturePoint(0.0050014843818 / 2, 0.0083929332787, 0.6663179931111), - QuadraturePoint(0.0052387830156 / 2, 0.6261245686071, 0.0092197583153), - QuadraturePoint(0.0054422104092 / 2, 0.0062801592979, 0.8335207460527), - QuadraturePoint(0.0056931248912 / 2, 0.8272539257367, 0.1665134939330), - QuadraturePoint(0.0059107422989 / 2, 0.0062005875353, 0.7424693255229), - QuadraturePoint(0.0059687967687 / 2, 0.1676900311185, 0.0065717743528), - QuadraturePoint(0.0067262190287 / 2, 0.7199353069567, 0.0064354534962), - QuadraturePoint(0.0068307848624 / 2, 0.2749740090237, 0.7185296120719), - QuadraturePoint(0.0069531259112 / 2, 0.0079257582005, 0.1766411374714), - QuadraturePoint(0.0072460270642 / 2, 0.0069981220752, 0.2704767254004), - QuadraturePoint(0.0072728189613 / 2, 0.8125248773263, 0.0082299533210), - QuadraturePoint(0.0073008930847 / 2, 0.0073536969970, 0.5934167875453), - QuadraturePoint(0.0073604666776 / 2, 0.7283665935411, 0.2648817553752), - QuadraturePoint(0.0074119923255 / 2, 0.1800642304565, 0.8115848976682), - QuadraturePoint(0.0074892214336 / 2, 0.2658102467762, 0.0068553525429), - QuadraturePoint(0.0078604067260 / 2, 0.0070892364520, 0.3757632659744), - QuadraturePoint(0.0078621726423 / 2, 0.3774054302043, 0.6148573533757), - QuadraturePoint(0.0080506361066 / 2, 0.0369649608668, 0.9210792302893), - QuadraturePoint(0.0081442860473 / 2, 0.9203194109805, 0.0426025082114), - QuadraturePoint(0.0081478804152 / 2, 0.0425477806431, 0.0372689941794), - QuadraturePoint(0.0092444146612 / 2, 0.6191278394983, 0.3724055713809), - QuadraturePoint(0.0094674635165 / 2, 0.3762697209178, 0.0081436422011), - QuadraturePoint(0.0097132210137 / 2, 0.0956111149690, 0.8771098372601), - QuadraturePoint(0.0099753581151 / 2, 0.0302473410377, 0.0943858903393), - QuadraturePoint(0.0103367803673 / 2, 0.8739905691754, 0.0313198990883), - QuadraturePoint(0.0112263277166 / 2, 0.8604133734958, 0.1049019782046), - QuadraturePoint(0.0114309118745 / 2, 0.0347307852352, 0.8609856462886), - QuadraturePoint(0.0115550567487 / 2, 0.1043606608343, 0.0357152881004), - QuadraturePoint(0.0135575856957 / 2, 0.7797622824754, 0.1872318199265), - QuadraturePoint(0.0135984962900 / 2, 0.0185865164256, 0.4834397678794), - QuadraturePoint(0.0137754813837 / 2, 0.0324585286618, 0.7783474916042), - QuadraturePoint(0.0137961015942 / 2, 0.8371293901157, 0.0804060570156), - QuadraturePoint(0.0138408839904 / 2, 0.0836602075315, 0.8421414817051), - QuadraturePoint(0.0140634019977 / 2, 0.0784070242501, 0.0849927089145), - QuadraturePoint(0.0140991451009 / 2, 0.4929238648458, 0.4892855914710), - QuadraturePoint(0.0142004111991 / 2, 0.1870637584073, 0.0345210858281), - QuadraturePoint(0.0144518424517 / 2, 0.4892636967025, 0.0190774755077), - QuadraturePoint(0.0150245979639 / 2, 0.0401982618372, 0.1691143187109), - QuadraturePoint(0.0152817804122 / 2, 0.7894259278865, 0.0412206731484), - QuadraturePoint(0.0155550724169 / 2, 0.1686260456429, 0.7894860640585), - QuadraturePoint(0.0164570886000 / 2, 0.3750901913174, 0.5895318272013), - QuadraturePoint(0.0165275759573 / 2, 0.0356362876880, 0.3681256217699), - QuadraturePoint(0.0166847554451 / 2, 0.5887548164804, 0.0359968962541), - QuadraturePoint(0.0167409312985 / 2, 0.0373308082182, 0.6790704673533), - QuadraturePoint(0.0168674663361 / 2, 0.2820769993374, 0.0373639992361), - QuadraturePoint(0.0168882230165 / 2, 0.6819277603320, 0.2803330345725), - QuadraturePoint(0.0172087112691 / 2, 0.0374938324382, 0.2634016180014), - QuadraturePoint(0.0174681068264 / 2, 0.6984079204127, 0.0364154673322), - QuadraturePoint(0.0176663899614 / 2, 0.2654390894079, 0.6980717436193), - QuadraturePoint(0.0182967621475 / 2, 0.1429848440800, 0.7612254618453), - QuadraturePoint(0.0183576852459 / 2, 0.7623554007647, 0.0943741220275), - QuadraturePoint(0.0186392569521 / 2, 0.0934222022749, 0.1479799836832), - QuadraturePoint(0.0189781060590 / 2, 0.5759004479923, 0.3821329641698), - QuadraturePoint(0.0191847922578 / 2, 0.3822427332525, 0.0426716362301), - QuadraturePoint(0.0194080442044 / 2, 0.0411414081675, 0.5718082874432), - QuadraturePoint(0.0194720072193 / 2, 0.0802462538379, 0.7702204382042), - QuadraturePoint(0.0200855080495 / 2, 0.7625229819410, 0.1559420577362), - QuadraturePoint(0.0201673909332 / 2, 0.1524941445131, 0.0842965421322), - QuadraturePoint(0.0221742162761 / 2, 0.0622159195833, 0.4538181318873), - QuadraturePoint(0.0229702440508 / 2, 0.1109539036076, 0.4586014071171), - QuadraturePoint(0.0233465117399 / 2, 0.4575627212057, 0.4795313560210), - QuadraturePoint(0.0234883135338 / 2, 0.4322865136374, 0.1230591237472), - QuadraturePoint(0.0240682099018 / 2, 0.5865002850241, 0.0834119779793), - QuadraturePoint(0.0240910792953 / 2, 0.0869359250818, 0.6755677013351), - QuadraturePoint(0.0245677049481 / 2, 0.0929594906936, 0.2326500892727), - QuadraturePoint(0.0246536315719 / 2, 0.6661932141454, 0.2448294007406), - QuadraturePoint(0.0246756530052 / 2, 0.4780306362227, 0.0661749044835), - QuadraturePoint(0.0249704602710 / 2, 0.4372215294577, 0.4442145585244), - QuadraturePoint(0.0250026544082 / 2, 0.6779224504669, 0.0929096534577), - QuadraturePoint(0.0250490869426 / 2, 0.2423431255660, 0.0889793655129), - QuadraturePoint(0.0250936250125 / 2, 0.2288925420305, 0.6780053081672), - QuadraturePoint(0.0251482076226 / 2, 0.3315065049959, 0.5847381559741), - QuadraturePoint(0.0255010290447 / 2, 0.3424200526607, 0.5139245722736), - QuadraturePoint(0.0256544511979 / 2, 0.0862630046475, 0.3340976249234), - QuadraturePoint(0.0257974750630 / 2, 0.5113188946635, 0.1380154720554), - QuadraturePoint(0.0270007753993 / 2, 0.1538977841001, 0.6788062619562), - QuadraturePoint(0.0274431536844 / 2, 0.6779951348472, 0.1663358925269), - QuadraturePoint(0.0277072401488 / 2, 0.1664600469411, 0.1582214504849), - QuadraturePoint(0.0278284415364 / 2, 0.0950910318888, 0.5666590332543), - QuadraturePoint(0.0287207381105 / 2, 0.3436048136712, 0.0978960873457), - QuadraturePoint(0.0288826834956 / 2, 0.5560417025366, 0.3468917820947), - QuadraturePoint(0.0293302729759 / 2, 0.1452404029513, 0.3599534491052), - QuadraturePoint(0.0318902879557 / 2, 0.1619685156238, 0.5810131373330), - QuadraturePoint(0.0319083660286 / 2, 0.5800164844262, 0.2560674640672), - QuadraturePoint(0.0320938960329 / 2, 0.2450201223288, 0.5881469552102), - QuadraturePoint(0.0321618608780 / 2, 0.2557621891794, 0.1652244065047), - QuadraturePoint(0.0322424127534 / 2, 0.2205239985511, 0.3496507466106), - QuadraturePoint(0.0327072446421 / 2, 0.4940183111285, 0.2549448448453), - QuadraturePoint(0.0329946316695 / 2, 0.2531570689798, 0.2543369115017), - QuadraturePoint(0.0331828096025 / 2, 0.5846891116357, 0.1666603916479), - QuadraturePoint(0.0334857162651 / 2, 0.1660333602278, 0.2523240191705), - QuadraturePoint(0.0335468472792 / 2, 0.2505426292461, 0.4959007627528), - QuadraturePoint(0.0337049042988 / 2, 0.3519336802182, 0.1805380367800), - QuadraturePoint(0.0340361462767 / 2, 0.3502668835419, 0.4358582329881), - QuadraturePoint(0.0342465235323 / 2, 0.4400892485512, 0.2120576104941), - QuadraturePoint(0.0345528817251 / 2, 0.4680855471546, 0.3552681570774), - QuadraturePoint(0.0356782875703 / 2, 0.1770237763947, 0.4670352922266), - QuadraturePoint(0.0364656225016 / 2, 0.3900920779501, 0.3323152819300), - QuadraturePoint(0.0365172708706 / 2, 0.2805847774120, 0.3898041176680), - QuadraturePoint(0.0371924811018 / 2, 0.3361523347440, 0.2778500044356), + QuadraturePoint(0.0014873417859 / 2, 0.0082881595033, 0.9848202768869), QuadraturePoint(0.0014889035262 / 2, 0.4618422030241, 0.5381577969759), + QuadraturePoint(0.0015005944380 / 2, 0.0071066441239, 0.0080842361390), QuadraturePoint(0.0015059208313 / 2, 0.9847613141699, 0.0070015755134), + QuadraturePoint(0.0015318868715 / 2, 0.5374447869049, 0.4625552130951), QuadraturePoint(0.0023032634487 / 2, 0.0000000000000, 0.4887676880140), + QuadraturePoint(0.0023649067042 / 2, 0.4914131929361, 0.0000000000000), QuadraturePoint(0.0028751143611 / 2, 0.0070345937020, 0.9574158053697), + QuadraturePoint(0.0029862488735 / 2, 0.9564734714228, 0.0364655449485), QuadraturePoint(0.0030384162737 / 2, 0.0370198792045, 0.0070908577166), + QuadraturePoint(0.0032092459688 / 2, 0.1024124542747, 0.8936125594937), QuadraturePoint(0.0037029598435 / 2, 0.5928065811509, 0.0049451705600), + QuadraturePoint(0.0037407186035 / 2, 0.0050948422371, 0.0996676659189), QuadraturePoint(0.0038452543223 / 2, 0.0081562023689, 0.0415561148784), + QuadraturePoint(0.0038670778668 / 2, 0.0424936107568, 0.9494865260352), QuadraturePoint(0.0039192555178 / 2, 0.9495543500844, 0.0081794507292), + QuadraturePoint(0.0039573282688 / 2, 0.8932787471239, 0.0053224326262), QuadraturePoint(0.0044032251724 / 2, 0.0069317612927, 0.9065401020433), + QuadraturePoint(0.0045907108173 / 2, 0.9035839030665, 0.0894771171077), QuadraturePoint(0.0047023669435 / 2, 0.0905665738209, 0.0070525342005), + QuadraturePoint(0.0050014843818 / 2, 0.0083929332787, 0.6663179931111), QuadraturePoint(0.0052387830156 / 2, 0.6261245686071, 0.0092197583153), + QuadraturePoint(0.0054422104092 / 2, 0.0062801592979, 0.8335207460527), QuadraturePoint(0.0056931248912 / 2, 0.8272539257367, 0.1665134939330), + QuadraturePoint(0.0059107422989 / 2, 0.0062005875353, 0.7424693255229), QuadraturePoint(0.0059687967687 / 2, 0.1676900311185, 0.0065717743528), + QuadraturePoint(0.0067262190287 / 2, 0.7199353069567, 0.0064354534962), QuadraturePoint(0.0068307848624 / 2, 0.2749740090237, 0.7185296120719), + QuadraturePoint(0.0069531259112 / 2, 0.0079257582005, 0.1766411374714), QuadraturePoint(0.0072460270642 / 2, 0.0069981220752, 0.2704767254004), + QuadraturePoint(0.0072728189613 / 2, 0.8125248773263, 0.0082299533210), QuadraturePoint(0.0073008930847 / 2, 0.0073536969970, 0.5934167875453), + QuadraturePoint(0.0073604666776 / 2, 0.7283665935411, 0.2648817553752), QuadraturePoint(0.0074119923255 / 2, 0.1800642304565, 0.8115848976682), + QuadraturePoint(0.0074892214336 / 2, 0.2658102467762, 0.0068553525429), QuadraturePoint(0.0078604067260 / 2, 0.0070892364520, 0.3757632659744), + QuadraturePoint(0.0078621726423 / 2, 0.3774054302043, 0.6148573533757), QuadraturePoint(0.0080506361066 / 2, 0.0369649608668, 0.9210792302893), + QuadraturePoint(0.0081442860473 / 2, 0.9203194109805, 0.0426025082114), QuadraturePoint(0.0081478804152 / 2, 0.0425477806431, 0.0372689941794), + QuadraturePoint(0.0092444146612 / 2, 0.6191278394983, 0.3724055713809), QuadraturePoint(0.0094674635165 / 2, 0.3762697209178, 0.0081436422011), + QuadraturePoint(0.0097132210137 / 2, 0.0956111149690, 0.8771098372601), QuadraturePoint(0.0099753581151 / 2, 0.0302473410377, 0.0943858903393), + QuadraturePoint(0.0103367803673 / 2, 0.8739905691754, 0.0313198990883), QuadraturePoint(0.0112263277166 / 2, 0.8604133734958, 0.1049019782046), + QuadraturePoint(0.0114309118745 / 2, 0.0347307852352, 0.8609856462886), QuadraturePoint(0.0115550567487 / 2, 0.1043606608343, 0.0357152881004), + QuadraturePoint(0.0135575856957 / 2, 0.7797622824754, 0.1872318199265), QuadraturePoint(0.0135984962900 / 2, 0.0185865164256, 0.4834397678794), + QuadraturePoint(0.0137754813837 / 2, 0.0324585286618, 0.7783474916042), QuadraturePoint(0.0137961015942 / 2, 0.8371293901157, 0.0804060570156), + QuadraturePoint(0.0138408839904 / 2, 0.0836602075315, 0.8421414817051), QuadraturePoint(0.0140634019977 / 2, 0.0784070242501, 0.0849927089145), + QuadraturePoint(0.0140991451009 / 2, 0.4929238648458, 0.4892855914710), QuadraturePoint(0.0142004111991 / 2, 0.1870637584073, 0.0345210858281), + QuadraturePoint(0.0144518424517 / 2, 0.4892636967025, 0.0190774755077), QuadraturePoint(0.0150245979639 / 2, 0.0401982618372, 0.1691143187109), + QuadraturePoint(0.0152817804122 / 2, 0.7894259278865, 0.0412206731484), QuadraturePoint(0.0155550724169 / 2, 0.1686260456429, 0.7894860640585), + QuadraturePoint(0.0164570886000 / 2, 0.3750901913174, 0.5895318272013), QuadraturePoint(0.0165275759573 / 2, 0.0356362876880, 0.3681256217699), + QuadraturePoint(0.0166847554451 / 2, 0.5887548164804, 0.0359968962541), QuadraturePoint(0.0167409312985 / 2, 0.0373308082182, 0.6790704673533), + QuadraturePoint(0.0168674663361 / 2, 0.2820769993374, 0.0373639992361), QuadraturePoint(0.0168882230165 / 2, 0.6819277603320, 0.2803330345725), + QuadraturePoint(0.0172087112691 / 2, 0.0374938324382, 0.2634016180014), QuadraturePoint(0.0174681068264 / 2, 0.6984079204127, 0.0364154673322), + QuadraturePoint(0.0176663899614 / 2, 0.2654390894079, 0.6980717436193), QuadraturePoint(0.0182967621475 / 2, 0.1429848440800, 0.7612254618453), + QuadraturePoint(0.0183576852459 / 2, 0.7623554007647, 0.0943741220275), QuadraturePoint(0.0186392569521 / 2, 0.0934222022749, 0.1479799836832), + QuadraturePoint(0.0189781060590 / 2, 0.5759004479923, 0.3821329641698), QuadraturePoint(0.0191847922578 / 2, 0.3822427332525, 0.0426716362301), + QuadraturePoint(0.0194080442044 / 2, 0.0411414081675, 0.5718082874432), QuadraturePoint(0.0194720072193 / 2, 0.0802462538379, 0.7702204382042), + QuadraturePoint(0.0200855080495 / 2, 0.7625229819410, 0.1559420577362), QuadraturePoint(0.0201673909332 / 2, 0.1524941445131, 0.0842965421322), + QuadraturePoint(0.0221742162761 / 2, 0.0622159195833, 0.4538181318873), QuadraturePoint(0.0229702440508 / 2, 0.1109539036076, 0.4586014071171), + QuadraturePoint(0.0233465117399 / 2, 0.4575627212057, 0.4795313560210), QuadraturePoint(0.0234883135338 / 2, 0.4322865136374, 0.1230591237472), + QuadraturePoint(0.0240682099018 / 2, 0.5865002850241, 0.0834119779793), QuadraturePoint(0.0240910792953 / 2, 0.0869359250818, 0.6755677013351), + QuadraturePoint(0.0245677049481 / 2, 0.0929594906936, 0.2326500892727), QuadraturePoint(0.0246536315719 / 2, 0.6661932141454, 0.2448294007406), + QuadraturePoint(0.0246756530052 / 2, 0.4780306362227, 0.0661749044835), QuadraturePoint(0.0249704602710 / 2, 0.4372215294577, 0.4442145585244), + QuadraturePoint(0.0250026544082 / 2, 0.6779224504669, 0.0929096534577), QuadraturePoint(0.0250490869426 / 2, 0.2423431255660, 0.0889793655129), + QuadraturePoint(0.0250936250125 / 2, 0.2288925420305, 0.6780053081672), QuadraturePoint(0.0251482076226 / 2, 0.3315065049959, 0.5847381559741), + QuadraturePoint(0.0255010290447 / 2, 0.3424200526607, 0.5139245722736), QuadraturePoint(0.0256544511979 / 2, 0.0862630046475, 0.3340976249234), + QuadraturePoint(0.0257974750630 / 2, 0.5113188946635, 0.1380154720554), QuadraturePoint(0.0270007753993 / 2, 0.1538977841001, 0.6788062619562), + QuadraturePoint(0.0274431536844 / 2, 0.6779951348472, 0.1663358925269), QuadraturePoint(0.0277072401488 / 2, 0.1664600469411, 0.1582214504849), + QuadraturePoint(0.0278284415364 / 2, 0.0950910318888, 0.5666590332543), QuadraturePoint(0.0287207381105 / 2, 0.3436048136712, 0.0978960873457), + QuadraturePoint(0.0288826834956 / 2, 0.5560417025366, 0.3468917820947), QuadraturePoint(0.0293302729759 / 2, 0.1452404029513, 0.3599534491052), + QuadraturePoint(0.0318902879557 / 2, 0.1619685156238, 0.5810131373330), QuadraturePoint(0.0319083660286 / 2, 0.5800164844262, 0.2560674640672), + QuadraturePoint(0.0320938960329 / 2, 0.2450201223288, 0.5881469552102), QuadraturePoint(0.0321618608780 / 2, 0.2557621891794, 0.1652244065047), + QuadraturePoint(0.0322424127534 / 2, 0.2205239985511, 0.3496507466106), QuadraturePoint(0.0327072446421 / 2, 0.4940183111285, 0.2549448448453), + QuadraturePoint(0.0329946316695 / 2, 0.2531570689798, 0.2543369115017), QuadraturePoint(0.0331828096025 / 2, 0.5846891116357, 0.1666603916479), + QuadraturePoint(0.0334857162651 / 2, 0.1660333602278, 0.2523240191705), QuadraturePoint(0.0335468472792 / 2, 0.2505426292461, 0.4959007627528), + QuadraturePoint(0.0337049042988 / 2, 0.3519336802182, 0.1805380367800), QuadraturePoint(0.0340361462767 / 2, 0.3502668835419, 0.4358582329881), + QuadraturePoint(0.0342465235323 / 2, 0.4400892485512, 0.2120576104941), QuadraturePoint(0.0345528817251 / 2, 0.4680855471546, 0.3552681570774), + QuadraturePoint(0.0356782875703 / 2, 0.1770237763947, 0.4670352922266), QuadraturePoint(0.0364656225016 / 2, 0.3900920779501, 0.3323152819300), + QuadraturePoint(0.0365172708706 / 2, 0.2805847774120, 0.3898041176680), QuadraturePoint(0.0371924811018 / 2, 0.3361523347440, 0.2778500044356), }; const QuadratureFormular QuadratureFormular_T_25(25, 120, P_QuadratureFormular_T_25); @@ -819,8 +509,7 @@ T *CCopy(T *pr, T p) { } template< class Rd > -const GQuadratureFormular< Rd > **pBuilQFd(const GQuadratureFormular< Rd > **const &pr, - const long &nex, const KNM_< double > &qf) { +const GQuadratureFormular< Rd > **pBuilQFd(const GQuadratureFormular< Rd > **const &pr, const long &nex, const KNM_< double > &qf) { ffassert(pr); *pr = BuilQFd< Rd >(nex, qf); return pr; @@ -839,3195 +528,2200 @@ PQP3 QF_TET_P1[] = { PQF3 const QuadratureFormular_Tet_P1(1, 1, QF_TET_P1); // QUAD QUAD_3D_P2_ = { 4 16 PQP3 QF_TET_P2[] = { - PQP3(R3(.13819660112501051517954131656343619, .13819660112501051517954131656343619, - .13819660112501051517954131656343619), + PQP3(R3(.13819660112501051517954131656343619, .13819660112501051517954131656343619, .13819660112501051517954131656343619), .25), // 0 0 - PQP3(R3(1. - 3. * (.13819660112501051517954131656343619), .13819660112501051517954131656343619, - .13819660112501051517954131656343619), + PQP3(R3(1. - 3. * (.13819660112501051517954131656343619), .13819660112501051517954131656343619, .13819660112501051517954131656343619), .25), // 1 4 - PQP3(R3(.13819660112501051517954131656343619, 1. - 3. * (.13819660112501051517954131656343619), - .13819660112501051517954131656343619), + PQP3(R3(.13819660112501051517954131656343619, 1. - 3. * (.13819660112501051517954131656343619), .13819660112501051517954131656343619), .25), // 2 8 - PQP3(R3(.13819660112501051517954131656343619, .13819660112501051517954131656343619, - 1. - 3. * (.13819660112501051517954131656343619)), + PQP3(R3(.13819660112501051517954131656343619, .13819660112501051517954131656343619, 1. - 3. * (.13819660112501051517954131656343619)), .25), // 3 12 }; PQF3 const QuadratureFormular_Tet_P2(2, 4, QF_TET_P2); // QUAD QUAD_3D_P3_ = { 8 32 PQP3 QF_TET_P3[] = { - PQP3(R3(.32805469671142664733580581998119743, .32805469671142664733580581998119743, - .32805469671142664733580581998119743), + PQP3(R3(.32805469671142664733580581998119743, .32805469671142664733580581998119743, .32805469671142664733580581998119743), .13852796651186214232361769837564129), // 0 0 - PQP3(R3(1. - 3. * (.32805469671142664733580581998119743), .32805469671142664733580581998119743, - .32805469671142664733580581998119743), + PQP3(R3(1. - 3. * (.32805469671142664733580581998119743), .32805469671142664733580581998119743, .32805469671142664733580581998119743), .13852796651186214232361769837564129), // 1 4 - PQP3(R3(.32805469671142664733580581998119743, 1. - 3. * (.32805469671142664733580581998119743), - .32805469671142664733580581998119743), + PQP3(R3(.32805469671142664733580581998119743, 1. - 3. * (.32805469671142664733580581998119743), .32805469671142664733580581998119743), .13852796651186214232361769837564129), // 2 8 - PQP3(R3(.32805469671142664733580581998119743, .32805469671142664733580581998119743, - 1. - 3. * (.32805469671142664733580581998119743)), + PQP3(R3(.32805469671142664733580581998119743, .32805469671142664733580581998119743, 1. - 3. * (.32805469671142664733580581998119743)), .13852796651186214232361769837564129), // 3 12 - PQP3(R3(.10695227393293068277170204157061650, .10695227393293068277170204157061650, - .10695227393293068277170204157061650), + PQP3(R3(.10695227393293068277170204157061650, .10695227393293068277170204157061650, .10695227393293068277170204157061650), .11147203348813785767638230162435871), // 4 16 - PQP3(R3(1. - 3. * (.10695227393293068277170204157061650), .10695227393293068277170204157061650, - .10695227393293068277170204157061650), + PQP3(R3(1. - 3. * (.10695227393293068277170204157061650), .10695227393293068277170204157061650, .10695227393293068277170204157061650), .11147203348813785767638230162435871), // 5 20 - PQP3(R3(.10695227393293068277170204157061650, 1. - 3. * (.10695227393293068277170204157061650), - .10695227393293068277170204157061650), + PQP3(R3(.10695227393293068277170204157061650, 1. - 3. * (.10695227393293068277170204157061650), .10695227393293068277170204157061650), .11147203348813785767638230162435871), // 6 24 - PQP3(R3(.10695227393293068277170204157061650, .10695227393293068277170204157061650, - 1. - 3. * (.10695227393293068277170204157061650)), + PQP3(R3(.10695227393293068277170204157061650, .10695227393293068277170204157061650, 1. - 3. * (.10695227393293068277170204157061650)), .11147203348813785767638230162435871), // 7 28 }; PQF3 const QuadratureFormular_Tet_P3(3, 8, QF_TET_P3); // QUAD QUAD_3D_P4_ = { 14 56 PQP3 QF_TET_P4[] = { - PQP3(R3(.09273525031089122628655892066032137, .09273525031089122628655892066032137, - .09273525031089122628655892066032137), + PQP3(R3(.09273525031089122628655892066032137, .09273525031089122628655892066032137, .09273525031089122628655892066032137), .07349304311636194934358694586367885), // 0 0 - PQP3(R3(1. - 3. * (.09273525031089122628655892066032137), .09273525031089122628655892066032137, - .09273525031089122628655892066032137), + PQP3(R3(1. - 3. * (.09273525031089122628655892066032137), .09273525031089122628655892066032137, .09273525031089122628655892066032137), .07349304311636194934358694586367885), // 1 4 - PQP3(R3(.09273525031089122628655892066032137, 1. - 3. * (.09273525031089122628655892066032137), - .09273525031089122628655892066032137), + PQP3(R3(.09273525031089122628655892066032137, 1. - 3. * (.09273525031089122628655892066032137), .09273525031089122628655892066032137), .07349304311636194934358694586367885), // 2 8 - PQP3(R3(.09273525031089122628655892066032137, .09273525031089122628655892066032137, - 1. - 3. * (.09273525031089122628655892066032137)), + PQP3(R3(.09273525031089122628655892066032137, .09273525031089122628655892066032137, 1. - 3. * (.09273525031089122628655892066032137)), .07349304311636194934358694586367885), // 3 12 - PQP3(R3(.31088591926330060975814749494040332, .31088591926330060975814749494040332, - .31088591926330060975814749494040332), + PQP3(R3(.31088591926330060975814749494040332, .31088591926330060975814749494040332, .31088591926330060975814749494040332), .11268792571801585036501492847638892), // 4 16 - PQP3(R3(1. - 3. * (.31088591926330060975814749494040332), .31088591926330060975814749494040332, - .31088591926330060975814749494040332), + PQP3(R3(1. - 3. * (.31088591926330060975814749494040332), .31088591926330060975814749494040332, .31088591926330060975814749494040332), .11268792571801585036501492847638892), // 5 20 - PQP3(R3(.31088591926330060975814749494040332, 1. - 3. * (.31088591926330060975814749494040332), - .31088591926330060975814749494040332), + PQP3(R3(.31088591926330060975814749494040332, 1. - 3. * (.31088591926330060975814749494040332), .31088591926330060975814749494040332), .11268792571801585036501492847638892), // 6 24 - PQP3(R3(.31088591926330060975814749494040332, .31088591926330060975814749494040332, - 1. - 3. * (.31088591926330060975814749494040332)), + PQP3(R3(.31088591926330060975814749494040332, .31088591926330060975814749494040332, 1. - 3. * (.31088591926330060975814749494040332)), .11268792571801585036501492847638892), // 7 28 - PQP3(R3(.04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000), - .5 - (.04550370412564965000000000000000000)), + PQP3(R3(.04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000), .5 - (.04550370412564965000000000000000000)), .04254602077708146686093208377328816), // 8 32 - PQP3(R3(.5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000, - .5 - (.04550370412564965000000000000000000)), + PQP3(R3(.5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000)), .04254602077708146686093208377328816), // 9 36 - PQP3(R3(.5 - (.04550370412564965000000000000000000), .5 - (.04550370412564965000000000000000000), - .04550370412564965000000000000000000), + PQP3(R3(.5 - (.04550370412564965000000000000000000), .5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000), .04254602077708146686093208377328816), // 10 40 - PQP3(R3(.04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000), - .04550370412564965000000000000000000), + PQP3(R3(.04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000), .04254602077708146686093208377328816), // 11 44 - PQP3(R3(.04550370412564965000000000000000000, .04550370412564965000000000000000000, - .5 - (.04550370412564965000000000000000000)), + PQP3(R3(.04550370412564965000000000000000000, .04550370412564965000000000000000000, .5 - (.04550370412564965000000000000000000)), .04254602077708146686093208377328816), // 12 48 - PQP3(R3(.5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000, - .04550370412564965000000000000000000), + PQP3(R3(.5 - (.04550370412564965000000000000000000), .04550370412564965000000000000000000, .04550370412564965000000000000000000), .04254602077708146686093208377328816), // 13 52 }; PQF3 const QuadratureFormular_Tet_P4(4, 14, QF_TET_P4); // QUAD QUAD_3D_P5_ = { 14 56 PQP3 QF_TET_P5[] = { - PQP3(R3(.31088591926330060979734573376345783, .31088591926330060979734573376345783, - .31088591926330060979734573376345783), + PQP3(R3(.31088591926330060979734573376345783, .31088591926330060979734573376345783, .31088591926330060979734573376345783), .11268792571801585079918565233328633), // 0 0 - PQP3(R3(1. - 3. * (.31088591926330060979734573376345783), .31088591926330060979734573376345783, - .31088591926330060979734573376345783), + PQP3(R3(1. - 3. * (.31088591926330060979734573376345783), .31088591926330060979734573376345783, .31088591926330060979734573376345783), .11268792571801585079918565233328633), // 1 4 - PQP3(R3(.31088591926330060979734573376345783, 1. - 3. * (.31088591926330060979734573376345783), - .31088591926330060979734573376345783), + PQP3(R3(.31088591926330060979734573376345783, 1. - 3. * (.31088591926330060979734573376345783), .31088591926330060979734573376345783), .11268792571801585079918565233328633), // 2 8 - PQP3(R3(.31088591926330060979734573376345783, .31088591926330060979734573376345783, - 1. - 3. * (.31088591926330060979734573376345783)), + PQP3(R3(.31088591926330060979734573376345783, .31088591926330060979734573376345783, 1. - 3. * (.31088591926330060979734573376345783)), .11268792571801585079918565233328633), // 3 12 - PQP3(R3(.09273525031089122640232391373703061, .09273525031089122640232391373703061, - .09273525031089122640232391373703061), + PQP3(R3(.09273525031089122640232391373703061, .09273525031089122640232391373703061, .09273525031089122640232391373703061), .07349304311636194954371020548632750), // 4 16 - PQP3(R3(1. - 3. * (.09273525031089122640232391373703061), .09273525031089122640232391373703061, - .09273525031089122640232391373703061), + PQP3(R3(1. - 3. * (.09273525031089122640232391373703061), .09273525031089122640232391373703061, .09273525031089122640232391373703061), .07349304311636194954371020548632750), // 5 20 - PQP3(R3(.09273525031089122640232391373703061, 1. - 3. * (.09273525031089122640232391373703061), - .09273525031089122640232391373703061), + PQP3(R3(.09273525031089122640232391373703061, 1. - 3. * (.09273525031089122640232391373703061), .09273525031089122640232391373703061), .07349304311636194954371020548632750), // 6 24 - PQP3(R3(.09273525031089122640232391373703061, .09273525031089122640232391373703061, - 1. - 3. * (.09273525031089122640232391373703061)), + PQP3(R3(.09273525031089122640232391373703061, .09273525031089122640232391373703061, 1. - 3. * (.09273525031089122640232391373703061)), .07349304311636194954371020548632750), // 7 28 - PQP3(R3(.04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943), - .5 - (.04550370412564964949188052627933943)), + PQP3(R3(.04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943), .5 - (.04550370412564964949188052627933943)), .04254602077708146643806942812025744), // 8 32 - PQP3(R3(.5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943, - .5 - (.04550370412564964949188052627933943)), + PQP3(R3(.5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943)), .04254602077708146643806942812025744), // 9 36 - PQP3(R3(.5 - (.04550370412564964949188052627933943), .5 - (.04550370412564964949188052627933943), - .04550370412564964949188052627933943), + PQP3(R3(.5 - (.04550370412564964949188052627933943), .5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943), .04254602077708146643806942812025744), // 10 40 - PQP3(R3(.04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943), - .04550370412564964949188052627933943), + PQP3(R3(.04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943), .04254602077708146643806942812025744), // 11 44 - PQP3(R3(.04550370412564964949188052627933943, .04550370412564964949188052627933943, - .5 - (.04550370412564964949188052627933943)), + PQP3(R3(.04550370412564964949188052627933943, .04550370412564964949188052627933943, .5 - (.04550370412564964949188052627933943)), .04254602077708146643806942812025744), // 12 48 - PQP3(R3(.5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943, - .04550370412564964949188052627933943), + PQP3(R3(.5 - (.04550370412564964949188052627933943), .04550370412564964949188052627933943, .04550370412564964949188052627933943), .04254602077708146643806942812025744), // 13 52 }; PQF3 const QuadratureFormular_Tet_P5(5, 14, QF_TET_P5); // QUAD QUAD_3D_P6_ = { 24 96 PQP3 QF_TET_P6[] = { - PQP3(R3(.21460287125915202928883921938628499, .21460287125915202928883921938628499, - .21460287125915202928883921938628499), + PQP3(R3(.21460287125915202928883921938628499, .21460287125915202928883921938628499, .21460287125915202928883921938628499), .03992275025816749209969062755747998), // 0 0 - PQP3(R3(1. - 3. * (.21460287125915202928883921938628499), .21460287125915202928883921938628499, - .21460287125915202928883921938628499), + PQP3(R3(1. - 3. * (.21460287125915202928883921938628499), .21460287125915202928883921938628499, .21460287125915202928883921938628499), .03992275025816749209969062755747998), // 1 4 - PQP3(R3(.21460287125915202928883921938628499, 1. - 3. * (.21460287125915202928883921938628499), - .21460287125915202928883921938628499), + PQP3(R3(.21460287125915202928883921938628499, 1. - 3. * (.21460287125915202928883921938628499), .21460287125915202928883921938628499), .03992275025816749209969062755747998), // 2 8 - PQP3(R3(.21460287125915202928883921938628499, .21460287125915202928883921938628499, - 1. - 3. * (.21460287125915202928883921938628499)), + PQP3(R3(.21460287125915202928883921938628499, .21460287125915202928883921938628499, 1. - 3. * (.21460287125915202928883921938628499)), .03992275025816749209969062755747998), // 3 12 - PQP3(R3(.04067395853461135311557944895641006, .04067395853461135311557944895641006, - .04067395853461135311557944895641006), + PQP3(R3(.04067395853461135311557944895641006, .04067395853461135311557944895641006, .04067395853461135311557944895641006), .01007721105532064294801323744593686), // 4 16 - PQP3(R3(1. - 3. * (.04067395853461135311557944895641006), .04067395853461135311557944895641006, - .04067395853461135311557944895641006), + PQP3(R3(1. - 3. * (.04067395853461135311557944895641006), .04067395853461135311557944895641006, .04067395853461135311557944895641006), .01007721105532064294801323744593686), // 5 20 - PQP3(R3(.04067395853461135311557944895641006, 1. - 3. * (.04067395853461135311557944895641006), - .04067395853461135311557944895641006), + PQP3(R3(.04067395853461135311557944895641006, 1. - 3. * (.04067395853461135311557944895641006), .04067395853461135311557944895641006), .01007721105532064294801323744593686), // 6 24 - PQP3(R3(.04067395853461135311557944895641006, .04067395853461135311557944895641006, - 1. - 3. * (.04067395853461135311557944895641006)), + PQP3(R3(.04067395853461135311557944895641006, .04067395853461135311557944895641006, 1. - 3. * (.04067395853461135311557944895641006)), .01007721105532064294801323744593686), // 7 28 - PQP3(R3(.32233789014227551034399447076249213, .32233789014227551034399447076249213, - .32233789014227551034399447076249213), + PQP3(R3(.32233789014227551034399447076249213, .32233789014227551034399447076249213, .32233789014227551034399447076249213), .05535718154365472209515327785372602), // 8 32 - PQP3(R3(1. - 3. * (.32233789014227551034399447076249213), .32233789014227551034399447076249213, - .32233789014227551034399447076249213), + PQP3(R3(1. - 3. * (.32233789014227551034399447076249213), .32233789014227551034399447076249213, .32233789014227551034399447076249213), .05535718154365472209515327785372602), // 9 36 - PQP3(R3(.32233789014227551034399447076249213, 1. - 3. * (.32233789014227551034399447076249213), - .32233789014227551034399447076249213), + PQP3(R3(.32233789014227551034399447076249213, 1. - 3. * (.32233789014227551034399447076249213), .32233789014227551034399447076249213), .05535718154365472209515327785372602), // 10 40 - PQP3(R3(.32233789014227551034399447076249213, .32233789014227551034399447076249213, - 1. - 3. * (.32233789014227551034399447076249213)), + PQP3(R3(.32233789014227551034399447076249213, .32233789014227551034399447076249213, 1. - 3. * (.32233789014227551034399447076249213)), .05535718154365472209515327785372602), // 11 44 PQP3(R3(.06366100187501752529923552760572698, .60300566479164914136743113906093969, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969)), + 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969)), 27. / 560.), // 12 48 - PQP3(R3(.06366100187501752529923552760572698, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), + PQP3(R3(.06366100187501752529923552760572698, 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .60300566479164914136743113906093969), 27. / 560.), // 13 52 PQP3(R3(.60300566479164914136743113906093969, .06366100187501752529923552760572698, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969)), + 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969)), 27. / 560.), // 14 56 - PQP3(R3(.60300566479164914136743113906093969, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), + PQP3(R3(.60300566479164914136743113906093969, 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .06366100187501752529923552760572698), 27. / 560.), // 15 60 - PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), - .06366100187501752529923552760572698, .60300566479164914136743113906093969), + PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .06366100187501752529923552760572698, + .60300566479164914136743113906093969), 27. / 560.), // 16 64 - PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), - .60300566479164914136743113906093969, .06366100187501752529923552760572698), + PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .60300566479164914136743113906093969, + .06366100187501752529923552760572698), 27. / 560.), // 17 68 PQP3(R3(.06366100187501752529923552760572698, .06366100187501752529923552760572698, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969)), + 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969)), 27. / 560.), // 18 72 - PQP3(R3(.06366100187501752529923552760572698, - 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), + PQP3(R3(.06366100187501752529923552760572698, 1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .06366100187501752529923552760572698), 27. / 560.), // 19 76 - PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - - (.60300566479164914136743113906093969), - .06366100187501752529923552760572698, .06366100187501752529923552760572698), + PQP3(R3(1. - (.06366100187501752529923552760572698) - (.06366100187501752529923552760572698) - (.60300566479164914136743113906093969), .06366100187501752529923552760572698, + .06366100187501752529923552760572698), 27. / 560.), // 20 80 - PQP3(R3(.06366100187501752529923552760572698, .06366100187501752529923552760572698, - .60300566479164914136743113906093969), + PQP3(R3(.06366100187501752529923552760572698, .06366100187501752529923552760572698, .60300566479164914136743113906093969), 27. / 560.), // 21 84 - PQP3(R3(.06366100187501752529923552760572698, .60300566479164914136743113906093969, - .06366100187501752529923552760572698), + PQP3(R3(.06366100187501752529923552760572698, .60300566479164914136743113906093969, .06366100187501752529923552760572698), 27. / 560.), // 22 88 - PQP3(R3(.60300566479164914136743113906093969, .06366100187501752529923552760572698, - .06366100187501752529923552760572698), + PQP3(R3(.60300566479164914136743113906093969, .06366100187501752529923552760572698, .06366100187501752529923552760572698), 27. / 560.), // 23 92 }; PQF3 const QuadratureFormular_Tet_P6(6, 24, QF_TET_P6); // QUAD QUAD_3D_P7_ = { 35 140 PQP3 QF_TET_P7[] = { PQP3(R3(0.25, 0.25, 0.25), .09548528946413084886057843611722638), // 0 0 - PQP3(R3(.31570114977820279942342999959331149, .31570114977820279942342999959331149, - .31570114977820279942342999959331149), + PQP3(R3(.31570114977820279942342999959331149, .31570114977820279942342999959331149, .31570114977820279942342999959331149), .04232958120996702907628617079854674), // 1 4 - PQP3(R3(1. - 3. * (.31570114977820279942342999959331149), .31570114977820279942342999959331149, - .31570114977820279942342999959331149), + PQP3(R3(1. - 3. * (.31570114977820279942342999959331149), .31570114977820279942342999959331149, .31570114977820279942342999959331149), .04232958120996702907628617079854674), // 2 8 - PQP3(R3(.31570114977820279942342999959331149, 1. - 3. * (.31570114977820279942342999959331149), - .31570114977820279942342999959331149), + PQP3(R3(.31570114977820279942342999959331149, 1. - 3. * (.31570114977820279942342999959331149), .31570114977820279942342999959331149), .04232958120996702907628617079854674), // 3 12 - PQP3(R3(.31570114977820279942342999959331149, .31570114977820279942342999959331149, - 1. - 3. * (.31570114977820279942342999959331149)), + PQP3(R3(.31570114977820279942342999959331149, .31570114977820279942342999959331149, 1. - 3. * (.31570114977820279942342999959331149)), .04232958120996702907628617079854674), // 4 16 - PQP3(R3(.05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247), - .5 - (.05048982259839636876305382298656247)), + PQP3(R3(.05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247), .5 - (.05048982259839636876305382298656247)), .03189692783285757993427482408294246), // 5 20 - PQP3(R3(.5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247, - .5 - (.05048982259839636876305382298656247)), + PQP3(R3(.5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247)), .03189692783285757993427482408294246), // 6 24 - PQP3(R3(.5 - (.05048982259839636876305382298656247), .5 - (.05048982259839636876305382298656247), - .05048982259839636876305382298656247), + PQP3(R3(.5 - (.05048982259839636876305382298656247), .5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247), .03189692783285757993427482408294246), // 7 28 - PQP3(R3(.05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247), - .05048982259839636876305382298656247), + PQP3(R3(.05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247), .03189692783285757993427482408294246), // 8 32 - PQP3(R3(.05048982259839636876305382298656247, .05048982259839636876305382298656247, - .5 - (.05048982259839636876305382298656247)), + PQP3(R3(.05048982259839636876305382298656247, .05048982259839636876305382298656247, .5 - (.05048982259839636876305382298656247)), .03189692783285757993427482408294246), // 9 36 - PQP3(R3(.5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247, - .05048982259839636876305382298656247), + PQP3(R3(.5 - (.05048982259839636876305382298656247), .05048982259839636876305382298656247, .05048982259839636876305382298656247), .03189692783285757993427482408294246), // 10 40 PQP3(R3(.18883383102600104773643110385458576, .57517163758700002348324157702230752, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752)), + 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752)), .03720713072833462136961556119148112), // 11 44 - PQP3(R3(.18883383102600104773643110385458576, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), + PQP3(R3(.18883383102600104773643110385458576, 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .57517163758700002348324157702230752), .03720713072833462136961556119148112), // 12 48 PQP3(R3(.57517163758700002348324157702230752, .18883383102600104773643110385458576, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752)), + 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752)), .03720713072833462136961556119148112), // 13 52 - PQP3(R3(.57517163758700002348324157702230752, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), + PQP3(R3(.57517163758700002348324157702230752, 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 14 56 - PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), - .18883383102600104773643110385458576, .57517163758700002348324157702230752), + PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .18883383102600104773643110385458576, + .57517163758700002348324157702230752), .03720713072833462136961556119148112), // 15 60 - PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), - .57517163758700002348324157702230752, .18883383102600104773643110385458576), + PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .57517163758700002348324157702230752, + .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 16 64 PQP3(R3(.18883383102600104773643110385458576, .18883383102600104773643110385458576, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752)), + 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752)), .03720713072833462136961556119148112), // 17 68 - PQP3(R3(.18883383102600104773643110385458576, - 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), + PQP3(R3(.18883383102600104773643110385458576, 1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 18 72 - PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - - (.57517163758700002348324157702230752), - .18883383102600104773643110385458576, .18883383102600104773643110385458576), + PQP3(R3(1. - (.18883383102600104773643110385458576) - (.18883383102600104773643110385458576) - (.57517163758700002348324157702230752), .18883383102600104773643110385458576, + .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 19 76 - PQP3(R3(.18883383102600104773643110385458576, .18883383102600104773643110385458576, - .57517163758700002348324157702230752), + PQP3(R3(.18883383102600104773643110385458576, .18883383102600104773643110385458576, .57517163758700002348324157702230752), .03720713072833462136961556119148112), // 20 80 - PQP3(R3(.18883383102600104773643110385458576, .57517163758700002348324157702230752, - .18883383102600104773643110385458576), + PQP3(R3(.18883383102600104773643110385458576, .57517163758700002348324157702230752, .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 21 84 - PQP3(R3(.57517163758700002348324157702230752, .18883383102600104773643110385458576, - .18883383102600104773643110385458576), + PQP3(R3(.57517163758700002348324157702230752, .18883383102600104773643110385458576, .18883383102600104773643110385458576), .03720713072833462136961556119148112), // 22 88 PQP3(R3(.02126547254148324598883610149981994, .81083024109854856111810537984823239, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239)), + 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239)), .00811077082990334156610343349109654), // 23 92 - PQP3(R3(.02126547254148324598883610149981994, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), + PQP3(R3(.02126547254148324598883610149981994, 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .81083024109854856111810537984823239), .00811077082990334156610343349109654), // 24 96 PQP3(R3(.81083024109854856111810537984823239, .02126547254148324598883610149981994, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239)), + 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239)), .00811077082990334156610343349109654), // 25 100 - PQP3(R3(.81083024109854856111810537984823239, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), + PQP3(R3(.81083024109854856111810537984823239, 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 26 104 - PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), - .02126547254148324598883610149981994, .81083024109854856111810537984823239), + PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .02126547254148324598883610149981994, + .81083024109854856111810537984823239), .00811077082990334156610343349109654), // 27 108 - PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), - .81083024109854856111810537984823239, .02126547254148324598883610149981994), + PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .81083024109854856111810537984823239, + .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 28 112 PQP3(R3(.02126547254148324598883610149981994, .02126547254148324598883610149981994, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239)), + 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239)), .00811077082990334156610343349109654), // 29 116 - PQP3(R3(.02126547254148324598883610149981994, - 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), + PQP3(R3(.02126547254148324598883610149981994, 1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 30 120 - PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - - (.81083024109854856111810537984823239), - .02126547254148324598883610149981994, .02126547254148324598883610149981994), + PQP3(R3(1. - (.02126547254148324598883610149981994) - (.02126547254148324598883610149981994) - (.81083024109854856111810537984823239), .02126547254148324598883610149981994, + .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 31 124 - PQP3(R3(.02126547254148324598883610149981994, .02126547254148324598883610149981994, - .81083024109854856111810537984823239), + PQP3(R3(.02126547254148324598883610149981994, .02126547254148324598883610149981994, .81083024109854856111810537984823239), .00811077082990334156610343349109654), // 32 128 - PQP3(R3(.02126547254148324598883610149981994, .81083024109854856111810537984823239, - .02126547254148324598883610149981994), + PQP3(R3(.02126547254148324598883610149981994, .81083024109854856111810537984823239, .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 33 132 - PQP3(R3(.81083024109854856111810537984823239, .02126547254148324598883610149981994, - .02126547254148324598883610149981994), + PQP3(R3(.81083024109854856111810537984823239, .02126547254148324598883610149981994, .02126547254148324598883610149981994), .00811077082990334156610343349109654), // 34 136 }; PQF3 const QuadratureFormular_Tet_P7(7, 35, QF_TET_P7); // QUAD QUAD_3D_P8_ = { 46 184 PQP3 QF_TET_P8[] = { - PQP3(R3(.03967542307038990126507132953938949, .03967542307038990126507132953938949, - .03967542307038990126507132953938949), + PQP3(R3(.03967542307038990126507132953938949, .03967542307038990126507132953938949, .03967542307038990126507132953938949), .00639714777990232132145142033517302), // 0 0 - PQP3(R3(1. - 3. * (.03967542307038990126507132953938949), .03967542307038990126507132953938949, - .03967542307038990126507132953938949), + PQP3(R3(1. - 3. * (.03967542307038990126507132953938949), .03967542307038990126507132953938949, .03967542307038990126507132953938949), .00639714777990232132145142033517302), // 1 4 - PQP3(R3(.03967542307038990126507132953938949, 1. - 3. * (.03967542307038990126507132953938949), - .03967542307038990126507132953938949), + PQP3(R3(.03967542307038990126507132953938949, 1. - 3. * (.03967542307038990126507132953938949), .03967542307038990126507132953938949), .00639714777990232132145142033517302), // 2 8 - PQP3(R3(.03967542307038990126507132953938949, .03967542307038990126507132953938949, - 1. - 3. * (.03967542307038990126507132953938949)), + PQP3(R3(.03967542307038990126507132953938949, .03967542307038990126507132953938949, 1. - 3. * (.03967542307038990126507132953938949)), .00639714777990232132145142033517302), // 3 12 - PQP3(R3(.31448780069809631378416056269714830, .31448780069809631378416056269714830, - .31448780069809631378416056269714830), + PQP3(R3(.31448780069809631378416056269714830, .31448780069809631378416056269714830, .31448780069809631378416056269714830), .04019044802096617248816115847981783), // 4 16 - PQP3(R3(1. - 3. * (.31448780069809631378416056269714830), .31448780069809631378416056269714830, - .31448780069809631378416056269714830), + PQP3(R3(1. - 3. * (.31448780069809631378416056269714830), .31448780069809631378416056269714830, .31448780069809631378416056269714830), .04019044802096617248816115847981783), // 5 20 - PQP3(R3(.31448780069809631378416056269714830, 1. - 3. * (.31448780069809631378416056269714830), - .31448780069809631378416056269714830), + PQP3(R3(.31448780069809631378416056269714830, 1. - 3. * (.31448780069809631378416056269714830), .31448780069809631378416056269714830), .04019044802096617248816115847981783), // 6 24 - PQP3(R3(.31448780069809631378416056269714830, .31448780069809631378416056269714830, - 1. - 3. * (.31448780069809631378416056269714830)), + PQP3(R3(.31448780069809631378416056269714830, .31448780069809631378416056269714830, 1. - 3. * (.31448780069809631378416056269714830)), .04019044802096617248816115847981783), // 7 28 - PQP3(R3(.10198669306270330000000000000000000, .10198669306270330000000000000000000, - .10198669306270330000000000000000000), + PQP3(R3(.10198669306270330000000000000000000, .10198669306270330000000000000000000, .10198669306270330000000000000000000), .02430797550477032117486910877192260), // 8 32 - PQP3(R3(1. - 3. * (.10198669306270330000000000000000000), .10198669306270330000000000000000000, - .10198669306270330000000000000000000), + PQP3(R3(1. - 3. * (.10198669306270330000000000000000000), .10198669306270330000000000000000000, .10198669306270330000000000000000000), .02430797550477032117486910877192260), // 9 36 - PQP3(R3(.10198669306270330000000000000000000, 1. - 3. * (.10198669306270330000000000000000000), - .10198669306270330000000000000000000), + PQP3(R3(.10198669306270330000000000000000000, 1. - 3. * (.10198669306270330000000000000000000), .10198669306270330000000000000000000), .02430797550477032117486910877192260), // 10 40 - PQP3(R3(.10198669306270330000000000000000000, .10198669306270330000000000000000000, - 1. - 3. * (.10198669306270330000000000000000000)), + PQP3(R3(.10198669306270330000000000000000000, .10198669306270330000000000000000000, 1. - 3. * (.10198669306270330000000000000000000)), .02430797550477032117486910877192260), // 11 44 - PQP3(R3(.18420369694919151227594641734890918, .18420369694919151227594641734890918, - .18420369694919151227594641734890918), + PQP3(R3(.18420369694919151227594641734890918, .18420369694919151227594641734890918, .18420369694919151227594641734890918), .05485889241369744046692412399039144), // 12 48 - PQP3(R3(1. - 3. * (.18420369694919151227594641734890918), .18420369694919151227594641734890918, - .18420369694919151227594641734890918), + PQP3(R3(1. - 3. * (.18420369694919151227594641734890918), .18420369694919151227594641734890918, .18420369694919151227594641734890918), .05485889241369744046692412399039144), // 13 52 - PQP3(R3(.18420369694919151227594641734890918, 1. - 3. * (.18420369694919151227594641734890918), - .18420369694919151227594641734890918), + PQP3(R3(.18420369694919151227594641734890918, 1. - 3. * (.18420369694919151227594641734890918), .18420369694919151227594641734890918), .05485889241369744046692412399039144), // 14 56 - PQP3(R3(.18420369694919151227594641734890918, .18420369694919151227594641734890918, - 1. - 3. * (.18420369694919151227594641734890918)), + PQP3(R3(.18420369694919151227594641734890918, .18420369694919151227594641734890918, 1. - 3. * (.18420369694919151227594641734890918)), .05485889241369744046692412399039144), // 15 60 - PQP3(R3(.06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827), - .5 - (.06343628775453989240514123870189827)), + PQP3(R3(.06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827), .5 - (.06343628775453989240514123870189827)), .03571961223409918246495096899661762), // 16 64 - PQP3(R3(.5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827, - .5 - (.06343628775453989240514123870189827)), + PQP3(R3(.5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827)), .03571961223409918246495096899661762), // 17 68 - PQP3(R3(.5 - (.06343628775453989240514123870189827), .5 - (.06343628775453989240514123870189827), - .06343628775453989240514123870189827), + PQP3(R3(.5 - (.06343628775453989240514123870189827), .5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827), .03571961223409918246495096899661762), // 18 72 - PQP3(R3(.06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827), - .06343628775453989240514123870189827), + PQP3(R3(.06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827), .03571961223409918246495096899661762), // 19 76 - PQP3(R3(.06343628775453989240514123870189827, .06343628775453989240514123870189827, - .5 - (.06343628775453989240514123870189827)), + PQP3(R3(.06343628775453989240514123870189827, .06343628775453989240514123870189827, .5 - (.06343628775453989240514123870189827)), .03571961223409918246495096899661762), // 20 80 - PQP3(R3(.5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827, - .06343628775453989240514123870189827), + PQP3(R3(.5 - (.06343628775453989240514123870189827), .06343628775453989240514123870189827, .06343628775453989240514123870189827), .03571961223409918246495096899661762), // 21 84 PQP3(R3(.02169016206772800480266248262493018, .71993192203946593588943495335273478, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478)), + 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478)), .00718319069785253940945110521980376), // 22 88 - PQP3(R3(.02169016206772800480266248262493018, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), + PQP3(R3(.02169016206772800480266248262493018, 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .71993192203946593588943495335273478), .00718319069785253940945110521980376), // 23 92 PQP3(R3(.71993192203946593588943495335273478, .02169016206772800480266248262493018, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478)), + 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478)), .00718319069785253940945110521980376), // 24 96 - PQP3(R3(.71993192203946593588943495335273478, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), + PQP3(R3(.71993192203946593588943495335273478, 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 25 100 - PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), - .02169016206772800480266248262493018, .71993192203946593588943495335273478), + PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .02169016206772800480266248262493018, + .71993192203946593588943495335273478), .00718319069785253940945110521980376), // 26 104 - PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), - .71993192203946593588943495335273478, .02169016206772800480266248262493018), + PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .71993192203946593588943495335273478, + .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 27 108 PQP3(R3(.02169016206772800480266248262493018, .02169016206772800480266248262493018, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478)), + 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478)), .00718319069785253940945110521980376), // 28 112 - PQP3(R3(.02169016206772800480266248262493018, - 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), + PQP3(R3(.02169016206772800480266248262493018, 1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 29 116 - PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - - (.71993192203946593588943495335273478), - .02169016206772800480266248262493018, .02169016206772800480266248262493018), + PQP3(R3(1. - (.02169016206772800480266248262493018) - (.02169016206772800480266248262493018) - (.71993192203946593588943495335273478), .02169016206772800480266248262493018, + .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 30 120 - PQP3(R3(.02169016206772800480266248262493018, .02169016206772800480266248262493018, - .71993192203946593588943495335273478), + PQP3(R3(.02169016206772800480266248262493018, .02169016206772800480266248262493018, .71993192203946593588943495335273478), .00718319069785253940945110521980376), // 31 124 - PQP3(R3(.02169016206772800480266248262493018, .71993192203946593588943495335273478, - .02169016206772800480266248262493018), + PQP3(R3(.02169016206772800480266248262493018, .71993192203946593588943495335273478, .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 32 128 - PQP3(R3(.71993192203946593588943495335273478, .02169016206772800480266248262493018, - .02169016206772800480266248262493018), + PQP3(R3(.71993192203946593588943495335273478, .02169016206772800480266248262493018, .02169016206772800480266248262493018), .00718319069785253940945110521980376), // 33 132 PQP3(R3(.20448008063679571424133557487274534, .58057719012880922417539817139062041, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041)), + 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041)), .01637218194531911754093813975611913), // 34 136 - PQP3(R3(.20448008063679571424133557487274534, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), + PQP3(R3(.20448008063679571424133557487274534, 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .58057719012880922417539817139062041), .01637218194531911754093813975611913), // 35 140 PQP3(R3(.58057719012880922417539817139062041, .20448008063679571424133557487274534, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041)), + 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041)), .01637218194531911754093813975611913), // 36 144 - PQP3(R3(.58057719012880922417539817139062041, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), + PQP3(R3(.58057719012880922417539817139062041, 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 37 148 - PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), - .20448008063679571424133557487274534, .58057719012880922417539817139062041), + PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .20448008063679571424133557487274534, + .58057719012880922417539817139062041), .01637218194531911754093813975611913), // 38 152 - PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), - .58057719012880922417539817139062041, .20448008063679571424133557487274534), + PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .58057719012880922417539817139062041, + .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 39 156 PQP3(R3(.20448008063679571424133557487274534, .20448008063679571424133557487274534, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041)), + 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041)), .01637218194531911754093813975611913), // 40 160 - PQP3(R3(.20448008063679571424133557487274534, - 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), + PQP3(R3(.20448008063679571424133557487274534, 1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 41 164 - PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - - (.58057719012880922417539817139062041), - .20448008063679571424133557487274534, .20448008063679571424133557487274534), + PQP3(R3(1. - (.20448008063679571424133557487274534) - (.20448008063679571424133557487274534) - (.58057719012880922417539817139062041), .20448008063679571424133557487274534, + .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 42 168 - PQP3(R3(.20448008063679571424133557487274534, .20448008063679571424133557487274534, - .58057719012880922417539817139062041), + PQP3(R3(.20448008063679571424133557487274534, .20448008063679571424133557487274534, .58057719012880922417539817139062041), .01637218194531911754093813975611913), // 43 172 - PQP3(R3(.20448008063679571424133557487274534, .58057719012880922417539817139062041, - .20448008063679571424133557487274534), + PQP3(R3(.20448008063679571424133557487274534, .58057719012880922417539817139062041, .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 44 176 - PQP3(R3(.58057719012880922417539817139062041, .20448008063679571424133557487274534, - .20448008063679571424133557487274534), + PQP3(R3(.58057719012880922417539817139062041, .20448008063679571424133557487274534, .20448008063679571424133557487274534), .01637218194531911754093813975611913), // 45 180 }; PQF3 const QuadratureFormular_Tet_P8(8, 46, QF_TET_P8); // QUAD QUAD_3D_P9_ = { 59 236 PQP3 QF_TET_P9[] = { PQP3(R3(0.25, 0.25, 0.25), .05489853459364812686895885032391298), // 0 0 - PQP3(R3(.03785502061999503609086515586175707, .03785502061999503609086515586175707, - .03785502061999503609086515586175707), + PQP3(R3(.03785502061999503609086515586175707, .03785502061999503609086515586175707, .03785502061999503609086515586175707), .00421825735654367356185795185819147), // 1 4 - PQP3(R3(1. - 3. * (.03785502061999503609086515586175707), .03785502061999503609086515586175707, - .03785502061999503609086515586175707), + PQP3(R3(1. - 3. * (.03785502061999503609086515586175707), .03785502061999503609086515586175707, .03785502061999503609086515586175707), .00421825735654367356185795185819147), // 2 8 - PQP3(R3(.03785502061999503609086515586175707, 1. - 3. * (.03785502061999503609086515586175707), - .03785502061999503609086515586175707), + PQP3(R3(.03785502061999503609086515586175707, 1. - 3. * (.03785502061999503609086515586175707), .03785502061999503609086515586175707), .00421825735654367356185795185819147), // 3 12 - PQP3(R3(.03785502061999503609086515586175707, .03785502061999503609086515586175707, - 1. - 3. * (.03785502061999503609086515586175707)), + PQP3(R3(.03785502061999503609086515586175707, .03785502061999503609086515586175707, 1. - 3. * (.03785502061999503609086515586175707)), .00421825735654367356185795185819147), // 4 16 - PQP3(R3(.16954439965012220000000000000000000, .16954439965012220000000000000000000, - .16954439965012220000000000000000000), + PQP3(R3(.16954439965012220000000000000000000, .16954439965012220000000000000000000, .16954439965012220000000000000000000), .02348412311384798927791501022996111), // 5 20 - PQP3(R3(1. - 3. * (.16954439965012220000000000000000000), .16954439965012220000000000000000000, - .16954439965012220000000000000000000), + PQP3(R3(1. - 3. * (.16954439965012220000000000000000000), .16954439965012220000000000000000000, .16954439965012220000000000000000000), .02348412311384798927791501022996111), // 6 24 - PQP3(R3(.16954439965012220000000000000000000, 1. - 3. * (.16954439965012220000000000000000000), - .16954439965012220000000000000000000), + PQP3(R3(.16954439965012220000000000000000000, 1. - 3. * (.16954439965012220000000000000000000), .16954439965012220000000000000000000), .02348412311384798927791501022996111), // 7 28 - PQP3(R3(.16954439965012220000000000000000000, .16954439965012220000000000000000000, - 1. - 3. * (.16954439965012220000000000000000000)), + PQP3(R3(.16954439965012220000000000000000000, .16954439965012220000000000000000000, 1. - 3. * (.16954439965012220000000000000000000)), .02348412311384798927791501022996111), // 8 32 - PQP3(R3(.05484140424416689000000000000000000, .05484140424416689000000000000000000, - .05484140424416689000000000000000000), + PQP3(R3(.05484140424416689000000000000000000, .05484140424416689000000000000000000, .05484140424416689000000000000000000), .00421283454980389148648831814037819), // 9 36 - PQP3(R3(1. - 3. * (.05484140424416689000000000000000000), .05484140424416689000000000000000000, - .05484140424416689000000000000000000), + PQP3(R3(1. - 3. * (.05484140424416689000000000000000000), .05484140424416689000000000000000000, .05484140424416689000000000000000000), .00421283454980389148648831814037819), // 10 40 - PQP3(R3(.05484140424416689000000000000000000, 1. - 3. * (.05484140424416689000000000000000000), - .05484140424416689000000000000000000), + PQP3(R3(.05484140424416689000000000000000000, 1. - 3. * (.05484140424416689000000000000000000), .05484140424416689000000000000000000), .00421283454980389148648831814037819), // 11 44 - PQP3(R3(.05484140424416689000000000000000000, .05484140424416689000000000000000000, - 1. - 3. * (.05484140424416689000000000000000000)), + PQP3(R3(.05484140424416689000000000000000000, .05484140424416689000000000000000000, 1. - 3. * (.05484140424416689000000000000000000)), .00421283454980389148648831814037819), // 12 48 - PQP3(R3(.32229717190921058836777748445908171, .32229717190921058836777748445908171, - .32229717190921058836777748445908171), + PQP3(R3(.32229717190921058836777748445908171, .32229717190921058836777748445908171, .32229717190921058836777748445908171), .02994712640542812769203037546126163), // 13 52 - PQP3(R3(1. - 3. * (.32229717190921058836777748445908171), .32229717190921058836777748445908171, - .32229717190921058836777748445908171), + PQP3(R3(1. - 3. * (.32229717190921058836777748445908171), .32229717190921058836777748445908171, .32229717190921058836777748445908171), .02994712640542812769203037546126163), // 14 56 - PQP3(R3(.32229717190921058836777748445908171, 1. - 3. * (.32229717190921058836777748445908171), - .32229717190921058836777748445908171), + PQP3(R3(.32229717190921058836777748445908171, 1. - 3. * (.32229717190921058836777748445908171), .32229717190921058836777748445908171), .02994712640542812769203037546126163), // 15 60 - PQP3(R3(.32229717190921058836777748445908171, .32229717190921058836777748445908171, - 1. - 3. * (.32229717190921058836777748445908171)), + PQP3(R3(.32229717190921058836777748445908171, .32229717190921058836777748445908171, 1. - 3. * (.32229717190921058836777748445908171)), .02994712640542812769203037546126163), // 16 64 - PQP3(R3(.10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052), - .5 - (.10961777508972033704050355954365052)), + PQP3(R3(.10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052), .5 - (.10961777508972033704050355954365052)), .03695441750679136335292416138761121), // 17 68 - PQP3(R3(.5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052, - .5 - (.10961777508972033704050355954365052)), + PQP3(R3(.5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052)), .03695441750679136335292416138761121), // 18 72 - PQP3(R3(.5 - (.10961777508972033704050355954365052), .5 - (.10961777508972033704050355954365052), - .10961777508972033704050355954365052), + PQP3(R3(.5 - (.10961777508972033704050355954365052), .5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052), .03695441750679136335292416138761121), // 19 76 - PQP3(R3(.10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052), - .10961777508972033704050355954365052), + PQP3(R3(.10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052), .03695441750679136335292416138761121), // 20 80 - PQP3(R3(.10961777508972033704050355954365052, .10961777508972033704050355954365052, - .5 - (.10961777508972033704050355954365052)), + PQP3(R3(.10961777508972033704050355954365052, .10961777508972033704050355954365052, .5 - (.10961777508972033704050355954365052)), .03695441750679136335292416138761121), // 21 84 - PQP3(R3(.5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052, - .10961777508972033704050355954365052), + PQP3(R3(.5 - (.10961777508972033704050355954365052), .10961777508972033704050355954365052, .10961777508972033704050355954365052), .03695441750679136335292416138761121), // 22 88 PQP3(R3(.45915766038590539763886410168178216, .08004485927247373376034330857923567, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567)), + 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567)), .00817349224171051348425319650294732), // 23 92 - PQP3(R3(.45915766038590539763886410168178216, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), + PQP3(R3(.45915766038590539763886410168178216, 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .08004485927247373376034330857923567), .00817349224171051348425319650294732), // 24 96 PQP3(R3(.08004485927247373376034330857923567, .45915766038590539763886410168178216, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567)), + 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567)), .00817349224171051348425319650294732), // 25 100 - PQP3(R3(.08004485927247373376034330857923567, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), + PQP3(R3(.08004485927247373376034330857923567, 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 26 104 - PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), - .45915766038590539763886410168178216, .08004485927247373376034330857923567), + PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .45915766038590539763886410168178216, + .08004485927247373376034330857923567), .00817349224171051348425319650294732), // 27 108 - PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), - .08004485927247373376034330857923567, .45915766038590539763886410168178216), + PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .08004485927247373376034330857923567, + .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 28 112 PQP3(R3(.45915766038590539763886410168178216, .45915766038590539763886410168178216, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567)), + 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567)), .00817349224171051348425319650294732), // 29 116 - PQP3(R3(.45915766038590539763886410168178216, - 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), + PQP3(R3(.45915766038590539763886410168178216, 1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 30 120 - PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - - (.08004485927247373376034330857923567), - .45915766038590539763886410168178216, .45915766038590539763886410168178216), + PQP3(R3(1. - (.45915766038590539763886410168178216) - (.45915766038590539763886410168178216) - (.08004485927247373376034330857923567), .45915766038590539763886410168178216, + .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 31 124 - PQP3(R3(.45915766038590539763886410168178216, .45915766038590539763886410168178216, - .08004485927247373376034330857923567), + PQP3(R3(.45915766038590539763886410168178216, .45915766038590539763886410168178216, .08004485927247373376034330857923567), .00817349224171051348425319650294732), // 32 128 - PQP3(R3(.45915766038590539763886410168178216, .08004485927247373376034330857923567, - .45915766038590539763886410168178216), + PQP3(R3(.45915766038590539763886410168178216, .08004485927247373376034330857923567, .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 33 132 - PQP3(R3(.08004485927247373376034330857923567, .45915766038590539763886410168178216, - .45915766038590539763886410168178216), + PQP3(R3(.08004485927247373376034330857923567, .45915766038590539763886410168178216, .45915766038590539763886410168178216), .00817349224171051348425319650294732), // 34 136 PQP3(R3(.03296694775357210169727386483414899, .71879584022434055051132299796383374, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374)), + 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374)), .00987978656102278957913113314297149), // 35 140 - PQP3(R3(.03296694775357210169727386483414899, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), + PQP3(R3(.03296694775357210169727386483414899, 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .71879584022434055051132299796383374), .00987978656102278957913113314297149), // 36 144 PQP3(R3(.71879584022434055051132299796383374, .03296694775357210169727386483414899, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374)), + 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374)), .00987978656102278957913113314297149), // 37 148 - PQP3(R3(.71879584022434055051132299796383374, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), + PQP3(R3(.71879584022434055051132299796383374, 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 38 152 - PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), - .03296694775357210169727386483414899, .71879584022434055051132299796383374), + PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .03296694775357210169727386483414899, + .71879584022434055051132299796383374), .00987978656102278957913113314297149), // 39 156 - PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), - .71879584022434055051132299796383374, .03296694775357210169727386483414899), + PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .71879584022434055051132299796383374, + .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 40 160 PQP3(R3(.03296694775357210169727386483414899, .03296694775357210169727386483414899, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374)), + 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374)), .00987978656102278957913113314297149), // 41 164 - PQP3(R3(.03296694775357210169727386483414899, - 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), + PQP3(R3(.03296694775357210169727386483414899, 1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 42 168 - PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - - (.71879584022434055051132299796383374), - .03296694775357210169727386483414899, .03296694775357210169727386483414899), + PQP3(R3(1. - (.03296694775357210169727386483414899) - (.03296694775357210169727386483414899) - (.71879584022434055051132299796383374), .03296694775357210169727386483414899, + .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 43 172 - PQP3(R3(.03296694775357210169727386483414899, .03296694775357210169727386483414899, - .71879584022434055051132299796383374), + PQP3(R3(.03296694775357210169727386483414899, .03296694775357210169727386483414899, .71879584022434055051132299796383374), .00987978656102278957913113314297149), // 44 176 - PQP3(R3(.03296694775357210169727386483414899, .71879584022434055051132299796383374, - .03296694775357210169727386483414899), + PQP3(R3(.03296694775357210169727386483414899, .71879584022434055051132299796383374, .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 45 180 - PQP3(R3(.71879584022434055051132299796383374, .03296694775357210169727386483414899, - .03296694775357210169727386483414899), + PQP3(R3(.71879584022434055051132299796383374, .03296694775357210169727386483414899, .03296694775357210169727386483414899), .00987978656102278957913113314297149), // 46 184 PQP3(R3(.18174359672117481549870278661377760, .60023700739524674102301240348069459, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459)), + 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459)), .02160718741919244401497646690335203), // 47 188 - PQP3(R3(.18174359672117481549870278661377760, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), + PQP3(R3(.18174359672117481549870278661377760, 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .60023700739524674102301240348069459), .02160718741919244401497646690335203), // 48 192 PQP3(R3(.60023700739524674102301240348069459, .18174359672117481549870278661377760, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459)), + 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459)), .02160718741919244401497646690335203), // 49 196 - PQP3(R3(.60023700739524674102301240348069459, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), + PQP3(R3(.60023700739524674102301240348069459, 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 50 200 - PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), - .18174359672117481549870278661377760, .60023700739524674102301240348069459), + PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .18174359672117481549870278661377760, + .60023700739524674102301240348069459), .02160718741919244401497646690335203), // 51 204 - PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), - .60023700739524674102301240348069459, .18174359672117481549870278661377760), + PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .60023700739524674102301240348069459, + .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 52 208 PQP3(R3(.18174359672117481549870278661377760, .18174359672117481549870278661377760, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459)), + 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459)), .02160718741919244401497646690335203), // 53 212 - PQP3(R3(.18174359672117481549870278661377760, - 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), + PQP3(R3(.18174359672117481549870278661377760, 1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 54 216 - PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - - (.60023700739524674102301240348069459), - .18174359672117481549870278661377760, .18174359672117481549870278661377760), + PQP3(R3(1. - (.18174359672117481549870278661377760) - (.18174359672117481549870278661377760) - (.60023700739524674102301240348069459), .18174359672117481549870278661377760, + .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 55 220 - PQP3(R3(.18174359672117481549870278661377760, .18174359672117481549870278661377760, - .60023700739524674102301240348069459), + PQP3(R3(.18174359672117481549870278661377760, .18174359672117481549870278661377760, .60023700739524674102301240348069459), .02160718741919244401497646690335203), // 56 224 - PQP3(R3(.18174359672117481549870278661377760, .60023700739524674102301240348069459, - .18174359672117481549870278661377760), + PQP3(R3(.18174359672117481549870278661377760, .60023700739524674102301240348069459, .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 57 228 - PQP3(R3(.60023700739524674102301240348069459, .18174359672117481549870278661377760, - .18174359672117481549870278661377760), + PQP3(R3(.60023700739524674102301240348069459, .18174359672117481549870278661377760, .18174359672117481549870278661377760), .02160718741919244401497646690335203), // 58 232 }; PQF3 const QuadratureFormular_Tet_P9(9, 59, QF_TET_P9); // QUAD QUAD_3D_P10_ = { 79 316 PQP3 QF_TET_P10[] = { PQP3(R3(0.25, 0.25, 0.25), .04574189830483037077884770618329337), // 0 0 - PQP3(R3(.11425191803006935688146412277598412, .11425191803006935688146412277598412, - .11425191803006935688146412277598412), + PQP3(R3(.11425191803006935688146412277598412, .11425191803006935688146412277598412, .11425191803006935688146412277598412), .01092727610912416907498417206565671), // 1 4 - PQP3(R3(1. - 3. * (.11425191803006935688146412277598412), .11425191803006935688146412277598412, - .11425191803006935688146412277598412), + PQP3(R3(1. - 3. * (.11425191803006935688146412277598412), .11425191803006935688146412277598412, .11425191803006935688146412277598412), .01092727610912416907498417206565671), // 2 8 - PQP3(R3(.11425191803006935688146412277598412, 1. - 3. * (.11425191803006935688146412277598412), - .11425191803006935688146412277598412), + PQP3(R3(.11425191803006935688146412277598412, 1. - 3. * (.11425191803006935688146412277598412), .11425191803006935688146412277598412), .01092727610912416907498417206565671), // 3 12 - PQP3(R3(.11425191803006935688146412277598412, .11425191803006935688146412277598412, - 1. - 3. * (.11425191803006935688146412277598412)), + PQP3(R3(.11425191803006935688146412277598412, .11425191803006935688146412277598412, 1. - 3. * (.11425191803006935688146412277598412)), .01092727610912416907498417206565671), // 4 16 - PQP3(R3(.01063790234539248531264164411274776, .01063790234539248531264164411274776, - .01063790234539248531264164411274776), + PQP3(R3(.01063790234539248531264164411274776, .01063790234539248531264164411274776, .01063790234539248531264164411274776), .00055352334192264689534558564012282), // 5 20 - PQP3(R3(1. - 3. * (.01063790234539248531264164411274776), .01063790234539248531264164411274776, - .01063790234539248531264164411274776), + PQP3(R3(1. - 3. * (.01063790234539248531264164411274776), .01063790234539248531264164411274776, .01063790234539248531264164411274776), .00055352334192264689534558564012282), // 6 24 - PQP3(R3(.01063790234539248531264164411274776, 1. - 3. * (.01063790234539248531264164411274776), - .01063790234539248531264164411274776), + PQP3(R3(.01063790234539248531264164411274776, 1. - 3. * (.01063790234539248531264164411274776), .01063790234539248531264164411274776), .00055352334192264689534558564012282), // 7 28 - PQP3(R3(.01063790234539248531264164411274776, .01063790234539248531264164411274776, - 1. - 3. * (.01063790234539248531264164411274776)), + PQP3(R3(.01063790234539248531264164411274776, .01063790234539248531264164411274776, 1. - 3. * (.01063790234539248531264164411274776)), .00055352334192264689534558564012282), // 8 32 - PQP3(R3(.31274070833535645859816704980806110, .31274070833535645859816704980806110, - .31274070833535645859816704980806110), + PQP3(R3(.31274070833535645859816704980806110, .31274070833535645859816704980806110, .31274070833535645859816704980806110), .02569337913913269580782688316792080), // 9 36 - PQP3(R3(1. - 3. * (.31274070833535645859816704980806110), .31274070833535645859816704980806110, - .31274070833535645859816704980806110), + PQP3(R3(1. - 3. * (.31274070833535645859816704980806110), .31274070833535645859816704980806110, .31274070833535645859816704980806110), .02569337913913269580782688316792080), // 10 40 - PQP3(R3(.31274070833535645859816704980806110, 1. - 3. * (.31274070833535645859816704980806110), - .31274070833535645859816704980806110), + PQP3(R3(.31274070833535645859816704980806110, 1. - 3. * (.31274070833535645859816704980806110), .31274070833535645859816704980806110), .02569337913913269580782688316792080), // 11 44 - PQP3(R3(.31274070833535645859816704980806110, .31274070833535645859816704980806110, - 1. - 3. * (.31274070833535645859816704980806110)), + PQP3(R3(.31274070833535645859816704980806110, .31274070833535645859816704980806110, 1. - 3. * (.31274070833535645859816704980806110)), .02569337913913269580782688316792080), // 12 48 - PQP3(R3(.01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000), - .5 - (.01631296303281644000000000000000000)), + PQP3(R3(.01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000), .5 - (.01631296303281644000000000000000000)), .00055387649657283109312967562590035), // 13 52 - PQP3(R3(.5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000, - .5 - (.01631296303281644000000000000000000)), + PQP3(R3(.5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000)), .00055387649657283109312967562590035), // 14 56 - PQP3(R3(.5 - (.01631296303281644000000000000000000), .5 - (.01631296303281644000000000000000000), - .01631296303281644000000000000000000), + PQP3(R3(.5 - (.01631296303281644000000000000000000), .5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000), .00055387649657283109312967562590035), // 15 60 - PQP3(R3(.01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000), - .01631296303281644000000000000000000), + PQP3(R3(.01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000), .00055387649657283109312967562590035), // 16 64 - PQP3(R3(.01631296303281644000000000000000000, .01631296303281644000000000000000000, - .5 - (.01631296303281644000000000000000000)), + PQP3(R3(.01631296303281644000000000000000000, .01631296303281644000000000000000000, .5 - (.01631296303281644000000000000000000)), .00055387649657283109312967562590035), // 17 68 - PQP3(R3(.5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000, - .01631296303281644000000000000000000), + PQP3(R3(.5 - (.01631296303281644000000000000000000), .01631296303281644000000000000000000, .01631296303281644000000000000000000), .00055387649657283109312967562590035), // 18 72 PQP3(R3(.03430622963180452385835196582344460, .59830121060139461905983787517050400, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400)), + 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400)), .01044842402938294329072628200105773), // 19 76 - PQP3(R3(.03430622963180452385835196582344460, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), + PQP3(R3(.03430622963180452385835196582344460, 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .59830121060139461905983787517050400), .01044842402938294329072628200105773), // 20 80 PQP3(R3(.59830121060139461905983787517050400, .03430622963180452385835196582344460, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400)), + 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400)), .01044842402938294329072628200105773), // 21 84 - PQP3(R3(.59830121060139461905983787517050400, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), + PQP3(R3(.59830121060139461905983787517050400, 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 22 88 - PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), - .03430622963180452385835196582344460, .59830121060139461905983787517050400), + PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .03430622963180452385835196582344460, + .59830121060139461905983787517050400), .01044842402938294329072628200105773), // 23 92 - PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), - .59830121060139461905983787517050400, .03430622963180452385835196582344460), + PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .59830121060139461905983787517050400, + .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 24 96 PQP3(R3(.03430622963180452385835196582344460, .03430622963180452385835196582344460, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400)), + 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400)), .01044842402938294329072628200105773), // 25 100 - PQP3(R3(.03430622963180452385835196582344460, - 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), + PQP3(R3(.03430622963180452385835196582344460, 1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 26 104 - PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - - (.59830121060139461905983787517050400), - .03430622963180452385835196582344460, .03430622963180452385835196582344460), + PQP3(R3(1. - (.03430622963180452385835196582344460) - (.03430622963180452385835196582344460) - (.59830121060139461905983787517050400), .03430622963180452385835196582344460, + .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 27 108 - PQP3(R3(.03430622963180452385835196582344460, .03430622963180452385835196582344460, - .59830121060139461905983787517050400), + PQP3(R3(.03430622963180452385835196582344460, .03430622963180452385835196582344460, .59830121060139461905983787517050400), .01044842402938294329072628200105773), // 28 112 - PQP3(R3(.03430622963180452385835196582344460, .59830121060139461905983787517050400, - .03430622963180452385835196582344460), + PQP3(R3(.03430622963180452385835196582344460, .59830121060139461905983787517050400, .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 29 116 - PQP3(R3(.59830121060139461905983787517050400, .03430622963180452385835196582344460, - .03430622963180452385835196582344460), + PQP3(R3(.59830121060139461905983787517050400, .03430622963180452385835196582344460, .03430622963180452385835196582344460), .01044842402938294329072628200105773), // 30 120 PQP3(R3(.12346418534551115945916818783743644, .47120066204746310257913700590727081, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081)), + 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081)), .02513844602651287118280517785487423), // 31 124 - PQP3(R3(.12346418534551115945916818783743644, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), + PQP3(R3(.12346418534551115945916818783743644, 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .47120066204746310257913700590727081), .02513844602651287118280517785487423), // 32 128 PQP3(R3(.47120066204746310257913700590727081, .12346418534551115945916818783743644, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081)), + 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081)), .02513844602651287118280517785487423), // 33 132 - PQP3(R3(.47120066204746310257913700590727081, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), + PQP3(R3(.47120066204746310257913700590727081, 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 34 136 - PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), - .12346418534551115945916818783743644, .47120066204746310257913700590727081), + PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .12346418534551115945916818783743644, + .47120066204746310257913700590727081), .02513844602651287118280517785487423), // 35 140 - PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), - .47120066204746310257913700590727081, .12346418534551115945916818783743644), + PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .47120066204746310257913700590727081, + .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 36 144 PQP3(R3(.12346418534551115945916818783743644, .12346418534551115945916818783743644, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081)), + 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081)), .02513844602651287118280517785487423), // 37 148 - PQP3(R3(.12346418534551115945916818783743644, - 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), + PQP3(R3(.12346418534551115945916818783743644, 1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 38 152 - PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - - (.47120066204746310257913700590727081), - .12346418534551115945916818783743644, .12346418534551115945916818783743644), + PQP3(R3(1. - (.12346418534551115945916818783743644) - (.12346418534551115945916818783743644) - (.47120066204746310257913700590727081), .12346418534551115945916818783743644, + .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 39 156 - PQP3(R3(.12346418534551115945916818783743644, .12346418534551115945916818783743644, - .47120066204746310257913700590727081), + PQP3(R3(.12346418534551115945916818783743644, .12346418534551115945916818783743644, .47120066204746310257913700590727081), .02513844602651287118280517785487423), // 40 160 - PQP3(R3(.12346418534551115945916818783743644, .47120066204746310257913700590727081, - .12346418534551115945916818783743644), + PQP3(R3(.12346418534551115945916818783743644, .47120066204746310257913700590727081, .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 41 164 - PQP3(R3(.47120066204746310257913700590727081, .12346418534551115945916818783743644, - .12346418534551115945916818783743644), + PQP3(R3(.47120066204746310257913700590727081, .12346418534551115945916818783743644, .12346418534551115945916818783743644), .02513844602651287118280517785487423), // 42 168 PQP3(R3(.40991962933181117418479812480531207, .16546413290740130923509687990363569, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569)), + 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569)), .01178620679249594711782155323755017), // 43 172 - PQP3(R3(.40991962933181117418479812480531207, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), + PQP3(R3(.40991962933181117418479812480531207, 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .16546413290740130923509687990363569), .01178620679249594711782155323755017), // 44 176 PQP3(R3(.16546413290740130923509687990363569, .40991962933181117418479812480531207, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569)), + 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569)), .01178620679249594711782155323755017), // 45 180 - PQP3(R3(.16546413290740130923509687990363569, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), + PQP3(R3(.16546413290740130923509687990363569, 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 46 184 - PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), - .40991962933181117418479812480531207, .16546413290740130923509687990363569), + PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .40991962933181117418479812480531207, + .16546413290740130923509687990363569), .01178620679249594711782155323755017), // 47 188 - PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), - .16546413290740130923509687990363569, .40991962933181117418479812480531207), + PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .16546413290740130923509687990363569, + .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 48 192 PQP3(R3(.40991962933181117418479812480531207, .40991962933181117418479812480531207, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569)), + 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569)), .01178620679249594711782155323755017), // 49 196 - PQP3(R3(.40991962933181117418479812480531207, - 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), + PQP3(R3(.40991962933181117418479812480531207, 1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 50 200 - PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - - (.16546413290740130923509687990363569), - .40991962933181117418479812480531207, .40991962933181117418479812480531207), + PQP3(R3(1. - (.40991962933181117418479812480531207) - (.40991962933181117418479812480531207) - (.16546413290740130923509687990363569), .40991962933181117418479812480531207, + .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 51 204 - PQP3(R3(.40991962933181117418479812480531207, .40991962933181117418479812480531207, - .16546413290740130923509687990363569), + PQP3(R3(.40991962933181117418479812480531207, .40991962933181117418479812480531207, .16546413290740130923509687990363569), .01178620679249594711782155323755017), // 52 208 - PQP3(R3(.40991962933181117418479812480531207, .16546413290740130923509687990363569, - .40991962933181117418479812480531207), + PQP3(R3(.40991962933181117418479812480531207, .16546413290740130923509687990363569, .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 53 212 - PQP3(R3(.16546413290740130923509687990363569, .40991962933181117418479812480531207, - .40991962933181117418479812480531207), + PQP3(R3(.16546413290740130923509687990363569, .40991962933181117418479812480531207, .40991962933181117418479812480531207), .01178620679249594711782155323755017), // 54 216 PQP3(R3(.17397243903011716743177479785668929, .62916375300275643773181882027844514, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514)), + 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514)), .01332022473886650471019828463616468), // 55 220 - PQP3(R3(.17397243903011716743177479785668929, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), + PQP3(R3(.17397243903011716743177479785668929, 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .62916375300275643773181882027844514), .01332022473886650471019828463616468), // 56 224 PQP3(R3(.62916375300275643773181882027844514, .17397243903011716743177479785668929, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514)), + 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514)), .01332022473886650471019828463616468), // 57 228 - PQP3(R3(.62916375300275643773181882027844514, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), + PQP3(R3(.62916375300275643773181882027844514, 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 58 232 - PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), - .17397243903011716743177479785668929, .62916375300275643773181882027844514), + PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .17397243903011716743177479785668929, + .62916375300275643773181882027844514), .01332022473886650471019828463616468), // 59 236 - PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), - .62916375300275643773181882027844514, .17397243903011716743177479785668929), + PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .62916375300275643773181882027844514, + .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 60 240 PQP3(R3(.17397243903011716743177479785668929, .17397243903011716743177479785668929, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514)), + 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514)), .01332022473886650471019828463616468), // 61 244 - PQP3(R3(.17397243903011716743177479785668929, - 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), + PQP3(R3(.17397243903011716743177479785668929, 1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 62 248 - PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - - (.62916375300275643773181882027844514), - .17397243903011716743177479785668929, .17397243903011716743177479785668929), + PQP3(R3(1. - (.17397243903011716743177479785668929) - (.17397243903011716743177479785668929) - (.62916375300275643773181882027844514), .17397243903011716743177479785668929, + .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 63 252 - PQP3(R3(.17397243903011716743177479785668929, .17397243903011716743177479785668929, - .62916375300275643773181882027844514), + PQP3(R3(.17397243903011716743177479785668929, .17397243903011716743177479785668929, .62916375300275643773181882027844514), .01332022473886650471019828463616468), // 64 256 - PQP3(R3(.17397243903011716743177479785668929, .62916375300275643773181882027844514, - .17397243903011716743177479785668929), + PQP3(R3(.17397243903011716743177479785668929, .62916375300275643773181882027844514, .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 65 260 - PQP3(R3(.62916375300275643773181882027844514, .17397243903011716743177479785668929, - .17397243903011716743177479785668929), + PQP3(R3(.62916375300275643773181882027844514, .17397243903011716743177479785668929, .17397243903011716743177479785668929), .01332022473886650471019828463616468), // 66 264 PQP3(R3(.03002157005631784150255786784038011, .81213056814351208262160080755918730, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730)), + 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730)), .00615987577565961666092767531756180), // 67 268 - PQP3(R3(.03002157005631784150255786784038011, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), + PQP3(R3(.03002157005631784150255786784038011, 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .81213056814351208262160080755918730), .00615987577565961666092767531756180), // 68 272 PQP3(R3(.81213056814351208262160080755918730, .03002157005631784150255786784038011, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730)), + 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730)), .00615987577565961666092767531756180), // 69 276 - PQP3(R3(.81213056814351208262160080755918730, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), + PQP3(R3(.81213056814351208262160080755918730, 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 70 280 - PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), - .03002157005631784150255786784038011, .81213056814351208262160080755918730), + PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .03002157005631784150255786784038011, + .81213056814351208262160080755918730), .00615987577565961666092767531756180), // 71 284 - PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), - .81213056814351208262160080755918730, .03002157005631784150255786784038011), + PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .81213056814351208262160080755918730, + .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 72 288 PQP3(R3(.03002157005631784150255786784038011, .03002157005631784150255786784038011, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730)), + 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730)), .00615987577565961666092767531756180), // 73 292 - PQP3(R3(.03002157005631784150255786784038011, - 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), + PQP3(R3(.03002157005631784150255786784038011, 1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 74 296 - PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - - (.81213056814351208262160080755918730), - .03002157005631784150255786784038011, .03002157005631784150255786784038011), + PQP3(R3(1. - (.03002157005631784150255786784038011) - (.03002157005631784150255786784038011) - (.81213056814351208262160080755918730), .03002157005631784150255786784038011, + .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 75 300 - PQP3(R3(.03002157005631784150255786784038011, .03002157005631784150255786784038011, - .81213056814351208262160080755918730), + PQP3(R3(.03002157005631784150255786784038011, .03002157005631784150255786784038011, .81213056814351208262160080755918730), .00615987577565961666092767531756180), // 76 304 - PQP3(R3(.03002157005631784150255786784038011, .81213056814351208262160080755918730, - .03002157005631784150255786784038011), + PQP3(R3(.03002157005631784150255786784038011, .81213056814351208262160080755918730, .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 77 308 - PQP3(R3(.81213056814351208262160080755918730, .03002157005631784150255786784038011, - .03002157005631784150255786784038011), + PQP3(R3(.81213056814351208262160080755918730, .03002157005631784150255786784038011, .03002157005631784150255786784038011), .00615987577565961666092767531756180), // 78 312 }; PQF3 const QuadratureFormular_Tet_P10(10, 79, QF_TET_P10); // QUAD QUAD_3D_P11_ = { 96 384 PQP3 QF_TET_P11[] = { - PQP3(R3(.12460560449278830000000000000000000, .12460560449278830000000000000000000, - .12460560449278830000000000000000000), + PQP3(R3(.12460560449278830000000000000000000, .12460560449278830000000000000000000, .12460560449278830000000000000000000), .01612698613577620369120244222737879), // 0 0 - PQP3(R3(1. - 3. * (.12460560449278830000000000000000000), .12460560449278830000000000000000000, - .12460560449278830000000000000000000), + PQP3(R3(1. - 3. * (.12460560449278830000000000000000000), .12460560449278830000000000000000000, .12460560449278830000000000000000000), .01612698613577620369120244222737879), // 1 4 - PQP3(R3(.12460560449278830000000000000000000, 1. - 3. * (.12460560449278830000000000000000000), - .12460560449278830000000000000000000), + PQP3(R3(.12460560449278830000000000000000000, 1. - 3. * (.12460560449278830000000000000000000), .12460560449278830000000000000000000), .01612698613577620369120244222737879), // 2 8 - PQP3(R3(.12460560449278830000000000000000000, .12460560449278830000000000000000000, - 1. - 3. * (.12460560449278830000000000000000000)), + PQP3(R3(.12460560449278830000000000000000000, .12460560449278830000000000000000000, 1. - 3. * (.12460560449278830000000000000000000)), .01612698613577620369120244222737879), // 3 12 - PQP3(R3(.02609630765687464746851542316261877, .02609630765687464746851542316261877, - .02609630765687464746851542316261877), + PQP3(R3(.02609630765687464746851542316261877, .02609630765687464746851542316261877, .02609630765687464746851542316261877), .00178872341812357138976990346996962), // 4 16 - PQP3(R3(1. - 3. * (.02609630765687464746851542316261877), .02609630765687464746851542316261877, - .02609630765687464746851542316261877), + PQP3(R3(1. - 3. * (.02609630765687464746851542316261877), .02609630765687464746851542316261877, .02609630765687464746851542316261877), .00178872341812357138976990346996962), // 5 20 - PQP3(R3(.02609630765687464746851542316261877, 1. - 3. * (.02609630765687464746851542316261877), - .02609630765687464746851542316261877), + PQP3(R3(.02609630765687464746851542316261877, 1. - 3. * (.02609630765687464746851542316261877), .02609630765687464746851542316261877), .00178872341812357138976990346996962), // 6 24 - PQP3(R3(.02609630765687464746851542316261877, .02609630765687464746851542316261877, - 1. - 3. * (.02609630765687464746851542316261877)), + PQP3(R3(.02609630765687464746851542316261877, .02609630765687464746851542316261877, 1. - 3. * (.02609630765687464746851542316261877)), .00178872341812357138976990346996962), // 7 28 - PQP3(R3(.07193883255798884087330011042809557, .07193883255798884087330011042809557, - .07193883255798884087330011042809557), + PQP3(R3(.07193883255798884087330011042809557, .07193883255798884087330011042809557, .07193883255798884087330011042809557), .00847529348343123401863799968389086), // 8 32 - PQP3(R3(1. - 3. * (.07193883255798884087330011042809557), .07193883255798884087330011042809557, - .07193883255798884087330011042809557), + PQP3(R3(1. - 3. * (.07193883255798884087330011042809557), .07193883255798884087330011042809557, .07193883255798884087330011042809557), .00847529348343123401863799968389086), // 9 36 - PQP3(R3(.07193883255798884087330011042809557, 1. - 3. * (.07193883255798884087330011042809557), - .07193883255798884087330011042809557), + PQP3(R3(.07193883255798884087330011042809557, 1. - 3. * (.07193883255798884087330011042809557), .07193883255798884087330011042809557), .00847529348343123401863799968389086), // 10 40 - PQP3(R3(.07193883255798884087330011042809557, .07193883255798884087330011042809557, - 1. - 3. * (.07193883255798884087330011042809557)), + PQP3(R3(.07193883255798884087330011042809557, .07193883255798884087330011042809557, 1. - 3. * (.07193883255798884087330011042809557)), .00847529348343123401863799968389086), // 11 44 - PQP3(R3(.32611122454203676937273102302894204, .32611122454203676937273102302894204, - .32611122454203676937273102302894204), + PQP3(R3(.32611122454203676937273102302894204, .32611122454203676937273102302894204, .32611122454203676937273102302894204), .01238021263944669050859562763135516), // 12 48 - PQP3(R3(1. - 3. * (.32611122454203676937273102302894204), .32611122454203676937273102302894204, - .32611122454203676937273102302894204), + PQP3(R3(1. - 3. * (.32611122454203676937273102302894204), .32611122454203676937273102302894204, .32611122454203676937273102302894204), .01238021263944669050859562763135516), // 13 52 - PQP3(R3(.32611122454203676937273102302894204, 1. - 3. * (.32611122454203676937273102302894204), - .32611122454203676937273102302894204), + PQP3(R3(.32611122454203676937273102302894204, 1. - 3. * (.32611122454203676937273102302894204), .32611122454203676937273102302894204), .01238021263944669050859562763135516), // 14 56 - PQP3(R3(.32611122454203676937273102302894204, .32611122454203676937273102302894204, - 1. - 3. * (.32611122454203676937273102302894204)), + PQP3(R3(.32611122454203676937273102302894204, .32611122454203676937273102302894204, 1. - 3. * (.32611122454203676937273102302894204)), .01238021263944669050859562763135516), // 15 60 - PQP3(R3(.29405882789858127213310307732130217, .29405882789858127213310307732130217, - .29405882789858127213310307732130217), + PQP3(R3(.29405882789858127213310307732130217, .29405882789858127213310307732130217, .29405882789858127213310307732130217), .02205586697199415746140963638568037), // 16 64 - PQP3(R3(1. - 3. * (.29405882789858127213310307732130217), .29405882789858127213310307732130217, - .29405882789858127213310307732130217), + PQP3(R3(1. - 3. * (.29405882789858127213310307732130217), .29405882789858127213310307732130217, .29405882789858127213310307732130217), .02205586697199415746140963638568037), // 17 68 - PQP3(R3(.29405882789858127213310307732130217, 1. - 3. * (.29405882789858127213310307732130217), - .29405882789858127213310307732130217), + PQP3(R3(.29405882789858127213310307732130217, 1. - 3. * (.29405882789858127213310307732130217), .29405882789858127213310307732130217), .02205586697199415746140963638568037), // 18 72 - PQP3(R3(.29405882789858127213310307732130217, .29405882789858127213310307732130217, - 1. - 3. * (.29405882789858127213310307732130217)), + PQP3(R3(.29405882789858127213310307732130217, .29405882789858127213310307732130217, 1. - 3. * (.29405882789858127213310307732130217)), .02205586697199415746140963638568037), // 19 76 - PQP3(R3(.19271399104965490000000000000000000, .19271399104965490000000000000000000, - .19271399104965490000000000000000000), + PQP3(R3(.19271399104965490000000000000000000, .19271399104965490000000000000000000, .19271399104965490000000000000000000), .02295765467664274421265594265203307), // 20 80 - PQP3(R3(1. - 3. * (.19271399104965490000000000000000000), .19271399104965490000000000000000000, - .19271399104965490000000000000000000), + PQP3(R3(1. - 3. * (.19271399104965490000000000000000000), .19271399104965490000000000000000000, .19271399104965490000000000000000000), .02295765467664274421265594265203307), // 21 84 - PQP3(R3(.19271399104965490000000000000000000, 1. - 3. * (.19271399104965490000000000000000000), - .19271399104965490000000000000000000), + PQP3(R3(.19271399104965490000000000000000000, 1. - 3. * (.19271399104965490000000000000000000), .19271399104965490000000000000000000), .02295765467664274421265594265203307), // 22 88 - PQP3(R3(.19271399104965490000000000000000000, .19271399104965490000000000000000000, - 1. - 3. * (.19271399104965490000000000000000000)), + PQP3(R3(.19271399104965490000000000000000000, .19271399104965490000000000000000000, 1. - 3. * (.19271399104965490000000000000000000)), .02295765467664274421265594265203307), // 23 92 - PQP3(R3(.00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225), - .5 - (.00047127204692773946587837159205225)), + PQP3(R3(.00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225), .5 - (.00047127204692773946587837159205225)), .00120553827014535727045055662252294), // 24 96 - PQP3(R3(.5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225, - .5 - (.00047127204692773946587837159205225)), + PQP3(R3(.5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225)), .00120553827014535727045055662252294), // 25 100 - PQP3(R3(.5 - (.00047127204692773946587837159205225), .5 - (.00047127204692773946587837159205225), - .00047127204692773946587837159205225), + PQP3(R3(.5 - (.00047127204692773946587837159205225), .5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225), .00120553827014535727045055662252294), // 26 104 - PQP3(R3(.00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225), - .00047127204692773946587837159205225), + PQP3(R3(.00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225), .00120553827014535727045055662252294), // 27 108 - PQP3(R3(.00047127204692773946587837159205225, .00047127204692773946587837159205225, - .5 - (.00047127204692773946587837159205225)), + PQP3(R3(.00047127204692773946587837159205225, .00047127204692773946587837159205225, .5 - (.00047127204692773946587837159205225)), .00120553827014535727045055662252294), // 28 112 - PQP3(R3(.5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225, - .00047127204692773946587837159205225), + PQP3(R3(.5 - (.00047127204692773946587837159205225), .00047127204692773946587837159205225, .00047127204692773946587837159205225), .00120553827014535727045055662252294), // 29 116 - PQP3(R3(.10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539), - .5 - (.10321360207480949336085123341390539)), + PQP3(R3(.10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539), .5 - (.10321360207480949336085123341390539)), .02479381575164443454447803302296997), // 30 120 - PQP3(R3(.5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539, - .5 - (.10321360207480949336085123341390539)), + PQP3(R3(.5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539)), .02479381575164443454447803302296997), // 31 124 - PQP3(R3(.5 - (.10321360207480949336085123341390539), .5 - (.10321360207480949336085123341390539), - .10321360207480949336085123341390539), + PQP3(R3(.5 - (.10321360207480949336085123341390539), .5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539), .02479381575164443454447803302296997), // 32 128 - PQP3(R3(.10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539), - .10321360207480949336085123341390539), + PQP3(R3(.10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539), .02479381575164443454447803302296997), // 33 132 - PQP3(R3(.10321360207480949336085123341390539, .10321360207480949336085123341390539, - .5 - (.10321360207480949336085123341390539)), + PQP3(R3(.10321360207480949336085123341390539, .10321360207480949336085123341390539, .5 - (.10321360207480949336085123341390539)), .02479381575164443454447803302296997), // 34 136 - PQP3(R3(.5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539, - .10321360207480949336085123341390539), + PQP3(R3(.5 - (.10321360207480949336085123341390539), .10321360207480949336085123341390539, .10321360207480949336085123341390539), .02479381575164443454447803302296997), // 35 140 PQP3(R3(.04349989920159741251267172033621503, .63045319723555591476353398203997141, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141)), + 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141)), .01203878836480353606935457416590660), // 36 144 - PQP3(R3(.04349989920159741251267172033621503, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), + PQP3(R3(.04349989920159741251267172033621503, 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .63045319723555591476353398203997141), .01203878836480353606935457416590660), // 37 148 PQP3(R3(.63045319723555591476353398203997141, .04349989920159741251267172033621503, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141)), + 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141)), .01203878836480353606935457416590660), // 38 152 - PQP3(R3(.63045319723555591476353398203997141, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), + PQP3(R3(.63045319723555591476353398203997141, 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 39 156 - PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), - .04349989920159741251267172033621503, .63045319723555591476353398203997141), + PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .04349989920159741251267172033621503, + .63045319723555591476353398203997141), .01203878836480353606935457416590660), // 40 160 - PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), - .63045319723555591476353398203997141, .04349989920159741251267172033621503), + PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .63045319723555591476353398203997141, + .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 41 164 PQP3(R3(.04349989920159741251267172033621503, .04349989920159741251267172033621503, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141)), + 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141)), .01203878836480353606935457416590660), // 42 168 - PQP3(R3(.04349989920159741251267172033621503, - 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), + PQP3(R3(.04349989920159741251267172033621503, 1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 43 172 - PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - - (.63045319723555591476353398203997141), - .04349989920159741251267172033621503, .04349989920159741251267172033621503), + PQP3(R3(1. - (.04349989920159741251267172033621503) - (.04349989920159741251267172033621503) - (.63045319723555591476353398203997141), .04349989920159741251267172033621503, + .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 44 176 - PQP3(R3(.04349989920159741251267172033621503, .04349989920159741251267172033621503, - .63045319723555591476353398203997141), + PQP3(R3(.04349989920159741251267172033621503, .04349989920159741251267172033621503, .63045319723555591476353398203997141), .01203878836480353606935457416590660), // 45 180 - PQP3(R3(.04349989920159741251267172033621503, .63045319723555591476353398203997141, - .04349989920159741251267172033621503), + PQP3(R3(.04349989920159741251267172033621503, .63045319723555591476353398203997141, .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 46 184 - PQP3(R3(.63045319723555591476353398203997141, .04349989920159741251267172033621503, - .04349989920159741251267172033621503), + PQP3(R3(.63045319723555591476353398203997141, .04349989920159741251267172033621503, .04349989920159741251267172033621503), .01203878836480353606935457416590660), // 47 188 PQP3(R3(.01414839289422299290755441603794058, .82491678632147090000000000000000000, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000)), + 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000)), .00189370204498242146248858917618493), // 48 192 - PQP3(R3(.01414839289422299290755441603794058, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), + PQP3(R3(.01414839289422299290755441603794058, 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .82491678632147090000000000000000000), .00189370204498242146248858917618493), // 49 196 PQP3(R3(.82491678632147090000000000000000000, .01414839289422299290755441603794058, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000)), + 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000)), .00189370204498242146248858917618493), // 50 200 - PQP3(R3(.82491678632147090000000000000000000, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), + PQP3(R3(.82491678632147090000000000000000000, 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 51 204 - PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), - .01414839289422299290755441603794058, .82491678632147090000000000000000000), + PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .01414839289422299290755441603794058, + .82491678632147090000000000000000000), .00189370204498242146248858917618493), // 52 208 - PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), - .82491678632147090000000000000000000, .01414839289422299290755441603794058), + PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .82491678632147090000000000000000000, + .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 53 212 PQP3(R3(.01414839289422299290755441603794058, .01414839289422299290755441603794058, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000)), + 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000)), .00189370204498242146248858917618493), // 54 216 - PQP3(R3(.01414839289422299290755441603794058, - 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), + PQP3(R3(.01414839289422299290755441603794058, 1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 55 220 - PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - - (.82491678632147090000000000000000000), - .01414839289422299290755441603794058, .01414839289422299290755441603794058), + PQP3(R3(1. - (.01414839289422299290755441603794058) - (.01414839289422299290755441603794058) - (.82491678632147090000000000000000000), .01414839289422299290755441603794058, + .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 56 224 - PQP3(R3(.01414839289422299290755441603794058, .01414839289422299290755441603794058, - .82491678632147090000000000000000000), + PQP3(R3(.01414839289422299290755441603794058, .01414839289422299290755441603794058, .82491678632147090000000000000000000), .00189370204498242146248858917618493), // 57 228 - PQP3(R3(.01414839289422299290755441603794058, .82491678632147090000000000000000000, - .01414839289422299290755441603794058), + PQP3(R3(.01414839289422299290755441603794058, .82491678632147090000000000000000000, .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 58 232 - PQP3(R3(.82491678632147090000000000000000000, .01414839289422299290755441603794058, - .01414839289422299290755441603794058), + PQP3(R3(.82491678632147090000000000000000000, .01414839289422299290755441603794058, .01414839289422299290755441603794058), .00189370204498242146248858917618493), // 59 236 PQP3(R3(.21646077368258425486341884576246642, .52711130286496480000000000000000000, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000)), + 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000)), .01838752922255814184581020943433469), // 60 240 - PQP3(R3(.21646077368258425486341884576246642, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), + PQP3(R3(.21646077368258425486341884576246642, 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .52711130286496480000000000000000000), .01838752922255814184581020943433469), // 61 244 PQP3(R3(.52711130286496480000000000000000000, .21646077368258425486341884576246642, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000)), + 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000)), .01838752922255814184581020943433469), // 62 248 - PQP3(R3(.52711130286496480000000000000000000, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), + PQP3(R3(.52711130286496480000000000000000000, 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 63 252 - PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), - .21646077368258425486341884576246642, .52711130286496480000000000000000000), + PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .21646077368258425486341884576246642, + .52711130286496480000000000000000000), .01838752922255814184581020943433469), // 64 256 - PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), - .52711130286496480000000000000000000, .21646077368258425486341884576246642), + PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .52711130286496480000000000000000000, + .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 65 260 PQP3(R3(.21646077368258425486341884576246642, .21646077368258425486341884576246642, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000)), + 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000)), .01838752922255814184581020943433469), // 66 264 - PQP3(R3(.21646077368258425486341884576246642, - 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), + PQP3(R3(.21646077368258425486341884576246642, 1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 67 268 - PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - - (.52711130286496480000000000000000000), - .21646077368258425486341884576246642, .21646077368258425486341884576246642), + PQP3(R3(1. - (.21646077368258425486341884576246642) - (.21646077368258425486341884576246642) - (.52711130286496480000000000000000000), .21646077368258425486341884576246642, + .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 68 272 - PQP3(R3(.21646077368258425486341884576246642, .21646077368258425486341884576246642, - .52711130286496480000000000000000000), + PQP3(R3(.21646077368258425486341884576246642, .21646077368258425486341884576246642, .52711130286496480000000000000000000), .01838752922255814184581020943433469), // 69 276 - PQP3(R3(.21646077368258425486341884576246642, .52711130286496480000000000000000000, - .21646077368258425486341884576246642), + PQP3(R3(.21646077368258425486341884576246642, .52711130286496480000000000000000000, .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 70 280 - PQP3(R3(.52711130286496480000000000000000000, .21646077368258425486341884576246642, - .21646077368258425486341884576246642), + PQP3(R3(.52711130286496480000000000000000000, .21646077368258425486341884576246642, .21646077368258425486341884576246642), .01838752922255814184581020943433469), // 71 284 PQP3(R3(.13301884366834711587538262083530116, .73318551371398651551736762818473584, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584)), + 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584)), .00375249249801662461193260176157591), // 72 288 - PQP3(R3(.13301884366834711587538262083530116, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), + PQP3(R3(.13301884366834711587538262083530116, 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .73318551371398651551736762818473584), .00375249249801662461193260176157591), // 73 292 PQP3(R3(.73318551371398651551736762818473584, .13301884366834711587538262083530116, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584)), + 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584)), .00375249249801662461193260176157591), // 74 296 - PQP3(R3(.73318551371398651551736762818473584, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), + PQP3(R3(.73318551371398651551736762818473584, 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 75 300 - PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), - .13301884366834711587538262083530116, .73318551371398651551736762818473584), + PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .13301884366834711587538262083530116, + .73318551371398651551736762818473584), .00375249249801662461193260176157591), // 76 304 - PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), - .73318551371398651551736762818473584, .13301884366834711587538262083530116), + PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .73318551371398651551736762818473584, + .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 77 308 PQP3(R3(.13301884366834711587538262083530116, .13301884366834711587538262083530116, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584)), + 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584)), .00375249249801662461193260176157591), // 78 312 - PQP3(R3(.13301884366834711587538262083530116, - 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), + PQP3(R3(.13301884366834711587538262083530116, 1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 79 316 - PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - - (.73318551371398651551736762818473584), - .13301884366834711587538262083530116, .13301884366834711587538262083530116), + PQP3(R3(1. - (.13301884366834711587538262083530116) - (.13301884366834711587538262083530116) - (.73318551371398651551736762818473584), .13301884366834711587538262083530116, + .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 80 320 - PQP3(R3(.13301884366834711587538262083530116, .13301884366834711587538262083530116, - .73318551371398651551736762818473584), + PQP3(R3(.13301884366834711587538262083530116, .13301884366834711587538262083530116, .73318551371398651551736762818473584), .00375249249801662461193260176157591), // 81 324 - PQP3(R3(.13301884366834711587538262083530116, .73318551371398651551736762818473584, - .13301884366834711587538262083530116), + PQP3(R3(.13301884366834711587538262083530116, .73318551371398651551736762818473584, .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 82 328 - PQP3(R3(.73318551371398651551736762818473584, .13301884366834711587538262083530116, - .13301884366834711587538262083530116), + PQP3(R3(.73318551371398651551736762818473584, .13301884366834711587538262083530116, .13301884366834711587538262083530116), .00375249249801662461193260176157591), // 83 332 PQP3(R3(.44054756810613723082959230959880706, .11506799584377921703650823955291194, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194)), + 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194)), .00633289841693951300885921328914879), // 84 336 - PQP3(R3(.44054756810613723082959230959880706, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), + PQP3(R3(.44054756810613723082959230959880706, 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .11506799584377921703650823955291194), .00633289841693951300885921328914879), // 85 340 PQP3(R3(.11506799584377921703650823955291194, .44054756810613723082959230959880706, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194)), + 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194)), .00633289841693951300885921328914879), // 86 344 - PQP3(R3(.11506799584377921703650823955291194, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), + PQP3(R3(.11506799584377921703650823955291194, 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 87 348 - PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), - .44054756810613723082959230959880706, .11506799584377921703650823955291194), + PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .44054756810613723082959230959880706, + .11506799584377921703650823955291194), .00633289841693951300885921328914879), // 88 352 - PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), - .11506799584377921703650823955291194, .44054756810613723082959230959880706), + PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .11506799584377921703650823955291194, + .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 89 356 PQP3(R3(.44054756810613723082959230959880706, .44054756810613723082959230959880706, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194)), + 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194)), .00633289841693951300885921328914879), // 90 360 - PQP3(R3(.44054756810613723082959230959880706, - 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), + PQP3(R3(.44054756810613723082959230959880706, 1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 91 364 - PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - - (.11506799584377921703650823955291194), - .44054756810613723082959230959880706, .44054756810613723082959230959880706), + PQP3(R3(1. - (.44054756810613723082959230959880706) - (.44054756810613723082959230959880706) - (.11506799584377921703650823955291194), .44054756810613723082959230959880706, + .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 92 368 - PQP3(R3(.44054756810613723082959230959880706, .44054756810613723082959230959880706, - .11506799584377921703650823955291194), + PQP3(R3(.44054756810613723082959230959880706, .44054756810613723082959230959880706, .11506799584377921703650823955291194), .00633289841693951300885921328914879), // 93 372 - PQP3(R3(.44054756810613723082959230959880706, .11506799584377921703650823955291194, - .44054756810613723082959230959880706), + PQP3(R3(.44054756810613723082959230959880706, .11506799584377921703650823955291194, .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 94 376 - PQP3(R3(.11506799584377921703650823955291194, .44054756810613723082959230959880706, - .44054756810613723082959230959880706), + PQP3(R3(.11506799584377921703650823955291194, .44054756810613723082959230959880706, .44054756810613723082959230959880706), .00633289841693951300885921328914879), // 95 380 }; PQF3 const QuadratureFormular_Tet_P11(11, 96, QF_TET_P11); // QUAD QUAD_3D_P12_ = { 127 508 PQP3 QF_TET_P12[] = { PQP3(R3(0.25, 0.25, 0.25), .02340581914868067999082580773836836), // 0 0 - PQP3(R3(.19318721110347230000000000000000000, .19318721110347230000000000000000000, - .19318721110347230000000000000000000), + PQP3(R3(.19318721110347230000000000000000000, .19318721110347230000000000000000000, .19318721110347230000000000000000000), .00484469946470415656870798306091558), // 1 4 - PQP3(R3(1. - 3. * (.19318721110347230000000000000000000), .19318721110347230000000000000000000, - .19318721110347230000000000000000000), + PQP3(R3(1. - 3. * (.19318721110347230000000000000000000), .19318721110347230000000000000000000, .19318721110347230000000000000000000), .00484469946470415656870798306091558), // 2 8 - PQP3(R3(.19318721110347230000000000000000000, 1. - 3. * (.19318721110347230000000000000000000), - .19318721110347230000000000000000000), + PQP3(R3(.19318721110347230000000000000000000, 1. - 3. * (.19318721110347230000000000000000000), .19318721110347230000000000000000000), .00484469946470415656870798306091558), // 3 12 - PQP3(R3(.19318721110347230000000000000000000, .19318721110347230000000000000000000, - 1. - 3. * (.19318721110347230000000000000000000)), + PQP3(R3(.19318721110347230000000000000000000, .19318721110347230000000000000000000, 1. - 3. * (.19318721110347230000000000000000000)), .00484469946470415656870798306091558), // 4 16 - PQP3(R3(.01811701371436566878506928822499717, .01811701371436566878506928822499717, - .01811701371436566878506928822499717), + PQP3(R3(.01811701371436566878506928822499717, .01811701371436566878506928822499717, .01811701371436566878506928822499717), .00079865303812732982185563521014343), // 5 20 - PQP3(R3(1. - 3. * (.01811701371436566878506928822499717), .01811701371436566878506928822499717, - .01811701371436566878506928822499717), + PQP3(R3(1. - 3. * (.01811701371436566878506928822499717), .01811701371436566878506928822499717, .01811701371436566878506928822499717), .00079865303812732982185563521014343), // 6 24 - PQP3(R3(.01811701371436566878506928822499717, 1. - 3. * (.01811701371436566878506928822499717), - .01811701371436566878506928822499717), + PQP3(R3(.01811701371436566878506928822499717, 1. - 3. * (.01811701371436566878506928822499717), .01811701371436566878506928822499717), .00079865303812732982185563521014343), // 7 28 - PQP3(R3(.01811701371436566878506928822499717, .01811701371436566878506928822499717, - 1. - 3. * (.01811701371436566878506928822499717)), + PQP3(R3(.01811701371436566878506928822499717, .01811701371436566878506928822499717, 1. - 3. * (.01811701371436566878506928822499717)), .00079865303812732982185563521014343), // 8 32 - PQP3(R3(.10700751831426066518406159227423033, .10700751831426066518406159227423033, - .10700751831426066518406159227423033), + PQP3(R3(.10700751831426066518406159227423033, .10700751831426066518406159227423033, .10700751831426066518406159227423033), .01311872008808756207964488505025527), // 9 36 - PQP3(R3(1. - 3. * (.10700751831426066518406159227423033), .10700751831426066518406159227423033, - .10700751831426066518406159227423033), + PQP3(R3(1. - 3. * (.10700751831426066518406159227423033), .10700751831426066518406159227423033, .10700751831426066518406159227423033), .01311872008808756207964488505025527), // 10 40 - PQP3(R3(.10700751831426066518406159227423033, 1. - 3. * (.10700751831426066518406159227423033), - .10700751831426066518406159227423033), + PQP3(R3(.10700751831426066518406159227423033, 1. - 3. * (.10700751831426066518406159227423033), .10700751831426066518406159227423033), .01311872008808756207964488505025527), // 11 44 - PQP3(R3(.10700751831426066518406159227423033, .10700751831426066518406159227423033, - 1. - 3. * (.10700751831426066518406159227423033)), + PQP3(R3(.10700751831426066518406159227423033, .10700751831426066518406159227423033, 1. - 3. * (.10700751831426066518406159227423033)), .01311872008808756207964488505025527), // 12 48 - PQP3(R3(.29936173715970702940603127680004538, .29936173715970702940603127680004538, - .29936173715970702940603127680004538), + PQP3(R3(.29936173715970702940603127680004538, .29936173715970702940603127680004538, .29936173715970702940603127680004538), .02352182961292765917274505054313770), // 13 52 - PQP3(R3(1. - 3. * (.29936173715970702940603127680004538), .29936173715970702940603127680004538, - .29936173715970702940603127680004538), + PQP3(R3(1. - 3. * (.29936173715970702940603127680004538), .29936173715970702940603127680004538, .29936173715970702940603127680004538), .02352182961292765917274505054313770), // 14 56 - PQP3(R3(.29936173715970702940603127680004538, 1. - 3. * (.29936173715970702940603127680004538), - .29936173715970702940603127680004538), + PQP3(R3(.29936173715970702940603127680004538, 1. - 3. * (.29936173715970702940603127680004538), .29936173715970702940603127680004538), .02352182961292765917274505054313770), // 15 60 - PQP3(R3(.29936173715970702940603127680004538, .29936173715970702940603127680004538, - 1. - 3. * (.29936173715970702940603127680004538)), + PQP3(R3(.29936173715970702940603127680004538, .29936173715970702940603127680004538, 1. - 3. * (.29936173715970702940603127680004538)), .02352182961292765917274505054313770), // 16 64 - PQP3(R3(.33333033333333333042835213613025030, .33333033333333333042835213613025030, - .33333033333333333042835213613025030), + PQP3(R3(.33333033333333333042835213613025030, .33333033333333333042835213613025030, .33333033333333333042835213613025030), .00210860882494149803857437048649497), // 17 68 - PQP3(R3(1. - 3. * (.33333033333333333042835213613025030), .33333033333333333042835213613025030, - .33333033333333333042835213613025030), + PQP3(R3(1. - 3. * (.33333033333333333042835213613025030), .33333033333333333042835213613025030, .33333033333333333042835213613025030), .00210860882494149803857437048649497), // 18 72 - PQP3(R3(.33333033333333333042835213613025030, 1. - 3. * (.33333033333333333042835213613025030), - .33333033333333333042835213613025030), + PQP3(R3(.33333033333333333042835213613025030, 1. - 3. * (.33333033333333333042835213613025030), .33333033333333333042835213613025030), .00210860882494149803857437048649497), // 19 76 - PQP3(R3(.33333033333333333042835213613025030, .33333033333333333042835213613025030, - 1. - 3. * (.33333033333333333042835213613025030)), + PQP3(R3(.33333033333333333042835213613025030, .33333033333333333042835213613025030, 1. - 3. * (.33333033333333333042835213613025030)), .00210860882494149803857437048649497), // 20 80 - PQP3(R3(.16575369007421640000000000000000000, .16575369007421640000000000000000000, - .16575369007421640000000000000000000), + PQP3(R3(.16575369007421640000000000000000000, .16575369007421640000000000000000000, .16575369007421640000000000000000000), .00047839298963616600187228601742259), // 21 84 - PQP3(R3(1. - 3. * (.16575369007421640000000000000000000), .16575369007421640000000000000000000, - .16575369007421640000000000000000000), + PQP3(R3(1. - 3. * (.16575369007421640000000000000000000), .16575369007421640000000000000000000, .16575369007421640000000000000000000), .00047839298963616600187228601742259), // 22 88 - PQP3(R3(.16575369007421640000000000000000000, 1. - 3. * (.16575369007421640000000000000000000), - .16575369007421640000000000000000000), + PQP3(R3(.16575369007421640000000000000000000, 1. - 3. * (.16575369007421640000000000000000000), .16575369007421640000000000000000000), .00047839298963616600187228601742259), // 23 92 - PQP3(R3(.16575369007421640000000000000000000, .16575369007421640000000000000000000, - 1. - 3. * (.16575369007421640000000000000000000)), + PQP3(R3(.16575369007421640000000000000000000, .16575369007421640000000000000000000, 1. - 3. * (.16575369007421640000000000000000000)), .00047839298963616600187228601742259), // 24 96 - PQP3(R3(.04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728), - .5 - (.04009986052352575650366980228640728)), + PQP3(R3(.04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728), .5 - (.04009986052352575650366980228640728)), .00204546234216855322941711800170502), // 25 100 - PQP3(R3(.5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728, - .5 - (.04009986052352575650366980228640728)), + PQP3(R3(.5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728)), .00204546234216855322941711800170502), // 26 104 - PQP3(R3(.5 - (.04009986052352575650366980228640728), .5 - (.04009986052352575650366980228640728), - .04009986052352575650366980228640728), + PQP3(R3(.5 - (.04009986052352575650366980228640728), .5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728), .00204546234216855322941711800170502), // 27 108 - PQP3(R3(.04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728), - .04009986052352575650366980228640728), + PQP3(R3(.04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728), .00204546234216855322941711800170502), // 28 112 - PQP3(R3(.04009986052352575650366980228640728, .04009986052352575650366980228640728, - .5 - (.04009986052352575650366980228640728)), + PQP3(R3(.04009986052352575650366980228640728, .04009986052352575650366980228640728, .5 - (.04009986052352575650366980228640728)), .00204546234216855322941711800170502), // 29 116 - PQP3(R3(.5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728, - .04009986052352575650366980228640728), + PQP3(R3(.5 - (.04009986052352575650366980228640728), .04009986052352575650366980228640728, .04009986052352575650366980228640728), .00204546234216855322941711800170502), // 30 120 PQP3(R3(.01951844463761131301132122485607343, .59982639757597731668263005976738196, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196)), + 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196)), .00334576331671817115245418532677178), // 31 124 - PQP3(R3(.01951844463761131301132122485607343, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), + PQP3(R3(.01951844463761131301132122485607343, 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .59982639757597731668263005976738196), .00334576331671817115245418532677178), // 32 128 PQP3(R3(.59982639757597731668263005976738196, .01951844463761131301132122485607343, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196)), + 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196)), .00334576331671817115245418532677178), // 33 132 - PQP3(R3(.59982639757597731668263005976738196, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), + PQP3(R3(.59982639757597731668263005976738196, 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 34 136 - PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), - .01951844463761131301132122485607343, .59982639757597731668263005976738196), + PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .01951844463761131301132122485607343, + .59982639757597731668263005976738196), .00334576331671817115245418532677178), // 35 140 - PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), - .59982639757597731668263005976738196, .01951844463761131301132122485607343), + PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .59982639757597731668263005976738196, + .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 36 144 PQP3(R3(.01951844463761131301132122485607343, .01951844463761131301132122485607343, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196)), + 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196)), .00334576331671817115245418532677178), // 37 148 - PQP3(R3(.01951844463761131301132122485607343, - 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), + PQP3(R3(.01951844463761131301132122485607343, 1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 38 152 - PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - - (.59982639757597731668263005976738196), - .01951844463761131301132122485607343, .01951844463761131301132122485607343), + PQP3(R3(1. - (.01951844463761131301132122485607343) - (.01951844463761131301132122485607343) - (.59982639757597731668263005976738196), .01951844463761131301132122485607343, + .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 39 156 - PQP3(R3(.01951844463761131301132122485607343, .01951844463761131301132122485607343, - .59982639757597731668263005976738196), + PQP3(R3(.01951844463761131301132122485607343, .01951844463761131301132122485607343, .59982639757597731668263005976738196), .00334576331671817115245418532677178), // 40 160 - PQP3(R3(.01951844463761131301132122485607343, .59982639757597731668263005976738196, - .01951844463761131301132122485607343), + PQP3(R3(.01951844463761131301132122485607343, .59982639757597731668263005976738196, .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 41 164 - PQP3(R3(.59982639757597731668263005976738196, .01951844463761131301132122485607343, - .01951844463761131301132122485607343), + PQP3(R3(.59982639757597731668263005976738196, .01951844463761131301132122485607343, .01951844463761131301132122485607343), .00334576331671817115245418532677178), // 42 168 PQP3(R3(.24970741896308715787490891769354198, .47400425629911050000000000000000000, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000)), + 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000)), .01181044822479275264785338274950585), // 43 172 - PQP3(R3(.24970741896308715787490891769354198, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), + PQP3(R3(.24970741896308715787490891769354198, 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .47400425629911050000000000000000000), .01181044822479275264785338274950585), // 44 176 PQP3(R3(.47400425629911050000000000000000000, .24970741896308715787490891769354198, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000)), + 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000)), .01181044822479275264785338274950585), // 45 180 - PQP3(R3(.47400425629911050000000000000000000, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), + PQP3(R3(.47400425629911050000000000000000000, 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 46 184 - PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), - .24970741896308715787490891769354198, .47400425629911050000000000000000000), + PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .24970741896308715787490891769354198, + .47400425629911050000000000000000000), .01181044822479275264785338274950585), // 47 188 - PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), - .47400425629911050000000000000000000, .24970741896308715787490891769354198), + PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .47400425629911050000000000000000000, + .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 48 192 PQP3(R3(.24970741896308715787490891769354198, .24970741896308715787490891769354198, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000)), + 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000)), .01181044822479275264785338274950585), // 49 196 - PQP3(R3(.24970741896308715787490891769354198, - 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), + PQP3(R3(.24970741896308715787490891769354198, 1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 50 200 - PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - - (.47400425629911050000000000000000000), - .24970741896308715787490891769354198, .24970741896308715787490891769354198), + PQP3(R3(1. - (.24970741896308715787490891769354198) - (.24970741896308715787490891769354198) - (.47400425629911050000000000000000000), .24970741896308715787490891769354198, + .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 51 204 - PQP3(R3(.24970741896308715787490891769354198, .24970741896308715787490891769354198, - .47400425629911050000000000000000000), + PQP3(R3(.24970741896308715787490891769354198, .24970741896308715787490891769354198, .47400425629911050000000000000000000), .01181044822479275264785338274950585), // 52 208 - PQP3(R3(.24970741896308715787490891769354198, .47400425629911050000000000000000000, - .24970741896308715787490891769354198), + PQP3(R3(.24970741896308715787490891769354198, .47400425629911050000000000000000000, .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 53 212 - PQP3(R3(.47400425629911050000000000000000000, .24970741896308715787490891769354198, - .24970741896308715787490891769354198), + PQP3(R3(.47400425629911050000000000000000000, .24970741896308715787490891769354198, .24970741896308715787490891769354198), .01181044822479275264785338274950585), // 54 216 PQP3(R3(.07674205857869954726322831328843659, .83056291375422969598432041821082569, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569)), + 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569)), .00290156990282342152841364375092118), // 55 220 - PQP3(R3(.07674205857869954726322831328843659, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), + PQP3(R3(.07674205857869954726322831328843659, 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .83056291375422969598432041821082569), .00290156990282342152841364375092118), // 56 224 PQP3(R3(.83056291375422969598432041821082569, .07674205857869954726322831328843659, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569)), + 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569)), .00290156990282342152841364375092118), // 57 228 - PQP3(R3(.83056291375422969598432041821082569, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), + PQP3(R3(.83056291375422969598432041821082569, 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 58 232 - PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), - .07674205857869954726322831328843659, .83056291375422969598432041821082569), + PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .07674205857869954726322831328843659, + .83056291375422969598432041821082569), .00290156990282342152841364375092118), // 59 236 - PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), - .83056291375422969598432041821082569, .07674205857869954726322831328843659), + PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .83056291375422969598432041821082569, + .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 60 240 PQP3(R3(.07674205857869954726322831328843659, .07674205857869954726322831328843659, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569)), + 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569)), .00290156990282342152841364375092118), // 61 244 - PQP3(R3(.07674205857869954726322831328843659, - 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), + PQP3(R3(.07674205857869954726322831328843659, 1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 62 248 - PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - - (.83056291375422969598432041821082569), - .07674205857869954726322831328843659, .07674205857869954726322831328843659), + PQP3(R3(1. - (.07674205857869954726322831328843659) - (.07674205857869954726322831328843659) - (.83056291375422969598432041821082569), .07674205857869954726322831328843659, + .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 63 252 - PQP3(R3(.07674205857869954726322831328843659, .07674205857869954726322831328843659, - .83056291375422969598432041821082569), + PQP3(R3(.07674205857869954726322831328843659, .07674205857869954726322831328843659, .83056291375422969598432041821082569), .00290156990282342152841364375092118), // 64 256 - PQP3(R3(.07674205857869954726322831328843659, .83056291375422969598432041821082569, - .07674205857869954726322831328843659), + PQP3(R3(.07674205857869954726322831328843659, .83056291375422969598432041821082569, .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 65 260 - PQP3(R3(.83056291375422969598432041821082569, .07674205857869954726322831328843659, - .07674205857869954726322831328843659), + PQP3(R3(.83056291375422969598432041821082569, .07674205857869954726322831328843659, .07674205857869954726322831328843659), .00290156990282342152841364375092118), // 66 264 PQP3(R3(.43011409627915217536723647418133112, .02265922072588833582931396831630072, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072)), + 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072)), .00949250645501753676094846901252898), // 67 268 - PQP3(R3(.43011409627915217536723647418133112, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), + PQP3(R3(.43011409627915217536723647418133112, 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .02265922072588833582931396831630072), .00949250645501753676094846901252898), // 68 272 PQP3(R3(.02265922072588833582931396831630072, .43011409627915217536723647418133112, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072)), + 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072)), .00949250645501753676094846901252898), // 69 276 - PQP3(R3(.02265922072588833582931396831630072, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), + PQP3(R3(.02265922072588833582931396831630072, 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 70 280 - PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), - .43011409627915217536723647418133112, .02265922072588833582931396831630072), + PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .43011409627915217536723647418133112, + .02265922072588833582931396831630072), .00949250645501753676094846901252898), // 71 284 - PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), - .02265922072588833582931396831630072, .43011409627915217536723647418133112), + PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .02265922072588833582931396831630072, + .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 72 288 PQP3(R3(.43011409627915217536723647418133112, .43011409627915217536723647418133112, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072)), + 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072)), .00949250645501753676094846901252898), // 73 292 - PQP3(R3(.43011409627915217536723647418133112, - 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), + PQP3(R3(.43011409627915217536723647418133112, 1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 74 296 - PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - - (.02265922072588833582931396831630072), - .43011409627915217536723647418133112, .43011409627915217536723647418133112), + PQP3(R3(1. - (.43011409627915217536723647418133112) - (.43011409627915217536723647418133112) - (.02265922072588833582931396831630072), .43011409627915217536723647418133112, + .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 75 300 - PQP3(R3(.43011409627915217536723647418133112, .43011409627915217536723647418133112, - .02265922072588833582931396831630072), + PQP3(R3(.43011409627915217536723647418133112, .43011409627915217536723647418133112, .02265922072588833582931396831630072), .00949250645501753676094846901252898), // 76 304 - PQP3(R3(.43011409627915217536723647418133112, .02265922072588833582931396831630072, - .43011409627915217536723647418133112), + PQP3(R3(.43011409627915217536723647418133112, .02265922072588833582931396831630072, .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 77 308 - PQP3(R3(.02265922072588833582931396831630072, .43011409627915217536723647418133112, - .43011409627915217536723647418133112), + PQP3(R3(.02265922072588833582931396831630072, .43011409627915217536723647418133112, .43011409627915217536723647418133112), .00949250645501753676094846901252898), // 78 312 PQP3(R3(.12197854304894211937147375564906792, .47765370899783134571567376444973682, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682)), + 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682)), .02094018358085748583183796760479700), // 79 316 - PQP3(R3(.12197854304894211937147375564906792, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), + PQP3(R3(.12197854304894211937147375564906792, 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .47765370899783134571567376444973682), .02094018358085748583183796760479700), // 80 320 PQP3(R3(.47765370899783134571567376444973682, .12197854304894211937147375564906792, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682)), + 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682)), .02094018358085748583183796760479700), // 81 324 - PQP3(R3(.47765370899783134571567376444973682, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), + PQP3(R3(.47765370899783134571567376444973682, 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 82 328 - PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), - .12197854304894211937147375564906792, .47765370899783134571567376444973682), + PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .12197854304894211937147375564906792, + .47765370899783134571567376444973682), .02094018358085748583183796760479700), // 83 332 - PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), - .47765370899783134571567376444973682, .12197854304894211937147375564906792), + PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .47765370899783134571567376444973682, + .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 84 336 PQP3(R3(.12197854304894211937147375564906792, .12197854304894211937147375564906792, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682)), + 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682)), .02094018358085748583183796760479700), // 85 340 - PQP3(R3(.12197854304894211937147375564906792, - 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), + PQP3(R3(.12197854304894211937147375564906792, 1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 86 344 - PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - - (.47765370899783134571567376444973682), - .12197854304894211937147375564906792, .12197854304894211937147375564906792), + PQP3(R3(1. - (.12197854304894211937147375564906792) - (.12197854304894211937147375564906792) - (.47765370899783134571567376444973682), .12197854304894211937147375564906792, + .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 87 348 - PQP3(R3(.12197854304894211937147375564906792, .12197854304894211937147375564906792, - .47765370899783134571567376444973682), + PQP3(R3(.12197854304894211937147375564906792, .12197854304894211937147375564906792, .47765370899783134571567376444973682), .02094018358085748583183796760479700), // 88 352 - PQP3(R3(.12197854304894211937147375564906792, .47765370899783134571567376444973682, - .12197854304894211937147375564906792), + PQP3(R3(.12197854304894211937147375564906792, .47765370899783134571567376444973682, .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 89 356 - PQP3(R3(.47765370899783134571567376444973682, .12197854304894211937147375564906792, - .12197854304894211937147375564906792), + PQP3(R3(.47765370899783134571567376444973682, .12197854304894211937147375564906792, .12197854304894211937147375564906792), .02094018358085748583183796760479700), // 90 360 PQP3(R3(.01480482319031682427540691439704854, .81083799468092699988474915243749073, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073)), + 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073)), .00171435866337409051521874943702732), // 91 364 - PQP3(R3(.01480482319031682427540691439704854, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), + PQP3(R3(.01480482319031682427540691439704854, 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .81083799468092699988474915243749073), .00171435866337409051521874943702732), // 92 368 PQP3(R3(.81083799468092699988474915243749073, .01480482319031682427540691439704854, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073)), + 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073)), .00171435866337409051521874943702732), // 93 372 - PQP3(R3(.81083799468092699988474915243749073, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), + PQP3(R3(.81083799468092699988474915243749073, 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 94 376 - PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), - .01480482319031682427540691439704854, .81083799468092699988474915243749073), + PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .01480482319031682427540691439704854, + .81083799468092699988474915243749073), .00171435866337409051521874943702732), // 95 380 - PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), - .81083799468092699988474915243749073, .01480482319031682427540691439704854), + PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .81083799468092699988474915243749073, + .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 96 384 PQP3(R3(.01480482319031682427540691439704854, .01480482319031682427540691439704854, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073)), + 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073)), .00171435866337409051521874943702732), // 97 388 - PQP3(R3(.01480482319031682427540691439704854, - 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), + PQP3(R3(.01480482319031682427540691439704854, 1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 98 392 - PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - - (.81083799468092699988474915243749073), - .01480482319031682427540691439704854, .01480482319031682427540691439704854), + PQP3(R3(1. - (.01480482319031682427540691439704854) - (.01480482319031682427540691439704854) - (.81083799468092699988474915243749073), .01480482319031682427540691439704854, + .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 99 396 - PQP3(R3(.01480482319031682427540691439704854, .01480482319031682427540691439704854, - .81083799468092699988474915243749073), + PQP3(R3(.01480482319031682427540691439704854, .01480482319031682427540691439704854, .81083799468092699988474915243749073), .00171435866337409051521874943702732), // 100 400 - PQP3(R3(.01480482319031682427540691439704854, .81083799468092699988474915243749073, - .01480482319031682427540691439704854), + PQP3(R3(.01480482319031682427540691439704854, .81083799468092699988474915243749073, .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 101 404 - PQP3(R3(.81083799468092699988474915243749073, .01480482319031682427540691439704854, - .01480482319031682427540691439704854), + PQP3(R3(.81083799468092699988474915243749073, .01480482319031682427540691439704854, .01480482319031682427540691439704854), .00171435866337409051521874943702732), // 102 408 PQP3(R3(.22646235632397177636617160407210034, .02251830769546778956654013747639605, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 103 412 - PQP3(R3(.22646235632397177636617160407210034, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.22646235632397177636617160407210034, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 104 416 PQP3(R3(.02251830769546778956654013747639605, .22646235632397177636617160407210034, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 105 420 - PQP3(R3(.02251830769546778956654013747639605, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.02251830769546778956654013747639605, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 106 424 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .22646235632397177636617160407210034, .02251830769546778956654013747639605), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .22646235632397177636617160407210034, + .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 107 428 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .02251830769546778956654013747639605, .22646235632397177636617160407210034), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .02251830769546778956654013747639605, + .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 108 432 PQP3(R3(.65250697573013212016385330106711095, .02251830769546778956654013747639605, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 109 436 - PQP3(R3(.65250697573013212016385330106711095, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.65250697573013212016385330106711095, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 110 440 PQP3(R3(.02251830769546778956654013747639605, .65250697573013212016385330106711095, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 111 444 - PQP3(R3(.02251830769546778956654013747639605, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.02251830769546778956654013747639605, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 112 448 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .65250697573013212016385330106711095, .02251830769546778956654013747639605), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .65250697573013212016385330106711095, + .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 113 452 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .02251830769546778956654013747639605, .65250697573013212016385330106711095), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .02251830769546778956654013747639605, + .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 114 456 PQP3(R3(.65250697573013212016385330106711095, .22646235632397177636617160407210034, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 115 460 - PQP3(R3(.65250697573013212016385330106711095, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.65250697573013212016385330106711095, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 116 464 PQP3(R3(.22646235632397177636617160407210034, .65250697573013212016385330106711095, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605)), + 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605)), .00759915954173370886076474450830409), // 117 468 - PQP3(R3(.22646235632397177636617160407210034, - 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), + PQP3(R3(.22646235632397177636617160407210034, 1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 118 472 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .65250697573013212016385330106711095, .22646235632397177636617160407210034), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .65250697573013212016385330106711095, + .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 119 476 - PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - - (.02251830769546778956654013747639605), - .22646235632397177636617160407210034, .65250697573013212016385330106711095), + PQP3(R3(1. - (.65250697573013212016385330106711095) - (.22646235632397177636617160407210034) - (.02251830769546778956654013747639605), .22646235632397177636617160407210034, + .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 120 480 - PQP3(R3(.65250697573013212016385330106711095, .22646235632397177636617160407210034, - .02251830769546778956654013747639605), + PQP3(R3(.65250697573013212016385330106711095, .22646235632397177636617160407210034, .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 121 484 - PQP3(R3(.65250697573013212016385330106711095, .02251830769546778956654013747639605, - .22646235632397177636617160407210034), + PQP3(R3(.65250697573013212016385330106711095, .02251830769546778956654013747639605, .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 122 488 - PQP3(R3(.22646235632397177636617160407210034, .65250697573013212016385330106711095, - .02251830769546778956654013747639605), + PQP3(R3(.22646235632397177636617160407210034, .65250697573013212016385330106711095, .02251830769546778956654013747639605), .00759915954173370886076474450830409), // 123 492 - PQP3(R3(.22646235632397177636617160407210034, .02251830769546778956654013747639605, - .65250697573013212016385330106711095), + PQP3(R3(.22646235632397177636617160407210034, .02251830769546778956654013747639605, .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 124 496 - PQP3(R3(.02251830769546778956654013747639605, .65250697573013212016385330106711095, - .22646235632397177636617160407210034), + PQP3(R3(.02251830769546778956654013747639605, .65250697573013212016385330106711095, .22646235632397177636617160407210034), .00759915954173370886076474450830409), // 125 500 - PQP3(R3(.02251830769546778956654013747639605, .22646235632397177636617160407210034, - .65250697573013212016385330106711095), + PQP3(R3(.02251830769546778956654013747639605, .22646235632397177636617160407210034, .65250697573013212016385330106711095), .00759915954173370886076474450830409), // 126 504 }; PQF3 const QuadratureFormular_Tet_P12(12, 127, QF_TET_P12); // QUAD QUAD_3D_P13_ = { 149 596 PQP3 QF_TET_P13[] = { PQP3(R3(0.25, 0.25, 0.25), .02191579945212728678229670892998658), // 0 0 - PQP3(R3(.09935339765028269917868020572165369, .09935339765028269917868020572165369, - .09935339765028269917868020572165369), + PQP3(R3(.09935339765028269917868020572165369, .09935339765028269917868020572165369, .09935339765028269917868020572165369), .00809592740005652573580359966615063), // 1 4 - PQP3(R3(1. - 3. * (.09935339765028269917868020572165369), .09935339765028269917868020572165369, - .09935339765028269917868020572165369), + PQP3(R3(1. - 3. * (.09935339765028269917868020572165369), .09935339765028269917868020572165369, .09935339765028269917868020572165369), .00809592740005652573580359966615063), // 2 8 - PQP3(R3(.09935339765028269917868020572165369, 1. - 3. * (.09935339765028269917868020572165369), - .09935339765028269917868020572165369), + PQP3(R3(.09935339765028269917868020572165369, 1. - 3. * (.09935339765028269917868020572165369), .09935339765028269917868020572165369), .00809592740005652573580359966615063), // 3 12 - PQP3(R3(.09935339765028269917868020572165369, .09935339765028269917868020572165369, - 1. - 3. * (.09935339765028269917868020572165369)), + PQP3(R3(.09935339765028269917868020572165369, .09935339765028269917868020572165369, 1. - 3. * (.09935339765028269917868020572165369)), .00809592740005652573580359966615063), // 4 16 - PQP3(R3(.02361873260499568532036302265004401, .02361873260499568532036302265004401, - .02361873260499568532036302265004401), + PQP3(R3(.02361873260499568532036302265004401, .02361873260499568532036302265004401, .02361873260499568532036302265004401), .00130319185047278813746994806952476), // 5 20 - PQP3(R3(1. - 3. * (.02361873260499568532036302265004401), .02361873260499568532036302265004401, - .02361873260499568532036302265004401), + PQP3(R3(1. - 3. * (.02361873260499568532036302265004401), .02361873260499568532036302265004401, .02361873260499568532036302265004401), .00130319185047278813746994806952476), // 6 24 - PQP3(R3(.02361873260499568532036302265004401, 1. - 3. * (.02361873260499568532036302265004401), - .02361873260499568532036302265004401), + PQP3(R3(.02361873260499568532036302265004401, 1. - 3. * (.02361873260499568532036302265004401), .02361873260499568532036302265004401), .00130319185047278813746994806952476), // 7 28 - PQP3(R3(.02361873260499568532036302265004401, .02361873260499568532036302265004401, - 1. - 3. * (.02361873260499568532036302265004401)), + PQP3(R3(.02361873260499568532036302265004401, .02361873260499568532036302265004401, 1. - 3. * (.02361873260499568532036302265004401)), .00130319185047278813746994806952476), // 8 32 - PQP3(R3(.30089166537572662790706731844610997, .30089166537572662790706731844610997, - .30089166537572662790706731844610997), + PQP3(R3(.30089166537572662790706731844610997, .30089166537572662790706731844610997, .30089166537572662790706731844610997), .01996610676014222116016391561580003), // 9 36 - PQP3(R3(1. - 3. * (.30089166537572662790706731844610997), .30089166537572662790706731844610997, - .30089166537572662790706731844610997), + PQP3(R3(1. - 3. * (.30089166537572662790706731844610997), .30089166537572662790706731844610997, .30089166537572662790706731844610997), .01996610676014222116016391561580003), // 10 40 - PQP3(R3(.30089166537572662790706731844610997, 1. - 3. * (.30089166537572662790706731844610997), - .30089166537572662790706731844610997), + PQP3(R3(.30089166537572662790706731844610997, 1. - 3. * (.30089166537572662790706731844610997), .30089166537572662790706731844610997), .01996610676014222116016391561580003), // 11 44 - PQP3(R3(.30089166537572662790706731844610997, .30089166537572662790706731844610997, - 1. - 3. * (.30089166537572662790706731844610997)), + PQP3(R3(.30089166537572662790706731844610997, .30089166537572662790706731844610997, 1. - 3. * (.30089166537572662790706731844610997)), .01996610676014222116016391561580003), // 12 48 - PQP3(R3(.18156624280757148139366685840064601, .18156624280757148139366685840064601, - .18156624280757148139366685840064601), + PQP3(R3(.18156624280757148139366685840064601, .18156624280757148139366685840064601, .18156624280757148139366685840064601), .02125705756007566772097136088386650), // 13 52 - PQP3(R3(1. - 3. * (.18156624280757148139366685840064601), .18156624280757148139366685840064601, - .18156624280757148139366685840064601), + PQP3(R3(1. - 3. * (.18156624280757148139366685840064601), .18156624280757148139366685840064601, .18156624280757148139366685840064601), .02125705756007566772097136088386650), // 14 56 - PQP3(R3(.18156624280757148139366685840064601, 1. - 3. * (.18156624280757148139366685840064601), - .18156624280757148139366685840064601), + PQP3(R3(.18156624280757148139366685840064601, 1. - 3. * (.18156624280757148139366685840064601), .18156624280757148139366685840064601), .02125705756007566772097136088386650), // 15 60 - PQP3(R3(.18156624280757148139366685840064601, .18156624280757148139366685840064601, - 1. - 3. * (.18156624280757148139366685840064601)), + PQP3(R3(.18156624280757148139366685840064601, .18156624280757148139366685840064601, 1. - 3. * (.18156624280757148139366685840064601)), .02125705756007566772097136088386650), // 16 64 - PQP3(R3(.00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354), - .5 - (.00428160639152879988718710754508354)), + PQP3(R3(.00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354), .5 - (.00428160639152879988718710754508354)), .00077331890737182713690269661719116), // 17 68 - PQP3(R3(.5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354, - .5 - (.00428160639152879988718710754508354)), + PQP3(R3(.5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354)), .00077331890737182713690269661719116), // 18 72 - PQP3(R3(.5 - (.00428160639152879988718710754508354), .5 - (.00428160639152879988718710754508354), - .00428160639152879988718710754508354), + PQP3(R3(.5 - (.00428160639152879988718710754508354), .5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354), .00077331890737182713690269661719116), // 19 76 - PQP3(R3(.00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354), - .00428160639152879988718710754508354), + PQP3(R3(.00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354), .00077331890737182713690269661719116), // 20 80 - PQP3(R3(.00428160639152879988718710754508354, .00428160639152879988718710754508354, - .5 - (.00428160639152879988718710754508354)), + PQP3(R3(.00428160639152879988718710754508354, .00428160639152879988718710754508354, .5 - (.00428160639152879988718710754508354)), .00077331890737182713690269661719116), // 21 84 - PQP3(R3(.5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354, - .00428160639152879988718710754508354), + PQP3(R3(.5 - (.00428160639152879988718710754508354), .00428160639152879988718710754508354, .00428160639152879988718710754508354), .00077331890737182713690269661719116), // 22 88 - PQP3(R3(.12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434), - .5 - (.12290357421888442998582785890620434)), + PQP3(R3(.12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434), .5 - (.12290357421888442998582785890620434)), .01755491389570430512641028370006205), // 23 92 - PQP3(R3(.5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434, - .5 - (.12290357421888442998582785890620434)), + PQP3(R3(.5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434)), .01755491389570430512641028370006205), // 24 96 - PQP3(R3(.5 - (.12290357421888442998582785890620434), .5 - (.12290357421888442998582785890620434), - .12290357421888442998582785890620434), + PQP3(R3(.5 - (.12290357421888442998582785890620434), .5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434), .01755491389570430512641028370006205), // 25 100 - PQP3(R3(.12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434), - .12290357421888442998582785890620434), + PQP3(R3(.12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434), .01755491389570430512641028370006205), // 26 104 - PQP3(R3(.12290357421888442998582785890620434, .12290357421888442998582785890620434, - .5 - (.12290357421888442998582785890620434)), + PQP3(R3(.12290357421888442998582785890620434, .12290357421888442998582785890620434, .5 - (.12290357421888442998582785890620434)), .01755491389570430512641028370006205), // 27 108 - PQP3(R3(.5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434, - .12290357421888442998582785890620434), + PQP3(R3(.5 - (.12290357421888442998582785890620434), .12290357421888442998582785890620434, .12290357421888442998582785890620434), .01755491389570430512641028370006205), // 28 112 PQP3(R3(.28318219770202728236417353077594322, .43037955664247500440987356786807501, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501)), + 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501)), .00213830361001659899343287397434178), // 29 116 - PQP3(R3(.28318219770202728236417353077594322, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), + PQP3(R3(.28318219770202728236417353077594322, 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .43037955664247500440987356786807501), .00213830361001659899343287397434178), // 30 120 PQP3(R3(.43037955664247500440987356786807501, .28318219770202728236417353077594322, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501)), + 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501)), .00213830361001659899343287397434178), // 31 124 - PQP3(R3(.43037955664247500440987356786807501, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), + PQP3(R3(.43037955664247500440987356786807501, 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 32 128 - PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), - .28318219770202728236417353077594322, .43037955664247500440987356786807501), + PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .28318219770202728236417353077594322, + .43037955664247500440987356786807501), .00213830361001659899343287397434178), // 33 132 - PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), - .43037955664247500440987356786807501, .28318219770202728236417353077594322), + PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .43037955664247500440987356786807501, + .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 34 136 PQP3(R3(.28318219770202728236417353077594322, .28318219770202728236417353077594322, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501)), + 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501)), .00213830361001659899343287397434178), // 35 140 - PQP3(R3(.28318219770202728236417353077594322, - 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), + PQP3(R3(.28318219770202728236417353077594322, 1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 36 144 - PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - - (.43037955664247500440987356786807501), - .28318219770202728236417353077594322, .28318219770202728236417353077594322), + PQP3(R3(1. - (.28318219770202728236417353077594322) - (.28318219770202728236417353077594322) - (.43037955664247500440987356786807501), .28318219770202728236417353077594322, + .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 37 148 - PQP3(R3(.28318219770202728236417353077594322, .28318219770202728236417353077594322, - .43037955664247500440987356786807501), + PQP3(R3(.28318219770202728236417353077594322, .28318219770202728236417353077594322, .43037955664247500440987356786807501), .00213830361001659899343287397434178), // 38 152 - PQP3(R3(.28318219770202728236417353077594322, .43037955664247500440987356786807501, - .28318219770202728236417353077594322), + PQP3(R3(.28318219770202728236417353077594322, .43037955664247500440987356786807501, .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 39 156 - PQP3(R3(.43037955664247500440987356786807501, .28318219770202728236417353077594322, - .28318219770202728236417353077594322), + PQP3(R3(.43037955664247500440987356786807501, .28318219770202728236417353077594322, .28318219770202728236417353077594322), .00213830361001659899343287397434178), // 40 160 PQP3(R3(.02239485904524970717572425710098278, .83488749018470024820940398932904512, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512)), + 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512)), .00256560169283338620814651902766716), // 41 164 - PQP3(R3(.02239485904524970717572425710098278, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), + PQP3(R3(.02239485904524970717572425710098278, 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .83488749018470024820940398932904512), .00256560169283338620814651902766716), // 42 168 PQP3(R3(.83488749018470024820940398932904512, .02239485904524970717572425710098278, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512)), + 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512)), .00256560169283338620814651902766716), // 43 172 - PQP3(R3(.83488749018470024820940398932904512, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), + PQP3(R3(.83488749018470024820940398932904512, 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 44 176 - PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), - .02239485904524970717572425710098278, .83488749018470024820940398932904512), + PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .02239485904524970717572425710098278, + .83488749018470024820940398932904512), .00256560169283338620814651902766716), // 45 180 - PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), - .83488749018470024820940398932904512, .02239485904524970717572425710098278), + PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .83488749018470024820940398932904512, + .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 46 184 PQP3(R3(.02239485904524970717572425710098278, .02239485904524970717572425710098278, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512)), + 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512)), .00256560169283338620814651902766716), // 47 188 - PQP3(R3(.02239485904524970717572425710098278, - 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), + PQP3(R3(.02239485904524970717572425710098278, 1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 48 192 - PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - - (.83488749018470024820940398932904512), - .02239485904524970717572425710098278, .02239485904524970717572425710098278), + PQP3(R3(1. - (.02239485904524970717572425710098278) - (.02239485904524970717572425710098278) - (.83488749018470024820940398932904512), .02239485904524970717572425710098278, + .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 49 196 - PQP3(R3(.02239485904524970717572425710098278, .02239485904524970717572425710098278, - .83488749018470024820940398932904512), + PQP3(R3(.02239485904524970717572425710098278, .02239485904524970717572425710098278, .83488749018470024820940398932904512), .00256560169283338620814651902766716), // 50 200 - PQP3(R3(.02239485904524970717572425710098278, .83488749018470024820940398932904512, - .02239485904524970717572425710098278), + PQP3(R3(.02239485904524970717572425710098278, .83488749018470024820940398932904512, .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 51 204 - PQP3(R3(.83488749018470024820940398932904512, .02239485904524970717572425710098278, - .02239485904524970717572425710098278), + PQP3(R3(.83488749018470024820940398932904512, .02239485904524970717572425710098278, .02239485904524970717572425710098278), .00256560169283338620814651902766716), // 52 208 PQP3(R3(.02191788402113435132324662419880111, .67691762094326571059673391273529166, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166)), + 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166)), .00338953948455728203040932651810398), // 53 212 - PQP3(R3(.02191788402113435132324662419880111, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), + PQP3(R3(.02191788402113435132324662419880111, 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .67691762094326571059673391273529166), .00338953948455728203040932651810398), // 54 216 PQP3(R3(.67691762094326571059673391273529166, .02191788402113435132324662419880111, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166)), + 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166)), .00338953948455728203040932651810398), // 55 220 - PQP3(R3(.67691762094326571059673391273529166, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), + PQP3(R3(.67691762094326571059673391273529166, 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 56 224 - PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), - .02191788402113435132324662419880111, .67691762094326571059673391273529166), + PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .02191788402113435132324662419880111, + .67691762094326571059673391273529166), .00338953948455728203040932651810398), // 57 228 - PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), - .67691762094326571059673391273529166, .02191788402113435132324662419880111), + PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .67691762094326571059673391273529166, + .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 58 232 PQP3(R3(.02191788402113435132324662419880111, .02191788402113435132324662419880111, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166)), + 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166)), .00338953948455728203040932651810398), // 59 236 - PQP3(R3(.02191788402113435132324662419880111, - 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), + PQP3(R3(.02191788402113435132324662419880111, 1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 60 240 - PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - - (.67691762094326571059673391273529166), - .02191788402113435132324662419880111, .02191788402113435132324662419880111), + PQP3(R3(1. - (.02191788402113435132324662419880111) - (.02191788402113435132324662419880111) - (.67691762094326571059673391273529166), .02191788402113435132324662419880111, + .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 61 244 - PQP3(R3(.02191788402113435132324662419880111, .02191788402113435132324662419880111, - .67691762094326571059673391273529166), + PQP3(R3(.02191788402113435132324662419880111, .02191788402113435132324662419880111, .67691762094326571059673391273529166), .00338953948455728203040932651810398), // 62 248 - PQP3(R3(.02191788402113435132324662419880111, .67691762094326571059673391273529166, - .02191788402113435132324662419880111), + PQP3(R3(.02191788402113435132324662419880111, .67691762094326571059673391273529166, .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 63 252 - PQP3(R3(.67691762094326571059673391273529166, .02191788402113435132324662419880111, - .02191788402113435132324662419880111), + PQP3(R3(.67691762094326571059673391273529166, .02191788402113435132324662419880111, .02191788402113435132324662419880111), .00338953948455728203040932651810398), // 64 256 PQP3(R3(.21481417044274656673534260788169227, .52280311286258745560867693994038579, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579)), + 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579)), .01135828330503278417235563981454793), // 65 260 - PQP3(R3(.21481417044274656673534260788169227, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), + PQP3(R3(.21481417044274656673534260788169227, 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .52280311286258745560867693994038579), .01135828330503278417235563981454793), // 66 264 PQP3(R3(.52280311286258745560867693994038579, .21481417044274656673534260788169227, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579)), + 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579)), .01135828330503278417235563981454793), // 67 268 - PQP3(R3(.52280311286258745560867693994038579, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), + PQP3(R3(.52280311286258745560867693994038579, 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 68 272 - PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), - .21481417044274656673534260788169227, .52280311286258745560867693994038579), + PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .21481417044274656673534260788169227, + .52280311286258745560867693994038579), .01135828330503278417235563981454793), // 69 276 - PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), - .52280311286258745560867693994038579, .21481417044274656673534260788169227), + PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .52280311286258745560867693994038579, + .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 70 280 PQP3(R3(.21481417044274656673534260788169227, .21481417044274656673534260788169227, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579)), + 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579)), .01135828330503278417235563981454793), // 71 284 - PQP3(R3(.21481417044274656673534260788169227, - 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), + PQP3(R3(.21481417044274656673534260788169227, 1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 72 288 - PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - - (.52280311286258745560867693994038579), - .21481417044274656673534260788169227, .21481417044274656673534260788169227), + PQP3(R3(1. - (.21481417044274656673534260788169227) - (.21481417044274656673534260788169227) - (.52280311286258745560867693994038579), .21481417044274656673534260788169227, + .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 73 292 - PQP3(R3(.21481417044274656673534260788169227, .21481417044274656673534260788169227, - .52280311286258745560867693994038579), + PQP3(R3(.21481417044274656673534260788169227, .21481417044274656673534260788169227, .52280311286258745560867693994038579), .01135828330503278417235563981454793), // 74 296 - PQP3(R3(.21481417044274656673534260788169227, .52280311286258745560867693994038579, - .21481417044274656673534260788169227), + PQP3(R3(.21481417044274656673534260788169227, .52280311286258745560867693994038579, .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 75 300 - PQP3(R3(.52280311286258745560867693994038579, .21481417044274656673534260788169227, - .21481417044274656673534260788169227), + PQP3(R3(.52280311286258745560867693994038579, .21481417044274656673534260788169227, .21481417044274656673534260788169227), .01135828330503278417235563981454793), // 76 304 PQP3(R3(.08000490008644308882018405418010744, .24689045570275147370034631014113188, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188)), + 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188)), .01103203882197761043040360052454856), // 77 308 - PQP3(R3(.08000490008644308882018405418010744, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), + PQP3(R3(.08000490008644308882018405418010744, 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .24689045570275147370034631014113188), .01103203882197761043040360052454856), // 78 312 PQP3(R3(.24689045570275147370034631014113188, .08000490008644308882018405418010744, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188)), + 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188)), .01103203882197761043040360052454856), // 79 316 - PQP3(R3(.24689045570275147370034631014113188, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), + PQP3(R3(.24689045570275147370034631014113188, 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 80 320 - PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), - .08000490008644308882018405418010744, .24689045570275147370034631014113188), + PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .08000490008644308882018405418010744, + .24689045570275147370034631014113188), .01103203882197761043040360052454856), // 81 324 - PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), - .24689045570275147370034631014113188, .08000490008644308882018405418010744), + PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .24689045570275147370034631014113188, + .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 82 328 PQP3(R3(.08000490008644308882018405418010744, .08000490008644308882018405418010744, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188)), + 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188)), .01103203882197761043040360052454856), // 83 332 - PQP3(R3(.08000490008644308882018405418010744, - 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), + PQP3(R3(.08000490008644308882018405418010744, 1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 84 336 - PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - - (.24689045570275147370034631014113188), - .08000490008644308882018405418010744, .08000490008644308882018405418010744), + PQP3(R3(1. - (.08000490008644308882018405418010744) - (.08000490008644308882018405418010744) - (.24689045570275147370034631014113188), .08000490008644308882018405418010744, + .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 85 340 - PQP3(R3(.08000490008644308882018405418010744, .08000490008644308882018405418010744, - .24689045570275147370034631014113188), + PQP3(R3(.08000490008644308882018405418010744, .08000490008644308882018405418010744, .24689045570275147370034631014113188), .01103203882197761043040360052454856), // 86 344 - PQP3(R3(.08000490008644308882018405418010744, .24689045570275147370034631014113188, - .08000490008644308882018405418010744), + PQP3(R3(.08000490008644308882018405418010744, .24689045570275147370034631014113188, .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 87 348 - PQP3(R3(.24689045570275147370034631014113188, .08000490008644308882018405418010744, - .08000490008644308882018405418010744), + PQP3(R3(.24689045570275147370034631014113188, .08000490008644308882018405418010744, .08000490008644308882018405418010744), .01103203882197761043040360052454856), // 88 352 PQP3(R3(.11579466150271899371721034492503850, .74997281767443310000000000000000000, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000)), + 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000)), .00457602573785952356043458354199517), // 89 356 - PQP3(R3(.11579466150271899371721034492503850, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), + PQP3(R3(.11579466150271899371721034492503850, 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .74997281767443310000000000000000000), .00457602573785952356043458354199517), // 90 360 PQP3(R3(.74997281767443310000000000000000000, .11579466150271899371721034492503850, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000)), + 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000)), .00457602573785952356043458354199517), // 91 364 - PQP3(R3(.74997281767443310000000000000000000, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), + PQP3(R3(.74997281767443310000000000000000000, 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 92 368 - PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), - .11579466150271899371721034492503850, .74997281767443310000000000000000000), + PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .11579466150271899371721034492503850, + .74997281767443310000000000000000000), .00457602573785952356043458354199517), // 93 372 - PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), - .74997281767443310000000000000000000, .11579466150271899371721034492503850), + PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .74997281767443310000000000000000000, + .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 94 376 PQP3(R3(.11579466150271899371721034492503850, .11579466150271899371721034492503850, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000)), + 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000)), .00457602573785952356043458354199517), // 95 380 - PQP3(R3(.11579466150271899371721034492503850, - 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), + PQP3(R3(.11579466150271899371721034492503850, 1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 96 384 - PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - - (.74997281767443310000000000000000000), - .11579466150271899371721034492503850, .11579466150271899371721034492503850), + PQP3(R3(1. - (.11579466150271899371721034492503850) - (.11579466150271899371721034492503850) - (.74997281767443310000000000000000000), .11579466150271899371721034492503850, + .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 97 388 - PQP3(R3(.11579466150271899371721034492503850, .11579466150271899371721034492503850, - .74997281767443310000000000000000000), + PQP3(R3(.11579466150271899371721034492503850, .11579466150271899371721034492503850, .74997281767443310000000000000000000), .00457602573785952356043458354199517), // 98 392 - PQP3(R3(.11579466150271899371721034492503850, .74997281767443310000000000000000000, - .11579466150271899371721034492503850), + PQP3(R3(.11579466150271899371721034492503850, .74997281767443310000000000000000000, .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 99 396 - PQP3(R3(.74997281767443310000000000000000000, .11579466150271899371721034492503850, - .11579466150271899371721034492503850), + PQP3(R3(.74997281767443310000000000000000000, .11579466150271899371721034492503850, .11579466150271899371721034492503850), .00457602573785952356043458354199517), // 100 400 PQP3(R3(.39129315347000474438672195978809687, .18835457382799180000000000000000000, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000)), + 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000)), .00827343104220868129752243222682095), // 101 404 - PQP3(R3(.39129315347000474438672195978809687, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), + PQP3(R3(.39129315347000474438672195978809687, 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .18835457382799180000000000000000000), .00827343104220868129752243222682095), // 102 408 PQP3(R3(.18835457382799180000000000000000000, .39129315347000474438672195978809687, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000)), + 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000)), .00827343104220868129752243222682095), // 103 412 - PQP3(R3(.18835457382799180000000000000000000, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), + PQP3(R3(.18835457382799180000000000000000000, 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 104 416 - PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), - .39129315347000474438672195978809687, .18835457382799180000000000000000000), + PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .39129315347000474438672195978809687, + .18835457382799180000000000000000000), .00827343104220868129752243222682095), // 105 420 - PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), - .18835457382799180000000000000000000, .39129315347000474438672195978809687), + PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .18835457382799180000000000000000000, + .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 106 424 PQP3(R3(.39129315347000474438672195978809687, .39129315347000474438672195978809687, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000)), + 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000)), .00827343104220868129752243222682095), // 107 428 - PQP3(R3(.39129315347000474438672195978809687, - 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), + PQP3(R3(.39129315347000474438672195978809687, 1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 108 432 - PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - - (.18835457382799180000000000000000000), - .39129315347000474438672195978809687, .39129315347000474438672195978809687), + PQP3(R3(1. - (.39129315347000474438672195978809687) - (.39129315347000474438672195978809687) - (.18835457382799180000000000000000000), .39129315347000474438672195978809687, + .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 109 436 - PQP3(R3(.39129315347000474438672195978809687, .39129315347000474438672195978809687, - .18835457382799180000000000000000000), + PQP3(R3(.39129315347000474438672195978809687, .39129315347000474438672195978809687, .18835457382799180000000000000000000), .00827343104220868129752243222682095), // 110 440 - PQP3(R3(.39129315347000474438672195978809687, .18835457382799180000000000000000000, - .39129315347000474438672195978809687), + PQP3(R3(.39129315347000474438672195978809687, .18835457382799180000000000000000000, .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 111 444 - PQP3(R3(.18835457382799180000000000000000000, .39129315347000474438672195978809687, - .39129315347000474438672195978809687), + PQP3(R3(.18835457382799180000000000000000000, .39129315347000474438672195978809687, .39129315347000474438672195978809687), .00827343104220868129752243222682095), // 112 448 PQP3(R3(.45315745821242834581317282468854978, .02202033169457796534173826092007299, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299)), + 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299)), .00586641165391940007076312979369247), // 113 452 - PQP3(R3(.45315745821242834581317282468854978, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), + PQP3(R3(.45315745821242834581317282468854978, 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .02202033169457796534173826092007299), .00586641165391940007076312979369247), // 114 456 PQP3(R3(.02202033169457796534173826092007299, .45315745821242834581317282468854978, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299)), + 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299)), .00586641165391940007076312979369247), // 115 460 - PQP3(R3(.02202033169457796534173826092007299, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), + PQP3(R3(.02202033169457796534173826092007299, 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 116 464 - PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), - .45315745821242834581317282468854978, .02202033169457796534173826092007299), + PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .45315745821242834581317282468854978, + .02202033169457796534173826092007299), .00586641165391940007076312979369247), // 117 468 - PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), - .02202033169457796534173826092007299, .45315745821242834581317282468854978), + PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .02202033169457796534173826092007299, + .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 118 472 PQP3(R3(.45315745821242834581317282468854978, .45315745821242834581317282468854978, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299)), + 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299)), .00586641165391940007076312979369247), // 119 476 - PQP3(R3(.45315745821242834581317282468854978, - 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), + PQP3(R3(.45315745821242834581317282468854978, 1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 120 480 - PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - - (.02202033169457796534173826092007299), - .45315745821242834581317282468854978, .45315745821242834581317282468854978), + PQP3(R3(1. - (.45315745821242834581317282468854978) - (.45315745821242834581317282468854978) - (.02202033169457796534173826092007299), .45315745821242834581317282468854978, + .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 121 484 - PQP3(R3(.45315745821242834581317282468854978, .45315745821242834581317282468854978, - .02202033169457796534173826092007299), + PQP3(R3(.45315745821242834581317282468854978, .45315745821242834581317282468854978, .02202033169457796534173826092007299), .00586641165391940007076312979369247), // 122 488 - PQP3(R3(.45315745821242834581317282468854978, .02202033169457796534173826092007299, - .45315745821242834581317282468854978), + PQP3(R3(.45315745821242834581317282468854978, .02202033169457796534173826092007299, .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 123 492 - PQP3(R3(.02202033169457796534173826092007299, .45315745821242834581317282468854978, - .45315745821242834581317282468854978), + PQP3(R3(.02202033169457796534173826092007299, .45315745821242834581317282468854978, .45315745821242834581317282468854978), .00586641165391940007076312979369247), // 124 496 PQP3(R3(.60775441245653315696274741541102470, .00561877924700169073874366184065955, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 125 500 - PQP3(R3(.60775441245653315696274741541102470, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.60775441245653315696274741541102470, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 126 504 PQP3(R3(.00561877924700169073874366184065955, .60775441245653315696274741541102470, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 127 508 - PQP3(R3(.00561877924700169073874366184065955, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.00561877924700169073874366184065955, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 128 512 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .60775441245653315696274741541102470, .00561877924700169073874366184065955), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .60775441245653315696274741541102470, + .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 129 516 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .00561877924700169073874366184065955, .60775441245653315696274741541102470), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .00561877924700169073874366184065955, + .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 130 520 PQP3(R3(.27324999892429634023602493512400674, .00561877924700169073874366184065955, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 131 524 - PQP3(R3(.27324999892429634023602493512400674, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.27324999892429634023602493512400674, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 132 528 PQP3(R3(.00561877924700169073874366184065955, .27324999892429634023602493512400674, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 133 532 - PQP3(R3(.00561877924700169073874366184065955, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.00561877924700169073874366184065955, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 134 536 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .27324999892429634023602493512400674, .00561877924700169073874366184065955), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .27324999892429634023602493512400674, + .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 135 540 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .00561877924700169073874366184065955, .27324999892429634023602493512400674), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .00561877924700169073874366184065955, + .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 136 544 PQP3(R3(.27324999892429634023602493512400674, .60775441245653315696274741541102470, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 137 548 - PQP3(R3(.27324999892429634023602493512400674, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.27324999892429634023602493512400674, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 138 552 PQP3(R3(.60775441245653315696274741541102470, .27324999892429634023602493512400674, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955)), + 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955)), .00313458521939849614410720196518793), // 139 556 - PQP3(R3(.60775441245653315696274741541102470, - 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), + PQP3(R3(.60775441245653315696274741541102470, 1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 140 560 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .27324999892429634023602493512400674, .60775441245653315696274741541102470), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .27324999892429634023602493512400674, + .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 141 564 - PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - - (.00561877924700169073874366184065955), - .60775441245653315696274741541102470, .27324999892429634023602493512400674), + PQP3(R3(1. - (.27324999892429634023602493512400674) - (.60775441245653315696274741541102470) - (.00561877924700169073874366184065955), .60775441245653315696274741541102470, + .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 142 568 - PQP3(R3(.27324999892429634023602493512400674, .60775441245653315696274741541102470, - .00561877924700169073874366184065955), + PQP3(R3(.27324999892429634023602493512400674, .60775441245653315696274741541102470, .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 143 572 - PQP3(R3(.27324999892429634023602493512400674, .00561877924700169073874366184065955, - .60775441245653315696274741541102470), + PQP3(R3(.27324999892429634023602493512400674, .00561877924700169073874366184065955, .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 144 576 - PQP3(R3(.60775441245653315696274741541102470, .27324999892429634023602493512400674, - .00561877924700169073874366184065955), + PQP3(R3(.60775441245653315696274741541102470, .27324999892429634023602493512400674, .00561877924700169073874366184065955), .00313458521939849614410720196518793), // 145 580 - PQP3(R3(.60775441245653315696274741541102470, .00561877924700169073874366184065955, - .27324999892429634023602493512400674), + PQP3(R3(.60775441245653315696274741541102470, .00561877924700169073874366184065955, .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 146 584 - PQP3(R3(.00561877924700169073874366184065955, .27324999892429634023602493512400674, - .60775441245653315696274741541102470), + PQP3(R3(.00561877924700169073874366184065955, .27324999892429634023602493512400674, .60775441245653315696274741541102470), .00313458521939849614410720196518793), // 147 588 - PQP3(R3(.00561877924700169073874366184065955, .60775441245653315696274741541102470, - .27324999892429634023602493512400674), + PQP3(R3(.00561877924700169073874366184065955, .60775441245653315696274741541102470, .27324999892429634023602493512400674), .00313458521939849614410720196518793), // 148 592 }; PQF3 const QuadratureFormular_Tet_P13(13, 149, QF_TET_P13); // QUAD QUAD_3D_P14_ = { 194 776 PQP3 QF_TET_P14[] = { - PQP3(R3(.12703434587701869604797950660749487, .12703434587701869604797950660749487, - .12703434587701869604797950660749487), + PQP3(R3(.12703434587701869604797950660749487, .12703434587701869604797950660749487, .12703434587701869604797950660749487), .00898427322254918127543126682598773), // 0 0 - PQP3(R3(1. - 3. * (.12703434587701869604797950660749487), .12703434587701869604797950660749487, - .12703434587701869604797950660749487), + PQP3(R3(1. - 3. * (.12703434587701869604797950660749487), .12703434587701869604797950660749487, .12703434587701869604797950660749487), .00898427322254918127543126682598773), // 1 4 - PQP3(R3(.12703434587701869604797950660749487, 1. - 3. * (.12703434587701869604797950660749487), - .12703434587701869604797950660749487), + PQP3(R3(.12703434587701869604797950660749487, 1. - 3. * (.12703434587701869604797950660749487), .12703434587701869604797950660749487), .00898427322254918127543126682598773), // 2 8 - PQP3(R3(.12703434587701869604797950660749487, .12703434587701869604797950660749487, - 1. - 3. * (.12703434587701869604797950660749487)), + PQP3(R3(.12703434587701869604797950660749487, .12703434587701869604797950660749487, 1. - 3. * (.12703434587701869604797950660749487)), .00898427322254918127543126682598773), // 3 12 - PQP3(R3(.03716308713428675181759859706979325, .03716308713428675181759859706979325, - .03716308713428675181759859706979325), + PQP3(R3(.03716308713428675181759859706979325, .03716308713428675181759859706979325, .03716308713428675181759859706979325), .00235414897468188299910869230818368), // 4 16 - PQP3(R3(1. - 3. * (.03716308713428675181759859706979325), .03716308713428675181759859706979325, - .03716308713428675181759859706979325), + PQP3(R3(1. - 3. * (.03716308713428675181759859706979325), .03716308713428675181759859706979325, .03716308713428675181759859706979325), .00235414897468188299910869230818368), // 5 20 - PQP3(R3(.03716308713428675181759859706979325, 1. - 3. * (.03716308713428675181759859706979325), - .03716308713428675181759859706979325), + PQP3(R3(.03716308713428675181759859706979325, 1. - 3. * (.03716308713428675181759859706979325), .03716308713428675181759859706979325), .00235414897468188299910869230818368), // 6 24 - PQP3(R3(.03716308713428675181759859706979325, .03716308713428675181759859706979325, - 1. - 3. * (.03716308713428675181759859706979325)), + PQP3(R3(.03716308713428675181759859706979325, .03716308713428675181759859706979325, 1. - 3. * (.03716308713428675181759859706979325)), .00235414897468188299910869230818368), // 7 28 - PQP3(R3(.30931161817607732544635505822019770, .30931161817607732544635505822019770, - .30931161817607732544635505822019770), + PQP3(R3(.30931161817607732544635505822019770, .30931161817607732544635505822019770, .30931161817607732544635505822019770), .00733553866836377016223467789336265), // 8 32 - PQP3(R3(1. - 3. * (.30931161817607732544635505822019770), .30931161817607732544635505822019770, - .30931161817607732544635505822019770), + PQP3(R3(1. - 3. * (.30931161817607732544635505822019770), .30931161817607732544635505822019770, .30931161817607732544635505822019770), .00733553866836377016223467789336265), // 9 36 - PQP3(R3(.30931161817607732544635505822019770, 1. - 3. * (.30931161817607732544635505822019770), - .30931161817607732544635505822019770), + PQP3(R3(.30931161817607732544635505822019770, 1. - 3. * (.30931161817607732544635505822019770), .30931161817607732544635505822019770), .00733553866836377016223467789336265), // 10 40 - PQP3(R3(.30931161817607732544635505822019770, .30931161817607732544635505822019770, - 1. - 3. * (.30931161817607732544635505822019770)), + PQP3(R3(.30931161817607732544635505822019770, .30931161817607732544635505822019770, 1. - 3. * (.30931161817607732544635505822019770)), .00733553866836377016223467789336265), // 11 44 - PQP3(R3(.07778813507287403019691221965639750, .07778813507287403019691221965639750, - .07778813507287403019691221965639750), + PQP3(R3(.07778813507287403019691221965639750, .07778813507287403019691221965639750, .07778813507287403019691221965639750), .00360629336228634011530354432318077), // 12 48 - PQP3(R3(1. - 3. * (.07778813507287403019691221965639750), .07778813507287403019691221965639750, - .07778813507287403019691221965639750), + PQP3(R3(1. - 3. * (.07778813507287403019691221965639750), .07778813507287403019691221965639750, .07778813507287403019691221965639750), .00360629336228634011530354432318077), // 13 52 - PQP3(R3(.07778813507287403019691221965639750, 1. - 3. * (.07778813507287403019691221965639750), - .07778813507287403019691221965639750), + PQP3(R3(.07778813507287403019691221965639750, 1. - 3. * (.07778813507287403019691221965639750), .07778813507287403019691221965639750), .00360629336228634011530354432318077), // 14 56 - PQP3(R3(.07778813507287403019691221965639750, .07778813507287403019691221965639750, - 1. - 3. * (.07778813507287403019691221965639750)), + PQP3(R3(.07778813507287403019691221965639750, .07778813507287403019691221965639750, 1. - 3. * (.07778813507287403019691221965639750)), .00360629336228634011530354432318077), // 15 60 - PQP3(R3(.01187611663683786502091234677477106, .01187611663683786502091234677477106, - .01187611663683786502091234677477106), + PQP3(R3(.01187611663683786502091234677477106, .01187611663683786502091234677477106, .01187611663683786502091234677477106), .00022796656022189240650071390651338), // 16 64 - PQP3(R3(1. - 3. * (.01187611663683786502091234677477106), .01187611663683786502091234677477106, - .01187611663683786502091234677477106), + PQP3(R3(1. - 3. * (.01187611663683786502091234677477106), .01187611663683786502091234677477106, .01187611663683786502091234677477106), .00022796656022189240650071390651338), // 17 68 - PQP3(R3(.01187611663683786502091234677477106, 1. - 3. * (.01187611663683786502091234677477106), - .01187611663683786502091234677477106), + PQP3(R3(.01187611663683786502091234677477106, 1. - 3. * (.01187611663683786502091234677477106), .01187611663683786502091234677477106), .00022796656022189240650071390651338), // 18 72 - PQP3(R3(.01187611663683786502091234677477106, .01187611663683786502091234677477106, - 1. - 3. * (.01187611663683786502091234677477106)), + PQP3(R3(.01187611663683786502091234677477106, .01187611663683786502091234677477106, 1. - 3. * (.01187611663683786502091234677477106)), .00022796656022189240650071390651338), // 19 76 - PQP3(R3(.02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476), - .5 - (.02371189715571358237825633505545476)), + PQP3(R3(.02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476), .5 - (.02371189715571358237825633505545476)), .00425068731230945391542573203967906), // 20 80 - PQP3(R3(.5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476, - .5 - (.02371189715571358237825633505545476)), + PQP3(R3(.5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476)), .00425068731230945391542573203967906), // 21 84 - PQP3(R3(.5 - (.02371189715571358237825633505545476), .5 - (.02371189715571358237825633505545476), - .02371189715571358237825633505545476), + PQP3(R3(.5 - (.02371189715571358237825633505545476), .5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476), .00425068731230945391542573203967906), // 22 88 - PQP3(R3(.02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476), - .02371189715571358237825633505545476), + PQP3(R3(.02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476), .00425068731230945391542573203967906), // 23 92 - PQP3(R3(.02371189715571358237825633505545476, .02371189715571358237825633505545476, - .5 - (.02371189715571358237825633505545476)), + PQP3(R3(.02371189715571358237825633505545476, .02371189715571358237825633505545476, .5 - (.02371189715571358237825633505545476)), .00425068731230945391542573203967906), // 24 96 - PQP3(R3(.5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476, - .02371189715571358237825633505545476), + PQP3(R3(.5 - (.02371189715571358237825633505545476), .02371189715571358237825633505545476, .02371189715571358237825633505545476), .00425068731230945391542573203967906), // 25 100 PQP3(R3(.04551422172971295738029708158398140, .73884882267833978290969755547076243, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243)), + 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243)), .00502229674184657212637707578731437), // 26 104 - PQP3(R3(.04551422172971295738029708158398140, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), + PQP3(R3(.04551422172971295738029708158398140, 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .73884882267833978290969755547076243), .00502229674184657212637707578731437), // 27 108 PQP3(R3(.73884882267833978290969755547076243, .04551422172971295738029708158398140, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243)), + 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243)), .00502229674184657212637707578731437), // 28 112 - PQP3(R3(.73884882267833978290969755547076243, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), + PQP3(R3(.73884882267833978290969755547076243, 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 29 116 - PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), - .04551422172971295738029708158398140, .73884882267833978290969755547076243), + PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .04551422172971295738029708158398140, + .73884882267833978290969755547076243), .00502229674184657212637707578731437), // 30 120 - PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), - .73884882267833978290969755547076243, .04551422172971295738029708158398140), + PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .73884882267833978290969755547076243, + .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 31 124 PQP3(R3(.04551422172971295738029708158398140, .04551422172971295738029708158398140, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243)), + 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243)), .00502229674184657212637707578731437), // 32 128 - PQP3(R3(.04551422172971295738029708158398140, - 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), + PQP3(R3(.04551422172971295738029708158398140, 1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 33 132 - PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - - (.73884882267833978290969755547076243), - .04551422172971295738029708158398140, .04551422172971295738029708158398140), + PQP3(R3(1. - (.04551422172971295738029708158398140) - (.04551422172971295738029708158398140) - (.73884882267833978290969755547076243), .04551422172971295738029708158398140, + .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 34 136 - PQP3(R3(.04551422172971295738029708158398140, .04551422172971295738029708158398140, - .73884882267833978290969755547076243), + PQP3(R3(.04551422172971295738029708158398140, .04551422172971295738029708158398140, .73884882267833978290969755547076243), .00502229674184657212637707578731437), // 35 140 - PQP3(R3(.04551422172971295738029708158398140, .73884882267833978290969755547076243, - .04551422172971295738029708158398140), + PQP3(R3(.04551422172971295738029708158398140, .73884882267833978290969755547076243, .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 36 144 - PQP3(R3(.73884882267833978290969755547076243, .04551422172971295738029708158398140, - .04551422172971295738029708158398140), + PQP3(R3(.73884882267833978290969755547076243, .04551422172971295738029708158398140, .04551422172971295738029708158398140), .00502229674184657212637707578731437), // 37 148 PQP3(R3(.19457055431059420000000000000000000, .36138202354403612356128050094846106, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106)), + 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106)), .00664105199619194276141547967835717), // 38 152 - PQP3(R3(.19457055431059420000000000000000000, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), + PQP3(R3(.19457055431059420000000000000000000, 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .36138202354403612356128050094846106), .00664105199619194276141547967835717), // 39 156 PQP3(R3(.36138202354403612356128050094846106, .19457055431059420000000000000000000, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106)), + 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106)), .00664105199619194276141547967835717), // 40 160 - PQP3(R3(.36138202354403612356128050094846106, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), + PQP3(R3(.36138202354403612356128050094846106, 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 41 164 - PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), - .19457055431059420000000000000000000, .36138202354403612356128050094846106), + PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .19457055431059420000000000000000000, + .36138202354403612356128050094846106), .00664105199619194276141547967835717), // 42 168 - PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), - .36138202354403612356128050094846106, .19457055431059420000000000000000000), + PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .36138202354403612356128050094846106, + .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 43 172 PQP3(R3(.19457055431059420000000000000000000, .19457055431059420000000000000000000, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106)), + 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106)), .00664105199619194276141547967835717), // 44 176 - PQP3(R3(.19457055431059420000000000000000000, - 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), + PQP3(R3(.19457055431059420000000000000000000, 1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 45 180 - PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - - (.36138202354403612356128050094846106), - .19457055431059420000000000000000000, .19457055431059420000000000000000000), + PQP3(R3(1. - (.19457055431059420000000000000000000) - (.19457055431059420000000000000000000) - (.36138202354403612356128050094846106), .19457055431059420000000000000000000, + .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 46 184 - PQP3(R3(.19457055431059420000000000000000000, .19457055431059420000000000000000000, - .36138202354403612356128050094846106), + PQP3(R3(.19457055431059420000000000000000000, .19457055431059420000000000000000000, .36138202354403612356128050094846106), .00664105199619194276141547967835717), // 47 188 - PQP3(R3(.19457055431059420000000000000000000, .36138202354403612356128050094846106, - .19457055431059420000000000000000000), + PQP3(R3(.19457055431059420000000000000000000, .36138202354403612356128050094846106, .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 48 192 - PQP3(R3(.36138202354403612356128050094846106, .19457055431059420000000000000000000, - .19457055431059420000000000000000000), + PQP3(R3(.36138202354403612356128050094846106, .19457055431059420000000000000000000, .19457055431059420000000000000000000), .00664105199619194276141547967835717), // 49 196 PQP3(R3(.42158193164647035846631052119479790, .13481021809330111977392354242291205, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205)), + 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205)), .00648663075652078221084713724389357), // 50 200 - PQP3(R3(.42158193164647035846631052119479790, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), + PQP3(R3(.42158193164647035846631052119479790, 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .13481021809330111977392354242291205), .00648663075652078221084713724389357), // 51 204 PQP3(R3(.13481021809330111977392354242291205, .42158193164647035846631052119479790, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205)), + 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205)), .00648663075652078221084713724389357), // 52 208 - PQP3(R3(.13481021809330111977392354242291205, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), + PQP3(R3(.13481021809330111977392354242291205, 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 53 212 - PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), - .42158193164647035846631052119479790, .13481021809330111977392354242291205), + PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .42158193164647035846631052119479790, + .13481021809330111977392354242291205), .00648663075652078221084713724389357), // 54 216 - PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), - .13481021809330111977392354242291205, .42158193164647035846631052119479790), + PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .13481021809330111977392354242291205, + .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 55 220 PQP3(R3(.42158193164647035846631052119479790, .42158193164647035846631052119479790, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205)), + 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205)), .00648663075652078221084713724389357), // 56 224 - PQP3(R3(.42158193164647035846631052119479790, - 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), + PQP3(R3(.42158193164647035846631052119479790, 1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 57 228 - PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - - (.13481021809330111977392354242291205), - .42158193164647035846631052119479790, .42158193164647035846631052119479790), + PQP3(R3(1. - (.42158193164647035846631052119479790) - (.42158193164647035846631052119479790) - (.13481021809330111977392354242291205), .42158193164647035846631052119479790, + .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 58 232 - PQP3(R3(.42158193164647035846631052119479790, .42158193164647035846631052119479790, - .13481021809330111977392354242291205), + PQP3(R3(.42158193164647035846631052119479790, .42158193164647035846631052119479790, .13481021809330111977392354242291205), .00648663075652078221084713724389357), // 59 236 - PQP3(R3(.42158193164647035846631052119479790, .13481021809330111977392354242291205, - .42158193164647035846631052119479790), + PQP3(R3(.42158193164647035846631052119479790, .13481021809330111977392354242291205, .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 60 240 - PQP3(R3(.13481021809330111977392354242291205, .42158193164647035846631052119479790, - .42158193164647035846631052119479790), + PQP3(R3(.13481021809330111977392354242291205, .42158193164647035846631052119479790, .42158193164647035846631052119479790), .00648663075652078221084713724389357), // 61 244 PQP3(R3(.36227661803202431683389679069549247, .09100846759454444774082592541447308, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308)), + 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308)), .01084924609520658118048627917429636), // 62 248 - PQP3(R3(.36227661803202431683389679069549247, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), + PQP3(R3(.36227661803202431683389679069549247, 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .09100846759454444774082592541447308), .01084924609520658118048627917429636), // 63 252 PQP3(R3(.09100846759454444774082592541447308, .36227661803202431683389679069549247, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308)), + 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308)), .01084924609520658118048627917429636), // 64 256 - PQP3(R3(.09100846759454444774082592541447308, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), + PQP3(R3(.09100846759454444774082592541447308, 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 65 260 - PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), - .36227661803202431683389679069549247, .09100846759454444774082592541447308), + PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .36227661803202431683389679069549247, + .09100846759454444774082592541447308), .01084924609520658118048627917429636), // 66 264 - PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), - .09100846759454444774082592541447308, .36227661803202431683389679069549247), + PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .09100846759454444774082592541447308, + .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 67 268 PQP3(R3(.36227661803202431683389679069549247, .36227661803202431683389679069549247, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308)), + 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308)), .01084924609520658118048627917429636), // 68 272 - PQP3(R3(.36227661803202431683389679069549247, - 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), + PQP3(R3(.36227661803202431683389679069549247, 1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 69 276 - PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - - (.09100846759454444774082592541447308), - .36227661803202431683389679069549247, .36227661803202431683389679069549247), + PQP3(R3(1. - (.36227661803202431683389679069549247) - (.36227661803202431683389679069549247) - (.09100846759454444774082592541447308), .36227661803202431683389679069549247, + .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 70 280 - PQP3(R3(.36227661803202431683389679069549247, .36227661803202431683389679069549247, - .09100846759454444774082592541447308), + PQP3(R3(.36227661803202431683389679069549247, .36227661803202431683389679069549247, .09100846759454444774082592541447308), .01084924609520658118048627917429636), // 71 284 - PQP3(R3(.36227661803202431683389679069549247, .09100846759454444774082592541447308, - .36227661803202431683389679069549247), + PQP3(R3(.36227661803202431683389679069549247, .09100846759454444774082592541447308, .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 72 288 - PQP3(R3(.09100846759454444774082592541447308, .36227661803202431683389679069549247, - .36227661803202431683389679069549247), + PQP3(R3(.09100846759454444774082592541447308, .36227661803202431683389679069549247, .36227661803202431683389679069549247), .01084924609520658118048627917429636), // 73 292 PQP3(R3(.26662003783461096351186917353420086, .45135951603290056428206454329600320, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320)), + 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320)), .00698225572400728567899793615355807), // 74 296 - PQP3(R3(.26662003783461096351186917353420086, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), + PQP3(R3(.26662003783461096351186917353420086, 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .45135951603290056428206454329600320), .00698225572400728567899793615355807), // 75 300 PQP3(R3(.45135951603290056428206454329600320, .26662003783461096351186917353420086, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320)), + 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320)), .00698225572400728567899793615355807), // 76 304 - PQP3(R3(.45135951603290056428206454329600320, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), + PQP3(R3(.45135951603290056428206454329600320, 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 77 308 - PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), - .26662003783461096351186917353420086, .45135951603290056428206454329600320), + PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .26662003783461096351186917353420086, + .45135951603290056428206454329600320), .00698225572400728567899793615355807), // 78 312 - PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), - .45135951603290056428206454329600320, .26662003783461096351186917353420086), + PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .45135951603290056428206454329600320, + .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 79 316 PQP3(R3(.26662003783461096351186917353420086, .26662003783461096351186917353420086, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320)), + 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320)), .00698225572400728567899793615355807), // 80 320 - PQP3(R3(.26662003783461096351186917353420086, - 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), + PQP3(R3(.26662003783461096351186917353420086, 1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 81 324 - PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - - (.45135951603290056428206454329600320), - .26662003783461096351186917353420086, .26662003783461096351186917353420086), + PQP3(R3(1. - (.26662003783461096351186917353420086) - (.26662003783461096351186917353420086) - (.45135951603290056428206454329600320), .26662003783461096351186917353420086, + .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 82 328 - PQP3(R3(.26662003783461096351186917353420086, .26662003783461096351186917353420086, - .45135951603290056428206454329600320), + PQP3(R3(.26662003783461096351186917353420086, .26662003783461096351186917353420086, .45135951603290056428206454329600320), .00698225572400728567899793615355807), // 83 332 - PQP3(R3(.26662003783461096351186917353420086, .45135951603290056428206454329600320, - .26662003783461096351186917353420086), + PQP3(R3(.26662003783461096351186917353420086, .45135951603290056428206454329600320, .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 84 336 - PQP3(R3(.45135951603290056428206454329600320, .26662003783461096351186917353420086, - .26662003783461096351186917353420086), + PQP3(R3(.45135951603290056428206454329600320, .26662003783461096351186917353420086, .26662003783461096351186917353420086), .00698225572400728567899793615355807), // 85 340 PQP3(R3(.07870367664603755989163074150395650, .53854007868617855365162509332690316, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316)), + 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316)), .01057643198113441258335538488635301), // 86 344 - PQP3(R3(.07870367664603755989163074150395650, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), + PQP3(R3(.07870367664603755989163074150395650, 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .53854007868617855365162509332690316), .01057643198113441258335538488635301), // 87 348 PQP3(R3(.53854007868617855365162509332690316, .07870367664603755989163074150395650, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316)), + 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316)), .01057643198113441258335538488635301), // 88 352 - PQP3(R3(.53854007868617855365162509332690316, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), + PQP3(R3(.53854007868617855365162509332690316, 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 89 356 - PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), - .07870367664603755989163074150395650, .53854007868617855365162509332690316), + PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .07870367664603755989163074150395650, + .53854007868617855365162509332690316), .01057643198113441258335538488635301), // 90 360 - PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), - .53854007868617855365162509332690316, .07870367664603755989163074150395650), + PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .53854007868617855365162509332690316, + .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 91 364 PQP3(R3(.07870367664603755989163074150395650, .07870367664603755989163074150395650, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316)), + 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316)), .01057643198113441258335538488635301), // 92 368 - PQP3(R3(.07870367664603755989163074150395650, - 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), + PQP3(R3(.07870367664603755989163074150395650, 1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 93 372 - PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - - (.53854007868617855365162509332690316), - .07870367664603755989163074150395650, .07870367664603755989163074150395650), + PQP3(R3(1. - (.07870367664603755989163074150395650) - (.07870367664603755989163074150395650) - (.53854007868617855365162509332690316), .07870367664603755989163074150395650, + .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 94 376 - PQP3(R3(.07870367664603755989163074150395650, .07870367664603755989163074150395650, - .53854007868617855365162509332690316), + PQP3(R3(.07870367664603755989163074150395650, .07870367664603755989163074150395650, .53854007868617855365162509332690316), .01057643198113441258335538488635301), // 95 380 - PQP3(R3(.07870367664603755989163074150395650, .53854007868617855365162509332690316, - .07870367664603755989163074150395650), + PQP3(R3(.07870367664603755989163074150395650, .53854007868617855365162509332690316, .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 96 384 - PQP3(R3(.53854007868617855365162509332690316, .07870367664603755989163074150395650, - .07870367664603755989163074150395650), + PQP3(R3(.53854007868617855365162509332690316, .07870367664603755989163074150395650, .07870367664603755989163074150395650), .01057643198113441258335538488635301), // 97 388 PQP3(R3(.01462604843949452202375023818416595, .68140642280720592407050422036244765, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765)), + 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765)), .00172517387494940531214061228255136), // 98 392 - PQP3(R3(.01462604843949452202375023818416595, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), + PQP3(R3(.01462604843949452202375023818416595, 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .68140642280720592407050422036244765), .00172517387494940531214061228255136), // 99 396 PQP3(R3(.68140642280720592407050422036244765, .01462604843949452202375023818416595, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765)), + 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765)), .00172517387494940531214061228255136), // 100 400 - PQP3(R3(.68140642280720592407050422036244765, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), + PQP3(R3(.68140642280720592407050422036244765, 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 101 404 - PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), - .01462604843949452202375023818416595, .68140642280720592407050422036244765), + PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .01462604843949452202375023818416595, + .68140642280720592407050422036244765), .00172517387494940531214061228255136), // 102 408 - PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), - .68140642280720592407050422036244765, .01462604843949452202375023818416595), + PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .68140642280720592407050422036244765, + .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 103 412 PQP3(R3(.01462604843949452202375023818416595, .01462604843949452202375023818416595, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765)), + 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765)), .00172517387494940531214061228255136), // 104 416 - PQP3(R3(.01462604843949452202375023818416595, - 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), + PQP3(R3(.01462604843949452202375023818416595, 1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 105 420 - PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - - (.68140642280720592407050422036244765), - .01462604843949452202375023818416595, .01462604843949452202375023818416595), + PQP3(R3(1. - (.01462604843949452202375023818416595) - (.01462604843949452202375023818416595) - (.68140642280720592407050422036244765), .01462604843949452202375023818416595, + .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 106 424 - PQP3(R3(.01462604843949452202375023818416595, .01462604843949452202375023818416595, - .68140642280720592407050422036244765), + PQP3(R3(.01462604843949452202375023818416595, .01462604843949452202375023818416595, .68140642280720592407050422036244765), .00172517387494940531214061228255136), // 107 428 - PQP3(R3(.01462604843949452202375023818416595, .68140642280720592407050422036244765, - .01462604843949452202375023818416595), + PQP3(R3(.01462604843949452202375023818416595, .68140642280720592407050422036244765, .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 108 432 - PQP3(R3(.68140642280720592407050422036244765, .01462604843949452202375023818416595, - .01462604843949452202375023818416595), + PQP3(R3(.68140642280720592407050422036244765, .01462604843949452202375023818416595, .01462604843949452202375023818416595), .00172517387494940531214061228255136), // 109 436 PQP3(R3(.20755902173331721318141636044536441, .49641284136813420000000000000000000, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000)), + 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000)), .01064026039260234415487304925754523), // 110 440 - PQP3(R3(.20755902173331721318141636044536441, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), + PQP3(R3(.20755902173331721318141636044536441, 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .49641284136813420000000000000000000), .01064026039260234415487304925754523), // 111 444 PQP3(R3(.49641284136813420000000000000000000, .20755902173331721318141636044536441, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000)), + 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000)), .01064026039260234415487304925754523), // 112 448 - PQP3(R3(.49641284136813420000000000000000000, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), + PQP3(R3(.49641284136813420000000000000000000, 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 113 452 - PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), - .20755902173331721318141636044536441, .49641284136813420000000000000000000), + PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .20755902173331721318141636044536441, + .49641284136813420000000000000000000), .01064026039260234415487304925754523), // 114 456 - PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), - .49641284136813420000000000000000000, .20755902173331721318141636044536441), + PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .49641284136813420000000000000000000, + .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 115 460 PQP3(R3(.20755902173331721318141636044536441, .20755902173331721318141636044536441, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000)), + 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000)), .01064026039260234415487304925754523), // 116 464 - PQP3(R3(.20755902173331721318141636044536441, - 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), + PQP3(R3(.20755902173331721318141636044536441, 1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 117 468 - PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - - (.49641284136813420000000000000000000), - .20755902173331721318141636044536441, .20755902173331721318141636044536441), + PQP3(R3(1. - (.20755902173331721318141636044536441) - (.20755902173331721318141636044536441) - (.49641284136813420000000000000000000), .20755902173331721318141636044536441, + .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 118 472 - PQP3(R3(.20755902173331721318141636044536441, .20755902173331721318141636044536441, - .49641284136813420000000000000000000), + PQP3(R3(.20755902173331721318141636044536441, .20755902173331721318141636044536441, .49641284136813420000000000000000000), .01064026039260234415487304925754523), // 119 476 - PQP3(R3(.20755902173331721318141636044536441, .49641284136813420000000000000000000, - .20755902173331721318141636044536441), + PQP3(R3(.20755902173331721318141636044536441, .49641284136813420000000000000000000, .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 120 480 - PQP3(R3(.49641284136813420000000000000000000, .20755902173331721318141636044536441, - .20755902173331721318141636044536441), + PQP3(R3(.49641284136813420000000000000000000, .20755902173331721318141636044536441, .20755902173331721318141636044536441), .01064026039260234415487304925754523), // 121 484 PQP3(R3(.00317672566580133046838579859910808, .88571644680187933415518991697343211, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211)), + 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211)), .00031627239419231128593612508289817), // 122 488 - PQP3(R3(.00317672566580133046838579859910808, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), + PQP3(R3(.00317672566580133046838579859910808, 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .88571644680187933415518991697343211), .00031627239419231128593612508289817), // 123 492 PQP3(R3(.88571644680187933415518991697343211, .00317672566580133046838579859910808, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211)), + 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211)), .00031627239419231128593612508289817), // 124 496 - PQP3(R3(.88571644680187933415518991697343211, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), + PQP3(R3(.88571644680187933415518991697343211, 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 125 500 - PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), - .00317672566580133046838579859910808, .88571644680187933415518991697343211), + PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .00317672566580133046838579859910808, + .88571644680187933415518991697343211), .00031627239419231128593612508289817), // 126 504 - PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), - .88571644680187933415518991697343211, .00317672566580133046838579859910808), + PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .88571644680187933415518991697343211, + .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 127 508 PQP3(R3(.00317672566580133046838579859910808, .00317672566580133046838579859910808, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211)), + 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211)), .00031627239419231128593612508289817), // 128 512 - PQP3(R3(.00317672566580133046838579859910808, - 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), + PQP3(R3(.00317672566580133046838579859910808, 1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 129 516 - PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - - (.88571644680187933415518991697343211), - .00317672566580133046838579859910808, .00317672566580133046838579859910808), + PQP3(R3(1. - (.00317672566580133046838579859910808) - (.00317672566580133046838579859910808) - (.88571644680187933415518991697343211), .00317672566580133046838579859910808, + .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 130 520 - PQP3(R3(.00317672566580133046838579859910808, .00317672566580133046838579859910808, - .88571644680187933415518991697343211), + PQP3(R3(.00317672566580133046838579859910808, .00317672566580133046838579859910808, .88571644680187933415518991697343211), .00031627239419231128593612508289817), // 131 524 - PQP3(R3(.00317672566580133046838579859910808, .88571644680187933415518991697343211, - .00317672566580133046838579859910808), + PQP3(R3(.00317672566580133046838579859910808, .88571644680187933415518991697343211, .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 132 528 - PQP3(R3(.88571644680187933415518991697343211, .00317672566580133046838579859910808, - .00317672566580133046838579859910808), + PQP3(R3(.88571644680187933415518991697343211, .00317672566580133046838579859910808, .00317672566580133046838579859910808), .00031627239419231128593612508289817), // 133 532 PQP3(R3(.16634658949265576428233847556684871, .64221464654291632524678940601354742, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742)), + 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742)), .00676212093730203740266276007684025), // 134 536 - PQP3(R3(.16634658949265576428233847556684871, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), + PQP3(R3(.16634658949265576428233847556684871, 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .64221464654291632524678940601354742), .00676212093730203740266276007684025), // 135 540 PQP3(R3(.64221464654291632524678940601354742, .16634658949265576428233847556684871, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742)), + 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742)), .00676212093730203740266276007684025), // 136 544 - PQP3(R3(.64221464654291632524678940601354742, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), + PQP3(R3(.64221464654291632524678940601354742, 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 137 548 - PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), - .16634658949265576428233847556684871, .64221464654291632524678940601354742), + PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .16634658949265576428233847556684871, + .64221464654291632524678940601354742), .00676212093730203740266276007684025), // 138 552 - PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), - .64221464654291632524678940601354742, .16634658949265576428233847556684871), + PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .64221464654291632524678940601354742, + .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 139 556 PQP3(R3(.16634658949265576428233847556684871, .16634658949265576428233847556684871, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742)), + 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742)), .00676212093730203740266276007684025), // 140 560 - PQP3(R3(.16634658949265576428233847556684871, - 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), + PQP3(R3(.16634658949265576428233847556684871, 1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 141 564 - PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - - (.64221464654291632524678940601354742), - .16634658949265576428233847556684871, .16634658949265576428233847556684871), + PQP3(R3(1. - (.16634658949265576428233847556684871) - (.16634658949265576428233847556684871) - (.64221464654291632524678940601354742), .16634658949265576428233847556684871, + .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 142 568 - PQP3(R3(.16634658949265576428233847556684871, .16634658949265576428233847556684871, - .64221464654291632524678940601354742), + PQP3(R3(.16634658949265576428233847556684871, .16634658949265576428233847556684871, .64221464654291632524678940601354742), .00676212093730203740266276007684025), // 143 572 - PQP3(R3(.16634658949265576428233847556684871, .64221464654291632524678940601354742, - .16634658949265576428233847556684871), + PQP3(R3(.16634658949265576428233847556684871, .64221464654291632524678940601354742, .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 144 576 - PQP3(R3(.64221464654291632524678940601354742, .16634658949265576428233847556684871, - .16634658949265576428233847556684871), + PQP3(R3(.64221464654291632524678940601354742, .16634658949265576428233847556684871, .16634658949265576428233847556684871), .00676212093730203740266276007684025), // 145 580 PQP3(R3(.30344194369885264264500117734906354, .00772105989990930297678960227638472, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 146 584 - PQP3(R3(.30344194369885264264500117734906354, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.30344194369885264264500117734906354, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 147 588 PQP3(R3(.00772105989990930297678960227638472, .30344194369885264264500117734906354, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 148 592 - PQP3(R3(.00772105989990930297678960227638472, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.00772105989990930297678960227638472, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 149 596 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .30344194369885264264500117734906354, .00772105989990930297678960227638472), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .30344194369885264264500117734906354, + .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 150 600 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .00772105989990930297678960227638472, .30344194369885264264500117734906354), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .00772105989990930297678960227638472, + .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 151 604 PQP3(R3(.59698804897542365623933181080626979, .00772105989990930297678960227638472, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 152 608 - PQP3(R3(.59698804897542365623933181080626979, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.59698804897542365623933181080626979, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 153 612 PQP3(R3(.00772105989990930297678960227638472, .59698804897542365623933181080626979, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 154 616 - PQP3(R3(.00772105989990930297678960227638472, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.00772105989990930297678960227638472, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 155 620 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .59698804897542365623933181080626979, .00772105989990930297678960227638472), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .59698804897542365623933181080626979, + .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 156 624 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .00772105989990930297678960227638472, .59698804897542365623933181080626979), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .00772105989990930297678960227638472, + .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 157 628 PQP3(R3(.59698804897542365623933181080626979, .30344194369885264264500117734906354, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 158 632 - PQP3(R3(.59698804897542365623933181080626979, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.59698804897542365623933181080626979, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 159 636 PQP3(R3(.30344194369885264264500117734906354, .59698804897542365623933181080626979, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472)), + 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472)), .00293371746826111669254642316791922), // 160 640 - PQP3(R3(.30344194369885264264500117734906354, - 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), + PQP3(R3(.30344194369885264264500117734906354, 1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 161 644 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .59698804897542365623933181080626979, .30344194369885264264500117734906354), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .59698804897542365623933181080626979, + .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 162 648 - PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - - (.00772105989990930297678960227638472), - .30344194369885264264500117734906354, .59698804897542365623933181080626979), + PQP3(R3(1. - (.59698804897542365623933181080626979) - (.30344194369885264264500117734906354) - (.00772105989990930297678960227638472), .30344194369885264264500117734906354, + .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 163 652 - PQP3(R3(.59698804897542365623933181080626979, .30344194369885264264500117734906354, - .00772105989990930297678960227638472), + PQP3(R3(.59698804897542365623933181080626979, .30344194369885264264500117734906354, .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 164 656 - PQP3(R3(.59698804897542365623933181080626979, .00772105989990930297678960227638472, - .30344194369885264264500117734906354), + PQP3(R3(.59698804897542365623933181080626979, .00772105989990930297678960227638472, .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 165 660 - PQP3(R3(.30344194369885264264500117734906354, .59698804897542365623933181080626979, - .00772105989990930297678960227638472), + PQP3(R3(.30344194369885264264500117734906354, .59698804897542365623933181080626979, .00772105989990930297678960227638472), .00293371746826111669254642316791922), // 166 664 - PQP3(R3(.30344194369885264264500117734906354, .00772105989990930297678960227638472, - .59698804897542365623933181080626979), + PQP3(R3(.30344194369885264264500117734906354, .00772105989990930297678960227638472, .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 167 668 - PQP3(R3(.00772105989990930297678960227638472, .59698804897542365623933181080626979, - .30344194369885264264500117734906354), + PQP3(R3(.00772105989990930297678960227638472, .59698804897542365623933181080626979, .30344194369885264264500117734906354), .00293371746826111669254642316791922), // 168 672 - PQP3(R3(.00772105989990930297678960227638472, .30344194369885264264500117734906354, - .59698804897542365623933181080626979), + PQP3(R3(.00772105989990930297678960227638472, .30344194369885264264500117734906354, .59698804897542365623933181080626979), .00293371746826111669254642316791922), // 169 676 PQP3(R3(.06021328978843793059084645285790579, .12582571438467239382589793638340901, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 170 680 - PQP3(R3(.06021328978843793059084645285790579, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.06021328978843793059084645285790579, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 171 684 PQP3(R3(.12582571438467239382589793638340901, .06021328978843793059084645285790579, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 172 688 - PQP3(R3(.12582571438467239382589793638340901, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.12582571438467239382589793638340901, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 173 692 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .06021328978843793059084645285790579, .12582571438467239382589793638340901), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .06021328978843793059084645285790579, + .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 174 696 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .12582571438467239382589793638340901, .06021328978843793059084645285790579), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .12582571438467239382589793638340901, + .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 175 700 PQP3(R3(.81379652801439184798325669233364806, .12582571438467239382589793638340901, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 176 704 - PQP3(R3(.81379652801439184798325669233364806, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.81379652801439184798325669233364806, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 177 708 PQP3(R3(.12582571438467239382589793638340901, .81379652801439184798325669233364806, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 178 712 - PQP3(R3(.12582571438467239382589793638340901, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.12582571438467239382589793638340901, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 179 716 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .81379652801439184798325669233364806, .12582571438467239382589793638340901), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .81379652801439184798325669233364806, + .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 180 720 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .12582571438467239382589793638340901, .81379652801439184798325669233364806), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .12582571438467239382589793638340901, + .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 181 724 PQP3(R3(.81379652801439184798325669233364806, .06021328978843793059084645285790579, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 182 728 - PQP3(R3(.81379652801439184798325669233364806, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.81379652801439184798325669233364806, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 183 732 PQP3(R3(.06021328978843793059084645285790579, .81379652801439184798325669233364806, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901)), + 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901)), .00091803679200083798695474146748587), // 184 736 - PQP3(R3(.06021328978843793059084645285790579, - 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), + PQP3(R3(.06021328978843793059084645285790579, 1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 185 740 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .81379652801439184798325669233364806, .06021328978843793059084645285790579), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .81379652801439184798325669233364806, + .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 186 744 - PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - - (.12582571438467239382589793638340901), - .06021328978843793059084645285790579, .81379652801439184798325669233364806), + PQP3(R3(1. - (.81379652801439184798325669233364806) - (.06021328978843793059084645285790579) - (.12582571438467239382589793638340901), .06021328978843793059084645285790579, + .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 187 748 - PQP3(R3(.81379652801439184798325669233364806, .06021328978843793059084645285790579, - .12582571438467239382589793638340901), + PQP3(R3(.81379652801439184798325669233364806, .06021328978843793059084645285790579, .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 188 752 - PQP3(R3(.81379652801439184798325669233364806, .12582571438467239382589793638340901, - .06021328978843793059084645285790579), + PQP3(R3(.81379652801439184798325669233364806, .12582571438467239382589793638340901, .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 189 756 - PQP3(R3(.06021328978843793059084645285790579, .81379652801439184798325669233364806, - .12582571438467239382589793638340901), + PQP3(R3(.06021328978843793059084645285790579, .81379652801439184798325669233364806, .12582571438467239382589793638340901), .00091803679200083798695474146748587), // 190 760 - PQP3(R3(.06021328978843793059084645285790579, .12582571438467239382589793638340901, - .81379652801439184798325669233364806), + PQP3(R3(.06021328978843793059084645285790579, .12582571438467239382589793638340901, .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 191 764 - PQP3(R3(.12582571438467239382589793638340901, .81379652801439184798325669233364806, - .06021328978843793059084645285790579), + PQP3(R3(.12582571438467239382589793638340901, .81379652801439184798325669233364806, .06021328978843793059084645285790579), .00091803679200083798695474146748587), // 192 768 - PQP3(R3(.12582571438467239382589793638340901, .06021328978843793059084645285790579, - .81379652801439184798325669233364806), + PQP3(R3(.12582571438467239382589793638340901, .06021328978843793059084645285790579, .81379652801439184798325669233364806), .00091803679200083798695474146748587), // 193 772 }; PQF3 const QuadratureFormular_Tet_P14(14, 194, QF_TET_P14); -const GQuadratureFormular< R2 > *tripleQF(Stack stack, - const GQuadratureFormular< R2 > *const &pqf) { +const GQuadratureFormular< R2 > *tripleQF(Stack stack, const GQuadratureFormular< R2 > *const &pqf) { const GQuadratureFormular< R2 > &qf = *pqf; int np = qf.n * 3; @@ -4060,8 +2754,7 @@ const GQuadratureFormular< R2 > *tripleQF(Stack stack, } template< class Rd > -const GQuadratureFormular< Rd > **cloneQF(const GQuadratureFormular< Rd > **const &pr, - GQuadratureFormular< Rd > const *const &qf) { +const GQuadratureFormular< Rd > **cloneQF(const GQuadratureFormular< Rd > **const &pr, GQuadratureFormular< Rd > const *const &qf) { ffassert(pr); int np = qf->n; GQuadraturePoint< Rd > *pq = new GQuadraturePoint< Rd >[np]; @@ -4090,63 +2783,37 @@ static void Load_Init( ) { Global.New("qf21pT", CConstant< const QuadratureFormular * >(&QuadratureFormular_T_21)); Global.New("qf23pT", CConstant< const QuadratureFormular * >(&QuadratureFormular_T_23)); Global.New("qf25pT", CConstant< const QuadratureFormular * >(&QuadratureFormular_T_25)); - Global.New("qf11pE", CConstant< const QuadratureFormular1d * >( - new QuadratureFormular1d(-1 + 2 * 11, 11, GaussLegendre(11), true))); - Global.New("qf12pE", CConstant< const QuadratureFormular1d * >( - new QuadratureFormular1d(-1 + 2 * 12, 12, GaussLegendre(12), true))); - Global.New("qf13pE", CConstant< const QuadratureFormular1d * >( - new QuadratureFormular1d(-1 + 2 * 13, 13, GaussLegendre(13), true))); + Global.New("qf11pE", CConstant< const QuadratureFormular1d * >(new QuadratureFormular1d(-1 + 2 * 11, 11, GaussLegendre(11), true))); + Global.New("qf12pE", CConstant< const QuadratureFormular1d * >(new QuadratureFormular1d(-1 + 2 * 12, 12, GaussLegendre(12), true))); + Global.New("qf13pE", CConstant< const QuadratureFormular1d * >(new QuadratureFormular1d(-1 + 2 * 13, 13, GaussLegendre(13), true))); - Global.Add( - "QF1d", "(", - new OneOperator2_< const GQuadratureFormular< R1 > *, long, KNM_< double > >(BuilQFd< R1 >)); - Global.Add( - "QF2d", "(", - new OneOperator2_< const GQuadratureFormular< R2 > *, long, KNM_< double > >(BuilQFd< R2 >)); - Global.Add( - "QF3d", "(", - new OneOperator2_< const GQuadratureFormular< R3 > *, long, KNM_< double > >(BuilQFd< R3 >)); + Global.Add("QF1d", "(", new OneOperator2_< const GQuadratureFormular< R1 > *, long, KNM_< double > >(BuilQFd< R1 >)); + Global.Add("QF2d", "(", new OneOperator2_< const GQuadratureFormular< R2 > *, long, KNM_< double > >(BuilQFd< R2 >)); + Global.Add("QF3d", "(", new OneOperator2_< const GQuadratureFormular< R3 > *, long, KNM_< double > >(BuilQFd< R3 >)); - Dcl_Type< const GQuadratureFormular< R1 > ** >( - ::InitializePtr< const GQuadratureFormular< R1 > * >, - ::DeletePtr< const GQuadratureFormular< R1 > * >); - Dcl_Type< const GQuadratureFormular< R2 > ** >( - ::InitializePtr< const GQuadratureFormular< R2 > * >, - ::DeletePtr< const GQuadratureFormular< R2 > * >); - Dcl_Type< const GQuadratureFormular< R3 > ** >( - ::InitializePtr< const GQuadratureFormular< R3 > * >, - ::DeletePtr< const GQuadratureFormular< R3 > * >); + Dcl_Type< const GQuadratureFormular< R1 > ** >(::InitializePtr< const GQuadratureFormular< R1 > * >, ::DeletePtr< const GQuadratureFormular< R1 > * >); + Dcl_Type< const GQuadratureFormular< R2 > ** >(::InitializePtr< const GQuadratureFormular< R2 > * >, ::DeletePtr< const GQuadratureFormular< R2 > * >); + Dcl_Type< const GQuadratureFormular< R3 > ** >(::InitializePtr< const GQuadratureFormular< R3 > * >, ::DeletePtr< const GQuadratureFormular< R3 > * >); zzzfff->Add("QF1", atype< const GQuadratureFormular< R1 > ** >( )); zzzfff->Add("QF2", atype< const GQuadratureFormular< R2 > ** >( )); zzzfff->Add("QF3", atype< const GQuadratureFormular< R3 > ** >( )); - TheOperators->Add( - "<-", - new OneOperator3_< const GQuadratureFormular< R1 > **, const GQuadratureFormular< R1 > **, long, - KNM_< double > >(pBuilQFd< R1 >), - new OneOperator3_< const GQuadratureFormular< R2 > **, const GQuadratureFormular< R2 > **, long, - KNM_< double > >(pBuilQFd< R2 >), - new OneOperator3_< const GQuadratureFormular< R3 > **, const GQuadratureFormular< R3 > **, long, - KNM_< double > >(pBuilQFd< R3 >), - new OneOperator2_< const GQuadratureFormular< R2 > **, const GQuadratureFormular< R2 > **, - const GQuadratureFormular< R2 > * >(cloneQF< R2 >), - new OneOperator2_< const GQuadratureFormular< R3 > **, const GQuadratureFormular< R3 > **, - const GQuadratureFormular< R3 > * >(cloneQF< R3 >), - new OneOperator2_< const GQuadratureFormular< R1 > **, const GQuadratureFormular< R1 > **, - const GQuadratureFormular< R1 > * >(cloneQF< R1 >) + TheOperators->Add("<-", new OneOperator3_< const GQuadratureFormular< R1 > **, const GQuadratureFormular< R1 > **, long, KNM_< double > >(pBuilQFd< R1 >), + new OneOperator3_< const GQuadratureFormular< R2 > **, const GQuadratureFormular< R2 > **, long, KNM_< double > >(pBuilQFd< R2 >), + new OneOperator3_< const GQuadratureFormular< R3 > **, const GQuadratureFormular< R3 > **, long, KNM_< double > >(pBuilQFd< R3 >), + new OneOperator2_< const GQuadratureFormular< R2 > **, const GQuadratureFormular< R2 > **, const GQuadratureFormular< R2 > * >(cloneQF< R2 >), + new OneOperator2_< const GQuadratureFormular< R3 > **, const GQuadratureFormular< R3 > **, const GQuadratureFormular< R3 > * >(cloneQF< R3 >), + new OneOperator2_< const GQuadratureFormular< R1 > **, const GQuadratureFormular< R1 > **, const GQuadratureFormular< R1 > * >(cloneQF< R1 >) ); // cast ** -> * map_type[typeid(const GQuadratureFormular< R1 > *).name( )]->AddCast( - new E_F1_funcT< const GQuadratureFormular< R1 > *, const GQuadratureFormular< R1 > ** >( - UnRef< const GQuadratureFormular< R1 > * >)); + new E_F1_funcT< const GQuadratureFormular< R1 > *, const GQuadratureFormular< R1 > ** >(UnRef< const GQuadratureFormular< R1 > * >)); map_type[typeid(const GQuadratureFormular< R2 > *).name( )]->AddCast( - new E_F1_funcT< const GQuadratureFormular< R2 > *, const GQuadratureFormular< R2 > ** >( - UnRef< const GQuadratureFormular< R2 > * >)); + new E_F1_funcT< const GQuadratureFormular< R2 > *, const GQuadratureFormular< R2 > ** >(UnRef< const GQuadratureFormular< R2 > * >)); map_type[typeid(const GQuadratureFormular< R3 > *).name( )]->AddCast( - new E_F1_funcT< const GQuadratureFormular< R3 > *, const GQuadratureFormular< R3 > ** >( - UnRef< const GQuadratureFormular< R3 > * >)); + new E_F1_funcT< const GQuadratureFormular< R3 > *, const GQuadratureFormular< R3 > ** >(UnRef< const GQuadratureFormular< R3 > * >)); // new quadrature formular for tet from ... /* * % Reference: @@ -4176,10 +2843,7 @@ static void Load_Init( ) { Global.New("qfVp13", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_P13)); Global.New("qfVp14", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_P14)); // - Global.Add( - "tripleQF", "(", - new OneOperator1s_< const GQuadratureFormular< R2 > *, const GQuadratureFormular< R2 > * >( - tripleQF)); + Global.Add("tripleQF", "(", new OneOperator1s_< const GQuadratureFormular< R2 > *, const GQuadratureFormular< R2 > * >(tripleQF)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/scotch.cpp b/plugin/seq/scotch.cpp index ad837ad05..22da6df65 100644 --- a/plugin/seq/scotch.cpp +++ b/plugin/seq/scotch.cpp @@ -48,10 +48,7 @@ class SCOTCH_Op : public E_F0mps { static const int n_name_param = 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - SCOTCH_Op(const basicAC_F0 &args, Expression param1, Expression param2, Expression param3) - : partition(param1), Th(param2), lpartition(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } + SCOTCH_Op(const basicAC_F0 &args, Expression param1, Expression param2, Expression param3) : partition(param1), Th(param2), lpartition(param3) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; @@ -64,10 +61,7 @@ class SCOTCH : public OneOperator { public: SCOTCH( ) : OneOperator(atype< K >( ), atype< KN< K > * >( ), atype< V >( ), atype< long >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new SCOTCH_Op< T, V, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); - } + E_F0 *code(const basicAC_F0 &args) const { return new SCOTCH_Op< T, V, K >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; template< class T, class V, class K > @@ -82,7 +76,7 @@ AnyType SCOTCH_Op< T, V, K >::operator( )(Stack stack) const { int nve = T::RdHat::d + 1; long lpart = GetAny< long >((*lpartition)(stack)); ffassert(lpart > 0 && part->n == nt && lpart < nt); - if(lpart == 1) { + if (lpart == 1) { *part = 0.0; return 0L; } @@ -131,8 +125,7 @@ AnyType SCOTCH_Op< T, V, K >::operator( )(Stack stack) const { SCOTCH_Num *vendtab = NULL; SCOTCH_Num *vlbltab = NULL; SCOTCH_Num *edlotab = NULL; - SCOTCH_graphBuild(&GraphSCOTCH, baseval, vertnbr, verttab, vendtab, velotab, vlbltab, edgenbr, - edgetab, edlotab); + SCOTCH_graphBuild(&GraphSCOTCH, baseval, vertnbr, verttab, vendtab, velotab, vlbltab, edgenbr, edgetab, edlotab); #ifdef DEBUG SCOTCH_graphCheck(&GraphSCOTCH); #endif diff --git a/plugin/seq/shell.cpp b/plugin/seq/shell.cpp index 7f91885f1..67d682a8b 100644 --- a/plugin/seq/shell.cpp +++ b/plugin/seq/shell.cpp @@ -195,9 +195,9 @@ long ffunsetenv(string *const &k) { #endif string *ff_getcwd(Stack s) { - char * buf = getcwd(0,0); - string * cwd= new string(buf); - free(buf); + char *buf = getcwd(0, 0); + string *cwd = new string(buf); + free(buf); return Add2StackOfPtr2Free(s, cwd); } @@ -238,13 +238,9 @@ string basename(const string *ppath) { return path.substr(i); } -string *ff_dirname(Stack s, string *const &path) { - return Add2StackOfPtr2Free(s, new string(dirname(path))); -} +string *ff_dirname(Stack s, string *const &path) { return Add2StackOfPtr2Free(s, new string(dirname(path))); } -string *ff_basename(Stack s, string *const &path) { - return Add2StackOfPtr2Free(s, new string(basename(path))); -} +string *ff_basename(Stack s, string *const &path) { return Add2StackOfPtr2Free(s, new string(basename(path))); } long copyfile(string *const &filecp, string *const &target) { int tagetisdir = ff_isdir(target); @@ -337,7 +333,7 @@ static void init( ) { Global.Add("getenv", "(", new OneOperator1s_< string *, string * >(ffgetenv)); Global.Add("setenv", "(", new OneOperator2_< long, string *, string * >(ffsetenv)); Global.Add("unsetenv", "(", new OneOperator1_< long, string * >(ffunsetenv)); - Global.Add("getcwd", "(", new OneOperator0s< string * >(ff_getcwd)); + Global.Add("getcwd", "(", new OneOperator0s< string * >(ff_getcwd)); } LOADFUNC(init); diff --git a/plugin/seq/splitedges.cpp b/plugin/seq/splitedges.cpp index 069e27c50..9f2223a2e 100644 --- a/plugin/seq/splitedges.cpp +++ b/plugin/seq/splitedges.cpp @@ -160,8 +160,7 @@ const Mesh *Split_Edges(Stack stack, Fem2D::Mesh const *const &pTh, long *dK) { in[e2] = iee; if (v10) { - cout << k << " \t " << in[0] << " " << in[1] << " " << in[2] << " nn " << tn - t << " " - << Le[e] << endl; + cout << k << " \t " << in[0] << " " << in[1] << " " << in[2] << " nn " << tn - t << " " << Le[e] << endl; } (*td).set(v, id[0], id[1], id[2], Th[k].lab); @@ -265,8 +264,7 @@ AnyType SplitEdges::operator( )(Stack stack) const { } if (v10) { - cout << k << " " << e << " f " << P << " = " << de << " " << be << " " << dK[k] << " " - << (1 << e) << endl; + cout << k << " " << e << " f " << P << " = " << de << " " << be << " " << dK[k] << " " << (1 << e) << endl; } int ee(e), kk; @@ -274,8 +272,7 @@ AnyType SplitEdges::operator( )(Stack stack) const { if ((kk < k) && (kk >= 0)) { bool bee = dK[kk] & (1 << ee); if (bee != be) { - cout << " Bizarre edge right != compatible left " << k << " " << e << " P = " << P - << " kk " << kk << " " << ee << " " << dK[kk] << endl; + cout << " Bizarre edge right != compatible left " << k << " " << e << " P = " << P << " kk " << kk << " " << ee << " " << dK[kk] << endl; dK[k] = dK[k] | (1 << e); dK[kk] = dK[kk] | (1 << ee); } diff --git a/plugin/seq/splitmesh12.cpp b/plugin/seq/splitmesh12.cpp index 40d2ebcea..c1eb5b9c2 100644 --- a/plugin/seq/splitmesh12.cpp +++ b/plugin/seq/splitmesh12.cpp @@ -41,32 +41,29 @@ using namespace std; #include using namespace Fem2D; -R3 Intersection(const R3 &A,const R3 &B,const R3 &C,const R3 &AA,const R3 &BB) -{ - double aa = -det(A,B,C,AA); - double bb = det(A,B,C,BB); - double s = aa + bb; - assert( aa/s > 0 && bb/s >=0 ); - R3 P = BB * aa / s + AA* aa / s; - return P; +R3 Intersection(const R3 &A, const R3 &B, const R3 &C, const R3 &AA, const R3 &BB) { + double aa = -det(A, B, C, AA); + double bb = det(A, B, C, BB); + double s = aa + bb; + assert(aa / s > 0 && bb / s >= 0); + R3 P = BB * aa / s + AA * aa / s; + return P; +} +R3 inSphereCenter(const R3 &A, const R3 &B, const R3 &C, const R3 &D) { + // see https://people.sc.fsu.edu/~jburkardt/presentations/cg_lab_tetrahedrons.pdf + R3 AB(A, B), AC(A, C), AD(A, D), BC(B, C), BD(B, D); + R3 Nabc = (AB ^ AC); + R3 Nabd = (AB ^ AD); + R3 Nacd = (AC ^ AD); + R3 Nbcd = (BC ^ BD); + R nabc = Nabc.norme( ); + R nabd = Nabd.norme( ); + R nacd = Nacd.norme( ); + R nbcd = Nbcd.norme( ); + R3 G = (nabc * D + nabd * C + nacd * B + nbcd * A) / (nabc + nabd + nacd + nbcd); + return G; } -R3 inSphereCenter(const R3& A,const R3& B,const R3& C,const R3& D) -{ - // see https://people.sc.fsu.edu/~jburkardt/presentations/cg_lab_tetrahedrons.pdf - R3 AB(A,B),AC(A,C),AD(A,D),BC(B,C),BD(B,D); - R3 Nabc = (AB^AC); - R3 Nabd = (AB^AD); - R3 Nacd = (AC^AD); - R3 Nbcd = (BC^BD); - R nabc = Nabc.norme(); - R nabd = Nabd.norme(); - R nacd = Nacd.norme(); - R nbcd = Nbcd.norme(); - - R3 G = (nabc*D + nabd*C + nacd*B + nbcd*A) / (nabc + nabd + nacd + nbcd) ; - return G; - } static void findPerm(int *ivt, int *pivt, Vertex3 *v) { std::copy(ivt, ivt + 4, pivt); R3 AB(v[ivt[0]], v[ivt[1]]); @@ -83,7 +80,7 @@ static void findPerm(int *ivt, int *pivt, Vertex3 *v) { } } -Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh,int cas) { +Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh, int cas) { assert(pTh); const Mesh3 &Th(*pTh); // le maillage d'origne a decoupe using Fem2D::BoundaryEdge; @@ -126,11 +123,11 @@ Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh,int cas) // generation des points barycentre de trianngles for (int k = 0; k < nbt; k++) { const Tet &K = Th[k]; - R3 G; - if(cas ==0) - G = ((R3)K[0] + K[1] + K[2] + K[3]) / 4.; - else - G = inSphereCenter(K[0], K[1], K[2], K[3]); + R3 G; + if (cas == 0) + G = ((R3)K[0] + K[1] + K[2] + K[3]) / 4.; + else + G = inSphereCenter(K[0], K[1], K[2], K[3]); vv->x = G.x; vv->y = G.y; vv->z = G.z; @@ -182,8 +179,7 @@ Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh,int cas) const Tet &K = Th[k]; const Tet &KAdj = Th[kk]; { - R3 uuu = K[nvfaceTet[e][1]] - K[nvfaceTet[e][0]], - vvv = K[nvfaceTet[e][2]] - K[nvfaceTet[e][0]]; + R3 uuu = K[nvfaceTet[e][1]] - K[nvfaceTet[e][0]], vvv = K[nvfaceTet[e][2]] - K[nvfaceTet[e][0]]; R3 n = uuu ^ vvv; Vertex3 dir(v[nbv + k] - v[nbv + kk]); Vertex3 w0(v[nbv + kk] - K[nvfaceTet[e][0]]); @@ -195,8 +191,7 @@ Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh,int cas) vv->z = v[nbv + kk].z + rr * dir.z; vv->lab = 0; } - int i0 = Th.operator( )(K[nvfaceTet[e][0]]), i1 = Th.operator( )(K[nvfaceTet[e][1]]), - i2 = Th.operator( )(K[nvfaceTet[e][2]]); + int i0 = Th.operator( )(K[nvfaceTet[e][0]]), i1 = Th.operator( )(K[nvfaceTet[e][1]]), i2 = Th.operator( )(K[nvfaceTet[e][2]]); for (int ij = 0; ij < 2; ++ij) { int ivt[4] = {ij == 0 ? nbv + k : nbv + kk, i1, i2, static_cast< int >(vv - v)}; @@ -251,10 +246,8 @@ Mesh3 const *SplitMesh12cas(Stack stack, Fem2D::Mesh3 const *const &pTh,int cas) return m; } } -Mesh3 const *SplitMesh12(Stack stack, Fem2D::Mesh3 const *const &pTh) { - return SplitMesh12cas(stack,pTh,0);} -Mesh3 const *SplitMesh12WorseyFarin(Stack stack, Fem2D::Mesh3 const *const &pTh) { - return SplitMesh12cas(stack,pTh,1);} +Mesh3 const *SplitMesh12(Stack stack, Fem2D::Mesh3 const *const &pTh) { return SplitMesh12cas(stack, pTh, 0); } +Mesh3 const *SplitMesh12WorseyFarin(Stack stack, Fem2D::Mesh3 const *const &pTh) { return SplitMesh12cas(stack, pTh, 1); } // truc pour que la fonction // static void Load_Init() soit appele a moment du chargement dynamique @@ -267,7 +260,7 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme } Global.Add("splitmesh12", "(", new OneOperator1s_< Mesh3 const *, Mesh3 const * >(SplitMesh12)); - Global.Add("splitmesh12WorseyFarin", "(", new OneOperator1s_< Mesh3 const *, Mesh3 const * >(SplitMesh12WorseyFarin)); + Global.Add("splitmesh12WorseyFarin", "(", new OneOperator1s_< Mesh3 const *, Mesh3 const * >(SplitMesh12WorseyFarin)); } LOADFUNC(Load_Init) diff --git a/plugin/seq/splitmesh6.cpp b/plugin/seq/splitmesh6.cpp index ceb160017..48950adb3 100644 --- a/plugin/seq/splitmesh6.cpp +++ b/plugin/seq/splitmesh6.cpp @@ -30,7 +30,7 @@ – Points on edges are obtained by intersecting the edge with the line joining the centers of the two and on boundary just barycenter . - + */ #include #include @@ -45,42 +45,38 @@ using namespace std; using namespace Fem2D; // seg intersection in 2d -R2 Intersection(R2 B,R2 BB,R2 A,R2 AA) -{ - double b = -det(A, AA, B); - double bb = det(A, AA, BB); - double s = b + bb; - assert( b/s > 0 && bb/s >=0 ); - R2 P = BB * b / s + B* bb / s; - return P; - +R2 Intersection(R2 B, R2 BB, R2 A, R2 AA) { + double b = -det(A, AA, B); + double bb = det(A, AA, BB); + double s = b + bb; + assert(b / s > 0 && bb / s >= 0); + R2 P = BB * b / s + B * bb / s; + return P; } // c -R2 incircleCenter(R2 A, R2 B, R2 C) -{ - R2 AB(A,B),CA(C,A),BC(B,C); - double lc=AB.norme(),lb=CA.norme(),la=BC.norme(); - R2 ABu =AB/lc, CAu=CA/lb, BCu = BC/la; - R2 AA = A + (ABu-CAu); - R2 BB = B + (BCu-ABu); - R2 CC = C + (CAu-BCu); - // inter (A,AA) et ((B,BB) - // intersection ddroite [a,aa] and [b,bb] - R2 G= Intersection(A,AA,B,BB); - assert(det(A,B,G)>0); - assert(det(A,G,C)>0); - assert(det(G,B,C)>0); - return G; - } - -Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) { +R2 incircleCenter(R2 A, R2 B, R2 C) { + R2 AB(A, B), CA(C, A), BC(B, C); + double lc = AB.norme( ), lb = CA.norme( ), la = BC.norme( ); + R2 ABu = AB / lc, CAu = CA / lb, BCu = BC / la; + R2 AA = A + (ABu - CAu); + R2 BB = B + (BCu - ABu); + R2 CC = C + (CAu - BCu); + // inter (A,AA) et ((B,BB) + // intersection ddroite [a,aa] and [b,bb] + R2 G = Intersection(A, AA, B, BB); + assert(det(A, B, G) > 0); + assert(det(A, G, C) > 0); + assert(det(G, B, C) > 0); + return G; +} + +Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh, int flags) { // flags == 0 basis - // flags == 1 Powell-Sabin refinend - + // flags == 1 Powell-Sabin refinend + assert(pTh); - bool PowellSabin = flags ==1; - if(verbosity>1) - cout << "SplitMesh6New "< 1) cout << "SplitMesh6New " << flags << endl; const Mesh &Th(*pTh); // le maillage d'origne a decoupe using Fem2D::BoundaryEdge; using Fem2D::Mesh; @@ -122,11 +118,11 @@ Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) // generation des points barycentre de trianngles o c for (int k = 0; k < nbt; k++) { Triangle &K = Th[k]; - R2 G; - if(PowellSabin) - G = incircleCenter(K[0] ,K[1] ,K[2] ); - else - G = ((R2)K[0] + K[1] + K[2]) / 3.; + R2 G; + if (PowellSabin) + G = incircleCenter(K[0], K[1], K[2]); + else + G = ((R2)K[0] + K[1] + K[2]) / 3.; vv->x = G.x; vv->y = G.y; vv->lab = 0; @@ -143,9 +139,9 @@ Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) if ((kk >= k) || (kk < 0)) { int v0 = Th(k, EdgesVertexTriangle[e][0]); int v1 = Th(k, EdgesVertexTriangle[e][1]); - R2 M; - if(PowellSabin && kk >0 && k !=kk) - M = Intersection(Th(v0),Th(v1),v[nbv+k],v[nbv+kk]); + R2 M; + if (PowellSabin && kk > 0 && k != kk) + M = Intersection(Th(v0), Th(v1), v[nbv + k], v[nbv + kk]); else M = ((R2)Th(v0) + Th(v1)) / 2.; int lab = 0; @@ -166,8 +162,7 @@ Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) } } } - if(verbosity>9) - cout << " SplitMesh6New:: nb edge = " << nbe << " == " << nn << endl; + if (verbosity > 9) cout << " SplitMesh6New:: nb edge = " << nbe << " == " << nn << endl; ffassert(nbe == nn); // generation des triangles @@ -204,7 +199,7 @@ Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) // generation de la class Mesh a partir des 3 tableaux : v,t,b { Mesh *m = new Mesh(nbv + nbt + nbe, nbt * 6, neb * 2, v, t, b); - m->renum(); + m->renum( ); R2 Pn, Px; m->BoundingBox(Pn, Px); m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); @@ -213,14 +208,8 @@ Mesh const *SplitMesh6New(Stack stack, Fem2D::Mesh const *const &pTh,int flags) return m; } } -Mesh const *SplitMesh6(Stack stack, Fem2D::Mesh const *const &pTh) -{ - return SplitMesh6New(stack,pTh,0); -} -Mesh const *SplitPowellSabin(Stack stack, Fem2D::Mesh const *const &pTh) -{ - return SplitMesh6New(stack,pTh,1); -} +Mesh const *SplitMesh6(Stack stack, Fem2D::Mesh const *const &pTh) { return SplitMesh6New(stack, pTh, 0); } +Mesh const *SplitPowellSabin(Stack stack, Fem2D::Mesh const *const &pTh) { return SplitMesh6New(stack, pTh, 1); } // truc pour que la fonction // static void Load_Init() soit appele a moment du chargement dynamique @@ -232,10 +221,10 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme cout << " load: splitmesh6 " << endl; } - Global.Add("splitmesh6", "(", new OneOperator1s_< Mesh const *, Mesh const * >(SplitMesh6)); - Global.Add("splitmesh6PowellSabin", "(", new OneOperator1s_< Mesh const *, Mesh const * >(SplitPowellSabin)); - - // utilisation + Global.Add("splitmesh6", "(", new OneOperator1s_< Mesh const *, Mesh const * >(SplitMesh6)); + Global.Add("splitmesh6PowellSabin", "(", new OneOperator1s_< Mesh const *, Mesh const * >(SplitPowellSabin)); + + // utilisation // mesh Th,Th3; // ... construction du maillage Th ici // Th3=splitmesh3(Th); @@ -244,8 +233,8 @@ static void Load_Init( ) { // le constructeur qui ajoute la fonction "splitme * mesh Th=square(5,5); * mesh Th6=splitmesh6(Th); // split with barycentrer * mesh ThPS=splitmesh6PowellSabin(Th); // split with PowellSabin point - - + + * plot(Th3,wait=1); */ } diff --git a/plugin/seq/tetgen.cpp b/plugin/seq/tetgen.cpp index 5964a329b..7d2a27d63 100644 --- a/plugin/seq/tetgen.cpp +++ b/plugin/seq/tetgen.cpp @@ -60,39 +60,23 @@ void mesh3_tetgenio_out(const tetgenio &out, Mesh3 &Th3); void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, Mesh3 &Th3); -void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &label_face, - Mesh3 &Th3); +void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &label_face, Mesh3 &Th3); Mesh3 *mesh3_tetgenio_out(const tetgenio &out); Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet); Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &label_face); -Mesh3 *Convexhull_3Dpoints(char *switch_tetgen, const int &nv_t, const double *Xcoord, - const double *Ycoord, const double *Zcoord, const int &label_tet); +Mesh3 *Convexhull_3Dpoints(char *switch_tetgen, const int &nv_t, const double *Xcoord, const double *Ycoord, const double *Zcoord, const int &label_tet); Mesh3 *RemplissageSurf3D_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &label_tet); -Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const int &label_tet, - const int &nbhole, const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl); -Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const int &label_tet, - const int &nbhole, const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl, const int &nbinside, - const double *InsidePoint, const int &sizeofmetric, - const double *metric) ; -Mesh3 *Transfo_Mesh2_tetgen(const double &precis_mesh, char *switch_tetgen, const Mesh &Th2, - const double *tab_XX, const double *tab_YY, const double *tab_ZZ, - int &border_only, int &recollement_border, int &point_confondus_ok, - const int &label_tet, const map< int, int > &maptri); -Mesh3 *Transfo_Mesh2_tetgen_new(const double &precis_mesh, char *switch_tetgen, const Mesh &Th2, - const double *tab_XX, const double *tab_YY, const double *tab_ZZ, - int &border_only, int &recollement_border, int &point_confondus_ok, - const int &label_tet, const map< int, int > &maptri, - const int &nbhole, const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl); -Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, - const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, +Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const int &label_tet, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, + const int &nbfacecl, const double *tabfacecl); +Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const int &label_tet, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, + const int &nbfacecl, const double *tabfacecl, const int &nbinside, const double *InsidePoint, const int &sizeofmetric, const double *metric); +Mesh3 *Transfo_Mesh2_tetgen(const double &precis_mesh, char *switch_tetgen, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, + int &recollement_border, int &point_confondus_ok, const int &label_tet, const map< int, int > &maptri); +Mesh3 *Transfo_Mesh2_tetgen_new(const double &precis_mesh, char *switch_tetgen, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, + int &recollement_border, int &point_confondus_ok, const int &label_tet, const map< int, int > &maptri, const int &nbhole, const double *tabhole, const int &nbregion, + const double *tabregion, const int &nbfacecl, const double *tabfacecl); +Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, const int &nbfacecl, const double *tabfacecl, const double *tsizevol); class Build2D3D_Op : public E_F0mps { @@ -102,25 +86,15 @@ class Build2D3D_Op : public E_F0mps { static const int n_name_param = 13 + 2; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: Build2D3D_Op(const basicAC_F0 &args, Expression tth) : eTh(tth), xx(0), yy(0), zz(0) { @@ -331,8 +305,7 @@ AnyType Build2D3D_Op::operator( )(Stack stack) const { * Mesh3 *Th3=Transfo_Mesh2_tetgen( precis_mesh, switch_tetgen, Th, txx, tyy, tzz, border_only, * recollement_border, point_confondus_ok, label_tet, mapfme); */ - MeshS *ThS_tmp = MoveMesh2_func(precis_mesh, Th, txx, tyy, tzz, border_only, recollement_border, - point_confondus_ok); + MeshS *ThS_tmp = MoveMesh2_func(precis_mesh, Th, txx, tyy, tzz, border_only, recollement_border, point_confondus_ok); /* delete array */ delete[] txx; @@ -377,8 +350,7 @@ AnyType Build2D3D_Op::operator( )(Stack stack) const { } /* mesh domains with tetgen */ - Mesh3 *Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, *ThS_tmp, label_tet, nbhole, tabhole, - nbregion, tabregion, nbfacecl, tabfacecl); + Mesh3 *Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, *ThS_tmp, label_tet, nbhole, tabhole, nbregion, tabregion, nbfacecl, tabfacecl); /* * Mesh3 *Th3=Transfo_Mesh2_tetgen_new( precis_mesh, switch_tetgen, Th, txx, tyy, tzz, @@ -424,8 +396,7 @@ void mesh3_tetgenio_out(const tetgenio &out, Mesh3 &Th3) { } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } Th3.set(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces); @@ -502,8 +473,7 @@ void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, Mesh3 &Th3) { } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } Th3.set(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces); @@ -540,8 +510,7 @@ void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, Mesh3 &Th3) { } } -void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &label_face, - Mesh3 &Th3) { +void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &label_face, Mesh3 &Th3) { int i; // All indices start from 1. @@ -561,8 +530,7 @@ void mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int &la } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } Th3.set(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces); @@ -625,8 +593,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out) { } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } // new parameter @@ -704,8 +671,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out) { (*bb++).set(v, iv, out.trifacemarkerlist[ibe]); } - Mesh3 *T_TH3 = - new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); + Mesh3 *T_TH3 = new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); if (verbosity > 1) cout << "FreeFEM: Check mesh given by tetgen" << endl; if (TestElementMesh3(*T_TH3) != 1) { @@ -735,8 +701,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet) { } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } // Th3.set(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces); @@ -778,8 +743,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet) { (*bb++).set(v, iv, out.trifacemarkerlist[ibe]); } - Mesh3 *T_TH3 = - new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); + Mesh3 *T_TH3 = new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); if (verbosity > 1) cout << "FreeFEM: Check mesh given by tetgen" << endl; if (TestElementMesh3(*T_TH3) != 1) { return T_TH3; @@ -808,8 +772,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int & } if (verbosity) { - cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " - << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; + cout << "Th3 :: Vertex Element Border :: " << out.numberofpoints << " " << out.numberoftetrahedra << " " << out.numberoftrifaces << endl; } // Th3.set(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces); @@ -855,8 +818,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int & (*bb++).set(v, iv, label_face); } - Mesh3 *T_TH3 = - new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); + Mesh3 *T_TH3 = new Mesh3(out.numberofpoints, out.numberoftetrahedra, out.numberoftrifaces, v, t, b); if (TestElementMesh3(*T_TH3) != 1) { return T_TH3; @@ -865,9 +827,7 @@ Mesh3 *mesh3_tetgenio_out(const tetgenio &out, const int &label_tet, const int & } } -Mesh3 *Convexhull_3Dpoints(char *switch_tetgen, const int &nv_t, const double *Xcoord, - const double *Ycoord, const double *Zcoord, const int &label_tet, - const int &label_face) { +Mesh3 *Convexhull_3Dpoints(char *switch_tetgen, const int &nv_t, const double *Xcoord, const double *Ycoord, const double *Zcoord, const int &label_tet, const int &label_face) { tetgenio in, out; @@ -909,8 +869,7 @@ Mesh3 *Convexhull_3Dpoints(char *switch_tetgen, const int &nv_t, const double *X Mesh3 *T_Th3 = mesh3_tetgenio_out(out, label_tet, label_face); if (verbosity > 1) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; } if (verbosity > 1) { @@ -928,8 +887,7 @@ Mesh3 *RemplissageSurf3D_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int int nbe_t = Th3.nbe; if (verbosity) { - cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " - << nbe_t << endl; + cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t << endl; } // Creation des tableau de tetgen @@ -1007,18 +965,15 @@ Mesh3 *RemplissageSurf3D_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int Mesh3 *T_Th3 = mesh3_tetgenio_out(out, label_tet); if (verbosity > 1) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; cout << "FreeFEM: End check mesh given by tetgen" << endl; } return T_Th3; } -Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const int &label_tet, - const int &nbhole, const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl) { +Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const int &label_tet, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, + const int &nbfacecl, const double *tabfacecl) { // assert(Th3.nt == 0); int nv_t = ThS.nv; @@ -1026,8 +981,7 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const int nbe_t = ThS.nbe; if (verbosity) { - cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " - << nbe_t << endl; + cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t << endl; } // Creation des tableau de tetgen @@ -1082,8 +1036,7 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const p->vertexlist = new int[3]; // creation of elements - const TriangleS &K( - ThS.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 + const TriangleS &K(ThS.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 p->vertexlist[0] = ThS.operator( )(K[0]) + 1; p->vertexlist[1] = ThS.operator( )(K[1]) + 1; p->vertexlist[2] = ThS.operator( )(K[2]) + 1; @@ -1133,28 +1086,22 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &ThS, const // mesh3_tetgenio_out( out, *T_Th3); Mesh3 *T_Th3 = mesh3_tetgenio_out(out); if (verbosity > 0) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; cout << "FreeFEM: End check mesh given by tetgen" << endl; } return T_Th3; } -Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const int &label_tet, - const int &nbhole, const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl, const int &nbinside, - const double *InsidePoint, const int &sizeofmetric, - const double *metric) { +Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const int &label_tet, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, + const int &nbfacecl, const double *tabfacecl, const int &nbinside, const double *InsidePoint, const int &sizeofmetric, const double *metric) { - // assert(Th3.nt == 0); + // assert(Th3.nt == 0); int nv_t = Th3.nv; int nt_t = Th3.nt; int nbe_t = Th3.nbe; if (verbosity) { - cout << "3D RemplissageSurf3D:: Vertex triangleS border " << nv_t << " " << nt_t << " " - << nbe_t << endl; + cout << "3D RemplissageSurf3D:: Vertex triangleS border " << nv_t << " " << nt_t << " " << nbe_t << endl; } // Creation des tableau de tetgen @@ -1196,10 +1143,9 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const for (int nnv = 0; nnv < 3 * nbinside; nnv++) { addin.pointlist[nnv] = InsidePoint[nnv]; } - if(verbosity>9 ) - for(int i=0; i 9) + for (int i = 0; i < nbinside * 3; i += 3) cout << " Tetg: " << i / 3 << " " << addin.pointlist[i] << " " << addin.pointlist[i + 1] << " " << addin.pointlist[i + 2] << endl; + for (int nnv = 0; nnv < nbinside; nnv++) { addin.pointmarkerlist[nnv] = 111; } @@ -1221,44 +1167,18 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const } // Version avec des facettes - // in.numberoffacets = nbe_t; - // in.facetlist = new tetgenio::facet[in.numberoffacets]; - // in.facetmarkerlist = new int[in.numberoffacets]; - // Version avec des facettes - in.numberoffacets = nt_t; - in.facetlist = new tetgenio::facet[in.numberoffacets]; - in.facetmarkerlist = new int[in.numberoffacets]; - - for (int it = 0; it < nt_t; it++) { - tetgenio::facet *f; - tetgenio::polygon *p; - f = &in.facetlist[it]; - f->numberofpolygons = 1; - f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; - f->numberofholes = 0; - f->holelist = NULL; - - p = &f->polygonlist[0]; - p->numberofvertices = 3; - p->vertexlist = new int[3]; - - // creation of elements - const TriangleS &K( - Th3.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 - p->vertexlist[0] = Th3.operator( )(K[0]) + 1; - p->vertexlist[1] = Th3.operator( )(K[1]) + 1; - p->vertexlist[2] = Th3.operator( )(K[2]) + 1; - - for (int kkk = 0; kkk < 3; kkk++) { - assert(p->vertexlist[kkk] <= in.numberofpoints && p->vertexlist[kkk] > 0); - } + // in.numberoffacets = nbe_t; + // in.facetlist = new tetgenio::facet[in.numberoffacets]; + // in.facetmarkerlist = new int[in.numberoffacets]; + // Version avec des facettes + in.numberoffacets = nt_t; + in.facetlist = new tetgenio::facet[in.numberoffacets]; + in.facetmarkerlist = new int[in.numberoffacets]; - in.facetmarkerlist[it] = K.lab; - } -/* for (int ibe = 0; ibe < nbe_t; ibe++) { + for (int it = 0; it < nt_t; it++) { tetgenio::facet *f; tetgenio::polygon *p; - f = &in.facetlist[ibe]; + f = &in.facetlist[it]; f->numberofpolygons = 1; f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; f->numberofholes = 0; @@ -1269,7 +1189,7 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const p->vertexlist = new int[3]; // creation of elements - const TriangleS &K(Th3.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 + const TriangleS &K(Th3.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 p->vertexlist[0] = Th3.operator( )(K[0]) + 1; p->vertexlist[1] = Th3.operator( )(K[1]) + 1; p->vertexlist[2] = Th3.operator( )(K[2]) + 1; @@ -1278,8 +1198,33 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const assert(p->vertexlist[kkk] <= in.numberofpoints && p->vertexlist[kkk] > 0); } - in.facetmarkerlist[ibe] = K.lab; - }*/ + in.facetmarkerlist[it] = K.lab; + } + /* for (int ibe = 0; ibe < nbe_t; ibe++) { + tetgenio::facet *f; + tetgenio::polygon *p; + f = &in.facetlist[ibe]; + f->numberofpolygons = 1; + f->polygonlist = new tetgenio::polygon[f->numberofpolygons]; + f->numberofholes = 0; + f->holelist = NULL; + + p = &f->polygonlist[0]; + p->numberofvertices = 3; + p->vertexlist = new int[3]; + + // creation of elements + const TriangleS &K(Th3.elements[it]); // const Triangle2 & K(Th2.elements[ii]); // Version Mesh2 + p->vertexlist[0] = Th3.operator( )(K[0]) + 1; + p->vertexlist[1] = Th3.operator( )(K[1]) + 1; + p->vertexlist[2] = Th3.operator( )(K[2]) + 1; + + for (int kkk = 0; kkk < 3; kkk++) { + assert(p->vertexlist[kkk] <= in.numberofpoints && p->vertexlist[kkk] > 0); + } + + in.facetmarkerlist[ibe] = K.lab; + }*/ // mise a jour des nouvelles variables @@ -1319,8 +1264,7 @@ Mesh3 *RemplissageSurf3D_tetgen_new(char *switch_tetgen, const MeshS &Th3, const // mesh3_tetgenio_out( out, *T_Th3); Mesh3 *T_Th3 = mesh3_tetgenio_out(out); if (verbosity > 0) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; cout << "FreeFEM: End check mesh given by tetgen" << endl; } @@ -1335,9 +1279,7 @@ Mesh3*Transfo_Mesh2_tetgen_new // Fonction Refine avec tetgen -Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, - const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, +Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, const int &nbfacecl, const double *tabfacecl, const double *tsizevol) { // verif option refine int i; @@ -1368,8 +1310,7 @@ Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int nbe_t = Th3.nbe; if (verbosity) { - cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " - << nbe_t << endl; + cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t << endl; } // Creation des tableau de tetgen @@ -1490,8 +1431,7 @@ Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const Mesh3 *T_Th3 = mesh3_tetgenio_out(out); if (verbosity > 0) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; cout << "FreeFEM: End check mesh given by tetgen" << endl; } @@ -1500,11 +1440,8 @@ Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const // Fonction Refine avec tetgen � l'aide d'une metrique -Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, - const double *tabhole, const int &nbregion, - const double *tabregion, const int &nbfacecl, - const double *tabfacecl, const double *tsizevol, - const int &sizeofmetric, const double *metric) { +Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int &nbhole, const double *tabhole, const int &nbregion, const double *tabregion, const int &nbfacecl, + const double *tabfacecl, const double *tsizevol, const int &sizeofmetric, const double *metric) { // verif option refine int i; @@ -1534,8 +1471,7 @@ Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const int nbe_t = Th3.nbe; if (verbosity) { - cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " - << nbe_t << endl; + cout << "3D RemplissageSurf3D:: Vertex triangle2 border " << nv_t << " " << nt_t << " " << nbe_t << endl; } // Creation des tableau de tetgen @@ -1667,8 +1603,7 @@ Mesh3 *ReconstructionRefine_tetgen(char *switch_tetgen, const Mesh3 &Th3, const Mesh3 *T_Th3 = mesh3_tetgenio_out(out); if (verbosity > 0) { - cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt - << " " << T_Th3->nbe << endl; + cout << " Finish Mesh3 tetgen :: Vertex, Element, Border" << T_Th3->nv << " " << T_Th3->nt << " " << T_Th3->nbe << endl; cout << "FreeFEM: End check mesh given by tetgen" << endl; } @@ -1689,25 +1624,15 @@ class Remplissage_Op : public E_F0mps { static const int n_name_param = 9 + 2 + 1 + 1; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: Remplissage_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -1755,29 +1680,26 @@ class Remplissage_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type Remplissage_Op::name_param[] = { - {"switch", &typeid(string *)}, - {"reftet", &typeid(long)}, // 1 - {"refface", &typeid(KN_< long >)}, // 2 - // new parmameters - {"nbofholes", &typeid(long)}, - {"holelist", &typeid(KN_< double >)}, - {"nbofregions", &typeid(long)}, - {"regionlist", &typeid(KN_< double >)}, - {"nboffacetcl", &typeid(long)}, - {"facetcl", &typeid(KN_< double >)}, - {"region", &typeid(long)}, // 9 - {"label", &typeid(KN_< long >)}, // 10 - {"addpointlist", &typeid(KN_< double >)}, // 11 - {"metric", &typeid(KN_< long >)}}; +basicAC_F0::name_and_type Remplissage_Op::name_param[] = {{"switch", &typeid(string *)}, + {"reftet", &typeid(long)}, // 1 + {"refface", &typeid(KN_< long >)}, // 2 + // new parmameters + {"nbofholes", &typeid(long)}, + {"holelist", &typeid(KN_< double >)}, + {"nbofregions", &typeid(long)}, + {"regionlist", &typeid(KN_< double >)}, + {"nboffacetcl", &typeid(long)}, + {"facetcl", &typeid(KN_< double >)}, + {"region", &typeid(long)}, // 9 + {"label", &typeid(KN_< long >)}, // 10 + {"addpointlist", &typeid(KN_< double >)}, // 11 + {"metric", &typeid(KN_< long >)}}; class Remplissage : public OneOperator { public: Remplissage( ) : OneOperator(atype< pmesh3 >( ), atype< pmeshS >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Remplissage_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Remplissage_Op(args, t[0]->CastTo(args[0])); } }; /*class RemplissageAddPoint: public OneOperator { @@ -1794,15 +1716,13 @@ t[1]->CastTo(args[1])); AnyType Remplissage_Op::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; MeshS *pTh = GetAny< MeshS * >((*eTh)(stack)); - bool bVol = false; + bool bVol = false; ffassert(pTh); MeshS &Th = *pTh; int nbv = Th.nv; // nombre de sommet int nbt = Th.nt; // nombre de triangles int nbe = Th.nbe; // nombre d'aretes fontiere - if (verbosity > 1) - cout << "Tetgen: initial surface mesh - Vertex: " << nbv << " Triangles:" << nbt - << " Edges: " << nbe << endl; + if (verbosity > 1) cout << "Tetgen: initial surface mesh - Vertex: " << nbv << " Triangles:" << nbt << " Edges: " << nbe << endl; KN< long > zzempty; // int intempty=0; @@ -1821,8 +1741,7 @@ AnyType Remplissage_Op::operator( )(Stack stack) const { KN< double > tabfacecl(arg(8, stack, zdzempty)); // parameter inside point // need to add "i" to the switch - KN< double > InsidePoint( - arg(11, stack, zdzempty)); // Add inside point in the volume mesh generated by tetgen + KN< double > InsidePoint(arg(11, stack, zdzempty)); // Add inside point in the volume mesh generated by tetgen // need to add "m" to the switch KN< double > metric(arg(12, stack, zdzempty)); // Add metric for tetgen @@ -1936,19 +1855,17 @@ AnyType Remplissage_Op::operator( )(Stack stack) const { } int nbinside = InsidePoint.N( ) / 3; - Mesh3 *Th3 = 0; + Mesh3 *Th3 = 0; if (nargs[11] || nargs[12] || bVol) { - Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, Th, label_tet, nbhole, tabhole, - nbregion, tabregion, nbfacecl, tabfacecl, nbinside, InsidePoint, sizeofmetric, metric); - // delete multiple vertex - Th3->TrueVertex(); + Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, Th, label_tet, nbhole, tabhole, nbregion, tabregion, nbfacecl, tabfacecl, nbinside, InsidePoint, sizeofmetric, metric); + // delete multiple vertex + Th3->TrueVertex( ); } else { - Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, Th, label_tet, nbhole, tabhole, nbregion, - tabregion, nbfacecl, tabfacecl); + Th3 = RemplissageSurf3D_tetgen_new(switch_tetgen, Th, label_tet, nbhole, tabhole, nbregion, tabregion, nbfacecl, tabfacecl); - if (nargs[11] || nargs[12]) // delete multiple vertex - Th3->TrueVertex( ); + if (nargs[11] || nargs[12]) // delete multiple vertex + Th3->TrueVertex( ); } if (verbosity > 0) { @@ -2006,25 +1923,15 @@ class ReconstructionRefine_Op : public E_F0mps { static const int n_name_param = 10 + 2 + 1; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: ReconstructionRefine_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -2066,9 +1973,7 @@ class ReconstructionRefine : public OneOperator { public: ReconstructionRefine( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new ReconstructionRefine_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new ReconstructionRefine_Op(args, t[0]->CastTo(args[0])); } }; AnyType ReconstructionRefine_Op::operator( )(Stack stack) const { @@ -2194,14 +2099,11 @@ AnyType ReconstructionRefine_Op::operator( )(Stack stack) const { // Add parameter "perhaps' with add a metric which defined sizeofvolume if (RefineMethod == 1) { - Th3 = ReconstructionRefine_tetgen(switch_tetgen, Th, nbhole, tabhole, nbregion, tabregion, - nbfacecl, tabfacecl, tsizevol); + Th3 = ReconstructionRefine_tetgen(switch_tetgen, Th, nbhole, tabhole, nbregion, tabregion, nbfacecl, tabfacecl, tsizevol); } else if (RefineMethod == 0) { - Th3 = ReconstructionRefine_tetgen(switch_tetgen, Th, nbhole, tabhole, nbregion, tabregion, - nbfacecl, tabfacecl, tsizevol, sizeofmetric, metric); + Th3 = ReconstructionRefine_tetgen(switch_tetgen, Th, nbhole, tabhole, nbregion, tabregion, nbfacecl, tabfacecl, tsizevol, sizeofmetric, metric); } else { - cerr << " We can't refine the initial mesh with tetgen. No sizeofvolume or metric is given " - << endl; + cerr << " We can't refine the initial mesh with tetgen. No sizeofvolume or metric is given " << endl; exit(1); } @@ -2276,29 +2178,18 @@ class ConvexHull3D_tetg_file_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - string *arg(int i, Stack stack, string *a) const { - return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; - } + string *arg(int i, Stack stack, string *a) const { return nargs[i] ? GetAny< string * >((*nargs[i])(stack)) : a; } public: - ConvexHull3D_tetg_file_Op(const basicAC_F0 &args, Expression zfilename) - : filename(zfilename), xx(0), yy(0), zz(0) { + ConvexHull3D_tetg_file_Op(const basicAC_F0 &args, Expression zfilename) : filename(zfilename), xx(0), yy(0), zz(0) { if (verbosity) { cout << "Convex Hull with TetGen" << endl; } @@ -2306,8 +2197,7 @@ class ConvexHull3D_tetg_file_Op : public E_F0mps { args.SetNameParam(n_name_param, name_param, nargs); } - ConvexHull3D_tetg_file_Op(const basicAC_F0 &args, Expression xxx, Expression yyy, Expression zzz) - : filename(0), xx(xxx), yy(yyy), zz(zzz) { + ConvexHull3D_tetg_file_Op(const basicAC_F0 &args, Expression xxx, Expression yyy, Expression zzz) : filename(0), xx(xxx), yy(yyy), zz(zzz) { if (verbosity) { cout << "Convex Hull with TetGen" << endl; } @@ -2318,28 +2208,21 @@ class ConvexHull3D_tetg_file_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type ConvexHull3D_tetg_file_Op::name_param[] = {{"switch", &typeid(string *)}, - {"reftet", &typeid(long)}, - {"refface", &typeid(long)}, - {"region", &typeid(long)}, - {"label", &typeid(long)}}; +basicAC_F0::name_and_type ConvexHull3D_tetg_file_Op::name_param[] = { + {"switch", &typeid(string *)}, {"reftet", &typeid(long)}, {"refface", &typeid(long)}, {"region", &typeid(long)}, {"label", &typeid(long)}}; class ConvexHull3D_tetg_file : public OneOperator { public: int cas; ConvexHull3D_tetg_file( ) : OneOperator(atype< pmesh3 >( ), atype< string * >( )), cas(0) {} - ConvexHull3D_tetg_file(int i) - : OneOperator(atype< pmesh3 >( ), atype< KN_< double > >( ), atype< KN_< double > >( ), - atype< KN_< double > >( )), - cas(1) {} + ConvexHull3D_tetg_file(int i) : OneOperator(atype< pmesh3 >( ), atype< KN_< double > >( ), atype< KN_< double > >( ), atype< KN_< double > >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 0) { return new ConvexHull3D_tetg_file_Op(args, t[0]->CastTo(args[0])); } else { - return new ConvexHull3D_tetg_file_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new ConvexHull3D_tetg_file_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } } }; @@ -2382,9 +2265,7 @@ AnyType ConvexHull3D_tetg_file_Op::operator( )(Stack stack) const { ffassert(fp.good( )); fp.close( ); } else { - KN_< double > c_xx = GetAny< KN< double > >((*xx)(stack)), - c_yy = GetAny< KN< double > >((*yy)(stack)), - c_zz = GetAny< KN< double > >((*zz)(stack)); + KN_< double > c_xx = GetAny< KN< double > >((*xx)(stack)), c_yy = GetAny< KN< double > >((*yy)(stack)), c_zz = GetAny< KN< double > >((*zz)(stack)); nbv = c_xx.N( ); ffassert(nbv == c_yy.N( ) && nbv == c_zz.N( )); cxx.resize(nbv); @@ -2396,8 +2277,7 @@ AnyType ConvexHull3D_tetg_file_Op::operator( )(Stack stack) const { } if (verbosity > 1) { - cout << " bound x " << cxx.min( ) << " " << cxx.max( ) << " y " << cyy.min( ) << " " - << cyy.max( ) << " z " << czz.min( ) << " " << czz.max( ) << endl; + cout << " bound x " << cxx.min( ) << " " << cxx.max( ) << " y " << cyy.min( ) << " " << cyy.max( ) << " z " << czz.min( ) << " " << czz.max( ) << endl; } KN< long > zzempty; diff --git a/plugin/seq/vortextools.cpp b/plugin/seq/vortextools.cpp index 67be75bd5..e275454b4 100644 --- a/plugin/seq/vortextools.cpp +++ b/plugin/seq/vortextools.cpp @@ -33,9 +33,7 @@ #include "AFunction_ext.hpp" #include -R3 get(KNM &b,int i){ - return R3(b(i,0),b(i,1),b(i,2)); -} +R3 get(KNM< double > &b, int i) { return R3(b(i, 0), b(i, 1), b(i, 2)); } // Builds a Bspline with 4 control points evaluates it at a given value // Inputs: @@ -46,10 +44,10 @@ R3 get(KNM &b,int i){ // t: value at which the Bspline is evaluated // Returns: // r: the value of the Bspline at parameter t -R3 BSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ - double t2=t*t, t3=t2*t, tm13=pow((1.-t),3); - R3 r = tm13/6. * p0 + (3.*t3-6.*t2+4.)/6. * p1 + (-3.*t3+3.*t2+3.*t+1.)/6. * p2 + t3/6. * p3; - return r; +R3 BSp(R3 &p0, R3 &p1, R3 &p2, R3 &p3, double t) { + double t2 = t * t, t3 = t2 * t, tm13 = pow((1. - t), 3); + R3 r = tm13 / 6. * p0 + (3. * t3 - 6. * t2 + 4.) / 6. * p1 + (-3. * t3 + 3. * t2 + 3. * t + 1.) / 6. * p2 + t3 / 6. * p3; + return r; } // Evaluates the derivative of the Bspline at a given value @@ -61,10 +59,10 @@ R3 BSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ // t: value at which the Bspline is evaluated // Returns: // r: the value of the Bspline derivative at parameter t -R3 dBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ - double t2=t*t, tm12=pow((1.-t),2); - R3 r = - tm12/2. * p0 + (3.*t2-4.*t)/2. * p1 + (-3.*t2+2.*t+1.)/2. * p2 + t2/2. * p3; - return r; +R3 dBSp(R3 &p0, R3 &p1, R3 &p2, R3 &p3, double t) { + double t2 = t * t, tm12 = pow((1. - t), 2); + R3 r = -tm12 / 2. * p0 + (3. * t2 - 4. * t) / 2. * p1 + (-3. * t2 + 2. * t + 1.) / 2. * p2 + t2 / 2. * p3; + return r; } // Evaluates the second derivative of the Bspline at a given value @@ -76,9 +74,9 @@ R3 dBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ // t: value at which the Bspline is evaluated // Returns: // r: the value of the Bspline second derivative at parameter t -R3 ddBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ - R3 r = (1.-t) * p0 + (3.*t-2.) * p1 + (-3.*t+1.) * p2 + t * p3; - return r; +R3 ddBSp(R3 &p0, R3 &p1, R3 &p2, R3 &p3, double t) { + R3 r = (1. - t) * p0 + (3. * t - 2.) * p1 + (-3. * t + 1.) * p2 + t * p3; + return r; } // Evaluates the third derivative of the Bspline at a given value @@ -90,9 +88,9 @@ R3 ddBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ // t: value at which the Bspline is evaluated // Returns: // r: the value of the Bspline third derivative at parameter t -R3 dddBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ - R3 r = - p0 + 3. * p1 - 3. * p2 + p3; - return r; +R3 dddBSp(R3 &p0, R3 &p1, R3 &p2, R3 &p3, double t) { + R3 r = -p0 + 3. * p1 - 3. * p2 + p3; + return r; } // Computes the curvature kappa and the torsion tau of the Bspline at parameter value t @@ -104,15 +102,14 @@ R3 dddBSp(R3 &p0,R3 &p1,R3 &p2, R3 &p3,double t){ // t: value at which the Bspline is evaluated // Returns: // A R2 vector containing the curvature and the torsion of the Bspline at parameter t -R2 kappatau(R3 &P0,R3 &P1,R3 &P2,R3 &P3,double t) -{ - R3 Sp, Spp, Sppp, SpxSpp; - Sp = dBSp(P0,P1,P2,P3,t); - Spp = ddBSp(P0,P1,P2,P3,t); - Sppp = dddBSp(P0,P1,P2,P3,t); - SpxSpp = Sp^Spp; - double norm2=SpxSpp.norme2(),norm=sqrt(norm2); - return R2(norm/pow(Sp.norme(),3),(SpxSpp,Sppp)/norm2); +R2 kappatau(R3 &P0, R3 &P1, R3 &P2, R3 &P3, double t) { + R3 Sp, Spp, Sppp, SpxSpp; + Sp = dBSp(P0, P1, P2, P3, t); + Spp = ddBSp(P0, P1, P2, P3, t); + Sppp = dddBSp(P0, P1, P2, P3, t); + SpxSpp = Sp ^ Spp; + double norm2 = SpxSpp.norme2( ), norm = sqrt(norm2); + return R2(norm / pow(Sp.norme( ), 3), (SpxSpp, Sppp) / norm2); } // Smooth a Curve through a 5-point moving average, apply niter smoothing iterations @@ -121,229 +118,222 @@ R2 kappatau(R3 &P0,R3 &P1,R3 &P2,R3 &P3,double t) // niter: number of smoothing iterations // Returns: // 0 -long smoothCurve(KNM * const &pc,long const & niter) -{ - double omega=.8,omega1=1.-omega; - KNM &p=*pc; // pour retirer le const .. - long n= p.N()-1; - long m = p.M(); - ffassert(m==3); - - KNM q(p); // copy p; - bool loop=false; - if(p(0,0)==p(n,0L) && p(0,1)==p(n,1L) && p(0,2)==p(n,2L)) loop = true;// Check if the curve is closed - - for(int iter=0; iter *const &pc, long const &niter) { + double omega = .8, omega1 = 1. - omega; + KNM< double > &p = *pc; // pour retirer le const .. + long n = p.N( ) - 1; + long m = p.M( ); + ffassert(m == 3); + + KNM< double > q(p); // copy p; + bool loop = false; + if (p(0, 0) == p(n, 0L) && p(0, 1) == p(n, 1L) && p(0, 2) == p(n, 2L)) loop = true; // Check if the curve is closed + + for (int iter = 0; iter < niter; ++iter) { + for (int j = 0; j < m; ++j) { + for (int i = 0; i <= n; i++) { + if (loop) { + if (i < n) { // If the curve is closed, apply moving average on all points + int ipp1 = (i + n - 2) % n; + int ip1 = (i + n - 1) % n; + int imm1 = (i + n + 2) % n; + int im1 = (i + n + 1) % n; + q(i, j) = 1. / 5. * (p(ipp1, j) + p(ip1, j) + p(i, j) + p(im1, j) + p(imm1, j)); + } else { + q(i, j) = q(0, j); + } + } else { // else do not change end points and use a 3-point average for i=1 and i=N-1 + if (i == 0 | i == n) { + q(i, j) = p(i, j); + } else if (i == 1 | i == (n - 1)) { + q(i, j) = 1. / 3. * (p(i - 1, j) + p(i, j) + p(i + 1, j)); + } else { + q(i, j) = 1. / 5. * (p(i - 2, j) + p(i - 1, j) + p(i, j) + p(i + 1, j) + p(i + 2, j)); + } } - p *= omega1; - q *= omega; - p += q; + } } - return 0L; + p *= omega1; + q *= omega; + p += q; + } + return 0L; } // Interpolate a curve using a bspline -// Input: +// Input: // pc: a list of points defining the curve // np: the number of points added between existing points // Returns: // pk: the new list of points -KNM_ BSp(Stack stack,KNM_ const & pc, long const & np) -{ - KNM_ p = pc; - long n = p.N()-1; - long m = p.M(); - long nbp = n; - long nbp2; - long ntvec = max(2L,np); - double dt = 1./ ntvec; - ffassert(m==3); - - bool loop=false;// Check if the curve is closed - if(p(0,0)==p(n,0L) && p(0,1)==p(n,1L) && p(0,2)==p(n,2L)) loop = true; - - // Endpoints need to be repeated mutliple times to ensure they do not change when building the Bspline - KNM b(1,m); - if(loop){ - nbp2 = nbp+3; - b.resize(nbp2,3); - b(0,':') = p(nbp-2,':'); - b(1,':') = p(nbp-1,':'); - for(int i=0;i<=nbp;i++){ - b(i+2,':') = p(i,':'); - } - } else { - nbp2 = nbp+5; - b.resize(nbp2,3); - b(0,':') = p(0,':'); - b(1,':') = p(0,':'); - for(int i=0;i BSp(Stack stack, KNM_< double > const &pc, long const &np) { + KNM_< double > p = pc; + long n = p.N( ) - 1; + long m = p.M( ); + long nbp = n; + long nbp2; + long ntvec = max(2L, np); + double dt = 1. / ntvec; + ffassert(m == 3); + + bool loop = false; // Check if the curve is closed + if (p(0, 0) == p(n, 0L) && p(0, 1) == p(n, 1L) && p(0, 2) == p(n, 2L)) loop = true; + + // Endpoints need to be repeated mutliple times to ensure they do not change when building the Bspline + KNM< double > b(1, m); + if (loop) { + nbp2 = nbp + 3; + b.resize(nbp2, 3); + b(0, ':') = p(nbp - 2, ':'); + b(1, ':') = p(nbp - 1, ':'); + for (int i = 0; i <= nbp; i++) { + b(i + 2, ':') = p(i, ':'); + } + } else { + nbp2 = nbp + 5; + b.resize(nbp2, 3); + b(0, ':') = p(0, ':'); + b(1, ':') = p(0, ':'); + for (int i = 0; i < nbp2 - 2; i++) { + b(i + 2, ':') = p(i, ':'); } - int newnbp = nbp2-3; - int taille = newnbp*(ntvec-1)+1; - int npk=6; - KNM_ pk(Add2StackOfPtr2FreeA(stack,new double[taille*npk]), taille, npk);// pour les PB de memoire ... - int ik=0; - R2 kt; - R3 bsp, bsp_old; - double s_tot = 0.; - for(int i=0;i pk(Add2StackOfPtr2FreeA(stack, new double[taille * npk]), taille, npk); // pour les PB de memoire ... + int ik = 0; + R2 kt; + R3 bsp, bsp_old; + double s_tot = 0.; + for (int i = 0; i < newnbp; i++) { + R3 P0(get(b, i)), P1(get(b, i + 1)), P2(get(b, i + 2)), P3(get(b, i + 3)); // Existing points + for (int ni = 0; ni < ntvec - 1; ni++) // add new points { - R3 P0(get(b,i)),P1(get(b,i+1)),P2(get(b,i+2)),P3(get(b,i+3));//Existing points - for(int ni=0;ni -eps && lr < 1+eps ) { - // zero sur a,b - return zz*10; - } else return zz*20; - } - static int count =0; - double dw =arg(b/a)/twopi; +double intdphase(bool bb, Complex const &a, Complex const &b, double const &eps) { + const double twopi = 2. * Pi; + double zz = bb ? 1. : -1.; + zz = 0; // in test !!!! FH. + // zero entra ua et ub => 0 phase ??? + Complex ab(b - a); + if (abs(ab) < eps) return zz * 100; + // 0= a + l ab => l = -a/ab + Complex l = -a / ab; + + if (abs(l.imag( )) < eps) { + // cout << " intdphase "<< l << " " << arg(a/b) << " " << a/b << endl; + // l est real ??? + // verif si l in [0,1] + double lr = l.imag( ); + if (lr > -eps && lr < 1 + eps) { + // zero sur a,b + return zz * 10; + } else + return zz * 20; + } + static int count = 0; + double dw = arg(b / a) / twopi; // if(count++<100) cout << dw << endl; - return dw; - + return dw; } -double ChargeF(int i1,int i2,int i3,Complex u[3], double const & eps) -{ - double ch = - intdphase(i199) cout << u[0]<< " " << u[1] << " " << u[2] << " ch = " << ch << endl; +double ChargeF(int i1, int i2, int i3, Complex u[3], double const &eps) { + double ch = intdphase(i1 < i2, u[0], u[1], eps) + intdphase(i2 < i3, u[1], u[2], eps) + intdphase(i3 < i1, u[2], u[0], eps); + double chn = round(ch); + if (verbosity > 99) cout << u[0] << " " << u[1] << " " << u[2] << " ch = " << ch << endl; - return ch ; + return ch; } -long uZero(pf3c const & fu, pf3r const & fuc, double const &eps) -{ - const double epscharge = 1e-3; // - - typedef Mesh3::Element Element; - typedef v_fes3::FESpace FESpace; - typedef Complex K; - pf3cbase bu=fu.first; - pf3rbase buc=fuc.first; - - ffassert(fu.second==0); - ffassert(fuc.second==0); - - KN * pu=bu->x(); - KN * puc=buc->x(); - - FESpace *pUh = fu.first->Vh ; - FESpace *pUch = fuc.first->newVh( ); - ffassert(pUh && pUch); - ffassert(&pUh->Th == &pUch->Th ); - if(pu ==0 || pu->N() != pUh->NbOfDF) { - ffassert(0); // u undef ... - } - if(puc ==0 || puc->N() != pUch->NbOfDF) { - if(!mpirank && verbosity>0) cout << " FE create or recreate " << puc << endl; - if(puc) delete [] puc; - *fuc.first = puc = new KN< double >(pUch->NbOfDF); - *puc = double( ); - } - const Mesh3 & Th=pUh->Th; - KN & u=*pu; - KN & uc=*puc; - FESpace & Uh = *pUh; - int nkk=0; - const double twopi = 2.*Pi; - double charge; - uc=0.; - for(int k=0; k -eps) && (ymn < eps) && (ymx > -eps); - int ucn=0;// number of faces of charge = 1 - - if(b) - { - for(int i=0; i<4;++i) - { - int i0 = Th(K[Element::nvface[i][0]]); - int i1 = Th(K[Element::nvface[i][1]]); - int i2 = Th(K[Element::nvface[i][2]]); - Complex u2[3]={u[i0],u[i1],u[i2]}; - double charge = ChargeF(i0,i1,i2,u2,eps); - R2 P2; - bool inz =in(u2,P2, eps) ; - - if( abs(round(charge)-charge)>1e-10 && verbosity>4) - cout << " uZero; charge F not int : "<< charge << " " << k << " / " << i << " nkk: " << nkk << " in:" << inz <<" "<< P2 << endl; - else if(verbosity>99) - cout << " uZero charge F int : "<< charge << " " << k << " / " << i << " nkk: " << nkk << " in:" << inz <<" "<< P2 << endl; - - if (inz && (abs(charge)>epscharge)) - ucn ++; - } - uc[k]=ucn; - if(ucn) nkk++; - } +long uZero(pf3c const &fu, pf3r const &fuc, double const &eps) { + const double epscharge = 1e-3; // + + typedef Mesh3::Element Element; + typedef v_fes3::FESpace FESpace; + typedef Complex K; + pf3cbase bu = fu.first; + pf3rbase buc = fuc.first; + + ffassert(fu.second == 0); + ffassert(fuc.second == 0); + + KN< K > *pu = bu->x( ); + KN< double > *puc = buc->x( ); + + FESpace *pUh = fu.first->Vh; + FESpace *pUch = fuc.first->newVh( ); + ffassert(pUh && pUch); + ffassert(&pUh->Th == &pUch->Th); + if (pu == 0 || pu->N( ) != pUh->NbOfDF) { + ffassert(0); // u undef ... + } + if (puc == 0 || puc->N( ) != pUch->NbOfDF) { + if (!mpirank && verbosity > 0) cout << " FE create or recreate " << puc << endl; + if (puc) delete[] puc; + *fuc.first = puc = new KN< double >(pUch->NbOfDF); + *puc = double( ); + } + const Mesh3 &Th = pUh->Th; + KN< K > &u = *pu; + KN< double > &uc = *puc; + FESpace &Uh = *pUh; + int nkk = 0; + const double twopi = 2. * Pi; + double charge; + uc = 0.; + for (int k = 0; k < Th.nt; ++k) { + const Element &K = Th[k]; + int i0 = Uh(k, 0); + int i1 = Uh(k, 1); + int i2 = Uh(k, 2); + int i3 = Uh(k, 3); + + double xmn = min(min(min(u[i0].real( ), u[i1].real( )), u[i2].real( )), u[i3].real( )); + double xmx = max(max(max(u[i0].real( ), u[i1].real( )), u[i2].real( )), u[i3].real( )); + double ymn = min(min(min(u[i0].imag( ), u[i1].imag( )), u[i2].imag( )), u[i3].imag( )); + double ymx = max(max(max(u[i0].imag( ), u[i1].imag( )), u[i2].imag( )), u[i3].imag( )); + + bool b = (xmn < eps) && (xmx > -eps) && (ymn < eps) && (ymx > -eps); + int ucn = 0; // number of faces of charge = 1 + + if (b) { + for (int i = 0; i < 4; ++i) { + int i0 = Th(K[Element::nvface[i][0]]); + int i1 = Th(K[Element::nvface[i][1]]); + int i2 = Th(K[Element::nvface[i][2]]); + Complex u2[3] = {u[i0], u[i1], u[i2]}; + double charge = ChargeF(i0, i1, i2, u2, eps); + R2 P2; + bool inz = in(u2, P2, eps); + + if (abs(round(charge) - charge) > 1e-10 && verbosity > 4) + cout << " uZero; charge F not int : " << charge << " " << k << " / " << i << " nkk: " << nkk << " in:" << inz << " " << P2 << endl; + else if (verbosity > 99) + cout << " uZero charge F int : " << charge << " " << k << " / " << i << " nkk: " << nkk << " in:" << inz << " " << P2 << endl; + + if (inz && (abs(charge) > epscharge)) ucn++; + } + uc[k] = ucn; + if (ucn) nkk++; } - return nkk; + } + return nkk; } -long uZero2D1(const Mesh * const & pTh,KN*const &pu, KN*const &pucharge) -{ - typedef Mesh::Element Element; - typedef Element::Vertex Vertex; - KN &u = *pu; - KN &ucharge = *pucharge; - const Mesh &Th = *pTh; - ffassert(u.N()==Th.nv); - ffassert(ucharge.N()==Th.nt); - const double twopi = 2.*Pi; - Complex u0,u1,u2;// value of u over the vertex of the tetrahedron - double charge; - double l0,l1,l2; - int nbc=0; - for (int k=0; k *const &pu, KN< double > *const &pucharge) { + typedef Mesh::Element Element; + typedef Element::Vertex Vertex; + KN< Complex > &u = *pu; + KN< double > &ucharge = *pucharge; + const Mesh &Th = *pTh; + ffassert(u.N( ) == Th.nv); + ffassert(ucharge.N( ) == Th.nt); + const double twopi = 2. * Pi; + Complex u0, u1, u2; // value of u over the vertex of the tetrahedron + double charge; + double l0, l1, l2; + int nbc = 0; + for (int k = 0; k < Th.nt; k++) { + double ck = 0; + for (int e = 0; e < 3; ++e) { + int i0 = Th(k, (e + 1) % 3); + int i1 = Th(k, (e + 2) % 3); + double ce = intdphase(i0 < i1, u[i0], u[i1], 1e-15); + ck += ce; } - return nbc; + if (abs(ck) < 1e-16) nbc++; + ucharge[k] = ck; + } + return nbc; } - -long uZero2D(const Mesh * const & pTh,KNM*const &ppoints,KN*const &pu, KN*const &pucharge, double* const & pdmin) -{ - const double eps =1e-12,epscharge=0.1; - typedef Mesh::Element Element; - typedef Element::Vertex Vertex; - KN &u = *pu; - KN &ucharge = *pucharge; - const Mesh &Th = *pTh; - KNM &pts=*ppoints; - KNM points(Th.nt,2); - KN Pf(Th.nt); - R2 Pmin,Pmax; - Th.BoundingBox(Pmin,Pmax); - FQuadTree *gtree=new FQuadTree(Pf,Pmin,Pmax,0); - double mindist=1e100; - - double &dmin = *pdmin; - ffassert(u.N()==Th.nv); - ffassert(ucharge.N()==Th.nt); - const double twopi = 2.*Pi; - Complex u0,u1,u2;// value of u over the vertex of the tetrahedron - double charge; - double l0,l1,l2; - int nbc=0; - double epsP = 10./gtree->coef; - for (int k=0; kepscharge )) - { - R2 Pk = K(P2); - // verif ... - if(gtree->ToClose(Pk,epsP,true)==0 ) { // new points - const Vertex * pvi=gtree->TrueNearestVertex(Pk); - if(pvi) - { - R2 d(Pk,*pvi); - mindist = min(mindist,d.norme2()); - } - Pf[nbc]=Pk; - gtree->Add(Pf[nbc]); - points(nbc,0) = Pk.x; - points(nbc,1) = Pk.y; - ucharge[k] = charge; - nbc++; - } +long uZero2D(const Mesh *const &pTh, KNM< double > *const &ppoints, KN< Complex > *const &pu, KN< double > *const &pucharge, double *const &pdmin) { + const double eps = 1e-12, epscharge = 0.1; + typedef Mesh::Element Element; + typedef Element::Vertex Vertex; + KN< Complex > &u = *pu; + KN< double > &ucharge = *pucharge; + const Mesh &Th = *pTh; + KNM< double > &pts = *ppoints; + KNM< double > points(Th.nt, 2); + KN< Vertex > Pf(Th.nt); + R2 Pmin, Pmax; + Th.BoundingBox(Pmin, Pmax); + FQuadTree *gtree = new FQuadTree(Pf, Pmin, Pmax, 0); + double mindist = 1e100; + + double &dmin = *pdmin; + ffassert(u.N( ) == Th.nv); + ffassert(ucharge.N( ) == Th.nt); + const double twopi = 2. * Pi; + Complex u0, u1, u2; // value of u over the vertex of the tetrahedron + double charge; + double l0, l1, l2; + int nbc = 0; + double epsP = 10. / gtree->coef; + for (int k = 0; k < Th.nt; k++) { + const Element &K = Th[k]; + int i0 = Th(k, 0); + int i1 = Th(k, 1); + int i2 = Th(k, 2); + Complex u2[3] = {u[i0], u[i1], u[i2]}; + charge = ChargeF(i0, i1, i2, u2, eps); + R2 P2; + ucharge[k] = 0; // p s vortex + if (in(u2, P2, eps) && (abs(charge) > epscharge)) { + R2 Pk = K(P2); + // verif ... + if (gtree->ToClose(Pk, epsP, true) == 0) { // new points + const Vertex *pvi = gtree->TrueNearestVertex(Pk); + if (pvi) { + R2 d(Pk, *pvi); + mindist = min(mindist, d.norme2( )); } - } - points.resize(nbc,2); - pts.resize(nbc,2); - pts=points; - - dmin = sqrt(mindist); - delete gtree; - return (long)nbc; + Pf[nbc] = Pk; + gtree->Add(Pf[nbc]); + points(nbc, 0) = Pk.x; + points(nbc, 1) = Pk.y; + ucharge[k] = charge; + nbc++; + } + } + } + points.resize(nbc, 2); + pts.resize(nbc, 2); + pts = points; + + dmin = sqrt(mindist); + delete gtree; + return (long)nbc; } // Build a graph of vortex points from a complex wavefunction @@ -584,261 +556,255 @@ long uZero2D(const Mesh * const & pTh,KNM*const &ppoints,KN*con // ploop: list of boolean indicating if the lines are closed or not // Returns: // b: the number of vortex lines -long ZeroLines(pf3c const & fu,double const & eps, KNM*const &ppoints,KN*const &pbe,KN* const & ploop) -{ - const double epscharge = 1e-3; // - typedef v_fes3::FESpace FESpace; - typedef Complex K; - pf3cbase bu=fu.first; - - ffassert(fu.second==0); - KN * pu=bu->x(); - FESpace *pUh = fu.first->Vh ; - const Mesh3 & Th=pUh->Th; - KN & u=*pu; - R3 D=Th.Pmax-Th.Pmin; - R3 M =(Th.Pmax+Th.Pmin)*.5; - double Dmesh = max(max(D.x,D.y),D.z); - double lb = Dmesh*0.6; - R3 Bmin = M - R3(lb,lb,lb), Bmax= M + R3(lb,lb,lb); - double hseuil= Dmesh*1e-12;// ???? - typedef Mesh3::Element Element; - typedef Element::Vertex Vertex; - - KNM &pts=*ppoints; - KN &be=*pbe; - KN &loop = *ploop; - - long nt =Th.nt; - long nv = Th.nv; - int nbp2=0; - for (int k=0; k *const &ppoints, KN< long > *const &pbe, KN< long > *const &ploop) { + const double epscharge = 1e-3; // + typedef v_fes3::FESpace FESpace; + typedef Complex K; + pf3cbase bu = fu.first; + + ffassert(fu.second == 0); + KN< K > *pu = bu->x( ); + FESpace *pUh = fu.first->Vh; + const Mesh3 &Th = pUh->Th; + KN< K > &u = *pu; + R3 D = Th.Pmax - Th.Pmin; + R3 M = (Th.Pmax + Th.Pmin) * .5; + double Dmesh = max(max(D.x, D.y), D.z); + double lb = Dmesh * 0.6; + R3 Bmin = M - R3(lb, lb, lb), Bmax = M + R3(lb, lb, lb); + double hseuil = Dmesh * 1e-12; // ???? + typedef Mesh3::Element Element; + typedef Element::Vertex Vertex; + + KNM< double > &pts = *ppoints; + KN< long > &be = *pbe; + KN< long > &loop = *ploop; + + long nt = Th.nt; + long nv = Th.nv; + int nbp2 = 0; + for (int k = 0; k < Th.nt; k++) { + const Element &K = Th[k]; + int fi[4], kf[4], nfi = 0; + R3 PF[4]; + for (int i = 0; i < 4; ++i) { + int i0 = Th(K[Element::nvface[i][0]]); + int i1 = Th(K[Element::nvface[i][1]]); + int i2 = Th(K[Element::nvface[i][2]]); + Complex u2[] = {u[i0], u[i1], u[i2]}; + R2 P2; + if (in(u2, P2, eps)) { + nbp2++; + } } - int nbpx = nbp2; - KN Pf(nbpx); - int nbp=0; - EF23::GTree *gtree=new EF23::GTree(Pf,Bmin,Bmax,0); - hseuil = 5./gtree->coef; // seuil minimal dans gtree - if(verbosity>9) cout << " hseuil minimal "<< hseuil << endl; - long ihseuil=gtree->coef*hseuil; - ffassert(ihseuil); - int nbarc =0; - typedef std::array Arc; - vector arc; - double hseuil2=hseuil*hseuil; - double charge; - const double twopi = 2.*Pi; - for (int k=0; k1e-10 && verbosity>4) - cout << " charge F not int : "<< charge << " " << k << " / " << i << " nbp: " << nbp << " in:" << inz <<" "<< P2 << endl; - else if(verbosity>99) - cout << " charge F int : "<< charge << " " << k << " / " << i << " nbp: " << nbp << " in:" << inz <<" "<< P2 << endl; - - if (inz && (abs(charge)>epscharge)) - { - R3 P=K(K.PBord(i,P2));// - Vertex * pvi=gtree->ToClose(P,hseuil,true); - // verif brute force - if(!pvi && nbp) - { - pvi=gtree->NearestVertex(P,true); - int j = pvi - Pf; - double l2 = R3(*pvi,P).norme2(); - if(l2 > hseuil2) pvi=0; - else if( l2 < hseuil2) { - if(verbosity>9) cout << " bug in ToClose ??? " << k << " "<< i << " == " << j << " : " << P << " j " << Pf[j] << " / " << l2 <9) cout << " bug " << k << " "<< i << " == " << j << " : " << P << " j " << Pf[j] << " / " << l2 <Add(Pf[nbp]); - pvi = &Pf[nbp]; - nbp++; - } - fi[nfi]=i; - ip[nfi]= pvi- (Vertex *) Pf; - nfi++; - - } - // compress ip - sort(ip,ip+nfi); - int nfi2=unique (ip, ip+nfi)-ip; - if( nfi2 != nfi && verbosity>9) cout << " nfi "<< nfi << " " << nfi2 << endl; - ffassert( nfi2 <=2); - if(nfi2==2) - { - int i0= ip[0],i1=ip[1]; - Arc A={i0,i1}; - arc.push_back(A); - } + } + int nbpx = nbp2; + KN< Vertex > Pf(nbpx); + int nbp = 0; + EF23::GTree< Vertex > *gtree = new EF23::GTree< Vertex >(Pf, Bmin, Bmax, 0); + hseuil = 5. / gtree->coef; // seuil minimal dans gtree + if (verbosity > 9) cout << " hseuil minimal " << hseuil << endl; + long ihseuil = gtree->coef * hseuil; + ffassert(ihseuil); + int nbarc = 0; + typedef std::array< int, 2 > Arc; + vector< Arc > arc; + double hseuil2 = hseuil * hseuil; + double charge; + const double twopi = 2. * Pi; + for (int k = 0; k < Th.nt; k++) { + const Element &K = Th[k]; + int fi[4], kf[4], ip[4], nfi = 0; + R3 PF[4]; + + for (int i = 0; i < 4; ++i) { + int i0 = Th(K[Element::nvface[i][0]]); + int i1 = Th(K[Element::nvface[i][1]]); + int i2 = Th(K[Element::nvface[i][2]]); + Complex u2[] = {u[i0], u[i1], u[i2]}; + double charge = ChargeF(i0, i1, i2, u2, eps); + + R2 P2; + bool inz = in(u2, P2, eps); + + if (abs(round(charge) - charge) > 1e-10 && verbosity > 4) + cout << " charge F not int : " << charge << " " << k << " / " << i << " nbp: " << nbp << " in:" << inz << " " << P2 << endl; + else if (verbosity > 99) + cout << " charge F int : " << charge << " " << k << " / " << i << " nbp: " << nbp << " in:" << inz << " " << P2 << endl; + + if (inz && (abs(charge) > epscharge)) { + R3 P = K(K.PBord(i, P2)); // + Vertex *pvi = gtree->ToClose(P, hseuil, true); + // verif brute force + if (!pvi && nbp) { + pvi = gtree->NearestVertex(P, true); + int j = pvi - Pf; + double l2 = R3(*pvi, P).norme2( ); + if (l2 > hseuil2) + pvi = 0; + else if (l2 < hseuil2) { + if (verbosity > 9) cout << " bug in ToClose ??? " << k << " " << i << " == " << j << " : " << P << " j " << Pf[j] << " / " << l2 << endl; + } } - // in ArcF(i0,i1) i \in [i0,i1], if i%5==4 => i/5 numéro thétraèdre else (i%5) numéro de face dans le tétraèdre i/5 - } - delete gtree; - sort(arc.begin(),arc.end()); - int nbua=unique(arc.begin(),arc.end())-arc.begin(); - if(verbosity>9) cout << " nbua "<< nbua << " " << arc.size() << " nbp " << nbp << " / " << nbp2 << endl; - arc.resize(nbua); - vector> av(nbp); - if(verbosity>99) cout << " nb arc = "<< arc.size() << endl; - for(int i=0;i99) cout << " arc "<< i <<" " << arc[i][0] <<" " << arc[i][1] << endl; - for(int j=0;j<2; ++j) - { - av[arc[i][j]].push_back(2*i+j); + /* if(0) // force brute ??? + for(int j=0; j< nbp; ++j) + { + double l2 = R3(P,Pf[j]).norme2(); + if( l2 < hseuil2) { + if(verbosity>9) cout << " bug " << k << " "<< i << " == " << j << " : " << P << " j " << Pf[j] << " / " << l2 <Add(Pf[nbp]); + pvi = &Pf[nbp]; + nbp++; } + fi[nfi] = i; + ip[nfi] = pvi - (Vertex *)Pf; + nfi++; + } + // compress ip + sort(ip, ip + nfi); + int nfi2 = unique(ip, ip + nfi) - ip; + if (nfi2 != nfi && verbosity > 9) cout << " nfi " << nfi << " " << nfi2 << endl; + ffassert(nfi2 <= 2); + if (nfi2 == 2) { + int i0 = ip[0], i1 = ip[1]; + Arc A = {i0, i1}; + arc.push_back(A); + } } - // recherche des banche du graphe - vector b; // debut de branche et fin de branche - KN next(nbp); - next=-1L; - int nca =0; - KN ca(arc.size(),0); - auto which = [&arc] (int a,int v) {ffassert( arc[a][0] ==v || arc[a][1] ==v); return arc[a][0] ==v ? 0 : 1 ;}; - auto nexta = [&arc,&av] (int i,int a) { - int aa=-1; - if(av[i].size() ==2) - { - if(verbosity>99) cout << i << " " << a << " : " << av[i][0]/2 << " "<< av[i][1]/2 << endl; - int k = av[i][1]/2 != a ; - - ffassert( av[i][1-k]/2 == a); - aa = av[i][k]; - } - return aa;}; - auto branch = [&ca , &arc, & next, &which, &nexta , &nca, & b, &av](int a,int i) { - // depart a, sommet ai de a - if( ca[a]) return ; - int ia=which(a,i); - int lg=1; - // depart de branch .. - b.push_back(2*a+ia); - ca[a]=1; - int v = arc[a][1-ia]; - if(verbosity>9) cout << " branch "<< a << " " << ia << " s= "<< i << " o= " << av[i].size() << " -> "<< v << " " ; - while(1) { - int aa = nexta(v,a); - if(aa <0) { if(verbosity>9) cout << " fin branch s= " < " << vv << endl; - v = vv; - ffassert(nca < arc.size()) ; - nca++; - lg++; - ca[a]=1; - } - - return; - }; - - for( int i=0; i0 && av[i].size()!=2 ) { - // un depart possible - if(verbosity>9) cout << " depart a "<< av[i].size() << " a= " < i/5 numéro thétraèdre else (i%5) numéro de face dans le tétraèdre i/5 + } + delete gtree; + sort(arc.begin( ), arc.end( )); + int nbua = unique(arc.begin( ), arc.end( )) - arc.begin( ); + if (verbosity > 9) cout << " nbua " << nbua << " " << arc.size( ) << " nbp " << nbp << " / " << nbp2 << endl; + arc.resize(nbua); + vector< vector< int > > av(nbp); + if (verbosity > 99) cout << " nb arc = " << arc.size( ) << endl; + for (int i = 0; i < arc.size( ); ++i) { + if (verbosity > 99) cout << " arc " << i << " " << arc[i][0] << " " << arc[i][1] << endl; + for (int j = 0; j < 2; ++j) { + av[arc[i][j]].push_back(2 * i + j); } - int nbline = b.size(); - loop.resize(nbline); - for(int i=0; i< nbline; ++i) - loop(i)=0; - // recheche des autre depart (les boucle) - for( int aa=0; aa9) cout << " depart boucle " << aa << arc[aa][0] << endl; - branch(aa,arc[aa][0]); - } + } + // recherche des banche du graphe + vector< int > b; // debut de branche et fin de branche + KN< long > next(nbp); + next = -1L; + int nca = 0; + KN< int > ca(arc.size( ), 0); + auto which = [&arc](int a, int v) { + ffassert(arc[a][0] == v || arc[a][1] == v); + return arc[a][0] == v ? 0 : 1; + }; + auto nexta = [&arc, &av](int i, int a) { + int aa = -1; + if (av[i].size( ) == 2) { + if (verbosity > 99) cout << i << " " << a << " : " << av[i][0] / 2 << " " << av[i][1] / 2 << endl; + int k = av[i][1] / 2 != a; + + ffassert(av[i][1 - k] / 2 == a); + aa = av[i][k]; } - loop.resize(b.size()); - for(int i=nbline; i< b.size(); ++i) - loop(i)=1; - - KNM points(nbp+b.size(),3); - - int nbe=0; - int nbc=0; + return aa; + }; + auto branch = [&ca, &arc, &next, &which, &nexta, &nca, &b, &av](int a, int i) { + // depart a, sommet ai de a + if (ca[a]) return; + int ia = which(a, i); + int lg = 1; + // depart de branch .. + b.push_back(2 * a + ia); + ca[a] = 1; + int v = arc[a][1 - ia]; + if (verbosity > 9) cout << " branch " << a << " " << ia << " s= " << i << " o= " << av[i].size( ) << " -> " << v << " "; + while (1) { + int aa = nexta(v, a); + if (aa < 0) { + if (verbosity > 9) cout << " fin branch s= " << v << " o= " << av[v].size( ) << " lg = " << lg << endl; + break; + } + if (ca[aa / 2]) { + if (verbosity > 9) cout << " fin loop " << aa / 2 << " s= " << v << " o=" << av[v].size( ) << " lg = " << lg << endl; + break; + } + a = aa / 2; + ia = aa % 2; + int vv = arc[a][1 - ia]; + next[v] = vv; + if (verbosity > 99) cout << " -> " << vv << endl; + v = vv; + ffassert(nca < arc.size( )); + nca++; + lg++; + ca[a] = 1; + } + + return; + }; + + for (int i = 0; i < nbp; ++i) + if (av[i].size( ) > 0 && av[i].size( ) != 2) { + // un depart possible + if (verbosity > 9) cout << " depart a " << av[i].size( ) << " a= " << av[i][0] / 2 << " " << endl; + for (int j = 0; j < av[i].size( ); ++j) branch(av[i][j] / 2, i); + } + int nbline = b.size( ); + loop.resize(nbline); + for (int i = 0; i < nbline; ++i) loop(i) = 0; + // recheche des autre depart (les boucle) + for (int aa = 0; aa < arc.size( ); ++aa) { + if (ca[aa] == 0) // no colorie , un depart possible dans le 2 sens { - if(verbosity>99) cout << " parcours de branch .." << endl; - for(int i=0; i< b.size(); ++i) - { - int a = b[i]/2, j =b[i]%2, s0=arc[a][j] , s= arc[a][1-j],ss; - if(verbosity>99) cout << " branch "<< i << " s0 = "<< s0 << " " << av[s0].size() << ": " << endl; - nbc++; - be.resize(nbc*2); - be(2*(nbc-1))=nbe; - R3 p0=Pf[s0]; - points(nbe,0)=p0.x; points(nbe,1)=p0.y; points(nbe,2)=p0.z; nbe++; - while ((ss=next[s])>=0) - { - R3 pss=Pf[ss]; - points(nbe,0)=pss.x; points(nbe,1)=pss.y; points(nbe,2)=pss.z; nbe++; - if(verbosity>99) cout << s << " -> "; - s=ss; - } - be(2*(nbc-1)+1)=nbe-1; - if(verbosity>99) cout << " : " << av[s].size() << "-1" << endl; - } + if (verbosity > 9) cout << " depart boucle " << aa << arc[aa][0] << endl; + branch(aa, arc[aa][0]); } - points.resize(nbe,3); - pts.resize(nbe,3); - pts=points; - return b.size(); + } + loop.resize(b.size( )); + for (int i = nbline; i < b.size( ); ++i) loop(i) = 1; + + KNM< double > points(nbp + b.size( ), 3); + + int nbe = 0; + int nbc = 0; + { + if (verbosity > 99) cout << " parcours de branch .." << endl; + for (int i = 0; i < b.size( ); ++i) { + int a = b[i] / 2, j = b[i] % 2, s0 = arc[a][j], s = arc[a][1 - j], ss; + if (verbosity > 99) cout << " branch " << i << " s0 = " << s0 << " " << av[s0].size( ) << ": " << endl; + nbc++; + be.resize(nbc * 2); + be(2 * (nbc - 1)) = nbe; + R3 p0 = Pf[s0]; + points(nbe, 0) = p0.x; + points(nbe, 1) = p0.y; + points(nbe, 2) = p0.z; + nbe++; + while ((ss = next[s]) >= 0) { + R3 pss = Pf[ss]; + points(nbe, 0) = pss.x; + points(nbe, 1) = pss.y; + points(nbe, 2) = pss.z; + nbe++; + if (verbosity > 99) cout << s << " -> "; + s = ss; + } + be(2 * (nbc - 1) + 1) = nbe - 1; + if (verbosity > 99) cout << " : " << av[s].size( ) << "-1" << endl; + } + } + points.resize(nbe, 3); + pts.resize(nbe, 3); + pts = points; + return b.size( ); } // Computes the curvature of a curve @@ -848,35 +814,34 @@ long ZeroLines(pf3c const & fu,double const & eps, KNM*const &ppoints,KN // pC: list storing the curvature at points in pTH // Returns: // 0 -long curvatureL(pmeshL const &pTh, KN*const &pc) -{ - typedef MeshL::Element Element; - KN &c = *pc; - const MeshL &Th = *pTh; - int nt=Th.nt,nv=Th.nv; - ffassert(c.N()==nv); - - KN< int > cn(nv); - KN< double > le(nv); - c = 0.; - cn = 0; - le = 0.; - - for(int k=0;k1 - int ii=1, kk = Th.ElementAdj(k,ii); - if(kk<0) continue; - const Element & EAdj(Th[kk]); - R3 EVAdj(EAdj[0],EAdj[1]);// vector 0->1 - double lAdj = EAdj.mesure(); - double scalprod = (EV,EVAdj); - double cosa = scalprod/lE/lAdj; - double aa = acos(cosa); - c[Th(k,1)] = 2.* aa / (lE + lAdj); - } - return 0L; +long curvatureL(pmeshL const &pTh, KN< double > *const &pc) { + typedef MeshL::Element Element; + KN< double > &c = *pc; + const MeshL &Th = *pTh; + int nt = Th.nt, nv = Th.nv; + ffassert(c.N( ) == nv); + + KN< int > cn(nv); + KN< double > le(nv); + c = 0.; + cn = 0; + le = 0.; + + for (int k = 0; k < nt; k++) { + const Element &E(Th[k]); + double lE = E.mesure( ); + R3 EV(E[0], E[1]); // vector 0->1 + int ii = 1, kk = Th.ElementAdj(k, ii); + if (kk < 0) continue; + const Element &EAdj(Th[kk]); + R3 EVAdj(EAdj[0], EAdj[1]); // vector 0->1 + double lAdj = EAdj.mesure( ); + double scalprod = (EV, EVAdj); + double cosa = scalprod / lE / lAdj; + double aa = acos(cosa); + c[Th(k, 1)] = 2. * aa / (lE + lAdj); + } + return 0L; } // Computes the arc-length of a curve @@ -888,23 +853,21 @@ long curvatureL(pmeshL const &pTh, KN*const &pc) // ss: Arc-length at points in xyz // Returns: // l: the length of the curve -double abscisses(KN_ const & x,KN_ const & y,KN_ const & z,KN_ const& ss) -{ - assert( x.N()==ss.N()); - assert( y.N()==ss.N()); - assert( z.N()==ss.N()); - KN_ s=ss; - double l=0; - s[0]=l; - R3 P(x[0],y[0],z[0]); - for(int i=1; i const &x, KN_< double > const &y, KN_< double > const &z, KN_< double > const &ss) { + assert(x.N( ) == ss.N( )); + assert(y.N( ) == ss.N( )); + assert(z.N( ) == ss.N( )); + KN_< double > s = ss; + double l = 0; + s[0] = l; + R3 P(x[0], y[0], z[0]); + for (int i = 1; i < ss.N( ); ++i) { + R3 Q(x[i], y[i], z[i]); + l += R3(P, Q).norme( ); + s[i] = l; + P = Q; + } + return l; } // Use linear interpolation to send data from irregular discretization to regular discretization @@ -915,47 +878,46 @@ double abscisses(KN_ const & x,KN_ const & y,KN_ const // xn: Interpolated values on regular discretization // Returns: // l: the length of the curve -double interpol(KN_ const & so,KN_ const & xo,KN_ const & xn) -{ - int N = xn.N(); - int M = so.N(); - double l = so[M-1]; - double dl = l/(N-1.),si=0, si1; - ffassert(so.N()==xo.N()); - int i0 = 0; - for(int i=0; i l - if( i== N-1) si=l; - // find i0 such that [so[i],so[i+1] [ - while (i0+219) cout << " iinterpole :" < const &so, KN_< double > const &xo, KN_< double > const &xn) { + int N = xn.N( ); + int M = so.N( ); + double l = so[M - 1]; + double dl = l / (N - 1.), si = 0, si1; + ffassert(so.N( ) == xo.N( )); + int i0 = 0; + for (int i = 0; i < N; ++i) { + si = i * dl; + // warning roundoff error s_(N-1) > l + if (i == N - 1) si = l; + // find i0 such that [so[i],so[i+1] [ + while (i0 + 2 < M) { // cout << i0<<" " << si << " " << so[i0+1] << " " << (si < so[i0+1] ) < 19) cout << " iinterpole :" << i0 << " " << M << ": " << si << ": " << si0 << " " << " " << si1 << " " << si0 - si << " " << si - si1 << endl; + ffassert(si0 <= si && si <= si1); + double l = (si - si0) / (si1 - si0); + xn[i] = xo[i0] * (1 - l) + xo[i0 + 1] * (l); + } + return l; } static void inittt( ) { - Global.Add("uZero2D", "(",new OneOperator5_ *,KN *,KN *,double* >(uZero2D)); - // Global.Add("uZero2D1", "(",new OneOperator3_ *,KN * >(uZero2D1)); - Global.Add("uZero", "(",new OneOperator3_(uZero)); - Global.Add("ZeroLines", "(",new OneOperator5_ *,KN*,KN*> (ZeroLines) ); - Global.Add("BSp", "(",new OneOperator2s_,KNM_,long >(BSp)); - Global.Add("curvatureL", "(", new OneOperator2_< long, pmeshL, KN * >(curvatureL)); - Global.Add("smoothCurve", "(",new OneOperator2_*,long >(smoothCurve)); - Global.Add("zero3", "(",new OneOperator3s_(zero3)); - Global.Add("interpol", "(",new OneOperator3_ > (interpol) ); - Global.Add("abscisses", "(",new OneOperator4_ > (abscisses) ); + Global.Add("uZero2D", "(", new OneOperator5_< long, const Mesh *, KNM< double > *, KN< Complex > *, KN< double > *, double * >(uZero2D)); + // Global.Add("uZero2D1", "(",new OneOperator3_ *,KN * >(uZero2D1)); + Global.Add("uZero", "(", new OneOperator3_< long, pf3c, pf3r, double >(uZero)); + Global.Add("ZeroLines", "(", new OneOperator5_< long, pf3c, double, KNM< double > *, KN< long > *, KN< long > * >(ZeroLines)); + Global.Add("BSp", "(", new OneOperator2s_< KNM_< double >, KNM_< double >, long >(BSp)); + Global.Add("curvatureL", "(", new OneOperator2_< long, pmeshL, KN< double > * >(curvatureL)); + Global.Add("smoothCurve", "(", new OneOperator2_< long, KNM< double > *, long >(smoothCurve)); + Global.Add("zero3", "(", new OneOperator3s_< R3 *, Complex, Complex, Complex >(zero3)); + Global.Add("interpol", "(", new OneOperator3_< double, KN_< double > >(interpol)); + Global.Add("abscisses", "(", new OneOperator4_< double, KN_< double > >(abscisses)); } LOADFUNC(inittt); diff --git a/src/Algo/BFGS.hpp b/src/Algo/BFGS.hpp index 8a818ee05..3d67afa63 100644 --- a/src/Algo/BFGS.hpp +++ b/src/Algo/BFGS.hpp @@ -119,8 +119,7 @@ typename BFGS< LS >::Param BFGS< LS >::optimizer(Param& model0) { err = (Real)sqrt((g1, g1)); if (this->isVerbose) cerr << "Iteration (" << this->iterNum << ") : " - << "current value of the objective function: " << this->ls->currentValue( ) - << "\t current residue: " << err << endl; + << "current value of the objective function: " << this->ls->currentValue( ) << "\t current residue: " << err << endl; this->appendResidue(err); // residual this->iterNum++; @@ -172,8 +171,7 @@ typename BFGS< LS >::Param BFGS< LS >::optimizer(Param& model0) { if (this->isVerbose) cerr << "Iteration (" << this->iterNum << ") : " - << "current value of the objective function: " << this->ls->currentValue( ) - << "\t current residue: " << err << endl; + << "current value of the objective function: " << this->ls->currentValue( ) << "\t current residue: " << err << endl; this->appendResidue(err); // residual this->iterNum++; diff --git a/src/Algo/BrentLS.hpp b/src/Algo/BrentLS.hpp index d02026f2d..4cd2f554d 100644 --- a/src/Algo/BrentLS.hpp +++ b/src/Algo/BrentLS.hpp @@ -129,8 +129,7 @@ BrentLineSearch< LS >::~BrentLineSearch( ) { // Code for the BrentBrent line search template< class LS > -typename BrentLineSearch< LS >::Param BrentLineSearch< LS >::search(Param &model0, Vect &direction, - Real tol, double delta) { +typename BrentLineSearch< LS >::Param BrentLineSearch< LS >::search(Param &model0, Vect &direction, Real tol, double delta) { this->iterNum = 0; KN< double > steps(3); // brackets Vect of_values(3); // OF evaluated inside bracket @@ -170,8 +169,7 @@ typename BrentLineSearch< LS >::Param BrentLineSearch< LS >::search(Param &model while (of_values[1] > of_values[2]) { r = (steps[1] - steps[0]) * (of_values[1] - of_values[2]); q = (steps[1] - steps[2]) * (of_values[1] - of_values[0]); - u = steps[1] - ((steps[1] - steps[2]) * q - (steps[1] - steps[0]) * r) / - (2. * Abs(Max(Abs(q - r), TINY)) / Sgn(q - r)); + u = steps[1] - ((steps[1] - steps[2]) * q - (steps[1] - steps[0]) * r) / (2. * Abs(Max(Abs(q - r), TINY)) / Sgn(q - r)); ulim = steps[1] + GLIMIT * (steps[2] - steps[1]); if ((steps[1] - u) * (u - steps[2]) > 0.) { @@ -283,8 +281,7 @@ typename BrentLineSearch< LS >::Param BrentLineSearch< LS >::search(Param &model q = Abs(q); etemp = e; e = d; - if (Abs(p) >= Abs(.5 * q * etemp) || p <= q * (steps[0] - x) || - p >= q * (steps[2] - x)) { // parabolic fit + if (Abs(p) >= Abs(.5 * q * etemp) || p <= q * (steps[0] - x) || p >= q * (steps[2] - x)) { // parabolic fit if (x >= xm) e = steps[0] - x; else diff --git a/src/Algo/CG.hpp b/src/Algo/CG.hpp index 254c219e0..b9d76425d 100644 --- a/src/Algo/CG.hpp +++ b/src/Algo/CG.hpp @@ -167,8 +167,7 @@ ConjugateGradient< LS >::Param ConjugateGradient< LS >::optimizer(Param& model0) err = (Real)sqrt((g1, g1)); if (isVerbose) cout << "Iteration (0) : " - << "current value of the objective function: " << ls->currentValue( ) - << "\t current residue: " << err << endl; + << "current value of the objective function: " << ls->currentValue( ) << "\t current residue: " << err << endl; appendResidue(err); // residual iterNum = 0; @@ -206,8 +205,7 @@ ConjugateGradient< LS >::Param ConjugateGradient< LS >::optimizer(Param& model0) err = (Real)sqrt((g1, g1)); if (isVerbose) cout << "Iteration (" << iterNum << ") : " - << "current value of the nrj : " << ls->currentValue( ) << "\t current residue : " << err - << endl; + << "current value of the nrj : " << ls->currentValue( ) << "\t current residue : " << err << endl; appendResidue(err); // residual } while (finalResidue( ) > tol && iterNum < iterMax); // stopping criterion diff --git a/src/Algo/CubicLS.hpp b/src/Algo/CubicLS.hpp index c51235f23..4921eb226 100644 --- a/src/Algo/CubicLS.hpp +++ b/src/Algo/CubicLS.hpp @@ -79,9 +79,7 @@ CubicLineSearch< LS >::~CubicLineSearch( ) {} // Code for the Cubic Line Search template< class LS > -typename CubicLineSearch< LS >::Param CubicLineSearch< LS >::search(const Param& current_solution, - Vect& p, Real slope, - double lambda) { +typename CubicLineSearch< LS >::Param CubicLineSearch< LS >::search(const Param& current_solution, Vect& p, Real slope, double lambda) { int tst = 0; // useful vars Real alpha = 0., alpha_prev = 0; diff --git a/src/Algo/LineSearch.hpp b/src/Algo/LineSearch.hpp index 9f478ebd6..2a75f0b12 100644 --- a/src/Algo/LineSearch.hpp +++ b/src/Algo/LineSearch.hpp @@ -150,10 +150,7 @@ typename LineSearch< P, V, M, VM, R >::Real LineSearch< P, V, M, VM, R >::curren } template< class P, class V, class M, class VM, class R > -typename LineSearch< P, V, M, VM, R >::Param LineSearch< P, V, M, VM, R >::search(const Param &m, - Vect &v, - Real alpha, - double beta) { +typename LineSearch< P, V, M, VM, R >::Param LineSearch< P, V, M, VM, R >::search(const Param &m, Vect &v, Real alpha, double beta) { cerr << "You need to specify the LineSearch method!" << endl; exit(1); } @@ -198,8 +195,7 @@ void LineSearch< P, V, M, VM, R >::numericalGradient(const Param &m) { } template< class P, class V, class M, class VM, class R > -typename LineSearch< P, V, M, VM, R >::Vect *LineSearch< P, V, M, VM, R >::gradient( - const Param &m) { +typename LineSearch< P, V, M, VM, R >::Vect *LineSearch< P, V, M, VM, R >::gradient(const Param &m) { Vect *g; g = nrj->getGradient(m); @@ -236,8 +232,7 @@ typename LineSearch< P, V, M, VM, R >::Real LineSearch< P, V, M, VM, R >::evalua // We moving forward from alpha*m, m is the start point in the direction dmod, of beta // We check we are in the bounds template< class P, class V, class M, class VM, class R > -typename LineSearch< P, V, M, VM, R >::Param LineSearch< P, V, M, VM, R >::update( - const Param &m, Real alpha, Real beta, const Vect &dmod) const { +typename LineSearch< P, V, M, VM, R >::Param LineSearch< P, V, M, VM, R >::update(const Param &m, Real alpha, Real beta, const Vect &dmod) const { Param newparam(m); long ndim = m.size( ); diff --git a/src/Algo/NewtonRaphson.hpp b/src/Algo/NewtonRaphson.hpp index b010abb38..cf73383f7 100644 --- a/src/Algo/NewtonRaphson.hpp +++ b/src/Algo/NewtonRaphson.hpp @@ -106,8 +106,7 @@ typename Newt< LS >::Param Newt< LS >::optimizer(Param& model0) { if (this->isVerbose) cerr << "Iteration (" << this->iterNum << ") : " - << "current value of the objective function: " << this->ls->currentValue( ) - << "\t current this->residue: " << err << endl; + << "current value of the objective function: " << this->ls->currentValue( ) << "\t current this->residue: " << err << endl; this->appendResidue(err); // residual diff --git a/src/Algo/Param.hpp b/src/Algo/Param.hpp index 604119f0c..908ec9ae4 100644 --- a/src/Algo/Param.hpp +++ b/src/Algo/Param.hpp @@ -31,8 +31,8 @@ using namespace std; #include "defs.hpp" -//#include "mvvtp.h" -//#include "mvblas.h" +// #include "mvvtp.h" +// #include "mvblas.h" // We nees a Vect type for update function template< class Real > @@ -87,8 +87,7 @@ Param< Real >::Param(int n) : KN< Real >(n) { } template< class Real > -Param< Real >::Param(const KN< Real >& maxp, const KN< Real >& minp, const KN< Real >& initmod) - : KN< Real >(initmod) { +Param< Real >::Param(const KN< Real >& maxp, const KN< Real >& minp, const KN< Real >& initmod) : KN< Real >(initmod) { int ndim = initmod.size( ); // cerr << "Param constructor 1" << endl; @@ -100,8 +99,7 @@ Param< Real >::Param(const KN< Real >& maxp, const KN< Real >& minp, const KN< R } template< class Real > -Param< Real >::Param(const KN< Real >& maxp, const KN< Real >& minp) - : KN< Real >(Min(minp.size( ), maxp.size( ))) { +Param< Real >::Param(const KN< Real >& maxp, const KN< Real >& minp) : KN< Real >(Min(minp.size( ), maxp.size( ))) { int ndim = Min(minp.size( ), maxp.size( )); // cerr << "Param constructor 2" << endl; diff --git a/src/Algo/RosenBrock.hpp b/src/Algo/RosenBrock.hpp index 2ad6f3647..f940ea9dd 100644 --- a/src/Algo/RosenBrock.hpp +++ b/src/Algo/RosenBrock.hpp @@ -3,8 +3,8 @@ #include "NRJ.hpp" #include "Param.hpp" -//#include "mvvtp.h" -//#include "mvblas.h" +// #include "mvvtp.h" +// #include "mvblas.h" template< class Real, class Mat > class RosenBrock : public tNRJ< Param< Real >, KN< Real >, Mat, Real > { @@ -21,8 +21,7 @@ class RosenBrock : public tNRJ< Param< Real >, KN< Real >, Mat, Real > { }; template< class Real, class Mat > -RosenBrock< Real, Mat >::RosenBrock(int n) - : tNRJ< Param< Real >, KN< Real >, Mat, Real >(n) { // On initialise le gradient +RosenBrock< Real, Mat >::RosenBrock(int n) : tNRJ< Param< Real >, KN< Real >, Mat, Real >(n) { // On initialise le gradient this->grad = new KN< Real >(n); // On initialise le hessien // Si on utlise pas le hessien, il suffit qu'il existe un constructeur diff --git a/src/Algo/lgalgo.cpp b/src/Algo/lgalgo.cpp index aac914ca4..daf8f8e5d 100644 --- a/src/Algo/lgalgo.cpp +++ b/src/Algo/lgalgo.cpp @@ -31,7 +31,7 @@ using namespace std; #include "BrentLS.hpp" #include "Optima.hpp" #include "BFGS.hpp" -//#include "CG.hpp" +// #include "CG.hpp" #include "NewtonRaphson.hpp" // template @@ -60,9 +60,7 @@ class OptimAlgo : public OneOperator { Expression X; C_F0 inittheparam, theparam, closetheparam; Expression J, dJ, hJ; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } R arg(int i, Stack stack, R a) const { return nargs[i] ? GetAny< R >((*nargs[i])(stack)) : a; } class lgNRJ : public tNRJ< PARAM, VECT, VMAT, REAL > { @@ -79,9 +77,7 @@ class OptimAlgo : public OneOperator { } public: - lgNRJ(Stack s, int n, Expression t, Expression JJ, Expression dJJ, Expression hJJ) - : tNRJ< PARAM, VECT, VMAT, REAL >(n), stack(s), J(JJ), dJ(dJJ), hJ(hJJ), theparame(t), - gg(0) { + lgNRJ(Stack s, int n, Expression t, Expression JJ, Expression dJJ, Expression hJJ) : tNRJ< PARAM, VECT, VMAT, REAL >(n), stack(s), J(JJ), dJ(dJJ), hJ(hJJ), theparame(t), gg(0) { if (dJ) gg = new VECT(n); } @@ -122,8 +118,7 @@ class OptimAlgo : public OneOperator { X = to< Kn * >(args[nbj]); C_F0 X_n(args[nbj], "n"); // the expression to init the theparam of all - inittheparam = - currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); + inittheparam = currentblock->NewVar< LocalVariable >("the parameter", atype< KN< R > * >( ), X_n); theparam = currentblock->Find("the parameter"); // the expression for the parameter args.SetNameParam(n_name_param, name_param, nargs); const Polymorphic *opJ = 0; @@ -144,9 +139,7 @@ class OptimAlgo : public OneOperator { J = dJ = hJ = 0; J = to< R >(C_F0(opJ, "(", theparam)); - if (opdJ) - dJ = to< Kn_ >(C_F0( - opdJ, "(", theparam)); // May2019 (bug?) Modif FH 17102005 (to verify) to ->to + if (opdJ) dJ = to< Kn_ >(C_F0(opdJ, "(", theparam)); // May2019 (bug?) Modif FH 17102005 (to verify) to ->to if (ophJ) hJ = to< Matrice_Creuse< R > * >(C_F0(ophJ, "(", theparam)); closetheparam = C_F0((Expression)Block::snewclose(currentblock), @@ -232,22 +225,14 @@ class OptimAlgo : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_LCG(args, cas); } - explicit OptimAlgo(int c) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} + explicit OptimAlgo(int c) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} - OptimAlgo(int c, int cc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< KN< R > * >( )), - cas(c) {} + OptimAlgo(int c, int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} - OptimAlgo(int c, int cc, int ccc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), - atype< Polymorphic * >( ), atype< KN< R > * >( )), - cas(c) {} + OptimAlgo(int c, int cc, int ccc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(c) {} }; -basicAC_F0::name_and_type OptimAlgo::E_LCG::name_param[] = { - {"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"nbiterline", &typeid(long)}}; +basicAC_F0::name_and_type OptimAlgo::E_LCG::name_param[] = {{"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"nbiterline", &typeid(long)}}; void init_algo( ); void init_algo( ) { @@ -260,5 +245,5 @@ void init_algo( ) { // End mesh3 debug } -//#include "InitFunct.hpp" -// static addingInitFunct TheaddingInitFunct(-9, init_algo); +// #include "InitFunct.hpp" +// static addingInitFunct TheaddingInitFunct(-9, init_algo); diff --git a/src/Eigen/arpackff.hpp b/src/Eigen/arpackff.hpp index 9b36ef9ab..d0dca76bd 100644 --- a/src/Eigen/arpackff.hpp +++ b/src/Eigen/arpackff.hpp @@ -34,7 +34,7 @@ typedef int integer; typedef int logical; -#define F77NAME(x) x ## _ +#define F77NAME(x) x##_ #define HIDDEN_HBW , int, int, int #define HIDDEN_BW , int, int @@ -42,173 +42,86 @@ typedef int logical; #define HIDDEN_112 , 1, 1, 2 extern "C" { - /* - // debug "common" statement. - - struct { - integer logfil, ndigit, mgetv0; - integer msaupd, msaup2, msaitr, mseigt, msapps, msgets, mseupd; - integer mnaupd, mnaup2, mnaitr, mneigt, mnapps, mngets, mneupd; - integer mcaupd, mcaup2, mcaitr, mceigt, mcapps, mcgets, mceupd; - } F77NAME(debug); - - // add FH for dynamic lib on win 32 - struct { - integer nopx, nbx, nrorth, nitref, nrstrt; - float tsaupd, tsaup2, tsaitr, tseigt, tsgets, tsapps, tsconv, - tnaupd, tnaup2, tnaitr, tneigh, tngets, tnapps, tnconv, - tcaupd, tcaup2, tcaitr, tceigh, tcgets, tcapps, tcconv, - tmvopx, tmvbx, tgetv0, titref, trvec; - } F77NAME(timing); - */ - - // double precision symmetric routines - void F77NAME(dsaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, double *tol, double *resid, - integer *ncv, double *V, integer *ldv, - integer *iparam, integer *ipntr, double *workd, - double *workl, integer *lworkl, integer *info HIDDEN_BW); - - void F77NAME(dseupd)( - logical *rvec, char *HowMny, logical *select, - double *d, double *Z, integer *ldz, - double *sigma, char *bmat, integer *n, - char *which, integer *nev, double *tol, - double *resid, integer *ncv, double *V, - integer *ldv, integer *iparam, integer *ipntr, - double *workd, double *workl, - integer *lworkl, integer *info HIDDEN_HBW); - - // double precision nonsymmetric routines - void F77NAME(dnaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, double *tol, double *resid, - integer *ncv, double *V, integer *ldv, - integer *iparam, integer *ipntr, double *workd, - double *workl, integer *lworkl, integer *info HIDDEN_BW); - - void F77NAME(dneupd)( - logical *rvec, char *HowMny, logical *select, - double *dr, double *di, double *Z, - integer *ldz, double *sigmar, - double *sigmai, double *workev, - char *bmat, integer *n, char *which, - integer *nev, double *tol, double *resid, - integer *ncv, double *V, integer *ldv, - integer *iparam, integer *ipntr, - double *workd, double *workl, - integer *lworkl, integer *info HIDDEN_HBW); - - // single precision symmetric routines - void F77NAME(ssaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, float *tol, float *resid, - integer *ncv, float *V, integer *ldv, - integer *iparam, integer *ipntr, float *workd, - float *workl, integer *lworkl, integer *info HIDDEN_BW); - - void F77NAME(sseupd)( - logical *rvec, char *HowMny, logical *select, - float *d, float *Z, integer *ldz, - float *sigma, char *bmat, integer *n, - char *which, integer *nev, float *tol, - float *resid, integer *ncv, float *V, - integer *ldv, integer *iparam, integer *ipntr, - float *workd, float *workl, - integer *lworkl, integer *info HIDDEN_HBW); - - // single precision nonsymmetric routines - void F77NAME(snaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, float *tol, float *resid, - integer *ncv, float *V, integer *ldv, - integer *iparam, integer *ipntr, float *workd, - float *workl, integer *lworkl, integer *info HIDDEN_BW); - - void F77NAME(sneupd)( - logical *rvec, char *HowMny, logical *select, - float *dr, float *di, float *Z, - integer *ldz, float *sigmar, - float *sigmai, float *workev, char *bmat, - integer *n, char *which, integer *nev, - float *tol, float *resid, integer *ncv, - float *V, integer *ldv, integer *iparam, - integer *ipntr, float *workd, float *workl, - integer *lworkl, integer *info HIDDEN_HBW); - - - void F77NAME(cnaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, float *tol, complex *resid, - integer *ncv, complex *V, integer *ldv, - integer *iparam, integer *ipntr, complex *workd, - complex *workl, integer *lworkl, - float *rwork, integer *info HIDDEN_BW); - - void F77NAME(cneupd)( - logical *rvec, char *HowMny, logical *select, - complex *d, complex *Z, integer *ldz, - complex *sigma, complex *workev, - char *bmat, integer *n, char *which, integer *nev, - float *tol, complex *resid, integer *ncv, - complex *V, integer *ldv, integer *iparam, - integer *ipntr, complex *workd, - complex *workl, integer *lworkl, - float *rwork, integer *info HIDDEN_HBW); - - // double precision complex routines - void F77NAME(znaupd)( - integer *ido, char *bmat, integer *n, char *which, - integer *nev, double *tol, complex *resid, - integer *ncv, complex *V, integer *ldv, - integer *iparam, integer *ipntr, complex *workd, - complex *workl, integer *lworkl, - double *rwork, integer *info HIDDEN_BW); - - void F77NAME(zneupd)( - logical *rvec, char *HowMny, logical *select, - complex *d, complex *Z, integer *ldz, - complex *sigma, complex *workev, - char *bmat, integer *n, char *which, integer *nev, - double *tol, complex *resid, integer *ncv, - complex *V, integer *ldv, integer *iparam, - integer *ipntr, complex *workd, - complex *workl, integer *lworkl, - double *rwork, integer *info HIDDEN_HBW); +/* +// debug "common" statement. + +struct { + integer logfil, ndigit, mgetv0; + integer msaupd, msaup2, msaitr, mseigt, msapps, msgets, mseupd; + integer mnaupd, mnaup2, mnaitr, mneigt, mnapps, mngets, mneupd; + integer mcaupd, mcaup2, mcaitr, mceigt, mcapps, mcgets, mceupd; +} F77NAME(debug); + +// add FH for dynamic lib on win 32 +struct { + integer nopx, nbx, nrorth, nitref, nrstrt; + float tsaupd, tsaup2, tsaitr, tseigt, tsgets, tsapps, tsconv, + tnaupd, tnaup2, tnaitr, tneigh, tngets, tnapps, tnconv, + tcaupd, tcaup2, tcaitr, tceigh, tcgets, tcapps, tcconv, + tmvopx, tmvbx, tgetv0, titref, trvec; +} F77NAME(timing); +*/ + +// double precision symmetric routines +void F77NAME(dsaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, double *tol, double *resid, integer *ncv, double *V, integer *ldv, integer *iparam, integer *ipntr, double *workd, + double *workl, integer *lworkl, integer *info HIDDEN_BW); + +void F77NAME(dseupd)(logical *rvec, char *HowMny, logical *select, double *d, double *Z, integer *ldz, double *sigma, char *bmat, integer *n, char *which, integer *nev, double *tol, double *resid, + integer *ncv, double *V, integer *ldv, integer *iparam, integer *ipntr, double *workd, double *workl, integer *lworkl, integer *info HIDDEN_HBW); + +// double precision nonsymmetric routines +void F77NAME(dnaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, double *tol, double *resid, integer *ncv, double *V, integer *ldv, integer *iparam, integer *ipntr, double *workd, + double *workl, integer *lworkl, integer *info HIDDEN_BW); + +void F77NAME(dneupd)(logical *rvec, char *HowMny, logical *select, double *dr, double *di, double *Z, integer *ldz, double *sigmar, double *sigmai, double *workev, char *bmat, integer *n, char *which, + integer *nev, double *tol, double *resid, integer *ncv, double *V, integer *ldv, integer *iparam, integer *ipntr, double *workd, double *workl, integer *lworkl, + integer *info HIDDEN_HBW); + +// single precision symmetric routines +void F77NAME(ssaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, float *tol, float *resid, integer *ncv, float *V, integer *ldv, integer *iparam, integer *ipntr, float *workd, + float *workl, integer *lworkl, integer *info HIDDEN_BW); + +void F77NAME(sseupd)(logical *rvec, char *HowMny, logical *select, float *d, float *Z, integer *ldz, float *sigma, char *bmat, integer *n, char *which, integer *nev, float *tol, float *resid, + integer *ncv, float *V, integer *ldv, integer *iparam, integer *ipntr, float *workd, float *workl, integer *lworkl, integer *info HIDDEN_HBW); + +// single precision nonsymmetric routines +void F77NAME(snaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, float *tol, float *resid, integer *ncv, float *V, integer *ldv, integer *iparam, integer *ipntr, float *workd, + float *workl, integer *lworkl, integer *info HIDDEN_BW); + +void F77NAME(sneupd)(logical *rvec, char *HowMny, logical *select, float *dr, float *di, float *Z, integer *ldz, float *sigmar, float *sigmai, float *workev, char *bmat, integer *n, char *which, + integer *nev, float *tol, float *resid, integer *ncv, float *V, integer *ldv, integer *iparam, integer *ipntr, float *workd, float *workl, integer *lworkl, + integer *info HIDDEN_HBW); + +void F77NAME(cnaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, float *tol, complex< float > *resid, integer *ncv, complex< float > *V, integer *ldv, integer *iparam, + integer *ipntr, complex< float > *workd, complex< float > *workl, integer *lworkl, float *rwork, integer *info HIDDEN_BW); + +void F77NAME(cneupd)(logical *rvec, char *HowMny, logical *select, complex< float > *d, complex< float > *Z, integer *ldz, complex< float > *sigma, complex< float > *workev, char *bmat, integer *n, + char *which, integer *nev, float *tol, complex< float > *resid, integer *ncv, complex< float > *V, integer *ldv, integer *iparam, integer *ipntr, complex< float > *workd, + complex< float > *workl, integer *lworkl, float *rwork, integer *info HIDDEN_HBW); + +// double precision complex routines +void F77NAME(znaupd)(integer *ido, char *bmat, integer *n, char *which, integer *nev, double *tol, complex< double > *resid, integer *ncv, complex< double > *V, integer *ldv, integer *iparam, + integer *ipntr, complex< double > *workd, complex< double > *workl, integer *lworkl, double *rwork, integer *info HIDDEN_BW); + +void F77NAME(zneupd)(logical *rvec, char *HowMny, logical *select, complex< double > *d, complex< double > *Z, integer *ldz, complex< double > *sigma, complex< double > *workev, char *bmat, + integer *n, char *which, integer *nev, double *tol, complex< double > *resid, integer *ncv, complex< double > *V, integer *ldv, integer *iparam, integer *ipntr, + complex< double > *workd, complex< double > *workl, integer *lworkl, double *rwork, integer *info HIDDEN_HBW); } -inline void saupp ( - int& ido, char bmat, int n, char* which, int nev, - double& tol, double resid[], int ncv, double V[], - int ldv, int iparam[], int ipntr[], double workd[], - double workl[], int lworkl, int& info) { - - F77NAME(dsaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], - &lworkl, &info HIDDEN_12); -} // saupp (double) - -inline void saupp ( - int& ido, char bmat, int n, char* which, int nev, - float& tol, float resid[], int ncv, float V[], - int ldv, int iparam[], int ipntr[], float workd[], - float workl[], int lworkl, int& info) { - - F77NAME(ssaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], - &lworkl, &info HIDDEN_12); -} // saupp (float) - -inline void seupp ( - bool rvec, char HowMny, double d[], double Z[], - int ldz, double sigma, char bmat, int n, - char* which, int nev, double tol, double resid[], - int ncv, double V[], int ldv, int iparam[], - int ipntr[], double workd[], double workl[], - int lworkl, int& info) { +inline void saupp(int &ido, char bmat, int n, char *which, int nev, double &tol, double resid[], int ncv, double V[], int ldv, int iparam[], int ipntr[], double workd[], double workl[], int lworkl, + int &info) { + + F77NAME(dsaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_12); +} // saupp (double) + +inline void saupp(int &ido, char bmat, int n, char *which, int nev, float &tol, float resid[], int ncv, float V[], int ldv, int iparam[], int ipntr[], float workd[], float workl[], int lworkl, + int &info) { + + F77NAME(ssaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_12); +} // saupp (float) + +inline void seupp(bool rvec, char HowMny, double d[], double Z[], int ldz, double sigma, char bmat, int n, char *which, int nev, double tol, double resid[], int ncv, double V[], int ldv, int iparam[], + int ipntr[], double workd[], double workl[], int lworkl, int &info) { int irvec; logical *iselect; @@ -218,21 +131,13 @@ inline void seupp ( iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(dseupd)( - &irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &bmat, - &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], - &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_112); + F77NAME(dseupd)(&irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_112); delete[] iselect; -} // seupp (double) +} // seupp (double) -inline void seupp ( - bool rvec, char HowMny, float d[], float Z[], - int ldz, float sigma, char bmat, int n, - char* which, int nev, float tol, float resid[], - int ncv, float V[], int ldv, int iparam[], - int ipntr[], float workd[], float workl[], - int lworkl, int& info) { +inline void seupp(bool rvec, char HowMny, float d[], float Z[], int ldz, float sigma, char bmat, int n, char *which, int nev, float tol, float resid[], int ncv, float V[], int ldv, int iparam[], + int ipntr[], float workd[], float workl[], int lworkl, int &info) { int irvec; logical *iselect; @@ -242,125 +147,74 @@ inline void seupp ( iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(sseupd)( - &irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &bmat, - &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], - &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_112); + F77NAME(sseupd)(&irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_112); delete[] iselect; -} // seupp (float) - -inline void naupp ( - int& ido, char bmat, int n, char* which, int nev, - double& tol, double resid[], int ncv, double V[], - int ldv, int iparam[], int ipntr[], double workd[], - double workl[], int lworkl, int& info) { - - F77NAME(dnaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], - &lworkl, &info HIDDEN_12); -} // naupp (double). - -inline void naupp ( - int& ido, char bmat, int n, char* which, int nev, - float& tol, float resid[], int ncv, float V[], - int ldv, int iparam[], int ipntr[], float workd[], - float workl[], int lworkl, int& info) { - - F77NAME(snaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], - &lworkl, &info HIDDEN_12); - -} // naupp (float) - -inline void caupp ( - int& ido, char bmat, int n, char* which, int nev, - double& tol, complex resid[], int ncv, - complex V[], int ldv, int iparam[], int ipntr[], - complex workd[], complex workl[], - int lworkl, double rwork[], int& info) { - - F77NAME(znaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], - &workl[1], &lworkl, &rwork[1], &info HIDDEN_12); -} // caupp - -inline void caupp ( - int& ido, char bmat, int n, char* which, int nev, - float& tol, complex resid[], int ncv, - complex V[], int ldv, int iparam[], int ipntr[], - complex workd[], complex workl[], - int lworkl, float rwork[], int& info) { - - F77NAME(cnaupd)( - &ido, &bmat, &n, which, &nev, &tol, resid, &ncv, - &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], - &workl[1], &lworkl, &rwork[1], &info HIDDEN_12); -} // caupp - -inline void ceupp ( - bool rvec, char HowMny, complex d[], - complex Z[], int ldz, complex sigma, - complex workev[], char bmat, int n, char* which, - int nev, double tol, complex resid[], int ncv, - complex V[], int ldv, int iparam[], int ipntr[], - complex workd[], complex workl[], - int lworkl, double rwork[], int& info) { +} // seupp (float) + +inline void naupp(int &ido, char bmat, int n, char *which, int nev, double &tol, double resid[], int ncv, double V[], int ldv, int iparam[], int ipntr[], double workd[], double workl[], int lworkl, + int &info) { + + F77NAME(dnaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_12); +} // naupp (double). + +inline void naupp(int &ido, char bmat, int n, char *which, int nev, float &tol, float resid[], int ncv, float V[], int ldv, int iparam[], int ipntr[], float workd[], float workl[], int lworkl, + int &info) { + + F77NAME(snaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info HIDDEN_12); + +} // naupp (float) + +inline void caupp(int &ido, char bmat, int n, char *which, int nev, double &tol, complex< double > resid[], int ncv, complex< double > V[], int ldv, int iparam[], int ipntr[], + complex< double > workd[], complex< double > workl[], int lworkl, double rwork[], int &info) { + + F77NAME(znaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &rwork[1], &info HIDDEN_12); +} // caupp + +inline void caupp(int &ido, char bmat, int n, char *which, int nev, float &tol, complex< float > resid[], int ncv, complex< float > V[], int ldv, int iparam[], int ipntr[], complex< float > workd[], + complex< float > workl[], int lworkl, float rwork[], int &info) { + + F77NAME(cnaupd)(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &rwork[1], &info HIDDEN_12); +} // caupp + +inline void ceupp(bool rvec, char HowMny, complex< double > d[], complex< double > Z[], int ldz, complex< double > sigma, complex< double > workev[], char bmat, int n, char *which, int nev, + double tol, complex< double > resid[], int ncv, complex< double > V[], int ldv, int iparam[], int ipntr[], complex< double > workd[], complex< double > workl[], int lworkl, + double rwork[], int &info) { int irvec; - logical * iselect; - complex *iZ; + logical *iselect; + complex< double > *iZ; irvec = (int)rvec; iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(zneupd)( - &irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, - &workev[0], &bmat, &n, which, &nev, &tol, resid, - &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], - &workd[1], &workl[1], &lworkl, &rwork[1], &info HIDDEN_112); + F77NAME(zneupd)(&irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &workev[0], &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &rwork[1], + &info HIDDEN_112); delete[] iselect; -} // ceupp (complex) +} // ceupp (complex) -inline void ceupp ( - bool rvec, char HowMny, complex d[], - complex Z[], int ldz, complex sigma, - complex workev[], char bmat, int n, char* which, - int nev, float tol, complex resid[], int ncv, - complex V[], int ldv, int iparam[], int ipntr[], - complex workd[], complex workl[], - int lworkl, float rwork[], int& info) { +inline void ceupp(bool rvec, char HowMny, complex< float > d[], complex< float > Z[], int ldz, complex< float > sigma, complex< float > workev[], char bmat, int n, char *which, int nev, float tol, + complex< float > resid[], int ncv, complex< float > V[], int ldv, int iparam[], int ipntr[], complex< float > workd[], complex< float > workl[], int lworkl, float rwork[], + int &info) { int irvec; - logical * iselect; - complex *iZ; + logical *iselect; + complex< float > *iZ; irvec = (int)rvec; iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(cneupd)( - &irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, - &workev[0], &bmat, &n, which, &nev, &tol, resid, - &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], - &workd[1], &workl[1], &lworkl, &rwork[1], &info HIDDEN_112); + F77NAME(cneupd)(&irvec, &HowMny, iselect, d, iZ, &ldz, &sigma, &workev[0], &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &rwork[1], + &info HIDDEN_112); delete[] iselect; -} // ceupp (complex) +} // ceupp (complex) -inline void neupp ( - bool rvec, char HowMny, double dr[], - double di[], double Z[], int ldz, double sigmar, - double sigmai, double workv[], char bmat, int n, - char* which, int nev, double tol, double resid[], - int ncv, double V[], int ldv, int iparam[], - int ipntr[], double workd[], double workl[], - int lworkl, int& info) { +inline void neupp(bool rvec, char HowMny, double dr[], double di[], double Z[], int ldz, double sigmar, double sigmai, double workv[], char bmat, int n, char *which, int nev, double tol, + double resid[], int ncv, double V[], int ldv, int iparam[], int ipntr[], double workd[], double workl[], int lworkl, int &info) { int irvec; logical *iselect; @@ -370,23 +224,14 @@ inline void neupp ( iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(dneupd)( - &irvec, &HowMny, iselect, dr, di, iZ, &ldz, &sigmar, - &sigmai, &workv[1], &bmat, &n, which, &nev, &tol, - resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], - &workd[1], &workl[1], &lworkl, &info HIDDEN_112); + F77NAME(dneupd)(&irvec, &HowMny, iselect, dr, di, iZ, &ldz, &sigmar, &sigmai, &workv[1], &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, + &info HIDDEN_112); delete[] iselect; -} // neupp (double) +} // neupp (double) -inline void neupp ( - bool rvec, char HowMny, float dr[], - float di[], float Z[], int ldz, float sigmar, - float sigmai, float workv[], char bmat, int n, - char* which, int nev, float tol, float resid[], - int ncv, float V[], int ldv, int iparam[], - int ipntr[], float workd[], float workl[], - int lworkl, int& info) { +inline void neupp(bool rvec, char HowMny, float dr[], float di[], float Z[], int ldz, float sigmar, float sigmai, float workv[], char bmat, int n, char *which, int nev, float tol, float resid[], + int ncv, float V[], int ldv, int iparam[], int ipntr[], float workd[], float workl[], int lworkl, int &info) { int irvec; logical *iselect; @@ -396,18 +241,14 @@ inline void neupp ( iselect = new logical[ncv]; iZ = (Z == NULL) ? &V[0] : Z; - F77NAME(sneupd)( - &irvec, &HowMny, iselect, dr, di, iZ, &ldz, &sigmar, - &sigmai, &workv[1], &bmat, &n, which, &nev, &tol, - resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], - &workd[1], &workl[1], &lworkl, &info HIDDEN_112); + F77NAME(sneupd)(&irvec, &HowMny, iselect, dr, di, iZ, &ldz, &sigmar, &sigmai, &workv[1], &bmat, &n, which, &nev, &tol, resid, &ncv, &V[0], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, + &info HIDDEN_112); delete[] iselect; -} // neupp (float) +} // neupp (float) -inline void sauppError (int info) { - if (info < 0) - cerr << " Arpack error sauppError" << info << endl; +inline void sauppError(int info) { + if (info < 0) cerr << " Arpack error sauppError" << info << endl; switch (info) { case 0: return; @@ -426,22 +267,21 @@ inline void sauppError (int info) { } } -inline void seuppError (int info) { - if (info < 0) - cerr << " Arpack error seuppError" << info << endl; +inline void seuppError(int info) { + if (info < 0) cerr << " Arpack error seuppError" << info << endl; switch (info) { case 0: return; case -8: case -9: - throw ErrorExec("lapack LAPACK_ERROR [sd]eupp ",info); + throw ErrorExec("lapack LAPACK_ERROR [sd]eupp ", info); case -14: - throw ErrorExec("lapack NOT_ACCURATE_EIG [sd]eupp ",info); + throw ErrorExec("lapack NOT_ACCURATE_EIG [sd]eupp ", info); case 1: - throw ErrorExec("lapack REORDERING_ERROR [sd]eupp ",info); + throw ErrorExec("lapack REORDERING_ERROR [sd]eupp ", info); default: - throw ErrorExec("lapack error [sd]eupp ",info); + throw ErrorExec("lapack error [sd]eupp ", info); } -} // EuppError +} // EuppError -#endif // ARPACKFF_HPP +#endif // ARPACKFF_HPP diff --git a/src/Eigen/eigenvalue.cpp b/src/Eigen/eigenvalue.cpp index 34ef59e02..59567be5a 100644 --- a/src/Eigen/eigenvalue.cpp +++ b/src/Eigen/eigenvalue.cpp @@ -27,7 +27,7 @@ #include using namespace std; -//#include "ff++.hpp" +// #include "ff++.hpp" #include "error.hpp" #include "arpackff.hpp" @@ -45,23 +45,23 @@ using namespace std; #include "lgmesh3.hpp" #include "lgsolver.hpp" #include "problem.hpp" -//#include "ffstack.hpp" +// #include "ffstack.hpp" extern Block *currentblock; typedef double R; static bool dddd = false; -template -void Show(int ido, KN_ w, const char *cmm) { - cout << cmm << ido << " max = " << w.max() << " - min = " << w.min() << " - sum = " << w.sum() << endl; +template< class K > +void Show(int ido, KN_< K > w, const char *cmm) { + cout << cmm << ido << " max = " << w.max( ) << " - min = " << w.min( ) << " - sum = " << w.sum( ) << endl; } -template -class FuncMat : public RNM_VirtualMatrix { -public: +template< class R > +class FuncMat : public RNM_VirtualMatrix< R > { + public: // typedef double K; - typedef KN Kn; - typedef KN_ Kn_; + typedef KN< R > Kn; + typedef KN_< R > Kn_; Stack stack; @@ -69,118 +69,130 @@ class FuncMat : public RNM_VirtualMatrix { C_F0 c_x; Kn *b; Expression mat1, mat; - typedef typename RNM_VirtualMatrix::plusAx plusAx; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; - FuncMat (int n, Stack stk, const OneOperator *op, const OneOperator *op1, Kn *bb=0) - : RNM_VirtualMatrix(n), - stack(stk), - x(n), c_x(CPValue(x)), b(bb), - mat1(op1 ? CastTo(C_F0(op1->code(basicAC_F0_wa(c_x)), (aType)*op1)) : 0), - mat(op ? CastTo(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) - {} + FuncMat(int n, Stack stk, const OneOperator *op, const OneOperator *op1, Kn *bb = 0) + : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), b(bb), mat1(op1 ? CastTo< Kn_ >(C_F0(op1->code(basicAC_F0_wa(c_x)), (aType)*op1)) : 0), + mat(op ? CastTo< Kn_ >(C_F0(op->code(basicAC_F0_wa(c_x)), (aType)*op)) : 0) {} - FuncMat () { if (mat1 != mat) delete mat; delete mat1; delete c_x.LeftValue(); } + FuncMat( ) { + if (mat1 != mat) delete mat; + delete mat1; + delete c_x.LeftValue( ); + } - void addMatMul (const Kn_ &xx, Kn_ &Ax) const { + void addMatMul(const Kn_ &xx, Kn_ &Ax) const { // cout << " addMatMul " << xx.N() << " " << Ax.N() << " " << cas << endl; - ffassert(xx.N() == Ax.N() && mat); - x =xx; - Ax += GetAny((*mat)(stack)); - if (b && &Ax != b) Ax += *b; // Ax - b => add b (not in cas of init. b c.a.d &Ax == b) - WhereStackOfPtr2Free(stack)->clean(); // add dec 2008 + ffassert(xx.N( ) == Ax.N( ) && mat); + x = xx; + Ax += GetAny< Kn_ >((*mat)(stack)); + if (b && &Ax != b) Ax += *b; // Ax - b => add b (not in cas of init. b c.a.d &Ax == b) + WhereStackOfPtr2Free(stack)->clean( ); // add dec 2008 } - void Solve (KN_ &Ax, const KN_ & xx) const { - ffassert(xx.N() == Ax.N() && mat1); + void Solve(KN_< R > &Ax, const KN_< R > &xx) const { + ffassert(xx.N( ) == Ax.N( ) && mat1); x = xx; - Ax = GetAny((*mat1)(stack)); - if (b && &Ax != b) Ax += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b) - WhereStackOfPtr2Free(stack)->clean(); // add dec 2008 + Ax = GetAny< Kn_ >((*mat1)(stack)); + if (b && &Ax != b) Ax += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b) + WhereStackOfPtr2Free(stack)->clean( ); // add dec 2008 } - plusAx operator * (const Kn &x) const { return plusAx(this,x); } - virtual bool ChecknbLine (int n) const { return true; } - virtual bool ChecknbColumn (int m) const { return true; } - bool WithSolver () const { return mat1; } + plusAx operator*(const Kn &x) const { return plusAx(this, x); } + virtual bool ChecknbLine(int n) const { return true; } + virtual bool ChecknbColumn(int m) const { return true; } + bool WithSolver( ) const { return mat1; } }; -void ToWhich (Stack stack, char *which, Expression ew) { - if (!ew) strcpy(which, "LM"); +void ToWhich(Stack stack, char *which, Expression ew) { + if (!ew) + strcpy(which, "LM"); else { - string *sw = GetAny((*ew)(stack)); - if (sw && sw->length() == 2) - strcpy(which, sw->c_str()); + string *sw = GetAny< string * >((*ew)(stack)); + if (sw && sw->length( ) == 2) strcpy(which, sw->c_str( )); int ok = 0; - if (strcmp(which, "LM") == 0) ok = 1; - else if (strcmp(which, "LA") == 0) ok = 1; - else if (strcmp(which, "SM") == 0) ok = 1; - else if (strcmp(which, "SA") == 0) ok = 1; - else if (strcmp(which, "SR") == 0) ok = 1; - else if (strcmp(which, "LR") == 0) ok = 1; - else if (strcmp(which, "BE") == 0) ok = 1; + if (strcmp(which, "LM") == 0) + ok = 1; + else if (strcmp(which, "LA") == 0) + ok = 1; + else if (strcmp(which, "SM") == 0) + ok = 1; + else if (strcmp(which, "SA") == 0) + ok = 1; + else if (strcmp(which, "SR") == 0) + ok = 1; + else if (strcmp(which, "LR") == 0) + ok = 1; + else if (strcmp(which, "BE") == 0) + ok = 1; ffassert(ok); } } -void CheckMode (int mode, bool A, bool A1, bool B, bool B1) { - if (mode == 1) { ffassert(A); } - if (mode == 2) { ffassert(A && B && B1 ); } - if (mode == 3) { ffassert(A1 && B); } +void CheckMode(int mode, bool A, bool A1, bool B, bool B1) { + if (mode == 1) { + ffassert(A); + } + if (mode == 2) { + ffassert(A && B && B1); + } + if (mode == 3) { + ffassert(A1 && B); + } } -template -void DoIdoAction (int ido, char bmat, int mode, KN_ &xx, KN_ &yy, KN_ &zz, KN_ &work, Mat &OP1, Mat &B) { - if ((mode == 3) && (bmat == 'G')) // shift-invert mode, generalized problem +template< class K, class Mat > +void DoIdoAction(int ido, char bmat, int mode, KN_< K > &xx, KN_< K > &yy, KN_< K > &zz, KN_< K > &work, Mat &OP1, Mat &B) { + if ((mode == 3) && (bmat == 'G')) // shift-invert mode, generalized problem switch (ido) { - case -1: //y <--- OP*x = inv[A-SIGMA*M]*M*x - if(dddd) Show(ido, xx, " <- (xx) "); - OP1.Solve(yy, work=B*xx); - if(dddd) Show(ido, yy, " -> (yy) "); + case -1: // y <--- OP*x = inv[A-SIGMA*M]*M*x + if (dddd) Show(ido, xx, " <- (xx) "); + OP1.Solve(yy, work = B * xx); + if (dddd) Show(ido, yy, " -> (yy) "); break; - case 1:// y <-- OP*x = inv[A-sigma*M]*z - if(dddd) Show(ido, zz, " <- (zz) "); + case 1: // y <-- OP*x = inv[A-sigma*M]*z + if (dddd) Show(ido, zz, " <- (zz) "); OP1.Solve(yy, zz); - if(dddd) Show(ido, yy, " -> (yy) "); + if (dddd) Show(ido, yy, " -> (yy) "); break; - case 2: // y <--- M*x - if(dddd) Show(ido, xx, " <- (xx) "); - yy = B*xx; - if(dddd) Show(ido, yy, " -> (yy) "); + case 2: // y <--- M*x + if (dddd) Show(ido, xx, " <- (xx) "); + yy = B * xx; + if (dddd) Show(ido, yy, " -> (yy) "); break; default: ffassert(0); } - else if ((mode == 2) && (bmat == 'G')) { // shift-invert mode, generalized problem + else if ((mode == 2) && (bmat == 'G')) { // shift-invert mode, generalized problem switch (ido) { - case -1: // y <--- OP*x = inv[M]*A*x + case -1: // y <--- OP*x = inv[M]*A*x case 1: - if (mode == 1) // M = Id //TODO there is a non-sens here: mode == 2 && mode == 1 - yy = OP1*xx; + if (mode == 1) // M = Id //TODO there is a non-sens here: mode == 2 && mode == 1 + yy = OP1 * xx; else - B.Solve(yy, work=OP1*xx); + B.Solve(yy, work = OP1 * xx); break; - case 2: // y <--- M*x. // not use mode = 1 - yy = B*xx; + case 2: // y <--- M*x. // not use mode = 1 + yy = B * xx; break; - default : + default: ffassert(0); } - } - else if ((mode == 1) && (bmat == 'I')) // direct mode, simple problem + } else if ((mode == 1) && (bmat == 'I')) // direct mode, simple problem switch (ido) { case 1: - B.Solve(yy, work=OP1*xx); + B.Solve(yy, work = OP1 * xx); break; - default : + default: ffassert(0); } - else if ((mode == 3) && (bmat == 'I')) // shift-invert mode, simple problem + else if ((mode == 3) && (bmat == 'I')) // shift-invert mode, simple problem switch (ido) { case -1: case 1: - OP1.Solve(yy, work=B*xx); + OP1.Solve(yy, work = B * xx); break; - default : + default: ffassert(0); } } @@ -225,31 +237,30 @@ void DoIdoAction (int ido, char bmat, int mode, KN_ &xx, KN_ &yy, KN_ & } }*/ -template +template< class K > const OneOperator *ToCode(Expression e) { const OneOperator *code = 0; if (e != 0) { - const Polymorphic *op = dynamic_cast(e); + const Polymorphic *op = dynamic_cast< const Polymorphic * >(e); ffassert(op); - code = op->Find("(", ArrayOfaType(atype* >(), false)); - if(code == 0) - { - cerr << " Erreur we are in Eigen "<< typeid(K).name() << " "<< endl; - cout << " bad type of function : Maybe we need to use complexEigenValue or EigenValue" << endl; - ffassert(code); - } + code = op->Find("(", ArrayOfaType(atype< KN< K > * >( ), false)); + if (code == 0) { + cerr << " Erreur we are in Eigen " << typeid(K).name( ) << " " << endl; + cout << " bad type of function : Maybe we need to use complexEigenValue or EigenValue" << endl; + ffassert(code); + } } return code; } class EigenValue : public OneOperator { -public: + public: typedef R K; - typedef KN Kn; - typedef KN_ Kn_; + typedef KN< K > Kn; + typedef KN_< K > Kn_; const int cas; class E_EV : public E_F0mps { - public: + public: const int cas; static basicAC_F0::name_and_type name_param[]; @@ -257,76 +268,66 @@ class EigenValue : public OneOperator { Expression nargs[n_name_param]; Expression expOP1, expB, expn; const OneOperator *codeOP1, *codeB, *codeOP, *codeB1; - template - T arg (int i, Stack stack, const T &a) const { return nargs[i] ? GetAny((*nargs[i])(stack)) : a; } - E_EV (const basicAC_F0 &args, int cc) : - cas(cc), expOP1(0), expB(0), expn(0), codeOP1(0), codeB(0), codeOP(0), codeB1(0) { + template< class T > + T arg(int i, Stack stack, const T &a) const { + return nargs[i] ? GetAny< T >((*nargs[i])(stack)) : a; + } + E_EV(const basicAC_F0 &args, int cc) : cas(cc), expOP1(0), expB(0), expn(0), codeOP1(0), codeB(0), codeOP(0), codeB1(0) { // OP1 = (A-sigma*B) // int nbj= args.size()-1; args.SetNameParam(n_name_param, name_param, nargs); if (cas == 1 || cas == 2) { - expn = to< long>(args[0]); - const Polymorphic *op = dynamic_cast(args[1].LeftValue()); + expn = to< long >(args[0]); + const Polymorphic *op = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); ffassert(op); - codeOP1 = op->Find("(", ArrayOfaType(atype(), false)); + codeOP1 = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); ffassert(codeOP1); if (cas == 2) { - const Polymorphic *op = dynamic_cast(args[2].LeftValue()); + const Polymorphic *op = dynamic_cast< const Polymorphic * >(args[2].LeftValue( )); ffassert(op); - codeB = op->Find("(", ArrayOfaType(atype(), false)); + codeB = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); ffassert(codeB); } } else if (cas == 3) { - expn = to< long>(args[0]); + expn = to< long >(args[0]); } else { - expOP1 = to *>(args[0]); - expB = to *>(args[1]); + expOP1 = to< Matrice_Creuse< K > * >(args[0]); + expB = to< Matrice_Creuse< K > * >(args[1]); } - ffassert((codeOP1 == 0) || (nargs[15] == 0)); // Double def - ffassert((codeB == 0) || (nargs[14] == 0)); // Double def - codeOP = ToCode(nargs[13]); - if (!codeB) codeB = ToCode(nargs[14]); - if (!codeOP1) codeOP1 = ToCode(nargs[15]); - codeB1 = ToCode(nargs[16]); + ffassert((codeOP1 == 0) || (nargs[15] == 0)); // Double def + ffassert((codeB == 0) || (nargs[14] == 0)); // Double def + codeOP = ToCode< double >(nargs[13]); + if (!codeB) codeB = ToCode< double >(nargs[14]); + if (!codeOP1) codeOP1 = ToCode< double >(nargs[15]); + codeB1 = ToCode< double >(nargs[16]); } - AnyType operator () (Stack stack) const; - operator aType () const { return atype(); } + AnyType operator( )(Stack stack) const; + operator aType( ) const { return atype< long >( ); } }; - E_F0 * code (const basicAC_F0 & args) const { return new E_EV(args,cas); } + E_F0 *code(const basicAC_F0 &args) const { return new E_EV(args, cas); } - EigenValue () : - OneOperator(atype(), - atype *>(), - atype *>()), - cas(0) {} + EigenValue( ) : OneOperator(atype< long >( ), atype< Matrice_Creuse< K > * >( ), atype< Matrice_Creuse< K > * >( )), cas(0) {} - EigenValue (int, int) : - OneOperator(atype(), atype(), - atype(), - atype()), - cas(2) {} + EigenValue(int, int) : OneOperator(atype< long >( ), atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( )), cas(2) {} - EigenValue (int) : - OneOperator(atype(), atype(), - atype()), - cas(1) {} + EigenValue(int) : OneOperator(atype< long >( ), atype< long >( ), atype< Polymorphic * >( )), cas(1) {} - EigenValue(int, int, int) : // All data are given through A=, B= A1=, B1= - OneOperator(atype(), atype()), - cas(3) {} + EigenValue(int, int, int) + : // All data are given through A=, B= A1=, B1= + OneOperator(atype< long >( ), atype< long >( )), cas(3) {} }; class EigenValueC : public OneOperator { -public: + public: typedef Complex K; typedef double R; - typedef KN Kn; - typedef KN_ Kn_; + typedef KN< K > Kn; + typedef KN_< K > Kn_; const int cas; class E_EV : public E_F0mps { - public: + public: const int cas; static basicAC_F0::name_and_type name_param[]; @@ -334,237 +335,208 @@ class EigenValueC : public OneOperator { Expression nargs[n_name_param]; Expression expOP1, expB, expn; const OneOperator *codeOP1, *codeB, *codeOP, *codeB1; - template - T arg (int i, Stack stack, const T &a) const { return nargs[i] ? GetAny((*nargs[i])(stack)) : a; } - E_EV (const basicAC_F0 &args, int cc) : - cas(cc), expOP1(0), expB(0), expn(0), codeOP1(0), codeB(0), codeOP(0), codeB1(0) { + template< class T > + T arg(int i, Stack stack, const T &a) const { + return nargs[i] ? GetAny< T >((*nargs[i])(stack)) : a; + } + E_EV(const basicAC_F0 &args, int cc) : cas(cc), expOP1(0), expB(0), expn(0), codeOP1(0), codeB(0), codeOP(0), codeB1(0) { // OP1 = (A-sigma*B) // int nbj = args.size()-1; args.SetNameParam(n_name_param, name_param, nargs); if (cas == 1 || cas == 2) { - expn = to(args[0]); - const Polymorphic *op = dynamic_cast(args[1].LeftValue()); + expn = to< long >(args[0]); + const Polymorphic *op = dynamic_cast< const Polymorphic * >(args[1].LeftValue( )); ffassert(op); - codeOP1 = op->Find("(", ArrayOfaType(atype(), false)); + codeOP1 = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); ffassert(codeOP1); if (cas == 2) { - const Polymorphic *op = dynamic_cast(args[2].LeftValue()); + const Polymorphic *op = dynamic_cast< const Polymorphic * >(args[2].LeftValue( )); ffassert(op); - codeB = op->Find("(", ArrayOfaType(atype(), false)); + codeB = op->Find("(", ArrayOfaType(atype< Kn * >( ), false)); ffassert(codeB); } } else if (cas == 3) { - expn = to(args[0]); + expn = to< long >(args[0]); } else { - expOP1 = to *>(args[0]); - expB = to *>(args[1]); + expOP1 = to< Matrice_Creuse< K > * >(args[0]); + expB = to< Matrice_Creuse< K > * >(args[1]); } - ffassert((codeOP1 == 0) || (nargs[13] == 0)); // Double def - ffassert((codeB == 0) || (nargs[12] == 0)); // Double def - codeOP = ToCode(nargs[11]); - if (!codeB) codeB = ToCode(nargs[12]); - if (!codeOP1) codeOP1 = ToCode(nargs[13]); - codeB1 = ToCode(nargs[14]); + ffassert((codeOP1 == 0) || (nargs[13] == 0)); // Double def + ffassert((codeB == 0) || (nargs[12] == 0)); // Double def + codeOP = ToCode< K >(nargs[11]); + if (!codeB) codeB = ToCode< K >(nargs[12]); + if (!codeOP1) codeOP1 = ToCode< K >(nargs[13]); + codeB1 = ToCode< K >(nargs[14]); } - AnyType operator () (Stack stack) const; - operator aType () const { return atype(); } + AnyType operator( )(Stack stack) const; + operator aType( ) const { return atype< long >( ); } }; - E_F0 *code (const basicAC_F0 &args) const { return new E_EV(args,cas); } + E_F0 *code(const basicAC_F0 &args) const { return new E_EV(args, cas); } - EigenValueC () : - OneOperator(atype(), - atype *>(), - atype *>()), - cas(0) {} + EigenValueC( ) : OneOperator(atype< long >( ), atype< Matrice_Creuse< K > * >( ), atype< Matrice_Creuse< K > * >( )), cas(0) {} - EigenValueC (int, int ) : - OneOperator(atype(), atype(), - atype(), - atype()), - cas(2) {} + EigenValueC(int, int) : OneOperator(atype< long >( ), atype< long >( ), atype< Polymorphic * >( ), atype< Polymorphic * >( )), cas(2) {} - EigenValueC (int) : - OneOperator(atype(), atype(), - atype()), - cas(1) {} + EigenValueC(int) : OneOperator(atype< long >( ), atype< long >( ), atype< Polymorphic * >( )), cas(1) {} - EigenValueC (int, int, int) : // All data are given through A=, B= A1=, B1= - OneOperator(atype(), atype()), - cas(3) {} + EigenValueC(int, int, int) + : // All data are given through A=, B= A1=, B1= + OneOperator(atype< long >( ), atype< long >( )), cas(3) {} }; - - basicAC_F0::name_and_type EigenValue::E_EV::name_param[] = { {"tol", &typeid(double)}, {"nev", &typeid(long)}, {"sym", &typeid(bool)}, {"sigma", &typeid(double)}, - {"value", &typeid(KN *)}, - {"vector", &typeid(FEbaseArrayKn *)}, // pferarray - {"ncv", &typeid(long)}, // the number of Arnoldi vectors generated - {"maxit", &typeid(long)}, // the maximum number of Arnoldi iterations - {"ivalue", &typeid(KN *)}, - {"rawvector", &typeid(KNM *)}, - {"resid", &typeid(KN *)}, - {"driver", &typeid(long)}, // 11th - {"which", &typeid(string*)}, // 12th - {"A", &typeid(Polymorphic*)}, - {"B", &typeid(Polymorphic*)}, - {"A1", &typeid(Polymorphic*)}, - {"B1", &typeid(Polymorphic*)}, - {"mode", &typeid(long)} // 17th + {"value", &typeid(KN< double > *)}, + {"vector", &typeid(FEbaseArrayKn< double > *)}, // pferarray + {"ncv", &typeid(long)}, // the number of Arnoldi vectors generated + {"maxit", &typeid(long)}, // the maximum number of Arnoldi iterations + {"ivalue", &typeid(KN< double > *)}, + {"rawvector", &typeid(KNM< double > *)}, + {"resid", &typeid(KN< double > *)}, + {"driver", &typeid(long)}, // 11th + {"which", &typeid(string *)}, // 12th + {"A", &typeid(Polymorphic *)}, + {"B", &typeid(Polymorphic *)}, + {"A1", &typeid(Polymorphic *)}, + {"B1", &typeid(Polymorphic *)}, + {"mode", &typeid(long)} // 17th }; basicAC_F0::name_and_type EigenValueC::E_EV::name_param[] = { {"tol", &typeid(double)}, {"nev", &typeid(long)}, {"sigma", &typeid(Complex)}, - {"value", &typeid(KN *)}, - {"vector", &typeid(FEbaseArrayKn *)}, // pfecarray - {"ncv", &typeid(long)}, // the number of Arnoldi vectors generated - {"maxit", &typeid(long)}, // the maximum number of Arnoldi iterations - {"rawvector", &typeid(KNM *)}, - {"resid", &typeid(KN *)}, - {"driver", &typeid(long)},// 9th - {"which", &typeid(string*)}, // 10th - {"A", &typeid(Polymorphic*)}, - {"B", &typeid(Polymorphic*)}, - {"A1", &typeid(Polymorphic*)}, - {"B1", &typeid(Polymorphic*)}, - {"mode", &typeid(long)} // 15th + {"value", &typeid(KN< Complex > *)}, + {"vector", &typeid(FEbaseArrayKn< Complex > *)}, // pfecarray + {"ncv", &typeid(long)}, // the number of Arnoldi vectors generated + {"maxit", &typeid(long)}, // the maximum number of Arnoldi iterations + {"rawvector", &typeid(KNM< Complex > *)}, + {"resid", &typeid(KN< Complex > *)}, + {"driver", &typeid(long)}, // 9th + {"which", &typeid(string *)}, // 10th + {"A", &typeid(Polymorphic *)}, + {"B", &typeid(Polymorphic *)}, + {"A1", &typeid(Polymorphic *)}, + {"B1", &typeid(Polymorphic *)}, + {"mode", &typeid(long)} // 15th }; -AnyType EigenValue::E_EV::operator () (Stack stack) const { +AnyType EigenValue::E_EV::operator( )(Stack stack) const { dddd = (verbosity >= 200); double tol = 1e-6; long nconv = 0; long nbev = 1; bool sym = false; - long ncv = 0; // the number of Arnoldi vectors generated - long maxit = 0; // the maximum number of Arnoldi iterations + long ncv = 0; // the number of Arnoldi vectors generated + long maxit = 0; // the maximum number of Arnoldi iterations double sigma = 0; - int driver = 4; // - int mymode = -1; // unset - KN *evalue = 0; - KN *evaluei = 0; - KN *resid = 0; - KNM *rawvector = 0; - //double ws, vs; // for debugging FH ++++++++++ - // pferarray evector2; - FEbaseArrayKn *evector = 0; // change may 2009 - tol = arg(0, stack, tol);// correct 26/06/24 thanks to PHT - nbev = arg(1, stack, 10); - sym = arg(2, stack, false); - sigma = arg(3, stack, 0.0); - evalue = arg*>(4, stack, 0); - evector = arg*>(5, stack, 0); - ncv = arg(6, stack, 0); - maxit = arg(7, stack, 0); - evaluei = arg*>(8, stack, 0); - rawvector = arg*>(9, stack, 0); - resid = arg*>(10, stack, 0); - mymode = arg(17, stack, -1); - driver = arg(11, stack, mymode==2 ? 3 : 4); + int driver = 4; // + int mymode = -1; // unset + KN< double > *evalue = 0; + KN< double > *evaluei = 0; + KN< double > *resid = 0; + KNM< double > *rawvector = 0; + // double ws, vs; // for debugging FH ++++++++++ + // pferarray evector2; + FEbaseArrayKn< double > *evector = 0; // change may 2009 + tol = arg< double >(0, stack, tol); // correct 26/06/24 thanks to PHT + nbev = arg< long >(1, stack, 10); + sym = arg< bool >(2, stack, false); + sigma = arg< double >(3, stack, 0.0); + evalue = arg< KN< double > * >(4, stack, 0); + evector = arg< FEbaseArrayKn< double > * >(5, stack, 0); + ncv = arg< long >(6, stack, 0); + maxit = arg< long >(7, stack, 0); + evaluei = arg< KN< double > * >(8, stack, 0); + rawvector = arg< KNM< double > * >(9, stack, 0); + resid = arg< KN< double > * >(10, stack, 0); + mymode = arg< long >(17, stack, -1); + driver = arg< long >(11, stack, mymode == 2 ? 3 : 4); char which[3]; - ToWhich (stack, which, nargs[12]); + ToWhich(stack, which, nargs[12]); // evector=evector2.first; - Matrice_Creuse *pOP1 = 0, *pB = 0; - if (expOP1) - pOP1 = GetAny *>((*expOP1)(stack)); - if (expB) - pB = GetAny *>((*expB)(stack)); - double *residptr = resid ? (double*) *resid : 0; + Matrice_Creuse< K > *pOP1 = 0, *pB = 0; + if (expOP1) pOP1 = GetAny< Matrice_Creuse< K > * >((*expOP1)(stack)); + if (expB) pB = GetAny< Matrice_Creuse< K > * >((*expB)(stack)); + double *residptr = resid ? (double *)*resid : 0; long n = 0; if (pOP1) n = pOP1->A->n; else { ffassert(expn); - n = GetAny((*expn)(stack)); + n = GetAny< long >((*expn)(stack)); } - if (evalue) nbev = Max((long)evalue->N(), nbev); + if (evalue) nbev = Max((long)evalue->N( ), nbev); - const RNM_VirtualMatrix *ptOP1 = 0, *ptB = 0, *ptOP = 0, *ptB1 = 0; + const RNM_VirtualMatrix< K > *ptOP1 = 0, *ptB = 0, *ptOP = 0, *ptB1 = 0; - if (pOP1) - ptOP1 = &(const RNM_VirtualMatrix&)(pOP1->A); - if (pB) - ptB = &(const RNM_VirtualMatrix&)(pB->A); - FuncMat *pcOP = 0, *pcB = 0; - if (codeOP1 || codeOP) - ptOP1 = pcOP = new FuncMat(n, stack, codeOP, codeOP1); - if (codeB || codeB1) - ptB = pcB = new FuncMat(n, stack, codeB, codeB1); + if (pOP1) ptOP1 = &(const RNM_VirtualMatrix< K > &)(pOP1->A); + if (pB) ptB = &(const RNM_VirtualMatrix< K > &)(pB->A); + FuncMat< K > *pcOP = 0, *pcB = 0; + if (codeOP1 || codeOP) ptOP1 = pcOP = new FuncMat< K >(n, stack, codeOP, codeOP1); + if (codeB || codeB1) ptB = pcB = new FuncMat< K >(n, stack, codeB, codeB1); - MatriceIdentite Id(n); + MatriceIdentite< K > Id(n); if (!ptB) ptB = &Id; - const RNM_VirtualMatrix &OP1 = *ptOP1, &B = *ptB; + const RNM_VirtualMatrix< K > &OP1 = *ptOP1, &B = *ptB; if (sym) { - nbev = min(n-1, nbev); - if (!ncv) ncv = min(nbev*2+1, n); + nbev = min(n - 1, nbev); + if (!ncv) ncv = min(nbev * 2 + 1, n); } else { - nbev = min(nbev, n-2); - if (!ncv) ncv = nbev*2 + 1; + nbev = min(nbev, n - 2); + if (!ncv) ncv = nbev * 2 + 1; } - ncv = max(nbev+2, ncv); + ncv = max(nbev + 2, ncv); ncv = min(ncv, n); - if (!maxit) maxit = 100*nbev; + if (!maxit) maxit = 100 * nbev; const char *serr[10]; int err = 0; - if (!(nbev < n)) - serr[err++] = " Number of eigenvalues of OP to be computed nev <= n "; + if (!(nbev < n)) serr[err++] = " Number of eigenvalues of OP to be computed nev <= n "; - if ((driver < 1 || driver > 5) && sym) - serr[err++] = " the driver = 1, 2, 3, 4, 5 "; - if ((driver < 1 || driver > 4) && !sym) - serr[err++] = " the driver = 1, 2, 3, 4 "; + if ((driver < 1 || driver > 5) && sym) serr[err++] = " the driver = 1, 2, 3, 4, 5 "; + if ((driver < 1 || driver > 4) && !sym) serr[err++] = " the driver = 1, 2, 3, 4 "; // 2 <= NCV-NEV and NCV <= N - if (!(ncv <= n) && sym) - serr[err++] = " ( ncv <= n) (symmetric case) "; - if (!((ncv <= n) && 2 <= (ncv-nbev )) && !sym ) - serr[err++] = " ( ncv <= n) 2 <= (ncv-nev ) (non-symmetric case) "; + if (!(ncv <= n) && sym) serr[err++] = " ( ncv <= n) (symmetric case) "; + if (!((ncv <= n) && 2 <= (ncv - nbev)) && !sym) serr[err++] = " ( ncv <= n) 2 <= (ncv-nev ) (non-symmetric case) "; - if (n != OP1.M) - serr[err++] = " the first matrix in EigneValue is not square."; - if (n != B.N) - serr[err++] = "Sorry the row's number of the secand matrix in EigneValue is wrong."; - if (n != B.M) - serr[err++] = "Sorry the column's number of the secand matrix in EigneValue is wrong."; + if (n != OP1.M) serr[err++] = " the first matrix in EigneValue is not square."; + if (n != B.N) serr[err++] = "Sorry the row's number of the secand matrix in EigneValue is wrong."; + if (n != B.M) serr[err++] = "Sorry the column's number of the secand matrix in EigneValue is wrong."; if (verbosity && mpirank == 0) { - if(sym) + if (sym) cout << "Real symmetric eigenvalue problem: A*x - B*x*lambda" << endl; else cout << "Real non symmetric eigenvalue problem: A*x - B*x*lambda" << endl; } - if (verbosity > 9 || err) - cout << " n " << n << ", nev "<< nbev << ", tol =" << tol << ", maxit =" << maxit - << ", ncv = " < work(n); + KN< K > work(n); int dmode[] = {-1, 1, 3, 2, 3}; if (sym) { int ido = 0; - //char bmat= mode == 1 ? 'I' : 'G'; - char bmat = (driver<3)? 'I' : 'G'; + // char bmat= mode == 1 ? 'I' : 'G'; + char bmat = (driver < 3) ? 'I' : 'G'; int mode = dmode[driver]; if (mymode > 0 && (mymode != mode)) { cerr << " Error mode == " << mymode << " == " << mode << " driver =" << driver << endl; @@ -573,31 +545,31 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { // char which[3]= "LM"; // larger value // if(mode >2) which[0] ='S'; // smaller value - int ishift = 1; // Auto Shift true by default + int ishift = 1; // Auto Shift true by default int iparam[12] = {0, ishift, 0, (int)maxit, 1, (int)nconv, 0, mode, 0, 0, 0, 0}; int ipntr[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - KN workd(3*n+1); - int lworkl = ncv*(ncv+9); - KN workl(lworkl+1); - KN vp(ncv*n+1); + KN< double > workd(3 * n + 1); + int lworkl = ncv * (ncv + 9); + KN< double > workl(lworkl + 1); + KN< double > vp(ncv * n + 1); - int info = (residptr !=0); - KN vresid(residptr ? 1 : n); + int info = (residptr != 0); + KN< double > vresid(residptr ? 1 : n); if (!residptr) residptr = &vresid[0]; while (1) { - saupp(ido, bmat, n, which, nbev, tol, residptr, ncv, vp, n, - iparam, ipntr, workd, workl, lworkl, info); - if (verbosity > 99) - cout << " saupp ido: " << ido << " info : " << info << endl; - if (info < 0) { cerr << " -- err arpack info = " << info << endl; } + saupp(ido, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, info); + if (verbosity > 99) cout << " saupp ido: " << ido << " info : " << info << endl; + if (info < 0) { + cerr << " -- err arpack info = " << info << endl; + } sauppError(info); if (ido == 99) break; - KN_ xx(&workd[ipntr[1]], n); - KN_ yy(&workd[ipntr[2]], n); - KN_ zz(&workd[ipntr[3]], n); + KN_< double > xx(&workd[ipntr[1]], n); + KN_< double > yy(&workd[ipntr[2]], n); + KN_< double > zz(&workd[ipntr[3]], n); DoIdoAction(ido, bmat, mode, xx, yy, zz, work, OP1, B); } @@ -610,14 +582,13 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { cerr << "WARNING: nconv(saupp) > nbev: " << nconv << " > " << nbev << endl; newdim = nconv; } - KN evr(newdim); - KNM Z(n, newdim); + KN< double > evr(newdim); + KNM< double > Z(n, newdim); int ldz = n; - char HowMny ='A'; + char HowMny = 'A'; int rvec = 1; - seupp(rvec, HowMny, evr, Z, ldz, sigma, bmat, n, - which, nbev, tol, residptr, ncv, vp, n, iparam,ipntr, workd, workl, lworkl, info); + seupp(rvec, HowMny, evr, Z, ldz, sigma, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, info); if (verbosity > 5) { cout << "Dimension of the system : " << n << endl; @@ -627,44 +598,42 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { cout << "Number of iterations taken : " << iparam[3] << endl; cout << endl; nconv = min(nconv, nbev); - //if (prob.EigenvaluesFound()) { - cout << "Eigenvalues:" << endl;// Add FH feb 2016 + // if (prob.EigenvaluesFound()) { + cout << "Eigenvalues:" << endl; // Add FH feb 2016 for (int i = 0; i < nconv; i++) { - cout << " lambda[" << (i+1) << "]: " << evr(i) << endl; - KN_ vi(Z(':', i)) ; - if (verbosity > 99) - cout <<" Eigenvector: :" << vi << endl; + cout << " lambda[" << (i + 1) << "]: " << evr(i) << endl; + KN_< K > vi(Z(':', i)); + if (verbosity > 99) cout << " Eigenvector: :" << vi << endl; } cout << endl; } if (evalue) { - KN & ev(*evalue); - int m = Min(nconv, ev.N()); - for (int i = 0; i < m; i++) - ev[i] = evr(i); + KN< double > &ev(*evalue); + int m = Min(nconv, ev.N( )); + for (int i = 0; i < m; i++) ev[i] = evr(i); } if (rawvector) { - int m = Min(nconv, rawvector->M()); - ffassert(rawvector->N() == n); + int m = Min(nconv, rawvector->M( )); + ffassert(rawvector->N( ) == n); for (int i = 0; i < m; i++) { - KN_ vi(Z(':', i)) ; + KN_< K > vi(Z(':', i)); // cout << " ------ EV--raw " << vi.min() << " " << vi.max() << endl; (*rawvector)(':', i) = vi; } } if (evector) { - FEbaseArrayKn & ev(*evector); + FEbaseArrayKn< K > &ev(*evector); int m = Min(nconv, (long)ev.N); for (int i = 0; i < m; i++) { - //KN & xx= *(ev(i)); - //if(xx.pVh->NbDoF != n) - //ExecError("Wrong Type size of FEspace to store the eigen vector "); - // if (xx.pVh != pOP1->pUh) - // ExecError("Wrong Type of FEspace to store the eigen vector "); - //xx.Vh = pOP1->Uh; - KN_ vi(Z(':', i)); + // KN & xx= *(ev(i)); + // if(xx.pVh->NbDoF != n) + // ExecError("Wrong Type size of FEspace to store the eigen vector "); + // if (xx.pVh != pOP1->pUh) + // ExecError("Wrong Type of FEspace to store the eigen vector "); + // xx.Vh = pOP1->Uh; + KN_< K > vi(Z(':', i)); ev.set(i, vi); } } @@ -672,10 +641,10 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { } else { // non symmetric case , // Finding an Arnoldi basis. - //int mode = 3; // Shift invert + // int mode = 3; // Shift invert int ido = 0; - //char bmat='G'; - char bmat = (driver<3) ? 'I' : 'G'; + // char bmat='G'; + char bmat = (driver < 3) ? 'I' : 'G'; int mode = dmode[driver]; if (mymode > 0 && (mymode != mode)) { @@ -684,29 +653,31 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { } // char which[] = "LM"; - int ishift = 1; // Auto Shift true by default + int ishift = 1; // Auto Shift true by default int iparam[12] = {0, ishift, 0, (int)maxit, 1, (int)nconv, 0, mode, 0, 0, 0, 0}; int ipntr[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - KN workd(3*n+1); - int lworkl = 3*ncv*(ncv+2); - KN workl(lworkl+1); - KN vp(ncv*n+1); + KN< double > workd(3 * n + 1); + int lworkl = 3 * ncv * (ncv + 2); + KN< double > workl(lworkl + 1); + KN< double > vp(ncv * n + 1); int info = (residptr != 0); - KN vresid(residptr ? 1 : n); + KN< double > vresid(residptr ? 1 : n); if (!residptr) residptr = &vresid[0]; - if (verbosity > 9) - cout << " n " << n << " nbev "<< nbev << " tol =" << tol << " maxit =" << maxit << " ncv = " << ncv << endl; + if (verbosity > 9) cout << " n " << n << " nbev " << nbev << " tol =" << tol << " maxit =" << maxit << " ncv = " << ncv << endl; while (1) { - naupp(ido, bmat, n, which, nbev, tol, residptr, ncv, vp, n, - iparam, ipntr, workd, workl, lworkl, info); - if (verbosity > 99) { cout << " naupp ido: " << ido << " info : " << info << endl; } - if (info < 0) { cerr << " -- err arpack info = " << info << endl; } + naupp(ido, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, info); + if (verbosity > 99) { + cout << " naupp ido: " << ido << " info : " << info << endl; + } + if (info < 0) { + cerr << " -- err arpack info = " << info << endl; + } sauppError(info); if (ido == 99) break; - KN_ xx(&workd[ipntr[1]], n); - KN_ yy(&workd[ipntr[2]], n); - KN_ zz(&workd[ipntr[3]], n); + KN_< double > xx(&workd[ipntr[1]], n); + KN_< double > yy(&workd[ipntr[2]], n); + KN_< double > zz(&workd[ipntr[3]], n); DoIdoAction(ido, bmat, mode, xx, yy, zz, work, OP1, B); } @@ -717,16 +688,14 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { cerr << "WARNING: nconv(naupp) > nbev: " << nconv << " > " << nbev << endl; newdim = nconv; } - KN evr(newdim+1), evi(newdim+1); - KNM Z(n, newdim+1); - KN workev(3*ncv); + KN< double > evr(newdim + 1), evi(newdim + 1); + KNM< double > Z(n, newdim + 1); + KN< double > workev(3 * ncv); int ldz = n; char HowMny = 'A'; int rvec = 1; double sigmai = 0; - neupp(rvec, HowMny, evr,evi, Z , ldz, sigma, sigmai, workev, - bmat, n, which, nbev, tol, residptr, ncv, - vp, n, iparam, ipntr, workd, workl, lworkl, info); + neupp(rvec, HowMny, evr, evi, Z, ldz, sigma, sigmai, workev, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, info); if (verbosity) { cout << "Real non-symmetric eigenvalue problem: A*x - B*x*lambda" << endl; @@ -738,16 +707,16 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { cout << "Number of Arnoldi vectors generated: " << ncv << endl; cout << "Number of iterations taken : " << iparam[3] << endl; cout << endl; - nconv = min(nconv, nbev);// Add FH feb 2016 + nconv = min(nconv, nbev); // Add FH feb 2016 cout << "Eigenvalues:" << endl; for (int i = 0; i < nconv; i++) { - cout << " lambda[" << (i+1) << "]: "; - ios::fmtflags oldflag = cout.flags(); + cout << " lambda[" << (i + 1) << "]: "; + ios::fmtflags oldflag = cout.flags( ); cout.setf(ios::showpos); cout << evr(i) << evi(i) << "i" << endl; - cout.flags(oldflag); // restore flags - KN_ vi(Z(':', i)); + cout.flags(oldflag); // restore flags + KN_< double > vi(Z(':', i)); if (verbosity > 99) { cout << " Eigenvector: " << vi << endl; cout << endl; @@ -756,28 +725,25 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { } if (evalue) { - KN &ev(*evalue); - int m = Min(nconv, ev.N()); - for (int i = 0; i < m; i++) - ev[i] = evr(i); + KN< double > &ev(*evalue); + int m = Min(nconv, ev.N( )); + for (int i = 0; i < m; i++) ev[i] = evr(i); } if (evaluei) { - KN &ev(*evaluei); - int m = Min(nconv, ev.N()); - for (int i = 0; i < m; i++) - ev[i] = evi(i); + KN< double > &ev(*evaluei); + int m = Min(nconv, ev.N( )); + for (int i = 0; i < m; i++) ev[i] = evi(i); } if (rawvector) { - //K* rawev(prob.RawEigenvectors()); - int m = Min(nconv, rawvector->M()); - ffassert(rawvector->N() == n); + // K* rawev(prob.RawEigenvectors()); + int m = Min(nconv, rawvector->M( )); + ffassert(rawvector->N( ) == n); for (int i = 0; i < m; i++) { - //int k = i; - KN_ vi(Z(':', i)); - if (verbosity > 2 && mpirank ==0) - cout << " ------ EV--raw " << vi.min() << " " << vi.max() << endl; + // int k = i; + KN_< K > vi(Z(':', i)); + if (verbosity > 2 && mpirank == 0) cout << " ------ EV--raw " << vi.min( ) << " " << vi.max( ) << endl; (*rawvector)(':', i) = vi; } } @@ -793,79 +759,77 @@ AnyType EigenValue::E_EV::operator () (Stack stack) const { // iev < 0 => complex // start real : rawev + n*(k-1) // -start imag : ramev +n*(k) - FEbaseArrayKn &ev(*evector); + FEbaseArrayKn< K > &ev(*evector); int m = Min(nconv, (long)ev.N); for (int i = 0; i < m; i++) { // K ev_i= - //prob.EigenvalueImag(i); - //KN & xx= *(ev[i]); + // prob.EigenvalueImag(i); + // KN & xx= *(ev[i]); // if (xx.pVh != pOP1->pUh) // ExecError("Wrong Type of FEspace to store the eigen vector "); // xx.Vh = pOP1->Uh; // int k=(ev_i < 0) ? i-1 : i; - //int k=i; - KN_ vi(Z(':', i));//rawev+n*k,n) ; - //xx= new KN(vi); - ev.set(i, vi);//new KN(vi)); + // int k=i; + KN_< K > vi(Z(':', i)); // rawev+n*k,n) ; + // xx= new KN(vi); + ev.set(i, vi); // new KN(vi)); } } } } - if(pcOP) delete pcOP; - if(pcB) delete pcB; + if (pcOP) delete pcOP; + if (pcB) delete pcB; return (long)nconv; } -AnyType EigenValueC::E_EV::operator () (Stack stack) const { +AnyType EigenValueC::E_EV::operator( )(Stack stack) const { dddd = (verbosity >= 200); double tol = 1e-6; long nconv = 0; long nbev = 1; - long ncv = 0; // the number of Arnoldi vectors generated - long maxit = 0; // the maximum number of Arnoldi iterations + long ncv = 0; // the number of Arnoldi vectors generated + long maxit = 0; // the maximum number of Arnoldi iterations long driver = 4; K sigma = 0; - KN *evalue = 0; - KN *resid = 0; - KNM *rawvector = 0; + KN< K > *evalue = 0; + KN< K > *resid = 0; + KNM< K > *rawvector = 0; // pfecarray evector2; - FEbaseArrayKn *evector = 0; - tol = arg(0, stack, 0); - nbev = arg(1, stack, 10); - sigma = arg(2, stack, 0.0); - evalue = arg*>(3, stack, 0); + FEbaseArrayKn< Complex > *evector = 0; + tol = arg< double >(0, stack, 0); + nbev = arg< long >(1, stack, 10); + sigma = arg< K >(2, stack, 0.0); + evalue = arg< KN< K > * >(3, stack, 0); // evector2 =arg(4,stack,make_pair(0,0)); - evector = arg*>(4, stack, 0); - ncv = arg(5, stack, 0); - maxit = arg(6, stack, 0); - rawvector = arg*>(7, stack, 0); - resid = arg*>(8, stack, 0); - int mymode = arg(15, stack, -1); - driver = arg(9, stack, mymode==2 ? 3 : 4); - K *residptr = resid ? (K*)*resid : 0; + evector = arg< FEbaseArrayKn< Complex > * >(4, stack, 0); + ncv = arg< long >(5, stack, 0); + maxit = arg< long >(6, stack, 0); + rawvector = arg< KNM< K > * >(7, stack, 0); + resid = arg< KN< K > * >(8, stack, 0); + int mymode = arg< long >(15, stack, -1); + driver = arg< long >(9, stack, mymode == 2 ? 3 : 4); + K *residptr = resid ? (K *)*resid : 0; char which[3]; ToWhich(stack, which, nargs[10]); - //evector=evector2.first; + // evector=evector2.first; ffassert(driver > 0 && driver < 5); // Matrice_Creuse *pOP1 = GetAny *>((*expOP1)(stack)); // Matrice_Creuse *pB = GetAny *>((*expB)(stack)); - if (evalue) nbev = Max((long)evalue->N(), nbev); - if (!maxit) maxit = 100*nbev; + if (evalue) nbev = Max((long)evalue->N( ), nbev); + if (!maxit) maxit = 100 * nbev; - //const MatriceCreuse & OP1 = pOP1->A; - //const MatriceCreuse & B = pB->A; + // const MatriceCreuse & OP1 = pOP1->A; + // const MatriceCreuse & B = pB->A; - //long n=OP1.n; + // long n=OP1.n; - Matrice_Creuse *pOP1 = 0, *pB = 0; - if (expOP1) - pOP1 = GetAny*>((*expOP1)(stack)); - if (expB) - pB = GetAny*>((*expB)(stack)); + Matrice_Creuse< K > *pOP1 = 0, *pB = 0; + if (expOP1) pOP1 = GetAny< Matrice_Creuse< K > * >((*expOP1)(stack)); + if (expB) pB = GetAny< Matrice_Creuse< K > * >((*expB)(stack)); // double * residptr=resid? (double*) *resid : 0; // cout << " residptr = " << residptr <A->n; else { ffassert(expn); - n = GetAny((*expn)(stack)); + n = GetAny< long >((*expn)(stack)); } - - const RNM_VirtualMatrix *ptOP1, *ptB; - if (pOP1) - ptOP1 = &(const RNM_VirtualMatrix&)(pOP1->A); - if (pB) - ptB = &(const RNM_VirtualMatrix&)(pB->A); - FuncMat *pcOP1 = 0, *pcB = 0; - if (codeOP1 || codeOP) - ptOP1 = pcOP1 = new FuncMat(n, stack, codeOP, codeOP1); - if (codeB || codeB1) - ptB = pcB = new FuncMat(n, stack, codeB, codeB1); - MatriceIdentite Id(n); + const RNM_VirtualMatrix< K > *ptOP1, *ptB; + if (pOP1) ptOP1 = &(const RNM_VirtualMatrix< K > &)(pOP1->A); + if (pB) ptB = &(const RNM_VirtualMatrix< K > &)(pB->A); + FuncMat< K > *pcOP1 = 0, *pcB = 0; + if (codeOP1 || codeOP) ptOP1 = pcOP1 = new FuncMat< K >(n, stack, codeOP, codeOP1); + if (codeB || codeB1) ptB = pcB = new FuncMat< K >(n, stack, codeB, codeB1); + MatriceIdentite< K > Id(n); if (!ptB) ptB = &Id; - const RNM_VirtualMatrix &OP1 = *ptOP1, &B = *ptB; + const RNM_VirtualMatrix< K > &OP1 = *ptOP1, &B = *ptB; - nbev = min(nbev, n-2); - if (!ncv) ncv = nbev*2+1; - ncv = max(nbev+2, ncv); + nbev = min(nbev, n - 2); + if (!ncv) ncv = nbev * 2 + 1; + ncv = max(nbev + 2, ncv); ncv = min(ncv, n); const char *serr[10]; int err = 0; - if (nbev >= n-1) - serr[err++] = " Number of eigenvalues of OP to be computed <= n-2 "; - if (driver < 1 || driver > 4) - serr[err++] = " the driver = 1 ,2 ,4 "; + if (nbev >= n - 1) serr[err++] = " Number of eigenvalues of OP to be computed <= n-2 "; + if (driver < 1 || driver > 4) serr[err++] = " the driver = 1 ,2 ,4 "; // 2 <= NCV-NEV and NCV <= N - if (!(2 <= nbev && ncv <= n)) - serr[err++] = " ( 2 <= nbev && nvc <= n) "; - if (n != OP1.N) - serr[err++] = " the first matrix in EigneValue is not Hermitien."; - if (n != B.N) - serr[err++] = "Sorry the row's number of the secand matrix in EigneValue is wrong."; - if (n != B.M) - serr[err++] = "Sorry the column's number of the secand matrix in EigneValue is wrong."; - if (verbosity) - cout << "Complex eigenvalue problem: A*x - B*x*lambda" << endl; - if (verbosity > 9 || err) - cout << " n " << n << " nev "<< nbev << " tol = " << tol << " maxit = " << maxit << " ncv = " << ncv - << " driver = " << driver << " which = " << which << endl; + if (!(2 <= nbev && ncv <= n)) serr[err++] = " ( 2 <= nbev && nvc <= n) "; + if (n != OP1.N) serr[err++] = " the first matrix in EigneValue is not Hermitien."; + if (n != B.N) serr[err++] = "Sorry the row's number of the secand matrix in EigneValue is wrong."; + if (n != B.M) serr[err++] = "Sorry the column's number of the secand matrix in EigneValue is wrong."; + if (verbosity) cout << "Complex eigenvalue problem: A*x - B*x*lambda" << endl; + if (verbosity > 9 || err) cout << " n " << n << " nev " << nbev << " tol = " << tol << " maxit = " << maxit << " ncv = " << ncv << " driver = " << driver << " which = " << which << endl; if (err) { cerr << " list of the error " << endl; - for (int i = 0; i < err; ++i) - cerr << "\n- " << serr[i] << endl; + for (int i = 0; i < err; ++i) cerr << "\n- " << serr[i] << endl; ExecError("Fatal Error in EigenValue (complex)"); } - KN work(n); + KN< K > work(n); // ARrcSymGenEig is a class that requires the user to provide a // way to perform the matrix-vector products w = OP*Bv = // inv(A-sigma*B)*B*v and w = B*v, where sigma is the adopted shift. @@ -954,43 +903,44 @@ AnyType EigenValueC::E_EV::operator () (Stack stack) const { // int mode=3; // Shift invert \ int ido = 0; - //char bmat='G'; + // char bmat='G'; int dmode[] = {-1, 1, 3, 2, 3}; - char bmat = (driver<3) ? 'I' : 'G'; + char bmat = (driver < 3) ? 'I' : 'G'; int mode = dmode[driver]; // char which[]="LM"; - int ishift = 1; // Auto Shift true by default + int ishift = 1; // Auto Shift true by default if (mymode > 0 && (mymode != mode)) { cerr << " Error complex case: mode == " << mymode << " == " << mode << " driver = " << driver << endl; ExecError("Wrong mod in Arpack complex case:"); } int iparam[12] = {0, ishift, 0, (int)maxit, 1, (int)nconv, 0, (int)mode, 0, 0, 0, 0}; - int ipntr[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - KN workd(3*n+1); - int lworkl = 3*ncv*ncv + 5*ncv; - KN workl(lworkl+1); - KN vp(ncv*n+1); + int ipntr[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + KN< K > workd(3 * n + 1); + int lworkl = 3 * ncv * ncv + 5 * ncv; + KN< K > workl(lworkl + 1); + KN< K > vp(ncv * n + 1); int info = (residptr != 0); - KN rwork(ncv+1); - KN vresid(residptr ? 1 : n); + KN< double > rwork(ncv + 1); + KN< K > vresid(residptr ? 1 : n); if (!residptr) residptr = &vresid[0]; - while(1) { - caupp(ido, bmat, n, which, nbev, - tol, residptr, ncv, - vp, n, iparam, ipntr, workd, workl, - lworkl, rwork, info); + while (1) { + caupp(ido, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, rwork, info); - if (verbosity > 99) { cout << " caupp ido: " << ido << " info : " << info << endl; } - if (info < 0) { cerr << " -- err arpack info = " << info << endl; } + if (verbosity > 99) { + cout << " caupp ido: " << ido << " info : " << info << endl; + } + if (info < 0) { + cerr << " -- err arpack info = " << info << endl; + } sauppError(info); if (ido == 99) break; - KN_ xx(&workd[ipntr[1]], n); - KN_ yy(&workd[ipntr[2]], n); - KN_ zz(&workd[ipntr[3]], n); + KN_< K > xx(&workd[ipntr[1]], n); + KN_< K > yy(&workd[ipntr[2]], n); + KN_< K > zz(&workd[ipntr[3]], n); DoIdoAction(ido, bmat, mode, xx, yy, zz, work, OP1, B); } @@ -1002,15 +952,13 @@ AnyType EigenValueC::E_EV::operator () (Stack stack) const { cerr << "WARNING: nconv(caupp) > nbev: " << nconv << " > " << nbev << endl; newdim = nconv; } - KN evc(newdim); - KNM Z(n, newdim); - KN workev(3*ncv); - //int ldz=n; - char HowMny ='A'; + KN< K > evc(newdim); + KNM< K > Z(n, newdim); + KN< K > workev(3 * ncv); + // int ldz=n; + char HowMny = 'A'; int rvec = 1; - ceupp(rvec, HowMny, evc, Z, n, sigma, workev, bmat, n, which, - nbev, tol, residptr, ncv, - vp, n, iparam, ipntr, workd, workl, lworkl, rwork, info); + ceupp(rvec, HowMny, evc, Z, n, sigma, workev, bmat, n, which, nbev, tol, residptr, ncv, vp, n, iparam, ipntr, workd, workl, lworkl, rwork, info); if (verbosity) { cout << "Complex eigenvalue problem: A*x - B*x*lambda" << endl; @@ -1023,41 +971,38 @@ AnyType EigenValueC::E_EV::operator () (Stack stack) const { cout << "Number of iterations taken : " << iparam[3] << endl; cout << endl; nconv = min(nconv, nbev); - cout << "Eigenvalues:" << endl;// Add FH feb 2016 + cout << "Eigenvalues:" << endl; // Add FH feb 2016 for (int i = 0; i < nconv; i++) { - cout << " lambda[" << (i+1) << "]: " << evc(i) << endl; - KN_ vi(Z(':', i)) ; - if (verbosity > 99) - cout <<" Eigenvector: :" << vi << endl; + cout << " lambda[" << (i + 1) << "]: " << evc(i) << endl; + KN_< K > vi(Z(':', i)); + if (verbosity > 99) cout << " Eigenvector: :" << vi << endl; } cout << endl; } if (evalue) { - KN & ev(*evalue); - int m = Min(nconv, ev.N()); - for (int i = 0; i < m; i++) - ev[i] = evc(i); + KN< K > &ev(*evalue); + int m = Min(nconv, ev.N( )); + for (int i = 0; i < m; i++) ev[i] = evc(i); } if (evector) { - //FEbaseArray & ev(*evector); - FEbaseArrayKn &ev(*evector); + // FEbaseArray & ev(*evector); + FEbaseArrayKn< K > &ev(*evector); int m = Min(nconv, (long)ev.N); for (int i = 0; i < m; i++) { - //FEbase & xx= **(ev[i]); - //KN_ vi(Z(':',i)) ; - //xx= new KN(vi); + // FEbase & xx= **(ev[i]); + // KN_ vi(Z(':',i)) ; + // xx= new KN(vi); ev.set(i, Z(':', i)); } } - if(rawvector) { - int m = Min(nconv, rawvector->M()); - ffassert(rawvector->N() == n); + if (rawvector) { + int m = Min(nconv, rawvector->M( )); + ffassert(rawvector->N( ) == n); for (int i = 0; i < m; i++) { - KN_ vi(Z(':', i)) ; + KN_< K > vi(Z(':', i)); (*rawvector)(':', i) = vi; - if (verbosity > 2 && mpirank == 0) - cout << " raw " << vi.l2() << " == " << (*rawvector)(':', i).l2()<< endl; + if (verbosity > 2 && mpirank == 0) cout << " raw " << vi.l2( ) << " == " << (*rawvector)(':', i).l2( ) << endl; } } } @@ -1066,25 +1011,25 @@ AnyType EigenValueC::E_EV::operator () (Stack stack) const { } #ifndef DYNM_LOAD -void init_eigenvalue () { +void init_eigenvalue( ) { if (verbosity && (mpirank == 0)) cout << "eigenvalue "; - Global.Add("EigenValue", "(", new EigenValue()); // j + dJ - Global.Add("EigenValue", "(", new EigenValueC()); // j + dJ - Global.Add("EigenValue", "(", new EigenValue(1)); // j + dJ - Global.Add("EigenValue", "(", new EigenValue(1, 1)); // j + dJ - Global.Add("EigenValue", "(", new EigenValue(1, 1, 1)); // A=, B= + Global.Add("EigenValue", "(", new EigenValue( )); // j + dJ + Global.Add("EigenValue", "(", new EigenValueC( )); // j + dJ + Global.Add("EigenValue", "(", new EigenValue(1)); // j + dJ + Global.Add("EigenValue", "(", new EigenValue(1, 1)); // j + dJ + Global.Add("EigenValue", "(", new EigenValue(1, 1, 1)); // A=, B= // sorry no to solve ambiguity => change of name - Global.Add("complexEigenValue", "(", new EigenValueC(1)); // j + dJ - Global.Add("complexEigenValue", "(", new EigenValueC(1, 1)); // j + dJ - Global.Add("complexEigenValue", "(", new EigenValueC(1, 1, 1)); // A=, B= ... + Global.Add("complexEigenValue", "(", new EigenValueC(1)); // j + dJ + Global.Add("complexEigenValue", "(", new EigenValueC(1, 1)); // j + dJ + Global.Add("complexEigenValue", "(", new EigenValueC(1, 1, 1)); // A=, B= ... } #else class Init { -public: - Init() { + public: + Init( ) { if (verbosity && (mpirank == 0)) cout << "eigenvalue "; - Global.Add("EigenValue2", "(", new EigenValue()); // j + dJ - Global.Add("EigenValue2", "(", new EigenValueC(1)); // j + dJ + Global.Add("EigenValue2", "(", new EigenValue( )); // j + dJ + Global.Add("EigenValue2", "(", new EigenValueC(1)); // j + dJ } }; Init init; diff --git a/src/Graphics/DefColor.cpp b/src/Graphics/DefColor.cpp index 52fd4a38c..ae4500adb 100644 --- a/src/Graphics/DefColor.cpp +++ b/src/Graphics/DefColor.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,69 +28,92 @@ #include using namespace std; -void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,int nbcolors,float *colors); +void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, int nbcolors, float *colors); +void hsvToRgb(float h, float s, float v, float &r, float &g, float &b) { + int i; + float aa, bb, cc, f; -void hsvToRgb (float h, float s, float v, float & r, float & g, float & b) -{ - int i; - float aa, bb, cc, f; - - if (s == 0) /* Grayscale */ - r = g = b = v; - else { - h = h - floorf(h); - h*=6.; - i = int(h); - f = h - i; - aa = v * (1 - s); - bb = v * (1 - (s * f)); - cc = v * (1 - (s * (1 - f))); - switch (i) { - case 0: r = v; g = cc; b = aa; break; - case 1: r = bb; g = v; b = aa; break; - case 2: r = aa; g = v; b = cc; break; - case 3: r = aa; g = bb; b = v; break; - case 4: r = cc; g = aa; b = v; break; - case 5: r = v; g = aa; b = bb; break; - } + if (s == 0) /* Grayscale */ + r = g = b = v; + else { + h = h - floorf(h); + h *= 6.; + i = int(h); + f = h - i; + aa = v * (1 - s); + bb = v * (1 - (s * f)); + cc = v * (1 - (s * (1 - f))); + switch (i) { + case 0: + r = v; + g = cc; + b = aa; + break; + case 1: + r = bb; + g = v; + b = aa; + break; + case 2: + r = aa; + g = v; + b = cc; + break; + case 3: + r = aa; + g = bb; + b = v; + break; + case 4: + r = cc; + g = aa; + b = v; + break; + case 5: + r = v; + g = aa; + b = bb; + break; } + } } -// def des couleurs de la tables -void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,int nbcolors,float *colors) -{ - if(k<=0) { r=g=b=1.;} // white - else if (k==1) { r=g=b=0.; } // black - else if (k >= nb) { r=g=b=0.;} // black - else if (grey) { float gg = 0.1+0.9*float(k-2)/(nb-3); r=g=b=gg;} - else if (nbcolors<=1) { - float h=float(k-2)/(nb-2),s=1.,v=1.; - hsvToRgb(h,s,v,r,g,b); - return;} - else { // interpolation dans la table hsv - int i= (k-2); - int j0= i*(nbcolors-1) / (nb-2); - int j1=j0+1; - int i0= j0*(nb-2)/(nbcolors-1); - int i1= j1*(nb-2)/(nbcolors-1); - int j03=j0*3,j13=j1*3; - float a=float(i1-i)/(i1-i0),a1=1-a; - if (hsv) - { - float h = colors[j03+0]*a + colors[j13+0]*a1; - float s = colors[j03+1]*a + colors[j13+1]*a1; - float v = colors[j03+2]*a + colors[j13+2]*a1; - hsvToRgb(h,s,v,r,g,b); } - else - { - r = colors[j03+0]*a + colors[j13+0]*a1; - g = colors[j03+1]*a + colors[j13+1]*a1; - b = colors[j03+2]*a + colors[j13+2]*a1; - } - } - +// def des couleurs de la tables +void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, int nbcolors, float *colors) { + if (k <= 0) { + r = g = b = 1.; + } // white + else if (k == 1) { + r = g = b = 0.; + } // black + else if (k >= nb) { + r = g = b = 0.; + } // black + else if (grey) { + float gg = 0.1 + 0.9 * float(k - 2) / (nb - 3); + r = g = b = gg; + } else if (nbcolors <= 1) { + float h = float(k - 2) / (nb - 2), s = 1., v = 1.; + hsvToRgb(h, s, v, r, g, b); + return; + } else { // interpolation dans la table hsv + int i = (k - 2); + int j0 = i * (nbcolors - 1) / (nb - 2); + int j1 = j0 + 1; + int i0 = j0 * (nb - 2) / (nbcolors - 1); + int i1 = j1 * (nb - 2) / (nbcolors - 1); + int j03 = j0 * 3, j13 = j1 * 3; + float a = float(i1 - i) / (i1 - i0), a1 = 1 - a; + if (hsv) { + float h = colors[j03 + 0] * a + colors[j13 + 0] * a1; + float s = colors[j03 + 1] * a + colors[j13 + 1] * a1; + float v = colors[j03 + 2] * a + colors[j13 + 2] * a1; + hsvToRgb(h, s, v, r, g, b); + } else { + r = colors[j03 + 0] * a + colors[j13 + 0] * a1; + g = colors[j03 + 1] * a + colors[j13 + 1] * a1; + b = colors[j03 + 2] * a + colors[j13 + 2] * a1; + } + } } - diff --git a/src/Graphics/Pcrgraph.cpp b/src/Graphics/Pcrgraph.cpp index b70f883bf..fb6fd8946 100644 --- a/src/Graphics/Pcrgraph.cpp +++ b/src/Graphics/Pcrgraph.cpp @@ -34,7 +34,7 @@ #define TOSTRING(i) TOSTRING1(i) #include #include -///#include +/// #include #include #include #include @@ -43,321 +43,301 @@ #include #include using namespace std; -//#include "vect.h" +// #include "vect.h" #include "error.hpp" #include "strversionnumber.hpp" -//#include +// #include /* ** Windows includes */ #include #include -///#include +/// #include #include #include #include -#include //*OT use for the console window -///#include +#include //*OT use for the console window +/// #include -const char * edpfilenamearg=0; -bool waitatend=true; -bool consoleatend=true; +const char *edpfilenamearg = 0; +bool waitatend = true; +bool consoleatend = true; #define fill thequikdrawfill #include "rgraph.hpp" -#include // add by fujiwara -#include "pdf.h" // add by fujiwara +#include // add by fujiwara +#include "pdf.h" // add by fujiwara -//char *Version = "1.2.7"; -void out_of_memory (); -void NEW_HANDLER (void); +// char *Version = "1.2.7"; +void out_of_memory( ); +void NEW_HANDLER(void); void myexit(int); void compile(char *fname); float scali(int i); float scalj(int j); -//int pStrCopy (StringPtr p1, StringPtr p2); -int execute(char* what); -//int DoMouseDown (int windowPart, WindowPtr whichWindow, EventRecord *myEvent); -char Getijc(int & x,int & y); -void postexit(); - -static int cube6[7][3] ={ {255,0,0},{255,255,0},{0,255,0}, - {0,255,255},{0,0,255}, {255,0,255},{255,0,0} }; -static int grey6[2][3] ={ {255,255,255},{0,0,0} }; -static bool grey=false; -static int ncolortable=0; -static int LastColor=2; // LastColor=1 => Noir et Blanc >2 =>couleur +// int pStrCopy (StringPtr p1, StringPtr p2); +int execute(char *what); +// int DoMouseDown (int windowPart, WindowPtr whichWindow, EventRecord *myEvent); +char Getijc(int &x, int &y); +void postexit( ); + +static int cube6[7][3] = {{255, 0, 0}, {255, 255, 0}, {0, 255, 0}, {0, 255, 255}, {0, 0, 255}, {255, 0, 255}, {255, 0, 0}}; +static int grey6[2][3] = {{255, 255, 255}, {0, 0, 0}}; +static bool grey = false; +static int ncolortable = 0; +static int LastColor = 2; // LastColor=1 => Noir et Blanc >2 =>couleur typedef struct rgb { BYTE r; // red component of color - BYTE g; // green component of color + BYTE g; // green component of color BYTE b; // blue component of color -} rgb; +} rgb; -static rgb * colortable=0; -static HPEN* hpen=0; -static HBRUSH* hbr=0; -static HFONT hFont=0; -static int fontH = 0; // The height of font -static int cstatic=1; +static rgb *colortable = 0; +static HPEN *hpen = 0; +static HBRUSH *hbr = 0; +static HFONT hFont = 0; +static int fontH = 0; // The height of font +static int cstatic = 1; -int getcolor(); -void putpixel(int ix,int iy, int couleur); +int getcolor( ); +void putpixel(int ix, int iy, int couleur); int scalx(float x); int scaly(float y); -void compile (char *); +void compile(char *); -void NEW_HANDLER (void){ set_new_handler (&out_of_memory);} +void NEW_HANDLER(void) { set_new_handler(&out_of_memory); } -#define ours(w) (w==grafWindow0) +#define ours(w) (w == grafWindow0) -template inline T Min (const T &a,const T &b){return a < b ? a : b;} -template inline T Max (const T &a,const T & b){return a > b ? a : b;} +template< class T > +inline T Min(const T &a, const T &b) { + return a < b ? a : b; +} +template< class T > +inline T Max(const T &a, const T &b) { + return a > b ? a : b; +} char errbuf[255]; -static int INITGRAPH=0; +static int INITGRAPH = 0; float rayon; -static int width,height; +static int width, height; static FILE *psfile = 0; static FILE *psfile_save = 0; -static bool pdffile = false; // add by fujiwara -static char *pdffile_name = nullptr; // add by fujiwara -static float pdf_s = 1; // add by fujiwara -static std::stringstream pdffile_content; // add by fujiwara -static FILE *svgfile = 0; // add by fujiwara -static FILE *svgfile_save = 0; // add by fujiwara -static float svg_s = 1; // add by fujiwara -static int svg_r = 0; // add by fujiwara -static int svg_g = 0; // add by fujiwara -static int svg_b = 0; // add by fujiwara -static int svg_lw = 1; // add by fujiwara -static float aspx, aspy, echx,echy,ech,rxmin,rxmax,rymin,rymax; +static bool pdffile = false; // add by fujiwara +static char *pdffile_name = nullptr; // add by fujiwara +static float pdf_s = 1; // add by fujiwara +static std::stringstream pdffile_content; // add by fujiwara +static FILE *svgfile = 0; // add by fujiwara +static FILE *svgfile_save = 0; // add by fujiwara +static float svg_s = 1; // add by fujiwara +static int svg_r = 0; // add by fujiwara +static int svg_g = 0; // add by fujiwara +static int svg_b = 0; // add by fujiwara +static int svg_lw = 1; // add by fujiwara +static float aspx, aspy, echx, echy, ech, rxmin, rxmax, rymin, rymax; static int currx, curry; static int carre; -static HWND hWnd; -static WNDCLASS rClass; +static HWND hWnd; +static WNDCLASS rClass; static HDC hdc; -static HANDLE hConOut=0; -const float fMinPixel = -32000; // to avoid int overflot +static HANDLE hConOut = 0; +const float fMinPixel = -32000; // to avoid int overflot const float fMaxPixel = 32000; /* Function definitions */ BOOL Init(HINSTANCE, HINSTANCE, LPSTR, int); -int DoMain(HINSTANCE hInstance); +int DoMain(HINSTANCE hInstance); LONG WINAPI OpenWindowProc1(HWND, UINT, WPARAM, LPARAM); -int getcolor(); -void putpixel(int ix,int iy, int couleur); +int getcolor( ); +void putpixel(int ix, int iy, int couleur); int scalx(float x); int scaly(float y); -void rattente (int); +void rattente(int); BOOL inittext(VOID); BOOL ShowOpenDialogBox(char *fileName); BOOL CreateProjetFile(char *fileName); -char *ChangePdeToExt(char *fileName,char *ext); -BOOL mainFreeFEM(); -int GetFileName(char *fullname, char *shortname); +char *ChangePdeToExt(char *fileName, char *ext); +BOOL mainFreeFEM( ); +int GetFileName(char *fullname, char *shortname); DWORD GetOption(char lpszCmdLine[]); void SetConsole(HANDLE hConsole); FILE *GetConsoleHandle(DWORD Dev); -BOOL GetConsoleBuff(); -BOOL EditLog(); -//void SaveMesh(Grid& t); -//void SavePlot(int D,Grid& t, Real *f); +BOOL GetConsoleBuff( ); +BOOL EditLog( ); +// void SaveMesh(Grid& t); +// void SavePlot(int D,Grid& t, Real *f); BOOL FatalErr(char *s, int err); -//BOOL CheckSameTrig(Grid& t); +// BOOL CheckSameTrig(Grid& t); //*OT flag for FreeFEM+/WinfFEM #define winf_VFFEM 1 #define winf_NOWAIT 2 #define winf_NOCOLOR 4 #define winf_NOEDIT 8 -#define winf_Usage 1024 +#define winf_Usage 1024 unsigned int winf_flg = 0; // end -char FreeFemCache[256]="\0", - shortName[256]="\0", - fullName[256]="\0"; - -void fillpoly(int n, float *poly){ - POINT *pt; - - pt = new POINT[n]; - for (int i=0; i < n; i++) { - pt[i].x = scalx(poly[2*i]); pt[i].y = scaly(poly[2*i+1]); - } - - if (cstatic <0 || cstatic > ncolortable) cstatic =1; - SelectObject(hdc,hbr[cstatic]); - int ret = Polygon(hdc,pt,n); - delete [] pt; - SelectObject(hdc,hpen[n]); - if (psfile) - { - fprintf(psfile,"bF "); - for (int i=0;i\n", - svg_r,svg_g,svg_b, svg_lw, svg_r,svg_g,svg_b); - } -} + if (cstatic < 0 || cstatic > ncolortable) cstatic = 1; + SelectObject(hdc, hbr[cstatic]); + int ret = Polygon(hdc, pt, n); + delete[] pt; + SelectObject(hdc, hpen[n]); + if (psfile) { + fprintf(psfile, "bF "); + for (int i = 0; i < n; i++) fprintf(psfile, "%d %d ", scalx(poly[2 * i]), height - scaly(poly[2 * i + 1])); + fprintf(psfile, "eF\n"); + } + // add by fujiwara + if (pdffile) { -void out_of_memory () -{ - cout << " error: operator new failed; not enough memory" << endl; - myexit (1); + i = 0; + pdffile_content << scalx(poly[2 * i]) * pdf_s << ' ' << (height - scaly(poly[2 * i + 1])) * pdf_s << " m "; + for (i = 1; i < n; i++) pdffile_content << scalx(poly[2 * i]) * pdf_s << ' ' << (height - scaly(poly[2 * i + 1])) * pdf_s << " l "; + pdffile_content << "f" << std::endl; + } + if (svgfile) { + fprintf(svgfile, "\n", svg_r, svg_g, svg_b, svg_lw, svg_r, svg_g, svg_b); + } } -void erreur(char *s) -{ - ErrorExec(s,0); - +void out_of_memory( ) { + cout << " error: operator new failed; not enough memory" << endl; + myexit(1); } -void HandleWindowEvent() -{ MSG msg; -//if ( PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE)) { -if ( PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } +void erreur(char *s) { ErrorExec(s, 0); } +void HandleWindowEvent( ) { + MSG msg; + // if ( PeekMessage(&msg,NULL,WM_PAINT,WM_PAINT,PM_NOREMOVE)) { + if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } void SetColorTable(int n); -void raffpoly(int n, float *poly){} +void raffpoly(int n, float *poly) {} #include "getprog-unix.hpp" - -void penthickness(int pepais){ - if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais); +void penthickness(int pepais) { + if (psfile) fprintf(psfile, "%d setlinewidth\n", pepais); // add by fujiwara - if ( pdffile ){ - pdffile_content << pepais << " w" << std::endl; + if (pdffile) { + pdffile_content << pepais << " w" << std::endl; } - if ( svgfile ){ - svg_lw = pepais; + if (svgfile) { + svg_lw = pepais; } } -void showgraphic(){ShowWindow(hWnd, SW_SHOW ); } // UpdateWindow(hWnd);} +void showgraphic( ) { ShowWindow(hWnd, SW_SHOW); } // UpdateWindow(hWnd);} -void thisexit(){ myexit(0);} +void thisexit( ) { myexit(0); } +void plotstring(const char *s) { + static HFONT hOldFont; -void plotstring(const char *s) -{ - static HFONT hOldFont; - - if (s == 0) return; - hOldFont = (HFONT)::SelectObject(hdc,hFont); - //::GetTextMetrics(hdc, &tm); - ::TextOut(hdc, currx, curry-fontH, s, strlen(s)); - ::DeleteObject(hOldFont); - - if(psfile) { - fprintf(psfile,"%d %d M\n", currx,height-curry); - fprintf(psfile,"(%s) S\n",s); - } + if (s == 0) return; + hOldFont = (HFONT)::SelectObject(hdc, hFont); + //::GetTextMetrics(hdc, &tm); + ::TextOut(hdc, currx, curry - fontH, s, strlen(s)); + ::DeleteObject(hOldFont); + + if (psfile) { + fprintf(psfile, "%d %d M\n", currx, height - curry); + fprintf(psfile, "(%s) S\n", s); + } // add by fujiwara - if( pdffile ){ - pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size - pdffile_content << "1 0 0 1 " << currx*pdf_s << ' ' << (height-curry)*pdf_s << " Tm" << std::endl; - pdffile_content << "(" << string << ") Tj ET" << std::endl; + if (pdffile) { + pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size + pdffile_content << "1 0 0 1 " << currx * pdf_s << ' ' << (height - curry) * pdf_s << " Tm" << std::endl; + pdffile_content << "(" << string << ") Tj ET" << std::endl; } - if( svgfile ){ - fprintf(svgfile,"%s\n",currx*svg_s,curry*svg_s,string); + if (svgfile) { + fprintf(svgfile, "%s\n", currx * svg_s, curry * svg_s, string); } } -void rmoveto(float x, float y) -{ - currx = scalx(x); - curry = scaly(y); +void rmoveto(float x, float y) { + currx = scalx(x); + curry = scaly(y); } -void rlineto(float x, float y) -{ - HandleWindowEvent(); +void rlineto(float x, float y) { + HandleWindowEvent( ); int newx = scalx(x), newy = scaly(y); - MoveToEx(hdc,currx,curry,NULL); - LineTo(hdc,newx,newy); + MoveToEx(hdc, currx, curry, NULL); + LineTo(hdc, newx, newy); if (psfile) { - fprintf(psfile,"%d %d M\n", currx,height-curry); - fprintf(psfile,"%d %d L\n", newx,height-newy); + fprintf(psfile, "%d %d M\n", currx, height - curry); + fprintf(psfile, "%d %d L\n", newx, height - newy); } // add by fujiwara - if ( pdffile ){ - pdffile_content << currx*pdf_s << ' ' << (height-curry)*pdf_s << " m " - << newx*pdf_s << ' ' << (height-newy)*pdf_s << " l S" << std::endl; + if (pdffile) { + pdffile_content << currx * pdf_s << ' ' << (height - curry) * pdf_s << " m " << newx * pdf_s << ' ' << (height - newy) * pdf_s << " l S" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, newx*svg_s, newy*svg_s, svg_r, svg_g, svg_b, svg_lw); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, newx * svg_s, newy * svg_s, svg_r, svg_g, + svg_b, svg_lw); } - currx = newx; curry = newy; + currx = newx; + curry = newy; } -void cadre(float xmin,float xmax,float ymin,float ymax) -{ - rxmin = xmin; - rxmax = xmax; - rymin = ymin; - rymax = ymax; - echx=aspx/(xmax-xmin); - echy=aspy/(ymax-ymin); +void cadre(float xmin, float xmax, float ymin, float ymax) { + rxmin = xmin; + rxmax = xmax; + rymin = ymin; + rymax = ymax; + echx = aspx / (xmax - xmin); + echy = aspy / (ymax - ymin); } -void getcadre(float &xmin,float &xmax,float &ymin,float &ymax) -{ +void getcadre(float &xmin, float &xmax, float &ymin, float &ymax) { xmin = rxmin; xmax = rxmax; ymin = rymin; ymax = rymax; } -void cadreortho(float centrex, float centrey, float rayon) -{ - RECT rc; - GetClientRect(hWnd, &rc); +void cadreortho(float centrex, float centrey, float rayon) { + RECT rc; + GetClientRect(hWnd, &rc); - width = rc.right - rc.left; - height = rc.bottom - rc.top; + width = rc.right - rc.left; + height = rc.bottom - rc.top; - if (height < width) - { + if (height < width) { rymin = centrey - rayon; rymax = centrey + rayon; - echx = echy= height / (2 * rayon); - rxmin= centrex - width / (2 * echx); - rxmax= centrex + width / (2 * echx); - } - else - { + echx = echy = height / (2 * rayon); + rxmin = centrex - width / (2 * echx); + rxmax = centrex + width / (2 * echx); + } else { rxmin = centrex - rayon; rxmax = centrex + rayon; echx = echy = width / (2 * rayon); @@ -366,358 +346,305 @@ void cadreortho(float centrex, float centrey, float rayon) } } -int scalx(float x) -{ - return static_cast((x - rxmin) * echx); -} +int scalx(float x) { return static_cast< int >((x - rxmin) * echx); } -int scaly(float y) -{ - return static_cast((rymax - y) * echy); -} +int scaly(float y) { return static_cast< int >((rymax - y) * echy); } -float scali(int i) -{ - return i/echx + rxmin; -} +float scali(int i) { return i / echx + rxmin; } -float scalj(int j) -{ - return -j/echy + rymax; -} +float scalj(int j) { return -j / echy + rymax; } void pointe(float x, float y) { -// putpixel(scalx(x), scaly(y), LastColor); + // putpixel(scalx(x), scaly(y), LastColor); } -int InRecScreen(float x1, float y1,float x2, float y2) -{ - float xi = Min(x1,x2),xa=Max(x1,x2); - float yi = Min(y1,y2),ya=Max(y1,y2); +int InRecScreen(float x1, float y1, float x2, float y2) { + float xi = Min(x1, x2), xa = Max(x1, x2); + float yi = Min(y1, y2), ya = Max(y1, y2); return (xa >= rxmin) && (xi <= rxmax) && (ya >= rymin) && (yi <= rymax); } -int InPtScreen( float x, float y) -{ - return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); -} +int InPtScreen(float x, float y) { return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); } -void SetRGBpen(int n) -{ - SelectObject(hdc, hpen[n]); -} +void SetRGBpen(int n) { SelectObject(hdc, hpen[n]); } -static rgb DefColorWin32( int k,int nb, bool hsv,bool grey,int nbcolors,float *colors) -{ - rgb C; - float r,g,b; -extern void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,int nbcolors,float *colors); - DefColor(r,g,b, k,nb,hsv,grey,nbcolors,colors); - C.r= (BYTE) (255*r); - C.g= (BYTE) (255*g); - C.b= (BYTE) (255*b); - return C; +static rgb DefColorWin32(int k, int nb, bool hsv, bool grey, int nbcolors, float *colors) { + rgb C; + float r, g, b; + extern void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, int nbcolors, float *colors); + DefColor(r, g, b, k, nb, hsv, grey, nbcolors, colors); + C.r = (BYTE)(255 * r); + C.g = (BYTE)(255 * g); + C.b = (BYTE)(255 * b); + return C; } - -void SetColorTable1(int nb,bool hsv,int nbcolors,float *colors) -{ +void SetColorTable1(int nb, bool hsv, int nbcolors, float *colors) { static bool greyo = !grey; - static float * colorso =0; - if(!INITGRAPH) return; - if (ncolortable == nb && greyo == grey && colorso == colors ) return;// optim - greyo = grey; - colorso=colors; - { - if (hpen) for(int i=0; i1) LastColor=nb-1; - for (int i0=0;i0 1) LastColor = nb - 1; + for (int i0 = 0; i0 < nb; i0++) { + colortable[i0] = DefColorWin32(i0, nb, hsv, grey, nbcolors, colors); + } + } - hpen = new HPEN[ncolortable]; - hbr = new HBRUSH[ncolortable]; + { - for(int i=0; i1) LastColor=nb-1; - - if (hpen) for(int i=0; i 1) LastColor = nb - 1; + + if (hpen) + for (int i = 0; i < ncolortable; i++) DeleteObject(hpen[i]); + delete[] hpen; + if (hbr) + for (int i = 0; i < ncolortable; i++) DeleteObject(hbr[i]); + delete[] hbr; if (hFont) DeleteObject(hFont); - hpen=0; - hbr=0; - hFont=0; + hpen = 0; + hbr = 0; + hFont = 0; - if(colortable) - delete [] colortable; - colortable = new rgb[nb+1]; + if (colortable) delete[] colortable; + colortable = new rgb[nb + 1]; ncolortable = nb; - int k=0; + int k = 0; colortable[k].r = 255; colortable[k].g = 255; colortable[k++].b = 255; colortable[k].r = 0; colortable[k].g = 0; colortable[k++].b = 0; - if (nb>2) - { - nb -= 2; - for (long i0=0;i0 2) { + nb -= 2; + for (long i0 = 0; i0 < nb; i0++, k++) { + long i6 = i0 * 6; + long j0 = i6 / nb; // in 0..6 + long j1 = j0 + 1; // in 1..6 + long k0 = i0 - (nb * j0) / 6L; + long k1 = (nb * j1) / 6L - i0; + long kk = (k0 + k1); + + if (!grey) { + colortable[k].r = ((cube6[j1][0] * k0 + cube6[j0][0] * k1) / kk); + colortable[k].g = ((cube6[j1][1] * k0 + cube6[j0][1] * k1) / kk); + colortable[k].b = ((cube6[j1][2] * k0 + cube6[j0][2] * k1) / kk); + } else { + kk = nb - 1; + k1 = i0; + k0 = nb - i0 - 1; + colortable[k].r = ((grey6[0][0] * k0 + grey6[1][0] * k1) / kk); + colortable[k].g = ((grey6[0][1] * k0 + grey6[1][1] * k1) / kk); + colortable[k].b = ((grey6[0][2] * k0 + grey6[1][2] * k1) / kk); + } + + /* + colortable[k].r = ((cube6[j1][0]*k0+cube6[j0][0]*k1)/kk)%256; + colortable[k].g = ((cube6[j1][1]*k0+cube6[j0][1]*k1)/kk)%256; + colortable[k].b = ((cube6[j1][2]*k0+cube6[j0][2]*k1)/kk)%256; + */ } - else - { ncolortable =2;} + } else { + ncolortable = 2; + } hpen = new HPEN[ncolortable]; hbr = new HBRUSH[ncolortable]; - for(int i=0; i LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc - - if (!(winf_flg&winf_NOCOLOR)) { - if (c>=0 && c < ncolortable) - cstatic = c; - else cstatic = 1; - SetRGBpen(cstatic); - } - // else SetRGBpen(1); +void couleur(int c) { + if (c != cstatic) { + c = c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc + + if (!(winf_flg & winf_NOCOLOR)) { + if (c >= 0 && c < ncolortable) + cstatic = c; + else + cstatic = 1; + SetRGBpen(cstatic); + } + // else SetRGBpen(1); } - if (psfile) - { - float r=1,g=1,b=1; + if (psfile) { + float r = 1, g = 1, b = 1; if (colortable) { - if (c>0 && c < ncolortable) - { - r = (float) colortable[c].r /255.; - g = (float) colortable[c].g /255.; - b = (float) colortable[c].b /255.; - } - } - else if (c!=0) - r=g=b=0; - - fprintf(psfile,"%.3f %.3f %.3f C\n",r,g,b); + if (c > 0 && c < ncolortable) { + r = (float)colortable[c].r / 255.; + g = (float)colortable[c].g / 255.; + b = (float)colortable[c].b / 255.; + } + } else if (c != 0) + r = g = b = 0; + fprintf(psfile, "%.3f %.3f %.3f C\n", r, g, b); + } + // add by fujiwara + if (pdffile) { + pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; + pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; + } + if (svgfile) { + svg_r = static_cast< int >(r * 256); + svg_g = static_cast< int >(g * 256); + svg_b = static_cast< int >(b * 256); } - // add by fujiwara - if( pdffile ){ - pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; - pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; - } - if( svgfile ){ - svg_r = static_cast(r*256); - svg_g = static_cast(g*256); - svg_b = static_cast(b*256); - } } -int LaCouleur(){return cstatic;} +int LaCouleur( ) { return cstatic; } //* Control on the graphic window -void rattente(int waitm) -{ - int i=0, j=0; - char c; - if (waitm) - if(!(winf_flg&winf_NOWAIT)) c = Getijc(i,j); +void rattente(int waitm) { + int i = 0, j = 0; + char c; + if (waitm) + if (!(winf_flg & winf_NOWAIT)) c = Getijc(i, j); } -char Getijc(int & x,int & y) -{ - char char1=' '; - if(!INITGRAPH) - { - x = 0; - y = 0; - return char1; - } - int cont=1; - POINT xy; - xy.x =0; - xy.y =0; +char Getijc(int &x, int &y) { + char char1 = ' '; + if (!INITGRAPH) { + x = 0; + y = 0; + return char1; + } + int cont = 1; + POINT xy; + xy.x = 0; + xy.y = 0; MSG msg; - SetWindowText(hWnd,"Click mouse to continue"); - do - { - GetMessage(&msg,hWnd,0,0);// all message - GetCursorPos(&xy); - switch (msg.message) - { - case WM_LBUTTONDOWN:char1=char(251), cont=0; - break; - // with shift 248 - case WM_RBUTTONDOWN:char1=char(253), cont=0; - break; - // with shit 250 - // if the 2 buttom, 252, et shith 249; - case WM_CLOSE: myexit(2); - case WM_DESTROY: myexit(3); - case WM_CHAR: char1 = (TCHAR)msg.wParam; cont = 0; break; - //case WM_KEYDOWN: char1 = (TCHAR)msg.wParam; cont=0; break; - default: - TranslateMessage(&msg); - DispatchMessage(&msg); - break; - } + SetWindowText(hWnd, "Click mouse to continue"); + do { + GetMessage(&msg, hWnd, 0, 0); // all message + GetCursorPos(&xy); + switch (msg.message) { + case WM_LBUTTONDOWN: + char1 = char(251), cont = 0; + break; + // with shift 248 + case WM_RBUTTONDOWN: + char1 = char(253), cont = 0; + break; + // with shit 250 + // if the 2 buttom, 252, et shith 249; + case WM_CLOSE: + myexit(2); + case WM_DESTROY: + myexit(3); + case WM_CHAR: + char1 = (TCHAR)msg.wParam; + cont = 0; + break; + // case WM_KEYDOWN: char1 = (TCHAR)msg.wParam; cont=0; break; + default: + TranslateMessage(&msg); + DispatchMessage(&msg); + break; } - while (cont); -// ScreenToClient(hWnd,&xy); - ShowWindow(hWnd, SW_SHOW ); - // SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - SetWindowText(hWnd, PACKAGE_STRING " works..."); - RECT rc; - ScreenToClient(hWnd,&xy); - GetClientRect(hWnd, &rc); - - x = xy.x-rc.left; - y = xy.y-rc.top; - // cout << " x = " << x << " y = " << y << " char = " << ((unsigned char)char1 > 127 ? '*': char1) << ")" << endl; - return char1; + } while (cont); + // ScreenToClient(hWnd,&xy); + ShowWindow(hWnd, SW_SHOW); + // SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowText(hWnd, PACKAGE_STRING " works..."); + RECT rc; + ScreenToClient(hWnd, &xy); + GetClientRect(hWnd, &rc); + + x = xy.x - rc.left; + y = xy.y - rc.top; + // cout << " x = " << x << " y = " << y << " char = " << ((unsigned char)char1 > 127 ? '*': char1) << ")" << endl; + return char1; } -char Getxyc(float &x,float &y) -{ - char c=' '; - int i=0,j=0; - if(!(winf_flg&winf_NOWAIT)) c = Getijc( i,j); +char Getxyc(float &x, float &y) { + char c = ' '; + int i = 0, j = 0; + if (!(winf_flg & winf_NOWAIT)) c = Getijc(i, j); x = scali(i); y = scalj(j); - //rattente(1); + // rattente(1); return c; } //* clear the screen with white -void reffecran(void) -{ - HBRUSH hbr; - RECT rc; +void reffecran(void) { + HBRUSH hbr; + RECT rc; - GetClientRect(hWnd, &rc); - hbr = CreateSolidBrush(RGB(255, 255, 255)); - FillRect(hdc,&rc,hbr); - DeleteObject(hbr); + GetClientRect(hWnd, &rc); + hbr = CreateSolidBrush(RGB(255, 255, 255)); + FillRect(hdc, &rc, hbr); + DeleteObject(hbr); } -BOOL ShowOpenDialogBox(char *fileName) -{ +BOOL ShowOpenDialogBox(char *fileName) { OPENFILENAME ofn; char szDirName[256]; - char *strFilter="PCgFEM Files (*.edp)\0*.edp\0All Files (*.*)\0*.*\0\0"; + char *strFilter = "PCgFEM Files (*.edp)\0*.edp\0All Files (*.*)\0*.*\0\0"; memset(&ofn, 0, sizeof(OPENFILENAME)); - getcwd(szDirName,sizeof(szDirName)); + getcwd(szDirName, sizeof(szDirName)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = NULL; ofn.lpstrFilter = strFilter; ofn.lpstrFileTitle = fileName; ofn.nMaxFileTitle = 80; - ofn.lpstrInitialDir=szDirName; - ofn.lpstrTitle ="Choose you freefem '*.edp' File"; - ofn.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; + ofn.lpstrInitialDir = szDirName; + ofn.lpstrTitle = "Choose you freefem '*.edp' File"; + ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; return GetOpenFileName(&ofn); } -void coutmode(short r) { ;}// will be done later +void coutmode(short r) { ; } // will be done later - -void initgraphique(void) -{ +void initgraphique(void) { if (INITGRAPH) return; - hdc=GetDC(hWnd); - hpen=0; - SetColorTable(2+6); + hdc = GetDC(hWnd); + hpen = 0; + SetColorTable(2 + 6); RECT rc; GetClientRect(hWnd, &rc); @@ -727,200 +654,189 @@ void initgraphique(void) height = rc.bottom - rc.top; carre = aspx == aspy; // Define the font style - LOGFONT lf; - TEXTMETRIC tm; - HFONT hFont, hOldFont; - - memset(&lf, 0, sizeof lf); - lf.lfHeight = -9; - lstrcpy(lf.lfFaceName,"Arial"); - lf.lfOutPrecision = OUT_TT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = PROOF_QUALITY; - lf.lfPitchAndFamily = FF_SWISS | VARIABLE_PITCH; - hFont = ::CreateFontIndirect(&lf); - - hOldFont = (HFONT)::SelectObject(hdc,hFont); - ::GetTextMetrics(hdc, &tm); - ::DeleteObject(hOldFont); - fontH = static_cast((tm.tmHeight + tm.tmExternalLeading)*0.6); + LOGFONT lf; + TEXTMETRIC tm; + HFONT hFont, hOldFont; + + memset(&lf, 0, sizeof lf); + lf.lfHeight = -9; + lstrcpy(lf.lfFaceName, "Arial"); + lf.lfOutPrecision = OUT_TT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = PROOF_QUALITY; + lf.lfPitchAndFamily = FF_SWISS | VARIABLE_PITCH; + hFont = ::CreateFontIndirect(&lf); + + hOldFont = (HFONT)::SelectObject(hdc, hFont); + ::GetTextMetrics(hdc, &tm); + ::DeleteObject(hOldFont); + fontH = static_cast< int >((tm.tmHeight + tm.tmExternalLeading) * 0.6); // end of font style INITGRAPH = 1; // cout << flush << "end inigraphique " << endl; } -void closegraphique(void) -{ - if(INITGRAPH) { - if(hpen) - DeleteObject(hpen), delete [] colortable; - if (hbr) DeleteObject(hbr), - INITGRAPH =0; // before DestroyWindow to avoid loop - ReleaseDC(hWnd,hdc); -// DestroyWindow(hWnd); - } +void closegraphique(void) { + if (INITGRAPH) { + if (hpen) DeleteObject(hpen), delete[] colortable; + if (hbr) DeleteObject(hbr), + INITGRAPH = 0; // before DestroyWindow to avoid loop + ReleaseDC(hWnd, hdc); + // DestroyWindow(hWnd); + } } -void GetScreenSize(int & ix,int &iy) -{ - ix = width ; +void GetScreenSize(int &ix, int &iy) { + ix = width; iy = height; } -void openPS(const char *filename ) -{ +void openPS(const char *filename) { RECT rc; GetClientRect(hWnd, &rc); width = rc.right - rc.left; height = rc.bottom - rc.top; - closePS(); + closePS( ); time_t t_loc; - float s=0.5; - const int shiftx=50,shifty=50; + float s = 0.5; + const int shiftx = 50, shifty = 50; time(&t_loc); - printf(" Save Postscript in file '%s'\n",filename?filename:"freefem.ps"), - psfile=fopen(filename?filename:"freefem.ps","w"); - if(psfile==0) {printf("Erreur %s \n",filename);exit(1);} - if(psfile) { - fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); - fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); - fprintf(psfile,"%%%%Pages: 1\n"); - fprintf(psfile,"%%%%BoundingBox: %d %d %d %d\n",shiftx,shifty,int(shiftx+width*s),int(shifty+height*s)); - fprintf(psfile,"%%%%EndComments\n"); - fprintf(psfile," /L { lineto currentpoint stroke newpath moveto} def\n"); - fprintf(psfile," /M { moveto } def\n"); - fprintf(psfile," /C {setrgbcolor} def\n"); - fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); - fprintf(psfile," %d %d translate \n",shiftx,shifty); - fprintf(psfile," %f %f scale \n",s,s); - fprintf(psfile," 0 %d 0 %d rec clip newpath\n",int(width),int(height)); - fprintf(psfile," /Helvetica findfont 10 scalefont setfont\n"); - fprintf(psfile," /S { show} def\n"); - fprintf(psfile," /bF { mark} def \n"); - fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); - fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); - - fprintf(psfile," 1 setlinewidth\n"); - psfile_save=psfile; + printf(" Save Postscript in file '%s'\n", filename ? filename : "freefem.ps"), psfile = fopen(filename ? filename : "freefem.ps", "w"); + if (psfile == 0) { + printf("Erreur %s \n", filename); + exit(1); + } + if (psfile) { + fprintf(psfile, "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n", "user"); + fprintf(psfile, "%%%%CreationDate: %s", ctime(&t_loc)); + fprintf(psfile, "%%%%Pages: 1\n"); + fprintf(psfile, "%%%%BoundingBox: %d %d %d %d\n", shiftx, shifty, int(shiftx + width * s), int(shifty + height * s)); + fprintf(psfile, "%%%%EndComments\n"); + fprintf(psfile, " /L { lineto currentpoint stroke newpath moveto} def\n"); + fprintf(psfile, " /M { moveto } def\n"); + fprintf(psfile, " /C {setrgbcolor} def\n"); + fprintf(psfile, " /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); + fprintf(psfile, " %d %d translate \n", shiftx, shifty); + fprintf(psfile, " %f %f scale \n", s, s); + fprintf(psfile, " 0 %d 0 %d rec clip newpath\n", int(width), int(height)); + fprintf(psfile, " /Helvetica findfont 10 scalefont setfont\n"); + fprintf(psfile, " /S { show} def\n"); + fprintf(psfile, " /bF { mark} def \n"); + fprintf(psfile, " /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); + fprintf(psfile, " /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); + + fprintf(psfile, " 1 setlinewidth\n"); + psfile_save = psfile; } } -void closePS(void) -{ - if(psfile_save) { - fprintf(psfile_save,"showpage\n");//fprintf(psfile,"showpage\n"); - fclose(psfile_save);//fclose(psfile); - } - - psfile=0; - psfile_save=0; +void closePS(void) { + if (psfile_save) { + fprintf(psfile_save, "showpage\n"); // fprintf(psfile,"showpage\n"); + fclose(psfile_save); // fclose(psfile); + } + psfile = 0; + psfile_save = 0; } //---------------------------------------------------------------------- // add by fujiwara //---------------------------------------------------------------------- -void openPDF(const char *filename ) -{ - if(pdffile) closePDF(); +void openPDF(const char *filename) { + if (pdffile) closePDF( ); - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } - pdffile_name = new char [ strlen(filename)+1 ]; - strcpy( pdffile_name, filename ); + pdffile_name = new char[strlen(filename) + 1]; + strcpy(pdffile_name, filename); - pdffile_content.str(""); // clear - pdffile_content.clear( std::stringstream::goodbit ); + pdffile_content.str(""); // clear + pdffile_content.clear(std::stringstream::goodbit); - pdffile_content.setf( std::ios::fixed ); - pdffile_content.precision( 3 ); + pdffile_content.setf(std::ios::fixed); + pdffile_content.precision(3); const int widthA4PDF = 596; - pdf_s = static_cast(widthA4PDF) / width; + pdf_s = static_cast< float >(widthA4PDF) / width; pdffile = true; - pdffile_content << "q" << std::endl; // gsave - + pdffile_content << "q" << std::endl; // gsave + return; } -void closePDF(void) -{ - if(pdffile) { +void closePDF(void) { + if (pdffile) { - std::string PDFTitle = "plot() by FreeFem++"; - std::string AppName = "FreeFem++ v" + StrVersionNumber(); + std::string PDFTitle = "plot() by FreeFem++"; + std::string AppName = "FreeFem++ v" + StrVersionNumber( ); - SimplePDF_FF pdf( pdffile_name, PDFTitle.c_str(), AppName.c_str() ); + SimplePDF_FF pdf(pdffile_name, PDFTitle.c_str( ), AppName.c_str( )); - const int widthPDF = static_cast( width * pdf_s ); - const int heightPDF = static_cast( height * pdf_s ); + const int widthPDF = static_cast< int >(width * pdf_s); + const int heightPDF = static_cast< int >(height * pdf_s); - pdffile_content << "Q" << std::endl; + pdffile_content << "Q" << std::endl; - pdf.addPage( pdffile_content, widthPDF, heightPDF ); + pdf.addPage(pdffile_content, widthPDF, heightPDF); - pdffile = false; + pdffile = false; } - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } return; } -void openSVG(const char *filename ) -{ - if(svgfile_save) closeSVG(); +void openSVG(const char *filename) { + if (svgfile_save) closeSVG( ); - const int widthA4PS = 596; - //const int heightA4PS = 842; - svg_s = static_cast(widthA4PS)/width; + const int widthA4PS = 596; + // const int heightA4PS = 842; + svg_s = static_cast< double >(widthA4PS) / width; char ffff[32]; int count = 0; - if(!filename){ + if (!filename) { bool notfound; do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.svg",count++); - volatile int r = stat(ffff,&buf) ; + sprintf(ffff, "rgraph_%.3d.svg", count++); + volatile int r = stat(ffff, &buf); notfound = (r != 0); - if( count > 1000 ) break; - } while ( !notfound ); - } - - const char *fsvg (filename?filename:ffff); - - svgfile=fopen(fsvg,"w"); - - if(svgfile) { - svgfile_save=svgfile; - fprintf(svgfile,"\n\n"); - fprintf(svgfile,"\n\n", StrVersionNumber().c_str()); - fprintf(svgfile,"\n", - static_cast(width*svg_s), static_cast(height*svg_s)); + if (count > 1000) break; + } while (!notfound); } - else - { + + const char *fsvg(filename ? filename : ffff); + + svgfile = fopen(fsvg, "w"); + + if (svgfile) { + svgfile_save = svgfile; + fprintf(svgfile, "\n\n"); + fprintf(svgfile, "\n\n", StrVersionNumber( ).c_str( )); + fprintf(svgfile, "\n", static_cast< int >(width * svg_s), static_cast< int >(height * svg_s)); + } else { cerr << " Err opening SVG file " << fsvg << endl; } return; } -void closeSVG(void) -{ - if(svgfile_save) { - fprintf(svgfile_save,"\n"); +void closeSVG(void) { + if (svgfile_save) { + fprintf(svgfile_save, "\n"); fclose(svgfile_save); } - svgfile_save=0; - svgfile=0; + svgfile_save = 0; + svgfile = 0; return; } @@ -928,156 +844,151 @@ void closeSVG(void) // add by fujiwara end //---------------------------------------------------------------------- - void Commentaire(const char * c) - { - if(psfile) { - fprintf(psfile,"%% %s\n",c); - } - // add by fujiwara - if( pdffile ) { - //fprintf(pdffile,"%% %s\n",c); - } - if( svgfile ) { - fprintf(svgfile,"%% %s\n",c); - } - }; - void NoirEtBlanc(int NB) - { - if(NB) LastColor=1; - else LastColor=ncolortable?ncolortable:2; +void Commentaire(const char *c) { + if (psfile) { + fprintf(psfile, "%% %s\n", c); } - - void MettreDansPostScript(int in) - { - if(in) psfile=psfile_save; - else psfile=0; - } // add by fujiwara - void MettreDansPDF(int in) // put into PDF - { - if(in) pdffile=true; - else pdffile=false; - } - void MettreDansSVG(int in) // put into SVG - { - if(in) svgfile=svgfile_save; - else svgfile=0; - } + if (pdffile) { + // fprintf(pdffile,"%% %s\n",c); + } + if (svgfile) { + fprintf(svgfile, "%% %s\n", c); + } +}; +void NoirEtBlanc(int NB) { + if (NB) + LastColor = 1; + else + LastColor = ncolortable ? ncolortable : 2; +} -// Various works when the program will end -void myexit(int err) +void MettreDansPostScript(int in) { + if (in) + psfile = psfile_save; + else + psfile = 0; +} +// add by fujiwara +void MettreDansPDF(int in) // put into PDF { - time_t ltime; // write the time stump in console - struct tm *now; - time(<ime); // write the end time - now = localtime(<ime); - cout << "\nEnd Time: " << asctime(now) << endl; - - if (err==0) { // normal end - cout << "end No Error " << endl << flush ; - } + if (in) + pdffile = true; else - cout << "end by Error (no.=" << err << ')' << endl; + pdffile = false; +} +void MettreDansSVG(int in) // put into SVG +{ + if (in) + svgfile = svgfile_save; + else + svgfile = 0; +} + +// Various works when the program will end +void myexit(int err) { + time_t ltime; // write the time stump in console + struct tm *now; + time(<ime); // write the end time + now = localtime(<ime); + cout << "\nEnd Time: " << asctime(now) << endl; + + if (err == 0) { // normal end + cout << "end No Error " << endl << flush; + } else + cout << "end by Error (no.=" << err << ')' << endl; rattente(1); - if (GetConsoleBuff()==FALSE) - FatalErr("Log file creation error !",0); - if (!(winf_flg&winf_NOEDIT)) EditLog(); + if (GetConsoleBuff( ) == FALSE) FatalErr("Log file creation error !", 0); + if (!(winf_flg & winf_NOEDIT)) EditLog( ); - if (INITGRAPH) - closegraphique(); + if (INITGRAPH) closegraphique( ); - FreeConsole(); - PostQuitMessage(0); - exit(err); + FreeConsole( ); + PostQuitMessage(0); + exit(err); } // initialize the console -void SetcppIo() -{ - FILE *fp=NULL,*fin=NULL; +void SetcppIo( ) { + FILE *fp = NULL, *fin = NULL; // Get the standard output - fin = GetConsoleHandle(STD_INPUT_HANDLE); - if(fin!=NULL) - *stdin = *fin; - - // get the standard output - if((fp = GetConsoleHandle(STD_OUTPUT_HANDLE)) == NULL) - *stdout = *fp; - freopen("conin$", "r", stdin); - freopen("conout$", "w", stdout); - // freopen("conout$", "w", stderr); - - using namespace __gnu_cxx; - stdio_filebuf * ccout = new stdio_filebuf(stdout, std::ios_base::out); - //static stdio_filebuf ccerr(stderr, std::ios_base::out); - stdio_filebuf *ccin= new stdio_filebuf(stdin, std::ios_base::in); - - cout.rdbuf(ccout); - cin.rdbuf(ccin); - cerr.rdbuf(ccout); - ios::sync_with_stdio(); + fin = GetConsoleHandle(STD_INPUT_HANDLE); + if (fin != NULL) *stdin = *fin; + + // get the standard output + if ((fp = GetConsoleHandle(STD_OUTPUT_HANDLE)) == NULL) *stdout = *fp; + freopen("conin$", "r", stdin); + freopen("conout$", "w", stdout); + // freopen("conout$", "w", stderr); + + using namespace __gnu_cxx; + stdio_filebuf< char > *ccout = new stdio_filebuf< char >(stdout, std::ios_base::out); + // static stdio_filebuf ccerr(stderr, std::ios_base::out); + stdio_filebuf< char > *ccin = new stdio_filebuf< char >(stdin, std::ios_base::in); + + cout.rdbuf(ccout); + cin.rdbuf(ccin); + cerr.rdbuf(ccout); + ios::sync_with_stdio( ); } -BOOL inittext(VOID) -{ +BOOL inittext(VOID) { - OSVERSIONINFO osVer; // for GetVersionEx() + OSVERSIONINFO osVer; // for GetVersionEx() osVer.dwOSVersionInfoSize = sizeof(osVer); GetVersionEx(&osVer); if (osVer.dwPlatformId == VER_PLATFORM_WIN32s) { MessageBox(NULL, - "This FreeFEM++ cannot run on Windows 3.1.\n" - "This application will now terminate.", - "Error: Windows NT or Windows 95 Required to Run", MB_OK ); - return FALSE; // Console API is not able in Windows 3.1 - } + "This FreeFEM++ cannot run on Windows 3.1.\n" + "This application will now terminate.", + "Error: Windows NT or Windows 95 Required to Run", MB_OK); + return FALSE; // Console API is not able in Windows 3.1 + } // FreeConsole(); // If the console is already used - AllocConsole(); // Use the console API - SetcppIo(); + AllocConsole( ); // Use the console API + SetcppIo( ); - /* - freopen("conin$", "r", stdin); - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); - */ + /* + freopen("conin$", "r", stdin); + freopen("conout$", "w", stdout); + freopen("conout$", "w", stderr); + */ - SetConsoleTitle(PACKAGE_STRING " console"); - return TRUE; + SetConsoleTitle(PACKAGE_STRING " console"); + return TRUE; } //*------- Modules for MS-Windows //*OT 12/3/1999 //* Get the buffer of the console //* The buffer is stored in the filename.log -BOOL GetConsoleBuff() -{ - CONSOLE_SCREEN_BUFFER_INFO csbi; //* to get buffer info +BOOL GetConsoleBuff( ) { + CONSOLE_SCREEN_BUFFER_INFO csbi; //* to get buffer info GetConsoleScreenBufferInfo(hConOut, &csbi); - COORD coordLine = {0,0}; - CHAR *szLine; //* buffer to read from the console (a line) + COORD coordLine = {0, 0}; + CHAR *szLine; //* buffer to read from the console (a line) DWORD dwCharsRead; char fname[255]; FILE *fp; - strcpy(fname,ChangePdeToExt(shortName,"log")); - if ((fp = fopen(fname,"w"))==NULL) { - perror(fname); - return FALSE; - } - - szLine = (CHAR *)malloc((csbi.dwSize.X+1) * sizeof(CHAR)); - for (int i=0; i 0)) szLine[j--] =0; - if (j < csbi.dwSize.X-1) szLine[j+1] = '\n'; - fprintf(fp,"%s",szLine); + int j = csbi.dwSize.X - 1; + while ((szLine[j] == ' ') && (j > 0)) szLine[j--] = 0; + if (j < csbi.dwSize.X - 1) szLine[j + 1] = '\n'; + fprintf(fp, "%s", szLine); coordLine.Y++; } fclose(fp); @@ -1088,52 +999,50 @@ BOOL GetConsoleBuff() //* Open the filename.log by the editor //* default editor is notepad.exe //* Using variable "ffemEd", we can change the editor -BOOL EditLog() -{ +BOOL EditLog( ) { char *editor, fname[256], cmdLine[255]; - strcpy(fname,ChangePdeToExt(shortName,"log")); + strcpy(fname, ChangePdeToExt(shortName, "log")); editor = getenv("ffed"); if (editor == 0) - sprintf(cmdLine,"notepad.exe %s",fname); - else - sprintf(cmdLine,"%s %s",editor,fname); - - if (WinExec(cmdLine,SW_SHOWNORMAL) < 31) { - sprintf(errbuf,"Cannot execute [%s]",cmdLine); - FatalErr(errbuf,99); - return FALSE; + sprintf(cmdLine, "notepad.exe %s", fname); + else + sprintf(cmdLine, "%s %s", editor, fname); + + if (WinExec(cmdLine, SW_SHOWNORMAL) < 31) { + sprintf(errbuf, "Cannot execute [%s]", cmdLine); + FatalErr(errbuf, 99); + return FALSE; } - FreeConsole(); + FreeConsole( ); return true; } -void Usage() -{ - cout << "Usage: freefem++ [options]" << endl; - cout << "Select a program file by the dialog box if option is omitted.\n[option]" << endl; - cout << "-f filename: Run the program file \"filename\"." << endl; - cout << " In this mode, all plotted datas are stored in the \".\\cache\"." << endl; - cout << " The stored datas are used in \"WinfFEM\" (IDE for freefem+)." << endl; - cout << " You can get this from ." << endl; - cout << "-s : No wait at end." << endl; - cout << "-b : Do not use the color" << endl; - cout << "-n : Do not open the log file at end. The editor is the notepad if you do not" << endl; - cout << " set \"ffed=[name of editor]\" in environments." << endl; - cout << "-h : Display the usage (this)." << endl; +void Usage( ) { + cout << "Usage: freefem++ [options]" << endl; + cout << "Select a program file by the dialog box if option is omitted.\n[option]" << endl; + cout << "-f filename: Run the program file \"filename\"." << endl; + cout << " In this mode, all plotted datas are stored in the \".\\cache\"." << endl; + cout << " The stored datas are used in \"WinfFEM\" (IDE for freefem+)." << endl; + cout << " You can get this from ." << endl; + cout << "-s : No wait at end." << endl; + cout << "-b : Do not use the color" << endl; + cout << "-n : Do not open the log file at end. The editor is the notepad if you do not" << endl; + cout << " set \"ffed=[name of editor]\" in environments." << endl; + cout << "-h : Display the usage (this)." << endl; } // freefem+ arg1 arg2 arg3 // Hack the args and analysis -int StoreFname(char Line[], int len) -{ - char msg[256]; char *ext; +int StoreFname(char Line[], int len) { + char msg[256]; + char *ext; // ALH - 2/6/04 - add treatments for names surrounded with quotes // (but still breaks on names including quotes). char stopchar = ' '; bool skipone = false; - if(Line[0] == '"' || Line[0] == '\''){ + if (Line[0] == '"' || Line[0] == '\'') { stopchar = Line[0]; skipone = true; } @@ -1141,24 +1050,28 @@ int StoreFname(char Line[], int len) // Copies the name string, including its surrounding quotes if // necessary. int i; - int j=0; - for (i=0; i0 )||isdigit(c) )) - if(isdigit(c)) vv+= c; - verbosity=atoi(vv.c_str()); - } - case 's': // not wait at end of execution - winf_flg |= winf_NOWAIT; ++i; - break; - case 'b': // no color - winf_flg |= winf_NOCOLOR; ++i; - break; - case 'n': - winf_flg |= winf_NOEDIT; ++i; - break; - case 'h': - winf_flg |= winf_Usage; ++i; - break; - default: - while (lpszCmdLine[i]!=' ' && (i < CmdLen)) - i++; + switch (lpszCmdLine[i]) { + case 'f': + i++; + while (lpszCmdLine[i] == ' ') ++i; + i += StoreFname(&lpszCmdLine[i], CmdLen - i); + winf_flg |= winf_VFFEM; + break; + case 'v': { + string vv; + char c; + while (i < CmdLen && ((isspace(c = lpszCmdLine[i++]) && vv.length( ) > 0) || isdigit(c))) + if (isdigit(c)) vv += c; + verbosity = atoi(vv.c_str( )); + } + case 's': // not wait at end of execution + winf_flg |= winf_NOWAIT; + ++i; + break; + case 'b': // no color + winf_flg |= winf_NOCOLOR; + ++i; + break; + case 'n': + winf_flg |= winf_NOEDIT; + ++i; + break; + case 'h': + winf_flg |= winf_Usage; + ++i; + break; + default: + while (lpszCmdLine[i] != ' ' && (i < CmdLen)) i++; } - } - else { - i += StoreFname(&lpszCmdLine[i],CmdLen-i); + } else { + i += StoreFname(&lpszCmdLine[i], CmdLen - i); break; } } @@ -1234,93 +1146,83 @@ DWORD GetOption(char lpszCmdLine[]) * 3) Show the desktop window in the manner requested by the User. * */ -BOOL Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpszCmdLine, int nCmdShow) -{ +BOOL Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { DWORD dwStyle = WS_OVERLAPPEDWINDOW; - if (!hPrevInstance) - { + if (!hPrevInstance) { /* Register Class for First Overlapped Window */ - rClass.lpszClassName = "FreeFem++" ; - rClass.hInstance = hInstance; - rClass.lpfnWndProc = OpenWindowProc1; - rClass.hCursor = LoadCursor(NULL, IDC_ARROW); - rClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + rClass.lpszClassName = "FreeFem++"; + rClass.hInstance = hInstance; + rClass.lpfnWndProc = OpenWindowProc1; + rClass.hCursor = LoadCursor(NULL, IDC_ARROW); + rClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); rClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); - rClass.style = 0x4000; - rClass.cbClsExtra = 0; - rClass.cbWndExtra = 0; - - if (!RegisterClass( &rClass)) - return FALSE; - } - int dd=600; - int ddx0=200; - int ddy0=30; -// long dwFlags; -/* DEVMODE dev_mode = {0}; - if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dev_mode)) - { - cout << " screen size ?? " << dev_mode.dmPelsWidth << " x " << dev_mode.dmPelsHeight << endl; - dd = Min(dev_mode.dmPelsWidth*0.7,dev_mode.dmPelsHeight*0.9); - ddx0 = dev_mode.dmPelsWidth*0.28; - ddy0=dev_mode.dmPelsHeight*0.05; - } - else cout << " Error EnumDisplaySettings => no screen size " << endl; + rClass.style = 0x4000; + rClass.cbClsExtra = 0; + rClass.cbWndExtra = 0; - */ + if (!RegisterClass(&rClass)) return FALSE; + } + int dd = 600; + int ddx0 = 200; + int ddy0 = 30; + // long dwFlags; + /* DEVMODE dev_mode = {0}; + if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dev_mode)) + { + cout << " screen size ?? " << dev_mode.dmPelsWidth << " x " << dev_mode.dmPelsHeight << endl; + dd = Min(dev_mode.dmPelsWidth*0.7,dev_mode.dmPelsHeight*0.9); + ddx0 = dev_mode.dmPelsWidth*0.28; + ddy0=dev_mode.dmPelsHeight*0.05; + } + else cout << " Error EnumDisplaySettings => no screen size " << endl; + + */ int sx = GetSystemMetrics(SM_CXSCREEN); int sy = GetSystemMetrics(SM_CYSCREEN); - dd = static_cast(Min(sx*0.7,sy*0.9)); - ddx0 = static_cast(sx*0.28); - ddy0 = static_cast(sy*0.05); + dd = static_cast< int >(Min(sx * 0.7, sy * 0.9)); + ddx0 = static_cast< int >(sx * 0.28); + ddy0 = static_cast< int >(sy * 0.05); - //cout << " Screen Size " << sx << " x " << sy << endl; - // Rectangle ss=Get_VirtualScreen(); - // dd=(Abs(ss.get_Top-ss.get_Bottom())*90)/100; + // cout << " Screen Size " << sx << " x " << sy << endl; + // Rectangle ss=Get_VirtualScreen(); + // dd=(Abs(ss.get_Top-ss.get_Bottom())*90)/100; GetOption(lpszCmdLine); - hWnd = CreateWindow("FreeFEM++", - PACKAGE_STRING " for Windows", - dwStyle,ddx0,ddy0,dd,dd,/* - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT,*/ - NULL, - NULL, - hInstance, - NULL); - - - if (*fullName == '\0' && (winf_flg != winf_Usage)) { // in command line, there is no filename - if (ShowOpenDialogBox(shortName)==FALSE) { - exit(0); + hWnd = CreateWindow("FreeFEM++", PACKAGE_STRING " for Windows", dwStyle, ddx0, ddy0, dd, dd, /* + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT,*/ + NULL, NULL, hInstance, NULL); + + if (*fullName == '\0' && (winf_flg != winf_Usage)) { // in command line, there is no filename + if (ShowOpenDialogBox(shortName) == FALSE) { + exit(0); } - strcpy(fullName,shortName); + strcpy(fullName, shortName); } - if (inittext()==FALSE) + if (inittext( ) == FALSE) myexit(1); - else if (winf_flg & winf_VFFEM ) { // create only cache, option "-f" is given - if (!getcwd(FreeFemCache,MAX_PATH)) { - FatalErr("Fail to get current path",-1); - } - strcat(FreeFemCache,"\\cache\\"); + else if (winf_flg & winf_VFFEM) { // create only cache, option "-f" is given + if (!getcwd(FreeFemCache, MAX_PATH)) { + FatalErr("Fail to get current path", -1); + } + strcat(FreeFemCache, "\\cache\\"); - if (chdir(FreeFemCache)) { // check the cache directory + if (chdir(FreeFemCache)) { // check the cache directory #ifndef __CYGWIN__ - if (mkdir(FreeFemCache)) { + if (mkdir(FreeFemCache)) { #else - if (mkdir(FreeFemCache,0777)) { + if (mkdir(FreeFemCache, 0777)) { #endif - sprintf(errbuf,"Fail to create the directory %s",FreeFemCache); - FatalErr(errbuf,-1); - } - } - else (chdir("..\\")); // already created - return TRUE; + sprintf(errbuf, "Fail to create the directory %s", FreeFemCache); + FatalErr(errbuf, -1); + } + } else + (chdir("..\\")); // already created + return TRUE; }; return TRUE; @@ -1334,16 +1236,11 @@ BOOL Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, * lParam - 32-bit parameter * */ -LONG WINAPI OpenWindowProc1( - HWND hWnd, - UINT wMsgID, - WPARAM wParam, - LPARAM lParam) -{ +LONG WINAPI OpenWindowProc1(HWND hWnd, UINT wMsgID, WPARAM wParam, LPARAM lParam) { switch (wMsgID) { case WM_DESTROY: PostQuitMessage(0); - DestroyWindow(hWnd); + DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, wMsgID, wParam, lParam); @@ -1352,133 +1249,129 @@ LONG WINAPI OpenWindowProc1( return 0; } - //*OT 29/12/98 // Routines and functions for WinfFEM -int chkCacheDir(); +int chkCacheDir( ); BOOL TestProjetPresence(char *shortName); BOOL CreateProjetFile(char *shortName); BOOL SaveLogFile(char *fileName); void GetOption(int argc, char *argv[]); -FILE *projet=NULL; +FILE *projet = NULL; // end - -int WINAPI WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpszCmdLine, // int argc, char *argv[] - int nCmdShow) -{ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, // int argc, char *argv[] + int nCmdShow) { MSG msg; - LPTSTR cmd = GetCommandLine(); - if (Init(hInstance, hPrevInstance,lpszCmdLine,nCmdShow)) { - // main after checking options - if (mainFreeFEM() == FALSE) - myexit(99); // exit with error - else myexit(0); - - while (GetMessage(&msg,NULL,0,0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - myexit(msg.wParam); // exit(msg.wParam); - } - return -1; + LPTSTR cmd = GetCommandLine( ); + if (Init(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)) { + // main after checking options + if (mainFreeFEM( ) == FALSE) + myexit(99); // exit with error + else + myexit(0); + + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + myexit(msg.wParam); // exit(msg.wParam); + } + return -1; } // the real main - -extern int mymain(int argc,char **argv); +extern int mymain(int argc, char **argv); // main() in FreeFEM+ for PCs -BOOL mainFreeFEM() -{ - char prjName[256]; +BOOL mainFreeFEM( ) { + char prjName[256]; - if (winf_flg & winf_VFFEM) { // given by "-f filename" - strcpy(prjName,ChangePdeToExt(shortName,"prj")); + if (winf_flg & winf_VFFEM) { // given by "-f filename" + strcpy(prjName, ChangePdeToExt(shortName, "prj")); - if (strcmp(FreeFemCache,"")!=0) - if (CreateProjetFile(prjName)==FALSE) - FatalErr(prjName,-1); - } + if (strcmp(FreeFemCache, "") != 0) + if (CreateProjetFile(prjName) == FALSE) FatalErr(prjName, -1); + } - cout << "Welcome to freefem++ v " << StrVersionNumber() <= 0 ; i-- ) { // loop 1 - if ( fullname[i] == '\\' ) { - for ( j = i+1, k=0 ; j < tail ; j++, k++ ) - *(shortname + k) = *(fullname + j ) ; - *(shortname + k) = '\0'; - break; - } + for (i = tail - 1; i >= 0; i--) { // loop 1 + if (fullname[i] == '\\') { + for (j = i + 1, k = 0; j < tail; j++, k++) *(shortname + k) = *(fullname + j); + *(shortname + k) = '\0'; + break; + } } - if (i == -1) - strcpy(shortname,fullname); + if (i == -1) strcpy(shortname, fullname); - return 0 ; // OK! + return 0; // OK! } - -void ShowHelp(const char * s,int k) -{ - if(k) { +void ShowHelp(const char *s, int k) { + if (k) { MettreDansPostScript(0); - MettreDansPDF(0); // add by fujiwara - MettreDansSVG(0); // add by fujiwara + MettreDansPDF(0); // add by fujiwara + MettreDansSVG(0); // add by fujiwara couleur(1); - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + rmoveto(xmin + (xmax - xmin) / 100, ymax - (k) * (ymax - ymin) / 30); plotstring(s); MettreDansPostScript(1); - MettreDansPDF(1); // add by fujiwara - MettreDansSVG(1); // add by fujiwara - // couleur(1); + MettreDansPDF(1); // add by fujiwara + MettreDansSVG(1); // add by fujiwara + // couleur(1); } } -char *ChangePdeToExt(char *fileName,char *ext) -{ - int len; - - len=strlen(fileName); - char *file = new char[len+1]; - for(int i=0; i -#define MAXPATH 256 -char * getOp(const char *what) -{ - int tail=0, len=0; - char *p; - - p = strrchr(what, '\\'); - if (p == NULL) p = (char *)what; - while (*p && (*p != ' ')) p++; - if (*p) *p++ = '\0'; - else return NULL; - while (*p && (*p == ' ')) p++; - if (*p) return p; - else return NULL; +#define MAXPATH 256 +char *getOp(const char *what) { + int tail = 0, len = 0; + char *p; + + p = strrchr(what, '\\'); + if (p == NULL) p = (char *)what; + while (*p && (*p != ' ')) p++; + if (*p) + *p++ = '\0'; + else + return NULL; + while (*p && (*p == ' ')) p++; + if (*p) + return p; + else + return NULL; } -#ifdef WWWWWWWWWWWWWWWWWWWW -int execute(const char* what) -{ +#ifdef WWWWWWWWWWWWWWWWWWWW +int execute(const char *what) { char szBuffer[MAXPATH + 1]; char *option; - int r=0; - char *vide=""; + int r = 0; + char *vide = ""; option = getOp(what); - if(!option) - option = vide; - cout << "excute :: " < @@ -63,11 +63,11 @@ typedef char *caddr_t; #include #include #endif -#undef index +#undef index #include "rgraph.hpp" -#include // add by fujiwara -#include "pdf.h" // add by fujiwara +#include // add by fujiwara +#include "pdf.h" // add by fujiwara #ifdef macintoshxx #include @@ -76,130 +76,127 @@ typedef char *caddr_t; #include #endif -template inline T Min (const T &a,const T &b){return a < b ? a : b;} -template inline T Max (const T &a,const T & b){return a > b ? a : b;} - +template< class T > +inline T Min(const T &a, const T &b) { + return a < b ? a : b; +} +template< class T > +inline T Max(const T &a, const T &b) { + return a > b ? a : b; +} -static long cube6[7][3] ={ { 65535,32000,32000},{ 65535, 65535,0},{0, 65535,0},{0, 65535, 65535},{0,0, 65535} - , { 65535,0, 65535},{ 32000,0,0} }; -static long grey6[2][3] ={ {65534,65534,65534},{0,0,0} }; +static long cube6[7][3] = {{65535, 32000, 32000}, {65535, 65535, 0}, {0, 65535, 0}, {0, 65535, 65535}, {0, 0, 65535}, {65535, 0, 65535}, {32000, 0, 0}}; +static long grey6[2][3] = {{65534, 65534, 65534}, {0, 0, 0}}; static FILE *psfile = 0; static FILE *psfile_save = 0; -static bool pdffile = false; // add by fujiwara -static char *pdffile_name = nullptr; // add by fujiwara -static float pdf_s = 1; // add by fujiwara -static std::stringstream pdffile_content; // add by fujiwara -static FILE *svgfile = 0; // add by fujiwara -static FILE *svgfile_save = 0; // add by fujiwara -static float svg_s = 1; // add by fujiwara -static int svg_r = 0; // add by fujiwara -static int svg_g = 0; // add by fujiwara -static int svg_b = 0; // add by fujiwara -static int svg_lw = 1; // add by fujiwara -static bool grey=false; -static int LastColor=2; // pour est en couleur par defaut +static bool pdffile = false; // add by fujiwara +static char *pdffile_name = nullptr; // add by fujiwara +static float pdf_s = 1; // add by fujiwara +static std::stringstream pdffile_content; // add by fujiwara +static FILE *svgfile = 0; // add by fujiwara +static FILE *svgfile_save = 0; // add by fujiwara +static float svg_s = 1; // add by fujiwara +static int svg_r = 0; // add by fujiwara +static int svg_g = 0; // add by fujiwara +static int svg_b = 0; // add by fujiwara +static int svg_lw = 1; // add by fujiwara +static bool grey = false; +static int LastColor = 2; // pour est en couleur par defaut const float fMinPixel = -32000; const float fMaxPixel = +32000; -#define reel float -static Display *display; -static Window win; -static XSizeHints size_hints; +#define reel float +static Display *display; +static Window win; +static XSizeHints size_hints; // static XEvent report; -static int ncolortable,fcolor; +static int ncolortable, fcolor; static XColor *colortable; -static GC gc; -static XFontStruct *font_info; -static int shift, control,shiftlock,alt; -static reel echx,echy,rxmin,rxmax,rymin,rymax; -static int lacouleur,screen, width, height, currx, curry; -static unsigned long background,foreground; -static Cursor cursor_watch,cursor_arrow; -static long NbErrX11 =0; -Colormap color_map,color_map_sys; +static GC gc; +static XFontStruct *font_info; +static int shift, control, shiftlock, alt; +static reel echx, echy, rxmin, rxmax, rymin, rymax; +static int lacouleur, screen, width, height, currx, curry; +static unsigned long background, foreground; +static Cursor cursor_watch, cursor_arrow; +static long NbErrX11 = 0; +Colormap color_map, color_map_sys; #define call(i) i -static Visual *visual; -static int INITGRAPH=0; -void myend() -{ - if (INITGRAPH) - closegraphique(); - cout << "the end" <error_code, msg, 80); - fprintf(stderr, "Error code %s\n", msg);} +int xerror(Display *display, XErrorEvent *myerr) { + if (NbErrX11++ < 10) { + char msg[80]; + XGetErrorText(display, myerr->error_code, msg, 80); + fprintf(stderr, "Error code %s\n", msg); + } return 0; } @@ -210,336 +207,294 @@ void xerror() assert(0); } */ -void xerrorio() -{ - +void xerrorio( ) { + fprintf(stderr, "Fatal erreur avec X-Windows\n"); assert(0); exit(2); } -void MyXSelectInput(Display * dpy,Window w,int mask) +void MyXSelectInput(Display *dpy, Window w, int mask) { XSetWindowAttributes attributes; attributes.event_mask = mask; XChangeWindowAttributes(dpy, w, CWEventMask, &attributes); } -int LaCouleur() {return lacouleur;} +int LaCouleur( ) { return lacouleur; } -void couleur(int c) -{ - if ( lacouleur == c) // small optim +void couleur(int c) { + if (lacouleur == c) // small optim return; - c= c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc - lacouleur = c; - if (colortable) - { - if (c>=0 && c < ncolortable) - XSetForeground(display,gc,colortable[c].pixel); - else - XSetForeground(display,gc,foreground); - } -else - if ( c == 0 ) - XSetForeground(display,gc,background); + c = c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc + lacouleur = c; + if (colortable) { + if (c >= 0 && c < ncolortable) + XSetForeground(display, gc, colortable[c].pixel); + else + XSetForeground(display, gc, foreground); + } else if (c == 0) + XSetForeground(display, gc, background); else - XSetForeground(display,gc,foreground); - if (psfile) - { - float r=1,g=1,b=1; + XSetForeground(display, gc, foreground); + if (psfile) { + float r = 1, g = 1, b = 1; if (colortable) { - if (c>0 && c < ncolortable) - { - r = (float) colortable[c].red /65535.; - g = (float) colortable[c].green /65535.; - b = (float) colortable[c].blue /65535.; - } - } - else if (c!=0) - r=g=b=0; - - fprintf(psfile,"%.3f %.3f %.3f C\n",r,g,b); + if (c > 0 && c < ncolortable) { + r = (float)colortable[c].red / 65535.; + g = (float)colortable[c].green / 65535.; + b = (float)colortable[c].blue / 65535.; + } + } else if (c != 0) + r = g = b = 0; + + fprintf(psfile, "%.3f %.3f %.3f C\n", r, g, b); + } + // add by fujiwara + if (pdffile) { + pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; + pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; + } + if (svgfile) { + svg_r = static_cast< int >(r * 256); + svg_g = static_cast< int >(g * 256); + svg_b = static_cast< int >(b * 256); } - // add by fujiwara - if( pdffile ){ - pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; - pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; - } - if( svgfile ){ - svg_r = static_cast(r*256); - svg_g = static_cast(g*256); - svg_b = static_cast(b*256); - } } +static XColor DefColorX11(int k, int nb, bool hsv, bool grey, int nbcolors, float *colors) { + XColor C; + float r, g, b; + extern void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, int nbcolors, float *colors); + DefColor(r, g, b, k, nb, hsv, grey, nbcolors, colors); + C.red = 65535 * r; + C.green = 65535 * g; + C.blue = 65535 * b; + C.flags = DoRed | DoGreen | DoBlue; + C.pixel = k; + // cout << " color : " << k << " " << C.red << " "<< C.green << " " << C.blue << " " << r << endl; + return C; +} -static XColor DefColorX11( int k,int nb, bool hsv,bool grey,int nbcolors,float *colors) -{ - XColor C; - float r,g,b; -extern void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,int nbcolors,float *colors); - DefColor(r,g,b, k,nb,hsv,grey,nbcolors,colors); - C.red=65535*r; - C.green=65535*g; - C.blue=65535*b; - C.flags = DoRed | DoGreen | DoBlue; - C.pixel=k; - // cout << " color : " << k << " " << C.red << " "<< C.green << " " << C.blue << " " << r << endl; - return C; -} - -void SetColorTable1(int nb,bool hsv,int nbcolors,float *colors) -{ +void SetColorTable1(int nb, bool hsv, int nbcolors, float *colors) { static bool greyo = !grey; - static float * colorso =0; - if(!INITGRAPH) return; - if (ncolortable == nb && greyo == grey && colorso == colors ) return;// optim - greyo = grey; - colorso=colors; - if (fcolor && nb>2 && nb < 256) - { - if(colortable) delete [] colortable; - colortable = new XColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - for (int i0=0;i0c_class != TrueColor) - { - // cout << "XStoreColors( not TrueColor)" << ncolortable << " " << - XStoreColors (display, color_map, colortable, ncolortable) ; - // << endl; - } - else - { - // cout << "XAllocColor (TrueColor)" << endl; - for (int i=0;i 2 && nb < 256) { + if (colortable) delete[] colortable; + colortable = new XColor[nb]; + ncolortable = nb; + if (LastColor > 1) LastColor = nb - 1; + for (int i0 = 0; i0 < nb; i0++) { + colortable[i0] = DefColorX11(i0, nb, hsv, grey, nbcolors, colors); + } + background = 0; + foreground = 1; + if (visual->c_class != TrueColor) { + // cout << "XStoreColors( not TrueColor)" << ncolortable << " " << + XStoreColors(display, color_map, colortable, ncolortable); + // << endl; + } else { + // cout << "XAllocColor (TrueColor)" << endl; + for (int i = 0; i < ncolortable; i++) XAllocColor(display, color_map, colortable + i); + background = colortable[background].pixel; + foreground = colortable[foreground].pixel; + } + if (win) { + XGCValues gcvalues; + gcvalues.foreground = foreground; + gcvalues.background = background; + gc = XCreateGC(display, win, GCForeground | GCBackground, &gcvalues); + } + } } -void SetColorTable(int nb) -{ +void SetColorTable(int nb) { int i; - if (fcolor && nb>2 && nb < 256) - { - nb = Max(nb,8); - if (ncolortable == nb) return;// optim - if(colortable) delete [] colortable; - colortable = new XColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - int k=0; - colortable[k].pixel=k; - colortable[k].red= 65535; - colortable[k].green= 65535; - colortable[k].blue= 65535; - colortable[k].flags = DoRed | DoGreen | DoBlue; - background=k; - k++; - colortable[k].pixel=k; - colortable[k].red=0; - colortable[k].green=0; - colortable[k].blue=0; - colortable[k].flags = DoRed | DoGreen | DoBlue; - foreground=k; - k++; - nb = nb -2; - for (long i0=0;i0 2 && nb < 256) { + nb = Max(nb, 8); + if (ncolortable == nb) return; // optim + if (colortable) delete[] colortable; + colortable = new XColor[nb]; + ncolortable = nb; + if (LastColor > 1) LastColor = nb - 1; + int k = 0; + colortable[k].pixel = k; + colortable[k].red = 65535; + colortable[k].green = 65535; + colortable[k].blue = 65535; + colortable[k].flags = DoRed | DoGreen | DoBlue; + background = k; + k++; + colortable[k].pixel = k; + colortable[k].red = 0; + colortable[k].green = 0; + colortable[k].blue = 0; + colortable[k].flags = DoRed | DoGreen | DoBlue; + foreground = k; + k++; + nb = nb - 2; + for (long i0 = 0; i0 < nb; i0++, k++) { + // long i1 = nb - i0; + long i6 = i0 * 6; + long j0 = i6 / nb; // in 0..6 + long j1 = j0 + 1; // in 1..6 + long k0 = i0 - (nb * j0) / 6L; + long k1 = (nb * j1) / 6L - i0; + long kk = k0 + k1; + // cout <bits_per_rgb; - color_map_sys = DefaultColormap (display, DefaultScreen (display)); + visual = DefaultVisual(display, DefaultScreen(display)); + fcolor = 0; /* pas couleur */ + int fstereo = 0; /* non */ + int nbplans = visual->bits_per_rgb; + color_map_sys = DefaultColormap(display, DefaultScreen(display)); color_map = color_map_sys; - foreground= BlackPixel(display, screen); - background= WhitePixel(display, screen); - - switch (visual->c_class) - { - case GrayScale: {break;} - case PseudoColor: - { - cout << " PseudoColor nbcolor =" << visual->map_entries << endl; - color_map= XCreateColormap (display, RootWindow (display, DefaultScreen (display)), - visual,AllocAll); - // copy the def color map - for (int i=0;imap_entries;i++) - { XColor colorcell_defs; - colorcell_defs.pixel = (unsigned long) i; - XQueryColor (display, color_map_sys, &colorcell_defs); - XStoreColor (display, color_map, &colorcell_defs); - } - fcolor=1; - - SetColorTable(8); // set - break; - } - case DirectColor: - { - cout << " DirectColor " << endl; - fcolor=1; - SetColorTable(8); // set - break; - } - case TrueColor : - { - cout << " TrueColor " << endl; - fcolor=1; - SetColorTable(8); // set - break; - } - } + foreground = BlackPixel(display, screen); + background = WhitePixel(display, screen); + + switch (visual->c_class) { + case GrayScale: { + break; + } + case PseudoColor: { + cout << " PseudoColor nbcolor =" << visual->map_entries << endl; + color_map = XCreateColormap(display, RootWindow(display, DefaultScreen(display)), visual, AllocAll); + // copy the def color map + for (int i = 0; i < visual->map_entries; i++) { + XColor colorcell_defs; + colorcell_defs.pixel = (unsigned long)i; + XQueryColor(display, color_map_sys, &colorcell_defs); + XStoreColor(display, color_map, &colorcell_defs); + } + fcolor = 1; + + SetColorTable(8); // set + break; + } + case DirectColor: { + cout << " DirectColor " << endl; + fcolor = 1; + SetColorTable(8); // set + break; + } + case TrueColor: { + cout << " TrueColor " << endl; + fcolor = 1; + SetColorTable(8); // set + break; + } + } font_info = XLoadQueryFont(display, "6x9"); if (!font_info) font_info = XLoadQueryFont(display, "6x10"); - if( !font_info) {cout << " erreur font 6x10 and 6x9 not found !\n";exit(2);}; + if (!font_info) { + cout << " erreur font 6x10 and 6x9 not found !\n"; + exit(2); + }; XSetErrorHandler((XErrorHandler)xerror); XSetIOErrorHandler((XIOErrorHandler)xerrorio); screen = DefaultScreen(display); width = DisplayWidth(display, screen); height = DisplayHeight(display, screen); - ddd = width < height ? width : height; - width = ddd*8/10; - height = ddd*8/10; - + ddd = width < height ? width : height; + width = ddd * 8 / 10; + height = ddd * 8 / 10; attributes.background_pixel = background; - attributes.border_pixel = foreground; - attributes.backing_store = Always; - attributes.colormap = color_map; - - win = XCreateWindow(display, RootWindow(display, DefaultScreen(display)), - 50, 80, width, height,4, - CopyFromParent, InputOutput, visual, - CWBackPixel | CWBorderPixel | CWBackingStore | CWColormap, - &attributes); - char title[256]; - sprintf(title,"%s%s","FreeFrem++ ",StrVersionNumber().c_str()); - XChangeProperty(display, win, XA_WM_NAME, XA_STRING, 8 - , PropModeReplace,(const unsigned char *) title , strlen(title)); - - - - + attributes.border_pixel = foreground; + attributes.backing_store = Always; + attributes.colormap = color_map; + + win = XCreateWindow(display, RootWindow(display, DefaultScreen(display)), 50, 80, width, height, 4, CopyFromParent, InputOutput, visual, CWBackPixel | CWBorderPixel | CWBackingStore | CWColormap, + &attributes); + char title[256]; + sprintf(title, "%s%s", "FreeFrem++ ", StrVersionNumber( ).c_str( )); + XChangeProperty(display, win, XA_WM_NAME, XA_STRING, 8, PropModeReplace, (const unsigned char *)title, strlen(title)); + gcvalues.foreground = foreground; gcvalues.background = background; - gcvalues.function = GXcopy ; + gcvalues.function = GXcopy; gc = XCreateGC(display, win, GCForeground | GCBackground | GCFunction, &gcvalues); - - XSetFillRule(display,gc,WindingRule); - - + + XSetFillRule(display, gc, WindingRule); + // win = XCreateSimpleWindow(display, RootWindow(display, screen), 50, 80, width, height, 4, // foreground,background); - cursor_arrow = XCreateFontCursor(display,XC_arrow); - cursor_watch = XCreateFontCursor(display,XC_watch); - + cursor_arrow = XCreateFontCursor(display, XC_arrow); + cursor_watch = XCreateFontCursor(display, XC_watch); + size_hints.flags = PPosition | PSize; size_hints.x = 0; size_hints.y = 0; @@ -547,38 +502,31 @@ void initgraphique() size_hints.height = height; XSetFont(display, gc, font_info->fid); - XSetForeground(display, gc, foreground); + XSetForeground(display, gc, foreground); XMapWindow(display, win); - MyXSelectInput (display, win, (int) (ExposureMask - | KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - /* | ResizeRedirectMask */ - | StructureNotifyMask) - ); - + MyXSelectInput(display, win, + (int)(ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | + ButtonReleaseMask + /* | ResizeRedirectMask */ + | StructureNotifyMask)); + // do XNextEvent(display, &report); while (report.type != Expose); - XDefineCursor(display,win,cursor_watch); - XFlush(display); + XDefineCursor(display, win, cursor_watch); + XFlush(display); INITGRAPH = 1; - } -void closegraphique() -{ - if (INITGRAPH) - { - INITGRAPH = 0; - XUnloadFont(display, font_info->fid); - XFreeGC(display, gc); - XCloseDisplay(display); - closePS(); - } +void closegraphique( ) { + if (INITGRAPH) { + INITGRAPH = 0; + XUnloadFont(display, font_info->fid); + XFreeGC(display, gc); + XCloseDisplay(display); + closePS( ); + } } -void cadre(reel xmin,reel xmax,reel ymin,reel ymax) -{ +void cadre(reel xmin, reel xmax, reel ymin, reel ymax) { rxmin = xmin; rxmax = xmax; rymin = ymin; @@ -588,90 +536,55 @@ void cadre(reel xmin,reel xmax,reel ymin,reel ymax) echy = height / (ymax - ymin); } -void getcadre(reel &xmin,reel &xmax,reel &ymin,reel &ymax) -{ +void getcadre(reel &xmin, reel &xmax, reel &ymin, reel &ymax) { xmin = rxmin; xmax = rxmax; ymin = rymin; ymax = rymax; - -} - - -int InRecScreen(reel x1, reel y1,reel x2, reel y2) -{ - - return (Max(x1,x2)>= rxmin) && (Min(x1,x2) <= rxmax) && (Max(y1,y2) >= rymin) && (Min(y1,y2) <= rymax); -} -int InPtScreen( reel x, reel y) -{ - return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); } +int InRecScreen(reel x1, reel y1, reel x2, reel y2) { return (Max(x1, x2) >= rxmin) && (Min(x1, x2) <= rxmax) && (Max(y1, y2) >= rymin) && (Min(y1, y2) <= rymax); } +int InPtScreen(reel x, reel y) { return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); } +float scali(int i) { return i / echx + rxmin; } +float scalj(int j) { return -j / echy + rymax; } +int scalx(reel x) { return (int)Min(fMaxPixel, Max(fMinPixel, ((x - rxmin) * echx))); } +int scaly(reel y) { return (int)Min(fMaxPixel, Max(fMinPixel, ((rymax - y) * echy))); } +void pointe(reel x, reel y) { XDrawPoint(display, win, gc, scalx(x), scaly(y)); } -float scali(int i) -{ - return i/echx + rxmin; -} -float scalj(int j) -{ - return -j/echy + rymax; -} -int scalx(reel x) -{ - return (int) Min(fMaxPixel,Max(fMinPixel,((x - rxmin) * echx))); -} -int scaly(reel y) -{ - return (int)Min(fMaxPixel,Max(fMinPixel,((rymax - y) * echy))); -} - -void pointe(reel x, reel y) -{ - XDrawPoint(display, win, gc, scalx(x), scaly(y)); -} - -void rmoveto(reel x, reel y) -{ +void rmoveto(reel x, reel y) { currx = scalx(x); curry = scaly(y); } -void rlineto(reel x, reel y) -{ +void rlineto(reel x, reel y) { int newx = scalx(x), newy = scaly(y); XDrawLine(display, win, gc, currx, curry, newx, newy); - if (psfile) - fprintf(psfile,"%d %d %d %d L\n",currx, height-curry, newx, height-newy); + if (psfile) fprintf(psfile, "%d %d %d %d L\n", currx, height - curry, newx, height - newy); // add by fujiwara - if ( pdffile ){ - pdffile_content << currx*pdf_s << ' ' << (height-curry)*pdf_s << " m " - << newx*pdf_s << ' ' << (height-newy)*pdf_s << " l S" << std::endl; + if (pdffile) { + pdffile_content << currx * pdf_s << ' ' << (height - curry) * pdf_s << " m " << newx * pdf_s << ' ' << (height - newy) * pdf_s << " l S" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, newx*svg_s, newy*svg_s, svg_r, svg_g, svg_b, svg_lw); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, newx * svg_s, newy * svg_s, svg_r, svg_g, + svg_b, svg_lw); } - currx = newx; curry = newy; -/* XFlush(display); */ + currx = newx; + curry = newy; + /* XFlush(display); */ } -void cadreortho(reel centrex, reel centrey, reel rayon) -{ +void cadreortho(reel centrex, reel centrey, reel rayon) { // int xasp,yasp; - if (height < width) - { + if (height < width) { rymin = centrey - rayon; rymax = centrey + rayon; - echx = echy= height / (2 * rayon); - rxmin= centrex - width / (2 * echx); - rxmax= centrex + width / (2 * echx); - } - else - { + echx = echy = height / (2 * rayon); + rxmin = centrex - width / (2 * echx); + rxmax = centrex + width / (2 * echx); + } else { rxmin = centrex - rayon; rxmax = centrex + rayon; echx = echy = width / (2 * rayon); @@ -680,629 +593,594 @@ void cadreortho(reel centrex, reel centrey, reel rayon) } } -void plotstring (const char * string) -{ int lx,l = strlen(string); - XDrawString(display, win, gc, currx, curry , string, l); - lx = XTextWidth( font_info,string,l); - if(psfile) fprintf(psfile,"(%s) %d %d S\n",string,currx,height-curry); +void plotstring(const char *string) { + int lx, l = strlen(string); + XDrawString(display, win, gc, currx, curry, string, l); + lx = XTextWidth(font_info, string, l); + if (psfile) fprintf(psfile, "(%s) %d %d S\n", string, currx, height - curry); // add by fujiwara - if( pdffile ){ - pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size - pdffile_content << "1 0 0 1 " << currx*pdf_s << ' ' << (height-curry)*pdf_s << " Tm" << std::endl; - pdffile_content << "(" << string << ") Tj ET" << std::endl; + if (pdffile) { + pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size + pdffile_content << "1 0 0 1 " << currx * pdf_s << ' ' << (height - curry) * pdf_s << " Tm" << std::endl; + pdffile_content << "(" << string << ") Tj ET" << std::endl; } - if( svgfile ){ - fprintf(svgfile,"%s\n",currx*svg_s,curry*svg_s,string); + if (svgfile) { + fprintf(svgfile, "%s\n", currx * svg_s, curry * svg_s, string); } - currx += lx; + currx += lx; } -void showgraphic() -{ -} +void showgraphic( ) {} -void x11draw3(int * ptype) -{ +void x11draw3(int *ptype) { XGCValues gcvalues; int type; - type= *ptype; - switch (type) - { - case 0 : {gcvalues.line_style = LineSolid; break;} - case 1 : {gcvalues.line_style = LineOnOffDash; break;} - default : {gcvalues.line_style = LineDoubleDash;break;} + type = *ptype; + switch (type) { + case 0: { + gcvalues.line_style = LineSolid; + break; + } + case 1: { + gcvalues.line_style = LineOnOffDash; + break; + } + default: { + gcvalues.line_style = LineDoubleDash; + break; + } } XChangeGC(display, gc, GCLineStyle, &gcvalues); - if (psfile) - switch (type) { - case 0 : {fprintf(psfile,"[] setdash\n");break;} - case 1 : {fprintf(psfile,"[3] setdash\n");break;} - default : {fprintf(psfile,"[4 1] setdash\n");break;} + if (psfile) switch (type) { + case 0: { + fprintf(psfile, "[] setdash\n"); + break; + } + case 1: { + fprintf(psfile, "[3] setdash\n"); + break; + } + default: { + fprintf(psfile, "[4 1] setdash\n"); + break; + } } // add by fujiwara - if ( pdffile ){ - // should be added + if (pdffile) { + // should be added } - if ( svgfile ){ - // should be added + if (svgfile) { + // should be added } -} +} -void penthickness(int pepais) -{ +void penthickness(int pepais) { XGCValues gcvalues; gcvalues.line_width = pepais; XChangeGC(display, gc, GCLineWidth, &gcvalues); - if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais); + if (psfile) fprintf(psfile, "%d setlinewidth\n", pepais); // add by fujiwara - if ( pdffile ){ - pdffile_content << pepais << " w" << std::endl; + if (pdffile) { + pdffile_content << pepais << " w" << std::endl; } - if ( svgfile ){ - svg_lw = pepais; + if (svgfile) { + svg_lw = pepais; } - } - -void x11linsrn(int * x1,int * x2,int * y1,int * y2) - //int *x1,*x2,*y1,*y2; -{ - XDrawLine(display, win, gc, *x1, *x2, *y1, *y2); -/* call(viderbuff)(); */ -} - - -void viderbuff() +void x11linsrn(int *x1, int *x2, int *y1, int *y2) +// int *x1,*x2,*y1,*y2; { - XRaiseWindow (display,win); - XFlush(display); + XDrawLine(display, win, gc, *x1, *x2, *y1, *y2); + /* call(viderbuff)(); */ } - - -void cercle(reel centrex, reel centrey, reel rayon) -{ - int r = (int) (rayon * echx); - XDrawArc(display, win, gc, - scalx(centrex) - r, scaly(centrey) - r, width, height, 0, 360 * 64); +void viderbuff( ) { + XRaiseWindow(display, win); XFlush(display); } -void reffecran() -{ - XClearWindow(display,win); + +void cercle(reel centrex, reel centrey, reel rayon) { + int r = (int)(rayon * echx); + XDrawArc(display, win, gc, scalx(centrex) - r, scaly(centrey) - r, width, height, 0, 360 * 64); + XFlush(display); } +void reffecran( ) { XClearWindow(display, win); } -void fillpoly(int n, float *poly) -{ +void fillpoly(int n, float *poly) { int i; - XPoint *poly0,polyloc[10]; - if(n<10) - poly0=polyloc; - else - if(poly0= (XPoint *) malloc(n*sizeof(XPoint)), !poly) - { + XPoint *poly0, polyloc[10]; + if (n < 10) + poly0 = polyloc; + else if (poly0 = (XPoint *)malloc(n * sizeof(XPoint)), !poly) { fprintf(stderr, "Erreur d'allocation dans raffpoly\n"); return; } - for(i=0; i\n", - svg_r,svg_g,svg_b, svg_lw, svg_r,svg_g,svg_b); - } + // add by fujiwara + if (pdffile) { + i = 0; + pdffile_content << scalx(poly[2 * i]) * pdf_s << ' ' << (height - scaly(poly[2 * i + 1])) * pdf_s << " m "; + for (i = 1; i < n; i++) pdffile_content << scalx(poly[2 * i]) * pdf_s << ' ' << (height - scaly(poly[2 * i + 1])) * pdf_s << " l "; + pdffile_content << "f" << std::endl; + } + if (svgfile) { + fprintf(svgfile, "\n", svg_r, svg_g, svg_b, svg_lw, svg_r, svg_g, svg_b); + } } #include "getprog-unix.hpp" +int execute(const char *str) { return system(str); } -int execute (const char * str) -{ - return system(str); -} - -char Getijc(int *x1,int *y1) -{ char char1; +char Getijc(int *x1, int *y1) { + char char1; XEvent event; - int flag,nb; + int flag, nb; XComposeStatus status; char buffer[20]; - KeySym keysym; /* incidence */ - XDefineCursor(display,win,cursor_arrow); - flag=0; - while (!flag) - { XNextEvent(display, &event); - if(event.type == ButtonRelease) - { *x1 = event.xbutton.x; - *y1 = event.xbutton.y; - if (event.xbutton.button == Button1) char1=shift?248:251; - else if (event.xbutton.button == Button2) char1=shift?249:252; - else char1=shift?250:253; + KeySym keysym; /* incidence */ + XDefineCursor(display, win, cursor_arrow); + flag = 0; + while (!flag) { + XNextEvent(display, &event); + if (event.type == ButtonRelease) { + *x1 = event.xbutton.x; + *y1 = event.xbutton.y; + if (event.xbutton.button == Button1) + char1 = shift ? 248 : 251; + else if (event.xbutton.button == Button2) + char1 = shift ? 249 : 252; + else + char1 = shift ? 250 : 253; // printf(" mouse release %d\n",(int) char1); - flag=1; - } - else if(event.type == KeyPress) - { *x1 = event.xkey.x; - *y1 = event.xkey.y; - char1= event.xkey.keycode ; - keysym=0; - nb=XLookupString(&event.xkey,buffer,20,&keysym,&status); - -/* printf("nb= %d keysym= %d buffer=",nb,keysym); -/* for(i=0;i<20;i++) -/* printf(" %d ",(int)buffer[i]); -/* printf("\n"); -*/ - -/* voir /usr/include/X11/keysymdef.h + ap_keysym */ - - if (nb != 0) - {char1 = buffer[0]; - flag= 1; - } - else - { -/* if (IsFunctionKey(keysym)) printf("function down\n"); - else if(IsModifierKey(keysym)) printf("modifier down\n"); - else if(IsKeypadKey(keysym)) printf(" keypad down\n"); - else if(IsMiscFunctionKey(keysym)) printf(" misc function down\n"); - else if(IsPFKey(keysym)) printf(" PF key down\n"); -*/ - - switch(keysym) - { -/* Cursor control & motion */ - /* - case XK_Left : - flag = 1; - char1 = call(keyboa).curs_left; - break; - case XK_Up : - flag = 1; - char1 = call(keyboa).curs_up; - break; - case XK_Right : - flag = 1; - char1 = call(keyboa).curs_right; - break; - case XK_Down : - flag = 1; - char1 = call(keyboa).curs_down; - break; - case XK_Next : - flag = 1; - char1 = call(keyboa).pad_down; - break; - case XK_Prior : - flag = 1; - char1 = call(keyboa).pad_up; - break; - case XK_End : - flag = 1; - char1 = call(keyboa).marg_right; - break; - case XK_Begin : - flag = 1; - char1 = call(keyboa).marg_left; - break; - */ -/* Misc Functions */ - /* - - case XK_Select : - flag = 1; - char1 = call(keyboa).mark; - break; */ -/* - case XK_Print : - flag = 1; - char1 = ; - break; - case XK_Execute : - flag = 1; - char1 = ; - break; - case XK_Insert : - flag = 1; - char1 = ; - break; - - case XK_Undo : - flag = 1; - char1 = call(keyboa).undo; - break; - - case XK_Redo : - flag = 1; - char1 = ; - break; - case XK_Menu : - flag = 1; - char1 = ; - break; - case XK_Find : - flag = 1; - char1 = ; - break; - - - case XK_Cancel : - flag = 1; - char1 = call(keyboa).line_del; - break; - case XK_Help : - flag = 1; - char1 = call(keyboa).help; - break; - - case XK_Break : - flag = 1; - char1 = ; - break; - case XK_Mode_switch : - flag = 1; - char1 = ; - break; - case XK_script_switch : - flag = 1; - char1 = ; - break; - case XK_Num_Lock : - flag = 1; - char1 = ; - break; - - case XK_F1 : - flag = 1; - char1 = shift ? call(keyboa).sfunct1 : call(keyboa).funct1 ; - break; - case XK_F2 : - flag = 1; - char1 = shift ? call(keyboa).sfunct2 : call(keyboa).funct2 ; - break; - case XK_F3 : - flag = 1; - char1 = shift ? call(keyboa).sfunct3 : call(keyboa).funct3 ; - break; - case XK_F4 : - flag = 1; - char1 = shift ? call(keyboa).sfunct4 : call(keyboa).funct4 ; - break; - case XK_F5 : - flag = 1; - char1 = shift ? call(keyboa).sfunct5 : call(keyboa).funct5 ; - break; - case XK_F6 : - flag = 1; - char1 = shift ? call(keyboa).sfunct6 : call(keyboa).funct6 ; - break; - case XK_F7 : - flag = 1; - char1 = shift ? call(keyboa).sfunct7 : call(keyboa).funct7 ; - break; - case XK_F8 : - flag = 1; - char1 = shift ? call(keyboa).sfunct8 : call(keyboa).funct8 ; - break; - case XK_F9 : - flag = 1; - char1 = shift ? call(keyboa).sfunct9 : call(keyboa).funct9 ; - break; - case XK_F10 : - flag = 1; - char1 = shift ? call(keyboa).sfunct10 : call(keyboa).funct10 ; - break; - case XK_F11 : - flag = 1; - char1 = shift ? call(keyboa).sfunct11 : call(keyboa).funct11 ; - break; - case XK_F12 : - flag = 1; - char1 = shift ? call(keyboa).sfunct12 : call(keyboa).funct12 ; - break; - */ - case XK_Shift_L : - shift=1; - break; - case XK_Shift_R : - shift=1; - break; - case XK_Control_L : - control=1; - break; - case XK_Control_R : - control=1; - break; - case XK_Caps_Lock : - shiftlock = 1 ; - break; - case XK_Shift_Lock : - shiftlock = 1 ; - break; - case XK_Meta_L : - alt=1; - break; - case XK_Meta_R : - alt=1; - break; - case XK_Alt_L : - alt=1; - break; - case XK_Alt_R : - alt=1; - break; - } /* end switch */ - } - } - else if(event.type == KeyRelease) - { *x1 = event.xkey.x; - *y1 = event.xkey.y; - char1= event.xkey.keycode ; - keysym=0; - nb=XLookupString(&event.xkey,buffer,20,&keysym,&status); -/* if (IsFunctionKey(keysym)) printf("function up\n"); - else if(IsModifierKey(keysym)) printf("modifier up\n"); - else if(IsKeypadKey(keysym)) printf(" keypad up\n"); - else if(IsMiscFunctionKey(keysym)) printf(" misc function up\n"); - else if(IsPFKey(keysym)) printf(" PF key up\n"); -*/ - if (nb == 0) - { - switch(keysym) - { - case XK_Shift_L : - shift=0; - break; - case XK_Shift_R : - shift=0; - break; - case XK_Control_L : - control=0; - break; - case XK_Control_R : - control=0; - break; - case XK_Caps_Lock : - shiftlock = 0 ; - break; - case XK_Shift_Lock : - shiftlock = 0 ; - break; - case XK_Meta_L : - alt=0; - break; - case XK_Meta_R : - alt=0; - break; - case XK_Alt_L : - alt=0; - break; - case XK_Alt_R : - alt=0; - break; - } /* end switch */ - - } + flag = 1; + } else if (event.type == KeyPress) { + *x1 = event.xkey.x; + *y1 = event.xkey.y; + char1 = event.xkey.keycode; + keysym = 0; + nb = XLookupString(&event.xkey, buffer, 20, &keysym, &status); + + /* printf("nb= %d keysym= %d buffer=",nb,keysym); + /* for(i=0;i<20;i++) + /* printf(" %d ",(int)buffer[i]); + /* printf("\n"); + */ + + /* voir /usr/include/X11/keysymdef.h + ap_keysym */ + + if (nb != 0) { + char1 = buffer[0]; + flag = 1; + } else { + /* if (IsFunctionKey(keysym)) printf("function down\n"); + else if(IsModifierKey(keysym)) printf("modifier down\n"); + else if(IsKeypadKey(keysym)) printf(" keypad down\n"); + else if(IsMiscFunctionKey(keysym)) printf(" misc function down\n"); + else if(IsPFKey(keysym)) printf(" PF key down\n"); + */ + + switch (keysym) { + /* Cursor control & motion */ + /* + case XK_Left : + flag = 1; + char1 = call(keyboa).curs_left; + break; + case XK_Up : + flag = 1; + char1 = call(keyboa).curs_up; + break; + case XK_Right : + flag = 1; + char1 = call(keyboa).curs_right; + break; + case XK_Down : + flag = 1; + char1 = call(keyboa).curs_down; + break; + case XK_Next : + flag = 1; + char1 = call(keyboa).pad_down; + break; + case XK_Prior : + flag = 1; + char1 = call(keyboa).pad_up; + break; + case XK_End : + flag = 1; + char1 = call(keyboa).marg_right; + break; + case XK_Begin : + flag = 1; + char1 = call(keyboa).marg_left; + break; + */ + /* Misc Functions */ + /* + + case XK_Select : + flag = 1; + char1 = call(keyboa).mark; + break; */ + /* + case XK_Print : + flag = 1; + char1 = ; + break; + case XK_Execute : + flag = 1; + char1 = ; + break; + case XK_Insert : + flag = 1; + char1 = ; + break; + + case XK_Undo : + flag = 1; + char1 = call(keyboa).undo; + break; + + case XK_Redo : + flag = 1; + char1 = ; + break; + case XK_Menu : + flag = 1; + char1 = ; + break; + case XK_Find : + flag = 1; + char1 = ; + break; + + + case XK_Cancel : + flag = 1; + char1 = call(keyboa).line_del; + break; + case XK_Help : + flag = 1; + char1 = call(keyboa).help; + break; + + case XK_Break : + flag = 1; + char1 = ; + break; + case XK_Mode_switch : + flag = 1; + char1 = ; + break; + case XK_script_switch : + flag = 1; + char1 = ; + break; + case XK_Num_Lock : + flag = 1; + char1 = ; + break; + + case XK_F1 : + flag = 1; + char1 = shift ? call(keyboa).sfunct1 : call(keyboa).funct1 ; + break; + case XK_F2 : + flag = 1; + char1 = shift ? call(keyboa).sfunct2 : call(keyboa).funct2 ; + break; + case XK_F3 : + flag = 1; + char1 = shift ? call(keyboa).sfunct3 : call(keyboa).funct3 ; + break; + case XK_F4 : + flag = 1; + char1 = shift ? call(keyboa).sfunct4 : call(keyboa).funct4 ; + break; + case XK_F5 : + flag = 1; + char1 = shift ? call(keyboa).sfunct5 : call(keyboa).funct5 ; + break; + case XK_F6 : + flag = 1; + char1 = shift ? call(keyboa).sfunct6 : call(keyboa).funct6 ; + break; + case XK_F7 : + flag = 1; + char1 = shift ? call(keyboa).sfunct7 : call(keyboa).funct7 ; + break; + case XK_F8 : + flag = 1; + char1 = shift ? call(keyboa).sfunct8 : call(keyboa).funct8 ; + break; + case XK_F9 : + flag = 1; + char1 = shift ? call(keyboa).sfunct9 : call(keyboa).funct9 ; + break; + case XK_F10 : + flag = 1; + char1 = shift ? call(keyboa).sfunct10 : call(keyboa).funct10 ; + break; + case XK_F11 : + flag = 1; + char1 = shift ? call(keyboa).sfunct11 : call(keyboa).funct11 ; + break; + case XK_F12 : + flag = 1; + char1 = shift ? call(keyboa).sfunct12 : call(keyboa).funct12 ; + break; + */ + case XK_Shift_L: + shift = 1; + break; + case XK_Shift_R: + shift = 1; + break; + case XK_Control_L: + control = 1; + break; + case XK_Control_R: + control = 1; + break; + case XK_Caps_Lock: + shiftlock = 1; + break; + case XK_Shift_Lock: + shiftlock = 1; + break; + case XK_Meta_L: + alt = 1; + break; + case XK_Meta_R: + alt = 1; + break; + case XK_Alt_L: + alt = 1; + break; + case XK_Alt_R: + alt = 1; + break; + } /* end switch */ + } + } else if (event.type == KeyRelease) { + *x1 = event.xkey.x; + *y1 = event.xkey.y; + char1 = event.xkey.keycode; + keysym = 0; + nb = XLookupString(&event.xkey, buffer, 20, &keysym, &status); + /* if (IsFunctionKey(keysym)) printf("function up\n"); + else if(IsModifierKey(keysym)) printf("modifier up\n"); + else if(IsKeypadKey(keysym)) printf(" keypad up\n"); + else if(IsMiscFunctionKey(keysym)) printf(" misc function up\n"); + else if(IsPFKey(keysym)) printf(" PF key up\n"); + */ + if (nb == 0) { + switch (keysym) { + case XK_Shift_L: + shift = 0; + break; + case XK_Shift_R: + shift = 0; + break; + case XK_Control_L: + control = 0; + break; + case XK_Control_R: + control = 0; + break; + case XK_Caps_Lock: + shiftlock = 0; + break; + case XK_Shift_Lock: + shiftlock = 0; + break; + case XK_Meta_L: + alt = 0; + break; + case XK_Meta_R: + alt = 0; + break; + case XK_Alt_L: + alt = 0; + break; + case XK_Alt_R: + alt = 0; + break; + } /* end switch */ + } } } - XDefineCursor(display,win,cursor_watch); + XDefineCursor(display, win, cursor_watch); XFlush(display); return char1; } - -char Getxyc(float &x,float &y) -{ + +char Getxyc(float &x, float &y) { // cout << " in Getxyc" << endl; char c; - int i,j; - c = Getijc( &i,&j); + int i, j; + c = Getijc(&i, &j); x = scali(i); y = scalj(j); // cout << " out Getxyc" << x << " " << y << " " << c << endl; return c; } -void rattente(int waitm) -{ int i,j; +void rattente(int waitm) { + int i, j; XFlush(display); - if (waitm) - Getijc(&i,&j); + if (waitm) Getijc(&i, &j); } - void GetScreenSize(int &ix,int &iy) -{ +void GetScreenSize(int &ix, int &iy) { ix = width; iy = height; } -void openPS(const char *filename ) -{ +void openPS(const char *filename) { char ffff[32]; - int count=0; - if(psfile_save) closePS(); + int count = 0; + if (psfile_save) closePS( ); time_t t_loc; - float s=0.5; - char username[10]; - /*if (!cuserid(username)) */ strcpy(username,"inconnue"); + float s = 0.5; + char username[10]; + /*if (!cuserid(username)) */ strcpy(username, "inconnue"); time(&t_loc); bool notfound; - if( !filename) - do { + if (!filename) do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.ps",count++); - volatile int r= stat(ffff,&buf) ; - notfound = r !=0; - if(count>1000) break; - } while ( !notfound ); - - - const char *fps (filename?filename:ffff); - - - psfile=fopen(fps,"w"); - if(psfile) { - psfile_save=psfile; - fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); - fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); - fprintf(psfile,"%%%%Pages: 1\n"); - fprintf(psfile,"%%%%BoundingBox: 0 0 %d %d\n",int(width*s),int(height*s)); - fprintf(psfile,"%%%%EndComments\n"); - fprintf(psfile," /L {newpath moveto lineto stroke} def\n"); - fprintf(psfile," /C {setrgbcolor} def\n"); - fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); - fprintf(psfile," %f %f scale \n",s,s); - fprintf(psfile," 0 %d 0 %d rec clip\n",int(width),int(height)); - fprintf(psfile," /Helvetica findfont 10 scalefont setfont\n"); - fprintf(psfile," /S {moveto show} def\n"); - fprintf(psfile," /bF { mark} def \n"); - fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); - fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); - fprintf(psfile," 1 setlinewidth\n"); - } - else + sprintf(ffff, "rgraph_%.3d.ps", count++); + volatile int r = stat(ffff, &buf); + notfound = r != 0; + if (count > 1000) break; + } while (!notfound); + + const char *fps(filename ? filename : ffff); + + psfile = fopen(fps, "w"); + if (psfile) { + psfile_save = psfile; + fprintf(psfile, "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n", "user"); + fprintf(psfile, "%%%%CreationDate: %s", ctime(&t_loc)); + fprintf(psfile, "%%%%Pages: 1\n"); + fprintf(psfile, "%%%%BoundingBox: 0 0 %d %d\n", int(width * s), int(height * s)); + fprintf(psfile, "%%%%EndComments\n"); + fprintf(psfile, " /L {newpath moveto lineto stroke} def\n"); + fprintf(psfile, " /C {setrgbcolor} def\n"); + fprintf(psfile, " /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); + fprintf(psfile, " %f %f scale \n", s, s); + fprintf(psfile, " 0 %d 0 %d rec clip\n", int(width), int(height)); + fprintf(psfile, " /Helvetica findfont 10 scalefont setfont\n"); + fprintf(psfile, " /S {moveto show} def\n"); + fprintf(psfile, " /bF { mark} def \n"); + fprintf(psfile, " /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); + fprintf(psfile, " /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); + fprintf(psfile, " 1 setlinewidth\n"); + } else cerr << " Err opening postscript file " << fps << endl; } -void closePS(void) -{ - if(psfile_save) { - fprintf(psfile_save,"showpage\n"); +void closePS(void) { + if (psfile_save) { + fprintf(psfile_save, "showpage\n"); fclose(psfile_save); } - psfile_save=0; - psfile=0; + psfile_save = 0; + psfile = 0; } //---------------------------------------------------------------------- // add by fujiwara //---------------------------------------------------------------------- -void openPDF(const char *filename ) -{ - if(pdffile) closePDF(); +void openPDF(const char *filename) { + if (pdffile) closePDF( ); - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } - pdffile_name = new char [ strlen(filename)+1 ]; - strcpy( pdffile_name, filename ); + pdffile_name = new char[strlen(filename) + 1]; + strcpy(pdffile_name, filename); - pdffile_content.str(""); // clear - pdffile_content.clear( std::stringstream::goodbit ); + pdffile_content.str(""); // clear + pdffile_content.clear(std::stringstream::goodbit); - pdffile_content.setf( std::ios::fixed ); - pdffile_content.precision( 3 ); + pdffile_content.setf(std::ios::fixed); + pdffile_content.precision(3); const int widthA4PDF = 596; - pdf_s = static_cast(widthA4PDF) / width; + pdf_s = static_cast< float >(widthA4PDF) / width; pdffile = true; - pdffile_content << "q" << std::endl; // gsave - + pdffile_content << "q" << std::endl; // gsave + return; } -void closePDF(void) -{ - if(pdffile) { +void closePDF(void) { + if (pdffile) { - std::string PDFTitle = "plot() by FreeFem++"; - std::string AppName = "FreeFem++ v" + StrVersionNumber(); + std::string PDFTitle = "plot() by FreeFem++"; + std::string AppName = "FreeFem++ v" + StrVersionNumber( ); - SimplePDF_FF pdf( pdffile_name, PDFTitle.c_str(), AppName.c_str() ); + SimplePDF_FF pdf(pdffile_name, PDFTitle.c_str( ), AppName.c_str( )); - const int widthPDF = static_cast( width * pdf_s ); - const int heightPDF = static_cast( height * pdf_s ); + const int widthPDF = static_cast< int >(width * pdf_s); + const int heightPDF = static_cast< int >(height * pdf_s); - pdffile_content << "Q" << std::endl; + pdffile_content << "Q" << std::endl; - pdf.addPage( pdffile_content, widthPDF, heightPDF ); + pdf.addPage(pdffile_content, widthPDF, heightPDF); - pdffile = false; + pdffile = false; } - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } return; } -void openSVG(const char *filename ) -{ - if(svgfile_save) closeSVG(); +void openSVG(const char *filename) { + if (svgfile_save) closeSVG( ); - const int widthA4PS = 596; - //const int heightA4PS = 842; - svg_s = static_cast(widthA4PS)/width; + const int widthA4PS = 596; + // const int heightA4PS = 842; + svg_s = static_cast< double >(widthA4PS) / width; char ffff[32]; int count = 0; - if(!filename){ + if (!filename) { bool notfound; do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.svg",count++); - volatile int r = stat(ffff,&buf) ; + sprintf(ffff, "rgraph_%.3d.svg", count++); + volatile int r = stat(ffff, &buf); notfound = (r != 0); - if( count > 1000 ) break; - } while ( !notfound ); - } - - const char *fsvg (filename?filename:ffff); - - svgfile=fopen(fsvg,"w"); - - if(svgfile) { - svgfile_save=svgfile; - fprintf(svgfile,"\n\n"); - fprintf(svgfile,"\n\n", StrVersionNumber().c_str()); - fprintf(svgfile,"\n", - static_cast(width*svg_s), static_cast(height*svg_s)); + if (count > 1000) break; + } while (!notfound); } - else - { + + const char *fsvg(filename ? filename : ffff); + + svgfile = fopen(fsvg, "w"); + + if (svgfile) { + svgfile_save = svgfile; + fprintf(svgfile, "\n\n"); + fprintf(svgfile, "\n\n", StrVersionNumber( ).c_str( )); + fprintf(svgfile, "\n", static_cast< int >(width * svg_s), static_cast< int >(height * svg_s)); + } else { cerr << " Err opening SVG file " << fsvg << endl; } return; } -void closeSVG(void) -{ - if(svgfile_save) { - fprintf(svgfile_save,"\n"); +void closeSVG(void) { + if (svgfile_save) { + fprintf(svgfile_save, "\n"); fclose(svgfile_save); } - svgfile_save=0; - svgfile=0; + svgfile_save = 0; + svgfile = 0; return; } @@ -1310,106 +1188,110 @@ void closeSVG(void) // add by fujiwara end //---------------------------------------------------------------------- - void coutmode(short i) {} -// bof bof --- - float GetHeigthFont() -{ - int dir,asc,desc,k; +void coutmode(short i) {} +// bof bof --- +float GetHeigthFont( ) { + int dir, asc, desc, k; XCharStruct overall; - XTextExtents(font_info,"gML",3,&dir,&asc,&desc,&overall); - return (asc+desc)*(0.9/echy); + XTextExtents(font_info, "gML", 3, &dir, &asc, &desc, &overall); + return (asc + desc) * (0.9 / echy); } - void Commentaire(const char * c) - { - if(psfile) { - fprintf(psfile,"%% %s\n",c); - } - // add by fujiwara - if( pdffile ) { - //fprintf(pdffile,"%% %s\n",c); - } - if( svgfile ) { - fprintf(svgfile,"%% %s\n",c); - } - }; - void NoirEtBlanc(int NB) - { - if(NB) LastColor=1; - else LastColor=ncolortable?ncolortable:2; +void Commentaire(const char *c) { + if (psfile) { + fprintf(psfile, "%% %s\n", c); } - - void MettreDansPostScript(int in) - { - if(in) psfile=psfile_save; - else psfile=0; - } // add by fujiwara - void MettreDansPDF(int in) // put into PDF - { - if(in) pdffile=true; - else pdffile=false; - } - void MettreDansSVG(int in) // put into SVG - { - if(in) svgfile=svgfile_save; - else svgfile=0; - } - -static void FillRect(float x0,float y0, float x1, float y1) - { - float r[8]; - r[0]=x0;r[1]=y0; - r[2]=x1;r[3]=y0; - r[4]=x1;r[5]=y1; - r[6]=x0;r[7]=y1; - fillpoly(4,r); - } - -int PutLevel(int lineno, float xf, int col) + if (pdffile) { + // fprintf(pdffile,"%% %s\n",c); + } + if (svgfile) { + fprintf(svgfile, "%% %s\n", c); + } +}; +void NoirEtBlanc(int NB) { + if (NB) + LastColor = 1; + else + LastColor = ncolortable ? ncolortable : 2; +} + +void MettreDansPostScript(int in) { + if (in) + psfile = psfile_save; + else + psfile = 0; +} +// add by fujiwara +void MettreDansPDF(int in) // put into PDF { - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - float xleft = xmax - (xmax-xmin)*0.1; - float ytop = ymax; - float ydelta = (ymax-ymin)/40; - ydelta=GetHeigthFont(); - xleft = xmax - 6*ydelta; - ytop -= ydelta*(col+2); + if (in) + pdffile = true; + else + pdffile = false; +} +void MettreDansSVG(int in) // put into SVG +{ + if (in) + svgfile = svgfile_save; + else + svgfile = 0; +} + +static void FillRect(float x0, float y0, float x1, float y1) { + float r[8]; + r[0] = x0; + r[1] = y0; + r[2] = x1; + r[3] = y0; + r[4] = x1; + r[5] = y1; + r[6] = x0; + r[7] = y1; + fillpoly(4, r); +} + +int PutLevel(int lineno, float xf, int col) { + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + float xleft = xmax - (xmax - xmin) * 0.1; + float ytop = ymax; + float ydelta = (ymax - ymin) / 40; + ydelta = GetHeigthFont( ); + xleft = xmax - 6 * ydelta; + ytop -= ydelta * (col + 2); couleur(col); - FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.); - rmoveto(xleft+ydelta*1.4,ytop+ydelta/4); + FillRect(xleft + ydelta / 8., ytop + ydelta / 8., xleft + ydelta * 7. / 8., ytop + ydelta * 7. / 8.); + rmoveto(xleft + ydelta * 1.4, ytop + ydelta / 4); char buf[30]; - sprintf(buf,"%g",xf); + sprintf(buf, "%g", xf); couleur(1); plotstring(buf); - return lineno; + return lineno; } - void ShowHelp(const char * s,int k) -{ - if(k) { +void ShowHelp(const char *s, int k) { + if (k) { MettreDansPostScript(0); - MettreDansPDF(0); // add by fujiwara - MettreDansSVG(0); // add by fujiwara + MettreDansPDF(0); // add by fujiwara + MettreDansSVG(0); // add by fujiwara couleur(1); - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + rmoveto(xmin + (xmax - xmin) / 100, ymax - (k) * (ymax - ymin) / 30); plotstring(s); MettreDansPostScript(1); - MettreDansPDF(1); // add by fujiwara - MettreDansSVG(1); // add by fujiwara - // couleur(1); + MettreDansPDF(1); // add by fujiwara + MettreDansSVG(1); // add by fujiwara + // couleur(1); } } - void setgrey(bool gg ){grey=gg;} - int getgrey(){ return grey;} +void setgrey(bool gg) { grey = gg; } +int getgrey( ) { return grey; } class Grid; -void SaveMesh(Grid &t){} -void SavePlot(int D, Grid& t, double *f){} -void SavePlot(int D, Grid& t, float *f){} - +void SaveMesh(Grid &t) {} +void SavePlot(int D, Grid &t, double *f) {} +void SavePlot(int D, Grid &t, float *f) {} diff --git a/src/Graphics/ff-win32.cpp b/src/Graphics/ff-win32.cpp index 515b625a0..a35c5b9f7 100644 --- a/src/Graphics/ff-win32.cpp +++ b/src/Graphics/ff-win32.cpp @@ -5,88 +5,79 @@ using namespace std; #include #ifdef _WIN64 -#pragma pack( push ) -#pragma pack( 16 ) +#pragma pack(push) +#pragma pack(16) #include "Commdlg.h" -#pragma pack( pop ) +#pragma pack(pop) #else #include "Commdlg.h" -#endif // _WIN64 -//#include -#include //*OT use for the console window +#endif // _WIN64 +// #include +#include //*OT use for the console window -BOOL ShowOpenDialogBox1(char *fileName) -{ - OPENFILENAME *pofn= new OPENFILENAME[2], &ofn= *pofn; - - char szDirName[256]; - const char *strFilter="freefem++ Files (*.edp)\0*.edp\0All Files (*.*)\0*.*\0\0"; - - memset(&ofn, 0, 2*sizeof(OPENFILENAME)); - getcwd(szDirName,sizeof(szDirName)); +BOOL ShowOpenDialogBox1(char *fileName) { + OPENFILENAME *pofn = new OPENFILENAME[2], &ofn = *pofn; + + char szDirName[256]; + const char *strFilter = "freefem++ Files (*.edp)\0*.edp\0All Files (*.*)\0*.*\0\0"; + + memset(&ofn, 0, 2 * sizeof(OPENFILENAME)); + getcwd(szDirName, sizeof(szDirName)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = NULL; ofn.lpstrFilter = strFilter; ofn.lpstrFileTitle = fileName; ofn.nMaxFileTitle = 1024; - ofn.lpstrInitialDir=szDirName; - ofn.lpstrTitle ="Choose you freefem '*.edp' File"; - ofn.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; - - BOOL ret= GetOpenFileNameA(pofn); - cout << " ret "<< ret << " "<< fileName << " "<< szDirName << endl; + ofn.lpstrInitialDir = szDirName; + ofn.lpstrTitle = "Choose you freefem '*.edp' File"; + ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + BOOL ret = GetOpenFileNameA(pofn); + cout << " ret " << ret << " " << fileName << " " << szDirName << endl; delete[] pofn; return ret; -} - - +} -string ChangeExt(const string & ff,const char * suff) -{ +string ChangeExt(const string &ff, const char *suff) { int dot = ff.rfind(".edp"); - assert(dot>0); - return ff.substr(0,dot)+suff; + assert(dot > 0); + return ff.substr(0, dot) + suff; } -bool GetConsoleBuff(const string &edpname) -{ - CONSOLE_SCREEN_BUFFER_INFO csbi; //* to get buffer info - HANDLE hConOut= GetStdHandle(STD_OUTPUT_HANDLE); - //cout << " handle " << hConOut << endl; - if( hConOut == 0) return false ; - if ( INVALID_HANDLE_VALUE == hConOut) return false; +bool GetConsoleBuff(const string &edpname) { + CONSOLE_SCREEN_BUFFER_INFO csbi; //* to get buffer info + HANDLE hConOut = GetStdHandle(STD_OUTPUT_HANDLE); + // cout << " handle " << hConOut << endl; + if (hConOut == 0) return false; + if (INVALID_HANDLE_VALUE == hConOut) return false; GetConsoleScreenBufferInfo(hConOut, &csbi); - - COORD coordLine = {0,0}; - CHAR *szLine=0; //* buffer to read from the console (a line) + + COORD coordLine = {0, 0}; + CHAR *szLine = 0; //* buffer to read from the console (a line) DWORD dwCharsRead; FILE *fp; - string fname=ChangeExt(edpname,".log"); - if ((fp = fopen(fname.c_str(),"w"))==NULL) { - perror(fname.c_str()); - cout<< " err fopen logfile: "<< fname << endl; + string fname = ChangeExt(edpname, ".log"); + if ((fp = fopen(fname.c_str( ), "w")) == NULL) { + perror(fname.c_str( )); + cout << " err fopen logfile: " << fname << endl; return false; } - szLine = new CHAR [csbi.dwSize.X+1]; - for (int i=0; i 0)) szLine[j--] =0; - if (j < csbi.dwSize.X-1) szLine[j+1] = '\n'; - fprintf(fp,"%s",szLine); + szLine = new CHAR[csbi.dwSize.X + 1]; + for (int i = 0; i < csbi.dwCursorPosition.Y; i++) { + if (ReadConsoleOutputCharacter(hConOut, szLine, csbi.dwSize.X, coordLine, &dwCharsRead) == FALSE) { + perror("ReadConsoleOutputCharacter"); + cout << " err ReadConsoleOutputCharacter " << i << " " << csbi.dwCursorPosition.Y << endl; + return false; + } + int j = csbi.dwSize.X - 1; + while ((szLine[j] == ' ') && (j > 0)) szLine[j--] = 0; + if (j < csbi.dwSize.X - 1) szLine[j + 1] = '\n'; + fprintf(fp, "%s", szLine); coordLine.Y++; } fclose(fp); - delete [] szLine; - cout << " save log in : '"<< fname << "'\n" ; + delete[] szLine; + cout << " save log in : '" << fname << "'\n"; return true; } #endif diff --git a/src/Graphics/ffglut.cpp b/src/Graphics/ffglut.cpp index 4c22ad4f5..b6b85ae46 100644 --- a/src/Graphics/ffglut.cpp +++ b/src/Graphics/ffglut.cpp @@ -45,3615 +45,3327 @@ using namespace std; #include "Mesh3dn.hpp" #include "PlotStream.hpp" -double kscreenscale = 1; // to solve bug on MacOS Catalina , wrong value in resize +double kscreenscale = 1; // to solve bug on MacOS Catalina , wrong value in resize extern long verbosity; -int glutscreenscale=1;// High Resolution Explained: Features and Benefit +int glutscreenscale = 1; // High Resolution Explained: Features and Benefit // add for the gestion of the endianness of the file. -//PlotStream::fBytes PlotStream::zott; //0123; -//PlotStream::hBytes PlotStream::zottffss; //012345678; +// PlotStream::fBytes PlotStream::zott; //0123; +// PlotStream::hBytes PlotStream::zottffss; //012345678; // ---- FH using namespace Fem2D; using std::numeric_limits; -const R pi=my_pi;//4*atan(1.); +const R pi = my_pi; // 4*atan(1.); using namespace std; -static int nbSendForNextPlot=0,nbTimerNextPlot=0; -int debug=0; -int casemouse=0,keyact=0; -double gwait=0;// no wait in second +static int nbSendForNextPlot = 0, nbTimerNextPlot = 0; +int debug = 0; +int casemouse = 0, keyact = 0; +double gwait = 0; // no wait in second #include "ffglut.hpp" #include "ffthreads.hpp" -int version =0; -int subversion =0; - -Thread::Id tidRead=0; -bool NoMorePlot=false; -bool NoMorePlotTilte=false; -ThePlot *currentPlot=0, *nextPlot=0; -bool inThreadRead=false; -FILE *datafile=0; - -static bool TryNewPlot( void ); - - -void LauchNextRead(); -void WaitNextRead(); -THREADFUNC(ThreadRead,fd); +int version = 0; +int subversion = 0; + +Thread::Id tidRead = 0; +bool NoMorePlot = false; +bool NoMorePlotTilte = false; +ThePlot *currentPlot = 0, *nextPlot = 0; +bool inThreadRead = false; +FILE *datafile = 0; + +static bool TryNewPlot(void); + +void LauchNextRead( ); +void WaitNextRead( ); +THREADFUNC(ThreadRead, fd); + +int kread = -1; + +map< int, OneWindow * > AllWindows; +map< int, int > Num2Windows; + +int Fin(int code) { + WaitNextRead( ); + if (!NoMorePlot && debug > 2) cout << " exit before end " << endl; + if (NoMorePlot && !code) exit(NoMorePlot ? 0 : 1); + if (code) exit(NoMorePlot ? 0 : 1); + return 0; +} + +int ReadOnePlot(FILE *fp) { + int err = 0; + if (!fp) return -4; + err = feof(fp); + if (err) return -2; + err = ferror(fp); + if (err) return -3; + + PlotStream f(fp); + f.set_binary_mode( ); + const char *magic2 = "#!ffglutdata2.."; + const char *magic3 = "#!ffglutdata3.."; + const char *magic3_1 = "#!ffglutdata3.1"; + const char *magic3_2 = "#!ffglutdata3.2"; + const char *magic4_0 = "#!ffglutdata4.0"; + const char *magic4_1 = "#!ffglutdata4.1"; + /* + + change version 3.2 add colored curve + */ + const int lmagic = strlen(magic2); + char magicxx[32]; + err = 0; + // init .. + if (kread == -1) { + for (int i = 0; i < lmagic; i++) { + int c = getc(fp); + if (i == 0 && c == EOF) return -2; // empty file + magicxx[i] = c; + } + magicxx[lmagic] = '\0'; + if (strcmp(magicxx, magic2) == 0) + version = 2; + else if (strcmp(magicxx, magic3) == 0) + version = 3; + else if (strcmp(magicxx, magic3_1) == 0) + version = 3; + else if (strcmp(magicxx, magic3_2) == 0) + version = 3; + else if (strcmp(magicxx, magic4_0) == 0) + version = 4; + else if (strcmp(magicxx, magic4_1) == 0) + version = 4; + else + err = 1; -int kread=-1; + if (err) { + if (debug > 2) cout << " Err read magic heading " << endl; + goto Lreturn; + } + kread++; + if (debug > 2) cout << " Read entete " << version << endl; + int c1 = getc(fp); + if (c1 == 13) int c2 = getc(fp); + } + long cas; + f >> cas; + err = -1; + if (feof(fp)) goto Lreturn; + if ((debug > 2)) cout << " ReadOnePlot " << kread + 1 << " cas = " << cas << " " << nextPlot << endl; + if (cas == PlotStream::dt_newplot) { + assert(nextPlot == 0); + nextPlot = new ThePlot(f, currentPlot, ++kread); + if (debug > 1) cout << "\n\n\n next is build " << nextPlot << " wait :" << nextPlot->wait << " -> " << kread << " gwait = " << gwait << "\n\n\n" << endl; + assert(nextPlot); + err = 0; + } else { + err = 1; + cout << " Error Cas inconnue (skip) " << endl; + } +Lreturn: + f.set_text_mode( ); + return err; +} + +void TimerNextPlot(int value) { + + nbTimerNextPlot++; + // the routine to until the end of nextplot. + // we use gluttimerfunc functionnaly + // remark, if we miss we retry. + if (nbTimerNextPlot > 1 && debug > 2) cout << " ###### Warning more than 1 nbTimerNextPlot" << nbTimerNextPlot << endl; + value = min(1000, (value * 3) / 2); // try at leat every 1 second (not to heavy computation) + if (TryNewPlot( )) { + if (debug > 9) cout << " #### TimerNextPlot TryNewPlot:: glutPostRedisplay " << nbTimerNextPlot << " " << nbSendForNextPlot << endl; + nbSendForNextPlot--; // do the plot .. + glutPostRedisplay( ); + } else { + if (debug > 9) cout << " #### TimerNextPlot wait " << nbTimerNextPlot << " " << nbSendForNextPlot << endl; + glutTimerFunc(value, TimerNextPlot, value); + } + nbTimerNextPlot--; +} +int SendForNextPlot( ) { -map AllWindows; -map Num2Windows; + if (nbSendForNextPlot > 0 && debug > 2) cout << " ###### Warning more than 1 SendForNextPlot" << nbSendForNextPlot + 1 << endl; + if (nbSendForNextPlot) return 0; + nbSendForNextPlot++; + // to send a event to plot the date sheet. + // and out a timer to wait to the end of read.. + // every 25/ second.. = 1000/25 = 40 ms + if (NoMorePlot) { + if (gwait) { + usleep((useconds_t)(1e6 * gwait)); + Fin(0); + } -int Fin(int code) -{ - WaitNextRead(); - if(!NoMorePlot && debug>2) - cout << " exit before end " << endl; - if(NoMorePlot && !code) exit(NoMorePlot ? 0 : 1); - if(code) exit(NoMorePlot ? 0 : 1); + if ((debug > 1)) cout << " send signal For Next plot, skip: No More Plot ! " << endl; + nbSendForNextPlot--; return 0; -} + } + if ((debug > 1)) cout << " Try to read read plot " << endl; + // put a timer for wait to the end of read + glutTimerFunc(40, TimerNextPlot, 40); + return 1; +} +static bool TryNewPlot(void); + +int signep4(int i0, int i1, int i2, int i3) { // calcul du signe dans la permutation + int s = 1; + if (i0 > i1) s = -s, Exchange(i0, i1); + if (i1 > i2) s = -s, Exchange(i1, i2); + if (i2 > i3) s = -s, Exchange(i2, i3); // i3 max + if (i0 > i1) s = -s, Exchange(i0, i1); + if (i1 > i2) s = -s, Exchange(i1, i2); // i2 max < i + if (i0 > i1) s = -s, Exchange(i0, i1); + return s; +} +inline R3 bary(const R3 K[4], R f[4], int i0, int i1, R v) { + R d = f[i0] - f[i1]; + assert(fabs(d) > 1e-20); + R l1 = (f[i0] - v) / d; // == 1 si v = f[i1] + R l0 = 1. - l1; + assert(l0 >= -1e-10 && l1 >= -1e-10); + return K[i0] * l0 + K[i1] * l1; // == K[i1] si l1 ==1 => v = f[i1] +} +void drawisoTet(const R3 K[4], R f[4], R v) { + static const int nvfaceTet[4][3] = {{3, 2, 1}, {0, 2, 3}, {3, 1, 0}, {0, 1, 2}}; //{ {2,1,3},{0,2,3},{1,0,3},{0,1,2} }; + + R3 P[4]; + int nP = 0; + int np[4] = { }, nm[4] = { }; + int km = 0, kp = 0; + for (int i = 0; i < 4; ++i) { + if (f[i] <= v) nm[km++] = i; + if (f[i] >= v) np[kp++] = i; + } -int ReadOnePlot(FILE *fp) -{ - int err=0; - if(!fp) return -4; - err= feof(fp) ; - if(err) return -2; - err= ferror(fp) ; - if(err) return -3; - - PlotStream f(fp); - f.set_binary_mode(); - const char * magic2="#!ffglutdata2.."; - const char * magic3="#!ffglutdata3.."; - const char * magic3_1="#!ffglutdata3.1"; - const char * magic3_2="#!ffglutdata3.2"; - const char * magic4_0="#!ffglutdata4.0"; - const char * magic4_1="#!ffglutdata4.1"; - /* - - change version 3.2 add colored curve - */ - const int lmagic=strlen(magic2); - char magicxx[32]; - err=0; - // init .. - if(kread==-1) - { - for(int i=0;i2) - cout << " Err read magic heading " << endl; - goto Lreturn; - } - kread++; - if(debug>2) cout << " Read entete " << version << endl; - int c1 =getc(fp); - if(c1==13) - int c2 =getc(fp); + int h = -1, b[3] = { }; + if (kp == 1 && km == 3) { + h = np[0]; + b[0] = nvfaceTet[h][0]; + b[1] = nvfaceTet[h][1]; + b[2] = nvfaceTet[h][2]; + } + if (km == 1 && kp == 3) { + h = nm[0]; + b[0] = nvfaceTet[h][0]; + b[2] = nvfaceTet[h][1]; + b[1] = nvfaceTet[h][2]; + } + if (kp == 2 && km == 2) { // cas quad + if (signep4(nm[0], nm[1], np[0], np[1]) < 0) Exchange(nm[0], nm[1]); + // le tet m[0],nm[1],np[0],np[1] est positif + P[0] = bary(K, f, nm[0], np[0], v); + P[1] = bary(K, f, nm[0], np[1], v); + P[2] = bary(K, f, nm[1], np[1], v); + P[3] = bary(K, f, nm[1], np[0], v); + nP = 4; + } else if (h >= 0) { // cas triangle + P[0] = bary(K, f, h, b[0], v); + P[1] = bary(K, f, h, b[1], v); + P[2] = bary(K, f, h, b[2], v); + nP = 3; + } + if (nP) { + if (nP > 2) { + R3 N(R3(P[0], P[1]) ^ R3(P[0], P[2])); + N /= N.norme( ); + glNormal3d(N.x, N.y, N.z); } - long cas; - f >> cas; - err=-1; - if (feof(fp)) goto Lreturn ; - if((debug > 2)) cout << " ReadOnePlot " << kread+1<< " cas = " << cas << " " << nextPlot << endl; - if(cas==PlotStream::dt_newplot) - { - assert(nextPlot==0); - nextPlot = new ThePlot(f,currentPlot,++kread); - if(debug>1) - cout << "\n\n\n next is build " << nextPlot<< " wait :" << nextPlot->wait << " -> " << kread << " gwait = " << gwait << "\n\n\n"<1 && debug >2 ) cout << " ###### Warning more than 1 nbTimerNextPlot" << nbTimerNextPlot << endl; - value=min(1000,(value*3)/2);// try at leat every 1 second (not to heavy computation) - if(TryNewPlot()) - { - if(debug >9) cout << " #### TimerNextPlot TryNewPlot:: glutPostRedisplay "<< nbTimerNextPlot << " " << nbSendForNextPlot < &viso, R v) { + int i = 0, j = viso.N( ), k; + if (v < viso[0] || v > viso[j - 1]) return -1; + while (i < j - 1) + if (viso[k = (i + j) / 2] > v) + j = k; else - { - if(debug >9) cout << " #### TimerNextPlot wait "<< nbTimerNextPlot << " " << nbSendForNextPlot<0 && debug >2 ) cout << " ###### Warning more than 1 SendForNextPlot" << nbSendForNextPlot+1 << endl; - if(nbSendForNextPlot) return 0; - nbSendForNextPlot++; - - // to send a event to plot the date sheet. - // and out a timer to wait to the end of read.. - // every 25/ second.. = 1000/25 = 40 ms - if(NoMorePlot) - { - if(gwait ) - {usleep((useconds_t)(1e6*gwait)); Fin(0); } +int ShowGlerror(const char *s) { + GLint error = glGetError( ); + if (error != GL_NO_ERROR) printf("Attention %s erreur : %x \n", s, error); + return error; +} - if((debug > 1)) cout << " send signal For Next plot, skip: No More Plot ! " << endl; - nbSendForNextPlot--; - return 0; +// def des couleurs de la tables +void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, KN< R > colors) { + int nbcolors = colors.N( ) / 3; + if (k <= 0) { + r = g = b = 1.; + } // white + else if (k == 1) { + r = g = b = 0.; + } // black + else if (k >= nb) { + r = g = b = 0.; + } // black + else if (grey) { + float gg = 0.1 + 0.9 * float(k - 2) / (nb - 3); + r = g = b = gg; + } else if (nbcolors <= 1) { + float h = float(k - 2) / (nb - 2), s = 1., v = 1.; + hsvToRgb(h, s, v, r, g, b); + return; + } else { // interpolation dans la table hsv + int i = (k - 2); + int j0 = i * (nbcolors - 1) / (nb - 2); + int j1 = j0 + 1; + int i0 = j0 * (nb - 2) / (nbcolors - 1); + int i1 = j1 * (nb - 2) / (nbcolors - 1); + int j03 = j0 * 3, j13 = j1 * 3; + float a = float(i1 - i) / (i1 - i0), a1 = 1 - a; + if (hsv) { + float h = colors[j03 + 0] * a + colors[j13 + 0] * a1; + float s = colors[j03 + 1] * a + colors[j13 + 1] * a1; + float v = colors[j03 + 2] * a + colors[j13 + 2] * a1; + hsvToRgb(h, s, v, r, g, b); + } else { + r = colors[j03 + 0] * a + colors[j13 + 0] * a1; + g = colors[j03 + 1] * a + colors[j13 + 1] * a1; + b = colors[j03 + 2] * a + colors[j13 + 2] * a1; } - if((debug > 1)) cout << " Try to read read plot "<< endl; - // put a timer for wait to the end of read - glutTimerFunc(40,TimerNextPlot,40); - return 1; + } } -static bool TryNewPlot( void ); - +template< class Mesh > +void Plot(const Mesh &Th, bool fill, bool plotmesh, bool plotborder, ThePlot &plot, GLint gllists, int *lok) { + glDisable(GL_DEPTH_TEST); + ShowGlerror("begin Mesh plot"); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + R z1 = plot.z0; + R z2 = plot.z0; + double r = 0, g = 0, b = 0; + if ((debug > 3)) cout << " OnePlotMesh::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts( ) << " " << z1 << " " << z2 << endl; + bool cc[3] = {plotborder, plotmesh && fill, plotmesh}; + int kk = 0; + if (cc[kk]) + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glLineWidth(2 * kscreenscale); + glBegin(GL_LINES); + for (int i = 0; i < Th.nbBrdElmts( ); i++) { + const typename Mesh::BorderElement &K(Th.be(i)); + plot.color(1 + abs(K.lab)); + glVertex3d(K[0].x, K[0].y, z1); + glVertex3d(K[1].x, K[1].y, z1); + } + glEnd( ); + glLineWidth(kscreenscale); + glEndList( ); // fin de la list + } + else + ; -int signep4(int i0,int i1,int i2,int i3) -{ // calcul du signe dans la permutation - int s =1; - if(i0>i1) s=-s,Exchange(i0,i1); - if(i1>i2) s=-s,Exchange(i1,i2); - if(i2>i3) s=-s,Exchange(i2,i3); // i3 max - if(i0>i1) s=-s,Exchange(i0,i1); - if(i1>i2) s=-s,Exchange(i1,i2); // i2 max < i - if(i0>i1) s=-s,Exchange(i0,i1); - return s; -} -inline R3 bary(const R3 K[4],R f[4],int i0,int i1,R v) -{ - R d=f[i0]-f[i1]; - assert(fabs(d)>1e-20); - R l1= (f[i0] - v)/ d; // == 1 si v = f[i1] - R l0 = 1. -l1; - assert(l0 >=-1e-10 && l1 >= -1e-10); - return K[i0]*l0 + K[i1]*l1; // == K[i1] si l1 ==1 => v = f[i1] -} -void drawisoTet(const R3 K[4],R f[4],R v) -{ - static const int nvfaceTet[4][3] ={{3,2,1}, {0,2,3},{ 3,1,0},{ 0,1,2}} ;//{ {2,1,3},{0,2,3},{1,0,3},{0,1,2} }; + kk++; + glEnable(GL_DEPTH_TEST); - R3 P[4]; - int nP=0; - int np[4]={},nm[4]={}; - int km=0,kp=0; - for (int i=0;i<4;++i) - { - if(f[i]<=v) nm[km++]=i; - if(f[i]>=v) np[kp++]=i; + if (cc[kk]) { + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glPolygonMode(GL_FRONT, GL_FILL); // GL_FILL + glBegin(GL_TRIANGLES); + for (int i = 0; i < Th.nt; i++) { + const typename Mesh::Element &K(Th[i]); + plot.color(K.lab ? 1 + abs(K.lab) : 0); + + // glColor3d(r,g,b); + glVertex3d(K[0].x, K[0].y, z2); + glVertex3d(K[1].x, K[1].y, z2); + glVertex3d(K[2].x, K[2].y, z2); + } + glEnd( ); + glEndList( ); } + } + kk++; + if (cc[kk]) { + glEnable(GL_DEPTH_TEST); + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glPolygonMode(GL_FRONT, GL_LINE); + glBegin(GL_TRIANGLES); + for (int i = 0; i < Th.nt; i++) { + const typename Mesh::Element &K(Th[i]); + plot.color(fill ? 1 : 1 + abs(K.lab)); + glVertex3d(K[0].x, K[0].y, z1); + glVertex3d(K[1].x, K[1].y, z1); + glVertex3d(K[2].x, K[2].y, z1); + } - int h=-1,b[3]={}; - if(kp==1 && km==3) - { - h = np[0]; - b[0]=nvfaceTet[h][0]; - b[1]=nvfaceTet[h][1]; - b[2]=nvfaceTet[h][2]; - } - if(km==1 && kp == 3) - { - h = nm[0]; - b[0]=nvfaceTet[h][0]; - b[2]=nvfaceTet[h][1]; - b[1]=nvfaceTet[h][2]; + glEnd( ); + glEndList( ); // fin de la list } - if(kp==2 && km==2) - {// cas quad - if(signep4(nm[0],nm[1],np[0],np[1]) < 0) - Exchange(nm[0],nm[1]); - // le tet m[0],nm[1],np[0],np[1] est positif - P[0]=bary(K,f,nm[0],np[0],v); - P[1]=bary(K,f,nm[0],np[1],v); - P[2]=bary(K,f,nm[1],np[1],v); - P[3]=bary(K,f,nm[1],np[0],v); - nP=4; + } + ShowGlerror("end Mesh plot"); +} + +void Plot(const Mesh3 &Th, bool fill, bool plotmesh, bool plotborder, ThePlot &plot, GLint gllists, int *lok) { + typedef Mesh3::BorderElement BE; + typedef Mesh3::Element Tet; + glEnable(GL_DEPTH_TEST); + ShowGlerror("begin Mesh3 plot"); + + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + R z1 = plot.z0; + R z2 = plot.z0; + + double r = 0, g = 0, b = 0; + if ((debug > 3)) cout << " OnePlotMesh3::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts( ) << " " << z1 << " " << z2 << endl; + bool cc[3] = {plotborder, plotborder && fill, plotmesh && fill}; + double saturation = plotmesh ? 1 : 0.25; + int kk = 0; + if (Th.nbe == 0) { + if (lok[kk]) + glCallList(gllists + kk); + else { // draw all vertex + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glBegin(GL_POINTS); + for (int i = 0; i < Th.nv; ++i) { + plot.color(1 + Th(i).lab, saturation); + glVertex3d(Th(i).x, Th(i).y, Th(i).z); + } + glEnd( ); + glEndList( ); // fin de la list } - else if (h>=0) - { // cas triangle - P[0]=bary(K,f,h,b[0],v); - P[1]=bary(K,f,h,b[1],v); - P[2]=bary(K,f,h,b[2],v); - nP=3; + } else if (cc[kk]) { + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glLineWidth(kscreenscale); + glAlphaFunc(GL_GREATER, 0.1); + glEnable(GL_ALPHA_TEST); + if (!plotmesh) { + glLineStipple(1, 0x300C); + glEnable(GL_LINE_STIPPLE); + } + glBegin(GL_TRIANGLES); + for (int i = 0; i < Th.nbe; i++) { + const BE &K(Th.be(i)); + plot.color(1 + abs(K.lab), saturation); + R3 N(R3(K[0], K[1]) ^ R3(K[0], K[2])); + N /= N.norme( ); + glNormal3d(N.x, N.y, N.z); + glVertex3d(K[0].x, K[0].y, K[0].z); + glVertex3d(K[1].x, K[1].y, K[1].z); + glVertex3d(K[2].x, K[2].y, K[2].z); + } + glEnd( ); + glDisable(GL_LINE_STIPPLE); + glLineWidth(kscreenscale); + glDisable(GL_ALPHA_TEST); + + glEndList( ); // fin de la list } + } + kk = 2; + if (cc[kk]) { + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glLineWidth(kscreenscale); + glPolygonMode(GL_FRONT, GL_FILL); // GL_FILL + glBegin(GL_TRIANGLES); + for (int i = 0; i < Th.nbe; i++) { + const BE &K(Th.be(i)); + plot.color(0, saturation); + R3 N(R3(K[0], K[1]) ^ R3(K[0], K[2])); + N /= N.norme( ); + glNormal3d(N.x, N.y, N.z); + glVertex3d(K[0].x, K[0].y, K[0].z); + glVertex3d(K[1].x, K[1].y, K[1].z); + glVertex3d(K[2].x, K[2].y, K[2].z); + } + glEnd( ); + glDisable(GL_LINE_STIPPLE); + glLineWidth(kscreenscale); + glDisable(GL_ALPHA_TEST); + glEndList( ); // fin de la list + } + } + kk++; + ShowGlerror("end Mesh3 plot"); +} + +void Plot(const MeshS &Th, bool fill, bool plotmesh, bool plotborder, ThePlot &plot, GLint gllists, int *lok, OneWindow *win) { + // glDisable(GL_DEPTH_TEST); + + ShowGlerror("begin MeshS plot"); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + R z1 = plot.z0; + R z2 = plot.z0; + R coef = plot.coeff; + bool pNormalT = plot.pNormalT; + int nbN = plot.nbN; + + double r = 0, g = 0, b = 0; + if ((debug > 3)) cout << " OnePlotMeshS::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts( ) << " " << z1 << " " << z2 << endl; + // plot.SetColorTable(16) ; + bool cc[3] = {plotborder, plotmesh && fill, plotmesh}; + int kk = 0; + + if (cc[kk]) + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glLineWidth(2 * kscreenscale); + glBegin(GL_LINES); + for (int i = 0; i < Th.nbBrdElmts( ); i++) { + const MeshS::BorderElement &K(Th.be(i)); + plot.color(1 + abs(K.lab)); + glVertex3d(K[0].x, K[0].y, K[0].z); + glVertex3d(K[1].x, K[1].y, K[1].z); + } + glEnd( ); + glLineWidth(kscreenscale); + glEndList( ); // fin de la list + } + else + ; - if(nP) - { - if(nP>2) - { - R3 N(R3(P[0],P[1])^R3(P[0],P[2])); - N /= N.norme(); - glNormal3d(N.x,N.y,N.z); - } - glBegin(GL_POLYGON); - for(int i=0;i 5) cout << " plot Normal element at triangles and the tangent to border " << pNormalT << endl; + R h = 8 * win->hpixel; + coef = coef * sqrt(Th.mes / Th.nt); + glLineWidth(0.5 * kscreenscale); + glColor3f(1, 0, 0); + for (int i = 0; i < Th.nbe; i++) { + typedef MeshS::BorderElement BE; + typedef BE::Rd Rd; + typedef BE::RdHat RdHat; + const MeshS::BorderElement &K(Th.be(i)); + RdHat g(0.5); + Rd G(K(g)); + Rd dd(K[0], K[1]); + dd /= dd.norme( ); + // fleche ou cone / orientation ??? + R3 nx(1., 0., 0.), ny(0., 1., 0.), nz(0., 0., 1.); + // R3 dd = uv*(-h/l); + R3 dnx = (dd ^ nx) * 0.5, dny = (dd ^ ny) * 0.5, dnz = (dd ^ nz) * 0.5; + dd *= -coef / dd.norme( ) / 5; + dnx *= -coef / dnx.norme( ) / 5; + dny *= -coef / dny.norme( ) / 5; + dnz *= -coef / dnz.norme( ) / 5; + + glLineWidth(kscreenscale); + glBegin(GL_LINES); + win->Seg3(G, G + dd + dnx); + win->Seg3(G, G + dd - dnx); + win->Seg3(G, G + dd + dny); + win->Seg3(G, G + dd - dny); + win->Seg3(G, G + dd + dnz); + win->Seg3(G, G + dd - dnz); + glEnd( ); + } + + for (int i = 0; i < Th.nt; i = 0 ? i++ : i += nbN) { + const MeshS::Element &K(Th[i]); + R3 NN = K.NormalTUnitaire( ); + NN *= coef; + R2 PtHat = R2::diag(1. / 3.); + R3 A(K(PtHat)); + NN += A; + R3 dd(A, NN); + double l = Max(sqrt((dd, dd)), 1e-20); + glBegin(GL_LINES); + win->Seg3(A, NN); + glEnd( ); + + // fleche ou cone / orientation ??? + R3 nx(1., 0., 0.), ny(0., 1., 0.), nz(0., 0., 1.); + // R3 dd = uv*(-h/l); + R3 dnx = (dd ^ nx) * 0.5, dny = (dd ^ ny) * 0.5, dnz = (dd ^ nz) * 0.5; + dd *= -coef / dd.norme( ) / 5; + dnx *= -coef / dnx.norme( ) / 5; + dny *= -coef / dny.norme( ) / 5; + dnz *= -coef / dnz.norme( ) / 5; + + glLineWidth(kscreenscale); + glBegin(GL_LINES); + win->Seg3(NN, NN + dd + dnx); + win->Seg3(NN, NN + dd - dnx); + win->Seg3(NN, NN + dd + dny); + win->Seg3(NN, NN + dd - dny); + win->Seg3(NN, NN + dd + dnz); + win->Seg3(NN, NN + dd - dnz); + glEnd( ); + } + glLineWidth(kscreenscale); + } + ShowGlerror("end MeshS plot"); } +void Plot(const MeshL &Th, bool fill, bool plotmesh, bool plotborder, ThePlot &plot, GLint gllists, int *lok, OneWindow *win) { + glDisable(GL_DEPTH_TEST); -int dichotomie(const KN_ &viso,R v) -{ - int i=0,j=viso.N(),k; - if (v viso[j-1]) - return -1; - while (i v) j=k; - else i=k; - return i; -} - + ShowGlerror("begin MeshL plot"); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + R z1 = plot.z0; + R z2 = plot.z0; + R coef = plot.coeff; + bool pNormalT = plot.pNormalT; + int nbN = plot.nbN; + double r = 0, g = 0, b = 0; + if ((debug > 3)) cout << " OnePlotMeshL::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts( ) << " " << z1 << " " << z2 << endl; + // plot.SetColorTable(16) ; + bool cc[3] = {plotborder, plotmesh && fill, plotmesh}; + int kk = 0; -int ShowGlerror(const char *s) -{ - GLint error = glGetError(); - if ( error != GL_NO_ERROR ) - printf("Attention %s erreur : %x \n",s,error); - return error; -} + if (cc[kk]) + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glPointSize(3); + glBegin(GL_POINTS); + for (int i = 0; i < Th.nbBrdElmts( ); i++) { + const MeshL::BorderElement &K(Th.be(i)); + plot.color(1 + abs(K.lab)); + glVertex3d(K[0].x, K[0].y, K[0].z); + } + glEnd( ); + glPointSize(1); + glEndList( ); // fin de la list + } + else + ; + kk++; + if (cc[kk]) { + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glLineWidth(2 * kscreenscale); + // glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);//GL_FILL + glBegin(GL_LINES); + for (int i = 0; i < Th.nt; i++) { + const MeshL::Element &K(Th[i]); + plot.color(K.lab ? 1 + abs(K.lab) : 0); + glVertex3d(K[0].x, K[0].y, K[0].z); + glVertex3d(K[1].x, K[1].y, K[1].z); + } + glEnd( ); + glLineWidth(kscreenscale); + glEndList( ); + } + } + kk++; + if (cc[kk]) { + if (lok[kk]) + glCallList(gllists + kk); + else { + lok[kk] = 1; + glNewList(gllists + kk, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + glPolygonMode(GL_FRONT, GL_LINE); + glBegin(GL_LINES); + for (int i = 0; i < Th.nt; i++) { + const MeshL::Element &K(Th[i]); + plot.color(fill ? 1 : 1 + abs(K.lab)); + glVertex3d(K[0].x, K[0].y, K[0].z); + glVertex3d(K[1].x, K[1].y, K[1].z); + } + glEnd( ); + glEndList( ); // fin de la list + } + } + if (pNormalT) { + coef = coef * (Th.mes / Th.nt); + glLineWidth(0.5 * kscreenscale); + glColor3f(1, 0, 0); + + for (int i = 0; i < Th.nt; i = 0 ? i++ : i += nbN) { + const MeshL::Element &K(Th[i]); + R3 NN = K.NormalTUnitaire( ); + NN *= coef; + R1 PtHat = R1::diag(1. / 2.); + R3 A(K(PtHat)); + NN += A; + R3 dd(A, NN); + double l = Max(sqrt((dd, dd)), 1e-20); + glBegin(GL_LINES); + win->Seg3(A, NN); + glEnd( ); + + // fleche ou cone / orientation ??? + R3 nx(1., 0., 0.), ny(0., 1., 0.), nz(0., 0., 1.); + // R3 dd = uv*(-h/l); + R3 dnx = (dd ^ nx) * 0.5, dny = (dd ^ ny) * 0.5, dnz = (dd ^ nz) * 0.5; + dd *= -coef / dd.norme( ) / 5; + dnx *= -coef / dnx.norme( ) / 5; + dny *= -coef / dny.norme( ) / 5; + dnz *= -coef / dnz.norme( ) / 5; + + glLineWidth(kscreenscale); + glBegin(GL_LINES); + win->Seg3(NN, NN + dd + dnx); + win->Seg3(NN, NN + dd - dnx); + win->Seg3(NN, NN + dd + dny); + win->Seg3(NN, NN + dd - dny); + win->Seg3(NN, NN + dd + dnz); + win->Seg3(NN, NN + dd - dnz); + glEnd( ); + } + glLineWidth(kscreenscale); + } + ShowGlerror("end MeshL plot"); +} + +void OnePlotError::Draw(OneWindow *win) { + initlist( ); + win->SetScreenView( ); + glColor3d(0., 0., 0.); + cout << " Error plot item empty " << item << endl; + char s[100]; + snprintf(s, 100, "Warning the item %ld fot the plot is empty", item); + win->Show(s, 4 + item * 2); + win->SetView( ); +} + +template< class Mesh > +void OnePlotMesh< Mesh >::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + Plot(*Th, plot.fill, true, true, plot, gllists, oklist); + ShowGlerror("OnePlotMesh::Draw"); +} + +void OnePlotMesh3::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + Plot(*Th, plot.fill, true, true, plot, gllists, oklist); + ShowGlerror("OnePlotMesh3::Draw"); +} + +void OnePlotMeshS::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + Plot(*Th, plot.fill, true, true, plot, gllists, oklist, win); + ShowGlerror("OnePlotMeshS::Draw"); +} + +void OnePlotMeshL::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + Plot(*Th, plot.fill, true, true, plot, gllists, oklist, win); + ShowGlerror("OnePlotMeshL::Draw"); +} + +void OnePlotFE3::Draw(OneWindow *win) { + initlist( ); + + ThePlot &plot = *win->theplot; + ShowGlerror("begin OnePlotFE3 plot"); + /// plot.SetDefIsoV(); + if (plot.fill && what % 10 == 6) + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + bool change = false; + if ((what % 10 == 6)) { + change = win->changeiso; + } -// def des couleurs de la tables -void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,KN colors) -{ - int nbcolors = colors.N()/3; - if(k<=0) { r=g=b=1.;} // white - else if (k==1) { r=g=b=0.; } // black - else if (k >= nb) { r=g=b=0.;} // black - else if (grey) { float gg = 0.1+0.9*float(k-2)/(nb-3); r=g=b=gg;} - else if (nbcolors<=1) { - float h=float(k-2)/(nb-2),s=1.,v=1.; - hsvToRgb(h,s,v,r,g,b); - return;} - else { // interpolation dans la table hsv - int i= (k-2); - int j0= i*(nbcolors-1) / (nb-2); - int j1=j0+1; - int i0= j0*(nb-2)/(nbcolors-1); - int i1= j1*(nb-2)/(nbcolors-1); - int j03=j0*3,j13=j1*3; - float a=float(i1-i)/(i1-i0),a1=1-a; - if (hsv) - { - float h = colors[j03+0]*a + colors[j13+0]*a1; - float s = colors[j03+1]*a + colors[j13+1]*a1; - float v = colors[j03+2]*a + colors[j13+2]*a1; - hsvToRgb(h,s,v,r,g,b); } - else - { - r = colors[j03+0]*a + colors[j13+0]*a1; - g = colors[j03+1]*a + colors[j13+1]*a1; - b = colors[j03+2]*a + colors[j13+2]*a1; - } + if (what % 10 == 6) + glEnable(GL_DEPTH_TEST); + else + glEnable(GL_DEPTH_TEST); + win->setLighting( ); + if (oklist[0] && !change) + glCallList(gllists + 0); + else { + oklist[0] = 1; + glNewList(gllists + 0, GL_COMPILE_AND_EXECUTE); // save la list sans affichage + int nsubV = Psub.N( ); + int nsubT = Ksub.N( ) / 4; + KN< R3 > Pn(nsubV); + int nK = v.N( ) / Th->nt; + for (int k = 0, o = 0; k < Th->nt; ++k, o += nK) { + const Mesh3::Element &K = (*Th)[k]; + int ii[4]; // + R ff[4]; + R3 Pt[4]; + for (int i = 0; i < nsubV; ++i) Pn[i] = K(Psub[i]); + int lK = 0; + if (what % 10 == 6) + for (int sk = 0; sk < nsubT; ++sk) { + + for (int l = 0; l < 4; ++l) { + int iv = Ksub[lK++]; + ii[l] = iv; + Pt[l] = Pn[iv]; + ff[l] = v[o + iv]; + } + + for (int i = 0; i < plot.Viso.N( ); ++i) { + plot.color(i + 4); + drawisoTet(Pt, ff, plot.Viso[i]); + } + } + } + glEndList( ); // fin de la list + } + win->unsetLighting( ); + ShowGlerror("b mesh OnePlotFE plot"); + Plot(*Th, false, plot.drawmeshes, plot.drawborder, plot, gllists + 2, &oklist[2]); + ShowGlerror("OnePlotFE::Draw"); +} + +void OnePlotFES::Draw(OneWindow *win) { + + initlist( ); + ThePlot &plot = *win->theplot; + ShowGlerror("begin OnePlotFE plot"); + win->setLighting( ); + assert(win); + const MeshS &Th(*this->Th); + int nsubT = Ksub.N( ) / 3; // NbOfSubTriangle(nsub); + int nsubV = Psub.N( ); // NbOfSubInternalVertices(nsub); + int nK = v.N( ) / Th.nt; + if (debug > 4) cout << "\t\t\tOnePlotMesh::Draw " << v.N( ) << " ,nt " << Th.nt << " " << nK << " " << Psub.N( ) << " " << what << " ,nv " << Th.nv << " cas=" << cas << endl; + ffassert(v.N( ) == Th.nt * nK); + int o = 0; + KN< R3 > Pn(Psub.N( )); + + if ((debug > 10)) cout << " " << nsubV << " " << nsubT << endl; + + // compute Normal at vertice + KN< R3 > Nv(Th.nv); + for (int it = 0; it < Th.nv; it++) // + Nv[it] = R3(0., 0., 0.); // + for (int it = 0; it < Th.nt; it++) { + const MeshS::Element &K = (Th[it]); + int iv; + for (int i = 0; i < 3; i++) { + iv = Th.operator( )(K[i]); + Nv[iv] += K.mesure( ) * K.NormalT( ); } + } + for (int i = 0; i < Th.nv; i++) Nv[i] /= Nv[i].norme( ); -} + if (plot.fill && what % 10 == 8) + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); -template -void Plot(const Mesh & Th,bool fill,bool plotmesh,bool plotborder,ThePlot & plot,GLint gllists,int * lok) -{ + if (what % 10 == 9) glDisable(GL_DEPTH_TEST); + else + glEnable(GL_DEPTH_TEST); - ShowGlerror("begin Mesh plot"); - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - R z1= plot.z0; - R z2= plot.z0; - - - double r=0,g=0,b=0; - if((debug > 3)) cout<< " OnePlotMesh::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts() << " " << z1 << " " << z2 << endl; - bool cc[3]= { plotborder , plotmesh && fill , plotmesh }; - int kk=0; - if(cc[kk]) - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glLineWidth(2*kscreenscale); - glBegin(GL_LINES); - for (int i=0;igetcadre(xmin, xmax, ymin, ymax); + R cc = win->hpixel * 40; + R kk = 4 * win->hpixel; + if (plot.ArrowSize > 0) kk = win->hpixel * max(win->width * plot.ArrowSize / 100., 1.); + + int klist = 0; + bool change = false; + if ((what % 10 == 8)) { + if (plot.fill) klist = 1; + change = win->changeiso; + } else if (what % 10 == 9) + change = win->changearrow; + if (debug > 9) cout << change << " " << klist << " ... " << oklist[klist] << " fill = " << plot.fill << " " << coef << endl; + if (oklist[klist] && !change) + glCallList(gllists + klist); + else { + oklist[klist] = 1; + glNewList(gllists + klist, GL_COMPILE_AND_EXECUTE); // save la list aevc affichage + if (debug > 100) cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: " << plot.Viso << endl; + for (int k = 0; k < Th.nt; ++k, o += nK) { + const typename MeshS::Element &K = Th[k]; + int iv[3]; + for (int i = 0; i < 3; i++) iv[i] = Th.operator( )(K[i]); + + for (int i = 0; i < nsubV; ++i) Pn[i] = K(Psub[i]); // local to global coord. + + if (what % 10 == 8) + for (int sk = 0; sk < nsubT; ++sk) { + int i0 = Ksub[sk * 3 + 0]; // numSubTriangle(nsub,sk,0); + int i1 = Ksub[sk * 3 + 1]; // numSubTriangle(nsub,sk,1); + int i2 = Ksub[sk * 3 + 2]; // numSubTriangle(nsub,sk,2); + + R ff[3] = {v[o + i0], v[o + i1], v[o + i2]}; + R3 Pt[3] = {Pn[i0], Pn[i1], Pn[i2]}; + R3 Nt[3] = {Nv[iv[0]], Nv[iv[1]], Nv[iv[2]]}; + if (plot.fill) + plot.DrawIsoTfill(Pt, ff, Nt, plot.Viso, plot.Viso.N( ), win->changePlotdim, win->viewdim); + else + plot.DrawIsoT(Pt, ff, Nt, plot.Viso, plot.Viso.N( ), win->changePlotdim, win->viewdim); + } + else if (what % 10 == 9) + for (int i = 0, j = 0; i < nsubV; ++i) { + R3 P = Pn[i]; + R3 uv(v[o + j], v[o + j + 1], v[o + j + 2]); + j += 3; + R l = Max(sqrt((uv, uv)), 1e-30); + int col = 2 + dichotomie(plot.Varrow, l); + if (debug > 100) cout << uv << " l= " << l << " " << coef << " " << col << endl; + plot.color(2 + col); + uv *= coef; + + l *= coef; + R3 dd = uv * (-kk / l); + R ndd = dd.norme( ); + dd /= ndd; + R3 nx(1., 0., 0.), ny(0., 1., 0.), nz(0., 0., 1.); + R3 dnx = (dd ^ nx) * 0.5, dny = (dd ^ ny) * 0.5, dnz = (dd ^ nz) * 0.5; + + dnx *= -coef * ndd / dnx.norme( ); + dny *= -coef * ndd / dny.norme( ); + dnz *= -coef * ndd / dnz.norme( ); + + if (l * 10000. < kk) continue; + if (l < kk) + uv *= (kk / l) * coef; + else if (l > cc) + uv *= (cc / l) * coef; + + dd *= ndd * coef; // denormalize + + glBegin(GL_LINES); + win->Seg3(P, P + uv); + + if (10 * l > kk) { + win->Seg3(P + uv, P + uv + dd + dnx); + win->Seg3(P + uv, P + uv + dd - dnx); + win->Seg3(P + uv, P + uv + dd + dny); + win->Seg3(P + uv, P + uv + dd - dny); + win->Seg3(P + uv, P + uv + dd + dnz); + win->Seg3(P + uv, P + uv + dd - dnz); + } + glEnd( ); + } + } + glEndList( ); // fin de la list + } + ShowGlerror("b mesh OnePlotFES plot"); + win->unsetLighting( ); + Plot(Th, false, plot.drawmeshes, plot.drawborder, plot, gllists + 2, &oklist[2], win); + ShowGlerror("OnePlotFES::Draw"); +} + +void OnePlotFEL::Draw(OneWindow *win) { + + initlist( ); + ThePlot &plot = *win->theplot; + ShowGlerror("begin OnePlotFE plot"); + win->setLighting( ); + assert(win); + const MeshL &Th(*this->Th); + int nsubT = Ksub.N( ) / 2; + int nsubV = Psub.N( ); + int nK = v.N( ) / Th.nt; + if (debug > 4) cout << "\t\t\tOnePlotMesh::Draw " << v.N( ) << " ,nt " << Th.nt << " " << nK << " " << Psub.N( ) << " " << what << " ,nv " << Th.nv << " cas=" << cas << endl; + ffassert(v.N( ) == Th.nt * nK); + int o = 0; + KN< R3 > Pn(Psub.N( )); + if ((debug > 10)) cout << " " << nsubV << " " << nsubT << endl; + + // compute Normal at vertice + KN< R3 > Nv(Th.nv); + for (int it = 0; it < Th.nv; it++) // + Nv[it] = R3(0., 0., 0.); // + for (int it = 0; it < Th.nt; it++) { + const MeshL::Element &K = (Th[it]); + int iv; + for (int i = 0; i < 2; i++) { + iv = Th.operator( )(K[i]); + Nv[iv] += K.mesure( ) * K.NormalT( ); + } + } + for (int i = 0; i < Th.nv; i++) Nv[i] /= Nv[i].norme( ); - } - glEnd(); - glLineWidth(kscreenscale); - glEndList(); // fin de la list - } - else ; + if (plot.fill && (what == 14 || what == 20 || what == 114 || what == 120)) + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - kk++; + if (what == 15 || what == 21) + glDisable(GL_DEPTH_TEST); + else glEnable(GL_DEPTH_TEST); - if(cc[kk]) - { - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glPolygonMode(GL_FRONT,GL_FILL);//GL_FILL - glBegin(GL_TRIANGLES); - for (int i=0;igetcadre(xmin, xmax, ymin, ymax); + R kk = 4 * win->hpixel; + if (plot.ArrowSize > 0) kk = win->hpixel * max(win->width * plot.ArrowSize / 100., 1.); + + int klist = 0; + bool change = false; + if (what == 14 || what == 20 || what == 114 || what == 120) { + if (plot.fill) klist = 1; + change = win->changeiso; + } else if (what == 15 || what == 21) + change = win->changearrow; + if (debug > 9) cout << change << " " << klist << " ... " << oklist[klist] << " fill = " << plot.fill << " " << coef << endl; + if (oklist[klist] && !change) + glCallList(gllists + klist); + else { + oklist[klist] = 1; + glNewList(gllists + klist, GL_COMPILE_AND_EXECUTE); // save la list aevc affichage + if (debug > 100) cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: " << plot.Viso << endl; + for (int k = 0; k < Th.nt; ++k, o += nK) { + const typename MeshL::Element &K = Th[k]; + int iv[2]; + for (int i = 0; i < 2; i++) iv[i] = Th.operator( )(K[i]); + for (int i = 0; i < nsubV; ++i) Pn[i] = K(Psub[i]); // local to global coord. + if (what == 14 || what == 20 || what == 114 || what == 120) { + for (int sk = 0; sk < nsubT; ++sk) { + int i0 = Ksub[sk * 2 + 0], i1 = Ksub[sk * 2 + 1]; + R ff[2] = {v[o + i0], v[o + i1]}; + R3 Pt[2] = {Pn[i0], Pn[i1]}; + R3 Nt[2] = {Nv[iv[0]], Nv[iv[1]]}; + plot.DrawIsoEfill(Pt, ff, Nt, plot.Viso, plot.Viso.N( ), win->changePlotdim, win->viewdim); + } + } else + ffassert(0); + } + glEndList( ); // fin de la list + } + ShowGlerror("b mesh OnePlotFEL plot"); + win->unsetLighting( ); + Plot(Th, false, plot.drawmeshes, plot.drawborder, plot, gllists + 2, &oklist[2], win); + ShowGlerror("OnePlotFEL::Draw"); +} + +template< class Mesh > +OnePlotFE< Mesh >::OnePlotFE(const Mesh *T, long w, PlotStream &f) : OnePlot(w, 2, 5), Th(T), cas(2) { + R2 P0, P1; + Th->BoundingBox(P0, P1); + Pmin = P0; + Pmax = P1; + if (version == 2) { + long nsub; + + f >> nsub; + int nsubT = NbOfSubTriangle(nsub); + int nsubV = NbOfSubInternalVertices(nsub); + + Psub.resize(nsubV); + Ksub.resize(nsubT * 3); + for (int i = 0, j = 0; i < nsubV; ++i) Psub[i] = SubInternalVertex(nsub, i); + + for (int sk = 0, p = 0; sk < nsubT; ++sk) + for (int i = 0; i < 3; ++i, ++p) Ksub[p] = numSubTriangle(nsub, sk, i); + + } else { + f >> Psub; + f >> Ksub; + if (debug > 2) { + cout << " Psub " << Psub << endl; + cout << " Ksub " << Ksub << endl; } - kk++; - if(cc[kk]) - { - glEnable(GL_DEPTH_TEST); - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glPolygonMode(GL_FRONT,GL_LINE); - glBegin(GL_TRIANGLES); - for (int i=0;i> v; + else { + f >> vc; + vc2v( ); + } + cas = 2; + vc2v( ); + if (debug > 3) cout << "OnePlotFE" << Th << " " << what << " " << Psub.N( ) << " " << Ksub.N( ) / 3 << " " << v.N( ) << " cas " << cas << endl; + ffassert(f.good( )); +} + +template< class Mesh > +bool OnePlotFE< Mesh >::vc2v( ) { + bool ret = false; + if (what >= 10) { + ret = true; + int n = vc.N( ); + if (v.size( ) != n) v.resize(n); + for (int i = 0; i < n; ++i) + if (cas % 4 == 0) + v[i] = vc[i].real( ); + else if (cas % 4 == 1) + v[i] = vc[i].imag( ); + else if (cas % 4 == 2) + v[i] = abs(vc[i]); + else if (cas % 4 == 3) + v[i] = arg(vc[i]); + } - glEnd(); - glEndList(); // fin de la list - } + if (what % 10 == 1) { + fmin = min(fmin, v.min( )); + fmax = max(fmax, v.max( )); + } else if (what % 10 == 2) { + int n = v.N( ) / 2; + for (int i = 0, j = 0; i < n; i++, j += 2) { + R2 u(v[j], v[j + 1]); + vmax2 = max(vmax2, u.norme2( )); } - ShowGlerror("end Mesh plot"); + } + return ret; +} + +bool OnePlotFE3::vc2v( ) { + bool ret = false; + if (what >= 10) { + ret = true; + int n = vc.N( ); + if (v.size( ) != n) v.resize(n); + for (int i = 0; i < n; ++i) + if (cas % 4 == 0) + v[i] = vc[i].real( ); + else if (cas % 4 == 1) + v[i] = vc[i].imag( ); + else if (cas % 4 == 2) + v[i] = abs(vc[i]); + else if (cas % 4 == 3) + v[i] = arg(vc[i]); + } -} + if (what % 10 == 6) { + fmin = min(fmin, v.min( )); + fmax = max(fmax, v.max( )); + } else if (what % 10 == 7) { + int n = v.N( ) / 3; + for (int i = 0, j = 0; i < n; i++, j += 3) { + R3 u(v[j], v[j + 1], v[j + 2]); + vmax2 = max(vmax2, u.norme2( )); + } + } + return ret; +} + +bool OnePlotFES::vc2v( ) { + bool ret = false; + if (what >= 10) { + ret = true; + int n = vc.N( ); + if (v.size( ) != n) v.resize(n); + for (int i = 0; i < n; ++i) + if (cas % 4 == 0) + v[i] = vc[i].real( ); + else if (cas % 4 == 1) + v[i] = vc[i].imag( ); + else if (cas % 4 == 2) + v[i] = abs(vc[i]); + else if (cas % 4 == 3) + v[i] = arg(vc[i]); + } -void Plot(const Mesh3 & Th,bool fill,bool plotmesh,bool plotborder,ThePlot & plot,GLint gllists,int * lok) -{ - typedef Mesh3::BorderElement BE; - typedef Mesh3::Element Tet; - glEnable(GL_DEPTH_TEST); - ShowGlerror("begin Mesh3 plot"); + if (what % 10 == 8) { + fmin = min(fmin, v.min( )); + fmax = max(fmax, v.max( )); + } else if (what % 10 == 9) { - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + int n = v.N( ) / 3; + for (int i = 0, j = 0; i < n; i++, j += 3) { + R3 u(v[j], v[j + 1], v[j + 2]); + vmax2 = max(vmax2, u.norme2( )); + } + } + return ret; +} + +bool OnePlotFEL::vc2v( ) { + bool ret = false; + if (what >= 16) { + ret = true; + int n = vc.N( ); + if (v.size( ) != n) v.resize(n); + for (int i = 0; i < n; ++i) + if (cas % 4 == 0) + v[i] = vc[i].real( ); + else if (cas % 4 == 1) + v[i] = vc[i].imag( ); + else if (cas % 4 == 2) + v[i] = abs(vc[i]); + else if (cas % 4 == 3) + v[i] = arg(vc[i]); + } - R z1= plot.z0; - R z2= plot.z0; + if (what == 14 || what == 20 || what == 114 || what == 120) { + fmin = min(fmin, v.min( )); + fmax = max(fmax, v.max( )); + } else if (what == 15 || what == 21) { - double r=0,g=0,b=0; - if((debug > 3)) cout<< " OnePlotMesh3::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts() << " " << z1 << " " << z2 << endl; - bool cc[3]= { plotborder , plotborder && fill , plotmesh && fill }; - double saturation =plotmesh ? 1 : 0.25; - int kk=0; - if(Th.nbe==0) - { - if(lok[kk]) glCallList(gllists+kk); - else - { // draw all vertex - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glBegin(GL_POINTS); - for(int i=0; i +void OnePlotFE< Mesh >::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + ShowGlerror("begin OnePlotFE plot"); + win->setLighting( ); + assert(win); + const Mesh &Th(*this->Th); + int nsubT = Ksub.N( ) / 3; // NbOfSubTriangle(nsub); + int nsubV = Psub.N( ); // NbOfSubInternalVertices(nsub); + int nK = v.N( ) / Th.nt; + if (debug > 4) cout << "\t\t\tOnePlotMesh::Draw " << v.N( ) << " ,nt " << Th.nt << " " << nK << " " << Psub.N( ) << " " << what << " ,nv " << Th.nv << " cas=" << cas << endl; + ffassert(v.N( ) == Th.nt * nK); + ffassert(nK == nsubV * (what % 10)); + int o = 0; + KN< R2 > Pn(Psub.N( )); + if ((debug > 10)) cout << " " << nsubV << " " << nsubT << endl; + + if (plot.fill && what % 10 == 1) + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + if (what % 10 == 2) + glDisable(GL_DEPTH_TEST); + else + glEnable(GL_DEPTH_TEST); - glEndList(); // fin de la list - } - } - kk=2; - if(cc[kk]) - { - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glLineWidth(kscreenscale); - glPolygonMode(GL_FRONT,GL_FILL);//GL_FILL - glBegin(GL_TRIANGLES); - for (int i=0;igetcadre(xmin, xmax, ymin, ymax); + R kk = 4 * win->hpixel; + if (plot.ArrowSize > 0) kk = win->hpixel * max(win->width * plot.ArrowSize / 100., 1.); + R cc = win->hpixel * 40; + + int klist = 0; + bool change = false; + if ((what % 10 == 1)) { + if (plot.fill) klist = 1; + change = win->changeiso; + } else if (what % 10 == 2) + change = win->changearrow; + if (debug > 9) cout << change << " " << klist << " ... " << oklist[klist] << " fill = " << plot.fill << " " << coef << endl; + if (oklist[klist] && !change) + glCallList(gllists + klist); + else { + oklist[klist] = 1; + glNewList(gllists + klist, GL_COMPILE_AND_EXECUTE); // save la list aevc affichage + if (debug > 100) cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: " << plot.Viso << endl; + for (int k = 0; k < Th.nt; ++k, o += nK) { + const typename Mesh::Element &K = Th[k]; + for (int i = 0; i < nsubV; ++i) Pn[i] = K(Psub[i]); // local to global coord. + if (what % 10 == 1) + for (int sk = 0; sk < nsubT; ++sk) { + int i0 = Ksub[sk * 3 + 0]; // numSubTriangle(nsub,sk,0); + int i1 = Ksub[sk * 3 + 1]; // numSubTriangle(nsub,sk,1); + int i2 = Ksub[sk * 3 + 2]; // numSubTriangle(nsub,sk,2); + + R ff[3] = {v[o + i0], v[o + i1], v[o + i2]}; + R2 Pt[3] = {Pn[i0], Pn[i1], Pn[i2]}; + if (plot.fill) + plot.DrawIsoTfill(Pt, ff, plot.Viso, plot.Viso.N( )); + else + plot.DrawIsoT(Pt, ff, plot.Viso, plot.Viso.N( )); + } + else // what ==2 + for (int i = 0, j = 0; i < nsubV; ++i) { + R2 P = Pn[i]; + R2 uv(v[o + j], v[o + j + 1]); + j += 2; + R l = Max(sqrt((uv, uv)), 1e-30); + int col = 2 + dichotomie(plot.Varrow, l); + if (debug > 100) cout << uv << " l= " << l << " " << coef << " " << col << endl; + + plot.color(2 + col); + uv = coef * uv; + l *= coef; + R2 dd = uv * (-kk / l); + R2 dn = dd.perp( ) * 0.5; + if (l * 10000. < kk) continue; + if (l < kk) + uv = uv * (kk / l); + else if (l > cc) + uv = uv * (cc / l); + glBegin(GL_LINES); + + win->Seg(P, P + uv); + + if (10 * l > kk) { + win->Seg(P + uv, P + uv + dd + dn); + win->Seg(P + uv, P + uv + dd - dn); + } + glEnd( ); + } + } + glEndList( ); // fin de la list + } - glEndList(); // fin de la list - } + ShowGlerror("b mesh OnePlotFE plot"); + win->unsetLighting( ); + Plot(Th, false, plot.drawmeshes, plot.drawborder, plot, gllists + 2, &oklist[2]); + ShowGlerror("OnePlotFE::Draw"); +} + +template< class Mesh > +void OnePlotFE< Mesh >::dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn2, R &vmx2) const { + const Mesh &Th(*this->Th); + int nsubT = Ksub.N( ) / 3; // NbOfSubTriangle(nsub); + int nsubV = Psub.N( ); // NbOfSubInternalVertices(nsub); + int nK = v.N( ) / Th.nt; + ffassert(v.N( ) == Th.nt * nK); + ffassert(nK == nsubV * (what % 10)); + int o = 0; + KN< R2 > Pn(Psub.N( )); + KN< R3 > P3(Psub.N( )); + double xmin, xmax, ymin, ymax; + KN< int > inCadre(nsubV); + win->getcadre(xmin, xmax, ymin, ymax); + bool ccc = false; + bool ddd = false; + if (ddd) cout << " dyn__ .. " << endl; + for (int k = 0; k < Th.nt; ++k, o += nK) { + const typename Mesh::Element &K = Th[k]; + inCadre = 0; + for (int i = 0; i < nsubV; ++i) Pn[i] = K(Psub[i]); // local to global coord. + for (int i = 0; i < nsubV; ++i) { + double f = 0; + if (what % 10 == 1) f = v[o + i]; + gluProject(Pn[i].x, Pn[i].y, f, win->modelMatrix, win->projMatrix, win->viewport, &P3[i].x, &P3[i].y, &P3[i].z); + if (ddd) cout << P3[i] << ", "; + + } // local to global coord. + if (ddd) cout << endl; + for (int sk = 0; sk < nsubT; ++sk) { + int i1 = Ksub[sk * 3 + 0], i2 = Ksub[sk * 3 + 1], i3 = Ksub[sk * 3 + 2]; + R3 P0 = Minc(Minc(P3[i1], P3[i2]), P3[i3]); + R3 P1 = Maxc(Maxc(P3[i1], P3[i2]), P3[i3]); + if (win->InRecScreen(P0, P1)) { + if (debug > 100) cout << " ??? " << P0 << " " << P1 << " , " << win->Bmin << " , " << win->Bmax << endl; + inCadre[i1] = 2; + inCadre[i2] = 2; + inCadre[i3] = 2; + } } - kk++; - ShowGlerror("end Mesh3 plot"); + for (int i = 0, j = 0; i < nsubV; ++i) + if (inCadre[i]) { + ccc = true; + if (what % 10 == 1) { + R f = v[o + i]; + fmn = min(f, fmn); + fmx = max(f, fmx); -} + } else // what ==2 -void Plot(const MeshS & Th,bool fill,bool plotmesh,bool plotborder, ThePlot & plot,GLint gllists,int * lok, OneWindow *win) -{ - //glDisable(GL_DEPTH_TEST); - - ShowGlerror("begin MeshS plot"); - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - R z1= plot.z0; - R z2= plot.z0; - R coef = plot.coeff; - bool pNormalT=plot.pNormalT; - int nbN=plot.nbN; - - double r=0,g=0,b=0; - if((debug > 3)) cout<< " OnePlotMeshS::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts() << " " << z1 << " " << z2 << endl; - // plot.SetColorTable(16) ; - bool cc[3]= { plotborder , plotmesh && fill , plotmesh }; - int kk=0; - - if(cc[kk]) - if(lok[kk]) glCallList(gllists+kk); - else { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glLineWidth(2*kscreenscale); - glBegin(GL_LINES); - for (int i=0;i 100 && ccc) cout << " dny_bfv : " << fmn << " " << fmx << " " << sqrt(vmn2) << " " << sqrt(vmx2) << " : " << Pn[0] << endl; + } +} +OnePlotCurve::OnePlotCurve(PlotStream &f, int nfield, ThePlot *theplot) : OnePlot(3, 2, 1), cas(0) { + f >> xx >> yy; + if (nfield >= 3) f >> zz; + if (nfield == 4) f >> cc; + ffassert(f.good( )); + ffassert(xx.N( ) && yy.N( ) && xx.N( ) == yy.N( )); + Pmin = Minc(Pmin, R3(xx.min( ), yy.min( ), Pmin.z)); + Pmax = Maxc(Pmax, R3(xx.max( ), yy.max( ), Pmax.z)); + if (zz.N( )) { + Pmin.z = Min(Pmin.z, zz.min( )); + Pmax.z = Max(Pmax.z, zz.max( )); + if (cc.N( ) == 0) { + fmax = Max(fmax, zz.max( )); + fmin = Min(fmin, zz.min( )); + theplot->withiso = true; + } + + } else + Pmin.z = Pmax.z = 0.; // Bof Bof .. FH Juin 2019 ... + if (cc.N( )) { + fmax = Max(fmax, cc.max( )); + fmin = Min(fmin, cc.min( )); + theplot->withiso = true; + } + if (debug > 3) + cout << " OnePlotCurve nbfield " << nfield << " max, N= " << xx.max( ) << " " << xx.N( ) << ", " << yy.max( ) << " " << yy.N( ) << " " << zz.N( ) << " " << cc.N( ) << " f " << fmin << " " << fmax + << endl; + ; +} - } - glEnd(); - glLineWidth(kscreenscale); - glEndList(); // fin de la list - } - else ; +void OnePlotCurve::dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn2, R &vmx2) const { + if (cc.N( ) == xx.N( )) { + ; // afaire ???? + } +} +void OnePlotCurve::Draw(OneWindow *win) { + initlist( ); + ThePlot &plot = *win->theplot; + double z = plot.z0; + if (debug > 3) cout << " OnePlotCurve::Draw " << (cc.N( ) != xx.N( )) << endl; + if (cas % 2) + glBegin(GL_POINTS); + else + glBegin(GL_LINE_STRIP); + plot.color(2); + if ((zz.N( ) != xx.N( )) && (cc.N( ) == 0)) + for (int i = 0; i < xx.N( ); i++) glVertex3d(xx[i], yy[i], z); + else if (cc.N( ) == 0) + for (int i = 0; i < xx.N( ); i++) glVertex3d(xx[i], yy[i], zz[i]); + else + for (int i = 0; i < xx.N( ); i++) { + int col = 2 + dichotomie(plot.Viso, cc[i]); + if (col < 1) col = 1; + if (col > plot.Viso.N( )) col = plot.Viso.N( ); + plot.color(col); + glVertex3d(xx[i], yy[i], zz[i]); + } + + glEnd( ); +} + +void OnePlotBorder::Draw(OneWindow *win) { + initlist( ); + + glDisable(GL_DEPTH_TEST); + ThePlot &plot = *win->theplot; + R h = 10 * win->hpixel * kscreenscale; + double z = plot.z0; + plot.SetColorTable(16); + + if (win->plotdim == 3) + for (int i = 0; i < data.size( ); ++i) { + vector< pair< long, R3 > > &v = data[i]; + ShowGlerror("end OnePlotBorder::Draw 1"); + + for (int j = 1; j < v.size( ); ++j) { + plot.color(2 + v[j].first); + R3 Po(v[j - 1].second), Pn(v[j].second); + R3 uv(Po, Pn); + double l = Max(sqrt((uv, uv)), 1e-20); + R3 nx(1., 0., 0.), ny(0., 1., 0.), nz(0., 0., 1.); + R3 dd = uv * (-h / l); + R3 dnx = (dd ^ nx) * 0.7, dny = (dd ^ ny) * 0.7, dnz = (dd ^ nz) * 0.7; + + glLineWidth(2 * kscreenscale); + glBegin(GL_LINES); + win->Seg3(Po, Pn); + glEnd( ); - kk++; - if(cc[kk]) - { - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);//GL_FILL - glBegin(GL_TRIANGLES); - for (int i=0;iSeg3(Po, Po + dd + dnx); + win->Seg3(Po, Po + dd - dnx); + win->Seg3(Po, Po + dd + dny); + win->Seg3(Po, Po + dd - dny); + win->Seg3(Po, Po + dd + dnz); + win->Seg3(Po, Po + dd - dnz); + } + glEnd( ); + } + ShowGlerror("end OnePlotBorder::Draw 2"); + + glPointSize(7); + glBegin(GL_POINTS); + int l = v.size( ) - 1; + plot.color(2 + v[0].first); + glVertex3d(v[0].second.x, v[0].second.y, v[0].second.z); + plot.color(2 + v[l].first); + glVertex3d(v[l].second.x, v[l].second.y, v[l].second.z); + glEnd( ); + glPointSize(1); + ShowGlerror("end OnePlotBorder::Draw 3"); + } + + else if (win->plotdim == 2) + for (int i = 0; i < data.size( ); ++i) { + vector< pair< long, R3 > > &v = data[i]; + ShowGlerror("end OnePlotBorder::Draw 1"); + + for (int j = 1; j < v.size( ); ++j) { + plot.color(2 + v[j].first); + R2 Po(v[j - 1].second.p2( )), Pn(v[j].second.p2( )); + R2 uv(Po, Pn); + double l = Max(sqrt((uv, uv)), 1e-20); + + R2 dd = uv * (-h / l); + R2 dn = dd.perp( ) * 0.5; + glLineWidth(2 * kscreenscale); + glBegin(GL_LINES); + win->Seg(Po, Pn); + glEnd( ); - } - glEnd(); - glEndList(); + glLineWidth(kscreenscale); + glBegin(GL_LINES); + if (j != 1) { + win->Seg(Po, Po + dd + dn); + win->Seg(Po, Po + dd - dn); } - } - kk++; - if(cc[kk]) - { - if(lok[kk]) glCallList(gllists+kk); - else - { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glPolygonMode(GL_FRONT,GL_LINE); - glBegin(GL_TRIANGLES); - for (int i=0;i5) cout << " plot Normal element at triangles and the tangent to border " << pNormalT << endl; - R h = 8*win->hpixel; - coef = coef*sqrt(Th.mes/Th.nt); - glLineWidth(0.5*kscreenscale); - glColor3f(1,0,0); - for (int i=0;iSeg3(G,G+dd+dnx); - win->Seg3(G,G+dd-dnx); - win->Seg3(G,G+dd+dny); - win->Seg3(G,G+dd-dny); - win->Seg3(G,G+dd+dnz); - win->Seg3(G,G+dd-dnz); - glEnd(); - - - } - for (int i=0;iSeg3(A,NN); - glEnd(); - - // fleche ou cone / orientation ??? - R3 nx(1.,0.,0.), ny(0.,1.,0.), nz(0.,0.,1.); - // R3 dd = uv*(-h/l); - R3 dnx = (dd^nx)*0.5, dny = (dd^ny)*0.5, dnz = (dd^nz)*0.5; - dd *= -coef/dd.norme()/5; - dnx *= -coef/dnx.norme()/5; - dny *= -coef/dny.norme()/5; - dnz *= -coef/dnz.norme()/5; - - glLineWidth(kscreenscale); - glBegin(GL_LINES); - win->Seg3(NN,NN+dd+dnx); - win->Seg3(NN,NN+dd-dnx); - win->Seg3(NN,NN+dd+dny); - win->Seg3(NN,NN+dd-dny); - win->Seg3(NN,NN+dd+dnz); - win->Seg3(NN,NN+dd-dnz); - glEnd(); - } - glLineWidth(kscreenscale); - } - + ShowGlerror("end OnePlotBorder::Draw"); +} - ShowGlerror("end MeshS plot"); +inline void plotquadx(float y, float iy, float z, float iz, float x1, bool outline = 0) { + glVertex3d(x1, y, z); + glVertex3d(x1, y + iy, z); + if (outline) glVertex3d(x1, y + iy, z); + glVertex3d(x1, y + iy, z + iz); + glVertex3d(x1, y + iy, z + iz); + glVertex3d(x1, y, z + iz); + if (outline) glVertex3d(x1, y, z + iz); + glVertex3d(x1, y, z); +} +inline void plotquady(float x, float ix, float z, float iz, float y1, bool outline = 0) { + glVertex3d(x, y1, z); + glVertex3d(x + ix, y1, z); + if (outline) glVertex3d(x + ix, y1, z); + glVertex3d(x + ix, y1, z + iz); + glVertex3d(x + ix, y1, z + iz); + glVertex3d(x, y1, z + iz); + if (outline) glVertex3d(x, y1, z + iz); + glVertex3d(x, y1, z); } +inline void plotquadz(float x, float ix, float y, float iy, float z1, bool outline = 0) { + glVertex3d(x, y, z1); + glVertex3d(x + ix, y, z1); + if (outline) glVertex3d(x + ix, y, z1); + glVertex3d(x + ix, y + iy, z1); + glVertex3d(x + ix, y + iy, z1); + glVertex3d(x, y + iy, z1); + if (outline) glVertex3d(x, y + iy, z1); + glVertex3d(x, y, z1); +} +void OnePlotHMatrix::Draw(OneWindow *win) { + if (si <= 0 || sj <= 0) return; + R scalez, zeps, dx, dy, dz; -void Plot(const MeshL & Th,bool fill,bool plotmesh,bool plotborder,ThePlot & plot,GLint gllists,int * lok, OneWindow *win) -{ + if (win->plotdim == 2) { glDisable(GL_DEPTH_TEST); - - ShowGlerror("begin MeshL plot"); - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - R z1= plot.z0; - R z2= plot.z0; - R coef = plot.coeff; - bool pNormalT=plot.pNormalT; - int nbN=plot.nbN; - - double r=0,g=0,b=0; - if((debug > 3)) cout<< " OnePlotMeshL::Draw " << plotmesh << " " << plotborder << " " << Th.nbBrdElmts() << " " << z1 << " " << z2 << endl; - // plot.SetColorTable(16) ; - bool cc[3]= { plotborder , plotmesh && fill , plotmesh }; - int kk=0; - - if(cc[kk]) - if(lok[kk]) - glCallList(gllists+kk); - else { - lok[kk]=1; - glNewList(gllists+kk,GL_COMPILE_AND_EXECUTE ); // save la list sans affichage - glPointSize(3); - glBegin(GL_POINTS); - for (int i=0;iSeg3(A,NN); - glEnd(); - - // fleche ou cone / orientation ??? - R3 nx(1.,0.,0.), ny(0.,1.,0.), nz(0.,0.,1.); - // R3 dd = uv*(-h/l); - R3 dnx = (dd^nx)*0.5, dny = (dd^ny)*0.5, dnz = (dd^nz)*0.5; - dd *= -coef/dd.norme()/5; - dnx *= -coef/dnx.norme()/5; - dny *= -coef/dny.norme()/5; - dnz *= -coef/dnz.norme()/5; - - glLineWidth(kscreenscale); - glBegin(GL_LINES); - win->Seg3(NN,NN+dd+dnx); - win->Seg3(NN,NN+dd-dnx); - win->Seg3(NN,NN+dd+dny); - win->Seg3(NN,NN+dd-dny); - win->Seg3(NN,NN+dd+dnz); - win->Seg3(NN,NN+dd-dnz); - glEnd(); - } - glLineWidth(kscreenscale); - } - ShowGlerror("end MeshL plot"); - -} + scalez = 0; + zeps = 0; + dx = 0; + dy = 0; + dz = 0; + } else { + glEnable(GL_DEPTH_TEST); + scalez = 0.5; + zeps = 0.001; + dx = -5e-4 * (win->Pvue3.x - win->cam.x); + dy = -5e-4 * (win->Pvue3.y - win->cam.y); + dz = -5e-4 * (win->Pvue3.z - win->cam.z); + } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + R z1 = 0; -void OnePlotError::Draw(OneWindow *win) -{ - initlist(); - win->SetScreenView() ; - glColor3d(0.,0.,0.); - cout << " Error plot item empty " << item << endl; - char s[100]; - snprintf(s,100,"Warning the item %ld fot the plot is empty",item); - win->Show(s,4+item*2); - win->SetView() ; -} + glBegin(GL_TRIANGLES); + for (int i = 0; i < nbdense; i++) { + std::pair< int, int > &offset = offsetsdense[i]; + std::pair< int, int > &size = sizesdense[i]; + z1 = scalez; + if (size.first > 1 || size.second > 1) { + glColor3f(1, 0, 0); // glColor3f((20.)/255,(80.)/255,(20.)/255); + plotquadz((float)offset.second / sj, (float)size.second / sj, 1. - (float)offset.first / si, -(float)size.first / si, z1); + + if (win->plotdim == 3) { + plotquadx(1. - (float)offset.first / si, -(float)size.first / si, 0, z1, (float)offset.second / sj); + plotquadx(1. - (float)offset.first / si, -(float)size.first / si, 0, z1, (float)(offset.second + size.second) / sj); + plotquady((float)offset.second / sj, (float)size.second / sj, 0, z1, 1. - (float)offset.first / si); + plotquady((float)offset.second / sj, (float)size.second / sj, 0, z1, 1. - (float)(offset.first + size.first) / si); + plotquadz((float)offset.second / sj, (float)size.second / sj, 1. - (float)offset.first / si, -(float)size.first / si, 0); + } + } + } -template -void OnePlotMesh::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot=*win->theplot; - Plot(*Th,plot.fill,true,true,plot,gllists,oklist); - ShowGlerror("OnePlotMesh::Draw"); -} - -void OnePlotMesh3::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot=*win->theplot; - Plot(*Th,plot.fill,true,true,plot,gllists,oklist); - ShowGlerror("OnePlotMesh3::Draw"); -} - -void OnePlotMeshS::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot=*win->theplot; - Plot(*Th,plot.fill,true,true,plot,gllists,oklist,win); - ShowGlerror("OnePlotMeshS::Draw"); -} - -void OnePlotMeshL::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot=*win->theplot; - Plot(*Th,plot.fill,true,true,plot,gllists,oklist,win); - ShowGlerror("OnePlotMeshL::Draw"); -} - -void OnePlotFE3::Draw(OneWindow *win) -{ - initlist(); - - ThePlot & plot=*win->theplot; - ShowGlerror("begin OnePlotFE3 plot"); - /// plot.SetDefIsoV(); - if(plot.fill && what%10==6) - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - else - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - bool change=false; - if( (what%10==6) ) - { - change = win->changeiso ; - } - - if(what%10==6) - glEnable(GL_DEPTH_TEST); - else - glEnable(GL_DEPTH_TEST); - win->setLighting(); - if(oklist[0] && !change) - glCallList(gllists+0); - else - { - oklist[0]=1; - glNewList(gllists+0,GL_COMPILE_AND_EXECUTE); // save la list sans affichage - int nsubV=Psub.N(); - int nsubT=Ksub.N()/4; - KN Pn(nsubV); - int nK=v.N()/ Th->nt; - for(int k=0,o=0;knt;++k, o+= nK) - { - const Mesh3::Element & K=(*Th)[k]; - int ii[4];// - R ff[4]; - R3 Pt[4]; - for(int i=0;iunsetLighting(); - ShowGlerror("b mesh OnePlotFE plot"); - Plot(*Th,false,plot.drawmeshes,plot.drawborder,plot,gllists+2,&oklist[2]); - ShowGlerror("OnePlotFE::Draw"); -} - - - - - -void OnePlotFES::Draw(OneWindow *win) -{ - - initlist(); - ThePlot & plot=*win->theplot; - ShowGlerror("begin OnePlotFE plot"); - win->setLighting(); - assert(win); - const MeshS & Th(*this->Th); - int nsubT= Ksub.N()/3;//NbOfSubTriangle(nsub); - int nsubV=Psub.N();//NbOfSubInternalVertices(nsub); - int nK=v.N()/ Th.nt; - if(debug>4) - cout << "\t\t\tOnePlotMesh::Draw " < Nv(Th.nv); - for (int it=0 ; itgetcadre(xmin,xmax,ymin,ymax); - R cc = win->hpixel*40; - R kk = 4*win->hpixel; - if(plot.ArrowSize>0) kk=win->hpixel*max(win->width*plot.ArrowSize/100.,1.); - - int klist=0; - bool change=false; - if( (what%10==8) ) - { - if ( plot.fill) klist=1; - change = win->changeiso ; - } - else if (what%10==9) - change = win->changearrow ; - if(debug>9) - cout << change << " " << klist << " ... " << oklist[klist] << " fill = " - << plot.fill << " " << coef << endl; - if (oklist[klist] && ! change ) - glCallList(gllists+klist); - else - { - oklist[klist]=1; - glNewList(gllists+klist,GL_COMPILE_AND_EXECUTE); // save la list aevc affichage - if(debug>100) - cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: "<< plot.Viso << endl; - for(int k=0;kchangePlotdim,win->viewdim); - else - plot.DrawIsoT( Pt, ff, Nt, plot.Viso,plot.Viso.N(),win->changePlotdim,win->viewdim); - } - else if (what%10==9) - for (int i=0,j=0;i100) - cout << uv << " l= " << l << " " << coef << " " < cc) - uv *= (cc/l)*coef; - - dd*=ndd*coef; // denormalize - - - glBegin(GL_LINES); - win->Seg3(P,P+uv); - - if (10*l>kk) { - win->Seg3(P+uv,P+uv+dd+dnx); - win->Seg3(P+uv,P+uv+dd-dnx); - win->Seg3(P+uv,P+uv+dd+dny); - win->Seg3(P+uv,P+uv+dd-dny); - win->Seg3(P+uv,P+uv+dd+dnz); - win->Seg3(P+uv,P+uv+dd-dnz); - } - glEnd(); - } - } - glEndList(); // fin de la list - -} - ShowGlerror("b mesh OnePlotFES plot"); - win->unsetLighting(); - Plot(Th,false,plot.drawmeshes,plot.drawborder,plot,gllists+2,&oklist[2],win); - ShowGlerror("OnePlotFES::Draw"); -} - -void OnePlotFEL::Draw(OneWindow *win) -{ - - initlist(); - ThePlot & plot=*win->theplot; - ShowGlerror("begin OnePlotFE plot"); - win->setLighting(); - assert(win); - const MeshL & Th(*this->Th); - int nsubT= Ksub.N()/2; - int nsubV=Psub.N(); - int nK=v.N()/ Th.nt; - if(debug>4) - cout << "\t\t\tOnePlotMesh::Draw " < Nv(Th.nv); - for (int it=0 ; itgetcadre(xmin,xmax,ymin,ymax); - R kk = 4*win->hpixel; - if(plot.ArrowSize>0) kk=win->hpixel*max(win->width*plot.ArrowSize/100.,1.); - - int klist=0; - bool change=false; - if(what == 14 || what == 20 || what == 114 || what == 120) { - if ( plot.fill) klist=1; - change = win->changeiso ; - } - else if (what==15 || what==21) - change = win->changearrow ; - if(debug>9) - cout << change << " " << klist << " ... " << oklist[klist] << " fill = " - << plot.fill << " " << coef << endl; - if (oklist[klist] && ! change ) - glCallList(gllists+klist); - else { - oklist[klist]=1; - glNewList(gllists+klist,GL_COMPILE_AND_EXECUTE); // save la list aevc affichage - if(debug>100) - cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: "<< plot.Viso << endl; - for(int k=0;kchangePlotdim,win->viewdim); - } - } - else - ffassert(0); - - } - glEndList(); // fin de la list - - } - ShowGlerror("b mesh OnePlotFEL plot"); - win->unsetLighting(); - Plot(Th,false,plot.drawmeshes,plot.drawborder,plot,gllists+2,&oklist[2],win); - ShowGlerror("OnePlotFEL::Draw"); -} - - -template -OnePlotFE::OnePlotFE(const Mesh *T,long w,PlotStream & f) -:OnePlot(w,2,5),Th(T),cas(2) -{ - R2 P0,P1; - Th->BoundingBox(P0,P1); - Pmin=P0; - Pmax=P1; - if(version==2) - { - long nsub; - - f>> nsub; - int nsubT=NbOfSubTriangle(nsub); - int nsubV=NbOfSubInternalVertices(nsub); - - Psub.resize(nsubV); - Ksub.resize(nsubT*3); - for(int i=0,j=0;i> Psub ; - f >> Ksub ; - if(debug>2) { - cout << " Psub " << Psub << endl; - cout << " Ksub " << Ksub << endl;} - - } - if(what<10) - f>> v; - else - { - f>> vc; - vc2v(); - } - cas =2; - vc2v(); - if(debug>3) cout << "OnePlotFE" << Th <<" " << what<< " " << Psub.N() << " " << Ksub.N()/3 <<" " << v.N() << " cas " << cas << endl; - ffassert(f.good()); - -} - - - -template -bool OnePlotFE::vc2v() -{ - bool ret=false; - if(what>=10) - { - ret=true; - int n = vc.N(); - if(v.size() !=n) - v.resize(n); - for(int i=0;i=10) - { - ret=true; - int n = vc.N(); - if(v.size() !=n) - v.resize(n); - for(int i=0;i=10) - { - ret=true; - int n = vc.N(); - if(v.size() !=n) - v.resize(n); - for(int i=0;i=16) - { - ret=true; - int n = vc.N(); - if(v.size() !=n) - v.resize(n); - for(int i=0;i -void OnePlotFE::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot=*win->theplot; - ShowGlerror("begin OnePlotFE plot"); - win->setLighting(); - assert(win); - const Mesh & Th(*this->Th); - int nsubT= Ksub.N()/3;//NbOfSubTriangle(nsub); - int nsubV=Psub.N();//NbOfSubInternalVertices(nsub); - int nK=v.N()/ Th.nt; - if(debug>4) - cout << "\t\t\tOnePlotMesh::Draw " <getcadre(xmin,xmax,ymin,ymax); - R kk = 4*win->hpixel; - if(plot.ArrowSize>0) kk=win->hpixel*max(win->width*plot.ArrowSize/100.,1.); - R cc = win->hpixel*40; - - int klist=0; - bool change=false; - if( (what%10==1) ) - { - if ( plot.fill) klist=1; - change = win->changeiso ; - } - else if (what%10==2) - change = win->changearrow ; - if(debug>9) - cout << change << " " << klist << " ... " << oklist[klist] << " fill = " - << plot.fill << " " << coef << endl; - if (oklist[klist] && ! change ) - glCallList(gllists+klist); - else - { - oklist[klist]=1; - glNewList(gllists+klist,GL_COMPILE_AND_EXECUTE); // save la list aevc affichage - if(debug>100) - cout << win->Bmin << ", Bmax: " << win->Bmax << " Viso: "<< plot.Viso << endl; - for(int k=0;k100) - cout << uv << " l= " << l << " " << coef << " " < cc) - uv = uv*(cc/l); - glBegin(GL_LINES); - - win->Seg(P,P+uv); - - if (10*l>kk) { - win->Seg(P+uv,P+uv+dd+dn); - win->Seg(P+uv,P+uv+dd-dn); - } - glEnd(); - } - - } - glEndList(); // fin de la list - } - - ShowGlerror("b mesh OnePlotFE plot"); - win->unsetLighting(); - Plot(Th,false,plot.drawmeshes,plot.drawborder,plot,gllists+2,&oklist[2]); - ShowGlerror("OnePlotFE::Draw"); -} - -template -void OnePlotFE::dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn2,R & vmx2) const -{ - const Mesh & Th(*this->Th); - int nsubT= Ksub.N()/3;//NbOfSubTriangle(nsub); - int nsubV=Psub.N();//NbOfSubInternalVertices(nsub); - int nK=v.N()/ Th.nt; - ffassert(v.N()== Th.nt*nK); - ffassert(nK == nsubV*(what%10)); - int o=0; - KN Pn(Psub.N()); - KN P3(Psub.N()); - double xmin,xmax,ymin,ymax; - KN inCadre(nsubV); - win->getcadre(xmin,xmax,ymin,ymax); - bool ccc=false; - bool ddd=false; - if(ddd) - cout << " dyn__ .. " << endl; - for(int k=0;kmodelMatrix,win->projMatrix,win->viewport, - &P3[i].x,&P3[i].y,&P3[i].z); - if(ddd) - cout <InRecScreen(P0,P1)) - { - if(debug>100) - cout << " ??? " << P0 << " " << P1 << " , " << win->Bmin - << " , " << win->Bmax << endl; - inCadre[i1]=2; - inCadre[i2]=2; - inCadre[i3]=2; - } - } - for (int i=0,j=0;i100 && ccc) - cout << " dny_bfv : " << fmn << " " << fmx << " " << sqrt(vmn2) << " " << sqrt(vmx2) - << " : " << Pn[0] << endl; - - } -} - -OnePlotCurve::OnePlotCurve(PlotStream & f,int nfield,ThePlot *theplot) -:OnePlot(3,2,1),cas(0) -{ - f >> xx>>yy; - if( nfield >=3) - f >> zz; - if( nfield ==4) - f >> cc; - ffassert(f.good()); - ffassert(xx.N() && yy.N() && xx.N() == yy.N()); - Pmin=Minc(Pmin,R3(xx.min(),yy.min(),Pmin.z)); - Pmax=Maxc(Pmax,R3(xx.max(),yy.max(),Pmax.z)); - if(zz.N()) - { - Pmin.z = Min(Pmin.z,zz.min()); - Pmax.z = Max(Pmax.z,zz.max()); - if( cc.N() ==0) - { - fmax = Max(fmax,zz.max()); - fmin = Min(fmin,zz.min()); - theplot->withiso=true; - } - - } - else - Pmin.z=Pmax.z=0.; // Bof Bof .. FH Juin 2019 ... - if( cc.N() ) - { - fmax = Max(fmax,cc.max()); - fmin = Min(fmin,cc.min()); - theplot->withiso=true; - } - if(debug>3) cout << " OnePlotCurve nbfield "<< nfield << " max, N= " << xx.max() << " " - << xx.N() << ", " << yy.max() << " " << yy.N() << " "<< zz.N() << " " << cc.N() << " f " << fmin << " " << fmax << endl;; - -} - -void OnePlotCurve::dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn2,R & vmx2) const -{ - if( cc.N() == xx.N()) - { - ; // afaire ???? - } -} -void OnePlotCurve::Draw(OneWindow *win) -{ - initlist(); - ThePlot & plot= *win->theplot; - double z = plot.z0; - if(debug>3) cout << " OnePlotCurve::Draw " << (cc.N() != xx.N()) << endl; - if(cas%2) - glBegin(GL_POINTS); - else - glBegin(GL_LINE_STRIP); - plot.color(2); - if( (zz.N()!=xx.N()) && (cc.N()==0) ) - for (int i=0;iplot.Viso.N()) col=plot.Viso.N(); - plot.color(col); - glVertex3d(xx[i],yy[i],zz[i]); - } - - glEnd(); - -} - -void OnePlotBorder::Draw(OneWindow *win) -{ - initlist(); - - glDisable(GL_DEPTH_TEST); - ThePlot & plot= *win->theplot; - R h = 10*win->hpixel*kscreenscale; - double z = plot.z0; - plot.SetColorTable(16) ; - - if(win->plotdim==3) - for(int i=0;i > & v=data[i]; - ShowGlerror("end OnePlotBorder::Draw 1"); - - for(int j=1;jSeg3(Po,Pn); - glEnd(); - - glLineWidth(kscreenscale); - glBegin(GL_LINES); - if(j!=1) { - win->Seg3(Po,Po+dd+dnx); - win->Seg3(Po,Po+dd-dnx); - win->Seg3(Po,Po+dd+dny); - win->Seg3(Po,Po+dd-dny); - win->Seg3(Po,Po+dd+dnz); - win->Seg3(Po,Po+dd-dnz); - } - glEnd(); - } - ShowGlerror("end OnePlotBorder::Draw 2"); - - glPointSize(7); - glBegin(GL_POINTS); - int l= v.size()-1; - plot.color(2+v[0].first); - glVertex3d(v[0].second.x,v[0].second.y,v[0].second.z); - plot.color(2+v[l].first); - glVertex3d(v[l].second.x,v[l].second.y,v[l].second.z); - glEnd(); - glPointSize(1); - ShowGlerror("end OnePlotBorder::Draw 3"); - } - - else if(win->plotdim==2) - for(int i=0;i > & v=data[i]; - ShowGlerror("end OnePlotBorder::Draw 1"); - - for(int j=1;jSeg(Po,Pn); - glEnd(); - - glLineWidth(kscreenscale); - glBegin(GL_LINES); - if(j!=1) - { - win->Seg(Po,Po+dd+dn); - win->Seg(Po,Po+dd-dn); - } - glEnd(); - } - - ShowGlerror("end OnePlotBorder::Draw 2"); - - glPointSize(7); - glBegin(GL_POINTS); - int l= v.size()-1; - plot.color(2+v[0].first); - glVertex3d(v[0].second.x,v[0].second.y,z); - plot.color(2+v[l].first); - glVertex3d(v[l].second.x,v[l].second.y,z); - glEnd(); - glPointSize(1); - ShowGlerror("end OnePlotBorder::Draw 3"); - } - - - - - - - ShowGlerror("end OnePlotBorder::Draw"); - -} - - -inline void plotquadx(float y, float iy, float z, float iz, float x1, bool outline = 0){ - glVertex3d(x1, y, z); - glVertex3d(x1, y+iy, z); - if (outline) glVertex3d(x1, y+iy, z); - glVertex3d(x1, y+iy, z+iz); - glVertex3d(x1, y+iy, z+iz); - glVertex3d(x1, y, z+iz); - if (outline) glVertex3d(x1, y, z+iz); - glVertex3d(x1, y, z); -} - -inline void plotquady(float x, float ix, float z, float iz, float y1, bool outline = 0){ - glVertex3d(x, y1, z); - glVertex3d(x+ix, y1, z); - if (outline) glVertex3d(x+ix, y1, z); - glVertex3d(x+ix, y1, z+iz); - glVertex3d(x+ix, y1, z+iz); - glVertex3d(x, y1, z+iz); - if (outline) glVertex3d(x, y1, z+iz); - glVertex3d(x, y1, z); -} - -inline void plotquadz(float x, float ix, float y, float iy, float z1, bool outline = 0){ - glVertex3d(x, y, z1); - glVertex3d(x+ix, y, z1); - if (outline) glVertex3d(x+ix, y, z1); - glVertex3d(x+ix, y+iy, z1); - glVertex3d(x+ix, y+iy, z1); - glVertex3d(x, y+iy, z1); - if (outline) glVertex3d(x, y+iy, z1); - glVertex3d(x, y, z1); -} - -void OnePlotHMatrix::Draw(OneWindow *win) -{ - if (si <= 0 || sj <= 0) - return; - - R scalez, zeps, dx, dy, dz; - - if (win->plotdim==2) { - glDisable(GL_DEPTH_TEST); - scalez = 0; - zeps = 0; - dx = 0; - dy = 0; - dz = 0; - } - else { - glEnable(GL_DEPTH_TEST); - scalez = 0.5; - zeps = 0.001; - dx = -5e-4*(win->Pvue3.x - win->cam.x); - dy = -5e-4*(win->Pvue3.y - win->cam.y); - dz = -5e-4*(win->Pvue3.z - win->cam.z); - } - - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - - R z1= 0; - - glBegin(GL_TRIANGLES); - for (int i=0;i < nbdense; i++) { - std::pair& offset = offsetsdense[i]; - std::pair& size = sizesdense[i]; - z1 = scalez; - if (size.first > 1 || size.second > 1) { - glColor3f(1,0,0); //glColor3f((20.)/255,(80.)/255,(20.)/255); - plotquadz((float)offset.second/sj, (float)size.second/sj, 1.-(float)offset.first/si, -(float)size.first/si, z1); - - if (win->plotdim==3) { - plotquadx(1.-(float)offset.first/si, -(float)size.first/si, 0, z1, (float)offset.second/sj); - plotquadx(1.-(float)offset.first/si, -(float)size.first/si, 0, z1, (float)(offset.second+size.second)/sj); - plotquady((float)offset.second/sj, (float)size.second/sj, 0, z1, 1.-(float)offset.first/si); - plotquady((float)offset.second/sj, (float)size.second/sj, 0, z1, 1.-(float)(offset.first+size.first)/si); - plotquadz((float)offset.second/sj, (float)size.second/sj, 1.-(float)offset.first/si, -(float)size.first/si, 0); - } - } - } - - for (int i=0;i < nblr; i++) { - std::pair& offset = offsetslr[i]; - std::pair& size = sizeslr[i]; - z1 = scalez*(1-compression[i]); + for (int i = 0; i < nblr; i++) { + std::pair< int, int > &offset = offsetslr[i]; + std::pair< int, int > &size = sizeslr[i]; + z1 = scalez * (1 - compression[i]); if (size.first > 1 || size.second > 1) { - glColor3f((20+compression[i]*80)/255,(80+compression[i]*170)/255,(20+compression[i]*80)/255); - if (win->theplot->fill || win->plotdim==3) - plotquadz((float)offset.second/sj, (float)size.second/sj, 1.-(float)offset.first/si, -(float)size.first/si, z1); + glColor3f((20 + compression[i] * 80) / 255, (80 + compression[i] * 170) / 255, (20 + compression[i] * 80) / 255); + if (win->theplot->fill || win->plotdim == 3) + plotquadz((float)offset.second / sj, (float)size.second / sj, 1. - (float)offset.first / si, -(float)size.first / si, z1); else { - plotquadz((float)offset.second/sj, (float)rankslr[i]/sj, 1.-(float)offset.first/si, -(float)size.first/si, z1); - plotquadz((float)offset.second/sj, (float)size.second/sj, 1.-(float)offset.first/si, -(float)rankslr[i]/si, z1); + plotquadz((float)offset.second / sj, (float)rankslr[i] / sj, 1. - (float)offset.first / si, -(float)size.first / si, z1); + plotquadz((float)offset.second / sj, (float)size.second / sj, 1. - (float)offset.first / si, -(float)rankslr[i] / si, z1); } - if (win->plotdim==3) { - plotquadx(1.-(float)offset.first/si, -(float)size.first/si, 0, z1, (float)offset.second/sj); - plotquadx(1.-(float)offset.first/si, -(float)size.first/si, 0, z1, (float)(offset.second+size.second)/sj); - plotquady((float)offset.second/sj, (float)size.second/sj, 0, z1, 1.-(float)offset.first/si); - plotquady((float)offset.second/sj, (float)size.second/sj, 0, z1, 1.-(float)(offset.first+size.first)/si); - plotquadz((float)offset.second/sj, (float)size.second/sj, 1.-(float)offset.first/si, -(float)size.first/si, 0); + if (win->plotdim == 3) { + plotquadx(1. - (float)offset.first / si, -(float)size.first / si, 0, z1, (float)offset.second / sj); + plotquadx(1. - (float)offset.first / si, -(float)size.first / si, 0, z1, (float)(offset.second + size.second) / sj); + plotquady((float)offset.second / sj, (float)size.second / sj, 0, z1, 1. - (float)offset.first / si); + plotquady((float)offset.second / sj, (float)size.second / sj, 0, z1, 1. - (float)(offset.first + size.first) / si); + plotquadz((float)offset.second / sj, (float)size.second / sj, 1. - (float)offset.first / si, -(float)size.first / si, 0); } } } - glEnd(); + glEnd( ); // For sparse matrices double vmax = -1e+30; - for (int i=0;i vmax && abs(compression[i]) < 1e10) - vmax = abs(compression[i]); + for (int i = 0; i < nblr; i++) + if (abs(compression[i]) > vmax && abs(compression[i]) < 1e10) vmax = abs(compression[i]); glPointSize(2); glBegin(GL_POINTS); - for (int i=0;i < nblr; i++) { - std::pair& offset = offsetslr[i]; - std::pair& size = sizeslr[i]; + for (int i = 0; i < nblr; i++) { + std::pair< int, int > &offset = offsetslr[i]; + std::pair< int, int > &size = sizeslr[i]; z1 = 0; if (size.first == 1 && size.second == 1) { - float val = compression[i]/vmax; - glColor3f((20+val*80)/255,(80+val*170)/255,(20+val*80)/255); - glVertex3d((float)offset.second/sj, 1.-(float)offset.first/si ,z1); + float val = compression[i] / vmax; + glColor3f((20 + val * 80) / 255, (80 + val * 170) / 255, (20 + val * 80) / 255); + glVertex3d((float)offset.second / sj, 1. - (float)offset.first / si, z1); } } - glEnd(); - if (win->plotdim==3) { + glEnd( ); + if (win->plotdim == 3) { glBegin(GL_LINES); - for (int i=0;i < nblr; i++) { - std::pair& offset = offsetslr[i]; - std::pair& size = sizeslr[i]; + for (int i = 0; i < nblr; i++) { + std::pair< int, int > &offset = offsetslr[i]; + std::pair< int, int > &size = sizeslr[i]; z1 = 0; if (size.first == 1 && size.second == 1) { - float val = compression[i]/vmax; - glColor3f((20+val*80)/255,(80+val*170)/255,(20+val*80)/255); - glVertex3d((float)offset.second/sj, 1.-(float)offset.first/si ,z1); - glVertex3d((float)offset.second/sj, 1.-(float)offset.first/si ,z1+(float)val); + float val = compression[i] / vmax; + glColor3f((20 + val * 80) / 255, (80 + val * 170) / 255, (20 + val * 80) / 255); + glVertex3d((float)offset.second / sj, 1. - (float)offset.first / si, z1); + glVertex3d((float)offset.second / sj, 1. - (float)offset.first / si, z1 + (float)val); } } - glEnd(); + glEnd( ); } glLineWidth(kscreenscale); - glColor3f(0,0,0); + glColor3f(0, 0, 0); glBegin(GL_LINES); - for (int i=0;i < nbdense; i++) { - std::pair& offset = offsetsdense[i]; - std::pair& size = sizesdense[i]; + for (int i = 0; i < nbdense; i++) { + std::pair< int, int > &offset = offsetsdense[i]; + std::pair< int, int > &size = sizesdense[i]; z1 = scalez; if (size.first > 1 || size.second > 1) { - plotquadz((float)offset.second/sj+dx, (float)size.second/sj, 1.-(float)offset.first/si+dy, -(float)size.first/si, dz,1); + plotquadz((float)offset.second / sj + dx, (float)size.second / sj, 1. - (float)offset.first / si + dy, -(float)size.first / si, dz, 1); - if (win->plotdim==3) { - plotquadx(1.-(float)offset.first/si+dy, -(float)size.first/si, dz, z1+dz, (float)offset.second/sj+dx,1); - plotquadx(1.-(float)offset.first/si+dy, -(float)size.first/si, dz, z1+dz, (float)(offset.second+size.second)/sj+dx,1); - plotquadz((float)offset.second/sj+dx, (float)size.second/sj, 1.-(float)offset.first/si+dy, -(float)size.first/si, z1+dz,1); + if (win->plotdim == 3) { + plotquadx(1. - (float)offset.first / si + dy, -(float)size.first / si, dz, z1 + dz, (float)offset.second / sj + dx, 1); + plotquadx(1. - (float)offset.first / si + dy, -(float)size.first / si, dz, z1 + dz, (float)(offset.second + size.second) / sj + dx, 1); + plotquadz((float)offset.second / sj + dx, (float)size.second / sj, 1. - (float)offset.first / si + dy, -(float)size.first / si, z1 + dz, 1); } } } - for (int i=0;i < nblr; i++) { - std::pair& offset = offsetslr[i]; - std::pair& size = sizeslr[i]; - z1 = scalez*(1-compression[i]); + for (int i = 0; i < nblr; i++) { + std::pair< int, int > &offset = offsetslr[i]; + std::pair< int, int > &size = sizeslr[i]; + z1 = scalez * (1 - compression[i]); if (size.first > 1 || size.second > 1) { - plotquadz((float)offset.second/sj+dx, (float)size.second/sj, 1.-(float)offset.first/si+dy, -(float)size.first/si, dz,1); - if (!win->theplot->fill && win->plotdim==2) - plotquadz((float)(offset.second+rankslr[i])/sj+dx, (float)(size.second-rankslr[i])/sj, 1.-(float)(offset.first+rankslr[i])/si+dy, -(float)(size.first-rankslr[i])/si, dz,1); - - if (win->plotdim==3) { - plotquadx(1.-(float)offset.first/si+dy, -(float)size.first/si, dz, z1+dz, (float)offset.second/sj+dx,1); - plotquadx(1.-(float)offset.first/si+dy, -(float)size.first/si, dz, z1+dz, (float)(offset.second+size.second)/sj+dx,1); - plotquadz((float)offset.second/sj+dx, (float)size.second/sj, 1.-(float)offset.first/si+dy, -(float)size.first/si, z1+dz,1); + plotquadz((float)offset.second / sj + dx, (float)size.second / sj, 1. - (float)offset.first / si + dy, -(float)size.first / si, dz, 1); + if (!win->theplot->fill && win->plotdim == 2) + plotquadz((float)(offset.second + rankslr[i]) / sj + dx, (float)(size.second - rankslr[i]) / sj, 1. - (float)(offset.first + rankslr[i]) / si + dy, -(float)(size.first - rankslr[i]) / si, dz, + 1); + + if (win->plotdim == 3) { + plotquadx(1. - (float)offset.first / si + dy, -(float)size.first / si, dz, z1 + dz, (float)offset.second / sj + dx, 1); + plotquadx(1. - (float)offset.first / si + dy, -(float)size.first / si, dz, z1 + dz, (float)(offset.second + size.second) / sj + dx, 1); + plotquadz((float)offset.second / sj + dx, (float)size.second / sj, 1. - (float)offset.first / si + dy, -(float)size.first / si, z1 + dz, 1); } } } - glEnd(); - glColor3f(0,0,0); - for (int i=0;i < nblr; i++) { - std::pair& offset = offsetslr[i]; - std::pair& size = sizeslr[i]; - z1 = scalez*(1-compression[i]); + glEnd( ); + glColor3f(0, 0, 0); + for (int i = 0; i < nblr; i++) { + std::pair< int, int > &offset = offsetslr[i]; + std::pair< int, int > &size = sizeslr[i]; + z1 = scalez * (1 - compression[i]); if (size.first > 1 || size.second > 1) { - string s = win->theplot->value ? std::to_string(int(100*compression[i])) : std::to_string(rankslr[i]); - float scale = 0.005*std::min((float)size.first/si,(float)size.second/sj)/**std::min(mSize.x(),mSize.y())*/; - if (win->theplot->value) - scale *= 0.9; + string s = win->theplot->value ? std::to_string(int(100 * compression[i])) : std::to_string(rankslr[i]); + float scale = 0.005 * std::min((float)size.first / si, (float)size.second / sj) /**std::min(mSize.x(),mSize.y())*/; + if (win->theplot->value) scale *= 0.9; - R textx = -36*scale*s.length()+(float)(offset.second+size.second*0.5)/sj; - R texty = -48*scale+1.-float(offset.first+size.first*0.5)/si; - R textz = z1+zeps; + R textx = -36 * scale * s.length( ) + (float)(offset.second + size.second * 0.5) / sj; + R texty = -48 * scale + 1. - float(offset.first + size.first * 0.5) / si; + R textz = z1 + zeps; - if (win->theplot->value) - textx -= 10*scale*s.length(); + if (win->theplot->value) textx -= 10 * scale * s.length( ); bool ptext = 0; - if (win->plotdim==2 && scale > 0.028/std::min(win->height,win->width)*win->hpixel*win->width) - ptext = 1; - if (win->plotdim==3)// && sqrt((win->Pvue3.x-textx)*(win->Pvue3.x-textx)+(win->Pvue3.y-texty)*(win->Pvue3.y-texty)+(win->Pvue3.z-textz)*(win->Pvue3.z-textz)) < 0.1) + if (win->plotdim == 2 && scale > 0.028 / std::min(win->height, win->width) * win->hpixel * win->width) ptext = 1; + if (win->plotdim == 3) // && sqrt((win->Pvue3.x-textx)*(win->Pvue3.x-textx)+(win->Pvue3.y-texty)*(win->Pvue3.y-texty)+(win->Pvue3.z-textz)*(win->Pvue3.z-textz)) < 0.1) ptext = 1; if (ptext) { - glPushMatrix(); + glPushMatrix( ); glTranslatef(textx, texty, textz); - glScalef(scale,scale,scale); - for(char& c : s) - glutStrokeCharacter(GLUT_STROKE_ROMAN,c); + glScalef(scale, scale, scale); + for (char &c : s) glutStrokeCharacter(GLUT_STROKE_ROMAN, c); if (win->theplot->value) { - glScalef(0.3,0.3,0.3); - glutStrokeCharacter(GLUT_STROKE_ROMAN,'%'); + glScalef(0.3, 0.3, 0.3); + glutStrokeCharacter(GLUT_STROKE_ROMAN, '%'); } - glPopMatrix(); + glPopMatrix( ); } } } - } +OneWindow::OneWindow(int h, int w, ThePlot *p) + : countdisplay(0), icurrentPlot(lplots.begin( )), lplotssize(0), height(h), width(w), theplot(0), hpixel(1), Bmin(0, 0), Bmax(1, 1), oBmin(Bmin), oBmax(Bmax), zmin(0), zmax(1), windowdump(false), + help(false), rapz0(-1.), rapz(1), withlight(false), changearrow(true), changeiso(true), keepPV(false), init(false) { -OneWindow::OneWindow(int h,int w,ThePlot *p) -: -countdisplay(0), -icurrentPlot(lplots.begin()), -lplotssize(0), -height(h),width(w),theplot(0),hpixel(1), -Bmin(0,0),Bmax(1,1),oBmin(Bmin),oBmax(Bmax),zmin(0),zmax(1), -windowdump(false),help(false), rapz0(-1.),rapz(1),withlight(false), -changearrow(true),changeiso(true), keepPV(false),init(false) -{ + add(p); +} - add(p); +void OneWindow::set(ThePlot *p) { + theplot = p; + if (p) { + if (debug) cout << "OneWindow:: set " << p->keepPV << " -> " << keepPV << endl; + plotdim = p->plotdim; + if (!keepPV) keepPV = p->keepPV; + pNormalT = p->pNormalT; + rapz0 = p->ZScale; + } + if (!init) { + rapz0 = -1; + if (p) rapz0 = p->ZScale; + DefaultView(2); + } } +void OneWindow::add(ThePlot *p) { + if (p) { + if (debug) cout << "OneWindow:: add " << p->keepPV << " -> " << keepPV << endl; + if (!keepPV) keepPV = p->keepPV; + lplots.push_back(p); + lplotssize++; + ++icurrentPlot; + if (icurrentPlot == lplots.end( )) --icurrentPlot; // the previous + if (icurrentPlot != lplots.end( )) set(*icurrentPlot); + if (lplotssize > 20) // pass 10 -> 20 for O. Pironneau 21/12/2020 FH. + { + bool isfirst = theplot == *lplots.begin( ); + if (debug > 1) cout << " delete a plot " << *lplots.begin( ) << endl; + delete *lplots.begin( ); + lplots.erase(lplots.begin( )); + lplotssize--; + if (isfirst) set(*lplots.begin( )); // change to the next plot + } + } else + set(p); +} + +void OneWindow::DefaultView(int state) { + if (debug > 1) cout << "DefaultView " << state << " " << keepPV << " theplot " << theplot << endl; + if (keepPV) { + if (state == 0 && init) return; + } else { + if (theplot && theplot->ZScale > 0) + rapz0 = theplot->ZScale; + else + rapz0 = -1; + } -void OneWindow::set(ThePlot *p) -{ - theplot=p; - if(p) - { - if( debug) cout << "OneWindow:: set "<< p->keepPV << " -> "<< keepPV << endl; - plotdim=p->plotdim; - if(!keepPV)keepPV=p->keepPV; - pNormalT=p->pNormalT; - rapz0 = p->ZScale; + if (theplot) { + init = 1; + plotdim = theplot->plotdim; + keepPV = theplot->keepPV; + R3 A(theplot->Pmin), B(theplot->Pmax); + R3 D(A, B); + R dxy = max(D.x, D.y); + zmax = theplot->fmax; + zmin = theplot->fmin; + theta = theplot->theta; + phi = theplot->phi; + if (theplot->ZScale > 0) rapz0 = theplot->ZScale; + if (theplot->datadim == 3) + rapz0 = 1; + else if (rapz0 <= 0) { + rapz0 = 0.4 * dxy / (zmax - zmin); + if (debug > 2) { + cout << " rapz0 = " << rapz0; + cout << " dz = " << zmax - zmin << " dxy =" << dxy << endl; + } } - if(!init) - { - rapz0 =-1; - if(p) rapz0 = p->ZScale; - DefaultView(2) ; + + rapz = rapz0; + coef_dist = theplot->dcoef; + focal = theplot->focal; + + if (theplot->datadim == 3) { + Bmin3 = A; + Bmax3 = B; + } else { // data plot 2d ou 1 d... + if (theplot->boundingbox.size( ) == 4) { + Bmin3.x = theplot->boundingbox[0]; + Bmin3.y = theplot->boundingbox[1]; + Bmax3.x = theplot->boundingbox[2]; + Bmax3.y = theplot->boundingbox[3]; + } else { + Bmin3.x = A.x; + Bmin3.y = A.y; + Bmax3.x = B.x; + Bmax3.y = B.y; + } + Bmin3.z = theplot->fmin; + Bmax3.z = theplot->fmax; + } + Pvue3 = (Bmin3 + Bmax3) / 2; + + D *= 0.05; + if (theplot->boundingbox.size( ) != 4) { + A -= D; + B += D; + } else { + R x1 = theplot->boundingbox[0], y1 = theplot->boundingbox[1]; + R x2 = theplot->boundingbox[2], y2 = theplot->boundingbox[3]; + A = R2(min(x1, x2), min(y1, y2)); + B = R2(max(x1, x2), max(y1, y2)); } + if (theplot->aspectratio) + cadreortho(A.p2( ), B.p2( )); + else + cadre(A.p2( ), B.p2( )); + } + hpixel = (Bmax.x - Bmin.x) / width; + + // SetView() ; } -void OneWindow::add(ThePlot *p) -{ - if(p) { - if( debug) cout << "OneWindow:: add "<< p->keepPV << " -> "<< keepPV << endl; - if(!keepPV) keepPV=p->keepPV; - lplots.push_back(p); - lplotssize++; - ++icurrentPlot; - if(icurrentPlot==lplots.end()) - --icurrentPlot;// the previous - if(icurrentPlot != lplots.end()) - set(*icurrentPlot); - if( lplotssize>20)// pass 10 -> 20 for O. Pironneau 21/12/2020 FH. - { - bool isfirst = theplot == *lplots.begin(); - if(debug >1) - cout << " delete a plot " << *lplots.begin() << endl; - delete *lplots.begin(); - lplots.erase(lplots.begin()); - lplotssize--; - if(isfirst) set(*lplots.begin()); // change to the next plot - } - } - else - set(p); -} - -void OneWindow::DefaultView(int state) -{ - if(debug>1) cout << "DefaultView " << state << " " <ZScale>0) rapz0=theplot->ZScale; - else rapz0=-1; - } - - if(theplot) - { - init =1; - plotdim=theplot->plotdim; - keepPV=theplot->keepPV; - R3 A(theplot->Pmin),B(theplot->Pmax); - R3 D(A,B); - R dxy= max(D.x,D.y); - zmax = theplot->fmax; - zmin = theplot->fmin; - theta=theplot->theta; - phi=theplot->phi; - if(theplot->ZScale>0) rapz0=theplot->ZScale; - if(theplot->datadim==3) rapz0=1; - else if(rapz0<=0) - { - rapz0 = 0.4* dxy/(zmax-zmin) ; - if(debug>2) - { - cout << " rapz0 = " << rapz0 ; - cout << " dz = " << zmax-zmin << " dxy =" << dxy << endl; - } - } +void OneWindow::SetScreenView( ) const { - rapz=rapz0; - coef_dist=theplot->dcoef; - focal=theplot->focal; - - if(theplot->datadim==3) - { - Bmin3=A; - Bmax3=B; - } - else - { // data plot 2d ou 1 d... - if(theplot->boundingbox.size() ==4) - { - Bmin3.x=theplot->boundingbox[0]; - Bmin3.y=theplot->boundingbox[1]; - Bmax3.x=theplot->boundingbox[2]; - Bmax3.y=theplot->boundingbox[3]; - } - else - { - Bmin3.x=A.x; - Bmin3.y=A.y; - Bmax3.x=B.x; - Bmax3.y=B.y; - } - Bmin3.z=theplot->fmin; - Bmax3.z=theplot->fmax; - } - Pvue3=(Bmin3+Bmax3)/2; - - - - D *=0.05; - if(theplot->boundingbox.size() !=4) - { - A -= D; - B += D; - } - else - { - R x1=theplot->boundingbox[0],y1=theplot->boundingbox[1]; - R x2=theplot->boundingbox[2],y2=theplot->boundingbox[3]; - A = R2(min(x1,x2),min(y1,y2)); - B = R2(max(x1,x2),max(y1,y2)); - } - - if (theplot->aspectratio) - cadreortho(A.p2(),B.p2()); - else - cadre(A.p2(),B.p2()); - } - hpixel = (Bmax.x-Bmin.x)/width; - - // SetView() ; + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_PROJECTION); + glLoadIdentity( ); + glOrtho(0, width, 0, height, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity( ); } -void OneWindow::SetScreenView() const -{ +void OneWindow::SetView( ) { + if (plotdim == 3 && theplot) { + glViewport(0, 0, width, height); - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0,width,0,height,-1,1); + glLoadIdentity( ); + R ratio = (double)width / (double)height; glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void OneWindow::SetView() -{ - if(plotdim==3 && theplot) - { - glViewport(0, 0,width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - R ratio= (double) width / (double) height; - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - - R aspect=ratio; - R3 DD(Bmin3,Bmax3); - DD.z *= rapz; - R dmax= DD.norme();; - R dist = 0.5*dmax/sin(focal/2)*coef_dist; - cam.x=Pvue3.x+cos(phi)*cos(theta)*dist; - cam.y=Pvue3.y+cos(phi)*sin(theta)*dist; - cam.z=Pvue3.z*rapz+dist*sin(phi); - R znear=max(dist-dmax,1e-30); - R zfare=dist+dmax; - gluPerspective(focal*180./my_pi,aspect,znear,zfare); - if(debug>2) - { - cout << " BB " << Bmin3 << " , " << Bmax3 << " rapz " << rapz << " dmax: "<< dmax << endl; - cout <<" setview 3d: rapz " << rapz << " cam: "; - cout << cam << " Pvue:" ; - cout << Pvue3 << " theta " << theta << " phi = "<< phi << endl; - } - gluLookAt(cam.x,cam.y,cam.z,Pvue3.x,Pvue3.y,Pvue3.z*rapz,0.,0.,1.); - glScaled(1.,1.,rapz); - - glGetDoublev(GL_PROJECTION_MATRIX,projMatrix); - ShowGlerror(" Get PM"); - glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix); - ShowGlerror(" Get MV"); - glGetIntegerv(GL_VIEWPORT,viewport); - ShowGlerror(" Get VP"); - viewdim=3; - - } - else - { - ShowGlerror("Begin SetView"); - glDisable(GL_DEPTH_TEST); - glViewport(0, 0,width, height); - R dz0,dz1,zm=0; - if(plotdim==3) - { - dz0=Bmin3.z; - dz1=Bmax3.z; - } - else - { - R zzmin = Min(zmin,theplot->fminT); - R zzmax = Max(zmax,theplot->fmaxT); - R dz = (zzmax-zzmin); - zm=(zzmin+zzmax)*0.5; - // to be sur the the z size is no zero . - dz = max(dz,(Bmax.x-Bmin.x)*0.1); - dz = max(dz,(Bmax.y-Bmin.y)*0.1); - dz0=-dz; - dz1 = dz; - viewdim=2; - } - - if((debug>3 )) cout << "\t\t\t SetView " << this << " " << Bmin << " " - << Bmax << " dz " << dz0 << " " << dz1 - << " theta " << theta << " phi = "<< phi << " // "<< Bmax - Bmin << " w " <aspectratio) - { - cadreortho(oBmin,oBmax); - } - -} - -void OneWindow::zoom(R coef) -{ - coef_dist*=coef; - R2 M=(oBmin+oBmax)/2.; - R2 D=(oBmax-oBmin)/2.; - R2 A= M - D*coef; - R2 B= M + D*coef; - if (theplot->aspectratio) - cadreortho(A,B); - else - cadre(A,B); - -} -void OneWindow::zoom(int w,int h,R coef) -{ - GLdouble x=w,y=height-h,z=(zmin+zmax)/2.; - GLdouble xx,yy,zz; - - - GLint ok= gluUnProject( x,y,z,modelMatrix,projMatrix,viewport,&xx,&yy,&zz); - ShowGlerror(" UnPro .. "); - if(debug>2) - cout << " ok " << ok << " " << x << " " << y << " " << z - << " -> " << xx << " " << yy << " " << zz << endl; - R2 oD(oBmin,oBmax); - R2 D(Bmin,Bmax); - R2 O(xx,yy); - if((debug > 3)) cout<< " zoom : " << this << " O " << O - << " " << coef << " D = "<< D<< "as " - << theplot->aspectratio << endl; - oD *= 0.5*coef; - R2 A = O - oD; - R2 B = O + oD; - if (theplot->aspectratio) - cadreortho(A,B); - else - cadre(A,B); -} -void OneWindow::MoveXView(R dx,R dy) -{ - R3 D(Bmin3,Bmax3); - R3 dd( dx*D.x*sin(theta),-dx*D.y*cos(theta), - dy*D.z); - if(debug>2) - cout << " MoveXView "<< dx << " " << dy << " " << D << " mn: " << Bmin3 <<" mx :" << Bmax3 << " d=" << dd << endl; - Pvue3 += dd/50.; - // 2d ... add FH july 2009 - R2 D2(-dx*5*hpixel,-dy*5*hpixel); - oBmin += D2; - oBmax += D2; - Bmin += D2; - Bmax += D2; - -} - -void OneWindow::cadre(R2 A,R2 B) -{ - - oBmin=Bmin=A; - oBmax=Bmax=B; - hpixel = (Bmax.x-Bmin.x)/width; + glLoadIdentity( ); + + R aspect = ratio; + R3 DD(Bmin3, Bmax3); + DD.z *= rapz; + R dmax = DD.norme( ); + ; + R dist = 0.5 * dmax / sin(focal / 2) * coef_dist; + cam.x = Pvue3.x + cos(phi) * cos(theta) * dist; + cam.y = Pvue3.y + cos(phi) * sin(theta) * dist; + cam.z = Pvue3.z * rapz + dist * sin(phi); + R znear = max(dist - dmax, 1e-30); + R zfare = dist + dmax; + gluPerspective(focal * 180. / my_pi, aspect, znear, zfare); + if (debug > 2) { + cout << " BB " << Bmin3 << " , " << Bmax3 << " rapz " << rapz << " dmax: " << dmax << endl; + cout << " setview 3d: rapz " << rapz << " cam: "; + cout << cam << " Pvue:"; + cout << Pvue3 << " theta " << theta << " phi = " << phi << endl; + } + gluLookAt(cam.x, cam.y, cam.z, Pvue3.x, Pvue3.y, Pvue3.z * rapz, 0., 0., 1.); + glScaled(1., 1., rapz); + + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + ShowGlerror(" Get PM"); + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + ShowGlerror(" Get MV"); + glGetIntegerv(GL_VIEWPORT, viewport); + ShowGlerror(" Get VP"); + viewdim = 3; + + } else { + ShowGlerror("Begin SetView"); + glDisable(GL_DEPTH_TEST); + glViewport(0, 0, width, height); + R dz0, dz1, zm = 0; + if (plotdim == 3) { + dz0 = Bmin3.z; + dz1 = Bmax3.z; + } else { + R zzmin = Min(zmin, theplot->fminT); + R zzmax = Max(zmax, theplot->fmaxT); + R dz = (zzmax - zzmin); + zm = (zzmin + zzmax) * 0.5; + // to be sur the the z size is no zero . + dz = max(dz, (Bmax.x - Bmin.x) * 0.1); + dz = max(dz, (Bmax.y - Bmin.y) * 0.1); + dz0 = -dz; + dz1 = dz; + viewdim = 2; + } + + if ((debug > 3)) + cout << "\t\t\t SetView " << this << " " << Bmin << " " << Bmax << " dz " << dz0 << " " << dz1 << " theta " << theta << " phi = " << phi << " // " << Bmax - Bmin << " w " << width << " h " + << height << endl; + ShowGlerror("0 Set MV"); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity( ); + ShowGlerror(" Set MV"); + glMatrixMode(GL_PROJECTION); + glLoadIdentity( ); + ShowGlerror(" Set PM 1"); + glOrtho(Bmin.x, Bmax.x, Bmin.y, Bmax.y, dz0, dz1); + ShowGlerror(" Set PM 2"); -} + R2 M = (Bmin + Bmax) / 2.; + glTranslated(0, 0, -zm); -void OneWindow::getcadre(double &xmin,double &xmax,double &ymin,double &ymax) -{ - xmin = Bmin.x; - xmax = Bmax.x; - ymin = Bmin.y; - ymax = Bmax.y; + glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); + ShowGlerror(" Get PM"); + glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); + ShowGlerror(" Get MV"); + glGetIntegerv(GL_VIEWPORT, viewport); + ShowGlerror(" Get VP"); + ShowGlerror("End SetView "); + } } -void OneWindow::Display() -{ - if(!theplot) return; - SetScreenView() ; - glColor3d(0.,0.,0.); - - if(help) - { - theplot->DrawHelp(this); - // help=false; - } - else - { - ShowGlerror("Begin Display"); - - if(theplot) - theplot->Draw(this); - ShowGlerror("After Display"); - } -} -void OneWindow::cadreortho(R2 A, R2 B) -{ - R2 D(A,B); - oBmin=A; - oBmax=B; - - if ( D.y*width < D.x*height) - // width -> infty => D.x la ref - D.y = D.x*(double) height/ width; - else // height -> infty => D.y la ref - D.x = D.y*(double) width/height; - R2 M=(A+B)/2., D2=D/2.; - - Bmin= M - D2; - Bmax= M + D2; - hpixel = (Bmax.x-Bmin.x)/width; - if((debug > 10)) cout << " cadreortho: "<< " :: " << Bmin << " " << Bmax <<" oB " << oBmin << " " << oBmax << " w: " <aspectratio) { + cadreortho(oBmin, oBmax); + } } -void OneWindow::setLighting() -{ - if(withlight) - { - if(plotdim==3) - { - GLfloat lp0[4] = { (float) cam.x,(float) cam.y, (float) cam.z, 1.0F }; - glLightfv(GL_LIGHT0,GL_POSITION,lp0); - - if(debug>1) cout << " Light pos 3d: " << cam << endl; - } - else - { - GLfloat position[] = {(float) Pvue3.x,(float) Pvue3.y,(float) (Pvue3.z+(Bmax3.z-Bmin3.z)*3),1.f} ; - glLightfv(GL_LIGHT0, GL_POSITION, position); - - } - - float cca=0.3,ccd=1., ccs=0.8; - GLfloat ambient[] = {cca,cca,cca,1.0f};//differents parametres - GLfloat diffuse[] = {ccd,ccd,ccd,1.0f}; - GLfloat specular_reflexion[] = {ccs,ccs,ccs,1.0f}; - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1); - glEnable(GL_LIGHTING);//positionnement de la lumiere avec - glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);//les differents parametres - glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuse); - - glEnable(GL_COLOR_MATERIAL);//specification de la reflexion sur les materiaux - glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,ambient); - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,diffuse); - glShadeModel(GL_FLAT); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - } - else - { - glDisable(GL_LIGHTING); - glDisable(GL_LIGHT0); - } +void OneWindow::zoom(R coef) { + coef_dist *= coef; + R2 M = (oBmin + oBmax) / 2.; + R2 D = (oBmax - oBmin) / 2.; + R2 A = M - D * coef; + R2 B = M + D * coef; + if (theplot->aspectratio) + cadreortho(A, B); + else + cadre(A, B); +} +void OneWindow::zoom(int w, int h, R coef) { + GLdouble x = w, y = height - h, z = (zmin + zmax) / 2.; + GLdouble xx, yy, zz; + + GLint ok = gluUnProject(x, y, z, modelMatrix, projMatrix, viewport, &xx, &yy, &zz); + ShowGlerror(" UnPro .. "); + if (debug > 2) cout << " ok " << ok << " " << x << " " << y << " " << z << " -> " << xx << " " << yy << " " << zz << endl; + R2 oD(oBmin, oBmax); + R2 D(Bmin, Bmax); + R2 O(xx, yy); + if ((debug > 3)) cout << " zoom : " << this << " O " << O << " " << coef << " D = " << D << "as " << theplot->aspectratio << endl; + oD *= 0.5 * coef; + R2 A = O - oD; + R2 B = O + oD; + if (theplot->aspectratio) + cadreortho(A, B); + else + cadre(A, B); +} +void OneWindow::MoveXView(R dx, R dy) { + R3 D(Bmin3, Bmax3); + R3 dd(dx * D.x * sin(theta), -dx * D.y * cos(theta), -dy * D.z); + if (debug > 2) cout << " MoveXView " << dx << " " << dy << " " << D << " mn: " << Bmin3 << " mx :" << Bmax3 << " d=" << dd << endl; + Pvue3 += dd / 50.; + // 2d ... add FH july 2009 + R2 D2(-dx * 5 * hpixel, -dy * 5 * hpixel); + oBmin += D2; + oBmax += D2; + Bmin += D2; + Bmax += D2; +} + +void OneWindow::cadre(R2 A, R2 B) { + + oBmin = Bmin = A; + oBmax = Bmax = B; + hpixel = (Bmax.x - Bmin.x) / width; +} + +void OneWindow::getcadre(double &xmin, double &xmax, double &ymin, double &ymax) { + xmin = Bmin.x; + xmax = Bmax.x; + ymin = Bmin.y; + ymax = Bmax.y; +} +void OneWindow::Display( ) { + if (!theplot) return; + SetScreenView( ); + glColor3d(0., 0., 0.); + + if (help) { + theplot->DrawHelp(this); + // help=false; + } else { + ShowGlerror("Begin Display"); + + if (theplot) theplot->Draw(this); + ShowGlerror("After Display"); + } } - -void OneWindow::unsetLighting() -{ +void OneWindow::cadreortho(R2 A, R2 B) { + R2 D(A, B); + oBmin = A; + oBmax = B; + + if (D.y * width < D.x * height) + // width -> infty => D.x la ref + D.y = D.x * (double)height / width; + else // height -> infty => D.y la ref + D.x = D.y * (double)width / height; + R2 M = (A + B) / 2., D2 = D / 2.; + + Bmin = M - D2; + Bmax = M + D2; + hpixel = (Bmax.x - Bmin.x) / width; + if ((debug > 10)) cout << " cadreortho: " << " :: " << Bmin << " " << Bmax << " oB " << oBmin << " " << oBmax << " w: " << width << " h: " << height << endl; +} +void OneWindow::setLighting( ) { + if (withlight) { + if (plotdim == 3) { + GLfloat lp0[4] = {(float)cam.x, (float)cam.y, (float)cam.z, 1.0F}; + glLightfv(GL_LIGHT0, GL_POSITION, lp0); + + if (debug > 1) cout << " Light pos 3d: " << cam << endl; + } else { + GLfloat position[] = {(float)Pvue3.x, (float)Pvue3.y, (float)(Pvue3.z + (Bmax3.z - Bmin3.z) * 3), 1.f}; + glLightfv(GL_LIGHT0, GL_POSITION, position); + } + + float cca = 0.3, ccd = 1., ccs = 0.8; + GLfloat ambient[] = {cca, cca, cca, 1.0f}; // differents parametres + GLfloat diffuse[] = {ccd, ccd, ccd, 1.0f}; + GLfloat specular_reflexion[] = {ccs, ccs, ccs, 1.0f}; + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); + glEnable(GL_LIGHTING); // positionnement de la lumiere avec + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); // les differents parametres + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + + glEnable(GL_COLOR_MATERIAL); // specification de la reflexion sur les materiaux + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + glShadeModel(GL_FLAT); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + } else { glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); + } } -OnePlotBorder::OnePlotBorder(PlotStream & f) -:OnePlot(4,3,1) -{ - long nbd; - f>> nbd; - data.resize(nbd); - for(int i=0;i> n; - data[i].resize(n+1); - for(int j=0;j<=n;++j) - { - long l; - double x,y,z; - f >> l>> x >> y >> z; - R3 P(x,y,z); - Pmin=Minc(Pmin,P); - Pmax=Maxc(Pmax,P); - data[i][j]=make_pair(l,P); - } - } - ffassert(f.good()); -} - - -void OnePlot::GLDraw(OneWindow *win) -{ - Draw(win); - - win->changeiso=0; - win->changearrow=0; -} - -void ThePlot::DrawHelp(OneWindow *win) -{ - int i = 1; - win->Show("Enter a keyboard character in the FreeFem Graphics window in order to:",i++); - - i+=1; - win->Show("enter) wait next plot",i++); - win->Show("p) previous plot (10 plots saved) ",i++); - win->Show("ESC) exit from ffglut (if termined) ",i++); - win->Show("^c) non-ignorable exit from ffglut ",i++); - win->Show("?) show this help window",i++); - win->Show("+) -) zoom in/out around the cursor 3/2 times ",i++); - win->Show("=) reset vue ",i++); - win->Show("r) refresh plot ",i++); - win->Show("up, down, left, right) special keys to translate ",i++); - win->Show("3) switch 3d/2d plot (in test) keys : ",i++); - win->Show(" z) Z) (focal zoom unzoom) ",i++); - win->Show(" H) h) switch increase or decrease the Z scale of the plot ",i++); - win->Show("mouse motion) ",i++); - win->Show(" - left button) rotate ",i++); - win->Show(" - right button) zoom (ctrl+button on mac) ",i++); - win->Show(" - right button +alt) translate (alt+ctrl+button on mac)",i++); - - win->Show("a) A) increase or decrease the arrow size",i++); - win->Show("B) switch between show border meshes or not",i++); - win->Show("i) I) update or not: the min/max bound of the functions to the window",i++); - win->Show("n) N) decrease or increase the number of iso value array ",i++); - win->Show("b) switch between black and white or color plotting ",i++); - win->Show("g) switch between grey or color plotting ",i++); - win->Show("f) switch between filling iso or iso line ",i++); - win->Show("l) switch between lighting or not ",i++); - win->Show("v) switch between show or not the numerical value of colors ",i++); - win->Show("m) switch between show or not meshes ",i++); - win->Show("w) window dump in file ffglutXXXX.ppm ",i++); - win->Show("*) keep/unkeep viewpoint for next plot",i++); - win->Show("k) complex data / change view type ",i++); - win->Show("T) show normal at element surface (only meshS)",i++); - win->Show("q) Q) decrease or increase the number of Normal ploted at element surface (only meshS)",i++); - win->Show("any other key : nothing ",++i); -} - -void ThePlot::dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn2,R & vmx2) const -{ - fmn=+1e100; - fmx=-fmn; - vmx2=0; - vmn2=+1e100; - for (list::const_iterator i= plots.begin();i != plots.end(); ++i) - { - if(*i) (*i)->dyn_bfv(win,fmn,fmx,vmn2,vmx2) ; - } - if(debug>4) - cout << "dyn_bfv " << fmn << " " << fmx << " " << vmn2 << " " << vmx2 <fmx) fmn=fmin,fmx=fmax; - if(vmn2<0) vmn2 = 0; - if(vmn2>vmx2) vmn2=0,vmx2=vmax2; -} - -bool ThePlot::NextCase() -{ - bool ret=false; - for (list::iterator i= plots.begin();i != plots.end(); ++i) - ret = (**i).NextCase() || ret; // alway run NextCase .. - return ret; -} - -void ThePlot::Draw(OneWindow *win) -{ - if((debug>1 )) - { - cout << " ThePlot::Plot " << count << " " << this << " win " << win << " " << state ; - for (list::iterator i= plots.begin();i != plots.end(); ++i) - cout << (**i).what; - cout << endl; - - } - if(state==0) { - state=1; - win->DefaultView(0); - } - - win->SetView(); - for (list::iterator i= plots.begin();i != plots.end(); ++i) - (*i)->Draw(win); - - if(cm || value) - { // screen plot ... - win->SetScreenView(); - if(cm) - { - color(1); - win->DrawCommentaire(cm->c_str(),0.1,0.97); - } - if(value) - { - int k0=0; - if(withiso) - { - win->PlotValue(Viso,k0,"IsoValue"); - k0=1+Viso.N(); - } - if(witharrow) - win->PlotValue(Varrow,k0,"Vec Value"); - } - // for picking.. - win->SetView(); - } - changeViso=false; - changeVarrow=false; - changeColor=false; - changeBorder=false; - changeFill=false; -} - -void ThePlot::SetColorTable(int nb) -{ - tbc.resize(nb); - for (int i=0;igrey; - } - greyo=grey; - drawborder=true; - drawmeshes=false; - add=false; - keepPV=false; - pNormalT=false; - nbN=1; // arbitrary initialisation - echelle=1.; - - Pmin=R3(+dinfty,+dinfty,+dinfty); - fmin = +dinfty; - fmax = -dinfty; - Pmax=R3(-dinfty,-dinfty,-dinfty); - vmax2=0; - - coefr=1; - long dimpp=0, dimHatpp=0; - long cas; -#define READ_VTK_PARAM(index,type) \ -case 20+index: {type dummy; fin >= dummy;} break; - - while(1) - { - - fin >> cas; - if((debug > 4)) cout << " read cas: " << cas << " " << PlotStream::dt_endarg << endl; - if(cas==PlotStream::dt_endarg) break; - if(version==2) - switch (cas) { - case 0: fin >> coeff; break; - case 1: fin >> cm; break; - case 2: fin >> psfile; break; - case 3: fin >> wait; break; - case 4: fin >> fill; break; - case 5: fin >> value; break; - case 6: fin >> clean; break; - case 7: fin >> aspectratio;uaspectratio=true; break; - case 8: fin >> boundingbox; break; - case 9: fin >> Niso; break; - case 10: fin >> Narrow; break; - case 11: fin >> Viso;Niso=Viso.N();pViso=true; break; - case 12: fin >> Varrow;Narrow=Varrow.N();pVarrow=true; break; - case 13: fin >> bw; break; - case 14: fin >> grey; break; - case 15: fin >> colors; break; - case 16: fin >> drawborder; break; - case 17: fin >> dimpp; break;// ajout fevr 2008 v3.0.6 - case 18: fin >> add; break; - case 19: fin >> keepPV; break; - case 20: fin >> echelle;break; - default: - cout << "Fatal error: Unknown case : " << cas <= coeff; break; - case 1: fin >= cm; break; - case 2: fin >= psfile; break; - case 3: fin >= wait; break; - case 4: fin >= fill; break; - case 5: fin >= value; break; - case 6: fin >= clean; break; - case 7: fin >= aspectratio;uaspectratio=true; break; - case 8: fin >= boundingbox; break; - case 9: fin >= Niso; break; - case 10: fin >= Narrow; break; - case 11: fin >= Viso;Niso=Viso.N();pViso=true; break; - case 12: fin >= Varrow;Narrow=Varrow.N();pVarrow=true; break; - case 13: fin >= bw; break; - case 14: fin >= grey; break; - case 15: fin >= colors; break; - case 16: fin >= drawborder; break; - case 17: fin >= dimpp; break;// ajout fevr 2008 v3.0.6 - case 18: fin >= add; break; - case 19: fin >= keepPV; break; - case 20: fin >= echelle;break; - case 21: fin >= ZScale;break; - - // unsed parameter ... - //READ_VTK_PARAM(1,double); // ZScale - READ_VTK_PARAM(2,bool); // WhiteBackground - READ_VTK_PARAM(3,bool); // OpaqueBorders - READ_VTK_PARAM(4,bool); // BorderAsMesh - READ_VTK_PARAM(5,bool); // ShowMeshes - READ_VTK_PARAM(6,long); // ColorScheme - READ_VTK_PARAM(7,long); // ArrowShape - // READ_VTK_PARAM(8,double); // ArrowSize - case 28: fin >= ArrowSize; break; - READ_VTK_PARAM(9,long); // ComplexDisplay - READ_VTK_PARAM(10,bool); // LabelColors - READ_VTK_PARAM(11,bool); // ShowAxes - READ_VTK_PARAM(12,bool); // CutPlane - READ_VTK_PARAM(13,KN); // CameraPosition - READ_VTK_PARAM(14,KN); // CameraFocalPoint - READ_VTK_PARAM(15,KN); // CameraViewUp - READ_VTK_PARAM(16,double); // CameraViewAngle - READ_VTK_PARAM(17,KN); // CameraClippingRange - READ_VTK_PARAM(18,KN); // CutPlaneOrigin - READ_VTK_PARAM(19,KN); // CutPlaneNormal - case 40: fin >= winnum; break; - - //case 43: fin >= winnum; break; - case 43: fin >= pNormalT;break; - case 44: fin >= pdffile;break; - case 45: fin >= svgfile;break; - - default: - static int nccc=0; - if(nccc++<5) - cout << " Skip Unknown case " << cas <<" (ffglut is too old ?)\n"; - fin.SkipData(); - break; - } - else ffassert(0); - ffassert(fin.good() && ! fin.eof()); - } - if(dimpp) plotdim=dimpp; - ffassert(cas==PlotStream::dt_endarg); - if((debug > 2)) - { cout << " ***** get ::: "; - cout << " Window num " << winnum << ", "; - cout << " coeff " << coeff <<", "; - if(cm) - cout << " cm " << *cm <<", "; - if(wait) cout << " wait " ; - if(fill) cout << " fill " ; - if(value) cout << " value " ; - if(bw) cout << " bw " ; - if(grey) cout << " grey " ; - if(drawborder) cout << " drawborder " ; - if(colors.N()) cout << "\n colors =" << colors; - if(boundingbox.N()) cout << "\n bb =" << boundingbox; - - cout << endl; - } - fin.GetMeshes(); - long nbmeshes; - fin >> nbmeshes; - if((debug > 2)) cout << " read nb : mesh " << nbmeshes << endl; - if(version==2) - { - Ths.resize(nbmeshes); - for(int i=0;i> l; - if(l>=0) - { - if((debug > 3)) cout << " read mesh " << i << " -> " << l << " " <=0 && l < nbmeshes); - if(version==2) - { - ffassert(Ths[l]==0); - fin >>Ths[l] ; - } - else - { - ffassert(Ths2[l]==0); - fin >>Ths2[l] ; - } - - if((debug > 3)) - { - if(version==2) - cout << i << " nt/nv " << l << " " <nt << " " << Ths[l]->nv << endl; - else - cout << i << " nt/nv " << l << " " <nt << " " << Ths2[l]->nv << endl; - } - ffassert(fin.good()); - } - else // Add FH optimisation FH 11/12/2008 (not use to day) - {// the mesh is already in the previous plot with number ll - ffassert(l==-1); - long ll; - fin >> l>> ll; // read l and ll - ffassert(old); - if(version==2) - { - Ths[l]=old->Ths[ll]; - Ths[l]->increment(); - } - else - { - Ths2[l]=old->Ths2[ll]; - Ths2[l]->increment(); - } - - } - - } - long nbmeshes3=0; - long nbmeshesS=0; - long nbmeshesL=0; - - int getMesh3Type = fin.GetMeshes3(); // 0 : dt_mesh3, 1 : dt_meshS, 2 : dt_meshL, 3 : dt_plots - if (getMesh3Type!=3) // read GetPlots if false ... - { - // There are 3D volume solution - if(getMesh3Type==0) - { - - fin >> nbmeshes3; - if((debug > 2)) cout << " read nb : mesh3 " << nbmeshes3 << endl; - Ths3.resize(nbmeshes3); - for(int i=0;i> l; - if(l>=0) - { - if((debug > 3)) cout << " read mesh3 " << i << " -> " << l - << " " <=0 && l < nbmeshes3); - ffassert(Ths3[l]==0); - fin >>Ths3[l] ; - if((debug > 3)) - cout << "mesh3 i: "<< i << " nt/nv " << l << " " <nt << " " - << Ths3[l]->nv << endl; - ffassert(fin.good()); - } - else // Add FH optimisation FH 11/12/2008 (not use to day) - {// the mesh is already in the previous plot with number ll - ffassert(l==-1); - long ll; - fin >> l>> ll; // read l and ll - ffassert(old); - Ths3[l]=old->Ths3[ll]; - Ths3[l]->increment(); // - } - } - getMesh3Type=fin.GetMeshes3(); - } - // There are 3D surface solution - if(getMesh3Type==1) { - fin >> nbmeshesS; - if((debug > 2)) cout << " read nb : meshS " << nbmeshesS << endl; - ThsS.resize(nbmeshesS); - for(int i=0;i> l; - if(l>=0) - { - if((debug > 3)) cout << "meshS i: "<< " read meshS " << i << " -> " << l - << " " <=0 && l < nbmeshesS); - ffassert(ThsS[l]==0); - fin >>ThsS[l] ; - if((debug > 3)) - cout << "meshS i: "<< i << " nt/nv " << l << " " <nt << " " - << ThsS[l]->nv << endl; - ffassert(fin.good()); - } - else // Add FH optimisation FH 11/12/2008 (not use to day) - {// the mesh is already in the previous plot with number ll - ffassert(l==-1); - long ll; - fin >> l>> ll; // read l and ll - ffassert(old); - ThsS[l]=old->ThsS[ll]; - ThsS[l]->increment(); // - } - } - getMesh3Type=fin.GetMeshes3(); - } - // There are 3D line solution - if(getMesh3Type==2) { - fin >> nbmeshesL; - if((debug > 2)) cout << " read nb : meshL " << nbmeshesL << endl; - ThsL.resize(nbmeshesL); - for(int i=0;i> l; - if(l>=0) - { - if((debug > 3)) cout << " read meshL " << i << " -> " << l - << " " <=0 && l < nbmeshesL); - ffassert(ThsL[l]==0); - fin >>ThsL[l] ; - if((debug > 3)) - cout << "meshL i: "<< i << " nt/nv " << l << " " <nt << " " - << ThsL[l]->nv << endl; - ffassert(fin.good()); - } - else // Add FH optimisation FH 11/12/2008 (not use to day) - {// the mesh is already in the previous plot with number ll - ffassert(l==-1); - long ll; - fin >> l>> ll; // read l and ll - ffassert(old); - ThsL[l]=old->ThsL[ll]; - ThsL[l]->increment(); // - } - } - getMesh3Type=fin.GetMeshes3(); - } - else if (getMesh3Type==4) - - fin.GetPlots(); - } - - long nbplot; - int iso3d=0, iso3dB=0; - fin >>nbplot; - if((debug > 2)) cout << " nb item plot " << nbplot << endl; - for(int i=0;i> what; - long imsh; - if((what !=3 && what != 13 )&& !uaspectratio) aspectratio= true; - if((debug > 2)) cout << " plot " << i << " what " << what << " as : " << aspectratio << endl; - - if(what==-1) // gestion of error (empty plot) - p = new OnePlotError(fin); - else if(what==0) - { - fin >> imsh; - if((debug > 9)) cout << " plot : mesh " << imsh << endl; - if(version==2) - p=new OnePlotMesh(Ths[imsh-1]); - else - p=new OnePlotMesh(Ths2[imsh-1]); - - } - else if (what==1 || what==2 || what==11 || what==12 ) - { - fin >> imsh; - if(what%10==1) withiso=true; - else if (what%10==2) witharrow=true; - if((debug >= 10)) cout << " plot : mesh " << imsh << endl; - ffassert(imsh>0 && imsh <=nbmeshes); - if(version==2) - p=new OnePlotFE(Ths[imsh-1],what,fin); - else - p=new OnePlotFE(Ths2[imsh-1],what,fin); - } - else if(what==3) - p=new OnePlotCurve(fin); - else if(what==13) - p=new OnePlotCurve(fin,4,this);// add zz and color .. - else if(what==4) - p=new OnePlotBorder(fin); - - // volume 3D meshes (mesh3 or mesh3 only in case with pointer on meshS or/and meshL - else if (what == 5) - { - fin >> imsh; - p=new OnePlotMesh3(Ths3[imsh-1]);if((debug > 9)) cout << " plot : mesh3 (volume 3D) " << imsh << endl; - } - // surface 3D meshes - else if(what==50) - { - fin >> imsh;if((debug > 9)) cout << " plot : meshS (surface 3D) " << imsh << endl; - p=new OnePlotMeshS(ThsS[imsh-1]); - } - // line 3D meshes - else if (what==55) - { - fin >> imsh;if((debug > 9)) cout << " plot : meshL (line 3D) " << imsh << endl; - p=new OnePlotMeshL(ThsL[imsh-1]); - } - else if (what==6 || what==7|| what==16 || what==17) - { - iso3d++; - fin >> imsh; - if(what==6||what==16 ) withiso=true; - - if((debug > 10)) cout << " plot : mesh3 (volume) " << imsh << endl; - ffassert(imsh>0 && imsh <=nbmeshes3); - p=new OnePlotFE3(Ths3[imsh-1],what,fin); - } - else if (what==8 || what==9 || what==18 || what==19) - { - iso3dB++; - fin >> imsh; - if(what==8||what==18 ) withiso=true; - else if (what%10==9) witharrow=true; - if((debug > 10)) cout << " plot : meshS (3D surface) " << imsh << endl; - ffassert(imsh>0 && imsh <=nbmeshesS); - - p=new OnePlotFES(ThsS[imsh-1],what,fin); - } - else if (what==14 || what==15 || what==20 || what==21) - { - iso3dB++; - fin >> imsh; - if(what==14||what==20 ) withiso=true; - else if (what==15||what==21 ) witharrow=true; - if((debug > 10)) cout << " plot : meshL (3D curve) " << imsh << endl; - ffassert(imsh>0 && imsh <=nbmeshesL); - p=new OnePlotFEL(ThsL[imsh-1],what,fin); - } - else if (what == 31) - { - p=new OnePlotHMatrix(what,fin); - } - else - { - cout << "Bizarre unknown what : " << what<< endl; - ffassert(0); - } - ffassert(p); - plots.push_back(p); - p->bb(Pmin,Pmax); - p->bfv(fmin,fmax,vmax2); - plotdim=max(plotdim,p->dim); - ffassert(fin.good()); - datadim=max(datadim,p->dim); - } - if(dimpp) plotdim=dimpp; - - if(Niso==0) - Niso = iso3d ? 5 : 20; - if(iso3dB) Niso=20; - double ref_f = abs(fmax)+abs(fmin) ; - if(fmax < fmin) - { - fmax = 1; - fmin = 0; - } - else if( (fmax-fmin) <= 1e-8*ref_f) - { - if(ref_f< 1e-20) ref_f=0.5; - fmax += ref_f/2; - fmin -= ref_f/2; - } - PminT=Pmin; - PmaxT=Pmax; - fminT=fmin; - fmaxT=fmax; - - z0= fminT -(fmaxT-fminT)*0.01; - if((debug > 2)) cout << " data bound: " << PminT << " " << PmaxT - << " fmin == " << fminT << " " << fmaxT - << " z0 " << z0 << endl; - fin.GetEndPlot(); - Viso.resize(Niso); - Varrow.resize(Narrow); - - SetColorTable(Max(Niso,Narrow)+4) ; - SetDefIsoV(Niso,Narrow,fmin,fmax) ; - -} - - -void ThePlot::SetDefIsoV(int niso,int narr,double fmn,double fmx,double vmn,double vmx) -{ - niso = max(niso,2); - narr = max(narr,2); - - bool dyni=niso!=Viso.N() , dyna = narr != Varrow.N(); - R d,x; - if(debug>3 && !(fmx>fmn) ) - cout << " SetDefIsoV (not) " << endl; - if(debug>3) - cout << " SetDefIsoV " << dyni << " " << fmn << " " << fmx << "pViso= " << pViso << " / "<< dyna << " " << vmn << " " << vmx << endl; - - // resize !!! - Viso.resize(niso); - Niso=Viso.N(); - - Varrow.resize(narr); - Narrow=Varrow.N(); - - if( fmx>fmn) - { - dyni = niso !=Viso.N() ; - // pViso = pViso && niso ==Viso.N(); FH: debile !!!!! - d = (fmx-fmn)/(max(Niso-2,1L)) ; - x = (fmn+fmx)/2-d*0.5*(Niso-1); - } - else - { - d = 1 ? (fmaxT-fminT)/(max(Niso-2,1L)) : (fmaxT-fminT)/(Niso-1); - x = 1 ? (fminT+fmaxT)/2-d*0.5*(Niso-1) :fminT+d/2; - } - if(!pViso || dyni) - { - for (int i = 0;i < Niso;i++) - {Viso[i]=x;x +=d; } - } - - - if(vmx>vmn) - { - dyna=true; - x = sqrt(vmn); - d = (sqrt(vmx)-x)/(Narrow-1.1); - } - else - { - x=0; - if(debug>10) - cout << "vmax2= " << vmax2 << endl; - d= sqrt(vmax2)/(Narrow-1.1); - } - if (!pVarrow || dyna) - for (int i = 0;i < Narrow;i++) - { - Varrow[i]=x; - x +=d; - } - if(debug>100) - cout << " Viso ..; " << Viso < & Viso,int k0,const char * cmm) -{ - - ShowGlerror("PlotValue b"); - if((debug > 10)) cout << "PlotValue:" << cmm << " " << k0 << " " << width << " " < 10)) cout << "PlotValue " << Viso << endl; - - R dx=(xmax-xmin); - R dy=(ymax-ymin); - // 10 points - R h=10*kscreenscale; - if( kscreenscale==2) h = 24;// BofBof F.H - R ho=h*1.1; - R x0=xmin+dx*0.85; - R y= ymin+dy*0.97; - if((debug > 10)) cout << x0 << " " << y << " " << h << endl; - y -= k0* ho; - this->color(0); - FillRectRasterPos(x0-h*0.5,y-h*(1.4*Viso.N()+0.3),x0+h*9,y+h*1.5); - ShowGlerror("PlotValue m"); - this->color(1); - - plot(x0+ho,y,cmm); - y -= ho; - for (int i=0;i 10)) cout << " x0 : " << x0<< " " << y << " " << h << " v = " << Viso[i] << endl; - this->color(i+4); - FillRectRasterPos(x0,y,x0+h,y+h); - plot(x0+ho,y+3*h/10,Viso[i]); - y -= ho; - ; +void OneWindow::unsetLighting( ) { + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); +} + +OnePlotBorder::OnePlotBorder(PlotStream &f) : OnePlot(4, 3, 1) { + long nbd; + f >> nbd; + data.resize(nbd); + for (int i = 0; i < nbd; ++i) { + long n; + f >> n; + data[i].resize(n + 1); + for (int j = 0; j <= n; ++j) { + long l; + double x, y, z; + f >> l >> x >> y >> z; + R3 P(x, y, z); + Pmin = Minc(Pmin, P); + Pmax = Maxc(Pmax, P); + data[i][j] = make_pair(l, P); } - ShowGlerror("PlotValue f"); + } + ffassert(f.good( )); +} + +void OnePlot::GLDraw(OneWindow *win) { + Draw(win); + + win->changeiso = 0; + win->changearrow = 0; +} + +void ThePlot::DrawHelp(OneWindow *win) { + int i = 1; + win->Show("Enter a keyboard character in the FreeFem Graphics window in order to:", i++); + + i += 1; + win->Show("enter) wait next plot", i++); + win->Show("p) previous plot (10 plots saved) ", i++); + win->Show("ESC) exit from ffglut (if termined) ", i++); + win->Show("^c) non-ignorable exit from ffglut ", i++); + win->Show("?) show this help window", i++); + win->Show("+) -) zoom in/out around the cursor 3/2 times ", i++); + win->Show("=) reset vue ", i++); + win->Show("r) refresh plot ", i++); + win->Show("up, down, left, right) special keys to translate ", i++); + win->Show("3) switch 3d/2d plot (in test) keys : ", i++); + win->Show(" z) Z) (focal zoom unzoom) ", i++); + win->Show(" H) h) switch increase or decrease the Z scale of the plot ", i++); + win->Show("mouse motion) ", i++); + win->Show(" - left button) rotate ", i++); + win->Show(" - right button) zoom (ctrl+button on mac) ", i++); + win->Show(" - right button +alt) translate (alt+ctrl+button on mac)", i++); + + win->Show("a) A) increase or decrease the arrow size", i++); + win->Show("B) switch between show border meshes or not", i++); + win->Show("i) I) update or not: the min/max bound of the functions to the window", i++); + win->Show("n) N) decrease or increase the number of iso value array ", i++); + win->Show("b) switch between black and white or color plotting ", i++); + win->Show("g) switch between grey or color plotting ", i++); + win->Show("f) switch between filling iso or iso line ", i++); + win->Show("l) switch between lighting or not ", i++); + win->Show("v) switch between show or not the numerical value of colors ", i++); + win->Show("m) switch between show or not meshes ", i++); + win->Show("w) window dump in file ffglutXXXX.ppm ", i++); + win->Show("*) keep/unkeep viewpoint for next plot", i++); + win->Show("k) complex data / change view type ", i++); + win->Show("T) show normal at element surface (only meshS)", i++); + win->Show("q) Q) decrease or increase the number of Normal ploted at element surface (only meshS)", i++); + win->Show("any other key : nothing ", ++i); +} + +void ThePlot::dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn2, R &vmx2) const { + fmn = +1e100; + fmx = -fmn; + vmx2 = 0; + vmn2 = +1e100; + for (list< OnePlot * >::const_iterator i = plots.begin( ); i != plots.end( ); ++i) { + if (*i) (*i)->dyn_bfv(win, fmn, fmx, vmn2, vmx2); + } + if (debug > 4) cout << "dyn_bfv " << fmn << " " << fmx << " " << vmn2 << " " << vmx2 << endl; + if (fmn > fmx) fmn = fmin, fmx = fmax; + if (vmn2 < 0) vmn2 = 0; + if (vmn2 > vmx2) vmn2 = 0, vmx2 = vmax2; } +bool ThePlot::NextCase( ) { + bool ret = false; + for (list< OnePlot * >::iterator i = plots.begin( ); i != plots.end( ); ++i) ret = (**i).NextCase( ) || ret; // alway run NextCase .. + return ret; +} -void OneWindow::DrawCommentaire(const char * cm,R x,R y) -{ +void ThePlot::Draw(OneWindow *win) { + if ((debug > 1)) { + cout << " ThePlot::Plot " << count << " " << this << " win " << win << " " << state; + for (list< OnePlot * >::iterator i = plots.begin( ); i != plots.end( ); ++i) cout << (**i).what; + cout << endl; + } + if (state == 0) { + state = 1; + win->DefaultView(0); + } - R xmin=0,xmax=height,ymin=0,ymax=height; - float dx=(xmax-xmin); - float dy=(ymax-ymin); - plot(xmin+dx*x,ymin+dy*y,cm); -} + win->SetView( ); + for (list< OnePlot * >::iterator i = plots.begin( ); i != plots.end( ); ++i) (*i)->Draw(win); -void plot(double xx,double yy,const char *cmm,int font) -{ - glRasterPos2f(xx,yy); - float x[4]; - glGetFloatv(GL_CURRENT_RASTER_POSITION,x); - if((debug > 10)) cout<<"avant x : "<SetScreenView( ); + if (cm) { + color(1); + win->DrawCommentaire(cm->c_str( ), 0.1, 0.97); + } + if (value) { + int k0 = 0; + if (withiso) { + win->PlotValue(Viso, k0, "IsoValue"); + k0 = 1 + Viso.N( ); + } + if (witharrow) win->PlotValue(Varrow, k0, "Vec Value"); + } + // for picking.. + win->SetView( ); + } + changeViso = false; + changeVarrow = false; + changeColor = false; + changeBorder = false; + changeFill = false; +} + +void ThePlot::SetColorTable(int nb) { + tbc.resize(nb); + for (int i = 0; i < nb; ++i) tbc[i].set(i, nb, this); +} + +ThePlot::ThePlot(PlotStream &fin, ThePlot *old, int kcount) + : count(kcount), state(0), changeViso(true), changeVarrow(true), changeColor(true), changeBorder(true), changeFill(true), withiso(false), witharrow(false), plotdim(2), changePlotdim(false), + theta(30. * my_pi / 180.), phi(20. * my_pi / 180.), dcoef(1), focal(20. * my_pi / 180.), datadim(1), winnum(0), keepPV(0), pNormalT(0) + +{ + string *pdffile = 0, *svgfile = 0; // add for fujiwara used today !!! + hsv = true; // hsv type + coeff = 1; + wait = 0; + value = false; + fill = false; + aspectratio = false; + clean = true; + uaspectratio = false; + pViso = false; + pVarrow = false; + Niso = 0; + Narrow = 20; + bw = false; + psfile = 0; + cm = 0; + grey = 0; + ZScale = -1; // auto + ArrowSize = -1; + if (old) { + grey = old->grey; + } + greyo = grey; + drawborder = true; + drawmeshes = false; + add = false; + keepPV = false; + pNormalT = false; + nbN = 1; // arbitrary initialisation + echelle = 1.; + + Pmin = R3(+dinfty, +dinfty, +dinfty); + fmin = +dinfty; + fmax = -dinfty; + Pmax = R3(-dinfty, -dinfty, -dinfty); + vmax2 = 0; + + coefr = 1; + long dimpp = 0, dimHatpp = 0; + long cas; +#define READ_VTK_PARAM(index, type) \ + case 20 + index: { \ + type dummy; \ + fin >= dummy; \ + } break; + + while (1) { + + fin >> cas; + if ((debug > 4)) cout << " read cas: " << cas << " " << PlotStream::dt_endarg << endl; + if (cas == PlotStream::dt_endarg) break; + if (version == 2) switch (cas) { + case 0: + fin >> coeff; + break; + case 1: + fin >> cm; + break; + case 2: + fin >> psfile; + break; + case 3: + fin >> wait; + break; + case 4: + fin >> fill; + break; + case 5: + fin >> value; + break; + case 6: + fin >> clean; + break; + case 7: + fin >> aspectratio; + uaspectratio = true; + break; + case 8: + fin >> boundingbox; + break; + case 9: + fin >> Niso; + break; + case 10: + fin >> Narrow; + break; + case 11: + fin >> Viso; + Niso = Viso.N( ); + pViso = true; + break; + case 12: + fin >> Varrow; + Narrow = Varrow.N( ); + pVarrow = true; + break; + case 13: + fin >> bw; + break; + case 14: + fin >> grey; + break; + case 15: + fin >> colors; + break; + case 16: + fin >> drawborder; + break; + case 17: + fin >> dimpp; + break; // ajout fevr 2008 v3.0.6 + case 18: + fin >> add; + break; + case 19: + fin >> keepPV; + break; + case 20: + fin >> echelle; + break; + default: + cout << "Fatal error: Unknown case : " << cas << endl; + ffassert(0); + break; + } + else if (version == 3 || version == 4) + switch (cas) { + case 0: + fin >= coeff; + break; + case 1: + fin >= cm; + break; + case 2: + fin >= psfile; + break; + case 3: + fin >= wait; + break; + case 4: + fin >= fill; + break; + case 5: + fin >= value; + break; + case 6: + fin >= clean; + break; + case 7: + fin >= aspectratio; + uaspectratio = true; + break; + case 8: + fin >= boundingbox; + break; + case 9: + fin >= Niso; + break; + case 10: + fin >= Narrow; + break; + case 11: + fin >= Viso; + Niso = Viso.N( ); + pViso = true; + break; + case 12: + fin >= Varrow; + Narrow = Varrow.N( ); + pVarrow = true; + break; + case 13: + fin >= bw; + break; + case 14: + fin >= grey; + break; + case 15: + fin >= colors; + break; + case 16: + fin >= drawborder; + break; + case 17: + fin >= dimpp; + break; // ajout fevr 2008 v3.0.6 + case 18: + fin >= add; + break; + case 19: + fin >= keepPV; + break; + case 20: + fin >= echelle; + break; + case 21: + fin >= ZScale; + break; + + // unsed parameter ... + // READ_VTK_PARAM(1,double); // ZScale + READ_VTK_PARAM(2, bool); // WhiteBackground + READ_VTK_PARAM(3, bool); // OpaqueBorders + READ_VTK_PARAM(4, bool); // BorderAsMesh + READ_VTK_PARAM(5, bool); // ShowMeshes + READ_VTK_PARAM(6, long); // ColorScheme + READ_VTK_PARAM(7, long); // ArrowShape + // READ_VTK_PARAM(8,double); // ArrowSize + case 28: + fin >= ArrowSize; + break; + READ_VTK_PARAM(9, long); // ComplexDisplay + READ_VTK_PARAM(10, bool); // LabelColors + READ_VTK_PARAM(11, bool); // ShowAxes + READ_VTK_PARAM(12, bool); // CutPlane + READ_VTK_PARAM(13, KN< double >); // CameraPosition + READ_VTK_PARAM(14, KN< double >); // CameraFocalPoint + READ_VTK_PARAM(15, KN< double >); // CameraViewUp + READ_VTK_PARAM(16, double); // CameraViewAngle + READ_VTK_PARAM(17, KN< double >); // CameraClippingRange + READ_VTK_PARAM(18, KN< double >); // CutPlaneOrigin + READ_VTK_PARAM(19, KN< double >); // CutPlaneNormal + case 40: + fin >= winnum; + break; + + // case 43: fin >= winnum; break; + case 43: + fin >= pNormalT; + break; + case 44: + fin >= pdffile; + break; + case 45: + fin >= svgfile; + break; + default: + static int nccc = 0; + if (nccc++ < 5) cout << " Skip Unknown case " << cas << " (ffglut is too old ?)\n"; + fin.SkipData( ); + break; + } + else + ffassert(0); + ffassert(fin.good( ) && !fin.eof( )); + } + if (dimpp) plotdim = dimpp; + ffassert(cas == PlotStream::dt_endarg); + if ((debug > 2)) { + cout << " ***** get ::: "; + cout << " Window num " << winnum << ", "; + cout << " coeff " << coeff << ", "; + if (cm) cout << " cm " << *cm << ", "; + if (wait) cout << " wait "; + if (fill) cout << " fill "; + if (value) cout << " value "; + if (bw) cout << " bw "; + if (grey) cout << " grey "; + if (drawborder) cout << " drawborder "; + if (colors.N( )) cout << "\n colors =" << colors; + if (boundingbox.N( )) cout << "\n bb =" << boundingbox; + + cout << endl; + } + fin.GetMeshes( ); + long nbmeshes; + fin >> nbmeshes; + if ((debug > 2)) cout << " read nb : mesh " << nbmeshes << endl; + if (version == 2) { + Ths.resize(nbmeshes); + for (int i = 0; i < nbmeshes; ++i) Ths[i] = 0; + } else { + Ths2.resize(nbmeshes); + for (int i = 0; i < nbmeshes; ++i) Ths2[i] = 0; + } + for (int i = 0; i < nbmeshes; ++i) { + long l; + fin >> l; + if (l >= 0) { + if ((debug > 3)) cout << " read mesh " << i << " -> " << l << " " << nbmeshes << endl; + l--; + ffassert(l >= 0 && l < nbmeshes); + if (version == 2) { + ffassert(Ths[l] == 0); + fin >> Ths[l]; + } else { + ffassert(Ths2[l] == 0); + fin >> Ths2[l]; + } + if ((debug > 3)) { + if (version == 2) + cout << i << " nt/nv " << l << " " << Ths[l]->nt << " " << Ths[l]->nv << endl; + else + cout << i << " nt/nv " << l << " " << Ths2[l]->nt << " " << Ths2[l]->nv << endl; + } + ffassert(fin.good( )); + } else // Add FH optimisation FH 11/12/2008 (not use to day) + { // the mesh is already in the previous plot with number ll + ffassert(l == -1); + long ll; + fin >> l >> ll; // read l and ll + ffassert(old); + if (version == 2) { + Ths[l] = old->Ths[ll]; + Ths[l]->increment( ); + } else { + Ths2[l] = old->Ths2[ll]; + Ths2[l]->increment( ); + } } - for (const char *s=cmm; *s; s++) - {if((debug > 10)) cout << *s ; - glutBitmapCharacter(glut_font,*s); + } + long nbmeshes3 = 0; + long nbmeshesS = 0; + long nbmeshesL = 0; + + int getMesh3Type = fin.GetMeshes3( ); // 0 : dt_mesh3, 1 : dt_meshS, 2 : dt_meshL, 3 : dt_plots + if (getMesh3Type != 3) // read GetPlots if false ... + { + // There are 3D volume solution + if (getMesh3Type == 0) { + + fin >> nbmeshes3; + if ((debug > 2)) cout << " read nb : mesh3 " << nbmeshes3 << endl; + Ths3.resize(nbmeshes3); + for (int i = 0; i < nbmeshes3; ++i) Ths3[i] = 0; + for (int i = 0; i < nbmeshes3; ++i) { + long l; + fin >> l; + if (l >= 0) { + if ((debug > 3)) cout << " read mesh3 " << i << " -> " << l << " " << nbmeshes3 << endl; + l--; + ffassert(l >= 0 && l < nbmeshes3); + ffassert(Ths3[l] == 0); + fin >> Ths3[l]; + if ((debug > 3)) cout << "mesh3 i: " << i << " nt/nv " << l << " " << Ths3[l]->nt << " " << Ths3[l]->nv << endl; + ffassert(fin.good( )); + } else // Add FH optimisation FH 11/12/2008 (not use to day) + { // the mesh is already in the previous plot with number ll + ffassert(l == -1); + long ll; + fin >> l >> ll; // read l and ll + ffassert(old); + Ths3[l] = old->Ths3[ll]; + Ths3[l]->increment( ); // + } + } + getMesh3Type = fin.GetMeshes3( ); + } + // There are 3D surface solution + if (getMesh3Type == 1) { + fin >> nbmeshesS; + if ((debug > 2)) cout << " read nb : meshS " << nbmeshesS << endl; + ThsS.resize(nbmeshesS); + for (int i = 0; i < nbmeshesS; ++i) ThsS[i] = 0; + for (int i = 0; i < nbmeshesS; ++i) { + long l; + fin >> l; + if (l >= 0) { + if ((debug > 3)) cout << "meshS i: " << " read meshS " << i << " -> " << l << " " << nbmeshesS << endl; + l--; + ffassert(l >= 0 && l < nbmeshesS); + ffassert(ThsS[l] == 0); + fin >> ThsS[l]; + if ((debug > 3)) cout << "meshS i: " << i << " nt/nv " << l << " " << ThsS[l]->nt << " " << ThsS[l]->nv << endl; + ffassert(fin.good( )); + } else // Add FH optimisation FH 11/12/2008 (not use to day) + { // the mesh is already in the previous plot with number ll + ffassert(l == -1); + long ll; + fin >> l >> ll; // read l and ll + ffassert(old); + ThsS[l] = old->ThsS[ll]; + ThsS[l]->increment( ); // + } + } + getMesh3Type = fin.GetMeshes3( ); + } + // There are 3D line solution + if (getMesh3Type == 2) { + fin >> nbmeshesL; + if ((debug > 2)) cout << " read nb : meshL " << nbmeshesL << endl; + ThsL.resize(nbmeshesL); + for (int i = 0; i < nbmeshesL; ++i) ThsL[i] = 0; + for (int i = 0; i < nbmeshesL; ++i) { + long l; + fin >> l; + if (l >= 0) { + if ((debug > 3)) cout << " read meshL " << i << " -> " << l << " " << nbmeshesL << endl; + l--; + ffassert(l >= 0 && l < nbmeshesL); + ffassert(ThsL[l] == 0); + fin >> ThsL[l]; + if ((debug > 3)) cout << "meshL i: " << i << " nt/nv " << l << " " << ThsL[l]->nt << " " << ThsL[l]->nv << endl; + ffassert(fin.good( )); + } else // Add FH optimisation FH 11/12/2008 (not use to day) + { // the mesh is already in the previous plot with number ll + ffassert(l == -1); + long ll; + fin >> l >> ll; // read l and ll + ffassert(old); + ThsL[l] = old->ThsL[ll]; + ThsL[l]->increment( ); // + } + } + getMesh3Type = fin.GetMeshes3( ); + } else if (getMesh3Type == 4) + + fin.GetPlots( ); + } + + long nbplot; + int iso3d = 0, iso3dB = 0; + fin >> nbplot; + if ((debug > 2)) cout << " nb item plot " << nbplot << endl; + for (int i = 0; i < nbplot; ++i) { + long what; + OnePlot *p = 0; + fin >> what; + long imsh; + if ((what != 3 && what != 13) && !uaspectratio) aspectratio = true; + if ((debug > 2)) cout << " plot " << i << " what " << what << " as : " << aspectratio << endl; + + if (what == -1) // gestion of error (empty plot) + p = new OnePlotError(fin); + else if (what == 0) { + fin >> imsh; + if ((debug > 9)) cout << " plot : mesh " << imsh << endl; + if (version == 2) + p = new OnePlotMesh< Mesh >(Ths[imsh - 1]); + else + p = new OnePlotMesh< Mesh2 >(Ths2[imsh - 1]); + + } else if (what == 1 || what == 2 || what == 11 || what == 12) { + fin >> imsh; + if (what % 10 == 1) + withiso = true; + else if (what % 10 == 2) + witharrow = true; + if ((debug >= 10)) cout << " plot : mesh " << imsh << endl; + ffassert(imsh > 0 && imsh <= nbmeshes); + if (version == 2) + p = new OnePlotFE< Mesh >(Ths[imsh - 1], what, fin); + else + p = new OnePlotFE< Mesh2 >(Ths2[imsh - 1], what, fin); + } else if (what == 3) + p = new OnePlotCurve(fin); + else if (what == 13) + p = new OnePlotCurve(fin, 4, this); // add zz and color .. + else if (what == 4) + p = new OnePlotBorder(fin); + + // volume 3D meshes (mesh3 or mesh3 only in case with pointer on meshS or/and meshL + else if (what == 5) { + fin >> imsh; + p = new OnePlotMesh3(Ths3[imsh - 1]); + if ((debug > 9)) cout << " plot : mesh3 (volume 3D) " << imsh << endl; + } + // surface 3D meshes + else if (what == 50) { + fin >> imsh; + if ((debug > 9)) cout << " plot : meshS (surface 3D) " << imsh << endl; + p = new OnePlotMeshS(ThsS[imsh - 1]); + } + // line 3D meshes + else if (what == 55) { + fin >> imsh; + if ((debug > 9)) cout << " plot : meshL (line 3D) " << imsh << endl; + p = new OnePlotMeshL(ThsL[imsh - 1]); + } else if (what == 6 || what == 7 || what == 16 || what == 17) { + iso3d++; + fin >> imsh; + if (what == 6 || what == 16) withiso = true; + + if ((debug > 10)) cout << " plot : mesh3 (volume) " << imsh << endl; + ffassert(imsh > 0 && imsh <= nbmeshes3); + p = new OnePlotFE3(Ths3[imsh - 1], what, fin); + } else if (what == 8 || what == 9 || what == 18 || what == 19) { + iso3dB++; + fin >> imsh; + if (what == 8 || what == 18) + withiso = true; + else if (what % 10 == 9) + witharrow = true; + if ((debug > 10)) cout << " plot : meshS (3D surface) " << imsh << endl; + ffassert(imsh > 0 && imsh <= nbmeshesS); + + p = new OnePlotFES(ThsS[imsh - 1], what, fin); + } else if (what == 14 || what == 15 || what == 20 || what == 21) { + iso3dB++; + fin >> imsh; + if (what == 14 || what == 20) + withiso = true; + else if (what == 15 || what == 21) + witharrow = true; + if ((debug > 10)) cout << " plot : meshL (3D curve) " << imsh << endl; + ffassert(imsh > 0 && imsh <= nbmeshesL); + p = new OnePlotFEL(ThsL[imsh - 1], what, fin); + } else if (what == 31) { + p = new OnePlotHMatrix(what, fin); + } else { + cout << "Bizarre unknown what : " << what << endl; + ffassert(0); + } + ffassert(p); + plots.push_back(p); + p->bb(Pmin, Pmax); + p->bfv(fmin, fmax, vmax2); + plotdim = max(plotdim, p->dim); + ffassert(fin.good( )); + datadim = max(datadim, p->dim); + } + if (dimpp) plotdim = dimpp; + + if (Niso == 0) Niso = iso3d ? 5 : 20; + if (iso3dB) Niso = 20; + double ref_f = abs(fmax) + abs(fmin); + if (fmax < fmin) { + fmax = 1; + fmin = 0; + } else if ((fmax - fmin) <= 1e-8 * ref_f) { + if (ref_f < 1e-20) ref_f = 0.5; + fmax += ref_f / 2; + fmin -= ref_f / 2; + } + PminT = Pmin; + PmaxT = Pmax; + fminT = fmin; + fmaxT = fmax; + + z0 = fminT - (fmaxT - fminT) * 0.01; + if ((debug > 2)) cout << " data bound: " << PminT << " " << PmaxT << " fmin == " << fminT << " " << fmaxT << " z0 " << z0 << endl; + fin.GetEndPlot( ); + Viso.resize(Niso); + Varrow.resize(Narrow); + + SetColorTable(Max(Niso, Narrow) + 4); + SetDefIsoV(Niso, Narrow, fmin, fmax); +} + +void ThePlot::SetDefIsoV(int niso, int narr, double fmn, double fmx, double vmn, double vmx) { + niso = max(niso, 2); + narr = max(narr, 2); + + bool dyni = niso != Viso.N( ), dyna = narr != Varrow.N( ); + R d, x; + if (debug > 3 && !(fmx > fmn)) cout << " SetDefIsoV (not) " << endl; + if (debug > 3) cout << " SetDefIsoV " << dyni << " " << fmn << " " << fmx << "pViso= " << pViso << " / " << dyna << " " << vmn << " " << vmx << endl; + + // resize !!! + Viso.resize(niso); + Niso = Viso.N( ); + + Varrow.resize(narr); + Narrow = Varrow.N( ); + + if (fmx > fmn) { + dyni = niso != Viso.N( ); + // pViso = pViso && niso ==Viso.N(); FH: debile !!!!! + d = (fmx - fmn) / (max(Niso - 2, 1L)); + x = (fmn + fmx) / 2 - d * 0.5 * (Niso - 1); + } else { + d = 1 ? (fmaxT - fminT) / (max(Niso - 2, 1L)) : (fmaxT - fminT) / (Niso - 1); + x = 1 ? (fminT + fmaxT) / 2 - d * 0.5 * (Niso - 1) : fminT + d / 2; + } + if (!pViso || dyni) { + for (int i = 0; i < Niso; i++) { + Viso[i] = x; + x += d; } - if((debug > 10)) cout << " ;;; " < vmn) { + dyna = true; + x = sqrt(vmn); + d = (sqrt(vmx) - x) / (Narrow - 1.1); + } else { + x = 0; + if (debug > 10) cout << "vmax2= " << vmax2 << endl; + d = sqrt(vmax2) / (Narrow - 1.1); + } + if (!pVarrow || dyna) + for (int i = 0; i < Narrow; i++) { + Varrow[i] = x; + x += d; + } + if (debug > 100) cout << " Viso ..; " << Viso << endl; + SetColorTable(Max(Niso, Narrow) + 4); +} + +void OneWindow::Show(const char *str, int i) { + int hx = 15; + if (kscreenscale == 2) hx = 25; // OK ... + int ix = width / 20; + int iy = height - hx * i; + plot(ix, iy, str); +} + +void FillRectRasterPos(R x0, R y0, R x1, R y1) { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // GL_FILL + glBegin(GL_POLYGON); + glVertex2d(x0, y0); + glVertex2d(x1, y0); + glVertex2d(x1, y1); + glVertex2d(x0, y1); + glEnd( ); +} + +void OneWindow::FillRect(R x0, R y0, R x1, R y1) { + + double z1 = (zmin + zmax) / 2; // line + glPolygonMode(GL_FRONT, GL_FILL); // GL_FILL + glBegin(GL_POLYGON); + glVertex3d(x0, y0, z1); + glVertex3d(x1, y0, z1); + glVertex3d(x1, y1, z1); + glVertex3d(x0, y1, z1); + glEnd( ); +} + +void OneWindow::PlotValue(const KN_< double > &Viso, int k0, const char *cmm) { + + ShowGlerror("PlotValue b"); + if ((debug > 10)) cout << "PlotValue:" << cmm << " " << k0 << " " << width << " " << height << " " << kscreenscale << endl; + R xmin = 0, xmax = width, ymin = 0, ymax = height; + if ((debug > 10)) cout << "PlotValue " << Viso << endl; + + R dx = (xmax - xmin); + R dy = (ymax - ymin); + // 10 points + R h = 10 * kscreenscale; + if (kscreenscale == 2) h = 24; // BofBof F.H + R ho = h * 1.1; + R x0 = xmin + dx * 0.85; + R y = ymin + dy * 0.97; + if ((debug > 10)) cout << x0 << " " << y << " " << h << endl; + y -= k0 * ho; + this->color(0); + FillRectRasterPos(x0 - h * 0.5, y - h * (1.4 * Viso.N( ) + 0.3), x0 + h * 9, y + h * 1.5); + ShowGlerror("PlotValue m"); + this->color(1); + + plot(x0 + ho, y, cmm); + y -= ho; + for (int i = 0; i < Viso.N( ); i++) { + if ((debug > 10)) cout << " x0 : " << x0 << " " << y << " " << h << " v = " << Viso[i] << endl; + this->color(i + 4); + FillRectRasterPos(x0, y, x0 + h, y + h); + plot(x0 + ho, y + 3 * h / 10, Viso[i]); + y -= ho; + ; + } + ShowGlerror("PlotValue f"); +} + +void OneWindow::DrawCommentaire(const char *cm, R x, R y) { + + R xmin = 0, xmax = height, ymin = 0, ymax = height; + float dx = (xmax - xmin); + float dy = (ymax - ymin); + plot(xmin + dx * x, ymin + dy * y, cm); +} + +void plot(double xx, double yy, const char *cmm, int font) { + glRasterPos2f(xx, yy); + float x[4]; + glGetFloatv(GL_CURRENT_RASTER_POSITION, x); + if ((debug > 10)) cout << "avant x : " << x[0] << " y : " << x[1] << " z : " << x[2] << " " << xx << " " << yy << endl; + void *glut_font = GLUT_BITMAP_HELVETICA_18; + if (kscreenscale == 2) glut_font = GLUT_BITMAP_TIMES_ROMAN_24; + switch (font) { + case 0: + glut_font = GLUT_STROKE_ROMAN; + break; + case 1: + glut_font = GLUT_STROKE_MONO_ROMAN; + break; + case 2: + glut_font = GLUT_BITMAP_9_BY_15; + break; + case 3: + glut_font = GLUT_BITMAP_8_BY_13; + break; + case 4: + glut_font = GLUT_BITMAP_TIMES_ROMAN_10; + break; + case 5: + glut_font = GLUT_BITMAP_TIMES_ROMAN_24; + break; + case 6: + glut_font = GLUT_BITMAP_HELVETICA_10; + break; + case 7: + glut_font = GLUT_BITMAP_HELVETICA_12; + break; + case 8: + glut_font = GLUT_BITMAP_HELVETICA_18; + break; + } + for (const char *s = cmm; *s; s++) { + if ((debug > 10)) cout << *s; + glutBitmapCharacter(glut_font, *s); + } + if ((debug > 10)) cout << " ;;; " << endl; } -void plot(double x,double y,double i,int font) -{ - char buf[24]; - snprintf(buf,24,"%g",i); - plot(x,y,buf); +void plot(double x, double y, double i, int font) { + char buf[24]; + snprintf(buf, 24, "%g", i); + plot(x, y, buf); } +void hsvToRgb(float h, float s, float v, float &r, float &g, float &b) { + int i; + float aa, bb, cc, f; -void hsvToRgb (float h, float s, float v, float & r, float & g, float & b) -{ - int i; - float aa, bb, cc, f; - - if (s == 0) /* Grayscale */ - r = g = b = v; - else { - h = h - floorf(h); - h*=6.; - i = int(h); - f = h - i; - aa = v * (1 - s); - bb = v * (1 - (s * f)); - cc = v * (1 - (s * (1 - f))); - switch (i) { - case 0: r = v; g = cc; b = aa; break; - case 1: r = bb; g = v; b = aa; break; - case 2: r = aa; g = v; b = cc; break; - case 3: r = aa; g = bb; b = v; break; - case 4: r = cc; g = aa; b = v; break; - case 5: r = v; g = aa; b = bb; break; - } + if (s == 0) /* Grayscale */ + r = g = b = v; + else { + h = h - floorf(h); + h *= 6.; + i = int(h); + f = h - i; + aa = v * (1 - s); + bb = v * (1 - (s * f)); + cc = v * (1 - (s * (1 - f))); + switch (i) { + case 0: + r = v; + g = cc; + b = aa; + break; + case 1: + r = bb; + g = v; + b = aa; + break; + case 2: + r = aa; + g = v; + b = cc; + break; + case 3: + r = aa; + g = bb; + b = v; + break; + case 4: + r = cc; + g = aa; + b = v; + break; + case 5: + r = v; + g = aa; + b = bb; + break; } + } } -void ThePlot::DrawIsoT(const R2 Pt[3],const R ff[3],const R * Viso,int NbIso, R rapz) -{ - int nbl =0; - R2 PQ[5]; - R eps2= Min(R2(Pt[0],Pt[1]).norme2(),R2(Pt[0],Pt[2]).norme2(),R2(Pt[1],Pt[2]).norme2() )*1e-8; - for(int l=0;l< NbIso;l++) /* loop on the level curves */ +void ThePlot::DrawIsoT(const R2 Pt[3], const R ff[3], const R *Viso, int NbIso, R rapz) { + int nbl = 0; + R2 PQ[5]; + R eps2 = Min(R2(Pt[0], Pt[1]).norme2( ), R2(Pt[0], Pt[2]).norme2( ), R2(Pt[1], Pt[2]).norme2( )) * 1e-8; + for (int l = 0; l < NbIso; l++) /* loop on the level curves */ + { + R xf = Viso[l]; + int im = 0; + for (int i = 0; i < 3; i++) // for the 3 edges { - R xf = Viso[l]; - int im=0; - for(int i=0;i<3;i++) // for the 3 edges - { - int j = (i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)<=0.1e-10) /* one side must be drawn */ - { - color(l+4); - glVertex3f(Pt[i].x, Pt[i].y, xf*rapz); - glVertex3f(Pt[j].x, Pt[j].y, xf*rapz); - } - else - { - R xlam=(fi-xf)/(fi-fj); - - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - } + int j = (i + 1) % 3; + R fi = (ff[i]); + R fj = (ff[j]); - if (im>=2) /* draw one segment */ + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) <= 0.1e-10) /* one side must be drawn */ { - color(l+4); - if( R2(PQ[0],PQ[1]).norme2() > eps2 ) - { - if(nbl++==0) glBegin(GL_LINES); - glVertex3f(PQ[0].x, PQ[0].y, xf*rapz); - glVertex3f(PQ[1].x, PQ[1].y, xf*rapz); - } + color(l + 4); + glVertex3f(Pt[i].x, Pt[i].y, xf * rapz); + glVertex3f(Pt[j].x, Pt[j].y, xf * rapz); + } else { + R xlam = (fi - xf) / (fi - fj); + + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; } + } } - if(nbl) glEnd(); + if (im >= 2) /* draw one segment */ + { + color(l + 4); + if (R2(PQ[0], PQ[1]).norme2( ) > eps2) { + if (nbl++ == 0) glBegin(GL_LINES); + glVertex3f(PQ[0].x, PQ[0].y, xf * rapz); + glVertex3f(PQ[1].x, PQ[1].y, xf * rapz); + } + } + } + if (nbl) glEnd( ); } // draw iso values for FE surface -void ThePlot::DrawIsoT(const R3 Pt[3],const R ff[3],const R3 Nt[3],const R * Viso,int NbIso,bool changePlotdim,int viewdim,R rapz) -{ - int nbl=0; - R3 PQ[5]; - R3 NQ[5]; - R eps2= Min(R3(Pt[0],Pt[1]).norme2(),R3(Pt[0],Pt[2]).norme2(),R3(Pt[1],Pt[2]).norme2() )*1e-8; - for(int l=0;l< NbIso;l++) { /* loop on the level curves */ - R xf = Viso[l]; - int im=0; - for(int i=0;i<3;i++) { // for the 3 edges - int j = (i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) { - if (Abs(fi-fj)<=0.1e-10) { /* one side must be drawn */ - color(l+4); - if(nbl++==0) glBegin(GL_LINES); - if(viewdim==3) - if(changePlotdim){ - glVertex3f(Pt[i].x+NQ[i].x*xf*rapz, Pt[i].y+NQ[i].y*xf*rapz, Pt[i].z+NQ[i].z*xf*rapz); - glVertex3f(Pt[j].x+NQ[j].x*xf*rapz, Pt[j].y+NQ[j].y*xf*rapz, Pt[j].z+NQ[j].z*xf*rapz); - } - else { - glVertex3f(Pt[i].x, Pt[i].y, Pt[i].z); - glVertex3f(Pt[j].x, Pt[j].y, Pt[j].z); - } - else if(viewdim==2) { - glVertex3f(Pt[i].x, Pt[i].y, xf*rapz); - glVertex3f(Pt[j].x, Pt[j].y, xf*rapz); - } - } - else { - R xlam=(fi-xf)/(fi-fj); - NQ[im] = Nt[i] * (1.F-xlam) + Nt[j]* xlam; - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } +void ThePlot::DrawIsoT(const R3 Pt[3], const R ff[3], const R3 Nt[3], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz) { + int nbl = 0; + R3 PQ[5]; + R3 NQ[5]; + R eps2 = Min(R3(Pt[0], Pt[1]).norme2( ), R3(Pt[0], Pt[2]).norme2( ), R3(Pt[1], Pt[2]).norme2( )) * 1e-8; + for (int l = 0; l < NbIso; l++) { /* loop on the level curves */ + R xf = Viso[l]; + int im = 0; + for (int i = 0; i < 3; i++) { // for the 3 edges + int j = (i + 1) % 3; + R fi = (ff[i]); + R fj = (ff[j]); + + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) <= 0.1e-10) { /* one side must be drawn */ + color(l + 4); + if (nbl++ == 0) glBegin(GL_LINES); + if (viewdim == 3) + if (changePlotdim) { + glVertex3f(Pt[i].x + NQ[i].x * xf * rapz, Pt[i].y + NQ[i].y * xf * rapz, Pt[i].z + NQ[i].z * xf * rapz); + glVertex3f(Pt[j].x + NQ[j].x * xf * rapz, Pt[j].y + NQ[j].y * xf * rapz, Pt[j].z + NQ[j].z * xf * rapz); + } else { + glVertex3f(Pt[i].x, Pt[i].y, Pt[i].z); + glVertex3f(Pt[j].x, Pt[j].y, Pt[j].z); } + else if (viewdim == 2) { + glVertex3f(Pt[i].x, Pt[i].y, xf * rapz); + glVertex3f(Pt[j].x, Pt[j].y, xf * rapz); + } + } else { + R xlam = (fi - xf) / (fi - fj); + NQ[im] = Nt[i] * (1.F - xlam) + Nt[j] * xlam; + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; } + } + } - if (im>=2) - { - color(l+4); - if( R3(PQ[0],PQ[1]).norme2() > eps2 ) { - if(nbl++==0) glBegin(GL_LINES); - if(viewdim==3) - if(changePlotdim){ - glVertex3f(PQ[0].x+NQ[0].x*xf*rapz, PQ[0].y+NQ[0].y*xf*rapz, PQ[0].z+NQ[0].z*xf*rapz); - glVertex3f(PQ[1].x+NQ[1].x*xf*rapz, PQ[1].y+NQ[1].y*xf*rapz, PQ[1].z+NQ[1].z*xf*rapz); - } - else { - glVertex3f(PQ[0].x, PQ[0].y, PQ[0].z); - glVertex3f(PQ[1].x, PQ[1].y, PQ[1].z); - } - else if(viewdim==2) { - glVertex3f(PQ[0].x, PQ[0].y, xf*rapz); - glVertex3f(PQ[1].x, PQ[1].y, xf*rapz); - } - } + if (im >= 2) { + color(l + 4); + if (R3(PQ[0], PQ[1]).norme2( ) > eps2) { + if (nbl++ == 0) glBegin(GL_LINES); + if (viewdim == 3) + if (changePlotdim) { + glVertex3f(PQ[0].x + NQ[0].x * xf * rapz, PQ[0].y + NQ[0].y * xf * rapz, PQ[0].z + NQ[0].z * xf * rapz); + glVertex3f(PQ[1].x + NQ[1].x * xf * rapz, PQ[1].y + NQ[1].y * xf * rapz, PQ[1].z + NQ[1].z * xf * rapz); + } else { + glVertex3f(PQ[0].x, PQ[0].y, PQ[0].z); + glVertex3f(PQ[1].x, PQ[1].y, PQ[1].z); + } + else if (viewdim == 2) { + glVertex3f(PQ[0].x, PQ[0].y, xf * rapz); + glVertex3f(PQ[1].x, PQ[1].y, xf * rapz); } + } } - if( nbl) glEnd(); + } + if (nbl) glEnd( ); } - - - // draw filling values for 2d FE -void ThePlot::DrawIsoTfill(const R2 Pt[3],const R ff[3],const R * Viso,int NbIso, R rapz) -{ - R2 PQ[10]; - R z[10]; - - R eps= (Viso[NbIso-1]-Viso[0])*1e-6; - for(int l=1;l< NbIso;l++) // loop on the level curves - { - R xfb = Viso[l-1]; - R xfh = Viso[l]; - assert(xfb < xfh); - int im=0; - for(int i=0;i<3;i++) // for the 3 edges - { - int j=(i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - R xxfb = xfb; - R xxfh = xfh; - if (fj=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)>=0.1e-20) - { - R xlam=(fi-xf)/(fi-fj); - z[im] = ff[i] * (1.F-xlam) + ff[j]* xlam; - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - if(verbosity>999) cout << im-1 << " PQ " << PQ[im-1] << endl; - } - } - xf = xxfh; - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)>=0.1e-20) - { - R xlam=(fi-xf)/(fi-fj); - z[im] = ff[i] * (1.F-xlam) + ff[j]* xlam; - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - if ( xfb-eps <=fj && fj <= xfh+eps) - z[im]=ff[j],PQ[im++] = Pt[j]; - +void ThePlot::DrawIsoTfill(const R2 Pt[3], const R ff[3], const R *Viso, int NbIso, R rapz) { + R2 PQ[10]; + R z[10]; + + R eps = (Viso[NbIso - 1] - Viso[0]) * 1e-6; + for (int l = 1; l < NbIso; l++) // loop on the level curves + { + R xfb = Viso[l - 1]; + R xfh = Viso[l]; + assert(xfb < xfh); + int im = 0; + for (int i = 0; i < 3; i++) // for the 3 edges + { + int j = (i + 1) % 3; + R fi = (ff[i]); + R fj = (ff[j]); + R xxfb = xfb; + R xxfh = xfh; + if (fj < fi) Exchange(xxfb, xxfh); + R xf = xxfb; + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + z[im] = ff[i] * (1.F - xlam) + ff[j] * xlam; + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; + if (verbosity > 999) cout << im - 1 << " PQ " << PQ[im - 1] << endl; } - if (im>2) - { - color(l+4); - R3 P[10]; - for(int i=0;i= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + z[im] = ff[i] * (1.F - xlam) + ff[j] * xlam; + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; } + } + if (xfb - eps <= fj && fj <= xfh + eps) z[im] = ff[j], PQ[im++] = Pt[j]; + } + if (im > 2) { + color(l + 4); + R3 P[10]; + for (int i = 0; i < im; ++i) P[i] = R3(PQ[i].x, PQ[i].y, z[i] * rapz); + R3 N(R3(P[0], P[1]) ^ R3(P[0], P[2])); + N /= N.norme( ); + if (N.z < 0) N = -N; + glNormal3d(N.x, N.y, N.z); + + glBegin(GL_POLYGON); + for (int i = 0; i < im; i++) { + glVertex3f(P[i].x, P[i].y, P[i].z); + } + glEnd( ); } + } } // draw filling values for 3d FE surface -void ThePlot::DrawIsoTfill(const R3 Pt[3],const R ff[3],const R3 Nt[3],const R * Viso,int NbIso,bool changePlotdim,int viewdim,R rapz) -{ - R3 PQ[10]; - R3 NQ[10]; - R z[10]; - R eps= (Viso[NbIso-1]-Viso[0])*1e-6; - for(int l=1;l< NbIso;l++) // loop on the level curves - { - R xfb = Viso[l-1]; - R xfh = Viso[l]; - assert(xfb < xfh); - int im=0; - for(int i=0;i<3;i++) // for the 3 edges - { - int j=(i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - R xxfb = xfb; - R xxfh = xfh; - if (fj=xf))||((fi>=xf)&&(fj<=xf))) { - if (Abs(fi-fj)>=0.1e-20) { - R xlam=(fi-xf)/(fi-fj); - z[im] = fi * (1.F-xlam) + fj* xlam; - NQ[im] = Nt[i] * (1.F-xlam) + Nt[j] * xlam; - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - xf = xxfh; - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) { - if (Abs(fi-fj)>=0.1e-20) { - R xlam=(fi-xf)/(fi-fj); - z[im] = fi * (1.F-xlam) + fj* xlam; - NQ[im] = Nt[i] * (1.F-xlam) + Nt[j] * xlam; - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - if ( xfb-eps <=fj && fj <= xfh+eps) - {z[im]=fj,NQ[im]=Nt[j]; PQ[im++] = Pt[j];} +void ThePlot::DrawIsoTfill(const R3 Pt[3], const R ff[3], const R3 Nt[3], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz) { + R3 PQ[10]; + R3 NQ[10]; + R z[10]; + R eps = (Viso[NbIso - 1] - Viso[0]) * 1e-6; + for (int l = 1; l < NbIso; l++) // loop on the level curves + { + R xfb = Viso[l - 1]; + R xfh = Viso[l]; + assert(xfb < xfh); + int im = 0; + for (int i = 0; i < 3; i++) // for the 3 edges + { + int j = (i + 1) % 3; + R fi = (ff[i]); + R fj = (ff[j]); + R xxfb = xfb; + R xxfh = xfh; + if (fj < fi) Exchange(xxfb, xxfh); + R xf = xxfb; + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + z[im] = fi * (1.F - xlam) + fj * xlam; + NQ[im] = Nt[i] * (1.F - xlam) + Nt[j] * xlam; + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; } - if (im>2) { - color(l+4); - R3 P[10]; - for(int i=0;i 100)) cout << i << " \t : " << PQ[i].x << " " << PQ[i].y << " " << PQ[i].z << endl; - glVertex3f(P[i].x, P[i].y, P[i].z); - } - glEnd(); + } + xf = xxfh; + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + z[im] = fi * (1.F - xlam) + fj * xlam; + NQ[im] = Nt[i] * (1.F - xlam) + Nt[j] * xlam; + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; } + } + if (xfb - eps <= fj && fj <= xfh + eps) { + z[im] = fj, NQ[im] = Nt[j]; + PQ[im++] = Pt[j]; + } + } + if (im > 2) { + color(l + 4); + R3 P[10]; + for (int i = 0; i < im; ++i) + if (viewdim == 3) + if (changePlotdim) + P[i] = R3(PQ[i].x + rapz * z[i] * NQ[i].x, PQ[i].y + rapz * z[i] * NQ[i].y, PQ[i].z + rapz * z[i] * NQ[i].z); + else + P[i] = R3(PQ[i].x, PQ[i].y, PQ[i].z); + else if (viewdim == 2) + P[i] = R3(PQ[i].x, PQ[i].y, rapz * z[i]); + + R3 N(R3(P[0], P[1]) ^ R3(P[0], P[2])); + N /= N.norme( ); + if (N.z < 0) N = -N; + glNormal3d(N.x, N.y, N.z); + + glBegin(GL_POLYGON); + for (int i = 0; i < im; i++) { + if ((debug > 100)) cout << i << " \t : " << PQ[i].x << " " << PQ[i].y << " " << PQ[i].z << endl; + glVertex3f(P[i].x, P[i].y, P[i].z); + } + glEnd( ); } + } } // draw filling values for 3d FE curve -void ThePlot::DrawIsoEfill(const R3 Pt[2],const R ff[2],const R3 Nt[2],const R * Viso,int NbIso,bool changePlotdim,int viewdim, R rapz) -{ - R3 PQ[10], NQ[10]; - R z[10]; - R eps= (Viso[NbIso-1]-Viso[0])*1e-6; - for(int l=1;l< NbIso;l++) // loop on the level curves - { - R xfb = Viso[l-1]; - R xfh = Viso[l]; - assert(xfb < xfh); - int im=0; - R fi=(ff[0]), fj=(ff[1]), xxfb=xfb, xxfh=xfh; - int sens = 0; - if (fj=0.1e-20) { - if ((xxfh>=fi && xxfb<=fj) || (xxfh<=fi && xxfb>=fj)) { - PQ[im] = Pt[0]; - NQ[im] = Nt[0]; - z[im++] = fi; - if ((!sens && (xxfb >= fi)) || (sens && (xxfb <= fi))) { - R xlam=(fi-xxfb)/(fi-fj); - PQ[im-1] = Pt[0] * (1.F-xlam) + Pt[1]* xlam; - NQ[im-1] = Nt[0] * (1.F-xlam) + Nt[1]* xlam; - z[im-1] = fi * (1.F-xlam) + fj* xlam; - } - PQ[im] = Pt[1]; - NQ[im] = Nt[1]; - z[im++] = fj; - if ((!sens && (xxfh <= fj)) || (sens && (xxfh >= fj))) { - R xlam=(fi-xxfh)/(fi-fj); - PQ[im-1] = Pt[0] * (1.F-xlam) + Pt[1]* xlam; - NQ[im-1] = Nt[0] * (1.F-xlam) + Nt[1]* xlam; - z[im-1] = fi * (1.F-xlam) + fj* xlam; - } - } - } - else if (xfb-eps <=fj && fj <= xfh+eps) { - PQ[im] = Pt[0]; NQ[im] = Nt[0]; z[im++] =fi; - PQ[im] = Pt[1]; NQ[im] = Nt[1]; z[im++] =fj; - } - - if (im>1) { - color(l+4); - R3 P[10]; - for(int i=0;i 100)) cout << i << " \t : " << Pt[i].x << " " << Pt[i].y << " " << Pt[i].z << endl; - glVertex3f(P[i].x, P[i].y, P[i].z); - } - glEnd(); - glLineWidth(kscreenscale); +void ThePlot::DrawIsoEfill(const R3 Pt[2], const R ff[2], const R3 Nt[2], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz) { + R3 PQ[10], NQ[10]; + R z[10]; + R eps = (Viso[NbIso - 1] - Viso[0]) * 1e-6; + for (int l = 1; l < NbIso; l++) // loop on the level curves + { + R xfb = Viso[l - 1]; + R xfh = Viso[l]; + assert(xfb < xfh); + int im = 0; + R fi = (ff[0]), fj = (ff[1]), xxfb = xfb, xxfh = xfh; + int sens = 0; + if (fj < fi) { + Exchange(xxfb, xxfh); + sens = 1; + } + + if (Abs(fi - fj) >= 0.1e-20) { + if ((xxfh >= fi && xxfb <= fj) || (xxfh <= fi && xxfb >= fj)) { + PQ[im] = Pt[0]; + NQ[im] = Nt[0]; + z[im++] = fi; + if ((!sens && (xxfb >= fi)) || (sens && (xxfb <= fi))) { + R xlam = (fi - xxfb) / (fi - fj); + PQ[im - 1] = Pt[0] * (1.F - xlam) + Pt[1] * xlam; + NQ[im - 1] = Nt[0] * (1.F - xlam) + Nt[1] * xlam; + z[im - 1] = fi * (1.F - xlam) + fj * xlam; + } + PQ[im] = Pt[1]; + NQ[im] = Nt[1]; + z[im++] = fj; + if ((!sens && (xxfh <= fj)) || (sens && (xxfh >= fj))) { + R xlam = (fi - xxfh) / (fi - fj); + PQ[im - 1] = Pt[0] * (1.F - xlam) + Pt[1] * xlam; + NQ[im - 1] = Nt[0] * (1.F - xlam) + Nt[1] * xlam; + z[im - 1] = fi * (1.F - xlam) + fj * xlam; } + } + } else if (xfb - eps <= fj && fj <= xfh + eps) { + PQ[im] = Pt[0]; + NQ[im] = Nt[0]; + z[im++] = fi; + PQ[im] = Pt[1]; + NQ[im] = Nt[1]; + z[im++] = fj; + } + + if (im > 1) { + color(l + 4); + R3 P[10]; + for (int i = 0; i < im; ++i) + if (viewdim == 3) + if (changePlotdim) + P[i] = R3(PQ[i].x + rapz * z[i] * NQ[i].x, PQ[i].y + rapz * z[i] * NQ[i].y, PQ[i].z + rapz * z[i] * NQ[i].z); + else + P[i] = R3(PQ[i].x, PQ[i].y, PQ[i].z); + else if (viewdim == 2) + P[i] = R3(PQ[i].x, PQ[i].y, rapz * z[i]); + + glLineWidth(3 * kscreenscale); + glPolygonMode(GL_FRONT, GL_LINE); + + glBegin(GL_LINES); + for (int i = 0; i < im; i++) { + if ((debug > 100)) cout << i << " \t : " << Pt[i].x << " " << Pt[i].y << " " << Pt[i].z << endl; + glVertex3f(P[i].x, P[i].y, P[i].z); + } + glEnd( ); + glLineWidth(kscreenscale); } + } } - -bool WindowDump (int width, int height) { +bool WindowDump(int width, int height) { int i, j; FILE *fptr; static int counter = 0; @@ -3661,19 +3373,19 @@ bool WindowDump (int width, int height) { unsigned char *image; /* Allocate our buffer for the image */ - if ((image = new unsigned char[3*width*height]) == NULL) { + if ((image = new unsigned char[3 * width * height]) == NULL) { fprintf(stderr, "WindowDump - Failed to allocate memory for image\n"); return false; } /* Open the file */ - snprintf(fname,32, "ffglut_%04d.ppm", counter); + snprintf(fname, 32, "ffglut_%04d.ppm", counter); if ((fptr = fopen(fname, MODE_WRITE_BINARY)) == NULL) { fprintf(stderr, "WindowDump - Failed to open file for window dump\n"); delete[] image; return false; } - if((debug > 10)) cout << " WindowDump in " << fname << endl; + if ((debug > 10)) cout << " WindowDump in " << fname << endl; /* Copy the image into our buffer */ glReadBuffer(GL_FRONT); @@ -3681,11 +3393,11 @@ bool WindowDump (int width, int height) { /* Write the PPM file */ fprintf(fptr, "P6\n%d %d\n255\n", width, height); - for (j = height-1; j >= 0; j--) { + for (j = height - 1; j >= 0; j--) { for (i = 0; i < width; i++) { - fputc(image[3*j*width+3*i+0], fptr); - fputc(image[3*j*width+3*i+1], fptr); - fputc(image[3*j*width+3*i+2], fptr); + fputc(image[3 * j * width + 3 * i + 0], fptr); + fputc(image[3 * j * width + 3 * i + 1], fptr); + fputc(image[3 * j * width + 3 * i + 2], fptr); } } fclose(fptr); @@ -3695,623 +3407,573 @@ bool WindowDump (int width, int height) { return true; } - -void Clean() -{ - glClearColor(1.0, 1.0, 1.0, 0.0); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); +void Clean( ) { + glClearColor(1.0, 1.0, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } -static void Reshape( int width, int height ) -{ - GLint pView[4]; - - width*= kscreenscale; - height*= kscreenscale; +static void Reshape(int width, int height) { + GLint pView[4]; + + width *= kscreenscale; + height *= kscreenscale; // cout << " width " << width << " "<resize(width,height); + OneWindow *win = CurrentWin( ); + if (win) { + win->resize(width, height); // glGetIntegerv(GL_VIEWPORT, pView); // cout << "pView " << pView[0]<< " "<< pView[1]<< " "<< pView[2]<< " "<< pView[3]<< endl; - - } - glutPostRedisplay(); + } + glutPostRedisplay( ); } - - -void Display(void) -{ - OneWindow * win=CurrentWin(); - if(win) - { - if (win->countdisplay++<0) { // HAsh for MAC OS Mojave ???? FH oct 2018 ... - if(debug>4 || 1) cout << "\n **** Hack Mojove :: glutReshapeWindow " << win->width << " " << win->height <<" \n" << endl; - win->width--; - win->height--; +void Display(void) { + OneWindow *win = CurrentWin( ); + if (win) { + if (win->countdisplay++ < 0) { // HAsh for MAC OS Mojave ???? FH oct 2018 ... + if (debug > 4 || 1) cout << "\n **** Hack Mojove :: glutReshapeWindow " << win->width << " " << win->height << " \n" << endl; + win->width--; + win->height--; #ifdef GLUT_WINDOW_SCALE - glutscreenscale= glutGet(GLUT_WINDOW_SCALE); + glutscreenscale = glutGet(GLUT_WINDOW_SCALE); #endif - glutReshapeWindow(win->width,win->height); - win->resize(win->width,win->height); - glutPostRedisplay(); - return; - } - - if(debug>9) - { - cout << "\n\n Display "<< win->theplot << " true wiat: " << (!win->theplot || !win->theplot->wait || gwait) << endl; - } - { - Clean(); - win->Display(); - glFlush(); - glutSwapBuffers(); - if ( win->windowdump) - WindowDump(win->width,win->height); - win->windowdump=false; - } - - } - if(debug>9) - { - cout << " Send SendForNextPlot : win->theplot " << win->theplot << " " << (!win->theplot || !win->theplot->wait || gwait);; - if(win->theplot) cout << " wait" << win->theplot->wait << endl; - cout <<"\n\n\n"<< endl; - } - if(!win->theplot || !win->theplot->wait || gwait ) - SendForNextPlot(); - - if(!NoMorePlotTilte &&NoMorePlot) - { - NoMorePlotTilte=true; - glutSetWindowTitle("FreeFem++ / Program ended; enter ESC to exit)"); + glutReshapeWindow(win->width, win->height); + win->resize(win->width, win->height); + glutPostRedisplay( ); + return; } -} - -static void Mouse( int button,int state,int x,int y ) -{ - // state up or down - x *= kscreenscale; - y *= kscreenscale; - - OneWindow * win=CurrentWin(); - keyact = glutGetModifiers(); - switch(button) - { - case GLUT_LEFT_BUTTON: - casemouse=GLUT_LEFT_BUTTON; - if(win) - { - if(win && state == GLUT_DOWN) { win->xold=x,win->yold=y;return;} - win->phi += (y-win->yold)/(2.*180.); - win->theta -= (x-win->xold)/(2*180.); - glutPostRedisplay(); - } - break; - case GLUT_RIGHT_BUTTON: - casemouse=GLUT_RIGHT_BUTTON; - if(win) - { - if(win && state == GLUT_DOWN) { win->xold=x,win->yold=y;return;} - } - break; + if (debug > 9) { + cout << "\n\n Display " << win->theplot << " true wiat: " << (!win->theplot || !win->theplot->wait || gwait) << endl; } -} -static void MotionMouse(int x,int y ) -{ - OneWindow * win=CurrentWin(); - x *= kscreenscale; - y *= kscreenscale; - switch(casemouse) { - case GLUT_LEFT_BUTTON: - - if(win) - { - win->phi += (y-win->yold)/(2.*180.); - win->theta -= (x-win->xold)/(2*180.); - win->xold=x; - win->yold=y; - glutPostRedisplay(); - } - break; - case GLUT_RIGHT_BUTTON: - casemouse=GLUT_RIGHT_BUTTON; - - if(win) - { - if(keyact & GLUT_ACTIVE_ALT) - { - int dx = (x-win->xold); - int dy = (y-win->yold); - win->MoveXView(dx,-dy); - glutPostRedisplay(); - { win->xold=x,win->yold=y;} - } - else { - // zoom en y - R dd= (y-win->yold); - - { win->xold=x,win->yold=y;} - win->zoom(pow(0.99,dd)); - glutPostRedisplay(); - - } - } - break; + Clean( ); + win->Display( ); + glFlush( ); + glutSwapBuffers( ); + if (win->windowdump) WindowDump(win->width, win->height); + win->windowdump = false; } + } + if (debug > 9) { + cout << " Send SendForNextPlot : win->theplot " << win->theplot << " " << (!win->theplot || !win->theplot->wait || gwait); + ; + if (win->theplot) cout << " wait" << win->theplot->wait << endl; + cout << "\n\n\n" << endl; + } + if (!win->theplot || !win->theplot->wait || gwait) SendForNextPlot( ); + if (!NoMorePlotTilte && NoMorePlot) { + NoMorePlotTilte = true; + glutSetWindowTitle("FreeFem++ / Program ended; enter ESC to exit)"); + } } -static void Key( unsigned char key, int x, int y ) -{ - x *= kscreenscale; - y *= kscreenscale; - OneWindow * win=CurrentWin(); - if(!win->theplot)return; - if(debug>1) cout << "Key winnum: " <theplot->winnum << endl; - int ni=win->theplot->Viso.N(); - int na=win->theplot->Varrow.N(); - int nbN=win->theplot->nbN; - - win->help= false; - switch (key) - { - case 27: // esc char - Fin(0); - break; - case 3: // esc char - Fin(9); - break; - case 'w': - if(win) - win->windowdump=true; - break; - case 'l': - win->withlight = !win->withlight; - break; - case '?' : - if(win) - win->help= true; - break; - case '+': - win->zoom(x,y,0.7); - win->coef_dist /= 1.2; - break; - case '-': - win->zoom(x,y,1./0.7); - win->coef_dist *= 1.2; - break; - case '3': - win->plotdim=win->plotdim==2?3:2; - break; - case '2': - win->changePlotdim=win->changePlotdim==0 ? 1 : 0; - break; - case '=': - win->DefaultView(1); - break; - case 'f': - win->theplot->fill = ! win->theplot->fill ; - break; - case '@': - win->dtheta = win->dtheta ? 0 : pi/1800.; - break; - case '*': // add FH mars 2013 .. - win->keepPV = ! win->keepPV; - if(debug) cout << " ... win->keepPV "<< win->keepPV << endl; - break; - case 'k': - if(win->theplot->NextCase()) - { - R fmn,fmx,vmn,vmx; - win->theplot->dyn_bfv(win,fmn,fmx,vmn,vmx) ; - win->theplot->SetDefIsoV(ni,na,fmn,fmx,vmn,vmx) ; - win->changeiso=true; - win->changearrow=true; - } - break; - - case 'b': - win->theplot->grey = ! win->theplot->grey ; - win->changeiso=true; - win->changearrow=true; - - break; - case 'g': - win->theplot->grey = ! win->theplot->grey ; - win->changeiso=true; - win->changearrow=true; - - break; - - case 'v': - win->theplot->value = ! win->theplot->value ; - break; - case 'm': - win->theplot->drawmeshes = ! win->theplot->drawmeshes ; - break; - case 'B': - win->theplot->drawborder = ! win->theplot->drawborder ; - break; - case 'H': - win->rapz *= 1.2; - break; - case 'h': - win->rapz /= 1.2; - break; - case 'p': - if(win->icurrentPlot != win->lplots.begin()) - win->set(*--win->icurrentPlot); - break; - case 'a': - win->theplot->coeff/= 1.2; - win->changearrow=true; - break; - case 'A': - win->theplot->coeff*= 1.2; - win->changearrow=true; - break; - - case 'n': - { - na -= na < 10 ? 2 : 5; - ni -= ni <10 ? 2 : 5; - na = max(na,2); - ni = max(ni,2); - R fmn,fmx,vmn,vmx; - win->theplot->dyn_bfv(win,fmn,fmx,vmn,vmx) ; - win->theplot->SetDefIsoV(ni,na,fmn,fmx,vmn,vmx) ; - - win->changeiso=true; - win->changearrow=true; - } - break ; - case 'N': - { - na += na < 10 ? 2 : 5; - ni += ni < 10 ? 2 : 5; - } - case 'i': - { - R fmn,fmx,vmn,vmx; - win->theplot->dyn_bfv(win,fmn,fmx,vmn,vmx) ; - win->theplot->SetDefIsoV(ni,na,fmn,fmx,vmn,vmx) ; - - win->changeiso=true; - win->changearrow=true; - } - break; - case 'I': - { - R fmn,fmx,vmn,vmx; - win->theplot->SetDefIsoV(ni,na) ; - win->changeiso=true; - win->changearrow=true; - } - break; - case 'z': - if(win->focal < my_pi/1.2 ) - { - win->coef_dist*=sin(win->focal*1.2/2)/sin(win->focal/2); - win->focal *=1.2; - } - break; - case 'Z': - if(win->focal > 1e-5) - { - win->coef_dist*=sin(win->focal/1.2/2)/sin(win->focal/2); - win->focal /=1.2; - } - break; - case '\r': - case '\n': - { - list::iterator ic = win->icurrentPlot; - if(++ic == win->lplots.end()) // last plot -> try new one - SendForNextPlot(); - else - win->set(*++win->icurrentPlot); - break; - } - case 'T': - win->theplot->pNormalT = ! win->theplot->pNormalT ; - break; - case 'Q': - { - win->theplot->nbN /= win->theplot->nbN < 0 ? 0 : 2; - break; - } - case 'q': - { - win->theplot->nbN *= win->theplot->nbN < 0 ? 0 : 2; - break; +static void Mouse(int button, int state, int x, int y) { + // state up or down + x *= kscreenscale; + y *= kscreenscale; + + OneWindow *win = CurrentWin( ); + keyact = glutGetModifiers( ); + switch (button) { + case GLUT_LEFT_BUTTON: + casemouse = GLUT_LEFT_BUTTON; + if (win) { + if (win && state == GLUT_DOWN) { + win->xold = x, win->yold = y; + return; + } + win->phi += (y - win->yold) / (2. * 180.); + win->theta -= (x - win->xold) / (2 * 180.); + glutPostRedisplay( ); + } + break; + case GLUT_RIGHT_BUTTON: + casemouse = GLUT_RIGHT_BUTTON; + if (win) { + if (win && state == GLUT_DOWN) { + win->xold = x, win->yold = y; + return; } - default: - if((debug > 10)) cout << " Key Character " << (int) key << " " << key << endl; - - } - glutPostRedisplay(); + } + break; + } } - - -void SpecialKey(int key, int x, int y) -{ - OneWindow * win=CurrentWin(); - if(win) - { - R dx(0),dy(0); - switch (key) { - case GLUT_KEY_LEFT: dx = -1; break; - case GLUT_KEY_RIGHT: dx = +1; break; - case GLUT_KEY_DOWN: dy = -1; break; - case GLUT_KEY_UP: dy = +1; break; +static void MotionMouse(int x, int y) { + OneWindow *win = CurrentWin( ); + x *= kscreenscale; + y *= kscreenscale; + switch (casemouse) { + case GLUT_LEFT_BUTTON: + + if (win) { + win->phi += (y - win->yold) / (2. * 180.); + win->theta -= (x - win->xold) / (2 * 180.); + win->xold = x; + win->yold = y; + glutPostRedisplay( ); + } + break; + case GLUT_RIGHT_BUTTON: + casemouse = GLUT_RIGHT_BUTTON; + + if (win) { + if (keyact & GLUT_ACTIVE_ALT) { + int dx = (x - win->xold); + int dy = (y - win->yold); + win->MoveXView(dx, -dy); + glutPostRedisplay( ); + { + win->xold = x, win->yold = y; + } + } else { + // zoom en y + R dd = (y - win->yold); + + { + win->xold = x, win->yold = y; + } + win->zoom(pow(0.99, dd)); + glutPostRedisplay( ); } - // calcul du deplacement de xm,ym,zm; - win->MoveXView(dx,dy); - glutPostRedisplay(); - } + } + break; + } } -void LauchNextRead() -{ - if(!NoMorePlot) - { - inThreadRead=true; - tidRead = Thread::Start(&ThreadRead,(void *) datafile); - } +static void Key(unsigned char key, int x, int y) { + x *= kscreenscale; + y *= kscreenscale; + OneWindow *win = CurrentWin( ); + if (!win->theplot) return; + if (debug > 1) cout << "Key winnum: " << win->theplot->winnum << endl; + int ni = win->theplot->Viso.N( ); + int na = win->theplot->Varrow.N( ); + int nbN = win->theplot->nbN; + + win->help = false; + switch (key) { + case 27: // esc char + Fin(0); + break; + case 3: // esc char + Fin(9); + break; + case 'w': + if (win) win->windowdump = true; + break; + case 'l': + win->withlight = !win->withlight; + break; + case '?': + if (win) win->help = true; + break; + case '+': + win->zoom(x, y, 0.7); + win->coef_dist /= 1.2; + break; + case '-': + win->zoom(x, y, 1. / 0.7); + win->coef_dist *= 1.2; + break; + case '3': + win->plotdim = win->plotdim == 2 ? 3 : 2; + break; + case '2': + win->changePlotdim = win->changePlotdim == 0 ? 1 : 0; + break; + case '=': + win->DefaultView(1); + break; + case 'f': + win->theplot->fill = !win->theplot->fill; + break; + case '@': + win->dtheta = win->dtheta ? 0 : pi / 1800.; + break; + case '*': // add FH mars 2013 .. + win->keepPV = !win->keepPV; + if (debug) cout << " ... win->keepPV " << win->keepPV << endl; + break; + case 'k': + if (win->theplot->NextCase( )) { + R fmn, fmx, vmn, vmx; + win->theplot->dyn_bfv(win, fmn, fmx, vmn, vmx); + win->theplot->SetDefIsoV(ni, na, fmn, fmx, vmn, vmx); + win->changeiso = true; + win->changearrow = true; + } + break; + + case 'b': + win->theplot->grey = !win->theplot->grey; + win->changeiso = true; + win->changearrow = true; + + break; + case 'g': + win->theplot->grey = !win->theplot->grey; + win->changeiso = true; + win->changearrow = true; + + break; + + case 'v': + win->theplot->value = !win->theplot->value; + break; + case 'm': + win->theplot->drawmeshes = !win->theplot->drawmeshes; + break; + case 'B': + win->theplot->drawborder = !win->theplot->drawborder; + break; + case 'H': + win->rapz *= 1.2; + break; + case 'h': + win->rapz /= 1.2; + break; + case 'p': + if (win->icurrentPlot != win->lplots.begin( )) win->set(*--win->icurrentPlot); + break; + case 'a': + win->theplot->coeff /= 1.2; + win->changearrow = true; + break; + case 'A': + win->theplot->coeff *= 1.2; + win->changearrow = true; + break; + + case 'n': { + na -= na < 10 ? 2 : 5; + ni -= ni < 10 ? 2 : 5; + na = max(na, 2); + ni = max(ni, 2); + R fmn, fmx, vmn, vmx; + win->theplot->dyn_bfv(win, fmn, fmx, vmn, vmx); + win->theplot->SetDefIsoV(ni, na, fmn, fmx, vmn, vmx); + + win->changeiso = true; + win->changearrow = true; + } break; + case 'N': { + na += na < 10 ? 2 : 5; + ni += ni < 10 ? 2 : 5; + } + case 'i': { + R fmn, fmx, vmn, vmx; + win->theplot->dyn_bfv(win, fmn, fmx, vmn, vmx); + win->theplot->SetDefIsoV(ni, na, fmn, fmx, vmn, vmx); + + win->changeiso = true; + win->changearrow = true; + } break; + case 'I': { + R fmn, fmx, vmn, vmx; + win->theplot->SetDefIsoV(ni, na); + win->changeiso = true; + win->changearrow = true; + } break; + case 'z': + if (win->focal < my_pi / 1.2) { + win->coef_dist *= sin(win->focal * 1.2 / 2) / sin(win->focal / 2); + win->focal *= 1.2; + } + break; + case 'Z': + if (win->focal > 1e-5) { + win->coef_dist *= sin(win->focal / 1.2 / 2) / sin(win->focal / 2); + win->focal /= 1.2; + } + break; + case '\r': + case '\n': { + list< ThePlot * >::iterator ic = win->icurrentPlot; + if (++ic == win->lplots.end( )) // last plot -> try new one + SendForNextPlot( ); + else + win->set(*++win->icurrentPlot); + break; + } + case 'T': + win->theplot->pNormalT = !win->theplot->pNormalT; + break; + case 'Q': { + win->theplot->nbN /= win->theplot->nbN < 0 ? 0 : 2; + break; + } + case 'q': { + win->theplot->nbN *= win->theplot->nbN < 0 ? 0 : 2; + break; + } + default: + if ((debug > 10)) cout << " Key Character " << (int)key << " " << key << endl; + } + glutPostRedisplay( ); +} + +void SpecialKey(int key, int x, int y) { + OneWindow *win = CurrentWin( ); + if (win) { + R dx(0), dy(0); + switch (key) { + case GLUT_KEY_LEFT: + dx = -1; + break; + case GLUT_KEY_RIGHT: + dx = +1; + break; + case GLUT_KEY_DOWN: + dy = -1; + break; + case GLUT_KEY_UP: + dy = +1; + break; + } + // calcul du deplacement de xm,ym,zm; + win->MoveXView(dx, dy); + glutPostRedisplay( ); + } } -void WaitNextRead() -{ - if( inThreadRead ) - { - assert(tidRead!=0); - Thread::Wait(tidRead); - tidRead =0; - inThreadRead=false;; - } +void LauchNextRead( ) { + if (!NoMorePlot) { + inThreadRead = true; + tidRead = Thread::Start(&ThreadRead, (void *)datafile); + } } -THREADFUNC(ThreadRead,fd) -{ - int err=0; - assert(nextPlot==0); - if(gwait) usleep((useconds_t) (gwait*1.e6) ); - err=ReadOnePlot((FILE*)fd); - if(debug>1) - cout << " We Read a plot : " << kread << " " << nextPlot << " " << err << endl; - if(err<0) - { - NoMorePlot=true; - - } - Thread::Exit(); - return 0; +void WaitNextRead( ) { + if (inThreadRead) { + assert(tidRead != 0); + Thread::Wait(tidRead); + tidRead = 0; + inThreadRead = false; + ; + } } +THREADFUNC(ThreadRead, fd) { + int err = 0; + assert(nextPlot == 0); + if (gwait) usleep((useconds_t)(gwait * 1.e6)); + err = ReadOnePlot((FILE *)fd); + if (debug > 1) cout << " We Read a plot : " << kread << " " << nextPlot << " " << err << endl; + if (err < 0) { + NoMorePlot = true; + } + Thread::Exit( ); + return 0; +} + +static bool TryNewPlot(void) { + // the routine to try to see if the next plot is read or not. + // ----------------------------------------------------------- + bool ret = false; + if (debug > 2) cout << " TryNewPlot plot : " << currentPlot << " next = " << nextPlot << endl; + ; + if (nextPlot != 0) { + + WaitNextRead( ); + int iwnp = nextPlot->winnum; + if (debug > 1) cout << " change current plot to: " << nextPlot << " et Lock Plot . winnum " << iwnp << endl; + ; + if (Num2Windows[iwnp] == 0) { + ostringstream titre; + titre << "W " << iwnp << " /FreeFem++: type return key to proceed (or ? for help on other)"; + int Height = 512; + int Width = 512 * 3 / 2; + + glutInitWindowSize(Width, Height); + glutInitWindowPosition(100 + iwnp * 50, 100 + iwnp * 50); + int iw0 = glutCreateWindow(titre.str( ).c_str( )); + if (debug > 1) cout << " ** glutCreateWindow " << iw0 << endl; + glDisable(GL_DEPTH_TEST); + glutReshapeFunc(Reshape); // pour changement de fenetre + glutKeyboardFunc(Key); // pour les evenements clavier + glutSpecialFunc(SpecialKey); + glutMouseFunc(Mouse); // pour les evenements sourie + glutMotionFunc(MotionMouse); // les mouvements de la sourie + glutDisplayFunc(Display); // l'affichage + glutPushWindow( ); + glutShowWindow( ); + AllWindows[iw0] = new OneWindow(Width + 1, Height + 1, nextPlot); + Num2Windows[iwnp] = iw0; + } else + AllWindows[Num2Windows[iwnp]]->add(nextPlot); + glutSetWindow(Num2Windows[iwnp]); + currentPlot = nextPlot; + nextPlot = 0; + LauchNextRead( ); + ret = true; + } + if (gwait && NoMorePlot) { + usleep((useconds_t)(1e6 * gwait)); + Fin(0); + } -static bool TryNewPlot( void ) -{ - // the routine to try to see if the next plot is read or not. - // ----------------------------------------------------------- - bool ret=false; - if(debug>2) - cout << " TryNewPlot plot : " << currentPlot << " next = " << nextPlot << endl;; - if (nextPlot!=0) - { - - WaitNextRead(); - int iwnp= nextPlot-> winnum; - if(debug>1) cout << " change current plot to: " << nextPlot << " et Lock Plot . winnum " << iwnp << endl;; - if(Num2Windows[iwnp]==0) - { - ostringstream titre; - titre << "W "<< iwnp << " /FreeFem++: type return key to proceed (or ? for help on other)"; - int Height = 512; - int Width = 512*3/2; - - glutInitWindowSize(Width , Height); - glutInitWindowPosition(100+iwnp*50, 100+iwnp*50); - int iw0=glutCreateWindow(titre.str().c_str()); - if(debug>1) cout << " ** glutCreateWindow " << iw0 << endl; - glDisable(GL_DEPTH_TEST); - glutReshapeFunc( Reshape ); // pour changement de fenetre - glutKeyboardFunc( Key ); // pour les evenements clavier - glutSpecialFunc(SpecialKey); - glutMouseFunc(Mouse); // pour les evenements sourie - glutMotionFunc(MotionMouse); // les mouvements de la sourie - glutDisplayFunc( Display ); // l'affichage - glutPushWindow(); - glutShowWindow(); - AllWindows[iw0]= new OneWindow(Width+1 , Height+1,nextPlot); - Num2Windows[iwnp]=iw0; - } - else - AllWindows[Num2Windows[iwnp]]->add(nextPlot); - glutSetWindow(Num2Windows[iwnp]); - currentPlot=nextPlot; - nextPlot=0; - LauchNextRead(); - ret=true; - } - if(gwait && NoMorePlot ) - {usleep((useconds_t)(1e6*gwait)); Fin(0); } - - return ret; -} -const char * Index(const char * p, const char c) -{ - int k=0; - while(k++<1000000) - if(!*p) return 0; - else if( *p==c) return p; - else ++p; - return 0; -} -const char * rIndex(const char * p, const char c) -{ - int k=0; - const char *pp=0; - while(k++<1000000) - if(!*p) break; - else if( *p==c) pp= p; - else ++p; - return pp; -} -void SetDefWin(const char *p,int & iii0,int & jjj0,int & Width,int &Height) -{ - // syntax - // 1024x1024+100+100 - // or - // 1024x1024 - const char *bx = p; - const char *by = Index(p,'x'); - const char *ox = Index(p,'+'); - const char *oy = rIndex(p,'+'); - if(by ==0) return; - Width= atoi(bx); - Height= atoi(by+1); - if(ox && (ox != oy)) - { - iii0= atoi(ox+1); - jjj0=atoi(oy+1); - } - if(debug>1) - cout << " position = "<< Width << "x" << Height << "+"<< iii0 << "+" << jjj0 << endl; - assert(Width >0 && Width < 3000); - assert(Height >0 && Height < 3000); - assert(iii0 >0 && iii0 < 3000); - assert(jjj0 >0 && jjj0 < 3000); - + return ret; } -int main(int argc, char** argv) -{ - lockOrientation=0;// to get bad mesh !! FH mai 2021 - ffapi::init(); - glutInit(&argc, argv); - bool stereo=false; - bool fullscreen = false; - - if(stereo) - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO); +const char *Index(const char *p, const char c) { + int k = 0; + while (k++ < 1000000) + if (!*p) + return 0; + else if (*p == c) + return p; else - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); - int i1=1; - int W = glutGet(GLUT_SCREEN_WIDTH); - int H = glutGet(GLUT_SCREEN_HEIGHT); + ++p; + return 0; +} +const char *rIndex(const char *p, const char c) { + int k = 0; + const char *pp = 0; + while (k++ < 1000000) + if (!*p) + break; + else if (*p == c) + pp = p; + else + ++p; + return pp; +} +void SetDefWin(const char *p, int &iii0, int &jjj0, int &Width, int &Height) { + // syntax + // 1024x1024+100+100 + // or + // 1024x1024 + const char *bx = p; + const char *by = Index(p, 'x'); + const char *ox = Index(p, '+'); + const char *oy = rIndex(p, '+'); + if (by == 0) return; + Width = atoi(bx); + Height = atoi(by + 1); + if (ox && (ox != oy)) { + iii0 = atoi(ox + 1); + jjj0 = atoi(oy + 1); + } + if (debug > 1) cout << " position = " << Width << "x" << Height << "+" << iii0 << "+" << jjj0 << endl; + assert(Width > 0 && Width < 3000); + assert(Height > 0 && Height < 3000); + assert(iii0 > 0 && iii0 < 3000); + assert(jjj0 > 0 && jjj0 < 3000); +} +int main(int argc, char **argv) { + lockOrientation = 0; // to get bad mesh !! FH mai 2021 + ffapi::init( ); + glutInit(&argc, argv); + bool stereo = false; + bool fullscreen = false; + + if (stereo) + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO); + else + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + int i1 = 1; + int W = glutGet(GLUT_SCREEN_WIDTH); + int H = glutGet(GLUT_SCREEN_HEIGHT); + glutscreenscale = 1; +#ifdef GLUT_WINDOW_SCALE + glutscreenscale = glutGet(GLUT_WINDOW_SCALE); + if (glutscreenscale < 0) // unsupported by original GLUT glutscreenscale = 1; - #ifdef GLUT_WINDOW_SCALE - glutscreenscale= glutGet(GLUT_WINDOW_SCALE); - if(glutscreenscale < 0) // unsupported by original GLUT - glutscreenscale = 1; #endif - int Height = glutscreenscale*2*H/3,Width = glutscreenscale*W*2/3, iii0=100,jjj0=100; - - string titre = "W0/FreeFem++: type return key to proceed (or ? for help on other)"; - int eerr=0; - if(argc>1) - { - if( (i1 < argc) &&strcmp(argv[i1],"-?")==0) i1++,eerr=-1; - if (i1 < argc) - { - if( strcmp(argv[i1],"-nv")==0) i1++,debug=0; - else if( strcmp(argv[i1],"-v")==0) i1++,debug=2,verbosity=2; - else if( strcmp(argv[i1],"-vv")==0) i1++,debug=5,verbosity=2; - else if( strcmp(argv[i1],"-vvv")==0) i1++,debug=10, verbosity=1000; - else if( strcmp(argv[i1],"-vvvv")==0) i1++,debug=99999, verbosity=1000; - else if( strcmp(argv[i1],"-0")==0) return 0; // do nothing - } - if( (i1+1 < argc) && (strcmp(argv[i1],"-wait")==0)) { i1++; gwait=atof(argv[i1++]); } - if( (i1+1 < argc) && (strcmp(argv[i1],"-g")==0)) { - i1++; - SetDefWin(argv[i1++], iii0,jjj0,Width,Height); - } - if( (i1+1 < argc) && (strcmp(argv[i1],"-t")==0)) { - i1++; - titre = argv[i1++]; - } - if( (i1 - argc > 1) ) - { - eerr = 1; - cout << " error ming args " << i1 - argc << endl; - } - } - if(debug>1) - { - cout << " glutscreenscale " << glutscreenscale << " " << Width << " " << Height << " " << W << " " << H << endl; - } - datafile =0; - if(debug>1) - cout << "ffglut : " << (argc>i1) << eerr << endl; - if(argc>i1 && (eerr==0)) - { - datafile=fopen(argv[argc-1], "r"); - if(debug >1) - cout << " fopen :" << argv[argc-1] << " " <1) - cout << " mode read = " << MODE_READ_BINARY << endl; - if(datafile==0) - datafile=stdin; - if ( !datafile){ - cerr<< " Erreur fdopen stdin in binary " << endl; - Fin(1); + int Height = glutscreenscale * 2 * H / 3, Width = glutscreenscale * W * 2 / 3, iii0 = 100, jjj0 = 100; + + string titre = "W0/FreeFem++: type return key to proceed (or ? for help on other)"; + int eerr = 0; + if (argc > 1) { + if ((i1 < argc) && strcmp(argv[i1], "-?") == 0) i1++, eerr = -1; + if (i1 < argc) { + if (strcmp(argv[i1], "-nv") == 0) + i1++, debug = 0; + else if (strcmp(argv[i1], "-v") == 0) + i1++, debug = 2, verbosity = 2; + else if (strcmp(argv[i1], "-vv") == 0) + i1++, debug = 5, verbosity = 2; + else if (strcmp(argv[i1], "-vvv") == 0) + i1++, debug = 10, verbosity = 1000; + else if (strcmp(argv[i1], "-vvvv") == 0) + i1++, debug = 99999, verbosity = 1000; + else if (strcmp(argv[i1], "-0") == 0) + return 0; // do nothing + } + if ((i1 + 1 < argc) && (strcmp(argv[i1], "-wait") == 0)) { + i1++; + gwait = atof(argv[i1++]); + } + if ((i1 + 1 < argc) && (strcmp(argv[i1], "-g") == 0)) { + i1++; + SetDefWin(argv[i1++], iii0, jjj0, Width, Height); + } + if ((i1 + 1 < argc) && (strcmp(argv[i1], "-t") == 0)) { + i1++; + titre = argv[i1++]; + } + if ((i1 - argc > 1)) { + eerr = 1; + cout << " error ming args " << i1 - argc << endl; } - int err=ReadOnePlot(datafile); - if(err) { - Fin(1);} - - + } + if (debug > 1) { + cout << " glutscreenscale " << glutscreenscale << " " << Width << " " << Height << " " << W << " " << H << endl; + } + datafile = 0; + if (debug > 1) cout << "ffglut : " << (argc > i1) << eerr << endl; + if (argc > i1 && (eerr == 0)) { + datafile = fopen(argv[argc - 1], "r"); + if (debug > 1) cout << " fopen :" << argv[argc - 1] << " " << datafile << endl; + if (datafile == 0) eerr = 100; + } + if (eerr) { + cerr << " Erreur ffglut [-nv|-v|-vv|-vvv] [-wait 0.5] [-g 512x300+10+10] [-t title] [file]" << endl; + cerr << " err number " << eerr << endl; + abort( ); + } - if(kread==0) { - Fin(1); - } - if(debug>1) - cout << "on a lue le premier plot next plot: " << nextPlot << endl; - - - - glutInitWindowSize((Width+1) , (Height+1)); - glutInitWindowPosition(iii0*glutscreenscale,jjj0*glutscreenscale); - - int iw0=glutCreateWindow(titre.c_str()); - GLint pView[4]; - glGetIntegerv(GL_VIEWPORT, pView); - // hack to correct bug in Catalina , incompatibility Width and pView (glutscreenscale???) - kscreenscale = (double) ( pView[2]- pView[0])/ (double) (Width+1) ; - if (kscreenscale < 0.1) kscreenscale= 1; - if(kscreenscale > 10.) kscreenscale=1; - if( debug>1 ) - cout << "pView " << pView[0]<< " "<< pView[1]<< " "<< pView[2]<< " "<< pView[3]<< " kscreenscale= " << kscreenscale << endl; - - Num2Windows[0]=iw0; - glDisable(GL_DEPTH_TEST); - glutReshapeFunc( Reshape ); // pour changement de fenetre - glutKeyboardFunc( Key ); // pour les evenements clavier - glutSpecialFunc(SpecialKey); - glutMouseFunc(Mouse); // pour les evenements sourie - glutMotionFunc(MotionMouse); // les mouvements de la sourie - glutDisplayFunc( Display ); // l'affichage - glutSetWindow(iw0); - AllWindows[iw0]=new OneWindow(Width+1 , Height+1 ,currentPlot); - TryNewPlot(); - glutMainLoop(); + if (debug > 1) cout << " mode read = " << MODE_READ_BINARY << endl; + if (datafile == 0) datafile = stdin; + if (!datafile) { + cerr << " Erreur fdopen stdin in binary " << endl; + Fin(1); + } + int err = ReadOnePlot(datafile); + if (err) { + Fin(1); + } - return 0; + if (kread == 0) { + Fin(1); + } + if (debug > 1) cout << "on a lue le premier plot next plot: " << nextPlot << endl; + + glutInitWindowSize((Width + 1), (Height + 1)); + glutInitWindowPosition(iii0 * glutscreenscale, jjj0 * glutscreenscale); + + int iw0 = glutCreateWindow(titre.c_str( )); + GLint pView[4]; + glGetIntegerv(GL_VIEWPORT, pView); + // hack to correct bug in Catalina , incompatibility Width and pView (glutscreenscale???) + kscreenscale = (double)(pView[2] - pView[0]) / (double)(Width + 1); + if (kscreenscale < 0.1) kscreenscale = 1; + if (kscreenscale > 10.) kscreenscale = 1; + if (debug > 1) cout << "pView " << pView[0] << " " << pView[1] << " " << pView[2] << " " << pView[3] << " kscreenscale= " << kscreenscale << endl; + + Num2Windows[0] = iw0; + glDisable(GL_DEPTH_TEST); + glutReshapeFunc(Reshape); // pour changement de fenetre + glutKeyboardFunc(Key); // pour les evenements clavier + glutSpecialFunc(SpecialKey); + glutMouseFunc(Mouse); // pour les evenements sourie + glutMotionFunc(MotionMouse); // les mouvements de la sourie + glutDisplayFunc(Display); // l'affichage + glutSetWindow(iw0); + AllWindows[iw0] = new OneWindow(Width + 1, Height + 1, currentPlot); + TryNewPlot( ); + glutMainLoop( ); + + return 0; } diff --git a/src/Graphics/ffglut.hpp b/src/Graphics/ffglut.hpp index b400d7264..444cda017 100644 --- a/src/Graphics/ffglut.hpp +++ b/src/Graphics/ffglut.hpp @@ -7,535 +7,486 @@ * */ #include -typedef std::complex Complex; +typedef std::complex< double > Complex; extern int debug; -static const double dinfty=numeric_limits::max(); -void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,KN colors); -void hsvToRgb (float h, float s, float v, float & r, float & g, float & b); - +static const double dinfty = numeric_limits< double >::max( ); +void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, KN< R > colors); +void hsvToRgb(float h, float s, float v, float &r, float &g, float &b); class ThePlot; class OneWindow; -struct OnePlot -{ - int dim; - R3 Pmin,Pmax; - double fmin,fmax; - double vmax2; - long what; - GLsizei ngllists; - GLint gllists; - KN oklist; - int setgllists; - virtual void Draw(OneWindow *win) =0; - virtual bool NextCase() {return false;} - void bb(R3 & Pmn,R3 &Pmx) const - { - Pmn=Minc(Pmin,Pmn); - Pmx=Maxc(Pmax,Pmx); - } - - void bfv(R & fmn,R &fmx,R & vmx) const - { - // cout << "\t\t\t\t f min, max v max :" << fmin << " " << fmax << " " << vmax2 << endl; - fmn=Min(fmin,fmn); - fmx=Max(fmax,fmx); - vmx=Max(vmax2,vmx); - } - - virtual void dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn,R & vmx) const - {// compute the function bound and arrow bound view .... - } - - OnePlot(long w,int ddim=2,int nbgllist=0) : - dim(ddim), - Pmin(dinfty,dinfty,dinfty),Pmax(-dinfty,-dinfty,-dinfty), - fmin(dinfty),fmax(-dinfty),vmax2(0), - what(w),ngllists(nbgllist),gllists(0), - oklist(nbgllist),setgllists(0){ - } - - void initlist() - { - if(! setgllists) - if(ngllists>0) - { - oklist=0; // - gllists= glGenLists(ngllists); - setgllists=1; - assert(gllists); - } - } - - void GLDraw(OneWindow *win); - virtual ~OnePlot() { - if(setgllists) glDeleteLists(gllists,ngllists); - }; -private: // pas de copy car il y a des destructeurs dans les classes derives - OnePlot(const OnePlot & ); - OnePlot & operator=(const OnePlot & ); +struct OnePlot { + int dim; + R3 Pmin, Pmax; + double fmin, fmax; + double vmax2; + long what; + GLsizei ngllists; + GLint gllists; + KN< int > oklist; + int setgllists; + virtual void Draw(OneWindow *win) = 0; + virtual bool NextCase( ) { return false; } + void bb(R3 &Pmn, R3 &Pmx) const { + Pmn = Minc(Pmin, Pmn); + Pmx = Maxc(Pmax, Pmx); + } + + void bfv(R &fmn, R &fmx, R &vmx) const { + // cout << "\t\t\t\t f min, max v max :" << fmin << " " << fmax << " " << vmax2 << endl; + fmn = Min(fmin, fmn); + fmx = Max(fmax, fmx); + vmx = Max(vmax2, vmx); + } + + virtual void dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn, R &vmx) const { // compute the function bound and arrow bound view .... + } + + OnePlot(long w, int ddim = 2, int nbgllist = 0) + : dim(ddim), Pmin(dinfty, dinfty, dinfty), Pmax(-dinfty, -dinfty, -dinfty), fmin(dinfty), fmax(-dinfty), vmax2(0), what(w), ngllists(nbgllist), gllists(0), oklist(nbgllist), setgllists(0) {} + + void initlist( ) { + if (!setgllists) + if (ngllists > 0) { + oklist = 0; // + gllists = glGenLists(ngllists); + setgllists = 1; + assert(gllists); + } + } + + void GLDraw(OneWindow *win); + virtual ~OnePlot( ) { + if (setgllists) glDeleteLists(gllists, ngllists); + }; + + private: // pas de copy car il y a des destructeurs dans les classes derives + OnePlot(const OnePlot &); + OnePlot &operator=(const OnePlot &); }; -template -struct OnePlotMesh : public OnePlot -{ - const Mesh *Th; - OnePlotMesh(const Mesh *T) - : OnePlot(0,2,3),Th(T) - { - R2 P0,P1; - Th->BoundingBox(P0,P1); - Pmin=P0; - Pmax=P1; - } - void Draw(OneWindow *win); - +template< class Mesh > +struct OnePlotMesh : public OnePlot { + const Mesh *Th; + OnePlotMesh(const Mesh *T) : OnePlot(0, 2, 3), Th(T) { + R2 P0, P1; + Th->BoundingBox(P0, P1); + Pmin = P0; + Pmax = P1; + } + void Draw(OneWindow *win); }; -struct OnePlotMesh3 : public OnePlot -{ - const Mesh3 *Th; - OnePlotMesh3(const Mesh3 *T) - : OnePlot(0,3,3),Th(T) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - //Th->BoundingBox(Pmin,Pmax); - } - void Draw(OneWindow *win); +struct OnePlotMesh3 : public OnePlot { + const Mesh3 *Th; + OnePlotMesh3(const Mesh3 *T) : OnePlot(0, 3, 3), Th(T) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + // Th->BoundingBox(Pmin,Pmax); + } + void Draw(OneWindow *win); }; -struct OnePlotMeshS : public OnePlot -{ - const MeshS *Th; - OnePlotMeshS(const MeshS *T) - : OnePlot(0,3,3),Th(T) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - //Th->BoundingBox(Pmin,Pmax); - } - void Draw(OneWindow *win); +struct OnePlotMeshS : public OnePlot { + const MeshS *Th; + OnePlotMeshS(const MeshS *T) : OnePlot(0, 3, 3), Th(T) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + // Th->BoundingBox(Pmin,Pmax); + } + void Draw(OneWindow *win); }; -struct OnePlotMeshL : public OnePlot -{ - const MeshL *Th; - OnePlotMeshL(const MeshL *T) - : OnePlot(0,3,3),Th(T) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - //Th->BoundingBox(Pmin,Pmax); - } - void Draw(OneWindow *win); +struct OnePlotMeshL : public OnePlot { + const MeshL *Th; + OnePlotMeshL(const MeshL *T) : OnePlot(0, 3, 3), Th(T) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + // Th->BoundingBox(Pmin,Pmax); + } + void Draw(OneWindow *win); }; -template -struct OnePlotFE: public OnePlot -{ - const Mesh *Th; - // long nsub; - KN v; - KN vc; - KN Psub; - KN Ksub; - int cas; // in cas of complex chaage interpertation of complex value - OnePlotFE(const Mesh *T,long w,PlotStream & f); - void Draw(OneWindow *win); - void dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn,R & vmx) const ; - bool vc2v(); - bool NextCase() { cas++; return vc2v();} +template< class Mesh > +struct OnePlotFE : public OnePlot { + const Mesh *Th; + // long nsub; + KN< double > v; + KN< Complex > vc; + KN< R2 > Psub; + KN< int > Ksub; + int cas; // in cas of complex chaage interpertation of complex value + OnePlotFE(const Mesh *T, long w, PlotStream &f); + void Draw(OneWindow *win); + void dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn, R &vmx) const; + bool vc2v( ); + bool NextCase( ) { + cas++; + return vc2v( ); + } }; -struct OnePlotFE3: public OnePlot -{ - const Mesh3 *Th; - long nsub; - KN v; - KN vc; - KN Psub; - KN Ksub; - int cas; // in cas of complex chaage interpertation of complex value - - OnePlotFE3(const Mesh3 *T,long w,PlotStream & f) - :OnePlot(w,3,5),Th(T),cas(2) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - - f >> Psub ; - f >> Ksub ; - if(what<10) - f >> v; - else - f >> vc; - vc2v(); - if(debug>3) cout << "OnePlotFE3" << Th <<" " << what<< " " << nsub <<" " << v.N() << endl - << " Pmin " << Pmin << " Pmax " << Pmax << endl; - ffassert(f.good()); - - } - void Draw(OneWindow *win); - bool vc2v(); - bool NextCase() { cas++; return vc2v();} +struct OnePlotFE3 : public OnePlot { + const Mesh3 *Th; + long nsub; + KN< double > v; + KN< Complex > vc; + KN< R3 > Psub; + KN< int > Ksub; + int cas; // in cas of complex chaage interpertation of complex value + + OnePlotFE3(const Mesh3 *T, long w, PlotStream &f) : OnePlot(w, 3, 5), Th(T), cas(2) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + + f >> Psub; + f >> Ksub; + if (what < 10) + f >> v; + else + f >> vc; + vc2v( ); + if (debug > 3) cout << "OnePlotFE3" << Th << " " << what << " " << nsub << " " << v.N( ) << endl << " Pmin " << Pmin << " Pmax " << Pmax << endl; + ffassert(f.good( )); + } + void Draw(OneWindow *win); + bool vc2v( ); + bool NextCase( ) { + cas++; + return vc2v( ); + } }; - -struct OnePlotFES: public OnePlot -{ - const MeshS *Th; - long nsub; - KN v; - KN vc; - KN Psub; - KN Ksub; - int cas; // in cas of complex chaage interpertation of complex value - - OnePlotFES(const MeshS *T,long w,PlotStream & f) - :OnePlot(w,3,5),Th(T),cas(2) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - - f >> Psub ; - f >> Ksub ; - if(what<10) - f >> v; - else - f >> vc; - vc2v(); - if(debug>3) cout << "OnePlotFES :" << Th <<" " << what<< " " << nsub <<" " << v.N() << endl - << " Pmin " << Pmin << " Pmax " << Pmax << endl; - ffassert(f.good()); - - } - void Draw(OneWindow *win); - bool vc2v(); - bool NextCase() { cas++; return vc2v();} +struct OnePlotFES : public OnePlot { + const MeshS *Th; + long nsub; + KN< double > v; + KN< Complex > vc; + KN< R2 > Psub; + KN< int > Ksub; + int cas; // in cas of complex chaage interpertation of complex value + + OnePlotFES(const MeshS *T, long w, PlotStream &f) : OnePlot(w, 3, 5), Th(T), cas(2) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + + f >> Psub; + f >> Ksub; + if (what < 10) + f >> v; + else + f >> vc; + vc2v( ); + if (debug > 3) cout << "OnePlotFES :" << Th << " " << what << " " << nsub << " " << v.N( ) << endl << " Pmin " << Pmin << " Pmax " << Pmax << endl; + ffassert(f.good( )); + } + void Draw(OneWindow *win); + bool vc2v( ); + bool NextCase( ) { + cas++; + return vc2v( ); + } }; -struct OnePlotFEL: public OnePlot -{ - const MeshL *Th; - long nsub; - KN v; - KN vc; - KN Psub; - KN Ksub; - int cas; // in cas of complex chaage interpertation of complex value - - OnePlotFEL(const MeshL *T,long w,PlotStream & f) - :OnePlot(w,3,5),Th(T),cas(2) - { - Pmin=Th->Pmin; - Pmax=Th->Pmax; - - f >> Psub ; - f >> Ksub ; - if(what<16) - f >> v; - else - f >> vc; - vc2v(); - if(debug>3) cout << "OnePlotFEL :" << Th <<" " << what<< " " << nsub <<" " << v.N() << endl - << " Pmin " << Pmin << " Pmax " << Pmax << endl; - ffassert(f.good()); - - } - void Draw(OneWindow *win); - bool vc2v(); - bool NextCase() { cas++; return vc2v();} +struct OnePlotFEL : public OnePlot { + const MeshL *Th; + long nsub; + KN< double > v; + KN< Complex > vc; + KN< R1 > Psub; + KN< int > Ksub; + int cas; // in cas of complex chaage interpertation of complex value + + OnePlotFEL(const MeshL *T, long w, PlotStream &f) : OnePlot(w, 3, 5), Th(T), cas(2) { + Pmin = Th->Pmin; + Pmax = Th->Pmax; + + f >> Psub; + f >> Ksub; + if (what < 16) + f >> v; + else + f >> vc; + vc2v( ); + if (debug > 3) cout << "OnePlotFEL :" << Th << " " << what << " " << nsub << " " << v.N( ) << endl << " Pmin " << Pmin << " Pmax " << Pmax << endl; + ffassert(f.good( )); + } + void Draw(OneWindow *win); + bool vc2v( ); + bool NextCase( ) { + cas++; + return vc2v( ); + } }; -struct OnePlotCurve: public OnePlot { - KN xx,yy,zz,cc; - int cas; - OnePlotCurve(PlotStream & f,int nfield=2,ThePlot *theplot=0); - void Draw(OneWindow *win); - void dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn2,R & vmx2) const; - bool NextCase() { cas++; return false;} +struct OnePlotCurve : public OnePlot { + KN< double > xx, yy, zz, cc; + int cas; + OnePlotCurve(PlotStream &f, int nfield = 2, ThePlot *theplot = 0); + void Draw(OneWindow *win); + void dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn2, R &vmx2) const; + bool NextCase( ) { + cas++; + return false; + } }; -struct OnePlotBorder: public OnePlot { - vector > > data; - OnePlotBorder(PlotStream & f); - void Draw(OneWindow *win); +struct OnePlotBorder : public OnePlot { + vector< vector< pair< long, R3 > > > data; + OnePlotBorder(PlotStream &f); + void Draw(OneWindow *win); }; +struct OnePlotHMatrix : public OnePlot { + int si; + int sj; + long nbdense; + long nblr; + std::vector< std::pair< int, int > > offsetsdense; + std::vector< std::pair< int, int > > sizesdense; + std::vector< std::pair< int, int > > offsetslr; + std::vector< std::pair< int, int > > sizeslr; + std::vector< int > rankslr; + std::vector< double > compression; + + OnePlotHMatrix(long w, PlotStream &f) : OnePlot(w) { + // dim = 2; + Pmin = R3(0, 0, 0); + Pmax = R3(1, 1, 0); + + int offseti, offsetj; + int sizei, sizej; + int rank; + + f >> si; + f >> sj; + f >> nbdense; + f >> nblr; + + offsetsdense.resize(nbdense); + sizesdense.resize(nbdense); + offsetslr.resize(nblr); + sizeslr.resize(nblr); + rankslr.resize(nblr); + compression.resize(nblr); + + for (int i = 0; i < nbdense; i++) { + f >> offseti; + f >> offsetj; + f >> sizei; + f >> sizej; + offsetsdense[i] = std::pair< int, int >(offseti, offsetj); + sizesdense[i] = std::pair< int, int >(sizei, sizej); + } -struct OnePlotHMatrix: public OnePlot -{ - int si; - int sj; - long nbdense; - long nblr; - std::vector> offsetsdense; - std::vector> sizesdense; - std::vector> offsetslr; - std::vector> sizeslr; - std::vector rankslr; - std::vector compression; - - OnePlotHMatrix(long w, PlotStream & f) - :OnePlot(w) - { - //dim = 2; - Pmin = R3(0,0,0); - Pmax = R3(1,1,0); - - int offseti, offsetj; - int sizei, sizej; - int rank; - - f >> si; - f >> sj; - f >> nbdense; - f >> nblr; - - offsetsdense.resize(nbdense); - sizesdense.resize(nbdense); - offsetslr.resize(nblr); - sizeslr.resize(nblr); - rankslr.resize(nblr); - compression.resize(nblr); - - for (int i=0;i> offseti; - f >> offsetj; - f >> sizei; - f >> sizej; - offsetsdense[i] = std::pair(offseti,offsetj); - sizesdense[i] = std::pair(sizei,sizej); - } - - for (int i=0;i> offseti; - f >> offsetj; - f >> sizei; - f >> sizej; - f >> rankslr[i]; - f >> compression[i]; - offsetslr[i] = std::pair(offseti,offsetj); - sizeslr[i] = std::pair(sizei,sizej); - } - - ffassert(f.good()); + for (int i = 0; i < nblr; i++) { + f >> offseti; + f >> offsetj; + f >> sizei; + f >> sizej; + f >> rankslr[i]; + f >> compression[i]; + offsetslr[i] = std::pair< int, int >(offseti, offsetj); + sizeslr[i] = std::pair< int, int >(sizei, sizej); } - void Draw(OneWindow *win); + + ffassert(f.good( )); + } + void Draw(OneWindow *win); }; // add 11/12/2008 for gestion of error FH (what -1) -struct OnePlotError: public OnePlot { - long item; - OnePlotError(PlotStream & f) - : OnePlot(-1) - { f >> item; - } - void Draw(OneWindow *win) ; - +struct OnePlotError : public OnePlot { + long item; + OnePlotError(PlotStream &f) : OnePlot(-1) { f >> item; } + void Draw(OneWindow *win); }; - - -class ThePlot -{ -public: - int count; - int state; // 0 new - GLint gllist; - KN colors; - bool hsv; // hsv type - KN boundingbox; - double coeff; - bool wait; - bool value; - bool fill; - bool aspectratio; - bool clean; - bool uaspectratio; - bool pViso,pVarrow; - bool withiso; - bool witharrow; - - long Niso,Narrow; - R3 Pmin,Pmax,PminT,PmaxT;// with R -> true bound - R fmin,fmax,fminT,fmaxT; // with bound with previous plot. - R vmax2; - KN Viso,Varrow; - int nbN; // intensity for plotting surface normal - bool bw; - string * psfile; - string * cm; - - bool grey; - bool greyo; - bool drawborder; - bool drawmeshes; - bool add,keepPV,pNormalT; - int periodNormalT; - double echelle; - double ArrowSize; - vector Ths; - vector Ths2; - vector Ths3; - vector ThsS; - vector ThsL; - list plots; - bool changeViso,changeVarrow,changeColor,changeBorder,changeFill; - R3 Pvue,Peyes; - R alpha; - R coefr; - R z0; // z pour les objets 2d. - R ZScale; - // for 3d plot jan 2009 - int plotdim; - bool blockwin, plotNormalT, changePlotdim; - R theta, phi, dcoef, focal; - int datadim; - // 2D - long winnum; - bool NextCase(); - - bool Change() const { return changeViso||changeVarrow||changeColor||changeBorder||changeFill;} - ~ThePlot() - { - for (list::iterator i= plots.begin();i != plots.end(); ++i) - if(*i) delete *i; - for (vector::iterator i= Ths.begin();i != Ths.end(); ++i) - if(*i) delete *i; - for (vector::iterator i= Ths2.begin();i != Ths2.end(); ++i) - if(*i) delete *i; - for (vector::iterator i= Ths3.begin();i != Ths3.end(); ++i) - if(*i) delete *i; - for (vector::iterator i= ThsS.begin();i != ThsS.end(); ++i) - if(*i) delete *i; - for (vector::iterator i= ThsL.begin();i != ThsL.end(); ++i) - if(*i) delete *i; - +class ThePlot { + public: + int count; + int state; // 0 new + GLint gllist; + KN< R > colors; + bool hsv; // hsv type + KN< R > boundingbox; + double coeff; + bool wait; + bool value; + bool fill; + bool aspectratio; + bool clean; + bool uaspectratio; + bool pViso, pVarrow; + bool withiso; + bool witharrow; + + long Niso, Narrow; + R3 Pmin, Pmax, PminT, PmaxT; // with R -> true bound + R fmin, fmax, fminT, fmaxT; // with bound with previous plot. + R vmax2; + KN< R > Viso, Varrow; + int nbN; // intensity for plotting surface normal + bool bw; + string *psfile; + string *cm; + + bool grey; + bool greyo; + bool drawborder; + bool drawmeshes; + bool add, keepPV, pNormalT; + int periodNormalT; + double echelle; + double ArrowSize; + vector< Mesh * > Ths; + vector< Mesh2 * > Ths2; + vector< Mesh3 * > Ths3; + vector< MeshS * > ThsS; + vector< MeshL * > ThsL; + list< OnePlot * > plots; + bool changeViso, changeVarrow, changeColor, changeBorder, changeFill; + R3 Pvue, Peyes; + R alpha; + R coefr; + R z0; // z pour les objets 2d. + R ZScale; + // for 3d plot jan 2009 + int plotdim; + bool blockwin, plotNormalT, changePlotdim; + R theta, phi, dcoef, focal; + int datadim; + // 2D + long winnum; + bool NextCase( ); + + bool Change( ) const { return changeViso || changeVarrow || changeColor || changeBorder || changeFill; } + ~ThePlot( ) { + for (list< OnePlot * >::iterator i = plots.begin( ); i != plots.end( ); ++i) + if (*i) delete *i; + for (vector< Mesh * >::iterator i = Ths.begin( ); i != Ths.end( ); ++i) + if (*i) delete *i; + for (vector< Mesh2 * >::iterator i = Ths2.begin( ); i != Ths2.end( ); ++i) + if (*i) delete *i; + for (vector< Mesh3 * >::iterator i = Ths3.begin( ); i != Ths3.end( ); ++i) + if (*i) delete *i; + for (vector< MeshS * >::iterator i = ThsS.begin( ); i != ThsS.end( ); ++i) + if (*i) delete *i; + for (vector< MeshL * >::iterator i = ThsL.begin( ); i != ThsL.end( ); ++i) + if (*i) delete *i; + } + ThePlot(PlotStream &fin, ThePlot *old, int kcount); + + void Draw(OneWindow *win); + void DrawHelp(OneWindow *win); + + struct RGB { + float r, g, b; + void set(int k, int nb, ThePlot *theplot) { DefColor(r, g, b, k, nb, theplot->hsv, theplot->grey, theplot->colors); } + }; + vector< RGB > tbc; + void color(int i, R alpha = 1.) { + ffassert(tbc.size( )); + RGB c(tbc[min(max(0, i), (const int)tbc.size( ) - 1)]); + if (alpha < 1) { + R a1 = 1. - alpha; + c.r = c.r * alpha + a1; + c.g = c.g * alpha + a1; + c.b = c.b * alpha + a1; + + // cout << " aaaa" << alpha << endl; } - ThePlot(PlotStream & fin,ThePlot *old , int kcount); - - void Draw(OneWindow *win) ; - void DrawHelp(OneWindow *win) ; - - struct RGB { float r,g,b; - void set(int k,int nb,ThePlot *theplot ) - { - DefColor(r,g,b, k,nb,theplot->hsv,theplot->grey,theplot->colors); - } - } ; - vector tbc; - void color(int i,R alpha=1.) { - ffassert(tbc.size()); - RGB c(tbc[min(max(0,i),(const int) tbc.size()-1)]); - if(alpha<1) { - R a1=1.-alpha; - c.r=c.r*alpha+a1; - c.g=c.g*alpha+a1; - c.b=c.b*alpha+a1; - - // cout << " aaaa" << alpha << endl; - } - glColor4f(c.r,c.g,c.b,alpha); - } - void SetColorTable(int nb); - void SetDefIsoV(int niso=0,int narr=0,R fmn=1.,R fmx=-1.,R vmn=1.,R vmx=-1.); - void DrawIsoT(const R2 Pt[3],const R ff[3],const R * Viso,int NbIso, R rapz=1); - void DrawIsoTfill(const R2 Pt[3],const R ff[3],const R * Viso,int NbIso, R rapz=1); - void DrawIsoT(const R3 Pt[3],const R ff[3],const R3 Nt[3],const R * Viso,int NbIso,bool changePlotdim, int viewdim,R rapz=1); - void DrawIsoTfill(const R3 Pt[3],const R ff[3],const R3 Nt[3],const R * Viso,int NbIso,bool changePlotdim,int viewdim, R rapz=1); - void DrawIsoEfill(const R3 Pt[2],const R ff[2],const R3 Nt[2],const R * Viso,int NbIso,bool changePlotdim,int viewdim, R rapz=1); - void dyn_bfv(OneWindow *win,R & fmn,R &fmx,R & vmn,R & vmx) const ; - + glColor4f(c.r, c.g, c.b, alpha); + } + void SetColorTable(int nb); + void SetDefIsoV(int niso = 0, int narr = 0, R fmn = 1., R fmx = -1., R vmn = 1., R vmx = -1.); + void DrawIsoT(const R2 Pt[3], const R ff[3], const R *Viso, int NbIso, R rapz = 1); + void DrawIsoTfill(const R2 Pt[3], const R ff[3], const R *Viso, int NbIso, R rapz = 1); + void DrawIsoT(const R3 Pt[3], const R ff[3], const R3 Nt[3], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz = 1); + void DrawIsoTfill(const R3 Pt[3], const R ff[3], const R3 Nt[3], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz = 1); + void DrawIsoEfill(const R3 Pt[2], const R ff[2], const R3 Nt[2], const R *Viso, int NbIso, bool changePlotdim, int viewdim, R rapz = 1); + void dyn_bfv(OneWindow *win, R &fmn, R &fmx, R &vmn, R &vmx) const; }; class OneWindow { -public: - int countdisplay;// for bug mojave - ThePlot *theplot; - list lplots;// to store some plot - list::iterator icurrentPlot;//=lplots.begin(); - int lplotssize; - - int height,width; - R2 Bmin,Bmax; - R2 oBmin,oBmax;// orign box - R zmin,zmax; - R hpixel;// taille pixel en coordonne x,y,z - int xold,yold; - bool windowdump,help; - - GLdouble modelMatrix[16]; - GLdouble projMatrix[16]; - GLint viewport[4]; - - int plotdim, viewdim; - R theta, phi, coef_dist, focal, dtheta; - R rapz,rapz0; - R3 Bmin3,Bmax3,Pvue3; - R3 cam; - bool withlight; - bool changearrow,changeiso;// to rebuild de graphic list if neccessary - bool keepPV,init,pNormalT,changePlotdim; - //double aspx, aspy, echx,echy,ech,rxmin,rxmax,rymin,rymax; - OneWindow(int h,int w,ThePlot *p); - void DefaultView(int state) ; - bool NextCase() ; - void SetView() ; - void MoveXView(R dx,R dy) ; - void set(ThePlot *p); - void add(ThePlot *p); - void cadre(R2 A,R2 B); - void cadreortho(R2 A,R2 B); - void getcadre(double &xmin,double &xmax,double &ymin,double &ymax); - void Display(); - void resize(int w,int h); - void zoom(int w,int h,R coef); - void zoom(R coef); - float GetHeigthFont(){return 10;} - void color(int i,R alpha=1) {theplot->color(i,alpha);} - void FillRect(R x0,R y0,R x1,R y1); - void PlotValue(const KN_ & Viso,int k0,const char * cmm); - void DrawCommentaire(const char * cm,R x,R y); - void SetScreenView() const ; - void Show(const char *str,int i); - void setLighting(); - void unsetLighting(); - void Seg(R2 A, R2 B) const { - glVertex3d(A.x,A.y,theplot->z0); - glVertex3d(B.x,B.y,theplot->z0); - } - void Seg3(R3 A, R3 B) const { - glVertex3d(A.x,A.y,A.z); - glVertex3d(B.x,B.y,B.z); - } - - int InRecScreen(R2 P1,R2 P2) const - { - R2 Pmn=Minc(P1,P2),Pmx=Maxc(P1,P2); - return (Pmx.x >= Bmin.x) && (Pmn.x <= Bmax.x) && (Pmx.y >= Bmin.y) && (Pmn.y <= Bmax.y); - } - int InRecScreen(R3 P1,R3 P2) const - { - R3 Pmn=Minc(P1,P2),Pmx=Maxc(P1,P2); - return (Pmx.x >= viewport[0]) && (Pmn.x <= viewport[2]) && (Pmx.y >= viewport[1]) && (Pmn.y <= viewport[3]); - } - - + public: + int countdisplay; // for bug mojave + ThePlot *theplot; + list< ThePlot * > lplots; // to store some plot + list< ThePlot * >::iterator icurrentPlot; //=lplots.begin(); + int lplotssize; + + int height, width; + R2 Bmin, Bmax; + R2 oBmin, oBmax; // orign box + R zmin, zmax; + R hpixel; // taille pixel en coordonne x,y,z + int xold, yold; + bool windowdump, help; + + GLdouble modelMatrix[16]; + GLdouble projMatrix[16]; + GLint viewport[4]; + + int plotdim, viewdim; + R theta, phi, coef_dist, focal, dtheta; + R rapz, rapz0; + R3 Bmin3, Bmax3, Pvue3; + R3 cam; + bool withlight; + bool changearrow, changeiso; // to rebuild de graphic list if neccessary + bool keepPV, init, pNormalT, changePlotdim; + // double aspx, aspy, echx,echy,ech,rxmin,rxmax,rymin,rymax; + OneWindow(int h, int w, ThePlot *p); + void DefaultView(int state); + bool NextCase( ); + void SetView( ); + void MoveXView(R dx, R dy); + void set(ThePlot *p); + void add(ThePlot *p); + void cadre(R2 A, R2 B); + void cadreortho(R2 A, R2 B); + void getcadre(double &xmin, double &xmax, double &ymin, double &ymax); + void Display( ); + void resize(int w, int h); + void zoom(int w, int h, R coef); + void zoom(R coef); + float GetHeigthFont( ) { return 10; } + void color(int i, R alpha = 1) { theplot->color(i, alpha); } + void FillRect(R x0, R y0, R x1, R y1); + void PlotValue(const KN_< double > &Viso, int k0, const char *cmm); + void DrawCommentaire(const char *cm, R x, R y); + void SetScreenView( ) const; + void Show(const char *str, int i); + void setLighting( ); + void unsetLighting( ); + void Seg(R2 A, R2 B) const { + glVertex3d(A.x, A.y, theplot->z0); + glVertex3d(B.x, B.y, theplot->z0); + } + void Seg3(R3 A, R3 B) const { + glVertex3d(A.x, A.y, A.z); + glVertex3d(B.x, B.y, B.z); + } + + int InRecScreen(R2 P1, R2 P2) const { + R2 Pmn = Minc(P1, P2), Pmx = Maxc(P1, P2); + return (Pmx.x >= Bmin.x) && (Pmn.x <= Bmax.x) && (Pmx.y >= Bmin.y) && (Pmn.y <= Bmax.y); + } + int InRecScreen(R3 P1, R3 P2) const { + R3 Pmn = Minc(P1, P2), Pmx = Maxc(P1, P2); + return (Pmx.x >= viewport[0]) && (Pmn.x <= viewport[2]) && (Pmx.y >= viewport[1]) && (Pmn.y <= viewport[3]); + } }; -void plot(double x,double y,const char *cmm,int font=-1); -void plot(double x,double y,double i,int fint = -1); +void plot(double x, double y, const char *cmm, int font = -1); +void plot(double x, double y, double i, int fint = -1); -extern map AllWindows; +extern map< int, OneWindow * > AllWindows; -inline OneWindow* CurrentWin() -{ - OneWindow* w= AllWindows[glutGetWindow()]; - ffassert(w); - return w; +inline OneWindow *CurrentWin( ) { + OneWindow *w = AllWindows[glutGetWindow( )]; + ffassert(w); + return w; } - diff --git a/src/Graphics/ffthreads.cpp b/src/Graphics/ffthreads.cpp index 935407cc0..5a5fbd183 100644 --- a/src/Graphics/ffthreads.cpp +++ b/src/Graphics/ffthreads.cpp @@ -1,21 +1,21 @@ // SUMMARY : Threads for Linux and Microsoft Win32 -// USAGE : -// ORG : +// USAGE : +// ORG : // AUTHOR : Antoine Le Hyaric / F. Hecht // E-MAIL : lehyaric@ann.jussieu.fr // This file is part of Freefem++ -// +// // Freefem++ is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. -// +// // Freefem++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public License // along with Freefem++; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -30,7 +30,7 @@ #include using namespace std; -#define ERROR_FF(msg) (cerr << msg< #endif - -Thread::Id Thread::Start(THREADFUNC(f,),Thread::Parm p){ +Thread::Id Thread::Start(THREADFUNC(f, ), Thread::Parm p) { Id tid; #ifdef __MINGW32__ unsigned ThreadId; - tid = (HANDLE) _beginthreadex(NULL,0,f,p,0,&ThreadId); - if(tid == NULL) ERROR_FF("Thread::Start: Thread could not be created"); + tid = (HANDLE)_beginthreadex(NULL, 0, f, p, 0, &ThreadId); + if (tid == NULL) ERROR_FF("Thread::Start: Thread could not be created"); #else - int R = pthread_create(&tid,NULL,f,p); - if(R != 0) ERROR_FF("Thread::Start: Thread could not be created"); + int R = pthread_create(&tid, NULL, f, p); + if (R != 0) ERROR_FF("Thread::Start: Thread could not be created"); #endif return tid; } -void Thread::Wait(Thread::Id tid){ +void Thread::Wait(Thread::Id tid) { #ifdef __MINGW32__ - DWORD R = WaitForSingleObject(tid,INFINITE); - if(R == WAIT_FAILED) ERROR_FF("Thread::Wait" " -- Wait failed"); + DWORD R = WaitForSingleObject(tid, INFINITE); + if (R == WAIT_FAILED) + ERROR_FF( + "Thread::Wait" + " -- Wait failed"); CloseHandle(tid); #else - int R=pthread_join(tid,NULL); - if(R!=0) ERROR_FF("Thread::Wait: Wait failed"); + int R = pthread_join(tid, NULL); + if (R != 0) ERROR_FF("Thread::Wait: Wait failed"); #endif } -void Thread::Exit(){ +void Thread::Exit( ) { #ifdef __MINGW32__ - _endthreadex(0); + _endthreadex(0); #else - pthread_exit(NULL); // No test: returns void. + pthread_exit(NULL); // No test: returns void. #endif } -void Thread::Kill(Thread::Id tid){ +void Thread::Kill(Thread::Id tid) { #ifdef __MINGW32__ - if(TerminateThread(tid,0) == 0) - ERROR_FF("Thread::Kill: Thread not killed"); + if (TerminateThread(tid, 0) == 0) ERROR_FF("Thread::Kill: Thread not killed"); #else - if(pthread_kill(tid,SIGINT)!=0) - ERROR_FF("Thread::Kill: Thread not killed"); + if (pthread_kill(tid, SIGINT) != 0) ERROR_FF("Thread::Kill: Thread not killed"); #endif } -Thread::Id Thread::Current(){ +Thread::Id Thread::Current( ) { #ifdef __MINGW32__ - return GetCurrentThread(); + return GetCurrentThread( ); #else - return pthread_self(); + return pthread_self( ); #endif } diff --git a/src/Graphics/ffthreads.hpp b/src/Graphics/ffthreads.hpp index f74af325f..35a983900 100644 --- a/src/Graphics/ffthreads.hpp +++ b/src/Graphics/ffthreads.hpp @@ -1,21 +1,21 @@ // SUMMARY : Threads for Linux and Microsoft Win32 -// USAGE : -// ORG : +// USAGE : +// ORG : // AUTHOR : Antoine Le Hyaric, Modif F. hecht // E-MAIL : lehyaric@ann.jussieu.fr // This file is part of Freefem++ -// +// // Freefem++ is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. -// +// // Freefem++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public License // along with Freefem++; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -38,28 +38,26 @@ using namespace std; // Just check that we are in a known environment (otherwise it may be // difficult to recognise that the simple cause is an ifdef problem). -class Thread{ -public: - +class Thread { + public: #ifdef __MINGW32__ -#define THREADFUNC(f,parm) unsigned int (__stdcall f)(Thread::Parm parm) +#define THREADFUNC(f, parm) unsigned int(__stdcall f)(Thread::Parm parm) typedef LPVOID Parm; typedef HANDLE Id; #else -#define THREADFUNC(f,parm) void* f(Thread::Parm parm) +#define THREADFUNC(f, parm) void* f(Thread::Parm parm) typedef void* Parm; typedef pthread_t Id; #endif // Mingw is a little puzzled if there are no brackets around // __stdcall - static Id Start(THREADFUNC(f,),Parm p); + static Id Start(THREADFUNC(f, ), Parm p); static void Wait(Id tid); - static void Exit(); // From inside the thread + static void Exit( ); // From inside the thread static void Kill(Id tid); - static Id Current(); + static Id Current( ); }; - -#endif // THREADS_HPP +#endif // THREADS_HPP diff --git a/src/Graphics/getprog-unix.hpp b/src/Graphics/getprog-unix.hpp index 1919e10d0..1982f41cd 100644 --- a/src/Graphics/getprog-unix.hpp +++ b/src/Graphics/getprog-unix.hpp @@ -18,8 +18,8 @@ extern long mpirank; extern long verbosity; -extern int typeofscript; -extern FILE *ThePlotStream; // Add for new plot. FH oct 2008 +extern int typeofscript; +extern FILE *ThePlotStream; // Add for new plot. FH oct 2008 // for the environnement variables ... extern const char *prognamearg; extern const char *edpfilenamearg; @@ -27,7 +27,7 @@ extern bool waitatend; extern bool consoleatend; extern bool echo_edp; extern bool NoGraphicWindow; -extern const char * check_plugin; +extern const char *check_plugin; extern int typeofscript; char *Shell_Space(const char *s); @@ -36,8 +36,10 @@ char *Shell_Space(const char *s) { int nbspace; int i; for (i = 0; i < 100000; ++i) { - if (!s[i]) break; - else if (isspace(s[i])) ++nbspace; + if (!s[i]) + break; + else if (isspace(s[i])) + ++nbspace; } if (!(i < 100000)) { cerr << " Bug Shell_Space routine " << endl; @@ -45,43 +47,45 @@ char *Shell_Space(const char *s) { } #ifdef _WIN32 - char * p = new char[i + 1 + nbspace]; - char * q = p; + char *p = new char[i + 1 + nbspace]; + char *q = p; for (i = 0; i < 100000; ++i) { - if (!s[i]) break; + if (!s[i]) + break; else if (isspace(s[i])) { - *q ++= '^'; - *q ++= s[i]; - } - else *q ++= s[i]; + *q++ = '^'; + *q++ = s[i]; + } else + *q++ = s[i]; } #else char *p = new char[i + nbspace]; char *q = p; for (i = 0; i < 100000; ++i) { - if (!s[i]) break; + if (!s[i]) + break; else if (isspace(s[i])) { - *q ++= '\\'; - *q ++= s[i]; - } - else *q ++= s[i]; + *q++ = '\\'; + *q++ = s[i]; + } else + *q++ = s[i]; } #endif - *q ++= '\0'; + *q++ = '\0'; assert(q - p <= i + nbspace); return p; } -extern void (*init_lgparallele)(); +extern void (*init_lgparallele)( ); extern bool load(string s); // <> called by [[file:../lglib/lg.ypp::getprog]] int getprog(char *fn, int argc, char **argv) { - waitatend = 0; // init_lgparallele==0; // wait if not parallel - consoleatend = false; // bug with redirection FH - typeofscript=0; // edp or markdown .. + waitatend = 0; // init_lgparallele==0; // wait if not parallel + consoleatend = false; // bug with redirection FH + typeofscript = 0; // edp or markdown .. int ret = 0; *fn = '\0'; -check_plugin=0; // no pluging to check .. + check_plugin = 0; // no pluging to check .. #ifdef _WIN32 const int lsuffix = 4; #else @@ -112,15 +116,13 @@ check_plugin=0; // no pluging to check .. #endif ffapi::ff_ch2edpdtmpir = false; bool ch2edpdir = false; - if(argc) - prognamearg = argv[0]; + if (argc) prognamearg = argv[0]; - if (prognamearg) { // FH add to remove ffglut in case of -nw or -nw.exe , mpi ,mpi.exp program FH juin 2014 - april 2017 + if (prognamearg) { // FH add to remove ffglut in case of -nw or -nw.exe , mpi ,mpi.exp program FH juin 2014 - april 2017 int l = strlen(prognamearg); - if( ((l > 4) && (strcmp("-nw", prognamearg + l - 3) == 0)) - || ((l > 8) && (strcmp("-nw.exe", prognamearg + l - 7) == 0)) - || ((l > 5) && (strcmp("-mpi", prognamearg + l - 4) == 0)) // Correct april 2017 FH - || ((l > 9) && (strcmp("-mpi.exe", prognamearg + l - 8) == 0)) // Correct april 2017 FH + if (((l > 4) && (strcmp("-nw", prognamearg + l - 3) == 0)) || ((l > 8) && (strcmp("-nw.exe", prognamearg + l - 7) == 0)) || + ((l > 5) && (strcmp("-mpi", prognamearg + l - 4) == 0)) // Correct april 2017 FH + || ((l > 9) && (strcmp("-mpi.exe", prognamearg + l - 8) == 0)) // Correct april 2017 FH ) { consoleatend = false; noffglut = true; @@ -128,39 +130,35 @@ check_plugin=0; // no pluging to check .. waitatend = false; } } - bool flagnw = 0; + bool flagnw = 0; echo_edp = true; ffapi::ff_justcompile = false; - if(argc) { + if (argc) { for (int i = 1; i < argc; i++) { if (verbosity > 3) cout << " ARGV " << i << " " << argv[i] << " " << fn << endl; if (ret == 0 && strcmp(argv[i], "-f") == 0 && i + 1 < argc) { - strncpy(fn, argv[i + 1],1024); + strncpy(fn, argv[i + 1], 1024); i++; edpfilenamearg = argv[i]; ret = 1; - } - else if (strcmp(argv[i], "-v") == 0 && i + 1 < argc) { + } else if (strcmp(argv[i], "-v") == 0 && i + 1 < argc) { verbosity = atoi(argv[i + 1]); i++; if (verbosity > 10) cout << " verbosity " << verbosity << endl; - } - else if ((strcmp(argv[i], "-nw") == 0) || (strcmp(argv[i], "-ng") == 0)) {// add -ng april 2017 + } else if ((strcmp(argv[i], "-nw") == 0) || (strcmp(argv[i], "-ng") == 0)) { // add -ng april 2017 flagnw = true; consoleatend = false; noffglut = true; NoGraphicWindow = true; - waitatend = false; // add modif FH. juin 2014 .. - } - else if (strcmp(argv[i], "-wg") == 0) { + waitatend = false; // add modif FH. juin 2014 .. + } else if (strcmp(argv[i], "-wg") == 0) { noffglut = false; NoGraphicWindow = false; - } - else if (strcmp(argv[i], "-md") == 0) { + } else if (strcmp(argv[i], "-md") == 0) { typeofscript = 1; } - else if (strcmp(argv[i], "-ne") == 0) // no edp + else if (strcmp(argv[i], "-ne") == 0) // no edp echo_edp = false; else if (strcmp(argv[i], "-cd") == 0) ch2edpdir = true; @@ -173,8 +171,7 @@ check_plugin=0; // no pluging to check .. noffglut = true; NoGraphicWindow = true; waitatend = false; - } - else if (strcmp(argv[i], "-ns") == 0) // no script + } else if (strcmp(argv[i], "-ns") == 0) // no script echo_edp = false; else if (strcmp(argv[i], "-nowait") == 0) waitatend = false; @@ -187,48 +184,41 @@ check_plugin=0; // no pluging to check .. else if (strcmp(argv[i], "-fglut") == 0 && i + 1 < argc) { fileglut = argv[++i]; noffglut = true; - } - else if (strcmp(argv[i], "-glut") == 0 && i + 1 < argc) { + } else if (strcmp(argv[i], "-glut") == 0 && i + 1 < argc) { progffglut = argv[++i]; if (flagnw) { noffglut = true; - NoGraphicWindow = true;// if -nw => no graphic in anycase - } - else { - noffglut = false; - NoGraphicWindow = false; + NoGraphicWindow = true; // if -nw => no graphic in anycase + } else { + noffglut = false; + NoGraphicWindow = false; } - } - else if (strcmp(argv[i], "-check_plugin") == 0 && i + 1 < argc) { - check_plugin=argv[++i]; - ;// BUG because freefem++ is not initial .. so do after .. - - } - else if (strcmp(argv[i], "-gff") == 0 && i + 1 < argc) { + } else if (strcmp(argv[i], "-check_plugin") == 0 && i + 1 < argc) { + check_plugin = argv[++i]; + ; // BUG because freefem++ is not initial .. so do after .. + + } else if (strcmp(argv[i], "-gff") == 0 && i + 1 < argc) { progffglut = Shell_Space(argv[++i]); - if (flagnw) { // if -nw => no graphic in anycase + if (flagnw) { // if -nw => no graphic in anycase noffglut = true; - NoGraphicWindow = true;// if -nw => no graphic in anycase - } - else { + NoGraphicWindow = true; // if -nw => no graphic in anycase + } else { noffglut = false; NoGraphicWindow = false; } - } - else if (strcmp(argv[i], "-?") == 0) + } else if (strcmp(argv[i], "-?") == 0) ret = 2; else if (strcmp(argv[i], "-f") == 0 && i + 1 < argc) { - strncpy(fn, argv[++i],1024); + strncpy(fn, argv[++i], 1024); ret = 1; edpfilenamearg = argv[i]; - // if(!typeofscript ) typeofscript= setMD(fn); + // if(!typeofscript ) typeofscript= setMD(fn); if (verbosity > 4) cout << " fn: " << fn << " " << typeofscript << endl; - } - else if (ret == 0) { - strncpy(fn, argv[i],1024); + } else if (ret == 0) { + strncpy(fn, argv[i], 1024); edpfilenamearg = argv[i]; - // if(!typeofscript )typeofscript= setMD(fn); + // if(!typeofscript )typeofscript= setMD(fn); ret = 1; if (verbosity > 4) cout << " fn: " << fn << " " << typeofscript << endl; } @@ -244,26 +234,26 @@ check_plugin=0; // no pluging to check .. #endif for (i = l - 1; i >= 0; i--) - if (edpfilenamearg[i] == sepdir) break; - else if (edpfilenamearg[i] == '/') break; // jav 2025 FH: add for case with the 2 sepdir / and \ + if (edpfilenamearg[i] == sepdir) + break; + else if (edpfilenamearg[i] == '/') + break; // jav 2025 FH: add for case with the 2 sepdir / and \ if (i > 0) { char *dir = new char[l + 1]; strcpy(dir, edpfilenamearg); - strcpy(fn, edpfilenamearg+i+1); + strcpy(fn, edpfilenamearg + i + 1); dir[i] = 0; int err = 0; - if( edpfilenamearg[i] != sepdir && verbosity) - { - cout << " Warning: dirsep of path is not "<< sepdir << endl; - cout << " path : "< 1 ) - cout << " chdir '" << dir << "'" << endl; + if (verbosity > 1) cout << " chdir '" << dir << "'" << endl; // FFCS: mingw64 API change err = chdir(dir); - //cout << err << endl; + // cout << err << endl; if (err) { cerr << " error: chdir " << dir << endl; exit(1); @@ -271,8 +261,7 @@ check_plugin=0; // no pluging to check .. delete[] dir; } } - if (!progffglut && !noffglut) - progffglut = ffglut; + if (!progffglut && !noffglut) progffglut = ffglut; if (progffglut && mpirank == 0) { // FFCS: divert stream to FFCS @@ -281,33 +270,32 @@ check_plugin=0; // no pluging to check .. // FFCS: just forget the following message because it could be understood as an error during FFCS execution // although ffglut is not used there. - //if(verbosity) - // printf(" EXEC of the plot: %s\n",progffglut); + // if(verbosity) + // printf(" EXEC of the plot: %s\n",progffglut); - if (!ThePlotStream) { cerr << " Error popen "<< progffglut << endl; exit(1); } - } - else if (fileglut && mpirank == 0) { // correction progffglut -> fileglut v3.0-2 FH. + if (!ThePlotStream) { + cerr << " Error popen " << progffglut << endl; + exit(1); + } + } else if (fileglut && mpirank == 0) { // correction progffglut -> fileglut v3.0-2 FH. ThePlotStream = fopen(fileglut, MODE_WRITE_BINARY); - if (verbosity) - cout << " save of the plot in file: " << fileglut << endl; + if (verbosity) cout << " save of the plot in file: " << fileglut << endl; if (!ThePlotStream) { - cerr << " Error save file glut " << fileglut - << " mode " << MODE_WRITE_BINARY << endl; + cerr << " Error save file glut " << fileglut << " mode " << MODE_WRITE_BINARY << endl; exit(1); } } #ifdef _WIN32 if (ret == 0) { - if (ShowOpenDialogBox1(fn)) - ret = 1; + if (ShowOpenDialogBox1(fn)) ret = 1; } #endif - if (ret != 1 && check_plugin==0) { + if (ret != 1 && check_plugin == 0) { const char *ff = argc ? argv[0] : "FreeFem++"; - cout << ff << " - version " << StrVersionNumber() << " " << sizeof(void*)*8 << "bits" << endl; + cout << ff << " - version " << StrVersionNumber( ) << " " << sizeof(void *) * 8 << "bits" << endl; cout << "License: LGPL 3+ (https://www.gnu.org/licenses/lgpl-3.0.en.html)" << endl; cout << "Usage: " << ff << " [FreeFEM arguments] filename [script arguments]" << endl; cout << "FreeFEM arguments:" << endl; @@ -316,7 +304,7 @@ check_plugin=0; // no pluging to check .. cout << "\t-nw: no graphics" << endl; cout << "\t-wg: with graphics" << endl; cout << "\t-ne: no edp script output" << endl; - cout << "\t-cd: change directory to script directory"<< endl; + cout << "\t-cd: change directory to script directory" << endl; cout << "\t-cdtmp: change directory to /tmp" << endl; cout << "\t-jc: just compile" << endl; cout << "\t-ns: same as -ne" << endl; @@ -328,11 +316,13 @@ check_plugin=0; // no pluging to check .. cout << "\t-fglut: [filename] redirect graphics in file" << endl; cout << "\t-glut: [command] use custom glut" << endl; cout << "\t-gff: [command] use custom glut (with space quoting)" << endl; - cout << "\t-check_plugin [plugin1,plugin2,...] just try if this plugins are correct" < 10) - cout << " file: " << fn << endl; + if (verbosity > 10) cout << " file: " << fn << endl; // cout << " verbosity="<< verbosity << endl; return 1; } -#endif //GETPROG_UNIX_HPP_ +#endif // GETPROG_UNIX_HPP_ diff --git a/src/Graphics/gggg.cpp b/src/Graphics/gggg.cpp index a15e7ac7d..e2c6fc940 100644 --- a/src/Graphics/gggg.cpp +++ b/src/Graphics/gggg.cpp @@ -31,64 +31,64 @@ namespace ffapi { - // void init) (); - // need #include - // need #include - // need using namespace std; - std::istream * (*cin)(); - std::ostream *(*cout)(); - std::ostream *(*cerr)(); + // void init) (); + // need #include + // need #include + // need using namespace std; + std::istream *(*cin)( ); + std::ostream *(*cout)( ); + std::ostream *(*cerr)( ); - // <> Cannot name these functions identically to the original file pointers under MingW32 (compile - // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF - // itself was changed. + // <> Cannot name these functions identically to the original file pointers under MingW32 (compile + // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF + // itself was changed. - FILE *(*ffstdout)(); - FILE *(*ffstderr)(); - FILE *(*ffstdin)(); + FILE *(*ffstdout)( ); + FILE *(*ffstderr)( ); + FILE *(*ffstdin)( ); - /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut - /// magic number + /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut + /// magic number - size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb,FILE *stream); + size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb, FILE *stream); - /// Indicates the begining of a new plot to avoid sending socket control data with each plot item. + /// Indicates the begining of a new plot to avoid sending socket control data with each plot item. - void (*newplot)(); + void (*newplot)( ); - /// Redefinition of standard system calls + /// Redefinition of standard system calls - FILE *(*ff_popen)(const char *command, const char *type); - int (*ff_pclose)(FILE *stream); - size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb,FILE *stream); - int (*ff_fflush)(FILE *stream); - int (*ff_ferror)(FILE *stream); - int (*ff_feof)(FILE *stream); + FILE *(*ff_popen)(const char *command, const char *type); + int (*ff_pclose)(FILE *stream); + size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream); + int (*ff_fflush)(FILE *stream); + int (*ff_ferror)(FILE *stream); + int (*ff_feof)(FILE *stream); - // Windows file mode - // ----------------- + // Windows file mode + // ----------------- - /// Changing file mode needs to be disabled when the file is a TCP socket to FFCS. Since the treatment is different in - /// FF and in FFLANG executables, they have to be stored in a DLL that changes between these two programs. + /// Changing file mode needs to be disabled when the file is a TCP socket to FFCS. Since the treatment is different in + /// FF and in FFLANG executables, they have to be stored in a DLL that changes between these two programs. - void (*wintextmode)(FILE *f); - void (*winbinmode)(FILE *f); + void (*wintextmode)(FILE *f); + void (*winbinmode)(FILE *f); - // Transfer basic MPI control - // -------------------------- + // Transfer basic MPI control + // -------------------------- - void (*mpi_init)(int &argc, char **& argv); - void (*mpi_finalize)(); + void (*mpi_init)(int &argc, char **&argv); + void (*mpi_finalize)( ); - // Permanent server control - // ------------------------ + // Permanent server control + // ------------------------ - /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell - /// commands) are not allowed. + /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell + /// commands) are not allowed. - bool (*protectedservermode)(); + bool (*protectedservermode)( ); -} +} // namespace ffapi // TODO: remove this block as soon as autoconf is removed from FreeFem++ #ifndef CMAKE @@ -101,27 +101,26 @@ namespace ffapi { #include #include "environment.hpp" -#define FF_GRAPH_PTR_DCL +#define FF_GRAPH_PTR_DCL #include "rgraph.hpp" -void ShowDebugStack(){} +void ShowDebugStack( ) {} - long verbosity = 1; - long searchMethod=0; // = 9999; //pichon //PROBABLY BUG : can't compile without it - bool lockOrientation=true; - FILE *ThePlotStream=0; // Add for new plot. FH oct 2008 +long verbosity = 1; +long searchMethod = 0; // = 9999; //pichon //PROBABLY BUG : can't compile without it +bool lockOrientation = true; +FILE *ThePlotStream = 0; // Add for new plot. FH oct 2008 +int TheCurrentLine = -1; // unset: by default +long mpisize = 0, mpirank = 0; - int TheCurrentLine=-1; // unset: by default - long mpisize=0,mpirank=0; - -bool showCPU= false; -long npichon2d=0, npichon3d=0; -long npichon2d1=0, npichon3d1=0; +bool showCPU = false; +long npichon2d = 0, npichon3d = 0; +long npichon2d1 = 0, npichon3d1 = 0; // add F. Hecht -EnvironmentData ffenvironment; +EnvironmentData ffenvironment; // April 2019 using std::ostream; #include -RefCounter *RefCounter::tnull=0; +RefCounter *RefCounter::tnull = 0; diff --git a/src/Graphics/glrgraph.hpp b/src/Graphics/glrgraph.hpp index 4444e08ae..015bec4ed 100644 --- a/src/Graphics/glrgraph.hpp +++ b/src/Graphics/glrgraph.hpp @@ -5,44 +5,44 @@ /* O. Pironneau */ // ********** DO NOT REMOVE THIS BANNER ********** /* - // SUMMARY : - // USAGE : - // ORG : + // SUMMARY : + // USAGE : + // ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* (fax) Olivier.Pironneau@ann.jussieu.fr */ /******************************************************/ -//#define FREEFEM -// AGL apple -// XGL X11 -// WGL window (a faire) +// #define FREEFEM +// AGL apple +// XGL X11 +// WGL window (a faire) -const char * edpfilenamearg=0; -bool waitatend=true; -bool consoleatend=true; +const char *edpfilenamearg = 0; +bool waitatend = true; +bool consoleatend = true; #ifdef AGL #define TARGET_API_MAC_CARBON 1 #define CALL_IN_SPOCKETS_BUT_NOT_IN_CARBON 1 #include - + #include #include #include @@ -71,314 +71,281 @@ using namespace std; #include #include #include "rgraph.hpp" -#include // add by fujiwara -#include "pdf.h" // add by fujiwara +#include // add by fujiwara +#include "pdf.h" // add by fujiwara #include #include #include -int currx=0,curry=0; +int currx = 0, curry = 0; static FILE *psfile = 0; static FILE *psfile_save = 0; -static bool pdffile = false; // add by fujiwara -static char *pdffile_name = nullptr; // add by fujiwara -static float pdf_s = 1; // add by fujiwara -static std::stringstream pdffile_content; // add by fujiwara -static FILE *svgfile = 0; // add by fujiwara -static FILE *svgfile_save = 0; // add by fujiwara -static float svg_s = 1; // add by fujiwara -static int svg_r = 0; // add by fujiwara -static int svg_g = 0; // add by fujiwara -static int svg_b = 0; // add by fujiwara -static int svg_lw = 1; // add by fujiwara +static bool pdffile = false; // add by fujiwara +static char *pdffile_name = nullptr; // add by fujiwara +static float pdf_s = 1; // add by fujiwara +static std::stringstream pdffile_content; // add by fujiwara +static FILE *svgfile = 0; // add by fujiwara +static FILE *svgfile_save = 0; // add by fujiwara +static float svg_s = 1; // add by fujiwara +static int svg_r = 0; // add by fujiwara +static int svg_g = 0; // add by fujiwara +static int svg_b = 0; // add by fujiwara +static int svg_lw = 1; // add by fujiwara #ifdef AGL -static AGLPixelFormat fmt; -static AGLContext ctx; +static AGLPixelFormat fmt; +static AGLContext ctx; -int pStrCopy (StringPtr p1, char * p2); -StringPtr c2p(const char * p,char *buf); +int pStrCopy(StringPtr p1, char *p2); +StringPtr c2p(const char *p, char *buf); #endif #ifdef XGL -static Display *dpy; -static Window win; -static XSizeHints size_hints; -//static GC gc; -static XFontStruct *font_info; +static Display *dpy; +static Window win; +static XSizeHints size_hints; +// static GC gc; +static XFontStruct *font_info; GLXContext cx; int stensize; -static Cursor cursor_watch,cursor_arrow; -static int shift, control,shiftlock,alt; -static GLuint basefont; +static Cursor cursor_watch, cursor_arrow; +static int shift, control, shiftlock, alt; +static GLuint basefont; #endif - -extern long verbosity; // level off printing - +extern long verbosity; // level off printing #ifdef FREEFEM -void myenviron () -{ +void myenviron( ) { cout << "FreeFEM error: operator new failed; not enough memory" << endl; - if (myenviron) - longjmp(myenvironj,1); + if (myenviron) longjmp(myenvironj, 1); exit(2); } -// pour imprimer la version FH +// pour imprimer la version FH #define STRING(i) #i #include jmp_buf myenvironj; -static int myenviron = 0; +static int myenviron = 0; -void out_of_memory (); -void NEW_HANDLER (void); +void out_of_memory( ); +void NEW_HANDLER(void); void compile(char *fname); float scali(int i); float scalj(int j); -void execute(char* what); -char Getijc(int & x,int & y); -int DoMouseDown (int windowPart, WindowPtr whichWindow, EventRecord *myEvent); - void NEW_HANDLER (void){ set_new_handler (&myenvironj);} +void execute(char *what); +char Getijc(int &x, int &y); +int DoMouseDown(int windowPart, WindowPtr whichWindow, EventRecord *myEvent); +void NEW_HANDLER(void) { set_new_handler(&myenvironj); } #endif static int nbcolor; static int ncolortable; -static int LastColor; // LastColor=1 => Noir et Blanc +static int LastColor; // LastColor=1 => Noir et Blanc #ifdef AGL -#define ours(w) (w==grafWindow0) -static WindowPtr grafWindow0; -static GrafPtr grafPort0; -static Rect boundsRect; -static CursHandle CrossCurseur ; -static CursHandle WatchCurseur ; -static Pattern white,black; +#define ours(w) (w == grafWindow0) +static WindowPtr grafWindow0; +static GrafPtr grafPort0; +static Rect boundsRect; +static CursHandle CrossCurseur; +static CursHandle WatchCurseur; +static Pattern white, black; #else struct RGBColor { - unsigned short red; /*magnitude of red component*/ - unsigned short green; /*magnitude of green component*/ - unsigned short blue; /*magnitude of blue component*/ + unsigned short red; /*magnitude of red component*/ + unsigned short green; /*magnitude of green component*/ + unsigned short blue; /*magnitude of blue component*/ }; #endif -template inline T Min (const T &a,const T &b){return a < b ? a : b;} -template inline T Max (const T &a,const T & b){return a > b ? a : b;} +template< class T > +inline T Min(const T &a, const T &b) { + return a < b ? a : b; +} +template< class T > +inline T Max(const T &a, const T &b) { + return a > b ? a : b; +} -static bool grey=false; -static int cube6[7][3] ={ {65534,0,0},{65534,65534,0},{0,65534,0},{0,65534,65534},{0,0,65534} - , {65534,0,65534},{65534,0,0} }; -static int grey6[2][3] ={ {65534,65534,65534},{0,0,0} }; +static bool grey = false; +static int cube6[7][3] = {{65534, 0, 0}, {65534, 65534, 0}, {0, 65534, 0}, {0, 65534, 65534}, {0, 0, 65534}, {65534, 0, 65534}, {65534, 0, 0}}; +static int grey6[2][3] = {{65534, 65534, 65534}, {0, 0, 0}}; char errbuf[255]; -static int INITGRAPH=0; -static float aspx, aspy, echx,echy,ech,rxmin,rxmax,rymin,rymax; +static int INITGRAPH = 0; +static float aspx, aspy, echx, echy, ech, rxmin, rxmax, rymin, rymax; static int carre, lacouleur; -static GLuint fontList; - - +static GLuint fontList; -static int width,height; +static int width, height; -static RGBColor * colortable; -int getcolor(); -void putpixel(int ix,int iy, int couleur); +static RGBColor *colortable; +int getcolor( ); +void putpixel(int ix, int iy, int couleur); int scalx(float x); int scaly(float y); -void thisexit(); +void thisexit( ); - -void DrawCStringGL (const char * cstrOut, GLuint fontList) -{ - GLint i = 0; - glRasterPos3d(currx,height-curry,0); - while (cstrOut [i]) - glCallList (fontList + cstrOut[i++]); +void DrawCStringGL(const char *cstrOut, GLuint fontList) { + GLint i = 0; + glRasterPos3d(currx, height - curry, 0); + while (cstrOut[i]) glCallList(fontList + cstrOut[i++]); } - #ifdef AGL -void InitMac(); +void InitMac( ); // -------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------- // APPLE EVENT SUPPORT ROUTINES // -------------------------------------------------------------------------------------------------------------- -StringPtr c2p(const char * p, unsigned char * buf) -{ - int l=strlen(p); - assert(l<255); +StringPtr c2p(const char *p, unsigned char *buf) { + int l = strlen(p); + assert(l < 255); - buf[0]=l; - memcpy(buf+1,p,l); - return buf; + buf[0] = l; + memcpy(buf + 1, p, l); + return buf; } -int pStrCopy (StringPtr p1, char * p2) +int pStrCopy(StringPtr p1, char *p2) /* copies a pascal string `p1 into a C string */ { - int len,i; - - len = (*p1++) %256; - for(i=1;i<=len;i++) *p2++=*p1++; - *p2 = 0; - return 0; -} + int len, i; -void InitMac() -{ - BitMap screenBitMap; - Rect screenBits; - Cursor theArrow; - GetQDGlobalsScreenBits(&screenBitMap); - screenBits = screenBitMap.bounds; - SetCursor(GetQDGlobalsArrow(&theArrow)); + len = (*p1++) % 256; + for (i = 1; i <= len; i++) *p2++ = *p1++; + *p2 = 0; + return 0; +} +void InitMac( ) { + BitMap screenBitMap; + Rect screenBits; + Cursor theArrow; + GetQDGlobalsScreenBits(&screenBitMap); + screenBits = screenBitMap.bounds; + SetCursor(GetQDGlobalsArrow(&theArrow)); } class InitilisationMac { static int init; - public: - InitilisationMac(){ InitMac();} -}; - -static InitilisationMac Initmac; // to call InitMac + public: + InitilisationMac( ) { InitMac( ); } +}; -int getprog(char* fn,int argc, char** argv) -{ - if (argc > 1) - { - int ret=0; - for (int i=1; i0) - cerr << " Syntaxe : " << argv[0] << " -f filename [-v verbosity] " << endl; - else - cerr << " Syntaxe : FreeFem++-agl -f filename [-v verbosity] " << endl; - - return ret; - } - return 1; - +static InitilisationMac Initmac; // to call InitMac + +int getprog(char *fn, int argc, char **argv) { + if (argc > 1) { + int ret = 0; + for (int i = 1; i < argc; i++) + if (ret == 0 && strcmp(argv[i], "-f") == 0 && i + 1 < argc) { + strcpy(fn, argv[i + 1]); + i++; + ret = 1; + } else if (strcmp(argv[i], "-v") == 0 && i + 1 < argc) { + verbosity = atoi(argv[i + 1]); + i++; + } else if (ret == 0) { + strcpy(fn, argv[i]); + ret = 1; + } + if (ret == 0) { + if (argc > 0) + cerr << " Syntaxe : " << argv[0] << " -f filename [-v verbosity] " << endl; + else + cerr << " Syntaxe : FreeFem++-agl -f filename [-v verbosity] " << endl; + + return ret; + } + return 1; + + } else { + OSErr anErr; + + FSRef fsRef; + NavDialogOptions dialogOptions; + NavReplyRecord reply; + + anErr = NavGetDefaultDialogOptions(&dialogOptions); + if (anErr != noErr) return -1; + anErr = NavChooseFile(0, &reply, &dialogOptions, 0, 0, 0, 0, 0); + if (anErr == noErr && reply.validRecord) { + // Deal with multiple file selection + long count; + + anErr = AECountItems(&(reply.selection), &count); + // Set up index for file list + if (anErr == noErr) { + long index; + + for (index = 1; index <= count; index++) { + AEKeyword theKeyword; + DescType actualType; + Size actualSize; + FSSpec documentFSSpec; + + // Get a pointer to selected file + anErr = AEGetNthPtr(&(reply.selection), index, typeFSRef, &theKeyword, &actualType, &fsRef, sizeof(fsRef), &actualSize); + if (anErr == noErr) { + anErr = FSRefMakePath(&fsRef, (UInt8 *)fn, 256); + if (anErr == noErr) { + cout << "Path : " << fn << endl; + char *ff = fn, *fff = 0; + while (*ff) { + if (*ff == '/') fff = ff; + ff++; + } + if (fff) { + *fff = 0; + cout << "chdir to " << fn << endl; + chdir(fn); + *fff = '/'; + } + } else + cout << "Err: " << anErr << endl; + /* + anErr = AEGetNthPtr(&(reply.selection), index, + typeFSS, &theKeyword, + &actualType,&documentFSSpec, + sizeof(documentFSSpec), + &actualSize); + anErr = HSetVol(0,documentFSSpec.vRefNum,documentFSSpec.parID); + pStrCopy(documentFSSpec.name, fn);*/ + } + } + } + // Dispose of NavReplyRecord, resources, descriptors + anErr = NavDisposeReply(&reply); + + } else + return 0; // erreur cancel + return (2); } - else - { OSErr anErr; - - - FSRef fsRef; - NavDialogOptions dialogOptions; - NavReplyRecord reply; - - anErr=NavGetDefaultDialogOptions(& dialogOptions); - if( anErr != noErr) return -1; - anErr =NavChooseFile(0,&reply,&dialogOptions,0,0,0,0,0) ; - if (anErr == noErr && reply.validRecord) - { - // Deal with multiple file selection - long count; - - anErr = AECountItems(&(reply.selection), &count); - // Set up index for file list - if (anErr == noErr) - { - long index; - - for (index = 1; index <= count; index++) - { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec documentFSSpec; - - // Get a pointer to selected file - anErr = AEGetNthPtr(&(reply.selection), index, - typeFSRef, &theKeyword, - &actualType,&fsRef, - sizeof(fsRef), - &actualSize); - if (anErr == noErr) - { - anErr=FSRefMakePath(&fsRef,(UInt8*)fn,256); - if ( anErr == noErr ) - { - cout << "Path : " << fn << endl; - char * ff=fn,*fff=0; - while ( *ff) - { - if (*ff=='/') fff=ff; - ff++; - } - if (fff) { - *fff=0; - cout << "chdir to "<< fn << endl; - chdir(fn); - *fff='/';} - } - else cout << "Err: "<< anErr << endl; - /* - anErr = AEGetNthPtr(&(reply.selection), index, - typeFSS, &theKeyword, - &actualType,&documentFSSpec, - sizeof(documentFSSpec), - &actualSize); - anErr = HSetVol(0,documentFSSpec.vRefNum,documentFSSpec.parID); - pStrCopy(documentFSSpec.name, fn);*/ - } - } - } - // Dispose of NavReplyRecord, resources, descriptors - anErr = NavDisposeReply(&reply); - - } - else return 0; // erreur cancel - return (2); - } } - //----------------------------------------------------------------------------------------------------------------------- -GLuint BuildFontGL (AGLContext ctx, GLint fontID, Style face, GLint size) -{ - GLuint listBase = glGenLists (256); - if (aglUseFont (ctx, fontID , face, size, 0, 256, (long) listBase)) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - return listBase; - } - else - { - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glDeleteLists (listBase, 256); - return 0; - } +GLuint BuildFontGL(AGLContext ctx, GLint fontID, Style face, GLint size) { + GLuint listBase = glGenLists(256); + if (aglUseFont(ctx, fontID, face, size, 0, 256, (long)listBase)) { + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + return listBase; + } else { + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glDeleteLists(listBase, 256); + return 0; + } } #else #include "getprog-unix.hpp" - #endif #ifdef XGL -void MyXSelectInput(Display * dpy,Window w,int mask) +void MyXSelectInput(Display *dpy, Window w, int mask) { XSetWindowAttributes attributes; @@ -389,199 +356,168 @@ void MyXSelectInput(Display * dpy,Window w,int mask) //----------------------------------------------------------------------------------------------------------------------- -void DeleteFontGL (GLuint fontList) -{ - if (fontList) - glDeleteLists (fontList, 256); +void DeleteFontGL(GLuint fontList) { + if (fontList) glDeleteLists(fontList, 256); } -void coutmode(short i) -{ - cout << flush; - cerr << flush; -;} +void coutmode(short i) { + cout << flush; + cerr << flush; + ; +} #ifdef FREEFEM - -void myexit(int err) -{ - if (INITGRAPH) - { +void myexit(int err) { + if (INITGRAPH) { rattente(0); - closegraphique(); + closegraphique( ); } - if (err !=0) - cout << "Error: freefem+ has ended with error code " <screen), - vi->visual, AllocNone); + cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); /* create a window */ swa.colormap = cmap; @@ -607,309 +542,269 @@ void initgraphique(void) swa.event_mask = StructureNotifyMask; height = 512; width = 512; - aspx = width; - aspy =height; - win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width, height, - 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel|CWColormap|CWEventMask, &swa); + aspx = width; + aspy = height; + win = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa); XMapWindow(dpy, win); - glXMakeCurrent(dpy, win, cx); - cursor_arrow = XCreateFontCursor(dpy,XC_arrow); - cursor_watch = XCreateFontCursor(dpy,XC_watch); - XDefineCursor(dpy,win,cursor_watch); - MyXSelectInput (dpy, win, (int) (ExposureMask - | KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - /* | ResizeRedirectMask */ - | StructureNotifyMask) - ); - font_info = XLoadQueryFont(dpy, "6x9"); - //XSetFont(dpy, gc, font_info->fid); - {unsigned int first, last; - int id = font_info->fid; - first = font_info->min_char_or_byte2; - last = font_info->max_char_or_byte2; - fontList = glGenLists(last+1); - if (fontList == 0) { - printf ("out of display lists\n"); - exit (1); - } - glXUseXFont(id, first, last-first+1, fontList+first); + glXMakeCurrent(dpy, win, cx); + cursor_arrow = XCreateFontCursor(dpy, XC_arrow); + cursor_watch = XCreateFontCursor(dpy, XC_watch); + XDefineCursor(dpy, win, cursor_watch); + MyXSelectInput(dpy, win, + (int)(ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | + ButtonReleaseMask + /* | ResizeRedirectMask */ + | StructureNotifyMask)); + font_info = XLoadQueryFont(dpy, "6x9"); + // XSetFont(dpy, gc, font_info->fid); + { + unsigned int first, last; + int id = font_info->fid; + first = font_info->min_char_or_byte2; + last = font_info->max_char_or_byte2; + fontList = glGenLists(last + 1); + if (fontList == 0) { + printf("out of display lists\n"); + exit(1); + } + glXUseXFont(id, first, last - first + 1, fontList + first); } -} - + } + #endif #ifdef WGL - a faire + a faire #endif - carre = aspx == aspy; - lacouleur = getcolor(); - nbcolor= 256; - ncolortable =0; - LastColor=2;// En couleur pas defaul - colortable=0; - SetColorTable(2+6); - - INITGRAPH = 1; - gluOrtho2D(0.0, height,0,width); - glLineWidth(1); - - // cout <<" End Initgraphique\n"; + carre = aspx == aspy; + lacouleur = getcolor( ); + nbcolor = 256; + ncolortable = 0; + LastColor = 2; // En couleur pas defaul + colortable = 0; + SetColorTable(2 + 6); + + INITGRAPH = 1; + gluOrtho2D(0.0, height, 0, width); + glLineWidth(1); + + // cout <<" End Initgraphique\n"; } -static RGBColor DefColorGL( int k,int nb, bool hsv,bool grey,int nbcolors,float *colors) -{ - RGBColor C; - float r,g,b; -extern void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool grey,int nbcolors,float *colors); - DefColor(r,g,b, k,nb,hsv,grey,nbcolors,colors); - C.red= (short unsigned int) (65535*r); - C.green=(short unsigned int)(65535*g); - C.blue= (short unsigned int) (65535*b); - return C; -} - -void SetColorTable1(int nb,bool hsv,int nbcolors,float *colors) -{ +static RGBColor DefColorGL(int k, int nb, bool hsv, bool grey, int nbcolors, float *colors) { + RGBColor C; + float r, g, b; + extern void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool grey, int nbcolors, float *colors); + DefColor(r, g, b, k, nb, hsv, grey, nbcolors, colors); + C.red = (short unsigned int)(65535 * r); + C.green = (short unsigned int)(65535 * g); + C.blue = (short unsigned int)(65535 * b); + return C; +} + +void SetColorTable1(int nb, bool hsv, int nbcolors, float *colors) { static bool greyo = !grey; - static float * colorso=0; - if(!INITGRAPH) return; - if (ncolortable == nb && greyo == grey && colorso == colors ) return;// optim - greyo = grey; - colorso=colors; - if (nbcolor && nb>2) - { - if(colortable) delete [] colortable; - colortable = new RGBColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - for (int i0=0;i0%s\n",currx*svg_s,curry*svg_s,string); + if (svgfile) { + fprintf(svgfile, "%s\n", currx * svg_s, curry * svg_s, string); } - currx += lx; -} + currx += lx; +} -int LaCouleur(){return lacouleur;} +int LaCouleur( ) { return lacouleur; } -void couleur(int c) -{ - if ( lacouleur == c) // small optim +void couleur(int c) { + if (lacouleur == c) // small optim return; - c= c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc - lacouleur =c; - float r=1,g=1,b=1; - if (c>=0 && c < ncolortable) - { - r = (float) colortable[c].red /65535.F; - g = (float) colortable[c].green /65535.F; - b = (float) colortable[c].blue /65535.F; - } - else if (c!=0) - r=g=b=0; - glColor4f (r,g,b,1.); - if (psfile) - fprintf(psfile,"%.3f %.3f %.3f C\n",r,g,b); - // add by fujiwara - if( pdffile ){ - pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; - pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; - } - if( svgfile ){ - svg_r = static_cast(r*256); - svg_g = static_cast(g*256); - svg_b = static_cast(b*256); - } - + c = c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc + lacouleur = c; + float r = 1, g = 1, b = 1; + if (c >= 0 && c < ncolortable) { + r = (float)colortable[c].red / 65535.F; + g = (float)colortable[c].green / 65535.F; + b = (float)colortable[c].blue / 65535.F; + } else if (c != 0) + r = g = b = 0; + glColor4f(r, g, b, 1.); + if (psfile) fprintf(psfile, "%.3f %.3f %.3f C\n", r, g, b); + // add by fujiwara + if (pdffile) { + pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; + pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; + } + if (svgfile) { + svg_r = static_cast< int >(r * 256); + svg_g = static_cast< int >(g * 256); + svg_b = static_cast< int >(b * 256); + } } -int InRecScreen(float x1, float y1,float x2, float y2) -{ - float xi = Min(x1,x2),xa=Max(x1,x2); - float yi = Min(y1,y2),ya=Max(y1,y2); +int InRecScreen(float x1, float y1, float x2, float y2) { + float xi = Min(x1, x2), xa = Max(x1, x2); + float yi = Min(y1, y2), ya = Max(y1, y2); return (xa >= rxmin) && (xi <= rxmax) && (ya >= rymin) && (yi <= rymax); } -int InPtScreen( float x, float y) -{ - return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); -} +int InPtScreen(float x, float y) { return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); } -void penthickness(int pepais) -{ -// PenSize(pepais,pepais); +void penthickness(int pepais) { + // PenSize(pepais,pepais); glLineWidth(pepais); - if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais); + if (psfile) fprintf(psfile, "%d setlinewidth\n", pepais); // add by fujiwara - if ( pdffile ){ - pdffile_content << pepais << " w" << std::endl; + if (pdffile) { + pdffile_content << pepais << " w" << std::endl; } - if ( svgfile ){ - svg_lw = pepais; + if (svgfile) { + svg_lw = pepais; } } -void cadre(float xmin,float xmax,float ymin,float ymax) -{ +void cadre(float xmin, float xmax, float ymin, float ymax) { rxmin = xmin; rxmax = xmax; rymin = ymin; @@ -917,32 +812,27 @@ void cadre(float xmin,float xmax,float ymin,float ymax) echx = aspx / (xmax - xmin); echy = aspy / (ymax - ymin); } -void getcadre(float &xmin,float &xmax,float &ymin,float &ymax) -{ +void getcadre(float &xmin, float &xmax, float &ymin, float &ymax) { xmin = rxmin; xmax = rxmax; ymin = rymin; ymax = rymax; - } -void cadreortho(float centrex, float centrey, float rayon) -{ - float xasp,yasp, getmaxx, getmaxy; - - getmaxx = xasp =aspx; getmaxy = yasp = aspy; - - if (getmaxx * (float)xasp > getmaxy * (float)yasp) - { +void cadreortho(float centrex, float centrey, float rayon) { + float xasp, yasp, getmaxx, getmaxy; + + getmaxx = xasp = aspx; + getmaxy = yasp = aspy; + + if (getmaxx * (float)xasp > getmaxy * (float)yasp) { rymin = centrey - rayon; rymax = centrey + rayon; - echy= getmaxy / (2 * rayon); - echx= (echy * xasp) / yasp; - rxmin= centrex - getmaxx / (2 * echx); - rxmax= centrex + getmaxx / (2 * echx); - } - else - { + echy = getmaxy / (2 * rayon); + echx = (echy * xasp) / yasp; + rxmin = centrex - getmaxx / (2 * echx); + rxmax = centrex + getmaxx / (2 * echx); + } else { rxmin = centrex - rayon; rxmax = centrex + rayon; echx = getmaxx / (2 * rayon); @@ -950,786 +840,721 @@ void cadreortho(float centrex, float centrey, float rayon) rymin = centrey - getmaxy / (2 * echy); rymax = centrey + getmaxy / (2 * echy); } - // cout << "cadreortho\n"; + // cout << "cadreortho\n"; } -int scalx(float x) -{ - return int((x - rxmin) * echx); -} +int scalx(float x) { return int((x - rxmin) * echx); } -int scaly(float y) -{ - return int((rymax - y) * echy); -} +int scaly(float y) { return int((rymax - y) * echy); } -float scali(int i) -{ - return i/echx + rxmin; -} -float scalj(int j) -{ - return -j/echy + rymax; -} +float scali(int i) { return i / echx + rxmin; } +float scalj(int j) { return -j / echy + rymax; } -void pointe(float x, float y) -{ +void pointe(float x, float y) { int newx = scalx(x), newy = scaly(y); putpixel(newx, newy, lacouleur); - if (psfile) - fprintf(psfile,"%d %d P\n", newx, height-newy); + if (psfile) fprintf(psfile, "%d %d P\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - pdffile_content << newx*pdf_s << ' ' << (height-newy)*pdf_s << ' ' - << pdf_s << ' ' << pdf_s << " re f" << std::endl; + if (pdffile) { + pdffile_content << newx * pdf_s << ' ' << (height - newy) * pdf_s << ' ' << pdf_s << ' ' << pdf_s << " re f" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, svg_s, svg_s, svg_r, svg_g, svg_b, 1); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, svg_s, svg_s, svg_r, svg_g, svg_b, + 1); } - } -void rmoveto(float x, float y) -{ +void rmoveto(float x, float y) { int newx = scalx(x), newy = scaly(y); - // MoveTo(newx,newy); - if (psfile) - fprintf(psfile,"%d %d M\n", newx, height-newy); + // MoveTo(newx,newy); + if (psfile) fprintf(psfile, "%d %d M\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - // should be added + if (pdffile) { + // should be added } - if ( svgfile ){ - // should be added + if (svgfile) { + // should be added } - currx = newx; curry = newy; - + currx = newx; + curry = newy; } -void rlineto(float x, float y) -{ +void rlineto(float x, float y) { int newx = scalx(x), newy = scaly(y); glBegin(GL_LINES); - glVertex2i(currx, height-curry); - glVertex2i(newx, height-newy); - glEnd(); - if (psfile) - fprintf(psfile,"%d %d L\n", newx,height-newy); + glVertex2i(currx, height - curry); + glVertex2i(newx, height - newy); + glEnd( ); + if (psfile) fprintf(psfile, "%d %d L\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - pdffile_content << currx*pdf_s << ' ' << (height-curry)*pdf_s << " m " - << newx*pdf_s << ' ' << (height-newy)*pdf_s << " l S" << std::endl; + if (pdffile) { + pdffile_content << currx * pdf_s << ' ' << (height - curry) * pdf_s << " m " << newx * pdf_s << ' ' << (height - newy) * pdf_s << " l S" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, newx*svg_s, newy*svg_s, svg_r, svg_g, svg_b, svg_lw); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, newx * svg_s, newy * svg_s, svg_r, svg_g, + svg_b, svg_lw); } - currx = newx; curry = newy; - + currx = newx; + curry = newy; } - -void fillpoly(int n, float *poly) -{ +void fillpoly(int n, float *poly) { glBegin(GL_POLYGON); - for (int i=0;i\n", svg_r, svg_g, svg_b, svg_lw, svg_r, svg_g, svg_b); } - if ( svgfile ) - { - fprintf(svgfile, "\n", - svg_r,svg_g,svg_b, svg_lw, svg_r,svg_g,svg_b); - } } - - - - - -int execute(const char* what) -{ +int execute(const char *what) { system(what); - return 1; // error + return 1; // error } #ifdef AGL -int DoMouseDown (int windowPart, WindowPtr whichWindow, EventRecord *myEvent) -{ +int DoMouseDown(int windowPart, WindowPtr whichWindow, EventRecord *myEvent) { int wasactive; - switch (windowPart) { - case inGoAway: - if (ours(whichWindow)) - if (TrackGoAway(whichWindow, myEvent->where)) - { - closegraphique(); - cout << "The end (closing the graphic window) " <portRect)); - ZoomWindow(whichWindow, inZoomIn, true); - InitCursor(); - } - break; - - case inZoomOut: -/* if (ours(whichWindow)) - { - SetCursor(&waitCursor); SetPort(whichWindow); - EraseRect(&(whichWindow->portRect)); - ZoomWindow(whichWindow, inZoomOut, true); - if(whichWindow == editWindow) - MyZoomWindow(whichWindow); - InitCursor(); - }*/ - break; - - case inMenuBar: -// return(DoCommand(MenuSelect(myEvent->where))); - break; - - case inSysWindow: - //SystemClick(myEvent, whichWindow); - break; - - case inDrag: - if (ours(whichWindow)) - { - SetPortWindowPort(whichWindow); - GetPort(&grafPort0); - - // DragWindow(whichWindow, myEvent->where, &dragRect); - } - break; - - case inGrow: - //if (ours(whichWindow)) - // {MyGrowWindow(whichWindow, myEvent->where);} - break; - - case inContent: - wasactive = (whichWindow == FrontWindow()); - if(!wasactive) { SelectWindow(whichWindow); - // if (ours(whichWindow) && MacReDraw ) (* MacReDraw)(); - } - else if (ours(whichWindow)) - { SetPortWindowPort(whichWindow); GetPort(&grafPort0); - - while (Button()) ; - return 0; - } - break; - } -return 1; + switch (windowPart) { + case inGoAway: + if (ours(whichWindow)) + if (TrackGoAway(whichWindow, myEvent->where)) { + closegraphique( ); + cout << "The end (closing the graphic window) " << endl; + exit(0); + // HideWindow(whichWindow); + } + break; + + case inZoomIn: + if (ours(whichWindow)) { + // SetCursor(&waitCursor); + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + reffecran( ); + // EraseRect(&(whichWindow->portRect)); + ZoomWindow(whichWindow, inZoomIn, true); + InitCursor( ); + } + break; + + case inZoomOut: + /* if (ours(whichWindow)) + { + SetCursor(&waitCursor); SetPort(whichWindow); + EraseRect(&(whichWindow->portRect)); + ZoomWindow(whichWindow, inZoomOut, true); + if(whichWindow == editWindow) + MyZoomWindow(whichWindow); + InitCursor(); + }*/ + break; + + case inMenuBar: + // return(DoCommand(MenuSelect(myEvent->where))); + break; + + case inSysWindow: + // SystemClick(myEvent, whichWindow); + break; + + case inDrag: + if (ours(whichWindow)) { + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + + // DragWindow(whichWindow, myEvent->where, &dragRect); + } + break; + + case inGrow: + // if (ours(whichWindow)) + // {MyGrowWindow(whichWindow, myEvent->where);} + break; + + case inContent: + wasactive = (whichWindow == FrontWindow( )); + if (!wasactive) { + SelectWindow(whichWindow); + // if (ours(whichWindow) && MacReDraw ) (* MacReDraw)(); + } else if (ours(whichWindow)) { + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + + while (Button( )); + return 0; + } + break; + } + return 1; } -char HandleEvent(EventRecord & myEvent) -{ +char HandleEvent(EventRecord &myEvent) { // cout << "HandleEvent\n"; - WindowPtr whichWindow=NULL; - short windowPart; - - char char1=0; - switch (myEvent.what) { - case mouseDown: - windowPart = FindWindow(myEvent.where, &whichWindow); - if( DoMouseDown(windowPart, whichWindow, &myEvent) ==0) - char1= 251; - break; - -// -// -// case keyDown: - case keyUp: - case autoKey: - { - - windowPart = FindWindow(myEvent.where, &whichWindow); - if((whichWindow==grafWindow0) /* && (inContent == windowPart)*/) - { if (grafWindow0 != FrontWindow()) { - SelectWindow(whichWindow); - SetPortWindowPort(whichWindow); GetPort(&grafPort0); - - } - char1 = (myEvent.message & 127L); - - } - break;} - - case updateEvt: - /* - if (ours((WindowPtr) myEvent.message)) { - BeginUpdate((WindowPtr) myEvent.message); - EndUpdate((WindowPtr) myEvent.message); - } */ - break; - // cout << "End HandleEvent" << int(char1) << endl; + WindowPtr whichWindow = NULL; + short windowPart; + + char char1 = 0; + switch (myEvent.what) { + case mouseDown: + windowPart = FindWindow(myEvent.where, &whichWindow); + if (DoMouseDown(windowPart, whichWindow, &myEvent) == 0) char1 = 251; + break; + + // + // + // case keyDown: + case keyUp: + case autoKey: { + + windowPart = FindWindow(myEvent.where, &whichWindow); + if ((whichWindow == grafWindow0) /* && (inContent == windowPart)*/) { + if (grafWindow0 != FrontWindow( )) { + SelectWindow(whichWindow); + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + } + char1 = (myEvent.message & 127L); + } + break; + } -} + case updateEvt: + /* + if (ours((WindowPtr) myEvent.message)) { + BeginUpdate((WindowPtr) myEvent.message); + EndUpdate((WindowPtr) myEvent.message); + } */ + break; + // cout << "End HandleEvent" << int(char1) << endl; + } return char1; } - #endif -char Getijc(int & x,int & y) -{ - char char1=0; - -#ifdef AGL -viderbuff(); - showgraphic(); - EventRecord myEvent; - int flag=1; -// HLock( (Handle) WatchCurseur); -// SetCursor(*CrossCurseur); -// HUnlock( (Handle) WatchCurseur); - SelectWindow(grafWindow0); - while (char1==0) { - if (GetNextEvent(everyEvent, &myEvent) /* ,OxFFFFFFFF,h)*/) - char1=HandleEvent(myEvent); - } - GlobalToLocal( & myEvent.where); - x = myEvent.where.h; - y = myEvent.where.v; +char Getijc(int &x, int &y) { + char char1 = 0; + +#ifdef AGL + viderbuff( ); + showgraphic( ); + EventRecord myEvent; + int flag = 1; + // HLock( (Handle) WatchCurseur); + // SetCursor(*CrossCurseur); + // HUnlock( (Handle) WatchCurseur); + SelectWindow(grafWindow0); + while (char1 == 0) { + if (GetNextEvent(everyEvent, &myEvent) /* ,OxFFFFFFFF,h)*/) char1 = HandleEvent(myEvent); + } + GlobalToLocal(&myEvent.where); + x = myEvent.where.h; + y = myEvent.where.v; #endif #ifdef XGL XEvent event; - int flag,nb; + int flag, nb; XComposeStatus status; char buffer[20]; - KeySym keysym; /* incidence */ - XDefineCursor(dpy,win,cursor_arrow); - flag=0; - while (!flag) - { XNextEvent(dpy, &event); - if(event.type == ButtonRelease) - { x = event.xbutton.x; - y = event.xbutton.y; - if (event.xbutton.button == Button1) char1=shift?248:251; - else if (event.xbutton.button == Button2) char1=shift?249:252; - else char1=shift?250:253; + KeySym keysym; /* incidence */ + XDefineCursor(dpy, win, cursor_arrow); + flag = 0; + while (!flag) { + XNextEvent(dpy, &event); + if (event.type == ButtonRelease) { + x = event.xbutton.x; + y = event.xbutton.y; + if (event.xbutton.button == Button1) + char1 = shift ? 248 : 251; + else if (event.xbutton.button == Button2) + char1 = shift ? 249 : 252; + else + char1 = shift ? 250 : 253; // printf(" mouse release %d\n",(int) char1); - flag=1; - } - else if(event.type == KeyPress) - { x = event.xkey.x; - y = event.xkey.y; - char1= event.xkey.keycode ; - keysym=0; - nb=XLookupString(&event.xkey,buffer,20,&keysym,&status); - -/* printf("nb= %d keysym= %d buffer=",nb,keysym); -/* for(i=0;i<20;i++) -/* printf(" %d ",(int)buffer[i]); -/* printf("\n"); -*/ - -/* voir /usr/include/X11/keysymdef.h + ap_keysym */ - - if (nb != 0) - {char1 = buffer[0]; - flag= 1; - } - else - { + flag = 1; + } else if (event.type == KeyPress) { + x = event.xkey.x; + y = event.xkey.y; + char1 = event.xkey.keycode; + keysym = 0; + nb = XLookupString(&event.xkey, buffer, 20, &keysym, &status); + + /* printf("nb= %d keysym= %d buffer=",nb,keysym); + /* for(i=0;i<20;i++) + /* printf(" %d ",(int)buffer[i]); + /* printf("\n"); + */ + + /* voir /usr/include/X11/keysymdef.h + ap_keysym */ + + if (nb != 0) { + char1 = buffer[0]; + flag = 1; + } else { /* if (IsFunctionKey(keysym)) printf("function down\n"); else if(IsModifierKey(keysym)) printf("modifier down\n"); else if(IsKeypadKey(keysym)) printf(" keypad down\n"); else if(IsMiscFunctionKey(keysym)) printf(" misc function down\n"); else if(IsPFKey(keysym)) printf(" PF key down\n"); */ -#ifdef XK_MISCELLANY - - switch(keysym) - { -/* Cursor control & motion */ - /* - case XK_Left : - flag = 1; - char1 = call(keyboa).curs_left; - break; - case XK_Up : - flag = 1; - char1 = call(keyboa).curs_up; - break; - case XK_Right : - flag = 1; - char1 = call(keyboa).curs_right; - break; - case XK_Down : - flag = 1; - char1 = call(keyboa).curs_down; - break; - case XK_Next : - flag = 1; - char1 = call(keyboa).pad_down; - break; - case XK_Prior : - flag = 1; - char1 = call(keyboa).pad_up; - break; - case XK_End : - flag = 1; - char1 = call(keyboa).marg_right; - break; - case XK_Begin : - flag = 1; - char1 = call(keyboa).marg_left; - break; - */ -/* Misc Functions */ - /* - - case XK_Select : - flag = 1; - char1 = call(keyboa).mark; - break; */ -/* - case XK_Print : - flag = 1; - char1 = ; - break; - case XK_Execute : - flag = 1; - char1 = ; - break; - case XK_Insert : - flag = 1; - char1 = ; - break; - - case XK_Undo : - flag = 1; - char1 = call(keyboa).undo; - break; - - case XK_Redo : - flag = 1; - char1 = ; - break; - case XK_Menu : - flag = 1; - char1 = ; - break; - case XK_Find : - flag = 1; - char1 = ; - break; - - - case XK_Cancel : - flag = 1; - char1 = call(keyboa).line_del; - break; - case XK_Help : - flag = 1; - char1 = call(keyboa).help; - break; - - case XK_Break : - flag = 1; - char1 = ; - break; - case XK_Mode_switch : - flag = 1; - char1 = ; - break; - case XK_script_switch : - flag = 1; - char1 = ; - break; - case XK_Num_Lock : - flag = 1; - char1 = ; - break; - - case XK_F1 : - flag = 1; - char1 = shift ? call(keyboa).sfunct1 : call(keyboa).funct1 ; - break; - case XK_F2 : - flag = 1; - char1 = shift ? call(keyboa).sfunct2 : call(keyboa).funct2 ; - break; - case XK_F3 : - flag = 1; - char1 = shift ? call(keyboa).sfunct3 : call(keyboa).funct3 ; - break; - case XK_F4 : - flag = 1; - char1 = shift ? call(keyboa).sfunct4 : call(keyboa).funct4 ; - break; - case XK_F5 : - flag = 1; - char1 = shift ? call(keyboa).sfunct5 : call(keyboa).funct5 ; - break; - case XK_F6 : - flag = 1; - char1 = shift ? call(keyboa).sfunct6 : call(keyboa).funct6 ; - break; - case XK_F7 : - flag = 1; - char1 = shift ? call(keyboa).sfunct7 : call(keyboa).funct7 ; - break; - case XK_F8 : - flag = 1; - char1 = shift ? call(keyboa).sfunct8 : call(keyboa).funct8 ; - break; - case XK_F9 : - flag = 1; - char1 = shift ? call(keyboa).sfunct9 : call(keyboa).funct9 ; - break; - case XK_F10 : - flag = 1; - char1 = shift ? call(keyboa).sfunct10 : call(keyboa).funct10 ; - break; - case XK_F11 : - flag = 1; - char1 = shift ? call(keyboa).sfunct11 : call(keyboa).funct11 ; - break; - case XK_F12 : - flag = 1; - char1 = shift ? call(keyboa).sfunct12 : call(keyboa).funct12 ; - break; - */ - case XK_Shift_L : - shift=1; - break; - case XK_Shift_R : - shift=1; - break; - case XK_Control_L : - control=1; - break; - case XK_Control_R : - control=1; - break; - case XK_Caps_Lock : - shiftlock = 1 ; - break; - case XK_Shift_Lock : - shiftlock = 1 ; - break; - case XK_Meta_L : - alt=1; - break; - case XK_Meta_R : - alt=1; - break; - case XK_Alt_L : - alt=1; - break; - case XK_Alt_R : - alt=1; - break; - } /* end switch */ -#endif - } - } - else if(event.type == KeyRelease) - { x = event.xkey.x; - y = event.xkey.y; - char1= event.xkey.keycode ; - keysym=0; - nb=XLookupString(&event.xkey,buffer,20,&keysym,&status); -/* if (IsFunctionKey(keysym)) printf("function up\n"); - else if(IsModifierKey(keysym)) printf("modifier up\n"); - else if(IsKeypadKey(keysym)) printf(" keypad up\n"); - else if(IsMiscFunctionKey(keysym)) printf(" misc function up\n"); - else if(IsPFKey(keysym)) printf(" PF key up\n"); -*/ - if (nb == 0) - { -#ifdef XK_MISCELLANY - switch(keysym) - { - - case XK_Shift_L : - shift=0; - break; - case XK_Shift_R : - shift=0; - break; - case XK_Control_L : - control=0; - break; - case XK_Control_R : - control=0; - break; - case XK_Caps_Lock : - shiftlock = 0 ; - break; - case XK_Shift_Lock : - shiftlock = 0 ; - break; - case XK_Meta_L : - alt=0; - break; - case XK_Meta_R : - alt=0; - break; - case XK_Alt_L : - alt=0; - break; - case XK_Alt_R : - alt=0; - break; - - } /* end switch */ -#endif - - } +#ifdef XK_MISCELLANY + + switch (keysym) { + /* Cursor control & motion */ + /* + case XK_Left : + flag = 1; + char1 = call(keyboa).curs_left; + break; + case XK_Up : + flag = 1; + char1 = call(keyboa).curs_up; + break; + case XK_Right : + flag = 1; + char1 = call(keyboa).curs_right; + break; + case XK_Down : + flag = 1; + char1 = call(keyboa).curs_down; + break; + case XK_Next : + flag = 1; + char1 = call(keyboa).pad_down; + break; + case XK_Prior : + flag = 1; + char1 = call(keyboa).pad_up; + break; + case XK_End : + flag = 1; + char1 = call(keyboa).marg_right; + break; + case XK_Begin : + flag = 1; + char1 = call(keyboa).marg_left; + break; + */ + /* Misc Functions */ + /* + + case XK_Select : + flag = 1; + char1 = call(keyboa).mark; + break; */ + /* + case XK_Print : + flag = 1; + char1 = ; + break; + case XK_Execute : + flag = 1; + char1 = ; + break; + case XK_Insert : + flag = 1; + char1 = ; + break; + + case XK_Undo : + flag = 1; + char1 = call(keyboa).undo; + break; + + case XK_Redo : + flag = 1; + char1 = ; + break; + case XK_Menu : + flag = 1; + char1 = ; + break; + case XK_Find : + flag = 1; + char1 = ; + break; + + + case XK_Cancel : + flag = 1; + char1 = call(keyboa).line_del; + break; + case XK_Help : + flag = 1; + char1 = call(keyboa).help; + break; + + case XK_Break : + flag = 1; + char1 = ; + break; + case XK_Mode_switch : + flag = 1; + char1 = ; + break; + case XK_script_switch : + flag = 1; + char1 = ; + break; + case XK_Num_Lock : + flag = 1; + char1 = ; + break; + + case XK_F1 : + flag = 1; + char1 = shift ? call(keyboa).sfunct1 : call(keyboa).funct1 ; + break; + case XK_F2 : + flag = 1; + char1 = shift ? call(keyboa).sfunct2 : call(keyboa).funct2 ; + break; + case XK_F3 : + flag = 1; + char1 = shift ? call(keyboa).sfunct3 : call(keyboa).funct3 ; + break; + case XK_F4 : + flag = 1; + char1 = shift ? call(keyboa).sfunct4 : call(keyboa).funct4 ; + break; + case XK_F5 : + flag = 1; + char1 = shift ? call(keyboa).sfunct5 : call(keyboa).funct5 ; + break; + case XK_F6 : + flag = 1; + char1 = shift ? call(keyboa).sfunct6 : call(keyboa).funct6 ; + break; + case XK_F7 : + flag = 1; + char1 = shift ? call(keyboa).sfunct7 : call(keyboa).funct7 ; + break; + case XK_F8 : + flag = 1; + char1 = shift ? call(keyboa).sfunct8 : call(keyboa).funct8 ; + break; + case XK_F9 : + flag = 1; + char1 = shift ? call(keyboa).sfunct9 : call(keyboa).funct9 ; + break; + case XK_F10 : + flag = 1; + char1 = shift ? call(keyboa).sfunct10 : call(keyboa).funct10 ; + break; + case XK_F11 : + flag = 1; + char1 = shift ? call(keyboa).sfunct11 : call(keyboa).funct11 ; + break; + case XK_F12 : + flag = 1; + char1 = shift ? call(keyboa).sfunct12 : call(keyboa).funct12 ; + break; + */ + case XK_Shift_L: + shift = 1; + break; + case XK_Shift_R: + shift = 1; + break; + case XK_Control_L: + control = 1; + break; + case XK_Control_R: + control = 1; + break; + case XK_Caps_Lock: + shiftlock = 1; + break; + case XK_Shift_Lock: + shiftlock = 1; + break; + case XK_Meta_L: + alt = 1; + break; + case XK_Meta_R: + alt = 1; + break; + case XK_Alt_L: + alt = 1; + break; + case XK_Alt_R: + alt = 1; + break; + } /* end switch */ +#endif + } + } else if (event.type == KeyRelease) { + x = event.xkey.x; + y = event.xkey.y; + char1 = event.xkey.keycode; + keysym = 0; + nb = XLookupString(&event.xkey, buffer, 20, &keysym, &status); + /* if (IsFunctionKey(keysym)) printf("function up\n"); + else if(IsModifierKey(keysym)) printf("modifier up\n"); + else if(IsKeypadKey(keysym)) printf(" keypad up\n"); + else if(IsMiscFunctionKey(keysym)) printf(" misc function up\n"); + else if(IsPFKey(keysym)) printf(" PF key up\n"); + */ + if (nb == 0) { +#ifdef XK_MISCELLANY + switch (keysym) { + + case XK_Shift_L: + shift = 0; + break; + case XK_Shift_R: + shift = 0; + break; + case XK_Control_L: + control = 0; + break; + case XK_Control_R: + control = 0; + break; + case XK_Caps_Lock: + shiftlock = 0; + break; + case XK_Shift_Lock: + shiftlock = 0; + break; + case XK_Meta_L: + alt = 0; + break; + case XK_Meta_R: + alt = 0; + break; + case XK_Alt_L: + alt = 0; + break; + case XK_Alt_R: + alt = 0; + break; + + } /* end switch */ +#endif + } } } - XDefineCursor(dpy,win,cursor_watch); + XDefineCursor(dpy, win, cursor_watch); XFlush(dpy); #endif #ifdef WGL - a faire + a faire #endif - return char1; - - - + return char1; } - -char Getxyc(float &x,float &y) -{ +char Getxyc(float &x, float &y) { char c; - int i,j; - // cout << "getxyc \n"; - c = Getijc( i,j); + int i, j; + // cout << "getxyc \n"; + c = Getijc(i, j); x = scali(i); y = scalj(j); -// cout << "getxyc out \n"; + // cout << "getxyc out \n"; return c; } -void viderbuff(){ - glFinish(); -#ifdef AGL - aglSwapBuffers (ctx); // send swap command +void viderbuff( ) { + glFinish( ); +#ifdef AGL + aglSwapBuffers(ctx); // send swap command #endif -#ifdef XGL - glXSwapBuffers (dpy,win); // send swap command +#ifdef XGL + glXSwapBuffers(dpy, win); // send swap command #endif - } - -void rattente(int waitm) -{ int i,j; - char c=0; - if(waitm) c = Getijc( i,j); - if ( c == 3) {cout << "rattente: ^c => abort " << endl;closegraphique();exit(1);}// ^c => exit -/* you may prefer to use carriage return to move to the next graph */ -/* getc(stdin); -*/ -// if(waitm) while(!Button()){ }; +void rattente(int waitm) { + int i, j; + char c = 0; + if (waitm) c = Getijc(i, j); + if (c == 3) { + cout << "rattente: ^c => abort " << endl; + closegraphique( ); + exit(1); + } // ^c => exit + /* you may prefer to use carriage return to move to the next graph */ + /* getc(stdin); + */ + // if(waitm) while(!Button()){ }; } -//void GetSizeScreen(int & ix,int &iy); -// GetScreenSize_ -void GetScreenSize(int & ix,int &iy) -{ - ix = width ; - iy = height; +// void GetSizeScreen(int & ix,int &iy); +// GetScreenSize_ +void GetScreenSize(int &ix, int &iy) { + ix = width; + iy = height; } - - -void openPS(const char *filename ) -{ +void openPS(const char *filename) { char ffff[32]; - int count=0; - if(psfile_save) closePS(); + int count = 0; + if (psfile_save) closePS( ); time_t t_loc; - float s=0.5; - const int shiftx=50,shifty=50; - // char username[10]; + float s = 0.5; + const int shiftx = 50, shifty = 50; + // char username[10]; time(&t_loc); bool notfound; - if( !filename) - do { + if (!filename) do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.ps",count++); - volatile int r= stat(ffff,&buf) ; - notfound = r !=0; - if(count>1000) break; - } while ( !notfound ); - - psfile=fopen(filename?filename:ffff,"w"); - - if(psfile==0) {printf("Erreur %s errno %d\n",filename?filename:ffff,errno);exit(1);} - if(psfile) { - fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); - fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); - fprintf(psfile,"%%%%Pages: 1\n"); - fprintf(psfile,"%%%%BoundingBox: %d %d %d %d\n",shiftx,shifty,int(shiftx+width*s),int(shifty+height*s)); - fprintf(psfile,"%%%%EndComments\n"); - fprintf(psfile," /L { lineto currentpoint stroke newpath moveto} def\n"); - fprintf(psfile," /M { moveto } def\n"); - fprintf(psfile," /C {setrgbcolor} def\n"); - fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); - fprintf(psfile," %d %d translate \n",shiftx,shifty); - fprintf(psfile," %f %f scale \n",s,s); - fprintf(psfile," 0 %d 0 %d rec clip newpath\n",int(width),int(height)); - fprintf(psfile," /Helvetica findfont 10 scalefont setfont\n"); - fprintf(psfile," /S { show} def\n"); - fprintf(psfile," /bF { mark} def \n"); - fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); - fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); - - fprintf(psfile," 1 setlinewidth\n"); - psfile_save=psfile; + sprintf(ffff, "rgraph_%.3d.ps", count++); + volatile int r = stat(ffff, &buf); + notfound = r != 0; + if (count > 1000) break; + } while (!notfound); + + psfile = fopen(filename ? filename : ffff, "w"); + + if (psfile == 0) { + printf("Erreur %s errno %d\n", filename ? filename : ffff, errno); + exit(1); + } + if (psfile) { + fprintf(psfile, "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n", "user"); + fprintf(psfile, "%%%%CreationDate: %s", ctime(&t_loc)); + fprintf(psfile, "%%%%Pages: 1\n"); + fprintf(psfile, "%%%%BoundingBox: %d %d %d %d\n", shiftx, shifty, int(shiftx + width * s), int(shifty + height * s)); + fprintf(psfile, "%%%%EndComments\n"); + fprintf(psfile, " /L { lineto currentpoint stroke newpath moveto} def\n"); + fprintf(psfile, " /M { moveto } def\n"); + fprintf(psfile, " /C {setrgbcolor} def\n"); + fprintf(psfile, " /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); + fprintf(psfile, " %d %d translate \n", shiftx, shifty); + fprintf(psfile, " %f %f scale \n", s, s); + fprintf(psfile, " 0 %d 0 %d rec clip newpath\n", int(width), int(height)); + fprintf(psfile, " /Helvetica findfont 10 scalefont setfont\n"); + fprintf(psfile, " /S { show} def\n"); + fprintf(psfile, " /bF { mark} def \n"); + fprintf(psfile, " /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); + fprintf(psfile, " /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); + + fprintf(psfile, " 1 setlinewidth\n"); + psfile_save = psfile; } } -void closePS(void) -{ - if(psfile_save) { - fprintf(psfile_save,"showpage\n"); +void closePS(void) { + if (psfile_save) { + fprintf(psfile_save, "showpage\n"); fclose(psfile_save); - } - - psfile=0; - psfile_save=0; - + } + + psfile = 0; + psfile_save = 0; } //---------------------------------------------------------------------- // add by fujiwara //---------------------------------------------------------------------- -void openPDF(const char *filename ) -{ - if(pdffile) closePDF(); +void openPDF(const char *filename) { + if (pdffile) closePDF( ); - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } - pdffile_name = new char [ strlen(filename)+1 ]; - strcpy( pdffile_name, filename ); + pdffile_name = new char[strlen(filename) + 1]; + strcpy(pdffile_name, filename); - pdffile_content.str(""); // clear - pdffile_content.clear( std::stringstream::goodbit ); + pdffile_content.str(""); // clear + pdffile_content.clear(std::stringstream::goodbit); - pdffile_content.setf( std::ios::fixed ); - pdffile_content.precision( 3 ); + pdffile_content.setf(std::ios::fixed); + pdffile_content.precision(3); const int widthA4PDF = 596; - pdf_s = static_cast(widthA4PDF) / width; + pdf_s = static_cast< float >(widthA4PDF) / width; pdffile = true; - pdffile_content << "q" << std::endl; // gsave - + pdffile_content << "q" << std::endl; // gsave + return; } -void closePDF(void) -{ - if(pdffile) { +void closePDF(void) { + if (pdffile) { - std::string PDFTitle = "plot() by FreeFem++"; - std::string AppName = "FreeFem++ v" + StrVersionNumber(); + std::string PDFTitle = "plot() by FreeFem++"; + std::string AppName = "FreeFem++ v" + StrVersionNumber( ); - SimplePDF_FF pdf( pdffile_name, PDFTitle.c_str(), AppName.c_str() ); + SimplePDF_FF pdf(pdffile_name, PDFTitle.c_str( ), AppName.c_str( )); - const int widthPDF = static_cast( width * pdf_s ); - const int heightPDF = static_cast( height * pdf_s ); + const int widthPDF = static_cast< int >(width * pdf_s); + const int heightPDF = static_cast< int >(height * pdf_s); - pdffile_content << "Q" << std::endl; + pdffile_content << "Q" << std::endl; - pdf.addPage( pdffile_content, widthPDF, heightPDF ); + pdf.addPage(pdffile_content, widthPDF, heightPDF); - pdffile = false; + pdffile = false; } - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } return; } -void openSVG(const char *filename ) -{ - if(svgfile_save) closeSVG(); +void openSVG(const char *filename) { + if (svgfile_save) closeSVG( ); - const int widthA4PS = 596; - //const int heightA4PS = 842; - svg_s = static_cast(widthA4PS)/width; + const int widthA4PS = 596; + // const int heightA4PS = 842; + svg_s = static_cast< double >(widthA4PS) / width; char ffff[32]; int count = 0; - if(!filename){ + if (!filename) { bool notfound; do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.svg",count++); - volatile int r = stat(ffff,&buf) ; + sprintf(ffff, "rgraph_%.3d.svg", count++); + volatile int r = stat(ffff, &buf); notfound = (r != 0); - if( count > 1000 ) break; - } while ( !notfound ); - } - - const char *fsvg (filename?filename:ffff); - - svgfile=fopen(fsvg,"w"); - - if(svgfile) { - svgfile_save=svgfile; - fprintf(svgfile,"\n\n"); - fprintf(svgfile,"\n\n", StrVersionNumber().c_str()); - fprintf(svgfile,"\n", - static_cast(width*svg_s), static_cast(height*svg_s)); + if (count > 1000) break; + } while (!notfound); } - else - { + + const char *fsvg(filename ? filename : ffff); + + svgfile = fopen(fsvg, "w"); + + if (svgfile) { + svgfile_save = svgfile; + fprintf(svgfile, "\n\n"); + fprintf(svgfile, "\n\n", StrVersionNumber( ).c_str( )); + fprintf(svgfile, "\n", static_cast< int >(width * svg_s), static_cast< int >(height * svg_s)); + } else { cerr << " Err opening SVG file " << fsvg << endl; } return; } -void closeSVG(void) -{ - if(svgfile_save) { - fprintf(svgfile_save,"\n"); +void closeSVG(void) { + if (svgfile_save) { + fprintf(svgfile_save, "\n"); fclose(svgfile_save); } - svgfile_save=0; - svgfile=0; + svgfile_save = 0; + svgfile = 0; return; } @@ -1737,114 +1562,115 @@ void closeSVG(void) // add by fujiwara end //---------------------------------------------------------------------- - void Commentaire(const char * c) - { - if(psfile) { - fprintf(psfile,"%% %s\n",c); - } - // add by fujiwara - if( pdffile ) { - //fprintf(pdffile,"%% %s\n",c); - } - if( svgfile ) { - fprintf(svgfile,"%% %s\n",c); - } - }; - void NoirEtBlanc(int NB) - { - if(NB) LastColor=1; - else LastColor=ncolortable?ncolortable:2; +void Commentaire(const char *c) { + if (psfile) { + fprintf(psfile, "%% %s\n", c); } - - void MettreDansPostScript(int in) - { - if(in) psfile=psfile_save; - else psfile=0; - } // add by fujiwara - void MettreDansPDF(int in) // put into PDF - { - if(in) pdffile=true; - else pdffile=false; - } - void MettreDansSVG(int in) // put into SVG - { - if(in) svgfile=svgfile_save; - else svgfile=0; - } - -static void FillRect(float x0,float y0, float x1, float y1) - { - float r[8]; - r[0]=x0;r[1]=y0; - r[2]=x1;r[3]=y0; - r[4]=x1;r[5]=y1; - r[6]=x0;r[7]=y1; - fillpoly(4,r); - } - -float GetHeigthFont() -{ - // FontInfo MyFontInfo; - // GetFontInfo(&MyFontInfo); -#ifdef XGL - int dir,asc,desc,k; - XCharStruct overall; + if (pdffile) { + // fprintf(pdffile,"%% %s\n",c); + } + if (svgfile) { + fprintf(svgfile, "%% %s\n", c); + } +}; +void NoirEtBlanc(int NB) { + if (NB) + LastColor = 1; + else + LastColor = ncolortable ? ncolortable : 2; +} - XTextExtents(font_info,"gML",3,&dir,&asc,&desc,&overall); - return (asc+desc)*(0.9/echy); -#else - int interligne = 9;// MyFontInfo.ascent + MyFontInfo.descent + MyFontInfo.leading; - return interligne/echy; -#endif +void MettreDansPostScript(int in) { + if (in) + psfile = psfile_save; + else + psfile = 0; +} +// add by fujiwara +void MettreDansPDF(int in) // put into PDF +{ + if (in) + pdffile = true; + else + pdffile = false; +} +void MettreDansSVG(int in) // put into SVG +{ + if (in) + svgfile = svgfile_save; + else + svgfile = 0; +} +static void FillRect(float x0, float y0, float x1, float y1) { + float r[8]; + r[0] = x0; + r[1] = y0; + r[2] = x1; + r[3] = y0; + r[4] = x1; + r[5] = y1; + r[6] = x0; + r[7] = y1; + fillpoly(4, r); } +float GetHeigthFont( ) { + // FontInfo MyFontInfo; + // GetFontInfo(&MyFontInfo); +#ifdef XGL + int dir, asc, desc, k; + XCharStruct overall; + XTextExtents(font_info, "gML", 3, &dir, &asc, &desc, &overall); + return (asc + desc) * (0.9 / echy); +#else + int interligne = 9; // MyFontInfo.ascent + MyFontInfo.descent + MyFontInfo.leading; + return interligne / echy; +#endif +} -int PutLevel(int lineno, float xf, int col) -{ - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - float xleft = xmax - (xmax-xmin)*0.1; - float ytop = ymax; - float ydelta = (ymax-ymin)/40; - ydelta=GetHeigthFont(); - xleft = xmax - 6*ydelta; - ytop -= ydelta*(col+2); +int PutLevel(int lineno, float xf, int col) { + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + float xleft = xmax - (xmax - xmin) * 0.1; + float ytop = ymax; + float ydelta = (ymax - ymin) / 40; + ydelta = GetHeigthFont( ); + xleft = xmax - 6 * ydelta; + ytop -= ydelta * (col + 2); couleur(col); - FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.); - rmoveto(xleft+ydelta*1.4,ytop+ydelta/4); + FillRect(xleft + ydelta / 8., ytop + ydelta / 8., xleft + ydelta * 7. / 8., ytop + ydelta * 7. / 8.); + rmoveto(xleft + ydelta * 1.4, ytop + ydelta / 4); char buf[30]; - sprintf(buf,"%g",xf); + sprintf(buf, "%g", xf); couleur(1); plotstring(buf); - return lineno; + return lineno; } - void ShowHelp(const char * s,int k) -{ - if(k) { +void ShowHelp(const char *s, int k) { + if (k) { MettreDansPostScript(0); - MettreDansPDF(0); // add by fujiwara - MettreDansSVG(0); // add by fujiwara + MettreDansPDF(0); // add by fujiwara + MettreDansSVG(0); // add by fujiwara couleur(1); - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + rmoveto(xmin + (xmax - xmin) / 100, ymax - (k) * (ymax - ymin) / 30); plotstring(s); MettreDansPostScript(1); - MettreDansPDF(1); // add by fujiwara - MettreDansSVG(1); // add by fujiwara - // couleur(1); + MettreDansPDF(1); // add by fujiwara + MettreDansSVG(1); // add by fujiwara + // couleur(1); } } class Grid; - void setgrey(bool gg ){grey=gg;} - int getgrey(){ return grey;} - -void SaveMesh(Grid &t){} -void SavePlot(int D, Grid& t, double *f){} -void SavePlot(int D, Grid& t, float *f){} +void setgrey(bool gg) { grey = gg; } +int getgrey( ) { return grey; } +void SaveMesh(Grid &t) {} +void SavePlot(int D, Grid &t, double *f) {} +void SavePlot(int D, Grid &t, float *f) {} diff --git a/src/Graphics/macglrgraf.cpp b/src/Graphics/macglrgraf.cpp index f865f98c2..a72b10530 100644 --- a/src/Graphics/macglrgraf.cpp +++ b/src/Graphics/macglrgraf.cpp @@ -1,25 +1,25 @@ // -*- Mode : c++ -*- // -// SUMMARY : +// SUMMARY : // ORG : UPMC // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/Graphics/macrgraf.cpp b/src/Graphics/macrgraf.cpp index f0e004aa1..a58ba4750 100644 --- a/src/Graphics/macrgraf.cpp +++ b/src/Graphics/macrgraf.cpp @@ -1,5 +1,5 @@ // -// SUMMARY : +// SUMMARY : // ORG : UPMC // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr @@ -12,19 +12,19 @@ // -*- Mode : c++ -*- /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -34,40 +34,40 @@ /******************************************************/ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : /* Authors: D. Bernardi, Y. Darmaillac F. Hecht, */ /* O. Pironneau */ // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -const char * edpfilenamearg=0; -bool waitatend=true; +const char *edpfilenamearg = 0; +bool waitatend = true; -//#define TARGET_API_MAC_CARBON 1 +// #define TARGET_API_MAC_CARBON 1 #define FF_GRAPH_SET_PTR #include #include -#include //OP my hack +#include //OP my hack #include "error.hpp" #include #include @@ -80,680 +80,596 @@ using namespace std; #include #define fill thequikdrawfill #include "rgraph.hpp" -#include // add by fujiwara -#include "pdf.h" // add by fujiwara +#include // add by fujiwara +#include "pdf.h" // add by fujiwara #include #include #include #include -//#include +// #include #include #include #include #include #include -#include +#include #undef fill static FILE *psfile = 0; static FILE *psfile_save = 0; -static bool pdffile = false; // add by fujiwara -static char *pdffile_name = nullptr; // add by fujiwara -static float pdf_s = 1; // add by fujiwara -static std::stringstream pdffile_content; // add by fujiwara -static FILE *svgfile = 0; // add by fujiwara -static FILE *svgfile_save = 0; // add by fujiwara -static float svg_s = 1; // add by fujiwara -static int svg_r = 0; // add by fujiwara -static int svg_g = 0; // add by fujiwara -static int svg_b = 0; // add by fujiwara -static int svg_lw = 1; // add by fujiwara - -static bool grey=false; -int pStrCopy (StringPtr p1, char * p2); +static bool pdffile = false; // add by fujiwara +static char *pdffile_name = nullptr; // add by fujiwara +static float pdf_s = 1; // add by fujiwara +static std::stringstream pdffile_content; // add by fujiwara +static FILE *svgfile = 0; // add by fujiwara +static FILE *svgfile_save = 0; // add by fujiwara +static float svg_s = 1; // add by fujiwara +static int svg_r = 0; // add by fujiwara +static int svg_g = 0; // add by fujiwara +static int svg_b = 0; // add by fujiwara +static int svg_lw = 1; // add by fujiwara + +static bool grey = false; +int pStrCopy(StringPtr p1, char *p2); #ifdef FREEFEM -// pour imprimer la version FH +// pour imprimer la version FH #define STRING(i) #i #include jmp_buf environ; -static int myenviron = 0; +static int myenviron = 0; TEHandle TESioux; -void out_of_memory (); -void NEW_HANDLER (void); +void out_of_memory( ); +void NEW_HANDLER(void); void compile(char *fname); float scali(int i); float scalj(int j); -void execute(char* what); -int DoMouseDown (int windowPart, WindowPtr whichWindow, EventRecord *myEvent); -char Getijc(int & x,int & y); - +void execute(char *what); +int DoMouseDown(int windowPart, WindowPtr whichWindow, EventRecord *myEvent); +char Getijc(int &x, int &y); -void out_of_memory () -{ +void out_of_memory( ) { cout << "FreeFEM error: operator new failed; not enough memory" << endl; - if (myenviron) - longjmp(environ,1); + if (myenviron) longjmp(environ, 1); exit(2); } -void NEW_HANDLER (void){ set_new_handler (&out_of_memory);} +void NEW_HANDLER(void) { set_new_handler(&out_of_memory); } #endif -#define ours(w) (w==grafWindow0) +#define ours(w) (w == grafWindow0) -template inline T Min (const T &a,const T &b){return a < b ? a : b;} -template inline T Max (const T &a,const T & b){return a > b ? a : b;} +template< class T > +inline T Min(const T &a, const T &b) { + return a < b ? a : b; +} +template< class T > +inline T Max(const T &a, const T &b) { + return a > b ? a : b; +} -static int cube6[7][3] ={ {65534,0,0},{65534,65534,0},{0,65534,0},{0,65534,65534},{0,0,65534} - , {65534,0,65534},{65534,0,0} }; -static int grey6[2][3] ={ {65534,65534,65534},{0,0,0} }; +static int cube6[7][3] = {{65534, 0, 0}, {65534, 65534, 0}, {0, 65534, 0}, {0, 65534, 65534}, {0, 0, 65534}, {65534, 0, 65534}, {65534, 0, 0}}; +static int grey6[2][3] = {{65534, 65534, 65534}, {0, 0, 0}}; char errbuf[255]; -static int INITGRAPH=0; -static float aspx, aspy, echx,echy,ech,rxmin,rxmax,rymin,rymax; +static int INITGRAPH = 0; +static float aspx, aspy, echx, echy, ech, rxmin, rxmax, rymin, rymax; static int carre, lacouleur; // static CWindowRecord wgRecord0; -static WindowPtr grafWindow0; -static GrafPtr grafPort0; -static Rect boundsRect; +static WindowPtr grafWindow0; +static GrafPtr grafPort0; +static Rect boundsRect; static int nbcolor; -static CursHandle CrossCurseur ; -static CursHandle WatchCurseur ; +static CursHandle CrossCurseur; +static CursHandle WatchCurseur; static int ncolortable; -static int LastColor; // LastColor=1 => Noir et Blanc -static Pattern white,black; +static int LastColor; // LastColor=1 => Noir et Blanc +static Pattern white, black; -static int width,height; -static RGBColor * colortable; -int getcolor(); -void putpixel(int ix,int iy, int couleur); +static int width, height; +static RGBColor *colortable; +int getcolor( ); +void putpixel(int ix, int iy, int couleur); int scalx(float x); int scaly(float y); -void thisexit(); -void InitMac(); +void thisexit( ); +void InitMac( ); // -------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------- // APPLE EVENT SUPPORT ROUTINES // -------------------------------------------------------------------------------------------------------------- -static OSStatus MissingParameterCheck( - const AppleEvent *inputEvent) +static OSStatus MissingParameterCheck(const AppleEvent *inputEvent) /* - This routine checks an input AppleEvent for the missing keyword. - If the missing keyword is found, that means that some required - parameters were missing (ie, an error). - - However, if the missing keyword isn't found, that means that we aren't missing - any required parameters (that is to say, all REQUIRED parameters were supplied - by the person who created the event). - - SOME DAY, THE ABOVE COMMENT WILL MAKE SENSE TO YOU. IT STILL DOESN'T - TO ME AND I WAS THE ONE WHO WROTE IT. + This routine checks an input AppleEvent for the missing keyword. + If the missing keyword is found, that means that some required + parameters were missing (ie, an error). + + However, if the missing keyword isn't found, that means that we aren't missing + any required parameters (that is to say, all REQUIRED parameters were supplied + by the person who created the event). + + SOME DAY, THE ABOVE COMMENT WILL MAKE SENSE TO YOU. IT STILL DOESN'T + TO ME AND I WAS THE ONE WHO WROTE IT. */ { - OSStatus anErr; - AEKeyword missingKeyword; - DescType ignoredActualType; - Size ignoredActualSize; - - anErr = AEGetAttributePtr( - inputEvent, - keyMissedKeywordAttr, - typeWildCard, - &ignoredActualType, - (Ptr) &missingKeyword, - sizeof(AEKeyword), - &ignoredActualSize); - - if (anErr == noErr) - anErr = errAEParamMissed; - else - if (anErr == errAEDescNotFound) - anErr = noErr; - - return anErr; - -} // MissingParameterCheck - - -static pascal OSErr DoOpenApp( - const AppleEvent *inputEvent, - AppleEvent *outputEvent, - SInt32 handlerRefCon) -{ -/* - #pragma unused (outputEvent, handlerRefCon) - - DoCommand(nil, cNew, 0, 0); - - // so that the initial document opens more quickly, we don't start - // the threads until we get an OpenApp or OpenDocument AppleEvent - if (gStarterThread != kNoThreadID) - SetThreadState(gStarterThread, kReadyThreadState, gStarterThread); -*/ - return(MissingParameterCheck(inputEvent)); - -} // DoOpenApp + OSStatus anErr; + AEKeyword missingKeyword; + DescType ignoredActualType; + Size ignoredActualSize; + + anErr = AEGetAttributePtr(inputEvent, keyMissedKeywordAttr, typeWildCard, &ignoredActualType, (Ptr)&missingKeyword, sizeof(AEKeyword), &ignoredActualSize); + + if (anErr == noErr) + anErr = errAEParamMissed; + else if (anErr == errAEDescNotFound) + anErr = noErr; + + return anErr; + +} // MissingParameterCheck + +static pascal OSErr DoOpenApp(const AppleEvent *inputEvent, AppleEvent *outputEvent, SInt32 handlerRefCon) { + /* + #pragma unused (outputEvent, handlerRefCon) + + DoCommand(nil, cNew, 0, 0); + + // so that the initial document opens more quickly, we don't start + // the threads until we get an OpenApp or OpenDocument AppleEvent + if (gStarterThread != kNoThreadID) + SetThreadState(gStarterThread, kReadyThreadState, gStarterThread); + */ + return (MissingParameterCheck(inputEvent)); + +} // DoOpenApp // -------------------------------------------------------------------------------------------------------------- -static pascal OSErr DoReopenApp( - const AppleEvent *inputEvent, - AppleEvent *outputEvent, - SInt32 handlerRefCon) -{ -/* -#pragma unused (outputEvent, handlerRefCon) +static pascal OSErr DoReopenApp(const AppleEvent *inputEvent, AppleEvent *outputEvent, SInt32 handlerRefCon) { + /* + #pragma unused (outputEvent, handlerRefCon) + + if (FrontWindow() == nil) + DoCommand(nil, cNew, 0, 0); + */ + return (MissingParameterCheck(inputEvent)); - if (FrontWindow() == nil) - DoCommand(nil, cNew, 0, 0); -*/ - return(MissingParameterCheck(inputEvent)); - -} // DoReopenApp +} // DoReopenApp // -------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------- -static pascal OSStatus DoOpenFile( - const AppleEvent *inputEvent - ) // nil == 0, zero length == print to default, other == printer name +static pascal OSStatus DoOpenFile(const AppleEvent *inputEvent) // nil == 0, zero length == print to default, other == printer name { - OSStatus anErr, anErr2; - AEDescList docList; // list of docs passed in - long index, itemsInList; - Boolean wasAlreadyOpen; -/* - anErr = AEGetParamDesc( inputEvent, keyDirectObject, typeAEList, &docList); - nrequire(anErr, GetFileList); - - anErr = AECountItems( &docList, &itemsInList); // how many files passed in - nrequire(anErr, CountDocs); - for (index = 1; index <= itemsInList; index++) // handle each file passed in - { - AEKeyword keywd; - DescType returnedType; - Size actualSize; - FSRef fileRef; - FSCatalogInfo theCatInfo; - - anErr = AEGetNthPtr( &docList, index, typeFSRef, &keywd, &returnedType, - (Ptr)(&fileRef), sizeof( fileRef ), &actualSize ); - nrequire(anErr, AEGetNthPtr); - - anErr = FSGetCatalogInfo( &fileRef, kFSCatInfoFinderInfo, &theCatInfo, NULL, NULL, NULL ); -/* - nrequire(anErr, FSGetCatalogInfo); - - if (anErr == noErr) - anErr = DetermineWindowTypeOrOpen(&fileRef, ((FInfo*)&theCatInfo.finderInfo)->fdType, nil, nil, &wasAlreadyOpen); - - -*/ - -// } - - return anErr; - -} // DoOpenOrPrint + OSStatus anErr, anErr2; + AEDescList docList; // list of docs passed in + long index, itemsInList; + Boolean wasAlreadyOpen; + /* + anErr = AEGetParamDesc( inputEvent, keyDirectObject, typeAEList, &docList); + nrequire(anErr, GetFileList); + + anErr = AECountItems( &docList, &itemsInList); // how many files passed in + nrequire(anErr, CountDocs); + for (index = 1; index <= itemsInList; index++) // handle each file passed in + { + AEKeyword keywd; + DescType returnedType; + Size actualSize; + FSRef fileRef; + FSCatalogInfo theCatInfo; + + anErr = AEGetNthPtr( &docList, index, typeFSRef, &keywd, &returnedType, + (Ptr)(&fileRef), sizeof( fileRef ), &actualSize ); + nrequire(anErr, AEGetNthPtr); + + anErr = FSGetCatalogInfo( &fileRef, kFSCatInfoFinderInfo, &theCatInfo, NULL, NULL, NULL ); + /* + nrequire(anErr, FSGetCatalogInfo); + + if (anErr == noErr) + anErr = DetermineWindowTypeOrOpen(&fileRef, ((FInfo*)&theCatInfo.finderInfo)->fdType, nil, nil, &wasAlreadyOpen); + + + */ + + // } + + return anErr; + +} // DoOpenOrPrint // -------------------------------------------------------------------------------------------------------------- -static pascal OSErr DoOpenDocument( - const AppleEvent *inputEvent, - AppleEvent *outputEvent, - SInt32 handlerRefCon) -{ +static pascal OSErr DoOpenDocument(const AppleEvent *inputEvent, AppleEvent *outputEvent, SInt32 handlerRefCon) { -#pragma unused (outputEvent, handlerRefCon) +#pragma unused(outputEvent, handlerRefCon) - OSStatus anErr=0; - - anErr = DoOpenFile(inputEvent); + OSStatus anErr = 0; - return anErr; - -} // DoOpenDocument -void InitMac() -{ + anErr = DoOpenFile(inputEvent); + + return anErr; + +} // DoOpenDocument +void InitMac( ) { #if TARGET_API_MAC_OS8 - InitGraf(&qd.thePort); - InitFonts(); - InitWindows(); - InitMenus(); - TEInit(); - InitDialogs(0L); - FlushEvents(everyEvent, 0L); - MaxApplZone(); + InitGraf(&qd.thePort); + InitFonts( ); + InitWindows( ); + InitMenus( ); + TEInit( ); + InitDialogs(0L); + FlushEvents(everyEvent, 0L); + MaxApplZone( ); #endif /* TARGET_API_MAC_OS8 */ - MoreMasters(); - - InitCursor(); + MoreMasters( ); + + InitCursor( ); #if TARGET_API_MAC_CARBON - BitMap screenBitMap; - Rect screenBits; - Cursor theArrow; - GetQDGlobalsScreenBits(&screenBitMap); - screenBits = screenBitMap.bounds; - SetCursor(GetQDGlobalsArrow(&theArrow)); + BitMap screenBitMap; + Rect screenBits; + Cursor theArrow; + GetQDGlobalsScreenBits(&screenBitMap); + screenBits = screenBitMap.bounds; + SetCursor(GetQDGlobalsArrow(&theArrow)); #else - Rect screenBits = qd.screenBits.bounds; - SetCursor(&qd.arrow); + Rect screenBits = qd.screenBits.bounds; + SetCursor(&qd.arrow); #endif /* TARGET_API_MAC_CARBON */ - - SIOUXSettings.initializeTB = 0; // else SIOUX initialize the toolbox for us + + SIOUXSettings.initializeTB = 0; // else SIOUX initialize the toolbox for us SIOUXSettings.toppixel = 45; - SIOUXSettings.leftpixel = 15; -// SIOUXSettings.fontface = bold + italic;// or normal + SIOUXSettings.leftpixel = 15; + // SIOUXSettings.fontface = bold + italic;// or normal SIOUXSettings.asktosaveonclose = 0; - + short bas = screenBits.bottom; - short droit = screenBits.right; - SIOUXSettings.columns = (short)(2.+(float)droit/8.); - SIOUXSettings.rows = (short)(10. + (float)bas/18.); - SIOUXSetTitle("\pfreefem+ line output"); //marche pas!! + short droit = screenBits.right; + SIOUXSettings.columns = (short)(2. + (float)droit / 8.); + SIOUXSettings.rows = (short)(10. + (float)bas / 18.); + SIOUXSetTitle("\pfreefem+ line output"); // marche pas!! SIOUXSettings.fontface = normal; - SIOUXSettings.fontid = 22;// courier; + SIOUXSettings.fontid = 22; // courier; SIOUXSettings.fontsize = 10; cout << "Initmac" << endl; - - #define INSTALL(event, handler) \ - AEInstallEventHandler(kCoreEventClass, event, handler, 0, false) - // AEC, changed to use the correct handler procs -// INSTALL (kAEOpenApplication, NewAEEventHandlerUPP(DoOpenApp)); -// INSTALL (kAEReopenApplication, NewAEEventHandlerUPP(DoReopenApp)); - INSTALL (kAEOpenDocuments, NewAEEventHandlerUPP(DoOpenDocument)); - #undef INSTALL +#define INSTALL(event, handler) AEInstallEventHandler(kCoreEventClass, event, handler, 0, false) + // AEC, changed to use the correct handler procs + // INSTALL (kAEOpenApplication, NewAEEventHandlerUPP(DoOpenApp)); + // INSTALL (kAEReopenApplication, NewAEEventHandlerUPP(DoReopenApp)); + INSTALL(kAEOpenDocuments, NewAEEventHandlerUPP(DoOpenDocument)); +#undef INSTALL } class InitilisationMac { static int init; - public: - InitilisationMac(){ InitMac();} + + public: + InitilisationMac( ) { InitMac( ); } }; -static InitilisationMac Initmac; // to call InitMac +static InitilisationMac Initmac; // to call InitMac -int getprog(char* fn,int argc, char** argvptr) -{ - OSErr anErr; +int getprog(char *fn, int argc, char **argvptr) { + OSErr anErr; NavDialogOptions dialogOptions; NavReplyRecord reply; - - anErr=NavGetDefaultDialogOptions(& dialogOptions); - if( anErr != noErr) return -1; - anErr =NavChooseFile(0,&reply,&dialogOptions,0,0,0,0,0) ; - if (anErr == noErr && reply.validRecord) - { - // Deal with multiple file selection - long count; - - anErr = AECountItems(&(reply.selection), &count); - // Set up index for file list - if (anErr == noErr) - { - long index; - - for (index = 1; index <= count; index++) - { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec documentFSSpec; - - // Get a pointer to selected file - anErr = AEGetNthPtr(&(reply.selection), index, - typeFSS, &theKeyword, - &actualType,&documentFSSpec, - sizeof(documentFSSpec), - &actualSize); - if (anErr == noErr) - { - anErr = HSetVol(0,documentFSSpec.vRefNum,documentFSSpec.parID); - pStrCopy(documentFSSpec.name, fn); - } - } - } - // Dispose of NavReplyRecord, resources, descriptors - anErr = NavDisposeReply(&reply); - - } - else return 0; // erreur cancel - return (2); + + anErr = NavGetDefaultDialogOptions(&dialogOptions); + if (anErr != noErr) return -1; + anErr = NavChooseFile(0, &reply, &dialogOptions, 0, 0, 0, 0, 0); + if (anErr == noErr && reply.validRecord) { + // Deal with multiple file selection + long count; + + anErr = AECountItems(&(reply.selection), &count); + // Set up index for file list + if (anErr == noErr) { + long index; + + for (index = 1; index <= count; index++) { + AEKeyword theKeyword; + DescType actualType; + Size actualSize; + FSSpec documentFSSpec; + + // Get a pointer to selected file + anErr = AEGetNthPtr(&(reply.selection), index, typeFSS, &theKeyword, &actualType, &documentFSSpec, sizeof(documentFSSpec), &actualSize); + if (anErr == noErr) { + anErr = HSetVol(0, documentFSSpec.vRefNum, documentFSSpec.parID); + pStrCopy(documentFSSpec.name, fn); + } + } + } + // Dispose of NavReplyRecord, resources, descriptors + anErr = NavDisposeReply(&reply); + + } else + return 0; // erreur cancel + return (2); } #ifdef FREEFEM +void thisexit( ) { myexit( ); } - void thisexit(){ myexit();} - -int main (int argc, char **argv) -{ - char *prog; - char fname[256]; - SIOUXSettings.sleep=1; - argc = getprog (fname, argc, argv); +int main(int argc, char **argv) { + char *prog; + char fname[256]; + SIOUXSettings.sleep = 1; + argc = getprog(fname, argc, argv); atexit(thisexit); - NEW_HANDLER (); // see dependent system files ({pc,x,mac}rgraph.{h,cpp}) - + NEW_HANDLER( ); // see dependent system files ({pc,x,mac}rgraph.{h,cpp}) int OPTION = 0; - if (argc == 2) - { - initgraphique(); - if(0==setjmp(environ)) - { myenviron=1; - compile (fname); - // cout << "No Error" << endl; - } - myenviron = 0; + if (argc == 2) { + initgraphique( ); + if (0 == setjmp(environ)) { + myenviron = 1; + compile(fname); + // cout << "No Error" << endl; } - else - printf ("To launch freefem you must type freefem and a file name\n"); - + myenviron = 0; + } else + printf("To launch freefem you must type freefem and a file name\n"); + return 0; } #else -extern int mymain(int argc,char **argv); -string StrVersionNumber(); +extern int mymain(int argc, char **argv); +string StrVersionNumber( ); + +int main(int argc, char **argv) { + SIOUXUseWaitNextEvent = true; + SIOUXSettings.sleep = 0; + char *wn = new char[256]; + for (int i = 0; i < 256; i++) wn[i] = 0; + strcpy(wn, " -- FreeFem++ "); + strcat(wn, StrVersionNumber( ).c_str( )); + + SIOUXSetTitle((unsigned char *)wn); + int ret = 15; + try { + ret = mymain(argc, argv); + } catch (...) { + cerr << "catch exception ???"; + } catch (Error &err) { + cerr << err.what( ) << endl; + } -int main (int argc, char **argv) -{ - SIOUXUseWaitNextEvent = true; - SIOUXSettings.sleep=0; - char * wn = new char [256]; - for (int i=0;i<256;i++) - wn[i] = 0; - strcpy(wn," -- FreeFem++ "); - strcat(wn,StrVersionNumber().c_str()); - - SIOUXSetTitle((unsigned char *) wn); - int ret=15; - try { - ret=mymain(argc,argv);} - catch( ...) { cerr << "catch exception ???";} - catch( Error & err) { - cerr << err.what() << endl; - } - - return ret; + return ret; } - void myexit(int i) - { - exit(i); - - } - +void myexit(int i) { exit(i); } + #endif -void coutmode(short i) -{ - cout << flush; - cerr << flush; - // if(i)(**(SIOUXTextWindow->edit)).txFace = 0; - // else (**(SIOUXTextWindow->edit)).txFace = 1; -;} - -void message(char *s) -{ - printf("%s \n", s); +void coutmode(short i) { + cout << flush; + cerr << flush; + // if(i)(**(SIOUXTextWindow->edit)).txFace = 0; + // else (**(SIOUXTextWindow->edit)).txFace = 1; + ; } -void erreur(char *s) -{ - cout << endl; - cerr << "##Fatal error :" << s << endl << "exit(1)" << endl; - exit(1); +void message(char *s) { printf("%s \n", s); } + +void erreur(char *s) { + cout << endl; + cerr << "##Fatal error :" << s << endl << "exit(1)" << endl; + exit(1); } -void *safecalloc(long nb, long size) -{ - void* p=NULL; +void *safecalloc(long nb, long size) { + void *p = NULL; p = calloc(nb, size); - if (p == NULL) - erreur("Out of Memory!\n"); + if (p == NULL) erreur("Out of Memory!\n"); return p; } -void safefree(void** f) -{ - if(*f) - { - free(*f); - *f=NULL; +void safefree(void **f) { + if (*f) { + free(*f); + *f = NULL; } } -void initgraphique(void) -{ - if(INITGRAPH) return; +void initgraphique(void) { + if (INITGRAPH) return; #if TARGET_API_MAC_CARBON - BitMap screenBitMap; - Rect screenBits; - Cursor theArrow; - GetQDGlobalsScreenBits(&screenBitMap); - screenBits = screenBitMap.bounds; - SetCursor(GetQDGlobalsArrow(&theArrow)); + BitMap screenBitMap; + Rect screenBits; + Cursor theArrow; + GetQDGlobalsScreenBits(&screenBitMap); + screenBits = screenBitMap.bounds; + SetCursor(GetQDGlobalsArrow(&theArrow)); #else - Rect screenBits = qd.screenBits.bounds; - SetCursor(&qd.arrow); + Rect screenBits = qd.screenBits.bounds; + SetCursor(&qd.arrow); #endif /* TARGET_API_MAC_CARBON */ - boundsRect.top = 45; - boundsRect.left = (short) (15 + (0.35 * screenBits.right)); - boundsRect.bottom = screenBits.bottom - 25; - boundsRect.right = screenBits.right- 25; - if((boundsRect.bottom - boundsRect.top) < (boundsRect.right - boundsRect.left)) - boundsRect.right = boundsRect.left + boundsRect.bottom - boundsRect.top; - else - boundsRect.bottom = boundsRect.top + boundsRect.right - boundsRect.left; - grafWindow0=NewCWindow(0, &boundsRect, "\pFreeFem Graphics",true, 8, NULL, true, 0); - ShowWindow(grafWindow0); - BringToFront(grafWindow0); - SelectWindow(grafWindow0); - SetPortWindowPort(grafWindow0); - GetPort(&grafPort0); - height = boundsRect.bottom - boundsRect.top - 10; - width = boundsRect.right - boundsRect.left -10; - aspx = boundsRect.right - boundsRect.left -10; - aspy = boundsRect.bottom - boundsRect.top - 10; - carre = aspx == aspy; - lacouleur = getcolor(); - CrossCurseur = GetCursor(crossCursor); - WatchCurseur = GetCursor(watchCursor); - GetQDGlobalsWhite(&white); - GetQDGlobalsBlack(&black); - - //if( (**(wgRecord0.port.portPixMap)).pixelSize>7) - nbcolor= 256; - //else - // nbcolor= 2; - - - ncolortable =0; - LastColor=2;// En couleur pas defaul - colortable=0; - SetColorTable(2+6); + boundsRect.top = 45; + boundsRect.left = (short)(15 + (0.35 * screenBits.right)); + boundsRect.bottom = screenBits.bottom - 25; + boundsRect.right = screenBits.right - 25; + if ((boundsRect.bottom - boundsRect.top) < (boundsRect.right - boundsRect.left)) + boundsRect.right = boundsRect.left + boundsRect.bottom - boundsRect.top; + else + boundsRect.bottom = boundsRect.top + boundsRect.right - boundsRect.left; + grafWindow0 = NewCWindow(0, &boundsRect, "\pFreeFem Graphics", true, 8, NULL, true, 0); + ShowWindow(grafWindow0); + BringToFront(grafWindow0); + SelectWindow(grafWindow0); + SetPortWindowPort(grafWindow0); + GetPort(&grafPort0); + height = boundsRect.bottom - boundsRect.top - 10; + width = boundsRect.right - boundsRect.left - 10; + aspx = boundsRect.right - boundsRect.left - 10; + aspy = boundsRect.bottom - boundsRect.top - 10; + carre = aspx == aspy; + lacouleur = getcolor( ); + CrossCurseur = GetCursor(crossCursor); + WatchCurseur = GetCursor(watchCursor); + GetQDGlobalsWhite(&white); + GetQDGlobalsBlack(&black); + + // if( (**(wgRecord0.port.portPixMap)).pixelSize>7) + nbcolor = 256; + // else + // nbcolor= 2; + + ncolortable = 0; + LastColor = 2; // En couleur pas defaul + colortable = 0; + SetColorTable(2 + 6); // TextFont(fontNum); - TextSize(9); // small size - INITGRAPH = 1; - - + TextSize(9); // small size + INITGRAPH = 1; } -static RGBColor DefColorMacOs( int k,int nb,bool hsv, bool grey,int nbcolors,float *colors) -{ - RGBColor C; - float r,g,b; - extern void DefColor(float & r, float & g, float & b, - int k,int nb,bool hsv, bool grey,int nbcolors,float *colors); - DefColor(r,g,b, k,nb,hsv,grey,nbcolors,colors); - C.red=65535*r; - C.green=65535*g; - C.blue=65535*b; - return C; -} - -void SetColorTable1(int nb,bool hsv,int nbcolors,float *colors) -{ - static bool greyo = !grey; - static float * colorso =0; - if(!INITGRAPH) return; - if (ncolortable == nb && greyo == grey && colorso == colors ) return;// optim - greyo = grey; - colorso=colors; - if (nbcolor && nb>2) - { - if(colortable) delete [] colortable; - colortable = new RGBColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - for (int i0=0;i0%s\n",currx*svg_s,curry*svg_s,string); + if (svgfile) { + fprintf(svgfile, "%s\n", currx * svg_s, curry * svg_s, string); } -} +} -int LaCouleur(){return lacouleur;} +int LaCouleur( ) { return lacouleur; } -void couleur(int c) -{ - if ( lacouleur == c) // small optim +void couleur(int c) { + if (lacouleur == c) // small optim return; - c= c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc - lacouleur =c; - if ( c == 0 ) + c = c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc + lacouleur = c; + if (c == 0) ForeColor(30); - else if (ncolortable>3 && c < ncolortable && c >=0 ) - RGBForeColor(colortable+c); - else - ForeColor(33); - if (psfile) - { - float r=1,g=1,b=1; + else if (ncolortable > 3 && c < ncolortable && c >= 0) + RGBForeColor(colortable + c); + else + ForeColor(33); + if (psfile) { + float r = 1, g = 1, b = 1; if (colortable) { - if (c>0 && c < ncolortable) - { - r = (float) colortable[c].red /65535.F; - g = (float) colortable[c].green /65535.F; - b = (float) colortable[c].blue /65535.F; - } - } - else if (c!=0) - r=g=b=0; - - fprintf(psfile,"%.3f %.3f %.3f C\n",r,g,b); + if (c > 0 && c < ncolortable) { + r = (float)colortable[c].red / 65535.F; + g = (float)colortable[c].green / 65535.F; + b = (float)colortable[c].blue / 65535.F; + } + } else if (c != 0) + r = g = b = 0; + + fprintf(psfile, "%.3f %.3f %.3f C\n", r, g, b); + } + // add by fujiwara + if (pdffile) { + pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; + pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; + } + if (svgfile) { + svg_r = static_cast< int >(r * 256); + svg_g = static_cast< int >(g * 256); + svg_b = static_cast< int >(b * 256); } - // add by fujiwara - if( pdffile ){ - pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; - pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; - } - if( svgfile ){ - svg_r = static_cast(r*256); - svg_g = static_cast(g*256); - svg_b = static_cast(b*256); - } - } -int InRecScreen(float x1, float y1,float x2, float y2) -{ - float xi = Min(x1,x2),xa=Max(x1,x2); - float yi = Min(y1,y2),ya=Max(y1,y2); +int InRecScreen(float x1, float y1, float x2, float y2) { + float xi = Min(x1, x2), xa = Max(x1, x2); + float yi = Min(y1, y2), ya = Max(y1, y2); return (xa >= rxmin) && (xi <= rxmax) && (ya >= rymin) && (yi <= rymax); } -int InPtScreen( float x, float y) -{ - return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); -} +int InPtScreen(float x, float y) { return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax); } -void penthickness(int pepais) -{ - PenSize(pepais,pepais); - if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais); +void penthickness(int pepais) { + PenSize(pepais, pepais); + if (psfile) fprintf(psfile, "%d setlinewidth\n", pepais); // add by fujiwara - if ( pdffile ){ - pdffile_content << pepais << " w" << std::endl; + if (pdffile) { + pdffile_content << pepais << " w" << std::endl; } - if ( svgfile ){ - svg_lw = pepais; + if (svgfile) { + svg_lw = pepais; } } -void cadre(float xmin,float xmax,float ymin,float ymax) -{ +void cadre(float xmin, float xmax, float ymin, float ymax) { rxmin = xmin; rxmax = xmax; rymin = ymin; @@ -761,32 +677,27 @@ void cadre(float xmin,float xmax,float ymin,float ymax) echx = aspx / (xmax - xmin); echy = aspy / (ymax - ymin); } -void getcadre(float &xmin,float &xmax,float &ymin,float &ymax) -{ +void getcadre(float &xmin, float &xmax, float &ymin, float &ymax) { xmin = rxmin; xmax = rxmax; ymin = rymin; ymax = rymax; - } -void cadreortho(float centrex, float centrey, float rayon) -{ - int xasp,yasp, getmaxx, getmaxy; - - getmaxx = xasp =aspx; getmaxy = yasp = aspy; - - if (getmaxx * (float)xasp > getmaxy * (float)yasp) - { +void cadreortho(float centrex, float centrey, float rayon) { + int xasp, yasp, getmaxx, getmaxy; + + getmaxx = xasp = aspx; + getmaxy = yasp = aspy; + + if (getmaxx * (float)xasp > getmaxy * (float)yasp) { rymin = centrey - rayon; rymax = centrey + rayon; - echy= getmaxy / (2 * rayon); - echx= (echy * xasp) / yasp; - rxmin= centrex - getmaxx / (2 * echx); - rxmax= centrex + getmaxx / (2 * echx); - } - else - { + echy = getmaxy / (2 * rayon); + echx = (echy * xasp) / yasp; + rxmin = centrex - getmaxx / (2 * echx); + rxmax = centrex + getmaxx / (2 * echx); + } else { rxmin = centrex - rayon; rxmax = centrex + rayon; echx = getmaxx / (2 * rayon); @@ -796,490 +707,431 @@ void cadreortho(float centrex, float centrey, float rayon) } } -int scalx(float x) -{ - return int((x - rxmin) * echx); -} +int scalx(float x) { return int((x - rxmin) * echx); } -int scaly(float y) -{ - return int((rymax - y) * echy); -} +int scaly(float y) { return int((rymax - y) * echy); } -float scali(int i) -{ - return i/echx + rxmin; -} -float scalj(int j) -{ - return -j/echy + rymax; -} +float scali(int i) { return i / echx + rxmin; } +float scalj(int j) { return -j / echy + rymax; } -void pointe(float x, float y) -{ +void pointe(float x, float y) { int newx = scalx(x), newy = scaly(y); putpixel(newx, newy, lacouleur); - if (psfile) - fprintf(psfile,"%d %d P\n", newx, height-newy); + if (psfile) fprintf(psfile, "%d %d P\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - pdffile_content << newx*pdf_s << ' ' << (height-newy)*pdf_s << ' ' - << pdf_s << ' ' << pdf_s << " re f" << std::endl; + if (pdffile) { + pdffile_content << newx * pdf_s << ' ' << (height - newy) * pdf_s << ' ' << pdf_s << ' ' << pdf_s << " re f" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, svg_s, svg_s, svg_r, svg_g, svg_b, 1); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, svg_s, svg_s, svg_r, svg_g, svg_b, + 1); } } -void rmoveto(float x, float y) -{ +void rmoveto(float x, float y) { int newx = scalx(x), newy = scaly(y); - MoveTo(newx,newy); - if (psfile) - fprintf(psfile,"%d %d M\n", newx, height-newy); + MoveTo(newx, newy); + if (psfile) fprintf(psfile, "%d %d M\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - // should be added + if (pdffile) { + // should be added } - if ( svgfile ){ - // should be added + if (svgfile) { + // should be added } } -void rlineto(float x, float y) -{ +void rlineto(float x, float y) { int newx = scalx(x), newy = scaly(y); - LineTo(newx,newy); - if (psfile) - fprintf(psfile,"%d %d L\n", newx,height-newy); + LineTo(newx, newy); + if (psfile) fprintf(psfile, "%d %d L\n", newx, height - newy); // add by fujiwara - if ( pdffile ){ - pdffile_content << currx*pdf_s << ' ' << (height-curry)*pdf_s << " m " - << newx*pdf_s << ' ' << (height-newy)*pdf_s << " l S" << std::endl; + if (pdffile) { + pdffile_content << currx * pdf_s << ' ' << (height - curry) * pdf_s << " m " << newx * pdf_s << ' ' << (height - newy) * pdf_s << " l S" << std::endl; } - if ( svgfile ){ - fprintf(svgfile,"\n", - currx*svg_s, curry*svg_s, newx*svg_s, newy*svg_s, svg_r, svg_g, svg_b, svg_lw); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, newx * svg_s, newy * svg_s, svg_r, svg_g, + svg_b, svg_lw); } - } -void raffpoly(int n, float *poly) -{ +void raffpoly(int n, float *poly) { PolyHandle thePoly; int i; - thePoly =OpenPoly(); - MoveTo(scalx(poly[0]),scaly( poly[1])); - for(i=1; i\n", svg_r, svg_g, svg_b, svg_lw, svg_r, svg_g, svg_b); } - if ( svgfile ) - { - fprintf(svgfile, "\n", - svg_r,svg_g,svg_b, svg_lw, svg_r,svg_g,svg_b); - } } -int pStrCopy (StringPtr p1, char * p2) +int pStrCopy(StringPtr p1, char *p2) /* copies a pascal string `p1 into a C string */ { - int len,i; - - len = (*p1++) %256; - for(i=1;i<=len;i++) *p2++=*p1++; - *p2 = 0; - return 0; -} - - - + int len, i; + len = (*p1++) % 256; + for (i = 1; i <= len; i++) *p2++ = *p1++; + *p2 = 0; + return 0; +} -int execute(const char* what) -{ - cout << " sorry no execute on MacOs we skip "<< what<where)) - { - closegraphique(); - cout << "Fin (fermeture fenetre graphique) " <portRect)); - ZoomWindow(whichWindow, inZoomIn, true); - InitCursor(); - } - break; - - case inZoomOut: -/* if (ours(whichWindow)) - { - SetCursor(&waitCursor); SetPort(whichWindow); - EraseRect(&(whichWindow->portRect)); - ZoomWindow(whichWindow, inZoomOut, true); - if(whichWindow == editWindow) - MyZoomWindow(whichWindow); - InitCursor(); - }*/ - break; - - case inMenuBar: -// return(DoCommand(MenuSelect(myEvent->where))); - break; - - case inSysWindow: - //SystemClick(myEvent, whichWindow); - break; - - case inDrag: - if (ours(whichWindow)) - { - SetPortWindowPort(whichWindow); - GetPort(&grafPort0); - - DragWindow(whichWindow, myEvent->where, 0); - } - break; - - case inGrow: - //if (ours(whichWindow)) - // {MyGrowWindow(whichWindow, myEvent->where);} - break; - - case inContent: - wasactive = (whichWindow == FrontWindow()); - if(!wasactive) { SelectWindow(whichWindow); - // if (ours(whichWindow) && MacReDraw ) (* MacReDraw)(); - } - else if (ours(whichWindow)) - { SetPortWindowPort(whichWindow); GetPort(&grafPort0); - - while (Button()) ; - return 0; - } - break; - } -return 1; -} -char HandleEvent(EventRecord & myEvent) -{ - WindowPtr whichWindow=NULL; - short windowPart; - - char char1=0; - switch (myEvent.what) { - case mouseDown: - windowPart = FindWindow(myEvent.where, &whichWindow); - if( DoMouseDown(windowPart, whichWindow, &myEvent) ==0) - char1= 251; - break; - -// -// -// case keyDown: - case keyUp: - case autoKey: - { - - windowPart = FindWindow(myEvent.where, &whichWindow); - if((whichWindow==grafWindow0) /* && (inContent == windowPart)*/) - { if (grafWindow0 != FrontWindow()) { - SelectWindow(whichWindow); - SetPortWindowPort(whichWindow); GetPort(&grafPort0); - - } - char1 = (myEvent.message & 127L); - - } - break;} - case updateEvt: - if (ours((WindowPtr) myEvent.message)) { - BeginUpdate((WindowPtr) myEvent.message); - EndUpdate((WindowPtr) myEvent.message); - } - break; - + switch (windowPart) { + case inGoAway: + if (ours(whichWindow)) + if (TrackGoAway(whichWindow, myEvent->where)) { + closegraphique( ); + cout << "Fin (fermeture fenetre graphique) " << endl; + exit(0); + // HideWindow(whichWindow); + } + break; + + case inZoomIn: + if (ours(whichWindow)) { + // SetCursor(&waitCursor); + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + reffecran( ); + // EraseRect(&(whichWindow->portRect)); + ZoomWindow(whichWindow, inZoomIn, true); + InitCursor( ); + } + break; + + case inZoomOut: + /* if (ours(whichWindow)) + { + SetCursor(&waitCursor); SetPort(whichWindow); + EraseRect(&(whichWindow->portRect)); + ZoomWindow(whichWindow, inZoomOut, true); + if(whichWindow == editWindow) + MyZoomWindow(whichWindow); + InitCursor(); + }*/ + break; + + case inMenuBar: + // return(DoCommand(MenuSelect(myEvent->where))); + break; + + case inSysWindow: + // SystemClick(myEvent, whichWindow); + break; + + case inDrag: + if (ours(whichWindow)) { + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + + DragWindow(whichWindow, myEvent->where, 0); + } + break; + + case inGrow: + // if (ours(whichWindow)) + // {MyGrowWindow(whichWindow, myEvent->where);} + break; + + case inContent: + wasactive = (whichWindow == FrontWindow( )); + if (!wasactive) { + SelectWindow(whichWindow); + // if (ours(whichWindow) && MacReDraw ) (* MacReDraw)(); + } else if (ours(whichWindow)) { + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + + while (Button( )); + return 0; + } + break; + } + return 1; } +char HandleEvent(EventRecord &myEvent) { + WindowPtr whichWindow = NULL; + short windowPart; + + char char1 = 0; + switch (myEvent.what) { + case mouseDown: + windowPart = FindWindow(myEvent.where, &whichWindow); + if (DoMouseDown(windowPart, whichWindow, &myEvent) == 0) char1 = 251; + break; + + // + // + // case keyDown: + case keyUp: + case autoKey: { + + windowPart = FindWindow(myEvent.where, &whichWindow); + if ((whichWindow == grafWindow0) /* && (inContent == windowPart)*/) { + if (grafWindow0 != FrontWindow( )) { + SelectWindow(whichWindow); + SetPortWindowPort(whichWindow); + GetPort(&grafPort0); + } + char1 = (myEvent.message & 127L); + } + break; + } + case updateEvt: + if (ours((WindowPtr)myEvent.message)) { + BeginUpdate((WindowPtr)myEvent.message); + EndUpdate((WindowPtr)myEvent.message); + } + break; + } return char1; } -void viderbuff(){ - QDFlushPortBuffer(grafPort0,0); -} - -char Getijc(int & x,int & y) -{ - char char1=0; - showgraphic(); - EventRecord myEvent; - int flag=1; - HLock( (Handle) WatchCurseur); - SetCursor(*CrossCurseur); - HUnlock( (Handle) WatchCurseur); - SelectWindow(grafWindow0); - while (char1==0) { - if (GetNextEvent(everyEvent, &myEvent) /* ,OxFFFFFFFF,h)*/) - char1=HandleEvent(myEvent); - } - GlobalToLocal( & myEvent.where); - x = myEvent.where.h; - y = myEvent.where.v; - HLock( (Handle) WatchCurseur); - SetCursor(*WatchCurseur); - HUnlock( (Handle) WatchCurseur); - - // printf("\t\t x = %d y = %d c=%d\n", x,y,char1); +void viderbuff( ) { QDFlushPortBuffer(grafPort0, 0); } + +char Getijc(int &x, int &y) { + char char1 = 0; + showgraphic( ); + EventRecord myEvent; + int flag = 1; + HLock((Handle)WatchCurseur); + SetCursor(*CrossCurseur); + HUnlock((Handle)WatchCurseur); + SelectWindow(grafWindow0); + while (char1 == 0) { + if (GetNextEvent(everyEvent, &myEvent) /* ,OxFFFFFFFF,h)*/) char1 = HandleEvent(myEvent); + } + GlobalToLocal(&myEvent.where); + x = myEvent.where.h; + y = myEvent.where.v; + HLock((Handle)WatchCurseur); + SetCursor(*WatchCurseur); + HUnlock((Handle)WatchCurseur); + + // printf("\t\t x = %d y = %d c=%d\n", x,y,char1); return char1; - - - } -char Getxyc(float &x,float &y) -{ +char Getxyc(float &x, float &y) { char c; - int i,j; - c = Getijc( i,j); + int i, j; + c = Getijc(i, j); x = scali(i); y = scalj(j); return c; } - -void rattente(int waitm) -{ int i,j; - char c=0; - if(waitm) c = Getijc( i,j); - if ( c == 3) {cout << "rattente: ^c => abort " << endl;closegraphique();exit(1);}// ^c => exit -/* you may prefer to use carriage return to move to the next graph */ -/* getc(stdin); -*/ -// if(waitm) while(!Button()){ }; +void rattente(int waitm) { + int i, j; + char c = 0; + if (waitm) c = Getijc(i, j); + if (c == 3) { + cout << "rattente: ^c => abort " << endl; + closegraphique( ); + exit(1); + } // ^c => exit + /* you may prefer to use carriage return to move to the next graph */ + /* getc(stdin); + */ + // if(waitm) while(!Button()){ }; } -void GetSizeScreen(int & ix,int &iy); -void GetScreenSize(int & ix,int &iy) -{ - ix = width ; - iy = height; +void GetSizeScreen(int &ix, int &iy); +void GetScreenSize(int &ix, int &iy) { + ix = width; + iy = height; } - - -void openPS(const char *filename ) -{ +void openPS(const char *filename) { char ffff[32]; - int count=0; - if(psfile_save) closePS(); + int count = 0; + if (psfile_save) closePS( ); time_t t_loc; - float s=0.5; - const int shiftx=50,shifty=50; - // char username[10]; + float s = 0.5; + const int shiftx = 50, shifty = 50; + // char username[10]; time(&t_loc); bool notfound; - if( !filename) - do { + if (!filename) do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.ps",count++); - volatile int r= stat(ffff,&buf) ; - notfound = r !=0; - if(count>1000) break; - } while ( !notfound ); - - psfile=fopen(filename?filename:ffff,"w"); - - if(psfile==0) {printf("Erreur %s errno %d\d",filename?filename:ffff,errno);exit(1);} - if(psfile) { - fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); - fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); - fprintf(psfile,"%%%%Pages: 1\n"); - fprintf(psfile,"%%%%BoundingBox: %d %d %d %d\n",shiftx,shifty,int(shiftx+width*s),int(shifty+height*s)); - fprintf(psfile,"%%%%EndComments\n"); - fprintf(psfile," /L { lineto currentpoint stroke newpath moveto} def\n"); - fprintf(psfile," /M { moveto } def\n"); - fprintf(psfile," /C {setrgbcolor} def\n"); - fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); - fprintf(psfile," %d %d translate \n",shiftx,shifty); - fprintf(psfile," %f %f scale \n",s,s); - fprintf(psfile," 0 %d 0 %d rec clip newpath\n",int(width),int(height)); - fprintf(psfile," /Helvetica findfont 10 scalefont setfont\n"); - fprintf(psfile," /S { show} def\n"); - fprintf(psfile," /bF { mark} def \n"); - fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); - fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); - - fprintf(psfile," 1 setlinewidth\n"); - psfile_save=psfile; + sprintf(ffff, "rgraph_%.3d.ps", count++); + volatile int r = stat(ffff, &buf); + notfound = r != 0; + if (count > 1000) break; + } while (!notfound); + + psfile = fopen(filename ? filename : ffff, "w"); + + if (psfile == 0) { + printf("Erreur %s errno %d\d", filename ? filename : ffff, errno); + exit(1); + } + if (psfile) { + fprintf(psfile, "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n", "user"); + fprintf(psfile, "%%%%CreationDate: %s", ctime(&t_loc)); + fprintf(psfile, "%%%%Pages: 1\n"); + fprintf(psfile, "%%%%BoundingBox: %d %d %d %d\n", shiftx, shifty, int(shiftx + width * s), int(shifty + height * s)); + fprintf(psfile, "%%%%EndComments\n"); + fprintf(psfile, " /L { lineto currentpoint stroke newpath moveto} def\n"); + fprintf(psfile, " /M { moveto } def\n"); + fprintf(psfile, " /C {setrgbcolor} def\n"); + fprintf(psfile, " /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); + fprintf(psfile, " %d %d translate \n", shiftx, shifty); + fprintf(psfile, " %f %f scale \n", s, s); + fprintf(psfile, " 0 %d 0 %d rec clip newpath\n", int(width), int(height)); + fprintf(psfile, " /Helvetica findfont 10 scalefont setfont\n"); + fprintf(psfile, " /S { show} def\n"); + fprintf(psfile, " /bF { mark} def \n"); + fprintf(psfile, " /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); + fprintf(psfile, " /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); + + fprintf(psfile, " 1 setlinewidth\n"); + psfile_save = psfile; } } -void closePS(void) -{ - if(psfile_save) { - fprintf(psfile_save,"showpage\n"); +void closePS(void) { + if (psfile_save) { + fprintf(psfile_save, "showpage\n"); fclose(psfile_save); - } - - psfile=0; - psfile_save=0; - + } + + psfile = 0; + psfile_save = 0; } //---------------------------------------------------------------------- // add by fujiwara //---------------------------------------------------------------------- -void openPDF(const char *filename ) -{ - if(pdffile) closePDF(); +void openPDF(const char *filename) { + if (pdffile) closePDF( ); - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } - pdffile_name = new char [ strlen(filename)+1 ]; - strcpy( pdffile_name, filename ); + pdffile_name = new char[strlen(filename) + 1]; + strcpy(pdffile_name, filename); - pdffile_content.str(""); // clear - pdffile_content.clear( std::stringstream::goodbit ); + pdffile_content.str(""); // clear + pdffile_content.clear(std::stringstream::goodbit); - pdffile_content.setf( std::ios::fixed ); - pdffile_content.precision( 3 ); + pdffile_content.setf(std::ios::fixed); + pdffile_content.precision(3); const int widthA4PDF = 596; - pdf_s = static_cast(widthA4PDF) / width; + pdf_s = static_cast< float >(widthA4PDF) / width; pdffile = true; - pdffile_content << "q" << std::endl; // gsave - + pdffile_content << "q" << std::endl; // gsave + return; } -void closePDF(void) -{ - if(pdffile) { +void closePDF(void) { + if (pdffile) { - std::string PDFTitle = "plot() by FreeFem++"; - std::string AppName = "FreeFem++ v" + StrVersionNumber(); + std::string PDFTitle = "plot() by FreeFem++"; + std::string AppName = "FreeFem++ v" + StrVersionNumber( ); - SimplePDF_FF pdf( pdffile_name, PDFTitle.c_str(), AppName.c_str() ); + SimplePDF_FF pdf(pdffile_name, PDFTitle.c_str( ), AppName.c_str( )); - const int widthPDF = static_cast( width * pdf_s ); - const int heightPDF = static_cast( height * pdf_s ); + const int widthPDF = static_cast< int >(width * pdf_s); + const int heightPDF = static_cast< int >(height * pdf_s); - pdffile_content << "Q" << std::endl; + pdffile_content << "Q" << std::endl; - pdf.addPage( pdffile_content, widthPDF, heightPDF ); + pdf.addPage(pdffile_content, widthPDF, heightPDF); - pdffile = false; + pdffile = false; } - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } return; } -void openSVG(const char *filename ) -{ - if(svgfile_save) closeSVG(); +void openSVG(const char *filename) { + if (svgfile_save) closeSVG( ); - const int widthA4PS = 596; - //const int heightA4PS = 842; - svg_s = static_cast(widthA4PS)/width; + const int widthA4PS = 596; + // const int heightA4PS = 842; + svg_s = static_cast< double >(widthA4PS) / width; char ffff[32]; int count = 0; - if(!filename){ + if (!filename) { bool notfound; do { struct stat buf; - sprintf(ffff,"rgraph_%.3d.svg",count++); - volatile int r = stat(ffff,&buf) ; + sprintf(ffff, "rgraph_%.3d.svg", count++); + volatile int r = stat(ffff, &buf); notfound = (r != 0); - if( count > 1000 ) break; - } while ( !notfound ); - } - - const char *fsvg (filename?filename:ffff); - - svgfile=fopen(fsvg,"w"); - - if(svgfile) { - svgfile_save=svgfile; - fprintf(svgfile,"\n\n"); - fprintf(svgfile,"\n\n", StrVersionNumber().c_str()); - fprintf(svgfile,"\n", - static_cast(width*svg_s), static_cast(height*svg_s)); + if (count > 1000) break; + } while (!notfound); } - else - { + + const char *fsvg(filename ? filename : ffff); + + svgfile = fopen(fsvg, "w"); + + if (svgfile) { + svgfile_save = svgfile; + fprintf(svgfile, "\n\n"); + fprintf(svgfile, "\n\n", StrVersionNumber( ).c_str( )); + fprintf(svgfile, "\n", static_cast< int >(width * svg_s), static_cast< int >(height * svg_s)); + } else { cerr << " Err opening SVG file " << fsvg << endl; } return; } -void closeSVG(void) -{ - if(svgfile_save) { - fprintf(svgfile_save,"\n"); +void closeSVG(void) { + if (svgfile_save) { + fprintf(svgfile_save, "\n"); fclose(svgfile_save); } - svgfile_save=0; - svgfile=0; + svgfile_save = 0; + svgfile = 0; return; } @@ -1287,105 +1139,107 @@ void closeSVG(void) // add by fujiwara end //---------------------------------------------------------------------- - void Commentaire(const char * c) - { - if(psfile) { - fprintf(psfile,"%% %s\n",c); - } - // add by fujiwara - if( pdffile ) { - //fprintf(pdffile,"%% %s\n",c); - } - if( svgfile ) { - fprintf(svgfile,"%% %s\n",c); - } - }; - void NoirEtBlanc(int NB) - { - if(NB) LastColor=1; - else LastColor=ncolortable?ncolortable:2; +void Commentaire(const char *c) { + if (psfile) { + fprintf(psfile, "%% %s\n", c); } - - void MettreDansPostScript(int in) - { - if(in) psfile=psfile_save; - else psfile=0; - } // add by fujiwara - void MettreDansPDF(int in) // put into PDF - { - if(in) pdffile=true; - else pdffile=false; - } - void MettreDansSVG(int in) // put into SVG - { - if(in) svgfile=svgfile_save; - else svgfile=0; - } - -static void FillRect(float x0,float y0, float x1, float y1) - { - float r[8]; - r[0]=x0;r[1]=y0; - r[2]=x1;r[3]=y0; - r[4]=x1;r[5]=y1; - r[6]=x0;r[7]=y1; - fillpoly(4,r); - } - -float GetHeigthFont() -{ - FontInfo MyFontInfo; - GetFontInfo(&MyFontInfo); - int interligne = MyFontInfo.ascent + MyFontInfo.descent + MyFontInfo.leading; - return interligne*0.7/echy; + if (pdffile) { + // fprintf(pdffile,"%% %s\n",c); + } + if (svgfile) { + fprintf(svgfile, "%% %s\n", c); + } +}; +void NoirEtBlanc(int NB) { + if (NB) + LastColor = 1; + else + LastColor = ncolortable ? ncolortable : 2; +} + +void MettreDansPostScript(int in) { + if (in) + psfile = psfile_save; + else + psfile = 0; +} +// add by fujiwara +void MettreDansPDF(int in) // put into PDF +{ + if (in) + pdffile = true; + else + pdffile = false; +} +void MettreDansSVG(int in) // put into SVG +{ + if (in) + svgfile = svgfile_save; + else + svgfile = 0; } +static void FillRect(float x0, float y0, float x1, float y1) { + float r[8]; + r[0] = x0; + r[1] = y0; + r[2] = x1; + r[3] = y0; + r[4] = x1; + r[5] = y1; + r[6] = x0; + r[7] = y1; + fillpoly(4, r); +} +float GetHeigthFont( ) { + FontInfo MyFontInfo; + GetFontInfo(&MyFontInfo); + int interligne = MyFontInfo.ascent + MyFontInfo.descent + MyFontInfo.leading; + return interligne * 0.7 / echy; +} -int PutLevel(int lineno, float xf, int col) -{ - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - float xleft = xmax - (xmax-xmin)*0.1; - float ytop = ymax; - float ydelta = (ymax-ymin)/40; - ydelta=GetHeigthFont(); - xleft = xmax - 6*ydelta; - ytop -= ydelta*(col+2); +int PutLevel(int lineno, float xf, int col) { + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + float xleft = xmax - (xmax - xmin) * 0.1; + float ytop = ymax; + float ydelta = (ymax - ymin) / 40; + ydelta = GetHeigthFont( ); + xleft = xmax - 6 * ydelta; + ytop -= ydelta * (col + 2); couleur(col); - FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.); - rmoveto(xleft+ydelta*1.4,ytop+ydelta/4); + FillRect(xleft + ydelta / 8., ytop + ydelta / 8., xleft + ydelta * 7. / 8., ytop + ydelta * 7. / 8.); + rmoveto(xleft + ydelta * 1.4, ytop + ydelta / 4); char buf[30]; - sprintf(buf,"%g",xf); + sprintf(buf, "%g", xf); couleur(1); plotstring(buf); - return lineno; + return lineno; } - void ShowHelp(const char * s,int k) -{ - if(k) { +void ShowHelp(const char *s, int k) { + if (k) { MettreDansPostScript(0); - MettreDansPDF(0); // add by fujiwara - MettreDansSVG(0); // add by fujiwara + MettreDansPDF(0); // add by fujiwara + MettreDansSVG(0); // add by fujiwara couleur(1); - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + rmoveto(xmin + (xmax - xmin) / 100, ymax - (k) * (ymax - ymin) / 30); plotstring(s); MettreDansPostScript(1); - MettreDansPDF(1); // add by fujiwara - MettreDansSVG(1); // add by fujiwara - // couleur(1); + MettreDansPDF(1); // add by fujiwara + MettreDansSVG(1); // add by fujiwara + // couleur(1); } } - void setgrey(bool gg ){grey=gg;} - int getgrey(){ return grey;} +void setgrey(bool gg) { grey = gg; } +int getgrey( ) { return grey; } class Grid; -void SaveMesh(Grid &t){} -void SavePlot(int D, Grid& t, double *f){} -void SavePlot(int D, Grid& t, float *f){} - +void SaveMesh(Grid &t) {} +void SavePlot(int D, Grid &t, double *f) {} +void SavePlot(int D, Grid &t, float *f) {} diff --git a/src/Graphics/mode_open.hpp b/src/Graphics/mode_open.hpp index a9abcf0f0..d9f2ae287 100644 --- a/src/Graphics/mode_open.hpp +++ b/src/Graphics/mode_open.hpp @@ -1,10 +1,10 @@ -#ifndef MODE_OPEN_HPP -#define MODE_OPEN_HPP +#ifndef MODE_OPEN_HPP +#define MODE_OPEN_HPP #ifdef __WIN32__ -#define MODE_READ_BINARY "rb" -#define MODE_WRITE_BINARY "wb" +#define MODE_READ_BINARY "rb" +#define MODE_WRITE_BINARY "wb" #else -#define MODE_READ_BINARY "r" -#define MODE_WRITE_BINARY "w" +#define MODE_READ_BINARY "r" +#define MODE_WRITE_BINARY "w" #endif #endif diff --git a/src/Graphics/pdf.h b/src/Graphics/pdf.h index a5026626b..0c117f3d1 100644 --- a/src/Graphics/pdf.h +++ b/src/Graphics/pdf.h @@ -5,7 +5,7 @@ // ORG : Graduate School of Informatics, Kyoto University, Japan // AUTHOR : Hiroshi Fujiwara // E-MAIL : fujiwara@acs.i.kyoto-u.ac.jp -// +// // The newest version is avalilable at: // http://www-an.acs.i.kyoto-u.ac.jp/~fujiwara/ff++-programs // @@ -20,11 +20,11 @@ #include #include #include -#include // strlen -#include // exit +#include // strlen +#include // exit -//#define HAVE_ZLIB // need zlib : CC ***.cpp -lz -//#undef HAVE_ZLIB +// #define HAVE_ZLIB // need zlib : CC ***.cpp -lz +// #undef HAVE_ZLIB //---------------------------------------------------------------------- // Simple PDF class @@ -33,459 +33,436 @@ #include #include #include -#include // strlen -#include // exit - -class SimplePDF_FF -{ - int byte_offset; - std::list xref; - - struct OutlineItem { - int headPageObjectNumber; - char *label; - }; - std::list outline; - - const std::string filename; - const std::string DocumentTitle; - int page_obj_offset, page; - - std::string get_datetime() const - { - std::time_t now = std::time( NULL ); - const std::tm* lt = std::localtime(&now); - - std::stringstream s; - - s << std::setfill('0') << std::right // valid for all operations << - << "20" << std::setw(2) << lt->tm_year-100 - << std::setw(2) << lt->tm_mon+1 // setw() is reset at each ops << - << std::setw(2) << lt->tm_mday - << std::setw(2) << lt->tm_hour - << std::setw(2) << lt->tm_min - << std::setw(2) << lt->tm_sec; - - return s.str(); - } +#include // strlen +#include // exit + +class SimplePDF_FF { + int byte_offset; + std::list< int > xref; + + struct OutlineItem { + int headPageObjectNumber; + char *label; + }; + std::list< OutlineItem > outline; + + const std::string filename; + const std::string DocumentTitle; + int page_obj_offset, page; + + std::string get_datetime( ) const { + std::time_t now = std::time(NULL); + const std::tm *lt = std::localtime(&now); + + std::stringstream s; + + s << std::setfill('0') << std::right // valid for all operations << + << "20" << std::setw(2) << lt->tm_year - 100 << std::setw(2) << lt->tm_mon + 1 // setw() is reset at each ops << + << std::setw(2) << lt->tm_mday << std::setw(2) << lt->tm_hour << std::setw(2) << lt->tm_min << std::setw(2) << lt->tm_sec; + + return s.str( ); + } #ifdef HAVE_ZLIB - int deflate_compress( char* &buf, const std::string &Stream ) const; + int deflate_compress(char *&buf, const std::string &Stream) const; #endif -public: + public: + SimplePDF_FF(const char *const filename, const char *const title = "", const char *const AppName = ""); - SimplePDF_FF( const char *const filename, const char *const title = "", - const char *const AppName = "" ); + ~SimplePDF_FF( ); - ~SimplePDF_FF(); + void addPage(const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT); - void addPage( const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT ); - - void addBookmark( const char *const BookmarkLabel ); + void addBookmark(const char *const BookmarkLabel); }; -SimplePDF_FF::SimplePDF_FF( const char *const PDFfilename, const char *const title, - const char *const AppName ) : filename( PDFfilename ), DocumentTitle( title ), page(0) -{ - std::ofstream fout( filename.c_str(), std::ios::binary ); +SimplePDF_FF::SimplePDF_FF(const char *const PDFfilename, const char *const title, const char *const AppName) : filename(PDFfilename), DocumentTitle(title), page(0) { + std::ofstream fout(filename.c_str( ), std::ios::binary); - if( !fout ){ - std::cerr << "Cannot open the file: " << filename << std::endl; - return; - } + if (!fout) { + std::cerr << "Cannot open the file: " << filename << std::endl; + return; + } - //-------------------------------------------------- - // Header Section - //-------------------------------------------------- - std::stringstream header; + //-------------------------------------------------- + // Header Section + //-------------------------------------------------- + std::stringstream header; #if 1 - // match to pdflatex & dvipdfmx in texlive 2019 - header << "%PDF-1.5\n" - << '%' << char(0xd0) << char(0xd4) << char(0xc5) << char(0xd8) << '\n'; + // match to pdflatex & dvipdfmx in texlive 2019 + header << "%PDF-1.5\n" << '%' << char(0xd0) << char(0xd4) << char(0xc5) << char(0xd8) << '\n'; #else - header << "%PDF-1.7\n" - << '%' << char(0xe2) << char(0xe3) << char(0xcf) << char(0xd3) << '\n'; + header << "%PDF-1.7\n" << '%' << char(0xe2) << char(0xe3) << char(0xcf) << char(0xd3) << '\n'; #endif - fout << header.str(); - byte_offset = header.str().length(); - - fout.close(); - - //-------------------------------------------------- - // Body Section : Objects - //-------------------------------------------------- - std::list obj; - - std::stringstream strDocumentInfo; - strDocumentInfo << "1 0 obj\n" - << "<<\n"; - - if( strlen( DocumentTitle.c_str() ) > 0 ) - strDocumentInfo << " /Title (" << DocumentTitle << ")\n"; - - strDocumentInfo << " /Creator (" << AppName << ")\n" - << " /CreationDate (D:" << get_datetime() << ")\n" - << ">>\n" - << "endobj\n"; - const std::string DocumentInfo = strDocumentInfo.str(); - - // /PageLayout \in { /SinglePage (default), /OneColumn, - // /TwoColumnLeft, /TwoColumnRight, /TwoPageLeft, /TwoPageRight } - // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } - const std::string DocumentCatalog = - "2 0 obj\n" - "<<\n" - " /Pages 3 0 R\n" - " /Type /Catalog\n" - " /PageLayout /SinglePage\n" - " /PageMode 4 0 R\n" - " /Outlines 5 0 R\n" - ">>\n" - "endobj\n"; - - //-------------------------------------------------- - // Object 3 is reserved for PageTree - // Object 4 is reserved for PageMode - // Object 5 is reserved for Outlines - // Object 6 is reserved for Outlines (document title) - //-------------------------------------------------- - - //-------------------------------------------------- - // Roman Fonts - //-------------------------------------------------- - const std::string FontEH = - "7 0 obj\n" - "<<\n" - " /BaseFont /Helvetica\n" - " /Subtype /Type1\n" - " /Type /Font\n" - ">>\n" - "endobj\n"; - - fout.open( filename.c_str(), std::ios::app ); - - obj.push_back( &DocumentInfo ); - obj.push_back( &DocumentCatalog ); - obj.push_back( &FontEH ); - - for(std::list::const_iterator itr = obj.begin(); itr != obj.end(); itr++){ - fout << **itr; - xref.push_back( byte_offset ); - byte_offset += (*itr)->length(); - } - - fout.close(); - - page_obj_offset = obj.size()+5; - - return; + fout << header.str( ); + byte_offset = header.str( ).length( ); + + fout.close( ); + + //-------------------------------------------------- + // Body Section : Objects + //-------------------------------------------------- + std::list< const std::string * > obj; + + std::stringstream strDocumentInfo; + strDocumentInfo << "1 0 obj\n" + << "<<\n"; + + if (strlen(DocumentTitle.c_str( )) > 0) strDocumentInfo << " /Title (" << DocumentTitle << ")\n"; + + strDocumentInfo << " /Creator (" << AppName << ")\n" + << " /CreationDate (D:" << get_datetime( ) << ")\n" + << ">>\n" + << "endobj\n"; + const std::string DocumentInfo = strDocumentInfo.str( ); + + // /PageLayout \in { /SinglePage (default), /OneColumn, + // /TwoColumnLeft, /TwoColumnRight, /TwoPageLeft, /TwoPageRight } + // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } + const std::string DocumentCatalog = + "2 0 obj\n" + "<<\n" + " /Pages 3 0 R\n" + " /Type /Catalog\n" + " /PageLayout /SinglePage\n" + " /PageMode 4 0 R\n" + " /Outlines 5 0 R\n" + ">>\n" + "endobj\n"; + + //-------------------------------------------------- + // Object 3 is reserved for PageTree + // Object 4 is reserved for PageMode + // Object 5 is reserved for Outlines + // Object 6 is reserved for Outlines (document title) + //-------------------------------------------------- + + //-------------------------------------------------- + // Roman Fonts + //-------------------------------------------------- + const std::string FontEH = + "7 0 obj\n" + "<<\n" + " /BaseFont /Helvetica\n" + " /Subtype /Type1\n" + " /Type /Font\n" + ">>\n" + "endobj\n"; + + fout.open(filename.c_str( ), std::ios::app); + + obj.push_back(&DocumentInfo); + obj.push_back(&DocumentCatalog); + obj.push_back(&FontEH); + + for (std::list< const std::string * >::const_iterator itr = obj.begin( ); itr != obj.end( ); itr++) { + fout << **itr; + xref.push_back(byte_offset); + byte_offset += (*itr)->length( ); + } + + fout.close( ); + + page_obj_offset = obj.size( ) + 5; + + return; } -SimplePDF_FF::~SimplePDF_FF() -{ - std::ofstream fout( filename.c_str(), std::ios::app ); - - //---------------------------------------- - // PageTree - //---------------------------------------- - std::stringstream strPageTree; - strPageTree << "3 0 obj\n" - << "<<\n" - << " /Kids ["; - - for(int i = 0; i < page; i++) - strPageTree << ((i == 0)? "": " ") << page_obj_offset+i*2 << " 0 R"; - - strPageTree << "]\n" - << " /Type /Pages\n" - << " /Count " << page << "\n" - << ">>\n" - << "endobj\n"; - - fout << strPageTree.str(); - - std::list::iterator itr = xref.begin(); // obj 1 (DocumentInfo) - itr++; // obj 2 (DocumentCatalog) - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - - byte_offset += strPageTree.str().length(); - - //---------------------------------------- - // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } - //---------------------------------------- - std::stringstream strPageMode; - strPageMode << "4 0 obj\n" - << " " << (outline.empty()? "/UseNone\n": "/UseOutlines\n") - << "endobj\n"; - - fout << strPageMode.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strPageMode.str().length(); - - //---------------------------------------- - // Outlines - //---------------------------------------- - std::stringstream strOutlines; - strOutlines << "5 0 obj\n" - << "<<\n" - << " /Type /Outlines\n" - << " /Count " << 1+outline.size() << "\n" // 1 : Document Title - << " /First 6 0 R\n" - << " /Last 6 0 R\n" - << ">>\n" - << "endobj\n"; - - fout << strOutlines.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strOutlines.str().length(); - - //---------------------------------------- - // the top of outline - //---------------------------------------- - strOutlines.str(""); // clear string buffer - strOutlines.clear( std::stringstream::goodbit ); // clear status - - strOutlines << "6 0 obj\n" - << "<<\n" - << " /Title (" << DocumentTitle << ")\n" - << " /Parent 5 0 R\n" - << " /Count " << outline.size() << "\n"; - - if( !outline.empty() ){ - - const int OutlineItemIdFirst = xref.size()+2; - const int OutlineItemIdLast = xref.size()+outline.size()+1; - - strOutlines << " /First " << OutlineItemIdFirst << " 0 R\n" - << " /Last " << OutlineItemIdLast << " 0 R\n"; - } - - strOutlines << " /Dest [" << outline.front().headPageObjectNumber << " 0 R /Fit]\n" - << ">>\n" - << "endobj\n"; - - fout << strOutlines.str(); - - itr++; // obj 3 (FontEH at present) - itr = xref.insert( itr, byte_offset ); // byte_offset is inserted before itr (FontEH) - // and itr indicates byte_offset - byte_offset += strOutlines.str().length(); - - //---------------------------------------- - // outline items - //---------------------------------------- - for(std::list::iterator itr = outline.begin(); itr != outline.end(); itr++){ - - std::stringstream strOutlineItem; - - const int object_id = xref.size()+1; - - strOutlineItem << object_id << " 0 obj\n" - << "<<\n" - << " /Title (" << itr->label << ")\n" - << " /Parent 6 0 R\n"; - - if( itr != outline.begin() ) - strOutlineItem << " /Prev " << object_id-1 << " 0 R\n"; - - std::list::const_iterator succ = itr; - succ++; - if( succ != outline.end() ) - strOutlineItem << " /Next " << object_id+1 << " 0 R\n"; - - strOutlineItem << " /Count 0\n" - << " /Dest [" << itr->headPageObjectNumber << " 0 R /Fit]\n" - << ">>\n" - << "endobj\n"; - - fout << strOutlineItem.str(); - - delete [] itr->label; - - xref.push_back( byte_offset ); - byte_offset += strOutlineItem.str().length(); - } - - //---------------------------------------- - // Corss-reference Table Section - //---------------------------------------- - const int nobjs = xref.size()+1; // including 0th object (0 0 obj) - - fout << "xref\n"; - fout << "0 " << nobjs << std::endl; - fout << "0000000000 65535 f \n"; // 0 0 obj - - for(std::list::const_iterator itr = xref.begin(); itr != xref.end(); itr++) - fout << std::setw(10) << std::setfill('0') << *itr << " 00000 n \n"; - - //---------------------------------------- - // Trailer Section - //---------------------------------------- - fout << "trailer\n" - << "<<\n" - << " /Info 1 0 R\n" - << " /Root 2 0 R\n" - << " /Size " << nobjs << "\n" - << ">>\n" - << "startxref\n" - << byte_offset << std::endl // starting position of 'xref' - << "%%EOF\n"; - - fout.close(); +SimplePDF_FF::~SimplePDF_FF( ) { + std::ofstream fout(filename.c_str( ), std::ios::app); + + //---------------------------------------- + // PageTree + //---------------------------------------- + std::stringstream strPageTree; + strPageTree << "3 0 obj\n" + << "<<\n" + << " /Kids ["; + + for (int i = 0; i < page; i++) strPageTree << ((i == 0) ? "" : " ") << page_obj_offset + i * 2 << " 0 R"; + + strPageTree << "]\n" + << " /Type /Pages\n" + << " /Count " << page << "\n" + << ">>\n" + << "endobj\n"; + + fout << strPageTree.str( ); + + std::list< int >::iterator itr = xref.begin( ); // obj 1 (DocumentInfo) + itr++; // obj 2 (DocumentCatalog) + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + + byte_offset += strPageTree.str( ).length( ); - return; + //---------------------------------------- + // /PageMode \in { /UseNone (default), /UseOutlines, /UseThumbs, /FullScreen, /UseOC, /UseAttachements } + //---------------------------------------- + std::stringstream strPageMode; + strPageMode << "4 0 obj\n" + << " " << (outline.empty( ) ? "/UseNone\n" : "/UseOutlines\n") << "endobj\n"; + + fout << strPageMode.str( ); + + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strPageMode.str( ).length( ); + + //---------------------------------------- + // Outlines + //---------------------------------------- + std::stringstream strOutlines; + strOutlines << "5 0 obj\n" + << "<<\n" + << " /Type /Outlines\n" + << " /Count " << 1 + outline.size( ) << "\n" // 1 : Document Title + << " /First 6 0 R\n" + << " /Last 6 0 R\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlines.str( ); + + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strOutlines.str( ).length( ); + + //---------------------------------------- + // the top of outline + //---------------------------------------- + strOutlines.str(""); // clear string buffer + strOutlines.clear(std::stringstream::goodbit); // clear status + + strOutlines << "6 0 obj\n" + << "<<\n" + << " /Title (" << DocumentTitle << ")\n" + << " /Parent 5 0 R\n" + << " /Count " << outline.size( ) << "\n"; + + if (!outline.empty( )) { + + const int OutlineItemIdFirst = xref.size( ) + 2; + const int OutlineItemIdLast = xref.size( ) + outline.size( ) + 1; + + strOutlines << " /First " << OutlineItemIdFirst << " 0 R\n" + << " /Last " << OutlineItemIdLast << " 0 R\n"; + } + + strOutlines << " /Dest [" << outline.front( ).headPageObjectNumber << " 0 R /Fit]\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlines.str( ); + + itr++; // obj 3 (FontEH at present) + itr = xref.insert(itr, byte_offset); // byte_offset is inserted before itr (FontEH) + // and itr indicates byte_offset + byte_offset += strOutlines.str( ).length( ); + + //---------------------------------------- + // outline items + //---------------------------------------- + for (std::list< OutlineItem >::iterator itr = outline.begin( ); itr != outline.end( ); itr++) { + + std::stringstream strOutlineItem; + + const int object_id = xref.size( ) + 1; + + strOutlineItem << object_id << " 0 obj\n" + << "<<\n" + << " /Title (" << itr->label << ")\n" + << " /Parent 6 0 R\n"; + + if (itr != outline.begin( )) strOutlineItem << " /Prev " << object_id - 1 << " 0 R\n"; + + std::list< OutlineItem >::const_iterator succ = itr; + succ++; + if (succ != outline.end( )) strOutlineItem << " /Next " << object_id + 1 << " 0 R\n"; + + strOutlineItem << " /Count 0\n" + << " /Dest [" << itr->headPageObjectNumber << " 0 R /Fit]\n" + << ">>\n" + << "endobj\n"; + + fout << strOutlineItem.str( ); + + delete[] itr->label; + + xref.push_back(byte_offset); + byte_offset += strOutlineItem.str( ).length( ); + } + + //---------------------------------------- + // Corss-reference Table Section + //---------------------------------------- + const int nobjs = xref.size( ) + 1; // including 0th object (0 0 obj) + + fout << "xref\n"; + fout << "0 " << nobjs << std::endl; + fout << "0000000000 65535 f \n"; // 0 0 obj + + for (std::list< int >::const_iterator itr = xref.begin( ); itr != xref.end( ); itr++) fout << std::setw(10) << std::setfill('0') << *itr << " 00000 n \n"; + + //---------------------------------------- + // Trailer Section + //---------------------------------------- + fout << "trailer\n" + << "<<\n" + << " /Info 1 0 R\n" + << " /Root 2 0 R\n" + << " /Size " << nobjs << "\n" + << ">>\n" + << "startxref\n" + << byte_offset << std::endl // starting position of 'xref' + << "%%EOF\n"; + + fout.close( ); + + return; } -// +// #ifdef HAVE_ZLIB #include -int SimplePDF_FF::deflate_compress( char* &outbuf, const std::string &Stream ) const -{ - char *inbuf = new char [ Stream.length()+1 ]; +int SimplePDF_FF::deflate_compress(char *&outbuf, const std::string &Stream) const { + char *inbuf = new char[Stream.length( ) + 1]; - for(size_t i = 0; i < Stream.length(); i++) // strcpy or strncpy - inbuf[i] = Stream[i]; - inbuf[ Stream.length() ] = '\0'; + for (size_t i = 0; i < Stream.length( ); i++) // strcpy or strncpy + inbuf[i] = Stream[i]; + inbuf[Stream.length( )] = '\0'; - z_stream z; - z.zalloc = Z_NULL; - z.zfree = Z_NULL; - z.opaque = Z_NULL; + z_stream z; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; - if( deflateInit(&z, Z_DEFAULT_COMPRESSION) != Z_OK ) { - std::cerr << "zlib: deflateInit(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflateInit(&z, Z_DEFAULT_COMPRESSION) != Z_OK) { + std::cerr << "zlib: deflateInit(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - outbuf = new char [ Stream.length()+1 ]; + outbuf = new char[Stream.length( ) + 1]; - z.next_in = reinterpret_cast(inbuf); - z.avail_in = Stream.length(); - z.next_out = reinterpret_cast(outbuf); - z.avail_out = Stream.length(); + z.next_in = reinterpret_cast< unsigned char * >(inbuf); + z.avail_in = Stream.length( ); + z.next_out = reinterpret_cast< unsigned char * >(outbuf); + z.avail_out = Stream.length( ); - if( deflate(&z, Z_FINISH) != Z_STREAM_END ){ - std::cerr << "zlib: deflate(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflate(&z, Z_FINISH) != Z_STREAM_END) { + std::cerr << "zlib: deflate(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - if( deflateEnd(&z) != Z_OK ){ - std::cerr << "zlib: deflateEnd(): " << ((z.msg)? z.msg: "Error") << std::endl; - std::exit(1); - } + if (deflateEnd(&z) != Z_OK) { + std::cerr << "zlib: deflateEnd(): " << ((z.msg) ? z.msg : "Error") << std::endl; + std::exit(1); + } - delete [] inbuf; + delete[] inbuf; - const int compressed_buf_length = Stream.length() - z.avail_out; + const int compressed_buf_length = Stream.length( ) - z.avail_out; - outbuf[compressed_buf_length] = '\n'; + outbuf[compressed_buf_length] = '\n'; - return compressed_buf_length+1; + return compressed_buf_length + 1; } #endif -void SimplePDF_FF::addPage( const std::stringstream &ContentStream, - const int WIDTH, const int HEIGHT ) -{ - //---------------------------------------- - // PageObject - //---------------------------------------- - std::stringstream strPageObject; - - strPageObject << page_obj_offset+2*page << " 0 obj\n" - << "<<\n" - << " /Type /Page\n" - << " /Parent 3 0 R\n" - << " /Resources << /Font << /F1 7 0 R >> >>\n" - << " /MediaBox [0 0 " << WIDTH << ' ' << HEIGHT << "]\n" - << " /Contents " << page_obj_offset+2*page+1 << " 0 R\n" - << ">>\n" - << "endobj\n"; - - const std::string PageObject = strPageObject.str(); - - //---------------------------------------- - // pageContent (stream) - //---------------------------------------- +void SimplePDF_FF::addPage(const std::stringstream &ContentStream, const int WIDTH, const int HEIGHT) { + //---------------------------------------- + // PageObject + //---------------------------------------- + std::stringstream strPageObject; + + strPageObject << page_obj_offset + 2 * page << " 0 obj\n" + << "<<\n" + << " /Type /Page\n" + << " /Parent 3 0 R\n" + << " /Resources << /Font << /F1 7 0 R >> >>\n" + << " /MediaBox [0 0 " << WIDTH << ' ' << HEIGHT << "]\n" + << " /Contents " << page_obj_offset + 2 * page + 1 << " 0 R\n" + << ">>\n" + << "endobj\n"; + + const std::string PageObject = strPageObject.str( ); + + //---------------------------------------- + // pageContent (stream) + //---------------------------------------- #ifdef HAVE_ZLIB - char *buf; - const int compressed_buf_length = deflate_compress( buf, ContentStream.str() ); + char *buf; + const int compressed_buf_length = deflate_compress(buf, ContentStream.str( )); #endif - //---------------------------------------- - // pageContent (object) - //---------------------------------------- - std::stringstream strContent; - strContent << page_obj_offset+2*page+1 << " 0 obj\n" - << "<< /Length "; + //---------------------------------------- + // pageContent (object) + //---------------------------------------- + std::stringstream strContent; + strContent << page_obj_offset + 2 * page + 1 << " 0 obj\n" + << "<< /Length "; #ifdef HAVE_ZLIB - strContent << compressed_buf_length << " /Filter /FlateDecode"; + strContent << compressed_buf_length << " /Filter /FlateDecode"; #else - strContent << ContentStream.str().length(); + strContent << ContentStream.str( ).length( ); #endif - strContent << " >>\n" - << "stream\n"; + strContent << " >>\n" + << "stream\n"; #ifdef HAVE_ZLIB - // Following works well even if buf[] has '\0' - strContent << std::string( buf+0, buf+compressed_buf_length ); - delete [] buf; + // Following works well even if buf[] has '\0' + strContent << std::string(buf + 0, buf + compressed_buf_length); + delete[] buf; #else - strContent << ContentStream.str(); + strContent << ContentStream.str( ); #endif - strContent << "endstream\n" - << "endobj\n"; + strContent << "endstream\n" + << "endobj\n"; - const std::string Content = strContent.str(); + const std::string Content = strContent.str( ); - //---------------------------------------- - // Add Page Objects - //---------------------------------------- - std::ofstream fout( filename.c_str(), std::ios::app ); + //---------------------------------------- + // Add Page Objects + //---------------------------------------- + std::ofstream fout(filename.c_str( ), std::ios::app); - const std::string*const PageObj[2] = { &PageObject, &Content }; + const std::string *const PageObj[2] = {&PageObject, &Content}; - for(int i = 0; i < 2; i++){ - xref.push_back( byte_offset ); - fout << *PageObj[i]; - byte_offset += PageObj[i]->length(); - } + for (int i = 0; i < 2; i++) { + xref.push_back(byte_offset); + fout << *PageObj[i]; + byte_offset += PageObj[i]->length( ); + } - fout.close(); - page++; + fout.close( ); + page++; - return; + return; } -void SimplePDF_FF::addBookmark( const char *const BookmarkLabel ) -{ - OutlineItem item; +void SimplePDF_FF::addBookmark(const char *const BookmarkLabel) { + OutlineItem item; - item.headPageObjectNumber = page_obj_offset+2*page; + item.headPageObjectNumber = page_obj_offset + 2 * page; - item.label = new char [ strlen(BookmarkLabel)+1 ]; - strcpy( item.label, BookmarkLabel ); - - outline.push_back( item ); + item.label = new char[strlen(BookmarkLabel) + 1]; + strcpy(item.label, BookmarkLabel); - return; + outline.push_back(item); + + return; } -#endif // PDF_H +#endif // PDF_H //---------------------------------------------------------------------- // End of file diff --git a/src/Graphics/rgraph.hpp b/src/Graphics/rgraph.hpp index 793b557c0..d8c84fab4 100644 --- a/src/Graphics/rgraph.hpp +++ b/src/Graphics/rgraph.hpp @@ -40,15 +40,17 @@ // // ----- #ifdef FF_GRAPH_SET_PTR -#define EXTERNFF(t,f,arg) t f##_ arg; extern t (*f) arg +#define EXTERNFF(t, f, arg) \ + t f##_ arg; \ + extern t(*f) arg #else #ifdef FF_GRAPH_PTR_DCL -#define EXTERNFF(t,f,arg) t (*f) arg +#define EXTERNFF(t, f, arg) t(*f) arg #else -#define EXTERNFF(t,f,arg) extern t (*f) arg +#define EXTERNFF(t, f, arg) extern t(*f) arg #endif #endif -//#define EXTERN +// #define EXTERN #ifdef __cplusplus // TODO: remove this block as soon as autoconf is removed from FreeFem++ @@ -56,110 +58,108 @@ #include #endif -//extern "C" { -EXTERNFF( void ,getcadre,(float &xmin,float &xmax, float &ymin, float &ymax)) ; -EXTERNFF( void ,GetScreenSize,(int &ix,int &iy)) ; // unused -EXTERNFF( char ,Getxyc,(float &x,float &y)) ; -EXTERNFF( void ,ShowHelp,(const char * s,int k)) ; // k=1 ??//tlr: deplace ici +// extern "C" { +EXTERNFF(void, getcadre, (float &xmin, float &xmax, float &ymin, float &ymax)); +EXTERNFF(void, GetScreenSize, (int &ix, int &iy)); // unused +EXTERNFF(char, Getxyc, (float &x, float &y)); +EXTERNFF(void, ShowHelp, (const char *s, int k)); // k=1 ??//tlr: deplace ici #endif -EXTERNFF( void ,erreur,(char *s)) ; -EXTERNFF( void ,initgraphique,()) ; // only in main -EXTERNFF( void ,closegraphique,()) ; -EXTERNFF( void ,showgraphic,()) ; -EXTERNFF( void ,rattente,(int waitm)) ; -EXTERNFF( void ,cadre,(float xmin,float xmax, float ymin, float ymax)) ; -EXTERNFF( void ,cadreortho,(float centrex, float centrey, float rayon)) ; -EXTERNFF( void ,couleur,(int c)) ; -EXTERNFF( int ,LaCouleur,()) ; -EXTERNFF( void ,pointe,(float x, float y)) ; -EXTERNFF( int ,InPtScreen,(float x, float y)) ; -EXTERNFF( int ,InRecScreen,(float x1, float y1,float x2, float y2)) ; -EXTERNFF( void ,plotstring,(const char *s)) ; -EXTERNFF( void ,rmoveto,(float x, float y)) ; -EXTERNFF( void ,rlineto,(float x, float y)) ; -EXTERNFF( void ,penthickness,(int )) ; -EXTERNFF( int ,execute,(const char* s)) ; -EXTERNFF( void ,reffecran,()) ; -EXTERNFF( void ,fillpoly,(int n, float *poly)) ; -EXTERNFF( void ,SetColorTable,(int nb)) ; -EXTERNFF( void ,SetColorTable1,(int nb,bool hsv,int nbcolors,float *colors)) ; -EXTERNFF( float ,GetHeigthFont,()) ; +EXTERNFF(void, erreur, (char *s)); +EXTERNFF(void, initgraphique, ( )); // only in main +EXTERNFF(void, closegraphique, ( )); +EXTERNFF(void, showgraphic, ( )); +EXTERNFF(void, rattente, (int waitm)); +EXTERNFF(void, cadre, (float xmin, float xmax, float ymin, float ymax)); +EXTERNFF(void, cadreortho, (float centrex, float centrey, float rayon)); +EXTERNFF(void, couleur, (int c)); +EXTERNFF(int, LaCouleur, ( )); +EXTERNFF(void, pointe, (float x, float y)); +EXTERNFF(int, InPtScreen, (float x, float y)); +EXTERNFF(int, InRecScreen, (float x1, float y1, float x2, float y2)); +EXTERNFF(void, plotstring, (const char *s)); +EXTERNFF(void, rmoveto, (float x, float y)); +EXTERNFF(void, rlineto, (float x, float y)); +EXTERNFF(void, penthickness, (int)); +EXTERNFF(int, execute, (const char *s)); +EXTERNFF(void, reffecran, ( )); +EXTERNFF(void, fillpoly, (int n, float *poly)); +EXTERNFF(void, SetColorTable, (int nb)); +EXTERNFF(void, SetColorTable1, (int nb, bool hsv, int nbcolors, float *colors)); +EXTERNFF(float, GetHeigthFont, ( )); // old function for freefem+ -//EXTERNFF( void ,compile,(char *fname)) ; -//EXTERNFF( void ,compileString,(char *texte)) ;/*tlr: add a string stream */ - -EXTERNFF( void ,openPS,(const char * )) ; -EXTERNFF( void ,closePS,(void)) ; -EXTERNFF( void ,openPDF,(const char * )) ; // add by fujiwara -EXTERNFF( void ,closePDF,(void)) ; // add by fujiwara -EXTERNFF( void ,openSVG,(const char * )) ; // add by fujiwara -EXTERNFF( void ,closeSVG,(void)) ; // add by fujiwara -EXTERNFF( void ,coutmode,(short i)) ; -EXTERNFF( void ,myexit,(int err)) ; // err=0 ?? -EXTERNFF( void ,viderbuff,()) ; -EXTERNFF( void ,Commentaire,(const char *)) ; -EXTERNFF( void ,NoirEtBlanc,(int NB)) ; -EXTERNFF( void ,MettreDansPostScript,(int in)) ;// oui=1 ou non=0 -EXTERNFF( void ,MettreDansPDF,(int in)) ;// oui=1 ou non=0 // add by fujiwara -EXTERNFF( void ,MettreDansSVG,(int in)) ;// oui=1 ou non=0 // add by fujiwara -EXTERNFF( int ,getprog,(char* fn,int , char** argvptr)) ; -EXTERNFF( void ,setgrey,(bool )) ; -EXTERNFF( int ,getgrey,( )) ; - +// EXTERNFF( void ,compile,(char *fname)) ; +// EXTERNFF( void ,compileString,(char *texte)) ;/*tlr: add a string stream */ + +EXTERNFF(void, openPS, (const char *)); +EXTERNFF(void, closePS, (void)); +EXTERNFF(void, openPDF, (const char *)); // add by fujiwara +EXTERNFF(void, closePDF, (void)); // add by fujiwara +EXTERNFF(void, openSVG, (const char *)); // add by fujiwara +EXTERNFF(void, closeSVG, (void)); // add by fujiwara +EXTERNFF(void, coutmode, (short i)); +EXTERNFF(void, myexit, (int err)); // err=0 ?? +EXTERNFF(void, viderbuff, ( )); +EXTERNFF(void, Commentaire, (const char *)); +EXTERNFF(void, NoirEtBlanc, (int NB)); +EXTERNFF(void, MettreDansPostScript, (int in)); // oui=1 ou non=0 +EXTERNFF(void, MettreDansPDF, (int in)); // oui=1 ou non=0 // add by fujiwara +EXTERNFF(void, MettreDansSVG, (int in)); // oui=1 ou non=0 // add by fujiwara +EXTERNFF(int, getprog, (char *fn, int, char **argvptr)); +EXTERNFF(void, setgrey, (bool)); +EXTERNFF(int, getgrey, ( )); // wrapping of function ----- -#ifdef FF_GRAPH_SET_PTR -static int init_ff_graph_ptr_func() -{ // a small function to set all pointeur - getcadre=getcadre_; - GetScreenSize=GetScreenSize_; - Getxyc=Getxyc_; - ShowHelp=ShowHelp_; - erreur=erreur_; - initgraphique=initgraphique_; - closegraphique=closegraphique_; - showgraphic=showgraphic_; - rattente=rattente_; - cadre=cadre_; - cadreortho=cadreortho_; - couleur=couleur_; - LaCouleur=LaCouleur_; - pointe=pointe_; - InPtScreen=InPtScreen_; - InRecScreen=InRecScreen_; - plotstring=plotstring_; - rmoveto=rmoveto_; - rlineto=rlineto_; - penthickness=penthickness_; - execute=execute_; - reffecran=reffecran_; - fillpoly=fillpoly_; - SetColorTable=SetColorTable_; - SetColorTable1=SetColorTable1_; - GetHeigthFont=GetHeigthFont_; - //compile=compile_; - //compileString=compileString_; - openPS=openPS_; - closePS=closePS_; - openPDF=openPDF_; // add by fujiwara - closePDF=closePDF_; // add by fujiwara - openSVG=openSVG_; // add by fujiwara - closeSVG=closeSVG_; // add by fujiwara - coutmode=coutmode_; - myexit=myexit_; - viderbuff=viderbuff_; - Commentaire=Commentaire_; - NoirEtBlanc=NoirEtBlanc_; - MettreDansPostScript=MettreDansPostScript_; - MettreDansPDF=MettreDansPDF_; // add by fujiwara - MettreDansSVG=MettreDansSVG_; // add by fujiwara - getprog=getprog_; - setgrey=setgrey_; - getgrey=getgrey_; +#ifdef FF_GRAPH_SET_PTR +static int init_ff_graph_ptr_func( ) { // a small function to set all pointeur + getcadre = getcadre_; + GetScreenSize = GetScreenSize_; + Getxyc = Getxyc_; + ShowHelp = ShowHelp_; + erreur = erreur_; + initgraphique = initgraphique_; + closegraphique = closegraphique_; + showgraphic = showgraphic_; + rattente = rattente_; + cadre = cadre_; + cadreortho = cadreortho_; + couleur = couleur_; + LaCouleur = LaCouleur_; + pointe = pointe_; + InPtScreen = InPtScreen_; + InRecScreen = InRecScreen_; + plotstring = plotstring_; + rmoveto = rmoveto_; + rlineto = rlineto_; + penthickness = penthickness_; + execute = execute_; + reffecran = reffecran_; + fillpoly = fillpoly_; + SetColorTable = SetColorTable_; + SetColorTable1 = SetColorTable1_; + GetHeigthFont = GetHeigthFont_; + // compile=compile_; + // compileString=compileString_; + openPS = openPS_; + closePS = closePS_; + openPDF = openPDF_; // add by fujiwara + closePDF = closePDF_; // add by fujiwara + openSVG = openSVG_; // add by fujiwara + closeSVG = closeSVG_; // add by fujiwara + coutmode = coutmode_; + myexit = myexit_; + viderbuff = viderbuff_; + Commentaire = Commentaire_; + NoirEtBlanc = NoirEtBlanc_; + MettreDansPostScript = MettreDansPostScript_; + MettreDansPDF = MettreDansPDF_; // add by fujiwara + MettreDansSVG = MettreDansSVG_; // add by fujiwara + getprog = getprog_; + setgrey = setgrey_; + getgrey = getgrey_; return 1; } // to call the init function before main -static int init_ff_graph_ptr_func_call = init_ff_graph_ptr_func(); +static int init_ff_graph_ptr_func_call = init_ff_graph_ptr_func( ); #define getcadre getcadre_ #define GetScreenSize GetScreenSize_ @@ -187,22 +187,22 @@ static int init_ff_graph_ptr_func_call = init_ff_graph_ptr_func(); #define SetColorTable SetColorTable_ #define SetColorTable1 SetColorTable1_ #define GetHeigthFont GetHeigthFont_ -//#define compile compile_ -//#define compileString compileString_ +// #define compile compile_ +// #define compileString compileString_ #define openPS openPS_ #define closePS closePS_ -#define openPDF openPDF_ // add by fujiwara -#define closePDF closePDF_ // add by fujiwara -#define openSVG openSVG_ // add by fujiwara -#define closeSVG closeSVG_ // add by fujiwara +#define openPDF openPDF_ // add by fujiwara +#define closePDF closePDF_ // add by fujiwara +#define openSVG openSVG_ // add by fujiwara +#define closeSVG closeSVG_ // add by fujiwara #define coutmode coutmode_ #define myexit myexit_ #define viderbuff viderbuff_ #define Commentaire Commentaire_ #define NoirEtBlanc NoirEtBlanc_ #define MettreDansPostScript MettreDansPostScript_ -#define MettreDansPDF MettreDansPDF_ // add by fujiwara -#define MettreDansSVG MettreDansSVG_ // add by fujiwara +#define MettreDansPDF MettreDansPDF_ // add by fujiwara +#define MettreDansSVG MettreDansSVG_ // add by fujiwara #define getprog getprog_ #define setgrey setgrey_ #define getgrey getgrey_ @@ -212,47 +212,41 @@ static int init_ff_graph_ptr_func_call = init_ff_graph_ptr_func(); //} - - #ifdef TERM_USED /** Ouput on the terminal window */ class myostream { - int channel; - - public: - - myostream(int ch) { channel = ch; } + int channel; - myostream& operator<<(char c); + public: + myostream(int ch) { channel = ch; } - myostream& operator<<(const char *s); + myostream &operator<<(char c); - myostream& operator<<(const void *p); + myostream &operator<<(const char *s); - myostream& operator<<(int n); + myostream &operator<<(const void *p); - myostream& operator<<(unsigned int n) { return *this << (int)n; } + myostream &operator<<(int n); - myostream& operator<<(long n); + myostream &operator<<(unsigned int n) { return *this << (int)n; } - myostream& operator<<(unsigned long n) { return *this << (long)n; } + myostream &operator<<(long n); - myostream& operator<<(double n); + myostream &operator<<(unsigned long n) { return *this << (long)n; } - myostream& operator<<(float n) { return *this << (double)n; } + myostream &operator<<(double n); - myostream& operator<<(__omanip func); + myostream &operator<<(float n) { return *this << (double)n; } + myostream &operator<<(__omanip func); }; +extern myostream termout; // could be cout, or another thing - -extern myostream termout; // could be cout, or another thing - -extern myostream termerr; // could be cerr, or another thing +extern myostream termerr; // could be cerr, or another thing #define cout termout @@ -260,10 +254,6 @@ extern myostream termerr; // could be cerr, or another thing #endif /* TERM_USED */ - - #endif /* __cplusplus */ - - #endif /* RGRAPH_H_ */ diff --git a/src/Graphics/sansrgraph.cpp b/src/Graphics/sansrgraph.cpp index 852ad380b..abcd4da8e 100644 --- a/src/Graphics/sansrgraph.cpp +++ b/src/Graphics/sansrgraph.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,10 +28,10 @@ // ALH - javascript output #ifdef FFJS -#ifndef NATIVEFFJS // [[file:~/ffjs/Makefile::NATIVEFFJS]] +#ifndef NATIVEFFJS // [[file:~/ffjs/Makefile::NATIVEFFJS]] #include -#endif // NATIVEFFJS -#endif // FFJS +#endif // NATIVEFFJS +#endif // FFJS #define FF_GRAPH_SET_PTR #include @@ -43,8 +43,8 @@ using namespace std; #include "rgraph.hpp" -#include // add by fujiwara -#include "pdf.h" // add by fujiwara +#include // add by fujiwara +#include "pdf.h" // add by fujiwara #include "error.hpp" #ifdef macintoshxx @@ -56,169 +56,153 @@ using namespace std; #ifdef xTARGET_CARBON #include -int pStrCopy (StringPtr p1, char * p2) +int pStrCopy(StringPtr p1, char *p2) /* copies a pascal string `p1 into a C string */ { - int len,i; - - len = (*p1++) %256; - for(i=1;i<=len;i++) *p2++=*p1++; - *p2 = 0; - return 0; + int len, i; + + len = (*p1++) % 256; + for (i = 1; i <= len; i++) *p2++ = *p1++; + *p2 = 0; + return 0; } -int getprog(char* fn,int argc, char** argvptr) -{ - OSErr anErr; +int getprog(char *fn, int argc, char **argvptr) { + OSErr anErr; NavDialogOptions dialogOptions; NavReplyRecord reply; - - anErr=NavGetDefaultDialogOptions(& dialogOptions); - if( anErr != noErr) return -1; - anErr =NavChooseFile(0,&reply,&dialogOptions,0,0,0,0,0) ; - if (anErr == noErr && reply.validRecord) - { - // Deal with multiple file selection - long count; - - anErr = AECountItems(&(reply.selection), &count); - // Set up index for file list - if (anErr == noErr) - { - long index; - - for (index = 1; index <= count; index++) - { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec documentFSSpec; - - // Get a pointer to selected file - anErr = AEGetNthPtr(&(reply.selection), index, - typeFSS, &theKeyword, - &actualType,&documentFSSpec, - sizeof(documentFSSpec), - &actualSize); - if (anErr == noErr) - { - anErr = HSetVol(0,documentFSSpec.vRefNum,documentFSSpec.parID); - pStrCopy(documentFSSpec.name, fn); - } - } - } - // Dispose of NavReplyRecord, resources, descriptors - anErr = NavDisposeReply(&reply); - - } - return (2); + + anErr = NavGetDefaultDialogOptions(&dialogOptions); + if (anErr != noErr) return -1; + anErr = NavChooseFile(0, &reply, &dialogOptions, 0, 0, 0, 0, 0); + if (anErr == noErr && reply.validRecord) { + // Deal with multiple file selection + long count; + + anErr = AECountItems(&(reply.selection), &count); + // Set up index for file list + if (anErr == noErr) { + long index; + + for (index = 1; index <= count; index++) { + AEKeyword theKeyword; + DescType actualType; + Size actualSize; + FSSpec documentFSSpec; + + // Get a pointer to selected file + anErr = AEGetNthPtr(&(reply.selection), index, typeFSS, &theKeyword, &actualType, &documentFSSpec, sizeof(documentFSSpec), &actualSize); + if (anErr == noErr) { + anErr = HSetVol(0, documentFSSpec.vRefNum, documentFSSpec.parID); + pStrCopy(documentFSSpec.name, fn); + } + } + } + // Dispose of NavReplyRecord, resources, descriptors + anErr = NavDisposeReply(&reply); + } + return (2); } #else #include "getprog-unix.hpp" #endif +template< class T > +inline T Min(const T &a, const T &b) { + return a < b ? a : b; +} +template< class T > +inline T Max(const T &a, const T &b) { + return a > b ? a : b; +} -template inline T Min (const T &a,const T &b){return a < b ? a : b;} -template inline T Max (const T &a,const T & b){return a > b ? a : b;} - - -static long cube6[7][3] ={ { 65535,32000,32000},{ 65535, 65535,0},{0, 65535,0},{0, 65535, 65535},{0,0, 65535} - , { 65535,0, 65535},{ 32000,0,0} }; -static long grey6[2][3] ={ {65534,65534,65534},{0,0,0} }; +static long cube6[7][3] = {{65535, 32000, 32000}, {65535, 65535, 0}, {0, 65535, 0}, {0, 65535, 65535}, {0, 0, 65535}, {65535, 0, 65535}, {32000, 0, 0}}; +static long grey6[2][3] = {{65534, 65534, 65534}, {0, 0, 0}}; -static bool grey=false; +static bool grey = false; static FILE *psfile = 0; static FILE *psfile_save = 0; -static bool pdffile = false; // add by fujiwara -static char *pdffile_name = nullptr; // add by fujiwara -static float pdf_s = 1; // add by fujiwara -static std::stringstream pdffile_content; // add by fujiwara -static FILE *svgfile = 0; // add by fujiwara -static FILE *svgfile_save = 0; // add by fujiwara -static float svg_s = 1; // add by fujiwara -static int svg_r = 0; // add by fujiwara -static int svg_g = 0; // add by fujiwara -static int svg_b = 0; // add by fujiwara -static int svg_lw = 1; // add by fujiwara -static int LastColor=2; // pour est en couleur par defaut +static bool pdffile = false; // add by fujiwara +static char *pdffile_name = nullptr; // add by fujiwara +static float pdf_s = 1; // add by fujiwara +static std::stringstream pdffile_content; // add by fujiwara +static FILE *svgfile = 0; // add by fujiwara +static FILE *svgfile_save = 0; // add by fujiwara +static float svg_s = 1; // add by fujiwara +static int svg_r = 0; // add by fujiwara +static int svg_g = 0; // add by fujiwara +static int svg_b = 0; // add by fujiwara +static int svg_lw = 1; // add by fujiwara +static int LastColor = 2; // pour est en couleur par defaut const float fMinPixel = -32000; const float fMaxPixel = +32000; -#define reel float - typedef struct XColor { - unsigned short red,green,blue; +#define reel float +typedef struct XColor { + unsigned short red, green, blue; } XColor; static XColor *colortable; -static int ncolortable,fcolor; -static reel echx,echy,rxmin,rxmax,rymin,rymax; -static int lacouleur=0, width, height, currx=0, curry=0; +static int ncolortable, fcolor; +static reel echx, echy, rxmin, rxmax, rymin, rymax; +static int lacouleur = 0, width, height, currx = 0, curry = 0; #define call(i) i -static int INITGRAPH=0; -void myend(); -void myend() -{ - if (INITGRAPH) - closegraphique(); - cout << "the end" <> @@ -230,217 +214,192 @@ extern int mymain(int argc,char **argv); // Built by [[file:~/fflib/Makefile::FFLIB_MAIN]] and called by [[file:~/fflib/fflib.cpp::calling_fflib_main]]. #ifdef FFLIB_MAIN -int fflib_main(int argc,char **argv) +int fflib_main(int argc, char **argv) #else -int main (int argc, char **argv) +int main(int argc, char **argv) #endif { atexit(doatexitff); - int ret=mymain(argc,argv); // <> + int ret = mymain(argc, argv); // <> return ret; } -#endif // WITHOUT_MAIN +#endif // WITHOUT_MAIN -#endif // FREEFEM +#endif // FREEFEM void message(char *s); -void message(char *s) -{ printf("%s \n",s);} +void message(char *s) { printf("%s \n", s); } -void erreur(char *s) -{ message(s); exit(0);} -void *safecalloc(size_t nb, size_t size); -void *safecalloc(size_t nb, size_t size) -{ - void* p=NULL; +void erreur(char *s) { + message(s); + exit(0); +} +void *safecalloc(size_t nb, size_t size); +void *safecalloc(size_t nb, size_t size) { + void *p = NULL; p = calloc(nb, size); if (p == NULL) printf("Run out of Memory!\n"); return p; } -void safefree(void** f); -void safefree(void** f) -{ - if(*f){ free((char*) *f); *f=NULL;} -} -void rflush(); -void rflush() -{ +void safefree(void **f); +void safefree(void **f) { + if (*f) { + free((char *)*f); + *f = NULL; + } } +void rflush( ); +void rflush( ) {} +int LaCouleur( ) { return lacouleur; } -int LaCouleur() {return lacouleur;} - -void couleur(int c) -{ - if ( lacouleur == c) // small optim +void couleur(int c) { + if (lacouleur == c) // small optim return; - c= c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc - lacouleur = c; - float r=1,g=1,b=1; - if (colortable) { - if (c>0 && c < ncolortable) - { - r = (float) colortable[c].red /65535.; - g = (float) colortable[c].green /65535.; - b = (float) colortable[c].blue /65535.; - } - } - else if (c!=0) - r=g=b=0; - if(psfile) - fprintf(psfile,"%.3f %.3f %.3f C\n",r,g,b); - - // add by fujiwara - if( pdffile ){ - pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; - pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; - } - if( svgfile ){ - svg_r = static_cast(r*256); - svg_g = static_cast(g*256); - svg_b = static_cast(b*256); + c = c > LastColor ? 1 : c; // c=Min(c,LastColor); pour noir et blanc + lacouleur = c; + float r = 1, g = 1, b = 1; + if (colortable) { + if (c > 0 && c < ncolortable) { + r = (float)colortable[c].red / 65535.; + g = (float)colortable[c].green / 65535.; + b = (float)colortable[c].blue / 65535.; } + } else if (c != 0) + r = g = b = 0; + if (psfile) fprintf(psfile, "%.3f %.3f %.3f C\n", r, g, b); + + // add by fujiwara + if (pdffile) { + pdffile_content << r << ' ' << g << ' ' << b << " RG" << std::endl; + pdffile_content << r << ' ' << g << ' ' << b << " rg" << std::endl; + } + if (svgfile) { + svg_r = static_cast< int >(r * 256); + svg_g = static_cast< int >(g * 256); + svg_b = static_cast< int >(b * 256); + } #ifdef FFJS_GRAPH - // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_couleur]] - EM_ASM_DOUBLE({ffjs_couleur($0,$1,$2)},r,g,b); + // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_couleur]] + EM_ASM_DOUBLE({ffjs_couleur($0, $1, $2)}, r, g, b); #endif } -extern void DefColor(float & r, float & g, float & b, - int k,int nb, bool hsv,bool ggrey,int nbcolors,float *colors); +extern void DefColor(float &r, float &g, float &b, int k, int nb, bool hsv, bool ggrey, int nbcolors, float *colors); -static XColor DefColorSansG( int k,int nb, bool hsv,bool ggrey,int nbcolors,float *colors) -{ - XColor C; - float r,g,b; - DefColor(r,g,b, k,nb,hsv,ggrey,nbcolors,colors); - C.red= (short unsigned int) (65535*r); - C.green=(short unsigned int)(65535*g); - C.blue= (short unsigned int) (65535*b); - return C; -} -void SetColorTable1(int nb,bool hsv,int nbcolors,float *colors) -{ +static XColor DefColorSansG(int k, int nb, bool hsv, bool ggrey, int nbcolors, float *colors) { + XColor C; + float r, g, b; + DefColor(r, g, b, k, nb, hsv, ggrey, nbcolors, colors); + C.red = (short unsigned int)(65535 * r); + C.green = (short unsigned int)(65535 * g); + C.blue = (short unsigned int)(65535 * b); + return C; +} +void SetColorTable1(int nb, bool hsv, int nbcolors, float *colors) { static bool greyo = !grey; - static float *colorso =0; - if(!INITGRAPH) return; - if (ncolortable == nb && greyo == grey && colorso == colors ) return;// optim - greyo = grey; - colorso=colors; - if (nbcolors && nb>2) - { - if(colortable) delete [] colortable; - colortable = new XColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - for (int i0=0;i02 && nb < 256) - { - nb = Max(nb,8); - if (ncolortable == nb) return;// optim - if(colortable) delete [] colortable; - colortable = new XColor[nb]; - ncolortable = nb; - if(LastColor>1) LastColor=nb-1; - // cout << "SetColorTable "<< nb << endl; - int k=0; - colortable[k].red= 65535; - colortable[k].green= 65535; - colortable[k].blue= 65535; - k++; - colortable[k].red=0; - colortable[k].green=0; - colortable[k].blue=0; - k++; - nb = nb -2; - for (long i0=0;i0 2) { + if (colortable) delete[] colortable; + colortable = new XColor[nb]; + ncolortable = nb; + if (LastColor > 1) LastColor = nb - 1; + for (int i0 = 0; i0 < nb; i0++) { + colortable[i0] = DefColorSansG(i0, nb, hsv, grey, nbcolors, colors); + } + + } else + ncolortable = 0; +} +void SetColorTable(int nb) { + if (fcolor && nb > 2 && nb < 256) { + nb = Max(nb, 8); + if (ncolortable == nb) return; // optim + if (colortable) delete[] colortable; + colortable = new XColor[nb]; + ncolortable = nb; + if (LastColor > 1) LastColor = nb - 1; + // cout << "SetColorTable "<< nb << endl; + int k = 0; + colortable[k].red = 65535; + colortable[k].green = 65535; + colortable[k].blue = 65535; + k++; + colortable[k].red = 0; + colortable[k].green = 0; + colortable[k].blue = 0; + k++; + nb = nb - 2; + for (long i0 = 0; i0 < nb; i0++, k++) { + // long i1 = nb - i0; + long i6 = i0 * 6; + long j0 = i6 / nb; // in 0..6 + long j1 = j0 + 1; // in 1..6 + long k0 = i0 - (nb * j0) / 6L; + long k1 = (nb * j1) / 6L - i0; + long kk = k0 + k1; + // cout <\n", - currx*svg_s, curry*svg_s, newx*svg_s, newy*svg_s, svg_r, svg_g, svg_b, svg_lw); + if (svgfile) { + fprintf(svgfile, "\n", currx * svg_s, curry * svg_s, newx * svg_s, newy * svg_s, svg_r, svg_g, + svg_b, svg_lw); } // add by fujiwara - currx = newx; curry = newy; + currx = newx; + curry = newy; #ifdef FFJS_GRAPH // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_rlineto]] - EM_ASM_INT({ffjs_rlineto($0,$1)},newx,newy); + EM_ASM_INT({ffjs_rlineto($0, $1)}, newx, newy); #endif } -void cadreortho(reel centrex, reel centrey, reel rayon) -{ +void cadreortho(reel centrex, reel centrey, reel rayon) { - if (height < width) - { + if (height < width) { rymin = centrey - rayon; rymax = centrey + rayon; - echx = echy= height / (2 * rayon); - rxmin= centrex - width / (2 * echx); - rxmax= centrex + width / (2 * echx); - } - else - { + echx = echy = height / (2 * rayon); + rxmin = centrex - width / (2 * echx); + rxmax = centrex + width / (2 * echx); + } else { rxmin = centrex - rayon; rxmax = centrex + rayon; echx = echy = width / (2 * rayon); @@ -552,217 +479,193 @@ void cadreortho(reel centrex, reel centrey, reel rayon) } } -void plotstring (const char * string) -{ //int l = strlen(string); - if(psfile) fprintf(psfile,"(%s) %d %d S\n",string,currx,height-curry); - +void plotstring(const char *string) { // int l = strlen(string); + if (psfile) fprintf(psfile, "(%s) %d %d S\n", string, currx, height - curry); + // add by fujiwara - if( pdffile ){ - pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size - pdffile_content << "1 0 0 1 " << currx*pdf_s << ' ' << (height-curry)*pdf_s << " Tm" << std::endl; - pdffile_content << "(" << string << ") Tj ET" << std::endl; + if (pdffile) { + pdffile_content << "BT /F1 " << 9 << " Tf" << std::endl; // 9*pdf_s : text font size + pdffile_content << "1 0 0 1 " << currx * pdf_s << ' ' << (height - curry) * pdf_s << " Tm" << std::endl; + pdffile_content << "(" << string << ") Tj ET" << std::endl; } - if( svgfile ){ - fprintf(svgfile,"%s\n",currx*svg_s,curry*svg_s,string); + if (svgfile) { + fprintf(svgfile, "%s\n", currx * svg_s, curry * svg_s, string); } // add by fujiwara - + #ifdef FFJS_GRAPH // ALH - <> javascript graph - Send the string character by character to // [[file:~/ffjs/main.js::ffjs_plotstring]] because there is no string parameter at the moment // [[http://kripken.github.io/emscripten-site/docs/api_reference/emscripten.h.html#c.EM_ASM_]] - - for(const char *c=string;*c;c++)EM_ASM_INT({ffjs_plotstring($0)},*c); + + for (const char *c = string; *c; c++) EM_ASM_INT({ffjs_plotstring($0)}, *c); EM_ASM(ffjs_plotstring(0)); #endif } -void showgraphic() -{ -} +void showgraphic( ) {} -void penthickness(int pepais) -{ - if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais*2); +void penthickness(int pepais) { + if (psfile) fprintf(psfile, "%d setlinewidth\n", pepais * 2); // add by fujiwara - if ( pdffile ){ - pdffile_content << pepais << " w" << std::endl; + if (pdffile) { + pdffile_content << pepais << " w" << std::endl; } - if ( svgfile ){ - svg_lw = pepais; + if (svgfile) { + svg_lw = pepais; } // add bu fujiwara #ifdef FFJS_GRAPH // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_penthickness]] - EM_ASM_INT({ffjs_penthickness($0)},pepais); + EM_ASM_INT({ffjs_penthickness($0)}, pepais); #endif } -void x11linsrn(int * ,int * ,int * ,int * ); -void x11linsrn(int * ,int * ,int * ,int * ) - //int *x1,*x2,*y1,*y2; -{ -} - - -void viderbuff() -{ -} +void x11linsrn(int *, int *, int *, int *); +void x11linsrn(int *, int *, int *, int *) +// int *x1,*x2,*y1,*y2; +{} +void viderbuff( ) {} -void cercle(reel , reel , reel ); -void cercle(reel , reel , reel ) -{ - //int r = (int) (rayon * echx); +void cercle(reel, reel, reel); +void cercle(reel, reel, reel) { + // int r = (int) (rayon * echx); } -void reffecran(){ +void reffecran( ) { #ifdef FFJS_GRAPH // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_graphstart]] - EM_ASM(ffjs_graphstart()); + EM_ASM(ffjs_graphstart( )); #endif } -void fillpoly(int n, float *poly) -{ +void fillpoly(int n, float *poly) { int i; - if (psfile) - { - fprintf(psfile,"bF "); - for (i=0;i\n", svg_r, svg_g, svg_b, svg_lw, svg_r, svg_g, svg_b); } - if ( svgfile ) - { - fprintf(svgfile, "\n", - svg_r,svg_g,svg_b, svg_lw, svg_r,svg_g,svg_b); - } // add by fujiwara - + #ifdef FFJS_GRAPH // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_fillpoly]] - EM_ASM_INT({ffjs_fillpoly_begin($0,$1)},scalx(poly[0]),scaly(poly[1])); - for(i=1;i(widthA4PDF) / width; + pdf_s = static_cast< float >(widthA4PDF) / width; pdffile = true; - pdffile_content << "q" << std::endl; // gsave - + pdffile_content << "q" << std::endl; // gsave + return; } -void closePDF(void) -{ - if(pdffile) { +void closePDF(void) { + if (pdffile) { - std::string PDFTitle = "plot() by FreeFem++"; - std::string AppName = "FreeFem++ v" + StrVersionNumber(); + std::string PDFTitle = "plot() by FreeFem++"; + std::string AppName = "FreeFem++ v" + StrVersionNumber( ); - SimplePDF_FF pdf( pdffile_name, PDFTitle.c_str(), AppName.c_str() ); + SimplePDF_FF pdf(pdffile_name, PDFTitle.c_str( ), AppName.c_str( )); - const int widthPDF = static_cast( width * pdf_s ); - const int heightPDF = static_cast( height * pdf_s ); + const int widthPDF = static_cast< int >(width * pdf_s); + const int heightPDF = static_cast< int >(height * pdf_s); - pdffile_content << "Q" << std::endl; + pdffile_content << "Q" << std::endl; - pdf.addPage( pdffile_content, widthPDF, heightPDF ); + pdf.addPage(pdffile_content, widthPDF, heightPDF); - pdffile = false; + pdffile = false; } - if( pdffile_name != nullptr ){ - delete [] pdffile_name; - pdffile_name = nullptr; + if (pdffile_name != nullptr) { + delete[] pdffile_name; + pdffile_name = nullptr; } return; } -void openSVG(const char *filename ) -{ - if(svgfile_save) closeSVG(); +void openSVG(const char *filename) { + if (svgfile_save) closeSVG( ); - const int widthA4PS = 596; - //const int heightA4PS = 842; - svg_s = static_cast(widthA4PS)/width; + const int widthA4PS = 596; + // const int heightA4PS = 842; + svg_s = static_cast< double >(widthA4PS) / width; char ffff[32]; int count = 0; - if(!filename){ + if (!filename) { bool notfound; do { struct stat buf; - snprintf(ffff,32,"rgraph_%.3d.svg",count++); - volatile int r = stat(ffff,&buf) ; + snprintf(ffff, 32, "rgraph_%.3d.svg", count++); + volatile int r = stat(ffff, &buf); notfound = (r != 0); - if( count > 1000 ) break; - } while ( !notfound ); - } - - const char *fsvg (filename?filename:ffff); - - svgfile=fopen(fsvg,"w"); - - if(svgfile) { - svgfile_save=svgfile; - fprintf(svgfile,"\n\n"); - fprintf(svgfile,"\n\n", StrVersionNumber().c_str()); - fprintf(svgfile,"\n", - static_cast(width*svg_s), static_cast(height*svg_s)); + if (count > 1000) break; + } while (!notfound); } - else - { + + const char *fsvg(filename ? filename : ffff); + + svgfile = fopen(fsvg, "w"); + + if (svgfile) { + svgfile_save = svgfile; + fprintf(svgfile, "\n\n"); + fprintf(svgfile, "\n\n", StrVersionNumber( ).c_str( )); + fprintf(svgfile, "\n", static_cast< int >(width * svg_s), static_cast< int >(height * svg_s)); + } else { cerr << " Err opening SVG file " << fsvg << endl; } return; } -void closeSVG(void) -{ - if(svgfile_save) { - fprintf(svgfile_save,"\n"); +void closeSVG(void) { + if (svgfile_save) { + fprintf(svgfile_save, "\n"); fclose(svgfile_save); } - svgfile_save=0; - svgfile=0; + svgfile_save = 0; + svgfile = 0; return; } @@ -770,31 +673,26 @@ void closeSVG(void) // add by fujiwara end //---------------------------------------------------------------------- +int execute(const char *str) { + if (verbosity) cout << "exec: " << str << endl; + return system(str); +} -int execute (const char * str) -{ - if(verbosity) - cout << "exec: " << str << endl; - return system(str); +char Getijc(int *x1, int *y1); +char Getijc(int *x1, int *y1) { + // char char1; + *x1 = 0; + *y1 = 0; + // cout << "entre un caractere ? "; + // cin >>char1 ; + return 0; // char1; } -char Getijc(int *x1,int *y1); -char Getijc(int *x1,int *y1) -{ - //char char1; - *x1=0; - *y1=0; - //cout << "entre un caractere ? "; - //cin >>char1 ; - return 0;// char1; -} - -char Getxyc(float &x,float &y) -{ +char Getxyc(float &x, float &y) { // cout << " in Getxyc" << endl; char c; - int i,j; - c = Getijc( &i,&j); + int i, j; + c = Getijc(&i, &j); x = scali(i); y = scalj(j); // cout << " out Getxyc" << x << " " << y << " " << c << endl; @@ -803,44 +701,37 @@ char Getxyc(float &x,float &y) } /// <> -void rattente(int ) -{ -} - void GetScreenSize(int &ix,int &iy) -{ +void rattente(int) {} +void GetScreenSize(int &ix, int &iy) { ix = width; iy = height; } // <> -void openPS(const char *filename ) -{ +void openPS(const char *filename) { char ffff[32]; - int count=0; - if(psfile_save) closePS(); + int count = 0; + if (psfile_save) closePS( ); time_t t_loc; - int widthA4PS=596; - //int heightA4PS=842; - float s= (double)widthA4PS/width; - char username[10]; - /*if (!cuserid(username)) */ strcpy(username,"inconnue"); + int widthA4PS = 596; + // int heightA4PS=842; + float s = (double)widthA4PS / width; + char username[10]; + /*if (!cuserid(username)) */ strcpy(username, "inconnue"); time(&t_loc); bool notfound; - if( !filename) - do { + if (!filename) do { struct stat buf; - snprintf(ffff,32,"rgraph_%.3d.ps",count++); - volatile int r= stat(ffff,&buf) ; - notfound = r !=0; - if(count>1000) break; - } while ( !notfound ); - + snprintf(ffff, 32, "rgraph_%.3d.ps", count++); + volatile int r = stat(ffff, &buf); + notfound = r != 0; + if (count > 1000) break; + } while (!notfound); - const char *fps (filename?filename:ffff); + const char *fps(filename ? filename : ffff); - - psfile=fopen(fps,"w"); + psfile = fopen(fps, "w"); #ifdef FFJS_GRAPH @@ -848,150 +739,152 @@ void openPS(const char *filename ) // [[file:~/ffjs/ffapi.js::ffjs_listgraphs]]. Send the file name character by character to // [[file:~/ffjs/ffapi.js::ffjs_listgraphs]] because there is no string parameter at the moment // [[http://kripken.github.io/emscripten-site/docs/api_reference/emscripten.h.html#c.EM_ASM_]] - - for(const char *c=fps;*c;c++)EM_ASM_INT({ffjs_listgraphs($0)},*c); + + for (const char *c = fps; *c; c++) EM_ASM_INT({ffjs_listgraphs($0)}, *c); EM_ASM(ffjs_listgraphs(0)); #endif - if(psfile) { - psfile_save=psfile; - fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user"); - fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc)); - fprintf(psfile,"%%%%Pages: 1\n"); - fprintf(psfile,"%%%%BoundingBox: 0 0 %d %d\n",int(width*s),int(height*s)); - fprintf(psfile,"%%%%EndComments\n"); - fprintf(psfile," /L {newpath moveto lineto stroke} def\n"); - fprintf(psfile," /C {setrgbcolor} def\n"); - fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); - fprintf(psfile," %f %f scale \n",s,s); - fprintf(psfile," 0 %d 0 %d rec clip\n",int(width),int(height)); - fprintf(psfile," /Helvetica findfont %d scalefont setfont\n",int(9/s)); - fprintf(psfile," /S {moveto show} def\n"); - fprintf(psfile," /bF { mark} def \n"); - fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); - fprintf(psfile," /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); - fprintf(psfile," 2 setlinewidth\n"); - } - else + if (psfile) { + psfile_save = psfile; + fprintf(psfile, "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n", "user"); + fprintf(psfile, "%%%%CreationDate: %s", ctime(&t_loc)); + fprintf(psfile, "%%%%Pages: 1\n"); + fprintf(psfile, "%%%%BoundingBox: 0 0 %d %d\n", int(width * s), int(height * s)); + fprintf(psfile, "%%%%EndComments\n"); + fprintf(psfile, " /L {newpath moveto lineto stroke} def\n"); + fprintf(psfile, " /C {setrgbcolor} def\n"); + fprintf(psfile, " /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n"); + fprintf(psfile, " %f %f scale \n", s, s); + fprintf(psfile, " 0 %d 0 %d rec clip\n", int(width), int(height)); + fprintf(psfile, " /Helvetica findfont %d scalefont setfont\n", int(9 / s)); + fprintf(psfile, " /S {moveto show} def\n"); + fprintf(psfile, " /bF { mark} def \n"); + fprintf(psfile, " /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n"); + fprintf(psfile, " /P { /yy exch def /xx exch def xx xx 1 add yy yy 1 add rec fill } def\n"); + fprintf(psfile, " 2 setlinewidth\n"); + } else cerr << " Err opening postscript file " << fps << endl; } -void closePS(void) -{ - if(psfile_save) { - fprintf(psfile_save,"showpage\n"); +void closePS(void) { + if (psfile_save) { + fprintf(psfile_save, "showpage\n"); fclose(psfile_save); } - psfile_save=0; - psfile=0; + psfile_save = 0; + psfile = 0; #ifdef FFJS_GRAPH // ALH - <> javascript graph [[file:~/ffjs/main.js::ffjs_graphdone]] - EM_ASM({ffjs_graphdone()}); + EM_ASM({ffjs_graphdone( )}); #endif } - void coutmode(short ) {} -// bof bof --- - float GetHeigthFont() -{ - double widthA4PS=596; - float s=widthA4PS/width; - return 5.5/s/echy; -} - void Commentaire(const char * c) - { - if(psfile) { - fprintf(psfile,"%% %s\n",c); - } - // add by fujiwara - if( pdffile ) { - //fprintf(pdffile,"%% %s\n",c); - } - if( svgfile ) { - fprintf(svgfile,"%% %s\n",c); - } +void coutmode(short) {} +// bof bof --- +float GetHeigthFont( ) { + double widthA4PS = 596; + float s = widthA4PS / width; + return 5.5 / s / echy; +} +void Commentaire(const char *c) { + if (psfile) { + fprintf(psfile, "%% %s\n", c); + } // add by fujiwara + if (pdffile) { + // fprintf(pdffile,"%% %s\n",c); } - void NoirEtBlanc(int NB) - { - if(NB) LastColor=1; - else LastColor=ncolortable?ncolortable:2; + if (svgfile) { + fprintf(svgfile, "%% %s\n", c); } - - void MettreDansPostScript(int in) - { - if(in) psfile=psfile_save; - else psfile=0; - } // add by fujiwara - void MettreDansPDF(int in) // put into PDF - { - if(in) pdffile=true; - else pdffile=false; - } - void MettreDansSVG(int in) // put into SVG - { - if(in) svgfile=svgfile_save; - else svgfile=0; - } - // add by fujiwara - -static void FillRect(float x0,float y0, float x1, float y1) - { - float r[8]; - r[0]=x0;r[1]=y0; - r[2]=x1;r[3]=y0; - r[4]=x1;r[5]=y1; - r[6]=x0;r[7]=y1; - fillpoly(4,r); - } -int PutLevel(int lineno, float xf, int col); -int PutLevel(int lineno, float xf, int col) +} +void NoirEtBlanc(int NB) { + if (NB) + LastColor = 1; + else + LastColor = ncolortable ? ncolortable : 2; +} + +void MettreDansPostScript(int in) { + if (in) + psfile = psfile_save; + else + psfile = 0; +} +// add by fujiwara +void MettreDansPDF(int in) // put into PDF +{ + if (in) + pdffile = true; + else + pdffile = false; +} +void MettreDansSVG(int in) // put into SVG { - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - float xleft = xmax - (xmax-xmin)*0.1; - float ytop = ymax; - float ydelta = (ymax-ymin)/40; - ydelta=GetHeigthFont(); - xleft = xmax - 6*ydelta; - ytop -= ydelta*(col+2); + if (in) + svgfile = svgfile_save; + else + svgfile = 0; +} +// add by fujiwara + +static void FillRect(float x0, float y0, float x1, float y1) { + float r[8]; + r[0] = x0; + r[1] = y0; + r[2] = x1; + r[3] = y0; + r[4] = x1; + r[5] = y1; + r[6] = x0; + r[7] = y1; + fillpoly(4, r); +} +int PutLevel(int lineno, float xf, int col); +int PutLevel(int lineno, float xf, int col) { + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + float xleft = xmax - (xmax - xmin) * 0.1; + float ytop = ymax; + float ydelta = (ymax - ymin) / 40; + ydelta = GetHeigthFont( ); + xleft = xmax - 6 * ydelta; + ytop -= ydelta * (col + 2); couleur(col); - FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.); - rmoveto(xleft+ydelta*1.4,ytop+ydelta/4); + FillRect(xleft + ydelta / 8., ytop + ydelta / 8., xleft + ydelta * 7. / 8., ytop + ydelta * 7. / 8.); + rmoveto(xleft + ydelta * 1.4, ytop + ydelta / 4); char buf[30]; - snprintf(buf,30,"%g",xf); + snprintf(buf, 30, "%g", xf); couleur(1); plotstring(buf); - return lineno; + return lineno; } - void ShowHelp(const char * s,int k) -{ - if(k) { +void ShowHelp(const char *s, int k) { + if (k) { MettreDansPostScript(0); - MettreDansPDF(0); // add by fujiwara - MettreDansSVG(0); // add by fujiwara + MettreDansPDF(0); // add by fujiwara + MettreDansSVG(0); // add by fujiwara couleur(1); - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30); + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + rmoveto(xmin + (xmax - xmin) / 100, ymax - (k) * (ymax - ymin) / 30); plotstring(s); MettreDansPostScript(1); - MettreDansPDF(1); // add by fujiwara - MettreDansSVG(1); // add by fujiwara - // couleur(1); + MettreDansPDF(1); // add by fujiwara + MettreDansSVG(1); // add by fujiwara + // couleur(1); } } - void setgrey(bool gg ){grey=gg;} - int getgrey(){ return grey;} +void setgrey(bool gg) { grey = gg; } +int getgrey( ) { return grey; } class Grid; void SaveMesh(Grid &); -void SavePlot(int , Grid& , double *); -void SavePlot(int , Grid& , float *); - -void SaveMesh(Grid &){} -void SavePlot(int , Grid& , double *){} -void SavePlot(int , Grid& , float *){} +void SavePlot(int, Grid &, double *); +void SavePlot(int, Grid &, float *); +void SaveMesh(Grid &) {} +void SavePlot(int, Grid &, double *) {} +void SavePlot(int, Grid &, float *) {} diff --git a/src/Graphics/xglrgraf.cpp b/src/Graphics/xglrgraf.cpp index eb64a34ee..f43a78e8d 100644 --- a/src/Graphics/xglrgraf.cpp +++ b/src/Graphics/xglrgraf.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/src/bamg/bamg.cpp b/src/bamg/bamg.cpp index abae5b2b4..8feb19859 100644 --- a/src/bamg/bamg.cpp +++ b/src/bamg/bamg.cpp @@ -110,8 +110,7 @@ int main(int argc, char **argv) { #ifdef LONGLONG long long bidon = 2; if ((double)bidon != 2.0) { - cerr << "Compiler bug Pb of cast of long long to a double => remove the LONGLONG define" - << endl; + cerr << "Compiler bug Pb of cast of long long to a double => remove the LONGLONG define" << endl; exit(10); } #endif @@ -150,9 +149,8 @@ int main(int argc, char **argv) { double power = 1; Triangles *Thr = 0, *Thb = 0; - char *fgeom = 0, *fmeshback = 0, *fmeshout = 0, *fmeshr = 0, *fmetrix = 0, *famfmt = 0, *fmsh = 0, - *fnopo = 0, *fftq = 0, *fam = 0, *famdba = 0, *rbb = 0, *rBB = 0, *wbb = 0, *wBB = 0, - *fMbb = 0, *foM = 0, *fMBB = 0; + char *fgeom = 0, *fmeshback = 0, *fmeshout = 0, *fmeshr = 0, *fmetrix = 0, *famfmt = 0, *fmsh = 0, *fnopo = 0, *fftq = 0, *fam = 0, *famdba = 0, *rbb = 0, *rBB = 0, *wbb = 0, *wBB = 0, *fMbb = 0, + *foM = 0, *fMBB = 0; verbosity = 2; char *datargv[128]; int datargc = 1; @@ -280,8 +278,7 @@ int main(int argc, char **argv) { omega = atof(argv[i]); else { cout << " Error in the arguments " << i << " of " << bamgversion << endl; - cout << " argument [" << i << "]= `" << ((i < argc) ? argv[i] : " The Lastest ") << "`" - << endl; + cout << " argument [" << i << "]= `" << ((i < argc) ? argv[i] : " The Lastest ") << "`" << endl; cout << " Usage :" << endl; cout << " Mesh INPUT: The 2 arguments are exclusives." << endl; cout << "" << endl; @@ -303,21 +300,17 @@ int main(int argc, char **argv) { cout << " same as in the case of -b argument" << endl; cout << "" << endl; cout << " -thetamax (double) change the angular limit for a corner in degre " << endl; - cout << " the angle is defined from 2 normals of 2 concecutives edges " - << endl; - cout << " if no geometry cf reading an am_fmt, amdba, nopo .. file " - << endl; + cout << " the angle is defined from 2 normals of 2 concecutives edges " << endl; + cout << " if no geometry cf reading an am_fmt, amdba, nopo .. file " << endl; cout << "" << endl; cout << " METRIC definition or mesh size definition, one of the" << endl; cout << " 2 next arguments is need in case of mesh adaption." << endl; cout << "" << endl; - cout << " -M filename Set the metric which is defined on the background mesh " - << endl; + cout << " -M filename Set the metric which is defined on the background mesh " << endl; cout << " or on the geometry. Metric file." << endl; cout << " -Mbb filename Set the solution defined on the background mesh for" << endl; - cout << " metric construction, the solutions was FE P1 defined on " - << endl; + cout << " metric construction, the solutions was FE P1 defined on " << endl; cout << " the background mesh. bb file. " << endl; cout << " -MBB filename same with -Mbb but with BB file " << endl; cout << "" << endl; @@ -326,8 +319,7 @@ int main(int argc, char **argv) { cout << " coef on the mesh size (1 by default)." << endl; cout << " -power (double) Set the power parameter of hessien to construct " << endl; cout << " the metric (1 by default)" << endl; - cout << " -maxsubdiv (double) Change the metric such that the maximal subdivision " - << endl; + cout << " -maxsubdiv (double) Change the metric such that the maximal subdivision " << endl; cout << " of a background's edge is bound by the " << endl; cout << " given number (always limited by 10) " << endl; cout << " -ratio (double) Set the ratio for a smoothing of the metric." << endl; @@ -335,19 +327,15 @@ int main(int argc, char **argv) { cout << " and if ratio is in [1.1,10] then the smoothing " << endl; cout << " change the metrix such that the greatest geometrical" << endl; cout << " progression (speed of mesh size variation) " << endl; - cout << " in a mesh is bounded by ratio (by default no smoothing)." - << endl; + cout << " in a mesh is bounded by ratio (by default no smoothing)." << endl; cout << " -hmin (double) Set the value of the minimal edge size." << endl; - cout << " -hminaniso (double) Set the value of the minimal edge size and save aniso." - << endl; + cout << " -hminaniso (double) Set the value of the minimal edge size and save aniso." << endl; cout << " -hmax (double) Set the value of the maximal edge size." << endl; cout << " -NbSmooth (int) Number of Smoothing iteration " << endl; cout << " (3 by default if the metric is set otherwise 0)." << endl; cout << " -omega (double) relaxation parameter for Smoothing " << endl; - cout << " -splitpbedge split in 2 all internal edges with 2 vertex on boundary" - << endl; - cout << " -nosplitpbedge d'ont cut internal edges with 2 vertex on boundary (default)" - << endl; + cout << " -splitpbedge split in 2 all internal edges with 2 vertex on boundary" << endl; + cout << " -nosplitpbedge d'ont cut internal edges with 2 vertex on boundary (default)" << endl; cout << "" << endl; cout << "" << endl; cout << " the next arguments are used with the -Mbb argument" << endl; @@ -375,8 +363,7 @@ int main(int argc, char **argv) { cout << "" << endl; cout << " -v (int) Set the level of impression (verbosity) " << endl; cout << " between 0 and 10 (1 by default)." << endl; - cout << " -nbv (int) Set the maximal of vertices (" << nbvx << " by default)." - << endl; + cout << " -nbv (int) Set the maximal of vertices (" << nbvx << " by default)." << endl; cout << "" << endl; cout << "" << endl; cout << " To interpoled a solution form background mesh to generated " << endl; @@ -411,8 +398,7 @@ int main(int argc, char **argv) { cout << endl; - cout << " Remark: if no argument is given when the arguments are read in " << datafile - << " file" << endl; + cout << " Remark: if no argument is given when the arguments are read in " << datafile << " file" << endl; exit(3); } // some verification @@ -445,26 +431,20 @@ int main(int argc, char **argv) { } #endif - if (verbosity) - cout << bamgversion << " : "; - if (fgeom && fileout) - cout << " Construction of a mesh from the geometry : " << fgeom << endl - << " with less than " << nbvx << " vertices " << endl; - else if (fmeshback && fileout) - if (NoMeshReconstruction) - cout << " Modification of a adpated mesh " << fmeshback << " with less than " << nbvx - << " vertices" << endl; - else - cout << " Construction of a adpated mesh from the background mesh: " << fmeshback - << " with less than " << nbvx << " vertices" << endl; - else if (fmeshback && foM) - cout << " Construction of the metric file on the background mesh: " << fmeshback << endl; + if (verbosity) cout << bamgversion << " : "; + if (fgeom && fileout) + cout << " Construction of a mesh from the geometry : " << fgeom << endl << " with less than " << nbvx << " vertices " << endl; + else if (fmeshback && fileout) + if (NoMeshReconstruction) + cout << " Modification of a adpated mesh " << fmeshback << " with less than " << nbvx << " vertices" << endl; + else + cout << " Construction of a adpated mesh from the background mesh: " << fmeshback << " with less than " << nbvx << " vertices" << endl; + else if (fmeshback && foM) + cout << " Construction of the metric file on the background mesh: " << fmeshback << endl; if (fgeom && fileout) { double time1; - if (verbosity) - cout << " Construction of a mesh from the geometry : " << fgeom << endl - << " with less than " << nbvx << " vertices " << endl; + if (verbosity) cout << " Construction of a mesh from the geometry : " << fgeom << endl << " with less than " << nbvx << " vertices " << endl; time0 = CPUtime( ); Geometry Gh(fgeom); @@ -504,9 +484,7 @@ int main(int argc, char **argv) { #endif time3 = CPUtime( ); if (verbosity > 1) - cout << " Cpu for meshing :" << setw(8) << time2 - time1 << "s, for Smoothing " - << time3 - time2 << "s Nb Vertices/s = " << (Th.nbv) / (time2 - time1) << setw(0) - << endl; + cout << " Cpu for meshing :" << setw(8) << time2 - time1 << "s, for Smoothing " << time3 - time2 << "s Nb Vertices/s = " << (Th.nbv) / (time2 - time1) << setw(0) << endl; if (fmeshout) Th.Write(fmeshout, Triangles::BDMesh); if (famfmt) Th.Write(famfmt, Triangles::am_fmtMesh); if (fam) Th.Write(fam, Triangles::amMesh); @@ -526,17 +504,14 @@ int main(int argc, char **argv) { time3 = CPUtime( ); if (verbosity > 0) { - cout << " Cpu for meshing with io :" << setw(8) << time3 - time0 - << "s Nb Vertices/s = " << (Th.nbv) / (time3 - time0) << setw(0) << endl; + cout << " Cpu for meshing with io :" << setw(8) << time3 - time0 << "s Nb Vertices/s = " << (Th.nbv) / (time3 - time0) << setw(0) << endl; cout << " Nb vertices = " << Th.nbv; - if (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2) - cout << " Nb Triangles = " << (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2); + if (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2) cout << " Nb Triangles = " << (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2); if (Th.NbOfQuad) cout << " Nb Quadrilaterals = " << Th.NbOfQuad; cout << endl; } - } else if (fmeshback && (fmetrix || fMbb || fMBB || NoMeshReconstruction) && - (fileout || foM || (rbb && wbb) || (rBB && wBB))) { + } else if (fmeshback && (fmetrix || fMbb || fMBB || NoMeshReconstruction) && (fileout || foM || (rbb && wbb) || (rBB && wBB))) { // to be sure the value was not stupide time0 = CPUtime( ); @@ -560,8 +535,7 @@ int main(int argc, char **argv) { MeshError(99); } assert(lsolbb == BTh.nbv); - BTh.IntersectConsMetric(solMbb, nbsolbb, 0, hmin, hmax, sqrt(err) * coef, 1e30, - AbsError ? 0.0 : CutOff, nbjacoby, Rescaling, power, ChoiseHessien); + BTh.IntersectConsMetric(solMbb, nbsolbb, 0, hmin, hmax, sqrt(err) * coef, 1e30, AbsError ? 0.0 : CutOff, nbjacoby, Rescaling, power, ChoiseHessien); if (!rbbeqMbb) delete[] solMbb, solMbb = 0; } if (fMBB) { @@ -572,8 +546,7 @@ int main(int argc, char **argv) { MeshError(99); } assert(lsolBB == BTh.nbv); - BTh.IntersectConsMetric(solMBB, nbsolBB, 0, hmin, hmax, sqrt(err) * coef, 1e30, - AbsError ? 0.0 : CutOff, nbjacoby, Rescaling, ChoiseHessien); + BTh.IntersectConsMetric(solMBB, nbsolBB, 0, hmin, hmax, sqrt(err) * coef, 1e30, AbsError ? 0.0 : CutOff, nbjacoby, Rescaling, ChoiseHessien); if (!rBBeqMBB) delete[] solMBB, solMBB = 0; } @@ -598,10 +571,9 @@ int main(int argc, char **argv) { else Thr = new Triangles(fmeshr, cutoffradian), Thb = &BTh; // read the new - Triangles &Th(*(NoMeshReconstruction - ? new Triangles(*Thr, &Thr->Gh, Thb, - nbvx) // copy the mesh + free space to modification - : new Triangles(nbvx, BTh, KeepBackVertices) // construct a new mesh + Triangles &Th(*(NoMeshReconstruction ? new Triangles(*Thr, &Thr->Gh, Thb, + nbvx) // copy the mesh + free space to modification + : new Triangles(nbvx, BTh, KeepBackVertices) // construct a new mesh )); if (Thr != &BTh) delete Thr; @@ -611,9 +583,7 @@ int main(int argc, char **argv) { Th.ReNumberingTheTriangleBySubDomain( ); time3 = CPUtime( ); - if (verbosity > 0) - cout << " Cpu time for meshing : " << time3 - time2 - << "s Nb Vertices/s = " << (Th.nbv) / (time3 - time2) << endl; + if (verbosity > 0) cout << " Cpu time for meshing : " << time3 - time2 << "s Nb Vertices/s = " << (Th.nbv) / (time3 - time2) << endl; if (verbosity > 3) Th.ShowHistogram( ); if (NbSmooth > 0) Th.SmoothingVertex(NbSmooth, omega); if (verbosity > 3 && NbSmooth > 0) Th.ShowHistogram( ); @@ -711,11 +681,9 @@ int main(int argc, char **argv) { Int4 iBB2 = nbfieldBB * i2; Int4 j = 0; - for (j = 0; j < nbfieldbb; j++) - *fbb << " " << (a[0] * solbb[ibb0++] + a[1] * solbb[ibb1++] + a[2] * solbb[ibb2++]); + for (j = 0; j < nbfieldbb; j++) *fbb << " " << (a[0] * solbb[ibb0++] + a[1] * solbb[ibb1++] + a[2] * solbb[ibb2++]); - for (j = 0; j < nbfieldBB; j++) - *fBB << " " << (a[0] * solBB[iBB0++] + a[1] * solBB[iBB1++] + a[2] * solBB[iBB2++]); + for (j = 0; j < nbfieldBB; j++) *fBB << " " << (a[0] * solBB[iBB0++] + a[1] * solBB[iBB1++] + a[2] * solBB[iBB2++]); if (fbb) *fbb << endl; if (fBB) *fBB << endl; @@ -725,16 +693,12 @@ int main(int argc, char **argv) { if (solbb) delete[] solbb; if (solBB) delete[] solBB; double time04 = CPUtime( ); - if (verbosity > 0) - cout << " Cpu time for interpolation " << time04 - time00 << " s" << endl; + if (verbosity > 0) cout << " Cpu time for interpolation " << time04 - time00 << " s" << endl; } time4 = CPUtime( ); if (verbosity > 0) { - cout << " Cpu time for meshing with io : " << time4 - time0 - << "s Nb Vertices/s = " << Th.nbv / (time4 - time0) << endl - << " Nb vertices = " << Th.nbv; - if (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2) - cout << " Nb Triangles = " << (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2); + cout << " Cpu time for meshing with io : " << time4 - time0 << "s Nb Vertices/s = " << Th.nbv / (time4 - time0) << endl << " Nb vertices = " << Th.nbv; + if (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2) cout << " Nb Triangles = " << (Th.nbt - Th.NbOutT - Th.NbOfQuad * 2); if (Th.NbOfQuad) cout << " Nb Quadrilaterals = " << Th.NbOfQuad; cout << endl; } diff --git a/src/bamg/cvmsh2.cpp b/src/bamg/cvmsh2.cpp index 4b5a18fb4..32dd73a97 100644 --- a/src/bamg/cvmsh2.cpp +++ b/src/bamg/cvmsh2.cpp @@ -80,12 +80,12 @@ void NewHandler( ) { exit(1); } -void MeshErrorIO(ios&) { +void MeshErrorIO(ios &) { MeshError(999); exit(1); } -int main(int argc, char** argv) { +int main(int argc, char **argv) { Real8 cutoffradian = 30.0 * Pi / 180.0; char *fin = 0, *fout = 0, *fgeom = 0; verbosity = 2; diff --git a/src/bamg/drawbdmesh.cpp b/src/bamg/drawbdmesh.cpp index 6d65be92e..877d7fb68 100644 --- a/src/bamg/drawbdmesh.cpp +++ b/src/bamg/drawbdmesh.cpp @@ -45,7 +45,7 @@ bool withrgraphique = true; #else bool withrgraphique = false; #endif -//#include +// #include int initgraph = 0; void NewHandler( ); void NewHandler( ) { diff --git a/src/bamg/global.cpp b/src/bamg/global.cpp index 9b2b0ee88..4a2afb7c2 100644 --- a/src/bamg/global.cpp +++ b/src/bamg/global.cpp @@ -81,9 +81,8 @@ void init_by_array(unsigned long init_key[], int key_length) { j = 0; k = (N > key_length ? N : key_length); for (; k; k--) { - mt[i] = - (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL)) + init_key[j] + j; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL)) + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; j++; if (i >= N) { @@ -94,7 +93,7 @@ void init_by_array(unsigned long init_key[], int key_length) { } for (k = N - 1; k; k--) { mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1566083941UL)) - i; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; if (i >= N) { mt[0] = mt[N - 1]; diff --git a/src/bamglib/Mesh2.cpp b/src/bamglib/Mesh2.cpp index e6c59f5ca..253ef1e0e 100644 --- a/src/bamglib/Mesh2.cpp +++ b/src/bamglib/Mesh2.cpp @@ -27,11 +27,11 @@ */ #ifdef __MWERKS__ #ifdef __INTEL__ -//#pragma global_optimizer off -//#pragma inline_depth(0) -//#pragma optimization_level 2 +// #pragma global_optimizer off +// #pragma inline_depth(0) +// #pragma optimization_level 2 #endif -//#pragma inline_depth 0 +// #pragma inline_depth 0 #endif extern bool withrgraphique; #include @@ -58,7 +58,7 @@ namespace bamg { static unsigned long myrand_next = 1; /* RAND_MAX assumed to be 32767 */ - int myrand(void) {// in 0:2^31 + int myrand(void) { // in 0:2^31 // myrand_next = myrand_next * 1103515245 + 12345; // return((unsigned)(myrand_next/65536) % 32768); @@ -117,9 +117,7 @@ namespace bamg { #endif Int4 AGoodNumberPrimeWith(Int4 n) { - const Int4 BigPrimeNumber[] = {567890359L, 567890431L, 567890437L, 567890461L, 567890471L, - 567890483L, 567890489L, 567890497L, 567890507L, 567890591L, - 567890599L, 567890621L, 567890629L, 0}; + const Int4 BigPrimeNumber[] = {567890359L, 567890431L, 567890437L, 567890461L, 567890471L, 567890483L, 567890489L, 567890497L, 567890507L, 567890591L, 567890599L, 567890621L, 567890629L, 0}; Int4 o = 0; Int4 pi = BigPrimeNumber[1]; @@ -144,8 +142,7 @@ namespace bamg { ostream &operator<<(ostream &f, const Triangle &ta) { if (CurrentTh) - f << "[" << CurrentTh->Number(ta) << "::" << CurrentTh->Number(ta.ns[0]) << "," - << CurrentTh->Number(ta.ns[1]) << "," << CurrentTh->Number(ta.ns[2]) << "," + f << "[" << CurrentTh->Number(ta) << "::" << CurrentTh->Number(ta.ns[0]) << "," << CurrentTh->Number(ta.ns[1]) << "," << CurrentTh->Number(ta.ns[2]) << "," << "{" << CurrentTh->Number(ta.at[0]) << " " << ta.aa[0] << "} " << "{" << CurrentTh->Number(ta.at[1]) << " " << ta.aa[1] << "} " << "{" << CurrentTh->Number(ta.at[2]) << " " << ta.aa[2] << "} " @@ -191,8 +188,7 @@ namespace bamg { (*t1)(VerticesOfTriangularEdge[a1][1]) = s2; // avant sb (*t2)(VerticesOfTriangularEdge[a2][1]) = s1; // avant sa // mise a jour des 2 adjacences externes - TriangleAdjacent taas1 = t1->Adj(as1), taas2 = t2->Adj(as2), tas1(t1, as1), tas2(t2, as2), - ta1(t1, a1), ta2(t2, a2); + TriangleAdjacent taas1 = t1->Adj(as1), taas2 = t2->Adj(as2), tas1(t1, as1), tas2(t2, as2), ta1(t1, a1), ta2(t2, a2); #ifdef DEBUG assert(!ta1.Locked( )); assert(!ta2.Locked( )); @@ -489,8 +485,7 @@ namespace bamg { return er; } - Metric Triangles::MetricAt( - const R2 &A) const { // if ((vertices <= &v) && (vertices < v+nbv)) return v.m; + Metric Triangles::MetricAt(const R2 &A) const { // if ((vertices <= &v) && (vertices < v+nbv)) return v.m; I2 a = toI2(A); Icoor2 deta[3]; Triangle *t = FindTriangleContening(a, deta); @@ -534,8 +529,7 @@ namespace bamg { // if(SHOW) cout <det<< " " << Real8(deta[1])/t->det // << " " << Real8(deta[2])/t->det << endl; if (t->det >= 0) - ilast = - NewItem(t, Real8(deta[0]) / t->det, Real8(deta[1]) / t->det, Real8(deta[2]) / t->det); + ilast = NewItem(t, Real8(deta[0]) / t->det, Real8(deta[1]) / t->det, Real8(deta[2]) / t->det); else { // find the nearest boundary edge of the vertex A // find a edge or such normal projection a the edge IJ is on the edge // <=> IJ.IA >=0 && IJ.AJ >=0 @@ -553,8 +547,8 @@ namespace bamg { NewItem(A, Metric(ba, v0, bb, v1)); return; } - } // find the nearest boundary edge of the vertex A - } // end not optimisation + } // find the nearest boundary edge of the vertex A + } // end not optimisation if (t->det < 0) { // outside departure while (t->det < 0) { // intersection boundary edge and a,b, k = (*t)(0) ? (((*t)(1) ? ((*t)(2) ? -1 : 2) : 1)) : 0; @@ -582,9 +576,7 @@ namespace bamg { iedge = tadj; if (t == tbegin) { // double ba, bb; - if (verbosity > 7) - cout << " SplitEdge: All the edges " << A << B << nbegin << det(vi, vj, b) - << " deti= " << deti << " detj=" << detj << endl; + if (verbosity > 7) cout << " SplitEdge: All the edges " << A << B << nbegin << det(vi, vj, b) << " deti= " << deti << " detj=" << detj << endl; TriangleAdjacent edge = CloseBoundaryEdge(a, t, ba, bb); Vertex &v0 = *edge.EdgeVertex(0), &v1 = *edge.EdgeVertex(1); NewItem(A, Metric(ba, v0, bb, v1)); @@ -663,32 +655,23 @@ namespace bamg { // so we have just to see the transition from - to + of the det0..2 on edge of t // because we are going from a to b - if ((dt[i = VerticesOfTriangularEdge[i0][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i0][1]] > 0)) + if ((dt[i = VerticesOfTriangularEdge[i0][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i0][1]] > 0)) ocut = i0; - else if ((dt[i = VerticesOfTriangularEdge[i1][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i1][1]] > 0)) + else if ((dt[i = VerticesOfTriangularEdge[i1][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i1][1]] > 0)) ocut = i1; - else if ((dt[i = VerticesOfTriangularEdge[i2][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i2][1]] > 0)) + else if ((dt[i = VerticesOfTriangularEdge[i2][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i2][1]] > 0)) ocut = i2; - else if ((dt[i = VerticesOfTriangularEdge[i0][0]] == 0) && - (dt[j = VerticesOfTriangularEdge[i0][1]] > 0)) + else if ((dt[i = VerticesOfTriangularEdge[i0][0]] == 0) && (dt[j = VerticesOfTriangularEdge[i0][1]] > 0)) ocut = i0; - else if ((dt[i = VerticesOfTriangularEdge[i1][0]] == 0) && - (dt[j = VerticesOfTriangularEdge[i1][1]] > 0)) + else if ((dt[i = VerticesOfTriangularEdge[i1][0]] == 0) && (dt[j = VerticesOfTriangularEdge[i1][1]] > 0)) ocut = i1; - else if ((dt[i = VerticesOfTriangularEdge[i2][0]] == 0) && - (dt[j = VerticesOfTriangularEdge[i2][1]] > 0)) + else if ((dt[i = VerticesOfTriangularEdge[i2][0]] == 0) && (dt[j = VerticesOfTriangularEdge[i2][1]] > 0)) ocut = i2; - else if ((dt[i = VerticesOfTriangularEdge[i0][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i0][1]] == 0)) + else if ((dt[i = VerticesOfTriangularEdge[i0][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i0][1]] == 0)) ocut = i0; - else if ((dt[i = VerticesOfTriangularEdge[i1][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i1][1]] == 0)) + else if ((dt[i = VerticesOfTriangularEdge[i1][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i1][1]] == 0)) ocut = i1; - else if ((dt[i = VerticesOfTriangularEdge[i2][0]] < 0) && - (dt[j = VerticesOfTriangularEdge[i2][1]] == 0)) + else if ((dt[i = VerticesOfTriangularEdge[i2][0]] < 0) && (dt[j = VerticesOfTriangularEdge[i2][1]] == 0)) ocut = i2; else { // On a edge (2 zero) k = 0; @@ -749,7 +732,7 @@ namespace bamg { return; } } // we go outside of omega - } // for(;;) + } // for(;;) } // routine SplitEdge @@ -896,17 +879,14 @@ namespace bamg { if (nbv < nbvx) { vertices[nbv].r = C; vertices[nbv++].m = Metric(cx, lIntTria[ii - 1].m, cy, lIntTria[ii].m); - if ((verbosity / 100 % 10) == 2) - cout << " -- Add point " << nbv - 1 << " " << vertices[nbv - 1] << " " - << vertices[nbv - 1].m << endl; + if ((verbosity / 100 % 10) == 2) cout << " -- Add point " << nbv - 1 << " " << vertices[nbv - 1] << " " << vertices[nbv - 1].m << endl; #ifdef DEBUG if (k > 1) { R2 AB = vertices[nbv - 2].r - vertices[nbv - 1].r; Real8 dp = LengthInterpole(vertices[nbv - 2].m, vertices[nbv - 1].m, AB); if (dp > 1.6) { - cerr << "PB calcul new Int. points trop loin l=" << dp << " v=" << nbv - 1 << " " - << nbv - 2 << Mx << My << y - x << endl; + cerr << "PB calcul new Int. points trop loin l=" << dp << " v=" << nbv - 1 << " " << nbv - 2 << Mx << My << y - x << endl; } } #endif @@ -916,8 +896,7 @@ namespace bamg { return nbv - nbvold; } - int SwapForForcingEdge(Vertex *&pva, Vertex *&pvb, TriangleAdjacent &tt1, Icoor2 &dets1, - Icoor2 &detsa, Icoor2 &detsb, + int SwapForForcingEdge(Vertex *&pva, Vertex *&pvb, TriangleAdjacent &tt1, Icoor2 &dets1, Icoor2 &detsa, Icoor2 &detsb, int &NbSwap) { // l'arete ta coupe l'arete pva pvb // de cas apres le swap sa coupe toujours // on cherche l'arete suivante @@ -958,10 +937,8 @@ namespace bamg { } Icoor2 detvasasb = det(*pva, sa, sb); Icoor2 detvbsasb = det(*pvb, sa, sb); - if (CurrentTh && - !(((detvasasb <= 0) && (detvbsasb >= 0)) || ((detvasasb >= 0) && (detvbsasb <= 0)))) { - cout << " detvasasb =" << detvasasb << "detvbsasb = " << detvbsasb << " " << pva << " " << pvb - << " " << CurrentTh << endl; + if (CurrentTh && !(((detvasasb <= 0) && (detvbsasb >= 0)) || ((detvasasb >= 0) && (detvbsasb <= 0)))) { + cout << " detvasasb =" << detvasasb << "detvbsasb = " << detvbsasb << " " << pva << " " << pvb << " " << CurrentTh << endl; #ifdef DRAWING1 reffecran( ); CurrentTh->Draw( ); @@ -986,13 +963,11 @@ namespace bamg { if ((dets1 <= 0 && dets2 <= 0) || (dets2 >= 0 && detsb >= 0)) ToSwap = 1; else // swap alleatoire - if (BinaryRand( )) - ToSwap = 2; + if (BinaryRand( )) ToSwap = 2; } #ifdef DEBUG if (ForDebugging) { - cerr << "swap = " << ToSwap << " ndet1 " << ndet1 << ", ndet2 " << ndet2 << "det1 " << det1 - << " det2 " << det2 << " if1 = " << ((ndet1 > 0) && (ndet2 > 0)) + cerr << "swap = " << ToSwap << " ndet1 " << ndet1 << ", ndet2 " << ndet2 << "det1 " << det1 << " det2 " << det2 << " if1 = " << ((ndet1 > 0) && (ndet2 > 0)) << " if2 = " << ((dets1 <= 0 && dets2 <= 0) || (dets2 >= 0 && detsb >= 0)) << endl; #ifdef DRAWING couleur(0); @@ -1116,12 +1091,9 @@ namespace bamg { while ((ks = SwapForForcingEdge(va, vb, tc, detss, det1, det2, NbSwap))) if (l++ > 10000000) { cerr << " Loop in forcing Edge AB " - << "\n vertex A " << a << "\n vertex B " << b << "\n nb de swap " << NbSwap - << "\n nb of try swap too big = " << l << " greater than " << 1000000 << endl; + << "\n vertex A " << a << "\n vertex B " << b << "\n nb de swap " << NbSwap << "\n nb of try swap too big = " << l << " greater than " << 1000000 << endl; - if (CurrentTh) - cerr << " vertex number " << CurrentTh->Number(a) << " " << CurrentTh->Number(b) - << endl; + if (CurrentTh) cerr << " vertex number " << CurrentTh->Number(a) << " " << CurrentTh->Number(b) << endl; #ifdef DEBUG ForDebugging = 1; #endif @@ -1140,8 +1112,7 @@ namespace bamg { l = 0; reffecran( ); while (ks = SwapForForcingEdge(va, vb, tc, detss, det1, det2, NbSwap) && (l++ < 1000)) - cerr << " " << CurrentTh->Number(tc.EdgeVertex(0)) << " " - << CurrentTh->Number(tc.EdgeVertex(1)) << " "; + cerr << " " << CurrentTh->Number(tc.EdgeVertex(0)) << " " << CurrentTh->Number(tc.EdgeVertex(1)) << " "; } #endif MeshError(990); @@ -1185,7 +1156,7 @@ namespace bamg { int munswap1 = a / 4; a &= 3; #else - if (a / 4 != 0) return 0; // arete lock or MarkUnSwap + if (a / 4 != 0) return 0; // arete lock or MarkUnSwap #endif Triangle *t1 = this, *t2 = at[a]; // les 2 triangles adjacent @@ -1226,9 +1197,7 @@ namespace bamg { OnSwap = (Abs(det1) + Abs(det2)) < detA; // convexe Icoor2 detMinNew = Min(det1, det2); - if (verbosity > 99999) - cout << " Triangle::swap int " << OnSwap << " " << det1 << " " << det2 << " " << detMinNew - << endl; + if (verbosity > 99999) cout << " Triangle::swap int " << OnSwap << " " << det1 << " " << det2 << " " << detMinNew << endl; // if (detMin<0 && (Abs(det1) + Abs(det2) == detA)) OnSwap=BinaryRand();// just for test if (!OnSwap && (detMinNew > 0)) { @@ -1238,19 +1207,15 @@ namespace bamg { while (1) if (kopt) { // critere de Delaunay pure isotrope - Icoor2 xb1 = sb->i.x - s1->i.x, x21 = s2->i.x - s1->i.x, yb1 = sb->i.y - s1->i.y, - y21 = s2->i.y - s1->i.y, xba = sb->i.x - sa->i.x, x2a = s2->i.x - sa->i.x, - yba = sb->i.y - sa->i.y, y2a = s2->i.y - sa->i.y; - double cosb12 = double(xb1 * x21 + yb1 * y21), cosba2 = double(xba * x2a + yba * y2a), - sinb12 = double(det2), sinba2 = double(t2->det); + Icoor2 xb1 = sb->i.x - s1->i.x, x21 = s2->i.x - s1->i.x, yb1 = sb->i.y - s1->i.y, y21 = s2->i.y - s1->i.y, xba = sb->i.x - sa->i.x, x2a = s2->i.x - sa->i.x, yba = sb->i.y - sa->i.y, + y2a = s2->i.y - sa->i.y; + double cosb12 = double(xb1 * x21 + yb1 * y21), cosba2 = double(xba * x2a + yba * y2a), sinb12 = double(det2), sinba2 = double(t2->det); // angle b12 > angle ba2 => cotg(angle b12) < cotg(angle ba2) OnSwap = ((double)cosb12 * (double)sinba2) < ((double)cosba2 * (double)sinb12); if (verbosity > 99999) - cout << " Triangle::swap " << OnSwap << " " << ((double)cosb12 * (double)sinba2) - << " " << ((double)cosba2 * (double)sinb12) << " " - << ((double)cosba2 * (double)sinb12) - ((double)cosb12 * (double)sinba2) - << endl; + cout << " Triangle::swap " << OnSwap << " " << ((double)cosb12 * (double)sinba2) << " " << ((double)cosba2 * (double)sinb12) << " " + << ((double)cosba2 * (double)sinb12) - ((double)cosb12 * (double)sinba2) << endl; // if(CurrentTh) // cout << "swap " << CurrentTh->Number(sa) << " " << CurrentTh->Number(sb) // << " " ; cout << cosb12 << " " << sinba2 << " " << cosba2 << " " << sinb12 @@ -1303,14 +1268,11 @@ namespace bamg { } } // OnSwap - } // (! OnSwap &&(det1 > 0) && (det2 > 0) ) + } // (! OnSwap &&(det1 > 0) && (det2 > 0) ) } #ifdef DEBUG1 if (OnSwap && (munswap1 || munswap2)) { - cout << " Error Mark unswap T " << CurrentTh->Number(t1) << " " << CurrentTh->Number(t2) - << endl - << *t1 << endl - << *t2 << endl; + cout << " Error Mark unswap T " << CurrentTh->Number(t1) << " " << CurrentTh->Number(t2) << endl << *t1 << endl << *t2 << endl; return 0; } #endif @@ -1486,8 +1448,7 @@ namespace bamg { TriangleAdjacent ta = t->Adj(iedge); #ifdef DEBUG1 - cout << " The point " << Number(s) << " is the edge " << izerodet << " of " << Number(t) - << " det3 = " << det3[0] << " " << det3[1] << " " << det3[2] << " " << endl; + cout << " The point " << Number(s) << " is the edge " << izerodet << " of " << Number(t) << " det3 = " << det3[0] << " " << det3[1] << " " << det3[2] << " " << endl; cout << " ta = " << ta << "ta->det =" << ((Triangle *)ta)->det << " " << t->det << endl; #endif @@ -1561,8 +1522,7 @@ namespace bamg { int rswap = tt[izerodet]->swap(iedge); if (!rswap) { - cout << " Problem swap: the point s is on an edge => swap " << iedge << " " << *tt[izerodet] - << endl; + cout << " Problem swap: the point s is on an edge => swap " << iedge << " " << *tt[izerodet] << endl; #ifdef DRAWING if (CurrentTh && withrgraphique) { reffecran( ); @@ -1613,9 +1573,7 @@ namespace bamg { vertices[nbv].DirOfSearch = NoDirOfSearch; } NbSplitEdge++; - if (verbosity > 7) - cout << " Internal edge with two vertices on boundary" << Number(v0) << " " - << Number(v1) << " by " << endl; + if (verbosity > 7) cout << " Internal edge with two vertices on boundary" << Number(v0) << " " << Number(v1) << " by " << endl; } } } @@ -1637,8 +1595,7 @@ namespace bamg { // << " " << Number(vi) << " <--> " << Number(vi) <link) { - cout << i << " Problem insert point " << Number(vi) << vi << Number(vi) - << " tcvi = " << tcvi << " " << tcvi->link << endl; + cout << i << " Problem insert point " << Number(vi) << vi << Number(vi) << " tcvi = " << tcvi << " " << tcvi->link << endl; cout << (*tcvi)[1] << (*tcvi)[2] << endl; tcvi = FindTriangleContening(vi.i, dete); cout << (*tcvi)[1] << (*tcvi)[2] << endl; @@ -1671,13 +1628,10 @@ namespace bamg { nbv = iv; } if (NbSplitEdge > nbv - nbvold) { - cout << " Warning: too few vertices to split all internal edges " << endl - << " We lost " << NbSplitEdge - (nbv - nbvold) << " edges. Sorry! " << endl; + cout << " Warning: too few vertices to split all internal edges " << endl << " We lost " << NbSplitEdge - (nbv - nbvold) << " edges. Sorry! " << endl; warning = 2; } - if (verbosity > 2) - cout << "SplitInternalEdgeWithBorderVertices: Number of splited edges " << NbSplitEdge - << endl; + if (verbosity > 2) cout << "SplitInternalEdgeWithBorderVertices: Number of splited edges " << NbSplitEdge << endl; return NbSplitEdge; } Int4 Triangles::InsertNewPoints(Int4 nbvold, Int4 &NbTSwap) { @@ -1728,8 +1682,7 @@ namespace bamg { // << " " << Number(vi) << " <--> " << Number(vj) <link) { - cerr << i << " Problem: insert point " << Number(vj) << vj << Number(vi) - << " tcvj = " << tcvj << " " << tcvj->link << endl; + cerr << i << " Problem: insert point " << Number(vj) << vj << Number(vi) << " tcvj = " << tcvj << " " << tcvj->link << endl; cerr << (*tcvj)[1] << (*tcvj)[2] << endl; tcvj = FindTriangleContening(vj.i, dete); cout << (*tcvj)[1] << (*tcvj)[2] << endl; @@ -1756,8 +1709,7 @@ namespace bamg { } } if (verbosity > 3) { - cout << " Number of new points " << iv << " Number of points which are too close " - << nbv - iv; + cout << " Number of new points " << iv << " Number of points which are too close " << nbv - iv; cout << " Nb swap = " << NbSwap << " after "; } @@ -1778,22 +1730,16 @@ namespace bamg { Int4 i; for (i = 0; i < nbt; i++) if (triangles[i].link) { - double dd = - Det(triangles[i][1].r - triangles[i][0].r, triangles[i][2].r - triangles[i][0].r); + double dd = Det(triangles[i][1].r - triangles[i][0].r, triangles[i][2].r - triangles[i][0].r); if (dd <= 0) { NbErr++; cerr << " det triangle i " << i << " = " << triangles[i].det; cerr << " det triangle " << dd; cerr << " The three vertices "; - cerr << Number(triangles[i][0]) << " " << Number(triangles[i][1]) << " " - << Number(triangles[i][2]) << endl; - cerr << "I2 " << triangles[i][0].r << triangles[i][1].r << triangles[i][2].r - << endl; - cerr << "R2 " << triangles[i][0].i << triangles[i][1].i << triangles[i][2].i - << endl; - cerr << "I2-R2 =" << toR2(triangles[i][0].i) - triangles[i][0].r - << toR2(triangles[i][1].i) - triangles[i][1].r - << toR2(triangles[i][2].i) - triangles[i][2].r << endl; + cerr << Number(triangles[i][0]) << " " << Number(triangles[i][1]) << " " << Number(triangles[i][2]) << endl; + cerr << "I2 " << triangles[i][0].r << triangles[i][1].r << triangles[i][2].r << endl; + cerr << "R2 " << triangles[i][0].i << triangles[i][1].i << triangles[i][2].i << endl; + cerr << "I2-R2 =" << toR2(triangles[i][0].i) - triangles[i][0].r << toR2(triangles[i][1].i) - triangles[i][1].r << toR2(triangles[i][2].i) - triangles[i][2].r << endl; } } if (NbErr) { @@ -1806,15 +1752,13 @@ namespace bamg { if (kkk) { for (i = 0; i < nbt; i++) if (triangles[i].link) { - double dd = - Det(triangles[i][1].r - triangles[i][0].r, triangles[i][2].r - triangles[i][0].r); + double dd = Det(triangles[i][1].r - triangles[i][0].r, triangles[i][2].r - triangles[i][0].r); if (dd <= 0) { NbErr++; cerr << " xxxdet triangle i " << i << " = " << triangles[i].det; cerr << " xxxdet triangle " << dd; cerr << " xxxLes trois sommets "; - cerr << Number(triangles[i][0]) << " " << Number(triangles[i][1]) << " " - << Number(triangles[i][2]) << endl; + cerr << Number(triangles[i][0]) << " " << Number(triangles[i][1]) << " " << Number(triangles[i][2]) << endl; cerr << triangles[i][0].r << triangles[i][1].r << triangles[i][2].r << endl; cerr << triangles[i][0].i << triangles[i][1].i << triangles[i][2].i << endl; } @@ -1851,9 +1795,7 @@ namespace bamg { int nbv1 = nbv; Bh.ReMakeTriangleContainingTheVertex( ); InsertNewPoints(nbvold, NbTSwap); - if (verbosity > 2) - cout << " (Nb of Points from background mesh = " << nbv - nbvold << " / " - << nbv1 - nbvold << ")" << endl; + if (verbosity > 2) cout << " (Nb of Points from background mesh = " << nbv - nbvold << " / " << nbv1 - nbvold << ")" << endl; } else Bh.ReMakeTriangleContainingTheVertex( ); @@ -1879,8 +1821,7 @@ namespace bamg { i = Headt; next_t = -first_np_or_next_t[i]; - for (t = &triangles[i]; i < nbt; - t = &triangles[i = next_t], next_t = -first_np_or_next_t[i]) { // for each triangle t + for (t = &triangles[i]; i < nbt; t = &triangles[i = next_t], next_t = -first_np_or_next_t[i]) { // for each triangle t // we can change first_np_or_next_t[i] // cout << " Do the triangle " << i << " Next_t=" << next_t << endl; assert(i >= 0 && i < nbt); @@ -1962,9 +1903,7 @@ namespace bamg { */ NbTSwap += NbSwapf; if (verbosity > 3) cout << " "; - if (verbosity > 2) - cout << " Number of vertices =" << nbv << " Number of triangles = " << nbt - NbOutT - << " NbSwap final = " << NbSwapf << " Total number of swaps = " << NbTSwap << endl; + if (verbosity > 2) cout << " Number of vertices =" << nbv << " Number of triangles = " << nbt - NbOutT << " NbSwap final = " << NbSwapf << " Total number of swaps = " << NbTSwap << endl; } void Triangles::NewPointsOld(Triangles &Bh) { // Triangles::NewPointsOld @@ -2049,8 +1988,7 @@ namespace bamg { #ifdef TRACETRIANGLE trace = trace || k == TRACETRIANGLE; if (trace) { - cout << "Test edge " << i << " AB = " << A << B << "i " << Number(vA) << "j" - << Number(vB); + cout << "Test edge " << i << " AB = " << A << B << "i " << Number(vA) << "j" << Number(vB); cout << " link" << (int)t->link << " ta=" << Number(ta) << " det " << ta->det; cout << " hA = " << vA.m.h << " hB = " << vB.m.h; cout << " loc " << ta->Locked(j) << endl; @@ -2077,7 +2015,7 @@ namespace bamg { kkk = 0, BeginNewPoint[j] = iv; } continue; // next edge of the triangle - } // end if( k < i) + } // end if( k < i) #ifdef DRAWING1 penthickness(2); @@ -2099,9 +2037,7 @@ namespace bamg { vertices[nbv].m = vertices[iv].m; // test if the new point is not to close to the 2 opposite vertex R2 CC1 = C - vC1, CC2 = C - vC2; - if (((vC1.m(CC1) + vertices[nbv].m(CC1)) > seuil) && - ((vC2.m(CC2) + vertices[nbv].m(CC2)) > seuil)) - nbv++; + if (((vC1.m(CC1) + vertices[nbv].m(CC1)) > seuil) && ((vC2.m(CC2) + vertices[nbv].m(CC2)) > seuil)) nbv++; } EndNewPoint[j] = nbv - 1; @@ -2110,8 +2046,7 @@ namespace bamg { #ifdef TRACETRIANGLE if (trace) { // verification des point cree - cout << "\n ------------ " << t->link << " " << t->det << " b " << BeginNewPoint[0] << " " - << BeginNewPoint[1] << " " << BeginNewPoint[2] << " " + cout << "\n ------------ " << t->link << " " << t->det << " b " << BeginNewPoint[0] << " " << BeginNewPoint[1] << " " << BeginNewPoint[2] << " " << " e " << EndNewPoint[0] << " " << EndNewPoint[1] << " " << EndNewPoint[2] << " " << " s " << step[0] << " " << step[1] << " " << step[2] << " " << endl; } @@ -2136,8 +2071,7 @@ namespace bamg { if (BeginNewPoint[j1] > EndNewPoint[j1]) continue; // else if (EndNewPoint[j1] - BeginNewPoint[j1] < 1) { - for (Int4 ii1 = BeginNewPoint[j1]; ii1 <= EndNewPoint[j1]; ii1++) - stack[kstack++] = ii1; + for (Int4 ii1 = BeginNewPoint[j1]; ii1 <= EndNewPoint[j1]; ii1++) stack[kstack++] = ii1; continue; } @@ -2228,9 +2162,8 @@ namespace bamg { if (i1 < nbvold) { // remove all the points i0; Int4 ip, ipp; - for (ip = i0; i0 != (ipp = vertices[ip].ReferenceNumber); ip = ipp) - vertices[ip].ReferenceNumber = -1; // mark remove - vertices[ip].ReferenceNumber = -1; // mark remove + for (ip = i0; i0 != (ipp = vertices[ip].ReferenceNumber); ip = ipp) vertices[ip].ReferenceNumber = -1; // mark remove + vertices[ip].ReferenceNumber = -1; // mark remove } else { // remove on of two points Int4 ip0, ip1, ipp0, ipp1; @@ -2259,14 +2192,13 @@ namespace bamg { DrawMark(C); #endif // update the new point points of the list - for (ip0 = i0; i0 != (ipp0 = vertices[ip0].ReferenceNumber); ip0 = ipp0) - vertices[ip0].r = C; + for (ip0 = i0; i0 != (ipp0 = vertices[ip0].ReferenceNumber); ip0 = ipp0) vertices[ip0].r = C; vertices[ip0].r = C; } } } } // for (i0= .... - } // for triangle + } // for triangle #ifdef DRAWING1 cout << " -------------------------------------------- " << endl; @@ -2280,11 +2212,10 @@ namespace bamg { Int4 ip, ipp, kkk = nbvold; for (i = nbvold; i < nbv; i++) - if (vertices[i].ReferenceNumber >= 0) { // good points - // cout <<" i = " << i ; - for (ip = i; i != (ipp = vertices[ip].ReferenceNumber); ip = ipp) - vertices[ip].ReferenceNumber = -1; // mark remove - vertices[ip].ReferenceNumber = -1; // mark remove + if (vertices[i].ReferenceNumber >= 0) { // good points + // cout <<" i = " << i ; + for (ip = i; i != (ipp = vertices[ip].ReferenceNumber); ip = ipp) vertices[ip].ReferenceNumber = -1; // mark remove + vertices[ip].ReferenceNumber = -1; // mark remove // cout << i << " ---> " << kkk << endl; vertices[kkk] = vertices[i]; vertices[kkk].i = toI2(vertices[kkk].r); @@ -2312,8 +2243,7 @@ namespace bamg { if (nbvnew) { const Int4 PrimeNumber = AGoodNumberPrimeWith(nbv); Int4 k3 = myrand( ) % nbvnew; - for (Int4 is3 = 0; is3 < nbvnew; is3++) - ordre[nbvold + is3] = &vertices[nbvold + (k3 = (k3 + PrimeNumber) % nbvnew)]; + for (Int4 is3 = 0; is3 < nbvnew; is3++) ordre[nbvold + is3] = &vertices[nbvold + (k3 = (k3 + PrimeNumber) % nbvnew)]; for (i = nbvold; i < nbv; i++) { Vertex *vi = ordre[i]; @@ -2459,8 +2389,7 @@ namespace bamg { } // fin de boucle en icount time2 = CPUtime( ); if (verbosity > 3) - cout << " NbSwap of insertion " << NbSwap << " NbSwap/Nbv " << (float)NbSwap / (float)nbv - << " NbUnSwap " << NbUnSwap << " Nb UnSwap/Nbv " << (float)NbUnSwap / (float)nbv << endl; + cout << " NbSwap of insertion " << NbSwap << " NbSwap/Nbv " << (float)NbSwap / (float)nbv << " NbUnSwap " << NbUnSwap << " Nb UnSwap/Nbv " << (float)NbUnSwap / (float)nbv << endl; NbUnSwap = 0; // construction d'un ordre aleatoire // const int PrimeNumber= (nbv % 999983) ? 1000003: 999983 ; @@ -2476,8 +2405,7 @@ namespace bamg { for (int is1 = 0; is1 < nbv; is1++) NbSwap += ordre[is1]->Optim(0, 0); timeloop = CPUtime( ); if (verbosity > 3) - cout << " Optim Loop " << Nbloop << " NbSwap: " << NbSwap << " NbSwap/Nbv " - << (float)NbSwap / (float)nbv << " CPU=" << timeloop - time000 << " s, " + cout << " Optim Loop " << Nbloop << " NbSwap: " << NbSwap << " NbSwap/Nbv " << (float)NbSwap / (float)nbv << " CPU=" << timeloop - time000 << " s, " << " NbUnSwap/Nbv " << (float)NbUnSwap / (float)nbv << endl; NbUnSwap = 0; if (!NbSwap) break; @@ -2494,8 +2422,7 @@ namespace bamg { #endif time3 = CPUtime( ); if (verbosity > 4) - cout << " init " << time1 - time0 << " initialisation, " << time2 - time1 - << "s, insert point " << time3 - time2 << "s, optim " << endl + cout << " init " << time1 - time0 << " initialisation, " << time2 - time1 << "s, insert point " << time3 - time2 << "s, optim " << endl << " Init Total Cpu Time = " << time3 - time0 << "s " << endl; #ifdef DRAWING1 @@ -2525,9 +2452,8 @@ namespace bamg { Nbswap += nbswp; if (nbswp) nbfe++; if (nbswp < 0 && k < 5) { - cerr << " Missing edge " << i << " v0 = " << Number(edges[i][0]) << edges[i][0].r - << " v1= " << Number(edges[i][1]) << edges[i][1].r << " " << edges[i].on->Cracked( ) - << " " << (Triangle *)ta; + cerr << " Missing edge " << i << " v0 = " << Number(edges[i][0]) << edges[i][0].r << " v1= " << Number(edges[i][1]) << edges[i][1].r << " " << edges[i].on->Cracked( ) << " " + << (Triangle *)ta; if (ta.t) { Vertex *aa = ta.EdgeVertex(0), *bb = ta.EdgeVertex(1); cerr << " crossing with [" << Number(aa) << ", " << Number(bb) << "]\n"; @@ -2543,12 +2469,11 @@ namespace bamg { MeshError(10, this); } for (Int4 j = 0; j < nbv; j++) Nbswap += vertices[j].Optim(1, 0); - if (verbosity > 3) - cout << " Number of inforced edges = " << nbfe << " Nb of Swap " << Nbswap << endl; + if (verbosity > 3) cout << " Number of inforced edges = " << nbfe << " Nb of Swap " << Nbswap << endl; } void Triangles::FindSubDomain(int OutSide = 0) { - //#define DRAWING1 + // #define DRAWING1 if (verbosity > 2) { if (OutSide) @@ -2697,10 +2622,8 @@ namespace bamg { if (kr != kl) { // cout << kl << " " << kr << " rl " << subdomains[kl].ref // << " rr " << subdomains[kr].ref ; - if (kl >= 0 && subdomains[kl].ref < 0 && kr >= 0 && subdomains[kr].ref >= 0) - nbk--, subdomains[kr].ref = subdomains[kl].ref - 1; - if (kr >= 0 && subdomains[kr].ref < 0 && kl >= 0 && subdomains[kl].ref >= 0) - nbk--, subdomains[kl].ref = subdomains[kr].ref - 1; + if (kl >= 0 && subdomains[kl].ref < 0 && kr >= 0 && subdomains[kr].ref >= 0) nbk--, subdomains[kr].ref = subdomains[kl].ref - 1; + if (kr >= 0 && subdomains[kr].ref < 0 && kl >= 0 && subdomains[kl].ref >= 0) nbk--, subdomains[kl].ref = subdomains[kr].ref - 1; if (kr < 0 && kl >= 0 && subdomains[kl].ref >= 0) nbk--, subdomains[kl].ref = -1; if (kl < 0 && kr >= 0 && subdomains[kr].ref >= 0) nbk--, subdomains[kr].ref = -1; // cout << " after \t " @@ -2711,10 +2634,9 @@ namespace bamg { // cout << subdomains[0].ref << subdomains[1].ref << endl; Int4 j = 0; for (i = 0; i < NbSubDomains; i++) - if ((-subdomains[i].ref) % - 2) { // good - // cout << " sudom ok = " << i << " " << subdomains[i].ref - // << " " << (-subdomains[i].ref) %2 << endl; + if ((-subdomains[i].ref) % 2) { // good + // cout << " sudom ok = " << i << " " << subdomains[i].ref + // << " " << (-subdomains[i].ref) %2 << endl; if (i != j) Exchange(subdomains[i], subdomains[j]); j++; } else { // cout << " remove sub domain " << i << endl; @@ -2727,8 +2649,7 @@ namespace bamg { } // while (t) } - if (verbosity > 4) - cout << " Number of removed subdomains (OutSideMesh) = " << NbSubDomains - j << endl; + if (verbosity > 4) cout << " Number of removed subdomains (OutSideMesh) = " << NbSubDomains - j << endl; NbSubDomains = j; } @@ -2759,14 +2680,14 @@ namespace bamg { int sens = Gh.subdomains[i].sens; // test if ge and e is in the same sens // cout << " geom edge = " << Gh.Number(eg) <<" @" << &eg << " ref = " << - //subdomains[i].ref + // subdomains[i].ref // << " ref edge =" << eg.ref << " sens " << sens ; if (((eg[0].r - eg[1].r), (e[0].r - e[1].r)) < 0) sens = -sens; subdomains[i].sens = sens; subdomains[i].edge = &e; // cout << " sens " << sens << " in geom " << eg[0].r << eg[1].r << " in mesh " << - //e[0].r << e[1].r << endl; cout << " v0 , v1 = " << Number(v0) << " " << Number(v1) << - //endl; + // e[0].r << e[1].r << endl; cout << " v0 , v1 = " << Number(v0) << " " << Number(v1) << + // endl; assert(t && sens); TriangleAdjacent ta(t, EdgesVertexTriangle[v0->vint][0]); // previous edges @@ -2781,12 +2702,9 @@ namespace bamg { subdomains[i].head = t = ta; // cout << " triangle =" << Number(t) << " = " << (*t)[0].r << (*t)[1].r << // (*t)[2].r << endl; - if (t < triangles || t >= triangles + nbt || t->det < 0 || - t->link == 0) // Ajoute aout 200 + if (t < triangles || t >= triangles + nbt || t->det < 0 || t->link == 0) // Ajoute aout 200 { - cerr << " Error in the definition of subdomain " << i << " boundary border " - << NbSubDomains - i << "/" << NbSubDomains << ": wrong direction " - << Gh.Number(eg) << " " << sens << endl; + cerr << " Error in the definition of subdomain " << i << " boundary border " << NbSubDomains - i << "/" << NbSubDomains << ": wrong direction " << Gh.Number(eg) << " " << sens << endl; err++; break; } @@ -2794,9 +2712,8 @@ namespace bamg { if (mark[it] >= 0) { if (verbosity > 10) - cerr << " Warning: the subdomain " << i << " ref = " << subdomains[i].ref - << " is previouly defined with " << mark[it] - << " ref = " << subdomains[mark[it]].ref << " skip this definition " << endl; + cerr << " Warning: the subdomain " << i << " ref = " << subdomains[i].ref << " is previouly defined with " << mark[it] << " ref = " << subdomains[mark[it]].ref + << " skip this definition " << endl; break; } if (i != inew) Exchange(subdomains[i], subdomains[inew]); @@ -2812,16 +2729,13 @@ namespace bamg { mark[Number(tt)] = i; tt = tt->link; } while (tt != t); - if (verbosity > 7) - cout << " Number of triangles in each subdomain " << i << " of ref " - << subdomains[i].ref << " = " << kkk << endl; + if (verbosity > 7) cout << " Number of triangles in each subdomain " << i << " of ref " << subdomains[i].ref << " = " << kkk << endl; break; } ta = Previous(Adj(ta)); if (t == (Triangle *)ta) { err++; - cerr << " Error in the definition of subdomain " << i << " edge = " << Gh.Number(eg) - << " " << sens << endl; + cerr << " Error in the definition of subdomain " << i << " edge = " << Gh.Number(eg) << " " << sens << endl; break; } // cout << " NB of remove subdomain " << NbSubDomTot-NbSubDomains<< endl; @@ -2830,8 +2744,7 @@ namespace bamg { if (err) MeshError(777, this); if (inew < NbSubDomains) { - if (verbosity > 5) - cout << " Warning: we remove " << NbSubDomains - inew << " subdomains " << endl; + if (verbosity > 5) cout << " Warning: we remove " << NbSubDomains - inew << " subdomains " << endl; NbSubDomains = inew; } @@ -2848,14 +2761,12 @@ namespace bamg { for (it = 0; it < nbt; it++) if (!triangles[it].link) NbOutT++; if (verbosity > 4) cout << " "; - if (verbosity > 2) - cout << " Number of bounded subdomains = " << NbSubDomTot << " NbOutTriangles = " << NbOutT - << endl; + if (verbosity > 2) cout << " Number of bounded subdomains = " << NbSubDomTot << " NbOutTriangles = " << NbOutT << endl; #ifdef DRAWING1 inquire( ); #endif - //#undef DRAWING1 + // #undef DRAWING1 } void Triangles::ReNumberingVertex(Int4 *renu) { // warning be carfull because pointeur @@ -2940,8 +2851,7 @@ namespace bamg { // do the change on all the pointeur for (it = 0; it < nbt; it++) triangles[it].ReNumbering(triangles, te, renu); - for (i = 0; i < NbSubDomains; i++) - subdomains[i].head = triangles + renu[Number(subdomains[i].head)]; + for (i = 0; i < NbSubDomains; i++) subdomains[i].head = triangles + renu[Number(subdomains[i].head)]; // move the Triangles without a copy of the array // be careful not trivial code @@ -2984,9 +2894,7 @@ namespace bamg { } while (t0 != (t = t->link)); } // NbOutT = nbt - k; - if (verbosity > 5) - cout << " Number of subdomain =" << NbSubDomains << " Number of inner triangles " << k - << " Nbt = " << nbt << " Out Triangles = " << nbt - k << endl; + if (verbosity > 5) cout << " Number of subdomain =" << NbSubDomains << " Number of inner triangles " << k << " Nbt = " << nbt << " Out Triangles = " << nbt - k << endl; return k; } @@ -3076,8 +2984,7 @@ namespace bamg { name = fname; warning = 0; if (inbvx) { - if(verbosity>4) - cout <<"nbvx,nbtx " << inbvx << " " << nbtx < 4) cout << "nbvx,nbtx " << inbvx << " " << nbtx << endl; vertices = new Vertex[nbvx]; assert(vertices); ordre = new Vertex *[nbvx]; @@ -3096,11 +3003,10 @@ namespace bamg { strftime(buf, 70, ", Date: %y/%m/%d %H:%M %Ss", localtime(&timer)); counter++; char countbuf[30]; - snprintf(countbuf,30, "%d", counter); + snprintf(countbuf, 30, "%d", counter); int lg = 0; if (&BTh != this && BTh.name) lg = strlen(BTh.name) + 4; - identity = new char[lg + strlen(buf) + strlen(countbuf) + 2 + 10 + - (Gh.name ? strlen(Gh.name) + 4 : 0)]; + identity = new char[lg + strlen(buf) + strlen(countbuf) + 2 + 10 + (Gh.name ? strlen(Gh.name) + 4 : 0)]; identity[0] = 0; if (lg) strcat(strcat(strcat(identity, "B="), BTh.name), ", "); @@ -3123,13 +3029,11 @@ namespace bamg { NbSubDomains = 0; // Meshbegin = vertices; // Meshend = vertices + nbvx; - if (verbosity > 98) - cout << " Triangles::PreInit() " << nbvx << " " << nbtx << " " << vertices << " " << ordre - << " " << triangles << endl; + if (verbosity > 98) cout << " Triangles::PreInit() " << nbvx << " " << nbtx << " " << vertices << " " << ordre << " " << triangles << endl; } void Triangles::GeomToTriangles1(Int4 inbvx, int KeepBackVertices) { - //#define DRAWING1 + // #define DRAWING1 Gh.NbRef++; // add a ref to Gh /************************************************************************* @@ -3242,9 +3146,7 @@ namespace bamg { // " // << " e " << " " << Gh.Number(ei.on) << " vc " << // Gh.Number((*Gh.curves[nc].be)[Gh.curves[nc].kb]) << endl; - if (ei.on == Gh.curves[nc].be && - (GeometricalVertex *)*ei[je].on == - &(*Gh.curves[nc].be)[Gh.curves[nc].kb] // same extremity + if (ei.on == Gh.curves[nc].be && (GeometricalVertex *)*ei[je].on == &(*Gh.curves[nc].be)[Gh.curves[nc].kb] // same extremity ) { // cout << " find " << endl; bcurve[nc] = iedge * 2 + je; @@ -3361,8 +3263,7 @@ namespace bamg { //((k1==1) != (k1==k1equi)) se = k1 ? se : 1. - se; se = k1 == k1equi ? se : 1. - se; - VertexOnBThEdge[NbVerticesOnGeomEdge++] = - VertexOnEdge(A1, &eeequi, se); // save + VertexOnBThEdge[NbVerticesOnGeomEdge++] = VertexOnEdge(A1, &eeequi, se); // save ongequi = Gh.ProjectOnCurve(eeequi, se, *A1, *GA1); A1->ReferenceNumber = eeequi.ref; A1->DirOfSearch = NoDirOfSearch; @@ -3371,10 +3272,8 @@ namespace bamg { e->v[0] = A0; e->v[1] = A1; if (verbosity > 99) - cout << i << "+ New P " << nbv - 1 << " " << sNew << " L0=" << L0 - << " AB=" << LAB << " s=" << (sNew - L0) / LAB << " se= " << se - << " B edge " << BTh.Number(ee) << " sign = " << k1 << " " << A1->r - << endl; + cout << i << "+ New P " << nbv - 1 << " " << sNew << " L0=" << L0 << " AB=" << LAB << " s=" << (sNew - L0) / LAB << " se= " << se << " B edge " << BTh.Number(ee) + << " sign = " << k1 << " " << A1->r << endl; #ifdef DEBUG // code \label(xxx) @@ -3384,9 +3283,7 @@ namespace bamg { cerr << " Problem with new points " << nbv - 1; cerr << " AB=" << LAB << " s=" << (sNew - L0) / LAB << " se= "; cerr << se << " B edge " << BTh.Number(ee) << " signe = " << k1 << endl; - cerr << " PB calcul new on cuver points trop loin l=" << dp - << " v=" << nbv - 1 << " " << nbv - 2 << " Lcurve = " << Lcurve << AB - << v0.m << v1.m << endl; + cerr << " PB calcul new on cuver points trop loin l=" << dp << " v=" << nbv - 1 << " " << nbv - 2 << " Lcurve = " << Lcurve << AB << v0.m << v1.m << endl; } #endif @@ -3420,9 +3317,7 @@ namespace bamg { break; } if (!ee.adj[k1]) { - cerr << "Error adjacent edges " << BTh.Number(ee) << ", nbe = " << nbe - << " Gh.vertices " << Gh.vertices << " k1 = " << k1 << " on=" << *ee[k1].on - << endl; + cerr << "Error adjacent edges " << BTh.Number(ee) << ", nbe = " << nbe << " Gh.vertices " << Gh.vertices << " k1 = " << k1 << " on=" << *ee[k1].on << endl; cerr << ee[k1].on->gv - Gh.vertices << endl; } pe = ee.adj[k1]; // next edge @@ -3434,9 +3329,7 @@ namespace bamg { if (phase) // construction of the last edge { Edge *e = edges + nbe++; - if (verbosity > 10) - cout << " Fin curve A1" << *A1 << " " << icurve << " <=> " << icurveequi << "-----" - << NbCreatePointOnCurve << " == " << i << endl; + if (verbosity > 10) cout << " Fin curve A1" << *A1 << " " << icurve << " <=> " << icurveequi << "-----" << NbCreatePointOnCurve << " == " << i << endl; e->on = ongequi; e->v[0] = A0; e->v[1] = A1; @@ -3446,7 +3339,7 @@ namespace bamg { if (PreviousNewEdge) PreviousNewEdge->adj[1] = e; PreviousNewEdge = e; // cout << "Last new edge " << nbe << " " << " on " << - //Gh.Number(pe->on) + // Gh.Number(pe->on) // << " of curve =" <on->CurveNumber < 5) - cout << icurve << " NbSegOnCurve = " << NbSegOnCurve << " Lstep=" << Lstep << " " - << NbOfNewPoints << " NBPC= " << NbCreatePointOnCurve << endl; + if (verbosity > 5) cout << icurve << " NbSegOnCurve = " << NbSegOnCurve << " Lstep=" << Lstep << " " << NbOfNewPoints << " NBPC= " << NbCreatePointOnCurve << endl; // do'nt // if(NbCreatePointOnCurve<1) break; } @@ -3486,8 +3377,7 @@ namespace bamg { if (step == 0) { // if(!NbOfNewPoints) break;// nothing ????? bug if (nbv + NbOfNewPoints > nbvx) { - cerr << " Too many vertices on geometry " << nbv + NbOfNewPoints << " >= " << nbvx - << endl; + cerr << " Too many vertices on geometry " << nbv + NbOfNewPoints << " >= " << nbvx << endl; MeshError(3, this); } // cout << " NbOfNewEdge" << NbOfNewEdge << " NbOfNewPoints " << NbOfNewPoints << endl; @@ -3529,7 +3419,7 @@ namespace bamg { // BTh[iv].i = toI2(BTh[iv].r); NewPoints(BTh, KeepBackVertices); CurrentTh = 0; - //#undef DRAWING1 + // #undef DRAWING1 } void Triangles::GeomToTriangles0(Int4 inbvx) { @@ -3625,9 +3515,8 @@ namespace bamg { nbe++; } } - } else { // on curve ------ - for (int kstep = 0; kstep <= step; - kstep++) { // begin for ( int kstep=0;kstep<= step;kstep++) + } else { // on curve ------ + for (int kstep = 0; kstep <= step; kstep++) { // begin for ( int kstep=0;kstep<= step;kstep++) // if 2nd step where 2 step // -- 1 compute le length of the curve // -- create the points and edge @@ -3737,10 +3626,8 @@ namespace bamg { cout << " new edge " << nbe - 1 << " "; cout << va << vb << " kk0 = " << kk0 << " " << kk1 << " ss=" << ss; cout << " " << sbb << endl; - cout << " " << aa << va->r << bb << vb->r - << " length=" << Norme2(va->r - vb->r) << endl; - cout << " s " << s << " lstep= " << lstep << " ledge= " << ledge - << " lcurve= " << lcurve << endl; + cout << " " << aa << va->r << bb << vb->r << " length=" << Norme2(va->r - vb->r) << endl; + cout << " s " << s << " lstep= " << lstep << " ledge= " << ledge << " lcurve= " << lcurve << endl; } // end of modification ... DF. Hecht 23/04/2014 FH @@ -3792,8 +3679,8 @@ namespace bamg { } else nbe += NbEdgeCurve; } // end on curve --- - } // if (edges[i][j].Corner()) - } // for (i=0;i 2) - cout << " -- FillHoleInMesh: Number of vertices =" << nbv << " Pmin = " << pmin - << " Pmax = " << pmax << endl; + if (verbosity > 2) cout << " -- FillHoleInMesh: Number of vertices =" << nbv << " Pmin = " << pmin << " Pmax = " << pmax << endl; assert(ordre); for (i = 0; i < nbv; i++) ordre[i] = 0; @@ -3996,8 +3878,7 @@ namespace bamg { Int4 *st = new Int4[nbt * 3]; for (i = 0; i < nbt * 3; i++) st[i] = -1; Int4 kk = 0; - for (i = 0; i < nbe; i++) - kk += (i == edge4->addtrie(Number(edges[i][0]), Number(edges[i][1]))); + for (i = 0; i < nbe; i++) kk += (i == edge4->addtrie(Number(edges[i][0]), Number(edges[i][1]))); if (kk != nbe) { cerr << " Double edge in the mesh: the number is " << kk - nbe << endl; MeshError(1002, this); @@ -4005,14 +3886,12 @@ namespace bamg { for (i = 0; i < nbt; i++) for (int j = 0; j < 3; j++) { // Int4 i0,i1; - Int4 k = edge4->addtrie(Number(triangles[i][VerticesOfTriangularEdge[j][0]]), - Number(triangles[i][VerticesOfTriangularEdge[j][1]])); + Int4 k = edge4->addtrie(Number(triangles[i][VerticesOfTriangularEdge[j][0]]), Number(triangles[i][VerticesOfTriangularEdge[j][1]])); Int4 invisible = triangles[i].Hidden(j); if (st[k] == -1) st[k] = 3 * i + j; else if (st[k] >= 0) { - assert(!triangles[i].TriangleAdj(j) && - !triangles[st[k] / 3].TriangleAdj((int)(st[k] % 3))); + assert(!triangles[i].TriangleAdj(j) && !triangles[st[k] / 3].TriangleAdj((int)(st[k] % 3))); triangles[i].SetAdj2(j, triangles + st[k] / 3, (int)(st[k] % 3)); if (invisible) triangles[i].SetHidden(j); @@ -4021,15 +3900,11 @@ namespace bamg { } st[k] = -2 - st[k]; } else { - cerr << " The edge (" << Number(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " - << Number(triangles[i][VerticesOfTriangularEdge[j][1]]) - << " ) is in more than 2 triangles " << k << endl; + cerr << " The edge (" << Number(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " << Number(triangles[i][VerticesOfTriangularEdge[j][1]]) << " ) is in more than 2 triangles " << k + << endl; cerr << " Edge " << j << " Of Triangle " << i << endl; cerr << " Edge " << (-st[k] + 2) % 3 << " Of Triangle " << (-st[k] + 2) / 3 << endl; - cerr << " Edge " - << triangles[(-st[k] + 2) / 3].NuEdgeTriangleAdj((int)((-st[k] + 2) % 3)) - << " Of Triangle " - << Number(triangles[(-st[k] + 2) / 3].TriangleAdj((int)((-st[k] + 2) % 3))) + cerr << " Edge " << triangles[(-st[k] + 2) / 3].NuEdgeTriangleAdj((int)((-st[k] + 2) % 3)) << " Of Triangle " << Number(triangles[(-st[k] + 2) / 3].TriangleAdj((int)((-st[k] + 2) % 3))) << endl; MeshError(9999, this); } @@ -4066,9 +3941,7 @@ namespace bamg { if (k != 0) { if (verbosity > 20) { cout << " The given edges are " << endl; - for (int i = 0; i < nbe; i++) - cout << " Edge " << i << " : " << Number(edges[i][0]) << " " << Number(edges[i][1]) - << " " << edges[i].ref << endl; + for (int i = 0; i < nbe; i++) cout << " Edge " << i << " : " << Number(edges[i][0]) << " " << Number(edges[i][1]) << " " << edges[i].ref << endl; } cerr << k << " boundary edges are not defined as edges " << endl; MeshError(9998, this); @@ -4280,8 +4153,7 @@ namespace bamg { for (int j = 0; j < 2; j++) if (!edges[i].adj[j]) if (!edges[i][j].on->IsRequiredVertex( )) { - cerr << " Erreur adj et sommet requis edges [" << i << "][ " << j - << "]= " << Number(edges[i][j]) << " : " + cerr << " Erreur adj et sommet requis edges [" << i << "][ " << j << "]= " << Number(edges[i][j]) << " : " << " on = " << Gh.Number(edges[i].on); if (edges[i][j].on->OnGeomVertex( )) cerr << " vertex " << Gh.Number(edges[i][j].on->gv); @@ -4352,10 +4224,8 @@ namespace bamg { for (i = 0; i < nbe; i++) edges[i].Set(Th, i, *this); for (i = 0; i < nbv; i++) vertices[i].Set(Th.vertices[i], Th, *this); for (i = 0; i < NbSubDomains; i++) subdomains[i].Set(Th, i, *this); - for (i = 0; i < NbVerticesOnGeomVertex; i++) - VerticesOnGeomVertex[i].Set(Th.VerticesOnGeomVertex[i], Th, *this); - for (i = 0; i < NbVerticesOnGeomEdge; i++) - VerticesOnGeomEdge[i].Set(Th.VerticesOnGeomEdge[i], Th, *this); + for (i = 0; i < NbVerticesOnGeomVertex; i++) VerticesOnGeomVertex[i].Set(Th.VerticesOnGeomVertex[i], Th, *this); + for (i = 0; i < NbVerticesOnGeomEdge; i++) VerticesOnGeomEdge[i].Set(Th.VerticesOnGeomEdge[i], Th, *this); quadtree = 0; // assert(!OutSidesTriangles); @@ -4452,8 +4322,7 @@ namespace bamg { for (i = 0; i < nbv; i++) tstart[i] = 0; for (j = 0; j < NbVerticesOnGeomVertex; j++) tstart[Number(VerticesOnGeomVertex[j].mv)] = &vide; for (k = 0; k < NbVerticesOnGeomEdge; k++) tstart[Number(VerticesOnGeomEdge[k].mv)] = &vide; - if (verbosity > 2) - cout << " -- SmoothingVertex: nb Iteration = " << nbiter << " Omega = " << omega << endl; + if (verbosity > 2) cout << " -- SmoothingVertex: nb Iteration = " << nbiter << " Omega = " << omega << endl; for (k = 0; k < nbiter; k++) { Int4 i, NbSwap = 0; Real8 delta = 0; @@ -4464,9 +4333,7 @@ namespace bamg { for (i = 0; i < nbv; i++) if (tstart[i] != &vide) // not a boundary vertex NbSwap += vertices[i].Optim(1); - if (verbosity > 3) - cout << " Move max = " << sqrt(delta) << " iteration = " << k - << " Nb of Swap = " << NbSwap << endl; + if (verbosity > 3) cout << " Move max = " << sqrt(delta) << " iteration = " << k << " Nb of Swap = " << NbSwap << endl; } delete[] tstart; @@ -4549,13 +4416,10 @@ namespace bamg { area *= 3; gammamn = sqrt(gammamn); gammamx = sqrt(gammamx); - cout << " -- adaptmesh statistics: Nb triangles " << nt << " , h min " << hmin << " , h max " - << hmax << endl; - cout << " area = " << area << " , M area = " << Marea << " , M area/( |Khat| nt) " - << Marea / (aireKh * nt) << endl; + cout << " -- adaptmesh statistics: Nb triangles " << nt << " , h min " << hmin << " , h max " << hmax << endl; + cout << " area = " << area << " , M area = " << Marea << " , M area/( |Khat| nt) " << Marea / (aireKh * nt) << endl; cout << " infiny-regularity: min " << gammamn << " max " << gammamx << endl; - cout << " anisomax " << sqrt(alpha2) << ", beta max = " << 1. / sqrt(beta / aireKh) - << " min " << 1. / sqrt(beta0 / aireKh) << endl; + cout << " anisomax " << sqrt(alpha2) << ", beta max = " << 1. / sqrt(beta / aireKh) << " min " << 1. / sqrt(beta0 / aireKh) << endl; } void Triangles::ShowHistogram( ) const { @@ -4694,7 +4558,7 @@ namespace bamg { kc = 1; vv = vlast++; kkk = 0; - } // new vertex if use + } // new vertex if use kk++; // number of cracked edge view } if (tt->link) { // if good triangles store the value @@ -4730,9 +4594,7 @@ namespace bamg { // int nbvo = nbv; nbv = vlast - vertices; int nbnewv = nbv - nbv; // nb of new vrtices - if (nbcrakev && verbosity > 1) - cout << " Number of craked vertices = " << nbcrakev << " Number of created vertices " - << nbnewv << endl; + if (nbcrakev && verbosity > 1) cout << " Number of craked vertices = " << nbcrakev << " Number of created vertices " << nbnewv << endl; // all the new vertices are on geometry // BOFBO-- A VOIR if (nbnewv) { // @@ -4767,8 +4629,7 @@ namespace bamg { SetVertexFieldOn( ); if (vlast >= vend) { - cerr << " Too few vertices. In order to crack the mesh, we need " << nbv << " vertices " - << endl; + cerr << " Too few vertices. In order to crack the mesh, we need " << nbv << " vertices " << endl; MeshError(555, this); } cout << " NbCrackedVertices " << NbCrackedVertices << endl; @@ -4776,8 +4637,7 @@ namespace bamg { return NbCrackedVertices; } - Triangles::Triangles(const Triangles &Tho, const int *flag, const int *bb) - : Gh(*(new Geometry( ))), BTh(*this) { // truncature + Triangles::Triangles(const Triangles &Tho, const int *flag, const int *bb) : Gh(*(new Geometry( ))), BTh(*this) { // truncature // char cname[] = "trunc"; @@ -4883,8 +4743,7 @@ namespace bamg { if (!a || !a->t) { if (a) { - cerr << " Warning: problem TriangleConteningTheVertex vertex number=" << Number(a) - << endl; + cerr << " Warning: problem TriangleConteningTheVertex vertex number=" << Number(a) << endl; cerr << " We forgot a call to ReMakeTriangleContainingTheVertex" << endl; } cerr << " Problem with " << B << toR2(B) << endl; diff --git a/src/bamglib/Mesh2.h b/src/bamglib/Mesh2.h index 52cb42d1f..64d4cd89f 100644 --- a/src/bamglib/Mesh2.h +++ b/src/bamglib/Mesh2.h @@ -62,17 +62,17 @@ namespace bamg { extern int hinterpole; typedef P2< Icoor1, Icoor2 > I2; -int myrand(void); + int myrand(void); inline int BinaryRand( ) { - return myrand() < (1<<30) ; - /* + return myrand( ) < (1 << 30); + /* #ifdef RAND_MAX - const long HalfRandMax = RAND_MAX / 2; - return rand( ) < HalfRandMax; + const long HalfRandMax = RAND_MAX / 2; + return rand( ) < HalfRandMax; #else - return rand( ) & 16384; // 2^14 (for sun because RAND_MAX is not def in stdlib.h) + return rand( ) & 16384; // 2^14 (for sun because RAND_MAX is not def in stdlib.h) #endif - */ + */ } typedef P2< Real8, Real8 > R2; @@ -130,8 +130,7 @@ namespace bamg { class ErrorMesh : public Error { public: const Triangles *Th; - ErrorMesh(const char *Text, int l, const Triangles *TTh = 0, const char *t2 = "") - : Error(MESH_ERROR, "Meshing error: ", Text, "\n number : ", l, ", ", t2), Th(TTh) {} + ErrorMesh(const char *Text, int l, const Triangles *TTh = 0, const char *t2 = "") : Error(MESH_ERROR, "Meshing error: ", Text, "\n number : ", l, ", ", t2), Th(TTh) {} }; #endif @@ -140,7 +139,7 @@ namespace bamg { Icoor1 dir; public: - Direction( ) : dir(MaxICoor){}; // no direction set + Direction( ) : dir(MaxICoor) {}; // no direction set Direction(Icoor1 i, Icoor1 j) { Icoor2 n2 = 2 * (Abs(i) + Abs(j)); Icoor2 r = MaxICoor * (Icoor2)i; @@ -183,7 +182,7 @@ namespace bamg { Vertex *onbv; // if vint == 16 on Background vertex Triangles::SetVertexFieldOnBTh() VertexOnEdge *onbe; // if vint == 32 on Background edge }; - Int1 vint; // the vertex number in triangle; varies between 0 and 2 in t + Int1 vint; // the vertex number in triangle; varies between 0 and 2 in t operator I2( ) const { return i; } // operator de cast operator const R2 &( ) const { return r; } // operator de cast // operator R2 & () {return r;}// operator de cast @@ -223,8 +222,8 @@ namespace bamg { Triangle *t; // le triangle int a; // le numero de l arete - TriangleAdjacent(Triangle *tt, int aa) : t(tt), a(aa & 3){}; - TriangleAdjacent( ){}; + TriangleAdjacent(Triangle *tt, int aa) : t(tt), a(aa & 3) {}; + TriangleAdjacent( ) {}; operator Triangle *( ) const { return t; } operator Triangle &( ) const { return *t; } @@ -271,8 +270,7 @@ namespace bamg { // on the curve edge a t in [0:1] Edge *adj[2]; // the 2 adj edges if on the same curve int Intersection(const Edge &e) const { - if (!(adj[0] == &e || adj[1] == &e)) - cerr << "Bug : Intersection " << (void *)&e << " " << adj[0] << " " << adj[1] << endl; + if (!(adj[0] == &e || adj[1] == &e)) cerr << "Bug : Intersection " << (void *)&e << " " << adj[0] << " " << adj[1] << endl; assert(adj[0] == &e || adj[1] == &e); return adj[0] == &e ? 0 : 1; } @@ -302,7 +300,7 @@ namespace bamg { t = v.t; vint = v.vint; } - GeometricalVertex( ) : cas(0), link(this){}; + GeometricalVertex( ) : cas(0), link(this) {}; GeometricalVertex *The( ) { assert(link); return link; @@ -386,9 +384,8 @@ namespace bamg { friend class TriangleAdjacent; friend ostream &operator<<(ostream &f, const Triangle &ta); - private: // les arete sont opposes a un sommet - Vertex - *ns[3]; // 3 vertices if t is triangle, t[i] allowed by access function, (*t)[i] if pointer + private: // les arete sont opposes a un sommet + Vertex *ns[3]; // 3 vertices if t is triangle, t[i] allowed by access function, (*t)[i] if pointer Triangle *at[3]; // nu triangle adjacent Int1 aa[3]; // les nu des arete dans le triangles (mod 4) public: @@ -433,10 +430,8 @@ namespace bamg { return TriangleAdjacent(at[i], aa[i] & 3); }; - Triangle *TriangleAdj(int i) const { return at[i & 3]; } // triangle adjacent + arete - Int1 NuEdgeTriangleAdj(int i) const { - return aa[i & 3] & 3; - } // Number of the adjacent edge in adj tria + Triangle *TriangleAdj(int i) const { return at[i & 3]; } // triangle adjacent + arete + Int1 NuEdgeTriangleAdj(int i) const { return aa[i & 3] & 3; } // Number of the adjacent edge in adj tria inline Real8 qualite( ); @@ -559,11 +554,8 @@ namespace bamg { public: IntersectionTriangles &operator[](int i) { return lIntTria[i]; } operator int &( ) { return Size; } - ListofIntersectionTriangles(int n = 256, int m = 16) - : MaxSize(n), Size(0), len(-1), state(-1), lIntTria(new IntersectionTriangles[n]), NbSeg(0), - MaxNbSeg(m), lSegsI(new SegInterpolation[m]) { - if (verbosity > 9) - cout << " construct ListofIntersectionTriangles" << MaxSize << " " << MaxNbSeg << endl; + ListofIntersectionTriangles(int n = 256, int m = 16) : MaxSize(n), Size(0), len(-1), state(-1), lIntTria(new IntersectionTriangles[n]), NbSeg(0), MaxNbSeg(m), lSegsI(new SegInterpolation[m]) { + if (verbosity > 9) cout << " construct ListofIntersectionTriangles" << MaxSize << " " << MaxNbSeg << endl; }; ~ListofIntersectionTriangles( ) { if (lIntTria) delete[] lIntTria, lIntTria = 0; @@ -604,9 +596,7 @@ namespace bamg { assert(nw); for (int i = 0; i < MaxSize; i++) // recopy nw[i] = lIntTria[i]; - if (verbosity > 3) - cout << " ListofIntersectionTriangles ReShape MaxSize " << MaxSize << " -> " << newsize - << endl; + if (verbosity > 3) cout << " ListofIntersectionTriangles ReShape MaxSize " << MaxSize << " -> " << newsize << endl; MaxSize = newsize; delete[] lIntTria; // remove old lIntTria = nw; // copy pointer @@ -674,7 +664,7 @@ namespace bamg { public: Vertex *v, *bv; VertexOnVertex(Vertex *w, Vertex *bw) : v(w), bv(bw) {} - VertexOnVertex( ){}; + VertexOnVertex( ) {}; inline void Set(const Triangles &, Int4, Triangles &); void SetOnBTh( ) { v->onbv = bv; @@ -747,8 +737,8 @@ namespace bamg { public: CrackedTriangle a, b; CrackedEdge( ) : a( ), b( ) {} - CrackedEdge(Edge *start, Int4 i, Int4 j) : a(start + i), b(start + j){}; - CrackedEdge(Edge *e0, Edge *e1) : a(e0), b(e1){}; + CrackedEdge(Edge *start, Int4 i, Int4 j) : a(start + i), b(start + j) {}; + CrackedEdge(Edge *e0, Edge *e1) : a(e0), b(e1) {}; void Crack( ) { a.Crack( ); @@ -829,7 +819,7 @@ namespace bamg { int warning; // end of variable - Triangles(Int4 i); //:BTh(*this),Gh(*new Geometry()){PreInit(i);} + Triangles(Int4 i); //: BTh(*this),Gh(*new Geometry()){PreInit(i);} void clear( ); ~Triangles( ) { if (NbRef == 0) { @@ -873,12 +863,8 @@ namespace bamg { Vertex &operator[](Int4 i) { return vertices[i]; }; const Triangle &operator( )(Int4 i) const { return triangles[i]; }; Triangle &operator( )(Int4 i) { return triangles[i]; }; - I2 toI2(const R2 &P) const { - return I2((Icoor1)(coefIcoor * (P.x - pmin.x)), (Icoor1)(coefIcoor * (P.y - pmin.y))); - } - R2 toR2(const I2 &P) const { - return R2((double)P.x / coefIcoor + pmin.x, (double)P.y / coefIcoor + pmin.y); - } + I2 toI2(const R2 &P) const { return I2((Icoor1)(coefIcoor * (P.x - pmin.x)), (Icoor1)(coefIcoor * (P.y - pmin.y))); } + R2 toR2(const I2 &P) const { return R2((double)P.x / coefIcoor + pmin.x, (double)P.y / coefIcoor + pmin.y); } void Add(Vertex &s, Triangle *t, Icoor2 * = 0); void Insert( ); // void InsertOld(); @@ -911,17 +897,16 @@ namespace bamg { void ReNumberingVertex(Int4 *renu); void SmoothingVertex(int = 3, Real8 = 0.3); Metric MetricAt(const R2 &) const; - GeometricalEdge *ProjectOnCurve(Edge &AB, Vertex &A, Vertex &B, Real8 theta, Vertex &R, - VertexOnEdge &BR, VertexOnGeom &GR); + GeometricalEdge *ProjectOnCurve(Edge &AB, Vertex &A, Vertex &B, Real8 theta, Vertex &R, VertexOnEdge &BR, VertexOnGeom &GR); void WriteElements(ostream &f, Int4 *reft, Int4 nbInT) const; Int4 Number(const Triangle &t) const { return &t - triangles; } - Int4 Number(const Triangle *t) const { return t ?t - triangles:-1; } + Int4 Number(const Triangle *t) const { return t ? t - triangles : -1; } Int4 Number(const Vertex &t) const { return &t - vertices; } - Int4 Number(const Vertex *t) const { return t ? t - vertices:-1; } + Int4 Number(const Vertex *t) const { return t ? t - vertices : -1; } Int4 Number(const Edge &t) const { return &t - edges; } - Int4 Number(const Edge *t) const { return t ? t - edges:-1; } + Int4 Number(const Edge *t) const { return t ? t - edges : -1; } Int4 Number2(const Triangle *t) const { // if(t>= triangles && t < triangles + nbt ) return t - triangles; @@ -950,11 +935,8 @@ namespace bamg { void Read_msh(MeshIstream &); void ReadMetric(const char *fmetrix, const Real8 hmin, const Real8 hmax, const Real8 coef); - void IntersectConsMetric(const double *s, const Int4 nbsol, const int *typsols, - const Real8 hmin, const Real8 hmax, const Real8 coef, - const Real8 anisomax, const Real8 CutOff = 1.e-4, - const int NbJacobi = 1, const int DoNormalisation = 1, - const double power = 1.0, const int choise = 0); + void IntersectConsMetric(const double *s, const Int4 nbsol, const int *typsols, const Real8 hmin, const Real8 hmax, const Real8 coef, const Real8 anisomax, const Real8 CutOff = 1.e-4, + const int NbJacobi = 1, const int DoNormalisation = 1, const double power = 1.0, const int choise = 0); void IntersectGeomMetric(const Real8 err, const int iso); int isCracked( ) const { return NbCrackedVertices != 0; } @@ -981,8 +963,7 @@ namespace bamg { void GeomToTriangles0(Int4 nbvx); // the real constructor mesh generator void PreInit(Int4, char * = 0); // - void Write_nop5(OFortranUnFormattedFile *f, Int4 &lnop5, Int4 &nef, Int4 &lgpdn, - Int4 ndsr) const; + void Write_nop5(OFortranUnFormattedFile *f, Int4 &lnop5, Int4 &nef, Int4 &lgpdn, Int4 ndsr) const; }; // End Class Triangles ///////////////////////////////////////////////////////////////////////////////////// @@ -1016,9 +997,7 @@ namespace bamg { // end of data - I2 toI2(const R2 &P) const { - return I2((Icoor1)(coefIcoor * (P.x - pmin.x)), (Icoor1)(coefIcoor * (P.y - pmin.y))); - } + I2 toI2(const R2 &P) const { return I2((Icoor1)(coefIcoor * (P.x - pmin.x)), (Icoor1)(coefIcoor * (P.y - pmin.y))); } Real8 MinimalHmin( ) { return 2.0 / coefIcoor; } Real8 MaximalHmax( ) { return Max(pmax.x - pmin.x, pmax.y - pmin.y); } @@ -1110,8 +1089,7 @@ namespace bamg { q = -1; // because we do 2 times else if (!t->link) q = -1; - else if (aa[0] & 16 || aa[1] & 16 || aa[2] & 16 || t->aa[0] & 16 || t->aa[1] & 16 || - t->aa[2] & 16) + else if (aa[0] & 16 || aa[1] & 16 || aa[2] & 16 || t->aa[0] & 16 || t->aa[1] & 16 || t->aa[2] & 16) q = -1; else if (option) { const Vertex &v2 = *ns[VerticesOfTriangularEdge[a][0]]; @@ -1126,10 +1104,7 @@ namespace bamg { } inline void Vertex::Set(const Vertex &rec, const Triangles &, Triangles &) { *this = rec; } - inline void GeometricalVertex::Set(const GeometricalVertex &rec, const Geometry &, - const Geometry &) { - *this = rec; - } + inline void GeometricalVertex::Set(const GeometricalVertex &rec, const Geometry &, const Geometry &) { *this = rec; } inline void Edge::Set(const Triangles &Th, Int4 i, Triangles &ThNew) { *this = Th.edges[i]; v[0] = ThNew.vertices + Th.Number(v[0]); @@ -1138,8 +1113,7 @@ namespace bamg { if (adj[0]) adj[0] = ThNew.edges + Th.Number(adj[0]); if (adj[1]) adj[1] = ThNew.edges + Th.Number(adj[1]); } - inline void GeometricalEdge::Set(const GeometricalEdge &rec, const Geometry &Gh, - Geometry &GhNew) { + inline void GeometricalEdge::Set(const GeometricalEdge &rec, const Geometry &Gh, Geometry &GhNew) { *this = rec; v[0] = GhNew.vertices + Gh.Number(v[0]); v[1] = GhNew.vertices + Gh.Number(v[1]); @@ -1162,8 +1136,7 @@ namespace bamg { if (at[0]) at[0] = ThNew.triangles + Th.Number(at[0]); if (at[1]) at[1] = ThNew.triangles + Th.Number(at[1]); if (at[2]) at[2] = ThNew.triangles + Th.Number(at[2]); - if (link >= Th.triangles && link < Th.triangles + Th.nbt) - link = ThNew.triangles + Th.Number(link); + if (link >= Th.triangles && link < Th.triangles + Th.nbt) link = ThNew.triangles + Th.Number(link); } inline void VertexOnVertex::Set(const Triangles &Th, Int4 i, Triangles &ThNew) { *this = Th.VertexOnBThVertex[i]; @@ -1176,8 +1149,7 @@ namespace bamg { assert(edge - Th.edges >= 0 && edge - Th.edges < Th.nbe); edge = ThNew.edges + Th.Number(edge); } - inline void GeometricalSubDomain::Set(const GeometricalSubDomain &rec, const Geometry &Gh, - const Geometry &GhNew) { + inline void GeometricalSubDomain::Set(const GeometricalSubDomain &rec, const Geometry &Gh, const Geometry &GhNew) { *this = rec; edge = Gh.Number(edge) + GhNew.edges; } @@ -1196,9 +1168,7 @@ namespace bamg { ge = ThNew.Gh.edges + Th.Gh.Number(ge); } } - inline Real8 Edge::MetricLength( ) const { - return LengthInterpole(v[0]->m, v[1]->m, v[1]->r - v[0]->r); - } + inline Real8 Edge::MetricLength( ) const { return LengthInterpole(v[0]->m, v[1]->m, v[1]->r - v[0]->r); } inline void Triangles::ReMakeTriangleContainingTheVertex( ) { Int4 i; @@ -1240,9 +1210,7 @@ namespace bamg { inline int TriangleAdjacent::Locked( ) const { return t->aa[a] & 4; } inline int TriangleAdjacent::Cracked( ) const { return t->aa[a] & 32; } - inline int TriangleAdjacent::GetAllFlag_UnSwap( ) const { - return t->aa[a] & 1012; - } // take all flag except MarkUnSwap + inline int TriangleAdjacent::GetAllFlag_UnSwap( ) const { return t->aa[a] & 1012; } // take all flag except MarkUnSwap inline int TriangleAdjacent::MarkUnSwap( ) const { return t->aa[a] & 8; } @@ -1252,22 +1220,14 @@ namespace bamg { inline TriangleAdjacent TriangleAdjacent::Adj( ) const { return t->Adj(a); } - inline Vertex *TriangleAdjacent::EdgeVertex(const int &i) const { - return t->ns[VerticesOfTriangularEdge[a][i]]; - } - inline Vertex *TriangleAdjacent::OppositeVertex( ) const { - return t->ns[bamg::OppositeVertex[a]]; - } + inline Vertex *TriangleAdjacent::EdgeVertex(const int &i) const { return t->ns[VerticesOfTriangularEdge[a][i]]; } + inline Vertex *TriangleAdjacent::OppositeVertex( ) const { return t->ns[bamg::OppositeVertex[a]]; } inline Icoor2 &TriangleAdjacent::det( ) const { return t->det; } inline TriangleAdjacent Adj(const TriangleAdjacent &a) { return a.Adj( ); } - inline TriangleAdjacent Next(const TriangleAdjacent &ta) { - return TriangleAdjacent(ta.t, NextEdge[ta.a]); - } + inline TriangleAdjacent Next(const TriangleAdjacent &ta) { return TriangleAdjacent(ta.t, NextEdge[ta.a]); } - inline TriangleAdjacent Previous(const TriangleAdjacent &ta) { - return TriangleAdjacent(ta.t, PreviousEdge[ta.a]); - } + inline TriangleAdjacent Previous(const TriangleAdjacent &ta) { return TriangleAdjacent(ta.t, PreviousEdge[ta.a]); } inline void Adj(GeometricalEdge *&on, int &i) { int j = i; @@ -1283,8 +1243,7 @@ namespace bamg { if (deta <= 0) ret = -1; else { - Real8 a = sqrt((Real8)(ac, ac)), b = sqrt((Real8)(bc, bc)), c = sqrt((Real8)(ab, ab)), - p = a + b + c; + Real8 a = sqrt((Real8)(ac, ac)), b = sqrt((Real8)(bc, bc)), c = sqrt((Real8)(ab, ab)), p = a + b + c; Real8 h = Max(Max(a, b), c), ro = deta / p; ret = ro / h; } @@ -1338,13 +1297,11 @@ namespace bamg { return bax * cay - bay * cax; } - void swap(Triangle *t1, Int1 a1, Triangle *t2, Int1 a2, Vertex *s1, Vertex *s2, Icoor2 det1, - Icoor2 det2); + void swap(Triangle *t1, Int1 a1, Triangle *t2, Int1 a2, Vertex *s1, Vertex *s2, Icoor2 det1, Icoor2 det2); int inline TriangleAdjacent::swap( ) { return t->swap(a); } - int SwapForForcingEdge(Vertex *&pva, Vertex *&pvb, TriangleAdjacent &tt1, Icoor2 &dets1, - Icoor2 &detsa, Icoor2 &detsb, int &nbswap); + int SwapForForcingEdge(Vertex *&pva, Vertex *&pvb, TriangleAdjacent &tt1, Icoor2 &dets1, Icoor2 &detsa, Icoor2 &detsb, int &nbswap); int ForceEdge(Vertex &a, Vertex &b, TriangleAdjacent &taret); @@ -1412,27 +1369,14 @@ namespace bamg { Int2 a1 = a, a2 = aa[a] % 4; assert(a2 < 3 && a2 >= 0); - if (t2 && - (((*t1).ns[VerticesOfTriangularEdge[a1][0]] != (*t2).ns[VerticesOfTriangularEdge[a2][1]]) || - ((*t1).ns[VerticesOfTriangularEdge[a1][1]] != - (*t2).ns[VerticesOfTriangularEdge[a2][0]]))) { - if (CurrentTh) - cerr << " In Triangles between Triangle " << CurrentTh->Number(t1) << " and " - << CurrentTh->Number(t2) << endl; + if (t2 && (((*t1).ns[VerticesOfTriangularEdge[a1][0]] != (*t2).ns[VerticesOfTriangularEdge[a2][1]]) || ((*t1).ns[VerticesOfTriangularEdge[a1][1]] != (*t2).ns[VerticesOfTriangularEdge[a2][0]]))) { + if (CurrentTh) cerr << " In Triangles between Triangle " << CurrentTh->Number(t1) << " and " << CurrentTh->Number(t2) << endl; cerr << "---- t1=" << t1 << " " << a1 << ", t2=" << t2 << " " << a2 << endl; - cerr << "t1=" << t1 << " " << a1 << " " << t1->ns[VerticesOfTriangularEdge[a1][0]] << " " - << t1->ns[VerticesOfTriangularEdge[a1][1]] << endl; - if (CurrentTh) - cerr << "t1=" << t1 << " " << a1 << " " - << CurrentTh->Number(t1->ns[VerticesOfTriangularEdge[a1][0]]) << " " - << CurrentTh->Number(t1->ns[VerticesOfTriangularEdge[a1][1]]) << endl; - if (t2) - cerr << "t2=" << t2 << " " << a2 << " " << t2->ns[VerticesOfTriangularEdge[a2][0]] << " " - << t2->ns[VerticesOfTriangularEdge[a2][1]] << endl; + cerr << "t1=" << t1 << " " << a1 << " " << t1->ns[VerticesOfTriangularEdge[a1][0]] << " " << t1->ns[VerticesOfTriangularEdge[a1][1]] << endl; + if (CurrentTh) cerr << "t1=" << t1 << " " << a1 << " " << CurrentTh->Number(t1->ns[VerticesOfTriangularEdge[a1][0]]) << " " << CurrentTh->Number(t1->ns[VerticesOfTriangularEdge[a1][1]]) << endl; + if (t2) cerr << "t2=" << t2 << " " << a2 << " " << t2->ns[VerticesOfTriangularEdge[a2][0]] << " " << t2->ns[VerticesOfTriangularEdge[a2][1]] << endl; if (t2 && CurrentTh) - cerr << "t2=" << t2 << " " << a2 << " " - << CurrentTh->Number(t2->ns[VerticesOfTriangularEdge[a2][0]]) << " " - << CurrentTh->Number(t2->ns[VerticesOfTriangularEdge[a2][1]]) << endl; + cerr << "t2=" << t2 << " " << a2 << " " << CurrentTh->Number(t2->ns[VerticesOfTriangularEdge[a2][0]]) << " " << CurrentTh->Number(t2->ns[VerticesOfTriangularEdge[a2][1]]) << endl; assert(0); } if (t2) assert(t1->aa[a1] / 4 == t2->aa[a2] / 4); // lock compatibite diff --git a/src/bamglib/MeshDraw.cpp b/src/bamglib/MeshDraw.cpp index b71109183..cf29c180c 100644 --- a/src/bamglib/MeshDraw.cpp +++ b/src/bamglib/MeshDraw.cpp @@ -72,32 +72,30 @@ namespace bamg { void Edge::Draw(Int4 i) const { if (!withrgraphique) return; - if (InRecScreen(Min(v[0]->r.x, v[1]->r.x), Max(v[0]->r.y, v[1]->r.y), Min(v[0]->r.x, v[1]->r.x), - Max(v[0]->r.y, v[1]->r.y))) { + if (InRecScreen(Min(v[0]->r.x, v[1]->r.x), Max(v[0]->r.y, v[1]->r.y), Min(v[0]->r.x, v[1]->r.x), Max(v[0]->r.y, v[1]->r.y))) { v[0]->MoveTo( ); v[1]->LineTo( ); R2 M = ((R2)*v[0] + (R2)*v[1]) * 0.5; Move(M); char VertexDraw_i10[20]; if (i < 0) - snprintf(VertexDraw_i10,20, "%p", this); + snprintf(VertexDraw_i10, 20, "%p", this); else - snprintf(VertexDraw_i10,20, "%ld", i); + snprintf(VertexDraw_i10, 20, "%ld", i); if (i >= 0) plotstring(&VertexDraw_i10[0]); } } void Vertex::Draw(Int4 i) const { if (!withrgraphique) return; if (CurrentTh && i < 0 && i != -2) { - if (CurrentTh->vertices <= this && this < CurrentTh->vertices + CurrentTh->nbv) - i = CurrentTh->Number(this); + if (CurrentTh->vertices <= this && this < CurrentTh->vertices + CurrentTh->nbv) i = CurrentTh->Number(this); } if (InPtScreen(r.x, r.y)) { char VertexDraw_i10[20]; if (i < 0) - snprintf(VertexDraw_i10,20, "%p", this); + snprintf(VertexDraw_i10, 20, "%p", this); else - snprintf(VertexDraw_i10,20, "%ld", i); + snprintf(VertexDraw_i10, 20, "%ld", i); showgraphic( ); // float eps = (MaxICoor/yGrafCoef)/100; @@ -122,29 +120,23 @@ namespace bamg { if (!withrgraphique) return; // int cc=LaCouleur(); if (CurrentTh && i < 0 && i != -2) { - if (CurrentTh->triangles <= this && this < CurrentTh->triangles + CurrentTh->nbt) - i = CurrentTh->Number(this); + if (CurrentTh->triangles <= this && this < CurrentTh->triangles + CurrentTh->nbt) i = CurrentTh->Number(this); } char i10[20]; if (i < 0) - snprintf(i10,20, "%p", this); + snprintf(i10, 20, "%p", this); else - snprintf(i10,20, "%ld", i); + snprintf(i10, 20, "%ld", i); showgraphic( ); if (ns[0] == 0) { - if (InRecScreen(Min(ns[1]->r.x, ns[2]->r.x), Min(ns[1]->r.y, ns[2]->r.y), - Max(ns[1]->r.x, ns[2]->r.x), Max(ns[1]->r.y, ns[2]->r.y))) { + if (InRecScreen(Min(ns[1]->r.x, ns[2]->r.x), Min(ns[1]->r.y, ns[2]->r.y), Max(ns[1]->r.x, ns[2]->r.x), Max(ns[1]->r.y, ns[2]->r.y))) { rmoveto(ns[1]->r.x, ns[1]->r.y); rlineto(ns[2]->r.x, ns[2]->r.y); - rmoveto((ns[1]->r.x + ns[2]->r.x) / 2.0 + (ns[1]->r.y - ns[2]->r.y) * 0.1, - (ns[1]->r.y + ns[2]->r.y) / 2.0 - (ns[1]->r.x - ns[2]->r.x) * 0.1); + rmoveto((ns[1]->r.x + ns[2]->r.x) / 2.0 + (ns[1]->r.y - ns[2]->r.y) * 0.1, (ns[1]->r.y + ns[2]->r.y) / 2.0 - (ns[1]->r.x - ns[2]->r.x) * 0.1); if (i >= 0) plotstring(&i10[0]); } - } else if (InRecScreen(Min3(ns[0]->r.x, ns[1]->r.x, ns[2]->r.x), - Min3(ns[0]->r.y, ns[1]->r.y, ns[2]->r.y), - Max3(ns[0]->r.x, ns[1]->r.x, ns[2]->r.x), - Max3(ns[0]->r.y, ns[1]->r.y, ns[2]->r.y))) { + } else if (InRecScreen(Min3(ns[0]->r.x, ns[1]->r.x, ns[2]->r.x), Min3(ns[0]->r.y, ns[1]->r.y, ns[2]->r.y), Max3(ns[0]->r.x, ns[1]->r.x, ns[2]->r.x), Max3(ns[0]->r.y, ns[1]->r.y, ns[2]->r.y))) { { const int i0 = 0, j01 = EdgesVertexTriangle[i0][1]; // j01==2 const int i1 = VerticesOfTriangularEdge[j01][1], @@ -166,8 +158,7 @@ namespace bamg { else rlineto(ns[i0]->r.x, ns[i0]->r.y); - rmoveto((ns[0]->r.x + ns[1]->r.x + ns[2]->r.x) / 3.0, - (ns[0]->r.y + ns[1]->r.y + ns[2]->r.y) / 3.0); + rmoveto((ns[0]->r.x + ns[1]->r.x + ns[2]->r.x) / 3.0, (ns[0]->r.y + ns[1]->r.y + ns[2]->r.y) / 3.0); } if (i >= 0) plotstring(&i10[0]); @@ -227,8 +218,7 @@ namespace bamg { // **********************************************************************"< 2) cout << "inquire: Nb de Triangle reel = " << ConsRefTriangle(reft) << endl; - while (Show("Enter ? for help", PS == 0), c = ::Getxyc(x, y), - (c && c != 'F' && c != 'f') && c < 250) { + while (Show("Enter ? for help", PS == 0), c = ::Getxyc(x, y), (c && c != 'F' && c != 'f') && c < 250) { rd = 0; couleur(1); // cout << " #"<< c << "# " << (int) c << " xy=" << x << " "<< y <Draw( ), couleur(1), penthickness(1); + if (c == 'q' && quadtree) penthickness(2), couleur(6), quadtree->Draw( ), couleur(1), penthickness(1); if (c == 'g') couleur(6), Gh.Draw( ); if (c == 'n') { for (int i = 0; i < nbv; i++) { @@ -372,8 +361,7 @@ namespace bamg { d = dd; } } - cout << " sommet " << j << "= " << vertices[j] << ", d = " << d << " " << vertices[j].m - << endl; + cout << " sommet " << j << "= " << vertices[j] << ", d = " << d << " " << vertices[j].m << endl; vertices[j].Draw(j); DrawMark(vertices[j].r); if (c == 's') vertices[j].m.Draw(vertices[j]); @@ -408,12 +396,9 @@ namespace bamg { Vertex *v1 = tta.EdgeVertex(1); tta.EdgeVertex(0)->MoveTo( ); tta.EdgeVertex(1)->LineTo( ); - cout << " Edge " << Number(tta.EdgeVertex(0)) << " " << Number(tta.EdgeVertex(1)) - << endl; + cout << " Edge " << Number(tta.EdgeVertex(0)) << " " << Number(tta.EdgeVertex(1)) << endl; for (Int4 k = 0; k < nbe; k++) - if ((edges[k](0) == v0 && edges[k](1) == v1) || - (edges[k](0) == v1 && edges[k](1) == v0)) - cout << " Edge " << k << " on Geo = " << Gh.Number(edges[k].on) << endl; + if ((edges[k](0) == v0 && edges[k](1) == v1) || (edges[k](0) == v1 && edges[k](1) == v0)) cout << " Edge " << k << " on Geo = " << Gh.Number(edges[k].on) << endl; if (c == 'e') { triangles[i].SetUnMarkUnSwap(ie); @@ -510,10 +495,10 @@ namespace bamg { return c; } -void Draw(long i, long j) { + void Draw(long i, long j) { if (!withrgraphique) return; - Draw((float) (i / xGrafCoef + xGrafOffSet), (float)(j / yGrafCoef + yGrafOffSet)); -} + Draw((float)(i / xGrafCoef + xGrafOffSet), (float)(j / yGrafCoef + yGrafOffSet)); + } int Triangle::swapDRAW(Int2 a) { int NbUnSwap = 0; if (a / 4 != 0) { @@ -564,21 +549,15 @@ void Draw(long i, long j) { while (1) if (kopt) { // critere de Delaunay pure - Real8 xb1 = sb->i.x - s1->i.x, x21 = s2->i.x - s1->i.x, yb1 = sb->i.y - s1->i.y, - y21 = s2->i.y - s1->i.y, xba = sb->i.x - sa->i.x, x2a = s2->i.x - sa->i.x, - yba = sb->i.y - sa->i.y, y2a = s2->i.y - sa->i.y, - cosb12 = xb1 * x21 + yb1 * y21, cosba2 = xba * x2a + yba * y2a, sinb12 = det2, - sinba2 = t2->det, + Real8 xb1 = sb->i.x - s1->i.x, x21 = s2->i.x - s1->i.x, yb1 = sb->i.y - s1->i.y, y21 = s2->i.y - s1->i.y, xba = sb->i.x - sa->i.x, x2a = s2->i.x - sa->i.x, yba = sb->i.y - sa->i.y, + y2a = s2->i.y - sa->i.y, cosb12 = xb1 * x21 + yb1 * y21, cosba2 = xba * x2a + yba * y2a, sinb12 = det2, sinba2 = t2->det, // zsinba2 = t2->det; // angle b12 > angle ba2 => cotg(angle b12) < cotg(angle ba2) OnSwap = (cosb12 * sinba2) < (cosba2 * sinb12); - if (CurrentTh) - cout << "swap s1=" << CurrentTh->Number(sa) << " s2=" << CurrentTh->Number(sb) - << " t1= " << CurrentTh->Number(t1) << " t2=" << CurrentTh->Number(t2) << " "; + if (CurrentTh) cout << "swap s1=" << CurrentTh->Number(sa) << " s2=" << CurrentTh->Number(sb) << " t1= " << CurrentTh->Number(t1) << " t2=" << CurrentTh->Number(t2) << " "; - cout << cosb12 << " " << sinba2 << " " << cosba2 << " " << sinb12 - << " Onswap = " << OnSwap << endl; + cout << cosb12 << " " << sinba2 << " " << cosba2 << " " << sinb12 << " Onswap = " << OnSwap << endl; break; } else { @@ -607,8 +586,7 @@ void Draw(long i, long j) { double d = (ABo.x * A1o.y - ABo.y * A1o.x) * 2; // because D/2 if (Abs(d) > dd * 1.e-3) { D2 C(MAB + ABo * ((D.x * A1o.y - D.y * A1o.x) / d)); - cout << "M1 r2 =" << M(C - S2) << " r1 = " << M(C - S1) << "ra = " << M(C - SA) - << " rb = " << M(C - SB); + cout << "M1 r2 =" << M(C - S2) << " r1 = " << M(C - S1) << "ra = " << M(C - SA) << " rb = " << M(C - SB); som = M(C - S2) / M(C - S1); cout << " r1/r2 = " << som << endl; } else { @@ -627,8 +605,7 @@ void Draw(long i, long j) { cout << " d = " << Abs(d) << " dd " << dd << endl; if (Abs(d) > dd * 1.e-3) { D2 C(MAB + ABo * ((D.x * A1o.y - D.y * A1o.x) / d)); - cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) - << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; + cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; som += M(C - S2) / M(C - S1); } else { kopt = 1; @@ -646,8 +623,7 @@ void Draw(long i, long j) { cout << " d = " << Abs(d) << " dd " << dd << endl; if (Abs(d) > dd * 1.e-3) { D2 C(MAB + ABo * ((D.x * A1o.y - D.y * A1o.x) / d)); - cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) - << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; + cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; som += M(C - S2) / M(C - S1); } else { kopt = 1; @@ -665,8 +641,7 @@ void Draw(long i, long j) { cout << " d = " << Abs(d) << " dd " << dd << endl; if (Abs(d) > dd * 1.e-3) { D2 C(MAB + ABo * ((D.x * A1o.y - D.y * A1o.x) / d)); - cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) - << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; + cout << "M2 r1 =" << M(C - S2) << " r2 = " << M(C - S1) << "ra = " << M(C - SA) << " rb = " << M(C - SB) << " r1/r2 = " << M(C - S2) / M(C - S1) << endl; som += M(C - S2) / M(C - S1); } else { kopt = 1; @@ -679,7 +654,7 @@ void Draw(long i, long j) { } } // OnSwap - } // (! OnSwap &&(det1 > 0) && (det2 > 0) ) + } // (! OnSwap &&(det1 > 0) && (det2 > 0) ) } cout << OnSwap << endl; if (OnSwap) { @@ -701,8 +676,7 @@ void Draw(long i, long j) { if (!withrgraphique) return; if (CurrentTh && i < 0 && i != -2) { - if (CurrentTh->Gh.edges <= this && this < CurrentTh->Gh.edges + CurrentTh->Gh.nbe) - i = CurrentTh->Gh.Number((this)); + if (CurrentTh->Gh.edges <= this && this < CurrentTh->Gh.edges + CurrentTh->Gh.nbe) i = CurrentTh->Gh.Number((this)); } v[0]->MoveTo( ); @@ -723,9 +697,9 @@ void Draw(long i, long j) { char VertexDraw_i10[20]; if (k50) { if (i < 0) - snprintf(VertexDraw_i10,20, "Eg%p", this); + snprintf(VertexDraw_i10, 20, "Eg%p", this); else - snprintf(VertexDraw_i10,20, "Eg%ld", i); + snprintf(VertexDraw_i10, 20, "Eg%ld", i); rmoveto(x50.x, x50.y); plotstring(&VertexDraw_i10[0]); } @@ -747,8 +721,7 @@ void Draw(long i, long j) { float hx = (GrafPMax.x - GrafPMin.x); float hy = (GrafPMax.y - GrafPMin.y); Grafh = Max(hx, hy) * 7 / 10; - if (withrgraphique) - cadreortho((GrafPMin.x + GrafPMax.x) * 0.5, (GrafPMin.y + GrafPMax.y) * 0.55, Grafh); + if (withrgraphique) cadreortho((GrafPMin.x + GrafPMax.x) * 0.5, (GrafPMin.y + GrafPMax.y) * 0.55, Grafh); } void Geometry::Draw( ) const { @@ -769,7 +742,7 @@ void Draw(long i, long j) { for (i = 0; i < nbv; i++) if (vertices[i].Required( )) { char i10[40]; - snprintf(i10,40, "%ld:%d", i, vertices[i].Required( )); + snprintf(i10, 40, "%ld:%d", i, vertices[i].Required( )); Move(vertices[i].r); if (vertices[i].Corner( )) couleur(2); plotstring(i10); diff --git a/src/bamglib/MeshGeom.cpp b/src/bamglib/MeshGeom.cpp index 22cb942f7..7de8ed66e 100644 --- a/src/bamglib/MeshGeom.cpp +++ b/src/bamglib/MeshGeom.cpp @@ -28,7 +28,7 @@ // #define TRACETRIANGLE 3 extern long verbosity; -//#define strcasecmp strcmp +// #define strcasecmp strcmp #include #include #include @@ -84,23 +84,20 @@ namespace bamg { edge4->addtrie(Number(edges[i][0]), Number(edges[i][1]), orientedgeold + i); } if (nbe != edge4->nb( )) { - cerr << " Some Double edge in the mesh, the number is " << nbe << " nbe4=" << edge4->nb( ) - << endl; + cerr << " Some Double edge in the mesh, the number is " << nbe << " nbe4=" << edge4->nb( ) << endl; MeshError(1002); } for (i = 0; i < nbt; i++) for (j = 0; j < 3; j++) { - int orienij; + int orienij; // Int4 i0,i1; - Int4 k = edge4->addtrie(Number(triangles[i][VerticesOfTriangularEdge[j][0]]), - Number(triangles[i][VerticesOfTriangularEdge[j][1]]),&orienij); - if(k< nbe) orientedgeold[k] *= orienij; // Add FH. 30/09/2024 PB orientation of internal edge !!! + Int4 k = edge4->addtrie(Number(triangles[i][VerticesOfTriangularEdge[j][0]]), Number(triangles[i][VerticesOfTriangularEdge[j][1]]), &orienij); + if (k < nbe) orientedgeold[k] *= orienij; // Add FH. 30/09/2024 PB orientation of internal edge !!! Int4 invisible = triangles[i].Hidden(j); if (st[k] == -1) st[k] = 3 * i + j; else if (st[k] >= 0) { - assert(!triangles[i].TriangleAdj(j) && - !triangles[st[k] / 3].TriangleAdj((int)(st[k] % 3))); + assert(!triangles[i].TriangleAdj(j) && !triangles[st[k] / 3].TriangleAdj((int)(st[k] % 3))); triangles[i].SetAdj2(j, triangles + st[k] / 3, (int)(st[k] % 3)); if (invisible) triangles[i].SetHidden(j); @@ -109,14 +106,12 @@ namespace bamg { } st[k] = -2 - st[k]; } else { - cerr << " The edge (" << Number(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " - << Number(triangles[i][VerticesOfTriangularEdge[j][1]]) - << " ) is in more than 2 triangles " << k << endl; + cerr << " The edge (" << Number(triangles[i][VerticesOfTriangularEdge[j][0]]) << " , " << Number(triangles[i][VerticesOfTriangularEdge[j][1]]) << " ) is in more than 2 triangles " << k + << endl; cerr << " Edge " << j << " Of Triangle " << i << endl; cerr << " Edge " << (-st[k] + 2) % 3 << " Of Triangle " << (-st[k] + 2) / 3 << endl; - cerr << " Edge " << triangles[(-st[k] + 2) / 3].NuEdgeTriangleAdj((int)((-st[k] + 2) % 3)) - << " Of Triangle " - << Number(triangles[(-st[k] + 2) / 3].TriangleAdj((int)((-st[k] + 2) % 3))) << endl; + cerr << " Edge " << triangles[(-st[k] + 2) / 3].NuEdgeTriangleAdj((int)((-st[k] + 2) % 3)) << " Of Triangle " << Number(triangles[(-st[k] + 2) / 3].TriangleAdj((int)((-st[k] + 2) % 3))) + << endl; MeshError(9999); } } @@ -146,8 +141,7 @@ namespace bamg { Triangle &tt = *triangles[it].TriangleAdj(j); // cout << it << " c=" << triangles[it].color << " " << Number(tt) << " c=" << tt.color // << endl; - if (triangles[it].color != tt.color || - i < nbeold) // Modif FH 06122055 // between 2 sub domai + if (triangles[it].color != tt.color || i < nbeold) // Modif FH 06122055 // between 2 sub domai k++; } else if (st[i] >= 0) // edge alone // if (i >= nbeold) @@ -197,20 +191,18 @@ namespace bamg { } if (add >= 0 && add < nbe) { - + edges[add].v[0] = &triangles[it][VerticesOfTriangularEdge[j][0]]; edges[add].v[1] = &triangles[it][VerticesOfTriangularEdge[j][1]]; edges[add].on = 0; if (add < nbeold) // in file edge // Modif FH 06122055 { -// Error in periodic adapt 2d !!!! FH, je ne comprend pas 10/10/24 !!!!!!! - // if(orientedgeold[add]<0) std::swap(edges[add].v[0],edges[add].v[1]);// add modif F.H. 30 sep. 24 !!!!! + // Error in periodic adapt 2d !!!! FH, je ne comprend pas 10/10/24 !!!!!!! + // if(orientedgeold[add]<0) std::swap(edges[add].v[0],edges[add].v[1]);// add modif F.H. 30 sep. 24 !!!!! edges[add].ref = edgessave[i].ref; - edges[add].on = - edgessave[i].on; // HACK pour recuperer les aretes requise midf FH avril 2006 ???? + edges[add].on = edgessave[i].on; // HACK pour recuperer les aretes requise midf FH avril 2006 ???? } else - edges[add].ref = - Min(edges[add].v[0]->ref( ), edges[add].v[1]->ref( )); // no a good choice + edges[add].ref = Min(edges[add].v[0]->ref( ), edges[add].v[1]->ref( )); // no a good choice } } assert(k == nbe); @@ -276,9 +268,7 @@ namespace bamg { } } else level -= 2; - if (verbosity > 5) - cout << " Nb of triangles " << k << " of Subdomain " << NbSubDomains << " " << kolor - << endl; + if (verbosity > 5) cout << " Nb of triangles " << k << " of Subdomain " << NbSubDomains << " " << kolor << endl; NbSubDomains++; } } @@ -293,8 +283,7 @@ namespace bamg { for (it = 0; it < nbt; it++) for (int j = 0; j < 3; j++) { tt = triangles[it].TriangleAdj(j); - if ((!tt || triangles[it].Locked(j) || tt->color != triangles[it].color) && - !subdomains[isd = colorT[it]].head) { + if ((!tt || triangles[it].Locked(j) || tt->color != triangles[it].color) && !subdomains[isd = colorT[it]].head) { subdomains[isd].head = triangles + it; subdomains[isd].ref = triangles[it].color; subdomains[isd].sens = j; // hack @@ -323,8 +312,7 @@ namespace bamg { Gh.edges = new GeometricalEdge[nbe]; Gh.NbSubDomains = NbSubDomains; Gh.subdomains = new GeometricalSubDomain[NbSubDomains]; - if (verbosity > 3) - cout << " Nb of vertices = " << Gh.nbv << " Nb of edges = " << Gh.nbe << endl; + if (verbosity > 3) cout << " Nb of vertices = " << Gh.nbv << " Nb of edges = " << Gh.nbe << endl; NbVerticesOnGeomVertex = Gh.nbv; VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex]; NbVerticesOnGeomEdge = 0; @@ -399,8 +387,7 @@ namespace bamg { int j = equiedges[i] / 2; int sens = equiedges[i] % 2; if (i != j && equiedges[i] >= 0) { - if (verbosity > 9) - cout << " Edges Equi " << i << " <=> " << j << " sens = " << sens << endl; + if (verbosity > 9) cout << " Edges Equi " << i << " <=> " << j << " sens = " << sens << endl; if (sens == 0) Gh.edges[i].SetEqui( ); else @@ -436,8 +423,7 @@ namespace bamg { int nbr = 0; for (i = 0; i < Gh.nbv; i++) if (Gh.vertices[i].Required( )) nbr++; - cout << " --11 nb require v in Gh " << nbr << " on " << Gh.nbv << " kreq =" << kreq - << " kkreq=" << kkreq << endl; + cout << " --11 nb require v in Gh " << nbr << " on " << Gh.nbv << " kreq =" << kreq << " kkreq=" << kkreq << endl; } for (i = 0; i < Gh.nbv; i++) @@ -544,8 +530,7 @@ namespace bamg { } return on; } - GeometricalEdge *Geometry::ProjectOnCurve(const Edge &e, Real8 s, Vertex &V, - VertexOnGeom &GV) const { + GeometricalEdge *Geometry::ProjectOnCurve(const Edge &e, Real8 s, Vertex &V, VertexOnGeom &GV) const { Real8 save_s = s; int NbTry = 0; retry: @@ -571,13 +556,11 @@ namespace bamg { // GeometricalEdge * eg0 = e.on,* eg1 = e.on, *eg=NULL; GeometricalEdge *eg0 = on, *eg1 = on; R2 Ag = (R2)(*on)[0], Bg = (R2)(*on)[1], AB = Bg - Ag; - if (NbTry) - cout << " G edge= " << Ag << Bg << endl - << " v edge" << V01 << " v geom " << AB << (V01, AB) << endl; + if (NbTry) cout << " G edge= " << Ag << Bg << endl << " v edge" << V01 << " v geom " << AB << (V01, AB) << endl; int OppositeSens = (V01, AB) < 0; int sens0 = 0, sens1 = 1; if (OppositeSens) s = 1 - s, Exchange(vg0, vg1), Exchange(V0, V1); - // find all the discretisation of the egde + // find all the discretisation of the egde #ifdef DEBUG // we supposee edge on=[Ag,Bg] intersect edge [V0,V1]; // => V0Ag.V0V1 > 0 || V0Bg.V0V1 >0 @@ -589,8 +572,7 @@ namespace bamg { Real8 cos1B = ((Bg - V1), V0V1); if ((cos0A < 0 && cos0B < 0) || (cos1A > 0 && cos1B > 0)) { cerr << " Bug on pointer edge [" << V0 << " , " << V1 << " ] " - << " on geometrical edge " << Number(on) << " = [" << Ag << " , " << Bg << " ] " - << endl; + << " on geometrical edge " << Number(on) << " = [" << Ag << " , " << Bg << " ] " << endl; cerr << cos0A << "> 0 || " << cos0B << " > 0 and "; cerr << cos1A << "< 0 || " << cos1B << " < 0 " << endl; @@ -607,66 +589,48 @@ namespace bamg { // int kkk; // if (NbTry) cout <<"Read (int) to Show Sioux window", cin >> kkk ; if (NbTry) { - cerr << " -- Fatal Error: on the class triangles before call Geometry::ProjectOnCurve" - << endl; + cerr << " -- Fatal Error: on the class triangles before call Geometry::ProjectOnCurve" << endl; cerr << " The mesh of the Geometry is to fine: "; - cerr << " 1) a mesh edge contening more than " << mxe / 2 << " geometrical edges." - << endl; - cerr << " 2) code bug : be sure that we call Triangles::SetVertexFieldOn() before " - << endl; + cerr << " 1) a mesh edge contening more than " << mxe / 2 << " geometrical edges." << endl; + cerr << " 2) code bug : be sure that we call Triangles::SetVertexFieldOn() before " << endl; cerr << " To solve the problem do a coarsening of the geometrical mesh " << endl; - cerr << " or change the constant value of mxe in " << __FILE__ << " line " << MXE__LINE - << "( dangerous way )" << endl; + cerr << " or change the constant value of mxe in " << __FILE__ << " line " << MXE__LINE << "( dangerous way )" << endl; MeshError(222); } NbTry++; goto retry; } GeometricalEdge *tmpge = eg0; - if (NbTry) - cout << "bug: --Edge @" << Number(tmpge) << " = " << Number(eg0) << ":" - << Number(eg0->Adj[0]) << "," << Number(eg0->Adj[1]) << ","; + if (NbTry) cout << "bug: --Edge @" << Number(tmpge) << " = " << Number(eg0) << ":" << Number(eg0->Adj[0]) << "," << Number(eg0->Adj[1]) << ","; ge[--bge] = eg0 = eg0->Adj[sens0]; assert(bge >= 0 && bge <= mxe); sens0 = 1 - (sensge[bge] = tmpge->SensAdj[sens0]); if (NbTry) - cout << "bug: Edge " << Number(eg0) << " " << 1 - sens0 << " S " - << Number((*eg0)[1 - sens0]) << ":" << Number(eg0->Adj[0]) << "," - << Number(eg0->Adj[1]) << "," << endl - << Number(eg0) << (*eg0)[sens0].r << "v = " << Number((*eg1)(sens0)) << " e = " << eg0 - << endl; + cout << "bug: Edge " << Number(eg0) << " " << 1 - sens0 << " S " << Number((*eg0)[1 - sens0]) << ":" << Number(eg0->Adj[0]) << "," << Number(eg0->Adj[1]) << "," << endl + << Number(eg0) << (*eg0)[sens0].r << "v = " << Number((*eg1)(sens0)) << " e = " << eg0 << endl; } - if (NbTry) - cout << Number((GeometricalEdge *)vg1) << " " << Number((GeometricalVertex *)vg1) << endl; + if (NbTry) cout << Number((GeometricalEdge *)vg1) << " " << Number((GeometricalVertex *)vg1) << endl; while (eg1 != (GeometricalEdge *)vg1 && (*eg1)(sens1) != (GeometricalVertex *)vg1) { if (tge >= mxe) { - cerr << " --Fatal Error: on the class triangles before call Geometry::ProjectOnCurve" - << endl; + cerr << " --Fatal Error: on the class triangles before call Geometry::ProjectOnCurve" << endl; NbTry++; if (NbTry < 2) goto retry; cerr << " The mesh of the Geometry is to fine:"; - cerr << " 1) a mesh edge contening more than " << mxe / 2 << " geometrical edges." - << endl; - cerr << " 2) code bug : be sure that we call Triangles::SetVertexFieldOn() before " - << endl; + cerr << " 1) a mesh edge contening more than " << mxe / 2 << " geometrical edges." << endl; + cerr << " 2) code bug : be sure that we call Triangles::SetVertexFieldOn() before " << endl; cerr << " To solve the problem do a coarsening of the geometrical mesh " << endl; - cerr << " or change the constant value of mxe in " << __FILE__ << " line " << MXE__LINE - << "( dangerous way )" << endl; + cerr << " or change the constant value of mxe in " << __FILE__ << " line " << MXE__LINE << "( dangerous way )" << endl; MeshError(223); } GeometricalEdge *tmpge = eg1; - if (NbTry) - cout << "++Edge @" << tmpge << " = " << Number(eg1) << "%" << Number(eg1->Adj[0]) << "," - << Number(eg1->Adj[1]) << ","; + if (NbTry) cout << "++Edge @" << tmpge << " = " << Number(eg1) << "%" << Number(eg1->Adj[0]) << "," << Number(eg1->Adj[1]) << ","; ge[++tge] = eg1 = eg1->Adj[sens1]; sensge[tge] = sens1 = 1 - tmpge->SensAdj[sens1]; assert(tge >= 0 && tge <= mxe); if (NbTry) - cout << " Edge " << Number(eg1) << " " << sens1 << " S " << Number((*eg1)[sens1]) << "%" - << Number(eg1->Adj[0]) << "," << Number(eg1->Adj[1]) << "," << Number(eg1) - << (*eg1)[sens1].r << "v = " << Number((*eg1)(sens1)) << " e = " << Number(eg1) - << endl; + cout << " Edge " << Number(eg1) << " " << sens1 << " S " << Number((*eg1)[sens1]) << "%" << Number(eg1->Adj[0]) << "," << Number(eg1->Adj[1]) << "," << Number(eg1) << (*eg1)[sens1].r + << "v = " << Number((*eg1)(sens1)) << " e = " << Number(eg1) << endl; } if (NbTry) cout << endl; @@ -767,8 +731,7 @@ namespace bamg { { cout << " The duplicate vertex " << endl; for (i = 0; i < nbv; i++) - if (!vertices[i].IsThe( )) - cout << " " << i << " and " << Number(vertices[i].The( )) << endl; + if (!vertices[i].IsThe( )) cout << " " << i << " and " << Number(vertices[i].The( )) << endl; MeshError(102); // throw(ErrorExec("exit",1)); } @@ -781,13 +744,10 @@ namespace bamg { // verification of crack GeometricalEdge &e1 = edges[i]; GeometricalEdge &e2 = *e1.link; - cerr << i << " " << e1[0].The( ) << " " << e2[0].The( ) << " " << e1[1].The( ) << " " - << e2[1].The( ) << endl; - if (!((e1[0].The( ) == e2[0].The( ) && e1[1].The( ) == e2[1].The( )) || - (e1[0].The( ) == e2[1].The( ) && e1[1].The( ) == e2[0].The( )))) { + cerr << i << " " << e1[0].The( ) << " " << e2[0].The( ) << " " << e1[1].The( ) << " " << e2[1].The( ) << endl; + if (!((e1[0].The( ) == e2[0].The( ) && e1[1].The( ) == e2[1].The( )) || (e1[0].The( ) == e2[1].The( ) && e1[1].The( ) == e2[0].The( )))) { err++; - cerr << " Cracked edges with no same vertex " << &e1 - edges << " " << &e2 - edges - << endl; + cerr << " Cracked edges with no same vertex " << &e1 - edges << " " << &e2 - edges << endl; } } if (err) { @@ -797,8 +757,7 @@ namespace bamg { } if (verbosity > 7) for (i = 0; i < nbv; i++) - if (vertices[i].Required( )) - cout << " The geo vertices " << i << " is required" << endl; + if (vertices[i].Required( )) cout << " The geo vertices " << i << " is required" << endl; for (i = 0; i < nbv; i++) hv[i] = -1; // empty list @@ -810,8 +769,7 @@ namespace bamg { MeshError(1); } eangle[i] = atan2(v10.y, v10.x); // angle in [ -Pi,Pi ] - if (verbosity > 9) - cout << " angle edge " << i << " " << eangle[i] * 180 / Pi << v10 << endl; + if (verbosity > 9) cout << " angle edge " << i << " " << eangle[i] * 180 / Pi << v10 << endl; for (jj = 0; jj < 2; jj++) { // generation of list Int4 v = Number(edges[i].v[jj]); ev[k] = hv[v]; @@ -858,23 +816,17 @@ namespace bamg { float angle1 = j1 ? OppositeAngle(eangle[i1]) : eangle[i1]; float angle2 = !j2 ? OppositeAngle(eangle[i2]) : eangle[i2]; float da12 = Abs(angle2 - angle1); - if (verbosity > 9) - cout << " check angle " << i << " " << i1 << " " << i2 << " " << 180 * (da12) / Pi - << " " << 180 * MaximalAngleOfCorner / Pi << vertices[i] << endl; + if (verbosity > 9) cout << " check angle " << i << " " << i1 << " " << i2 << " " << 180 * (da12) / Pi << " " << 180 * MaximalAngleOfCorner / Pi << vertices[i] << endl; if ((da12 >= MaximalAngleOfCorner) && (da12 <= 2 * Pi - MaximalAngleOfCorner)) { vertices[i].SetCorner( ); - if (verbosity > 7) - cout << " The vertex " << i << " is a corner (angle) " << 180 * (da12) / Pi << " " - << 180 * MaximalAngleOfCorner / Pi << endl; + if (verbosity > 7) cout << " The vertex " << i << " is a corner (angle) " << 180 * (da12) / Pi << " " << 180 * MaximalAngleOfCorner / Pi << endl; } // if the ref a changing then is SetRequired(); if (edges[i1].flag != edges[i2].flag || edges[i1].Required( )) { vertices[i].SetRequired( ); - if (verbosity > 7) - cout << " The vertex " << i - << " is Required the flag change (crack or equi, or require)" << endl; + if (verbosity > 7) cout << " The vertex " << i << " is Required the flag change (crack or equi, or require)" << endl; } if (edges[i1].ref != edges[i2].ref) { @@ -885,8 +837,7 @@ namespace bamg { if (ord != 2) { vertices[i].SetCorner( ); - if (verbosity > 7) - cout << " the vertex " << i << " is a corner ordre = " << ord << endl; + if (verbosity > 7) cout << " the vertex " << i << " is a corner ordre = " << ord << endl; } // close the liste around the vertex { @@ -911,8 +862,7 @@ namespace bamg { } edges[i1].Adj[j1] = edges + i; edges[i1].SensAdj[j1] = jj; - if (verbosity > 10) - cout << " edges. Adj " << i1 << " " << j1 << " <--- " << i << " " << jj << endl; + if (verbosity > 10) cout << " edges. Adj " << i1 << " " << j1 << " <--- " << i << " " << jj << endl; } // generation of all the tangente @@ -954,8 +904,7 @@ namespace bamg { if (verbosity > 7) for (i = 0; i < nbv; i++) - if (vertices[i].Required( )) - cout << " The geo vertices " << i << " is required " << endl; + if (vertices[i].Required( )) cout << " The geo vertices " << i << " is required " << endl; for (int step = 0; step < 2; step++) { for (i = 0; i < nbe; i++) edges[i].SetUnMark( ); @@ -963,8 +912,7 @@ namespace bamg { NbOfCurves = 0; Int4 nbgem = 0; for (int level = 0; level < 2 && nbgem != nbe; level++) - for (jj = 0; jj < 2; - jj++) // change the sens of loop to keep interior normal in general.. feb. 2017 + for (jj = 0; jj < 2; jj++) // change the sens of loop to keep interior normal in general.. feb. 2017 for (i = 0; i < nbe; i++) // for(jj=0;jj<2;jj++) // old code { @@ -996,8 +944,7 @@ namespace bamg { e = e->Adj[k1]; // next edge } // for(;;) - if (verbosity > 10 && curves == 0) - cout << NbOfCurves << " curve : nb edges= " << nee << endl; + if (verbosity > 10 && curves == 0) cout << NbOfCurves << " curve : nb edges= " << nee << endl; NbOfCurves++; if (level) { if (verbosity > 4) @@ -1045,22 +992,17 @@ namespace bamg { if (reverse) curves[i].Reverse( ); if (verbosity > 9) { cout << " -- curve equi /reverse=" << reverse << " sens: " << sens << endl; - cout << " curve " << i << ": " << Number(be) << " <=> " << Number(eqbe) << " " - << be->Equi( ) << be->ReverseEqui( ) << " --> " << Number(ee) << " <=>" - << Number(eqee) << " " << ee->Equi( ) << ee->ReverseEqui( ) << endl; - cout << " curve eq: " << nc << ": " << Number(bee) << " " << bee->Equi( ) - << bee->ReverseEqui( ) << " --> " << Number(eee) << " !" << eee->Equi( ) - << eee->ReverseEqui( ) << endl; + cout << " curve " << i << ": " << Number(be) << " <=> " << Number(eqbe) << " " << be->Equi( ) << be->ReverseEqui( ) << " --> " << Number(ee) << " <=>" << Number(eqee) << " " + << ee->Equi( ) << ee->ReverseEqui( ) << endl; + cout << " curve eq: " << nc << ": " << Number(bee) << " " << bee->Equi( ) << bee->ReverseEqui( ) << " --> " << Number(eee) << " !" << eee->Equi( ) << eee->ReverseEqui( ) << endl; } } } - if (verbosity > 3) - cout << " End ReadGeometry: Number of curves in geometry is " << NbOfCurves << endl; + if (verbosity > 3) cout << " End ReadGeometry: Number of curves in geometry is " << NbOfCurves << endl; if (verbosity > 9) for (int i = 0; i < NbOfCurves; i++) { - cout << " Curve " << i << " begin e=" << Number(curves[i].be) << " k=" << curves[i].kb - << " end e= " << Number(curves[i].ee) << " k=" << curves[i].ke << endl; + cout << " Curve " << i << " begin e=" << Number(curves[i].be) << " k=" << curves[i].kb << " end e= " << Number(curves[i].ee) << " k=" << curves[i].ke << endl; } delete[] ev; delete[] hv; diff --git a/src/bamglib/MeshQuad.cpp b/src/bamglib/MeshQuad.cpp index 7d20e7dbb..16307bdc7 100644 --- a/src/bamglib/MeshQuad.cpp +++ b/src/bamglib/MeshQuad.cpp @@ -55,7 +55,7 @@ namespace bamg { #ifdef __MWERKS__ #pragma global_optimizer on #pragma optimization_level 1 -//#pragma inline_depth 0 +// #pragma inline_depth 0 #endif class DoubleAndInt4 { @@ -90,7 +90,7 @@ namespace bamg { if (j > r) { c[i] = crit; break; - } // L8 -> G2 + } // L8 -> G2 if ((j < r) && (c[j] < c[j + 1])) j++; // L5 if (crit < c[j]) c[i] = c[j]; // L6+1 G4 @@ -136,8 +136,7 @@ namespace bamg { return 1.0 - Max(Max(Abs(cosDAB), Abs(cosABC)), Max(Abs(cosBCD), Abs(cosCDA))); } - GeometricalEdge *Triangles::ProjectOnCurve(Edge &BhAB, Vertex &vA, Vertex &vB, Real8 theta, - Vertex &R, VertexOnEdge &BR, VertexOnGeom &GR) + GeometricalEdge *Triangles::ProjectOnCurve(Edge &BhAB, Vertex &vA, Vertex &vB, Real8 theta, Vertex &R, VertexOnEdge &BR, VertexOnGeom &GR) { void *pA = 0, *pB = 0; @@ -176,10 +175,10 @@ namespace bamg { // be careful the back ground edge e is on same geom edge // of the initiale edge def by the 2 vertex A B; assert(e >= BTh.edges && e < BTh.edges + BTh.nbe); // Is a background Mesh; - // walk on BTh edge - // assert(0 /* not finish ProjectOnCurve with BackGround Mesh*/); - // 1 first find a back ground edge contening the vertex A - // 2 walk n back gound boundary to find the final vertex B + // walk on BTh edge + // assert(0 /* not finish ProjectOnCurve with BackGround Mesh*/); + // 1 first find a back ground edge contening the vertex A + // 2 walk n back gound boundary to find the final vertex B #ifdef DEBUG // we suppose if the vertex A is on a background edge and @@ -229,10 +228,8 @@ namespace bamg { // we suppose take the curve's abcisse // cout << kkk << " e = " << BTh.Number(e) << " v0= " // << BTh.Number(v0) << " v1 = " << BTh.Number((*e)[sens]) << endl; - for (eee = e, iii = sens, te0 = tA; - eee && (((void *)eee) != pB) && ((void *)(v1 = &((*eee)[iii]))) != pB; - neee = eee->adj[iii], iii = 1 - neee->Intersection(*eee), eee = neee, v0 = v1, - te0 = 1 - iii) { + for (eee = e, iii = sens, te0 = tA; eee && (((void *)eee) != pB) && ((void *)(v1 = &((*eee)[iii]))) != pB; + neee = eee->adj[iii], iii = 1 - neee->Intersection(*eee), eee = neee, v0 = v1, te0 = 1 - iii) { // cout << kkk << " eee = " << BTh.Number(eee) << " v0= " // << BTh.Number(v0) << " v1 = " << BTh.Number(v1) << endl; @@ -263,9 +260,8 @@ namespace bamg { Real8 dp = LengthInterpole(v0->m, v1->m, (R2)*v1 - (R2)*v0); lg += dp; abscisse = lg * theta; - if (abscisse <= lg && - abscisse >= lg0) // small optimisation we know the lenght because end - { // ok we find the geom edge + if (abscisse <= lg && abscisse >= lg0) // small optimisation we know the lenght because end + { // ok we find the geom edge Real8 sss = (abscisse - lg0) / dp; Real8 thetab = te0 * (1 - sss) + sss * tB; assert(thetab >= 0 && thetab <= 1); @@ -290,10 +286,7 @@ namespace bamg { void Triangles::MakeQuadrangles(double costheta) { if (verbosity > 2) cout << " -- MakeQuadrangles costheta = " << costheta << endl; - if (verbosity > 5) - cout << " (in) Nb of Quadrilaterals = " << NbOfQuad - << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 - << " Nb of outside triangles = " << NbOutT << endl; + if (verbosity > 5) cout << " (in) Nb of Quadrilaterals = " << NbOfQuad << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 << " Nb of outside triangles = " << NbOutT << endl; if (costheta > 1) { if (verbosity > 5) cout << " do nothing costheta >1 " << endl; @@ -322,9 +315,7 @@ namespace bamg { } NbOfQuad = kk; if (verbosity > 2) { - cout << " (out) Nb of Quadrilaterals = " << NbOfQuad - << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 - << " Nb of outside triangles = " << NbOutT << endl; + cout << " (out) Nb of Quadrilaterals = " << NbOfQuad << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 << " Nb of outside triangles = " << NbOutT << endl; } delete[] qq; #ifdef DRAWING2 @@ -343,14 +334,9 @@ namespace bamg { int Triangles::SplitElement(int choice) { Direction NoDirOfSearch; const int withBackground = &BTh != this; - if (verbosity > 2) - cout << " -- SplitElement " << (choice ? " Q->4Q and T->4T " : " Q->4Q or T->3Q ") << endl; + if (verbosity > 2) cout << " -- SplitElement " << (choice ? " Q->4Q and T->4T " : " Q->4Q or T->3Q ") << endl; ; - if (verbosity > 5) - cout << endl - << " (in) Nb of Quadrilaterals = " << NbOfQuad - << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 - << " Nb of outside triangles = " << NbOutT << endl; + if (verbosity > 5) cout << endl << " (in) Nb of Quadrilaterals = " << NbOfQuad << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 << " Nb of outside triangles = " << NbOutT << endl; ReNumberingTheTriangleBySubDomain( ); #ifdef DRAWING2 @@ -395,13 +381,9 @@ namespace bamg { // do allocation for pointeur to the geometry and background VertexOnGeom *newVerticesOnGeomEdge = new VertexOnGeom[newNbVerticesOnGeomEdge]; - VertexOnEdge *newVertexOnBThEdge = - newNbVertexOnBThEdge ? new VertexOnEdge[newNbVertexOnBThEdge] : 0; - if (NbVerticesOnGeomEdge) - memcpy(newVerticesOnGeomEdge, VerticesOnGeomEdge, - sizeof(VertexOnGeom) * NbVerticesOnGeomEdge); - if (NbVertexOnBThEdge) - memcpy(newVertexOnBThEdge, VertexOnBThEdge, sizeof(VertexOnEdge) * NbVertexOnBThEdge); + VertexOnEdge *newVertexOnBThEdge = newNbVertexOnBThEdge ? new VertexOnEdge[newNbVertexOnBThEdge] : 0; + if (NbVerticesOnGeomEdge) memcpy(newVerticesOnGeomEdge, VerticesOnGeomEdge, sizeof(VertexOnGeom) * NbVerticesOnGeomEdge); + if (NbVertexOnBThEdge) memcpy(newVertexOnBThEdge, VertexOnBThEdge, sizeof(VertexOnEdge) * NbVertexOnBThEdge); Edge *newedges = new Edge[newnbe]; // memcpy(newedges,edges,sizeof(Edge)*nbe); SetOfEdges4 *edge4 = new SetOfEdges4(nbe, nbv); @@ -440,8 +422,7 @@ namespace bamg { // the first PB is to now a background edge between the 2 vertices assert(edgesGtoB); // cout << " ie = " << ie <<" v0 = " << Number(newedges[ie][0]) << endl; - ong = ProjectOnCurve(*edgesGtoB[Gh.Number(edges[i].on)], edges[i][0], edges[i][1], 0.5, - vertices[k], newVertexOnBThEdge[kvb], newVerticesOnGeomEdge[kvg++]); + ong = ProjectOnCurve(*edgesGtoB[Gh.Number(edges[i].on)], edges[i][0], edges[i][1], 0.5, vertices[k], newVertexOnBThEdge[kvb], newVerticesOnGeomEdge[kvg++]); vertices[k].ReferenceNumber = edges[i].ref; vertices[k].DirOfSearch = NoDirOfSearch; ; @@ -538,22 +519,14 @@ namespace bamg { Vertex &A = vertices[ks]; Real8 aa = 0, bb = 0, cc = 0, dd = 0; if ((dd = Area2(v0.r, v1.r, A.r)) >= 0) { // warning PB roundoff error - if (t.link && ((aa = Area2(A.r, t[1].r, t[2].r)) < 0.0 || - (bb = Area2(t[0].r, A.r, t[2].r)) < 0.0 || - (cc = Area2(t[0].r, t[1].r, A.r)) < 0.0)) - ferr++, cerr << " Error : " << ke + nbvold << " not in triangle " << i - << " In=" << !!t.link << " " << aa << " " << bb << " " << cc << " " << dd - << endl; + if (t.link && ((aa = Area2(A.r, t[1].r, t[2].r)) < 0.0 || (bb = Area2(t[0].r, A.r, t[2].r)) < 0.0 || (cc = Area2(t[0].r, t[1].r, A.r)) < 0.0)) + ferr++, cerr << " Error : " << ke + nbvold << " not in triangle " << i << " In=" << !!t.link << " " << aa << " " << bb << " " << cc << " " << dd << endl; } else { - if (tt.link && ((aa = Area2(A.r, tt[1].r, tt[2].r)) < 0 || - (bb = Area2(tt[0].r, A.r, tt[2].r)) < 0 || - (cc = Area2(tt[0].r, tt[1].r, A.r)) < 0)) - ferr++, cerr << " Warning : " << ke + nbvold << " not in triangle " << ii - << " In=" << !!tt.link << " " << aa << " " << bb << " " << cc << " " - << dd << endl; + if (tt.link && ((aa = Area2(A.r, tt[1].r, tt[2].r)) < 0 || (bb = Area2(tt[0].r, A.r, tt[2].r)) < 0 || (cc = Area2(tt[0].r, tt[1].r, A.r)) < 0)) + ferr++, cerr << " Warning : " << ke + nbvold << " not in triangle " << ii << " In=" << !!tt.link << " " << aa << " " << bb << " " << cc << " " << dd << endl; } } } @@ -606,7 +579,7 @@ namespace bamg { else cerr << endl << " Bug " << i << " " << j << " t=" << t << endl; - } // ke<0 + } // ke<0 else { // ke >=0 kedge[3 * i + j] = nbvold + ke; kkk[nbsplitedge++] = j; // previously splited @@ -863,10 +836,7 @@ namespace bamg { for (i = 0; i < nbt; i++) triangles[i].check( ); #endif - if (verbosity > 2) - cout << " (out) Nb of Quadrilaterals = " << NbOfQuad - << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 - << " Nb of outside triangles = " << NbOutT << endl; + if (verbosity > 2) cout << " (out) Nb of Quadrilaterals = " << NbOfQuad << " Nb Of Triangles = " << nbt - NbOutT - NbOfQuad * 2 << " Nb of outside triangles = " << NbOutT << endl; CurrentTh = OCurrentTh; return 0; // ok diff --git a/src/bamglib/MeshRead.cpp b/src/bamglib/MeshRead.cpp index 1a7ea7ea3..b1d8de7b3 100644 --- a/src/bamglib/MeshRead.cpp +++ b/src/bamglib/MeshRead.cpp @@ -36,7 +36,7 @@ #include "SetOfE4.h" #ifdef __MWERKS__ #pragma optimization_level 2 -//#pragma inline_depth 1 +// #pragma inline_depth 1 #endif #ifdef DRAWING1 @@ -55,8 +55,7 @@ namespace bamg { Int4 hvertices = 0; Int4 ifgeom = 0; Metric M1(1); - if (verbosity > 1) - cout << " -- ReadMesh " << f_in.CurrentFile << " Version = " << Version << endl; + if (verbosity > 1) cout << " -- ReadMesh " << f_in.CurrentFile << " Version = " << Version << endl; int field = 0; int showfield = 0; while (f_in.cm( )) { @@ -88,8 +87,7 @@ namespace bamg { found = fg.find_last_of("/\\"); if (found != string::npos) // seaprateur fg = dir + fg.substr(found + 1); - if (verbosity > 4) - cout << " -- read geometry in " << fg << " not in " << fgeom << " " << endl; + if (verbosity > 4) cout << " -- read geometry in " << fg << " not in " << fgeom << " " << endl; Gh.ReadGeometry(fg.c_str( )); } else { // include geometry @@ -134,15 +132,11 @@ namespace bamg { nbt = 0; } else if (!strcmp(fieldname, "Triangles")) { if (dim != 2) cerr << "ReadMesh: Dimension <> 2" << endl, f_in.ShowIoErr(0); - if (!vertices || !triangles || !nbv) - cerr << "ReadMesh:Triangles before Vertices" << endl, f_in.ShowIoErr(0); + if (!vertices || !triangles || !nbv) cerr << "ReadMesh:Triangles before Vertices" << endl, f_in.ShowIoErr(0); int NbOfTria; f_in >> NbOfTria; if (verbosity > 3) cout << " NbOfTria = " << NbOfTria << endl; - if (nbt + NbOfTria >= nbtx) - cerr << "ReadMesh: We must have 2*NbOfQuad + NbOfTria = " << nbt + NbOfTria - << " < 2*nbv-2 =" << nbtx << endl, - f_in.ShowIoErr(0); + if (nbt + NbOfTria >= nbtx) cerr << "ReadMesh: We must have 2*NbOfQuad + NbOfTria = " << nbt + NbOfTria << " < 2*nbv-2 =" << nbtx << endl, f_in.ShowIoErr(0); // begintria = nbt; for (i = 0; i < NbOfTria; i++) { Int4 i1, i2, i3, iref; @@ -173,14 +167,10 @@ namespace bamg { } else if (!strcmp(fieldname, "Quadrilaterals")) { if (dim != 2) cerr << "ReadMesh: Dimension <> 2" << endl, f_in.ShowIoErr(0); - if (!vertices || !triangles || !nbv) - cerr << "ReadMesh:Quadrilaterals before Vertices" << endl, f_in.ShowIoErr(0); + if (!vertices || !triangles || !nbv) cerr << "ReadMesh:Quadrilaterals before Vertices" << endl, f_in.ShowIoErr(0); f_in >> NbOfQuad; if (verbosity > 3) cout << " NbOfQuad= " << NbOfQuad << endl; - if (nbt + 2 * NbOfQuad >= nbtx) - cerr << "ReadMesh: We must have 2*NbOfQuad + NbOfTria = " << nbt + 2 * NbOfQuad - << " < 2*nbv-2 =" << nbtx << endl, - f_in.ShowIoErr(0); + if (nbt + 2 * NbOfQuad >= nbtx) cerr << "ReadMesh: We must have 2*NbOfQuad + NbOfTria = " << nbt + 2 * NbOfQuad << " < 2*nbv-2 =" << nbtx << endl, f_in.ShowIoErr(0); // beginquad=nbt; for (i = 0; i < NbOfQuad; i++) { Int4 i1, i2, i3, i4, iref; @@ -197,14 +187,10 @@ namespace bamg { // endquad=nbt; } else if (!strcmp(fieldname, "VertexOnGeometricVertex")) { f_in >> NbVerticesOnGeomVertex; - if (verbosity > 5) - cout << " NbVerticesOnGeomVertex = " << NbVerticesOnGeomVertex << endl - << " Gh.vertices " << Gh.vertices << endl; + if (verbosity > 5) cout << " NbVerticesOnGeomVertex = " << NbVerticesOnGeomVertex << endl << " Gh.vertices " << Gh.vertices << endl; if (NbVerticesOnGeomVertex) { VerticesOnGeomVertex = new VertexOnGeom[NbVerticesOnGeomVertex]; - if (verbosity > 7) - cout << " VerticesOnGeomVertex = " << VerticesOnGeomVertex << endl - << " Gh.vertices " << Gh.vertices << endl; + if (verbosity > 7) cout << " VerticesOnGeomVertex = " << VerticesOnGeomVertex << endl << " Gh.vertices " << Gh.vertices << endl; assert(VerticesOnGeomVertex); for (Int4 i0 = 0; i0 < NbVerticesOnGeomVertex; i0++) { Int4 i1, i2; @@ -231,8 +217,7 @@ namespace bamg { Int4 i, j, i1, i2; f_in >> nbe; edges = new Edge[nbe]; - if (verbosity > 5) - cout << " Record Edges: Nb of Edge " << nbe << " edges " << edges << endl; + if (verbosity > 5) cout << " Record Edges: Nb of Edge " << nbe << " edges " << edges << endl; assert(edges); Real8* len = 0; if (!hvertices) { @@ -341,17 +326,13 @@ namespace bamg { } else { // unkown field field = ++showfield; if (showfield == 1) // just to show one time - if (verbosity > 5) - cout << " Warning we skip the field " << fieldname << " at line " << f_in.LineNumber - << endl; + if (verbosity > 5) cout << " Warning we skip the field " << fieldname << " at line " << f_in.LineNumber << endl; } showfield = field; // just to show one time } if (ifgeom == 0) { - if (verbosity) - cout << " ## Warning: Mesh without geometry we construct a geometry (theta =" - << cutoffradian * 180 / Pi << " degres )" << endl; + if (verbosity) cout << " ## Warning: Mesh without geometry we construct a geometry (theta =" << cutoffradian * 180 / Pi << " degres )" << endl; ConsGeometry(cutoffradian); Gh.AfterRead( ); } @@ -380,9 +361,7 @@ namespace bamg { } f_in.eol( ); // - for (i = 0; i < nbv; i++) - f_in >> vertices[i].r.x >> vertices[i].r.y, vertices[i].m = M1, - vertices[i].DirOfSearch = NoDirOfSearch; + for (i = 0; i < nbv; i++) f_in >> vertices[i].r.x >> vertices[i].r.y, vertices[i].m = M1, vertices[i].DirOfSearch = NoDirOfSearch; f_in.eol( ); // @@ -467,15 +446,13 @@ namespace bamg { cout << " where in record " << f_in.where( ) << " " << strcmp("NOPO", typesd) << endl; cerr << " not a nopo file but `" << typesd << "`" << " len = " << strlen(typesd) << endl; - cerr << (int)typesd[0] << (int)typesd[1] << (int)typesd[2] << (int)typesd[3] << (int)typesd[4] - << endl; + cerr << (int)typesd[0] << (int)typesd[1] << (int)typesd[2] << (int)typesd[3] << (int)typesd[4] << endl; cout << " nomcre :" << nomcre << endl; cout << " date :" << date << endl; cout << " titre :" << titre << endl; MeshError(112); } - if (verbosity > 2) - cout << " nb de tableau associe : " << ntacm << " niveau =" << niveau << endl; + if (verbosity > 2) cout << " nb de tableau associe : " << ntacm << " niveau =" << niveau << endl; for (i = 0; i < ntacm; i++) f_in.Record( ); @@ -492,9 +469,7 @@ namespace bamg { Int4 np = nop2[21]; // Int4 nef = nop2[13]; Metric M1(1); - if (verbosity > 2) - cout << " ndim = " << ndim << " ncopnp= " << ncopnp << " ne = " << ne - << " ntri = " << ntria << " nquad = " << nquad << " np = " << np << endl; + if (verbosity > 2) cout << " ndim = " << ndim << " ncopnp= " << ncopnp << " ne = " << ne << " ntri = " << ntria << " nquad = " << nquad << " np = " << np << endl; nbv = np; nbt = 2 * nquad + ntria; if (ne != nquad + ntria || ndim != 2 || ncopnp != 1) { @@ -632,8 +607,7 @@ namespace bamg { Int4 i, ne, nt, nq; f_in.cm( ) >> nbv >> ne >> nt >> nq; - if (verbosity > 3) - cout << " nbv = " << nbv << " nbtra = " << nt << " nbquad = " << nq << endl; + if (verbosity > 3) cout << " nbv = " << nbv << " nbtra = " << nt << " nbquad = " << nq << endl; nbt = nt + 2 * nq; nbvx = nbv; @@ -710,7 +684,7 @@ namespace bamg { f_in >> i1 >> i2 >> r; edges[i].v[0] = vertices + i1 - 1; edges[i].v[1] = vertices + i2 - 1; - if(verbosity>199) cout << " Read_msh egde: "<< i1 << " "<< i2 << " "<< r << endl; + if (verbosity > 199) cout << " Read_msh egde: " << i1 << " " << i2 << " " << r << endl; edges[i].adj[0] = 0; edges[i].adj[1] = 0; edges[i].ref = r; @@ -760,8 +734,7 @@ namespace bamg { // MeshError(888); } - Triangles::Triangles(const char* filename, Real8 cutoffradian) - : Gh(*(new Geometry( ))), BTh(*this) { + Triangles::Triangles(const char* filename, Real8 cutoffradian) : Gh(*(new Geometry( ))), BTh(*this) { #ifdef DRAWING1 if (!withrgraphique) { initgraphique( ); @@ -909,8 +882,7 @@ namespace bamg { nbvx = nbv; vertices = new GeometricalVertex[nbvx]; - if (verbosity > 5) - cout << " Geom Record Vertices nbv = " << nbv << "vertices = " << vertices << endl; + if (verbosity > 5) cout << " Geom Record Vertices nbv = " << nbv << "vertices = " << vertices << endl; assert(nbvx >= nbv); nbiv = nbv; for (i = 0; i < nbv; i++) { @@ -942,15 +914,12 @@ namespace bamg { coefIcoor = (MaxICoor) / (Max(pmax.x - pmin.x, pmax.y - pmin.y)); assert(coefIcoor > 0); if (verbosity > 5) { - cout << " Geom: min=" << pmin << "max =" << pmax << " hmin = " << MinimalHmin( ) - << endl; + cout << " Geom: min=" << pmin << "max =" << pmax << " hmin = " << MinimalHmin( ) << endl; } - } else if (!strcmp(fieldname, "MaximalAngleOfCorner") || - !strcmp(fieldname, "AngleOfCornerBound")) { + } else if (!strcmp(fieldname, "MaximalAngleOfCorner") || !strcmp(fieldname, "AngleOfCornerBound")) { f_in >> MaximalAngleOfCorner; - if (verbosity > 5) - cout << " Geom Record MaximalAngleOfCorner " << MaximalAngleOfCorner << endl; + if (verbosity > 5) cout << " Geom Record MaximalAngleOfCorner " << MaximalAngleOfCorner << endl; MaximalAngleOfCorner *= Pi / 180; } else if (!strcmp(fieldname, "Edges")) { if (nbv <= 0) { @@ -1076,12 +1045,10 @@ namespace bamg { } else { // unkown field field = ++showfield; if (showfield == 1) // just to show one time - if (verbosity > 3) - cout << " Warning we skip the field " << fieldname << " at line " << f_in.LineNumber - << endl; + if (verbosity > 3) cout << " Warning we skip the field " << fieldname << " at line " << f_in.LineNumber << endl; } showfield = field; // just to show one time - } // while !eof() + } // while !eof() // generation de la geometrie // 1 construction des aretes // construire des aretes en chaque sommets diff --git a/src/bamglib/MeshWrite.cpp b/src/bamglib/MeshWrite.cpp index 0831df4ac..205f73ea7 100644 --- a/src/bamglib/MeshWrite.cpp +++ b/src/bamglib/MeshWrite.cpp @@ -64,7 +64,7 @@ namespace bamg { const char *gsuffix = ".gmsh"; int ls = 0; int lll = strlen(filename); - int bin=0; + int bin = 0; if (type == AutoMesh) { type = BDMesh; if (!strcmp(filename + lll - (ls = 7), ".am_fmt")) @@ -72,14 +72,14 @@ namespace bamg { else if (!strcmp(filename + lll - (ls = 6), ".amdba")) type = amdbaMesh; else if (!strcmp(filename + lll - (ls = 3), ".am")) - bin=1,type = amMesh; + bin = 1, type = amMesh; else if (!strcmp(filename + lll - (ls = 5), ".nopo")) - bin=1,type = NOPOMesh; + bin = 1, type = NOPOMesh; else if (!strcmp(filename + lll - (ls = 4), ".msh")) type = mshMesh; //-----------------------------ajout format hdf5-----------------------------// else if (!strcmp(filename + lll - (ls = 3), ".h5")) - bin=1,type = hdf5Mesh; + bin = 1, type = hdf5Mesh; //-----------------------------ajout format hdf5-----------------------------// else if (!strcmp(filename + lll - (ls = 4), ".ftq")) type = ftqMesh; @@ -88,7 +88,7 @@ namespace bamg { else if (!strcmp(filename + lll - (ls = 6), ".AMDBA")) type = amdbaMesh; else if (!strcmp(filename + lll - (ls = 3), ".AM")) - bin=1,type = amMesh; + bin = 1, type = amMesh; else if (!strcmp(filename + lll - (ls = 5), ".NOPO")) type = NOPOMesh; else if (!strcmp(filename + lll - (ls = 4), ".MSH")) @@ -99,7 +99,7 @@ namespace bamg { ls = 0; } if (verbosity > 1) { - cout << " -- Writing the file " << filename << " binary:" << bin <<" of type " ; + cout << " -- Writing the file " << filename << " binary:" << bin << " of type "; switch (type) { case BDMesh: cout << " BD Mesh "; @@ -128,8 +128,7 @@ namespace bamg { break; //-----------------------------ajout format hdf5-----------------------------// default: - cerr << endl - << " Unknown type mesh file " << (int)type << " for Writing " << filename << endl; + cerr << endl << " Unknown type mesh file " << (int)type << " for Writing " << filename << endl; MeshError(1); } Int4 NbOfTria = nbt - 2 * NbOfQuad - NbOutT; @@ -138,10 +137,10 @@ namespace bamg { if (nbe) cout << " NbOfRefEdge = " << nbe; cout << endl; } - ios_base::openmode mode = ios_base::out; - if(bin) mode |=ios_base::binary; - if(verbosity>9) cout << " mode = " << mode << " bin: " << ios_base::binary << " out: s" << ios_base::out << endl; - ofstream f(filename,mode /*,ios::trunc*/); + ios_base::openmode mode = ios_base::out; + if (bin) mode |= ios_base::binary; + if (verbosity > 9) cout << " mode = " << mode << " bin: " << ios_base::binary << " out: s" << ios_base::out << endl; + ofstream f(filename, mode /*,ios::trunc*/); f.precision(17); if (f) switch (type) { @@ -154,7 +153,7 @@ namespace bamg { strcpy(Gh.name + lll - ls, gsuffix + 1); else strcpy(Gh.name + lll - ls, gsuffix); - if(verbosity > 1) cout << " write geo in " << Gh.name << endl; + if (verbosity > 1) cout << " write geo in " << Gh.name << endl; ofstream f(Gh.name); f << Gh; Gh.OnDisk = true; @@ -195,8 +194,7 @@ namespace bamg { } if (verbosity > 5) cout << "end write" << endl; } - void Triangles::Write_nop5(OFortranUnFormattedFile *f, Int4 &lnop5, Int4 &nef, Int4 &lgpdn, - Int4 ndsr) const { + void Triangles::Write_nop5(OFortranUnFormattedFile *f, Int4 &lnop5, Int4 &nef, Int4 &lgpdn, Int4 ndsr) const { ndsr = 0; Int4 *reft = new Int4[nbt]; // Int4 nbInT = ; @@ -409,10 +407,8 @@ namespace bamg { cout << " nef = " << nef << endl; cout << " np = " << nbv << endl; cout << " ndsr = " << ndsr << endl; - f << Int4(27) << Int4(2) << ndsr << ndsd << Int4(1) << nbtria + nbquad << Int4(0) << Int4(0) - << nbtria << nbquad << Int4(0) << Int4(0) << Int4(0) << Int4(0) << nef << Int4(nbv) << Int4(0) - << Int4(0) << Int4(0) << Int4(0) << Int4(0) << Int4(0) << nbv << Int4(2) << lpgdn << Int4(0) - << lnop5 << Int4(1); + f << Int4(27) << Int4(2) << ndsr << ndsd << Int4(1) << nbtria + nbquad << Int4(0) << Int4(0) << nbtria << nbquad << Int4(0) << Int4(0) << Int4(0) << Int4(0) << nef << Int4(nbv) << Int4(0) + << Int4(0) << Int4(0) << Int4(0) << Int4(0) << Int4(0) << nbv << Int4(2) << lpgdn << Int4(0) << lnop5 << Int4(1); f.Record( ); f << (Int4)2 * nbv; for (i = 0; i < nbv; i++) f << (float)vertices[i].r.x << (float)vertices[i].r.y; @@ -491,20 +487,17 @@ namespace bamg { if (reft[i] < 0) continue; ta = t.Quadrangle(v0, v1, v2, v3); if (!ta) { // a triangles - f << "3 " << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " - << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; + f << "3 " << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; k++; } if (&t < ta) { k++; - f << "4 " << Number(v0) + 1 << " " << Number(v1) + 1 << " " << Number(v2) + 1 << " " - << Number(v3) + 1 << " " << subdomains[reft[i]].ref << endl; + f << "4 " << Number(v0) + 1 << " " << Number(v1) + 1 << " " << Number(v2) + 1 << " " << Number(v3) + 1 << " " << subdomains[reft[i]].ref << endl; } } assert(k == nele); - for (i = 0; i < nbv; i++) - f << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) << endl; + for (i = 0; i < nbv; i++) f << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) << endl; delete[] reft; } void Triangles::Write_msh(ostream &f) const { @@ -515,16 +508,12 @@ namespace bamg { f.precision(17); f << nbv << " " << nbInT << " " << nbe << endl; - for (i = 0; i < nbv; i++) - f << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) << endl; + for (i = 0; i < nbv; i++) f << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) << endl; for (i = 0; i < nbt; i++) - if (reft[i] >= 0) - f << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " - << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; + if (reft[i] >= 0) f << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; - for (i = 0; i < nbe; i++) - f << Number(edges[i][0]) + 1 << " " << Number(edges[i][1]) + 1 << " " << edges[i].ref << endl; + for (i = 0; i < nbe; i++) f << Number(edges[i][0]) + 1 << " " << Number(edges[i][1]) + 1 << " " << edges[i].ref << endl; delete[] reft; } @@ -537,10 +526,10 @@ namespace bamg { Int4 *reft = new Int4[nbt]; Int4 nbInT = ConsRefTriangle(reft); float coord[nbv][2]; - //int Connectivity[nbInT][3]; - - typedef int int3[3]; - int3 *Connectivity =new int3[nbInT]; + // int Connectivity[nbInT][3]; + + typedef int int3[3]; + int3 *Connectivity = new int3[nbInT]; for (i = 0; i < nbv; i++) { coord[i][0] = vertices[i].r.x; @@ -563,7 +552,7 @@ namespace bamg { WriteXdmf *XdmfMeshFile2D = new WriteXdmf(f, nbInT, nbv); XdmfMeshFile2D->WriteXdmfMeshFile2D( ); delete XdmfMeshFile2D; - delete [] Connectivity; + delete[] Connectivity; delete[] reft; #else @@ -581,14 +570,10 @@ namespace bamg { Int4 nbInT = ConsRefTriangle(reft); f << nbv << " " << nbInT << endl; cout.precision(17); - for (i = 0; i < nbv; i++) - f << i + 1 << " " << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) - << endl; + for (i = 0; i < nbv; i++) f << i + 1 << " " << vertices[i].r.x << " " << vertices[i].r.y << " " << vertices[i].ref( ) << endl; j = 1; for (i = 0; i < nbt; i++) - if (reft[i] >= 0) - f << j++ << " " << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " - << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; + if (reft[i] >= 0) f << j++ << " " << Number(triangles[i][0]) + 1 << " " << Number(triangles[i][1]) + 1 << " " << Number(triangles[i][2]) + 1 << " " << subdomains[reft[i]].ref << endl; f << endl; delete[] reft; } @@ -620,8 +605,7 @@ namespace bamg { Triangle &t = Th.triangles[i]; if (reft[i] >= 0 && !(t.Hidden(0) || t.Hidden(1) || t.Hidden(2))) { k--; - f << Th.Number(t[0]) + 1 << " " << Th.Number(t[1]) + 1 << " " << Th.Number(t[2]) + 1 - << " " << Th.subdomains[reft[i]].ref << endl; + f << Th.Number(t[0]) + 1 << " " << Th.Number(t[1]) + 1 << " " << Th.Number(t[2]) + 1 << " " << Th.subdomains[reft[i]].ref << endl; reft[i] = ++num; } } @@ -636,8 +620,7 @@ namespace bamg { if (reft[i] < 0) continue; if ((ta = t.Quadrangle(v0, v1, v2, v3)) != 0 && &t < ta) { k--; - f << Th.Number(v0) + 1 << " " << Th.Number(v1) + 1 << " " << Th.Number(v2) + 1 << " " - << Th.Number(v3) + 1 << " " << Th.subdomains[reft[i]].ref << endl; + f << Th.Number(v0) + 1 << " " << Th.Number(v1) + 1 << " " << Th.Number(v2) + 1 << " " << Th.Number(v3) + 1 << " " << Th.subdomains[reft[i]].ref << endl; reft[i] = ++num; reft[Number(ta)] = num; } @@ -664,10 +647,8 @@ namespace bamg { WriteStr(f, Th.Gh.name), f << endl; else { // empty file name -> geom in same file f << "\"\"" << endl << endl; - f << "# BEGIN of the include geometry file because geometry is not on the disk" << Th.Gh - << endl; - f << "End" << endl - << "# END of the include geometry file because geometry is not on the disk" << endl; + f << "# BEGIN of the include geometry file because geometry is not on the disk" << Th.Gh << endl; + f << "End" << endl << "# END of the include geometry file because geometry is not on the disk" << endl; } } { @@ -700,15 +681,12 @@ namespace bamg { Th.WriteElements(f, reft, nbInT); { f << "\nSubDomainFromMesh\n" << Th.NbSubDomains << endl; - for (Int4 i = 0; i < Th.NbSubDomains; i++) - f << 3 << " " << reft[Th.Number(Th.subdomains[i].head)] << " " << 1 << " " - << Th.subdomains[i].ref << endl; + for (Int4 i = 0; i < Th.NbSubDomains; i++) f << 3 << " " << reft[Th.Number(Th.subdomains[i].head)] << " " << 1 << " " << Th.subdomains[i].ref << endl; } if (Th.Gh.NbSubDomains) { f << "\nSubDomainFromGeom\n" << Th.Gh.NbSubDomains << endl; for (Int4 i = 0; i < Th.NbSubDomains; i++) { - f << 2 << " " << Th.Number(Th.subdomains[i].edge) + 1 << " " << Th.subdomains[i].sens << " " - << Th.Gh.subdomains[i].ref << endl; + f << 2 << " " << Th.Number(Th.subdomains[i].edge) + 1 << " " << Th.subdomains[i].sens << " " << Th.Gh.subdomains[i].ref << endl; } } { @@ -716,8 +694,7 @@ namespace bamg { for (Int4 i0 = 0; i0 < Th.NbVerticesOnGeomVertex; i0++) { VertexOnGeom &v = Th.VerticesOnGeomVertex[i0]; assert(v.OnGeomVertex( )); - f << " " << Th.Number((Vertex *)v) + 1 << " " << Th.Gh.Number((GeometricalVertex *)v) + 1 - << endl; + f << " " << Th.Number((Vertex *)v) + 1 << " " << Th.Gh.Number((GeometricalVertex *)v) + 1 << endl; } } { @@ -905,9 +882,7 @@ namespace bamg { Int4 i; f << "\nSubDomainFromGeom\n"; f << Gh.NbSubDomains << endl; - for (i = 0; i < Gh.NbSubDomains; i++) - f << "2 " << Gh.Number(Gh.subdomains[i].edge) + 1 << " " << Gh.subdomains[i].sens << " " - << Gh.subdomains[i].ref << endl; + for (i = 0; i < Gh.NbSubDomains; i++) f << "2 " << Gh.Number(Gh.subdomains[i].edge) + 1 << " " << Gh.subdomains[i].sens << " " << Gh.subdomains[i].ref << endl; } { Int4 n = 0, i; @@ -919,10 +894,8 @@ namespace bamg { if (n) { f << "TangentAtEdges " << n << endl; for (i = 0; i < Gh.nbe; i++) { - if (Gh.edges[i].TgA( ) && Gh.edges[i][0].Corner( )) - f << i + 1 << " 1 " << Gh.edges[i].tg[0].x << " " << Gh.edges[i].tg[0].y << endl; - if (Gh.edges[i].TgB( ) && Gh.edges[i][1].Corner( )) - f << i + 1 << " 2 " << Gh.edges[i].tg[1].x << " " << Gh.edges[i].tg[1].y << endl; + if (Gh.edges[i].TgA( ) && Gh.edges[i][0].Corner( )) f << i + 1 << " 1 " << Gh.edges[i].tg[0].x << " " << Gh.edges[i].tg[0].y << endl; + if (Gh.edges[i].TgB( ) && Gh.edges[i][1].Corner( )) f << i + 1 << " 2 " << Gh.edges[i].tg[1].x << " " << Gh.edges[i].tg[1].y << endl; } } } diff --git a/src/bamglib/Meshgibbs.cpp b/src/bamglib/Meshgibbs.cpp index 69af789d5..92f43df53 100644 --- a/src/bamglib/Meshgibbs.cpp +++ b/src/bamglib/Meshgibbs.cpp @@ -46,18 +46,13 @@ int gibbs1_(integer* n, integer* record, integer* ptvois); int gibbs2_(integer* n, integer* record, integer* criter); -int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, integer* nv, - integer* nx, integer* ny, integer* nn, integer* w1, integer* w2, integer* pfold, - integer* pfnew, integer* impre, integer* nfout); -int gibbsb_(integer* x, integer* y, integer* n, integer* ptvois, integer* vois, integer* nx, - integer* ny, integer* nv, integer* nn, integer* m, integer* wh, integer* wl, integer* r, +int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, integer* nv, integer* nx, integer* ny, integer* nn, integer* w1, integer* w2, integer* pfold, integer* pfnew, integer* impre, integer* nfout); -int gibbsc_(integer* nz, integer* nv, integer* niveau, integer* n, integer*); -int gibbsd_(integer* racine, integer* n, integer* ptvois, integer* vois, integer* nv, integer* r, - integer* niveau); -int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, integer* vois, - integer* m, integer* r, integer* new_, integer* option, integer* pfnew, integer* impre, +int gibbsb_(integer* x, integer* y, integer* n, integer* ptvois, integer* vois, integer* nx, integer* ny, integer* nv, integer* nn, integer* m, integer* wh, integer* wl, integer* r, integer* impre, integer* nfout); +int gibbsc_(integer* nz, integer* nv, integer* niveau, integer* n, integer*); +int gibbsd_(integer* racine, integer* n, integer* ptvois, integer* vois, integer* nv, integer* r, integer* niveau); +int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, integer* vois, integer* m, integer* r, integer* new_, integer* option, integer* pfnew, integer* impre, integer* nfout); /* Subroutine */ int gibbs1_(integer* n, integer* record, integer* ptvois) { /* System generated locals */ @@ -116,8 +111,7 @@ int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, i goto L8; } L5: - if (ptvois[record[j] + 1] - ptvois[record[j]] < - ptvois[record[j + 1] + 1] - ptvois[record[j + 1]]) { + if (ptvois[record[j] + 1] - ptvois[record[j]] < ptvois[record[j + 1] + 1] - ptvois[record[j + 1]]) { ++j; } L6: @@ -196,9 +190,8 @@ int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, i } /* gibbs2_ */ /* Subroutine */ -int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, integer* nv, - integer* nx, integer* ny, integer* nn, integer* w1, integer* w2, integer* pfold, - integer* pfnew, integer* impre, integer* nfout) { +int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, integer* nv, integer* nx, integer* ny, integer* nn, integer* w1, integer* w2, integer* pfold, integer* pfnew, + integer* impre, integer* nfout) { /* System generated locals */ integer i__1, i__2, i__3, i__4; @@ -339,8 +332,7 @@ int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, /* endif */ /* optimisation de la descendance de la numerotation */ /* ------------------------------------------------- */ - gibbsb_(&x, &y, n, &ptvois[1], &vois[1], &nx[1], &ny[1], nv, nn, &m[1], &w1[1], &w2[1], &r[1], - impre, nfout); + gibbsb_(&x, &y, n, &ptvois[1], &vois[1], &nx[1], &ny[1], nv, nn, &m[1], &w1[1], &w2[1], &r[1], impre, nfout); /* renumerotation de cuthill mac kee avec la meilleur des 4 option s */ @@ -407,9 +399,8 @@ int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, return 0; } /* gibbsa_ */ -/* Subroutine */ int gibbsb_(integer* x, integer* y, integer* n, integer* ptvois, integer* vois, - integer* nx, integer* ny, integer* nv, integer* nn, integer* m, - integer* wh, integer* wl, integer* r, integer* impre, integer* nfout) { +/* Subroutine */ int gibbsb_(integer* x, integer* y, integer* n, integer* ptvois, integer* vois, integer* nx, integer* ny, integer* nv, integer* nn, integer* m, integer* wh, integer* wl, integer* r, + integer* impre, integer* nfout) { /* System generated locals */ integer i__1, i__2; @@ -644,8 +635,7 @@ int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, return 0; } /* gibbsc_ */ -/* Subroutine */ int gibbsd_(integer* racine, integer* n, integer* ptvois, integer* vois, - integer* nv, integer* r, integer* niveau) { +/* Subroutine */ int gibbsd_(integer* racine, integer* n, integer* ptvois, integer* vois, integer* nv, integer* r, integer* niveau) { /* System generated locals */ integer i__1, i__2; @@ -729,9 +719,8 @@ int gibbsa_(integer* n, integer* ptvois, integer* vois, integer* r, integer* m, return 0; } /* gibbsd_ */ -/* Subroutine */ int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, - integer* vois, integer* m, integer* r, integer* new_, integer* option, - integer* pfnew, integer* impre, integer* nfout) { +/* Subroutine */ int gibbst_(integer* n, integer* p, integer* nv, integer* nn, integer* ptvois, integer* vois, integer* m, integer* r, integer* new_, integer* option, integer* pfnew, integer* impre, + integer* nfout) { /* System generated locals */ integer i__1, i__2, i__3, i__4, i__5; @@ -998,8 +987,7 @@ int Triangles::gibbs( ) w1 = new long[nv + 1]; w2 = new long[nv + 1]; long lnv = nv; - err = - gibbsa_(&lnv, ptvois, vois, r, m, nnv, nx, ny, nn, w1, w2, &pfold, &pfnew, &printint, &iodev); + err = gibbsa_(&lnv, ptvois, vois, r, m, nnv, nx, ny, nn, w1, w2, &pfold, &pfnew, &printint, &iodev); delete[] m; delete[] nnv; delete[] nn; diff --git a/src/bamglib/Meshio.cpp b/src/bamglib/Meshio.cpp index 4b59f5209..b37440664 100644 --- a/src/bamglib/Meshio.cpp +++ b/src/bamglib/Meshio.cpp @@ -55,8 +55,7 @@ namespace bamg { double *sol = 0; frbb >> dimlu >> nbsol >> lsol >> typesollu; if (typesol != typesollu) { - cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " << typesol - << endl; + cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " << typesol << endl; cerr << " or dim of solution (read) " << dimlu << " != (wanted) " << dim << endl; nbsol = 0; lsol = 0; @@ -72,8 +71,7 @@ namespace bamg { } /////////////////////////////////////////////////////////// - double *ReadBBFile(const char *file, long &nbsol, long &lsol, int *&typesols, const int dim, - const int typesol) { + double *ReadBBFile(const char *file, long &nbsol, long &lsol, int *&typesols, const int dim, const int typesol) { MeshIstream frbb(file); int dimlu, typesollu; @@ -89,8 +87,7 @@ namespace bamg { frbb >> typesols[i]; typesols[i]--; if (typesols[i] < 0 || typesols[i] >= 4) { - cerr << " Error reading BBFile the type solution " << i + 1 << " is " << typesols[i] + 1 - << " is not in [1..4] " << endl; + cerr << " Error reading BBFile the type solution " << i + 1 << " is " << typesols[i] + 1 << " is not in [1..4] " << endl; frbb.ShowIoErr(998); nbsol = 0; lsol = 0; @@ -102,20 +99,15 @@ namespace bamg { } frbb >> lsol >> typesollu; if (typesol != typesollu) { - cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " << typesol - << endl; + cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " << typesol << endl; cerr << " or dim of solution (read) " << dimlu << " != (wanted) " << dim << endl; frbb.ShowIoErr(999); nbsol = 0; lsol = 0; } else { - if (verbosity > 5) - cout << " read BB file " << file << " with nbsol " << nbsol - << " total nb of field = " << n << endl; + if (verbosity > 5) cout << " read BB file " << file << " with nbsol " << nbsol << " total nb of field = " << n << endl; if (verbosity > 9) - for (i = 0; i < nbsol; i++) - cout << " the type of solution " << i + 1 << " is " << sizeoftype[typesols[i]] - << " and the number of sub-field are " << sizeoftype[typesols[i]] << endl; + for (i = 0; i < nbsol; i++) cout << " the type of solution " << i + 1 << " is " << sizeoftype[typesols[i]] << " and the number of sub-field are " << sizeoftype[typesols[i]] << endl; sol = new double[lsol * n]; double *s = sol; for (i = 0; i < lsol; i++) @@ -129,9 +121,8 @@ namespace bamg { void MeshIstream::ShowIoErr(int s) { LineError = 1; if (CurrentFile) cerr << " In file " << CurrentFile; - cerr << ", Erreur Lecture " << s << ", good=" << (s & ios::goodbit) - << ", bad=" << (s & ios::badbit) << ", fail=" << (s & ios::failbit) - << ", eof=" << (s & ios::eofbit) << " Line " << LineNumber << endl; + cerr << ", Erreur Lecture " << s << ", good=" << (s & ios::goodbit) << ", bad=" << (s & ios::badbit) << ", fail=" << (s & ios::failbit) << ", eof=" << (s & ios::eofbit) << " Line " << LineNumber + << endl; if (!in.eof( )) { in.clear(ios::goodbit); int i = 0; @@ -155,8 +146,7 @@ namespace bamg { while (*ss && c == *ss && in.get(c)) ss++; if (*ss) { // no - if (verbosity > 9) - cout << "IsString: not " << s << " " << n << " putback " << ss - s << " :" << c; + if (verbosity > 9) cout << "IsString: not " << s << " " << n << " putback " << ss - s << " :" << c; if (in.good( )) in.putback(c), ss--; while (ss - s > 0) { cout << *ss; @@ -201,8 +191,7 @@ namespace bamg { // save the last record if (l == 0) { // l rec no set -- l = where( ); - if (verbosity > 9) - cout << " size of last record = " << l << " n = " << nb_rec << " i= " << i << endl; + if (verbosity > 9) cout << " size of last record = " << l << " n = " << nb_rec << " i= " << i << endl; if (!f->good( )) Error(3); f->seekp(i - sizeof(long)); if (!f->good( )) Error(3); @@ -217,8 +206,7 @@ namespace bamg { if (!f->good( )) Error(3); if (f && to_close) { - if (verbosity > 9) - cout << "delete OFortranUnFormattedFile " << file_name << " @end = " << n << endl; + if (verbosity > 9) cout << "delete OFortranUnFormattedFile " << file_name << " @end = " << n << endl; delete f; } f = 0; @@ -226,8 +214,7 @@ namespace bamg { IFortranUnFormattedFile::~IFortranUnFormattedFile( ) { if (f && to_close) { - if (verbosity > 9) - cout << " delete IFortranUnFormattedFile" << file_name << " @end = " << n << endl; + if (verbosity > 9) cout << " delete IFortranUnFormattedFile" << file_name << " @end = " << n << endl; delete f; } f = 0; @@ -241,9 +228,7 @@ namespace bamg { if (!f->good( )) Error(3); i = j = n + sizeof(l); n += l + sizeof(l); // end - if (verbosity > 9) - cout << " Read rec end =" << n << " l= " << l << " current= " << j << " begin= " << i - << endl; + if (verbosity > 9) cout << " Read rec end =" << n << " l= " << l << " current= " << j << " begin= " << i << endl; return l; } @@ -259,8 +244,7 @@ namespace bamg { if (n >= 0) { if (l == 0) { // l rec no set -- l = where( ); - if (verbosity > 9) - cout << " set len of rec " << nb_rec << " = " << l << " @ " << i - sizeof(long) << endl; + if (verbosity > 9) cout << " set len of rec " << nb_rec << " = " << l << " @ " << i - sizeof(long) << endl; f->seekp(i - sizeof(long)); f->write((char *)&l, sizeof(l)); @@ -281,9 +265,7 @@ namespace bamg { j = n; i = n; n += l; - if (verbosity > 9) - cout << " Write rec end =" << n << " l= " << l << " current= " << j << " begin= " << i - << endl; + if (verbosity > 9) cout << " Write rec end =" << n << " l= " << l << " current= " << j << " begin= " << i << endl; return l; } void OFortranUnFormattedFile::Error(int err) { @@ -299,8 +281,7 @@ namespace bamg { else cerr << " unknown err " << err; - cerr << " Record number = " << nb_rec << endl - << " read position in file " << j << " < " << n << " = end on record " << endl; + cerr << " Record number = " << nb_rec << endl << " read position in file " << j << " < " << n << " = end on record " << endl; cerr << " position in the record = " << where( ) << " length of record = " << l << endl; cerr << " file = " << file_name << endl; MeshError(900); @@ -319,8 +300,7 @@ namespace bamg { else cerr << " unknown err " << err; - cerr << " Record number = " << nb_rec << endl - << " read position in file " << j << " < " << n << " = end on record " << endl; + cerr << " Record number = " << nb_rec << endl << " read position in file " << j << " < " << n << " = end on record " << endl; cerr << " position in the record = " << where( ) << " length of record = " << l << endl; cerr << " file = " << file_name << endl; MeshError(900); diff --git a/src/bamglib/Meshio.h b/src/bamglib/Meshio.h index 88a2d8192..2d0761112 100644 --- a/src/bamglib/Meshio.h +++ b/src/bamglib/Meshio.h @@ -52,10 +52,8 @@ namespace bamg { void WriteStr(ostream &out, char *str); - double *ReadbbFile(const char *file, long &nbsol, long &lsol, const int dim = 2, - const int typesol = 2); - double *ReadBBFile(const char *file, long &nbsol, long &lsol, int *&typesols, const int dim = 2, - const int typesol = 2); + double *ReadbbFile(const char *file, long &nbsol, long &lsol, const int dim = 2, const int typesol = 2); + double *ReadBBFile(const char *file, long &nbsol, long &lsol, int *&typesols, const int dim = 2, const int typesol = 2); // solution at vertex (P1) union Char4orLong { @@ -74,11 +72,7 @@ namespace bamg { { char c; int cmm = 0; - while (in.get(c) && - (isspace(c) - ? (((c == '\n' || c == char(12) || c == char(15)) && (LineNumber++, cmm = 0)), 1) - : (cmm || (c == '#' && (cmm = 1))))) - ((void)0); + while (in.get(c) && (isspace(c) ? (((c == '\n' || c == char(12) || c == char(15)) && (LineNumber++, cmm = 0)), 1) : (cmm || (c == '#' && (cmm = 1))))) ((void)0); if (in.good( )) in.putback(c); return in; } @@ -97,8 +91,7 @@ namespace bamg { } // MeshIstream(istream & i): in(i),CurrentFile(0),LineNumber(1),LineError(0) {} - MeshIstream(const char *file_name) - : in(*new ifstream(file_name)), CurrentFile(file_name), LineNumber(1), LineError(0) { + MeshIstream(const char *file_name) : in(*new ifstream(file_name)), CurrentFile(file_name), LineNumber(1), LineError(0) { if (!in) { cerr << " Error Opening file " << file_name, CurrentFile = 0; ShowIoErr(1); @@ -153,15 +146,11 @@ namespace bamg { int to_close; public: - IFortranUnFormattedFile(char *name) - : f(new ifstream(name)), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(name), - to_close(1) { + IFortranUnFormattedFile(char *name) : f(new ifstream(name)), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(name), to_close(1) { if (!*f) Error(0); } - IFortranUnFormattedFile(MeshIstream &ff) - : f(&ff.in), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(ff.CurrentFile), - to_close(0) { + IFortranUnFormattedFile(MeshIstream &ff) : f(&ff.in), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(ff.CurrentFile), to_close(0) { if (!*f) Error(0); } @@ -183,13 +172,10 @@ namespace bamg { int to_close; public: - OFortranUnFormattedFile(const char *name, IOS_OPENMODE mm = ios::trunc) - : f(new ofstream(name, mm)), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(name), - to_close(1) { + OFortranUnFormattedFile(const char *name, IOS_OPENMODE mm = ios::trunc) : f(new ofstream(name, mm)), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(name), to_close(1) { if (!*f) Error(0); } - OFortranUnFormattedFile(ostream &ff) - : f(&ff), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(unkown), to_close(0) { + OFortranUnFormattedFile(ostream &ff) : f(&ff), i(0), l(0), n((long)-sizeof(long)), nb_rec(0), file_name(unkown), to_close(0) { if (!*f) Error(0); } diff --git a/src/bamglib/Metric.cpp b/src/bamglib/Metric.cpp index 01f7b7257..eb6b254fe 100644 --- a/src/bamglib/Metric.cpp +++ b/src/bamglib/Metric.cpp @@ -32,10 +32,7 @@ namespace bamg { - inline Real8 det3x3(Real8 A[3], Real8 B[3], Real8 C[3]) { - return A[0] * (B[1] * C[2] - B[2] * C[1]) - A[1] * (B[0] * C[2] - B[2] * C[0]) + - A[2] * (B[0] * C[1] - B[1] * C[0]); - } + inline Real8 det3x3(Real8 A[3], Real8 B[3], Real8 C[3]) { return A[0] * (B[1] * C[2] - B[2] * C[1]) - A[1] * (B[0] * C[2] - B[2] * C[0]) + A[2] * (B[0] * C[1] - B[1] * C[0]); } SaveMetricInterpole LastMetricInterpole; @@ -113,11 +110,8 @@ namespace bamg { return MetricAnIso(Mi.x.x, 0.5 * (Mi.x.y + Mi.y.x), Mi.y.y); } - MetricAnIso::MetricAnIso(const Real8 a[3], const MetricAnIso m0, const MetricAnIso m1, - const MetricAnIso m2) { - MetricAnIso mab(a[0] * m0.a11 + a[1] * m1.a11 + a[2] * m2.a11, - a[0] * m0.a21 + a[1] * m1.a21 + a[2] * m2.a21, - a[0] * m0.a22 + a[1] * m1.a22 + a[2] * m2.a22); + MetricAnIso::MetricAnIso(const Real8 a[3], const MetricAnIso m0, const MetricAnIso m1, const MetricAnIso m2) { + MetricAnIso mab(a[0] * m0.a11 + a[1] * m1.a11 + a[2] * m2.a11, a[0] * m0.a21 + a[1] * m1.a21 + a[2] * m2.a21, a[0] * m0.a22 + a[1] * m1.a22 + a[2] * m2.a22); MatVVP2x2 vab(mab); @@ -201,9 +195,7 @@ namespace bamg { void Triangles::IntersectGeomMetric(const Real8 err = 1, const int iso = 0) { - if (verbosity > 1) - cout << " -- IntersectGeomMetric geometric err=" << err << (iso ? " iso " : " aniso ") - << endl; + if (verbosity > 1) cout << " -- IntersectGeomMetric geometric err=" << err << (iso ? " iso " : " aniso ") << endl; Real8 ss[2] = {0.00001, 0.99999}; Real8 errC = 2 * sqrt(2 * err); Real8 hmax = Gh.MaximalHmax( ); @@ -308,16 +300,12 @@ namespace bamg { } if (verbosity > 2) { - cout << " input : Hmin = " << sqrt(1 / h2) << " Hmax = " << sqrt(1 / h1) - << " factor of anisotropy max = " << sqrt(rx) << endl; - cout << " output: Hmin = " << sqrt(1 / hn2) << " Hmax = " << sqrt(1 / hn1) - << " factor of anisotropy max = " << sqrt(rnx) << endl; + cout << " input : Hmin = " << sqrt(1 / h2) << " Hmax = " << sqrt(1 / h1) << " factor of anisotropy max = " << sqrt(rx) << endl; + cout << " output: Hmin = " << sqrt(1 / hn2) << " Hmax = " << sqrt(1 / hn1) << " factor of anisotropy max = " << sqrt(rnx) << endl; } } - void Triangles::IntersectConsMetric(const double *s, const Int4 nbsol, const int *typsols, - const Real8 hmin1, const Real8 hmax1, const Real8 coef, - const Real8 anisomax, const Real8 CutOff, const int NbJacobi, - const int DoNormalisation, const double power, + void Triangles::IntersectConsMetric(const double *s, const Int4 nbsol, const int *typsols, const Real8 hmin1, const Real8 hmax1, const Real8 coef, const Real8 anisomax, const Real8 CutOff, + const int NbJacobi, const int DoNormalisation, const double power, const int choice) { // the array of solution s is store // sol0,sol1,...,soln on vertex 0 // sol0,sol1,...,soln on vertex 1 @@ -351,10 +339,8 @@ namespace bamg { Real8 coef2 = 1 / (coef * coef); if (verbosity > 1) { - cout << " -- Construction of Metric: Nb of field. " << n << " nbt = " << nbt - << " nbv= " << nbv << " coef = " << coef << endl - << " hmin = " << hmin << " hmax=" << hmax << " anisomax = " << anisomax - << " Nb Jacobi " << NbJacobi << " Power = " << power; + cout << " -- Construction of Metric: Nb of field. " << n << " nbt = " << nbt << " nbv= " << nbv << " coef = " << coef << endl + << " hmin = " << hmin << " hmax=" << hmax << " anisomax = " << anisomax << " Nb Jacobi " << NbJacobi << " Power = " << power; if (RelativeMetric) cout << " RelativeErr with CutOff= " << CutOff << endl; else @@ -402,8 +388,7 @@ namespace bamg { for (int j = 0; j < 3; j++) { Triangle *ta = t.Adj(j); if (!ta || !ta->link) // no adj triangle => edge on boundary - OnBoundary[Number(t[VerticesOfTriangularEdge[j][0]])] = 1, - OnBoundary[Number(t[VerticesOfTriangularEdge[j][1]])] = 1, nbb++; + OnBoundary[Number(t[VerticesOfTriangularEdge[j][0]])] = 1, OnBoundary[Number(t[VerticesOfTriangularEdge[j][1]])] = 1, nbb++; } workT[i] = nbb; @@ -427,8 +412,7 @@ namespace bamg { Real8 h1 = 1.e30, h2 = 1e-30, rx = 0; Real8 coef = 1. / (anisomax * anisomax); Real8 hn1 = 1.e30, hn2 = 1e-30, rnx = 1.e-30; - int nbfield = - typsols ? (typsols[nusol] < 4 ? sizeoftype[typsols[nusol]] : typsols[nusol] + 1) : 1; + int nbfield = typsols ? (typsols[nusol] < 4 ? sizeoftype[typsols[nusol]] : typsols[nusol] + 1) : 1; if (nbfield == 1) for (iv = 0, k = 0; iv < nbv; iv++, k += n) { dxdx[iv] = dxdy[iv] = dydy[iv] = 0; @@ -449,10 +433,7 @@ namespace bamg { Real8 absmax = Max(Abs(smin), Abs(smax)); Real8 cnorm = DoNormalisation ? coef2 / sdelta : coef2; - if (verbosity > 2) - cout << " Solution " << nusol << " Min = " << smin << " Max = " << smax - << " Delta =" << sdelta << " cnorm = " << cnorm << " Nb of fields =" << nbfield - << endl; + if (verbosity > 2) cout << " Solution " << nusol << " Min = " << smin << " Max = " << smax << " Delta =" << sdelta << " cnorm = " << cnorm << " Nb of fields =" << nbfield << endl; if (sdelta < 1.0e-10 * Max(absmax, 1e-20) && (nbfield == 1)) { if (verbosity > 2) @@ -545,8 +526,8 @@ namespace bamg { // verif // cout << " " << (taa[0][0]*cBC + taa[1][0]*cCA + taa[2][0] * cAB)/det33 << " //== " << bb[0] ; cout << " " << (taa[0][1]*cBC + taa[1][1]*cCA + taa[2][1] * - //cAB)/det33 << " == " << bb[1]; cout << " " << (taa[0][2]*cBC + taa[1][2]*cCA + - //taa[2][2] * cAB)/det33 << " == " << bb[2] + // cAB)/det33 << " == " << bb[1]; cout << " " << (taa[0][2]*cBC + taa[1][2]*cCA + + // taa[2][2] * cAB)/det33 << " == " << bb[2] // << " -- " ; // cout << lla*sA + llb*sB+llc*sC+ (lla*llb* cAB + llb*llc* cBC + llc*lla*cCA)/det33 // << " == " << llf << endl; @@ -556,12 +537,11 @@ namespace bamg { // grad li = njk / detT ; with i j k ={A,B,C) Real8 Hxx = cAB * (nBC.x * nCA.x) + cBC * (nCA.x * nAB.x) + cCA * (nAB.x * nBC.x); Real8 Hyy = cAB * (nBC.y * nCA.y) + cBC * (nCA.y * nAB.y) + cCA * (nAB.y * nBC.y); - Real8 Hxy = cAB * (nBC.y * nCA.x) + cBC * (nCA.y * nAB.x) + cCA * (nAB.y * nBC.x) + - cAB * (nBC.x * nCA.y) + cBC * (nCA.x * nAB.y) + cCA * (nAB.x * nBC.y); + Real8 Hxy = cAB * (nBC.y * nCA.x) + cBC * (nCA.y * nAB.x) + cCA * (nAB.y * nBC.x) + cAB * (nBC.x * nCA.y) + cBC * (nCA.x * nAB.y) + cCA * (nAB.x * nBC.y); Real8 coef = 1.0 / (3 * dd * det33); Real8 coef2 = 2 * coef; // cout << " H = " << Hxx << " " << Hyy << " " << Hxy/2 << " coef2 = " << - //coef2 << endl; + // coef2 << endl; Hxx *= coef2; Hyy *= coef2; Hxy *= coef2; @@ -646,8 +626,7 @@ namespace bamg { iB = Number(triangles[i][1]); iC = Number(triangles[i][2]); Real8 cc = 3; - if (ijacobi == 0) - cc = Max((Real8)((Mmassxx[iA] > 0) + (Mmassxx[iB] > 0) + (Mmassxx[iC] > 0)), 1.); + if (ijacobi == 0) cc = Max((Real8)((Mmassxx[iA] > 0) + (Mmassxx[iB] > 0) + (Mmassxx[iC] > 0)), 1.); workT[i] = (dd[iA] + dd[iB] + dd[iC]) / cc; } for (iv = 0; iv < nbv; iv++) workV[iv] = 0; @@ -719,14 +698,11 @@ namespace bamg { } // for all vertices if (verbosity > 2) { cout << " Field " << nufield << " of solution " << nusol << endl; - cout << " before bounding : Hmin = " << sqrt(1 / h2) - << " Hmax = " << sqrt(1 / h1) << " factor of anisotropy max = " << sqrt(rx) << endl; - cout << " after bounding : Hmin = " << sqrt(1 / hn2) - << " Hmax = " << sqrt(1 / hn1) << " factor of anisotropy max = " << sqrt(rnx) - << endl; + cout << " before bounding : Hmin = " << sqrt(1 / h2) << " Hmax = " << sqrt(1 / h1) << " factor of anisotropy max = " << sqrt(rx) << endl; + cout << " after bounding : Hmin = " << sqrt(1 / hn2) << " Hmax = " << sqrt(1 / hn1) << " factor of anisotropy max = " << sqrt(rnx) << endl; } } // end of for all field - } // end for all solution + } // end for all solution delete[] detT; delete[] Mmass; @@ -739,16 +715,13 @@ namespace bamg { delete[] OnBoundary; } - void Triangles::ReadMetric(const char *fmetrix, const Real8 hmin1 = 1.0e-30, - const Real8 hmax1 = 1.0e30, const Real8 coef = 1) { + void Triangles::ReadMetric(const char *fmetrix, const Real8 hmin1 = 1.0e-30, const Real8 hmax1 = 1.0e30, const Real8 coef = 1) { Real8 hmin = Max(hmin1, MinimalHmin( )); Real8 hmax = Min(hmax1, MaximalHmax( )); MeshIstream f_metrix(fmetrix); Int4 k, j; f_metrix >> k >> j; - if (verbosity > 1) - cout << " metrix: open " << fmetrix << ", le coef = " << coef << ", hmin = " << hmin - << ", hmax = " << hmax << ((j == 1) ? " Iso " : " AnIso ") << endl; + if (verbosity > 1) cout << " metrix: open " << fmetrix << ", le coef = " << coef << ", hmin = " << hmin << ", hmax = " << hmax << ((j == 1) ? " Iso " : " AnIso ") << endl; if (k != nbv || !(j == 1 || j == 3)) { cerr << " Error Pb metrix " << k << " <> " << nbv << " or 1 or 3 <> " << j << endl; @@ -784,8 +757,7 @@ namespace bamg { } } else { f << nbv << " " << 3 << endl; - for (Int4 iv = 0; iv < nbv; iv++) - f << vertices[iv].m.a11 << " " << vertices[iv].m.a21 << " " << vertices[iv].m.a22 << endl; + for (Int4 iv = 0; iv < nbv; iv++) f << vertices[iv].m.a11 << " " << vertices[iv].m.a21 << " " << vertices[iv].m.a22 << endl; } } void Triangles::MaxSubDivision(Real8 maxsubdiv) { @@ -793,8 +765,7 @@ namespace bamg { #ifdef DRAWING2 inquire( ); #endif - if (verbosity > 1) - cout << " -- Limit the subdivision of a edges in the new mesh by " << maxsubdiv << endl; + if (verbosity > 1) cout << " -- Limit the subdivision of a edges in the new mesh by " << maxsubdiv << endl; // for all the edges // if the len of the edge is to long Int4 it, nbchange = 0; @@ -854,9 +825,7 @@ namespace bamg { } } } - if (verbosity > 3) - cout << " Nb of metric change = " << nbchange - << " Max of the subdivision of a edges before change = " << sqrt(lmax) << endl; + if (verbosity > 3) cout << " Nb of metric change = " << nbchange << " Max of the subdivision of a edges before change = " << sqrt(lmax) << endl; #ifdef DRAWING2 inquire( ); #endif @@ -864,8 +833,7 @@ namespace bamg { void Triangles::SmoothMetric(Real8 raisonmax) { if (raisonmax < 1.1) return; - if (verbosity > 1) - cout << " -- Triangles::SmoothMetric raisonmax = " << raisonmax << " " << nbv << endl; + if (verbosity > 1) cout << " -- Triangles::SmoothMetric raisonmax = " << raisonmax << " " << nbv << endl; ReMakeTriangleContainingTheVertex( ); Int4 i, j, kch, kk, ip; Int4 *first_np_or_next_t0 = new Int4[nbv]; @@ -880,9 +848,8 @@ namespace bamg { while (Head0 >= 0 && kk++ < 100) { kch = 0; for (i = Head0; i >= 0; i = first_np_or_next_t0[ip = i], - first_np_or_next_t0[ip] = - -1) { // pour tous les triangles autour du sommet s - // cout << kk << " i = " << i << " " << ip << endl; + first_np_or_next_t0[ip] = -1) { // pour tous les triangles autour du sommet s + // cout << kk << " i = " << i << " " << ip << endl; Triangle *t = vertices[i].t; assert(t); Vertex &vi = vertices[i]; @@ -916,23 +883,19 @@ namespace bamg { Head0 = Head1; Head1 = -1; Exchange(first_np_or_next_t0, first_np_or_next_t1); - if (verbosity > 5) - cout << " Iteration " << kk << " Nb de vertices with change " << kch << endl; + if (verbosity > 5) cout << " Iteration " << kk << " Nb de vertices with change " << kch << endl; } if (verbosity > 2 && verbosity < 5) cout << " Nb of Loop " << kch << endl; delete[] first_np_or_next_t0; delete[] first_np_or_next_t1; } - void Geometry::ReadMetric(const char *fmetrix, Real8 hmin = 1.0e-30, Real8 hmax = 1.0e30, - Real8 coef = 1) { + void Geometry::ReadMetric(const char *fmetrix, Real8 hmin = 1.0e-30, Real8 hmax = 1.0e30, Real8 coef = 1) { hmin = Max(hmin, MinimalHmin( )); MeshIstream f_metrix(fmetrix); Int4 k, j; f_metrix >> k >> j; - if (verbosity > 1) - cout << " -- ReadMetric " << fmetrix << ", coef = " << coef << ", hmin = " << hmin - << ", hmax = " << hmax << ((j == 1) ? " Iso " : " AnIso ") << endl; + if (verbosity > 1) cout << " -- ReadMetric " << fmetrix << ", coef = " << coef << ", hmin = " << hmin << ", hmax = " << hmax << ((j == 1) ? " Iso " : " AnIso ") << endl; if (k != nbv || !(j == 1 || j == 3)) { cerr << " Error Pb metrix " << k << " <> " << nbv << " or 1 or 3 <> " << j << endl; @@ -1016,9 +979,7 @@ namespace bamg { assert(i < 512); LastMetricInterpole.lab = l; LastMetricInterpole.opt = i; - if (i > 200 && kkk++ < 10 && verbosity) - cout << "Warning LengthInterpole: ( i = " << i << " l = " << l << " sss " << sss << " ) " - << sstop << endl; + if (i > 200 && kkk++ < 10 && verbosity) cout << "Warning LengthInterpole: ( i = " << i << " l = " << l << " sss " << sss << " ) " << sstop << endl; return l; } diff --git a/src/bamglib/Metric.h b/src/bamglib/Metric.h index 13f52976d..f65c1c4e2 100644 --- a/src/bamglib/Metric.h +++ b/src/bamglib/Metric.h @@ -30,7 +30,7 @@ #define TYPEMETRIX MetricAnIso #endif -//#include "R2.h" +// #include "R2.h" namespace bamg { typedef P2< double, double > D2; @@ -48,15 +48,12 @@ namespace bamg { public: MetricIso(Real8 a) : h(a) {} - MetricIso(const MetricAnIso M); // {MatVVP2x2 vp(M);h=1/sqrt(Max(vp.lambda1,vp.lambda2));} + MetricIso(const MetricAnIso M); // {MatVVP2x2 vp(M);h=1/sqrt(Max(vp.lambda1,vp.lambda2));} MetricIso(Real8 a11, Real8 a21, Real8 a22); // {*this=MetricAnIso(a11,a21,a22));} - MetricIso( ) : h(1){}; // + MetricIso( ) : h(1) {}; // MetricIso(const Real8 a[3], const MetricIso m0, const MetricIso m1, const MetricIso m2) - : h(hinterpole - ? (a[0] * m0.h + a[1] * m1.h + a[2] * m2.h) - : 1 / sqrt(a[0] / (m0.h * m0.h) + a[1] / (m1.h * m1.h) + a[2] / (m2.h * m2.h))) {} - MetricIso(const Real8 a, const MetricIso ma, const Real8 b, const MetricIso mb) - : h(hinterpole ? a * ma.h + b * mb.h : 1 / sqrt(a / (ma.h * ma.h) + b / (mb.h * mb.h))) {} + : h(hinterpole ? (a[0] * m0.h + a[1] * m1.h + a[2] * m2.h) : 1 / sqrt(a[0] / (m0.h * m0.h) + a[1] / (m1.h * m1.h) + a[2] / (m2.h * m2.h))) {} + MetricIso(const Real8 a, const MetricIso ma, const Real8 b, const MetricIso mb) : h(hinterpole ? a * ma.h + b * mb.h : 1 / sqrt(a / (ma.h * ma.h) + b / (mb.h * mb.h))) {} R2 Orthogonal(const R2 A) const { return R2(-h * A.y, h * A.x); } R2 Orthogonal(const I2 A) const { return R2(-h * A.y, h * A.x); } // D2 Orthogonal(const D2 A)const {return D2(-h*A.y,h*A.x);} @@ -88,7 +85,7 @@ namespace bamg { Real8 a11, a21, a22; MetricAnIso(Real8 a) : a11(1 / (a * a)), a21(0), a22(1 / (a * a)) {} MetricAnIso(Real8 a, Real8 b, Real8 c) : a11(a), a21(b), a22(c) {} - MetricAnIso( ){}; // + MetricAnIso( ) {}; // MetricAnIso(const Real8 a[3], const MetricAnIso m0, const MetricAnIso m1, const MetricAnIso m2); R2 mul(const R2 x) const { return R2(a11 * x.x + a21 * x.y, a21 * x.x + a22 * x.y); } Real8 det( ) const { return a11 * a22 - a21 * a21; } @@ -107,13 +104,9 @@ namespace bamg { } operator D2xD2( ) { return D2xD2(a11, a21, a21, a22); } - Real8 operator( )(R2 x) const { - return sqrt(x.x * x.x * a11 + 2 * x.x * x.y * a21 + x.y * x.y * a22); - }; + Real8 operator( )(R2 x) const { return sqrt(x.x * x.x * a11 + 2 * x.x * x.y * a21 + x.y * x.y * a22); }; // Real8 operator()(D2 x) const { return sqrt(x.x*x.x*a11+2*x.x*x.y*a21+x.y*x.y*a22);}; - Real8 operator( )(R2 x, R2 y) const { - return x.x * y.x * a11 + (x.x * x.y + x.y * y.x) * a21 + x.y * y.y * a22; - }; + Real8 operator( )(R2 x, R2 y) const { return x.x * y.x * a11 + (x.x * x.y + x.y * y.x) * a21 + x.y * y.y * a22; }; inline void Box(Real8& hx, Real8& hy) const; friend ostream& operator<<(ostream& f, const MetricAnIso& M) { f << " mtr a11=" << M.a11 << " a21=a12=" << M.a21 << " a22=" << M.a22 << ";"; @@ -185,9 +178,9 @@ namespace bamg { lambda2 = bamg::Max(lambda2, lambda1 * coef); else // a verifier if (lambda1 > lambda2) - lambda1 = bamg::Min(lambda1, lambda2 * coef); - else - lambda2 = bamg::Min(lambda2, lambda1 * coef); + lambda1 = bamg::Min(lambda1, lambda2 * coef); + else + lambda2 = bamg::Min(lambda2, lambda1 * coef); } void ReductionSimultanee(MetricAnIso M1, MetricAnIso M2, double& l1, double& l2, D2xD2& V); @@ -232,18 +225,10 @@ namespace bamg { extern SaveMetricInterpole LastMetricInterpole; // for optimization Real8 LengthInterpole(const MetricAnIso Ma, const MetricAnIso Mb, R2 AB); - Real8 abscisseInterpole(const MetricAnIso Ma, const MetricAnIso Mb, R2 AB, Real8 s, - int optim = 0); + Real8 abscisseInterpole(const MetricAnIso Ma, const MetricAnIso Mb, R2 AB, Real8 s, int optim = 0); - inline Real8 LengthInterpole(Real8 la, Real8 lb) { - return (Abs(la - lb) < 1.0e-6 * Max3(la, lb, 1.0e-20)) ? (la + lb) / 2 - : la * lb * log(la / lb) / (la - lb); - } + inline Real8 LengthInterpole(Real8 la, Real8 lb) { return (Abs(la - lb) < 1.0e-6 * Max3(la, lb, 1.0e-20)) ? (la + lb) / 2 : la * lb * log(la / lb) / (la - lb); } - inline Real8 abscisseInterpole(Real8 la, Real8 lb, Real8 lab, Real8 s) { - return (Abs(la - lb) < 1.0e-6 * Max3(la, lb, 1.0e-20)) - ? s - : expm1(s * lab * (la - lb) / (la * lb)) * lb / (la - lb); - } + inline Real8 abscisseInterpole(Real8 la, Real8 lb, Real8 lab, Real8 s) { return (Abs(la - lb) < 1.0e-6 * Max3(la, lb, 1.0e-20)) ? s : expm1(s * lab * (la - lb) / (la * lb)) * lb / (la - lb); } } // namespace bamg diff --git a/src/bamglib/QuadTree.cpp b/src/bamglib/QuadTree.cpp index f26a3c31f..b84fe1e80 100644 --- a/src/bamglib/QuadTree.cpp +++ b/src/bamglib/QuadTree.cpp @@ -27,7 +27,7 @@ */ #include -//#include +// #include #include #include @@ -192,8 +192,7 @@ namespace bamg { Icoor1 iii = ii[l] + I_IJ(k, hb); Icoor1 jjj = jj[l] + J_IJ(k, hb); - if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && - INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { + if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { pb[++l] = b; pi[l] = b->n > 0 ? (int)b->n : 4; ii[l] = iii; @@ -264,8 +263,7 @@ namespace bamg { long iii = ii[l] + I_IJ(k, hb); long jjj = jj[l] + J_IJ(k, hb); - if (INTER_SEG(iii, iii + hb, i - hx, i + hx) && - INTER_SEG(jjj, jjj + hb, j - hy, j + hy)) { + if (INTER_SEG(iii, iii + hb, i - hx, i + hx) && INTER_SEG(jjj, jjj + hb, j - hy, j + hy)) { pb[++l] = b; pi[l] = b->n > 0 ? (int)b->n : 4; ii[l] = iii; @@ -311,7 +309,7 @@ namespace bamg { b->n = -b->n; // mark is pointer QuadTreeBox b->b[0] = b->b[1] = b->b[2] = b->b[3] = 0; // set empty QuadTreeBox ptr l >>= 1; // div the size by 2 - for (int k = 0; k < 4; k++) // for the 4 vertices find the sub QuadTreeBox ij + for (int k = 0; k < 4; k++) // for the 4 vertices find the sub QuadTreeBox ij { int ij; QuadTreeBox *bb = b->b[ij = IJ(v4[k]->i.x, v4[k]->i.y, l)]; @@ -327,9 +325,7 @@ namespace bamg { NbVertices++; } - QuadTree::QuadTree(Triangles *t, long nbv) - : lenStorageQuadTreeBox(t->nbvx / 8 + 10), th(t), NbQuadTreeBox(0), NbVertices(0), - NbQuadTreeBoxSearch(0), NbVerticesSearch(0) { + QuadTree::QuadTree(Triangles *t, long nbv) : lenStorageQuadTreeBox(t->nbvx / 8 + 10), th(t), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0) { if (nbv == -1) nbv = t->nbv; sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); root = NewQuadTreeBox( ); @@ -340,9 +336,7 @@ namespace bamg { #endif } - QuadTree::QuadTree( ) - : lenStorageQuadTreeBox(100), th(0), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), - NbVerticesSearch(0) { + QuadTree::QuadTree( ) : lenStorageQuadTreeBox(100), th(0), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0) { sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); root = NewQuadTreeBox( ); } @@ -364,8 +358,7 @@ namespace bamg { ostream &operator<<(ostream &f, const QuadTree &qt) { f << " the quadtree " << endl; f << " NbQuadTreeBox = " << qt.NbQuadTreeBox << " Nb Vertices = " << qt.NbVertices << endl; - f << " NbQuadTreeBoxSearch " << qt.NbQuadTreeBoxSearch << " NbVerticesSearch " - << qt.NbVerticesSearch << endl; + f << " NbQuadTreeBoxSearch " << qt.NbQuadTreeBoxSearch << " NbVerticesSearch " << qt.NbVerticesSearch << endl; f << " SizeOf QuadTree" << qt.SizeOf( ) << endl; // return dump(f,*qt.root); return f; @@ -451,8 +444,7 @@ namespace bamg { Icoor1 iii = ii[l] + I_IJ(k, hb); Icoor1 jjj = jj[l] + J_IJ(k, hb); - if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && - INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { + if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { pb[++l] = b; pi[l] = b->n > 0 ? (int)b->n : 4; ii[l] = iii; diff --git a/src/bamglib/QuadTree.h b/src/bamglib/QuadTree.h index ca5a3dd3d..3e97eb067 100644 --- a/src/bamglib/QuadTree.h +++ b/src/bamglib/QuadTree.h @@ -61,9 +61,7 @@ namespace bamg { if (n) delete n; delete[] b; } - long SizeOf( ) const { - return len * sizeof(QuadTreeBox) + sizeof(StorageQuadTreeBox) + (n ? n->SizeOf( ) : 0); - } + long SizeOf( ) const { return len * sizeof(QuadTreeBox) + sizeof(StorageQuadTreeBox) + (n ? n->SizeOf( ) : 0); } }; // end class StorageQuadTreeBox StorageQuadTreeBox *sb; @@ -101,6 +99,6 @@ namespace bamg { friend ostream &operator<<(ostream &f, const QuadTree &qt); }; } // namespace bamg -//#undef IJ +// #undef IJ #endif // QUAD_TREE_H diff --git a/src/bamglib/R2.h b/src/bamglib/R2.h index 5ed7bcbcb..cc825c2f8 100644 --- a/src/bamglib/R2.h +++ b/src/bamglib/R2.h @@ -38,7 +38,7 @@ namespace bamg { public: R x, y; - P2( ) : x(0), y(0){}; + P2( ) : x(0), y(0) {}; P2(R a, R b) : x(a), y(b) {} P2(P2 A, P2 B) : x(B.x - A.x), y(B.y - A.y) {} P2< R, RR > operator+(const P2< R, RR >& cc) const { return P2< R, RR >(x + cc.x, y + cc.y); } @@ -46,9 +46,7 @@ namespace bamg { P2< R, RR > operator-( ) const { return P2< R, RR >(-x, -y); } // RR operator*(const P2 & cc) const {return (RR) x* (RR) cc.x+(RR) y* (RR) cc.y;} // // produit scalaire - RR operator,(const P2< R, RR >& cc) const { - return (RR)x * (RR)cc.x + (RR)y * (RR)cc.y; - } // produit scalaire + RR operator,(const P2< R, RR >& cc) const { return (RR)x * (RR)cc.x + (RR)y * (RR)cc.y; } // produit scalaire P2< R, RR > operator*(R cc) const { return P2< R, RR >(x * cc, y * cc); } // P2 operator*(RR cc) const {return P2((R)(x*cc),(R)(y*cc));} P2< R, RR > operator/(R cc) const { return P2< R, RR >(x / cc, y / cc); } @@ -83,9 +81,7 @@ namespace bamg { return f; } - friend P2< R, RR > operator*(P2< R, RR > c, P2xP2< R, RR > cc) { - return P2< R, RR >(c.x * cc.x.x + c.y * cc.y.x, c.x * cc.x.y + c.y * cc.y.y); - } + friend P2< R, RR > operator*(P2< R, RR > c, P2xP2< R, RR > cc) { return P2< R, RR >(c.x * cc.x.x + c.y * cc.y.x, c.x * cc.x.y + c.y * cc.y.y); } public: P2< R, RR > x, y; @@ -93,13 +89,8 @@ namespace bamg { P2xP2(P2< R, RR > a, P2< R, RR > b) : x(a), y(b) {} P2xP2(P2< R, RR > a, P2< R, RR > b, P2< R, RR > c) : x(b - a), y(c - a) {} P2xP2(R xx, R xy, R yx, R yy) : x(xx, xy), y(yx, yy) {} - P2< R, RR > operator*(const P2< R, RR > c) const { - return P2< R, RR >(x.x * c.x + x.y * c.y, y.x * c.x + y.y * c.y); - } - P2xP2< R, RR > operator*(P2xP2< R, RR > c) const { - return P2xP2< R, RR >(x.x * c.x.x + x.y * c.y.x, x.x * c.x.y + x.y * c.y.y, - y.x * c.x.x + y.y * c.y.x, y.x * c.x.y + y.y * c.y.y); - } + P2< R, RR > operator*(const P2< R, RR > c) const { return P2< R, RR >(x.x * c.x + x.y * c.y, y.x * c.x + y.y * c.y); } + P2xP2< R, RR > operator*(P2xP2< R, RR > c) const { return P2xP2< R, RR >(x.x * c.x.x + x.y * c.y.x, x.x * c.x.y + x.y * c.y.y, y.x * c.x.x + y.y * c.y.x, y.x * c.x.y + y.y * c.y.y); } RR det( ) const { return (RR)x.x * (RR)y.y - (RR)x.y * (RR)y.x; } P2xP2< R, RR > inv( ) const { RR d = (*this).det( ); diff --git a/src/bamglib/write_hdf5.cpp b/src/bamglib/write_hdf5.cpp index 488368eb9..b8bf335e4 100644 --- a/src/bamglib/write_hdf5.cpp +++ b/src/bamglib/write_hdf5.cpp @@ -9,8 +9,7 @@ extern long verbosity; using std::max; using std::min; -WriteHdf5::WriteHdf5(const char *ffname, Int4 nbelem, Int4 nbvertex) - : hdf5_filename(ffname), nbofelem(nbelem), nbofvertex(nbvertex) { +WriteHdf5::WriteHdf5(const char *ffname, Int4 nbelem, Int4 nbvertex) : hdf5_filename(ffname), nbofelem(nbelem), nbofvertex(nbvertex) { // constructeur // creation du fichier hdf5 file_id = H5Fcreate(hdf5_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -70,35 +69,30 @@ void WriteHdf5::WriteHdf5MeshFile2D(float coordinates[][2], int connec[][3]) { // ecriture des coordonnees 2D X et Y des noeuds group_id_coord = H5Gcreate2(file_id, "/Coordinates", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataspace_id_coord = H5Screate_simple(2, dims_coord, NULL); - dataset_id_coord = H5Dcreate2(file_id, "/Coordinates/XY", H5T_IEEE_F32LE, dataspace_id_coord, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_coord = H5Dcreate2(file_id, "/Coordinates/XY", H5T_IEEE_F32LE, dataspace_id_coord, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_coord, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, coordinates); // ecriture des valeurs max des coordonnees aid_max_x = H5Screate_simple(1, dims_x_max, NULL); - attr_max_x = - H5Acreate2(dataset_id_coord, "X_MAX", H5T_IEEE_F32LE, aid_max_x, H5P_DEFAULT, H5P_DEFAULT); + attr_max_x = H5Acreate2(dataset_id_coord, "X_MAX", H5T_IEEE_F32LE, aid_max_x, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(attr_max_x, H5T_NATIVE_FLOAT, &x_max); status = H5Aclose(attr_max_x); status = H5Sclose(aid_max_x); aid_min_x = H5Screate_simple(1, dims_x_min, NULL); - attr_min_x = - H5Acreate2(dataset_id_coord, "X_MIN", H5T_IEEE_F32LE, aid_min_x, H5P_DEFAULT, H5P_DEFAULT); + attr_min_x = H5Acreate2(dataset_id_coord, "X_MIN", H5T_IEEE_F32LE, aid_min_x, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(attr_min_x, H5T_NATIVE_FLOAT, &x_min); status = H5Aclose(attr_min_x); status = H5Sclose(aid_min_x); aid_max_y = H5Screate_simple(1, dims_y_max, NULL); - attr_max_y = - H5Acreate2(dataset_id_coord, "Y_MAX", H5T_IEEE_F32LE, aid_max_y, H5P_DEFAULT, H5P_DEFAULT); + attr_max_y = H5Acreate2(dataset_id_coord, "Y_MAX", H5T_IEEE_F32LE, aid_max_y, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(attr_max_y, H5T_NATIVE_FLOAT, &y_max); status = H5Aclose(attr_max_y); status = H5Sclose(aid_max_y); aid_min_y = H5Screate_simple(1, dims_y_min, NULL); - attr_min_y = - H5Acreate2(dataset_id_coord, "Y_MIN", H5T_IEEE_F32LE, aid_min_y, H5P_DEFAULT, H5P_DEFAULT); + attr_min_y = H5Acreate2(dataset_id_coord, "Y_MIN", H5T_IEEE_F32LE, aid_min_y, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(attr_min_y, H5T_NATIVE_FLOAT, &y_min); status = H5Aclose(attr_min_y); status = H5Sclose(aid_min_y); @@ -111,8 +105,7 @@ void WriteHdf5::WriteHdf5MeshFile2D(float coordinates[][2], int connec[][3]) { group_id_connec = H5Gcreate2(file_id, "/Connectivity", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); dataspace_id_elem2node = H5Screate_simple(2, dims_elem2node, NULL); - dataset_id_elem2node = H5Dcreate2(file_id, "/Connectivity/ELEM2NODE", H5T_STD_I32LE, - dataspace_id_elem2node, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_elem2node = H5Dcreate2(file_id, "/Connectivity/ELEM2NODE", H5T_STD_I32LE, dataspace_id_elem2node, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_elem2node, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, connec); status = H5Dclose(dataset_id_elem2node); status = H5Sclose(dataspace_id_elem2node); @@ -124,22 +117,19 @@ void WriteHdf5::WriteHdf5MeshFile2D(float coordinates[][2], int connec[][3]) { type_id = H5Tcopy(H5T_C_S1); status = H5Tset_size(type_id, 8); dataspace_id_elemtype = H5Screate(H5S_SCALAR); - dataset_id_elemtype = H5Dcreate2(file_id, "/Connectivity/ELEMTYPE", type_id, - dataspace_id_elemtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_elemtype = H5Dcreate2(file_id, "/Connectivity/ELEMTYPE", type_id, dataspace_id_elemtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_elemtype, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, elemtype); status = H5Dclose(dataset_id_elemtype); status = H5Sclose(dataspace_id_elemtype); dataspace_id_nelem = H5Screate_simple(1, dims_nelem, NULL); - dataset_id_nelem = H5Dcreate2(file_id, "/Connectivity/NELEM", H5T_STD_I32LE, dataspace_id_nelem, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_nelem = H5Dcreate2(file_id, "/Connectivity/NELEM", H5T_STD_I32LE, dataspace_id_nelem, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_nelem, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nbofelem); status = H5Dclose(dataset_id_nelem); status = H5Sclose(dataspace_id_nelem); dataspace_id_nnode = H5Screate_simple(1, dims_nnode, NULL); - dataset_id_nnode = H5Dcreate2(file_id, "/Connectivity/NNODE", H5T_STD_I32LE, dataspace_id_nnode, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_nnode = H5Dcreate2(file_id, "/Connectivity/NNODE", H5T_STD_I32LE, dataspace_id_nnode, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_nnode, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &nbofvertex); status = H5Dclose(dataset_id_nnode); status = H5Sclose(dataspace_id_nnode); @@ -150,8 +140,7 @@ void WriteHdf5::WriteHdf5MeshFile2D(float coordinates[][2], int connec[][3]) { type_mesh_id = H5Tcopy(H5T_C_S1); status = H5Tset_size(type_mesh_id, 7); dataspace_id_meshtype = H5Screate(H5S_SCALAR); - dataset_id_meshtype = H5Dcreate2(file_id, "/Connectivity/TYPE", type_mesh_id, - dataspace_id_meshtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_meshtype = H5Dcreate2(file_id, "/Connectivity/TYPE", type_mesh_id, dataspace_id_meshtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_meshtype, type_mesh_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, meshtype); status = H5Dclose(dataset_id_meshtype); status = H5Sclose(dataspace_id_meshtype); @@ -345,8 +334,7 @@ void WriteHdf5::WriteHdf5SolFile2DInit( ) { group_id_data = H5Gcreate2(file_id, "/Data", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } -void WriteHdf5::WriteHdf5SolFile2DAddField(string *fieldname, int result_order, int trans_dim, - int what_type, float *field) { +void WriteHdf5::WriteHdf5SolFile2DAddField(string *fieldname, int result_order, int trans_dim, int what_type, float *field) { // ajout des champs solution dans le groupe /Data string str_data = "/Data/"; @@ -393,8 +381,7 @@ void WriteHdf5::WriteHdf5SolFile2DAddField(string *fieldname, int result_order, strncat(data_type, type_char[what_type].c_str( ), ldata_type); assert(strnlen(data_type, ldata_type) < ldata_type - 2); // verif data_type is long enough dataspace_id_data = H5Screate_simple(2, dims_data, NULL); - dataset_id_data = H5Dcreate2(file_id, char_datafieldname_tot, H5T_IEEE_F32LE, dataspace_id_data, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_data = H5Dcreate2(file_id, char_datafieldname_tot, H5T_IEEE_F32LE, dataspace_id_data, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_data, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, field); type_id = H5Tcopy(H5T_C_S1); status = H5Tset_size(type_id, 17); @@ -422,8 +409,7 @@ void WriteHdf5::WriteHdf5SolFile3DInit( ) { group_id_data = H5Gcreate2(file_id, "/Data", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } -void WriteHdf5::WriteHdf5SolFile3DAddField(string *fieldname, int result_order, int trans_dim, - int what_type, float *field) { +void WriteHdf5::WriteHdf5SolFile3DAddField(string *fieldname, int result_order, int trans_dim, int what_type, float *field) { // ajout des champs solution dans le groupe /Data string str_data = "/Data/"; @@ -470,8 +456,7 @@ void WriteHdf5::WriteHdf5SolFile3DAddField(string *fieldname, int result_order, strncat(data_type, type_char[what_type].c_str( ), ldata_type); assert(strnlen(data_type, ldata_type) < ldata_type - 2); dataspace_id_data = H5Screate_simple(2, dims_data, NULL); - dataset_id_data = H5Dcreate2(file_id, char_datafieldname_tot, H5T_IEEE_F32LE, dataspace_id_data, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset_id_data = H5Dcreate2(file_id, char_datafieldname_tot, H5T_IEEE_F32LE, dataspace_id_data, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id_data, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, field); type_id = H5Tcopy(H5T_C_S1); status = H5Tset_size(type_id, 18); diff --git a/src/bamglib/write_hdf5.hpp b/src/bamglib/write_hdf5.hpp index f05b529e8..99e7608b7 100644 --- a/src/bamglib/write_hdf5.hpp +++ b/src/bamglib/write_hdf5.hpp @@ -45,12 +45,10 @@ class WriteHdf5 { void WriteHdf5MeshFile2D(float coordinates[][2], int connec[][3]); // void WriteHdf5MeshFile3D(float coordinates[][3], int connec[][4]); void WriteHdf5SolFile2DInit( ); - void WriteHdf5SolFile2DAddField(string *fieldname, int result_order, int trans_dim, int what_type, - float *field); + void WriteHdf5SolFile2DAddField(string *fieldname, int result_order, int trans_dim, int what_type, float *field); void WriteHdf5SolFile2DFinalize( ); void WriteHdf5SolFile3DInit( ); - void WriteHdf5SolFile3DAddField(string *fieldname, int result_order, int trans_dim, int what_type, - float *field); + void WriteHdf5SolFile3DAddField(string *fieldname, int result_order, int trans_dim, int what_type, float *field); void WriteHdf5SolFile3DFinalize( ); }; diff --git a/src/bamglib/write_xdmf.cpp b/src/bamglib/write_xdmf.cpp index 0587bb9a1..e2735cb7c 100644 --- a/src/bamglib/write_xdmf.cpp +++ b/src/bamglib/write_xdmf.cpp @@ -12,8 +12,7 @@ int debug_w = 0; // Le nom des fichiers solution doit se finir par .sol.h5 // L'interface ne prend en compte que les elements de type triangle et tetraedre. -WriteXdmf::WriteXdmf(const char *ffname, Int4 nbelem, Int4 nbvertex) - : WXffname(ffname), nbofelem(nbelem), nbofvertex(nbvertex) { +WriteXdmf::WriteXdmf(const char *ffname, Int4 nbelem, Int4 nbvertex) : WXffname(ffname), nbofelem(nbelem), nbofvertex(nbvertex) { // constructeur // recuperation du nom de fichier passe dans l'input // pour creation du nom de fichier xdmf @@ -49,17 +48,14 @@ void WriteXdmf::WriteXdmfMeshFile2D( ) { xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; // nb nodes per element, ici classe triangle donc =3 - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << WXffname << ":/Connectivity/ELEM2NODE\n"; xdmf_file << " \n"; xdmf_file << " \n"; xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << WXffname << ":/Coordinates/XY\n"; xdmf_file << " \n"; xdmf_file << " \n"; @@ -132,24 +128,20 @@ void WriteXdmf::WriteXdmfSolFile2DInit( ) { xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; // nb nodes per element, ici classe triangle donc =3 - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << str_h5_mesh_filename.c_str( ) << ":/Connectivity/ELEM2NODE\n"; xdmf_file << " \n"; xdmf_file << " \n"; xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << str_h5_mesh_filename.c_str( ) << ":/Coordinates/XY\n"; xdmf_file << " \n"; xdmf_file << " \n"; } -void WriteXdmf::WriteXdmfSolFile2DAddField(string *fieldname, int data_type, int result_order, - int trans_dim) { +void WriteXdmf::WriteXdmfSolFile2DAddField(string *fieldname, int data_type, int result_order, int trans_dim) { vector< string > type_char(3); vector< string > res_char(2); @@ -160,16 +152,13 @@ void WriteXdmf::WriteXdmfSolFile2DAddField(string *fieldname, int data_type, int res_char[1] = "Node"; // ecriture des descriptions du ou des champs solution 2D - xdmf_file << " c_str( ) << "\" AttributeType=\"" - << type_char[data_type] << "\" Center=\"" << res_char[result_order] << "\">\n"; + xdmf_file << " c_str( ) << "\" AttributeType=\"" << type_char[data_type] << "\" Center=\"" << res_char[result_order] << "\">\n"; if (result_order == 0) { - xdmf_file << " \n"; } else { - xdmf_file << " \n"; } @@ -209,24 +198,20 @@ void WriteXdmf::WriteXdmfSolFile3DInit( ) { xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; // nb nodes per element, ici classe tetrahedre donc =4 - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << str_h5_mesh_filename.c_str( ) << ":/Connectivity/ELEM2NODE\n"; xdmf_file << " \n"; xdmf_file << " \n"; xdmf_file << " \n"; - xdmf_file << " \n"; + xdmf_file << " \n"; xdmf_file << " " << str_h5_mesh_filename.c_str( ) << ":/Coordinates/XYZ\n"; xdmf_file << " \n"; xdmf_file << " \n"; } -void WriteXdmf::WriteXdmfSolFile3DAddField(string *fieldname, int data_type, int result_order, - int trans_dim) { +void WriteXdmf::WriteXdmfSolFile3DAddField(string *fieldname, int data_type, int result_order, int trans_dim) { vector< string > type_char(3); vector< string > res_char(2); type_char[0] = "Scalar"; @@ -236,16 +221,13 @@ void WriteXdmf::WriteXdmfSolFile3DAddField(string *fieldname, int data_type, int res_char[1] = "Node"; // ecriture des descriptions du ou des champs solution 3D - xdmf_file << " c_str( ) << "\" AttributeType=\"" - << type_char[data_type] << "\" Center=\"" << res_char[result_order] << "\">\n"; + xdmf_file << " c_str( ) << "\" AttributeType=\"" << type_char[data_type] << "\" Center=\"" << res_char[result_order] << "\">\n"; if (result_order == 0) { - xdmf_file << " \n"; } else { - xdmf_file << " \n"; } diff --git a/src/bamglib/write_xdmf.hpp b/src/bamglib/write_xdmf.hpp index c03a88847..1bae5942a 100644 --- a/src/bamglib/write_xdmf.hpp +++ b/src/bamglib/write_xdmf.hpp @@ -29,12 +29,10 @@ class WriteXdmf { void WriteXdmfMeshFile2D( ); // void WriteXdmfMeshFile3D(); void WriteXdmfSolFile2DInit( ); - void WriteXdmfSolFile2DAddField(string* fieldname, int data_type, int result_order, - int trans_dim); + void WriteXdmfSolFile2DAddField(string* fieldname, int data_type, int result_order, int trans_dim); void WriteXdmfSolFile2DFinalize( ); void WriteXdmfSolFile3DInit( ); - void WriteXdmfSolFile3DAddField(string* fieldname, int data_type, int result_order, - int trans_dim); + void WriteXdmfSolFile3DAddField(string* fieldname, int data_type, int result_order, int trans_dim); void WriteXdmfSolFile3DFinalize( ); }; diff --git a/src/bin-win32/launchff++.cpp b/src/bin-win32/launchff++.cpp index 3bd528f66..26faef3d6 100644 --- a/src/bin-win32/launchff++.cpp +++ b/src/bin-win32/launchff++.cpp @@ -38,11 +38,11 @@ const char C = '"'; /*! * */ -char *dirname (const char *pp) { +char *dirname(const char *pp) { int i, l = strlen(pp); - for (i = l-1; i >= 0; i--) + for (i = l - 1; i >= 0; i--) if (pp[i] == '\\') break; - char *dir = new char[l+1]; + char *dir = new char[l + 1]; strcpy(dir, pp); dir[i] = 0; return dir; @@ -51,22 +51,22 @@ char *dirname (const char *pp) { /*! * */ -char *newq (const char *p) { +char *newq(const char *p) { int l = strlen(p); assert(l < 1000); - char *c = new char[l+100]; + char *c = new char[l + 100]; assert(c); c[0] = C; - strcpy(c+1, p); - c[l+1] = C; - c[l+2] = 0; + strcpy(c + 1, p); + c[l + 1] = C; + c[l + 2] = 0; return c; } /*! * */ -int main (int argc, const char **argv) { +int main(int argc, const char **argv) { char filename[MAX_PATH]; const int n100 = 100; const char *ffargv[n100]; @@ -75,13 +75,12 @@ int main (int argc, const char **argv) { const char *dirll = dirname(argv[0]); const char *pp = 0; char ff[1000]; - const char *fe = "\\freefem++.exe";//"C:\\msys64\\home\\hecht\\ff++\\src\\bin-win32\\ar v.exe"; + const char *fe = "\\freefem++.exe"; //"C:\\msys64\\home\\hecht\\ff++\\src\\bin-win32\\ar v.exe"; *ff = 0; strcat(ff, dirll); strcat(ff, fe); - //string cmd="freefem++.exe "; - for (int i = 0; i < n100; ++i) - ffargv[i] = 0; + // string cmd="freefem++.exe "; + for (int i = 0; i < n100; ++i) ffargv[i] = 0; int nffa = 0; ffargv[nffa++] = newq(ff); @@ -92,16 +91,15 @@ int main (int argc, const char **argv) { // cmd += C; // cmd += argv[i]; if (!pp && strlen(argv[i]) > 2) - if (argv[i][1] == ':') - pp = argv[i]; + if (argv[i][1] == ':') pp = argv[i]; // cmd += C; // cmd += " "; ffargv[nffa++] = newq(argv[i]); - if( debug) cout << " ffl: arg " << i << argv[i] << endl; + if (debug) cout << " ffl: arg " << i << argv[i] << endl; } } - if(!pp) { + if (!pp) { // cerr << " Sorry no file name "<< endl; // cerr << " Drag and Drop the file icon on the application icon or double clip on script file" << endl; // cmd += " -wait -log"; @@ -109,13 +107,13 @@ int main (int argc, const char **argv) { OPENFILENAME ofn; ZeroMemory(&filename, sizeof(filename)); ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof( ofn ); - ofn.hwndOwner = NULL; // If you have a window to center over, put its HANDLE here + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = NULL; // If you have a window to center over, put its HANDLE here ofn.lpstrFilter = "freefem++ Files (*.edp)\0*.edp\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrTitle = "Please, select a file"; - ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrTitle = "Please, select a file"; + ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST; if (GetOpenFileNameA(&ofn)) { std::cout << "You chose the file \"" << filename << "\"\n"; @@ -127,35 +125,65 @@ int main (int argc, const char **argv) { else cmd += filename[i] ; */ if (!pp && strlen(filename) > 2) - if (filename[1] == ':') - pp = filename; + if (filename[1] == ':') pp = filename; ffargv[nffa++] = newq(filename); - //cmd += filename; - //cmd += C; - // cout << " system : " << cmd << endl; - //int ret= system(cmd.c_str()); + // cmd += filename; + // cmd += C; + // cout << " system : " << cmd << endl; + // int ret= system(cmd.c_str()); } else { // All this stuff below is to tell you exactly how you messed up above. // Once you've got that fixed, you can often (not always!) reduce it to a 'user cancelled' assumption. - switch (CommDlgExtendedError()) { - case CDERR_DIALOGFAILURE : std::cout << "CDERR_DIALOGFAILURE\n"; break; - case CDERR_FINDRESFAILURE : std::cout << "CDERR_FINDRESFAILURE\n"; break; - case CDERR_INITIALIZATION : std::cout << "CDERR_INITIALIZATION\n"; break; - case CDERR_LOADRESFAILURE : std::cout << "CDERR_LOADRESFAILURE\n"; break; - case CDERR_LOADSTRFAILURE : std::cout << "CDERR_LOADSTRFAILURE\n"; break; - case CDERR_LOCKRESFAILURE : std::cout << "CDERR_LOCKRESFAILURE\n"; break; - case CDERR_MEMALLOCFAILURE : std::cout << "CDERR_MEMALLOCFAILURE\n"; break; - case CDERR_MEMLOCKFAILURE : std::cout << "CDERR_MEMLOCKFAILURE\n"; break; - case CDERR_NOHINSTANCE : std::cout << "CDERR_NOHINSTANCE\n"; break; - case CDERR_NOHOOK : std::cout << "CDERR_NOHOOK\n"; break; - case CDERR_NOTEMPLATE : std::cout << "CDERR_NOTEMPLATE\n"; break; - case CDERR_STRUCTSIZE : std::cout << "CDERR_STRUCTSIZE\n"; break; - case FNERR_BUFFERTOOSMALL : std::cout << "FNERR_BUFFERTOOSMALL\n"; break; - case FNERR_INVALIDFILENAME : std::cout << "FNERR_INVALIDFILENAME\n"; break; - case FNERR_SUBCLASSFAILURE : std::cout << "FNERR_SUBCLASSFAILURE\n"; break; - default : std::cout << "You cancelled.\n"; + switch (CommDlgExtendedError( )) { + case CDERR_DIALOGFAILURE: + std::cout << "CDERR_DIALOGFAILURE\n"; + break; + case CDERR_FINDRESFAILURE: + std::cout << "CDERR_FINDRESFAILURE\n"; + break; + case CDERR_INITIALIZATION: + std::cout << "CDERR_INITIALIZATION\n"; + break; + case CDERR_LOADRESFAILURE: + std::cout << "CDERR_LOADRESFAILURE\n"; + break; + case CDERR_LOADSTRFAILURE: + std::cout << "CDERR_LOADSTRFAILURE\n"; + break; + case CDERR_LOCKRESFAILURE: + std::cout << "CDERR_LOCKRESFAILURE\n"; + break; + case CDERR_MEMALLOCFAILURE: + std::cout << "CDERR_MEMALLOCFAILURE\n"; + break; + case CDERR_MEMLOCKFAILURE: + std::cout << "CDERR_MEMLOCKFAILURE\n"; + break; + case CDERR_NOHINSTANCE: + std::cout << "CDERR_NOHINSTANCE\n"; + break; + case CDERR_NOHOOK: + std::cout << "CDERR_NOHOOK\n"; + break; + case CDERR_NOTEMPLATE: + std::cout << "CDERR_NOTEMPLATE\n"; + break; + case CDERR_STRUCTSIZE: + std::cout << "CDERR_STRUCTSIZE\n"; + break; + case FNERR_BUFFERTOOSMALL: + std::cout << "FNERR_BUFFERTOOSMALL\n"; + break; + case FNERR_INVALIDFILENAME: + std::cout << "FNERR_INVALIDFILENAME\n"; + break; + case FNERR_SUBCLASSFAILURE: + std::cout << "FNERR_SUBCLASSFAILURE\n"; + break; + default: + std::cout << "You cancelled.\n"; } - //int ret= system(cmd.c_str()); + // int ret= system(cmd.c_str()); return 1; } } @@ -164,8 +192,7 @@ int main (int argc, const char **argv) { if (debug) cout << " ffl: file:" << pp << endl; int i = 0; dir = dirname(pp); - if (debug) - cout << " ffl: chdir to " << dir << endl; + if (debug) cout << " ffl: chdir to " << dir << endl; _chdir(dir); delete[] dir; } @@ -178,8 +205,9 @@ int main (int argc, const char **argv) { for (int i = 0; i < n100; ++i) if (ffargv[i]) cout << i << " " << ffargv[i] << endl; - else break; - cout << " call "< #include #include @@ -54,513 +54,472 @@ using namespace std; #include "PlotStream.hpp" #include "BamgFreeFem.hpp" #include -const Fem2D::Mesh *bamg2msh( bamg::Triangles* tTh,bool renumbering) -{ +const Fem2D::Mesh *bamg2msh(bamg::Triangles *tTh, bool renumbering) { using namespace bamg; - bamg::Triangles & th (*tTh); - tTh->ReNumberingTheTriangleBySubDomain(!renumbering);// just compress - Int4 i,j,k=0; - int nv = tTh->nbv; - int nt = tTh->nbt - tTh->NbOutT; - int neb = tTh->nbe; + bamg::Triangles &th(*tTh); + tTh->ReNumberingTheTriangleBySubDomain(!renumbering); // just compress + Int4 i, j, k = 0; + int nv = tTh->nbv; + int nt = tTh->nbt - tTh->NbOutT; + int neb = tTh->nbe; int nbcrakev = 0; - tTh->ReMakeTriangleContainingTheVertex(); - Fem2D::Triangle * t = new Fem2D::Triangle[nt] ; - Fem2D::BoundaryEdge * b_e = new Fem2D::BoundaryEdge[neb]; + tTh->ReMakeTriangleContainingTheVertex( ); + Fem2D::Triangle *t = new Fem2D::Triangle[nt]; + Fem2D::BoundaryEdge *b_e = new Fem2D::BoundaryEdge[neb]; Fem2D::Vertex vbase; Fem2D::Vertex *vb(&vbase); - if (verbosity>5) - cout << " -- Before cracking mesh: Nb Triangles = " << nt << " Nb of Vertices " << nv << endl; - for ( i=0;i= 0 ) && (i <3)); - // turn around the vertex v - TriangleAdjacent ta(tbegin,EdgesVertexTriangle[i][0]);// previous edge - int k=0; - do { - int kv = VerticesOfTriangularEdge[ta][1]; - k++; - Triangle * tt (ta); - throwassert( &v == & (* tt)[kv] ); - if ( ta.Cracked() ) - { - if ( kk == 0) tbegin=ta,kkk=0; // begin by a cracked edge => restart - if ( kkk ) { kc =1;vv = vb + nv++; kkk = 0; } // new vertex if use - kk++; - // number of cracked edge view - } - if ( tt->link ) { // if good triangles store the value - int it = th.Number(tt); - throwassert(it < nt); - t[it](kv) = vv; - kkk++; - } else if (kk) { // crack + boundary - if ( kkk ) { kc =1;vv = vb + nv++; kkk = 0; } // new vertex if use - } + if (verbosity > 5) cout << " -- Before cracking mesh: Nb Triangles = " << nt << " Nb of Vertices " << nv << endl; + for (i = 0; i < nt; i++) // unset all triangles + for (j = 0; j < 3; j++) t[i](j) = 0; + for (int iv = 0; iv < th.nbv; iv++) // vertex + { + const Vertex &v(th[iv]); + int kk = 0; // nb cracked + int kc = 0; + int kkk = 0; // nb triangle with same number + Triangle *tbegin = v.t; + Fem2D::Vertex *vv = vb + iv; + int i = v.vint; + throwassert(tbegin && (i >= 0) && (i < 3)); + // turn around the vertex v + TriangleAdjacent ta(tbegin, EdgesVertexTriangle[i][0]); // previous edge + int k = 0; + do { + int kv = VerticesOfTriangularEdge[ta][1]; + k++; + Triangle *tt(ta); + throwassert(&v == &(*tt)[kv]); + if (ta.Cracked( )) { + if (kk == 0) tbegin = ta, kkk = 0; // begin by a cracked edge => restart + if (kkk) { + kc = 1; + vv = vb + nv++; + kkk = 0; + } // new vertex if use + kk++; + // number of cracked edge view + } + if (tt->link) { // if good triangles store the value + int it = th.Number(tt); + throwassert(it < nt); + t[it](kv) = vv; + kkk++; + } else if (kk) { // crack + boundary + if (kkk) { + kc = 1; + vv = vb + nv++; + kkk = 0; + } // new vertex if use + } - ta = Next(ta).Adj(); - } while ( (tbegin != ta)); - throwassert(k); - if (kc) nbcrakev++; - } - double badvalue=12345e100; - Fem2D::Vertex * v = new Fem2D::Vertex[nv]; - for(int i=0; i=0 && k < nv); - Vertex & thv(th(i)[j]); - v[k].x = thv.r.x; - v[k].y = thv.r.y; - v[k].lab = thv.ref(); - } - } - int kerr=0; - - for(int i=0; i= 0 && k < nv); + Vertex &thv(th(i)[j]); + v[k].x = thv.r.x; + v[k].y = thv.r.y; + v[k].lab = thv.ref( ); } + } + int kerr = 0; + + for (int i = 0; i < nv; ++i) + if (v[i].x == badvalue) kerr++; + if (kerr) { + cerr << " bamg2msh: Error: missing " << kerr << " vertices ???? " << endl; + cerr << " I May be: Some giving point are outside the domain ???? " << endl; + ExecError("Buildmesh : bamg2msh missing vertices"); + } // warning in cracked edges // construction of the edges -- - if (nbcrakev && verbosity>2) - cout << " -- Nb of craked vertices = " << nbcrakev << " Nb of created vertices " << nv - th.nbv << endl; + if (nbcrakev && verbosity > 2) cout << " -- Nb of craked vertices = " << nbcrakev << " Nb of created vertices " << nv - th.nbv << endl; - - for (i=0;inbe;i++) - { - int i0=tTh->Number(tTh->edges[i][0]),i1=tTh->Number(tTh->edges[i][1]); - throwassert(i0>=0 && i0 =0 && i1 199) cout << " bamg2msh edge "<< i0 << " " << i1 << " " << tTh->edges[i].ref << endl; - b_e[i]=Fem2D::BoundaryEdge(v,i0,i1,tTh->edges[i].ref); - } + for (i = 0; i < tTh->nbe; i++) { + int i0 = tTh->Number(tTh->edges[i][0]), i1 = tTh->Number(tTh->edges[i][1]); + throwassert(i0 >= 0 && i0 < nv); + throwassert(i1 >= 0 && i1 < nv); + if (verbosity > 199) cout << " bamg2msh edge " << i0 << " " << i1 << " " << tTh->edges[i].ref << endl; + b_e[i] = Fem2D::BoundaryEdge(v, i0, i1, tTh->edges[i].ref); + } Int4 *reft = new Int4[tTh->nbt]; - //Int4 nbref = - long nerr=0; + // Int4 nbref = + long nerr = 0; tTh->ConsRefTriangle(reft); - for( i=0,k=0;inbt;i++) - if(tTh->triangles[i].link) - { - - Fem2D::R2 A(t[k][0]),B(t[k][1]),C(t[k][2]); - t[k].area = (( B-A)^(C-A))*0.5 ; - nerr += t[k].area <=0; - t[k].lab = tTh->subdomains[reft[i]].ref; // a faire - throwassert(k == i); - k++; - } - delete [] reft; - throwassert ( nt == k); - tTh->ReMakeTriangleContainingTheVertex(); - - if (verbosity) - cout << " -- mesh: Nb of Triangles = " << setw(6) << nt << ", Nb of Vertices " << nv << endl; - if(nerr) - { - cerr << "Fatal error: Number of Negative triangles "<< nerr << endl; - delete [] v; - delete [] t; - delete [] b_e; - ExecError("bamg2mesh error negative triangle "); + for (i = 0, k = 0; i < tTh->nbt; i++) + if (tTh->triangles[i].link) { + + Fem2D::R2 A(t[k][0]), B(t[k][1]), C(t[k][2]); + t[k].area = ((B - A) ^ (C - A)) * 0.5; + nerr += t[k].area <= 0; + t[k].lab = tTh->subdomains[reft[i]].ref; // a faire + throwassert(k == i); + k++; + } + delete[] reft; + throwassert(nt == k); + tTh->ReMakeTriangleContainingTheVertex( ); + + if (verbosity) cout << " -- mesh: Nb of Triangles = " << setw(6) << nt << ", Nb of Vertices " << nv << endl; + if (nerr) { + cerr << "Fatal error: Number of Negative triangles " << nerr << endl; + delete[] v; + delete[] t; + delete[] b_e; + ExecError("bamg2mesh error negative triangle "); } { - Fem2D::Mesh *m = new Fem2D::Mesh(nv,nt,neb,v,t,b_e); - if (renumbering) m->renum(); - m->MakeQuadTree(); + Fem2D::Mesh *m = new Fem2D::Mesh(nv, nt, neb, v, t, b_e); + if (renumbering) m->renum( ); + m->MakeQuadTree( ); return m; } } -Fem2D::Mesh *bamg2msh(const bamg::Geometry &Gh) -{ +Fem2D::Mesh *bamg2msh(const bamg::Geometry &Gh) { // ------------------ - int nv= Gh.nbv; - int neb=Gh.nbe; - Fem2D::Triangle * t = 0 ; - Fem2D::BoundaryEdge * b_e = new Fem2D::BoundaryEdge[neb]; - Fem2D::Vertex *v = new Fem2D::Vertex[nv] ; - for (int i=0;iMakeQuadTree(); + Fem2D::Mesh *m = new Fem2D::Mesh(nv, 0, neb, v, t, b_e); + m->MakeQuadTree( ); return m; } // ------------------ } - - bamg::Triangles * msh2bamg(const Fem2D::Mesh & Th,double cutoffradian,long * reqedgeslab,int nreqedgeslab) +bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian, long *reqedgeslab, int nreqedgeslab) { using namespace bamg; - Triangles *Tn=new Triangles(Th.nv); + Triangles *Tn = new Triangles(Th.nv); Tn->nbv = Th.nv; Tn->nbt = Th.nt; Tn->nbe = Th.neb; - Tn->name= new char[strlen("msh2bamg")+1]; - strcpy(Tn->name,"msh2bamg"); + Tn->name = new char[strlen("msh2bamg") + 1]; + strcpy(Tn->name, "msh2bamg"); throwassert(Tn->triangles); - Tn->edges = new Edge [Th.neb]; + Tn->edges = new Edge[Th.neb]; Int4 i; Metric Mid(1.); - for (i = 0; i < Th.nv; i++) - { - Tn->vertices[i].r.x = Th(i).x; - Tn->vertices[i].r.y = Th(i).y; - Tn->vertices[i].m=Mid; - Tn->vertices[i].ReferenceNumber = Th(i).lab; - } - - for (i = 0; i < Th.nt; i++) - { - int i1 = Th(Th[i][0]); - int i2 = Th(Th[i][1]); - int i3 = Th(Th[i][2]); - Tn->triangles[i]= Triangle( Tn,i1 ,i2 ,i3 ); - Tn->triangles[i].color = Th[i].lab; - } - // Real8 cutoffradian = -1; - // add code un change boundary part ... frev 2009 JYU FH - set labreq; - if(nreqedgeslab && verbosity) cout << " label of required edges " ; - for (int i=0; i edges[i].v[0] = Tn->vertices + Th(Th.bedges[i][0]); - Tn->edges[i].v[1] = Tn->vertices + Th(Th.bedges[i][1]); - Tn->edges[i].ref = Th.bedges[i].lab; - Tn->edges[i].on = 0; - if( labreq.find( Tn->edges[i].ref) != labreq.end()) - { - k++; - Tn->edges[i].on = &paszero; - } + for (i = 0; i < Th.nv; i++) { + Tn->vertices[i].r.x = Th(i).x; + Tn->vertices[i].r.y = Th(i).y; + Tn->vertices[i].m = Mid; + Tn->vertices[i].ReferenceNumber = Th(i).lab; + } + for (i = 0; i < Th.nt; i++) { + int i1 = Th(Th[i][0]); + int i2 = Th(Th[i][1]); + int i3 = Th(Th[i][2]); + Tn->triangles[i] = Triangle(Tn, i1, i2, i3); + Tn->triangles[i].color = Th[i].lab; + } + // Real8 cutoffradian = -1; + // add code un change boundary part ... frev 2009 JYU FH + set< int > labreq; + if (nreqedgeslab && verbosity) cout << " label of required edges "; + for (int i = 0; i < nreqedgeslab; ++i) { + if (verbosity) cout << " " << reqedgeslab[i]; + labreq.insert(reqedgeslab[i]); + } + bamg::GeometricalEdge paszero; // add JYU fevr 2009 for required edge .... + if (nreqedgeslab && verbosity) cout << endl; + int k = 0; + for (i = 0; i < Th.neb; i++) { + Tn->edges[i].v[0] = Tn->vertices + Th(Th.bedges[i][0]); + Tn->edges[i].v[1] = Tn->vertices + Th(Th.bedges[i][1]); + Tn->edges[i].ref = Th.bedges[i].lab; + Tn->edges[i].on = 0; + if (labreq.find(Tn->edges[i].ref) != labreq.end( )) { + k++; + Tn->edges[i].on = &paszero; } - if(verbosity)cout << " number of required edges : "<< k << endl; - + } + if (verbosity) cout << " number of required edges : " << k << endl; Tn->ConsGeometry(cutoffradian); - Tn->Gh.AfterRead(); - Tn->SetIntCoor(); - Tn->FillHoleInMesh(); + Tn->Gh.AfterRead( ); + Tn->SetIntCoor( ); + Tn->FillHoleInMesh( ); return Tn; } - - bamg::Triangles * msh2bamg(const Fem2D::Mesh & Th,double cutoffradian, - int nbdfv, int * ndfv,int nbdfe, int * ndfe, - long * reqedgeslab,int nreqedgeslab) -{ +bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian, int nbdfv, int *ndfv, int nbdfe, int *ndfe, long *reqedgeslab, int nreqedgeslab) { using namespace bamg; - Triangles *Tn=new Triangles(Th.nv); - KN equiedges(Th.neb); - for(int i=0;i kk(Th.neb),kn(Th.neb); - kk=0; - for(int i=0;i " << dk0 << " " << dk1 << endl; - ExecError("bug periodic mesh in ??? "); - } - equiedges[i]=2*k+sens; - - } + Triangles *Tn = new Triangles(Th.nv); + KN< int > equiedges(Th.neb); + for (int i = 0; i < Th.neb; i++) equiedges[i] = 2 * i; + if (nbdfe != 0) { + KN< int > kk(Th.neb), kn(Th.neb); + kk = 0; + for (int i = 0; i < Th.neb; i++) { + int df = ndfe[i]; + kk[df]++; + if (kk[df] == 1) + kn[df] = i; + else { + int k = kn[df], sens = 0; + int di0 = ndfv[Th(Th.bedges[i][0])]; + int di1 = ndfv[Th(Th.bedges[i][1])]; + int dk0 = ndfv[Th(Th.bedges[k][0])]; + int dk1 = ndfv[Th(Th.bedges[k][1])]; + if ((di0 == dk0) && (di1 == dk1)) + sens = 0; + else if ((di1 == dk0) && (di0 == dk1)) + sens = 1; + else { + cout << "Error in periodic mesh " << di0 << " " << di1 << " <=> " << dk0 << " " << dk1 << endl; + ExecError("bug periodic mesh in ??? "); + } + equiedges[i] = 2 * k + sens; } + } - }; // a faire pour les maillages periodique + }; // a faire pour les maillages periodique Tn->nbv = Th.nv; Tn->nbt = Th.nt; Tn->nbe = Th.neb; - Tn->name= new char[strlen("msh2bamg")+1]; - strcpy(Tn->name,"msh2bamg"); + Tn->name = new char[strlen("msh2bamg") + 1]; + strcpy(Tn->name, "msh2bamg"); throwassert(Tn->triangles); - Tn->edges = new Edge [Th.neb]; + Tn->edges = new Edge[Th.neb]; Int4 i; - Metric Mid(1.); - for (i = 0; i < Th.nv; i++) - { - Tn->vertices[i].r.x = Th(i).x; - Tn->vertices[i].r.y = Th(i).y; - Tn->vertices[i].ReferenceNumber = Th(i).lab; - Tn->vertices[i].m=Mid; - } - - for (i = 0; i < Th.nt; i++) - { - int i1 = Th(Th[i][0]); - int i2 = Th(Th[i][1]); - int i3 = Th(Th[i][2]); - Tn->triangles[i]= Triangle( Tn,i1 ,i2 ,i3 ); - Tn->triangles[i].color = Th[i].lab; - } + Metric Mid(1.); + for (i = 0; i < Th.nv; i++) { + Tn->vertices[i].r.x = Th(i).x; + Tn->vertices[i].r.y = Th(i).y; + Tn->vertices[i].ReferenceNumber = Th(i).lab; + Tn->vertices[i].m = Mid; + } - // add code un change boundary part ... frev 2009 JYU FH - set labreq; - if(nreqedgeslab && verbosity) cout << " label of required edges " ; - for (int i=0; i triangles[i] = Triangle(Tn, i1, i2, i3); + Tn->triangles[i].color = Th[i].lab; + } - for (i = 0; i < Th.neb; i++) - { - Tn->edges[i].v[0] = Tn->vertices + Th(Th.bedges[i][0]); - Tn->edges[i].v[1] = Tn->vertices + Th(Th.bedges[i][1]); - Tn->edges[i].ref = Th.bedges[i].lab; - Tn->edges[i].on = 0; - if( labreq.find( Tn->edges[i].ref) != labreq.end()) - { - k++; - Tn->edges[i].on = &paszero; - } + // add code un change boundary part ... frev 2009 JYU FH + set< int > labreq; + if (nreqedgeslab && verbosity) cout << " label of required edges "; + for (int i = 0; i < nreqedgeslab; ++i) { + if (verbosity) cout << " " << reqedgeslab[i]; + labreq.insert(reqedgeslab[i]); + } + bamg::GeometricalEdge paszero; // add JYU fevr 2009 for required edge .... + if (nreqedgeslab && verbosity) cout << endl; + int k = 0; + + for (i = 0; i < Th.neb; i++) { + Tn->edges[i].v[0] = Tn->vertices + Th(Th.bedges[i][0]); + Tn->edges[i].v[1] = Tn->vertices + Th(Th.bedges[i][1]); + Tn->edges[i].ref = Th.bedges[i].lab; + Tn->edges[i].on = 0; + if (labreq.find(Tn->edges[i].ref) != labreq.end( )) { + k++; + Tn->edges[i].on = &paszero; } - Tn->ConsGeometry(cutoffradian,equiedges); - Tn->Gh.AfterRead(); - Tn->SetIntCoor(); - Tn->FillHoleInMesh(); + } + Tn->ConsGeometry(cutoffradian, equiedges); + Tn->Gh.AfterRead( ); + Tn->SetIntCoor( ); + Tn->FillHoleInMesh( ); return Tn; } -extern double genrand_res53(void) ; -double NormalDistrib(double sigma) -{ - if( sigma <=0.) return 0.; - double rand = genrand_res53() ; - const double TWOPI = 3.14159265358979323846264338328*2.; - return sigma*sqrt(-2.0*log(rand))*cos(TWOPI*rand); +extern double genrand_res53(void); +double NormalDistrib(double sigma) { + if (sigma <= 0.) return 0.; + double rand = genrand_res53( ); + const double TWOPI = 3.14159265358979323846264338328 * 2.; + return sigma * sqrt(-2.0 * log(rand)) * cos(TWOPI * rand); } // (stack,b,true,0,true); bool Requiredboundary=true, KNM *pintern=0, double alea=0) -const Fem2D::Mesh * BuildMesh(Stack stack,const Fem2D::MeshL **ppmshL , int nbmshL, bool justboundary,int nbvmax,bool Requiredboundary,KNM *pintern,double alea,bool SplitEdgeWith2Boundary) -{ - if(alea) Requiredboundary=1; - int nbvinter=0; - if( pintern) - { - nbvinter=pintern->N(); - if((pintern->M() != 2 ) && ( pintern->M()!=3)) - { - cout << " point m = " <M()< *pintern, double alea, + bool SplitEdgeWith2Boundary) { + if (alea) Requiredboundary = 1; + int nbvinter = 0; + if (pintern) { + nbvinter = pintern->N( ); + if ((pintern->M( ) != 2) && (pintern->M( ) != 3)) { + cout << " point m = " << pintern->M( ) << endl; + ExecError("Error: BuildMesh number of column of internal point (point=) must be 2 or 3!"); } - int brefintp= -2000000000; + } + int brefintp = -2000000000; using namespace bamg; using bamg::Abs; using bamg::Max; using bamg::Min; using bamg::Pi; using Fem2D::MeshL; - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; - - int nbvx=nbvinter,nbe=0,nbsd=0; - for (int k=0; knv; - nbe += pmshL->nt;; - // nbsd++; + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; + + int nbvx = nbvinter, nbe = 0, nbsd = 0; + for (int k = 0; k < nbmshL; ++k) { + const MeshL *pmshL = ppmshL[k]; + nbvx += pmshL->nv; + nbe += pmshL->nt; + ; + // nbsd++; } - Geometry * Gh = new Geometry; - - if(verbosity>2) - cout <<"\t\t" << " Begin: ConstGeometry from nb Mesh L " << nbsd << " Requiredboundary " << Requiredboundary << endl; - const char * filename = "FREEFEM.gh"; - Gh->name=new char [strlen(filename)+1]; - strcpy(Gh->name,filename); - Real8 Hmin = HUGE_VAL;// the infinie value - Int4 hvertices =0; - Int4 i,nn,n; - Gh->MaximalAngleOfCorner =30.00*Pi/180.0; + Geometry *Gh = new Geometry; + + if (verbosity > 2) cout << "\t\t" << " Begin: ConstGeometry from nb Mesh L " << nbsd << " Requiredboundary " << Requiredboundary << endl; + const char *filename = "FREEFEM.gh"; + Gh->name = new char[strlen(filename) + 1]; + strcpy(Gh->name, filename); + Real8 Hmin = HUGE_VAL; // the infinie value + Int4 hvertices = 0; + Int4 i, nn, n; + Gh->MaximalAngleOfCorner = 30.00 * Pi / 180.0; Gh->nbv = 0; Gh->nbvx = nbvx; Gh->nbe = nbe; Gh->edges = new GeometricalEdge[Gh->nbe]; - bamg::Vertex *vertices = new Vertex[Gh->nbvx];// correction 2009/07/03 - double lmin= HUGE_VAL; + bamg::Vertex *vertices = new Vertex[Gh->nbvx]; // correction 2009/07/03 + double lmin = HUGE_VAL; // generation des points et des lignes - i=0; - double zmin = HUGE_VAL, zmax = -HUGE_VAL; - for (int k=0; k1) cout<< " buildmesh MeshL: zmin "<< zmin << " zmax "<< zmax << endl; - /* - for (E_BorderN const * k=b;k;k=k->next) - { - int nbd = k->NbBorder(stack); - for(int index=0; indexb->xfrom); // a faire - double & t = * k->var(stack),tt; - double a(k->from(stack)),b(k->to(stack)); - long * indx = k->index(stack); - if(indx) *indx = index; - else ffassert(index==0); - n=Max(Abs(k->Nbseg(stack,index)),1L); - tt=t=a; - double delta = (b-a)/n; - for ( nn=0;nn<=n;nn++,i++, tt += delta) - { - t = tt; - if (nn==n) t=b; // to remove roundoff error - if( nn >0 && nn < n) { t += NormalDistrib(alea); } // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr - mp.label = k->label(); - k->code(stack); // compute x,y, label - vertices[i].r.x=mp.P.x; - vertices[i].r.y=mp.P.y; - vertices[i].ReferenceNumber= mp.label; - vertices[i].color = i; - if (nn>0) { - lmin=min(lmin,Norme2_2( vertices[i].r-vertices[i-1].r)); - } - } + i = 0; + double zmin = HUGE_VAL, zmax = -HUGE_VAL; + for (int k = 0; k < nbmshL; ++k) { + const MeshL *pmshL = ppmshL[k]; + const MeshL &Tl = *pmshL; + for (int v = 0; v < Tl.nv; ++v, i++) { + vertices[i].r.x = Tl.vertices[v].x; + vertices[i].r.y = Tl.vertices[v].y; + zmin = min(zmin, Tl.vertices[v].z); + zmax = max(zmax, Tl.vertices[v].z); + vertices[i].ReferenceNumber = Tl.vertices[v].lab; + vertices[i].color = i; } + for (int e = 0; e < Tl.nt; ++e) lmin = min(lmin, Tl[e].mesure( )); + } + if (verbosity > 1) cout << " buildmesh MeshL: zmin " << zmin << " zmax " << zmax << endl; + /* + for (E_BorderN const * k=b;k;k=k->next) + { + int nbd = k->NbBorder(stack); + for(int index=0; indexb->xfrom); // a faire + double & t = * k->var(stack),tt; + double a(k->from(stack)),b(k->to(stack)); + long * indx = k->index(stack); + if(indx) *indx = index; + else ffassert(index==0); + n=Max(Abs(k->Nbseg(stack,index)),1L); + tt=t=a; + double delta = (b-a)/n; + for ( nn=0;nn<=n;nn++,i++, tt += delta) + { + t = tt; + if (nn==n) t=b; // to remove roundoff error + if( nn >0 && nn < n) { t += NormalDistrib(alea); } // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + mp.label = k->label(); + k->code(stack); // compute x,y, label + vertices[i].r.x=mp.P.x; + vertices[i].r.y=mp.P.y; + vertices[i].ReferenceNumber= mp.label; + vertices[i].color = i; + if (nn>0) { + lmin=min(lmin,Norme2_2( vertices[i].r-vertices[i-1].r)); + } + } + } } - */ - // add interna point - if(pintern) - { - for(int k=0; kpmin = vertices[0].r; - Gh->pmax = vertices[0].r; + long nbv = 0; + Gh->pmin = vertices[0].r; + Gh->pmax = vertices[0].r; // recherche des extrema des vertices pmin,pmax - for (i=0;ipmin.x = Min(Gh->pmin.x,vertices[i].r.x); - Gh->pmin.y = Min(Gh->pmin.y,vertices[i].r.y); - Gh->pmax.x = Max(Gh->pmax.x,vertices[i].r.x); - Gh->pmax.y = Max(Gh->pmax.y,vertices[i].r.y); - } + for (i = 0; i < nbvprev; i++) { + Gh->pmin.x = Min(Gh->pmin.x, vertices[i].r.x); + Gh->pmin.y = Min(Gh->pmin.y, vertices[i].r.y); + Gh->pmax.x = Max(Gh->pmax.x, vertices[i].r.x); + Gh->pmax.y = Max(Gh->pmax.y, vertices[i].r.y); + } - double diameter=Max(Gh->pmax.x-Gh->pmin.x,Gh->pmax.y-Gh->pmin.y); - Gh->coefIcoor= (MaxICoor)/diameter; - Icoor1 epsI = (Icoor1) (Gh->coefIcoor*eps); - ffassert(Gh->coefIcoor >0); + double diameter = Max(Gh->pmax.x - Gh->pmin.x, Gh->pmax.y - Gh->pmin.y); + Gh->coefIcoor = (MaxICoor) / diameter; + Icoor1 epsI = (Icoor1)(Gh->coefIcoor * eps); + ffassert(Gh->coefIcoor > 0); - if(lmin2) - { - cout <<"\t\t" << " Geom: min="<< Gh->pmin << "max ="<< Gh->pmax - << " hmin = " << Gh->MinimalHmin() << endl; - } + if (verbosity > 2) { + cout << "\t\t" << " Geom: min=" << Gh->pmin << "max =" << Gh->pmax << " hmin = " << Gh->MinimalHmin( ) << endl; + } nbv = 0; - { // find common point + { // find common point QuadTree quadtree; Metric Id(1.); - for ( i=0;itoI2(vertices[i].r); - vertices[i].m = Id; - Vertex *v= quadtree.ToClose(vertices[i],eps,epsI,epsI) ; - // quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); - if( v && Norme1(v->r - vertices[i]) < eps ) - { vertices[i].color=v->color; } - else {quadtree.Add(vertices[i]); - vertices[i].color = nbv++;} + for (i = 0; i < nbvprev; i++) { + vertices[i].i = Gh->toI2(vertices[i].r); + vertices[i].m = Id; + Vertex *v = quadtree.ToClose(vertices[i], eps, epsI, epsI); + // quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); + if (v && Norme1(v->r - vertices[i]) < eps) { + vertices[i].color = v->color; + } else { + quadtree.Add(vertices[i]); + vertices[i].color = nbv++; } - } // to delete quadtree - if (verbosity>1) - cout << " Nb of common points " << nbvprev-nbv < 1) cout << " Nb of common points " << nbvprev - nbv << endl; Gh->nbvx = nbv; Gh->nbv = nbv; @@ -571,245 +530,221 @@ const Fem2D::Mesh * BuildMesh(Stack stack,const Fem2D::MeshL **ppmshL , int nb const Direction NoDirOfSearch; // compression of points int kkk; - for ( i=0,kkk=0;kkkvertices[i].r.x = vertices[kkk].r.x ; - Gh->vertices[i].r.y = vertices[kkk].r.y; - throwassert(Gh->vertices[i].IsThe()); - Gh->vertices[i].ReferenceNumber = vertices[kkk].ReferenceNumber ; - Gh->vertices[i].DirOfSearch = NoDirOfSearch; - Gh->vertices[i].color =0; - Gh->vertices[i].Set(); - if(Requiredboundary) - Gh->vertices[i].SetRequired(); - - if(Gh->vertices[i].ReferenceNumber < 0) - Gh->vertices[i].SetRequired(); - - i++; - } + Gh->vertices[i].r.x = vertices[kkk].r.x; + Gh->vertices[i].r.y = vertices[kkk].r.y; + throwassert(Gh->vertices[i].IsThe( )); + Gh->vertices[i].ReferenceNumber = vertices[kkk].ReferenceNumber; + Gh->vertices[i].DirOfSearch = NoDirOfSearch; + Gh->vertices[i].color = 0; + Gh->vertices[i].Set( ); + if (Requiredboundary) Gh->vertices[i].SetRequired( ); + + if (Gh->vertices[i].ReferenceNumber < 0) Gh->vertices[i].SetRequired( ); + + i++; } - throwassert(i==nbv); - R2 zero2(0,0); - if(verbosity>5) - cout <<"\t\t" << " Record Edges: Nb of Edge " << Gh->nbe < 5) cout << "\t\t" << " Record Edges: Nb of Edge " << Gh->nbe << endl; throwassert(Gh->edges); - throwassert (Gh->nbv >0); - Real8 *len =0; - if (!hvertices) - { - len = new Real8[Gh->nbv]; - for(i=0;inbv;i++) - len[i]=0; - } - int nnn=0; - i=0; - for (int k=0; knbv > 0); + Real8 *len = 0; + if (!hvertices) { + len = new Real8[Gh->nbv]; + for (i = 0; i < Gh->nbv; i++) len[i] = 0; + } + int nnn = 0; + i = 0; + for (int k = 0; k < nbmshL; ++k) { + const MeshL *pmshL = ppmshL[k]; + const MeshL &Tl = *pmshL; + + for (int e = 0; e < Tl.nt; ++e, ++i) { + // PB retrouve i1, i2 avant compression ... - int i1 = Tl(e,0)+nnn; - int i2 = Tl(e,1)+nnn; + int i1 = Tl(e, 0) + nnn; + int i2 = Tl(e, 1) + nnn; // apres compression - i1 = vertices[i1].color; - i2 = vertices[i2].color; + i1 = vertices[i1].color; + i2 = vertices[i2].color; throwassert(i1 >= 0 && i1 < nbv); throwassert(i2 >= 0 && i2 < nbv); Gh->edges[i].ref = Tl[e].lab; - Gh->edges[i].v[0]= Gh->vertices + i1; - Gh->edges[i].v[1]= Gh->vertices + i2; - R2 x12 = Gh->vertices[i2].r-Gh->vertices[i1].r; - Real8 l12=Norme2(x12); - Gh->edges[i].tg[0]=zero2; - Gh->edges[i].tg[1]=zero2; + Gh->edges[i].v[0] = Gh->vertices + i1; + Gh->edges[i].v[1] = Gh->vertices + i2; + R2 x12 = Gh->vertices[i2].r - Gh->vertices[i1].r; + Real8 l12 = Norme2(x12); + Gh->edges[i].tg[0] = zero2; + Gh->edges[i].tg[1] = zero2; Gh->edges[i].SensAdj[0] = Gh->edges[i].SensAdj[1] = -1; Gh->edges[i].Adj[0] = Gh->edges[i].Adj[1] = 0; Gh->edges[i].flag = 0; - Gh->edges[i].link=0; + Gh->edges[i].link = 0; - if(Requiredboundary) - Gh->edges[i].SetRequired(); + if (Requiredboundary) Gh->edges[i].SetRequired( ); - if (!hvertices) - { - Gh->vertices[i1].color++; - Gh->vertices[i2].color++; - len[i1] += l12; - len[i2] += l12; - } + if (!hvertices) { + Gh->vertices[i1].color++; + Gh->vertices[i2].color++; + len[i1] += l12; + len[i2] += l12; + } - Hmin = Min(Hmin,l12); + Hmin = Min(Hmin, l12); } - nnn += Tl.nv; + nnn += Tl.nv; } - /* - for (E_BorderN const * k=b;k;k=k->next) + /* + for (E_BorderN const * k=b;k;k=k->next) - { int nbd = k->NbBorder(stack); - for(int index=0; indexvar(stack); - double a(k->from(stack)),b(k->to(stack)); - n=Max(Abs(k->Nbseg(stack,index)),1L); - long * indx = (k->index(stack)); - if(indx) *indx = index; - else ffassert(index==0); - - double delta = (b-a)/n; - t=a+delta/2; - for ( nn=0;nnlabel(); - k->code(stack); - Int4 i1 = vertices[nnn].color, i2 = vertices[++nnn].color; - throwassert(i1 >= 0 && i1 < nbv); - throwassert(i2 >= 0 && i2 < nbv); - Gh->edges[i].ref = mp.label; - Gh->edges[i].v[0]= Gh->vertices + i1; - Gh->edges[i].v[1]= Gh->vertices + i2; - R2 x12 = Gh->vertices[i2].r-Gh->vertices[i1].r; - Real8 l12=Norme2(x12); - Gh->edges[i].tg[0]=zero2; - Gh->edges[i].tg[1]=zero2; - Gh->edges[i].SensAdj[0] = Gh->edges[i].SensAdj[1] = -1; - Gh->edges[i].Adj[0] = Gh->edges[i].Adj[1] = 0; - Gh->edges[i].flag = 0; - Gh->edges[i].link=0; - if(Requiredboundary) - Gh->edges[i].SetRequired(); - - if (!hvertices) - { - Gh->vertices[i1].color++; - Gh->vertices[i2].color++; - len[i1] += l12; - len[i2] += l12; - } - - Hmin = Min(Hmin,l12); - } - nnn++; - }} + { int nbd = k->NbBorder(stack); + for(int index=0; indexvar(stack); + double a(k->from(stack)),b(k->to(stack)); + n=Max(Abs(k->Nbseg(stack,index)),1L); + long * indx = (k->index(stack)); + if(indx) *indx = index; + else ffassert(index==0); + + double delta = (b-a)/n; + t=a+delta/2; + for ( nn=0;nnlabel(); + k->code(stack); + Int4 i1 = vertices[nnn].color, i2 = vertices[++nnn].color; + throwassert(i1 >= 0 && i1 < nbv); + throwassert(i2 >= 0 && i2 < nbv); + Gh->edges[i].ref = mp.label; + Gh->edges[i].v[0]= Gh->vertices + i1; + Gh->edges[i].v[1]= Gh->vertices + i2; + R2 x12 = Gh->vertices[i2].r-Gh->vertices[i1].r; + Real8 l12=Norme2(x12); + Gh->edges[i].tg[0]=zero2; + Gh->edges[i].tg[1]=zero2; + Gh->edges[i].SensAdj[0] = Gh->edges[i].SensAdj[1] = -1; + Gh->edges[i].Adj[0] = Gh->edges[i].Adj[1] = 0; + Gh->edges[i].flag = 0; + Gh->edges[i].link=0; + if(Requiredboundary) + Gh->edges[i].SetRequired(); + + if (!hvertices) + { + Gh->vertices[i1].color++; + Gh->vertices[i2].color++; + len[i1] += l12; + len[i2] += l12; + } + + Hmin = Min(Hmin,l12); + } + nnn++; + }} */ - delete [] vertices; vertices=0; + delete[] vertices; + vertices = 0; - throwassert(nnn+nbvinter==nbvprev); - throwassert(i==Gh->nbe); + throwassert(nnn + nbvinter == nbvprev); + throwassert(i == Gh->nbe); // definition the default of the given mesh size - if (!hvertices) - { - bool hvint = pintern ? pintern->M() ==3 : 0; - for (i=0;inbv;i++) - { - if(hvint &&Gh->vertices[i].ReferenceNumber vertices[i].ReferenceNumber-brefintp; - Gh->vertices[i].m=Metric( (*pintern)(k ,2L)); - Gh->vertices[i].ReferenceNumber = -1; //++ bof bof FH .. + if (!hvertices) { + bool hvint = pintern ? pintern->M( ) == 3 : 0; + for (i = 0; i < Gh->nbv; i++) { + if (hvint && Gh->vertices[i].ReferenceNumber < brefintp + nbvinter) { + long k = Gh->vertices[i].ReferenceNumber - brefintp; + Gh->vertices[i].m = Metric((*pintern)(k, 2L)); + Gh->vertices[i].ReferenceNumber = -1; //++ bof bof FH .. + + } else if (Gh->vertices[i].color > 0) + Gh->vertices[i].m = Metric(len[i] / (Real8)Gh->vertices[i].color); + else + Gh->vertices[i].m = Metric(Hmin); + } + delete[] len; - } - else if (Gh->vertices[i].color > 0) - Gh->vertices[i].m= Metric(len[i] /(Real8) Gh->vertices[i].color); - else - Gh->vertices[i].m= Metric(Hmin); - } - delete [] len; + if (verbosity > 3) cout << "\t\t" << " Geom Hmin " << Hmin << endl; + } - if(verbosity>3) - cout <<"\t\t" << " Geom Hmin " << Hmin << endl; - } + Gh->NbSubDomains = nbsd; + if (Gh->NbSubDomains > 0) { + Gh->subdomains = new GeometricalSubDomain[Gh->NbSubDomains]; + Int4 i1 = 0; + i = 0; + for (int k = 0; k < nbmshL; ++k) { + const MeshL *pmshL = ppmshL[k]; - Gh->NbSubDomains=nbsd; - if (Gh->NbSubDomains>0) - { - Gh->subdomains = new GeometricalSubDomain[ Gh->NbSubDomains]; - Int4 i1=0; - i=0; - for (int k=0; knext) - { - int nbd = k->NbBorder(stack); - for(int index=0; indexNbseg(stack,index); - //long n= Max(1L,Abs(Nbseg)); - Gh->subdomains[i].sens = 1; //Nbseg >0 ? 1 : -1; - Gh->subdomains[i].edge=Gh->edges + i1; - Gh->subdomains[i].ref = i; - i1 += pmshL->nt; - } + /* for (E_BorderN const * k=b;k;k=k->next) + { + int nbd = k->NbBorder(stack); + for(int index=0; indexNbseg(stack,index); + // long n= Max(1L,Abs(Nbseg)); + Gh->subdomains[i].sens = 1; // Nbseg >0 ? 1 : -1; + Gh->subdomains[i].edge = Gh->edges + i1; + Gh->subdomains[i].ref = i; + i1 += pmshL->nt; } - Gh->NbEquiEdges=0; - Gh->NbCrackedEdges=0; - const Fem2D::Mesh * m=0; + } + Gh->NbEquiEdges = 0; + Gh->NbCrackedEdges = 0; + const Fem2D::Mesh *m = 0; if (justboundary) - m=bamg2msh(*Gh); - else - { - Gh->AfterRead(); - - double nbx = min(((double) Gh->nbv*(double)Gh->nbv)/9.+1000,0.5e9); - int nbvx = nbvmax ? nbvmax : (int) nbx ; - if(verbosity>1) cout << " BuilMesh (MeshL)" << nbvx << " nbx = " << nbx << " nbvmax=" <AfterRead( ); + + double nbx = min(((double)Gh->nbv * (double)Gh->nbv) / 9. + 1000, 0.5e9); + int nbvx = nbvmax ? nbvmax : (int)nbx; + if (verbosity > 1) cout << " BuilMesh (MeshL)" << nbvx << " nbx = " << nbx << " nbvmax=" << nbvmax << endl; // int nbtx= nbvmax ? nbvmax : (Gh->nbv*Gh->nbv)/9 +1000; - if(verbosity> 99) cout << " ** Gh = " << endl << *Gh << endl << " *** " <0 && nbc++ <2 && Th->nbv < nbv-1 ) - { - nbs= Th->SplitInternalEdgeWithBorderVertices(); - if(verbosity>1) cout << "BuildMesh: SplitInternalEdgeWithBorderVertices: count ="<< nbc << " " << nbs << endl; - } - - } + if (verbosity > 99) cout << " ** Gh = " << endl << *Gh << endl << " *** " << nbvx << endl; + ; + Triangles *Th = 0; + try { + Th = new Triangles(nbvx, *Gh); + if (SplitEdgeWith2Boundary) { + long nbs = 1, nbc = 0; + while (nbs > 0 && nbc++ < 2 && Th->nbv < nbv - 1) { + nbs = Th->SplitInternalEdgeWithBorderVertices( ); + if (verbosity > 1) cout << "BuildMesh: SplitInternalEdgeWithBorderVertices: count =" << nbc << " " << nbs << endl; + } + } - if(alea) // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + if (alea) // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + { + Th->SetVertexFieldOn( ); + for (int i = 0; i < Th->nbv; ++i) { + VertexOnGeom *on = 0; + if (!(Th->vertices[i].on)) // we are non on geometry { - Th->SetVertexFieldOn(); - for( int i=0;inbv;++i) - { - VertexOnGeom *on=0; - if( !(Th->vertices[i].on) ) // we are non on geometry - { - // move a little the points - Th->vertices[i].r.x += NormalDistrib(alea); - Th->vertices[i].r.y += NormalDistrib(alea); - - } - } - + // move a little the points + Th->vertices[i].r.x += NormalDistrib(alea); + Th->vertices[i].r.y += NormalDistrib(alea); } + } + } - m=bamg2msh(Th,true); + m = bamg2msh(Th, true); - } - catch(...) - { - Gh->NbRef=0; + } catch (...) { + Gh->NbRef = 0; delete Gh; - if(m) delete m; - if(Th) delete Th;// clean memory ??? - cout << " catch Err bamg " << endl; - throw ; - } - delete Th; + if (m) delete m; + if (Th) delete Th; // clean memory ??? + cout << " catch Err bamg " << endl; + throw; + } + delete Th; } delete Gh; @@ -818,155 +753,147 @@ const Fem2D::Mesh * BuildMesh(Stack stack,const Fem2D::MeshL **ppmshL , int nb m->BoundingBox(Pn,Px); m->quadtree=new Fem2D::FQuadTree(m,Pn,Px,m->nv); ---------- */ - mp=mps; + mp = mps; return m; } -const Fem2D::Mesh * BuildMesh(Stack stack,const Fem2D::MeshL *pmshL , bool justboundary,int nbvmax,bool Requiredboundary,KNM *pintern,double alea,bool SplitEdgeWith2Boundary) -{ - return BuildMesh(stack,&pmshL,1,justboundary,nbvmax,Requiredboundary,pintern,alea, SplitEdgeWith2Boundary); +const Fem2D::Mesh *BuildMesh(Stack stack, const Fem2D::MeshL *pmshL, bool justboundary, int nbvmax, bool Requiredboundary, KNM< double > *pintern, double alea, bool SplitEdgeWith2Boundary) { + return BuildMesh(stack, &pmshL, 1, justboundary, nbvmax, Requiredboundary, pintern, alea, SplitEdgeWith2Boundary); } -const Fem2D::Mesh * BuildMesh(Stack stack, E_BorderN const * const & b,bool justboundary,int nbvmax,bool Requiredboundary,KNM *pintern,double alea,bool SplitEdgeWith2Boundary) -{ - if(alea) Requiredboundary=1; - int nbvinter=0; - if( pintern) - { - nbvinter=pintern->N(); - if((pintern->M() != 2 ) && ( pintern->M()!=3)) - { - cout << " point m = " <M()< *pintern, double alea, bool SplitEdgeWith2Boundary) { + if (alea) Requiredboundary = 1; + int nbvinter = 0; + if (pintern) { + nbvinter = pintern->N( ); + if ((pintern->M( ) != 2) && (pintern->M( ) != 3)) { + cout << " point m = " << pintern->M( ) << endl; + ExecError("Error: BuildMesh number of column of internal point (point=) must be 2 or 3!"); } - int brefintp= -2000000000; + } + int brefintp = -2000000000; using namespace bamg; using bamg::Abs; using bamg::Max; using bamg::Min; using bamg::Pi; - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; - int nbvx=nbvinter,nbe=0,nbsd=0; - for (E_BorderN const * k=b;k;k=k->next) - { - int nbd = k->NbBorder(stack); - for(int index=0; indexNbseg(stack,index))); ; - nbvx += n+1; - nbe += n; - nbsd++; + int nbvx = nbvinter, nbe = 0, nbsd = 0; + for (E_BorderN const *k = b; k; k = k->next) { + int nbd = k->NbBorder(stack); + for (int index = 0; index < nbd; ++index) { + long n = Max(1L, Abs(k->Nbseg(stack, index))); + ; + nbvx += n + 1; + nbe += n; + nbsd++; } } - Geometry * Gh = new Geometry; - - if(verbosity>2) - cout <<"\t\t" << " Begin: ConstGeometry from nb Border " << nbsd <name=new char [strlen(filename)+1]; - strcpy(Gh->name,filename); - Real8 Hmin = HUGE_VAL;// the infinie value - Int4 hvertices =0; - Int4 i,nn,n; - Gh->MaximalAngleOfCorner =30.00*Pi/180.0; + Geometry *Gh = new Geometry; + + if (verbosity > 2) cout << "\t\t" << " Begin: ConstGeometry from nb Border " << nbsd << endl; + const char *filename = "FREEFEM.gh"; + Gh->name = new char[strlen(filename) + 1]; + strcpy(Gh->name, filename); + Real8 Hmin = HUGE_VAL; // the infinie value + Int4 hvertices = 0; + Int4 i, nn, n; + Gh->MaximalAngleOfCorner = 30.00 * Pi / 180.0; Gh->nbv = 0; Gh->nbvx = nbvx; Gh->nbe = nbe; Gh->edges = new GeometricalEdge[Gh->nbe]; - bamg::Vertex *vertices = new Vertex[Gh->nbvx];// correction 2009/07/03 - double lmin= HUGE_VAL; + bamg::Vertex *vertices = new Vertex[Gh->nbvx]; // correction 2009/07/03 + double lmin = HUGE_VAL; // generation des points et des lignes - i=0; - for (E_BorderN const * k=b;k;k=k->next) - { + i = 0; + for (E_BorderN const *k = b; k; k = k->next) { int nbd = k->NbBorder(stack); - for(int index=0; indexb->xfrom); // a faire - double & t = * k->var(stack),tt; - double a(k->from(stack)),b(k->to(stack)); - long * indx = k->index(stack); - if(indx) *indx = index; - else ffassert(index==0); - n=Max(Abs(k->Nbseg(stack,index)),1L); - tt=t=a; - double delta = (b-a)/n; - for ( nn=0;nn<=n;nn++,i++, tt += delta) - { - t = tt; - if (nn==n) t=b; // to remove roundoff error - if( nn >0 && nn < n) { t += NormalDistrib(alea); } // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr - mp.label = k->label(); - k->code(stack); // compute x,y, label - vertices[i].r.x=mp.P.x; - vertices[i].r.y=mp.P.y; - vertices[i].ReferenceNumber= mp.label; - vertices[i].color = i; - if (nn>0) { - lmin=min(lmin,Norme2_2( vertices[i].r-vertices[i-1].r)); - } + for (int index = 0; index < nbd; ++index) { + assert(k->b->xfrom); // a faire + double &t = *k->var(stack), tt; + double a(k->from(stack)), b(k->to(stack)); + long *indx = k->index(stack); + if (indx) + *indx = index; + else + ffassert(index == 0); + n = Max(Abs(k->Nbseg(stack, index)), 1L); + tt = t = a; + double delta = (b - a) / n; + for (nn = 0; nn <= n; nn++, i++, tt += delta) { + t = tt; + if (nn == n) t = b; // to remove roundoff error + if (nn > 0 && nn < n) { + t += NormalDistrib(alea); + } // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + mp.label = k->label( ); + k->code(stack); // compute x,y, label + vertices[i].r.x = mp.P.x; + vertices[i].r.y = mp.P.y; + vertices[i].ReferenceNumber = mp.label; + vertices[i].color = i; + if (nn > 0) { + lmin = min(lmin, Norme2_2(vertices[i].r - vertices[i - 1].r)); } + } } -} - // add interna point - if(pintern) - { - for(int k=0; kpmin = vertices[0].r; - Gh->pmax = vertices[0].r; + long nbv = 0; + Gh->pmin = vertices[0].r; + Gh->pmax = vertices[0].r; // recherche des extrema des vertices pmin,pmax - for (i=0;ipmin.x = Min(Gh->pmin.x,vertices[i].r.x); - Gh->pmin.y = Min(Gh->pmin.y,vertices[i].r.y); - Gh->pmax.x = Max(Gh->pmax.x,vertices[i].r.x); - Gh->pmax.y = Max(Gh->pmax.y,vertices[i].r.y); - } + for (i = 0; i < nbvprev; i++) { + Gh->pmin.x = Min(Gh->pmin.x, vertices[i].r.x); + Gh->pmin.y = Min(Gh->pmin.y, vertices[i].r.y); + Gh->pmax.x = Max(Gh->pmax.x, vertices[i].r.x); + Gh->pmax.y = Max(Gh->pmax.y, vertices[i].r.y); + } - double diameter=Max(Gh->pmax.x-Gh->pmin.x,Gh->pmax.y-Gh->pmin.y); - Gh->coefIcoor= (MaxICoor)/diameter; - Icoor1 epsI = (Icoor1) (Gh->coefIcoor*eps); - ffassert(Gh->coefIcoor >0); + double diameter = Max(Gh->pmax.x - Gh->pmin.x, Gh->pmax.y - Gh->pmin.y); + Gh->coefIcoor = (MaxICoor) / diameter; + Icoor1 epsI = (Icoor1)(Gh->coefIcoor * eps); + ffassert(Gh->coefIcoor > 0); - if(lmin2) - { - cout <<"\t\t" << " Geom: min="<< Gh->pmin << "max ="<< Gh->pmax - << " hmin = " << Gh->MinimalHmin() << endl; - } + if (verbosity > 2) { + cout << "\t\t" << " Geom: min=" << Gh->pmin << "max =" << Gh->pmax << " hmin = " << Gh->MinimalHmin( ) << endl; + } nbv = 0; - { // find common point + { // find common point QuadTree quadtree; Metric Id(1.); - for ( i=0;itoI2(vertices[i].r); - vertices[i].m = Id; - Vertex *v= quadtree.ToClose(vertices[i],eps,epsI,epsI) ; - // quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); - if( v && Norme1(v->r - vertices[i]) < eps ) - { vertices[i].color=v->color; } - else {quadtree.Add(vertices[i]); - vertices[i].color = nbv++;} + for (i = 0; i < nbvprev; i++) { + vertices[i].i = Gh->toI2(vertices[i].r); + vertices[i].m = Id; + Vertex *v = quadtree.ToClose(vertices[i], eps, epsI, epsI); + // quadtree.NearestVertex(vertices[i].i.x,vertices[i].i.y); + if (v && Norme1(v->r - vertices[i]) < eps) { + vertices[i].color = v->color; + } else { + quadtree.Add(vertices[i]); + vertices[i].color = nbv++; } - } // to delete quadtree - if (verbosity>1) - cout << " Nb of common points " << nbvprev-nbv < 1) cout << " Nb of common points " << nbvprev - nbv << endl; Gh->nbvx = nbv; Gh->nbv = nbv; @@ -977,191 +904,171 @@ const Fem2D::Mesh * BuildMesh(Stack stack, E_BorderN const * const & b,bool jus const Direction NoDirOfSearch; // compression of points int kkk; - for ( i=0,kkk=0;kkkvertices[i].r.x = vertices[kkk].r.x ; - Gh->vertices[i].r.y = vertices[kkk].r.y; - throwassert(Gh->vertices[i].IsThe()); - Gh->vertices[i].ReferenceNumber = vertices[kkk].ReferenceNumber ; - Gh->vertices[i].DirOfSearch = NoDirOfSearch; - Gh->vertices[i].color =0; - Gh->vertices[i].Set(); - if(Requiredboundary) - Gh->vertices[i].SetRequired(); - - if(Gh->vertices[i].ReferenceNumber < 0) - Gh->vertices[i].SetRequired(); - - i++; - } + Gh->vertices[i].r.x = vertices[kkk].r.x; + Gh->vertices[i].r.y = vertices[kkk].r.y; + throwassert(Gh->vertices[i].IsThe( )); + Gh->vertices[i].ReferenceNumber = vertices[kkk].ReferenceNumber; + Gh->vertices[i].DirOfSearch = NoDirOfSearch; + Gh->vertices[i].color = 0; + Gh->vertices[i].Set( ); + if (Requiredboundary) Gh->vertices[i].SetRequired( ); + + if (Gh->vertices[i].ReferenceNumber < 0) Gh->vertices[i].SetRequired( ); + + i++; } - throwassert(i==nbv); - R2 zero2(0,0); - if(verbosity>5) - cout <<"\t\t" << " Record Edges: Nb of Edge " << Gh->nbe < 5) cout << "\t\t" << " Record Edges: Nb of Edge " << Gh->nbe << endl; throwassert(Gh->edges); - throwassert (Gh->nbv >0); - Real8 *len =0; - if (!hvertices) - { - len = new Real8[Gh->nbv]; - for(i=0;inbv;i++) - len[i]=0; - } - int nnn=0; - i=0; - for (E_BorderN const * k=b;k;k=k->next) + throwassert(Gh->nbv > 0); + Real8 *len = 0; + if (!hvertices) { + len = new Real8[Gh->nbv]; + for (i = 0; i < Gh->nbv; i++) len[i] = 0; + } + int nnn = 0; + i = 0; + for (E_BorderN const *k = b; k; k = k->next) - { int nbd = k->NbBorder(stack); - for(int index=0; indexvar(stack); - double a(k->from(stack)),b(k->to(stack)); - n=Max(Abs(k->Nbseg(stack,index)),1L); - long * indx = (k->index(stack)); - if(indx) *indx = index; - else ffassert(index==0); - - double delta = (b-a)/n; - t=a+delta/2; - for ( nn=0;nnlabel(); - k->code(stack); - Int4 i1 = vertices[nnn].color, i2 = vertices[++nnn].color; - throwassert(i1 >= 0 && i1 < nbv); - throwassert(i2 >= 0 && i2 < nbv); - Gh->edges[i].ref = mp.label; - Gh->edges[i].v[0]= Gh->vertices + i1; - Gh->edges[i].v[1]= Gh->vertices + i2; - R2 x12 = Gh->vertices[i2].r-Gh->vertices[i1].r; - Real8 l12=Norme2(x12); - Gh->edges[i].tg[0]=zero2; - Gh->edges[i].tg[1]=zero2; - Gh->edges[i].SensAdj[0] = Gh->edges[i].SensAdj[1] = -1; - Gh->edges[i].Adj[0] = Gh->edges[i].Adj[1] = 0; - Gh->edges[i].flag = 0; - Gh->edges[i].link=0; - if(Requiredboundary) - Gh->edges[i].SetRequired(); - - if (!hvertices) - { - Gh->vertices[i1].color++; - Gh->vertices[i2].color++; - len[i1] += l12; - len[i2] += l12; - } - - Hmin = Min(Hmin,l12); + { + int nbd = k->NbBorder(stack); + for (int index = 0; index < nbd; ++index) { + double &t = *k->var(stack); + double a(k->from(stack)), b(k->to(stack)); + n = Max(Abs(k->Nbseg(stack, index)), 1L); + long *indx = (k->index(stack)); + if (indx) + *indx = index; + else + ffassert(index == 0); + + double delta = (b - a) / n; + t = a + delta / 2; + for (nn = 0; nn < n; nn++, i++, t += delta) { + + mp.label = k->label( ); + k->code(stack); + Int4 i1 = vertices[nnn].color, i2 = vertices[++nnn].color; + throwassert(i1 >= 0 && i1 < nbv); + throwassert(i2 >= 0 && i2 < nbv); + Gh->edges[i].ref = mp.label; + Gh->edges[i].v[0] = Gh->vertices + i1; + Gh->edges[i].v[1] = Gh->vertices + i2; + R2 x12 = Gh->vertices[i2].r - Gh->vertices[i1].r; + Real8 l12 = Norme2(x12); + Gh->edges[i].tg[0] = zero2; + Gh->edges[i].tg[1] = zero2; + Gh->edges[i].SensAdj[0] = Gh->edges[i].SensAdj[1] = -1; + Gh->edges[i].Adj[0] = Gh->edges[i].Adj[1] = 0; + Gh->edges[i].flag = 0; + Gh->edges[i].link = 0; + if (Requiredboundary) Gh->edges[i].SetRequired( ); + + if (!hvertices) { + Gh->vertices[i1].color++; + Gh->vertices[i2].color++; + len[i1] += l12; + len[i2] += l12; } + + Hmin = Min(Hmin, l12); + } nnn++; - }} + } + } - delete [] vertices; vertices=0; + delete[] vertices; + vertices = 0; - throwassert(nnn+nbvinter==nbvprev); - throwassert(i==Gh->nbe); + throwassert(nnn + nbvinter == nbvprev); + throwassert(i == Gh->nbe); // definition the default of the given mesh size - if (!hvertices) - { - bool hvint = pintern ? pintern->M() ==3 : 0; - for (i=0;inbv;i++) - { - if(hvint &&Gh->vertices[i].ReferenceNumber vertices[i].ReferenceNumber-brefintp; - Gh->vertices[i].m=Metric( (*pintern)(k ,2L)); - Gh->vertices[i].ReferenceNumber = -1; //++ bof bof FH .. - - } - else if (Gh->vertices[i].color > 0) - Gh->vertices[i].m= Metric(len[i] /(Real8) Gh->vertices[i].color); - else - Gh->vertices[i].m= Metric(Hmin); - } - delete [] len; - - if(verbosity>3) - cout <<"\t\t" << " Geom Hmin " << Hmin << endl; + if (!hvertices) { + bool hvint = pintern ? pintern->M( ) == 3 : 0; + for (i = 0; i < Gh->nbv; i++) { + if (hvint && Gh->vertices[i].ReferenceNumber < brefintp + nbvinter) { + long k = Gh->vertices[i].ReferenceNumber - brefintp; + Gh->vertices[i].m = Metric((*pintern)(k, 2L)); + Gh->vertices[i].ReferenceNumber = -1; //++ bof bof FH .. + + } else if (Gh->vertices[i].color > 0) + Gh->vertices[i].m = Metric(len[i] / (Real8)Gh->vertices[i].color); + else + Gh->vertices[i].m = Metric(Hmin); } + delete[] len; - Gh->NbSubDomains=nbsd; - if (Gh->NbSubDomains>0) - { - Gh->subdomains = new GeometricalSubDomain[ Gh->NbSubDomains]; - Int4 i1=0; - i=0; - for (E_BorderN const * k=b;k;k=k->next) - { - int nbd = k->NbBorder(stack); - for(int index=0; indexNbseg(stack,index); - long n= Max(1L,Abs(Nbseg)); - Gh->subdomains[i].sens = Nbseg >0 ? 1 : -1; - Gh->subdomains[i].edge=Gh->edges + i1; - Gh->subdomains[i].ref = i; - i1 += n; - }} + if (verbosity > 3) cout << "\t\t" << " Geom Hmin " << Hmin << endl; + } + + Gh->NbSubDomains = nbsd; + if (Gh->NbSubDomains > 0) { + Gh->subdomains = new GeometricalSubDomain[Gh->NbSubDomains]; + Int4 i1 = 0; + i = 0; + for (E_BorderN const *k = b; k; k = k->next) { + int nbd = k->NbBorder(stack); + for (int index = 0; index < nbd; ++index, i++) { + long Nbseg = k->Nbseg(stack, index); + long n = Max(1L, Abs(Nbseg)); + Gh->subdomains[i].sens = Nbseg > 0 ? 1 : -1; + Gh->subdomains[i].edge = Gh->edges + i1; + Gh->subdomains[i].ref = i; + i1 += n; + } } - Gh->NbEquiEdges=0; - Gh->NbCrackedEdges=0; - const Fem2D::Mesh * m=0; + } + Gh->NbEquiEdges = 0; + Gh->NbCrackedEdges = 0; + const Fem2D::Mesh *m = 0; if (justboundary) - m=bamg2msh(*Gh); - else - { - Gh->AfterRead(); - int nbtx= nbvmax ? nbvmax : (Gh->nbv*Gh->nbv)/9 +1000; - if(verbosity> 99) cout << " ** Gh = " << endl << *Gh << endl << " *** " <0 && nbc++ <2 && Th->nbv < nbtx-1 ) - { - nbs= Th->SplitInternalEdgeWithBorderVertices(); - if(verbosity>1) cout << "BuildMesh: SplitInternalEdgeWithBorderVertices: count ="<< nbc << " " << nbs << endl; - } - - } + m = bamg2msh(*Gh); + else { + Gh->AfterRead( ); + int nbtx = nbvmax ? nbvmax : (Gh->nbv * Gh->nbv) / 9 + 1000; + if (verbosity > 99) cout << " ** Gh = " << endl << *Gh << endl << " *** " << endl; + ; + Triangles *Th = 0; + try { + Th = new Triangles(nbtx, *Gh); + if (SplitEdgeWith2Boundary) { + long nbs = 1, nbc = 0; + while (nbs > 0 && nbc++ < 2 && Th->nbv < nbtx - 1) { + nbs = Th->SplitInternalEdgeWithBorderVertices( ); + if (verbosity > 1) cout << "BuildMesh: SplitInternalEdgeWithBorderVertices: count =" << nbc << " " << nbs << endl; + } + } - if(alea) // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + if (alea) // Add F. Hecht Juin 2018 for J-M Sac Epee: jean-marc.sac-epee@univ-lorraine.fr + { + Th->SetVertexFieldOn( ); + for (int i = 0; i < Th->nbv; ++i) { + VertexOnGeom *on = 0; + if (!(Th->vertices[i].on)) // we are non on geometry { - Th->SetVertexFieldOn(); - for( int i=0;inbv;++i) - { - VertexOnGeom *on=0; - if( !(Th->vertices[i].on) ) // we are non on geometry - { - // move a little the points - Th->vertices[i].r.x += NormalDistrib(alea); - Th->vertices[i].r.y += NormalDistrib(alea); - - } - } - + // move a little the points + Th->vertices[i].r.x += NormalDistrib(alea); + Th->vertices[i].r.y += NormalDistrib(alea); } + } + } - m=bamg2msh(Th,true); + m = bamg2msh(Th, true); - } - catch(...) - { - Gh->NbRef=0; - delete Gh; - if(m) delete m; - if(Th) delete Th;// clean memory ??? - cout << " catch Err bamg " << endl; - throw ; - } - delete Th; + } catch (...) { + Gh->NbRef = 0; + delete Gh; + if (m) delete m; + if (Th) delete Th; // clean memory ??? + cout << " catch Err bamg " << endl; + throw; + } + delete Th; } delete Gh; @@ -1170,228 +1077,209 @@ const Fem2D::Mesh * BuildMesh(Stack stack, E_BorderN const * const & b,bool jus m->BoundingBox(Pn,Px); m->quadtree=new Fem2D::FQuadTree(m,Pn,Px,m->nv); ---------- */ - mp=mps; + mp = mps; return m; } -void E_BorderN::BoundingBox(Stack stack,double &xmin,double & xmax, double & ymin,double & ymax, double & zmin,double & zmax) const -{ +void E_BorderN::BoundingBox(Stack stack, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const { - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; - - for (E_BorderN const * k=this;k;k=k->next) - { - int nbd = k->NbBorder(stack); - for(int index=0; indexb->xfrom); // a faire - double & t = * k->var(stack); - double a(k->from(stack)),b(k->to(stack)); - long * indx = (k->index(stack)); - if(indx) *indx = index; - else ffassert(index==0); - - long n=Max(Abs(k->Nbseg(stack,index)),1L); - t=a; - double delta = (b-a)/n; - for (int nn=0;nn<=n;nn++, t += delta) - { - if (nn==n) t=b; // to remove roundoff error - mp.P=Fem2D::R3();// reset , x,y, z to 0 . Jan 2020 FH. - mp.label = k->label(); - k->code(stack); // compute x,y, label - xmin=Min(xmin,mp.P.x); - xmax=Max(xmax,mp.P.x); - ymin=Min(ymin,mp.P.y); - ymax=Max(ymax,mp.P.y); - zmin=Min(zmin,mp.P.z); - zmax=Max(zmax,mp.P.z); - } - }} - mp=mps; -} + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; + for (E_BorderN const *k = this; k; k = k->next) { + int nbd = k->NbBorder(stack); + for (int index = 0; index < nbd; ++index) { + assert(k->b->xfrom); // a faire + double &t = *k->var(stack); + double a(k->from(stack)), b(k->to(stack)); + long *indx = (k->index(stack)); + if (indx) + *indx = index; + else + ffassert(index == 0); + + long n = Max(Abs(k->Nbseg(stack, index)), 1L); + t = a; + double delta = (b - a) / n; + for (int nn = 0; nn <= n; nn++, t += delta) { + if (nn == n) t = b; // to remove roundoff error + mp.P = Fem2D::R3( ); // reset , x,y, z to 0 . Jan 2020 FH. + mp.label = k->label( ); + k->code(stack); // compute x,y, label + xmin = Min(xmin, mp.P.x); + xmax = Max(xmax, mp.P.x); + ymin = Min(ymin, mp.P.y); + ymax = Max(ymax, mp.P.y); + zmin = Min(zmin, mp.P.z); + zmax = Max(zmax, mp.P.z); + } + } + } + mp = mps; +} -void E_BorderN::Plot(Stack stack) const -{ +void E_BorderN::Plot(Stack stack) const { using Fem2D::R2; - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; - float x0,x1,y0,y1; - getcadre(x0,x1,y0,y1); - float h= (x1-x0)*0.01; - int nbd=0; - for (E_BorderN const * k=this;k;k=k->next) - { - int nbdr = k->NbBorder(stack); - for(int index=0; indexnext) { + int nbdr = k->NbBorder(stack); + for (int index = 0; index < nbdr; ++index) { nbd++; - assert(k->b->xfrom); // a faire - double & t = * k->var(stack); - double a(k->from(stack)),b(k->to(stack)); - long n=Max(Abs(k->Nbseg(stack,index)),1L); - long * indx = (k->index(stack)); - if(indx) *indx = index; - else ffassert(index==0); - - t=a; - double delta = (b-a)/n; - R2 P,Po; - for (int nn=0;nn<=n;nn++, t += delta) - { - if (nn==n) t=b; // to remove roundoff error - mp.label = k->label(); - mp.P.z=0; - k->code(stack); // compute x,y, label - P=mp.P.p2(); - couleur(2+mp.label); - if(nn!=0) { LineTo(P); - R2 uv(Po,P); - double l = Max(sqrt((uv,uv)),1e-20); - - R2 dd = uv*(-h/l); - R2 dn = dd.perp()*0.5; - - LineTo(P+dd+dn); - MoveTo(P+dd-dn); - LineTo(P);} - else { - DrawMark(mp.P.p2(),0.01); - MoveTo(mp.P.p2()); - - } - Po=P; + assert(k->b->xfrom); // a faire + double &t = *k->var(stack); + double a(k->from(stack)), b(k->to(stack)); + long n = Max(Abs(k->Nbseg(stack, index)), 1L); + long *indx = (k->index(stack)); + if (indx) + *indx = index; + else + ffassert(index == 0); + + t = a; + double delta = (b - a) / n; + R2 P, Po; + for (int nn = 0; nn <= n; nn++, t += delta) { + if (nn == n) t = b; // to remove roundoff error + mp.label = k->label( ); + mp.P.z = 0; + k->code(stack); // compute x,y, label + P = mp.P.p2( ); + couleur(2 + mp.label); + if (nn != 0) { + LineTo(P); + R2 uv(Po, P); + double l = Max(sqrt((uv, uv)), 1e-20); + + R2 dd = uv * (-h / l); + R2 dn = dd.perp( ) * 0.5; + + LineTo(P + dd + dn); + MoveTo(P + dd - dn); + LineTo(P); + } else { + DrawMark(mp.P.p2( ), 0.01); + MoveTo(mp.P.p2( )); } - DrawMark(mp.P.p2(),0.01); - MoveTo(mp.P.p2()); + Po = P; + } + DrawMark(mp.P.p2( ), 0.01); + MoveTo(mp.P.p2( )); } + } + if (verbosity > 9) cout << " -- Plot size : " << nbd << " Border \n"; + mp = mps; } - if(verbosity>9) cout << " -- Plot size : " << nbd << " Border \n"; - mp=mps; -} -void E_BorderN::SavePlot(Stack stack,PlotStream & plot ) const -{ - using Fem2D::R2; +void E_BorderN::SavePlot(Stack stack, PlotStream &plot) const { + using Fem2D::R2; - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; - long nbd1=0;// nb of sub border - for (E_BorderN const * k=this;k;k=k->next) - { - int nbdr = k->NbBorder(stack); - for(int index=0; indexnext) { + int nbdr = k->NbBorder(stack); + for (int index = 0; index < nbdr; ++index) nbd1++; + } + plot << nbd1; + int nbd = 0; + for (E_BorderN const *k = this; k; k = k->next) { + int nbdr = k->NbBorder(stack); + for (int index = 0; index < nbdr; ++index) { + nbd++; + assert(k->b->xfrom); // a faire + double &t = *k->var(stack); + double a(k->from(stack)), b(k->to(stack)); + long n = Max(Abs(k->Nbseg(stack, index)), 1L); + long *indx = (k->index(stack)); + if (indx) + *indx = index; + else + ffassert(index == 0); + + t = a; + double delta = (b - a) / n; + R2 P, Po; + plot << (long)n; + for (int nn = 0; nn <= n; nn++, t += delta) { + if (nn == n) t = b; // to remove roundoff error + mp.label = k->label( ); + mp.P.z = 0; + k->code(stack); // compute x,y, label + P = mp.P.p2( ); + Fem2D::R3 P3 = mp.P; + // cout << "test P3 " << P3 << endl; + plot << (long)mp.label << P3.x << P3.y << P3.z; + } } - plot << nbd1; - int nbd=0; - for (E_BorderN const * k=this;k;k=k->next) - { - int nbdr = k->NbBorder(stack); - for(int index=0; indexb->xfrom); // a faire - double & t = * k->var(stack); - double a(k->from(stack)),b(k->to(stack)); - long n=Max(Abs(k->Nbseg(stack,index)),1L); - long * indx = (k->index(stack)); - if(indx) *indx = index; - else ffassert(index==0); - - t=a; - double delta = (b-a)/n; - R2 P,Po; - plot<< (long) n; - for (int nn=0;nn<=n;nn++, t += delta) - { - if (nn==n) t=b; // to remove roundoff error - mp.label = k->label(); - mp.P.z=0; - k->code(stack); // compute x,y, label - P=mp.P.p2(); - Fem2D::R3 P3=mp.P; - //cout << "test P3 " << P3 << endl; - plot << (long) mp.label <9) cout << " -- Plot size : " << nbd << " Border \n"; - mp=mps; + } + assert(nbd == nbd1); + if (verbosity > 9) cout << " -- Plot size : " << nbd << " Border \n"; + mp = mps; } -const Fem2D::Mesh * BuildMeshBorder(Stack stack, E_BorderN const * const & b) -{ - return BuildMesh(stack,b,true,0,true); -} -const Fem2D::Mesh * BuildMesh(Stack stack, E_BorderN const * const & b,bool Requiredboundary) -{ - return BuildMesh(stack,b,false,0,Requiredboundary); -} +const Fem2D::Mesh *BuildMeshBorder(Stack stack, E_BorderN const *const &b) { return BuildMesh(stack, b, true, 0, true); } +const Fem2D::Mesh *BuildMesh(Stack stack, E_BorderN const *const &b, bool Requiredboundary) { return BuildMesh(stack, b, false, 0, Requiredboundary); } -const Fem2D::Mesh * ReadTriangulate( string * const & s) { +const Fem2D::Mesh *ReadTriangulate(string *const &s) { using namespace Fem2D; - KN xy; + KN< R2 > xy; char c; - int nv=0; - for(int step=0;step<2;step++) - { - nv=0; - ifstream f(s->c_str()); - if(!f) {cerr <<" Error opening file " << *s << endl; - ExecError("Opening file ");} - while (f.good()) - { - R2 P; - f >> P ; - if (!f.good()) break; - if (step) xy[nv]=P; - nv++; - while (f.get(c) && (c!='\n' && c!='\r' ) ) (void) 0; // eat until control (new line - } - if (!step && nv ) xy.init(nv); // alloc the array + int nv = 0; + for (int step = 0; step < 2; step++) { + nv = 0; + ifstream f(s->c_str( )); + if (!f) { + cerr << " Error opening file " << *s << endl; + ExecError("Opening file "); + } + while (f.good( )) { + R2 P; + f >> P; + if (!f.good( )) break; + if (step) xy[nv] = P; + nv++; + while (f.get(c) && (c != '\n' && c != '\r')) (void)0; // eat until control (new line } - if(verbosity) - cout << " we read " << nv << " coordinates xy "<< endl; + if (!step && nv) xy.init(nv); // alloc the array + } + if (verbosity) cout << " we read " << nv << " coordinates xy " << endl; - Mesh * m=new Mesh(nv,xy); - m->MakeQuadTree(); + Mesh *m = new Mesh(nv, xy); + m->MakeQuadTree( ); return m; - } -const Fem2D::Mesh * Triangulate( const KN_ & xx,const KN_ & yy) -{ - using namespace Fem2D; - ffassert(xx.N()==yy.N()); - int nv=xx.N(); - KN xy(nv); - for(int i=0;iMakeQuadTree(); - return m; - +const Fem2D::Mesh *Triangulate(const KN_< double > &xx, const KN_< double > &yy) { + using namespace Fem2D; + ffassert(xx.N( ) == yy.N( )); + int nv = xx.N( ); + KN< R2 > xy(nv); + for (int i = 0; i < nv; ++i) xy[i] = R2(xx[i], yy[i]); + Mesh *m = new Mesh(nv, xy); + m->MakeQuadTree( ); + return m; } -const Fem2D::Mesh * ReadMeshbamg( string * const & s) { +const Fem2D::Mesh *ReadMeshbamg(string *const &s) { using bamg::Triangles; - Triangles * bTh= new Triangles(s->c_str()); - const Fem2D::Mesh * m=bamg2msh(bTh,false);// no renum + Triangles *bTh = new Triangles(s->c_str( )); + const Fem2D::Mesh *m = bamg2msh(bTh, false); // no renum delete bTh; return m; } -const Fem2D::Mesh * buildmeshbamg( string * const & s, int nbvxin) { +const Fem2D::Mesh *buildmeshbamg(string *const &s, int nbvxin) { - using bamg::Triangles; using bamg::Geometry; - Geometry Gh(s->c_str()); - double nbx = min(((double) Gh.nbv*(double) Gh.nbv)/9.+1000,0.5e9); - - int nbvx = nbvxin ? nbvxin : (int) nbx ; - if (verbosity>1) cout << " buildmeshbamg: nbvx = "<< nbvx << "nbx =" << nbx << " " << nbvxin << endl; - Triangles * bTh= new Triangles(nbvx,Gh); - const Fem2D::Mesh * m=bamg2msh(bTh,false);// no renum + using bamg::Triangles; + Geometry Gh(s->c_str( )); + double nbx = min(((double)Gh.nbv * (double)Gh.nbv) / 9. + 1000, 0.5e9); + + int nbvx = nbvxin ? nbvxin : (int)nbx; + if (verbosity > 1) cout << " buildmeshbamg: nbvx = " << nbvx << "nbx =" << nbx << " " << nbvxin << endl; + Triangles *bTh = new Triangles(nbvx, Gh); + const Fem2D::Mesh *m = bamg2msh(bTh, false); // no renum delete bTh; return m; } diff --git a/src/femlib/BamgFreeFem.hpp b/src/femlib/BamgFreeFem.hpp index 8e28185d4..a3755cfc7 100644 --- a/src/femlib/BamgFreeFem.hpp +++ b/src/femlib/BamgFreeFem.hpp @@ -32,25 +32,23 @@ namespace bamg { extern void (*MeshIstreamErrorHandler)(ios &); class Triangles; -} +} // namespace bamg +const Fem2D::Mesh *ReadMeshbamg(string *const &s); +const Fem2D::Mesh *ReadTriangulate(string *const &s); +const Fem2D::Mesh *Triangulate(const KN_< double > &xx, const KN_< double > &yy); +const Fem2D::Mesh *bamg2msh(bamg::Triangles *tTh, bool renumbering = false); +bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian = -1.0, long *reqedgeslab = 0, int nreqedgeslab = 0); +bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian, int nbdfv, int *ndfv, int nbdfe, int *ndfe, long *reqedgeslab = 0, int nreqedgeslab = 0); -const Fem2D::Mesh *ReadMeshbamg(string *const & s); -const Fem2D::Mesh *ReadTriangulate( string *const &s); -const Fem2D::Mesh *Triangulate(const KN_ &xx, const KN_ &yy); -const Fem2D::Mesh *bamg2msh(bamg::Triangles* tTh, bool renumbering=false); -bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian=-1.0,long *reqedgeslab=0, int nreqedgeslab=0); -bamg::Triangles *msh2bamg(const Fem2D::Mesh &Th, double cutoffradian, int nbdfv, int *ndfv,int nbdfe, int *ndfe, - long *reqedgeslab=0, int nreqedgeslab=0); - -const Fem2D::Mesh *BuildMesh(Stack stack, E_BorderN const *const &b, bool justboundary, int nbvmax=0, bool Requiredboundary=true, - KNM *pintern=0, double alea=0,bool SplitEdgeWith2Boundary=false); -const Fem2D::Mesh *BuildMesh(Stack stack, const Fem2D::MeshL *pmshL , bool justboundary, int nbvmax=0, bool Requiredboundary=true, - KNM *pintern=0, double alea=0,bool SplitEdgeWith2Boundary=false); +const Fem2D::Mesh *BuildMesh(Stack stack, E_BorderN const *const &b, bool justboundary, int nbvmax = 0, bool Requiredboundary = true, KNM< double > *pintern = 0, double alea = 0, + bool SplitEdgeWith2Boundary = false); +const Fem2D::Mesh *BuildMesh(Stack stack, const Fem2D::MeshL *pmshL, bool justboundary, int nbvmax = 0, bool Requiredboundary = true, KNM< double > *pintern = 0, double alea = 0, + bool SplitEdgeWith2Boundary = false); const Fem2D::Mesh *BuildMesh(Stack stack, E_BorderN const *const &b, bool Requiredboundary); const Fem2D::Mesh *BuildMesh(Stack stack, E_BorderN const *const &b, bool Requiredboundary); const Fem2D::Mesh *BuildMeshBorder(Stack stack, E_BorderN const *const &b); -const Fem2D::Mesh *MoveTheMesh(const Fem2D::Mesh &Th, const KN_ &u, const KN_ &v); -const Fem2D::Mesh *buildmeshbamg(string *const &s, int =0); +const Fem2D::Mesh *MoveTheMesh(const Fem2D::Mesh &Th, const KN_< double > &u, const KN_< double > &v); +const Fem2D::Mesh *buildmeshbamg(string *const &s, int = 0); -#endif //FREEFEMBAMG_H_ +#endif // FREEFEMBAMG_H_ diff --git a/src/femlib/CG.cpp b/src/femlib/CG.cpp index fbd9eabc5..dd1ac5af3 100644 --- a/src/femlib/CG.cpp +++ b/src/femlib/CG.cpp @@ -7,64 +7,49 @@ #include "CG.hpp" #include -//int verbosity =2 ; -typedef std::complex Complex; +// int verbosity =2 ; +typedef std::complex< double > Complex; +template< class I, class K > +K *myscopy(I n, const K *x, K *y) { -template -K * myscopy(I n,const K *x,K *y) -{ - - for(I i=0;i -K mysdot(I n,const K *x,const K *y) -{ - K s=0; - for(I i=0;i +K mysdot(I n, const K *x, const K *y) { + K s = 0; + for (I i = 0; i < n; ++i) s += x[i] * y[i]; + return s; } -template -Complex mysdot(I n,const Complex *x,const Complex *y) -{ - Complex s=0; - for(I i=0;i +Complex mysdot(I n, const Complex *x, const Complex *y) { + Complex s = 0; + for (I i = 0; i < n; ++i) s += std::conj(x[i]) * y[i]; + return s; } -template -K * mysaxpy(I n,K a,const K *x,K *y) -{ - for(I i=0; i< n; ++i) - y[i] += a* x[i]; - return y; +template< class I, class K > +K *mysaxpy(I n, K a, const K *x, K *y) { + for (I i = 0; i < n; ++i) y[i] += a * x[i]; + return y; } -template -K * mysax2y(I n,K a,const K *x,K *y) -{ - for(I i=0; i< n; ++i) - y[i] = a* x[i]; - return y; +template< class I, class K > +K *mysax2y(I n, K a, const K *x, K *y) { + for (I i = 0; i < n; ++i) y[i] = a * x[i]; + return y; } -template -K * myscal(I n,K a,K *x) -{ - for(I i=0; i +K *myscal(I n, K a, K *x) { + for (I i = 0; i < n; ++i) x[i] *= a; + return x; } -template -double mysnrm2(I n,const K *x) -{ - double s=0.; - for(I i=0; i +double mysnrm2(I n, const K *x) { + double s = 0.; + for (I i = 0; i < n; ++i) s += std::norm(x[i]); + return std::sqrt(s); } #ifdef WITHBLAS @@ -72,500 +57,396 @@ double mysnrm2(I n,const K *x) #ifdef __cplusplus extern "C" { #endif - // BLAS function - double ddot_(int *n,const double *x, int *incx,const double *y, int *incy); - void dcopy_(int *n,const double *x, int *incx,const double *y,int *incy); - void dscal_(int *n,const double *alpha, double *x, int *incx); - void daxpy_(int *n,const double *alpha,const double *x, int *incx, - double *y, int *incy); - double dnrm2_(int *n,const double *x, int *incx); - void idmin_(int *n,const double *sx, int *incx); - complex zdot_(int *n,const Complex *x, int *incx,const Complex *y, int *incy); - void zcopy_(int *n,const Complex *x, int *incx, Complex *y,int *incy); - void zscal_(int *n,const Complex *alpha, Complex *x, int *incx); - void zaxpy_(int *n,const Complex *alpha,const Complex *x, int *incx, - Complex *y, int *incy); - double znrm2_(int *n,const Complex *x, int *incx); - +// BLAS function +double ddot_(int *n, const double *x, int *incx, const double *y, int *incy); +void dcopy_(int *n, const double *x, int *incx, const double *y, int *incy); +void dscal_(int *n, const double *alpha, double *x, int *incx); +void daxpy_(int *n, const double *alpha, const double *x, int *incx, double *y, int *incy); +double dnrm2_(int *n, const double *x, int *incx); +void idmin_(int *n, const double *sx, int *incx); +complex zdot_(int *n, const Complex *x, int *incx, const Complex *y, int *incy); +void zcopy_(int *n, const Complex *x, int *incx, Complex *y, int *incy); +void zscal_(int *n, const Complex *alpha, Complex *x, int *incx); +void zaxpy_(int *n, const Complex *alpha, const Complex *x, int *incx, Complex *y, int *incy); +double znrm2_(int *n, const Complex *x, int *incx); + #ifdef __cplusplus } #endif -template -double * mysnrm2(int n,double *x) -{ - int un=1; - return dnrm2_(&n,x,un); +template< int, double > +double *mysnrm2(int n, double *x) { + int un = 1; + return dnrm2_(&n, x, un); } - -template -double * myscopy(int n,const double *x,double *y) -{ - int un=1; - dcopy_(&n,x,&un,y,&un); - return y; +template< int, double > +double *myscopy(int n, const double *x, double *y) { + int un = 1; + dcopy_(&n, x, &un, y, &un); + return y; } -template -double mysdot(int n,const double *x,const double *y) -{ - int un=1; - return ddot_(&n,x,&un,y,&un); +template< int, double > +double mysdot(int n, const double *x, const double *y) { + int un = 1; + return ddot_(&n, x, &un, y, &un); } -template -double * mysaxpy(int n,double a,const double *x,double *y) -{ - int un=1; - daxpy_(&n,&a,x,&un,y,&un); - return y; +template< int, double > +double *mysaxpy(int n, double a, const double *x, double *y) { + int un = 1; + daxpy_(&n, &a, x, &un, y, &un); + return y; } -template -double * mysax2y(int n,double a,const double *x,double *y) -{ - int un=1; - std::fill(y,y+1,0.); - daxpy_(&n,&a,x,&un,y,&un); - return y; +template< int, double > +double *mysax2y(int n, double a, const double *x, double *y) { + int un = 1; + std::fill(y, y + 1, 0.); + daxpy_(&n, &a, x, &un, y, &un); + return y; } -template -double * myscal(int n,double a,double *x) -{ - int un=1; - dscal_(&n,&a,x,&un); - return x; +template< int, double > +double *myscal(int n, double a, double *x) { + int un = 1; + dscal_(&n, &a, x, &un); + return x; } -template -double * mysnrm2(int n,const Complex *x) -{ - int un=1; - return znrm2_(&n,x,un); +template< int, Complex > +double *mysnrm2(int n, const Complex *x) { + int un = 1; + return znrm2_(&n, x, un); } -template -Complex * myscopy(int n,const Complex *x,Complex *y) -{ - int un=1; - zcopy_(&n,x,&un,y,&un); - return y; +template< int, Complex > +Complex *myscopy(int n, const Complex *x, Complex *y) { + int un = 1; + zcopy_(&n, x, &un, y, &un); + return y; } -template -Complex mysdot(int n,const Complex *x,const Complex *y) -{ - int un=1; - return zdotc_(&n,x,&un,y,&un); +template< int, Complex > +Complex mysdot(int n, const Complex *x, const Complex *y) { + int un = 1; + return zdotc_(&n, x, &un, y, &un); } -template -Complex * mysaxpy(int n,Complex a,const Complex *x,Complex *y) -{ - int un=1; - zaxpy_(&n,&a,x,&un,y,&un); - return y; +template< int, Complex > +Complex *mysaxpy(int n, Complex a, const Complex *x, Complex *y) { + int un = 1; + zaxpy_(&n, &a, x, &un, y, &un); + return y; } -template -Complex * mysax2y(int n,Complex a,const Complex *x,Complex *y) -{ - int un=1; - std::fill(x,x+n,Complex(0.)); - zaxpy_(&n,&a,x,&un,y,&un); - return y; +template< int, Complex > +Complex *mysax2y(int n, Complex a, const Complex *x, Complex *y) { + int un = 1; + std::fill(x, x + n, Complex(0.)); + zaxpy_(&n, &a, x, &un, y, &un); + return y; } -template -Complex * myscal(int n,Complex a,Complex *x) -{ - int un=1; - zscal_(&n,&a,x,&un); - return x; +template< int, Complex > +Complex *myscal(int n, Complex a, Complex *x) { + int un = 1; + zscal_(&n, &a, x, &un); + return x; } #else #endif - -template -K * SetArrayGC(I *x,long n,K c) -{ - std::fill(x,x+n,c); - return x; +template< class I, class K > +K *SetArrayGC(I *x, long n, K c) { + std::fill(x, x + n, c); + return x; } -template -int ConjugueGradient(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - TypeScalar * b, // second membre - TypeScalar * x, // solution qui contient une initialisation - int &nbitermax,// change FH mars 2020 add & - double &eps,// change FH mars 2020 add & +template< class TypeIndex, class TypeScalar > +int ConjugueGradient(CGMatVirt< TypeIndex, TypeScalar > &A, // fonction et pointeur data pour A + CGMatVirt< TypeIndex, TypeScalar > &C, // fonction et pointeur data pour C + TypeScalar *b, // second membre + TypeScalar *x, // solution qui contient une initialisation + int &nbitermax, // change FH mars 2020 add & + double &eps, // change FH mars 2020 add & int niveauimpression) { - using namespace std; - typedef TypeIndex Z; - typedef TypeScalar K; - - // niveauimpression: 0: pas impression .. 10 a chaque iteration - Z n = A.n, nret=0; - K NaN = nan(""); - K * G = SetArrayGC(new K[n] ,n,NaN); - K * CG= SetArrayGC(new K[n],n,NaN); - K *AH=CG;// meme tableau que CG Attention ?????? - K *H=SetArrayGC(new K[n],n,NaN); - K rho, gamma; - K minus1=-1.; - double gCgp, gCg, eps2=eps*eps; - assert( A.m==n && C.m==n && C.n==n); - niveauimpression=std::min(niveauimpression,10); - int nprint =std::max((int)(max(nbitermax+1,1000)*(10.-niveauimpression)/10.),1); - - mysaxpy(n,minus1,b,A.matmul(x,G));// G = Ax -b - gCg = real(mysdot(n,G,C.matmul(G,CG))) ; - myscal(n,minus1,myscopy(n,CG,H)); // H =- CG; - if( eps >0 ) { eps2 *=gCg ; eps = sqrt(eps2); } - - assert( !(gCg != gCg) ); // verif if NaN => bad Matrix.. - if(gCg < 1e-30) - { if(niveauimpression) - std::cout << " GC: converge after 0 iteration ||g||_C^2" << gCg << std::endl; - nret = 2; - nbitermax=0; + using namespace std; + typedef TypeIndex Z; + typedef TypeScalar K; + + // niveauimpression: 0: pas impression .. 10 a chaque iteration + Z n = A.n, nret = 0; + K NaN = nan(""); + K *G = SetArrayGC(new K[n], n, NaN); + K *CG = SetArrayGC(new K[n], n, NaN); + K *AH = CG; // meme tableau que CG Attention ?????? + K *H = SetArrayGC(new K[n], n, NaN); + K rho, gamma; + K minus1 = -1.; + double gCgp, gCg, eps2 = eps * eps; + assert(A.m == n && C.m == n && C.n == n); + niveauimpression = std::min(niveauimpression, 10); + int nprint = std::max((int)(max(nbitermax + 1, 1000) * (10. - niveauimpression) / 10.), 1); + + mysaxpy(n, minus1, b, A.matmul(x, G)); // G = Ax -b + gCg = real(mysdot(n, G, C.matmul(G, CG))); + myscal(n, minus1, myscopy(n, CG, H)); // H =- CG; + if (eps > 0) { + eps2 *= gCg; + eps = sqrt(eps2); + } + + assert(!(gCg != gCg)); // verif if NaN => bad Matrix.. + if (gCg < 1e-30) { + if (niveauimpression) std::cout << " GC: converge after 0 iteration ||g||_C^2" << gCg << std::endl; + nret = 2; + nbitermax = 0; + } else + for (int iter = 1; iter <= nbitermax; ++iter) { + gCgp = gCg; + rho = real(-mysdot(n, G, H) / mysdot(n, H, A.matmul(H, AH))); + + mysaxpy(n, rho, H, x); + mysaxpy(n, rho, AH, G); + gCg = real(mysdot(n, G, C.matmul(G, CG))); + gamma = gCg / gCgp; + mysaxpy(n, minus1, CG, myscal(n, gamma, H)); + + if (gCg < eps2) // We have converged ... + { + if (niveauimpression) std::cout << " GC: converge after " << iter << " g=" << gCg << " rho= " << rho << " gamma= " << gamma << std::endl; + ; + nret = 1; + nbitermax = iter; + break; + } else if (((iter + 1) % nprint) == 0) + std::cout << " GC:iteration " << iter << " rho " << rho << " gamma " << gamma << " ||g||_C^2:" << gCg << " / " << eps2 << std::endl; } - else - for(int iter=1; iter <= nbitermax; ++iter) - { - gCgp = gCg; - rho = real(-mysdot(n,G,H)/mysdot(n,H,A.matmul(H,AH))); - - mysaxpy(n,rho,H,x); - mysaxpy(n,rho,AH,G); - gCg = real(mysdot(n,G,C.matmul(G,CG))); - gamma = gCg/ gCgp; - mysaxpy(n,minus1,CG,myscal(n,gamma,H)); - - if(gCg < eps2) // We have converged ... - { - if(niveauimpression) - std::cout << " GC: converge after " < (CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - double * b, // second membre - double * x, // solution qui contient une initialisation - int &nbitermax, - double &eps, - int niveauimpression) -; - -template -int ConjugueGradient (CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - Complex * b, // second membre - Complex * x, // solution qui contient une initialisation - int &nbitermax, - double &eps, - int niveauimpression) -; - -template -int ConjugueGradient (CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - double * b, // second membre - double * x, // solution qui contient une initialisation - int &nbitermax, - double &eps, - int niveauimpression) -; - -template -int ConjugueGradient (CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - Complex * b, // second membre - Complex * x, // solution qui contient une initialisation - int &nbitermax, - double &eps, - int niveauimpression) -; - - -typedef CGMatVirt MatVirt; -#define DBL_EPSILON 2.2204460492503131e-16 // double epsilon +template int ConjugueGradient< int, double >(CGMatVirt< int, double > &A, // fonction et pointeur data pour A + CGMatVirt< int, double > &C, // fonction et pointeur data pour C + double *b, // second membre + double *x, // solution qui contient une initialisation + int &nbitermax, double &eps, int niveauimpression); + +template int ConjugueGradient< int, Complex >(CGMatVirt< int, Complex > &A, // fonction et pointeur data pour A + CGMatVirt< int, Complex > &C, // fonction et pointeur data pour C + Complex *b, // second membre + Complex *x, // solution qui contient une initialisation + int &nbitermax, double &eps, int niveauimpression); + +template int ConjugueGradient< long, double >(CGMatVirt< long, double > &A, // fonction et pointeur data pour A + CGMatVirt< long, double > &C, // fonction et pointeur data pour C + double *b, // second membre + double *x, // solution qui contient une initialisation + int &nbitermax, double &eps, int niveauimpression); + +template int ConjugueGradient< long, Complex >(CGMatVirt< long, Complex > &A, // fonction et pointeur data pour A + CGMatVirt< long, Complex > &C, // fonction et pointeur data pour C + Complex *b, // second membre + Complex *x, // solution qui contient une initialisation + int &nbitermax, double &eps, int niveauimpression); + +typedef CGMatVirt< int, double > MatVirt; +#define DBL_EPSILON 2.2204460492503131e-16 // double epsilon #define TINY 1.0e-20 -//typedef double FLOAT; -//typedef double REAL; -//#defined WITH_MPI -template -void UnDoPermute(int n,int *p,K *x,K *tmp) -{ - if(p) - { - for(int i=0; i< n; ++i) - tmp[p[i]]=x[i]; - for(int i=0; i< n; ++i) - x[i]= tmp[i]; - } +// typedef double FLOAT; +// typedef double REAL; +// #defined WITH_MPI +template< typename K > +void UnDoPermute(int n, int *p, K *x, K *tmp) { + if (p) { + for (int i = 0; i < n; ++i) tmp[p[i]] = x[i]; + for (int i = 0; i < n; ++i) x[i] = tmp[i]; + } } -template +template< typename K > -void DoPermute(int n,int *p,K *x,K *tmp) -{ - if(p) - { - for(int i=0; i< n; ++i) - tmp[i]=x[p[i]]; - for(int i=0; i< n; ++i) - x[i]= tmp[i]; - } +void DoPermute(int n, int *p, K *x, K *tmp) { + if (p) { + for (int i = 0; i < n; ++i) tmp[i] = x[p[i]]; + for (int i = 0; i < n; ++i) x[i] = tmp[i]; + } } - - - #include "RNM.hpp" - double ffconj(double x) {return x;} - Complex ffconj(Complex x) {return std::conj(x);} - -template -bool fgmres(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &CC,int leftC, - K *prhs, - K *px, - double &eps, - int &nbitermx, - int nbkrylov, - int verbo, - int *wbc) -{ - // This code is base of fgmres of F. Nataf, P. Jolivet and P-H Tournier. - // witten in freefem++ - - verbo=std::min(verbo,10); - int nprint =std::max((int)(max(nbkrylov+1,100)*(10.-verbo)/10.),1); - leftC=1; - typedef double R; - R relerr=1e100 , relres=1e100,normb=0.; - Z n = A.n; - K NaN = nan(""); - K * rot0 = SetArrayGC(new K[nbkrylov+2] ,nbkrylov+2,NaN); - K * rot1 = SetArrayGC(new K[nbkrylov+2] ,nbkrylov+2,NaN); - K * g = SetArrayGC(new K[nbkrylov+1] ,nbkrylov+1,NaN); - K * g1 = SetArrayGC(new K[nbkrylov+1] ,nbkrylov+1,NaN); - leftC = 0; - CGMatVirtId MatId(n); - CGMatVirt & C=CC; - CGMatVirt *pCl = leftC ? &C : &MatId; - CGMatVirt *pCr = !leftC ? &C : &MatId; - Z nrestart=0; - - - KN rwi(n),uni(n),x0(n),ri(n); - KNM Hn(nbkrylov+2,nbkrylov+1); - KN_ x(px,n),rhs(prhs,n); - KN< KN > Vi(nbkrylov+1),Vpi(nbkrylov+1); - KN zi(n),vi(n),wi(n); - Hn = K(); - wi = rhs; // remove tgv ???? -// ffassert(wbc) ; - int kk=0; - if( wbc) - for(int i=0; i< n; ++i) - if( wbc[i]) // remove TGV in RHS ... - kk++,wi[i]=K(); - // cout << " nbcl " << kk<< endl; - pCl->matmul(wi,vi); - // remove BC part - - normb = mysnrm2(n,(K*) vi); - //cout << " normb " << normb << " "<< endl; - uni = x; - K minus1 = K(-1.); - bool noconv = true; - int iter =0;// - while (noconv) - { - x0=uni; - // ri[] = matA(uni); ri[] -= rhs; ri[] *= -1.0; - myscal(n,minus1,mysaxpy(n,minus1,prhs,A.matmul(uni,ri))); - pCl->matmul(ri,zi); - // g[0] = sqrt(real(pr#scalprod(zi[],zi[]))); - g[0]=mysnrm2(n,(K*)zi); - if(verbo>3) - cout << " ** fgmres: " << iter << " residus 0 " << abs(g[0]) << " Cl: " << normb << endl ; - if (normb < 1.e-20 || eps < 0) normb = 1.; - Vi[0]=(1./g[0])*zi; - int it; // need for reconstruction - for( it=0; itmatmul(Vi[it],vi); - - if (!leftC) { - C.matmul(Vi[it],vi);// preCON(Vi[it][]); - Vpi[it]=vi; - // vi[]=Vpi[it][]; - A.matmul(vi,wi);// wi[]=matA(vi[]); - - } - else { - A.matmul(Vi[it],vi);// vi[]=matA(Vi[it][]); - C.matmul(vi,wi);// wi[] = preCON(vi[]); - } - // mofif Gram Schmidt - for(int i=0; i nbitermx) break; // no converge +double ffconj(double x) { return x; } +Complex ffconj(Complex x) { return std::conj(x); } + +template< typename K, typename Z = int > +bool fgmres(CGMatVirt< Z, K > &A, // fonction et pointeur data pour A + CGMatVirt< Z, K > &CC, int leftC, K *prhs, K *px, double &eps, int &nbitermx, int nbkrylov, int verbo, int *wbc) { + // This code is base of fgmres of F. Nataf, P. Jolivet and P-H Tournier. + // witten in freefem++ + + verbo = std::min(verbo, 10); + int nprint = std::max((int)(max(nbkrylov + 1, 100) * (10. - verbo) / 10.), 1); + leftC = 1; + typedef double R; + R relerr = 1e100, relres = 1e100, normb = 0.; + Z n = A.n; + K NaN = nan(""); + K *rot0 = SetArrayGC(new K[nbkrylov + 2], nbkrylov + 2, NaN); + K *rot1 = SetArrayGC(new K[nbkrylov + 2], nbkrylov + 2, NaN); + K *g = SetArrayGC(new K[nbkrylov + 1], nbkrylov + 1, NaN); + K *g1 = SetArrayGC(new K[nbkrylov + 1], nbkrylov + 1, NaN); + leftC = 0; + CGMatVirtId< Z, K > MatId(n); + CGMatVirt< Z, K > &C = CC; + CGMatVirt< Z, K > *pCl = leftC ? &C : &MatId; + CGMatVirt< Z, K > *pCr = !leftC ? &C : &MatId; + Z nrestart = 0; + + KN< K > rwi(n), uni(n), x0(n), ri(n); + KNM< K > Hn(nbkrylov + 2, nbkrylov + 1); + KN_< K > x(px, n), rhs(prhs, n); + KN< KN< K > > Vi(nbkrylov + 1), Vpi(nbkrylov + 1); + KN< K > zi(n), vi(n), wi(n); + Hn = K( ); + wi = rhs; // remove tgv ???? + // ffassert(wbc) ; + int kk = 0; + if (wbc) + for (int i = 0; i < n; ++i) + if (wbc[i]) // remove TGV in RHS ... + kk++, wi[i] = K( ); + // cout << " nbcl " << kk<< endl; + pCl->matmul(wi, vi); + // remove BC part + + normb = mysnrm2(n, (K *)vi); + // cout << " normb " << normb << " "<< endl; + uni = x; + K minus1 = K(-1.); + bool noconv = true; + int iter = 0; // + while (noconv) { + x0 = uni; + // ri[] = matA(uni); ri[] -= rhs; ri[] *= -1.0; + myscal(n, minus1, mysaxpy(n, minus1, prhs, A.matmul(uni, ri))); + pCl->matmul(ri, zi); + // g[0] = sqrt(real(pr#scalprod(zi[],zi[]))); + g[0] = mysnrm2(n, (K *)zi); + if (verbo > 3) cout << " ** fgmres: " << iter << " residus 0 " << abs(g[0]) << " Cl: " << normb << endl; + if (normb < 1.e-20 || eps < 0) normb = 1.; + Vi[0] = (1. / g[0]) * zi; + int it; // need for reconstruction + for (it = 0; it < nbkrylov; it++, iter++) { + pCr->matmul(Vi[it], vi); + + if (!leftC) { + C.matmul(Vi[it], vi); // preCON(Vi[it][]); + Vpi[it] = vi; + // vi[]=Vpi[it][]; + A.matmul(vi, wi); // wi[]=matA(vi[]); + + } else { + A.matmul(Vi[it], vi); // vi[]=matA(Vi[it][]); + C.matmul(vi, wi); // wi[] = preCON(vi[]); + } + // mofif Gram Schmidt + for (int i = 0; i < it + 1; i++) { + Hn(i, it) = mysdot(n, (K *)wi, (K *)Vi[i]); + mysaxpy(n, -ffconj(Hn(i, it)), (K *)Vi[i], (K *)wi); // wi = ffconj(Hn(i,it))* Vi[i]; + } + K aux = Hn(it + 1, it) = mysnrm2(n, (K *)(K *)wi); + + Vi[it + 1] = (1. / aux) * wi; + /* QR decomposition of Hn*/ + for (int i = 0; i < it; i++) { /* QR decomposition of Hn*/ + K aa = ffconj(rot0[i]) * Hn(i, it) + ffconj(rot1[i]) * Hn(i + 1, it); + K bb = -rot1[i] * Hn(i, it) + rot0[i] * Hn(i + 1, it); + Hn(i, it) = aa; + Hn(i + 1, it) = bb; + // cout << i << " " << aa << " " << bb << endl; + } + K sq = sqrt(ffconj(Hn(it, it)) * Hn(it, it) + Hn(it + 1, it) * Hn(it + 1, it)); + rot0[it] = Hn(it, it) / sq; + rot1[it] = Hn(it + 1, it) / sq; + // cout << " sq " << sq << " " << rot0[it] << " " << rot1[it] << endl; + + Hn(it, it) = ffconj(rot0[it]) * Hn(it, it) + ffconj(rot1[it]) * Hn(it + 1, it); + Hn(it + 1, it) = 0.; + g[it + 1] = -rot1[it] * g[it]; + g[it] = ffconj(rot0[it]) * g[it]; + + relres = abs(g[it + 1]); // residu gmres ||Ax -b ||_2 + if ((iter + 1) % nprint == 0) cout << " fgmres " << iter << " Res: = " << relres << " Rel res = " << relres / normb << endl; + + if (relres / normb < abs(eps)) { + noconv = false; + if (verbo) { + cout << " ** fgmres has converged in " << (iter) << " iterations " + << "The relative residual is " << relres / normb << " Cl: " << normb << endl; } - it = min(it,nbkrylov-1); - /* Reconstruct the solution */ - // use g0, g1 , Hn , Vp, Vpi (fgmres) - - KN y(it+1); - for(int i=it; i>=0; i--) - { - g1[i] = g[i]; - for(int j=i+1; jmatmul(wi,uni);// uni[]= Precon(uni[]) if (!leffC) pas flexi - uni += x0;// - x = uni; - // Fin reconstruction de la solution - - if(!noconv) break; - if( iter > nbitermx) break; // no converge - if( (nrestart++< verbo) && (verbo> 2) ) - cout << " ** restart fgmres iter " < nbitermx) break; // no converge } - if(noconv && verbo ) - { - cout << " !!!!!!!! fgmres has not converged in " << iter << " iterations " - << "The relative residual is " << relres/normb << " Cl: " << normb << endl; + it = min(it, nbkrylov - 1); + /* Reconstruct the solution */ + // use g0, g1 , Hn , Vp, Vpi (fgmres) + + KN< K > y(it + 1); + for (int i = it; i >= 0; i--) { + g1[i] = g[i]; + for (int j = i + 1; j < it + 1; j++) g1[i] = g1[i] - Hn(i, j) * y[j]; + y[i] = g1[i] / Hn(i, i); + } + + wi = K( ); + for (int i = 0; i < it + 1; i++) { + if (!leftC) + wi += ffconj(y[i]) * Vpi[i]; // ICI Fgmres ... pas de tableau Vpi ... + else + wi += ffconj(y[i]) * Vi[i]; } - nbitermx=iter; // to - delete [] g1; - delete [] g; - delete [] rot1; - delete [] rot0; - return !noconv; + uni = wi; // + // pCr->matmul(wi,uni);// uni[]= Precon(uni[]) if (!leffC) pas flexi + uni += x0; // + x = uni; + // Fin reconstruction de la solution + + if (!noconv) break; + if (iter > nbitermx) break; // no converge + if ((nrestart++ < verbo) && (verbo > 2)) cout << " ** restart fgmres iter " << iter << " res: " << relres / normb << endl; + } + if (noconv && verbo) { + cout << " !!!!!!!! fgmres has not converged in " << iter << " iterations " + << "The relative residual is " << relres / normb << " Cl: " << normb << endl; + } + nbitermx = iter; // to + delete[] g1; + delete[] g; + delete[] rot1; + delete[] rot0; + return !noconv; } -template -bool fgmres(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C,int leftC, - double *y, - double *x, - double &tol, - int &maxits, - int restart, - int verb, - int *wbc); -template -bool fgmres(CGMatVirt > &A, // fonction et pointeur data pour A - CGMatVirt > &C,int leftC, - std::complex *y, - std::complex *x, - double &tol, - int &maxits, - int restart, - int verb, - int *wbc); -template -bool fgmres(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C,int leftC, - double *y, - double *x, - double &tol, - int &maxits, - int restart, - int verb, - int *wbc ); -template -bool fgmres(CGMatVirt > &A, // fonction et pointeur data pour A - CGMatVirt > &C,int leftC, - std::complex *y, - std::complex *x, - double &tol, - int &maxits, - int restart, - int verb, - int *wbc ); - - -template double * myscopy(int n,const double *x,double *y); -template double * myscal(int n,double a,double *x); -template double * myscopy(unsigned long n,const double *x,double *y); -template double * myscal(unsigned long n,double a,double *x); -template double * mysaxpy(int n,double a,const double *x,double *y); - -template Complex * myscopy(int n,const Complex *x,Complex *y); -template Complex * myscal(int n,Complex a,Complex *x); -template Complex * myscopy(unsigned long n,const Complex *x,Complex *y); -template Complex * myscal(unsigned long n,Complex a,Complex *x); -template Complex * mysaxpy(int n,Complex a,const Complex *x,Complex *y); +template bool fgmres(CGMatVirt< int, double > &A, // fonction et pointeur data pour A + CGMatVirt< int, double > &C, int leftC, double *y, double *x, double &tol, int &maxits, int restart, int verb, int *wbc); +template bool fgmres(CGMatVirt< int, std::complex< double > > &A, // fonction et pointeur data pour A + CGMatVirt< int, std::complex< double > > &C, int leftC, std::complex< double > *y, std::complex< double > *x, double &tol, int &maxits, int restart, int verb, int *wbc); +template bool fgmres(CGMatVirt< long, double > &A, // fonction et pointeur data pour A + CGMatVirt< long, double > &C, int leftC, double *y, double *x, double &tol, int &maxits, int restart, int verb, int *wbc); +template bool fgmres(CGMatVirt< long, std::complex< double > > &A, // fonction et pointeur data pour A + CGMatVirt< long, std::complex< double > > &C, int leftC, std::complex< double > *y, std::complex< double > *x, double &tol, int &maxits, int restart, int verb, int *wbc); + +template double *myscopy< int, double >(int n, const double *x, double *y); +template double *myscal< int, double >(int n, double a, double *x); +template double *myscopy< unsigned long, double >(unsigned long n, const double *x, double *y); +template double *myscal< unsigned long, double >(unsigned long n, double a, double *x); +template double *mysaxpy(int n, double a, const double *x, double *y); + +template Complex *myscopy< int, Complex >(int n, const Complex *x, Complex *y); +template Complex *myscal< int, Complex >(int n, Complex a, Complex *x); +template Complex *myscopy< unsigned long, Complex >(unsigned long n, const Complex *x, Complex *y); +template Complex *myscal< unsigned long, Complex >(unsigned long n, Complex a, Complex *x); +template Complex *mysaxpy(int n, Complex a, const Complex *x, Complex *y); diff --git a/src/femlib/CG.hpp b/src/femlib/CG.hpp index 549c040d1..073735986 100644 --- a/src/femlib/CG.hpp +++ b/src/femlib/CG.hpp @@ -28,9 +28,9 @@ extern long verbosity; -template +template< class TypeIndex = int, class TypeScalar = double > struct CGMatVirt { -public: + public: typedef TypeIndex I; typedef TypeScalar R; @@ -38,60 +38,60 @@ struct CGMatVirt { mutable int it; mutable double cpu; virtual R *addmatmul(R *x, R *Ax) const = 0; - virtual ~CGMatVirt() { - if (verbosity > 5) - std::cout << " cpu CGMatVirt " << cpu << " s / " << it << " nb mul " << std::endl; + virtual ~CGMatVirt( ) { + if (verbosity > 5) std::cout << " cpu CGMatVirt " << cpu << " s / " << it << " nb mul " << std::endl; } virtual R *matmul(R *x, R *Ax) const { it++; - std::fill(Ax, Ax+n, 0.); - double t0 = ((double) clock())/CLOCKS_PER_SEC; - R*p = addmatmul(x, Ax); - cpu += ((double)clock())/CLOCKS_PER_SEC - t0; + std::fill(Ax, Ax + n, 0.); + double t0 = ((double)clock( )) / CLOCKS_PER_SEC; + R *p = addmatmul(x, Ax); + cpu += ((double)clock( )) / CLOCKS_PER_SEC - t0; return p; } - virtual void SetInitWithBC(R*rhs, R *x) const {} // do nothing by default .. - CGMatVirt(int nn, int mm=-1) : n(nn), m(mm < 0 ? nn : mm), cpu(0.), it(0) {} - virtual int *pwcl() const { return 0; } // array know if node with BC (TGV) + virtual void SetInitWithBC(R *rhs, R *x) const {} // do nothing by default .. + CGMatVirt(int nn, int mm = -1) : n(nn), m(mm < 0 ? nn : mm), cpu(0.), it(0) {} + virtual int *pwcl( ) const { return 0; } // array know if node with BC (TGV) }; -template -int ConjugueGradient(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, // fonction et pointeur data pour C - TypeScalar *b, // second membre - TypeScalar *x, // solution qui contient une initialisation - int &nbitermax, - double &eps, - int niveauimpression); +template< class TypeIndex = int, class TypeScalar = double > +int ConjugueGradient(CGMatVirt< TypeIndex, TypeScalar > &A, // fonction et pointeur data pour A + CGMatVirt< TypeIndex, TypeScalar > &C, // fonction et pointeur data pour C + TypeScalar *b, // second membre + TypeScalar *x, // solution qui contient une initialisation + int &nbitermax, double &eps, int niveauimpression); -template -bool fgmres(CGMatVirt &A, // fonction et pointeur data pour A - CGMatVirt &C, int leftC, - K *y, - K *x, - double &tol, - int &maxits, - int restart=50, - int verbo=3, - int *perm=0); +template< typename K, typename Z > +bool fgmres(CGMatVirt< Z, K > &A, // fonction et pointeur data pour A + CGMatVirt< Z, K > &C, int leftC, K *y, K *x, double &tol, int &maxits, int restart = 50, int verbo = 3, int *perm = 0); -template +template< class I, class K > K *myscopy(I n, const K *x, K *y); -template +template< class I, class K > K *myscal(I n, K a, K *x); -template -inline double *ProduitMatVec(const CGMatVirt *A, TypeScalar *x, TypeScalar *Ax) { return A->matmul(x, Ax); } -template -inline double *ProduitMatVec(const CGMatVirt &A, TypeScalar *x, TypeScalar *Ax) { return A.matmul(x, Ax); } -template K *mysaxpy(I n, K a, const K *x, K *y); - -template -struct CGMatVirtId : public CGMatVirt { - CGMatVirtId(Z nn): CGMatVirt (nn, nn) {} - R *matmul(R *x, R *Ax) const { myscopy(this->n, x, Ax); return Ax; } - R *addmatmul(R *x, R *Ax) const { mysaxpy(this->n,R(1.), x, Ax); return Ax; } +template< class TypeIndex = int, class TypeScalar = double > +inline double *ProduitMatVec(const CGMatVirt< TypeIndex, TypeScalar > *A, TypeScalar *x, TypeScalar *Ax) { + return A->matmul(x, Ax); +} +template< class TypeIndex = int, class TypeScalar = double > +inline double *ProduitMatVec(const CGMatVirt< TypeIndex, TypeScalar > &A, TypeScalar *x, TypeScalar *Ax) { + return A.matmul(x, Ax); +} +template< class I, class K > +K *mysaxpy(I n, K a, const K *x, K *y); +template< class Z = int, class R = double > +struct CGMatVirtId : public CGMatVirt< Z, R > { + CGMatVirtId(Z nn) : CGMatVirt< Z, R >(nn, nn) {} + R *matmul(R *x, R *Ax) const { + myscopy(this->n, x, Ax); + return Ax; + } + R *addmatmul(R *x, R *Ax) const { + mysaxpy(this->n, R(1.), x, Ax); + return Ax; + } }; -#endif // _CG_HPP_ +#endif // _CG_HPP_ diff --git a/src/femlib/CGNL.hpp b/src/femlib/CGNL.hpp index ddb89b559..a00c200b8 100644 --- a/src/femlib/CGNL.hpp +++ b/src/femlib/CGNL.hpp @@ -2,118 +2,109 @@ #ifndef CGNL_HPP_ #define CGNL_HPP_ -template -R argmin(R rho,const DJ & dJ, KN_ &x,KN_ &h,KN_ &g,KN_ &w) -{ - // Find ro such thah (dJ(x+ro h),h) =0 - // remark input: dJ(x)=g - int k=0; -// g=dJ*x; // pour est sure - R ro0=0, ro=rho,ro1=rho,rold=0; - R p0= (g,h),p,p1; - if(p0>0) { h=-g; p0=(g,h); +template< class R, class DJ > +R argmin(R rho, const DJ &dJ, KN_< R > &x, KN_< R > &h, KN_< R > &g, KN_< R > &w) { + // Find ro such thah (dJ(x+ro h),h) =0 + // remark input: dJ(x)=g + int k = 0; + // g=dJ*x; // pour est sure + R ro0 = 0, ro = rho, ro1 = rho, rold = 0; + R p0 = (g, h), p, p1; + if (p0 > 0) { + h = -g; + p0 = (g, h); cout << "Reset searching directions to gradient! (Wow! says F. hecht) \n"; - } - R ap0=fabs(p0)*0.01; // on arrete quand on a divise par 100. - - x += (ro-rold)* h; rold=ro; g=dJ*x;// dJ(x,g); - p= ( p1 = (g,h) ); - if ( verbosity >=50 ) - cout << " ro " << ro << " " << p - << " rh0= 0 " << p0 << endl; - - - bool loop=true; - while (k++<100 && loop) - { // calcul du nouveau ro courant - - if (p0*p1 <0) { // Ok changement de signe - R lambda= (-p0/(-p0+p1)); - if (lambda>0.8) lambda=0.8; - if (lambda<0.2) lambda=0.2; - ro = ro1*lambda + (1-lambda)*ro0 ; - x += (ro-rold)* h; rold=ro; g=dJ*x;// dJ(x,g); - assert(ro>1e-30 && ro < 1e+30); - p = (g,h); - if ( verbosity >=50 ) - cout << " " << ", rho=" << ro << " gh= " << p - << "; ro0, gh0 = " << ro0 << " " << p0 - << "; ro1, gh1 = " << ro1 << " " << p1 << " " << lambda ; - - if(fabs(p) <= ap0 || k>100 ) { - if ( verbosity >=50 ) - cout << endl << endl; - return ro; - } - if(p0*p<0) { - p1=p; - ro1=ro; - if ( verbosity >=50 ) cout << " +\n";} - else { - p0=p; - ro0=ro; - if ( verbosity >=50 ) cout <<" -\n";} + } + R ap0 = fabs(p0) * 0.01; // on arrete quand on a divise par 100. + + x += (ro - rold) * h; + rold = ro; + g = dJ * x; // dJ(x,g); + p = (p1 = (g, h)); + if (verbosity >= 50) cout << " ro " << ro << " " << p << " rh0= 0 " << p0 << endl; + + bool loop = true; + while (k++ < 100 && loop) { // calcul du nouveau ro courant + + if (p0 * p1 < 0) { // Ok changement de signe + R lambda = (-p0 / (-p0 + p1)); + if (lambda > 0.8) lambda = 0.8; + if (lambda < 0.2) lambda = 0.2; + ro = ro1 * lambda + (1 - lambda) * ro0; + x += (ro - rold) * h; + rold = ro; + g = dJ * x; // dJ(x,g); + assert(ro > 1e-30 && ro < 1e+30); + p = (g, h); + if (verbosity >= 50) cout << " " << ", rho=" << ro << " gh= " << p << "; ro0, gh0 = " << ro0 << " " << p0 << "; ro1, gh1 = " << ro1 << " " << p1 << " " << lambda; + + if (fabs(p) <= ap0 || k > 100) { + if (verbosity >= 50) cout << endl << endl; + return ro; + } + if (p0 * p < 0) { + p1 = p; + ro1 = ro; + if (verbosity >= 50) cout << " +\n"; + } else { + p0 = p; + ro0 = ro; + if (verbosity >= 50) cout << " -\n"; } - else - { - ro *=2; - p0=p1; - x += (ro-rold)* h; rold=ro; g=dJ*x;//dJ(x,g); - p = (g,h); - p1=p; - ro1=ro; - if ( verbosity >=50 ) cout <= 50) cout << p << " " << ro << " 2* "; + } + } ExecError("NLCG: ArgMin loop (convexe minimization? )"); return 0; } -template -int NLCG(const DJ & dJ,const P & C,KN_ &x,const int nbitermax, double &eps,long kprint=1000000000,S *Stop=0) -{ +template< class R, class DJ, class P, class S > +int NLCG(const DJ &dJ, const P &C, KN_< R > &x, const int nbitermax, double &eps, long kprint = 1000000000, S *Stop = 0) { // ------------- - // assert(&x && &dJ && &C); - typedef KN Rn; - int n=x.N(); - - R ro=1; - Rn g(n),h(n),Ah(n), & Cg(Ah); // on utilise Ah pour stocke Cg - g=dJ*x;// dJ(x,g); - Cg = C*g; // gradient preconditionne - h =-Cg; - R g2 = (Cg,g); - if (g2 < 1e-30) - { if(kprint>1) - cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; - return 2; } - if (kprint>5 ) - cout << " 0 GCNL g^2 =" << g2 << endl; - R reps2 =eps >0 ? eps*eps*g2 : -eps; // epsilon relatif + // assert(&x && &dJ && &C); + typedef KN< R > Rn; + int n = x.N( ); + + R ro = 1; + Rn g(n), h(n), Ah(n), &Cg(Ah); // on utilise Ah pour stocke Cg + g = dJ * x; // dJ(x,g); + Cg = C * g; // gradient preconditionne + h = -Cg; + R g2 = (Cg, g); + if (g2 < 1e-30) { + if (kprint > 1) cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; + return 2; + } + if (kprint > 5) cout << " 0 GCNL g^2 =" << g2 << endl; + R reps2 = eps > 0 ? eps * eps * g2 : -eps; // epsilon relatif eps = reps2; - for (int iter=0;iter<=nbitermax;iter++) - { - ro = argmin(ro,dJ,x,h,g,Ah); - - Cg = C*g; - R g2p=g2; - g2 = (Cg,g); - bool stop = Stop && Stop->Stop(iter,x,g); - if ( kprint >1 ) - cout << "CGNL:" <= 201103L @@ -32,21 +32,18 @@ static long verbosity; - -static long StorageUsed() -{ +static long StorageUsed( ) { #if MALLOC_ZONE_SPECIFIC_FLAGS - struct mstats mem1; - mem1 = mstats(); - return mem1.bytes_used; + struct mstats mem1; + mem1 = mstats( ); + return mem1.bytes_used; #elif M_MMAP_THRESHOLD - struct mallinfo mem1; - mem1=mallinfo(); - return mem1.uordblks; + struct mallinfo mem1; + mem1 = mallinfo( ); + return mem1.uordblks; #else - return 0; + return 0; #endif - } #ifndef NCHECKPTR #define DEBUGUNALLOC 1 @@ -82,19 +79,18 @@ static long StorageUsed() #include #include -void debugalloc() -{ } +void debugalloc( ) {} -void debugunalloc() -{ static long count=0; +void debugunalloc( ) { + static long count = 0; // debugalloc(); - count++;} - + count++; +} -void exitalloc(int i) -{ static long count=0; - count++; - exit(1); +void exitalloc(int i) { + static long count = 0; + count++; + exit(1); } // Modif: Juin 2001 for debuging missing delete point @@ -103,41 +99,34 @@ void exitalloc(int i) // #define SHOWALLOC // TO DEBUG ALL UN DELETE POINETUR +int UnShowAlloc = 1; -int UnShowAlloc =1; +int ShowAlloc(const char *s, size_t &lg); -int ShowAlloc(const char *s,size_t & lg); +// inline void *operator new(size_t, void *place) { return place; } -//inline void *operator new(size_t, void *place) { return place; } - -static int kerr=0; -void * mymalloc(size_t l) -{ - char *p = (char*)malloc(l+16); +static int kerr = 0; +void *mymalloc(size_t l) { + char *p = (char *)malloc(l + 16); if (!p) return p; - for( int i = 0; i < 8 ; i++) - p[i] = 'a'+i,p[i+l+8] = 'z'-i; // put a marque before - return (void*) (p+8); + for (int i = 0; i < 8; i++) p[i] = 'a' + i, p[i + l + 8] = 'z' - i; // put a marque before + return (void *)(p + 8); } -void myfree(char *p,size_t l=0,int nordre=0) -{ - if(p) { +void myfree(char *p, size_t l = 0, int nordre = 0) { + if (p) { p -= 8; - int k =0; - for( int i = 0; i < 8 ; i++) - { - if (p[i] != 'a' +i) k++; - if(l && (p[i+l+8] != 'z' -i)) k++; - } - for (size_t i=0;ir) {c[i]=crit;break;} // L8 -> G2 - if ((j G2 + while (1) { // label 2 + if (l <= 1) { // label 20 + crit = c[r]; + c[r--] = c[1]; + if (r == 1) { + c[1] = crit; + return; + } + } else + crit = c[--l]; + j = l; + while (1) { // label 4 + i = j; + j = 2 * j; + if (j > r) { + c[i] = crit; + break; + } // L8 -> G2 + if ((j < r) && (*c[j] < *c[j + 1])) j++; // L5 + if (*crit < *c[j]) + c[i] = c[j]; // L6+1 G4 + else { + c[i] = crit; + break; + } // L8 -> G2 } } } - class AllocData {public: + class AllocData { + public: OneAlloc *a; - AllocData * next; - AllocData(); - ~AllocData(); - private: - AllocData(const AllocExtern::AllocData&); - void operator=(const AllocExtern::AllocData&); - }; + AllocData *next; + AllocData( ); + ~AllocData( ); -private: + private: + AllocData(const AllocExtern::AllocData &); + void operator=(const AllocExtern::AllocData &); + }; + private: static const long Maxundelptr = 2048; - static size_t StorageUsage; - static size_t AllocSize ; + static size_t StorageUsage; + static size_t AllocSize; static size_t MaxUsedSize; - static AllocData * AllocHead ; + static AllocData *AllocHead; static long NbAlloc; static long NbAllocShow; static long NbPtr; - static void * NextFree; + static void *NextFree; static long NbuDelPtr; static long uDelPtr[Maxundelptr]; static bool after_end; static char filename[128]; - AllocData * NewAllocData(); - OneAlloc *Alloc(); - static const int nblastalloc=20; - static OneAlloc * LastAlloc[nblastalloc]; -public: - static bool CheckAlloc ; - - void * MyNewOperator(size_t ll,bool is_array ); - void MyDeleteOperator(void * pp,bool is_array); - AllocExtern(); - ~AllocExtern(); - void init(); - int ShowAlloc( const char *s,size_t & lg); - bool IsUnDelPtr(long nn) { // dichotomic find - long i=0; - long j=NbuDelPtr-1; - while (i<=j) { - long k = (i+j)/2, kn=uDelPtr[k]; - if ( nn kn) i = k+1; + AllocData *NewAllocData( ); + OneAlloc *Alloc( ); + static const int nblastalloc = 20; + static OneAlloc *LastAlloc[nblastalloc]; + + public: + static bool CheckAlloc; + + void *MyNewOperator(size_t ll, bool is_array); + void MyDeleteOperator(void *pp, bool is_array); + AllocExtern( ); + ~AllocExtern( ); + void init( ); + int ShowAlloc(const char *s, size_t &lg); + bool IsUnDelPtr(long nn) { // dichotomic find + long i = 0; + long j = NbuDelPtr - 1; + while (i <= j) { + long k = (i + j) / 2, kn = uDelPtr[k]; + if (nn < kn) + j = k - 1; + else if (nn > kn) + i = k + 1; else - return true;} + return true; + } return false; } }; static AllocExtern AllocExternData; -size_t AllocExtern::StorageUsage=0; -size_t AllocExtern::AllocSize =0; -size_t AllocExtern::MaxUsedSize =0; -AllocExtern::AllocData * AllocExtern::AllocHead =0; -long AllocExtern::NbAlloc =0; -long AllocExtern::NbAllocShow=0; -long AllocExtern::NbPtr =0; -void * AllocExtern::NextFree =0; -long AllocExtern::NbuDelPtr =0; +size_t AllocExtern::StorageUsage = 0; +size_t AllocExtern::AllocSize = 0; +size_t AllocExtern::MaxUsedSize = 0; +AllocExtern::AllocData *AllocExtern::AllocHead = 0; +long AllocExtern::NbAlloc = 0; +long AllocExtern::NbAllocShow = 0; +long AllocExtern::NbPtr = 0; +void *AllocExtern::NextFree = 0; +long AllocExtern::NbuDelPtr = 0; long AllocExtern::uDelPtr[Maxundelptr]; -bool AllocExtern::after_end =false; +bool AllocExtern::after_end = false; bool AllocExtern::CheckAlloc = true; -char AllocExtern::filename[128] ="ListOfUnAllocPtr.bin"; -AllocExtern::OneAlloc * AllocExtern::LastAlloc[nblastalloc]; -AllocExtern::AllocData * AllocExtern::NewAllocData() -{ +char AllocExtern::filename[128] = "ListOfUnAllocPtr.bin"; +AllocExtern::OneAlloc *AllocExtern::LastAlloc[nblastalloc]; +AllocExtern::AllocData *AllocExtern::NewAllocData( ) { - AllocExtern::AllocData * ad = (AllocData *) mymalloc(sizeof(AllocData)); - ad->a = (OneAlloc*) mymalloc(sizeof(OneAlloc)*N100); - for (int i=0;ia[i].l=0,ad->a[i].p=NextFree,NextFree = & ad->a[i]; + AllocExtern::AllocData *ad = (AllocData *)mymalloc(sizeof(AllocData)); + ad->a = (OneAlloc *)mymalloc(sizeof(OneAlloc) * N100); + for (int i = 0; i < N100; i++) ad->a[i].l = 0, ad->a[i].p = NextFree, NextFree = &ad->a[i]; ad->next = AllocHead; AllocHead = ad; #ifdef SHOWALLOC - printf("\t\tCheckPtr: OneAlloc[100] %lx\n",this); + printf("\t\tCheckPtr: OneAlloc[100] %lx\n", this); #endif return ad; } - - -AllocExtern::OneAlloc * AllocExtern::Alloc() -{ - OneAlloc * f = (OneAlloc *) NextFree; - if (!f) - AllocHead = NewAllocData(); - f =(OneAlloc *) NextFree; +AllocExtern::OneAlloc *AllocExtern::Alloc( ) { + OneAlloc *f = (OneAlloc *)NextFree; + if (!f) AllocHead = NewAllocData( ); + f = (OneAlloc *)NextFree; if (!f) exitalloc(1); - NextFree = f->p; + NextFree = f->p; return f; } - -void * AllocExtern::MyNewOperator(size_t ll,bool is_array) -{ - if(after_end || !CheckAlloc) return malloc(ll); - init(); - AllocExtern::OneAlloc * a = Alloc(); +void *AllocExtern::MyNewOperator(size_t ll, bool is_array) { + if (after_end || !CheckAlloc) return malloc(ll); + init( ); + AllocExtern::OneAlloc *a = Alloc( ); a->p = mymalloc(ll); - a->l = ll+1; // pour les allocation null + a->l = ll + 1; // pour les allocation null a->n = ++NbAlloc; a->is_array = is_array; - LastAlloc[NbPtr%nblastalloc] = a; + LastAlloc[NbPtr % nblastalloc] = a; NbPtr++; AllocSize += ll; #ifdef DEBUGUNALLOC - if ( (IsUnDelPtr(a->n) && (a->n >= DEBUGUNALLOC) )) - debugunalloc(); + if ((IsUnDelPtr(a->n) && (a->n >= DEBUGUNALLOC))) debugunalloc( ); #endif #ifdef SHOWALLOC - printf( "\t%d\tCheckPtr: New Alloc %ld %lx when %ld\n ",a->n, ll, a->p, a->n); + printf("\t%d\tCheckPtr: New Alloc %ld %lx when %ld\n ", a->n, ll, a->p, a->n); #endif - MaxUsedSize = AllocSize < MaxUsedSize ? MaxUsedSize : AllocSize; - if( !ll && !a->p) - { - if(verbosity>2) { + MaxUsedSize = AllocSize < MaxUsedSize ? MaxUsedSize : AllocSize; + if (!ll && !a->p) { + if (verbosity > 2) { printf("\t\tCheckPtrMem Full Exit(10) New Alloc %ld %p when %ld\n ", ll, a->p, a->n); - printf ("\t\tCheckPtr:Max Memory used %10.3f kbytes " , MaxUsedSize/1024. ); - printf (" Memory undelete %ld \n" , AllocSize); - } - exitalloc(1); + printf("\t\tCheckPtr:Max Memory used %10.3f kbytes ", MaxUsedSize / 1024.); + printf(" Memory undelete %ld \n", AllocSize); } - return (void*) ((char*)a->p); + exitalloc(1); + } + return (void *)((char *)a->p); } -void AllocExtern::MyDeleteOperator(void * pp,bool is_array) -{ - if(after_end) { /*free(pp)*/; return;} - if( !AllocExtern::CheckAlloc) {free(pp); return;} - - init(); - for( int i=0; i< nblastalloc; ++i) - { - if( (NbPtr-i) <0) break; - int k =(NbPtr-i)%nblastalloc; - if (LastAlloc[k] && LastAlloc[k]->l>0 && LastAlloc[k]->p ==pp) - { - AllocExtern::OneAlloc * pa=LastAlloc[k]; - LastAlloc[k]=0; - size_t ll = pa->l-1; - for (size_t kkk=0;kkkn); +void AllocExtern::MyDeleteOperator(void *pp, bool is_array) { + if (after_end) { /*free(pp)*/ + ; + return; + } + if (!AllocExtern::CheckAlloc) { + free(pp); + return; + } + + init( ); + for (int i = 0; i < nblastalloc; ++i) { + if ((NbPtr - i) < 0) break; + int k = (NbPtr - i) % nblastalloc; + if (LastAlloc[k] && LastAlloc[k]->l > 0 && LastAlloc[k]->p == pp) { + AllocExtern::OneAlloc *pa = LastAlloc[k]; + LastAlloc[k] = 0; + size_t ll = pa->l - 1; + for (size_t kkk = 0; kkk < ll; kkk++) ((char *)pp)[kkk] = 18; + + myfree((char *)pp, ll, pa->n); #ifdef SHOWALLOC - printf("\t%d\tCheckPtr: fast delete Alloc %ld %lx when %ld \n",pa->n,pa->l-1, pa->p, pa->n); + printf("\t%d\tCheckPtr: fast delete Alloc %ld %lx when %ld \n", pa->n, pa->l - 1, pa->p, pa->n); #endif - AllocSize -= ll; - NbPtr--; - pa->l=0; - pa->p = NextFree; - pa->n =0; - if (pa->is_array != is_array) - printf("\t\tCheckPtr: erreur delete [] \n"); - //if( pa->n < NbAllocShow ) debugalloc(); - NextFree = & pa->p; - return; - } + AllocSize -= ll; + NbPtr--; + pa->l = 0; + pa->p = NextFree; + pa->n = 0; + if (pa->is_array != is_array) printf("\t\tCheckPtr: erreur delete [] \n"); + // if( pa->n < NbAllocShow ) debugalloc(); + NextFree = &pa->p; + return; } - if (AllocHead) - { - AllocExtern::AllocData *p = AllocHead; - int kloop=0; - while (p) - { - for (int i=0;ia[i].l > 0) && (p->a[i].p == pp)) - { + } + if (AllocHead) { + AllocExtern::AllocData *p = AllocHead; + int kloop = 0; + while (p) { + for (int i = 0; i < N100; i++) + if ((p->a[i].l > 0) && (p->a[i].p == pp)) { #ifdef SHOWALLOC - printf("\t%d\tCheckPtr: delete Alloc %ld %lx when %ld \n",p->a[i].n,p->a[i].l-1, p->a[i].p, p->a[i].n); + printf("\t%d\tCheckPtr: delete Alloc %ld %lx when %ld \n", p->a[i].n, p->a[i].l - 1, p->a[i].p, p->a[i].n); #endif - size_t ll = p->a[i].l-1; - for (size_t kkk=0;kkka[i].n); - - AllocSize -= ll; - NbPtr--; - p->a[i].l=0; - p->a[i].p = NextFree; - p->a[i].n =0; - if (p->a[i].is_array != is_array) - printf("\t\tCheckPtr: erreur delete [] \n"); - //if( p->a[i].n < NbAllocShow ) debugalloc(); - NextFree = & p->a[i].p; - return;} - if(p == p->next || kloop++ > 10000) - { - printf("\n\n ****CheckPTR Big BUG ??????? loop %d\n",kloop); - break; - } - - p = p->next; - } - if(pp) - { - printf( "\t\tCheckPtr: delete of bad pointer %p -----------\n",pp); - debugalloc(); - } - - } else - myfree((char*)pp); -} -void AllocExtern::init() -{ - static int count=0; - if(0== (count++)) - { - snprintf(filename,128,"ListOfAllocPtr-%d.bin",(int) sizeof(void*)); - StorageUsage=0; - AllocSize =0; - MaxUsedSize =0; - AllocHead =0; - NbAlloc =0; - NbPtr =0; - NextFree =0; - NbuDelPtr =0; - NbuDelPtr = 0; - - after_end = false; - for(int i=0; i 100000000 && NbuDelPtr <0) - { - printf("Fatal error in the file %s is wrong (please remove)",filename); - exit(1); - } - fclose(file); - } - else - { // printf("fopen ListOfUnAllocPtr errno = %d\n",errno); - } + size_t ll = p->a[i].l - 1; + for (size_t kkk = 0; kkk < ll; kkk++) ((char *)pp)[kkk] = 18; + + myfree((char *)pp, ll, p->a[i].n); + + AllocSize -= ll; + NbPtr--; + p->a[i].l = 0; + p->a[i].p = NextFree; + p->a[i].n = 0; + if (p->a[i].is_array != is_array) printf("\t\tCheckPtr: erreur delete [] \n"); + // if( p->a[i].n < NbAllocShow ) debugalloc(); + NextFree = &p->a[i].p; + return; + } + if (p == p->next || kloop++ > 10000) { + printf("\n\n ****CheckPTR Big BUG ??????? loop %d\n", kloop); + break; + } + + p = p->next; + } + if (pp) { + printf("\t\tCheckPtr: delete of bad pointer %p -----------\n", pp); + debugalloc( ); } -} -AllocExtern::AllocExtern() -{ - init(); + } else + myfree((char *)pp); } - -AllocExtern::~AllocExtern() -{ - if(UnShowAlloc==0) return; - OneAlloc * list[Maxundelptr]; - - AllocData * p=AllocHead; - int k=0,kk=0; - int lln=0; - - while (p) {int i=N100; - while(i--) - if (p->a[i].l >0 ) - { - if ( p->a[i].n >= p->a[i].n) lln = p->a[i].n; - if ( p->a[i].n <= NbAllocShow ) - k++; - else - if (kka+i; - - } - p = p->next; - } - k+=kk; - kk=kk < Maxundelptr ? kk : Maxundelptr; - HeapSort(list,kk); - if(verbosity > 2) - for (int i= kk-10<0 ? 0 : kk-10 ;ip,list[i]->l,list[i]->n); +void AllocExtern::init( ) { + static int count = 0; + if (0 == (count++)) { + snprintf(filename, 128, "ListOfAllocPtr-%d.bin", (int)sizeof(void *)); + StorageUsage = 0; + AllocSize = 0; + MaxUsedSize = 0; + AllocHead = 0; + NbAlloc = 0; + NbPtr = 0; + NextFree = 0; + NbuDelPtr = 0; + NbuDelPtr = 0; + + after_end = false; + for (int i = 0; i < nblastalloc; i++) LastAlloc[i] = 0; + FILE *file = fopen(filename, "rb"); + + if (file) { + fread(&NbuDelPtr, sizeof(long), 1, file); + fread(uDelPtr, sizeof(long), NbuDelPtr, file); + if (NbuDelPtr > 100000000 && NbuDelPtr < 0) { + printf("Fatal error in the file %s is wrong (please remove)", filename); + exit(1); } - if (kk) - { - FILE *file=fopen(filename,"wb"); - if (file) - { - NbuDelPtr=kk; - for (int i=0;in; - fwrite(&NbuDelPtr,sizeof(long),1,file); - fwrite(uDelPtr,sizeof(long),NbuDelPtr,file); - fclose(file); - } - } - - if(verbosity>2) { - if(k) printf ("\t\tCheckPtr:Nb of undelete pointer is %d last %d\n",k,lln); - printf ("\t\tCheckPtr:Max Memory used %10.3f kbytes " , MaxUsedSize/1024. ); - printf (" Memory undelete %ld \n" , AllocSize); + fclose(file); + } else { // printf("fopen ListOfUnAllocPtr errno = %d\n",errno); + } + } +} +AllocExtern::AllocExtern( ) { init( ); } + +AllocExtern::~AllocExtern( ) { + if (UnShowAlloc == 0) return; + OneAlloc *list[Maxundelptr]; + + AllocData *p = AllocHead; + int k = 0, kk = 0; + int lln = 0; + + while (p) { + int i = N100; + while (i--) + if (p->a[i].l > 0) { + if (p->a[i].n >= p->a[i].n) lln = p->a[i].n; + if (p->a[i].n <= NbAllocShow) + k++; + else if (kk < Maxundelptr) + list[kk++] = p->a + i; } + p = p->next; + } + k += kk; + kk = kk < Maxundelptr ? kk : Maxundelptr; + HeapSort(list, kk); + if (verbosity > 2) + for (int i = kk - 10 < 0 ? 0 : kk - 10; i < kk; i++) { + printf("\t\tCheckPtr:Undelete pointer %p size %ld when %ld\n", list[i]->p, list[i]->l, list[i]->n); + } + if (kk) { + FILE *file = fopen(filename, "wb"); + if (file) { + NbuDelPtr = kk; + for (int i = 0; i < kk; i++) uDelPtr[i] = list[i]->n; + fwrite(&NbuDelPtr, sizeof(long), 1, file); + fwrite(uDelPtr, sizeof(long), NbuDelPtr, file); + fclose(file); + } + } - // clean store pointer - p=AllocHead; - while (p) - { - myfree((char*)p->a); - AllocData * pold = p; - p = p->next; - myfree((char*)pold); - } - AllocHead=0; - after_end=true; + if (verbosity > 2) { + if (k) printf("\t\tCheckPtr:Nb of undelete pointer is %d last %d\n", k, lln); + printf("\t\tCheckPtr:Max Memory used %10.3f kbytes ", MaxUsedSize / 1024.); + printf(" Memory undelete %ld \n", AllocSize); + } + + // clean store pointer + p = AllocHead; + while (p) { + myfree((char *)p->a); + AllocData *pold = p; + p = p->next; + myfree((char *)pold); + } + AllocHead = 0; + after_end = true; } // ------------------ +void *operator new(std::size_t ll, const std::nothrow_t ¬hrow_constant) throw( ) { + void *p = AllocExternData.MyNewOperator(ll, false); + if (ll && !p) { + printf("EXIT BECAUSE MEMORY FULL \n"); + exitalloc(1); + }; + return p; +} + +void *operator new[](std::size_t ll, const std::nothrow_t ¬hrow_constant) throw( ) { + void *p = AllocExternData.MyNewOperator(ll, true); + if (ll && !p) { + printf("EXIT BECAUSE MEMORY FULL \n"); + exitalloc(1); + }; + return p; +} + +void *operator new(std::size_t ll) throw(std::bad_alloc) { + void *p = AllocExternData.MyNewOperator(ll, false); + if (ll && !p) { + printf("THROW BECAUSE MEMORY FULL \n"); + std::bad_alloc exception; + throw exception; + }; + return p; +} + +void *operator new[](std::size_t ll) throw(std::bad_alloc) { + void *p = AllocExternData.MyNewOperator(ll, true); + if (ll && !p) { + printf("THROW BECAUSE MEMORY FULL \n"); + std::bad_alloc exception; + throw exception; + }; + return p; +} + +void operator delete(void *pp, const std::nothrow_t ¬hrow_constant) throw( ) { AllocExternData.MyDeleteOperator(pp, false); } +void operator delete[](void *pp, const std::nothrow_t ¬hrow_constant) throw( ) { AllocExternData.MyDeleteOperator(pp, true); } +void operator delete(void *pp) throw( ) { AllocExternData.MyDeleteOperator(pp, false); } +void operator delete[](void *pp) throw( ) { AllocExternData.MyDeleteOperator(pp, true); } -void * operator new(std::size_t ll,const std::nothrow_t& nothrow_constant) throw() -{ void * p = AllocExternData.MyNewOperator(ll,false); - if (ll && !p) { printf("EXIT BECAUSE MEMORY FULL \n"); - exitalloc(1); }; - return p;} - -void * operator new[](std::size_t ll,const std::nothrow_t& nothrow_constant) throw() -{ void * p = AllocExternData.MyNewOperator(ll,true); - if (ll && !p) { printf("EXIT BECAUSE MEMORY FULL \n"); - exitalloc(1); }; - return p;} - -void *operator new(std::size_t ll) throw(std::bad_alloc) -{ void * p = AllocExternData.MyNewOperator(ll,false); - if (ll && !p) { printf("THROW BECAUSE MEMORY FULL \n"); - std::bad_alloc exception; - throw exception; }; - return p;} - -void *operator new[] (std::size_t ll) throw(std::bad_alloc) -{ void * p = AllocExternData.MyNewOperator(ll,true); - if (ll && !p) { - printf("THROW BECAUSE MEMORY FULL \n"); - std::bad_alloc exception; - throw exception; }; - return p;} - - -void operator delete(void * pp,const std::nothrow_t& nothrow_constant) throw() -{ AllocExternData.MyDeleteOperator(pp,false);} -void operator delete[] (void * pp,const std::nothrow_t& nothrow_constant) throw() -{ AllocExternData.MyDeleteOperator(pp,true);} -void operator delete(void * pp) throw() -{ AllocExternData.MyDeleteOperator(pp,false);} -void operator delete[](void * pp) throw() -{ AllocExternData.MyDeleteOperator(pp,true);} - -int AllocExtern::ShowAlloc(const char *s,size_t & lg) { - size_t m =StorageUsage; - StorageUsage =StorageUsed(); - if (!NbAllocShow) {NbAllocShow=NbAlloc;} - if(verbosity > 2) - printf ("----------CheckPtr:-----%s------ NbUndelPtr %ld Alloc: %ld NbPtr %ld Mem Usage: %zu diff: %ld\n",s,NbPtr,AllocSize,NbAlloc,StorageUsage,(long)(StorageUsage-m)); +int AllocExtern::ShowAlloc(const char *s, size_t &lg) { + size_t m = StorageUsage; + StorageUsage = StorageUsed( ); + if (!NbAllocShow) { + NbAllocShow = NbAlloc; + } + if (verbosity > 2) + printf("----------CheckPtr:-----%s------ NbUndelPtr %ld Alloc: %ld NbPtr %ld Mem Usage: %zu diff: %ld\n", s, NbPtr, AllocSize, NbAlloc, StorageUsage, (long)(StorageUsage - m)); lg = AllocSize; return NbPtr; } -int ShowAlloc(const char *s,size_t & lg) -{ return AllocExternData.ShowAlloc(s,lg);} -void WithoutCheckPtr(){AllocExtern::CheckAlloc=false;} -void WithCheckPtr(){AllocExtern::CheckAlloc=true;} +int ShowAlloc(const char *s, size_t &lg) { return AllocExternData.ShowAlloc(s, lg); } +void WithoutCheckPtr( ) { AllocExtern::CheckAlloc = false; } +void WithCheckPtr( ) { AllocExtern::CheckAlloc = true; } #else #define XXXX @@ -567,108 +544,90 @@ void WithCheckPtr(){AllocExtern::CheckAlloc=true;} #include #include -long CheckPtr___nbptr=0; -size_t CheckPtr___memoryusage =0; +long CheckPtr___nbptr = 0; +size_t CheckPtr___memoryusage = 0; -void * operator new(std::size_t size,const std::nothrow_t& nothrow_constant) throw() -{ - CheckPtr___nbptr++; - void *p = malloc( size ); - if(verbosity > 1000000 ) - std::cout << " CheckPtr: new nothrow" << CheckPtr___nbptr << " " << size - << " p =" << p < 1000000) std::cout << " CheckPtr: new nothrow" << CheckPtr___nbptr << " " << size << " p =" << p << std::endl; - return p; + return p; } -void * operator new[](std::size_t size,const std::nothrow_t& nothrow_constant) throw() -{ - void *p = malloc(size); - CheckPtr___nbptr++; - if(verbosity > 1000000 ) - std::cout << " CheckPtr: new[] nothrow" << CheckPtr___nbptr << " " << size << " p =" << p < 1000000) std::cout << " CheckPtr: new[] nothrow" << CheckPtr___nbptr << " " << size << " p =" << p << std::endl; + return p; } -void *operator new(std::size_t size) //throw(std::bad_alloc) +void *operator new(std::size_t size) // throw(std::bad_alloc) { - CheckPtr___nbptr++; - void *p = malloc( size ); - if(verbosity > 1000000 ) - std::cout << " CheckPtr: new throw " << CheckPtr___nbptr << " " << size - << " p =" << p < 1000000) std::cout << " CheckPtr: new throw " << CheckPtr___nbptr << " " << size << " p =" << p << std::endl; - return p; + return p; } -void *operator new[](std::size_t size) //throw(std::bad_alloc) +void *operator new[](std::size_t size) // throw(std::bad_alloc) { - void *p = malloc(size); - CheckPtr___nbptr++; - if(verbosity > 1000000 ) - std::cout << " CheckPtr: new[] throw" << CheckPtr___nbptr << " " << size << " p =" << p < 1000000) std::cout << " CheckPtr: new[] throw" << CheckPtr___nbptr << " " << size << " p =" << p << std::endl; + return p; } -void operator delete(void * p,const std::nothrow_t& nothrow_constant) throw() -{ - if(verbosity > 1000000 ) - std::cout << " CheckPtr: free nothrow " << CheckPtr___nbptr-1 << " p =" << p < 1000000) std::cout << " CheckPtr: free nothrow " << CheckPtr___nbptr - 1 << " p =" << p << std::endl; - CheckPtr___nbptr--; + free(p); + CheckPtr___nbptr--; } -void operator delete[](void * p,const std::nothrow_t& nothrow_constant) throw() -{ - if(verbosity > 1000000 ) - std::cout << " CheckPtr: free[] thow" << CheckPtr___nbptr-1 << " p =" << p < 1000000) std::cout << " CheckPtr: free[] thow" << CheckPtr___nbptr - 1 << " p =" << p << std::endl; + free(p); + CheckPtr___nbptr--; } -void operator delete(void * p) throw() -{ - if(verbosity > 1000000 ) - std::cout << " CheckPtr: free throw " << CheckPtr___nbptr-1 << " p =" << p < 1000000) std::cout << " CheckPtr: free throw " << CheckPtr___nbptr - 1 << " p =" << p << std::endl; - free(p); - - CheckPtr___nbptr--; + free(p); + CheckPtr___nbptr--; } -void operator delete[](void * p) throw() -{ - if(verbosity > 1000000 ) - std::cout << " CheckPtr: free[] throw " << CheckPtr___nbptr-1 << " p =" << p < 1000000) std::cout << " CheckPtr: free[] throw " << CheckPtr___nbptr - 1 << " p =" << p << std::endl; + free(p); + CheckPtr___nbptr--; +} +int ShowAlloc(const char *s, size_t &lg) { + size_t m = StorageUsed( ); + long diff = m - CheckPtr___memoryusage; + if (verbosity > 0 && CheckPtr___memoryusage != 0 && m != CheckPtr___memoryusage) printf("CheckPtr: Warning memory leak with malloc = %ld \n ", diff); + CheckPtr___memoryusage = m; + lg = 0; + return CheckPtr___nbptr; } +void WithoutCheckPtr( ) {} +void WithCheckPtr( ) {} -int ShowAlloc(const char *s,size_t & lg) -{ - size_t m =StorageUsed(); - long diff = m-CheckPtr___memoryusage; - if(verbosity > 0 && CheckPtr___memoryusage!=0 && m != CheckPtr___memoryusage) - printf("CheckPtr: Warning memory leak with malloc = %ld \n ",diff); - CheckPtr___memoryusage=m; - lg = 0; return CheckPtr___nbptr;} -void WithoutCheckPtr(){} -void WithCheckPtr(){} - -int UnShowAlloc =0; +int UnShowAlloc = 0; #else #include -int ShowAlloc(const char *s,size_t & lg) -{lg=0; return 0;} -int UnShowAlloc =0; - void WithoutCheckPtr(){} - void WithCheckPtr(){} +int ShowAlloc(const char *s, size_t &lg) { + lg = 0; + return 0; +} +int UnShowAlloc = 0; +void WithoutCheckPtr( ) {} +void WithCheckPtr( ) {} #endif #endif diff --git a/src/femlib/ConjuguedGradrientNL.cpp b/src/femlib/ConjuguedGradrientNL.cpp index 8ffb4a741..e2defb6c2 100644 --- a/src/femlib/ConjuguedGradrientNL.cpp +++ b/src/femlib/ConjuguedGradrientNL.cpp @@ -1,116 +1,115 @@ // ********** DO NOT REMOVE THIS BANNER ********** -// ORIG-DATE: 29 fev 2000 +// ORIG-DATE: 29 fev 2000 // -*- Mode : c++ -*- // -// SUMMARY : array modelisation -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE +// SUMMARY : array modelisation +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - - - + + + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - + + */ -template -R argmin(R rho,const M & dJ,const KN_ &x,KN_ &h,KN_ &g,KN_ &w) -{ - // find ro / (dJ(x+roh),h) =0 - // remark input: dJ(x)=g - int k=0; - - R ro0=0, ro=rho,ro1=rho; - R p0= (g,h),p,p1; - R ap0=Abs(p0)*0.1; // on arret quand on a divise par 10. - x += (ro-rold)* h; rold=ro; g =A(x); - p= ( p1 = (g,h) ); - +template< class R, class DJ, class M > +R argmin(R rho, const M &dJ, const KN_< R > &x, KN_< R > &h, KN_< R > &g, KN_< R > &w) { + // find ro / (dJ(x+roh),h) =0 + // remark input: dJ(x)=g + int k = 0; - bool loop=true; - while (k++<100 && loop) - { // calcul du nouveau ro courant - if (p0*p1 <0) { // Ok changement de signe - ro = (p0*ro1+p1*ro0)/ (p0+p1); - x += (ro-rold)* h; rold=ro; g =A(x); - p = (g,h); - if ( verbosity >3 ) - cout << " ro " << ro << " gh= " << p - << "; ro0, gh0 = " << ro0 << " " << p0 - << "; ro1, gh1 = " << ro1 << " " << p1 << endl; - - if(Abs(p) <= ap0 || k>10 ) return ro; - if(p0*p<0) { p1=p;ro1=ro;} - else {p0=p;ro0=ro;} - } - else { - ro *=2; - x += (ro-rold)* h; rold=ro; g =A(x); - p = (g,h); - p1=p; - ro1=ro; + R ro0 = 0, ro = rho, ro1 = rho; + R p0 = (g, h), p, p1; + R ap0 = Abs(p0) * 0.1; // on arret quand on a divise par 10. + x += (ro - rold) * h; + rold = ro; + g = A(x); + p = (p1 = (g, h)); + + bool loop = true; + while (k++ < 100 && loop) { // calcul du nouveau ro courant + if (p0 * p1 < 0) { // Ok changement de signe + ro = (p0 * ro1 + p1 * ro0) / (p0 + p1); + x += (ro - rold) * h; + rold = ro; + g = A(x); + p = (g, h); + if (verbosity > 3) cout << " ro " << ro << " gh= " << p << "; ro0, gh0 = " << ro0 << " " << p0 << "; ro1, gh1 = " << ro1 << " " << p1 << endl; + + if (Abs(p) <= ap0 || k > 10) return ro; + if (p0 * p < 0) { + p1 = p; + ro1 = ro; + } else { + p0 = p; + ro0 = ro; + } + } else { + ro *= 2; + x += (ro - rold) * h; + rold = ro; + g = A(x); + p = (g, h); + p1 = p; + ro1 = ro; } - } + } } -template -int ConjuguedGradientNL(const M & dJ,const P & C,KN_ &x,const int nbitermax, double &eps,long kprint=1000000000) -{ -// ------------- - throwassert(&x && &b && &A && &C); - typedef KN Rn; - int n=b.N(); - if (verbosity>99) kprint=1; - throwassert(n==x.N()); - R ro=1; - Rn g(n),h(n),Ah(n), & Cg(Ah); // on utilise Ah pour stocke Cg - g = dJ(x); - Cg = C*g; // gradient preconditionne - h =-Cg; - R g2 = (Cg,g); - if (g2 < 1e-30) - { if(verbosity>1) - cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; - return 2; } - if (verbosity>5 ) - cout << " 0 GCNL g^2 =" << g2 << endl; - R reps2 =eps >0 ? eps*eps*g2 : -eps; // epsilon relatif - eps = reps2; - for (int iter=0;iter<=nbitermax;iter++) - { - ro = argmin(J,x,h,g,Ah); - - Cg = C*g; - R g2p=g2; - g2 = (Cg,g); - if ( verbosity >1 ) - cout << "CGNL:" < +int ConjuguedGradientNL(const M &dJ, const P &C, KN_< R > &x, const int nbitermax, double &eps, long kprint = 1000000000) { + // ------------- + throwassert(&x && &b && &A && &C); + typedef KN< R > Rn; + int n = b.N( ); + if (verbosity > 99) kprint = 1; + throwassert(n == x.N( )); + R ro = 1; + Rn g(n), h(n), Ah(n), &Cg(Ah); // on utilise Ah pour stocke Cg + g = dJ(x); + Cg = C * g; // gradient preconditionne + h = -Cg; + R g2 = (Cg, g); + if (g2 < 1e-30) { + if (verbosity > 1) cout << "GCNL g^2 =" << g2 << " < 1.e-30 Nothing to do " << endl; + return 2; + } + if (verbosity > 5) cout << " 0 GCNL g^2 =" << g2 << endl; + R reps2 = eps > 0 ? eps * eps * g2 : -eps; // epsilon relatif + eps = reps2; + for (int iter = 0; iter <= nbitermax; iter++) { + ro = argmin(J, x, h, g, Ah); + + Cg = C * g; + R g2p = g2; + g2 = (Cg, g); + if (verbosity > 1) cout << "CGNL:" << iter << " ro = " << ro << " ||g||^2 = " << g2 << endl; + if (g2 < reps2) { + if (verbosity) cout << "CGNL converge: " << iter << " ro = " << ro << " ||g||^2 = " << g2 << endl; + return 1; // ok + } + R gamma = g2 / g2p; + h *= gamma; + h -= Cg; // h = -Cg * gamma* h + } + cout << " CGNL: the method don't converge in " << nbitermax << " iterations \n"; + return 0; } diff --git a/src/femlib/DOperator.hpp b/src/femlib/DOperator.hpp index c4ce8e0b7..f5bd94340 100644 --- a/src/femlib/DOperator.hpp +++ b/src/femlib/DOperator.hpp @@ -1,582 +1,572 @@ #include // class for 1 linear form -// just copy a array +// just copy a array // Warning this class are use at compilating time // ---------------------------------------------- -using Fem2D::operatortype; -using Fem2D::op_id; +using Fem2D::last_operatortype; using Fem2D::op_dx; using Fem2D::op_dy; using Fem2D::op_dz; -using Fem2D::last_operatortype; +using Fem2D::op_id; +using Fem2D::operatortype; -template -inline T * NewCopy(const T * const o,int n) -{ - int m=n; - T * c = new T [n]; - for (int i=0;i +inline T *NewCopy(const T *const o, int n) { + int m = n; + T *c = new T[n]; + for (int i = 0; i < m; i++) c[i] = o[i]; return c; } -template -inline T * NewCopy(const T * const o,int n,int m) -{ - throwassert(m<=n); - T * c = new T [n]; - for (int i=0;i +inline T *NewCopy(const T *const o, int n, int m) { + throwassert(m <= n); + T *c = new T[n]; + for (int i = 0; i < m; i++) c[i] = o[i]; return c; } -template -struct triplet -{ - typedef T1 first_type; - typedef T2 second_type; - typedef T3 third_type; - T1 first; - T2 second; - T3 third; - triplet() : first(),second(),third() {} - triplet(const T1& x, const T2& y, const T3& z) : first(x),second(y), third(z) {} - template inline - triplet(const triplet& p) : first(p.first),second(p.second),third(p.third) {} +template< class T1, class T2, class T3 > +struct triplet { + typedef T1 first_type; + typedef T2 second_type; + typedef T3 third_type; + T1 first; + T2 second; + T3 third; + triplet( ) : first( ), second( ), third( ) {} + triplet(const T1 &x, const T2 &y, const T3 &z) : first(x), second(y), third(z) {} + template< class U, class V, class W > + inline triplet(const triplet< U, V, W > &p) : first(p.first), second(p.second), third(p.third) {} }; -template -inline triplet make_triplet(T1 x, T2 y, T3 z) -{ - return triplet(x, y, z); +template< class T1, class T2, class T3 > +inline triplet< T1, T2, T3 > make_triplet(T1 x, T2 y, T3 z) { + return triplet< T1, T2, T3 >(x, y, z); } +template< class I, class R > +class LinearComb : public E_F0mps { + public: + typedef I TI; + typedef R TR; + typedef size_t size_type; + typedef pair< I, R > K; + typedef vector< K > array; + typedef typename array::const_iterator const_iterator; + typedef typename array::iterator iterator; + array v; + vector< size_type > where_in_stack_opt; + vector< bool > mesh_indep_stack_opt; + const E_F0_Optimize *optiexp0, *optiexpK; + bool isoptimize; + + LinearComb( ) : v( ), where_in_stack_opt( ), mesh_indep_stack_opt( ), optiexp0(0), optiexpK(0), isoptimize(false) {} + + LinearComb(const I &i, const R &r) : v(1), where_in_stack_opt( ), mesh_indep_stack_opt( ), optiexp0( ), optiexpK( ), isoptimize(false) { v[0] = make_pair< I, R >((I)i, (R)r); } + + LinearComb(const LinearComb &l) : v(l.v), where_in_stack_opt(l.where_in_stack_opt), mesh_indep_stack_opt(l.mesh_indep_stack_opt), optiexp0(l.optiexp0), optiexpK(l.optiexpK), isoptimize(false) {} + + int nbtrue(bool *ok) const { + int k = 0; + for (size_t i = 0; i < v.size( ); i++) + if (ok[i]) k++; + return k; + } -template - class LinearComb : public E_F0mps { public: - typedef I TI; - typedef R TR; - typedef size_t size_type; - typedef pair K; - typedef vector array; - typedef typename array::const_iterator const_iterator; - typedef typename array::iterator iterator; - array v; - vector where_in_stack_opt; - vector mesh_indep_stack_opt; - const E_F0_Optimize * optiexp0,*optiexpK; - bool isoptimize; - - LinearComb(): v(), - where_in_stack_opt(),mesh_indep_stack_opt(), - optiexp0(0),optiexpK(0),isoptimize(false) {} - - LinearComb(const I& i,const R& r) :v(1), - where_in_stack_opt(),mesh_indep_stack_opt(), - optiexp0(),optiexpK(),isoptimize(false) - { - v[0]=make_pair((I)i,(R)r); - } - - LinearComb(const LinearComb &l) - :v(l.v), - where_in_stack_opt(l.where_in_stack_opt), - mesh_indep_stack_opt(l.mesh_indep_stack_opt), - optiexp0(l.optiexp0),optiexpK(l.optiexpK),isoptimize(false){} - - int nbtrue(bool *ok) const - { - int k=0; - for (size_t i=0;i &l) { - v=l.v; - where_in_stack_opt=l.where_in_stack_opt; - mesh_indep_stack_opt=l.mesh_indep_stack_opt; - optiexp0=l.optiexp0; - optiexpK=l.optiexpK; - isoptimize=l.isoptimize; - } - const I * simple() const { if (v.size()==1) return & v.begin()->first;else return 0;} - void add(const I& i,const R &r) { - for (iterator k=v.begin();k!=v.end();k++) - if (k->first == i) {k->second += r;return ;} - v.push_back(make_pair((I)i,(R)r)); - } - - size_type size() const { return v.size();} - - const K & operator[](size_type i) const { return v[i];} - - void operator+=(const LinearComb & l) { - for (const_iterator k=l.v.begin();k!=l.v.end();k++) - { const K & kk(*k); - add(kk.first,kk.second);} - } - - void operator*=(const R & r) { - for (iterator k=v.begin();k!=v.end();k++) - {K & kk(*k); - kk.second = kk.second*r;} - } - - void operator/=(const R & r) { - for (iterator k=v.begin();k!=v.end();k++) - {K & kk(*k); - kk.second = kk.second/r; } - } - - AnyType operator()(Stack ) const { - return SetAny * >(this);} - operator aType () const { return atype();} - - - bool mappable(bool (*f)(const R &)) const { - for (const_iterator k=v.begin();k!=v.end();k++) - if (!(*f)(k->second)) return false; - return true;} - - void mapping(R (*f)(const R &)) { - for (iterator k=v.begin();k!=v.end();k++) - k->second=(*f)(k->second) ;} - - int MaxOp() const { - int m=0; - for (const_iterator k=v.begin();k!=v.end();k++) - m= maxop(m,(k->first)) ; - return m;} - - void DiffOp(KN_ &d) const { - assert(d.N() >= last_operatortype); - d=false; - for (const_iterator k=v.begin();k!=v.end();k++) - SetOp(d,k->first); - - - } - unsigned int DiffOp(int & lastop) const - { - unsigned int d=0; - lastop=0; - for (const_iterator k=v.begin();k!=v.end();k++) - d |= GetDiffOp(k->first,lastop); - - assert(lastop &l) { + v = l.v; + where_in_stack_opt = l.where_in_stack_opt; + mesh_indep_stack_opt = l.mesh_indep_stack_opt; + optiexp0 = l.optiexp0; + optiexpK = l.optiexpK; + isoptimize = l.isoptimize; + } + const I *simple( ) const { + if (v.size( ) == 1) + return &v.begin( )->first; + else + return 0; + } + void add(const I &i, const R &r) { + for (iterator k = v.begin( ); k != v.end( ); k++) + if (k->first == i) { + k->second += r; + return; + } + v.push_back(make_pair< I, R >((I)i, (R)r)); + } + + size_type size( ) const { return v.size( ); } + + const K &operator[](size_type i) const { return v[i]; } + + void operator+=(const LinearComb &l) { + for (const_iterator k = l.v.begin( ); k != l.v.end( ); k++) { + const K &kk(*k); + add(kk.first, kk.second); + } + } + + void operator*=(const R &r) { + for (iterator k = v.begin( ); k != v.end( ); k++) { + K &kk(*k); + kk.second = kk.second * r; + } + } + + void operator/=(const R &r) { + for (iterator k = v.begin( ); k != v.end( ); k++) { + K &kk(*k); + kk.second = kk.second / r; + } + } + + AnyType operator( )(Stack) const { return SetAny< const LinearComb< I, R > * >(this); } + operator aType( ) const { return atype< const LinearComb >( ); } + + bool mappable(bool (*f)(const R &)) const { + for (const_iterator k = v.begin( ); k != v.end( ); k++) + if (!(*f)(k->second)) return false; + return true; + } + + void mapping(R (*f)(const R &)) { + for (iterator k = v.begin( ); k != v.end( ); k++) k->second = (*f)(k->second); + } + + int MaxOp( ) const { + int m = 0; + for (const_iterator k = v.begin( ); k != v.end( ); k++) m = maxop(m, (k->first)); + return m; + } + + void DiffOp(KN_< bool > &d) const { + assert(d.N( ) >= last_operatortype); + d = false; + for (const_iterator k = v.begin( ); k != v.end( ); k++) SetOp(d, k->first); + } + unsigned int DiffOp(int &lastop) const { + unsigned int d = 0; + lastop = 0; + for (const_iterator k = v.begin( ); k != v.end( ); k++) d |= GetDiffOp(k->first, lastop); + + assert(lastop < last_operatortype); + lastop++; + + return d; + } + + ostream &dump(ostream &f) const { + int n = size( ); + for (int i = 0; i < n; i++) { + const K &ri = v[i]; + Expression ee = ri.second.LeftValue( ); + f << "\n\t\t" << i << " " << ri.first << ": "; + f << " : type exp: " << typeid(*ee).name( ) << " " << endl; + } return f; - } - LinearComb * Optimize(Block * b) - { - const bool kdump=(verbosity/1000)%10==1; - if (kdump) - cout << "\n\n Optimize " << endl; - LinearComb * r=new LinearComb(*this); - LinearComb &rr= *r; - int n = rr.size(); - - deque > ll; + } + LinearComb *Optimize(Block *b) { + const bool kdump = (verbosity / 1000) % 10 == 1; + if (kdump) cout << "\n\n Optimize " << endl; + LinearComb *r = new LinearComb(*this); + LinearComb &rr = *r; + int n = rr.size( ); + + deque< pair< Expression, int > > ll; MapOfE_F0 m; rr.where_in_stack_opt.resize(n); rr.mesh_indep_stack_opt.resize(n); - size_type top = b->OffSet(0), topbb=top; // FH. bofbof ??? - for (int i=0; iMeshIndependent(); - rr.where_in_stack_opt[i]=ee->Optimize(ll, m, top); - if (kdump) - cout << "\n\t\t"<< i << " " << ri.first << ": " << rr.where_in_stack_opt[i] << endl; + size_type top = b->OffSet(0), topbb = top; // FH. bofbof ??? + for (int i = 0; i < n; i++) { + const K &ri = rr.v[i]; + Expression ee = ri.second.LeftValue( ); + if (kdump) cout << "Optimize : type exp: " << typeid(*ee).name( ) << " " << endl; + rr.mesh_indep_stack_opt[i] = ee->MeshIndependent( ); + rr.where_in_stack_opt[i] = ee->Optimize(ll, m, top); + if (kdump) cout << "\n\t\t" << i << " " << ri.first << ": " << rr.where_in_stack_opt[i] << endl; + } + + b->OffSet(top - topbb); + // + int k = ll.size( ), k0 = 0, k1 = 0; + for (int i = 0; i < k; i++) + if (ll[i].first->MeshIndependent( )) k0++; + deque< pair< Expression, int > > l0(k0), l1(k - k0); + k0 = 0, k1 = 0; + for (int i = 0; i < k; i++) + if (ll[i].first->MeshIndependent( )) { + if (kdump) cout << " mi " << ll[i].second << " " << *(ll[i].first) << endl; + l0[k0++] = ll[i]; + } else { + if (kdump) cout << " md " << ll[i].second << " " << *(ll[i].first) << endl; + l1[k1++] = ll[i]; } - - b->OffSet(top-topbb); - // - int k=ll.size(),k0=0,k1=0; - for (int i=0;iMeshIndependent()) k0++; - deque > l0(k0),l1(k-k0); - k0=0,k1=0; - for (int i=0;iMeshIndependent()) - { - if (kdump) - cout << " mi " << ll[i].second << " " << *(ll[i].first) << endl; - l0[k0++]=ll[i]; - } - else - { - if (kdump) - cout << " md " << ll[i].second << " " << *(ll[i].first) << endl; - l1[k1++]=ll[i]; - } - if (k0) - rr.optiexp0 = new E_F0_Optimize(l0,m,0); - if (k1) - rr.optiexpK = new E_F0_Optimize(l1,m,0); - rr.isoptimize=true; - if (kdump) cout << "LinearCom Optimize k0(mi) = " << k0 << " k1 = " << k1 << "\n\n"< +LinearComb< I, R > operator+(const LinearComb< I, R > &a, const LinearComb< I, R > &b) { + LinearComb< I, R > r(a); + r += b; + return r; +} +template< class I, class R > +LinearComb< I, R > operator*(const LinearComb< I, R > &a, const R &b) { + LinearComb< I, R > r(a); + r *= b; + return r; +} +template< class I, class R > +LinearComb< I, R > operator*(const R &b, const LinearComb< I, R > &a) { + LinearComb< I, R > r(a); + r *= b; + return r; +} -template -LinearComb operator+(const LinearComb & a,const LinearComb & b) - {LinearComb r(a);r+=b;return r;} - -template -LinearComb operator*(const LinearComb & a,const R & b) - {LinearComb r(a);r*=b;return r;} -template -LinearComb operator*(const R & b,const LinearComb & a) - {LinearComb r(a);r*=b;return r;} - - - -class MGauche :public pair {public: - MGauche() {} - MGauche(int i,operatortype j) {first = i;second= j;} - MGauche(const pair &p) : pair(p){} - bool operator==(const MGauche& a) const { - return static_cast(first == a.first && second == a.second);} - int maxop(int op) const { return Max(op,(int) second);} - +class MGauche : public pair< int, operatortype > { + public: + MGauche( ) {} + MGauche(int i, operatortype j) { + first = i; + second = j; + } + MGauche(const pair< int, operatortype > &p) : pair< int, operatortype >(p) {} + bool operator==(const MGauche &a) const { return static_cast< bool >(first == a.first && second == a.second); } + int maxop(int op) const { return Max(op, (int)second); } }; -class MDroit :public pair {public: - MDroit(){} - MDroit(int i,operatortype j) {first = i;second =j;} - // first : number of unknow +class MDroit : public pair< int, operatortype > { + public: + MDroit( ) {} + MDroit(int i, operatortype j) { + first = i; + second = j; + } + // first : number of unknow // second : number of operator ( 0 Id, 1 dx, 2 dy) - MDroit(const pair &p) : pair(p){} - bool operator==(const MDroit& a) const { - return static_cast(first == a.first && second == a.second);} + MDroit(const pair< int, operatortype > &p) : pair< int, operatortype >(p) {} + bool operator==(const MDroit &a) const { return static_cast< bool >(first == a.first && second == a.second); } }; -inline ostream & operator<<(ostream & f,const MDroit & p) -{ f << p.first <<','< -inline ostream & operator<<(ostream & f,const pair &p) -{ f << p.first <<" "< LinearOperatorG; -typedef LinearComb LinearOperatorD; - -typedef LinearComb,C_F0> BilinearOperator; - -inline int maxop(int op,const MGauche & v) - { return Max(op,(int) v.second);} -inline int maxop(int op,const MDroit & v) - { return Max(op,(int) v.second);} -inline int maxop(int op,const pair & b) - { return Max(op,(int) b.first.second,(int) b.second.second );} +inline ostream &operator<<(ostream &f, const MDroit &p) { + f << p.first << ',' << p.second; + return f; +} +inline ostream &operator<<(ostream &f, const MGauche &p) { + f << p.first << ';' << p.second; + return f; +} + +template< typename A, typename B > +inline ostream &operator<<(ostream &f, const pair< A, B > &p) { + f << p.first << " " << p.second; + return f; +} + +// extern const C_F0 & One, &Zero; +C_F0 operator*(const C_F0 &, const C_F0 &); +C_F0 &operator+=(const C_F0 &, const C_F0 &); + +typedef LinearComb< MGauche, C_F0 > LinearOperatorG; +typedef LinearComb< MDroit, C_F0 > LinearOperatorD; + +typedef LinearComb< pair< MGauche, MDroit >, C_F0 > BilinearOperator; + +inline int maxop(int op, const MGauche &v) { return Max(op, (int)v.second); } +inline int maxop(int op, const MDroit &v) { return Max(op, (int)v.second); } +inline int maxop(int op, const pair< MGauche, MDroit > &b) { return Max(op, (int)b.first.second, (int)b.second.second); } // Add J. Morice :: 07/22 -inline void changeIndexFunctionInconnue( BilinearOperator &Op, const KN &index_operator, const KN &new_index_funct){ +inline void changeIndexFunctionInconnue(BilinearOperator &Op, const KN< size_t > &index_operator, const KN< int > &new_index_funct) { // function to change the index of inconnue function in a BilinearOperator // first.first ==> the inconnue function - ffassert( index_operator.size() == new_index_funct.size() ); // check the size of the vector - int N = index_operator.size(); - for( int j=0; j &index_operator, const KN &new_index_funct){ - // function to change the index of test function in a BilinearOperator +inline void changeIndexFunctionTest(BilinearOperator &Op, const KN< size_t > &index_operator, const KN< int > &new_index_funct) { + // function to change the index of test function in a BilinearOperator // first.second ==> the test function - ffassert( index_operator.size() == new_index_funct.size() ); // check the size of the vector - int N = index_operator.size(); - for( int j=0; j,pair > i1(vi.first); - const pair ii(i1.first),jj(i1.second); - f << *(const E_F0 *) vi.second << char('u'+ii.first) << www[ii.second] << " " << char('u'+jj.first)<<"'" << www[jj.second] ; - if ( (++k%5)==0) f << endl ; else f << " "; +inline BilinearOperator operator*(const LinearOperatorG &a, const LinearOperatorD &b) { + BilinearOperator r; + for (LinearOperatorG::const_iterator i = a.v.begin( ); i != a.v.end( ); i++) + for (LinearOperatorD::const_iterator j = b.v.begin( ); j != b.v.end( ); j++) { + const LinearOperatorG::K vi(*i); + const LinearOperatorD::K vj(*j); + + r.add(make_pair(vi.first, vj.first), vi.second * vj.second); } + return r; +} +inline BilinearOperator operator*(const LinearOperatorD &b, const LinearOperatorG &a) { + BilinearOperator r; + for (LinearOperatorG::const_iterator i = a.v.begin( ); i != a.v.end( ); i++) + for (LinearOperatorD::const_iterator j = b.v.begin( ); j != b.v.end( ); j++) { + const LinearOperatorG::K vi(*i); + const LinearOperatorD::K vj(*j); + + r.add(make_pair(vi.first, vj.first), vi.second * vj.second); + } + return r; +} +ostream &operator<<(ostream &f, const BilinearOperator &a); + +inline ostream &operator<<(ostream &f, const BilinearOperator &a) { + int k = 0; + for (BilinearOperator::const_iterator i = a.v.begin( ); i != a.v.end( ); i++) { + const BilinearOperator::K vi(*i); + const char *www[] = {" ", "_x ", "_y "}; + const pair< pair< int, int >, pair< int, int > > i1(vi.first); + const pair< int, int > ii(i1.first), jj(i1.second); + f << *(const E_F0 *)vi.second << char('u' + ii.first) << www[ii.second] << " " << char('u' + jj.first) << "'" << www[jj.second]; + if ((++k % 5) == 0) + f << endl; + else + f << " "; + } return f; } typedef LinearOperatorD LOperaD; typedef LinearOperatorG LOperaG; typedef BilinearOperator Opera; -inline LOperaG DiffG(int i,operatortype j) { return LOperaG(make_pair(i,j),*pOne);} -inline LOperaD DiffD(int i,operatortype j) { return LOperaD(make_pair(i,j),*pOne);} - -inline LOperaG *newU_(int i) { LOperaG * r; - r= new LOperaG(make_pair(i,op_id),*pOne); - SHOWVERB( cout << "newU_ " << r << endl); - return r; } -inline LOperaG *newU_x(int i) { return new LOperaG(make_pair(i,op_dx),*pOne);} -inline LOperaG *newU_y(int i) { return new LOperaG(make_pair(i,op_dy),*pOne);} -inline LOperaD *newV_(int i) { return new LOperaD(make_pair(i,op_id),*pOne);} -inline LOperaD *newV_x(int i) { return new LOperaD(make_pair(i,op_dx),*pOne);} -inline LOperaD *newV_y(int i) { return new LOperaD(make_pair(i,op_dy),*pOne);} - -template - L * Diff(const L * u,const operatortype & d) { - throwassert(u); - L * r= new L(*u); - for (typename L::iterator i=r->v.begin();i!=r->v.end();i++) - { - operatortype & dd=i->first.second; - if (dd != op_id) - { ffassert(0); i->first.second = op_id; } // a faire - else { - ffassert(i->second.EvaluableWithOutStack());// a faire derivation des fonctions - dd = d ; } - +inline LOperaG DiffG(int i, operatortype j) { return LOperaG(make_pair(i, j), *pOne); } +inline LOperaD DiffD(int i, operatortype j) { return LOperaD(make_pair(i, j), *pOne); } + +inline LOperaG *newU_(int i) { + LOperaG *r; + r = new LOperaG(make_pair(i, op_id), *pOne); + SHOWVERB(cout << "newU_ " << r << endl); + return r; +} +inline LOperaG *newU_x(int i) { return new LOperaG(make_pair(i, op_dx), *pOne); } +inline LOperaG *newU_y(int i) { return new LOperaG(make_pair(i, op_dy), *pOne); } +inline LOperaD *newV_(int i) { return new LOperaD(make_pair(i, op_id), *pOne); } +inline LOperaD *newV_x(int i) { return new LOperaD(make_pair(i, op_dx), *pOne); } +inline LOperaD *newV_y(int i) { return new LOperaD(make_pair(i, op_dy), *pOne); } + +template< class L > +L *Diff(const L *u, const operatortype &d) { + throwassert(u); + L *r = new L(*u); + for (typename L::iterator i = r->v.begin( ); i != r->v.end( ); i++) { + operatortype &dd = i->first.second; + if (dd != op_id) { + ffassert(0); + i->first.second = op_id; + } // a faire + else { + ffassert(i->second.EvaluableWithOutStack( )); // a faire derivation des fonctions + dd = d; } - return r;} - -template -L * CONJ_op(const L * u) { - throwassert(u); - L * r= new L(*u); - for (typename L::iterator i=r->v.begin();i!=r->v.end();i++) - { typename L::TR & cc=i->second; - if( cc.right()==atype() ) - i->second= C_F0(TheOperators,"\'",cc); - - } - return r;} - - - -template -int MaxOp(const L * u) { - throwassert(u); - int op=0; - for (typename L::const_iterator i=u->v.begin();i!=u->v.end();i++) - op = maxop(op,i->first); - return op;} + } + return r; +} +template< class L > +L *CONJ_op(const L *u) { + throwassert(u); + L *r = new L(*u); + for (typename L::iterator i = r->v.begin( ); i != r->v.end( ); i++) { + typename L::TR &cc = i->second; + if (cc.right( ) == atype< Complex >( )) i->second = C_F0(TheOperators, "\'", cc); + } + return r; +} +template< class L > +int MaxOp(const L *u) { + throwassert(u); + int op = 0; + for (typename L::const_iterator i = u->v.begin( ); i != u->v.end( ); i++) op = maxop(op, i->first); + return op; +} -template -class CODE_L1 { public: - typedef L* Result; - typedef L* (*func)(const basicAC_F0 & args) ; - static L* f(const basicAC_F0 & args) { return ff(args);} // ff :A-> L* - static ArrayOfaType typeargs() {return ArrayOfaType(atype);} +template< class L, class A, L *ff(const basicAC_F0 &args) > +class CODE_L1 { + public: + typedef L *Result; + typedef L *(*func)(const basicAC_F0 &args); + static L *f(const basicAC_F0 &args) { return ff(args); } // ff :A-> L* + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >); } }; -template -class CODE_L_Add { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - const L * b(dynamic_cast((Expression) args[1])); - throwassert(a && b ); - return new L(*a+*b);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} +template< class L > +class CODE_L_Add { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + const L *b(dynamic_cast< const L * >((Expression)args[1])); + throwassert(a && b); + return new L(*a + *b); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const L * >( ), atype< const L * >( )); } }; -template -class CODE_L_Sub { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - const L * b(dynamic_cast((Expression) args[1])); - throwassert(a && b ); - L * bb = new L(*pminusOne * *b); - return new L(*a+*bb);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} +template< class L > +class CODE_L_Sub { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + const L *b(dynamic_cast< const L * >((Expression)args[1])); + throwassert(a && b); + L *bb = new L(*pminusOne * *b); + return new L(*a + *bb); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const L * >( ), atype< const L * >( )); } }; -template -class CODE_L_Minus { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - throwassert(a && pminusOne ); - return new L(*pminusOne * *a);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype());} +template< class L > +class CODE_L_Minus { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + throwassert(a && pminusOne); + return new L(*pminusOne * *a); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const L * >( )); } }; -template -class CODE_L_Plus { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - throwassert(a ); - return new L( *a);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype());} +template< class L > +class CODE_L_Plus { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + throwassert(a); + return new L(*a); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const L * >( )); } }; -template -class CODE_L_Mul { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const A * a(dynamic_cast((Expression) args[0])); - const B * b(dynamic_cast((Expression) args[1])); +template< class L, class A, class B > +class CODE_L_Mul { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const A *a(dynamic_cast< const A * >((Expression)args[0])); + const B *b(dynamic_cast< const B * >((Expression)args[1])); SHOWVERB(cout << " CODE_L_Mul " << a << " " << b << endl); - throwassert(a && b ); - return new L(*a * *b);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} + throwassert(a && b); + return new L(*a * *b); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const A * >( ), atype< const B * >( )); } }; -template -class CODE_L_MulRL { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * b(dynamic_cast((Expression) args[1])); +template< class T, class L > +class CODE_L_MulRL { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *b(dynamic_cast< const L * >((Expression)args[1])); if (!b) { - - cout << " --- " << ((Expression) args[1]) << typeid((Expression) args[1]).name() << endl; - throwassert( b ); + + cout << " --- " << ((Expression)args[1]) << typeid((Expression)args[1]).name( ) << endl; + throwassert(b); } - return new L(to(args[0]) * *b);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} + return new L(to< T >(args[0]) * *b); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< T >( ), atype< const L * >( )); } }; -template -class CODE_L_MulLR { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - throwassert( a ); - return new L(to(args[1]) * *a);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} +template< class L, class T > +class CODE_L_MulLR { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + throwassert(a); + return new L(to< T >(args[1]) * *a); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( ), atype< T >( )); } }; -template -class CODE_L_DivLR { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a(dynamic_cast((Expression) args[0])); - throwassert( a ); - return new L(C_F0(TheOperators,"/",*pOne,args[1]) * *a);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype(),atype());} +template< class L, class T > +class CODE_L_DivLR { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a(dynamic_cast< const L * >((Expression)args[0])); + throwassert(a); + return new L(C_F0(TheOperators, "/", *pOne, args[1]) * *a); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( ), atype< T >( )); } }; -template -class CODE_Diff { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a=dynamic_cast((Expression) args[0]) ; - throwassert( a ); - return Diff(a,op);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype());} +template< class L, operatortype op > +class CODE_Diff { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a = dynamic_cast< const L * >((Expression)args[0]); + throwassert(a); + return Diff(a, op); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( )); } }; -template -class CODE_conj { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * a=dynamic_cast((Expression) args[0]) ; - throwassert( a ); - return CONJ_op(a);} - static ArrayOfaType typeargs() {return ArrayOfaType(atype());} +template< class L > +class CODE_conj { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *a = dynamic_cast< const L * >((Expression)args[0]); + throwassert(a); + return CONJ_op(a); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( )); } }; -enum TheCode_VF { Code_Jump=1, Code_Mean=2, Code_OtherSide=3}; - -template -class Code_VF { public: - typedef const L* Result; - static E_F0 * f(const basicAC_F0 & args) { - const L * u=dynamic_cast((Expression) args[0]) ; - assert( u ); - L * r= new L(*u); - for (typename L::iterator i=r->v.begin();i!=r->v.end();i++) - { operatortype & dd=i->first.second; - assert(dd());} +enum TheCode_VF { Code_Jump = 1, Code_Mean = 2, Code_OtherSide = 3 }; + +template< class L, TheCode_VF code > +class Code_VF { + public: + typedef const L *Result; + static E_F0 *f(const basicAC_F0 &args) { + const L *u = dynamic_cast< const L * >((Expression)args[0]); + assert(u); + L *r = new L(*u); + for (typename L::iterator i = r->v.begin( ); i != r->v.end( ); i++) { + operatortype &dd = i->first.second; + assert(dd < last_operatortype); + dd = (operatortype)((int)dd + last_operatortype * code); + } + return r; + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Result >( )); } }; - diff --git a/src/femlib/DataFindBoundary.hpp b/src/femlib/DataFindBoundary.hpp index 7ce40167e..87f2e552f 100644 --- a/src/femlib/DataFindBoundary.hpp +++ b/src/femlib/DataFindBoundary.hpp @@ -4,35 +4,32 @@ #include #include -template -struct GenericDataFindBoundary -{ - typedef typename Mesh::Vertex Vertex; - - typedef typename Mesh::Element Element; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::RdHat RdHat; - typedef typename Mesh::BorderElement::RdHat RdBHat; - //using EF23::GTree; +template< typename Mesh > +struct GenericDataFindBoundary { + typedef typename Mesh::Vertex Vertex; - static const int d = Rd::d; - static const int dHat = RdHat::d; - static const int dBHat = RdBHat::d; - static const bool bborder = d == dHat; // build border .?? - const Mesh *pTh; - EF23::GTree *tree; - mutable long nbfind, nbelement; - KN P;// the barycentre of element - KN delta;// de dist of recheche - KN lp;// buffer of recheche .. - long debug ; - GenericDataFindBoundary(Mesh const * pTh,int ddebug=0); - ~GenericDataFindBoundary() ;//{delete tree;} - int Find(Rd P,double *l,int & outside,long old=-1) const ;// old :add FH et PHT mai 2022 - void gnuplot(const string & fn); -}; + typedef typename Mesh::Element Element; + typedef typename Mesh::BorderElement BorderElement; + typedef typename Mesh::Rd Rd; + typedef typename Mesh::RdHat RdHat; + typedef typename Mesh::BorderElement::RdHat RdBHat; + // using EF23::GTree; + static const int d = Rd::d; + static const int dHat = RdHat::d; + static const int dBHat = RdBHat::d; + static const bool bborder = d == dHat; // build border .?? + const Mesh *pTh; + EF23::GTree< Vertex > *tree; + mutable long nbfind, nbelement; + KN< Vertex > P; // the barycentre of element + KN< double > delta; // de dist of recheche + KN< Vertex * > lp; // buffer of recheche .. + long debug; + GenericDataFindBoundary(Mesh const *pTh, int ddebug = 0); + ~GenericDataFindBoundary( ); //{delete tree;} + int Find(Rd P, double *l, int &outside, long old = -1) const; // old :add FH et PHT mai 2022 + void gnuplot(const string &fn); +}; #endif - diff --git a/src/femlib/Drawing.cpp b/src/femlib/Drawing.cpp index 87c6f23c5..243e95531 100644 --- a/src/femlib/Drawing.cpp +++ b/src/femlib/Drawing.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -34,771 +34,674 @@ #include #include "rgraph.hpp" - #include "RNM.hpp" #include "fem.hpp" -#include "FESpacen.hpp" -#include "FESpace.hpp" +#include "FESpacen.hpp" +#include "FESpace.hpp" namespace Fem2D { -void NewSetColorTable(int nb,float *colors=0,int nbcolors=0,bool hsv=true); - -void NewSetColorTable(int nb,float *colors,int nbcolors,bool hsv) -{ - if(colors && nbcolors) - SetColorTable1(nb,hsv,nbcolors,colors); - else - SetColorTable(nb); -} -int dichotomie(const RN_ &viso,R v) -{ - int i=0,j=viso.N(),k; - if (v viso[j-1]) - return -1; - while (i v) j=k; - else i=k; - return i; -} - -void plot(long i) -{ - char buf[24]; - snprintf(buf,24,"%ld",i); - plotstring(buf); -} -void plot(int i) -{ - char buf[24]; - snprintf(buf,24,"%d",i); - plotstring(buf); -} -void plot(double i) -{ - char buf[24]; - snprintf(buf,24,"%g",i); - plotstring(buf); -} - -void DrawIsoT(const R2 Pt[3],const R ff[3],const RN_ & Viso); -void DrawIsoTfill(const R2 Pt[3],const R ff[3],const RN_ & Viso,double rapz); - -void FillRect(float x0,float y0, float x1, float y1) - { - float r[8]; - r[0]=x0;r[1]=y0; - r[2]=x1;r[3]=y0; - r[4]=x1;r[5]=y1; - r[6]=x0;r[7]=y1; - fillpoly(4,r); - } - -void PlotValue(const RN_ & Viso,int k0,const char * cmm) -{ - float xmin,xmax,ymin,ymax; - // cout << "PlotValue " << Viso << endl; - // int ix,iy; - // GetSizeScreen(ix,iy); - getcadre(xmin,xmax,ymin,ymax); - float dx=(xmax-xmin); - float dy=(ymax-ymin); - // 10 points - // int kk = Max(30,iy/10); - float h=GetHeigthFont(); - float x0=xmin+dx*0.8; - float y= ymin+dy*0.95; - // cout << x0 << " " << y << " " << h << endl; - y -= k0* h*1.4; - couleur(0); - FillRect(x0-h*0.5,y-h*(1.4*Viso.N()+0.3),x0+h*9,y+h*1.5); - couleur(1); - rmoveto(x0+1.2*h,y); - plotstring(cmm); - y -= h*1.4; - for (int i=0;i viso[j - 1]) return -1; + while (i < j - 1) + if (viso[k = (i + j) / 2] > v) + j = k; + else + i = k; + return i; + } + + void plot(long i) { + char buf[24]; + snprintf(buf, 24, "%ld", i); + plotstring(buf); + } + void plot(int i) { + char buf[24]; + snprintf(buf, 24, "%d", i); + plotstring(buf); + } + void plot(double i) { + char buf[24]; + snprintf(buf, 24, "%g", i); + plotstring(buf); + } + + void DrawIsoT(const R2 Pt[3], const R ff[3], const RN_& Viso); + void DrawIsoTfill(const R2 Pt[3], const R ff[3], const RN_& Viso, double rapz); + + void FillRect(float x0, float y0, float x1, float y1) { + float r[8]; + r[0] = x0; + r[1] = y0; + r[2] = x1; + r[3] = y0; + r[4] = x1; + r[5] = y1; + r[6] = x0; + r[7] = y1; + fillpoly(4, r); + } + + void PlotValue(const RN_& Viso, int k0, const char* cmm) { + float xmin, xmax, ymin, ymax; + // cout << "PlotValue " << Viso << endl; + // int ix,iy; + // GetSizeScreen(ix,iy); + getcadre(xmin, xmax, ymin, ymax); + float dx = (xmax - xmin); + float dy = (ymax - ymin); + // 10 points + // int kk = Max(30,iy/10); + float h = GetHeigthFont( ); + float x0 = xmin + dx * 0.8; + float y = ymin + dy * 0.95; + // cout << x0 << " " << y << " " << h << endl; + y -= k0 * h * 1.4; + couleur(0); + FillRect(x0 - h * 0.5, y - h * (1.4 * Viso.N( ) + 0.3), x0 + h * 9, y + h * 1.5); + couleur(1); + rmoveto(x0 + 1.2 * h, y); + plotstring(cmm); + y -= h * 1.4; + for (int i = 0; i < Viso.N( ); i++) { + couleur(i + 4); + FillRect(x0, y, x0 + h, y + h); + rmoveto(x0 + 1.2 * h, y); + y -= h * 1.4; + plot(Viso[i]); } -} - -void DrawCommentaire(const char * cm,float x,float y) -{ - float xmin,xmax,ymin,ymax; - getcadre(xmin,xmax,ymin,ymax); - float dx=(xmax-xmin); - float dy=(ymax-ymin); - - rmoveto(xmin+dx*x,ymin+dy*y); - plotstring(cm); -} - -void Mesh::DrawBoundary() const -{ - for(int i=0;i0) InitDraw(); - - SetColorTable(16) ; - for (int i=0;i 0) InitDraw( ); + + SetColorTable(16); + for (int i = 0; i < nt; i++) { + if (fill) { + triangles[i].Fill(2 + Abs(triangles[i].lab)); + couleur(triangles[i].lab ? 1 : 0); + triangles[i].Draw( ); + } else { + couleur(1 + Abs(triangles[i].lab)); + triangles[i].Draw( ); + } } - - couleur(1); - penthickness(2); - for (int i=0;i0) kk=ArrowSize/100.; - R cc = d*0.05; - int nsb = nbsubdivision(); - int nsb2 = NbOfSubTriangle(nsb); - int nbdf=NbDoF(); - RN fk(nbdf); - RN gk(nbdf); - for (int i=0;i99) cout << " color vect " << l << " " << col << endl; + return minmax; + } + void FElement::Draw(const RN_& U, const RN_& V, const RN_& Viso, R coef, int i0, int i1, double ArrowSize) const { + bool whatd[last_operatortype]; + initwhatd(whatd, 0); + + float xmin, xmax, ymin, ymax; + getcadre(xmin, xmax, ymin, ymax); + float d = Max(ymax - ymin, xmax - xmin); + R kk = d * 0.005; + if (ArrowSize > 0) kk = ArrowSize / 100.; + R cc = d * 0.05; + int nsb = nbsubdivision( ); + int nsb2 = NbOfSubTriangle(nsb); + int nbdf = NbDoF( ); + RN fk(nbdf); + RN gk(nbdf); + for (int i = 0; i < nbdf; i++) // get the local value + fk[i] = U[operator( )(i)]; + for (int i = 0; i < nbdf; i++) // get the local value + gk[i] = V[operator( )(i)]; + + RNMK fb(nbdf, N, 3); // the value for basic fonction + RN f0(3); + RN f1(3); + R2 Pt, P[3], A(T[0]), B(T[1]), C(T[2]); + for (int k = 0; k < nsb2; k++) { + // ff=0.0; + for (int j = 0; j < 3; j++) { + // cout << nbdf << endl; + Pt = SubTriangle(nsb, k, j); // current point + BF(whatd, Pt, fb); + f0[j] = dot(fb('.', i0, 0), fk); + f1[j] = dot(fb('.', i1, 0), gk); + // if(number<2) + // cout << number << " " << fk << " " << fb('.',0,0) << " : " << f0[j] << " " << f1[j] << endl; + P[j] = A * (1 - Pt.x - Pt.y) + B * Pt.x + C * Pt.y; + R2 uv(f0[j], f1[j]); + R l = Max(sqrt((uv, uv)), 1e-30); + + { + int col = 4 + dichotomie(Viso, l); + if (verbosity > 99) cout << " color vect " << l << " " << col << endl; couleur(col); - uv = coef*uv; + uv = coef * uv; l *= coef; - R2 dd = uv*(-kk/l);// modif F.H size of arraow 08/14 FH.l - - R2 dn = dd.perp()*0.5; - if (l*10000.< kk) continue; - if (l < kk) - uv = uv*(kk/l); - else if (l> cc) - uv = uv*(cc/l); - MoveTo(P[j]); - LineTo(P[j]+uv); - if (l>kk) { - LineTo(P[j]+uv+dd+dn); - MoveTo(P[j]+uv+dd-dn); - LineTo(P[j]+uv);} + R2 dd = uv * (-kk / l); // modif F.H size of arraow 08/14 FH.l + + R2 dn = dd.perp( ) * 0.5; + if (l * 10000. < kk) continue; + if (l < kk) + uv = uv * (kk / l); + else if (l > cc) + uv = uv * (cc / l); + MoveTo(P[j]); + LineTo(P[j] + uv); + if (l > kk) { + LineTo(P[j] + uv + dd + dn); + MoveTo(P[j] + uv + dd - dn); + LineTo(P[j] + uv); } + } } - } -} - -void DrawIsoT(const R2 Pt[3],const R ff[3],const RN_ & Viso) -{ - R2 PQ[5]; - int NbIso = Viso.N(); - for(int l=0;l< NbIso;l++) /* loop on the level curves */ + } + } + + void DrawIsoT(const R2 Pt[3], const R ff[3], const RN_& Viso) { + R2 PQ[5]; + int NbIso = Viso.N( ); + for (int l = 0; l < NbIso; l++) /* loop on the level curves */ { R xf = Viso[l]; - int im=0; - for(int i=0;i<3;i++) // for the 3 edges - { - int j = (i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)<=0.1e-10) /* one side must be drawn */ - { - couleur(l+4); - MoveTo(Pt[i]); - LineTo(Pt[j]); - } - else - { - R xlam=(fi-xf)/(fi-fj); - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - } - - if (im>=2) /* draw one segment */ - { - couleur(l+4); - MoveTo(PQ[0]); - LineTo(PQ[1]); - } + int im = 0; + for (int i = 0; i < 3; i++) // for the 3 edges + { + int j = (i + 1) % 3; + R fi = (ff[i]); + R fj = (ff[j]); + + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) <= 0.1e-10) /* one side must be drawn */ + { + couleur(l + 4); + MoveTo(Pt[i]); + LineTo(Pt[j]); + } else { + R xlam = (fi - xf) / (fi - fj); + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; + } + } + } + + if (im >= 2) /* draw one segment */ + { + couleur(l + 4); + MoveTo(PQ[0]); + LineTo(PQ[1]); + } } - -} -void DrawIsoTfill(const R2 Pt[3],const R ff[3],const RN_ & Viso,double rapz) -{ - R2 PQ[10]; - int NbIso = Viso.N(); - R eps= (Viso[NbIso-1]-Viso[0])*1e-6; - for(int l=1;l< NbIso;l++) // loop on the level curves + } + void DrawIsoTfill(const R2 Pt[3], const R ff[3], const RN_& Viso, double rapz) { + R2 PQ[10]; + int NbIso = Viso.N( ); + R eps = (Viso[NbIso - 1] - Viso[0]) * 1e-6; + for (int l = 1; l < NbIso; l++) // loop on the level curves { - R xfb = Viso[l-1]; + R xfb = Viso[l - 1]; R xfh = Viso[l]; - int im=0; - for(int i=0;i<3;i++) // for the 3 edges - { - int j=(i+1)%3; - R fi=(ff[i]); - R fj=(ff[j]); - R xxfb = xfb; - R xxfh = xfh; - if (fj=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)>=0.1e-20) - { - R xlam=(fi-xf)/(fi-fj); - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - xf = xxfh; - if(((fi<=xf)&&(fj>=xf))||((fi>=xf)&&(fj<=xf))) - { - if (Abs(fi-fj)>=0.1e-20) - { - R xlam=(fi-xf)/(fi-fj); - PQ[im++] = Pt[i] * (1.F-xlam) + Pt[j]* xlam; - } - } - if ( xfb-eps <=fj && fj <= xfh+eps) - PQ[im++] = Pt[j]; - } - if (im>2) - { - float f[20]; - int k=0; - for (int i=0;i -void TBoundaryEdge::Draw() const -{ - couleur(2+(lab%6)); - MoveTo(*vertices[0]); - LineTo(*vertices[1]); -} - - template - void FElement::SaveDraw(const KN_ & U,int composante,R* Usave) const - { - int nsb = nbsubdivision(); - int nsbv = NbOfSubInternalVertices(nsb); - int nbdf=NbDoF(); - KN fk(nbdf); - for (int i=0;i= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; + } + } + xf = xxfh; + if (((fi <= xf) && (fj >= xf)) || ((fi >= xf) && (fj <= xf))) { + if (Abs(fi - fj) >= 0.1e-20) { + R xlam = (fi - xf) / (fi - fj); + PQ[im++] = Pt[i] * (1.F - xlam) + Pt[j] * xlam; + } + } + if (xfb - eps <= fj && fj <= xfh + eps) PQ[im++] = Pt[j]; + } + if (im > 2) { + float f[20]; + int k = 0; + for (int i = 0; i < im; i++) f[k++] = PQ[i].x, f[k++] = PQ[i].y; + f[k++] = f[0]; + f[k++] = f[1]; + + couleur(3 + l); + fillpoly(im, f); + } } - template - void FElement::SaveDraw(const KN_ & U,const KN_ & V,int iU,int iV,R * Usave) const - { - int nsb = nbsubdivision(); - int nsbv = NbOfSubInternalVertices(nsb); - int nbdf=NbDoF(); - KN fk(nbdf); - KN gk(nbdf); - for (int i=0;i -KN FESpace::newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const - { - nsb = TFE[0]->nbsubdivision; - int nsbv = NbOfSubInternalVertices(nsb); - lg = nsbv*Th.nt; - if(verbosity>99) - cout << " ++ newSaveDraw what: nt " << Th.nt << " " << nsbv << " " << lg << endl; - KN v(lg); - ffassert(v); - for (int k=0,i=0;k(true,v);// to remove the copy. + } + + template< class R2 > + void TBoundaryEdge< R2 >::Draw( ) const { + couleur(2 + (lab % 6)); + MoveTo(*vertices[0]); + LineTo(*vertices[1]); + } + + template< class R > + void FElement::SaveDraw(const KN_< R >& U, int composante, R* Usave) const { + int nsb = nbsubdivision( ); + int nsbv = NbOfSubInternalVertices(nsb); + int nbdf = NbDoF( ); + KN< R > fk(nbdf); + for (int i = 0; i < nbdf; i++) // get the local value + fk[i] = U[operator( )(i)]; + R2 Pt; + bool whatd[last_operatortype]; + initwhatd(whatd, 0); + + RNMK fb(nbdf, N, 3); // the value for basic fonction + for (int k = 0; k < nsbv; k++) { + Pt = SubInternalVertex(nsb, k); + BF(whatd, Pt, fb); + Usave[k] = R( ); // (fb('.',composante,0),fk); + for (int i = 0; i < nbdf; ++i) Usave[k] += fb(i, composante, 0) * fk[i]; } - - -template -KN FESpace::newSaveDraw(const KN_ & U,const KN_ & V,int iU,int iV,int & lg,int & nsb) const + } + template< class R > + void FElement::SaveDraw(const KN_< R >& U, const KN_< R >& V, int iU, int iV, R* Usave) const { + int nsb = nbsubdivision( ); + int nsbv = NbOfSubInternalVertices(nsb); + int nbdf = NbDoF( ); + KN< R > fk(nbdf); + KN< R > gk(nbdf); + for (int i = 0; i < nbdf; i++) // get the local valu { - nsb = TFE[0]->nbsubdivision; - int nsbv = NbOfSubInternalVertices(nsb)*2; - lg = nsbv*Th.nt; - - KN v(lg); - - for (int k=0,i=0;k(true,v);// to remove the copy. + fk[i] = U[operator( )(i)]; + gk[i] = V[operator( )(i)]; } - -typedef complex Complex; -template - KN FESpace::newSaveDraw(const KN_ & U,const KN_ & V,int iU,int iV,int & lg,int & nsb) const ; -template - KN FESpace::newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const ; - template - KN FESpace::newSaveDraw(const KN_ & U,const KN_ & V,int iU,int iV,int & lg,int & nsb) const ; - template - KN FESpace::newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const ; - - -void FESpace::Draw(const RN_& U,const RN_ & Viso,int j,float *colors,int nbcolors,bool hsv,bool drawborder) const -{ - showgraphic(); - NewSetColorTable(Viso.N()+4,colors,nbcolors,hsv); - for (int k=0;k& U,const KN_& V,int j0,int j1,bool bb) const -{ - R2 Pminmax(1e100,-1e100); - for (int k=0;k& U,int j0,bool bb) const -{ - R2 Pminmax(1e100,-1e100); - for (int k=0;k& U,const RN_ & Viso, R coef,int j0,int j1,float *colors,int nbcolors,bool hsv,bool drawborder,double ArrowSize) const -{ - showgraphic(); - NewSetColorTable(Viso.N()+5,colors,nbcolors,hsv); - for (int k=0;k& U,const KN_& V,const RN_ & Viso, R coef,int iu,int iv,float *colors,int nbcolors,bool hsv,bool drawborder,double ArrowSize) const -{ - showgraphic(); - NewSetColorTable(Viso.N()+5,colors,nbcolors,hsv); - for (int k=0;k -void TTriangle::Draw(double skrink) const -{ - const TTriangle & K(*this); - R2 A(K[0]),B(K[1]),C(K[2]),G((A+B+C)/3.); - A = G + (A-G)*skrink; - B = G + (B-G)*skrink; - C = G + (C-G)*skrink; - MoveTo(A); - LineTo(B); - LineTo(C); - LineTo(A); -} - -template -void TTriangle::Draw(int edge,double skrink) const -{ - const TTriangle & K(*this); - R2 A(K[0]),B(K[1]),C(K[2]),G((A+B+C)/3.); - MoveTo(G+(*vertices[(edge+1)%3]-G)*skrink); - LineTo(G+(*vertices[(edge+2)%3]-G)*skrink); -} - - -template void TTriangle::Draw(double skrink) const; -template void TTriangle::Draw(int edge,double skrink) const; - -template -void TTriangle::Fill(int color) const -{ - const TTriangle & K(*this); - R2 A(K[0]),B(K[1]),C(K[2]); - float p[]={(float)A.x,(float)A.y,(float)B.x,(float)B.y,(float)C.x,(float)C.y}; - int c=LaCouleur(); - couleur(color); - fillpoly(3,p); - couleur(c); -} - -void DrawMark(R2 P,R k) - { - float x0,x1,y0,y1; - getcadre(x0,x1,y0,y1); - float h= (x1-x0)*(float)k; - rmoveto((float)P.x+h,(float)P.y-h); - rlineto((float)P.x+h,(float)P.y+h); - rlineto((float)P.x-h,(float)P.y+h); - rlineto((float)P.x-h,(float)P.y-h); - rlineto((float)P.x+h,(float)P.y-h); - } - - Triangle * Mesh::Find(const R2 & P) const - { + k2 += 2; + } + } + + template< class R > + KN< R > FESpace::newSaveDraw(const KN_< R >& U, int composante, int& lg, int& nsb) const { + nsb = TFE[0]->nbsubdivision; + int nsbv = NbOfSubInternalVertices(nsb); + lg = nsbv * Th.nt; + if (verbosity > 99) cout << " ++ newSaveDraw what: nt " << Th.nt << " " << nsbv << " " << lg << endl; + KN< R > v(lg); + ffassert(v); + for (int k = 0, i = 0; k < Th.nt; k++) { + (*this)[k].SaveDraw(U, composante, &v[i]); + i += nsbv; + } + return KN< R >(true, v); // to remove the copy. + } + + template< class R > + KN< R > FESpace::newSaveDraw(const KN_< R >& U, const KN_< R >& V, int iU, int iV, int& lg, int& nsb) const { + nsb = TFE[0]->nbsubdivision; + int nsbv = NbOfSubInternalVertices(nsb) * 2; + lg = nsbv * Th.nt; + + KN< R > v(lg); + + for (int k = 0, i = 0; k < Th.nt; k++) { + (*this)[k].SaveDraw(U, V, iU, iV, &v[i]); + i += nsbv; + } + return KN< R >(true, v); // to remove the copy. + } + + typedef complex< double > Complex; + template KN< double > FESpace::newSaveDraw< double >(const KN_< double >& U, const KN_< double >& V, int iU, int iV, int& lg, int& nsb) const; + template KN< double > FESpace::newSaveDraw< double >(const KN_< double >& U, int composante, int& lg, int& nsb) const; + template KN< Complex > FESpace::newSaveDraw< Complex >(const KN_< Complex >& U, const KN_< Complex >& V, int iU, int iV, int& lg, int& nsb) const; + template KN< Complex > FESpace::newSaveDraw< Complex >(const KN_< Complex >& U, int composante, int& lg, int& nsb) const; + + void FESpace::Draw(const RN_& U, const RN_& Viso, int j, float* colors, int nbcolors, bool hsv, bool drawborder) const { + showgraphic( ); + NewSetColorTable(Viso.N( ) + 4, colors, nbcolors, hsv); + for (int k = 0; k < Th.nt; k++) (*this)[k].Draw(U, Viso, j); + NewSetColorTable(2 + 6, colors, nbcolors, hsv); + if (drawborder) Th.DrawBoundary( ); + NewSetColorTable(Viso.N( ) + 4, colors, nbcolors, hsv); + } + + void FESpace::Drawfill(const RN_& U, const RN_& Viso, int j, double rapz, float* colors, int nbcolors, bool hsv, bool drawborder) const { + showgraphic( ); + NewSetColorTable(Viso.N( ) + 4, colors, nbcolors, hsv); + for (int k = 0; k < Th.nt; k++) (*this)[k].Drawfill(U, Viso, j, rapz); + NewSetColorTable(2 + 6, colors, nbcolors, hsv); + if (drawborder) Th.DrawBoundary( ); + NewSetColorTable(Viso.N( ) + 4, colors, nbcolors, hsv); + } + + R2 FESpace::MinMax(const KN_< R >& U, const KN_< R >& V, int j0, int j1, bool bb) const { + R2 Pminmax(1e100, -1e100); + for (int k = 0; k < Th.nt; k++) { + const Triangle& K(Th[k]); + R2 A(K[0]), B(K[1]), C(K[2]); + if (bb || InRecScreen(Min(A.x, B.x, C.x), Min(A.y, B.y, C.y), Max(A.x, B.x, C.x), Max(A.y, B.y, C.y))) Pminmax = minmax(Pminmax, (*this)[k].MinMax(U, V, j0, j1)); + } + return Pminmax; + } + R2 FESpace::MinMax(const KN_< R >& U, int j0, bool bb) const { + R2 Pminmax(1e100, -1e100); + for (int k = 0; k < Th.nt; k++) { + const Triangle& K(Th[k]); + R2 A(K[0]), B(K[1]), C(K[2]); + if (bb || InRecScreen(Min(A.x, B.x, C.x), Min(A.y, B.y, C.y), Max(A.x, B.x, C.x), Max(A.y, B.y, C.y))) Pminmax = minmax(Pminmax, (*this)[k].MinMax(U, j0)); + } + return Pminmax; + } + void FESpace::Draw(const KN_< R >& U, const RN_& Viso, R coef, int j0, int j1, float* colors, int nbcolors, bool hsv, bool drawborder, double ArrowSize) const { + showgraphic( ); + NewSetColorTable(Viso.N( ) + 5, colors, nbcolors, hsv); + for (int k = 0; k < Th.nt; k++) (*this)[k].Draw(U, U, Viso, coef, j0, j1, ArrowSize); + NewSetColorTable(2 + 6, colors, nbcolors, hsv); + if (drawborder) Th.DrawBoundary( ); + NewSetColorTable(Viso.N( ) + 5, colors, nbcolors, hsv); + } + + void FESpace::Draw(const KN_< R >& U, const KN_< R >& V, const RN_& Viso, R coef, int iu, int iv, float* colors, int nbcolors, bool hsv, bool drawborder, double ArrowSize) const { + showgraphic( ); + NewSetColorTable(Viso.N( ) + 5, colors, nbcolors, hsv); + for (int k = 0; k < Th.nt; k++) (*this)[k].Draw(U, V, Viso, coef, iu, iv, ArrowSize); + NewSetColorTable(2 + 6, colors, nbcolors, hsv); + if (drawborder) Th.DrawBoundary( ); + NewSetColorTable(Viso.N( ) + 5, colors, nbcolors, hsv); + } + + template< class R2 > + void TTriangle< R2 >::Draw(double skrink) const { + const TTriangle< R2 >& K(*this); + R2 A(K[0]), B(K[1]), C(K[2]), G((A + B + C) / 3.); + A = G + (A - G) * skrink; + B = G + (B - G) * skrink; + C = G + (C - G) * skrink; + MoveTo(A); + LineTo(B); + LineTo(C); + LineTo(A); + } + + template< class R2 > + void TTriangle< R2 >::Draw(int edge, double skrink) const { + const TTriangle< R2 >& K(*this); + R2 A(K[0]), B(K[1]), C(K[2]), G((A + B + C) / 3.); + MoveTo(G + (*vertices[(edge + 1) % 3] - G) * skrink); + LineTo(G + (*vertices[(edge + 2) % 3] - G) * skrink); + } + + template void TTriangle< R2 >::Draw(double skrink) const; + template void TTriangle< R2 >::Draw(int edge, double skrink) const; + + template< class R2 > + void TTriangle< R2 >::Fill(int color) const { + const TTriangle< R2 >& K(*this); + R2 A(K[0]), B(K[1]), C(K[2]); + float p[] = {(float)A.x, (float)A.y, (float)B.x, (float)B.y, (float)C.x, (float)C.y}; + int c = LaCouleur( ); + couleur(color); + fillpoly(3, p); + couleur(c); + } + + void DrawMark(R2 P, R k) { + float x0, x1, y0, y1; + getcadre(x0, x1, y0, y1); + float h = (x1 - x0) * (float)k; + rmoveto((float)P.x + h, (float)P.y - h); + rlineto((float)P.x + h, (float)P.y + h); + rlineto((float)P.x - h, (float)P.y + h); + rlineto((float)P.x - h, (float)P.y - h); + rlineto((float)P.x + h, (float)P.y - h); + } + + Triangle* Mesh::Find(const R2& P) const { // brute force - - for (int i=0;i-eps && b >-eps && c >-eps) return triangles + i; - - } - return 0; // outside - } - - - -template - void TMortar::Draw() const { - throwassert(Th); - for (int i=0;i -eps && b > -eps && c > -eps) return triangles + i; + } + return 0; // outside + } + + template< class R2 > + void TMortar< R2 >::Draw( ) const { + throwassert(Th); + for (int i = 0; i < nleft; i++) (*Th)[left[i] / 3].Draw(left[i] % 3, 0.8); + for (int i = 0; i < nright; i++) (*Th)[right[i] / 3].Draw(right[i] % 3, 0.8); + } +} // namespace Fem2D diff --git a/src/femlib/Element_P2h.cpp b/src/femlib/Element_P2h.cpp index e9cc7d56f..3d8959447 100644 --- a/src/femlib/Element_P2h.cpp +++ b/src/femlib/Element_P2h.cpp @@ -1,134 +1,124 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "error.hpp" #include "rgraph.hpp" -using namespace std; +using namespace std; #include "RNM.hpp" #include "fem.hpp" #include "FESpace.hpp" -namespace Fem2D { +namespace Fem2D { - // ------ P2h Hierarchical (just remove P1 node of the P2 finite element) -------- - class TypeOfFE_P2hLagrange : public TypeOfFE { public: - static int Data[]; + // ------ P2h Hierarchical (just remove P1 node of the P2 finite element) -------- + class TypeOfFE_P2hLagrange : public TypeOfFE { + public: + static int Data[]; static double Pi_h_coef[]; - TypeOfFE_P2hLagrange(): TypeOfFE(0,1,0,1,Data,4,1,3,3,Pi_h_coef) - { - - const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int i=0;i=3); - throwassert(val.M()==1); - - val=0; -// -- - if (whatd[op_id]) - { - RN_ f0(val('.',0,op_id)); - f0[0] = 4*l1*l2; // oppose au sommet 0 - f0[1] = 4*l0*l2; // oppose au sommet 1 - f0[2] = 4*l1*l0; // oppose au sommet 3 - } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = 4*(Dl1.x*l2 + Dl2.x*l1) ; - f0x[1] = 4*(Dl2.x*l0 + Dl0.x*l2) ; - f0x[2] = 4*(Dl0.x*l1 + Dl1.x*l0) ; - } + TypeOfFE_P2hLagrange( ) : TypeOfFE(0, 1, 0, 1, Data, 4, 1, 3, 3, Pi_h_coef) { - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = 4*(Dl1.y*l2 + Dl2.y*l1) ; - f0y[1] = 4*(Dl2.y*l0 + Dl0.y*l2) ; - f0y[2] = 4*(Dl0.y*l1 + Dl1.y*l0) ; - } - - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - - fxx[0] = 8*Dl1.x*Dl2.x; - fxx[1] = 8*Dl0.x*Dl2.x; - fxx[2] = 8*Dl0.x*Dl1.x; - } + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + }; + // on what nu df on node node of df + int TypeOfFE_P2hLagrange::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 3}; + double TypeOfFE_P2hLagrange::Pi_h_coef[] = {1., 1., 1.}; - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - fyy[0] = 8*Dl1.y*Dl2.y; - fyy[1] = 8*Dl0.y*Dl2.y; - fyy[2] = 8*Dl0.y*Dl1.y; - } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - - fxy[0] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x); - fxy[1] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x); - fxy[2] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x); - } - - } - -} -// link with FreeFem++ do not work with static library .a -// FH so add a extern name to call in init_static_FE (see end of FESpace.cpp) -void init_FE_P2h() { }; + void TypeOfFE_P2hLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + // R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + + val = 0; + // -- + if (whatd[op_id]) { + RN_ f0(val('.', 0, op_id)); + f0[0] = 4 * l1 * l2; // oppose au sommet 0 + f0[1] = 4 * l0 * l2; // oppose au sommet 1 + f0[2] = 4 * l1 * l0; // oppose au sommet 3 + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = 4 * (Dl1.x * l2 + Dl2.x * l1); + f0x[1] = 4 * (Dl2.x * l0 + Dl0.x * l2); + f0x[2] = 4 * (Dl0.x * l1 + Dl1.x * l0); + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = 4 * (Dl1.y * l2 + Dl2.y * l1); + f0y[1] = 4 * (Dl2.y * l0 + Dl0.y * l2); + f0y[2] = 4 * (Dl0.y * l1 + Dl1.y * l0); + } -extern ListOfTFE typefem_P2h; + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + + fxx[0] = 8 * Dl1.x * Dl2.x; + fxx[1] = 8 * Dl0.x * Dl2.x; + fxx[2] = 8 * Dl0.x * Dl1.x; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + fyy[0] = 8 * Dl1.y * Dl2.y; + fyy[1] = 8 * Dl0.y * Dl2.y; + fyy[2] = 8 * Dl0.y * Dl1.y; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + + fxy[0] = 4 * (Dl1.x * Dl2.y + Dl1.y * Dl2.x); + fxy[1] = 4 * (Dl0.x * Dl2.y + Dl0.y * Dl2.x); + fxy[2] = 4 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x); + } + } + } + // link with FreeFem++ do not work with static library .a + // FH so add a extern name to call in init_static_FE (see end of FESpace.cpp) + void init_FE_P2h( ) {}; -static TypeOfFE_P2hLagrange P2LagrangeP2h; -// given the name of the finite element in FreeFem++ - ListOfTFE typefem_P2h("P2h", &P2LagrangeP2h); + extern ListOfTFE typefem_P2h; + static TypeOfFE_P2hLagrange P2LagrangeP2h; + // given the name of the finite element in FreeFem++ + ListOfTFE typefem_P2h("P2h", &P2LagrangeP2h); -// --- fin -- -} // FEM2d namespace + // --- fin -- +} // namespace Fem2D diff --git a/src/femlib/Element_RT.cpp b/src/femlib/Element_RT.cpp index 9f77112a4..574a927d2 100644 --- a/src/femlib/Element_RT.cpp +++ b/src/femlib/Element_RT.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -32,794 +32,737 @@ #include #include #include "rgraph.hpp" -using namespace std; +using namespace std; #include "RNM.hpp" #include "fem.hpp" #include "FESpace.hpp" -namespace Fem2D { - -class TypeOfFE_RT : public TypeOfFE { public: - static int Data[]; - TypeOfFE_RT(): TypeOfFE(0,1,0,2,Data,1,1,6,3) - {const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int p=0,kk=0;p<3;p++) - { P_Pi_h[p]=Pt[p]; - for (int j=0;j<2;j++) - pij_alpha[kk++]= IPJ(p,p,j); - }} - // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - void FB(const bool * watdd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; -// void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; - void Pi_h_alpha(const baseFElement & K,KN_ & v) const ; -} ; -// on what nu df on node node of df - int TypeOfFE_RT::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0,0, 0,0,3,3}; - -/* void TypeOfFE_RT::D2_FB(const Mesh & ,const Triangle & ,const R2 & ,RNMK_ & val) const -{ // - val=0; -}*/ -/* - void TypeOfFE_RT::FB(const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // -// const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - if (val.N() <3) - throwassert(val.N() >=3); - throwassert(val.M()==2 ); - throwassert(val.K()==3 ); - RN_ f0(val('.',0,0)); - RN_ f1(val('.',1,0)); - val=0; -// RN_ df0(val(0,'.',0)); -// RN_ fy(val('.','.',2)); - // a_i ([x,y]-c_i) , ou c_i = A,B , C si i= 0,1,2 - // int_T a_i div([x,y]-c_i) = 1 - // div div([x,y]-c_i) = 2 - // donc a_i = 1/(2 area T) - - R a=1./(2*K.area); - R a0= K.EdgeOrientation(0) * a ; - R a1= K.EdgeOrientation(1) * a ; - R a2= K.EdgeOrientation(2) * a ; - // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; - - // ------------ - f0[0] = (P.x-A.x)*a0; - f1[0] = (P.y-A.y)*a0; - - f0[1] = (P.x-B.x)*a1; - f1[1] = (P.y-B.y)*a1; - - f0[2] = (P.x-C.x)*a2; - f1[2] = (P.y-C.y)*a2; - // ---------------- - // ---------------- - // BUG dans RT correct FH le 17 sept 2002 - // dx [x,y] = [1,0] et non [1,1] - // dy [x,y] = [0,1] et non [1,1] - // ------------------------------------- - - val(0,0,1) = a0; - val(1,0,1) = a1; - val(2,0,1) = a2; - val(0,1,2) = a0; - val(1,1,2) = a1; - val(2,1,2) = a2; - -} -*/ - void TypeOfFE_RT::FB(const bool *whatd,const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // -// const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - // R l0=1-P.x-P.y,l1=P.x,l2=P.y; - // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - throwassert(val.N() >=3); - throwassert(val.M()==2 ); -// throwassert(val.K()==3 ); - val=0; - R a=1./(2*K.area); - R a0= K.EdgeOrientation(0) * a ; - R a1= K.EdgeOrientation(1) * a ; - R a2= K.EdgeOrientation(2) * a ; - // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; - - // ------------ - if (whatd[op_id]) - { - assert(val.K()>op_id); - RN_ f0(val('.',0,0)); - RN_ f1(val('.',1,0)); - f0[0] = (P.x-A.x)*a0; - f1[0] = (P.y-A.y)*a0; - - f0[1] = (P.x-B.x)*a1; - f1[1] = (P.y-B.y)*a1; - - f0[2] = (P.x-C.x)*a2; - f1[2] = (P.y-C.y)*a2; - } - // ---------------- - // BUG dans RT correct FH le 17 sept 2002 - // dx [x,y] = [1,0] et non [1,1] - // dy [x,y] = [0,1] et non [1,1] - // ------------------------------------- - if (whatd[op_dx]) - { - assert(val.K()>op_dx); - val(0,0,op_dx) = a0; - val(1,0,op_dx) = a1; - val(2,0,op_dx) = a2; - } - if (whatd[op_dy]) - { - assert(val.K()>op_dy); - val(0,1,op_dy) = a0; - val(1,1,op_dy) = a1; - val(2,1,op_dy) = a2; +namespace Fem2D { + + class TypeOfFE_RT : public TypeOfFE { + public: + static int Data[]; + TypeOfFE_RT( ) : TypeOfFE(0, 1, 0, 2, Data, 1, 1, 6, 3) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int p = 0, kk = 0; p < 3; p++) { + P_Pi_h[p] = Pt[p]; + for (int j = 0; j < 2; j++) pij_alpha[kk++] = IPJ(p, p, j); + } + } + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *watdd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; + void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; + }; + // on what nu df on node node of df + int TypeOfFE_RT::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 3, 3}; + + /* void TypeOfFE_RT::D2_FB(const Mesh & ,const Triangle & ,const R2 & ,RNMK_ & val) const + { // + val=0; + }*/ + /* + void TypeOfFE_RT::FB(const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const + { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]),C(K[2]); + R l0=1-P.x-P.y,l1=P.x,l2=P.y; + // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + if (val.N() <3) + throwassert(val.N() >=3); + throwassert(val.M()==2 ); + throwassert(val.K()==3 ); + RN_ f0(val('.',0,0)); + RN_ f1(val('.',1,0)); + val=0; + // RN_ df0(val(0,'.',0)); + // RN_ fy(val('.','.',2)); + // a_i ([x,y]-c_i) , ou c_i = A,B , C si i= 0,1,2 + // int_T a_i div([x,y]-c_i) = 1 + // div div([x,y]-c_i) = 2 + // donc a_i = 1/(2 area T) + + R a=1./(2*K.area); + R a0= K.EdgeOrientation(0) * a ; + R a1= K.EdgeOrientation(1) * a ; + R a2= K.EdgeOrientation(2) * a ; + // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; + + // ------------ + f0[0] = (P.x-A.x)*a0; + f1[0] = (P.y-A.y)*a0; + + f0[1] = (P.x-B.x)*a1; + f1[1] = (P.y-B.y)*a1; + + f0[2] = (P.x-C.x)*a2; + f1[2] = (P.y-C.y)*a2; + // ---------------- + // ---------------- + // BUG dans RT correct FH le 17 sept 2002 + // dx [x,y] = [1,0] et non [1,1] + // dy [x,y] = [0,1] et non [1,1] + // ------------------------------------- + + val(0,0,1) = a0; + val(1,0,1) = a1; + val(2,0,1) = a2; + val(0,1,2) = a0; + val(1,1,2) = a1; + val(2,1,2) = a2; + } -} -/* - void TypeOfFE_RT::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const -{ - const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - const Triangle & T(K.T); - // if (K.number<2) cout << K.number << ": " ; - for (int i=0;i<3;i++) - { - f(v,T(Pt[i]),K,i,Pt[i],arg); - R2 E(T.Edge(i)); - R signe = T.EdgeOrientation(i) ; - val[i]= signe*(v[j]*E.y-v[j+1]*E.x); - // if (K.number<2) cout << val[i] << " " ; - } - // if (K.number<2) cout << endl; -} -*/ -void TypeOfFE_RT::Pi_h_alpha(const baseFElement & K,KN_ & v) const -{ - const Triangle & T(K.T); - - for (int i=0,k=0;i<3;i++) - { - R2 E(T.Edge(i)); - R signe = T.EdgeOrientation(i) ; - v[k++]= signe*E.y; - v[k++]=-signe*E.x; - } -} -// ------------------- - - - -class TypeOfFE_RTmodif : public TypeOfFE { public: - static int Data[]; - TypeOfFE_RTmodif(): TypeOfFE(0,1,0,2,Data,1,1,6,3) - {const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int p=0,kk=0;p<3;p++) - { P_Pi_h[p]=Pt[p]; - for (int j=0;j<2;j++) - pij_alpha[kk++]= IPJ(p,p,j); - }} - // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - void FB(const bool * whatd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; - void Pi_h_alpha(const baseFElement & K,KN_ & v) const ; -} ; -// on what nu df on node node of df - int TypeOfFE_RTmodif::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0,0, 0,0, 3,3}; - - - void TypeOfFE_RTmodif::FB(const bool * whatd,const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // -// const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - R la=1-PHat.x-PHat.y,lb=PHat.x,lc=PHat.y; - R2 Dla(K.H(0)), Dlb(K.H(1)), Dlc(K.H(2)); - throwassert(val.N() >=3); - throwassert(val.M()==2 ); - - R2 AB(A,B),AC(A,C),BA(B,A),BC(B,C),CA(C,A),CB(C,B); - - R aa0= 1./(((AB,Dlb) + (AC,Dlc))*K.area); - R aa1= 1./(((BA,Dla) + (BC,Dlc))*K.area); - R aa2= 1./(((CA,Dla) + (CB,Dlb))*K.area); - int i=0; - R a0= &K[ (i+1)%3] < &K[ (i+2)%3] ? aa0 : -aa0 ; - i=1; - R a1= &K[ (i+1)%3] < &K[ (i+2)%3] ? aa1 : -aa1 ; - i=2; - R a2= &K[ (i+1)%3] < &K[ (i+2)%3] ? aa2 : -aa2 ; - // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; - - R2 Va= AB*(lb*a0) + AC*(lc*a0); - R2 Vb= BA*(la*a1) + BC*(lc*a1); - R2 Vc= CA*(la*a2) + CB*(lb*a2); - R2 Va_x= AB*(Dlb.x*a0) + AC*(Dlc.x*a0); - R2 Vb_x= BA*(Dla.x*a1) + BC*(Dlc.x*a1); - R2 Vc_x= CA*(Dla.x*a2) + CB*(Dlb.x*a2); - R2 Va_y= AB*(Dlb.y*a0) + AC*(Dlc.y*a0); - R2 Vb_y= BA*(Dla.y*a1) + BC*(Dlc.y*a1); - R2 Vc_y= CA*(Dla.y*a2) + CB*(Dlb.y*a2); - - if( whatd[op_id]) - { - RN_ f0(val('.',0,0)); - RN_ f1(val('.',1,0)); - - f0[0] = Va.x; - f1[0] = Va.y; - - f0[1] = Vb.x; - f1[1] = Vb.y; - - f0[2] = Vc.x; - f1[2] = Vc.y; + */ + void TypeOfFE_RT::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &PHat, RNMK_ &val) const { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]), C(K[2]); + // R l0=1-P.x-P.y,l1=P.x,l2=P.y; + // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 2); + // throwassert(val.K()==3 ); + val = 0; + R a = 1. / (2 * K.area); + R a0 = K.EdgeOrientation(0) * a; + R a1 = K.EdgeOrientation(1) * a; + R a2 = K.EdgeOrientation(2) * a; + // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; + + // ------------ + if (whatd[op_id]) { + assert(val.K( ) > op_id); + RN_ f0(val('.', 0, 0)); + RN_ f1(val('.', 1, 0)); + f0[0] = (P.x - A.x) * a0; + f1[0] = (P.y - A.y) * a0; + + f0[1] = (P.x - B.x) * a1; + f1[1] = (P.y - B.y) * a1; + + f0[2] = (P.x - C.x) * a2; + f1[2] = (P.y - C.y) * a2; + } + // ---------------- + // BUG dans RT correct FH le 17 sept 2002 + // dx [x,y] = [1,0] et non [1,1] + // dy [x,y] = [0,1] et non [1,1] + // ------------------------------------- + if (whatd[op_dx]) { + assert(val.K( ) > op_dx); + val(0, 0, op_dx) = a0; + val(1, 0, op_dx) = a1; + val(2, 0, op_dx) = a2; + } + if (whatd[op_dy]) { + assert(val.K( ) > op_dy); + val(0, 1, op_dy) = a0; + val(1, 1, op_dy) = a1; + val(2, 1, op_dy) = a2; + } } - // ---------------- - if( whatd[op_dx]) - { - val(0,0,1) = Va_x.x; - val(0,1,1) = Va_x.y; - - val(1,0,1) = Vb_x.x; - val(1,1,1) = Vb_x.y; - - val(2,0,1) = Vc_x.x; - val(2,1,1) = Vc_x.y; - } - - if( whatd[op_dy]) - { - val(0,0,2) = Va_y.x; - val(0,1,2) = Va_y.y; - - val(1,0,2) = Vb_y.x; - val(1,1,2) = Vb_y.y; - - val(2,0,2) = Vc_y.x; - val(2,1,2) = Vc_y.y; - } - -} - -void TypeOfFE_RTmodif::Pi_h_alpha(const baseFElement & K,KN_ & v) const -{ - const Triangle & T(K.T); - - for (int i=0,k=0;i<3;i++) - { - R2 E(T.Edge(i)); - R signe = &T[ (i+1)%3] < &T[ (i+2)%3] ? 1.0 : -1.0 ; - v[k++]= signe*E.y; - v[k++]=-signe*E.x; - } -} - - -// --------------------- -class TypeOfFE_P0 : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - - TypeOfFE_P0(): TypeOfFE(0,0,1,1,Data,1,1,1,1,Pi_h_coef){ - pij_alpha[0]=IPJ(0,0,0); - P_Pi_h[0]=R2(1./3.,1./3.); - } - void FB(const bool * watdd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - -}; - -// on what nu df on node node of df - int TypeOfFE_P0::Data[]={6, 0, 0, 0 , 0 ,0, 0, 1 }; -double TypeOfFE_P0::Pi_h_coef[]={1.0}; - - -void TypeOfFE_P0::FB(const bool* whatd,const Mesh & ,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // - // const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - //R l0=1-P.x-P.y,l1=P.x,l2=P.y; - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - throwassert(val.N() >=1); - throwassert(val.M()==1 ); - // throwassert(val.K()==3 ); - val=0; - if ( whatd[op_id]) - val(0,0,0) =1; -} - -// ------ P1 non conforme -------- -class TypeOfFE_P1ncLagrange : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P1ncLagrange(): TypeOfFE(0,1,0,1,Data,1,1,3,3,Pi_h_coef) + /* + void TypeOfFE_RT::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const { const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int i=0;i &v) const { + const Triangle &T(K.T); + + for (int i = 0, k = 0; i < 3; i++) { + R2 E(T.Edge(i)); + R signe = T.EdgeOrientation(i); + v[k++] = signe * E.y; + v[k++] = -signe * E.x; + } } + // ------------------- + + class TypeOfFE_RTmodif : public TypeOfFE { + public: + static int Data[]; + TypeOfFE_RTmodif( ) : TypeOfFE(0, 1, 0, 2, Data, 1, 1, 6, 3) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int p = 0, kk = 0; p < 3; p++) { + P_Pi_h[p] = Pt[p]; + for (int j = 0; j < 2; j++) pij_alpha[kk++] = IPJ(p, p, j); + } + } + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; + void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; + }; + // on what nu df on node node of df + int TypeOfFE_RTmodif::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 3, 3}; + + void TypeOfFE_RTmodif::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &PHat, RNMK_ &val) const { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]), C(K[2]); + R la = 1 - PHat.x - PHat.y, lb = PHat.x, lc = PHat.y; + R2 Dla(K.H(0)), Dlb(K.H(1)), Dlc(K.H(2)); + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 2); + + R2 AB(A, B), AC(A, C), BA(B, A), BC(B, C), CA(C, A), CB(C, B); + + R aa0 = 1. / (((AB, Dlb) + (AC, Dlc)) * K.area); + R aa1 = 1. / (((BA, Dla) + (BC, Dlc)) * K.area); + R aa2 = 1. / (((CA, Dla) + (CB, Dlb)) * K.area); + int i = 0; + R a0 = &K[(i + 1) % 3] < &K[(i + 2) % 3] ? aa0 : -aa0; + i = 1; + R a1 = &K[(i + 1) % 3] < &K[(i + 2) % 3] ? aa1 : -aa1; + i = 2; + R a2 = &K[(i + 1) % 3] < &K[(i + 2) % 3] ? aa2 : -aa2; + // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; + + R2 Va = AB * (lb * a0) + AC * (lc * a0); + R2 Vb = BA * (la * a1) + BC * (lc * a1); + R2 Vc = CA * (la * a2) + CB * (lb * a2); + R2 Va_x = AB * (Dlb.x * a0) + AC * (Dlc.x * a0); + R2 Vb_x = BA * (Dla.x * a1) + BC * (Dlc.x * a1); + R2 Vc_x = CA * (Dla.x * a2) + CB * (Dlb.x * a2); + R2 Va_y = AB * (Dlb.y * a0) + AC * (Dlc.y * a0); + R2 Vb_y = BA * (Dla.y * a1) + BC * (Dlc.y * a1); + R2 Vc_y = CA * (Dla.y * a2) + CB * (Dlb.y * a2); + + if (whatd[op_id]) { + RN_ f0(val('.', 0, 0)); + RN_ f1(val('.', 1, 0)); + + f0[0] = Va.x; + f1[0] = Va.y; + + f0[1] = Vb.x; + f1[1] = Vb.y; + + f0[2] = Vc.x; + f1[2] = Vc.y; + } + // ---------------- + if (whatd[op_dx]) { + val(0, 0, 1) = Va_x.x; + val(0, 1, 1) = Va_x.y; - void FB(const bool * whatd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + val(1, 0, 1) = Vb_x.x; + val(1, 1, 1) = Vb_x.y; -} ; - -// on what nu df on node node of df - int TypeOfFE_P1ncLagrange::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0, 0,3}; -double TypeOfFE_P1ncLagrange::Pi_h_coef[]={1.,1.,1.}; + val(2, 0, 1) = Vc_x.x; + val(2, 1, 1) = Vc_x.y; + } + if (whatd[op_dy]) { + val(0, 0, 2) = Va_y.x; + val(0, 1, 2) = Va_y.y; -class TypeOfFE_ConsEdge : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; + val(1, 0, 2) = Vb_y.x; + val(1, 1, 2) = Vb_y.y; - TypeOfFE_ConsEdge(): TypeOfFE(0,1,0,1,Data,3,1,3,3,Pi_h_coef) - { const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int i=0;i=3); - throwassert(val.M()==1 ); - - val=0; - if (whatd[op_id]) - { - - RN_ f0(val('.',0,0)); - // - f0[0] = double(l0 <= min(l1,l2) ); // arete - f0[1] = double(l1 <= min(l0,l2) ); - f0[2] = double(l2 <= min(l0,l1) ); + val(2, 0, 2) = Vc_y.x; + val(2, 1, 2) = Vc_y.y; + } } -} -/* -class TypeOfFE_P1Edge : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - - TypeOfFE_P1Edge(): TypeOfFE(0,2,0,1,Data,3,1,12,6,Pi_h_coef) - { R2 Pt[6] ; - - int kk=0; - for(int i=0;i<3;++i) - for(int j=0;i=0) - pij_alpha[kk++]= IPJ(i,other[i],0); - P_Pi_h[i]=Pt[i]; } - } - - void FB(const bool * whatd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - - } ; - // on what nu df on node node of df - int TypeOfFE_ConsEdge::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0, 0,3}; - double TypeOfFE_ConsEdge::Pi_h_coef[]={1.,1.,1.}; - void TypeOfFE_ConsEdge::FB(const bool * whatd,const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const - { - // const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - - if (val.N() <3) - throwassert(val.N() >=3); - throwassert(val.M()==1 ); - - val=0; - if (whatd[op_id]) - { - - RN_ f0(val('.',0,0)); - // - f0[0] = double(l0 <= min(l1,l2) ); // arete - f0[1] = double(l1 <= min(l0,l2) ); - f0[2] = double(l2 <= min(l0,l1) ); - } - + void TypeOfFE_RTmodif::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + const Triangle &T(K.T); + + for (int i = 0, k = 0; i < 3; i++) { + R2 E(T.Edge(i)); + R signe = &T[(i + 1) % 3] < &T[(i + 2) % 3] ? 1.0 : -1.0; + v[k++] = signe * E.y; + v[k++] = -signe * E.x; } - -*/ - -void TypeOfFE_P1ncLagrange::FB(const bool * whatd,const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const -{ - // const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - - throwassert(val.N() >=3); - throwassert(val.M()==1 ); - // throwassert(val.K()==3 ); - - val=0; - if (whatd[op_id]) - { - RN_ f0(val('.',0,0)); - f0[0] = 1-l0*2; - f0[1] = 1-l1*2; - f0[2] = 1-l2*2; } - if (whatd[op_dx] || whatd[op_dy] ) - { + + // --------------------- + class TypeOfFE_P0 : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + + TypeOfFE_P0( ) : TypeOfFE(0, 0, 1, 1, Data, 1, 1, 1, 1, Pi_h_coef) { + pij_alpha[0] = IPJ(0, 0, 0); + P_Pi_h[0] = R2(1. / 3., 1. / 3.); + } + void FB(const bool *watdd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + }; + + // on what nu df on node node of df + int TypeOfFE_P0::Data[] = {6, 0, 0, 0, 0, 0, 0, 1}; + double TypeOfFE_P0::Pi_h_coef[] = {1.0}; + + void TypeOfFE_P0::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &PHat, RNMK_ &val) const { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]), C(K[2]); + // R l0=1-P.x-P.y,l1=P.x,l2=P.y; R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - if (whatd[op_dx]) + throwassert(val.N( ) >= 1); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + val = 0; + if (whatd[op_id]) val(0, 0, 0) = 1; + } + + // ------ P1 non conforme -------- + class TypeOfFE_P1ncLagrange : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + TypeOfFE_P1ncLagrange( ) : TypeOfFE(0, 1, 0, 1, Data, 1, 1, 3, 3, Pi_h_coef) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + }; + + // on what nu df on node node of df + int TypeOfFE_P1ncLagrange::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 3}; + double TypeOfFE_P1ncLagrange::Pi_h_coef[] = {1., 1., 1.}; + + class TypeOfFE_ConsEdge : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + + TypeOfFE_ConsEdge( ) : TypeOfFE(0, 1, 0, 1, Data, 3, 1, 3, 3, Pi_h_coef) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + }; + // on what nu df on node node of df + int TypeOfFE_ConsEdge::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 3}; + double TypeOfFE_ConsEdge::Pi_h_coef[] = {1., 1., 1.}; + void TypeOfFE_ConsEdge::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + + val = 0; + if (whatd[op_id]) { + + RN_ f0(val('.', 0, 0)); + // + f0[0] = double(l0 <= min(l1, l2)); // arete + f0[1] = double(l1 <= min(l0, l2)); + f0[2] = double(l2 <= min(l0, l1)); + } + } + /* + class TypeOfFE_P1Edge : public TypeOfFE { public: + static int Data[]; + static double Pi_h_coef[]; + + TypeOfFE_P1Edge(): TypeOfFE(0,2,0,1,Data,3,1,12,6,Pi_h_coef) + { R2 Pt[6] ; + + int kk=0; + for(int i=0;i<3;++i) + for(int j=0;i=0) + pij_alpha[kk++]= IPJ(i,other[i],0); + P_Pi_h[i]=Pt[i]; } + } + + void FB(const bool * whatd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + + } ; + // on what nu df on node node of df + int TypeOfFE_ConsEdge::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0, 0,3}; + double TypeOfFE_ConsEdge::Pi_h_coef[]={1.,1.,1.}; + void TypeOfFE_ConsEdge::FB(const bool * whatd,const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = -Dl0.x*2; - f0x[1] = -Dl1.x*2; - f0x[2] = -Dl2.x*2; + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]),C(K[2]); + R l0=1-P.x-P.y,l1=P.x,l2=P.y; + + if (val.N() <3) + throwassert(val.N() >=3); + throwassert(val.M()==1 ); + + val=0; + if (whatd[op_id]) + { + + RN_ f0(val('.',0,0)); + // + f0[0] = double(l0 <= min(l1,l2) ); // arete + f0[1] = double(l1 <= min(l0,l2) ); + f0[2] = double(l2 <= min(l0,l1) ); + } + + } + + */ + + void TypeOfFE_P1ncLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + // l1( cshrink1*(cshrink*((1,0)-G)+G)-G)+G = 1 + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + if (whatd[op_id]) { + RN_ f0(val('.', 0, 0)); + f0[0] = 1 - l0 * 2; + f0[1] = 1 - l1 * 2; + f0[2] = 1 - l2 * 2; + } + if (whatd[op_dx] || whatd[op_dy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = -Dl0.x * 2; + f0x[1] = -Dl1.x * 2; + f0x[2] = -Dl2.x * 2; + } + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = -Dl0.y * 2; + f0y[1] = -Dl1.y * 2; + f0y[2] = -Dl2.y * 2; } - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = -Dl0.y*2; - f0y[1] = -Dl1.y*2; - f0y[2] = -Dl2.y*2; - } - } -} - -// The RT orthogonal FE - -class TypeOfFE_RTortho : public TypeOfFE { public: - static int Data[]; - TypeOfFE_RTortho(): TypeOfFE(0,1,0,2,Data,1,1,6,3) - {const R2 Pt[] = { R2(0.5,0.5), R2(0.0,0.5), R2(0.5,0.0) }; - for (int p=0,kk=0;p<3;p++) - { P_Pi_h[p]=Pt[p]; - for (int j=0;j<2;j++) - pij_alpha[kk++]= IPJ(p,p,j); - }} - - void FB(const bool * watdd, const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - void Pi_h_alpha(const baseFElement & K,KN_ & v) const ; -} ; -// on what nu df on node node of df - int TypeOfFE_RTortho::Data[]={3,4,5, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0,0, 0,0, 3,3}; - - - - void TypeOfFE_RTortho::FB(const bool *whatd,const Mesh & Th,const Triangle & K,const R2 & PHat,RNMK_ & val) const -{ // -// const Triangle & K(FE.T); - R2 P(K(PHat)); - R2 A(K[0]), B(K[1]),C(K[2]); - //R l0=1-P.x-P.y,l1=P.x,l2=P.y; - // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - throwassert(val.N() >=3); - throwassert(val.M()==2 ); -// throwassert(val.K()==3 ); - val=0; - R a=1./(2*K.area); - R a0= K.EdgeOrientation(0) * a ; - R a1= K.EdgeOrientation(1) * a ; - R a2= K.EdgeOrientation(2) * a ; - // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; - - // ------------ - if (whatd[op_id]) - { - assert(val.K()>op_id); - RN_ f0(val('.',0,0)); - RN_ f1(val('.',1,0)); - f1[0] = (P.x-A.x)*a0; - f0[0] = -(P.y-A.y)*a0; - - f1[1] = (P.x-B.x)*a1; - f0[1] = -(P.y-B.y)*a1; - - f1[2] = (P.x-C.x)*a2; - f0[2] = -(P.y-C.y)*a2; + } } - // ---------------- - if (whatd[op_dx]) - { - assert(val.K()>op_dx); - val(0,1,op_dx) = a0; - val(1,1,op_dx) = a1; - val(2,1,op_dx) = a2; - } - if (whatd[op_dy]) - { - assert(val.K()>op_dy); - val(0,0,op_dy) = -a0; - val(1,0,op_dy) = -a1; - val(2,0,op_dy) = -a2; + + // The RT orthogonal FE + + class TypeOfFE_RTortho : public TypeOfFE { + public: + static int Data[]; + TypeOfFE_RTortho( ) : TypeOfFE(0, 1, 0, 2, Data, 1, 1, 6, 3) { + const R2 Pt[] = {R2(0.5, 0.5), R2(0.0, 0.5), R2(0.5, 0.0)}; + for (int p = 0, kk = 0; p < 3; p++) { + P_Pi_h[p] = Pt[p]; + for (int j = 0; j < 2; j++) pij_alpha[kk++] = IPJ(p, p, j); + } + } + + void FB(const bool *watdd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const; + }; + // on what nu df on node node of df + int TypeOfFE_RTortho::Data[] = {3, 4, 5, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 3, 3}; + + void TypeOfFE_RTortho::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &PHat, RNMK_ &val) const { // + // const Triangle & K(FE.T); + R2 P(K(PHat)); + R2 A(K[0]), B(K[1]), C(K[2]); + // R l0=1-P.x-P.y,l1=P.x,l2=P.y; + // R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 2); + // throwassert(val.K()==3 ); + val = 0; + R a = 1. / (2 * K.area); + R a0 = K.EdgeOrientation(0) * a; + R a1 = K.EdgeOrientation(1) * a; + R a2 = K.EdgeOrientation(2) * a; + // if (Th(K)< 2) cout << Th(K) << " " << A << " " << B << " " << C << "; " << a0 << " " << a1 << " "<< a2 << endl;; + + // ------------ + if (whatd[op_id]) { + assert(val.K( ) > op_id); + RN_ f0(val('.', 0, 0)); + RN_ f1(val('.', 1, 0)); + f1[0] = (P.x - A.x) * a0; + f0[0] = -(P.y - A.y) * a0; + + f1[1] = (P.x - B.x) * a1; + f0[1] = -(P.y - B.y) * a1; + + f1[2] = (P.x - C.x) * a2; + f0[2] = -(P.y - C.y) * a2; + } + // ---------------- + if (whatd[op_dx]) { + assert(val.K( ) > op_dx); + val(0, 1, op_dx) = a0; + val(1, 1, op_dx) = a1; + val(2, 1, op_dx) = a2; + } + if (whatd[op_dy]) { + assert(val.K( ) > op_dy); + val(0, 0, op_dy) = -a0; + val(1, 0, op_dy) = -a1; + val(2, 0, op_dy) = -a2; + } + } + + void TypeOfFE_RTortho::Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + const Triangle &T(K.T); + + for (int i = 0, k = 0; i < 3; i++) { + R2 E(T.Edge(i)); + R signe = &T[(i + 1) % 3] < &T[(i + 2) % 3] ? 1.0 : -1.0; + v[k++] = signe * E.x; + v[k++] = signe * E.y; + } } -} - -void TypeOfFE_RTortho::Pi_h_alpha(const baseFElement & K,KN_ & v) const -{ - const Triangle & T(K.T); - - for (int i=0,k=0;i<3;i++) - { - R2 E(T.Edge(i)); - R signe = &T[ (i+1)%3] < &T[ (i+2)%3] ? 1.0 : -1.0 ; - v[k++]= signe*E.x; - v[k++]= signe*E.y; - } -} -// ------------------- -// ttdc finite element fully discontinue. -// ------------------- -class TypeOfFE_P1ttdc : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; + // ------------------- + // ttdc finite element fully discontinue. + // ------------------- + class TypeOfFE_P1ttdc : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; static const R2 G; static const R cshrink; static const R cshrink1; // (1 -1/3)* - - static R2 Shrink(const R2& P){ return (P-G)*cshrink+G;} - static R2 Shrink1(const R2& P){ return (P-G)*cshrink1+G;} - - TypeOfFE_P1ttdc(): TypeOfFE(0,0,3,1,Data,1,1,3,3,Pi_h_coef) - { const R2 Pt[] = { Shrink(R2(0,0)), Shrink(R2(1,0)), Shrink(R2(0,1)) }; - for (int i=0;i & u,int componante,int op) const ; - -} ; - const R2 TypeOfFE_P1ttdc::G(1./3.,1./3.); - const R TypeOfFE_P1ttdc::cshrink=1-1e-2; - const R TypeOfFE_P1ttdc::cshrink1=1./TypeOfFE_P1ttdc::cshrink; - -class TypeOfFE_P2ttdc : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; + } + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + }; + const R2 TypeOfFE_P1ttdc::G(1. / 3., 1. / 3.); + const R TypeOfFE_P1ttdc::cshrink = 1 - 1e-2; + const R TypeOfFE_P1ttdc::cshrink1 = 1. / TypeOfFE_P1ttdc::cshrink; + + class TypeOfFE_P2ttdc : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; static const R2 G; static const R cshrink; static const R cshrink1; - - static R2 Shrink(const R2& P){ return (P-G)*cshrink+G;} - static R2 Shrink1(const R2& P){ return (P-G)*cshrink1+G;} - - TypeOfFE_P2ttdc(): TypeOfFE(0,0,6,1,Data,3,1,6,6,Pi_h_coef) - { const R2 Pt[] = { Shrink(R2(0,0)), Shrink(R2(1,0)), Shrink(R2(0,1)), - Shrink(R2(0.5,0.5)),Shrink(R2(0,0.5)),Shrink(R2(0.5,0)) }; - for (int i=0;i & u,int componante,int op) const -{ - - R2 PHat=Shrink1(P1Hat); - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); - R r=0; - if (op==0) - { - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; - r = u0*l0+u1*l1+l2*u2; + + static R2 Shrink(const R2 &P) { return (P - G) * cshrink + G; } + static R2 Shrink1(const R2 &P) { return (P - G) * cshrink1 + G; } + + TypeOfFE_P2ttdc( ) : TypeOfFE(0, 0, 6, 1, Data, 3, 1, 6, 6, Pi_h_coef) { + const R2 Pt[] = {Shrink(R2(0, 0)), Shrink(R2(1, 0)), Shrink(R2(0, 1)), Shrink(R2(0.5, 0.5)), Shrink(R2(0, 0.5)), Shrink(R2(0.5, 0))}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } } - else - { - const Triangle & T=K.T; - R2 D0 = T.H(0)*cshrink1 , D1 = T.H(1)*cshrink1 , D2 = T.H(2)*cshrink1 ; - if (op==1) - r = D0.x*u0 + D1.x*u1 + D2.x*u2 ; - else - r = D0.y*u0 + D1.y*u1 + D2.y*u2 ; + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + }; + // on what nu df on node node of df + int TypeOfFE_P1ttdc::Data[] = {6, 6, 6, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 3}; + int TypeOfFE_P2ttdc::Data[] = {6, 6, 6, 6, 6, 6, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 6}; + double TypeOfFE_P1ttdc::Pi_h_coef[] = {1., 1., 1.}; + double TypeOfFE_P2ttdc::Pi_h_coef[] = {1., 1., 1., 1., 1., 1.}; + + const R2 TypeOfFE_P2ttdc::G(1. / 3., 1. / 3.); + const R TypeOfFE_P2ttdc::cshrink = 1 - 1e-2; + const R TypeOfFE_P2ttdc::cshrink1 = 1. / TypeOfFE_P2ttdc::cshrink; + + R TypeOfFE_P1ttdc::operator( )(const FElement &K, const R2 &P1Hat, const KN_< R > &u, int componante, int op) const { + + R2 PHat = Shrink1(P1Hat); + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); + R r = 0; + if (op == 0) { + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + r = u0 * l0 + u1 * l1 + l2 * u2; + } else { + const Triangle &T = K.T; + R2 D0 = T.H(0) * cshrink1, D1 = T.H(1) * cshrink1, D2 = T.H(2) * cshrink1; + if (op == 1) + r = D0.x * u0 + D1.x * u1 + D2.x * u2; + else + r = D0.y * u0 + D1.y * u1 + D2.y * u2; } - // cout << r << "\t"; - return r; -} - -void TypeOfFE_P1ttdc::FB(const bool *whatd,const Mesh & ,const Triangle & K,const R2 & P1,RNMK_ & val) const -{ - R2 P=Shrink1(P1); - - // const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - - throwassert(val.N() >=3); - throwassert(val.M()==1 ); - // throwassert(val.K()==3 ); - - val=0; - RN_ f0(val('.',0,op_id)); - - if (whatd[op_id]) - { - f0[0] = l0; - f0[1] = l1; - f0[2] = l2;} - if (whatd[op_dx] || whatd[op_dy]) - { - R2 Dl0(K.H(0)*cshrink1), Dl1(K.H(1)*cshrink1), Dl2(K.H(2)*cshrink1); - - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x; - f0x[1] = Dl1.x; - f0x[2] = Dl2.x; - } - - if (whatd[op_dy]) { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y; - f0y[1] = Dl1.y; - f0y[2] = Dl2.y; - } - } -} - - - - void TypeOfFE_P2ttdc::FB(const bool *whatd,const Mesh & ,const Triangle & K,const R2 & P1,RNMK_ & val) const -{ - R2 P=Shrink1(P1); - -// const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); - -// throwassert(FE.N == 1); - throwassert( val.N()>=6); - throwassert(val.M()==1); -// throwassert(val.K()==3 ); - - val=0; -// -- - if (whatd[op_id]) - { - RN_ f0(val('.',0,op_id)); - f0[0] = l0*(2*l0-1); - f0[1] = l1*(2*l1-1); - f0[2] = l2*(2*l2-1); - f0[3] = 4*l1*l2; // oppose au sommet 0 - f0[4] = 4*l0*l2; // oppose au sommet 1 - f0[5] = 4*l1*l0; // oppose au sommet 3 - } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)*cshrink1), Dl1(K.H(1)*cshrink1), Dl2(K.H(2)*cshrink1); - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x*l4_0; - f0x[1] = Dl1.x*l4_1; - f0x[2] = Dl2.x*l4_2; - f0x[3] = 4*(Dl1.x*l2 + Dl2.x*l1) ; - f0x[4] = 4*(Dl2.x*l0 + Dl0.x*l2) ; - f0x[5] = 4*(Dl0.x*l1 + Dl1.x*l0) ; + // cout << r << "\t"; + return r; } - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y*l4_0; - f0y[1] = Dl1.y*l4_1; - f0y[2] = Dl2.y*l4_2; - f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) ; - f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) ; - f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) ; - } - - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - - fxx[0] = 4*Dl0.x*Dl0.x; - fxx[1] = 4*Dl1.x*Dl1.x; - fxx[2] = 4*Dl2.x*Dl2.x; - fxx[3] = 8*Dl1.x*Dl2.x; - fxx[4] = 8*Dl0.x*Dl2.x; - fxx[5] = 8*Dl0.x*Dl1.x; - } + void TypeOfFE_P1ttdc::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P1, RNMK_ &val) const { + R2 P = Shrink1(P1); - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - fyy[0] = 4*Dl0.y*Dl0.y; - fyy[1] = 4*Dl1.y*Dl1.y; - fyy[2] = 4*Dl2.y*Dl2.y; - fyy[3] = 8*Dl1.y*Dl2.y; - fyy[4] = 8*Dl0.y*Dl2.y; - fyy[5] = 8*Dl0.y*Dl1.y; + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + RN_ f0(val('.', 0, op_id)); + + if (whatd[op_id]) { + f0[0] = l0; + f0[1] = l1; + f0[2] = l2; + } + if (whatd[op_dx] || whatd[op_dy]) { + R2 Dl0(K.H(0) * cshrink1), Dl1(K.H(1) * cshrink1), Dl2(K.H(2) * cshrink1); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x; + f0x[1] = Dl1.x; + f0x[2] = Dl2.x; + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y; + f0y[1] = Dl1.y; + f0y[2] = Dl2.y; + } + } } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - - fxy[0] = 4*Dl0.x*Dl0.y; - fxy[1] = 4*Dl1.x*Dl1.y; - fxy[2] = 4*Dl2.x*Dl2.y; - fxy[3] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x); - fxy[4] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x); - fxy[5] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x); + + void TypeOfFE_P2ttdc::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P1, RNMK_ &val) const { + R2 P = Shrink1(P1); + + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + R l4_0 = (4 * l0 - 1), l4_1 = (4 * l1 - 1), l4_2 = (4 * l2 - 1); + + // throwassert(FE.N == 1); + throwassert(val.N( ) >= 6); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + // -- + if (whatd[op_id]) { + RN_ f0(val('.', 0, op_id)); + f0[0] = l0 * (2 * l0 - 1); + f0[1] = l1 * (2 * l1 - 1); + f0[2] = l2 * (2 * l2 - 1); + f0[3] = 4 * l1 * l2; // oppose au sommet 0 + f0[4] = 4 * l0 * l2; // oppose au sommet 1 + f0[5] = 4 * l1 * l0; // oppose au sommet 3 + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0) * cshrink1), Dl1(K.H(1) * cshrink1), Dl2(K.H(2) * cshrink1); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x * l4_0; + f0x[1] = Dl1.x * l4_1; + f0x[2] = Dl2.x * l4_2; + f0x[3] = 4 * (Dl1.x * l2 + Dl2.x * l1); + f0x[4] = 4 * (Dl2.x * l0 + Dl0.x * l2); + f0x[5] = 4 * (Dl0.x * l1 + Dl1.x * l0); + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y * l4_0; + f0y[1] = Dl1.y * l4_1; + f0y[2] = Dl2.y * l4_2; + f0y[3] = 4 * (Dl1.y * l2 + Dl2.y * l1); + f0y[4] = 4 * (Dl2.y * l0 + Dl0.y * l2); + f0y[5] = 4 * (Dl0.y * l1 + Dl1.y * l0); + } + + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + + fxx[0] = 4 * Dl0.x * Dl0.x; + fxx[1] = 4 * Dl1.x * Dl1.x; + fxx[2] = 4 * Dl2.x * Dl2.x; + fxx[3] = 8 * Dl1.x * Dl2.x; + fxx[4] = 8 * Dl0.x * Dl2.x; + fxx[5] = 8 * Dl0.x * Dl1.x; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + fyy[0] = 4 * Dl0.y * Dl0.y; + fyy[1] = 4 * Dl1.y * Dl1.y; + fyy[2] = 4 * Dl2.y * Dl2.y; + fyy[3] = 8 * Dl1.y * Dl2.y; + fyy[4] = 8 * Dl0.y * Dl2.y; + fyy[5] = 8 * Dl0.y * Dl1.y; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + + fxy[0] = 4 * Dl0.x * Dl0.y; + fxy[1] = 4 * Dl1.x * Dl1.y; + fxy[2] = 4 * Dl2.x * Dl2.y; + fxy[3] = 4 * (Dl1.x * Dl2.y + Dl1.y * Dl2.x); + fxy[4] = 4 * (Dl0.x * Dl2.y + Dl0.y * Dl2.x); + fxy[5] = 4 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x); + } + } } - - } - -} - -// -// end ttdc -// ------------------ - -static TypeOfFE_RTortho The_TypeOfFE_RTortho; -static TypeOfFE_RT The_TypeOfFE_RT; -static TypeOfFE_P0 The_TypeOfFE_P0; -static TypeOfFE_P1ttdc The_TypeOfFE_P1ttdc; -static TypeOfFE_P2ttdc The_TypeOfFE_P2ttdc; -static TypeOfFE_RTmodif The_TypeOfFE_RTmodif; -static TypeOfFE_P1ncLagrange The_TypeOfFE_P1nc; -static TypeOfFE_ConsEdge The_TypeOfFE_ConsEdge; // add FH -TypeOfFE & RTLagrangeOrtho(The_TypeOfFE_RTortho); -TypeOfFE & RTLagrange(The_TypeOfFE_RT); -TypeOfFE & RTmodifLagrange(The_TypeOfFE_RTmodif); -TypeOfFE & P0Lagrange(The_TypeOfFE_P0); -TypeOfFE & P1ncLagrange(The_TypeOfFE_P1nc); -TypeOfFE & P1ttdc(The_TypeOfFE_P1ttdc); -TypeOfFE & P2ttdc(The_TypeOfFE_P2ttdc); -TypeOfFE & P0edge(The_TypeOfFE_ConsEdge); - -} + // + // end ttdc + // ------------------ + + static TypeOfFE_RTortho The_TypeOfFE_RTortho; + static TypeOfFE_RT The_TypeOfFE_RT; + static TypeOfFE_P0 The_TypeOfFE_P0; + static TypeOfFE_P1ttdc The_TypeOfFE_P1ttdc; + static TypeOfFE_P2ttdc The_TypeOfFE_P2ttdc; + static TypeOfFE_RTmodif The_TypeOfFE_RTmodif; + static TypeOfFE_P1ncLagrange The_TypeOfFE_P1nc; + static TypeOfFE_ConsEdge The_TypeOfFE_ConsEdge; // add FH + TypeOfFE &RTLagrangeOrtho(The_TypeOfFE_RTortho); + TypeOfFE &RTLagrange(The_TypeOfFE_RT); + TypeOfFE &RTmodifLagrange(The_TypeOfFE_RTmodif); + TypeOfFE &P0Lagrange(The_TypeOfFE_P0); + TypeOfFE &P1ncLagrange(The_TypeOfFE_P1nc); + TypeOfFE &P1ttdc(The_TypeOfFE_P1ttdc); + TypeOfFE &P2ttdc(The_TypeOfFE_P2ttdc); + TypeOfFE &P0edge(The_TypeOfFE_ConsEdge); + +} // namespace Fem2D diff --git a/src/femlib/FESpace-v0.cpp b/src/femlib/FESpace-v0.cpp index 87c11f76d..e2327f8fc 100644 --- a/src/femlib/FESpace-v0.cpp +++ b/src/femlib/FESpace-v0.cpp @@ -5,1322 +5,877 @@ #include #include #include "rgraph.hpp" -using namespace std; +using namespace std; #include "RNM.hpp" #include "fem.hpp" #include "FESpace.hpp" -namespace Fem2D { +namespace Fem2D { - int Make(const TypeOfFE ** t,int k,KN & P,KN & I) - { - typedef TypeOfFE::IPJ IPJ; + int Make(const TypeOfFE **t, int k, KN< R2 > &P, KN< int > &I) { + typedef TypeOfFE::IPJ IPJ; - int n=0,nn=0; + int n = 0, nn = 0; - for (int i=0;i p(t[i]->P_Pi_h); - for (int j=0;j ajout - I[nn]=n++; - for (int l=0;l detruit - break;} + for (int i = 0; i < k; i++) { + const KN< R2 > p(t[i]->P_Pi_h); + for (int j = 0; j < p.N( ); j++, nn++) { + P[n] = p[j]; // par defaut un nouveau => ajout + I[nn] = n++; + for (int l = 0; l < n - 1; l++) { + R2 QP(p[j], P[l]); + if ((QP, QP) < 1.0e-12) { + I[nn] = l; + n--; // on a retrouver => detruit + break; + } } - - } + } } - return n; // nombre de point commun - } - - KN Makepij_alpha(const TypeOfFE ** t,int k) - { - // Attention les df est numerote de facon croissant - // en faisant une boucle sur les TypeOfFE - // comme dans la class TypeOfFESum - typedef TypeOfFE::IPJ IPJ; - int n=0,m=0; - for (int i=0;i< k;i++) { - n += t[i]->pij_alpha.N(); - m += t[i]->P_Pi_h.N(); + return n; // nombre de point commun + } + + KN< TypeOfFE::IPJ > Makepij_alpha(const TypeOfFE **t, int k) { + // Attention les df est numerote de facon croissant + // en faisant une boucle sur les TypeOfFE + // comme dans la class TypeOfFESum + typedef TypeOfFE::IPJ IPJ; + int n = 0, m = 0; + for (int i = 0; i < k; i++) { + n += t[i]->pij_alpha.N( ); + m += t[i]->P_Pi_h.N( ); } - KN ij(n); - KN I(m); - KN P(m); - Make(t,k,P,I); - int p0=0,i0=0,N0=0,nn=0; - for (int i=0;i< k;i++) { - const KN p(t[i]->pij_alpha); - for (int j=0;j ij(n); + KN< int > I(m); + KN< R2 > P(m); + Make(t, k, P, I); + int p0 = 0, i0 = 0, N0 = 0, nn = 0; + for (int i = 0; i < k; i++) { + const KN< IPJ > p(t[i]->pij_alpha); + for (int j = 0; j < p.N( ); j++, nn++) { + ij[nn].i = p[j].i + i0; // comme dans TypeOfFESum + ij[nn].j = N0 + p[j].j; + ij[nn].p = I[p[j].p + p0]; + + // cout << nn << "Makepij_alpha: " << ij[nn].i << " " << ij[nn].p << " " << ij[nn].j << endl; } - i0+=t[i]->NbDoF; - p0+=t[i]->P_Pi_h.N(); - N0+=t[i]->N;} - return ij; - } - KN MakeP_Pi_h(const TypeOfFE **t,int k) - { - int np=0; - for (int i=0;i< k;i++) - np += t[i]->P_Pi_h.N(); - - KN< R2 > yy(np); - KN zz(np); - int kk=Make(t,k,yy,zz); - // cout << " MakeP_Pi_h: " << kk << " from " << np << endl; - return yy(SubArray(kk)); - - } - -ListOfTFE * ListOfTFE::all ; // list of all object of this type - -ListOfTFE::ListOfTFE (const char * n,TypeOfFE *t) : name(n),tfe(t) -{ - if(!t) - assert(t); - static int count=0; - if (count++==0) - all=0; // init of all in dependant of the ordre of the objet file - next=all; - all=this; -} - -const TypeOfFE ** Make(const FESpace **l,int k) { - const TypeOfFE** p=new const TypeOfFE*[k]; - for (int i=0;iTFE[0]; - return p; -} -const TypeOfFE ** Make(const TypeOfFE **l,int k) { - const TypeOfFE** p=new const TypeOfFE*[k]; - for (int i=0;i Aipj(ipj.N()); - KNM Vp(N,PtHat.N()); - - Pi_h(Aipj); - for (int p=0;p Vpp(Vp('.',p)); - for (int j=0;j & v) const - { - for (int i=0,k0=0;iNbDoF; - KN_ sv(v(SubArray(n,k0))); - teb[i]->Pi_h_alpha(K,sv); - k0+= n;} + i0 += t[i]->NbDoF; + p0 += t[i]->P_Pi_h.N( ); + N0 += t[i]->N; } - ~TypeOfFESum(){ delete [] teb;} -} ; - -class FEProduitConstruct { protected: - const TypeOfFE & teb; - int k; - int * data; - FEProduitConstruct(int kk,const TypeOfFE &t) ; - ~FEProduitConstruct(){delete [] data;} -}; - -class TypeOfFEProduit: protected FEProduitConstruct, public TypeOfFE { public: - TypeOfFEProduit(int kk,const TypeOfFE &t): - FEProduitConstruct(kk,t),TypeOfFE(t,kk,data) {} - - // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; - void FB(const bool * whatd,const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; -// void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; -// void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void * arg ) const; - virtual void Pi_h_alpha(const baseFElement & K,KN_ & v) const - { int nbof=teb.NbDoF; - for (int i=0,k0=0;i sv(v(SubArray(nbof,k0))); - teb.Pi_h_alpha(K,sv); - } + return ij; + } + KN< R2 > MakeP_Pi_h(const TypeOfFE **t, int k) { + int np = 0; + for (int i = 0; i < k; i++) np += t[i]->P_Pi_h.N( ); + + KN< R2 > yy(np); + KN< int > zz(np); + int kk = Make(t, k, yy, zz); + // cout << " MakeP_Pi_h: " << kk << " from " << np << endl; + return yy(SubArray(kk)); + } + + ListOfTFE *ListOfTFE::all; // list of all object of this type + + ListOfTFE::ListOfTFE(const char *n, TypeOfFE *t) : name(n), tfe(t) { + if (!t) assert(t); + static int count = 0; + if (count++ == 0) all = 0; // init of all in dependant of the ordre of the objet file + next = all; + all = this; + } + + const TypeOfFE **Make(const FESpace **l, int k) { + const TypeOfFE **p = new const TypeOfFE *[k]; + for (int i = 0; i < k; i++) p[i] = l[i]->TFE[0]; + return p; + } + const TypeOfFE **Make(const TypeOfFE **l, int k) { + const TypeOfFE **p = new const TypeOfFE *[k]; + for (int i = 0; i < k; i++) p[i] = l[i]; + return p; + } + + bool Same(const FESpace **l, int k) { + for (int i = 1; i < k; i++) + if (l[0] != l[i]) return false; + return true; + } + + class FESumConstruct { + protected: + const TypeOfFE **teb; + const int k; + int nbn; // nb of node + int *data; + int *const NN; // NN[ i:i+1[ dimension de l'element i + int *const DF; // DF[i:i+1[ df associe a l'element i + int *const comp; // + FESumConstruct(int kk, const TypeOfFE **t); + virtual ~FESumConstruct( ) { + delete[] DF; + delete[] NN; + delete[] comp; + delete[] data; } - - ~TypeOfFEProduit(){} -} ; - -FEProduitConstruct::FEProduitConstruct(int kk,const TypeOfFE &t) - :k(kk),teb(t) -{ - int m= teb.NbDoF; - KN nn(teb.NbNode); - nn=0; // nb de dl par noeud - for (int i=0;i m; - int i=k,j; - while(i--) // on va a l'envert pour avoir comp[i] <=i - m[teb[i]]=i; - // l'ordre comp est important comp est croissant mais pas de pb. - i=k; - while(i--) - comp[i]=m[teb[i]]; // comp[i] <=i - - // reservatition des intervalles en espaces - int n=0,N=0; - for ( j=0;jN;} - NN[kk] = N; - // reservation des interval en df - n=0; - for ( j=0;jNbDoF;} - DF[kk] = n; -// n = nb de DF total -// N the fem is in R^N - - data = new int [n*5 + N]; - int c=0; - int ki= 0; -// recherche des noeuds - KN w(7),nn(7); - w=0; - nn=0; - - - for ( j=0;jNbDoF;i++) - nn[teb[j]->DFOnWhat[i]]++; - nbn=0; - for( j=0;j<7;j++) - if (nn[j]) nn[j]=nbn++; - else nn[j]=-1; - KN dln(7); - dln=0; - // nn donne numero de noeud sur what - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOnWhat[i]; - - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOfNode[i]+dln[teb[j]->DFOnWhat[i]]; - for ( i=0;iNbDoF;i++) - dln[teb[j]->DFOnWhat[i]]=Max(dln[teb[j]->DFOnWhat[i]],data[cc++]+1); + }; + + void FElement::Pi_h(RN_ val, InterpolFunction f, R *v, void *arg = 0) const { + // routine: a tester FH. + FElement::aIPJ ipj(Pi_h_ipj( )); + FElement::aR2 PtHat(Pi_h_R2( )); + KN< R > Aipj(ipj.N( )); + KNM< R > Vp(N, PtHat.N( )); + + Pi_h(Aipj); + for (int p = 0; p < PtHat.N( ); p++) { + f(v, T(PtHat[p]), *this, T.lab, PtHat[p], arg); + KN_< double > Vpp(Vp('.', p)); + for (int j = 0; j < N; j++) Vpp[j] = v[j]; } - - - for ( j=0;jNbDoF;i++) - data[c++] = nn[teb[j]->DFOnWhat[i]]; + + for (int i = 0; i < Aipj.N( ); i++) { + const FElement::IPJ &ipj_i(ipj[i]); + val[ipj_i.i] += Aipj[i] * Vp(ipj_i.j, ipj_i.p); } - - for ( j=0;jNbDoF;i++) - data[c++] = j; // node from of FE - - - for ( j=0;jNbDoF;i++) - data[c++] = i; // node from of df in FE - - int xx=0; - for (j=0;jN;i++) - { - data[c] = teb[j]->dim_which_sub_fem[i]+xx; - xxx=Max(xxx,data[c]+1); - c++; - } - xx=xxx; - } - - throwassert(c== 5*n+N); -/* int cc=0; - cout << " Data : " << endl; - for ( i=0;i<5;i++) { - for (j=0;j & u,int componante,int op) const ; - -} ; - -/////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// NEW //////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -class TypeOfFE_P1Bubble : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P1Bubble(): TypeOfFE(1,0,1,1,Data,1,1,4,4,Pi_h_coef) - { const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1), R2(1./3.,1./3.) }; - for (int i=0;i & u,int componante,int op) const ; - -} ; -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -class TypeOfFE_P2Lagrange : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - - TypeOfFE_P2Lagrange(): TypeOfFE(1,1,0,1,Data,3,1,6,6,Pi_h_coef) - { const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1),R2(0.5,0.5),R2(0,0.5),R2(0.5,0) }; - for (int i=0;icounter), - MaxNbNodePerElement(t->MaxNbNodePerElement), - MaxNbDFPerElement(t->MaxNbDFPerElement*k), - NodesOfElement(t->NodesOfElement), - FirstNodeOfElement(t->FirstNodeOfElement), - FirstDfOfNode(0), - NbOfElements(t->NbOfElements), - NbOfDF(t->NbOfDF*k), - NbOfNode(t->NbOfNode), - Nproduit(t->Nproduit*k) - { - throwassert(t==0 || t->FirstDfOfNode==0); - *counter++; - } - -ConstructDataFElement::ConstructDataFElement (const Mesh &Th,int NbDfOnSommet,int ndfonEdge,int ndfonFace,const TypeOfMortar *tm, -int nbdfv,const int *ndfv,int nbdfe,const int *ndfe) -: counter(&thecounter),thecounter(0) -{ - Make(Th,NbDfOnSommet,ndfonEdge,ndfonFace, tm,nbdfv,ndfv,nbdfe,ndfe); -} - -ConstructDataFElement::ConstructDataFElement(const FESpace ** l,int k) -: thecounter(0),counter(&thecounter) -{ - int NbDfOnSommet=0; - int ndfonEdge=0; - int ndfonFace=0; - const Mesh & Th(l[0]->Th); - for (int i=0;iTFE[0]->ndfonVertex; - ndfonEdge += l[i]->TFE[0]->ndfonEdge; - ndfonFace += l[i]->TFE[0]->ndfonFace; - throwassert( &Th== &l[i]->Th); - throwassert( l[i]->TFE.constant()); - } - - Make(Th,NbDfOnSommet,ndfonEdge,ndfonFace,0); -} - - -void ConstructDataFElement::Make(const Mesh &Th,int NbDfOnSommet,int ndfonEdge,int ndfonFace,const TypeOfMortar *tm, -int nb_dfv,const int *ndfv,int nb_dfe,const int *ndfe) -{ - *counter=0; - Nproduit =1; - int ndf=0,samendf=1; - - int nbdfe=3*NbDfOnSommet+3*ndfonEdge+ndfonFace; - int nbne = 0; - int nn=0; - int firstmul=0; - throwassert( tm || Th.NbMortars==0); - NbOfElements = Th.nt; // by default - // if mortars - // - int NbOfNodeL=0; - NbOfElements += Th.NbMortars; - FirstDfOfNode =0; - FirstNodeOfElement=0; - MaxNbDFPerElement=3*NbDfOnSommet+3*ndfonEdge+ndfonFace; - - int ks=0,ke=0,kt=0; - if(NbDfOnSommet) { nbne+=3; - ks=1; - ndf=NbDfOnSommet;} - - if(ndfonEdge) { nbne+=3; - ke=1; - samendf &= !ndf || ndf == ndfonEdge; - ndf=ndfonEdge;} - - if(ndfonFace) { nbne+=1; - kt=1; - samendf &= !ndf || ndf == ndfonFace; - ndf=ndfonFace;} - - int NbDFonNode[7],NodeIsOn[7]; - { - int j=0,k=0; - if(ks) { NbDFonNode[j++]=NbDfOnSommet; NbDFonNode[j++]=NbDfOnSommet; NbDFonNode[j++]=NbDfOnSommet;} - if(ke) { NbDFonNode[j++]=ndfonEdge; NbDFonNode[j++]=ndfonEdge; NbDFonNode[j++]=ndfonEdge;} - if(kt) { NbDFonNode[j++]=ndfonFace;} - - if (ks) {NodeIsOn[k++]=0;NodeIsOn[k++]=1;NodeIsOn[k++]=2;} - if (ke) {NodeIsOn[k++]=3;NodeIsOn[k++]=4;NodeIsOn[k++]=5;} - if (kt) {NodeIsOn[k++]=6;} - - throwassert(j == nbne); + + class TypeOfFESum : public FESumConstruct, public TypeOfFE { + public: + TypeOfFESum(const FESpace **t, int kk) : FESumConstruct(kk, Make(t, kk)), TypeOfFE(teb, kk, data) {} + TypeOfFESum(const TypeOfFE **t, int kk) : FESumConstruct(kk, Make(t, kk)), TypeOfFE(teb, kk, data) {} + + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void * arg ) const; + virtual void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + for (int i = 0, k0 = 0; i < k; i++) { + int n = teb[i]->NbDoF; + KN_< R > sv(v(SubArray(n, k0))); + teb[i]->Pi_h_alpha(K, sv); + k0 += n; + } + } + ~TypeOfFESum( ) { delete[] teb; } + }; + + class FEProduitConstruct { + protected: + const TypeOfFE &teb; + int k; + int *data; + FEProduitConstruct(int kk, const TypeOfFE &t); + ~FEProduitConstruct( ) { delete[] data; } + }; + + class TypeOfFEProduit : protected FEProduitConstruct, public TypeOfFE { + public: + TypeOfFEProduit(int kk, const TypeOfFE &t) : FEProduitConstruct(kk, t), TypeOfFE(t, kk, data) {} + + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void * arg ) const; + virtual void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + int nbof = teb.NbDoF; + for (int i = 0, k0 = 0; i < k; i++, k0 += nbof) { + KN_< R > sv(v(SubArray(nbof, k0))); + teb.Pi_h_alpha(K, sv); + } + } + + ~TypeOfFEProduit( ) {} + }; + + FEProduitConstruct::FEProduitConstruct(int kk, const TypeOfFE &t) : k(kk), teb(t) { + int m = teb.NbDoF; + KN< int > nn(teb.NbNode); + nn = 0; // nb de dl par noeud + for (int i = 0; i < m; i++) nn[teb.NodeOfDF[i]]++; + + int n = m * kk; + int N = teb.N * kk; + data = new int[n * 5 + N]; + int c = 0; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = teb.DFOnWhat[i]; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) // num of df on node for the df = j + data[c++] = teb.DFOfNode[i] + j * nn[teb.NodeOfDF[i]]; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = teb.NodeOfDF[i]; // node of df + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = j; // node from of FE + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = i; // node from of df in FE + + for (int j = 0; j < kk; j++) + for (int i = 0; i < teb.N; i++) data[c++] = teb.dim_which_sub_fem[i] + teb.nb_sub_fem * j; } - - MaxNbNodePerElement=nbne; -// - if ( ks && (!ke && ! kt) && (ndfv==0 && ndfe==0)) - {nn=Th.nv; - NodesOfElement=0; + FESumConstruct::FESumConstruct(int kk, const TypeOfFE **t) : k(kk), teb(t), NN(new int[kk + 1]), DF(new int[kk + 1]), comp(new int[kk]) { + map< const TypeOfFE *, int > m; + int i = k, j; + while (i--) // on va a l'envert pour avoir comp[i] <=i + m[teb[i]] = i; + // l'ordre comp est important comp est croissant mais pas de pb. + i = k; + while (i--) comp[i] = m[teb[i]]; // comp[i] <=i + + // reservatition des intervalles en espaces + int n = 0, N = 0; + for (j = 0; j < kk; j++) { + NN[j] = N; + N += teb[j]->N; + } + NN[kk] = N; + // reservation des interval en df + n = 0; + for (j = 0; j < kk; j++) { + DF[j] = n; + n += teb[j]->NbDoF; + } + DF[kk] = n; + // n = nb de DF total + // N the fem is in R^N + + data = new int[n * 5 + N]; + int c = 0; + int ki = 0; + // recherche des noeuds + KN< int > w(7), nn(7); + w = 0; + nn = 0; + + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) nn[teb[j]->DFOnWhat[i]]++; + nbn = 0; + for (j = 0; j < 7; j++) + if (nn[j]) + nn[j] = nbn++; + else + nn[j] = -1; + KN< int > dln(7); + dln = 0; + // nn donne numero de noeud sur what + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOnWhat[i]; + + for (j = 0; j < kk; j++) { + int cc = c; + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOfNode[i] + dln[teb[j]->DFOnWhat[i]]; + for (i = 0; i < teb[j]->NbDoF; i++) dln[teb[j]->DFOnWhat[i]] = Max(dln[teb[j]->DFOnWhat[i]], data[cc++] + 1); + } + + for (j = 0; j < kk; j++) { + // w renumerotation des noeuds + // Ok si un noeud par what + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = nn[teb[j]->DFOnWhat[i]]; + } + + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = j; // node from of FE + + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = i; // node from of df in FE + + int xx = 0; + for (j = 0; j < kk; j++) { + int xxx = xx; + for (i = 0; i < teb[j]->N; i++) { + data[c] = teb[j]->dim_which_sub_fem[i] + xx; + xxx = Max(xxx, data[c] + 1); + c++; } - else { -// constuction du tableau NodesOfElement bofbof + xx = xxx; + } -// computation of the length lne of array NodesOfElement - int lne= Th.nt*nbne; - if (Th.NbMortars) - { - samendf= false; - NbOfNodeL=Th.NbMortars; - throwassert(tm); - FirstNodeOfElement = new int[NbOfElements+1]; - int k=0,kk=0; - for (k=0;kNbOfNodes(Th,Th.mortars[im]); - } - FirstNodeOfElement[k++]=lne; - } - - NodesOfElement = new int[lne]; - - for (int i=0;i=0 && jj>=0) - NodesOfElement[kk*nbne+oe+jj] = nn + ndfe[be] ; // adj - NodesOfElement[k*nbne+oe+j] = nn + ndfe[be] ; // new - } - nn += nb_dfe; - } - for (int k=0;kConstructionOfNode(Th,im,NodesOfElement,FirstNodeOfElement,nn); - Mortar & M(Th.mortars[im]); - NodesOfElement[i++] = nn++; // the first node is the lag. mul. - int n=M.NbT(); - for (int kk=0;kkNbLagrangeMult(Th,Th.mortars[km]); // On node par - int nodemul = NodesOfElement[fk]; // the first node is the lagr. mul. - throwassert(FirstDfOfNode[nodemul+1]==-1); - FirstDfOfNode[nodemul+1]= ndlmul; - NbOfDFL += ndlmul; - int nbdle=0; - int nbnm=lk-fk; - for (int j=fk;jnb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - Th(TTh), - NbOfDF(cdef->NbOfDF), - NbOfElements(cdef->NbOfElements), - NbOfNodes(cdef->NbOfNode), - MaxNbNodePerElement(cdef->MaxNbNodePerElement), - MaxNbDFPerElement(cdef->MaxNbDFPerElement), - NodesOfElement(cdef->NodesOfElement), - FirstDfOfNodeData(cdef->FirstDfOfNode), - FirstNodeOfElement(cdef->FirstNodeOfElement), - tom(&tm) { - // cout << "avant renum ="<< *this <D2_FB(Th,K,P,v); - else - v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); - } } -*/ -/* - void TypeOfFESum::FB(const Mesh & Th,const Triangle & K,const R2 & P,RNMK_ & val) const - { - val=0.0; - SubArray t(3); - for (int i=0;iFB(Th,K,P,v); - else - v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + }; + + /////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////// NEW //////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// + + class TypeOfFE_P1Bubble : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + TypeOfFE_P1Bubble( ) : TypeOfFE(1, 0, 1, 1, Data, 1, 1, 4, 4, Pi_h_coef) { + const R2 Pt[] = {R2(0, 0), R2(1, 0), R2(0, 1), R2(1. / 3., 1. / 3.)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } } - } -*/ - void TypeOfFESum::FB(const bool * whatd,const Mesh & Th,const Triangle & K,const R2 & P,RNMK_ & val) const - { - val=0.0; - SubArray t(val.K()); - for (int i=0;iFB(whatd,Th,K,P,v); - else - v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; + // virtual R operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const ; + }; + /////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// + + class TypeOfFE_P2Lagrange : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + + TypeOfFE_P2Lagrange( ) : TypeOfFE(1, 1, 0, 1, Data, 3, 1, 6, 6, Pi_h_coef) { + const R2 Pt[] = {R2(0, 0), R2(1, 0), R2(0, 1), R2(0.5, 0.5), R2(0, 0.5), R2(0.5, 0)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + + // void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const; + // void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const; + // void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const; + }; + + int TypeOfFE_P1Lagrange::Data[] = {0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0}; + int TypeOfFE_P1Bubble::Data[] = {0, 1, 2, 6, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0}; + int TypeOfFE_P2Lagrange::Data[] = {0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0}; + double TypeOfFE_P1Lagrange::Pi_h_coef[] = {1., 1., 1.}; + double TypeOfFE_P1Bubble::Pi_h_coef[] = {1., 1., 1., 1.}; + double TypeOfFE_P2Lagrange::Pi_h_coef[] = {1., 1., 1., 1., 1., 1.}; + + inline void dump(char *m, int n, int *p) { + cout << m; + for (int i = 0; i < n; i++) cout << " " << p[i]; + cout << endl; + } + + ConstructDataFElement::~ConstructDataFElement( ) { + if (*counter == 0) { + delete[] NodesOfElement; + delete[] FirstNodeOfElement; + delete[] FirstDfOfNode; + } else + counter--; + } + + ConstructDataFElement::ConstructDataFElement(const ConstructDataFElement *t, int k) + : thecounter(0), counter(t->counter), MaxNbNodePerElement(t->MaxNbNodePerElement), MaxNbDFPerElement(t->MaxNbDFPerElement * k), NodesOfElement(t->NodesOfElement), + FirstNodeOfElement(t->FirstNodeOfElement), FirstDfOfNode(0), NbOfElements(t->NbOfElements), NbOfDF(t->NbOfDF * k), NbOfNode(t->NbOfNode), Nproduit(t->Nproduit * k) { + throwassert(t == 0 || t->FirstDfOfNode == 0); + *counter++; + } + + ConstructDataFElement::ConstructDataFElement(const Mesh &Th, int NbDfOnSommet, int ndfonEdge, int ndfonFace, const TypeOfMortar *tm, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : counter(&thecounter), thecounter(0) { + Make(Th, NbDfOnSommet, ndfonEdge, ndfonFace, tm, nbdfv, ndfv, nbdfe, ndfe); + } + + ConstructDataFElement::ConstructDataFElement(const FESpace **l, int k) : thecounter(0), counter(&thecounter) { + int NbDfOnSommet = 0; + int ndfonEdge = 0; + int ndfonFace = 0; + const Mesh &Th(l[0]->Th); + for (int i = 0; i < k; i++) { + NbDfOnSommet += l[i]->TFE[0]->ndfonVertex; + ndfonEdge += l[i]->TFE[0]->ndfonEdge; + ndfonFace += l[i]->TFE[0]->ndfonFace; + throwassert(&Th == &l[i]->Th); + throwassert(l[i]->TFE.constant( )); + } + + Make(Th, NbDfOnSommet, ndfonEdge, ndfonFace, 0); + } + + void ConstructDataFElement::Make(const Mesh &Th, int NbDfOnSommet, int ndfonEdge, int ndfonFace, const TypeOfMortar *tm, int nb_dfv, const int *ndfv, int nb_dfe, const int *ndfe) { + *counter = 0; + Nproduit = 1; + int ndf = 0, samendf = 1; + + int nbdfe = 3 * NbDfOnSommet + 3 * ndfonEdge + ndfonFace; + int nbne = 0; + int nn = 0; + int firstmul = 0; + throwassert(tm || Th.NbMortars == 0); + NbOfElements = Th.nt; // by default + // if mortars + // + int NbOfNodeL = 0; + NbOfElements += Th.NbMortars; + FirstDfOfNode = 0; + FirstNodeOfElement = 0; + MaxNbDFPerElement = 3 * NbDfOnSommet + 3 * ndfonEdge + ndfonFace; + + int ks = 0, ke = 0, kt = 0; + if (NbDfOnSommet) { + nbne += 3; + ks = 1; + ndf = NbDfOnSommet; + } + + if (ndfonEdge) { + nbne += 3; + ke = 1; + samendf &= !ndf || ndf == ndfonEdge; + ndf = ndfonEdge; } - } -/* - void TypeOfFESum::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int jjj, void * arg) const - { - for(int i=0;iPi_h(KK,vv,f,v,jjj+NN[i],arg); - } - // cout << val(SubArray(NbDoF)) << endl; - - } - /* - void TypeOfFE_P1Lagrange::D2_FB(const Mesh & ,const Triangle & ,const R2 & ,RNMK_ & val) const -{ // - val=0; -} -*/ -/* - void TypeOfFE_P2Lagrange::D2_FB(const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const -{ // 2 times derivatives for error indicator -// const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); - - throwassert(val.N() >=6); - throwassert(val.M()==1 ); - throwassert(val.K()==3 ); - - val=0; - RN_ fxx(val('.',0,0)); - RN_ fxy(val('.',0,1)); - RN_ fyy(val('.',0,2)); - - fxx[0] = 4*Dl0.x*Dl0.x; - fxx[1] = 4*Dl1.x*Dl1.x; - fxx[2] = 4*Dl2.x*Dl2.x; - fxx[3] = 8*Dl1.x*Dl2.x; - fxx[4] = 8*Dl0.x*Dl2.x; - fxx[5] = 8*Dl0.x*Dl1.x; - - fyy[0] = 4*Dl0.y*Dl0.y; - fyy[1] = 4*Dl1.y*Dl1.y; - fyy[2] = 4*Dl2.y*Dl2.y; - fyy[3] = 8*Dl1.y*Dl2.y; - fyy[4] = 8*Dl0.y*Dl2.y; - fyy[5] = 8*Dl0.y*Dl1.y; - - fxy[0] = 4*Dl0.y*Dl0.y; - fxy[1] = 4*Dl1.y*Dl1.y; - fxy[2] = 4*Dl2.y*Dl2.y; - fxy[3] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x); - fxy[4] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x); - fxy[5] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x); - -} -*/ - R TypeOfFE_P1Lagrange::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const -{ - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); - R r=0; - if (op==0) + + if (ndfonFace) { + nbne += 1; + kt = 1; + samendf &= !ndf || ndf == ndfonFace; + ndf = ndfonFace; + } + + int NbDFonNode[7], NodeIsOn[7]; { - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; - r = u0*l0+u1*l1+l2*u2; + int j = 0, k = 0; + if (ks) { + NbDFonNode[j++] = NbDfOnSommet; + NbDFonNode[j++] = NbDfOnSommet; + NbDFonNode[j++] = NbDfOnSommet; + } + if (ke) { + NbDFonNode[j++] = ndfonEdge; + NbDFonNode[j++] = ndfonEdge; + NbDFonNode[j++] = ndfonEdge; + } + if (kt) { + NbDFonNode[j++] = ndfonFace; + } + + if (ks) { + NodeIsOn[k++] = 0; + NodeIsOn[k++] = 1; + NodeIsOn[k++] = 2; + } + if (ke) { + NodeIsOn[k++] = 3; + NodeIsOn[k++] = 4; + NodeIsOn[k++] = 5; + } + if (kt) { + NodeIsOn[k++] = 6; + } + + throwassert(j == nbne); } - else - { - const Triangle & T=K.T; - R2 D0 = T.H(0) , D1 = T.H(1) , D2 = T.H(2) ; - if (op==1) - r = D0.x*u0 + D1.x*u1 + D2.x*u2 ; - else - r = D0.y*u0 + D1.y*u1 + D2.y*u2 ; + + MaxNbNodePerElement = nbne; + + // + if (ks && (!ke && !kt) && (ndfv == 0 && ndfe == 0)) { + nn = Th.nv; + NodesOfElement = 0; + } else { + // constuction du tableau NodesOfElement bofbof + + // computation of the length lne of array NodesOfElement + int lne = Th.nt * nbne; + if (Th.NbMortars) { + samendf = false; + NbOfNodeL = Th.NbMortars; + throwassert(tm); + FirstNodeOfElement = new int[NbOfElements + 1]; + int k = 0, kk = 0; + for (k = 0; k < Th.nt; k++, kk += nbne) FirstNodeOfElement[k] = kk; + + for (int im = 0; im < Th.NbMortars; im++) // (www) code + { + FirstNodeOfElement[k++] = lne; + lne += tm->NbOfNodes(Th, Th.mortars[im]); + } + FirstNodeOfElement[k++] = lne; + } + + NodesOfElement = new int[lne]; + + for (int i = 0; i < lne; i++) NodesOfElement[i] = -1; + int i = 0; + int oe = 0; + if (ks) { + oe = 3; + nn = ndfv ? nb_dfv : Th.nv; + } + + if (ke && ndfe) { + for (int be = 0; be < Th.neb; be++) { + int j, k = Th.BoundaryElement(be, j); + int jj = j; + int kk = Th.ElementAdj(k, jj); + if (kk >= 0 && jj >= 0) NodesOfElement[kk * nbne + oe + jj] = nn + ndfe[be]; // adj + NodesOfElement[k * nbne + oe + j] = nn + ndfe[be]; // new + } + nn += nb_dfe; + } + for (int k = 0; k < Th.nt; k++) { + int iold = i; + if (ks) { + for (int j = 0; j < 3; j++) NodesOfElement[i++] = ndfv ? ndfv[Th(k, j)] : Th(k, j); + } + if (ke) { + for (int j = 0; j < 3; j++) + if (NodesOfElement[i] < 0) { + int jj = j; + int kk = Th.ElementAdj(k, jj); + + NodesOfElement[kk * nbne + oe + jj] = nn; // adj + NodesOfElement[i++] = nn++; // new + } else + i++; + } + if (kt) NodesOfElement[i++] = nn++; + // cout << k ; + // dump(" ",i-iold, NodesOfElement+iold); + } + // cout << i << " " << Th.nt*nbne << endl; + firstmul = nn; + if (Th.NbMortars) { + // construction of the mortars element + int *color = new int[firstmul]; + // + int thecolor = 0; + for (int j = 0; j < firstmul; j++) color[j] = thecolor; + + for (int im = 0; im < Th.NbMortars; im++) { + int iold = i; + thecolor++; // get a new color + // tm->ConstructionOfNode(Th,im,NodesOfElement,FirstNodeOfElement,nn); + Mortar &M(Th.mortars[im]); + NodesOfElement[i++] = nn++; // the first node is the lag. mul. + int n = M.NbT( ); + for (int kk = 0; kk < n; kk++) { + int K, e; + K = M.T_e(kk, e); + int kb = FirstNodeOfElement[K]; + int ke = FirstNodeOfElement[K + 1]; + for (int j = kb, jj = 0; j < ke; j++, jj++) + if (onWhatIsEdge[e][NodeIsOn[jj]]) { // the node jj is on edge e + int node = NodesOfElement[j]; + // cout << "." << jj << " K=" << K <<" "<=3); - throwassert(val.M()==1 ); -// throwassert(val.K()==3 ); - - val=0; - RN_ f0(val('.',0,op_id)); - - if (whatd[op_id]) - { - f0[0] = l0; - f0[1] = l1; - f0[2] = l2;} - if (whatd[op_dx] || whatd[op_dy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x; - f0x[1] = Dl1.x; - f0x[2] = Dl2.x; - } - - if (whatd[op_dy]) { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y; - f0y[1] = Dl1.y; - f0y[2] = Dl2.y; + NbOfNode = nn; + int NbOfDFL = 0; + if (!samendf) { + throwassert(NodesOfElement); + FirstDfOfNode = new int[nn + 1]; + for (int i = 0; i <= nn; i++) FirstDfOfNode[i] = -1; + int i = 0; + // the classical part (FEM) + for (int k = 0; k < Th.nt; k++) + for (int j = 0; j < nbne; j++) // thanks to student + FirstDfOfNode[NodesOfElement[i++] + 1] = NbDFonNode[j]; + // the mortars parts juste the mulplicator + + for (int km = 0, k = Th.nt; km < Th.NbMortars; km++, k++) { // the lag. mult. is the first node of the mortar -- + throwassert(FirstNodeOfElement); + // hack + int fk = FirstNodeOfElement[k]; + int lk = FirstNodeOfElement[k + 1]; + int ndlmul = tm->NbLagrangeMult(Th, Th.mortars[km]); // On node par + int nodemul = NodesOfElement[fk]; // the first node is the lagr. mul. + throwassert(FirstDfOfNode[nodemul + 1] == -1); + FirstDfOfNode[nodemul + 1] = ndlmul; + NbOfDFL += ndlmul; + int nbdle = 0; + int nbnm = lk - fk; + for (int j = fk; j < lk; j++) nbdle += FirstDfOfNode[NodesOfElement[j] + 1]; + MaxNbDFPerElement = Max(MaxNbDFPerElement, nbdle); + } + + FirstDfOfNode[0] = 0; + for (int i = 0; i <= nn; i++) throwassert(FirstDfOfNode[i] != -1); + + for (int i = 0; i < nn; i++) FirstDfOfNode[i + 1] += FirstDfOfNode[i]; + NbOfDF = FirstDfOfNode[nn]; + } else { + NbOfDF = nn * ndf; + Nproduit = ndf; + } + MaxNbNodePerElement = nbne; + + cout << " Nb Of Nodes = " << nn << endl; + if (NbOfNodeL) cout << " Nb of Lagrange Mul Node = " << NbOfNodeL << endl; + cout << " Nb of DF = " << NbOfDF << endl; + if (NbOfDFL) { + cout << " Nb of Lagrange Mul DF = " << NbOfDFL << endl; + cout << " MaxNbDFPerElement = " << MaxNbDFPerElement << endl; + }; } + + FESpace::FESpace(const FESpace &Vh, int k) + : ptrTFE(new TypeOfFEProduit(k, *Vh.TFE[0])), TFE(1, 0, ptrTFE), cmesh(Vh.Th), cdef(Vh.cdef ? new ConstructDataFElement(Vh.cdef, k) : 0), N(Vh.N * k), Nproduit(Vh.Nproduit * k), + nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + + Th(Vh.Th), NbOfDF(Vh.NbOfDF * k), NbOfElements(Vh.NbOfElements), NbOfNodes(Vh.NbOfNodes), MaxNbNodePerElement(Vh.MaxNbNodePerElement), MaxNbDFPerElement(Vh.MaxNbDFPerElement * k), + NodesOfElement(Vh.NodesOfElement), FirstDfOfNodeData(cdef ? cdef->FirstDfOfNode : 0), FirstNodeOfElement(Vh.FirstNodeOfElement), tom(0) { + if (cdef) renum( ); } -} - -/////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// NEW ///////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/* -void TypeOfFE_P1Bubble::FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const -{ - assert(0); -} - - -void TypeOfFE_P1Bubble::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int, void *) const -{ - assert(0); -} - -/* -R TypeOfFE_P1Bubble::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const -{ - assert(0); -} -*/ - -void TypeOfFE_P1Bubble::FB(const bool *whatd,const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const -{ -// const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y, l1=P.x, l2=P.y, lb=l0*l1*l2*9.; - - throwassert(val.N() >=4); - throwassert(val.M()==1 ); -// throwassert(val.K()==3 ); - - val=0; - RN_ f0(val('.',0,op_id)); - - if (whatd[op_id]) - { - f0[0] = l0-lb; - f0[1] = l1-lb; - f0[2] = l2-lb; - f0[3] = 3.*lb; - } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), - Dlb((Dl0*l1*l2+Dl1*l0*l2+Dl2*l0*l1)*9.); - - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x-Dlb.x; - f0x[1] = Dl1.x-Dlb.x; - f0x[2] = Dl2.x-Dlb.x; - f0x[3] = 3.*Dlb.x; + + FESpace::FESpace(const FESpace **Vh, int k) + : ptrTFE(new TypeOfFESum(Vh, k)), TFE(1, 0, ptrTFE), cmesh((**Vh).Th), cdef(new ConstructDataFElement(Vh, k)), N(sum(Vh, &FESpace::N, k)), Nproduit(cdef->Nproduit), nb_sub_fem(TFE[0]->nb_sub_fem), + dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + + Th((**Vh).Th), NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), MaxNbNodePerElement(cdef->MaxNbNodePerElement), MaxNbDFPerElement(cdef->MaxNbDFPerElement), + NodesOfElement(cdef->NodesOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), FirstNodeOfElement(cdef->FirstNodeOfElement), tom(0) { + if (cdef) renum( ); } - - if (whatd[op_dy]) { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y-Dlb.y; - f0y[1] = Dl1.y-Dlb.y; - f0y[2] = Dl2.y-Dlb.y; - f0y[3] = 3.*Dlb.y; + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE **tef, int k, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : ptrTFE(new TypeOfFESum(tef, k)), TFE(1, 0, ptrTFE), cmesh(TTh), + cdef(new ConstructDataFElement(TTh, sum(tef, &TypeOfFE::ndfonVertex, k), sum(tef, &TypeOfFE::ndfonEdge, k), sum(tef, &TypeOfFE::ndfonFace, k), 0, nbdfv, ndfv, nbdfe, ndfe)), + N(sum(tef, &TypeOfFE::N, k)), Nproduit(cdef->Nproduit), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + + Th(TTh), NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), MaxNbNodePerElement(cdef->MaxNbNodePerElement), MaxNbDFPerElement(cdef->MaxNbDFPerElement), + NodesOfElement(cdef->NodesOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), FirstNodeOfElement(cdef->FirstNodeOfElement), tom(0) { + if (cdef) renum( ); } - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - R lbdxx= 2*((Dl0.x*Dl1.x)*l2+(Dl1.x*Dl2.x)*l0+(Dl2.x*Dl0.x)*l1); - fxx[0] = -lbdxx; - fxx[1] = -lbdxx; - fxx[2] = -lbdxx; - fxx[3] = 3*lbdxx; + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE &tef, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : ptrTFE(0), TFE(1, 0, &tef), cmesh(TTh), cdef(new ConstructDataFElement(TTh, tef.ndfonVertex, tef.ndfonEdge, tef.ndfonFace, 0, nbdfv, ndfv, nbdfe, ndfe)), N(tef.N), Nproduit(cdef->Nproduit), + nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), Th(TTh), NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), + MaxNbNodePerElement(cdef->MaxNbNodePerElement), MaxNbDFPerElement(cdef->MaxNbDFPerElement), NodesOfElement(cdef->NodesOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), + FirstNodeOfElement(cdef->FirstNodeOfElement), tom(0) { + if (tef.ndfonVertex || tef.ndfonEdge) renum( ); } - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - R lbdyy= 2*((Dl0.y*Dl1.y)*l2+(Dl1.y*Dl2.y)*l0+(Dl2.y*Dl0.y)*l1); - - fyy[0] = -lbdyy; - fyy[1] = -lbdyy; - fyy[2] = -lbdyy; - fyy[3] = 3*lbdyy; + FESpace::~FESpace( ) { + SHOWVERB(cout << " FESpace::~FESpace() " << endl); + delete cdef; + if (ptrTFE) delete ptrTFE; } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - R lbdxy= (Dl0.x*Dl1.y+ Dl0.y*Dl1.x)*l2+(Dl1.x*Dl2.y+Dl1.y*Dl2.x)*l0+(Dl2.x*Dl0.y+Dl2.y*Dl0.x)*l1; - fxy[0] = 4*Dl0.x*Dl0.y-9.*(l0-l1-l2); - fxy[1] = 4*Dl1.x*Dl1.y-9.*(l0-l1-l2); - fxy[2] = 4*Dl2.x*Dl2.y-9.*(l0-l1-l2); - fxy[3] = 27.*(l0-l1-l2); + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE &tef, const TypeOfMortar &tm) + : ptrTFE(0), TFE(1, 0, &tef), cmesh(TTh), cdef(new ConstructDataFElement(TTh, tef.ndfonVertex, tef.ndfonEdge, tef.ndfonFace, &tm)), N(tef.N), Nproduit(1), nb_sub_fem(TFE[0]->nb_sub_fem), + dim_which_sub_fem(TFE[0]->dim_which_sub_fem), Th(TTh), NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), MaxNbNodePerElement(cdef->MaxNbNodePerElement), + MaxNbDFPerElement(cdef->MaxNbDFPerElement), NodesOfElement(cdef->NodesOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), FirstNodeOfElement(cdef->FirstNodeOfElement), tom(&tm) { + // cout << "avant renum ="<< *this <=3); - throwassert(val.M()==1 ); - throwassert(val.K()==3 ); - - val=0; - RN_ f0(val('.',0,0)); - RN_ f0x(val('.',0,1)); - RN_ f0y(val('.',0,2)); - - f0[0] = l0; - f0[1] = l1; - f0[2] = l2; - - f0x[0] = Dl0.x; - f0x[1] = Dl1.x; - f0x[2] = Dl2.x; - - f0y[0] = Dl0.y; - f0y[1] = Dl1.y; - f0y[2] = Dl2.y; -} - - void TypeOfFE_P2Lagrange::FB(const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const -{ -// const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); - -// throwassert(FE.N == 1); - throwassert( val.N()>=6); - throwassert(val.M()==1); - throwassert(val.K()==3 ); - - val=0; - RN_ f0(val('.',0,0)); - RN_ f0x(val('.',0,1)); - RN_ f0y(val('.',0,2)); -// -- - f0[0] = l0*(2*l0-1); - f0[1] = l1*(2*l1-1); - f0[2] = l2*(2*l2-1); - f0[3] = 4*l1*l2; // oppose au sommet 0 - f0[4] = 4*l0*l2; // oppose au sommet 1 - f0[5] = 4*l1*l0; // oppose au sommet 3 - - - f0x[0] = Dl0.x*l4_0; - f0x[1] = Dl1.x*l4_1; - f0x[2] = Dl2.x*l4_2; - f0x[3] = 4*(Dl1.x*l2 + Dl2.x*l1) ; - f0x[4] = 4*(Dl2.x*l0 + Dl0.x*l2) ; - f0x[5] = 4*(Dl0.x*l1 + Dl1.x*l0) ; - - - f0y[0] = Dl0.y*l4_0; - f0y[1] = Dl1.y*l4_1; - f0y[2] = Dl2.y*l4_2; - f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) ; - f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) ; - f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) ; - -} -*/ -void TypeOfFE_P2Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const -{ -// const Triangle & K(FE.T); - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-P.x-P.y,l1=P.x,l2=P.y; - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); - -// throwassert(FE.N == 1); - throwassert( val.N()>=6); - throwassert(val.M()==1); -// throwassert(val.K()==3 ); - - val=0; -// -- - if (whatd[op_id]) - { - RN_ f0(val('.',0,op_id)); - f0[0] = l0*(2*l0-1); - f0[1] = l1*(2*l1-1); - f0[2] = l2*(2*l2-1); - f0[3] = 4*l1*l2; // oppose au sommet 0 - f0[4] = 4*l0*l2; // oppose au sommet 1 - f0[5] = 4*l1*l0; // oppose au sommet 3 + /* + void TypeOfFEProduit::D2_FB(const Mesh & Th,const Triangle & K,const R2 & P,RNMK_ & val) const + { + int n=teb.NbDoF; + int m=teb.N; + val=0.0; + SubArray t(3); + RNMK_ v(val(SubArray(n,0,k),SubArray(m),t)); + teb.D2_FB(Th,K,P,v); + for (int i=1;iD2_FB(Th,K,P,v); + else + v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); + } } + */ + /* + void TypeOfFESum::FB(const Mesh & Th,const Triangle & K,const R2 & P,RNMK_ & val) const + { + val=0.0; + SubArray t(3); + for (int i=0;iFB(Th,K,P,v); + else + v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); + } + } + */ + void TypeOfFESum::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const R2 &P, RNMK_ &val) const { + val = 0.0; + SubArray t(val.K( )); + for (int i = 0; i < k; i++) { + int j = comp[i]; + int ni = NN[i]; + int di = DF[i]; + int i1 = i + 1; + int nii = NN[i1]; + int dii = DF[i1]; + throwassert(ni < nii && di < dii); + RNMK_ v(val(SubArray(dii - di, di), SubArray(nii - ni, ni), t)); + if (j <= i) + teb[i]->FB(whatd, Th, K, P, v); + else + v = val(SubArray(DF[j + 1] - DF[j], DF[j]), SubArray(NN[j + 1] - NN[j], NN[j]), t); + } } + /* + void TypeOfFESum::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int jjj, void * arg) const + { + for(int i=0;iPi_h(KK,vv,f,v,jjj+NN[i],arg); + } + // cout << val(SubArray(NbDoF)) << endl; - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y*l4_0; - f0y[1] = Dl1.y*l4_1; - f0y[2] = Dl2.y*l4_2; - f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) ; - f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) ; - f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) ; + } + /* + void TypeOfFE_P1Lagrange::D2_FB(const Mesh & ,const Triangle & ,const R2 & ,RNMK_ & val) const + { // + val=0; } - - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); + */ + /* + void TypeOfFE_P2Lagrange::D2_FB(const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const + { // 2 times derivatives for error indicator + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]),C(K[2]); + R l0=1-P.x-P.y,l1=P.x,l2=P.y; + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); + + throwassert(val.N() >=6); + throwassert(val.M()==1 ); + throwassert(val.K()==3 ); + + val=0; + RN_ fxx(val('.',0,0)); + RN_ fxy(val('.',0,1)); + RN_ fyy(val('.',0,2)); fxx[0] = 4*Dl0.x*Dl0.x; fxx[1] = 4*Dl1.x*Dl1.x; @@ -1328,394 +883,663 @@ void TypeOfFE_P2Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K, fxx[3] = 8*Dl1.x*Dl2.x; fxx[4] = 8*Dl0.x*Dl2.x; fxx[5] = 8*Dl0.x*Dl1.x; - } - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); fyy[0] = 4*Dl0.y*Dl0.y; fyy[1] = 4*Dl1.y*Dl1.y; fyy[2] = 4*Dl2.y*Dl2.y; fyy[3] = 8*Dl1.y*Dl2.y; fyy[4] = 8*Dl0.y*Dl2.y; fyy[5] = 8*Dl0.y*Dl1.y; - } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - - fxy[0] = 4*Dl0.x*Dl0.y; - fxy[1] = 4*Dl1.x*Dl1.y; - fxy[2] = 4*Dl2.x*Dl2.y; + + fxy[0] = 4*Dl0.y*Dl0.y; + fxy[1] = 4*Dl1.y*Dl1.y; + fxy[2] = 4*Dl2.y*Dl2.y; fxy[3] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x); fxy[4] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x); fxy[5] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x); + } - - } - -} -/* - void TypeOfFE_P1Lagrange::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const -{ - const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1) }; - for (int i=0;i<3;i++) - { - f(v,K.T(Pt[i]),K,i,Pt[i],arg),val[i]=*(v+j);} - -} - void TypeOfFE_P2Lagrange::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const -{ - const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1),R2(0.5,0.5),R2(0,0.5),R2(0.5,0) }; - for (int i=0;i<6;i++) - { - f(v,K.T(Pt[i]),K,i,Pt[i],arg),val[i]=*(v+j);} - -} -*/ - - -//TypeOfFE P1Lagrange(1,0,0,P1Functions,D2_P1Functions,P1Interpolant,DataP1Lagrange); -//TypeOfFE P2Lagrange(1,1,0,P2Functions,D2_P2Functions,P2Interpolant,DataP2Lagrange,3); - -// case of fine mesh -class TypeOfMortarCas1: public TypeOfMortar { - friend class FESpace; - friend class FMortar; - friend class ConstructDataFElement; - protected: - int NbLagrangeMult(const Mesh &,const Mortar &M) const ; - - int NbDoF(const Mesh &,const Mortar &M,int i) const - { int l(M.NbLeft()),r(M.NbRight()); - int n =Max(l,r); - int mn=Min(l,r); - return (l+r)*(ndfonVertex + ndfonEdge) + (n+1)*ndfonVertex + n*ndfonEdge -mn-1; + */ + R TypeOfFE_P1Lagrange::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); + R r = 0; + if (op == 0) { + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + r = u0 * l0 + u1 * l1 + l2 * u2; + } else { + const Triangle &T = K.T; + R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); + if (op == 1) + r = D0.x * u0 + D1.x * u1 + D2.x * u2; + else + r = D0.y * u0 + D1.y * u1 + D2.y * u2; + } + // cout << r << "\t"; + return r; + } + + void TypeOfFE_P1Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + RN_ f0(val('.', 0, op_id)); + + if (whatd[op_id]) { + f0[0] = l0; + f0[1] = l1; + f0[2] = l2; + } + if (whatd[op_dx] || whatd[op_dy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x; + f0x[1] = Dl1.x; + f0x[2] = Dl2.x; } - int NbOfNodes(const Mesh &,const Mortar &M) const // call one time - {int l(M.NbLeft()),r(M.NbRight()); return (l+r)*(vertex_is_node+edge_is_node)+1;} - int NbDoF(const Mesh &,const Mortar &M) const - { int l(M.NbLeft()),r(M.NbRight()); - int n =Max(l,r); - int mn=Min(l,r); - return (l+r)*(ndfonVertex + ndfonEdge) + (n+1)*ndfonVertex + n*ndfonEdge -mn-1; + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y; + f0y[1] = Dl1.y; + f0y[2] = Dl2.y; } - - int NodeOfDF(const FESpace &Vh,const Mortar &M,int i) const - {throwassert(0);return 0;} - int DFOfNode(const FESpace &Vh,const Mortar &M,int i) const - {throwassert(0);return 0;} - void ConstructionOfNode(const Mesh &Th,int im,int * NodesOfElement,int *FirstNodeOfElement,int &lastnodenumber) const; - void ConsTheSubMortar(FMortar & ) const; - - const int vertex_is_node,edge_is_node; - public: - TypeOfMortarCas1 (int i,int j): TypeOfMortar(i,j), - vertex_is_node(i?1:0),edge_is_node(j?1:0) {}; - -} MortarCas1P2(1,1) ; - - const TypeOfMortar & TheMortarCas1P2(MortarCas1P2); - - -void TypeOfMortarCas1::ConstructionOfNode(const Mesh &Th,int im,int * NodesOfElement,int *FirstNodeOfElement,int &lastnodenumber) const -{ - // im mortar number - // trop complique on change - const Mortar &M(Th.mortars[im]); - int k = Th.nt+im; - int kk=FirstNodeOfElement[k]; // begin - // lagrange multiplicator one new node - NodesOfElement[kk++] = lastnodenumber++; -/* - int il = M.NbLeft(); - int ir = M.NbRight(); - int ir1 = ir-1; - // left - - for( int j=0;j & u,int componante,int op) const + { + assert(0); + } + */ + + void TypeOfFE_P1Bubble::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y, lb = l0 * l1 * l2 * 9.; + + throwassert(val.N( ) >= 4); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + RN_ f0(val('.', 0, op_id)); + + if (whatd[op_id]) { + f0[0] = l0 - lb; + f0[1] = l1 - lb; + f0[2] = l2 - lb; + f0[3] = 3. * lb; + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), Dlb((Dl0 * l1 * l2 + Dl1 * l0 * l2 + Dl2 * l0 * l1) * 9.); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x - Dlb.x; + f0x[1] = Dl1.x - Dlb.x; + f0x[2] = Dl2.x - Dlb.x; + f0x[3] = 3. * Dlb.x; + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y - Dlb.y; + f0y[1] = Dl1.y - Dlb.y; + f0y[2] = Dl2.y - Dlb.y; + f0y[3] = 3. * Dlb.y; + } + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + R lbdxx = 2 * ((Dl0.x * Dl1.x) * l2 + (Dl1.x * Dl2.x) * l0 + (Dl2.x * Dl0.x) * l1); + fxx[0] = -lbdxx; + fxx[1] = -lbdxx; + fxx[2] = -lbdxx; + fxx[3] = 3 * lbdxx; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + R lbdyy = 2 * ((Dl0.y * Dl1.y) * l2 + (Dl1.y * Dl2.y) * l0 + (Dl2.y * Dl0.y) * l1); + + fyy[0] = -lbdyy; + fyy[1] = -lbdyy; + fyy[2] = -lbdyy; + fyy[3] = 3 * lbdyy; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + R lbdxy = (Dl0.x * Dl1.y + Dl0.y * Dl1.x) * l2 + (Dl1.x * Dl2.y + Dl1.y * Dl2.x) * l0 + (Dl2.x * Dl0.y + Dl2.y * Dl0.x) * l1; + fxy[0] = 4 * Dl0.x * Dl0.y - 9. * (l0 - l1 - l2); + fxy[1] = 4 * Dl1.x * Dl1.y - 9. * (l0 - l1 - l2); + fxy[2] = 4 * Dl2.x * Dl2.y - 9. * (l0 - l1 - l2); + fxy[3] = 27. * (l0 - l1 - l2); + } + } + } + /////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// + + /* void TypeOfFE_P1Lagrange::FB(const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const + { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]),C(K[2]); + R l0=1-P.x-P.y,l1=P.x,l2=P.y; + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + + if (val.N() <3) + throwassert(val.N() >=3); + throwassert(val.M()==1 ); + throwassert(val.K()==3 ); + + val=0; + RN_ f0(val('.',0,0)); + RN_ f0x(val('.',0,1)); + RN_ f0y(val('.',0,2)); + + f0[0] = l0; + f0[1] = l1; + f0[2] = l2; + + f0x[0] = Dl0.x; + f0x[1] = Dl1.x; + f0x[2] = Dl2.x; + + f0y[0] = Dl0.y; + f0y[1] = Dl1.y; + f0y[2] = Dl2.y; + } + + void TypeOfFE_P2Lagrange::FB(const Mesh & ,const Triangle & K,const R2 & P,RNMK_ & val) const + { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]),C(K[2]); + R l0=1-P.x-P.y,l1=P.x,l2=P.y; + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); + + // throwassert(FE.N == 1); + throwassert( val.N()>=6); + throwassert(val.M()==1); + throwassert(val.K()==3 ); + + val=0; + RN_ f0(val('.',0,0)); + RN_ f0x(val('.',0,1)); + RN_ f0y(val('.',0,2)); + // -- + f0[0] = l0*(2*l0-1); + f0[1] = l1*(2*l1-1); + f0[2] = l2*(2*l2-1); + f0[3] = 4*l1*l2; // oppose au sommet 0 + f0[4] = 4*l0*l2; // oppose au sommet 1 + f0[5] = 4*l1*l0; // oppose au sommet 3 + + + f0x[0] = Dl0.x*l4_0; + f0x[1] = Dl1.x*l4_1; + f0x[2] = Dl2.x*l4_2; + f0x[3] = 4*(Dl1.x*l2 + Dl2.x*l1) ; + f0x[4] = 4*(Dl2.x*l0 + Dl0.x*l2) ; + f0x[5] = 4*(Dl0.x*l1 + Dl1.x*l0) ; + + + f0y[0] = Dl0.y*l4_0; + f0y[1] = Dl1.y*l4_1; + f0y[2] = Dl2.y*l4_2; + f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) ; + f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) ; + f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) ; + + } + */ + void TypeOfFE_P2Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const R2 &P, RNMK_ &val) const { + // const Triangle & K(FE.T); + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - P.x - P.y, l1 = P.x, l2 = P.y; + R l4_0 = (4 * l0 - 1), l4_1 = (4 * l1 - 1), l4_2 = (4 * l2 - 1); + + // throwassert(FE.N == 1); + throwassert(val.N( ) >= 6); + throwassert(val.M( ) == 1); + // throwassert(val.K()==3 ); + + val = 0; + // -- + if (whatd[op_id]) { + RN_ f0(val('.', 0, op_id)); + f0[0] = l0 * (2 * l0 - 1); + f0[1] = l1 * (2 * l1 - 1); + f0[2] = l2 * (2 * l2 - 1); + f0[3] = 4 * l1 * l2; // oppose au sommet 0 + f0[4] = 4 * l0 * l2; // oppose au sommet 1 + f0[5] = 4 * l1 * l0; // oppose au sommet 3 + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x * l4_0; + f0x[1] = Dl1.x * l4_1; + f0x[2] = Dl2.x * l4_2; + f0x[3] = 4 * (Dl1.x * l2 + Dl2.x * l1); + f0x[4] = 4 * (Dl2.x * l0 + Dl0.x * l2); + f0x[5] = 4 * (Dl0.x * l1 + Dl1.x * l0); + } + + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y * l4_0; + f0y[1] = Dl1.y * l4_1; + f0y[2] = Dl2.y * l4_2; + f0y[3] = 4 * (Dl1.y * l2 + Dl2.y * l1); + f0y[4] = 4 * (Dl2.y * l0 + Dl0.y * l2); + f0y[5] = 4 * (Dl0.y * l1 + Dl1.y * l0); + } + + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + + fxx[0] = 4 * Dl0.x * Dl0.x; + fxx[1] = 4 * Dl1.x * Dl1.x; + fxx[2] = 4 * Dl2.x * Dl2.x; + fxx[3] = 8 * Dl1.x * Dl2.x; + fxx[4] = 8 * Dl0.x * Dl2.x; + fxx[5] = 8 * Dl0.x * Dl1.x; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + fyy[0] = 4 * Dl0.y * Dl0.y; + fyy[1] = 4 * Dl1.y * Dl1.y; + fyy[2] = 4 * Dl2.y * Dl2.y; + fyy[3] = 8 * Dl1.y * Dl2.y; + fyy[4] = 8 * Dl0.y * Dl2.y; + fyy[5] = 8 * Dl0.y * Dl1.y; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + + fxy[0] = 4 * Dl0.x * Dl0.y; + fxy[1] = 4 * Dl1.x * Dl1.y; + fxy[2] = 4 * Dl2.x * Dl2.y; + fxy[3] = 4 * (Dl1.x * Dl2.y + Dl1.y * Dl2.x); + fxy[4] = 4 * (Dl0.x * Dl2.y + Dl0.y * Dl2.x); + fxy[5] = 4 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x); + } + } + } + /* + void TypeOfFE_P1Lagrange::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const + { + const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1) }; + for (int i=0;i<3;i++) + { + f(v,K.T(Pt[i]),K,i,Pt[i],arg),val[i]=*(v+j);} + + } + void TypeOfFE_P2Lagrange::Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int j, void * arg) const + { + const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1),R2(0.5,0.5),R2(0,0.5),R2(0.5,0) }; + for (int i=0;i<6;i++) + { + f(v,K.T(Pt[i]),K,i,Pt[i],arg),val[i]=*(v+j);} + + } + */ + + // TypeOfFE P1Lagrange(1,0,0,P1Functions,D2_P1Functions,P1Interpolant,DataP1Lagrange); + // TypeOfFE P2Lagrange(1,1,0,P2Functions,D2_P2Functions,P2Interpolant,DataP2Lagrange,3); + + // case of fine mesh + class TypeOfMortarCas1 : public TypeOfMortar { + friend class FESpace; + friend class FMortar; + friend class ConstructDataFElement; + + protected: + int NbLagrangeMult(const Mesh &, const Mortar &M) const; + + int NbDoF(const Mesh &, const Mortar &M, int i) const { + int l(M.NbLeft( )), r(M.NbRight( )); + int n = Max(l, r); + int mn = Min(l, r); + return (l + r) * (ndfonVertex + ndfonEdge) + (n + 1) * ndfonVertex + n * ndfonEdge - mn - 1; + } + int NbOfNodes(const Mesh &, const Mortar &M) const // call one time + { + int l(M.NbLeft( )), r(M.NbRight( )); + return (l + r) * (vertex_is_node + edge_is_node) + 1; + } + int NbDoF(const Mesh &, const Mortar &M) const { + int l(M.NbLeft( )), r(M.NbRight( )); + int n = Max(l, r); + int mn = Min(l, r); + return (l + r) * (ndfonVertex + ndfonEdge) + (n + 1) * ndfonVertex + n * ndfonEdge - mn - 1; + } + + int NodeOfDF(const FESpace &Vh, const Mortar &M, int i) const { + throwassert(0); + return 0; + } + int DFOfNode(const FESpace &Vh, const Mortar &M, int i) const { + throwassert(0); + return 0; + } + void ConstructionOfNode(const Mesh &Th, int im, int *NodesOfElement, int *FirstNodeOfElement, int &lastnodenumber) const; + void ConsTheSubMortar(FMortar &) const; + + const int vertex_is_node, edge_is_node; + + public: + TypeOfMortarCas1(int i, int j) : TypeOfMortar(i, j), vertex_is_node(i ? 1 : 0), edge_is_node(j ? 1 : 0) {}; + + } MortarCas1P2(1, 1); + + const TypeOfMortar &TheMortarCas1P2(MortarCas1P2); + + void TypeOfMortarCas1::ConstructionOfNode(const Mesh &Th, int im, int *NodesOfElement, int *FirstNodeOfElement, int &lastnodenumber) const { + // im mortar number + // trop complique on change + const Mortar &M(Th.mortars[im]); + int k = Th.nt + im; + int kk = FirstNodeOfElement[k]; // begin + // lagrange multiplicator one new node + NodesOfElement[kk++] = lastnodenumber++; + /* + int il = M.NbLeft(); + int ir = M.NbRight(); + int ir1 = ir-1; + // left + + for( int j=0;j=0 && lr >= 0); - // throwassert ( ll <=lg && lr <= lg); - - // cout << "AA , BB = " << AA << "," << BB << endl; - // cout << " " << ll << " " << lr << " ll=" << sm.sm[k].left << ", "; - if (ll=0 && lr >= 0); + // throwassert ( ll <=lg && lr <= lg); + + // cout << "AA , BB = " << AA << "," << BB << endl; + // cout << " " << ll << " " << lr << " ll=" << sm.sm[k].left << ", "; + if (ll < lr) { + BB = Bl, lb = ll, il++; + } else { + BB = Br, lb = lr, ir++; + } + // cout << k << " " << k << " " << la/lg << " " << lb/lg << endl; + sm.sm[k].a = la / lg; + sm.sm[k].b = lb / lg; + sm.sm[k].A = AA; + sm.sm[k].B = BB; + la = lb; + AA = BB; + k++; + throwassert(k <= nbsm); + } while (il < nl && ir < nr); + + // cout << "k=" << k <2); - return nbmul; - } - - -// --- - FMortar::FMortar(const FESpace * VVh,int k) - : - Vh(*VVh), - M(Vh.Th.mortars[k-Vh.Th.nt]), - N(VVh->N), - p(Vh.PtrFirstNodeOfElement(k)), - nbn(Vh.NbOfNodesInElement(k)), - tom(Vh.tom) - - { throwassert(k>=Vh.Th.nt && k tom->ConsTheSubMortar(*this);} - - R TypeOfFE::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const + nbmul += 1; // P1; + lgp = lgc; + lgc = lgs; + } + } else { + R2 AA(M.VRight(0)), BB(M.VRight(1)); + lgp = Norme2(BB - AA); // preced + AA = BB; + BB = M.VRight(2); + lgc = Norme2(BB - AA); // courant + + for (int i = 1; i < nr - 1; i++) { + AA = BB; + BB = M.VRight(i + 2); + lgs = Norme2(AA - BB); // le suivant + if (Abs(lgp - lgc) < leps && Abs(lgs - lgc) < leps) + nbmul += 2; // P2 + else + nbmul += 1; // P1; + lgp = lgc; + lgc = lgs; + } + } + throwassert(nbmul > 2); + return nbmul; + } + + // --- + FMortar::FMortar(const FESpace *VVh, int k) + : Vh(*VVh), M(Vh.Th.mortars[k - Vh.Th.nt]), N(VVh->N), p(Vh.PtrFirstNodeOfElement(k)), nbn(Vh.NbOfNodesInElement(k)), tom(Vh.tom) + { - R v[1000],vf[100]; - assert(N*3*NbDoF<=1000 && NbDoF <100 ); - KNMK_ fb(v,NbDoF,N,op+1); // the value for basic fonction - KN_ fk(vf,NbDoF); - for (int i=0;i= Vh.Th.nt && k < Vh.Th.nt + Vh.Th.NbMortars); + VVh->tom->ConsTheSubMortar(*this); + } + + R TypeOfFE::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R v[1000], vf[100]; + assert(N * 3 * NbDoF <= 1000 && NbDoF < 100); + KNMK_< R > fb(v, NbDoF, N, op + 1); // the value for basic fonction + KN_< R > fk(vf, NbDoF); + for (int i = 0; i < NbDoF; i++) // get the local value + fk[i] = u[K(i)]; // get value of basic function - bool whatd[last_operatortype]; - for (int i=0;i & P,KN & I) - { - typedef TypeOfFE::IPJ IPJ; + int Make(const TypeOfFE **t, int k, KN< R2 > &P, KN< int > &I) { + typedef TypeOfFE::IPJ IPJ; - int n=0,nn=0; + int n = 0, nn = 0; - for (int i=0;i p(t[i]->P_Pi_h); - for (int j=0;j ajout - I[nn]=n++; - for (int l=0;l detruit - break;} + for (int i = 0; i < k; i++) { + const KN< R2 > p(t[i]->P_Pi_h); + for (int j = 0; j < p.N( ); j++, nn++) { + P[n] = p[j]; // par defaut un nouveau => ajout + I[nn] = n++; + for (int l = 0; l < n - 1; l++) { + R2 QP(p[j], P[l]); + if ((QP, QP) < 1.0e-12) { + I[nn] = l; + n--; // on a retrouver => detruit + break; + } } + } + } + return n; // nombre de point commun + } - } + KN< TypeOfFE::IPJ > Makepij_alpha(const TypeOfFE **t, int k) { + // Attention les df est numerote de facon croissant + // en faisant une boucle sur les TypeOfFE + // comme dans la class TypeOfFESum + typedef TypeOfFE::IPJ IPJ; + int n = 0, m = 0; + for (int i = 0; i < k; i++) { + n += t[i]->pij_alpha.N( ); + m += t[i]->P_Pi_h.N( ); } - return n; // nombre de point commun - } - - KN Makepij_alpha(const TypeOfFE ** t,int k) - { - // Attention les df est numerote de facon croissant - // en faisant une boucle sur les TypeOfFE - // comme dans la class TypeOfFESum - typedef TypeOfFE::IPJ IPJ; - int n=0,m=0; - for (int i=0;i< k;i++) { - n += t[i]->pij_alpha.N(); - m += t[i]->P_Pi_h.N(); + KN< TypeOfFE::IPJ > ij(n); + KN< int > I(m); + KN< R2 > P(m); + Make(t, k, P, I); + int p0 = 0, i0 = 0, N0 = 0, nn = 0; + for (int i = 0; i < k; i++) { + const KN< IPJ > p(t[i]->pij_alpha); + for (int j = 0; j < p.N( ); j++, nn++) { + ij[nn].i = p[j].i + i0; // comme dans TypeOfFESum + ij[nn].j = N0 + p[j].j; + ij[nn].p = I[p[j].p + p0]; + } + i0 += t[i]->NbDoF; + p0 += t[i]->P_Pi_h.N( ); + N0 += t[i]->N; } - KN ij(n); - KN I(m); - KN P(m); - Make(t,k,P,I); - int p0=0,i0=0,N0=0,nn=0; - for (int i=0;i< k;i++) { - const KN p(t[i]->pij_alpha); - for (int j=0;j MakeP_Pi_h(const TypeOfFE **t, int k) { + int np = 0; + for (int i = 0; i < k; i++) np += t[i]->P_Pi_h.N( ); + + KN< R2 > yy(np); + KN< int > zz(np); + int kk = Make(t, k, yy, zz); + return yy(SubArray(kk)); + } - } - i0+=t[i]->NbDoF; - p0+=t[i]->P_Pi_h.N(); - N0+=t[i]->N;} - return ij; - } - KN MakeP_Pi_h(const TypeOfFE **t,int k) - { - int np=0; - for (int i=0;i< k;i++) - np += t[i]->P_Pi_h.N(); - - KN< R2 > yy(np); - KN zz(np); - int kk=Make(t,k,yy,zz); - return yy(SubArray(kk)); - - } - -ListOfTFE * ListOfTFE::all ; // list of all object of this type - -void init_static_FE(); // to correct so probleme with static Library FH aout 2004 -// the list of other FE file to force the link - -ListOfTFE::ListOfTFE (const char * n,TypeOfFE *t) : name(n),tfe(t) -{ - if(!t) - assert(t); - static int count=0; - if (count++==0) - all=0; // init of all in dependant of the ordre of the objet file - next=all; - all=this; - // to correct so probleme with static Library FH aout 2004 - init_static_FE(); -} - -const TypeOfFE ** Make(const FESpace **l,int k) { - const TypeOfFE** p=new const TypeOfFE*[k]; - for (int i=0;iTFE[0]; - return p; -} -const TypeOfFE ** Make(const TypeOfFE **l,int k) { - const TypeOfFE** p=new const TypeOfFE*[k]; - for (int i=0;i Aipj(ipj.N()); - KNM Vp(N,PtHat.N()); - - Pi_h(Aipj); - for (int p=0;p Vpp(Vp('.',p)); - for (int j=0;j & v) const - { - int k0=0; - for (int i=0;ipij_alpha.N(); // ici BUG - KN_ sv(v(SubArray(n,k0))); - teb[i]->Pi_h_alpha(K,sv); - k0+= n;} - assert(pij_alpha.N()==k0); + ListOfTFE::ListOfTFE(const char *n, TypeOfFE *t) : name(n), tfe(t) { + if (!t) assert(t); + static int count = 0; + if (count++ == 0) all = 0; // init of all in dependant of the ordre of the objet file + next = all; + all = this; + // to correct so probleme with static Library FH aout 2004 + init_static_FE( ); + } + + const TypeOfFE **Make(const FESpace **l, int k) { + const TypeOfFE **p = new const TypeOfFE *[k]; + for (int i = 0; i < k; i++) p[i] = l[i]->TFE[0]; + return p; + } + const TypeOfFE **Make(const TypeOfFE **l, int k) { + const TypeOfFE **p = new const TypeOfFE *[k]; + for (int i = 0; i < k; i++) p[i] = l[i]; + return p; + } + + bool Same(const FESpace **l, int k) { + for (int i = 1; i < k; i++) + if (l[0] != l[i]) return false; + return true; + } + + class FESumConstruct { + protected: + const int k; + const TypeOfFE **teb; + int nbn; // nb of node + int *data; + int *data1; + int *const NN; // NN[ i:i+1[ dimension de l'element i + int *const DF; // DF[i:i+1[ df associe a l'element i + int *const comp; // + FESumConstruct(int kk, const TypeOfFE **t); + virtual ~FESumConstruct( ) { + delete[] DF; + delete[] NN; + delete[] comp; + delete[] data; } - ~TypeOfFESum(){ delete [] teb;} -} ; - -class FEProduitConstruct { protected: - int k; - const TypeOfFE & teb; - int * data; - int * data1; - FEProduitConstruct(int kk,const TypeOfFE &t) ; - ~FEProduitConstruct(){delete [] data;} -}; - -class TypeOfFEProduit: protected FEProduitConstruct, public TypeOfFE { public: - TypeOfFEProduit(int kk,const TypeOfFE &t): - FEProduitConstruct(kk,t),TypeOfFE(t,kk,data,data1) {} - - - void FB(const bool * whatd,const Mesh & Th,const Triangle & K,const RdHat &PHat, RNMK_ & val) const; - virtual void Pi_h_alpha(const baseFElement & K,KN_ & v) const - { int nbof=teb.NbDoF; - for (int i=0,k0=0;i sv(v(SubArray(nbof,k0))); - teb.Pi_h_alpha(K,sv); + }; + + void FElement::Pi_h(RN_ val, InterpolFunction f, R *v, void *arg = 0) const { + // routine: a tester FH. + FElement::aIPJ ipj(Pi_h_ipj( )); + FElement::aR2 PtHat(Pi_h_R2( )); + KN< R > Aipj(ipj.N( )); + KNM< R > Vp(N, PtHat.N( )); + + Pi_h(Aipj); + for (int p = 0; p < PtHat.N( ); p++) { + f(v, T(PtHat[p]), *this, T.lab, PtHat[p], arg); + KN_< double > Vpp(Vp('.', p)); + for (int j = 0; j < N; j++) Vpp[j] = v[j]; + } + + for (int i = 0; i < Aipj.N( ); i++) { + const FElement::IPJ &ipj_i(ipj[i]); + val[ipj_i.i] += Aipj[i] * Vp(ipj_i.j, ipj_i.p); } } - ~TypeOfFEProduit(){} -} ; - -FEProduitConstruct::FEProduitConstruct(int kk,const TypeOfFE &t) - :k(kk),teb(t) -{ - int m= teb.NbDoF; - KN nn(teb.NbNode); - nn=0; // nb de dl par noeud - for (int i=0;i &v) const { + int k0 = 0; + for (int i = 0; i < k; i++) { + int n = teb[i]->pij_alpha.N( ); // ici BUG + KN_< R > sv(v(SubArray(n, k0))); + teb[i]->Pi_h_alpha(K, sv); + k0 += n; + } + assert(pij_alpha.N( ) == k0); } - // warning the numbering of - for(int j=0;j m; - int i=k,j; - while(i--) // on va a l'envert pour avoir comp[i] <=i - m[teb[i]]=i; + ~TypeOfFESum( ) { delete[] teb; } + }; + + class FEProduitConstruct { + protected: + int k; + const TypeOfFE &teb; + int *data; + int *data1; + FEProduitConstruct(int kk, const TypeOfFE &t); + ~FEProduitConstruct( ) { delete[] data; } + }; + + class TypeOfFEProduit : protected FEProduitConstruct, public TypeOfFE { + public: + TypeOfFEProduit(int kk, const TypeOfFE &t) : FEProduitConstruct(kk, t), TypeOfFE(t, kk, data, data1) {} + + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + virtual void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + int nbof = teb.NbDoF; + for (int i = 0, k0 = 0; i < k; i++, k0 += nbof) { + KN_< R > sv(v(SubArray(nbof, k0))); + teb.Pi_h_alpha(K, sv); + } + } + + ~TypeOfFEProduit( ) {} + }; + + FEProduitConstruct::FEProduitConstruct(int kk, const TypeOfFE &t) : k(kk), teb(t) { + int m = teb.NbDoF; + KN< int > nn(teb.NbNode); + nn = 0; // nb de dl par noeud + for (int i = 0; i < m; i++) nn[teb.NodeOfDF[i]]++; + + int n = m * kk; + int No = teb.N; + int N = No * kk; + data = new int[n * (5 + 2) + 3 * N]; + data1 = data + n * (5) + N; // april 2006 add 2 array ???? + int c = 0; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = teb.DFOnWhat[i]; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) // num of df on node for the df = j + data[c++] = teb.DFOfNode[i] + j * nn[teb.NodeOfDF[i]]; + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = teb.NodeOfDF[i]; // node of df + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = j; // node from of FE + + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) data[c++] = i; // node from of df in FE + + for (int j = 0; j < kk; j++) + for (int i = 0; i < teb.N; i++) data[c++] = teb.dim_which_sub_fem[i] + teb.nb_sub_fem * j; + + int ci = n; + int cj = 0; + + // ou dans la partie miminal element finite atomic + for (int i = 0; i < m; i++) + for (int j = 0; j < kk; j++) { + int il = teb.fromASubDF[i]; + int jl = teb.fromASubFE[i]; + data1[ci++] = il; + data1[cj++] = j * teb.nb_sub_fem + jl; + } + // warning the numbering of + for (int j = 0; j < kk; ++j) + for (int i = 0; i < No; ++i) data1[ci++] = 0; // j*m+teb.begin_dfcomp[i]; + for (int j = 0; j < kk; ++j) + for (int i = 0; i < No; ++i) data1[ci++] = m * kk; // j*m+teb.end_dfcomp[i]; + if (verbosity) cout << " kk " << kk << " " << m << " : "; + } + + FESumConstruct::FESumConstruct(int kk, const TypeOfFE **t) : k(kk), teb(t), NN(new int[kk + 1]), DF(new int[kk + 1]), comp(new int[kk]) { + map< const TypeOfFE *, int > m; + int i = k, j; + while (i--) // on va a l'envert pour avoir comp[i] <=i + m[teb[i]] = i; // l'ordre comp est important comp est croissant mais pas de pb. - i=k; - while(i--) - comp[i]=m[teb[i]]; // comp[i] <=i - - // reservatition des intervalles en espaces - int n=0,N=0; - for ( j=0;jN;} - NN[kk] = N; - // reservation des interval en df - n=0; - for ( j=0;jNbDoF;} - DF[kk] = n; -// n = nb de DF total -// N the fem is in R^N - - data = new int [n*(5+2) + 3*N]; - data1 = data + n*5+N; // april 2006 add 2 array ???? - - int c=0; -// recherche des noeuds - KN w(7),nn(7); - w=0; - nn=0; - - - for ( j=0;jNbDoF;i++) - nn[teb[j]->DFOnWhat[i]]++; - nbn=0; - for( j=0;j<7;j++) - if (nn[j]) nn[j]=nbn++; - else nn[j]=-1; - KN dln(7); - dln=0; - // nn donne numero de noeud sur what - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOnWhat[i]; - - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOfNode[i]+dln[teb[j]->DFOnWhat[i]]; - for ( i=0;iNbDoF;i++) - dln[teb[j]->DFOnWhat[i]]=Max(dln[teb[j]->DFOnWhat[i]],data[cc++]+1); + i = k; + while (i--) comp[i] = m[teb[i]]; // comp[i] <=i + + // reservatition des intervalles en espaces + int n = 0, N = 0; + for (j = 0; j < kk; j++) { + NN[j] = N; + N += teb[j]->N; + } + NN[kk] = N; + // reservation des interval en df + n = 0; + for (j = 0; j < kk; j++) { + DF[j] = n; + n += teb[j]->NbDoF; + } + DF[kk] = n; + // n = nb de DF total + // N the fem is in R^N + + data = new int[n * (5 + 2) + 3 * N]; + data1 = data + n * 5 + N; // april 2006 add 2 array ???? + + int c = 0; + // recherche des noeuds + KN< int > w(7), nn(7); + w = 0; + nn = 0; + + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) nn[teb[j]->DFOnWhat[i]]++; + nbn = 0; + for (j = 0; j < 7; j++) + if (nn[j]) + nn[j] = nbn++; + else + nn[j] = -1; + KN< int > dln(7); + dln = 0; + // nn donne numero de noeud sur what + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOnWhat[i]; + + for (j = 0; j < kk; j++) { + int cc = c; + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOfNode[i] + dln[teb[j]->DFOnWhat[i]]; + for (i = 0; i < teb[j]->NbDoF; i++) dln[teb[j]->DFOnWhat[i]] = Max(dln[teb[j]->DFOnWhat[i]], data[cc++] + 1); } + for (j = 0; j < kk; j++) { + // w renumerotation des noeuds + // Ok si un noeud par what + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = nn[teb[j]->DFOnWhat[i]]; + } - for ( j=0;jNbDoF;i++) - data[c++] = nn[teb[j]->DFOnWhat[i]]; + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = j; // node from of FE + + for (j = 0; j < kk; j++) + for (i = 0; i < teb[j]->NbDoF; i++) + data[c++] = i; // node from of df in FE + // error -- here + // in case of [P2,P2],P1 + // we expect 0,0,1 and we get 0 1 2 + // => wrong BC ???? + int xx = 0; + for (j = 0; j < kk; j++) { + int xxx = xx; + for (i = 0; i < teb[j]->N; i++) { + data[c] = teb[j]->dim_which_sub_fem[i] + xx; + xxx = Max(xxx, data[c] + 1); + c++; + } + xx = xxx; } - for ( j=0;jNbDoF;i++) - data[c++] = j; // node from of FE - - - for ( j=0;jNbDoF;i++) - data[c++] = i; // node from of df in FE - // error -- here - //in case of [P2,P2],P1 - // we expect 0,0,1 and we get 0 1 2 - // => wrong BC ???? - int xx=0; - for (j=0;jN;i++) - { - data[c] = teb[j]->dim_which_sub_fem[i]+xx; - xxx=Max(xxx,data[c]+1); - c++; - } - xx=xxx; - } - - - // ou dans la partie miminal element finite atomic - - int ci=n; - int cf=2*n; - int cl=cf+N;; - int cj=0; - int ccc=0; - for ( j=0;jnb_sub_fem) - for ( i=0;iNbDoF;i++) - { - int il= teb[j]->fromASubDF[i]; - int jl= teb[j]->fromASubFE[i]; - data1[ci++]=il; - data1[cj++]=ccc+jl; - } - - for (int j=0,ccn=0 ; jNbDoF) - for(int k=0;kN;++k) - { - data1[cf++] = ccn + teb[j]->begin_dfcomp[k]; - data1[cl++] = ccn + teb[j]->end_dfcomp[k]; - } - ffassert(cl==2*n+2*N); - - ffassert(c== 5*n+N); -} - -class TypeOfFE_P1Lagrange : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P1Lagrange(): TypeOfFE(1,0,0,1,Data,1,1,3,3,Pi_h_coef) - { const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1) }; - for (int i=0;i & u,int componante,int op) const ; - -} ; -/////////////////////////////////////////////////////////////////////////////// -// FH pour tester des idee de schema ---- Juin 2005 --- -/////////////////////////////////////////////////////////////////////////////// - -// un VF cell centre -class TypeOfFE_P0VF : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P0VF(): TypeOfFE(1,0,0,1,Data,1,1,3,3,Pi_h_coef) - { const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1) }; - for (int i=0;i & u,int componante,int op) const ; - -} ; -int TypeOfFE_P0VF::Data[]={0,1,2, 0,0,0, 0,1,2, 0,0,0, 0,1,2, 0, 0,3}; -double TypeOfFE_P0VF::Pi_h_coef[]={1.,1.,1.}; // bofbof a verifier ... - - R TypeOfFE_P0VF::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const -{ - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); - R r=0; - if (op==0) - { - R l0=0,l1=PHat.x,l2=PHat.y; + // ou dans la partie miminal element finite atomic + + int ci = n; + int cf = 2 * n; + int cl = cf + N; + ; + int cj = 0; + int ccc = 0; + for (j = 0; j < kk; ccc += teb[j++]->nb_sub_fem) + for (i = 0; i < teb[j]->NbDoF; i++) { + int il = teb[j]->fromASubDF[i]; + int jl = teb[j]->fromASubFE[i]; + data1[ci++] = il; + data1[cj++] = ccc + jl; + } + + for (int j = 0, ccn = 0; j < kk; ccn += teb[j++]->NbDoF) + for (int k = 0; k < teb[j]->N; ++k) { + data1[cf++] = ccn + teb[j]->begin_dfcomp[k]; + data1[cl++] = ccn + teb[j]->end_dfcomp[k]; + } + ffassert(cl == 2 * n + 2 * N); + + ffassert(c == 5 * n + N); + } + + class TypeOfFE_P1Lagrange : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + TypeOfFE_P1Lagrange( ) : TypeOfFE(1, 0, 0, 1, Data, 1, 1, 3, 3, Pi_h_coef) { + const R2 Pt[] = {R2(0, 0), R2(1, 0), R2(0, 1)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + }; + /////////////////////////////////////////////////////////////////////////////// + // FH pour tester des idee de schema ---- Juin 2005 --- + /////////////////////////////////////////////////////////////////////////////// + + // un VF cell centre + class TypeOfFE_P0VF : public TypeOfFE { + public: + static int Data[]; + static double Pi_h_coef[]; + TypeOfFE_P0VF( ) : TypeOfFE(1, 0, 0, 1, Data, 1, 1, 3, 3, Pi_h_coef) { + const R2 Pt[] = {R2(0, 0), R2(1, 0), R2(0, 1)}; + for (int i = 0; i < NbDoF; i++) { + pij_alpha[i] = IPJ(i, i, 0); + P_Pi_h[i] = Pt[i]; + } + } + void FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const; + virtual R operator( )(const FElement &K, const RdHat &PHat, const KN_< R > &u, int componante, int op) const; + }; + int TypeOfFE_P0VF::Data[] = {0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 2, 0, 0, 3}; + double TypeOfFE_P0VF::Pi_h_coef[] = {1., 1., 1.}; // bofbof a verifier ... + + R TypeOfFE_P0VF::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); + R r = 0; + if (op == 0) { + R l0 = 0, l1 = PHat.x, l2 = PHat.y; l1 = l1 * 3. < 1; l2 = l2 * 3. < 1; - l0 = 1 - l1 -l2;// // FH & AS july 2020 + l0 = 1 - l1 - l2; // // FH & AS july 2020 - r = u0*l0+u1*l1+l2*u2; + r = u0 * l0 + u1 * l1 + l2 * u2; + } else { + r = 0; } - else - { - r =0; + return r; + } + + void TypeOfFE_P0VF::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + // const Triangle & K(FE.T); + if (whatd[op_id]) { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + l1 = l1 * 3. < 1; + l2 = l2 * 3. < 1; + l0 = 1 - l1 - l2; // FH & AS july 2020 + + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); + + val = 0; + RN_ f0(val('.', 0, op_id)); + + f0[0] = l0; + f0[1] = l1; + f0[2] = l2; } - return r; -} - - -void TypeOfFE_P0VF::FB(const bool *whatd,const Mesh & ,const Triangle & K,const RdHat & PHat,RNMK_ & val) const -{ -// const Triangle & K(FE.T); - if (whatd[op_id]) - { - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; - l1 = l1 * 3. < 1; - l2 = l2 * 3. < 1; - l0 = 1 - l1 -l2;// FH & AS july 2020 - - throwassert(val.N() >=3); - throwassert(val.M()==1 ); - - val=0; - RN_ f0(val('.',0,op_id)); - - f0[0] = l0; - f0[1] = l1; - f0[2] = l2;} - -} - - -/////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// NEW //////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -class TypeOfFE_P1Bubble : public TypeOfFE { public: - static int Data[]; - static double Pi_h_coef[]; - TypeOfFE_P1Bubble(): TypeOfFE(1,0,1,1,Data,1,1,4,4,Pi_h_coef) - { const R2 Pt[] = { R2(0,0), R2(1,0), R2(0,1), R2(1./3.,1./3.) }; - for (int i=0;icounter), - MaxNbNodePerElement(t->MaxNbNodePerElement), - MaxNbDFPerElement(t->MaxNbDFPerElement*k), - NodesOfElement(t->NodesOfElement), - FirstNodeOfElement(t->FirstNodeOfElement), - FirstDfOfNode(0), - NbOfElements(t->NbOfElements), - NbOfDF(t->NbOfDF*k), - NbOfNode(t->NbOfNode), - Nproduit(t->Nproduit*k) - { - throwassert(t==0 || t->FirstDfOfNode==0); - (*counter)++; // correction mai 2006 bug in counter incrementation - - } - -ConstructDataFElement::ConstructDataFElement (const Mesh &Th,/*int NbDfOnSommet,int ndfonEdge,int ndfonFace*/ -const KN & TFEs,const TypeOfMortar *tm, -int nbdfv,const int *ndfv,int nbdfe,const int *ndfe) -: counter(NewCounter()) -{ - Make(Th,TFEs,/*NbDfOnSommet,ndfonEdge,ndfonFace,*/ tm,nbdfv,ndfv,nbdfe,ndfe); -} - -ConstructDataFElement::ConstructDataFElement(const FESpace ** l,int k,const KN & TFEs) -: counter(NewCounter()) -{ - const Mesh & Th(l[0]->Th); - for (int i=0;iTh); - ffassert( l[i]->TFE.constant()); - } - - Make(Th,TFEs);//NbDfOnSommet,ndfonEdge,ndfonFace,0); -} - - -void ConstructDataFElement::Make(const Mesh &Th, -const KN & TFEs, - -/*int NbDfOnSommet,int ndfonEdge,int ndfonFace,*/const TypeOfMortar *tm, -int nb_dfv,const int *ndfv,int nb_dfe,const int *ndfe) -/* pour le condition de periodicit� .. - nb_dfv : nombre de sommets recolle par periodicit� - ndfv: numerotation des sommets pour CL de periodicite - ndfv[i] = numero du sommet i (i NbDFonNode(NbNodes), NodeIsOn(NbNodes); - NbDFonNode=0; - for (int df=0;dfcounter), MaxNbNodePerElement(t->MaxNbNodePerElement), MaxNbDFPerElement(t->MaxNbDFPerElement * k), NodesOfElement(t->NodesOfElement), FirstNodeOfElement(t->FirstNodeOfElement), + FirstDfOfNode(0), NbOfElements(t->NbOfElements), NbOfDF(t->NbOfDF * k), NbOfNode(t->NbOfNode), Nproduit(t->Nproduit * k) { + throwassert(t == 0 || t->FirstDfOfNode == 0); + (*counter)++; // correction mai 2006 bug in counter incrementation + } + + ConstructDataFElement::ConstructDataFElement(const Mesh &Th, /*int NbDfOnSommet,int ndfonEdge,int ndfonFace*/ + const KN< const TypeOfFE * > &TFEs, const TypeOfMortar *tm, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : counter(NewCounter( )) { + Make(Th, TFEs, /*NbDfOnSommet,ndfonEdge,ndfonFace,*/ tm, nbdfv, ndfv, nbdfe, ndfe); + } + + ConstructDataFElement::ConstructDataFElement(const FESpace **l, int k, const KN< const TypeOfFE * > &TFEs) : counter(NewCounter( )) { + const Mesh &Th(l[0]->Th); + for (int i = 0; i < k; i++) { + ffassert(&Th == &l[i]->Th); + ffassert(l[i]->TFE.constant( )); } - assert(NbDFonNode.sum() == nbdfe); - - NbNodeonVertex=TFE.NbNodeOnVertex; - NbNodeonEdge=TFE.NbNodeOnEdge; - NbNodeonElement=TFE.NbNodeOnElement; - - assert(NbNodeonVertex<=1); - assert(NbNodeonEdge<=1); - assert(NbNodeonElement<=1); - Nproduit =1; - const int ndf=NbDFonNode[0]; - int samendf=1; - - for (int i=1;i0, - ke=TFE.NbNodeOnEdge>0, - kt=TFE.NbNodeOnElement>0; - MaxNbNodePerElement=nbne; - - if ( ks && (!ke && ! kt) && (ndfv==0 && ndfe==0)) - {nn=Th.nv; - NodesOfElement=0; + + Make(Th, TFEs); // NbDfOnSommet,ndfonEdge,ndfonFace,0); + } + + void ConstructDataFElement::Make(const Mesh &Th, const KN< const TypeOfFE * > &TFEs, + + /*int NbDfOnSommet,int ndfonEdge,int ndfonFace,*/ const TypeOfMortar *tm, int nb_dfv, const int *ndfv, int nb_dfe, const int *ndfe) + /* pour le condition de periodicit� .. + nb_dfv : nombre de sommets recolle par periodicit� + ndfv: numerotation des sommets pour CL de periodicite + ndfv[i] = numero du sommet i (i NbDFonNode(NbNodes), NodeIsOn(NbNodes); + NbDFonNode = 0; + for (int df = 0; df < nbdfe; df++) { + int node = TFE.NodeOfDF[df]; + int what = TFE.DFOnWhat[df]; + int ndfonnode = TFE.DFOfNode[df]; + NbDFonNode[node] = Max(NbDFonNode[node], ndfonnode + 1); + NodeIsOn[node] = what; + } + assert(NbDFonNode.sum( ) == nbdfe); + + NbNodeonVertex = TFE.NbNodeOnVertex; + NbNodeonEdge = TFE.NbNodeOnEdge; + NbNodeonElement = TFE.NbNodeOnElement; + + assert(NbNodeonVertex <= 1); + assert(NbNodeonEdge <= 1); + assert(NbNodeonElement <= 1); + Nproduit = 1; + const int ndf = NbDFonNode[0]; + int samendf = 1; + + for (int i = 1; i < NbNodes; i++) + if (ndf != NbDFonNode[i]) { + samendf = 0; + break; } - else { -// constuction du tableau NodesOfElement bofbof -// computation of the length lne of array NodesOfElement - int lne= Th.nt*nbne; - if (Th.NbMortars) + int nbne = NbNodes; + int nn = 0; + int firstmul = 0; + ffassert(tm || Th.NbMortars == 0); + NbOfElements = Th.nt; // by default + // if mortars + int NbOfNodeL = 0; + NbOfElements += Th.NbMortars; + FirstDfOfNode = 0; + FirstNodeOfElement = 0; + MaxNbDFPerElement = nbdfe; + assert(3 * NbDfOnSommet + 3 * ndfonEdge + ndfonFace == MaxNbDFPerElement); + + int ks = TFE.NbNodeOnVertex > 0, ke = TFE.NbNodeOnEdge > 0, kt = TFE.NbNodeOnElement > 0; + MaxNbNodePerElement = nbne; + + if (ks && (!ke && !kt) && (ndfv == 0 && ndfe == 0)) { + nn = Th.nv; + NodesOfElement = 0; + } else { + // constuction du tableau NodesOfElement bofbof + + // computation of the length lne of array NodesOfElement + int lne = Th.nt * nbne; + if (Th.NbMortars) { + samendf = false; + NbOfNodeL = Th.NbMortars; + ffassert(tm); + FirstNodeOfElement = new int[NbOfElements + 1]; + int k = 0, kk = 0; + for (k = 0; k < Th.nt; k++, kk += nbne) FirstNodeOfElement[k] = kk; + + for (int im = 0; im < Th.NbMortars; im++) // (www) code { - samendf= false; - NbOfNodeL=Th.NbMortars; - ffassert(tm); - FirstNodeOfElement = new int[NbOfElements+1]; - int k=0,kk=0; - for (k=0;kNbOfNodes(Th,Th.mortars[im]); - } - FirstNodeOfElement[k++]=lne; + FirstNodeOfElement[k++] = lne; + lne += tm->NbOfNodes(Th, Th.mortars[im]); } + FirstNodeOfElement[k++] = lne; + } + + NodesOfElement = new int[lne]; + + for (int i = 0; i < lne; i++) NodesOfElement[i] = -1; + int i = 0; + int oe = 0; + if (ks) { + oe = 3 * NbNodeonVertex; + nn = (ndfv ? nb_dfv : Th.nv) * NbNodeonVertex; + } - NodesOfElement = new int[lne]; - - for (int i=0;i= 0 && jj >=0 && !(( kk == k ) && ( jj=j ) ) ) - { - if (k < kk ) kjj = NbNodeonEdge-kj-1; // - else kj = NbNodeonEdge-kj-1, kjj = NbNodeonEdge-kj-1; - } - if (kjj >=0) - NodesOfElement[kk*nbne+oe+jj] = nn + ndfe[be]*NbNodeonEdge+ kjj ; // adj - NodesOfElement[k*nbne+oe+j] = nn + ndfe[be]*NbNodeonEdge+ kj ; // new + if (kk >= 0 && jj >= 0 && !((kk == k) && (jj = j))) { + if (k < kk) + kjj = NbNodeonEdge - kj - 1; // + else + kj = NbNodeonEdge - kj - 1, kjj = NbNodeonEdge - kj - 1; + } + if (kjj >= 0) NodesOfElement[kk * nbne + oe + jj] = nn + ndfe[be] * NbNodeonEdge + kjj; // adj + NodesOfElement[k * nbne + oe + j] = nn + ndfe[be] * NbNodeonEdge + kj; // new } - } - nn += nb_dfe; } - for (int k=0;k=k && jjj == jj); - NodesOfElement[kk*nbne+oe+jjj] = nn ; // adj - NodesOfElement[i++] = nn++ ; // new - } else i++; - } - for (int jj=0;jj= k && jjj == jj); + NodesOfElement[kk * nbne + oe + jjj] = nn; // adj + NodesOfElement[i++] = nn++; // new + } else + i++; } - firstmul=nn; - if (Th.NbMortars) - { - // construction of the mortars element - int * color= new int [firstmul]; - int thecolor=0; - for (int j=0;j adding - { - color[node] = thecolor; - NodesOfElement[i++] = node; - } - } - } - ffassert(i==FirstNodeOfElement[im+Th.nt+1]); + for (int jj = 0; jj < NbNodeonElement; jj++) NodesOfElement[i++] = nn++; + } + firstmul = nn; + if (Th.NbMortars) { + // construction of the mortars element + int *color = new int[firstmul]; + int thecolor = 0; + for (int j = 0; j < firstmul; j++) color[j] = thecolor; + + for (int im = 0; im < Th.NbMortars; im++) { + thecolor++; // get a new color + Mortar &M(Th.mortars[im]); + NodesOfElement[i++] = nn++; // the first node is the lag. mul. + int n = M.NbT( ); + for (int kk = 0; kk < n; kk++) { + int K, e; + K = M.T_e(kk, e); + int kb = FirstNodeOfElement[K]; + int ke = FirstNodeOfElement[K + 1]; + for (int j = kb, jj = 0; j < ke; j++, jj++) + if (onWhatIsEdge[e][NodeIsOn[jj]]) { // the node jj is on edge e + int node = NodesOfElement[j]; + throwassert(node < firstmul); + if (color[node] != thecolor) // new node => adding + { + color[node] = thecolor; + NodesOfElement[i++] = node; + } } - delete [] color; } - else - ffassert(i==Th.nt*nbne && i ); - NbOfNode=nn; - - - } - NbOfNode=nn; - int NbOfDFL=0; - if (! samendf) - { - - ffassert(NodesOfElement); - FirstDfOfNode= new int [nn+1]; - for (int i=0;i<=nn;i++) FirstDfOfNode[i]=-1; - int i=0; - // the classical part (FEM) - for (int k=0;kNbLagrangeMult(Th,Th.mortars[km]); // On node par - int nodemul = NodesOfElement[fk]; // the first node is the lagr. mul. - throwassert(FirstDfOfNode[nodemul+1]==-1); - FirstDfOfNode[nodemul+1]= ndlmul; - NbOfDFL += ndlmul; - int nbdle=0; - for (int j=fk;j2) - { - cout << " FESpace: Nb Of Nodes = " << nn ; - if(NbOfNodeL) - cout << " Nb of Lagrange Mul Node = " << NbOfNodeL ; - cout << " Nb of DF = " << NbOfDF << endl; - if(NbOfDFL) { - cout << " Nb of Lagrange Mul DF = " << NbOfDFL ; - cout << " MaxNbDFPerElement = " << MaxNbDFPerElement ; - }; - cout << endl; - } -} - -FESpace::FESpace(const FESpace & Vh,int k ) - : - Th(Vh.Th), - ptrTFE(new TypeOfFEProduit(k,*Vh.TFE[0])), - TFE(1,0,ptrTFE), - cdef(Vh.cdef?new ConstructDataFElement(Vh.cdef,k):0), - cmesh(Vh.Th), - N(Vh.N*k), - Nproduit(Vh.Nproduit*k), - NbOfDF(Vh.NbOfDF*k), - NbOfElements(Vh.NbOfElements), - NbOfNodes(Vh.NbOfNodes), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - NodesOfElement(Vh.NodesOfElement), - FirstNodeOfElement(Vh.FirstNodeOfElement), - FirstDfOfNodeData(cdef?cdef->FirstDfOfNode:0), - tom(0), - MaxNbNodePerElement(Vh.MaxNbNodePerElement), - MaxNbDFPerElement(Vh.MaxNbDFPerElement*k) -{ - // correction mai 2006 no renumbering of existing cdef - if(cdef && (Vh.cdef && Vh.cdef->counter != cdef->counter)) { - renum(); // correction mai 2006 no renumbering of existing cdef - } - Show(); - } - -FESpace::FESpace(const FESpace ** Vh,int k ) - : - Th((**Vh).Th), - ptrTFE(new TypeOfFESum(Vh,k)), - TFE(1,0,ptrTFE), - cdef(new ConstructDataFElement(Vh,k,TFE)), - cmesh((**Vh).Th), - N(sum(Vh,&FESpace::N,k)), - Nproduit(cdef->Nproduit), - NbOfDF(cdef->NbOfDF), - NbOfElements(cdef->NbOfElements), - NbOfNodes(cdef->NbOfNode), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - NodesOfElement(cdef->NodesOfElement), - FirstNodeOfElement(cdef->FirstNodeOfElement), - FirstDfOfNodeData(cdef->FirstDfOfNode), - tom(0) , - MaxNbNodePerElement(cdef->MaxNbNodePerElement), - MaxNbDFPerElement(cdef->MaxNbDFPerElement) -{ - if(cdef) renum(); - Show(); - // verification - long snbdf=0; - for(int i=0;iNbOfDF; - if( snbdf !=NbOfDF) - cerr << " Problem build of FEspace (2d) (may be : due to periodic Boundary condition missing ) FH " << endl - << " The number of DF must be " << snbdf << " and it is " << NbOfDF <Nproduit), - - NbOfDF(cdef->NbOfDF), - NbOfElements(cdef->NbOfElements), - NbOfNodes(cdef->NbOfNode), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - NodesOfElement(cdef->NodesOfElement), - FirstNodeOfElement(cdef->FirstNodeOfElement), - FirstDfOfNodeData(cdef->FirstDfOfNode), - tom(0) , - MaxNbNodePerElement(cdef->MaxNbNodePerElement), - MaxNbDFPerElement(cdef->MaxNbDFPerElement) -{ - if(cdef) renum(); - Show(); -} - - - FESpace::FESpace(const Mesh & TTh,const TypeOfFE & tef,int nbdfv,const int *ndfv,int nbdfe,const int *ndfe) - : - Th(TTh), - ptrTFE(0), - TFE(1,0,&tef), - cdef(new ConstructDataFElement(TTh,TFE,0,nbdfv,ndfv,nbdfe,ndfe)), - cmesh(TTh), - N(tef.N), - Nproduit(cdef->Nproduit), - NbOfDF(cdef->NbOfDF), - NbOfElements(cdef->NbOfElements), - NbOfNodes(cdef->NbOfNode), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - NodesOfElement(cdef->NodesOfElement), - FirstNodeOfElement(cdef->FirstNodeOfElement), - FirstDfOfNodeData(cdef->FirstDfOfNode), - tom(0), - MaxNbNodePerElement(cdef->MaxNbNodePerElement), - MaxNbDFPerElement(cdef->MaxNbDFPerElement) -{ - if(tef.ndfonVertex || tef.ndfonEdge) renum(); - Show(); -} - - FESpace::~FESpace() - { - SHOWVERB(cout << " FESpace::~FESpace() " << endl); - delete cdef; - if(ptrTFE) - delete ptrTFE; - } - - FESpace::FESpace(const Mesh & TTh,const TypeOfFE & tef,const TypeOfMortar & tm) - : - Th(TTh), - ptrTFE(0), - TFE(1,0,&tef), - cdef(new ConstructDataFElement(TTh,TFE,&tm)),//tef.ndfonVertex,tef.ndfonEdge,tef.ndfonFace,&tm)), - cmesh(TTh), - N(tef.N), - Nproduit(1), - NbOfDF(cdef->NbOfDF), - NbOfElements(cdef->NbOfElements), - NbOfNodes(cdef->NbOfNode), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - NodesOfElement(cdef->NodesOfElement), - FirstNodeOfElement(cdef->FirstNodeOfElement), - FirstDfOfNodeData(cdef->FirstDfOfNode), - tom(&tm), - MaxNbNodePerElement(cdef->MaxNbNodePerElement), - MaxNbDFPerElement(cdef->MaxNbDFPerElement) -{ - renum(); - Show(); - } - -void ConstructDataFElement::renum(const long *r,int l) - { - ffassert(this); - if (NodesOfElement) - for (int i=0;i< l ; i++) - NodesOfElement[i]=r[NodesOfElement[i]]; - if(FirstDfOfNode) - { int k,i,*n=new int[NbOfNode]; - for ( i=0;iFB(whatd,Th,K,PHat,v); - else - v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); - } - } - R TypeOfFE_P1Lagrange::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const -{ - R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); - R r=0; - if (op==op_id) - { - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; - r = u0*l0+u1*l1+l2*u2; - } - else - { - const Triangle & T=K.T; - R2 D0 = T.H(0) , D1 = T.H(1) , D2 = T.H(2) ; - if (op==op_dx) - r = D0.x*u0 + D1.x*u1 + D2.x*u2 ; - else if(op==op_dy) - r = D0.y*u0 + D1.y*u1 + D2.y*u2 ; - } - return r; -} - - -void TypeOfFE_P1Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,const RdHat & PHat,RNMK_ & val) const -{ - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; + NbOfNode = nn; + int NbOfDFL = 0; + if (!samendf) { + + ffassert(NodesOfElement); + FirstDfOfNode = new int[nn + 1]; + for (int i = 0; i <= nn; i++) FirstDfOfNode[i] = -1; + int i = 0; + // the classical part (FEM) + for (int k = 0; k < Th.nt; k++) + for (int j = 0; j < nbne; j++) // thanks to student + FirstDfOfNode[NodesOfElement[i++] + 1] = NbDFonNode[j]; + // the mortars parts juste the mulplicator + + for (int km = 0, k = Th.nt; km < Th.NbMortars; km++, k++) { // the lag. mult. is the first node of the mortar -- + throwassert(FirstNodeOfElement); + // hack + int fk = FirstNodeOfElement[k]; + int lk = FirstNodeOfElement[k + 1]; + int ndlmul = tm->NbLagrangeMult(Th, Th.mortars[km]); // On node par + int nodemul = NodesOfElement[fk]; // the first node is the lagr. mul. + throwassert(FirstDfOfNode[nodemul + 1] == -1); + FirstDfOfNode[nodemul + 1] = ndlmul; + NbOfDFL += ndlmul; + int nbdle = 0; + for (int j = fk; j < lk; j++) nbdle += FirstDfOfNode[NodesOfElement[j] + 1]; + MaxNbDFPerElement = Max(MaxNbDFPerElement, nbdle); + } - throwassert(val.N() >=3); - throwassert(val.M()==1 ); + FirstDfOfNode[0] = 0; + for (int i = 0; i <= nn; i++) throwassert(FirstDfOfNode[i] != -1); - val=0; - RN_ f0(val('.',0,op_id)); + for (int i = 0; i < nn; i++) FirstDfOfNode[i + 1] += FirstDfOfNode[i]; + NbOfDF = FirstDfOfNode[nn]; + } else { + NbOfDF = nn * ndf; + Nproduit = ndf; + } + MaxNbNodePerElement = nbne; + if (verbosity > 2) { + cout << " FESpace: Nb Of Nodes = " << nn; + if (NbOfNodeL) cout << " Nb of Lagrange Mul Node = " << NbOfNodeL; + cout << " Nb of DF = " << NbOfDF << endl; + if (NbOfDFL) { + cout << " Nb of Lagrange Mul DF = " << NbOfDFL; + cout << " MaxNbDFPerElement = " << MaxNbDFPerElement; + }; + cout << endl; + } + } - if (whatd[op_id]) - { - f0[0] = l0; - f0[1] = l1; - f0[2] = l2;} - if (whatd[op_dx] || whatd[op_dy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x; - f0x[1] = Dl1.x; - f0x[2] = Dl2.x; + FESpace::FESpace(const FESpace &Vh, int k) + : Th(Vh.Th), ptrTFE(new TypeOfFEProduit(k, *Vh.TFE[0])), TFE(1, 0, ptrTFE), cdef(Vh.cdef ? new ConstructDataFElement(Vh.cdef, k) : 0), cmesh(Vh.Th), N(Vh.N * k), Nproduit(Vh.Nproduit * k), + NbOfDF(Vh.NbOfDF * k), NbOfElements(Vh.NbOfElements), NbOfNodes(Vh.NbOfNodes), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), NodesOfElement(Vh.NodesOfElement), + FirstNodeOfElement(Vh.FirstNodeOfElement), FirstDfOfNodeData(cdef ? cdef->FirstDfOfNode : 0), tom(0), MaxNbNodePerElement(Vh.MaxNbNodePerElement), MaxNbDFPerElement(Vh.MaxNbDFPerElement * k) { + // correction mai 2006 no renumbering of existing cdef + if (cdef && (Vh.cdef && Vh.cdef->counter != cdef->counter)) { + renum( ); // correction mai 2006 no renumbering of existing cdef + } + Show( ); } - if (whatd[op_dy]) { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y; - f0y[1] = Dl1.y; - f0y[2] = Dl2.y; + FESpace::FESpace(const FESpace **Vh, int k) + : Th((**Vh).Th), ptrTFE(new TypeOfFESum(Vh, k)), TFE(1, 0, ptrTFE), cdef(new ConstructDataFElement(Vh, k, TFE)), cmesh((**Vh).Th), N(sum(Vh, &FESpace::N, k)), Nproduit(cdef->Nproduit), + NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + NodesOfElement(cdef->NodesOfElement), FirstNodeOfElement(cdef->FirstNodeOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), tom(0), MaxNbNodePerElement(cdef->MaxNbNodePerElement), + MaxNbDFPerElement(cdef->MaxNbDFPerElement) { + if (cdef) renum( ); + Show( ); + // verification + long snbdf = 0; + for (int i = 0; i < k; ++i) snbdf += Vh[i]->NbOfDF; + if (snbdf != NbOfDF) + cerr << " Problem build of FEspace (2d) (may be : due to periodic Boundary condition missing ) FH " << endl << " The number of DF must be " << snbdf << " and it is " << NbOfDF << endl; + ffassert(snbdf == NbOfDF); } + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE **tef, int k, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : Th(TTh), ptrTFE(new TypeOfFESum(tef, k)), TFE(1, 0, ptrTFE), cdef(new ConstructDataFElement(TTh, TFE, // sum(tef,&TypeOfFE::ndfonVertex,k), + // sum(tef,&TypeOfFE::ndfonEdge,k), + // sum(tef,&TypeOfFE::ndfonFace,k), + 0, nbdfv, ndfv, nbdfe, ndfe)), + cmesh(TTh), N(sum(tef, &TypeOfFE::N, k)), Nproduit(cdef->Nproduit), + + NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + NodesOfElement(cdef->NodesOfElement), FirstNodeOfElement(cdef->FirstNodeOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), tom(0), MaxNbNodePerElement(cdef->MaxNbNodePerElement), + MaxNbDFPerElement(cdef->MaxNbDFPerElement) { + if (cdef) renum( ); + Show( ); } -} - -/////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// NEW ///////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - - -void TypeOfFE_P1Bubble::FB(const bool *whatd,const Mesh & ,const Triangle & K,const RdHat & PHat,RNMK_ & val) const -{ - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-PHat.x-PHat.y, l1=PHat.x, l2=PHat.y, lb=l0*l1*l2*9.; - - throwassert(val.N() >=4); - throwassert(val.M()==1 ); - - val=0; - RN_ f0(val('.',0,op_id)); - - if (whatd[op_id]) - { - f0[0] = l0-lb; - f0[1] = l1-lb; - f0[2] = l2-lb; - f0[3] = 3.*lb; - } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), - Dlb((Dl0*l1*l2+Dl1*l0*l2+Dl2*l0*l1)*9.); - - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x-Dlb.x; - f0x[1] = Dl1.x-Dlb.x; - f0x[2] = Dl2.x-Dlb.x; - f0x[3] = 3.*Dlb.x; + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE &tef, int nbdfv, const int *ndfv, int nbdfe, const int *ndfe) + : Th(TTh), ptrTFE(0), TFE(1, 0, &tef), cdef(new ConstructDataFElement(TTh, TFE, 0, nbdfv, ndfv, nbdfe, ndfe)), cmesh(TTh), N(tef.N), Nproduit(cdef->Nproduit), NbOfDF(cdef->NbOfDF), + NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), NodesOfElement(cdef->NodesOfElement), + FirstNodeOfElement(cdef->FirstNodeOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), tom(0), MaxNbNodePerElement(cdef->MaxNbNodePerElement), MaxNbDFPerElement(cdef->MaxNbDFPerElement) { + if (tef.ndfonVertex || tef.ndfonEdge) renum( ); + Show( ); } - if (whatd[op_dy]) { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y-Dlb.y; - f0y[1] = Dl1.y-Dlb.y; - f0y[2] = Dl2.y-Dlb.y; - f0y[3] = 3.*Dlb.y; + FESpace::~FESpace( ) { + SHOWVERB(cout << " FESpace::~FESpace() " << endl); + delete cdef; + if (ptrTFE) delete ptrTFE; } - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - R lbdxx= 18*((Dl0.x*Dl1.x)*l2+(Dl1.x*Dl2.x)*l0+(Dl2.x*Dl0.x)*l1); - fxx[0] = -lbdxx; - fxx[1] = -lbdxx; - fxx[2] = -lbdxx; - fxx[3] = 3*lbdxx; + + FESpace::FESpace(const Mesh &TTh, const TypeOfFE &tef, const TypeOfMortar &tm) + : Th(TTh), ptrTFE(0), TFE(1, 0, &tef), cdef(new ConstructDataFElement(TTh, TFE, &tm)), // tef.ndfonVertex,tef.ndfonEdge,tef.ndfonFace,&tm)), + cmesh(TTh), N(tef.N), Nproduit(1), NbOfDF(cdef->NbOfDF), NbOfElements(cdef->NbOfElements), NbOfNodes(cdef->NbOfNode), nb_sub_fem(TFE[0]->nb_sub_fem), + dim_which_sub_fem(TFE[0]->dim_which_sub_fem), NodesOfElement(cdef->NodesOfElement), FirstNodeOfElement(cdef->FirstNodeOfElement), FirstDfOfNodeData(cdef->FirstDfOfNode), tom(&tm), + MaxNbNodePerElement(cdef->MaxNbNodePerElement), MaxNbDFPerElement(cdef->MaxNbDFPerElement) { + renum( ); + Show( ); } - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - R lbdyy= 18*((Dl0.y*Dl1.y)*l2+(Dl1.y*Dl2.y)*l0+(Dl2.y*Dl0.y)*l1); + void ConstructDataFElement::renum(const long *r, int l) { + ffassert(this); + if (NodesOfElement) + for (int i = 0; i < l; i++) NodesOfElement[i] = r[NodesOfElement[i]]; + if (FirstDfOfNode) { + int k, i, *n = new int[NbOfNode]; + for (i = 0; i < NbOfNode; i++) n[r[i]] = FirstDfOfNode[i + 1] - FirstDfOfNode[i]; + FirstDfOfNode[0] = k = 0; + for (i = 0; i < NbOfNode;) { + k += n[i]; + FirstDfOfNode[++i] = k; + } + delete[] n; + } + } - fyy[0] = -lbdyy; - fyy[1] = -lbdyy; - fyy[2] = -lbdyy; - fyy[3] = 3*lbdyy; + void TypeOfFEProduit::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + int n = teb.NbDoF; + int m = teb.N; + val = 0.0; + SubArray t(val.K( )); + RNMK_ v(val(SubArray(n, 0, k), SubArray(m), t)); + teb.FB(whatd, Th, K, PHat, v); + for (int i = 1; i < k; i++) val(SubArray(n, i, k), SubArray(m, m * i), t) = v; } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - R lbdxy= 9*(Dl0.x*Dl1.y+ Dl0.y*Dl1.x)*l2+(Dl1.x*Dl2.y+Dl1.y*Dl2.x)*l0+(Dl2.x*Dl0.y+Dl2.y*Dl0.x)*l1; - fxy[0] = 4*Dl0.x*Dl0.y-lbdxy; - fxy[1] = 4*Dl1.x*Dl1.y-lbdxy; - fxy[2] = 4*Dl2.x*Dl2.y-lbdxy; - fxy[3] = +3*lbdxy; + + void TypeOfFESum::FB(const bool *whatd, const Mesh &Th, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + val = 0.0; + SubArray t(val.K( )); + for (int i = 0; i < k; i++) { + int j = comp[i]; + int ni = NN[i]; + int di = DF[i]; + int i1 = i + 1; + int nii = NN[i1]; + int dii = DF[i1]; + throwassert(ni < nii && di < dii); + RNMK_ v(val(SubArray(dii - di, di), SubArray(nii - ni, ni), t)); + if (j <= i) + teb[i]->FB(whatd, Th, K, PHat, v); + else + v = val(SubArray(DF[j + 1] - DF[j], DF[j]), SubArray(NN[j + 1] - NN[j], NN[j]), t); + } } + R TypeOfFE_P1Lagrange::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R u0(u(K(0))), u1(u(K(1))), u2(u(K(2))); + R r = 0; + if (op == op_id) { + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + r = u0 * l0 + u1 * l1 + l2 * u2; + } else { + const Triangle &T = K.T; + R2 D0 = T.H(0), D1 = T.H(1), D2 = T.H(2); + if (op == op_dx) + r = D0.x * u0 + D1.x * u1 + D2.x * u2; + else if (op == op_dy) + r = D0.y * u0 + D1.y * u1 + D2.y * u2; + } + return r; } -} -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// + void TypeOfFE_P1Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; -void TypeOfFE_P2Lagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,const RdHat & PHat,RNMK_ & val) const -{ - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y; - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); + throwassert(val.N( ) >= 3); + throwassert(val.M( ) == 1); - throwassert( val.N()>=6); - throwassert(val.M()==1); + val = 0; + RN_ f0(val('.', 0, op_id)); - val=0; - if (whatd[op_id]) - { - RN_ f0(val('.',0,op_id)); - f0[0] = l0*(2*l0-1); - f0[1] = l1*(2*l1-1); - f0[2] = l2*(2*l2-1); - f0[3] = 4*l1*l2; // oppose au sommet 0 - f0[4] = 4*l0*l2; // oppose au sommet 1 - f0[5] = 4*l1*l0; // oppose au sommet 3 - } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x*l4_0; - f0x[1] = Dl1.x*l4_1; - f0x[2] = Dl2.x*l4_2; - f0x[3] = 4*(Dl1.x*l2 + Dl2.x*l1) ; - f0x[4] = 4*(Dl2.x*l0 + Dl0.x*l2) ; - f0x[5] = 4*(Dl0.x*l1 + Dl1.x*l0) ; - } - - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y*l4_0; - f0y[1] = Dl1.y*l4_1; - f0y[2] = Dl2.y*l4_2; - f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) ; - f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) ; - f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) ; - } + if (whatd[op_id]) { + f0[0] = l0; + f0[1] = l1; + f0[2] = l2; + } + if (whatd[op_dx] || whatd[op_dy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x; + f0x[1] = Dl1.x; + f0x[2] = Dl2.x; + } - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - - fxx[0] = 4*Dl0.x*Dl0.x; - fxx[1] = 4*Dl1.x*Dl1.x; - fxx[2] = 4*Dl2.x*Dl2.x; - fxx[3] = 8*Dl1.x*Dl2.x; - fxx[4] = 8*Dl0.x*Dl2.x; - fxx[5] = 8*Dl0.x*Dl1.x; + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y; + f0y[1] = Dl1.y; + f0y[2] = Dl2.y; + } + } } - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - fyy[0] = 4*Dl0.y*Dl0.y; - fyy[1] = 4*Dl1.y*Dl1.y; - fyy[2] = 4*Dl2.y*Dl2.y; - fyy[3] = 8*Dl1.y*Dl2.y; - fyy[4] = 8*Dl0.y*Dl2.y; - fyy[5] = 8*Dl0.y*Dl1.y; - } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - - fxy[0] = 4*Dl0.x*Dl0.y; - fxy[1] = 4*Dl1.x*Dl1.y; - fxy[2] = 4*Dl2.x*Dl2.y; - fxy[3] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x); - fxy[4] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x); - fxy[5] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x); - } + /////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// NEW ///////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// - } + void TypeOfFE_P1Bubble::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y, lb = l0 * l1 * l2 * 9.; -} + throwassert(val.N( ) >= 4); + throwassert(val.M( ) == 1); + val = 0; + RN_ f0(val('.', 0, op_id)); -void TypeOfFE_P2bLagrange::FB(const bool *whatd,const Mesh & ,const Triangle & K,const RdHat & PHat,RNMK_ & val) const -{ - R2 A(K[0]), B(K[1]),C(K[2]); - R l0=1-PHat.x-PHat.y,l1=PHat.x,l2=PHat.y,lb=l0*l1*l2*3.; - R l4_0=(4*l0-1),l4_1=(4*l1-1),l4_2=(4*l2-1); + if (whatd[op_id]) { + f0[0] = l0 - lb; + f0[1] = l1 - lb; + f0[2] = l2 - lb; + f0[3] = 3. * lb; + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), Dlb((Dl0 * l1 * l2 + Dl1 * l0 * l2 + Dl2 * l0 * l1) * 9.); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x - Dlb.x; + f0x[1] = Dl1.x - Dlb.x; + f0x[2] = Dl2.x - Dlb.x; + f0x[3] = 3. * Dlb.x; + } - throwassert( val.N()>=7); - throwassert(val.M()==1); + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y - Dlb.y; + f0y[1] = Dl1.y - Dlb.y; + f0y[2] = Dl2.y - Dlb.y; + f0y[3] = 3. * Dlb.y; + } + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + R lbdxx = 18 * ((Dl0.x * Dl1.x) * l2 + (Dl1.x * Dl2.x) * l0 + (Dl2.x * Dl0.x) * l1); + fxx[0] = -lbdxx; + fxx[1] = -lbdxx; + fxx[2] = -lbdxx; + fxx[3] = 3 * lbdxx; + } - val=0; - if (whatd[op_id]) - { - R lb4=lb*4; - RN_ f0(val('.',0,op_id)); - f0[0] = l0*(2*l0-1)+lb; - f0[1] = l1*(2*l1-1)+lb; - f0[2] = l2*(2*l2-1)+lb; - f0[3] = 4*l1*l2-lb4; // oppose au sommet 0 - f0[4] = 4*l0*l2-lb4; // oppose au sommet 1 - f0[5] = 4*l1*l0-lb4; // oppose au sommet 3 - f0[6] = 9*lb; + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + R lbdyy = 18 * ((Dl0.y * Dl1.y) * l2 + (Dl1.y * Dl2.y) * l0 + (Dl2.y * Dl0.y) * l1); + fyy[0] = -lbdyy; + fyy[1] = -lbdyy; + fyy[2] = -lbdyy; + fyy[3] = 3 * lbdyy; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + R lbdxy = 9 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x) * l2 + (Dl1.x * Dl2.y + Dl1.y * Dl2.x) * l0 + (Dl2.x * Dl0.y + Dl2.y * Dl0.x) * l1; + fxy[0] = 4 * Dl0.x * Dl0.y - lbdxy; + fxy[1] = 4 * Dl1.x * Dl1.y - lbdxy; + fxy[2] = 4 * Dl2.x * Dl2.y - lbdxy; + fxy[3] = +3 * lbdxy; + } + } } - if( whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) - { - R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), Dlb((Dl0*l1*l2+Dl1*l0*l2+Dl2*l0*l1)*3.), - Dlb4(Dlb*4.); + /////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// + + void TypeOfFE_P2Lagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y; + R l4_0 = (4 * l0 - 1), l4_1 = (4 * l1 - 1), l4_2 = (4 * l2 - 1); + + throwassert(val.N( ) >= 6); + throwassert(val.M( ) == 1); + + val = 0; + if (whatd[op_id]) { + RN_ f0(val('.', 0, op_id)); + f0[0] = l0 * (2 * l0 - 1); + f0[1] = l1 * (2 * l1 - 1); + f0[2] = l2 * (2 * l2 - 1); + f0[3] = 4 * l1 * l2; // oppose au sommet 0 + f0[4] = 4 * l0 * l2; // oppose au sommet 1 + f0[5] = 4 * l1 * l0; // oppose au sommet 3 + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)); + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x * l4_0; + f0x[1] = Dl1.x * l4_1; + f0x[2] = Dl2.x * l4_2; + f0x[3] = 4 * (Dl1.x * l2 + Dl2.x * l1); + f0x[4] = 4 * (Dl2.x * l0 + Dl0.x * l2); + f0x[5] = 4 * (Dl0.x * l1 + Dl1.x * l0); + } - if (whatd[op_dx]) - { - RN_ f0x(val('.',0,op_dx)); - f0x[0] = Dl0.x*l4_0 +Dlb.x; - f0x[1] = Dl1.x*l4_1 +Dlb.x; - f0x[2] = Dl2.x*l4_2 +Dlb.x; - f0x[3] = 4*(Dl1.x*l2 + Dl2.x*l1) -Dlb4.x; - f0x[4] = 4*(Dl2.x*l0 + Dl0.x*l2) -Dlb4.x; - f0x[5] = 4*(Dl0.x*l1 + Dl1.x*l0) -Dlb4.x; - f0x[6] = 9.*Dlb.x; - } + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y * l4_0; + f0y[1] = Dl1.y * l4_1; + f0y[2] = Dl2.y * l4_2; + f0y[3] = 4 * (Dl1.y * l2 + Dl2.y * l1); + f0y[4] = 4 * (Dl2.y * l0 + Dl0.y * l2); + f0y[5] = 4 * (Dl0.y * l1 + Dl1.y * l0); + } - if (whatd[op_dy]) - { - RN_ f0y(val('.',0,op_dy)); - f0y[0] = Dl0.y*l4_0 +Dlb.y; - f0y[1] = Dl1.y*l4_1 +Dlb.y; - f0y[2] = Dl2.y*l4_2 +Dlb.y; - f0y[3] = 4*(Dl1.y*l2 + Dl2.y*l1) -Dlb4.y; - f0y[4] = 4*(Dl2.y*l0 + Dl0.y*l2) -Dlb4.y; - f0y[5] = 4*(Dl0.y*l1 + Dl1.y*l0) -Dlb4.y; - f0y[6] = 9*Dlb.y; + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + fxx[0] = 4 * Dl0.x * Dl0.x; + fxx[1] = 4 * Dl1.x * Dl1.x; + fxx[2] = 4 * Dl2.x * Dl2.x; + fxx[3] = 8 * Dl1.x * Dl2.x; + fxx[4] = 8 * Dl0.x * Dl2.x; + fxx[5] = 8 * Dl0.x * Dl1.x; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + fyy[0] = 4 * Dl0.y * Dl0.y; + fyy[1] = 4 * Dl1.y * Dl1.y; + fyy[2] = 4 * Dl2.y * Dl2.y; + fyy[3] = 8 * Dl1.y * Dl2.y; + fyy[4] = 8 * Dl0.y * Dl2.y; + fyy[5] = 8 * Dl0.y * Dl1.y; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + + fxy[0] = 4 * Dl0.x * Dl0.y; + fxy[1] = 4 * Dl1.x * Dl1.y; + fxy[2] = 4 * Dl2.x * Dl2.y; + fxy[3] = 4 * (Dl1.x * Dl2.y + Dl1.y * Dl2.x); + fxy[4] = 4 * (Dl0.x * Dl2.y + Dl0.y * Dl2.x); + fxy[5] = 4 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x); + } + } } - if (whatd[op_dxx]) - { - RN_ fxx(val('.',0,op_dxx)); - R lbdxx= 6*((Dl0.x*Dl1.x)*l2+(Dl1.x*Dl2.x)*l0+(Dl2.x*Dl0.x)*l1); - R lbd4xx= 4*lbdxx; - - fxx[0] = 4*Dl0.x*Dl0.x + lbdxx; - fxx[1] = 4*Dl1.x*Dl1.x + lbdxx;; - fxx[2] = 4*Dl2.x*Dl2.x + lbdxx;; - fxx[3] = 8*Dl1.x*Dl2.x - lbd4xx; - fxx[4] = 8*Dl0.x*Dl2.x - lbd4xx; - fxx[5] = 8*Dl0.x*Dl1.x - lbd4xx; - fxx[6] = 9*lbdxx; + void TypeOfFE_P2bLagrange::FB(const bool *whatd, const Mesh &, const Triangle &K, const RdHat &PHat, RNMK_ &val) const { + R2 A(K[0]), B(K[1]), C(K[2]); + R l0 = 1 - PHat.x - PHat.y, l1 = PHat.x, l2 = PHat.y, lb = l0 * l1 * l2 * 3.; + R l4_0 = (4 * l0 - 1), l4_1 = (4 * l1 - 1), l4_2 = (4 * l2 - 1); + + throwassert(val.N( ) >= 7); + throwassert(val.M( ) == 1); + + val = 0; + if (whatd[op_id]) { + R lb4 = lb * 4; + RN_ f0(val('.', 0, op_id)); + f0[0] = l0 * (2 * l0 - 1) + lb; + f0[1] = l1 * (2 * l1 - 1) + lb; + f0[2] = l2 * (2 * l2 - 1) + lb; + f0[3] = 4 * l1 * l2 - lb4; // oppose au sommet 0 + f0[4] = 4 * l0 * l2 - lb4; // oppose au sommet 1 + f0[5] = 4 * l1 * l0 - lb4; // oppose au sommet 3 + f0[6] = 9 * lb; + } + if (whatd[op_dx] || whatd[op_dy] || whatd[op_dxx] || whatd[op_dyy] || whatd[op_dxy]) { + R2 Dl0(K.H(0)), Dl1(K.H(1)), Dl2(K.H(2)), Dlb((Dl0 * l1 * l2 + Dl1 * l0 * l2 + Dl2 * l0 * l1) * 3.), Dlb4(Dlb * 4.); + + if (whatd[op_dx]) { + RN_ f0x(val('.', 0, op_dx)); + f0x[0] = Dl0.x * l4_0 + Dlb.x; + f0x[1] = Dl1.x * l4_1 + Dlb.x; + f0x[2] = Dl2.x * l4_2 + Dlb.x; + f0x[3] = 4 * (Dl1.x * l2 + Dl2.x * l1) - Dlb4.x; + f0x[4] = 4 * (Dl2.x * l0 + Dl0.x * l2) - Dlb4.x; + f0x[5] = 4 * (Dl0.x * l1 + Dl1.x * l0) - Dlb4.x; + f0x[6] = 9. * Dlb.x; } - if (whatd[op_dyy]) - { - RN_ fyy(val('.',0,op_dyy)); - R lbdyy= 6*((Dl0.y*Dl1.y)*l2+(Dl1.y*Dl2.y)*l0+(Dl2.y*Dl0.y)*l1); - R lbd4yy= lbdyy*4; - - fyy[0] = 4*Dl0.y*Dl0.y + lbdyy; - fyy[1] = 4*Dl1.y*Dl1.y + lbdyy; - fyy[2] = 4*Dl2.y*Dl2.y + lbdyy; - fyy[3] = 8*Dl1.y*Dl2.y - lbd4yy; - fyy[4] = 8*Dl0.y*Dl2.y - lbd4yy; - fyy[5] = 8*Dl0.y*Dl1.y - lbd4yy; - fyy[6] = 9*lbdyy; + if (whatd[op_dy]) { + RN_ f0y(val('.', 0, op_dy)); + f0y[0] = Dl0.y * l4_0 + Dlb.y; + f0y[1] = Dl1.y * l4_1 + Dlb.y; + f0y[2] = Dl2.y * l4_2 + Dlb.y; + f0y[3] = 4 * (Dl1.y * l2 + Dl2.y * l1) - Dlb4.y; + f0y[4] = 4 * (Dl2.y * l0 + Dl0.y * l2) - Dlb4.y; + f0y[5] = 4 * (Dl0.y * l1 + Dl1.y * l0) - Dlb4.y; + f0y[6] = 9 * Dlb.y; + } - } - if (whatd[op_dxy]) - { - assert(val.K()>op_dxy); - RN_ fxy(val('.',0,op_dxy)); - R lbdxy= 3*(Dl0.x*Dl1.y+ Dl0.y*Dl1.x)*l2+(Dl1.x*Dl2.y+Dl1.y*Dl2.x)*l0+(Dl2.x*Dl0.y+Dl2.y*Dl0.x)*l1; - R lbd4xy= lbdxy*4; - - fxy[0] = 4*Dl0.x*Dl0.y + lbdxy; - fxy[1] = 4*Dl1.x*Dl1.y + lbdxy; - fxy[2] = 4*Dl2.x*Dl2.y + lbdxy; - fxy[3] = 4*(Dl1.x*Dl2.y + Dl1.y*Dl2.x) - lbd4xy; - fxy[4] = 4*(Dl0.x*Dl2.y + Dl0.y*Dl2.x) - lbd4xy; - fxy[5] = 4*(Dl0.x*Dl1.y + Dl0.y*Dl1.x) - lbd4xy; - fxy[6] = 9.*lbdxy; + if (whatd[op_dxx]) { + RN_ fxx(val('.', 0, op_dxx)); + R lbdxx = 6 * ((Dl0.x * Dl1.x) * l2 + (Dl1.x * Dl2.x) * l0 + (Dl2.x * Dl0.x) * l1); + R lbd4xx = 4 * lbdxx; + + fxx[0] = 4 * Dl0.x * Dl0.x + lbdxx; + fxx[1] = 4 * Dl1.x * Dl1.x + lbdxx; + ; + fxx[2] = 4 * Dl2.x * Dl2.x + lbdxx; + ; + fxx[3] = 8 * Dl1.x * Dl2.x - lbd4xx; + fxx[4] = 8 * Dl0.x * Dl2.x - lbd4xx; + fxx[5] = 8 * Dl0.x * Dl1.x - lbd4xx; + fxx[6] = 9 * lbdxx; + } + + if (whatd[op_dyy]) { + RN_ fyy(val('.', 0, op_dyy)); + R lbdyy = 6 * ((Dl0.y * Dl1.y) * l2 + (Dl1.y * Dl2.y) * l0 + (Dl2.y * Dl0.y) * l1); + R lbd4yy = lbdyy * 4; + + fyy[0] = 4 * Dl0.y * Dl0.y + lbdyy; + fyy[1] = 4 * Dl1.y * Dl1.y + lbdyy; + fyy[2] = 4 * Dl2.y * Dl2.y + lbdyy; + fyy[3] = 8 * Dl1.y * Dl2.y - lbd4yy; + fyy[4] = 8 * Dl0.y * Dl2.y - lbd4yy; + fyy[5] = 8 * Dl0.y * Dl1.y - lbd4yy; + fyy[6] = 9 * lbdyy; + } + if (whatd[op_dxy]) { + assert(val.K( ) > op_dxy); + RN_ fxy(val('.', 0, op_dxy)); + R lbdxy = 3 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x) * l2 + (Dl1.x * Dl2.y + Dl1.y * Dl2.x) * l0 + (Dl2.x * Dl0.y + Dl2.y * Dl0.x) * l1; + R lbd4xy = lbdxy * 4; + + fxy[0] = 4 * Dl0.x * Dl0.y + lbdxy; + fxy[1] = 4 * Dl1.x * Dl1.y + lbdxy; + fxy[2] = 4 * Dl2.x * Dl2.y + lbdxy; + fxy[3] = 4 * (Dl1.x * Dl2.y + Dl1.y * Dl2.x) - lbd4xy; + fxy[4] = 4 * (Dl0.x * Dl2.y + Dl0.y * Dl2.x) - lbd4xy; + fxy[5] = 4 * (Dl0.x * Dl1.y + Dl0.y * Dl1.x) - lbd4xy; + fxy[6] = 9. * lbdxy; + } + } } - } + // case of fine mesh + class TypeOfMortarCas1 : public TypeOfMortar { + friend class FESpace; + friend class FMortar; + friend class ConstructDataFElement; -} + protected: + int NbLagrangeMult(const Mesh &, const Mortar &M) const; -// case of fine mesh -class TypeOfMortarCas1: public TypeOfMortar { - friend class FESpace; - friend class FMortar; - friend class ConstructDataFElement; - protected: - int NbLagrangeMult(const Mesh &,const Mortar &M) const ; + int NbDoF(const Mesh &, const Mortar &M, int i) const { + int l(M.NbLeft( )), r(M.NbRight( )); + int n = Max(l, r); + int mn = Min(l, r); + return (l + r) * (ndfonVertex + ndfonEdge) + (n + 1) * ndfonVertex + n * ndfonEdge - mn - 1; + } + int NbOfNodes(const Mesh &, const Mortar &M) const // call one time + { + int l(M.NbLeft( )), r(M.NbRight( )); + return (l + r) * (vertex_is_node + edge_is_node) + 1; + } + int NbDoF(const Mesh &, const Mortar &M) const { + int l(M.NbLeft( )), r(M.NbRight( )); + int n = Max(l, r); + int mn = Min(l, r); + return (l + r) * (ndfonVertex + ndfonEdge) + (n + 1) * ndfonVertex + n * ndfonEdge - mn - 1; + } - int NbDoF(const Mesh &,const Mortar &M,int i) const - { int l(M.NbLeft()),r(M.NbRight()); - int n =Max(l,r); - int mn=Min(l,r); - return (l+r)*(ndfonVertex + ndfonEdge) + (n+1)*ndfonVertex + n*ndfonEdge -mn-1; - } - int NbOfNodes(const Mesh &,const Mortar &M) const // call one time - {int l(M.NbLeft()),r(M.NbRight()); return (l+r)*(vertex_is_node+edge_is_node)+1;} - int NbDoF(const Mesh &,const Mortar &M) const - { int l(M.NbLeft()),r(M.NbRight()); - int n =Max(l,r); - int mn=Min(l,r); - return (l+r)*(ndfonVertex + ndfonEdge) + (n+1)*ndfonVertex + n*ndfonEdge -mn-1; - } + int NodeOfDF(const FESpace &Vh, const Mortar &M, int i) const { + ffassert(0); + return 0; + } + int DFOfNode(const FESpace &Vh, const Mortar &M, int i) const { + ffassert(0); + return 0; + } + void ConstructionOfNode(const Mesh &Th, int im, int *NodesOfElement, int *FirstNodeOfElement, int &lastnodenumber) const; + void ConsTheSubMortar(FMortar &) const; - int NodeOfDF(const FESpace &Vh,const Mortar &M,int i) const - {ffassert(0);return 0;} - int DFOfNode(const FESpace &Vh,const Mortar &M,int i) const - {ffassert(0);return 0;} - void ConstructionOfNode(const Mesh &Th,int im,int * NodesOfElement,int *FirstNodeOfElement,int &lastnodenumber) const; - void ConsTheSubMortar(FMortar & ) const; - - const int vertex_is_node,edge_is_node; - public: - TypeOfMortarCas1 (int i,int j): TypeOfMortar(i,j), - vertex_is_node(i?1:0),edge_is_node(j?1:0) {}; - -} MortarCas1P2(1,1) ; - - const TypeOfMortar & TheMortarCas1P2(MortarCas1P2); - - -void TypeOfMortarCas1::ConstructionOfNode(const Mesh &Th,int im,int * NodesOfElement,int *FirstNodeOfElement,int &lastnodenumber) const -{ - // im mortar number - // trop complique on change - // const Mortar &M(Th.mortars[im]); - int k = Th.nt+im; - int kk=FirstNodeOfElement[k]; // begin - // lagrange multiplicator one new node - NodesOfElement[kk++] = lastnodenumber++; - throwassert(FirstNodeOfElement[k+1]==kk); -} - - R d1P1F0(const FESpace *,const aSubFMortar *,R x) {return 1-x;}// 1 on 0 - R d1P1F1 (const FESpace *,const aSubFMortar *,R x) {return x;}// 1 on 1 - - R d1P2F0 (const FESpace *,const aSubFMortar *,R x) {return (1-x)*(1-2*x);}// 1 on x=0 - R d1P2F1(const FESpace *,const aSubFMortar *,R x) {return (1-x)*x*4;} // 1 on x=1/2 - R d1P2F2(const FESpace *,const aSubFMortar *,R x) {return x*(2*x-1);} // 1 on x=1 - - void TypeOfMortarCas1::ConsTheSubMortar(FMortar & sm) const - { // constuction of - const Mortar & M(sm.M); - int nl=M.NbLeft(); - int nr=M.NbRight(); - int nbsm= nl+nr-1; - sm.nbsm = nbsm; - int ldata = 6*nbsm;// 3 gauche+ 3 droite - sm.sm = new aSubFMortar[nbsm]; - sm.datai = new int [ldata]; - typedef R (* Fdataf)(const FESpace *,const aSubFMortar *,R); - sm.dataf =new Fdataf[ldata]; // new (R (*[ldata])(const FESpace *,const aSubFMortar *,R)) ; - ffassert( sm.dataf ); // remove previous line FH, PB comp - int *dataDfNumberOFmul=sm.datai; - - R (**dataf)(const FESpace *,const aSubFMortar *,R) ; - dataf=sm.dataf; - for (int i=0;i2); - return nbmul; - } + const TypeOfMortar &TheMortarCas1P2(MortarCas1P2); + void TypeOfMortarCas1::ConstructionOfNode(const Mesh &Th, int im, int *NodesOfElement, int *FirstNodeOfElement, int &lastnodenumber) const { + // im mortar number + // trop complique on change + // const Mortar &M(Th.mortars[im]); + int k = Th.nt + im; + int kk = FirstNodeOfElement[k]; // begin + // lagrange multiplicator one new node + NodesOfElement[kk++] = lastnodenumber++; + throwassert(FirstNodeOfElement[k + 1] == kk); + } + + R d1P1F0(const FESpace *, const aSubFMortar *, R x) { return 1 - x; } // 1 on 0 + R d1P1F1(const FESpace *, const aSubFMortar *, R x) { return x; } // 1 on 1 + + R d1P2F0(const FESpace *, const aSubFMortar *, R x) { return (1 - x) * (1 - 2 * x); } // 1 on x=0 + R d1P2F1(const FESpace *, const aSubFMortar *, R x) { return (1 - x) * x * 4; } // 1 on x=1/2 + R d1P2F2(const FESpace *, const aSubFMortar *, R x) { return x * (2 * x - 1); } // 1 on x=1 + + void TypeOfMortarCas1::ConsTheSubMortar(FMortar &sm) const { // constuction of + const Mortar &M(sm.M); + int nl = M.NbLeft( ); + int nr = M.NbRight( ); + int nbsm = nl + nr - 1; + sm.nbsm = nbsm; + int ldata = 6 * nbsm; // 3 gauche+ 3 droite + sm.sm = new aSubFMortar[nbsm]; + sm.datai = new int[ldata]; + typedef R (*Fdataf)(const FESpace *, const aSubFMortar *, R); + sm.dataf = new Fdataf[ldata]; // new (R (*[ldata])(const FESpace *,const aSubFMortar *,R)) ; + ffassert(sm.dataf); // remove previous line FH, PB comp + int *dataDfNumberOFmul = sm.datai; + + R (**dataf)(const FESpace *, const aSubFMortar *, R); + dataf = sm.dataf; + for (int i = 0; i < ldata; i++) sm.dataf[i] = 0; + R2 A(M.VLeft(0)); + R2 B(M.VLeft(nl)); + ffassert(&M.VLeft(0) == &M.VRight(0)); + ffassert(&M.VLeft(nl) == &M.VRight(nr)); + + R2 AB(A, B); + R lg = Norme2(AB); + R2 AB1(AB / lg); + int il = 0, ir = 0; + int k = 0; + R la = 0.0; + R lb = 0.0; + R2 AA(A), BB(A); + do { + sm.sm[k].left = M.left[il]; + sm.sm[k].right = M.right[ir]; + R2 Bl(M.VLeft(il + 1)); + R2 Br(M.VRight(ir + 1)); + R ll = (AB1, Bl - A), lr = (AB1, Br - A); + if (ll < lr) { + BB = Bl, lb = ll, il++; + } else { + BB = Br, lb = lr, ir++; + } + sm.sm[k].a = la / lg; + sm.sm[k].b = lb / lg; + sm.sm[k].A = AA; + sm.sm[k].B = BB; + la = lb; + AA = BB; + k++; + throwassert(k <= nbsm); + } while (il < nl && ir < nr); + + ffassert(nbsm == Max(nl, nr)); + nbsm = k; + sm.nbsm = k; + // construction of interpolation + // 1) on a P1 on P2 + // P2 si les longueurs des aSubMortar precedende et suivant sont les meme + // sinon P1 + // calcul de leps + R leps = 1.0 / (1048576.0); // 1/2^20 + R lgp = 0; + R lgc = 0; + R lgs = sm.sm[0].lg1( ); + + int nmul = 0; + for (int k = 0; k < nbsm; k++) { + + lgp = lgc; + lgc = lgs; + lgs = k + 1 == nbsm ? 0 : sm.sm[k + 1].lg1( ); + sm.sm[k].DfNumberOFmul = dataDfNumberOFmul; + sm.sm[k].f = dataf; + if (Abs(lgp - lgc) < leps && Abs(lgs - lgc) < leps) { // P2 + sm.sm[k].Nbmul = 3; + *dataDfNumberOFmul++ = nmul++; + *dataDfNumberOFmul++ = nmul++; + *dataDfNumberOFmul++ = nmul; + *dataf++ = d1P2F0; + *dataf++ = d1P2F1; + *dataf++ = d1P2F2; + + } else { // P1 + sm.sm[k].Nbmul = 2; + *dataDfNumberOFmul++ = nmul++; + *dataDfNumberOFmul++ = nmul; + *dataf++ = d1P1F0; + *dataf++ = d1P1F1; + } + } + nmul++; + ffassert(nmul == sm.NbDoF(0)); + } -// --- - FMortar::FMortar(const FESpace * VVh,int k) - : - Vh(*VVh), - M(Vh.Th.mortars[k-Vh.Th.nt]), - p(Vh.PtrFirstNodeOfElement(k)), - nbn(Vh.NbOfNodesInElement(k)), - N(VVh->N), - tom(Vh.tom) + int TypeOfMortarCas1::NbLagrangeMult(const Mesh &, const Mortar &M) const { + int nl = M.NbLeft( ); + int nr = M.NbRight( ); + R2 A(M.VLeft(0)); + R2 B(M.VLeft(nl)); + R2 AB(A, B); + R lg = Norme2(AB); + R leps = lg / 1048576.0; + ffassert(nl == 1 || nr == 1); + R lgp = 0, lgc = 0, lgs = 0; + int nbmul = 3; + if (nr == 1) { + R2 AA(M.VLeft(0)), BB(M.VLeft(1)); + lgp = Norme2(BB - AA); // preced + AA = BB; + BB = M.VLeft(2); + lgc = Norme2(BB - AA); // courant + + for (int i = 1; i < nl - 1; i++) { + AA = BB; + BB = M.VLeft(i + 2); + lgs = Norme2(AA - BB); // le suivant + if (Abs(lgp - lgc) < leps && Abs(lgs - lgc) < leps) + nbmul += 2; // P2 + else + nbmul += 1; // P1; + lgp = lgc; + lgc = lgs; + } + } else { + R2 AA(M.VRight(0)), BB(M.VRight(1)); + lgp = Norme2(BB - AA); // preced + AA = BB; + BB = M.VRight(2); + lgc = Norme2(BB - AA); // courant + + for (int i = 1; i < nr - 1; i++) { + AA = BB; + BB = M.VRight(i + 2); + lgs = Norme2(AA - BB); // le suivant + if (Abs(lgp - lgc) < leps && Abs(lgs - lgc) < leps) + nbmul += 2; // P2 + else + nbmul += 1; // P1; + lgp = lgc; + lgc = lgs; + } + } + ffassert(nbmul > 2); + return nbmul; + } - { ffassert(k>=Vh.Th.nt && k tom->ConsTheSubMortar(*this);} + // --- + FMortar::FMortar(const FESpace *VVh, int k) + : Vh(*VVh), M(Vh.Th.mortars[k - Vh.Th.nt]), p(Vh.PtrFirstNodeOfElement(k)), nbn(Vh.NbOfNodesInElement(k)), N(VVh->N), tom(Vh.tom) - R TypeOfFE::operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) const { - R v[10000],vf[1000]; - assert(N*3*NbDoF<=10000 && NbDoF <1000 ); - KNMK_ fb(v,NbDoF,N,op+1); // the value for basic fonction - KN_ fk(vf,NbDoF); - for (int i=0;i= Vh.Th.nt && k < Vh.Th.nt + Vh.Th.NbMortars); + VVh->tom->ConsTheSubMortar(*this); + } + + R TypeOfFE::operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const { + R v[10000], vf[1000]; + assert(N * 3 * NbDoF <= 10000 && NbDoF < 1000); + KNMK_< R > fb(v, NbDoF, N, op + 1); // the value for basic fonction + KN_< R > fk(vf, NbDoF); + for (int i = 0; i < NbDoF; i++) // get the local value + fk[i] = u[K(i)]; // get value of basic function - bool whatd[last_operatortype]; - for (int i=0;i -namespace Fem2D { - class FESpace; -class TypeOfFE; +namespace Fem2D { + class FESpace; + class TypeOfFE; /* -// numbering of derivative +// numbering of derivative enum operatortype { op_id=0, op_dx=1,op_dy=2, op_dxx=3,op_dyy=4, - op_dyx=5,op_dxy=5, + op_dyx=5,op_dxy=5, op_dz=6, - op_dzz=7, - op_dzx=8,op_dxz=8, - op_dzy=9,op_dyz=9 - }; - + op_dzz=7, + op_dzx=8,op_dxz=8, + op_dzy=9,op_dyz=9 + }; + const int last_operatortype=10; - + inline void initwhatd(bool *whatd,int k) { for (int i=0;i RN_; -typedef KN RN; -typedef KNM_ RNM_; -//typedef KNM RNM; -typedef KNMK_ RNMK_; -typedef KNMK RNMK; - -inline int FindIn(int v,int *a,int n) -{ - for (int i=0;i -// i = df -// j = [0 N[ (ou N est la dim de l'espace d'arrive N=3 -// k = 0,1,2 f,fx,fy - - -class FElement; -class baseFElement; -class FMortar; -class TypeOfMortar; - -// for FE -//typedef void (* basicFunction)(const FElement & FE,const R2 &P, RNMK_ & val); -typedef void (* InterpolFunction)(R* v, const R2 & P,const baseFElement &,int where,const R2 & Phat, void * arg); -//typedef void (*InterpolantFunction)(const FElement & FE,RN_ & val, InterpolFunction f, R* v); -// for FM ( Finite Mortar Mortar + interpolation) -typedef void (* basicFunctionMortar)(const FMortar & FE,const R2 &P, RNMK_ & val); -typedef void (* InterpolFunctionMortar)(R* v, const R2 & P,const Mortar &,int where,const R2 & Phat); -typedef void (*InterpolantFunctionMortar)(const FMortar & FE,RN_ & val, InterpolFunctionMortar f, R* v); - -//void P1Functions(const FElement &FE,const R2 & P,RNMK_ & val); -//void P2Functions(const FElement &FE,const R2 & P,RNMK_ & val); - - -class VofScalarFE { - R v[3]; - public: - VofScalarFE() {v[0]=v[1]=v[2]=0;} - VofScalarFE(R f,R fx,R fy) {v[0]=f;v[1]=fx;v[2]=fy;} - - R & operator[](int i){ return v[i];} - const R & operator[](int i) const { return v[i];} - R f() { return v[0];} - R fx() { return v[1];} - R fy() { return v[2];} - VofScalarFE &operator+=(const VofScalarFE & a) { v[0]+=a.v[0]; v[1]+=a.v[1]; v[2]+=a.v[2];return *this;} -}; - -class ConstructDataFElement { - friend class FESpace; - //int thecounter; // chang 09/2008 the counter is a pointer because - // if you remove before the master the counter become invalide. - int * counter; - int MaxNbNodePerElement; - int MaxNbDFPerElement; - int *NodesOfElement; - int *FirstNodeOfElement; - int *FirstDfOfNode; - int NbOfElements; - int NbOfDF; - int NbOfNode; - int Nproduit; - ConstructDataFElement(const Mesh &Th,/*int NbDfOnSommet,int ndfonEdge,int ndfonFace,*/ - const KN & TFEs,const TypeOfMortar *tm=0, - int nbdfv=0,const int *ndfv=0,int nbdfe=0,const int *ndfe=0); - ConstructDataFElement(const ConstructDataFElement *,int k); - ConstructDataFElement(const FESpace ** l,int k,const KN & TFEs) ; - void renum(const long *r,int l) ; - ~ConstructDataFElement(); - void Make(const Mesh &Th,/*int NbDfOnSommet,int ndfonEdge,int ndfonFace*/const KN & TFEs,const TypeOfMortar *tm=0, - int nbdfv=0,const int *ndfv=0,int nbdfe=0,const int *ndfe=0); -private: - static int *NewCounter() { int * p=new int; *p=0;return p;}// add the build thecounter. -}; - -template -inline int sum(const T ** l,int const T::*p,int n) - { - int r=0; - for (int i=0;i*p; - return r; + typedef KN_< R > RN_; + typedef KN< R > RN; + typedef KNM_< R > RNM_; + // typedef KNM RNM; + typedef KNMK_< R > RNMK_; + typedef KNMK< R > RNMK; + + inline int FindIn(int v, int *a, int n) { + for (int i = 0; i < n; i++) + if (v == a[i]) return i; + return -1; + }; + + // Methode boeuf + // on suppose que pour chaque elment fini + // on sait calculer + // un tableau de point x,y + // les valeur de la fonction et des derives + // FB(RN_ + // i = df + // j = [0 N[ (ou N est la dim de l'espace d'arrive N=3 + // k = 0,1,2 f,fx,fy + + class FElement; + class baseFElement; + class FMortar; + class TypeOfMortar; + + // for FE + // typedef void (* basicFunction)(const FElement & FE,const R2 &P, RNMK_ & val); + typedef void (*InterpolFunction)(R *v, const R2 &P, const baseFElement &, int where, const R2 &Phat, void *arg); + // typedef void (*InterpolantFunction)(const FElement & FE,RN_ & val, InterpolFunction f, R* v); + // for FM ( Finite Mortar Mortar + interpolation) + typedef void (*basicFunctionMortar)(const FMortar &FE, const R2 &P, RNMK_ &val); + typedef void (*InterpolFunctionMortar)(R *v, const R2 &P, const Mortar &, int where, const R2 &Phat); + typedef void (*InterpolantFunctionMortar)(const FMortar &FE, RN_ &val, InterpolFunctionMortar f, R *v); + + // void P1Functions(const FElement &FE,const R2 & P,RNMK_ & val); + // void P2Functions(const FElement &FE,const R2 & P,RNMK_ & val); + + class VofScalarFE { + R v[3]; + + public: + VofScalarFE( ) { v[0] = v[1] = v[2] = 0; } + VofScalarFE(R f, R fx, R fy) { + v[0] = f; + v[1] = fx; + v[2] = fy; + } + + R &operator[](int i) { return v[i]; } + const R &operator[](int i) const { return v[i]; } + R f( ) { return v[0]; } + R fx( ) { return v[1]; } + R fy( ) { return v[2]; } + VofScalarFE &operator+=(const VofScalarFE &a) { + v[0] += a.v[0]; + v[1] += a.v[1]; + v[2] += a.v[2]; + return *this; + } + }; + + class ConstructDataFElement { + friend class FESpace; + // int thecounter; // chang 09/2008 the counter is a pointer because + // if you remove before the master the counter become invalide. + int *counter; + int MaxNbNodePerElement; + int MaxNbDFPerElement; + int *NodesOfElement; + int *FirstNodeOfElement; + int *FirstDfOfNode; + int NbOfElements; + int NbOfDF; + int NbOfNode; + int Nproduit; + ConstructDataFElement(const Mesh &Th, /*int NbDfOnSommet,int ndfonEdge,int ndfonFace,*/ + const KN< const TypeOfFE * > &TFEs, const TypeOfMortar *tm = 0, int nbdfv = 0, const int *ndfv = 0, int nbdfe = 0, const int *ndfe = 0); + ConstructDataFElement(const ConstructDataFElement *, int k); + ConstructDataFElement(const FESpace **l, int k, const KN< const TypeOfFE * > &TFEs); + void renum(const long *r, int l); + ~ConstructDataFElement( ); + void Make(const Mesh &Th, /*int NbDfOnSommet,int ndfonEdge,int ndfonFace*/ const KN< const TypeOfFE * > &TFEs, const TypeOfMortar *tm = 0, int nbdfv = 0, const int *ndfv = 0, int nbdfe = 0, + const int *ndfe = 0); + + private: + static int *NewCounter( ) { + int *p = new int; + *p = 0; + return p; + } // add the build thecounter. + }; + + template< class T > + inline int sum(const T **l, int const T::*p, int n) { + int r = 0; + for (int i = 0; i < n; i++) r += l[i]->*p; + return r; } - -template -inline int max(const T ** l,int const T::*p,int n) - { - int r=0; - for (int i=0;i*p,r); - return r; + + template< class T > + inline int max(const T **l, int const T::*p, int n) { + int r = 0; + for (int i = 0; i < n; i++) r = Max(l[i]->*p, r); + return r; } - - -class TypeOfFE { public: -// The FEM is in R^N -// The FEM is compose from nb_sub_fem -// dim_which_sub_fem[N] give - typedef R2 RdHat; // add avril 2009 FH - typedef R2 Rd; // add avril 2009 FH - - - friend class FESpace; - friend class FElement; - friend class FEProduitConstruct; - const int NbDoF; - const int NbNodeOnVertex, NbNodeOnEdge, NbNodeOnElement; - const int ndfonVertex, ndfonEdge, ndfonFace, N,nb_sub_fem; - const int NbNode; - // remark - // virtual void FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const =0; - virtual void FB(const bool *,const Mesh & Th,const Triangle & K,const RdHat &PHat, RNMK_ & val) const =0; -// virtual void D2_FB(const Mesh & Th,const Triangle & K,const R2 &P, RNMK_ & val) const=0; - // virtual void Pi_h(const baseFElement & K,RN_ & val, InterpolFunction f, R* v,int , void *) const=0; - - // soit - // $(U_pj)_{{j=0,N-1}; {p=0,nbpoint_Pi_h-1}}$ les valeurs de U au point Phat[i]; - // p est le numero du point d'integration - // j est la composante - // l'interpole est defini par - // Pi_h u = \sum_k u_k w^k , et u_i = \sum_pj alpha_ipj U_pj - // la matrice de alpha_ipj est tres creuse - struct IPJ { - int i,p,j; // i is DoF, p is Point, j is componante - IPJ(int ii=0,int pp=0,int jj=0):i(ii),p(pp),j(jj) {} - }; - - friend KN Makepij_alpha(const TypeOfFE **,int ); - friend KN MakeP_Pi_h(const TypeOfFE **,int ); - - const KN & Ph_ijalpha() const {return pij_alpha;} // la struct de la matrice - const KN & Pi_h_R2() const { return P_Pi_h;} // les points - virtual void Pi_h_alpha(const baseFElement & K,KN_ & v) const - { assert(coef_Pi_h_alpha); - v=KN_(coef_Pi_h_alpha,pij_alpha.N());} - - // ---- - - const int nbsubdivision; // nb of subdivision for plot - int const * const DFOnWhat; // 0,1,2 vertex 3,4,5 edge 6 triangle - int const * const DFOfNode; // n\u00c9 du df on Node - int const * const NodeOfDF; // - int const * const fromFE; // the df come from df of FE - int const * const fromDF; // the df come from with FE - int const * const dim_which_sub_fem; // from atomic sub FE for CL (size N) - KN pij_alpha ; - KN P_Pi_h ; - double *coef_Pi_h_alpha; - KN Sub_ToFE; // List of atomic sub TFE avril 2006 - // form Atomic Sub FE - int const * const fromASubFE; // avril 2006 for CL - int const * const fromASubDF; // avril 2006 for CL - int const * const begin_dfcomp; // mai 2008 for optimiation - int const * const end_dfcomp; // mai 2008 - - // if 0 no plot - public: - - TypeOfFE(const TypeOfFE & t,int k,const int * data,const int * data1) - : - NbDoF(t.NbDoF*k), - NbNodeOnVertex(t.NbNodeOnVertex),NbNodeOnEdge(t.NbNodeOnEdge),NbNodeOnElement(t.NbNodeOnElement), - ndfonVertex(t.ndfonVertex*k),ndfonEdge(t.ndfonEdge*k),ndfonFace(t.ndfonFace*k), - N(t.N*k),nb_sub_fem(t.nb_sub_fem*k), - NbNode(t.NbNode), - nbsubdivision(t.nbsubdivision), - DFOnWhat(data), - DFOfNode(data+NbDoF), - NodeOfDF(data+2*NbDoF), - fromFE(data+3*NbDoF), - fromDF(data+4*NbDoF), - dim_which_sub_fem(data+5*NbDoF), - pij_alpha(t.pij_alpha.N()*k),P_Pi_h(t.P_Pi_h), - coef_Pi_h_alpha(0), - Sub_ToFE(nb_sub_fem), - fromASubFE(data1+0*NbDoF), - fromASubDF(data1+1*NbDoF), - begin_dfcomp(data1+2*NbDoF), - end_dfcomp(data1+2*NbDoF+N) - - { - for(int i=0,kk=0;i=0 && dim_which_sub_fem[N-1]< nb_sub_fem); - // Warning the componant is moving first - for (int j=0,l=0;jnb_sub_fem;j++) - Sub_ToFE[kk++]=t[i]->Sub_ToFE[j]; - assert(begin_dfcomp[0]==0 && end_dfcomp[N-1]==NbDoF); - - Sub_ToFE= this; - throwassert(dim_which_sub_fem[N-1]>=0 && dim_which_sub_fem[N-1]< nb_sub_fem);} - - TypeOfFE(const int i,const int j,const int k,const int NN,const int * data,int nsub,int nbsubfem, - int kPi,int npPi,double * coef_Pi_h_a=0) - : NbDoF(3*(i+j)+k), - NbNodeOnVertex(NbNodebyWhat(data,NbDoF,0)), - NbNodeOnEdge(NbNodebyWhat(data,NbDoF,3)), - NbNodeOnElement(NbNodebyWhat(data,NbDoF,6)), -/* ndfonVertex(Count(data,NbDoF,0)), - ndfonEdge(Count(data,NbDoF,3)), - ndfonFace(Count(data,NbDoF,6)), - */ - ndfonVertex(i),ndfonEdge(j),ndfonFace(k),N(NN),nb_sub_fem(nbsubfem), - NbNode( (ndfonVertex ? 3 :0) + (ndfonEdge ? 3 :0 ) +(ndfonFace? 1 :0) ), - nbsubdivision(nsub), - DFOnWhat(data), - DFOfNode(data+NbDoF), - NodeOfDF(data+2*NbDoF), - fromFE(data+3*NbDoF), - fromDF(data+4*NbDoF), - dim_which_sub_fem(data+5*NbDoF), - pij_alpha(kPi),P_Pi_h(npPi), - coef_Pi_h_alpha(coef_Pi_h_a), - Sub_ToFE(nb_sub_fem), - fromASubFE(data+3*NbDoF), - fromASubDF(data+4*NbDoF), - begin_dfcomp(data+5*NbDoF+N), - end_dfcomp(data+5*NbDoF+2*N) - { - Sub_ToFE= this; - assert(begin_dfcomp[0]==0 && end_dfcomp[N-1]==NbDoF); - // cout << "TypeOfFE " <=0 && dim_which_sub_fem[N-1]< nb_sub_fem);} - - TypeOfFE(const int nbdf,const int NN,const int * data,int nsub,int nbsubfem, - int kPi,int npPi,double * coef_Pi_h_a=0) - : - NbDoF(nbdf), - NbNodeOnVertex(NbNodebyWhat(data,NbDoF,0)), - NbNodeOnEdge(NbNodebyWhat(data,NbDoF,3)), - NbNodeOnElement(NbNodebyWhat(data,NbDoF,6)), - ndfonVertex(Count(data,NbDoF,0)), - ndfonEdge(Count(data,NbDoF,3)), - ndfonFace(Count(data,NbDoF,6)), - N(NN), - nb_sub_fem(nbsubfem), - NbNode( (ndfonVertex ? 3 :0) + (ndfonEdge ? 3 :0 ) +(ndfonFace? 1 :0) ), - nbsubdivision(nsub), - DFOnWhat(data), - DFOfNode(data+NbDoF), - NodeOfDF(data+2*NbDoF), - fromFE(data+3*NbDoF), - fromDF(data+4*NbDoF), - dim_which_sub_fem(data+5*NbDoF), - pij_alpha(kPi),P_Pi_h(npPi), - coef_Pi_h_alpha(coef_Pi_h_a), - Sub_ToFE(nb_sub_fem) , - fromASubFE(data+3*NbDoF), - fromASubDF(data+4*NbDoF), - begin_dfcomp(data+5*NbDoF+N), - end_dfcomp(data+5*NbDoF+2*N) - - { - Sub_ToFE= this; - assert(begin_dfcomp[0]==0 && end_dfcomp[N-1]==NbDoF); - assert(ndfonVertex==Count(data,NbDoF,0)); - assert(ndfonVertex==Count(data,NbDoF,1)); - assert(ndfonVertex==Count(data,NbDoF,2)); - assert(ndfonEdge==Count(data,NbDoF,3)); - assert(ndfonEdge==Count(data,NbDoF,4)); - assert(ndfonEdge==Count(data,NbDoF,5)); - assert(ndfonFace==Count(data,NbDoF,6)); - - throwassert(dim_which_sub_fem[N-1]>=0 && dim_which_sub_fem[N-1]< nb_sub_fem);} - - virtual ~TypeOfFE() { } - virtual R operator()(const FElement & K,const R2 & PHat,const KN_ & u,int componante,int op) - const ; - - private: - static int Count(const int *data,int n,int which) - { - int kk=0; - for (int i=0;i Makepij_alpha(const TypeOfFE **, int); + friend KN< R2 > MakeP_Pi_h(const TypeOfFE **, int); + + const KN< IPJ > &Ph_ijalpha( ) const { return pij_alpha; } // la struct de la matrice + const KN< R2 > &Pi_h_R2( ) const { return P_Pi_h; } // les points + virtual void Pi_h_alpha(const baseFElement &K, KN_< double > &v) const { + assert(coef_Pi_h_alpha); + v = KN_< double >(coef_Pi_h_alpha, pij_alpha.N( )); + } + + // ---- + + const int nbsubdivision; // nb of subdivision for plot + int const *const DFOnWhat; // 0,1,2 vertex 3,4,5 edge 6 triangle + int const *const DFOfNode; // n\u00c9 du df on Node + int const *const NodeOfDF; // + int const *const fromFE; // the df come from df of FE + int const *const fromDF; // the df come from with FE + int const *const dim_which_sub_fem; // from atomic sub FE for CL (size N) + KN< IPJ > pij_alpha; + KN< R2 > P_Pi_h; + double *coef_Pi_h_alpha; + KN< TypeOfFE * > Sub_ToFE; // List of atomic sub TFE avril 2006 + // form Atomic Sub FE + int const *const fromASubFE; // avril 2006 for CL + int const *const fromASubDF; // avril 2006 for CL + int const *const begin_dfcomp; // mai 2008 for optimiation + int const *const end_dfcomp; // mai 2008 + + // if 0 no plot + public: + TypeOfFE(const TypeOfFE &t, int k, const int *data, const int *data1) + : NbDoF(t.NbDoF * k), NbNodeOnVertex(t.NbNodeOnVertex), NbNodeOnEdge(t.NbNodeOnEdge), NbNodeOnElement(t.NbNodeOnElement), ndfonVertex(t.ndfonVertex * k), ndfonEdge(t.ndfonEdge * k), + ndfonFace(t.ndfonFace * k), N(t.N * k), nb_sub_fem(t.nb_sub_fem * k), NbNode(t.NbNode), nbsubdivision(t.nbsubdivision), DFOnWhat(data), DFOfNode(data + NbDoF), NodeOfDF(data + 2 * NbDoF), + fromFE(data + 3 * NbDoF), fromDF(data + 4 * NbDoF), dim_which_sub_fem(data + 5 * NbDoF), pij_alpha(t.pij_alpha.N( ) * k), P_Pi_h(t.P_Pi_h), coef_Pi_h_alpha(0), Sub_ToFE(nb_sub_fem), + fromASubFE(data1 + 0 * NbDoF), fromASubDF(data1 + 1 * NbDoF), begin_dfcomp(data1 + 2 * NbDoF), end_dfcomp(data1 + 2 * NbDoF + N) + + { + for (int i = 0, kk = 0; i < k; i++) + for (int j = 0; j < t.nb_sub_fem; j++) Sub_ToFE[kk++] = t.Sub_ToFE[j]; + assert(begin_dfcomp[0] == 0 && end_dfcomp[N - 1] == NbDoF); + + throwassert(dim_which_sub_fem[N - 1] >= 0 && dim_which_sub_fem[N - 1] < nb_sub_fem); + // Warning the componant is moving first + for (int j = 0, l = 0; j < t.pij_alpha.N( ); j++) // for all sub DF + for (int i = 0; i < k; i++, l++) // for componate + { + pij_alpha[l].i = t.pij_alpha[j].i * k + i; // DoF number + pij_alpha[l].p = t.pij_alpha[j].p; // point of interpolation + pij_alpha[l].j = t.pij_alpha[j].j + i * t.N; // componante of interpolation + } + } + + TypeOfFE(const TypeOfFE **t, int k, const int *data, const int *data1) + : NbDoF(sum(t, &TypeOfFE::NbDoF, k)), NbNodeOnVertex(NbNodebyWhat(data, NbDoF, 0)), NbNodeOnEdge(NbNodebyWhat(data, NbDoF, 3)), NbNodeOnElement(NbNodebyWhat(data, NbDoF, 6)), + ndfonVertex(sum(t, &TypeOfFE::ndfonVertex, k)), ndfonEdge(sum(t, &TypeOfFE::ndfonEdge, k)), ndfonFace(sum(t, &TypeOfFE::ndfonFace, k)), N(sum(t, &TypeOfFE::N, k)), + nb_sub_fem(sum(t, &TypeOfFE::nb_sub_fem, k)), NbNode((ndfonVertex ? 3 : 0) + (ndfonEdge ? 3 : 0) + (ndfonFace ? 1 : 0)), nbsubdivision(max(t, &TypeOfFE::nbsubdivision, k)), + + DFOnWhat(data), DFOfNode(data + NbDoF), NodeOfDF(data + 2 * NbDoF), fromFE(data + 3 * NbDoF), fromDF(data + 4 * NbDoF), dim_which_sub_fem(data + 5 * NbDoF), pij_alpha(Makepij_alpha(t, k)), + P_Pi_h(MakeP_Pi_h(t, k)), coef_Pi_h_alpha(0), Sub_ToFE(nb_sub_fem), fromASubFE(data1 + 0 * NbDoF), fromASubDF(data1 + 1 * NbDoF), begin_dfcomp(data1 + 2 * NbDoF), + end_dfcomp(data1 + 2 * NbDoF + N) { + for (int i = 0, kk = 0; i < k; i++) + for (int j = 0; j < t[i]->nb_sub_fem; j++) Sub_ToFE[kk++] = t[i]->Sub_ToFE[j]; + assert(begin_dfcomp[0] == 0 && end_dfcomp[N - 1] == NbDoF); + + Sub_ToFE = this; + throwassert(dim_which_sub_fem[N - 1] >= 0 && dim_which_sub_fem[N - 1] < nb_sub_fem); + } + + TypeOfFE(const int i, const int j, const int k, const int NN, const int *data, int nsub, int nbsubfem, int kPi, int npPi, double *coef_Pi_h_a = 0) + : NbDoF(3 * (i + j) + k), NbNodeOnVertex(NbNodebyWhat(data, NbDoF, 0)), NbNodeOnEdge(NbNodebyWhat(data, NbDoF, 3)), NbNodeOnElement(NbNodebyWhat(data, NbDoF, 6)), + /* ndfonVertex(Count(data,NbDoF,0)), + ndfonEdge(Count(data,NbDoF,3)), + ndfonFace(Count(data,NbDoF,6)), + */ + ndfonVertex(i), ndfonEdge(j), ndfonFace(k), N(NN), nb_sub_fem(nbsubfem), NbNode((ndfonVertex ? 3 : 0) + (ndfonEdge ? 3 : 0) + (ndfonFace ? 1 : 0)), nbsubdivision(nsub), DFOnWhat(data), + DFOfNode(data + NbDoF), NodeOfDF(data + 2 * NbDoF), fromFE(data + 3 * NbDoF), fromDF(data + 4 * NbDoF), dim_which_sub_fem(data + 5 * NbDoF), pij_alpha(kPi), P_Pi_h(npPi), + coef_Pi_h_alpha(coef_Pi_h_a), Sub_ToFE(nb_sub_fem), fromASubFE(data + 3 * NbDoF), fromASubDF(data + 4 * NbDoF), begin_dfcomp(data + 5 * NbDoF + N), end_dfcomp(data + 5 * NbDoF + 2 * N) { + Sub_ToFE = this; + assert(begin_dfcomp[0] == 0 && end_dfcomp[N - 1] == NbDoF); + // cout << "TypeOfFE " <= 0 && dim_which_sub_fem[N - 1] < nb_sub_fem); + } + + TypeOfFE(const int nbdf, const int NN, const int *data, int nsub, int nbsubfem, int kPi, int npPi, double *coef_Pi_h_a = 0) + : NbDoF(nbdf), NbNodeOnVertex(NbNodebyWhat(data, NbDoF, 0)), NbNodeOnEdge(NbNodebyWhat(data, NbDoF, 3)), NbNodeOnElement(NbNodebyWhat(data, NbDoF, 6)), ndfonVertex(Count(data, NbDoF, 0)), + ndfonEdge(Count(data, NbDoF, 3)), ndfonFace(Count(data, NbDoF, 6)), N(NN), nb_sub_fem(nbsubfem), NbNode((ndfonVertex ? 3 : 0) + (ndfonEdge ? 3 : 0) + (ndfonFace ? 1 : 0)), nbsubdivision(nsub), + DFOnWhat(data), DFOfNode(data + NbDoF), NodeOfDF(data + 2 * NbDoF), fromFE(data + 3 * NbDoF), fromDF(data + 4 * NbDoF), dim_which_sub_fem(data + 5 * NbDoF), pij_alpha(kPi), P_Pi_h(npPi), + coef_Pi_h_alpha(coef_Pi_h_a), Sub_ToFE(nb_sub_fem), fromASubFE(data + 3 * NbDoF), fromASubDF(data + 4 * NbDoF), begin_dfcomp(data + 5 * NbDoF + N), end_dfcomp(data + 5 * NbDoF + 2 * N) + + { + Sub_ToFE = this; + assert(begin_dfcomp[0] == 0 && end_dfcomp[N - 1] == NbDoF); + assert(ndfonVertex == Count(data, NbDoF, 0)); + assert(ndfonVertex == Count(data, NbDoF, 1)); + assert(ndfonVertex == Count(data, NbDoF, 2)); + assert(ndfonEdge == Count(data, NbDoF, 3)); + assert(ndfonEdge == Count(data, NbDoF, 4)); + assert(ndfonEdge == Count(data, NbDoF, 5)); + assert(ndfonFace == Count(data, NbDoF, 6)); + + throwassert(dim_which_sub_fem[N - 1] >= 0 && dim_which_sub_fem[N - 1] < nb_sub_fem); + } + + virtual ~TypeOfFE( ) {} + virtual R operator( )(const FElement &K, const R2 &PHat, const KN_< R > &u, int componante, int op) const; + + private: + static int Count(const int *data, int n, int which) { + int kk = 0; + for (int i = 0; i < n; ++i) if (which == data[i]) ++kk; - return kk;} - - static int LastNode(const int *data,int n) - { - int kk=0,i0=2*n; - for(int i=0;i= 0 && xx <= 1); + return TriangleHat[c] * (xx) + TriangleHat[d] * (1 - xx); } + }; - int FirstDFOfNode(int i) const {return FirstDfOfNodeData ? FirstDfOfNodeData[i] : i*Nproduit;} - int LastDFOfNode(int i) const {return FirstDfOfNodeData ? FirstDfOfNodeData[i+1] : (i+1)*Nproduit;} - int NbDFOfNode(int i) const {return FirstDfOfNodeData ? FirstDfOfNodeData[i+1]-FirstDfOfNodeData[i] : Nproduit;} - int MaximalNbOfNodes() const {return MaxNbNodePerElement;}; - int MaximalNbOfDF() const {return MaxNbDFPerElement;}; - const int * PtrFirstNodeOfElement(int k) const { - return NodesOfElement - ? NodesOfElement + (FirstNodeOfElement ? FirstNodeOfElement[k] : k*MaxNbNodePerElement) - : 0;} - - int SizeToStoreAllNodeofElement() const { - return FirstNodeOfElement - ? FirstNodeOfElement[NbOfElements] - : MaxNbNodePerElement*NbOfElements;} - - int NbOfNodesInElement(int k) const { - return FirstNodeOfElement - ? FirstNodeOfElement[k+1] - FirstNodeOfElement[k] - : MaxNbNodePerElement ;} - int esize() const { return MaxNbDFPerElement*N*last_operatortype;} // size to store all value of B. function - - FESpace(const FESpace &,int k ); - FESpace(const FESpace **,int k ); - FESpace(const Mesh & TTh,const TypeOfFE **,int k,int nbdfv=0,const int *ndfv=0,int nbdfe=0,const int *ndfe=0 );//int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); - - FESpace(const Mesh & TTh,const TypeOfFE & , - int nbdfv=0,const int *ndfv=0,int nbdfe=0,const int *ndfe=0);//int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); - - FESpace(const Mesh & TTh,const TypeOfFE &,const TypeOfMortar & );//int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); - ~FESpace(); - // FESpace(Mesh & TTh,int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); - int renum(); - - FElement operator[](int k) const { return FElement(this,k);} - FElement operator[](const Triangle & K) const { return FElement(this,Th.number(K));} - int operator()(int k)const {return NbOfNodesInElement(k);} - int operator()(int k,int i) const { // the node i of element k - return NodesOfElement ? *(PtrFirstNodeOfElement(k) + i) : Th(k,i) ;} - - void Draw(const KN_& U,const KN_& Viso,int j=0,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Draw iso line - void Drawfill(const KN_& U,const KN_& Viso,int j=0,double rapz=1,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Draw iso line - - template - KN newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const ; - template - KN newSaveDraw(const KN_ & U,const KN_ & V,int iU,int IV,int & lg,int & nsb) const ; - void Draw(const KN_& U,const KN_ & Viso, R coef,int j0=0,int j1=1,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true,double ArrowSize=-1) const ; // Arrow - void Draw(const KN_& U,const KN_& V,const KN_ & Viso, R coef,int iu=0,int iv=0,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true,double ArrowSize=-1) const ; // Arrow - R2 MinMax(const KN_& U,const KN_& V,int j0,int j1,bool bb=true) const ; - R2 MinMax(const KN_& U,int j0, bool bb=true) const ; - // void destroy() {RefCounter::destroy();} - bool isFEMesh() const { return !cdef && ( N==1) ;} // to make optim - void Show() const { - // cout << " Show: FESpace " << this << " " << N << " "; if(cdef) cout << cdef->NodesOfElement << endl;else cout << endl; - } + class FMortar { + public: + friend class FESpace; + const FESpace &Vh; + const Mortar &M; + const int *p; + const int nbn; // nb of node + // const int nbnl,nbnr; // nb of node left, right + + // we supposse + // the node numbering in a mortar is + // 1 the lagrange mul. + // 2 the node of left side + // 3 the node of right side + + const int N; + TypeOfMortar const *const tom; + FMortar(const FESpace *VVh, int k); + + public: + int operator[](int i) const; + int operator( )(int i, int df) const; // { N\u00c9 du DoF du noeud i de df local df + int operator( )(int df) const { return operator( )(NodeOfDF(df), DFOfNode(df)); } + int NbDoF(int i) const; //{return tom->NbDoF(Vh.Th,M,i);}; // number of DF + int NbOfNodes( ) const { return nbn; } + int NbDoF( ) const; + int NodeOfDF(int i) const; + int DFOfNode(int i) const; + + int nbsm; // nb of submortar + aSubFMortar *sm; + ~FMortar( ) { + delete[] datai; + delete[] dataf; + } - private: // for gibbs - int gibbsv (long* ptvoi,long* vois,long* lvois,long* w,long* v); - -}; - -inline baseFElement::baseFElement( const FESpace &aVh, int k) - : Vh(aVh),T(Vh.Th[k]),tfe(aVh.TFE[k]),N(aVh.N),number(k){} - -inline baseFElement::baseFElement(const baseFElement & K, const TypeOfFE & atfe) - : Vh(K.Vh),T(K.T),tfe(&atfe),N(Vh.N),number(K.number){} - - -inline FElement::FElement(const FESpace * VVh,int k) - : baseFElement(*VVh,k) , - p(Vh.PtrFirstNodeOfElement(k)), - nb(Vh.NbOfNodesInElement(k)) - - {} - -inline int FElement::operator[](int i) const { - return p ? p[i] : ((&T[i])-Vh.Th.vertices);} - -inline int FElement::operator()(int i,int df) const { - return Vh.FirstDFOfNode(p ? p[i] : ((&T[i])-Vh.Th.vertices)) + df;} - -inline int FMortar::operator()(int i,int df) const {throwassert(p); - return Vh.FirstDFOfNode(p[i]) + df;} - -inline int FMortar::operator[](int i) const {throwassert(p); - return p[i];} - -inline int FElement::NbDoF(int i) const { - int node =p ? p[i] : ((&T[i])-Vh.Th.vertices); - return Vh.LastDFOfNode(node)-Vh.FirstDFOfNode(node);} - -void SetDefaultIsoValue(const KN_& U,KN_ & Viso); -void SetDefaultIsoValue(const KN_& u,const KN_& v,KN_ & Viso); -void MoveTo(R2 P); -void LineTo(R2 P) ; + int *datai; + R (**dataf)(const FESpace *, const aSubFMortar *, R); -/* -void operator=( KN_ & u,const FElementGlobalToLocal & x) -{ - int n=u.N(); - throwassert(n==x.S.NbDoF()); - for (int i=0;iNbDoF(Vh.Th,M);} -//inline int FMortar::NbOfNodes()const {return } -inline int FMortar::NodeOfDF(int i) const { return tom->NodeOfDF(Vh,M,i);} -inline int FMortar::DFOfNode(int i) const { return tom->DFOfNode(Vh,M,i);} - -inline ostream & operator << (ostream & f,const FElement & FE) - { - f << FE.number << "," < TFE; + + private: + ConstructDataFElement *cdef; // juste pour les constantes + public: + CountPointer< const Mesh > cmesh; + const int N; // dim espace d'arrive + const int Nproduit; // dim de l'espace produit generalement 1 + const int NbOfDF; + const int NbOfElements; + const int NbOfNodes; + const int nb_sub_fem; // nb de sous elements finis tensorise (independe au niveau des composantes) + int const *const dim_which_sub_fem; // donne les dependant des composantes liee a un meme sous element fini + // exemple si N=5, + // dim_which_sub_fem[0]=0; + // dim_which_sub_fem[1] =1; + // dim_which_sub_fem[2]= 2 + // dim_which_sub_fem[3] =2 + // dim_which_sub_fem[4] =3 + // => + // le sous elements fini 0 est lie a la composante 0 + // le sous elements fini 1 est lie a la composante 1 + // le sous elements fini 2 est lie aux composantes 2,3 + // le sous elements fini 3 est lie a la composante 4 + // donc pour les CL. les composante 2 et 3 sont lie car elle sont utiliser pour definir un + // meme degre de libert\u00e9. + + int const *const NodesOfElement; + int const *const FirstNodeOfElement; + int const *const FirstDfOfNodeData; + const TypeOfMortar *tom; + const int MaxNbNodePerElement; + const int MaxNbDFPerElement; + + // par defaut P1 + FESpace(const Mesh &TTh) + : Th(TTh), ptrTFE(0), TFE(1, 0, &P1Lagrange), cdef(0), cmesh(TTh), N(1), Nproduit(1), NbOfDF(TTh.nv), NbOfElements(TTh.nt), NbOfNodes(TTh.nv), nb_sub_fem(TFE[0]->nb_sub_fem), + dim_which_sub_fem(TFE[0]->dim_which_sub_fem), NodesOfElement(0), FirstNodeOfElement(0), FirstDfOfNodeData(0), tom(0), MaxNbNodePerElement(3), MaxNbDFPerElement(3 * Nproduit) { + if (!lockOrientation) { + cerr << " Error, lockOrientation must be true to build fespace ; must check orientation element for mesh"; + assert(lockOrientation); } - - f << endl << " FirstDFOfNode :" ; - for (int i=0;i<=Vh.NbOfNodes;i++) - {if (i%10==0) cout << "\n" << setw(3) << i << " : "; - cout << setw(3) << Vh.FirstDFOfNode(i) << " ";} - - return f; - - } - -inline void FElement::BF(const R2 & PHat,RNMK_ & val) const { - static bool whatdold[last_operatortype]={true,true,true,false,false,false,false,false,false,false}; - tfe->FB(whatdold,Vh.Th,T,PHat,val);} -inline void FElement::BF(const bool * whatd,const R2 & PHat,RNMK_ & val) const { tfe->FB(whatd,Vh.Th,T,PHat,val);} -//inline void FElement::D2_BF(const R2 & P,RNMK_ & val) const { tfe->D2_FB(Vh.Th,T,P,val);} - -// ------- - extern const TypeOfMortar & TheMortarCas1P2; - -void PlotValue(const RN_ & Viso,int k0,const char * cmm); - -// to store all the type of TFE -// the problem is the TFE can be define on lot of file.cpp -struct ListOfTFE { - const char * name; - TypeOfFE * tfe; - ListOfTFE * next; - - static ListOfTFE * all ; // list of all object of this type - ListOfTFE (const char * n,TypeOfFE *t); -}; -// to get a unique list of TypeOfFE -// local variable of TypeOfFE -ListOfTFE & GetListOfTFE() ; - - -inline R FElement::operator()(const R2 & PHat, - const KN_ & u,int i,int op) const -{ - return (*tfe)(*this,PHat,u,i,op); -} + } + int FirstDFOfNode(int i) const { return FirstDfOfNodeData ? FirstDfOfNodeData[i] : i * Nproduit; } + int LastDFOfNode(int i) const { return FirstDfOfNodeData ? FirstDfOfNodeData[i + 1] : (i + 1) * Nproduit; } + int NbDFOfNode(int i) const { return FirstDfOfNodeData ? FirstDfOfNodeData[i + 1] - FirstDfOfNodeData[i] : Nproduit; } + int MaximalNbOfNodes( ) const { return MaxNbNodePerElement; }; + int MaximalNbOfDF( ) const { return MaxNbDFPerElement; }; + const int *PtrFirstNodeOfElement(int k) const { return NodesOfElement ? NodesOfElement + (FirstNodeOfElement ? FirstNodeOfElement[k] : k * MaxNbNodePerElement) : 0; } -inline complex FElement::operator()(const R2 & PHat,const KN_ > & u,int i,int op) const -{ - complex * pu=u; // pointeur du tableau - double *pr = static_cast(static_cast(pu)); + int SizeToStoreAllNodeofElement( ) const { return FirstNodeOfElement ? FirstNodeOfElement[NbOfElements] : MaxNbNodePerElement * NbOfElements; } - const KN_ ur(pr,u.n,u.step*2); - const KN_ ui(pr+1,u.n,u.step*2); - - return complex((*tfe)(*this,PHat,ur,i,op),(*tfe)(*this,PHat,ui,i,op)); -} + int NbOfNodesInElement(int k) const { return FirstNodeOfElement ? FirstNodeOfElement[k + 1] - FirstNodeOfElement[k] : MaxNbNodePerElement; } + int esize( ) const { return MaxNbDFPerElement * N * last_operatortype; } // size to store all value of B. function -} + FESpace(const FESpace &, int k); + FESpace(const FESpace **, int k); + FESpace(const Mesh &TTh, const TypeOfFE **, int k, int nbdfv = 0, const int *ndfv = 0, int nbdfe = 0, const int *ndfe = 0); // int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); + + FESpace(const Mesh &TTh, const TypeOfFE &, int nbdfv = 0, const int *ndfv = 0, int nbdfe = 0, const int *ndfe = 0); // int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); + + FESpace(const Mesh &TTh, const TypeOfFE &, const TypeOfMortar &); // int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); + ~FESpace( ); + // FESpace(Mesh & TTh,int NbDfOnSommet,int ndfonEdge,int ndfonFace,int NN=1); + int renum( ); + + FElement operator[](int k) const { return FElement(this, k); } + FElement operator[](const Triangle &K) const { return FElement(this, Th.number(K)); } + int operator( )(int k) const { return NbOfNodesInElement(k); } + int operator( )(int k, int i) const { // the node i of element k + return NodesOfElement ? *(PtrFirstNodeOfElement(k) + i) : Th(k, i); + } + + void Draw(const KN_< R > &U, const KN_< R > &Viso, int j = 0, float *colors = 0, int nbcolors = 0, bool hsv = true, bool drawborder = true) const; // Draw iso line + void Drawfill(const KN_< R > &U, const KN_< R > &Viso, int j = 0, double rapz = 1, float *colors = 0, int nbcolors = 0, bool hsv = true, bool drawborder = true) const; // Draw iso line + + template< class R > + KN< R > newSaveDraw(const KN_< R > &U, int composante, int &lg, int &nsb) const; + template< class R > + KN< R > newSaveDraw(const KN_< R > &U, const KN_< R > &V, int iU, int IV, int &lg, int &nsb) const; + void Draw(const KN_< R > &U, const KN_< R > &Viso, R coef, int j0 = 0, int j1 = 1, float *colors = 0, int nbcolors = 0, bool hsv = true, bool drawborder = true, + double ArrowSize = -1) const; // Arrow + void Draw(const KN_< R > &U, const KN_< R > &V, const KN_< R > &Viso, R coef, int iu = 0, int iv = 0, float *colors = 0, int nbcolors = 0, bool hsv = true, bool drawborder = true, + double ArrowSize = -1) const; // Arrow + R2 MinMax(const KN_< R > &U, const KN_< R > &V, int j0, int j1, bool bb = true) const; + R2 MinMax(const KN_< R > &U, int j0, bool bb = true) const; + // void destroy() {RefCounter::destroy();} + bool isFEMesh( ) const { return !cdef && (N == 1); } // to make optim + void Show( ) const { + // cout << " Show: FESpace " << this << " " << N << " "; if(cdef) cout << cdef->NodesOfElement << endl;else cout << endl; + } + + private: // for gibbs + int gibbsv(long *ptvoi, long *vois, long *lvois, long *w, long *v); + }; + + inline baseFElement::baseFElement(const FESpace &aVh, int k) : Vh(aVh), T(Vh.Th[k]), tfe(aVh.TFE[k]), N(aVh.N), number(k) {} + + inline baseFElement::baseFElement(const baseFElement &K, const TypeOfFE &atfe) : Vh(K.Vh), T(K.T), tfe(&atfe), N(Vh.N), number(K.number) {} + + inline FElement::FElement(const FESpace *VVh, int k) + : baseFElement(*VVh, k), p(Vh.PtrFirstNodeOfElement(k)), nb(Vh.NbOfNodesInElement(k)) + + {} + + inline int FElement::operator[](int i) const { return p ? p[i] : ((&T[i]) - Vh.Th.vertices); } + + inline int FElement::operator( )(int i, int df) const { return Vh.FirstDFOfNode(p ? p[i] : ((&T[i]) - Vh.Th.vertices)) + df; } + + inline int FMortar::operator( )(int i, int df) const { + throwassert(p); + return Vh.FirstDFOfNode(p[i]) + df; + } + + inline int FMortar::operator[](int i) const { + throwassert(p); + return p[i]; + } + + inline int FElement::NbDoF(int i) const { + int node = p ? p[i] : ((&T[i]) - Vh.Th.vertices); + return Vh.LastDFOfNode(node) - Vh.FirstDFOfNode(node); + } + + void SetDefaultIsoValue(const KN_< R > &U, KN_< R > &Viso); + void SetDefaultIsoValue(const KN_< R > &u, const KN_< R > &v, KN_< R > &Viso); + void MoveTo(R2 P); + void LineTo(R2 P); + + /* + void operator=( KN_ & u,const FElementGlobalToLocal & x) + { + int n=u.N(); + throwassert(n==x.S.NbDoF()); + for (int i=0;iNbDoF(Vh.Th, M); } + // inline int FMortar::NbOfNodes()const {return } + inline int FMortar::NodeOfDF(int i) const { return tom->NodeOfDF(Vh, M, i); } + inline int FMortar::DFOfNode(int i) const { return tom->DFOfNode(Vh, M, i); } + + inline ostream &operator<<(ostream &f, const FElement &FE) { + f << FE.number << "," << FE.nb << ":"; + for (int i = 0; i < FE.nb; i++) f << "\t" << FE.p[i]; + return f; + } + inline ostream &operator<<(ostream &f, const FESpace &Vh) { + cout << " list of nodes per element :" << endl; + for (int k = 0; k < Vh.NbOfElements; k++) { + f << setw(3) << k << ":"; + for (int j = 0; j < Vh(k); j++) f << " " << setw(3) << Vh(k, j); + cout << endl; + } + + f << endl << " FirstDFOfNode :"; + for (int i = 0; i <= Vh.NbOfNodes; i++) { + if (i % 10 == 0) cout << "\n" << setw(3) << i << " : "; + cout << setw(3) << Vh.FirstDFOfNode(i) << " "; + } + + return f; + } + + inline void FElement::BF(const R2 &PHat, RNMK_ &val) const { + static bool whatdold[last_operatortype] = {true, true, true, false, false, false, false, false, false, false}; + tfe->FB(whatdold, Vh.Th, T, PHat, val); + } + inline void FElement::BF(const bool *whatd, const R2 &PHat, RNMK_ &val) const { tfe->FB(whatd, Vh.Th, T, PHat, val); } + // inline void FElement::D2_BF(const R2 & P,RNMK_ & val) const { tfe->D2_FB(Vh.Th,T,P,val);} + + // ------- + extern const TypeOfMortar &TheMortarCas1P2; + + void PlotValue(const RN_ &Viso, int k0, const char *cmm); + + // to store all the type of TFE + // the problem is the TFE can be define on lot of file.cpp + struct ListOfTFE { + const char *name; + TypeOfFE *tfe; + ListOfTFE *next; + + static ListOfTFE *all; // list of all object of this type + ListOfTFE(const char *n, TypeOfFE *t); + }; + // to get a unique list of TypeOfFE + // local variable of TypeOfFE + ListOfTFE &GetListOfTFE( ); + + inline R FElement::operator( )(const R2 &PHat, const KN_< R > &u, int i, int op) const { return (*tfe)(*this, PHat, u, i, op); } + + inline complex< R > FElement::operator( )(const R2 &PHat, const KN_< complex< R > > &u, int i, int op) const { + complex< double > *pu = u; // pointeur du tableau + double *pr = static_cast< double * >(static_cast< void * >(pu)); + + const KN_< R > ur(pr, u.n, u.step * 2); + const KN_< R > ui(pr + 1, u.n, u.step * 2); + + return complex< R >((*tfe)(*this, PHat, ur, i, op), (*tfe)(*this, PHat, ui, i, op)); + } +} // namespace Fem2D #endif diff --git a/src/femlib/FESpacen.cpp b/src/femlib/FESpacen.cpp index cc4a55e19..b15c3c669 100644 --- a/src/femlib/FESpacen.cpp +++ b/src/femlib/FESpacen.cpp @@ -2,36 +2,35 @@ // ORIG-DATE: Jan 2008 // -*- Mode : c++ -*- // -// SUMMARY : Generic Fiinite Element 1d, 2d, 3d -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE +// SUMMARY : Generic Fiinite Element 1d, 2d, 3d +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Thank to the ARN () FF2A3 grant - ref:ANR-07-CIS7-002-01 + ref:ANR-07-CIS7-002-01 */ - #include #include "ufunction.hpp" @@ -45,233 +44,194 @@ #include "FESpacen.hpp" #include "splitsimplex.hpp" - int UniqueffId::count=0; - namespace Fem2D { - -//template -int nbdf_d(const int ndfitem[4],const int nd[4]) -{ - const int ndf = ndfitem[0]*nd[0] + ndfitem[1]*nd[1]+ ndfitem[2]*nd[2] + ndfitem[3]*nd[3]; - return ndf; -} - -//template -int nbnode_d(const int ndfitem[4],const int nd[4]) -{ - // const int nd[]= {Element::nv, Element::ne,Element::nf,Element::nt}; - const int ndf = nd[0]*(ndfitem[0]!=0) + nd[1]*(ndfitem[1]!=0)+ nd[2]*(ndfitem[2]!=0) + nd[3]*(ndfitem[3]!=0); +int UniqueffId::count = 0; +namespace Fem2D { + + // template + int nbdf_d(const int ndfitem[4], const int nd[4]) { + const int ndf = ndfitem[0] * nd[0] + ndfitem[1] * nd[1] + ndfitem[2] * nd[2] + ndfitem[3] * nd[3]; return ndf; -} - -//template -int *builddata_d(const int ndfitem[4],const int nd[4],int N) -{ - // const int d=Element::Rd::d; - // const int nwhat=Element::nitem; - // const int nd[]= {Element::nv, Element::ne,Element::nf,Element::nt}; - // const int nitem=nd[0]+nd[1]+nd[2]+nd[3]; - // cout << " nitem="<< nitem<< endl; - const int ndf = nbdf_d(ndfitem,nd); - const int nnode=nbnode_d(ndfitem,nd); - int lgdata= ndf*5+N; - int * data = new int[lgdata]; - int p=0; - for(int i=0,nw=0;i<=3;++i) - for(int j=0;j + int nbnode_d(const int ndfitem[4], const int nd[4]) { + // const int nd[]= {Element::nv, Element::ne,Element::nf,Element::nt}; + const int ndf = nd[0] * (ndfitem[0] != 0) + nd[1] * (ndfitem[1] != 0) + nd[2] * (ndfitem[2] != 0) + nd[3] * (ndfitem[3] != 0); + return ndf; + } + + // template + int *builddata_d(const int ndfitem[4], const int nd[4], int N) { + // const int d=Element::Rd::d; + // const int nwhat=Element::nitem; + // const int nd[]= {Element::nv, Element::ne,Element::nf,Element::nt}; + // const int nitem=nd[0]+nd[1]+nd[2]+nd[3]; + // cout << " nitem="<< nitem<< endl; + const int ndf = nbdf_d(ndfitem, nd); + const int nnode = nbnode_d(ndfitem, nd); + int lgdata = ndf * 5 + N; + int *data = new int[lgdata]; + int p = 0; + for (int i = 0, nw = 0; i <= 3; ++i) + for (int j = 0; j < nd[i]; ++j, nw++) // pour les what (support de node) + for (int k = 0; k < ndfitem[i]; ++k) // + data[p++] = nw; + // cout << p << " " < &teb) { + const int k = teb.N( ); + KN< int > NN(k + 1), DF(k + 1), comp(k + 1); + map< dataTypeOfFE const *, int > m; + int i = k, j; + while (i--) // on va a l'envert pour avoir comp[i] <=i + m[teb[i]] = i; + // l'ordre comp est important comp est croissant mais pas de pb. + i = k; + while (i--) comp[i] = m[teb[i]]; // comp[i] <=i + int n = 0, N = 0; + for (j = 0; j < k; j++) { + NN[j] = N; + N += teb[j]->N; } - // cout << p << " " << 3*ndf << " " << nitem << endl; - for(int i=0;i &teb) -{ - const int k = teb.N(); - KN NN(k+1), DF(k+1) , comp(k+1); - map< dataTypeOfFE const *,int> m; - int i=k,j; - while(i--) // on va a l'envert pour avoir comp[i] <=i - m[teb[i]]=i; - // l'ordre comp est important comp est croissant mais pas de pb. - i=k; - while(i--) - comp[i]=m[teb[i]]; // comp[i] <=i - int n=0,N=0; - for ( j=0;jN;} NN[k] = N; - // reservation des interval en df - n=0; - for ( j=0;jNbDoF;} + // reservation des interval en df + n = 0; + for (j = 0; j < k; j++) { + DF[j] = n; + n += teb[j]->NbDoF; + } DF[k] = n; - - int NbDoF=0; - int dfon[4]={0,0,0,0}; - int nbsubdivision=0; - int discon=0; - for (int i=0;iNbDoF; - dfon[0] += teb[i]->ndfonVertex; - dfon[1] += teb[i]->ndfonEdge; - dfon[2] += teb[i]->ndfonFace; - dfon[3] += teb[i]->ndfonVolume; - nbsubdivision = max(nbsubdivision,teb[i]->nbsubdivision); - discon = discon || teb[i]->discontinue; // bof bof 1 FE discontinue => discontinue - } - int nwhat=15; // 15 = 4+6+1+1 (nb of support item (what) : vertex, edges, fqces, tet) - - int ostart=nwhat; - int * data0=new int[ostart+7*NbDoF+N]; - int * data=data0+ostart; - int * data1=data+5*NbDoF; - - int c=0; - KN w(nwhat),nn(nwhat); - - w=0; - nn=0; - - - for ( j=0;jNbDoF;i++) - nn[teb[j]->DFOnWhat[i]]++; - int nbn=0; - for( j=0;j dln(nwhat); - dln=0; - // nn donne numero de noeud sur what - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOnWhat[i]; - - for ( j=0;jNbDoF;i++) - data[c++] = teb[j]->DFOfNode[i]+dln[teb[j]->DFOnWhat[i]]; - for ( i=0;iNbDoF;i++) - dln[teb[j]->DFOnWhat[i]]=Max(dln[teb[j]->DFOnWhat[i]],data[cc++]+1); - } - - - for ( j=0;jNbDoF;i++) - data[c++] = nn[teb[j]->DFOnWhat[i]]; + + int NbDoF = 0; + int dfon[4] = {0, 0, 0, 0}; + int nbsubdivision = 0; + int discon = 0; + for (int i = 0; i < k; ++i) { + NbDoF += teb[i]->NbDoF; + dfon[0] += teb[i]->ndfonVertex; + dfon[1] += teb[i]->ndfonEdge; + dfon[2] += teb[i]->ndfonFace; + dfon[3] += teb[i]->ndfonVolume; + nbsubdivision = max(nbsubdivision, teb[i]->nbsubdivision); + discon = discon || teb[i]->discontinue; // bof bof 1 FE discontinue => discontinue + } + int nwhat = 15; // 15 = 4+6+1+1 (nb of support item (what) : vertex, edges, fqces, tet) + + int ostart = nwhat; + int *data0 = new int[ostart + 7 * NbDoF + N]; + int *data = data0 + ostart; + int *data1 = data + 5 * NbDoF; + + int c = 0; + KN< int > w(nwhat), nn(nwhat); + + w = 0; + nn = 0; + + for (j = 0; j < k; j++) + for (i = 0; i < teb[j]->NbDoF; i++) nn[teb[j]->DFOnWhat[i]]++; + int nbn = 0; + for (j = 0; j < nwhat; j++) + if (nn[j]) + nn[j] = nbn++; + else + nn[j] = -1; + KN< int > dln(nwhat); + dln = 0; + // nn donne numero de noeud sur what + for (j = 0; j < k; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOnWhat[i]; + + for (j = 0; j < k; j++) { + int cc = c; + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = teb[j]->DFOfNode[i] + dln[teb[j]->DFOnWhat[i]]; + for (i = 0; i < teb[j]->NbDoF; i++) dln[teb[j]->DFOnWhat[i]] = Max(dln[teb[j]->DFOnWhat[i]], data[cc++] + 1); + } + + for (j = 0; j < k; j++) { + // w renumerotation des noeuds + // Ok si un noeud par what + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = nn[teb[j]->DFOnWhat[i]]; + } + + for (j = 0; j < k; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = j; // node from of FE + + for (j = 0; j < k; j++) + for (i = 0; i < teb[j]->NbDoF; i++) data[c++] = i; // node from of df in FE + // error -- here + // in case of [P2,P2],P1 + // we expect 0,0,1 and we get 0 1 2 + // => wrong BC ???? + c += 2 * n; // on saute le deux tableau en plus (cf data1.) + + int xx = 0; + for (j = 0; j < k; j++) { + int xxx = xx; + for (i = 0; i < teb[j]->N; i++) { + data[c] = teb[j]->dim_which_sub_fem[i] + xx; + xxx = Max(xxx, data[c] + 1); + c++; } - - for ( j=0;jNbDoF;i++) - data[c++] = j; // node from of FE - - - for ( j=0;jNbDoF;i++) - data[c++] = i; // node from of df in FE - // error -- here - //in case of [P2,P2],P1 - // we expect 0,0,1 and we get 0 1 2 - // => wrong BC ???? - c+=2*n; // on saute le deux tableau en plus (cf data1.) - - - int xx=0; - for (j=0;jN;i++) - { - data[c] = teb[j]->dim_which_sub_fem[i]+xx; - xxx=Max(xxx,data[c]+1); - c++; - } - xx=xxx; + xx = xxx; + } + + // ou dans la partie miminal element finite atomic + + int ci = n; + int cj = 0; + int ccc = 0; + for (j = 0; j < k; ccc += teb[j++]->nb_sub_fem) + + for (i = 0; i < teb[j]->NbDoF; i++) { + int il = teb[j]->fromASubDF[i]; + int jl = teb[j]->fromASubFE[i]; + data1[ci++] = il; + data1[cj++] = ccc + jl; } - - - // ou dans la partie miminal element finite atomic - - int ci=n; - int cj=0; - int ccc=0; - for ( j=0;jnb_sub_fem) - - for ( i=0;iNbDoF;i++) - { - int il= teb[j]->fromASubDF[i]; - int jl= teb[j]->fromASubFE[i]; - data1[ci++]=il; - data1[cj++]=ccc+jl; - } - - int nb_sub_fem=ccc; - - ffassert(c== 7*n+N); + + int nb_sub_fem = ccc; + + ffassert(c == 7 * n + N); /* int cc=0; cout << " Data : " << endl; for ( i=0;i<5;i++) { @@ -282,423 +242,329 @@ int *builddata_d(const int nitemdim[4],const KN< dataTypeOfFE const *> &teb) for (i=0;i & tef) -: -data(builddata_d(nitemdim,tef)), -dataalloc(data), -ndfonVertex(data[0]), -ndfonEdge(data[1]), -ndfonFace(data[2]), -ndfonVolume(data[3]), -NbDoF(data[4]), -NbNode(data[5]), -N(data[6]), -nb_sub_fem(data[7]), -nbsubdivision(data[8]), -discontinue(data[9]), -DFOnWhat(data+15+0*NbDoF), -DFOfNode(data+15+1*NbDoF), -NodeOfDF(data+15+2*NbDoF), -fromFE(data+15+3*NbDoF), -fromDF(data+15+4*NbDoF), -fromASubFE(data+15+5*NbDoF), -fromASubDF(data+15+6*NbDoF) , -dim_which_sub_fem(data+15+7*NbDoF) -{} - -template -void GTypeOfFESum::init(InterpolationMatrix & M,FElement * pK,int odf,int ocomp,int *pp) const -{ - // a faire ..... cas matrix invariante - assert(0); -} - -template - GTypeOfFESum::GTypeOfFESum(const KN< GTypeOfFE const *> & t) - : - GTypeOfFE(t), - k(t.N()), - teb(t), - NN(k+1), - DF(k+1) , - comp(k+1) {Build();} - -template -static KN< GTypeOfFE const *> kn(const GFESpace ** tt,int kk) - { - KN< GTypeOfFE const *> r(kk); - for(int i=0;iTFE[0];ffassert(tt[i]->TFE.constant());} - return r; - } -template -static KN< GTypeOfFE const *> kn(const GFESpace & tt,int kk) - { - return KN< GTypeOfFE const *> (kk,tt.TFE[0]); - } - -template - GTypeOfFESum::GTypeOfFESum(const GFESpace ** tt,int kk) - : - GTypeOfFE(kn(tt,kk)), - k(kk), - teb(kn(tt,kk)), - NN(k+1), - DF(k+1) , - comp(k+1) {Build();} - -template - GTypeOfFESum::GTypeOfFESum(const GFESpace & tt,int kk) - : - GTypeOfFE(kn(tt,kk)), - k(kk), - teb(kn(tt,kk)), - NN(k+1), - DF(k+1) , - comp(k+1) {Build();} - -template -void GTypeOfFESum::Build() -{ - bool debug=verbosity>5;; - { - const KN< GTypeOfFE const *> & t=teb; - map *,int> m; - int i=k,j; - while(i--) // on va a l'envert pour avoir comp[i] <=i - m[teb[i]]=i; - // l'ordre comp est important comp est croissant mais pas de pb. - i=k; - while(i--) - comp[i]=m[teb[i]]; // comp[i] <=i - - // reservatition des intervalles en espaces - int n=0,N=0; - for ( j=0;jN;} - NN[k] = N; - // reservation des interval en df - n=0; - for ( j=0;jNbDoF;} - DF[k] = n; } - int ii=0; - for (int i=0;i &tef) + : data(builddata_d(nitemdim, tef)), dataalloc(data), ndfonVertex(data[0]), ndfonEdge(data[1]), ndfonFace(data[2]), ndfonVolume(data[3]), NbDoF(data[4]), NbNode(data[5]), N(data[6]), + nb_sub_fem(data[7]), nbsubdivision(data[8]), discontinue(data[9]), DFOnWhat(data + 15 + 0 * NbDoF), DFOfNode(data + 15 + 1 * NbDoF), NodeOfDF(data + 15 + 2 * NbDoF), + fromFE(data + 15 + 3 * NbDoF), fromDF(data + 15 + 4 * NbDoF), fromASubFE(data + 15 + 5 * NbDoF), fromASubDF(data + 15 + 6 * NbDoF), dim_which_sub_fem(data + 15 + 7 * NbDoF) {} + + template< class Mesh > + void GTypeOfFESum< Mesh >::init(InterpolationMatrix< RdHat > &M, FElement *pK, int odf, int ocomp, int *pp) const { + // a faire ..... cas matrix invariante + assert(0); + } + + template< class Mesh > + GTypeOfFESum< Mesh >::GTypeOfFESum(const KN< GTypeOfFE< Mesh > const * > &t) : GTypeOfFE< Mesh >(t), k(t.N( )), teb(t), NN(k + 1), DF(k + 1), comp(k + 1) { + Build( ); + } + + template< class Mesh > + static KN< GTypeOfFE< Mesh > const * > kn(const GFESpace< Mesh > **tt, int kk) { + KN< GTypeOfFE< Mesh > const * > r(kk); + for (int i = 0; i < kk; ++i) { + r[i] = tt[i]->TFE[0]; + ffassert(tt[i]->TFE.constant( )); + } + return r; + } + template< class Mesh > + static KN< GTypeOfFE< Mesh > const * > kn(const GFESpace< Mesh > &tt, int kk) { + return KN< GTypeOfFE< Mesh > const * >(kk, tt.TFE[0]); + } + + template< class Mesh > + GTypeOfFESum< Mesh >::GTypeOfFESum(const GFESpace< Mesh > **tt, int kk) : GTypeOfFE< Mesh >(kn(tt, kk)), k(kk), teb(kn(tt, kk)), NN(k + 1), DF(k + 1), comp(k + 1) { + Build( ); + } + + template< class Mesh > + GTypeOfFESum< Mesh >::GTypeOfFESum(const GFESpace< Mesh > &tt, int kk) : GTypeOfFE< Mesh >(kn(tt, kk)), k(kk), teb(kn(tt, kk)), NN(k + 1), DF(k + 1), comp(k + 1) { + Build( ); + } + + template< class Mesh > + void GTypeOfFESum< Mesh >::Build( ) { + bool debug = verbosity > 5; + ; { - for (int j=0;jnb_sub_fem;++j) - this->Sub_ToFE[ii++]=teb[i]->Sub_ToFE[j]; + const KN< GTypeOfFE< Mesh > const * > &t = teb; + map< const GTypeOfFE< Mesh > *, int > m; + int i = k, j; + while (i--) // on va a l'envert pour avoir comp[i] <=i + m[teb[i]] = i; + // l'ordre comp est important comp est croissant mais pas de pb. + i = k; + while (i--) comp[i] = m[teb[i]]; // comp[i] <=i + + // reservatition des intervalles en espaces + int n = 0, N = 0; + for (j = 0; j < k; j++) { + NN[j] = N; + N += teb[j]->N; + } + NN[k] = N; + // reservation des interval en df + n = 0; + for (j = 0; j < k; j++) { + DF[j] = n; + n += teb[j]->NbDoF; + } + DF[k] = n; } - assert(ii==this->nb_sub_fem ); - - int c=0,c0=0, fcom=0; - for (int i=0;inb_sub_fem;i++) - { - int N=this->Sub_ToFE[i]->N; - int ndofi=this->Sub_ToFE[i]->NbDoF; - this->first_comp[i]= fcom; - this->last_comp[i]= fcom+N; + int ii = 0; + for (int i = 0; i < k; ++i) { + for (int j = 0; j < teb[i]->nb_sub_fem; ++j) this->Sub_ToFE[ii++] = teb[i]->Sub_ToFE[j]; + } + assert(ii == this->nb_sub_fem); + + int c = 0, c0 = 0, fcom = 0; + for (int i = 0; i < this->nb_sub_fem; i++) { + int N = this->Sub_ToFE[i]->N; + int ndofi = this->Sub_ToFE[i]->NbDoF; + this->first_comp[i] = fcom; + this->last_comp[i] = fcom + N; fcom += N; - for(int j=0;jbegin_dfcomp[c] = c0 + this->Sub_ToFE[i]->begin_dfcomp[j] ; - this->end_dfcomp[c] = c0 + this->Sub_ToFE[i]->end_dfcomp[j] ; - c++; - } - c0+=ndofi; - + for (int j = 0; j < N; ++j) { + this->begin_dfcomp[c] = c0 + this->Sub_ToFE[i]->begin_dfcomp[j]; + this->end_dfcomp[c] = c0 + this->Sub_ToFE[i]->end_dfcomp[j]; + c++; + } + c0 += ndofi; } - if(debug) - { - cout <<" NbDoF : " << this->NbDoF <N;++i) - cout << " comp " << i << " ["<begin_dfcomp[i]<<", "<< this->end_dfcomp[i]<< "[\n"; + if (debug) { + cout << " NbDoF : " << this->NbDoF << endl; + for (int i = 0; i < this->N; ++i) cout << " comp " << i << " [" << this->begin_dfcomp[i] << ", " << this->end_dfcomp[i] << "[\n"; } - - // construction de l'interpolation . - - int npi=0; - int nci=0; - bool var=true; - for (int i=0;inb_sub_fem;i++) - { - npi +=this->Sub_ToFE[i]->NbPtforInterpolation; - nci +=this->Sub_ToFE[i]->NbcoefforInterpolation; + + // construction de l'interpolation . + + int npi = 0; + int nci = 0; + bool var = true; + for (int i = 0; i < this->nb_sub_fem; i++) { + npi += this->Sub_ToFE[i]->NbPtforInterpolation; + nci += this->Sub_ToFE[i]->NbcoefforInterpolation; var = var && this->Sub_ToFE[i]->invariantinterpolationMatrix; } - assert(this->NbcoefforInterpolation== nci); - this->invariantinterpolationMatrix=var; - // this->pInterpolation.init(nci); - // this->cInterpolation.init(nci); - // this->dofInterpolation.iniy(nci); - KN opi(this->nb_sub_fem);// offset numumber point intgartion - { - map mpt; - numPtInterpolation.init(npi); - int npp=0,kkk=0; - KN Ptt(npi); - for (int i=0;inb_sub_fem;i++) - { - opi[i]=kkk; - const GTypeOfFE &ti=*this->Sub_ToFE[i]; - - for(int p=0;p100) - cout << " p= "<< p << " [ " << Ptt[kkk]<< "] , "<< kkk<< " "<< npp<< " " << numPtInterpolation[kkk]<< endl;; - - } + assert(this->NbcoefforInterpolation == nci); + this->invariantinterpolationMatrix = var; + // this->pInterpolation.init(nci); + // this->cInterpolation.init(nci); + // this->dofInterpolation.iniy(nci); + KN< int > opi(this->nb_sub_fem); // offset numumber point intgartion + { + map< RdHat, int, lessRd > mpt; + numPtInterpolation.init(npi); + int npp = 0, kkk = 0; + KN< RdHat > Ptt(npi); + for (int i = 0; i < this->nb_sub_fem; i++) { + opi[i] = kkk; + const GTypeOfFE< Mesh > &ti = *this->Sub_ToFE[i]; + + for (int p = 0; p < ti.NbPtforInterpolation; ++p, ++kkk) { + Ptt[kkk] = ti.PtInterpolation[p]; + if (mpt.find(Ptt[kkk]) == mpt.end( )) mpt[Ptt[kkk]] = npp++; + numPtInterpolation[kkk] = mpt[Ptt[kkk]]; + if (verbosity > 100) cout << " p= " << p << " [ " << Ptt[kkk] << "] , " << kkk << " " << npp << " " << numPtInterpolation[kkk] << endl; + ; + } } - assert(this->NbPtforInterpolation==0); - if(verbosity>5) - cout << npp; - this->NbPtforInterpolation=npp; - this->PtInterpolation.init(npp); - for(int i=0;iPtInterpolation[numPtInterpolation[i]]=Ptt[i]; + assert(this->NbPtforInterpolation == 0); + if (verbosity > 5) cout << npp; + this->NbPtforInterpolation = npp; + this->PtInterpolation.init(npp); + for (int i = 0; i < kkk; ++i) // correction bug .. + this->PtInterpolation[numPtInterpolation[i]] = Ptt[i]; + } + + int oc = 0, odof = 0; + for (int i = 0, k = 0; i < this->nb_sub_fem; i++) { + const GTypeOfFE< Mesh > &ti = *this->Sub_ToFE[i]; + for (int j = 0; j < ti.NbcoefforInterpolation; ++j, ++k) { + this->pInterpolation[k] = numPtInterpolation[opi[i] + ti.pInterpolation[j]]; + this->cInterpolation[k] = ti.cInterpolation[j] + oc; + this->dofInterpolation[k] = ti.dofInterpolation[j] + odof; + this->coefInterpolation[k] = ti.coefInterpolation[j]; + } + oc += ti.N; + odof += ti.NbDoF; + } + if (verbosity > 100) { + cout << " **GTypeOfFESum::Build() p:" << this->pInterpolation << endl; + cout << " ** c :" << this->cInterpolation << endl; + cout << " ** dof :" << this->dofInterpolation << endl; + cout << " **G coef :" << this->coefInterpolation << endl; + } + assert(c == this->N); } - - int oc=0,odof=0; - for (int i=0,k=0;inb_sub_fem;i++) - { - const GTypeOfFE &ti=*this->Sub_ToFE[i]; - for(int j=0;jpInterpolation[k] = numPtInterpolation[opi[i]+ti.pInterpolation[j]]; - this->cInterpolation[k] = ti.cInterpolation[j]+oc; - this->dofInterpolation[k] = ti.dofInterpolation[j]+odof; - this->coefInterpolation[k]=ti.coefInterpolation[j]; - } + + template< class Mesh > + void GTypeOfFESum< Mesh >::set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int oocoef, int oodf, int *nnump) const { + int op = 0, oc = 0, odof = oodf, ocoef = oocoef; + assert(nnump == 0); + for (int i = 0, k = 0; i < this->nb_sub_fem; i++) { + const GTypeOfFE< Mesh > &ti = *this->Sub_ToFE[i]; + if (!ti.invariantinterpolationMatrix) ti.set(Th, K, M, ocoef, odof, &numPtInterpolation[op]); oc += ti.N; - odof += ti.NbDoF; + odof += ti.NbDoF; + ocoef += ti.NbcoefforInterpolation; + op += ti.NbPtforInterpolation; } - if(verbosity>100) - { - cout << " **GTypeOfFESum::Build() p:" <pInterpolation <cInterpolation <dofInterpolation <coefInterpolation < 100) { + cout << " GTypeOfFESum set " << this->coefInterpolation << endl; + cout << " GTypeOfFESum set M.p " << M.p << endl; + cout << " \t numPtInterpolation:" << this->numPtInterpolation << endl; } - assert(c==this->N); -} - - -template void GTypeOfFESum::set(const Mesh & Th,const Element & K,InterpolationMatrix & M,int oocoef,int oodf,int *nnump ) const - { - int op=0,oc=0,odof=oodf,ocoef=oocoef; - assert(nnump==0); - for (int i=0,k=0;inb_sub_fem;i++) - { - const GTypeOfFE &ti=*this->Sub_ToFE[i]; - if(!ti.invariantinterpolationMatrix) - ti.set(Th,K,M,ocoef,odof,&numPtInterpolation[op]); - oc += ti.N; - odof += ti.NbDoF; - ocoef += ti.NbcoefforInterpolation; - op += ti.NbPtforInterpolation; - - } - if( verbosity > 100) - { - cout << " GTypeOfFESum set "<< this->coefInterpolation << endl; - cout << " GTypeOfFESum set M.p "<< M.p << endl; - cout << " \t numPtInterpolation:"<< this->numPtInterpolation << endl; - } - } - -template - GFESpace::GFESpace(const GFESpace & Vh,int kk,int nbequibe,int *equibe) - : - GFESpacePtrTFE(new GTypeOfFESum(Vh,kk)), - DataFENodeDF(Vh.Th.BuildDFNumbering(this->ptrTFE->ndfonVertex,this->ptrTFE->ndfonEdge,this->ptrTFE->ndfonFace,this->ptrTFE->ndfonVolume,nbequibe,equibe)), - Th(Vh.Th), - TFE(1,0,this->ptrTFE), - cmesh(Th), - N(TFE[0]->N), - Nproduit(kk), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), - maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) - - { - } - -template - GFESpace::GFESpace(const GFESpace ** pVh,int kk,int nbequibe,int *equibe) - : - GFESpacePtrTFE(new GTypeOfFESum(pVh,kk)), - DataFENodeDF((**pVh).Th.BuildDFNumbering(this->ptrTFE->ndfonVertex,this->ptrTFE->ndfonEdge,this->ptrTFE->ndfonFace,this->ptrTFE->ndfonVolume,nbequibe,equibe)), - Th((**pVh).Th), - TFE(1,0,this->ptrTFE), - cmesh(Th), - N(TFE[0]->N), - Nproduit(FirstDfOfNodeData ? 1 :MaxNbDFPerNode), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), - maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) - - { - long snbdf=0; - for(int i=0;iNbOfDF; - if( snbdf !=NbOfDF) - cerr << " Problem build of GFESpace (3d) (may be : due to periodic Boundary condition missing ) FH " << endl - << " The number of DF must be " << snbdf << " and it is " << NbOfDF <Th); - } - - template - template - KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const - { - const int d = Rd::d; - Rd *Ps=0; - int *Ks=0; - int nsb = TFE[0]->nbsubdivision; - int nvsub,nksub; - SplitSimplex(nsb, nvsub, Ps, nksub , Ks); - ffassert( Psub.unset()); - ffassert( Ksub.unset()); - Psub.set(Ps,nvsub); - Ksub.set(Ks,nksub*(d+1)); - lg= nvsub*Th.nt; - KN v(lg); - for (int k=0,i=0;k(true,v);// to remove the copy. - } - - - template< > - template - KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const - { - typedef typename MeshS::RdHat RdHat; - const int dHat = RdHat::d; - MeshS::RdHat *Ps=0; - int *Ks=0; - int nsb = TFE[0]->nbsubdivision; - int nvsub,nksub; - SplitSimplex(nsb, nvsub, Ps, nksub , Ks); - ffassert( Psub.unset()); - ffassert( Ksub.unset()); - Psub.set(Ps,nvsub); - Ksub.set(Ks,nksub*(dHat+1)); - lg= nvsub*Th.nt; - KN v(lg); - for (int k=0,i=0;k(true,v);// to remove the copy. - } - - - template< > - template - KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const - { - typedef typename MeshL::RdHat RdHat; - const int dHat = RdHat::d; - MeshL::RdHat *Ps=0; - int *Ks=0; - int nsb = TFE[0]->nbsubdivision; - int nvsub,nksub; - SplitSimplex(nsb, nvsub, Ps, nksub , Ks); - ffassert( Psub.unset()); - ffassert( Ksub.unset()); - Psub.set(Ps,nvsub); - Ksub.set(Ks,nksub*(dHat+1)); - lg= nvsub*Th.nt; - KN v(lg); - for (int k=0,i=0;k(true,v);// to remove the copy. - } - - - - /* - template - KN GFESpace::newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const - { - nsb = TFE[0]->nbsubdivision; - int nsbv = NbOfSubInternalVertices(nsb,d); - lg = nsbv*Th.nt; - cout << "newSaveDraw what: nt " << Th.nt << " " << nsbv << " " << lg << endl; - KN v(lg); - ffassert(v); - for (int k=0,i=0;k(true,v);// to remove the copy. - } - */ - // explicite instance.. - template class GTypeOfFESum; - template class GTypeOfFESum; - template class GTypeOfFESum; - template class GTypeOfFESum; - template class GFESpace; - template class GFESpace; - template class GFESpace; - template class GFESpace; - template class GFESpace; - - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - - typedef std::complex Complex; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - template KN GFESpace::newSaveDraw(const KN_ & U,int componante,int & lg,KN &Psub,KN &Ksub,int op_U) const ; - - - } + } + + template< class MMesh > + GFESpace< MMesh >::GFESpace(const GFESpace &Vh, int kk, int nbequibe, int *equibe) + : GFESpacePtrTFE< MMesh >(new GTypeOfFESum< MMesh >(Vh, kk)), + DataFENodeDF(Vh.Th.BuildDFNumbering(this->ptrTFE->ndfonVertex, this->ptrTFE->ndfonEdge, this->ptrTFE->ndfonFace, this->ptrTFE->ndfonVolume, nbequibe, equibe)), Th(Vh.Th), + TFE(1, 0, this->ptrTFE), cmesh(Th), N(TFE[0]->N), Nproduit(kk), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) + + {} + + template< class MMesh > + GFESpace< MMesh >::GFESpace(const GFESpace **pVh, int kk, int nbequibe, int *equibe) + : GFESpacePtrTFE< MMesh >(new GTypeOfFESum< MMesh >(pVh, kk)), + DataFENodeDF((**pVh).Th.BuildDFNumbering(this->ptrTFE->ndfonVertex, this->ptrTFE->ndfonEdge, this->ptrTFE->ndfonFace, this->ptrTFE->ndfonVolume, nbequibe, equibe)), Th((**pVh).Th), + TFE(1, 0, this->ptrTFE), cmesh(Th), N(TFE[0]->N), Nproduit(FirstDfOfNodeData ? 1 : MaxNbDFPerNode), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) + + { + long snbdf = 0; + for (int i = 0; i < kk; ++i) snbdf += pVh[i]->NbOfDF; + if (snbdf != NbOfDF) + cerr << " Problem build of GFESpace (3d) (may be : due to periodic Boundary condition missing ) FH " << endl << " The number of DF must be " << snbdf << " and it is " << NbOfDF << endl; + ffassert(snbdf == NbOfDF); + + for (int i = 0; i < kk; ++i) ffassert(&Th == &pVh[i]->Th); + } + + template< class MMesh > + template< class R > + KN< R > GFESpace< MMesh >::newSaveDraw(const KN_< R > &U, int componante, int &lg, KN< typename MMesh::RdHat > &Psub, KN< int > &Ksub, int op_U) const { + const int d = Rd::d; + Rd *Ps = 0; + int *Ks = 0; + int nsb = TFE[0]->nbsubdivision; + int nvsub, nksub; + SplitSimplex< Rd >(nsb, nvsub, Ps, nksub, Ks); + ffassert(Psub.unset( )); + ffassert(Ksub.unset( )); + Psub.set(Ps, nvsub); + Ksub.set(Ks, nksub * (d + 1)); + lg = nvsub * Th.nt; + KN< R > v(lg); + for (int k = 0, i = 0; k < Th.nt; k++) { + FElement K = (*this)[k]; + for (int l = 0; l < nvsub; l++) v[i++] = K(Psub[l], U, componante, op_U); + } + return KN< R >(true, v); // to remove the copy. + } + + template<> + template< class R > + KN< R > GFESpace< MeshS >::newSaveDraw(const KN_< R > &U, int componante, int &lg, KN< typename MeshS::RdHat > &Psub, KN< int > &Ksub, int op_U) const { + typedef typename MeshS::RdHat RdHat; + const int dHat = RdHat::d; + MeshS::RdHat *Ps = 0; + int *Ks = 0; + int nsb = TFE[0]->nbsubdivision; + int nvsub, nksub; + SplitSimplex< RdHat >(nsb, nvsub, Ps, nksub, Ks); + ffassert(Psub.unset( )); + ffassert(Ksub.unset( )); + Psub.set(Ps, nvsub); + Ksub.set(Ks, nksub * (dHat + 1)); + lg = nvsub * Th.nt; + KN< R > v(lg); + for (int k = 0, i = 0; k < Th.nt; k++) { + FElementS K = (*this)[k]; + for (int l = 0; l < nvsub; l++) v[i++] = K(Psub[l], U, componante, op_U); + } + return KN< R >(true, v); // to remove the copy. + } + + template<> + template< class R > + KN< R > GFESpace< MeshL >::newSaveDraw(const KN_< R > &U, int componante, int &lg, KN< typename MeshL::RdHat > &Psub, KN< int > &Ksub, int op_U) const { + typedef typename MeshL::RdHat RdHat; + const int dHat = RdHat::d; + MeshL::RdHat *Ps = 0; + int *Ks = 0; + int nsb = TFE[0]->nbsubdivision; + int nvsub, nksub; + SplitSimplex< RdHat >(nsb, nvsub, Ps, nksub, Ks); + ffassert(Psub.unset( )); + ffassert(Ksub.unset( )); + Psub.set(Ps, nvsub); + Ksub.set(Ks, nksub * (dHat + 1)); + lg = nvsub * Th.nt; + KN< R > v(lg); + for (int k = 0, i = 0; k < Th.nt; k++) { + FElementL K = (*this)[k]; + for (int l = 0; l < nvsub; l++) v[i++] = K(Psub[l], U, componante, op_U); + } + return KN< R >(true, v); // to remove the copy. + } + + /* + template + KN GFESpace::newSaveDraw(const KN_ & U,int composante,int & lg,int & nsb) const + { + nsb = TFE[0]->nbsubdivision; + int nsbv = NbOfSubInternalVertices(nsb,d); + lg = nsbv*Th.nt; + cout << "newSaveDraw what: nt " << Th.nt << " " << nsbv << " " << lg << endl; + KN v(lg); + ffassert(v); + for (int k=0,i=0;k(true,v);// to remove the copy. + } + */ + // explicite instance.. + template class GTypeOfFESum< Mesh2 >; + template class GTypeOfFESum< Mesh3 >; + template class GTypeOfFESum< MeshS >; + template class GTypeOfFESum< MeshL >; + template class GFESpace< Mesh1 >; + template class GFESpace< Mesh2 >; + template class GFESpace< Mesh3 >; + template class GFESpace< MeshS >; + template class GFESpace< MeshL >; + + template KN< double > GFESpace< MeshL >::newSaveDraw< double >(const KN_< double > &U, int componante, int &lg, KN< typename MeshL::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< double > GFESpace< MeshS >::newSaveDraw< double >(const KN_< double > &U, int componante, int &lg, KN< typename MeshS::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< double > GFESpace< Mesh3 >::newSaveDraw< double >(const KN_< double > &U, int componante, int &lg, KN< typename Mesh3::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< double > GFESpace< Mesh2 >::newSaveDraw< double >(const KN_< double > &U, int componante, int &lg, KN< typename Mesh2::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< double > GFESpace< Mesh1 >::newSaveDraw< double >(const KN_< double > &U, int componante, int &lg, KN< typename Mesh1::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + + typedef std::complex< double > Complex; + template KN< Complex > GFESpace< MeshL >::newSaveDraw< Complex >(const KN_< Complex > &U, int componante, int &lg, KN< typename MeshL::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< Complex > GFESpace< MeshS >::newSaveDraw< Complex >(const KN_< Complex > &U, int componante, int &lg, KN< typename MeshS::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< Complex > GFESpace< Mesh3 >::newSaveDraw< Complex >(const KN_< Complex > &U, int componante, int &lg, KN< typename Mesh3::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< Complex > GFESpace< Mesh2 >::newSaveDraw< Complex >(const KN_< Complex > &U, int componante, int &lg, KN< typename Mesh2::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + template KN< Complex > GFESpace< Mesh1 >::newSaveDraw< Complex >(const KN_< Complex > &U, int componante, int &lg, KN< typename Mesh1::RdHat > &Psub, KN< int > &Ksub, int op_U) const; + +} // namespace Fem2D diff --git a/src/femlib/FESpacen.hpp b/src/femlib/FESpacen.hpp index fff003b8a..cd649130f 100644 --- a/src/femlib/FESpacen.hpp +++ b/src/femlib/FESpacen.hpp @@ -2,33 +2,33 @@ // ORIG-DATE: Jan 2008 // -*- Mode : c++ -*- // -// SUMMARY : Generic Fiinite Element header 1d, 2d, 3d -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE +// SUMMARY : Generic Fiinite Element header 1d, 2d, 3d +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Thank to the ARN () FF2A3 grant - ref:ANR-07-CIS7-002-01 + ref:ANR-07-CIS7-002-01 */ #ifndef FESpacen_HPP_ @@ -59,768 +59,647 @@ using namespace std; #include "RNM.hpp" - #include "QuadratureFormular.hpp" namespace Fem2D { -template class GFESpace; -template class GFElement; -template class GbaseFElement; -template class GTypeOfFE; - -// numbering of derivative -enum operatortype { - op_id=0, - op_dx=1,op_dy=2, - op_dxx=3,op_dyy=4, - op_dyx=5,op_dxy=5, - op_dz=6, - op_dzz=7, - op_dzx=8,op_dxz=8, - op_dzy=9,op_dyz=9 -}; - -typedef unsigned int What_d; - -const unsigned int Fop_id= 1<< op_id; - -const unsigned int Fop_dx= 1<< op_dx; -const unsigned int Fop_dy= 1<< op_dy; -const unsigned int Fop_dz= 1<< op_dz; - -const unsigned int Fop_dxx= 1<< op_dxx; -const unsigned int Fop_dxy= 1<< op_dxy; -const unsigned int Fop_dxz= 1<< op_dxz; - -const unsigned int Fop_dyx= 1<< op_dyx; -const unsigned int Fop_dyy= 1<< op_dyy; -const unsigned int Fop_dyz= 1<< op_dyz; - -const unsigned int Fop_dzx= 1<< op_dzx; -const unsigned int Fop_dzy= 1<< op_dzy; -const unsigned int Fop_dzz= 1<< op_dzz; - -const unsigned int Fop_D0 = Fop_id; -const unsigned int Fop_D1 = Fop_dx | Fop_dy | Fop_dz; -const unsigned int Fop_D2 = Fop_dxx | Fop_dyy | Fop_dzz | Fop_dxy | Fop_dxz | Fop_dyz; -const unsigned int Fop_Dall = Fop_D0| Fop_D1| Fop_D2; - -inline What_d Fwhatd(const operatortype op) { return 1<< op;} - - -const int last_operatortype=10; -const bool operatortypeValue[last_operatortype]= {true,false,false,false,false,false,false,false,false,false} ; - - -inline void initwhatd(bool *whatd,int k) -{ - for (int i=0;i RN_; -typedef KN RN; -typedef KNM_ RNM_; -typedef KNMK_ RNMK_; -typedef KNMK RNMK; - -template class GFElement; -template class GFESpace; -templateclass GTypeOfFE ; - -class dataTypeOfFE { - - -private: - const int * data; - const int * dataalloc; - -public: - const int ndfonVertex; + template< class Mesh > + class GFESpace; + template< class Mesh > + class GFElement; + template< class Mesh > + class GbaseFElement; + template< class Mesh > + class GTypeOfFE; + + // numbering of derivative + enum operatortype { op_id = 0, op_dx = 1, op_dy = 2, op_dxx = 3, op_dyy = 4, op_dyx = 5, op_dxy = 5, op_dz = 6, op_dzz = 7, op_dzx = 8, op_dxz = 8, op_dzy = 9, op_dyz = 9 }; + + typedef unsigned int What_d; + + const unsigned int Fop_id = 1 << op_id; + + const unsigned int Fop_dx = 1 << op_dx; + const unsigned int Fop_dy = 1 << op_dy; + const unsigned int Fop_dz = 1 << op_dz; + + const unsigned int Fop_dxx = 1 << op_dxx; + const unsigned int Fop_dxy = 1 << op_dxy; + const unsigned int Fop_dxz = 1 << op_dxz; + + const unsigned int Fop_dyx = 1 << op_dyx; + const unsigned int Fop_dyy = 1 << op_dyy; + const unsigned int Fop_dyz = 1 << op_dyz; + + const unsigned int Fop_dzx = 1 << op_dzx; + const unsigned int Fop_dzy = 1 << op_dzy; + const unsigned int Fop_dzz = 1 << op_dzz; + + const unsigned int Fop_D0 = Fop_id; + const unsigned int Fop_D1 = Fop_dx | Fop_dy | Fop_dz; + const unsigned int Fop_D2 = Fop_dxx | Fop_dyy | Fop_dzz | Fop_dxy | Fop_dxz | Fop_dyz; + const unsigned int Fop_Dall = Fop_D0 | Fop_D1 | Fop_D2; + + inline What_d Fwhatd(const operatortype op) { return 1 << op; } + + const int last_operatortype = 10; + const bool operatortypeValue[last_operatortype] = {true, false, false, false, false, false, false, false, false, false}; + + inline void initwhatd(bool *whatd, int k) { + for (int i = 0; i < last_operatortype; i++) whatd[i] = false; + whatd[k] = true; + } + + typedef double R; + typedef KN_< R > RN_; + typedef KN< R > RN; + typedef KNM_< R > RNM_; + typedef KNMK_< R > RNMK_; + typedef KNMK< R > RNMK; + + template< class Mesh > + class GFElement; + template< class Mesh > + class GFESpace; + template< class Mesh > + class GTypeOfFE; + + class dataTypeOfFE { + + private: + const int *data; + const int *dataalloc; + + public: + const int ndfonVertex; const int ndfonEdge; const int ndfonFace; const int ndfonVolume; const int NbDoF; const int NbNode; - int N,nb_sub_fem; - const int nbsubdivision; // nb of subdivision for plot + int N, nb_sub_fem; + const int nbsubdivision; // nb of subdivision for plot const bool discontinue; - int const * const DFOnWhat; - int const * const DFOfNode; // nu du df on Node - int const * const NodeOfDF; // nu du node du df - int const * const fromFE; // the df come from df of FE - int const * const fromDF; // the df come from with FE - int const * const fromASubFE; // avril 2006 for CL - int const * const fromASubDF; // avril 2006 for CL - int const * const dim_which_sub_fem; // from atomic sub FE for CL - const int * ndfOn() const { return & ndfonVertex;} - - dataTypeOfFE(const int *nnitemdim,const int dfon[4],int NN,int nbsubdivisionn,int nb_sub_femm=1,bool discon=true); - // pour evite un template - // nitemdim : nbitem : si d==2 3,3,1,0 , si d=3: 4,6,4,1 , si d==1 = 2,1,0,0 - // dfon : nombre de df par item - // NN - dataTypeOfFE(const int nitemdim[4],const KN< dataTypeOfFE const *> & tef); - - virtual ~dataTypeOfFE(){ if(dataalloc) delete [] dataalloc;} - }; - -template -class InterpolationMatrix { -public: - const int N,np,ncoef; - bool invariant; - int k; - KN P; - KN coef; - KN comp; - KN p; - KN dofe; - - template - InterpolationMatrix(const GFESpace &Vh); - - template - InterpolationMatrix(const GTypeOfFE & tef); - - template - void set(const GFElement & FK); - - -private: // copie interdit ... - InterpolationMatrix(const InterpolationMatrix &); - void operator=(const InterpolationMatrix &); -}; - -template -ostream & operator<<(ostream& f,const InterpolationMatrix &M) -{ f<< M.N << " k "<< M.k << " np "<< M.np << " nc "<< M.ncoef << endl; - f<< " = P = " << M.P ; - f << "\ncoef=" < QF; + + const GFESpace< Mesh > &Vh; + const Element &T; + const GTypeOfFE< Mesh > *tfe; + const int N; + const int number; + GbaseFElement(const GFESpace< Mesh > &aVh, int k); + GbaseFElement(const GbaseFElement &K, const GTypeOfFE< Mesh > &atfe); + R EdgeOrientation(int i) const { return T.EdgeOrientation(i); } + }; + + template< class Mesh > + class GFElement : public GbaseFElement< Mesh > { + public: + typedef typename Mesh::Element Element; + typedef Element E; + typedef typename E::Rd Rd; + typedef typename E::RdHat RdHat; + typedef Fem2D::GQuadratureFormular< RdHat > QF; + + friend class GFESpace< Mesh >; + const int *p; + const int nb; + + GFElement(const GFESpace< Mesh > *VVh, int k); + + int NbOfNodes( ) const { return nb; } + int operator[](int i) const; //{ return p ? p+i : ((&T[i])-Vh.Th.vertices);} N\u00c9 du noeud + int NbDoF(int i) const; // number of DF + int operator( )(int i, int df) const; // { N\u00c9 du DoF du noeud i de df local df + int operator( )(int df) const { return operator( )(NodeOfDF(df), DFOfNode(df)); } + // void Draw(const KN_ & U, const KN_ & VIso,int j=0) const ; + // void Drawfill(const KN_ & U, const KN_ & VIso,int j=0,double rapz=1) const ; + // void Draw(const RN_& U,const RN_& V, const KN_ & Viso,R coef,int i0,int i1) const; + // Rd MinMax(const RN_& U,const RN_& V,int i0,int i1) const ; + // Rd MinMax(const RN_& U,int i0) const ; + void BF(const RdHat &PHat, RNMK_ &val) const; // { tfe->FB(Vh.Th,T,P,val);} + void BF(const What_d whatd, const RdHat &PHat, RNMK_ &val) const; // { tfe->FB(Vh.Th,T,P,val);} + void set(InterpolationMatrix< RdHat > &M) const { this->tfe->set(this->Vh.Th, this->T, M, 0, 0, 0); } + // add april 08 begin end number for df of the componante ic + int dfcbegin(int ic) const { return this->tfe->begin_dfcomp[ic]; } + int dfcend(int ic) const { return this->tfe->end_dfcomp[ic]; } + // the fist and last composant of a sub finite element + // int firstcomp(int isfe) const {return this->tfe->first_comp[isfe];} + // int lastcomp(int isfe) const {return this->tfe->last_comp[isfe];} + int subFE(int df) const { return this->tfe->fromASubFE[df]; } + + template< class RR > + KN_< RR > &Pi_h(KNM_< RR > vpt, KN_< RR > &vdf, InterpolationMatrix< RdHat > &M) const { + // compute the interpolation + // in : vpt value of componant j at point p : vpt(p,j) + // out: vdf value du the degre of freedom + vdf = RR( ); + + if (M.k != this->number) M.set((const GFElement &)*this); + + for (int k = 0; k < M.ncoef; ++k) { + vdf[M.dofe[k]] += M.coef[k] * vpt(M.p[k], M.comp[k]); + if (verbosity > 99) cout << " ... " << vdf[M.dofe[k]] << " " << k << " " << M.dofe[k] << " += " << M.coef[k] << " " << M.p[k] << " " << M.comp[k] << " " << vpt(M.p[k], M.comp[k]) << endl; + } + return vdf; + } + + int NbDoF( ) const { return this->tfe->NbDoF; } + int DFOnWhat(int i) const { return this->tfe->DFOnWhat[i]; } + int FromDF(int i) const { return this->tfe->fromDF[i]; } + int FromFE(int i) const { return this->tfe->fromFE[i]; } + + // df is the df in element + int NodeOfDF(int df) const { return this->tfe->NodeOfDF[df]; } // a node + int FromASubFE(int i) const { return this->tfe->fromASubFE[i]; } + int FromASubDF(int i) const { return this->tfe->fromASubDF[i]; } + int DFOfNode(int df) const { return this->tfe->DFOfNode[df]; } // the df number on the node + + R operator( )(const RdHat &PHat, const KN_< R > &u, int i, int op) const; + complex< R > operator( )(const RdHat &PHat, const KN_< complex< R > > &u, int i, int op) const; + + // GFElementGlobalToLocal operator()(const KN_ & u ) const { return GFElementGlobalToLocal(*this,u);} + private: + int nbsubdivision( ) const { return this->tfe->nbsubdivision; } // for draw + }; + + template< class MMesh > + class BuildTFE { + protected: + GTypeOfFE< MMesh > const *const tfe; + }; + template< class MMesh > + struct GFESpacePtrTFE { + GTypeOfFE< MMesh > const *const ptrTFE; + GFESpacePtrTFE(GTypeOfFE< MMesh > const *const pptrTFE = 0) : ptrTFE(pptrTFE) {} + virtual ~GFESpacePtrTFE( ) { + if (ptrTFE) delete ptrTFE; } - return vdf; - } - - - int NbDoF() const {return this->tfe->NbDoF;} - int DFOnWhat(int i) const { return this->tfe->DFOnWhat[i];} - int FromDF(int i) const { return this->tfe->fromDF[i];} - int FromFE(int i) const { return this->tfe->fromFE[i];} - - // df is the df in element - int NodeOfDF(int df) const { return this->tfe->NodeOfDF[df];} // a node - int FromASubFE(int i) const { return this->tfe->fromASubFE[i];} - int FromASubDF(int i) const { return this->tfe->fromASubDF[i];} - int DFOfNode(int df) const { return this->tfe->DFOfNode[df];} // the df number on the node - - R operator()(const RdHat & PHat,const KN_ & u,int i,int op) const ; - complex operator()(const RdHat & PHat,const KN_ > & u,int i,int op) const ; - - // GFElementGlobalToLocal operator()(const KN_ & u ) const { return GFElementGlobalToLocal(*this,u);} -private: - int nbsubdivision() const { return this->tfe->nbsubdivision;} // for draw -}; - - -template - class BuildTFE { protected: - GTypeOfFE const * const tfe; - }; - -template -struct GFESpacePtrTFE { - GTypeOfFE const * const ptrTFE; - GFESpacePtrTFE(GTypeOfFE const * const pptrTFE=0) : ptrTFE(pptrTFE) {} - virtual ~GFESpacePtrTFE() { if(ptrTFE) delete ptrTFE;} -}; - -template -class GFESpace : public RefCounter,protected GFESpacePtrTFE, public DataFENodeDF, public UniqueffId { -public: - typedef MMesh Mesh; - typedef GFElement FElement; - typedef typename Mesh::Element Element; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef GTypeOfFE TypeOfFE; - typedef GQuadratureFormular QFElement; - typedef GQuadratureFormular QFBorderElement; - - const Mesh &Th; - - KN *> TFE; -private: - -public: - CountPointer cmesh; - const int N; // dim espace d'arrive - const int Nproduit; // 1 if non constant Max number df par node. else Max number df par node.. - const int nb_sub_fem; // nb de sous elements finis tensorise (independe au niveau des composantes) - int const* const dim_which_sub_fem;// donne les dependant des composantes liee a un meme sous element fini - const int maxNbPtforInterpolation; - const int maxNbcoefforInterpolation; - - // exemple si N=5, - // dim_which_sub_fem[0]=0; - // dim_which_sub_fem[1] =1; - // dim_which_sub_fem[2]= 2 - // dim_which_sub_fem[3] =2 - // dim_which_sub_fem[4] =3 - // => - // le sous elements fini 0 est lie a la composante 0 - // le sous elements fini 1 est lie a la composante 1 - // le sous elements fini 2 est lie aux composantes 2,3 - // le sous elements fini 3 est lie a la composante 4 - // donc pour les CL. les composante 2 et 3 sont lie car elle sont utiliser pour definir un - // meme degre de libert\u00e9. - - // par defaut P1 - - GFESpace(const Mesh & TTh,const GTypeOfFE & tfe=DataFE::P1,int nbequibe=0,int *equibe=0) - : - GFESpacePtrTFE(0), - DataFENodeDF(TTh.BuildDFNumbering(tfe.ndfonVertex,tfe.ndfonEdge,tfe.ndfonFace,tfe.ndfonVolume,nbequibe,equibe)), - Th(TTh), - TFE(1,0,&tfe), - cmesh(TTh), - N(TFE[0]->N), - Nproduit(FirstDfOfNodeData ? 1 :MaxNbDFPerNode ), - nb_sub_fem(TFE[0]->nb_sub_fem), - dim_which_sub_fem(TFE[0]->dim_which_sub_fem), - maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), - maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) - - { - if(!lockOrientation) { - cerr << " Error, lockOrientation must be true to build fespace ; must check orientation element for mesh" ; - assert(lockOrientation); + }; + + template< class MMesh > + class GFESpace : public RefCounter, protected GFESpacePtrTFE< MMesh >, public DataFENodeDF, public UniqueffId { + public: + typedef MMesh Mesh; + typedef GFElement< Mesh > FElement; + typedef typename Mesh::Element Element; + typedef typename Mesh::BorderElement BorderElement; + typedef typename Mesh::Rd Rd; + typedef GTypeOfFE< Mesh > TypeOfFE; + typedef GQuadratureFormular< typename Element::RdHat > QFElement; + typedef GQuadratureFormular< typename BorderElement::RdHat > QFBorderElement; + + const Mesh &Th; + + KN< const GTypeOfFE< Mesh > * > TFE; + + private: + public: + CountPointer< const Mesh > cmesh; + const int N; // dim espace d'arrive + const int Nproduit; // 1 if non constant Max number df par node. else Max number df par node.. + const int nb_sub_fem; // nb de sous elements finis tensorise (independe au niveau des composantes) + int const *const dim_which_sub_fem; // donne les dependant des composantes liee a un meme sous element fini + const int maxNbPtforInterpolation; + const int maxNbcoefforInterpolation; + + // exemple si N=5, + // dim_which_sub_fem[0]=0; + // dim_which_sub_fem[1] =1; + // dim_which_sub_fem[2]= 2 + // dim_which_sub_fem[3] =2 + // dim_which_sub_fem[4] =3 + // => + // le sous elements fini 0 est lie a la composante 0 + // le sous elements fini 1 est lie a la composante 1 + // le sous elements fini 2 est lie aux composantes 2,3 + // le sous elements fini 3 est lie a la composante 4 + // donc pour les CL. les composante 2 et 3 sont lie car elle sont utiliser pour definir un + // meme degre de libert\u00e9. + + // par defaut P1 + + GFESpace(const Mesh &TTh, const GTypeOfFE< Mesh > &tfe = DataFE< Mesh >::P1, int nbequibe = 0, int *equibe = 0) + : GFESpacePtrTFE< MMesh >(0), DataFENodeDF(TTh.BuildDFNumbering(tfe.ndfonVertex, tfe.ndfonEdge, tfe.ndfonFace, tfe.ndfonVolume, nbequibe, equibe)), Th(TTh), TFE(1, 0, &tfe), cmesh(TTh), + N(TFE[0]->N), Nproduit(FirstDfOfNodeData ? 1 : MaxNbDFPerNode), nb_sub_fem(TFE[0]->nb_sub_fem), dim_which_sub_fem(TFE[0]->dim_which_sub_fem), + maxNbPtforInterpolation(TFE[0]->NbPtforInterpolation), maxNbcoefforInterpolation(TFE[0]->NbcoefforInterpolation) + + { + if (!lockOrientation) { + cerr << " Error, lockOrientation must be true to build fespace ; must check orientation element for mesh"; + assert(lockOrientation); } - if(verbosity) cout << " -- FESpace: Nb of Nodes " << NbOfNodes - << " Nb of DoF " << NbOfDF <& U,const KN_& Viso,int j=0,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Draw iso line void Drawfill(const KN_& U,const KN_& Viso,int j=0,double rapz=1,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Draw iso line - + void Draw(const KN_& U,const KN_ & Viso, R coef,int j0=0,int j1=1,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Arrow void Draw(const KN_& U,const KN_& V,const KN_ & Viso, R coef,int iu=0,int iv=0,float *colors=0,int nbcolors=0,bool hsv=true,bool drawborder=true) const ; // Arrow Rd MinMax(const KN_& U,const KN_& V,int j0,int j1,bool bb=true) const ; Rd MinMax(const KN_& U,int j0, bool bb=true) const ; // void destroy() {RefCounter::destroy();} */ - bool isFEMesh() const { return ! NodesOfElement && ( N==1) ;} // to make optim - template - KN newSaveDraw(const KN_ & U,int composante,int & lg,KN &Psub,KN &Ksub,int op_U=0) const ; - - - -private: // for gibbs - int gibbsv (long* ptvoi,long* vois,long* lvois,long* w,long* v); -}; - -template -inline GbaseFElement::GbaseFElement( const GFESpace &aVh, int k) - : Vh(aVh),T(Vh.Th[k]),tfe(aVh.TFE[k]),N(aVh.N),number(k){} - -template -inline GbaseFElement::GbaseFElement(const GbaseFElement & K, const GTypeOfFE & atfe) - : Vh(K.Vh),T(K.T),tfe(&atfe),N(Vh.N),number(K.number){} - -template -GFElement::GFElement(const GFESpace * VVh,int k) - : GbaseFElement(*VVh,k) , - p(this->Vh.PtrFirstNodeOfElement(k)), - nb(this->Vh.NbOfNodesInElement(k)) -{} - -template -inline int GFElement::operator[](int i) const { - return p ? p[i] : ((&this->T[i])-this->Vh.Th.vertices);} - -template -inline int GFElement::operator()(int i,int df) const { - return this->Vh.FirstDFOfNode(p ? p[i] : ((&this->T[i])-this->Vh.Th.vertices)) + df;} - -template -inline int GFElement::NbDoF(int i) const { - int node =p ? p[i] : ((&this->T[i])-this->Vh.Th.vertices); - return this->Vh.LastDFOfNode(node)-this->Vh.FirstDFOfNode(node);} - -template -inline void GFElement::BF(const RdHat & PHat,RNMK_ & val) const { - this->tfe->FB(Fop_D0|Fop_D1,this->Vh.Th,this->T,PHat,val);} - - -template - inline void GFElement::BF(const What_d whatd,const RdHat & PHat,RNMK_ & val) const { this->tfe->FB(whatd,this->Vh.Th,this->T,PHat,val);} - -//template - // inline void GFElement::set(InterpolationMatrix &M) const { this->tfe->set(this->Vh.Th,this->T,&M);} - -template -inline R GFElement::operator()(const RdHat & PHat, - const KN_ & u,int i,int op) const -{ - return (*this->tfe)(*this,PHat,u,i,op); -} - -template -inline complex GFElement::operator()(const RdHat & PHat,const KN_ > & u,int i,int op) const -{ - complex * pu=u; // pointeur du tableau - double *pr = static_cast(static_cast(pu)); - - const KN_ ur(pr,u.n,u.step*2); - const KN_ ui(pr+1,u.n,u.step*2); - - return complex((*this->tfe)(*this,PHat,ur,i,op),(*this->tfe)(*this,PHat,ui,i,op)); -} - - - -template -R GTypeOfFE::operator()(const GFElement & K,const RdHat & PHat,const KN_ & u,int componante,int op) const -{ - KNMK fb(NbDoF,N,last_operatortype); // the value for basic fonction - KN fk(NbDoF); - for (int i=0;i + KN< R > newSaveDraw(const KN_< R > &U, int composante, int &lg, KN< typename Mesh::RdHat > &Psub, KN< int > &Ksub, int op_U = 0) const; + + private: // for gibbs + int gibbsv(long *ptvoi, long *vois, long *lvois, long *w, long *v); + }; + + template< class Mesh > + inline GbaseFElement< Mesh >::GbaseFElement(const GFESpace< Mesh > &aVh, int k) : Vh(aVh), T(Vh.Th[k]), tfe(aVh.TFE[k]), N(aVh.N), number(k) {} + + template< class Mesh > + inline GbaseFElement< Mesh >::GbaseFElement(const GbaseFElement &K, const GTypeOfFE< Mesh > &atfe) : Vh(K.Vh), T(K.T), tfe(&atfe), N(Vh.N), number(K.number) {} + + template< class Mesh > + GFElement< Mesh >::GFElement(const GFESpace< Mesh > *VVh, int k) : GbaseFElement< Mesh >(*VVh, k), p(this->Vh.PtrFirstNodeOfElement(k)), nb(this->Vh.NbOfNodesInElement(k)) {} + + template< class Mesh > + inline int GFElement< Mesh >::operator[](int i) const { + return p ? p[i] : ((&this->T[i]) - this->Vh.Th.vertices); + } + + template< class Mesh > + inline int GFElement< Mesh >::operator( )(int i, int df) const { + return this->Vh.FirstDFOfNode(p ? p[i] : ((&this->T[i]) - this->Vh.Th.vertices)) + df; + } + + template< class Mesh > + inline int GFElement< Mesh >::NbDoF(int i) const { + int node = p ? p[i] : ((&this->T[i]) - this->Vh.Th.vertices); + return this->Vh.LastDFOfNode(node) - this->Vh.FirstDFOfNode(node); + } + + template< class Mesh > + inline void GFElement< Mesh >::BF(const RdHat &PHat, RNMK_ &val) const { + this->tfe->FB(Fop_D0 | Fop_D1, this->Vh.Th, this->T, PHat, val); + } + + template< class Mesh > + inline void GFElement< Mesh >::BF(const What_d whatd, const RdHat &PHat, RNMK_ &val) const { + this->tfe->FB(whatd, this->Vh.Th, this->T, PHat, val); + } + + // template + // inline void GFElement::set(InterpolationMatrix &M) const { this->tfe->set(this->Vh.Th,this->T,&M);} + + template< class Mesh > + inline R GFElement< Mesh >::operator( )(const RdHat &PHat, const KN_< R > &u, int i, int op) const { + return (*this->tfe)(*this, PHat, u, i, op); + } + + template< class Mesh > + inline complex< R > GFElement< Mesh >::operator( )(const RdHat &PHat, const KN_< complex< R > > &u, int i, int op) const { + complex< double > *pu = u; // pointeur du tableau + double *pr = static_cast< double * >(static_cast< void * >(pu)); + + const KN_< R > ur(pr, u.n, u.step * 2); + const KN_< R > ui(pr + 1, u.n, u.step * 2); + + return complex< R >((*this->tfe)(*this, PHat, ur, i, op), (*this->tfe)(*this, PHat, ui, i, op)); + } + + template< class Mesh > + R GTypeOfFE< Mesh >::operator( )(const GFElement< Mesh > &K, const RdHat &PHat, const KN_< R > &u, int componante, int op) const { + KNMK< R > fb(NbDoF, N, last_operatortype); // the value for basic fonction + KN< R > fk(NbDoF); + for (int i = 0; i < NbDoF; i++) // get the local value + fk[i] = u[K(i)]; // get value of basic function - FB( 1 << op ,K.Vh.Th,K.T,PHat,fb); - R r = (fb('.',componante,op),fk); + FB(1 << op, K.Vh.Th, K.T, PHat, fb); + R r = (fb('.', componante, op), fk); return r; -} - -int nbdf_d(const int ndfitem[4],const int nd[4]); -int nbnode_d(const int ndfitem[4],const int nd[4]); -int *builddata_d(const int ndfitem[4],const int nd[4]); - - - - -template -class GTypeOfFESum: public GTypeOfFE { - -public: - typedef GFElement FElement; - typedef typename Mesh::Element Element; - typedef typename Element::RdHat RdHat; - typedef typename Mesh::Rd Rd; - const int k; - KN *> teb; - KN NN,DF,comp,numPtInterpolation; - - GTypeOfFESum(const KN< GTypeOfFE const *> & t); - GTypeOfFESum(const GFESpace **,int kk); - GTypeOfFESum(const GFESpace &,int kk); - - void Build(); // the true constructor - - void init(InterpolationMatrix & M,FElement * pK=0,int odf=0,int ocomp=0,int *pp=0) const; - void set(const Mesh & Th,const Element & K,InterpolationMatrix & M,int ocoef,int odf,int *nump ) const; // no change by deflaut - void FB(const What_d whatd,const Mesh & Th,const Element & K,const RdHat &PHat, KNMK_ & val) const ; - ~GTypeOfFESum(){} -} ; - - -template -void GTypeOfFESum::FB(const What_d whatd,const Mesh & Th,const Element & K,const RdHat &PHat, KNMK_ & val) const -{ - val=0.0; - SubArray t(val.K()); - for (int i=0;iFB(whatd,Th,K,PHat,v); - else - v=val(SubArray(DF[j+1]-DF[j],DF[j]),SubArray(NN[j+1]-NN[j],NN[j]),t); - } -} - - - -template -template -InterpolationMatrix::InterpolationMatrix(const GFESpace &Vh) - : - N(Vh.N),np(Vh.maxNbPtforInterpolation),ncoef(Vh.maxNbcoefforInterpolation), - invariant(Vh.TFE.constant() ? Vh.TFE[0]->invariantinterpolationMatrix: false), - k(-1), - P(np), - comp(ncoef), - p(ncoef), - dofe(ncoef) -{ - Vh.TFE[0]->GTypeOfFE::init(*this,0,0,0,0); -} - -template -template -InterpolationMatrix::InterpolationMatrix(const GTypeOfFE & tef) - : - N(tef.N),np(tef.NbPtforInterpolation),ncoef(tef.NbcoefforInterpolation), - invariant(tef.invariantinterpolationMatrix), - k(-1), - P(np), - comp(ncoef), - p(ncoef), - dofe(ncoef) -{ - // virtual void init(InterpolationMatrix & M,FElement * pK=0,int odf=0,int ocomp=0,int *pp=0) const - tef.GTypeOfFE::init(*this,0,0,0,0); -} - -template template -void InterpolationMatrix::set(const GFElement & FK) -{ - if(k==FK.number) return; - k=FK.number; - if(invariant) return; + } + + int nbdf_d(const int ndfitem[4], const int nd[4]); + int nbnode_d(const int ndfitem[4], const int nd[4]); + int *builddata_d(const int ndfitem[4], const int nd[4]); + + template< class Mesh > + class GTypeOfFESum : public GTypeOfFE< Mesh > { + + public: + typedef GFElement< Mesh > FElement; + typedef typename Mesh::Element Element; + typedef typename Element::RdHat RdHat; + typedef typename Mesh::Rd Rd; + const int k; + KN< const GTypeOfFE< Mesh > * > teb; + KN< int > NN, DF, comp, numPtInterpolation; + + GTypeOfFESum(const KN< GTypeOfFE< Mesh > const * > &t); + GTypeOfFESum(const GFESpace< Mesh > **, int kk); + GTypeOfFESum(const GFESpace< Mesh > &, int kk); + + void Build( ); // the true constructor + + void init(InterpolationMatrix< RdHat > &M, FElement *pK = 0, int odf = 0, int ocomp = 0, int *pp = 0) const; + void set(const Mesh &Th, const Element &K, InterpolationMatrix< RdHat > &M, int ocoef, int odf, int *nump) const; // no change by deflaut + void FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, KNMK_< R > &val) const; + ~GTypeOfFESum( ) {} + }; + + template< class Mesh > + void GTypeOfFESum< Mesh >::FB(const What_d whatd, const Mesh &Th, const Element &K, const RdHat &PHat, KNMK_< R > &val) const { + val = 0.0; + SubArray t(val.K( )); + for (int i = 0; i < k; i++) { + int j = comp[i]; + int ni = NN[i]; + int di = DF[i]; + int i1 = i + 1; + int nii = NN[i1]; + int dii = DF[i1]; + assert(ni < nii && di < dii); + RNMK_ v(val(SubArray(dii - di, di), SubArray(nii - ni, ni), t)); + if (j <= i) + teb[i]->FB(whatd, Th, K, PHat, v); + else + v = val(SubArray(DF[j + 1] - DF[j], DF[j]), SubArray(NN[j + 1] - NN[j], NN[j]), t); + } + } + + template< class RdHat > + template< class Mesh > + InterpolationMatrix< RdHat >::InterpolationMatrix(const GFESpace< Mesh > &Vh) + : N(Vh.N), np(Vh.maxNbPtforInterpolation), ncoef(Vh.maxNbcoefforInterpolation), invariant(Vh.TFE.constant( ) ? Vh.TFE[0]->invariantinterpolationMatrix : false), k(-1), P(np), comp(ncoef), + p(ncoef), dofe(ncoef) { + Vh.TFE[0]->GTypeOfFE< Mesh >::init(*this, 0, 0, 0, 0); + } + + template< class RdHat > + template< class Mesh > + InterpolationMatrix< RdHat >::InterpolationMatrix(const GTypeOfFE< Mesh > &tef) + : N(tef.N), np(tef.NbPtforInterpolation), ncoef(tef.NbcoefforInterpolation), invariant(tef.invariantinterpolationMatrix), k(-1), P(np), comp(ncoef), p(ncoef), dofe(ncoef) { + // virtual void init(InterpolationMatrix & M,FElement * pK=0,int odf=0,int ocomp=0,int *pp=0) const + tef.GTypeOfFE< Mesh >::init(*this, 0, 0, 0, 0); + } + + template< class RdHat > + template< class Mesh > + void InterpolationMatrix< RdHat >::set(const GFElement< Mesh > &FK) { + if (k == FK.number) return; + k = FK.number; + if (invariant) return; FK.set(*this); - //assert(invariant); - // a faire ... -} - -typedef GTypeOfFE TypeOfFE3; -typedef GTypeOfFE TypeOfFES; -typedef GTypeOfFE TypeOfFEL; -typedef GFESpace FESpace3; -typedef GFESpace FESpaceS; -typedef GFESpace FESpaceL; -typedef GFESpace FESpace2; -typedef GFElement FElementL; -typedef GFElement FElement3; -typedef GFElement FElementS; -typedef GFElement FElement2; -typedef GbaseFElement baseFElement2; -typedef GbaseFElement baseFElement3; -typedef GbaseFElement baseFElementS; -typedef GbaseFElement baseFElementL; - -} + // assert(invariant); + // a faire ... + } + typedef GTypeOfFE< Mesh3 > TypeOfFE3; + typedef GTypeOfFE< MeshS > TypeOfFES; + typedef GTypeOfFE< MeshL > TypeOfFEL; + typedef GFESpace< Mesh3 > FESpace3; + typedef GFESpace< MeshS > FESpaceS; + typedef GFESpace< MeshL > FESpaceL; + typedef GFESpace< Mesh2 > FESpace2; + typedef GFElement< MeshL > FElementL; + typedef GFElement< Mesh3 > FElement3; + typedef GFElement< MeshS > FElementS; + typedef GFElement< Mesh2 > FElement2; + typedef GbaseFElement< Mesh2 > baseFElement2; + typedef GbaseFElement< Mesh3 > baseFElement3; + typedef GbaseFElement< MeshS > baseFElementS; + typedef GbaseFElement< MeshL > baseFElementL; + +} // namespace Fem2D #endif diff --git a/src/femlib/FQuadTree.cpp b/src/femlib/FQuadTree.cpp index beb3fcc7f..89b0cb86e 100644 --- a/src/femlib/FQuadTree.cpp +++ b/src/femlib/FQuadTree.cpp @@ -49,1191 +49,1002 @@ using namespace Fem2D; // new version ---------- // ---------------------- #ifdef DRAWING -void FQuadTree::PlotQuad(I2 pp,long hb) -{ - IMoveTo(pp.x,pp.y); - ILineTo(pp.x+hb,pp.y); - ILineTo(pp.x+hb,pp.y+hb); - ILineTo(pp.x ,pp.y+hb); - ILineTo(pp.x ,pp.y); +void FQuadTree::PlotQuad(I2 pp, long hb) { + IMoveTo(pp.x, pp.y); + ILineTo(pp.x + hb, pp.y); + ILineTo(pp.x + hb, pp.y + hb); + ILineTo(pp.x, pp.y + hb); + ILineTo(pp.x, pp.y); } -void FQuadTree::PlotX(I2 p,long hb) -{ - IMoveTo(p.x, p.y); - ILineTo(p.x+hb/2,p.y+hb/2); - IMoveTo(p.x+hb/2,p.y); - ILineTo(p.x ,p.y+hb/2); +void FQuadTree::PlotX(I2 p, long hb) { + IMoveTo(p.x, p.y); + ILineTo(p.x + hb / 2, p.y + hb / 2); + IMoveTo(p.x + hb / 2, p.y); + ILineTo(p.x, p.y + hb / 2); } -void FQuadTree::Draw() -{ - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; +void FQuadTree::Draw( ) { + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; I2 pp[MaxDeep]; - int l=0; // level - QuadTreeBox * b; - IntQuad hb = MaxISize; - if (!root) return ; - pb[0]= root; - pi[0]= root->n>0 ?(int) root->n : 4 ;; - pp[0].x=pp[0].y=0;//ii[0]=jj[0]=0; - do{ - b= pb[l]; - - while (pi[l]--) + int l = 0; // level + QuadTreeBox *b; + IntQuad hb = MaxISize; + if (!root) return; + pb[0] = root; + pi[0] = root->n > 0 ? (int)root->n : 4; + ; + pp[0].x = pp[0].y = 0; // ii[0]=jj[0]=0; + do { + b = pb[l]; + + while (pi[l]--) { + if (b->n > 0) // Vertex QuadTreeBox none empty { - if (b->n>0) // Vertex QuadTreeBox none empty - { - for (int k=0;kn;k++) - { - DrawMark(*b->v[k],0.002); - - } - break; - } - else // Pointer QuadTreeBox - { - int lll = pi[l]; - QuadTreeBox *b0=b; - - if ((b=b->b[lll])) - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],lll,hb); - - pb[++l]= b; - pi[l]= 4; - pp[l]=ppp; - PlotQuad(pp[l],hb); - } - else - { - I2 ppp(pp[l],lll,hb/2); - b=b0; - PlotX(ppp,hb/2); - } - } + for (int k = 0; k < b->n; k++) { + DrawMark(*b->v[k], 0.002); + } + break; + } else // Pointer QuadTreeBox + { + int lll = pi[l]; + QuadTreeBox *b0 = b; + + if ((b = b->b[lll])) { + hb >>= 1; // div by 2 + I2 ppp(pp[l], lll, hb); + + pb[++l] = b; + pi[l] = 4; + pp[l] = ppp; + PlotQuad(pp[l], hb); + } else { + I2 ppp(pp[l], lll, hb / 2); + b = b0; + PlotX(ppp, hb / 2); + } } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); - } #endif -Vertex * FQuadTree::TrueNearestVertex(long xi,long yj) -{ - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - I2 pp[ MaxDeep ]; - int l=0; // level - QuadTreeBox * b; - IntQuad h=MaxISize,h0; - IntQuad hb = MaxISize; - I2 p0(0,0); - I2 plus( xin) - return vn; // empty tree - - - // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : 4 ; - pp[0]=p0; - h=hb; - do { - b= pb[l]; - while (pi[l]--) - { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - I2 i2 = R2ToI2(b->v[k]); - h0 = I2(i2,plus).norm();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k]; - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } - } - hb <<= 1; // mul by 2 - } while (l--); - - return vn; -} -Vertex * FQuadTree::NearestVertex(long xi,long yj) -{ - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - I2 pp[ MaxDeep ]; - int l=0; // level - QuadTreeBox * b; - IntQuad h=MaxISize,h0; - IntQuad hb = MaxISize; - I2 p0(0,0); - I2 plus( xin) - return vn; // empty tree + long n0; + if (!root->n) return vn; // empty tree - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = plus.Case(hb2);//(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - QuadTreeBox * b0= b->b[k]; - if ( ( b0 == 0) || (b0->n == 0) ) - break; // null box or empty => break - NbQuadTreeBoxSearch++; - b=b0; - p0.Add(k,hb2); - hb = hb2; + // general case ----- + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + pp[0] = p0; + h = hb; + do { + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + I2 i2 = R2ToI2(b->v[k]); + h0 = I2(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = b->v[k]; + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + I2 ppp(pp[l], k, hb); + + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) + { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; + } } + hb <<= 1; // mul by 2 + } while (l--); + return vn; +} +Vertex *FQuadTree::NearestVertex(long xi, long yj) { + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + I2 pp[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + IntQuad h = MaxISize, h0; + IntQuad hb = MaxISize; + I2 p0(0, 0); + I2 plus(xi < MaxISize ? (xi < 0 ? 0 : xi) : MaxISize - 1, yj < MaxISize ? (yj < 0 ? 0 : yj) : MaxISize - 1); - if ( n0 > 0) - { - for( int k=0;kv[k]); - h0 = I2(i2,plus).norm();//NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k];} - NbVerticesSearch++; - } - return vn; + Vertex *vn = 0; + + // init for optimisation --- + b = root; + long n0; + if (!root->n) return vn; // empty tree + + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = plus.Case(hb2); //(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j + QuadTreeBox *b0 = b->b[k]; + if ((b0 == 0) || (b0->n == 0)) break; // null box or empty => break + NbQuadTreeBoxSearch++; + b = b0; + p0.Add(k, hb2); + hb = hb2; + } + + if (n0 > 0) { + for (int k = 0; k < n0; k++) { + I2 i2 = R2ToI2(b->v[k]); + h0 = I2(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = b->v[k]; + } + NbVerticesSearch++; } + return vn; + } // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : 4 ; - pp[0]=p0; - h=hb; + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + pp[0] = p0; + h = hb; do { - b= pb[l]; - while (pi[l]--) + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - I2 i2 = R2ToI2(b->v[k]); - h0 = I2(i2,plus).norm();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k]; - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + NbVerticesSearch++; + I2 i2 = R2ToI2(b->v[k]); + h0 = I2(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = b->v[k]; + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + I2 ppp(pp[l], k, hb); + + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) + { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); return vn; } // FH add to get the list for point close of point xi,yi at distance less the dh // jan 2020 -int FQuadTree::ListNearestVertex(Vertex **lnv,int nlvnx,long dh,long xi,long yj) -{ - int nlnv=0; - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - I2 pp[ MaxDeep ]; - int l=0; // level - QuadTreeBox * b; - IntQuad hunsed=MaxISize,h0; - IntQuad hb = MaxISize; - I2 p0(0,0); - I2 plus( xin) - return nlnv; // empty tree - - - // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : 4 ; - pp[0]=p0; - //h=dh; - do { - - while (pi[l]--) +int FQuadTree::ListNearestVertex(Vertex **lnv, int nlvnx, long dh, long xi, long yj) { + int nlnv = 0; + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + I2 pp[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + IntQuad hunsed = MaxISize, h0; + IntQuad hb = MaxISize; + I2 p0(0, 0); + I2 plus(xi < MaxISize ? (xi < 0 ? 0 : xi) : MaxISize - 1, yj < MaxISize ? (yj < 0 ? 0 : yj) : MaxISize - 1); + + Vertex *vn = 0; + + // init for optimisation --- + + b = root; + long n0; + if (!root->n) return nlnv; // empty tree + + // general case ----- + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + pp[0] = p0; + // h=dh; + do { + + while (pi[l]--) { + int k = pi[l]; + b = pb[l]; + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + I2 i2 = R2ToI2(b->v[k]); + h0 = I2(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < dh) { + vn = b->v[k]; + if (nlnv < nlvnx) lnv[nlnv++] = vn; + } + } else // Pointer QuadTreeBox + { + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) // new box { - int k = pi[l]; - b= pb[l]; - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - I2 i2 = R2ToI2(b->v[k]); - h0 = I2(i2,plus).norm();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k]; - if(nlnvb[k])) // new box - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,dh) ) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - pp[l]=ppp; - } - else - hb <<=1 ; - } - - } + hb >>= 1; // div by 2 + I2 ppp(pp[l], k, hb); + + if (ppp.interseg(plus, hb, dh)) { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + pp[l] = ppp; + } else + hb <<= 1; } - hb <<= 1; // mul by 2 - } while (l--); - - return nlnv; + } + } + hb <<= 1; // mul by 2 + } while (l--); + + return nlnv; } // end Add jan 2020 FH. - -Vertex * FQuadTree::ToClose(const R2 & v,R seuil,long hx,long hy,bool nearest) -{ - I2 H(hx,hy); - const I2 p(XtoI(v.x),YtoJ(v.y)); +Vertex *FQuadTree::ToClose(const R2 &v, R seuil, long hx, long hy, bool nearest) { + I2 H(hx, hy); + const I2 p(XtoI(v.x), YtoJ(v.y)); const R2 X(v); - R seuil2 = seuil*seuil; - Vertex *pvr =0; // return vertex - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - I2 pp[ MaxDeep ]; - - int l=0; // level - QuadTreeBox * b; + R seuil2 = seuil * seuil; + Vertex *pvr = 0; // return vertex + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + I2 pp[MaxDeep]; + + int l = 0; // level + QuadTreeBox *b; long hb = MaxISize; - I2 p0(0,0); + I2 p0(0, 0); - if (!root->n) - return 0; // empty tree + if (!root->n) return 0; // empty tree // general case ----- - pb[0]= root; - pi[0]= root->n>0 ?(int) root->n : 4 ; - pp[0]=p0; + pb[0] = root; + pi[0] = root->n > 0 ? (int)root->n : 4; + pp[0] = p0; do { - b= pb[l]; - while (pi[l]--) + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - Vertex & V(*b->v[k]); - I2 i2 = R2ToI2(V); - if ( I2(i2,p).less(H) ) - { - R2 XY(X,V); - R dd; - if( (dd= (XY,XY) ) < seuil2 ) - { - if( nearest ) // modif FH - { - seuil2=dd; - pvr = & V; - } - else - return &V; - } - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],k,hb); - if (ppp.interseg(p,hb,H)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + NbVerticesSearch++; + Vertex &V(*b->v[k]); + I2 i2 = R2ToI2(V); + if (I2(i2, p).less(H)) { + R2 XY(X, V); + R dd; + if ((dd = (XY, XY)) < seuil2) { + if (nearest) // modif FH + { + seuil2 = dd; + pvr = &V; + } else + return &V; + } + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + I2 ppp(pp[l], k, hb); + if (ppp.interseg(p, hb, H)) { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); return pvr; } - -void FQuadTree::Add( Vertex & w) -{ - QuadTreeBox ** pb , *b; - I2 p(XtoI(w.x),YtoJ(w.y)); - long l=MaxISize; +void FQuadTree::Add(Vertex &w) { + QuadTreeBox **pb, *b; + I2 p(XtoI(w.x), YtoJ(w.y)); + long l = MaxISize; pb = &root; - while( (b=*pb) && (b->n<0)) - { - b->n--; - l >>= 1; - pb = &b->b[p.Case(l)]; - } - if (b) { - if (b->n > 3 && b->v[3] == &w) return; - if (b->n > 2 && b->v[2] == &w) return; - if (b->n > 1 && b->v[1] == &w) return; - if (b->n > 0 && b->v[0] == &w) return; + while ((b = *pb) && (b->n < 0)) { + b->n--; + l >>= 1; + pb = &b->b[p.Case(l)]; + } + if (b) { + if (b->n > 3 && b->v[3] == &w) return; + if (b->n > 2 && b->v[2] == &w) return; + if (b->n > 1 && b->v[1] == &w) return; + if (b->n > 0 && b->v[0] == &w) return; } throwassert(l); - while ((b= *pb) && (b->n == 4)) // the QuadTreeBox is full + while ((b = *pb) && (b->n == 4)) // the QuadTreeBox is full + { + Vertex *v4[4]; // copy of the QuadTreeBox vertices + + v4[0] = b->v[0]; + v4[1] = b->v[1]; + v4[2] = b->v[2]; + v4[3] = b->v[3]; + b->n = -b->n; // mark is pointer QuadTreeBox + b->b[0] = b->b[1] = b->b[2] = b->b[3] = 0; // set empty QuadTreeBox ptr + l >>= 1; // div the size by 2 + for (int k = 0; k < 4; k++) // for the 4 vertices find the sub QuadTreeBox ij { - Vertex *v4[4]; // copy of the QuadTreeBox vertices - - v4[0]= b->v[0]; - v4[1]= b->v[1]; - v4[2]= b->v[2]; - v4[3]= b->v[3]; - b->n = -b->n; // mark is pointer QuadTreeBox - b->b[0]=b->b[1]=b->b[2]=b->b[3]=0; // set empty QuadTreeBox ptr - l >>= 1; // div the size by 2 - for (int k=0;k<4;k++) // for the 4 vertices find the sub QuadTreeBox ij - { - int ij; - QuadTreeBox * bb = b->b[ij=R2ToI2(v4[k]).Case(l)]; - if (!bb) - bb=b->b[ij]=NewQuadTreeBox(); // alloc the QuadTreeBox - bb->v[bb->n++] = v4[k]; - } - pb = &b->b[p.Case(l)]; + int ij; + QuadTreeBox *bb = b->b[ij = R2ToI2(v4[k]).Case(l)]; + if (!bb) bb = b->b[ij] = NewQuadTreeBox( ); // alloc the QuadTreeBox + bb->v[bb->n++] = v4[k]; } - if (!(b = *pb)) - b=*pb= NewQuadTreeBox(); // alloc the QuadTreeBox - b->v[b->n++]=&w; // we add the vertex + pb = &b->b[p.Case(l)]; + } + if (!(b = *pb)) b = *pb = NewQuadTreeBox( ); // alloc the QuadTreeBox + b->v[b->n++] = &w; // we add the vertex NbVertices++; } - -FQuadTree::FQuadTree(Vertex * v,R2 Pmin,R2 Pmax,long nbv) - : - th(0), - lenStorageQuadTreeBox(Max(abs(nbv),1000L)), - NbQuadTreeBox(0), - NbVertices(0), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - cMin(Pmin-(Pmax-Pmin)/2), - cMax(Pmax+(Pmax-Pmin)/2), - coef( MaxISize/Norme_infty(cMax-cMin)) +FQuadTree::FQuadTree(Vertex *v, R2 Pmin, R2 Pmax, long nbv) + : th(0), lenStorageQuadTreeBox(Max(abs(nbv), 1000L)), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), cMin(Pmin - (Pmax - Pmin) / 2), cMax(Pmax + (Pmax - Pmin) / 2), + coef(MaxISize / Norme_infty(cMax - cMin)) { - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); - for (long i=0;inv/8+100), - th(t), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - NbQuadTreeBox(0), - NbVertices(0), - cMin(Pmin-(Pmax-Pmin)/2), - cMax(Pmax+(Pmax-Pmin)/2), - coef( MaxISize/Norme_infty(cMax-cMin)) +FQuadTree::FQuadTree(const Mesh *t, R2 Pmin, R2 Pmax, long nbv) + : lenStorageQuadTreeBox(t->nv / 8 + 100), th(t), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), NbQuadTreeBox(0), NbVertices(0), cMin(Pmin - (Pmax - Pmin) / 2), cMax(Pmax + (Pmax - Pmin) / 2), + coef(MaxISize / Norme_infty(cMax - cMin)) { if (nbv == -1) nbv = t->nv; - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); if (t) - for (long i=0;ivertices[i]); + for (long i = 0; i < nbv; i++) Add(t->vertices[i]); #ifdef DRAWING1 - Draw(); + Draw( ); #endif } -FQuadTree::FQuadTree(const Mesh* t,long tnv,R2 Pmin,R2 Pmax,long nbv) : - lenStorageQuadTreeBox(tnv/8+100), - th(t), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - NbQuadTreeBox(0), - NbVertices(0), - cMin(Pmin-(Pmax-Pmin)/2), - cMax(Pmax+(Pmax-Pmin)/2), - coef( MaxISize/Norme_infty(cMax-cMin)) +FQuadTree::FQuadTree(const Mesh *t, long tnv, R2 Pmin, R2 Pmax, long nbv) + : lenStorageQuadTreeBox(tnv / 8 + 100), th(t), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), NbQuadTreeBox(0), NbVertices(0), cMin(Pmin - (Pmax - Pmin) / 2), cMax(Pmax + (Pmax - Pmin) / 2), + coef(MaxISize / Norme_infty(cMax - cMin)) { if (nbv == -1) nbv = tnv; - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); if (t) - for (long i=0;ivertices[i]); + for (long i = 0; i < nbv; i++) Add(t->vertices[i]); #ifdef DRAWING1 - Draw(); + Draw( ); #endif } - -FQuadTree::FQuadTree() : - lenStorageQuadTreeBox(100), - th(0), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - NbQuadTreeBox(0), - NbVertices(0), - cMin(0,0),cMax(0,0),coef(0) -{ - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); +FQuadTree::FQuadTree( ) : lenStorageQuadTreeBox(100), th(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), NbQuadTreeBox(0), NbVertices(0), cMin(0, 0), cMax(0, 0), coef(0) { + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); } -FQuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll,StorageQuadTreeBox *nn) -{ +FQuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll, StorageQuadTreeBox *nn) { len = ll; n = nn; b = new QuadTreeBox[ll]; - for (int i = 0; i n) - return vn; // empty tree - - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = plus.Case(hb2);//(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - QuadTreeBox * b0= b->b[k]; - if ( ( b0 == 0) || (b0->n == 0) ) - break; // null box or empty => break - NbQuadTreeBoxSearch++; - b=b0; - p0.Add(k,hb2); - hb = hb2; - } - + long n0; + if (!root->n) return vn; // empty tree + + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = plus.Case(hb2); //(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j + QuadTreeBox *b0 = b->b[k]; + if ((b0 == 0) || (b0->n == 0)) break; // null box or empty => break + NbQuadTreeBoxSearch++; + b = b0; + p0.Add(k, hb2); + hb = hb2; + } - if ( n0 > 0) - { - for(int k=0;kv[k]; - if (v->ninside(P)) { - I2 i2 = R2ToI2(v); - // try if is in the right sens -- - h0 = I2(i2,plus).norm();// h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 0) { + for (int k = 0; k < n0; k++) { + Vertex *v = b->v[k]; + if (v->ninside(P)) { + I2 i2 = R2ToI2(v); + // try if is in the right sens -- + h0 = I2(i2, plus).norm( ); // h0 = NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + NbVerticesSearch++; + } } + if (vn) return vn; + } // general case ----- // INITIALISATION OF THE STACK - l =0; // level - pb[0]= b; - pi[0]= b->n>0 ?(int) b->n : 4 ; - pp[0]=p0; - h=hb; - L1: - do { // walk on the tree - b= pb[l]; - while (pi[l]--) // loop on 4 element of the box + l = 0; // level + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + pp[0] = p0; + h = hb; +L1: + do { // walk on the tree + b = pb[l]; + while (pi[l]--) // loop on 4 element of the box + { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - Vertex * v=b->v[k]; - if (v->ninside(P) ) { - NbVerticesSearch++; - I2 i2 = R2ToI2(v); - // if good sens when try -- - h0 = I2(i2,plus).norm();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 b[k])) - { - hb >>=1 ; // div by 2 - I2 ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + Vertex *v = b->v[k]; + if (v->ninside(P)) { + NbVerticesSearch++; + I2 i2 = R2ToI2(v); + // if good sens when try -- + h0 = I2(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + I2 ppp(pp[l], k, hb); + + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) + { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); - if (!vn && b != root ) - {// cas particulier on repart du sommet on avais rien trouver - b=root; - hb = MaxISize; - p0=I2(0,0); - l=0; - pb[0]= b; - pi[0]= b->n>0 ?(int) b->n : 4 ; - pp[0]=I2(0,0); - - goto L1; - } + if (!vn && b != root) { // cas particulier on repart du sommet on avais rien trouver + b = root; + hb = MaxISize; + p0 = I2(0, 0); + l = 0; + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + pp[0] = I2(0, 0); + + goto L1; + } return vn; } #else - // nouvelle version a tester +#define INTER_SEG(a, b, x, y) (((y) > (a)) && ((x) < (b))) +#define ABS(i) ((i) < 0 ? -(i) : (i)) +#define MAX1(i, j) ((i) > (j) ? (i) : (j)) +#define NORM(i1, j1, i2, j2) MAX1(ABS((i1) - (j1)), ABS((i2) - (j2))) - -#define INTER_SEG(a,b,x,y) (((y) > (a)) && ((x) <(b))) -#define ABS(i) ((i)<0 ?-(i) :(i)) -#define MAX1(i,j) ((i)>(j) ?(i) :(j)) -#define NORM(i1,j1,i2,j2) MAX1(ABS((i1)-(j1)),ABS((i2)-(j2))) - -#define IJ(i,j,l) ( ( j & l) ? (( i & l) ? 3 : 2 ) :( ( i & l)? 1 : 0 )) -#define I_IJ(k,l) (( k&1) ? l : 0) -#define J_IJ(k,l) (( k&2) ? l : 0) - +#define IJ(i, j, l) ((j & l) ? ((i & l) ? 3 : 2) : ((i & l) ? 1 : 0)) +#define I_IJ(k, l) ((k & 1) ? l : 0) +#define J_IJ(k, l) ((k & 2) ? l : 0) #ifdef DRAWING // old version ---- -void FQuadTree::Draw() -{ - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - long ii[ MaxDeep ], jj [ MaxDeep]; - int l=0; // level - QuadTreeBox * b; - IntQuad hb = MaxISize; - if (!root) return ; - long kkk =0; - pb[0]= root; - pi[0]= root->n>0 ?(int) root->n : 4 ;; - ii[0]=jj[0]=0; - do{ - b= pb[l]; - - while (pi[l]--) +void FQuadTree::Draw( ) { + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + long ii[MaxDeep], jj[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + IntQuad hb = MaxISize; + if (!root) return; + long kkk = 0; + pb[0] = root; + pi[0] = root->n > 0 ? (int)root->n : 4; + ; + ii[0] = jj[0] = 0; + do { + b = pb[l]; + + while (pi[l]--) { + if (b->n > 0) // Vertex QuadTreeBox none empty + { // + for (int k = 0; k < b->n; k++) { + DrawMark(*b->v[k], 0.002); + } + break; + } else // Pointer QuadTreeBox { - if (b->n>0) // Vertex QuadTreeBox none empty - { // - for (int k=0;kn;k++) - { - DrawMark(*b->v[k],0.002); - - } - break; - } - else // Pointer QuadTreeBox - { - int lll = pi[l]; - QuadTreeBox *b0=b; - - if ((b=b->b[lll])) - { - hb >>=1 ; // div by 2 - long iii = ii[l]+I_IJ(lll,hb); - long jjj = jj[l]+J_IJ(lll,hb); - - pb[++l]= b; - pi[l]= 4; - ii[l]= iii; - jj[l]= jjj; - - IMoveTo(ii[l],jj[l]); - ILineTo(ii[l]+hb,jj[l]); - ILineTo(ii[l]+hb,jj[l]+hb); - ILineTo(ii[l] ,jj[l]+hb); - ILineTo(ii[l] ,jj[l]); - - - } - else - { - long iii = ii[l]+I_IJ(lll,hb/2); - long jjj = jj[l]+J_IJ(lll,hb/2); - b=b0; - - IMoveTo(iii, jjj); - ILineTo(iii+hb/2,jjj+hb/2); - IMoveTo(iii+hb/2,jjj); - ILineTo(iii ,jjj+hb/2); - - } - } + int lll = pi[l]; + QuadTreeBox *b0 = b; + + if ((b = b->b[lll])) { + hb >>= 1; // div by 2 + long iii = ii[l] + I_IJ(lll, hb); + long jjj = jj[l] + J_IJ(lll, hb); + + pb[++l] = b; + pi[l] = 4; + ii[l] = iii; + jj[l] = jjj; + + IMoveTo(ii[l], jj[l]); + ILineTo(ii[l] + hb, jj[l]); + ILineTo(ii[l] + hb, jj[l] + hb); + ILineTo(ii[l], jj[l] + hb); + ILineTo(ii[l], jj[l]); + + } else { + long iii = ii[l] + I_IJ(lll, hb / 2); + long jjj = jj[l] + J_IJ(lll, hb / 2); + b = b0; + + IMoveTo(iii, jjj); + ILineTo(iii + hb / 2, jjj + hb / 2); + IMoveTo(iii + hb / 2, jjj); + ILineTo(iii, jjj + hb / 2); + } } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); - } #endif -Vertex * FQuadTree::NearestVertex(long xi,long yj) -{ - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - long ii[ MaxDeep ], jj [ MaxDeep]; - int l=0; // level - QuadTreeBox * b; - IntQuad h=MaxISize,h0; - IntQuad hb = MaxISize; - long i0=0,j0=0; - long iplus( xin) - return vn; // empty tree - - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = IJ(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - QuadTreeBox * b0= b->b[k]; - if ( ( b0 == 0) || (b0->n == 0) ) - break; // null box or empty => break - NbQuadTreeBoxSearch++; - b=b0; - i0 += I_IJ(k,hb2); // i orign of QuadTreeBox - j0 += J_IJ(k,hb2); // j orign of QuadTreeBox - hb = hb2; - } - + long n0; + if (!root->n) return vn; // empty tree + + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = IJ(iplus, jplus, hb2); // QuadTreeBox number of size hb2 contening i;j + QuadTreeBox *b0 = b->b[k]; + if ((b0 == 0) || (b0->n == 0)) break; // null box or empty => break + NbQuadTreeBoxSearch++; + b = b0; + i0 += I_IJ(k, hb2); // i orign of QuadTreeBox + j0 += J_IJ(k, hb2); // j orign of QuadTreeBox + hb = hb2; + } - if ( n0 > 0) - { - for( int k=0;kv[k]); - h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k];} - NbVerticesSearch++; - } - return vn; + if (n0 > 0) { + for (int k = 0; k < n0; k++) { + I2 i2 = R2ToI2(b->v[k]); + h0 = NORM(iplus, i2.x, jplus, i2.y); + if (h0 < h) { + h = h0; + vn = b->v[k]; + } + NbVerticesSearch++; } + return vn; + } // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : 4 ; - ii[0]=i0; - jj[0]=j0; - h=hb; + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + ii[0] = i0; + jj[0] = j0; + h = hb; do { - b= pb[l]; - while (pi[l]--) + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + I2 i2 = R2ToI2(b->v[k]); + h0 = NORM(iplus, i2.x, jplus, i2.y); + if (h0 < h) { + h = h0; + vn = b->v[k]; + } + } else // Pointer QuadTreeBox { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - I2 i2 = R2ToI2(b->v[k]); - h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k]; - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - long iii = ii[l]+I_IJ(k,hb); - long jjj = jj[l]+J_IJ(k,hb); - - if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - ii[l]= iii; - jj[l]= jjj; - - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + long iii = ii[l] + I_IJ(k, hb); + long jjj = jj[l] + J_IJ(k, hb); + + if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + ii[l] = iii; + jj[l] = jjj; + + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); return vn; } - - -Vertex * FQuadTree::ToClose(const R2 & v,R seuil,long hx,long hy) -{ - const long i=XtoI(v.x); - const long j=YtoJ(v.y); +Vertex *FQuadTree::ToClose(const R2 &v, R seuil, long hx, long hy) { + const long i = XtoI(v.x); + const long j = YtoJ(v.y); const R2 X(v); - R seuil2 = seuil*seuil; - - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - long ii[ MaxDeep ], jj [ MaxDeep]; - int l=0; // level - QuadTreeBox * b; - long h=MaxISize; - long hb = MaxISize; - long i0=0,j0=0; + R seuil2 = seuil * seuil; + + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + long ii[MaxDeep], jj[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + long h = MaxISize; + long hb = MaxISize; + long i0 = 0, j0 = 0; - if (!root->n) - return 0; // empty tree + if (!root->n) return 0; // empty tree // general case ----- - pb[0]= root; - pi[0]= root->n>0 ?(int) root->n : 4 ; - ii[0]=i0; - jj[0]=j0; - h=hb; + pb[0] = root; + pi[0] = root->n > 0 ? (int)root->n : 4; + ii[0] = i0; + jj[0] = j0; + h = hb; do { - b= pb[l]; - while (pi[l]--) + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + Vertex &V(*b->v[k]); + I2 i2 = R2ToI2(V); + if (ABS(i - i2.x) < hx && ABS(j - i2.y) < hy) { + R2 XY(X, V); + R dd; + if ((dd = (XY, XY)) < seuil) { + return &V; + } + } + } else // Pointer QuadTreeBox { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - Vertex & V(*b->v[k]); - I2 i2 = R2ToI2(V); - if ( ABS(i-i2.x) b[k])) - { - hb >>=1 ; // div by 2 - long iii = ii[l]+I_IJ(k,hb); - long jjj = jj[l]+J_IJ(k,hb); - - if (INTER_SEG(iii,iii+hb,i-hx,i+hx) && INTER_SEG(jjj,jjj+hb,j-hy,j+hy)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - ii[l]= iii; - jj[l]= jjj; - - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + long iii = ii[l] + I_IJ(k, hb); + long jjj = jj[l] + J_IJ(k, hb); + + if (INTER_SEG(iii, iii + hb, i - hx, i + hx) && INTER_SEG(jjj, jjj + hb, j - hy, j + hy)) { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + ii[l] = iii; + jj[l] = jjj; + + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); return 0; } - -void FQuadTree::Add( Vertex & w) -{ - QuadTreeBox ** pb , *b; - long i= XtoI(w.x), j=YtoJ(w.y),l=MaxISize; +void FQuadTree::Add(Vertex &w) { + QuadTreeBox **pb, *b; + long i = XtoI(w.x), j = YtoJ(w.y), l = MaxISize; pb = &root; - while( (b=*pb) && (b->n<0)) - { - b->n--; - l >>= 1; - pb = &b->b[IJ(i,j,l)]; - } - if (b) { - if (b->n > 3 && b->v[3] == &w) return; - if (b->n > 2 && b->v[2] == &w) return; - if (b->n > 1 && b->v[1] == &w) return; - if (b->n > 0 && b->v[0] == &w) return; + while ((b = *pb) && (b->n < 0)) { + b->n--; + l >>= 1; + pb = &b->b[IJ(i, j, l)]; + } + if (b) { + if (b->n > 3 && b->v[3] == &w) return; + if (b->n > 2 && b->v[2] == &w) return; + if (b->n > 1 && b->v[1] == &w) return; + if (b->n > 0 && b->v[0] == &w) return; } throwassert(l); - while ((b= *pb) && (b->n == 4)) // the QuadTreeBox is full + while ((b = *pb) && (b->n == 4)) // the QuadTreeBox is full + { + Vertex *v4[4]; // copy of the QuadTreeBox vertices + + v4[0] = b->v[0]; + v4[1] = b->v[1]; + v4[2] = b->v[2]; + v4[3] = b->v[3]; + b->n = -b->n; // mark is pointer QuadTreeBox + b->b[0] = b->b[1] = b->b[2] = b->b[3] = 0; // set empty QuadTreeBox ptr + l >>= 1; // div the size by 2 + for (int k = 0; k < 4; k++) // for the 4 vertices find the sub QuadTreeBox ij { - Vertex *v4[4]; // copy of the QuadTreeBox vertices - - v4[0]= b->v[0]; - v4[1]= b->v[1]; - v4[2]= b->v[2]; - v4[3]= b->v[3]; - b->n = -b->n; // mark is pointer QuadTreeBox - b->b[0]=b->b[1]=b->b[2]=b->b[3]=0; // set empty QuadTreeBox ptr - l >>= 1; // div the size by 2 - for (int k=0;k<4;k++) // for the 4 vertices find the sub QuadTreeBox ij - { - int ij; - QuadTreeBox * bb = b->b[ij=IJ(XtoI(v4[k]->x),YtoJ(v4[k]->y),l)]; - if (!bb) - bb=b->b[ij]=NewQuadTreeBox(); // alloc the QuadTreeBox - bb->v[bb->n++] = v4[k]; - } - pb = &b->b[IJ(i,j,l)]; + int ij; + QuadTreeBox *bb = b->b[ij = IJ(XtoI(v4[k]->x), YtoJ(v4[k]->y), l)]; + if (!bb) bb = b->b[ij] = NewQuadTreeBox( ); // alloc the QuadTreeBox + bb->v[bb->n++] = v4[k]; } - if (!(b = *pb)) - b=*pb= NewQuadTreeBox(); // alloc the QuadTreeBox - b->v[b->n++]=&w; // we add the vertex + pb = &b->b[IJ(i, j, l)]; + } + if (!(b = *pb)) b = *pb = NewQuadTreeBox( ); // alloc the QuadTreeBox + b->v[b->n++] = &w; // we add the vertex NbVertices++; } -FQuadTree::FQuadTree(Mesh * t,R2 Pmin,R2 Pmax,long nbv) : - th(t), - lenStorageQuadTreeBox(t->nv/8+100), - NbQuadTreeBox(0), - NbVertices(0), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - cMin(Pmin-(Pmax-Pmin)/2), - cMax(Pmax+(Pmax-Pmin)/2), - coef( MaxISize/Norme_infty(cMax-cMin)) +FQuadTree::FQuadTree(Mesh *t, R2 Pmin, R2 Pmax, long nbv) + : th(t), lenStorageQuadTreeBox(t->nv / 8 + 100), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), cMin(Pmin - (Pmax - Pmin) / 2), cMax(Pmax + (Pmax - Pmin) / 2), + coef(MaxISize / Norme_infty(cMax - cMin)) { if (nbv == -1) nbv = t->nv; - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); if (t) - for (long i=0;ivertices[i]); + for (long i = 0; i < nbv; i++) Add(t->vertices[i]); #ifdef DRAWING1 - Draw(); + Draw( ); #endif } -FQuadTree::FQuadTree() : - th(0), - lenStorageQuadTreeBox(100), - NbQuadTreeBox(0), - NbVertices(0), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - coef(0),cMin(0,0),cMax(0,0) -{ - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); +FQuadTree::FQuadTree( ) : th(0), lenStorageQuadTreeBox(100), NbQuadTreeBox(0), NbVertices(0), NbQuadTreeBoxSearch(0), NbVerticesSearch(0), coef(0), cMin(0, 0), cMax(0, 0) { + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); } -FQuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll,StorageQuadTreeBox *nn) -{ +FQuadTree::StorageQuadTreeBox::StorageQuadTreeBox(long ll, StorageQuadTreeBox *nn) { len = ll; n = nn; b = new QuadTreeBox[ll]; - for (int i = 0; i n) - return vn; // empty tree - - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = IJ(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - QuadTreeBox * b0= b->b[k]; - if ( ( b0 == 0) || (b0->n == 0) ) - break; // null box or empty => break - NbQuadTreeBoxSearch++; - b=b0; - i0 += I_IJ(k,hb2); // i orign of QuadTreeBox - j0 += J_IJ(k,hb2); // j orign of QuadTreeBox - hb = hb2; - } - + long n0; + if (!root->n) return vn; // empty tree + + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = IJ(iplus, jplus, hb2); // QuadTreeBox number of size hb2 contening i;j + QuadTreeBox *b0 = b->b[k]; + if ((b0 == 0) || (b0->n == 0)) break; // null box or empty => break + NbQuadTreeBoxSearch++; + b = b0; + i0 += I_IJ(k, hb2); // i orign of QuadTreeBox + j0 += J_IJ(k, hb2); // j orign of QuadTreeBox + hb = hb2; + } - if ( n0 > 0) - { - for(int k=0;kv[k]; - if (v->ninside(P)) { - I2 i2 = R2ToI2(v); - // try if is in the right sens -- - h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 0) { + for (int k = 0; k < n0; k++) { + Vertex *v = b->v[k]; + if (v->ninside(P)) { + I2 i2 = R2ToI2(v); + // try if is in the right sens -- + h0 = NORM(iplus, i2.x, jplus, i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + NbVerticesSearch++; + } } + if (vn) return vn; + } // general case ----- // INITIALISATION OF THE STACK - l =0; // level - pb[0]= b; - pi[0]= b->n>0 ?(int) b->n : 4 ; - ii[0]=i0; - jj[0]=j0; - h=hb; - L1: - do { // walk on the tree - b= pb[l]; - while (pi[l]--) // loop on 4 element of the box + l = 0; // level + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + ii[0] = i0; + jj[0] = j0; + h = hb; +L1: + do { // walk on the tree + b = pb[l]; + while (pi[l]--) // loop on 4 element of the box + { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - Vertex * v=b->v[k]; - if (v->ninside(P) ) { - NbVerticesSearch++; - I2 i2 = R2ToI2(v); - // if good sens when try -- - h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 b[k])) - { - hb >>=1 ; // div by 2 - long iii = ii[l]+I_IJ(k,hb); - long jjj = jj[l]+J_IJ(k,hb); - - if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : 4 ; - ii[l]= iii; - jj[l]= jjj; - - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + Vertex *v = b->v[k]; + if (v->ninside(P)) { + NbVerticesSearch++; + I2 i2 = R2ToI2(v); + // if good sens when try -- + h0 = NORM(iplus, i2.x, jplus, i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + long iii = ii[l] + I_IJ(k, hb); + long jjj = jj[l] + J_IJ(k, hb); + + if (INTER_SEG(iii, iii + hb, iplus - h, iplus + h) && INTER_SEG(jjj, jjj + hb, jplus - h, jplus + h)) { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : 4; + ii[l] = iii; + jj[l] = jjj; + + } else + b = b0, hb <<= 1; + } else + b = b0; } - hb <<= 1; // mul by 2 + } + hb <<= 1; // mul by 2 } while (l--); - if (!vn && b != root ) - {// cas particulier on repart du sommet on avais rien trouver - b=root; - hb = MaxISize; - i0=0; - j0=0; - l=0; - pb[0]= b; - pi[0]= b->n>0 ?(int) b->n : 4 ; - ii[0]=i0; - jj[0]=j0; - - goto L1; - } + if (!vn && b != root) { // cas particulier on repart du sommet on avais rien trouver + b = root; + hb = MaxISize; + i0 = 0; + j0 = 0; + l = 0; + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : 4; + ii[0] = i0; + jj[0] = j0; + + goto L1; + } return vn; } diff --git a/src/femlib/FQuadTree.hpp b/src/femlib/FQuadTree.hpp index 262926610..d0d5311af 100644 --- a/src/femlib/FQuadTree.hpp +++ b/src/femlib/FQuadTree.hpp @@ -1,172 +1,158 @@ // ********** DO NOT REMOVE THIS BANNER ********** /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -// AUTHOR: F. Hecht, +// AUTHOR: F. Hecht, // ORG : UMPC -// E-MAIL : Frederic.Hecht@Inria.fr +// E-MAIL : Frederic.Hecht@Inria.fr // // ORIG-DATE: Dec 97 namespace Fem2D { -const int MaxDeep = 30; -typedef long IntQuad; -const IntQuad MaxISize = ( 1L << MaxDeep); - -#define VERSION_Fem2D_FQuadTree 2 -/* - in version 2 - add bool nearest=false Mai 20128 FH. for inytersect mesh - Vertex * ToClose(const R2 & ,R ,long,long,bool nearest=false); - */ -class Mesh; -//typename Vertex; - -class FQuadTree { - public: - class I2 { public: - static bool INTER_SEG1d(long a,long b,long x,long y) { return (((y) > (a)) && ((x) <(b)));} - long x,y; - I2() {} - I2(long i,long j): x(i),y(j) {} - I2(const I2 &pp,long k,long l): x(pp.x+(( k&1) ? l : 0)),y(pp.y+(( k&2) ? l : 0)) {} - void Add(long k,long l) { x+= (( k&1) ? l : 0) ; y+= (( k&2) ? l : 0);} - I2(const I2 &A,const I2 &B) : x(B.x-A.x),y(B.y-A.y) {} - - long Case(long l) const { return ( ( y & l) ? (( x & l) ? 3 : 2 ) :( ( x & l)? 1 : 0 ));} - long norm() const { return Max(abs(x),abs(y));} - bool less(I2 h) const { return abs(x) Vertex else => QuadTreeBox; - union { - QuadTreeBox *b[4]; - Vertex * v[4]; +#define VERSION_Fem2D_FQuadTree 2 + /* + in version 2 + add bool nearest=false Mai 20128 FH. for inytersect mesh + Vertex * ToClose(const R2 & ,R ,long,long,bool nearest=false); + */ + class Mesh; + // typename Vertex; + + class FQuadTree { + public: + class I2 { + public: + static bool INTER_SEG1d(long a, long b, long x, long y) { return (((y) > (a)) && ((x) < (b))); } + long x, y; + I2( ) {} + I2(long i, long j) : x(i), y(j) {} + I2(const I2 &pp, long k, long l) : x(pp.x + ((k & 1) ? l : 0)), y(pp.y + ((k & 2) ? l : 0)) {} + void Add(long k, long l) { + x += ((k & 1) ? l : 0); + y += ((k & 2) ? l : 0); + } + I2(const I2 &A, const I2 &B) : x(B.x - A.x), y(B.y - A.y) {} + + long Case(long l) const { return ((y & l) ? ((x & l) ? 3 : 2) : ((x & l) ? 1 : 0)); } + long norm( ) const { return Max(abs(x), abs(y)); } + bool less(I2 h) const { return abs(x) < h.x && abs(y) < h.y; } + bool interseg(I2 pp, long hb, long h) const { return INTER_SEG1d(x, x + hb, pp.x - h, pp.x + h) && INTER_SEG1d(y, y + hb, pp.y - h, pp.y + h); } + bool interseg(const I2 &pp, long hb, const I2 &h) const { return INTER_SEG1d(x, x + hb, pp.x - h.x, pp.x + h.x) && INTER_SEG1d(y, y + hb, pp.y - h.y, pp.y + h.y); } }; - - - }; // end class QuadTreeBox ///////////////// - - class StorageQuadTreeBox { - public: - QuadTreeBox *b,*bc,*be; - long len; - StorageQuadTreeBox *n; // next StorageQuadTreeBox - StorageQuadTreeBox(long ,StorageQuadTreeBox * =0); - ~StorageQuadTreeBox(); - long SizeOf() const { - return len*sizeof(QuadTreeBox)+sizeof(StorageQuadTreeBox)+ (n?n->SizeOf():0); + + class QuadTreeBox { + public: + long n; // if n < 4 => Vertex else => QuadTreeBox; + union { + QuadTreeBox *b[4]; + Vertex *v[4]; + }; + + }; // end class QuadTreeBox ///////////////// + + class StorageQuadTreeBox { + public: + QuadTreeBox *b, *bc, *be; + long len; + StorageQuadTreeBox *n; // next StorageQuadTreeBox + StorageQuadTreeBox(long, StorageQuadTreeBox * = 0); + ~StorageQuadTreeBox( ); + long SizeOf( ) const { return len * sizeof(QuadTreeBox) + sizeof(StorageQuadTreeBox) + (n ? n->SizeOf( ) : 0); } + }; // end class StorageQuadTreeBox + + StorageQuadTreeBox *sb; + + long lenStorageQuadTreeBox; + + public: + QuadTreeBox *root; + const Mesh *th; + + long NbQuadTreeBoxSearch, NbVerticesSearch; + long NbQuadTreeBox, NbVertices; + + R2 cMin, cMax; // box of QuadTree + R coef; // + + long XtoI(R x) { return (long)((Max(Min(x, cMax.x), cMin.x) - cMin.x) * coef); } + long YtoJ(R y) { return (long)((Max(Min(y, cMax.y), cMin.y) - cMin.y) * coef); } + R ItoX(long i) { return double(i) * coef + cMin.x; } + R ItoY(long j) { return double(j) * coef + cMin.y; } + I2 R2ToI2(const R2 &P) { return I2(XtoI(P.x), YtoJ(P.y)); } + I2 R2ToI2(const R2 *P) { return I2(XtoI(P->x), YtoJ(P->y)); } + + Vertex *NearestVertex(const R2 &P) { return NearestVertex(XtoI(P.x), YtoJ(P.y)); } + Vertex *TrueNearestVertex(const R2 &P) { return TrueNearestVertex(XtoI(P.x), YtoJ(P.y)); } + + Vertex *NearestVertexWithNormal(const R2 &P); + // { return NearestVertexWithNormal(XtoI(P.x),YtoJ(P.y));} + + Vertex *NearestVertex(long i, long j); + Vertex *TrueNearestVertex(long i, long j); + + int ListNearestVertex(Vertex **lnv, int nvn, long dh, long xi, long yj); // Add FH jan 2020 + int ListNearestVertex(Vertex **lnv, int nvn, double delta, R2 P) { + I2 IP = R2ToI2(P); + long hx = (long)(coef * delta); + hx = hx > 0 ? hx : 1; // bof bof .... + return ListNearestVertex(lnv, nvn, hx, IP.x, IP.y); } - }; // end class StorageQuadTreeBox - - StorageQuadTreeBox * sb; - - - long lenStorageQuadTreeBox; - -public: - QuadTreeBox * root; - const Mesh *th; - - long NbQuadTreeBoxSearch,NbVerticesSearch; - long NbQuadTreeBox,NbVertices; - - R2 cMin,cMax; // box of QuadTree - R coef; // - - - long XtoI(R x) { return (long) ((Max(Min(x,cMax.x),cMin.x)-cMin.x)*coef);} - long YtoJ(R y) { return (long) ((Max(Min(y,cMax.y),cMin.y)-cMin.y)*coef);} - R ItoX(long i){ return double(i)*coef+cMin.x ;} - R ItoY(long j){ return double(j)*coef+cMin.y ;} - I2 R2ToI2(const R2 &P) { return I2(XtoI(P.x),YtoJ(P.y));} - I2 R2ToI2(const R2 *P) { return I2(XtoI(P->x),YtoJ(P->y));} - - - Vertex * NearestVertex(const R2 & P) { return NearestVertex(XtoI(P.x),YtoJ(P.y));} - Vertex * TrueNearestVertex(const R2 & P) { return TrueNearestVertex(XtoI(P.x),YtoJ(P.y));} - - Vertex * NearestVertexWithNormal(const R2 & P); - // { return NearestVertexWithNormal(XtoI(P.x),YtoJ(P.y));} - - Vertex * NearestVertex(long i,long j); - Vertex * TrueNearestVertex(long i,long j); - - int ListNearestVertex(Vertex **lnv,int nvn,long dh,long xi,long yj); // Add FH jan 2020 - int ListNearestVertex(Vertex **lnv,int nvn,double delta,R2 P) - { - I2 IP=R2ToI2(P); - long hx = (long) (coef*delta); - hx = hx>0 ? hx:1; // bof bof .... - return ListNearestVertex(lnv,nvn,hx,IP.x,IP.y); + // Vertex * NearestVertexWithNormal(long i,long j); // new version + Vertex *ToClose(const R2 &, R, long, long, bool nearest = false); + Vertex *ToClose(const R2 &P, R delta, bool nearest = false) { + long hx = (long)(coef * delta); + hx = hx > 0 ? hx : 1; // bof bof .... + return ToClose(P, delta, hx, hx, nearest); } -// Vertex * NearestVertexWithNormal(long i,long j); // new version - Vertex * ToClose(const R2 & ,R ,long,long,bool nearest=false); - Vertex * ToClose(const R2 & P,R delta,bool nearest=false){ - long hx = (long) (coef*delta); - hx = hx>0 ? hx:1; // bof bof .... - return ToClose(P,delta,hx,hx,nearest);} - long SizeOf() const {return sizeof(FQuadTree)+sb->SizeOf();} + long SizeOf( ) const { return sizeof(FQuadTree) + sb->SizeOf( ); } #ifdef DRAWING - void IMoveTo(long i,long j) -{ rmoveto(float(i)/coef+cMin.x ,float(j)/coef+cMin.y );} + void IMoveTo(long i, long j) { rmoveto(float(i) / coef + cMin.x, float(j) / coef + cMin.y); } -void ILineTo(long i,long j) - {rlineto(float(i)/coef+cMin.x ,float(j)/coef+cMin.y );} - void Draw(); - void PlotQuad(I2 pp,long hb); - void PlotX(I2 pp,long hb); + void ILineTo(long i, long j) { rlineto(float(i) / coef + cMin.x, float(j) / coef + cMin.y); } + void Draw( ); + void PlotQuad(I2 pp, long hb); + void PlotX(I2 pp, long hb); #endif - void Add( Vertex & w); - - QuadTreeBox* NewQuadTreeBox() - { - ///cout << "NewQuadTreeBox " << sb << " " << sb->bc << " " - //<< sb->be << " " <bcbe)) - sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb); - - throwassert(sb && (sb->bc->n == 0)); - NbQuadTreeBox++; - return sb->bc++; - } - ~FQuadTree(); - FQuadTree(const Mesh* t,long tnv,R2 Pmin,R2 Pmax,long nbv=-1); - FQuadTree(const Mesh * t,R2 Pmin,R2 Pmax,long nbv=-1); - FQuadTree(Vertex * v,R2 Pmin,R2 Pmax,long nbv); - FQuadTree(); - friend ostream& operator <<(ostream& f, const FQuadTree & qt); + void Add(Vertex &w); + QuadTreeBox *NewQuadTreeBox( ) { + /// cout << "NewQuadTreeBox " << sb << " " << sb->bc << " " + //<< sb->be << " " <bc < sb->be)) sb = new StorageQuadTreeBox(lenStorageQuadTreeBox, sb); - -}; -//#undef IJ - - -} // name space + throwassert(sb && (sb->bc->n == 0)); + NbQuadTreeBox++; + return sb->bc++; + } + ~FQuadTree( ); + FQuadTree(const Mesh *t, long tnv, R2 Pmin, R2 Pmax, long nbv = -1); + FQuadTree(const Mesh *t, R2 Pmin, R2 Pmax, long nbv = -1); + FQuadTree(Vertex *v, R2 Pmin, R2 Pmax, long nbv); + FQuadTree( ); + friend ostream &operator<<(ostream &f, const FQuadTree &qt); + }; + // #undef IJ +} // namespace Fem2D diff --git a/src/femlib/GQuadTree.cpp b/src/femlib/GQuadTree.cpp index 006d8cb33..c02634b21 100644 --- a/src/femlib/GQuadTree.cpp +++ b/src/femlib/GQuadTree.cpp @@ -1,1626 +1,1408 @@ // ORIG-DATE: Jan 2008 // -*- Mode : c++ -*- // -// SUMMARY : Generic Tree (binairy, Quad, Oct) -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE +// SUMMARY : Generic Tree (binairy, Quad, Oct) +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Thank to the ARN () FF2A3 grant - ref:ANR-07-CIS7-002-01 + ref:ANR-07-CIS7-002-01 */ - #include #include #include "error.hpp" #include #include -#include +#include #include #include "ufunction.hpp" #include "HeapSort.hpp" using namespace std; - #include "GenericMesh.hpp" #include "Mesh1dn.hpp" #include "Mesh2dn.hpp" #include "Mesh3dn.hpp" -#include - -extern long npichon2d, npichon3d; -extern long npichon2d1, npichon3d1; - +#include +extern long npichon2d, npichon3d; +extern long npichon2d1, npichon3d1; namespace EF23 { - + // new version ---------- // ---------------------- - template - void OrthoProject(const Rd &P,const Rd &A,const Rd & B,R * l) - { - Rd AB(A,B),AP(A,P),BP(B,P); - R pa=(AB,AP),pb=(AB,BP); + template< class Rd > + void OrthoProject(const Rd &P, const Rd &A, const Rd &B, R *l) { + Rd AB(A, B), AP(A, P), BP(B, P); + R pa = (AB, AP), pb = (AB, BP); // (l0 PA + l1 PB , AB)=0 // l0 pa + l1 pb = 0 // l0 + l1 =1 // l0 (pa - pb) = - pb; - l[0] = - pb/(pa-pb); - l[1] = 1-l[0]; + l[0] = -pb / (pa - pb); + l[1] = 1 - l[0]; } - - template - void OrthoProject(const Rd &P,const Rd &A,const Rd &B,const Rd &C,R * l) - { - Rd AB(A,B),AC(A,C),AP(A,P),BP(B,P),CP(C,P); - R2 p0( (AB,AP) , (AC,AP) ); - R2 p1( (AB,BP) , (AC,BP) ); - R2 p2( (AB,CP) , (AC,CP) ); - // sum li pi = 0 - // l0 + l1 + l2 = 1 - // => - R2 O; - R d = det(p0,p1,p2); - l[0] = det(O ,p1,p2)/ d; - l[1] = det(p0,O ,p2)/ d; - l[2] = 1. -l[0] -l[1]; - // - // + + template< class Rd > + void OrthoProject(const Rd &P, const Rd &A, const Rd &B, const Rd &C, R *l) { + Rd AB(A, B), AC(A, C), AP(A, P), BP(B, P), CP(C, P); + R2 p0((AB, AP), (AC, AP)); + R2 p1((AB, BP), (AC, BP)); + R2 p2((AB, CP), (AC, CP)); + // sum li pi = 0 + // l0 + l1 + l2 = 1 + // => + R2 O; + R d = det(p0, p1, p2); + l[0] = det(O, p1, p2) / d; + l[1] = det(p0, O, p2) / d; + l[2] = 1. - l[0] - l[1]; + // + // } - -template - int GTree::ListNearestVertex(Vertex **lnv,int nlvnx,int dh,Zd xyi) - { - NbSearch++; - // warning this function return the NearestVertex in the first - // none empty box contening the point xyi. - // They do not return the true nearest point in classical norm. - int nlnv =0; - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - Zd pp[ MaxDeep ]; - int l=0; // level - QuadTreeBox * b; - Int8 h2=(Int8)dh*dh,h0; - IntQuad h=dh,hb = MaxISize; - Zd p0(0,0,0); - Zd plus(xyi) ; plus.Bound(); - - // xin) - return 0; // empty tree - - if(verbosity>4999) - cout << " general case : ListNearestVertex" << endl; - // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : N ; - pp[0]=p0; - - do { - b= pb[l]; - while (pi[l]--) + + template< class Vertex > + int GTree< Vertex >::ListNearestVertex(Vertex **lnv, int nlvnx, int dh, Zd xyi) { + NbSearch++; + // warning this function return the NearestVertex in the first + // none empty box contening the point xyi. + // They do not return the true nearest point in classical norm. + int nlnv = 0; + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + Zd pp[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + Int8 h2 = (Int8)dh * dh, h0; + IntQuad h = dh, hb = MaxISize; + Zd p0(0, 0, 0); + Zd plus(xyi); + plus.Bound( ); + + // xin) return 0; // empty tree + + if (verbosity > 4999) cout << " general case : ListNearestVertex" << endl; + // general case ----- + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : N; + pp[0] = p0; + + do { + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + Zd i2 = VtoZd(b->v[k]); + h0 = Zd(i2, plus).norm2( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h2) { // on stock .. + if (nlnv < nlvnx) lnv[nlnv++] = b->v[k]; + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + Zd ppp(pp[l], k, hb); + + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - Zd i2 = VtoZd(b->v[k]); - h0 = Zd(i2,plus).norm2();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 v[k]; - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - Zd ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - NbQuadTreeBoxSearch++;// add box search - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : N ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } - } - hb <<= 1; // mul by 2 - } while (l--); - - return nlnv; - } - + NbQuadTreeBoxSearch++; // add box search + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : N; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; + } + } + hb <<= 1; // mul by 2 + } while (l--); + + return nlnv; + } - template - Vertex * GTree::NearestVertex(Zd xyi,bool trueNearest)//long xi,long yj) + template< class Vertex > + Vertex *GTree< Vertex >::NearestVertex(Zd xyi, bool trueNearest) // long xi,long yj) { - typedef typename Vertex::Rd Rd; + typedef typename Vertex::Rd Rd; // warning this function return the NearestVertex in the first // none empty box contening the point xyi. // They do not return the true nearest point in classical norm. NbSearch++; - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - Zd pp[ MaxDeep ]; - int l=0; // level - QuadTreeBox * b; - Int8 h2=(Int8) MaxISize*(Int8)MaxISize*3,h0; - IntQuad h=MaxISize,hb = MaxISize; - Zd p0(0,0,0); - Zd plus(xyi) ; plus.Bound(); - int c2infty = 1+trueNearest;// 2 if trueNearest + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + Zd pp[MaxDeep]; + int l = 0; // level + QuadTreeBox *b; + Int8 h2 = (Int8)MaxISize * (Int8)MaxISize * 3, h0; + IntQuad h = MaxISize, hb = MaxISize; + Zd p0(0, 0, 0); + Zd plus(xyi); + plus.Bound( ); + int c2infty = 1 + trueNearest; // 2 if trueNearest // xin) - return vn; // empty tree - if( ! trueNearest ) - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = plus.Case(hb2);//(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - - QuadTreeBox * b0= b->b[k]; - - if ( ( b0 == 0) || (b0->n == 0) ){ - break; // null box or empty box => break - } - NbQuadTreeBoxSearch++; - b=b0; - p0.Add(k,hb2); - hb = hb2; - + long n0 = 0; + if (!root->n) return vn; // empty tree + if (!trueNearest) + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = plus.Case(hb2); //(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j + + QuadTreeBox *b0 = b->b[k]; + + if ((b0 == 0) || (b0->n == 0)) { + break; // null box or empty box => break + } + NbQuadTreeBoxSearch++; + b = b0; + p0.Add(k, hb2); + hb = hb2; } - // n0 number of boxes of in b ("b0") - if(verbosity>2000) - cout << " NV: n0=" << n0 << " " << trueNearest < 0) - { - for( int k=0;kv[k]); - h0 = Zd(i2,plus).norm2(); //warning .. norm sup and not norm 2 ... - if (h0 v[k]; - ffassert(vn); - } - NbVerticesSearch++; - } - if(verbosity>2000) - cout << " find " << vn << " " << h0 << " " << h2 << " " << endl; + // n0 number of boxes of in b ("b0") + if (verbosity > 2000) cout << " NV: n0=" << n0 << " " << trueNearest << endl; + + if (n0 > 0) { + for (int k = 0; k < n0; k++) { + Zd i2 = VtoZd(b->v[k]); + h0 = Zd(i2, plus).norm2( ); // warning .. norm sup and not norm 2 ... + if (h0 < h2) { + h2 = h0; + vn = b->v[k]; + ffassert(vn); + } + NbVerticesSearch++; + } + if (verbosity > 2000) cout << " find " << vn << " " << h0 << " " << h2 << " " << endl; return vn; } - -if(verbosity>2000) - cout << " general case : NearVertex" << endl; + + if (verbosity > 2000) cout << " general case : NearVertex" << endl; // general case ----- - pb[0]= b; - pi[0]=b->n>0 ?(int) b->n : N ; - pp[0]=p0; - h=hb; - do { - b= pb[l]; - while (pi[l]--) - { + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : N; + pp[0] = p0; + h = hb; + do { + b = pb[l]; + while (pi[l]--) { int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - Zd i2 = VtoZd(b->v[k]); - h0 = Zd(i2,plus).norm2();// norme 2 ^2 - if (h0 norm 2 big enought - vn = b->v[k]; - if(verbosity>2000) - cout << " NV: find " << vn << " " << h0/coef << " " << h2/coef << " " << h/coef << " k " << k << " P= " << (const Rd &) *b->v[k] << endl; - - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if ((b=b->b[k])) - { - hb >>=1 ; // div by 2 - Zd ppp(pp[l],k,hb); - if(verbosity>99999) - { - { - Rd rpp=ppp, rP = plus; - cout << " box " << b->n << " " << rpp/coef << " .. " << rP/coef << " h= " << h/coef << " hb " << hb/coef << " l " << l << " " << k << endl; - } - } - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - - if(verbosity>99999) - { - Rd rpp=ppp; - cout << " box inter " << rpp/coef << " size "<< hb/coef << " l " << l << " " << k << endl; - } - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : N ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } + + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + Zd i2 = VtoZd(b->v[k]); + h0 = Zd(i2, plus).norm2( ); // norme 2 ^2 + if (h0 < h2) { + h2 = h0; + h = Zd(i2, plus).norm( ) * c2infty; // norm infty -> norm 2 big enought + vn = b->v[k]; + if (verbosity > 2000) cout << " NV: find " << vn << " " << h0 / coef << " " << h2 / coef << " " << h / coef << " k " << k << " P= " << (const Rd &)*b->v[k] << endl; + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + Zd ppp(pp[l], k, hb); + if (verbosity > 99999) { + { + Rd rpp = ppp, rP = plus; + cout << " box " << b->n << " " << rpp / coef << " .. " << rP / coef << " h= " << h / coef << " hb " << hb / coef << " l " << l << " " << k << endl; + } + } + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) + { + + if (verbosity > 99999) { + Rd rpp = ppp; + cout << " box inter " << rpp / coef << " size " << hb / coef << " l " << l << " " << k << endl; + } + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : N; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; + } } - hb <<= 1; // mul by 2 - } while (l--); - - return vn; + hb <<= 1; // mul by 2 + } while (l--); + + return vn; } - - - template - Vertex * GTree::ToClose(const Rd & v,R seuil,Zd H,bool nearest) - { + + template< class Vertex > + Vertex *GTree< Vertex >::ToClose(const Rd &v, R seuil, Zd H, bool nearest) { const Rd X(v); const Zd p(RdtoZd(v)); - R seuil2 = seuil*seuil; + R seuil2 = seuil * seuil; // const Metric Mx(v.m); - Vertex * pvr=0; - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - Zd pp[ MaxDeep ]; - - int l=0; // level - QuadTreeBox * b; - long h=MaxISize; - long hb = MaxISize; - Zd p0( 0 ); - - if (!root->n) - return 0; // empty tree - + Vertex *pvr = 0; + QuadTreeBox *pb[MaxDeep]; + int pi[MaxDeep]; + Zd pp[MaxDeep]; + + int l = 0; // level + QuadTreeBox *b; + long h = MaxISize; + long hb = MaxISize; + Zd p0(0); + + if (!root->n) return 0; // empty tree + // general case ----- - pb[0]= root; - pi[0]= root->n>0 ?(int) root->n : N ; - pp[0]= p0; - h=hb; - do { - b= pb[l]; - while (pi[l]--) - { - int k = pi[l]; - //cout << "b" << b << ", k= " << k << endl; - //cout << " b->n " << b->n << endl; - if (b->n>0) // Vertex QuadTreeBox none empty - { - NbVerticesSearch++; - Vertex & V(*b->v[k]); - Zd i2 = VtoZd(V); - - if ( Zd(i2,p).less(H) ) - { - - Rd XY(X,V); - R dd; - if( (dd= (XY,XY) ) < seuil2 ) // LengthInterpole(Mx(XY), b->v[k]->m(XY))) < seuil ) - { - if( nearest ) // modif FH aug. 2019 For P. Jolivet. - { - seuil2=dd; - pvr = & V; - } - else - return &V; - } - } - } - else // Pointer QuadTreeBox - { - QuadTreeBox *b0=b; - NbQuadTreeBoxSearch++; - if( (b=b->b[k]) ) - { - - hb >>=1; // div by 2 - Zd ppp(pp[l],k,hb); - - if( ppp.interseg(p,hb,H) ) - { - - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : N; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - - } - else - b=b0; - } - } // fin: while(pi[l]--) - hb <<= 1; // mul by 2 + pb[0] = root; + pi[0] = root->n > 0 ? (int)root->n : N; + pp[0] = p0; + h = hb; + do { + b = pb[l]; + while (pi[l]--) { + int k = pi[l]; + // cout << "b" << b << ", k= " << k << endl; + // cout << " b->n " << b->n << endl; + if (b->n > 0) // Vertex QuadTreeBox none empty + { + NbVerticesSearch++; + Vertex &V(*b->v[k]); + Zd i2 = VtoZd(V); + + if (Zd(i2, p).less(H)) { + + Rd XY(X, V); + R dd; + if ((dd = (XY, XY)) < seuil2) // LengthInterpole(Mx(XY), b->v[k]->m(XY))) < seuil ) + { + if (nearest) // modif FH aug. 2019 For P. Jolivet. + { + seuil2 = dd; + pvr = &V; + } else + return &V; + } + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + + hb >>= 1; // div by 2 + Zd ppp(pp[l], k, hb); + + if (ppp.interseg(p, hb, H)) { + + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : N; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + + } else + b = b0; + } + } // fin: while(pi[l]--) + hb <<= 1; // mul by 2 } while (l--); return pvr; - } - - template - void GTree::Add( Vertex & w) - { - QuadTreeBox ** pb , *b; + + template< class Vertex > + void GTree< Vertex >::Add(Vertex &w) { + QuadTreeBox **pb, *b; Zd p(VtoZd(w)); - long l=MaxISize; + long l = MaxISize; pb = &root; - - while( (b=*pb) && (b->n<0)) - { - b->n--; - l >>= 1; - pb = &b->b[p.Case(l)]; - } - if (b) { - for(int i=N-1;i>=0;--i) - if (b->n > i && b->v[i] == &w) - { - //if( abs(w.x+0.5)<1e-10 ) cout << "if (b->n > i && b->v[i] == &w)" <n < 0)) { + b->n--; + l >>= 1; + pb = &b->b[p.Case(l)]; + } + if (b) { + for (int i = N - 1; i >= 0; --i) + if (b->n > i && b->v[i] == &w) { + // if( abs(w.x+0.5)<1e-10 ) cout << "if (b->n > i && b->v[i] == &w)" <n == N)) // the QuadTreeBox is full - { - //if(verbosity > 5) cout << " b = " << b << b->n << " " << l << endl; - Vertex *v4[N]; // copy of the QuadTreeBox vertices - for(int i=0;iv[i]; - b->v[i]=0;} - - b->n = -b->n; // mark is pointer QuadTreeBox - - l >>= 1; // div the size by 2 - ffassert(l); - for (int k=0;kb[ij=VtoZd(v4[k]).Case(l)]; - //if(verbosity > 5) cout << "ij= "<< ij << " " << VtoZd(v4[k])<< endl; - if (!bb) - bb=b->b[ij]=NewQuadTreeBox(); // alloc the QuadTreeBox - //if(verbosity > 5) cout << bb << " " << k << " " << ij << endl; - bb->v[bb->n++] = v4[k]; - } - pb = &b->b[p.Case(l)]; + while ((b = *pb) && (b->n == N)) // the QuadTreeBox is full + { + // if(verbosity > 5) cout << " b = " << b << b->n << " " << l << endl; + Vertex *v4[N]; // copy of the QuadTreeBox vertices + for (int i = 0; i < N; ++i) { + v4[i] = b->v[i]; + b->v[i] = 0; } - if (!(b = *pb)) - { //if(verbosity > 5) cout << "Qbox \n"; - b=*pb= NewQuadTreeBox(); // alloc the QuadTreeBox + + b->n = -b->n; // mark is pointer QuadTreeBox + + l >>= 1; // div the size by 2 + ffassert(l); + for (int k = 0; k < N; k++) // for the 4 vertices find the sub QuadTreeBox ij + { + int ij; + QuadTreeBox *bb = b->b[ij = VtoZd(v4[k]).Case(l)]; + // if(verbosity > 5) cout << "ij= "<< ij << " " << VtoZd(v4[k])<< endl; + if (!bb) bb = b->b[ij] = NewQuadTreeBox( ); // alloc the QuadTreeBox + // if(verbosity > 5) cout << bb << " " << k << " " << ij << endl; + bb->v[bb->n++] = v4[k]; } - //if(verbosity > 5) cout << b << " " << b->n << endl; - b->v[b->n++]=&w; // we add the vertex - NbVertices++; - + pb = &b->b[p.Case(l)]; + } + if (!(b = *pb)) { // if(verbosity > 5) cout << "Qbox \n"; + b = *pb = NewQuadTreeBox( ); // alloc the QuadTreeBox + } + // if(verbosity > 5) cout << b << " " << b->n << endl; + b->v[b->n++] = &w; // we add the vertex + NbVertices++; } - -template -GTree::GTree(Vertex * v,Rd Pmin,Rd Pmax,int nbv) : - lenStorageQuadTreeBox(nbv/8+100), - // th(t), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - NbSearch(0), - NbQuadTreeBox(0), - NbVertices(0), - cMin(Pmin-(Pmax-Pmin)/2), - cMax(Pmax+(Pmax-Pmin)/2), - coef( MaxISize/Norme_infty(cMax-cMin)) - -{ - if(verbosity>5){ - cout << " GTree: box: "<< Pmin << " " << Pmax << " " << cMin << " "<< cMax << " nbv : " << nbv < MaxICoor); - if (v) - for (long i=0;i - GTree::GTree() : - lenStorageQuadTreeBox(100), - // th(0), - NbQuadTreeBoxSearch(0), - NbVerticesSearch(0), - NbSearch(0), - NbQuadTreeBox(0), - NbVertices(0), - cMin(),cMax(),coef(0) + template< class Vertex > + GTree< Vertex >::GTree(Vertex *v, Rd Pmin, Rd Pmax, int nbv) + : lenStorageQuadTreeBox(nbv / 8 + 100), + // th(t), + NbQuadTreeBoxSearch(0), NbVerticesSearch(0), NbSearch(0), NbQuadTreeBox(0), NbVertices(0), cMin(Pmin - (Pmax - Pmin) / 2), cMax(Pmax + (Pmax - Pmin) / 2), + coef(MaxISize / Norme_infty(cMax - cMin)) + { - sb =new StorageQuadTreeBox(lenStorageQuadTreeBox); - root=NewQuadTreeBox(); + if (verbosity > 5) { + cout << " GTree: box: " << Pmin << " " << Pmax << " " << cMin << " " << cMax << " nbv : " << nbv << endl; + cout << "MaxISize " << MaxISize << endl; + // cout << " RdtoZd(cMin)" << RdtoZd(cMin) << " RdtoZd(cMax)" << RdtoZd(cMax) << endl; + // cout << " RdtoZd(Pmin)" << RdtoZd(Pmin) << " RdtoZd(Pmax)" << RdtoZd(Pmax) << endl; + } + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); + // throwassert( MaxISize > MaxICoor); + if (v) + for (long i = 0; i < nbv; i++) Add(v[i]); } - - template - GTree::StorageQuadTreeBox::StorageQuadTreeBox(int ll,StorageQuadTreeBox *nn) - { + + template< class Vertex > + GTree< Vertex >::GTree( ) + : lenStorageQuadTreeBox(100), + // th(0), + NbQuadTreeBoxSearch(0), NbVerticesSearch(0), NbSearch(0), NbQuadTreeBox(0), NbVertices(0), cMin( ), cMax( ), coef(0) { + sb = new StorageQuadTreeBox(lenStorageQuadTreeBox); + root = NewQuadTreeBox( ); + } + + template< class Vertex > + GTree< Vertex >::StorageQuadTreeBox::StorageQuadTreeBox(int ll, StorageQuadTreeBox *nn) { len = ll; n = nn; b = new QuadTreeBox[ll]; - for (int i = 0; i GTree::StorageQuadTreeBox::~StorageQuadTreeBox() - { //cout << "~StorageQuadTreeBox " << this << " n " << n << " b " << b << endl; - if(n) delete n; - delete [] b; + + template< class Vertex > + GTree< Vertex >::StorageQuadTreeBox::~StorageQuadTreeBox( ) { // cout << "~StorageQuadTreeBox " << this << " n " << n << " b " << b << endl; + if (n) delete n; + delete[] b; } - - template GTree::~GTree() - { - if(verbosity>4) cout << "~GTree " << *this << endl; - - delete sb; + + template< class Vertex > + GTree< Vertex >::~GTree( ) { + if (verbosity > 4) cout << "~GTree " << *this << endl; + + delete sb; } - -template ostream& operator <<(ostream& f, const GTree & qt) -{ - f << " the tree " << endl; - f << " NbTreeBox = " << qt.NbQuadTreeBox - << " Nb Vertices = " << qt.NbVertices << endl; - f << " NbTreeBoxSearch " << qt.NbQuadTreeBoxSearch - << " NbVerticesSearch " << qt.NbVerticesSearch << " NbSearch " << qt.NbSearch << " ratio: " - << qt.NbVerticesSearch/max(1L,qt.NbSearch) << endl; - f << " SizeOf QuadTree" << qt.SizeOf() << endl; - // return dump(f,*qt.root); - return f; -} - - template Vertex * GTree::NearestVertexWithNormal(const Rd &P)//(long xi,long yj) + + template< class Vertex > + ostream &operator<<(ostream &f, const GTree< Vertex > &qt) { + f << " the tree " << endl; + f << " NbTreeBox = " << qt.NbQuadTreeBox << " Nb Vertices = " << qt.NbVertices << endl; + f << " NbTreeBoxSearch " << qt.NbQuadTreeBoxSearch << " NbVerticesSearch " << qt.NbVerticesSearch << " NbSearch " << qt.NbSearch << " ratio: " << qt.NbVerticesSearch / max(1L, qt.NbSearch) + << endl; + f << " SizeOf QuadTree" << qt.SizeOf( ) << endl; + // return dump(f,*qt.root); + return f; + } + + template< class Vertex > + Vertex *GTree< Vertex >::NearestVertexWithNormal(const Rd &P) //(long xi,long yj) { NbSearch++; - QuadTreeBox * pb[ MaxDeep ]; - int pi[ MaxDeep ]; - Zd pp[ MaxDeep]; - int l; // level - QuadTreeBox * b; - IntQuad h=MaxISize,h0; - IntQuad hb = MaxISize; - Zd p0; - Zd plus(RdtoZd(P) );//xin) - return vn; // empty tree - - while( (n0 = b->n) < 0) - { - // search the non empty - // QuadTreeBox containing the point (i,j) - long hb2 = hb >> 1 ; - int k = plus.Case(hb2);//(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j - QuadTreeBox * b0= b->b[k]; - if ( ( b0 == 0) || (b0->n == 0) ) - break; // null box or empty => break - NbQuadTreeBoxSearch++; - p0.Add(k,hb2); - hb = hb2; + long n0; + if (!root->n) return vn; // empty tree + + while ((n0 = b->n) < 0) { + // search the non empty + // QuadTreeBox containing the point (i,j) + long hb2 = hb >> 1; + int k = plus.Case(hb2); //(iplus,jplus,hb2);// QuadTreeBox number of size hb2 contening i;j + QuadTreeBox *b0 = b->b[k]; + if ((b0 == 0) || (b0->n == 0)) break; // null box or empty => break + NbQuadTreeBoxSearch++; + p0.Add(k, hb2); + hb = hb2; + } + + if (n0 > 0) { + for (int k = 0; k < n0; k++) { + Vertex *v = b->v[k]; + if (v->ninside(P)) { + Zd i2 = VtoZd(v); + // try if is in the right sens -- + h0 = Zd(i2, plus).norm( ); // h0 = NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + NbVerticesSearch++; + } } - - - if ( n0 > 0) - { - for(int k=0;kv[k]; - if (v->ninside(P)) { - Zd i2 = VtoZd(v); - // try if is in the right sens -- - h0 = Zd(i2,plus).norm();// h0 = NORM(iplus,i2.x,jplus,i2.y); - if (h0 n>0 ?(int) b->n : N ; - pp[0]=p0; - h=hb; - L1: - do { // walk on the tree - b= pb[l]; - while (pi[l]--) // loop on 4 element of the box - { - int k = pi[l]; - - if (b->n>0) // Vertex QuadTreeBox none empty - { - Vertex * v=b->v[k]; - if (v->ninside(P) ) { - NbVerticesSearch++; - Zd i2 = VtoZd(v); - // if good sens when try -- - h0 = Zd(i2,plus).norm();// NORM(iplus,i2.x,jplus,i2.y); - if (h0 b[k])) - { - hb >>=1 ; // div by 2 - Zd ppp(pp[l],k,hb); - - if ( ppp.interseg(plus,hb,h) )//(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) - { - pb[++l]= b; - pi[l]= b->n>0 ?(int) b->n : N ; - pp[l]=ppp; - } - else - b=b0, hb <<=1 ; - } - else - b=b0; - } - } - hb <<= 1; // mul by 2 - } while (l--); - if (!vn && b != root ) - {// cas particulier on repart du sommet on avais rien trouver - b=root; - hb = MaxISize; - p0=Zd(); - l=0; - pb[0]= b; - pi[0]= b->n>0 ?(int) b->n : N ; - pp[0]=Zd(); - - goto L1; - } - return vn; -} + // INITIALISATION OF THE STACK + l = 0; // level + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : N; + pp[0] = p0; + h = hb; + L1: + do { // walk on the tree + b = pb[l]; + while (pi[l]--) // loop on 4 element of the box + { + int k = pi[l]; + if (b->n > 0) // Vertex QuadTreeBox none empty + { + Vertex *v = b->v[k]; + if (v->ninside(P)) { + NbVerticesSearch++; + Zd i2 = VtoZd(v); + // if good sens when try -- + h0 = Zd(i2, plus).norm( ); // NORM(iplus,i2.x,jplus,i2.y); + if (h0 < h) { + h = h0; + vn = v; + } + } + } else // Pointer QuadTreeBox + { + QuadTreeBox *b0 = b; + NbQuadTreeBoxSearch++; + if ((b = b->b[k])) { + hb >>= 1; // div by 2 + Zd ppp(pp[l], k, hb); + if (ppp.interseg(plus, hb, h)) //(INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)) + { + pb[++l] = b; + pi[l] = b->n > 0 ? (int)b->n : N; + pp[l] = ppp; + } else + b = b0, hb <<= 1; + } else + b = b0; + } + } + hb <<= 1; // mul by 2 + } while (l--); + if (!vn && b != root) { // cas particulier on repart du sommet on avais rien trouver + b = root; + hb = MaxISize; + p0 = Zd( ); + l = 0; + pb[0] = b; + pi[0] = b->n > 0 ? (int)b->n : N; + pp[0] = Zd( ); + goto L1; + } + return vn; + } // static int kfind=0; // static int kthrough=0; - - inline void CoorBary(const Triangle2 & K,const R2 & P, R *l) - { - R detK = 2.*K.mesure() ; - l[1]=det(K[0],P,K[2])/detK; - l[2]=det(K[0],K[1],P)/detK; - l[0]=1-l[1]-l[2]; + + inline void CoorBary(const Triangle2 &K, const R2 &P, R *l) { + R detK = 2. * K.mesure( ); + l[1] = det(K[0], P, K[2]) / detK; + l[2] = det(K[0], K[1], P) / detK; + l[0] = 1 - l[1] - l[2]; } - - - inline void CoorBary(const Tet & K,const R3 & P, R *l) - { - R detK = 6.*K.mesure() ; - l[1]=det(K[0],P,K[2],K[3])/detK; - l[2]=det(K[0],K[1],P,K[3])/detK; - l[3]=det(K[0],K[1],K[2],P)/detK; - l[0]=1-l[1]-l[2]-l[3]; + inline void CoorBary(const Tet &K, const R3 &P, R *l) { + R detK = 6. * K.mesure( ); + l[1] = det(K[0], P, K[2], K[3]) / detK; + l[2] = det(K[0], K[1], P, K[3]) / detK; + l[3] = det(K[0], K[1], K[2], P) / detK; + l[0] = 1 - l[1] - l[2] - l[3]; } - - - inline int CoorBaryPos(const Triangle2 & K,const R2 & P, R *l) - { - CoorBary(K,P,l); - int n=0,m=-1; - int nl[Tet::nv+1]; - R eps = -1e-10; - for(int i=0;i=0) - { // proj P on face .. m - int i0=Triangle2::nvadj[m][0]; - int i1=Triangle2::nvadj[m][1]; - R2 A(K[i0]),B(K[i1]); - R2 AB(A,B),AP(A,P); - double l2= AB.norme2(); - // L = (AB,AP)/l2 - - l[i0] = max(0.,min(1.,(AB,AP)/l2)); - l[i1] = 1-l[i0]; - l[m]=0; - } - return n; - - - - } - inline int CoorBaryPos(const Tet & K,const R3 & P, R *l) - { - CoorBary(K,P,l); - int n=0,m=-1; - int nl[Tet::nv+1]; - R eps = -1e-10; - for(int i=0;i=0) - { // proj P on face .. m - int i0=Tet::nvadj[m][0]; - int i1=Tet::nvadj[m][1]; - int i2=Tet::nvadj[m][2]; - R3 A(K[i0]),B(K[i1]),C(K[i2]); - R3 AB(A,B), AC(A,C); - R3 N = AB^AC ; - double N2 = (N,N); - l[i0] = max(0.,min(1.,det(P,B,C,N)/N2)); - l[i1] = max(0.,min(1.,det(A,P,C,N)/N2)); - l[i2] = 1-l[i0]-l[i1]; - l[m]=0; - } - return n; - - + inline int CoorBaryPos(const Triangle2 &K, const R2 &P, R *l) { + CoorBary(K, P, l); + int n = 0, m = -1; + int nl[Tet::nv + 1]; + R eps = -1e-10; + for (int i = 0; i < Triangle2::nv; ++i) // correction FH 2/04/20 + if (l[i] < eps) { + nl[n++] = i; + } else + m = i; + if (m >= 0) { // proj P on face .. m + int i0 = Triangle2::nvadj[m][0]; + int i1 = Triangle2::nvadj[m][1]; + R2 A(K[i0]), B(K[i1]); + R2 AB(A, B), AP(A, P); + double l2 = AB.norme2( ); + // L = (AB,AP)/l2 + + l[i0] = max(0., min(1., (AB, AP) / l2)); + l[i1] = 1 - l[i0]; + l[m] = 0; } - -// inline int nRand(int n) { -// return rand()%n; //avant random()%n; -// } - - inline int find5(int i,int *k,int l) - { - if(l<5) - { - for(int j=0;j=k[0] && i<=k[l-1]) - { - int i0=0,i1=l-1; - while(i0<=i1) - { int im=(i0+i1)/2; - if(ik[im]) i0=im+1; - else - if(i==k[im]){ - return im; - } - } + return n; + } + inline int CoorBaryPos(const Tet &K, const R3 &P, R *l) { + CoorBary(K, P, l); + int n = 0, m = -1; + int nl[Tet::nv + 1]; + R eps = -1e-10; + for (int i = 0; i < Tet::nv; ++i) // correction FH 2/04/20 + if (l[i] < eps) { + nl[n++] = i; + } else + m = i; + if (m >= 0) { // proj P on face .. m + int i0 = Tet::nvadj[m][0]; + int i1 = Tet::nvadj[m][1]; + int i2 = Tet::nvadj[m][2]; + R3 A(K[i0]), B(K[i1]), C(K[i2]); + R3 AB(A, B), AC(A, C); + R3 N = AB ^ AC; + double N2 = (N, N); + l[i0] = max(0., min(1., det(P, B, C, N) / N2)); + l[i1] = max(0., min(1., det(A, P, C, N) / N2)); + l[i2] = 1 - l[i0] - l[i1]; + l[m] = 0; + } + return n; + } + + // inline int nRand(int n) { + // return rand()%n; //avant random()%n; + // } + + inline int find5(int i, int *k, int l) { + if (l < 5) { + for (int j = 0; j < l; ++j) + if (i == k[j]) return j; + } else if (i >= k[0] && i <= k[l - 1]) { + int i0 = 0, i1 = l - 1; + while (i0 <= i1) { + int im = (i0 + i1) / 2; + if (i < k[im]) + i1 = im - 1; + else if (i > k[im]) + i0 = im + 1; + else if (i == k[im]) { + return im; + } } + } return -1; - } - - template - const typename Mesh::Element * Find(const Mesh & Th, - GTree *quadtree, - typename Mesh::Rd P, - typename Mesh::RdHat & Phat, - bool & outside, - const typename Mesh::Element * tstart) -{ - typedef typename Mesh::Element Element; - typedef typename Mesh::Vertex Vertex; - typedef typename Mesh::Rd Rd; - const int nkv=Element::nv; - const int d=Rd::d; - R dP=DBL_MAX, nddd=0; - Rd PPhat,Delta; - R eps = -1e-10;// def test in tet .. - - int k=0; - const int nReStartMax = 1 << Rd::d; // Nb vertex of the d-cube/ + } + + template< class Mesh > + const typename Mesh::Element *Find(const Mesh &Th, GTree< typename Mesh::Vertex > *quadtree, typename Mesh::Rd P, typename Mesh::RdHat &Phat, bool &outside, const typename Mesh::Element *tstart) { + typedef typename Mesh::Element Element; + typedef typename Mesh::Vertex Vertex; + typedef typename Mesh::Rd Rd; + const int nkv = Element::nv; + const int d = Rd::d; + R dP = DBL_MAX, nddd = 0; + Rd PPhat, Delta; + R eps = -1e-10; // def test in tet .. + + int k = 0; + const int nReStartMax = 1 << Rd::d; // Nb vertex of the d-cube/ int nReStart = 0; - int itstart[100],itout[100],kstart=0; + int itstart[100], itout[100], kstart = 0; Rd Pout[100]; - int it,j,it00,nbdeja=0,nbdejax=0; - const int mxbord=1000; - int kbord[mxbord+1]; - int nbord=0; - map deja; - if(searchMethod>1) goto PICHON; - if ( tstart ) - it00=it = Th(tstart); - else if(quadtree) - { - const Vertex * v=quadtree->NearestVertex(P);// Change Juil 2017 .. -/* - if (!v) - { - v=quadtree->NearestVertex(P); - assert(v); - }*/ - if( !v) { - verbosity = 10000000; - cout << "Bug search " << P << endl; - v=quadtree->NearestVertex(P); - } - ffassert(v); // bug !!!! - it00=it=Th.Contening(v); - nddd= Norme2(P-*v); - if(verbosity>200) - cout << " Find: Close : "<< *v << " , " << Th(v) << " dist " << nddd << endl; - - } - else ffassert(0); -RESTART: - ffassert(kstart<100); - itstart[kstart++]=it; - if(verbosity>199) - cout << " " << nReStart << " tstart= " << tstart << " , it=" << it << " P="<< P << " " << kstart << endl; - outside=true; - Mesh::kfind++; - while (1) - { - //if(verbosity>199) cout << "it " << it < deja; + if (searchMethod > 1) goto PICHON; + if (tstart) + it00 = it = Th(tstart); + else if (quadtree) { + const Vertex *v = quadtree->NearestVertex(P); // Change Juil 2017 .. + /* + if (!v) + { + v=quadtree->NearestVertex(P); + assert(v); + }*/ + if (!v) { + verbosity = 10000000; + cout << "Bug search " << P << endl; + v = quadtree->NearestVertex(P); + } + ffassert(v); // bug !!!! + it00 = it = Th.Contening(v); + nddd = Norme2(P - *v); + if (verbosity > 200) cout << " Find: Close : " << *v << " , " << Th(v) << " dist " << nddd << endl; + + } else + ffassert(0); + RESTART: + ffassert(kstart < 100); + itstart[kstart++] = it; + if (verbosity > 199) cout << " " << nReStart << " tstart= " << tstart << " , it=" << it << " P=" << P << " " << kstart << endl; + outside = true; + Mesh::kfind++; + while (1) { + // if(verbosity>199) cout << "it " << it < 500) - { // boucle ???? change eps - nbdeja=++deja[it];// we stocke le deja view in map - - nbdejax = max(nbdeja,nbdeja); - if(nbdejax> 5) eps=1e-7; - else if(nbdejax> 4) eps=1e-8; - else if(nbdejax> 3) eps=1e-9; - - ffassert(nbdeja<100); + ffassert(k++ < 2000); + if (k > 500) { // boucle ???? change eps + nbdeja = ++deja[it]; // we stocke le deja view in map + + nbdejax = max(nbdeja, nbdeja); + if (nbdejax > 5) + eps = 1e-7; + else if (nbdejax > 4) + eps = 1e-8; + else if (nbdejax > 3) + eps = 1e-9; + + ffassert(nbdeja < 100); } - - int kk,n=0,nl[nkv]; + + int kk, n = 0, nl[nkv]; R l[nkv]; - for(int iii=0; iii bug - + // avant: // R eps = -K.mesure()*1e-10; - if( nbdeja>3) eps=-1e-8; - - - for(int i=0;i19 && nbdeja >1) { - cout << " Bizarre loop in search "<< nbdeja << " tet it=" << it ; - cout << " K.mesure=" << K.mesure() ; - cout << " eps=" << eps << " : " ; - for(int i=0;i on test les autre - { // 1) existe t'il un adj interne - int nn=0,ii; - int nadj[d+1],ni[d+1]; - for(int i=0;i=0) && find5(itt,kbord,nbord) < 0 ) - ni[nn++]=i,nadj[i]=itt; - if(verbosity>1000) - cout << " nn : "<< nn << endl; - if (nn>0) - { - //j=nadj[nRand(nn)]; - j=ni[randwalk(nn)]; - it=nadj[j]; - dP=DBL_MAX; - //cout << "new it= " << it << endl; - continue; - } - } + Rd pp = K(Phat) - P; + if (pp.norme( ) > 1e-5) { + cout << " Bug find P " << P << " ==" << K(Phat); + cout << "Phat== " << Phat << " diff= " << pp << endl; + assert(0); + } + +#endif + return &K; + } + + kk = n == 1 ? 0 : randwalk(n); + j = nl[kk]; + int itt = Th.ElementAdj(it, j); + if (itt != it && itt >= 0) { + dP = DBL_MAX; + it = itt; + continue; + } + int inkbord = find5(it, kbord, nbord); + if (inkbord < 0 && nbord < mxbord) { + kbord[nbord++] = it; + if (nbord >= 5) HeapSort(kbord, nbord); + } + if (verbosity > 1001) { + cout << " bord " << it << " nbf < 0 : " << n << " (inb) " << inkbord << " nfb" << nbord << endl; + R ss = 0; + for (int i = 0; i < nkv; ++i) { + ss += l[i]; + cout << l[i] << " "; + } + cout << " s=" << ss << endl; + ; + } + + if (verbosity > 2000) cout << " GQuadTree::value of n " << n << endl; + + if (n != 1) // on est sur le bord, mais plusieurs face <0 => on test les autre + { // 1) existe t'il un adj interne + int nn = 0, ii; + int nadj[d + 1], ni[d + 1]; + for (int i = 0; i < nkv; ++i) + // avant :: if (l[i] < eps && (itt=Th.ElementAdj(it,ii=i)) != it && itt && find5(itt,kbord,nbord) < -1 ) + if (l[i] < eps && (itt = Th.ElementAdj(it, ii = i)) != it && (itt >= 0) && find5(itt, kbord, nbord) < 0) ni[nn++] = i, nadj[i] = itt; + if (verbosity > 1000) cout << " nn : " << nn << endl; + if (nn > 0) { + // j=nadj[nRand(nn)]; + j = ni[randwalk(nn)]; + it = nadj[j]; + dP = DBL_MAX; + // cout << "new it= " << it << endl; + continue; + } + } // toutes les faces <0 sont sur le bord. // pour l'instant on s'arête // le point est externe. (mais trop cher pour faire mieux) - // on projet le points sur le bord via le coordonne - // barycentrique - { // a ridge on border (to hard to do the correct stuff) - // or a corner just do the projection on lambda - R s=0.; - for(int i=0;i1000) - { - cout << " "<< P << " " << n << " l: "; - R ss=0; - for(int i=0;i 1000) { + cout << " " << P << " " << n << " l: "; + R ss = 0; + for (int i = 0; i < nkv; ++i) { + ss += l[i]; + cout << l[i] << " "; } - outside=true; -// New Method mars 2020 - if(1) // searchMethod==0) - { - GenericDataFindBoundary * gdfb=Th.Buildgdfb(); - if(gdfb ) + cout << " s=" << ss << " " << s << " exit by bord " << it << " " << Phat << endl; + ; + } + outside = true; + // New Method mars 2020 + if (1) // searchMethod==0) + { + GenericDataFindBoundary< Mesh > *gdfb = Th.Buildgdfb( ); + if (gdfb) { + double l[4], lK[4]; + int na[4], nna = 0, mma = 0; + int loutside; // of border ??? 0 inside, 1 out close, 2, out fare, , -1 inside + int itt = gdfb->Find(P, l, loutside); + // warning l is projecton on boundary ???? + CoorBary(Th[itt], P, lK); + const double eps = 1e-10; + for (int i = 0; i <= Rd::d; ++i) + if (lK[i] < -eps) na[nna++] = i; + for (int k = 0; k < nna; ++k) { + int ii = na[k], ittt = Th.ElementAdj(itt, ii); + if (ittt < 0 || ittt == itt) mma++; + } + it = itt; + + if (nna) // + { + if (nReStart++ < 1) + goto RESTART; + else if (searchMethod) + goto PICHON; + Phat = Rd(l + 1); + } else // in itt + Phat = Rd(lK + 1); // correction FH 1/0>4/2020 + outside = nna > 0; + + const Element &K = Th[it]; + if (verbosity > 9) + cout << " - Find " << P << " -> " << K(Phat) << " " << loutside << " k= " << itt << " dist =" << (P - K(Phat)).norme( ) << " :: " << Phat << " nddd= " << nddd << " " << nReStart << " " + << nna << endl; + return Th.elements + it; // outside + } + } + // end New Methode + // on retest with a other stating point?????? + // Mod. 23/02/2016 F. H + itout[kstart - 1] = it; + Pout[kstart - 1] = Phat; + while (nReStart++ < nReStartMax) { // Loop on the vertex of a d-hyper-cude { - double l[4],lK[4]; - int na[4],nna=0,mma=0; - int loutside;// of border ??? 0 inside, 1 out close, 2, out fare, , -1 inside - int itt =gdfb->Find(P,l,loutside); - // warning l is projecton on boundary ???? - CoorBary(Th[itt],P,lK); - const double eps = 1e-10; - for (int i=0; i<= Rd::d;++i ) - if(lK[i] < -eps) na[nna++]=i; - for( int k=0; k4/2020 - outside=nna>0; - - const Element &K=Th[it]; - if( verbosity > 9) - cout << " - Find "<< P << " -> " << K(Phat) << " " << loutside << " k= " << itt - << " dist =" << (P-K(Phat)).norme() << " :: " << Phat << " nddd= " << nddd <<" " << nReStart << " " << nna << endl; - return Th.elements + it; // outside - + int k = nReStart - 1; + int i = (nReStart - 2) / 2; + + for (int i = 0; i < Rd::d; ++i) Delta[i] = ((1 << i) & k) ? nddd : -nddd; } + if (verbosity > 199) { + Rd pp = Th[it](Phat) - P; + cout << " restart find P " << P << " !=" << Th[it](Phat) << "\t"; + cout << "Phat== " << Phat << " diff= " << pp << " it = " << it << endl; } -// end New Methode - // on retest with a other stating point?????? - // Mod. 23/02/2016 F. H - itout[kstart-1]= it; - Pout[kstart-1]=Phat; - while(nReStart++ < nReStartMax) - {// Loop on the vertex of a d-hyper-cude - { - int k= nReStart-1; - int i = (nReStart-2)/2; - - for(int i=0; i199) { - Rd pp=Th[it](Phat)-P; - cout << " restart find P " << P << " !=" < 199) cout << " loop Search " << nReStart << P << " Delta" << Delta << " it " << it << " same " << same << endl; + if (same) continue; + if (Rd::d == 2) npichon2d1++; + if (Rd::d == 3) npichon3d1++; + + goto RESTART; } - - if(searchMethod) goto PICHON; - // Search best out .... - int ko=0,k=0; - double dmin=Norme2_2(P-Th[itout[k]](Pout[k])); - for(int k=1; k149) - cout << " -- Find(out) " << it << " Outside " << outside << " it "<< it << " err = "<< sqrt(dmin) << "/" << Phat << " " << nddd << endl; - return &Th[it] ; - } + } + Phat = Pout[ko]; + it = itout[ko]; + if (verbosity > 149) cout << " -- Find(out) " << it << " Outside " << outside << " it " << it << " err = " << sqrt(dmin) << "/" << Phat << " " << nddd << endl; + return &Th[it]; + } } - - PICHON: - { - if(Rd::d==2) npichon2d++; - if(Rd::d==3) npichon3d++; - - /*==============================PICHON=================*/ - // Brute force ** */ - R l[4], eps = -1e-6; //pichon - double dist_baryC = 0.0, min_dist_baryC = 1e31; - long closestTet = -1; - l[0]=l[1]=l[2]=l[3]=1; // for d < 3 - for(int tet=0;tet= eps) && (l[1] >= eps) && (l[2] >= eps) && (l[3] >= eps) ) - { - if( verbosity>199) - { - cout << " #### brute force " << tet << " "<< endl; - } - outside=false; - Phat=Rd(l+1); - return &K; - } + dist_baryC = 0.0; + for (int i = 0; i < nkv; i++) dist_baryC += abs(l[i]); + + // define closest Tetrahedron !!! TO VERIFY THE HYPOTHESE !!! + if (dist_baryC < min_dist_baryC) { + min_dist_baryC = dist_baryC; + closestTet = tet; + } + + if ((l[0] >= eps) && (l[1] >= eps) && (l[2] >= eps) && (l[3] >= eps)) { + if (verbosity > 199) { + cout << " #### brute force " << tet << " " << endl; + } + outside = false; + Phat = Rd(l + 1); + return &K; + } } - - const Element & K(Th[closestTet]); - outside=true; - CoorBaryPos(K,P,l); - - Phat=Rd(l+1); - if(verbosity>2) - cout << " --vertex:" << P << " NOT in DOMAIN. use closestTet. Phat:" << Phat << endl; - return &K; + + const Element &K(Th[closestTet]); + outside = true; + CoorBaryPos(K, P, l); + + Phat = Rd(l + 1); + if (verbosity > 2) cout << " --vertex:" << P << " NOT in DOMAIN. use closestTet. Phat:" << Phat << endl; + return &K; } - /*==============================PICHON=================*/ -} + /*==============================PICHON=================*/ + } + + // Instantiation manuel des templates + + template class GTree< Vertex2 >; + template class GTree< Vertex3 >; + template class GTree< Vertex1 >; + /// typedef MeshS::GMesh GMeshS; + typedef Mesh3::GMesh GMesh3; + typedef Mesh2::GMesh GMesh2; + typedef Mesh1::GMesh GMesh1; -// Instantiation manuel des templates - -template class GTree; -template class GTree; -template class GTree; - -///typedef MeshS::GMesh GMeshS; -typedef Mesh3::GMesh GMesh3; -typedef Mesh2::GMesh GMesh2; -typedef Mesh1::GMesh GMesh1; - - -/*template -const GMeshS::Element * Find(const GMeshS & Th, - GTree< GMeshS::Vertex> *quadtree, - GMeshS::Rd P, - GMeshS::RdHat & Phat, - bool & outside, - const GMeshS::Element * tstart); + /*template + const GMeshS::Element * Find(const GMeshS & Th, + GTree< GMeshS::Vertex> *quadtree, + GMeshS::Rd P, + GMeshS::RdHat & Phat, + bool & outside, + const GMeshS::Element * tstart); + */ + + template const GMesh3::Element *Find< GMesh3 >(const GMesh3 &Th, GTree< GMesh3::Vertex > *quadtree, GMesh3::Rd P, GMesh3::RdHat &Phat, bool &outside, const GMesh3::Element *tstart); + template const GMesh2::Element *Find< GMesh2 >(const GMesh2 &Th, GTree< GMesh2::Vertex > *quadtree, GMesh2::Rd P, GMesh2::RdHat &Phat, bool &outside, const GMesh2::Element *tstart); + + /* + template + const GMesh1::Element * Find(const GMesh1 & Th, + GTree< GMesh1::Vertex> *quadtree, + GMesh1::Rd P, + GMesh1::RdHat & Phat, + bool & outside, + const GMesh1::Element * tstart); */ - -template -const GMesh3::Element * Find(const GMesh3 & Th, - GTree< GMesh3::Vertex> *quadtree, - GMesh3::Rd P, - GMesh3::RdHat & Phat, - bool & outside, - const GMesh3::Element * tstart); -template -const GMesh2::Element * Find(const GMesh2 & Th, - GTree< GMesh2::Vertex> *quadtree, - GMesh2::Rd P, - GMesh2::RdHat & Phat, - bool & outside, - const GMesh2::Element * tstart); +} // namespace EF23 -/* - template - const GMesh1::Element * Find(const GMesh1 & Th, - GTree< GMesh1::Vertex> *quadtree, - GMesh1::Rd P, - GMesh1::RdHat & Phat, - bool & outside, - const GMesh1::Element * tstart); -*/ +template< typename Mesh > +GenericDataFindBoundary< Mesh >::~GenericDataFindBoundary( ) { + if (verbosity > 1) + cout << "\n -- ~GenericDataFindBoundary: Nb find " << nbfind << " nb element " << nbelement << " ratio " << (double)nbelement / std::max(nbfind, 1L) << " mpirank " << mpirank << endl; + delete tree; } +template< typename Mesh > +void GenericDataFindBoundary< Mesh >::gnuplot(const string &fn) { // for debugging .. + if (dHat < 3) { + ofstream gp(fn.c_str( )); + ffassert(gp); -template -GenericDataFindBoundary::~GenericDataFindBoundary() -{ - if(verbosity>1) cout << "\n -- ~GenericDataFindBoundary: Nb find " << nbfind << " nb element " - << nbelement << " ratio " << (double) nbelement/std::max(nbfind,1L) - << " mpirank " << mpirank << endl; - delete tree; -} -template -void GenericDataFindBoundary::gnuplot(const string & fn) -{ // for debugging .. - if(dHat < 3) - { - ofstream gp(fn.c_str()); - ffassert(gp); - - const Mesh &Th = *pTh; - if( bborder ) - for(int be=0; be=0 || k != kk) - { - for(int j=0; j< BorderElement::nv;++j) - gp << (Rd) B[j] << endl; - gp << "\n\n"; - } - } - } - else - for(int k=0; k= 0 || k != kk) { + for (int j = 0; j < BorderElement::nv; ++j) gp << (Rd)B[j] << endl; + gp << "\n\n"; + } + } + } + else + for (int k = 0; k < Th.nt; ++k) { + const Element &K = Th[k]; + for (int j = 0; j <= Element::nv; ++j) gp << (Rd)K[j % Element::nv] << endl; + gp << "\n\n"; + } + if (dHat == 2) { + ofstream gp((fn + "c").c_str( )); + for (int i = 0; i < P.N( ); ++i) { + int N = 100; + const double pi = 3.14159265358979323846264338327950288; + double dt = pi * 2. / N, r = delta[i]; + for (int j = 0; j <= N; ++j) { + Fem2D::R3 Q = P[i]; + double x = Q.x + r * cos(dt * j); + double y = Q.y + r * sin(dt * j); + double z = Q.z; + gp << x << " " << y << " " << z << endl; + } + gp << "\n\n"; + } } + } } -inline double Plambla(int dhat,const Fem2D::R2 *Q,Fem2D::R2 &P,double *l) -{ - ffassert(0); // to do +inline double Plambla(int dhat, const Fem2D::R2 *Q, Fem2D::R2 &P, double *l) { + ffassert(0); // to do } -inline double Plambla(int dhat,const Fem2D::R1 *Q,Fem2D::R1 &P,double *l) -{ - ffassert(0); // to do +inline double Plambla(int dhat, const Fem2D::R1 *Q, Fem2D::R1 &P, double *l) { + ffassert(0); // to do } -inline double Plambla(int dhat,const Fem2D::R3 *Q,Fem2D::R3 &P,double *l) -{ - using Fem2D::R3 ; - double dd=0; - if(dhat==1) - { - R3 AB(Q[0],Q[1]), AP(Q[0],P); - double ab2=(AB,AB); - l[1] = (AP,AB)/ab2; - l[0] = 1- l[1]; - dd= ab2; - } - else if(dhat==2) - { - R3 AB(Q[0],Q[1]), AC(Q[0],Q[2]); - R3 N = AB^AC ; - double N2 = (N,N); - dd = N2; - l[0] = det(Q[1]-P ,Q[2]-P ,N)/N2; - l[1] = det(P -Q[0],Q[2]-Q[0],N)/N2; - l[2] = 1-l[0]-l[1]; - } - else if( dhat==3) - { - double d=det(Q[0],Q[1],Q[2],Q[3]); - dd = d; - l[0]=det(P,Q[1],Q[2],Q[3])/d; - l[1]=det(Q[0],P,Q[2],Q[3])/d; - l[2]=det(Q[0],Q[1],P,Q[3])/d; - l[3]= 1- l[0]-l[1]-l[2]; - } - else assert(0); - return dd; +inline double Plambla(int dhat, const Fem2D::R3 *Q, Fem2D::R3 &P, double *l) { + using Fem2D::R3; + double dd = 0; + if (dhat == 1) { + R3 AB(Q[0], Q[1]), AP(Q[0], P); + double ab2 = (AB, AB); + l[1] = (AP, AB) / ab2; + l[0] = 1 - l[1]; + dd = ab2; + } else if (dhat == 2) { + R3 AB(Q[0], Q[1]), AC(Q[0], Q[2]); + R3 N = AB ^ AC; + double N2 = (N, N); + dd = N2; + l[0] = det(Q[1] - P, Q[2] - P, N) / N2; + l[1] = det(P - Q[0], Q[2] - Q[0], N) / N2; + l[2] = 1 - l[0] - l[1]; + } else if (dhat == 3) { + double d = det(Q[0], Q[1], Q[2], Q[3]); + dd = d; + l[0] = det(P, Q[1], Q[2], Q[3]) / d; + l[1] = det(Q[0], P, Q[2], Q[3]) / d; + l[2] = det(Q[0], Q[1], P, Q[3]) / d; + l[3] = 1 - l[0] - l[1] - l[2]; + } else + assert(0); + return dd; } -inline double dist2(int dhat,const Fem2D::R2 *Q,Fem2D::R2 &P,double *l,double *dl) -{ - ffassert(0); - return 0; +inline double dist2(int dhat, const Fem2D::R2 *Q, Fem2D::R2 &P, double *l, double *dl) { + ffassert(0); + return 0; } -inline double dist2(int dhat,const Fem2D::R1 *Q,Fem2D::R1 &P,double *l,double *dl) -{ - ffassert(0); - return 0; - +inline double dist2(int dhat, const Fem2D::R1 *Q, Fem2D::R1 &P, double *l, double *dl) { + ffassert(0); + return 0; } -inline double dist2(int dhat,const Fem2D::R3 *Q,Fem2D::R3 &P,double *l,double *dl) -{ - using Fem2D::R3 ; - double d2=0; - if(dhat==1) - { - dl[0]=min(1.,max(l[0],0.)); - dl[1]=1.-dl[0]; - R3 Pj = dl[0]*Q[0]+dl[1]*Q[1]; - d2 = R3(Pj,P).norme2(); - - } - else if(dhat==2) - { - int i=-1; - if(l[0]<0) i=0; - else if(l[1]<0) i=1; - else if(l[2]<0) i=2; - - if( i>=0) - { - // project on edge i - int i1= (i+1)%3,i2=(i+2)%3; - R3 AB(Q[i1],Q[i2]), AP(Q[i1],P); - dl[i2] = (AP,AB)/(AB,AB); - dl[i2]=min(1.,max(dl[i2],0.));// proj on AB .. - dl[i1] = 1- dl[i2]; - dl[i]=0; - } - else - { - dl[0]=l[0]; - dl[1]=l[1]; - dl[2]=l[2]; - } - R3 Pj = dl[0]*Q[0]+dl[1]*Q[1]+dl[2]*Q[2]; - d2 = R3(Pj,P).norme2(); - - } - else if( dhat==3) - { - ffassert(0); // to do FH... non ... +inline double dist2(int dhat, const Fem2D::R3 *Q, Fem2D::R3 &P, double *l, double *dl) { + using Fem2D::R3; + double d2 = 0; + if (dhat == 1) { + dl[0] = min(1., max(l[0], 0.)); + dl[1] = 1. - dl[0]; + R3 Pj = dl[0] * Q[0] + dl[1] * Q[1]; + d2 = R3(Pj, P).norme2( ); + + } else if (dhat == 2) { + int i = -1; + if (l[0] < 0) + i = 0; + else if (l[1] < 0) + i = 1; + else if (l[2] < 0) + i = 2; + + if (i >= 0) { + // project on edge i + int i1 = (i + 1) % 3, i2 = (i + 2) % 3; + R3 AB(Q[i1], Q[i2]), AP(Q[i1], P); + dl[i2] = (AP, AB) / (AB, AB); + dl[i2] = min(1., max(dl[i2], 0.)); // proj on AB .. + dl[i1] = 1 - dl[i2]; + dl[i] = 0; + } else { + dl[0] = l[0]; + dl[1] = l[1]; + dl[2] = l[2]; } - else assert(0); - return d2; + R3 Pj = dl[0] * Q[0] + dl[1] * Q[1] + dl[2] * Q[2]; + d2 = R3(Pj, P).norme2( ); + + } else if (dhat == 3) { + ffassert(0); // to do FH... non ... + } else + assert(0); + return d2; } -template -int GenericDataFindBoundary::Find(typename Mesh::Rd PP,double *l,int & outside,long old) const +template< typename Mesh > +int GenericDataFindBoundary< Mesh >::Find(typename Mesh::Rd PP, double *l, int &outside, long old) const // old :add FH et PHT mai 2022 -{ // FH: outside : 0 inside, 1 out close, 2, out fare, , -1 inside - // warning l - nbfind++; - typedef double R; - int nu=-1,ne=-1; - R dnu= 1e200,deps=0; - R dl[dHat+1]; - outside = 0; - Vertex *p0= &P[0]; - Vertex *p =tree->TrueNearestVertex(PP); - ffassert(p); - int ip = p-P; - Rd Q[dHat+1]; - R ll[dHat+1],lpj[dHat+1]; - if( old >=0 && !bborder) - { // check if old is correct element - int k =old; - const Element & K=(*pTh)[k]; - int nI =dHat+1; - for(int i=0; i< nI;++i) - Q[i]=K[i]; - double ddeps=Plambla(nI-1,Q,PP,ll);// return une taille ^2, ^4, ^3 suivant la dim nI-1 - R d2 = dist2(nI-1,Q,PP,ll,lpj); - if( nI==2) - ddeps =ddeps/10000.; - else if (nI==3) - ddeps = sqrt(ddeps)/10000.; // epaisseur de l'objet au carre 1.100 de - else ffassert(0); - if( d2 < ddeps/1000.) // pour etre sur - { +{ // FH: outside : 0 inside, 1 out close, 2, out fare, , -1 inside + // warning l + nbfind++; + typedef double R; + int nu = -1, ne = -1; + R dnu = 1e200, deps = 0; + R dl[dHat + 1]; + outside = 0; + Vertex *p0 = &P[0]; + Vertex *p = tree->TrueNearestVertex(PP); + ffassert(p); + int ip = p - P; + Rd Q[dHat + 1]; + R ll[dHat + 1], lpj[dHat + 1]; + if (old >= 0 && !bborder) { // check if old is correct element + int k = old; + const Element &K = (*pTh)[k]; + int nI = dHat + 1; + for (int i = 0; i < nI; ++i) Q[i] = K[i]; + double ddeps = Plambla(nI - 1, Q, PP, ll); // return une taille ^2, ^4, ^3 suivant la dim nI-1 + R d2 = dist2(nI - 1, Q, PP, ll, lpj); + if (nI == 2) + ddeps = ddeps / 10000.; + else if (nI == 3) + ddeps = sqrt(ddeps) / 10000.; // epaisseur de l'objet au carre 1.100 de + else + ffassert(0); + if (d2 < ddeps / 1000.) // pour etre sur + { - for(int i=0;i<=dHat;++i) - l[i]=lpj[i]; - outside=0; - return k; - } + for (int i = 0; i <= dHat; ++i) l[i] = lpj[i]; + outside = 0; + return k; } + } -//#define DEBUGGING +// #define DEBUGGING #ifdef DEBUGGING - int err=0; - double dispp=Rd(PP,*p).norme(); - for(int i=0; iTrueNearestVertex(PP); - ffassert(err==0); - } + int err = 0; + double dispp = Rd(PP, *p).norme( ); + for (int i = 0; i < P.N( ); ++i) { + double l = Rd(PP, P[i]).norme( ); + if (l < dispp * (1 - 1e-14)) err++, cout << " bug " << l << " " << dispp << " i " << i << " ip" << ip << " " << dispp - l << endl; + } + if (err) { // relay for debug + p = tree->TrueNearestVertex(PP); + ffassert(err == 0); + } #endif - Vertex **plp = &lp[0]; - long lvp=tree->ListNearestVertex(plp,lp.N(), delta[ip],P[ip]); - HeapSort(plp,lvp ); -// verif ListNearestVertex - + Vertex **plp = &lp[0]; + long lvp = tree->ListNearestVertex(plp, lp.N( ), delta[ip], P[ip]); + HeapSort(plp, lvp); + // verif ListNearestVertex + #ifdef DEBUGGING - { - int err=0; - set lst; - int nnnm=0,nnnp=0; - double unp =(1+1e-14),unm=(1-1e-14); - for(int j=0; j= nnnm); - ffassert(err==0); + { + int err = 0; + set< int > lst; + int nnnm = 0, nnnp = 0; + double unp = (1 + 1e-14), unm = (1 - 1e-14); + for (int j = 0; j < lvp; ++j) lst.insert(lp[j] - p0); + for (int i = 0; i < P.N( ); ++i) { + double l = Rd(P[ip], P[i]).norme( ); + if (l < delta[ip] * unp) nnnp++; + if (l < delta[ip] * unm) nnnm++; + + if ((l < delta[ip] * unp) && (lst.find(i) == lst.end( ))) { + err++; + cout << " bug " << i << " not in set " << endl; + } } + ffassert(lvp <= nnnp && lvp >= nnnm); + ffassert(err == 0); + } #endif - if( verbosity>19) - { - cout << ip << " , " << delta[ip] << " | " << lvp << " : "; - for(int j=0; jlab/Element::ne; - int e = lp[j]->lab%Element::ne; - cout << " "<< k << " "; - // ffassert(i == k || ); - } - cout << endl; + if (verbosity > 19) { + cout << ip << " , " << delta[ip] << " | " << lvp << " : "; + for (int j = 0; j < lvp; ++j) { + int i = lp[j] - p0; + int k = lp[j]->lab / Element::ne; + int e = lp[j]->lab % Element::ne; + cout << " " << k << " "; + // ffassert(i == k || ); } - for(int j=0; jlab/Element::ne; - int e = lp[j]->lab%Element::ne; - if(debug) cout << " -- k = "<< k << " " << e << " " << j << endl; - - const Element & K=(*pTh)[k]; - int I[4]={0,1,2,3}; - int nI =dHat+1; - if( bborder) - { // take just of part of Element .. - nI= Element::nva; - ffassert(nI==BorderElement::RdHat::d+1); - for(int i=0; i< nI;++i) - I[i]=Element::nvadj[e][i]; - } - - - for(int i=0; i< nI;++i) - Q[i]=K[I[i]]; - - double ddeps=Plambla(nI-1,Q,PP,ll);// return une taille ^2, ^4, ^3 suivant la dim nI-1 - R d2 = dist2(nI-1,Q,PP,ll,lpj); - if( dnu > d2) - { - if( nI==2) - deps =ddeps/10000.; - else if (nI==3) - deps = sqrt(ddeps)/10000.; // epaisseur de l'objet au carre 1.100 de - else ffassert(0); - nu = k; - ne= e; - dnu=d2; - - - if( bborder) - { // - for(int i=0;i<=dHat;++i) - dl[i]=0; - for(int i=0;i99) cout << " Find " << k << " " << e << " / " << dnu << endl; + cout << endl; + } + for (int j = 0; j < lvp; ++j) { + nbelement++; + int k = lp[j]->lab / Element::ne; + int e = lp[j]->lab % Element::ne; + if (debug) cout << " -- k = " << k << " " << e << " " << j << endl; + + const Element &K = (*pTh)[k]; + int I[4] = {0, 1, 2, 3}; + int nI = dHat + 1; + if (bborder) { // take just of part of Element .. + nI = Element::nva; + ffassert(nI == BorderElement::RdHat::d + 1); + for (int i = 0; i < nI; ++i) I[i] = Element::nvadj[e][i]; } - ffassert(nu>=0); - outside = dnu < deps ? 0 - : ((dnu< delta[ip]*delta[ip])? 1: 2) ;// 0 in, 1 near, 2 fare ..BofBof .. - for(int i=0; i<= dHat;++i) - l[i]=dl[i]; - - if(debug) cout << " -- out nu "<< nu << " "<< ne << " , " << dnu <<" d_i " << delta[ip] << " : " - << l[1] << " " << l[2] << " "<< outside<< endl; - return nu; + + for (int i = 0; i < nI; ++i) Q[i] = K[I[i]]; + + double ddeps = Plambla(nI - 1, Q, PP, ll); // return une taille ^2, ^4, ^3 suivant la dim nI-1 + R d2 = dist2(nI - 1, Q, PP, ll, lpj); + if (dnu > d2) { + if (nI == 2) + deps = ddeps / 10000.; + else if (nI == 3) + deps = sqrt(ddeps) / 10000.; // epaisseur de l'objet au carre 1.100 de + else + ffassert(0); + nu = k; + ne = e; + dnu = d2; + + if (bborder) { // + for (int i = 0; i <= dHat; ++i) dl[i] = 0; + for (int i = 0; i < nI; ++i) dl[I[i]] = lpj[i]; + } else { + for (int i = 0; i <= dHat; ++i) dl[i] = lpj[i]; + } + } + if (verbosity > 99) cout << " Find " << k << " " << e << " / " << dnu << endl; + } + ffassert(nu >= 0); + outside = dnu < deps ? 0 : ((dnu < delta[ip] * delta[ip]) ? 1 : 2); // 0 in, 1 near, 2 fare ..BofBof .. + for (int i = 0; i <= dHat; ++i) l[i] = dl[i]; + + if (debug) cout << " -- out nu " << nu << " " << ne << " , " << dnu << " d_i " << delta[ip] << " : " << l[1] << " " << l[2] << " " << outside << endl; + return nu; } -template -int TrueBorder(const Mesh &Th,typename Mesh::Vertex *P,double *delta) -{ - typedef typename Mesh::Vertex Vertex; - - typedef typename Mesh::Element Element; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::BorderElement::RdHat RdHat; - static const int d = Rd::d; - static const int dHat = RdHat::d; - - int nv =0; - RdHat GHat(RdHat::diag(1./(dHat+1))); - - for(int be=0; be +int TrueBorder(const Mesh &Th, typename Mesh::Vertex *P, double *delta) { + typedef typename Mesh::Vertex Vertex; + + typedef typename Mesh::Element Element; + typedef typename Mesh::BorderElement BorderElement; + typedef typename Mesh::Rd Rd; + typedef typename Mesh::BorderElement::RdHat RdHat; + static const int d = Rd::d; + static const int dHat = RdHat::d; + + int nv = 0; + RdHat GHat(RdHat::diag(1. / (dHat + 1))); + + for (int be = 0; be < Th.nbe; ++be) { + const BorderElement &E = Th.be(be); + int e, k = Th.BoundaryElement(be, e); { - const BorderElement &E=Th.be(be); - int e,k = Th.BoundaryElement(be,e); - { - int ee=e, kk= Th.ElementAdj(k,ee); - if ( kk >=0 || k != kk) - { - E(GHat); - Rd G(E(GHat)); - double l = 0;// 1.5 to be sure .. FH - for(int i=0; i< BorderElement::nv ;++i) - l = max(l, Rd(G,E[i]).norme2()) ; - delta[nv]=l; - P[nv].lab= Element::ne*k+e;// element and edge - (Rd &) P[nv++]=G; - - - } - } + int ee = e, kk = Th.ElementAdj(k, ee); + if (kk >= 0 || k != kk) { + E(GHat); + Rd G(E(GHat)); + double l = 0; // 1.5 to be sure .. FH + for (int i = 0; i < BorderElement::nv; ++i) l = max(l, Rd(G, E[i]).norme2( )); + delta[nv] = l; + P[nv].lab = Element::ne * k + e; // element and edge + (Rd &)P[nv++] = G; + } } - return nv; + } + return nv; } -inline double CPUtime(){ return ((double) std::clock())/CLOCKS_PER_SEC;} -template -GenericDataFindBoundary::GenericDataFindBoundary(Mesh const * _pTh,int ddebug) -: pTh(_pTh),tree(0),nbfind(0), nbelement(0), P(bborder ? pTh->nbe: pTh->nt),delta(P.N()),lp(0),debug(ddebug) -{ - double t0= CPUtime(); - //cout << " enter in GenericDataFindBoundary"<< endl; - const int nvE= Element::nv; - const int nvB = BorderElement::nv; - const int nvK = bborder ? nvB : nvE; - const Mesh &Th = *pTh; - // extract true Border if d != dHat - // othesize keep all mesh - RdHat GHat(RdHat::diag(1./(dHat+1))); - long ncount=0, mcount=0; - int nv =0; - // warning in case of meshL , bord is points => code bborder stupide.. - if(bborder) - nv = TrueBorder(Th,(Vertex *)P,delta); - else - { // - for(int k=0; k9999) - cout << k << " P " << G << endl; - - } - } - } - - //P.resize(nv); no resize because no copy of vertices ... - delta.resize(nv); - lp.resize(nv); - if(debug>7) gnuplot("dfb0.gp"); - Vertex * P0= &P[0]; - KN d0(delta); - for(int i=0; i< nv;++i) - d0[i]=sqrt(d0[i]); - delta= 0.; - Rd Pn, Px; - Th.BoundingBox(Pn, Px); - double col=0; - tree=new EF23::GTree (&P[0], Pn, Px,nv);// build quadtre - int lvpx=0; - // cout << " next step in GenericDataFindBoundary"<< endl; - long NbQuadTreeBoxSearch=tree->NbQuadTreeBoxSearch,NbVerticesSearch=tree->NbVerticesSearch; - for(int i=0;i9) cout << i << " " << d0[i] << endl; - long nbsg=tree->NbQuadTreeBoxSearch,nvsg=tree->NbVerticesSearch; - int lvp=tree->ListNearestVertex(lp,nv, d0[i]*2.1,P[i]); - if(debug>9) cout <NbVerticesSearch-nvsg << " " << tree->NbQuadTreeBoxSearch-nbsg << " / " << lvp << " " << d0[i] << endl; - lvpx=max(lvp,lvpx); - for(int j=0,k; j9) cout << k << " "<< delta[k] << ", "; - } +inline double CPUtime( ) { return ((double)std::clock( )) / CLOCKS_PER_SEC; } +template< typename Mesh > +GenericDataFindBoundary< Mesh >::GenericDataFindBoundary(Mesh const *_pTh, int ddebug) + : pTh(_pTh), tree(0), nbfind(0), nbelement(0), P(bborder ? pTh->nbe : pTh->nt), delta(P.N( )), lp(0), debug(ddebug) { + double t0 = CPUtime( ); + // cout << " enter in GenericDataFindBoundary"<< endl; + const int nvE = Element::nv; + const int nvB = BorderElement::nv; + const int nvK = bborder ? nvB : nvE; + const Mesh &Th = *pTh; + // extract true Border if d != dHat + // othesize keep all mesh + RdHat GHat(RdHat::diag(1. / (dHat + 1))); + long ncount = 0, mcount = 0; + int nv = 0; + // warning in case of meshL , bord is points => code bborder stupide.. + if (bborder) + nv = TrueBorder(Th, (Vertex *)P, delta); + else { // + for (int k = 0; k < Th.nt; ++k) { + const Element &K = Th[k]; + { + Rd G(K(GHat)); + double l = 0; // 1.5 to be sur .. FH + for (int i = 0; i < Element::nv; ++i) l = max(l, Rd(G, K[i]).norme2( )); + delta[nv] = l; + P[nv].lab = Element::ne * k; // element and edge + (Rd &)P[nv++] = G; + if (verbosity > 9999) cout << k << " P " << G << endl; + } } - if(debug>9) - for(int i=0;i5) - gnuplot("dfb1.gp"); - if(verbosity>4) - { - cout << " ** BuildDataFindBoundary " << nv << " " << delta.max() << " " << delta.sum()/nv << " " << delta.min() << endl; - cout << " count "<< mcount << " / " <NbQuadTreeBoxSearch - NbQuadTreeBoxSearch - << " v " << tree->NbVerticesSearch-NbVerticesSearch << " CPU =" << CPUtime()-t0 << endl; + } + + // P.resize(nv); no resize because no copy of vertices ... + delta.resize(nv); + lp.resize(nv); + if (debug > 7) gnuplot("dfb0.gp"); + Vertex *P0 = &P[0]; + KN< double > d0(delta); + for (int i = 0; i < nv; ++i) d0[i] = sqrt(d0[i]); + delta = 0.; + Rd Pn, Px; + Th.BoundingBox(Pn, Px); + double col = 0; + tree = new EF23::GTree< Vertex >(&P[0], Pn, Px, nv); // build quadtre + int lvpx = 0; + // cout << " next step in GenericDataFindBoundary"<< endl; + long NbQuadTreeBoxSearch = tree->NbQuadTreeBoxSearch, NbVerticesSearch = tree->NbVerticesSearch; + for (int i = 0; i < nv; ++i) { + ncount++; + if (debug > 9) cout << i << " " << d0[i] << endl; + long nbsg = tree->NbQuadTreeBoxSearch, nvsg = tree->NbVerticesSearch; + int lvp = tree->ListNearestVertex(lp, nv, d0[i] * 2.1, P[i]); + if (debug > 9) cout << i << " " << tree->NbVerticesSearch - nvsg << " " << tree->NbQuadTreeBoxSearch - nbsg << " / " << lvp << " " << d0[i] << endl; + lvpx = max(lvp, lvpx); + for (int j = 0, k; j < lvp; ++j) { + mcount++; + k = lp[j] - P0; + // double dij = Rd(P[i],*lp[j]).norme(); + // warning must be Proof FH. + delta[k] = max(delta[k], d0[i] + d0[k]); + delta[i] = max(delta[i], d0[i] + d0[k]); + + if (debug > 9) cout << k << " " << delta[k] << ", "; } + } + if (debug > 9) + for (int i = 0; i < nv; ++i) cout << i << " " << d0[i] << " " << delta[i] << endl; + if (debug > 5) gnuplot("dfb1.gp"); + if (verbosity > 4) { + cout << " ** BuildDataFindBoundary " << nv << " " << delta.max( ) << " " << delta.sum( ) / nv << " " << delta.min( ) << endl; + cout << " count " << mcount << " / " << ncount << " ratio " << (double)mcount / max(ncount, 1L) << " max lvp " << lvpx << " gtree search box " + << tree->NbQuadTreeBoxSearch - NbQuadTreeBoxSearch << " v " << tree->NbVerticesSearch - NbVerticesSearch << " CPU =" << CPUtime( ) - t0 << endl; + } } // Bof Bof pas sur du tout. /* @@ -1632,11 +1414,11 @@ GenericDataFindBoundary::GenericDataFindBoundary(Mesh const * _pTh,int dde dfb=new DataFindBoundary(this);//,count++==0?9:0); dfb->debug=0; } - + } */ -template class GenericDataFindBoundary; -template class GenericDataFindBoundary; -template class GenericDataFindBoundary; -template class GenericDataFindBoundary; -template class GenericDataFindBoundary; +template class GenericDataFindBoundary< Fem2D::MeshS::GMesh >; +template class GenericDataFindBoundary< Fem2D::Mesh3::GMesh >; +template class GenericDataFindBoundary< Fem2D::Mesh2::GMesh >; +template class GenericDataFindBoundary< Fem2D::Mesh1::GMesh >; +template class GenericDataFindBoundary< Fem2D::MeshL::GMesh >; diff --git a/src/femlib/GQuadTree.hpp b/src/femlib/GQuadTree.hpp index cdb2da908..9cca025be 100644 --- a/src/femlib/GQuadTree.hpp +++ b/src/femlib/GQuadTree.hpp @@ -2,33 +2,33 @@ // ORIG-DATE: Jan 2008 // -*- Mode : c++ -*- // -// SUMMARY : Generic Tree header (binairy, Quad, Oct) -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE +// SUMMARY : Generic Tree header (binairy, Quad, Oct) +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curi, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Thank to the ARN () FF2A3 grant - ref:ANR-07-CIS7-002-01 + ref:ANR-07-CIS7-002-01 */ namespace Fem2D { @@ -39,225 +39,226 @@ namespace EF23 { using Fem2D::R; static const int MaxDeep = 30; - typedef int IntQuad; - typedef long long Int8; - static const IntQuad MaxISize = ( 1L << MaxDeep); - static const IntQuad MaxISize1 = MaxISize-1; -class Z0 { -public: - // static bool INTER_SEG1d(int a,int b,int x,int y) { return (((y) > (a)) && ((x) <(b)));} - static bool INTER_SEG1dn(int a,int b,int x0,int d) { - int x= x0-d, y = x0+d; - if(verbosity>999 && y < x0 ) cout << "overflow ?? inter_1dn" << " ] "<< a << "," << b << "[ inter ] " << x << "," << y << "[\n"; - if(y<0) y = std::numeric_limits::max();// overflow in .. - - return (((y) > (a)) && ((x) <(b)));} - -}; - class Z1 : public Z0 { public: + typedef int IntQuad; + typedef long long Int8; + static const IntQuad MaxISize = (1L << MaxDeep); + static const IntQuad MaxISize1 = MaxISize - 1; + class Z0 { + public: + // static bool INTER_SEG1d(int a,int b,int x,int y) { return (((y) > (a)) && ((x) <(b)));} + static bool INTER_SEG1dn(int a, int b, int x0, int d) { + int x = x0 - d, y = x0 + d; + if (verbosity > 999 && y < x0) cout << "overflow ?? inter_1dn" << " ] " << a << "," << b << "[ inter ] " << x << "," << y << "[\n"; + if (y < 0) y = std::numeric_limits< int >::max( ); // overflow in .. + + return (((y) > (a)) && ((x) < (b))); + } + }; + class Z1 : public Z0 { + public: // static bool INTER_SEG1d(int a,int b,int x,int y) { return (((y) > (a)) && ((x) <(b)));} int x; - Z1():x(0){} + Z1( ) : x(0) {} Z1(R1 P) : x((int)P.x) {} - Z1( int i) : x(i){} - Z1(const Z1 &pp,int k,int l): x(pp.x+(( k&1) ? l : 0)) {} - void Add(int k,int l) { x+= (( k&1) ? l : 0) ;} - Z1(const Z1 &A,const Z1 &B) : x(B.x-A.x){} - - int Case(int l) const { return ( x & l)? 1 : 0 ;} - int norm() const { return abs(x);} - Int8 norm2() const { return (Int8) x* (Int8) x;} - void Bound() { x = max(min(x,MaxISize1),0);} - - bool less(Z1 h) const { return abs(x) bc << " " - //<< sb->be << " " <bcbe)) - sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb); - - assert(sb && (sb->bc->n == 0)); - NbQuadTreeBox++; - return sb->bc++; - } - ~GTree(); - GTree(Vertex * v,Rd Pmin,Rd Pmax,int nbv); - GTree(); - template - friend ostream& operator <<(ostream& f, const GTree & qt); - // add FH mars 2020 , for new search .. FH... - int ListNearestVertex(Vertex **lnv,int nvn,double delta,Rd P) - { int hx = (int) (coef*delta); - hx = hx>0 ? hx:1; // bof bof .... - return ListNearestVertex(lnv,nvn,hx,RdtoZd(P));} - Vertex * TrueNearestVertex(Zd i2) {return NearestVertex(i2,true);} - int ListNearestVertex(Vertex **lnv,int nlvnx,int dh,Zd xyi); - - - Vertex * TrueNearestVertex(const Rd & P) { - return TrueNearestVertex(RdtoZd(P));} + long NbQuadTreeBoxSearch, NbVerticesSearch, NbSearch; + long NbQuadTreeBox, NbVertices; + + Rd cMin, cMax; // box of QuadTree + R coef; // + + Zd RdtoZd(const Rd &P) const { return Zd((Minc(Maxc(P, cMin), cMax) - cMin) * coef); } + Zd VtoZd(const Vertex *v) const { return RdtoZd((const Rd &)*v); } + Zd VtoZd(const Vertex &v) const { return RdtoZd((const Rd &)v); } + + Rd ZdtoRd(const Zd &I) const { return ((Rd)I) / coef + cMin; } + + Vertex *NearestVertex(const Rd &P, bool trueNearest = false) { return NearestVertex(RdtoZd(P), trueNearest); } // XtoI(P.x),YtoJ(P.y));} + Vertex *NearestVertexWithNormal(const Rd &P); + Vertex *NearestVertex(Zd i2, bool trueNearest = false); + + Vertex *ToClose(const Rd &, R, Zd, bool nearest = false); + Vertex *ToClose(const Rd &P, R delta, bool nearest = false) { + int hx = (int)(coef * delta); + hx = hx > 0 ? hx : 1; // bof bof .... + ffassert(hx > 0); // bug if too small dec. 2019 FH. + // if(verbosity > 5 ) cout << "hx=" << hx << " coef=" << coef << endl; + return ToClose(P, delta, Zd(hx), nearest); + } + int SizeOf( ) const { return sizeof(GTree) + sb->SizeOf( ); } + + void Add(Vertex &w); + + QuadTreeBox *NewQuadTreeBox( ) { + /// cout << "NewQuadTreeBox " << sb << " " << sb->bc << " " + //<< sb->be << " " <bc < sb->be)) sb = new StorageQuadTreeBox(lenStorageQuadTreeBox, sb); + + assert(sb && (sb->bc->n == 0)); + NbQuadTreeBox++; + return sb->bc++; + } + ~GTree( ); + GTree(Vertex *v, Rd Pmin, Rd Pmax, int nbv); + GTree( ); + template< class V > + friend ostream &operator<<(ostream &f, const GTree< V > &qt); + // add FH mars 2020 , for new search .. FH... + int ListNearestVertex(Vertex **lnv, int nvn, double delta, Rd P) { + int hx = (int)(coef * delta); + hx = hx > 0 ? hx : 1; // bof bof .... + return ListNearestVertex(lnv, nvn, hx, RdtoZd(P)); + } + Vertex *TrueNearestVertex(Zd i2) { return NearestVertex(i2, true); } + int ListNearestVertex(Vertex **lnv, int nlvnx, int dh, Zd xyi); + + Vertex *TrueNearestVertex(const Rd &P) { return TrueNearestVertex(RdtoZd(P)); } }; - - template - const typename Mesh::Element * Find(const Mesh & Th, - GTree *quadtree, - typename Mesh::Rd P, - typename Mesh::RdHat & Phat, - bool & outside, - const typename Mesh::Element * tstart); - - -} // name space + template< class Mesh > + const typename Mesh::Element *Find(const Mesh &Th, GTree< typename Mesh::Vertex > *quadtree, typename Mesh::Rd P, typename Mesh::RdHat &Phat, bool &outside, const typename Mesh::Element *tstart); + +} // namespace EF23 diff --git a/src/femlib/GenericMesh.hpp b/src/femlib/GenericMesh.hpp index 0089c8542..0486c107d 100644 --- a/src/femlib/GenericMesh.hpp +++ b/src/femlib/GenericMesh.hpp @@ -40,8 +40,8 @@ // la regle de programmation 3 extern long verbosity; extern bool lockOrientation; -extern long searchMethod; //pichon -#include // Add J. Morice +extern long searchMethod; // pichon +#include // Add J. Morice #include "cassert" #include "assertion.hpp" @@ -51,353 +51,402 @@ extern long searchMethod; //pichon #include "RefCounter.hpp" - using namespace ::std; - #include "Serialize.hpp" #include "GQuadTree.hpp" #include "DataFindBoundary.hpp" // definition R -namespace Fem2D { +namespace Fem2D { #include "R3.hpp" #include "Label.hpp" #include "HashTable.hpp" -inline int randwalk(int ncas) -{ - const long long a = 314125421, m= 777777; - static long xn = 19999999%m; - if(ncas <=0) xn=19999999%m; - long long xxn = xn; - xn = a*xxn%m +1; - xn %= m; - return (xn*ncas)/m; -} + inline int randwalk(int ncas) { + const long long a = 314125421, m = 777777; + static long xn = 19999999 % m; + if (ncas <= 0) xn = 19999999 % m; + long long xxn = xn; + xn = a * xxn % m + 1; + xn %= m; + return (xn * ncas) / m; + } - const double UnSetMesure=-1e+200; + const double UnSetMesure = -1e+200; -inline int maxdfon(const int *dfon){ return max(max(dfon[0],dfon[1]),max(dfon[2],dfon[3]));} + inline int maxdfon(const int *dfon) { return max(max(dfon[0], dfon[1]), max(dfon[2], dfon[3])); } // struct R {}; -template struct typeRd {typedef R0 Rd;}; -template<> struct typeRd<1> {typedef R1 Rd;}; -template<> struct typeRd<2> {typedef R2 Rd;}; -template<> struct typeRd<3> {typedef R3 Rd;}; - -const int NbTypeItemElement = 4; - -const int TypeVertex =0; -const int TypeEdge =1; -const int TypeFace =2; -const int TypeVolume =3; - // add FH ... april 2009 for peroidic Boundary Condition. - // gestion of the permutation 1,2,3 - // here just user order - // NumPerm : number of the permutation - // p permutation n= NumPerm(p) - // p1 permutation inv n1 = NumPerm(p1) - // p1[p[i]]=i - // => n1 number of the perm / p[p1[i]] increase <=> i - // SetNumPerm: set the permutation form number - - template inline int NumPerm(int *) {ffassert(0);} - template inline int NumPerm1(int *) {ffassert(0);} // num perm inverse - template<> inline int NumPerm<1>(int *) { return 0;} - template<> inline int NumPerm1<1>(int *) { return 0;} - template<> inline int NumPerm<2>(int *p) { return p[0] > p[1] ;} - template<> inline int NumPerm1<2>(int *p) { return p[0] > p[1] ;} - - template<> inline int NumPerm1<3>(int *p) { - // signe + depart*2 - int k=0,i0=0,i1=1,i2=2,j[3]; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; - if(p[i1]> p[i2]) swap(i1,i2),k +=1; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; - assert(p[i0] < p[i1] && p[i1] < p[i2]); - // j is inv of i1,i2,i3 - j[i0]=0;j[i1]=1;j[i2]=2; - return (k%2)+i0*2; // signe + depart*2 - } - - template<> inline int NumPerm<3>(int *p) { - // signe + depart*2 - int k=0,i0=0,i1=1,i2=2,j[3]; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; - if(p[i1]> p[i2]) swap(i1,i2),k +=1; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; - assert(p[i0] < p[i1] && p[i1] < p[i2]); - // j is inv of i1,i2,i3 - j[i0]=0;j[i1]=1;j[i2]=2; - return (k%2)+ ((j[0]+3)%3)*2; // signe + depart*2 - } - // build de permutation - template inline void SetNumPerm(int n,int *p) { ffassert(0); }// a error} - template inline void SetNumPerm1(int n,int *p) { ffassert(0); }// a error} - - template<> inline void SetNumPerm<1>(int ,int *p) { p[0]=0;} // a error} - template<> inline void SetNumPerm<2>(int n,int *p) { p[0]=n;p[1]=1-n;} // a error} - - // build perm inverse - template<> inline void SetNumPerm1<1>(int ,int *p) { p[0]=0;} // a error} - template<> inline void SetNumPerm1<2>(int n,int *p) { p[0]=n;p[1]=1-n;} // a error} - - template<> inline void SetNumPerm1<3>(int n,int *p) { - int i=n/2, j= n%2 ? 2:1; - p[i]=0;p[(i+j)%3]=1;p[(i+j+j)%3]=2; - assert( n == NumPerm1<3>(p)); - } - - template<> inline void SetNumPerm<3>(int n,int *p) { - int i=n/2, j= n%2 ? 2:1; - p[0]=i;p[1]=(i+j)%3;p[2]=(i+j+j)%3; - assert( n == NumPerm<3>(p)); - } - // --- end add periodic - -class DataFENodeDF { - int * nbref; // pointer on common ref counter -public: - int ndfon[4]; - const int NbOfElements; - const int NbOfNodes; - const int NbOfDF; - const int * const NodesOfElement; - const int * const FirstDfOfNodeData; - const int * const FirstNodeOfElement; // 0 - const int MaxNbNodePerElement; - const int MaxNbDFPerElement; - const int MaxNbDFPerNode; - int ndfonVertex()const {return ndfon[0];} - int ndfonEdge()const {return ndfon[1];} - int ndfonFace()const {return ndfon[2];} - int ndfonTet()const {return ndfon[3];} - - DataFENodeDF(const DataFENodeDF & m) - : - nbref( m.nbref ) , - NbOfElements(m.NbOfElements), - NbOfNodes(m.NbOfNodes), - NbOfDF(m.NbOfDF), - NodesOfElement(m.NodesOfElement), - FirstDfOfNodeData(m.FirstDfOfNodeData), - FirstNodeOfElement(m.FirstNodeOfElement), - MaxNbNodePerElement(m.MaxNbNodePerElement), - MaxNbDFPerElement(m.MaxNbDFPerElement) , - MaxNbDFPerNode(maxdfon(m.ndfon)) - { - for(int i=0;i + struct typeRd { + typedef R0 Rd; + }; + template<> + struct typeRd< 1 > { + typedef R1 Rd; + }; + template<> + struct typeRd< 2 > { + typedef R2 Rd; + }; + template<> + struct typeRd< 3 > { + typedef R3 Rd; + }; + + const int NbTypeItemElement = 4; + + const int TypeVertex = 0; + const int TypeEdge = 1; + const int TypeFace = 2; + const int TypeVolume = 3; + // add FH ... april 2009 for peroidic Boundary Condition. + // gestion of the permutation 1,2,3 + // here just user order + // NumPerm : number of the permutation + // p permutation n= NumPerm(p) + // p1 permutation inv n1 = NumPerm(p1) + // p1[p[i]]=i + // => n1 number of the perm / p[p1[i]] increase <=> i + // SetNumPerm: set the permutation form number + + template< int d > + inline int NumPerm(int *) { + ffassert(0); } - ~DataFENodeDF() - { - if ((*nbref)==0) // remove if nbref ==0 - { - delete nbref; - delete [] NodesOfElement; - delete [] FirstDfOfNodeData; - delete [] FirstNodeOfElement; - } - else (*nbref)--; + template< int d > + inline int NumPerm1(int *) { + ffassert(0); + } // num perm inverse + template<> + inline int NumPerm< 1 >(int *) { + return 0; } -private: - void operator=(const DataFENodeDF &) ; - -}; - -template -class GenericVertex : public Rn,public Label -{ - - template - friend class GenericMesh; - friend inline ostream& operator <<(ostream& f, const GenericVertex & v ) - { f << (const Rn &) v << ' ' << (const Label &) v ; return f; } - friend inline istream& operator >> (istream& f, GenericVertex & v ) - { f >> (Rn &) v >> (Label &) v ; return f; } - - Rn *normal; // pointeur sur la normal exterieur pour filtre des points de departs - -public: - typedef Rn Rd; - static const int d=Rd::d; - GenericVertex() : Rd(),Label(),normal(0) {}; - GenericVertex(const Rd & P,int r=0): Rd(P),Label(r),normal(0){} - - void SetNormal(Rd *&n,const Rd & N) - { if (normal) { - Rd NN=*normal+N; - *normal= NN/NN.norme(); } - else *(normal=n++)=N;} - - Rd Ne() const {return normal ? *normal: Rd();} - bool ninside(const Rd & P) const - { - return normal? (Rd(*this,P),*normal)<=0: true; + template<> + inline int NumPerm1< 1 >(int *) { + return 0; + } + template<> + inline int NumPerm< 2 >(int *p) { + return p[0] > p[1]; + } + template<> + inline int NumPerm1< 2 >(int *p) { + return p[0] > p[1]; } -private: // pas de copie pour ne pas prendre l'adresse - GenericVertex(const GenericVertex &); - void operator=(const GenericVertex &); - -}; - template inline R1 ExtNormal( GenericVertex *const v[2],int const f[1]) { static_assert ( d== 1 ,"dim =1"); return f[0]==0 ? R1(-1):R1(1); } - template inline R2 ExtNormal( GenericVertex *const v[3],int const f[2]) { static_assert ( d== 2 ,"dim=2"); return R2(*v[f[1]],*v[f[0]]).perp(); } - // correct signe N in 3d mai 2009 (FH) - template inline R3 ExtNormal( GenericVertex *const v[4],int const f[3]) { static_assert ( d== 3 ,"dim=3"); return R3(*v[f[0]],*v[f[2]])^R3(*v[f[0]],*v[f[1]]) ; } - template<> // pour axel exterior Normal of surface .. - inline R3 ExtNormal<2>( GenericVertex *const v[3],int const f[2]) {return R3(*v[f[0]],*v[f[1]])^(R3(*v[0],*v[1])^R3(*v[0],*v[2])); }// module 2 aire*l template<> - inline R3 ExtNormal<1>( GenericVertex *const v[2],int const f[1]) { - R3 Nn; - if(f[0]==0) Nn=R3(*v[1],*v[0]);//-R3(*v[0]); - else if(f[0]==1) Nn=R3(*v[0],*v[1]);//+R3(*v[1]); - if (verbosity>99) cout << "\n( ExtNormal<1> " << Nn << " v0 " << *v[0] << " v1 " << *v[1]<< " 0/1: " << f[0] << ")" << endl; - return Nn; + inline int NumPerm1< 3 >(int *p) { + // signe + depart*2 + int k = 0, i0 = 0, i1 = 1, i2 = 2, j[3]; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; + if (p[i1] > p[i2]) swap(i1, i2), k += 1; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; + assert(p[i0] < p[i1] && p[i1] < p[i2]); + // j is inv of i1,i2,i3 + j[i0] = 0; + j[i1] = 1; + j[i2] = 2; + return (k % 2) + i0 * 2; // signe + depart*2 } - // Clever the orientation in case of only 1 vertex april 2019 (Hard to find !!!!! FH and PHT) - template struct SwapOrient { static void SwapO(V **w){swap(w[0],w[1]);}} ; - template struct SwapOrient<1,V> { static void SwapO(V **){}} ; - - -template -class GenericElement: public Label { -public: - typedef typename Data::V Vertex; - typedef typename Data::V::Rd Rd; - typedef typename Data::RdHat RdHat;// for parametrization - typedef typename Data::RdHatBord RdHatBord;// for parametrization - - typedef typename Rd::R R; - - static const int nv=Data::NbOfVertices; // nb of vertices - static const int ne=Data::NbOfEdges; // nb of edges - static const int nf=Data::NbOfFaces; // nb of faces - static const int nt=Data::NT; // nb of tets - static const int nitem=nv+ne+nf+nt; - static const int nva=Data::NbOfVertexOnHyperFace; - static const int nea=Data::NbOfAdjElem; - static const int d=Rd::d; - static const int (* const nvedge)[2] ;// - static const int (* const nvface)[3] ;// - static const int (* const onWhatBorder)[nitem] ;// - - static const int (* const nvadj)[nva] ;// - static const int nitemdim[4]; // nv,ne,nf,nt - - // variable prive -private: - Vertex *vertices[nv]; // an array of 3 pointer to vertex - R mes; -public: - GenericElement() {} - const Vertex & operator[](int i) const { - ASSERTION(i>=0 && i =0 && i 0 ); - return *this; + + template<> + inline int NumPerm< 3 >(int *p) { + // signe + depart*2 + int k = 0, i0 = 0, i1 = 1, i2 = 2, j[3]; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; + if (p[i1] > p[i2]) swap(i1, i2), k += 1; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; + assert(p[i0] < p[i1] && p[i1] < p[i2]); + // j is inv of i1,i2,i3 + j[i0] = 0; + j[i1] = 1; + j[i2] = 2; + return (k % 2) + ((j[0] + 3) % 3) * 2; // signe + depart*2 } + // build de permutation + template< int d > + inline void SetNumPerm(int n, int *p) { + ffassert(0); + } // a error} + template< int d > + inline void SetNumPerm1(int n, int *p) { + ffassert(0); + } // a error} - void changeOrientation() { SwapOrient::SwapO(vertices);} + template<> + inline void SetNumPerm< 1 >(int, int *p) { + p[0] = 0; + } // a error} + template<> + inline void SetNumPerm< 2 >(int n, int *p) { + p[0] = n; + p[1] = 1 - n; + } // a error} - istream & Read1(istream & f,Vertex * v0,int n) - { - int iv[nv]={},ir,err=0; - for (int i=0;i + inline void SetNumPerm1< 1 >(int, int *p) { + p[0] = 0; + } // a error} + template<> + inline void SetNumPerm1< 2 >(int n, int *p) { + p[0] = n; + p[1] = 1 - n; + } // a error} + + template<> + inline void SetNumPerm1< 3 >(int n, int *p) { + int i = n / 2, j = n % 2 ? 2 : 1; + p[i] = 0; + p[(i + j) % 3] = 1; + p[(i + j + j) % 3] = 2; + assert(n == NumPerm1< 3 >(p)); + } + + template<> + inline void SetNumPerm< 3 >(int n, int *p) { + int i = n / 2, j = n % 2 ? 2 : 1; + p[0] = i; + p[1] = (i + j) % 3; + p[2] = (i + j + j) % 3; + assert(n == NumPerm< 3 >(p)); + } + // --- end add periodic + + class DataFENodeDF { + int *nbref; // pointer on common ref counter + public: + int ndfon[4]; + const int NbOfElements; + const int NbOfNodes; + const int NbOfDF; + const int *const NodesOfElement; + const int *const FirstDfOfNodeData; + const int *const FirstNodeOfElement; // 0 + const int MaxNbNodePerElement; + const int MaxNbDFPerElement; + const int MaxNbDFPerNode; + int ndfonVertex( ) const { return ndfon[0]; } + int ndfonEdge( ) const { return ndfon[1]; } + int ndfonFace( ) const { return ndfon[2]; } + int ndfonTet( ) const { return ndfon[3]; } + + DataFENodeDF(const DataFENodeDF &m) + : nbref(m.nbref), NbOfElements(m.NbOfElements), NbOfNodes(m.NbOfNodes), NbOfDF(m.NbOfDF), NodesOfElement(m.NodesOfElement), FirstDfOfNodeData(m.FirstDfOfNodeData), + FirstNodeOfElement(m.FirstNodeOfElement), MaxNbNodePerElement(m.MaxNbNodePerElement), MaxNbDFPerElement(m.MaxNbDFPerElement), MaxNbDFPerNode(maxdfon(m.ndfon)) { + for (int i = 0; i < NbTypeItemElement; ++i) ndfon[i] = m.ndfon[i]; + (*nbref)++; // add one to the ref counter + } + DataFENodeDF(int andfon[NbTypeItemElement], int aNbOfElements, int aNbOfNodes, int aNbOfDF, const int *aNodesOfElement, const int *aFirstDfOfNodeData, int aMaxNbNodePerElement, + int aMaxNbDFPerElement) + : nbref(new int(0)), // new ref counter + NbOfElements(aNbOfElements), NbOfNodes(aNbOfNodes), NbOfDF(aNbOfDF), NodesOfElement(aNodesOfElement), FirstDfOfNodeData(aFirstDfOfNodeData), FirstNodeOfElement(0), + MaxNbNodePerElement(aMaxNbNodePerElement), MaxNbDFPerElement(aMaxNbDFPerElement), MaxNbDFPerNode(maxdfon(andfon)) { + for (int i = 0; i < NbTypeItemElement; ++i) ndfon[i] = andfon[i]; + } + ~DataFENodeDF( ) { + if ((*nbref) == 0) // remove if nbref ==0 { - f >> iv[i]; - iv[i]--; - if ( ! (iv[i]>=0 && iv[i] + class GenericVertex : public Rn, public Label { + + template< typename T, typename B, typename V > + friend class GenericMesh; + friend inline ostream &operator<<(ostream &f, const GenericVertex &v) { + f << (const Rn &)v << ' ' << (const Label &)v; + return f; + } + friend inline istream &operator>>(istream &f, GenericVertex &v) { + f >> (Rn &)v >> (Label &)v; + return f; + } + + Rn *normal; // pointeur sur la normal exterieur pour filtre des points de departs + + public: + typedef Rn Rd; + static const int d = Rd::d; + GenericVertex( ) : Rd( ), Label( ), normal(0) {}; + GenericVertex(const Rd &P, int r = 0) : Rd(P), Label(r), normal(0) {} + + void SetNormal(Rd *&n, const Rd &N) { + if (normal) { + Rd NN = *normal + N; + *normal = NN / NN.norme( ); + } else + *(normal = n++) = N; + } + + Rd Ne( ) const { return normal ? *normal : Rd( ); } + bool ninside(const Rd &P) const { return normal ? (Rd(*this, P), *normal) <= 0 : true; } + + private: // pas de copie pour ne pas prendre l'adresse + GenericVertex(const GenericVertex &); + void operator=(const GenericVertex &); + }; + template< int d > + inline R1 ExtNormal(GenericVertex< R1 > *const v[2], int const f[1]) { + static_assert(d == 1, "dim =1"); + return f[0] == 0 ? R1(-1) : R1(1); + } + template< int d > + inline R2 ExtNormal(GenericVertex< R2 > *const v[3], int const f[2]) { + static_assert(d == 2, "dim=2"); + return R2(*v[f[1]], *v[f[0]]).perp( ); + } + // correct signe N in 3d mai 2009 (FH) + template< int d > + inline R3 ExtNormal(GenericVertex< R3 > *const v[4], int const f[3]) { + static_assert(d == 3, "dim=3"); + return R3(*v[f[0]], *v[f[2]]) ^ R3(*v[f[0]], *v[f[1]]); + } + template<> // pour axel exterior Normal of surface .. + inline R3 ExtNormal< 2 >(GenericVertex< R3 > *const v[3], int const f[2]) { + return R3(*v[f[0]], *v[f[1]]) ^ (R3(*v[0], *v[1]) ^ R3(*v[0], *v[2])); + } // module 2 aire*l + template<> + inline R3 ExtNormal< 1 >(GenericVertex< R3 > *const v[2], int const f[1]) { + R3 Nn; + if (f[0] == 0) + Nn = R3(*v[1], *v[0]); //-R3(*v[0]); + else if (f[0] == 1) + Nn = R3(*v[0], *v[1]); //+R3(*v[1]); + if (verbosity > 99) cout << "\n( ExtNormal<1> " << Nn << " v0 " << *v[0] << " v1 " << *v[1] << " 0/1: " << f[0] << ")" << endl; + return Nn; + } + // Clever the orientation in case of only 1 vertex april 2019 (Hard to find !!!!! FH and PHT) + template< int NN, typename V > + struct SwapOrient { + static void SwapO(V **w) { swap(w[0], w[1]); } + }; + template< typename V > + struct SwapOrient< 1, V > { + static void SwapO(V **) {} + }; + + template< typename Data > + class GenericElement : public Label { + public: + typedef typename Data::V Vertex; + typedef typename Data::V::Rd Rd; + typedef typename Data::RdHat RdHat; // for parametrization + typedef typename Data::RdHatBord RdHatBord; // for parametrization + + typedef typename Rd::R R; + + static const int nv = Data::NbOfVertices; // nb of vertices + static const int ne = Data::NbOfEdges; // nb of edges + static const int nf = Data::NbOfFaces; // nb of faces + static const int nt = Data::NT; // nb of tets + static const int nitem = nv + ne + nf + nt; + static const int nva = Data::NbOfVertexOnHyperFace; + static const int nea = Data::NbOfAdjElem; + static const int d = Rd::d; + static const int (*const nvedge)[2]; // + static const int (*const nvface)[3]; // + static const int (*const onWhatBorder)[nitem]; // + + static const int (*const nvadj)[nva]; // + static const int nitemdim[4]; // nv,ne,nf,nt + + // variable prive + private: + Vertex *vertices[nv]; // an array of 3 pointer to vertex + R mes; + + public: + GenericElement( ) {} + const Vertex &operator[](int i) const { + ASSERTION(i >= 0 && i < nv); + return *vertices[i]; + } // to see triangle as a array of vertex + + Vertex &operator[](int i) { + ASSERTION(i >= 0 && i < nv); + return *vertices[i]; + } // to see triangle as a array of vertex + + const Vertex &at(int i) const { return *vertices[i]; } // to see triangle as a array of vert + + Vertex &at(int i) { return *vertices[i]; } // to see triangle as a array of vert + + GenericElement &set(Vertex *v0, int *iv, int r, double mss = UnSetMesure) { + for (int i = 0; i < nv; ++i) vertices[i] = v0 + iv[i]; + mes = (mss != UnSetMesure) ? mss : Data::mesure(vertices); + lab = r; + assert((RdHat::d != Rd::d) || mes > 0); + return *this; + } + + void changeOrientation( ) { SwapOrient< nv, Vertex >::SwapO(vertices); } + + istream &Read1(istream &f, Vertex *v0, int n) { + int iv[nv] = { }, ir, err = 0; + for (int i = 0; i < nv; ++i) { + f >> iv[i]; + iv[i]--; + if (!(iv[i] >= 0 && iv[i] < n)) err++; } - f >> ir; - if(err || ! f.good() ) - { - cerr << " Erreur GenericElement::Read1 " << nv << " " << n << " : " ; - for (int j=0;j> ir; + if (err || !f.good( )) { + cerr << " Erreur GenericElement::Read1 " << nv << " " << n << " : "; + for (int j = 0; j < nv; ++j) cerr << iv[j] << " "; + cerr << " , " << ir << endl; + abort( ); } - set(v0,iv,ir); - return f; - } + set(v0, iv, ir); + return f; + } - Rd Edge(int i) const {ASSERTION(i>=0 && i = 0 && i < ne); + return Rd(at(nvedge[i][0]), at(nvedge[i][1])); + } // opposite edge vertex i - Rd N(int i) const { return ExtNormal (vertices,nvadj[i]);} - RdHat PBord(int i,RdHatBord P) const { return Data::PBord(nvadj[i],P);} // Correction FH mars 2019 For Axel + Rd N(int i) const { return ExtNormal< RdHat::d >(vertices, nvadj[i]); } + RdHat PBord(int i, RdHatBord P) const { return Data::PBord(nvadj[i], P); } // Correction FH mars 2019 For Axel - Rd operator()(const RdHat & Phat) const { - Rd r= (1.-Phat.sum())*(*(Rd*) vertices[0]); - for (int i=1;if[1]) fo = -fo,Exchange(f[0],f[1]); - if(f[1]>f[2]) { fo = -fo,Exchange(f[1],f[2]); - if(f[0]>f[1]) fo = -fo,Exchange(f[0],f[1]); } - return fo; - } - - int facePermutation(int i) const - { // change not return number in [0,6[ 24 march 2020 + const Vertex *vb[nva]; + for (int i = 0; i < nva; ++i) vb[i] = &at(nvadj[i][i]); + + return mesurebord(nva, vb); + } + int faceOrient(int i) const { // def the permutatution of orient the face + int fo = 1; + const Vertex *f[3] = {&at(nvface[i][0]), &at(nvface[i][1]), &at(nvface[i][2])}; + if (f[0] > f[1]) fo = -fo, Exchange(f[0], f[1]); + if (f[1] > f[2]) { + fo = -fo, Exchange(f[1], f[2]); + if (f[0] > f[1]) fo = -fo, Exchange(f[0], f[1]); + } + return fo; + } + + int facePermutation(int i) const { // change not return number in [0,6[ 24 march 2020 // def the permutatution of orient the face /* - + // change to be compatible to SetNumPerm code .. int fo =0; const Vertex * f[3]={&at(nvface[i][0]), &at(nvface[i][1]), &at(nvface[i][2])}; @@ -406,887 +455,821 @@ class GenericElement: public Label { if(f[0]>f[1]) fo+=4,Exchange(f[0],f[1]); } return fo; */ - const Vertex * p[3]={&at(nvface[i][0]), &at(nvface[i][1]), &at(nvface[i][2])}; + const Vertex *p[3] = {&at(nvface[i][0]), &at(nvface[i][1]), &at(nvface[i][2])}; // signe + depart*2 - int k=0,i0=0,i1=1,i2=2,j[3]; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; - if(p[i1]> p[i2]) swap(i1,i2),k +=1; - if(p[i0]> p[i1]) swap(i0,i1),k +=1; + int k = 0, i0 = 0, i1 = 1, i2 = 2, j[3]; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; + if (p[i1] > p[i2]) swap(i1, i2), k += 1; + if (p[i0] > p[i1]) swap(i0, i1), k += 1; assert(p[i0] < p[i1] && p[i1] < p[i2]); - return (k%2)+i0*2; // signe + depart*2 + return (k % 2) + i0 * 2; // signe + depart*2 + } - - - } + int EdgeOrientation(int i) const { return 2 * (&at(nvedge[i][0]) < &at(nvedge[i][1])) - 1; } // return -1 or 1 FH: Change jan 2018 - int EdgeOrientation(int i) const - { return 2*(&at(nvedge[i][0]) < &at(nvedge[i][1]))-1;}// return -1 or 1 FH: Change jan 2018 + R lenEdge(int i) const { + ASSERTION(i >= 0 && i < ne); + Rd E = Edge(i); + return sqrt((E, E)); + } + R lenEdgesmax( ) const { + R lx2 = 0; + for (int i = 0; i < ne; ++i) lx2 = max(lx2, lenEdge2(i)); + return sqrt(lx2); + } + R lenEdge2(int i) const { + ASSERTION(i >= 0 && i < ne); + Rd E = Edge(i); + return ((E, E)); + } - R lenEdge(int i) const {ASSERTION(i>=0 && i =0 && i + inline void PermI2J(const void **I, const void **J, int *S) { + ffassert(0); } - - void Change(Vertex *vold, Vertex *vnew) - { - for (int i=0;i + inline void PermI2J< 1 >(const void **I, const void **J, int *S) { + S[0] = 0; + } + template<> + inline void PermI2J< 2 >(const void **I, const void **J, int *S) { + if (I[0] == J[0]) { + assert(I[1] == J[1]); + S[0] = 0; + S[1] = 1; + } else { + assert(I[1] == J[0] && I[0] == J[1]); + S[0] = 1; + S[1] = 0; + } + } + template<> + inline void PermI2J< 3 >(const void **I, const void **J, int *S) { + if (I[0] == J[0]) + S[0] = 0; + else if (I[0] == J[1]) + S[0] = 1; + else { + S[0] = 2; + assert(I[0] == J[2]); + } + if (I[1] == J[0]) + S[1] = 0; + else if (I[1] == J[1]) + S[1] = 1; + else { + S[1] = 2; + assert(I[1] == J[2]); + } + S[2] = 3 - S[0] - S[1]; + assert(I[2] == J[3 - S[0] - S[1]]); } - //Rd n(int i) const // unit exterior normal - // {Rd E=Edge(i);return Rd(E.y,-E.x)/Norme2(E);} - - -private: - // pas de copie - GenericElement(const GenericElement &); - GenericElement &operator = (const GenericElement &); -}; + template< typename T, typename B, typename V > + class GenericMesh : public RefCounter { + public: + typedef GenericMesh GMesh; + typedef T Element; + typedef typename V::Rd Rd; + typedef typename Rd::R R; + typedef V Vertex; + typedef B BorderElement; + typedef EF23::GTree< V > GTree; + typedef typename Element::RdHat RdHat; // for parametrization + + int nt, nv, nbe, nadjnomanifold; + R mes, mesb; + // private: + V *vertices; + T *elements; + B *borderelements; + Rd *bnormalv; // boundary vertex normal + Rd Pmin, Pmax; // // the bound of the domain see BuildBound + static const int nea = T::nea; // numbering of adj (4 in Tet, 3 in Tria, 2 in seg) + static const int nva = T::nva; // numbering of vertex in Adj element + static int kfind, kthrough; // number of search and number of throught element. + int *TheAdjacencesLink; // to store the adj link k*nea+i -> k'*nea+i' + int *BoundaryElementHeadLink; // + int *ElementConteningVertex; + GTree *gtree; + mutable GenericDataFindBoundary< GMesh > *gdfb; + + public: + int nbElmts( ) const { return nt; } + int nbBrdElmts( ) const { return nbe; } + int nbVertices( ) const { return nv; } + const T &operator[](int i) const { return elements[CheckT(i)]; } + const V &operator( )(int i) const { return vertices[CheckV(i)]; } + const B &be(int i) const { return borderelements[CheckBE(i)]; } + void BoundingBox(Rd &pmin, Rd &pmax) const { + pmin = Pmin; + pmax = Pmax; + } + T &t(int i) { return elements[CheckT(i)]; } + V &v(int i) { return vertices[CheckV(i)]; } + B &be(int i) { return borderelements[CheckBE(i)]; } + const T &t(int i) const { return elements[CheckT(i)]; } + const V &v(int i) const { return vertices[CheckV(i)]; } + + GenericMesh( ) + : nt(0), nv(0), nbe(0), nadjnomanifold(0), mes(0.), mesb(0.), vertices(0), elements(0), borderelements(0), bnormalv(0), TheAdjacencesLink(0), BoundaryElementHeadLink(0), + ElementConteningVertex(0), gtree(0), gdfb(0) {} + + GenericMesh(const Serialize &serialized); + + void set(int mv, int mt, int mbe) { + assert(nt == 0 && nv == 0 && nbe == 0); + nt = mt; + nv = mv; + nbe = mbe; + vertices = new V[nv]; + if (nt) elements = new T[nt]; + if (nbe > 0) borderelements = new B[nbe]; + assert((nt >= 0 && elements) || !nt); + assert(nv > 0 && vertices); + } + int operator( )(const T &tt) const { return CheckT(&tt - elements); } + int operator( )(const T *tt) const { return CheckT(tt - elements); } + int operator( )(const V &vv) const { return CheckV(&vv - vertices); } + int operator( )(const V *vv) const { return CheckV(vv - vertices); } + int operator( )(const B &k) const { return CheckBE(&k - borderelements); } + int operator( )(const B *k) const { return CheckBE(k - borderelements); } + int operator( )(int it, int j) const { return operator( )(elements[it][j]); } // Nu vertex j of triangle it + int be(int it, int j) const { return operator( )(borderelements[it][j]); } // Nu vertex j of triangle it + + int CheckV(int i) const { + ASSERTION(i >= 0 && i < nv); + return i; + } + int CheckT(int i) const { + ASSERTION(i >= 0 && i < nt); + return i; + } + int CheckBE(int i) const { + ASSERTION(i >= 0 && i < nbe); + return i; + } - template inline void PermI2J(const void **I,const void **J,int *S) - { - ffassert(0); + int Contening(const Vertex *vv) const { return ElementConteningVertex[vv - vertices] / (Element::nv); } + int kvContening(const Vertex *vv) const { return ElementConteningVertex[vv - vertices]; } + void BuildAdj( ); + void BuildBoundaryElementAdj( ); // Add J. Morice function that give the TheAdjacencesSurfaceLink :: Version avec un manifold + void BuildBoundaryElementAdj(const int &nbsurf, int *firstDefSurface, int *labelDefSurface, int *senslabelDefSurface); // version avec plusieurs vari�t�s + + // template<> + void SameVertex(const double precis_mesh, Vertex *v, Element *t, int nv, int nt, int *ind_nv_t, int *Numero_Som, int &new_nv); + void VertexInElement(Vertex *vertice, Element *list, int &nv, int *(&ind_nv), int nt, int *ind_nt, int *(&old2new)); + void clean_mesh(const double precis_mesh, int &nv, int &nt, int &nbe, V *(&v), T *(&t), B *(&b), bool removeduplicate, bool rebuildboundary, int orientation); + + void Buildbnormalv( ); + void BuildBound( ); + void BuildjElementConteningVertex( ); + void BuildGTree( ) { + if (gtree == 0) gtree = new GTree(vertices, Pmin, Pmax, nv); } - template<> inline void PermI2J<1>(const void **I,const void **J,int *S) - { - S[0]=0; + GenericDataFindBoundary< GMesh > *Buildgdfb( ) const { + if (gdfb == 0) gdfb = new GenericDataFindBoundary< GMesh >(this); + return gdfb; } - template<> inline void PermI2J<2>(const void **I,const void **J,int *S) + DataFENodeDF BuildDFNumbering(int dfon[NbTypeItemElement], int nbequibe = 0, int *equibe = 0) const; + DataFENodeDF BuildDFNumbering(int ndfv, int ndfe, int ndff, int ndft, int nbequibe = 0, int *equibe = 0) const { + int dfon[NbTypeItemElement] = {ndfv, ndfe, ndff, ndft}; + return BuildDFNumbering(dfon, nbequibe, equibe); + } + int nElementonB(int k, int j) const // Correct v4.10 FH 06/2021 in case of no manifold mesh !! { - if(I[0]==J[0]) - { assert(I[1]==J[1]); - S[0]=0;S[1]=1;} - else - { assert(I[1]==J[0]&&I[0]==J[1]); - S[0]=1;S[1]=0;} - } - template<> inline void PermI2J<3>(const void **I,const void **J,int *S) + int kk0 = nea * k + j, kk = TheAdjacencesLink[kk0]; + int n = 1; + // add case of no manifold Juin 2021 FH.. value >2 + while (kk != kk0 && kk >= 0) { + kk = TheAdjacencesLink[kk]; + n++; + ffassert(n < 1000); // remove loop !!!! + } + return n; + } + double uniqueBE(int k, int j) const // add to have unique BE { - if(I[0]==J[0]) S[0]=0; - else if(I[0]==J[1]) S[0]=1; - else {S[0]=2; assert(I[0]==J[2]) ;} - if(I[1]==J[0]) S[1]=0; - else if(I[1]==J[1]) S[1]=1; - else {S[1]=2; assert(I[1]==J[2]) ; } - S[2]=3-S[0]-S[1]; - assert(I[2]==J[3-S[0]-S[1]]); - } - - -template -class GenericMesh : public RefCounter -{ -public: - typedef GenericMesh GMesh; - typedef T Element; - typedef typename V::Rd Rd; - typedef typename Rd::R R; - typedef V Vertex; - typedef B BorderElement; - typedef EF23::GTree GTree; - typedef typename Element::RdHat RdHat;// for parametrization - - int nt,nv,nbe,nadjnomanifold; - R mes,mesb; - //private: - V *vertices; - T *elements; - B *borderelements; - Rd * bnormalv; // boundary vertex normal - Rd Pmin,Pmax; // // the bound of the domain see BuildBound - static const int nea=T::nea; // numbering of adj (4 in Tet, 3 in Tria, 2 in seg) - static const int nva=T::nva; // numbering of vertex in Adj element - static int kfind,kthrough; // number of search and number of throught element. - int *TheAdjacencesLink; // to store the adj link k*nea+i -> k'*nea+i' - int *BoundaryElementHeadLink; // - int *ElementConteningVertex; - GTree *gtree; - mutable GenericDataFindBoundary *gdfb; -public: - int nbElmts() const {return nt;} - int nbBrdElmts() const {return nbe;} - int nbVertices() const {return nv;} - const T & operator[](int i) const {return elements[CheckT(i)];} - const V& operator()(int i) const {return vertices[CheckV(i)];} - const B& be(int i) const {return borderelements[CheckBE(i)];} - void BoundingBox(Rd &pmin,Rd &pmax) const {pmin=Pmin;pmax=Pmax;} - T & t(int i) {return elements[CheckT(i)];} - V & v(int i) {return vertices[CheckV(i)];} - B & be(int i) {return borderelements[CheckBE(i)];} - const T & t(int i) const {return elements[CheckT(i)];} - const V & v(int i) const {return vertices[CheckV(i)];} - - - GenericMesh() - : nt(0),nv(0),nbe(0),nadjnomanifold(0), mes(0.),mesb(0.) , - vertices(0),elements(0),borderelements(0),bnormalv(0), - TheAdjacencesLink(0),BoundaryElementHeadLink(0), - ElementConteningVertex(0), gtree(0),gdfb(0) - { - - } - - GenericMesh(const Serialize &serialized) ; - - void set(int mv,int mt,int mbe) - { - assert(nt==0 && nv==0 && nbe ==0); - nt=mt; - nv=mv; - nbe=mbe; - vertices=new V[nv]; - if(nt) elements= new T[nt]; - if(nbe>0) borderelements = new B[nbe]; - assert( (nt >=0 && elements) || !nt); - assert( nv >0 && vertices); - - } - - - int operator()(const T & tt) const {return CheckT(&tt - elements);} - int operator()(const T * tt) const {return CheckT(tt - elements);} - int operator()(const V & vv) const {return CheckV(&vv - vertices);} - int operator()(const V * vv) const{return CheckV(vv - vertices);} - int operator()(const B & k) const {return CheckBE(&k - borderelements);} - int operator()(const B * k) const{return CheckBE(k - borderelements);} - int operator()(int it,int j) const {return operator()(elements[it][j]);}// Nu vertex j of triangle it - int be(int it,int j) const {return operator()(borderelements[it][j]);}// Nu vertex j of triangle it - - int CheckV(int i) const { ASSERTION(i>=0 && i < nv); return i;} - int CheckT(int i) const { ASSERTION(i>=0 && i < nt); return i;} - int CheckBE(int i) const { ASSERTION(i>=0 && i < nbe); return i;} - - - int Contening(const Vertex * vv) const{ return ElementConteningVertex[ vv - vertices]/(Element::nv);} - int kvContening(const Vertex * vv) const{ return ElementConteningVertex[ vv - vertices];} - void BuildAdj(); - void BuildBoundaryElementAdj(); // Add J. Morice function that give the TheAdjacencesSurfaceLink :: Version avec un manifold - void BuildBoundaryElementAdj(const int &nbsurf, int* firstDefSurface, int* labelDefSurface, int* senslabelDefSurface); // version avec plusieurs vari�t�s - - //template<> - void SameVertex(const double precis_mesh, Vertex *v, Element *t, int nv, int nt, int *ind_nv_t, int *Numero_Som, int &new_nv); - void VertexInElement( Vertex *vertice, Element *list, int &nv, int *(&ind_nv), int nt, int *ind_nt, int *(&old2new) ); - void clean_mesh(const double precis_mesh, int &nv, int &nt, int &nbe, V *(&v), T *(&t), B *(&b), bool removeduplicate, bool rebuildboundary, int orientation); - - void Buildbnormalv(); - void BuildBound(); - void BuildjElementConteningVertex(); - void BuildGTree() {if(gtree==0) gtree=new GTree(vertices,Pmin,Pmax,nv);} - GenericDataFindBoundary * Buildgdfb() const {if(gdfb==0) gdfb=new GenericDataFindBoundary(this) ; return gdfb;} - DataFENodeDF BuildDFNumbering(int dfon[NbTypeItemElement],int nbequibe=0,int *equibe=0) const ; - DataFENodeDF BuildDFNumbering(int ndfv,int ndfe,int ndff,int ndft,int nbequibe=0,int *equibe=0) const - { int dfon[NbTypeItemElement]={ndfv,ndfe,ndff,ndft}; - return BuildDFNumbering(dfon,nbequibe,equibe); - } - int nElementonB(int k,int j) const // Correct v4.10 FH 06/2021 in case of no manifold mesh !! - { int kk0=nea*k+j,kk= TheAdjacencesLink[kk0]; - int n =1; - // add case of no manifold Juin 2021 FH.. value >2 - while ( kk!=kk0 && kk >=0) - { kk = TheAdjacencesLink[kk]; - n++; - ffassert(n<1000); // remove loop !!!! - } - return n; - } - double uniqueBE(int k,int j) const // add to have unique BE - { int kk0=nea*k+j,kk= TheAdjacencesLink[kk0],kkm=kk0; - int n =1; - // add case of no manifold Juin 2021 FH.. value >2 - while ( kk!=kk0 && kk >=0) - { kk = TheAdjacencesLink[kk]; - kkm = min(kk,kkm); - n++; - ffassert(n<1000); // remove loop !!!! - } - return kk0==kk; + int kk0 = nea * k + j, kk = TheAdjacencesLink[kk0], kkm = kk0; + int n = 1; + // add case of no manifold Juin 2021 FH.. value >2 + while (kk != kk0 && kk >= 0) { + kk = TheAdjacencesLink[kk]; + kkm = min(kk, kkm); + n++; + ffassert(n < 1000); // remove loop !!!! } + return kk0 == kk; + } - int ElementAdj(int k,int &j) const { - int p=TheAdjacencesLink[nea*k+j]; - if(p>=0) j=p%nea; - return p>=0 ? p/nea: -1-j;}// modif FH. to change the code of copule k,kadj on border element.. + int ElementAdj(int k, int &j) const { + int p = TheAdjacencesLink[nea * k + j]; + if (p >= 0) j = p % nea; + return p >= 0 ? p / nea : -1 - j; + } // modif FH. to change the code of copule k,kadj on border element.. // correct bug of 23/05/2013 : 1 dof on RT0 3d... - - - int ElementAdj(int k,int &j,Rd& PHat) const - { - // return the kk the number of adj element k to hyperface j (opposite to vertex j) - // out j: is the new hyperface number in element kk. - // and - // in : Pt is the point on hyperface j on element k on ref element K hat. - // remark lb[j]==0 at enter - // you get the new point Pt (in on hyperface j on element kk - // and lb[j] ==0 at return (j have change). - int p=TheAdjacencesLink[nea*k+j]; - if(p>=0) - { - - R lb[Rd::d+1];//{1.-PHat.sum(),PHat}; - R lbb[Rd::d+1];//{1.-PHat.sum(),PHat}; - PHat.toBary(lb); // R1 R2 R3 - assert(Abs(lb[j])<1e-10); - int sigma[T::nva]; - const void * nvkj[T::nva], *nvkkjj[T::nva]; - int jj=p%nea; - int kk=p/nea; - - Element & K(elements[CheckT(k)]); - Element & KK(elements[CheckT(kk)]); - Rd Pin=K(PHat); - for (int l=0;l(nvkj,nvkkjj,sigma); - for (int l=0;l= 0) { + + R lb[Rd::d + 1]; //{1.-PHat.sum(),PHat}; + R lbb[Rd::d + 1]; //{1.-PHat.sum(),PHat}; + PHat.toBary(lb); // R1 R2 R3 + assert(Abs(lb[j]) < 1e-10); + int sigma[T::nva]; + const void *nvkj[T::nva], *nvkkjj[T::nva]; + int jj = p % nea; + int kk = p / nea; + + Element &K(elements[CheckT(k)]); + Element &KK(elements[CheckT(kk)]); + Rd Pin = K(PHat); + for (int l = 0; l < T::nva; ++l) nvkj[l] = &K[T::nvadj[j][l]]; + for (int l = 0; l < T::nva; ++l) nvkkjj[l] = &KK[T::nvadj[jj][l]]; + // il faut permute ll. + PermI2J< nva >(nvkj, nvkkjj, sigma); + for (int l = 0; l < T::nva; ++l) lbb[T::nvadj[jj][l]] = lb[T::nvadj[j][sigma[l]]]; + lbb[jj] = 0; #ifdef DEBUG - Rd PH=PHat; + Rd PH = PHat; #endif - PHat=Rd(lbb+1); + PHat = Rd(lbb + 1); #ifdef DEBUG - Rd Pout=KK(PHat); - if( (Pin-Pout).norme2() > 1e-10 ) - { - for (int l=0;l<=T::nva;++l) - cout << lbb[l] <<" < -- " << lb[l] << endl; - for (int l=0;l " << PHat << " jj = " << jj << endl; - assert(0); - } + Rd Pout = KK(PHat); + if ((Pin - Pout).norme2( ) > 1e-10) { + for (int l = 0; l <= T::nva; ++l) cout << lbb[l] << " < -- " << lb[l] << endl; + for (int l = 0; l < T::nva; ++l) + cout << l << " : o= " << nvkkjj[l] << " i= " << nvkj[l] << " " << sigma[l] << " -- " << &KK[T::nvadj[jj][l]] << " == " << &K[T::nvadj[j][sigma[l]]] << " -- " << &K[T::nvadj[j][l]] + << " == " << &KK[T::nvadj[jj][sigma[l]]] << " -- " << lbb[T::nvadj[jj][l]] << " == " << lb[T::nvadj[j][sigma[l]]] << " ++ " << T::nvadj[jj][l] << " <-- " << T::nvadj[j][sigma[l]] + << endl; + cout << "Adj: j= " << j << " ," << Pin << " != " << Pout << " , " << PH << " -> " << PHat << " jj = " << jj << endl; + assert(0); + } #endif - j=jj; - return kk; + j = jj; + return kk; } - return -1;// on border - } + return -1; // on border + } - int GetAllElementAdj(int it,int *tabk) const - { // get the tab of all adj element (max ne) - // and return the size of the tab - int i=0; - for(int j=0;j=0 && tabk[i]!=it) i++; + int GetAllElementAdj(int it, int *tabk) const { // get the tab of all adj element (max ne) + // and return the size of the tab + int i = 0; + for (int j = 0; j < nea; ++j) { + tabk[i] = TheAdjacencesLink[3 * it + j] / 3; + if (tabk[i] >= 0 && tabk[i] != it) i++; } - return i; - } + return i; + } - int BoundaryElement(int bbe,int & ItemInK) const { - int i= BoundaryElementHeadLink[bbe]; - ItemInK = i%nea; - return i/nea;} + int BoundaryElement(int bbe, int &ItemInK) const { + int i = BoundaryElementHeadLink[bbe]; + ItemInK = i % nea; + return i / nea; + } - // Add J. Morice - template - SortArray itemadjs(const int (* const nu )[N],int k,int i, int *sens) const - { - int nnv[N]; - const B & K(borderelements[CheckBE(k)]); - ASSERTION(i>=0 && i + SortArray< int, N > itemadjs(const int (*const nu)[N], int k, int i, int *sens) const { + int nnv[N]; + const B &K(borderelements[CheckBE(k)]); + ASSERTION(i >= 0 && i < M); + for (int j = 0; j < N; ++j) { + nnv[j] = operator( )(K[nu[i][j]]); + } + return SortArray< int, N >(nnv, sens); } - return SortArray(nnv,sens); - } - SortArray items(int k,int i,int *sens) const - { - return itemadjs(B::nvadj,k,i,sens); - } + SortArray< int, B::nva > items(int k, int i, int *sens) const { return itemadjs< B::nva, B::nv >(B::nvadj, k, i, sens); } + template< int N, int M > + SortArray< int, N > iteme(const int (*const nu)[N], int k, int i, int *psens = 0) const { + int nnv[N]; + const Element &K(elements[CheckT(k)]); + ASSERTION(i >= 0 && i < M); + for (int j = 0; j < N; ++j) { + nnv[j] = operator( )(K[nu[i][j]]); + } - template - SortArray iteme(const int (* const nu )[N],int k,int i,int *psens=0) const - { - int nnv[N]; - const Element & K(elements[CheckT(k)]); - ASSERTION(i>=0 && i (nnv, psens); } - return SortArray(nnv,psens); - } + SortArray< int, B::nv > itemadj(int k, int i, int *psens = 0) const { return iteme< B::nv, T::nea >(T::nvadj, k, i, psens); } - SortArray itemadj(int k,int i,int *psens=0) const - { - return iteme(T::nvadj,k,i,psens); - } + SortArray< int, B::nv > itembe(int k, int *psens = 0) const { + int nnv[B::nv]; + const B &K(borderelements[CheckBE(k)]); - SortArray itembe(int k,int *psens=0) const - { - int nnv[B::nv]; - const B & K(borderelements[CheckBE(k)]); + for (int j = 0; j < B::nv; ++j) { + nnv[j] = operator( )(K[j]); + } - for (int j=0;j(nnv, psens); } - return SortArray(nnv,psens); - } + // const Element * Find(const Rd & P) const ; + const Element *Find(Rd P, RdHat &Phat, bool &outside, const Element *tstart = 0) const { return EF23::Find< GMesh >(*this, this->gtree, P, Phat, outside, tstart); } + + R mesure( ) { return mes; } + R bordermesure( ) { return mesb; } + virtual ~GenericMesh( ) { + + delete[] ElementConteningVertex; + delete[] TheAdjacencesLink; + delete[] BoundaryElementHeadLink; + if (nt > 0) delete[] elements; + if (nbe > 0) delete[] borderelements; + delete[] vertices; + delete[] bnormalv; + if (gtree) delete gtree; + if (gdfb) delete gdfb; + ElementConteningVertex = 0; + TheAdjacencesLink = 0; + BoundaryElementHeadLink = 0; + borderelements = 0; + elements = 0; + vertices = 0; + bnormalv = 0; + gtree = 0; + gdfb = 0; + nt = (0); + nv = (0); + nbe = (0); + mes = (0.); + mesb = (0.); + } - // const Element * Find(const Rd & P) const ; - const Element * Find(Rd P, RdHat & Phat,bool & outside,const Element * tstart=0) const - {return EF23::Find(*this,this->gtree,P,Phat,outside,tstart);} - - R mesure(){ return mes;} - R bordermesure(){ return mesb;} - virtual ~GenericMesh() { - - delete [] ElementConteningVertex; - delete [] TheAdjacencesLink; - delete [] BoundaryElementHeadLink; - if(nt>0) delete [] elements; - if(nbe>0) delete [] borderelements; - delete [] vertices; - delete [] bnormalv; - if(gtree) delete gtree; - if(gdfb) delete gdfb; - ElementConteningVertex=0; - TheAdjacencesLink=0; - BoundaryElementHeadLink=0; - borderelements=0; - elements=0; - vertices=0; - bnormalv=0; - gtree=0; - gdfb=0; - nt=(0); - nv=(0); - nbe=(0); - mes=(0.); - mesb=(0.); + Serialize serialize( ) const; + + private: + GenericMesh(const GenericMesh &); // pas de construction par copie + void operator=(const GenericMesh &); // pas affectation par copy + }; + + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::BuildjElementConteningVertex( ) { + const int nkv = T::nv; + int lerr[10] = { }; + if (!ElementConteningVertex) ElementConteningVertex = new int[nv]; + + for (int i = 0; i < nv; ++i) ElementConteningVertex[i] = -1; + + for (int k = 0; k < nt; ++k) + for (int i = 0; i < nkv; ++i) ElementConteningVertex[operator( )(elements[k][i])] = nkv * k + i; // modif FH nov 2022 add vertex number !! + int kerr = 0; + for (int i = 0; i < nv; ++i) + if (ElementConteningVertex[i] < 0) + if (kerr < 10) lerr[kerr++] = i; + if (kerr) { + cerr << " Fatal error: some vertex are not at least in one element \n : "; + for (int i = 0; i < kerr; ++i) cerr << " " << lerr[i]; + cerr << endl; + } + ffassert(kerr == 0); // Sure Error. } - - Serialize serialize() const; - -private: - GenericMesh(const GenericMesh &); // pas de construction par copie - void operator=(const GenericMesh &);// pas affectation par copy -}; - -template -void GenericMesh::BuildjElementConteningVertex() -{ - const int nkv= T::nv; - int lerr[10]={}; - if(!ElementConteningVertex) ElementConteningVertex = new int[nv]; - - for(int i=0;i - void GenericMesh::BuildAdj() - { - if(TheAdjacencesLink!=0) return ;// already build ... - TheAdjacencesLink = new int[nea*nt]; - BoundaryElementHeadLink = new int[nbe]; - HashTable,int> h(nea*nt,nv); - int nk=0,nba=0; - int err=0; - if(verbosity>5) - cout << " -- BuildAdj:nva= " << nva << " " << nea << " "<< nbe << endl; - nadjnomanifold=0; - for (int k=0;k a(itemadj(k,i,&sens));// warning the face of tet given interieon normal FH. - if(verbosity>299) cout <,int>::iterator p= h.find(a); - if(!p) { - h.add(a,nk); - TheAdjacencesLink[nk]=-1; - nba++; - } - else { - if(p->v<0 ) {// no manifold TO DO - // clean adj - int nk1=-1-p->v; - int nk2= TheAdjacencesLink[nk1];// next - if(nk2>=0) { // firt time remove existing link ... - nadjnomanifold++; - TheAdjacencesLink[nk1]=nk ; // inserting between nk1 and nk2 - TheAdjacencesLink[nk]=nk2 ; - // on no manifold border . - if(verbosity>99 ) cout << " Border manifold " << k << " "<< i << " :: " << itemadj(k,i)<< " :: " << nk1/nea << " " << nk2/nea - << " :: " <v "<< p->v << endl; - TheAdjacencesLink[nk]=p->v; - TheAdjacencesLink[p->v]=nk; - p->v=-1-nk; - nba--; - } - - - } - ++nk; - } - int nbordnomanifold=0; - if(nadjnomanifold && B::nv>1) - { - - // remove all adj of no manifold border - int k3= nt*nea; - for (int p=0; p< k3; ++p ) - { - int pp=TheAdjacencesLink[p]; - if(pp>0 && TheAdjacencesLink[pp]>=0 && TheAdjacencesLink[pp] != p ) - { // border of no manifold - if(verbosity>19) cout << " -- " << p/nea << " " ; - ++nbordnomanifold; - // remove link ... put -2 in all list ... - TheAdjacencesLink[p]=-2; - while (pp>=0 && TheAdjacencesLink[pp]>=0 ) - { - if(verbosity>19) cout << pp/nea << " " ; - int ppp=pp; - pp=TheAdjacencesLink[pp]; - TheAdjacencesLink[ppp]=-2;// break the list ... - } - if(verbosity>19) cout << " . " << endl; - } + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::BuildAdj( ) { + if (TheAdjacencesLink != 0) return; // already build ... + TheAdjacencesLink = new int[nea * nt]; + BoundaryElementHeadLink = new int[nbe]; + HashTable< SortArray< int, nva >, int > h(nea * nt, nv); + int nk = 0, nba = 0; + int err = 0; + if (verbosity > 5) cout << " -- BuildAdj:nva= " << nva << " " << nea << " " << nbe << endl; + nadjnomanifold = 0; + for (int k = 0; k < nt; ++k) + for (int i = 0; i < nea; ++i) { + int sens; + SortArray< int, nva > a(itemadj(k, i, &sens)); // warning the face of tet given interieon normal FH. + if (verbosity > 299) cout << nk << " T " << k << "### " << " item(k,i)= " << itemadj(k, i) << " a= " << a << " k " << k << " i " << i << endl; + typename HashTable< SortArray< int, nva >, int >::iterator p = h.find(a); + if (!p) { + h.add(a, nk); + TheAdjacencesLink[nk] = -1; + nba++; + } else { + if (p->v < 0) { // no manifold TO DO + // clean adj + int nk1 = -1 - p->v; + int nk2 = TheAdjacencesLink[nk1]; // next + if (nk2 >= 0) { // firt time remove existing link ... + nadjnomanifold++; + TheAdjacencesLink[nk1] = nk; // inserting between nk1 and nk2 + TheAdjacencesLink[nk] = nk2; + // on no manifold border . + if (verbosity > 99) + cout << " Border manifold " << k << " " << i << " :: " << itemadj(k, i) << " :: " << nk1 / nea << " " << nk2 / nea << " :: " << TheAdjacencesLink[nk1] / nea << '.' + << TheAdjacencesLink[nk] / nea << '.' << TheAdjacencesLink[nk2] / nea << endl; + // nba--; + // no manifold TO DO if false } - + } else { + // cout << " test p->v "<< p->v << endl; + TheAdjacencesLink[nk] = p->v; + TheAdjacencesLink[p->v] = nk; + p->v = -1 - nk; + nba--; + } } - if(verbosity&& nadjnomanifold) cerr << " --- Warning no manifold obj nb:" << nbordnomanifold<< " adj "<< nadjnomanifold << " of dim =" << T::RdHat::d << endl; - int kerr=0,kerrf=0,nbei=0,fwarn=0; - map,pair > mapfs; - int uncorrect =0, nbchangeorient=0; - for(int step=0; step<2; ++step) - { - for (int ke=0;ke a(itembe(ke,&sens)); - - typename HashTable,int>::iterator p= h.find(a); - - if(verbosity>99) cout << "B " << ke << " ### " << " item(k,i)= " << itembe(ke) << " a= " << a << endl; - - if(!p) { err++; - if(err==1) cerr << "Err Border element not in mesh \n"; - if (err<10) cerr << " \t " << ke << " : " << a << endl; - } + ++nk; + } + int nbordnomanifold = 0; + if (nadjnomanifold && B::nv > 1) { + + // remove all adj of no manifold border + int k3 = nt * nea; + for (int p = 0; p < k3; ++p) { + int pp = TheAdjacencesLink[p]; + if (pp > 0 && TheAdjacencesLink[pp] >= 0 && TheAdjacencesLink[pp] != p) { // border of no manifold + if (verbosity > 19) cout << " -- " << p / nea << " "; + ++nbordnomanifold; + // remove link ... put -2 in all list ... + TheAdjacencesLink[p] = -2; + while (pp >= 0 && TheAdjacencesLink[pp] >= 0) { + if (verbosity > 19) cout << pp / nea << " "; + int ppp = pp; + pp = TheAdjacencesLink[pp]; + TheAdjacencesLink[ppp] = -2; // break the list ... + } + if (verbosity > 19) cout << " . " << endl; + } + } + } + if (verbosity && nadjnomanifold) cerr << " --- Warning no manifold obj nb:" << nbordnomanifold << " adj " << nadjnomanifold << " of dim =" << T::RdHat::d << endl; + int kerr = 0, kerrf = 0, nbei = 0, fwarn = 0; + map< pair< int, int >, pair< int, int > > mapfs; + int uncorrect = 0, nbchangeorient = 0; + for (int step = 0; step < 2; ++step) { + for (int ke = 0; ke < nbe; ++ke) { + int sens, s = 0, ss = 0; + SortArray< int, nva > a(itembe(ke, &sens)); + + typename HashTable< SortArray< int, nva >, int >::iterator p = h.find(a); + + if (verbosity > 99) cout << "B " << ke << " ### " << " item(k,i)= " << itembe(ke) << " a= " << a << endl; + + if (!p) { + err++; + if (err == 1) cerr << "Err Border element not in mesh \n"; + if (err < 10) cerr << " \t " << ke << " : " << a << endl; + } else { + int nk = p->v < 0 ? -p->v - 1 : p->v; + int nkk = TheAdjacencesLink[nk]; + if (nkk >= 0) { + nbei++; + // choise le bon .. too get the correct normal + int k = nk / nea, e = nk % nea; + int kk = nkk / nea, ee = nkk % nea; + itemadj(k, e, &s); + if (verbosity > 15) cout << " item(k,e)= " << itemadj(k, e) << " k " << k << " e " << e << " s " << s << endl; + itemadj(kk, ee, &ss); + if (verbosity > 15) cout << " item(kk,ee)= " << itemadj(kk, ee) << " kk " << kk << " ee " << ee << " ss " << ss << endl; + // assert(s && ss && s== -ss); + if (!(s && ss && s == -ss) && lockOrientation && (B::nv > 1)) { + cerr << " Bad orientation: The adj border element defined by [ " << itemadj(k, e) << " ] is oriented in the same direction in element " << k << " and in the element " << kk + << " ****** bug in mesh construction? orientation parameter? " << endl; + ffassert(0); + } + if (sens == s) { + swap(nk, nkk); + swap(k, kk); + } // autre cote + // verif sens normal + int regk = elements[k].lab; + int regkk = elements[kk].lab; + + if (regk != regkk) { // verif orientation interior normal + int sr = 1; + if (step == 0) { + if (regk > regkk) + mapfs[make_pair(regkk, regk)].second++; // increme le + grand else - { - int nk = p->v <0 ? -p->v-1 : p->v; - int nkk= TheAdjacencesLink[nk]; - if( nkk>=0) - { - nbei ++; - // choise le bon .. too get the correct normal - int k= nk/nea, e=nk%nea; - int kk= nkk/nea, ee=nkk%nea; - itemadj(k,e,&s); if(verbosity>15) cout << " item(k,e)= " << itemadj(k,e) << " k " << k << " e " << e << " s " << s << endl; - itemadj(kk,ee,&ss); if(verbosity>15) cout << " item(kk,ee)= " << itemadj(kk,ee) << " kk " << kk << " ee " << ee << " ss " << ss << endl; - //assert(s && ss && s== -ss); - if (!(s && ss && s== -ss) && lockOrientation && (B::nv>1)) { - cerr << " Bad orientation: The adj border element defined by [ " << itemadj(k,e) << " ] is oriented in the same direction in element " - << k << " and in the element " << kk << " ****** bug in mesh construction? orientation parameter? "<< endl; - ffassert(0); - } - if( sens == s) {swap(nk,nkk);swap(k,kk);} // autre cote - // verif sens normal - int regk= elements[k].lab; - int regkk= elements[kk].lab; - - if(regk != regkk) - { // verif orientation interior normal - int sr =1; - if(step==0) - { - if(regk>regkk) - mapfs[make_pair(regkk,regk)].second++;// increme le + grand - else - mapfs[make_pair(regk,regkk)].first++;// increme le + grand - } - else { // correct the sens of face - if(regk>regkk) sr=-1,swap(regk,regkk); - // change orientation de du plus petit nombre - map,pair >::iterator p= mapfs.find(make_pair(regk,regkk)); - int nfk = p->second.first; - int nfkk =p->second.second; - // event regkk - bool change=0; - if( (nfk < nfkk) && sr == 1 ) change=1; - if( (nfk > nfkk) && sr == -1 ) change=1; - if( change) - { - nbchangeorient++; - borderelements[ke].changeOrientation(); - if(verbosity>2) cout << " changeOrientation face:"<< ke << endl; - swap(nk,nkk); - swap(k,kk); - } - } - - } - - } - else - {// verif if the face is in correct sens ... - int sk,k= nk/nea, e=nk%nea; // same oreintatio ??? - itemadj(k,e,&sk); - if( sk != sens && (step == 0) ) - { - fwarn++; - if( verbosity>4 && fwarn < 10) cout << " -- warning true boundary element "< regkk) sr = -1, swap(regk, regkk); + // change orientation de du plus petit nombre + map< pair< int, int >, pair< int, int > >::iterator p = mapfs.find(make_pair(regk, regkk)); + int nfk = p->second.first; + int nfkk = p->second.second; + // event regkk + bool change = 0; + if ((nfk < nfkk) && sr == 1) change = 1; + if ((nfk > nfkk) && sr == -1) change = 1; + if (change) { + nbchangeorient++; + borderelements[ke].changeOrientation( ); + if (verbosity > 2) cout << " changeOrientation face:" << ke << endl; + swap(nk, nkk); + swap(k, kk); } + } } - } - for(map,pair >::iterator p=mapfs.begin(); p != mapfs.end(); ++p) - { - if( p->second.first && p->second.second) - { - if(verbosity>2 && step==0) cout << " error in orientation of internal face between region " - << p->first.first << " , " << p->first.second << " to no zero value " - << p->second.first << " " << p->second.second << endl; - uncorrect++; + } else { // verif if the face is in correct sens ... + int sk, k = nk / nea, e = nk % nea; // same oreintatio ??? + itemadj(k, e, &sk); + if (sk != sens && (step == 0)) { + fwarn++; + if (verbosity > 4 && fwarn < 10) cout << " -- warning true boundary element " << ke << " is no in correct orientation " << endl; + borderelements[ke].changeOrientation( ); + nbchangeorient++; } - } - if(uncorrect==0) break; - } - if( nbchangeorient && verbosity>2) cout << " Warning change orientation of " << nbchangeorient << " faces \n"; - if( fwarn && verbosity>2) cout << " Warning error in boundary oriention " << fwarn << " faces \n"; - if( kerr || kerrf ) { - cout << " Erreur in boundary orientation bug in mesh or bug in ff++ " << kerr << " / " <1) - { - cout << " -- BuildAdj:"<< this <<" nb Elememt " << nt << " nb vertices " << nv << endl; - cout << " : nb adj = "<< na << " on border " << nba << " nea = " << nea << " nva = " << nva - << " nb no manifold border " << nadjnomanifold << endl; - if(nea==2) - cout << " Const d'Euler: " << nt - na + nv << endl; - else - cout << endl; - } -} + } + for (map< pair< int, int >, pair< int, int > >::iterator p = mapfs.begin( ); p != mapfs.end( ); ++p) { + if (p->second.first && p->second.second) { + if (verbosity > 2 && step == 0) + cout << " error in orientation of internal face between region " << p->first.first << " , " << p->first.second << " to no zero value " << p->second.first << " " << p->second.second + << endl; + uncorrect++; + } + } + if (uncorrect == 0) break; + } + if (nbchangeorient && verbosity > 2) cout << " Warning change orientation of " << nbchangeorient << " faces \n"; + if (fwarn && verbosity > 2) cout << " Warning error in boundary oriention " << fwarn << " faces \n"; + if (kerr || kerrf) { + cout << " Erreur in boundary orientation bug in mesh or bug in ff++ " << kerr << " / " << nbei << "\n\n"; + cout << " or Erreur in face " << kerrf << " / " << nbei << "\n\n"; + } + ffassert(kerr == 0 && kerrf == 0); + ffassert(err == 0); + int na = h.n; + if (verbosity > 1) { + cout << " -- BuildAdj:" << this << " nb Elememt " << nt << " nb vertices " << nv << endl; + cout << " : nb adj = " << na << " on border " << nba << " nea = " << nea << " nva = " << nva << " nb no manifold border " << nadjnomanifold << endl; + if (nea == 2) + cout << " Const d'Euler: " << nt - na + nv << endl; + else + cout << endl; + } + } -template -void GenericMesh::BuildBoundaryElementAdj() -{ + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::BuildBoundaryElementAdj( ) { // Return in TheBorderElementAjacencesLink // if exist a link :: sign(nk_link)*(nk_link+1) // else :: sign(nk)*(nk) - int *TheBoundaryElementAdjacencesLink = new int[B::nea*nbe]; - HashTable,int> h(B::nea*nbe,nv); - int nk=0; - int err=0,errm=0; + int *TheBoundaryElementAdjacencesLink = new int[B::nea * nbe]; + HashTable< SortArray< int, B::nva >, int > h(B::nea * nbe, nv); + int nk = 0; + int err = 0, errm = 0; int sens; - cout << "nea/nva" << B::nea << " " << B::nva << endl; - for (int k=0;k a(items(k,i,&sens)); - - typename HashTable,int>::iterator p= h.find(a); - if(!p) - { - h.add(a,nk); - TheBoundaryElementAdjacencesLink[nk] = sens*(nk+1) ; // sens; - } - else - { - ASSERTION(p->v>=0); - if( sens*TheBoundaryElementAdjacencesLink[p->v] > 0 ){ - - B & K(borderelements[CheckBE(k)]); - // Bug before is here nea : nb of border element for adj : , nva = nb of vertex of border element for adl - - cout << " The adj border element defined by [ " ; - for(int ia=0; iav/B::nea) << endl; - err++; - - } - if( abs(TheBoundaryElementAdjacencesLink[p->v]) != 1+p->v ){ - - B & K(borderelements[CheckBE(k)]); - if(errm<10) - { - cout << " The adj border element defined by vertex [ "; - for(int ia=0; iav)/B::nea <<", "<< k+1 <<" and "<< 1+(abs(TheBoundaryElementAdjacencesLink[p->v])-1)/B::nea << endl; - } - errm++; - } - if( errm) cout << " The border "<v]; - TheBoundaryElementAdjacencesLink[p->v]= sens*(nk+1); + cout << "nea/nva" << B::nea << " " << B::nva << endl; + for (int k = 0; k < nbe; ++k) + for (int i = 0; i < B::nea; ++i) { + SortArray< int, B::nva > a(items(k, i, &sens)); + + typename HashTable< SortArray< int, B::nva >, int >::iterator p = h.find(a); + if (!p) { + h.add(a, nk); + TheBoundaryElementAdjacencesLink[nk] = sens * (nk + 1); // sens; + } else { + ASSERTION(p->v >= 0); + if (sens * TheBoundaryElementAdjacencesLink[p->v] > 0) { + + B &K(borderelements[CheckBE(k)]); + // Bug before is here nea : nb of border element for adj : , nva = nb of vertex of border element for adl + + cout << " The adj border element defined by [ "; + for (int ia = 0; ia < nva; ++ia) cout << operator( )(K[B::nvadj[i][ia]]) + 1 << " "; + cout << " ] is oriented in the same direction in element " << k + 1 << " and in element " << 1 + (p->v / B::nea) << endl; + err++; + } + if (abs(TheBoundaryElementAdjacencesLink[p->v]) != 1 + p->v) { + B &K(borderelements[CheckBE(k)]); + if (errm < 10) { + cout << " The adj border element defined by vertex [ "; + for (int ia = 0; ia < nva; ++ia) cout << operator( )(K[B::nvadj[i][ia]]) + 1 << " "; + cout << " ] is belong to the three border elements ::" << 1 + (p->v) / B::nea << ", " << k + 1 << " and " << 1 + (abs(TheBoundaryElementAdjacencesLink[p->v]) - 1) / B::nea << endl; } - if( err > 10 ) - exit(1); - nk++; + errm++; + } + if (errm) cout << " The border " << B::RdHat::d << "d " << " is none manifold" << endl; + if (err) cout << " The border " << B::RdHat::d << "d " << " is badly oriented !!!! " << endl; + ffassert(err == 0 && errm == 0); + TheBoundaryElementAdjacencesLink[nk] = TheBoundaryElementAdjacencesLink[p->v]; + TheBoundaryElementAdjacencesLink[p->v] = sens * (nk + 1); } + if (err > 10) exit(1); + nk++; + } - assert(err==0); - delete [ ] TheBoundaryElementAdjacencesLink; - if(verbosity) cout << "number of adjacents edges " << nk << endl; -} + assert(err == 0); + delete[] TheBoundaryElementAdjacencesLink; + if (verbosity) cout << "number of adjacents edges " << nk << endl; + } + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::BuildBoundaryElementAdj(const int &nbsurf, int *firstDefSurface, int *labelDefSurface, int *senslabelDefSurface) { -template -void GenericMesh::BuildBoundaryElementAdj(const int &nbsurf, int* firstDefSurface, int* labelDefSurface, int* senslabelDefSurface) -{ + // Return in TheBoundaryElementAdjacences + // if exist a link :: sign(nk_link)*(nk_link+1) + // else :: sign(nk)*(nk) - // Return in TheBoundaryElementAdjacences - // if exist a link :: sign(nk_link)*(nk_link+1) - // else :: sign(nk)*(nk) + for (int isurf = 0; isurf < nbsurf; isurf++) { + // ###################################### + // Trop operations if ===> a changer - for(int isurf=0; isurf < nbsurf; isurf++){ + int nbe_surf = 0; // number in the surface + + for (int k = 0; k < nbe; k++) { + B &K(borderelements[CheckBE(k)]); + int label = K.lab; + for (int iii = firstDefSurface[isurf]; iii < firstDefSurface[isurf + 1]; iii++) + if (label == labelDefSurface[iii]) nbe_surf++; + } - //###################################### - // Trop operations if ===> a changer + int facek = 0; + int *surf_be = new int[nbe_surf]; + int *orientation_surf_be = new int[nbe_surf]; + for (int k = 0; k < nbe; k++) { + B &K(borderelements[CheckBE(k)]); + int label = K.lab; + for (int iii = firstDefSurface[isurf]; iii < firstDefSurface[isurf + 1]; iii++) + if (label == labelDefSurface[iii]) { + surf_be[facek] = k; + orientation_surf_be[facek] = senslabelDefSurface[iii]; + facek++; + } + } - int nbe_surf=0; // number in the surface + // ###################################### + + int *TheBoundaryElementAdjacencesLink = new int[B::nea * nbe_surf]; + HashTable< SortArray< int, B::nva >, int > h(B::nea * nbe_surf, nv); + int nk = 0; + int err = 0; + int sens; + if (verbosity > 4) cout << "BuildBoundaryElementAdj: nea/nva " << B::nea << " " << B::nva << endl; + for (int k = 0; k < nbe_surf; ++k) + for (int i = 0; i < B::nea; ++i) { + SortArray< int, B::nva > a(items(surf_be[k], i, &sens)); + sens = sens * orientation_surf_be[k]; + typename HashTable< SortArray< int, B::nva >, int >::iterator p = h.find(a); + if (!p) { + h.add(a, nk); + TheBoundaryElementAdjacencesLink[nk] = sens * (nk + 1); + // nk est un nombre locale depend de la surfaces choisie + // element du bord est donn�e par :: surf_be[nk/3]; + // arrete corespondante locale de l'element :: nk%3; + } else { + + ASSERTION(p->v >= 0); + if (sens * TheBoundaryElementAdjacencesLink[p->v] > 0) { + + B &K(borderelements[CheckBE(surf_be[k])]); + int firstVertex = operator( )(K[B::nvadj[0][i]]) + 1; + int secondVertex = operator( )(K[B::nvadj[1][i]]) + 1; + cout << " The edges, defined by vertex is " << firstVertex << "-" << secondVertex << ", is oriented in the same direction in element " << surf_be[k] + 1 << " and in element " + << 1 + surf_be[(p->v / B::nea)] << endl; + + err++; + } - for(int k=0; kv]) != 1 + p->v) { - int facek=0; - int *surf_be=new int[nbe_surf]; - int *orientation_surf_be=new int[nbe_surf]; - for(int k=0; kv) / B::nea] << ", " << surf_be[k] + 1 + << " and " << 1 + surf_be[(abs(TheBoundaryElementAdjacencesLink[p->v]) - 1) / B::nea] << endl; + cout << " The " << isurf + 1 << " Surface contains these edges is not a manifold" << endl; + err++; + assert(err == 0); + } - //###################################### + TheBoundaryElementAdjacencesLink[nk] = TheBoundaryElementAdjacencesLink[p->v]; + ; + TheBoundaryElementAdjacencesLink[p->v] = sens * (nk + 1); + } + if (err > 10) exit(1); + nk++; + } - int *TheBoundaryElementAdjacencesLink = new int[B::nea*nbe_surf]; - HashTable,int> h(B::nea*nbe_surf,nv); - int nk=0; - int err=0; - int sens; - if(verbosity>4) cout << "BuildBoundaryElementAdj: nea/nva " << B::nea << " " << B::nva << endl; - for (int k=0;k a(items( surf_be[k],i,&sens)); - sens=sens*orientation_surf_be[k]; - typename HashTable,int>::iterator p= h.find(a); - if(!p) - { - h.add(a,nk); - TheBoundaryElementAdjacencesLink[nk]=sens*(nk+1); - // nk est un nombre locale depend de la surfaces choisie - // element du bord est donn�e par :: surf_be[nk/3]; - // arrete corespondante locale de l'element :: nk%3; - } - else - { - - ASSERTION(p->v>=0); - if( sens*TheBoundaryElementAdjacencesLink[p->v] > 0 ){ - - B & K(borderelements[CheckBE(surf_be[k])]); - int firstVertex = operator()(K[B::nvadj[0][i]])+1; - int secondVertex = operator()(K[B::nvadj[1][i]])+1; - cout << " The edges, defined by vertex is " << firstVertex << "-" << secondVertex << ", is oriented in the same direction in element " << surf_be[k]+1 << - " and in element "<< 1+surf_be[(p->v/B::nea)] << endl; - - err++; - } - - if( abs(TheBoundaryElementAdjacencesLink[p->v]) != 1+p->v ){ - - B & K(borderelements[CheckBE(k)]); - int firstVertex = operator()(K[B::nvadj[0][i]])+1; - int secondVertex = operator()(K[B::nvadj[1][i]])+1; - cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex << "belong to the three border elements ::" - << 1+surf_be[(p->v)/B::nea] <<", "<< surf_be[k]+1 <<" and "<< 1+surf_be[(abs(TheBoundaryElementAdjacencesLink[p->v])-1)/B::nea] << endl; - cout << " The "<< isurf+1 << " Surface contains these edges is not a manifold" << endl; - err++; - assert(err==0); - } - - - TheBoundaryElementAdjacencesLink[nk] = TheBoundaryElementAdjacencesLink[p->v];; - TheBoundaryElementAdjacencesLink[p->v] = sens*(nk+1); - - } - if( err > 10 ) - exit(1); - nk++; - } - - assert(err==0); - delete [] surf_be; - delete [] orientation_surf_be; - delete [ ] TheBoundaryElementAdjacencesLink; - if(verbosity) cout << "number of adjacents edges " << nk << endl; + assert(err == 0); + delete[] surf_be; + delete[] orientation_surf_be; + delete[] TheBoundaryElementAdjacencesLink; + if (verbosity) cout << "number of adjacents edges " << nk << endl; + } } -} - -template -void GenericMesh::VertexInElement(V *vertice, T *list, int &nv, int *(&ind_nv), int nt, int *ind_nt, int *(&old2new) ) { - + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::VertexInElement(V *vertice, T *list, int &nv, int *(&ind_nv), int nt, int *ind_nt, int *(&old2new)) { + // new map and list vertices after clean multiple elements int map[nv]; int indv[nv]; - - int takev[nv], takenewv[nv] ; - for (int i=0;i5) cout << " real used vertice:" << np << endl; - - for(int i=0;i -void GenericMesh::SameVertex(const double precis_mesh, V *vertice, T *element, int nv, int nt, int *ind_nv_t, int *old2new, int &new_nv) { - if (verbosity > 2) - cout << "clean mesh: remove multiple vertices, elements, border elements and check border elements " << endl; - double precispt=0; + if (verbosity > 5) cout << " real used vertice:" << np << endl; + + for (int i = 0; i < nv; i++) { + ind_nv[i] = indv[i]; + old2new[i] = map[i]; + } + nv = np; + } + + // output int *ind_nv_t, int *old2new, int &new_nv + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::SameVertex(const double precis_mesh, V *vertice, T *element, int nv, int nt, int *ind_nv_t, int *old2new, int &new_nv) { + if (verbosity > 2) cout << "clean mesh: remove multiple vertices, elements, border elements and check border elements " << endl; + double precispt = 0; // remove the multiple vertices // 1/ compute bmin, bmax, hmin with the criteria precis_mesh // 2/ build a gtree to extract the simple vertices (not multiple) double hmin = 1e10; Rd bmin, bmax; - if (verbosity > 2) {cout << " BuilBound " << endl;} - //Mesh::Vertex ? + if (verbosity > 2) { + cout << " BuilBound " << endl; + } + // Mesh::Vertex ? bmin.x = vertice[0].x; bmin.y = vertice[0].y; bmin.z = vertice[0].z; @@ -1294,16 +1277,18 @@ void GenericMesh::SameVertex(const double precis_mesh, V *vertice, T *ele bmax.y = bmin.y; bmax.z = bmin.z; - if (verbosity > 1) {cout << " determination of bmin and bmax" << endl;} + if (verbosity > 1) { + cout << " determination of bmin and bmax" << endl; + } for (int i = 1; i < nv; i++) { - bmin.x = min(bmin.x, vertice[i].x); - bmin.y = min(bmin.y, vertice[i].y); - bmin.z = min(bmin.z, vertice[i].z); - - bmax.x = max(bmax.x, vertice[i].x); - bmax.y = max(bmax.y, vertice[i].y); - bmax.z = max(bmax.z, vertice[i].z); + bmin.x = min(bmin.x, vertice[i].x); + bmin.y = min(bmin.y, vertice[i].y); + bmin.z = min(bmin.z, vertice[i].z); + + bmax.x = max(bmax.x, vertice[i].x); + bmax.y = max(bmax.y, vertice[i].y); + bmax.z = max(bmax.z, vertice[i].z); } double longmini_box; @@ -1311,899 +1296,806 @@ void GenericMesh::SameVertex(const double precis_mesh, V *vertice, T *ele longmini_box = sqrt(longmini_box); if (precis_mesh < 0) - precispt = -longmini_box; + precispt = -longmini_box; else - precispt = precis_mesh*longmini_box; + precispt = precis_mesh * longmini_box; if (verbosity > 1) { - cout << " bmin := " << bmin.x << " " << bmin.y << " " << bmin.z << endl; - cout << " bmax := " << bmax.x << " " << bmax.y << " " << bmax.z << endl; - cout << " box volume :=" << longmini_box << endl; - cout << " eps size edges "<< precispt << endl; + cout << " bmin := " << bmin.x << " " << bmin.y << " " << bmin.z << endl; + cout << " bmax := " << bmax.x << " " << bmax.y << " " << bmax.z << endl; + cout << " box volume :=" << longmini_box << endl; + cout << " eps size edges " << precispt << endl; } // determination de hmin - for (int i = 0; i < nt ; i++) { - const T &K(element[i]); - double longedge=0.; - int iv[T::nea]; - - for (int j = 0; j < T::nea ; j++) - iv[j] = operator()(K[j]); - for (int j = 0; j < T::nea ; j++) - for (int k = j + 1; k < T::nea; k++) { - int &i1 = iv[j]; - int &i2 = iv[k]; - longedge = Rd(vertice[i1],vertice[i2]).norme(); - if (longedge > precispt) hmin = min(hmin, longedge); - } - + for (int i = 0; i < nt; i++) { + const T &K(element[i]); + double longedge = 0.; + int iv[T::nea]; + + for (int j = 0; j < T::nea; j++) iv[j] = operator( )(K[j]); + for (int j = 0; j < T::nea; j++) + for (int k = j + 1; k < T::nea; k++) { + int &i1 = iv[j]; + int &i2 = iv[k]; + longedge = Rd(vertice[i1], vertice[i2]).norme( ); + if (longedge > precispt) hmin = min(hmin, longedge); } + } - - if (verbosity > 5) { - cout << " longmini_box" << longmini_box << endl; - cout << " hmin =" << hmin << endl; - } + if (verbosity > 5) { + cout << " longmini_box" << longmini_box << endl; + cout << " hmin =" << hmin << endl; + } + + assert(hmin < longmini_box); + if (verbosity > 5) cout << " Norme2(bmin-bmax)=" << Norme2(bmin - bmax) << endl; + + // assertion pour la taille de l octree + assert(hmin > Norme2(bmin - bmax) / 1e9); + + double hseuil = hmin / 1000.; + if (verbosity > 3) cout << " hseuil=" << hseuil << endl; + + V *vv = new V[nv]; + GTree *gtree = new GTree(vv, bmin, bmax, 0); + + if (verbosity > 2) { + cout << " -- taille de la boite " << endl; + cout << "\t" << bmin.x << " " << bmin.y << " " << bmin.z << endl; + cout << "\t" << bmax.x << " " << bmax.y << " " << bmax.z << endl; + } + + // creation of octree + for (int i = 0; i < nv; i++) { + const V &vi(vertice[i]); + V *pvi = gtree->ToClose(vi, hseuil); + if (!pvi) { + vv[new_nv].x = vi.x; + vv[new_nv].y = vi.y; + vv[new_nv].z = vi.z; + vv[new_nv].lab = vi.lab; + ind_nv_t[new_nv] = i; + old2new[i] = new_nv; + gtree->Add(vv[new_nv]); + new_nv++; + } + // treatment of multiple vertice made in sameElement + else + old2new[i] = pvi - vv; + } + delete gtree; + delete[] vv; + } + + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >:: + + clean_mesh(double precis_mesh, int &nv, int &nt, int &nbe, V *(&v), T *(&t), B *(&b), bool removeduplicate, bool rebuildboundary, int orientation) { - assert(hmin < longmini_box); - if (verbosity > 5) - cout << " Norme2(bmin-bmax)=" << Norme2(bmin - bmax) << endl; - - // assertion pour la taille de l octree - assert(hmin > Norme2(bmin - bmax) / 1e9); - - - double hseuil = hmin / 1000.; - if (verbosity > 3) - cout << " hseuil=" << hseuil << endl; - - V *vv = new V[nv]; - GTree *gtree = new GTree(vv, bmin, bmax, 0); - - if (verbosity > 2) { - cout << " -- taille de la boite " << endl; - cout << "\t" << bmin.x << " " << bmin.y << " " << bmin.z << endl; - cout << "\t" << bmax.x << " " << bmax.y << " " << bmax.z << endl; - } - - // creation of octree - for (int i = 0; i < nv; i++) { - const V &vi(vertice[i]); - V *pvi = gtree->ToClose(vi, hseuil); - if (!pvi) { - vv[new_nv].x = vi.x; - vv[new_nv].y = vi.y; - vv[new_nv].z = vi.z; - vv[new_nv].lab = vi.lab; - ind_nv_t[new_nv] = i; - old2new[i] = new_nv; - gtree->Add(vv[new_nv]); - new_nv++; - } - // treatment of multiple vertice made in sameElement - else - old2new[i] = pvi - vv; - - } - delete gtree; - delete [] vv; - -} - - -template -void GenericMesh:: - -clean_mesh(double precis_mesh, int &nv, int &nt, int &nbe, V *(&v), T *(&t), B *(&b), bool removeduplicate, bool rebuildboundary, int orientation) { - - // array for the index of new vertices, element, borderelement in the old numbering - int new_nv=0, new_nt=0, new_nbe=0; - // double mes = 0, mesb = 0; - int *ind_nv=new int[nv]; - int *ind_nt=new int[nt]; - int *ind_nbe=new int[nbe]; + int new_nv = 0, new_nt = 0, new_nbe = 0; + // double mes = 0, mesb = 0; + int *ind_nv = new int[nv]; + int *ind_nt = new int[nt]; + int *ind_nbe = new int[nbe]; // mapping old to new vertices index - int *old2new=new int[nv]; + int *old2new = new int[nv]; // clean multiples vertice SameVertex(precis_mesh, v, t, nv, nt, ind_nv, old2new, new_nv); - - if(!removeduplicate) - nv=new_nv; - + + if (!removeduplicate) nv = new_nv; + // clean multiple elements and border elements SameElement(v, t, nt, ind_nt, old2new, new_nt, removeduplicate); SameElement(v, b, nbe, ind_nbe, old2new, new_nbe, removeduplicate); - + // if removeduplicate, must recheck the vertice -> could have some vertex are not at least in one element - - if(removeduplicate) - VertexInElement(v, t, nv, ind_nv, new_nt, ind_nt, old2new); - + + if (removeduplicate) VertexInElement(v, t, nv, ind_nv, new_nt, ind_nt, old2new); + V *vv; - vv=new V[nv]; - - for(int i=0;i= 0 && iv[j] < nv); - } - if (orientation<0 && T::nv>2 ) - nbort++,swap(iv[1], iv[2]); - else if (orientation<0 && T::nv==2 ) - nbort++,swap(iv[0], iv[1]); - - tt[i].set(vv, iv, K.lab); - mes+=tt[i].mesure(); - } - B *bb=0; - if( new_nbe ==0 && rebuildboundary) - { - if(verbosity) cout << "clean_mesh: rebuild boundary mesh from adjacent "<< endl; - - - typedef SortArray IB; - map adj; - int nben =0; - for(int k=0; k= 0 && iv[j] < nv); + } + if (orientation < 0 && T::nv > 2) + nbort++, swap(iv[1], iv[2]); + else if (orientation < 0 && T::nv == 2) + nbort++, swap(iv[0], iv[1]); + + tt[i].set(vv, iv, K.lab); + mes += tt[i].mesure( ); + } + B *bb = 0; + if (new_nbe == 0 && rebuildboundary) { + if (verbosity) cout << "clean_mesh: rebuild boundary mesh from adjacent " << endl; + + typedef SortArray< int, B::nv > IB; + map< IB, long > adj; + int nben = 0; + for (int k = 0; k < nt; ++k) + for (int j = 0; j < T::nea; j++) { + int nn[B::nv]; + for (int i = 0; i < B::nv; ++i) nn[i] = &(tt[k][T::nvadj[j][i]]) - vv; + + IB ib(nn); + if (adj.find(ib) == adj.end( )) // do not exist => new + { + adj[ib] = k * T::nea + j; + ++nben; + } else // exits => internal.. { - int nn[B::nv]; - for(int i=0; i new - { adj[ib]= k*T::nea+j; - ++nben;} - else // exits => internal.. - { adj[ib]=-1; --nben;} + adj[ib] = -1; + --nben; } - if(verbosity) cout << " nb of boundary element " << nben << endl; - bb=new B[nben]; - int ii=0; - for(typename map::iterator i=adj.begin(); i != adj.end(); ++i ) - { - if( i->second >=0 ) - { - int k =i->second /T::nea, j = i->second %T::nea; - int nn[B::nv]; - for(int i=0; i::iterator i = adj.begin( ); i != adj.end( ); ++i) { + if (i->second >= 0) { + int k = i->second / T::nea, j = i->second % T::nea; + int nn[B::nv]; + for (int i = 0; i < B::nv; ++i) nn[i] = &(tt[k][T::nvadj[j][i]]) - vv; + bb[ii++].set(vv, nn, 1); + } + } + ffassert(ii == nben); + nbe = nben; + } else { + nbe = new_nbe; + bb = new B[nbe]; + for (int i = 0; i < nbe; i++) { + int &ie = ind_nbe[i]; const B &K(b[ie]); int iv[B::nv]; - for (int j = 0; j < B::nea ; j++) { - iv[j] = old2new[ &(K[j]) - v]; - assert(iv[j] >= 0 && iv[j] < nv); + for (int j = 0; j < B::nea; j++) { + iv[j] = old2new[&(K[j]) - v]; + assert(iv[j] >= 0 && iv[j] < nv); } - if (orientation<0 && B::nv>=2 )// correct FH juin 2021 do also on B edge (nv==2) - nborb++,swap(iv[(B::nv)-2], iv[(B::nv)-1]); + if (orientation < 0 && B::nv >= 2) // correct FH juin 2021 do also on B edge (nv==2) + nborb++, swap(iv[(B::nv)-2], iv[(B::nv)-1]); bb[i].set(vv, iv, K.lab); - mesb+=bb[i].mesure(); - } - } - if(verbosity>2) - cout << " after clean mesh, nv = " << nv << " nt = " << nt << " nbe = " << nbe - << "\n nb swap orient element" << nbort - << "\n nb swap orient border element" << nborb << endl; - - if (mes<0) { - cerr << " Error of mesh orientation , current orientation = " << orientation << endl; - cerr << " mesure element mesh = " << mes << endl; - cerr << " mesure border mesh = " << mesb << endl; - } - - delete [] v; - delete [] t; - delete [] b; - v=vv; - t=tt; - b=bb; + mesb += bb[i].mesure( ); + } + } + if (verbosity > 2) + cout << " after clean mesh, nv = " << nv << " nt = " << nt << " nbe = " << nbe << "\n nb swap orient element" << nbort << "\n nb swap orient border element" << nborb << endl; + + if (mes < 0) { + cerr << " Error of mesh orientation , current orientation = " << orientation << endl; + cerr << " mesure element mesh = " << mes << endl; + cerr << " mesure border mesh = " << mesb << endl; + } + + delete[] v; + delete[] t; + delete[] b; + v = vv; + t = tt; + b = bb; // rebuild all - BuildBound(); - delete [] TheAdjacencesLink; TheAdjacencesLink=0; BuildAdj(); - delete [] bnormalv; bnormalv=0; Buildbnormalv(); - delete [] ElementConteningVertex; ElementConteningVertex=0; BuildjElementConteningVertex(); - delete gtree; gtree=0; BuildGTree(); - - delete []ind_nv; - delete []ind_nt; - delete []ind_nbe; - delete []old2new; - -} - - - - - - - - -// template -// void GenericMesh::BuildBoundaryElementAdj_V2(const int &nbsurf,int *firstDefSurface, int *labelDefSurface, int *senslabelDefSurface) -// { -// // assert(firstDefSurface.N() == nbsurf+1); -// // assert(labelDefSurface.N() == firstDefSurface[nbsurf]); -// // assert(senslabelDefSurface.N() == firstDefSurface[nbsurf]); - -// // determination des labels des surfaces -// map maplabel; -// int numero_label=0; -// for(int ii=0; ii< firstDefSurface[nbsurf]; ii++){ -// map::const_iterator imap=maplabel.find( abs(labelDefSurface[ii]) ); -// //cout << "K.lab= " << K.lab << endl; -// if(imap == maplabel.end()){ -// maplabel[ abs(labelDefSurface[ii]) ] = numero_label; -// numero_label = numero_label+1; -// } -// } - -// int *nbe_label=new int[numero_label]; -// for(int ii=0; ii< numero_label; ii++) nbe_label[ii] = 0; -// for(int k=0; k::const_iterator imap=maplabel.find( K.lab ); - -// // if(imap == maplabel.end()){ -// // printf("The label %d given for Definition of different surface is not in the border element mesh\n",K.lab); -// // exit(1); -// // } -// // else{ -// nbe_label[(*imap).second]++; -// // } -// } - -// int all_nbe_label=0; -// for(int k=0; k::const_iterator imap=maplabel.find( K.lab ); -// assert(imap != maplabel.end()); -// organisation_be_label[ debut_nbe_label[(*imap).second] + count_nbe_label[(*imap).second] ] = k ; -// count_nbe_label[(*imap).second ]++; -// } - -// for(int ii=0; ii< numero_label; ii++) -// assert( count_nbe_label[ii] == nbe_label[ii] ); - -// delete [] count_nbe_label; - -// for(int isurf=0; isurf < nbsurf; isurf++){ - -// int nbe_surf=0; // number in the surface -// for( int iii=firstDefSurface[isurf]; iii< firstDefSurface[isurf+1];iii++ ){ -// map::const_iterator imap=maplabel.find( abs(labelDefSurface[iii]) ); -// nbe_surf=nbe_surf+nbe_label[ (*imap).second ]; -// } - -// // assert(TheBoundaryElementAdjacencesLink==0); plus tard -// int *TheBoundaryElementAdjacencesLink = new int[B::nea*nbe_surf]; -// HashTable,int> h(B::nea*nbe_surf,nv); -// int nk=0; -// int err=0; -// int sens; - -// int count_sbe; -// int *surf_be = new int[nbe_surf]; - -// count_sbe=0; -// for( int iii=firstDefSurface[isurf]; iii< firstDefSurface[isurf+1];iii++ ){ -// map::const_iterator imap=maplabel.find( abs(labelDefSurface[iii]) ); - -// for( int jjj= debut_nbe_label[(*imap).second]; jjj < debut_nbe_label[(*imap).second+1]; jjj++ ){ -// int k=organisation_be_label[jjj]; -// surf_be[count_sbe] = k; -// count_sbe++; - -// for (int i=0;i a(items( k,i,&sens)); -// sens=sens*senslabelDefSurface[iii]; -// typename HashTable,int>::iterator p= h.find(a); -// if(!p) -// { -// h.add(a,nk); -// TheBoundaryElementAdjacencesLink[nk] = sens*(nk+1); -// } -// else -// { - -// ASSERTION(p->v>=0); -// if( sens*TheBoundaryElementAdjacencesLink[p->v] > 0){ - -// B & K(borderelements[CheckBE(k)]); -// int firstVertex = operator()(K[B::nvadj[i][0]])+1; -// int secondVertex = operator()(K[B::nvadj[i][1]])+1; -// cout << " The edges, defined by vertex is " << firstVertex << "-" << secondVertex << ", is oriented in the same direction in element " << k+1 << -// " and in element "<< 1+surf_be[(p->v/B::nea)] << endl; -// err++; -// } - -// if( abs(TheBoundaryElementAdjacencesLink[p->v]) != 1+p->v ){ - -// B & K(borderelements[CheckBE(k)]); -// int firstVertex = operator()(K[B::nvadj[i][0]])+1; -// int secondVertex = operator()(K[B::nvadj[i][1]])+1; -// cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex << "belong to the three border elements ::" -// << 1+surf_be[(p->v)/B::nea] <<", "<< surf_be[k]+1 <<" and "<< 1+surf_be[(abs(TheBoundaryElementAdjacencesLink[p->v])-1)/B::nea] << endl; -// cout << " The "<< isurf+1 << " Surface contains these edges is not a manifold" << endl; -// err++; -// assert(err==0); -// } - -// TheBoundaryElementAdjacencesLink[nk]=TheBoundaryElementAdjacencesLink[p->v]; -// TheBoundaryElementAdjacencesLink[p->v]=sens*(nk+1); -// } - -// if( err > 10 ) -// exit(1); -// nk++; -// } -// } -// } - -// assert(err==0); -// delete [ ] TheBoundaryElementAdjacencesLink; -// delete [ ] surf_be; -// if(verbosity) cout << "number of adjacents edges " << nk << endl; -// } - -// delete [] organisation_be_label; -// delete [] debut_nbe_label; -// delete [] nbe_label; -// } - - -template -DataFENodeDF GenericMesh::BuildDFNumbering(int ndfon[NbTypeItemElement],int nbequibe,int *equibe) const -{ -/* Numbering in 1d, 2d ok if no manifold object - Warning: wrong in 3d if no manifold object but improble. - nbequibe nb of borderelement with equi boundary condition - for i =0, 2*nbequibe, i+= 2) - - be0= equibe[i]/8 <=> be1=equibe[i+1] /8 - equibe[i]%8 given the permuation p0 compare to sort array. - equibe[i+1]%8 given the permuation p1 compare to sort array. - the numbering of perumation - SetNumPerm(p0,equibe[i+1]%8); - SetNumPerm(p1,equibe[i+1]%8); - - so a level of point with always have: - be0[p0[j]] <==> be1[p1[j]] + BuildBound( ); + delete[] TheAdjacencesLink; + TheAdjacencesLink = 0; + BuildAdj( ); + delete[] bnormalv; + bnormalv = 0; + Buildbnormalv( ); + delete[] ElementConteningVertex; + ElementConteningVertex = 0; + BuildjElementConteningVertex( ); + delete gtree; + gtree = 0; + BuildGTree( ); + + delete[] ind_nv; + delete[] ind_nt; + delete[] ind_nbe; + delete[] old2new; + } + // template + // void GenericMesh::BuildBoundaryElementAdj_V2(const int &nbsurf,int *firstDefSurface, int *labelDefSurface, int *senslabelDefSurface) + // { + // // assert(firstDefSurface.N() == nbsurf+1); + // // assert(labelDefSurface.N() == firstDefSurface[nbsurf]); + // // assert(senslabelDefSurface.N() == firstDefSurface[nbsurf]); + + // // determination des labels des surfaces + // map maplabel; + // int numero_label=0; + // for(int ii=0; ii< firstDefSurface[nbsurf]; ii++){ + // map::const_iterator imap=maplabel.find( abs(labelDefSurface[ii]) ); + // //cout << "K.lab= " << K.lab << endl; + // if(imap == maplabel.end()){ + // maplabel[ abs(labelDefSurface[ii]) ] = numero_label; + // numero_label = numero_label+1; + // } + // } + + // int *nbe_label=new int[numero_label]; + // for(int ii=0; ii< numero_label; ii++) nbe_label[ii] = 0; + // for(int k=0; k::const_iterator imap=maplabel.find( K.lab ); + + // // if(imap == maplabel.end()){ + // // printf("The label %d given for Definition of different surface is not in the border element mesh\n",K.lab); + // // exit(1); + // // } + // // else{ + // nbe_label[(*imap).second]++; + // // } + // } + + // int all_nbe_label=0; + // for(int k=0; k::const_iterator imap=maplabel.find( K.lab ); + // assert(imap != maplabel.end()); + // organisation_be_label[ debut_nbe_label[(*imap).second] + count_nbe_label[(*imap).second] ] = k ; + // count_nbe_label[(*imap).second ]++; + // } + + // for(int ii=0; ii< numero_label; ii++) + // assert( count_nbe_label[ii] == nbe_label[ii] ); + + // delete [] count_nbe_label; + + // for(int isurf=0; isurf < nbsurf; isurf++){ + + // int nbe_surf=0; // number in the surface + // for( int iii=firstDefSurface[isurf]; iii< firstDefSurface[isurf+1];iii++ ){ + // map::const_iterator imap=maplabel.find( abs(labelDefSurface[iii]) ); + // nbe_surf=nbe_surf+nbe_label[ (*imap).second ]; + // } + + // // assert(TheBoundaryElementAdjacencesLink==0); plus tard + // int *TheBoundaryElementAdjacencesLink = new int[B::nea*nbe_surf]; + // HashTable,int> h(B::nea*nbe_surf,nv); + // int nk=0; + // int err=0; + // int sens; + + // int count_sbe; + // int *surf_be = new int[nbe_surf]; + + // count_sbe=0; + // for( int iii=firstDefSurface[isurf]; iii< firstDefSurface[isurf+1];iii++ ){ + // map::const_iterator imap=maplabel.find( abs(labelDefSurface[iii]) ); + + // for( int jjj= debut_nbe_label[(*imap).second]; jjj < debut_nbe_label[(*imap).second+1]; jjj++ ){ + // int k=organisation_be_label[jjj]; + // surf_be[count_sbe] = k; + // count_sbe++; + + // for (int i=0;i a(items( k,i,&sens)); + // sens=sens*senslabelDefSurface[iii]; + // typename HashTable,int>::iterator p= h.find(a); + // if(!p) + // { + // h.add(a,nk); + // TheBoundaryElementAdjacencesLink[nk] = sens*(nk+1); + // } + // else + // { + + // ASSERTION(p->v>=0); + // if( sens*TheBoundaryElementAdjacencesLink[p->v] > 0){ + + // B & K(borderelements[CheckBE(k)]); + // int firstVertex = operator()(K[B::nvadj[i][0]])+1; + // int secondVertex = operator()(K[B::nvadj[i][1]])+1; + // cout << " The edges, defined by vertex is " << firstVertex << "-" << secondVertex << ", is oriented in the same direction in element " << k+1 << + // " and in element "<< 1+surf_be[(p->v/B::nea)] << endl; + // err++; + // } + + // if( abs(TheBoundaryElementAdjacencesLink[p->v]) != 1+p->v ){ + + // B & K(borderelements[CheckBE(k)]); + // int firstVertex = operator()(K[B::nvadj[i][0]])+1; + // int secondVertex = operator()(K[B::nvadj[i][1]])+1; + // cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex << "belong to the three border elements ::" + // << 1+surf_be[(p->v)/B::nea] <<", "<< surf_be[k]+1 <<" and "<< 1+surf_be[(abs(TheBoundaryElementAdjacencesLink[p->v])-1)/B::nea] << endl; + // cout << " The "<< isurf+1 << " Surface contains these edges is not a manifold" << endl; + // err++; + // assert(err==0); + // } + + // TheBoundaryElementAdjacencesLink[nk]=TheBoundaryElementAdjacencesLink[p->v]; + // TheBoundaryElementAdjacencesLink[p->v]=sens*(nk+1); + // } + + // if( err > 10 ) + // exit(1); + // nk++; + // } + // } + // } + + // assert(err==0); + // delete [ ] TheBoundaryElementAdjacencesLink; + // delete [ ] surf_be; + // if(verbosity) cout << "number of adjacents edges " << nk << endl; + // } + + // delete [] organisation_be_label; + // delete [] debut_nbe_label; + // delete [] nbe_label; + // } + + template< typename T, typename B, typename V > + DataFENodeDF GenericMesh< T, B, V >::BuildDFNumbering(int ndfon[NbTypeItemElement], int nbequibe, int *equibe) const { + /* Numbering in 1d, 2d ok if no manifold object + Warning: wrong in 3d if no manifold object but improble. + nbequibe nb of borderelement with equi boundary condition + for i =0, 2*nbequibe, i+= 2) + + be0= equibe[i]/8 <=> be1=equibe[i+1] /8 + equibe[i]%8 given the permuation p0 compare to sort array. + equibe[i+1]%8 given the permuation p1 compare to sort array. + the numbering of perumation + SetNumPerm(p0,equibe[i+1]%8); + SetNumPerm(p1,equibe[i+1]%8); + + so a level of point with always have: + be0[p0[j]] <==> be1[p1[j]] + + + */ + const GenericMesh &Th(*this); + int nnodeK = T::NbNodes(ndfon); + int *p = 0, *pp = 0; + unsigned int tinfty = std::numeric_limits< unsigned int >::max( ); + + const int nkv = T::nv; + const int nkf = T::nf; + const int nke = T::ne; + const int nkt = T::nt; + const int nbev = B::nv; + const int nbef = B::nf; + const int nbee = B::ne; + const int nk[] = {nkv, nke, nkf, nkt}; + int MaxNbNodePerElement = 0; + int MaxNbDFPerElement = 0; + int nbNodes = 0; + int NbOfDF = 0; + int n = 0; + int minndf = 100000000; + int maxndf = 0; + int nbnzero = 0; + for (int dd = 0; dd < NbTypeItemElement; ++dd) + if (ndfon[dd]) { - */ - const GenericMesh & Th(*this); - int nnodeK = T::NbNodes(ndfon); - int *p = 0, *pp=0; - unsigned int tinfty=std::numeric_limits::max() ; - - const int nkv= T::nv; - const int nkf= T::nf; - const int nke= T::ne; - const int nkt= T::nt; - const int nbev= B::nv; - const int nbef= B::nf; - const int nbee= B::ne; - const int nk[]={nkv,nke,nkf,nkt}; - int MaxNbNodePerElement=0; - int MaxNbDFPerElement=0; - int nbNodes=0; - int NbOfDF=0; - int n=0; - int minndf=100000000; - int maxndf=0; - int nbnzero=0; - for (int dd=0;dd 0); + const int nkeys = 4 + 6 + 4 + 1; + assert(nnodeK <= nkeys); + + if (nodearevertices) { + nbNodes = nv; + NbOfDF = nbNodes * ndfon[0]; + } else { + p = new int[nnodeK * nt]; + typedef SortArray< unsigned int, 2 > Key; + + Key keys[nkeys * 2]; + int keysdim[nkeys * 2]; + + int of = Th.nv + 10; // Modif FH 28/05/2013 + int ndim[NbTypeItemElement] = {0, 0, 0, 0}; + NbOfDF = 0; { + HashTable< Key, int > h(nnodeK * nt, of + nt); + int nbmaxeq = 1 + nnodeK * nbequibe; + int nbhasheq = nbequibe ? of + nt : 1; + HashTable< Key, Key > equi(nbmaxeq, nbhasheq); + // constuction of item translation for + if (verbosity > 9) cout << " nb equi be : " << nbequibe << endl; + for (int ieq = 0, keq = 0; keq < nbequibe; ++keq) { + int p1[nbev], p2[nbev]; + int v1[nbev] = { }, v2[nbev] = { }; + int be1 = equibe[ieq] / 8, pe1 = equibe[ieq++] % 8; + int be2 = equibe[ieq] / 8, pe2 = equibe[ieq++] % 8; + int itemb1, k1 = BoundaryElement(be1, itemb1); + int itemb2, k2 = BoundaryElement(be2, itemb2); + const B &b1(Th.be(be1)); + const B &b2(Th.be(be2)); + SetNumPerm< nbev >(pe1, p1); + SetNumPerm< nbev >(pe2, p2); + int m = 0; + for (int i = 0; i < nbev; ++i) { + v1[i] = Th(b1[p1[i]]); + v2[i] = Th(b2[p2[i]]); + } - nbnzero++; - minndf=Min(minndf,ndfon[dd]); - maxndf=Max(maxndf,ndfon[dd]); - MaxNbDFPerElement += ndfon[dd]*nk[dd]; - MaxNbNodePerElement += nk[dd]; + int dimb = B::RdHat::d; + if (ndfon[dimb]) { // simple border element + } + if (ndfon[0]) + for (int i = 0; i < nbev; ++i) { + keysdim[m] = 0, keys[m++] = Key(v1[i], tinfty); + keysdim[m] = 0, keys[m++] = Key(v2[i], tinfty); + if (verbosity > 100) cout << be1 << " " << be2 << " " << v1[i] << " <--> " << v2[i] << " / " << Th(v1[i]) << " <=> " << Th(v2[i]) << endl; + } + if (ndfon[1]) + for (int i = 0; i < nbee; ++i) { + keysdim[m] = 1, keys[m++] = Key(v1[B::nvedge[i][0]], v1[B::nvedge[i][1]]); + keysdim[m] = 1, keys[m++] = Key(v2[B::nvedge[i][0]], v2[B::nvedge[i][1]]); + } + if (ndfon[2] && dimb == 2) { + assert(nbef == 1 && nkf != 1); + int ii; + keysdim[m] = 2, keys[m++] = Key(k1 + of, ElementAdj(k1, ii = itemb1) + of); + keysdim[m] = 2, keys[m++] = Key(k2 + of, ElementAdj(k2, ii = itemb2) + of); + } + + for (int j = 0; j < m;) { + int i0 = j++, i1 = j++; + if (keys[i1] < keys[i0]) swap(keys[i0], keys[i1]); + if (keys[i0] < keys[i1]) // not equal ... Add nov. 2014 + equi.add(keys[i0], keys[i1]); + } + } + + // to find the final equivalent key ... + // in change of chaibe of equi key + for (int it = 0, change = 1; change; it++) { + change = 0; + ffassert(it++ < 100); + for (typename HashTable< Key, Key >::iterator qe, pe = equi.begin( ); pe != equi.end( ); ++pe) { + if (verbosity > 9999) cout << pe->k << " " << pe->v << endl; + ffassert(pe->k < pe->v); + qe = equi.find(pe->v); + if (qe) { + if (verbosity > 9999) cout << pe->k << " " << pe->v << " <=> " << qe->k << endl; + + change++; + ffassert(qe->k < qe->v); + pe->v = qe->v; + } + } + if (verbosity > 5) cout << " -- BuildDF: iteration in final equivalent " << it << " nb change " << change << endl; + } + + // construction of nodes numbering + + // ------------ + + for (int k = 0; k < nt; ++k) { + const T &K(Th[k]); + int m = 0; + if (ndfon[0]) // node on vertex + for (int i = 0; i < nkv; ++i) keysdim[m] = 0, keys[m++] = Key(Th(K[i]), tinfty); + if (ndfon[1]) // node on Edge + for (int i = 0; i < nke; ++i) keysdim[m] = 1, keys[m++] = Key(Th(K[T::nvedge[i][0]]), Th(K[T::nvedge[i][1]])); + if (ndfon[2]) // node on Face + { + if (nkf == 1) + keysdim[m] = 2, keys[m++] = Key(k + of, tinfty); + else + for (int ii, i = 0; i < nkf; ++i) keysdim[m] = 2, keys[m++] = Key(k + of, ElementAdj(k, ii = i) + of); + } + if (ndfon[3]) // node on Tet + if (nkt == 1) keysdim[m] = 3, keys[m++] = Key(k + of, tinfty); + + if (k < 0) { + for (int i = 0; i < nke; ++i) cout << " e= " << T::nvedge[i][0] << " " << T::nvedge[i][1] << endl; + cout << ndfon[0] << " " << ndfon[1] << " " << ndfon[2] << " " << ndfon[3] << ": " + << " m = " << m << " " << nnodeK << " " << T::nv << " " << T::ne << " " << T::nf << " " << T::nt << endl; + } + assert(m == nnodeK); + for (int i = 0; i < m; i++) { + Key ki = keys[i], kio = ki; + typename HashTable< Key, Key >::iterator pe = equi.find(ki); + if (pe) { + ki = pe->v; + } + typename HashTable< Key, int >::iterator pk = h.find(ki); + if (!pk) { + pk = h.add(ki, nbNodes++); + NbOfDF += ndfon[keysdim[i]]; + } + if (verbosity > 100 && pe) cout << kio << " -> " << pe->k << " :: " << pk->v << endl; + p[n++] = pk->v; + ndim[keysdim[i]]++; + } + } } - bool constndfpernode = minndf == maxndf; - bool nodearevertices = ( nbnzero ==1 && ndfon[0]) && nbequibe==0 ; + if (verbosity) { + cout << " -- Build Nodes/DF on mesh : n.v. " << nv << ", n. elmt. " << nt << ", n b. elmt. " << nbe << endl; + cout << " nb of Nodes " << nbNodes << " nb of DoF " << NbOfDF << " DFon=" << ndfon[0] << ndfon[1] << ndfon[2] << ndfon[3] << endl; + } + if (!constndfpernode) { + pp = new int[nbNodes + 1]; + int kk = 0, nn = 0; + for (int k = 0; k < nt; ++k) + for (int i = 0; i < nnodeK; i++) pp[p[nn++]] = ndfon[keysdim[i]]; + ; + for (int n = 0; n < nbNodes; ++n) { + int ndfn = pp[n]; + pp[n] = kk; + kk += ndfn; + } + pp[nbNodes] = NbOfDF; // add last + assert(kk == NbOfDF); + } + } + return DataFENodeDF(ndfon, nt, nbNodes, NbOfDF, p, pp, MaxNbNodePerElement, MaxNbDFPerElement); + } + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::BuildBound( ) { + mes = 0.; + mesb = 0.; - assert(maxndf>0); - const int nkeys=4+6+4+1; - assert(nnodeK<= nkeys); + for (int i = 0; i < nt; i++) mes += this->elements[i].mesure( ); - if(nodearevertices) - { - nbNodes=nv; - NbOfDF=nbNodes*ndfon[0]; + for (int i = 0; i < nbe; i++) mesb += this->be(i).mesure( ); + + if (vertices && (nv > 0)) { + Pmin = vertices[0]; + Pmax = vertices[0]; + for (int i = 1; i < nv; ++i) { + Pmin = Minc(Pmin, vertices[i]); + Pmax = Maxc(Pmax, vertices[i]); + } } - else - { - p = new int[nnodeK*nt]; - typedef SortArray Key; + if (verbosity > 3) + cout << " -- GMesh" << V::d << " , n V: " << nv << " , n Elm: " << nt << " , n B Elm: " << nbe << "mes " << mes << " " << mesb << " , bb: (" << Pmin << ") , (" << Pmax << ")\n"; + } - Key keys[nkeys*2]; - int keysdim[nkeys*2]; + template< typename T, typename B, typename V > + void GenericMesh< T, B, V >::Buildbnormalv( ) { + const int nkv = T::nv; - int of = Th.nv+10;// Modif FH 28/05/2013 - int ndim[NbTypeItemElement]={0,0,0,0}; - NbOfDF=0; - { - HashTable h(nnodeK*nt,of+nt); - int nbmaxeq = 1+nnodeK*nbequibe; - int nbhasheq = nbequibe ? of+nt : 1; - HashTable equi(nbmaxeq,nbhasheq); - // constuction of item translation for - if(verbosity>9) - cout << " nb equi be : " << nbequibe << endl; - for(int ieq=0,keq=0;keq(pe1,p1); - SetNumPerm(pe2,p2); - int m=0; - for(int i=0;i100) cout << be1<< " " << be2 << " " << v1[i] << " <--> " << v2[i] - << " / " << Th(v1[i]) << " <=> " << Th(v2[i]) << endl; - } - if( ndfon[1] ) - for(int i=0;i::iterator qe,pe=equi.begin() ; pe != equi.end(); ++pe) - { - if( verbosity>9999) cout << pe->k << " " << pe->v << endl; - ffassert( pe->k < pe->v); - qe=equi.find(pe->v); - if(qe) - { - if( verbosity>9999) cout << pe->k << " " << pe->v << " <=> " << qe->k <k < qe->v); - pe->v = qe->v; - } - - - } - if(verbosity>5) - cout << " -- BuildDF: iteration in final equivalent " << it << " nb change " << change << endl; - } - - - // construction of nodes numbering - - // ------------ - - for(int k=0;k::iterator pe= equi.find(ki); - if(pe) { ki= pe->v; } - typename HashTable::iterator pk= h.find(ki); - if(!pk) - { - pk = h.add(ki,nbNodes++); - NbOfDF += ndfon[keysdim[i]]; - } - if(verbosity>100 && pe ) cout << kio << " -> " << pe->k << " :: " << pk->v << endl; - p[n++] = pk->v; - ndim[keysdim[i]]++; - - } - } + if (bnormalv) { + return; + } + int nb = 0; + for (int k = 0; k < nt; k++) + for (int i = 0; i < nkv; i++) { + int ii(i), kk; + kk = ElementAdj(k, ii); + if (kk < 0 || kk == k) nb++; } - if(verbosity) - { cout << " -- Build Nodes/DF on mesh : n.v. " << nv << ", n. elmt. " << nt << ", n b. elmt. " < -void GenericMesh::Buildbnormalv() -{ - const int nkv= T::nv; - - if (bnormalv) - {return;} - int nb=0; - for (int k=0;k4) - cout << " number of real boundary element " << nb << endl; - bnormalv= new Rd[nb]; - Rd *n=bnormalv; - for (int k=0;k -Serialize GenericMesh::serialize() const -{ + if (verbosity > 4) cout << " number of real boundary element " << nb << endl; + bnormalv = new Rd[nb]; + Rd *n = bnormalv; + for (int k = 0; k < nt; k++) + for (int i = 0; i < nea; i++) { + int ii, kk = ElementAdj(k, ii = i); + if (kk < 0 || kk == k) { + Element &K(elements[k]); + Rd N; //=K.n(i); + for (int j = 0; j < nva; ++j) { + K[Element::nvadj[i][j]].SetNormal(n, N); + } + } + } + assert(n - bnormalv <= nb); + } + + static const char *GenericMesh_magicmesh = "GenericMesh v0"; + template< typename T, typename B, typename V > + Serialize GenericMesh< T, B, V >::serialize( ) const { const int nve = T::nv; const int nvbe = B::nv; const int d = Rd::d; - long long l=0; + long long l = 0; l += sizeof(long long); - l += 7*sizeof(int); // add bordermesh - l += nt*(sizeof(int)*(nve + 1)); - l += nv*( sizeof(int) + sizeof(double)*d); - l += nbe*(sizeof(int)*(nvbe+1)); - if(verbosity>3) - cout << "Serialize gmesh " << l << " " << nve << " " << nvbe << endl; - Serialize serialized(l,GenericMesh_magicmesh); + l += 7 * sizeof(int); // add bordermesh + l += nt * (sizeof(int) * (nve + 1)); + l += nv * (sizeof(int) + sizeof(double) * d); + l += nbe * (sizeof(int) * (nvbe + 1)); + if (verbosity > 3) cout << "Serialize gmesh " << l << " " << nve << " " << nvbe << endl; + Serialize serialized(l, GenericMesh_magicmesh); // cout << l << magicmesh << endl; - size_t pp=0; - int havebordermesh=0; // by defaut, no border mesh in the genericmesh + size_t pp = 0; + int havebordermesh = 0; // by defaut, no border mesh in the genericmesh serialized.put(pp, l); - serialized.put( pp,d); - serialized.put( pp,havebordermesh); - serialized.put( pp,nve); - serialized.put( pp,nvbe); - serialized.put( pp,nt); - serialized.put( pp,nv); - serialized.put( pp,nbe); - if (verbosity>9) - cout << " GenericMesh Serialized : " << l << " " << nt << " " << nv << " " << nbe << endl; - for (int i=0;i 9) cout << " GenericMesh Serialized : " << l << " " << nt << " " << nv << " " << nbe << endl; + for (int i = 0; i < nv; i++) { + for (int j = 0; j < d; ++j) serialized.put(pp, vertices[i][j]); + serialized.put(pp, vertices[i].lab); + } + for (int i = 0; i < nt; i++) { - const Element & K(elements[i]); - for(int j=0;j - GenericMesh::GenericMesh(const Serialize &serialized) - : nt(0),nv(0),nbe(0),nadjnomanifold(0), mes(0.),mesb(0.) , - vertices(0),elements(0),borderelements(0),bnormalv(0), - TheAdjacencesLink(0),BoundaryElementHeadLink(0), - ElementConteningVertex(0), gtree(0),gdfb(0) + } - { - const int nve = T::nv; - const int nvbe = B::nv; - const int d = Rd::d; + /* GenericMesh() + : nt(0),nv(0),nbe(0), mes(0.),mesb(0.) , + vertices(0),elements(0),borderelements(0),bnormalv(0), + TheAdjacencesLink(0),BoundaryElementHeadLink(0), + ElementConteningVertex(0), gtree(0) + {} + */ + template< typename T, typename B, typename V > + GenericMesh< T, B, V >::GenericMesh(const Serialize &serialized) + : nt(0), nv(0), nbe(0), nadjnomanifold(0), mes(0.), mesb(0.), vertices(0), elements(0), borderelements(0), bnormalv(0), TheAdjacencesLink(0), BoundaryElementHeadLink(0), ElementConteningVertex(0), + gtree(0), gdfb(0) + + { + const int nve = T::nv; + const int nvbe = B::nv; + const int d = Rd::d; int havebordermesh; - int dd,nnve,nnvbe,nnt,nnv,nnbe; - long long l=0; - size_t pp=0; - serialized.get(pp, l); - serialized.get( pp,dd); - serialized.get( pp,havebordermesh); - serialized.get( pp,nnve); - serialized.get( pp,nnvbe); - serialized.get( pp,nnt); - serialized.get( pp,nnv); - serialized.get( pp,nnbe); - ffassert(d==dd && nve == nnve && nvbe == nnvbe); - set(nnv,nnt,nnbe); - for (int i=0;i - void SameElement( TypeVert *vertice, TypeGenericElement *list, int nelt, int *(&ind_nv_t), int *old2new, int &new_nelt, bool removeduplicate) { - - new_nelt=0; - static const int nk=TypeGenericElement::nv; - int iv[nk]; - - HashTable,int> h(nk*nelt,nelt); - - int *originmulti=new int [nelt]; - - int originTypeGenericElement=0; - int multiTypeGenericElement=0; - int *indice=new int [nelt]; - - for (int i=0;i a(iv,&sens); - typename HashTable,int>::iterator p= h.find(a); - // check multiple element - // 1/ keep the original - if (!commonValue(a)) { // if iv[0] != iv[1] (!= iv[2] != iv[3]) - if(!p) { - h.add(a,new_nelt); - indice[new_nelt]=i; - new_nelt++; - } - // or 2/ rm all multiples or keep the orinal - else { - originmulti[i]=p->v; // the double elt the current - multiTypeGenericElement++; - - if(removeduplicate && originmulti[p->v]==-1) { // the origin elt - originmulti[p->v]=p->v; - originTypeGenericElement++; - } - } - } - } - // rebuild the index list if remove all multiples - if(removeduplicate) { - int cmp=0; - for(int i=0;i2) - cout << "no duplicate elements: "<< cmp << " and remove " << multiTypeGenericElement << " multiples elements, corresponding to " << originTypeGenericElement << " original elements " << endl; - + int dd, nnve, nnvbe, nnt, nnv, nnbe; + long long l = 0; + size_t pp = 0; + serialized.get(pp, l); + serialized.get(pp, dd); + serialized.get(pp, havebordermesh); + serialized.get(pp, nnve); + serialized.get(pp, nnvbe); + serialized.get(pp, nnt); + serialized.get(pp, nnv); + serialized.get(pp, nnbe); + ffassert(d == dd && nve == nnve && nvbe == nnvbe); + set(nnv, nnt, nnbe); + for (int i = 0; i < nv; i++) { + for (int j = 0; j < d; ++j) serialized.get(pp, vertices[i][j]); + serialized.get(pp, vertices[i].lab); + } + mes = 0.; + for (int i = 0; i < nt; i++) { + int ii[nve], lab; + for (int j = 0; j < nve; ++j) serialized.get(pp, ii[j]); + serialized.get(pp, lab); + mes += elements[i].set(vertices, ii, lab).mesure( ); + } + mesb = 0; + for (int i = 0; i < nbe; i++) { + int ii[nvbe], lab; + for (int j = 0; j < nvbe; ++j) serialized.get(pp, ii[j]); + serialized.get(pp, lab); + mesb += borderelements[i].set(vertices, ii, lab).mesure( ); + } + assert(pp == serialized.size( )); + } + + template< typename TypeGenericElement, typename TypeVert > + void SameElement(TypeVert *vertice, TypeGenericElement *list, int nelt, int *(&ind_nv_t), int *old2new, int &new_nelt, bool removeduplicate) { + + new_nelt = 0; + static const int nk = TypeGenericElement::nv; + int iv[nk]; + + HashTable< SortArray< int, nk >, int > h(nk * nelt, nelt); + + int *originmulti = new int[nelt]; + + int originTypeGenericElement = 0; + int multiTypeGenericElement = 0; + int *indice = new int[nelt]; + + for (int i = 0; i < nelt; i++) { + originmulti[i] = -1; + indice[i] = -1; + } + + for (int i = 0; i < nelt; i++) { + + const TypeGenericElement &K(list[i]); + for (int j = 0; j < nk; j++) iv[j] = old2new[&(K[j]) - vertice]; // vertice of element in new numbering + int sens; + SortArray< int, nk > a(iv, &sens); + typename HashTable< SortArray< int, nk >, int >::iterator p = h.find(a); + // check multiple element + // 1/ keep the original + if (!commonValue(a)) { // if iv[0] != iv[1] (!= iv[2] != iv[3]) + if (!p) { + h.add(a, new_nelt); + indice[new_nelt] = i; + new_nelt++; } + // or 2/ rm all multiples or keep the orinal else { - for(int i=0;i2) - cout << " Warning, the mesh could contain multiple same elements, keep a single copy in mesh...option removemulti in the operator mesh is avalaible" << endl; + originmulti[i] = p->v; // the double elt the current + multiTypeGenericElement++; + + if (removeduplicate && originmulti[p->v] == -1) { // the origin elt + originmulti[p->v] = p->v; + originTypeGenericElement++; + } + } + } + } + // rebuild the index list if remove all multiples + if (removeduplicate) { + int cmp = 0; + for (int i = 0; i < nelt; i++) { + if (originmulti[i] == -1) { + ind_nv_t[cmp] = i; + cmp++; } - delete[] originmulti; - delete[] indice; - + } + assert((nelt - originTypeGenericElement - multiTypeGenericElement) == cmp); + new_nelt = cmp; + if (verbosity > 2) + cout << "no duplicate elements: " << cmp << " and remove " << multiTypeGenericElement << " multiples elements, corresponding to " << originTypeGenericElement << " original elements " << endl; + + } else { + for (int i = 0; i < nelt; i++) ind_nv_t[i] = indice[i]; + if (verbosity > 2) cout << " Warning, the mesh could contain multiple same elements, keep a single copy in mesh...option removemulti in the operator mesh is avalaible" << endl; } - -} + delete[] originmulti; + delete[] indice; + } + +} // namespace Fem2D #if defined(__clang__) && defined(__has_warning) #if __has_warning("-Wundefined-var-template") #pragma clang diagnostic pop diff --git a/src/femlib/HashMatrix.cpp b/src/femlib/HashMatrix.cpp index 6a0e8a05f..abf389b1c 100644 --- a/src/femlib/HashMatrix.cpp +++ b/src/femlib/HashMatrix.cpp @@ -4,64 +4,73 @@ // F. hecht // version v0 ... -int WhichMatrix(istream & f) -{ - string line; - while ( isspace(f.peek())) - f.get(); - if ( f.peek() =='#' ) - { - line=""; - while ( f.good() ) - { - char c=f.get(); - if(c=='\n' || c=='\r') { break;} - line += c; - } - if( line.find("(Morse)") != std::string::npos) - return 2; // morse - - else if( line.find("(COO)") != std::string::npos) - return 3; // morse - - return 0; +int WhichMatrix(istream &f) { + string line; + while (isspace(f.peek( ))) f.get( ); + if (f.peek( ) == '#') { + line = ""; + while (f.good( )) { + char c = f.get( ); + if (c == '\n' || c == '\r') { + break; + } + line += c; } - return 0; -} + if (line.find("(Morse)") != std::string::npos) + return 2; // morse + else if (line.find("(COO)") != std::string::npos) + return 3; // morse -template -void HashMatrix::HeapSort(I *ii,I *jj, R *aij,long n) -{ - long l,j,r,i; - I criti,critj; - R crita; -#define HM__criteq(i) criti=ii[i],critj=jj[i], crita=aij[i] -#define HM__eqcrit(i) ii[i]=criti,jj[i]=critj, aij[i]=crita -#define HM__eqij(i,j) ii[i]=ii[j],jj[i]=jj[j], aij[i]=aij[j] -#define HM__cmpij(i,j) ( ii[i] != ii[j] ? ii[i] < ii[j] : jj[i] < jj[j]) -#define HM__cmpcrit(j) ( criti != ii[j] ? criti < ii[j] : critj < jj[j]) - - if( n <= 1) return; - l = n/2 + 1; - r = n; - while (1) { // label 2 - if(l <= 1 ) { // label 20 - HM__criteq(r-1);//crit = c[r]; - HM__eqij(r-1,0); - --r; //c[r--] = c[1]; - if ( r == 1 ) { HM__eqcrit(0); /*c[1]=crit;*/ return;} - } else {--l; HM__criteq(l-1);}// crit = c[--l]; - j=l; - while (1) {// label 4 - i=j; - j=2*j; - if (j>r) {HM__eqcrit(i-1);/*c[i]=crit;*/break;} // L8 -> G2 - if ((j G2 - } + return 0; + } + return 0; +} + +template< class I, class R > +void HashMatrix< I, R >::HeapSort(I *ii, I *jj, R *aij, long n) { + long l, j, r, i; + I criti, critj; + R crita; +#define HM__criteq(i) criti = ii[i], critj = jj[i], crita = aij[i] +#define HM__eqcrit(i) ii[i] = criti, jj[i] = critj, aij[i] = crita +#define HM__eqij(i, j) ii[i] = ii[j], jj[i] = jj[j], aij[i] = aij[j] +#define HM__cmpij(i, j) (ii[i] != ii[j] ? ii[i] < ii[j] : jj[i] < jj[j]) +#define HM__cmpcrit(j) (criti != ii[j] ? criti < ii[j] : critj < jj[j]) + + if (n <= 1) return; + l = n / 2 + 1; + r = n; + while (1) { // label 2 + if (l <= 1) { // label 20 + HM__criteq(r - 1); // crit = c[r]; + HM__eqij(r - 1, 0); + --r; // c[r--] = c[1]; + if (r == 1) { + HM__eqcrit(0); /*c[1]=crit;*/ + return; + } + } else { + --l; + HM__criteq(l - 1); + } // crit = c[--l]; + j = l; + while (1) { // label 4 + i = j; + j = 2 * j; + if (j > r) { + HM__eqcrit(i - 1); /*c[i]=crit;*/ + break; + } // L8 -> G2 + if ((j < r) && (HM__cmpij(j - 1, j))) j++; // L5 + if (HM__cmpcrit(j - 1)) + HM__eqij(i - 1, j - 1); // c[i]=c[j]; // L6+1 G4 + else { + HM__eqcrit(i - 1); /*c[i]=crit;*/ + break; + } // L8 -> G2 } + } #undef HM__criteq #undef HM__eqcrit #undef HM__eqij @@ -69,1392 +78,1159 @@ void HashMatrix::HeapSort(I *ii,I *jj, R *aij,long n) #undef HM__cmpcrit } -template -void HashMatrix::setdiag(const KN_ & d) -{ - for(int ii=0; iin; ++ii) - diag(ii)=d[ii]; -} - -template -void HashMatrix::getdiag( KN_ & d) const -{ - for(int ii=0; iin; ++ii) - d[ii]=diag(ii); -} - -template -R HashMatrix::pscal(R *x,R *y,I sx,I sy) -{ - R s=0; - if( fortran) - { - x -= fortran; - y -= fortran; - } - if(half > 0) - for (size_t k=0; k -typename HashMatrix::uniquecodeInt HashMatrix::CodeIJ() const { - uniquecodeInt code=this->n; - code ^=roll64(this->n,0); - code ^=roll64(this->m,24); - code ^=roll64(nnz, 48); - for(size_t k=0,kk=0; k< nnz;++k) - { - code^=roll64(i[k],++kk); - code^=roll64(j[k],++kk); - } - return code; +template< class I, class R > +void HashMatrix< I, R >::setdiag(const KN_< R > &d) { + for (int ii = 0; ii < this->n; ++ii) diag(ii) = d[ii]; } -template -HashMatrix::HashMatrix(I nn,I mm,I nnnz,int halff) -: VirtualMatrix(nn,mm), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -// trans(false), -half(halff), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) -{ - Increaze(nnnz); +template< class I, class R > +void HashMatrix< I, R >::getdiag(KN_< R > &d) const { + for (int ii = 0; ii < this->n; ++ii) d[ii] = diag(ii); } -template -HashMatrix::HashMatrix(istream & f,int cas): -VirtualMatrix(0,0), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -// trans(false), -half(0), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) -{ - if(cas ==-1) cas= WhichMatrix(f) ; - // eat lines with # - string line; - int k=0; - while ( isspace(f.peek())) - f.get(); - while ( f.peek() =='#' ) - { - line=""; - while ( f.good() ) - { - char c=f.get(); - if(c=='\n' || c=='\r') { break;} - line += c; - } - if( f.peek()=='\n' || f.peek()=='\r') f.get(); - if(verbosity>9) - cout << " -- Matrx: "<< k << " :" << line << " cas " << cas << endl; - k++; +template< class I, class R > +R HashMatrix< I, R >::pscal(R *x, R *y, I sx, I sy) { + R s = 0; + if (fortran) { + x -= fortran; + y -= fortran; + } + if (half > 0) + for (size_t k = 0; k < nnz; ++i) { + if (i[k] != j[k]) + s += conj(x[i[k] * sx]) * aij[k] * y[j[k] * sy] + conj(x[j[k] * sx]) * (half == 1 ? conj(aij[k]) : aij[k]) * y[i[k] * sy]; + else + s += conj(x[i[k] * sx]) * aij[k] * y[j[k] * sy]; } - if(cas== 2) - { - I rn,rm; - int rsymetrique; - size_t rnbcoef; - ffassert(f.good() ); - f >> rn >> rm >> rsymetrique >>rnbcoef; - - if(verbosity>3) - cout << " -- Read Mat: " << this->n << " x " << this->m << " sym : " << rsymetrique << " nnz=" << rnbcoef <=0 && rm>=0 && rnbcoef>=0 ); - resize(rn,rm,rnbcoef); - half =rsymetrique; - I ii,jj; - - R aaij; - - for (size_t kk =0;kk> ii >> jj >> aaij; - ffassert(f.good() ); - operator()(ii-1,jj-1) = aaij; - } + else + for (size_t k = 0; k < nnz; ++i) s += conj(x[i[k] * sx]) * aij[k] * y[j[k] * sy]; + return s; +} + +template< class I, class R > +typename HashMatrix< I, R >::uniquecodeInt HashMatrix< I, R >::CodeIJ( ) const { + uniquecodeInt code = this->n; + code ^= roll64(this->n, 0); + code ^= roll64(this->m, 24); + code ^= roll64(nnz, 48); + for (size_t k = 0, kk = 0; k < nnz; ++k) { + code ^= roll64(i[k], ++kk); + code ^= roll64(j[k], ++kk); + } + return code; +} + +template< class I, class R > +HashMatrix< I, R >::HashMatrix(I nn, I mm, I nnnz, int halff) + : VirtualMatrix< I, R >(nn, mm), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), + // trans(false), + half(halff), state(unsorted), type_state(type_HM), nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) { + Increaze(nnnz); +} + +template< class I, class R > +HashMatrix< I, R >::HashMatrix(istream &f, int cas) + : VirtualMatrix< I, R >(0, 0), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), + // trans(false), + half(0), state(unsorted), type_state(type_HM), nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) { + if (cas == -1) cas = WhichMatrix(f); + // eat lines with # + string line; + int k = 0; + while (isspace(f.peek( ))) f.get( ); + while (f.peek( ) == '#') { + line = ""; + while (f.good( )) { + char c = f.get( ); + if (c == '\n' || c == '\r') { + break; + } + line += c; } - else if(cas== 3) - { - I nn,mm,f77, sstate, tstate; - int hhalf; - size_t nnnz; - f >> nn >> mm >> nnnz >> hhalf >> f77 >> sstate >> tstate ; - ffassert(f.good() && nn>0 && mm>0 && nnnz>0 ); - resize(nn,mm,nnnz); - half =hhalf; - for(size_t kk=0; kk < nnnz; ++kk) - { - I ii,jj; - R aaij; - f >> ii >> jj >> aaij ; - ffassert(f.good() ); - operator()(ii-f77,jj-f77) = aaij; - } - + if (f.peek( ) == '\n' || f.peek( ) == '\r') f.get( ); + if (verbosity > 9) cout << " -- Matrx: " << k << " :" << line << " cas " << cas << endl; + k++; + } + if (cas == 2) { + I rn, rm; + int rsymetrique; + size_t rnbcoef; + ffassert(f.good( )); + f >> rn >> rm >> rsymetrique >> rnbcoef; + + if (verbosity > 3) cout << " -- Read Mat: " << this->n << " x " << this->m << " sym : " << rsymetrique << " nnz=" << rnbcoef << endl; + ffassert(f.good( ) && rn >= 0 && rm >= 0 && rnbcoef >= 0); + resize(rn, rm, rnbcoef); + half = rsymetrique; + I ii, jj; + + R aaij; + + for (size_t kk = 0; kk < rnbcoef; ++kk) { + f >> ii >> jj >> aaij; + ffassert(f.good( )); + operator( )(ii - 1, jj - 1) = aaij; } - else { - cerr << " Unknown matrix type" << endl << endl; - ffassert(0); + } else if (cas == 3) { + I nn, mm, f77, sstate, tstate; + int hhalf; + size_t nnnz; + f >> nn >> mm >> nnnz >> hhalf >> f77 >> sstate >> tstate; + ffassert(f.good( ) && nn > 0 && mm > 0 && nnnz > 0); + resize(nn, mm, nnnz); + half = hhalf; + for (size_t kk = 0; kk < nnnz; ++kk) { + I ii, jj; + R aaij; + f >> ii >> jj >> aaij; + ffassert(f.good( )); + operator( )(ii - f77, jj - f77) = aaij; } - - -} - -template -HashMatrix::HashMatrix(KNM_ F,double threshold) -: VirtualMatrix(F.N(),F.M()), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(0), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) -{ - Increaze(); - for(int ii=0; ii threshold) - operator()(ii,jj)=Fiijj; - } -} -// PB .... -template -HashMatrix::HashMatrix(I nn,I mm,bool Half) -: VirtualMatrix(nn,mm), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(Half), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) - -{ - Increaze(max(nn,mm)*4); -} - -template -HashMatrix::HashMatrix(const HashMatrix& A) -: VirtualMatrix (A), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(A.half), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) -{ - Increaze(A.nnz); - operator=(A); -} - -template template -HashMatrix::HashMatrix(const HashMatrix& A) -: VirtualMatrix (A.n,A.m), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(A.half), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),mindiffij(1),maxdiffij(-1),tgv(0), ntgv(0) -{ - HashMatrix::set(A.n,A.m,A.half,A.nnz,A.i,A.j,A.aij,fortran); -} - -template template -HashMatrix::HashMatrix(const HashMatrix& A, R (*ff)(RR) ) -: VirtualMatrix (A.n,A.m), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(A.half), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),tgv(0), ntgv(0) -{ - HashMatrix::set(A.n,A.m,A.half,A.nnz,A.i,A.j,A.aij,fortran,ff); -} - -template -HashMatrix::HashMatrix(I nn,const R *diag) -: VirtualMatrix (nn,nn), nnz(0),nnzmax(0),nhash(0),nbcollision(0),nbfind(0),matmulcpu(0.),i(0),j(0),p(0),aij(0), -head(0), next(0), -half(0), state(unsorted),type_state(type_HM), -nbsort(0),sizep(0),lock(0), fortran(0) , -re_do_numerics(0),re_do_symbolic(0),tgv(0), ntgv(0) -{ - Increaze(nn); - for(int k=0;k +HashMatrix< I, R >::HashMatrix(KNM_< R > F, double threshold) + : VirtualMatrix< I, R >(F.N( ), F.M( )), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(0), state(unsorted), + type_state(type_HM), nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) -template -void HashMatrix::setp(I sp) { - - if(sp == 0) - { - delete [] p; - p=0; - } - - else if( sp != sizep) - { - if(p) delete [] p; - p = new I[sp]; - - } - if(p ) - for(I ii=0; ii999) cout << " HashMatrix:: setp "<< this << " sp= " << sp << " p "<< p << " / " << (sp != sizep) << endl; - ffassert( (sp==0) == (p==0) ); - sizep=sp; - -} -template -void HashMatrix::RemoveHalf(int cas,double tol) -{ - size_t kk=0; - if( cas <=0) // remove L, keep U case - { - for(size_t k=0; k tol && ( i[k] <= j[k] ) ) // fix PHT Oct 2021 -- not used for now - { - i[kk] = i[k]; - j[kk] = j[k]; - aij[kk] = aij[k]; - ++kk; - } - } - else - { - for(size_t k=0; k tol && ( i[k] >= j[k] ) ) // fix PHT Oct 2021 -- not used for now - { - i[kk] = i[k]; - j[kk] = j[k]; - aij[kk] = aij[k]; - ++kk; - } + Increaze( ); + for (int ii = 0; ii < F.N( ); ++ii) + for (int jj = 0; jj < F.M( ); ++jj) { + R Fiijj = F(ii, jj); + if (abs(Fiijj) > threshold) operator( )(ii, jj) = Fiijj; } - half= cas==0; - size_t nrt = nnz - kk; - if (verbosity>2) - cout << " RemoveHalf " << cas << " tol " << tol << " , remove term : " << nrt << " half =" << half << endl; - nnz = kk; - if(nrt) Increaze(kk); - else ReHash(); - state= unsorted; - type_state=type_COO; - -} - -template -void HashMatrix::resize(I nn, I mm,size_t nnnz, double tol , int sym ) -{ - bool goodsym = sym*half > 0 || (!sym && !half); - bool conjug = (half*sym < 0); - mm= mm ? mm : nn; - if( nn == this->n && mm == this->m && nnz == nnnz && goodsym && tol <0) return ; - ffassert(half >= 0 && sym >= 0); // TODO - this->m=mm; - this->n=nn; - this->N=nn; - this->M=mm; - R mxt =0; - size_t kk=0; - if( (nn>0) && (mm >0)) { - for(size_t k=0; k n && j[k] < this->m && t > tol && (!sym || i[k] >= j[k] ) ) - { - i[kk] = i[k]; - j[kk] = j[k]; - aij[kk] = (i[k]!=j[k] && conjug ?conj(aij[k]) : aij[k]); - ++kk; - } - } - if (sym < 0) swap(i,j); - } - if(verbosity>9 ) cout << "HashMatrix::resize: new nnz = " << kk << " " << nnz << " " << " sym " << sym << " "<< tol << " " << nn << " " << mm << endl; - half = (half ? half : sym); - nnnz = max(nnnz,kk); - bool rresize = (nnnz < 0.8*nnz) || ((nnnz > 1.2*nnz)) ; - nnz = kk; // forget after value ... - if(rresize) Increaze(nnnz); - else ReHash(); - state= unsorted; - type_state=type_COO; -} -template -void HashMatrix::SymmetrizePattern() -{ - ffassert( this->n==this->m); - for(size_t k=0; k +HashMatrix< I, R >::HashMatrix(I nn, I mm, bool Half) + : VirtualMatrix< I, R >(nn, mm), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(Half), state(unsorted), type_state(type_HM), + nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) -template -void HashMatrix::clear() { - nbsort=0; - re_do_numerics=1; - re_do_symbolic=1; - half=0; - lock=0; - fortran = 0; - state=unsorted; - type_state = type_HM; - mindiffij=1; - maxdiffij=-1; - tgv=0; - ntgv=0; - setp(0); // unset - if(nnz) - { - nnz=0; - nbcollision=0; - for (size_t h=0;h +HashMatrix< I, R >::HashMatrix(const HashMatrix &A) + : VirtualMatrix< I, R >(A), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(A.half), state(unsorted), type_state(type_HM), + nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) { + Increaze(A.nnz); + operator=(A); +} + +template< class I, class R > +template< class II > +HashMatrix< I, R >::HashMatrix(const HashMatrix< II, R > &A) + : VirtualMatrix< I, R >(A.n, A.m), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(A.half), state(unsorted), + type_state(type_HM), nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), mindiffij(1), maxdiffij(-1), tgv(0), ntgv(0) { + HashMatrix< I, R >::set< II >(A.n, A.m, A.half, A.nnz, A.i, A.j, A.aij, fortran); +} + +template< class I, class R > +template< class II, class RR > +HashMatrix< I, R >::HashMatrix(const HashMatrix< II, RR > &A, R (*ff)(RR)) + : VirtualMatrix< I, R >(A.n, A.m), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(A.half), state(unsorted), + type_state(type_HM), nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), tgv(0), ntgv(0) { + HashMatrix< I, R >::set< II, RR >(A.n, A.m, A.half, A.nnz, A.i, A.j, A.aij, fortran, ff); +} + +template< class I, class R > +HashMatrix< I, R >::HashMatrix(I nn, const R *diag) + : VirtualMatrix< I, R >(nn, nn), nnz(0), nnzmax(0), nhash(0), nbcollision(0), nbfind(0), matmulcpu(0.), i(0), j(0), p(0), aij(0), head(0), next(0), half(0), state(unsorted), type_state(type_HM), + nbsort(0), sizep(0), lock(0), fortran(0), re_do_numerics(0), re_do_symbolic(0), tgv(0), ntgv(0) { + Increaze(nn); + for (int k = 0; k < nn; ++k) operator( )(k, k) = diag[k]; +} + +template< class I, class R > +void HashMatrix< I, R >::setp(I sp) { + + if (sp == 0) { + delete[] p; + p = 0; + } + + else if (sp != sizep) { + if (p) delete[] p; + p = new I[sp]; + } + if (p) + for (I ii = 0; ii < sp; ++ii) p[ii] = -1; + if (verbosity > 999) cout << " HashMatrix:: setp " << this << " sp= " << sp << " p " << p << " / " << (sp != sizep) << endl; + ffassert((sp == 0) == (p == 0)); + sizep = sp; +} +template< class I, class R > +void HashMatrix< I, R >::RemoveHalf(int cas, double tol) { + size_t kk = 0; + if (cas <= 0) // remove L, keep U case + { + for (size_t k = 0; k < nnz; ++k) + if (abs(aij[k]) > tol && (i[k] <= j[k])) // fix PHT Oct 2021 -- not used for now + { + i[kk] = i[k]; + j[kk] = j[k]; + aij[kk] = aij[k]; + ++kk; + } + } else { + for (size_t k = 0; k < nnz; ++k) + if (abs(aij[k]) > tol && (i[k] >= j[k])) // fix PHT Oct 2021 -- not used for now + { + i[kk] = i[k]; + j[kk] = j[k]; + aij[kk] = aij[k]; + ++kk; + } + } + half = cas == 0; + size_t nrt = nnz - kk; + if (verbosity > 2) cout << " RemoveHalf " << cas << " tol " << tol << " , remove term : " << nrt << " half =" << half << endl; + nnz = kk; + if (nrt) + Increaze(kk); + else + ReHash( ); + state = unsorted; + type_state = type_COO; +} + +template< class I, class R > +void HashMatrix< I, R >::resize(I nn, I mm, size_t nnnz, double tol, int sym) { + bool goodsym = sym * half > 0 || (!sym && !half); + bool conjug = (half * sym < 0); + mm = mm ? mm : nn; + if (nn == this->n && mm == this->m && nnz == nnnz && goodsym && tol < 0) return; + ffassert(half >= 0 && sym >= 0); // TODO + this->m = mm; + this->n = nn; + this->N = nn; + this->M = mm; + R mxt = 0; + size_t kk = 0; + if ((nn > 0) && (mm > 0)) { + for (size_t k = 0; k < nnz; ++k) { + double t = abs(aij[k]); + if (i[k] < this->n && j[k] < this->m && t > tol && (!sym || i[k] >= j[k])) { + i[kk] = i[k]; + j[kk] = j[k]; + aij[kk] = (i[k] != j[k] && conjug ? conj(aij[k]) : aij[k]); + ++kk; + } } - -} - -template -void HashMatrix::setfortran(int yes) -{ -// trop casse geule - int shift = yes-fortran; - if( shift == 0) return ; - CheckUnLock("setfortran"); - for( int k = 0; k 9) cout << "HashMatrix::resize: new nnz = " << kk << " " << nnz << " " << " sym " << sym << " " << tol << " " << nn << " " << mm << endl; + half = (half ? half : sym); + nnnz = max(nnnz, kk); + bool rresize = (nnnz < 0.8 * nnz) || ((nnnz > 1.2 * nnz)); + nnz = kk; // forget after value ... + if (rresize) + Increaze(nnnz); + else + ReHash( ); + state = unsorted; + type_state = type_COO; +} +template< class I, class R > +void HashMatrix< I, R >::SymmetrizePattern( ) { + ffassert(this->n == this->m); + for (size_t k = 0; k < nnz; ++k) npij(j[k], i[k]); +} + +template< class I, class R > +void HashMatrix< I, R >::clear( ) { + nbsort = 0; + re_do_numerics = 1; + re_do_symbolic = 1; + half = 0; + lock = 0; + fortran = 0; + state = unsorted; + type_state = type_HM; + mindiffij = 1; + maxdiffij = -1; + tgv = 0; + ntgv = 0; + setp(0); // unset + if (nnz) { + nnz = 0; + nbcollision = 0; + for (size_t h = 0; h < nhash; ++h) head[h] = empty; + } +} + +template< class I, class R > +void HashMatrix< I, R >::setfortran(int yes) { + // trop casse geule + int shift = yes - fortran; + if (shift == 0) return; + CheckUnLock("setfortran"); + for (int k = 0; k < nnz; ++k) { + i[k] += shift; + j[k] += shift; + } + if (type_CSC == type_state) + for (int k = 0; k <= this->m; ++k) p[k] += shift; + else if (type_CSR == type_state) + for (int k = 0; k <= this->n; ++k) p[k] += shift; + fortran = yes; + // do the shift + return; +} + +template< class I, class R > +template< typename T > +void HashMatrix< I, R >::HMresize(T *&t, size_t no, size_t nn) { + if (no != nn || t == 0) { + T *tt = new T[nn]; + if (t) + for (size_t i = 0; i < no; ++i) tt[i] = t[i]; + if (t) delete[] t; + t = tt; + } +} + +template< class I, class R > +bool HashMatrix< I, R >::do2Triangular(bool lower) { + ffassert(half); // + size_t nc = 0; + if (lower) + for (size_t k = 0; k < nnz; ++k) { + if ((i[k] < j[k])) // Upper + ++nc, swap(i[k], j[k]); } - if ( type_CSC == type_state) - for (int k=0; k<= this->m; ++k) - p[k] += shift; - else if ( type_CSR == type_state) - for (int k=0; k<= this->n; ++k) - p[k] += shift; - fortran = yes ; - // do the shift - return ; -} - - - - -template template -void HashMatrix::HMresize(T *&t,size_t no,size_t nn) -{ - if( no != nn || t==0) - { - T * tt= new T[nn]; - if(t) - for(size_t i=0; i< no; ++i) - tt[i]= t[i]; - if(t) delete [] t; - t=tt; + else + for (size_t k = 0; k < nnz; ++k) { + if ((i[k] > j[k])) // Lower + ++nc, swap(i[k], j[k]); } -} - - -template bool HashMatrix::do2Triangular(bool lower) -{ - ffassert(half); // - size_t nc=0; - if( lower ) - for(size_t k=0; k< nnz; ++k) - { - if( (i[k] < j[k]) ) // Upper - ++nc,swap(i[k],j[k]); - } + if (nc) { + ReHash( ); + state = unsorted; + } + return nc; +} +template< class I, class R > +int HashMatrix< I, R >::IsTrianglulare( ) const { + size_t nU, nL = 0, nD = 0; + for (size_t k = 0; k < nnz; ++k) { + if (i[k] < j[k]) + ++nU; // 0,10 + else if (i[k] == j[k]) + ++nD; // 10,10 else - for(size_t k=0; k< nnz; ++k) - { - if( (i[k] > j[k]) ) // Lower - ++nc,swap(i[k],j[k]); - } - if( nc) - { - ReHash(); - state=unsorted; - } - return nc; -} -template int HashMatrix::IsTrianglulare() const -{ - size_t nU, nL=0,nD=0; - for(size_t k=0; k< nnz; ++k) - { - if( i[k] < j[k] ) ++nU;// 0,10 - else if( i[k] == j[k] ) ++nD;// 10,10 - else ++nL;// 10,0 - } - // 3 => no sym - // 1 nU==0 => Trian Lower (no upper term) - // 2 nL==0 => Trian Upper (no upper term) - return 2*!nL + !nU ; -} -template -void HashMatrix::dotranspose(bool doconj) -{ - swap(i,j); - swap(this->n,this->m); - swap(this->N,this->M); - if(doconj) conj(aij,this->nnz); - ReHash(); - state=unsorted; -} -template -void HashMatrix::Renumbering(I nn,I mm,KN_ ii,KN_ jj) -{ - //Do B_ii(i),jj(j) : A_i,j - size_t kk=0; - for(size_t k=0; k=0 && j1 >=0 && i1 n=nn; - this->m=mm; - this->N=nn; - this->M=mm; - state=unsorted; - - RemoveDoubleij(kk); // remove double term - - - -} -template -void HashMatrix::RemoveDoubleij(int kkk) -{ - nnz=kkk; - COO(); - I ip=-1,jp=-1; - long kk=-1; - for(size_t k=0; k4) - cout << " HashMatrix::RemoveDoubleij remove "<< nnz - kk << " coef "<< endl; - Increaze(kk,kk); -} -template -void HashMatrix::RenumberingInv(KN_ II,KN_ JJ) -{ - //Do B_(i),(j) : A_ii(i),jj(j) - I n = this->n, m = this->m; - I nn= II.N(), mm= JJ.N(); - const I minus1 =-1; - KN ii(n,minus1), jj(m,minus1); - // build inversion - int notinjection=0; - // build invertion .. - for( I l=0; l= 0 && IIl < n) - { - if(ii[IIl]>=0 ) notinjection =1; - ii[IIl]=l; - } - } - for( int l=0; l= 0 && IIl < m) - { - if(jj[IIl]>=0 ) notinjection |=2 ; - jj[IIl]=l; - } - } - if( !notinjection) - { - cerr << " HashMatrix::Renumbering not injection " < -void HashMatrix::Increaze(size_t nnzxnew,size_t newnnz) -{ - size_t mnx =(size_t)max(this->n,this->m); - if(newnnz==0) newnnz = nnz; - else nnz=newnnz; - if( nnzxnew==0) { - nnzxnew = max(max(mnx*2,newnnz),(size_t) (nnzmax*1.2) ); - } - - size_t nzzx = nnzxnew; - double nnzl = min(max(1.,double(nzzx)/mnx),50.);// bof bof !!!! FH - size_t nh = mnx*nnzl; - if(verbosity>999) cout << "HMresize "<< nzzx << " " < -void HashMatrix::ReHash() -{ - - for(size_t h=0;h no sym + // 1 nU==0 => Trian Lower (no upper term) + // 2 nL==0 => Trian Upper (no upper term) + return 2 * !nL + !nU; +} +template< class I, class R > +void HashMatrix< I, R >::dotranspose(bool doconj) { + swap(i, j); + swap(this->n, this->m); + swap(this->N, this->M); + if (doconj) conj(aij, this->nnz); + ReHash( ); + state = unsorted; +} +template< class I, class R > +void HashMatrix< I, R >::Renumbering(I nn, I mm, KN_< I > ii, KN_< I > jj) { + // Do B_ii(i),jj(j) : A_i,j + size_t kk = 0; + for (size_t k = 0; k < nnz; ++k) { + I i1 = ii[i[k]], j1 = jj[i[k]]; + if (i1 >= 0 && j1 >= 0 && i1 < nn && j1 < mm) // coef existe { - Hash h= hash(i[k],j[k]); - next[k]=head[h]; - head[h]=k; + i[kk] = i1; + j[kk] = j1; + aij[kk++] = aij[k]; } -} - - -template -HashMatrix::~HashMatrix() -{ - if(nbfind && verbosity>4) - cout << " ~HashMatrix: Mean collision in hash: " << (double) nbcollision/ nbfind << " " - << this << " rank: "<< mpirank << " matmul " << matmulcpu << "s" << endl; - - delete [] i; - delete [] j; - delete [] aij; - delete [] next; - delete [] head; - if(p) delete [] p; - type_state=type_isdeleted;// Mark Matrix is type_isdeleted - i =0; - j=0; - aij=0; - next=0; - head =0; - this->n=-1234567890;// stupide number - this->m=-1234567801;// stupide number - this->nnz=-1234567802; - // because the solver is some time deleted after ... -} - -template -void HashMatrix::Sortij() -{ - - if( state != sorted_ij) - { - CheckUnLock("Sortij"); - HeapSort(i,j,aij,nnz); - ReHash(); - nbsort++; - state = sorted_ij; + } + nnz = kk; + this->n = nn; + this->m = mm; + this->N = nn; + this->M = mm; + state = unsorted; + + RemoveDoubleij(kk); // remove double term +} +template< class I, class R > +void HashMatrix< I, R >::RemoveDoubleij(int kkk) { + nnz = kkk; + COO( ); + I ip = -1, jp = -1; + long kk = -1; + for (size_t k = 0; k < nnz; ++k) { + if (ip != i[k] && jp != j[k]) { // new term + ++kk; + i[kk] = ip = i[k]; + j[kk] = jp = j[k]; + aij[kk] = aij[k]; + } else + aij[kk] = +aij[k]; + } + if (verbosity > 4) cout << " HashMatrix::RemoveDoubleij remove " << nnz - kk << " coef " << endl; + Increaze(kk, kk); +} +template< class I, class R > +void HashMatrix< I, R >::RenumberingInv(KN_< I > II, KN_< I > JJ) { + // Do B_(i),(j) : A_ii(i),jj(j) + I n = this->n, m = this->m; + I nn = II.N( ), mm = JJ.N( ); + const I minus1 = -1; + KN< I > ii(n, minus1), jj(m, minus1); + // build inversion + int notinjection = 0; + // build invertion .. + for (I l = 0; l < nn; ++l) { + I IIl = II[l]; + if (IIl >= 0 && IIl < n) { + if (ii[IIl] >= 0) notinjection = 1; + ii[IIl] = l; } -} - -template -void HashMatrix::Sortji() -{ - if( state != sorted_ji) - { - CheckUnLock("Sortji"); - HeapSort(j,i,aij,nnz); - ReHash(); - state = sorted_ji; - nbsort++; + } + for (int l = 0; l < mm; ++l) { + I IIl = JJ[l]; + if (IIl >= 0 && IIl < m) { + if (jj[IIl] >= 0) notinjection |= 2; + jj[IIl] = l; } -} - -template -void HashMatrix::set(I nn,I mm,int hhalf,size_t nnnz, I *ii, I*jj, R *aa,int f77,int tcsr) -{ -// tcsr >0 => CSR ii pointer size nn+1, jj col size nnnz -// tcrs <0 = CSC jj pointer size mm+1, ii row size nnnz -// tcsr == 0 => COO - - clear(); - this->n=nn; - this->m=mm; - this->N=nn; - this->M=mm; - fortran=f77; - half=hhalf; - Increaze(nnnz); - nnz=nnnz; - if(tcsr >=0) // input CSR - HMcopy(j,jj,nnnz);// copy of col - if(tcsr <=0) // input CSC - HMcopy(i,ii,nnnz);// copy of row - if( tcsr>0)// input CSR - for(I ip=0; ip< nn; ++ip) - for(I k=ii[ip]; k -HashMatrix & HashMatrix::operator=(const HashMatrix &A) -{ - if( (const void*) this == (const void*) & A) return *this; - set(A.n,A.m,A.half,A.nnz,A.i,A.j,A.aij,A.fortran); - return *this; -} - -template -HashMatrix & HashMatrix::operator+=(const HashMatrix &A) -{ - Add(&A); - return *this; -} - -template -HashMatrix & HashMatrix::operator-=(const HashMatrix &A) -{ - Add(&A,R(-1.)); - return *this; -} - -template -void HashMatrix::Add(const HashMatrix *PA,R coef,bool trans, I ii00,I jj00) -{ - const HashMatrix &A=*PA; - I nn=A.n,mm=A.m; - I *ii=A.i; - I *jj=A.j; - size_t Annz= A.nnz; ; - if( trans ) swap(nn,mm),swap(ii,jj); - nn = max(this->n,nn); - mm = max(this->m,mm); - resize(nn,mm); - if( (const void*) this == (const void*) & A && ii00==0 && jj00==0 && !trans ) - for(I k=0; k < nnz; ++k) - aij[k] += coef*aij[k]; - else - { ffassert((const void*) this != (const void*) & A); // not the same matrix - if ( this->half!= A.half ) MATERROR(1,"+= on diff type of mat of type HashMatrix "); - - for(size_t k=0;k -void Addto(HashMatrix *P0, const HashMatrix *PA,R (*f)(K) ,bool trans, I ii00,I jj00) -{ - const HashMatrix &A=*PA; - I nn=A.n,mm=A.m; - I *ii=A.i; - I *jj=A.j; - size_t Annz= A.nnz; ; - if( trans ) swap(nn,mm),swap(ii,jj); - nn = max(P0->n,nn); - mm = max(P0->m,mm); - P0->resize(nn,mm); - - { - if( (const void*) P0 == (const void*) & A && ii00==0 && jj00==0 && !trans ) - for(I k=0; k < P0->nnz; ++k) - P0->aij[k] += f(A.aij[k]); - else - { ffassert((const void*) P0 != (const void*) & A); // not the same matrix - if ( P0->half!= A.half ) MATERROR(1,"+= on diff type of mat of type HashMatrix "); - - for(size_t k=0;koperator()(ii[k]+ii00,jj[k]+jj00) += f(A.aij[k]); - } - } -} - - - - -template -void HashMatrix::operator*=(R v) -{ - re_do_numerics=1; - for(int k=0; k < nnz; ++k) - aij[k] *= v; - -} - -template -void HashMatrix::operator=(const R & v) -{ - re_do_numerics=1; - for(int k=0; k < nnz; ++k) - aij[k] = v; - -} - -template -void HashMatrix::HM() -{ - re_do_numerics++; - re_do_symbolic++; - setp(0); - type_state=type_HM; - -} - -template -void HashMatrix::COO() -{ - if(verbosity>999) cout << " HashMatrix:: COO "<< this->n << " x " << this->m << " "<< p << " / "<< sizep << endl; - Sortij(); - setp(0); - type_state=type_COO; -} - - -template -void HashMatrix::COO(I *& IA, I *& IJ, R *& A) -{ - Sortij(); - IA=i; - IJ=j; - A=aij; - setp(0); - type_state=type_COO; -} - - -template -void HashMatrix::CSR(I *& IA, I *& JA, R *& A) -{ - Sortij(); - Buildp(this->n,i,type_CSR); - IA=p; - JA=j; - A=aij; - type_state=type_CSR; -} - -template -void HashMatrix::CSR() -{ - if(verbosity>999) cout << " HashMatrix:: csr() " << state << " " << sorted_ij<< endl; - Sortij(); - Buildp(this->n,i,type_CSR); - type_state=type_CSR; -} - - -template -void HashMatrix::CSC() -{ - Sortji(); - Buildp(this->m,j,type_CSC); - type_state=type_CSC; -} - - -template -void HashMatrix::CSC(I *& JA, I *& IA, R *& A) -{ - - Sortji(); - Buildp(this->m,j,type_CSC); - JA=p; - IA=i; - A=aij; - type_state=type_CSC; -} - - - -template -size_t HashMatrix::SortLU(int U) -{ // put U or L at the top and return the nnz term associated - if( half) { - - } - size_t nnzu =0,nnzd=0; - for(int k=0; k i <= j - else if (i[k]==j[k]) ++nnzd; - size_t nnzl=nnz-nnzu-nnzd; - cout << "SortLU " << U << ":s " << nnzl << " "<< nnzd << " " << nnzu << endl; - size_t kR=0; - if(U>0) - { - size_t kU=0L,k; - - for( k=0; k i <= j - // verif - cout << " SortLU "<< kU << " " << nnzu+nnzd << " " << k << endl; - - for( k=0; kj[k]); - - kR = kU; - assert(kU == nnzu+nnzd); - } - else - { - size_t kL=0L,k; - - for( k=0; k=j[k]) - { - std::swap(aij[k],aij[kL]); - std::swap(i[k],i[kL]); - std::swap(j[k],j[kL++]); - } - - kR = kL; - - - } - ReHash(); + } + if (!notinjection) { + cerr << " HashMatrix::Renumbering not injection " << notinjection << endl; + ffassert(0); // to do + } + Renumbering(nn, mm, ii, jj); +} + +template< class I, class R > +void HashMatrix< I, R >::Increaze(size_t nnzxnew, size_t newnnz) { + size_t mnx = (size_t)max(this->n, this->m); + if (newnnz == 0) + newnnz = nnz; + else + nnz = newnnz; + if (nnzxnew == 0) { + nnzxnew = max(max(mnx * 2, newnnz), (size_t)(nnzmax * 1.2)); + } + + size_t nzzx = nnzxnew; + double nnzl = min(max(1., double(nzzx) / mnx), 50.); // bof bof !!!! FH + size_t nh = mnx * nnzl; + if (verbosity > 999) cout << "HMresize " << nzzx << " " << nnzxnew << " mpirank" << mpirank << " " << this << endl; + HMresize(i, nnz, nzzx); + HMresize(j, nnz, nzzx); + HMresize(aij, nnz, nzzx); + HMresize(next, 0, nzzx); + HMresize(head, 0, nh); + nnzmax = nzzx; + nhash = nh; + ReHash( ); + state = unsorted; +} + +template< class I, class R > +void HashMatrix< I, R >::ReHash( ) { + + for (size_t h = 0; h < nhash; ++h) head[h] = empty; + for (size_t k = 0; k < nnz; ++k) { + Hash h = hash(i[k], j[k]); + next[k] = head[h]; + head[h] = k; + } +} + +template< class I, class R > +HashMatrix< I, R >::~HashMatrix( ) { + if (nbfind && verbosity > 4) cout << " ~HashMatrix: Mean collision in hash: " << (double)nbcollision / nbfind << " " << this << " rank: " << mpirank << " matmul " << matmulcpu << "s" << endl; + + delete[] i; + delete[] j; + delete[] aij; + delete[] next; + delete[] head; + if (p) delete[] p; + type_state = type_isdeleted; // Mark Matrix is type_isdeleted + i = 0; + j = 0; + aij = 0; + next = 0; + head = 0; + this->n = -1234567890; // stupide number + this->m = -1234567801; // stupide number + this->nnz = -1234567802; + // because the solver is some time deleted after ... +} + +template< class I, class R > +void HashMatrix< I, R >::Sortij( ) { + + if (state != sorted_ij) { + CheckUnLock("Sortij"); + HeapSort(i, j, aij, nnz); + ReHash( ); nbsort++; - state += addstateLU(U) ; - return kR; - -} - -template -size_t HashMatrix::CSC_U(I *& JA, I *& IA, R *& A) -{ - - if(type_CSC!=type_state) - HeapSort(j,i,aij,nnz); - state=type_CSC; - size_t nnzu=SortLU(1); - Buildp(this->m,j,type_CSC+addstateLU(1),nnzu); - - JA=p; - IA=i; - A=aij; - return nnzu; -} - -template -size_t HashMatrix::CSR_L(I *& IA, I *& JA, R *& A) -{ - if(type_CSR!=type_state) - HeapSort(i,j,aij,nnz); - state=type_CSR; - size_t nnzl=SortLU(-1); - Buildp(this->m,i,type_CSR+addstateLU(-1),nnzl); - - IA=p; - JA=j; - A=aij; - return nnzl; + state = sorted_ij; + } } +template< class I, class R > +void HashMatrix< I, R >::Sortji( ) { + if (state != sorted_ji) { + CheckUnLock("Sortji"); + HeapSort(j, i, aij, nnz); + ReHash( ); + state = sorted_ji; + nbsort++; + } +} + +template< class I, class R > +void HashMatrix< I, R >::set(I nn, I mm, int hhalf, size_t nnnz, I *ii, I *jj, R *aa, int f77, int tcsr) { + // tcsr >0 => CSR ii pointer size nn+1, jj col size nnnz + // tcrs <0 = CSC jj pointer size mm+1, ii row size nnnz + // tcsr == 0 => COO + + clear( ); + this->n = nn; + this->m = mm; + this->N = nn; + this->M = mm; + fortran = f77; + half = hhalf; + Increaze(nnnz); + nnz = nnnz; + if (tcsr >= 0) // input CSR + HMcopy(j, jj, nnnz); // copy of col + if (tcsr <= 0) // input CSC + HMcopy(i, ii, nnnz); // copy of row + if (tcsr > 0) // input CSR + for (I ip = 0; ip < nn; ++ip) + for (I k = ii[ip]; k < ii[ip + 1]; ++k) i[k - f77] = ip + f77; + else if (tcsr < 0) // input CSC + for (I jp = 0; jp < mm; ++jp) + for (I k = jj[jp]; k < jj[jp + 1]; ++k) j[k - f77] = jp + f77; + + HMcopy(aij, aa, nnnz); + ReHash( ); +} + +template< class I, class R > +HashMatrix< I, R > &HashMatrix< I, R >::operator=(const HashMatrix &A) { + if ((const void *)this == (const void *)&A) return *this; + set(A.n, A.m, A.half, A.nnz, A.i, A.j, A.aij, A.fortran); + return *this; +} + +template< class I, class R > +HashMatrix< I, R > &HashMatrix< I, R >::operator+=(const HashMatrix &A) { + Add(&A); + return *this; +} + +template< class I, class R > +HashMatrix< I, R > &HashMatrix< I, R >::operator-=(const HashMatrix &A) { + Add(&A, R(-1.)); + return *this; +} + +template< class I, class R > +void HashMatrix< I, R >::Add(const HashMatrix< I, R > *PA, R coef, bool trans, I ii00, I jj00) { + const HashMatrix< I, R > &A = *PA; + I nn = A.n, mm = A.m; + I *ii = A.i; + I *jj = A.j; + size_t Annz = A.nnz; + ; + if (trans) swap(nn, mm), swap(ii, jj); + nn = max(this->n, nn); + mm = max(this->m, mm); + resize(nn, mm); + if ((const void *)this == (const void *)&A && ii00 == 0 && jj00 == 0 && !trans) + for (I k = 0; k < nnz; ++k) aij[k] += coef * aij[k]; + else { + ffassert((const void *)this != (const void *)&A); // not the same matrix + if (this->half != A.half) MATERROR(1, "+= on diff type of mat of type HashMatrix "); + + for (size_t k = 0; k < Annz; ++k) operator( )(ii[k] + ii00, jj[k] + jj00) += coef * A.aij[k]; + } +} + +template< class I, class R, class K > +void Addto(HashMatrix< I, R > *P0, const HashMatrix< I, K > *PA, R (*f)(K), bool trans, I ii00, I jj00) { + const HashMatrix< I, K > &A = *PA; + I nn = A.n, mm = A.m; + I *ii = A.i; + I *jj = A.j; + size_t Annz = A.nnz; + ; + if (trans) swap(nn, mm), swap(ii, jj); + nn = max(P0->n, nn); + mm = max(P0->m, mm); + P0->resize(nn, mm); + + { + if ((const void *)P0 == (const void *)&A && ii00 == 0 && jj00 == 0 && !trans) + for (I k = 0; k < P0->nnz; ++k) P0->aij[k] += f(A.aij[k]); + else { + ffassert((const void *)P0 != (const void *)&A); // not the same matrix + if (P0->half != A.half) MATERROR(1, "+= on diff type of mat of type HashMatrix "); -template -void HashMatrix::Buildp(I nn,I * IA,int type_m,size_t nnzz) -{ - if(verbosity>999) cout << " HashMatrix:: Buildp"<< this->n<< " x " << this->m << " " << nn << " " << IA<< " " << type_m << " " << nnzz << " / " << nnz << " / p=" << p <=0 ; --k ) - { - p[IA[k]-fortran] = k+fortran; - ffassert( (IA[k]-fortran>=0 ) && (IA[k]-fortran<=nn)); - } - p[nn]=nnzz+fortran; - // remove empty row - for(I ii=nn-1;ii>=0;--ii) - if(p[ii]<0)// empty row - p[ii]=p[ii+1]; - - - - type_state=type_m; - if(verbosity>10) - { - cout << "Buildp p=" << nn<< " type_m =" << type_m << endl; - for(int ii=0;ii<=nn;++ii) - cout << ii << " " << p[ii] << endl; - cout << " end Buildp\n"; - } - + for (size_t k = 0; k < Annz; ++k) P0->operator( )(ii[k] + ii00, jj[k] + jj00) += f(A.aij[k]); } - assert(p); -} - - - -template -typename HashMatrix::Pair HashMatrix::RoworCol(I ii,bool row) -{ - size_t k0=0,k1=nnz-1,k=nnz-1; - I * pp=0; - if(row) - { - if(state != sorted_ij) Sortij(); - pp= i; + } +} + +template< class I, class R > +void HashMatrix< I, R >::operator*=(R v) { + re_do_numerics = 1; + for (int k = 0; k < nnz; ++k) aij[k] *= v; +} + +template< class I, class R > +void HashMatrix< I, R >::operator=(const R &v) { + re_do_numerics = 1; + for (int k = 0; k < nnz; ++k) aij[k] = v; +} + +template< class I, class R > +void HashMatrix< I, R >::HM( ) { + re_do_numerics++; + re_do_symbolic++; + setp(0); + type_state = type_HM; +} + +template< class I, class R > +void HashMatrix< I, R >::COO( ) { + if (verbosity > 999) cout << " HashMatrix:: COO " << this->n << " x " << this->m << " " << p << " / " << sizep << endl; + Sortij( ); + setp(0); + type_state = type_COO; +} + +template< class I, class R > +void HashMatrix< I, R >::COO(I *&IA, I *&IJ, R *&A) { + Sortij( ); + IA = i; + IJ = j; + A = aij; + setp(0); + type_state = type_COO; +} + +template< class I, class R > +void HashMatrix< I, R >::CSR(I *&IA, I *&JA, R *&A) { + Sortij( ); + Buildp(this->n, i, type_CSR); + IA = p; + JA = j; + A = aij; + type_state = type_CSR; +} + +template< class I, class R > +void HashMatrix< I, R >::CSR( ) { + if (verbosity > 999) cout << " HashMatrix:: csr() " << state << " " << sorted_ij << endl; + Sortij( ); + Buildp(this->n, i, type_CSR); + type_state = type_CSR; +} + +template< class I, class R > +void HashMatrix< I, R >::CSC( ) { + Sortji( ); + Buildp(this->m, j, type_CSC); + type_state = type_CSC; +} + +template< class I, class R > +void HashMatrix< I, R >::CSC(I *&JA, I *&IA, R *&A) { + + Sortji( ); + Buildp(this->m, j, type_CSC); + JA = p; + IA = i; + A = aij; + type_state = type_CSC; +} + +template< class I, class R > +size_t HashMatrix< I, R >::SortLU(int U) { // put U or L at the top and return the nnz term associated + if (half) { + } + size_t nnzu = 0, nnzd = 0; + for (int k = 0; k < nnz; ++k) + if (i[k] < j[k]) + ++nnzu; // 1 2 in U => i <= j + else if (i[k] == j[k]) + ++nnzd; + size_t nnzl = nnz - nnzu - nnzd; + cout << "SortLU " << U << ":s " << nnzl << " " << nnzd << " " << nnzu << endl; + size_t kR = 0; + if (U > 0) { + size_t kU = 0L, k; + + for (k = 0; k < nnz; ++k) + if (i[k] <= j[k]) { + std::swap(aij[k], aij[kU]); + std::swap(i[k], i[kU]); + std::swap(j[k], j[kU++]); + } // 1 2 in U => i <= j + // verif + cout << " SortLU " << kU << " " << nnzu + nnzd << " " << k << endl; + + for (k = 0; k < kU; ++k) assert(i[k] <= j[k]); + for (k = kU; k < nnz; ++k) assert(i[k] > j[k]); + + kR = kU; + assert(kU == nnzu + nnzd); + } else { + size_t kL = 0L, k; + + for (k = 0; k < nnz; ++k) + if (i[k] >= j[k]) { + std::swap(aij[k], aij[kL]); + std::swap(i[k], i[kL]); + std::swap(j[k], j[kL++]); + } + + kR = kL; + } + ReHash( ); + nbsort++; + state += addstateLU(U); + return kR; +} + +template< class I, class R > +size_t HashMatrix< I, R >::CSC_U(I *&JA, I *&IA, R *&A) { + + if (type_CSC != type_state) HeapSort(j, i, aij, nnz); + state = type_CSC; + size_t nnzu = SortLU(1); + Buildp(this->m, j, type_CSC + addstateLU(1), nnzu); + + JA = p; + IA = i; + A = aij; + return nnzu; +} + +template< class I, class R > +size_t HashMatrix< I, R >::CSR_L(I *&IA, I *&JA, R *&A) { + if (type_CSR != type_state) HeapSort(i, j, aij, nnz); + state = type_CSR; + size_t nnzl = SortLU(-1); + Buildp(this->m, i, type_CSR + addstateLU(-1), nnzl); + + IA = p; + JA = j; + A = aij; + return nnzl; +} + +template< class I, class R > +void HashMatrix< I, R >::Buildp(I nn, I *IA, int type_m, size_t nnzz) { + if (verbosity > 999) cout << " HashMatrix:: Buildp" << this->n << " x " << this->m << " " << nn << " " << IA << " " << type_m << " " << nnzz << " / " << nnz << " / p=" << p << endl; + if (nnzz == 0) nnzz = nnz; + if (type_m != type_state) { + + assert(state == type_m); + + setp(nn + 1); + // int shift = fortran; + std::fill(p, p + nn + 1, -1); + p[nn] = fortran + (I)nnzz; + for (I k = I(nnzz) - 1; k >= 0; --k) { + p[IA[k] - fortran] = k + fortran; + ffassert((IA[k] - fortran >= 0) && (IA[k] - fortran <= nn)); } - else - { - if(state != sorted_ji) Sortji(); - pp = j; + p[nn] = nnzz + fortran; + // remove empty row + for (I ii = nn - 1; ii >= 0; --ii) + if (p[ii] < 0) // empty row + p[ii] = p[ii + 1]; + + type_state = type_m; + if (verbosity > 10) { + cout << "Buildp p=" << nn << " type_m =" << type_m << endl; + for (int ii = 0; ii <= nn; ++ii) cout << ii << " " << p[ii] << endl; + cout << " end Buildp\n"; } - assert(nbsort < (size_t) this->n+100 ); - - while(pp[k0] < ii) - { - if( k-k0 <=1) break; - size_t kk = (k0+k)/2; - //cout << kk << " " << k0 << endl; - if(pp[kk]ii) k1=kk; - k=kk; - } - } - if(pp[k0]ii) - k1=kk; - else - k=kk; - } - if(pp[k1]>ii) - --k1; - //cout << ii << "k0 =" << k0 << " k1 " << k1 << endl; - Pair ret(k0,k1); - return ret; -} - - - -template -R* HashMatrix::addMatMul(R *x,R*Ax,bool Transpose,I sx,I sAx) const { - I *ii=i,*jj=j; - R *aa=aij; - double t0= CPUsecond(); - ffassert(half >= 0); // half < 0 TODO - // if(Transpose != trans) {std::swap(ii,jj);} - const bool do_conj = ((std::is_same >::value || std::is_same >::value )) && Transpose; - if(Transpose ) {std::swap(ii,jj);} - if(fortran) {aa++;} - if( verbosity>99) cout << " addMatMul "<< sx << " "<< sAx << " " << half << " " << do_conj << endl; - if(do_conj)// complex and transpose => hermitian - { - if(sx==1 && sAx==1) - { - if( half) - for(size_t k=0; k +typename HashMatrix< I, R >::Pair HashMatrix< I, R >::RoworCol(I ii, bool row) { + size_t k0 = 0, k1 = nnz - 1, k = nnz - 1; + I *pp = 0; + if (row) { + if (state != sorted_ij) Sortij( ); + pp = i; + } else { + if (state != sorted_ji) Sortji( ); + pp = j; + } + assert(nbsort < (size_t)this->n + 100); + + while (pp[k0] < ii) { + if (k - k0 <= 1) break; + size_t kk = (k0 + k) / 2; + // cout << kk << " " << k0 << endl; + if (pp[kk] < ii) + k0 = kk; + else { + if (pp[kk] > ii) k1 = kk; + k = kk; } + } + if (pp[k0] < ii) ++k0; + k = k0; + while (ii < pp[k1]) { + if ((k1 - k) <= 1) break; + size_t kk = (k1 + k) / 2; + // cout << kk << " " << k1 << endl; + if (pp[kk] > ii) + k1 = kk; else - if( half) - for(size_t k=0; k ii) --k1; + // cout << ii << "k0 =" << k0 << " k1 " << k1 << endl; + Pair ret(k0, k1); + return ret; +} + +template< class I, class R > +R *HashMatrix< I, R >::addMatMul(R *x, R *Ax, bool Transpose, I sx, I sAx) const { + I *ii = i, *jj = j; + R *aa = aij; + double t0 = CPUsecond( ); + ffassert(half >= 0); // half < 0 TODO + // if(Transpose != trans) {std::swap(ii,jj);} + const bool do_conj = ((std::is_same< R, complex< double > >::value || std::is_same< R, complex< float > >::value)) && Transpose; + if (Transpose) { + std::swap(ii, jj); + } + if (fortran) { + aa++; + } + if (verbosity > 99) cout << " addMatMul " << sx << " " << sAx << " " << half << " " << do_conj << endl; + if (do_conj) // complex and transpose => hermitian + { + if (sx == 1 && sAx == 1) { + if (half) + for (size_t k = 0; k < nnz; ++k) { + R aak = aa[k], caak = conj(aa[k]); + Ax[ii[k]] += caak * x[jj[k]]; + if (ii[k] != jj[k]) Ax[jj[k]] += caak * x[ii[k]]; } + else + for (size_t k = 0; k < nnz; ++k) Ax[ii[k]] += conj(aa[k]) * x[jj[k]]; + } else if (half) + for (size_t k = 0; k < nnz; ++k) { + R aak = aa[k], caak = conj(aa[k]); + Ax[ii[k] * sAx] += caak * x[jj[k] * sx]; + if (ii[k] != jj[k]) Ax[jj[k] * sAx] += aak * x[ii[k] * sx]; + } else - for(size_t k=0; k (no conj) - { - if(sx==1 && sAx==1) - { - if( half) - for(size_t k=0; k (no conj) + { + if (sx == 1 && sAx == 1) { + if (half) + for (size_t k = 0; k < nnz; ++k) { + Ax[ii[k]] += aa[k] * x[jj[k]]; + if (ii[k] != jj[k]) Ax[jj[k]] += aa[k] * x[ii[k]]; } + else + for (size_t k = 0; k < nnz; ++k) Ax[ii[k]] += aa[k] * x[jj[k]]; + } else if (half) + for (size_t k = 0; k < nnz; ++k) { + Ax[ii[k] * sAx] += aa[k] * x[jj[k] * sx]; + if (ii[k] != jj[k]) Ax[jj[k] * sAx] += aa[k] * x[ii[k] * sx]; + } else - for(size_t k=0; k -R HashMatrix::trace () const { - R t=R(); - for(int ii=0; iin; ++ii) - t+= diag(ii); - return t; -} - -template -double HashMatrix::FrobeniusNorm() const -{ - double s=0; - for(size_t k=0; k -double HashMatrix::norm1() const -{ - double s=0; - for(size_t k=0; k -double HashMatrix::norminfty() const -{ - double s=abs(aij[0]); - for(size_t k=0; k -void HashMatrix::SetBC(char *wbc,double ttgv) -{ - tgv = ttgv; - ntgv =0; - if ( this->n != this->m) MATERROR(1,"SetBC on none square matrix ?????"); - if(ttgv<0) { - for(I ii=0; ii< this->n; ++ii) - if( wbc[ii] ) - operator()(ii,ii) += 0; // create diag coef if it does not exist - CSR(); - } - for(I ii=0; ii< this->n; ++ii) - if( wbc[ii] ) - { - ntgv++; - if(ttgv<0) - { - - if( wbc[ii] ) - { - for (I k=p[ii];k 1.0e-10 && std::abs(ttgv+30.0) > 1.0e-10) - aij[k]=0;// put row to zero - } - - } - else - operator()(ii,ii)=ttgv; + for (size_t k = 0; k < nnz; ++k) Ax[ii[k] * sAx] += aa[k] * x[jj[k] * sx]; + } + matmulcpu += CPUsecond( ) - t0; + return Ax; +} + +template< class I, class R > +R HashMatrix< I, R >::trace( ) const { + R t = R( ); + for (int ii = 0; ii < this->n; ++ii) t += diag(ii); + return t; +} + +template< class I, class R > +double HashMatrix< I, R >::FrobeniusNorm( ) const { + double s = 0; + for (size_t k = 0; k < nnz; ++k) s += norm(aij[k]); + s = sqrt(s); + return s; +} + +template< class I, class R > +double HashMatrix< I, R >::norm1( ) const { + double s = 0; + for (size_t k = 0; k < nnz; ++k) s += abs(aij[k]); + return s; +} + +template< class I, class R > +double HashMatrix< I, R >::norminfty( ) const { + double s = abs(aij[0]); + for (size_t k = 0; k < nnz; ++k) s = std::max(abs(aij[k]), s); + return s; +} + +template< class I, class R > +void HashMatrix< I, R >::SetBC(char *wbc, double ttgv) { + tgv = ttgv; + ntgv = 0; + if (this->n != this->m) MATERROR(1, "SetBC on none square matrix ?????"); + if (ttgv < 0) { + for (I ii = 0; ii < this->n; ++ii) + if (wbc[ii]) operator( )(ii, ii) += 0; // create diag coef if it does not exist + CSR( ); + } + for (I ii = 0; ii < this->n; ++ii) + if (wbc[ii]) { + ntgv++; + if (ttgv < 0) { + + if (wbc[ii]) { + for (I k = p[ii]; k < p[ii + 1]; ++k) + if (j[k] == ii) + aij[k] = (ttgv < -9.0 ? 0.0 : 1.0); + else if (std::abs(ttgv + 3.0) > 1.0e-10 && std::abs(ttgv + 30.0) > 1.0e-10) + aij[k] = 0; // put row to zero } - if( std::abs(ttgv+2.0) < 1.0e-10 || std::abs(ttgv+20.0) < 1.0e-10 || std::abs(ttgv+3.0) < 1.0e-10 || std::abs(ttgv+30.0) < 1.0e-10) // remove also columm tgv == -2,-3 ..... - { - CSC(); - for(I jj=0; jj< this->n; ++jj) - if( wbc[jj] ) { - for (I k=p[jj];k -void HashMatrix::addMap(R coef,std::map< pair, R> &mij,bool trans,I ii00,I jj00,bool cnj,double threshold) -{ - for (auto pm=mij.begin(); pm != mij.end(); ++pm) - { - I ii = pm->first.first+ii00, jj= pm->first.second+jj00; - R cmij = coef* pm->second; - - if(trans) swap(ii,jj); - if( abs(cmij) > threshold ) - { - if(cnj) cmij = conj(cmij); - operator()(ii,jj) += cmij; - } - } -} - -template -bool HashMatrix::addMatTo(R coef,HashMatrix & mij,bool trans,I ii00,I jj00,bool cnj,double threshold,const bool keepSym) -{ - // add a mij + = coef * [(this)^trans^cnj , - double eps0=max(numeric_limits::min(),threshold); - - if (half) - { - for( size_t kk= 0; kkeps0) // remove for IPOPT april 2019 FH only if threshold >0 - { - mij[ij_mat(trans,ii00,jj00,ii,jj)] += cij ; - if (ii!=jj&&!keepSym) - mij[ij_mat(trans,ii00,jj00,jj,ii)] += cij; - } - } + } else + operator( )(ii, ii) = ttgv; } - else - { - for(size_t kk= 0; kkeps0) // / remove for IPOPT april 2019 FH - mij[ij_mat(trans,ii00,jj00,ii,jj)] += cij; - } + if (std::abs(ttgv + 2.0) < 1.0e-10 || std::abs(ttgv + 20.0) < 1.0e-10 || std::abs(ttgv + 3.0) < 1.0e-10 || std::abs(ttgv + 30.0) < 1.0e-10) // remove also columm tgv == -2,-3 ..... + { + CSC( ); + for (I jj = 0; jj < this->n; ++jj) + if (wbc[jj]) { + for (I k = p[jj]; k < p[jj + 1]; ++k) + if (i[k] != jj || ttgv < -19.0) aij[k] = 0; // put column to zero + } + } +} + +template< class I, class R > +void HashMatrix< I, R >::addMap(R coef, std::map< pair< I, I >, R > &mij, bool trans, I ii00, I jj00, bool cnj, double threshold) { + for (auto pm = mij.begin( ); pm != mij.end( ); ++pm) { + I ii = pm->first.first + ii00, jj = pm->first.second + jj00; + R cmij = coef * pm->second; + + if (trans) swap(ii, jj); + if (abs(cmij) > threshold) { + if (cnj) cmij = conj(cmij); + operator( )(ii, jj) += cmij; } - - return keepSym; -} - - -template -VirtualMatrix & HashMatrix::operator +=(MatriceElementaire & me) { - // R zero=R(); - int il,jl,i,j; - int * mi=me.ni, *mj=me.nj; - if ((this->n==0) && (this->m==0)) - { - - - cout << " -- Bug: HashMat is empty let's build it" << endl; - ffassert(0); - + } +} + +template< class I, class R > +bool HashMatrix< I, R >::addMatTo(R coef, HashMatrix< I, R > &mij, bool trans, I ii00, I jj00, bool cnj, double threshold, const bool keepSym) { + // add a mij + = coef * [(this)^trans^cnj , + double eps0 = max(numeric_limits< double >::min( ), threshold); + + if (half) { + for (size_t kk = 0; kk < nnz; ++kk) { + I ii = i[kk], jj = j[kk]; + R cij = coef * (cnj ? RNM::conj(aij[kk]) : aij[kk]); + if (threshold == 0 || std::norm(cij) > eps0) // remove for IPOPT april 2019 FH only if threshold >0 + { + mij[ij_mat(trans, ii00, jj00, ii, jj)] += cij; + if (ii != jj && !keepSym) mij[ij_mat(trans, ii00, jj00, jj, ii)] += cij; + } } - R * al = me.a; - R * aij; - switch (me.mtype) { - case MatriceElementaire::Full : ffassert(!half); - for (il=0; il::Symmetric : ffassert(half); - for (il=0; il eps0) // / remove for IPOPT april 2019 FH + mij[ij_mat(trans, ii00, jj00, ii, jj)] += cij; } - return *this; -} - - -template -void SetBC(I ii,double ttgv) { diag(ii)=ttgv;}; - - - -template -double HashMatrix::gettgv(I * pntgv,double ratio) const -{ - if( this->n != this->m) return 0; // no ttgv - double ttgv =0, max1=0; - I ntgv=0; - for (I ii=0; iin;++ii) - { - R * p=pij(ii,ii); - if (p) - { - - double a=real(*p); - if( a> ttgv ) - { - max1=ttgv; - ttgv=a; - ntgv =1; - } - else if (a== ttgv) - ++ntgv; - else if( a >max1) - max1 = a; + } + + return keepSym; +} + +template< class I, class R > +VirtualMatrix< I, R > &HashMatrix< I, R >::operator+=(MatriceElementaire< R > &me) { + // R zero=R(); + int il, jl, i, j; + int *mi = me.ni, *mj = me.nj; + if ((this->n == 0) && (this->m == 0)) { + + cout << " -- Bug: HashMat is empty let's build it" << endl; + ffassert(0); + } + R *al = me.a; + R *aij; + switch (me.mtype) { + case MatriceElementaire< R >::Full: + ffassert(!half); + for (il = 0; il < me.n; ++il) { + i = mi[il]; + for (jl = 0; jl < me.m; ++jl, ++al) { + j = mj[jl]; + aij = npij(i, j); + { + throwassert(aij); + *aij += *al; + } } - - } - if( max1*ratio> ttgv) // ttgv to small => no ttgv .... - ttgv=0,ntgv=0; // no ttgv - if(pntgv) *pntgv = ntgv; - return ttgv; - -} - -template -void HashMatrix::setsdp(int sym,bool dp) // sym dpos para -{ - this->symetric=(sym != 0); // not used -- defined in VirtualMatrix - this->positive_definite=dp; // not used -- defined in VirtualMatrix - if ((half*sym > 0) || (!sym && !half)) - half = sym; - else { - if (sym) - Half(sym); // remove half part -- sym > 0 --> keep L, sym < 0 --> keep U - else - UnHalf(); + } + break; + + case MatriceElementaire< R >::Symmetric: + ffassert(half); + for (il = 0; il < me.n; ++il) { + i = mi[il]; + for (jl = 0; jl < il + 1; ++jl) { + j = mj[jl]; + aij = (j < i) ? npij(i, j) : npij(j, i); + throwassert(aij); + *aij += *al++; + } + } + break; + default: + cerr << "Big bug type MatriceElementaire unknown" << (int)me.mtype << endl; + ErrorExec("Bi-ug in Hashmat += MatriceElementaire", 1); + break; + } + return *this; +} + +template< class I, class R > +void SetBC(I ii, double ttgv) { + diag(ii) = ttgv; +}; + +template< class I, class R > +double HashMatrix< I, R >::gettgv(I *pntgv, double ratio) const { + if (this->n != this->m) return 0; // no ttgv + double ttgv = 0, max1 = 0; + I ntgv = 0; + for (I ii = 0; ii < this->n; ++ii) { + R *p = pij(ii, ii); + if (p) { + + double a = real(*p); + if (a > ttgv) { + max1 = ttgv; + ttgv = a; + ntgv = 1; + } else if (a == ttgv) + ++ntgv; + else if (a > max1) + max1 = a; } + } + if (max1 * ratio > ttgv) // ttgv to small => no ttgv .... + ttgv = 0, ntgv = 0; // no ttgv + if (pntgv) *pntgv = ntgv; + return ttgv; } -template -void HashMatrix::UnHalf() +template< class I, class R > +void HashMatrix< I, R >::setsdp(int sym, bool dp) // sym dpos para { - if (half==0) return; - HM(); - size_t nnz0=nnz,err=0; - for(int k=0; k j[k] ) - { - size_t ki=insert(j[k],i[k],(half == 1?conj(aij[k]):aij[k])); - err += ki < nnz0; - } - else if ( i[k] < j[k] ) - err++; - half = 0; - if( err ) - cerr << " Try of unsymmetrize no half matrix (Bug) ... ????" <symetric = (sym != 0); // not used -- defined in VirtualMatrix + this->positive_definite = dp; // not used -- defined in VirtualMatrix + if ((half * sym > 0) || (!sym && !half)) + half = sym; + else { + if (sym) + Half(sym); // remove half part -- sym > 0 --> keep L, sym < 0 --> keep U + else + UnHalf( ); + } +} + +template< class I, class R > +void HashMatrix< I, R >::UnHalf( ) { + if (half == 0) return; + HM( ); + size_t nnz0 = nnz, err = 0; + for (int k = 0; k < nnz0; ++k) + if (i[k] > j[k]) { + size_t ki = insert(j[k], i[k], (half == 1 ? conj(aij[k]) : aij[k])); + err += ki < nnz0; + } else if (i[k] < j[k]) + err++; + half = 0; + if (err) cerr << " Try of unsymmetrize no half matrix (Bug) ... ????" << endl; + ffassert(err == 0); } typedef double R; -typedef complex C; -// because for UMFPACK 64 because long are only 32 bits under windows - -template class HashMatrix; -template class HashMatrix; -template class HashMatrix; -template class HashMatrix; -template class HashMatrix; -template class HashMatrix; -template HashMatrix::HashMatrix(const HashMatrix & ); -template HashMatrix::HashMatrix(const HashMatrix & ); -template HashMatrix::HashMatrix(const HashMatrix & ); -template HashMatrix::HashMatrix(const HashMatrix & ); - -template HashMatrix::HashMatrix(const HashMatrix & ); -template HashMatrix::HashMatrix(const HashMatrix & ); -template HashMatrix::HashMatrix(const HashMatrix & , R(*ff)(C)); -//template HashMatrix::HashMatrix(const HashMatrix & ); - -//template HashMatrix & HashMatrix::operator=(const HashMatrix & ); -//template HashMatrix & HashMatrix::operator=(const HashMatrix & ); -//template HashMatrix & HashMatrix::operator+=(const HashMatrix & ); -//template HashMatrix & HashMatrix::operator+=(const HashMatrix & ); - -template void Addto(HashMatrix *P0, const HashMatrix *PA,R (*f)(C) ,bool trans, int ii00,int jj00); -template void Addto(HashMatrix *P0, const HashMatrix *PA,C (*f)(R) ,bool trans, int ii00,int jj00); - -template void HashMatrix::set(long nn,long mm,int hhalf,size_t nnnz, long *ii, long*jj, R *aa,int f77); -template void HashMatrix::set(long long nn,long long mm,int hhalf,size_t nnnz, long long *ii, long long*jj, R *aa,int f77); -//template void HashMatrix::set(int nn,int mm,bool hhalf,size_t nnnz, int *ii, int*jj, R *aa,int f77,R(*ff)(R)); -//template void HashMatrix::set(long nn,long mm,bool hhalf,size_t nnnz, long *ii, long *jj, R *aa,int f77,R(*ff)(R)); -template void HashMatrix::set(int nn,int mm,int hhalf,size_t nnnz, int *ii, int*jj, C *aa,int f77,C(*ff)(C)); -template void HashMatrix::set(int nn,int mm,int hhalf,size_t nnnz, int *ii, int*jj, C *aa,int f77,R(*ff)(C)); - -//template void HashMatrix::set(int nn,int mm,bool hhalf,size_t nnnz, int *ii, int*jj, R *aa,int f77,C(*ff)(R)); -//template void HashMatrix::set(long nn,long mm,bool hhalf,size_t nnnz, long *ii, long *jj, C *aa,int f77,C(*ff)(C)); - - - void init_HashMatrix () -{ - -} +typedef complex< R > C; +// because for UMFPACK 64 because long are only 32 bits under windows + +template class HashMatrix< int, R >; +template class HashMatrix< int, C >; +template class HashMatrix< long, R >; +template class HashMatrix< long, C >; +template class HashMatrix< long long, R >; +template class HashMatrix< long long, C >; +template HashMatrix< long, R >::HashMatrix(const HashMatrix< int, R > &); +template HashMatrix< long, C >::HashMatrix(const HashMatrix< int, C > &); +template HashMatrix< long long, R >::HashMatrix(const HashMatrix< int, R > &); +template HashMatrix< long long, C >::HashMatrix(const HashMatrix< int, C > &); + +template HashMatrix< int, C >::HashMatrix(const HashMatrix< long, C > &); +template HashMatrix< int, C >::HashMatrix(const HashMatrix< long long, C > &); +template HashMatrix< int, R >::HashMatrix(const HashMatrix< int, C > &, R (*ff)(C)); +// template HashMatrix::HashMatrix(const HashMatrix & ); + +// template HashMatrix & HashMatrix::operator=(const HashMatrix & ); +// template HashMatrix & HashMatrix::operator=(const HashMatrix & ); +// template HashMatrix & HashMatrix::operator+=(const HashMatrix & ); +// template HashMatrix & HashMatrix::operator+=(const HashMatrix & ); + +template void Addto< int, R, C >(HashMatrix< int, R > *P0, const HashMatrix< int, C > *PA, R (*f)(C), bool trans, int ii00, int jj00); +template void Addto< int, C, R >(HashMatrix< int, C > *P0, const HashMatrix< int, R > *PA, C (*f)(R), bool trans, int ii00, int jj00); + +template void HashMatrix< int, R >::set< long >(long nn, long mm, int hhalf, size_t nnnz, long *ii, long *jj, R *aa, int f77); +template void HashMatrix< int, R >::set< long long >(long long nn, long long mm, int hhalf, size_t nnnz, long long *ii, long long *jj, R *aa, int f77); +// template void HashMatrix::set(int nn,int mm,bool hhalf,size_t nnnz, int *ii, int*jj, R *aa,int f77,R(*ff)(R)); +// template void HashMatrix::set(long nn,long mm,bool hhalf,size_t nnnz, long *ii, long *jj, R *aa,int f77,R(*ff)(R)); +template void HashMatrix< int, C >::set< int, C >(int nn, int mm, int hhalf, size_t nnnz, int *ii, int *jj, C *aa, int f77, C (*ff)(C)); +template void HashMatrix< int, R >::set< int, C >(int nn, int mm, int hhalf, size_t nnnz, int *ii, int *jj, C *aa, int f77, R (*ff)(C)); + +// template void HashMatrix::set(int nn,int mm,bool hhalf,size_t nnnz, int *ii, int*jj, R *aa,int f77,C(*ff)(R)); +// template void HashMatrix::set(long nn,long mm,bool hhalf,size_t nnnz, long *ii, long *jj, C *aa,int f77,C(*ff)(C)); + +void init_HashMatrix( ) {} // just to test /* static void tttt() { HashMatrix AiR(10); HashMatrix AlR(AiR);//,HashMatrix::cast_funct); - + HashMatrix AlC(10); HashMatrix AiC(10); diff --git a/src/femlib/HashMatrix.hpp b/src/femlib/HashMatrix.hpp old mode 100755 new mode 100644 index dbb9fb3d8..db99760a9 --- a/src/femlib/HashMatrix.hpp +++ b/src/femlib/HashMatrix.hpp @@ -16,670 +16,660 @@ using std::tuple; #include "RefCounter.hpp" #include "VirtualMatrix.hpp" -using std::max; -using std::min; +using std::complex; using std::cout; using std::endl; +using std::list; +using std::max; +using std::min; using std::pair; using std::swap; -using std::complex; -using std::list; -extern long verbosity ; - -void init_HashMatrix (); -template -inline uint64_t roll64(Z y,ZZ r){uint64_t x=y; r %= 64; return (x< class HashMatrix; - -template -void Addto(HashMatrix *P0,const HashMatrix *PA,R (*f)(K) ,bool trans=false, I ii00=0,I jj00=0); - - - -template -class HashMatrix : public VirtualMatrix -{ - static void HeapSort(TypeIndex *ii,TypeIndex *jj, TypeScalaire *aij,long n); - - -public: - - template static void conj(R *x,TypeIndex nnz){} - static void conj(complex *x,TypeIndex nnz){ for(int k=0; k *x,TypeIndex nnz){for(int k=0; k conj(const complex &x){return std::conj(x);} - static complex conj(const complex &x){return std::conj(x);} - - typedef TypeIndex I; - typedef TypeScalaire R; - typedef uint64_t uniquecodeInt; - static const int type_isdeleted=-1,type_HM=0,type_COO=1, type_CSR=2,type_CSC=3; - static const int unsorted=0, sorted_ij=type_CSR,sorted_ji=type_CSC; - typedef size_t iterator; - typedef size_t Hash; - typedef pair Pair; - size_t nnz,nnzmax,nhash; - mutable size_t nbcollision,nbfind; - mutable double matmulcpu; - I * i,*j; - I *p; - R * aij; - size_t * head; - size_t * next; - int half; - int state,type_state; - size_t nbsort; - I sizep; - int lock; - int fortran; // index start a one .. - mutable int re_do_numerics,re_do_symbolic; - mutable I mindiffij,maxdiffij;// add jan. 2023 - - static const size_t empty= (I) -1; - // for Dirichlet BC - double tgv; - I ntgv; - - I NbCoef() const {return (I) nnz;} - - void Setdiffij(int force=0) const { - if(force || (mindiffij> maxdiffij)) - { - mindiffij= std::numeric_limits::max(); - maxdiffij= std::numeric_limits::min(); - for(int k=0; k< nnz; ++k) { - mindiffij = min(mindiffij,i[k]-j[k]); - maxdiffij = max(maxdiffij,i[k]-j[k]); - }} - } - bool isL() const { Setdiffij(0); return maxdiffij >=0 ;}// j <= i => diffij >=0 - bool isU() const { Setdiffij(0); return mindiffij <=0 ;}// j >= i => diffij <=0 - void setcoef(const KN_ & x){KN_c(this->aij,nnz); ffassert(x.SameShape(c)); - if( x.constant()) c=x[0]; else c = x;} - void getcoef( KN_ & x) const {ffassert(x.N()==(I) nnz);x =KN_(this->aij,nnz);} - - void setdiag(const KN_ & d); - void getdiag( KN_ & d) const; - R pscal(R *x,R *y,I sx=1,I sy=1); - R pscal(const KN_ & x,const KN_ & y) {ffassert(x.N()==this->N && y.N()==this->N && this->N ==this->M ); return pscal(x,y,(I) x.step,(I) y.step);} - void SetMorse(); - void UnSetMorse(); - uniquecodeInt CodeIJ() const ; - void init(I nn,I mm,size_t nnnz,int halff); - HashMatrix(I nn,I mm,I nnnz,int halff); - HashMatrix(istream & f,int cas=-1); - HashMatrix(KNM_ F,double threshold=1e-30); - explicit HashMatrix(I nn,I mm,bool Half); // too dangerous - HashMatrix(const HashMatrix& A); - HashMatrix(I nn,const R *diag); - void RenumberingInv(KN_ II,KN_ JJ); - void Renumbering(I nn,I mm,KN_ II,KN_ JJ); - void RemoveDoubleij(int kk);// remove - template static R cast_funct(K x) { return (R) x;} - - template HashMatrix(const HashMatrix &A , R (*ff)(K) ); - template HashMatrix(const HashMatrix &A ); - - template HashMatrix & operator=(const HashMatrix& A ) - { - if( (const void*) this == (const void*) & A) return *this; - - set(A.n,A.m,A.half,A.nnz,A.i,A.j,A.aij,A.fortran,cast_funct); - return *this; - } +extern long verbosity; + +void init_HashMatrix( ); +template< class Z, class ZZ > +inline uint64_t roll64(Z y, ZZ r) { + uint64_t x = y; + r %= 64; + return (x << r) | (x << (64 - r)); +} - template HashMatrix & operator+=(const HashMatrix& A ); +int WhichMatrix(istream &f); +template< class TypeIndex, class TypeScalaire > +class HashMatrix; +template< class I, class R, class K > +void Addto(HashMatrix< I, R > *P0, const HashMatrix< I, K > *PA, R (*f)(K), bool trans = false, I ii00 = 0, I jj00 = 0); - int IsTrianglulare() const ; +template< class TypeIndex, class TypeScalaire > +class HashMatrix : public VirtualMatrix< TypeIndex, TypeScalaire > { + static void HeapSort(TypeIndex *ii, TypeIndex *jj, TypeScalaire *aij, long n); - void CheckUnLock(const char * cmm) - { - if( lock) - { - std::cerr << " Sorry Forbidder operation ( " - << cmm<< " ) matix is lock " << endl; - assert(0); - } + public: + template< class R > + static void conj(R *x, TypeIndex nnz) {} + static void conj(complex< double > *x, TypeIndex nnz) { + for (int k = 0; k < nnz; ++k) x[k] = std::conj(x[k]); + } + static void conj(complex< float > *x, TypeIndex nnz) { + for (int k = 0; k < nnz; ++k) x[k] = std::conj(x[k]); + } + static double conj(double x) { return x; } + static float conj(float x) { return x; } + static complex< double > conj(const complex< double > &x) { return std::conj(x); } + static complex< float > conj(const complex< float > &x) { return std::conj(x); } + + typedef TypeIndex I; + typedef TypeScalaire R; + typedef uint64_t uniquecodeInt; + static const int type_isdeleted = -1, type_HM = 0, type_COO = 1, type_CSR = 2, type_CSC = 3; + static const int unsorted = 0, sorted_ij = type_CSR, sorted_ji = type_CSC; + typedef size_t iterator; + typedef size_t Hash; + typedef pair< size_t, size_t > Pair; + size_t nnz, nnzmax, nhash; + mutable size_t nbcollision, nbfind; + mutable double matmulcpu; + I *i, *j; + I *p; + R *aij; + size_t *head; + size_t *next; + int half; + int state, type_state; + size_t nbsort; + I sizep; + int lock; + int fortran; // index start a one .. + mutable int re_do_numerics, re_do_symbolic; + mutable I mindiffij, maxdiffij; // add jan. 2023 + + static const size_t empty = (I)-1; + // for Dirichlet BC + double tgv; + I ntgv; + + I NbCoef( ) const { return (I)nnz; } + + void Setdiffij(int force = 0) const { + if (force || (mindiffij > maxdiffij)) { + mindiffij = std::numeric_limits< I >::max( ); + maxdiffij = std::numeric_limits< I >::min( ); + for (int k = 0; k < nnz; ++k) { + mindiffij = min(mindiffij, i[k] - j[k]); + maxdiffij = max(maxdiffij, i[k] - j[k]); + } } - void setp(I sp); - void resize(I nn, I mm=0) {resize(nn,mm,nnz); } + } + bool isL( ) const { + Setdiffij(0); + return maxdiffij >= 0; + } // j <= i => diffij >=0 + bool isU( ) const { + Setdiffij(0); + return mindiffij <= 0; + } // j >= i => diffij <=0 + void setcoef(const KN_< R > &x) { + KN_< R > c(this->aij, nnz); + ffassert(x.SameShape(c)); + if (x.constant( )) + c = x[0]; + else + c = x; + } + void getcoef(KN_< R > &x) const { + ffassert(x.N( ) == (I)nnz); + x = KN_< R >(this->aij, nnz); + } - void resize(I nn, I mm,size_t nnnz, double tol = -1., int sym=0 ); - void SymmetrizePattern(); // To do for Suzuki , Paradiso - void clear(); - Hash hash(size_t ii,size_t jj) const{ return ( (ii-fortran)+ (jj-fortran)*this->n )%nhash; } + void setdiag(const KN_< R > &d); + void getdiag(KN_< R > &d) const; + R pscal(R *x, R *y, I sx = 1, I sy = 1); + R pscal(const KN_< R > &x, const KN_< R > &y) { + ffassert(x.N( ) == this->N && y.N( ) == this->N && this->N == this->M); + return pscal(x, y, (I)x.step, (I)y.step); + } + void SetMorse( ); + void UnSetMorse( ); + uniquecodeInt CodeIJ( ) const; + void init(I nn, I mm, size_t nnnz, int halff); + HashMatrix(I nn, I mm, I nnnz, int halff); + HashMatrix(istream &f, int cas = -1); + HashMatrix(KNM_< R > F, double threshold = 1e-30); + explicit HashMatrix(I nn, I mm, bool Half); // too dangerous + HashMatrix(const HashMatrix &A); + HashMatrix(I nn, const R *diag); + void RenumberingInv(KN_< I > II, KN_< I > JJ); + void Renumbering(I nn, I mm, KN_< I > II, KN_< I > JJ); + void RemoveDoubleij(int kk); // remove + template< class R, class K > + static R cast_funct(K x) { + return (R)x; + } - void setfortran(int yes); + template< class J, class K > + HashMatrix(const HashMatrix< J, K > &A, R (*ff)(K)); + template< class J > + HashMatrix(const HashMatrix< J, R > &A); - size_t find(size_t ii,size_t jj) const { return find(ii,jj, hash(ii,jj)); } + template< class II, class RR > + HashMatrix &operator=(const HashMatrix< II, RR > &A) { + if ((const void *)this == (const void *)&A) return *this; - size_t find(I ii,I jj,Hash h) const - { - nbfind++; - for (size_t k=head[h];k!=empty;k=next[k]) - { - ++nbcollision; - if( ii== i[k] && jj==j[k] ) return k; - } - return empty; - } + set(A.n, A.m, A.half, A.nnz, A.i, A.j, A.aij, A.fortran, cast_funct< R, RR >); + return *this; + } - size_t insert(I ii, I jj,const R & aa) - { - state=unsorted; - Hash h= hash(ii,jj); - size_t k=find(ii,jj,h); - if(k==empty) - k =simpleinsert(ii,jj,h); - aij[k] += aa; - return k; - } + template< class II, class RR > + HashMatrix &operator+=(const HashMatrix< II, RR > &A); - template static void HMresize(T *&t,size_t no,size_t nn); - template static void HMcopy( T *dst,const TT *from, size_t nn); - template static void HMcopy( T *dst,const TT *from, size_t nn, T (*ff)(TT) ); - - bool do2Triangular(bool lower) ; // put half tp lower or upper - void dotranspose(bool doconj=1); - void conj(){ conj(aij,this->nnz);} // add F.H sep 2022 - void Increaze(size_t nnznew=0,size_t newnnz=0);// newnnz<0 => newnnz is set to nnz (change value of nnz) - void ReHash(); - size_t size() const { return nnz;} - size_t simpleinsert(I ii, I jj,Hash &h); - R *pij(I ii,I jj) const; - R *npij(I ii,I jj); // with add if no term ii,jj - - R & diag(I ii) { return operator()(ii,ii);} - R diag(I ii) const { return operator()(ii,ii);} - R operator()(I ii,I jj) const - { - Hash h = hash(ii,jj); - size_t k = find(ii,jj,h); - if(k==empty) return R(); - else return aij[k]; - } + int IsTrianglulare( ) const; - R & operator()(I ii,I jj) - { - return *npij(ii,jj); + void CheckUnLock(const char *cmm) { + if (lock) { + std::cerr << " Sorry Forbidder operation ( " << cmm << " ) matix is lock " << endl; + assert(0); } + } + void setp(I sp); + void resize(I nn, I mm = 0) { resize(nn, mm, nnz); } - R operator()(pair ij) const {return operator()(ij.first,ij.second);} - R & operator()(pair ij) {return operator()(ij.first,ij.second);} - R operator[](pair ij) const {return operator()(ij.first,ij.second);} - R & operator[](pair ij) {return operator()(ij.first,ij.second);} - ~HashMatrix(); - - - void Sortij(); - void Sortji(); - - void set(I nn,I mm,int hhalf,size_t nnnz, I *ii, I *jj, R *aa,int f77=0,int tcsr=0); - template void set(II nn,II mm,int hhalf,size_t nnnz, II *ii, II*jj, R *aa,int f77); - template void set(II nn,II mm,int hhalf,size_t nnnz, II *ii, II*jj, RR *aa,int f77,R (*ff)(RR)); - - void Add(const HashMatrix *PA,R coef=R(1),bool trans=false, I ii00=0,I jj00=0); - - HashMatrix &operator=(const HashMatrix &A) ; - HashMatrix &operator+=(const HashMatrix &A) ;// {Add(&A); return *this;}; - HashMatrix &operator-=(const HashMatrix &A) ; //{Add(&A,R(-1.)); return *this;} - - - - void operator*=(R v); - void operator=(const R & v); - void HM();// un sorted ... Default type .. - void COO(); - void COO(I *& IA, I *& IJ, R *& A); - void CSR(I *& IA, I *& JA, R *& A); - void CSR(); - void CSC(); - void CSC(I *& JA, I *& IA, R *& A); - static int addstateLU(int U) { return U>0 ? 4 : 5; }; - - size_t SortLU(int U); - size_t CSC_U(I *& JA, I *& IA, R *& A); - size_t CSR_L(I *& IA, I *& JA, R *& A); - void Buildp(I nn,I * IA,int type_m,size_t nnzz=0); - Pair Row(I ii) { return RoworCol(ii, true /*!trans*/);} - Pair Col(I jj) { return RoworCol(jj, false /*trans*/);} - Pair RoworCol(I ii,bool row); - void checksize(size_t nn,size_t mm=0) const - { mm= mm ? mm : nn; assert( (nn ==this->n) && (mm==this->m));} - R* addMatMul(R *x,R*Ax,bool Transpose,I sx=1,I sAx=1) const; - R* addMatTransMul(R *x,R*Ax) const { return addMatMul(x,Ax,true); } - R* addMatMul(R *x,R*Ax) const { return addMatMul(x,Ax,false);} - R trace () const; - double FrobeniusNorm() const; - double norm1() const; - double norminfty() const; - bool sym() const {return (half > 0);} - - int typemat() const { return int(half > 0)*VirtualMatrix::TS_SYM ;} - void SetBC(char *wbc,double ttgv); + void resize(I nn, I mm, size_t nnnz, double tol = -1., int sym = 0); + void SymmetrizePattern( ); // To do for Suzuki , Paradiso + void clear( ); + Hash hash(size_t ii, size_t jj) const { return ((ii - fortran) + (jj - fortran) * this->n) % nhash; } + void setfortran(int yes); - void addMap(R coef,std::map< pair, R> &mij,bool trans=false,I ii00=0,I jj00=0,bool cnj=false,double threshold=0.); - bool addMatTo(R coef,HashMatrix & mij,bool trans=false,I ii00=0,I jj00=0,bool cnj=false,double threshold=0.,const bool keepSym=false) ; + size_t find(size_t ii, size_t jj) const { return find(ii, jj, hash(ii, jj)); } + size_t find(I ii, I jj, Hash h) const { + nbfind++; + for (size_t k = head[h]; k != empty; k = next[k]) { + ++nbcollision; + if (ii == i[k] && jj == j[k]) return k; + } + return empty; + } - VirtualMatrix & operator +=(MatriceElementaire & me) ; - ostream& dump (ostream&f) const { return f<<*this;} - void SetBC(I ii,double ttgv) { diag(ii)=ttgv;}; + size_t insert(I ii, I jj, const R &aa) { + state = unsorted; + Hash h = hash(ii, jj); + size_t k = find(ii, jj, h); + if (k == empty) k = simpleinsert(ii, jj, h); + aij[k] += aa; + return k; + } - double gettgv(I * pntgv=0,double ratio=1e6) const ; - bool GetReDoNumerics() const { bool b=re_do_numerics; re_do_numerics=0;return b;} - bool GetReDoSymbolic() const { bool b=re_do_symbolic; re_do_symbolic=0;return b;} + template< typename T > + static void HMresize(T *&t, size_t no, size_t nn); + template< typename T, typename TT > + static void HMcopy(T *dst, const TT *from, size_t nn); + template< typename T, typename TT > + static void HMcopy(T *dst, const TT *from, size_t nn, T (*ff)(TT)); + + bool do2Triangular(bool lower); // put half tp lower or upper + void dotranspose(bool doconj = 1); + void conj( ) { conj(aij, this->nnz); } // add F.H sep 2022 + void Increaze(size_t nnznew = 0, size_t newnnz = 0); // newnnz<0 => newnnz is set to nnz (change value of nnz) + void ReHash( ); + size_t size( ) const { return nnz; } + size_t simpleinsert(I ii, I jj, Hash &h); + R *pij(I ii, I jj) const; + R *npij(I ii, I jj); // with add if no term ii,jj + + R &diag(I ii) { return operator( )(ii, ii); } + R diag(I ii) const { return operator( )(ii, ii); } + R operator( )(I ii, I jj) const { + Hash h = hash(ii, jj); + size_t k = find(ii, jj, h); + if (k == empty) + return R( ); + else + return aij[k]; + } + R &operator( )(I ii, I jj) { return *npij(ii, jj); } + + R operator( )(pair< I, I > ij) const { return operator( )(ij.first, ij.second); } + R &operator( )(pair< I, I > ij) { return operator( )(ij.first, ij.second); } + R operator[](pair< I, I > ij) const { return operator( )(ij.first, ij.second); } + R &operator[](pair< I, I > ij) { return operator( )(ij.first, ij.second); } + ~HashMatrix( ); + + void Sortij( ); + void Sortji( ); + + void set(I nn, I mm, int hhalf, size_t nnnz, I *ii, I *jj, R *aa, int f77 = 0, int tcsr = 0); + template< class II > + void set(II nn, II mm, int hhalf, size_t nnnz, II *ii, II *jj, R *aa, int f77); + template< class II, class RR > + void set(II nn, II mm, int hhalf, size_t nnnz, II *ii, II *jj, RR *aa, int f77, R (*ff)(RR)); + + void Add(const HashMatrix< I, R > *PA, R coef = R(1), bool trans = false, I ii00 = 0, I jj00 = 0); + + HashMatrix &operator=(const HashMatrix &A); + HashMatrix &operator+=(const HashMatrix &A); // {Add(&A); return *this;}; + HashMatrix &operator-=(const HashMatrix &A); //{Add(&A,R(-1.)); return *this;} + + void operator*=(R v); + void operator=(const R &v); + void HM( ); // un sorted ... Default type .. + void COO( ); + void COO(I *&IA, I *&IJ, R *&A); + void CSR(I *&IA, I *&JA, R *&A); + void CSR( ); + void CSC( ); + void CSC(I *&JA, I *&IA, R *&A); + static int addstateLU(int U) { return U > 0 ? 4 : 5; }; + + size_t SortLU(int U); + size_t CSC_U(I *&JA, I *&IA, R *&A); + size_t CSR_L(I *&IA, I *&JA, R *&A); + void Buildp(I nn, I *IA, int type_m, size_t nnzz = 0); + Pair Row(I ii) { return RoworCol(ii, true /*!trans*/); } + Pair Col(I jj) { return RoworCol(jj, false /*trans*/); } + Pair RoworCol(I ii, bool row); + void checksize(size_t nn, size_t mm = 0) const { + mm = mm ? mm : nn; + assert((nn == this->n) && (mm == this->m)); + } + R *addMatMul(R *x, R *Ax, bool Transpose, I sx = 1, I sAx = 1) const; + R *addMatTransMul(R *x, R *Ax) const { return addMatMul(x, Ax, true); } + R *addMatMul(R *x, R *Ax) const { return addMatMul(x, Ax, false); } + R trace( ) const; + double FrobeniusNorm( ) const; + double norm1( ) const; + double norminfty( ) const; + bool sym( ) const { return (half > 0); } + + int typemat( ) const { return int(half > 0) * VirtualMatrix< int, R >::TS_SYM; } + void SetBC(char *wbc, double ttgv); + + void addMap(R coef, std::map< pair< I, I >, R > &mij, bool trans = false, I ii00 = 0, I jj00 = 0, bool cnj = false, double threshold = 0.); + bool addMatTo(R coef, HashMatrix< I, R > &mij, bool trans = false, I ii00 = 0, I jj00 = 0, bool cnj = false, double threshold = 0., const bool keepSym = false); + + VirtualMatrix< I, R > &operator+=(MatriceElementaire< R > &me); + ostream &dump(ostream &f) const { return f << *this; } + void SetBC(I ii, double ttgv) { diag(ii) = ttgv; }; + + double gettgv(I *pntgv = 0, double ratio = 1e6) const; + bool GetReDoNumerics( ) const { + bool b = re_do_numerics; + re_do_numerics = 0; + return b; + } + bool GetReDoSymbolic( ) const { + bool b = re_do_symbolic; + re_do_symbolic = 0; + return b; + } - HashMatrix *toMatriceMorse(bool transpose=false,bool copy=false) const {ffassert(0); return 0;} - double psor(KN_ & x,const KN_ & gmin,const KN_ & gmax , double omega) {ffassert(0); }; + HashMatrix< I, R > *toMatriceMorse(bool transpose = false, bool copy = false) const { + ffassert(0); + return 0; + } + double psor(KN_< R > &x, const KN_< R > &gmin, const KN_< R > &gmax, double omega) { ffassert(0); }; - void UnHalf(); - void Half(int wsym) {resize(this->n,this->m,nnz,-1,wsym);} - void RemoveHalf(int cas,double tol=-1) ; + void UnHalf( ); + void Half(int wsym) { resize(this->n, this->m, nnz, -1, wsym); } + void RemoveHalf(int cas, double tol = -1); - void setsdp(int sym,bool dp); // set of unset to sym / defpos or not + void setsdp(int sym, bool dp); // set of unset to sym / defpos or not - virtual bool ChecknbLine (I n) const {return this->n==n;} - virtual bool ChecknbColumn (I m) const {return this->m==m;} - static double CPUsecond() { - return (double)clock()/CLOCKS_PER_SEC; - } + virtual bool ChecknbLine(I n) const { return this->n == n; } + virtual bool ChecknbColumn(I m) const { return this->m == m; } + static double CPUsecond( ) { return (double)clock( ) / CLOCKS_PER_SEC; } }; // 0 good , -1 delete, ... -template int GoodPtrHashMatrix(const HashMatrix *p ) { - if( p==0) return 1; - if( p->N != p->n) return -2; - if( p->M != p->m) return -3; - if (p->nnz ==-1234567802) return -4; - if( p->i && p->j && p->aij ) return 0; - return -5; +template< class I, class R > +int GoodPtrHashMatrix(const HashMatrix< I, R > *p) { + if (p == 0) return 1; + if (p->N != p->n) return -2; + if (p->M != p->m) return -3; + if (p->nnz == -1234567802) return -4; + if (p->i && p->j && p->aij) return 0; + return -5; } -template void CheckPtrHashMatrix(const HashMatrix *p,const char * where ) -{ - int gm=GoodPtrHashMatrix(p); - if( gm !=0) - { - if(gm <0) - cout << " n = " << p->n << " == " << p->N - << " , m= " << p->m << " "<< p->M - << " nzz "<< p->nnz << endl; - cerr << " Fatal Error " << where << " invalid HashMatrix Ptr "<< gm << " "<< p << endl; - ffassert(0); - } +template< class I, class R > +void CheckPtrHashMatrix(const HashMatrix< I, R > *p, const char *where) { + int gm = GoodPtrHashMatrix(p); + if (gm != 0) { + if (gm < 0) cout << " n = " << p->n << " == " << p->N << " , m= " << p->m << " " << p->M << " nzz " << p->nnz << endl; + cerr << " Fatal Error " << where << " invalid HashMatrix Ptr " << gm << " " << p << endl; + ffassert(0); + } } // END OF CLASS HashMatrix -template -inline size_t HashMatrix::simpleinsert(I ii, I jj,Hash &h) -{ - state=unsorted; - re_do_numerics=1; - re_do_symbolic=1; - - type_state=type_HM; - if(nnz==nnzmax) { - Increaze(); - h = hash(ii,jj); - } - i[nnz] = ii; - j[nnz] = jj; - aij[nnz] = R(); - next[nnz]=head[h]; - head[h]=nnz; - return nnz++; +template< class I, class R > +inline size_t HashMatrix< I, R >::simpleinsert(I ii, I jj, Hash &h) { + state = unsorted; + re_do_numerics = 1; + re_do_symbolic = 1; + + type_state = type_HM; + if (nnz == nnzmax) { + Increaze( ); + h = hash(ii, jj); + } + i[nnz] = ii; + j[nnz] = jj; + aij[nnz] = R( ); + next[nnz] = head[h]; + head[h] = nnz; + return nnz++; } -template -inline R * HashMatrix::pij(I ii,I jj) const -{ - re_do_numerics=1; - Hash h = hash(ii,jj); - size_t k = find(ii,jj,h); - return k==empty ? 0 : aij+k; +template< class I, class R > +inline R *HashMatrix< I, R >::pij(I ii, I jj) const { + re_do_numerics = 1; + Hash h = hash(ii, jj); + size_t k = find(ii, jj, h); + return k == empty ? 0 : aij + k; } -template -inline R *HashMatrix::npij(I ii,I jj) // with add if no term ii,jj +template< class I, class R > +inline R *HashMatrix< I, R >::npij(I ii, I jj) // with add if no term ii,jj { - re_do_numerics=1; - Hash h = hash(ii,jj); - size_t k = find(ii,jj,h); - if(k==empty) - { - k =simpleinsert(ii,jj,h); - aij[k]=0; - } - return aij+k; + re_do_numerics = 1; + Hash h = hash(ii, jj); + size_t k = find(ii, jj, h); + if (k == empty) { + k = simpleinsert(ii, jj, h); + aij[k] = 0; + } + return aij + k; } // - -template -void AddMul(HashMatrix &AB,HashMatrix &A, HashMatrix &B,bool ta=false,bool tb=false,R c=R(1)) -{ - AB.half=false; - int An= A.n, Am =A.m; - int Bn= B.n, Bm =B.m; - int halfA = A.half; - int halfB = B.half; - - if(ta) swap(An,Am); - if(tb) swap(Bn,Bm); - bool tcb = (std::is_same >::value|| std::is_same >::value ) && tb; - bool tca = (std::is_same >::value|| std::is_same >::value ) && ta; - AB.checksize(An,Bm); - ffassert(Am == Bn); - // need A col sort , b row sort - if( tb) - B.CSC(); // sort by COL nd build p. +template< class I, class RA, class RB = RA, class RAB = RA > +void AddMul(HashMatrix< I, RAB > &AB, HashMatrix< I, RA > &A, HashMatrix< I, RB > &B, bool ta = false, bool tb = false, R c = R(1)) { + AB.half = false; + int An = A.n, Am = A.m; + int Bn = B.n, Bm = B.m; + int halfA = A.half; + int halfB = B.half; + + if (ta) swap(An, Am); + if (tb) swap(Bn, Bm); + bool tcb = (std::is_same< RB, complex< double > >::value || std::is_same< RB, complex< float > >::value) && tb; + bool tca = (std::is_same< RA, complex< double > >::value || std::is_same< RA, complex< float > >::value) && ta; + AB.checksize(An, Bm); + ffassert(Am == Bn); + // need A col sort , b row sort + if (tb) + B.CSC( ); // sort by COL nd build p. + else + B.CSR( ); // sort by row... and build p. + int *Bj = tb ? B.i : B.j; + int *Bi = tb ? B.j : B.i; + // first Half + for (size_t l = 0; l < A.nnz; ++l) { + I i = A.i[l], j = A.j[l]; + RA aij = A.aij[l]; + if (ta) swap(i, j); + if (tca) aij = HashMatrix< I, RA >::conj(aij); + + for (size_t ll = B.p[j]; ll < B.p[j + 1]; ++ll) { + I k = Bj[ll]; + if (verbosity > 1000000000) cout << " *** " << i << " " << " " << k << " : " << j << " : " << ll << " " << B.i[ll] << " " << B.j[ll] << " :: " << A.aij[l] * B.aij[ll] << endl; + assert(j == Bi[ll]); + RB bjk = tcb ? HashMatrix< I, RB >::conj(B.aij[ll]) : B.aij[ll]; + + AB(i, k) += c * aij * bjk; + } + } + // second Half of A + if (halfA) { + if (verbosity > 10) cout << " ** halfA " << endl; + for (size_t l = 0; l < A.nnz; ++l) { + I i = A.i[l], j = A.j[l]; + if (i == j) continue; + RA aij = A.aij[l]; + if (!ta) swap(i, j); + // if(!tca) aij=HashMatrix::conj(aij); + + for (size_t ll = B.p[j]; ll < B.p[j + 1]; ++ll) { + I k = Bj[ll]; + if (verbosity > 1000000000) cout << " *** " << i << " " << " " << k << " : " << j << " : " << ll << " " << B.i[ll] << " " << B.j[ll] << " :: " << A.aij[l] * B.aij[ll] << endl; + assert(j == Bi[ll]); + RB bjk = tcb ? HashMatrix< I, RB >::conj(B.aij[ll]) : B.aij[ll]; + + AB(i, k) += c * aij * bjk; + } + } + } + if (halfB) { + if (!tb) + B.CSC( ); // sort by COL nd build p. else - B.CSR(); // sort by row... and build p. - int * Bj = tb ? B.i : B.j; - int * Bi = tb ? B.j : B.i; - // first Half - for(size_t l=0; l< A.nnz;++l) - { - I i=A.i[l],j=A.j[l]; - RA aij=A.aij[l]; - if(ta) swap(i,j); - if(tca) aij=HashMatrix::conj(aij); - - for(size_t ll=B.p[j]; ll< B.p[j+1] ;++ll) - { - I k = Bj[ll]; - if(verbosity>1000000000) cout << " *** " << i<< " " << " " << k << " : " << j << " : " - << ll << " " << B.i[ll] <<" " << B.j[ll]<< " :: " << A.aij[l]*B.aij[ll] <::conj(B.aij[ll]) : B.aij[ll]; - - AB(i,k) += c* aij*bjk; - } + B.CSR( ); // sort by row... and build p. + // first Half miss .. + for (size_t l = 0; l < A.nnz; ++l) { + I i = A.i[l], j = A.j[l]; + RA aij = A.aij[l]; + if (ta) swap(i, j); + if (tca) aij = HashMatrix< I, RA >::conj(aij); + + for (size_t ll = B.p[j]; ll < B.p[j + 1]; ++ll) { + if (Bi[ll] == Bj[ll]) continue; + I k = Bi[ll]; + + assert(j == Bj[ll]); + RB bjk = B.aij[ll]; + if (tb) bjk = HashMatrix< I, RB >::conj(bjk); + AB(i, k) += c * aij * bjk; + } } // second Half of A - if( halfA ) - { - if(verbosity>10) cout<< " ** halfA "<< endl; - for(size_t l=0; l< A.nnz;++l) - { - I i=A.i[l],j=A.j[l]; - if( i==j) continue; - RA aij=A.aij[l]; - if(!ta) swap(i,j); - //if(!tca) aij=HashMatrix::conj(aij); - - for(size_t ll=B.p[j]; ll< B.p[j+1] ;++ll) - { - I k = Bj[ll]; - if(verbosity>1000000000) cout << " *** " << i<< " " << " " << k << " : " << j << " : " - << ll << " " << B.i[ll] <<" " << B.j[ll]<< " :: " << A.aij[l]*B.aij[ll] <::conj(B.aij[ll]) : B.aij[ll]; - - AB(i,k) += c* aij*bjk; + if (halfA) + for (size_t l = 0; l < A.nnz; ++l) { + I i = A.i[l], j = A.j[l]; + if (i == j) continue; + RA aij = A.aij[l]; + if (!ta) swap(i, j); + // if(!tca) aij=HashMatrix::conj(aij); + + for (size_t ll = B.p[j]; ll < B.p[j + 1]; ++ll) { + if (Bi[ll] == Bj[ll]) continue; + I k = Bi[ll]; + if (verbosity > 1000000000) cout << " *** " << i << " " << " " << k << " : " << j << " : " << ll << " " << B.i[ll] << " " << B.j[ll] << " :: " << A.aij[l] * B.aij[ll] << endl; + assert(j == Bj[ll]); + RB bjk = tcb ? HashMatrix< I, RB >::conj(B.aij[ll]) : B.aij[ll]; + + AB(i, k) += c * aij * bjk; } - } - } - if( halfB) - { - if( !tb) - B.CSC(); // sort by COL nd build p. - else - B.CSR(); // sort by row... and build p. - // first Half miss .. - for(size_t l=0; l< A.nnz;++l) - { - I i=A.i[l],j=A.j[l]; - RA aij=A.aij[l]; - if(ta) swap(i,j); - if(tca) aij=HashMatrix::conj(aij); - - for(size_t ll=B.p[j]; ll< B.p[j+1] ;++ll) - { - if( Bi[ll]== Bj[ll]) continue; - I k = Bi[ll]; - - assert(j == Bj[ll]); - RB bjk = B.aij[ll]; - if(tb) bjk = HashMatrix::conj(bjk); - AB(i,k) += c* aij*bjk; - } } - // second Half of A - if( halfA ) - for(size_t l=0; l< A.nnz;++l) - { - I i=A.i[l],j=A.j[l]; - if( i==j) continue; - RA aij=A.aij[l]; - if(!ta) swap(i,j); - //if(!tca) aij=HashMatrix::conj(aij); - - for(size_t ll=B.p[j]; ll< B.p[j+1] ;++ll) - { - if( Bi[ll]== Bj[ll]) continue; - I k = Bi[ll]; - if(verbosity>1000000000) cout << " *** " << i<< " " << " " << k << " : " << j << " : " - << ll << " " << B.i[ll] <<" " << B.j[ll]<< " :: " << A.aij[l]*B.aij[ll] <::conj(B.aij[ll]) : B.aij[ll]; - - AB(i,k) += c* aij*bjk; - } - } - - } - } -template -std::ostream & operator<<(std::ostream & f, const HashMatrix &A) -{ - int p20=20; - long pold= f.precision(); - if( pold > 20) p20= (int) pold; - if(A.type_state==HashMatrix::type_CSR) - { +template< class I, class R > +std::ostream &operator<<(std::ostream &f, const HashMatrix< I, R > &A) { + int p20 = 20; + long pold = f.precision( ); + if (pold > 20) p20 = (int)pold; + if (A.type_state == HashMatrix< I, R >::type_CSR) { using namespace std; f << "# Sparse Matrix (Morse) " << &A << endl; f << "# first line: n m (is symmetic) nnz \n"; f << "# after for each nonzero coefficient: i j a_ij where (i,j) \\in {1,...,n}x{1,...,m} \n"; - f << A.n << " " << A.m << " " << A.half << " " << A.nnz < -tuple BuildCombMat(HashMatrix & mij,const list*,bool> > &lM,bool trans,int ii00,int jj00,bool cnj) -{ - - typedef typename list *,bool> >::const_iterator lconst_iterator; +template< class R > +tuple< int, int, bool > BuildCombMat(HashMatrix< int, R > &mij, const list< tuple< R, VirtualMatrix< int, R > *, bool > > &lM, bool trans, int ii00, int jj00, bool cnj) { - lconst_iterator begin=lM.begin(); - lconst_iterator end=lM.end(); - lconst_iterator i; + typedef typename list< tuple< R, VirtualMatrix< int, R > *, bool > >::const_iterator lconst_iterator; + lconst_iterator begin = lM.begin( ); + lconst_iterator end = lM.end( ); + lconst_iterator i; - int n=0,m=0; - bool sym=true; - for(i=begin;i!=end&&sym;i++) + int n = 0, m = 0; + bool sym = true; + for (i = begin; i != end && sym; i++) { + if (get< 1 >(*i)) // M == 0 => zero matrix { - if(get<1>(*i))// M == 0 => zero matrix - { - VirtualMatrix& M=*get<1>(*i); - if(!M.sym()) - sym = false; - } + VirtualMatrix< int, R > &M = *get< 1 >(*i); + if (!M.sym( )) sym = false; } - int iter=0; - for(i=begin;i!=end;i++) + } + int iter = 0; + for (i = begin; i != end; i++) { + if (get< 1 >(*i)) // M == 0 => zero matrix { - if(get<1>(*i)) // M == 0 => zero matrix - { - VirtualMatrix & M=*get<1>(*i); - bool transpose = get<2>(*i) != trans; - bool conjuge = get<2>(*i) != cnj; - - ffassert( &M); - R coef= get<0>(*i); - if(verbosity>99) - cout << " "<< iter++<< " BuildCombMat + " << coef << "*" << &M << " " << sym << " t = " << transpose << " " << get<2>(*i) << endl; - { if(transpose) {m=max(m,M.n); n=max(n,M.m);} else{n=max(M.n,n); m=max(M.m,m);}} - - M.addMatTo(coef,mij,transpose,ii00,jj00,conjuge,0.0,sym); + VirtualMatrix< int, R > &M = *get< 1 >(*i); + bool transpose = get< 2 >(*i) != trans; + bool conjuge = get< 2 >(*i) != cnj; + + ffassert(&M); + R coef = get< 0 >(*i); + if (verbosity > 99) cout << " " << iter++ << " BuildCombMat + " << coef << "*" << &M << " " << sym << " t = " << transpose << " " << get< 2 >(*i) << endl; + { + if (transpose) { + m = max(m, M.n); + n = max(n, M.m); + } else { + n = max(M.n, n); + m = max(M.m, m); } + } + + M.addMatTo(coef, mij, transpose, ii00, jj00, conjuge, 0.0, sym); } + } - //V4 return new MatriceMorseOld(n,m,mij,sym); - return make_tuple(n,m,sym); + // V4 return new MatriceMorseOld(n,m,mij,sym); + return make_tuple(n, m, sym); } -template -tuple nmCombMat(const list*,bool> > &lM,bool trans,int ii00,int jj00,bool cnj=false) -{ - - typedef typename list *,bool> >::const_iterator lconst_iterator; +template< class R > +tuple< int, int, bool > nmCombMat(const list< tuple< R, VirtualMatrix< int, R > *, bool > > &lM, bool trans, int ii00, int jj00, bool cnj = false) { - lconst_iterator begin=lM.begin(); - lconst_iterator end=lM.end(); - lconst_iterator i; + typedef typename list< tuple< R, VirtualMatrix< int, R > *, bool > >::const_iterator lconst_iterator; + lconst_iterator begin = lM.begin( ); + lconst_iterator end = lM.end( ); + lconst_iterator i; - int n=0,m=0; - bool sym=true; - for(i=begin;i!=end&&sym;i++++) + int n = 0, m = 0; + bool sym = true; + for (i = begin; i != end && sym; i++ ++) { + if (std::get< 1 >(*i)) // M == 0 => zero matrix { - if(std::get<1>(*i)) // M == 0 => zero matrix - { - VirtualMatrix& M=*std::get<1>(*i); - if(!M.sym()) - sym = false; - } + VirtualMatrix< int, R > &M = *std::get< 1 >(*i); + if (!M.sym( )) sym = false; } + } - for(i=begin;i!=end;i++++) + for (i = begin; i != end; i++ ++) { + if (std::get< 1 >(*i)) // M == 0 => zero matrix { - if(std::get<1>(*i)) // M == 0 => zero matrix - { - VirtualMatrix& M=*std::get<1>(*i); - bool transpose = std::get<2>(*i) != trans; - ffassert( &M); - R coef=std::get<0>(*i); - if(verbosity>99) - cout << " BuildCombMat + " << coef << "*" << &M << " " << sym << " t = " << transpose << " " << std::get<2>(*i) << endl; - { if(transpose) {m=max(m,M.n); n=max(n,M.m);} else{n=max(M.n,n); m=max(M.m,m);}} - + VirtualMatrix< int, R > &M = *std::get< 1 >(*i); + bool transpose = std::get< 2 >(*i) != trans; + ffassert(&M); + R coef = std::get< 0 >(*i); + if (verbosity > 99) cout << " BuildCombMat + " << coef << "*" << &M << " " << sym << " t = " << transpose << " " << std::get< 2 >(*i) << endl; + { + if (transpose) { + m = max(m, M.n); + n = max(n, M.m); + } else { + n = max(M.n, n); + m = max(M.m, m); } + } } + } - return make_tuple(n,m,sym); + return make_tuple(n, m, sym); } -template -HashMatrix* BuildCombMat(const list*,bool> > &lM,bool trans=false,int ii00=0,int jj00=0) -{ - - auto nmsym=nmCombMat(lM,trans,ii00,jj00); - int n = std::get<0>(nmsym), m =std::get<1>(nmsym); - bool half= std::get<2>(nmsym); - HashMatrix * mij= new HashMatrix(n,m,0,int(half)); - nmsym=BuildCombMat(*mij,lM,trans,ii00,jj00,trans);// remember trans => conj +template< class R > +HashMatrix< int, R > *BuildCombMat(const list< tuple< R, VirtualMatrix< int, R > *, bool > > &lM, bool trans = false, int ii00 = 0, int jj00 = 0) { - return mij; // V4 mij; + auto nmsym = nmCombMat(lM, trans, ii00, jj00); + int n = std::get< 0 >(nmsym), m = std::get< 1 >(nmsym); + bool half = std::get< 2 >(nmsym); + HashMatrix< int, R > *mij = new HashMatrix< int, R >(n, m, 0, int(half)); + nmsym = BuildCombMat(*mij, lM, trans, ii00, jj00, trans); // remember trans => conj + return mij; // V4 mij; } -template -static inline pair ij_mat(bool trans,I ii00,I jj00,I i,I j) { - // warning trans sub matrix and not the block. - return trans ? make_pair(j+ii00,i+jj00) - : make_pair(i+ii00,j+jj00) ; } - - +template< class I > +static inline pair< I, I > ij_mat(bool trans, I ii00, I jj00, I i, I j) { + // warning trans sub matrix and not the block. + return trans ? make_pair< I, I >(j + ii00, i + jj00) : make_pair< I, I >(i + ii00, j + jj00); +} -template template -void HashMatrix::HMcopy( T *dst,const TT *from, size_t nn, T(*ff)(TT)) -{ - for(size_t i=0; i< nn; ++i) - dst[i]= ff(from[i]); +template< class I, class R > +template< typename T, typename TT > +void HashMatrix< I, R >::HMcopy(T *dst, const TT *from, size_t nn, T (*ff)(TT)) { + for (size_t i = 0; i < nn; ++i) dst[i] = ff(from[i]); } -template template -void HashMatrix::HMcopy( T *dst,const TT *from, size_t nn) -{ - for(size_t i=0; i< nn; ++i) - dst[i]= (T) from[i]; +template< class I, class R > +template< typename T, typename TT > +void HashMatrix< I, R >::HMcopy(T *dst, const TT *from, size_t nn) { + for (size_t i = 0; i < nn; ++i) dst[i] = (T)from[i]; } -template template HashMatrix & -HashMatrix::operator+=(const HashMatrix& A ) -{ - Addto(this,&A,cast_funct); +template< class I, class R > +template< class II, class RR > +HashMatrix< I, R > &HashMatrix< I, R >::operator+=(const HashMatrix< II, RR > &A) { + Addto(this, &A, cast_funct); } - -template template -void HashMatrix::set(II nn,II mm,int hhalf,size_t nnnz, II *ii, II*jj, RR *aa,int f77,R(*ff)(RR)) -{ - clear(); - this->n=nn; - this->m=mm; - this->N=nn; - this->M=mm; - fortran=f77; - half=hhalf; - Increaze(nnnz); - nnz=nnnz; - - HMcopy(i,ii,nnnz); - HMcopy(j,jj,nnnz); - HMcopy(aij,aa,nnnz,ff); - ReHash(); +template< class I, class R > +template< class II, class RR > +void HashMatrix< I, R >::set(II nn, II mm, int hhalf, size_t nnnz, II *ii, II *jj, RR *aa, int f77, R (*ff)(RR)) { + clear( ); + this->n = nn; + this->m = mm; + this->N = nn; + this->M = mm; + fortran = f77; + half = hhalf; + Increaze(nnnz); + nnz = nnnz; + + HMcopy(i, ii, nnnz); + HMcopy(j, jj, nnnz); + HMcopy(aij, aa, nnnz, ff); + ReHash( ); } -template template -void HashMatrix::set(II nn,II mm,int hhalf,size_t nnnz, II *ii, II*jj, R *aa,int f77) -{ - clear(); - this->n=nn; - this->m=mm; - this->N=nn; - this->M=mm; - fortran=f77; - half=hhalf; - Increaze(nnnz); - nnz=nnnz; - - HMcopy(i,ii,nnnz); - HMcopy(j,jj,nnnz); - HMcopy(aij,aa,nnnz); - ReHash(); +template< class I, class R > +template< class II > +void HashMatrix< I, R >::set(II nn, II mm, int hhalf, size_t nnnz, II *ii, II *jj, R *aa, int f77) { + clear( ); + this->n = nn; + this->m = mm; + this->N = nn; + this->M = mm; + fortran = f77; + half = hhalf; + Increaze(nnnz); + nnz = nnnz; + + HMcopy(i, ii, nnnz); + HMcopy(j, jj, nnnz); + HMcopy(aij, aa, nnnz); + ReHash( ); } #endif diff --git a/src/femlib/HashTable.hpp b/src/femlib/HashTable.hpp index c489ae69f..125e56603 100644 --- a/src/femlib/HashTable.hpp +++ b/src/femlib/HashTable.hpp @@ -1,219 +1,184 @@ +inline size_t rotl(size_t value, int shift) { return (value << shift) | (value >> (sizeof(value) * 8 - shift)); } +template< typename T, int N > +struct SortArray {}; - - -inline size_t rotl(size_t value, int shift) { - return (value << shift) | (value >> (sizeof(value) * 8 - shift)); -} -template -struct SortArray { -}; - -template -struct SortArray { +template< typename T > +struct SortArray< T, 1 > { T v[1]; -SortArray(T *a,int * sens=0) - { - v[0]=a[0]; - if(sens) *sens =1; - } - SortArray(const T& a0) - { - v[0]=a0; + SortArray(T *a, int *sens = 0) { + v[0] = a[0]; + if (sens) *sens = 1; } - SortArray(){} - bool operator == (const SortArray & t) const - { return v[0] == t.v[0] ;} - bool operator<(const SortArray & t) const - { return v[0] < t.v[0] ;} - size_t hash() const {return (size_t) v[0];} + SortArray(const T &a0) { v[0] = a0; } + SortArray( ) {} + bool operator==(const SortArray< T, 1 > &t) const { return v[0] == t.v[0]; } + bool operator<(const SortArray< T, 1 > &t) const { return v[0] < t.v[0]; } + size_t hash( ) const { return (size_t)v[0]; } }; - -template -struct SortArray { +template< typename T > +struct SortArray< T, 2 > { // using std::swap; T v[2]; - SortArray(T *a,int * sens=0) - { int s=1; - v[0]=a[0]; - v[1]=a[1]; - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - if(sens) *sens=s; + SortArray(T *a, int *sens = 0) { + int s = 1; + v[0] = a[0]; + v[1] = a[1]; + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); + if (sens) *sens = s; } - SortArray(const T& a0,const T &a1) - { - v[0]=a0; - v[1]=a1; - if(v[0]>v[1]) swap(v[0],v[1]); + SortArray(const T &a0, const T &a1) { + v[0] = a0; + v[1] = a1; + if (v[0] > v[1]) swap(v[0], v[1]); } - SortArray(){} - bool operator == (const SortArray & t) const - { return v[0] == t.v[0] && v[1] == t.v[1] ;} - bool operator<(const SortArray & t) const - { return v[0] != t.v[0] ? v[0] < t.v[0] : v[1] < t.v[1] ;} - //size_t hash() const {return (size_t) v[0] + rotl(v[1],2) ;} - size_t hash() const {return (size_t) v[0] + 257LU*(size_t) v[0] ;} + SortArray( ) {} + bool operator==(const SortArray< T, 2 > &t) const { return v[0] == t.v[0] && v[1] == t.v[1]; } + bool operator<(const SortArray< T, 2 > &t) const { return v[0] != t.v[0] ? v[0] < t.v[0] : v[1] < t.v[1]; } + // size_t hash() const {return (size_t) v[0] + rotl(v[1],2) ;} + size_t hash( ) const { return (size_t)v[0] + 257LU * (size_t)v[0]; } }; - -template -struct SortArray { +template< typename T > +struct SortArray< T, 3 > { T v[3]; - SortArray(T *a,int *sens=0) - { - int s=1; - v[0]=a[0]; - v[1]=a[1]; - v[2]=a[2]; - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - if(v[1]>v[2]) { - s=-s,swap(v[1],v[2]); - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - ASSERTION(v[0] <= v[1] && v[1] <= v[2] ); + SortArray(T *a, int *sens = 0) { + int s = 1; + v[0] = a[0]; + v[1] = a[1]; + v[2] = a[2]; + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); + if (v[1] > v[2]) { + s = -s, swap(v[1], v[2]); + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); + ASSERTION(v[0] <= v[1] && v[1] <= v[2]); } - if(sens) *sens=s; + if (sens) *sens = s; } - - SortArray(){} - bool operator == (const SortArray & t) const - { return v[0] == t.v[0] && v[1] == t.v[1] && v[2] == t.v[2] ;} - - bool operator<(const SortArray & t) const - { return v[0] != t.v[0] ? v[0] < t.v[0] : - ( v[1] != t.v[1] ? v[1] < t.v[1] : v[2] < t.v[2] );} - //size_t hash() const {return (size_t) v[0] + rotl(v[1],2) * rotl(v[2],4) ;} - size_t hash() const {return (size_t) v[0] + 257LU*(size_t) v[1] + 49993LU*(size_t) v[2] ;} - - // size_t hash() const {return (size_t) v[0];} + + SortArray( ) {} + bool operator==(const SortArray< T, 3 > &t) const { return v[0] == t.v[0] && v[1] == t.v[1] && v[2] == t.v[2]; } + + bool operator<(const SortArray< T, 3 > &t) const { return v[0] != t.v[0] ? v[0] < t.v[0] : (v[1] != t.v[1] ? v[1] < t.v[1] : v[2] < t.v[2]); } + // size_t hash() const {return (size_t) v[0] + rotl(v[1],2) * rotl(v[2],4) ;} + size_t hash( ) const { return (size_t)v[0] + 257LU * (size_t)v[1] + 49993LU * (size_t)v[2]; } + + // size_t hash() const {return (size_t) v[0];} }; -template -struct SortArray { - T v[4]; - SortArray(T *a,int *sens=0) - { - int s=1; - v[0]=a[0]; - v[1]=a[1]; - v[2]=a[2]; - v[3]=a[3]; - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - if(v[1]>v[2]) { - s=-s,swap(v[1],v[2]); - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - } - if(v[2]>v[3]) { - s=-s,swap(v[3],v[2]); - if(v[1]>v[2]) s=-s,swap(v[1],v[2]); - if(v[0]>v[1]) s=-s,swap(v[0],v[1]); - } - - ASSERTION(v[0] <= v[1] && v[1] <= v[2] && v[2] <= v[3]); - - if(sens) *sens=s; +template< typename T > +struct SortArray< T, 4 > { + T v[4]; + SortArray(T *a, int *sens = 0) { + int s = 1; + v[0] = a[0]; + v[1] = a[1]; + v[2] = a[2]; + v[3] = a[3]; + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); + if (v[1] > v[2]) { + s = -s, swap(v[1], v[2]); + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); } - - SortArray(){} - bool operator == (const SortArray & t) const - { return v[0] == t.v[0] && v[1] == t.v[1] && v[2] == t.v[2] && v[3] == t.v[3] ;} - - bool operator<(const SortArray & t) const - { return v[0] != t.v[0] ? v[0] < t.v[0] : - ( v[1] != t.v[1] ? v[1] < t.v[1] : - ( v[2] != t.v[2] ? v[2] < t.v[2]: v[3] < t.v[3] ));} - -// size_t hash() const {return (size_t) v[0] + rotl(v[1],2) + rotl(v[2],4) + rotl(v[3],6);} - size_t hash() const {return (size_t) v[0] + 257LU*(size_t) v[1] + 66067LU*(size_t) v[2] +16974611LU*(size_t) v[3] ;} - - + if (v[2] > v[3]) { + s = -s, swap(v[3], v[2]); + if (v[1] > v[2]) s = -s, swap(v[1], v[2]); + if (v[0] > v[1]) s = -s, swap(v[0], v[1]); + } + + ASSERTION(v[0] <= v[1] && v[1] <= v[2] && v[2] <= v[3]); + + if (sens) *sens = s; + } + + SortArray( ) {} + bool operator==(const SortArray< T, 4 > &t) const { return v[0] == t.v[0] && v[1] == t.v[1] && v[2] == t.v[2] && v[3] == t.v[3]; } + + bool operator<(const SortArray< T, 4 > &t) const { return v[0] != t.v[0] ? v[0] < t.v[0] : (v[1] != t.v[1] ? v[1] < t.v[1] : (v[2] != t.v[2] ? v[2] < t.v[2] : v[3] < t.v[3])); } + + // size_t hash() const {return (size_t) v[0] + rotl(v[1],2) + rotl(v[2],4) + rotl(v[3],6);} + size_t hash( ) const { return (size_t)v[0] + 257LU * (size_t)v[1] + 66067LU * (size_t)v[2] + 16974611LU * (size_t)v[3]; } }; -template -ostream & operator<<(ostream & f,const SortArray & item) -{ - for (int i=0;i +ostream &operator<<(ostream &f, const SortArray< T, N > &item) { + for (int i = 0; i < N; ++i) f << " " << item.v[i]; + return f; } -template -bool commonValue(const SortArray & t) { - for(int i=1;i +bool commonValue(const SortArray< T, N > &t) { + for (int i = 1; i < N; i++) + if (t.v[i - 1] == t.v[i]) return true; + return false; } -template +template< class K, class V > class HashTable { -public: - struct nKV { size_t next; K k; V v; - nKV(){} }; + public: + struct nKV { + size_t next; + K k; + V v; + nKV( ) {} + }; typedef nKV *iterator; - size_t n,nx,nk,ncol,nfind; - size_t * head; - nKV * t; - static const size_t endhash= (size_t) -1; - - HashTable(size_t nnx,size_t nnk) - : n(0),nx(nnx),nk(nnk),ncol(0),nfind(0), - head(new size_t[nk]),t(new nKV[nx]) - { reset();} - - void reset() - { - n=0; - ncol=0; - for (size_t j=0;jv; - else return t[add(key,V())].v; + if (p) + return p->v; + else + return t[add(key, V( ))].v; } - ~HashTable() - { - if(nfind && verbosity>4) - cout << " ~HashTable: Cas moyen : " << (double) ncol/ nfind << endl; - delete [] head; - delete [] t; + ~HashTable( ) { + if (nfind && verbosity > 4) cout << " ~HashTable: Cas moyen : " << (double)ncol / nfind << endl; + delete[] head; + delete[] t; } // pas de copie .... -private: - HashTable(const HashTable&); - void operator=(const HashTable&); + private: + HashTable(const HashTable &); + void operator=(const HashTable &); }; diff --git a/src/femlib/HeapSort.hpp b/src/femlib/HeapSort.hpp old mode 100755 new mode 100644 index 96840004f..2496aa30b --- a/src/femlib/HeapSort.hpp +++ b/src/femlib/HeapSort.hpp @@ -23,56 +23,85 @@ #ifndef _HEAP_SORT_HPP_ #define _HEAP_SORT_HPP_ -template +template< class T > void HeapSort(T *c, long n) { long l, j, r, i; T crit; if (n <= 1) return; - l = n/2; + l = n / 2; r = n - 1; - while (1) { // label 2 - if (l < 1 ) { // label 20 + while (1) { // label 2 + if (l < 1) { // label 20 crit = c[r]; c[r--] = c[0]; - if (!r) { c[0] = crit; return; } - } else crit = c[--l]; + if (!r) { + c[0] = crit; + return; + } + } else + crit = c[--l]; j = l; - while (1) { // label 4 + while (1) { // label 4 i = j; - j = 2*j + 1; - if (j > r) { c[i] = crit; break; } // L8 -> G2 - if ((j < r) && (c[j] < c[j+1])) j++; // L5 - if (crit < c[j]) c[i] = c[j]; // L6+1 G4 - else { c[i] = crit; break; } // L8 -> G2 + j = 2 * j + 1; + if (j > r) { + c[i] = crit; + break; + } // L8 -> G2 + if ((j < r) && (c[j] < c[j + 1])) j++; // L5 + if (crit < c[j]) + c[i] = c[j]; // L6+1 G4 + else { + c[i] = crit; + break; + } // L8 -> G2 } } } -template +template< class K, class T > void HeapSort(K *k, T *t, long n) { long l, j, r, i; K kk; T tt; if (n <= 1) return; - l = n/2; + l = n / 2; r = n - 1; - while (1) { // label 2 - if (l < 1) { // label 20 - kk = k[r]; - tt = t[r]; - t[r] = t[0], k[r--] = k[0]; - if (!r) { k[0] = kk; t[0] = tt; return; } - } else { kk = k[--l]; tt = t[l]; } + while (1) { // label 2 + if (l < 1) { // label 20 + kk = k[r]; + tt = t[r]; + t[r] = t[0], k[r--] = k[0]; + if (!r) { + k[0] = kk; + t[0] = tt; + return; + } + } else { + kk = k[--l]; + tt = t[l]; + } j = l; - while (1) { // label 4 - i = j; - j = 2*j + 1; - if (j > r) { k[i] = kk; t[i] = tt; break; } // L8 -> G2 - if ((j < r) && (k[j] < k[j+1])) j++; // L5 - if (kk < k[j]) { k[i] = k[j]; t[i] = t[j]; } // L6+1 G4 - else { k[i] = kk; t[i] = tt; break; } //L8 -> G2 + while (1) { // label 4 + i = j; + j = 2 * j + 1; + if (j > r) { + k[i] = kk; + t[i] = tt; + break; + } // L8 -> G2 + if ((j < r) && (k[j] < k[j + 1])) j++; // L5 + if (kk < k[j]) { + k[i] = k[j]; + t[i] = t[j]; + } // L6+1 G4 + else { + k[i] = kk; + t[i] = tt; + break; + } // L8 -> G2 } } } -#endif //_HEAP_SORT_HPP_ +#endif //_HEAP_SORT_HPP_ diff --git a/src/femlib/InvIntFunc.cpp b/src/femlib/InvIntFunc.cpp index e2e893f0e..9f1f54937 100644 --- a/src/femlib/InvIntFunc.cpp +++ b/src/femlib/InvIntFunc.cpp @@ -1,30 +1,30 @@ -// used by splitsimplex.cpp -// to inverse numering ... -// F. Hecht +// used by splitsimplex.cpp +// to inverse numering ... +// F. Hecht // ORIG-DATE: fev 2009 // -*- Mode : c++ -*- // -// SUMMARY : Model mesh 2d -// USAGE : LGPL -// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE +// SUMMARY : Model mesh 2d +// USAGE : LGPL +// ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE // AUTHOR : Frederic Hecht // E-MAIL : frederic.hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -33,28 +33,31 @@ ref:ANR-07-CIS7-002-01 */ inline int InvIntFunction(int l) -// calcul de inverse de la fonction F +// calcul de inverse de la fonction F { - // inverse la function F - int i=0,j,k=F_1(l); - int Fi=F(i),Fj,Fk=F(k); - assert(l<=Fk); - while (1) - { - j = (i+k)/2; - if(j==i) break; - Fj=F(j); - // cout << i<< j << k << " " << (l < Fj) << " : "; - if( l < Fj ) { k=j; Fk=Fj;} - else if ( l > Fj ) { i=j; Fi=Fj;} - else { i=j;} - // cout << " ** " << l << " : " << i<< " "<< j << " "<< k << " : Fi " << Fi << " " << Fj << " "<< Fk << endl; - + // inverse la function F + int i = 0, j, k = F_1(l); + int Fi = F(i), Fj, Fk = F(k); + assert(l <= Fk); + while (1) { + j = (i + k) / 2; + if (j == i) break; + Fj = F(j); + // cout << i<< j << k << " " << (l < Fj) << " : "; + if (l < Fj) { + k = j; + Fk = Fj; + } else if (l > Fj) { + i = j; + Fi = Fj; + } else { + i = j; } + // cout << " ** " << l << " : " << i<< " "<< j << " "<< k << " : Fi " << Fi << " " << Fj << " "<< Fk << endl; + } - - if( Fk==l) i=k; + if (Fk == l) i = k; // cout << " i =" << i << " l= " << l << " in [ " << F(i) << ", " << F(i+1) << "[ " << endl; - assert( (F(i) <= l) && (l < F(i+1) ) ); - return i; + assert((F(i) <= l) && (l < F(i + 1))); + return i; } diff --git a/src/femlib/Label.hpp b/src/femlib/Label.hpp index 9556c864d..c20402a16 100644 --- a/src/femlib/Label.hpp +++ b/src/femlib/Label.hpp @@ -2,19 +2,23 @@ #define LABEL_HPP // <((*a)(NullStack)); - if ( va == A() ) - { - return true; - } - } - if (mib && b->EvaluableWithOutStack() ) - { - B vb = GetAny((*b)(NullStack)); - if ( vb == B() ) - { - return true; } - } - return false; +long genrandint(long s) { + init_genrand((unsigned long)s); + return 0; +} +long genrandint32( ) { return (long)genrand_int32( ); } + +template< class A, class B, bool RO = true > +struct MIMul { + static bool MeshIndependent(Expression a, Expression b) { + bool mia = a->MeshIndependent( ); + bool mib = b->MeshIndependent( ); + if (mia && mib) + return true; + else { + if (mia && a->EvaluableWithOutStack( )) { + A va = GetAny< A >((*a)(NullStack)); + if (va == A( )) { + return true; } - + } + if (mib && b->EvaluableWithOutStack( )) { + B vb = GetAny< B >((*b)(NullStack)); + if (vb == B( )) { + return true; + } + } + return false; } - static bool ReadOnly() { return RO;} - + } + static bool ReadOnly( ) { return RO; } }; - // add frev 2007 -class opTrans : public OneOperator{ -public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - opTrans(): OneOperator(atype(),atype() ) {} - E_F0 * code(const basicAC_F0 & args) const { - return new TransE_Array(dynamic_cast((Expression) args[0])); } +class opTrans : public OneOperator { + public: + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + opTrans( ) : OneOperator(atype< TransE_Array >( ), atype< E_Array >( )) {} + E_F0 *code(const basicAC_F0 &args) const { return new TransE_Array(dynamic_cast< const E_Array * >((Expression)args[0])); } }; -class opUnary : public OneOperator{ -public: - const char * op; - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} - - opUnary(const char * oop,aType A): OneOperator(atype(),A), op(oop) {} +class opUnary : public OneOperator { + public: + const char *op; + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; + opUnary(const char *oop, aType A) : OneOperator(atype< C_F0 >( ), A), op(oop) {} + + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; }; -class opDot : public OneOperator{ -public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} +class opDot : public OneOperator { + public: + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } - opDot(aType A, aType B): OneOperator(atype(),A,B) {} - opDot(): OneOperator(atype(),atype(),atype() ) {} + opDot(aType A, aType B) : OneOperator(atype< C_F0 >( ), A, B) {} + opDot( ) : OneOperator(atype< C_F0 >( ), atype< TransE_Array >( ), atype< E_Array >( )) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; }; /* To Do FH 2024 class opPrint : public OneOperator{ @@ -630,1114 +680,974 @@ class opPrint : public OneOperator{ E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} C_F0 code2(const basicAC_F0 &args) const; };*/ -class opColumn : public OneOperator{ -public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} +class opColumn : public OneOperator { + public: + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } - opColumn(aType A, aType B): OneOperator(atype(),A,B) {if( A== basicForEachType::type_C_F0)pref=-100;} - opColumn(aType A): OneOperator(atype(),ArrayOfaType(A,true)) {pref=-100;} + opColumn(aType A, aType B) : OneOperator(atype< C_F0 >( ), A, B) { + if (A == basicForEachType::type_C_F0) pref = -100; + } + opColumn(aType A) : OneOperator(atype< C_F0 >( ), ArrayOfaType(A, true)) { pref = -100; } - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; }; -class opSum : public OneOperator{ -public: - const char * op; - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} +class opSum : public OneOperator { + public: + const char *op; + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } - opSum(const char *opp,aType A, aType B): OneOperator(atype(),A,B),op(opp) {} + opSum(const char *opp, aType A, aType B) : OneOperator(atype< C_F0 >( ), A, B), op(opp) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; }; -class opFormal : public OneOperator{ -public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} - C_F0 (*thecode2)(const basicAC_F0 &args); - opFormal(aType A,C_F0 (c2)(const basicAC_F0 &args) ): OneOperator(atype(),A),thecode2(c2) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const { return (*thecode2)(args);} +class opFormal : public OneOperator { + public: + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } + C_F0 (*thecode2)(const basicAC_F0 &args); + opFormal(aType A, C_F0(c2)(const basicAC_F0 &args)) : OneOperator(atype< C_F0 >( ), A), thecode2(c2) {} + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const { return (*thecode2)(args); } }; // fin frev 2007 // nov 2007 v[i] -class opVI : public OneOperator{ -public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} +class opVI : public OneOperator { + public: + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } + bool MeshIndependent( ) const { return false; } - opVI(aType A): OneOperator(atype(),A,atype()) {} + opVI(aType A) : OneOperator(atype< C_F0 >( ), A, atype< long >( )) {} - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; }; +C_F0 formalMatCofactor(const basicAC_F0 &args) { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + assert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + int ma = 1; + int na = a.size( ); + if (na < 1) CompileError(" Cofactor ([ ...]) "); + bool maa = a[0].left( ) == atype< E_Array >( ); + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" a matrix with variable number of columm"); + } -C_F0 formalMatCofactor(const basicAC_F0 &args) -{ - bool ta =args[0].left()==atype(); - const TransE_Array * tea=0; - const E_Array * ea=0; - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - assert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - int ma =1; - int na=a.size(); - if(na <1 ) CompileError(" Cofactor ([ ...]) "); - bool maa= a[0].left()==atype(); - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" a matrix with variable number of columm"); - + int na1 = na, ma1 = ma; + if (ta) RNM::Exchange(na1, ma1); + if (na1 != ma1) CompileError(" CoFactor: no square matrix "); + if (na1 > 3 || (na1 < 1)) CompileError(" CoFactor: square matrix size is more then 3 "); + KNM< CC_F0 > A(na1, na1); + KNM< CC_F0 > C(na1, na1); + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); } - - int na1=na,ma1=ma; - if(ta) RNM::Exchange(na1,ma1); - if(na1 != ma1) CompileError(" CoFactor: no square matrix "); - if(na1 > 3 || ( na1 <1) ) CompileError(" CoFactor: square matrix size is more then 3 "); - KNM A(na1,na1); - KNM C(na1,na1); - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(); - const TransE_Array * tea=0; - const E_Array * ea=0; - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - assert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - int ma =1; - int na=a.size(); - if(na <1 ) CompileError(" trace [ ...] "); - bool maa= a[0].left()==atype(); - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" first matrix with variable number of columm"); - - } + v += vi; + } + return C_F0(TheOperators, "[]", v); +} - int na1=na,ma1=ma; - if(ta) RNM::Exchange(na1,ma1); - if(na1 != ma1) CompileError(" trace: no square matrix "); - KNM A(na1,ma1); - - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(); - const TransE_Array * tea=0; - const E_Array * ea=0; - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - assert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - int ma =1; - int na=a.size(); - if(na <1 ) CompileError(" trace [ ...] "); - bool maa= a[0].left()==atype(); - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" matrix with variable number of columm"); +C_F0 formalMatTrace(const basicAC_F0 &args) { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + assert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + int ma = 1; + int na = a.size( ); + if (na < 1) CompileError(" trace [ ...] "); + bool maa = a[0].left( ) == atype< E_Array >( ); + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" first matrix with variable number of columm"); + } + int na1 = na, ma1 = ma; + if (ta) RNM::Exchange(na1, ma1); + if (na1 != ma1) CompileError(" trace: no square matrix "); + KNM< CC_F0 > A(na1, ma1); + + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); } + else + for (int i = 0; i < na; ++i) + if (!ta) + A(i, 0) = a[i]; + else + A(0, i) = TryConj(a[i]); + + CC_F0 s; + s = A(0, 0); // correction feb. 2016 Thank to O. Pironneau + for (int i = 1; i < na1; ++i) s = C_F0(TheOperators, "+", s, A(i, i)); + return s; +} - int na1=na,ma1=ma; - if(ta) RNM::Exchange(na1,ma1); - if(na1 != ma1) CompileError(" trace: no square matrix "); - KNM A(na1,ma1); - - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j( ); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + assert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + int ma = 1; + int na = a.size( ); + if (na < 1) CompileError(" trace [ ...] "); + bool maa = a[0].left( ) == atype< E_Array >( ); + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" matrix with variable number of columm"); + } + int na1 = na, ma1 = ma; + if (ta) RNM::Exchange(na1, ma1); + if (na1 != ma1) CompileError(" trace: no square matrix "); + KNM< CC_F0 > A(na1, ma1); + + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); + } + else + for (int i = 0; i < na; ++i) + if (!ta) + A(i, 0) = a[i]; + else + A(0, i) = TryConj(a[i]); + + if (na1 == 1) + return A(0, 0); + else if (na1 == 2) { + C_F0 s1(TheOperators, "*", A(0, 0), A(1, 1)); + C_F0 s2(TheOperators, "*", A(0, 1), A(1, 0)); + return C_F0(TheOperators, "-", s1, s2); + } else if (na1 == 3) { + int i = 0, ii = (i + 1) % 3, iii = (i + 2) % 3; + A(i, 0) * A(i, 0); + C_F0 det = A(i, 0) * A(ii, 1) * A(iii, 2) - A(i, 0) * A(ii, 2) * A(iii, 1); + i++; + ii = (i + 1) % 3, iii = (i + 2) % 3; + det += A(i, 0) * A(ii, 1) * A(iii, 2) - A(i, 0) * A(ii, 2) * A(iii, 1); + i++; + ii = (i + 1) % 3, iii = (i + 2) % 3; + det += A(i, 0) * A(ii, 1) * A(iii, 2) - A(i, 0) * A(ii, 2) * A(iii, 1); + return det; + } else { + CompileError("FH: sorry only det of 1x1 and 2x2 matrix "); + } + return C_F0( ); } // Add juin 2007 -template +template< class A, class B = A, class R = A > struct evalE_mul { - static AnyType eval(Stack s,const E_F0 * ab,const E_F0 * a,const E_F0 * b, bool & meshidenp) - { - A aa = GetAny((*a)(s)) ; - B bb = GetAny((*b)(s)) ; - R rr(aa*bb); - bool mia=a->MeshIndependent(); - bool mib=b->MeshIndependent(); - - if (( aa == A()) && mia ) meshidenp=true; - else if(( bb == B()) && mib ) meshidenp=true; - else meshidenp = mib && mia; - cout << " meshidenp ??? " << meshidenp << " " << rr << endl; - return SetAny(static_cast(rr)); - } + static AnyType eval(Stack s, const E_F0 *ab, const E_F0 *a, const E_F0 *b, bool &meshidenp) { + A aa = GetAny< A >((*a)(s)); + B bb = GetAny< B >((*b)(s)); + R rr(aa * bb); + bool mia = a->MeshIndependent( ); + bool mib = b->MeshIndependent( ); + + if ((aa == A( )) && mia) + meshidenp = true; + else if ((bb == B( )) && mib) + meshidenp = true; + else + meshidenp = mib && mia; + cout << " meshidenp ??? " << meshidenp << " " << rr << endl; + return SetAny< R >(static_cast< R >(rr)); + } }; -istream *Getline(istream * f, string ** s) -{ - if( *s==0) *s=newstring(); - getline(*f,**s); - size_t l = (**s).length(); - if( l > 0 && ((**s)[l-1]=='\r')) (**s).resize(l-1); // - return f; +istream *Getline(istream *f, string **s) { + if (*s == 0) *s = newstring( ); + getline(*f, **s); + size_t l = (**s).length( ); + if (l > 0 && ((**s)[l - 1] == '\r')) (**s).resize(l - 1); // + return f; } // Fin Add ne marche pas .... // fiun avril 2007 // Hack to Bypass a bug in freefem FH ... template<> -class ForEachType: public basicForEachType{public:// correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(void *),sizeof(void *),0,0,iv,id,OOnReturn) { } +class ForEachType< void * > : public basicForEachType { + public: // correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(void *), sizeof(void *), 0, 0, iv, id, OOnReturn) {} }; -inline double walltime(){ - // add for Pichon mars 2010 - time_t currentWallTime; - time(¤tWallTime); - return (double)currentWallTime; -} - -inline long fftime() -{ - time_t tloc; - return time(&tloc); -} -long ffstrtol(string* p) -{ - char * pe; - const char *pp=p->c_str(); - long r = strtol(pp,&pe,10); - const char *ppe = pe, *pppe= pp+p->size(); - assert(ppe <= pppe); - for(const char *ppe = pe; ppe < pppe; ++ppe) - ffassert(isspace(*ppe)); - return r; +inline double walltime( ) { + // add for Pichon mars 2010 + time_t currentWallTime; + time(¤tWallTime); + return (double)currentWallTime; +} +inline long fftime( ) { + time_t tloc; + return time(&tloc); } -long ffstrtol(string* p,long d) -{ - char * pe; - const char *pp=p->c_str(); - long r = strtol(pp,&pe,d); - const char *ppe = pe, *pppe= pp+p->size(); - ffassert(ppe <= pppe); - for(const char *ppe = pe; ppe < pppe; ++ppe) - ffassert(isspace(*ppe)); - return r; +long ffstrtol(string *p) { + char *pe; + const char *pp = p->c_str( ); + long r = strtol(pp, &pe, 10); + const char *ppe = pe, *pppe = pp + p->size( ); + assert(ppe <= pppe); + for (const char *ppe = pe; ppe < pppe; ++ppe) ffassert(isspace(*ppe)); + return r; +} +long ffstrtol(string *p, long d) { + char *pe; + const char *pp = p->c_str( ); + long r = strtol(pp, &pe, d); + const char *ppe = pe, *pppe = pp + p->size( ); + ffassert(ppe <= pppe); + for (const char *ppe = pe; ppe < pppe; ++ppe) ffassert(isspace(*ppe)); + return r; } -double ffstrtod(string* p) -{ - char * pe; - const char *pp=p->c_str(); - double r = strtod(pp,&pe); - const char *ppe = pe, *pppe= pp+p->size(); - ffassert(ppe <= pppe); - for(const char *ppe = pe; ppe < pppe; ++ppe) - ffassert(isspace(*ppe)); - return r; +double ffstrtod(string *p) { + char *pe; + const char *pp = p->c_str( ); + double r = strtod(pp, &pe); + const char *ppe = pe, *pppe = pp + p->size( ); + ffassert(ppe <= pppe); + for (const char *ppe = pe; ppe < pppe; ++ppe) ffassert(isspace(*ppe)); + return r; +} +long atoi(string *p) { return atol(p->c_str( )); } // add march 2010 +double atof(string *p) { return atof(p->c_str( )); } // add march 2010 +double NaN(string *p) { return nan(p->c_str( )); } // add march 2012 +double NaN( ) { return nan(""); } // add march 2012 +int ShowAlloc(const char *s, size_t &lg); +long ShowAlloc1(string *s, long *np) { + size_t lg; + long n = ShowAlloc(s->c_str( ), lg); + *np = lg; + return n; +} +long ShowAlloc1(string *s) { + size_t lg; + long n = ShowAlloc(s->c_str( ), lg); + return n; } -long atoi(string* p) {return atol(p->c_str());}// add march 2010 -double atof(string* p) {return atof(p->c_str());}// add march 2010 -double NaN(string* p) { -return nan(p->c_str());}// add march 2012 -double NaN() {return nan("");}// add march 2012 -int ShowAlloc(const char *s,size_t & lg); -long ShowAlloc1(string * s,long * np) { size_t lg; long n= ShowAlloc(s->c_str(),lg); *np=lg; return n;} -long ShowAlloc1(string * s) { size_t lg; long n= ShowAlloc(s->c_str(),lg); return n;} - -class E_ForAllLoopMapSS -{ public: - typedef String K; - typedef String V; - typedef string *KK; - typedef string *VV; - - typedef MyMap *Tab; - typedef MyMap::iterator TabI ; - - typedef ForAllLoopOpBase DataL; - const DataL *data; - E_ForAllLoopMapSS(const DataL *t): data(t){} - AnyType f(Stack s) const { - TabI ii; - Tab t= GetAny(data->tab(s)); - - KK * i = GetAny(data->i(s)); - VV * v = GetAny(data->v(s)); - if(verbosity>1000) { - cout << " i " << (char*) (void *) i - (char*)(void*) s ; - cout << " vi " << (char*) (void *) v - (char*)(void*) s ; - cout << endl;} - - - ffassert(i && v); - if(t->m) - ii=t->m->begin(); - bool ok = true; - while(ok) - { - if(verbosity>99999) cout << " new n"; - TabI iip=ii++; - ok = ii != t->m->end(); - String kk = iip->first; - String vv = iip->second; - const string * pvo=iip->second; - - *i = kk; - *v = vv; - const string * pv =*v; - // for Windows otherwise trap ???? FH. march 2016 - if(verbosity>99999) cout << " b:" << i << " "<< v << " " << kk << " " << vv << endl; - - data->code(s); - if(verbosity>99999) cout << " a:" << i << " "<< v << " " << kk << " " << **v << endl; - if( pvo == (const string *) iip->second) // no change m[i]= - {if( *v != pv ) // v change - iip->second = **v; - } - else if( *v != pv ) - {// v change - cerr << " Erreur forall change m[i] and mi (stupide please choosse) \n"; - ffassert(0); - } - if(verbosity>99999) cout << " A;" << i << " "<< v << " " << kk << " " << vv << " ok =" << ok << endl; - - *i=0; - *v=0; - if(verbosity>99999) - { - cout << " 0:" << i << " "<< v << " " << kk << " " << vv << endl; - for (TabI iii=t->m->begin();iii!= t->m->end();++iii) - cout << " map =" << iii->first << " -> " << iii->second << endl; - cout << " end of map " << endl; - } - } - return Nothing ; +class E_ForAllLoopMapSS { + public: + typedef String K; + typedef String V; + typedef string *KK; + typedef string *VV; + + typedef MyMap< K, V > *Tab; + typedef MyMap< K, V >::iterator TabI; + + typedef ForAllLoopOpBase DataL; + const DataL *data; + E_ForAllLoopMapSS(const DataL *t) : data(t) {} + AnyType f(Stack s) const { + TabI ii; + Tab t = GetAny< Tab >(data->tab(s)); + + KK *i = GetAny< KK * >(data->i(s)); + VV *v = GetAny< VV * >(data->v(s)); + if (verbosity > 1000) { + cout << " i " << (char *)(void *)i - (char *)(void *)s; + cout << " vi " << (char *)(void *)v - (char *)(void *)s; + cout << endl; } + ffassert(i && v); + if (t->m) ii = t->m->begin( ); + bool ok = true; + while (ok) { + if (verbosity > 99999) cout << " new n"; + TabI iip = ii++; + ok = ii != t->m->end( ); + String kk = iip->first; + String vv = iip->second; + const string *pvo = iip->second; + + *i = kk; + *v = vv; + const string *pv = *v; + // for Windows otherwise trap ???? FH. march 2016 + if (verbosity > 99999) cout << " b:" << i << " " << v << " " << kk << " " << vv << endl; + + data->code(s); + if (verbosity > 99999) cout << " a:" << i << " " << v << " " << kk << " " << **v << endl; + if (pvo == (const string *)iip->second) // no change m[i]= + { + if (*v != pv) // v change + iip->second = **v; + } else if (*v != pv) { // v change + cerr << " Erreur forall change m[i] and mi (stupide please choosse) \n"; + ffassert(0); + } + if (verbosity > 99999) cout << " A;" << i << " " << v << " " << kk << " " << vv << " ok =" << ok << endl; + + *i = 0; + *v = 0; + if (verbosity > 99999) { + cout << " 0:" << i << " " << v << " " << kk << " " << vv << endl; + for (TabI iii = t->m->begin( ); iii != t->m->end( ); ++iii) cout << " map =" << iii->first << " -> " << iii->second << endl; + cout << " end of map " << endl; + } + } + return Nothing; + } }; - double projection(const double & aa, const double & bb, const double & x ) -{ double a=aa,b=bb; if(a>b) std::swap(a,b); return min(max(a,x),b);} -double dist(const double & aa, const double & bb) { return sqrt( aa*aa+bb*bb);} -double dist(const double & aa, const double & bb,const double & cc) { return sqrt(aa*aa+bb*bb+cc*cc);} +double projection(const double &aa, const double &bb, const double &x) { + double a = aa, b = bb; + if (a > b) std::swap(a, b); + return min(max(a, x), b); +} +double dist(const double &aa, const double &bb) { return sqrt(aa * aa + bb * bb); } +double dist(const double &aa, const double &bb, const double &cc) { return sqrt(aa * aa + bb * bb + cc * cc); } // Add Jan 2017 FH -double diffpos(const double & aa, const double & bb) { return aa0.)-(x<0.); }// Add FH jan 2018 -long sign(long x){return (x>0)-(x<0); }// Add FH jan 2018 -bool ffsignbit(long x){return signbit(x);} -bool ffsignbit(double x){return signbit(x);} -template -bool pswap(T *a,T *b) {swap(*a,*b);return 0; } -long lrintc(Complex x) { return lrint(real(x));} -long lroundc(Complex x) { return lround(real(x));} -void Init_map_type() -{ - TheOperators=new Polymorphic(), - TheRightOperators=new Polymorphic(); - map_type[typeid(AnyType).name()] = new ForTypeAnyType(); - map_type[typeid(void).name()] = new ForTypeVoid(); - InitLoop(); - Dcl_Type(0); - Dcl_TypeandPtr(0,0,::InitializeDef,0); - Dcl_TypeandPtr(0,0,::InitializeDef,0); - Dcl_TypeandPtr(0,0,::InitializeDef,0); - Dcl_TypeandPtr(0,0,::InitializeDef,0); - Dcl_Type(); // add FH ... for mpi comm world - Dcl_Type(); - Dcl_Type(); - Dcl_Type(); - Dcl_TypeandPtr(0,0,::InitializePtr,::DeletePtr); - Dcl_TypeandPtr(0,0,::InitializePtr,::DeletePtr); - Dcl_TypeandPtr(0,0,::InitializePtr,::DeletePtr); - Dcl_Type< ostream_precis > (); - Dcl_Type< ostream_seekp > (); - Dcl_Type< istream_seekg > (); - Dcl_Type< istream_good > (); - Dcl_Type< NothingType > (); - Dcl_Type(); - Dcl_Type(); - - basicForEachType::type_C_F0 = map_type[typeid(C_F0).name()] = new TypeLineFunction; - Dcl_Type(); - Dcl_Type(); - Dcl_Type();// add - Dcl_Type(); - Dcl_Type(); - typedef MyMap MyMapSS; - map_type[typeid(MyMapSS*).name()] = new ForEachType(Initialize,Delete) ; - map_type_of_map[make_pair(atype(),atype())]=atype(); - - - Dcl_Type(); - Dcl_Type >(); - - initArrayDCLlong(); - initArrayDCLdouble(); - initArrayDCLComplex(); - - Dcl_Type(); - - // <> les types des variables - - zzzfff->Add("real",typevarreal=atype()); - zzzfff->Add("int",atype()); - zzzfff->Add("complex",typevarcomplex=atype()); - zzzfff->Add("bool",atype()); - zzzfff->Add("string",atype()); - zzzfff->Add("ifstream",atype()); - zzzfff->Add("ofstream",atype()); - zzzfff->AddF("func",atype()); - - - -// end of know types - - map_type[typeid(bool).name()]->AddCast( - new E_F1_funcT(UnRef), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast) - ); - - - map_type[typeid(long).name()]->AddCast( - new E_F1_funcT(UnRef), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast) - ); - - - map_type[typeid(double).name()]->AddCast( - new E_F1_funcT(UnRef), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast) - - ); - - map_type[typeid(Complex).name()]->AddCast( - new E_F1_funcT(UnRef), - new E_F1_funcT(Cast), - new E_F1_funcT(Cast) - ); - - map_type[typeid(string*).name()]->AddCast( - new E_F1_funcT(UnRefCopyPtr), - new E_F1_funcT(FCast), - new E_F1_funcT(FCast), - new E_F1_funcT(FCast), - new E_F1_funcT(FCast) - ); - // a changer --------------- modif - map_type[typeid(string*).name()]->AddCast( - new E_F1_funcT(FCast), - new E_F1_funcT(FCast) - ); - - map_type[typeid(long).name()]->AddCast(new OneOperator_border_label); - - Global.New("verbosity",CPValue(verbosity)); - - Global.New("searchMethod",CPValue(searchMethod)); //pichon - Global.New("tgv",CPValue(ff_tgv)); - Global.New("lockOrientation",CPValue(lockOrientation)); - extern long newconvect3;// def in global.cpp - Global.New("newconvect",CPValue(newconvect3)); //pichon - - // <> uses [[file:AFunction.hpp::CConstant]] - Global.New("cout",CConstant(&cout)); - - Global.New("cerr",CConstant(&cerr));// add jan 2014 FH. - Global.New("cin",CConstant(&cin)); - Global.New("append",CConstant(ios::app)); - Global.New("binary",CConstant(ios::binary)); // add FH april 2014 - TheOperators->Add("|",new OneBinaryOperator >); // add FH april 2014 - Global.New("endl",CConstant("\n")); - Global.New("true",CConstant(true)); - Global.New("false",CConstant(false)); - Global.New("pi",CConstant(3.14159265358979323846264338328)); - Global.New("version",CConstant(VersionNumber())); - - Global.New("showCPU",CPValue(showCPU)); - Global.New("CPUTime",CConstant(&showCPU)); - // def de Zero et One - pZero = new C_F0(CConstant(0.0)); - pOne = new C_F0(CConstant(1.0)); - pminusOne = new C_F0(CConstant(-1.0)); - - TheOperators->Add(":", - new OneOperatorConst(new EConstant(':')), - new OneBinaryOperator, - new OneTernaryOperator3); - - - TheOperators->Add("+", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > , - new OneBinaryOperator_st > // a changer to do FH string * mars 2006 - ); - TheOperators->Add("-", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > - ); - - TheOperators->Add("*", - new OneBinaryOperator,OneBinaryOperatorMI,evalE_mul >, - new OneBinaryOperator,OneBinaryOperatorMI,evalE_mul >, - new OneBinaryOperator,MIMul,evalE_mul >, - new OneBinaryOperator, MIMul,evalE_mul >, - new OneBinaryOperator,MIMul,evalE_mul >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > - ); - // add missing operation jan 2017 FH. - TheOperators->Add("*", - new OneBinaryOperator >, - new OneBinaryOperator > - ); - TheOperators->Add("+", - new OneBinaryOperator >, - new OneBinaryOperator > - ); - TheOperators->Add("-", - new OneBinaryOperator >, - new OneBinaryOperator > - ); - TheOperators->Add("/", - // new OneBinaryOperator >, - new OneBinaryOperator > - ); - - TheOperators->Add("/", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > - ); - - TheOperators->Add("%", - new OneBinaryOperator >, - new OneOperator2(fmod) - ); - - - TheOperators->Add("+", - new OneUnaryOperator >, - new OneUnaryOperator >, - new OneUnaryOperator >); - - TheOperators->Add("-", - new OneUnaryOperator >, - new OneUnaryOperator >, - new OneUnaryOperator >); - - TheOperators->Add("^", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > - ); - - TheOperators->Add("<", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - TheOperators->Add("<=", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - TheOperators->Add(">", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // string * mars 2006 - ); - TheOperators->Add(">=", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - TheOperators->Add("==", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - - TheOperators->Add("!=", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - - TheOperators->Add("!", - new OneUnaryOperator > - ); - - TheOperators->Add("&&", new OneBinaryOperator ); - TheOperators->Add("&", new OneBinaryOperator ); - TheOperators->Add("||", new OneBinaryOperator ); - TheOperators->Add("|", new OneBinaryOperator ); - - // Unary_Op_Comparaision - - TheOperators->Add("=", - new OneBinaryOperator ,OneBinaryOperatorMIWO >, - new OneBinaryOperator ,OneBinaryOperatorMIWO>, - new OneBinaryOperator ,OneBinaryOperatorMIWO>, - new OneBinaryOperator ,OneBinaryOperatorMIWO>, - new OneBinaryOperator // FH string * mars 2006 - ); - - TheOperators->Add("?:", - new Operator_Aritm_If, - new Operator_Aritm_If, - new Operator_Aritm_If, - new Operator_Aritm_If, - new Operator_Aritm_If // (OK???) to do FH string * mars 2006 - ); - - initArrayOperatorlong(); - initArrayOperatordouble(); - initArrayOperatorComplex(); - initStringOperator(); - - - TheOperators->Add("+=", - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO > - ); - - - TheOperators->Add("-=", - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO > - ); - - - - TheOperators->Add("*=", - new OneBinaryOperator ,OneBinaryOperatorMIWO>, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO > - ); - - - TheOperators->Add("/=", - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO > - ); - - TheOperators->Add("+", - new AddBorderOperator - ); - - // add frev 2007 - TheOperators->Add("\'", new opTrans); - // Pas formel !!!! - // TheOperators->Add("<<",new opPrint("<<",atype(),atype(),atype() ) ); - // TheOperators->Add("<<",new opPrint("<<",atype(),atype(),atype() ) ); - - TheOperators->Add("*",new opDot(atype(),atype() ) ); // a faire mais dur - TheOperators->Add("*",new opDot(atype(),atype() ) ); // a faire mais dur - TheOperators->Add("*",new opColumn(atype() ) ); // [ ]* C_F0 (all) - TheOperators->Add("*",new opColumn(basicForEachType::type_C_F0,atype() ) ); // [ ]* C_F0 (all) - TheOperators->Add("*",new opColumn(basicForEachType::type_C_F0,atype() ) ); // [ ]* C_F0 (all) -// type_C_F0 - TheOperators->Add("::",new opColumn(atype(),atype() ) ); // a faire mais dur - TheOperators->Add("*",new opDot(atype(),atype() ) ); // a faire mais dur - TheOperators->Add("*",new opDot(atype(),atype() ) ); // a faire mais dur - - // car le type de retour depent des objets du tableau - atype()->Add("[","",new opVI(atype()) ); - atype()->Add("[","",new opVI(atype()) ); - TheOperators->Add("+",new opSum("+",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("+",new opSum("+",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("+",new opSum("+",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("+",new opSum("+",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("-",new opSum("-",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("-",new opSum("-",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("-",new opSum("-",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("-",new opSum("-",atype(),atype() ) ); // a faire mais dur - TheOperators->Add(".*",new opSum("*",atype(),atype() ) ); // a faire mais dur - TheOperators->Add(".*",new opSum("*",atype(),atype() ) ); // a faire mais dur - TheOperators->Add(".*",new opSum("*",atype(),atype() ) ); // a faire mais dur - TheOperators->Add(".*",new opSum("*",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("./",new opSum("/",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("./",new opSum("/",atype(),atype() ) ); // a faire mais dur - TheOperators->Add("./",new opSum("/",atype(),atype() ) ); // a faire mais dur - // correct in sept. 2009 - TheOperators->Add("./",new opSum("/",atype(),atype() ) ); // a faire mais dur - // Add sep 2025 - TheOperators->Add("-",new opUnary("-",atype()) ); - TheOperators->Add("-",new opUnary("-",atype()) ); - TheOperators->Add("+",new opUnary("+",atype()) ); // - TheOperators->Add("+",new opUnary("+",atype()) ); - - - // il faut refechir ..... FH - // il faut definir le type d'un tableau bof, bof (atype()) - TheOperators->Add(">>", - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO >, - new OneBinaryOperator,OneBinaryOperatorMIWO > - - ); - - TheOperators->Add("<<", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > // FH string * mars 2006 - ); - - - TheRightOperators->Add("++", - new OneOperator1 >(&RIncremantation)); - TheRightOperators->Add("--", - new OneOperator1 >(&RDecremantation)); - TheOperators->Add("++", - new OneOperator1 >(&LIncremantation)); - TheOperators->Add("--", - new OneOperator1 >(&LDecremantation)); -// init - TheOperators->Add("<-", - new OneOperator2(&set_copyp_new), // FH string * mars 2006 - new OneOperator2_(&set_copyp), // - new OneOperator2_(&set_copyp), - new OneOperator2_(&set_copyp), // mars 2006 - new OneOperator2_(&set_copy), - new OneBinaryOperator >, // FH string * mars 2006 - new OneBinaryOperator >, // FH string * mars 2006 - new OneTernaryOperator3 > , // FH string * mars 2006 - new OneTernaryOperator3 > // FH string * april 2014 - ); - - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - - Add("<-","(", new OneUnaryOperator >); // FH string * mars 2006 - - Add("precision",".",new OneOperator1(ostream_precision)); - Add("precision",".",new OneOperator1(ostream_precision)); - - // add FH jan 2010 ... - Add("seekp",".",new OneOperator1(ff_oseekp)); - Add("seekp",".",new OneOperator1(ff_oseekp)); - - Add("seekg",".",new OneOperator1(ff_iseekg)); - Add("seekg",".",new OneOperator1(ff_iseekg)); - Add("tellp",".",new OneOperator1(ff_oseekp)); - Add("tellp",".",new OneOperator1(ff_oseekp)); - - Add("tellg",".",new OneOperator1(ff_iseekg)); - Add("tellg",".",new OneOperator1(ff_iseekg)); - - Add("(","",new OneOperator1(fftellp), - new OneOperator2(ffseekp)); - Add("(","",new OneOperator1(fftellg), - new OneOperator2(ffseekg)); - // end add jan 2010 .. - Add("(","",new OneOperator1(get_precis), - new OneOperator2(set_precis)); -// add v 1.41 - Add("good",".",new OneOperator1(to_istream_good)); - Add("good",".",new OneOperator1(to_istream_good)); - Add("good",".",new OneOperator1(to_istream_good)); - Add("(","",new OneOperator1(get_good)); - - Add("eof",".",new OneOperator1(get_eof)); -// add v 4.5 jan 2020 FH. - Add("eatspace",".",new OneOperator1(eatspace)); - Add("length",".",new OneOperator1(filelength)); -// add v 2.8 - Add("scientific",".",new OneOperator1(set_os)); - Add("fixed",".",new OneOperator1(set_os)); - Add("showbase",".",new OneOperator1(set_os)); - Add("noshowbase",".",new OneOperator1(set_os)); - Add("showpos",".",new OneOperator1(set_os)); - Add("noshowpos",".",new OneOperator1(set_os)); - Add("default",".",new OneOperator1(set_os)); - Add("flush",".",new OneOperator1(set_os_flush));// ADD may 2010 - - Add("scientific",".",new OneOperator1(set_os1)); - Add("fixed",".",new OneOperator1(set_os1)); - Add("showbase",".",new OneOperator1(set_os1)); - Add("noshowbase",".",new OneOperator1(set_os1)); - Add("showpos",".",new OneOperator1(set_os1)); - Add("noshowpos",".",new OneOperator1(set_os1)); - Add("default",".",new OneOperator1(set_os1)); - Add("flush",".",new OneOperator1(set_os_flush));// ADD may 2010 - - Global.Add("getline","(",new OneOperator2(Getline)); -// add 2.16 - Global.Add("trace","(",new opFormal(atype(),formalMatTrace )); - Global.Add("det","(",new opFormal(atype(),formalMatDet )); -// end add - - // add 3.20 - Global.Add("Cofactor","(",new opFormal(atype(),formalMatCofactor )); - - TheOperators->Add("<>",new OneOperator_FEarray ); - TheOperators->Add("[]",new OneOperator_array ); - TheOperators->Add("[border]",new OneOperator_border ); - - Global.Add("cos","(",new OneOperator1(cos,2)); - Global.Add("square","(",new OneOperator1 >(Square));// add FH Mai 2011 - Global.Add("square","(",new OneOperator1 >(Square)); - Global.Add("square","(",new OneOperator1 >(Square));// add FH Mai 2011 - //add for Olivier FH July 2014 - Global.Add("sqr","(",new OneOperator1 >(Square));// - Global.Add("sqr","(",new OneOperator1 >(Square)); - Global.Add("sqr","(",new OneOperator1 >(Square));// - - Global.Add("round","(",new OneOperator1(round)); // add june 2007 - Global.Add("lround","(",new OneOperator1(lround)); // add june 2007 - Global.Add("floor","(",new OneOperator1(floor)); // add march 2006 - Global.Add("ceil","(",new OneOperator1(ceil)); // add march 2006 - Global.Add("rint","(",new OneOperator1(rint)); // add june 2006 - Global.Add("lrint","(",new OneOperator1(lrint)); // add mars 2014 - Global.Add("lrint","(",new OneOperator1(lrintc)); // add aout 2020 - Global.Add("lround","(",new OneOperator1(lroundc)); // add aout 2020 - - Global.Add("sin","(",new OneOperator1(sin,2)); - Global.Add("tan","(",new OneOperator1(tan,2)); - Global.Add("atan","(",new OneOperator1(atan,2)); - Global.Add("sinh","(",new OneOperator1(sinh,2)); - Global.Add("cosh","(",new OneOperator1(cosh,2)); - Global.Add("tanh","(",new OneOperator1(tanh,2)); - - Global.Add("atoi","(",new OneOperator1(atoi));// add march 2010 - Global.Add("atol","(",new OneOperator1(atoi));// add march 2010 - Global.Add("atof","(",new OneOperator1(atof));// add march 2010 - - Global.Add("strtol","(",new OneOperator1(ffstrtol));// add march 2017 - Global.Add("strtol","(",new OneOperator2(ffstrtol));// add march 2017 - Global.Add("strtod","(",new OneOperator1(ffstrtod));// add march 2017 - - Global.Add("atanh","(",new OneOperator1(atanh)); - Global.Add("asin","(",new OneOperator1(asin)); - Global.Add("acos","(",new OneOperator1(acos)); - Global.Add("asinh","(",new OneOperator1(asinh)); - Global.Add("acosh","(",new OneOperator1(acosh)); +double diffpos(const double &aa, const double &bb) { return aa < bb ? bb - aa : 0.; } +double invdiffpos(const double &aa, const double &bb) { return aa < bb ? 1. / (bb - aa) : 0.; } +double diffnp(const double &aa, const double &bb) { return aa < 0. && 0. < bb ? bb - aa : 0.; } // Corr 08/18 G. Sadaka +double invdiffnp(const double &aa, const double &bb) { return aa < 0. && 0. < bb ? 1. / max(bb - aa, 1e-30) : 0.; } // Corr 08/18 G. Sadaka +double invdiff(const double &aa, const double &bb) { + double d = aa - bb; + return abs(d) < 1e-30 ? d : 1 / d; +} +double invdiff(const double &aa, const double &bb, const double &eps) { + double d = aa - bb; + return abs(d) < eps ? d : 1 / d; +} +extern double ff_tgv; // Add FH jan 2018 +double sign(double x) { return (x > 0.) - (x < 0.); } // Add FH jan 2018 +long sign(long x) { return (x > 0) - (x < 0); } // Add FH jan 2018 +bool ffsignbit(long x) { return signbit(x); } +bool ffsignbit(double x) { return signbit(x); } +template< typename T > +bool pswap(T *a, T *b) { + swap(*a, *b); + return 0; +} +long lrintc(Complex x) { return lrint(real(x)); } +long lroundc(Complex x) { return lround(real(x)); } +void Init_map_type( ) { + TheOperators = new Polymorphic( ), TheRightOperators = new Polymorphic( ); + map_type[typeid(AnyType).name( )] = new ForTypeAnyType( ); + map_type[typeid(void).name( )] = new ForTypeVoid( ); + InitLoop( ); + Dcl_Type< Expression >(0); + Dcl_TypeandPtr< double >(0, 0, ::InitializeDef< double >, 0); + Dcl_TypeandPtr< long >(0, 0, ::InitializeDef< long >, 0); + Dcl_TypeandPtr< bool >(0, 0, ::InitializeDef< bool >, 0); + Dcl_TypeandPtr< Complex >(0, 0, ::InitializeDef< Complex >, 0); + Dcl_Type< void * >( ); // add FH ... for mpi comm world + Dcl_Type< char * >( ); + Dcl_Type< const char * >( ); + Dcl_Type< char >( ); + Dcl_TypeandPtr< string * >(0, 0, ::InitializePtr< string * >, ::DeletePtr< string * >); + Dcl_TypeandPtr< ostream * >(0, 0, ::InitializePtr< ostream * >, ::DeletePtr< ostream * >); + Dcl_TypeandPtr< istream * >(0, 0, ::InitializePtr< istream * >, ::DeletePtr< istream * >); + Dcl_Type< ostream_precis >( ); + Dcl_Type< ostream_seekp >( ); + Dcl_Type< istream_seekg >( ); + Dcl_Type< istream_good >( ); + Dcl_Type< NothingType >( ); + Dcl_Type< OP_setw >( ); + Dcl_Type< Polymorphic * >( ); + + basicForEachType::type_C_F0 = map_type[typeid(C_F0).name( )] = new TypeLineFunction; + Dcl_Type< E_Array >( ); + Dcl_Type< E_FEarray >( ); + Dcl_Type< TransE_Array >( ); // add + Dcl_Type< const E_Border * >( ); + Dcl_Type< const E_BorderN * >( ); + typedef MyMap< String, String > MyMapSS; + map_type[typeid(MyMapSS *).name( )] = new ForEachType< MyMapSS * >(Initialize< MyMapSS >, Delete< MyMapSS >); + map_type_of_map[make_pair(atype< string * >( ), atype< string * >( ))] = atype< MyMapSS * >( ); + + Dcl_Type< SubArray >( ); + Dcl_Type< pair< long, long > >( ); + + initArrayDCLlong( ); + initArrayDCLdouble( ); + initArrayDCLComplex( ); + + Dcl_Type< ios::openmode >( ); + + // <> les types des variables + + zzzfff->Add("real", typevarreal = atype< double * >( )); + zzzfff->Add("int", atype< long * >( )); + zzzfff->Add("complex", typevarcomplex = atype< Complex * >( )); + zzzfff->Add("bool", atype< bool * >( )); + zzzfff->Add("string", atype< string ** >( )); + zzzfff->Add("ifstream", atype< istream ** >( )); + zzzfff->Add("ofstream", atype< ostream ** >( )); + zzzfff->AddF("func", atype< C_F0 >( )); + + // end of know types + + map_type[typeid(bool).name( )]->AddCast(new E_F1_funcT< bool, bool * >(UnRef< bool >), new E_F1_funcT< bool, long >(Cast< bool, long >), new E_F1_funcT< bool, double >(Cast< bool, double >)); + + map_type[typeid(long).name( )]->AddCast(new E_F1_funcT< long, long * >(UnRef< long >), new E_F1_funcT< long, double >(Cast< long, double >), new E_F1_funcT< long, bool >(Cast< long, bool >), + new E_F1_funcT< long, ostream_precis >(Cast< long, ostream_precis >), new E_F1_funcT< long, ostream_seekp >(Cast< long, ostream_seekp >), + new E_F1_funcT< long, istream_seekg >(Cast< long, istream_seekg >)); + + map_type[typeid(double).name( )]->AddCast( + new E_F1_funcT< double, double * >(UnRef< double >), new E_F1_funcT< double, long >(Cast< double, long >), new E_F1_funcT< double, bool >(Cast< double, bool >) + + ); + + map_type[typeid(Complex).name( )]->AddCast(new E_F1_funcT< Complex, Complex * >(UnRef< Complex >), new E_F1_funcT< Complex, long >(Cast< Complex, long >), + new E_F1_funcT< Complex, double >(Cast< Complex, double >)); + + map_type[typeid(string *).name( )]->AddCast(new E_F1_funcT< string *, string ** >(UnRefCopyPtr< string >), new E_F1_funcT< string *, long >(FCast< string *, long, toString >), + new E_F1_funcT< string *, double >(FCast< string *, double, toString >), new E_F1_funcT< string *, bool >(FCast< string *, bool, toString >), + new E_F1_funcT< string *, Complex >(FCast< string *, Complex, toString >)); + // a changer --------------- modif + map_type[typeid(string *).name( )]->AddCast(new E_F1_funcT< string *, char * >(FCast< string *, char *, toStringC >), + new E_F1_funcT< string *, const char * >(FCast< string *, const char *, toStringCconst >)); + + map_type[typeid(long).name( )]->AddCast(new OneOperator_border_label); + + Global.New("verbosity", CPValue< long >(verbosity)); + + Global.New("searchMethod", CPValue< long >(searchMethod)); // pichon + Global.New("tgv", CPValue< double >(ff_tgv)); + Global.New("lockOrientation", CPValue< bool >(lockOrientation)); + extern long newconvect3; // def in global.cpp + Global.New("newconvect", CPValue< long >(newconvect3)); // pichon + + // <> uses [[file:AFunction.hpp::CConstant]] + Global.New("cout", CConstant< ostream * >(&cout)); + + Global.New("cerr", CConstant< ostream * >(&cerr)); // add jan 2014 FH. + Global.New("cin", CConstant< istream * >(&cin)); + Global.New("append", CConstant< ios::openmode >(ios::app)); + Global.New("binary", CConstant< ios::openmode >(ios::binary)); // add FH april 2014 + TheOperators->Add("|", new OneBinaryOperator< Op2_pipe< ios::openmode > >); // add FH april 2014 + Global.New("endl", CConstant< const char * >("\n")); + Global.New("true", CConstant< bool >(true)); + Global.New("false", CConstant< bool >(false)); + Global.New("pi", CConstant< double >(3.14159265358979323846264338328)); + Global.New("version", CConstant< double >(VersionNumber( ))); + + Global.New("showCPU", CPValue< bool >(showCPU)); + Global.New("CPUTime", CConstant< bool * >(&showCPU)); + // def de Zero et One + pZero = new C_F0(CConstant< double >(0.0)); + pOne = new C_F0(CConstant< double >(1.0)); + pminusOne = new C_F0(CConstant< double >(-1.0)); + + TheOperators->Add(":", new OneOperatorConst< char >(new EConstant< char >(':')), new OneBinaryOperator< SubArray2 >, new OneTernaryOperator3< SubArray3 >); + + TheOperators->Add("+", new OneBinaryOperator< Op2_add< long, long, long > >, new OneBinaryOperator< Op2_add< double, double, double > >, new OneBinaryOperator< Op2_add< double, double, long > >, + new OneBinaryOperator< Op2_add< double, long, double > >, new OneBinaryOperator< Op2_add< long, bool, bool > >, new OneBinaryOperator< Op2_add< long, long, bool > >, + new OneBinaryOperator< Op2_add< long, bool, long > >, new OneBinaryOperator< Op2_add< Complex, Complex, Complex > >, new OneBinaryOperator< Op2_add< Complex, Complex, double > >, + new OneBinaryOperator< Op2_add< Complex, double, Complex > >, new OneBinaryOperator< Op2_add< Complex, Complex, long > >, + new OneBinaryOperator< Op2_add< Complex, long, Complex > >, new OneBinaryOperator_st< Op2_padd< string, string *, string * > > // a changer to do FH string * mars 2006 + ); + TheOperators->Add("-", new OneBinaryOperator< Op2_sub< long, long, long > >, new OneBinaryOperator< Op2_sub< double, double, double > >, new OneBinaryOperator< Op2_sub< double, double, long > >, + new OneBinaryOperator< Op2_sub< double, long, double > >, new OneBinaryOperator< Op2_sub< long, bool, bool > >, new OneBinaryOperator< Op2_sub< long, long, bool > >, + new OneBinaryOperator< Op2_sub< long, bool, long > >, new OneBinaryOperator< Op2_sub< Complex, Complex, Complex > >, new OneBinaryOperator< Op2_sub< Complex, Complex, double > >, + new OneBinaryOperator< Op2_sub< Complex, double, Complex > >, new OneBinaryOperator< Op2_sub< Complex, Complex, long > >, + new OneBinaryOperator< Op2_sub< Complex, long, Complex > >); + + TheOperators->Add( + "*", new OneBinaryOperator< Op2_mul< bool, bool, bool >, OneBinaryOperatorMI, evalE_mul< bool > >, new OneBinaryOperator< Op2_mul< long, long, long >, OneBinaryOperatorMI, evalE_mul< long > >, + new OneBinaryOperator< Op2_mul< double, double, double >, MIMul< double, double >, evalE_mul< double > >, + new OneBinaryOperator< Op2_mul< double, double, long >, MIMul< double, long >, evalE_mul< double, long, double > >, + new OneBinaryOperator< Op2_mul< double, long, double >, MIMul< long, double >, evalE_mul< long, double, double > >, new OneBinaryOperator< Op2_mul< Complex, Complex, Complex > >, + new OneBinaryOperator< Op2_mul< Complex, Complex, double > >, new OneBinaryOperator< Op2_mul< Complex, double, Complex > >, new OneBinaryOperator< Op2_mul< Complex, Complex, long > >, + new OneBinaryOperator< Op2_mul< Complex, long, Complex > >, new OneBinaryOperator< Op2_mul< long, long, bool > >, new OneBinaryOperator< Op2_mul< long, bool, long > >); + // add missing operation jan 2017 FH. + TheOperators->Add("*", new OneBinaryOperator< Op2_mul< Complex, Complex, bool > >, new OneBinaryOperator< Op2_mul< Complex, bool, Complex > >); + TheOperators->Add("+", new OneBinaryOperator< Op2_add< Complex, Complex, bool > >, new OneBinaryOperator< Op2_add< Complex, bool, Complex > >); + TheOperators->Add("-", new OneBinaryOperator< Op2_sub< Complex, Complex, bool > >, new OneBinaryOperator< Op2_sub< Complex, bool, Complex > >); + TheOperators->Add("/", + // new OneBinaryOperator >, + new OneBinaryOperator< Op2_div< Complex, bool, Complex > >); + + TheOperators->Add("/", new OneBinaryOperator< Op2_div< long, long, long > >, new OneBinaryOperator< Op2_div< double, double, double > >, new OneBinaryOperator< Op2_div< double, double, long > >, + new OneBinaryOperator< Op2_div< double, long, double > >, new OneBinaryOperator< Op2_div< Complex, Complex, Complex > >, + new OneBinaryOperator< Op2_div< Complex, Complex, double > >, new OneBinaryOperator< Op2_div< Complex, double, Complex > >, + new OneBinaryOperator< Op2_div< Complex, Complex, long > >, new OneBinaryOperator< Op2_div< Complex, long, Complex > >); + + TheOperators->Add("%", new OneBinaryOperator< Op2_mod< long, long, long > >, new OneOperator2< double, double, double >(fmod)); + + TheOperators->Add("+", new OneUnaryOperator< Op1_plus< double > >, new OneUnaryOperator< Op1_plus< long > >, new OneUnaryOperator< Op1_plus< Complex > >); + + TheOperators->Add("-", new OneUnaryOperator< Op1_neg< double > >, new OneUnaryOperator< Op1_neg< long > >, new OneUnaryOperator< Op1_neg< Complex > >); + + TheOperators->Add("^", new OneBinaryOperator< Op2_pow< long, long, long > >, new OneBinaryOperator< Op2_pow< double, double, double > >, new OneBinaryOperator< Op2_pow< double, double, long > >, + new OneBinaryOperator< Op2_pow< Complex, Complex, Complex > >); + + TheOperators->Add( + "<", new OneBinaryOperator< Op2_lt< long, long > >, new OneBinaryOperator< Op2_lt< double, double > >, new OneBinaryOperator< Op2_plt< string *, string * > > // FH string * mars 2006 + ); + TheOperators->Add( + "<=", new OneBinaryOperator< Op2_le< long, long > >, new OneBinaryOperator< Op2_le< double, double > >, new OneBinaryOperator< Op2_ple< string *, string * > > // FH string * mars 2006 + ); + TheOperators->Add( + ">", new OneBinaryOperator< Op2_gt< long, long > >, new OneBinaryOperator< Op2_gt< double, double > >, new OneBinaryOperator< Op2_pgt< string *, string * > > // string * mars 2006 + ); + TheOperators->Add( + ">=", new OneBinaryOperator< Op2_ge< long, long > >, new OneBinaryOperator< Op2_ge< double, double > >, new OneBinaryOperator< Op2_pge< string *, string * > > // FH string * mars 2006 + ); + TheOperators->Add("==", new OneBinaryOperator< Op2_eq< long, long > >, new OneBinaryOperator< Op2_eq< double, double > >, new OneBinaryOperator< Op2_eq< Complex, Complex > >, + new OneBinaryOperator< Op2_peq< string *, string * > > // FH string * mars 2006 + ); + + TheOperators->Add("!=", new OneBinaryOperator< Op2_ne< long, long > >, new OneBinaryOperator< Op2_ne< double, double > >, new OneBinaryOperator< Op2_ne< Complex, Complex > >, + new OneBinaryOperator< Op2_pne< string *, string * > > // FH string * mars 2006 + ); + + TheOperators->Add("!", new OneUnaryOperator< Op1_not< bool > >); + + TheOperators->Add("&&", new OneBinaryOperator< Op2_and >); + TheOperators->Add("&", new OneBinaryOperator< Op2_and >); + TheOperators->Add("||", new OneBinaryOperator< Op2_or >); + TheOperators->Add("|", new OneBinaryOperator< Op2_or >); + + // Unary_Op_Comparaision + + TheOperators->Add("=", new OneBinaryOperator< set_eq< bool >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq< long >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_eq< double >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq< Complex >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_peqstring, OneBinaryOperatorMIWO > // FH string * mars 2006 + ); + + TheOperators->Add("?:", new Operator_Aritm_If< bool >, new Operator_Aritm_If< long >, new Operator_Aritm_If< double >, new Operator_Aritm_If< Complex >, + new Operator_Aritm_If< string * > // (OK???) to do FH string * mars 2006 + ); + + initArrayOperatorlong( ); + initArrayOperatordouble( ); + initArrayOperatorComplex( ); + initStringOperator( ); + + TheOperators->Add("+=", new OneBinaryOperator< set_eq_add< long >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq_add< double >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_eq_add< Complex >, OneBinaryOperatorMIWO >); + + TheOperators->Add("-=", new OneBinaryOperator< set_eq_sub< long >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq_sub< double >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_eq_sub< Complex >, OneBinaryOperatorMIWO >); + + TheOperators->Add("*=", new OneBinaryOperator< set_eq_mul< long >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq_mul< double >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_eq_mul< Complex >, OneBinaryOperatorMIWO >); + + TheOperators->Add("/=", new OneBinaryOperator< set_eq_div< long >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq_div< double >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< set_eq_div< Complex >, OneBinaryOperatorMIWO >); + + TheOperators->Add("+", new AddBorderOperator); + + // add frev 2007 + TheOperators->Add("\'", new opTrans); + // Pas formel !!!! + // TheOperators->Add("<<",new opPrint("<<",atype(),atype(),atype() ) ); + // TheOperators->Add("<<",new opPrint("<<",atype(),atype(),atype() ) ); + + TheOperators->Add("*", new opDot(atype< TransE_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("*", new opDot(atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("*", new opColumn(atype< E_Array >( ))); // [ ]* C_F0 (all) + TheOperators->Add("*", new opColumn(basicForEachType::type_C_F0, atype< E_Array >( ))); // [ ]* C_F0 (all) + TheOperators->Add("*", new opColumn(basicForEachType::type_C_F0, atype< TransE_Array >( ))); // [ ]* C_F0 (all) + // type_C_F0 + TheOperators->Add("::", new opColumn(atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("*", new opDot(atype< E_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add("*", new opDot(atype< TransE_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + + // car le type de retour depent des objets du tableau + atype< E_Array >( )->Add("[", "", new opVI(atype< E_Array >( ))); + atype< TransE_Array >( )->Add("[", "", new opVI(atype< TransE_Array >( ))); + TheOperators->Add("+", new opSum("+", atype< TransE_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("+", new opSum("+", atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("+", new opSum("+", atype< E_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add("+", new opSum("+", atype< TransE_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add("-", new opSum("-", atype< TransE_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("-", new opSum("-", atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("-", new opSum("-", atype< E_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add("-", new opSum("-", atype< TransE_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add(".*", new opSum("*", atype< TransE_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add(".*", new opSum("*", atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add(".*", new opSum("*", atype< E_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add(".*", new opSum("*", atype< TransE_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + TheOperators->Add("./", new opSum("/", atype< TransE_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("./", new opSum("/", atype< E_Array >( ), atype< E_Array >( ))); // a faire mais dur + TheOperators->Add("./", new opSum("/", atype< E_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + // correct in sept. 2009 + TheOperators->Add("./", new opSum("/", atype< TransE_Array >( ), atype< TransE_Array >( ))); // a faire mais dur + // Add sep 2025 + TheOperators->Add("-", new opUnary("-", atype< E_Array >( ))); + TheOperators->Add("-", new opUnary("-", atype< TransE_Array >( ))); + TheOperators->Add("+", new opUnary("+", atype< E_Array >( ))); // + TheOperators->Add("+", new opUnary("+", atype< TransE_Array >( ))); + + // il faut refechir ..... FH + // il faut definir le type d'un tableau bof, bof (atype()) + TheOperators->Add(">>", new OneBinaryOperator< Op_Read< bool >, OneBinaryOperatorMIWO >, new OneBinaryOperator< Op_Read< long >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< Op_Read< double >, OneBinaryOperatorMIWO >, new OneBinaryOperator< Op_Read< Complex >, OneBinaryOperatorMIWO >, + new OneBinaryOperator< Op_ReadP< string >, OneBinaryOperatorMIWO > + + ); + + TheOperators->Add("<<", new OneBinaryOperator< Print< bool > >, new OneBinaryOperator< Print< long > >, new OneBinaryOperator< Print< double > >, new OneBinaryOperator< Print< Complex > >, + new OneBinaryOperator< PrintP< string * > > // FH string * mars 2006 + ); + + TheRightOperators->Add("++", new OneOperator1< long, long *, E_F_F0< long, long *, false > >(&RIncremantation< long >)); + TheRightOperators->Add("--", new OneOperator1< long, long *, E_F_F0< long, long *, false > >(&RDecremantation< long >)); + TheOperators->Add("++", new OneOperator1< long, long *, E_F_F0< long, long *, false > >(&LIncremantation< long >)); + TheOperators->Add("--", new OneOperator1< long, long *, E_F_F0< long, long *, false > >(&LDecremantation< long >)); + // init + TheOperators->Add("<-", new OneOperator2< string **, string **, string * >(&set_copyp_new< string >), // FH string * mars 2006 + new OneOperator2_< double *, double *, double >(&set_copyp), // + new OneOperator2_< long *, long *, long >(&set_copyp), new OneOperator2_< bool *, bool *, bool >(&set_copyp), // mars 2006 + new OneOperator2_< Complex *, Complex *, Complex >(&set_copy), new OneBinaryOperator< Op2_set_pstring< istream **, ifstream > >, // FH string * mars 2006 + new OneBinaryOperator< Op2_set_pstring< ostream **, ofstream > >, // FH string * mars 2006 + new OneTernaryOperator3< Op2_set_pstringiomode< ostream **, ofstream > >, // FH string * mars 2006 + new OneTernaryOperator3< Op2_set_pstringiomode< istream **, ifstream > > // FH string * april 2014 + ); + + atype< istream * >( )->AddCast(new E_F1_funcT< istream *, istream ** >(UnRef< istream * >)); + atype< ostream * >( )->AddCast(new E_F1_funcT< ostream *, ostream ** >(UnRef< ostream * >)); + + Add< ostream ** >("<-", "(", new OneUnaryOperator< Op1_new_pstring< ostream *, ofstream > >); // FH string * mars 2006 + + Add< ostream ** >("precision", ".", new OneOperator1< ostream_precis, ostream ** >(ostream_precision)); + Add< ostream * >("precision", ".", new OneOperator1< ostream_precis, ostream * >(ostream_precision)); + + // add FH jan 2010 ... + Add< ostream ** >("seekp", ".", new OneOperator1< ostream_seekp, ostream ** >(ff_oseekp)); + Add< ostream * >("seekp", ".", new OneOperator1< ostream_seekp, ostream * >(ff_oseekp)); + + Add< istream ** >("seekg", ".", new OneOperator1< istream_seekg, istream ** >(ff_iseekg)); + Add< istream * >("seekg", ".", new OneOperator1< istream_seekg, istream * >(ff_iseekg)); + Add< ostream ** >("tellp", ".", new OneOperator1< ostream_seekp, ostream ** >(ff_oseekp)); + Add< ostream * >("tellp", ".", new OneOperator1< ostream_seekp, ostream * >(ff_oseekp)); + + Add< istream ** >("tellg", ".", new OneOperator1< istream_seekg, istream ** >(ff_iseekg)); + Add< istream * >("tellg", ".", new OneOperator1< istream_seekg, istream * >(ff_iseekg)); + + Add< ostream_seekp >("(", "", new OneOperator1< long, ostream_seekp >(fftellp), new OneOperator2< long, ostream_seekp, long >(ffseekp)); + Add< istream_seekg >("(", "", new OneOperator1< long, istream_seekg >(fftellg), new OneOperator2< long, istream_seekg, long >(ffseekg)); + // end add jan 2010 .. + Add< ostream_precis >("(", "", new OneOperator1< long, ostream_precis >(get_precis), new OneOperator2< long, ostream_precis, long >(set_precis)); + // add v 1.41 + Add< istream ** >("good", ".", new OneOperator1< istream_good, istream ** >(to_istream_good)); + Add< istream * >("good", ".", new OneOperator1< istream_good, istream * >(to_istream_good)); + Add< istream * >("good", ".", new OneOperator1< istream_good, istream * >(to_istream_good)); + Add< istream_good >("(", "", new OneOperator1< long, istream_good >(get_good)); + + Add< istream ** >("eof", ".", new OneOperator1< bool, istream ** >(get_eof)); + // add v 4.5 jan 2020 FH. + Add< istream ** >("eatspace", ".", new OneOperator1< bool, istream ** >(eatspace)); + Add< istream ** >("length", ".", new OneOperator1< long, istream ** >(filelength)); + // add v 2.8 + Add< ostream ** >("scientific", ".", new OneOperator1< ostream **, ostream ** >(set_os< scientific >)); + Add< ostream ** >("fixed", ".", new OneOperator1< ostream **, ostream ** >(set_os< fixed >)); + Add< ostream ** >("showbase", ".", new OneOperator1< ostream **, ostream ** >(set_os< showbase >)); + Add< ostream ** >("noshowbase", ".", new OneOperator1< ostream **, ostream ** >(set_os< noshowbase >)); + Add< ostream ** >("showpos", ".", new OneOperator1< ostream **, ostream ** >(set_os< showpos >)); + Add< ostream ** >("noshowpos", ".", new OneOperator1< ostream **, ostream ** >(set_os< noshowpos >)); + Add< ostream ** >("default", ".", new OneOperator1< ostream **, ostream ** >(set_os< default1 >)); + Add< ostream ** >("flush", ".", new OneOperator1< ostream **, ostream ** >(set_os_flush)); // ADD may 2010 + + Add< ostream * >("scientific", ".", new OneOperator1< ostream *, ostream * >(set_os1< scientific >)); + Add< ostream * >("fixed", ".", new OneOperator1< ostream *, ostream * >(set_os1< fixed >)); + Add< ostream * >("showbase", ".", new OneOperator1< ostream *, ostream * >(set_os1< showbase >)); + Add< ostream * >("noshowbase", ".", new OneOperator1< ostream *, ostream * >(set_os1< noshowbase >)); + Add< ostream * >("showpos", ".", new OneOperator1< ostream *, ostream * >(set_os1< showpos >)); + Add< ostream * >("noshowpos", ".", new OneOperator1< ostream *, ostream * >(set_os1< noshowpos >)); + Add< ostream * >("default", ".", new OneOperator1< ostream *, ostream * >(set_os1< default1 >)); + Add< ostream * >("flush", ".", new OneOperator1< ostream *, ostream * >(set_os_flush)); // ADD may 2010 + + Global.Add("getline", "(", new OneOperator2< istream *, istream *, string ** >(Getline)); + // add 2.16 + Global.Add("trace", "(", new opFormal(atype< E_Array >( ), formalMatTrace)); + Global.Add("det", "(", new opFormal(atype< E_Array >( ), formalMatDet)); + // end add + + // add 3.20 + Global.Add("Cofactor", "(", new opFormal(atype< E_Array >( ), formalMatCofactor)); + + TheOperators->Add("<>", new OneOperator_FEarray); + TheOperators->Add("[]", new OneOperator_array); + TheOperators->Add("[border]", new OneOperator_border); + + Global.Add("cos", "(", new OneOperator1< double >(cos, 2)); + Global.Add("square", "(", new OneOperator1< long, long, E_F_F0< long, const long & > >(Square)); // add FH Mai 2011 + Global.Add("square", "(", new OneOperator1< double, double, E_F_F0< double, const double & > >(Square)); + Global.Add("square", "(", new OneOperator1< Complex, Complex, E_F_F0< Complex, const Complex & > >(Square)); // add FH Mai 2011 + // add for Olivier FH July 2014 + Global.Add("sqr", "(", new OneOperator1< long, long, E_F_F0< long, const long & > >(Square)); // + Global.Add("sqr", "(", new OneOperator1< double, double, E_F_F0< double, const double & > >(Square)); + Global.Add("sqr", "(", new OneOperator1< Complex, Complex, E_F_F0< Complex, const Complex & > >(Square)); // + + Global.Add("round", "(", new OneOperator1< double >(round)); // add june 2007 + Global.Add("lround", "(", new OneOperator1< long, double >(lround)); // add june 2007 + Global.Add("floor", "(", new OneOperator1< double >(floor)); // add march 2006 + Global.Add("ceil", "(", new OneOperator1< double >(ceil)); // add march 2006 + Global.Add("rint", "(", new OneOperator1< double >(rint)); // add june 2006 + Global.Add("lrint", "(", new OneOperator1< long, double >(lrint)); // add mars 2014 + Global.Add("lrint", "(", new OneOperator1< long, Complex >(lrintc)); // add aout 2020 + Global.Add("lround", "(", new OneOperator1< long, Complex >(lroundc)); // add aout 2020 + + Global.Add("sin", "(", new OneOperator1< double >(sin, 2)); + Global.Add("tan", "(", new OneOperator1< double >(tan, 2)); + Global.Add("atan", "(", new OneOperator1< double >(atan, 2)); + Global.Add("sinh", "(", new OneOperator1< double >(sinh, 2)); + Global.Add("cosh", "(", new OneOperator1< double >(cosh, 2)); + Global.Add("tanh", "(", new OneOperator1< double >(tanh, 2)); + + Global.Add("atoi", "(", new OneOperator1< long, string * >(atoi)); // add march 2010 + Global.Add("atol", "(", new OneOperator1< long, string * >(atoi)); // add march 2010 + Global.Add("atof", "(", new OneOperator1< double, string * >(atof)); // add march 2010 + + Global.Add("strtol", "(", new OneOperator1< long, string * >(ffstrtol)); // add march 2017 + Global.Add("strtol", "(", new OneOperator2< long, string *, long >(ffstrtol)); // add march 2017 + Global.Add("strtod", "(", new OneOperator1< double, string * >(ffstrtod)); // add march 2017 + + Global.Add("atanh", "(", new OneOperator1< double >(atanh)); + Global.Add("asin", "(", new OneOperator1< double >(asin)); + Global.Add("acos", "(", new OneOperator1< double >(acos)); + Global.Add("asinh", "(", new OneOperator1< double >(asinh)); + Global.Add("acosh", "(", new OneOperator1< double >(acosh)); #ifdef HAVE_ERFC - Global.Add("erf","(",new OneOperator1(erf)); - Global.Add("erfc","(",new OneOperator1(erfc)); + Global.Add("erf", "(", new OneOperator1< double >(erf)); + Global.Add("erfc", "(", new OneOperator1< double >(erfc)); #endif #ifdef HAVE_TGAMMA - Global.Add("tgamma","(",new OneOperator1(tgamma)); - Global.Add("lgamma","(",new OneOperator1(lgamma)); + Global.Add("tgamma", "(", new OneOperator1< double >(tgamma)); + Global.Add("lgamma", "(", new OneOperator1< double >(lgamma)); #endif - // function de bessel j0, j1, jn, y0, y1, yn -- bessel functions of first and second kind + // function de bessel j0, j1, jn, y0, y1, yn -- bessel functions of first and second kind #ifdef HAVE_JN - Global.Add("j0","(",new OneOperator1(j0)); - Global.Add("j1","(",new OneOperator1(j1)); - Global.Add("jn","(",new OneOperator2(myjn)); - Global.Add("y0","(",new OneOperator1(y0)); - Global.Add("y1","(",new OneOperator1(y1)); - Global.Add("yn","(",new OneOperator2(myyn)); + Global.Add("j0", "(", new OneOperator1< double >(j0)); + Global.Add("j1", "(", new OneOperator1< double >(j1)); + Global.Add("jn", "(", new OneOperator2< double, long, double >(myjn)); + Global.Add("y0", "(", new OneOperator1< double >(y0)); + Global.Add("y1", "(", new OneOperator1< double >(y1)); + Global.Add("yn", "(", new OneOperator2< double, long, double >(myyn)); #endif - Global.Add("exp","(",new OneOperator1(exp)); - Global.Add("log","(",new OneOperator1(log)); - Global.Add("log10","(",new OneOperator1(log10)); -// Global.Add("pow","(",new OneOperator2(pow)); - Global.Add("pow","(",new OneBinaryOperator >); - Global.Add("pow","(",new OneBinaryOperator >); - -// Global.Add("pow","(",new OneOperator2(pow)); - Global.Add("max","(",new OneOperator2_(Max )); - Global.Add("min","(",new OneOperator2_(Min )); - Global.Add("diffpos","(",new OneOperator2_(diffpos )); // jan 2018 FH - Global.Add("invdiffpos","(",new OneOperator2_(invdiffpos )); // jan 2018 FH - Global.Add("diffnp","(",new OneOperator2_(diffnp )); // jan 2018 FH - Global.Add("invdiffnp","(",new OneOperator2_(invdiffnp )); // jan 2018 FH - Global.Add("invdiff","(",new OneOperator2_(invdiff )); // jan 2018 FH - Global.Add("invdiff","(",new OneOperator3_(invdiff )); // jan 2018 FH - - Global.Add("max","(",new OneOperator2_(Max)); - Global.Add("min","(",new OneOperator2_(Min)); - Global.Add("max","(",new OneOperator3_(Max )); - Global.Add("min","(",new OneOperator3_(Min )); - Global.Add("max","(",new OneOperator3_(Max)); - Global.Add("min","(",new OneOperator3_(Min)); - Global.Add("max","(",new OneOperator4_(Max)); - Global.Add("min","(",new OneOperator4_(Min)); - Global.Add("max","(",new OneOperator4_(Max)); - Global.Add("min","(",new OneOperator4_(Min)); - - Global.Add("atan2","(",new OneOperator2(atan2)); - Global.Add("fmod","(",new OneOperator2(fmod));// add sep 2017 - Global.Add("fdim","(",new OneOperator2(fdim));// add sep 2017 - Global.Add("fmax","(",new OneOperator2(fmax));// add sep 2017 - Global.Add("fmin","(",new OneOperator2(fmin));// add sep 2017 - - Global.Add("hypot","(",new OneOperator2(hypot));// add Jan 2014 - - Global.Add("atan","(",new OneOperator2(atan2)); - Global.Add("sqrt","(",new OneOperator1(sqrt,2)); - Global.Add("cbrt","(",new OneOperator1(cbrt,2)); - Global.Add("abs","(",new OneOperator1(Abs)); - Global.Add("abs","(",new OneOperator1(Abs)); - Global.Add("cos","(",new OneOperator1_(cos)); - Global.Add("sin","(",new OneOperator1_(sin)); - Global.Add("sinh","(",new OneOperator1_(sinh)); - Global.Add("cosh","(",new OneOperator1_(cosh)); - Global.Add("tanh","(",new OneOperator1_(tanh));// Add June 2016 FH.. - Global.Add("log","(",new OneOperator1_(log)); - Global.Add("tan","(",new OneOperator1_(tan)); - Global.Add("exp","(",new OneOperator1_(exp)); - - Global.Add("pow","(",new OneBinaryOperator >); - //new OneOperator2_(pow )); - Global.Add("sqrt","(",new OneOperator1_(sqrt,0)); - Global.Add("conj","(",new OneOperator1_(conj,0)); - Global.Add("conj","(",new OneOperator1_(RNM::conj,1)); - TheOperators->Add("\'",new OneOperator1_(conj,0)); - TheOperators->Add("\'",new OneOperator1_(RNM::conj,1)); // add F. Feb 2010 of conj of varf.. - - - Global.Add("imag","(",new OneOperator1(Imag)); - // Big probleme real is a type - Add("<--","(",new OneOperator1(Real)); - - Global.Add("abs","(",new OneOperator1_(abs)); - - Global.Add("arg","(",new OneOperator1_(arg)); - Global.Add("norm","(",new OneOperator1_(norm)); - Global.Add("exit","(",new OneOperator1(Exit)); - Global.Add("assert","(",new OneOperator1(Assert)); - - Global.Add("clock","(",new OneOperator0(CPUtime)); - Global.Add("time","(",new OneOperator0(walltime));// add mars 2010 for Pichon. - Global.Add("ltime","(",new OneOperator0(fftime));// add mars 2014 ( the times unix fonction) - Global.Add("storageused","(",new OneOperator0(storageused)); - Global.Add("storagetotal","(",new OneOperator0(storagetotal)); - - Global.Add("dumptable","(",new OneOperator1(dumptable)); - Global.Add("exec","(",new OneOperator1(exec)); //FH string * mars 2006 - Global.Add("system","(",new OneOperator1(exec)); //FH string fevr 2011 - - Global.Add("polar","(",new OneOperator2_(polar)); - // rand generator --- - unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4; + Global.Add("exp", "(", new OneOperator1< double >(exp)); + Global.Add("log", "(", new OneOperator1< double >(log)); + Global.Add("log10", "(", new OneOperator1< double >(log10)); + // Global.Add("pow","(",new OneOperator2(pow)); + Global.Add("pow", "(", new OneBinaryOperator< Op2_pow< double, double, double > >); + Global.Add("pow", "(", new OneBinaryOperator< Op2_pow< long, long, long > >); + + // Global.Add("pow","(",new OneOperator2(pow)); + Global.Add("max", "(", new OneOperator2_< double, double >(Max< double >)); + Global.Add("min", "(", new OneOperator2_< double, double >(Min< double >)); + Global.Add("diffpos", "(", new OneOperator2_< double, double >(diffpos)); // jan 2018 FH + Global.Add("invdiffpos", "(", new OneOperator2_< double, double >(invdiffpos)); // jan 2018 FH + Global.Add("diffnp", "(", new OneOperator2_< double, double >(diffnp)); // jan 2018 FH + Global.Add("invdiffnp", "(", new OneOperator2_< double, double >(invdiffnp)); // jan 2018 FH + Global.Add("invdiff", "(", new OneOperator2_< double, double >(invdiff)); // jan 2018 FH + Global.Add("invdiff", "(", new OneOperator3_< double, double, double >(invdiff)); // jan 2018 FH + + Global.Add("max", "(", new OneOperator2_< long, long >(Max)); + Global.Add("min", "(", new OneOperator2_< long, long >(Min)); + Global.Add("max", "(", new OneOperator3_< double, double >(Max< double >)); + Global.Add("min", "(", new OneOperator3_< double, double >(Min< double >)); + Global.Add("max", "(", new OneOperator3_< long, long >(Max)); + Global.Add("min", "(", new OneOperator3_< long, long >(Min)); + Global.Add("max", "(", new OneOperator4_< long, long >(Max)); + Global.Add("min", "(", new OneOperator4_< long, long >(Min)); + Global.Add("max", "(", new OneOperator4_< double, double >(Max)); + Global.Add("min", "(", new OneOperator4_< double, double >(Min)); + + Global.Add("atan2", "(", new OneOperator2< double >(atan2)); + Global.Add("fmod", "(", new OneOperator2< double >(fmod)); // add sep 2017 + Global.Add("fdim", "(", new OneOperator2< double >(fdim)); // add sep 2017 + Global.Add("fmax", "(", new OneOperator2< double >(fmax)); // add sep 2017 + Global.Add("fmin", "(", new OneOperator2< double >(fmin)); // add sep 2017 + + Global.Add("hypot", "(", new OneOperator2< double >(hypot)); // add Jan 2014 + + Global.Add("atan", "(", new OneOperator2< double >(atan2)); + Global.Add("sqrt", "(", new OneOperator1< double >(sqrt, 2)); + Global.Add("cbrt", "(", new OneOperator1< double >(cbrt, 2)); + Global.Add("abs", "(", new OneOperator1< double >(Abs)); + Global.Add("abs", "(", new OneOperator1< long >(Abs)); + Global.Add("cos", "(", new OneOperator1_< Complex >(cos)); + Global.Add("sin", "(", new OneOperator1_< Complex >(sin)); + Global.Add("sinh", "(", new OneOperator1_< Complex >(sinh)); + Global.Add("cosh", "(", new OneOperator1_< Complex >(cosh)); + Global.Add("tanh", "(", new OneOperator1_< Complex >(tanh)); // Add June 2016 FH.. + Global.Add("log", "(", new OneOperator1_< Complex >(log)); + Global.Add("tan", "(", new OneOperator1_< Complex >(tan)); + Global.Add("exp", "(", new OneOperator1_< Complex >(exp)); + + Global.Add("pow", "(", new OneBinaryOperator< Op2_pow< Complex, Complex, Complex > >); + // new OneOperator2_(pow )); + Global.Add("sqrt", "(", new OneOperator1_< Complex >(sqrt, 0)); + Global.Add("conj", "(", new OneOperator1_< Complex >(conj, 0)); + Global.Add("conj", "(", new OneOperator1_< double >(RNM::conj, 1)); + TheOperators->Add("\'", new OneOperator1_< Complex >(conj, 0)); + TheOperators->Add("\'", new OneOperator1_< double >(RNM::conj, 1)); // add F. Feb 2010 of conj of varf.. + + Global.Add("imag", "(", new OneOperator1< double, Complex >(Imag)); + // Big probleme real is a type + Add< double >("<--", "(", new OneOperator1< double, Complex >(Real)); + + Global.Add("abs", "(", new OneOperator1_< double, Complex >(abs)); + + Global.Add("arg", "(", new OneOperator1_< double, Complex >(arg)); + Global.Add("norm", "(", new OneOperator1_< double, Complex >(norm)); + Global.Add("exit", "(", new OneOperator1< long >(Exit)); + Global.Add("assert", "(", new OneOperator1< bool >(Assert)); + + Global.Add("clock", "(", new OneOperator0< double >(CPUtime)); + Global.Add("time", "(", new OneOperator0< double >(walltime)); // add mars 2010 for Pichon. + Global.Add("ltime", "(", new OneOperator0< long >(fftime)); // add mars 2014 ( the times unix fonction) + Global.Add("storageused", "(", new OneOperator0< long >(storageused)); + Global.Add("storagetotal", "(", new OneOperator0< long >(storagetotal)); + + Global.Add("dumptable", "(", new OneOperator1< ostream *, ostream * >(dumptable)); + Global.Add("exec", "(", new OneOperator1< long, string * >(exec)); // FH string * mars 2006 + Global.Add("system", "(", new OneOperator1< long, string * >(exec)); // FH string fevr 2011 + + Global.Add("polar", "(", new OneOperator2_< Complex, double, double >(polar)); + // rand generator --- + unsigned long init[4] = {0x123, 0x234, 0x345, 0x456}, length = 4; init_by_array(init, length); - Global.Add("randint32","(",new OneOperator_0(genrandint32)); - Global.Add("randint31","(",new OneOperator_0(genrand_int31)); - Global.Add("randreal1","(",new OneOperator_0(genrand_real1)); - Global.Add("randreal2","(",new OneOperator_0(genrand_real2)); - Global.Add("randreal3","(",new OneOperator_0(genrand_real3)); - Global.Add("randres53","(",new OneOperator_0(genrand_res53)); - Global.Add("randinit","(",new OneOperator1(genrandint)); + Global.Add("randint32", "(", new OneOperator_0< long >(genrandint32)); + Global.Add("randint31", "(", new OneOperator_0< long >(genrand_int31)); + Global.Add("randreal1", "(", new OneOperator_0< double >(genrand_real1)); + Global.Add("randreal2", "(", new OneOperator_0< double >(genrand_real2)); + Global.Add("randreal3", "(", new OneOperator_0< double >(genrand_real3)); + Global.Add("randres53", "(", new OneOperator_0< double >(genrand_res53)); + Global.Add("randinit", "(", new OneOperator1< long >(genrandint)); // NaN and Inf - Global.Add("ShowAlloc","(",new OneOperator1(ShowAlloc1));// debuging - Global.Add("ShowAlloc","(",new OneOperator2(ShowAlloc1));// debuging - Global.Add("NaN","(",new OneOperator0(NaN)); - - Global.Add("NaN","(",new OneOperator1(NaN)); - Global.Add("isNaN","(",new OneOperator1(isNaN)); - Global.Add("copysign","(",new OneOperator2(copysign));// Add jan 2018 FH - Global.Add("sign","(",new OneOperator1(sign));// Add jan 2018 FH - Global.Add("sign","(",new OneOperator1(sign));// Add jan 2018 FH - Global.Add("signbit","(",new OneOperator1(ffsignbit));// Add jan 2018 FH - Global.Add("signbit","(",new OneOperator1(ffsignbit));// Add jan 2018 FH - - Global.Add("isInf","(",new OneOperator1(isInf)); - Global.Add("isNormal","(",new OneOperator1(isNormal)); - Global.Add("chtmpdir","(",new OneOperator0(ffapi::chtmpdir)); - Global.Add("projection","(",new OneOperator3_(projection)); - Global.Add("dist","(",new OneOperator2_(dist)); - Global.Add("dist","(",new OneOperator3_(dist)); - Global.Add("swap","(",new OneOperator2(pswap)); - Global.Add("swap","(",new OneOperator2(pswap)); - Global.Add("swap","(",new OneOperator2(pswap)); - Global.Add("swap","(",new OneOperator2(pswap)); - Global.Add("swap","(",new OneOperator2(pswap)); - - - atype()->Add("[","",new OneOperator2_(get_elements)); - - atype()->SetTypeLoop(atype(),atype()); - + Global.Add("ShowAlloc", "(", new OneOperator1< long, string * >(ShowAlloc1)); // debuging + Global.Add("ShowAlloc", "(", new OneOperator2< long, string *, long * >(ShowAlloc1)); // debuging + Global.Add("NaN", "(", new OneOperator0< double >(NaN)); + + Global.Add("NaN", "(", new OneOperator1< double, string * >(NaN)); + Global.Add("isNaN", "(", new OneOperator1< long, double >(isNaN)); + Global.Add("copysign", "(", new OneOperator2< double >(copysign)); // Add jan 2018 FH + Global.Add("sign", "(", new OneOperator1< double >(sign)); // Add jan 2018 FH + Global.Add("sign", "(", new OneOperator1< long >(sign)); // Add jan 2018 FH + Global.Add("signbit", "(", new OneOperator1< bool, long >(ffsignbit)); // Add jan 2018 FH + Global.Add("signbit", "(", new OneOperator1< bool, double >(ffsignbit)); // Add jan 2018 FH + + Global.Add("isInf", "(", new OneOperator1< long, double >(isInf)); + Global.Add("isNormal", "(", new OneOperator1< long, double >(isNormal)); + Global.Add("chtmpdir", "(", new OneOperator0< long >(ffapi::chtmpdir)); + Global.Add("projection", "(", new OneOperator3_< double, double >(projection)); + Global.Add("dist", "(", new OneOperator2_< double, double >(dist)); + Global.Add("dist", "(", new OneOperator3_< double, double >(dist)); + Global.Add("swap", "(", new OneOperator2< bool, double * >(pswap)); + Global.Add("swap", "(", new OneOperator2< bool, long * >(pswap)); + Global.Add("swap", "(", new OneOperator2< bool, bool * >(pswap)); + Global.Add("swap", "(", new OneOperator2< bool, Complex * >(pswap)); + Global.Add("swap", "(", new OneOperator2< bool, string ** >(pswap)); + + atype< MyMapSS * >( )->Add("[", "", new OneOperator2_< string **, MyMapSS *, string * >(get_elements)); + + atype< MyMapSS * >( )->SetTypeLoop(atype< string ** >( ), atype< string ** >( )); tables_of_identifier.push_back(&Global); - TheOperators->Add("<<",new OneBinaryOperator >); + TheOperators->Add("<<", new OneBinaryOperator< PrintP< MyMapSS * > >); - TheOperators->Add("{}",new ForAllLoop); + TheOperators->Add("{}", new ForAllLoop< E_ForAllLoopMapSS >); // add setw feb 2015 FH - Global.Add("setw","(",new OneOperator1(defOP_setw)); - TheOperators->Add("<<", new OneBinaryOperator >); -// Add FH oct 2022 and remove form plugin pipe + Global.Add("setw", "(", new OneOperator1< OP_setw, long >(defOP_setw)); + TheOperators->Add("<<", new OneBinaryOperator< Print< OP_setw > >); +// Add FH oct 2022 and remove form plugin pipe #ifdef _WIN32 Global.New("onWIN32", CConstant< bool >(true)); #else @@ -1745,495 +1655,490 @@ void Init_map_type() #endif } +void ClearMem( ) { + size_t lg; + ShowAlloc("ClearMem: begin", lg); + delete pZero; + delete pOne; + delete pminusOne; + + tables_of_identifier.clear( ); + for (map< const string, basicForEachType * >::iterator i = map_type.begin( ); i != map_type.end( ); ++i) delete i->second; + + map_type.clear( ); + map_type_of_map.clear( ); + map_pair_of_type.clear( ); + Global.clear( ); + if (TheOperators) TheOperators->clear( ); + if (TheRightOperators) TheRightOperators->clear( ); + + CodeAlloc::clear( ); + ShowAlloc("ClearMem: end", lg); +} +// <> +static addingInitFunct TheaddingInitFunct(-10000, Init_map_type); +C_F0 opVI::code2(const basicAC_F0 &args) const { + Expression p = args[1]; + if (!p->EvaluableWithOutStack( )) { + CompileError(" [...][p], The p must be a constant , sorry"); + } + int pv = GetAny< long >((*p)(NullStack)); + bool ta = args[0].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + assert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + if (tea) { + AC_F0 v; + for (int i = 0; i < a.size( ); ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li && (li->size( ) > pv)); + + const C_F0 vi = TryConj((*li)[pv]); + if (i == 0) + v = vi; + else + v += vi; + } - void ClearMem() - { - size_t lg; - ShowAlloc("ClearMem: begin" , lg); - delete pZero; - delete pOne; - delete pminusOne; - - tables_of_identifier.clear(); - for (map::iterator i=map_type.begin();i!=map_type.end();++i) - delete i->second; + return C_F0(TheOperators, "[]", v); + } - map_type.clear(); - map_type_of_map.clear(); - map_pair_of_type.clear(); - Global.clear(); - if(TheOperators) - TheOperators->clear(); - if(TheRightOperators) - TheRightOperators->clear(); + if (!(pv >= 0 && pv < a.size( ))) { + cerr << "\n\nerror [ ... ][" << pv << " ] " << " the size of [ ...] is " << a.size( ) << endl; + lgerror(" bound of [ .., .. , ..][ . ] operation "); + } - CodeAlloc::clear(); - ShowAlloc("ClearMem: end" , lg); + return (*a.v)[pv]; +} - } +C_F0 opDot::code2(const basicAC_F0 &args) const { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + bool tb = args[1].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const TransE_Array *teb = 0; + const E_Array *ea = 0; + const E_Array *eb = 0; // E_F0 + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + if (tb) + teb = dynamic_cast< const TransE_Array * >((Expression)args[1]); + else + eb = dynamic_cast< const E_Array * >((Expression)args[1]); + assert(ea || tea); + assert(eb || teb); + const E_Array &a = ta ? *tea->v : *ea; + const E_Array &b = tb ? *teb->v : *eb; + int ma = 1; + int mb = 1; + int na = a.size( ); + int nb = b.size( ); + if (na < 1 && nb < 1) CompileError(" empty array [ ...]'*[ ... ] "); + bool mab = b[0].left( ) == atype< E_Array >( ); + bool maa = a[0].left( ) == atype< E_Array >( ); + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" first matrix with variable number of columm"); + } + if (mab) { + mb = b[1].LeftValue( )->nbitem( ); + for (int i = 1; i < nb; i++) + if (mb != (int)b[i].LeftValue( )->nbitem( )) CompileError(" second matrix with variable number of columm"); + } + int na1 = na, ma1 = ma, nb1 = nb, mb1 = mb; + if (ta) RNM::Exchange(na1, ma1); + if (tb) RNM::Exchange(nb1, mb1); + + KNM< CC_F0 > A(na1, ma1), B(nb1, mb1); + if (A.M( ) != B.N( )) { + cout << " formal prod array or matrix : [ .. ] * [ .. ] " << endl; + cout << " first array : matrix " << maa << " trans " << ta << " " << na << "x" << ma << endl; + cout << " second array : matrix " << mab << " trans " << tb << " " << nb << "x" << mb << endl; + CompileError(" no same size [ ...]'*[ ... ] sorry "); + } -// <> -static addingInitFunct TheaddingInitFunct(-10000,Init_map_type); - -C_F0 opVI::code2(const basicAC_F0 &args) const -{ - Expression p=args[1]; - if ( ! p->EvaluableWithOutStack() ) - { - CompileError(" [...][p], The p must be a constant , sorry"); + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); } - int pv = GetAny((*p)(NullStack)); - bool ta =args[0].left()==atype(); - const TransE_Array * tea=0; - const E_Array * ea=0; - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - assert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - if(tea){ - AC_F0 v ; - for (int i=0;i(a[i].LeftValue()); - ffassert(li && (li->size() >pv)); - - const C_F0 vi = TryConj( (*li)[pv]); - if(i==0) v=vi; - else v+= vi; - - } - - return C_F0(TheOperators,"[]",v); - + else + for (int i = 0; i < na; ++i) + if (!ta) + A(i, 0) = a[i]; + else + A(0, i) = TryConj(a[i]); + + if (mab) + for (int i = 0; i < nb; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(b[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < mb; ++j) + if (!tb) + B(i, j) = (*li)[j]; + else + B(j, i) = TryConj((*li)[j]); } - - if(!(pv >=0 && pv C(na1, mb1); + CC_F0 s, abi; + for (int i = 0; i < na1; ++i) + for (int j = 0; j < mb1; ++j) { + s = C_F0(TheOperators, "*", A(i, 0), B(0, j)); + for (int k = 1; k < ma1; ++k) { + abi = C_F0(TheOperators, "*", A(i, k), B(k, j)); + s = C_F0(TheOperators, "+", s, abi); + } + C(i, j) = s; + }; + if (na1 == 1 && mb1 == 1) + return C(0, 0); + else if (mb1 == 1) // || (na1==1)) // correct du car ' on conj encore r . mars 2010 + { + AC_F0 v; + v = C(0, 0); + int i0 = na1 != 1, j0 = mb1 != 1, nn = mb1 * na1; + for (int i = 1; i < nn; ++i) v += C(i0 * i, j0 * i); + C_F0 r(TheOperators, "[]", v); + if (mb1 == 1) + return r; + else + return C_F0(TheOperators, "\'", r); // Bug car on conj encore r . mars 2010 + } else { + AC_F0 v, cc; + v = C(0, 0); + for (int i = 0; i < na1; ++i) { + cc = C(i, 0); + for (int j = 1; j < mb1; ++j) cc += C(i, j); + C_F0 vi(TheOperators, "[]", cc); + if (i == 0) + v = vi; + else + v += vi; } + return C_F0(TheOperators, "[]", v); + } - return (* a.v)[pv]; -} - -C_F0 opDot::code2(const basicAC_F0 &args) const -{ - bool ta =args[0].left()==atype(); - bool tb = args[1].left()==atype(); - const TransE_Array * tea=0; - const TransE_Array * teb=0; - const E_Array * ea=0; - const E_Array * eb=0;// E_F0 - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - if( tb) teb = dynamic_cast((Expression) args[1]); - else eb = dynamic_cast((Expression) args[1]); - assert( ea || tea ); - assert( eb || teb ); - const E_Array & a= ta ? *tea->v : *ea; - const E_Array & b= tb ? *teb->v : *eb; - int ma =1; - int mb =1; - int na=a.size(); - int nb=b.size(); - if(na <1 && nb < 1) CompileError(" empty array [ ...]'*[ ... ] "); - bool mab= b[0].left()==atype(); - bool maa= a[0].left()==atype(); - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" first matrix with variable number of columm"); + cout << " formal prod array or matrix : [ .. ] * [ .. ] " << na << "x" << nb << endl; + cout << " formal prod array or matrix : [ .. ] * [ .. ] " << endl; + cout << " first array : matrix " << maa << " trans " << ta << " " << na << "x" << ma << endl; + cout << " second array : matrix " << mab << " trans " << tb << " " << nb << "x" << mb << endl; + CompileError(" not implemented sorry ..... (FH) to do ???? "); + return C_F0( ); +} +C_F0 opColumn::code2(const basicAC_F0 &args) const { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + bool tb = args[1].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const TransE_Array *teb = 0; + const E_Array *ea = 0; + const E_Array *eb = 0; // E_F0 + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + if (tb) + teb = dynamic_cast< const TransE_Array * >((Expression)args[1]); + else + eb = dynamic_cast< const E_Array * >((Expression)args[1]); + + if ((eb || teb) && (ea || tea)) { + const E_Array &a = ta ? *tea->v : *ea; + const E_Array &b = tb ? *teb->v : *eb; + int ma = 1; + int mb = 1; + int na = a.size( ); + int nb = b.size( ); + if (na < 1 && nb < 1) CompileError(" empty array [ ...]':[ ... ] "); + bool mab = b[0].left( ) == atype< E_Array >( ); + bool maa = a[0].left( ) == atype< E_Array >( ); + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" first matrix with variable number of columm"); } - if(mab) { - mb= b[1].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" second matrix with variable number of columm"); + if (mab) { + mb = b[1].LeftValue( )->nbitem( ); + for (int i = 1; i < nb; i++) + if (mb != (int)b[i].LeftValue( )->nbitem( )) CompileError(" second matrix with variable number of columm"); } - int na1=na,ma1=ma,nb1=nb,mb1=mb; - if(ta) RNM::Exchange(na1,ma1); - if(tb) RNM::Exchange(nb1,mb1); - - KNM A(na1,ma1), B(nb1,mb1); - if ( A.M() != B.N()) - { - cout << " formal prod array or matrix : [ .. ] * [ .. ] " << endl; - cout << " first array : matrix " << maa << " trans " << ta << " " << na << "x" << ma < A(na1, ma1), B(nb1, mb1); + if ((na1 != nb1) || (ma1 != mb1) || (na1 * ma1 == 0)) { + cout << "\n formal array or matrix : [ .. ] : [ .. ] " << endl; + cout << " first array : matrix " << maa << " trans " << ta << " " << na << "x" << ma << endl; + cout << " second array : matrix " << mab << " trans " << tb << " " << nb << "x" << mb << endl; + CompileError(" no same size [ ...] : [ ... ] sorry "); } - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(b[i].LeftValue()); - ffassert(li); - for (int j=0; j(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); + } else - for (int i=0;i C(na1,mb1); - CC_F0 s,abi; - for (int i=0;i(b[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < mb; ++j) + if (!tb) + B(i, j) = (*li)[j]; + else + B(j, i) = TryConj((*li)[j]); + } else - { - AC_F0 v,cc; - v=C(0,0); - for (int i=0;i(); - bool tb = args[1].left()==atype(); - const TransE_Array * tea=0; - const TransE_Array * teb=0; - const E_Array * ea=0; - const E_Array * eb=0;// E_F0 - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - if( tb) teb = dynamic_cast((Expression) args[1]); - else eb = dynamic_cast((Expression) args[1]); - - if( (eb || teb) && ( ea || tea ) ) - { - const E_Array & a= ta ? *tea->v : *ea; - const E_Array & b= tb ? *teb->v : *eb; - int ma =1; - int mb =1; - int na=a.size(); - int nb=b.size(); - if(na <1 && nb < 1) CompileError(" empty array [ ...]':[ ... ] "); - bool mab= b[0].left()==atype(); - bool maa= a[0].left()==atype(); - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" first matrix with variable number of columm"); + CC_F0 s, aibi; - } - if(mab) { - mb= b[1].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" second matrix with variable number of columm"); - } - int na1=na,ma1=ma,nb1=nb,mb1=mb; - if(ta) RNM::Exchange(na1,ma1); - if(tb) RNM::Exchange(nb1,mb1); - - KNM A(na1,ma1), B(nb1,mb1); - if ( (na1!=nb1 ) || (ma1 != mb1) || (na1 * ma1 ==0) ) - { - cout << "\n formal array or matrix : [ .. ] : [ .. ] " << endl; - cout << " first array : matrix " << maa << " trans " << ta << " " << na << "x" << ma <(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(b[i].LeftValue()); - ffassert(li); - for (int j=0; j [ a0*b',a1*b', + const E_Array &a = ta ? *tea->v : *ea; + int na = a.size( ); + AC_F0 v; + v = 0; // empty + C_F0 b = ta ? TryConj(args[1]) : args[1]; + for (int i = 0; i < na; ++i) v += C_F0(TheOperators, "*", a[i], b); + return ta ? C_F0(TheOperators, "\'", C_F0(TheOperators, "[]", v)) : C_F0(TheOperators, "[]", v); + + } else if (eb || teb) { // modif 2 /08/ 2013 FH .. bug in a*[ b0,b1,... ]' + const E_Array &b = tb ? *teb->v : *eb; + int nb = b.size( ); + C_F0 a = tb ? TryConj(args[0]) : args[0]; + AC_F0 v; + v = 0; // empty + for (int i = 0; i < nb; ++i) v += C_F0(TheOperators, "*", a, b[i]); + return tb ? C_F0(TheOperators, "\'", C_F0(TheOperators, "[]", v)) : C_F0(TheOperators, "[]", v); + + } else + ffassert(0); + return C_F0( ); +} +C_F0 opUnary::code2(const basicAC_F0 &args) const { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + assert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + int na = a.size( ); + if (na < 1 && nb < 1) CompileError(" empty array - [ ...] "); + bool maa = a[0].left( ) == atype< E_Array >( ); + int ma = 1; + + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" first matrix with variable number of columm"); + } + int na1 = na, ma1 = ma; + if (ta) RNM::Exchange(na1, ma1); + + KNM< CC_F0 > A(na1, ma1); + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; else - for (int i=0;i [ a0*b',a1*b', - const E_Array & a= ta ? *tea->v : *ea; - int na=a.size(); - AC_F0 v; - v = 0; // empty - C_F0 b =ta ? TryConj(args[1]) :args[1]; - for (int i=0;iv : *eb; - int nb=b.size(); - C_F0 a =tb ? TryConj(args[0]) :args[0]; - AC_F0 v; - v = 0; // empty - for (int i=0;i(); - const TransE_Array * tea=0; - const E_Array * ea=0; - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - assert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - int na=a.size(); - if(na <1 && nb < 1) CompileError(" empty array - [ ...] "); - bool maa= a[0].left()==atype(); - int ma =1; - - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" first matrix with variable number of columm"); - - } - int na1=na,ma1=ma; - if(ta) RNM::Exchange(na1,ma1); - - KNM A(na1,ma1) ; - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(); - bool tb = args[1].left()==atype(); - const TransE_Array * tea=0; - const TransE_Array * teb=0; - const E_Array * ea=0; - const E_Array * eb=0;// E_F0 - if( ta) tea = dynamic_cast((Expression) args[0]); - else ea = dynamic_cast((Expression) args[0]); - if( tb) teb = dynamic_cast((Expression) args[1]); - else eb = dynamic_cast((Expression) args[1]); - assert( ea || tea ); - assert( eb || teb ); - const E_Array & a= ta ? *tea->v : *ea; - const E_Array & b= tb ? *teb->v : *eb; - int na=a.size(); - int nb=b.size(); - if(na <1 && nb < 1) CompileError(" empty array [ ...] + [ ... ] "); - - bool mab= b[0].left()==atype(); - bool maa= a[0].left()==atype(); - int ma =1; - int mb =1; - - if(maa) { - ma= a[0].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" first matrix with variable number of columm"); - - } - if(mab) { - mb= b[1].LeftValue()->nbitem(); - for (int i=1;inbitem()) - CompileError(" second matrix with variable number of columm"); +C_F0 opSum::code2(const basicAC_F0 &args) const { + + bool ta = args[0].left( ) == atype< TransE_Array >( ); + bool tb = args[1].left( ) == atype< TransE_Array >( ); + const TransE_Array *tea = 0; + const TransE_Array *teb = 0; + const E_Array *ea = 0; + const E_Array *eb = 0; // E_F0 + if (ta) + tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + else + ea = dynamic_cast< const E_Array * >((Expression)args[0]); + if (tb) + teb = dynamic_cast< const TransE_Array * >((Expression)args[1]); + else + eb = dynamic_cast< const E_Array * >((Expression)args[1]); + assert(ea || tea); + assert(eb || teb); + const E_Array &a = ta ? *tea->v : *ea; + const E_Array &b = tb ? *teb->v : *eb; + int na = a.size( ); + int nb = b.size( ); + if (na < 1 && nb < 1) CompileError(" empty array [ ...] + [ ... ] "); + + bool mab = b[0].left( ) == atype< E_Array >( ); + bool maa = a[0].left( ) == atype< E_Array >( ); + int ma = 1; + int mb = 1; + + if (maa) { + ma = a[0].LeftValue( )->nbitem( ); + for (int i = 1; i < na; i++) + if (ma != (int)a[i].LeftValue( )->nbitem( )) CompileError(" first matrix with variable number of columm"); + } + if (mab) { + mb = b[1].LeftValue( )->nbitem( ); + for (int i = 1; i < nb; i++) + if (mb != (int)b[i].LeftValue( )->nbitem( )) CompileError(" second matrix with variable number of columm"); + } + int na1 = na, ma1 = ma, nb1 = nb, mb1 = mb; + if (ta) RNM::Exchange(na1, ma1); + if (tb) RNM::Exchange(nb1, mb1); + + if (na1 != nb1 || ma1 != mb1) CompileError(" formal [ [...] [] ] + [ [..], [..] , ... ] "); + + KNM< CC_F0 > A(na1, ma1), B(nb1, mb1); + if (maa) + for (int i = 0; i < na; ++i) { + const E_Array *li = dynamic_cast< const E_Array * >(a[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < ma; ++j) + if (!ta) + A(i, j) = (*li)[j]; + else + A(j, i) = TryConj((*li)[j]); } - int na1=na,ma1=ma,nb1=nb,mb1=mb; - if(ta) RNM::Exchange(na1,ma1); - if(tb) RNM::Exchange(nb1,mb1); - - if(na1 != nb1 || ma1 != mb1) CompileError(" formal [ [...] [] ] + [ [..], [..] , ... ] "); - - KNM A(na1,ma1), B(nb1,mb1); - if(maa) - for (int i=0;i(a[i].LeftValue()); - ffassert(li); - for (int j=0; j(b[i].LeftValue()); - ffassert(li); - for (int j=0; j(b[i].LeftValue( )); + ffassert(li); + for (int j = 0; j < mb; ++j) + if (!tb) + B(i, j) = (*li)[j]; + else + B(j, i) = TryConj((*li)[j]); } - else { - // return formal matrix - AC_F0 w,v; - w=0; - for (int i=0;i999999) cout << p << "=newstring() " <999999) cout << p << "=newstring((string) "<< c << ") \n"; - return p;} -string *newstring(const char * c){ - string * p=new string(c); - if(verbosity>999999) cout << p << "=newstring((char*) "<< c << " ) \n"; - return p;} -void freestring(const string * c){ - if(verbosity>999999) cout << c << "freestring( "<< *c <<") \n"; - delete c;} +string *newstring( ) { + string *p = new string( ); + if (verbosity > 999999) cout << p << "=newstring() " << endl; + ; + return p; +} +string *newstring(const string &c) { + string *p = new string(c); + if (verbosity > 999999) cout << p << "=newstring((string) " << c << ") \n"; + return p; +} +string *newstring(const char *c) { + string *p = new string(c); + if (verbosity > 999999) cout << p << "=newstring((char*) " << c << " ) \n"; + return p; +} +void freestring(const string *c) { + if (verbosity > 999999) cout << c << "freestring( " << *c << ") \n"; + delete c; +} diff --git a/src/fflib/AFunction.hpp b/src/fflib/AFunction.hpp index c921b9683..f2c005e85 100644 --- a/src/fflib/AFunction.hpp +++ b/src/fflib/AFunction.hpp @@ -2,37 +2,36 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//file afonction.h - +// file afonction.h #ifndef __AFONCTION__ #define __AFONCTION__ -#include "showverb.hpp" +#include "showverb.hpp" #include "InitFunct.hpp" #include @@ -51,40 +50,39 @@ #include #include extern bool showCPU; -#include "RNM.hpp" +#include "RNM.hpp" -# include +#include /* #ifdef TIME_WITH_SYS_TIME -# include -# include +# include +# include #else -# ifdef HAVE_SYS_TIME_H -# include -# else +# ifdef HAVE_SYS_TIME_H +# include +# else # include -# endif +# endif #endif */ -// #include +// #include #include "CodeAlloc.hpp" -inline double CPUtime(){ - /* +inline double CPUtime( ) { + /* #ifdef SYSTIMES - struct tms buf; - if (times(&buf)!=-1) - return ((double)buf.tms_utime+(double)buf.tms_stime)/(long) sysconf(_SC_CLK_TCK); - else +struct tms buf; +if (times(&buf)!=-1) + return ((double)buf.tms_utime+(double)buf.tms_stime)/(long) sysconf(_SC_CLK_TCK); +else #endif - */ - return ((double) std::clock())/CLOCKS_PER_SEC; + */ + return ((double)std::clock( )) / CLOCKS_PER_SEC; } -extern long verbosity; // level off printing -extern long searchMethod; //pichon -extern bool withrgraphique; -extern bool lockOrientation; // lock the element orientation - +extern long verbosity; // level off printing +extern long searchMethod; // pichon +extern bool withrgraphique; +extern bool lockOrientation; // lock the element orientation using namespace std; #include "ffstack.hpp" @@ -92,75 +90,72 @@ using namespace std; #include "AnyType.hpp" #include "String.hpp" - class basicForEachType; class E_F1_funcT_Type; -class E_F0; // une instruction exec time -class C_F0; // une instruction complie time +class E_F0; // une instruction exec time +class C_F0; // une instruction complie time class ListOfInst; class Polymorphic; class OneOperator; -/// <> is used as the type of the local list contained in ListOfInst +/// <> is used as the type of the local list contained in ListOfInst -typedef E_F0 * Expression; // [[E_F0]] +typedef E_F0 *Expression; // [[E_F0]] class AC_F0; class basicAC_F0; -typedef complex Complex; +typedef complex< double > Complex; /// <> [[file:AnyType.hpp::aType]] [[E_F0]] -typedef pair Type_Expr ;// to store the type and the expression 29042005 FH +typedef pair< aType, E_F0 * > Type_Expr; // to store the type and the expression 29042005 FH + +int FindType(const char *name); +void lgerror(const char *s); +void CompileError(string msg = "", aType r = 0); +void ExecError(string msg = ""); - int FindType(const char * name) ; - void lgerror (const char* s) ; - void CompileError(string msg="",aType r=0); - void ExecError(string msg=""); - struct UnId { - const char * id; + const char *id; aType r; - Expression e; - deque * array; // to store a array - aType re; - bool ref; // a ref or non - bool compo_begin; // used in problem/solve to know if we have a composite Problem //=== Modif 4/10/2022 Morice (chevron dans problem) - bool compo_end; // used in problem/solve to know if we have a composite Problem //=== Modif 4/10/2022 Morice (chevron dans problem) - UnId() :id(0),r(0),e(0),array(0),re(0),ref(false),compo_begin(false),compo_end(false) {} - UnId(const char * idd) :id(idd),r(0),e(0),array(0),re(0),ref(false), compo_begin(false), compo_end(false) {} - UnId(const char * idd,const C_F0 & ee,aType rr,bool reff) ; - UnId(deque * d, bool cc_b=false, bool cc_e=false) : id(0),r(0),e(0),array(d?new deque(*d):0),re(0),ref(false),compo_begin(cc_b),compo_end(cc_e) { } - UnId(const UnId & u) : - id(u.id),r(u.r),e(u.e), - array(u.array?new deque(*u.array):0), - re(u.re),ref(u.ref),compo_begin(u.compo_begin),compo_end(u.compo_end) {} - // Modif 24032005 - void operator= (const UnId & u) { - id=u.id; - r=u.r; - e=u.e; - re=u.re; - ref=u.ref; - compo_begin=u.compo_begin; - compo_end=u.compo_end; - if(array) delete array; - array=0; - if(u.array) array= new deque(*u.array); - } - - ~UnId(){ if( array) delete array;} // Modif 24032005 - + Expression e; + deque< UnId > *array; // to store a array + aType re; + bool ref; // a ref or non + bool compo_begin; // used in problem/solve to know if we have a composite Problem //=== Modif 4/10/2022 Morice (chevron dans problem) + bool compo_end; // used in problem/solve to know if we have a composite Problem //=== Modif 4/10/2022 Morice (chevron dans problem) + UnId( ) : id(0), r(0), e(0), array(0), re(0), ref(false), compo_begin(false), compo_end(false) {} + UnId(const char *idd) : id(idd), r(0), e(0), array(0), re(0), ref(false), compo_begin(false), compo_end(false) {} + UnId(const char *idd, const C_F0 &ee, aType rr, bool reff); + UnId(deque< UnId > *d, bool cc_b = false, bool cc_e = false) : id(0), r(0), e(0), array(d ? new deque< UnId >(*d) : 0), re(0), ref(false), compo_begin(cc_b), compo_end(cc_e) {} + UnId(const UnId &u) : id(u.id), r(u.r), e(u.e), array(u.array ? new deque< UnId >(*u.array) : 0), re(u.re), ref(u.ref), compo_begin(u.compo_begin), compo_end(u.compo_end) {} + // Modif 24032005 + void operator=(const UnId &u) { + id = u.id; + r = u.r; + e = u.e; + re = u.re; + ref = u.ref; + compo_begin = u.compo_begin; + compo_end = u.compo_end; + if (array) delete array; + array = 0; + if (u.array) array = new deque< UnId >(*u.array); + } + + ~UnId( ) { + if (array) delete array; + } // Modif 24032005 }; /// <> -typedef deque ListOfId; +typedef deque< UnId > ListOfId; -// xxx is a type so xxx can't be a parameter -#define ATYPE(xxx) map_type[typeid(xxx).name()] +// xxx is a type so xxx can't be a parameter +#define ATYPE(xxx) map_type[typeid(xxx).name( )] /* #define NEW_TYPE(type) map_type[typeid(type).name()] = new ForEachType(0,0) //#define NEW_TYPE(type) map_type[typeid(type).name()] = new ForEachType() -#define NEW_TYPE_I(type,i,d) map_type[typeid(type).name()] = new ForEachType(i,d) +#define NEW_TYPE_I(type,i,d) map_type[typeid(type).name()] = new ForEachType(i,d) #define NEW_TYPE_Ptr(type) map_type[typeid(type*).name()] = new ForEachTypePtr() #define NEW_TYPE_PtrND(type) map_type[typeid(type*).name()] = new ForEachTypePtr(0) #define NEW_TYPE_PtrNIND(type) map_type[typeid(type*).name()] = new ForEachTypePtr(0,0) @@ -168,468 +163,533 @@ typedef deque ListOfId; */ /// Doxygen doc -extern Polymorphic * TheOperators, * TheRightOperators; +extern Polymorphic *TheOperators, *TheRightOperators; // ------------- -extern C_F0 *pOne,*pZero,*pminusOne; - - -typedef AnyType (* Function1)(Stack, const AnyType &); -typedef AnyType (* Function2)(Stack, const AnyType &,const AnyType &); -typedef AnyType (* CFunction2)(Stack, E_F0 *, E_F0 *); -typedef AnyType (* CFunction4)(Stack, E_F0 *, E_F0 *, E_F0 *, E_F0 *); - +extern C_F0 *pOne, *pZero, *pminusOne; -Expression NewExpression(Function1,Expression); -Expression NewExpression(Function2,Expression,Expression); +typedef AnyType (*Function1)(Stack, const AnyType &); +typedef AnyType (*Function2)(Stack, const AnyType &, const AnyType &); +typedef AnyType (*CFunction2)(Stack, E_F0 *, E_F0 *); +typedef AnyType (*CFunction4)(Stack, E_F0 *, E_F0 *, E_F0 *, E_F0 *); +Expression NewExpression(Function1, Expression); +Expression NewExpression(Function2, Expression, Expression); -inline Type_Expr make_Type_Expr(aType t, E_F0 * e) {return make_pair(t,e);} -inline Type_Expr make_Type_Expr( E_F0 * e,aType t) {return make_pair(t,e);} +inline Type_Expr make_Type_Expr(aType t, E_F0 *e) { return make_pair(t, e); } +inline Type_Expr make_Type_Expr(E_F0 *e, aType t) { return make_pair(t, e); } -struct Keyless - { - using first_argument_type = const char *; - using second_argument_type = const char *; - using result_type = bool; - typedef const char * Key; - bool operator()(const Key& x, const Key& y) const { return strcmp(x,y)<0;} }; - +struct Keyless { + using first_argument_type = const char *; + using second_argument_type = const char *; + using result_type = bool; + typedef const char *Key; + bool operator( )(const Key &x, const Key &y) const { return strcmp(x, y) < 0; } +}; // <> class vectorOfInst; -class TableOfIdentifier: public CodeAlloc { - public: +class TableOfIdentifier : public CodeAlloc { + public: struct Value; - typedef const char * Key; - typedef map maptype; - typedef pair pKV; + typedef const char *Key; + typedef map< Key, Value, Keyless > maptype; + typedef pair< const Key, Value > pKV; typedef maptype::iterator iterator; typedef maptype::const_iterator const_iterator; - - struct Value :public Type_Expr { - pKV * next; // link all the variable in reverse order to call delete on each variable - bool del; - Value(const Type_Expr & vv,pKV * n,bool dd=true) : Type_Expr(vv),next(n),del(dd) {} - Value(aType t,E_F0 *f,pKV *n,bool dd=true): Type_Expr(t,f),next(n),del(dd) {} - };// to store the type and the expression - pKV * listofvar; - -// struct Keyless : binary_function -// { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} }; + struct Value : public Type_Expr { + pKV *next; // link all the variable in reverse order to call delete on each variable + bool del; + Value(const Type_Expr &vv, pKV *n, bool dd = true) : Type_Expr(vv), next(n), del(dd) {} + Value(aType t, E_F0 *f, pKV *n, bool dd = true) : Type_Expr(t, f), next(n), del(dd) {} + }; // to store the type and the expression + pKV *listofvar; + + // struct Keyless : binary_function + // { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} }; maptype m; int nIdWithDelete; - C_F0 Find(Key) const ; - C_F0 Find(Key,const basicAC_F0 &) const ; - - const Type_Expr & New(Key k,const Type_Expr & v,bool del=true); - void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0, - OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0, - OneOperator *p5=0,OneOperator *p6=0) ; - void clear(); -template - C_F0 NewVar(Key k,aType t,size_t & top,const C_F0 &i) ; -template - C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args) ; -template - C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const U & data) ; -// C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const C_F0& f) ; -template - C_F0 NewVar(Key k,aType t,size_t & top) ; - C_F0 NewID(aType t,Key k, C_F0 & c,size_t & top,bool del=true); - C_F0 NewID(aType t,Key k, C_F0 & c,const ListOfId & l,size_t & top,bool del=true); -template - C_F0 NewFESpace(Key k,aType t,size_t & top,const basicAC_F0 &args); - friend ostream & operator<<(ostream & f,const TableOfIdentifier & ); - - vectorOfInst* newdestroy(); - C_F0 destroy(); - TableOfIdentifier() ; //: listofvar(0) {}; - ~TableOfIdentifier(); // -}; - - -// <> for all the type of the language + C_F0 Find(Key) const; + C_F0 Find(Key, const basicAC_F0 &) const; + + const Type_Expr &New(Key k, const Type_Expr &v, bool del = true); + void Add(Key k, Key op, OneOperator *p0, OneOperator *p1 = 0, OneOperator *p2 = 0, OneOperator *p3 = 0, OneOperator *p4 = 0, OneOperator *p5 = 0, OneOperator *p6 = 0); + void clear( ); + template< class T > + C_F0 NewVar(Key k, aType t, size_t &top, const C_F0 &i); + template< class T > + C_F0 NewVar(Key k, aType t, size_t &top, const basicAC_F0 &args); + template< class T, class U > + C_F0 NewVar(Key k, aType t, size_t &top, const basicAC_F0 &args, const U &data); + // C_F0 NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const C_F0& f) ; + template< class T > + C_F0 NewVar(Key k, aType t, size_t &top); + C_F0 NewID(aType t, Key k, C_F0 &c, size_t &top, bool del = true); + C_F0 NewID(aType t, Key k, C_F0 &c, const ListOfId &l, size_t &top, bool del = true); + template< class T > + C_F0 NewFESpace(Key k, aType t, size_t &top, const basicAC_F0 &args); + friend ostream &operator<<(ostream &f, const TableOfIdentifier &); + + vectorOfInst *newdestroy( ); + C_F0 destroy( ); + TableOfIdentifier( ); //: listofvar(0) {}; + ~TableOfIdentifier( ); // +}; + +// <> for all the type of the language class basicForEachType : public CodeAlloc { - const type_info * ktype; // the real type_info - // const type_info *ktypefunc;// the type of code - public: - static basicForEachType * tnull; - const size_t size; - - - typedef OneOperator * CastFunc; - typedef map::const_iterator const_cast_iterator; - - typedef const char * Key; - - // virtual void print(ostream &f,const void *p) const =0; - - friend ostream & operator<<(ostream & f,const basicForEachType & e) - { f << '<' << e.name() << '>' ;return f;} - void Show(ostream & f) const ; - const char * name() const { return this!=tnull ? ktype->name() :"NULL" ;} - virtual bool CastingFrom(const basicForEachType * t) const ; - // modif FH ----- A TESTER // - virtual bool SametypeRight(const basicForEachType * t) const {return (this == t) || (t == un_ptr_type) || (t == type_C_F0);} -// virtual Type_Expr init(const Type_Expr & te) const { return Type_Expr(0,0);} - virtual int TYPEOFID() const {return 0;} -// bool SametypeLeft(const basicForEachType * t) const {return t == this;} - // bool To(const basicForEachType * t) const { throwassert(t && this);return un_ptr_type == this ? t->un_ptr_type == this : t == this;} - virtual C_F0 CastTo(const C_F0 & e) const ; - virtual void SetArgs(const ListOfId *lid) const ;// { cout << "SetArgs::\n " ;throwassert(lid==0 || lid->size()==0);} - aType right() const {return un_ptr_type;}; - Expression RightValueExpr(Expression f) const; - // Type_Expr NewVar(Key k,aType t,size_t & top,const C_F0 &i); - virtual C_F0 Initialization(const Type_Expr & e) const ; - virtual Expression Destroy(const C_F0 &) const ; - virtual bool ExistDestroy() const {return destroy;} - virtual Type_Expr SetParam(const C_F0 & c,const ListOfId * l,size_t & top) const; - virtual Expression OnReturn(Expression f) const; - // { return make_pair(this,c.left());} - - protected: - basicForEachType(const type_info & k ,const size_t , - const E_F1_funcT_Type * p=0,basicForEachType *rr=0, - Function1 iv=0,Function1 id=0, Function1 dreturn=0) ; -/* inline basicForEachType(const type_info & k ,const type_info & kf ,const size_t , - const E_F1_funcT_Type * p=0,basicForEachType *rr=0, - Function1 iv=0,Function1 id=0) ;*/ - -public: - static const basicForEachType * type_C_F0; // for any type un formal operation .... FH add 09/2012 - - const basicForEachType * un_ptr_type; // type of right exp - private: - // map mapofcast; - OneOperator * casting; // <> list of operator for casting to this type - - const E_F1_funcT_Type * un_ptr; // is ptr -> get value function - Function1 DoOnReturn; // to call some thing on return. - - - Function1 InitExp; // to init the ptr value - Function1 destroy;// the destroy function - TableOfIdentifier ti; // all polymorphisme of the Identifier - public: + const type_info *ktype; // the real type_info + // const type_info *ktypefunc;// the type of code + public: + static basicForEachType *tnull; + const size_t size; + + typedef OneOperator *CastFunc; + typedef map< aType, CastFunc >::const_iterator const_cast_iterator; + + typedef const char *Key; + + // virtual void print(ostream &f,const void *p) const =0; + + friend ostream &operator<<(ostream &f, const basicForEachType &e) { + f << '<' << e.name( ) << '>'; + return f; + } + void Show(ostream &f) const; + const char *name( ) const { return this != tnull ? ktype->name( ) : "NULL"; } + virtual bool CastingFrom(const basicForEachType *t) const; + // modif FH ----- A TESTER // + virtual bool SametypeRight(const basicForEachType *t) const { return (this == t) || (t == un_ptr_type) || (t == type_C_F0); } + // virtual Type_Expr init(const Type_Expr & te) const { return Type_Expr(0,0);} + virtual int TYPEOFID( ) const { return 0; } + // bool SametypeLeft(const basicForEachType * t) const {return t == this;} + // bool To(const basicForEachType * t) const { throwassert(t && this);return un_ptr_type == this ? t->un_ptr_type == this : t == this;} + virtual C_F0 CastTo(const C_F0 &e) const; + virtual void SetArgs(const ListOfId *lid) const; // { cout << "SetArgs::\n " ;throwassert(lid==0 || lid->size()==0);} + aType right( ) const { return un_ptr_type; }; + Expression RightValueExpr(Expression f) const; + // Type_Expr NewVar(Key k,aType t,size_t & top,const C_F0 &i); + virtual C_F0 Initialization(const Type_Expr &e) const; + virtual Expression Destroy(const C_F0 &) const; + virtual bool ExistDestroy( ) const { return destroy; } + virtual Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const; + virtual Expression OnReturn(Expression f) const; + // { return make_pair(this,c.left());} + + protected: + basicForEachType(const type_info &k, const size_t, const E_F1_funcT_Type *p = 0, basicForEachType *rr = 0, Function1 iv = 0, Function1 id = 0, Function1 dreturn = 0); + /* inline basicForEachType(const type_info & k ,const type_info & kf ,const size_t , + const E_F1_funcT_Type * p=0,basicForEachType *rr=0, + Function1 iv=0,Function1 id=0) ;*/ + + public: + static const basicForEachType *type_C_F0; // for any type un formal operation .... FH add 09/2012 + + const basicForEachType *un_ptr_type; // type of right exp + private: + // map mapofcast; + OneOperator *casting; // <> list of operator for casting to this type + + const E_F1_funcT_Type *un_ptr; // is ptr -> get value function + Function1 DoOnReturn; // to call some thing on return. + + Function1 InitExp; // to init the ptr value + Function1 destroy; // the destroy function + TableOfIdentifier ti; // all polymorphisme of the Identifier + public: // basicForEachType * FunctionType() const;// { return funct_type ? funct_type : (funct_type= new FuncForEachType(this));} - C_F0 Find(const char * k) const; // {return ti->Find(k);} - C_F0 Find(const char * k,const basicAC_F0 & args) const; // {return ti->Find(k);} - void New(Key k,Type_Expr v,bool del=true){ti.New(k,v,del);} - - void Add(Key k,Key op,OneOperator *p0,OneOperator *p1=0, - OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0, - OneOperator *p5=0,OneOperator *p6=0) - {ti.Add(k,op,p0,p1,p2,p3,p4,p5,p6);} - - void AddCast(CastFunc f1,CastFunc f2=0,CastFunc f3=0,CastFunc f4=0, - CastFunc f5=0,CastFunc f6=0,CastFunc f7=0,CastFunc f8=0); - ostream & ShowTable(ostream & f) const { f << ti; return f;} - - // basicForEachType * funct_type; - virtual ~basicForEachType(); + C_F0 Find(const char *k) const; // {return ti->Find(k);} + C_F0 Find(const char *k, const basicAC_F0 &args) const; // {return ti->Find(k);} + void New(Key k, Type_Expr v, bool del = true) { ti.New(k, v, del); } - // Add FH: for implicite loop FH. Jan 2016 - // type for i, type for j, type valeur - basicForEachType *typei,*typej,*typev; - void SetTypeLoop(basicForEachType *v,basicForEachType *i=0,basicForEachType *j=0) - { typev=v; typei=i;typej=j;} - -}; + void Add(Key k, Key op, OneOperator *p0, OneOperator *p1 = 0, OneOperator *p2 = 0, OneOperator *p3 = 0, OneOperator *p4 = 0, OneOperator *p5 = 0, OneOperator *p6 = 0) { + ti.Add(k, op, p0, p1, p2, p3, p4, p5, p6); + } + void AddCast(CastFunc f1, CastFunc f2 = 0, CastFunc f3 = 0, CastFunc f4 = 0, CastFunc f5 = 0, CastFunc f6 = 0, CastFunc f7 = 0, CastFunc f8 = 0); + ostream &ShowTable(ostream &f) const { + f << ti; + return f; + } -template -inline basicForEachType * atype() { - map::iterator ir=map_type.find(typeid(T).name()); - // basicForEachType * r=map_type[]; - if (ir == map_type.end()) { cerr << "Error: aType '" << typeid(T).name() << "', doesn't exist\n"; - ShowType(cerr); - throw(ErrorExec("exit",1));} - return ir->second;} + // basicForEachType * funct_type; + virtual ~basicForEachType( ); + + // Add FH: for implicite loop FH. Jan 2016 + // type for i, type for j, type valeur + basicForEachType *typei, *typej, *typev; + void SetTypeLoop(basicForEachType *v, basicForEachType *i = 0, basicForEachType *j = 0) { + typev = v; + typei = i; + typej = j; + } +}; -template -inline basicForEachType * atype0() { - map::iterator ir=map_type.find(typeid(T).name()); - if (ir == map_type.end()) return 0; - return ir->second;} +template< typename T > +inline basicForEachType *atype( ) { + map< const string, basicForEachType * >::iterator ir = map_type.find(typeid(T).name( )); + // basicForEachType * r=map_type[]; + if (ir == map_type.end( )) { + cerr << "Error: aType '" << typeid(T).name( ) << "', doesn't exist\n"; + ShowType(cerr); + throw(ErrorExec("exit", 1)); + } + return ir->second; +} +template< typename T > +inline basicForEachType *atype0( ) { + map< const string, basicForEachType * >::iterator ir = map_type.find(typeid(T).name( )); + if (ir == map_type.end( )) return 0; + return ir->second; +} // -------- -//typedef basicForEachType TheType; +// typedef basicForEachType TheType; -// const basicForEachType * ktype; // compilation time +// const basicForEachType * ktype; // compilation time -// class for all exp -// a left exp is a pointer expression +// class for all exp +// a left exp is a pointer expression // ------- // -- exec times le code is just E_F0*(fonction without args) class C_LF2; class C_LF1; -// 3 types of function/expression 0,1,2 args +// 3 types of function/expression 0,1,2 args /// <> is the base class for all expressions built by parsing an EDP script in the grammar of the FreeFem++ /// language (see [[file:../lglib/lg.ypp]]). E_F0 pointers are typed as [[Expression]], stored as a list in /// [[ListOfInst]], and evaluated when CListOfInst::eval() [[file:AFunction.hpp::CListOfInst::eval]] is called at /// [[file:../lglib/lg.ypp::evaluate_parsed_FF_script]] (see \ref index). No internal data member. -class E_F0 :public CodeAlloc - { - public: - static E_F0 *tnull; - struct kless - { - using first_argument_type = Expression; - using second_argument_type = Expression; - using result_type = bool; - bool operator()(const Expression& x, const Expression& y) const{ - //cout << x << " " << y << x->compare(y) << " ::: "; - int r1 = x->compare(y);// , r2 = y->compare(x); - //assert(r1+r2==0); - return r1<0;} }; - typedef map< E_F0 *,int,kless> MapOfE_F0; - - virtual AnyType operator()(Stack) const =0; - virtual bool Empty() const {return this==tnull; } - // virtual E_F0 * destroy(Stack ) const {return 0;} +class E_F0 : public CodeAlloc { + public: + static E_F0 *tnull; + struct kless { + using first_argument_type = Expression; + using second_argument_type = Expression; + using result_type = bool; + bool operator( )(const Expression &x, const Expression &y) const { + // cout << x << " " << y << x->compare(y) << " ::: "; + int r1 = x->compare(y); // , r2 = y->compare(x); + // assert(r1+r2==0); + return r1 < 0; + } + }; + typedef map< E_F0 *, int, kless > MapOfE_F0; + + virtual AnyType operator( )(Stack) const = 0; + virtual bool Empty( ) const { return this == tnull; } + // virtual E_F0 * destroy(Stack ) const {return 0;} // virtual const E_F0 * Parameter(Stack ) const {return this;} - virtual size_t nbitem() const {return 1;} - virtual KN componentNbitem() const { ffassert(0);}; - virtual bool EvaluableWithOutStack() const {return false;} // - virtual bool MeshIndependent() const {return true;} // - virtual bool Zero() const {return false;} // - virtual E_F0 * right_E_F0() const { return 0;} - virtual bool ReadOnly() const { return true;} // the expression do not change the memory - virtual ~E_F0() {} - virtual int compare (const E_F0 *t) const { int r= (t==this) ? 0 : ( ( this > &l,MapOfE_F0 & m, size_t & n) ; // build optimisation - virtual AnyType operator()(Stack stack,AnyType *) const { return operator()(stack);} // call optim code - virtual operator aType () const { assert(0);return 0;} // the type of the expression - virtual ostream & dump(ostream &f) const { f << ' ' << typeid(*this).name() << ' ' << this << ' ' ;return f; } - // for OPTIMIZATION - - int find(const MapOfE_F0 & m) ; - int insert(Expression opt,deque > &l,MapOfE_F0 & m, size_t & n) ; - // ajoute for optimisation to say if a expression in meshindep a exec time - // to solve 0*x // question - // juin 2007 FH - virtual AnyType eval(Stack stack, bool & meshindep ) const - { meshindep=MeshIndependent();return operator()(stack);} - - }; - -inline ostream & operator<<(ostream & f,const E_F0 &e) { if(!e.Empty()) e.dump(f); else f << " --0-- " ;return f;} - -/// <> Specialization of [[E_F0]] where MeshIndependent() always returns false instead of true. - -class E_F0mps : public E_F0 { public: - virtual bool MeshIndependent() const {return false;} // -}; - -class E_F0info : public E_F0 { public: - // not a real expression just to pass information - virtual bool EvaluableWithOutStack() const {return true;} // - virtual bool MeshIndependent() const {return true;} // - virtual AnyType operator()(Stack ) const { - return SetAny(this);} - operator aType () const { return atype();} - - -}; - -class E_F1 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &) const =0;}; -class E_F2 : public CodeAlloc{ public: virtual AnyType operator()(Stack,AnyType &,AnyType &) const =0;}; -class E_FN : public CodeAlloc{ public: virtual AnyType operator()(Stack,size_t N,...) const =0;}; - -// class to play with polymorphisme + virtual size_t nbitem( ) const { return 1; } + virtual KN< size_t > componentNbitem( ) const { ffassert(0); }; + virtual bool EvaluableWithOutStack( ) const { return false; } // + virtual bool MeshIndependent( ) const { return true; } // + virtual bool Zero( ) const { return false; } // + virtual E_F0 *right_E_F0( ) const { return 0; } + virtual bool ReadOnly( ) const { return true; } // the expression do not change the memory + virtual ~E_F0( ) {} + virtual int compare(const E_F0 *t) const { + int r = (t == this) ? 0 : ((this < t) ? -1 : 1); + // cout << "cmp " << typeid(*this).name() << r << endl; + return r; + } // to give a order in instuction + virtual int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n); // build optimisation + virtual AnyType operator( )(Stack stack, AnyType *) const { return operator( )(stack); } // call optim code + virtual operator aType( ) const { + assert(0); + return 0; + } // the type of the expression + virtual ostream &dump(ostream &f) const { + f << ' ' << typeid(*this).name( ) << ' ' << this << ' '; + return f; + } + // for OPTIMIZATION + + int find(const MapOfE_F0 &m); + int insert(Expression opt, deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n); + // ajoute for optimisation to say if a expression in meshindep a exec time + // to solve 0*x // question + // juin 2007 FH + virtual AnyType eval(Stack stack, bool &meshindep) const { + meshindep = MeshIndependent( ); + return operator( )(stack); + } +}; + +inline ostream &operator<<(ostream &f, const E_F0 &e) { + if (!e.Empty( )) + e.dump(f); + else + f << " --0-- "; + return f; +} + +/// <> Specialization of [[E_F0]] where MeshIndependent() always returns false instead of true. + +class E_F0mps : public E_F0 { + public: + virtual bool MeshIndependent( ) const { return false; } // +}; + +class E_F0info : public E_F0 { + public: + // not a real expression just to pass information + virtual bool EvaluableWithOutStack( ) const { return true; } // + virtual bool MeshIndependent( ) const { return true; } // + virtual AnyType operator( )(Stack) const { return SetAny< const E_F0 * >(this); } + operator aType( ) const { return atype< Expression >( ); } +}; + +class E_F1 : public CodeAlloc { + public: + virtual AnyType operator( )(Stack, AnyType &) const = 0; +}; +class E_F2 : public CodeAlloc { + public: + virtual AnyType operator( )(Stack, AnyType &, AnyType &) const = 0; +}; +class E_FN : public CodeAlloc { + public: + virtual AnyType operator( )(Stack, size_t N, ...) const = 0; +}; + +// class to play with polymorphisme // --------------------------------- class basicAC_F0; -class ArrayOfaType : public CodeAlloc{ +class ArrayOfaType : public CodeAlloc { // class for the type of parameter - aType tt[11]; - protected: + aType tt[11]; - int n; - aType * t; // array of type - bool ellipse; - void operator=(const ArrayOfaType &); // no set operator - public: - // ArrayOfaType() :n(0),t(0),ellipse(false) {} - explicit ArrayOfaType(bool ell=false) - :n(0),t(0),ellipse(ell) {} - - explicit ArrayOfaType(const aType & a,bool ell=false) - :n(1),t(tt),ellipse(ell) {t[0]=a;} - - explicit ArrayOfaType(const aType & a,const aType & b,bool ell=false) - :n(2),t(tt),ellipse(ell) {t[0]=a,t[1]=b;} - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,bool ell=false) - :n(3),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;} - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,bool ell=false) - :n(4),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; - /* cout << * a << *b << * c << * d << " ---------" << endl; */} - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,bool ell=false) - :n(5),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; } - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,bool ell=false) - :n(6),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; } - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e, - const aType & f,const aType & g, - bool ell=false) - :n(7),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; } // (6 args) Added by Fabian Dortu - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e, - const aType & f,const aType & g,const aType & h, - bool ell=false) - :n(8),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; } // (7 args) Added by Fabian Dortu - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e, - const aType & f,const aType & g,const aType & h, const aType & i, - bool ell=false) - :n(9),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; } // (8 args) Added by Fabian Dortu - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d, const aType & e, - const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, - bool ell=false) - :n(10),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; } // (10 args) Added by Fabian Dortu - - explicit ArrayOfaType(const aType & a,const aType & b,const aType & c,const aType & d,const aType & e,const aType & f,const aType & g,const aType & h, const aType & i, const aType & j, const aType & k,bool ell=false) - :n(11),t(tt),ellipse(ell) {t[0]=a,t[1]=b;t[2]=c;t[3]=d; t[4]=e; t[5]=f; t[6]=g; t[7]=h; t[8]=i; t[9]=j; t[10]=k; } // (10 args) Added by Fabian Dortu - - - ArrayOfaType(const basicAC_F0 & ) ; - ArrayOfaType(const ArrayOfaType & ); // - ArrayOfaType(const ListOfId * l); - ~ArrayOfaType() { if(t && t != tt) delete [] t;t=0;n=0;} - bool WithOutCast( const ArrayOfaType & a) const ; - bool WithCast( const ArrayOfaType & a,int nbcast=100000) const ; // return the number of cast - // exactly comparaison - bool operator==( const ArrayOfaType & a) const { - if (a.n != n || a.ellipse !=ellipse) return false; - for (int i=0;i> Base class for all language operators. Daughter classes have the same name with several extensions: /// "[1-9]" represent the number of operator arguments, "_" designates operators that take a reference instead of a /// copied argument, "s" designates operators that require a stack argument. -class OneOperator : public ArrayOfaType { - friend class MakeVectSpaceN; - friend class basicForEachType; - const basicForEachType * r; // return type - OneOperator *next; // to make a list of OneOperator - public: - int pref; // to try to solve ambiguity for binary operator - // 10 for bool, 20 for int , 30 for long , 40, for float, 50 double, 60 for complex, 70 string - // string+ 1 => string - // 1+string => string - OneOperator(aType rr) ;// : r(rr),ArrayOfaType(),next(0),pref(0) {throwassert(r);} - OneOperator(aType rr,aType a) ;//: r(rr),ArrayOfaType(a,false),next(0),pref(0) {throwassert(rr && a );} - OneOperator(aType rr,aType a,aType b);// : r(rr),ArrayOfaType(a,b,false),next(0),pref(0) { - // throwassert(rr && a && b);} - OneOperator(aType rr,aType a,aType b,aType c) ; - //: r(rr),ArrayOfaType(a,b,c,false),next(0),pref(0) {throwassert(rr && a && b && c);} - OneOperator(aType rr,aType a,aType b,aType c,aType d) ; - //: r(rr),ArrayOfaType(a,b,c,d,false),next(0),pref(0) {throwassert(rr && a && b && c);} - - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) ; - //: r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} // Added by Fabian Dortu (5 parameters) - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) ; - //: r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f);} // Added by Fabian Dortu (6 parameters) - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g); - // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g);} // Added by Fabian Dortu (7 parameters) - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h); - // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h);} // Added by Fabian Dortu (8 parameters) - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i) ; - //: r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i);} // Added by Fabian Dortu (9 parameters) - OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j); - // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,j,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i && j);} // Added by Fabian Dortu (10 parameters) - - - - OneOperator(aType rr,const ArrayOfaType &ta) ; - //: r(rr),ArrayOfaType(ta),next(0),pref(0) {throwassert(rr);} - OneOperator(aType rr,bool ellipse) ; - //: r(rr),ArrayOfaType(ellipse),next(0),pref(0) {throwassert(rr );} - OneOperator(aType rr,const ListOfId *l) ; - //: r(rr),ArrayOfaType(l),next(0),pref(0) {throwassert(rr );} - - typedef pair pair_find; - void operator+=(OneOperator &a){throwassert(a.next==0);a.next=next;next=&a;} - // a way to make none recurve delete good - virtual ~OneOperator(); - pair_find Find(const ArrayOfaType & at) const ; - pair_find FindWithOutCast(const ArrayOfaType & at) const ; // for - OneOperator * FindSameR(const ArrayOfaType & at) ; - - void Show(const ArrayOfaType & at,ostream &f=cerr) const; - void Show(ostream &f=cerr) const; - operator aType () const { return r;} - - // <> - virtual E_F0 * code(const basicAC_F0 &) const =0; - virtual C_F0 code2(const basicAC_F0 &a) const ; // {return code(code(a),r);} - const OneOperator * Simple() const { return next||n?0:this;} - friend ostream & operator<<(ostream & f,const OneOperator & a); - +class OneOperator : public ArrayOfaType { + friend class MakeVectSpaceN; + friend class basicForEachType; + const basicForEachType *r; // return type + OneOperator *next; // to make a list of OneOperator + public: + int pref; // to try to solve ambiguity for binary operator + // 10 for bool, 20 for int , 30 for long , 40, for float, 50 double, 60 for complex, 70 string + // string+ 1 => string + // 1+string => string + OneOperator(aType rr); // : r(rr),ArrayOfaType(),next(0),pref(0) {throwassert(r);} + OneOperator(aType rr, aType a); //: r(rr),ArrayOfaType(a,false),next(0),pref(0) {throwassert(rr && a );} + OneOperator(aType rr, aType a, aType b); // : r(rr),ArrayOfaType(a,b,false),next(0),pref(0) { + // throwassert(rr && a && b);} + OneOperator(aType rr, aType a, aType b, aType c); + //: r(rr),ArrayOfaType(a,b,c,false),next(0),pref(0) {throwassert(rr && a && b && c);} + OneOperator(aType rr, aType a, aType b, aType c, aType d); + //: r(rr),ArrayOfaType(a,b,c,d,false),next(0),pref(0) {throwassert(rr && a && b && c);} + + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e); + //: r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} // Added by Fabian Dortu (5 parameters) + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f); + //: r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f);} // Added by Fabian Dortu (6 parameters) + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g); + // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g);} // Added by Fabian Dortu (7 parameters) + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h); + // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h);} // Added by Fabian Dortu (8 parameters) + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h, aType i); + //: r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i);} // Added by Fabian Dortu (9 parameters) + OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h, aType i, aType j); + // : r(rr),ArrayOfaType(a,b,c,d,e,f,g,h,i,j,false),next(0),pref(0) {throwassert(rr && a && b && c && d && e && f && g && h && i && j);} // Added by Fabian Dortu (10 parameters) + + OneOperator(aType rr, const ArrayOfaType &ta); + //: r(rr),ArrayOfaType(ta),next(0),pref(0) {throwassert(rr);} + OneOperator(aType rr, bool ellipse); + //: r(rr),ArrayOfaType(ellipse),next(0),pref(0) {throwassert(rr );} + OneOperator(aType rr, const ListOfId *l); + //: r(rr),ArrayOfaType(l),next(0),pref(0) {throwassert(rr );} + + typedef pair< const OneOperator *, int > pair_find; + void operator+=(OneOperator &a) { + throwassert(a.next == 0); + a.next = next; + next = &a; + } + // a way to make none recurve delete good + virtual ~OneOperator( ); + pair_find Find(const ArrayOfaType &at) const; + pair_find FindWithOutCast(const ArrayOfaType &at) const; // for + OneOperator *FindSameR(const ArrayOfaType &at); + + void Show(const ArrayOfaType &at, ostream &f = cerr) const; + void Show(ostream &f = cerr) const; + operator aType( ) const { return r; } + + // <> + virtual E_F0 *code(const basicAC_F0 &) const = 0; + virtual C_F0 code2(const basicAC_F0 &a) const; // {return code(code(a),r);} + const OneOperator *Simple( ) const { return next || n ? 0 : this; } + friend ostream &operator<<(ostream &f, const OneOperator &a); }; /// <> -class Polymorphic: - public E_F0mps // [[E_F0mps]] +class Polymorphic : public E_F0mps // [[E_F0mps]] { - // a list of type - // simple, array or function -private: - typedef const char * Key; - typedef OneOperator * Value; - // struct Keyless : binary_function - // { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} }; - - typedef map maptype; // - typedef maptype::const_iterator const_iterator; // - typedef maptype::iterator iterator; // - // remark the map is mutable because - // a expression is const E_F0 * - // So There is a incompatibility between - // we save an expression in a variable - // we have to add thing to a polymorphisme expression - mutable maptype m; // all polymorphisme of the Identifier - Expression e; // default expression -public: - Polymorphic() : m(),e(0) {} - -// by default Empty and do nothing - virtual AnyType operator()(Stack ) const { return Nothing;} - virtual bool Empty() const {return true;} // by default Empty - void clear() { m.clear();} - const OneOperator * Find(const char *op, const ArrayOfaType &at) const; - const OneOperator * FindWithOutCast(const char *op,const ArrayOfaType &at) const; - void Show(const char *op,const ArrayOfaType & at,ostream &f=cerr)const ; - void Add(const char * op,OneOperator * p0 ,OneOperator * p1=0,OneOperator * p2=0, - OneOperator * p3=0,OneOperator * p4=0,OneOperator * p5=0, - OneOperator * p6=0,OneOperator * p7=0,OneOperator * p8=0, - OneOperator * p9=0,OneOperator * pa=0,OneOperator * pb=0, - OneOperator * pc=0,OneOperator * pd=0,OneOperator * pe=0 - ) const - {Addp(op,p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa,pb,pc,pd,pe,0);} - void Add(const char * op,OneOperator ** pp) const ; -private: - void Addp(const char * op,OneOperator * pp,...) const ; - friend ostream & operator<<(ostream & f,const Polymorphic & a); + // a list of type + // simple, array or function + private: + typedef const char *Key; + typedef OneOperator *Value; + // struct Keyless : binary_function + // { bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} }; + + typedef map< Key, Value, Keyless > maptype; // + typedef maptype::const_iterator const_iterator; // + typedef maptype::iterator iterator; // + // remark the map is mutable because + // a expression is const E_F0 * + // So There is a incompatibility between + // we save an expression in a variable + // we have to add thing to a polymorphisme expression + mutable maptype m; // all polymorphisme of the Identifier + Expression e; // default expression + public: + Polymorphic( ) : m( ), e(0) {} + + // by default Empty and do nothing + virtual AnyType operator( )(Stack) const { return Nothing; } + virtual bool Empty( ) const { return true; } // by default Empty + void clear( ) { m.clear( ); } + const OneOperator *Find(const char *op, const ArrayOfaType &at) const; + const OneOperator *FindWithOutCast(const char *op, const ArrayOfaType &at) const; + void Show(const char *op, const ArrayOfaType &at, ostream &f = cerr) const; + void Add(const char *op, OneOperator *p0, OneOperator *p1 = 0, OneOperator *p2 = 0, OneOperator *p3 = 0, OneOperator *p4 = 0, OneOperator *p5 = 0, OneOperator *p6 = 0, OneOperator *p7 = 0, + OneOperator *p8 = 0, OneOperator *p9 = 0, OneOperator *pa = 0, OneOperator *pb = 0, OneOperator *pc = 0, OneOperator *pd = 0, OneOperator *pe = 0) const { + Addp(op, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pa, pb, pc, pd, pe, 0); + } + void Add(const char *op, OneOperator **pp) const; + + private: + void Addp(const char *op, OneOperator *pp, ...) const; + friend ostream &operator<<(ostream &f, const Polymorphic &a); }; /// <> The type for polymorphisme of id. Contains one [[Expression]] and the type that the expression will return @@ -637,885 +697,893 @@ class Polymorphic: class basicAC_F0; class C_F0 { - friend class CC_F0; // cf [[CC_F0]] -protected: - Expression f; // the expression code, cf [[Expression]] - aType r; // the expression type, cf [[file:../fflib/AnyType.hpp::aType]] - -public: - // the constructeur - C_F0() :f(0),r(0) {} - C_F0(const C_F0 & c):f(c.f),r(c.r) {} - C_F0(const C_F0 & a,const C_F0 & b); // concatenation + friend class CC_F0; // cf [[CC_F0]] + protected: + Expression f; // the expression code, cf [[Expression]] + aType r; // the expression type, cf [[file:../fflib/AnyType.hpp::aType]] + + public: + // the constructeur + C_F0( ) : f(0), r(0) {} + C_F0(const C_F0 &c) : f(c.f), r(c.r) {} + C_F0(const C_F0 &a, const C_F0 &b); // concatenation /// cf [[Type_Expr]] - C_F0(const Type_Expr & a):f(a.second),r(a.first) {} + C_F0(const Type_Expr &a) : f(a.second), r(a.first) {} /// <> [[file:AFunction2.cpp::C_F0_constructor_pop_char_basicAC_F0_impl]] /// cf [[Polymorphic]] - C_F0(const Polymorphic *,const char *,const basicAC_F0 & ); + C_F0(const Polymorphic *, const char *, const basicAC_F0 &); - C_F0(const Polymorphic *,const char *, AC_F0 & ); + C_F0(const Polymorphic *, const char *, AC_F0 &); - // function, array .. - C_F0(const C_F0 & e,const char *op,const basicAC_F0 & p) ; - C_F0(const C_F0 & e,const char *op, AC_F0 & p) ; + // function, array .. + C_F0(const C_F0 &e, const char *op, const basicAC_F0 &p); + C_F0(const C_F0 &e, const char *op, AC_F0 &p); // <> [[C_F0_constructor_char_C_F0_impl]] - C_F0(const C_F0 & e,const char *op,const C_F0 & ee); + C_F0(const C_F0 &e, const char *op, const C_F0 &ee); - C_F0(const C_F0 & e,const char *op,const C_F0 & a,const C_F0 & b) ; - C_F0(const C_F0 & e,const char *nm) ; + C_F0(const C_F0 &e, const char *op, const C_F0 &a, const C_F0 &b); + C_F0(const C_F0 &e, const char *nm); // without parameter ex f(). cf [[Polymorphic]] - C_F0(const Polymorphic * pop,const char *op); + C_F0(const Polymorphic *pop, const char *op); - // unary operator - C_F0(const Polymorphic * pop,const char *op,const C_F0 & a); + // unary operator + C_F0(const Polymorphic *pop, const char *op, const C_F0 &a); // <> binary operator [[file:AFunction2.cpp::C_F0_constructor_binary]] - C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b); + C_F0(const Polymorphic *pop, const char *op, const C_F0 &a, const C_F0 &b); + + // ternary operator + C_F0(const Polymorphic *pop, const char *op, const C_F0 &a, const C_F0 &b, const C_F0 &c); - // ternary operator - C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b,const C_F0 & c); - - C_F0( Expression ff,aType rr ): f(ff),r(rr) { + C_F0(Expression ff, aType rr) : f(ff), r(rr) { // cout << "C_F0: " << * rr << endl;// dec 2007 FH // if (!rr && ff) cerr << "Type Null" << endl; } // operator Expression() const {return f;} - AnyType eval(Stack s) const {return (*f)(s);} - - Expression RightValue() const { return r->RightValueExpr(f);} - Expression LeftValue() const; - - aType left() const {return r;} - aType right() const {return r->right();} - C_F0 RightExp() const { return C_F0(RightValue(),right());} // FH add 07/2005 - operator E_F0 * () const {return f;} - bool Empty() const {return !f || f->Empty();} - bool NotNull() const {return f;} - int TYPEOFID() const { return r ? r->TYPEOFID(): 0;} - int nbitem() const { return f ? f->nbitem() : 0;} - bool EvaluableWithOutStack() const { return f && f->EvaluableWithOutStack();} - bool Zero() const { return !f || f->Zero();} - Expression Destroy() { return r->Destroy(*this);} - - operator const Polymorphic * () const {return dynamic_cast(f);} - bool operator==(const C_F0 & a) const {return f==a.f && r == a.r;} - bool operator!=(const C_F0 & a) const {return f!=a.f || r != a.r;} + AnyType eval(Stack s) const { return (*f)(s); } + + Expression RightValue( ) const { return r->RightValueExpr(f); } + Expression LeftValue( ) const; + + aType left( ) const { return r; } + aType right( ) const { return r->right( ); } + C_F0 RightExp( ) const { return C_F0(RightValue( ), right( )); } // FH add 07/2005 + operator E_F0 *( ) const { return f; } + bool Empty( ) const { return !f || f->Empty( ); } + bool NotNull( ) const { return f; } + int TYPEOFID( ) const { return r ? r->TYPEOFID( ) : 0; } + int nbitem( ) const { return f ? f->nbitem( ) : 0; } + bool EvaluableWithOutStack( ) const { return f && f->EvaluableWithOutStack( ); } + bool Zero( ) const { return !f || f->Zero( ); } + Expression Destroy( ) { return r->Destroy(*this); } + + operator const Polymorphic *( ) const { return dynamic_cast< const Polymorphic * >(f); } + bool operator==(const C_F0 &a) const { return f == a.f && r == a.r; } + bool operator!=(const C_F0 &a) const { return f != a.f || r != a.r; } // Type_Expr SetParam(const ListOfId * l,size_t & top) const ; - bool MeshIndependent() const { return f ? f->MeshIndependent() : false;} - C_F0 OnReturn() { f=r->OnReturn(f); return *this; } // Add mai 2009 (for return statment. -private: - friend class Block; - friend class TableOfIdentifier; - C_F0( Expression ff ): f(ff),r(0) {} + bool MeshIndependent( ) const { return f ? f->MeshIndependent( ) : false; } + C_F0 OnReturn( ) { + f = r->OnReturn(f); + return *this; + } // Add mai 2009 (for return statment. + private: + friend class Block; + friend class TableOfIdentifier; + C_F0(Expression ff) : f(ff), r(0) {} }; - - // for bison [[CListOfInst]] class CListOfInst; - // a => b - // f => t||f - // t => t - // (a =>b) <=> (!a || b ) - +// a => b +// f => t||f +// t => t +// (a =>b) <=> (!a || b ) + // warning ------------------ -class ForTypeVoid: public basicForEachType{public: - ForTypeVoid():basicForEachType(typeid(void),0,0,0,0,0) {} +class ForTypeVoid : public basicForEachType { + public: + ForTypeVoid( ) : basicForEachType(typeid(void), 0, 0, 0, 0, 0) {} }; -template -class ForEachType: public basicForEachType{public: - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id,OOnReturn) { - if (sizeof(T) > sizeof(AnyTypeWithOutCheck) ) - { - cout << " Sorry the " < " << sizeof(AnyTypeWithOutCheck) << " ) " << endl; - throwassert(sizeof(T) <= sizeof(AnyTypeWithOutCheck) ); - } +template< class T > +class ForEachType : public basicForEachType { + public: + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(T), sizeof(T), 0, 0, iv, id, OOnReturn) { + if (sizeof(T) > sizeof(AnyTypeWithOutCheck)) { + cout << " Sorry the " << typeid(T).name( ) << " is too large ( " << sizeof(T) << " > " << sizeof(AnyTypeWithOutCheck) << " ) " << endl; + throwassert(sizeof(T) <= sizeof(AnyTypeWithOutCheck)); } + } }; -template -class ForEachType: public basicForEachType{public:// coorection july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(T),sizeof(T),0,0,iv,id,OOnReturn) { - //T i= 0.0; - } +template< class T > +class ForEachType< T * > : public basicForEachType { + public: // coorection july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(T), sizeof(T), 0, 0, iv, id, OOnReturn) { + // T i= 0.0; + } }; -template AnyType UnRef(Stack,const AnyType &a) ; -template AnyType Initialize(Stack,const AnyType &a) ; -template AnyType Destroy(Stack,const AnyType &a) ; +template< class A, class B > +AnyType UnRef(Stack, const AnyType &a); +template< class A > +AnyType Initialize(Stack, const AnyType &a); +template< class A > +AnyType Destroy(Stack, const AnyType &a); -// the type of variable is pointer because we need to write in -template -class ForEachTypePtr: public basicForEachType { public: - ForEachTypePtr(); - ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn=0); - ForEachTypePtr(Function1 dl); +// the type of variable is pointer because we need to write in +template< class T, class PT = T * > +class ForEachTypePtr : public basicForEachType { + public: + ForEachTypePtr( ); + ForEachTypePtr(Function1 init, Function1 dl, Function1 onreturn = 0); + ForEachTypePtr(Function1 dl); }; -template -class ForEachTypePtr: public basicForEachType { public: - ForEachTypePtr(T* bb=0,Function1 onreturn=0); - ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn=0); - ForEachTypePtr(Function1 dl); +template< class T > +class ForEachTypePtr< T *, T ** > : public basicForEachType { + public: + ForEachTypePtr(T *bb = 0, Function1 onreturn = 0); + ForEachTypePtr(Function1 init, Function1 dl, Function1 onreturn = 0); + ForEachTypePtr(Function1 dl); }; - -template -class ForEachTypePtrfspace: public ForEachTypePtr { public: - ForEachTypePtrfspace():ForEachTypePtr() {} - int TYPEOFID() const {return RTYPE;} +template< class T, int RTYPE > +class ForEachTypePtrfspace : public ForEachTypePtr< T > { + public: + ForEachTypePtrfspace( ) : ForEachTypePtr< T >( ) {} + int TYPEOFID( ) const { return RTYPE; } }; - -class ForTypeAnyType: public basicForEachType{public: - ForTypeAnyType(): basicForEachType(typeid(AnyType),sizeof(AnyType)) {} - bool CastingFrom(const basicForEachType * ) const {return true;} - C_F0 CastTo(const C_F0 & e) const {return e;} +class ForTypeAnyType : public basicForEachType { + public: + ForTypeAnyType( ) : basicForEachType(typeid(AnyType), sizeof(AnyType)) {} + bool CastingFrom(const basicForEachType *) const { return true; } + C_F0 CastTo(const C_F0 &e) const { return e; } }; +// for cast and get value associed to a pointer -// for cast and get value associed to a pointer +template< class A, class B > +AnyType Cast(Stack, const AnyType &b) { + return SetAny< A >(static_cast< A >(GetAny< B >(b))); +} - -template - AnyType Cast(Stack,const AnyType &b) { - return SetAny(static_cast(GetAny(b)));} - -template - AnyType FCast(Stack s,const AnyType &b) { - return SetAny(Add2StackOfPtr2Free(s,F(GetAny(b))));} - -template - AnyType UnRef(Stack,const AnyType &a) { - return SetAny(*PGetAny(a));} +template< class A, class B, A F(const B &) > +AnyType FCast(Stack s, const AnyType &b) { + return SetAny< A >(Add2StackOfPtr2Free(s, F(GetAny< B >(b)))); +} -template - AnyType UnRef(Stack,const AnyType &a) { - return SetAny(*GetAny(a));} - - -template - AnyType UnRefCopyPtr(Stack s,const AnyType &a) { - A ** ppa=PGetAny(a); - A * pc = *ppa ? new A(**ppa) : nullptr; - return SetPtrAny(Add2StackOfPtr2Free(s,pc)) ;} - - -template AnyType Initialize(Stack,const AnyType &x){ - A * a=PGetAny(x); - A *b=new A;// - memcpy(a,b,sizeof(A));// bitcopy - ::operator delete(b); // delete with no destruction - return SetPtrAny(a); +template< class A > +AnyType UnRef(Stack, const AnyType &a) { + return SetAny< A >(*PGetAny< A >(a)); } -template AnyType InitializePtr(Stack stack,const AnyType &x){ - A * a=PGetAny(x); - SHOWVERB( cout << " init ptr " << typeid(A*).name() << (char *) a - (char*) stack<< endl); - *a=0; - return x; +template< class A, class B > +AnyType UnRef(Stack, const AnyType &a) { + return SetAny< A >(*GetAny< B >(a)); } -template AnyType InitializeDef(Stack stack,const AnyType &x){ - A * a=PGetAny(x); - SHOWVERB( cout << " init ptr " << typeid(A*).name() << (char *) a - (char*) stack<< endl); - *a=A(); - return x; +template< class A > +AnyType UnRefCopyPtr(Stack s, const AnyType &a) { + A **ppa = PGetAny< A * >(a); + A *pc = *ppa ? new A(**ppa) : nullptr; + return SetPtrAny(Add2StackOfPtr2Free(s, pc)); } +template< class A > +AnyType Initialize(Stack, const AnyType &x) { + A *a = PGetAny< A >(x); + A *b = new A; // + memcpy(a, b, sizeof(A)); // bitcopy + ::operator delete(b); // delete with no destruction + return SetPtrAny(a); +} -template inline AnyType Delete(Stack,const AnyType &x){ - A * a=PGetAny(x); - SHOWVERB(cout << "DESTROY " < +AnyType InitializePtr(Stack stack, const AnyType &x) { + A *a = PGetAny< A >(x); + SHOWVERB(cout << " init ptr " << typeid(A *).name( ) << (char *)a - (char *)stack << endl); + *a = 0; + return x; } -template inline AnyType Destroy(Stack,const AnyType &x){ - A * a=PGetAny(x); - SHOWVERB(cout << "DESTROY " <destroy(); - return Nothing; +template< class A > +AnyType InitializeDef(Stack stack, const AnyType &x) { + A *a = PGetAny< A >(x); + SHOWVERB(cout << " init ptr " << typeid(A *).name( ) << (char *)a - (char *)stack << endl); + *a = A( ); + return x; } -template inline AnyType DestroyS(Stack,const AnyType &x){ - A a=GetAny(x); - SHOWVERB(cout << "DESTROY " < +inline AnyType Delete(Stack, const AnyType &x) { + A *a = PGetAny< A >(x); + SHOWVERB(cout << "DESTROY " << typeid(A).name( ) << " " << a << endl); + (*a).~A( ); + return Nothing; } -template inline AnyType InitS(Stack,const AnyType &x){ - A a=GetAny(x); - SHOWVERB(cout << "InitS " < +inline AnyType Destroy(Stack, const AnyType &x) { + A *a = PGetAny< A >(x); + SHOWVERB(cout << "DESTROY " << typeid(A).name( ) << " " << a << endl); + a->destroy( ); + return Nothing; } -template inline AnyType InitP(Stack,const AnyType &x){ - A *a=PGetAny(x); - SHOWVERB(cout << "InitP " <init(); - return Nothing; + +template< class A > +inline AnyType DestroyS(Stack, const AnyType &x) { + A a = GetAny< A >(x); + SHOWVERB(cout << "DESTROY " << typeid(A).name( ) << " " << a << endl); + a.destroy( ); + return Nothing; } +template< class A > +inline AnyType InitS(Stack, const AnyType &x) { + A a = GetAny< A >(x); + SHOWVERB(cout << "InitS " << typeid(A).name( ) << " " << a << endl); + a.init( ); + return Nothing; +} +template< class A > +inline AnyType InitP(Stack, const AnyType &x) { + A *a = PGetAny< A >(x); + SHOWVERB(cout << "InitP " << typeid(A).name( ) << " " << a << endl); + a->init( ); + return Nothing; +} -template inline AnyType DestroyPtr(Stack,const AnyType &x) { - const A * a=PGetAny(x); - SHOWVERB(cout << "DestroyPtr " << typeid(A).name() << *a << endl); - (*a)->destroy(); - // delete *a; +template< class A > +inline AnyType DestroyPtr(Stack, const AnyType &x) { + const A *a = PGetAny< A >(x); + SHOWVERB(cout << "DestroyPtr " << typeid(A).name( ) << *a << endl); + (*a)->destroy( ); + // delete *a; - return Nothing; + return Nothing; }; -template inline AnyType DeletePtr(Stack,const AnyType &x) { - const A * a=PGetAny(x); - SHOWVERB( cout << "DeletePtr " << typeid(A).name() << *a << endl); - // (*a)->destroy(); - delete *a; +template< class A > +inline AnyType DeletePtr(Stack, const AnyType &x) { + const A *a = PGetAny< A >(x); + SHOWVERB(cout << "DeletePtr " << typeid(A).name( ) << *a << endl); + // (*a)->destroy(); + delete *a; - return Nothing; -}; - -template<> AnyType inline DestroyPtr(Stack,const AnyType &x) { - string ** a=PGetAny(x); - SHOWVERB( cout << "DestroyPtr " << typeid(string*).name() << *a << endl); - freestring(*a); - return Nothing; + return Nothing; }; +template<> +AnyType inline DestroyPtr< string * >(Stack, const AnyType &x) { + string **a = PGetAny< string * >(x); + SHOWVERB(cout << "DestroyPtr " << typeid(string *).name( ) << *a << endl); + freestring(*a); + return Nothing; +}; - -template AnyType Initialize(Stack,const AnyType &x,const AnyType &y){ - A * a=PGetAny(x); - A *b=new A(GetAny(x));// - memcpy(a,b,sizeof(A));// bitcopy - ::operator delete(b); // delete with no destruction - return PtrtoAny(a); +template< class A > +AnyType Initialize(Stack, const AnyType &x, const AnyType &y) { + A *a = PGetAny< A >(x); + A *b = new A(GetAny< A >(x)); // + memcpy(a, b, sizeof(A)); // bitcopy + ::operator delete(b); // delete with no destruction + return PtrtoAny(a); } - - - -class E_F0_CFunc2 :public E_F0mps { public: - CFunction2 f2; - E_F0 *a,*b; - AnyType operator()(Stack s) const {return f2(s,a,b);} - E_F0_CFunc2( CFunction2 ff,E_F0 *aa,E_F0 *bb) : f2(ff),a(aa),b(bb){} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack() && b->EvaluableWithOutStack();} // - operator aType () const { return atype();} +class E_F0_CFunc2 : public E_F0mps { + public: + CFunction2 f2; + E_F0 *a, *b; + AnyType operator( )(Stack s) const { return f2(s, a, b); } + E_F0_CFunc2(CFunction2 ff, E_F0 *aa, E_F0 *bb) : f2(ff), a(aa), b(bb) {} + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ) && b->EvaluableWithOutStack( ); } // + operator aType( ) const { return atype< void >( ); } }; -class E_F0_CFunc4 :public E_F0mps { public: - CFunction4 f4; - E_F0 *a,*b,*c,*d; - AnyType operator()(Stack s) const {return f4(s,a,b,c,d);} - E_F0_CFunc4( CFunction4 ff,E_F0 *aa,E_F0 *bb,E_F0 *cc,E_F0 *dd) - : f4(ff),a(aa),b(bb),c(cc),d(dd){} - operator aType () const { return atype();} - +class E_F0_CFunc4 : public E_F0mps { + public: + CFunction4 f4; + E_F0 *a, *b, *c, *d; + AnyType operator( )(Stack s) const { return f4(s, a, b, c, d); } + E_F0_CFunc4(CFunction4 ff, E_F0 *aa, E_F0 *bb, E_F0 *cc, E_F0 *dd) : f4(ff), a(aa), b(bb), c(cc), d(dd) {} + operator aType( ) const { return atype< void >( ); } }; - - -template - class E_F1_F :public E_F1 { public: - typedef R (*func)(A) ; +template< class R, class A > +class E_F1_F : public E_F1 { + public: + typedef R (*func)(A); func f; E_F1_F(func ff) : f(ff) {} - AnyType operator()(Stack s,AnyType & a) const - {return SetAny(f(GetAny(a)));} + AnyType operator( )(Stack s, AnyType &a) const { return SetAny< R >(f(GetAny< A >(a))); } }; -template - class E_F2_F :public E_F2 { public: - typedef R (*func)(const A0 &,const A1&) ; +template< class R, class A0, class A1 > +class E_F2_F : public E_F2 { + public: + typedef R (*func)(const A0 &, const A1 &); func f; E_F2_F(func ff) : f(ff) {} - AnyType operator()(Stack s,AnyType & a0,AnyType & a1) const - {return SetAny(f(GetAny(a0),GetAny(a1)));} -}; - -template - class E_F_F0 :public E_F0 { public: - template struct remove_reference {typedef T type;}; -// template struct remove_reference {typedef T type;}; - template struct remove_reference {typedef T type;}; - typedef typename remove_reference::type A0; - - - typedef R (*func)( TA0 ) ; + AnyType operator( )(Stack s, AnyType &a0, AnyType &a1) const { return SetAny< R >(f(GetAny< A0 >(a0), GetAny< A1 >(a1))); } +}; + +template< class R, class TA0, bool RO = true > +class E_F_F0 : public E_F0 { + public: + template< class T > + struct remove_reference { + typedef T type; + }; + // template struct remove_reference {typedef T type;}; + template< class T > + struct remove_reference< const T & > { + typedef T type; + }; + typedef typename remove_reference< TA0 >::type A0; + + typedef R (*func)(TA0); func f; Expression a; - E_F_F0(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const - {return SetAny(f(GetAny( (*a)(s) )));} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack();} // - bool MeshIndependent() const {return a->MeshIndependent();} // - bool ReadOnly() const { return RO ;} - int compare (const E_F0 *t) const { - int rr; + E_F_F0(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a)(s)))); } + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // + bool ReadOnly( ) const { return RO; } + int compare(const E_F0 *t) const { + int rr; // cout << "cmp " << typeid(*this).name() << " and " << typeid(t).name() << endl; - const E_F_F0* tt=dynamic_cast(t); - if (tt && f == tt->f) rr = a->compare(tt->a); - else rr = E_F0::compare(t); - return rr; - } // to give a order in instuction - - int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) ; - virtual ostream & dump(ostream &ff) const { ff << typeid(*this).name() <<" f= " << f << " a= "<< *a << ' ' ;return ff; } - + const E_F_F0 *tt = dynamic_cast< const E_F_F0 * >(t); + if (tt && f == tt->f) + rr = a->compare(tt->a); + else + rr = E_F0::compare(t); + return rr; + } // to give a order in instuction + + int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n); + virtual ostream &dump(ostream &ff) const { + ff << typeid(*this).name( ) << " f= " << f << " a= " << *a << ' '; + return ff; + } }; -// modif for xlc++ FH -template -class E_F_F0_Opt: public E_F_F0 { public : - size_t ia; - E_F_F0_Opt(const E_F_F0 &t,size_t iaa) - : E_F_F0(t) , ia(iaa) {assert(iaa<2000000 && iaa >0);} - AnyType operator()(Stack s) const - { +// modif for xlc++ FH +template< class R, class TA0, bool RO = true > +class E_F_F0_Opt : public E_F_F0< R, TA0, RO > { + public: + size_t ia; + E_F_F0_Opt(const E_F_F0< R, TA0, RO > &t, size_t iaa) : E_F_F0< R, TA0, RO >(t), ia(iaa) { assert(iaa < 2000000 && iaa > 0); } + AnyType operator( )(Stack s) const { // A0 x = *static_cast(static_cast(static_cast(s)+ia)); - // cout << " opt f (" << x << " ) = " << ": " << ia << endl; - return SetAny( this->f( *static_cast::A0 *>(static_cast(static_cast(s)+ia)) ) );} - -}; - -template - int E_F_F0::Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { - int rr = find(m); - if (rr) return rr; - return insert(new E_F_F0_Opt(*this,a->Optimize(l,m,n)),l,m,n); - } -// fin modif xlc++ - -template - class E_VF_F0 :public E_F0 { public: - typedef void (*func)( A0 ) ; + // cout << " opt f (" << x << " ) = " << ": " << ia << endl; + return SetAny< R >(this->f(*static_cast< typename E_F_F0< R, TA0 >::A0 * >(static_cast< void * >(static_cast< char * >(s) + ia)))); + } +}; + +template< class R, class TA0, bool RO > +int E_F_F0< R, TA0, RO >::Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { + int rr = find(m); + if (rr) return rr; + return insert(new E_F_F0_Opt< R, TA0, RO >(*this, a->Optimize(l, m, n)), l, m, n); +} +// fin modif xlc++ + +template< class A0 > +class E_VF_F0 : public E_F0 { + public: + typedef void (*func)(A0); func f; Expression a; - E_VF_F0(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const - {f(GetAny( (*a)(s) ));return Nothing;} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack();} // - - bool MeshIndependent() const { return a->MeshIndependent(); } - -}; - -inline int clexico(int i,int j) { return i==0 ? j : i;} -inline int clexico(int i,int j,int k) { int ll=clexico(i,j); return ll==0 ? k : ll;} - -template - class E_F_F0F0 :public E_F0 { public: - template struct remove_reference {typedef T type;}; - template struct remove_reference {typedef T type;}; - typedef typename remove_reference::type A0; - typedef typename remove_reference::type A1; - typedef R (*func)( A0 , A1 ) ; - + E_VF_F0(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { + f(GetAny< A0 >((*a)(s))); + return Nothing; + } + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + + bool MeshIndependent( ) const { return a->MeshIndependent( ); } +}; + +inline int clexico(int i, int j) { return i == 0 ? j : i; } +inline int clexico(int i, int j, int k) { + int ll = clexico(i, j); + return ll == 0 ? k : ll; +} + +template< class R, class TA0, class TA1 > +class E_F_F0F0 : public E_F0 { + public: + template< class T > + struct remove_reference { + typedef T type; + }; + template< class T > + struct remove_reference< T & > { + typedef T type; + }; + typedef typename remove_reference< TA0 >::type A0; + typedef typename remove_reference< TA1 >::type A1; + typedef R (*func)(A0, A1); + func f; - Expression a0,a1; - E_F_F0F0(func ff,Expression aa0,Expression aa1) - : f(ff),a0(aa0),a1(aa1) {} - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)) , GetAny((*a1)(s)) ) );} - bool EvaluableWithOutStack() const - {return a0->EvaluableWithOutStack() && a1->EvaluableWithOutStack();} // - bool MeshIndependent() const - {return a0->MeshIndependent() && a1->MeshIndependent();} // - int compare (const E_F0 *t) const { - int rr; + Expression a0, a1; + E_F_F0F0(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)))); } + bool EvaluableWithOutStack( ) const { return a0->EvaluableWithOutStack( ) && a1->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ); } // + int compare(const E_F0 *t) const { + int rr; // cout << "cmp " << typeid(*this).name() << " and " << typeid(t).name() << endl; - const E_F_F0F0* tt=dynamic_cast(t); - if (tt && f == tt->f) rr= clexico(a0->compare(tt->a0),a1->compare(tt->a1)); - else rr = E_F0::compare(t); - return rr; - } // to give a order in instuction - - int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) ; - + const E_F_F0F0 *tt = dynamic_cast< const E_F_F0F0 * >(t); + if (tt && f == tt->f) + rr = clexico(a0->compare(tt->a0), a1->compare(tt->a1)); + else + rr = E_F0::compare(t); + return rr; + } // to give a order in instuction + + int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n); }; // modif for xlc++ -template -class E_F_F0F0_Opt: public E_F_F0F0 { public : - size_t ia,ib; - E_F_F0F0_Opt(const E_F_F0F0 &t,size_t iaa,size_t ibb) - : E_F_F0F0(t) , - ia(iaa),ib(ibb) {} - AnyType operator()(Stack s) const - { - //A0 aa =*static_cast(static_cast(static_cast(s)+ia)); - //A1 bb=*static_cast(static_cast(static_cast(s)+ib)) ; - //cout << ia << " " << ib << "f( " << aa << "," << bb << " ) = "<< f(aa,bb) << endl; - return SetAny( this->f( *static_cast::A0 *>(static_cast(static_cast(s)+ia)) , - *static_cast::A1 *>(static_cast(static_cast(s)+ib)) ) );} - -}; - - -template - int E_F_F0F0::Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { - - int rr = find(m); - if (rr) return rr; - - return insert(new E_F_F0F0_Opt(*this,a0->Optimize(l,m,n),a1->Optimize(l,m,n)),l,m,n); - } -// add modif for xlc++ +template< class R, class TA0, class TA1 > +class E_F_F0F0_Opt : public E_F_F0F0< R, TA0, TA1 > { + public: + size_t ia, ib; + E_F_F0F0_Opt(const E_F_F0F0< R, TA0, TA1 > &t, size_t iaa, size_t ibb) : E_F_F0F0< R, TA0, TA1 >(t), ia(iaa), ib(ibb) {} + AnyType operator( )(Stack s) const { + // A0 aa =*static_cast(static_cast(static_cast(s)+ia)); + // A1 bb=*static_cast(static_cast(static_cast(s)+ib)) ; + // cout << ia << " " << ib << "f( " << aa << "," << bb << " ) = "<< f(aa,bb) << endl; + return SetAny< R >(this->f(*static_cast< typename E_F_F0F0< R, TA0, TA1 >::A0 * >(static_cast< void * >(static_cast< char * >(s) + ia)), + *static_cast< typename E_F_F0F0< R, TA0, TA1 >::A1 * >(static_cast< void * >(static_cast< char * >(s) + ib)))); + } +}; +template< class R, class TA0, class TA1 > +int E_F_F0F0< R, TA0, TA1 >::Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { + int rr = find(m); + if (rr) return rr; -template - class E_F_F0_ :public E_F0 { public: - typedef R (*func)(const A0& ) ; + return insert(new E_F_F0F0_Opt< R, TA0, TA1 >(*this, a0->Optimize(l, m, n), a1->Optimize(l, m, n)), l, m, n); +} +// add modif for xlc++ + +template< class R, class A0 > +class E_F_F0_ : public E_F0 { + public: + typedef R (*func)(const A0 &); func f; Expression a; - E_F_F0_(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const - {return SetAny(f(GetAny( (*a)(s) )));} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack() ;} // - bool MeshIndependent() const - {return a->MeshIndependent();} // - -}; -// add FH 07/2008 for pmesh clean -template -class E_F_F0_Add2RC :public E_F0 { public: - typedef R (*func)(const A0& ) ; - func f; - Expression a; - E_F_F0_Add2RC(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const - {return SetAny(Add2StackOfPtr2FreeRC(s,f(GetAny( (*a)(s) ))));} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack() ;} // - bool MeshIndependent() const - {return a->MeshIndependent();} // - -}; -// end add. -template - class E_F_F0s_ :public E { public: - typedef R (*func)(Stack stack,const A0& ) ; + E_F_F0_(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a)(s)))); } + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // +}; +// add FH 07/2008 for pmesh clean +template< class R, class A0 > +class E_F_F0_Add2RC : public E_F0 { + public: + typedef R (*func)(const A0 &); + func f; + Expression a; + E_F_F0_Add2RC(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { return SetAny< R >(Add2StackOfPtr2FreeRC(s, f(GetAny< A0 >((*a)(s))))); } + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // +}; +// end add. +template< class R, class A0, class E = E_F0 > +class E_F_F0s_ : public E { + public: + typedef R (*func)(Stack stack, const A0 &); func f; Expression a; - E_F_F0s_(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const - {return SetAny(f(s,GetAny( (*a)(s) )));} -// bool MeshIndependent() const {return true;} // def in E + E_F_F0s_(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(s, GetAny< A0 >((*a)(s)))); } + // bool MeshIndependent() const {return true;} // def in E - operator aType () const { return atype();} - + operator aType( ) const { return atype< R >( ); } }; -template - class E_F_F0F0_ :public E { public: - typedef R (*func)(const A0 &,const A1 & ) ; +template< class R, class A0, class A1, class E = E_F0 > +class E_F_F0F0_ : public E { + public: + typedef R (*func)(const A0 &, const A1 &); func f; - Expression a0,a1; - E_F_F0F0_(func ff,Expression aa0,Expression aa1) - : f(ff),a0(aa0),a1(aa1) {} - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)) , GetAny((*a1)(s)) ) );} - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent();} // - -}; -// FH Add 07/2008 -// class with add 1 to the refcounter for mesh . -template -class E_F_F0F0_Add2RC :public E { public: -typedef R (*func)(const A0 &,const A1 & ) ; -func f; -Expression a0,a1; -E_F_F0F0_Add2RC(func ff,Expression aa0,Expression aa1) -: f(ff),a0(aa0),a1(aa1) {} -AnyType operator()(Stack s) const -{return SetAny(Add2StackOfPtr2FreeRC(s, f( GetAny((*a0)(s)) , GetAny((*a1)(s)) ) ));} -bool MeshIndependent() const -{return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent();} // - -}; -// FH end 07/2008 -template - class E_F_F0F0F0_ :public E { public: - typedef R (*func)(const A0 &,const A1 & , const A2 &) ; + Expression a0, a1; + E_F_F0F0_(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)))); } + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ); } // +}; +// FH Add 07/2008 +// class with add 1 to the refcounter for mesh . +template< class R, class A0, class A1, class E = E_F0 > +class E_F_F0F0_Add2RC : public E { + public: + typedef R (*func)(const A0 &, const A1 &); func f; - Expression a0,a1,a2; - E_F_F0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2) - : f(ff),a0(aa0),a1(aa1),a2(aa2) {} - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)) , GetAny((*a1)(s)),GetAny((*a2)(s)) ) );} - virtual size_t nbitem() const {return a2->nbitem(); } - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent();} // - + Expression a0, a1; + E_F_F0F0_Add2RC(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} + AnyType operator( )(Stack s) const { return SetAny< R >(Add2StackOfPtr2FreeRC(s, f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s))))); } + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ); } // +}; +// FH end 07/2008 +template< class R, class A0, class A1, class A2, class E = E_F0 > +class E_F_F0F0F0_ : public E { + public: + typedef R (*func)(const A0 &, const A1 &, const A2 &); + func f; + Expression a0, a1, a2; + E_F_F0F0F0_(func ff, Expression aa0, Expression aa1, Expression aa2) : f(ff), a0(aa0), a1(aa1), a2(aa2) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)))); } + virtual size_t nbitem( ) const { return a2->nbitem( ); } + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ); } // }; -template - class E_F_stackF0F0F0_ :public E_F0mps { public: - typedef R (*func)(Stack, const A0 &,const A1 & , const A2 &) ; - func f; - Expression a0,a1,a2; - E_F_stackF0F0F0_(func ff,Expression aa0,Expression aa1,Expression aa2) - : f(ff),a0(aa0),a1(aa1),a2(aa2) {} - AnyType operator()(Stack s) const - {return SetAny( f(s, GetAny((*a0)(s)) , GetAny((*a1)(s)),GetAny((*a2)(s)) ) );} - virtual size_t nbitem() const {return a2->nbitem(); } - bool MeshIndependent() const { return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent();} -}; - -template - class E_F_F0F0_NC :public E_F0 { public: - typedef R (*func)( A0 &,const A1 & ) ; +template< class R, class A0, class A1, class A2, class E = E_F0 > +class E_F_stackF0F0F0_ : public E_F0mps { + public: + typedef R (*func)(Stack, const A0 &, const A1 &, const A2 &); func f; - Expression a0,a1; - E_F_F0F0_NC(func ff,Expression aa0,Expression aa1) - : f(ff),a0(aa0),a1(aa1) {} - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)) , GetAny((*a1)(s)) ) );} - bool MeshIndependent() const - {return a0->MeshIndependent() && a1->MeshIndependent() ; } // - + Expression a0, a1, a2; + E_F_stackF0F0F0_(func ff, Expression aa0, Expression aa1, Expression aa2) : f(ff), a0(aa0), a1(aa1), a2(aa2) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)))); } + virtual size_t nbitem( ) const { return a2->nbitem( ); } + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ); } }; - - - - class E_F_StackF0F0 :public E_F0mps { public: - typedef AnyType (*func)(Stack,Expression ,Expression ) ; +template< class R, class A0, class A1 > +class E_F_F0F0_NC : public E_F0 { + public: + typedef R (*func)(A0 &, const A1 &); func f; - Expression a0,a1; - E_F_StackF0F0(func ff,Expression aa0,Expression aa1) - : f(ff),a0(aa0),a1(aa1) { } - AnyType operator()(Stack s) const - {return (*f)(s, a0 , a1) ;} - + Expression a0, a1; + E_F_F0F0_NC(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)))); } + bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ); } // }; +class E_F_StackF0F0 : public E_F0mps { + public: + typedef AnyType (*func)(Stack, Expression, Expression); + func f; + Expression a0, a1; + E_F_StackF0F0(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} + AnyType operator( )(Stack s) const { return (*f)(s, a0, a1); } +}; /* class E_F_F0F0_ :public E_F0 { public: - typedef AnyType (*func)(const AnyType &,const AnyType & ) ; + typedef AnyType (*func)(const AnyType &,const AnyType & ) ; func f; Expression a0,a1; - E_F_F0F0_(func ff,Expression aa0,Expression aa1) + E_F_F0F0_(func ff,Expression aa0,Expression aa1) : f(ff),a0(aa0),a1(aa1) {} - AnyType operator()(Stack s) const - {return f( (*a0)(s) , (*a1)(s) );} - bool MeshIndependent() const - {return a0->MeshIndependent() && a1->MeshIndependent() ; } // + AnyType operator()(Stack s) const + {return f( (*a0)(s) , (*a1)(s) );} + bool MeshIndependent() const + {return a0->MeshIndependent() && a1->MeshIndependent() ; } // }; */ -class E_F2_func :public E_F2 { public: - Function2 f; - AnyType operator()(Stack s,AnyType & a,AnyType & b) const {return f(s,a,b);} - E_F2_func( Function2 ff) : f(ff) {} -}; - -class E_F0_Func1 :public E_F0 { public: - Function1 f; - E_F0 *a; - AnyType operator()(Stack s) const {return f(s,(*a)(s));} - E_F0_Func1( Function1 f1,E_F0 *aa) : f(f1),a(aa){} - bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();} // - bool MeshIndependent() const {return a->MeshIndependent();} // - int compare (const E_F0 *t) const { - int rr; - const E_F0_Func1* tt=dynamic_cast(t); - if (tt && f == tt->f) rr = a->compare(tt->a); - else rr = E_F0::compare(t); - return rr; - } // to give a order in instuction - // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation +class E_F2_func : public E_F2 { + public: + Function2 f; + AnyType operator( )(Stack s, AnyType &a, AnyType &b) const { return f(s, a, b); } + E_F2_func(Function2 ff) : f(ff) {} +}; - virtual ostream & dump(ostream &ff) const { ff << "E_F0_Func1 f= " << f << " a= "<< *a << ' ' ;return ff; } +class E_F0_Func1 : public E_F0 { + public: + Function1 f; + E_F0 *a; + AnyType operator( )(Stack s) const { return f(s, (*a)(s)); } + E_F0_Func1(Function1 f1, E_F0 *aa) : f(f1), a(aa) {} + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // + int compare(const E_F0 *t) const { + int rr; + const E_F0_Func1 *tt = dynamic_cast< const E_F0_Func1 * >(t); + if (tt && f == tt->f) + rr = a->compare(tt->a); + else + rr = E_F0::compare(t); + return rr; + } // to give a order in instuction + // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation + virtual ostream &dump(ostream &ff) const { + ff << "E_F0_Func1 f= " << f << " a= " << *a << ' '; + return ff; + } }; -class E_F0_Func2 :public E_F0 { public: - Function2 f; - E_F0 *a,*b; - AnyType operator()(Stack s) const {return f(s,(*a)(s),(*b)(s));} - E_F0_Func2( Function2 f1,E_F0 *aa,E_F0 *bb) : f(f1),a(aa),b(bb){} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack() &&b->EvaluableWithOutStack();} // - bool MeshIndependent() const {return a->MeshIndependent() && b->MeshIndependent();} // - +class E_F0_Func2 : public E_F0 { + public: + Function2 f; + E_F0 *a, *b; + AnyType operator( )(Stack s) const { return f(s, (*a)(s), (*b)(s)); } + E_F0_Func2(Function2 f1, E_F0 *aa, E_F0 *bb) : f(f1), a(aa), b(bb) {} + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ) && b->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ) && b->MeshIndependent( ); } // }; - - // the variable offset / stack (local variable) -template class Value1:public E_F0 - { +template< class R > +class Value1 : public E_F0 { size_t offset; - public: - AnyType operator()(Stack s) const { return SetAny(static_cast(static_cast( static_cast(s)+offset)));} - Value1(size_t o):offset(o) {} + + public: + AnyType operator( )(Stack s) const { return SetAny< R * >(static_cast< R * >(static_cast< void * >(static_cast< char * >(s) + offset))); } + Value1(size_t o) : offset(o) {} }; // the variable globale -template class GValue:public E_F0 - { +template< class R > +class GValue : public E_F0 { mutable R v; - public: - AnyType operator()(Stack ) const { return SetAny(static_cast(static_cast(&v)));} - GValue(R o):v(o) {} - bool EvaluableWithOutStack() const {return true;} // - -}; - -// a constante value -template int ccompare(const R & a,const R& b){ return a==b ? 0 :( a int ccompare(const complex & a,const complex& b){ - int c=ccompare(a.real(),b.real()); - return c==0 ? ccompare(a.imag(),b.imag()): c ;} - -template class EConstant:public E_F0 - { - const R v; - public: - AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny(v);} - EConstant(const R & o):v(o) { /*cout << "New constant " << o << endl;*/} - bool EvaluableWithOutStack() const {return true;} // - operator aType () const { return atype();} - bool Zero()const { return v == R();} - int compare (const E_F0 *t) const { - int rr; - const EConstant * tt=dynamic_cast(t); - if (tt) rr = ccompare(v,tt->v); - else rr = E_F0::compare(t); - return rr; - } - ostream & dump(ostream &f) const { f << " ((" <(static_cast< R * >(static_cast< void * >(&v))); } + GValue(R o) : v(o) {} + bool EvaluableWithOutStack( ) const { return true; } // +}; +// a constante value +template< class R > +int ccompare(const R &a, const R &b) { + return a == b ? 0 : (a < b ? -1 : +1); +} +template< class R > +int ccompare(const complex< R > &a, const complex< R > &b) { + int c = ccompare(a.real( ), b.real( )); + return c == 0 ? ccompare(a.imag( ), b.imag( )) : c; +} +template< class R > +class EConstant : public E_F0 { + const R v; + public: + AnyType operator( )(Stack) const { /*cout << " ()" << v << endl*/ + ; + return SetAny< R >(v); + } + EConstant(const R &o) : v(o) { /*cout << "New constant " << o << endl;*/ } + bool EvaluableWithOutStack( ) const { return true; } // + operator aType( ) const { return atype< R >( ); } + bool Zero( ) const { return v == R( ); } + int compare(const E_F0 *t) const { + int rr; + const EConstant *tt = dynamic_cast< const EConstant * >(t); + if (tt) + rr = ccompare(v, tt->v); + else + rr = E_F0::compare(t); + return rr; + } + ostream &dump(ostream &f) const { + f << " ((" << typeid(R).name( ) << ") " << v << ") "; + return f; + } +}; // the variable offset / stack (local variable) - class LocalVariable:public E_F0 - { - public: +class LocalVariable : public E_F0 { + public: size_t offset; - aType t; // type of the variable just for check - public: - AnyType operator()(Stack s) const { - // SHOWVERB( cout << "\n\tget var " << offset << " " << t->name() << endl); -// return PtrtoAny(static_cast(static_cast(s)+offset),t);} - return PtrtoAny(Stack_offset(s,offset),t);} - - LocalVariable(size_t o,aType tt):offset(o),t(tt) {throwassert(tt); - SHOWVERB(cout << "\n--------new var " << offset << " " << t->name() << endl); - } + aType t; // type of the variable just for check + public: + AnyType operator( )(Stack s) const { + // SHOWVERB( cout << "\n\tget var " << offset << " " << t->name() << endl); + // return PtrtoAny(static_cast(static_cast(s)+offset),t);} + return PtrtoAny(Stack_offset< void >(s, offset), t); + } + + LocalVariable(size_t o, aType tt) : offset(o), t(tt) { + throwassert(tt); + SHOWVERB(cout << "\n--------new var " << offset << " " << t->name( ) << endl); + } }; +class LocalVariableFES : public LocalVariable { + private: + KN< size_t > data; -class LocalVariableFES : public LocalVariable { - private: - KN data; - public: - LocalVariableFES(size_t o,aType tt,const KN & d) - : LocalVariable(o,tt),data(d) {} - size_t nbitem() const { return data.sum();} - KN componentNbitem() const{ return data;} // return the nbitem of each component of a composite FESpace. + public: + LocalVariableFES(size_t o, aType tt, const KN< size_t > &d) : LocalVariable(o, tt), data(d) {} + size_t nbitem( ) const { return data.sum( ); } + KN< size_t > componentNbitem( ) const { return data; } // return the nbitem of each component of a composite FESpace. }; -template -class LocalVariablePlus : public LocalVariable { public: +template< class U > +class LocalVariablePlus : public LocalVariable { + public: U data; - LocalVariablePlus(size_t o,aType tt,const U & d) - : LocalVariable(o,tt),data(d) {} + LocalVariablePlus(size_t o, aType tt, const U &d) : LocalVariable(o, tt), data(d) {} }; -// global variable bof bof -template class PValue:public E_F0 - { - T * p; - public: - AnyType operator()(Stack ) const { return p;} - PValue(T * pp):p(pp) {} -}; +// global variable bof bof +template< class T > +class PValue : public E_F0 { + T *p; + public: + AnyType operator( )(Stack) const { return p; } + PValue(T *pp) : p(pp) {} +}; // global variable bof bof // value througth a pointeur add F.H july 2014 -template class dPValue:public E_F0 -{ - T * p; -public: - AnyType operator()(Stack ) const { return SetAny(*p);} - dPValue(T * pp):p(pp) {} -}; +template< class T > +class dPValue : public E_F0 { + T *p; -template class PPValue:public E_F0 - { - R ** p; - public: - AnyType operator()(Stack ) const { return SetAny(*p);} - PPValue(R ** pp):p(pp) {} + public: + AnyType operator( )(Stack) const { return SetAny< T >(*p); } + dPValue(T *pp) : p(pp) {} }; +template< class R > +class PPValue : public E_F0 { + R **p; + + public: + AnyType operator( )(Stack) const { return SetAny< R * >(*p); } + PPValue(R **pp) : p(pp) {} +}; -template -Type_Expr CPValue(R & v) - { - throwassert(map_type[typeid(R*).name()]); - return make_pair(map_type[typeid(R*).name()],new PValue(&v)); - } +template< class R > +Type_Expr CPValue(R &v) { + throwassert(map_type[typeid(R *).name( )]); + return make_pair(map_type[typeid(R *).name( )], new PValue< R >(&v)); +} -template -Type_Expr dCPValue(R * v) -{ - throwassert(map_type[typeid(R).name()]); - return make_pair(map_type[typeid(R).name()],new dPValue(v)); +template< class R > +Type_Expr dCPValue(R *v) { + throwassert(map_type[typeid(R).name( )]); + return make_pair(map_type[typeid(R).name( )], new dPValue< R >(v)); +} +template< class R > +Type_Expr CPPValue(R *&v) { + throwassert(map_type[typeid(R *).name( )]); + return make_pair(map_type[typeid(R *).name( )], new PPValue< R >(&v)); } -template -Type_Expr CPPValue(R *& v) - { - throwassert(map_type[typeid(R*).name()]); - return make_pair(map_type[typeid(R*).name()],new PPValue(&v)); - } // <> returns [[Type_Expr]] -template -Type_Expr CConstant(const R & v) - { - throwassert(map_type[typeid(R).name()]); - return make_pair(map_type[typeid(R).name()],new EConstant(v)); - } +template< class R > +Type_Expr CConstant(const R &v) { + throwassert(map_type[typeid(R).name( )]); + return make_pair(map_type[typeid(R).name( )], new EConstant< R >(v)); +} /// <>, same as [[C_F0]] but without constructor/destructor to be used in union [[file:../lglib/lg.ypp::YYSTYPE]] class vectorOfInst; class CC_F0 { - Expression f; // [[Expression]] + Expression f; // [[Expression]] aType r; -public: - void operator=(const C_F0& c) { f=c.f;r=c.r;;} - void operator=(const AC_F0& a) ; //{ f=new E_Array(a); f= atype();}; - void operator=(long ) {f=0;r=0;} - void operator=(const CListOfInst& c);//{ C_FO cc=c;f=cc.f;r=cc.r} - operator C_F0 () const {return C_F0(f,r);} - bool Empty() const {return !f || f->Empty();} - aType left() const {return r;} - // operator const C_F0 &() const {return *this;} + + public: + void operator=(const C_F0 &c) { + f = c.f; + r = c.r; + ; + } + void operator=(const AC_F0 &a); //{ f=new E_Array(a); f= atype();}; + void operator=(long) { + f = 0; + r = 0; + } + void operator=(const CListOfInst &c); //{ C_FO cc=c;f=cc.f;r=cc.r} + operator C_F0( ) const { return C_F0(f, r); } + bool Empty( ) const { return !f || f->Empty( ); } + aType left( ) const { return r; } + // operator const C_F0 &() const {return *this;} }; /// <> -class ListOfInst : - public E_F0mps // [[E_F0mps]] -{ +class ListOfInst : public E_F0mps // [[E_F0mps]] +{ int n; - Expression * list; - int * linenumber; - int * lsldel; + Expression *list; + int *linenumber; + int *lsldel; const int nx; - vectorOfInst * atclose; // Sep 2017 FH - // add sep. 2016 FH + vectorOfInst *atclose; // Sep 2017 FH + // add sep. 2016 FH -public: - - ListOfInst():n(0),list(0),linenumber(0),lsldel(0),nx(10),atclose(0){} - ListOfInst(int nn):n(0),list(0),linenumber(0),lsldel(0),nx(nn?nn:10),atclose(0) {} - void Add(const C_F0 & ins); + public: + ListOfInst( ) : n(0), list(0), linenumber(0), lsldel(0), nx(10), atclose(0) {} + ListOfInst(int nn) : n(0), list(0), linenumber(0), lsldel(0), nx(nn ? nn : 10), atclose(0) {} + void Add(const C_F0 &ins); /// <> implemented at [[file:AFunction2.cpp::ListOfInst::operator()]] - AnyType operator()(Stack s) const; -// AnyType reval(Stack s,int & i) const; // eval of Routine -// AnyType rcleaneval(Stack s,int & i) const; // clean of Routine - operator aType () const { return n ? (aType) * (list[n-1]) : atype();} - - Expression &operator[](int i){return list[i];} - bool empty() const {return n==0;} - int size() const {return n;} - Expression * ptr() const {return list;} - int * nlines() const {return linenumber;} - void setclose(vectorOfInst * at) {atclose=at;} // Sep 2017 FH - ~ListOfInst(){ - // cout << " ----- ~ListOfInst " << endl; - if(list) delete [] list; - list=0; - if(linenumber) delete[] linenumber; - if(lsldel) delete[] lsldel; - linenumber=0; - lsldel=0; + AnyType operator( )(Stack s) const; + // AnyType reval(Stack s,int & i) const; // eval of Routine + // AnyType rcleaneval(Stack s,int & i) const; // clean of Routine + operator aType( ) const { return n ? (aType) * (list[n - 1]) : atype< void >( ); } + + Expression &operator[](int i) { return list[i]; } + bool empty( ) const { return n == 0; } + int size( ) const { return n; } + Expression *ptr( ) const { return list; } + int *nlines( ) const { return linenumber; } + void setclose(vectorOfInst *at) { atclose = at; } // Sep 2017 FH + ~ListOfInst( ) { + // cout << " ----- ~ListOfInst " << endl; + if (list) delete[] list; + list = 0; + if (linenumber) delete[] linenumber; + if (lsldel) delete[] lsldel; + linenumber = 0; + lsldel = 0; } }; /// <> used in [[file:../lglib/lg.ypp::YYSTYPE]] -class CListOfInst{ -private: - - /// class [[ListOfInst]] - ListOfInst * f; +class CListOfInst { + private: + /// class [[ListOfInst]] + ListOfInst *f; const basicForEachType *r; -public: - void operator=(const CC_F0 &a){ - f=new ListOfInst(); - if( !a.Empty() ) { + public: + void operator=(const CC_F0 &a) { + f = new ListOfInst( ); + if (!a.Empty( )) { f->Add(a); - r=a.left(); }} - CListOfInst & operator+=(const CC_F0 & a);//{ if( !a.Empty()){ f->Add(a);r=a.left();};return *this;} - void setclose( vectorOfInst * fin) { - assert(f); - if(verbosity>99999) cout << "CListOfInst: setclose n " << f->size() << " " << f << " " << fin << endl; - f->setclose(fin); - + r = a.left( ); + } } - operator C_F0 () const { return C_F0(f,r);} - operator ListOfInst * () const { return f;} + CListOfInst &operator+=(const CC_F0 &a); //{ if( !a.Empty()){ f->Add(a);r=a.left();};return *this;} + void setclose(vectorOfInst *fin) { + assert(f); + if (verbosity > 99999) cout << "CListOfInst: setclose n " << f->size( ) << " " << f << " " << fin << endl; + f->setclose(fin); + } + operator C_F0( ) const { return C_F0(f, r); } + operator ListOfInst *( ) const { return f; } /// <> Called by yyparse() at [[file:../lglib/lg.ypp::start_symbol]] to evaluate the /// complete expression tree when reaching the end of its "start" symbol. It calls ListOfInst::operator()() at /// [[ListOfInst::operator()]] for its private [[ListOfInst]] pointer #f. - void eval(Stack s) {(*f)(s);} + void eval(Stack s) { (*f)(s); } - int size() const {return f->size();} - Expression * ptr() const {return f->ptr();} - int * nlines() const { return f->nlines();} + int size( ) const { return f->size( ); } + Expression *ptr( ) const { return f->ptr( ); } + int *nlines( ) const { return f->nlines( ); } }; - -AnyType FWhile(Stack ,E_F0 * test,E_F0 * ins); -AnyType FFor(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * ins); -AnyType FIf(Stack s ,E_F0 * test,E_F0 * i1,E_F0 * i2,E_F0 * notuse); -AnyType TTry(Stack s ,E_F0 * i0,E_F0 * i1,E_F0 * i2,E_F0 * notuse); - +AnyType FWhile(Stack, E_F0 *test, E_F0 *ins); +AnyType FFor(Stack s, E_F0 *i0, E_F0 *i1, E_F0 *i2, E_F0 *ins); +AnyType FIf(Stack s, E_F0 *test, E_F0 *i1, E_F0 *i2, E_F0 *notuse); +AnyType TTry(Stack s, E_F0 *i0, E_F0 *i1, E_F0 *i2, E_F0 *notuse); /// <> Contains all FreeFem++ language keywords. Definition in [[file:global.cpp::Global]], uses [[TableOfIdentifier]] extern TableOfIdentifier Global; -void ShowType(ostream & ); - -template -inline C_F0 to(const C_F0 & a) { return map_type[typeid(T).name()]->CastTo(a);} +void ShowType(ostream &); +template< class T > +inline C_F0 to(const C_F0 &a) { + return map_type[typeid(T).name( )]->CastTo(a); +} /* inline C_F0 toBool(const C_F0 & a) {return ATYPE(bool)->CastTo(a);} @@ -1524,773 +1592,819 @@ inline C_F0 toLong(const C_F0 & a) {return ATYPE(long)->CastTo(a);} inline C_F0 toDouble(const C_F0 & a) {return ATYPE(double)->CastTo(a);} inline C_F0 toComplex(const C_F0 & a) {return ATYPE(Complex)->CastTo(a);} */ -inline C_F0 While(C_F0 test,C_F0 ins) {return C_F0(new E_F0_CFunc2(FWhile,to(test),ins),0);} -inline C_F0 For(C_F0 i0,C_F0 i1,C_F0 i2,C_F0 ins) {return C_F0(new E_F0_CFunc4(FFor,i0,to(i1),i2,ins),0);} -inline C_F0 Try(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(TTry,i0,i1,i2,0),0);} -inline C_F0 Try(C_F0 i0,C_F0 i1) {return C_F0(new E_F0_CFunc4(TTry,i0,i1,0,0),0);} -inline C_F0 FIf(C_F0 i0,C_F0 i1,C_F0 i2) {return C_F0(new E_F0_CFunc4(FIf,to(i0),i1,i2,0),0);} -inline C_F0 FIf(C_F0 i0,C_F0 i1) {return C_F0(new E_F0_CFunc4(FIf,to(i0),i1,0,0),0);} -//inline C_F0 C_F0::PtrValue() const{ -// if (!(r && r->un_ptr)) { cerr << "PtrValue: Not a Left value " << *r << endl;CompileError();} -// return C_F0(new E_F0_Func1(r->un_ptr->f,f),r->un_ptr->r);} +inline C_F0 While(C_F0 test, C_F0 ins) { return C_F0(new E_F0_CFunc2(FWhile, to< bool >(test), ins), 0); } +inline C_F0 For(C_F0 i0, C_F0 i1, C_F0 i2, C_F0 ins) { return C_F0(new E_F0_CFunc4(FFor, i0, to< bool >(i1), i2, ins), 0); } +inline C_F0 Try(C_F0 i0, C_F0 i1, C_F0 i2) { return C_F0(new E_F0_CFunc4(TTry, i0, i1, i2, 0), 0); } +inline C_F0 Try(C_F0 i0, C_F0 i1) { return C_F0(new E_F0_CFunc4(TTry, i0, i1, 0, 0), 0); } +inline C_F0 FIf(C_F0 i0, C_F0 i1, C_F0 i2) { return C_F0(new E_F0_CFunc4(FIf, to< bool >(i0), i1, i2, 0), 0); } +inline C_F0 FIf(C_F0 i0, C_F0 i1) { return C_F0(new E_F0_CFunc4(FIf, to< bool >(i0), i1, 0, 0), 0); } +// inline C_F0 C_F0::PtrValue() const{ +// if (!(r && r->un_ptr)) { cerr << "PtrValue: Not a Left value " << *r << endl;CompileError();} +// return C_F0(new E_F0_Func1(r->un_ptr->f,f),r->un_ptr->r);} /// <> version de base d'un tableau d'un parametres pour les operateurs unaire, binaire, pas d'allocation class basicAC_F0 { - friend class E_Array; // for mapping fonction - friend class E_FEarray; // for mapping fonction - protected: + friend class E_Array; // for mapping fonction + friend class E_FEarray; // for mapping fonction + protected: typedef const C_F0 const_C_F0; - int nb; - C_F0 *a; + int nb; + C_F0 *a; + public: - typedef map maptype ; + typedef map< const char *, C_F0, Keyless > maptype; typedef maptype::iterator iterator; typedef maptype::const_iterator const_iterator; - maptype * named_parameter; - basicAC_F0 & operator=(int i) {throwassert(i==0);named_parameter=0,nb=0;return *this;} // pas de parametres - basicAC_F0 & operator=(C_F0 & c) {named_parameter=0;nb=1;a=&c;return *this;} - basicAC_F0 & operator=(pair p) {named_parameter=0;nb=p.first;a=p.second;return *this;} - const C_F0 & operator [] (int i) const {throwassert(a && ifind(k) ; - if (i == named_parameter->end() ) return C_F0(); - else return i->second;} - else return C_F0();} - - struct name_and_type{ - const char * name; - const type_info * type; - } ; - - void SetNameParam(int n=0,name_and_type *l=0 , Expression * e=0) const ; + maptype *named_parameter; + basicAC_F0 &operator=(int i) { + throwassert(i == 0); + named_parameter = 0, nb = 0; + return *this; + } // pas de parametres + basicAC_F0 &operator=(C_F0 &c) { + named_parameter = 0; + nb = 1; + a = &c; + return *this; + } + basicAC_F0 &operator=(pair< int, C_F0 * > p) { + named_parameter = 0; + nb = p.first; + a = p.second; + return *this; + } + const C_F0 &operator[](int i) const { + throwassert(a && i < nb); + return a[i]; + } + int size( ) const { return nb; } + C_F0 *ptr( ) const { return a; } + C_F0 find(const char *k) const { + assert(k); + if (named_parameter) { + const_iterator i = named_parameter->find(k); + if (i == named_parameter->end( )) + return C_F0( ); + else + return i->second; + } else + return C_F0( ); + } + + struct name_and_type { + const char *name; + const type_info *type; + }; + + void SetNameParam(int n = 0, name_and_type *l = 0, Expression *e = 0) const; }; /// <> array of parameters for FF language operators. uses [[basicAC_F0]] -class AC_F0: public basicAC_F0 { // a Array of [[C_F0]] -// tableau d'un parametres max 1024 parametres -// avec allocation - const static int MaxSize; - // no constructor in this class (this class is in a union ) - public: - AC_F0 & operator=(pair p) { - named_parameter=0; a=new C_F0[MaxSize]; nb=0;Add(p.first,p.second);return *this;} - AC_F0 & operator+=(pair p) {Add(p.first,p.second);return *this;} - - AC_F0 & operator=(long k) {throwassert(k==0);named_parameter=0;a=new C_F0[MaxSize]; nb=0;return *this;} - AC_F0 & operator=(const C_F0& c) {named_parameter=0; a=new C_F0[MaxSize]; nb=0;a[nb++]=c;return *this;} - AC_F0 & operator+=(const C_F0& c) { - if ( ! (a&& nb 1024"); - a[nb++]=c;return *this;} - AC_F0 & operator+=(const AC_F0& c) { - if ( ! (a&& nb 1024"); - for(int j=0; jinsert(c.named_parameter->begin(),c.named_parameter->end()); // insert named parameter +class AC_F0 : public basicAC_F0 { // a Array of [[C_F0]] + // tableau d'un parametres max 1024 parametres + // avec allocation + const static int MaxSize; + // no constructor in this class (this class is in a union ) + public: + AC_F0 &operator=(pair< const char *, const C_F0 > p) { + named_parameter = 0; + a = new C_F0[MaxSize]; + nb = 0; + Add(p.first, p.second); + return *this; + } + AC_F0 &operator+=(pair< const char *, const C_F0 > p) { + Add(p.first, p.second); + return *this; + } + + AC_F0 &operator=(long k) { + throwassert(k == 0); + named_parameter = 0; + a = new C_F0[MaxSize]; + nb = 0; + return *this; + } + AC_F0 &operator=(const C_F0 &c) { + named_parameter = 0; + a = new C_F0[MaxSize]; + nb = 0; + a[nb++] = c; + return *this; + } + AC_F0 &operator+=(const C_F0 &c) { + if (!(a && nb < MaxSize)) CompileError("Sorry number of parameters > 1024"); + a[nb++] = c; + return *this; + } + AC_F0 &operator+=(const AC_F0 &c) { + if (!(a && nb < MaxSize - c.size( ))) CompileError("Sorry number of parameters > 1024"); + for (int j = 0; j < c.size( ); ++j) a[nb++] = c[j]; + // add named parameter .. + // ffassert( named_parameter==0); // modif FH & JM June 2022 + if (c.named_parameter) { + if (!named_parameter) named_parameter = new maptype( ); // map vide + named_parameter->insert(c.named_parameter->begin( ), c.named_parameter->end( )); // insert named parameter // named_parameter=new maptype(*c.named_parameter);// old code :copy la map !!!!! - } - // end modif June 2022 - - return *this;} - AC_F0 & Add(const char * nm,const C_F0 &c) { - if (!named_parameter) named_parameter=new maptype(); - iterator i=named_parameter->find(nm); - if(i==named_parameter->end()) named_parameter->insert(make_pair(nm,c)); - else {cerr << " the named in the list already exists "<< nm < struct pack { }; - template - using AllC_F0 = typename std::enable_if::value...>, pack::value..., true>>::value>::type; - template> - basicAC_F0_wa(T... a) : basicAC_F0_wa({std::forward(a)...}) { } - basicAC_F0_wa(const std::initializer_list& e) { - named_parameter=0; - nb = e.size(); - a = new C_F0[nb]; - int i = 0; - for(auto n : e) - a[i++] = n; - } - - basicAC_F0_wa(C_F0 e,const basicAC_F0 & b) { - named_parameter=0; - if (b.named_parameter) named_parameter = new maptype(*b.named_parameter); - nb=1+b.size(); - a= new C_F0[nb]; - a[0]=e; - for (int i=1;ifind(nm); + if (i == named_parameter->end( )) + named_parameter->insert(make_pair(nm, c)); + else { + cerr << " the named in the list already exists " << nm << endl; + CompileError( ); + } + return *this; + } + int size( ) const { return nb; } + const C_F0 &operator[](int i) const { + if (!(a && i < nb)) { + cout << " AC_F0 bug " << a << " " << i << endl; + ffassert(a && i < nb); + } + return a[i]; + } + void destroy( ) { + + nb = 0; + if (named_parameter) delete named_parameter; + if (a) delete[] a; + a = 0; + named_parameter = 0; + } }; +class basicAC_F0_wa : public basicAC_F0 { + public: + template< bool... > + struct pack {}; + template< class... T > + using AllC_F0 = typename std::enable_if< std::is_same< pack< true, std::is_convertible< T, C_F0 >::value... >, pack< std::is_convertible< T, C_F0 >::value..., true > >::value >::type; + template< class... T, typename = AllC_F0< T... > > + basicAC_F0_wa(T... a) : basicAC_F0_wa({std::forward< T >(a)...}) {} + basicAC_F0_wa(const std::initializer_list< C_F0 > &e) { + named_parameter = 0; + nb = e.size( ); + a = new C_F0[nb]; + int i = 0; + for (auto n : e) a[i++] = n; + } + + basicAC_F0_wa(C_F0 e, const basicAC_F0 &b) { + named_parameter = 0; + if (b.named_parameter) named_parameter = new maptype(*b.named_parameter); + nb = 1 + b.size( ); + a = new C_F0[nb]; + a[0] = e; + for (int i = 1; i < nb; i++) a[i] = b[i - 1]; + } + ~basicAC_F0_wa( ) { + delete[] a; + a = 0; + delete named_parameter; + named_parameter = 0; + } + + basicAC_F0_wa(const basicAC_F0 &b) { + named_parameter = 0; + if (b.named_parameter) named_parameter = new maptype(*b.named_parameter); + nb = b.size( ); + a = new C_F0[nb]; + for (int i = 0; i < nb; i++) a[i] = b[i]; + } + + private: + void operator=(const basicAC_F0 &b); +}; // <> -class E_Array :public E_F0 { public: - basicAC_F0_wa *v;// the value - E_Array(const basicAC_F0 & aa) : v(new basicAC_F0_wa(aa)) {throwassert(v);} - AnyType operator()(Stack) const { - cerr << " No evaluation of an E_array" << endl; - throwassert(0); - return Nothing;} - const C_F0 & operator [] (int i) const {throwassert(v );return (*v)[i];} - int size() const {return v->size();} - size_t nbitem() const {return v->size();} - void map(C_F0 (*mapping)(const C_F0 & )) const - { for (int i=0;isize();i++) - v->a[i]=(*mapping)(v->a[i]);} - virtual bool MeshIndependent() const { - for (int i=0;isize();i++) - if (v->a[i].MeshIndependent()) return false; - return false; - - } // - operator aType () const { return atype();} - +class E_Array : public E_F0 { + public: + basicAC_F0_wa *v; // the value + E_Array(const basicAC_F0 &aa) : v(new basicAC_F0_wa(aa)) { throwassert(v); } + AnyType operator( )(Stack) const { + cerr << " No evaluation of an E_array" << endl; + throwassert(0); + return Nothing; + } + const C_F0 &operator[](int i) const { + throwassert(v); + return (*v)[i]; + } + int size( ) const { return v->size( ); } + size_t nbitem( ) const { return v->size( ); } + void map(C_F0 (*mapping)(const C_F0 &)) const { + for (int i = 0; i < v->size( ); i++) v->a[i] = (*mapping)(v->a[i]); + } + virtual bool MeshIndependent( ) const { + for (int i = 0; i < v->size( ); i++) + if (v->a[i].MeshIndependent( )) return false; + return false; + + } // + operator aType( ) const { return atype< void >( ); } }; // A voir le nom avec F // Remark: c'est un cc de E_Array + Fusionner ?? -class E_FEarray :public E_F0 { public: - basicAC_F0_wa *v;// the value - E_FEarray(const basicAC_F0 & aa) : v(new basicAC_F0_wa(aa)) {throwassert(v);} - AnyType operator()(Stack) const { - cerr << " No evaluation of an E_FEarray" << endl; - throwassert(0); - return Nothing;} - const C_F0 & operator [] (int i) const {throwassert(v );return (*v)[i];} - int size() const {return v->size();} - size_t nbitem() const {return v->size();} - void map(C_F0 (*mapping)(const C_F0 & )) const - { for (int i=0;isize();i++) - v->a[i]=(*mapping)(v->a[i]);} - virtual bool MeshIndependent() const { - for (int i=0;isize();i++) - if (v->a[i].MeshIndependent()) return false; - return false; - - } // - operator aType () const { return atype();} - +class E_FEarray : public E_F0 { + public: + basicAC_F0_wa *v; // the value + E_FEarray(const basicAC_F0 &aa) : v(new basicAC_F0_wa(aa)) { throwassert(v); } + AnyType operator( )(Stack) const { + cerr << " No evaluation of an E_FEarray" << endl; + throwassert(0); + return Nothing; + } + const C_F0 &operator[](int i) const { + throwassert(v); + return (*v)[i]; + } + int size( ) const { return v->size( ); } + size_t nbitem( ) const { return v->size( ); } + void map(C_F0 (*mapping)(const C_F0 &)) const { + for (int i = 0; i < v->size( ); i++) v->a[i] = (*mapping)(v->a[i]); + } + virtual bool MeshIndependent( ) const { + for (int i = 0; i < v->size( ); i++) + if (v->a[i].MeshIndependent( )) return false; + return false; + + } // + operator aType( ) const { return atype< void >( ); } }; // add frev 2007 -class TransE_Array: public E_F0 { public: - const E_Array * v; - int size() const {return v->size();} - size_t nbitem() const {return v->size();} - bool MeshIndependent(){return v->MeshIndependent();} - TransE_Array(const E_Array * e): v(e) {ffassert(e);} - AnyType operator()(Stack s) const {ffassert(0);return 0L;} +class TransE_Array : public E_F0 { + public: + const E_Array *v; + int size( ) const { return v->size( ); } + size_t nbitem( ) const { return v->size( ); } + bool MeshIndependent( ) { return v->MeshIndependent( ); } + TransE_Array(const E_Array *e) : v(e) { ffassert(e); } + AnyType operator( )(Stack s) const { + ffassert(0); + return 0L; + } }; // fin nov 2007 // add 2010 feb. FH -inline C_F0 TryConj(const C_F0 & c) { - // here put the conj operator ... - ArrayOfaType at(c.left()); - basicAC_F0_wa p(c); - const OneOperator * ff=TheOperators->Find("\'",at); - if (ff) { - if(verbosity>10) - cout << " ( do Conj) " ; - return ff->code2(p); - } - - return c; } +inline C_F0 TryConj(const C_F0 &c) { + // here put the conj operator ... + ArrayOfaType at(c.left( )); + basicAC_F0_wa p(c); + const OneOperator *ff = TheOperators->Find("\'", at); + if (ff) { + if (verbosity > 10) cout << " ( do Conj) "; + return ff->code2(p); + } + + return c; +} // fin add 2010 feb. // avril 2007 -class PlotStream; -class E_Border ; -class E_BorderN :public E_F0mps { public: - const E_Border * b; - int cas;// 0 long , 1, KN_ , 2 : Array // FH april 14 .. - Expression n; - const E_BorderN * next; - - static int Cas(C_F0 nn) - { - if( atype()->CastingFrom(nn.left())) return 0; - else if(atype >()->CastingFrom(nn.left())) return 1; - else if( atype< const E_Array * >()->CastingFrom(nn.left()) ) - { - E_Array & a = *dynamic_cast< E_Array *>((Expression) nn); - ffassert(a); - a.map(::to); - // a[i]=CastTo(a[i]); - return 2; +class PlotStream; +class E_Border; +class E_BorderN : public E_F0mps { + public: + const E_Border *b; + int cas; // 0 long , 1, KN_ , 2 : Array // FH april 14 .. + Expression n; + const E_BorderN *next; + + static int Cas(C_F0 nn) { + if (atype< long >( )->CastingFrom(nn.left( ))) + return 0; + else if (atype< KN_< long > >( )->CastingFrom(nn.left( ))) + return 1; + else if (atype< const E_Array * >( )->CastingFrom(nn.left( ))) { + E_Array &a = *dynamic_cast< E_Array * >((Expression)nn); + ffassert(a); + a.map(::to< long >); + // a[i]=CastTo(a[i]); + return 2; + } else + CompileError(" Number of element of a border ( longn , int array, [ ] array "); + return -1; // bug + } + E_BorderN(const E_Border *bb, C_F0 nn, const E_BorderN *nx = 0); + E_BorderN(const E_BorderN &bb, const E_BorderN *nx) : b(bb.b), cas(bb.cas), n(bb.n), next(nx) { + int kk = 1; + if (bb.next) { // modif FH. 13/02/2008 + + const E_BorderN **pnext = &next; + E_BorderN *pp; + next = bb.next; // copy bb; + for (int step = 0; step < 2; ++step) { + while (*pnext) { + kk++; + pp = new E_BorderN(**pnext); // copy + *pnext = pp; + pnext = &pp->next; } - else CompileError(" Number of element of a border ( longn , int array, [ ] array "); - return -1; // bug - } - E_BorderN(const E_Border * bb, C_F0 nn,const E_BorderN * nx=0) ; - E_BorderN(const E_BorderN & bb,const E_BorderN * nx) - : b(bb.b),cas(bb.cas),n(bb.n),next(nx) - { - int kk=1; - if(bb.next) {// modif FH. 13/02/2008 - - const E_BorderN ** pnext = &next; - E_BorderN *pp; - next = bb.next; // copy bb; - for(int step=0;step<2;++step) - { - while (*pnext) - { - kk++; - pp = new E_BorderN(**pnext); // copy - *pnext = pp; - pnext = & pp->next; - } - if(step==0) - *pnext= nx; // copy de nx - } - // cout << " BorderN : nb item : " << kk << " == " << size()<< endl; - } - } - AnyType operator()(Stack) const { - return SetAny(this);} - operator aType () const { return atype();} - int size() const { int k=0;for(const E_BorderN *pp=this;pp; pp=pp->next) k++; return k;} - E_BorderN * operator+( const E_BorderN & bb) const - { throwassert(bb.next==0); - return new E_BorderN(bb,this);} - -static C_F0 to(int cas, C_F0 nn) - { - if(cas==0) return ::to(nn); - else if(cas ==1) return ::to >(nn); - else if(cas == 2) return ::to (nn); - else ffassert(0); // Big bug .. FH .. + if (step == 0) *pnext = nx; // copy de nx + } + // cout << " BorderN : nb item : " << kk << " == " << size()<< endl; } - long Nbseg(Stack stack,int index) const { - if(cas==0) {assert(index==0); return GetAny((*n)(stack));} - else if (cas==1 ) return (GetAny >((*n)(stack)))(index); - else if (cas==2) {E_Array & a = *dynamic_cast< E_Array *>((Expression) n);assert(a); Expression nn= a[index]; return GetAny((*nn)(stack));} - else return 0; + } + AnyType operator( )(Stack) const { return SetAny< const E_BorderN * >(this); } + operator aType( ) const { return atype< const E_BorderN * >( ); } + int size( ) const { + int k = 0; + for (const E_BorderN *pp = this; pp; pp = pp->next) k++; + return k; + } + E_BorderN *operator+(const E_BorderN &bb) const { + throwassert(bb.next == 0); + return new E_BorderN(bb, this); + } + + static C_F0 to(int cas, C_F0 nn) { + if (cas == 0) + return ::to< long >(nn); + else if (cas == 1) + return ::to< KN_< long > >(nn); + else if (cas == 2) + return ::to< E_Array >(nn); + else + ffassert(0); // Big bug .. FH .. + } + long Nbseg(Stack stack, int index) const { + if (cas == 0) { + assert(index == 0); + return GetAny< long >((*n)(stack)); + } else if (cas == 1) + return (GetAny< KN_< long > >((*n)(stack)))(index); + else if (cas == 2) { + E_Array &a = *dynamic_cast< E_Array * >((Expression)n); + assert(a); + Expression nn = a[index]; + return GetAny< long >((*nn)(stack)); + } else + return 0; } long NbBorder(Stack stack) const { - if(cas==0) return 1; - else if (cas==1 ) return GetAny >((*n)(stack)).N(); - else if (cas==2) return dynamic_cast(n)->size(); - else return 0; - } //GetAny((*n)(stack));} - - double from(Stack stack) const ;//{ return GetAny((*n)(stack));} - double to(Stack stack) const ;//{ return GetAny((*b)(stack));} - long * index(Stack stack) const ;//{ return GetAny((*b)(stack));} - double * var(Stack stack) const ;//{ return GetAny((*n)(stack));} - void code(Stack stack) const ; - long label()const ; - void Plot(Stack stack) const ; - void SavePlot(Stack stack,PlotStream & plot ) const; - - void BoundingBox(Stack stack,double &xmin,double & xmax, double & ymin,double & ymax, double & zmin,double & zmax) const ; -}; - -class AddBorderOperator: public OneOperator{ - typedef const E_BorderN * A; - public: - E_F0 * code(const basicAC_F0 & args) const - { - A a0=dynamic_cast((Expression) args[0]); - A a1=dynamic_cast((Expression) args[1]); - ffassert( a0 && a1); - //ffassert(a1->next==0); // change FH 13/02/2008 - return new E_BorderN(*a1,a0);} - AddBorderOperator(): - OneOperator(map_type[typeid(A).name()],map_type[typeid(A).name()],map_type[typeid(A).name()]) - {pref = 0;} - -}; - - -class OneOperator_borderN : public OneOperator {public: - const E_Border * theborder;int cas; - E_F0 * code(const basicAC_F0 & a) const - { return new E_BorderN(theborder,a[0]);} - OneOperator_borderN(const E_Border * b) - : OneOperator(atype(),atype()), - theborder(b),cas(0){} - OneOperator_borderN(const E_Border * b,int ) - : OneOperator(atype(),atype >()), - theborder(b),cas(1){} - OneOperator_borderN(const E_Border * b,int,int ) - : OneOperator(atype(),atype()), - theborder(b),cas(2){} - -}; - -class E_Border :public Polymorphic { public: - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =0; + if (cas == 0) + return 1; + else if (cas == 1) + return GetAny< KN_< long > >((*n)(stack)).N( ); + else if (cas == 2) + return dynamic_cast< const E_Array * >(n)->size( ); + else + return 0; + } // GetAny((*n)(stack));} + + double from(Stack stack) const; //{ return GetAny((*n)(stack));} + double to(Stack stack) const; //{ return GetAny((*b)(stack));} + long *index(Stack stack) const; //{ return GetAny((*b)(stack));} + double *var(Stack stack) const; //{ return GetAny((*n)(stack));} + void code(Stack stack) const; + long label( ) const; + void Plot(Stack stack) const; + void SavePlot(Stack stack, PlotStream &plot) const; + + void BoundingBox(Stack stack, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const; +}; + +class AddBorderOperator : public OneOperator { + typedef const E_BorderN *A; + + public: + E_F0 *code(const basicAC_F0 &args) const { + A a0 = dynamic_cast< A >((Expression)args[0]); + A a1 = dynamic_cast< A >((Expression)args[1]); + ffassert(a0 && a1); + // ffassert(a1->next==0); // change FH 13/02/2008 + return new E_BorderN(*a1, a0); + } + AddBorderOperator( ) : OneOperator(map_type[typeid(A).name( )], map_type[typeid(A).name( )], map_type[typeid(A).name( )]) { pref = 0; } +}; + +class OneOperator_borderN : public OneOperator { + public: + const E_Border *theborder; + int cas; + E_F0 *code(const basicAC_F0 &a) const { return new E_BorderN(theborder, a[0]); } + OneOperator_borderN(const E_Border *b) : OneOperator(atype< const E_BorderN * >( ), atype< long >( )), theborder(b), cas(0) {} + OneOperator_borderN(const E_Border *b, int) : OneOperator(atype< const E_BorderN * >( ), atype< KN_< long > >( )), theborder(b), cas(1) {} + OneOperator_borderN(const E_Border *b, int, int) : OneOperator(atype< const E_BorderN * >( ), atype< E_Array >( )), theborder(b), cas(2) {} +}; + +class E_Border : public Polymorphic { + public: + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 0; static long Count; - Expression xvar,xfrom,xto,xcode,xindex; - basicAC_F0_wa * tab; + Expression xvar, xfrom, xto, xcode, xindex; + basicAC_F0_wa *tab; long label; - E_Border(const E_Array * a) : - xvar(0),xfrom(0),xto(0),xcode(0),xindex(0), tab(a? a->v:0) ,label(++Count) - { - assert(tab); - Add("(",new OneOperator_borderN(this)); - Add("(",new OneOperator_borderN(this,1)); - Add("(",new OneOperator_borderN(this,1,1)); - /* A FAIRE pour multy border ****/ - } - - E_Border(const basicAC_F0 & aa) : - xvar(to(aa[0])), - xfrom(to(aa[1])), - xto(to(aa[2])), - xcode(aa[aa.size()-1].LeftValue()), - xindex( (aa.size() > 4) ? (Expression) to(aa[3]) : 0 ), - //xindex( to(aa[3]) ), - tab(0), - label(++Count) - { - Add("(",new OneOperator_borderN(this)); - Add("(",new OneOperator_borderN(this,1)); - Add("(",new OneOperator_borderN(this,1,1)); - } - - AnyType operator()(Stack) const { - return SetAny(this);} - double length(Stack ) const { ffassert(0);return 0.0; /* a faire */ } -}; -inline E_BorderN::E_BorderN(const E_Border *bb, C_F0 nn,const E_BorderN * nx) -:b(bb),cas(Cas(nn)),n(to(cas,nn) ),next(nx) { /* cout << " -- E_BorderN : cas " << cas << endl; */ throwassert(b);} - -inline double E_BorderN::from(Stack stack) const {return b->xfrom ? GetAny((*b->xfrom)(stack)): double(0.0);} -inline double E_BorderN::to(Stack stack) const {return b->xto? GetAny((*b->xto)(stack)): b->length(stack) ;} -inline double * E_BorderN::var(Stack stack) const {return b->xvar ? GetAny((*b->xvar)(stack)): (double*) 0 ;} -inline long * E_BorderN::index(Stack stack) const {return b->xindex ? GetAny((*b->xindex)(stack)): (long*) 0 ;} -inline void E_BorderN::code(Stack stack)const {(*b->xcode)(stack);} -inline long E_BorderN::label()const {return b->label;} - -inline ArrayOfaType::ArrayOfaType(const basicAC_F0 & aa) : n(aa.size()),t(n ? (n<=4 ? tt : new aType[n]):0),ellipse(false) { - for (int i=0;isecond);} - -inline C_F0 TableOfIdentifier::Find(const char * name,const basicAC_F0 & args) const { - const_iterator i=m.find(name); - if ( i == m.end()) {cerr<<"No operator " << name<second),"(",args);}} + E_Border(const E_Array *a) : xvar(0), xfrom(0), xto(0), xcode(0), xindex(0), tab(a ? a->v : 0), label(++Count) { + assert(tab); + Add("(", new OneOperator_borderN(this)); + Add("(", new OneOperator_borderN(this, 1)); + Add("(", new OneOperator_borderN(this, 1, 1)); + /* A FAIRE pour multy border ****/ + } + + E_Border(const basicAC_F0 &aa) + : xvar(to< double * >(aa[0])), xfrom(to< double >(aa[1])), xto(to< double >(aa[2])), xcode(aa[aa.size( ) - 1].LeftValue( )), xindex((aa.size( ) > 4) ? (Expression)to< long * >(aa[3]) : 0), + // xindex( to(aa[3]) ), + tab(0), label(++Count) { + Add("(", new OneOperator_borderN(this)); + Add("(", new OneOperator_borderN(this, 1)); + Add("(", new OneOperator_borderN(this, 1, 1)); + } + + AnyType operator( )(Stack) const { return SetAny< const E_Border * >(this); } + double length(Stack) const { + ffassert(0); + return 0.0; /* a faire */ + } +}; +inline E_BorderN::E_BorderN(const E_Border *bb, C_F0 nn, const E_BorderN *nx) : b(bb), cas(Cas(nn)), n(to(cas, nn)), next(nx) { /* cout << " -- E_BorderN : cas " << cas << endl; */ throwassert(b); } + +inline double E_BorderN::from(Stack stack) const { return b->xfrom ? GetAny< double >((*b->xfrom)(stack)) : double(0.0); } +inline double E_BorderN::to(Stack stack) const { return b->xto ? GetAny< double >((*b->xto)(stack)) : b->length(stack); } +inline double *E_BorderN::var(Stack stack) const { return b->xvar ? GetAny< double * >((*b->xvar)(stack)) : (double *)0; } +inline long *E_BorderN::index(Stack stack) const { return b->xindex ? GetAny< long * >((*b->xindex)(stack)) : (long *)0; } +inline void E_BorderN::code(Stack stack) const { (*b->xcode)(stack); } +inline long E_BorderN::label( ) const { return b->label; } + +inline ArrayOfaType::ArrayOfaType(const basicAC_F0 &aa) : n(aa.size( )), t(n ? (n <= 4 ? tt : new aType[n]) : 0), ellipse(false) { + for (int i = 0; i < n; i++) t[i] = aa[i].left( ); +} + +inline ArrayOfaType::ArrayOfaType(const ArrayOfaType &aa) : n(aa.n), t(n <= 4 ? tt : new aType[n]), ellipse(aa.ellipse) { + for (int i = 0; i < n; i++) t[i] = aa.t[i]; +} + +inline C_F0 TableOfIdentifier::Find(const char *name) const { + const_iterator i = m.find(name); + if (i == m.end( )) { + return C_F0( ); + } else + return C_F0(i->second); +} + +inline C_F0 TableOfIdentifier::Find(const char *name, const basicAC_F0 &args) const { + const_iterator i = m.find(name); + if (i == m.end( )) { + cerr << "No operator " << name << endl; + cerr << *this << endl; + CompileError("TableOfIdentifier::Find"); + return C_F0( ); + } else { + return C_F0(C_F0(i->second), "(", args); + } +} // Attention il y a moralement un bug // les initialisation x = y ( passe par l'operateur binaire <- dans TheOperators // les initialisation x(y) ( passe par l'operateur unaire <- du type de x // ------- -inline size_t align8(size_t &off) -{ - size_t o= off %8 ; - off += o ? 8-o : 0; - return off; -} - - -template -inline Type_Expr NewVariable(aType t,size_t &off) -{ - size_t o= align8(off);// align - // off += t->un_ptr_type->size; - // bug off += t->size; - off += t->un_ptr_type->size; // correction 16/09/2003 merci a Richard MICHEL - return Type_Expr(t,new T(o,t)); -} - -template -inline Type_Expr NewVariable(aType t,size_t &off,const basicAC_F0 &args) -{ - size_t o= align8(off);// align - off += t->un_ptr_type->size; - return Type_Expr(t,new T(o,t,args)); -} - -template -inline Type_Expr NewVariable(aType t,size_t &off,const U & data) -{ - size_t o= align8(off);// align - off += t->un_ptr_type->size; - return Type_Expr(t,new T(o,t,data)); -} -//extern int NbNewVarWithDel; // def in global.cpp sep 2016 FH. - -template -inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const C_F0 &i) - { - // if( t-> ExistDestroy()) NbNewVarWithDel++; - return C_F0(TheOperators,"<-",New(k,NewVariable(t,top)),i);} - -template -inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args) - { - // return C_F0(TheOperators,"<-",New(k,NewVariable(t,top)),t->Find("<-",args));} - // if( t-> ExistDestroy()) NbNewVarWithDel++; - return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewVariable(t,top)),args));} - -template -inline C_F0 TableOfIdentifier::NewFESpace(Key k,aType t,size_t & top,const basicAC_F0 &args) - { - return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewFESpace(t,top,args)),args));} - - -template -inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const basicAC_F0 &args,const U & data) - { - // if( t-> ExistDestroy()) NbNewVarWithDel++; - // return C_F0(TheOperators,"<-",New(k,t->NewVar(top)),t->Find("<-",args));} - return C_F0(TheOperators,"<-",basicAC_F0_wa(New(k,NewVariable(t,top,data)),args));} - -//inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const AC_F0 &args,const C_F0& ) -// { throwassert(0); return C_F0(TheOperators,"<-",New(k,NewVariable(t,top)),t->Find("<-",args));} - -template -inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top) - { // if( t-> ExistDestroy()) NbNewVarWithDel++; - return t->Initialization(New(k,NewVariable(t,top))); } - -// save a expression -inline C_F0 TableOfIdentifier::NewID(aType r,Key k, C_F0 & c,size_t &top, bool del ) - { // Add an expression in the list; - //(Par exemple: Uh ux; Maintenant on ajoute [[ux]] à la table des identifiants ou table des variables). - New(k,(make_pair(c.left(),c.LeftValue())),del);return 0; } - // { return r->Initialization(New(k,r->SetParam(c,ListOfId(),top),del));} - -inline C_F0 TableOfIdentifier::NewID(aType r,Key k, C_F0 & c,const ListOfId & l,size_t & top,bool del) - { return r->Initialization(New(k,r->SetParam(c,&l,top),del));} - +inline size_t align8(size_t &off) { + size_t o = off % 8; + off += o ? 8 - o : 0; + return off; +} + +template< class T > +inline Type_Expr NewVariable(aType t, size_t &off) { + size_t o = align8(off); // align + // off += t->un_ptr_type->size; + // bug off += t->size; + off += t->un_ptr_type->size; // correction 16/09/2003 merci a Richard MICHEL + return Type_Expr(t, new T(o, t)); +} + +template< class T > +inline Type_Expr NewVariable(aType t, size_t &off, const basicAC_F0 &args) { + size_t o = align8(off); // align + off += t->un_ptr_type->size; + return Type_Expr(t, new T(o, t, args)); +} + +template< class T, class U > +inline Type_Expr NewVariable(aType t, size_t &off, const U &data) { + size_t o = align8(off); // align + off += t->un_ptr_type->size; + return Type_Expr(t, new T(o, t, data)); +} +// extern int NbNewVarWithDel; // def in global.cpp sep 2016 FH. + +template< class T > +inline C_F0 TableOfIdentifier::NewVar(Key k, aType t, size_t &top, const C_F0 &i) { + // if( t-> ExistDestroy()) NbNewVarWithDel++; + return C_F0(TheOperators, "<-", New(k, NewVariable< T >(t, top)), i); +} + +template< class T > +inline C_F0 TableOfIdentifier::NewVar(Key k, aType t, size_t &top, const basicAC_F0 &args) { + // return C_F0(TheOperators,"<-",New(k,NewVariable(t,top)),t->Find("<-",args));} + // if( t-> ExistDestroy()) NbNewVarWithDel++; + return C_F0(TheOperators, "<-", basicAC_F0_wa(New(k, NewVariable< T >(t, top)), args)); +} + +template< class T > +inline C_F0 TableOfIdentifier::NewFESpace(Key k, aType t, size_t &top, const basicAC_F0 &args) { + return C_F0(TheOperators, "<-", basicAC_F0_wa(New(k, NewFESpace< T >(t, top, args)), args)); +} + +template< class T, class U > +inline C_F0 TableOfIdentifier::NewVar(Key k, aType t, size_t &top, const basicAC_F0 &args, const U &data) { + // if( t-> ExistDestroy()) NbNewVarWithDel++; + // return C_F0(TheOperators,"<-",New(k,t->NewVar(top)),t->Find("<-",args));} + return C_F0(TheOperators, "<-", basicAC_F0_wa(New(k, NewVariable< T, U >(t, top, data)), args)); +} + +// inline C_F0 TableOfIdentifier::NewVar(Key k,aType t,size_t & top,const AC_F0 &args,const C_F0& ) +// { throwassert(0); return C_F0(TheOperators,"<-",New(k,NewVariable(t,top)),t->Find("<-",args));} + +template< class T > +inline C_F0 TableOfIdentifier::NewVar(Key k, aType t, size_t &top) { // if( t-> ExistDestroy()) NbNewVarWithDel++; + return t->Initialization(New(k, NewVariable< T >(t, top))); +} + +// save a expression +inline C_F0 TableOfIdentifier::NewID(aType r, Key k, C_F0 &c, size_t &top, bool del) { // Add an expression in the list; + //(Par exemple: Uh ux; Maintenant on ajoute [[ux]] à la table des identifiants ou table des variables). + New(k, (make_pair< aType, E_F0 * >(c.left( ), c.LeftValue( ))), del); + return 0; +} +// { return r->Initialization(New(k,r->SetParam(c,ListOfId(),top),del));} + +inline C_F0 TableOfIdentifier::NewID(aType r, Key k, C_F0 &c, const ListOfId &l, size_t &top, bool del) { return r->Initialization(New(k, r->SetParam(c, &l, top), del)); } + /// <> allocated at [[file:global.cpp::tables_of_identifier]] -typedef list ListOfTOfId; -extern list tables_of_identifier; +typedef list< TableOfIdentifier * > ListOfTOfId; +extern list< TableOfIdentifier * > tables_of_identifier; /// [[file:AFunction2.cpp::Find]] -C_F0 Find(const char * name); - -inline C_F0 basicForEachType::Find(const char * k) const - { C_F0 r( ti.Find(k)); - //if (r.Empty()) {cerr << " no member " <MeshIndependent() && b->MeshIndependent();} -} ; - -inline C_F0::C_F0(const C_F0 & a,const C_F0 & b) - { // the concatenation - if (a.Empty()) - {r=b.r,f=b.f;} - else if (b.Empty()) - {r=a.r,f=b.f;} - else - {r=b.r; - f= new E_comma(a.f,b.f);} - } - -inline C_F0::C_F0(const C_F0 & e,const char *op, AC_F0 & p) - { *this=C_F0(e,op,(const basicAC_F0 &) p); - p.destroy(); - } -inline C_F0::C_F0(const Polymorphic * poly,const char *op, AC_F0 & p) - { *this=C_F0(poly,op,(const basicAC_F0 &) p); - p.destroy(); - } - -inline C_F0::C_F0(const C_F0 & e,const char *op,const basicAC_F0 & p) - { - const Polymorphic * pop=e; - if (pop) - { - //cerr << "poly: " << *pop << endl; - *this=C_F0(pop,op,p); - } - else { - // cerr << *e.r << " : table " << endl; - // e.r->ShowTable(cerr); - C_F0 x=e.r->Find(op); - - pop=x; - if(pop) - { - basicAC_F0_wa ep(e,p); - *this=C_F0(pop,"",ep); - } - else - { - cerr << " unknown operator " << op << " on type " << *e.r << endl; - CompileError(); - }} - } - -inline C_F0::C_F0(const C_F0 & e,const char *op,const C_F0 & a,const C_F0 & b) -{ - C_F0 tab[2]={a,b}; - basicAC_F0 p; - p=make_pair(2,tab); - *this= C_F0(e,op,p); +C_F0 Find(const char *name); + +inline C_F0 basicForEachType::Find(const char *k) const { + C_F0 r(ti.Find(k)); + // if (r.Empty()) {cerr << " no member " <> -inline C_F0::C_F0(const C_F0 & e,const char *op,const C_F0 & ee) -{ - const Polymorphic * pop=e; - if (pop) - { - // calls [[C_F0_constructor_binary_decl]] - *this=C_F0(pop,op,e,ee); +inline C_F0 basicForEachType::Find(const char *k, const basicAC_F0 &args) const { return ti.Find(k, args); } +inline C_F0 basicForEachType::Initialization(const Type_Expr &e) const { + if (!InitExp) { + cerr << "Internal Error: No Way to m Initialize this var type " << *this << endl; + CompileError( ); + } + return C_F0(new E_F0_Func1(InitExp, e.second), this); +} + +// inline AnyType Args2(const AnyType &,const AnyType & b) {return b;} +class E_comma : public E_F0 { + public: + Expression a, b; + E_comma(Expression aa, Expression bb) : a(aa), b(bb) {} + AnyType operator( )(Stack s) const { + (*a)(s); + return (*b)(s); + } + bool MeshIndependent( ) const { return a->MeshIndependent( ) && b->MeshIndependent( ); } +}; + +inline C_F0::C_F0(const C_F0 &a, const C_F0 &b) { // the concatenation + if (a.Empty( )) { + r = b.r, f = b.f; + } else if (b.Empty( )) { + r = a.r, f = b.f; + } else { + r = b.r; + f = new E_comma(a.f, b.f); + } +} + +inline C_F0::C_F0(const C_F0 &e, const char *op, AC_F0 &p) { + *this = C_F0(e, op, (const basicAC_F0 &)p); + p.destroy( ); +} +inline C_F0::C_F0(const Polymorphic *poly, const char *op, AC_F0 &p) { + *this = C_F0(poly, op, (const basicAC_F0 &)p); + p.destroy( ); +} + +inline C_F0::C_F0(const C_F0 &e, const char *op, const basicAC_F0 &p) { + const Polymorphic *pop = e; + if (pop) { + // cerr << "poly: " << *pop << endl; + *this = C_F0(pop, op, p); + } else { + // cerr << *e.r << " : table " << endl; + // e.r->ShowTable(cerr); + C_F0 x = e.r->Find(op); + + pop = x; + if (pop) { + basicAC_F0_wa ep(e, p); + *this = C_F0(pop, "", ep); + } else { + cerr << " unknown operator " << op << " on type " << *e.r << endl; + CompileError( ); } - else { + } +} + +inline C_F0::C_F0(const C_F0 &e, const char *op, const C_F0 &a, const C_F0 &b) { + C_F0 tab[2] = {a, b}; + basicAC_F0 p; + p = make_pair(2, tab); + *this = C_F0(e, op, p); +} + +/// <> +inline C_F0::C_F0(const C_F0 &e, const char *op, const C_F0 &ee) { + const Polymorphic *pop = e; + if (pop) { + // calls [[C_F0_constructor_binary_decl]] + *this = C_F0(pop, op, e, ee); + } else { // cerr << *e.r << " : table " << endl; // e.r->ShowTable(cerr); - C_F0 x=e.r->Find(op); - pop=x; - if(pop) - *this=C_F0(pop,"",e,ee); - else - { - cerr << " unknown operator " << op << " on type " << *e.r << " " << *ee.r<< endl; - CompileError(); - } - } -} - -inline C_F0::C_F0(const C_F0 & e,const char *nm) - { - // cerr << " C_F0(const C_F0 & e,const char *item) : " << " " << nm << endl; - C_F0 x=e.r->Find(nm); - const Polymorphic * pop=x; - // cerr << "Find " << *pop << endl; - if (pop) - *this=C_F0(pop,".",e); // unary oper . - else - { - cerr << " No operator ." << nm << " for type " << *e.r << endl; - lgerror(""); - } - - } -inline E_F0 * C_F0::LeftValue() const { - return f; + C_F0 x = e.r->Find(op); + pop = x; + if (pop) + *this = C_F0(pop, "", e, ee); + else { + cerr << " unknown operator " << op << " on type " << *e.r << " " << *ee.r << endl; + CompileError( ); + } + } } +inline C_F0::C_F0(const C_F0 &e, const char *nm) { + // cerr << " C_F0(const C_F0 & e,const char *item) : " << " " << nm << endl; + C_F0 x = e.r->Find(nm); + const Polymorphic *pop = x; + // cerr << "Find " << *pop << endl; + if (pop) + *this = C_F0(pop, ".", e); // unary oper . + else { + cerr << " No operator ." << nm << " for type " << *e.r << endl; + lgerror(""); + } +} +inline E_F0 *C_F0::LeftValue( ) const { return f; } + /*inline Type_Expr C_F0::SetParam(const ListOfId * l,size_t & top) const { return r->SetParam(*this,l,top); }*/ - /// Declaration of TypeArray -aType TypeArray(aType,aType); -aType TypeArray(aType c,aType b,aType a); +aType TypeArray(aType, aType); +aType TypeArray(aType c, aType b, aType a); /// Declaration of TypeTemplate -aType TypeTemplate(aType,aType); +aType TypeTemplate(aType, aType); -void Init_map_type(); +void Init_map_type( ); /// <> -class Block { // - static size_t Max(size_t a,size_t b){ return a < b ? b :a;} - typedef const char * Key; - Block * fatherblock; - size_t top,topmax; - TableOfIdentifier table; - ListOfTOfId::iterator itabl; - -public: - // list of variable - size_t OffSet(size_t ssize) { - top=align8(top); - size_t r=top; top+=ssize ;topmax=Max(topmax,top); - return r;} - Block(Block * f=0); -/* :fatherblock(f),top(f?f->top:BeginOffset*sizeof(void*)),topmax(top) - { - itabl=tables_of_identifier.insert(tables_of_identifier.begin(),&table); - }*/ - size_t size() const { return Max(topmax,top);} - void Add(Key k,Key op,OneOperator *p0) - { table.Add(k,op,p0);} +class Block { // + static size_t Max(size_t a, size_t b) { return a < b ? b : a; } + typedef const char *Key; + Block *fatherblock; + size_t top, topmax; + TableOfIdentifier table; + ListOfTOfId::iterator itabl; + + public: + // list of variable + size_t OffSet(size_t ssize) { + top = align8(top); + size_t r = top; + top += ssize; + topmax = Max(topmax, top); + return r; + } + Block(Block *f = 0); + /* :fatherblock(f),top(f?f->top:BeginOffset*sizeof(void*)),topmax(top) + { + itabl=tables_of_identifier.insert(tables_of_identifier.begin(),&table); + }*/ + size_t size( ) const { return Max(topmax, top); } + void Add(Key k, Key op, OneOperator *p0) { table.Add(k, op, p0); } // <> - -template - C_F0 NewVar(Key k,aType t,const C_F0 &i) - {return table.NewVar(k, t,top,i);} -/*template - C_F0 NewFESpace(Key k,aType t,const basicAC_F0 &args) - {return table.NewFESpace(k, t,top,args);}*/ -template - C_F0 NewVar(Key k,aType t, AC_F0 &args) - {C_F0 r= table.NewVar(k, t,top,args); - args.destroy(); - topmax=Max(topmax,top); - return r;} -template - C_F0 NewVar(Key k,aType t,const basicAC_F0 &args) - {C_F0 r= table.NewVar(k, t,top,args); - topmax=Max(topmax,top); - return r;} -template - C_F0 NewVar(Key k,aType t,const basicAC_F0 &args,const U & data) - {C_F0 r= table.NewVar(k, t,top,args,data); - topmax=Max(topmax,top); - return r;} -// C_F0 NewVar(Key k,aType t,const AC_F0 &args,const C_F0 & f) -// {return table.NewVar(k, t,top,args,f);} -template - C_F0 NewVar(Key k,aType t) - {C_F0 r= table.NewVar(k, t,top); - topmax=Max(topmax,top); - return r; - } - // C_F0 NewVar(aType t,Key k,C_F0 f) + template< class T > + C_F0 NewVar(Key k, aType t, const C_F0 &i) { + return table.NewVar< T >(k, t, top, i); + } + /*template + C_F0 NewFESpace(Key k,aType t,const basicAC_F0 &args) + {return table.NewFESpace(k, t,top,args);}*/ + template< class T > + C_F0 NewVar(Key k, aType t, AC_F0 &args) { + C_F0 r = table.NewVar< T >(k, t, top, args); + args.destroy( ); + topmax = Max(topmax, top); + return r; + } + template< class T > + C_F0 NewVar(Key k, aType t, const basicAC_F0 &args) { + C_F0 r = table.NewVar< T >(k, t, top, args); + topmax = Max(topmax, top); + return r; + } + template< class T, class U > + C_F0 NewVar(Key k, aType t, const basicAC_F0 &args, const U &data) { + C_F0 r = table.NewVar< T, U >(k, t, top, args, data); + topmax = Max(topmax, top); + return r; + } + // C_F0 NewVar(Key k,aType t,const AC_F0 &args,const C_F0 & f) + // {return table.NewVar(k, t,top,args,f);} + template< class T > + C_F0 NewVar(Key k, aType t) { + C_F0 r = table.NewVar< T >(k, t, top); + topmax = Max(topmax, top); + return r; + } + + // C_F0 NewVar(aType t,Key k,C_F0 f) // {return table.NewVar(t,k, f);} - C_F0 NewID(aType t,Key k,C_F0 f,bool del=true) - {C_F0 r= table.NewID(t,k, f,top,del); - topmax=Max(topmax,top); - return r;} - C_F0 NewID(aType t,Key k,C_F0 f,const ListOfId & l,bool del=true) - {C_F0 r= table.NewID(t,k,f,l,top,del); - topmax=Max(topmax,top); - return r;} - - static Block * open(Block *& c); - static vectorOfInst * snewclose(Block *& c); - //vectorOfInst * newclose(Block *& c) ;// sep 2016 FH - - static CC_F0 close(Block *& c,C_F0 ); - static CC_F0 close(Block *& c,CListOfInst ); /* { - tables_of_identifier.erase(itabl); - c=fatherblock; - if (fatherblock) {fatherblock->topmax=topmax; - fatherblock->top=top;} - - CC_F0 r; - r = table.destroy(); - delete this; - return r;}*/ - C_F0 Find(const char * k) const {return table.Find(k);} - ~Block(); //{} - int nIdWithDelete() const { return table.nIdWithDelete;} -}; + C_F0 NewID(aType t, Key k, C_F0 f, bool del = true) { + C_F0 r = table.NewID(t, k, f, top, del); + topmax = Max(topmax, top); + return r; + } + C_F0 NewID(aType t, Key k, C_F0 f, const ListOfId &l, bool del = true) { + C_F0 r = table.NewID(t, k, f, l, top, del); + topmax = Max(topmax, top); + return r; + } + static Block *open(Block *&c); + static vectorOfInst *snewclose(Block *&c); + // vectorOfInst * newclose(Block *& c) ;// sep 2016 FH + static CC_F0 close(Block *&c, C_F0); + static CC_F0 close(Block *&c, CListOfInst); /* { + tables_of_identifier.erase(itabl); + c=fatherblock; + if (fatherblock) {fatherblock->topmax=topmax; + fatherblock->top=top;} + + CC_F0 r; + r = table.destroy(); + delete this; + return r;}*/ + C_F0 Find(const char *k) const { return table.Find(k); } + ~Block( ); //{} + int nIdWithDelete( ) const { return table.nIdWithDelete; } +}; /// <> To know the meaning of OneOperator name extensions, see [[OneOperator]]. The template arguments to /// OneOperator classes are identical to the types of the arguments of the C++ function that is called from the /// class. The matrices are of type KNM* or KNM** (for left-side expressions, but this is "more /// tricky") which correspond to a real[int,int] in the edp script. -template > -class OneOperator1 : public OneOperator { - aType r,t0; // return type - typedef typename CODE::func func; // R (*func)(A) ; - func f; - public: - - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(f,t0->CastTo(args[0]));} - - OneOperator1(func ff,int ppref=0): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]), - t0( map_type[typeid(A).name()] ), f(ff) {pref=ppref;} - - OneOperator1(func ff,aType tt0,int ppref=0): - OneOperator(map_type[typeid(R).name()],tt0), - t0( map_type[typeid(A).name()] ), f(ff) {pref=ppref;} -}; - - -template > -class OneOperator2 : public OneOperator { - aType r,t0,t1; // return type - typedef typename CODE::func func; - func f; - public: +template< class R, class A = R, class CODE = E_F_F0< R, A > > +class OneOperator1 : public OneOperator { + aType r, t0; // return type + typedef typename CODE::func func; // R (*func)(A) ; + func f; - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(f,t0->CastTo(args[0]),t1->CastTo(args[1]));} + public: + E_F0 *code(const basicAC_F0 &args) const { return new CODE(f, t0->CastTo(args[0])); } - OneOperator2(func ff,int ppref=0): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]), - t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) { - pref=ppref; - } - - OneOperator2(func ff,aType tt0,aType tt1): - OneOperator(map_type[typeid(R).name()],tt0,tt1), - t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {} - + OneOperator1(func ff, int ppref = 0) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )]), t0(map_type[typeid(A).name( )]), f(ff) { pref = ppref; } + + OneOperator1(func ff, aType tt0, int ppref = 0) : OneOperator(map_type[typeid(R).name( )], tt0), t0(map_type[typeid(A).name( )]), f(ff) { pref = ppref; } +}; + +template< class R, class A = R, class B = A, class CODE = E_F_F0F0< R, A, B > > +class OneOperator2 : public OneOperator { + aType r, t0, t1; // return type + typedef typename CODE::func func; + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { return new CODE(f, t0->CastTo(args[0]), t1->CastTo(args[1])); } + + OneOperator2(func ff, int ppref = 0) + : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]), f(ff) { + pref = ppref; + } + + OneOperator2(func ff, aType tt0, aType tt1) : OneOperator(map_type[typeid(R).name( )], tt0, tt1), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]), f(ff) {} }; /*template @@ -2300,450 +2414,402 @@ struct OneBinaryOperator_Traits { typedef C::second_argument_type B; };*/ // the greatest pref win ... -template struct SameType { static const int OK=0;}; -template struct SameType { static const int OK=1;}; -template<> struct SameType { static const int OK=10;}; -//template<> struct SameType { static const int OK=19;}; -//template<> struct SameType { static const int OK=19;}; -template<> struct SameType { static const int OK=20;}; -template<> struct SameType { static const int OK=30;}; -template<> struct SameType { static const int OK=40;}; -//template<> struct SameType { static const int OK=43;}; -//template<> struct SameType { static const int OK=43;}; -//template<> struct SameType { static const int OK=42;}; -//template<> struct SameType { static const int OK=42;}; -//template<> struct SameType { static const int OK=41;}; -//template<> struct SameType { static const int OK=41;}; -template<> struct SameType { static const int OK=50;}; - -template -struct mybinary_function -{ - typedef Arg1 first_argument_type; - typedef Arg2 second_argument_type; - typedef Result result_type; -}; - -template -struct ternary_function -{ - typedef Arg1 first_argument_type; - typedef Arg2 second_argument_type; - typedef Arg3 third_argument_type; - typedef Result result_type; -}; - -template -struct quad_function -{ - typedef Arg1 first_argument_type; - typedef Arg2 second_argument_type; - typedef Arg3 third_argument_type; - typedef Arg4 fourth_argument_type; - typedef Result result_type; -}; - -template -class OneBinaryOperatorCode : public OneOperator{ +template< class A, class B > +struct SameType { + static const int OK = 0; +}; +template< class A > +struct SameType< A, A > { + static const int OK = 1; +}; +template<> +struct SameType< bool, bool > { + static const int OK = 10; +}; +// template<> struct SameType { static const int OK=19;}; +// template<> struct SameType { static const int OK=19;}; +template<> +struct SameType< long, long > { + static const int OK = 20; +}; +template<> +struct SameType< double, double > { + static const int OK = 30; +}; +template<> +struct SameType< Complex, Complex > { + static const int OK = 40; +}; +// template<> struct SameType { static const int OK=43;}; +// template<> struct SameType { static const int OK=43;}; +// template<> struct SameType { static const int OK=42;}; +// template<> struct SameType { static const int OK=42;}; +// template<> struct SameType { static const int OK=41;}; +// template<> struct SameType { static const int OK=41;}; +template<> +struct SameType< string *, string * > { + static const int OK = 50; +}; + +template< typename Arg1, typename Arg2, class Result > +struct mybinary_function { + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Result result_type; +}; + +template< typename Arg1, typename Arg2, typename Arg3, class Result > +struct ternary_function { + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Arg3 third_argument_type; + typedef Result result_type; +}; + +template< typename Arg1, typename Arg2, typename Arg3, typename Arg4, class Result > +struct quad_function { + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Arg3 third_argument_type; + typedef Arg4 fourth_argument_type; + typedef Result result_type; +}; + +template< typename T, class CODE > +class OneBinaryOperatorCode : public OneOperator { typedef typename T::result_type R; typedef typename T::first_argument_type A; typedef typename T::second_argument_type B; -/* - class Op : public E_F0 { - typedef typename T::result_type Result; - Expression a,b; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(::f( GetAny((*a)(s)) , - GetAny((*b)(s)) - );} - Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {} - bool MeshIndependent() const { - return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();} - }; -*/ - public: - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]));} - OneBinaryOperatorCode(): - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()] - ) {} -}; -template -class OneTernaryOperator : public OneOperator{ + /* + class Op : public E_F0 { + typedef typename T::result_type Result; + Expression a,b; + public: + AnyType operator()(Stack s) const + {return SetAny(static_cast(::f( GetAny((*a)(s)) , + GetAny((*b)(s)) + );} + Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {} + bool MeshIndependent() const { + return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();} + }; + */ + public: + E_F0 *code(const basicAC_F0 &args) const { return new CODE(t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } + OneBinaryOperatorCode( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]) {} +}; +template< typename T, class CODE > +class OneTernaryOperator : public OneOperator { typedef typename T::result_type R; typedef typename T::first_argument_type A; typedef typename T::second_argument_type B; typedef typename T::third_argument_type C; -/* - class Op : public E_F0 { - typedef typename T::result_type Result; - Expression a,b,c; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(C::f( GetAny((*a)(s)) , - GetAny((*b)(s)) , - GetAny((*c)(s)))));} - Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {} - bool MeshIndependent() const { - return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();} - }; -*/ - public: - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));} - OneTernaryOperator(): - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()]) {} -}; - -template -class OneQuadOperator : public OneOperator{ + /* + class Op : public E_F0 { + typedef typename T::result_type Result; + Expression a,b,c; + public: + AnyType operator()(Stack s) const + {return SetAny(static_cast(C::f( GetAny((*a)(s)) , + GetAny((*b)(s)) , + GetAny((*c)(s)))));} + Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {} + bool MeshIndependent() const { + return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();} + }; + */ + public: + E_F0 *code(const basicAC_F0 &args) const { return new CODE(t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + OneTernaryOperator( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )]) {} +}; + +template< typename T, class CODE > +class OneQuadOperator : public OneOperator { typedef typename T::result_type R; typedef typename T::first_argument_type A; typedef typename T::second_argument_type B; typedef typename T::third_argument_type C; typedef typename T::fourth_argument_type D; -/* - class Op : public E_F0 { - typedef typename T::result_type Result; - Expression a,b,c,d; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(T::f( GetAny((*a)(s)) , - GetAny((*b)(s)) , - GetAny((*c)(s)), - GetAny((*d)(s)) - )));} - Op(Expression aa,Expression bb,Expression cc,Expression dd) : a(aa),b(bb),c(cc),d(dd) {} - bool MeshIndependent() const { - return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent() && d->MeshIndependent();} - }; - */ -public: - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]),t[3]->CastTo(args[3]));} - OneQuadOperator(): - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()] - ) {} + /* + class Op : public E_F0 { + typedef typename T::result_type Result; + Expression a,b,c,d; + public: + AnyType operator()(Stack s) const + {return SetAny(static_cast(T::f( GetAny((*a)(s)) , + GetAny((*b)(s)) , + GetAny((*c)(s)), + GetAny((*d)(s)) + )));} + Op(Expression aa,Expression bb,Expression cc,Expression dd) : a(aa),b(bb),c(cc),d(dd) {} + bool MeshIndependent() const { + return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent() && d->MeshIndependent();} + }; + */ + public: + E_F0 *code(const basicAC_F0 &args) const { return new CODE(t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } + OneQuadOperator( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )]) {} }; - -template -class OneTernaryOperator3 : public OneOperator{ +template< typename T > +class OneTernaryOperator3 : public OneOperator { typedef typename T::result_type R; typedef typename T::first_argument_type A; typedef typename T::second_argument_type B; typedef typename T::third_argument_type C; - class Op : public E_F0 { - // typedef typename C::result_type Result; - Expression a,b,c; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(T::f( s, GetAny((*a)(s)) , - GetAny((*b)(s)) , - GetAny((*c)(s)))));} - Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc) {} - bool MeshIndependent() const { return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent();} - - }; - - public: - E_F0 * code(const basicAC_F0 & args) const - { return new Op(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));} - OneTernaryOperator3(): - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()]) {} -}; - + class Op : public E_F0 { + // typedef typename C::result_type Result; + Expression a, b, c; + public: + AnyType operator( )(Stack s) const { return SetAny< R >(static_cast< R >(T::f(s, GetAny< A >((*a)(s)), GetAny< B >((*b)(s)), GetAny< C >((*c)(s))))); } + Op(Expression aa, Expression bb, Expression cc) : a(aa), b(bb), c(cc) {} + bool MeshIndependent( ) const { return a->MeshIndependent( ) && b->MeshIndependent( ) && c->MeshIndependent( ); } + }; + public: + E_F0 *code(const basicAC_F0 &args) const { return new Op(t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } + OneTernaryOperator3( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )]) {} +}; struct OneBinaryOperatorMI { - static bool MeshIndependent(Expression a,Expression b) { return a->MeshIndependent() && b->MeshIndependent();} - static bool ReadOnly() { return true;} + static bool MeshIndependent(Expression a, Expression b) { return a->MeshIndependent( ) && b->MeshIndependent( ); } + static bool ReadOnly( ) { return true; } }; struct OneBinaryOperatorMIWO { - static bool MeshIndependent(Expression a,Expression b) { return a->MeshIndependent() && b->MeshIndependent();} - static bool ReadOnly() { return false;} + static bool MeshIndependent(Expression a, Expression b) { return a->MeshIndependent( ) && b->MeshIndependent( ); } + static bool ReadOnly( ) { return false; } }; // ---------- operator with stack ??? for auto delete -template -class OneBinaryOperator_st : public OneOperator{ - typedef typename C::result_type R; +template< typename C, class MI = OneBinaryOperatorMI > +class OneBinaryOperator_st : public OneOperator { + typedef typename C::result_type R; typedef typename C::first_argument_type A; typedef typename C::second_argument_type B; - aType t0,t1; // type of template modif FH mars 2006 + aType t0, t1; // type of template modif FH mars 2006 class Op : public E_F0 { - typedef typename C::result_type Result; - Expression a,b; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(C::f(s, GetAny((*a)(s)) , GetAny((*b)(s)))));} - Op(Expression aa,Expression bb) : a(aa),b(bb) {} - bool MeshIndependent() const { return MI::MeshIndependent(a,b);} - bool ReadOnly() const { return MI::ReadOnly() ;} - int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { + typedef typename C::result_type Result; + Expression a, b; + + public: + AnyType operator( )(Stack s) const { return SetAny< R >(static_cast< R >(C::f(s, GetAny< A >((*a)(s)), GetAny< B >((*b)(s))))); } + Op(Expression aa, Expression bb) : a(aa), b(bb) {} + bool MeshIndependent( ) const { return MI::MeshIndependent(a, b); } + bool ReadOnly( ) const { return MI::ReadOnly( ); } + int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { int rr = find(m); - if (rr) return rr; - int Opa = a->Optimize(l,m,n); - int Opb =b->Optimize(l,m,n); - return insert(new Opt(*this,Opa,Opb),l,m,n); - } - int compare (const E_F0 *t) const { + if (rr) return rr; + int Opa = a->Optimize(l, m, n); + int Opb = b->Optimize(l, m, n); + return insert(new Opt(*this, Opa, Opb), l, m, n); + } + int compare(const E_F0 *t) const { int rr; - const Op * tt=dynamic_cast(t); - if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b)); - else rr = E_F0::compare(t); + const Op *tt = dynamic_cast< const Op * >(t); + if (tt) + rr = clexico(a->compare(tt->a), b->compare(tt->b)); + else + rr = E_F0::compare(t); // cout << "cmp E_F0_Func1 " << rr << endl; return rr; - } // to give a order in instuction + } // to give a order in instuction // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation - - virtual ostream & dump(ostream &f) const { - f << "Op<" << typeid(C).name() - << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ; - return f; } + + virtual ostream &dump(ostream &f) const { + f << "Op<" << typeid(C).name( ) << "> \n\t\t\t( a= " << *a << ") \n\t\t\t(b= " << *b << ") "; + return f; + } }; - // build optimisation - class Opt: public Op { public : - size_t ia,ib; - Opt(const Op &t,size_t iaa,size_t ibb) - : Op(t) , - ia(iaa),ib(ibb) {} - AnyType operator()(Stack s) const - { - // cout << "Opt2 ::: " << ia << " "<< ib << " f = " - // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , + // build optimisation + class Opt : public Op { + public: + size_t ia, ib; + Opt(const Op &t, size_t iaa, size_t ibb) : Op(t), ia(iaa), ib(ibb) {} + AnyType operator( )(Stack s) const { + // cout << "Opt2 ::: " << ia << " "<< ib << " f = " + // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , // *static_cast(static_cast(static_cast(s)+ib))))) << endl; - - - return SetAny( C::f(s, *static_cast(static_cast(static_cast(s)+ia)) , - *static_cast(static_cast(static_cast(s)+ib)) ) );} - - - }; - // aType r; // return type -public: - E_F0 * code(const basicAC_F0 & args) const - { //cout << "A op B \n" ; - return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));} - OneBinaryOperator_st(): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]), - t0(t[0]), - t1(t[1]) - {pref = SameType::OK ;} - - OneBinaryOperator_st(aType tt0,aType tt1): - OneOperator(map_type[typeid(R).name()], - tt0 ? tt0 : map_type[typeid(A).name()] , - tt1 ? tt1 : map_type[typeid(B).name()]), - t0(map_type[typeid(A).name()]), - t1(map_type[typeid(B).name()]) - {pref = SameType::OK ;} + return SetAny< R >(C::f(s, *static_cast< A * >(static_cast< void * >(static_cast< char * >(s) + ia)), *static_cast< B * >(static_cast< void * >(static_cast< char * >(s) + ib)))); + } + }; + // aType r; // return type + public: + E_F0 *code(const basicAC_F0 &args) const { // cout << "A op B \n" ; + return new Op(t0->CastTo(args[0]), t1->CastTo(args[1])); + } + OneBinaryOperator_st( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(t[0]), t1(t[1]) { pref = SameType< A, B >::OK; } + + OneBinaryOperator_st(aType tt0, aType tt1) + : OneOperator(map_type[typeid(R).name( )], tt0 ? tt0 : map_type[typeid(A).name( )], tt1 ? tt1 : map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]) { + pref = SameType< A, B >::OK; + } }; struct evalE_F2 { - static AnyType eval(Stack s,const E_F0 * ab,const E_F0 * a,const E_F0 * b, bool & meshidenp) - { - return ab->E_F0::eval(s,meshidenp); - } -}; - -// Add FH juin 2020 -template -class OneBinaryOperatorBug : public OneOperator{ - typedef bool R; -public: - E_F0 * code(const basicAC_F0 & args) const - { //cout << "A op B \n" ; - cout << " Error expression impossible between "<< typeid(A).name() << " , "< -class OneBinaryOperator : public OneOperator{ - typedef typename C::result_type R; + static AnyType eval(Stack s, const E_F0 *ab, const E_F0 *a, const E_F0 *b, bool &meshidenp) { return ab->E_F0::eval(s, meshidenp); } +}; + +// Add FH juin 2020 +template< typename A, typename B > +class OneBinaryOperatorBug : public OneOperator { + typedef bool R; + + public: + E_F0 *code(const basicAC_F0 &args) const { // cout << "A op B \n" ; + cout << " Error expression impossible between " << typeid(A).name( ) << " , " << typeid(B).name( ) << endl; + CompileError(" Expression must return bad type!!!"); + return 0; + } + OneBinaryOperatorBug( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]) { pref = 100; } +}; +template< typename C, class MI = OneBinaryOperatorMI, class MIx = evalE_F2 > +class OneBinaryOperator : public OneOperator { + typedef typename C::result_type R; typedef typename C::first_argument_type A; typedef typename C::second_argument_type B; - aType t0,t1; // type of template modif FH mars 2006 + aType t0, t1; // type of template modif FH mars 2006 class Op : public E_F0 { - typedef typename C::first_argument_type A; - typedef typename C::second_argument_type B; - typedef typename C::result_type Result; - Expression a,b; - public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(C::f( GetAny((*a)(s)) , GetAny((*b)(s)))));} + typedef typename C::first_argument_type A; + typedef typename C::second_argument_type B; + typedef typename C::result_type Result; + Expression a, b; + + public: + AnyType operator( )(Stack s) const { return SetAny< R >(static_cast< R >(C::f(GetAny< A >((*a)(s)), GetAny< B >((*b)(s))))); } // optim eval MI ... juin 2007 FH ... - AnyType eval(Stack s, bool & meshidenp) const - {return MIx::eval(s,this,a,b,meshidenp);} - // fi optime - Op(Expression aa,Expression bb) : a(aa),b(bb) {} - bool MeshIndependent() const { return MI::MeshIndependent(a,b);} - bool ReadOnly() const { return MI::ReadOnly() ;} - int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { + AnyType eval(Stack s, bool &meshidenp) const { return MIx::eval(s, this, a, b, meshidenp); } + // fi optime + Op(Expression aa, Expression bb) : a(aa), b(bb) {} + bool MeshIndependent( ) const { return MI::MeshIndependent(a, b); } + bool ReadOnly( ) const { return MI::ReadOnly( ); } + int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { int rr = find(m); - if (rr) return rr; - int Opa = a->Optimize(l,m,n); - int Opb =b->Optimize(l,m,n); - return insert(new Opt(*this,Opa,Opb),l,m,n); - } - int compare (const E_F0 *t) const { + if (rr) return rr; + int Opa = a->Optimize(l, m, n); + int Opb = b->Optimize(l, m, n); + return insert(new Opt(*this, Opa, Opb), l, m, n); + } + int compare(const E_F0 *t) const { int rr; - const Op * tt=dynamic_cast(t); - if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b)); - else rr = E_F0::compare(t); + const Op *tt = dynamic_cast< const Op * >(t); + if (tt) + rr = clexico(a->compare(tt->a), b->compare(tt->b)); + else + rr = E_F0::compare(t); // cout << "cmp E_F0_Func1 " << rr << endl; return rr; - } // to give a order in instuction + } // to give a order in instuction // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation - - virtual ostream & dump(ostream &f) const { - f << "Op<" << typeid(C).name() - << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ; - return f; } + + virtual ostream &dump(ostream &f) const { + f << "Op<" << typeid(C).name( ) << "> \n\t\t\t( a= " << *a << ") \n\t\t\t(b= " << *b << ") "; + return f; + } }; - // build optimisation - class Opt: public Op { public : - size_t ia,ib; - Opt(const Op &t,size_t iaa,size_t ibb) - : Op(t) , - ia(iaa),ib(ibb) {} - AnyType operator()(Stack s) const - { - // cout << "Opt2 ::: " << ia << " "<< ib << " f = " - // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , + // build optimisation + class Opt : public Op { + public: + size_t ia, ib; + Opt(const Op &t, size_t iaa, size_t ibb) : Op(t), ia(iaa), ib(ibb) {} + AnyType operator( )(Stack s) const { + // cout << "Opt2 ::: " << ia << " "<< ib << " f = " + // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , // *static_cast(static_cast(static_cast(s)+ib))))) << endl; - - - return SetAny( C::f( *static_cast(static_cast(static_cast(s)+ia)) , - *static_cast(static_cast(static_cast(s)+ib)) ) );} - - - }; - // aType r; // return type -public: - E_F0 * code(const basicAC_F0 & args) const - { //cout << "A op B \n" ; - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));} - OneBinaryOperator(int ppref=0): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]), - t0(t[0]), - t1(t[1]) - {pref = ppref+SameType::OK ;} - - OneBinaryOperator(aType tt0,aType tt1): - OneOperator(map_type[typeid(R).name()], - tt0 ? tt0 : map_type[typeid(A).name()] , - tt1 ? tt1 : map_type[typeid(B).name()]), - t0(map_type[typeid(A).name()]), - t1(map_type[typeid(B).name()]) - {pref = SameType::OK ;} + return SetAny< R >(C::f(*static_cast< A * >(static_cast< void * >(static_cast< char * >(s) + ia)), *static_cast< B * >(static_cast< void * >(static_cast< char * >(s) + ib)))); + } + }; + // aType r; // return type + public: + E_F0 *code(const basicAC_F0 &args) const { // cout << "A op B \n" ; + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new Op(t0->CastTo(args[0]), t1->CastTo(args[1])); + } + OneBinaryOperator(int ppref = 0) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(t[0]), t1(t[1]) { pref = ppref + SameType< A, B >::OK; } + + OneBinaryOperator(aType tt0, aType tt1) + : OneOperator(map_type[typeid(R).name( )], tt0 ? tt0 : map_type[typeid(A).name( )], tt1 ? tt1 : map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]) { + pref = SameType< A, B >::OK; + } }; //------------- -template -class Operator_Aritm_If : public OneOperator{ - typedef bool A; - typedef R B; - typedef R C; +template< typename R > +class Operator_Aritm_If : public OneOperator { + typedef bool A; + typedef R B; + typedef R C; class Op : public E_F0 { - typedef R Result; - Expression a,b,c; - public: - AnyType operator()(Stack s) const - { - bool ok = GetAny((*a)(s)) ; - R r ; - if( ok) r=GetAny((*b)(s)) ; - else r =GetAny((*c)(s)) ; - return SetAny(r);// static_cast( ? GetAny((*b)(s)) : GetAny((*c)(s)) )); - } - Op(Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc){} - bool MeshIndependent() const { return a->MeshIndependent() && b->MeshIndependent() &&b->MeshIndependent() ;} - int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { + typedef R Result; + Expression a, b, c; + + public: + AnyType operator( )(Stack s) const { + bool ok = GetAny< bool >((*a)(s)); + R r; + if (ok) + r = GetAny< B >((*b)(s)); + else + r = GetAny< C >((*c)(s)); + return SetAny< R >(r); // static_cast( ? GetAny((*b)(s)) : GetAny((*c)(s)) )); + } + Op(Expression aa, Expression bb, Expression cc) : a(aa), b(bb), c(cc) {} + bool MeshIndependent( ) const { return a->MeshIndependent( ) && b->MeshIndependent( ) && b->MeshIndependent( ); } + int Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { int rr = find(m); - if (rr) return rr; - int Opa = a->Optimize(l,m,n); - int Opb =b->Optimize(l,m,n); - int Opc =c->Optimize(l,m,n); - return insert(new Opt(*this,Opa,Opb,Opc),l,m,n); - } - int compare (const E_F0 *t) const { + if (rr) return rr; + int Opa = a->Optimize(l, m, n); + int Opb = b->Optimize(l, m, n); + int Opc = c->Optimize(l, m, n); + return insert(new Opt(*this, Opa, Opb, Opc), l, m, n); + } + int compare(const E_F0 *t) const { int rr; - const Op * tt=dynamic_cast(t); - if (tt ) rr = clexico(a->compare(tt->a),b->compare(tt->b),c->compare(tt->c)); - else rr = E_F0::compare(t); + const Op *tt = dynamic_cast< const Op * >(t); + if (tt) + rr = clexico(a->compare(tt->a), b->compare(tt->b), c->compare(tt->c)); + else + rr = E_F0::compare(t); // cout << "cmp E_F0_Func1 " << rr << endl; return rr; - } // to give a order in instuction + } // to give a order in instuction // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation - - virtual ostream & dump(ostream &f) const { - f << "Op<" << typeid(C).name() - << "> \n\t\t\t( a= "<< *a<< ") \n\t\t\t(b= "<< *b << ") " ; - return f; } + + virtual ostream &dump(ostream &f) const { + f << "Op<" << typeid(C).name( ) << "> \n\t\t\t( a= " << *a << ") \n\t\t\t(b= " << *b << ") "; + return f; + } }; - // build optimisation - class Opt: public Op { public : - size_t ia,ib,ic; - Opt(const Op &t,size_t iaa,size_t ibb,size_t icc) - : Op(t) , - ia(iaa),ib(ibb),ic(icc) {} - AnyType operator()(Stack s) const - { - // cout << "Opt2 ::: " << ia << " "<< ib << " f = " - // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , + // build optimisation + class Opt : public Op { + public: + size_t ia, ib, ic; + Opt(const Op &t, size_t iaa, size_t ibb, size_t icc) : Op(t), ia(iaa), ib(ibb), ic(icc) {} + AnyType operator( )(Stack s) const { + // cout << "Opt2 ::: " << ia << " "<< ib << " f = " + // << GetAny(SetAny(C::f( *static_cast(static_cast(static_cast(s)+ia)) , // *static_cast(static_cast(static_cast(s)+ib))))) << endl; - - - return SetAny( - static_cast ( - *static_cast(static_cast(static_cast(s)+ia)) ? - *static_cast(static_cast(static_cast(s)+ib)) : - *static_cast(static_cast(static_cast(s)+ic)) ) );} - - - }; - // aType r; // return type -public: - E_F0 * code(const basicAC_F0 & args) const - { //cout << "A op B \n" ; - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - return new Op(t[0]->CastTo(args[0]),t[1]->CastTo(args[1]),t[2]->CastTo(args[2]));} - Operator_Aritm_If(): - OneOperator(map_type[typeid(R).name()],map_type[typeid(bool).name()],map_type[typeid(B).name()],map_type[typeid(B).name()]) - {pref = SameType::OK ;} -}; - -/* essai d'unification des classes - -template + + return SetAny< R >(static_cast< R >(*static_cast< bool * >(static_cast< void * >(static_cast< char * >(s) + ia)) ? *static_cast< B * >(static_cast< void * >(static_cast< char * >(s) + ib)) + : *static_cast< C * >(static_cast< void * >(static_cast< char * >(s) + ic)))); + } + }; + // aType r; // return type + public: + E_F0 *code(const basicAC_F0 &args) const { // cout << "A op B \n" ; + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + return new Op(t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); + } + Operator_Aritm_If( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(bool).name( )], map_type[typeid(B).name( )], map_type[typeid(B).name( )]) { pref = SameType< B, B >::OK; } +}; + +/* essai d'unification des classes + +template struct F_1 : unary_function,public E_F0 { - AnyType operator()(Stack s) const + AnyType operator()(Stack s) const { return SetAny( ff(GetAny((*a)(s)))) ;} }; @@ -2754,177 +2820,150 @@ class bUnary_Op : public C { public: Expression a; public: - - bUnary_Op(Expression aa) : a(aa) {} - - int compare (const E_F0 *t) const { + + bUnary_Op(Expression aa) : a(aa) {} + + int compare (const E_F0 *t) const { int rr; const bUnary_Op * tt=dynamic_cast(t); if (tt) rr = a->compare(tt->a); else rr = E_F0::compare(t); // cout << "cmp E_F0_Func1 " << rr << endl; return rr; - } // to give a order in instuction - bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();} // - bool MeshIndependent() const {return a->MeshIndependent();} // - + } // to give a order in instuction + bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();} // + bool MeshIndependent() const {return a->MeshIndependent();} // + // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation - virtual ostream & dump(ostream &f) const { - f << "Op1<" << typeid(C).name() + virtual ostream & dump(ostream &f) const { + f << "Op1<" << typeid(C).name() << "> \n\t\t\t( a= "<< *a<< ") " ; - return f; } - + return f; } + }; -*/ -template -class Unary_Op : public E_F0 { public: +*/ +template< class C > +class Unary_Op : public E_F0 { + public: + typedef typename C::result_type R; + typedef typename C::argument_type A; + Expression a; - typedef typename C::result_type R; - typedef typename C::argument_type A; - - Expression a; - public: - AnyType operator()(Stack s) const - { return SetAny( C::f(GetAny((*a)(s)))) ;} - - Unary_Op(Expression aa) : a(aa) {} - - int compare (const E_F0 *t) const { - int rr; - const Unary_Op * tt=dynamic_cast(t); - if (tt) rr = a->compare(tt->a); - else rr = E_F0::compare(t); - // cout << "cmp E_F0_Func1 " << rr << endl; - return rr; - } // to give a order in instuction - bool EvaluableWithOutStack() const {return a->EvaluableWithOutStack();} // - bool MeshIndependent() const {return a->MeshIndependent();} // - - // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation + public: + AnyType operator( )(Stack s) const { return SetAny< R >(C::f(GetAny< A >((*a)(s)))); } - virtual ostream & dump(ostream &f) const { - f << "Op1<" << typeid(C).name() - << "> \n\t\t\t( a= "<< *a<< ") " ; - return f; } - - - }; + Unary_Op(Expression aa) : a(aa) {} + int compare(const E_F0 *t) const { + int rr; + const Unary_Op *tt = dynamic_cast< const Unary_Op * >(t); + if (tt) + rr = a->compare(tt->a); + else + rr = E_F0::compare(t); + // cout << "cmp E_F0_Func1 " << rr << endl; + return rr; + } // to give a order in instuction + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // + // int Optimize(deque > &l,MapOfE_F0 & m, size_t & n) const; // build optimisation -template > -class OneUnaryOperator : public OneOperator{ + virtual ostream &dump(ostream &f) const { + f << "Op1<" << typeid(C).name( ) << "> \n\t\t\t( a= " << *a << ") "; + return f; + } +}; + +template< class C, class Op = Unary_Op< C > > +class OneUnaryOperator : public OneOperator { typedef typename C::result_type R; - typedef typename C::argument_type A; - aType tA; - public: - E_F0 * code(const basicAC_F0 & args) const - { if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - return new Op(tA->CastTo(args[0]));} - OneUnaryOperator(aType tt0=map_type[typeid(A).name()]): - OneOperator(map_type[typeid(R).name()],tt0), - tA(map_type[typeid(A).name()]) - {} -}; - -template > -class OneOperator1s_ : public OneOperator { - typedef R (*func)(Stack stack, const A &) ; - func f; - public: - E_F0 * code(const basicAC_F0 & args) const - { if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - return new CODE(f,t[0]->CastTo(args[0]));} - OneOperator1s_(func ff): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]),f(ff){} -}; - -template > -class OneOperator1_ : public OneOperator { - aType t0; // return type - typedef R (*func)(const A &) ; - func f; - public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f,t[0]->CastTo(args[0]));} - OneOperator1_(func ff,int ppref=0): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()]),t0( map_type[typeid(A).name()] ),f(ff){pref=ppref;} - OneOperator1_(func ff,aType tt0,int ppref=0): - OneOperator(map_type[typeid(R).name()],tt0), - t0( map_type[typeid(A).name()]), f(ff) {pref=ppref;} - -}; - -template class E_F_F0F0_; - - - - -template > -class OneOperator2_ : public OneOperator { - aType t0,t1; // return type type de f, f(t1, t2) - typedef typename CODE::func func; - func f; - public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f,t0->CastTo(args[0]),t1->CastTo(args[1]));} - OneOperator2_(func ff): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]), - t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {} - OneOperator2_(int ppref,func ff): - OneOperator(map_type[typeid(R).name()],map_type[typeid(A).name()],map_type[typeid(B).name()]), - t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {pref=ppref;} - - OneOperator2_(func ff,aType tt0,aType tt1): - OneOperator(map_type[typeid(R).name()],tt0,tt1), - t0( map_type[typeid(A).name()] ),t1(map_type[typeid(B).name()] ), f(ff) {} - -}; - -template > -class OneOperator3_ : public OneOperator { - // aType r; // return type - aType tA,tB,tC; // type of template modif FH mars 2007 - typedef typename CODE::func func; - func f; - public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f,tA->CastTo(args[0]),tB->CastTo(args[1]),tC->CastTo(args[2]));} - OneOperator3_(func ff, - aType tt0=map_type[typeid(A).name()], - aType tt1=map_type[typeid(B).name()], - aType tt2=map_type[typeid(C).name()]) - : OneOperator(map_type[typeid(R).name()],tt0,tt1,tt2), - tA(map_type[typeid(A).name()]), - tB(map_type[typeid(B).name()]), - tC(map_type[typeid(C).name()]), - f(ff){} - OneOperator3_(int ppref,func ff, - aType tt0=map_type[typeid(A).name()], - aType tt1=map_type[typeid(B).name()], - aType tt2=map_type[typeid(C).name()]) - : OneOperator(map_type[typeid(R).name()],tt0,tt1,tt2), - tA(map_type[typeid(A).name()]), - tB(map_type[typeid(B).name()]), - tC(map_type[typeid(C).name()]), - f(ff) {pref=ppref;} + typedef typename C::argument_type A; + aType tA; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + return new Op(tA->CastTo(args[0])); + } + OneUnaryOperator(aType tt0 = map_type[typeid(A).name( )]) : OneOperator(map_type[typeid(R).name( )], tt0), tA(map_type[typeid(A).name( )]) {} +}; + +template< class R, class A = R, class CODE = E_F_F0s_< R, A > > +class OneOperator1s_ : public OneOperator { + typedef R (*func)(Stack stack, const A &); + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + return new CODE(f, t[0]->CastTo(args[0])); + } + OneOperator1s_(func ff) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )]), f(ff) {} +}; + +template< class R, class A = R, class CODE = E_F_F0_< R, A > > +class OneOperator1_ : public OneOperator { + aType t0; // return type + typedef R (*func)(const A &); + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0])); + } + OneOperator1_(func ff, int ppref = 0) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )]), t0(map_type[typeid(A).name( )]), f(ff) { pref = ppref; } + OneOperator1_(func ff, aType tt0, int ppref = 0) : OneOperator(map_type[typeid(R).name( )], tt0), t0(map_type[typeid(A).name( )]), f(ff) { pref = ppref; } +}; + +template< class R, class A, class B, class E > +class E_F_F0F0_; +template< class R, class A = R, class B = A, class CODE = E_F_F0F0_< R, A, B, E_F0 > > +class OneOperator2_ : public OneOperator { + aType t0, t1; // return type type de f, f(t1, t2) + typedef typename CODE::func func; + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t0->CastTo(args[0]), t1->CastTo(args[1])); + } + OneOperator2_(func ff) + : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]), f(ff) {} + OneOperator2_(int ppref, func ff) + : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]), f(ff) { + pref = ppref; + } + + OneOperator2_(func ff, aType tt0, aType tt1) : OneOperator(map_type[typeid(R).name( )], tt0, tt1), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]), f(ff) {} +}; + +template< class R, class A = R, class B = A, class C = B, class CODE = E_F_F0F0F0_< R, A, B, C, E_F0 > > +class OneOperator3_ : public OneOperator { + // aType r; // return type + aType tA, tB, tC; // type of template modif FH mars 2007 + typedef typename CODE::func func; + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, tA->CastTo(args[0]), tB->CastTo(args[1]), tC->CastTo(args[2])); + } + OneOperator3_(func ff, aType tt0 = map_type[typeid(A).name( )], aType tt1 = map_type[typeid(B).name( )], aType tt2 = map_type[typeid(C).name( )]) + : OneOperator(map_type[typeid(R).name( )], tt0, tt1, tt2), tA(map_type[typeid(A).name( )]), tB(map_type[typeid(B).name( )]), tC(map_type[typeid(C).name( )]), f(ff) {} + OneOperator3_(int ppref, func ff, aType tt0 = map_type[typeid(A).name( )], aType tt1 = map_type[typeid(B).name( )], aType tt2 = map_type[typeid(C).name( )]) + : OneOperator(map_type[typeid(R).name( )], tt0, tt1, tt2), tA(map_type[typeid(A).name( )]), tB(map_type[typeid(B).name( )]), tC(map_type[typeid(C).name( )]), f(ff) { + pref = ppref; + } }; // <> utilise [[E_F0]]. la class code doit contenir @@ -2932,127 +2971,135 @@ class OneOperator3_ : public OneOperator { class CODE: public E_F0 { typedef ... func .. ; typedef .. R; - static ArrayOfaType typeargs(); // the list of type de l'operateur of the args - typedef ... R; // return type + static ArrayOfaType typeargs(); // the list of type de l'operateur of the args + typedef ... R; // return type } */ -template -class OneOperatorCode : public OneOperator { - public: - E_F0 * code(const basicAC_F0 & args) const { return CODE::f(args);} - OneOperatorCode(): OneOperator(atype(),CODE::typeargs()) {pref=ppref;} - OneOperatorCode(aType rr,const ArrayOfaType & l): OneOperator(rr,l) {pref=ppref;} - OneOperatorCode(aType rr,aType a): OneOperator(rr,a) {pref=ppref;} - OneOperatorCode(aType rr,aType a,aType b): OneOperator(rr,a,b) {pref=ppref;} - OneOperatorCode(aType rr,aType a,aType b,aType c): OneOperator(rr,a,b,c) {pref=ppref;} - -}; - -template struct binary_trait{ typedef A R ;}; -template<> struct binary_trait { typedef double R;}; -template<> struct binary_trait { typedef double R;}; -template<> struct binary_trait > { typedef complex R;}; -template<> struct binary_trait > { typedef complex R;}; -template<> struct binary_trait > { typedef complex R ;}; -template struct binary_trait { typedef string* R ;}; - -// 1 variable pour les operation de cast -class E_F1_funcT_Type: public OneOperator{ public: - // const basicForEachType *r,*a; - Function1 f; - E_F0 * code(const basicAC_F0 & args) const { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new E_F0_Func1(f,args[0]);} - - E_F1_funcT_Type(const basicForEachType *rr,const basicForEachType *aa,Function1 ff) - : OneOperator(rr,aa), f(ff) {} - - //: r(rr),a(aa),f(ff) {} - // friend ostream & operator<<(ostream & f,const E_F1_funcT_Type & e) { f << *e.a << " -> " << *e.r ;return f;} -}; - -template -class E_F1_funcT :public E_F1_funcT_Type{ public: - E_F1_funcT(Function1 ff) : E_F1_funcT_Type(map_type[typeid(R).name()],map_type[typeid(A).name()],ff){} - E_F1_funcT(aType rr,aType a,Function1 ff) : E_F1_funcT_Type(rr,a,ff){} -}; - - -template - ForEachTypePtr::ForEachTypePtr(): - basicForEachType(typeid(PT),sizeof(PT), -// new E_F1_funcT(UnRef),atype(), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - - ::Initialize,::Delete){} - -template - ForEachTypePtr::ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn): - basicForEachType(typeid(PT),sizeof(PT), -// new E_F1_funcT(UnRef),atype(), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - init, - dl , onreturn ){} - -template - ForEachTypePtr::ForEachTypePtr(Function1 dl): - basicForEachType(typeid(PT),sizeof(PT), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - ::Initialize,dl){} - - -template - ForEachTypePtr::ForEachTypePtr(T* unused,Function1 OOnReturn): - basicForEachType(typeid(T**),sizeof(T**), -// new E_F1_funcT(UnRef),atype(), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - - ::InitializePtr,::DestroyPtr,OOnReturn){} - -template - ForEachTypePtr::ForEachTypePtr(Function1 init,Function1 dl,Function1 onreturn): - basicForEachType(typeid(T**),sizeof(T**), - // new E_F1_funcT(UnRef),atype(), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - init , - dl , - onreturn){} - -template - ForEachTypePtr::ForEachTypePtr(Function1 dl): - basicForEachType(typeid(T**),sizeof(T**), -// new E_F1_funcT(UnRef),atype(), - new E_F1_funcT_Type(atype(),this,UnRef),atype(), - ::InitializePtr,dl){} - +template< class CODE, int ppref = 0 > +class OneOperatorCode : public OneOperator { + public: + E_F0 *code(const basicAC_F0 &args) const { return CODE::f(args); } + OneOperatorCode( ) : OneOperator(atype< typename CODE::Result >( ), CODE::typeargs( )) { pref = ppref; } + OneOperatorCode(aType rr, const ArrayOfaType &l) : OneOperator(rr, l) { pref = ppref; } + OneOperatorCode(aType rr, aType a) : OneOperator(rr, a) { pref = ppref; } + OneOperatorCode(aType rr, aType a, aType b) : OneOperator(rr, a, b) { pref = ppref; } + OneOperatorCode(aType rr, aType a, aType b, aType c) : OneOperator(rr, a, b, c) { pref = ppref; } +}; + +template< class A, class B > +struct binary_trait { + typedef A R; +}; +template<> +struct binary_trait< int, double > { + typedef double R; +}; +template<> +struct binary_trait< long, double > { + typedef double R; +}; +template<> +struct binary_trait< int, complex< double > > { + typedef complex< double > R; +}; +template<> +struct binary_trait< long, complex< double > > { + typedef complex< double > R; +}; +template<> +struct binary_trait< double, complex< double > > { + typedef complex< double > R; +}; +template< class A > +struct binary_trait< A, string * > { + typedef string *R; +}; + +// 1 variable pour les operation de cast +class E_F1_funcT_Type : public OneOperator { + public: + // const basicForEachType *r,*a; + Function1 f; + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new E_F0_Func1(f, args[0]); + } + + E_F1_funcT_Type(const basicForEachType *rr, const basicForEachType *aa, Function1 ff) : OneOperator(rr, aa), f(ff) {} + + //: r(rr),a(aa),f(ff) {} + // friend ostream & operator<<(ostream & f,const E_F1_funcT_Type & e) { f << *e.a << " -> " << *e.r ;return f;} +}; + +template< class R, class A > +class E_F1_funcT : public E_F1_funcT_Type { + public: + E_F1_funcT(Function1 ff) : E_F1_funcT_Type(map_type[typeid(R).name( )], map_type[typeid(A).name( )], ff) {} + E_F1_funcT(aType rr, aType a, Function1 ff) : E_F1_funcT_Type(rr, a, ff) {} +}; + +template< class T, class PT > +ForEachTypePtr< T, PT >::ForEachTypePtr( ) + : basicForEachType(typeid(PT), sizeof(PT), + // new E_F1_funcT(UnRef),atype(), + new E_F1_funcT_Type(atype< T >( ), this, UnRef< T, PT >), atype< T >( ), + + ::Initialize< T >, ::Delete< T >) {} + +template< class T, class PT > +ForEachTypePtr< T, PT >::ForEachTypePtr(Function1 init, Function1 dl, Function1 onreturn) + : basicForEachType(typeid(PT), sizeof(PT), + // new E_F1_funcT(UnRef),atype(), + new E_F1_funcT_Type(atype< T >( ), this, UnRef< T, PT >), atype< T >( ), init, dl, onreturn) {} + +template< class T, class PT > +ForEachTypePtr< T, PT >::ForEachTypePtr(Function1 dl) : basicForEachType(typeid(PT), sizeof(PT), new E_F1_funcT_Type(atype< T >( ), this, UnRef< T, PT >), atype< T >( ), ::Initialize< T >, dl) {} + +template< class T > +ForEachTypePtr< T *, T ** >::ForEachTypePtr(T *unused, Function1 OOnReturn) + : basicForEachType(typeid(T **), sizeof(T **), + // new E_F1_funcT(UnRef),atype(), + new E_F1_funcT_Type(atype< T * >( ), this, UnRef< T * >), atype< T * >( ), + + ::InitializePtr< T * >, ::DestroyPtr< T * >, OOnReturn) {} + +template< class T > +ForEachTypePtr< T *, T ** >::ForEachTypePtr(Function1 init, Function1 dl, Function1 onreturn) + : basicForEachType(typeid(T **), sizeof(T **), + // new E_F1_funcT(UnRef),atype(), + new E_F1_funcT_Type(atype< T * >( ), this, UnRef< T * >), atype< T * >( ), init, dl, onreturn) {} + +template< class T > +ForEachTypePtr< T *, T ** >::ForEachTypePtr(Function1 dl) + : basicForEachType(typeid(T **), sizeof(T **), + // new E_F1_funcT(UnRef),atype(), + new E_F1_funcT_Type(atype< T * >( ), this, UnRef< T * >), atype< T * >( ), ::InitializePtr< T * >, dl) {} + /* class FuncForEachType : public basicForEachType {public: FuncForEachType(const basicForEachType * t); - const basicForEachType * rtype; - }; + const basicForEachType * rtype; + }; */ - - /* inline basicForEachType::basicForEachType(const type_info & k, const type_info & kf, const size_t s, const E_F1_funcT_Type * p, basicForEachType *rr, - Function1 iv,Function1 id) + Function1 iv,Function1 id) : ktype(&k),ktypefunc(&kf), size(s), un_ptr(p), - un_ptr_type(rr?rr:this), - InitExp(iv), + un_ptr_type(rr?rr:this), + InitExp(iv), destroy(id) , - funct_type(new FuncForEachType(this)){} - - + funct_type(new FuncForEachType(this)){} + + */ -/* remove frev 2019 FH. +/* remove frev 2019 FH. inline C_F0 & operator+=(C_F0 & a,C_F0 &b) { C_F0 r = C_F0(TheOperators,"+",a,b); @@ -3062,226 +3109,224 @@ inline C_F0 & operator+=(C_F0 & a,C_F0 &b) */ // Morice 06/2022 // check if < in the map_type/ -template -void CheckDclTypeEmpty() { - if((verbosity > 9) && (map_type.find(typeid(T).name())!=map_type.end())) - cout << " (Erreur fftype dcl twice "<< typeid(T).name() << " " << - *map_type[typeid(T).name()] << ")" ; +template< typename T > +void CheckDclTypeEmpty( ) { + if ((verbosity > 9) && (map_type.find(typeid(T).name( )) != map_type.end( ))) cout << " (Erreur fftype dcl twice " << typeid(T).name( ) << " " << *map_type[typeid(T).name( )] << ")"; } // Morice 06/2022 // Add the << T >> and << PT >> in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template -void Dcl_TypeandPtr_ (Function1 i,Function1 d,Function1 pi,Function1 pd,Function1 OnReturn=0,Function1 pOnReturn=0) - { - CheckDclTypeEmpty(); - CheckDclTypeEmpty(); - map_type[typeid(T).name()] = new ForEachType(i,d,OnReturn); - map_type[typeid(PT).name()] = new ForEachTypePtr(pi,pd,pOnReturn); - } +template< typename T, typename PT > +void Dcl_TypeandPtr_(Function1 i, Function1 d, Function1 pi, Function1 pd, Function1 OnReturn = 0, Function1 pOnReturn = 0) { + CheckDclTypeEmpty< T >( ); + CheckDclTypeEmpty< PT >( ); + map_type[typeid(T).name( )] = new ForEachType< T >(i, d, OnReturn); + map_type[typeid(PT).name( )] = new ForEachTypePtr< T, PT >(pi, pd, pOnReturn); +} // Morice 06/2022 // Add the << T >> and << T* >>in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template -void Dcl_TypeandPtr (Function1 i,Function1 d,Function1 pi,Function1 pd,Function1 OnReturn=0,Function1 pOnReturn=0) -{ - CheckDclTypeEmpty(); - CheckDclTypeEmpty(); +template< class T > +void Dcl_TypeandPtr(Function1 i, Function1 d, Function1 pi, Function1 pd, Function1 OnReturn = 0, Function1 pOnReturn = 0) { + CheckDclTypeEmpty< T >( ); + CheckDclTypeEmpty< T * >( ); -map_type[typeid(T).name()] = new ForEachType(i,d,OnReturn); -map_type[typeid(T*).name()] = new ForEachTypePtr(pi,pd,pOnReturn); + map_type[typeid(T).name( )] = new ForEachType< T >(i, d, OnReturn); + map_type[typeid(T *).name( )] = new ForEachTypePtr< T >(pi, pd, pOnReturn); } // Morice 06/2022 // Add the << T >> and << T* >>in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template - void Dcl_TypeandPtr (Function1 pi,Function1 pd) - { - CheckDclTypeEmpty(); - CheckDclTypeEmpty(); - map_type[typeid(T).name()] = new ForEachType(); - map_type[typeid(T*).name()] = new ForEachTypePtr(pi,pd); - } - +template< class T > +void Dcl_TypeandPtr(Function1 pi, Function1 pd) { + CheckDclTypeEmpty< T >( ); + CheckDclTypeEmpty< T * >( ); + map_type[typeid(T).name( )] = new ForEachType< T >( ); + map_type[typeid(T *).name( )] = new ForEachTypePtr< T >(pi, pd); +} + // Morice 06/2022 // Add the << T >> and << T* >>in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template - void Dcl_TypeandPtr (Function1 pd) - { - CheckDclTypeEmpty(); - CheckDclTypeEmpty(); - map_type[typeid(T).name()] = new ForEachType(); - map_type[typeid(T*).name()] = new ForEachTypePtr(pd); - } +template< class T > +void Dcl_TypeandPtr(Function1 pd) { + CheckDclTypeEmpty< T >( ); + CheckDclTypeEmpty< T * >( ); + map_type[typeid(T).name( )] = new ForEachType< T >( ); + map_type[typeid(T *).name( )] = new ForEachTypePtr< T >(pd); +} // Morice 06/2022 // Add the << T >> and << T* >>in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template - void Dcl_TypeandPtr () - { - CheckDclTypeEmpty(); - CheckDclTypeEmpty(); - map_type[typeid(T).name()] = new ForEachType(); - map_type[typeid(T*).name()] = new ForEachTypePtr(); - } +template< class T > +void Dcl_TypeandPtr( ) { + CheckDclTypeEmpty< T >( ); + CheckDclTypeEmpty< T * >( ); + map_type[typeid(T).name( )] = new ForEachType< T >( ); + map_type[typeid(T *).name( )] = new ForEachTypePtr< T >( ); +} // Morice 06/2022 // Add the class T in the map_type. // The map_type contains the different <> in Freefem that can be verified. -template - aType Dcl_Type (Function1 iv=0,Function1 id=0,Function1 Onreturn=0) - { - if (sizeof(T) >sizeof(AnyData)) { - cerr << " the type " << typeid(T).name() << " is too large " << sizeof(AnyData) << endl; - throwassert(sizeof(T) <=sizeof(AnyData));} - CheckDclTypeEmpty(); - - return map_type[typeid(T).name()] = new ForEachType(iv,id,Onreturn); - - } - -template - void Add(const char * k,const char * op,OneOperator *p0,OneOperator *p1=0, - OneOperator *p2=0,OneOperator *p3=0,OneOperator *p4=0, - OneOperator *p5=0,OneOperator *p6=0) - {atype()->Add(k,op,p0,p1,p2,p3,p4,p5,p6);} - -inline C_F0 operator *(const C_F0 &a,const C_F0 &b) -{ - return a==*pOne ? b : ( b ==*pOne ? a : C_F0(TheOperators,"*",a,b)) ;} -inline C_F0 operator+(const C_F0 &a,const C_F0 &b){ return C_F0(TheOperators,"+",a,b);} -inline C_F0 operator-(const C_F0 &a,const C_F0 &b){ return C_F0(TheOperators,"-",a,b);} - +template< class T > +aType Dcl_Type(Function1 iv = 0, Function1 id = 0, Function1 Onreturn = 0) { + if (sizeof(T) > sizeof(AnyData)) { + cerr << " the type " << typeid(T).name( ) << " is too large " << sizeof(AnyData) << endl; + throwassert(sizeof(T) <= sizeof(AnyData)); + } + CheckDclTypeEmpty< T >( ); + + return map_type[typeid(T).name( )] = new ForEachType< T >(iv, id, Onreturn); +} + +template< class T > +void Add(const char *k, const char *op, OneOperator *p0, OneOperator *p1 = 0, OneOperator *p2 = 0, OneOperator *p3 = 0, OneOperator *p4 = 0, OneOperator *p5 = 0, OneOperator *p6 = 0) { + atype< T >( )->Add(k, op, p0, p1, p2, p3, p4, p5, p6); +} + +inline C_F0 operator*(const C_F0 &a, const C_F0 &b) { return a == *pOne ? b : (b == *pOne ? a : C_F0(TheOperators, "*", a, b)); } +inline C_F0 operator+(const C_F0 &a, const C_F0 &b) { return C_F0(TheOperators, "+", a, b); } +inline C_F0 operator-(const C_F0 &a, const C_F0 &b) { return C_F0(TheOperators, "-", a, b); } + /// <> -inline C_F0 &operator +=(C_F0 &a,const C_F0 &b) -{ - C_F0 r=C_F0(TheOperators,"+",a,b); - a=r; - return a;} - -//inline bool CC_F0::Empty() const {return !f || f->Empty();} -inline void CC_F0::operator=(const CListOfInst& c) - { C_F0 cc=c;f=cc.f;r=cc.r;} -inline CListOfInst & CListOfInst::operator+=(const CC_F0 & a) - { if( !a.Empty()){ f->Add(a);r=a.left();};return *this;} - -inline Type_Expr basicForEachType::SetParam(const C_F0 & ,const ListOfId * ,size_t & ) const - { cerr << " int basicForEachType " << name() << endl; - InternalError("basicForEachType::SetParam non defined"); }//return make_pair(c.left(),c.LeftValue());} - +inline C_F0 &operator+=(C_F0 &a, const C_F0 &b) { + C_F0 r = C_F0(TheOperators, "+", a, b); + a = r; + return a; +} + +// inline bool CC_F0::Empty() const {return !f || f->Empty();} +inline void CC_F0::operator=(const CListOfInst &c) { + C_F0 cc = c; + f = cc.f; + r = cc.r; +} +inline CListOfInst &CListOfInst::operator+=(const CC_F0 &a) { + if (!a.Empty( )) { + f->Add(a); + r = a.left( ); + }; + return *this; +} +inline Type_Expr basicForEachType::SetParam(const C_F0 &, const ListOfId *, size_t &) const { + cerr << " int basicForEachType " << name( ) << endl; + InternalError("basicForEachType::SetParam non defined"); +} // return make_pair(c.left(),c.LeftValue());} /* // --- pour les cast ------ -class OneOpCast: public OneOperator { +class OneOpCast: public OneOperator { typedef const E_F1_funcT_Type * CastFunc; CastFunc f; - public: - E_F0 * code(const basicAC_F0 & args) const { return new E_F0_Func1(f->f,args[0]);} + public: + E_F0 * code(const basicAC_F0 & args) const { return new E_F0_Func1(f->f,args[0]);} OneOpCast(CastFunc ff): OneOperator(ff->r,ff->a),f(ff){} }; */ -// -inline bool basicForEachType::CastingFrom(aType t) const { - throwassert( t); - if ( t == this) return true; - else if( t == type_C_F0 ) return true; // FH do work .... 09 / 2012 (use of ellispe ...) - return casting->FindSameR(ArrayOfaType(t,false)); // uses [[casting]] [[file:AFunction2.cpp::FindSameR]] - } - -inline void CerrCast(const pair & i) -{ - cerr << "\t" << *i.first << ":" << i.second << endl; +// +inline bool basicForEachType::CastingFrom(aType t) const { + throwassert(t); + if (t == this) + return true; + else if (t == type_C_F0) + return true; // FH do work .... 09 / 2012 (use of ellispe ...) + return casting->FindSameR(ArrayOfaType(t, false)); // uses [[casting]] [[file:AFunction2.cpp::FindSameR]] } -inline C_F0 basicForEachType::CastTo(const C_F0 & e) const -{ - throwassert(this); - aType t = e.left(); - if (this== t) return e; - - - C_F0 ce=e; +inline void CerrCast(const pair< const basicForEachType *, const E_F1_funcT_Type * > &i) { cerr << "\t" << *i.first << ":" << i.second << endl; } + +inline C_F0 basicForEachType::CastTo(const C_F0 &e) const { + throwassert(this); + aType t = e.left( ); + if (this == t) return e; + + C_F0 ce = e; basicAC_F0 at; - at=ce; - OneOperator * opcast =casting->FindSameR(ArrayOfaType(t,false)); - if ( opcast ) - if ( *opcast == at ) // left value - return C_F0(opcast->code(at),this); - else { // rigth value - aType tr = e.right(); - ce = C_F0(e.RightValue(),tr); - at = ce; - return C_F0(opcast->code(at),this); } - else - { cerr << "Impossible to cast " << *e.left() << " in " << *this << endl; - if (casting) casting->Show(cerr) ; - CompileError();} - return C_F0(); -} -inline Expression basicForEachType::RightValueExpr(Expression f) const -{ - if (un_ptr) return new E_F0_Func1(un_ptr->f,f); - else return f; + at = ce; + OneOperator *opcast = casting->FindSameR(ArrayOfaType(t, false)); + if (opcast) + if (*opcast == at) // left value + return C_F0(opcast->code(at), this); + else { // rigth value + aType tr = e.right( ); + ce = C_F0(e.RightValue( ), tr); + at = ce; + return C_F0(opcast->code(at), this); + } + else { + cerr << "Impossible to cast " << *e.left( ) << " in " << *this << endl; + if (casting) casting->Show(cerr); + CompileError( ); + } + return C_F0( ); +} +inline Expression basicForEachType::RightValueExpr(Expression f) const { + if (un_ptr) + return new E_F0_Func1(un_ptr->f, f); + else + return f; } -inline void CompileError(string msg,aType r){ - string m= r ? msg + " type: " + r->name() : msg ; - lgerror(m.c_str()); - } - - inline void ExecError(string msg){ - // cerr << "Fatal ExecError: " << msg << endl; - throw(ErrorExec(msg.c_str(),1)); - } - -const Function1 NotReturnOfthisType = reinterpret_cast(1); +inline void CompileError(string msg, aType r) { + string m = r ? msg + " type: " + r->name( ) : msg; + lgerror(m.c_str( )); +} -inline Expression basicForEachType::OnReturn(Expression f) const { - if(!DoOnReturn) return f; - else if(DoOnReturn== NotReturnOfthisType ) - CompileError("Problem when returning this type (sorry work in progress FH!) ", this); - else return new E_F0_Func1(DoOnReturn,f); - return 0; +inline void ExecError(string msg) { + // cerr << "Fatal ExecError: " << msg << endl; + throw(ErrorExec(msg.c_str( ), 1)); } +const Function1 NotReturnOfthisType = reinterpret_cast< Function1 >(1); -inline void CC_F0::operator=(const AC_F0& a) { f=new E_Array(a); r= atype();}; +inline Expression basicForEachType::OnReturn(Expression f) const { + if (!DoOnReturn) + return f; + else if (DoOnReturn == NotReturnOfthisType) + CompileError("Problem when returning this type (sorry work in progress FH!) ", this); + else + return new E_F0_Func1(DoOnReturn, f); + return 0; +} -inline UnId::UnId(const char * idd,const C_F0 & ee,aType rr=0,bool reff=false) - :id(idd),r(rr),e(ee),array(0),re(ee.left()) ,ref(reff), compo_begin(false), compo_end(false){}; +inline void CC_F0::operator=(const AC_F0 &a) { + f = new E_Array(a); + r = atype< E_Array >( ); +}; +inline UnId::UnId(const char *idd, const C_F0 &ee, aType rr = 0, bool reff = false) : id(idd), r(rr), e(ee), array(0), re(ee.left( )), ref(reff), compo_begin(false), compo_end(false) {}; -class E_exception : public exception { public: - enum CODE_exception { UNKNOWN,e_break,e_continue,e_return} ; - CODE_exception code; - AnyType r; // for return - public: - E_exception(CODE_exception c,AnyType rr=Nothing) : code(c),r(rr) {} - int type() {return code;} - virtual const char * what() const throw() { return "E_exception (break,continue or return) "; } - ~E_exception() throw() {} +class E_exception : public exception { + public: + enum CODE_exception { UNKNOWN, e_break, e_continue, e_return }; + CODE_exception code; + AnyType r; // for return + public: + E_exception(CODE_exception c, AnyType rr = Nothing) : code(c), r(rr) {} + int type( ) { return code; } + virtual const char *what( ) const throw( ) { return "E_exception (break,continue or return) "; } + ~E_exception( ) throw( ) {} }; - -class E_throw : public E_F0mps { public: - E_exception::CODE_exception kind; - Expression ret; // return value - E_throw(E_exception::CODE_exception c,Expression e=0) :kind(c),ret(e) {} - AnyType operator()(Stack s) const { - (ret ? throw(E_exception(kind,(*ret)(s))) - : throw(E_exception(kind))); - return Nothing; } - operator aType () const { return atype();} - - } ; +class E_throw : public E_F0mps { + public: + E_exception::CODE_exception kind; + Expression ret; // return value + E_throw(E_exception::CODE_exception c, Expression e = 0) : kind(c), ret(e) {} + AnyType operator( )(Stack s) const { + (ret ? throw(E_exception(kind, (*ret)(s))) : throw(E_exception(kind))); + return Nothing; + } + operator aType( ) const { return atype< void >( ); } +}; /* class E_block : public E_F0mps { public: @@ -3296,265 +3341,237 @@ class E_block : public E_F0mps { public: E_block( C_F0 l,C_F0 c) : n(1),code(new Expression),clean(c) { code[0]=l;} AnyType operator()(Stack s) const ; - operator aType () const { return atype();} - + operator aType () const { return atype();} + }; */ class Routine; -class E_Routine : public E_F0mps { public: - ListOfInst * code; - // Expression clean; +class E_Routine : public E_F0mps { + public: + ListOfInst *code; + // Expression clean; aType rt; int nbparam; - Expression * param; - const char * name; - E_Routine(const Routine * routine,const basicAC_F0 & args); - AnyType operator()(Stack s) const; - ~E_Routine() ;//{ delete [] param;} modif del for windows - private: + Expression *param; + const char *name; + E_Routine(const Routine *routine, const basicAC_F0 &args); + AnyType operator( )(Stack s) const; + ~E_Routine( ); //{ delete [] param;} modif del for windows + private: E_Routine(const E_Routine &); void operator=(const E_Routine &); - operator aType () const{ return rt;} - + operator aType( ) const { return rt; } }; /// <> used in [[file:../lglib/lg.ypp::YYSTYPE]] -class Routine: public OneOperator{ public: - size_t offset; - aType tfunc,tret; - const char * name; - const ListOfId param; - Block * currentblock; - ListOfInst * ins; - - - E_F0 * code(const basicAC_F0 & args) const ; - Routine(aType tf,aType tr,const char * iden, ListOfId *l,Block * & cb); - Block * Set(CListOfInst instr) ; -}; - - -class TypeLineFunction: public ForEachType { - public: - TypeLineFunction() : ForEachType(0,0) {} - - void SetArgs(const ListOfId *lid) const { - if (lid) CompileError("No Argument in line function"); - } - - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { return Type_Expr(c.left(),c.LeftValue()); } - - C_F0 Initialization(const Type_Expr & ) const - { return C_F0(); } // nothing to initialize - +class Routine : public OneOperator { + public: + size_t offset; + aType tfunc, tret; + const char *name; + const ListOfId param; + Block *currentblock; + ListOfInst *ins; + + E_F0 *code(const basicAC_F0 &args) const; + Routine(aType tf, aType tr, const char *iden, ListOfId *l, Block *&cb); + Block *Set(CListOfInst instr); }; +class TypeLineFunction : public ForEachType< C_F0 > { + public: + TypeLineFunction( ) : ForEachType< C_F0 >(0, 0) {} + + void SetArgs(const ListOfId *lid) const { + if (lid) CompileError("No Argument in line function"); + } + + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { return Type_Expr(c.left( ), c.LeftValue( )); } -class E_F0_Optimize : public E_F0 { - deque > l; + C_F0 Initialization(const Type_Expr &) const { return C_F0( ); } // nothing to initialize +}; + +class E_F0_Optimize : public E_F0 { + deque< pair< Expression, int > > l; // mutable deque var; MapOfE_F0 m; int NBbitem; int ret; -public: - E_F0_Optimize(deque > &ll,MapOfE_F0 & mm,int rett) : - l(ll),m(mm),NBbitem(1),ret(rett) {} - int sizevar() const {return l.size();} - AnyType eval(Stack s,int notinit,bool * unvar) const { - int k= l.size(),kk=0; - if(notinit ==0) - { - //var.resize(k); - for (int i=0;i(s,offset) = l[i].first->eval(s, unvar[i]); - if( unvar[i]) kk++; - } - if (verbosity/100 && verbosity % 10 == 2) - cout << "E_F0_Optimize nb MI exp: " << kk << " / " << k << endl; + + public: + E_F0_Optimize(deque< pair< Expression, int > > &ll, MapOfE_F0 &mm, int rett) : l(ll), m(mm), NBbitem(1), ret(rett) {} + int sizevar( ) const { return l.size( ); } + AnyType eval(Stack s, int notinit, bool *unvar) const { + int k = l.size( ), kk = 0; + if (notinit == 0) { + // var.resize(k); + for (int i = 0; i < k; i++) { + size_t offset = l[i].second; + unvar[i] = true; + *Stack_offset< AnyType >(s, offset) = l[i].first->eval(s, unvar[i]); + if (unvar[i]) kk++; } - else - for (int i=0;i(s,offset) = (*l[i].first)(s); - //*static_cast(static_cast((char*)s+offset))= (*l[i].first)(s); // FH NEWSTACK - // cout << " E_F0_Optimize " << offset << " " << *static_cast(static_cast((char*)s+offset)) << endl; ; - } - // return *static_cast(static_cast((char*)s+ret)); - return *Stack_offset(s,ret); // FH NEWSTACK - } - - virtual AnyType operator()(Stack s) const { - int k= l.size(); - for (int i=0;i(s,offset) = (*l[i].first)(s); + if (verbosity / 100 && verbosity % 10 == 2) cout << "E_F0_Optimize nb MI exp: " << kk << " / " << k << endl; + } else + for (int i = 0; i < k; i++) { + size_t offset = l[i].second; + if (!unvar[i]) *Stack_offset< AnyType >(s, offset) = (*l[i].first)(s); + //*static_cast(static_cast((char*)s+offset))= (*l[i].first)(s); // FH NEWSTACK + // cout << " E_F0_Optimize " << offset << " " << *static_cast(static_cast((char*)s+offset)) << endl; ; + } + // return *static_cast(static_cast((char*)s+ret)); + return *Stack_offset< AnyType >(s, ret); // FH NEWSTACK + } + + virtual AnyType operator( )(Stack s) const { + int k = l.size( ); + for (int i = 0; i < k; i++) { + size_t offset = l[i].second; + *Stack_offset< AnyType >(s, offset) = (*l[i].first)(s); //*static_cast(static_cast((char*)s+offset))= (*l[i].first)(s); // FH NEWSTACK // cout << " E_F0_Optimize " << offset << " " << *static_cast(static_cast((char*)s+offset)) << endl; ; - } - // return *static_cast(static_cast((char*)s+ret)); - return *Stack_offset(s,ret); // FH NEWSTACK + } + // return *static_cast(static_cast((char*)s+ret)); + return *Stack_offset< AnyType >(s, ret); // FH NEWSTACK } - virtual bool Empty() const {return l.size(); } + virtual bool Empty( ) const { return l.size( ); } // virtual E_F0 * destroy(Stack ) const {return 0;} // virtual const E_F0 * Parameter(Stack ) const {return this;} - virtual size_t nbitem() const { return NBbitem;} - virtual bool EvaluableWithOutStack() const {return false;} // - virtual bool MeshIndependent() const {return false;} // - virtual E_F0 * right_E_F0() const { return 0;} - virtual ~E_F0_Optimize() {} - // virtual int compare (const E_F0 *t) const { return t-this;} // to give a order in instuction - virtual operator aType () const { return *(l.back().first);} // the type of the expression -}; - - -inline int E_F0::find(const MapOfE_F0 & m) { // exp - // cout << " ffff :" ; - MapOfE_F0::const_iterator i= m.find(this); - if(i != m.end()) { - if( (verbosity / 100)% 10 == 1) - { - cout << "\n find : "; - cout << i->second << " mi=" ; - cout << MeshIndependent() << " " ; - cout << typeid(*this).name() ; - cout << " cmp = " << compare(i->first) ; - cout << " " << i->first->compare(this) << " "; - dump(cout); - } - assert( compare(i->first) == 0); - } - return i == m.end() ? 0 : i->second ; + virtual size_t nbitem( ) const { return NBbitem; } + virtual bool EvaluableWithOutStack( ) const { return false; } // + virtual bool MeshIndependent( ) const { return false; } // + virtual E_F0 *right_E_F0( ) const { return 0; } + virtual ~E_F0_Optimize( ) {} + // virtual int compare (const E_F0 *t) const { return t-this;} // to give a order in instuction + virtual operator aType( ) const { return *(l.back( ).first); } // the type of the expression +}; + +inline int E_F0::find(const MapOfE_F0 &m) { // exp + // cout << " ffff :" ; + MapOfE_F0::const_iterator i = m.find(this); + if (i != m.end( )) { + if ((verbosity / 100) % 10 == 1) { + cout << "\n find : "; + cout << i->second << " mi="; + cout << MeshIndependent( ) << " "; + cout << typeid(*this).name( ); + cout << " cmp = " << compare(i->first); + cout << " " << i->first->compare(this) << " "; + dump(cout); } - inline int E_F0::insert(Expression opt,deque > &l,MapOfE_F0 & m, size_t & n) - { - int rr=align8(n); - pair p(this,rr); - if( (verbosity / 100)% 10 == 1) - cout << " -- insert opt " << n << " " << *this << endl; - n += sizeof(AnyType); - l.push_back(make_pair((Expression)opt,(int)rr)); - m.insert(p); - return rr; - } + assert(compare(i->first) == 0); + } + return i == m.end( ) ? 0 : i->second; +} +inline int E_F0::insert(Expression opt, deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { + int rr = align8(n); + pair< Expression, int > p(this, rr); + if ((verbosity / 100) % 10 == 1) cout << " -- insert opt " << n << " " << *this << endl; + n += sizeof(AnyType); + l.push_back(make_pair((Expression)opt, (int)rr)); + m.insert(p); + return rr; +} -extern vector > * debugstack; +extern vector< pair< const E_Routine *, int > > *debugstack; -struct NothingType { // a type to do nothing - NothingType() {}; +struct NothingType { // a type to do nothing + NothingType( ) {}; }; -extern basicForEachType * typevarreal, * typevarcomplex; // type of real and complex variable - -void initArrayOperators(); -void initArrayDCL(); +extern basicForEachType *typevarreal, *typevarcomplex; // type of real and complex variable -void ClearMem(); +void initArrayOperators( ); +void initArrayDCL( ); + +void ClearMem( ); // <> -inline C_F0 OneOperator::code2(const basicAC_F0 &a) const {return C_F0(code(a),r);} - -template -class OneOperator0 : public OneOperator {public: - class E_F0_F :public E_F0 { public: - typedef R (*func)( ) ; - func f; - E_F0_F(func ff) : f(ff) {} - AnyType operator()(Stack ) const {return SetAny( f()) ;} - operator aType () const { return atype();} - - }; - - // aType r; // return type - typedef R (*func)() ; - func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new E_F0_F(f);} - OneOperator0(func ff): OneOperator(map_type[typeid(R).name()]),f(ff){} -}; - -template -Type_Expr CVariable(R (*ff)() ) -{ - throwassert(map_type[typeid(R).name()]); - return make_pair(map_type[typeid(R).name()],new typename OneOperator0::E_F0_F(ff)); -} -void InitLoop(); -C_F0 ForAll(Block *,ListOfId * id,C_F0 m); -C_F0 ForAll(C_F0 loop,C_F0 inst); - -class PolymorphicLoop:public Polymorphic { -public: - typedef Expression Exp; - C_F0 t; - Exp v,i,j; - PolymorphicLoop(C_F0 tt,AC_F0 &args) : t(tt),v(0),i(0), j(0){ - if(verbosity>1000) - cout << "PolymorphicLoop args " << args.size() << endl; - if(args.size()>1) v=args[1]; // v - if(args.size()>2) i=args[2]; // i,v - if(args.size()>3) j=i,i=args[3];// i,j, v - - if(verbosity>1000) - cout <<" v " << v << " i=" << i << " j=" << j << endl; - } - AnyType ftab(Stack s) const { return (*(Expression) t)(s);} - AnyType fv(Stack s) const { return v ? (*v)(s): Nothing ;} - AnyType fi(Stack s) const { return i ? (*i)(s): Nothing ;} - AnyType fj(Stack s) const { return j ? (*j)(s): Nothing ;} - +inline C_F0 OneOperator::code2(const basicAC_F0 &a) const { return C_F0(code(a), r); } + +template< class R > +class OneOperator0 : public OneOperator { + public: + class E_F0_F : public E_F0 { + public: + typedef R (*func)( ); + func f; + E_F0_F(func ff) : f(ff) {} + AnyType operator( )(Stack) const { return SetAny< R >(f( )); } + operator aType( ) const { return atype< R >( ); } + }; + + // aType r; // return type + typedef R (*func)( ); + func f; + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new E_F0_F(f); + } + OneOperator0(func ff) : OneOperator(map_type[typeid(R).name( )]), f(ff) {} }; +template< class R > +Type_Expr CVariable(R (*ff)( )) { + throwassert(map_type[typeid(R).name( )]); + return make_pair(map_type[typeid(R).name( )], new typename OneOperator0< R >::E_F0_F(ff)); +} +void InitLoop( ); +C_F0 ForAll(Block *, ListOfId *id, C_F0 m); +C_F0 ForAll(C_F0 loop, C_F0 inst); +class PolymorphicLoop : public Polymorphic { + public: + typedef Expression Exp; + C_F0 t; + Exp v, i, j; + PolymorphicLoop(C_F0 tt, AC_F0 &args) : t(tt), v(0), i(0), j(0) { + if (verbosity > 1000) cout << "PolymorphicLoop args " << args.size( ) << endl; + if (args.size( ) > 1) v = args[1]; // v + if (args.size( ) > 2) i = args[2]; // i,v + if (args.size( ) > 3) j = i, i = args[3]; // i,j, v + + if (verbosity > 1000) cout << " v " << v << " i=" << i << " j=" << j << endl; + } + AnyType ftab(Stack s) const { return (*(Expression)t)(s); } + AnyType fv(Stack s) const { return v ? (*v)(s) : Nothing; } + AnyType fi(Stack s) const { return i ? (*i)(s) : Nothing; } + AnyType fj(Stack s) const { return j ? (*j)(s) : Nothing; } +}; -class ForAllLoopOpBase : public E_F0mps { public: - Expression et,ecode; - const PolymorphicLoop *epl; - ForAllLoopOpBase( basicForEachType * ret,const basicAC_F0 & args) - : et(ret->CastTo(args[0])), ecode(args[2]),epl(0) - { - // if(args.size() > 3) efin=args[3]; - epl = dynamic_cast((Expression) args[1]); - assert(epl!=0); - } - AnyType tab(Stack s) const { return (*et)(s);} - AnyType v(Stack s) const { return epl->fv(s);} - AnyType i(Stack s) const { return epl->fi(s);} - AnyType j(Stack s) const { return epl->fj(s);} - void code(Stack s) const { (*ecode)(s) ;} +class ForAllLoopOpBase : public E_F0mps { + public: + Expression et, ecode; + const PolymorphicLoop *epl; + ForAllLoopOpBase(basicForEachType *ret, const basicAC_F0 &args) : et(ret->CastTo(args[0])), ecode(args[2]), epl(0) { + // if(args.size() > 3) efin=args[3]; + epl = dynamic_cast< const PolymorphicLoop * >((Expression)args[1]); + assert(epl != 0); + } + AnyType tab(Stack s) const { return (*et)(s); } + AnyType v(Stack s) const { return epl->fv(s); } + AnyType i(Stack s) const { return epl->fi(s); } + AnyType j(Stack s) const { return epl->fj(s); } + void code(Stack s) const { (*ecode)(s); } // void end(Stack s) const { if(efin) (*efin)(s);} - - }; -template -class ForAllLoop : public OneOperator {public: - typedef typename F::Tab T; - class ForAllLoopOp : public ForAllLoopOpBase { public: - F f; - ForAllLoopOp(const basicAC_F0 & args):ForAllLoopOpBase(atype(),args),f((const ForAllLoopOpBase*)this) {} - AnyType operator()(Stack s) const { return this->f.f(s);} - }; - E_F0 * code(const basicAC_F0 & args) const - { - - return new ForAllLoopOp(args); - } - ForAllLoop() :OneOperator(atype(),atype(),atype()){ - this->ellipse=true; - } - +template< class F > +class ForAllLoop : public OneOperator { + public: + typedef typename F::Tab T; + class ForAllLoopOp : public ForAllLoopOpBase { + public: + F f; + ForAllLoopOp(const basicAC_F0 &args) : ForAllLoopOpBase(atype< T >( ), args), f((const ForAllLoopOpBase *)this) {} + AnyType operator( )(Stack s) const { return this->f.f(s); } + }; + E_F0 *code(const basicAC_F0 &args) const { return new ForAllLoopOp(args); } + ForAllLoop( ) : OneOperator(atype< NothingType >( ), atype< T >( ), atype< PolymorphicLoop * >( )) { this->ellipse = true; } }; #endif - - diff --git a/src/fflib/AFunction2.cpp b/src/fflib/AFunction2.cpp index 0fc8ccdb1..1604ae3c7 100644 --- a/src/fflib/AFunction2.cpp +++ b/src/fflib/AFunction2.cpp @@ -25,8 +25,8 @@ along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//#pragma dont_inline on -//#pragma inline_depth(1) +// #pragma dont_inline on +// #pragma inline_depth(1) // TODO: remove this block as soon as autoconf is removed from FreeFem++ #ifndef CMAKE @@ -47,972 +47,833 @@ #include "rgraph.hpp" #include "InitFunct.hpp" -vector > *debugstack=0; +vector< pair< const E_Routine *, int > > *debugstack = 0; +class vectorOfInst : public E_F0mps { + public: + int n; + Expression *v; + vectorOfInst(int k) : n(k), v(new Expression[k]) { + ffassert(v); + for (int i = 0; i < n; ++i) v[i] = 0; + } + ~vectorOfInst( ) { delete[] v; } + bool empty( ) const { return n; } -class vectorOfInst : public E_F0mps { public: - int n; - Expression * v; - vectorOfInst(int k): n(k),v(new Expression[k]) {ffassert(v); - for(int i=0;i=0) j = n-j; - else j =0; - if(verbosity>999) cout << " eval vectorOfInst " << j << " " << n << endl; - for (int i=j;i= 0) + j = n - j; + else + j = 0; + if (verbosity > 999) cout << " eval vectorOfInst " << j << " " << n << endl; + for (int i = j; i < n; ++i) { + ffassert(v[i]); + (*(v[i]))(s); } + } - private: + private: vectorOfInst(const vectorOfInst &); void operator=(const vectorOfInst &); }; -double VersionNumber(); - -OneOperator::pair_find OneOperator::Find(const ArrayOfaType & at)const - { - const OneOperator *w=0,*oo; - int nn=0,p=-10000; - for (int ncast=0;ncast<=n;ncast++) // loop on the number of cast - { - p=-10000; - for (oo=this;oo;oo=oo->next) - if (oo->pref>=p && oo->WithCast(at,ncast)) - { - if(ppref) {nn=0;p=oo->pref;} - nn++; - w=oo;} - if (nn) return make_pair(w,nn); - } - for (oo=this;oo;oo=oo->next) - if (oo->WithCast(at)) - {nn++; - w=oo;} - return make_pair(w,nn); -} - -OneOperator::pair_find OneOperator::FindWithOutCast(const ArrayOfaType & at)const - { - const OneOperator *w=0,*oo; - int n=0; - for (oo=this;oo;oo=oo->next) - if (oo->WithOutCast(at)) - {n++; - w=oo;} - return make_pair(w,n); -} +double VersionNumber( ); -// <> -OneOperator* OneOperator::FindSameR(const ArrayOfaType & at) - { - if (this==tnull) return 0; - OneOperator *oo,*r; - int n=0; - for (oo=this;oo;oo=oo->next) - { - if (at==*oo) n++,r=oo; - else if (oo->WithOutCast(at)) n++,r=oo; +OneOperator::pair_find OneOperator::Find(const ArrayOfaType &at) const { + const OneOperator *w = 0, *oo; + int nn = 0, p = -10000; + for (int ncast = 0; ncast <= n; ncast++) // loop on the number of cast + { + p = -10000; + for (oo = this; oo; oo = oo->next) + if (oo->pref >= p && oo->WithCast(at, ncast)) { + if (p < oo->pref) { + nn = 0; + p = oo->pref; } - return n==1 ? r : 0; + nn++; + w = oo; + } + if (nn) return make_pair(w, nn); + } + for (oo = this; oo; oo = oo->next) + if (oo->WithCast(at)) { + nn++; + w = oo; + } + return make_pair(w, nn); } -void OneOperator::Show(ostream &f) const -{ - const OneOperator *oo; - for (oo=this;oo;oo=oo->next) - f << "\t (" << *oo << ")\n"; - } +OneOperator::pair_find OneOperator::FindWithOutCast(const ArrayOfaType &at) const { + const OneOperator *w = 0, *oo; + int n = 0; + for (oo = this; oo; oo = oo->next) + if (oo->WithOutCast(at)) { + n++; + w = oo; + } + return make_pair(w, n); +} -void OneOperator::Show(const ArrayOfaType & at,ostream &f) const -{ - const OneOperator *oo; - int n=0,np=0; - for (oo=this;oo;oo=oo->next) - if (oo->WithOutCast(at)) {n++;f << "\t (" << *oo << ")\n";} - if(n==0) - for (oo=this;oo;oo=oo->next) - if (oo->WithCast(at)) { - n++; - if (oo->pref) np++; - if (oo->pref) - f << " c(" << oo->pref << ") \t (" << *oo << ")\n" ; - else f << " \t c(" << *oo << ")\n"; - } - if (n==0) - { - f << " List of choices "<< endl; - Show(f); - } - else if (np != 1) - f << " We have ambiguity " << n << endl; - } - -const OneOperator * Polymorphic::Find(const char *op, const ArrayOfaType &at) const - { - const_iterator i=m.find(op); - int nf=0; - if (i!=m.end()) - { - OneOperator::pair_find r=i->second->Find(at); - if (r.second==1) return r.first; - nf=max(nf,r.second); - } - if(nf) { cerr << "\n Warning ambiguity Polymorphic Find "<< nf << endl; - Show(op,at,cerr); } - return 0; - } -const OneOperator * Polymorphic::FindWithOutCast(const char *op, const ArrayOfaType &at) const - { - int nf=0; - const_iterator i=m.find(op); - if (i!=m.end()) - { - OneOperator::pair_find r=i->second->FindWithOutCast(at); - if (r.second==1) return r.first; - nf=max(nf,r.second); - } - if(nf) { cerr << "\n Warning ambiguity Polymorphic FindWithOutCast "<> +OneOperator *OneOperator::FindSameR(const ArrayOfaType &at) { + if (this == tnull) return 0; + OneOperator *oo, *r; + int n = 0; + for (oo = this; oo; oo = oo->next) { + if (at == *oo) + n++, r = oo; + else if (oo->WithOutCast(at)) + n++, r = oo; } + return n == 1 ? r : 0; +} +void OneOperator::Show(ostream &f) const { + const OneOperator *oo; + for (oo = this; oo; oo = oo->next) f << "\t (" << *oo << ")\n"; +} -void Polymorphic::Show(const char *op,const ArrayOfaType & at,ostream &f) const - { - const_iterator i=m.find(op); - if (i==m.end()) f << " unknown " << op << " operator " << endl; - else i->second->Show(at,f); +void OneOperator::Show(const ArrayOfaType &at, ostream &f) const { + const OneOperator *oo; + int n = 0, np = 0; + for (oo = this; oo; oo = oo->next) + if (oo->WithOutCast(at)) { + n++; + f << "\t (" << *oo << ")\n"; + } + if (n == 0) + for (oo = this; oo; oo = oo->next) + if (oo->WithCast(at)) { + n++; + if (oo->pref) np++; + if (oo->pref) + f << " c(" << oo->pref << ") \t (" << *oo << ")\n"; + else + f << " \t c(" << *oo << ")\n"; + } + if (n == 0) { + f << " List of choices " << endl; + Show(f); + } else if (np != 1) + f << " We have ambiguity " << n << endl; +} + +const OneOperator *Polymorphic::Find(const char *op, const ArrayOfaType &at) const { + const_iterator i = m.find(op); + int nf = 0; + if (i != m.end( )) { + OneOperator::pair_find r = i->second->Find(at); + if (r.second == 1) return r.first; + nf = max(nf, r.second); + } + if (nf) { + cerr << "\n Warning ambiguity Polymorphic Find " << nf << endl; + Show(op, at, cerr); } + return 0; +} +const OneOperator *Polymorphic::FindWithOutCast(const char *op, const ArrayOfaType &at) const { + int nf = 0; + const_iterator i = m.find(op); + if (i != m.end( )) { + OneOperator::pair_find r = i->second->FindWithOutCast(at); + if (r.second == 1) return r.first; + nf = max(nf, r.second); + } + if (nf) { + cerr << "\n Warning ambiguity Polymorphic FindWithOutCast " << op << " " << nf << endl; + Show(op, at, cerr); + } + return 0; +} + +void Polymorphic::Show(const char *op, const ArrayOfaType &at, ostream &f) const { + const_iterator i = m.find(op); + if (i == m.end( )) + f << " unknown " << op << " operator " << endl; + else + i->second->Show(at, f); +} // <> cf [[file:AFunction.hpp::C_F0_constructor_pop_char_basicAC_F0_decl]] -C_F0::C_F0(const Polymorphic * poly,const char *op,const basicAC_F0 & p) -{ - ArrayOfaType at(p); - if (poly) { // a Polymorphic => polymorphisme - const OneOperator * ff=poly->Find(op,at); - if (ff) { - if( verbosity>9999) {cout << endl; - poly->Show(op,at,cout); - cout << op << ": (in " << at << ") => " << " " << *ff<< "\n\n";} - - // [[file:AFunction.hpp::OneOperator_code2]] - *this= ff->code2(p); - } - else - { if(mpirank==0) - { - cerr << " error operator " << op << " " << at << endl; - poly->Show(op,at,cerr); - poly->Find(op,at); - } - CompileError(); - } +C_F0::C_F0(const Polymorphic *poly, const char *op, const basicAC_F0 &p) { + ArrayOfaType at(p); + if (poly) { // a Polymorphic => polymorphisme + const OneOperator *ff = poly->Find(op, at); + if (ff) { + if (verbosity > 9999) { + cout << endl; + poly->Show(op, at, cout); + cout << op << ": (in " << at << ") => " << " " << *ff << "\n\n"; + } + + // [[file:AFunction.hpp::OneOperator_code2]] + *this = ff->code2(p); + } else { + if (mpirank == 0) { + cerr << " error operator " << op << " " << at << endl; + poly->Show(op, at, cerr); + poly->Find(op, at); + } + CompileError( ); } - else { - // no polymorphisme - if(mpirank==0){ - cerr << " const Polymorphic * poly,const char *op,const basicAC_F0 & p) " << endl; - cerr << op << " " << at << endl; - - } - CompileError(); - } + } else { + // no polymorphisme + if (mpirank == 0) { + cerr << " const Polymorphic * poly,const char *op,const basicAC_F0 & p) " << endl; + cerr << op << " " << at << endl; } + CompileError( ); + } +} // operator without parameter -C_F0::C_F0(const Polymorphic * pop,const char *op) -{ - basicAC_F0 p; - p=0; - *this= C_F0(pop,op,p); +C_F0::C_F0(const Polymorphic *pop, const char *op) { + basicAC_F0 p; + p = 0; + *this = C_F0(pop, op, p); } // operator unaire -C_F0::C_F0(const Polymorphic * pop,const char *op,const C_F0 & aa) -{ - basicAC_F0 p; +C_F0::C_F0(const Polymorphic *pop, const char *op, const C_F0 &aa) { + basicAC_F0 p; C_F0 a(aa); - p=a; - *this= C_F0(pop,op,p); + p = a; + *this = C_F0(pop, op, p); } // <> operator binaire -C_F0::C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b) -{ - C_F0 tab[2]={a,b}; +C_F0::C_F0(const Polymorphic *pop, const char *op, const C_F0 &a, const C_F0 &b) { + C_F0 tab[2] = {a, b}; basicAC_F0 p; - p=make_pair(2,tab); + p = make_pair< int, C_F0 * >(2, tab); // [[file:AFunction.hpp::C_F0_constructor_pop_char_basicAC_F0_decl]] - *this=C_F0(pop,op,p); + *this = C_F0(pop, op, p); } // operator trinaire -C_F0::C_F0(const Polymorphic * pop,const char *op,const C_F0 & a,const C_F0 & b,const C_F0 & c) -{ - C_F0 tab[3]={a,b,c}; - basicAC_F0 p; - p=make_pair(3,tab); - *this= C_F0(pop,op,p); -} - - - OneOperator::~OneOperator(){ - OneOperator * d=next; - next=0; - if(! CodeAlloc::cleanning) // hash FH (pour les fuite de m�moire) - while(d) - { - OneOperator * dd=d->next; - d->next=0; - delete d; - d=dd; - } - } +C_F0::C_F0(const Polymorphic *pop, const char *op, const C_F0 &a, const C_F0 &b, const C_F0 &c) { + C_F0 tab[3] = {a, b, c}; + basicAC_F0 p; + p = make_pair< int, C_F0 * >(3, tab); + *this = C_F0(pop, op, p); +} - OneOperator::OneOperator(aType rr) - : ArrayOfaType(),r(rr),next(0),pref(0) {throwassert(r);} - OneOperator::OneOperator(aType rr,aType a) - : ArrayOfaType(a,false),r(rr),next(0),pref(0) {throwassert(rr && a );} - OneOperator::OneOperator(aType rr,aType a,aType b) - : ArrayOfaType(a,b,false),r(rr),next(0),pref(0) { - throwassert(rr && a && b);} - OneOperator::OneOperator(aType rr,aType a,aType b,aType c) - : ArrayOfaType(a,b,c,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c);} - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d) - : ArrayOfaType(a,b,c,d,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c);} - - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) - : ArrayOfaType(a,b,c,d,e,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d);} // Added by Fabian Dortu (5 parameters) - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) - : ArrayOfaType(a,b,c,d,e,f,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d && e && f);} // Added by Fabian Dortu (6 parameters) - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g) - : ArrayOfaType(a,b,c,d,e,f,g,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d && e && f && g);} // Added by Fabian Dortu (7 parameters) - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h) - : ArrayOfaType(a,b,c,d,e,f,g,h,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d && e && f && g && h);} // Added by Fabian Dortu (8 parameters) - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i) - : ArrayOfaType(a,b,c,d,e,f,g,h,i,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d && e && f && g && h && i);} // Added by Fabian Dortu (9 parameters) - OneOperator::OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f, aType g, aType h, aType i, aType j) - : ArrayOfaType(a,b,c,d,e,f,g,h,i,j,false),r(rr),next(0),pref(0) - {throwassert(rr && a && b && c && d && e && f && g && h && i && j);} // Added by Fabian Dortu (10 parameters) - - - - OneOperator::OneOperator(aType rr,const ArrayOfaType &ta) - : ArrayOfaType(ta),r(rr),next(0),pref(0) - {throwassert(rr);} - OneOperator::OneOperator(aType rr,bool ellipse) - : ArrayOfaType(ellipse),r(rr),next(0),pref(0) - {throwassert(rr );} - OneOperator::OneOperator(aType rr,const ListOfId *l) - : ArrayOfaType(l),r(rr),next(0),pref(0) - {throwassert(rr );} - -void Polymorphic::Addp (const char *op, Value pp, ...) const { - pair p = m.insert(pair(op, pp)); +OneOperator::~OneOperator( ) { + OneOperator *d = next; + next = 0; + if (!CodeAlloc::cleanning) // hash FH (pour les fuite de m�moire) + while (d) { + OneOperator *dd = d->next; + d->next = 0; + delete d; + d = dd; + } +} + +OneOperator::OneOperator(aType rr) : ArrayOfaType( ), r(rr), next(0), pref(0) { throwassert(r); } +OneOperator::OneOperator(aType rr, aType a) : ArrayOfaType(a, false), r(rr), next(0), pref(0) { throwassert(rr && a); } +OneOperator::OneOperator(aType rr, aType a, aType b) : ArrayOfaType(a, b, false), r(rr), next(0), pref(0) { throwassert(rr && a && b); } +OneOperator::OneOperator(aType rr, aType a, aType b, aType c) : ArrayOfaType(a, b, c, false), r(rr), next(0), pref(0) { throwassert(rr && a && b && c); } +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d) : ArrayOfaType(a, b, c, d, false), r(rr), next(0), pref(0) { throwassert(rr && a && b && c); } + +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e) : ArrayOfaType(a, b, c, d, e, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d); +} // Added by Fabian Dortu (5 parameters) +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f) : ArrayOfaType(a, b, c, d, e, f, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d && e && f); +} // Added by Fabian Dortu (6 parameters) +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g) : ArrayOfaType(a, b, c, d, e, f, g, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d && e && f && g); +} // Added by Fabian Dortu (7 parameters) +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h) : ArrayOfaType(a, b, c, d, e, f, g, h, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d && e && f && g && h); +} // Added by Fabian Dortu (8 parameters) +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h, aType i) : ArrayOfaType(a, b, c, d, e, f, g, h, i, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d && e && f && g && h && i); +} // Added by Fabian Dortu (9 parameters) +OneOperator::OneOperator(aType rr, aType a, aType b, aType c, aType d, aType e, aType f, aType g, aType h, aType i, aType j) + : ArrayOfaType(a, b, c, d, e, f, g, h, i, j, false), r(rr), next(0), pref(0) { + throwassert(rr && a && b && c && d && e && f && g && h && i && j); +} // Added by Fabian Dortu (10 parameters) + +OneOperator::OneOperator(aType rr, const ArrayOfaType &ta) : ArrayOfaType(ta), r(rr), next(0), pref(0) { throwassert(rr); } +OneOperator::OneOperator(aType rr, bool ellipse) : ArrayOfaType(ellipse), r(rr), next(0), pref(0) { throwassert(rr); } +OneOperator::OneOperator(aType rr, const ListOfId *l) : ArrayOfaType(l), r(rr), next(0), pref(0) { throwassert(rr); } + +void Polymorphic::Addp(const char *op, Value pp, ...) const { + pair< iterator, bool > p = m.insert(pair< const Key, Value >(op, pp)); Value f = p.first->second; - if (!p.second) // not insert => old + if (!p.second) // not insert => old *f += *pp; va_list ap; va_start(ap, pp); - for (pp = va_arg(ap, OneOperator*); pp; pp = va_arg(ap, OneOperator*)) - *f += *pp; + for (pp = va_arg(ap, OneOperator *); pp; pp = va_arg(ap, OneOperator *)) *f += *pp; va_end(ap); } -void Polymorphic::Add(const char * op,Value *pp) const -{ - if (*pp) - { - pair p=m.insert(pair(op,*pp)); - Value f= p.first->second; - if (!p.second) // not insert => old +void Polymorphic::Add(const char *op, Value *pp) const { + if (*pp) { + pair< iterator, bool > p = m.insert(pair< const Key, Value >(op, *pp)); + Value f = p.first->second; + if (!p.second) // not insert => old *f += **pp; pp++; - for(;*pp;pp++) - *f += **pp; - } - + for (; *pp; pp++) *f += **pp; + } } - // <> - int FindType(const char * name) - { - C_F0 r; - - ListOfTOfId::const_iterator i=tables_of_identifier.begin(); - for(;i!=tables_of_identifier.end();++i) - { - TableOfIdentifier * ti=*i; - r = ti->Find(name); - if (r.NotNull()) return r.TYPEOFID(); - } - return 0; - } +int FindType(const char *name) { + C_F0 r; + + ListOfTOfId::const_iterator i = tables_of_identifier.begin( ); + for (; i != tables_of_identifier.end( ); ++i) { + TableOfIdentifier *ti = *i; + r = ti->Find(name); + if (r.NotNull( )) return r.TYPEOFID( ); + } + return 0; +} /// <> uses [[file:global.cpp::tables_of_identifier]] -C_F0 Find(const char * name) -{ - C_F0 r; - ListOfTOfId::const_iterator i=tables_of_identifier.begin(); - for(;i!=tables_of_identifier.end();++i) - { - TableOfIdentifier * ti=*i; - r = ti->Find(name); - if (r.NotNull()) return r; - } - if(mpirank==0) - cerr << " The Identifier " << name << " does not exist " << endl; - CompileError(); - return r; +C_F0 Find(const char *name) { + C_F0 r; + ListOfTOfId::const_iterator i = tables_of_identifier.begin( ); + for (; i != tables_of_identifier.end( ); ++i) { + TableOfIdentifier *ti = *i; + r = ti->Find(name); + if (r.NotNull( )) return r; + } + if (mpirank == 0) cerr << " The Identifier " << name << " does not exist " << endl; + CompileError( ); + return r; } -vectorOfInst* TableOfIdentifier::newdestroy() -{ - int k=0; - for (pKV * i=listofvar;i;i=i->second.next) - { - if (i->second.del && i->second.first->ExistDestroy() ) - assert(i->second.first); - if (i->second.del && i->second.first->ExistDestroy() ) k++; - } - ffassert(nIdWithDelete==k); -// new code - vectorOfInst * l= new vectorOfInst(k); - int j=0; - for (pKV * i=listofvar;i;i=i->second.next) - if (i->second.del && i->second.first->ExistDestroy()) - l->v[j++]=i->second.first->Destroy(i->second) ; - ffassert(j==k); - return l; -} -C_F0 TableOfIdentifier::destroy() {return C_F0(newdestroy());} - void TableOfIdentifier::clear() - { - for (iterator i=m.begin();i!=m.end();++i) - { - // delete i->first; - } - m.clear(); - } - -Expression basicForEachType::Destroy(const C_F0 & e) const -{ - return destroy ? NewExpression(destroy,e) : (Expression) e; +vectorOfInst *TableOfIdentifier::newdestroy( ) { + int k = 0; + for (pKV *i = listofvar; i; i = i->second.next) { + if (i->second.del && i->second.first->ExistDestroy( )) assert(i->second.first); + if (i->second.del && i->second.first->ExistDestroy( )) k++; + } + ffassert(nIdWithDelete == k); + // new code + vectorOfInst *l = new vectorOfInst(k); + int j = 0; + for (pKV *i = listofvar; i; i = i->second.next) + if (i->second.del && i->second.first->ExistDestroy( )) l->v[j++] = i->second.first->Destroy(i->second); + ffassert(j == k); + return l; } - -basicForEachType::~basicForEachType() - { - if(casting) delete casting; - ti.clear(); +C_F0 TableOfIdentifier::destroy( ) { return C_F0(newdestroy( )); } +void TableOfIdentifier::clear( ) { + for (iterator i = m.begin( ); i != m.end( ); ++i) { + // delete i->first; } + m.clear( ); +} -basicForEachType::basicForEachType(const type_info & k, - const size_t s, - const E_F1_funcT_Type * p, - basicForEachType *rr, - Function1 iv,Function1 id, Function1 dreturn) - : ktype(&k),//ktypefunc(0), - size(s), - un_ptr_type(rr?rr:this), - casting(0), // no casting to - un_ptr(p), - InitExp(iv), - DoOnReturn(dreturn), - //funct_type(0), - destroy(id) {} - void basicForEachType::SetArgs(const ListOfId *lid) const -{ SHOWVERB(cout << "SetArgs::\n ") ;ffassert(lid==0 || lid->size()==0);} - +Expression basicForEachType::Destroy(const C_F0 &e) const { return destroy ? NewExpression(destroy, e) : (Expression)e; } +basicForEachType::~basicForEachType( ) { + if (casting) delete casting; + ti.clear( ); +} - TableOfIdentifier::TableOfIdentifier() : listofvar(0),nIdWithDelete(0) {} - TableOfIdentifier:: ~TableOfIdentifier() {} +basicForEachType::basicForEachType(const type_info &k, const size_t s, const E_F1_funcT_Type *p, basicForEachType *rr, Function1 iv, Function1 id, Function1 dreturn) + : ktype(&k), // ktypefunc(0), + size(s), un_ptr_type(rr ? rr : this), casting(0), // no casting to + un_ptr(p), InitExp(iv), DoOnReturn(dreturn), + // funct_type(0), + destroy(id) {} +void basicForEachType::SetArgs(const ListOfId *lid) const { + SHOWVERB(cout << "SetArgs::\n "); + ffassert(lid == 0 || lid->size( ) == 0); +} +TableOfIdentifier::TableOfIdentifier( ) : listofvar(0), nIdWithDelete(0) {} +TableOfIdentifier::~TableOfIdentifier( ) {} -Block::Block(Block * f):fatherblock(f),top(f?f->top:BeginOffset*sizeof(void*)),topmax(top) - { - itabl=tables_of_identifier.insert(tables_of_identifier.begin(),&table); - } -Block::~Block(){} +Block::Block(Block *f) : fatherblock(f), top(f ? f->top : BeginOffset * sizeof(void *)), topmax(top) { itabl = tables_of_identifier.insert(tables_of_identifier.begin( ), &table); } +Block::~Block( ) {} - vectorOfInst * Block::snewclose(Block *& c) { - Block * a=c; - tables_of_identifier.erase(a->itabl); - c=a->fatherblock; - if (a->fatherblock) {a->fatherblock->topmax=a->topmax; - a->fatherblock->top=a->top;} - - vectorOfInst * r; - r = a->table.newdestroy(); - delete a; - return r;} +vectorOfInst *Block::snewclose(Block *&c) { + Block *a = c; + tables_of_identifier.erase(a->itabl); + c = a->fatherblock; + if (a->fatherblock) { + a->fatherblock->topmax = a->topmax; + a->fatherblock->top = a->top; + } -CC_F0 Block::close(Block *& c,C_F0 ins) -{ - CListOfInst inst; - CC_F0 cins; cins=ins; - inst = cins; - inst.setclose(Block::snewclose(c)); - CC_F0 rr; - rr=inst; - return rr; + vectorOfInst *r; + r = a->table.newdestroy( ); + delete a; + return r; } - CC_F0 Block::close(Block *& c,CListOfInst inst) { +CC_F0 Block::close(Block *&c, C_F0 ins) { + CListOfInst inst; + CC_F0 cins; + cins = ins; + inst = cins; + inst.setclose(Block::snewclose(c)); + CC_F0 rr; + rr = inst; + return rr; +} - inst.setclose(Block::snewclose(c)); - CC_F0 rr; - rr=inst; - return rr; - } +CC_F0 Block::close(Block *&c, CListOfInst inst) { - Block * Block::open(Block *& cb) - { - Block * ncb = new Block(cb); - if(verbosity>99) cout << " Block::open " << ncb << " " << cb << endl; + inst.setclose(Block::snewclose(c)); + CC_F0 rr; + rr = inst; + return rr; +} - return cb = ncb; - } +Block *Block::open(Block *&cb) { + Block *ncb = new Block(cb); + if (verbosity > 99) cout << " Block::open " << ncb << " " << cb << endl; + return cb = ncb; +} -const Type_Expr & TableOfIdentifier::New(Key k,const Type_Expr & v,bool del) +const Type_Expr &TableOfIdentifier::New(Key k, const Type_Expr &v, bool del) { + if (this != &Global) { + if (Global.m.find(k) != Global.m.end( )) { + if (mpirank == 0 && (verbosity > 0)) cerr << "\n *** Warning The identifier " << k << " hide a Global identifier \n"; + } + } + pair< iterator, bool > p = m.insert(pKV(k, Value(v, listofvar, del))); + listofvar = &*m.find(k); + if (!p.second) { + if (mpirank == 0) { + cerr << " The identifier " << k << " exists \n"; + cerr << " \t the existing type is " << *p.first->second.first << endl; + cerr << " \t the new type is " << *v.first << endl; + } + CompileError( ); + } + if (del && v.first->ExistDestroy( )) { + nIdWithDelete++; + if (verbosity > 9999) cout << "\n \t add ExistDestroy" << endl; + } + return v; +} +void TableOfIdentifier::Add(Key k, Key op, OneOperator *p0, OneOperator *p1, OneOperator *p2, OneOperator *p3, OneOperator *p4, OneOperator *p5, OneOperator *p6) { + iterator i = m.find(k); + if (i == m.end( )) // new { - if( this != &Global) { - if ( Global.m.find(k) != Global.m.end() ) - { - if(mpirank==0 && (verbosity>0)) - cerr << "\n *** Warning The identifier " << k << " hide a Global identifier \n"; + Value poly0 = Value(atype< Polymorphic * >( ), new Polymorphic( ), listofvar); + i = m.insert(pair< const Key, Value >(k, poly0)).first; + listofvar = &*i; + } + const Polymorphic *p = dynamic_cast< const Polymorphic * >(i->second.second); + if (!p) { + if (mpirank == 0) cerr << k << " is not a Polymorphic id " << endl; + CompileError( ); + } + p->Add(op, p0, p1, p2, p3, p4, p5, p6); +} - } +ArrayOfaType::ArrayOfaType(const ListOfId *l) : n(l->size( )), t(new aType[n]), ellipse(false) { + for (int i = 0; i < n; i++) { + t[i] = (*l)[i].r; + if (!t[i]) { + if (mpirank == 0) cerr << " Argument " << i << " '" << (*l)[i].id << "' without type\n"; + CompileError("DCL routine: Argument without type "); } - pair p=m.insert(pKV(k,Value(v,listofvar,del))); - listofvar = &*m.find(k); - if (!p.second) - { - if(mpirank==0) { - cerr << " The identifier " << k << " exists \n"; - cerr << " \t the existing type is " << *p.first->second.first << endl; - cerr << " \t the new type is " << *v.first << endl; - } - CompileError(); - } - if(del && v.first->ExistDestroy() ) - { - nIdWithDelete++; - if(verbosity>9999) cout << "\n \t add ExistDestroy" << endl; + } +} + +bool ArrayOfaType::WithOutCast(const ArrayOfaType &a) const { + if ((!ellipse && (a.n != n)) || (ellipse && n > a.n)) return false; + for (int i = 0; i < n; i++) + if (!a.t[i]->SametypeRight(t[i])) return false; + return true; +} + +bool ArrayOfaType::WithCast(const ArrayOfaType &a, int nbcast) const { + if ((!ellipse && (a.n != n)) || (ellipse && n > a.n)) return false; + for (int i = 0; i < n; i++) + if (a.t[i]->SametypeRight(t[i])) + ; + else if (!t[i]->CastingFrom(a.t[i])) + return false; + else if (--nbcast < 0) + return false; + return true; +} +void basicForEachType::AddCast(CastFunc f1, CastFunc f2, CastFunc f3, CastFunc f4, CastFunc f5, CastFunc f6, CastFunc f7, CastFunc f8) { + CastFunc ff[] = {f1, f2, f3, f4, f5, f6, f7, f8, 0}; + for (int i = 0; ff[i]; i++) { + ffassert(this == *ff[i]); + if (casting->FindSameR(*ff[i])) { + if (mpirank == 0) { + cerr << " The casting to " << *ff[i] << " exists " << endl; + cerr << " List of cast " << endl; + casting->Show(cerr); } - return v; + CompileError( ); + } + if (casting) + *casting += *ff[i]; + else + casting = ff[i]; } - void TableOfIdentifier::Add(Key k,Key op,OneOperator *p0,OneOperator *p1, - OneOperator *p2,OneOperator *p3,OneOperator *p4,OneOperator *p5,OneOperator *p6) - { - iterator i= m.find(k); - if (i==m.end()) // new - { - Value poly0=Value(atype(),new Polymorphic(),listofvar); - i=m.insert(pair(k,poly0)).first; - listofvar= &*i; - } - const Polymorphic * p= dynamic_cast(i->second.second); - if ( !p) { - if(mpirank==0) - cerr << k << " is not a Polymorphic id " << endl; - CompileError(); - } - p->Add(op,p0,p1,p2,p3,p4,p5,p6); - } - - ArrayOfaType::ArrayOfaType(const ListOfId * l) - : n(l->size()),t(new aType[n]),ellipse(false) - { - for (int i=0;i a.n) ) return false; - for (int i=0;iSametypeRight(t[i])) - return false; - return true; - } - - -bool ArrayOfaType::WithCast( const ArrayOfaType & a,int nbcast) const - { - if ( ( !ellipse && (a.n != n)) || (ellipse && n > a.n) ) return false; - for (int i=0;iSametypeRight(t[i])) ; - else if (! t[i]->CastingFrom(a.t[i])) return false; - else if ( --nbcast <0) return false; - return true; - } - -void basicForEachType::AddCast(CastFunc f1,CastFunc f2,CastFunc f3,CastFunc f4, - CastFunc f5,CastFunc f6,CastFunc f7,CastFunc f8) - { - CastFunc ff[]={f1,f2,f3,f4,f5,f6,f7,f8,0}; - for (int i=0;ff[i];i++) - { - ffassert(this == *ff[i] ); - if (casting->FindSameR(*ff[i])) - { - if(mpirank==0) - { - cerr << " The casting to " << *ff[i] << " exists " << endl; - cerr << " List of cast " << endl; - casting->Show(cerr); - } - CompileError(); - } - if (casting) *casting += *ff[i]; - else casting = ff[i]; - } - } - - ostream & operator<<(ostream & f,const OneOperator & a) -{ - f << "\t " << * (a.r) << " : " <<(const ArrayOfaType &) a; - return f; } - ostream & operator<<(ostream & f,const Polymorphic & a) -{ +ostream &operator<<(ostream &f, const OneOperator &a) { + f << "\t " << *(a.r) << " : " << (const ArrayOfaType &)a; + return f; +} + +ostream &operator<<(ostream &f, const Polymorphic &a) { Polymorphic::const_iterator i; - if(&a==E_F0::tnull) return f << "Null " << endl; - for (i=a.m.begin();i!=a.m.end();i++) - { + if (&a == E_F0::tnull) return f << "Null " << endl; + for (i = a.m.begin( ); i != a.m.end( ); i++) { f << " operator" << i->first << " : " << endl; i->second->Show(f); - } + } + return f; +} +ostream &operator<<(ostream &f, const ArrayOfaType &a) { + for (int i = 0; i < a.n; i++) f << (i ? ", " : " ") << *a.t[i]; + if (a.ellipse) + f << "... "; + else + f << " "; + return f; +} +ostream &operator<<(ostream &f, const TableOfIdentifier &t) { + TableOfIdentifier::const_iterator i; + for (i = t.m.begin( ); i != t.m.end( ); i++) { + TableOfIdentifier::Value v = i->second; + f << i->first << ": " << *v.first << " <- "; + const Polymorphic *p = dynamic_cast< const Polymorphic * >(v.second); + if (p) + f << "Polymorphic " << *p << endl; + else + f << " Simple @" << v.second << endl; + } return f; } - ostream & operator<<(ostream & f,const ArrayOfaType & a) - { - for (int i=0;isecond; - f << i->first << ": " << *v.first << " <- " ; - const Polymorphic * p=dynamic_cast(v.second); - if(p) f << "Polymorphic " << *p << endl; - else f << " Simple @" << v.second << endl; - } - return f; - } -Expression NewExpression(Function1 f,Expression a) -{ +Expression NewExpression(Function1 f, Expression a) { ffassert(f); - return new E_F0_Func1(f,a); + return new E_F0_Func1(f, a); } -Expression NewExpression(Function2 f,Expression a,Expression b) -{ +Expression NewExpression(Function2 f, Expression a, Expression b) { ffassert(f); - return new E_F0_Func2(f,a,b); - + return new E_F0_Func2(f, a, b); } // <> - void ShowType(ostream & f) - { - - map::const_iterator i; - for(i=map_type.begin();i!=map_type.end();i++) - { - f << " --"<< i->first <<" = " ; - i->second->Show(f) ; - f << endl; - } - - } - - void basicForEachType::Show(ostream & f) const { - f << " " <<* this << endl; - if (casting) casting->Show(f) ; - if (ti.m.size()) - { - TableOfIdentifier::const_iterator mc=ti.m.begin(); - TableOfIdentifier::const_iterator end=ti.m.end(); - for (;mc != end;mc++) - { - f << " " << mc->first << ", type :" << *mc->second.first << endl; - const Polymorphic * op =dynamic_cast(mc->second.second) ; - if ( op ) f << *op << endl; - } - } - } - - +void ShowType(ostream &f) { + map< const string, basicForEachType * >::const_iterator i; + for (i = map_type.begin( ); i != map_type.end( ); i++) { + f << " --" << i->first << " = "; + i->second->Show(f); + f << endl; + } +} +void basicForEachType::Show(ostream &f) const { + f << " " << *this << endl; + if (casting) casting->Show(f); + if (ti.m.size( )) { + TableOfIdentifier::const_iterator mc = ti.m.begin( ); + TableOfIdentifier::const_iterator end = ti.m.end( ); + for (; mc != end; mc++) { + f << " " << mc->first << ", type :" << *mc->second.first << endl; + const Polymorphic *op = dynamic_cast< const Polymorphic * >(mc->second.second); + if (op) f << *op << endl; + } + } +} -E_Routine::E_Routine(const Routine * routine,const basicAC_F0 & args) - : code(routine->ins), - rt(routine->tret), - nbparam(args.size()), - param(new Expression[nbparam]), - name(routine->name) -{ - assert(routine->ins); - for (int i=0;i10000) cout << "E_Routine " << *routine->param[i].r << " <- " << *args[i].left() << endl; - param[i]=routine->param[i].r->CastTo(args[i]); - } +E_Routine::E_Routine(const Routine *routine, const basicAC_F0 &args) : code(routine->ins), rt(routine->tret), nbparam(args.size( )), param(new Expression[nbparam]), name(routine->name) { + assert(routine->ins); + for (int i = 0; i < args.size( ); i++) // bug pb copie des string dec 2007 FH ??????????????? + { + if (verbosity > 10000) cout << "E_Routine " << *routine->param[i].r << " <- " << *args[i].left( ) << endl; + param[i] = routine->param[i].r->CastTo(args[i]); + } }; -E_Routine::~E_Routine() { - if(verbosity>10000) cout << "~E_Routine()"<< endl; - delete [] param;} -AnyType E_Routine::operator()(Stack s) const { - debugstack->push_back(pair(this,TheCurrentLine)); - const int lgsave=BeginOffset*sizeof(void*); - char save[lgsave]; - AnyType ret=Nothing; - memcpy(save,s,lgsave); // save - AnyType *listparam; - Add2StackOfPtr2FreeA(s,listparam=new AnyType[nbparam]); - -// to day the memory gestion of the local variable are static, - for (int i=0;i(s,ParamPtrOffset) = listparam; - WhereStackOfPtr2Free(s)=new StackOfPtr2Free(s);// FH mars 2006 - - try { - ret=(*code)(s); - } - catch( E_exception & e) { - if (e.type() == E_exception::e_return) - ret = e.r; - else - ErrorExec("E_exception: break or contine not in loop ",1); - } - catch(...) { // clean and rethrow the exception - WhereStackOfPtr2Free(s)->clean(); // FH mars 2005 - memcpy(s,save,lgsave); // restore - TheCurrentLine=debugstack->back().second; - debugstack->pop_back(); - - throw ; - } +E_Routine::~E_Routine( ) { + if (verbosity > 10000) cout << "~E_Routine()" << endl; + delete[] param; +} +AnyType E_Routine::operator( )(Stack s) const { + debugstack->push_back(pair< const E_Routine *, int >(this, TheCurrentLine)); + const int lgsave = BeginOffset * sizeof(void *); + char save[lgsave]; + AnyType ret = Nothing; + memcpy(save, s, lgsave); // save + AnyType *listparam; + Add2StackOfPtr2FreeA(s, listparam = new AnyType[nbparam]); + + // to day the memory gestion of the local variable are static, + for (int i = 0; i < nbparam; i++) listparam[i] = (*param[i])(s); // set of the parameter + Stack_Ptr< AnyType >(s, ParamPtrOffset) = listparam; + WhereStackOfPtr2Free(s) = new StackOfPtr2Free(s); // FH mars 2006 + + try { + ret = (*code)(s); + } catch (E_exception &e) { + if (e.type( ) == E_exception::e_return) + ret = e.r; + else + ErrorExec("E_exception: break or contine not in loop ", 1); + } catch (...) { // clean and rethrow the exception + WhereStackOfPtr2Free(s)->clean( ); // FH mars 2005 + memcpy(s, save, lgsave); // restore + TheCurrentLine = debugstack->back( ).second; + debugstack->pop_back( ); + + throw; + } // (*clean)(s); // the clean is done in CleanE_Routine delete . - // delete [] listparam; after return - memcpy(s,save,lgsave); // restore - TheCurrentLine=debugstack->back().second; - debugstack->pop_back(); - - // il faudrait que les variable locale soit detruire apres le return - // cf routine clean, pour le cas ou l'on retourne un tableau local. - // plus safe ????? FH. (fait 2008) - // mais pb si a = f()+g() OK les pointeurs des instruction sont detruit - // en fin d'instruction programme de l'appelant FH 2007 - // ... ou alors changer le return ???? qui doit copie le resultat.. (voir) - return ret; -} -extern Block *currentblock;// def in lg.ypp -void ListOfInst::Add(const C_F0 & ins) { - if( (!ins.Empty()) ) { - if( verbosity > 9999 ) - cout << " Add " << n << " " << TheCurrentLine << endl; - if (n%nx==0){ - Expression * l = new Expression [n+nx]; - int * ln = new int [n+nx]; - int * lsd = new int [n+nx]; - for (int i=0;inIdWithDelete(); - list[n++] = ins; + // delete [] listparam; after return + memcpy(s, save, lgsave); // restore + TheCurrentLine = debugstack->back( ).second; + debugstack->pop_back( ); + + // il faudrait que les variable locale soit detruire apres le return + // cf routine clean, pour le cas ou l'on retourne un tableau local. + // plus safe ????? FH. (fait 2008) + // mais pb si a = f()+g() OK les pointeurs des instruction sont detruit + // en fin d'instruction programme de l'appelant FH 2007 + // ... ou alors changer le return ???? qui doit copie le resultat.. (voir) + return ret; +} +extern Block *currentblock; // def in lg.ypp +void ListOfInst::Add(const C_F0 &ins) { + if ((!ins.Empty( ))) { + if (verbosity > 9999) cout << " Add " << n << " " << TheCurrentLine << endl; + if (n % nx == 0) { + Expression *l = new Expression[n + nx]; + int *ln = new int[n + nx]; + int *lsd = new int[n + nx]; + for (int i = 0; i < n; i++) { + l[i] = list[i]; + ln[i] = linenumber[i]; + lsd[i] = lsldel[i]; + } + delete[] list; + delete[] linenumber; + delete[] lsldel; + list = l; + linenumber = ln; + lsldel = lsd; } + throwassert(list); + linenumber[n] = TheCurrentLine; + lsldel[n] = currentblock->nIdWithDelete( ); + list[n++] = ins; + } } /// <> Iteratively calls each item in the local array #list of type #Expression -AnyType ListOfInst::operator()(Stack s) const { - AnyType r; - int i; - double s0=CPUtime(),s1=s0,ss0=s0; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(s); - try { // modif FH oct 2006 - for (i=0;iclean(); // modif FH mars 2006 clean Ptr - s1=CPUtime(); - if (showCPU) - cout << " CPU: "<< i <<" " << linenumber[i] << ": " << s1-s0 << "s" << " " << s1-ss0 << "s" << " / " << " " <n) { - if(verbosity>99999 ) cout << " ListOfInst::atclose() " << n << " " << atclose->n << " // " << lsldel[n-1] << endl; - atclose->eval(s,atclose->n);}// Add for sep 2016 FH +AnyType ListOfInst::operator( )(Stack s) const { + AnyType r; + int i; + double s0 = CPUtime( ), s1 = s0, ss0 = s0; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(s); + try { // modif FH oct 2006 + for (i = 0; i < n; i++) { + TheCurrentLine = linenumber[i]; + r = (*list[i])(s); + sptr->clean( ); // modif FH mars 2006 clean Ptr + s1 = CPUtime( ); + if (showCPU) cout << " CPU: " << i << " " << linenumber[i] << ": " << s1 - s0 << "s" << " " << s1 - ss0 << "s" << " / " << " " << lsldel[i] << " " << mpirank << endl; + s0 = CPUtime( ); } - catch( E_exception & e) - { - if(verbosity>999) cout << " catch E_exception " << i << " " << lsldel[i] << endl; - if(atclose) {atclose->eval(s,lsldel[i]);}// Add sep 2016 FH for clean init varaible - if (e.type() != E_exception::e_return) - sptr->clean(); // pour ne pas detruire la valeur retourne ... FH jan 2007 - throw; // rethow + if (atclose && atclose->n) { + if (verbosity > 99999) cout << " ListOfInst::atclose() " << n << " " << atclose->n << " // " << lsldel[n - 1] << endl; + atclose->eval(s, atclose->n); + } // Add for sep 2016 FH + } catch (E_exception &e) { + if (verbosity > 999) cout << " catch E_exception " << i << " " << lsldel[i] << endl; + if (atclose) { + atclose->eval(s, lsldel[i]); + } // Add sep 2016 FH for clean init varaible + if (e.type( ) != E_exception::e_return) sptr->clean( ); // pour ne pas detruire la valeur retourne ... FH jan 2007 + throw; // rethow + } catch (...) { + if (verbosity > 999) cout << " catch .... " << i << " " << lsldel[i] << endl; + if (atclose) { + atclose->eval(s, lsldel[i]); } - catch(...) - { - if(verbosity>999) cout << " catch .... " << i << " " << lsldel[i] << endl; - if(atclose) {atclose->eval(s,lsldel[i]);} - sptr->clean(); - throw; + sptr->clean( ); + throw; + } + return r; +} + +void ShowDebugStack( ) { + if (mpisize) + cerr << " current line = " << TheCurrentLine << " mpirank " << mpirank << " / " << mpisize << endl; + else + cerr << " current line = " << TheCurrentLine << endl; + if (debugstack) + for (int i = 0; i < debugstack->size( ); ++i) { + + cerr << " call " << debugstack->at(i).first->name << " at line " << debugstack->at(i).second << endl; } - return r;} - -void ShowDebugStack() - { - if (mpisize) - cerr << " current line = " << TheCurrentLine - << " mpirank " << mpirank << " / " << mpisize <at(i).first->name<< " at line " - <at(i).second << endl; - } - } - - - int E_F0::Optimize(deque > &l,MapOfE_F0 & m, size_t & n) - { - int rr = find(m); - if (rr) return rr; - if( (verbosity / 10)% 10 == 1) - cout << "\n new expression : " << n << " mi=" << MeshIndependent()<< " " << typeid(*this).name() - << " :" << *this << endl; - return insert(this,l,m,n); - } - - -class E_F0para :public E_F0 { public: +} + +int E_F0::Optimize(deque< pair< Expression, int > > &l, MapOfE_F0 &m, size_t &n) { + int rr = find(m); + if (rr) return rr; + if ((verbosity / 10) % 10 == 1) cout << "\n new expression : " << n << " mi=" << MeshIndependent( ) << " " << typeid(*this).name( ) << " :" << *this << endl; + return insert(this, l, m, n); +} + +class E_F0para : public E_F0 { + public: const int i; - AnyType operator()(Stack s) const { - return Stack_Ptr(s,ParamPtrOffset)[i]; - } - E_F0para(int ii) : i(ii){} + AnyType operator( )(Stack s) const { return Stack_Ptr< AnyType >(s, ParamPtrOffset)[i]; } + E_F0para(int ii) : i(ii) {} }; -Routine::Routine(aType tf,aType tr,const char * iden, ListOfId *l,Block * & cb) - : OneOperator(tr,l),offset(cb->OffSet(sizeof(void*))), - tfunc(tf),tret(tr),name(iden),param(*l), - currentblock(new Block(cb)),ins(0)//,clean(0) - { - delete l; // add FH 24032005 (trap ) - cb = currentblock; - for (size_t i=0;iNewID(param[i].r,param[i].id,C_F0(new E_F0para(i),// modif FH 2007 - param[i].r), - !param[i].ref); - } - } - Block * Routine::Set(CListOfInst instrs) - { - instrs.setclose(Block::snewclose(currentblock)); - ins=instrs; - return currentblock;} - - -E_F0 * Routine::code(const basicAC_F0 & args) const +Routine::Routine(aType tf, aType tr, const char *iden, ListOfId *l, Block *&cb) + : OneOperator(tr, l), offset(cb->OffSet(sizeof(void *))), tfunc(tf), tret(tr), name(iden), param(*l), currentblock(new Block(cb)), ins(0) //,clean(0) { - - return new E_Routine(this,args); + delete l; // add FH 24032005 (trap ) + cb = currentblock; + for (size_t i = 0; i < param.size( ); i++) { + currentblock->NewID(param[i].r, param[i].id, + C_F0(new E_F0para(i), // modif FH 2007 + param[i].r), + !param[i].ref); + } +} +Block *Routine::Set(CListOfInst instrs) { + instrs.setclose(Block::snewclose(currentblock)); + ins = instrs; + return currentblock; } -void basicAC_F0::SetNameParam(int n,name_and_type *l , Expression * e) const -{ - int k=0; - if ( !n && !named_parameter) return; +E_F0 *Routine::code(const basicAC_F0 &args) const { return new E_Routine(this, args); } - for (int i=0;iname()] ) - { - if(mpirank==0) - { - cerr << " missing ff type: '" <name() << "' "<< map_type.size() << "\n"; - cerr << "i= " << i << "\n"; - } - InternalError(" missing type "); - assert(map_type[l[i].type->name()]); - } - e[i]= map_type[l[i].type->name()]->CastTo(ce); - k++; - } - } - - if (!named_parameter) return; - - if ((size_t) k!= named_parameter->size()) - { - cout << " Sorry some name parameter are not used! found" << k << " == " << named_parameter->size() <begin(); ii != named_parameter->end();ii++) - { - for (int i=0;ifirst)) - goto L1; - cout << "\t the parameter is '" << ii->first << "' is unused " << endl; - L1:; - } - if ( n && mpirank==0) { - cerr << " The named parameter can be " << endl; - for (int i=0;iname() << ">\n"; +void basicAC_F0::SetNameParam(int n, name_and_type *l, Expression *e) const { + int k = 0; + if (!n && !named_parameter) return; + + for (int i = 0; i < n; i++) { + C_F0 ce = find(l[i].name); + if (ce.LeftValue( ) == 0) + e[i] = 0; + else { + if (!map_type[l[i].type->name( )]) { + if (mpirank == 0) { + cerr << " missing ff type: '" << l[i].type->name( ) << "' " << map_type.size( ) << "\n"; + cerr << "i= " << i << "\n"; + } + InternalError(" missing type "); + assert(map_type[l[i].type->name( )]); + } + e[i] = map_type[l[i].type->name( )]->CastTo(ce); + k++; + } + } + + if (!named_parameter) return; + + if ((size_t)k != named_parameter->size( )) { + cout << " Sorry some name parameter are not used! found" << k << " == " << named_parameter->size( ) << endl; + for (const_iterator ii = named_parameter->begin( ); ii != named_parameter->end( ); ii++) { + for (int i = 0; i < n; i++) + if (!strcmp(l[i].name, ii->first)) goto L1; + cout << "\t the parameter is '" << ii->first << "' is unused " << endl; + L1:; + } + if (n && mpirank == 0) { + cerr << " The named parameter can be " << endl; + for (int i = 0; i < n; i++) cerr << "\t" << l[i].name << " = <" << l[i].type->name( ) << ">\n"; } CompileError("Unused named parameter"); - } + } } - // change FH to bluid .dll -void lgerror (const char* s) - { - if(mpirank==0) - { - cerr << endl; - cerr <<" Error line number " << zzzfff->lineno() << ", in file " << zzzfff->filename() - <<", before token " <YYText() << endl - << s << endl; - } - throw(ErrorCompile(s,zzzfff->lineno(),zzzfff->YYText() )); +void lgerror(const char *s) { + if (mpirank == 0) { + cerr << endl; + cerr << " Error line number " << zzzfff->lineno( ) << ", in file " << zzzfff->filename( ) << ", before token " << zzzfff->YYText( ) << endl << s << endl; } + throw(ErrorCompile(s, zzzfff->lineno( ), zzzfff->YYText( ))); +} +C_F0 ForAll(Block *cb, ListOfId *id, C_F0 m) { + + // Block::open(cb); // new block + // decl variable + if (verbosity > 1000) cout << "InitAutoLoop ::: " << id->size( ) << " type=" << *(m.left( )) << endl; + + ffassert(id->size( ) < 4); + aType t = m.left( ); + ffassert(id->size( ) <= 0 || t->typev); + ffassert(id->size( ) <= 1 || t->typei); + ffassert(id->size( ) <= 2 || t->typej); + // missing this king of code atype->SetTypeLoop(atype(),atype()) maybe !!!! FH. + ffassert(id->size( ) < 4); + // find the size do data + aType tt[4]; + int k = 0; + if (t->typei) tt[k++] = t->typei; + if (t->typej) tt[k++] = t->typej; + if (t->typev) tt[k++] = t->typev; + + for (int i = 0; i < k; ++i) { + if (verbosity > 1000) cout << " aType = " << i << " left " << *tt[i] << " right=" << *tt[i]->right( ) << endl; + } + AC_F0 args; + args = 0; // reset + args += m; + for (int j = 0, i = id->size( ); j < id->size( ); ++j) { + --i; + C_F0 ci = cb->NewVar< LocalVariable >((*id)[i].id, tt[i]); + C_F0 cv = Find((*id)[i].id); + args += cv; + const LocalVariable *lv = dynamic_cast< LocalVariable * >((E_F0 *)cv); + if (verbosity > 1000) + cout << " new id " << tt[i] << " " << (*id)[i].id << " " << " E=" << (Expression)args[j] << " " << (Expression)ci << " " << args.size( ) - 1 << " ov: " << (lv ? lv->offset : -1) << " " + << *cv.left( ) << endl; + } + Expression loop = new PolymorphicLoop(m, args); + if (verbosity > 1000) cout << "a type: " << *atype< PolymorphicLoop * >( ) << " " << loop << endl; + return C_F0(loop, atype< PolymorphicLoop * >( )); +} - C_F0 ForAll(Block *cb,ListOfId * id,C_F0 m) -{ - -//Block::open(cb); // new block - // decl variable - if(verbosity>1000) - cout << "InitAutoLoop ::: " << id->size()<< " type=" << *(m.left()) << endl; - - ffassert(id->size()<4); - aType t=m.left() ; - ffassert(id->size()<=0 || t->typev); - ffassert(id->size()<=1 || t->typei); - ffassert(id->size()<=2 || t->typej); - // missing this king of code atype->SetTypeLoop(atype(),atype()) maybe !!!! FH. - ffassert(id->size()<4); - // find the size do data - aType tt[4]; - int k=0; - if(t->typei) tt[k++]=t->typei; - if(t->typej) tt[k++]=t->typej; - if(t->typev) tt[k++]=t->typev; - - for(int i=0;i1000) - cout << " aType = " << i << " left " << *tt[i] << " right="<< *tt[i]->right() <size(); jsize() ; ++j) - { - --i; - C_F0 ci=cb->NewVar((*id)[i].id,tt[i]); - C_F0 cv=Find((*id)[i].id); - args+=cv; - const LocalVariable *lv = dynamic_cast((E_F0*) cv); - if(verbosity>1000) - cout << " new id " << tt[i] << " "<< (*id)[i].id << " " << " E=" - << (Expression) args[j] << " " - << (Expression) ci << " " <offset: -1) << " " << *cv.left() << endl; - } - Expression loop= new PolymorphicLoop(m,args); - if(verbosity>1000) - cout << "a type: " << *atype() << " " << loop << endl; - - return C_F0(loop,atype()); -} - - C_F0 ForAll(C_F0 cloop,C_F0 inst) -{ - if(verbosity>1000) - cout << " type cloop " << *cloop.left() << " " << cloop.LeftValue() << " " << endl; - const PolymorphicLoop *loop= dynamic_cast(cloop.LeftValue()); - ffassert(loop); - AC_F0 args; - args=0; - args+=loop->t; - args+=cloop; - C_F0 instt(inst,atype()); - args+=instt; - return C_F0(TheOperators,"{}",args); -} - -void InitLoop() -{ - Dcl_Type(0); - +C_F0 ForAll(C_F0 cloop, C_F0 inst) { + if (verbosity > 1000) cout << " type cloop " << *cloop.left( ) << " " << cloop.LeftValue( ) << " " << endl; + const PolymorphicLoop *loop = dynamic_cast< const PolymorphicLoop * >(cloop.LeftValue( )); + ffassert(loop); + AC_F0 args; + args = 0; + args += loop->t; + args += cloop; + C_F0 instt(inst, atype< NothingType >( )); + args += instt; + return C_F0(TheOperators, "{}", args); } + +void InitLoop( ) { Dcl_Type< PolymorphicLoop * >(0); } diff --git a/src/fflib/AFunction_ext.hpp b/src/fflib/AFunction_ext.hpp index 5b5d73e99..d4527f518 100644 --- a/src/fflib/AFunction_ext.hpp +++ b/src/fflib/AFunction_ext.hpp @@ -3,7 +3,7 @@ // be defined. See example code in include/AFunction.hpp // Two classes must be defined (here we show an example for a function accepting 4 arguments): // -// class OneOperator4_ +// class OneOperator4_ // class E_F_F0F0F0F0_ // // Note: in file includeAFunction.hpp, the class "OneOperator" (around line 400) mut be modified. @@ -11,214 +11,155 @@ // Add F. Hecht oct 2009 // **** 2 paramters with the stack // class OneOperator2s_ -// class E_F_F0F0s_ +// class E_F_F0F0s_ #ifndef AFUNCTION_EXT_HPP__ -#define AFUNCTION_EXT_HPP__ -template // extend (4th arg.) -class E_F_F0F0s_ :public E { public: // extend - typedef R (*func)(Stack s,const A0 &,const A1 & ) ; // extend (statck +2th arg.) +#define AFUNCTION_EXT_HPP__ +template< class R, class A0, class A1, class E = E_F0 > // extend (4th arg.) +class E_F_F0F0s_ : public E { + public: // extend + typedef R (*func)(Stack s, const A0 &, const A1 &); // extend (statck +2th arg.) func f; - Expression a0,a1; // extend - E_F_F0F0s_(func ff, - Expression aa0, - Expression aa1) - : f(ff), a0(aa0), a1(aa1) {} // extend (2th arg.) - AnyType operator()(Stack s) const - {return SetAny( f( s, - GetAny((*a0)(s)), - GetAny((*a1)(s)) ) );} // extend (2th arg.) - virtual size_t nbitem() const {return a1->nbitem(); } // modif ??? - bool MeshIndependent() const - {return E::MeshIndependent() &&a0->MeshIndependent() && a1->MeshIndependent() ;} // extend (2th arg.) - + Expression a0, a1; // extend + E_F_F0F0s_(func ff, Expression aa0, Expression aa1) : f(ff), a0(aa0), a1(aa1) {} // extend (2th arg.) + AnyType operator( )(Stack s) const { return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)))); } // extend (2th arg.) + virtual size_t nbitem( ) const { return a1->nbitem( ); } // modif ??? + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ); } // extend (2th arg.) }; -template > // extend (4th arg.) -class OneOperator2s_ : public OneOperator { // - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class CODE = E_F_F0F0s_< R, A, B, E_F0 > > // extend (4th arg.) +class OneOperator2s_ : public OneOperator { // + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]));} // extend - OneOperator2s_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()]), // extens - f(ff){} - OneOperator2s_(func ff,int preff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()]), // extens - f(ff){pref=preff;} - -}; - + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); + } // extend + OneOperator2s_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], + map_type[typeid(B).name( )]), // extens + f(ff) {} + OneOperator2s_(func ff, int preff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], + map_type[typeid(B).name( )]), // extens + f(ff) { + pref = preff; + } +}; // **** 2 paramters with the stack // class OneOperator2s_ -// class E_F_F0F0s_ +// class E_F_F0F0s_ -template // extend (4th arg.) -class E_F_F0F0F0s_ :public E { public: // extend - typedef R (*func)(Stack s,const A0 &,const A1 &,const A2 & ) ; // extend (statck +2th arg.) +template< class R, class A0, class A1, class A2, class E = E_F0 > // extend (4th arg.) +class E_F_F0F0F0s_ : public E { + public: // extend + typedef R (*func)(Stack s, const A0 &, const A1 &, const A2 &); // extend (statck +2th arg.) func f; - Expression a0,a1,a2; // extend - E_F_F0F0F0s_(func ff, - Expression aa0, - Expression aa1, - Expression aa2) - : f(ff), a0(aa0), a1(aa1), a2(aa2) {} // extend (2th arg.) - AnyType operator()(Stack s) const - {return SetAny( f( s, - GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)) ) );} // extend (3th arg.) - virtual size_t nbitem() const {return a2->nbitem(); } // modif ??? - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent() && a2->MeshIndependent() ;} // extend (2th arg.) - + Expression a0, a1, a2; // extend + E_F_F0F0F0s_(func ff, Expression aa0, Expression aa1, Expression aa2) : f(ff), a0(aa0), a1(aa1), a2(aa2) {} // extend (2th arg.) + AnyType operator( )(Stack s) const { return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)))); } // extend (3th arg.) + virtual size_t nbitem( ) const { return a2->nbitem( ); } // modif ??? + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ); } // extend (2th arg.) }; -template > // extend (3th arg.) -class OneOperator3s_ : public OneOperator { // - aType r; // return type - aType tA,tB,tC; // type of template modif FH mars 2007 - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class CODE = E_F_F0F0F0s_< R, A, B, C, E_F0 > > // extend (3th arg.) +class OneOperator3s_ : public OneOperator { // + aType r; // return type + aType tA, tB, tC; // type of template modif FH mars 2007 + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]));} // extend -/* OneOperator3s_(func ff): // 2-> - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()]), // extend - f(ff){}*/ - OneOperator3s_(func ff, - aType tt0=map_type[typeid(A).name()], - aType tt1=map_type[typeid(B).name()], - aType tt2=map_type[typeid(C).name()]) - : OneOperator(map_type[typeid(R).name()],tt0,tt1,tt2), - tA(map_type[typeid(A).name()]), - tB(map_type[typeid(B).name()]), - tC(map_type[typeid(C).name()]), - f(ff){} + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); + } // extend + /* OneOperator3s_(func ff): // 2-> + OneOperator(map_type[typeid(R).name()], + map_type[typeid(A).name()], + map_type[typeid(B).name()], + map_type[typeid(C).name()]), // extend + f(ff){}*/ + OneOperator3s_(func ff, aType tt0 = map_type[typeid(A).name( )], aType tt1 = map_type[typeid(B).name( )], aType tt2 = map_type[typeid(C).name( )]) + : OneOperator(map_type[typeid(R).name( )], tt0, tt1, tt2), tA(map_type[typeid(A).name( )]), tB(map_type[typeid(B).name( )]), tC(map_type[typeid(C).name( )]), f(ff) {} }; // *********************************************** // *********************************************** // **** 4 parameters // *********************** -template // extend (4th arg.) -class E_F_F0F0F0F0_ :public E { public: // extend - typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 & ) ; // extend (4th arg.) +template< class R, class A0, class A1, class A2, class A3, class E = E_F0 > // extend (4th arg.) +class E_F_F0F0F0F0_ : public E { + public: // extend + typedef R (*func)(const A0 &, const A1 &, const A2 &, const A3 &); // extend (4th arg.) func f; - Expression a0,a1,a2,a3; // extend - E_F_F0F0F0F0_(func ff, - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3) {} // extend (4th arg.) - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)) ) );} // extend (4th arg.) - virtual size_t nbitem() const {return a3->nbitem(); } // modif - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent()&& a3->MeshIndependent();} // extend (4th arg.) - + Expression a0, a1, a2, a3; // extend + E_F_F0F0F0F0_(func ff, Expression aa0, Expression aa1, Expression aa2, + Expression aa3) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3) {} // extend (4th arg.) + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)))); } // extend (4th arg.) + virtual size_t nbitem( ) const { return a3->nbitem( ); } // modif + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ); } // extend (4th arg.) }; -template > // extend (4th arg.) -class OneOperator4_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class CODE = E_F_F0F0F0F0_< R, A, B, C, D, E_F0 > > // extend (4th arg.) +class OneOperator4_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]));} // extend - OneOperator4_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()]), // extens - f(ff){} -}; - + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + } // extend + OneOperator4_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], + map_type[typeid(D).name( )]), // extens + f(ff) {} +}; -template // extend (4th arg.) -class E_F_F0F0F0F0s_ :public E { public: // extend - typedef R (*func)(Stack, const A0 &,const A1 & , const A2 &, const A3 & ) ; // extend (4th arg.) +template< class R, class A0, class A1, class A2, class A3, class E = E_F0 > // extend (4th arg.) +class E_F_F0F0F0F0s_ : public E { + public: // extend + typedef R (*func)(Stack, const A0 &, const A1 &, const A2 &, const A3 &); // extend (4th arg.) func f; - Expression a0,a1,a2,a3; // extend - E_F_F0F0F0F0s_(func ff, - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3) {} // extend (4th arg.) - AnyType operator()(Stack s) const - {return SetAny( f( s, GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)) ) );} // extend (4th arg.) - virtual size_t nbitem() const {return a3->nbitem(); } // modif - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent()&& a3->MeshIndependent();} // extend (4th arg.) - + Expression a0, a1, a2, a3; // extend + E_F_F0F0F0F0s_(func ff, Expression aa0, Expression aa1, Expression aa2, + Expression aa3) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3) {} // extend (4th arg.) + AnyType operator( )(Stack s) const { return SetAny< R >(f(s, GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)))); } // extend (4th arg.) + virtual size_t nbitem( ) const { return a3->nbitem( ); } // modif + bool MeshIndependent( ) const { return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ); } // extend (4th arg.) }; -template > // extend (4th arg.) -class OneOperator4s_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class CODE = E_F_F0F0F0F0s_< R, A, B, C, D, E_F0 > > // extend (4th arg.) +class OneOperator4s_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]));} // extend - OneOperator4s_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()]), // extens - f(ff){} -}; + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + } // extend + OneOperator4s_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], + map_type[typeid(D).name( )]), // extens + f(ff) {} +}; // *********************************************** // **** 5 parameters @@ -226,59 +167,43 @@ class OneOperator4s_ : public OneOperator { // 3->4 // // NOTE: add the following line in AFunction.hpp // -// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) -// : r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} +// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) +// : r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} -template // extend AX -class E_F_F0F0F0F0F0_ :public E { public: // extend - typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 & ) ; // extend AX +template< class R, class A0, class A1, class A2, class A3, class A4, class E = E_F0 > // extend AX +class E_F_F0F0F0F0F0_ : public E { + public: // extend + typedef R (*func)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &); // extend AX func f; - Expression a0,a1,a2,a3,a4; // extend aX - E_F_F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4) {} // extend aX - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)) ) );} // extend aX - virtual size_t nbitem() const {return a4->nbitem(); } - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent();} // extend aX - + Expression a0, a1, a2, a3, a4; // extend aX + E_F_F0F0F0F0F0_(func ff, // extend F0 + Expression aa0, Expression aa1, Expression aa2, Expression aa3, + Expression aa4) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4) {} // extend aX + AnyType operator( )(Stack s) const { return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)))); } // extend aX + virtual size_t nbitem( ) const { return a4->nbitem( ); } + bool MeshIndependent( ) const { + return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ) && a4->MeshIndependent( ); + } // extend aX }; -template > // extend -class OneOperator5_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, class CODE = E_F_F0F0F0F0F0_< R, A, B, C, D, E, E_F0 > > // extend +class OneOperator5_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]));} // extend - OneOperator5_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()]), // extend - f(ff){} + + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4])); + } // extend + OneOperator5_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )], + map_type[typeid(E).name( )]), // extend + f(ff) {} }; // *********************************************** @@ -286,205 +211,142 @@ class OneOperator5_ : public OneOperator { // 3->4 // *********************** // // NOTE: add the following line in AFunction.hpp -// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) -// : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} +// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) +// : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} -template // extend AX -class E_F_F0F0F0F0F0F0_ :public E { public: // extend - typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 & ) ; // extend AX +template< class R, class A0, class A1, class A2, class A3, class A4, class A5, class E = E_F0 > // extend AX +class E_F_F0F0F0F0F0F0_ : public E { + public: // extend + typedef R (*func)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &); // extend AX func f; - Expression a0,a1,a2,a3,a4,a5; // extend aX + Expression a0, a1, a2, a3, a4, a5; // extend aX E_F_F0F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4, - Expression aa5) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5) {} // extend aX - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)), - GetAny((*a5)(s)) ) );} // extend aX - virtual size_t nbitem() const {return a5->nbitem(); } - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent();} // extend aX - + Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4, + Expression aa5) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5) {} // extend aX + AnyType operator( )(Stack s) const { + return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)), GetAny< A5 >((*a5)(s)))); + } // extend aX + virtual size_t nbitem( ) const { return a5->nbitem( ); } + bool MeshIndependent( ) const { + return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ) && a4->MeshIndependent( ) && a5->MeshIndependent( ); + } // extend aX }; -template > // extend -class OneOperator6_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, class F = E, class CODE = E_F_F0F0F0F0F0F0_< R, A, B, C, D, E, F, E_F0 > > // extend +class OneOperator6_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]), - t[5]->CastTo(args[5]));} // extend - OneOperator6_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()], - map_type[typeid(F).name()]), // extend - f(ff){} -}; + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5])); + } // extend + OneOperator6_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )], map_type[typeid(E).name( )], + map_type[typeid(F).name( )]), // extend + f(ff) {} +}; // *********************************************** // **** 7 parameters // *********************** // // NOTE: add the following line in AFunction.hpp -// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) -// : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} +// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) +// : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} -template // extend AX -class E_F_F0F0F0F0F0F0F0_ :public E { public: // extend - typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 &, const A6 & ) ; // extend AX +template< class R, class A0, class A1, class A2, class A3, class A4, class A5, class A6, class E = E_F0 > // extend AX +class E_F_F0F0F0F0F0F0F0_ : public E { + public: // extend + typedef R (*func)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &); // extend AX func f; - Expression a0,a1,a2,a3,a4,a5,a6; // extend aX - E_F_F0F0F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4, - Expression aa5, - Expression aa6) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6) {} // extend aX - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)), - GetAny((*a5)(s)), - GetAny((*a6)(s)) ) );} // extend aX - virtual size_t nbitem() const {return a6->nbitem(); } // modif - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent();} // extend aX - + Expression a0, a1, a2, a3, a4, a5, a6; // extend aX + E_F_F0F0F0F0F0F0F0_(func ff, // extend F0 + Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4, Expression aa5, + Expression aa6) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6) {} // extend aX + AnyType operator( )(Stack s) const { + return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)), GetAny< A5 >((*a5)(s)), GetAny< A6 >((*a6)(s)))); + } // extend aX + virtual size_t nbitem( ) const { return a6->nbitem( ); } // modif + bool MeshIndependent( ) const { + return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ) && a4->MeshIndependent( ) && a5->MeshIndependent( ) && + a6->MeshIndependent( ); + } // extend aX }; -template > // extend -class OneOperator7_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, class F = E, class G = F, class CODE = E_F_F0F0F0F0F0F0F0_< R, A, B, C, D, E, F, G, E_F0 > > // extend +class OneOperator7_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]), - t[5]->CastTo(args[5]), - t[6]->CastTo(args[6]));} // extend - OneOperator7_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()], - map_type[typeid(F).name()], - map_type[typeid(G).name()]), // extend - f(ff){} -}; - + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5]), t[6]->CastTo(args[6])); + } // extend + OneOperator7_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )], map_type[typeid(E).name( )], + map_type[typeid(F).name( )], + map_type[typeid(G).name( )]), // extend + f(ff) {} +}; // *********************************************** // **** 8 parameters // *********************** // -template // extend AX -class E_F_F0F0F0F0F0F0F0F0_ :public E { public: // extend - typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 & ) ; // extend AX +template< class R, class A0, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class E = E_F0 > // extend AX +class E_F_F0F0F0F0F0F0F0F0_ : public E { + public: // extend + typedef R (*func)(const A0 &, const A1 &, const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &); // extend AX func f; - Expression a0,a1,a2,a3,a4,a5,a6,a7; // extend aX - E_F_F0F0F0F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4, - Expression aa5, - Expression aa6, - Expression aa7) // extend - : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6), a7(aa7) {} // extend aX - AnyType operator()(Stack s) const - {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)), - GetAny((*a5)(s)), - GetAny((*a6)(s)), - GetAny((*a7)(s)) ) );} // extend aX - virtual size_t nbitem() const {return a7->nbitem(); } // modif - bool MeshIndependent() const - {return E::MeshIndependent() && a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent()&& a7->MeshIndependent();} // extend aX - + Expression a0, a1, a2, a3, a4, a5, a6, a7; // extend aX + E_F_F0F0F0F0F0F0F0F0_(func ff, // extend F0 + Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4, Expression aa5, Expression aa6, + Expression aa7) // extend + : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6), a7(aa7) {} // extend aX + AnyType operator( )(Stack s) const { + return SetAny< R >(f(GetAny< A0 >((*a0)(s)), GetAny< A1 >((*a1)(s)), GetAny< A2 >((*a2)(s)), GetAny< A3 >((*a3)(s)), GetAny< A4 >((*a4)(s)), GetAny< A5 >((*a5)(s)), GetAny< A6 >((*a6)(s)), + GetAny< A7 >((*a7)(s)))); + } // extend aX + virtual size_t nbitem( ) const { return a7->nbitem( ); } // modif + bool MeshIndependent( ) const { + return E::MeshIndependent( ) && a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ) && a3->MeshIndependent( ) && a4->MeshIndependent( ) && a5->MeshIndependent( ) && + a6->MeshIndependent( ) && a7->MeshIndependent( ); + } // extend aX }; -template > // extend -class OneOperator8_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; +template< class R, class A = R, class B = A, class C = B, class D = C, class E = D, class F = E, class G = F, class H = G, + class CODE = E_F_F0F0F0F0F0F0F0F0_< R, A, B, C, D, E, F, G, H, E_F0 > > // extend +class OneOperator8_ : public OneOperator { // 3->4 + aType r; // return type + typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { - if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]), - t[5]->CastTo(args[5]), - t[6]->CastTo(args[6]), - t[7]->CastTo(args[7]));} // extend - OneOperator8_(func ff): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()], - map_type[typeid(F).name()], - map_type[typeid(G).name()], - map_type[typeid(H).name()]), // extend - f(ff){} -}; + public: + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5]), t[6]->CastTo(args[6]), + t[7]->CastTo(args[7])); + } // extend + OneOperator8_(func ff) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )], map_type[typeid(D).name( )], map_type[typeid(E).name( )], + map_type[typeid(F).name( )], map_type[typeid(G).name( )], + map_type[typeid(H).name( )]), // extend + f(ff) {} +}; // *********************************************** // **** 9 parameters @@ -493,66 +355,66 @@ class OneOperator8_ : public OneOperator { // 3->4 /* template // extend AX -class E_F_F0F0F0F0F0F0F0F0F0_ :public E { public: // extend +class E_F_F0F0F0F0F0F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 & ) ; // extend AX func f; Expression a0,a1,a2,a3,a4,a5,a6,a7,a8; // extend aX E_F_F0F0F0F0F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4, - Expression aa5, - Expression aa6, - Expression aa7, - Expression aa8) // extend + Expression aa0, + Expression aa1, + Expression aa2, + Expression aa3, + Expression aa4, + Expression aa5, + Expression aa6, + Expression aa7, + Expression aa8) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6), a7(aa7), a8(aa8) {} // extend aX - AnyType operator()(Stack s) const + AnyType operator()(Stack s) const {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)), - GetAny((*a5)(s)), - GetAny((*a6)(s)), - GetAny((*a7)(s)), - GetAny((*a8)(s)) ) );} // extend aX + GetAny((*a1)(s)), + GetAny((*a2)(s)), + GetAny((*a3)(s)), + GetAny((*a4)(s)), + GetAny((*a5)(s)), + GetAny((*a6)(s)), + GetAny((*a7)(s)), + GetAny((*a8)(s)) ) );} // extend aX virtual size_t nbitem() const {return a8->nbitem(); } // modif - bool MeshIndependent() const + bool MeshIndependent() const {return E::MeshIndependent() &&a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent()&& a7->MeshIndependent()&& a8->MeshIndependent();} // extend aX + && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent()&& a7->MeshIndependent()&& a8->MeshIndependent();} // extend aX }; -template > // extend +template > // extend class OneOperator9_ : public OneOperator { // 3->4 - aType r; // return type + aType r; // return type typedef typename CODE::func func; func f; -public: - E_F0 * code(const basicAC_F0 & args) const +public: + E_F0 * code(const basicAC_F0 & args) const { return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]), - t[5]->CastTo(args[5]), - t[6]->CastTo(args[6]), - t[7]->CastTo(args[7]), - t[8]->CastTo(args[8]));} // extend + t[0]->CastTo(args[0]), + t[1]->CastTo(args[1]), + t[2]->CastTo(args[2]), + t[3]->CastTo(args[3]), + t[4]->CastTo(args[4]), + t[5]->CastTo(args[5]), + t[6]->CastTo(args[6]), + t[7]->CastTo(args[7]), + t[8]->CastTo(args[8]));} // extend OneOperator9_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()], - map_type[typeid(F).name()], - map_type[typeid(G).name()], - map_type[typeid(H).name()], - map_type[typeid(I).name()]), // extend + map_type[typeid(A).name()], + map_type[typeid(B).name()], + map_type[typeid(C).name()], + map_type[typeid(D).name()], + map_type[typeid(E).name()], + map_type[typeid(F).name()], + map_type[typeid(G).name()], + map_type[typeid(H).name()], + map_type[typeid(I).name()]), // extend f(ff){} }; */ @@ -566,71 +428,58 @@ class OneOperator9_ : public OneOperator { // 3->4 // template // extend AX -class E_F_F0F0F0F0F0F0F0F0F0F0_ :public E { public: // extend +class E_F_F0F0F0F0F0F0F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 &, const A6 &, const A7 &, const A8 &, const A9 & ) ; // extend AX func f; Expression a0,a1,a2,a3,a4,a5,a6,a7,a8,a9; // extend aX E_F_F0F0F0F0F0F0F0F0F0F0_(func ff, // extend F0 - Expression aa0, - Expression aa1, - Expression aa2, - Expression aa3, - Expression aa4, - Expression aa5, - Expression aa6, - Expression aa7, - Expression aa8, - Expression aa9) // extend + Expression aa0, + Expression aa1, + Expression aa2, + Expression aa3, + Expression aa4, + Expression aa5, + Expression aa6, + Expression aa7, + Expression aa8, + Expression aa9) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6), a7(aa7), a8(aa8), a9(aa9) {} // extend aX - AnyType operator()(Stack s) const + AnyType operator()(Stack s) const {return SetAny( f( GetAny((*a0)(s)), - GetAny((*a1)(s)), - GetAny((*a2)(s)), - GetAny((*a3)(s)), - GetAny((*a4)(s)), - GetAny((*a5)(s)), - GetAny((*a6)(s)), - GetAny((*a7)(s)), - GetAny((*a8)(s)), - GetAny((*a9)(s)) ) );} // extend aX - virtual size_t nbitem() const {return a9->nbitem(); } // modif - bool MeshIndependent() const + GetAny((*a1)(s)), + GetAny((*a2)(s)), + GetAny((*a3)(s)), + GetAny((*a4)(s)), + GetAny((*a5)(s)), + GetAny((*a6)(s)), + GetAny((*a7)(s)), + GetAny((*a8)(s)), + GetAny((*a9)(s)) ) );} // extend aX + virtual size_t nbitem() const {return a9->nbitem(); } // modif + bool MeshIndependent() const {return E::MeshIndependent() &&a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() - && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent() - && a7->MeshIndependent()&& a8->MeshIndependent()&& a9->MeshIndependent();} // extend aX + && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent() + && a7->MeshIndependent()&& a8->MeshIndependent()&& a9->MeshIndependent();} // extend aX }; -template > // extend -class OneOperator10_ : public OneOperator { // 3->4 - aType r; // return type - typedef typename CODE::func func; - func f; -public: - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(f, - t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[3]->CastTo(args[3]), - t[4]->CastTo(args[4]), - t[5]->CastTo(args[5]), - t[6]->CastTo(args[6]), - t[7]->CastTo(args[7]), - t[8]->CastTo(args[8]), - t[9]->CastTo(args[9]));} // extend +template > // +extend class OneOperator10_ : public OneOperator { // 3->4 aType r; // return type typedef typename CODE::func func; func f; public: E_F0 * code(const basicAC_F0 & args) const { return new +CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5]), t[6]->CastTo(args[6]), t[7]->CastTo(args[7]), + t[8]->CastTo(args[8]), + t[9]->CastTo(args[9]));} // extend OneOperator10_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()], - map_type[typeid(C).name()], - map_type[typeid(D).name()], - map_type[typeid(E).name()], - map_type[typeid(F).name()], - map_type[typeid(G).name()], - map_type[typeid(H).name()], - map_type[typeid(I).name()], - map_type[typeid(J).name()]), // extend + map_type[typeid(A).name()], + map_type[typeid(B).name()], + map_type[typeid(C).name()], + map_type[typeid(D).name()], + map_type[typeid(E).name()], + map_type[typeid(F).name()], + map_type[typeid(G).name()], + map_type[typeid(H).name()], + map_type[typeid(I).name()], + map_type[typeid(J).name()]), // extend f(ff){} }; diff --git a/src/fflib/AddNewFE.h b/src/fflib/AddNewFE.h index 8a882f858..d23ba92c4 100644 --- a/src/fflib/AddNewFE.h +++ b/src/fflib/AddNewFE.h @@ -1,122 +1,137 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // to add Finite Element to ff++ -class EConstantTypeOfFE :public E_F0 -{ -// using namespace Fem2D; - Fem2D::TypeOfFE * v; +class EConstantTypeOfFE : public E_F0 { + // using namespace Fem2D; + Fem2D::TypeOfFE *v; size_t N; bool isconst; -public: - AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny(v);} - EConstantTypeOfFE( Fem2D::TypeOfFE * o,bool ic=true):v(o),N(v->N),isconst(ic) {assert(v); /*cout << "New constant " << o << endl;*/} - size_t nbitem() const { return N ;} - EConstantTypeOfFE & operator=(Fem2D::TypeOfFE * vv) { - ffassert( !isconst && vv && (vv->N == N)); // same type - v = vv; - return *this; + + public: + AnyType operator( )(Stack) const { /*cout << " ()" << v << endl*/ + ; + return SetAny< Fem2D::TypeOfFE * >(v); + } + EConstantTypeOfFE(Fem2D::TypeOfFE *o, bool ic = true) : v(o), N(v->N), isconst(ic) { assert(v); /*cout << "New constant " << o << endl;*/ } + size_t nbitem( ) const { return N; } + EConstantTypeOfFE &operator=(Fem2D::TypeOfFE *vv) { + ffassert(!isconst && vv && (vv->N == N)); // same type + v = vv; + return *this; + } + operator aType( ) const { + assert(v); + return atype< Fem2D::TypeOfFE * >( ); } - operator aType () const { assert(v);return atype();} }; - -struct AddNewFE { - AddNewFE (const char * FEname,Fem2D::TypeOfFE* tfe) - { - ffassert(tfe); // check - Global.New(FEname, Type_Expr(atype() ,new EConstantTypeOfFE(tfe))); +struct AddNewFE { + AddNewFE(const char *FEname, Fem2D::TypeOfFE *tfe) { + ffassert(tfe); // check + Global.New(FEname, Type_Expr(atype< Fem2D::TypeOfFE * >( ), new EConstantTypeOfFE(tfe))); } }; // 3d volume case -class EConstantTypeOfFE3 :public E_F0 -{ public: - // using namespace Fem2D; - typedef Fem2D::TypeOfFE3 * T; - T v; -public: - AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny(v);} - EConstantTypeOfFE3( T o):v(o) { /*cout << "New constant " << o << endl;*/} - size_t nbitem() const { assert(v); - if(verbosity > 2) - cout << " nb item = " << v->N << endl; - return v->N ;} - operator aType () const { return atype();} -}; +class EConstantTypeOfFE3 : public E_F0 { + public: + // using namespace Fem2D; + typedef Fem2D::TypeOfFE3 *T; + T v; -Type_Expr CConstantTFE3(const EConstantTypeOfFE3::T & v); + public: + AnyType operator( )(Stack) const { /*cout << " ()" << v << endl*/ + ; + return SetAny< T >(v); + } + EConstantTypeOfFE3(T o) : v(o) { /*cout << "New constant " << o << endl;*/ } + size_t nbitem( ) const { + assert(v); + if (verbosity > 2) cout << " nb item = " << v->N << endl; + return v->N; + } + operator aType( ) const { return atype< T >( ); } +}; +Type_Expr CConstantTFE3(const EConstantTypeOfFE3::T &v); // 3d surface case -class EConstantTypeOfFES :public E_F0 -{ public: - // using namespace Fem2D; - typedef Fem2D::TypeOfFES * T; - T v; -public: - AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny(v);} - EConstantTypeOfFES( T o):v(o) { /*cout << "New constant " << o << endl;*/} - size_t nbitem() const { assert(v); - if(verbosity > 2) - cout << " nb item = " << v->N << endl; - return v->N ;} - operator aType () const { return atype();} -}; - +class EConstantTypeOfFES : public E_F0 { + public: + // using namespace Fem2D; + typedef Fem2D::TypeOfFES *T; + T v; -Type_Expr CConstantTFES(const EConstantTypeOfFES::T & v); + public: + AnyType operator( )(Stack) const { /*cout << " ()" << v << endl*/ + ; + return SetAny< T >(v); + } + EConstantTypeOfFES(T o) : v(o) { /*cout << "New constant " << o << endl;*/ } + size_t nbitem( ) const { + assert(v); + if (verbosity > 2) cout << " nb item = " << v->N << endl; + return v->N; + } + operator aType( ) const { return atype< T >( ); } +}; +Type_Expr CConstantTFES(const EConstantTypeOfFES::T &v); // 3d curve case -class EConstantTypeOfFEL :public E_F0 -{ public: - // using namespace Fem2D; - typedef Fem2D::TypeOfFEL * T; - T v; -public: - AnyType operator()(Stack ) const { /*cout << " ()" << v << endl*/;return SetAny(v);} - EConstantTypeOfFEL( T o):v(o) { /*cout << "New constant " << o << endl;*/} - size_t nbitem() const { assert(v); - if(verbosity > 2) - cout << " nb item = " << v->N << endl; - return v->N ;} - operator aType () const { return atype();} -}; +class EConstantTypeOfFEL : public E_F0 { + public: + // using namespace Fem2D; + typedef Fem2D::TypeOfFEL *T; + T v; + public: + AnyType operator( )(Stack) const { /*cout << " ()" << v << endl*/ + ; + return SetAny< T >(v); + } + EConstantTypeOfFEL(T o) : v(o) { /*cout << "New constant " << o << endl;*/ } + size_t nbitem( ) const { + assert(v); + if (verbosity > 2) cout << " nb item = " << v->N << endl; + return v->N; + } + operator aType( ) const { return atype< T >( ); } +}; -Type_Expr CConstantTFEL(const EConstantTypeOfFEL::T & v); +Type_Expr CConstantTFEL(const EConstantTypeOfFEL::T &v); /* class EConstantTypeOfFE3 :public E_F0 -{ +{ // using namespace Fem2D; Fem2D::TypeOfFE3 * v; size_t N; @@ -124,43 +139,37 @@ class EConstantTypeOfFE3 :public E_F0 public: AnyType operator()(Stack ) const { return SetAny(v);} EConstantTypeOfFE3( Fem2D::TypeOfFE3 * o,bool ic=true):v(o),N(v->N),isconst(ic) {assert(v); //cout << "New constant " << o << endl;} - size_t nbitem() const { return N ;} + size_t nbitem() const { return N ;} EConstantTypeOfFE3 & operator=(Fem2D::TypeOfFE3 * vv) { - ffassert( !isconst && vv && (vv->N == N)); // same type - v = vv; + ffassert( !isconst && vv && (vv->N == N)); // same type + v = vv; } - operator aType () const { assert(v);return atype();} + operator aType () const { assert(v);return atype();} }; */ -extern map TEF2dto3d; -TypeOfFE * FindFE2(const char * s); - -struct AddNewFE3 { - AddNewFE3 (const char * FEname,Fem2D::TypeOfFE3* tfe,const char * FEname2=0) - { - ffassert(tfe); // check - Global.New(FEname, Type_Expr(atype() ,new EConstantTypeOfFE3(tfe))); - if(FEname2 && strlen(FEname2)) - TEF2dto3d[FindFE2(FEname2)]=tfe; - } +extern map< TypeOfFE *, TypeOfFE3 * > TEF2dto3d; +TypeOfFE *FindFE2(const char *s); + +struct AddNewFE3 { + AddNewFE3(const char *FEname, Fem2D::TypeOfFE3 *tfe, const char *FEname2 = 0) { + ffassert(tfe); // check + Global.New(FEname, Type_Expr(atype< Fem2D::TypeOfFE3 * >( ), new EConstantTypeOfFE3(tfe))); + if (FEname2 && strlen(FEname2)) TEF2dto3d[FindFE2(FEname2)] = tfe; + } }; -extern map TEF2dtoS; +extern map< TypeOfFE *, TypeOfFES * > TEF2dtoS; struct AddNewFES { - AddNewFES (const char * FEname,Fem2D::TypeOfFES* tfe,const char * FEname2=0) - { - ffassert(tfe); // check - Global.New(FEname, Type_Expr(atype() ,new EConstantTypeOfFES(tfe))); - if(FEname2 && strlen(FEname2)) - TEF2dtoS[FindFE2(FEname2)]=tfe; - } + AddNewFES(const char *FEname, Fem2D::TypeOfFES *tfe, const char *FEname2 = 0) { + ffassert(tfe); // check + Global.New(FEname, Type_Expr(atype< Fem2D::TypeOfFES * >( ), new EConstantTypeOfFES(tfe))); + if (FEname2 && strlen(FEname2)) TEF2dtoS[FindFE2(FEname2)] = tfe; + } }; -extern map TEF2dtoL; +extern map< TypeOfFE *, TypeOfFEL * > TEF2dtoL; struct AddNewFEL { - AddNewFEL (const char * FEname,Fem2D::TypeOfFEL* tfe,const char * FEname2=0) - { - ffassert(tfe); // check - Global.New(FEname, Type_Expr(atype() ,new EConstantTypeOfFEL(tfe))); - if(FEname2 && strlen(FEname2)) - TEF2dtoL[FindFE2(FEname2)]=tfe; - } + AddNewFEL(const char *FEname, Fem2D::TypeOfFEL *tfe, const char *FEname2 = 0) { + ffassert(tfe); // check + Global.New(FEname, Type_Expr(atype< Fem2D::TypeOfFEL * >( ), new EConstantTypeOfFEL(tfe))); + if (FEname2 && strlen(FEname2)) TEF2dtoL[FindFE2(FEname2)] = tfe; + } }; diff --git a/src/fflib/AnyType.hpp b/src/fflib/AnyType.hpp index d374e1991..279d909fe 100644 --- a/src/fflib/AnyType.hpp +++ b/src/fflib/AnyType.hpp @@ -1,34 +1,34 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // definition of the a type to store any bacis type -// void *, long, double, complex, all bigger type -// are pointer -//#define WITHCHECK +// void *, long, double, complex, all bigger type +// are pointer +// #define WITHCHECK /// cf [[file:AFunction.hpp::basicForEachType]] @@ -36,174 +36,190 @@ class basicForEachType; /// <> uses [[file:AFunction.hpp::basicForEachType]] -typedef const basicForEachType * aType; - -ostream & operator<<(ostream & f,const basicForEachType & e); +typedef const basicForEachType* aType; -//typedef unsigned char AnyData[24]; +ostream& operator<<(ostream& f, const basicForEachType& e); -//typedef unsigned char AnyData[2*(sizeof(void*)+2*sizeof(double))]; -// change for 64 architecture must containt 2*(1 ptr + 3 long)) -// and for 32 2( ptr + 2 double) -// so 2( 3ptr + double ) sims Ok FH MAI 2006 -//typedef unsigned char AnyData[2*(3*sizeof(void*)+sizeof(double))]; -typedef unsigned char AnyData[2*(5*sizeof(void*))]; // change . +// typedef unsigned char AnyData[24]; +// typedef unsigned char AnyData[2*(sizeof(void*)+2*sizeof(double))]; +// change for 64 architecture must containt 2*(1 ptr + 3 long)) +// and for 32 2( ptr + 2 double) +// so 2( 3ptr + double ) sims Ok FH MAI 2006 +// typedef unsigned char AnyData[2*(3*sizeof(void*)+sizeof(double))]; +typedef unsigned char AnyData[2 * (5 * sizeof(void*))]; // change . -extern map map_type; +extern map< const string, basicForEachType* > map_type; -template - class CheckSize { } ; -template -class CheckSize { - CheckSize() { } // private constructor to see the error -} ; -class AnyTypeWithCheck { +template< class T, bool ok > +class CheckSize {}; +template< class T > +class CheckSize< T, false > { + CheckSize( ) {} // private constructor to see the error +}; +class AnyTypeWithCheck { + + private: + union { + AnyData data; + void* p; + double r; + long l; + bool b; + // complex c; + }; - private: - union { - AnyData data; - void * p; - double r; - long l; - bool b; -// complex c; - }; public: - const basicForEachType *ktype; -// friend ostream & operator<<(ostream &f,const AnyTypeWithCheck &p); - AnyTypeWithCheck(): ktype(0){} - AnyTypeWithCheck(long ll) {l=ll;ktype=map_type[typeid(long).name()];} - AnyTypeWithCheck(double dd) {r=dd;ktype=map_type[typeid(double).name()];} - AnyTypeWithCheck(bool bb ) {b=bb;ktype=map_type[typeid(bool).name()];} - - void operator =(void *pp){p=pp;} + const basicForEachType* ktype; + // friend ostream & operator<<(ostream &f,const AnyTypeWithCheck &p); + AnyTypeWithCheck( ) : ktype(0) {} + AnyTypeWithCheck(long ll) { + l = ll; + ktype = map_type[typeid(long).name( )]; + } + AnyTypeWithCheck(double dd) { + r = dd; + ktype = map_type[typeid(double).name( )]; + } + AnyTypeWithCheck(bool bb) { + b = bb; + ktype = map_type[typeid(bool).name( )]; + } + + void operator=(void* pp) { p = pp; } }; -class AnyTypeWithOutCheck { - - public: - union { - AnyData data; - void * p; - double r; - long l; - bool b; -// complex c; - }; +class AnyTypeWithOutCheck { + + public: + union { + AnyData data; + void* p; + double r; + long l; + bool b; + // complex c; + }; + public: - AnyTypeWithOutCheck(){} - AnyTypeWithOutCheck(long ll) {l=ll;} - AnyTypeWithOutCheck(double dd) {r=dd;} - AnyTypeWithOutCheck(void *pp ) {p=pp;} - AnyTypeWithOutCheck(bool bb ) {b=bb;} - - void operator =(void *pp){p=pp;} + AnyTypeWithOutCheck( ) {} + AnyTypeWithOutCheck(long ll) { l = ll; } + AnyTypeWithOutCheck(double dd) { r = dd; } + AnyTypeWithOutCheck(void* pp) { p = pp; } + AnyTypeWithOutCheck(bool bb) { b = bb; } + + void operator=(void* pp) { p = pp; } }; #ifdef WITHCHECK -typedef AnyTypeWithCheck AnyType; +typedef AnyTypeWithCheck AnyType; #else -typedef AnyTypeWithOutCheck AnyType; +typedef AnyTypeWithOutCheck AnyType; #endif static AnyType Nothing; - -#ifdef WITHCHECK - -template AnyTypeWithCheck SetAny(const T & x) - { - AnyTypeWithCheck any; - CheckSize(); - throwassert( (any.ktype=map_type[typeid(T).name()])); - throwassert (sizeof(T) <= sizeof(AnyData)); - //a.t=x; - memcpy(&any,&x,sizeof(x)); - return any; - } -template AnyTypeWithOutCheck inline SetPtrAny( T * p) -{ - throwassert( (any.ktype=map_type[typeid(T*).name()])); - return p; -} -inline AnyTypeWithCheck PtrtoAny(void * p,aType r) - { - AnyTypeWithCheck any; - any=p; - throwassert(any.ktype=r); - return any; - } - - -#else +#ifdef WITHCHECK - template AnyTypeWithOutCheck inline SetAny(const T & x) - { - AnyTypeWithOutCheck any; - CheckSize(); - // plus stable ??? F avril 2006 FH. - memcpy(&any,&x,sizeof(x)); - // plante de temps en temps sous wind32 . FH - //any = *( (AnyTypeWithOutCheck *) (void *) &x); - return any; - } -template AnyTypeWithOutCheck inline SetPtrAny( T * p) -{ - return p; +template< typename T > +AnyTypeWithCheck SetAny(const T& x) { + AnyTypeWithCheck any; + CheckSize< T, sizeof(T) <= sizeof(AnyData) >( ); + throwassert((any.ktype = map_type[typeid(T).name( )])); + throwassert(sizeof(T) <= sizeof(AnyData)); + // a.t=x; + memcpy(&any, &x, sizeof(x)); + return any; } -inline AnyTypeWithOutCheck PtrtoAny(void * p,aType ) - { - return p; - } - template<> inline AnyTypeWithOutCheck SetAny(const double & x) - { return x;} - template<> inline AnyTypeWithOutCheck SetAny(const long & x) - { return x;} - template<> inline AnyTypeWithOutCheck SetAny(const bool & x) - { return x;} - - template inline AnyTypeWithOutCheck SetAny( T * x) - { return reinterpret_cast( x);} - template inline AnyTypeWithOutCheck SetAny( const T * x) - { return reinterpret_cast( x);} - - - -#endif - template inline const T& GetAny(const AnyTypeWithCheck & x); - - template inline const T& GetAny(const AnyTypeWithCheck & x) -{ - CheckSize(); - if (x.ktype!=map_type[typeid(T).name()]) - { cerr<< "GetAny: PB type <"; - cerr < <=" << *(x.ktype) << endl; - throw(ErrorExec("exit",1));} - return *static_cast(static_cast(&x)); +template< typename T > +AnyTypeWithOutCheck inline SetPtrAny(T* p) { + throwassert((any.ktype = map_type[typeid(T*).name( )])); + return p; +} +inline AnyTypeWithCheck PtrtoAny(void* p, aType r) { + AnyTypeWithCheck any; + any = p; + throwassert(any.ktype = r); + return any; } +#else +template< typename T > +AnyTypeWithOutCheck inline SetAny(const T& x) { + AnyTypeWithOutCheck any; + CheckSize< T, sizeof(T) <= sizeof(AnyData) >( ); + // plus stable ??? F avril 2006 FH. + memcpy(&any, &x, sizeof(x)); + // plante de temps en temps sous wind32 . FH + // any = *( (AnyTypeWithOutCheck *) (void *) &x); + return any; +} +template< typename T > +AnyTypeWithOutCheck inline SetPtrAny(T* p) { + return p; +} +inline AnyTypeWithOutCheck PtrtoAny(void* p, aType) { return p; } +template<> +inline AnyTypeWithOutCheck SetAny< double >(const double& x) { + return x; +} +template<> +inline AnyTypeWithOutCheck SetAny< long >(const long& x) { + return x; +} +template<> +inline AnyTypeWithOutCheck SetAny< bool >(const bool& x) { + return x; +} +template< typename T > +inline AnyTypeWithOutCheck SetAny(T* x) { + return reinterpret_cast< void* >(x); +} +template< typename T > +inline AnyTypeWithOutCheck SetAny(const T* x) { + return reinterpret_cast< void* >(x); +} - - template inline const T& GetAny(const AnyTypeWithOutCheck & x) -{ - CheckSize(); - return *static_cast(static_cast(&x)); +#endif +template< class T > +inline const T& GetAny(const AnyTypeWithCheck& x); + +template< class T > +inline const T& GetAny(const AnyTypeWithCheck& x) { + CheckSize< T, sizeof(T) <= sizeof(AnyData) >( ); + if (x.ktype != map_type[typeid(T).name( )]) { + cerr << "GetAny: PB type <"; + cerr << typeid(T).name( ); + cerr << "> <=" << *(x.ktype) << endl; + throw(ErrorExec("exit", 1)); + } + return *static_cast< const T* >(static_cast< const void* >(&x)); } - template<> inline const double& GetAny(const AnyTypeWithOutCheck & x) - { return x.r;} - template<> inline const long& GetAny(const AnyTypeWithOutCheck & x) - { return x.l;} - template<> inline const bool& GetAny(const AnyTypeWithOutCheck & x) - { return x.b;} +template< typename T > +inline const T& GetAny(const AnyTypeWithOutCheck& x) { + CheckSize< T, sizeof(T) <= sizeof(AnyData) >( ); + return *static_cast< const T* >(static_cast< const void* >(&x)); +} - template inline T * PGetAny(const AnyTypeWithOutCheck & x) - { return static_cast< T*>(x.p);} - - //template inline T * const & GetAny(const AnyTypeWithOutCheck & x) - // { return x.p;} +template<> +inline const double& GetAny< double >(const AnyTypeWithOutCheck& x) { + return x.r; +} +template<> +inline const long& GetAny< long >(const AnyTypeWithOutCheck& x) { + return x.l; +} +template<> +inline const bool& GetAny< bool >(const AnyTypeWithOutCheck& x) { + return x.b; +} +template< class T > +inline T* PGetAny(const AnyTypeWithOutCheck& x) { + return static_cast< T* >(x.p); +} +// template inline T * const & GetAny(const AnyTypeWithOutCheck & x) +// { return x.p;} diff --git a/src/fflib/CodeAlloc.cpp b/src/fflib/CodeAlloc.cpp index ca341969c..6e1bccc17 100644 --- a/src/fflib/CodeAlloc.cpp +++ b/src/fflib/CodeAlloc.cpp @@ -39,60 +39,71 @@ bool CodeAlloc::cleanning=false; */ static long kerr = 0; static long nbsort = 0; -template +template< class T > static void HeapSort(T *c, long n) { long l, j, r, i; T crit; - c--; // on decale de 1 pour que le tableau commence a 1 + c--; // on decale de 1 pour que le tableau commence a 1 if (n <= 1) return; - l = n/2 + 1; + l = n / 2 + 1; r = n; - while (1) { // label 2 - if (l <= 1 ) { // label 20 + while (1) { // label 2 + if (l <= 1) { // label 20 crit = c[r]; c[r--] = c[1]; - if ( r == 1 ) { c[1] = crit; return; } - } else crit = c[--l]; + if (r == 1) { + c[1] = crit; + return; + } + } else + crit = c[--l]; j = l; - while (1) { // label 4 + while (1) { // label 4 i = j; - j = 2*j; - if (j > r) { c[i] = crit; break; } // L8 -> G2 - if ((j < r) && (c[j] < c[j+1])) j++; // L5 - if (crit < c[j]) c[i] = c[j]; // L6+1 G4 - else { c[i] = crit; break; } //L8 -> G2 + j = 2 * j; + if (j > r) { + c[i] = crit; + break; + } // L8 -> G2 + if ((j < r) && (c[j] < c[j + 1])) j++; // L5 + if (crit < c[j]) + c[i] = c[j]; // L6+1 G4 + else { + c[i] = crit; + break; + } // L8 -> G2 } } } - void CodeAlloc::resize() { - Sort_mem(); - if (nbt*1.5 + 10 >= nbpx ) { +void CodeAlloc::resize( ) { + Sort_mem( ); + if (nbt * 1.5 + 10 >= nbpx) { nbpx = chunk; - mem = (CodeAlloc**)realloc(mem, chunk*sizeof(void*)); - if (mem) nbpx = chunk; - else ErrorExec("Alloc problem", 0); + mem = (CodeAlloc **)realloc(mem, chunk * sizeof(void *)); + if (mem) + nbpx = chunk; + else + ErrorExec("Alloc problem", 0); chunk *= 3; chunk /= 2; assert(chunk > nbpx); } } -void CodeAlloc::Sort_mem() { +void CodeAlloc::Sort_mem( ) { size_t i, j; if (nbt == 0) return; nbsort++; HeapSort(mem, nbt); for (i = 0, j = 0; i < nbt; i++) - if (!isdel(i)) - mem[j++] = mem[i]; + if (!isdel(i)) mem[j++] = mem[i]; nbt = j; - if (nbt != nb) - assert(nbt == nb); + if (nbt != nb) assert(nbt == nb); } -void CodeAlloc::clear() { +void CodeAlloc::clear( ) { return; // cleanning=true; @@ -123,19 +134,23 @@ void CodeAlloc::ErrorDel(void *pp) { kerr++; } -void CodeAlloc::operator delete(void * pp) { +void CodeAlloc::operator delete(void *pp) { // return ; // FH - if (!sort && (nb*2 > nbt)) Sort_mem(); - int ib = 0, ie = nbt-1, im; + if (!sort && (nb * 2 > nbt)) Sort_mem( ); + int ib = 0, ie = nbt - 1, im; if (pp < mem[ib]) ErrorDel(pp); if (pp > mem[ie]) ErrorDel(pp); int p = -1; while (ib < ie) { - im = (ib + ie)/2; + im = (ib + ie) / 2; { - if (pp < mem[im]) ie = im - 1; // in [ib , im-1] - else if (mem[im] == pp) { p = im; break; } - else ib = im + 1;// in [im+1 , ie] + if (pp < mem[im]) + ie = im - 1; // in [ib , im-1] + else if (mem[im] == pp) { + p = im; + break; + } else + ib = im + 1; // in [im+1 , ie] } } if (p < 0 && mem[ib] == pp) p = ib; @@ -143,8 +158,9 @@ void CodeAlloc::operator delete(void * pp) { if (p < 0) ErrorDel(pp); else { - setdel(p); //le tableau est detruit - nbdl++; nb--; + setdel(p); // le tableau est detruit + nbdl++; + nb--; ::operator delete(pp); } } diff --git a/src/fflib/CodeAlloc.hpp b/src/fflib/CodeAlloc.hpp index 2cd58d373..ae2add504 100644 --- a/src/fflib/CodeAlloc.hpp +++ b/src/fflib/CodeAlloc.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,56 +29,54 @@ #ifndef CODE_ALLOC_HPP #define CODE_ALLOC_HPP -class CodeAlloc { public: - - static size_t nb,nbt,lg, nbdl,nbpx, chunk ; - static CodeAlloc ** mem; +class CodeAlloc { + public: + static size_t nb, nbt, lg, nbdl, nbpx, chunk; + static CodeAlloc **mem; static bool cleanning; - static void * lgmax; + static void *lgmax; static bool sort; - static size_t memoryusage; // add FH mach 2014 .. - static CodeAlloc * tnull; + static size_t memoryusage; // add FH mach 2014 .. + static CodeAlloc *tnull; static bool isdel(int i) { - return ((char *) (void *) mem[i] - (char *) 0) % 2 == 1; - } - - static void setdel(int i) - { - mem[i] = (CodeAlloc *) (void *) (((char *) mem[i] - (char *) 0)+ 1); + return ((char *)(void *)mem[i] - (char *)0) % 2 == 1; } - static void resize(); - - static void * Add2CleanAtEnd(void * p) - { - if(p) { - if(nbt>=nbpx) resize(); - if(nbt>0) sort = sort && mem[nbt-1] < p; - nb++; - mem[nbt++]=(CodeAlloc*)p; } + + static void setdel(int i) { mem[i] = (CodeAlloc *)(void *)(((char *)mem[i] - (char *)0) + 1); } + static void resize( ); + + static void *Add2CleanAtEnd(void *p) { + if (p) { + if (nbt >= nbpx) resize( ); + if (nbt > 0) sort = sort && mem[nbt - 1] < p; + nb++; + mem[nbt++] = (CodeAlloc *)p; + } return p; } - - void *operator new(size_t ll ) { - lg+=ll; - return Add2CleanAtEnd(::operator new(ll));} - - static void Sort_mem(); - static void clear(); + void *operator new(size_t ll) { + lg += ll; + return Add2CleanAtEnd(::operator new(ll)); + } + + static void Sort_mem( ); + static void clear( ); static void ErrorDel(void *pp); - void operator delete(void * pp); - virtual ~CodeAlloc() {} - + void operator delete(void *pp); + virtual ~CodeAlloc( ) {} }; -template class CodeAllocT: public CodeAlloc{ - T * p; - public: - CodeAllocT(int n): p(new T[n]) { assert(p);} - static T * New(int n) { return (new CodeAllocT(n))->p;} - ~CodeAllocT(){ delete [] p;} +template< class T > +class CodeAllocT : public CodeAlloc { + T *p; + + public: + CodeAllocT(int n) : p(new T[n]) { assert(p); } + static T *New(int n) { return (new CodeAllocT(n))->p; } + ~CodeAllocT( ) { delete[] p; } }; #endif diff --git a/src/fflib/InitFunct.cpp b/src/fflib/InitFunct.cpp index 9dd9e287d..f35f2b0cc 100644 --- a/src/fflib/InitFunct.cpp +++ b/src/fflib/InitFunct.cpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,57 +29,50 @@ #include #include #include -#include -#include "ffapi.hpp" +#include +#include "ffapi.hpp" using namespace std; -typedef void (* afunc)(); -typedef pair InitFunct; +typedef void (*afunc)( ); +typedef pair< int, afunc > InitFunct; -deque * getInitFunctlist() -{ - static deque * data = new deque(); +deque< InitFunct > *getInitFunctlist( ) { + static deque< InitFunct > *data = new deque< InitFunct >( ); return data; } extern long verbosity; -set & ff_SetofInitFunct() { static set sset; return sset;} +set< string > &ff_SetofInitFunct( ) { + static set< string > sset; + return sset; +} // <> -void call(const InitFunct & a) { - if(verbosity>5) - cout << "\n addInitFunct : " << a.first << " call : " <5) - cout << " ) " ; +void call(const InitFunct &a) { + if (verbosity > 5) cout << "\n addInitFunct : " << a.first << " call : " << a.second << " ( "; + (*a.second)( ); + if (verbosity > 5) cout << " ) "; } -bool comp(const InitFunct a,const InitFunct b) - { - return a.first < b.first; - } +bool comp(const InitFunct a, const InitFunct b) { return a.first < b.first; } // <> called by [[file:load.cpp::callInitsFunct]] -void callInitsFunct() -{ - deque *l(getInitFunctlist()); // [[getInitFunctlist]] - sort(l->begin(),l->end(),comp); - if(verbosity>5) cout << " callInitsFunct : " << l->size() << endl; - for_each(l->begin(),l->end(),call); // [[call]] - l->clear(); +void callInitsFunct( ) { + deque< InitFunct > *l(getInitFunctlist( )); // [[getInitFunctlist]] + sort(l->begin( ), l->end( ), comp); + if (verbosity > 5) cout << " callInitsFunct : " << l->size( ) << endl; + for_each(l->begin( ), l->end( ), call); // [[call]] + l->clear( ); } // <> called by [[file:InitFunct.hpp::calling_addInitFunct]] -void addInitFunct(int i,void (* f)(),const char *name) -{ - if(!name || (! *name ) +void addInitFunct(int i, void (*f)( ), const char *name) { + if (!name || + (!*name) - // [[ff_SetofInitFunct]] - || ff_SetofInitFunct().insert(name).second - ){ - getInitFunctlist()->push_back(make_pair(i,f)); - if(verbosity>9) cout << " -- addInitFunct: " << i << " " << f - << " " << (name ? name : "" ) <push_back(make_pair(i, f)); + if (verbosity > 9) cout << " -- addInitFunct: " << i << " " << f << " " << (name ? name : "") << endl; + } else + cout << " ******** addInitFunct " << name << " is always load (skip) !" << endl; } diff --git a/src/fflib/InitFunct.hpp b/src/fflib/InitFunct.hpp index 44bc8257d..0be28f46c 100644 --- a/src/fflib/InitFunct.hpp +++ b/src/fflib/InitFunct.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,19 +29,20 @@ #ifndef INITSFUNCT_HPP_ #define INITSFUNCT_HPP_ #include "ffapi.hpp" - + // [[file:~/ff/src/fflib/InitFunct.cpp::addInitFunct]] -void addInitFunct(int i,void (* f)(),const char *name) ; +void addInitFunct(int i, void (*f)( ), const char *name); // [[file:InitFunct.cpp::callInitsFunct]] -void callInitsFunct(); +void callInitsFunct( ); -class addingInitFunct { public: - addingInitFunct(int i,void (* f)(),const char *name="") { +class addingInitFunct { + public: + addingInitFunct(int i, void (*f)( ), const char *name = "") { // [[file:~/ff/src/fflib/InitFunct.cpp::addInitFunct]] - addInitFunct(i,f,name); + addInitFunct(i, f, name); } -} ; +}; // <> In Emscripten manipulating input and output streams is not allowed (cf // [[file:~/fflib/Makefile::NO_STREAM_REDIRECT]]) @@ -50,51 +51,53 @@ class addingInitFunct { public: #define LOADINITIO #else #if _WIN32 -#define LOADINITIO { \ - streambuf * so =ffapi::cout()->rdbuf() ; \ - streambuf * si =ffapi::cin()->rdbuf() ; \ - streambuf * se =ffapi::cerr()->rdbuf() ; \ - if( so && cout.rdbuf() != so ) cout.rdbuf(so); \ - if( si && cin.rdbuf() != si ) cin.rdbuf(si); \ - if( se && cerr.rdbuf() != se ) cerr.rdbuf(se); \ -} -#else // [[_WIN32]] -#define LOADINITIO { \ - streambuf * so =ffapi::cout()->rdbuf() ; \ - streambuf * si =ffapi::cin()->rdbuf() ; \ - streambuf * se =ffapi::cerr()->rdbuf() ; \ - if( so && cout.rdbuf() != so ) cout.rdbuf(so); \ - if( si && cin.rdbuf() != si ) cin.rdbuf(si); \ - if( se && cerr.rdbuf() != se ) cerr.rdbuf(se); \ - stdout = ffapi::ffstdout(); \ - stderr = ffapi::ffstderr(); \ - stdin = ffapi::ffstdin(); \ -} -#endif // [[_WIN32]] -#endif // [[NO_STREAM_REDIRECT]] +#define LOADINITIO \ + { \ + streambuf *so = ffapi::cout( )->rdbuf( ); \ + streambuf *si = ffapi::cin( )->rdbuf( ); \ + streambuf *se = ffapi::cerr( )->rdbuf( ); \ + if (so && cout.rdbuf( ) != so) cout.rdbuf(so); \ + if (si && cin.rdbuf( ) != si) cin.rdbuf(si); \ + if (se && cerr.rdbuf( ) != se) cerr.rdbuf(se); \ + } +#else // [[_WIN32]] +#define LOADINITIO \ + { \ + streambuf *so = ffapi::cout( )->rdbuf( ); \ + streambuf *si = ffapi::cin( )->rdbuf( ); \ + streambuf *se = ffapi::cerr( )->rdbuf( ); \ + if (so && cout.rdbuf( ) != so) cout.rdbuf(so); \ + if (si && cin.rdbuf( ) != si) cin.rdbuf(si); \ + if (se && cerr.rdbuf( ) != se) cerr.rdbuf(se); \ + stdout = ffapi::ffstdout( ); \ + stderr = ffapi::ffstderr( ); \ + stdin = ffapi::ffstdin( ); \ + } +#endif // [[_WIN32]] +#endif // [[NO_STREAM_REDIRECT]] -#define LOADINITNM(EXEC,NM) \ - \ - static void AutoLoadInit() { \ - \ - /* [[LOADINITIO]] */ \ - LOADINITIO; \ - if(verbosity>9) cout << "\n loadfile " NM "\n" ; \ - EXEC; \ - } \ - \ - static int DoLoadInit() { \ - if(verbosity>9) cout << " **** " << NM << " ****\n" ; \ - \ - /* <> */ \ - /* [[file:~/ff/src/fflib/InitFunct.cpp::addInitFunct]] */ \ - addInitFunct(10000,&AutoLoadInit,NM); \ - return 2; \ - } \ - \ - static int callDoLoadInit=DoLoadInit(); +#define LOADINITNM(EXEC, NM) \ + \ + static void AutoLoadInit( ) { \ + \ + /* [[LOADINITIO]] */ \ + LOADINITIO; \ + if (verbosity > 9) cout << "\n loadfile " NM "\n"; \ + EXEC; \ + } \ + \ + static int DoLoadInit( ) { \ + if (verbosity > 9) cout << " **** " << NM << " ****\n"; \ + \ + /* <> */ \ + /* [[file:~/ff/src/fflib/InitFunct.cpp::addInitFunct]] */ \ + addInitFunct(10000, &AutoLoadInit, NM); \ + return 2; \ + } \ + \ + static int callDoLoadInit = DoLoadInit( ); -#define LOADINIT(TI) LOADINITNM(TI init obsolete,__FILE__) -#define LOADFUNC(FC) LOADINITNM(FC() ,__FILE__) +#define LOADINIT(TI) LOADINITNM(TI init obsolete, __FILE__) +#define LOADFUNC(FC) LOADINITNM(FC( ), __FILE__) -#endif // [[INITSFUNCT_HPP_]] +#endif // [[INITSFUNCT_HPP_]] diff --git a/src/fflib/Operator.hpp b/src/fflib/Operator.hpp index f08d9b385..6eae14249 100644 --- a/src/fflib/Operator.hpp +++ b/src/fflib/Operator.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,365 +29,399 @@ #ifndef Operator_hpp_ #define Operator_hpp_ -#if defined(__GNUC__) && __GNUC__+0 >= 3 -inline double pow(double x,long l) { return pow(x,(double)l);} +#if defined(__GNUC__) && __GNUC__ + 0 >= 3 +inline double pow(double x, long l) { return pow(x, (double)l); } #endif - -template +template< class R, class A = R > struct Op1_neg { - using argument_type = A; - using result_type = R; - static R f(const A & a) { return - (R)a;} }; - -template -struct Op1_plus{ - using argument_type = A; - using result_type = R; - static R f(const A & a) { return + (R)a;} }; - -template -struct Op1_not{ - using argument_type = A; - using result_type = bool; - static bool f(const A & a) { return ! (bool)a;} }; - -template + using argument_type = A; + using result_type = R; + static R f(const A& a) { return -(R)a; } +}; + +template< class R, class A = R > +struct Op1_plus { + using argument_type = A; + using result_type = R; + static R f(const A& a) { return +(R)a; } +}; + +template< class A > +struct Op1_not { + using argument_type = A; + using result_type = bool; + static bool f(const A& a) { return !(bool)a; } +}; + +template< class R, class A = R, class B = A > struct Op2_add { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return ((R)a + (R)b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return ((R)a + (R)b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_sub { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return ((R)a - (R)b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return ((R)a - (R)b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_DotDiv { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return DotDiv((R)a, (R)b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return DotDiv((R)a, (R)b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_DotStar { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return DotStar((R)a, (R)b);} }; - + using result_type = R; + static R f(const A& a, const B& b) { return DotStar((R)a, (R)b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_mul { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - // cout << a << " * " << b <<" => " << ((R)a * (R)b) << endl; - return ((R)a * (R)b);} }; -template + using result_type = R; + static R f(const A& a, const B& b) { + // cout << a << " * " << b <<" => " << ((R)a * (R)b) << endl; + return ((R)a * (R)b); + } +}; +template< class R, class A, class B > struct Op2_mull { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - // cout << a << " * " << b <<" => " << ((R)a * (R)b) << endl; - return (a * b);} }; + using result_type = R; + static R f(const A& a, const B& b) { + // cout << a << " * " << b <<" => " << ((R)a * (R)b) << endl; + return (a * b); + } +}; -template +template< class R, class A = R, class B = A > struct Op2_div { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - if (b == B()) - {cerr << a << "/" << b << " : " << typeid(A).name() << " " << typeid(B).name() - << " " << typeid(R).name() << endl;ExecError(" Div by 0");} - return ((R)a / (R)b);} }; + using result_type = R; + static R f(const A& a, const B& b) { + if (b == B( )) { + cerr << a << "/" << b << " : " << typeid(A).name( ) << " " << typeid(B).name( ) << " " << typeid(R).name( ) << endl; + ExecError(" Div by 0"); + } + return ((R)a / (R)b); + } +}; -template +template< class R, class A, class B > struct Op2_divv { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - if (b == B()) - {cerr << a << "/" << b << " : " << typeid(A).name() << " " << typeid(B).name() - << " " << typeid(R).name() << endl;ExecError(" Div by 0");} - return (a / b);} }; + using result_type = R; + static R f(const A& a, const B& b) { + if (b == B( )) { + cerr << a << "/" << b << " : " << typeid(A).name( ) << " " << typeid(B).name( ) << " " << typeid(R).name( ) << endl; + ExecError(" Div by 0"); + } + return (a / b); + } +}; -template +template< class R > struct Op2_pipe { - using first_argument_type = R; + using first_argument_type = R; using second_argument_type = R; - using result_type = R; - static R f(const R & a,const R & b) { return (a | b);} }; + using result_type = R; + static R f(const R& a, const R& b) { return (a | b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_mod { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return ((R)a % (R)b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return ((R)a % (R)b); } +}; -template +template< class A, class B = A > struct Op2_lt { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { -// cout << a << " < " << b << " = " << ( a " <<( a == b) << endl; - return a == b;} }; + using result_type = bool; + static bool f(const A& a, const B& b) { // cout << a << " == " << b << " => " <<( a == b) << endl; + return a == b; + } +}; -template +template< class A, class B = A > struct Op2_ne { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { return a != b;} }; + using result_type = bool; + static bool f(const A& a, const B& b) { return a != b; } +}; struct Op2_and { - using first_argument_type = bool; + using first_argument_type = bool; using second_argument_type = bool; - using result_type = bool; - static bool f(const bool & a,const bool & b) { return a && b;} }; - + using result_type = bool; + static bool f(const bool& a, const bool& b) { return a && b; } +}; + struct Op2_or { - using first_argument_type = bool; + using first_argument_type = bool; using second_argument_type = bool; - using result_type = bool; - static bool f(const bool & a,const bool & b) { return a || b;} }; - + using result_type = bool; + static bool f(const bool& a, const bool& b) { return a || b; } +}; -template +template< class R, class A, class B > struct Op2_padd { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R * f(Stack s,const A & a,const B & b) { - R* r= Add2StackOfPtr2Free(s, a || b ? new R ((a ? *a : nullptr) + (b ? *b : nullptr)) : nullptr); - // delete a,delete b; - return r;} }; - + using result_type = R*; + static R* f(Stack s, const A& a, const B& b) { + R* r = Add2StackOfPtr2Free(s, a || b ? new R((a ? *a : nullptr) + (b ? *b : nullptr)) : nullptr); + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_plt { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r= *a < *b; - //delete a,delete b; - return r;} }; + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a < *b; + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_ple { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r= *a <= *b; - // delete a,delete b; - return r;} }; - + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a <= *b; + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_pgt { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r= *a > *b; - // delete a,delete b; - return r;} }; - + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a > *b; + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_pge { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r= *a >= *b; - // delete a,delete b; - return r;} }; + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a >= *b; + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_peq { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r= *a == *b; - // delete a,delete b; - return r;} }; + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a == *b; + // delete a,delete b; + return r; + } +}; -template +template< class A, class B = A > struct Op2_pne { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = bool; - static bool f(const A & a,const B & b) { bool r=*a != *b; - // delete a,delete b; - return r;} }; - + using result_type = bool; + static bool f(const A& a, const B& b) { + bool r = *a != *b; + // delete a,delete b; + return r; + } +}; -template +template< class R, class A = R, class B = A > struct Op2_pow { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return R(pow(a,b));}}; - - + using result_type = R; + static R f(const A& a, const B& b) { return R(pow(a, b)); } +}; -template +template< class A > struct Op_Read { - using first_argument_type = istream*; + using first_argument_type = istream*; using second_argument_type = A*; - using result_type = istream*; - static istream * f(istream * const & f,A * const & a) - { - if( !f || !*f) ExecError("Fatal Error: file not open in read value (Op_Read)"); - *f >> *a; - if(!f->good()) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); - return f; - } + using result_type = istream*; + static istream* f(istream* const& f, A* const& a) { + if (!f || !*f) ExecError("Fatal Error: file not open in read value (Op_Read)"); + *f >> *a; + if (!f->good( )) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); + return f; + } }; -template +template< class A > struct Op_ReadP { - using first_argument_type = istream*; + using first_argument_type = istream*; using second_argument_type = A**; - using result_type = istream*; - static istream * f(istream * const & f,A ** const & a) - { - assert(a); - if( ! *a) *a= new A ; - if( !f || !*f) ExecError("Fatal Error: file not open in read value (Op_Read)"); - *f >> **a; - if(!f->good()) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); - return f; - } -}; - -template + using result_type = istream*; + static istream* f(istream* const& f, A** const& a) { + assert(a); + if (!*a) *a = new A; + if (!f || !*f) ExecError("Fatal Error: file not open in read value (Op_Read)"); + *f >> **a; + if (!f->good( )) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); + return f; + } +}; + +template< class A > struct Op_ReadKN { - using first_argument_type = istream*; - using second_argument_type = KN*; - using result_type = istream*; - static istream * f(istream * const & f,KN* const & a) - { - if( !f || !*f) ExecError("Fatal Error: file not open in read array (Op_ReadKN)"); - int n;char c; - *f >> n; - if(!f->good()) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); - - if(n !=a->N()) { - cerr << " length on the array " << a->N() << " != " << n << " length in file " << endl; - ExecError("Fatal Error: incompatible length in read array (Op_ReadKN)"); - assert(n==a->N()); - } - while (f->get(c) && (c!='\n' && c!='\r' ) ) ((void) 0); // eat until control (new line - - // buffer problem if reading value are out range - for (int i=0;i> (*a)[i] ; - if (!f->good()) { - cerr << " reading problem with value i:" << i << " .... " <<(*a)[i]< " << (*a)[i] << " " << f->good() << endl; - } - } - return f; - } + using first_argument_type = istream*; + using second_argument_type = KN< A >*; + using result_type = istream*; + static istream* f(istream* const& f, KN< A >* const& a) { + if (!f || !*f) ExecError("Fatal Error: file not open in read array (Op_ReadKN)"); + int n; + char c; + *f >> n; + if (!f->good( )) ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); + + if (n != a->N( )) { + cerr << " length on the array " << a->N( ) << " != " << n << " length in file " << endl; + ExecError("Fatal Error: incompatible length in read array (Op_ReadKN)"); + assert(n == a->N( )); + } + while (f->get(c) && (c != '\n' && c != '\r')) ((void)0); // eat until control (new line + + // buffer problem if reading value are out range + for (int i = 0; i < n; i++) { + *f >> (*a)[i]; + if (!f->good( )) { + cerr << " reading problem with value i:" << i << " .... " << (*a)[i] << endl; + ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); + cout << "test i: " << i << " -> " << (*a)[i] << " " << f->good( ) << endl; + } + } + return f; + } }; -template +template< class A > struct Op_ReadKNM { - using first_argument_type = istream*; - using second_argument_type = KNM*; - using result_type = istream*; - static istream * f(istream * const & f,KNM* const & a) - { - if( !f || !*f) ExecError("Fatal Error: file not open in read array (Op_ReadKNM)"); - int n,m;char c; - *f >> n >> m; - if(!f->good()) ExecError("Fatal Error: file not good in read array (Op_ReadKNM)"); - - if(n !=a->N() || m != a->M() ) { - cerr << " length on the array N " << a->N() << " != " << n << " n in file " << endl; - cerr << " or M " << a->M() << " != " << m << " m in file " << endl; - ExecError("Fatal Error: incompatible length in read array (Op_ReadKNM)"); - assert(n==a->N()); - } - while (f->get(c) && (c!='\n' && c!='\r' ) ) ((void) 0); // eat until control (new line - - for (int i=0;i> (*a)(i,j) ; - if (!f->good()) { - cerr << " reading problem with value i:" << i << " .... " <<(*a)[i]< " << (*a)(i,j) << " " << f->good() << endl; - } - } - return f; + using first_argument_type = istream*; + using second_argument_type = KNM< A >*; + using result_type = istream*; + static istream* f(istream* const& f, KNM< A >* const& a) { + if (!f || !*f) ExecError("Fatal Error: file not open in read array (Op_ReadKNM)"); + int n, m; + char c; + *f >> n >> m; + if (!f->good( )) ExecError("Fatal Error: file not good in read array (Op_ReadKNM)"); + + if (n != a->N( ) || m != a->M( )) { + cerr << " length on the array N " << a->N( ) << " != " << n << " n in file " << endl; + cerr << " or M " << a->M( ) << " != " << m << " m in file " << endl; + ExecError("Fatal Error: incompatible length in read array (Op_ReadKNM)"); + assert(n == a->N( )); } + while (f->get(c) && (c != '\n' && c != '\r')) ((void)0); // eat until control (new line + + for (int i = 0; i < n; i++) + for (int j = 0; j < m; j++) { + *f >> (*a)(i, j); + if (!f->good( )) { + cerr << " reading problem with value i:" << i << " .... " << (*a)[i] << endl; + ExecError("Fatal Error: file not good in read array (Op_ReadKN)"); + cout << "test (i,j): (" << i << "," << j << ")" << " -> " << (*a)(i, j) << " " << f->good( ) << endl; + } + } + return f; + } }; - -template +template< class A > struct Op_WriteKNM { - using first_argument_type = ostream*; - using second_argument_type = KNM*; - using result_type = ostream*; - static ostream * f(ostream * const & f,KNM* const & a) { - *f << *a; - return f; - } + using first_argument_type = ostream*; + using second_argument_type = KNM< A >*; + using result_type = ostream*; + static ostream* f(ostream* const& f, KNM< A >* const& a) { + *f << *a; + return f; + } }; - -template +template< class A > struct Op_WriteKN { - using first_argument_type = ostream*; - using second_argument_type = KN*; - using result_type = ostream*; - static ostream * f(ostream * const & f,KN* const & a) { - *f << *a; - return f; - } + using first_argument_type = ostream*; + using second_argument_type = KN< A >*; + using result_type = ostream*; + static ostream* f(ostream* const& f, KN< A >* const& a) { + *f << *a; + return f; + } }; /* FH je supprime mauvais code nov 2019 @@ -396,7 +430,7 @@ struct Op_WriteKNM : public binary_function*,ostrea static ostream * f(ostream * const & f,KNM* const & a) { int n =a->N(), m = a->M(); - + for (int i=0;i1.e300 || abs((*a)(i,j))<1.e-300) @@ -419,202 +453,262 @@ struct Op_WriteKN : public binary_function*,ostream* } }; */ -template +template< class A > struct Print { - using first_argument_type = ostream*; + using first_argument_type = ostream*; using second_argument_type = A; - using result_type = ostream*; - static ostream* f(ostream* const & a,const A & b) { *a << b; return a;} + using result_type = ostream*; + static ostream* f(ostream* const& a, const A& b) { + *a << b; + return a; + } }; // --------------------------------------------- -template +template< class A > struct set_eq { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = A; - using result_type = A*; - static A* f(A* const & a,const A & b) { *a = b; return a;} + using result_type = A*; + static A* f(A* const& a, const A& b) { + *a = b; + return a; + } }; -template +template< class A, class B > struct set_eqq { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(const A & a,const B & b) {A aa(a); aa = b; return aa;} + using result_type = A; + static A f(const A& a, const B& b) { + A aa(a); + aa = b; + return aa; + } }; -template +template< class A, class B > struct set_eqq_add { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(const A & a,const B & b) {A aa(a); aa += b; return aa;} + using result_type = A; + static A f(const A& a, const B& b) { + A aa(a); + aa += b; + return aa; + } }; -template +template< class A > struct set_eq_add { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = A; - using result_type = A*; - static A* f(A* const & a,const A & b) { *a += b; return a;} + using result_type = A*; + static A* f(A* const& a, const A& b) { + *a += b; + return a; + } }; -template +template< class A > struct set_eq_sub { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = A; - using result_type = A*; - static A* f(A* const & a,const A & b) { *a -= b; return a;} + using result_type = A*; + static A* f(A* const& a, const A& b) { + *a -= b; + return a; + } }; -template +template< class A, class B = A > struct set_eq_mul { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a,const B & b) { *a *= b; return a;} + using result_type = A*; + static A* f(A* const& a, const B& b) { + *a *= b; + return a; + } }; -template +template< class A, class B = A > struct set_eq_div { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a,const B & b) { *a /= b; return a;} + using result_type = A*; + static A* f(A* const& a, const B& b) { + *a /= b; + return a; + } }; - struct set_peqstring { - using first_argument_type = string**; + using first_argument_type = string**; using second_argument_type = string*; - using result_type = string**; - static string** f(string** const & a, string * const & b) { - if(*a != b ) - { - //cerr << " set_peq " << *a << endl; - freestring(*a); - //cerr << " set_peq " << *a << " " << " = " << b << " " << endl; - *a = newstring(*b); //(stack ptr) FH mars 2006 - //cerr << " set_peq " << *a << " " << **a << " = " << *b << " " << b << endl; + using result_type = string**; + static string** f(string** const& a, string* const& b) { + if (*a != b) { + // cerr << " set_peq " << *a << endl; + freestring(*a); + // cerr << " set_peq " << *a << " " << " = " << b << " " << endl; + *a = newstring(*b); //(stack ptr) FH mars 2006 + // cerr << " set_peq " << *a << " " << **a << " = " << *b << " " << b << endl; } - return a;} + return a; + } }; // --------------------------------------------- -template +template< class A, class B > struct set_eqarrayp { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { *a = *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + *a = *b; + return a; + } }; -template +template< class A, class B > struct set_eqarrayp_add { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { assert(SameShape(*a,*b)); *a += *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a += *b; + return a; + } }; -template +template< class A, class B > struct set_eqarrayp_sub { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { assert(SameShape(*a,*b)); *a -= *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a -= *b; + return a; + } }; -template +template< class A, class B > struct set_eqarrayp_mul { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { assert(SameShape(*a,*b)); *a *= *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a *= *b; + return a; + } }; - -template +template< class A, class B > struct set_eqarrayp_div { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { assert(SameShape(*a,*b)); *a /= *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a /= *b; + return a; + } }; // --------------------------------------------- -template +template< class A, class B > struct set_eqarraypd { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,*b)); *a = *b; - delete b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a = *b; + delete b; + return a; + } }; - -template +template< class A, class B > struct set_eqarraypd_add { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,*b)); *a += *b; - delete b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a += *b; + delete b; + return a; + } }; -template +template< class A, class B > struct set_eqarraypd_sub { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,*b)); *a -= *b; - delete b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a -= *b; + delete b; + return a; + } }; -template +template< class A, class B > struct set_eqarraypd_mul { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,*b)); *a *= *b; - delete b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a *= *b; + delete b; + return a; + } }; -template +template< class A, class B > struct set_eqarraypd_div { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,*b)); *a /= *b; - delete b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, *b)); + *a /= *b; + delete b; + return a; + } }; // --------------------------------------------- -template +template< class A, class B > struct set_eqarray { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) - { *a = b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + *a = b; + return a; + } }; -// --------------------------------------------- august 2007 FH -template +// --------------------------------------------- august 2007 FH +template< class A, class B > struct init_eqarray { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) - { a->init(); *a = b; - return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + a->init( ); + *a = b; + return a; + } }; /* template @@ -625,67 +719,92 @@ struct init_eqarray_call { return a;} };*/ // --------------------------------------------- -template +template< class A, class B > struct init_eqarraypd { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {a->init(); *a = *b; + using result_type = A*; + static A* f(A* const& a, B const& b) { + a->init( ); + *a = *b; delete b; - return a;} + return a; + } }; // --------------------------------------------- -template +template< class A, class B > struct init_eqarrayp { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) { a->init(); *a = *b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + a->init( ); + *a = *b; + return a; + } }; // ---------------------------------------- fin modif august 2007 -template +template< class A, class B > struct set_eqarray_add { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,b)); *a += b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, b)); + *a += b; + return a; + } }; -template +template< class A, class B > struct set_eqarray_sub { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,b)); *a -= b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, b)); + *a -= b; + return a; + } }; -template +template< class A, class B > struct set_eqarray_mul { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,b)); *a *= b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, b)); + *a *= b; + return a; + } }; -template +template< class A, class B > struct set_eqarray_div { - using first_argument_type = A*; + using first_argument_type = A*; using second_argument_type = B; - using result_type = A*; - static A* f(A* const & a, B const & b) {assert(SameShape(*a,b)); *a /= b; return a;} + using result_type = A*; + static A* f(A* const& a, B const& b) { + assert(SameShape(*a, b)); + *a /= b; + return a; + } }; -template -struct set_eq_array{ - using first_argument_type = A; +template< class A, class B > +struct set_eq_array { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(const A & a, B const & b) - { A aa=a;aa = b; - return a;} + using result_type = A; + static A f(const A& a, B const& b) { + A aa = a; + aa = b; + return a; + } }; /* @@ -697,357 +816,476 @@ struct set_eq_array_call: public binary_function { return a;} }; */ -template -struct set_eq_array_add { - using first_argument_type = A; - using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa += b; return a;} +template< class A, class B > +struct set_eq_array_add { + using first_argument_type = A; + using second_argument_type = B; + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, b)); + A aa(a); + aa += b; + return a; + } }; -template -struct set_eq_array_sub { - using first_argument_type = A; +template< class A, class B > +struct set_eq_array_sub { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa -= b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, b)); + A aa(a); + aa -= b; + return a; + } }; -template -struct set_eq_array_mul { - using first_argument_type = A; +template< class A, class B > +struct set_eq_array_mul { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa *= b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, b)); + A aa(a); + aa *= b; + return a; + } }; -template -struct set_eq_array_div { - using first_argument_type = A; +template< class A, class B > +struct set_eq_array_div { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa /= b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, b)); + A aa(a); + aa /= b; + return a; + } }; -template -struct set_eq_arrayp { - using first_argument_type = A; - using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) { A aa(a); aa = *b; return a;} +template< class A, class B > +struct set_eq_arrayp { + using first_argument_type = A; + using second_argument_type = B; + using result_type = A; + static A f(A const& a, B const& b) { + A aa(a); + aa = *b; + return a; + } }; // --------------------------------------------- -template -struct set_eq_arraypd { - using first_argument_type = A; - using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,*b));A aa(a); aa = *b; - delete b; - return a;} +template< class A, class B > +struct set_eq_arraypd { + using first_argument_type = A; + using second_argument_type = B; + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa = *b; + delete b; + return a; + } }; -template -struct set_eq_arrayp_sub { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arrayp_sub { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa -= *b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa -= *b; + return a; + } }; -template -struct set_eq_arrayp_mul { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arrayp_mul { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa *= *b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa *= *b; + return a; + } }; -template -struct set_eq_arrayp_div { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arrayp_div { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa /= *b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa /= *b; + return a; + } }; -template -struct set_eq_arrayp_add { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arrayp_add { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa += *b; return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa += *b; + return a; + } }; -template -struct set_eq_arraypd_add { - using first_argument_type = A; - using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa += *b; - delete b; - return a;} +template< class A, class B > +struct set_eq_arraypd_add { + using first_argument_type = A; + using second_argument_type = B; + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa += *b; + delete b; + return a; + } }; -template -struct set_eq_arraypd_sub { - using first_argument_type = A; - using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa -= *b; - delete b; - return a;} +template< class A, class B > +struct set_eq_arraypd_sub { + using first_argument_type = A; + using second_argument_type = B; + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa -= *b; + delete b; + return a; + } }; -template -struct set_eq_arraypd_mul { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arraypd_mul { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa *= *b; - delete b; - return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa *= *b; + delete b; + return a; + } }; -template -struct set_eq_arraypd_div { - using first_argument_type = A; +template< class A, class B > +struct set_eq_arraypd_div { + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa /= *b; - delete b; - return a;} + using result_type = A; + static A f(A const& a, B const& b) { + assert(SameShape(a, *b)); + A aa(a); + aa /= *b; + delete b; + return a; + } }; -template +template< class A > struct PrintP { - using first_argument_type = ostream*; + using first_argument_type = ostream*; using second_argument_type = A; - using result_type = ostream*; - static ostream* f(ostream* const & a,const A & b) { if(b) *a << *b; - // a->flush();// ADD FH MAi 2010 to empty the buffer baf idea add flush of ostream - //delete b; mars 2006 FH - return a;} + using result_type = ostream*; + static ostream* f(ostream* const& a, const A& b) { + if (b) *a << *b; + // a->flush();// ADD FH MAi 2010 to empty the buffer baf idea add flush of ostream + // delete b; mars 2006 FH + return a; + } }; -template +template< class A > struct PrintPnd { - using first_argument_type = ostream*; + using first_argument_type = ostream*; using second_argument_type = A; - using result_type = ostream*; - static ostream* f(ostream* const & a,const A & b) - { if(verbosity>9999) cout << "PrintPnd: " << b << endl; *a << *b; return a;} + using result_type = ostream*; + static ostream* f(ostream* const& a, const A& b) { + if (verbosity > 9999) cout << "PrintPnd: " << b << endl; + *a << *b; + return a; + } }; -template +template< class A > struct PrintPn { - using first_argument_type = ostream*; + using first_argument_type = ostream*; using second_argument_type = A; - using result_type = ostream*; - static ostream* f(ostream* const & a,const A & b) - { if(verbosity>9999) cout << "PrintPn: " << b << endl; *a << b; return a;} -}; - - - - -template R * set_eqP(R* a,A b){ - if (*a != b) delete (*a) ; - ( *a =b); return a;} -template R * set_eqdestroy(R* a,A b){ - if (*a != b) (**a).destroy() ;// le cas debile Th=Th doit marcher - // cout << " set_eqdestroy " << a << " " << b << endl; - ( *a =b); return a;} - -template R * set_eqdestroy_incr(R* a,A b){ - if(b) (*b).increment() ; - if(*a) (**a).destroy() ;// le cas debile Th=Th doit marcher - // cout << " set_eqdestroy " << a << " " << b << endl; - ( *a =b); return a;} - -template R * set_copy( R* const & a,const R & b){ - SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); - memcpy(a,&b,sizeof(R)); return a;} - -template R ** set_copy_new( R** const & a,const R * & b){ - SHOWVERB( cout << " set_copy_new " << typeid(R).name() << " " << &b << endl); - *a= new R(*b); - return a;} - -template R * set_copyp( R* const & a,const R & b){ - SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); + using result_type = ostream*; + static ostream* f(ostream* const& a, const A& b) { + if (verbosity > 9999) cout << "PrintPn: " << b << endl; + *a << b; + return a; + } +}; + +template< class R, class A > +R* set_eqP(R* a, A b) { + if (*a != b) delete (*a); + (*a = b); + return a; +} +template< class R, class A > +R* set_eqdestroy(R* a, A b) { + if (*a != b) + (**a).destroy( ); // le cas debile Th=Th doit marcher + // cout << " set_eqdestroy " << a << " " << b << endl; + (*a = b); + return a; +} + +template< class R, class A > +R* set_eqdestroy_incr(R* a, A b) { + if (b) (*b).increment( ); + if (*a) + (**a).destroy( ); // le cas debile Th=Th doit marcher + // cout << " set_eqdestroy " << a << " " << b << endl; + (*a = b); + return a; +} + +template< class R > +R* set_copy(R* const& a, const R& b) { + SHOWVERB(cout << " set_copy " << typeid(R).name( ) << " " << &b << endl); + memcpy(a, &b, sizeof(R)); + return a; +} + +template< class R > +R** set_copy_new(R** const& a, const R*& b) { + SHOWVERB(cout << " set_copy_new " << typeid(R).name( ) << " " << &b << endl); + *a = new R(*b); + return a; +} + +template< class R > +R* set_copyp(R* const& a, const R& b) { + SHOWVERB(cout << " set_copy " << typeid(R).name( ) << " " << &b << endl); // memcpy(a,&b,sizeof(R)); - *a = b; - return a;} + *a = b; + return a; +} -template R ** set_copyp_new( R** a,R* b){ - SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); - //memcpy(a,&b,sizeof(R)); return a; FH 2007 - // cerr << " set_copyp_new " << typeid(R).name() << " " << b << " " << *b ; +template< class R > +R** set_copyp_new(R** a, R* b) { + SHOWVERB(cout << " set_copy " << typeid(R).name( ) << " " << &b << endl); + // memcpy(a,&b,sizeof(R)); return a; FH 2007 + // cerr << " set_copyp_new " << typeid(R).name() << " " << b << " " << *b ; *a = new R(*b); - // cerr << " -> " << *a << endl; + // cerr << " -> " << *a << endl; return a; - } +} -template R ** set_copy_incr( R** const & a, R * const & b){ - *a=b; - SHOWVERB( cout << "set_copy_incr " << b << " dans "<< a << endl); - if(b) b->increment(); - return a;} +template< class R > +R** set_copy_incr(R** const& a, R* const& b) { + *a = b; + SHOWVERB(cout << "set_copy_incr " << b << " dans " << a << endl); + if (b) b->increment( ); + return a; +} -template R * set_init2( R* const & a,const A & b,const A & c){ - SHOWVERB( cout << " set_init2 " << typeid(R).name() << " " << &b << " " << &c << endl); - a->init(b,c); return a;} -template R * set_init( R* const & a,const A & b){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); - a->init(b); return a;} -template R * set_init_N( R* const & a,const A & b){ - SHOWVERB( cout << " set_init_N" << typeid(R).name() << " " << &b << endl); - a->init(b.N()); *a=b; return a;} +template< class R, class A > +R* set_init2(R* const& a, const A& b, const A& c) { + SHOWVERB(cout << " set_init2 " << typeid(R).name( ) << " " << &b << " " << &c << endl); + a->init(b, c); + return a; +} +template< class R, class A > +R* set_init(R* const& a, const A& b) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << &b << endl); + a->init(b); + return a; +} +template< class R, class A > +R* set_init_N(R* const& a, const A& b) { + SHOWVERB(cout << " set_init_N" << typeid(R).name( ) << " " << &b << endl); + a->init(b.N( )); + *a = b; + return a; +} -template R * set_initp( R* const & a,const A & b){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); - a->init(*b); return a;} +template< class R, class A > +R* set_initp(R* const& a, const A& b) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << &b << endl); + a->init(*b); + return a; +} -template +template< class R, class A = R, class B = A > struct Op2_add0 { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (a + b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (a + b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_build { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return R(a,b);} }; -template + using result_type = R; + static R f(const A& a, const B& b) { return R(a, b); } +}; +template< class R, class A = R, class B = A > struct Op2_pbuild { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R *f(const A & a,const B & b) { return new R(a,b);} }; - -template + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a, b); } +}; + +template< class R, class A = R, class B = A > struct Op2_add__n { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R * f(const A & a,const B & b) { return new R(a + b);} }; -template + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a + b); } +}; +template< class R, class A = R, class B = A > struct Op2_addp_n { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R* f(const A & a,const B & b) { return new R(*a + b);} }; -template + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(*a + b); } +}; +template< class R, class A = R, class B = A > struct Op2_add_pn { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R* f(const A & a,const B & b) { return new R(a + *b);} }; - + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a + *b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_sub0 { - using first_argument_type = A; - using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (a - b);} }; - -template -struct Op1_subp{ - using argument_type = A; - using result_type = R; - static R f(const A & a) { return (- *a );} }; -template -struct Op1_sub{ - using argument_type = A; - using result_type = R; -static R f(const A & a) { return (- a );} }; - -template + using first_argument_type = A; + using second_argument_type = B; + using result_type = R; + static R f(const A& a, const B& b) { return (a - b); } +}; + +template< class R, class A = R > +struct Op1_subp { + using argument_type = A; + using result_type = R; + static R f(const A& a) { return (-*a); } +}; +template< class R, class A = R > +struct Op1_sub { + using argument_type = A; + using result_type = R; + static R f(const A& a) { return (-a); } +}; + +template< class R, class A = R, class B = A > struct Op2_mulcp { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (a * *b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (a * *b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_mulc { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (a * b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (a * b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_divc { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (a / b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (a / b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_mulpc { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (b * *a);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (b * *a); } +}; -template +template< class R, class A = R, class B = A > struct Op2_mulpcp { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return (*a * *b);} }; + using result_type = R; + static R f(const A& a, const B& b) { return (*a * *b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_2p_ { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { return R(*a,*b);} }; - + using result_type = R; + static R f(const A& a, const B& b) { return R(*a, *b); } +}; -template +template< class R, class A = R, class B = A > struct Op2_sub__n { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R * f(const A & a,const B & b) { return new R(a - b);} }; -template + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a - b); } +}; +template< class R, class A = R, class B = A > struct Op2_subp_n { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R* f(const A & a,const B & b) { return new R(*a - b);} }; -template + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(*a - b); } +}; +template< class R, class A = R, class B = A > struct Op2_sub_pn { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R* f(const A & a,const B & b) { return new R(a - *b);} }; - + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a - *b); } +}; -template -struct Op3_p: public ternary_function { - static R* f(Stack s,const A & a,const B & b,const C & c ) { return new R(a,b,c);} }; +template< class R, class A = R, class B = A, class C = A > +struct Op3_p : public ternary_function< A, B, C, R* > { + static R* f(Stack s, const A& a, const B& b, const C& c) { return new R(a, b, c); } +}; -template +template< class R, class A = R, class B = A > struct Op2_p { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = R*; - static R* f(const A & a,const B & b) { return new R(a,b);} }; - - - + using result_type = R*; + static R* f(const A& a, const B& b) { return new R(a, b); } +}; -template -class Transpose{ public: - T t; - Transpose( T v) - : t(v) {} - template Transpose( TT v) : t(v) {} - template Transpose( TT * v) : t(*v) {} - operator const T & () const {return t;} +template< class T > +class Transpose { + public: + T t; + Transpose(T v) : t(v) {} + template< class TT > + Transpose(TT v) : t(v) {} + template< class TT > + Transpose(TT* v) : t(*v) {} + operator const T&( ) const { return t; } }; #endif diff --git a/src/fflib/P1IsoValue.cpp b/src/fflib/P1IsoValue.cpp index 2c3acc229..432e4a4bb 100644 --- a/src/fflib/P1IsoValue.cpp +++ b/src/fflib/P1IsoValue.cpp @@ -11,426 +11,366 @@ using namespace std; #include "P1IsoValue.hpp" using namespace Fem2D; extern long verbosity; -//typedef double R; +// typedef double R; -inline R3 bary(const R3 K[4],R f[4],int i0,int i1,R v) -{ - R d=f[i0]-f[i1]; - assert(fabs(d)>1e-20); - R l1= (f[i0] - v)/ d; // == 1 si v = f[i1] - R l0 = 1. -l1; - assert(l0 >=-1e-10 && l1 >= -1e-10); - return K[i0]*l0 + K[i1]*l1; // == K[i1] si l1 ==1 => v = f[i1] +inline R3 bary(const R3 K[4], R f[4], int i0, int i1, R v) { + R d = f[i0] - f[i1]; + assert(fabs(d) > 1e-20); + R l1 = (f[i0] - v) / d; // == 1 si v = f[i1] + R l0 = 1. - l1; + assert(l0 >= -1e-10 && l1 >= -1e-10); + return K[i0] * l0 + K[i1] * l1; // == K[i1] si l1 ==1 => v = f[i1] } -inline R2 bary(const R2 K[3],R f[3],int i0,int i1,R v) -{ - R d=f[i0]-f[i1]; - assert(fabs(d)>1e-20); - R l1= (f[i0] - v)/ d; // == 1 si v = f[i1] - R l0 = 1. -l1; - assert(l0 >=-1e-10 && l1 >= -1e-10); - return K[i0]*l0 + K[i1]*l1; // == K[i1] si l1 ==1 => v = f[i1] +inline R2 bary(const R2 K[3], R f[3], int i0, int i1, R v) { + R d = f[i0] - f[i1]; + assert(fabs(d) > 1e-20); + R l1 = (f[i0] - v) / d; // == 1 si v = f[i1] + R l0 = 1. - l1; + assert(l0 >= -1e-10 && l1 >= -1e-10); + return K[i0] * l0 + K[i1] * l1; // == K[i1] si l1 ==1 => v = f[i1] } -static inline int signep4(int i0,int i1,int i2,int i3) -{ // calcul du signe dans la permutation - int s =1; - if(i0>i1) s=-s,Exchange(i0,i1); - if(i1>i2) s=-s,Exchange(i1,i2); - if(i2>i3) s=-s,Exchange(i2,i3); // i3 max - if(i0>i1) s=-s,Exchange(i0,i1); - if(i1>i2) s=-s,Exchange(i1,i2); // i2 max < i - if(i0>i1) s=-s,Exchange(i0,i1); - return s; +static inline int signep4(int i0, int i1, int i2, int i3) { // calcul du signe dans la permutation + int s = 1; + if (i0 > i1) s = -s, Exchange(i0, i1); + if (i1 > i2) s = -s, Exchange(i1, i2); + if (i2 > i3) s = -s, Exchange(i2, i3); // i3 max + if (i0 > i1) s = -s, Exchange(i0, i1); + if (i1 > i2) s = -s, Exchange(i1, i2); // i2 max < i + if (i0 > i1) s = -s, Exchange(i0, i1); + return s; } -inline int signe_permutation(int i0,int i1,int i2,int i3) -{ - int p=1; - if(i0>i1) Exchange(i0,i1), p = -p; - if(i0>i2) Exchange(i0,i2), p = -p; - if(i0>i3) Exchange(i0,i3), p = -p; - if(i1>i2) Exchange(i1,i2), p = -p; - if(i1>i3) Exchange(i1,i3), p = -p; - if(i2>i3) Exchange(i2,i3), p = -p; - return p; +inline int signe_permutation(int i0, int i1, int i2, int i3) { + int p = 1; + if (i0 > i1) Exchange(i0, i1), p = -p; + if (i0 > i2) Exchange(i0, i2), p = -p; + if (i0 > i3) Exchange(i0, i3), p = -p; + if (i1 > i2) Exchange(i1, i2), p = -p; + if (i1 > i3) Exchange(i1, i3), p = -p; + if (i2 > i3) Exchange(i2, i3), p = -p; + return p; } -inline void pen23tet(R3 P[6],R3 Q[3][4]) -{ - //int d1[3][4]= { {1,6,2,3}, {1,5,2,6}, {1,6,4,5}}; - int d0[3][4]= { {0,5,1,2}, {0,4,1,5}, {0,5,3,4}}; - /* the 6 way to spilt a pent en tet ... - DATA PDD /1,0,2,3,4,5,0,6/ - DATA (MU(I, 1),I=1,12) /1,6,2,3, 1,5,2,6, 1,6,4,5/ - DATA (MU(I, 2),I=1,12) /1,6,2,3, 1,4,2,6, 2,6,4,5/ - DATA (MU(I, 3),I=1,12) /1,4,2,3, 2,6,3,4, 2,6,4,5/ - DATA (MU(I, 4),I=1,12) /1,5,2,3, 1,5,3,6, 1,6,4,5/ - DATA (MU(I, 5),I=1,12) /1,5,2,3, 1,5,3,4, 3,6,4,5/ - DATA (MU(I, 6),I=1,12) /1,4,2,3, 2,5,3,4, 3,6,4,5/ - */ - for(int k=0; k<3; ++k) - for(int i=0; i<4;++i) - Q[k][i]=P[d0[k][i]]; +inline void pen23tet(R3 P[6], R3 Q[3][4]) { + // int d1[3][4]= { {1,6,2,3}, {1,5,2,6}, {1,6,4,5}}; + int d0[3][4] = {{0, 5, 1, 2}, {0, 4, 1, 5}, {0, 5, 3, 4}}; + /* the 6 way to spilt a pent en tet ... + DATA PDD /1,0,2,3,4,5,0,6/ + DATA (MU(I, 1),I=1,12) /1,6,2,3, 1,5,2,6, 1,6,4,5/ + DATA (MU(I, 2),I=1,12) /1,6,2,3, 1,4,2,6, 2,6,4,5/ + DATA (MU(I, 3),I=1,12) /1,4,2,3, 2,6,3,4, 2,6,4,5/ + DATA (MU(I, 4),I=1,12) /1,5,2,3, 1,5,3,6, 1,6,4,5/ + DATA (MU(I, 5),I=1,12) /1,5,2,3, 1,5,3,4, 3,6,4,5/ + DATA (MU(I, 6),I=1,12) /1,4,2,3, 2,5,3,4, 3,6,4,5/ + */ + for (int k = 0; k < 3; ++k) + for (int i = 0; i < 4; ++i) Q[k][i] = P[d0[k][i]]; } +int UnderIso(double *f, R2 Q[2][3], double area2[2], double eps) { -int UnderIso(double *f,R2 Q[2][3] ,double area2[2], double eps) -{ - - const R2 *K = R2::KHat; - const int p1[]= {1,2,0}; - const int p2[]= {2,0,1}; - R v=0; - // build the negative tetra under zero iso value of f .. - double fmx=f[0], fmn=f[0]; - fmx = std::max(fmx,f[1]); - fmn = std::min(fmn,f[1]); - fmx = std::max(fmx,f[2]); - fmn = std::min(fmn,f[2]); - if( fmn >= v - eps) - { - area2[0]=1; - return 0; // no intersection .. - } - if( fmx <= v+ eps) - { - area2[0]=1; - return 1; - }; // full triz .. + const R2 *K = R2::KHat; + const int p1[] = {1, 2, 0}; + const int p2[] = {2, 0, 1}; + R v = 0; + // build the negative tetra under zero iso value of f .. + double fmx = f[0], fmn = f[0]; + fmx = std::max(fmx, f[1]); + fmn = std::min(fmn, f[1]); + fmx = std::max(fmx, f[2]); + fmn = std::min(fmn, f[2]); + if (fmn >= v - eps) { + area2[0] = 1; + return 0; // no intersection .. + } + if (fmx <= v + eps) { + area2[0] = 1; + return 1; + }; // full triz .. - int np[4],nm[4]; - int km=0,kp=0; - - int ntria=0; - for (int i=0;i<3;++i) - { - if(f[i]<=v+eps) nm[km++]=i; - else np[kp++] = i; - } - if(km == 0) - { - area2[0]=0; - return 0; - } - else if( km == 1) - { // 1 tet j, j+1, j+2, j+3 - int j0=nm[0]; - int j1=p1[j0], j2=p2[j0]; - Q[0][0]=K[j0]; - Q[0][1]=bary(K,f,j0,j1,v); - Q[0][2]=bary(K,f,j0,j2,v); - ntria=1; - } - else if( km == 2) - {// 1 prisme - ntria=2; - int j0 = np[0]; - int j1=p1[j0], j2=p2[j0]; - R2 Q1=bary(K,f,j0,j1,v); - R2 Q2=bary(K,f,j0,j2,v); - Q[0][0]=K[j1]; - Q[0][1]=K[j2]; - Q[0][2]=Q2; - Q[1][0]=K[j1]; - Q[1][1]=Q2; - Q[1][2]=Q1; - } - else if( km == 3) - { - area2[0]=1; - return 1; - } - // vol computation - for(int k=0; k< ntria; ++k) - { - area2[k]=det(Q[k][0],Q[k][1],Q[k][2]); - //cout <= - eps); - } - - return ntria; - + int np[4], nm[4]; + int km = 0, kp = 0; + + int ntria = 0; + for (int i = 0; i < 3; ++i) { + if (f[i] <= v + eps) + nm[km++] = i; + else + np[kp++] = i; + } + if (km == 0) { + area2[0] = 0; + return 0; + } else if (km == 1) { // 1 tet j, j+1, j+2, j+3 + int j0 = nm[0]; + int j1 = p1[j0], j2 = p2[j0]; + Q[0][0] = K[j0]; + Q[0][1] = bary(K, f, j0, j1, v); + Q[0][2] = bary(K, f, j0, j2, v); + ntria = 1; + } else if (km == 2) { // 1 prisme + ntria = 2; + int j0 = np[0]; + int j1 = p1[j0], j2 = p2[j0]; + R2 Q1 = bary(K, f, j0, j1, v); + R2 Q2 = bary(K, f, j0, j2, v); + Q[0][0] = K[j1]; + Q[0][1] = K[j2]; + Q[0][2] = Q2; + Q[1][0] = K[j1]; + Q[1][1] = Q2; + Q[1][2] = Q1; + } else if (km == 3) { + area2[0] = 1; + return 1; + } + // vol computation + for (int k = 0; k < ntria; ++k) { + area2[k] = det(Q[k][0], Q[k][1], Q[k][2]); + // cout <= -eps); + } + + return ntria; } -int UnderIso(double *f,R3 Q[3][4] ,double vol6[3], double eps) -{ - const R3 *K = R3::KHat; - const int p1[]= {1,2,3,0}; - const int p2[]= {2,0,0,2}; - const int p3[]= {3,3,1,1}; - R v=0; +int UnderIso(double *f, R3 Q[3][4], double vol6[3], double eps) { + const R3 *K = R3::KHat; + const int p1[] = {1, 2, 3, 0}; + const int p2[] = {2, 0, 0, 2}; + const int p3[] = {3, 3, 1, 1}; + R v = 0; // build the negative tetra under zero iso value of f .. - double fmx=f[0], fmn=f[0]; - fmx = std::max(fmx,f[1]); - fmn = std::min(fmn,f[1]); - fmx = std::max(fmx,f[2]); - fmn = std::min(fmn,f[2]); - fmx = std::max(fmx,f[3]); - fmn = std::min(fmn,f[3]); - if( fmn >= v - eps) - { - vol6[0]=1; - return 0; // no intersection .. - } - if( fmx <= v+ eps) - { - vol6[0]=1; - return 1; - }; // full tet .. - + double fmx = f[0], fmn = f[0]; + fmx = std::max(fmx, f[1]); + fmn = std::min(fmn, f[1]); + fmx = std::max(fmx, f[2]); + fmn = std::min(fmn, f[2]); + fmx = std::max(fmx, f[3]); + fmn = std::min(fmn, f[3]); + if (fmn >= v - eps) { + vol6[0] = 1; + return 0; // no intersection .. + } + if (fmx <= v + eps) { + vol6[0] = 1; + return 1; + }; // full tet .. + // hard case .. -// count number - vol6[0]=1; - - int np[4],nm[4]; - int km=0,kp=0; - - int ntet=0; - for (int i=0;i<4;++i) - { - if(f[i]<=v+eps) nm[km++]=i; - else np[kp++] = i; - } - if(km == 0) - { - vol6[0]=0; - return 0; - } - else if( km == 1) - { // 1 tet j, j+1, j+2, j+3 - int j0=nm[0]; - int j1=p1[j0], j2=p2[j0], j3=p3[j0]; - Q[0][0]=K[j0]; - Q[0][1]=bary(K,f,j0,j1,v); - Q[0][2]=bary(K,f,j0,j2,v); - Q[0][3]=bary(K,f,j0,j3,v); - ntet=1; - } - else if( km == 2) - {// 1 prisme i0,i1, j0,j1, k0, k0 - ntet=3; - int i0=nm[0]; - int i1=nm[1]; - int k0=np[0]; - int k1=np[1]; - if(signe_permutation(i0,i1,k0,k1)<0) - std::swap(k0,k1); - - R3 P[6]; - P[0]=K[i0]; - P[1]=bary(K,f,i0,k0,v); - P[2]=bary(K,f,i0,k1,v); - P[3]=K[i1]; - P[4]=bary(K,f,i1,k0,v); - P[5]=bary(K,f,i1,k1,v); - pen23tet(P,Q); - - } - else if( km == 3) - { // prisme - ntet=3; - int k0=np[0]; - int i1=p1[k0]; - int i2=p2[k0]; - int i3=p3[k0]; - assert(signe_permutation(k0,i1,i2,i3)>0); - R3 P[6]; - P[3]=K[i1]; - P[4]=K[i2]; - P[5]=K[i3]; - P[0]=bary(K,f,i1,k0,v); - P[1]=bary(K,f,i2,k0,v); - P[2]=bary(K,f,i3,k0,v); - pen23tet(P,Q); - + // count number + vol6[0] = 1; - } - else if( km == 4) - { - vol6[0]=1; - return 1; - } -// vol computation - for(int k=0; k< ntet; ++k) - { - vol6[k]=det(Q[k][0],Q[k][1],Q[k][2],Q[k][3]); - assert(vol6[k] >= - eps); - if( vol6[k] 99 ) - cout < 0); + R3 P[6]; + P[3] = K[i1]; + P[4] = K[i2]; + P[5] = K[i3]; + P[0] = bary(K, f, i1, k0, v); + P[1] = bary(K, f, i2, k0, v); + P[2] = bary(K, f, i3, k0, v); + pen23tet(P, Q); + + } else if (km == 4) { + vol6[0] = 1; + return 1; + } + // vol computation + for (int k = 0; k < ntet; ++k) { + vol6[k] = det(Q[k][0], Q[k][1], Q[k][2], Q[k][3]); + assert(vol6[k] >= -eps); + if (vol6[k] < eps && verbosity > 99) cout << k << " bizarre " << km << " " << Q[k][0] << " " << Q[k][1] << " " << Q[k][2] << " " << Q[k][3] << endl; + } + + return ntet; } -int IsoLineK(double *f,Fem2D::R3 *Q, double eps) -{ - - static const int nvfaceTet[4][3] ={{3,2,1}, {0,2,3},{ 3,1,0},{ 0,1,2}} ; - - const R3 *K=R3::KHat; - int kv=0,vk[4],tv[4],kf; - for(int i=0;i<4;++i) - { - if( abs(f[i]) <= eps) - { - tv[kv++]=i; - vk[i]=1; - } - else - vk[kf=i]=0; - } - if(kv==3) - { - // cout << " full face " << kf << endl; - // a face complete kf.. - // warning - int i1=1,i2=2; - if(f[kf] <0) i1=2,i2=1; - Q[0]=K[nvfaceTet[kf][0]]; - Q[1]=K[nvfaceTet[kf][i1]]; - Q[2]=K[nvfaceTet[kf][i2]]; - - return (f[kf] >0) ? 3:0;// to take one fulL face not to times ... - } +int IsoLineK(double *f, Fem2D::R3 *Q, double eps) { - R v=0; - int nP=0; - int np[4],nm[4],nps[4],nms[4];; - int km=0,kp=0,kms=0,kps=0; - - for (int i=0;i<4;++i) - { - if(f[i]<=v+eps) nm[km++]=i; - if(f[i]>=v-eps) np[kp++]=i; - // strict .. - if(f[i]v+eps) nps[kps++]=i; - } - - // cout << "IsoLineK: km kp "<< km << " " << kp << endl; - int h=-1,b[3]; - if(kps==1 && km==3) - { - h = nps[0]; - b[0]=nvfaceTet[h][0]; - b[1]=nvfaceTet[h][1]; - b[2]=nvfaceTet[h][2]; - } - if(kms==1 && kp == 3) - { - h = nms[0]; - b[0]=nvfaceTet[h][0]; - b[2]=nvfaceTet[h][1]; - b[1]=nvfaceTet[h][2]; - } - if(kp==2 && km==2) - {// cas quad - if(signep4(nm[0],nm[1],np[0],np[1]) < 0) - Exchange(nm[0],nm[1]); - Q[0]=bary(K,f,nm[0],np[0],v); - Q[1]=bary(K,f,nm[0],np[1],v); - Q[2]=bary(K,f,nm[1],np[1],v); - Q[3]=bary(K,f,nm[1],np[0],v); - nP=4; - } - else if (h>=0) - { // cas triangle - Q[0]=bary(K,f,h,b[0],v); - Q[1]=bary(K,f,h,b[1],v); - Q[2]=bary(K,f,h,b[2],v); - nP=3; - } - - return nP; + static const int nvfaceTet[4][3] = {{3, 2, 1}, {0, 2, 3}, {3, 1, 0}, {0, 1, 2}}; + + const R3 *K = R3::KHat; + int kv = 0, vk[4], tv[4], kf; + for (int i = 0; i < 4; ++i) { + if (abs(f[i]) <= eps) { + tv[kv++] = i; + vk[i] = 1; + } else + vk[kf = i] = 0; + } + if (kv == 3) { + // cout << " full face " << kf << endl; + // a face complete kf.. + // warning + int i1 = 1, i2 = 2; + if (f[kf] < 0) i1 = 2, i2 = 1; + Q[0] = K[nvfaceTet[kf][0]]; + Q[1] = K[nvfaceTet[kf][i1]]; + Q[2] = K[nvfaceTet[kf][i2]]; + + return (f[kf] > 0) ? 3 : 0; // to take one fulL face not to times ... + } + + R v = 0; + int nP = 0; + int np[4], nm[4], nps[4], nms[4]; + ; + int km = 0, kp = 0, kms = 0, kps = 0; + + for (int i = 0; i < 4; ++i) { + if (f[i] <= v + eps) nm[km++] = i; + if (f[i] >= v - eps) np[kp++] = i; + // strict .. + if (f[i] < v - eps) nms[kms++] = i; + if (f[i] > v + eps) nps[kps++] = i; + } + + // cout << "IsoLineK: km kp "<< km << " " << kp << endl; + int h = -1, b[3]; + if (kps == 1 && km == 3) { + h = nps[0]; + b[0] = nvfaceTet[h][0]; + b[1] = nvfaceTet[h][1]; + b[2] = nvfaceTet[h][2]; + } + if (kms == 1 && kp == 3) { + h = nms[0]; + b[0] = nvfaceTet[h][0]; + b[2] = nvfaceTet[h][1]; + b[1] = nvfaceTet[h][2]; + } + if (kp == 2 && km == 2) { // cas quad + if (signep4(nm[0], nm[1], np[0], np[1]) < 0) Exchange(nm[0], nm[1]); + Q[0] = bary(K, f, nm[0], np[0], v); + Q[1] = bary(K, f, nm[0], np[1], v); + Q[2] = bary(K, f, nm[1], np[1], v); + Q[3] = bary(K, f, nm[1], np[0], v); + nP = 4; + } else if (h >= 0) { // cas triangle + Q[0] = bary(K, f, h, b[0], v); + Q[1] = bary(K, f, h, b[1], v); + Q[2] = bary(K, f, h, b[2], v); + nP = 3; + } + + return nP; } -int IsoLineK(double *f,Fem2D::R2 *Q, double eps) -{ - int debug=0; - R2 P[3]={ R2(0.,0.),R2(1.,0.),R2(0.,1.)}; - int kv=0,ke=0,e=3; - int tv[3],te[3],vk[3],i0[3],i1[3]; - for(int i=0;i<3;++i) - { - if( abs(f[i]) <= eps) { - e -= tv[kv++]=i; - vk[i]=1; - } +int IsoLineK(double *f, Fem2D::R2 *Q, double eps) { + int debug = 0; + R2 P[3] = {R2(0., 0.), R2(1., 0.), R2(0., 1.)}; + int kv = 0, ke = 0, e = 3; + int tv[3], te[3], vk[3], i0[3], i1[3]; + for (int i = 0; i < 3; ++i) { + if (abs(f[i]) <= eps) { + e -= tv[kv++] = i; + vk[i] = 1; + } else + vk[i] = 0; + } + if (debug) cout << " ** " << kv << endl; + if (kv > 1) // on 2 vertex on the isoline .... + { + if (kv == 2) { + if (f[e] > 0.) { + int j0 = (e + 1) % 3; + int j1 = (e + 2) % 3; + te[ke] = e + 3, i0[ke] = j0, i1[ke] = j0, ++ke; + te[ke] = e, i0[ke] = j1, i1[ke] = j1, ++ke; + // pb d'unicity, need to see the adj triangle ... + // return 10+e ; // edge number + 10 + } else + return 0; // skip edge ... + + } else + return 0; // const funct... + } else // see internal edge .. + for (int ee = 0; ee < 3; ++ee) { + int j0 = (ee + 1) % 3; + int j1 = (ee + 2) % 3; + if (vk[j0]) // the intial point on iso line + { + if (0. < f[j1]) + te[ke] = ee, i0[ke] = j0, i1[ke] = j0, ++ke; else - vk[i]=0; + te[ke] = ee + 3, i0[ke] = j0, i1[ke] = j0, ++ke; + } else if (vk[j1]) + ; // skip the final point on iso line + else if (f[j0] < 0. && 0. < f[j1]) // good sens + te[ke] = ee, i0[ke] = j0, i1[ke] = j1, ++ke; + else if (f[j0] > 0. && 0. > f[j1]) // inverse sens + te[ke] = ee + 3, i0[ke] = j1, i1[ke] = j0, ++ke; } - if(debug) cout << " ** " << kv << endl; - if(kv>1) // on 2 vertex on the isoline .... + if (ke == 2) { + // the K[i1[0]] , Q[0], Q[1] must be direct ... + // the K[i0[1]] , Q[0], Q[1] must be direct ... + // Warning no trivail case .. make a plot to see + // with is good + // the first edge must be + + if (te[0] < 3) // oriente the line { - if(kv==2) - { - if(f[e] > 0.) - { - int j0=(e+1)%3; - int j1=(e+2)%3; - te[ke]=e+3,i0[ke]=j0,i1[ke]=j0,++ke; - te[ke]=e,i0[ke]=j1,i1[ke]=j1,++ke; - // pb d'unicity, need to see the adj triangle ... - //return 10+e ; // edge number + 10 - } - else return 0; // skip edge ... - - } - else return 0; // const funct... + assert(te[1] >= 3); + std::swap(te[0], te[1]); + std::swap(i0[0], i0[1]); + std::swap(i1[0], i1[1]); + if (debug) cout << " swap " << endl; } - else // see internal edge .. - for(int ee=0;ee<3;++ee) - { - int j0=(ee+1)%3; - int j1=(ee+2)%3; - if( vk[j0]) // the intial point on iso line - { - if(0. < f[j1]) - te[ke]=ee,i0[ke]=j0,i1[ke]=j0,++ke; - else - te[ke]=ee+3,i0[ke]=j0,i1[ke]=j0,++ke; - } - else if (vk[j1]); // skip the final point on iso line - else if( f[j0] < 0. && 0. < f[j1]) // good sens - te[ke]=ee,i0[ke]=j0,i1[ke]=j1,++ke; - else if ( f[j0] > 0. && 0. > f[j1]) // inverse sens - te[ke]=ee+3,i0[ke]=j1,i1[ke]=j0,++ke; - } - if( ke==2) - { - // the K[i1[0]] , Q[0], Q[1] must be direct ... - // the K[i0[1]] , Q[0], Q[1] must be direct ... - // Warning no trivail case .. make a plot to see - // with is good - // the first edge must be - - if(te[0]<3) // oriente the line - { - assert(te[1] >=3); - std::swap(te[0],te[1]); - std::swap(i0[0],i0[1]); - std::swap(i1[0],i1[1]); - if(debug) cout << " swap " << endl; - } - for(int i=0;i<2;++i) - { - int j0=i0[i],j1=i1[i]; - if( j0== j1) - Q[i] = P[j0]; - else - Q[i] = (P[j0]*(f[j1]) - P[j1]*(f[j0]) ) /(f[j1]-f[j0]); - if(debug) cout << i << " " << j0 << " " << j1 << " : " - << Q[i] << "***" << endl; - } - if(!vk[i1[0]]) - assert( det(P[i1[0]],Q[0],Q[1]) > 0); - if(!vk[i0[1]]) - assert( det(P[i0[1]],Q[1],Q[0]) > 0); - return 2; + for (int i = 0; i < 2; ++i) { + int j0 = i0[i], j1 = i1[i]; + if (j0 == j1) + Q[i] = P[j0]; + else + Q[i] = (P[j0] * (f[j1]) - P[j1] * (f[j0])) / (f[j1] - f[j0]); + if (debug) cout << i << " " << j0 << " " << j1 << " : " << Q[i] << "***" << endl; } - // remark, the left of the line is upper . - return 0; + if (!vk[i1[0]]) assert(det(P[i1[0]], Q[0], Q[1]) > 0); + if (!vk[i0[1]]) assert(det(P[i0[1]], Q[1], Q[0]) > 0); + return 2; + } + // remark, the left of the line is upper . + return 0; } diff --git a/src/fflib/P1IsoValue.hpp b/src/fflib/P1IsoValue.hpp index 76ce7c01c..6d39a708e 100644 --- a/src/fflib/P1IsoValue.hpp +++ b/src/fflib/P1IsoValue.hpp @@ -7,25 +7,24 @@ // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #ifndef __ff__P1IsoValue__ #define __ff__P1IsoValue__ @@ -33,17 +32,13 @@ #include #include - #include "ufunction.hpp" -namespace Fem2D -{ +namespace Fem2D { #include "R3.hpp" } -int IsoLineK(double *f,Fem2D::R3 *Q, double eps); -int IsoLineK(double *f,Fem2D::R2 *Q, double eps); -int UnderIso(double *f,Fem2D::R3 Q[3][4] ,double vol[3], double eps); -int UnderIso(double *f,Fem2D::R2 Q[2][3] ,double area[2], double eps); - - +int IsoLineK(double *f, Fem2D::R3 *Q, double eps); +int IsoLineK(double *f, Fem2D::R2 *Q, double eps); +int UnderIso(double *f, Fem2D::R3 Q[3][4], double vol[3], double eps); +int UnderIso(double *f, Fem2D::R2 Q[2][3], double area[2], double eps); #endif /* defined(__ff__P1IsoValue__) */ diff --git a/src/fflib/PlotStream.hpp b/src/fflib/PlotStream.hpp index e441f5b79..576778fe4 100644 --- a/src/fflib/PlotStream.hpp +++ b/src/fflib/PlotStream.hpp @@ -15,263 +15,363 @@ #ifndef PLOT_STREAM_HPP_ #define PLOT_STREAM_HPP_ -//FFCS visualization stream redirection +// FFCS visualization stream redirection #include "ffapi.hpp" -using Fem2D::Mesh; -using Fem2D::Mesh3; -namespace Fem2D { - -} +using Fem2D::Mesh; +using Fem2D::Mesh3; +namespace Fem2D {} +class PlotStream { + public: + FILE* TheStream; -class PlotStream -{ -public: - - FILE * TheStream; - - PlotStream(FILE *Stream) :TheStream(Stream) { } - operator bool() const { return TheStream;} - // datatype mush be < 0 to have no collistion with arg number. + PlotStream(FILE* Stream) : TheStream(Stream) {} + operator bool( ) const { return TheStream; } + // datatype mush be < 0 to have no collistion with arg number. // FFCS: <> - enum datatype { dt_meshes=-1,dt_plots=-2,dt_endplot=-3,dt_meshes3=-10,dt_endarg=99999,dt_newplot=-5, dt_meshesS=-12, dt_meshesL=-13}; // modif order - + enum datatype { dt_meshes = -1, dt_plots = -2, dt_endplot = -3, dt_meshes3 = -10, dt_endarg = 99999, dt_newplot = -5, dt_meshesS = -12, dt_meshesL = -13 }; // modif order + // dt_plots3=-11,dt_plotsS=-13,dt_plots3S=-14 - //FFCS:need to send control data to FFCS at least once per plot - void SendNewPlot() { ffapi::newplot();write((long )dt_newplot); set_binary_mode(); } - void SendEndArgPlot() {write((long )dt_endarg); } - //FFCS:redirect visualization stream - void SendEndPlot() { write((long )dt_endplot);ffapi::ff_fflush(TheStream); set_text_mode() ;} - void SendPlots() { write((long )dt_plots); } - void SendMeshes() { write((long )dt_meshes);} - void SendMeshes3() { write((long )dt_meshes3);} - void SendMeshesS() { write((long )dt_meshesS);} - void SendMeshesL() { write((long )dt_meshesL);} - //FFCS: divert stream to FFCS - void write(const void *data,size_t l) {ffapi::ff_fwrite(data,1,l,TheStream);} + // FFCS:need to send control data to FFCS at least once per plot + void SendNewPlot( ) { + ffapi::newplot( ); + write((long)dt_newplot); + set_binary_mode( ); + } + void SendEndArgPlot( ) { write((long)dt_endarg); } + // FFCS:redirect visualization stream + void SendEndPlot( ) { + write((long)dt_endplot); + ffapi::ff_fflush(TheStream); + set_text_mode( ); + } + void SendPlots( ) { write((long)dt_plots); } + void SendMeshes( ) { write((long)dt_meshes); } + void SendMeshes3( ) { write((long)dt_meshes3); } + void SendMeshesS( ) { write((long)dt_meshesS); } + void SendMeshesL( ) { write((long)dt_meshesL); } + // FFCS: divert stream to FFCS + void write(const void* data, size_t l) { ffapi::ff_fwrite(data, 1, l, TheStream); } - PlotStream& write(const bool& bb) {bool b=w_endian(bb);write(reinterpret_cast (&b),sizeof(bool));return *this;} - PlotStream& write(const long long& bb) {long long b=w_endian(bb);write(reinterpret_cast (&b),sizeof(long long));return *this;} - PlotStream& write(const long& bb) { // always write 8 bits for a long FH. - long long ll=bb;ll=w_endian(ll);write(reinterpret_cast (&ll),sizeof(long long)); - return *this;} - PlotStream& write(const int& bb) {int b=w_endian(bb);write(reinterpret_cast (&b),sizeof(int));return *this;} - PlotStream& write(const double& bb) {double b=w_endian(bb);write(reinterpret_cast (&b),sizeof(double));return *this;} - PlotStream& write(const complex& bb) {return write(bb.real()),write(bb.imag());} - PlotStream &write(const Fem2D::R1 & P) { return write(P.x);} - PlotStream &write(const Fem2D::R2 & P) { return write(P.x),write(P.y);} - PlotStream &write(const Fem2D::R3 & P) { return write(P.x),write(P.y),write(P.z);} + PlotStream& write(const bool& bb) { + bool b = w_endian(bb); + write(reinterpret_cast< const void* >(&b), sizeof(bool)); + return *this; + } + PlotStream& write(const long long& bb) { + long long b = w_endian(bb); + write(reinterpret_cast< const void* >(&b), sizeof(long long)); + return *this; + } + PlotStream& write(const long& bb) { // always write 8 bits for a long FH. + long long ll = bb; + ll = w_endian(ll); + write(reinterpret_cast< const void* >(&ll), sizeof(long long)); + return *this; + } + PlotStream& write(const int& bb) { + int b = w_endian(bb); + write(reinterpret_cast< const void* >(&b), sizeof(int)); + return *this; + } + PlotStream& write(const double& bb) { + double b = w_endian(bb); + write(reinterpret_cast< const void* >(&b), sizeof(double)); + return *this; + } + PlotStream& write(const complex< double >& bb) { return write(bb.real( )), write(bb.imag( )); } + PlotStream& write(const Fem2D::R1& P) { return write(P.x); } + PlotStream& write(const Fem2D::R2& P) { return write(P.x), write(P.y); } + PlotStream& write(const Fem2D::R3& P) { return write(P.x), write(P.y), write(P.z); } - PlotStream& write(const string& b) { - int l=b.size(); + PlotStream& write(const string& b) { + int l = b.size( ); write(l); - write(b.data(),l); + write(b.data( ), l); return *this; } - - void set_text_mode() - { - //FFCS:visualization stream redirection + + void set_text_mode( ) { + // FFCS:visualization stream redirection ffapi::wintextmode(TheStream); } - void set_binary_mode() - { - //FFCS:visualization stream redirection + void set_binary_mode( ) { + // FFCS:visualization stream redirection ffapi::winbinmode(TheStream); } - - PlotStream & operator << (const bool& b) { return write(b); } - PlotStream & operator << (const long& b) { return write(b); } - PlotStream & operator << (const long long & b) { return write(b); } - PlotStream & operator << (const int& b) { return write(b); } - PlotStream & operator << (const double& b) { return write(b); } - PlotStream & operator << (const complex& b) { return write(b); } - PlotStream & operator << (const string& s) { return write(s); } - PlotStream & operator << (const string* s) { ffassert(s); return write(*s); } - template - PlotStream & operator << (const KN_& b) - { - long n=b.N(); - write(n); - // cout << "PlotStream :<< n " << n << endl; - for (int i=0;i& b) { return write(b); } + PlotStream& operator<<(const string& s) { return write(s); } + PlotStream& operator<<(const string* s) { + ffassert(s); + return write(*s); + } + template< class T > + PlotStream& operator<<(const KN_< T >& b) { + long n = b.N( ); + write(n); + // cout << "PlotStream :<< n " << n << endl; + + for (int i = 0; i < n; ++i) write(b[i]); + return *this; + } + + PlotStream& operator<<(const Mesh& Th) { + /* + Serialize s=Th.serialize(); + long n=s.size(); + write( n ); + write(s,s.size());*/ + GSave2(TheStream, Th); + return *this; + } + + PlotStream& operator<<(const Fem2D::Mesh2& Th) { + Th.GSave(TheStream); + return *this; + } + PlotStream& operator<<(const Fem2D::Mesh3& Th) { + Th.GSave(TheStream); + return *this; + } + PlotStream& operator<<(const Fem2D::MeshS& Th) { + Th.GSave(TheStream); + return *this; + } + PlotStream& operator<<(const Fem2D::MeshL& Th) { + Th.GSave(TheStream); + return *this; + } + void read(void* data, size_t l) { + char* p = (char*)data; + for (int i = 0; i < l; ++i) *p++ = (char)getc(TheStream); + // fread( p++,1,1,TheStream); + // read(data,l); + } + // FFCS:visualization stream redirection + bool good( ) const { return ffapi::ff_ferror(TheStream) == 0; } + void GetNewPlot( ) { + get(dt_newplot); + set_binary_mode( ); + } + void GetEndArgPlot( ) { get(dt_endarg); } + void GetEndPlot( ) { + get(dt_endplot); + set_text_mode( ); + } + void GetPlots( ) { get(dt_plots); } + void GetMeshes( ) { get(dt_meshes); } + // void GetMeshesS() { get(dt_meshesS);} + /* bool GetMeshes3() { long tt; read(tt); + if(tt== dt_meshes3) return true; + else if (tt== dt_plots) return false; + cout << " Error Check : get " << tt << " == wait for "<< dt_meshes3 << " or "<< dt_plots << endl; + ffassert(0); + }*/ - PlotStream & operator << (const Mesh& Th) { - /* - Serialize s=Th.serialize(); - long n=s.size(); - write( n ); - write(s,s.size());*/ - GSave2(TheStream , Th) ; - return *this;} + inline int GetMeshes3( ) { + long tt; + read(tt); - PlotStream & operator << (const Fem2D::Mesh2& Th) { Th.GSave(TheStream); return *this;} - PlotStream & operator << (const Fem2D::Mesh3& Th) { Th.GSave(TheStream); return *this;} - PlotStream & operator << (const Fem2D::MeshS& Th) { Th.GSave(TheStream); return *this;} - PlotStream & operator << (const Fem2D::MeshL& Th) { Th.GSave(TheStream); return *this;} - - void read( void *data,size_t l) { - char * p= (char*)data; - for(int i=0;i (&b),sizeof(bool)); b=r_endian(b);return *this;} - PlotStream& read( long long& b) {read(reinterpret_cast< void *> (&b),sizeof(long long)); b=r_endian(b);return *this;} - PlotStream& read( long& b) { long long l; - read(reinterpret_cast< void *> (&l),sizeof(long long)); - l=r_endian(l); - b=(long) l; - if(( b-(long) l) !=0) - { cout << " err err read long : error " << b << " != " << l << endl; - assert( (b-(long) l)==0);} - return *this;} - PlotStream& read( int& b) {read(reinterpret_cast< void *> (&b),sizeof(int)); b=r_endian(b);return *this;} - PlotStream& read( double& b) {read(reinterpret_cast< void *> (&b),sizeof(double)); b=r_endian(b);return *this;} - PlotStream &read( complex &C) { double re,im; read(re); read(im); C=complex(re,im); return - *this;} - PlotStream &read( Fem2D::R1 & P) { return read(P.x);} - PlotStream &read( Fem2D::R2 & P) { return read(P.x),read(P.y);} - PlotStream &read( Fem2D::R3 & P) { return read(P.x),read(P.y),read(P.z);} - PlotStream& read( string& b) { + cout << " Error Check : get " << tt << " == wait for " << dt_meshes3 << " or " << dt_meshesS << " or " << dt_meshesL << " or " << dt_plots << endl; + ffassert(0); + } + + void get(datatype t) { + long tt; + read(tt); + if (tt != (long)t) cout << " Error Check : get " << tt << " == wait for " << t << endl; + ffassert(tt == (long)t); + } + // FFCS:visualization stream redirection + bool eof( ) { return ffapi::ff_feof(TheStream); } + PlotStream& read(bool& b) { + read(reinterpret_cast< void* >(&b), sizeof(bool)); + b = r_endian(b); + return *this; + } + PlotStream& read(long long& b) { + read(reinterpret_cast< void* >(&b), sizeof(long long)); + b = r_endian(b); + return *this; + } + PlotStream& read(long& b) { + long long l; + read(reinterpret_cast< void* >(&l), sizeof(long long)); + l = r_endian(l); + b = (long)l; + if ((b - (long)l) != 0) { + cout << " err err read long : error " << b << " != " << l << endl; + assert((b - (long)l) == 0); + } + return *this; + } + PlotStream& read(int& b) { + read(reinterpret_cast< void* >(&b), sizeof(int)); + b = r_endian(b); + return *this; + } + PlotStream& read(double& b) { + read(reinterpret_cast< void* >(&b), sizeof(double)); + b = r_endian(b); + return *this; + } + PlotStream& read(complex< double >& C) { + double re, im; + read(re); + read(im); + C = complex< double >(re, im); + return *this; + } + PlotStream& read(Fem2D::R1& P) { return read(P.x); } + PlotStream& read(Fem2D::R2& P) { return read(P.x), read(P.y); } + PlotStream& read(Fem2D::R3& P) { return read(P.x), read(P.y), read(P.z); } + PlotStream& read(string& b) { int l; read(l); b.resize(l); - read(& (b[0]),l); + read(&(b[0]), l); return *this; } - - - - PlotStream & operator >> ( bool& b) { return read(b); } - PlotStream & operator >> ( long& b) { return read(b); } - PlotStream & operator >> ( long long& b) { return read(b); } - PlotStream & operator >> ( int& b) { return read(b); } - PlotStream & operator >> ( double& b) { return read(b); } - PlotStream & operator >> ( complex& b) { return read(b); } - PlotStream & operator >> ( string& s) { return read(s); } - PlotStream & operator >> ( string *& s) - { if(!s) s= new string(); return read(*s); + + PlotStream& operator>>(bool& b) { return read(b); } + PlotStream& operator>>(long& b) { return read(b); } + PlotStream& operator>>(long long& b) { return read(b); } + PlotStream& operator>>(int& b) { return read(b); } + PlotStream& operator>>(double& b) { return read(b); } + PlotStream& operator>>(complex< double >& b) { return read(b); } + PlotStream& operator>>(string& s) { return read(s); } + PlotStream& operator>>(string*& s) { + if (!s) s = new string( ); + return read(*s); // cout << " fread string " << s <> ( Mesh *& Th) - { + + PlotStream& operator>>(Mesh*& Th) { long n; read(n); - Serialize s(n,Mesh::magicmesh); - read(s,n ); - Th= new Mesh(s); + Serialize s(n, Mesh::magicmesh); + read(s, n); + Th = new Mesh(s); return *this; } - - - template - PlotStream & operator >> ( KN& b) - { + + template< class T > + PlotStream& operator>>(KN< T >& b) { long n; read(n); - // cout << "PlotStream >> : n " << n << endl; - // read empty array .... (n ==0) - if( ! b.N() && n) b.init(n);// if n ==0 do nothing .. Add FH nov. 2016 - ffassert( b.N()==n); - for (int i=0;i> : n " << n << endl; + // read empty array .... (n ==0) + if (!b.N( ) && n) b.init(n); // if n ==0 do nothing .. Add FH nov. 2016 + ffassert(b.N( ) == n); + for (int i = 0; i < n; ++i) read(b[i]); return *this; } - // PlotStream & operator << (const Mesh3& Th); + // PlotStream & operator << (const Mesh3& Th); // PlotStream & operator >> ( Mesh3 *& Th); - PlotStream & operator >> ( Fem2D::Mesh3 *& Th) { Th= new Fem2D::Mesh3(TheStream); return *this;} - PlotStream & operator >> ( Fem2D::Mesh2 *& Th) { Th= new Fem2D::Mesh2(TheStream); return *this;} - PlotStream & operator >> ( Fem2D::MeshS *& Th) { Th= new Fem2D::MeshS(TheStream); return *this;} - PlotStream & operator >> ( Fem2D::MeshL *& Th) { Th= new Fem2D::MeshL(TheStream); return *this;} - - // --- I also write the type .. to skip data if we need to skip data - // just change >> and << by : <= and >= - PlotStream & operator <= (const bool& b) { return write(1),write(b); } - PlotStream & operator <= (const long& b) { return write(2),write(b); } - PlotStream & operator <= (const long long & b) { return write(3),write(b); } - PlotStream & operator <= (const int& b) { return write(4),write(b); } - PlotStream & operator <= (const double& b) { return write(5),write(b); } - PlotStream & operator <= (const string& s) { return write(6),write(s); } - PlotStream & operator <= (const string* s) { return write(6),write(*s); } - template - PlotStream & operator <= (const KN_& b) { return write(10),write((int) sizeof(T)),operator<<(b);} - - PlotStream & operator >= ( bool& b) { return readc(1)>>b; } - PlotStream & operator >= ( long& b) { return readc(2)>>b; } - PlotStream & operator >= ( long long & b) {return readc(3)>>b; } - PlotStream & operator >= ( int& b) { return readc(4)>>b; } - PlotStream & operator >= ( double& b) { return readc(5)>>b; } - PlotStream & operator >= ( string& s) { return readc(6)>>s; } - PlotStream & operator >= ( string*& s) { return readc(6)>>s; } - template - PlotStream & operator >= ( KN& b) { return readc(10), readc(sizeof(T)), operator>>(b);} - PlotStream & readc(int cc) { int c; read(c); assert(c==cc); return *this;} - - void SkipData() { int c; read(c); - bool b; - int i; - long l,n; - long long ll; - string s; - double d; - char buf[100]; - switch (c) { - case 1: read(b);break; - case 2: read(l);break; - case 3: read(ll);break; - case 4: read(i);break; - case 5: read(d);break; - case 6: read(s);break; - case 10: read(l); assert(l>0 && l <100); - read(n); - for(int i=0;i>(Fem2D::Mesh3*& Th) { + Th = new Fem2D::Mesh3(TheStream); + return *this; + } + PlotStream& operator>>(Fem2D::Mesh2*& Th) { + Th = new Fem2D::Mesh2(TheStream); + return *this; + } + PlotStream& operator>>(Fem2D::MeshS*& Th) { + Th = new Fem2D::MeshS(TheStream); + return *this; + } + PlotStream& operator>>(Fem2D::MeshL*& Th) { + Th = new Fem2D::MeshL(TheStream); + return *this; + } + + // --- I also write the type .. to skip data if we need to skip data + // just change >> and << by : <= and >= + PlotStream& operator<=(const bool& b) { return write(1), write(b); } + PlotStream& operator<=(const long& b) { return write(2), write(b); } + PlotStream& operator<=(const long long& b) { return write(3), write(b); } + PlotStream& operator<=(const int& b) { return write(4), write(b); } + PlotStream& operator<=(const double& b) { return write(5), write(b); } + PlotStream& operator<=(const string& s) { return write(6), write(s); } + PlotStream& operator<=(const string* s) { return write(6), write(*s); } + template< class T > + PlotStream& operator<=(const KN_< T >& b) { + return write(10), write((int)sizeof(T)), operator<<(b); + } + + PlotStream& operator>=(bool& b) { return readc(1) >> b; } + PlotStream& operator>=(long& b) { return readc(2) >> b; } + PlotStream& operator>=(long long& b) { return readc(3) >> b; } + PlotStream& operator>=(int& b) { return readc(4) >> b; } + PlotStream& operator>=(double& b) { return readc(5) >> b; } + PlotStream& operator>=(string& s) { return readc(6) >> s; } + PlotStream& operator>=(string*& s) { return readc(6) >> s; } + template< class T > + PlotStream& operator>=(KN< T >& b) { + return readc(10), readc(sizeof(T)), operator>>(b); + } + PlotStream& readc(int cc) { + int c; + read(c); + assert(c == cc); + return *this; + } + + void SkipData( ) { + int c; + read(c); + bool b; + int i; + long l, n; + long long ll; + string s; + double d; + char buf[100]; + switch (c) { + case 1: + read(b); + break; + case 2: + read(l); + break; + case 3: + read(ll); + break; + case 4: + read(i); + break; + case 5: + read(d); + break; + case 6: + read(s); + break; + case 10: + read(l); + assert(l > 0 && l < 100); + read(n); + for (int i = 0; i < n; ++n) read(buf, l); + default: + break; + } + } }; -#endif //PLOT_STREAM_HPP +#endif // PLOT_STREAM_HPP diff --git a/src/fflib/Serialize.hpp b/src/fflib/Serialize.hpp index 8a48b733e..635ded3ca 100644 --- a/src/fflib/Serialize.hpp +++ b/src/fflib/Serialize.hpp @@ -30,71 +30,69 @@ struct MPIrank; class Serialize { // we store a refcounter in the pointer p a adress p-sizeof(long) // so we can use the copy constructor - protected: - size_t lg; - const char *what; - char *p; - public: - Serialize(size_t lgg, const char *wht): - lg(lgg), - what(wht), - p((new char[lg + sizeof(long)]()) + sizeof(long)) - { count() = 0; } - void resize(size_t lgn) { // Add nov 2010 FH of asyncrone recv MPI ... - if (lgn > lg) { - char *p0 = new char[lgn+sizeof(long)]; - memcpy(p0, p-sizeof(long), lg+sizeof(long)); - delete [](p-sizeof(long)); - p = p0+sizeof(long); - } - lg = lgn; - } - ~Serialize() { if(count()-- == 0) delete [](p-sizeof(long)); } - size_t size() const { return lg; } - - inline int havebordermesh() { - size_t pp=3*sizeof(int); - int bordermesh=0; - get( pp,bordermesh); - return bordermesh; + protected: + size_t lg; + const char *what; + char *p; + + public: + Serialize(size_t lgg, const char *wht) : lg(lgg), what(wht), p((new char[lg + sizeof(long)]( )) + sizeof(long)) { count( ) = 0; } + void resize(size_t lgn) { // Add nov 2010 FH of asyncrone recv MPI ... + if (lgn > lg) { + char *p0 = new char[lgn + sizeof(long)]; + memcpy(p0, p - sizeof(long), lg + sizeof(long)); + delete[] (p - sizeof(long)); + p = p0 + sizeof(long); } - - // mpi routine - void mpisend(const MPIrank &, long tag, const void *comm); - Serialize(const MPIrank &, const char *wht, long tag, const void *comm); - // end mpi routine - operator void *() { return p; } - operator char *() { return p; } - bool samewhat(const char *w) const { return strncmp(what, w, 8) == 0; } + lg = lgn; + } + ~Serialize( ) { + if (count( )-- == 0) delete[] (p - sizeof(long)); + } + size_t size( ) const { return lg; } - Serialize(const Serialize & s) : - lg(s.lg), - what(s.what), - p(s.p) - { count()++; } + inline int havebordermesh( ) { + size_t pp = 3 * sizeof(int); + int bordermesh = 0; + get(pp, bordermesh); + return bordermesh; + } - template inline void get(size_t &k, T &x) const { - T xx;//= r_endian(x); - assert(k <= lg+sizeof(T)); - memcpy(&xx, p + k, sizeof(T)); - k += sizeof(T); - x = r_endian(xx); - } + // mpi routine + void mpisend(const MPIrank &, long tag, const void *comm); + Serialize(const MPIrank &, const char *wht, long tag, const void *comm); + // end mpi routine + operator void *( ) { return p; } + operator char *( ) { return p; } + bool samewhat(const char *w) const { return strncmp(what, w, 8) == 0; } - template inline void put(size_t & k, const T & x) { - if (!(k <= lg+sizeof(T))) { - cout << " assert put " << k << " <=" << lg + sizeof(T) << endl; - assert((k <= lg+sizeof(T))); - } - T xx = w_endian(x); - memcpy(p + k, &xx, sizeof(T)); - k += sizeof(T); + Serialize(const Serialize &s) : lg(s.lg), what(s.what), p(s.p) { count( )++; } + + template< typename T > + inline void get(size_t &k, T &x) const { + T xx; //= r_endian(x); + assert(k <= lg + sizeof(T)); + memcpy(&xx, p + k, sizeof(T)); + k += sizeof(T); + x = r_endian(xx); + } + + template< typename T > + inline void put(size_t &k, const T &x) { + if (!(k <= lg + sizeof(T))) { + cout << " assert put " << k << " <=" << lg + sizeof(T) << endl; + assert((k <= lg + sizeof(T))); } + T xx = w_endian(x); + memcpy(p + k, &xx, sizeof(T)); + k += sizeof(T); + } + + protected: + long &count( ) const { return *(long *)(void *)(p - sizeof(long)); } - protected: - long &count() const { return *(long*)(void*)(p-sizeof(long)); } - private: - void operator = (Serialize &s); // no affectation + private: + void operator=(Serialize &s); // no affectation }; -#endif // SERIALIZE_HPP_ +#endif // SERIALIZE_HPP_ diff --git a/src/fflib/String.hpp b/src/fflib/String.hpp index a25afbc36..7ff031bdd 100644 --- a/src/fflib/String.hpp +++ b/src/fflib/String.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,11 +28,10 @@ #ifndef STRING_HPP_ #define STRING_HPP_ - #include #include -// BUG option compilation -fast +// BUG option compilation -fast /* template string * toString(const T& a) @@ -43,168 +42,181 @@ string * toString(const T& a) */ // to be sure new and delele be in see dll for windows - string *newstring(); - string *newstring(const string & c); - string *newstring(const char * c); - void freestring(const string * c); -//fh June 2016 .... Hard bug -inline string * toString(const double& a) -{ +string *newstring( ); +string *newstring(const string &c); +string *newstring(const char *c); +void freestring(const string *c); +// fh June 2016 .... Hard bug +inline string *toString(const double &a) { char buf[30]; - snprintf(buf,30,"%g",a); - return newstring(buf); + snprintf(buf, 30, "%g", a); + return newstring(buf); } -inline string * toString(const long& a) -{ +inline string *toString(const long &a) { char buf[30]; - snprintf(buf,30,"%ld",a); + snprintf(buf, 30, "%ld", a); return newstring(buf); } -inline string * toString(const bool& a) -{ - return newstring(a?"T":"F"); -} -inline string * toString(const complex & a) -{ +inline string *toString(const bool &a) { return newstring(a ? "T" : "F"); } +inline string *toString(const complex< double > &a) { char buf[60]; - snprintf(buf,30,"%g%+gi",a.real(),a.imag()); + snprintf(buf, 30, "%g%+gi", a.real( ), a.imag( )); return newstring(buf); } +inline string *toStringCconst(const char *const &a) { return newstring(a); } +inline string *toStringC(char *const &a) { return newstring(a); } -inline string * toStringCconst(const char * const &a) -{ return newstring(a); -} -inline string * toStringC( char * const &a) -{ return newstring(a); -} - -template -string * PtoString(const T * a) -{ ostringstream r; +template< class T > +string *PtoString(const T *a) { + ostringstream r; r << *a ENDS; - return newstring(r.str()); + return newstring(r.str( )); } -template -AnyType PtoStringA(void *, const AnyType &a) -{ +template< class T > +AnyType PtoStringA(void *, const AnyType &a) { ostringstream r; - r << *GetAny(a) ENDS ; - return SetAny(newstring(r.str())); + r << *GetAny< T * >(a) ENDS; + return SetAny< string * >(newstring(r.str( ))); } -template -AnyType toStringA(void *, const AnyType &a) -{ +template< class T > +AnyType toStringA(void *, const AnyType &a) { ostringstream r; - r << GetAny(a) ENDS ; - return SetAny(newstring(r.str())); + r << GetAny< T >(a) ENDS; + return SetAny< string * >(newstring(r.str( ))); } class String { - - string * p; - public: - -// String( string & pp) : p(&pp) {} - String() : p(newstring()) {/*cout << "String" << p <<","<< *p << endl;*/} - void init() { p= newstring();} // Add FH march 2010 -void destroy() { freestring(p);p=0;} // Add FH march 2010 -// String( string * c) : p(c) {cout << "String" << p <<","<< *p << endl;} - String(const String & c) : p(newstring(*c.p)) {/*cout << "String" << p <<","<< *p << endl;*/} - String(const string & c) : p(newstring(c)) {/*cout << "String" << p <<","<< *p << endl;*/} - String(const string * c) : p(newstring(*c)) {/*cout << "String" << p <<","<< *p << endl;*/} - String(const char * c) : p(newstring(c)) {/*cout << "String" << p <<","<< *p << endl;*/} - String(const long & c) : p(toString(c)){/*cout << "String" << p <<","<< *p << endl;*/} - String(const double & c) : p(toString(c)){/*cout << "String" << p <<","<< *p << endl;*/} - String(const bool & c) : p(toString(c)){/*cout << "String" << p <<","<< *p << endl;*/} - String(const long * c) : p(PtoString(c)){/*cout << "String" << p <<","<< *p << endl;*/} - String(const double * c) : p(PtoString(c)){/*cout << "String" << p <<","<< *p << endl;*/} - String & operator=(const String & s){ freestring(p);p=newstring(s);return *this;} - String operator+(const String & s)const {return String(newstring(*p+*s.p));} - ~String(){ if(verbosity>999999) cout << "~String" << p <<" "<< *p << "." << endl; freestring(p); p=0;} - operator const string & () const {return *p;} - operator string & () {return *p;} - operator const string * () const {return p;} - operator string *& () {return p;} - - string ** getap() {return &p;} - friend inline ostream & operator<<(ostream & f,const String & s) {throwassert(s.p); f << *s.p ; return f;} - bool operator<(const String &t) const {assert(p && t.p);return *p<*t.p;} // correction FH feb 2004 - bool operator>(const String &t) const {assert(p && t.p);return *p>*t.p;} // correction FH feb 2004 -}; + string *p; + + public: + // String( string & pp) : p(&pp) {} + String( ) : p(newstring( )) { /*cout << "String" << p <<","<< *p << endl;*/ } + void init( ) { p = newstring( ); } // Add FH march 2010 + void destroy( ) { + freestring(p); + p = 0; + } // Add FH march 2010 + // String( string * c) : p(c) {cout << "String" << p <<","<< *p << endl;} + String(const String &c) : p(newstring(*c.p)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const string &c) : p(newstring(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const string *c) : p(newstring(*c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const char *c) : p(newstring(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const long &c) : p(toString(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const double &c) : p(toString(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const bool &c) : p(toString(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const long *c) : p(PtoString(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String(const double *c) : p(PtoString(c)) { /*cout << "String" << p <<","<< *p << endl;*/ } + String &operator=(const String &s) { + freestring(p); + p = newstring(s); + return *this; + } + String operator+(const String &s) const { return String(newstring(*p + *s.p)); } + ~String( ) { + if (verbosity > 999999) cout << "~String" << p << " " << *p << "." << endl; + freestring(p); + p = 0; + } + operator const string &( ) const { return *p; } + operator string &( ) { return *p; } + operator const string *( ) const { return p; } + operator string *&( ) { return p; } + + string **getap( ) { return &p; } + friend inline ostream &operator<<(ostream &f, const String &s) { + throwassert(s.p); + f << *s.p; + return f; + } + bool operator<(const String &t) const { + assert(p && t.p); + return *p < *t.p; + } // correction FH feb 2004 + bool operator>(const String &t) const { + assert(p && t.p); + return *p > *t.p; + } // correction FH feb 2004 +}; -template +template< class K, class V > class MyMap { - public: - typedef V Value; - typedef K Key; - typedef map MAP; - typedef typename map::iterator iterator; - map *m; - - MyMap() : m(new map) {/*cout << "new MyMap:: " << m << endl;*/} - MyMap &operator=(MyMap &M){ - // cout << " MyMap::= " << m << " = " << M.m << endl; - delete m;m=new map(M); - } - bool exist(const K & k) const { return m&& (m->find(k)!= m->end());} - bool insert(const K & k,const V & v) - { - typedef typename map::value_type value_type; - return m->insert(value_type(k,v)).second; - } - bool insert(const K & k, V * const v) - { - typedef typename map::value_type value_type; - return m->insert(value_type(k,*v)).second; - } - - V &operator[](const K & k) { - throwassert(m); - typename map::iterator i=m->find(k); -// cout << k << " " << " end? " << (i==m->end()) << endl; -// for( map::iterator ii=m->begin(); ii != m->end();ii++) - // cout << " MyMap :: m="<< m << ": " << ii->first << " -> " << ii->second <::iterator j=m->find(k); - - // cout << " m->find(k)->second " << i->second << ";" << j->second <::value_type value_type; - if (i==m->end()) - i=m->insert(value_type(k,V())).first; - V & v= i->second ; - return v; -} - ~MyMap(){if(verbosity>99999)cout << " ~MyMap:: delete "<< m << endl; delete m;m=0;} - void destroy(){if(verbosity>99999) cout << " MyMap:: destroy "<< m << endl;delete m;m=0;} - void init() { m=new MAP; if(verbosity>99999) cout << " MyMap:: int "<< m << endl; } - private: - MyMap(const MyMap &M):m(new map(*M.m)) {} -public: - friend inline ostream & operator<<(ostream & f,const MyMap & s) - { - if(s.m) - for(MyMap::iterator i=s.m->begin(); i!= s.m->end(); ++i) - f << i->first << " " << i->second << endl; - return f;} - - + public: + typedef V Value; + typedef K Key; + typedef map< K, V > MAP; + typedef typename map< K, V >::iterator iterator; + map< K, V > *m; + + MyMap( ) : m(new map< K, V >) { /*cout << "new MyMap:: " << m << endl;*/ } + MyMap &operator=(MyMap &M) { + // cout << " MyMap::= " << m << " = " << M.m << endl; + delete m; + m = new map< K, V >(M); + } + bool exist(const K &k) const { return m && (m->find(k) != m->end( )); } + bool insert(const K &k, const V &v) { + typedef typename map< K, V >::value_type value_type; + return m->insert(value_type(k, v)).second; + } + bool insert(const K &k, V *const v) { + typedef typename map< K, V >::value_type value_type; + return m->insert(value_type(k, *v)).second; + } + + V &operator[](const K &k) { + throwassert(m); + typename map< K, V >::iterator i = m->find(k); + // cout << k << " " << " end? " << (i==m->end()) << endl; + // for( map::iterator ii=m->begin(); ii != m->end();ii++) + // cout << " MyMap :: m="<< m << ": " << ii->first << " -> " << ii->second <::iterator j=m->find(k); + + // cout << " m->find(k)->second " << i->second << ";" << j->second <::value_type value_type; + if (i == m->end( )) i = m->insert(value_type(k, V( ))).first; + V &v = i->second; + return v; + } + ~MyMap( ) { + if (verbosity > 99999) cout << " ~MyMap:: delete " << m << endl; + delete m; + m = 0; + } + void destroy( ) { + if (verbosity > 99999) cout << " MyMap:: destroy " << m << endl; + delete m; + m = 0; + } + void init( ) { + m = new MAP; + if (verbosity > 99999) cout << " MyMap:: int " << m << endl; + } + + private: + MyMap(const MyMap &M) : m(new map< K, V >(*M.m)) {} + + public: + friend inline ostream &operator<<(ostream &f, const MyMap &s) { + if (s.m) + for (MyMap::iterator i = s.m->begin( ); i != s.m->end( ); ++i) f << i->first << " " << i->second << endl; + return f; + } }; -template -struct pairless - { - using first_argument_type = pair; - using second_argument_type = const char *; - using result_type = bool; - typedef pair Key; - bool operator()(const Key& x, const Key& y) const { return x.first,aType,pairless > Map_type_of_map; - -extern Map_type_of_map map_type_of_map ; // to store te type -// of a map of A[B] +template< class A, class B > +struct pairless { + using first_argument_type = pair< A, B >; + using second_argument_type = const char *; + using result_type = bool; + typedef pair< A, B > Key; + bool operator( )(const Key &x, const Key &y) const { return x.first < y.first ? true : ((x.first == y.first) ? (x.second < y.second) : false); } +}; + +typedef map< pair< aType, aType >, aType, pairless< aType, aType > > Map_type_of_map; +extern Map_type_of_map map_type_of_map; // to store te type +// of a map of A[B] #endif diff --git a/src/fflib/UMFPack_Solver.cpp b/src/fflib/UMFPack_Solver.cpp index d72833f84..f9d19f9d7 100644 --- a/src/fflib/UMFPack_Solver.cpp +++ b/src/fflib/UMFPack_Solver.cpp @@ -1,6 +1,6 @@ // file to add UMFPACK solver with dynamic load. -#include +#include using namespace std; #include "rgraph.hpp" @@ -14,24 +14,22 @@ using namespace std; #ifdef HAVE_LIBUMFPACK -void init_UMFPack_solver() { - setptrstring(def_solver,"UMFPACK"); - setptrstring(def_solver_sym,"CHOLMOD"); - setptrstring(def_solver_sym_dp,"CHOLMOD"); - Global.New("HaveUMFPACK",CConstant(true)); - } - +void init_UMFPack_solver( ) { + setptrstring(def_solver, "UMFPACK"); + setptrstring(def_solver_sym, "CHOLMOD"); + setptrstring(def_solver_sym_dp, "CHOLMOD"); + Global.New("HaveUMFPACK", CConstant< bool >(true)); +} + #else -void init_UMFPack_solver() { - setptrstring(def_solver,"LU"); - setptrstring(def_solver_sym,"CROUT"); - setptrstring(def_solver_sym_dp,"CHOLESKY"); - - if(verbosity&& (mpirank==0)) - cout << " no UMFPACK -> replace by LU or GMRES "; - - Global.New("HaveUMFPACK",CConstant(false)); +void init_UMFPack_solver( ) { + setptrstring(def_solver, "LU"); + setptrstring(def_solver_sym, "CROUT"); + setptrstring(def_solver_sym_dp, "CHOLESKY"); + + if (verbosity && (mpirank == 0)) cout << " no UMFPACK -> replace by LU or GMRES "; + + Global.New("HaveUMFPACK", CConstant< bool >(false)); } #endif - diff --git a/src/fflib/array_complex.cpp b/src/fflib/array_complex.cpp index 0b65ffd7f..a6566d63a 100644 --- a/src/fflib/array_complex.cpp +++ b/src/fflib/array_complex.cpp @@ -39,11 +39,11 @@ * \param vc Complex array, size n * \return Real or Imaginary part of the complex array, depending on offset (0: real, 1: imaginary) */ -template -KN_ Get_C2R_(KN_ > vc) { - complex * pc = vc; // table pointer - double *pr = static_cast(static_cast(pc)); - return KN_(pr+offset, vc.N(), vc.step*2); +template< int offset > +KN_< double > Get_C2R_(KN_< complex< double > > vc) { + complex< double > *pc = vc; // table pointer + double *pr = static_cast< double * >(static_cast< void * >(pc)); + return KN_< double >(pr + offset, vc.N( ), vc.step * 2); } /*! @@ -51,63 +51,59 @@ KN_ Get_C2R_(KN_ > vc) { * \param vc Complex array, size n*m * \return Real or Imaginary part of the complex array, depending on offset (0: real, 1: imaginary) */ -template -KNM_ Get_C2R_(KNM_ > vc) { - complex * pc = vc; // table pointer - double *pr = static_cast(static_cast(pc)); - return KNM_(pr+offset, ShapeOfArray(vc.N(), vc.step*2), vc.shapei, vc.shapej); +template< int offset > +KNM_< double > Get_C2R_(KNM_< complex< double > > vc) { + complex< double > *pc = vc; // table pointer + double *pr = static_cast< double * >(static_cast< void * >(pc)); + return KNM_< double >(pr + offset, ShapeOfArray(vc.N( ), vc.step * 2), vc.shapei, vc.shapej); } /*! * \brief Initialization */ -KN_ rmeps(KN_rmeps p,double eps) -{ - for(int i=0;i(); +KN_< Complex > rmeps(KN_rmeps< Complex > p, double eps) { + for (int i = 0; i < p.v.N( ); ++i) { + int c = 0; + double a = p.v[i].real( ), b = p.v[i].imag( ); + if (abs(a) < eps) c = 1, a = 0.; + if (abs(b) < eps) c = 1, b = 0.; + if (c) p.v[i] = Complex(a, b); + } + return p.v; +} // +void initArrayDCLComplex( ) { ArrayDCL< Complex >( ); } -} - -Complex square(const Complex &x){ return x*x; } +Complex square(const Complex &x) { return x * x; } // double imagc(const Complex &x){ return imag(x); } // Commented out in interface // double realc(const Complex &x){ return realc(x); } -void initArrayOperatorComplex() { +void initArrayOperatorComplex( ) { typedef Complex K; - typedef const K & KK; - Dcl_Type< KN_rmeps > (); + typedef const K &KK; + Dcl_Type< KN_rmeps< K > >( ); typedef double R; - typedef const R & RR; - ArrayOperator(); - ArrayOperatorF(); - Add *>("rmeps",".",new OneOperator1,KN_ >(build_rmeps)); - Add >("(","",new OneOperator2,KN_rmeps,double>(rmeps)); + typedef const R &RR; + ArrayOperator< Complex, long >( ); + ArrayOperatorF< Complex, const Complex & >( ); + Add< KN< K > * >("rmeps", ".", new OneOperator1< KN_rmeps< K >, KN_< K > >(build_rmeps)); + Add< KN_rmeps< K > >("(", "", new OneOperator2< KN_< K >, KN_rmeps< K >, double >(rmeps)); // Take the real or imaginary part of a complex array - Add *>("im", ".", new OneOperator1, KN_ >(Get_C2R_<1>, atype* >())); - Add >("im", ".", new OneOperator1, KN_ >(Get_C2R_<1>, atype >())); - Add *>("re", ".", new OneOperator1, KN_ >(Get_C2R_<0>, atype* >())); - Add >("re", ".", new OneOperator1, KN_ >(Get_C2R_<0>, atype >())); + Add< KN< Complex > * >("im", ".", new OneOperator1< KN_< double >, KN_< Complex > >(Get_C2R_< 1 >, atype< KN< Complex > * >( ))); + Add< KN_< Complex > >("im", ".", new OneOperator1< KN_< double >, KN_< Complex > >(Get_C2R_< 1 >, atype< KN_< Complex > >( ))); + Add< KN< Complex > * >("re", ".", new OneOperator1< KN_< double >, KN_< Complex > >(Get_C2R_< 0 >, atype< KN< Complex > * >( ))); + Add< KN_< Complex > >("re", ".", new OneOperator1< KN_< double >, KN_< Complex > >(Get_C2R_< 0 >, atype< KN_< Complex > >( ))); - Add *>("im", ".", new OneOperator1, KNM_ >(Get_C2R_<1>, atype* >())); - Add >("im", ".", new OneOperator1, KNM_ >(Get_C2R_<1>, atype >())); - Add *>("re", ".", new OneOperator1, KNM_ >(Get_C2R_<0>, atype* >())); - Add >("re", ".", new OneOperator1, KNM_ >(Get_C2R_<0>, atype >())); + Add< KNM< Complex > * >("im", ".", new OneOperator1< KNM_< double >, KNM_< Complex > >(Get_C2R_< 1 >, atype< KNM< Complex > * >( ))); + Add< KNM_< Complex > >("im", ".", new OneOperator1< KNM_< double >, KNM_< Complex > >(Get_C2R_< 1 >, atype< KNM_< Complex > >( ))); + Add< KNM< Complex > * >("re", ".", new OneOperator1< KNM_< double >, KNM_< Complex > >(Get_C2R_< 0 >, atype< KNM< Complex > * >( ))); + Add< KNM_< Complex > >("re", ".", new OneOperator1< KNM_< double >, KNM_< Complex > >(Get_C2R_< 0 >, atype< KNM_< Complex > >( ))); - Global.Add("square", "(", new OneOperator1F_KN_, K, KK, KN_ >(square)); - Global.Add("conj", "(", new OneOperator1F_KN_,K, KK, KN_ >(conj)); + Global.Add("square", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(square)); + Global.Add("conj", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(conj)); // Global.Add("imag", "(", new OneOperator1F_KN_, R, KK, KN_ >(imagc)); // Add >("<--", "(", new OneOperator1F_KN_, R, KK, KN_ >(realc)); - map_type[typeid(SetArray).name()]->AddCast( - new E_F1_funcT, SetArray >(Cast, SetArray >), - new E_F1_funcT, SetArray >(Cast, SetArray >) - ); - Global.Add("toCarray", "(", new OneOperator_2KN_); + map_type[typeid(SetArray< K >).name( )]->AddCast(new E_F1_funcT< SetArray< K >, SetArray< long > >(Cast< SetArray< K >, SetArray< long > >), + new E_F1_funcT< SetArray< K >, SetArray< double > >(Cast< SetArray< K >, SetArray< double > >)); + Global.Add("toCarray", "(", new OneOperator_2KN_< Complex >); } diff --git a/src/fflib/array_init.hpp b/src/fflib/array_init.hpp index 62822a97b..a9cb62d1f 100644 --- a/src/fflib/array_init.hpp +++ b/src/fflib/array_init.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,15 +29,15 @@ #ifndef ARRAY_INIT_HPP #define ARRAY_INIT_HPP -void initArrayDCLComplex(); -void initArrayOperatorComplex(); +void initArrayDCLComplex( ); +void initArrayOperatorComplex( ); // -void initArrayDCLdouble(); -void initArrayOperatordouble(); +void initArrayDCLdouble( ); +void initArrayOperatordouble( ); // -void initArrayDCLlong(); -void initArrayOperatorlong(); +void initArrayDCLlong( ); +void initArrayOperatorlong( ); // -void initStringOperator(); +void initStringOperator( ); -#endif // _ARRAY_INIT_HPP +#endif // _ARRAY_INIT_HPP diff --git a/src/fflib/array_long.cpp b/src/fflib/array_long.cpp index c4269db77..c78352613 100644 --- a/src/fflib/array_long.cpp +++ b/src/fflib/array_long.cpp @@ -39,182 +39,173 @@ void initArrayDCL() { */ aType aaaa_knlp; -void initArrayDCLlong() { +void initArrayDCLlong( ) { // ArrayOperator(); - Dcl_Type(); // Add FH mars 2005 - ArrayDCL(); - aaaa_knlp = atype*>(); + Dcl_Type< Inv_KN_long >( ); // Add FH mars 2005 + ArrayDCL< long >( ); + aaaa_knlp = atype< KN< long > * >( ); } class OneBinaryOperatorInv_KN_long : public OneOperator { - public: - OneBinaryOperatorInv_KN_long(basicForEachType * ti) : OneOperator(atype(), ti ,atype()) {} - E_F0 * code(const basicAC_F0 & args) const { - Expression p=args[1]; - if (!p->EvaluableWithOutStack()) { - bool bb = p->EvaluableWithOutStack(); - cout << bb << " " << *p << endl; - CompileError("Inverse: int[int] I, array, with I^p, The p must be a constant == -1, sorry"); - } - long pv = GetAny((*p)(NullStack)); - if (pv !=-1) { - char buf[100]; - snprintf(buf,100, "Inverse: int[int] I, array, I^%ld, The pow must be == -1, sorry", pv); - CompileError(buf); - } - return new E_F_F0 >(Build >, to< KN_ >(args[0])); + public: + OneBinaryOperatorInv_KN_long(basicForEachType *ti) : OneOperator(atype< Inv_KN_long >( ), ti, atype< long >( )) {} + E_F0 *code(const basicAC_F0 &args) const { + Expression p = args[1]; + if (!p->EvaluableWithOutStack( )) { + bool bb = p->EvaluableWithOutStack( ); + cout << bb << " " << *p << endl; + CompileError("Inverse: int[int] I, array, with I^p, The p must be a constant == -1, sorry"); + } + long pv = GetAny< long >((*p)(NullStack)); + if (pv != -1) { + char buf[100]; + snprintf(buf, 100, "Inverse: int[int] I, array, I^%ld, The pow must be == -1, sorry", pv); + CompileError(buf); } + return new E_F_F0< Inv_KN_long, KN_< long > >(Build< Inv_KN_long, KN_< long > >, to< KN_< long > >(args[0])); + } }; // Add mars 2010 -template R *set_init_init( R* const & a,const long & n) { - SHOWVERB(cout << " set_init " << typeid(R).name() << " " << n << endl); +template< class R > +R *set_init_init(R *const &a, const long &n) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << n << endl); a->init(n); - for (int i = 0; i < n; i++) - (*a)[i].init(); + for (int i = 0; i < n; i++) (*a)[i].init( ); return a; } -inline string **get_elements(KN *const &a, long const &b) { - ffassert(a && b >=0 && b < a->size()); - String &Sret = (*a)[b]; // correction FH feb 2004 +inline string **get_elements(KN< String > *const &a, long const &b) { + ffassert(a && b >= 0 && b < a->size( )); + String &Sret = (*a)[b]; // correction FH feb 2004 // delete b; la chaine est detruire automatiquement en fin d'instruction FH jan 2010 - return Sret.getap(); + return Sret.getap( ); } -template inline AnyType Destroy_KN(Stack,const AnyType &x) { - KN *a = GetAny*>(x); - for (int i = 0; i N(); i++) - (a)[i].destroy(); - a->destroy(); +template< class A > +inline AnyType Destroy_KN(Stack, const AnyType &x) { + KN< A > *a = GetAny< KN< A > * >(x); + for (int i = 0; i < a->N( ); i++) (a)[i].destroy( ); + a->destroy( ); return Nothing; } // end add -template +template< class A, class B > struct set_Inv_KN_long { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(const A & a, B const & b) { - int n = a.N(); - KN_ I(b.t); - for (int i = 0; i < I.N(); ++i) { + using result_type = A; + static A f(const A &a, B const &b) { + int n = a.N( ); + KN_< long > I(b.t); + for (int i = 0; i < I.N( ); ++i) { int j = I[i]; - if (j >= 0 && j < n) - a[j] = i; + if (j >= 0 && j < n) a[j] = i; } return a; } }; -template +template< class A, class B > struct set_Inv_pKN_longI { - using first_argument_type = A; + using first_argument_type = A; using second_argument_type = B; - using result_type = A; - static A f(const A & a, B const & b) { - KN_ I(b.t); - int n = I.max() + 1; + using result_type = A; + static A f(const A &a, B const &b) { + KN_< long > I(b.t); + int n = I.max( ) + 1; a->init(n); (*a) = -1; - for (int i = 0; i < I.N(); ++i) { + for (int i = 0; i < I.N( ); ++i) { int j = I[i]; - if (j >= 0 && j < n) - (*a)[j] = i; + if (j >= 0 && j < n) (*a)[j] = i; } return a; } }; -long findall(const KN_ & a, const long &v, KN * const & pI) -{ - long nn=0,k=0;; - KN & I=*pI; - for(long i=0; i9) - cout << "findall: nn = " << nn << I << endl; - return nn; +long findall(const KN_< long > &a, const long &v, KN< long > *const &pI) { + long nn = 0, k = 0; + ; + KN< long > &I = *pI; + for (long i = 0; i < a.N( ); ++i) + if (a[i] == v) nn++; + I.resize(nn); + for (long i = 0; i < a.N( ); ++i) + if (a[i] == v) I[k++] = i; + if (verbosity > 9) cout << "findall: nn = " << nn << I << endl; + return nn; } - - -void initArrayOperatorlong() -{ +void initArrayOperatorlong( ) { typedef long K; - Dcl_Type< Eye > ();// OK this is the fist array def .. - Global.Add("eye","(",new OneOperator1(fEye)); - Global.Add("eye","(",new OneOperator2(fEye)); - Global.Add("findall", "(", new OneOperator3_< long, KN_, long ,KN*>(findall));// oct 2020 FH. + Dcl_Type< Eye >( ); // OK this is the fist array def .. + Global.Add("eye", "(", new OneOperator1< Eye, long >(fEye)); + Global.Add("eye", "(", new OneOperator2< Eye, long >(fEye)); + Global.Add("findall", "(", new OneOperator3_< long, KN_< long >, long, KN< long > * >(findall)); // oct 2020 FH. - ArrayOperator(); + ArrayOperator< long, long >( ); // to define inverse permutation // Add FH mars 2005 - TheOperators->Add("^", new OneBinaryOperatorInv_KN_long(atype >())); + TheOperators->Add("^", new OneBinaryOperatorInv_KN_long(atype< KN_< long > >( ))); //- TheOperators->Add("^", new OneBinaryOperatorInv_KN_long(atype *>())); - aatypeknlongp = atype*>(); // for compilation error with g++ 3.2.2 + aatypeknlongp = atype< KN< long > * >( ); // for compilation error with g++ 3.2.2 - Add >("sort", ".", new OneOperator1_, KN_ >(SortKn >)); + Add< KN_< long > >("sort", ".", new OneOperator1_< KN_< K >, KN_< K > >(SortKn< K, KN_< K > >)); // Add >("sort", ".", new OneOperator1_,KN >(SortKn >)); - Add *>("sort", ".", new OneOperator1_*, KN* >(SortpKn)); - Global.Add("sort", "(", new OneOperator2_*, KN*, KN* >(SortpKn2)); + Add< KN< long > * >("sort", ".", new OneOperator1_< KN< K > *, KN< K > * >(SortpKn< K >)); + Global.Add("sort", "(", new OneOperator2_< KN< K > *, KN< K > *, KN< long > * >(SortpKn2< K, long >)); // ArrayDCL(); - Dcl_TypeandPtr_, KN *>(0, 0, 0, ::Destroy >, ::ClearReturnKK_, KN_ >, ::ClearReturnpKK >); - map_type[typeid(KN_).name()]->AddCast( - new E_F1_funcT,KN*>(UnRefpKN,KN_ > ) ); - - atype* >()->Add("[", "", new OneOperator2_*, long >(get_elements)); - TheOperators->Add("<-", new OneOperator2_ *, KN *, long>(&set_init_init), new InitArrayfromArray*, true>); - TheOperators->Add("<-", new OneBinaryOperator ,KN_ > > );//, - // new OneOperator2_ *,KN *,KN *>(&set_initp)); // Add FH nov 2023 - TheOperators->Add("=", new OneBinaryOperator ,KN_ > > ); //, - // new OneBinaryOperator ,KN* > > ); // Add FH nov 2023 - - map_type_of_map[make_pair(atype(), atype())] = atype*>(); // vector [string] - Add *>("n", ".", new OneOperator1 *>(get_n)); - Add >("n", ".", new OneOperator1 >(get__n)); - extern KN *pkarg; - Global.New("ARGV", CPValue >(*pkarg));// add FH mars 2010 - Global.Add("toZarray", "(", new OneOperator_2KN_); - Global.Add("toSarray", "(", new OneOperator_2KN_); - TheOperators->Add("=", new OneBinaryOperator, Inv_KN_long> >); - TheOperators->Add("<-", new OneBinaryOperator*, Inv_KN_long> >); - - Add *>("imin", ".", new OneOperator1 *>(get_imin)); - Add *>("imax", ".", new OneOperator1 *>(get_imax)); - Add *>("imin", ".", new OneOperator1 *>(get_imin)); // Add april 2018 FH - Add *>("imax", ".", new OneOperator1 *>(get_imax)); // Add april 2018 FH - Add *>("jmin", ".", new OneOperator1 *>(get_jmin)); // Add april 2018 FH - Add *>("jmax", ".", new OneOperator1 *>(get_jmax)); // Add april 2018 FH - TheOperators->Add("ijmax", new OneOperator3_ *, long*, long*>(get_ijmax)); // Add april 2018 FH - TheOperators->Add("ijmin", new OneOperator3_ *, long*, long*>(get_ijmin)); // Add april 2018 FH + Dcl_TypeandPtr_< KN_< String >, KN< String > * >(0, 0, 0, ::Destroy< KN< String > >, ::ClearReturnKK_< K, KN< String >, KN_< String > >, ::ClearReturnpKK< String, KN< String > >); + map_type[typeid(KN_< String >).name( )]->AddCast(new E_F1_funcT< KN_< String >, KN< String > * >(UnRefpKN< KN< String >, KN_< String > >)); + + atype< KN< String > * >( )->Add("[", "", new OneOperator2_< string **, KN< String > *, long >(get_elements)); + TheOperators->Add("<-", new OneOperator2_< KN< String > *, KN< String > *, long >(&set_init_init), new InitArrayfromArray< string *, KN< String > *, true >); + TheOperators->Add("<-", new OneBinaryOperator< init_eqarray< KN< String >, KN_< String > > >); //, + // new OneOperator2_ *,KN *,KN *>(&set_initp)); // Add FH nov 2023 + TheOperators->Add("=", new OneBinaryOperator< set_eqarray< KN< String >, KN_< String > > >); //, + // new OneBinaryOperator ,KN* > > ); // Add FH nov 2023 + + map_type_of_map[make_pair(atype< long >( ), atype< string * >( ))] = atype< KN< String > * >( ); // vector [string] + Add< KN< String > * >("n", ".", new OneOperator1< long, KN< String > * >(get_n)); + Add< KN_< String > >("n", ".", new OneOperator1< long, KN_< String > >(get__n)); + extern KN< String > *pkarg; + Global.New("ARGV", CPValue< KN< String > >(*pkarg)); // add FH mars 2010 + Global.Add("toZarray", "(", new OneOperator_2KN_< long >); + Global.Add("toSarray", "(", new OneOperator_2KN_< String, string * >); + TheOperators->Add("=", new OneBinaryOperator< set_Inv_KN_long< KN_< long >, Inv_KN_long > >); + TheOperators->Add("<-", new OneBinaryOperator< set_Inv_pKN_longI< KN< long > *, Inv_KN_long > >); + + Add< KN< K > * >("imin", ".", new OneOperator1< long, KN< K > * >(get_imin)); + Add< KN< K > * >("imax", ".", new OneOperator1< long, KN< K > * >(get_imax)); + Add< KNM< K > * >("imin", ".", new OneOperator1< long, KNM< K > * >(get_imin)); // Add april 2018 FH + Add< KNM< K > * >("imax", ".", new OneOperator1< long, KNM< K > * >(get_imax)); // Add april 2018 FH + Add< KNM< K > * >("jmin", ".", new OneOperator1< long, KNM< K > * >(get_jmin)); // Add april 2018 FH + Add< KNM< K > * >("jmax", ".", new OneOperator1< long, KNM< K > * >(get_jmax)); // Add april 2018 FH + TheOperators->Add("ijmax", new OneOperator3_< NothingType, KNM< K > *, long *, long * >(get_ijmax)); // Add april 2018 FH + TheOperators->Add("ijmin", new OneOperator3_< NothingType, KNM< K > *, long *, long * >(get_ijmin)); // Add april 2018 FH // madd FH. march 2015 ... - Global.Add("Unique", "(", new Unique); - Global.Add("Unique", "(", new Unique); + Global.Add("Unique", "(", new Unique< K, K >); + Global.Add("Unique", "(", new Unique< K, double >); // convertion double -> long (via lround) - Dcl_Type >(); - Global.Add("lround", "(", new OneOperator1F_KN_, K, double, KN_ >(lround)); - TheOperators->Add("=", new OneBinaryOperator, F_KN_ > >); // add FH juin 2005 - TheOperators->Add("+=", new OneBinaryOperator, F_KN_ > >); // add FH juin 2005 - TheOperators->Add("-=", new OneBinaryOperator, F_KN_ > >); // add FH juin 2005 - TheOperators->Add("/=", new OneBinaryOperator, F_KN_ > >); // add FH juin 2005 - TheOperators->Add("*=", new OneBinaryOperator, F_KN_ > >); // add FH juin 2005 - - TheOperators->Add("<-", new InitMapfromArray*, string *, string*, true> ); - - TheOperators->Add("<<", new OneBinaryOperator * > >(50)); // add may 2018 FH, coor - TheOperators->Add("<<", new OneBinaryOperator > >); // add now 2023 FH and change priorite to remove ambiguity - - // sep 2023 FH for G. Sadaka . - Dcl_Type< Resize > > (); - Add *>("resize",".",new OneOperator1< Resize >,KN *>(to_Resize)); - Add > >("(","",new OneOperator2_ *,Resize > , long >(resize1)); - - + Dcl_Type< F_KN_< K, K, double > >( ); + Global.Add("lround", "(", new OneOperator1F_KN_< F_KN_< K, K, double >, K, double, KN_< double > >(lround)); + TheOperators->Add("=", new OneBinaryOperator< set_eq_array< KN_< K >, F_KN_< K, K, double > > >); // add FH juin 2005 + TheOperators->Add("+=", new OneBinaryOperator< set_eq_array_add< KN_< K >, F_KN_< K, K, double > > >); // add FH juin 2005 + TheOperators->Add("-=", new OneBinaryOperator< set_eq_array_sub< KN_< K >, F_KN_< K, K, double > > >); // add FH juin 2005 + TheOperators->Add("/=", new OneBinaryOperator< set_eq_array_div< KN_< K >, F_KN_< K, K, double > > >); // add FH juin 2005 + TheOperators->Add("*=", new OneBinaryOperator< set_eq_array_mul< KN_< K >, F_KN_< K, K, double > > >); // add FH juin 2005 + + TheOperators->Add("<-", new InitMapfromArray< MyMap< String, String > *, string *, string *, true >); + + TheOperators->Add("<<", new OneBinaryOperator< PrintPnd< KN< String > * > >(50)); // add may 2018 FH, coor + TheOperators->Add("<<", new OneBinaryOperator< PrintPn< KN_< String > > >); // add now 2023 FH and change priorite to remove ambiguity + + // sep 2023 FH for G. Sadaka . + Dcl_Type< Resize< KN< String > > >( ); + Add< KN< String > * >("resize", ".", new OneOperator1< Resize< KN< String > >, KN< String > * >(to_Resize)); + Add< Resize< KN< String > > >("(", "", new OneOperator2_< KN< String > *, Resize< KN< String > >, long >(resize1)); } // void xxxx() { diff --git a/src/fflib/array_real.cpp b/src/fflib/array_real.cpp index 467db9c45..cff8d3465 100644 --- a/src/fflib/array_real.cpp +++ b/src/fflib/array_real.cpp @@ -23,70 +23,66 @@ #include "array_tlp.hpp" #include "array_init.hpp" -double square(double x) { return x*x; } +double square(double x) { return x * x; } -void initArrayDCLdouble() { +void initArrayDCLdouble( ) { // ArrayOperator(); - ArrayDCL(); + ArrayDCL< double >( ); } - KN_ rmeps(KN_rmeps p,double eps){ - for(int i=0;i A Build(B b) { return A(b); } +KN_< double > rmeps(KN_rmeps< double > p, double eps) { + for (int i = 0; i < p.v.N( ); ++i) + if (abs(p.v[i]) < eps) p.v[i] = 0; + return p.v; +} // +// template A Build(B b) { return A(b); } - -void initArrayOperatordouble() { - Dcl_Type< KN_rmeps > (); - ArrayOperator(); - ArrayOperatorF(); +void initArrayOperatordouble( ) { + Dcl_Type< KN_rmeps< double > >( ); + ArrayOperator< double, long >( ); + ArrayOperatorF< double, double >( ); typedef double K; typedef double KK; - Dcl_Type >(); - Add *>("rmeps",".",new OneOperator1,KN_ >(build_rmeps)); - Add >("(","",new OneOperator2,KN_rmeps,double>(rmeps)); - Global.Add("fabs", "(", new OneOperator1F_KN_, K, KK, KN_ >(fabs)); - Global.Add("abs", "(", new OneOperator1F_KN_, K, KK, KN_ >(fabs)); - Global.Add("cbrt","(",new OneOperator1F_KN_,K,KK,KN_ >(cbrt)); - Global.Add("acos", "(", new OneOperator1F_KN_, K, KK, KN_ >(acos)); - Global.Add("asin", "(", new OneOperator1F_KN_, K, KK, KN_ >(asin)); - Global.Add("atan", "(", new OneOperator1F_KN_,K, KK, KN_ >(atan)); - Global.Add("floor", "(", new OneOperator1F_KN_,K, KK, KN_ >(floor)); - Global.Add("ceil", "(", new OneOperator1F_KN_,K, KK, KN_ >(ceil)); + Dcl_Type< QuantileKN< K > >( ); + Add< KN< K > * >("rmeps", ".", new OneOperator1< KN_rmeps< K >, KN_< K > >(build_rmeps)); + Add< KN_rmeps< K > >("(", "", new OneOperator2< KN_< K >, KN_rmeps< K >, double >(rmeps)); + Global.Add("fabs", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(fabs)); + Global.Add("abs", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(fabs)); + Global.Add("cbrt", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(cbrt)); + Global.Add("acos", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(acos)); + Global.Add("asin", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(asin)); + Global.Add("atan", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(atan)); + Global.Add("floor", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(floor)); + Global.Add("ceil", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(ceil)); - Global.Add("square", "(", new OneOperator1F_KN_, K, KK, KN_ >(square)); - Add >("sort", ".", new OneOperator1_, KN_ >(SortKn >)); + Global.Add("square", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(square)); + Add< KN_< double > >("sort", ".", new OneOperator1_< KN_< K >, KN_< K > >(SortKn< K, KN_< K > >)); // Add >("sort", ".", new OneOperator1_, KN >(SortKn >)); - Add *>("sort", ".", new OneOperator1_*, KN* >(SortpKn)); + Add< KN< double > * >("sort", ".", new OneOperator1_< KN< K > *, KN< K > * >(SortpKn< K >)); // Add >("sort", ".", new OneOperator2_, KN_, KN_ >(SortKn, KN_ >)); // Add >("sort", ".", new OneOperator2_, KN, KN_ >(SortKn, KN_ >)); - Global.Add("sort", "(", new OneOperator2_*, KN*, KN* >(SortpKn2)); + Global.Add("sort", "(", new OneOperator2_< KN< K > *, KN< K > *, KN< long > * >(SortpKn2< K, long >)); - Add >("quantile", ".", new OneOperator1, KN_ >(Build, KN_ >)); + Add< KN_< double > >("quantile", ".", new OneOperator1< QuantileKN< K >, KN_< K > >(Build< QuantileKN< K >, KN_< K > >)); // Add >("quantile", ".", new OneOperator1, KN_ >(Build, KN_ >, atype >())); // Add * >("quantile", ".", new OneOperator1, KN_ >(Build, KN_ >, atype >())); - Add * >("quantile", ".", new OneOperator1, KN_ >(Build, KN_ >, atype *>())); - Add >("(", "", new OneOperator2_, double>(Quantile)); + Add< KN< double > * >("quantile", ".", new OneOperator1< QuantileKN< K >, KN_< K > >(Build< QuantileKN< K >, KN_< K > >, atype< KN< K > * >( ))); + Add< QuantileKN< K > >("(", "", new OneOperator2_< K, QuantileKN< K >, double >(Quantile< K >)); - map_type[typeid(SetArray).name()]->AddCast( - new E_F1_funcT, SetArray >(Cast, SetArray >) - ); - Global.Add("toRarray", "(", new OneOperator_2KN_); - Add *>("imin", ".", new OneOperator1 *>(get_imin)); - Add *>("imax", ".", new OneOperator1 *>(get_imax)); - Add *>("imin", ".", new OneOperator1 *>(get_imin));// Add april 2018 FH - Add *>("imax", ".", new OneOperator1 *>(get_imax));// Add april 2018 FH - Add *>("jmin", ".", new OneOperator1 *>(get_jmin));// Add april 2018 FH - Add *>("jmax", ".", new OneOperator1 *>(get_jmax));// Add april 2018 FH - Global.Add("ijmax", "(", new OneOperator3_ *, long*, long*>(get_ijmax));// Add april 2018 FH - Global.Add("ijmin", "(", new OneOperator3_ *, long*, long*>(get_ijmin));// Add april 2018 FH + map_type[typeid(SetArray< K >).name( )]->AddCast(new E_F1_funcT< SetArray< K >, SetArray< long > >(Cast< SetArray< K >, SetArray< long > >)); + Global.Add("toRarray", "(", new OneOperator_2KN_< double >); + Add< KN< K > * >("imin", ".", new OneOperator1< long, KN< K > * >(get_imin)); + Add< KN< K > * >("imax", ".", new OneOperator1< long, KN< K > * >(get_imax)); + Add< KNM< K > * >("imin", ".", new OneOperator1< long, KNM< K > * >(get_imin)); // Add april 2018 FH + Add< KNM< K > * >("imax", ".", new OneOperator1< long, KNM< K > * >(get_imax)); // Add april 2018 FH + Add< KNM< K > * >("jmin", ".", new OneOperator1< long, KNM< K > * >(get_jmin)); // Add april 2018 FH + Add< KNM< K > * >("jmax", ".", new OneOperator1< long, KNM< K > * >(get_jmax)); // Add april 2018 FH + Global.Add("ijmax", "(", new OneOperator3_< NothingType, KNM< K > *, long *, long * >(get_ijmax)); // Add april 2018 FH + Global.Add("ijmin", "(", new OneOperator3_< NothingType, KNM< K > *, long *, long * >(get_ijmin)); // Add april 2018 FH // madd FH. march 2015 ... - Global.Add("Unique", "(", new Unique); - Global.Add("Unique", "(", new Unique); - - + Global.Add("Unique", "(", new Unique< K, K >); + Global.Add("Unique", "(", new Unique< K, long >); // ArrayDCL(); } diff --git a/src/fflib/array_resize.hpp b/src/fflib/array_resize.hpp index 42319162d..1c281f1f2 100644 --- a/src/fflib/array_resize.hpp +++ b/src/fflib/array_resize.hpp @@ -1,41 +1,57 @@ #ifndef ARRAY_RESIZE_HPP_ #define ARRAY_RESIZE_HPP_ -template struct Resize{ T *v; - Resize( T * vv) : v(vv) {} -}; - -template T *resize1(const Resize & t,const long &n) -{ - t.v->resize(n); - return t.v; -} +template< class T > +struct Resize { + T *v; + Resize(T *vv) : v(vv) {} +}; -template T *resizeandclean1(const Resize & t,const long &n) -{ - - int nn= t.v->N(); // old size - - for (int i=n;iresize(n); - for (int i=nn;i +T *resize1(const Resize< T > &t, const long &n) { + t.v->resize(n); + return t.v; } +template< class T > +T *resizeandclean1(const Resize< T > &t, const long &n) { + + int nn = t.v->N( ); // old size + + for (int i = n; i < nn; i++) { + delete (*t.v)[i]; + } // clean + t.v->resize(n); + for (int i = nn; i < n; i++) { + (*t.v)[i] = 0; + } + return t.v; +} -template T *resize2(const Resize & t,const long &n, const long & m) -{ - t.v->resize(n,m); - return t.v; +template< class T > +T *resize2(const Resize< T > &t, const long &n, const long &m) { + t.v->resize(n, m); + return t.v; } -template Resize to_Resize( T *v){ return Resize(v);} +template< class T > +Resize< T > to_Resize(T *v) { + return Resize< T >(v); +} -template struct Resize1{ T v; - Resize1( T vv) : v(vv) {} +template< class T > +struct Resize1 { + T v; + Resize1(T vv) : v(vv) {} }; -template Resize1 to_Resize1( T v){ return Resize1(v);} +template< class T > +Resize1< T > to_Resize1(T v) { + return Resize1< T >(v); +} -template A Build(B b) { return A(b);} +template< class A, class B > +A Build(B b) { + return A(b); +} -#endif // ARRAY_RESIZE_HPP_ +#endif // ARRAY_RESIZE_HPP_ diff --git a/src/fflib/array_tlp.hpp b/src/fflib/array_tlp.hpp index c49214711..634b599a4 100644 --- a/src/fflib/array_tlp.hpp +++ b/src/fflib/array_tlp.hpp @@ -25,8 +25,8 @@ along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//#pragma dont_inline on -//#pragma inline_depth(1) +// #pragma dont_inline on +// #pragma inline_depth(1) // TODO: remove this block as soon as autoconf is removed from FreeFem++ #ifndef CMAKE @@ -38,7 +38,7 @@ #include #include -//#include +// #include #include "AFunction.hpp" #include @@ -59,702 +59,749 @@ namespace Fem2D { #include "R3.hpp" } -template -struct affectation -{ - using first_argument_type = T; - using second_argument_type = T; - using result_type = T; - T& operator()(T& x, const T& y) const {return (x=y);} +template< class T > +struct affectation { + using first_argument_type = T; + using second_argument_type = T; + using result_type = T; + T &operator( )(T &x, const T &y) const { return (x = y); } }; -template -struct affectation_add -{ - using first_argument_type = T; - using second_argument_type = T; - using result_type = T; - T& operator()(T& x, const T& y) const {return (x+=y);}// correct FH 25/10/2013 +template< class T > +struct affectation_add { + using first_argument_type = T; + using second_argument_type = T; + using result_type = T; + T &operator( )(T &x, const T &y) const { return (x += y); } // correct FH 25/10/2013 }; -template -struct affectation_sub -{ - using first_argument_type = T; - using second_argument_type = T; - using result_type = T; - T& operator()(T& x, const T& y) const {return (x-=y);}// correct FH 25/10/2013 +template< class T > +struct affectation_sub { + using first_argument_type = T; + using second_argument_type = T; + using result_type = T; + T &operator( )(T &x, const T &y) const { return (x -= y); } // correct FH 25/10/2013 }; +extern Map_type_of_map map_type_of_map; // to store te type +extern Map_type_of_map map_pair_of_type; // to store te type +extern basicForEachType *typevarreal, *typevarcomplex; // type of real and complex variable -extern Map_type_of_map map_type_of_map ; // to store te type -extern Map_type_of_map map_pair_of_type ; // to store te type - -extern basicForEachType * typevarreal, * typevarcomplex; // type of real and complex variable - -extern int TheCurrentLine; // unset: by default -extern long mpisize,mpirank; - -template inline T Square (const T &a){return a*a;} - +extern int TheCurrentLine; // unset: by default +extern long mpisize, mpirank; +template< class T > +inline T Square(const T &a) { + return a * a; +} -template +template< class K > struct Op2_dotproduct { - using first_argument_type = Transpose >; - using second_argument_type = KN *; - using result_type = K; - static K f( Transpose > const & a, KN * const& b) - { return (conj(a.t),*b);} }; + using first_argument_type = Transpose< KN_< K > >; + using second_argument_type = KN< K > *; + using result_type = K; + static K f(Transpose< KN_< K > > const &a, KN< K > *const &b) { return (conj(a.t), *b); } +}; -template +template< class K > struct Op2_dotproduct_ { - using first_argument_type = Transpose >; - using second_argument_type = KN_; - using result_type = K; - static K f( Transpose > const & a, KN_ const& b) - { return (conj(a.t),b);} }; - - -template -void HeapSort(T *c,long n,long o) -{ // trie un tableau c de n valeur avec un decalage de o. - // le tableau: c[i*o] , pour i = 0 a n-1 - long l,j,r,i; - T crit; - c-=o; // on decale de o pour que le tableau commence a o - if( n <= 1) return; - l = (n/2 + 1)*o; - r = n*o; - while (1) { // label 2 - if(l <= o ) { // label 20 - crit = c[r]; - c[r] = c[o]; - r-=o; - if ( r == o ) { c[o]=crit; return;} - } else crit = c[l-=o]; - j=l; - while (1) {// label 4 - i=j; - j=2*j; - if (j>r) {c[i]=crit;break;} // L8 -> G2 - if ((j G2 - } + using first_argument_type = Transpose< KN_< K > >; + using second_argument_type = KN_< K >; + using result_type = K; + static K f(Transpose< KN_< K > > const &a, KN_< K > const &b) { return (conj(a.t), b); } +}; + +template< class T > +void HeapSort(T *c, long n, long o) { // trie un tableau c de n valeur avec un decalage de o. + // le tableau: c[i*o] , pour i = 0 a n-1 + long l, j, r, i; + T crit; + c -= o; // on decale de o pour que le tableau commence a o + if (n <= 1) return; + l = (n / 2 + 1) * o; + r = n * o; + while (1) { // label 2 + if (l <= o) { // label 20 + crit = c[r]; + c[r] = c[o]; + r -= o; + if (r == o) { + c[o] = crit; + return; + } + } else + crit = c[l -= o]; + j = l; + while (1) { // label 4 + i = j; + j = 2 * j; + if (j > r) { + c[i] = crit; + break; + } // L8 -> G2 + if ((j < r) && (c[j] < c[j + o])) j += o; // L5 + if (crit < c[j]) + c[i] = c[j]; // L6+1 G4 + else { + c[i] = crit; + break; + } // L8 -> G2 } + } } -template A SortKn(const A & ca) -{ - A a(ca); - if(a.n > 0) - HeapSort(&a[0],a.n,a.step); - return a;} +template< class R, class A > +A SortKn(const A &ca) { + A a(ca); + if (a.n > 0) HeapSort< R >(&a[0], a.n, a.step); + return a; +} -template A SortKn(const A & ca,const B & cb) -{ - cout << "SortKn " << endl; - const A &a(ca); - const B &b(cb); - ffassert(a.n == b.n); - ffassert(a.step == b.step && b.step ==1); - if(a.n > 0) - HeapSort(&a[0],&b[0],a.n); - cout << b << endl; -return a;} - -template KN * SortpKn2( KN * const & pa,KN * const & pb){ +template< class R, class RR, class A, class B > +A SortKn(const A &ca, const B &cb) { + cout << "SortKn " << endl; + const A &a(ca); + const B &b(cb); + ffassert(a.n == b.n); + ffassert(a.step == b.step && b.step == 1); + if (a.n > 0) HeapSort< R, RR >(&a[0], &b[0], a.n); + cout << b << endl; + return a; +} + +template< class R, class RR > +KN< R > *SortpKn2(KN< R > *const &pa, KN< RR > *const &pb) { // cout << " SortpKn2 " << endl; - KN &a(*pa); - KN &b(*pb); - ffassert(a.n == b.n); - ffassert(a.step == b.step && b.step ==1); - if(a.n > 0) - HeapSort(&a[0],&b[0],a.n); - return pa;} - -template KN * SortpKn( KN * const & pa){ - KN &a(*pa); - if(a.n > 0) - HeapSort(&a[0],a.n,a.step); - return pa;} - -template -class QuantileKN: public KN_ { public: - QuantileKN(const KN_ &a): KN_(a) {} - QuantileKN(KN * p): KN_(*p) {} - operator R *() const {return this->KN_::operator R *() ;} + KN< R > &a(*pa); + KN< RR > &b(*pb); + ffassert(a.n == b.n); + ffassert(a.step == b.step && b.step == 1); + if (a.n > 0) HeapSort< R, RR >(&a[0], &b[0], a.n); + return pa; +} + +template< class R > +KN< R > *SortpKn(KN< R > *const &pa) { + KN< R > &a(*pa); + if (a.n > 0) HeapSort< R >(&a[0], a.n, a.step); + return pa; +} + +template< class R > +class QuantileKN : public KN_< R > { + public: + QuantileKN(const KN_< R > &a) : KN_< R >(a) {} + QuantileKN(KN< R > *p) : KN_< R >(*p) {} + operator R *( ) const { return this->KN_< R >::operator R *( ); } }; +template< class R > +R Quantile(QuantileKN< R > const &a, const double &q) { + KN< R > b(a); + HeapSort< R >(b, b.n, b.step); + long m = lrint(b.n * q); + if (m >= b.n) m = b.n - 1; + if (m < 0) m = 0; + R qq = b[m]; + // cout << "Quantile: m = " << m << " " << b < R Quantile(QuantileKN const & a,const double & q){ - KN b(a); - HeapSort(b,b.n,b.step); - long m=lrint(b.n*q); - if( m >= b.n) m=b.n-1; - if( m < 0) m=0; - R qq=b[m]; - // cout << "Quantile: m = " << m << " " << b < -inline bool exist_element( MyMap * const & a,string* const & b) -{ return a->exist(*b);} +template< class RR, class A, class B > +RR *get_elementp_(const A &a, const B &b) { + if (b < 0 || a->N( ) <= b) { + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) << endl; + ExecError("Out of bound in operator []"); + } + return &((*a)[b]); +} -template<> -inline string ** get_element( MyMap * const & a,string* const & b) - { string** ret= &((*a)[*b]); // correction FH feb 2004 - if( *ret ==0) *ret = newstring(""); // string vide ??? - // cout << "get_element " << *b << " : " << ret << " = "<< * ret << endl; - // delete b; modif mars 2006 auto del ptr - return ret;} - -inline string ** get_elements( MyMap * const & a,string* const & b) - { String* Sret= &((*a)[*b]); // correction FH feb 2004 - // delete b; modif mars 2006 auto del ptr - return Sret->getap();} - -template -RR * get_element_(const A & a,const B & b){ - if( b<0 || a.N() <= b) - { cerr << " Out of bound 0 <=" << b << " < " << a.N() << " array type = " << typeid(A).name() << endl; - ExecError("Out of bound in operator []");} - return &((a)[b]);} - - -template -RR * get_elementp_(const A & a,const B & b){ - if( b<0 || a->N() <= b) - { cerr << " Out of bound 0 <=" << b << " < " << a->N() << " array type = " << typeid(A).name() << endl; - ExecError("Out of bound in operator []");} - return &((*a)[b]);} +template< class K > +KN_< K > fSubArray(const KN_< K > &a, const SubArray &b) { + return a(b); +} +template< class K > +KN_< K > fSubArrayp(KN< K > *const &a, const SubArray &b) { + return (*a)(b); +} -template -KN_ fSubArray(const KN_ & a,const SubArray & b) - { return a(b);} -template -KN_ fSubArrayp( KN * const & a,const SubArray & b) - { return (*a)(b);} +template< class K > +KNM_< K > fSubArraybb(const KNM_< K > &a, const SubArray &b, const SubArray &c) { + return a(b, c); +} +template< class K > +KNM_< K > fSubArraypbb(KNM< K > *const &a, const SubArray &b, const SubArray &c) { + return (*a)(b, c); +} -template -KNM_ fSubArraybb(const KNM_ & a,const SubArray & b,const SubArray & c) -{ return a(b,c);} -template -KNM_ fSubArraypbb( KNM * const & a,const SubArray & b,const SubArray & c) -{ return (*a)(b,c);} +template< class K > +KN_< K > fSubArrayib(const KNM_< K > &a, const long &i, const SubArray &b) { + return a(i, b); +} +template< class K > +KN_< K > fSubArraybi(const KNM_< K > &a, const SubArray &b, const long &i) { + return a(b, i); +} -template -KN_ fSubArrayib(const KNM_ & a,const long &i,const SubArray & b) -{ return a(i,b);} -template -KN_ fSubArraybi(const KNM_ & a,const SubArray & b,const long &i) -{ return a(b,i);} +template< class K > +KN_< K > fSubArraypib(KNM< K > *const &a, const long &i, const SubArray &b) { + return (*a)(i, b); +} +template< class K > +KN_< K > fSubArraypbi(KNM< K > *const &a, const SubArray &b, const long &i) { + return (*a)(b, i); +} -template -KN_ fSubArraypib( KNM *const & a,const long &i,const SubArray & b) -{ return (*a)(i,b);} -template -KN_ fSubArraypbi( KNM *const & a,const SubArray & b,const long &i) -{ return (*a)(b,i);} - - -template -A fSubArrayc(const A & a,const char & b) - { return a;} - -template -RR * get_elementp2_(const A & a,const B & b,const C & c){ - if( b<0 || a->N() <= b || c<0 || a->M() <= c ) - { cerr << " Out of bound 0 <=" << b << " < " << a->N() << " " << c << " < " << a->M() - << " array type = " << typeid(A).name() << endl; - ExecError("Out of bound in operator (,)");} - return &((*a)(b,c));} - -template -RR get_element_is(const A & a,const B & b,const C & c){ - // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; - return ((*a)(b,'.')(c));} - -template -RR get_element_si(const A & a,const B & b,const C & c){ - // cout << c << " .... " << ((*a)(b,SubArray(1,c) )) << endl;; - return ((*a)('.',c)(b));} - -template -struct check_get_element_lineorcol -{ - static void check(const A & a,const B & b,const C & c){ - if(c == ':' && (b<0 || a->N() <= b)) - ExecError("Out of bound"); - if(b == ':' && (c<0 || a->M() <= c)) - ExecError("Out of bound"); +template< class A > +A fSubArrayc(const A &a, const char &b) { + return a; +} - } +template< class RR, class A, class B, class C > +RR *get_elementp2_(const A &a, const B &b, const C &c) { + if (b < 0 || a->N( ) <= b || c < 0 || a->M( ) <= c) { + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " " << c << " < " << a->M( ) << " array type = " << typeid(A).name( ) << endl; + ExecError("Out of bound in operator (,)"); + } + return &((*a)(b, c)); +} + +template< class RR, class A, class B, class C > +RR get_element_is(const A &a, const B &b, const C &c) { + // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; + return ((*a)(b, '.')(c)); +} + +template< class RR, class A, class B, class C > +RR get_element_si(const A &a, const B &b, const C &c) { + // cout << c << " .... " << ((*a)(b,SubArray(1,c) )) << endl;; + return ((*a)('.', c)(b)); +} + +template< class A, class B, class C > +struct check_get_element_lineorcol { + static void check(const A &a, const B &b, const C &c) { + if (c == ':' && (b < 0 || a->N( ) <= b)) ExecError("Out of bound"); + if (b == ':' && (c < 0 || a->M( ) <= c)) ExecError("Out of bound"); + } }; -template -struct check_get_element_lineorcol -{ - static void check(const A & a,const B & b,const char & c){ - if( (b<0 || a->N() <= b)) - ExecError("Out of bound"); - } +template< class A, class B > +struct check_get_element_lineorcol< A, B, char > { + static void check(const A &a, const B &b, const char &c) { + if ((b < 0 || a->N( ) <= b)) ExecError("Out of bound"); + } }; -template -struct check_get_element_lineorcol -{ - static void check(const A & a,const char & b,const B & c){ - if( (c<0 || a->M() <= c)) - ExecError("Out of bound"); - } +template< class A, class B > +struct check_get_element_lineorcol< A, char, B > { + static void check(const A &a, const char &b, const B &c) { + if ((c < 0 || a->M( ) <= c)) ExecError("Out of bound"); + } }; -template -RR get_element_lineorcol(const A & a,const B & b,const C & c){ - // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; - check_get_element_lineorcol::check(a,b,c); - return ((*a)(b,c)); - } - -template -RR get_element_is_(const A & a,const B & b,const C & c){ - // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; -return ((a)(b,'.')(c));} +template< class RR, class A, class B, class C > +RR get_element_lineorcol(const A &a, const B &b, const C &c) { + // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; + check_get_element_lineorcol< A, B, C >::check(a, b, c); + return ((*a)(b, c)); +} -template -RR get_element_si_(const A & a,const B & b,const C & c){ - // cout << c << " .... " << ((*a)(b,SubArray(1,c) )) << endl;; -return ((a)('.',c)(b));} +template< class RR, class A, class B, class C > +RR get_element_is_(const A &a, const B &b, const C &c) { + // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; + return ((a)(b, '.')(c)); +} -template -RR get_element_lineorcol_(const A & a,const B & b,const C & c){ - // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; -return ((a)(b,c));} +template< class RR, class A, class B, class C > +RR get_element_si_(const A &a, const B &b, const C &c) { + // cout << c << " .... " << ((*a)(b,SubArray(1,c) )) << endl;; + return ((a)('.', c)(b)); +} -template -RR * get_elementp2__(const A & a,const B & b,const C & c){ - if( b<0 || a.N() <= b || c<0 || a.M() <= c ) - { cerr << " Out of bound 0 <=" << b << " < " << a.N() << " " << c << " < " << a.M() - << " array type = " << typeid(A).name() << endl; - ExecError("Out of bound in operator (,)");} -return &((a)(b,c));} +template< class RR, class A, class B, class C > +RR get_element_lineorcol_(const A &a, const B &b, const C &c) { + // cout << b << " .... " << ((*a)(SubArray(1,b),c)) << endl;; + return ((a)(b, c)); +} +template< class RR, class A, class B, class C > +RR *get_elementp2__(const A &a, const B &b, const C &c) { + if (b < 0 || a.N( ) <= b || c < 0 || a.M( ) <= c) { + cerr << " Out of bound 0 <=" << b << " < " << a.N( ) << " " << c << " < " << a.M( ) << " array type = " << typeid(A).name( ) << endl; + ExecError("Out of bound in operator (,)"); + } + return &((a)(b, c)); +} -template -struct myremove_pointer -{ - typedef T type; +template< typename T > +struct myremove_pointer { + typedef T type; }; -template -struct myremove_pointer -{ - typedef typename myremove_pointer::type type; +template< typename T > +struct myremove_pointer< T * > { + typedef typename myremove_pointer< T >::type type; }; -template -class InitMapfromArray : public OneOperator { -public: - typedef typename myremove_pointer::type MMap ; +template< class Map, class Key, class Value, bool isinit > +class InitMapfromArray : public OneOperator { + public: + typedef typename myremove_pointer< Map >::type MMap; // typedef typename KNR::K RR; - typedef Map A; - typedef Map R; - typedef E_Array B; - - class CODE : public E_F0 { public: - Expression a0; - int N; - Expression * tab; - int * what;// 0 RR, 1 KN, - const bool mi; - /* - static KN_ &set(KN * a,KN *& p,int n){ - if(isinit) a->init(n); - else a->resize(n); - p =a; - return *a;}*/ - - /* static KN_ &set(KN_ & a,KN *& p,int n){p=0;return a;}*/ - - CODE(Expression a,const E_Array & tt) - : a0(a),N(tt.size()), - tab(new Expression [N]), - what(new int[N]) , - mi(tt.MeshIndependent()) - - { - assert(&tt); - // int err=0; - for (int i=0;i()->CastingFrom(tt[i].right() ) ) - { - tab[i]=atype()->CastTo(tt[i]); - what[i]=1; - } - else if(i%2==1 && atype()->CastingFrom(tt[i].right() ) ) - { - tab[i]=atype()->CastTo(tt[i]); - what[i]=1; - } + typedef Map A; + typedef Map R; + typedef E_Array B; + + class CODE : public E_F0 { + public: + Expression a0; + int N; + Expression *tab; + int *what; // 0 RR, 1 KN, + const bool mi; + /* + static KN_ &set(KN * a,KN *& p,int n){ + if(isinit) a->init(n); + else a->resize(n); + p =a; + return *a;}*/ - else - CompileError(" InitMapfromArray: we are waiting for Key or Value type"); - } - AnyType operator()(Stack stack) const - { - - A aa=GetAny((*a0)(stack)); - if(isinit) aa->init(); - for(int i=0,j=0; i((*(tab[j++]))(stack)); - // String sk(*k); - Value v= GetAny((*(tab[j++]))(stack)); - - //cout << "InitMapfromArray "<< *k << " " << (string) sk << " "<< v << endl; - aa->insert(*k,v); - } - return SetAny(aa); + /* static KN_ &set(KN_ & a,KN *& p,int n){p=0;return a;}*/ + + CODE(Expression a, const E_Array &tt) + : a0(a), N(tt.size( )), tab(new Expression[N]), what(new int[N]), mi(tt.MeshIndependent( )) + + { + assert(&tt); + // int err=0; + for (int i = 0; i < N; i++) + if (i % 2 == 0 && atype< Key >( )->CastingFrom(tt[i].right( ))) { + tab[i] = atype< Key >( )->CastTo(tt[i]); + what[i] = 1; + } else if (i % 2 == 1 && atype< Value >( )->CastingFrom(tt[i].right( ))) { + tab[i] = atype< Value >( )->CastTo(tt[i]); + what[i] = 1; } - bool MeshIndependent() const {return mi;} // - ~CODE() { delete [] tab; delete[] what;} - operator aType () const { return atype();} - }; // end sub class CODE - - -public: - E_F0 * code(const basicAC_F0 & args) const - { if(verbosity>9999) - cout << "\n code InitMapfromArray:" << *args[0].left() << " " << *args[1].left() - << "( "<< *t[0] << " " << *t[1] <<")" <CastTo(args[0]),*dynamic_cast( t[1]->CastTo(args[1]).LeftValue()));} - InitMapfromArray(int preff=0): OneOperator(atype(),atype(),atype()) { - pref=preff; + + else + CompileError(" InitMapfromArray: we are waiting for Key or Value type"); + } + AnyType operator( )(Stack stack) const { + + A aa = GetAny< A >((*a0)(stack)); + if (isinit) aa->init( ); + for (int i = 0, j = 0; i < N / 2; ++i) { + Key k = GetAny< Key >((*(tab[j++]))(stack)); + // String sk(*k); + Value v = GetAny< Value >((*(tab[j++]))(stack)); + + // cout << "InitMapfromArray "<< *k << " " << (string) sk << " "<< v << endl; + aa->insert(*k, v); + } + return SetAny< R >(aa); + } + bool MeshIndependent( ) const { return mi; } // + ~CODE( ) { + delete[] tab; + delete[] what; } + operator aType( ) const { return atype< R >( ); } + }; // end sub class CODE + public: + E_F0 *code(const basicAC_F0 &args) const { + if (verbosity > 9999) cout << "\n code InitMapfromArray:" << *args[0].left( ) << " " << *args[1].left( ) << "( " << *t[0] << " " << *t[1] << ")" << endl; + return new CODE(t[0]->CastTo(args[0]), *dynamic_cast< const E_Array * >(t[1]->CastTo(args[1]).LeftValue( ))); + } + InitMapfromArray(int preff = 0) : OneOperator(atype< R >( ), atype< A >( ), atype< B >( )) { pref = preff; } }; +template< class CR, class KNRR, bool isinit > +class InitArrayfromArray : public OneOperator { + public: + typedef typename myremove_pointer< KNRR >::type KNR; + typedef typename KNR::K RR; + typedef KNRR A; + typedef KNRR R; + typedef E_Array B; + + class CODE : public E_F0 { + public: + Expression a0; + int N; + Expression *tab; + int *what; // 0 RR, 1 KN, + const bool mi; + + static KN_< RR > &set(KN< RR > *a, KN< RR > *&p, int n) { + if (isinit) + a->init(n); + else + a->resize(n); + p = a; + return *a; + } -template -class InitArrayfromArray : public OneOperator { -public: - typedef typename myremove_pointer::type KNR ; - typedef typename KNR::K RR; - typedef KNRR A; - typedef KNRR R; - typedef E_Array B; - - class CODE : public E_F0 { public: - Expression a0; - int N; - Expression * tab; - int * what;// 0 RR, 1 KN, - const bool mi; - - static KN_ &set(KN * a,KN *& p,int n){ - if(isinit) a->init(n); - else a->resize(n); - p =a; - return *a;} - - static KN_ &set(KN_ & a,KN *& p,int n){p=0;return a;} - - CODE(Expression a,const E_Array & tt) - : a0(a),N(tt.size()), - tab(new Expression [N]), - what(new int[N]) , - mi(tt.MeshIndependent()) - - { - assert(&tt); - // int err=0; - for (int i=0;i()->CastingFrom(tt[i].right() ) ) - { - tab[i]=atype()->CastTo(tt[i]); - what[i]=0; - } - else if(atype >()->CastingFrom(tt[i].right() ) ) - { - tab[i]=atype >()->CastTo(tt[i].RightExp()); - what[i]=1; - } - else - CompileError(" InitArrayfromArray: we are waiting for scalar or vector of scalar"); + static KN_< RR > &set(KN_< RR > &a, KN< RR > *&p, int n) { + p = 0; + return a; } - AnyType operator()(Stack stack) const + + CODE(Expression a, const E_Array &tt) + : a0(a), N(tt.size( )), tab(new Expression[N]), what(new int[N]), mi(tt.MeshIndependent( )) + { - // a verifier ... FH nov 2015..... - //extern void xxxx(); - //xxxx(); - KN * pa=0; - A aa=GetAny((*a0)(stack)); - KN v(N); - KN nn(N+1); - for (int i=0;i >(v[i]).size(); - if (nn[i]) n += nn[i]; - else what[i] = 2; // do not go through empty arrays - } - if(verbosity>10000)cout << " InitArrayfromArray aa = " <=n); - for (int i=0,j=0 ;i(v[i]); - else if (what[i]==1) - a(SubArray(nn[i],j)) = GetAny >((*(tab[i]))(stack));// correct bug nov 2014 + assert(&tt); + // int err=0; + for (int i = 0; i < N; i++) + if (atype< CR >( )->CastingFrom(tt[i].right( ))) { + tab[i] = atype< CR >( )->CastTo(tt[i]); + what[i] = 0; + } else if (atype< KN_< RR > >( )->CastingFrom(tt[i].right( ))) { + tab[i] = atype< KN_< RR > >( )->CastTo(tt[i].RightExp( )); + what[i] = 1; + } else + CompileError(" InitArrayfromArray: we are waiting for scalar or vector of scalar"); + } + AnyType operator( )(Stack stack) const { + // a verifier ... FH nov 2015..... + // extern void xxxx(); + // xxxx(); + KN< RR > *pa = 0; + A aa = GetAny< A >((*a0)(stack)); + KN< AnyType > v(N); + KN< int > nn(N + 1); + for (int i = 0; i < N; i++) v[i] = (*(tab[i]))(stack); + + int n = 0; + for (int i = 0; i < N; i++) { + if (what[i] == 0) + nn[i] = 1; + else if (what[i] == 1) + nn[i] = GetAny< KN_< RR > >(v[i]).size( ); + if (nn[i]) + n += nn[i]; + else + what[i] = 2; // do not go through empty arrays + } + if (verbosity > 10000) cout << " InitArrayfromArray aa = " << aa << " n=" << n << endl; + KN_< RR > a = set(aa, pa, n); + if (verbosity > 10000) cout << " InitArrayfromArray a.N() " << a.N( ) << " " << n << " " << pa << " " << isinit << endl; + ffassert(a.N( ) >= n); + for (int i = 0, j = 0; i < N; j += nn[i++]) { + // cout << " ### " << i << " " << j << endl; + if (what[i] == 0) + a[j] = GetAny< CR >(v[i]); + else if (what[i] == 1) + a(SubArray(nn[i], j)) = GetAny< KN_< RR > >((*(tab[i]))(stack)); // correct bug nov 2014 } - // (due to resize=> pointer change Fh - return SetAny(aa); + // (due to resize=> pointer change Fh + return SetAny< R >(aa); } - bool MeshIndependent() const {return mi;} // - ~CODE() { delete [] tab; delete[] what;} - operator aType () const { return atype();} - }; // end sub class CODE - - - public: - E_F0 * code(const basicAC_F0 & args) const - { if(verbosity>9999) - cout << "\n code InitArrayfromArray:" << *args[0].left() << " " << *args[1].left() - << "( "<< *t[0] << " " << *t[1] <<")" <CastTo(args[0]),*dynamic_cast( t[1]->CastTo(args[1]).LeftValue()));} - InitArrayfromArray(int preff=0): OneOperator(atype(),atype(),atype()) { - pref=preff; - // cout << "\n @@@ R " << *atype()<< " A " << *atype() << " B " << * atype() << " " << preff <( ); } + }; // end sub class CODE + public: + E_F0 *code(const basicAC_F0 &args) const { + if (verbosity > 9999) cout << "\n code InitArrayfromArray:" << *args[0].left( ) << " " << *args[1].left( ) << "( " << *t[0] << " " << *t[1] << ")" << endl; + return new CODE(t[0]->CastTo(args[0]), *dynamic_cast< const E_Array * >(t[1]->CastTo(args[1]).LeftValue( ))); + } + InitArrayfromArray(int preff = 0) : OneOperator(atype< R >( ), atype< A >( ), atype< B >( )) { + pref = preff; + // cout << "\n @@@ R " << *atype()<< " A " << *atype() << " B " << * atype() << " " << preff < struct InitMatfromAArray_Barray{ typedef E_Array Btype; }; -template<> struct InitMatfromAArray_Barray{ typedef TransE_Array Btype; }; - -template -class InitMatfromAArray : public OneOperator { -public: - typedef KNM * A; - typedef KNM * R; - - - typedef typename InitMatfromAArray_Barray::Btype B; - - class CODE : public E_F0 { public: - Expression a0; - int N; - int M; - Expression ** tab; - const bool mi; - - CODE(Expression a,const E_Array & tt) - : a0(a),N(tt.size()),M(0), - tab(new Expression* [N]), - mi(tt.MeshIndependent()) - - { - assert(&tt); - // int err=0; - for (int i=0;i(tt[i].LeftValue()); - if (li) - { - const E_Array & lli = *li; - // -- check --- - if( i == 0) { - M = lli.size(); ffassert( M>0 ); - for (int i=0;isize() ) { - cout << " line " << i << " the size of the column change " << M << " to " << li->size() << endl; - CompileError(" Is not a matrix, M is not constant" ); } } - - for (int j=0;j()->CastTo( lli[j]); - } - else // li == 0 - CompileError(" we are waiting for vector of scalar [ , , , ] "); - } - - } +template< bool t > +struct InitMatfromAArray_Barray { + typedef E_Array Btype; +}; +template<> +struct InitMatfromAArray_Barray< true > { + typedef TransE_Array Btype; +}; + +template< class RR, bool isinit, bool Trans = false > +class InitMatfromAArray : public OneOperator { + public: + typedef KNM< RR > *A; + typedef KNM< RR > *R; + + typedef typename InitMatfromAArray_Barray< Trans >::Btype B; + + class CODE : public E_F0 { + public: + Expression a0; + int N; + int M; + Expression **tab; + const bool mi; + + CODE(Expression a, const E_Array &tt) + : a0(a), N(tt.size( )), M(0), tab(new Expression *[N]), mi(tt.MeshIndependent( )) - AnyType operator()(Stack stack) const { - A a=GetAny((*a0)(stack)); - int NN=N,MM=M; - if(Trans) swap(NN,MM); + assert(&tt); + // int err=0; + for (int i = 0; i < N; i++) { + const E_Array *li = dynamic_cast< const E_Array * >(tt[i].LeftValue( )); + if (li) { + const E_Array &lli = *li; + // -- check --- + if (i == 0) { + M = lli.size( ); + ffassert(M > 0); + for (int i = 0; i < N; i++) tab[i] = new Expression[M]; + } else { + if (M != li->size( )) { + cout << " line " << i << " the size of the column change " << M << " to " << li->size( ) << endl; + CompileError(" Is not a matrix, M is not constant"); + } + } + + for (int j = 0; j < M; j++) tab[i][j] = atype< RR >( )->CastTo(lli[j]); + } else // li == 0 + CompileError(" we are waiting for vector of scalar [ , , , ] "); + } + } + + AnyType operator( )(Stack stack) const { + A a = GetAny< A >((*a0)(stack)); + int NN = N, MM = M; + if (Trans) swap(NN, MM); if (isinit) - a->init(NN,MM); + a->init(NN, MM); else - a->resize(NN,MM); - - for (int i =0;i( (*(tab[i][j]))(stack))) ; - else - (*a)(i,j)= GetAny< RR >( (*(tab[i][j]))(stack)) ; - return SetAny(a); + a->resize(NN, MM); + + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) + if (Trans) + (*a)(j, i) = RNM::conj(GetAny< RR >((*(tab[i][j]))(stack))); + else + (*a)(i, j) = GetAny< RR >((*(tab[i][j]))(stack)); + return SetAny< R >(a); } - bool MeshIndependent() const {return mi;} // - ~CODE() { for (int i=0;i();} - }; // end sub class CODE - - - public: - E_F0 * code(const basicAC_F0 & args) const - { - const E_Array * ea; - if(Trans) - { - const TransE_Array *tea =dynamic_cast( t[1]->CastTo(args[1]).LeftValue()); - ea =tea->v; - } - else - ea =dynamic_cast( t[1]->CastTo(args[1]).LeftValue()); - return new CODE(t[0]->CastTo(args[0]),*ea) ;} - InitMatfromAArray(): OneOperator(atype(),atype(),atype()) {} - + bool MeshIndependent( ) const { return mi; } // + ~CODE( ) { + for (int i = 0; i < N; i++) delete[] tab[i]; + delete[] tab; + } + operator aType( ) const { return atype< R >( ); } + }; // end sub class CODE + + public: + E_F0 *code(const basicAC_F0 &args) const { + const E_Array *ea; + if (Trans) { + const TransE_Array *tea = dynamic_cast< const TransE_Array * >(t[1]->CastTo(args[1]).LeftValue( )); + ea = tea->v; + } else + ea = dynamic_cast< const E_Array * >(t[1]->CastTo(args[1]).LeftValue( )); + return new CODE(t[0]->CastTo(args[0]), *ea); + } + InitMatfromAArray( ) : OneOperator(atype< R >( ), atype< A >( ), atype< B >( )) {} }; -template -class SetArrayofKNfromKN : public OneOperator { -public: - typedef KN_ A; // Warning B type of 1 parameter - typedef KN_ R; - typedef E_Array B; // A type of 2 parameter - - class CODE : public E_F0 { public: - Expression a0; - int N; - Expression * tab; - int * what;// 0 RR, 1 KN, - const bool mi; - - CODE(Expression a,const E_Array & tt) - : a0(a),N(tt.size()), - tab(new Expression [N]), - what(new int[N]) , - mi(tt.MeshIndependent()) - { - assert(&tt); - // int err=0; - for (int i=0;i()->CastingFrom(tt[i].left() ) ) - { - tab[i]=atype()->CastTo(tt[i]); - what[i]=0; - } - else if(atype >()->CastingFrom(tt[i].right() ) ) - { - tab[i]=atype >()->CastTo(tt[i].RightExp()); - what[i]=1; - } - else - CompileError("SetArrayofKNfromKN: we are waiting for scalar or vector of scalar"); +template< typename RR > +class SetArrayofKNfromKN : public OneOperator { + public: + typedef KN_< RR > A; // Warning B type of 1 parameter + typedef KN_< RR > R; + typedef E_Array B; // A type of 2 parameter + + class CODE : public E_F0 { + public: + Expression a0; + int N; + Expression *tab; + int *what; // 0 RR, 1 KN, + const bool mi; + + CODE(Expression a, const E_Array &tt) : a0(a), N(tt.size( )), tab(new Expression[N]), what(new int[N]), mi(tt.MeshIndependent( )) { + assert(&tt); + // int err=0; + for (int i = 0; i < N; i++) + if (atype< RR * >( )->CastingFrom(tt[i].left( ))) { + tab[i] = atype< RR * >( )->CastTo(tt[i]); + what[i] = 0; + } else if (atype< KN_< RR > >( )->CastingFrom(tt[i].right( ))) { + tab[i] = atype< KN_< RR > >( )->CastTo(tt[i].RightExp( )); + what[i] = 1; + } else + CompileError("SetArrayofKNfromKN: we are waiting for scalar or vector of scalar"); } - AnyType operator()(Stack stack) const - { - A a=GetAny((*a0)(stack)); - KN v(N); - KN nn(N+1); - for (int i=0;i >(v[i]).size(); - if (nn[i]) n += nn[i]; - else what[i] = 2; // do not go through empty arrays - } - ffassert(n == a.size()); - for (int i=0,j=0 ;i(v[i]) = a[j]; - else if (what[i]==1) { // hack FH - KN_ tab(GetAny >(v[i])); - tab =a(SubArray(nn[i],j)); - } - return SetAny(a); + AnyType operator( )(Stack stack) const { + A a = GetAny< A >((*a0)(stack)); + KN< AnyType > v(N); + KN< int > nn(N + 1); + for (int i = 0; i < N; i++) v[i] = (*(tab[i]))(stack); + + int n = 0; + for (int i = 0; i < N; i++) { + if (what[i] == 0) + nn[i] = 1; + else if (what[i] == 1) + nn[i] = GetAny< KN_< RR > >(v[i]).size( ); + if (nn[i]) + n += nn[i]; + else + what[i] = 2; // do not go through empty arrays + } + ffassert(n == a.size( )); + for (int i = 0, j = 0; i < N; j += nn[i++]) + + if (what[i] == 0) + *GetAny< RR * >(v[i]) = a[j]; + else if (what[i] == 1) { // hack FH + KN_< RR > tab(GetAny< KN_< RR > >(v[i])); + tab = a(SubArray(nn[i], j)); + } + return SetAny< R >(a); } - bool MeshIndependent() const {return mi;} // - ~CODE() { delete [] tab; delete[] what;} - operator aType () const { return atype();} - }; // end sub class CODE - - - public: // warning hack A and B - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(t[1]->CastTo(args[1]),*dynamic_cast( t[0]->CastTo(args[0]).RightValue()));} - SetArrayofKNfromKN(): OneOperator(atype(),atype(),atype()) {} // warning with A and B + bool MeshIndependent( ) const { return mi; } // + ~CODE( ) { + delete[] tab; + delete[] what; + } + operator aType( ) const { return atype< R >( ); } + }; // end sub class CODE + public: // warning hack A and B + E_F0 *code(const basicAC_F0 &args) const { return new CODE(t[1]->CastTo(args[1]), *dynamic_cast< const E_Array * >(t[0]->CastTo(args[0]).RightValue( ))); } + SetArrayofKNfromKN( ) : OneOperator(atype< R >( ), atype< B >( ), atype< A >( )) {} // warning with A and B }; +template< class K > +long get_MyMap_n(MyMap< String, K > *p) { + return p ? (p->m ? p->m->size( ) : 0) : 0; +} +template< class K > +long get_n(KN< K > *p) { + return p->N( ); +} // +template< class K > +long get__n(KN_< K > p) { + return p.N( ); +} // + +template< class K > +long get_n(KNM< K > *p) { + return p->N( ); +} // +template< class K > +long get_m(KNM< K > *p) { + return p->M( ); +} // +template< class K > +long get__n(KNM_< K > p) { + return p.N( ); +} // +template< class K > +long get__m(KNM_< K > p) { + return p.M( ); +} // + +template< class K > +K get_max(KN< K > *p) { + return p->max( ); +} // +template< class K > +K get_min(KN< K > *p) { + return p->min( ); +} // + +template< class K > +long get_imax(KN< K > *p) { + long i = 0; + for (long k = 1; k < p->N( ); ++k) + if ((*p)[k] > (*p)[i]) i = k; + return i; +} +template< class K > +long get_imin(KN< K > *p) { + long i = 0; + for (long k = 1; k < p->N( ); ++k) + if ((*p)[k] < (*p)[i]) i = k; + return i; +} +template< class K > +long get_imin(KNM< K > *p) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) < (*p)(i, j)) i = k, j = l; + return i; +} -template long get_MyMap_n(MyMap *p) {return p ? (p->m ? p->m->size():0):0 ;} -template long get_n(KN * p){ return p->N();}// -template long get__n(KN_ p){ return p.N();}// - -template long get_n(KNM * p){ return p->N();}// -template long get_m(KNM * p){ return p->M();}// -template long get__n(KNM_ p){ return p.N();}// -template long get__m(KNM_ p){ return p.M();}// - -template K get_max(KN * p){ return p->max();}// -template K get_min(KN * p){ return p->min();}// - -template long get_imax(KN * p){ long i =0; for(long k=1;k< p->N(); ++k) if( (*p)[k]>(*p)[i] ) i=k; return i ;} -template long get_imin(KN * p){ long i =0; for(long k=1;k< p->N(); ++k) if( (*p)[k]<(*p)[i] ) i=k; return i ;} -template long get_imin(KNM * p){ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) <(*p)(i,j) ) i=k,j=l; - return i ;} - -template long get_jmin(KNM * p){ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) <(*p)(i,j) ) i=k,j=l; - return j ;} +template< class K > +long get_jmin(KNM< K > *p) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) < (*p)(i, j)) i = k, j = l; + return j; +} -template long get_imax(KNM * p){ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) >(*p)(i,j) ) i=k,j=l; - return i ;} +template< class K > +long get_imax(KNM< K > *p) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) > (*p)(i, j)) i = k, j = l; + return i; +} /*template K get_max(KNM * p){ K m = (*p)(0,0), mm; for(long k=0;k< p->N(); ++k) @@ -766,55 +813,113 @@ template K get_min(KNM * p){ for(long l=0;l< p->M(); ++l) if( (mm=(*p)(k,l)) < m ) m=mm ; return m ;} */ -template long get_jmax(KNM * p){ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) >(*p)(i,j) ) i=k,j=l; - return j ;} -template NothingType get_ijmax(KNM * const & p,long * const & pi,long * const & pj ){ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) >(*p)(i,j) ) i=k,j=l; - *pi = i; - *pj = j; - return NothingType() ;} -template NothingType get_ijmin(KNM * const & p,long * const & pi,long * const & pj ) -{ - long i =0,j=0; - for(long k=0;k< p->N(); ++k) - for(long l=0;l< p->M(); ++l) if( (*p)(k,l) <(*p)(i,j) ) i=k,j=l; - *pi = i; - *pj = j; - return NothingType() ;} - -template K get_sum(KN * p){ return p->sum();} -template double get_l2(KN * p){ return p->l2();} -template double get_l1(KN * p){ return p->l1();} -template double get_linfty(KN * p){ return p->linfty();} - -template K get_max(KNM * p){ return p->max();} -template K get_min(KNM * p){ return p->min();} -template K get_sum(KNM * p){ return p->sum();} -template double get_l2(KNM * p){ return p->l2();} -template double get_l1(KNM * p){ return p->l1();} -template double get_linfty(KNM * p){ return p->linfty();} +template< class K > +long get_jmax(KNM< K > *p) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) > (*p)(i, j)) i = k, j = l; + return j; +} +template< class K > +NothingType get_ijmax(KNM< K > *const &p, long *const &pi, long *const &pj) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) > (*p)(i, j)) i = k, j = l; + *pi = i; + *pj = j; + return NothingType( ); +} +template< class K > +NothingType get_ijmin(KNM< K > *const &p, long *const &pi, long *const &pj) { + long i = 0, j = 0; + for (long k = 0; k < p->N( ); ++k) + for (long l = 0; l < p->M( ); ++l) + if ((*p)(k, l) < (*p)(i, j)) i = k, j = l; + *pi = i; + *pj = j; + return NothingType( ); +} -template K get_sum0(const T & p){ return p.sum();} -template K get_max0(const T &p){ return p.max();} -template K get_min0(const T &p){ return p.min();} -template K get_l2_0(const T &p){ return p.l2();} -template K get_l1_0(const T &p){ return p.l1();} -template K get_linfty_0(const T &p){ return p.linfty();} +template< class K > +K get_sum(KN< K > *p) { + return p->sum( ); +} +template< class K > +double get_l2(KN< K > *p) { + return p->l2( ); +} +template< class K > +double get_l1(KN< K > *p) { + return p->l1( ); +} +template< class K > +double get_linfty(KN< K > *p) { + return p->linfty( ); +} +template< class K > +K get_max(KNM< K > *p) { + return p->max( ); +} +template< class K > +K get_min(KNM< K > *p) { + return p->min( ); +} +template< class K > +K get_sum(KNM< K > *p) { + return p->sum( ); +} +template< class K > +double get_l2(KNM< K > *p) { + return p->l2( ); +} +template< class K > +double get_l1(KNM< K > *p) { + return p->l1( ); +} +template< class K > +double get_linfty(KNM< K > *p) { + return p->linfty( ); +} +template< class K, class T > +K get_sum0(const T &p) { + return p.sum( ); +} +template< class K, class T > +K get_max0(const T &p) { + return p.max( ); +} +template< class K, class T > +K get_min0(const T &p) { + return p.min( ); +} +template< class K, class T > +K get_l2_0(const T &p) { + return p.l2( ); +} +template< class K, class T > +K get_l1_0(const T &p) { + return p.l1( ); +} +template< class K, class T > +K get_linfty_0(const T &p) { + return p.linfty( ); +} - class ostream_precis { public: - ostream_precis(ostream * ff) :f(ff) {} - ostream * f; - operator long () const {return f->precision();} - }; +class ostream_precis { + public: + ostream_precis(ostream *ff) : f(ff) {} + ostream *f; + operator long( ) const { return f->precision( ); } +}; -template B castto(const A & a){ return a;} +template< class A, class B > +B castto(const A &a) { + return a; +} /* template @@ -823,1193 +928,1086 @@ AnyType ClearReturnpKN(Stack stack, const AnyType & a) KN * m = GetAny(a); Add2StackOfPtr2FreeRC(stack, (K*) (*m) ); if(verbosity>1) - cout << "AddIncrement:: increment + Add2StackOfPtr2FreeRC " << endl; + cout << "AddIncrement:: increment + Add2StackOfPtr2FreeRC " << endl; return new KN(true, *m); }*/ -template -AnyType ClearReturnpKK(Stack stack, const AnyType & a) -{ - // a ne faire que pour les variables local au return... - // pour l'instant on copie pour fqire mqrche - // a repense FH mqi 2009.... - KK * m = GetAny(a); +template< typename K, typename KK > +AnyType ClearReturnpKK(Stack stack, const AnyType &a) { + // a ne faire que pour les variables local au return... + // pour l'instant on copie pour fqire mqrche + // a repense FH mqi 2009.... + KK *m = GetAny< KK * >(a); // KN *cm=new KN(true, *m); bug quant KN est une variable global - // KN *cm=new KN( *m); // on duplique le tableau comme en C++ (dur dur ?????? FH) - m->increment(); - Add2StackOfPtr2FreeRC(stack,m); - if(verbosity>400) - cout << "ClearReturnpKK:: increment + Add2StackOfPtr2FreeRC nb ref " << -m->next << endl; - return m; -} -template -AnyType ClearReturnpKK_(Stack stack, const AnyType & a) -{ - // il faut faire un copie du tableau - KK_ * m = GetAny(a); - KK *cm=new KK(*m); + // KN *cm=new KN( *m); // on duplique le tableau comme en C++ (dur dur ?????? FH) + m->increment( ); + Add2StackOfPtr2FreeRC(stack, m); + if (verbosity > 400) cout << "ClearReturnpKK:: increment + Add2StackOfPtr2FreeRC nb ref " << -m->next << endl; + return m; +} +template< typename K, typename KK, typename KK_ > +AnyType ClearReturnpKK_(Stack stack, const AnyType &a) { + // il faut faire un copie du tableau + KK_ *m = GetAny< KK_ * >(a); + KK *cm = new KK(*m); + + Add2StackOfPtr2Free(stack, cm); // detruire la copie + if (verbosity > 400) cout << "ClearReturnpKK_:: copie Add2StackOfPtr2Free " << endl; + return (KK_ *)cm; +} +template< typename K, typename KK, typename KK_ > +AnyType ClearReturnKK_(Stack stack, const AnyType &a) { + // il faut faire un copie du tableau + KK_ m = GetAny< KK_ >(a); + KK *cm = new KK(m); + + Add2StackOfPtr2Free(stack, cm); // detruire la copie + if (verbosity > 400) cout << "ClearReturnKK_:: copie Add2StackOfPtr2Free " << endl; + return SetAny< KK_ >(*cm); +} +template< typename K, typename KK_, typename KK > +AnyType CopieKK_pKK(Stack stack, const AnyType &a) { + KK_ m = GetAny< KK_ >(a); + KK *cm = new KK(m); + if (verbosity > 400) cout << "CopieKK_pKK:: copie Add2StackOfPtr2Free " << cm << endl; + Add2StackOfPtr2Free(stack, cm); // detruire la copie + return cm; +} - Add2StackOfPtr2Free(stack,cm);// detruire la copie - if(verbosity>400) - cout << "ClearReturnpKK_:: copie Add2StackOfPtr2Free " << endl; - return (KK_ *) cm; +template< typename KK, typename KK_ > +AnyType UnRefpKN(Stack, const AnyType &a) { + KK_ a_(*PGetAny< KK >(a)); + return SetAny< KK_ >(a_); } -template -AnyType ClearReturnKK_(Stack stack, const AnyType & a) -{ - // il faut faire un copie du tableau - KK_ m = GetAny(a); - KK *cm=new KK(m); - - Add2StackOfPtr2Free(stack,cm);// detruire la copie - if(verbosity>400) - cout << "ClearReturnKK_:: copie Add2StackOfPtr2Free " << endl; - return SetAny(*cm); -} -template -AnyType CopieKK_pKK(Stack stack,const AnyType &a) { - KK_ m = GetAny(a); - KK *cm=new KK(m); - if(verbosity>400) - cout << "CopieKK_pKK:: copie Add2StackOfPtr2Free "<< cm << endl; - Add2StackOfPtr2Free(stack,cm);// detruire la copie -return cm;} - - -template -AnyType UnRefpKN(Stack,const AnyType &a) { - KK_ a_(*PGetAny(a)); - return SetAny(a_);} - -template inline AnyType DestroyKN(Stack,const AnyType &x){ - KN * a=PGetAny >(x); - SHOWVERB(cout << "DESTROY " <N(); ++i) - (*a)[i].destroy(); - a->destroy(); - return Nothing; -} - -template -AnyType TransposeKNM(Stack,const AnyType &a) { - Transpose< KNM * > ta(GetAny * > >(a)); - return SetAny >((*ta.t).t());} -template -void ArrayDCL() -{ +template< class A > +inline AnyType DestroyKN(Stack, const AnyType &x) { + KN< A > *a = PGetAny< KN< A > >(x); + SHOWVERB(cout << "DESTROY " << typeid(A).name( ) << " " << a << endl); + for (int i = 0; i < a->N( ); ++i) (*a)[i].destroy( ); + a->destroy( ); + return Nothing; +} + +template< typename K > +AnyType TransposeKNM(Stack, const AnyType &a) { + Transpose< KNM< K > * > ta(GetAny< Transpose< KNM< K > * > >(a)); + return SetAny< KNM_< K > >((*ta.t).t( )); +} + +template< class K > +void ArrayDCL( ) { // Dcl_TypeandPtr >(0,0,0,::Destroy >, 0 , ::ClearReturnKN ); - //Dcl_Type *>(0,::Destroy >, ::ClearReturnpKK > ); - //Dcl_TypeandPtr >(0,0,0,0,::ClearReturnKK_,KN_ >,::ClearReturnpKK_,KN_ >); - Dcl_TypeandPtr_ ,KN* > (0,0,::InitP >,::Destroy >, ::ClearReturnKK_,KN_ >,::ClearReturnpKK >); // add init 0 + // Dcl_Type *>(0,::Destroy >, ::ClearReturnpKK > ); + // Dcl_TypeandPtr >(0,0,0,0,::ClearReturnKK_,KN_ >,::ClearReturnpKK_,KN_ >); + Dcl_TypeandPtr_< KN_< K >, KN< K > * >(0, 0, ::InitP< KN< K > >, ::Destroy< KN< K > >, ::ClearReturnKK_< K, KN< K >, KN_< K > >, ::ClearReturnpKK< K, KN< K > >); // add init 0 - // Dcl_Type *>(0,::Destroy >); - // Dcl_Type *>(0,::Destroy >); // Modif 17102005 - // attention un exp KN<> * right est un KN<> et non un KN<> * + // Dcl_Type *>(0,::Destroy >); + // Dcl_Type *>(0,::Destroy >); // Modif 17102005 + // attention un exp KN<> * right est un KN<> et non un KN<> * // Dcl_Type *>(0,::Destroy > ,::ClearReturnpKK >); - Dcl_TypeandPtr_ ,KNM* > (0,0,0,::Destroy >, ::ClearReturnKK_,KNM_ >,::ClearReturnpKK >); - Dcl_Type< KN >* >(InitP>>,::DestroyKN >,::ClearReturnpKK,KN > >); - Dcl_Type< KN >* >(InitP>>,::DestroyKN >,::ClearReturnpKK,KN > >); - - Dcl_Type< outProduct_KN_* >(); - Dcl_Type< Transpose > > (); - Dcl_Type< Transpose< KNM *> >(); - - Dcl_Type >(); - - Dcl_Type >(); - Dcl_Type >(); - Dcl_Type >(); - Dcl_Type >(); - Dcl_Type >(); - Dcl_Type >(); - Dcl_Type *>(); - Dcl_Type *>(); - // for B(I) and B(I^-1) - Dcl_Type,Inv_KN_long> *>(); - Dcl_Type,KN_ > *>(); - - map_type[typeid(KN * ).name()]->AddCast( - new E_F1_funcT*,KN_ >(CopieKK_pKK,KN > ) - ); -// add august 2009 FH to see full matrix as a array - map_type[typeid(KN_ ).name()]->AddCast( - new E_F1_funcT,KNM* >(UnRef,KNM *> )); - - - map_type[typeid(KN_ ).name()]->AddCast( + Dcl_TypeandPtr_< KNM_< K >, KNM< K > * >(0, 0, 0, ::Destroy< KNM< K > >, ::ClearReturnKK_< K, KNM< K >, KNM_< K > >, ::ClearReturnpKK< K, KNM< K > >); + Dcl_Type< KN< KNM< K > > * >(InitP< KN< KNM< K > > >, ::DestroyKN< KNM< K > >, ::ClearReturnpKK< KNM< K >, KN< KNM< K > > >); + Dcl_Type< KN< KN< K > > * >(InitP< KN< KN< K > > >, ::DestroyKN< KN< K > >, ::ClearReturnpKK< KN< K >, KN< KN< K > > >); + + Dcl_Type< outProduct_KN_< K > * >( ); + Dcl_Type< Transpose< KN_< K > > >( ); + Dcl_Type< Transpose< KNM< K > * > >( ); + + Dcl_Type< Add_KN_< K > >( ); + + Dcl_Type< DotStar_KN_< K > >( ); + Dcl_Type< DotSlash_KN_< K > >( ); + Dcl_Type< Sub_KN_< K > >( ); + Dcl_Type< Mulc_KN_< K > >( ); + Dcl_Type< Divc_KN_< K > >( ); + Dcl_Type< Mul_KNM_KN_< K > >( ); + Dcl_Type< Add_Mulc_KN_< K > * >( ); + Dcl_Type< if_arth_KN_< K > * >( ); + // for B(I) and B(I^-1) + Dcl_Type< pair< KN_< K >, Inv_KN_long > * >( ); + Dcl_Type< pair< KN_< K >, KN_< long > > * >( ); + + map_type[typeid(KN< K > *).name( )]->AddCast(new E_F1_funcT< KN< K > *, KN_< K > >(CopieKK_pKK< K, KN_< K >, KN< K > >)); + // add august 2009 FH to see full matrix as a array + map_type[typeid(KN_< K >).name( )]->AddCast(new E_F1_funcT< KN_< K >, KNM< K > * >(UnRef< KN_< K >, KNM< K > * >)); + + map_type[typeid(KN_< K >).name( )]->AddCast( // new E_F1_funcT,KN_*>(UnRefpKN_ ), - new E_F1_funcT,KN*>(UnRefpKN,KN_ > ) - // inutil cas KN est right expression de KN* -// new E_F1_funcT,KN >(Cast,KN >) - - ); - map_type[typeid(KNM_ ).name()]->AddCast( - new E_F1_funcT,KNM*>(UnRefpKN,KNM_ > ) , - new E_F1_funcT,Transpose< KNM *> >(TransposeKNM) - ); - - // ,new E_F1_funcT,K>(ValueToKN_), - // new E_F1_funcT,K*>(PtrToKN_) -/* - // Ajoute FH - map_type[typeid(KN ).name()]->AddCast( - new E_F1_funcT,KN*>(UnRef >) - // ,new E_F1_funcT,K>(ValueToKN_), - // new E_F1_funcT,K*>(PtrToKN_) - ); */ - map_type_of_map[make_pair(atype(),atype())]=atype*>(); // vector - map_pair_of_type[make_pair(atype(),atype())] =atype >(); - map_type_of_map[make_pair(atype >(),atype())]=atype*>(); // matrix - map_type_of_map[make_pair(atype(),atype >())]=atype >*>();// tableau de tableau - map_type_of_map[make_pair(atype(),atype >())]=atype >*>();// tableau de matrix - - // Add FH for loop 2015 - atype*>()->SetTypeLoop(atype(),atype()); - atype*>()->SetTypeLoop(atype(),atype(),atype()); - atype >()->SetTypeLoop(atype(),atype()); - atype >()->SetTypeLoop(atype(),atype(),atype()); - - // map string of array .. Test FH Mai 2022 ... - - map_type[typeid(MyMap*).name()] = new ForEachType*>(Initialize >,Delete >) ; - - map_type_of_map[make_pair(atype(),atype())]=atype*>(); - - - typedef MyMap > MyMapofArray; - map_type[typeid(MyMapofArray*).name()] = new ForEachType(Initialize,Delete) ; - ffassert(TypeArray(atype(),atype())); - // make_pair(atype(),atype >()) - // real[string][int] - map_type_of_map[make_pair(TypeArray(atype(),atype()),atype())]=atype(); - ;// map of tableau + new E_F1_funcT< KN_< K >, KN< K > * >(UnRefpKN< KN< K >, KN_< K > >) + // inutil cas KN est right expression de KN* + // new E_F1_funcT,KN >(Cast,KN >) + + ); + map_type[typeid(KNM_< K >).name( )]->AddCast(new E_F1_funcT< KNM_< K >, KNM< K > * >(UnRefpKN< KNM< K >, KNM_< K > >), new E_F1_funcT< KNM_< K >, Transpose< KNM< K > * > >(TransposeKNM< K >)); + + // ,new E_F1_funcT,K>(ValueToKN_), + // new E_F1_funcT,K*>(PtrToKN_) + /* + // Ajoute FH + map_type[typeid(KN ).name()]->AddCast( + new E_F1_funcT,KN*>(UnRef >) + // ,new E_F1_funcT,K>(ValueToKN_), + // new E_F1_funcT,K*>(PtrToKN_) + ); */ + map_type_of_map[make_pair(atype< long >( ), atype< K >( ))] = atype< KN< K > * >( ); // vector + map_pair_of_type[make_pair(atype< long >( ), atype< long >( ))] = atype< pair< long, long > >( ); + map_type_of_map[make_pair(atype< pair< long, long > >( ), atype< K >( ))] = atype< KNM< K > * >( ); // matrix + map_type_of_map[make_pair(atype< long >( ), atype< KN_< K > >( ))] = atype< KN< KN< K > > * >( ); // tableau de tableau + map_type_of_map[make_pair(atype< long >( ), atype< KNM_< K > >( ))] = atype< KN< KNM< K > > * >( ); // tableau de matrix + + // Add FH for loop 2015 + atype< KN< K > * >( )->SetTypeLoop(atype< K * >( ), atype< long * >( )); + atype< KNM< K > * >( )->SetTypeLoop(atype< K * >( ), atype< long * >( ), atype< long * >( )); + atype< KN_< K > >( )->SetTypeLoop(atype< K * >( ), atype< long * >( )); + atype< KNM_< K > >( )->SetTypeLoop(atype< K * >( ), atype< long * >( ), atype< long * >( )); + + // map string of array .. Test FH Mai 2022 ... + + map_type[typeid(MyMap< String, K > *).name( )] = new ForEachType< MyMap< String, K > * >(Initialize< MyMap< String, K > >, Delete< MyMap< String, K > >); + + map_type_of_map[make_pair(atype< string * >( ), atype< K >( ))] = atype< MyMap< String, K > * >( ); + + typedef MyMap< String, KN< K > > MyMapofArray; + map_type[typeid(MyMapofArray *).name( )] = new ForEachType< MyMapofArray * >(Initialize< MyMapofArray >, Delete< MyMapofArray >); + ffassert(TypeArray(atype< K >( ), atype< string * >( ))); + // make_pair(atype(),atype >()) + // real[string][int] + map_type_of_map[make_pair(TypeArray(atype< K >( ), atype< string * >( )), atype< long >( ))] = atype< MyMapofArray * >( ); + ; // map of tableau /* atype*>()->Add("[","",new OneOperator2_*,string*>(get_element)); TheOperators->Add("&",new OneOperator2_*,string*>(exist_element)); TheOperators->Add("<<",new OneBinaryOperator*> >); Add* >("n",".",new OneOperator1 *>(get_MyMap_n)); */ - } - - -template pair * pBuild(const A & a,const B & b) - { return new pair(a,b);} +template< class A, class B > +pair< A, B > *pBuild(const A &a, const B &b) { + return new pair< A, B >(a, b); +} // add mars 2006 -template +template< class K, class L, class OP > struct set_A_BI { - using first_argument_type = KN_; - using second_argument_type = pair, KN_ > *; - using result_type = KN_; - static KN_ f(const KN_ & a, pair, KN_ > * const & b) { - KN_ x(a); + using first_argument_type = KN_< K >; + using second_argument_type = pair< KN_< K >, KN_< L > > *; + using result_type = KN_< K >; + static KN_< K > f(const KN_< K > &a, pair< KN_< K >, KN_< L > > *const &b) { + KN_< K > x(a); OP op; - const KN_ & y(b->first); - const KN_ & I(b->second); - L N = x.N(); - L n = y.N(); - - L maxI=I(SubArray(N)).max() ; - L minI=I(SubArray(N)).min() ; - - if( maxI >= n || I.N() < N) - { cerr << " Out of Bound x=y(I) : 0 <= " << minI << " < "<< maxI << "< " << n << endl; - cerr << " or I.N() " << I.N() << " > " << N << endl; - ExecError("Out of Bound error"); - } - - for(int i=0;i=0) - op(x(i),y(I[i])); + const KN_< K > &y(b->first); + const KN_< L > &I(b->second); + L N = x.N( ); + L n = y.N( ); + + L maxI = I(SubArray(N)).max( ); + L minI = I(SubArray(N)).min( ); + + if (maxI >= n || I.N( ) < N) { + cerr << " Out of Bound x=y(I) : 0 <= " << minI << " < " << maxI << "< " << n << endl; + cerr << " or I.N() " << I.N( ) << " > " << N << endl; + ExecError("Out of Bound error"); + } + + for (int i = 0; i < N; i++) + if (I[i] >= 0) op(x(i), y(I[i])); delete b; return a; - } }; // add oct 2019 To: real[int] b = a(I); // where a and I is also a array.. -template +template< class K, class L, class OP > struct init_A_BI { - using first_argument_type = KN*; - using second_argument_type = pair, KN_ > *; - using result_type = KN*; - static KN* f( KN * const & a, pair, KN_ > * const & b) { - KN * px(a); - OP op; - const KN_ & y(b->first); - const KN_ & I(b->second); - L n = y.N(); - px->init(I.N()); - KN & x=*px; - L N = x.N(); - - L maxI=I.max() ; - L minI=I.min() ; - - if( maxI >= n ) - { cerr << " Out of Bound x=y(I) : 0 <= " << minI << " < "<< maxI << "< " << n << endl; - cerr << " or I.N() " << I.N() << " > " << N << endl; - ExecError("Out of Bound error"); - } - - for(int i=0;i=0) - op(x(i),y(I[i])); - delete b; - return a; - + using first_argument_type = KN< K > *; + using second_argument_type = pair< KN_< K >, KN_< L > > *; + using result_type = KN< K > *; + static KN< K > *f(KN< K > *const &a, pair< KN_< K >, KN_< L > > *const &b) { + KN< K > *px(a); + OP op; + const KN_< K > &y(b->first); + const KN_< L > &I(b->second); + L n = y.N( ); + px->init(I.N( )); + KN< K > &x = *px; + L N = x.N( ); + + L maxI = I.max( ); + L minI = I.min( ); + + if (maxI >= n) { + cerr << " Out of Bound x=y(I) : 0 <= " << minI << " < " << maxI << "< " << n << endl; + cerr << " or I.N() " << I.N( ) << " > " << N << endl; + ExecError("Out of Bound error"); } + + for (int i = 0; i < N; i++) + if (I[i] >= 0) op(x(i), y(I[i])); + delete b; + return a; + } }; -template +template< class K, class L, class OP > struct set_AI_B { - using first_argument_type = pair, KN_ > *; - using second_argument_type = KN_; - using result_type = NothingType; - static NothingType f( pair, KN_ > * const & b,const KN_ & a) { - KN_ x(a); + using first_argument_type = pair< KN_< K >, KN_< L > > *; + using second_argument_type = KN_< K >; + using result_type = NothingType; + static NothingType f(pair< KN_< K >, KN_< L > > *const &b, const KN_< K > &a) { + KN_< K > x(a); OP op; - const KN_ & y(b->first); - const KN_ & I(b->second); - L N = I.N(); - L n = y.N(); - - L maxI=I(SubArray(N)).max() ; - L minI=I(SubArray(N)).min() ; - - if( maxI >= n || x.N() < N ) - { cerr << " Out of Bound x(I)=y : 0 <= " << minI << " < "<< maxI << "< " << n << endl; - cerr << " or x.N() " << I.N() << " > " << N << endl; - ExecError("Out of Bound error"); - } - - for(int i=0;i=0) - op(y(I[i]),x[i]); - delete b; - return NothingType(); + const KN_< K > &y(b->first); + const KN_< L > &I(b->second); + L N = I.N( ); + L n = y.N( ); + + L maxI = I(SubArray(N)).max( ); + L minI = I(SubArray(N)).min( ); + + if (maxI >= n || x.N( ) < N) { + cerr << " Out of Bound x(I)=y : 0 <= " << minI << " < " << maxI << "< " << n << endl; + cerr << " or x.N() " << I.N( ) << " > " << N << endl; + ExecError("Out of Bound error"); + } + for (int i = 0; i < N; i++) + if (I[i] >= 0) op(y(I[i]), x[i]); + delete b; + return NothingType( ); } }; -template -struct Op3_paac: public ternary_function,KN_,K,if_arth_KN_*> { -static if_arth_KN_* f(Stack s,const KN_ & a,const KN_ & b,const K & c ) { - //K cc(c); - KN_ kc(new(NewAllocTmp(s,sizeof(c))) K(c),1,0); - return new if_arth_KN_(a,b,kc);} +template< class K > +struct Op3_paac : public ternary_function< KN_< K >, KN_< K >, K, if_arth_KN_< K > * > { + static if_arth_KN_< K > *f(Stack s, const KN_< K > &a, const KN_< K > &b, const K &c) { + // K cc(c); + KN_< K > kc(new (NewAllocTmp(s, sizeof(c))) K(c), 1, 0); + return new if_arth_KN_< K >(a, b, kc); + } }; -template -struct Op3_paca: public ternary_function,K,KN_,if_arth_KN_*> { - static if_arth_KN_* f(Stack s,const KN_ & a,const K & b,const KN_ & c ) { - //K bb(b); - KN_ kb(new(NewAllocTmp(s,sizeof(b))) K(b),1,0); - return new if_arth_KN_(a,kb,c);} +template< class K > +struct Op3_paca : public ternary_function< KN_< K >, K, KN_< K >, if_arth_KN_< K > * > { + static if_arth_KN_< K > *f(Stack s, const KN_< K > &a, const K &b, const KN_< K > &c) { + // K bb(b); + KN_< K > kb(new (NewAllocTmp(s, sizeof(b))) K(b), 1, 0); + return new if_arth_KN_< K >(a, kb, c); + } }; -template -struct Op3_pacc: public ternary_function,K,K,if_arth_KN_*> { - static if_arth_KN_* f(Stack s,const KN_ & a,const K & b,const K & c ) { - K cc(c),bb(b); - KN_ kc(new(NewAllocTmp(s,sizeof(c))) K(c),1,0), - kb(new(NewAllocTmp(s,sizeof(b))) K(b),1,0); - return new if_arth_KN_(a,kb,kc);} +template< class K > +struct Op3_pacc : public ternary_function< KN_< K >, K, K, if_arth_KN_< K > * > { + static if_arth_KN_< K > *f(Stack s, const KN_< K > &a, const K &b, const K &c) { + K cc(c), bb(b); + KN_< K > kc(new (NewAllocTmp(s, sizeof(c))) K(c), 1, 0), kb(new (NewAllocTmp(s, sizeof(b))) K(b), 1, 0); + return new if_arth_KN_< K >(a, kb, kc); + } }; -template KNM_ Transp(KNM_ M){ return M.t();} // Add FH July 2015 -template -struct SetArray2{ - using first_argument_type = K; +template< class K > +KNM_< K > Transp(KNM_< K > M) { + return M.t( ); +} // Add FH July 2015 +template< class K > +struct SetArray2 { + using first_argument_type = K; using second_argument_type = K; - using result_type = SetArray; - static SetArray f(const K & a,const K & b) { + using result_type = SetArray< K >; + static SetArray< K > f(const K &a, const K &b) { // cout << "SubArray: " << a << " " << b << endl; // SetArray(long nn,R oo=R(),R sstep=R(1)): o(oo),n(nn),step(sstep) {} - long n= long(abs((b-a))); - - - ffassert(n>=0); - K s= (n==0) ? 1 : (b-a)/K(n);// correction oct 2019 FH Thanks to P. Ventura + long n = long(abs((b - a))); + + ffassert(n >= 0); + K s = (n == 0) ? 1 : (b - a) / K(n); // correction oct 2019 FH Thanks to P. Ventura n++; - if(verbosity>100) - cout << " SetArray " << n << " " << a << " " << s << endl; - return SetArray(n,a,s);} }; + if (verbosity > 100) cout << " SetArray " << n << " " << a << " " << s << endl; + return SetArray< K >(n, a, s); + } +}; -template -struct SetArray3: public ternary_function > { - static SetArray f(Stack s,const K & a,const K &b,const K & c) { +template< class K > +struct SetArray3 : public ternary_function< K, K, K, SetArray< K > > { + static SetArray< K > f(Stack s, const K &a, const K &b, const K &c) { // cout << "SubArray: " << a << " " << b << " " << c << endl; - long n= long(1+abs((c-a)/b)); - if(verbosity>100) - cout << " SetArray " << n << " : " << " " << a << " " << b << " " << c << endl; - return SetArray(n,a,b);} }; - -template R * set_init_array( R* const & a,const A & b){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); - a->init(b.size()); - *a=b; -return a;} -template R * set_array( R* const & a,const A & b){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); - a->resize(b.size()); - *a=b; -return a;} + long n = long(1 + abs((c - a) / b)); + if (verbosity > 100) cout << " SetArray " << n << " : " << " " << a << " " << b << " " << c << endl; + return SetArray< K >(n, a, b); + } +}; + +template< class R, class A > +R *set_init_array(R *const &a, const A &b) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << &b << endl); + a->init(b.size( )); + *a = b; + return a; +} +template< class R, class A > +R *set_array(R *const &a, const A &b) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << &b << endl); + a->resize(b.size( )); + *a = b; + return a; +} // missing FH august 2009 -template R * set_arrayp( R* const & a,const A & b){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); - a->resize(b->size()); - *a=*b; -return a;} -template R set_array_( R const & a,const A & b){ - SHOWVERB( cout << " set_array_ " << typeid(R).name() << " " << &b << endl); - ffassert(a.N()==b.size()); - R aa=a; - aa=b; -return a;} +template< class R, class A > +R *set_arrayp(R *const &a, const A &b) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << &b << endl); + a->resize(b->size( )); + *a = *b; + return a; +} +template< class R, class A > +R set_array_(R const &a, const A &b) { + SHOWVERB(cout << " set_array_ " << typeid(R).name( ) << " " << &b << endl); + ffassert(a.N( ) == b.size( )); + R aa = a; + aa = b; + return a; +} // xxxxxxxxxxx -template KNM * set_initmat_t(KNM * a,Transpose * > b ){ - ConjKNM_ tb=b.t->t(); ; - a->init(tb.N(),tb.M()); - *a=tb; - return a;} -template KNM * set_initmat(KNM * a,KNM * b ){ - - a->init(b->N(),b->M()); - *a=*b; - return a;} -template KNM * set_mat_t(KNM * a,Transpose * > b ){ - ConjKNM_ tb=b.t->t(); ; - a->resize(tb.N(),tb.M());// correction mars 2013 - *a=tb; - return a;} -template KNM * addto_mat_t(KNM * a,Transpose * > b ){ - ConjKNM_ tb=b.t->t(); ; - *a+=tb; - return a;} -template KNM * subto_mat_t(KNM * a,Transpose * > b ){ - ConjKNM_ tb=b.t->t(); ; - *a-=tb; - return a;} -template KNM * set_mat(KNM * a,KNM * b ){ - - a->resize(b->N(),b->M()); - *a=*b; - return a;} - -template -class OneOperator_2KN_ : public OneOperator {public: - class Op : public E_F0 { - public: - int N; - Expression *tab; - - Op( const E_Array &bb) : N(bb.size()), tab(new Expression[N]) - { - for(int i=0;i()->CastTo( bb[i]); - } - AnyType operator()(Stack s) const { - K * p = Add2StackOfPtr2FreeA(s,new K[N]); // mark to be delete .. - KN_ A(p,N); // FH: Correct jan 2019 bug is: stupide A what delete if KN type - for(int i=0;i( (*tab[i])(s)); - return SetAny >(A);} - }; - E_F0 * code(const basicAC_F0 & a) const - { const E_Array * b = dynamic_cast(a[0].LeftValue()); - ffassert(b); - return new Op(*b);} - - OneOperator_2KN_(): OneOperator(atype >(),atype()) { pref=-1;} +template< class K > +KNM< K > *set_initmat_t(KNM< K > *a, Transpose< KNM< K > * > b) { + ConjKNM_< K > tb = b.t->t( ); + ; + a->init(tb.N( ), tb.M( )); + *a = tb; + return a; +} +template< class K > +KNM< K > *set_initmat(KNM< K > *a, KNM< K > *b) { + + a->init(b->N( ), b->M( )); + *a = *b; + return a; +} +template< class K > +KNM< K > *set_mat_t(KNM< K > *a, Transpose< KNM< K > * > b) { + ConjKNM_< K > tb = b.t->t( ); + ; + a->resize(tb.N( ), tb.M( )); // correction mars 2013 + *a = tb; + return a; +} +template< class K > +KNM< K > *addto_mat_t(KNM< K > *a, Transpose< KNM< K > * > b) { + ConjKNM_< K > tb = b.t->t( ); + ; + *a += tb; + return a; +} +template< class K > +KNM< K > *subto_mat_t(KNM< K > *a, Transpose< KNM< K > * > b) { + ConjKNM_< K > tb = b.t->t( ); + ; + *a -= tb; + return a; +} +template< class K > +KNM< K > *set_mat(KNM< K > *a, KNM< K > *b) { + + a->resize(b->N( ), b->M( )); + *a = *b; + return a; +} + +template< class K, class KK = K > +class OneOperator_2KN_ : public OneOperator { + public: + class Op : public E_F0 { + public: + int N; + Expression *tab; + + Op(const E_Array &bb) : N(bb.size( )), tab(new Expression[N]) { + for (int i = 0; i < N; ++i) tab[i] = atype< KK >( )->CastTo(bb[i]); + } + AnyType operator( )(Stack s) const { + K *p = Add2StackOfPtr2FreeA< K >(s, new K[N]); // mark to be delete .. + KN_< K > A(p, N); // FH: Correct jan 2019 bug is: stupide A what delete if KN type + for (int i = 0; i < N; ++i) A[i] = GetAny< KK >((*tab[i])(s)); + return SetAny< KN_< K > >(A); + } + }; + E_F0 *code(const basicAC_F0 &a) const { + const E_Array *b = dynamic_cast< const E_Array * >(a[0].LeftValue( )); + ffassert(b); + return new Op(*b); + } + + OneOperator_2KN_( ) : OneOperator(atype< KN_< K > >( ), atype< E_Array >( )) { pref = -1; } }; -template +template< class K, class L > class Unique_Op : public E_F0mps { - public: - Expression ar; - Expression va; - static const int n_name_param = 1; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - Unique_Op(const basicAC_F0& args, Expression param1, Expression param2) : ar(param1), va(param2) { - args.SetNameParam(n_name_param, name_param, nargs); - } - AnyType operator()(Stack stack) const; + public: + Expression ar; + Expression va; + static const int n_name_param = 1; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + Unique_Op< K, L >(const basicAC_F0 &args, Expression param1, Expression param2) : ar(param1), va(param2) { args.SetNameParam(n_name_param, name_param, nargs); } + AnyType operator( )(Stack stack) const; }; -template -basicAC_F0::name_and_type Unique_Op::name_param[] = { - {"remove", &typeid(long)}, +template< class K, class L > +basicAC_F0::name_and_type Unique_Op< K, L >::name_param[] = { + {"remove", &typeid(long)}, }; -template +template< class K, class L > class Unique : public OneOperator { - public: - Unique() : OneOperator(atype(), atype*>(), atype*>()) { } + public: + Unique( ) : OneOperator(atype< long >( ), atype< KN< K > * >( ), atype< KN< L > * >( )) {} - E_F0* code(const basicAC_F0& args) const { - return new Unique_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Unique_Op< K, L >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } }; -template -AnyType Unique_Op::operator()(Stack stack) const { - KN* array = GetAny*>((*ar)(stack)); - KN* val = GetAny*>((*va)(stack)); - std::set vals; - for(int i = 0; i < array->n; ++i) +template< class K, class L > +AnyType Unique_Op< K, L >::operator( )(Stack stack) const { + KN< K > *array = GetAny< KN< K > * >((*ar)(stack)); + KN< L > *val = GetAny< KN< L > * >((*va)(stack)); + std::set< L > vals; + for (int i = 0; i < array->n; ++i) // if(!nargs[0] || (*array)[i] != remove) - vals.insert((*array)[i]); - if( nargs[0]) // remove - { - long remove = GetAny((*nargs[0])(stack)) ; - typename std::set::iterator lr = vals.find(remove); - if( lr != vals.end()) vals.erase(lr); - } - val->resize(vals.size()); - int i = 0; - for(typename std::set::iterator it = vals.begin(); it != vals.end(); ++it) - (*val)[i++] = *it; - return static_cast(vals.size()); + vals.insert((*array)[i]); + if (nargs[0]) // remove + { + long remove = GetAny< long >((*nargs[0])(stack)); + typename std::set< L >::iterator lr = vals.find(remove); + if (lr != vals.end( )) vals.erase(lr); + } + val->resize(vals.size( )); + int i = 0; + for (typename std::set< L >::iterator it = vals.begin( ); it != vals.end( ); ++it) (*val)[i++] = *it; + return static_cast< long >(vals.size( )); } +template< class K > +class E_ForAllLoopRNM { + public: + typedef KNM_< K > Tab; + typedef ForAllLoopOpBase DataL; + const DataL *data; + E_ForAllLoopRNM(const DataL *t) : data(t) {} + AnyType f(Stack s) const { + Tab t = GetAny< KNM_< K > >(data->tab(s)); + long *i = GetAny< long * >(data->i(s)); + long *j = GetAny< long * >(data->j(s)); + K *v = GetAny< K * >(data->v(s)); + if (verbosity > 1000) { + cout << i << " " << j << " " << v << " " << data->epl << endl; + cout << " i " << (char *)(void *)i - (char *)(void *)s; + cout << " j " << (char *)(void *)j - (char *)(void *)s; + cout << " vij " << (char *)(void *)v - (char *)(void *)s; + cout << endl; + } - - - -template -class E_ForAllLoopRNM -{ public: - typedef KNM_ Tab; - typedef ForAllLoopOpBase DataL; - const DataL *data; - E_ForAllLoopRNM(const DataL *t): data(t){} - AnyType f(Stack s) const { - Tab t= GetAny >(data->tab(s)); - long * i= GetAny(data->i(s)); - long * j= GetAny(data->j(s)); - K * v = GetAny(data->v(s)); - if(verbosity>1000) { - cout << i << " " << j << " " << v << " " << data->epl << endl; - cout << " i " << (char*) (void *) i - (char*)(void*) s ; - cout << " j " << (char*)(void *) j - (char*)(void*) s ; - cout << " vij " << (char*) (void *) v - (char*)(void*) s ; - cout << endl; + ffassert(i && j && v); + for (*i = 0; *i < t.N( ); ++*i) + for (*j = 0; *j < t.M( ); ++*j) { + *v = t(*i, *j); + try { + data->code(s); + t(*i, *j) = *v; + } catch (E_exception &e) { + if (e.code == E_exception::e_break) + break; + else if (e.code == E_exception::e_continue) + continue; + else + throw e; } - - ffassert(i && j && v); - for ( *i=0;*icode(s); - t(*i,*j)= *v; - } - catch ( E_exception & e) { - if (e.code == E_exception::e_break) break; - else if (e.code == E_exception::e_continue) continue; - else throw e; - } - - - } - // data->end(s); - return Nothing ; - } - + } + // data->end(s); + return Nothing; + } }; -template -class E_ForAllLoopRN -{ public: - typedef KN_ Tab; - typedef ForAllLoopOpBase DataL; - const DataL *data; - E_ForAllLoopRN(const DataL *t): data(t){} - AnyType f(Stack s) const { - Tab t= GetAny >(data->tab(s)); - long * i= GetAny(data->i(s)); - K * v = GetAny(data->v(s)); - // cout << i << " " << j << " " << v << " " << data->epl << endl; - if(verbosity>1000) { - cout << " i " << (char*) (void *) i - (char*)(void*) s ; - cout << " vi " << (char*) (void *) v - (char*)(void*) s ; - cout << endl; - } - - ffassert(i && v); - for ( *i=0;*icode(s); - t(*i)= *v; - } - catch ( E_exception & e) { - if (e.code == E_exception::e_break) break; - else if (e.code == E_exception::e_continue) continue; - else throw e; - } - - } - // data->end(s); - return Nothing ; +template< class K > +class E_ForAllLoopRN { + public: + typedef KN_< K > Tab; + typedef ForAllLoopOpBase DataL; + const DataL *data; + E_ForAllLoopRN(const DataL *t) : data(t) {} + AnyType f(Stack s) const { + Tab t = GetAny< KN_< K > >(data->tab(s)); + long *i = GetAny< long * >(data->i(s)); + K *v = GetAny< K * >(data->v(s)); + // cout << i << " " << j << " " << v << " " << data->epl << endl; + if (verbosity > 1000) { + cout << " i " << (char *)(void *)i - (char *)(void *)s; + cout << " vi " << (char *)(void *)v - (char *)(void *)s; + cout << endl; } + ffassert(i && v); + for (*i = 0; *i < t.N( ); ++*i) { + *v = t[*i]; + try { + data->code(s); + t(*i) = *v; + } catch (E_exception &e) { + if (e.code == E_exception::e_break) + break; + else if (e.code == E_exception::e_continue) + continue; + else + throw e; + } + } + // data->end(s); + return Nothing; + } }; -template -class E_ForAllLoopMapSI -{ public: - typedef String K; - typedef string *KK; - typedef V *VV; - - typedef MyMap *Tab; - typedef typename MyMap::iterator TabI ; - - typedef ForAllLoopOpBase DataL; - const DataL *data; - E_ForAllLoopMapSI(const DataL *t): data(t){} - AnyType f(Stack s) const { - Tab t= GetAny(data->tab(s)); - KK * i = GetAny(data->i(s)); - VV v = GetAny(data->v(s)); - // cout << i << " " << j << " " << v << " " << data->epl << endl; - if(verbosity>1000) { - cout << " i " << (char*) (void *) i - (char*)(void*) s ; - cout << " vi " << (char*) (void *) v - (char*)(void*) s ; - cout << endl; - } - - ffassert(i && v); - if(t->m) - for (TabI ii=t->m->begin();ii != t->m->end();++ii) - { - String kk = ii->first; - V vv = ii->second; - - *i = kk; - *v = vv; - // for Windows otherwise trap ???? FH. march 2016 - if(verbosity>99999) cout << " " << i << " "<< v << " " << kk << " " << vv << endl; - try { - data->code(s); - ii->second = *v; - } - catch ( E_exception & e) { - if (e.code == E_exception::e_break) break; - else if (e.code == E_exception::e_continue) continue; - else throw e; - } - - - *i=0; - } - // data->end(s); - return Nothing ; +template< class V > +class E_ForAllLoopMapSI { + public: + typedef String K; + typedef string *KK; + typedef V *VV; + + typedef MyMap< K, V > *Tab; + typedef typename MyMap< K, V >::iterator TabI; + + typedef ForAllLoopOpBase DataL; + const DataL *data; + E_ForAllLoopMapSI(const DataL *t) : data(t) {} + AnyType f(Stack s) const { + Tab t = GetAny< Tab >(data->tab(s)); + KK *i = GetAny< KK * >(data->i(s)); + VV v = GetAny< VV >(data->v(s)); + // cout << i << " " << j << " " << v << " " << data->epl << endl; + if (verbosity > 1000) { + cout << " i " << (char *)(void *)i - (char *)(void *)s; + cout << " vi " << (char *)(void *)v - (char *)(void *)s; + cout << endl; } + ffassert(i && v); + if (t->m) + for (TabI ii = t->m->begin( ); ii != t->m->end( ); ++ii) { + String kk = ii->first; + V vv = ii->second; + + *i = kk; + *v = vv; + // for Windows otherwise trap ???? FH. march 2016 + if (verbosity > 99999) cout << " " << i << " " << v << " " << kk << " " << vv << endl; + try { + data->code(s); + ii->second = *v; + } catch (E_exception &e) { + if (e.code == E_exception::e_break) + break; + else if (e.code == E_exception::e_continue) + continue; + else + throw e; + } + + *i = 0; + } + // data->end(s); + return Nothing; + } }; -template -KN_ getdiag_(KNM_ A) { - int n = A.N(), m=A.M(); - int nn= min(n,m); - int si= A.shapei.step; - //int ni =A.shapei.next; - int sj= A.shapej.step; - - KN_ d(A,SubArray(nn,0,sj+si)); - return d; -} -template -KN_ getdiag(KNM *pA) { - ffassert(pA); - return getdiag_(*pA); -} - -template -KN_ asarray(KNM *pA) { - ffassert( pA->IsVector1()); - return *pA; } +template< class K > +KN_< K > getdiag_(KNM_< K > A) { + int n = A.N( ), m = A.M( ); + int nn = min(n, m); + int si = A.shapei.step; + // int ni =A.shapei.next; + int sj = A.shapej.step; + + KN_< K > d(A, SubArray(nn, 0, sj + si)); + return d; +} +template< class K > +KN_< K > getdiag(KNM< K > *pA) { + ffassert(pA); + return getdiag_(*pA); +} + +template< class K > +KN_< K > asarray(KNM< K > *pA) { + ffassert(pA->IsVector1( )); + return *pA; +} // Add Oct 2019 -template -KNM * set_Eye(KNM *pA,const Eye eye) -{ - int n = eye.n, m=eye.m, nn= min(n,m); - if( init) pA->init(n,m); - else pA->resize(n,m); - *pA = K(); - KN_ d(*pA,SubArray(nn,0,n+1)); - d= K(1.); - return pA; +template< class K, bool init > +KNM< K > *set_Eye(KNM< K > *pA, const Eye eye) { + int n = eye.n, m = eye.m, nn = min(n, m); + if (init) + pA->init(n, m); + else + pA->resize(n, m); + *pA = K( ); + KN_< K > d(*pA, SubArray(nn, 0, n + 1)); + d = K(1.); + return pA; } extern aType aaaa_knlp; -template -void ArrayOperator() -{ - // juin 2009 remove type KN_< > * - // and set KN<> * 9left expression) qnd KN_<> is the associated expression.. - // => lot of change because KN<>* and KN_< > can generqte ambuguity. - // so remove all to code with KN<>* type. - // the remove cqde are in comment : - // the comment begin //- - // and the if(0) in comment /* */ - - - Dcl_Type< Resize > > (); - Dcl_Type< Resize > > (); - - //- typedef KN ZN; - - // add dec 2009. ne marche pas ( incompatible avec MatrixBlock) a comprendre ????? FH. - // // xxxxxxxxxx 2010 feb. retest .. FH - // il y a plusieurs problems - // 1) [1,2,3.] -> tableau de quel type int, real , complex ???? - // - // map_type[typeid(KN_).name()]->AddCast(new OneOperator_2KN_); - // fin add - // ---- - - atype* >()->Add("[","",new OneOperator2_*,Z >(get_elementp_*,Z>)); - atype* >()->Add("(","",new OneOperator2_*,Z >(get_elementp_*,Z>)); - atype >()->Add("(","",new OneOperator2_,KN_,char >(fSubArrayc >)); - atype >()->Add("(","",new OneOperator2_,KN_,SubArray>(fSubArray )); - atype*>()->Add("(","",new OneOperator2_,KN*,SubArray>(fSubArrayp )); - atype* >()->Add("(","",new OneOperator2_*,KN*,char >(fSubArrayc* >)); -// +template< class K, class Z > +void ArrayOperator( ) { + // juin 2009 remove type KN_< > * + // and set KN<> * 9left expression) qnd KN_<> is the associated expression.. + // => lot of change because KN<>* and KN_< > can generqte ambuguity. + // so remove all to code with KN<>* type. + // the remove cqde are in comment : + // the comment begin //- + // and the if(0) in comment /* */ + + Dcl_Type< Resize< KN< K > > >( ); + Dcl_Type< Resize< KNM< K > > >( ); + + //- typedef KN ZN; + + // add dec 2009. ne marche pas ( incompatible avec MatrixBlock) a comprendre ????? FH. + // // xxxxxxxxxx 2010 feb. retest .. FH + // il y a plusieurs problems + // 1) [1,2,3.] -> tableau de quel type int, real , complex ???? + // + // map_type[typeid(KN_).name()]->AddCast(new OneOperator_2KN_); + // fin add + // ---- + + atype< KN< K > * >( )->Add("[", "", new OneOperator2_< K *, KN< K > *, Z >(get_elementp_< K, KN< K > *, Z >)); + atype< KN< K > * >( )->Add("(", "", new OneOperator2_< K *, KN< K > *, Z >(get_elementp_< K, KN< K > *, Z >)); + atype< KN_< K > >( )->Add("(", "", new OneOperator2_< KN_< K >, KN_< K >, char >(fSubArrayc< KN_< K > >)); + atype< KN_< K > >( )->Add("(", "", new OneOperator2_< KN_< K >, KN_< K >, SubArray >(fSubArray< K >)); + atype< KN< K > * >( )->Add("(", "", new OneOperator2_< KN_< K >, KN< K > *, SubArray >(fSubArrayp< K >)); + atype< KN< K > * >( )->Add("(", "", new OneOperator2_< KN< K > *, KN< K > *, char >(fSubArrayc< KN< K > * >)); + // + + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< KNM_< K >, KNM_< K >, SubArray, SubArray >(fSubArraybb< K >)); + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< KNM_< K >, KNM< K > *, SubArray, SubArray >(fSubArraypbb< K >)); + /* + atype >()->Add("(","",new OneOperator3_,KNM_,SubArray,long>(fSubArraybi )); + atype >()->Add("(","",new OneOperator3_,KNM_,long,SubArray>(fSubArrayib )); + atype >()->Add("(","",new OneOperator3_,KNM*,SubArray,long>(fSubArraypbi )); + atype >()->Add("(","",new OneOperator3_,KNM*,long,SubArray>(fSubArraypib )); + */ + // + + atype< KN_< K > >( )->Add("[", "", new OneOperator2_< K *, KN_< K >, Z >(get_element_< K, KN_< K >, Z >)); + atype< KN_< K > >( )->Add("(", "", new OneOperator2_< K *, KN_< K >, Z >(get_element_< K, KN_< K >, Z >)); + + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM< K > *, Z, SubArray >(get_element_is< KN_< K >, KNM< K > *, Z, SubArray >)); + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM< K > *, SubArray, Z >(get_element_si< KN_< K >, KNM< K > *, SubArray, Z >)); + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM< K > *, Z, char >(get_element_lineorcol< KN_< K >, KNM< K > *, Z, char >)); + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM< K > *, char, Z >(get_element_lineorcol< KN_< K >, KNM< K > *, char, Z >)); + atype< KNM< K > * >( )->Add("(", "", new OneOperator3_< K *, KNM< K > *, Z, Z >(get_elementp2_< K, KNM< K > *, Z, Z >)); + + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM_< K >, Z, SubArray >(get_element_is_< KN_< K >, KNM_< K >, Z, SubArray >)); + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM_< K >, SubArray, Z >(get_element_si_< KN_< K >, KNM_< K >, SubArray, Z >)); + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM_< K >, Z, char >(get_element_lineorcol_< KN_< K >, KNM_< K >, Z, char >)); + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< KN_< K >, KNM_< K >, char, Z >(get_element_lineorcol_< KN_< K >, KNM_< K >, char, Z >)); + atype< KNM_< K > >( )->Add("(", "", new OneOperator3_< K *, KNM_< K >, Z, Z >(get_elementp2__< K, KNM_< K >, Z, Z >)); + + Add< KN< K > * >("sum", ".", new OneOperator1< K, KN< K > * >(get_sum)); + Add< KN< K > * >("min", ".", new OneOperator1< K, KN< K > * >(get_min)); + Add< KN< K > * >("max", ".", new OneOperator1< K, KN< K > * >(get_max)); + + Add< KN< K > * >("l2", ".", new OneOperator1< double, KN< K > * >(get_l2)); + Add< KN< K > * >("l1", ".", new OneOperator1< double, KN< K > * >(get_l1)); + Add< KN< K > * >("linfty", ".", new OneOperator1< double, KN< K > * >(get_linfty)); + // add july 2009 + Add< KNM< K > * >("sum", ".", new OneOperator1< K, KNM< K > * >(get_sum)); + Add< KNM< K > * >("min", ".", new OneOperator1< K, KNM< K > * >(get_min)); + Add< KNM< K > * >("max", ".", new OneOperator1< K, KNM< K > * >(get_max)); + Add< KNM< K > * >("l2", ".", new OneOperator1< double, KNM< K > * >(get_l2)); + Add< KNM< K > * >("l1", ".", new OneOperator1< double, KNM< K > * >(get_l1)); + Add< KNM< K > * >("linfty", ".", new OneOperator1< double, KNM< K > * >(get_linfty)); + // end add + + Add< KN_< K > >("sum", ".", new OneOperator1_< K, KN_< K > >(get_sum0< K, KN_< K > >)); + Add< KN_< K > >("min", ".", new OneOperator1_< K, KN_< K > >(get_min0< K, KN_< K > >)); + Add< KN_< K > >("max", ".", new OneOperator1_< K, KN_< K > >(get_max0< K, KN_< K > >)); + Add< KN_< K > >("l2", ".", new OneOperator1_< double, KN_< K > >(get_l2_0< double, KN_< K > >)); + Add< KN_< K > >("l1", ".", new OneOperator1_< double, KN_< K > >(get_l1_0< double, KN_< K > >)); + Add< KN_< K > >("linfty", ".", new OneOperator1_< double, KN_< K > >(get_linfty_0< double, KN_< K > >)); + + // add july 2009 + Add< KNM_< K > >("sum", ".", new OneOperator1_< K, KNM_< K > >(get_sum0< K, KNM_< K > >)); + Add< KNM_< K > >("min", ".", new OneOperator1_< K, KNM_< K > >(get_min0< K, KNM_< K > >)); + Add< KNM_< K > >("max", ".", new OneOperator1_< K, KNM_< K > >(get_max0< K, KNM_< K > >)); + Add< KNM_< K > >("l2", ".", new OneOperator1_< double, KNM_< K > >(get_l2_0< double, KNM_< K > >)); + Add< KNM_< K > >("l1", ".", new OneOperator1_< double, KNM_< K > >(get_l1_0< double, KNM_< K > >)); + Add< KNM_< K > >("linfty", ".", new OneOperator1_< double, KNM_< K > >(get_linfty_0< double, KNM_< K > >)); + // end add - atype >()->Add("(","",new OneOperator3_,KNM_,SubArray,SubArray>(fSubArraybb )); - atype* >()->Add("(","",new OneOperator3_,KNM*,SubArray,SubArray>(fSubArraypbb )); - /* - atype >()->Add("(","",new OneOperator3_,KNM_,SubArray,long>(fSubArraybi )); - atype >()->Add("(","",new OneOperator3_,KNM_,long,SubArray>(fSubArrayib )); - atype >()->Add("(","",new OneOperator3_,KNM*,SubArray,long>(fSubArraypbi )); - atype >()->Add("(","",new OneOperator3_,KNM*,long,SubArray>(fSubArraypib )); - */ -// + /* + Add >("sum",".", new OneOperator1_ >(get_sum0 >)); + Add >("min",".", new OneOperator1_ >(get_min0 >)); + Add >("max",".", new OneOperator1_ >(get_max0 >)); + Add >("l2",".", new OneOperator1_ >(get_l2_0 >)); + Add >("l1",".", new OneOperator1_ >(get_l1_0 >)); + Add >("linfty",".",new OneOperator1_ >(get_linfty_0 >)); + */ + + Add< KN< K > * >("resize", ".", new OneOperator1< Resize< KN< K > >, KN< K > * >(to_Resize)); + Add< KNM< K > * >("resize", ".", new OneOperator1< Resize< KNM< K > >, KNM< K > * >(to_Resize)); + + Add< Resize< KN< K > > >("(", "", new OneOperator2_< KN< K > *, Resize< KN< K > >, Z >(resize1)); + Add< Resize< KNM< K > > >("(", "", new OneOperator3_< KNM< K > *, Resize< KNM< K > >, Z, Z >(resize2)); + + TheOperators->Add("<-", + // new OneOperator2_ *,KN *,R3>(&set_initR3), + // new OneOperator2_ *,KN *,R3*>(&set_initR3), + + new OneOperator2_< KN< K > *, KN< K > *, Z >(&set_init), new InitArrayfromArray< K, KN< K > *, true > + // new OneOperator2_ *,KN *,KN >(&set_init), + // new OneOperator2_ *,KN *,KN_ >(&set_init) ???? + // new OneOperator2_ *,KN *,KN * >(&set_initp) + ); + TheOperators->Add("<-", new OneOperator2_< KN< KN< K > > *, KN< KN< K > > *, Z >(&set_init)); + TheOperators->Add("<-", new OneOperator2_< KN< KNM< K > > *, KN< KNM< K > > *, Z >(&set_init)); + + TheOperators->Add("<-", new OneOperator3_< KNM< K > *, KNM< K > *, Z, Z >(&set_init2), new InitMatfromAArray< K, true, false >, new InitMatfromAArray< K, true, true >); + + Add< KN< K > * >("<-", "(", new OneOperator2_< KN< K > *, KN< K > *, Z >(&set_init)); + // Add *>("<-","(",new OneOperator2_ *,KN *,KN >(&set_init)); + // Add *>("<-","(",new OneOperator2_ *,KN *,KN_ >(&set_init)); + // Add *>("<-","(",new OneOperator2_ *,KN *,KN * >(&set_initp)); + Add< KNM< K > * >("<-", "(", new OneOperator3_< KNM< K > *, KNM< K > *, Z, Z >(&set_init2)); + TheOperators->Add("<-", new OneOperator2< KNM< K > *, KNM< K > *, Transpose< KNM< K > * > >(&set_initmat_t)); // may 2011 FH.. + TheOperators->Add("=", new OneOperator2< KNM< K > *, KNM< K > *, Eye >(set_Eye< K, false >)); // may 2011 FH.. + TheOperators->Add("<-", new OneOperator2< KNM< K > *, KNM< K > *, Eye >(set_Eye< K, true >)); // may 2011 FH.. + TheOperators->Add("=", new OneOperator2< KNM< K > *, KNM< K > *, Transpose< KNM< K > * > >(&set_mat_t)); // may 2011 FH.. + TheOperators->Add("+=", new OneOperator2< KNM< K > *, KNM< K > *, Transpose< KNM< K > * > >(&addto_mat_t)); // oct 2011 FH.. + TheOperators->Add("-=", new OneOperator2< KNM< K > *, KNM< K > *, Transpose< KNM< K > * > >(&subto_mat_t)); // oct 2011 FH.. + // TheOperators->Add("-=",new OneOperator2 *,KNM *,Transpose * > >(&subto_mat_t<-1>));// oct 2011 FH.. + // Add *>("<-","(",new OneOperator2 *,KNM *,KNM * >(&set_initmat));// may 2011 FH.. + // Add *>("=","(",new OneOperator2 *,KNM *,Transpose * > >(&set_mat_t));// may 2011 FH.. + // Add *>("=","(",new OneOperator2 *,KNM *,KNM * >(&set_mat));// may 2011 FH.. + + // Add *>("=","(",new OneOperator2_ *,KNM *,Transpose * > >(&set_tt)); + + Add< KN< K > * >("<-", "(", new InitArrayfromArray< K, KN< K > *, true >); + Add< KNM< K > * >("<-", "(", new InitMatfromAArray< K, true, false >); + Add< KNM< K > * >("<-", "(", new InitMatfromAArray< K, true, true >); + Add< KN< K > * >("n", ".", new OneOperator1< Z, KN< K > * >(get_n)); + Add< KN_< K > >("n", ".", new OneOperator1< Z, KN_< K > >(get__n)); + Add< KNM< K > * >("n", ".", new OneOperator1< Z, KNM< K > * >(get_n)); + Add< KNM< K > * >("m", ".", new OneOperator1< Z, KNM< K > * >(get_m)); + Add< KNM_< K > >("n", ".", new OneOperator1< Z, KNM_< K > >(get__n)); + Add< KNM_< K > >("m", ".", new OneOperator1< Z, KNM_< K > >(get__m)); + // ajout ars 2012 FH + Add< KN< KN< K > > * >("n", ".", new OneOperator1< long, KN< KN< K > > * >(get_n)); + Add< KN< KNM< K > > * >("n", ".", new OneOperator1< long, KN< KNM< K > > * >(get_n)); + atype< KN< KN< K > > * >( )->Add("[", "", new OneOperator2_< KN< K > *, KN< KN< K > > *, Z >(get_elementp_< KN< K >, KN< KN< K > > *, Z >)); + atype< KN< KNM< K > > * >( )->Add("[", "", new OneOperator2_< KNM< K > *, KN< KNM< K > > *, Z >(get_elementp_< KNM< K >, KN< KNM< K > > *, Z >)); + Dcl_Type< Resize< KN< KN< K > > > >( ); + Dcl_Type< Resize< KN< KNM< K > > > >( ); + Add< KN< KN< K > > * >("resize", ".", new OneOperator1< Resize< KN< KN< K > > >, KN< KN< K > > * >(to_Resize)); + Add< KN< KNM< K > > * >("resize", ".", new OneOperator1< Resize< KN< KNM< K > > >, KN< KNM< K > > * >(to_Resize)); + Add< Resize< KN< KN< K > > > >("(", "", new OneOperator2_< KN< KN< K > > *, Resize< KN< KN< K > > >, long >(resize1)); + Add< Resize< KN< KNM< K > > > >("(", "", new OneOperator2_< KN< KNM< K > > *, Resize< KN< KNM< K > > >, long >(resize1)); + Dcl_Type< Mul_KNMh_KN_< K > >( ); + // AddOpeqarray("="); + + TheOperators->Add("=", new InitArrayfromArray< K, KN< K > *, false >(10)); + TheOperators->Add("=", new InitArrayfromArray< K, KN_< K >, false >(1)); // ???????? FH nov 2015 .. + TheOperators->Add("=", new InitMatfromAArray< K, false, false >, new InitMatfromAArray< K, false, true >); + TheOperators->Add("=", new SetArrayofKNfromKN< K >); + // add august 2007 - atype >()->Add("[","",new OneOperator2_,Z >(get_element_,Z>)); - atype >()->Add("(","",new OneOperator2_,Z >(get_element_,Z>)); - - - atype* >()->Add("(","",new OneOperator3_,KNM*,Z,SubArray >(get_element_is,KNM*,Z,SubArray>)); - atype* >()->Add("(","",new OneOperator3_,KNM*,SubArray,Z >(get_element_si,KNM*,SubArray,Z>)); - atype* >()->Add("(","",new OneOperator3_,KNM*,Z,char >(get_element_lineorcol,KNM*,Z,char>)); - atype* >()->Add("(","",new OneOperator3_,KNM*,char,Z >(get_element_lineorcol,KNM*,char,Z>)); - atype* >()->Add("(","",new OneOperator3_*,Z,Z >(get_elementp2_*,Z,Z>)); - - atype >()->Add("(","",new OneOperator3_,KNM_,Z,SubArray >(get_element_is_,KNM_,Z,SubArray>)); - atype >()->Add("(","",new OneOperator3_,KNM_,SubArray,Z >(get_element_si_,KNM_,SubArray,Z>)); - atype >()->Add("(","",new OneOperator3_,KNM_,Z,char >(get_element_lineorcol_,KNM_,Z,char>)); - atype >()->Add("(","",new OneOperator3_,KNM_,char,Z >(get_element_lineorcol_,KNM_,char,Z>)); - atype >()->Add("(","",new OneOperator3_,Z,Z >(get_elementp2__,Z,Z>)); - - - Add *>("sum",".",new OneOperator1 *>(get_sum)); - Add *>("min",".",new OneOperator1 *>(get_min)); - Add *>("max",".",new OneOperator1 *>(get_max)); - - Add *>("l2",".",new OneOperator1 *>(get_l2)); - Add *>("l1",".",new OneOperator1 *>(get_l1)); - Add *>("linfty",".",new OneOperator1 *>(get_linfty)); -// add july 2009 - Add *>("sum",".",new OneOperator1 *>(get_sum)); - Add *>("min",".",new OneOperator1 *>(get_min)); - Add *>("max",".",new OneOperator1 *>(get_max)); - Add *>("l2",".",new OneOperator1 *>(get_l2)); - Add *>("l1",".",new OneOperator1 *>(get_l1)); - Add *>("linfty",".",new OneOperator1 *>(get_linfty)); -// end add - - Add >("sum",".",new OneOperator1_ >(get_sum0 >)); - Add >("min",".",new OneOperator1_ >(get_min0 >)); - Add >("max",".",new OneOperator1_ >(get_max0 >)); - Add >("l2",".",new OneOperator1_ >(get_l2_0 >)); - Add >("l1",".",new OneOperator1_ >(get_l1_0 >)); - Add >("linfty",".",new OneOperator1_ >(get_linfty_0 >)); - -// add july 2009 - Add >("sum",".",new OneOperator1_ >(get_sum0 >)); - Add >("min",".",new OneOperator1_ >(get_min0 >)); - Add >("max",".",new OneOperator1_ >(get_max0 >)); - Add >("l2",".",new OneOperator1_ >(get_l2_0 >)); - Add >("l1",".",new OneOperator1_ >(get_l1_0 >)); - Add >("linfty",".",new OneOperator1_ >(get_linfty_0 >)); -// end add + TheOperators->Add("<-", + // new OneBinaryOperator ,K > > , + new OneBinaryOperator< init_eqarray< KN< K >, Add_KN_< K > > >, new OneBinaryOperator< init_eqarray< KN< K >, DotStar_KN_< K > > >, + new OneBinaryOperator< init_eqarray< KN< K >, DotSlash_KN_< K > > >, new OneBinaryOperator< init_eqarray< KN< K >, Sub_KN_< K > > >, + new OneBinaryOperator< init_eqarray< KN< K >, Mulc_KN_< K > > >, new OneBinaryOperator< init_eqarray< KN< K >, Divc_KN_< K > > >, + new OneBinaryOperator< init_eqarray< KN< K >, Mul_KNM_KN_< K > > >, new OneBinaryOperator< init_eqarray< KN< K >, KN_< K > > >, // Add FH juin 2005 + new OneBinaryOperator< init_eqarraypd< KN< K >, Add_Mulc_KN_< K > * > >, // Add FH aug 2005 + new OneBinaryOperator< init_eqarraypd< KN< K >, if_arth_KN_< K > * > > + // new OneBinaryOperator ,KN* > > + ); + TheOperators->Add("=", new OneBinaryOperator< set_eqarray< KNM< K >, K > >, new OneBinaryOperator< set_eqarrayp< KNM< K >, KNM< K > * > > -/* - Add >("sum",".", new OneOperator1_ >(get_sum0 >)); - Add >("min",".", new OneOperator1_ >(get_min0 >)); - Add >("max",".", new OneOperator1_ >(get_max0 >)); - Add >("l2",".", new OneOperator1_ >(get_l2_0 >)); - Add >("l1",".", new OneOperator1_ >(get_l1_0 >)); - Add >("linfty",".",new OneOperator1_ >(get_linfty_0 >)); -*/ + ); - Add *>("resize",".",new OneOperator1< Resize >,KN *>(to_Resize)); - Add *>("resize",".",new OneOperator1< Resize >,KNM *>(to_Resize)); - - Add > >("(","",new OneOperator2_ *,Resize > , Z >(resize1)); - Add > >("(","",new OneOperator3_ *,Resize > , Z, Z >(resize2)); - - - TheOperators->Add("<-", - // new OneOperator2_ *,KN *,R3>(&set_initR3), - // new OneOperator2_ *,KN *,R3*>(&set_initR3), - - new OneOperator2_ *,KN *,Z>(&set_init), - new InitArrayfromArray*,true> - // new OneOperator2_ *,KN *,KN >(&set_init), - // new OneOperator2_ *,KN *,KN_ >(&set_init) ???? - // new OneOperator2_ *,KN *,KN * >(&set_initp) - ); - TheOperators->Add("<-", - new OneOperator2_ > *,KN< KN > * ,Z >(&set_init)); - TheOperators->Add("<-", - new OneOperator2_ > *,KN< KNM > * ,Z >(&set_init)); - - TheOperators->Add("<-", - new OneOperator3_ *,KNM *,Z,Z>(&set_init2), - new InitMatfromAArray, - new InitMatfromAArray - ); - - Add *>("<-","(",new OneOperator2_ *,KN *,Z>(&set_init)); - // Add *>("<-","(",new OneOperator2_ *,KN *,KN >(&set_init)); - //Add *>("<-","(",new OneOperator2_ *,KN *,KN_ >(&set_init)); - // Add *>("<-","(",new OneOperator2_ *,KN *,KN * >(&set_initp)); - Add *>("<-","(",new OneOperator3_ *,KNM *,Z,Z>(&set_init2)); - TheOperators->Add("<-",new OneOperator2 *,KNM *,Transpose * > >(&set_initmat_t));// may 2011 FH.. - TheOperators->Add("=",new OneOperator2 *,KNM *, Eye >(set_Eye));// may 2011 FH.. - TheOperators->Add("<-",new OneOperator2 *,KNM *, Eye >(set_Eye));// may 2011 FH.. - TheOperators->Add("=",new OneOperator2 *,KNM *,Transpose * > >(&set_mat_t));// may 2011 FH.. - TheOperators->Add("+=",new OneOperator2 *,KNM *,Transpose * > >(&addto_mat_t));// oct 2011 FH.. - TheOperators->Add("-=",new OneOperator2 *,KNM *,Transpose * > >(&subto_mat_t));// oct 2011 FH.. -// TheOperators->Add("-=",new OneOperator2 *,KNM *,Transpose * > >(&subto_mat_t<-1>));// oct 2011 FH.. - // Add *>("<-","(",new OneOperator2 *,KNM *,KNM * >(&set_initmat));// may 2011 FH.. - // Add *>("=","(",new OneOperator2 *,KNM *,Transpose * > >(&set_mat_t));// may 2011 FH.. - // Add *>("=","(",new OneOperator2 *,KNM *,KNM * >(&set_mat));// may 2011 FH.. + TheOperators->Add("=", new OneBinaryOperator< set_eq_array< KN_< K >, K > >, new OneBinaryOperator< set_eq_array< KN_< K >, Add_KN_< K > > >, + new OneBinaryOperator< set_eq_array< KN_< K >, DotStar_KN_< K > > >, new OneBinaryOperator< set_eq_array< KN_< K >, DotSlash_KN_< K > > >, + new OneBinaryOperator< set_eq_array< KN_< K >, Sub_KN_< K > > >, new OneBinaryOperator< set_eq_array< KN_< K >, Mulc_KN_< K > > >, + new OneBinaryOperator< set_eq_array< KN_< K >, Divc_KN_< K > > >, new OneBinaryOperator< set_eq_array< KN_< K >, Mul_KNM_KN_< K > > >, + new OneBinaryOperator< set_eq_arraypd< KN_< K >, if_arth_KN_< K > * > >, new OneBinaryOperator< set_eq_arraypd< KN_< K >, Add_Mulc_KN_< K > * > >, // Add FH aug 2005 + new OneBinaryOperator< set_eq_array< KN_< K >, KN_< K > > >, // add FH juin 2005 + new OneBinaryOperator< set_eq_arraypd< KN_< K >, KN< K > * > > - // Add *>("=","(",new OneOperator2_ *,KNM *,Transpose * > >(&set_tt)); - - Add *>("<-","(",new InitArrayfromArray*,true>); - Add *>("<-","(",new InitMatfromAArray); - Add *>("<-","(",new InitMatfromAArray); - Add *>("n",".",new OneOperator1 *>(get_n)); - Add >("n",".",new OneOperator1 >(get__n)); - Add *>("n",".",new OneOperator1 *>(get_n)); - Add *>("m",".",new OneOperator1 *>(get_m)); - Add >("n",".",new OneOperator1 >(get__n)); - Add >("m",".",new OneOperator1 >(get__m)); - //ajout ars 2012 FH - Add > *>("n",".",new OneOperator1 > *>(get_n)); - Add > *>("n",".",new OneOperator1 > *>(get_n)); - atype > * >()->Add("[","",new OneOperator2_*,KN >*,Z >(get_elementp_,KN >*,Z>)); - atype > * >()->Add("[","",new OneOperator2_*,KN >*,Z >(get_elementp_,KN >*,Z>)); - Dcl_Type< Resize > > > (); - Dcl_Type< Resize > > >(); - Add > * >("resize",".",new OneOperator1< Resize > >,KN > *>(to_Resize)); - Add > * >("resize",".",new OneOperator1< Resize > >,KN > *>(to_Resize)); - Add > > >("(","",new OneOperator2_ > *,Resize > > , long >(resize1)); - Add > > >("(","",new OneOperator2_ > *,Resize > > , long >(resize1)); - Dcl_Type >(); -// AddOpeqarray("="); - - TheOperators->Add("=", new InitArrayfromArray*,false>(10)); - TheOperators->Add("=", new InitArrayfromArray,false>(1));// ???????? FH nov 2015 .. - TheOperators->Add("=", new InitMatfromAArray, - new InitMatfromAArray - ); - TheOperators->Add("=", new SetArrayofKNfromKN - ); - // add august 2007 + //- new OneBinaryOperator ,KN* > > + ); + // ajoute mars 2010 FH + TheOperators->Add("<-", new OneBinaryOperator< init_eqarray< KNM< K >, KNM_< K > > >); - TheOperators->Add("<-", - // new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,KN_ > > , // Add FH juin 2005 - new OneBinaryOperator ,Add_Mulc_KN_* > > , // Add FH aug 2005 - new OneBinaryOperator ,if_arth_KN_* > > - // new OneBinaryOperator ,KN* > > - ); - - - TheOperators->Add("=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator , KNM * > > - - ); - - TheOperators->Add("=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,if_arth_KN_* > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , // Add FH aug 2005 - new OneBinaryOperator ,KN_ > >, // add FH juin 2005 - new OneBinaryOperator ,KN* > > - - //- new OneBinaryOperator ,KN* > > - ); -// ajoute mars 2010 FH - TheOperators->Add("<-", - new OneBinaryOperator ,KNM_ > > - ); - - TheOperators->Add("=", - new OneBinaryOperator ,KNM_ > > - - // new OneBinaryOperator ,K > > , - // new OneBinaryOperator ,KNM_ > >, - // new OneBinaryOperator ,KNM* > > - ); - -// end add ... -/*if(0) - TheOperators->Add("+=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,if_arth_KN_* > > , - new OneBinaryOperator ,KN_ > > , // Add FH juin 2005 - new OneBinaryOperator ,KN* > > - - ); -*/ - TheOperators->Add("+=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,if_arth_KN_* > > , - new OneBinaryOperator ,KN_ > > // add FH juin 2005 - - // new OneBinaryOperator ,KN* > > - ); -/* if(0) - TheOperators->Add("-=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,if_arth_KN_* > > , - new OneBinaryOperator ,KN_ > > , // Add FH juin 2005 - new OneBinaryOperator ,KN* > > - );*/ - - TheOperators->Add("-=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,DotStar_KN_ > > , - new OneBinaryOperator ,DotSlash_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,if_arth_KN_* > > , - //- new OneBinaryOperator ,KN* > > - new OneBinaryOperator ,KN_ > > // Add FH juin 2005 - ); - -/* if(0) - TheOperators->Add("*=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,KN* > > - );*/ + TheOperators->Add("=", new OneBinaryOperator< set_eqarray< KNM< K >, KNM_< K > > > + + // new OneBinaryOperator ,K > > , + // new OneBinaryOperator ,KNM_ > >, + // new OneBinaryOperator ,KNM* > > + ); + // end add ... + /*if(0) + TheOperators->Add("+=", + new OneBinaryOperator ,K > > , + new OneBinaryOperator ,Add_KN_ > > , + new OneBinaryOperator ,DotStar_KN_ > > , + new OneBinaryOperator ,DotSlash_KN_ > > , + new OneBinaryOperator ,Sub_KN_ > > , + new OneBinaryOperator ,Mulc_KN_ > > , + new OneBinaryOperator ,Mul_KNM_KN_ > > , + new OneBinaryOperator ,Add_Mulc_KN_* > > , + new OneBinaryOperator ,if_arth_KN_* > > , + new OneBinaryOperator ,KN_ > > , // Add FH juin 2005 + new OneBinaryOperator ,KN* > > + + ); + */ + TheOperators->Add("+=", new OneBinaryOperator< set_eq_array_add< KN_< K >, K > >, new OneBinaryOperator< set_eq_array_add< KN_< K >, Add_KN_< K > > >, + new OneBinaryOperator< set_eq_array_add< KN_< K >, DotStar_KN_< K > > >, new OneBinaryOperator< set_eq_array_add< KN_< K >, DotSlash_KN_< K > > >, + new OneBinaryOperator< set_eq_array_add< KN_< K >, Sub_KN_< K > > >, new OneBinaryOperator< set_eq_array_add< KN_< K >, Mulc_KN_< K > > >, + new OneBinaryOperator< set_eq_array_add< KN_< K >, Divc_KN_< K > > >, new OneBinaryOperator< set_eq_array_add< KN_< K >, Mul_KNM_KN_< K > > >, + new OneBinaryOperator< set_eq_arraypd_add< KN_< K >, Add_Mulc_KN_< K > * > >, new OneBinaryOperator< set_eq_arraypd_add< KN_< K >, if_arth_KN_< K > * > >, + new OneBinaryOperator< set_eq_array_add< KN_< K >, KN_< K > > > // add FH juin 2005 + + // new OneBinaryOperator ,KN* > > + ); + /* if(0) + TheOperators->Add("-=", + new OneBinaryOperator ,K > > , + new OneBinaryOperator ,Add_KN_ > > , + new OneBinaryOperator ,DotStar_KN_ > > , + new OneBinaryOperator ,DotSlash_KN_ > > , + new OneBinaryOperator ,Sub_KN_ > > , + new OneBinaryOperator ,Mulc_KN_ > > , + new OneBinaryOperator ,Mul_KNM_KN_ > > , + new OneBinaryOperator ,Add_Mulc_KN_* > > , + new OneBinaryOperator ,if_arth_KN_* > > , + new OneBinaryOperator ,KN_ > > , // Add FH juin 2005 + new OneBinaryOperator ,KN* > > + );*/ + + TheOperators->Add("-=", new OneBinaryOperator< set_eq_array_sub< KN_< K >, K > >, new OneBinaryOperator< set_eq_array_sub< KN_< K >, Add_KN_< K > > >, + new OneBinaryOperator< set_eq_array_sub< KN_< K >, DotStar_KN_< K > > >, new OneBinaryOperator< set_eq_array_sub< KN_< K >, DotSlash_KN_< K > > >, + new OneBinaryOperator< set_eq_array_sub< KN_< K >, Sub_KN_< K > > >, new OneBinaryOperator< set_eq_array_sub< KN_< K >, Mulc_KN_< K > > >, + new OneBinaryOperator< set_eq_array_sub< KN_< K >, Divc_KN_< K > > >, new OneBinaryOperator< set_eq_array_sub< KN_< K >, Mul_KNM_KN_< K > > >, + new OneBinaryOperator< set_eq_arraypd_sub< KN_< K >, Add_Mulc_KN_< K > * > >, new OneBinaryOperator< set_eq_arraypd_sub< KN_< K >, if_arth_KN_< K > * > >, + //- new OneBinaryOperator ,KN* > > + new OneBinaryOperator< set_eq_array_sub< KN_< K >, KN_< K > > > // Add FH juin 2005 + ); + + /* if(0) TheOperators->Add("*=", - new OneBinaryOperator ,K > > ); - TheOperators->Add(".*=", - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - //- new OneBinaryOperator ,KN* > > - new OneBinaryOperator ,KN_ > > - ); -// FH correction 01 nov 2005 FH copy paste mistake eq_ exchange ok v2.0-3 -/* if(0) - TheOperators->Add("/=", - new OneBinaryOperator ,K > > , - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,KN_ > > - );*/ - - TheOperators->Add("/=", - new OneBinaryOperator ,K > > ); - TheOperators->Add("./=", - new OneBinaryOperator ,Add_KN_ > > , - new OneBinaryOperator ,Sub_KN_ > > , - new OneBinaryOperator ,Mulc_KN_ > > , - new OneBinaryOperator ,Divc_KN_ > > , - new OneBinaryOperator ,Mul_KNM_KN_ > > , - new OneBinaryOperator ,Add_Mulc_KN_* > > , - new OneBinaryOperator ,KN_ > > - ); -// end correction - TheOperators->Add("+", - new OneBinaryOperator,KN_,KN_ > >, - //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), - new OneBinaryOperator,Mulc_KN_,Mulc_KN_ > >, - new OneBinaryOperator,KN_,Mulc_KN_ > >, - new OneBinaryOperator,Mulc_KN_ ,KN_ > > - ); - - TheOperators->Add("-", - new OneBinaryOperator,KN_ ,KN_ > >, - //- new OneBinaryOperator,KN_ ,KN_ > >(knrp,knrp), - new OneUnaryOperator,KN_ > >, - new OneBinaryOperator,Mulc_KN_,Mulc_KN_ > >, - new OneBinaryOperator,KN_,Mulc_KN_ > >, - new OneBinaryOperator,Mulc_KN_ ,KN_ > > - ); - - TheOperators->Add("*", - //- new OneBinaryOperator,KN*,K> >, - //- new OneBinaryOperator,K,KN*> >, - new OneBinaryOperator,KN_,K> >, - new OneBinaryOperator,K,KN_ > >, - new OneBinaryOperator,KNM*,KN*> >,// A*b zzzzzzz - - // new OneBinaryOperator,KNM_,KN_> >, // - add #1 mqi 2009 - // new OneBinaryOperator >, - new OneBinaryOperator > - //- ,new OneBinaryOperator,KN*,Transpose > > > - // ,new OneBinaryOperatorBug >,KNM* > - ,new OneBinaryOperatorBug >,KNM_ > - ,new OneBinaryOperatorBug >,Transpose* > > - - ,new OneBinaryOperator,KN_,Transpose > > > - ,new OneBinaryOperator,Mulc_KN_,Transpose > > > - - ); - TheOperators->Add("*", new OneBinaryOperator, Transpose*>, KN*> >); // A'*b - TheOperators->Add("=", new OneBinaryOperator, Mul_KNMh_KN_ > >); - TheOperators->Add("<-", new OneBinaryOperator, Mul_KNMh_KN_ > >); - - TheOperators->Add("/", - new OneBinaryOperator,K,KN_ > >, - new OneBinaryOperator,KN_,K > > - - ); - -// nouvel operateur - TheOperators->Add("+=", - new OneBinaryOperator ,outProduct_KN_* > > - ); - - TheOperators->Add("-=", - new OneBinaryOperator ,outProduct_KN_* > > - ); - - TheOperators->Add("=", - new OneBinaryOperator ,outProduct_KN_* > > - ); -// tested ok ... FH - TheOperators->Add("?:", - new OneTernaryOperator3, KN_ > > , - new OneTernaryOperator3 > , - new OneTernaryOperator3 > , - new OneTernaryOperator3 > - - ); -// end ... + new OneBinaryOperator ,K > > , + new OneBinaryOperator ,Add_KN_ > > , + new OneBinaryOperator ,Sub_KN_ > > , + new OneBinaryOperator ,Mulc_KN_ > > , + new OneBinaryOperator ,Mul_KNM_KN_ > > , + new OneBinaryOperator ,Add_Mulc_KN_* > > , + new OneBinaryOperator ,KN* > > + );*/ + + TheOperators->Add("*=", new OneBinaryOperator< set_eq_array_mul< KN_< K >, K > >); + TheOperators->Add(".*=", new OneBinaryOperator< set_eq_array_mul< KN_< K >, Add_KN_< K > > >, new OneBinaryOperator< set_eq_array_mul< KN_< K >, Sub_KN_< K > > >, + new OneBinaryOperator< set_eq_array_mul< KN_< K >, Mulc_KN_< K > > >, new OneBinaryOperator< set_eq_array_mul< KN_< K >, Divc_KN_< K > > >, + new OneBinaryOperator< set_eq_array_mul< KN_< K >, Mul_KNM_KN_< K > > >, new OneBinaryOperator< set_eq_arraypd_mul< KN_< K >, Add_Mulc_KN_< K > * > >, + //- new OneBinaryOperator ,KN* > > + new OneBinaryOperator< set_eq_array_mul< KN_< K >, KN_< K > > >); + // FH correction 01 nov 2005 FH copy paste mistake eq_ exchange ok v2.0-3 + /* if(0) + TheOperators->Add("/=", + new OneBinaryOperator ,K > > , + new OneBinaryOperator ,Add_KN_ > > , + new OneBinaryOperator ,Sub_KN_ > > , + new OneBinaryOperator ,Mulc_KN_ > > , + new OneBinaryOperator ,Mul_KNM_KN_ > > , + new OneBinaryOperator ,Add_Mulc_KN_* > > , + new OneBinaryOperator ,KN_ > > + );*/ + + TheOperators->Add("/=", new OneBinaryOperator< set_eq_array_div< KN_< K >, K > >); + TheOperators->Add("./=", new OneBinaryOperator< set_eq_array_div< KN_< K >, Add_KN_< K > > >, new OneBinaryOperator< set_eq_array_div< KN_< K >, Sub_KN_< K > > >, + new OneBinaryOperator< set_eq_array_div< KN_< K >, Mulc_KN_< K > > >, new OneBinaryOperator< set_eq_array_div< KN_< K >, Divc_KN_< K > > >, + new OneBinaryOperator< set_eq_array_div< KN_< K >, Mul_KNM_KN_< K > > >, new OneBinaryOperator< set_eq_arraypd_div< KN_< K >, Add_Mulc_KN_< K > * > >, + new OneBinaryOperator< set_eq_array_div< KN_< K >, KN_< K > > >); + // end correction + TheOperators->Add("+", new OneBinaryOperator< Op2_add0< Add_KN_< K >, KN_< K >, KN_< K > > >, + //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), + new OneBinaryOperator< Op2_add__n< Add_Mulc_KN_< K >, Mulc_KN_< K >, Mulc_KN_< K > > >, new OneBinaryOperator< Op2_add__n< Add_Mulc_KN_< K >, KN_< K >, Mulc_KN_< K > > >, + new OneBinaryOperator< Op2_add__n< Add_Mulc_KN_< K >, Mulc_KN_< K >, KN_< K > > >); + + TheOperators->Add("-", new OneBinaryOperator< Op2_sub0< Sub_KN_< K >, KN_< K >, KN_< K > > >, + //- new OneBinaryOperator,KN_ ,KN_ > >(knrp,knrp), + new OneUnaryOperator< Op1_sub< Mulc_KN_< K >, KN_< K > > >, new OneBinaryOperator< Op2_sub__n< Add_Mulc_KN_< K >, Mulc_KN_< K >, Mulc_KN_< K > > >, + new OneBinaryOperator< Op2_sub__n< Add_Mulc_KN_< K >, KN_< K >, Mulc_KN_< K > > >, new OneBinaryOperator< Op2_sub__n< Add_Mulc_KN_< K >, Mulc_KN_< K >, KN_< K > > >); + + TheOperators->Add("*", + //- new OneBinaryOperator,KN*,K> >, + //- new OneBinaryOperator,K,KN*> >, + new OneBinaryOperator< Op2_mulc< Mulc_KN_< K >, KN_< K >, K > >, new OneBinaryOperator< Op2_mulc< Mulc_KN_< K >, K, KN_< K > > >, + new OneBinaryOperator< Op2_mulpcp< Mul_KNM_KN_< K >, KNM< K > *, KN< K > * > >, // A*b zzzzzzz + + // new OneBinaryOperator,KNM_,KN_> >, // - add #1 mqi 2009 + // new OneBinaryOperator >, + new OneBinaryOperator< Op2_dotproduct_< K > > + //- ,new OneBinaryOperator,KN*,Transpose > > > + // ,new OneBinaryOperatorBug >,KNM* > + , + new OneBinaryOperatorBug< Transpose< KN_< K > >, KNM_< K > >, new OneBinaryOperatorBug< Transpose< KN_< K > >, Transpose< KNM< K > * > > + + , + new OneBinaryOperator< Op2_pbuild< outProduct_KN_< K >, KN_< K >, Transpose< KN_< K > > > >, + new OneBinaryOperator< Op2_pbuild< outProduct_KN_< K >, Mulc_KN_< K >, Transpose< KN_< K > > > > -// add mars 2006 -// atype >()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >)); - atype >()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype >(), atype >() )); - atype *>()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype * >(), atype >() )); - //atype >()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype >(), knlp )); - //atype *>()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype * >(), knlp )); - Add *>("diag",".",new OneOperator1 ,KNM *>(getdiag) ); - Add >("diag",".",new OneOperator1 ,KNM_ >(getdiag_) ); - Add *>("asarray",".",new OneOperator1 ,KNM *>(asarray) ); - - TheOperators->Add("<-", - new OneBinaryOperator > > ); - TheOperators->Add("=", - new OneBinaryOperator > > , - new OneBinaryOperator > > - ); - TheOperators->Add("+=", - new OneBinaryOperator > > , - new OneBinaryOperator > > - ); - TheOperators->Add("-=", - new OneBinaryOperator > > , - new OneBinaryOperator > > - ); -// fin + ); + TheOperators->Add("*", new OneBinaryOperator< Op2_2p_< Mul_KNMh_KN_< K >, Transpose< KNM< K > * >, KN< K > * > >); // A'*b + TheOperators->Add("=", new OneBinaryOperator< init_eqarray< KN< K >, Mul_KNMh_KN_< K > > >); + TheOperators->Add("<-", new OneBinaryOperator< init_eqarray< KN< K >, Mul_KNMh_KN_< K > > >); + + TheOperators->Add("/", new OneBinaryOperator< Op2_divc< Divc_KN_< K >, K, KN_< K > > >, new OneBinaryOperator< Op2_divc< Mulc_KN_< K >, KN_< K >, K > > + + ); + + // nouvel operateur + TheOperators->Add("+=", new OneBinaryOperator< set_eqarraypd_add< KNM< K >, outProduct_KN_< K > * > >); + + TheOperators->Add("-=", new OneBinaryOperator< set_eqarraypd_sub< KNM< K >, outProduct_KN_< K > * > >); + + TheOperators->Add("=", new OneBinaryOperator< set_eqarraypd< KNM< K >, outProduct_KN_< K > * > >); + // tested ok ... FH + TheOperators->Add( + "?:", new OneTernaryOperator3< Op3_p< if_arth_KN_< K >, KN_< K > > >, new OneTernaryOperator3< Op3_paac< K > >, new OneTernaryOperator3< Op3_pacc< K > >, new OneTernaryOperator3< Op3_paca< K > > + + ); + // end ... + + // add mars 2006 + // atype >()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >)); + atype< KN_< K > >( )->Add("(", "", new OneOperator2_< pair< KN_< K >, KN_< long > > *, KN_< K >, KN_< long > >(pBuild< KN_< K >, KN_< long > >, atype< KN_< K > >( ), atype< KN_< long > >( ))); + atype< KN< K > * >( )->Add("(", "", new OneOperator2_< pair< KN_< K >, KN_< long > > *, KN_< K >, KN_< long > >(pBuild< KN_< K >, KN_< long > >, atype< KN< K > * >( ), atype< KN_< long > >( ))); + // atype >()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype >(), knlp )); + // atype *>()->Add("(","",new OneOperator2_< pair,KN_ > * ,KN_ , KN_ >(pBuild< KN_ , KN_ >,atype * >(), knlp )); + Add< KNM< K > * >("diag", ".", new OneOperator1< KN_< K >, KNM< K > * >(getdiag< K >)); + Add< KNM_< K > >("diag", ".", new OneOperator1< KN_< K >, KNM_< K > >(getdiag_< K >)); + Add< KNM< K > * >("asarray", ".", new OneOperator1< KN_< K >, KNM< K > * >(asarray< K >)); + + TheOperators->Add("<-", new OneBinaryOperator< init_A_BI< K, Z, affectation< K > > >); + TheOperators->Add("=", new OneBinaryOperator< set_A_BI< K, Z, affectation< K > > >, new OneBinaryOperator< set_AI_B< K, Z, affectation< K > > >); + TheOperators->Add("+=", new OneBinaryOperator< set_A_BI< K, Z, affectation_add< K > > >, new OneBinaryOperator< set_AI_B< K, Z, affectation_add< K > > >); + TheOperators->Add("-=", new OneBinaryOperator< set_A_BI< K, Z, affectation_sub< K > > >, new OneBinaryOperator< set_AI_B< K, Z, affectation_sub< K > > >); + // fin TheOperators->Add("\'", - // new OneOperator1 >,KN *>(&Build >,KN *>), - new OneOperator1 >,KN_ >(&Build >,KN_ >), - new OneOperator1 * >, KNM * >(&Build * >,KNM * >,10) , - new OneOperator1 , KNM_ >(Transp, 1) + // new OneOperator1 >,KN *>(&Build >,KN *>), + new OneOperator1< Transpose< KN_< K > >, KN_< K > >(&Build< Transpose< KN_< K > >, KN_< K > >), + new OneOperator1< Transpose< KNM< K > * >, KNM< K > * >(&Build< Transpose< KNM< K > * >, KNM< K > * >, 10), new OneOperator1< KNM_< K >, KNM_< K > >(Transp< K >, 1)); + + TheOperators->Add(".*", new OneBinaryOperator< Op2_build< DotStar_KN_< K >, KN_< K >, KN_< K > > > //-, + //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), + //- new OneBinaryOperator,KN_,KN_ > >(knr_,knrp), + //- new OneBinaryOperator,KN_,KN_ > >(knrp,knr_) + ); - TheOperators->Add(".*", - new OneBinaryOperator,KN_,KN_ > > //-, - //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), - //- new OneBinaryOperator,KN_,KN_ > >(knr_,knrp), - //- new OneBinaryOperator,KN_,KN_ > >(knrp,knr_) - - ); - - - TheOperators->Add("./", - new OneBinaryOperator,KN_,KN_ > > //-, - //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), - //- new OneBinaryOperator,KN_,KN_ > >(knr_,knrp), - //- new OneBinaryOperator,KN_,KN_ > >(knrp,knr_) - ); - - TheOperators->Add("<<", - // new OneBinaryOperator*> >, - new OneBinaryOperator > >, - new OneBinaryOperator > > - ); - TheOperators->Add("<<", - new OneBinaryOperator< PrintPnd< KN< KNM >* > >, - new OneBinaryOperator< PrintPnd< KN< KN >* > > - ); + TheOperators->Add("./", new OneBinaryOperator< Op2_build< DotSlash_KN_< K >, KN_< K >, KN_< K > > > //-, + //- new OneBinaryOperator,KN_,KN_ > >(knrp,knrp), + //- new OneBinaryOperator,KN_,KN_ > >(knr_,knrp), + //- new OneBinaryOperator,KN_,KN_ > >(knrp,knr_) + ); + + TheOperators->Add("<<", + // new OneBinaryOperator*> >, + new OneBinaryOperator< Print< KNM_< K > > >, new OneBinaryOperator< Print< KN_< K > > >); + TheOperators->Add("<<", new OneBinaryOperator< PrintPnd< KN< KNM< K > > * > >, new OneBinaryOperator< PrintPnd< KN< KN< K > > * > >); // remove f.H ne marche pas // TheOperators->Add("<<", // new OneBinaryOperator >, // new OneBinaryOperator > // ); - TheOperators->Add(">>", - new OneBinaryOperator >, - new OneBinaryOperator > - ); - atype*>()->Add("[","",new OneOperator2_*,string*>(get_element)); - TheOperators->Add("&",new OneOperator2_*,string*>(exist_element)); - TheOperators->Add("<<",new OneBinaryOperator*> >); - Add* >("n",".",new OneOperator1 *>(get_MyMap_n)); - - // Add Mai 2009 - Dcl_Type >(); - TheOperators->Add("::", - - new OneBinaryOperator >, - new OneTernaryOperator3 >); - TheOperators->Add("<-", - new OneOperator2_ *,KN *,SetArray >(&set_init_array)); + TheOperators->Add(">>", new OneBinaryOperator< Op_ReadKN< K > >, new OneBinaryOperator< Op_ReadKNM< K > >); + atype< MyMap< String, K > * >( )->Add("[", "", new OneOperator2_< K *, MyMap< String, K > *, string * >(get_element< K >)); + TheOperators->Add("&", new OneOperator2_< bool, MyMap< String, K > *, string * >(exist_element< K >)); + TheOperators->Add("<<", new OneBinaryOperator< PrintP< MyMap< String, K > * > >); + Add< MyMap< String, K > * >("n", ".", new OneOperator1< Z, MyMap< String, K > * >(get_MyMap_n)); - TheOperators->Add("=", - new OneOperator2_ *,KN *,SetArray >(&set_array), - new OneOperator2_ *,KN *,KN * >(&set_arrayp), // to reomve ambiguity aug 2009 - new OneOperator2_ ,KN_ ,SetArray >(-1,&set_array_) // missing aug 2009 a(:)=1:3 less prioritaire - ); + // Add Mai 2009 + Dcl_Type< SetArray< K > >( ); + TheOperators->Add("::", - atype*>()->SetTypeLoop(atype(),atype()); + new OneBinaryOperator< SetArray2< K > >, new OneTernaryOperator3< SetArray3< K > >); + TheOperators->Add("<-", new OneOperator2_< KN< K > *, KN< K > *, SetArray< K > >(&set_init_array)); + TheOperators->Add("=", new OneOperator2_< KN< K > *, KN< K > *, SetArray< K > >(&set_array), new OneOperator2_< KN< K > *, KN< K > *, KN< K > * >(&set_arrayp), // to reomve ambiguity aug 2009 + new OneOperator2_< KN_< K >, KN_< K >, SetArray< K > >(-1, &set_array_) // missing aug 2009 a(:)=1:3 less prioritaire + ); - TheOperators->Add("{}",new ForAllLoop >); + atype< MyMap< String, K > * >( )->SetTypeLoop(atype< K * >( ), atype< string ** >( )); - TheOperators->Add("{}",new ForAllLoop >); - TheOperators->Add("{}",new ForAllLoop >); + TheOperators->Add("{}", new ForAllLoop< E_ForAllLoopMapSI< K > >); - TheOperators->Add("<-",new InitMapfromArray*,string *,K,true> ); + TheOperators->Add("{}", new ForAllLoop< E_ForAllLoopRNM< K > >); + TheOperators->Add("{}", new ForAllLoop< E_ForAllLoopRN< K > >); + TheOperators->Add("<-", new InitMapfromArray< MyMap< String, K > *, string *, K, true >); } -template -class OneOperator1F_KN_ : public OneOperator { - aType r; // return type - typedef A (*func)( B ) ; - func f; - public: - E_F0 * code(const basicAC_F0 & args) const - { return new Op(f,t[0]->CastTo(args[0]));} - OneOperator1F_KN_(func ff): - OneOperator(map_type[typeid(R).name()],map_type[typeid(BB).name()]),f(ff){} - - class Op :public E_F0 { public: - typedef A (*func)(B ) ; +template< class R, class A, class B = A, class BB = B > +class OneOperator1F_KN_ : public OneOperator { + aType r; // return type + typedef A (*func)(B); func f; - Expression a; - Op(func ff,Expression aa) : f(ff),a(aa) {} - AnyType operator()(Stack s) const {return SetAny( R(f, GetAny( (*a)(s)) ) );} - bool EvaluableWithOutStack() const - {return a->EvaluableWithOutStack() ;} // - bool MeshIndependent() const - {return a->MeshIndependent();} // + public: + E_F0 *code(const basicAC_F0 &args) const { return new Op(f, t[0]->CastTo(args[0])); } + OneOperator1F_KN_(func ff) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(BB).name( )]), f(ff) {} + + class Op : public E_F0 { + public: + typedef A (*func)(B); + func f; + Expression a; + Op(func ff, Expression aa) : f(ff), a(aa) {} + AnyType operator( )(Stack s) const { return SetAny< R >(R(f, GetAny< BB >((*a)(s)))); } + bool EvaluableWithOutStack( ) const { return a->EvaluableWithOutStack( ); } // + bool MeshIndependent( ) const { return a->MeshIndependent( ); } // + }; }; - -}; -template -void ArrayOperatorF() -{ - Dcl_Type >(); - - - Global.Add("exp","(",new OneOperator1F_KN_,K,KK,KN_ >(exp)); - Global.Add("log","(",new OneOperator1F_KN_,K,KK,KN_ >(log)); - Global.Add("log10","(",new OneOperator1F_KN_,K,KK,KN_ >(log10)); - Global.Add("sqrt","(",new OneOperator1F_KN_,K,KK,KN_ >(sqrt)); - Global.Add("sin","(",new OneOperator1F_KN_,K,KK,KN_ >(sin)); - Global.Add("cos","(",new OneOperator1F_KN_,K,KK,KN_ >(cos)); - Global.Add("tan","(",new OneOperator1F_KN_,K,KK,KN_ >(tan)); - Global.Add("cosh","(",new OneOperator1F_KN_,K,KK,KN_ >(cosh)); - Global.Add("sinh","(",new OneOperator1F_KN_,K,KK,KN_ >(sinh)); - Global.Add("tanh","(",new OneOperator1F_KN_,K,KK,KN_ >(tanh)); - // Global.Add("acos","(",new OneOperator1F_KN_,K,KK,KN_ >(acos)); - // Global.Add("asin","(",new OneOperator1F_KN_,K,KK,KN_ >(asin)); - // Global.Add("atan","(",new OneOperator1F_KN_,K,KK,KN_ >(atan)); - - TheOperators->Add("=",new OneBinaryOperator ,F_KN_ > > ); // add FH juin 2005 - TheOperators->Add("+=",new OneBinaryOperator ,F_KN_ > > ); // add FH juin 2005 - TheOperators->Add("-=",new OneBinaryOperator ,F_KN_ > > ); // add FH juin 2005 - TheOperators->Add("/=",new OneBinaryOperator ,F_KN_ > > ); // add FH juin 2005 - TheOperators->Add("*=",new OneBinaryOperator ,F_KN_ > > ); // add FH juin 2005 - - TheOperators->Add("<-", new OneOperator2_ *,KN *,F_KN_ >(set_init_N)); - +template< class K, class KK > +void ArrayOperatorF( ) { + Dcl_Type< F_KN_< K, K, K, KK > >( ); + + Global.Add("exp", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(exp)); + Global.Add("log", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(log)); + Global.Add("log10", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(log10)); + Global.Add("sqrt", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(sqrt)); + Global.Add("sin", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(sin)); + Global.Add("cos", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(cos)); + Global.Add("tan", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(tan)); + Global.Add("cosh", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(cosh)); + Global.Add("sinh", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(sinh)); + Global.Add("tanh", "(", new OneOperator1F_KN_< F_KN_< K, K, K, KK >, K, KK, KN_< K > >(tanh)); + // Global.Add("acos","(",new OneOperator1F_KN_,K,KK,KN_ >(acos)); + // Global.Add("asin","(",new OneOperator1F_KN_,K,KK,KN_ >(asin)); + // Global.Add("atan","(",new OneOperator1F_KN_,K,KK,KN_ >(atan)); + + TheOperators->Add("=", new OneBinaryOperator< set_eq_array< KN_< K >, F_KN_< K, K, K, KK > > >); // add FH juin 2005 + TheOperators->Add("+=", new OneBinaryOperator< set_eq_array_add< KN_< K >, F_KN_< K, K, K, KK > > >); // add FH juin 2005 + TheOperators->Add("-=", new OneBinaryOperator< set_eq_array_sub< KN_< K >, F_KN_< K, K, K, KK > > >); // add FH juin 2005 + TheOperators->Add("/=", new OneBinaryOperator< set_eq_array_div< KN_< K >, F_KN_< K, K, K, KK > > >); // add FH juin 2005 + TheOperators->Add("*=", new OneBinaryOperator< set_eq_array_mul< KN_< K >, F_KN_< K, K, K, KK > > >); // add FH juin 2005 + + TheOperators->Add("<-", new OneOperator2_< KN< K > *, KN< K > *, F_KN_< K, K, K, KK > >(set_init_N)); } // Add nov 2019 version 4.4-3 FH -template struct KN_rmeps {KN_ v; - KN_rmeps(KN_ vv):v(vv) {} -} ; -template KN_rmeps build_rmeps(KN_ v){ return KN_rmeps(v);} +template< class K > +struct KN_rmeps { + KN_< K > v; + KN_rmeps(KN_< K > vv) : v(vv) {} +}; +template< class K > +KN_rmeps< K > build_rmeps(KN_< K > v) { + return KN_rmeps< K >(v); +} #endif diff --git a/src/fflib/compositeFESpace.cpp b/src/fflib/compositeFESpace.cpp index 1bd8b4429..b9c5751ea 100644 --- a/src/fflib/compositeFESpace.cpp +++ b/src/fflib/compositeFESpace.cpp @@ -1,5 +1,5 @@ -//#include "HashMatrix.hpp" -//#include "lgmat.hpp" +// #include "HashMatrix.hpp" +// #include "lgmat.hpp" #ifndef FFLANG #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) @@ -11,43 +11,43 @@ #include // include the bemtool library .... path define in where library -//#include +// #include #include #include #include #include -//#include "PlotStream.hpp" +// #include "PlotStream.hpp" #include "HashMatrix.hpp" #include "common.hpp" -//extern FILE *ThePlotStream; +// extern FILE *ThePlotStream; using namespace std; -//using namespace htool; -//using namespace bemtool; +// using namespace htool; +// using namespace bemtool; #include -//typedef LinearComb Finconnue; -//typedef LinearComb Ftest; -//typedef const Finconnue finconnue; -//typedef const Ftest ftest; -//class CDomainOfIntegration; -//class FormBilinear; +// typedef LinearComb Finconnue; +// typedef LinearComb Ftest; +// typedef const Finconnue finconnue; +// typedef const Ftest ftest; +// class CDomainOfIntegration; +// class FormBilinear; #include "common_bem.hpp" #include "bem.hpp" #endif #endif -#include +#include using namespace std; #include "rgraph.hpp" #include "error.hpp" #include "AFunction.hpp" -//#include "lex.hpp" +// #include "lex.hpp" #include "HashMatrix.hpp" #include "SparseLinearSolver.hpp" @@ -60,117 +60,110 @@ using namespace std; #include #include "compositeFESpace.hpp" - -string typeFEtoString(int typeFE) -{ - string toto=""; - if(typeFE == 2){ - toto= "FESpace2D Vol"; - }else if(typeFE == 3){ - toto= "FESpace3D Vol"; - }else if(typeFE == 4){ - toto= "FESpace3D Surf"; - }else if(typeFE == 5){ - toto= "FESpace3D Curve"; - } - else{ +string typeFEtoString(int typeFE) { + string toto = ""; + if (typeFE == 2) { + toto = "FESpace2D Vol"; + } else if (typeFE == 3) { + toto = "FESpace3D Vol"; + } else if (typeFE == 4) { + toto = "FESpace3D Surf"; + } else if (typeFE == 5) { + toto = "FESpace3D Curve"; + } else { cerr << "func typeFEtoString :: error in the type of FESpace " << endl; ffassert(0); } return toto; } - /** - * @brief Builds a new largs whit each element are included in one block - * @param largs list of argument of the initial Forms - * @param NpUh number of FESpace in Uh - * @param NpVh number of FESpace in Vh - * @param indexBlockUh give the index of the block for a given component of FESpace Uh - * @param indexBlockVh give the index of the block for a given component of FESpace Vh - * - */ - -list creationLargsForCompositeFESpace( const list & largs, const int &NpUh, const int &NpVh, - const KN &indexBlockUh, const KN &indexBlockVh ){ - + * @brief Builds a new largs whit each element are included in one block + * @param largs list of argument of the initial Forms + * @param NpUh number of FESpace in Uh + * @param NpVh number of FESpace in Vh + * @param indexBlockUh give the index of the block for a given component of FESpace Uh + * @param indexBlockVh give the index of the block for a given component of FESpace Vh + * + */ + +list< C_F0 > creationLargsForCompositeFESpace(const list< C_F0 > &largs, const int &NpUh, const int &NpVh, const KN< int > &indexBlockUh, const KN< int > &indexBlockVh) { + // At the end of this function, every element of newlargs is included in one block - list newlargs; // creation de la nouvelle list largs + list< C_F0 > newlargs; // creation de la nouvelle list largs // const_iterator - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); - // loop over largs information - if(verbosity>3) cout << "loop over the integral" << endl; + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + // loop over largs information + if (verbosity > 3) cout << "loop over the integral" << endl; int count_integral = 0; - for (ii=ib;ii != ie;ii++) { + for (ii = ib; ii != ie; ii++) { count_integral++; - if(verbosity>3){ - cout <<"========================================================" << endl; - cout <<"= =" << endl; + if (verbosity > 3) { + cout << "========================================================" << endl; + cout << "= =" << endl; cout << "reading the " << count_integral << "-th integral" << endl; } - Expression e=ii->LeftValue(); - aType r = ii->left(); - if(verbosity>3){ + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (verbosity > 3) { cout << "e=" << e << ", " << "r=" << r << endl; - cout <<"= =" << endl; + cout << "= =" << endl; } // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ - const FormBilinear * bb=dynamic_cast(e); + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); ffassert(bb); - const CDomainOfIntegration & di= *bb->di; + const CDomainOfIntegration &di = *bb->di; - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } - - size_t Opsize= Op->v.size(); - if( verbosity > 3 ){ + + size_t Opsize = Op->v.size( ); + if (verbosity > 3) { cout << " loop over the term inside the integral" << endl; - cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size() << endl; + cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size( ) << endl; } - std::vector< std::pair > indexBlock(Opsize); + std::vector< std::pair< int, int > > indexBlock(Opsize); - for(size_t jj=0; jj( - indexBlockUh[ Op->v[jj].first.first.first ], - indexBlockVh[ Op->v[jj].first.second.first ] ); + for (size_t jj = 0; jj < Opsize; jj++) { + indexBlock[jj] = std::pair< int, int >(indexBlockUh[Op->v[jj].first.first.first], indexBlockVh[Op->v[jj].first.second.first]); } // index to check if a integral is defined on multi block - int countOP=0; - BilinearOperator * OpBloc= new BilinearOperator(); + int countOP = 0; + BilinearOperator *OpBloc = new BilinearOperator( ); // loop over the block - for(int ibloc=0; iblocv.empty() ); - } - OpBloc->add(Op->v[jj].first, Op->v[jj].second); // Add the billinearOperator to bloc (ibloc,jbloc). + for (int ibloc = 0; ibloc < NpUh; ibloc++) { + for (int jbloc = 0; jbloc < NpVh; jbloc++) { + + // BilinearOperator * OpBloc= new BilinearOperator(); + countOP = 0; + for (size_t jj = 0; jj < Opsize; jj++) { + if (indexBlock[jj].first == ibloc && indexBlock[jj].second == jbloc) { + if (countOP == 0) { + ffassert(OpBloc->v.empty( )); + } + OpBloc->add(Op->v[jj].first, Op->v[jj].second); // Add the billinearOperator to bloc (ibloc,jbloc). countOP += 1; } } - - if( countOP > 0 ){ - // << countOP << " voila titi " << "OpBloc->v.size()= " << OpBloc->v.size() << endl; - ffassert( OpBloc->v.size() > 0); - + + if (countOP > 0) { + // << countOP << " voila titi " << "OpBloc->v.size()= " << OpBloc->v.size() << endl; + ffassert(OpBloc->v.size( ) > 0); + // FormBilinear *titi = new FormBilinear( &di, OpBloc ); - newlargs.push_back( C_F0( new FormBilinear( &di, OpBloc ), r ) ); - + newlargs.push_back(C_F0(new FormBilinear(&di, OpBloc), r)); + // // Add to the given block // for(size_t jj=0; jjv.size(); jj++){ // OpBloc->v[jj].first.first.first = localIndexInTheBlockUh( OpBloc->v[jj].first.first.first ); // finconnue @@ -178,128 +171,122 @@ list creationLargsForCompositeFESpace( const list & largs, const in // } // block_largs(ibloc,jbloc).push_back( C_F0( new FormBilinear( &di, OpBloc ), r) ); - OpBloc->v.clear(); - ffassert( (OpBloc->v.empty() == true ) ); - + OpBloc->v.clear( ); + ffassert((OpBloc->v.empty( ) == true)); } - } } delete OpBloc; - } // end billinear type + } // end billinear type // *************************************** - // Case linear type + // Case linear type // *************************************** - else if(r == atype< const FormLinear *>()){ + else if (r == atype< const FormLinear * >( )) { // if(verbosity>3) cout << "FormLinear in variational form" << endl; - const FormLinear * ll=dynamic_cast(e); - LOperaD * Op = const_cast(ll->l); + const FormLinear *ll = dynamic_cast< const FormLinear * >(e); + LOperaD *Op = const_cast< LOperaD * >(ll->l); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } - size_t Opsize= Op->v.size(); - + size_t Opsize = Op->v.size( ); + // creation the vector of the indexBlock for each element OpChange std::vector< int > indexBlock(Opsize); - for(size_t jj=0; jjv[jj].first.first ]; + for (size_t jj = 0; jj < Opsize; jj++) { + indexBlock[jj] = indexBlockVh[Op->v[jj].first.first]; } - LOperaD * OpBloc= new LOperaD(); + LOperaD *OpBloc = new LOperaD( ); // put the term inside OpChange in the good block - for(int jbloc=0; jblocv.empty() ); - } - OpBloc->add(Op->v[jj].first,Op->v[jj].second); // Add the LinearOperator to bloc (ibloc,jbloc). - countOP += 1; + for (int jbloc = 0; jbloc < NpVh; jbloc++) { + int countOP = 0; + // LOperaD * OpBloc= new LOperaD(); + for (size_t jj = 0; jj < Opsize; jj++) { + if (indexBlock[jj] == jbloc) { + if (countOP == 0) { + ffassert(OpBloc->v.empty( )); + } + OpBloc->add(Op->v[jj].first, Op->v[jj].second); // Add the LinearOperator to bloc (ibloc,jbloc). + countOP += 1; } } - if( countOP > 0 ){ - ffassert( OpBloc->v.size() > 0); - + if (countOP > 0) { + ffassert(OpBloc->v.size( ) > 0); + // // for coonstruction of block_largs // for(size_t jj=0; jjv.size(); jj++){ // OpBloc->v[jj].first.first = localIndexInTheBlockVh( OpBloc->v[jj].first.first ); // } - newlargs.push_back( C_F0( new FormLinear( (ll->di), OpBloc ), r ) ); + newlargs.push_back(C_F0(new FormLinear((ll->di), OpBloc), r)); // // for coonstruction of block_largs // block_largs(jbloc,jbloc).push_back( C_F0( new FormLinear( (ll->di), OpBloc ), r ) ); - OpBloc->v.clear(); - ffassert( ( OpBloc->v.empty() == true) ); // check if OpBloc is empty after clear(); + OpBloc->v.clear( ); + ffassert((OpBloc->v.empty( ) == true)); // check if OpBloc is empty after clear(); } } delete OpBloc; - } // end linear type + } // end linear type // *************************************** // Case Boundary condition // *************************************** - else if(r == atype()){ - if(verbosity>3) cout << " BC in variational form " << endl; - BC_set * bc=dynamic_cast< BC_set *>(e); + else if (r == atype< const BC_set * >( )) { + if (verbosity > 3) cout << " BC in variational form " << endl; + BC_set *bc = dynamic_cast< BC_set * >(e); - int sizebc=bc->bc.size(); + int sizebc = bc->bc.size( ); std::vector< int > indexBlock(sizebc); // calculate the index of the componenent where the bloc - for (int k=0; k &xx=bc->bc[k]; + for (int k = 0; k < sizebc; k++) { + pair< int, Expression > &xx = bc->bc[k]; indexBlock[k] = indexBlockUh[xx.first]; // xx.first = localIndexInTheBlockVh(xx.first); // change the index corresponding to the block } bool addBC = false; - bool *okBC =new bool[NpUh]; - for(int ibloc=0; ibloc() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); ffassert(bbtmp); int VVFBEM = bbtmp->type; - if(VVFBEM ==1){ - BemKFormBilinear * bb= dynamic_cast< BemKFormBilinear *>(e); + if (VVFBEM == 1) { + BemKFormBilinear *bb = dynamic_cast< BemKFormBilinear * >(e); ffassert(bb); - + // creation of the new operator - BemKFormBilinear * bbnew = new BemKFormBilinear( bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); - newlargs.push_back( C_F0( bbnew, r ) ); - } - else if(VVFBEM == 2){ + BemKFormBilinear *bbnew = new BemKFormBilinear(bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft))); + newlargs.push_back(C_F0(bbnew, r)); + } else if (VVFBEM == 2) { cerr << " BEM Potential in composite FESpace in construction " << endl; ffassert(0); - } - else{ + } else { cerr << "VFBEM must be egal to 1(kernel) or 2(potential)" << endl; ffassert(0); } @@ -307,87 +294,87 @@ list creationLargsForCompositeFESpace( const list & largs, const in #endif #endif - } // end iterator oflargs + } // end iterator oflargs return newlargs; } -KNM< list > computeBlockLargs( const list & largs, const int &NpUh, const int &NpVh, const KN &indexBlockUh, const KN &indexBlockVh ){ - // creation of the return value - KNM< list > block_largs( (long)NpUh, (long)NpVh ); +KNM< list< C_F0 > > computeBlockLargs(const list< C_F0 > &largs, const int &NpUh, const int &NpVh, const KN< int > &indexBlockUh, const KN< int > &indexBlockVh) { + // creation of the return value + KNM< list< C_F0 > > block_largs((long)NpUh, (long)NpVh); - long UhtotalNbItem = indexBlockUh.N(); - long VhtotalNbItem = indexBlockVh.N(); + long UhtotalNbItem = indexBlockUh.N( ); + long VhtotalNbItem = indexBlockVh.N( ); // impression des information de la composition largs - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); // necessaire :: UhtotalNbItem, indexBlockUh // Loop to put each term of the varf in each correct block - // loop over largs information - if(verbosity>3) cout << "loop over the integral" << endl; + // loop over largs information + if (verbosity > 3) cout << "loop over the integral" << endl; int count_integral = 0; - for (ii=ib;ii != ie;ii++) { + for (ii = ib; ii != ie; ii++) { count_integral++; - - Expression e=ii->LeftValue(); - aType r = ii->left(); - if(verbosity>3){ - cout <<"========================================================" << endl; - cout <<"= =" << endl; + + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (verbosity > 3) { + cout << "========================================================" << endl; + cout << "= =" << endl; cout << "reading the " << count_integral << "-th term of the variational form used to define the matrix" << endl; cout << "e=" << e << ", " << "r=" << r << endl; - cout <<"= =" << endl; + cout << "= =" << endl; } // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ - const FormBilinear * bb=dynamic_cast(e); - const CDomainOfIntegration & di= *bb->di; + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const CDomainOfIntegration &di = *bb->di; - if(verbosity >3){ + if (verbosity > 3) { cout << "di.kind=" << di.kind << ", di.dHat=" << di.dHat << endl; - cout << "di.d= " << di.d << ", di.Th= " << di.Th << endl; + cout << "di.d= " << di.d << ", di.Th= " << di.Th << endl; } - - int d = di.d; + + int d = di.d; int dHat = di.dHat; - // Sert a verifier que "*bb->di->Th" est du bon type ==> A enlever - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); + // Sert a verifier que "*bb->di->Th" est du bon type ==> A enlever + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } - - size_t Opsize= Op->v.size(); - if(verbosity >3){ + + size_t Opsize = Op->v.size( ); + if (verbosity > 3) { cout << " loop over the term inside the integral" << endl; - cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size() << endl; + cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size( ) << endl; } - + // index to check if a integral is defined on multi block - int indexOfBlockUh = -1; // A changer de nom - int indexOfBlockVh = -1; // A changer de nom - for(size_t jj=0; jjv[jj]; - pair finc(ll.first.first), ftest(ll.first.second); - if(verbosity>3){ + pair< int, int > finc(ll.first.first), ftest(ll.first.second); + if (verbosity > 3) { cout << " operateur jj= " << jj << endl; - cout << " FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; - cout << " FormBilinear: operator order finc =" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 + cout << " FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; + cout << " FormBilinear: operator order finc =" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 } - + // Fred fait peut être un message après ???? // verification que la taille des tableaux des fonctions tests et de la fonction inconnue`` - // sont correctes. - ffassert( -1 < finc.first && finc.first < UhtotalNbItem); - ffassert( -1 < ftest.first && ftest.first < VhtotalNbItem); + // sont correctes. + ffassert(-1 < finc.first && finc.first < UhtotalNbItem); + ffassert(-1 < ftest.first && ftest.first < VhtotalNbItem); // finc.first : index de component de la fonction inconnue // ftest.first: index de component de la fonction test @@ -402,41 +389,39 @@ KNM< list > computeBlockLargs( const list & largs, const int &NpUh, //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if( jj== 0 ){ + if (jj == 0) { indexOfBlockUh = indexBlockUh[finc.first]; indexOfBlockVh = indexBlockVh[ftest.first]; - } - else if( indexOfBlockUh != indexBlockUh[finc.first] ){ - cerr << "The " << count_integral <<"-th integral(s) contains the constribution of two different blocks:" << endl; - cerr << "the first term correspond to block (" << indexOfBlockUh << " , " << indexOfBlockVh << ")" << endl; - cerr << "the "<= 0 && indexOfBlockVh >= 0); - - // A faire :: recuperation des éléments pour chacun des blocs - // Actuellement, on associe une intégrale par block ==> - - block_largs(indexOfBlockUh,indexOfBlockVh).push_back(*ii); + ffassert(indexOfBlockUh >= 0 && indexOfBlockVh >= 0); + + // A faire :: recuperation des éléments pour chacun des blocs + // Actuellement, on associe une intégrale par block ==> - if(verbosity>3) cout << "The " << count_integral <<"-th integral(s) is added to the block (" << indexOfBlockUh << " , " << indexOfBlockVh << ")" < 3) cout << "The " << count_integral << "-th integral(s) is added to the block (" << indexOfBlockUh << " , " << indexOfBlockVh << ")" << endl; } #ifndef FFLANG @@ -444,84 +429,85 @@ KNM< list > computeBlockLargs( const list & largs, const int &NpUh, // ****************************************** // Case BemKFormBilinear (KERNEL FORM ONLY) // ****************************************** - else if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); int VVFBEM = bbtmp->type; - if(VVFBEM ==1){ - //BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - const BemKFormBilinear * bb= dynamic_cast(e); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0);} - - int indexOfBlockUh = -1; // A changer de nom - int indexOfBlockVh = -1; // A changer de nom + if (VVFBEM == 1) { + // BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); + const BemKFormBilinear *bb = dynamic_cast< const BemKFormBilinear * >(e); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + ffassert(0); + } + int indexOfBlockUh = -1; // A changer de nom + int indexOfBlockVh = -1; // A changer de nom // loop over the index of finconnue - LOperaG * OpG = const_cast(b->fi); - ffassert( OpG->v.size() == 1); - size_t jj =0; - for (LOperaG::const_iterator lop=OpG->v.begin();lop!=OpG->v.end();lop++){ + LOperaG *OpG = const_cast< LOperaG * >(b->fi); + ffassert(OpG->v.size( ) == 1); + size_t jj = 0; + for (LOperaG::const_iterator lop = OpG->v.begin( ); lop != OpG->v.end( ); lop++) { LOperaG::K lf(*lop); - pair finc(lf.first); - if(verbosity >3){ + pair< int, int > finc(lf.first); + if (verbosity > 3) { cout << " operateur jj= " << jj << endl; cout << " BemFormLinear: number of unknown finc= " << finc.first << endl; } - ffassert( -1 < finc.first && finc.first < UhtotalNbItem); // check the index + ffassert(-1 < finc.first && finc.first < UhtotalNbItem); // check the index - if( jj== 0 ){ + if (jj == 0) { indexOfBlockUh = indexBlockUh[finc.first]; - } - else if( indexOfBlockUh != indexBlockUh[finc.first] ){ - cerr << "The " << count_integral <<"-th term of the varitional form contains the constribution of two different FESpace:" << endl; + } else if (indexOfBlockUh != indexBlockUh[finc.first]) { + cerr << "The " << count_integral << "-th term of the varitional form contains the constribution of two different FESpace:" << endl; cerr << "This terms correspond to a BEM integral terms" << endl; cerr << "the first term correspond to element " << indexOfBlockUh << " of the Composite FESpace (Finconnu)." << endl; - cerr << "the "<< jj <<"-th term correspond to element " << indexBlockUh(finc.first) << endl; + cerr << "the " << jj << "-th term correspond to element " << indexBlockUh(finc.first) << endl; cerr << "In a composite FESpace, you need to define a BEM integral for each FESpace individually." << endl; cerr << "A ameliorer Jacques." << endl; ffassert(0); } - jj+=1; + jj += 1; } - // Loop over the index of ftest - LOperaD * OpD = const_cast(b->ft); - ffassert( OpD->v.size() == 1); - jj =0; // reinitialisation ton zero - for (LOperaD::const_iterator lop=OpD->v.begin();lop!=OpD->v.end();lop++){ - + LOperaD *OpD = const_cast< LOperaD * >(b->ft); + ffassert(OpD->v.size( ) == 1); + jj = 0; // reinitialisation ton zero + for (LOperaD::const_iterator lop = OpD->v.begin( ); lop != OpD->v.end( ); lop++) { + LOperaD::K lf(*lop); - pair ftest(lf.first); - if(verbosity>3){ + pair< int, int > ftest(lf.first); + if (verbosity > 3) { cout << " operateur jj= " << jj << endl; cout << " BemFormLinear: number of unknown ftest= " << ftest.first << endl; } - ffassert( -1 < ftest.first && ftest.first < VhtotalNbItem); // check the index + ffassert(-1 < ftest.first && ftest.first < VhtotalNbItem); // check the index - if( jj== 0 ){ + if (jj == 0) { indexOfBlockVh = indexBlockVh[ftest.first]; - } - else if( indexOfBlockVh != indexBlockVh[ftest.first] ){ - cerr << "The " << count_integral <<"-th term of the varitional form contains the constribution of two different FESpace:" << endl; + } else if (indexOfBlockVh != indexBlockVh[ftest.first]) { + cerr << "The " << count_integral << "-th term of the varitional form contains the constribution of two different FESpace:" << endl; cerr << "This terms correspond to a BEM integral terms" << endl; cerr << "the first term correspond to element " << indexOfBlockVh << " of the Composite FESpace (Ftest)." << endl; - cerr << "the "<< jj <<"-th term correspond to element " << indexBlockVh(ftest.first) << endl; + cerr << "the " << jj << "-th term correspond to element " << indexBlockVh(ftest.first) << endl; cerr << "In a composite FESpace, you need to define a BEM integral term for each FESpace individually." << endl; cerr << "A ameliorer Jacques." << endl; ffassert(0); } - jj+=1; + jj += 1; } - block_largs(indexOfBlockUh,indexOfBlockVh).push_back(*ii); + block_largs(indexOfBlockUh, indexOfBlockVh).push_back(*ii); - }else if(VVFBEM == 2){ - BemPFormBilinear * bb=new BemPFormBilinear(*dynamic_cast(e)); - FoperatorPBEM * b=const_cast< FoperatorPBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; } + } else if (VVFBEM == 2) { + BemPFormBilinear *bb = new BemPFormBilinear(*dynamic_cast< const BemPFormBilinear * >(e)); + FoperatorPBEM *b = const_cast< FoperatorPBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } cerr << " BEM Potential in composite FESpace in construction " << endl; ffassert(0); @@ -530,371 +516,366 @@ KNM< list > computeBlockLargs( const list & largs, const int &NpUh, } #endif #endif - else if (r==atype() ){ + else if (r == atype< const FormLinear * >( )) { // === FormLinear === // - const FormLinear * ll=dynamic_cast(e); - LOperaD * Op = const_cast(ll->l); + const FormLinear *ll = dynamic_cast< const FormLinear * >(e); + LOperaD *Op = const_cast< LOperaD * >(ll->l); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } int indexOfBlockVh = -1; - size_t Opsize= Op->v.size(); - size_t jj =0; - for (LOperaD::const_iterator lop=Op->v.begin();lop!=Op->v.end();lop++) - { + size_t Opsize = Op->v.size( ); + size_t jj = 0; + for (LOperaD::const_iterator lop = Op->v.begin( ); lop != Op->v.end( ); lop++) { LOperaD::K lf(*lop); - pair ftest(lf.first); - if(verbosity>3){ + pair< int, int > ftest(lf.first); + if (verbosity > 3) { cout << " operateur jj= " << jj << endl; cout << " FormLinear: number of unknown ftest= " << ftest.first << endl; } - ffassert( -1 < ftest.first && ftest.first < VhtotalNbItem); + ffassert(-1 < ftest.first && ftest.first < VhtotalNbItem); - if( jj== 0 ){ + if (jj == 0) { indexOfBlockVh = indexBlockVh[ftest.first]; - } - else if( indexOfBlockVh != indexBlockVh[ftest.first] ){ - cerr << "The " << count_integral <<"-th term of the varitional form contains the constribution of two different FESpace:" << endl; + } else if (indexOfBlockVh != indexBlockVh[ftest.first]) { + cerr << "The " << count_integral << "-th term of the varitional form contains the constribution of two different FESpace:" << endl; cerr << "This terms correspond to an integral terms" << endl; cerr << "the first term correspond to element " << indexOfBlockVh << " of the Composite FESpace " << endl; - cerr << "the "<< jj <<"-th term correspond to element " << indexBlockVh(ftest.first) << endl; + cerr << "the " << jj << "-th term correspond to element " << indexBlockVh(ftest.first) << endl; cerr << "In a composite FESpace, you need to define a BC for each FESpace individually." << endl; cerr << "A ameliorer Jacques." << endl; ffassert(0); } - jj+=1; + jj += 1; } // Added the boundary condition in the largs block - block_largs(indexOfBlockVh,indexOfBlockVh).push_back(*ii); - } - else if(r == atype()){ - if(verbosity >3) cout << " BC in variational form " << endl; - - const BC_set * bc=dynamic_cast(e); - + block_largs(indexOfBlockVh, indexOfBlockVh).push_back(*ii); + } else if (r == atype< const BC_set * >( )) { + if (verbosity > 3) cout << " BC in variational form " << endl; + + const BC_set *bc = dynamic_cast< const BC_set * >(e); + // index to check if a integral is defined on multi block int indexOfBlockUh = -1; - - int kk=bc->bc.size(); - for (int k=0;k xx=bc->bc[k]; - ffassert( -1 < xx.first && xx.first < UhtotalNbItem); // check the value of index of the component of the varf - - if( k == 0) indexOfBlockUh = indexBlockUh[xx.first]; // index of the block Uh - else if( indexOfBlockUh != indexBlockUh[xx.first] ){ - cerr << "The " << count_integral <<"-th term of the varitional form contains the constribution of two different FESpace:" << endl; - cerr << "This terms correspond to Boundary condition" << endl; - cerr << "the first term correspond to element " << indexOfBlockUh << " of the Composite FESpace " << endl; - cerr << "the "<bc.size( ); + for (int k = 0; k < kk; k++) { + pair< int, Expression > xx = bc->bc[k]; + ffassert(-1 < xx.first && xx.first < UhtotalNbItem); // check the value of index of the component of the varf + + if (k == 0) + indexOfBlockUh = indexBlockUh[xx.first]; // index of the block Uh + else if (indexOfBlockUh != indexBlockUh[xx.first]) { + cerr << "The " << count_integral << "-th term of the varitional form contains the constribution of two different FESpace:" << endl; + cerr << "This terms correspond to Boundary condition" << endl; + cerr << "the first term correspond to element " << indexOfBlockUh << " of the Composite FESpace " << endl; + cerr << "the " << kk << "-th term correspond to element " << indexBlockUh(xx.first) << endl; + cerr << "In a composite FESpace, you need to define a BC for each FESpace individually." << endl; + cerr << "A ameliorer Jacques." << endl; + ffassert(0); + } } // Added the boundary condition in the largs block - block_largs(indexOfBlockUh,indexOfBlockUh).push_back(*ii); - - //ffassert(0); - } - else{ - + block_largs(indexOfBlockUh, indexOfBlockUh).push_back(*ii); + + // ffassert(0); + } else { + cerr << "Composite FESpace only :: bilinear form" << endl; cerr << " :: linear form" << endl; cerr << " :: BC" << endl; - #ifndef FFLANG - #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) +#ifndef FFLANG +#if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) cerr << " :: BemFormBilinear" << endl; - #endif - #endif +#endif +#endif ffassert(0); } } return block_largs; } - -// Info necessaire :: " block_largs, localIndexInTheBlockUh, localIndexInTheBlockVh, NpUh, NpVh -void changeComponentFormCompositeFESpace( const KN &localIndexInTheBlockUh, const KN &localIndexInTheBlockVh, - KNM< list > & block_largs ){ +// Info necessaire :: " block_largs, localIndexInTheBlockUh, localIndexInTheBlockVh, NpUh, NpVh +void changeComponentFormCompositeFESpace(const KN< int > &localIndexInTheBlockUh, const KN< int > &localIndexInTheBlockVh, KNM< list< C_F0 > > &block_largs) { // put the right number of each component of each block - long NpUh = block_largs.N(); - long NpVh = block_largs.M(); - - for( long i=0; i *b_largs=&block_largs(i,j); - list::const_iterator b_ii,b_ib=b_largs->begin(),b_ie=b_largs->end(); - for (b_ii=b_ib;b_ii != b_ie;b_ii++){ - Expression e=b_ii->LeftValue(); - aType r = b_ii->left(); - // Case FormBilinear - if (r==atype() ){ - const FormBilinear * bb=dynamic_cast(e); - - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); - if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + long NpUh = block_largs.N( ); + long NpVh = block_largs.M( ); + + for (long i = 0; i < NpUh; i++) { + for (long j = 0; j < NpVh; j++) { + + const list< C_F0 > *b_largs = &block_largs(i, j); + list< C_F0 >::const_iterator b_ii, b_ib = b_largs->begin( ), b_ie = b_largs->end( ); + for (b_ii = b_ib; b_ii != b_ie; b_ii++) { + Expression e = b_ii->LeftValue( ); + aType r = b_ii->left( ); + // Case FormBilinear + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); - } - - size_t Opsize= Op->v.size(); - if(verbosity>3){ - cout << " loop over the term inside the integral" << endl; - cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size() << endl; - } - KN index_operator_finc(Opsize); - KN new_index_funct_finc(Opsize); + } + + size_t Opsize = Op->v.size( ); + if (verbosity > 3) { + cout << " loop over the term inside the integral" << endl; + cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size( ) << endl; + } + KN< size_t > index_operator_finc(Opsize); + KN< int > new_index_funct_finc(Opsize); - KN index_operator_ftest(Opsize); - KN new_index_funct_ftest(Opsize); + KN< size_t > index_operator_ftest(Opsize); + KN< int > new_index_funct_ftest(Opsize); - // index to check if a integral is defined on multi block - for(size_t jj=0; jjv[jj]; - pair finc(ll.first.first), ftest(ll.first.second); + // index to check if a integral is defined on multi block + for (size_t jj = 0; jj < Opsize; jj++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll = Op->v[jj]; + pair< int, int > finc(ll.first.first), ftest(ll.first.second); - long jj2= jj; + long jj2 = jj; - index_operator_finc[ jj2] = jj; - new_index_funct_finc[ jj2] = localIndexInTheBlockUh(finc.first); - - index_operator_ftest[ jj2] = jj; - new_index_funct_ftest[ jj2] = localIndexInTheBlockVh(ftest.first); + index_operator_finc[jj2] = jj; + new_index_funct_finc[jj2] = localIndexInTheBlockUh(finc.first); + index_operator_ftest[jj2] = jj; + new_index_funct_ftest[jj2] = localIndexInTheBlockVh(ftest.first); + } + changeIndexFunctionInconnue(*Op, index_operator_finc, new_index_funct_finc); + + changeIndexFunctionTest(*Op, index_operator_ftest, new_index_funct_ftest); + } + +#ifndef FFLANG +#if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) + // ****************************************** + // Case BemKFormBilinear (KERNEL FORM ONLY) + // ****************************************** + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); + int VVFBEM = bbtmp->type; + + if (VVFBEM == 1) { + // BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); + const BemKFormBilinear *bb = dynamic_cast< const BemKFormBilinear * >(e); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + exit(0); } - changeIndexFunctionInconnue(*Op, index_operator_finc, new_index_funct_finc ); - - changeIndexFunctionTest(*Op, index_operator_ftest, new_index_funct_ftest ); - } - - #ifndef FFLANG - #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - // ****************************************** - // Case BemKFormBilinear (KERNEL FORM ONLY) - // ****************************************** - else if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); - int VVFBEM = bbtmp->type; - - if(VVFBEM ==1){ - //BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - const BemKFormBilinear * bb= dynamic_cast(e); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; exit(0);} - - // loop over the index of finconnue - LOperaG * OpG = const_cast(b->fi); - ffassert( OpG->v.size() == 1); - size_t Opsize= OpG->v.size(); - - for(size_t jjj=0; jjjv[jjj]; - OpG->v[jjj].first.first = localIndexInTheBlockUh( OpG->v[jjj].first.first ); - - pair finc(lf.first); - if(verbosity>3){ - cout << " new value :: block i,j=" << i << ","<< j << ", operateur jj= " << jjj << endl; - cout << " BemormBilinear: number of unknown finc = " << finc.first << endl; - cout << " BemFormBilinear: operator order finc = " << finc.second << endl; - } - } + // loop over the index of finconnue + LOperaG *OpG = const_cast< LOperaG * >(b->fi); + ffassert(OpG->v.size( ) == 1); + size_t Opsize = OpG->v.size( ); + + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaG::K lf = OpG->v[jjj]; + OpG->v[jjj].first.first = localIndexInTheBlockUh(OpG->v[jjj].first.first); - // Loop over the index of ftest - LOperaD * OpD = const_cast(b->ft); - ffassert( OpD->v.size() == 1); - Opsize= OpD->v.size(); - for(size_t jjj=0; jjjv[jjj]; - OpD->v[jjj].first.first = localIndexInTheBlockVh( OpD->v[jjj].first.first ); - - pair ftest(lf.first); - if(verbosity>3){ - cout << " new value :: block i,j=" << i << ","<< j << ", operateur jj= " << jjj << endl; - cout << " BemormBilinear: number of unknown ftest = " << ftest.first << endl; - cout << " BemFormBilinear: operator order ftest = " << ftest.second << endl; - } + pair< int, int > finc(lf.first); + if (verbosity > 3) { + cout << " new value :: block i,j=" << i << "," << j << ", operateur jj= " << jjj << endl; + cout << " BemormBilinear: number of unknown finc = " << finc.first << endl; + cout << " BemFormBilinear: operator order finc = " << finc.second << endl; } } - else if(VVFBEM == 2){ - BemPFormBilinear * bb=new BemPFormBilinear(*dynamic_cast(e)); - FoperatorPBEM * b=const_cast< FoperatorPBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; } - cerr << " BEM Potential in composite FESpace in construction " << endl; - ffassert(0); + // Loop over the index of ftest + LOperaD *OpD = const_cast< LOperaD * >(b->ft); + ffassert(OpD->v.size( ) == 1); + Opsize = OpD->v.size( ); + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaD::K lf = OpD->v[jjj]; + OpD->v[jjj].first.first = localIndexInTheBlockVh(OpD->v[jjj].first.first); + + pair< int, int > ftest(lf.first); + if (verbosity > 3) { + cout << " new value :: block i,j=" << i << "," << j << ", operateur jj= " << jjj << endl; + cout << " BemormBilinear: number of unknown ftest = " << ftest.first << endl; + cout << " BemFormBilinear: operator order ftest = " << ftest.second << endl; + } + } + } else if (VVFBEM == 2) { + BemPFormBilinear *bb = new BemPFormBilinear(*dynamic_cast< const BemPFormBilinear * >(e)); + FoperatorPBEM *b = const_cast< FoperatorPBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; } + cerr << " BEM Potential in composite FESpace in construction " << endl; + ffassert(0); } - #endif - #endif - // LinearForm - else if (r==atype() ){ - const FormLinear * ll=dynamic_cast(e); - LOperaD * Op = const_cast(ll->l); - if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; - ffassert(0); - } - size_t Opsize= Op->v.size(); - for(size_t jjj=0; jjjv[jjj].first.first = localIndexInTheBlockVh( Op->v[jjj].first.first ); - } + } +#endif +#endif + // LinearForm + else if (r == atype< const FormLinear * >( )) { + const FormLinear *ll = dynamic_cast< const FormLinear * >(e); + LOperaD *Op = const_cast< LOperaD * >(ll->l); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + ffassert(0); } - // case BC_set - else if(r == atype()){ - ffassert( i == j ); // diagonal block - BC_set * bc=dynamic_cast< BC_set *>(e); // on ne peut pas utiliser " const BC_set * " ou autrement erreur ce ompilation: Morice - - //KN new_index_funct_finc( bc.size() ); - int kk=bc->bc.size(); - //pair &bc_ib(bc->bc.begin()); - - for (int k=0;k &xx2= bc->bc[k]; - //new_index_funct_finc[k] = localIndexInTheBlockUh(bc[k].first); - // change the index of the component to correspond to the index in the block - xx2.first = localIndexInTheBlockUh(xx2.first); - //bc->changeNumberOfComponent(k,localIndexInTheBlockUh(xx.first)); - //bc->bc[k].first = localIndexInTheBlockUh( bc->bc[k].first ); - } + + size_t Opsize = Op->v.size( ); + for (size_t jjj = 0; jjj < Opsize; jjj++) { + Op->v[jjj].first.first = localIndexInTheBlockVh(Op->v[jjj].first.first); + } + } + // case BC_set + else if (r == atype< const BC_set * >( )) { + ffassert(i == j); // diagonal block + BC_set *bc = dynamic_cast< BC_set * >(e); // on ne peut pas utiliser " const BC_set * " ou autrement erreur ce ompilation: Morice + + // KN new_index_funct_finc( bc.size() ); + int kk = bc->bc.size( ); + // pair &bc_ib(bc->bc.begin()); + + for (int k = 0; k < kk; k++) { + pair< int, Expression > &xx2 = bc->bc[k]; + // new_index_funct_finc[k] = localIndexInTheBlockUh(bc[k].first); + // change the index of the component to correspond to the index in the block + xx2.first = localIndexInTheBlockUh(xx2.first); + // bc->changeNumberOfComponent(k,localIndexInTheBlockUh(xx.first)); + // bc->bc[k].first = localIndexInTheBlockUh( bc->bc[k].first ); } } - // listOfComponentBilinearForm(*b_largs); } + // listOfComponentBilinearForm(*b_largs); + } } } +void reverseChangeComponentFormCompositeFESpace(const KN< int > &beginBlockUh, const KN< int > &beginBlockVh, KNM< list< C_F0 > > &block_largs) { + // Info necessaire :: " block_largs, beginBlockUh, beginBlockVh, NpUh, NpVh -void reverseChangeComponentFormCompositeFESpace(const KN &beginBlockUh, const KN &beginBlockVh, - KNM< list > & block_largs){ - // Info necessaire :: " block_largs, beginBlockUh, beginBlockVh, NpUh, NpVh - - long NpUh = block_largs.N(); - long NpVh = block_largs.M(); + long NpUh = block_largs.N( ); + long NpVh = block_largs.M( ); // put the right number of component of each block - for( int i=0; i *b_largs=&block_largs(i,j); - list::const_iterator b_ii,b_ib=b_largs->begin(),b_ie=b_largs->end(); - for (b_ii=b_ib;b_ii != b_ie;b_ii++){ - Expression e=b_ii->LeftValue(); - aType r = b_ii->left(); - - // bilinear case - if (r==atype() ){ - const FormBilinear * bb=dynamic_cast(e); - - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); - if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + for (int i = 0; i < NpUh; i++) { + for (int j = 0; j < NpVh; j++) { + + const list< C_F0 > *b_largs = &block_largs(i, j); + list< C_F0 >::const_iterator b_ii, b_ib = b_largs->begin( ), b_ie = b_largs->end( ); + for (b_ii = b_ib; b_ii != b_ie; b_ii++) { + Expression e = b_ii->LeftValue( ); + aType r = b_ii->left( ); + + // bilinear case + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); - } - - size_t Opsize= Op->v.size(); - - KN index_operator_finc(Opsize); - KN new_index_funct_finc(Opsize); - - KN index_operator_ftest(Opsize); - KN new_index_funct_ftest(Opsize); - - // index to check if a integral is defined on multi block - for(size_t jj=0; jjv[jj]; - pair finc(ll.first.first), ftest(ll.first.second); - - long jj2= jj; - - index_operator_finc[ jj2] = jj; - new_index_funct_finc[ jj2] = beginBlockUh[i]+finc.first; - - index_operator_ftest[ jj2] = jj; - new_index_funct_ftest[ jj2] = beginBlockVh[j]+ftest.first; - } - changeIndexFunctionInconnue(*Op, index_operator_finc, new_index_funct_finc ); - - changeIndexFunctionTest(*Op, index_operator_ftest, new_index_funct_ftest ); - } - + } + + size_t Opsize = Op->v.size( ); + + KN< size_t > index_operator_finc(Opsize); + KN< int > new_index_funct_finc(Opsize); + + KN< size_t > index_operator_ftest(Opsize); + KN< int > new_index_funct_ftest(Opsize); + + // index to check if a integral is defined on multi block + for (size_t jj = 0; jj < Opsize; jj++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll = Op->v[jj]; + pair< int, int > finc(ll.first.first), ftest(ll.first.second); + + long jj2 = jj; + + index_operator_finc[jj2] = jj; + new_index_funct_finc[jj2] = beginBlockUh[i] + finc.first; + + index_operator_ftest[jj2] = jj; + new_index_funct_ftest[jj2] = beginBlockVh[j] + ftest.first; + } + changeIndexFunctionInconnue(*Op, index_operator_finc, new_index_funct_finc); + + changeIndexFunctionTest(*Op, index_operator_ftest, new_index_funct_ftest); + } + #ifndef FFLANG #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - // ****************************************** - // Case BemKFormBilinear (KERNEL FORM ONLY) - // ****************************************** - else if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); - int VVFBEM = bbtmp->type; - - if(VVFBEM ==1){ - // BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - const BemKFormBilinear * bb= dynamic_cast(e); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0);} - - // loop over the index of finconnue - LOperaG * OpG = const_cast(b->fi); - ffassert( OpG->v.size() == 1); - size_t Opsize= OpG->v.size(); - - for(size_t jjj=0; jjjv[jjj]); - OpG->v[jjj].first.first += beginBlockUh[i]; - - } + // ****************************************** + // Case BemKFormBilinear (KERNEL FORM ONLY) + // ****************************************** + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); + int VVFBEM = bbtmp->type; + + if (VVFBEM == 1) { + // BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); + const BemKFormBilinear *bb = dynamic_cast< const BemKFormBilinear * >(e); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + ffassert(0); + } - // Loop over the index of ftest - LOperaD * OpD = const_cast(b->ft); - ffassert( OpD->v.size() == 1); - Opsize= OpD->v.size(); - for(size_t jjj=0; jjjv[jjj]); - OpD->v[jjj].first.first += beginBlockVh[j]; - - } + // loop over the index of finconnue + LOperaG *OpG = const_cast< LOperaG * >(b->fi); + ffassert(OpG->v.size( ) == 1); + size_t Opsize = OpG->v.size( ); + + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaG::K *lf = &(OpG->v[jjj]); + OpG->v[jjj].first.first += beginBlockUh[i]; } - else if(VVFBEM == 2){ - BemPFormBilinear * bb=new BemPFormBilinear(*dynamic_cast(e)); - FoperatorPBEM * b=const_cast< FoperatorPBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0);} - cerr << " BEM Potential in composite FESpace in construction " << endl; + // Loop over the index of ftest + LOperaD *OpD = const_cast< LOperaD * >(b->ft); + ffassert(OpD->v.size( ) == 1); + Opsize = OpD->v.size( ); + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaD::K *lf = &(OpD->v[jjj]); + OpD->v[jjj].first.first += beginBlockVh[j]; + } + } else if (VVFBEM == 2) { + BemPFormBilinear *bb = new BemPFormBilinear(*dynamic_cast< const BemPFormBilinear * >(e)); + FoperatorPBEM *b = const_cast< FoperatorPBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } + cerr << " BEM Potential in composite FESpace in construction " << endl; + ffassert(0); } + + } #endif -#endif - // BC_set - // case BC_set - else if(r == atype()){ - ffassert( i == j ); // diagonal block - BC_set * bc=dynamic_cast(e); - - //KN new_index_funct_finc( bc.size() ); - int kk=bc->bc.size(); - for (int k=0;kbc[k].first += beginBlockUh[i]; - pair &xx=bc->bc[k]; - xx.first += beginBlockUh[i]; - } +#endif + // BC_set + // case BC_set + else if (r == atype< const BC_set * >( )) { + ffassert(i == j); // diagonal block + BC_set *bc = dynamic_cast< BC_set * >(e); + + // KN new_index_funct_finc( bc.size() ); + int kk = bc->bc.size( ); + for (int k = 0; k < kk; k++) { + // bc->bc[k].first += beginBlockUh[i]; + pair< int, Expression > &xx = bc->bc[k]; + xx.first += beginBlockUh[i]; } } } + } } } @@ -907,113 +888,111 @@ MatriceMorse * buildInterpolationMatrixT(const FESpaceL & U */ template< class R, class FESpaceT1, class FESpaceT2 > -Matrice_Creuse * buildMatrixInterpolationForCompositeFESpace(const FESpaceT1 * Uh ,const FESpaceT2 * Vh){ +Matrice_Creuse< R > *buildMatrixInterpolationForCompositeFESpace(const FESpaceT1 *Uh, const FESpaceT2 *Vh) { ffassert(Uh); ffassert(Vh); int NUh = Uh->N; int NVh = Vh->N; - - Matrice_Creuse * sparse_mat= new Matrice_Creuse(); + + Matrice_Creuse< R > *sparse_mat = new Matrice_Creuse< R >( ); // Remarque pas de U2Vc pour l'instant - int* data = new int[4 + NUh]; + int *data = new int[4 + NUh]; // default value for the interpolation matrix - data[0]=false; // transpose not - data[1]=(long) op_id; // get just value - data[2]=false; // get just value - data[3]=0L; // get just value + data[0] = false; // transpose not + data[1] = (long)op_id; // get just value + data[2] = false; // get just value + data[3] = 0L; // get just value - for(int i=0;i3){ - for(int i=0;i " << data[4+i] << " Componante of Vh " < 3) { + for (int i = 0; i < NUh; ++i) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " Componante of Vh " << endl; } } - for(int i=0;i=NVh) - { - cout << "The Uh componante " << i << " -> " << data[4+i] << " >= " << NVh << " number of Vh Componante " <= NVh) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " >= " << NVh << " number of Vh Componante " << endl; ExecError("Interpolation incompability between componante "); } } const FESpaceT1 &rUh = *Uh; const FESpaceT2 &rVh = *Vh; - MatriceMorse* titi=buildInterpolationMatrixT(rUh,rVh,data); + MatriceMorse< R > *titi = buildInterpolationMatrixT< FESpaceT1, FESpaceT2 >(rUh, rVh, data); - sparse_mat->init(); - sparse_mat->typemat=0;//(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master( titi ); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); - if(verbosity>3){ + sparse_mat->init( ); + sparse_mat->typemat = 0; //(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(titi); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); + if (verbosity > 3) { cout << "sparse_mat->typemat=" << sparse_mat->typemat << endl; cout << "N=" << sparse_mat->A->n << endl; cout << "M=" << sparse_mat->A->m << endl; } - delete [] data; + delete[] data; return sparse_mat; } -// print the information of the list of arguments of the varf -void listOfComponentBilinearForm(const list & largs){ +// print the information of the list of arguments of the varf +void listOfComponentBilinearForm(const list< C_F0 > &largs) { - list::const_iterator ii,ib=largs.begin(),ie=largs.end(); + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); - // loop over largs information + // loop over largs information cout << "loop over the integral" << endl; int count_integral = 0; - for (ii=ib;ii != ie;ii++) { + for (ii = ib; ii != ie; ii++) { count_integral++; - Expression e=ii->LeftValue(); - aType r = ii->left(); - - cout <<"========================================================" << endl; - cout <<"= =" << endl; + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + + cout << "========================================================" << endl; + cout << "= =" << endl; cout << "reading the " << count_integral << "-th integral" << endl; cout << "e=" << e << ", " << "r=" << r << endl; - cout <<"= =" << endl; - + cout << "= =" << endl; + // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ - const FormBilinear * bb=dynamic_cast(e); - const CDomainOfIntegration & di= *bb->di; - + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const CDomainOfIntegration &di = *bb->di; + cout << "di.kind=" << di.kind << endl; cout << "di.dHat=" << di.dHat << endl; cout << "di.d=" << di.d << endl; cout << "di.Th=" << di.Th << endl; - - int d = di.d; + + int d = di.d; int dHat = di.dHat; - - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); + + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } - - size_t Opsize= Op->v.size(); - - cout << " loop over the term inside the integral" << endl; - cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size() << endl; - + + size_t Opsize = Op->v.size( ); + + cout << " loop over the term inside the integral" << endl; + cout << " Number of term in the integral:: Op->v.size()=" << Op->v.size( ) << endl; + // index to check if a integral is defined on multi block - for(size_t jj=0; jjv[jj]; - pair finc(ll.first.first), ftest(ll.first.second); - + pair< int, int > finc(ll.first.first), ftest(ll.first.second); + cout << " operateur jj= " << jj << endl; - cout << " FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; - cout << " FormBilinear: operator order finc =" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 - + cout << " FormBilinear: number of unknown finc=" << finc.first << " ,ftest= " << ftest.first << endl; + cout << " FormBilinear: operator order finc =" << finc.second << " ,ftest= " << ftest.second << endl; // ordre only op_id=0 + // finc.first : index de component de la fonction inconnue // ftest.first: index de component de la fonction test //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1025,389 +1004,392 @@ void listOfComponentBilinearForm(const list & largs){ // finc.first = 20 , ftest.first = 15 // finc.second = 1 , ftest.second = 0 - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } - } - else if(r == atype()){ + } else if (r == atype< const BC_set * >( )) { cout << " BC in variational form " << endl; - const BC_set * bc=dynamic_cast(e); - - int kk=bc->bc.size(); - cout << "bc.size=" << bc->bc.size() << endl; - for (int k=0;kbc["<< k << "].first= " << bc->bc[k].first << endl; + const BC_set *bc = dynamic_cast< const BC_set * >(e); + + int kk = bc->bc.size( ); + cout << "bc.size=" << bc->bc.size( ) << endl; + for (int k = 0; k < kk; k++) { + cout << "bc->bc[" << k << "].first= " << bc->bc[k].first << endl; } } - #ifndef FFLANG - #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) +#ifndef FFLANG +#if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) // ****************************************** // Case BemKFormBilinear (KERNEL FORM ONLY) // ****************************************** - else if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); int VVFBEM = bbtmp->type; - cout << " read index term = "<< count_integral << " VVFBEM=" << VVFBEM << endl; - if(VVFBEM ==1){ - //BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); - BemKFormBilinear * bb = dynamic_cast< BemKFormBilinear *>(e); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - if (b == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0);} + cout << " read index term = " << count_integral << " VVFBEM=" << VVFBEM << endl; + if (VVFBEM == 1) { + // BemKFormBilinear * bb=new BemKFormBilinear(*dynamic_cast(e)); + BemKFormBilinear *bb = dynamic_cast< BemKFormBilinear * >(e); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + if (b == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + ffassert(0); + } // loop over the index of finconnue - LOperaG * OpG = const_cast(b->fi); - ffassert( OpG->v.size() == 1); - size_t Opsize= OpG->v.size(); + LOperaG *OpG = const_cast< LOperaG * >(b->fi); + ffassert(OpG->v.size( ) == 1); + size_t Opsize = OpG->v.size( ); cout << " pointeur " << OpG << endl; - for(size_t jjj=0; jjjv[jjj]); - pair finc(lf->first); + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaG::K *lf = &(OpG->v[jjj]); + pair< int, int > finc(lf->first); cout << " operateur jj= " << jjj << endl; cout << " BemFormBilinear: number of unknown finc = " << finc.first << endl; - cout << " BemFormBilinear: operator order finc = " << finc.second << endl; + cout << " BemFormBilinear: operator order finc = " << finc.second << endl; } - // Loop over the index of ftest - LOperaD * OpD = const_cast(b->ft); - ffassert( OpD->v.size() == 1); - Opsize= OpD->v.size(); - for(size_t jjj=0; jjjv[jjj]); - pair ftest(lf->first); + LOperaD *OpD = const_cast< LOperaD * >(b->ft); + ffassert(OpD->v.size( ) == 1); + Opsize = OpD->v.size( ); + for (size_t jjj = 0; jjj < Opsize; jjj++) { + LOperaD::K *lf = &(OpD->v[jjj]); + pair< int, int > ftest(lf->first); cout << " operateur jj= " << jjj << endl; cout << " BemormBilinear: number of unknown ftest = " << ftest.first << endl; - cout << " BemFormBilinear: operator order ftest = " << ftest.second << endl; + cout << " BemFormBilinear: operator order ftest = " << ftest.second << endl; } - } - else if(VVFBEM == 2){ + } else if (VVFBEM == 2) { cerr << " BEM Potential in composite FESpace in construction " << endl; ffassert(0); - } - else{ + } else { cerr << " VFBEM=1 (kernel) or VFBEM=2 (potential) " << endl; ffassert(0); } } - #endif - #endif - else{ +#endif +#endif + else { cerr << "listOfComponentBilinearForm :: vectorial FESpace :: bilinear form only " << endl; cerr << " uniquement terme bilineaire + BC " << endl; ffassert(0); } } - } /** - * @brief determine if we have BEM bilinear operator in a subblock and the type - * @param largs list of argument of the Bilinear Form - */ + * @brief determine if we have BEM bilinear operator in a subblock and the type + * @param largs list of argument of the Bilinear Form + */ /* This function give the good result if only if the FESpace inconnu and FESpace test are scalar FESpace - due to this check : + due to this check : if( finc.first==0 && ftest.first==0) // only first component for finc and ftest */ -int haveBemSubMatrixBlock(const list & largs, int Uh_NbItem, int Vh_NbItem){ +int haveBemSubMatrixBlock(const list< C_F0 > &largs, int Uh_NbItem, int Vh_NbItem) { - ffassert( Uh_NbItem == 1 && Vh_NbItem == 1); + ffassert(Uh_NbItem == 1 && Vh_NbItem == 1); // this function is used to know if a block of the matrix contains BEM Operator // return the type of Bem Block - bool haveBemFormBilinear = false; - bool haveMassMatrixforBEMTOOL = false; - int nbFB=0; - int nbBC=0; - int nbBEM=0; - // - list::const_iterator ii, b_ib=largs.begin(), b_ie=largs.end(); - + bool haveBemFormBilinear = false; + bool haveMassMatrixforBEMTOOL = false; + int nbFB = 0; + int nbBC = 0; + int nbBEM = 0; + // + list< C_F0 >::const_iterator ii, b_ib = largs.begin( ), b_ie = largs.end( ); + #ifndef FFLANG #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - for( ii=b_ib;ii != b_ie;ii++){ - Expression e=ii->LeftValue(); - aType r = ii->left(); + for (ii = b_ib; ii != b_ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); // ****************************************** // Case BemKFormBilinear (KERNEL FORM ONLY) // ****************************************** - if (r==atype() ){ + if (r == atype< const BemFormBilinear * >( )) { haveBemFormBilinear = true; nbBEM++; } } #endif #endif - if( nbBEM > 1 ){ + if (nbBEM > 1) { cerr << "Two BEM operator in a sub-matrix defined by a time product of two FESpace is not allowed" << endl; ffassert(0); } - for( ii=b_ib;ii != b_ie;ii++){ - Expression e=ii->LeftValue(); - aType r = ii->left(); - + for (ii = b_ib; ii != b_ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ + if (r == atype< const FormBilinear * >( )) { nbFB++; // - const FormBilinear * bb=dynamic_cast(e); - const CDomainOfIntegration & di= *bb->di; + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const CDomainOfIntegration &di = *bb->di; // check the integration (keyword) - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); - if (Op == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; } + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } - size_t Opsize= Op->v.size(); + size_t Opsize = Op->v.size( ); - for(size_t jj=0; jjv[jj]; // LinearComb,C_F0> BilinearOperator; - pair finc(ll.first.first), ftest(ll.first.second); + BilinearOperator::K ll = Op->v[jj]; // LinearComb,C_F0> BilinearOperator; + pair< int, int > finc(ll.first.first), ftest(ll.first.second); - // check if we have a mass matrix that we need to add to BEMTOOL + // check if we have a mass matrix that we need to add to BEMTOOL // cf bem.hpp: see pair getBemKernel(Stack stack, const list & largs). - - if( finc.first==0 && ftest.first==0) // only first component for finc and ftest - if( finc.second==0 && ftest.second==0 ) // only op_id=0 - if( (di.kind == CDomainOfIntegration::int1d && di.dHat==1) || (di.kind == CDomainOfIntegration::int2d && di.dHat==2) ){ - if( ! haveMassMatrixforBEMTOOL ){ + + if (finc.first == 0 && ftest.first == 0) // only first component for finc and ftest + if (finc.second == 0 && ftest.second == 0) // only op_id=0 + if ((di.kind == CDomainOfIntegration::int1d && di.dHat == 1) || (di.kind == CDomainOfIntegration::int2d && di.dHat == 2)) { + if (!haveMassMatrixforBEMTOOL) { cerr << " Two mass matrix for BEMTOOl in largs is not allowed " << endl; ffassert(0); } haveMassMatrixforBEMTOOL = true; } } - } // atype FormBilinear - else if(r == atype()){ + } // atype FormBilinear + else if (r == atype< const BC_set * >( )) { nbBC++; - } // atype BC + } // atype BC } - if( nbBC >0 ){ - if( haveBemFormBilinear ){ + if (nbBC > 0) { + if (haveBemFormBilinear) { cerr << "Error: Dirichlet Boundary condition and BEM operator in the same variational form." << endl; ffassert(0); } } // mixed FEM-BEM terms - if( haveBemFormBilinear && haveMassMatrixforBEMTOOL && nbFB > 0 ){ + if (haveBemFormBilinear && haveMassMatrixforBEMTOOL && nbFB > 0) { return 12; // BEM + mass matrix ==> H-matrix, FEM - } - else if( haveBemFormBilinear && nbFB > 0){ + } else if (haveBemFormBilinear && nbFB > 0) { return 11; // BEM+FEM - } - else if( haveBemFormBilinear && haveMassMatrixforBEMTOOL ){ - return 2; // BEM + mass matrix ==> H-matrix - } - else if( haveBemFormBilinear ){ + } else if (haveBemFormBilinear && haveMassMatrixforBEMTOOL) { + return 2; // BEM + mass matrix ==> H-matrix + } else if (haveBemFormBilinear) { return 1; // BEM only - } - else{ + } else { return 0; // FEM only } } /** - * @brief largs separate in two part : BEM (H-matrix) and FEM - * @param largs list of argument of the Bilinear Form - * @param largs_FEM list of argument for the FEM part - * @param largs_BEM list of argument for the BEM part (included sometimes mass matrix ) that be compressed in H-matrix - */ + * @brief largs separate in two part : BEM (H-matrix) and FEM + * @param largs list of argument of the Bilinear Form + * @param largs_FEM list of argument for the FEM part + * @param largs_BEM list of argument for the BEM part (included sometimes mass matrix ) that be compressed in H-matrix + */ /* This function must be call if we have BEM Bilinear operator in a block. - + */ -void separateFEMpartBemPart(const list & largs, list &largs_FEM, list &largs_BEM ){ - +void separateFEMpartBemPart(const list< C_F0 > &largs, list< C_F0 > &largs_FEM, list< C_F0 > &largs_BEM) { + bool newC_F0 = false; bool haveBemFormBilinear = false; - int nbBEM=0; - // - list::const_iterator ii, b_ib=largs.begin(), b_ie=largs.end(); - + int nbBEM = 0; + // + list< C_F0 >::const_iterator ii, b_ib = largs.begin( ), b_ie = largs.end( ); + #ifndef FFLANG #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - for( ii=b_ib;ii != b_ie;ii++){ - Expression e=ii->LeftValue(); - aType r = ii->left(); + for (ii = b_ib; ii != b_ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); // ****************************************** // Case BemKFormBilinear (KERNEL FORM ONLY) // ****************************************** - if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); + if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); ffassert(bbtmp); int VVFBEM = bbtmp->type; haveBemFormBilinear = true; nbBEM++; - if(VVFBEM ==1){ - BemKFormBilinear * bb= dynamic_cast< BemKFormBilinear *>(e); + if (VVFBEM == 1) { + BemKFormBilinear *bb = dynamic_cast< BemKFormBilinear * >(e); ffassert(bb); - //BemKFormBilinear * bbnew = new BemKFormBilinear( bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); // marche ??? - if(newC_F0){ - BemKFormBilinear * bbnew = new BemKFormBilinear( bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); // marche ??? - largs_BEM.push_back( C_F0( bbnew, r ) ); - } - else largs_BEM.push_back(*ii); + // BemKFormBilinear * bbnew = new BemKFormBilinear( bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); // marche ??? + if (newC_F0) { + BemKFormBilinear *bbnew = new BemKFormBilinear(bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft))); // marche ??? + largs_BEM.push_back(C_F0(bbnew, r)); + } else + largs_BEM.push_back(*ii); - }else{ + } else { cerr << "case VVFBEM noot coded yet. todo." << endl; ffassert(0); - } + } // On pourrait retourner l'element de largs. Mais on prefere en creer un nouveau pour etre coherent avec cree deleteNewLargs. - // largs_BEM.push_back(*ii); + // largs_BEM.push_back(*ii); } } #endif #endif - for( ii=b_ib;ii != b_ie;ii++){ - Expression e=ii->LeftValue(); - aType r = ii->left(); - + for (ii = b_ib; ii != b_ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ - + if (r == atype< const FormBilinear * >( )) { + // - const FormBilinear * bb=dynamic_cast(e); - const CDomainOfIntegration & di= *bb->di; + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const CDomainOfIntegration &di = *bb->di; // check the integration (keyword) - BilinearOperator * Op=const_cast< BilinearOperator *>(bb->b); - if (Op == NULL) { if(mpirank == 0) cout << "dynamic_cast error" << endl; } + BilinearOperator *Op = const_cast< BilinearOperator * >(bb->b); + if (Op == NULL) { + if (mpirank == 0) cout << "dynamic_cast error" << endl; + } + + size_t Opsize = Op->v.size( ); - size_t Opsize= Op->v.size(); - - bool haveBEMmass = false; + bool haveBEMmass = false; size_t indexBEMmass = -1; - for(size_t jj=0; jjv[jj]; // LinearComb,C_F0> BilinearOperator; - pair finc(ll.first.first), ftest(ll.first.second); + BilinearOperator::K ll = Op->v[jj]; // LinearComb,C_F0> BilinearOperator; + pair< int, int > finc(ll.first.first), ftest(ll.first.second); - // check if we have a mass matrix that we need to add to BEMTOOL + // check if we have a mass matrix that we need to add to BEMTOOL // cf bem.hpp: see pair getBemKernel(Stack stack, const list & largs). - if( haveBemFormBilinear ){ + if (haveBemFormBilinear) { // IF BEM VERIFIED THAT WE HAVE A MASS MATRIX - if( finc.first==0 && ftest.first==0) // only first component for finc and ftest - if( finc.second==0 && ftest.second==0 ) // only op_id=0 - if( (di.kind == CDomainOfIntegration::int1d && di.dHat==1) || (di.kind == CDomainOfIntegration::int2d && di.dHat==2) ){ - - //haveBEMmass = true; - haveBEMmass = false; - indexBEMmass = jj; + if (finc.first == 0 && ftest.first == 0) // only first component for finc and ftest + if (finc.second == 0 && ftest.second == 0) // only op_id=0 + if ((di.kind == CDomainOfIntegration::int1d && di.dHat == 1) || (di.kind == CDomainOfIntegration::int2d && di.dHat == 2)) { + + // haveBEMmass = true; + haveBEMmass = false; + indexBEMmass = jj; } } } - if( !haveBEMmass ){ - if(newC_F0) largs_FEM.push_back( C_F0( new FormBilinear( &di, Op ), r ) ); - else largs_FEM.push_back(*ii) ; - } - else{ - if(indexBEMmass <0){ ffassert(0);} - if(Opsize==1 && indexBEMmass == 0){ - // case one element corresponding the mass matrix adding for BEMTOOOL - BilinearOperator * OpBEM = new BilinearOperator( Op->v[indexBEMmass].first, Op->v[indexBEMmass].second ); - if(newC_F0){ - BilinearOperator * OpBEM = new BilinearOperator( Op->v[indexBEMmass].first, Op->v[indexBEMmass].second ); - largs_BEM.push_back( C_F0( new FormBilinear( &di, OpBEM ), r ) ); - } - else largs_BEM.push_back( *ii ); + if (!haveBEMmass) { + if (newC_F0) + largs_FEM.push_back(C_F0(new FormBilinear(&di, Op), r)); + else + largs_FEM.push_back(*ii); + } else { + if (indexBEMmass < 0) { + ffassert(0); } - else{ - ffassert( newC_F0 ); // True only if we have newC_F0 - bool * partFEM = new bool[Opsize]; - for(size_t jj=0; jjv[indexBEMmass].first, Op->v[indexBEMmass].second); + if (newC_F0) { + BilinearOperator *OpBEM = new BilinearOperator(Op->v[indexBEMmass].first, Op->v[indexBEMmass].second); + largs_BEM.push_back(C_F0(new FormBilinear(&di, OpBEM), r)); + } else + largs_BEM.push_back(*ii); + } else { + ffassert(newC_F0); // True only if we have newC_F0 + bool *partFEM = new bool[Opsize]; + for (size_t jj = 0; jj < Opsize; jj++) { + partFEM[jj] = true; } partFEM[indexBEMmass] = false; - // check - if(verbosity>3) cout << "partFEM=" << partFEM << endl; - - if(newC_F0){ - BilinearOperator * OpFEM = new BilinearOperator( *Op, partFEM ); - largs_FEM.push_back( C_F0( new FormBilinear( &di, OpFEM ), r ) ); - } - else largs_FEM.push_back(*ii); + // check + if (verbosity > 3) cout << "partFEM=" << partFEM << endl; - if(newC_F0){ - BilinearOperator * OpBEM = new BilinearOperator( Op->v[indexBEMmass].first, Op->v[indexBEMmass].second ); - largs_BEM.push_back( C_F0( new FormBilinear( &di, OpBEM ), r ) ); - } - else largs_BEM.push_back(*ii); + if (newC_F0) { + BilinearOperator *OpFEM = new BilinearOperator(*Op, partFEM); + largs_FEM.push_back(C_F0(new FormBilinear(&di, OpFEM), r)); + } else + largs_FEM.push_back(*ii); + + if (newC_F0) { + BilinearOperator *OpBEM = new BilinearOperator(Op->v[indexBEMmass].first, Op->v[indexBEMmass].second); + largs_BEM.push_back(C_F0(new FormBilinear(&di, OpBEM), r)); + } else + largs_BEM.push_back(*ii); - delete [] partFEM; + delete[] partFEM; } } // creation des deux listes - } // atype FormBilinear - else if(r == atype()){ - const BC_set * bc=dynamic_cast(e); - if(newC_F0) largs_FEM.push_back( C_F0( new BC_set(*bc), r) ); - else largs_FEM.push_back( *ii ); - } // atype BC - else if(r == atype()){ - const FormLinear * ll=dynamic_cast(e); - LOperaD * Op = const_cast(ll->l); - if(newC_F0) largs_FEM.push_back( C_F0( new FormLinear( (ll->di), Op ), r ) ); - else largs_FEM.push_back( *ii ); - - } // atype FormLinear + } // atype FormBilinear + else if (r == atype< const BC_set * >( )) { + const BC_set *bc = dynamic_cast< const BC_set * >(e); + if (newC_F0) + largs_FEM.push_back(C_F0(new BC_set(*bc), r)); + else + largs_FEM.push_back(*ii); + } // atype BC + else if (r == atype< const FormLinear * >( )) { + const FormLinear *ll = dynamic_cast< const FormLinear * >(e); + LOperaD *Op = const_cast< LOperaD * >(ll->l); + if (newC_F0) + largs_FEM.push_back(C_F0(new FormLinear((ll->di), Op), r)); + else + largs_FEM.push_back(*ii); + + } // atype FormLinear } } /** - * @brief Function to delete element of newlargs = list to avoid memory leak. - * @param largs list of argument of the composite FESpace gene - */ + * @brief Function to delete element of newlargs = list to avoid memory leak. + * @param largs list of argument of the composite FESpace gene + */ /* remark: only FormBilinear and BemFormBilinear is deleted */ -void deleteNewLargs(list &newlargs){ - list::iterator ii,ib=newlargs.begin(),ie=newlargs.end(); - for (ii=ib;ii != ie;ii++) { - Expression e=ii->LeftValue(); - aType r = ii->left(); - +void deleteNewLargs(list< C_F0 > &newlargs) { + list< C_F0 >::iterator ii, ib = newlargs.begin( ), ie = newlargs.end( ); + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + // *************************************** // Case FormBillinear // *************************************** - if (r==atype() ){ - FormBilinear * bb=dynamic_cast< FormBilinear *>(e); - //BilinearOperator * Op=dynamic_cast< BilinearOperator *>(bb->b); - for(size_t jj=0; jj < bb->b->v.size(); jj++ ){ - bb->b->v[jj].second.Destroy(); + if (r == atype< const FormBilinear * >( )) { + FormBilinear *bb = dynamic_cast< FormBilinear * >(e); + // BilinearOperator * Op=dynamic_cast< BilinearOperator *>(bb->b); + for (size_t jj = 0; jj < bb->b->v.size( ); jj++) { + bb->b->v[jj].second.Destroy( ); } delete bb->b; delete bb; } - if (r==atype() ){ - FormLinear * ll=dynamic_cast< FormLinear *>(e); - LOperaD * Op = const_cast(ll->l); + if (r == atype< const FormLinear * >( )) { + FormLinear *ll = dynamic_cast< FormLinear * >(e); + LOperaD *Op = const_cast< LOperaD * >(ll->l); if (Op == NULL) { - if(mpirank == 0) cout << "dynamic_cast error" << endl; + if (mpirank == 0) cout << "dynamic_cast error" << endl; ffassert(0); } - - for(size_t jj=0; jj < Op->v.size(); jj++ ){ - Op->v[jj].second.Destroy(); + + for (size_t jj = 0; jj < Op->v.size( ); jj++) { + Op->v[jj].second.Destroy( ); } delete ll->l; delete ll; @@ -1416,8 +1398,8 @@ void deleteNewLargs(list &newlargs){ // BC_set in newlargs correspond to the original BC_set in largs // ==> implies not deleted this element. // **************************************************************** - else if (r==atype() ){ - BC_set * bb=dynamic_cast< BC_set *>(e); + else if (r == atype< const BC_set * >( )) { + BC_set *bb = dynamic_cast< BC_set * >(e); /* //BilinearOperator * Op=dynamic_cast< BilinearOperator *>(bb->b); for(size_t jj=0; jj < bb->b->v.size(); jj++ ){ @@ -1432,129 +1414,119 @@ void deleteNewLargs(list &newlargs){ // ****************************************** // Case BemKFormBilinear (KERNEL FORM ONLY) // ****************************************** - else if (r==atype() ){ - BemFormBilinear * bbtmp= dynamic_cast< BemFormBilinear *>(e); + else if (r == atype< const BemFormBilinear * >( )) { + BemFormBilinear *bbtmp = dynamic_cast< BemFormBilinear * >(e); ffassert(bbtmp); int VVFBEM = bbtmp->type; - if(VVFBEM ==1){ - BemKFormBilinear * bb= dynamic_cast< BemKFormBilinear *>(e); + if (VVFBEM == 1) { + BemKFormBilinear *bb = dynamic_cast< BemKFormBilinear * >(e); ffassert(bb); - FoperatorKBEM * b=const_cast< FoperatorKBEM *>(bb->b); - LOperaG * OpG = const_cast(b->fi); - for(size_t jj=0; jj < OpG->v.size(); jj++ ){ - OpG->v[jj].second.Destroy(); + FoperatorKBEM *b = const_cast< FoperatorKBEM * >(bb->b); + LOperaG *OpG = const_cast< LOperaG * >(b->fi); + for (size_t jj = 0; jj < OpG->v.size( ); jj++) { + OpG->v[jj].second.Destroy( ); } - LOperaD * OpD = const_cast(b->ft); - for(size_t jj=0; jj < OpD->v.size(); jj++ ){ - OpD->v[jj].second.Destroy(); + LOperaD *OpD = const_cast< LOperaD * >(b->ft); + for (size_t jj = 0; jj < OpD->v.size( ); jj++) { + OpD->v[jj].second.Destroy( ); } delete b->fi; delete b->ft; delete b; delete bb; - //BemKFormBilinear * bbnew = new BemKFormBilinear( bb->di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); // marche ??? - //newlargs.push_back( C_F0( bbnew, r ) ); - } - else{ - cerr << "coding only case VFBEM == 1. Other case todo." <di, FoperatorKBEM(bb->b->kbem, *(bb->b->fi), *(bb->b->ft) ) ); // marche ??? + // newlargs.push_back( C_F0( bbnew, r ) ); + } else { + cerr << "coding only case VFBEM == 1. Other case todo." << endl; ffassert(0); } } #endif #endif - ii->Destroy(); + ii->Destroy( ); } - newlargs.clear(); + newlargs.clear( ); } - /** - * @brief : A décrire - * + * @brief : A décrire + * * @param : - * + * * */ /* ATTENTION CETTE FONCTION SUPPOSE QUE L'ALLOCATION DE LA MATRICE EST FAIT AVANT */ -template -void varfToCompositeBlockLinearSystem_fes(bool initmat, bool initx, - /*const typename v_fes1::pfes &pUh, const typename v_fes2::pfes &pVh,*/ - const typename v_fes1::FESpace*& PUh, const typename v_fes2::FESpace*& PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf=false){ - - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes2::pfes pfes2; - typedef typename v_fes1::FESpace FESpace1; - typedef typename v_fes2::FESpace FESpace2; - typedef typename FESpace1::Mesh Mesh1; - typedef typename FESpace2::Mesh Mesh2; - - varfToCompositeBlockLinearSystem( initmat, initx, PUh, PVh, sym, tgv, largs, stack, B, X, A,mpirankandsize,B_from_varf); - +template< class K, class MMesh, class v_fes1, class v_fes2 > +void varfToCompositeBlockLinearSystem_fes(bool initmat, bool initx, + /*const typename v_fes1::pfes &pUh, const typename v_fes2::pfes &pVh,*/ + const typename v_fes1::FESpace *&PUh, const typename v_fes2::FESpace *&PVh, const int &sym, const double &tgv, const list< C_F0 > &largs, Stack stack, + KN_< K > *B, KN_< K > *X, MatriceCreuse< K > &A, int *mpirankandsize, bool B_from_varf = false) { + + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes2::pfes pfes2; + typedef typename v_fes1::FESpace FESpace1; + typedef typename v_fes2::FESpace FESpace2; + typedef typename FESpace1::Mesh Mesh1; + typedef typename FESpace2::Mesh Mesh2; + + varfToCompositeBlockLinearSystem< K, MMesh, FESpace1, FESpace2 >(initmat, initx, PUh, PVh, sym, tgv, largs, stack, B, X, A, mpirankandsize, B_from_varf); } -template -void varfToCompositeBlockLinearSystem(bool initmat, bool initx, const FESpace1 * PUh, const FESpace2 * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf) - { - typedef typename FESpace1::Mesh Mesh1; - typedef typename FESpace2::Mesh Mesh2; +template< class R, class MMesh, class FESpace1, class FESpace2 > +void varfToCompositeBlockLinearSystem(bool initmat, bool initx, const FESpace1 *PUh, const FESpace2 *PVh, const int &sym, const double &tgv, const list< C_F0 > &largs, Stack stack, KN_< R > *B, + KN_< R > *X, MatriceCreuse< R > &A, int *mpirankandsize, bool B_from_varf) { + typedef typename FESpace1::Mesh Mesh1; + typedef typename FESpace2::Mesh Mesh2; // this lines must be defined outside this function - const FESpace1 & Uh = *PUh ; - const FESpace2 & Vh = *PVh ; - const MMesh* pTh = (is_same< Mesh1, Mesh2 >::value) ? (MMesh*)&PUh->Th : 0; - const MMesh &Th= *pTh ; // integration Th - bool same=isSameMesh( largs, &Uh.Th, &Vh.Th, stack); - + const FESpace1 &Uh = *PUh; + const FESpace2 &Vh = *PVh; + const MMesh *pTh = (is_same< Mesh1, Mesh2 >::value) ? (MMesh *)&PUh->Th : 0; + const MMesh &Th = *pTh; // integration Th + bool same = isSameMesh(largs, &Uh.Th, &Vh.Th, stack); // PAC(e) : on retourne le type MatriceCreuse Ici et non Matrice_Creuse dans creationBlockOfMatrixToBilinearForm. // Attention pour la generalisation - if(same){ - if (AssembleVarForm,MMesh,FESpace1,FESpace2 >( stack,Th,Uh,Vh,sym, initmat ? &A:0 , B, largs, mpirankandsize)) - { - if( B && !B_from_varf ){ + if (same) { + if (AssembleVarForm< R, MatriceCreuse< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym, initmat ? &A : 0, B, largs, mpirankandsize)) { + if (B && !B_from_varf) { // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm - *B = - *B; + *B = -*B; // hach FH - for (int i=0, n= B->N(); i< n; i++) - if( abs((*B)[i]) < 1.e-60 ) (*B)[i]=0; + for (int i = 0, n = B->N( ); i < n; i++) + if (abs((*B)[i]) < 1.e-60) (*B)[i] = 0; } - AssembleBC ( stack,Th,Uh,Vh,sym, initmat ? &A:0 , B, initx ? X:0, largs, tgv, mpirankandsize); // TODO with problem + AssembleBC< R, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym, initmat ? &A : 0, B, initx ? X : 0, largs, tgv, mpirankandsize); // TODO with problem + } else { + if (B && !B_from_varf) *B = -*B; // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm } - else{ - if( B && !B_from_varf ) *B = - *B; // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm - } - }else{ + } else { #ifdef V3__CODE - MatriceMap AAA; - cout << "V3__CODE=" << AAA.size() << endl; - ffassert(0); // code a faire - MatriceMorse *pMA = new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,AAA.size(),sym>0); - bool bc=AssembleVarForm,MMesh,FESpace1,FESpace2>( stack,Th,Uh,Vh,sym>0,initmat ? &AAA:0,B,largs); - pMA->addMap(1.,AAA); + MatriceMap< R > AAA; + cout << "V3__CODE=" << AAA.size( ) << endl; + ffassert(0); // code a faire + MatriceMorse< R > *pMA = new MatriceMorse< R >(Vh.NbOfDF, Uh.NbOfDF, AAA.size( ), sym > 0); + bool bc = AssembleVarForm< R, MatriceMap< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, initmat ? &AAA : 0, B, largs); + pMA->addMap(1., AAA); #else - MatriceMorse *pMA = dynamic_cast< HashMatrix*>(&A);// new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,0,sym); - MatriceMap & AAA = *pMA; - bool bc=AssembleVarForm,MMesh,FESpace1,FESpace2>( stack,Th,Uh,Vh,sym>0,initmat ? &AAA:0,B,largs, mpirankandsize); + MatriceMorse< R > *pMA = dynamic_cast< HashMatrix< int, R > * >(&A); // new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,0,sym); + MatriceMap< R > &AAA = *pMA; + bool bc = AssembleVarForm< R, MatriceMap< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, initmat ? &AAA : 0, B, largs, mpirankandsize); #endif - if (bc){ - if( B && !B_from_varf ){ + if (bc) { + if (B && !B_from_varf) { // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm - *B = - *B; + *B = -*B; // hach FH - for (int i=0, n= B->N(); i< n; i++) - if( abs((*B)[i]) < 1.e-60 ) (*B)[i]=0; + for (int i = 0, n = B->N( ); i < n; i++) + if (abs((*B)[i]) < 1.e-60) (*B)[i] = 0; } - AssembleBC ( stack,Th,Uh,Vh,sym, initmat ? &A:0 , B, initx ? X:0, largs, tgv, mpirankandsize); // TODO with problem - } - else{ - if( B && !B_from_varf ) *B = - *B; // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm + AssembleBC< R >(stack, Th, Uh, Vh, sym, initmat ? &A : 0, B, initx ? X : 0, largs, tgv, mpirankandsize); // TODO with problem + } else { + if (B && !B_from_varf) *B = -*B; // case problem or solve : b = int2d(Th)( f*v ) but we evaluate before -int2d(Th)( f*v ) in AssembleVarForm } } } @@ -1564,124 +1536,106 @@ void varfToCompositeBlockLinearSystem(bool initmat, bool initx, const FESpace1 * /** * @brief - * - * @param HMatrix_block H-matrix corresponding to a local block + * + * @param HMatrix_block H-matrix corresponding to a local block */ /* pas de initmat */ -template< class R> -void varfBemToCompositeBlockLinearSystem_hmat(const int& iUh, const int &jVh, - const int &typeUh, const int &typeVh, const generic_v_fes * LLUh, const generic_v_fes * LLVh, - const list & b_largs_zz, Stack stack, Data_Bem_Solver &dsbem, - HMatrixVirt** Hmat){ - - //cout << "iUh=" << iUh << " , " << "jVh=" << jVh << endl; - //cout << LLUh << " " << LLVh << endl; - - // reinitialise Hmat - if( *Hmat) - delete *Hmat; - *Hmat =0; - - int VFBEM = typeVFBEM(b_largs_zz,stack); // get type of VFBEM - - - - // block diagonal matrix - if( typeUh == 4 && typeVh == 4 ){ - ffassert( iUh==jVh ); // If not a block diagonal not coded yet :: Same mesh for the different FESpace - // MeshS --- MeshS - // ==== FESpace 3d Surf: inconnue et test === - const FESpaceS * PUh = (FESpaceS *) LLUh->getpVh(); - const FESpaceS * PVh = (FESpaceS *) LLVh->getpVh(); - - creationHMatrixtoBEMForm(PUh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat); - - } - else if( typeUh == 5 && typeVh == 5 ){ - ffassert( iUh==jVh ); // If not a block diagonal not coded yet :: Same mesh for the different FESpace - // MeshL --- MeshL - // ==== FESpace 3d Curve: inconnue et test === - const FESpaceL * PUh = (FESpaceL *) LLUh->getpVh(); - const FESpaceL * PVh = (FESpaceL *) LLVh->getpVh(); - - creationHMatrixtoBEMForm ( PUh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else if( typeUh == 5 && typeVh == 2 ){ - //ffassert( !(iUh==jVh) ); - // case Uh[i] == MeshL et Vh[j] = Mesh2 - - if(verbosity>3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; - if(verbosity>3) cout << " === hypothesis:: FESpace become FESpaceL for Vh === " << endl; - - const FESpaceL * PUh = (FESpaceL *) LLUh->getpVh(); - creationHMatrixtoBEMForm ( PUh, PUh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else if( typeUh == 4 && typeVh == 3 ){ - //ffassert( !(iUh==jVh) ); - // case Uh[i] == MeshS et Vh[j] = Mesh3 - - if(verbosity>3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; - if(verbosity>3) cout << " === hypothesis:: FESpace3 become FESpaceS for Vh === " << endl; - const FESpaceS * PUh = (FESpaceS *) LLUh->getpVh(); - creationHMatrixtoBEMForm ( PUh, PUh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else if( typeUh == 2 && typeVh == 5 ){ - // case Uh[i] == Mesh2 et Vh[j] = MeshL - if(verbosity>3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; - if(verbosity>3) cout << " === hypothesis:: FESpace become FESpaceL for Uh === " << endl; - - const FESpaceL * PVh = (FESpaceL *) LLVh->getpVh(); - creationHMatrixtoBEMForm ( PVh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else if( typeUh == 3 && typeVh == 4 ){ - // case Uh[i] == Mesh3 et Vh[j] = MeshS - if(verbosity>3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; - if(verbosity>3) cout << " === hypothesis:: FESpace3 become FESpaceS for Uh === " << endl; - const FESpaceS * PVh = (FESpaceS *) LLVh->getpVh(); - creationHMatrixtoBEMForm ( PVh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else{ - cerr << " BEM bilinear form " << endl; - cerr << " Block ("<< iUh <<" ,"<< jVh << ")" << endl; - cerr << " =: Pas prise en compte des FESpace inconnue de type := "<< typeFEtoString( typeUh ) << endl; - cerr << " =: avec des FESpace test de type := "<< typeFEtoString( typeVh ) << endl; - ffassert(0); - } +template< class R > +void varfBemToCompositeBlockLinearSystem_hmat(const int &iUh, const int &jVh, const int &typeUh, const int &typeVh, const generic_v_fes *LLUh, const generic_v_fes *LLVh, + const list< C_F0 > &b_largs_zz, Stack stack, Data_Bem_Solver &dsbem, HMatrixVirt< R > **Hmat) { + + // cout << "iUh=" << iUh << " , " << "jVh=" << jVh << endl; + // cout << LLUh << " " << LLVh << endl; + + // reinitialise Hmat + if (*Hmat) delete *Hmat; + *Hmat = 0; + + int VFBEM = typeVFBEM(b_largs_zz, stack); // get type of VFBEM + + // block diagonal matrix + if (typeUh == 4 && typeVh == 4) { + ffassert(iUh == jVh); // If not a block diagonal not coded yet :: Same mesh for the different FESpace + // MeshS --- MeshS + // ==== FESpace 3d Surf: inconnue et test === + const FESpaceS *PUh = (FESpaceS *)LLUh->getpVh( ); + const FESpaceS *PVh = (FESpaceS *)LLVh->getpVh( ); + + creationHMatrixtoBEMForm< R, MeshS, FESpaceS, FESpaceS >(PUh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + + } else if (typeUh == 5 && typeVh == 5) { + ffassert(iUh == jVh); // If not a block diagonal not coded yet :: Same mesh for the different FESpace + // MeshL --- MeshL + // ==== FESpace 3d Curve: inconnue et test === + const FESpaceL *PUh = (FESpaceL *)LLUh->getpVh( ); + const FESpaceL *PVh = (FESpaceL *)LLVh->getpVh( ); + + creationHMatrixtoBEMForm< R, MeshL, FESpaceL, FESpaceL >(PUh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else if (typeUh == 5 && typeVh == 2) { + // ffassert( !(iUh==jVh) ); + // case Uh[i] == MeshL et Vh[j] = Mesh2 + + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; + if (verbosity > 3) cout << " === hypothesis:: FESpace become FESpaceL for Vh === " << endl; + + const FESpaceL *PUh = (FESpaceL *)LLUh->getpVh( ); + creationHMatrixtoBEMForm< R, MeshL, FESpaceL, FESpaceL >(PUh, PUh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else if (typeUh == 4 && typeVh == 3) { + // ffassert( !(iUh==jVh) ); + // case Uh[i] == MeshS et Vh[j] = Mesh3 + + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; + if (verbosity > 3) cout << " === hypothesis:: FESpace3 become FESpaceS for Vh === " << endl; + const FESpaceS *PUh = (FESpaceS *)LLUh->getpVh( ); + creationHMatrixtoBEMForm< R, MeshS, FESpaceS, FESpaceS >(PUh, PUh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else if (typeUh == 2 && typeVh == 5) { + // case Uh[i] == Mesh2 et Vh[j] = MeshL + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; + if (verbosity > 3) cout << " === hypothesis:: FESpace become FESpaceL for Uh === " << endl; + + const FESpaceL *PVh = (FESpaceL *)LLVh->getpVh( ); + creationHMatrixtoBEMForm< R, MeshL, FESpaceL, FESpaceL >(PVh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else if (typeUh == 3 && typeVh == 4) { + // case Uh[i] == Mesh3 et Vh[j] = MeshS + if (verbosity > 3) cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; + if (verbosity > 3) cout << " === hypothesis:: FESpace3 become FESpaceS for Uh === " << endl; + const FESpaceS *PVh = (FESpaceS *)LLVh->getpVh( ); + creationHMatrixtoBEMForm< R, MeshS, FESpaceS, FESpaceS >(PVh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else { + cerr << " BEM bilinear form " << endl; + cerr << " Block (" << iUh << " ," << jVh << ")" << endl; + cerr << " =: Pas prise en compte des FESpace inconnue de type := " << typeFEtoString(typeUh) << endl; + cerr << " =: avec des FESpace test de type := " << typeFEtoString(typeVh) << endl; + ffassert(0); + } } /** * @brief - * - * @param hm_A_block matrix creuse corresponding to a local block + * + * @param hm_A_block matrix creuse corresponding to a local block */ -template< class R> -HashMatrix * varfBemToBlockDenseMatrix(const int& iUh, const int &jVh, const int &typeUh, const int &typeVh, const generic_v_fes * LLUh, const generic_v_fes * LLVh, - const list & b_largs_zz, Stack stack, Data_Bem_Solver &dsbem){ - - HashMatrix * hm_A_block = nullptr; - for (list::const_iterator i=b_largs_zz.begin(); i!=b_largs_zz.end(); i++) { - list bi; - bi.clear(); +template< class R > +HashMatrix< int, R > *varfBemToBlockDenseMatrix(const int &iUh, const int &jVh, const int &typeUh, const int &typeVh, const generic_v_fes *LLUh, const generic_v_fes *LLVh, + const list< C_F0 > &b_largs_zz, Stack stack, Data_Bem_Solver &dsbem) { + + HashMatrix< int, R > *hm_A_block = nullptr; + for (list< C_F0 >::const_iterator i = b_largs_zz.begin( ); i != b_largs_zz.end( ); i++) { + list< C_F0 > bi; + bi.clear( ); bi.push_back(*i); // creation of the H-matrix - HMatrixVirt ** Hmat = new HMatrixVirt *(); + HMatrixVirt< R > **Hmat = new HMatrixVirt< R > *( ); // construction of the H-matrix - varfBemToCompositeBlockLinearSystem_hmat( iUh, jVh, typeUh, typeVh, - LLUh, LLVh, bi, stack, dsbem,Hmat); + varfBemToCompositeBlockLinearSystem_hmat(iUh, jVh, typeUh, typeVh, LLUh, LLVh, bi, stack, dsbem, Hmat); // creation of dense matrix - KNM* M= HMatrixVirtToDense< KNM, R >(Hmat); + KNM< R > *M = HMatrixVirtToDense< KNM< R >, R >(Hmat); - HashMatrix * hm_i = new HashMatrix(*M); + HashMatrix< int, R > *hm_i = new HashMatrix< int, R >(*M); if (!hm_A_block) hm_A_block = hm_i; else { @@ -1690,736 +1644,648 @@ HashMatrix * varfBemToBlockDenseMatrix(const int& iUh, const int &jVh, co } // delete dense matrix - M->destroy(); + M->destroy( ); delete M; // delete Hmat - if( *Hmat) - delete *Hmat; + if (*Hmat) delete *Hmat; delete Hmat; } return hm_A_block; } /** - * @brief computation of matrice of interpolation for BEM + * @brief computation of matrice of interpolation for BEM * PAC(e) remove in the future when is not necessary -*/ -Matrice_Creuse * buildBlockMatrixInterpolation( const int &i, const int&j, const int&typeUh, const int& typeVh, - const generic_v_fes * LLUh, const generic_v_fes * LLVh ){ - - ffassert( !(LLUh == LLVh) ); - - if( typeUh == 5 && typeVh == 2 ){ - // case Uh[i] == MeshL et Vh[j] = Mesh2 - const FESpaceL * PUh = (FESpaceL *) LLUh->getpVh(); - const FESpace * PVh = (FESpace *) LLVh->getpVh(); - - Matrice_Creuse * MI_BBB = buildMatrixInterpolationForCompositeFESpace( PUh, PVh ); + */ +Matrice_Creuse< double > *buildBlockMatrixInterpolation(const int &i, const int &j, const int &typeUh, const int &typeVh, const generic_v_fes *LLUh, const generic_v_fes *LLVh) { + + ffassert(!(LLUh == LLVh)); + + if (typeUh == 5 && typeVh == 2) { + // case Uh[i] == MeshL et Vh[j] = Mesh2 + const FESpaceL *PUh = (FESpaceL *)LLUh->getpVh( ); + const FESpace *PVh = (FESpace *)LLVh->getpVh( ); + + Matrice_Creuse< double > *MI_BBB = buildMatrixInterpolationForCompositeFESpace< double, FESpaceL, FESpace >(PUh, PVh); return MI_BBB; - // return MI_BBB->pHM(); // (HashMatrix return) - } - else if( typeUh == 2 && typeVh == 5 ){ + // return MI_BBB->pHM(); // (HashMatrix return) + } else if (typeUh == 2 && typeVh == 5) { // case Uh[i] == MeshL et Vh[j] = Mesh2 - const FESpace * PUh = (FESpace *) LLUh->getpVh(); - const FESpaceL * PVh = (FESpaceL *) LLVh->getpVh(); + const FESpace *PUh = (FESpace *)LLUh->getpVh( ); + const FESpaceL *PVh = (FESpaceL *)LLVh->getpVh( ); - Matrice_Creuse * MI_BBB = buildMatrixInterpolationForCompositeFESpace( PVh, PUh ); + Matrice_Creuse< double > *MI_BBB = buildMatrixInterpolationForCompositeFESpace< double, FESpaceL, FESpace >(PVh, PUh); return MI_BBB; - } - else{ + } else { cerr << "other case in construction" << endl; - ffassert(0); + ffassert(0); } return nullptr; } /** * @brief - * + * * @param hm_A global matrix of a Linear System */ -template< class R> -void varfBemToCompositeBlockLinearSystem(const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &sizeUh, const long &sizeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes *LLUh, const generic_v_fes * LLVh, - const list & b_largs_zz, Stack stack, Expression const * nargs, - HashMatrix *hm_A, const int &n_name_param){ //=OpCall_FormBilinear_np::n_name_param){ +template< class R > +void varfBemToCompositeBlockLinearSystem(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &sizeUh, const long &sizeVh, const long &offsetUh, const long &offsetVh, + const generic_v_fes *LLUh, const generic_v_fes *LLVh, const list< C_F0 > &b_largs_zz, Stack stack, Expression const *nargs, HashMatrix< int, R > *hm_A, + const int &n_name_param) { //=OpCall_FormBilinear_np::n_name_param){ Data_Bem_Solver dsbem; - dsbem.factorize=0; - dsbem.initmat=true; - SetEnd_Data_Bem_Solver(stack, dsbem, nargs,n_name_param); // LIST_NAME_PARM_HMAT + dsbem.factorize = 0; + dsbem.initmat = true; + SetEnd_Data_Bem_Solver< R >(stack, dsbem, nargs, n_name_param); // LIST_NAME_PARM_HMAT // hm_A_block : is a dense block - HashMatrix * hm_A_block = varfBemToBlockDenseMatrix(i, j, typeUh, typeVh, LLUh, LLVh, b_largs_zz, stack, dsbem ); + HashMatrix< int, R > *hm_A_block = varfBemToBlockDenseMatrix< R >(i, j, typeUh, typeVh, LLUh, LLVh, b_largs_zz, stack, dsbem); - // IF LLVh is FESpace(Mesh2) ==> LLVh become LLUh (by hypothesis) + // IF LLVh is FESpace(Mesh2) ==> LLVh become LLUh (by hypothesis) // Remove this comment in the future. bool isNeedInterpolationMatrix = false; bool isNeedInterpolationMatrixLeft = false; - if( typeUh == 5 && typeVh == 2){ + if (typeUh == 5 && typeVh == 2) { isNeedInterpolationMatrix = true; isNeedInterpolationMatrixLeft = true; - } - else if( typeUh == 2 && typeVh == 5){ + } else if (typeUh == 2 && typeVh == 5) { isNeedInterpolationMatrix = true; isNeedInterpolationMatrixLeft = false; } - if( isNeedInterpolationMatrix ){ - if(verbosity>3) cout << " creation of interpolation matrix " << endl; + if (isNeedInterpolationMatrix) { + if (verbosity > 3) cout << " creation of interpolation matrix " << endl; // Creation of the Interpolation Matrix - Matrice_Creuse * MI = buildBlockMatrixInterpolation( i, j, typeUh, typeVh, LLUh, LLVh ); - MatriceMorse *mMI = MI->pHM(); + Matrice_Creuse< double > *MI = buildBlockMatrixInterpolation(i, j, typeUh, typeVh, LLUh, LLVh); + MatriceMorse< double > *mMI = MI->pHM( ); - if(isNeedInterpolationMatrixLeft ){ + if (isNeedInterpolationMatrixLeft) { // BBB=MI'*BBB; - MatriceMorse *mAB=new MatriceMorse(MI->M(), hm_A_block->m,0,0); - AddMul(*mAB,*mMI,*hm_A_block,true,false); + MatriceMorse< R > *mAB = new MatriceMorse< R >(MI->M( ), hm_A_block->m, 0, 0); + AddMul< int, double, R, R >(*mAB, *mMI, *hm_A_block, true, false); - hm_A->Add(mAB, R(1.0), false, (int) offsetVh,(int) offsetUh); + hm_A->Add(mAB, R(1.0), false, (int)offsetVh, (int)offsetUh); // test function (Vh) are the line and inconnu function (Uh) are the column delete mAB; - } - else{ + } else { // BBB=BBB*MI; - MatriceMorse *mAB=new MatriceMorse(hm_A_block->m,MI->M(),0,0); - AddMul(*mAB,*hm_A_block,*mMI,false,false); + MatriceMorse< R > *mAB = new MatriceMorse< R >(hm_A_block->m, MI->M( ), 0, 0); + AddMul< int, R, double, R >(*mAB, *hm_A_block, *mMI, false, false); - hm_A->Add(mAB, R(1.0), false, (int) offsetVh,(int) offsetUh); + hm_A->Add(mAB, R(1.0), false, (int)offsetVh, (int)offsetUh); // test function (Vh) are the line and inconnu function (Uh) are the column delete mAB; } - MI->destroy(); + MI->destroy( ); delete MI; - } - else{ - hm_A->Add(hm_A_block, R(1.0), false, (int) offsetVh,(int) offsetUh); + } else { + hm_A->Add(hm_A_block, R(1.0), false, (int)offsetVh, (int)offsetUh); // test function (Vh) are the line and inconnu function (Uh) are the column } - hm_A_block->destroy(); + hm_A_block->destroy( ); } #endif #endif - #if !defined(PARALLELE) || !defined(WITH_bemtool) || !defined(WITH_htool) -template< class R> -void varfBemToCompositeBlockLinearSystem(const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &sizeUh, const long &sizeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * LLUh, const generic_v_fes * LLVh, - const list & b_largs_zz, Stack stack, Expression const * nargs, - HashMatrix *hm_A,const int &n_name_param){ - #if !defined(WITH_bemtool) || !defined(WITH_htool) - cerr << "no BEM library" << endl; - #else - cerr << "BEM only valid in parallel" << endl; - #endif - ffassert(0); - } +template< class R > +void varfBemToCompositeBlockLinearSystem(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &sizeUh, const long &sizeVh, const long &offsetUh, const long &offsetVh, + const generic_v_fes *LLUh, const generic_v_fes *LLVh, const list< C_F0 > &b_largs_zz, Stack stack, Expression const *nargs, HashMatrix< int, R > *hm_A, + const int &n_name_param) { +#if !defined(WITH_bemtool) || !defined(WITH_htool) + cerr << "no BEM library" << endl; +#else + cerr << "BEM only valid in parallel" << endl; +#endif + ffassert(0); +} #endif +template< class K, class MMesh, class v_fes1, class v_fes2 > +void varfToCompositeBlockLinearSystemALLCASE_pfesT(const int &i, const int &j, const long &offsetUh, const long &offsetVh, const typename v_fes1::FESpace *&PUh, const typename v_fes2::FESpace *&PVh, + bool initmat, bool initx, const int &sym, const double &tgv, const list< C_F0 > &b_largs_zz, Stack stack, KN_< K > *B, KN_< K > *X, + HashMatrix< int, K > *hm_A, int *mpirankandsize, bool B_from_varf = false) { -template -void varfToCompositeBlockLinearSystemALLCASE_pfesT( const int& i, const int &j, - const long &offsetUh, const long &offsetVh, - const typename v_fes1::FESpace * &PUh, const typename v_fes2::FESpace * &PVh, - bool initmat, bool initx, const int &sym, const double &tgv, - const list & b_largs_zz, Stack stack, - KN_ *B, KN_ *X, HashMatrix *hm_A,int *mpirankandsize, bool B_from_varf=false){ - - - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes2::pfes pfes2; - typedef typename v_fes1::FESpace FESpace1; - typedef typename v_fes2::FESpace FESpace2; - - //const FESpace1 * PUh = (FESpace1*) pfesUh->getpVh(); // update the FESpace1 - //const FESpace2 * PVh = (FESpace2*) pfesVh->getpVh(); // update the FESpace2 - - MatriceCreuse * A_block = new MatriceMorse( PVh->NbOfDF, PUh->NbOfDF, 0, sym ); - MatriceCreuse & BBB(*A_block); - - long N = PVh->NbOfDF; - long M = PUh->NbOfDF; - - ffassert( B && X || (!B && !X) ); - - if(B && X){ - - KN x_block(N); - x_block=K(0.0); // initiallise the block to zero ??? - - KN b_block(M); - b_block=K(0.0); // initiallise the block to zero ??? - - if( i == j ){ - ffassert( PUh->NbOfDF == PVh->NbOfDF); // not coding yet : voir comment prendre les conditions aux limites. - //ffassert( PUh == PVh); - - // diagonal block - // give initial value to X: if necessary - if(initx){ - for(int ii=0; iiNbOfDF; ii++) - x_block[ii] = (*X)[ii+offsetUh]; - } - - // give initial value to B: if necessary - for(int ii=0; iiNbOfDF; ii++) - b_block[ii] = (*B)[ii+offsetVh]; - - varfToCompositeBlockLinearSystem_fes( initmat, initx, PUh, PVh, sym, tgv, b_largs_zz, stack, - &b_block, &x_block, BBB, mpirankandsize, B_from_varf); - - // update X: if necessary - if(initx){ - for(int ii=0; iiNbOfDF; ii++) - (*X)[ii+offsetUh] += x_block[ii]; // verification += A faire si on doit le faire ????? - } + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes2::pfes pfes2; + typedef typename v_fes1::FESpace FESpace1; + typedef typename v_fes2::FESpace FESpace2; + + // const FESpace1 * PUh = (FESpace1*) pfesUh->getpVh(); // update the FESpace1 + // const FESpace2 * PVh = (FESpace2*) pfesVh->getpVh(); // update the FESpace2 + + MatriceCreuse< K > *A_block = new MatriceMorse< K >(PVh->NbOfDF, PUh->NbOfDF, 0, sym); + MatriceCreuse< K > &BBB(*A_block); + + long N = PVh->NbOfDF; + long M = PUh->NbOfDF; + + ffassert(B && X || (!B && !X)); + + if (B && X) { + + KN< K > x_block(N); + x_block = K(0.0); // initiallise the block to zero ??? + + KN< K > b_block(M); + b_block = K(0.0); // initiallise the block to zero ??? - // update B: if necessary - for(int ii=0; iiNbOfDF; ii++) - (*B)[ii+offsetVh] += b_block[ii]; + if (i == j) { + ffassert(PUh->NbOfDF == PVh->NbOfDF); // not coding yet : voir comment prendre les conditions aux limites. + // ffassert( PUh == PVh); + + // diagonal block + // give initial value to X: if necessary + if (initx) { + for (int ii = 0; ii < PUh->NbOfDF; ii++) x_block[ii] = (*X)[ii + offsetUh]; } - else{ - // non diagonal block - // no B : so B_from_varf can be default value - varfToCompositeBlockLinearSystem_fes( initmat, false, PUh, PVh, sym, tgv, b_largs_zz, stack, - 0, 0, BBB,mpirankandsize); + + // give initial value to B: if necessary + for (int ii = 0; ii < PVh->NbOfDF; ii++) b_block[ii] = (*B)[ii + offsetVh]; + + varfToCompositeBlockLinearSystem_fes< K, MMesh, v_fes1, v_fes2 >(initmat, initx, PUh, PVh, sym, tgv, b_largs_zz, stack, &b_block, &x_block, BBB, mpirankandsize, B_from_varf); + + // update X: if necessary + if (initx) { + for (int ii = 0; ii < PUh->NbOfDF; ii++) (*X)[ii + offsetUh] += x_block[ii]; // verification += A faire si on doit le faire ????? } - } - else{ + + // update B: if necessary + for (int ii = 0; ii < PVh->NbOfDF; ii++) (*B)[ii + offsetVh] += b_block[ii]; + } else { + // non diagonal block // no B : so B_from_varf can be default value - varfToCompositeBlockLinearSystem_fes( initmat, false, PUh, PVh, sym, tgv, b_largs_zz, stack, - 0, 0, BBB,mpirankandsize); + varfToCompositeBlockLinearSystem_fes< K, MMesh, v_fes1, v_fes2 >(initmat, false, PUh, PVh, sym, tgv, b_largs_zz, stack, 0, 0, BBB, mpirankandsize); } + } else { + // no B : so B_from_varf can be default value + varfToCompositeBlockLinearSystem_fes< K, MMesh, v_fes1, v_fes2 >(initmat, false, PUh, PVh, sym, tgv, b_largs_zz, stack, 0, 0, BBB, mpirankandsize); + } - if( hm_A ){ - const HashMatrix * hm_block = dynamic_cast *>( &BBB ); - - if(mpirank ==0 && verbosity > 3) cout << "varfToCompositeBlockLinearSystem_fes::Add local block (" << i << "," << j <<")=> size nnz=" << hm_block->nnz << endl; + if (hm_A) { + const HashMatrix< int, K > *hm_block = dynamic_cast< HashMatrix< int, K > * >(&BBB); - hm_A->Add(hm_block, K(1.0), false, (int) offsetVh,(int) offsetUh); // test function (Vh) are the line and inconnu function (Uh) are the column - } - else{ - // only LinearForm and BC - ffassert( initmat == false ); - } - delete A_block; + if (mpirank == 0 && verbosity > 3) cout << "varfToCompositeBlockLinearSystem_fes::Add local block (" << i << "," << j << ")=> size nnz=" << hm_block->nnz << endl; + + hm_A->Add(hm_block, K(1.0), false, (int)offsetVh, (int)offsetUh); // test function (Vh) are the line and inconnu function (Uh) are the column + } else { + // only LinearForm and BC + ffassert(initmat == false); + } + delete A_block; } -template -void varfToCompositeBlockLinearSystemALLCASE_pfes( const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * pfesUh, const generic_v_fes * pfesVh, - bool initmat, bool initx, const int &sym, const double &tgv, - const pcommworld &commworld, const list & b_largs_zz, Stack stack, - KN_ *B, KN_ *X, HashMatrix *hm_A, bool B_from_varf){ +template< class R > +void varfToCompositeBlockLinearSystemALLCASE_pfes(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &offsetUh, const long &offsetVh, const generic_v_fes *pfesUh, + const generic_v_fes *pfesVh, bool initmat, bool initx, const int &sym, const double &tgv, const pcommworld &commworld, const list< C_F0 > &b_largs_zz, + Stack stack, KN_< R > *B, KN_< R > *X, HashMatrix< int, R > *hm_A, bool B_from_varf) { int mpirankandsize[2]; mpirankandsize[0] = 0; mpirankandsize[1] = 1; - #ifndef FFLANG - #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - #include +#ifndef FFLANG +#if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) +#include MPI_Comm comm; - if(commworld) - MPI_Comm_dup(*((MPI_Comm*)commworld), &comm); + if (commworld) + MPI_Comm_dup(*((MPI_Comm *)commworld), &comm); else - MPI_Comm_dup(MPI_COMM_WORLD, &comm); + MPI_Comm_dup(MPI_COMM_WORLD, &comm); MPI_Comm_rank(comm, &mpirankandsize[0]); MPI_Comm_size(comm, &mpirankandsize[1]); - if( verbosity >3 && mpirank ==0) cout << "PARALLEL :: mpisize=" << mpirankandsize[1] << endl; - #endif - #endif - if(typeUh == 2 && typeVh == 2){ // Mesh2 -- Mesh2 - const FESpace * PUh = (FESpace*) pfesUh->getpVh(); // update the FESpace1 - const FESpace * PVh = (FESpace*) pfesVh->getpVh(); // update the FESpace2 - - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, - initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - }else if(typeUh == 3 && typeVh == 3){ // Mesh3 -- Mesh3 - const FESpace3 * PUh = (FESpace3*) pfesUh->getpVh(); // update the FESpace1 - const FESpace3 * PVh = (FESpace3*) pfesVh->getpVh(); // update the FESpace2 - - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - }else if(typeUh == 4 && typeVh == 4){ // MeshS -- MeshS - const FESpaceS * PUh = (FESpaceS*) pfesUh->getpVh(); // update the FESpace1 - const FESpaceS * PVh = (FESpaceS*) pfesVh->getpVh(); // update the FESpace2 - - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, - PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - } - else if(typeUh == 5 && typeVh == 5){ // MeshL -- MeshL - const FESpaceL * PUh = (FESpaceL*) pfesUh->getpVh(); // update the FESpace1 - const FESpaceL * PVh = (FESpaceL*) pfesVh->getpVh(); // update the FESpace2 + if (verbosity > 3 && mpirank == 0) cout << "PARALLEL :: mpisize=" << mpirankandsize[1] << endl; +#endif +#endif + if (typeUh == 2 && typeVh == 2) { // Mesh2 -- Mesh2 + const FESpace *PUh = (FESpace *)pfesUh->getpVh( ); // update the FESpace1 + const FESpace *PVh = (FESpace *)pfesVh->getpVh( ); // update the FESpace2 - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - } - else if(typeUh == 5 && typeVh == 2){ // MeshL -- Mesh - const FESpaceL * PUh = (FESpaceL*) pfesUh->getpVh(); // update the FESpace1 - const FESpace * PVh = (FESpace*) pfesVh->getpVh(); // update the FESpace2 + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, Mesh, v_fes, v_fes >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - } - else if(typeUh == 2 && typeVh == 5){ // Mesh -- MeshL - const FESpace * PUh = (FESpace*) pfesUh->getpVh(); // update the FESpace1 - const FESpaceL * PVh = (FESpaceL*) pfesVh->getpVh(); // update the FESpace2 + } else if (typeUh == 3 && typeVh == 3) { // Mesh3 -- Mesh3 + const FESpace3 *PUh = (FESpace3 *)pfesUh->getpVh( ); // update the FESpace1 + const FESpace3 *PVh = (FESpace3 *)pfesVh->getpVh( ); // update the FESpace2 - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - } - else if(typeUh == 4 && typeVh == 3){ // MeshS -- Mesh3 - const FESpaceS * PUh = (FESpaceS*) pfesUh->getpVh(); // update the FESpace1 - const FESpace3 * PVh = (FESpace3*) pfesVh->getpVh(); // update the FESpace2 + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, Mesh3, v_fes3, v_fes3 >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - } - else if(typeUh == 3 && typeVh == 4){ // Mesh3 -- MeshS - const FESpace3 * PUh = (FESpace3*) pfesUh->getpVh(); // update the FESpace1 - const FESpaceS * PVh = (FESpaceS*) pfesVh->getpVh(); // update the FESpace2 + } else if (typeUh == 4 && typeVh == 4) { // MeshS -- MeshS + const FESpaceS *PUh = (FESpaceS *)pfesUh->getpVh( ); // update the FESpace1 + const FESpaceS *PVh = (FESpaceS *)pfesVh->getpVh( ); // update the FESpace2 - varfToCompositeBlockLinearSystemALLCASE_pfesT( i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A,mpirankandsize,B_from_varf); - - } - else{ + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshS, v_fesS, v_fesS >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + + } else if (typeUh == 5 && typeVh == 5) { // MeshL -- MeshL + const FESpaceL *PUh = (FESpaceL *)pfesUh->getpVh( ); // update the FESpace1 + const FESpaceL *PVh = (FESpaceL *)pfesVh->getpVh( ); // update the FESpace2 + + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshL, v_fesL, v_fesL >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + + } else if (typeUh == 5 && typeVh == 2) { // MeshL -- Mesh + const FESpaceL *PUh = (FESpaceL *)pfesUh->getpVh( ); // update the FESpace1 + const FESpace *PVh = (FESpace *)pfesVh->getpVh( ); // update the FESpace2 + + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshL, v_fesL, v_fes >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + + } else if (typeUh == 2 && typeVh == 5) { // Mesh -- MeshL + const FESpace *PUh = (FESpace *)pfesUh->getpVh( ); // update the FESpace1 + const FESpaceL *PVh = (FESpaceL *)pfesVh->getpVh( ); // update the FESpace2 + + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshL, v_fes, v_fesL >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + } else if (typeUh == 4 && typeVh == 3) { // MeshS -- Mesh3 + const FESpaceS *PUh = (FESpaceS *)pfesUh->getpVh( ); // update the FESpace1 + const FESpace3 *PVh = (FESpace3 *)pfesVh->getpVh( ); // update the FESpace2 + + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshS, v_fesS, v_fes3 >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + + } else if (typeUh == 3 && typeVh == 4) { // Mesh3 -- MeshS + const FESpace3 *PUh = (FESpace3 *)pfesUh->getpVh( ); // update the FESpace1 + const FESpaceS *PVh = (FESpaceS *)pfesVh->getpVh( ); // update the FESpace2 + + varfToCompositeBlockLinearSystemALLCASE_pfesT< R, MeshS, v_fes3, v_fesS >(i, j, offsetUh, offsetVh, PUh, PVh, initmat, initx, sym, tgv, b_largs_zz, stack, B, X, hm_A, mpirankandsize, B_from_varf); + + } else { cerr << "Other type for FESpace in construction, in construction ..." << endl; ffassert(0); } } -template -AnyType OpMatrixtoBilinearFormVG::Op::operator()(Stack stack) const -{ +template< class R > +AnyType OpMatrixtoBilinearFormVG< R >::Op::operator( )(Stack stack) const { assert(b && b->nargs); - pvectgenericfes * pUh= GetAny((*b->euh)(stack)); - pvectgenericfes * pVh= GetAny((*b->evh)(stack)); + pvectgenericfes *pUh = GetAny< pvectgenericfes * >((*b->euh)(stack)); + pvectgenericfes *pVh = GetAny< pvectgenericfes * >((*b->evh)(stack)); - ffassert( *pUh && *pVh ); + ffassert(*pUh && *pVh); // Update is necessary when we get "pvectgenericfes" to take account a new mesh for example. - (*pUh)->update(); - (*pVh)->update(); + (*pUh)->update( ); + (*pVh)->update( ); - if( verbosity > 5){ - (*pUh)->printPointer(); - (*pVh)->printPointer(); + if (verbosity > 5) { + (*pUh)->printPointer( ); + (*pVh)->printPointer( ); } - int NpUh = (*pUh)->N; // number of fespace in pUh - int NpVh = (*pVh)->N; // number of fespace in pVh + int NpUh = (*pUh)->N; // number of fespace in pUh + int NpVh = (*pVh)->N; // number of fespace in pVh - KN UhNbOfDf = (*pUh)->vectOfNbOfDF(); // A changer en long - KN VhNbOfDf = (*pVh)->vectOfNbOfDF(); + KN< int > UhNbOfDf = (*pUh)->vectOfNbOfDF( ); // A changer en long + KN< int > VhNbOfDf = (*pVh)->vectOfNbOfDF( ); - KN UhNbItem = (*pUh)->vectOfNbitem(); - KN VhNbItem = (*pVh)->vectOfNbitem(); + KN< int > UhNbItem = (*pUh)->vectOfNbitem( ); + KN< int > VhNbItem = (*pVh)->vectOfNbitem( ); - const KNM> & block_largs=b->block_largs; - - // check if we have a square matrix - bool A_is_square= (void*)pUh == (void*)pVh || ((*pUh)->totalNbOfDF()) == ( (*pVh)->totalNbOfDF()) ; + const KNM< list< C_F0 > > &block_largs = b->block_largs; + // check if we have a square matrix + bool A_is_square = (void *)pUh == (void *)pVh || ((*pUh)->totalNbOfDF( )) == ((*pVh)->totalNbOfDF( )); - // === simple check if A is symetrical === // + // === simple check if A is symetrical === // // voir avec les autres. - bool A_is_maybe_sym = (void*)pUh == (void*)pVh; + bool A_is_maybe_sym = (void *)pUh == (void *)pVh; // VF == true => VF type of Matrix - bool VF=false; - for(int i=0; iblock_largs(i,j)); - if( !VF ) VF=block_VF; + bool VF = false; + for (int i = 0; i < NpUh; i++) { + for (int j = 0; j < NpVh; j++) { + bool block_VF = isVF(b->block_largs(i, j)); + if (!VF) VF = block_VF; } } - //bool VF=isVF(b->largs); //=== used to set the solver ??? block matrix ??? ===/ + // bool VF=isVF(b->largs); //=== used to set the solver ??? block matrix ??? ===/ - // set parameteer of the matrix :: + // set parameteer of the matrix :: Data_Sparse_Solver ds; - ds.factorize=0; - ds.initmat=true; - int np_bem = OpCall_FormBilinear_np::n_name_param; // number of parameter with BEM + ds.factorize = 0; + ds.initmat = true; + int np_bem = OpCall_FormBilinear_np::n_name_param; // number of parameter with BEM int np = OpCall_FormBilinear_np::n_name_param - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver(stack,ds, b->nargs,np); + SetEnd_Data_Sparse_Solver< R >(stack, ds, b->nargs, np); - - // J'ai repris ce qu'il y avait. + // J'ai repris ce qu'il y avait. // PAC(e) :: Attention peut être pas compatible avec les matrices bloc. // A repenser :: surtout pour le parametre symetrique? on le met ce parametre à zéro pour l'instant. - // set ds.sym = 0 + // set ds.sym = 0 ds.sym = 0; - if(verbosity>3) - cout << " === we consider the block matrix as a non symetric matrix === (to be change in the future)" << endl; + if (verbosity > 3) cout << " === we consider the block matrix as a non symetric matrix === (to be change in the future)" << endl; - if (! A_is_square ) - { - if(verbosity>3) cout << " -- the solver is un set on rectangular matrix " << endl; - } + if (!A_is_square) { + if (verbosity > 3) cout << " -- the solver is un set on rectangular matrix " << endl; + } // A quoi cela correspond?? Gestion du stack + autre - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH aout 2007 + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH aout 2007 - Matrice_Creuse & A( * GetAny*>((*a)(stack))); - if(init) A.init(); // - if(verbosity>3){ - cout << " A.N=" << A.N() << endl; - cout << " A.M=" << A.M() << endl; + Matrice_Creuse< R > &A(*GetAny< Matrice_Creuse< R > * >((*a)(stack))); + if (init) A.init( ); // + if (verbosity > 3) { + cout << " A.N=" << A.N( ) << endl; + cout << " A.M=" << A.M( ) << endl; } - if( ! pUh || ! pVh) return SetAny *>(&A); // + if (!pUh || !pVh) return SetAny< Matrice_Creuse< R > * >(&A); // // need to define the size of the entire matrix here ==> execution error - A.resize( (*pVh)->totalNbOfDF(), (*pUh)->totalNbOfDF() ); + A.resize((*pVh)->totalNbOfDF( ), (*pUh)->totalNbOfDF( )); // test function (Vh) are the line // inconnu function (Uh) are the column // Assemble the variational form - int maxJVh=NpVh; - + int maxJVh = NpVh; + int offsetMatrixUh = 0; // loop over the block - for( int i=0; i 0 ){ maxJVh=(i+1); ffassert(maxJVh3) cout << "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; - + if (ds.sym > 0) { + maxJVh = (i + 1); + ffassert(maxJVh < NpVh); + } + for (int j = 0; j < maxJVh; j++) { + if (verbosity > 3) cout << "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; + // size of the block int N_block = UhNbOfDf[i]; int M_block = VhNbOfDf[j]; - - const list &b_largs = block_largs(i,j); - if(verbosity>2) cout << "size_block =" << b_largs.size() << endl; - if( b_largs.size()> 0){ - list largs_FEM; - list largs_BEM; - largs_FEM.clear(); - largs_BEM.clear(); - separateFEMpartBemPart( b_largs, largs_FEM, largs_BEM ); - - if(verbosity>2){ - cout << " FEM.size()=" << largs_FEM.size() << endl; - cout << " BEM.size()=" << largs_BEM.size() << endl; - } - //largs_BEM.clear(); - // // init matrice creuse of the largs argument - // Matrice_Creuse *CCC = new Matrice_Creuse() ; - // CCC->init(); // - // CCC->resize(M_block,N_block); // test function (Vh) are the line and inconnu function (Uh) are the column - // // cout << "block: i=" << i << "j=" << j << " (N,M)=" << M_block << " " << N_block << endl; - int method =1; -if(method == 1){ - if( largs_BEM.size() >0 ){ - varfBemToCompositeBlockLinearSystem( i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], (long) UhNbOfDf[i], (long) VhNbOfDf[j], - (long) offsetMatrixUh, (long) offsetMatrixVh, (*pUh)->vect[i], (*pVh)->vect[j], - largs_BEM, stack, b->nargs, A.pHM(),np_bem); + + const list< C_F0 > &b_largs = block_largs(i, j); + if (verbosity > 2) cout << "size_block =" << b_largs.size( ) << endl; + if (b_largs.size( ) > 0) { + list< C_F0 > largs_FEM; + list< C_F0 > largs_BEM; + largs_FEM.clear( ); + largs_BEM.clear( ); + separateFEMpartBemPart(b_largs, largs_FEM, largs_BEM); + + if (verbosity > 2) { + cout << " FEM.size()=" << largs_FEM.size( ) << endl; + cout << " BEM.size()=" << largs_BEM.size( ) << endl; } -}else if(method==2){ + // largs_BEM.clear(); + // // init matrice creuse of the largs argument + // Matrice_Creuse *CCC = new Matrice_Creuse() ; + // CCC->init(); // + // CCC->resize(M_block,N_block); // test function (Vh) are the line and inconnu function (Uh) are the column + // // cout << "block: i=" << i << "j=" << j << " (N,M)=" << M_block << " " << N_block << endl; + int method = 1; + if (method == 1) { + if (largs_BEM.size( ) > 0) { + varfBemToCompositeBlockLinearSystem(i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], (long)UhNbOfDf[i], (long)VhNbOfDf[j], (long)offsetMatrixUh, (long)offsetMatrixVh, (*pUh)->vect[i], + (*pVh)->vect[j], largs_BEM, stack, b->nargs, A.pHM( ), np_bem); + } + } else if (method == 2) { - if( largs_BEM.size() >0 ){ + if (largs_BEM.size( ) > 0) { #ifndef FFLANG #if defined(PARALLELE) && defined(WITH_bemtool) && defined(WITH_htool) - const list & b_largs_zz = largs_BEM; - - int VFBEM = typeVFBEM(b_largs_zz,stack); - if(VFBEM == 2){ cerr << " not implemented with BEM POTENTIAL" << endl; ffassert(0);} - Data_Bem_Solver dsbem; - dsbem.factorize=0; - dsbem.initmat=true; - SetEnd_Data_Bem_Solver(stack, dsbem, b->nargs,OpCall_FormBilinear_np::n_name_param); // LIST_NAME_PARM_HMAT - - HMatrixVirt ** Hmat = new HMatrixVirt *(); - - // - // a voir dans le futur si la difference entre bloc diagonal et bloc non diagonal a un sens. ::: 08/2022 ::: Morice - // - if( i==j ){ - - bool samemesh = (void*) (*pUh)->vect[i]->getppTh() == (void*) (*pVh)->vect[j]->getppTh(); // same Fem2D::Mesh +++ pot or kernel - if (VFBEM==1) - ffassert (samemesh); - if(init) - *Hmat =0; - *Hmat =0; - if( *Hmat) - delete *Hmat; - *Hmat =0; - - - // block diagonal matrix - if( (*pUh)->typeFE[i] == 4 && (*pVh)->typeFE[j] == 4 ){ - ffassert( i==j ); // If not a block diagonal not coded yet - // MeshS --- MeshS - // ==== FESpace 3d Surf: inconnue et test === - const FESpaceS * PUh = (FESpaceS *) (*pUh)->vect[i]->getpVh(); - const FESpaceS * PVh = (FESpaceS *) (*pVh)->vect[j]->getpVh(); - - creationHMatrixtoBEMForm(PUh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat); + const list< C_F0 > &b_largs_zz = largs_BEM; - } - else if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 5 ){ - ffassert( i==j ); // If not a block diagonal not coded yet - // MeshL --- MeshL - // ==== FESpace 3d Curve: inconnue et test === - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); - const FESpaceL * PVh = (FESpaceL *) (*pVh)->vect[j]->getpVh(); - - creationHMatrixtoBEMForm ( PUh, PVh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); - } - else{ - cerr << " BEM bilinear form " << endl; - cerr << " Block ("<< i <<" ,"<< j << ")" << endl; - cerr << " =: Pas prise en compte des FESpace inconnue de type := "<< typeFEtoString( (*pUh)->typeFE[i] ) << endl; - cerr << " =: avec des FESpace test de type := "<< typeFEtoString( (*pVh)->typeFE[j] ) << endl; + int VFBEM = typeVFBEM(b_largs_zz, stack); + if (VFBEM == 2) { + cerr << " not implemented with BEM POTENTIAL" << endl; ffassert(0); } + Data_Bem_Solver dsbem; + dsbem.factorize = 0; + dsbem.initmat = true; + SetEnd_Data_Bem_Solver< R >(stack, dsbem, b->nargs, OpCall_FormBilinear_np::n_name_param); // LIST_NAME_PARM_HMAT + + HMatrixVirt< R > **Hmat = new HMatrixVirt< R > *( ); + + // + // a voir dans le futur si la difference entre bloc diagonal et bloc non diagonal a un sens. ::: 08/2022 ::: Morice + // + if (i == j) { + + bool samemesh = (void *)(*pUh)->vect[i]->getppTh( ) == (void *)(*pVh)->vect[j]->getppTh( ); // same Fem2D::Mesh +++ pot or kernel + if (VFBEM == 1) ffassert(samemesh); + if (init) *Hmat = 0; + *Hmat = 0; + if (*Hmat) delete *Hmat; + *Hmat = 0; + + // block diagonal matrix + if ((*pUh)->typeFE[i] == 4 && (*pVh)->typeFE[j] == 4) { + ffassert(i == j); // If not a block diagonal not coded yet + // MeshS --- MeshS + // ==== FESpace 3d Surf: inconnue et test === + const FESpaceS *PUh = (FESpaceS *)(*pUh)->vect[i]->getpVh( ); + const FESpaceS *PVh = (FESpaceS *)(*pVh)->vect[j]->getpVh( ); + + creationHMatrixtoBEMForm< R, MeshS, FESpaceS, FESpaceS >(PUh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + + } else if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 5) { + ffassert(i == j); // If not a block diagonal not coded yet + // MeshL --- MeshL + // ==== FESpace 3d Curve: inconnue et test === + const FESpaceL *PUh = (FESpaceL *)(*pUh)->vect[i]->getpVh( ); + const FESpaceL *PVh = (FESpaceL *)(*pVh)->vect[j]->getpVh( ); + + creationHMatrixtoBEMForm< R, MeshL, FESpaceL, FESpaceL >(PUh, PVh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + } else { + cerr << " BEM bilinear form " << endl; + cerr << " Block (" << i << " ," << j << ")" << endl; + cerr << " =: Pas prise en compte des FESpace inconnue de type := " << typeFEtoString((*pUh)->typeFE[i]) << endl; + cerr << " =: avec des FESpace test de type := " << typeFEtoString((*pVh)->typeFE[j]) << endl; + ffassert(0); + } - // creation de la matrice dense - KNM* M= HMatrixVirtToDense< KNM, R >(Hmat); + // creation de la matrice dense + KNM< R > *M = HMatrixVirtToDense< KNM< R >, R >(Hmat); - HashMatrix *phm= new HashMatrix(*M); - MatriceCreuse *pmc(phm); + HashMatrix< int, R > *phm = new HashMatrix< int, R >(*M); + MatriceCreuse< R > *pmc(phm); - Matrice_Creuse BBB; - BBB.A=0; - BBB.A.master(pmc); + Matrice_Creuse< R > BBB; + BBB.A = 0; + BBB.A.master(pmc); - A.pHM()->Add( BBB.pHM(), R(1), false, offsetMatrixVh, offsetMatrixUh ); // test function (Vh) are the line and inconnu function (Uh) are the column + A.pHM( )->Add(BBB.pHM( ), R(1), false, offsetMatrixVh, offsetMatrixUh); // test function (Vh) are the line and inconnu function (Uh) are the column - M->destroy(); - delete M; - BBB.destroy(); - } - else{ - - bool samemesh = (void*) (*pUh)->vect[i]->getppTh() == (void*) (*pVh)->vect[j]->getppTh(); // same Fem2D::Mesh +++ pot or kernel - - if(init) - *Hmat =0; - if( *Hmat) - delete *Hmat; - *Hmat =0; - - - // block non diagonal matrix - if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2 ){ - // case Uh[i] == MeshL et Vh[j] = Mesh2 // Est ce que cela a un sens? - - cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; - //ffassert(0); - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); - creationHMatrixtoBEMForm ( PUh, PUh, VFBEM, - b_largs_zz, stack, dsbem, Hmat ); + M->destroy( ); + delete M; + BBB.destroy( ); + } else { + bool samemesh = (void *)(*pUh)->vect[i]->getppTh( ) == (void *)(*pVh)->vect[j]->getppTh( ); // same Fem2D::Mesh +++ pot or kernel + + if (init) *Hmat = 0; + if (*Hmat) delete *Hmat; + *Hmat = 0; + + // block non diagonal matrix + if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2) { + // case Uh[i] == MeshL et Vh[j] = Mesh2 // Est ce que cela a un sens? + + cout << " === creation de la matrice BEM pour un bloc non diagonaux === " << endl; + // ffassert(0); + const FESpaceL *PUh = (FESpaceL *)(*pUh)->vect[i]->getpVh( ); + creationHMatrixtoBEMForm< R, MeshL, FESpaceL, FESpaceL >(PUh, PUh, VFBEM, b_largs_zz, stack, dsbem, Hmat); + + } + + else { + cerr << " BEM bilinear form " << endl; + cerr << " Block (" << i << " ," << j << ")" << endl; + cerr << " =: Pas prise en compte des FESpace inconnue de type := " << typeFEtoString((*pUh)->typeFE[i]) << endl; + cerr << " =: avec des FESpace test de type := " << typeFEtoString((*pVh)->typeFE[j]) << endl; + ffassert(0); + } + + // creation de la matrice dense + + KNM< R > *M = HMatrixVirtToDense< KNM< R >, R >(Hmat); + + HashMatrix< int, R > *phm = new HashMatrix< int, R >(*M); + MatriceCreuse< R > *pmc(phm); + + Matrice_Creuse< R > *BBB = new Matrice_Creuse< R >( ); + BBB->A = 0; + BBB->A.master(pmc); + // BBB->resize(356,356); + + // BEM matrix is constructed with different FESpace + ffassert((*pUh)->vect[i]->getpVh( ) != (*pVh)->vect[j]->getpVh( )); + + if ((*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2) { + // case Uh[i] == MeshL et Vh[j] = Mesh2 + const FESpaceL *PUh = (FESpaceL *)(*pUh)->vect[i]->getpVh( ); + const FESpace *PVh = (FESpace *)(*pVh)->vect[j]->getpVh( ); + // construction of the matrix of interpolation + + // Matrice_Creuse * MI_BBB=new Matrice_Creuse(); // = buildMatrixInterpolationForCompositeFESpace( PUh, PVh ); + Matrice_Creuse< double > *MI_BBB = buildMatrixInterpolationForCompositeFESpace< double, FESpaceL, FESpace >(PUh, PVh); + + // MI_BBB->resize(356,2922); + // multiplication matrix*matrix + + MatriceMorse< double > *mA = MI_BBB->pHM( ); + MatriceMorse< R > *mB = BBB->pHM( ); + + // cout << "A=MI " << MI_BBB->N() << " " << MI_BBB->M() << endl; + // cout << "B=BBB " << BBB->N() << " " << BBB->M() << endl; + + ffassert(MI_BBB->M( ) >= BBB->M( )); + + ffassert(MI_BBB->N( ) == BBB->M( )); + + MatriceMorse< R > *mAB = new MatriceMorse< R >(MI_BBB->M( ), BBB->M( ), 0, 0); + AddMul< int, double, R, R >(*mAB, *mA, *mB, true, false); // BBB=MI_BBB'*BBB; + + A.pHM( )->Add(mAB, R(1), false, offsetMatrixVh, offsetMatrixUh); // test function (Vh) are the line and inconnu function (Uh) are the column + + delete mAB; + MI_BBB->destroy( ); + delete MI_BBB; + + } else { + cerr << "==== to do ==== " << endl; + ffassert(0); + } + M->destroy( ); + delete M; + BBB->destroy( ); + delete BBB; } - - else{ - cerr << " BEM bilinear form " << endl; - cerr << " Block ("<< i <<" ,"<< j << ")" << endl; - cerr << " =: Pas prise en compte des FESpace inconnue de type := "<< typeFEtoString( (*pUh)->typeFE[i] ) << endl; - cerr << " =: avec des FESpace test de type := "<< typeFEtoString( (*pVh)->typeFE[j] ) << endl; - ffassert(0); - } - - // creation de la matrice dense - - KNM* M = HMatrixVirtToDense< KNM, R >(Hmat); - - HashMatrix *phm= new HashMatrix(*M); - MatriceCreuse *pmc(phm); - - Matrice_Creuse *BBB=new Matrice_Creuse(); - BBB->A=0; - BBB->A.master(pmc); - //BBB->resize(356,356); - - // BEM matrix is constructed with different FESpace - ffassert( (*pUh)->vect[i]->getpVh() != (*pVh)->vect[j]->getpVh() ) ; - - - if( (*pUh)->typeFE[i] == 5 && (*pVh)->typeFE[j] == 2 ){ - // case Uh[i] == MeshL et Vh[j] = Mesh2 - const FESpaceL * PUh = (FESpaceL *) (*pUh)->vect[i]->getpVh(); - const FESpace * PVh = (FESpace *) (*pVh)->vect[j]->getpVh(); - // construction of the matrix of interpolation - - //Matrice_Creuse * MI_BBB=new Matrice_Creuse(); // = buildMatrixInterpolationForCompositeFESpace( PUh, PVh ); - Matrice_Creuse * MI_BBB = buildMatrixInterpolationForCompositeFESpace( PUh, PVh ); - - //MI_BBB->resize(356,2922); - // multiplication matrix*matrix - - MatriceMorse *mA= MI_BBB->pHM(); - MatriceMorse *mB= BBB->pHM(); - - //cout << "A=MI " << MI_BBB->N() << " " << MI_BBB->M() << endl; - //cout << "B=BBB " << BBB->N() << " " << BBB->M() << endl; - - ffassert( MI_BBB->M() >= BBB->M() ); - - ffassert( MI_BBB->N() == BBB->M() ); - - MatriceMorse *mAB=new MatriceMorse(MI_BBB->M(), BBB->M(),0,0); - AddMul(*mAB,*mA,*mB,true,false); // BBB=MI_BBB'*BBB; - - A.pHM()->Add( mAB, R(1), false, offsetMatrixVh, offsetMatrixUh ); // test function (Vh) are the line and inconnu function (Uh) are the column - - delete mAB; - MI_BBB->destroy(); - delete MI_BBB; - - } - else{ - cerr << "==== to do ==== " << endl; - ffassert(0); - } - M->destroy(); - delete M; - BBB->destroy(); - delete BBB; - - } - if( *Hmat) - delete *Hmat; - delete Hmat; + if (*Hmat) delete *Hmat; + delete Hmat; #endif #endif + } } -} - if( largs_FEM.size() >0 ){ + if (largs_FEM.size( ) > 0) { // computation of the matrix - const list & b_largs_zz = largs_FEM; - - varfToCompositeBlockLinearSystemALLCASE_pfes( i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], - offsetMatrixUh, offsetMatrixVh, (*pUh)->vect[i], (*pVh)->vect[j], - true, false, ds.sym, ds.tgv, ds.commworld, - b_largs_zz, stack, - 0, 0, A.pHM()); + const list< C_F0 > &b_largs_zz = largs_FEM; + + varfToCompositeBlockLinearSystemALLCASE_pfes< R >(i, j, (*pUh)->typeFE[i], (*pVh)->typeFE[j], offsetMatrixUh, offsetMatrixVh, (*pUh)->vect[i], (*pVh)->vect[j], true, false, ds.sym, ds.tgv, + ds.commworld, b_largs_zz, stack, 0, 0, A.pHM( )); } - if(mpirank ==0 && verbosity >3) cout << "Add block (" << i << "," << j <<")=> size nnz=" << A.pHM()->nnz << endl; - //delete CCC; - } // end loop bb_largs_ii - offsetMatrixVh += VhNbOfDf[j]; - } // end loop j + if (mpirank == 0 && verbosity > 3) cout << "Add block (" << i << "," << j << ")=> size nnz=" << A.pHM( )->nnz << endl; + // delete CCC; + } // end loop bb_largs_ii + offsetMatrixVh += VhNbOfDf[j]; + } // end loop j offsetMatrixUh += UhNbOfDf[i]; - } // end loop i - - //pUh = nullptr; - //pVh = nullptr; - //if( *pUh ){ (*pUh)->destroy();} + } // end loop i - A.pHM()->half = ds.sym; - if (A_is_square) - SetSolver(stack,VF,*A.A,ds); + // pUh = nullptr; + // pVh = nullptr; + // if( *pUh ){ (*pUh)->destroy();} - return SetAny *>(&A); -} + A.pHM( )->half = ds.sym; + if (A_is_square) SetSolver(stack, VF, *A.A, ds); + return SetAny< Matrice_Creuse< R > * >(&A); +} // Mesh - Mesh -template void varfToCompositeBlockLinearSystem< double, Mesh, FESpace, FESpace> - (bool initmat, bool initx, const FESpace * PUh, const FESpace * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); - -template void varfToCompositeBlockLinearSystem< Complex, Mesh, FESpace, FESpace> - (bool initmat, bool initx, const FESpace * PUh, const FESpace * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< double, Mesh, FESpace, FESpace >(bool initmat, bool initx, const FESpace *PUh, const FESpace *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< double > *B, KN_< double > *X, MatriceCreuse< double > &A, + int *mpirankandsize, bool B_from_varf); + +template void varfToCompositeBlockLinearSystem< Complex, Mesh, FESpace, FESpace >(bool initmat, bool initx, const FESpace *PUh, const FESpace *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< Complex > *B, KN_< Complex > *X, MatriceCreuse< Complex > &A, + int *mpirankandsize, bool B_from_varf); // MeshL - MeshL -template void varfToCompositeBlockLinearSystem< double, MeshL, FESpaceL, FESpaceL> - (bool initmat, bool initx, const FESpaceL * PUh, const FESpaceL * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< double, MeshL, FESpaceL, FESpaceL >(bool initmat, bool initx, const FESpaceL *PUh, const FESpaceL *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< double > *B, KN_< double > *X, MatriceCreuse< double > &A, + int *mpirankandsize, bool B_from_varf); -template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpaceL, FESpaceL> - (bool initmat, bool initx, const FESpaceL * PUh, const FESpaceL * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpaceL, FESpaceL >(bool initmat, bool initx, const FESpaceL *PUh, const FESpaceL *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< Complex > *B, KN_< Complex > *X, MatriceCreuse< Complex > &A, + int *mpirankandsize, bool B_from_varf); // Mesh - MeshL -template void varfToCompositeBlockLinearSystem< double, MeshL, FESpace, FESpaceL> - (bool initmat, bool initx, const FESpace * PUh, const FESpaceL * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< double, MeshL, FESpace, FESpaceL >(bool initmat, bool initx, const FESpace *PUh, const FESpaceL *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< double > *B, KN_< double > *X, MatriceCreuse< double > &A, + int *mpirankandsize, bool B_from_varf); -template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpace, FESpaceL> - (bool initmat, bool initx, const FESpace * PUh, const FESpaceL * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpace, FESpaceL >(bool initmat, bool initx, const FESpace *PUh, const FESpaceL *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< Complex > *B, KN_< Complex > *X, MatriceCreuse< Complex > &A, + int *mpirankandsize, bool B_from_varf); // MeshL - Mesh -template void varfToCompositeBlockLinearSystem< double, MeshL, FESpaceL, FESpace> - (bool initmat, bool initx, const FESpaceL * PUh, const FESpace * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< double, MeshL, FESpaceL, FESpace >(bool initmat, bool initx, const FESpaceL *PUh, const FESpace *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< double > *B, KN_< double > *X, MatriceCreuse< double > &A, + int *mpirankandsize, bool B_from_varf); -template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpaceL, FESpace> - (bool initmat, bool initx, const FESpaceL * PUh, const FESpace * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); +template void varfToCompositeBlockLinearSystem< Complex, MeshL, FESpaceL, FESpace >(bool initmat, bool initx, const FESpaceL *PUh, const FESpace *PVh, const int &sym, const double &tgv, + const list< C_F0 > &largs, Stack stack, KN_< Complex > *B, KN_< Complex > *X, MatriceCreuse< Complex > &A, + int *mpirankandsize, bool B_from_varf); // FEM block -template void varfToCompositeBlockLinearSystemALLCASE_pfes( const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * pfesUh, const generic_v_fes * pfesVh, - bool initmat, bool initx, const int &sym, const double &tgv, - const pcommworld &comm, const list & b_largs_zz, Stack stack, - KN_ *B, KN_ *X, HashMatrix *hm_A, bool B_from_varf=false); - -template void varfToCompositeBlockLinearSystemALLCASE_pfes( const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * pfesUh, const generic_v_fes * pfesVh, - bool initmat, bool initx, const int &sym, const double &tgv, - const pcommworld &comm, const list & b_largs_zz, Stack stack, - KN_ *B, KN_ *X, HashMatrix *hm_A, bool B_from_varf=false); +template void varfToCompositeBlockLinearSystemALLCASE_pfes(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &offsetUh, const long &offsetVh, const generic_v_fes *pfesUh, + const generic_v_fes *pfesVh, bool initmat, bool initx, const int &sym, const double &tgv, const pcommworld &comm, + const list< C_F0 > &b_largs_zz, Stack stack, KN_< double > *B, KN_< double > *X, HashMatrix< int, double > *hm_A, bool B_from_varf = false); +template void varfToCompositeBlockLinearSystemALLCASE_pfes(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &offsetUh, const long &offsetVh, const generic_v_fes *pfesUh, + const generic_v_fes *pfesVh, bool initmat, bool initx, const int &sym, const double &tgv, const pcommworld &comm, + const list< C_F0 > &b_largs_zz, Stack stack, KN_< Complex > *B, KN_< Complex > *X, HashMatrix< int, Complex > *hm_A, + bool B_from_varf = false); // BEM block -template<> void varfBemToCompositeBlockLinearSystem(const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &sizeUh, const long &sizeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * LLUh, const generic_v_fes *LLVh, - const list & b_largs_zz, Stack stack, Expression const * nargs, - HashMatrix *hm_A,const int &n_name_param){ - ffassert(0); - } - -template void varfBemToCompositeBlockLinearSystem(const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &sizeUh, const long &sizeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes * LLUh, const generic_v_fes *LLVh, - const list & b_largs_zz, Stack stack, Expression const *nargs, - HashMatrix *hm_A,const int &n_name_param); - -template AnyType OpMatrixtoBilinearFormVG::Op::operator()(Stack stack) const; - -template AnyType OpMatrixtoBilinearFormVG::Op::operator()(Stack stack) const; +template<> +void varfBemToCompositeBlockLinearSystem< double >(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &sizeUh, const long &sizeVh, const long &offsetUh, const long &offsetVh, + const generic_v_fes *LLUh, const generic_v_fes *LLVh, const list< C_F0 > &b_largs_zz, Stack stack, Expression const *nargs, + HashMatrix< int, double > *hm_A, const int &n_name_param) { + ffassert(0); +} + +template void varfBemToCompositeBlockLinearSystem(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &sizeUh, const long &sizeVh, const long &offsetUh, const long &offsetVh, + const generic_v_fes *LLUh, const generic_v_fes *LLVh, const list< C_F0 > &b_largs_zz, Stack stack, Expression const *nargs, + HashMatrix< int, Complex > *hm_A, const int &n_name_param); + +template AnyType OpMatrixtoBilinearFormVG< double >::Op::operator( )(Stack stack) const; + +template AnyType OpMatrixtoBilinearFormVG< Complex >::Op::operator( )(Stack stack) const; diff --git a/src/fflib/compositeFESpace.hpp b/src/fflib/compositeFESpace.hpp index a9da1285f..6156c8e0d 100644 --- a/src/fflib/compositeFESpace.hpp +++ b/src/fflib/compositeFESpace.hpp @@ -2,85 +2,70 @@ #ifndef COMPOSITE_FESPACE_HPP_ #define COMPOSITE_FESPACE_HPP_ -template // to make A=linearform(x) -struct OpMatrixtoBilinearFormVG - : public OneOperator -{ - typedef typename Call_CompositeFormBilinear::const_iterator const_iterator; +template< class R > // to make A=linearform(x) +struct OpMatrixtoBilinearFormVG : public OneOperator { + typedef typename Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >::const_iterator const_iterator; int init; - + class Op : public E_F0mps { - public: - Call_CompositeFormBilinear *b; - Expression a; - int init; - //AnyType operator()(Stack s) const; - - Op(Expression aa,Expression bb,int initt) - : b(new Call_CompositeFormBilinear(* dynamic_cast *>(bb))),a(aa),init(initt) - { + public: + Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes > *b; + Expression a; + int init; + // AnyType operator()(Stack s) const; + + Op(Expression aa, Expression bb, int initt) + : b(new Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >(*dynamic_cast< const Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes > * >(bb))), a(aa), + init(initt) { assert(b && b->nargs); - int NN = (int) b->euh->componentNbitem().size(); - int MM = (int) b->evh->componentNbitem().size(); + int NN = (int)b->euh->componentNbitem( ).size( ); + int MM = (int)b->evh->componentNbitem( ).size( ); - bool total_iscmplx=false; + bool total_iscmplx = false; // loop over block - for(int i=0; iblock_largs(i,j),IsComplexType::value) ; + bool iscmplx = FieldOfForm(b->block_largs(i, j), IsComplexType< R >::value); // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; - ffassert( (iscmplx) == IsComplexType::value); - if( !total_iscmplx ) total_iscmplx=iscmplx; + ffassert((iscmplx) == IsComplexType< R >::value); + if (!total_iscmplx) total_iscmplx = iscmplx; } } } - operator aType () const { return atype *>();} + operator aType( ) const { return atype< Matrice_Creuse< R > * >( ); } - AnyType operator()(Stack s) const; + AnyType operator( )(Stack s) const; }; - E_F0 * code(const basicAC_F0 & args) const - { return new Op(to*>(args[0]),args[1],init); } - OpMatrixtoBilinearFormVG(int initt=0) : - OneOperator(atype*>(),atype*>(),atype*>()), - init(initt){}; - + E_F0 *code(const basicAC_F0 &args) const { return new Op(to< Matrice_Creuse< R > * >(args[0]), args[1], init); } + OpMatrixtoBilinearFormVG(int initt = 0) + : OneOperator(atype< Matrice_Creuse< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< const Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes > * >( )), init(initt) {}; }; - string typeFEtoString(int typeFE); - - /** - * @brief Builds a new largs whit each element are included in one block - * @param largs list of argument of the initial Forms - * @param NpUh number of FESpace in Uh - * @param NpVh number of FESpace in Vh - * @param indexBlockUh give the index of the block for a given component of FESpace Uh - * @param indexBlockVh give the index of the block for a given component of FESpace Vh - * - */ - -list creationLargsForCompositeFESpace( const list & largs, const int &NpUh, const int &NpVh, - const KN &indexBlockUh, const KN &indexBlockVh ); - + * @brief Builds a new largs whit each element are included in one block + * @param largs list of argument of the initial Forms + * @param NpUh number of FESpace in Uh + * @param NpVh number of FESpace in Vh + * @param indexBlockUh give the index of the block for a given component of FESpace Uh + * @param indexBlockVh give the index of the block for a given component of FESpace Vh + * + */ +list< C_F0 > creationLargsForCompositeFESpace(const list< C_F0 > &largs, const int &NpUh, const int &NpVh, const KN< int > &indexBlockUh, const KN< int > &indexBlockVh); -KNM< list > computeBlockLargs( const list & largs, const int &NpUh, const int &NpVh, const KN &indexBlockUh, const KN &indexBlockVh ); - +KNM< list< C_F0 > > computeBlockLargs(const list< C_F0 > &largs, const int &NpUh, const int &NpVh, const KN< int > &indexBlockUh, const KN< int > &indexBlockVh); +// Info necessaire :: " block_largs, localIndexInTheBlockUh, localIndexInTheBlockVh, NpUh, NpVh +void changeComponentFormCompositeFESpace(const KN< int > &localIndexInTheBlockUh, const KN< int > &localIndexInTheBlockVh, KNM< list< C_F0 > > &block_largs); -// Info necessaire :: " block_largs, localIndexInTheBlockUh, localIndexInTheBlockVh, NpUh, NpVh -void changeComponentFormCompositeFESpace( const KN &localIndexInTheBlockUh, const KN &localIndexInTheBlockVh, - KNM< list > & block_largs ); - -void reverseChangeComponentFormCompositeFESpace(const KN &beginBlockUh, const KN &beginBlockVh, - KNM< list > & block_largs); +void reverseChangeComponentFormCompositeFESpace(const KN< int > &beginBlockUh, const KN< int > &beginBlockVh, KNM< list< C_F0 > > &block_largs); -template -MatriceMorse * buildInterpolationMatrixT(const FESpaceT1 & Uh,const FESpaceT2 & Vh,void *data); +template< class FESpaceT1, class FESpaceT2 > +MatriceMorse< R > *buildInterpolationMatrixT(const FESpaceT1 &Uh, const FESpaceT2 &Vh, void *data); /* template< > @@ -88,85 +73,73 @@ MatriceMorse * buildInterpolationMatrixT(const FESpaceL & U */ template< class R, class FESpaceT1, class FESpaceT2 > -Matrice_Creuse * buildMatrixInterpolationForCompositeFESpace(const FESpaceT1 * Uh ,const FESpaceT2 * Vh); +Matrice_Creuse< R > *buildMatrixInterpolationForCompositeFESpace(const FESpaceT1 *Uh, const FESpaceT2 *Vh); // print information of the varf -void listOfComponentBilinearForm(const list & largs); +void listOfComponentBilinearForm(const list< C_F0 > &largs); /** - * @brief determine if we have BEM bilinear operator in a subblock and the type - * @param largs list of argument of the Bilinear Form - */ + * @brief determine if we have BEM bilinear operator in a subblock and the type + * @param largs list of argument of the Bilinear Form + */ /* This function give the good result if only if the FESpace inconnu and FESpace test are scalar FESpace - due to this check : + due to this check : if( finc.first==0 && ftest.first==0) // only first component for finc and ftest */ -int haveBemSubMatrixBlock(const list & largs, int Uh_NbItem, int Vh_NbItem); +int haveBemSubMatrixBlock(const list< C_F0 > &largs, int Uh_NbItem, int Vh_NbItem); /** - * @brief largs separate in two part : BEM (H-matrix) and FEM - * @param largs list of argument of the Bilinear Form - * @param largs_FEM list of argument for the FEM part - * @param largs_BEM list of argument for the BEM part (included sometimes mass matrix ) that be compressed in H-matrix - */ + * @brief largs separate in two part : BEM (H-matrix) and FEM + * @param largs list of argument of the Bilinear Form + * @param largs_FEM list of argument for the FEM part + * @param largs_BEM list of argument for the BEM part (included sometimes mass matrix ) that be compressed in H-matrix + */ /* This function must be call if we have BEM Bilinear operator in a block. - -*/ -void separateFEMpartBemPart(const list & largs, list &largs_FEM, list &largs_BEM ); +*/ +void separateFEMpartBemPart(const list< C_F0 > &largs, list< C_F0 > &largs_FEM, list< C_F0 > &largs_BEM); /** - * @brief Function to delete element of newlargs = list to avoid memory leak. - * @param largs list of argument of the composite FESpace gene - */ + * @brief Function to delete element of newlargs = list to avoid memory leak. + * @param largs list of argument of the composite FESpace gene + */ /* remark: only FormBilinear and BemFormBilinear is deleted */ -void deleteNewLargs(list &newlargs); +void deleteNewLargs(list< C_F0 > &newlargs); /** - * @brief Function to create a matrix of a composite FESpace (FreeFem Matrix) - * @param largs list of argument of the composite FESpace gene - */ - -template -void varfToCompositeBlockMatrix( const int &i_Uh, const int &j_Vh, pvectgenericfes *pUh, pvectgenericfes *pVh, - //vect_generic_v_fes **pUh, vect_generic_v_fes **pVh, - const int &sym, const double &tgv, const list & b_largs_zz, Stack stack, - Matrice_Creuse &BBB); + * @brief Function to create a matrix of a composite FESpace (FreeFem Matrix) + * @param largs list of argument of the composite FESpace gene + */ + +template< class R > +void varfToCompositeBlockMatrix(const int &i_Uh, const int &j_Vh, pvectgenericfes *pUh, pvectgenericfes *pVh, + // vect_generic_v_fes **pUh, vect_generic_v_fes **pVh, + const int &sym, const double &tgv, const list< C_F0 > &b_largs_zz, Stack stack, Matrice_Creuse< R > &BBB); /* -template -void computationGlobalMatrix( const KNM> &block_largs, Expression *nargs, +template +void computationGlobalMatrix( const KNM> &block_largs, Expression *nargs, pvectgenericfes * pUh, pvectgenericfes * pVh ){ } */ -template -void varfToCompositeBlockLinearSystem(bool initmat, bool initx, const FESpace1 * PUh, const FESpace2 * PVh, - const int &sym, const double &tgv, const list & largs, Stack stack, - KN_ *B, KN_ *X, MatriceCreuse &A,int *mpirankandsize, bool B_from_varf); - - -template< class R> -void varfBemToCompositeBlockLinearSystem(const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &sizeUh, const long &sizeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes *LLUh, const generic_v_fes * LLVh, - const list & b_largs_zz, Stack stack, Expression const * nargs, - HashMatrix *hm_A, const int &n_name_param); - -template -void varfToCompositeBlockLinearSystemALLCASE_pfes( const int& i, const int &j, - const int &typeUh, const int &typeVh, - const long &offsetUh, const long &offsetVh, - const generic_v_fes *pfesUh, const generic_v_fes *pfesVh, - bool initmat, bool initx, const int &sym, const double &tgv, - const pcommworld &comm, const list & b_largs_zz, Stack stack, - KN_ *B, KN_ *X, HashMatrix *hm_A, bool B_from_varf=false); +template< class R, class MMesh, class FESpace1, class FESpace2 > +void varfToCompositeBlockLinearSystem(bool initmat, bool initx, const FESpace1 *PUh, const FESpace2 *PVh, const int &sym, const double &tgv, const list< C_F0 > &largs, Stack stack, KN_< R > *B, + KN_< R > *X, MatriceCreuse< R > &A, int *mpirankandsize, bool B_from_varf); + +template< class R > +void varfBemToCompositeBlockLinearSystem(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &sizeUh, const long &sizeVh, const long &offsetUh, const long &offsetVh, + const generic_v_fes *LLUh, const generic_v_fes *LLVh, const list< C_F0 > &b_largs_zz, Stack stack, Expression const *nargs, HashMatrix< int, R > *hm_A, + const int &n_name_param); + +template< class K > +void varfToCompositeBlockLinearSystemALLCASE_pfes(const int &i, const int &j, const int &typeUh, const int &typeVh, const long &offsetUh, const long &offsetVh, const generic_v_fes *pfesUh, + const generic_v_fes *pfesVh, bool initmat, bool initx, const int &sym, const double &tgv, const pcommworld &comm, const list< C_F0 > &b_largs_zz, + Stack stack, KN_< K > *B, KN_< K > *X, HashMatrix< int, K > *hm_A, bool B_from_varf = false); #endif \ No newline at end of file diff --git a/src/fflib/endian.hpp b/src/fflib/endian.hpp index 99b3742b9..1cb151a0e 100644 --- a/src/fflib/endian.hpp +++ b/src/fflib/endian.hpp @@ -28,20 +28,25 @@ // the order of the bytes is the same order of // a shift operator << in a integer. // -------------------------------------------- -template -inline void w_endian(const unsigned char *c, unsigned char *k) { cerr << " L = " << L << endl; assert(0); } -template -inline void r_endian(const unsigned char *c, unsigned char *k) { assert(0); } +template< int L > +inline void w_endian(const unsigned char *c, unsigned char *k) { + cerr << " L = " << L << endl; + assert(0); +} +template< int L > +inline void r_endian(const unsigned char *c, unsigned char *k) { + assert(0); +} template<> -inline void w_endian<1>(const unsigned char *c, unsigned char *k) { *k = *c; } +inline void w_endian< 1 >(const unsigned char *c, unsigned char *k) { + *k = *c; +} template<> -inline void w_endian<8>(const unsigned char *c, unsigned char *k) { - static const unsigned long long ull = - ( 0ULL + (1ULL << 8) + (2ULL << 16) + (3ULL << 24) - + (4ULL << 32) + (5ULL << 40) + (6ULL << 48) + (7ULL << 56) ); - static const unsigned char *o = reinterpret_cast(&ull); +inline void w_endian< 8 >(const unsigned char *c, unsigned char *k) { + static const unsigned long long ull = (0ULL + (1ULL << 8) + (2ULL << 16) + (3ULL << 24) + (4ULL << 32) + (5ULL << 40) + (6ULL << 48) + (7ULL << 56)); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&ull); // cout << " ++++ " << ull << " .. "; // for (int i = 0; i < 8; ++i) cout << (int)o[i]; assert(8 == sizeof(ull)); @@ -70,9 +75,9 @@ template std::ostream &dump(std::ostream & f, const T &t) { */ template<> -inline void w_endian<4>(const unsigned char *c, unsigned char *k) { +inline void w_endian< 4 >(const unsigned char *c, unsigned char *k) { static const unsigned int u0123 = 0U + (1U << 8) + (2U << 16) + (3U << 24); - static const unsigned char *o = reinterpret_cast(&u0123); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&u0123); // order c[o^-1]: if o: 0123 -> 2130 // if c == 1U + (2U << 8) + (3U << 16) + (4U << 24); // then k[0] = 1, k[1] = 2, k[2] = 3, k[3] = 4 @@ -84,23 +89,23 @@ inline void w_endian<4>(const unsigned char *c, unsigned char *k) { } template<> -inline void w_endian<2>(const unsigned char *c, unsigned char *k) { +inline void w_endian< 2 >(const unsigned char *c, unsigned char *k) { static const unsigned short int u01 = 0U + (1U << 8); - static const unsigned char *o = reinterpret_cast(&u01); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&u01); assert(2 == sizeof(u01)); k[o[0]] = c[0]; k[o[1]] = c[1]; } template<> -inline void r_endian<1>(const unsigned char *c, unsigned char *k) { *k = *c; } +inline void r_endian< 1 >(const unsigned char *c, unsigned char *k) { + *k = *c; +} template<> -inline void r_endian<8>(const unsigned char *c, unsigned char *k) { - static const unsigned long long ull = - ( 0ULL + (1ULL << 8) + (2ULL << 16) + (3ULL << 24) - + (4ULL << 32) + (5ULL << 40) + (6ULL << 48) + (7ULL << 56) ); - static const unsigned char *o = reinterpret_cast(&ull); +inline void r_endian< 8 >(const unsigned char *c, unsigned char *k) { + static const unsigned long long ull = (0ULL + (1ULL << 8) + (2ULL << 16) + (3ULL << 24) + (4ULL << 32) + (5ULL << 40) + (6ULL << 48) + (7ULL << 56)); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&ull); assert(8 == sizeof(ull)); k[0] = c[o[0]]; @@ -114,9 +119,9 @@ inline void r_endian<8>(const unsigned char *c, unsigned char *k) { } template<> -inline void r_endian<4>(const unsigned char c[4], unsigned char k[4]) { +inline void r_endian< 4 >(const unsigned char c[4], unsigned char k[4]) { static const unsigned int u0123 = 0U + (1U << 8) + (2U << 16) + (3U << 24); - static const unsigned char *o = reinterpret_cast(&u0123); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&u0123); assert(4 == sizeof(u0123)); k[0] = c[o[0]]; @@ -126,25 +131,25 @@ inline void r_endian<4>(const unsigned char c[4], unsigned char k[4]) { } template<> -inline void r_endian<2>(const unsigned char c[2], unsigned char k[2]) { - static const unsigned short u01 = 0U + (1U << 8) ; - static const unsigned char *o = reinterpret_cast(&u01); +inline void r_endian< 2 >(const unsigned char c[2], unsigned char k[2]) { + static const unsigned short u01 = 0U + (1U << 8); + static const unsigned char *o = reinterpret_cast< const unsigned char * >(&u01); assert(2 == sizeof(u01)); k[0] = c[o[0]]; k[1] = c[o[1]]; } -template -inline T r_endian(const T & t ) { +template< class T > +inline T r_endian(const T &t) { T r; - r_endian(reinterpret_cast(&t), reinterpret_cast(&r)); + r_endian< sizeof(t) >(reinterpret_cast< const unsigned char * >(&t), reinterpret_cast< unsigned char * >(&r)); return r; } -template -inline T w_endian(const T & t ) { +template< class T > +inline T w_endian(const T &t) { T r; - w_endian(reinterpret_cast(&t), reinterpret_cast(&r)); + w_endian< sizeof(t) >(reinterpret_cast< const unsigned char * >(&t), reinterpret_cast< unsigned char * >(&r)); return r; } diff --git a/src/fflib/environment.cpp b/src/fflib/environment.cpp index 39e89d49e..e6fee93df 100644 --- a/src/fflib/environment.cpp +++ b/src/fflib/environment.cpp @@ -30,7 +30,7 @@ // set in getprog-unix.hpp in Graphic dir const char *prognamearg = 0; -extern void (*initparallele)(int &, char **&); // to know if mpiversion ... +extern void (*initparallele)(int &, char **&); // to know if mpiversion ... #ifdef PURE_WIN32 #include @@ -52,10 +52,10 @@ const char dirnsep = BACKSLACH, dirsep = SLACH; #include -int dirExists (const string & path) { +int dirExists(const string &path) { struct stat info; - if (stat(path.c_str(), &info ) != 0) + if (stat(path.c_str( ), &info) != 0) return 0; else if (info.st_mode & S_IFDIR) return 1; @@ -63,85 +63,85 @@ int dirExists (const string & path) { return 0; } -string DirName (const char *f) { +string DirName(const char *f) { const char *c = strrchr(f, dirsep); - if (!c) return string(""); - else return string(f, strlen(f)-strlen(c)); + if (!c) + return string(""); + else + return string(f, strlen(f) - strlen(c)); } -string TransDir (string dir, string adddir="") { - for (size_t i = 0; i < dir.size(); ++i) +string TransDir(string dir, string adddir = "") { + for (size_t i = 0; i < dir.size( ); ++i) if (dir[i] == dirnsep) dir[i] = dirsep; - if (dir.size() > 1 && dir[dir.size()-1] != dirsep) - dir += dirsep; - if (adddir.length() && dir[0] == '!') - dir = adddir + dirsep + dir.substr(1); + if (dir.size( ) > 1 && dir[dir.size( ) - 1] != dirsep) dir += dirsep; + if (adddir.length( ) && dir[0] == '!') dir = adddir + dirsep + dir.substr(1); return dir; } -template -void show (const char *s, const T &l, const char *separateur="\n") { - cout << s << * separateur; - for (typename T::const_iterator i = l.begin(); i != l.end(); i++) - cout << * i << * separateur; +template< typename T > +void show(const char *s, const T &l, const char *separateur = "\n") { + cout << s << *separateur; + for (typename T::const_iterator i = l.begin( ); i != l.end( ); i++) cout << *i << *separateur; } -bool EnvironmentFind (string key, string item) { +bool EnvironmentFind(string key, string item) { EnvironmentData::iterator ekey = ffenvironment.find(key); - if (ekey != ffenvironment.end()) { + if (ekey != ffenvironment.end( )) { OneEnvironmentData *pl = &ekey->second; - OneEnvironmentData::iterator i = find(pl->begin(), pl->end(), item); - return i != pl->end(); + OneEnvironmentData::iterator i = find(pl->begin( ), pl->end( ), item); + return i != pl->end( ); } return false; } -bool EnvironmentClean (string key) { +bool EnvironmentClean(string key) { EnvironmentData::iterator ekey = ffenvironment.find(key); - if (ekey != ffenvironment.end()) { + if (ekey != ffenvironment.end( )) { OneEnvironmentData *pl = &ekey->second; - pl->clear(); + pl->clear( ); return true; } return false; } -bool EnvironmentInsert (string key, string item, string before) { +bool EnvironmentInsert(string key, string item, string before) { bool ret = true; OneEnvironmentData &l = ffenvironment[key]; char sufmpi[] = {'m', 'p', 'i', dirsep, '\0'}; - string suf = ((key == "loadpath") && initparallele ) ? sufmpi : ""; - if (verbosity > 1000) cout << " **EnvironmentInsert " << initparallele << " suf '" - << suf << "' " << item << endl; - if (!suf.empty() && dirExists(item+suf)) { + string suf = ((key == "loadpath") && initparallele) ? sufmpi : ""; + if (verbosity > 1000) cout << " **EnvironmentInsert " << initparallele << " suf '" << suf << "' " << item << endl; + if (!suf.empty( ) && dirExists(item + suf)) { if (verbosity >= 100) cout << " EnvironmentInsert: Add suf " << suf << " to " << item << " in GetEnvironment " << key << endl; item += suf; } - OneEnvironmentData::iterator i = find(l.begin(), l.end(), item); + OneEnvironmentData::iterator i = find(l.begin( ), l.end( ), item); - if (i != l.end()) { ret = false; l.erase(i); } // if exist => remove - i = find(l.begin(), l.end(), before); + if (i != l.end( )) { + ret = false; + l.erase(i); + } // if exist => remove + i = find(l.begin( ), l.end( ), before); if (verbosity >= 100) cout << " insert " << key << " " << item << " " << before << endl; - if (i == l.end() && before != "$") - l.insert(l.begin(), item); // insert in front + if (i == l.end( ) && before != "$") + l.insert(l.begin( ), item); // insert in front else - l.insert(i, item); // insert before i + l.insert(i, item); // insert before i return ret; } -int GetEnvironment (const string &key, string items) { +int GetEnvironment(const string &key, string items) { if (verbosity >= 100) cout << key << " -> " << items << endl; bool path = key.find("path") != string::npos; int d = 0, k = 0; - if (path) - items += ";;"; - for (size_t i = 0; i < items.size(); i++) + if (path) items += ";;"; + for (size_t i = 0; i < items.size( ); i++) if (items[i] == ';') { - string item = items.substr(d, i-d); + string item = items.substr(d, i - d); if (path) item = TransDir(item); if (verbosity >= 100) cout << " + " << item << endl; if (!EnvironmentFind(key, item)) { @@ -154,131 +154,119 @@ int GetEnvironment (const string &key, string items) { return k; } -int readinitfile (const string &file) { - string line=""; - string key; - string value; - bool add=false; - ifstream f(file.c_str()); - if( ! f) { - if(verbosity>=20) cout << "error opening init file: " << file << endl; - return 0;} - string dirfile=DirName(file.c_str()); - char c,c1,bv=0; - int linenumber = 1; - bool inkey=false,invalue=false,cmm=false; - while (f) - { - c= f.get(); - c1=f.peek(); - if(c == EOF) - break; - if(c =='\n' || c=='\r' ) - { - linenumber++; - line=""; - cmm = false; - } - else - line+= c; - if(c=='#') cmm=true; - if(!cmm) - { - if(invalue) // get value key [=|+= value ] - { - if (bv) // store the value - { - if (! (c == bv || ( bv==' ' && isspace(c)) ) ) - { - value+= c; // add to value - } - else // end of value - { - bv =0; invalue=0; // fin de la value - if(verbosity >= 50) - cout <= 20) cout << "error opening init file: " << file << endl; + return 0; + } + string dirfile = DirName(file.c_str( )); + char c, c1, bv = 0; + int linenumber = 1; + bool inkey = false, invalue = false, cmm = false; + while (f) { + c = f.get( ); + c1 = f.peek( ); + if (c == EOF) break; + if (c == '\n' || c == '\r') { + linenumber++; + line = ""; + cmm = false; + } else + line += c; + if (c == '#') cmm = true; + if (!cmm) { + if (invalue) // get value key [=|+= value ] + { + if (bv) // store the value + { + if (!(c == bv || (bv == ' ' && isspace(c)))) { + value += c; // add to value + } else // end of value + { + bv = 0; + invalue = 0; // fin de la value + if (verbosity >= 50) cout << file << ":" << key << " = " << value << endl; + if (key == "verbosity") + verbosity = atoi(value.c_str( )); + else { + if (!add) { + EnvironmentClean(key); + GetEnvironment(key, value); + } else { + bool path = key.find("path") != string::npos; + if (path) + EnvironmentInsert(key, TransDir(value, dirfile), "$"); + else + EnvironmentInsert(key, value, "$"); + } + } + key = ""; + value = ""; + } + } else // find begin of value + { + if (c == '\'' || c == '"') { + bv = c; + value = ""; + } else if (!isspace(c)) { + value = c; + bv = ' '; + } + } + } else if (inkey) { + if (isalnum(c)) + key += c; + else if (c == '=') { + inkey = false; + invalue = true; + add = false; + } else if (c == '+' && c1 == '=') { + inkey = false; + invalue = true; + add = true; + c1 = f.get( ); + } else if (!isspace(c)) + break; + } else if (isalpha(c)) { + inkey = 1; + key = c; + } + } + } + if (inkey || invalue || bv) { + cout << " error read init file : " << file << " " << linenumber << endl; + cout << " line : " << line << endl; + return -11; + } + return 1; } +void GetEnvironment( ) { + char *ff_verbosity = 0, *ff_loadpath = 0, *ff_incpath = 0, *home = 0; -void GetEnvironment () { - char * ff_verbosity=0,* ff_loadpath=0,* ff_incpath=0,* home=0; - - // FFCS: we must make sure that FFCS does not reuse the same freefem++.pref as FF because some shared libraries must be - // recompiled. + // FFCS: we must make sure that FFCS does not reuse the same freefem++.pref as FF because some shared libraries must be + // recompiled. #ifdef PURE_WIN32 -string ffprefsuffix ="pref"; + string ffprefsuffix = "pref"; #else -string ffprefsuffix ="pref"; + string ffprefsuffix = "pref"; #endif #ifdef ENABLE_FFCS - string ffpref="freefem++-cs.pref"; + string ffpref = "freefem++-cs.pref"; #else - string ffpref="freefem++."+ffprefsuffix; + string ffpref = "freefem++." + ffprefsuffix; #endif #ifdef HAVE_GETENV ff_verbosity = getenv("FF_VERBOSITY"); ff_loadpath = getenv("FF_LOADPATH"); ff_incpath = getenv("FF_INCLUDEPATH"); - home = getenv("HOME"); + home = getenv("HOME"); #endif #ifdef PURE_WIN32 @@ -288,124 +276,109 @@ string ffprefsuffix ="pref"; char envl[LEN]; char envi[LEN]; char envh[LEN]; - char execpath[MAX_PATH+1]; + char execpath[MAX_PATH + 1]; - if (GetEnvironmentVariable("FF_VERBOSITY", envv, LEN) > 0) - ff_verbosity=envv; + if (GetEnvironmentVariable("FF_VERBOSITY", envv, LEN) > 0) ff_verbosity = envv; - if (GetEnvironmentVariable("FF_LOADPATH", envl, LEN) > 0) - ff_loadpath=envl; + if (GetEnvironmentVariable("FF_LOADPATH", envl, LEN) > 0) ff_loadpath = envl; - if (GetEnvironmentVariable("FF_INCLUDEPATH", envi, LEN) > 0) - ff_incpath=envi; + if (GetEnvironmentVariable("FF_INCLUDEPATH", envi, LEN) > 0) ff_incpath = envi; - if (GetEnvironmentVariable("HOMEPATH", envh, LEN) > 0) - home=envh; + if (GetEnvironmentVariable("HOMEPATH", envh, LEN) > 0) home = envh; #endif - if ( ff_verbosity ) { + if (ff_verbosity) { verbosity = atoi(ff_verbosity); - if(verbosity > 4) - cout << " -- GetEnvironmentVariable: verbosity= " < 4) cout << " -- GetEnvironmentVariable: verbosity= " << verbosity << endl; } #ifdef PURE_WIN32 - int bytes = GetModuleFileName(NULL, execpath, MAX_PATH); - execpath[bytes]='\0'; - if(bytes) - { - string execdir=DirName(execpath); - if(execdir.length()) - { - EnvironmentInsert("init-files",execdir+"\\"+ffpref,"$"); - } - } + int bytes = GetModuleFileName(NULL, execpath, MAX_PATH); + execpath[bytes] = '\0'; + if (bytes) { + string execdir = DirName(execpath); + if (execdir.length( )) { + EnvironmentInsert("init-files", execdir + "\\" + ffpref, "$"); + } + } #else - EnvironmentInsert("init-files","/etc/"+ffpref,"$"); + EnvironmentInsert("init-files", "/etc/" + ffpref, "$"); #ifdef FF_PREFIX_DIR_APPLE - EnvironmentInsert("init-files",string(FF_PREFIX_DIR_APPLE) + "/etc/" + ffpref ,"$"); + EnvironmentInsert("init-files", string(FF_PREFIX_DIR_APPLE) + "/etc/" + ffpref, "$"); #endif #ifdef FF_PREFIX_DIR - EnvironmentInsert("init-files",string(FF_PREFIX_DIR) + "/etc/" + ffpref ,"$"); + EnvironmentInsert("init-files", string(FF_PREFIX_DIR) + "/etc/" + ffpref, "$"); #endif - if(prognamearg) - { - if( strchr(prognamearg,dirsep) ) - { - EnvironmentInsert("init-files",TransDir(DirName(prognamearg))+"/../etc/"+ffpref,"$"); - } + if (prognamearg) { + if (strchr(prognamearg, dirsep)) { + EnvironmentInsert("init-files", TransDir(DirName(prognamearg)) + "/../etc/" + ffpref, "$"); } + } #endif - if(home) - EnvironmentInsert("init-files",TransDir(home)+"."+ffpref,"$"); + if (home) EnvironmentInsert("init-files", TransDir(home) + "." + ffpref, "$"); - EnvironmentInsert("init-files",ffpref,"$"); + EnvironmentInsert("init-files", ffpref, "$"); { - OneEnvironmentData & l = ffenvironment["init-files"]; - OneEnvironmentData::iterator i=l.begin(); - while( i != l.end()) - { - if(verbosity>2) cout << " try initfile : " <<*i << endl; - readinitfile(*i++); - } + OneEnvironmentData &l = ffenvironment["init-files"]; + OneEnvironmentData::iterator i = l.begin( ); + while (i != l.end( )) { + if (verbosity > 2) cout << " try initfile : " << *i << endl; + readinitfile(*i++); + } } - if(ff_loadpath) - GetEnvironment("loadpath",ff_loadpath); - if(ff_incpath) - GetEnvironment("includepath",ff_incpath); - - EnvironmentInsert("includepath","","");// always add "" the first include path - if( verbosity >2) - { - EnvironmentData::iterator loadpath=ffenvironment.find("loadpath"); - EnvironmentData::iterator inc=ffenvironment.find("includepath"); - if( loadpath != ffenvironment.end()) { - show("\nload path : ",loadpath->second, "\n \t "); - cout <<"(.)"< 2) { + EnvironmentData::iterator loadpath = ffenvironment.find("loadpath"); + EnvironmentData::iterator inc = ffenvironment.find("includepath"); + if (loadpath != ffenvironment.end( )) { + show("\nload path : ", loadpath->second, "\n \t "); + cout << "(.)" << endl; + } + if (inc != ffenvironment.end( )) { + show("\ninclude path : ", inc->second, "\n \t "); + cout << "(.)" << endl; + } + } + if (verbosity > 10) cout << " -- GetEnvironment: verbosity is set to " << verbosity << endl; +} +const char *check_plugin = 0; +void EnvironmentLoad( ) { + if (check_plugin) { + bool ok = true; + std::string s = check_plugin; + s += ','; + std::string delimiter = ","; + size_t pos = 0; + std::string token; + while ((pos = s.find(delimiter)) != std::string::npos) { + if (pos) { + token = s.substr(0, pos); + if (verbosity) cout << " check_plugin:try load " << token << endl; + ok = load(token.c_str( )); + if (!ok) break; } - if( inc != ffenvironment.end()) { - show("\ninclude path : ",inc->second, "\n \t "); - cout <<"(.)"< 4) cout << " ok " << ok << " s =" << s << endl; } - if(verbosity>10) cout << " -- GetEnvironment: verbosity is set to " << verbosity << endl; - - } -const char *check_plugin=0; -void EnvironmentLoad() { - if(check_plugin) { - bool ok=true; - std::string s =check_plugin; - s+= ','; - std::string delimiter = ","; - size_t pos = 0; - std::string token; - while ((pos = s.find(delimiter)) != std::string::npos) { - if(pos) { - token = s.substr(0, pos); - if(verbosity) cout <<" check_plugin:try load "<< token << endl; - ok = load(token.c_str()); - if(!ok) break; - } - s.erase(0, pos + delimiter.length()); - if(verbosity>4) cout << " ok " << ok << " s ="<< s << endl; - - } - if(ok) exit(0); - else exit(1); } - EnvironmentData::iterator toload=ffenvironment.find("load"); - if( toload != ffenvironment.end()) - - for (OneEnvironmentData::iterator i=toload->second.begin(); i != toload->second.end(); ++i) - { - if(verbosity) cout << "PreEnv load :"<< *i << endl; - load(*i); - } + if (ok) + exit(0); + else + exit(1); + } + EnvironmentData::iterator toload = ffenvironment.find("load"); + if (toload != ffenvironment.end( )) + for (OneEnvironmentData::iterator i = toload->second.begin( ); i != toload->second.end( ); ++i) { + if (verbosity) cout << "PreEnv load :" << *i << endl; + load(*i); + } } // from ffapi to env. F. Hecht .. @@ -418,37 +391,33 @@ void EnvironmentLoad() { #include #endif -namespace ffapi -{ -// to change to tmp dir for exec ... -long chtmpdir() -{ +namespace ffapi { + // to change to tmp dir for exec ... + long chtmpdir( ) { char tmp[256]; #ifdef _WIN32 - strcpy(tmp,"c:\\Temp"); - if (GetEnvironmentVariable("TEMP", tmp, 256) > 0); + strcpy(tmp, "c:\\Temp"); + if (GetEnvironmentVariable("TEMP", tmp, 256) > 0) + ; #else - strcpy(tmp,"/tmp/"); + strcpy(tmp, "/tmp/"); #endif - if(verbosity>2) - std::cout << " Change to " << endl; + if (verbosity > 2) std::cout << " Change to " << endl; return chdir(tmp); - -} -bool ff_justcompile=false; -bool ff_ch2edpdtmpir=0; -void ifchtmpdir() -{ - if(ff_ch2edpdtmpir) { + } + bool ff_justcompile = false; + bool ff_ch2edpdtmpir = 0; + void ifchtmpdir( ) { + if (ff_ch2edpdtmpir) { } -} -} + } +} // namespace ffapi #ifdef TESTMAIN long verbosity = 50; EnvironmentData environment; -int main () { - GetEnvironment(); +int main( ) { + GetEnvironment( ); return 0; } #endif diff --git a/src/fflib/environment.hpp b/src/fflib/environment.hpp index 399746389..dd3757489 100644 --- a/src/fflib/environment.hpp +++ b/src/fflib/environment.hpp @@ -37,17 +37,16 @@ #include #include #include -typedef std::list OneEnvironmentData; -typedef std::map EnvironmentData; +typedef std::list< std::string > OneEnvironmentData; +typedef std::map< std::string, OneEnvironmentData > EnvironmentData; -extern EnvironmentData ffenvironment; +extern EnvironmentData ffenvironment; extern long verbosity; -extern int typeofscript;// 0 edp, 1 Markdown init 2 Markdown after init +extern int typeofscript; // 0 edp, 1 Markdown init 2 Markdown after init -bool EnvironmentInsert(std::string key,std::string item,std::string before); +bool EnvironmentInsert(std::string key, std::string item, std::string before); -void GetEnvironment(); -void EnvironmentLoad(); - -#endif // ENVIRONMENT_HPP_ +void GetEnvironment( ); +void EnvironmentLoad( ); +#endif // ENVIRONMENT_HPP_ diff --git a/src/fflib/error.hpp b/src/fflib/error.hpp index 3b50a56bb..0f34551d4 100644 --- a/src/fflib/error.hpp +++ b/src/fflib/error.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -32,110 +32,96 @@ #include "throwassert.hpp" #include -extern int TheCurrentLine; +extern int TheCurrentLine; -#if defined(__GNUC__) && __GNUC__+0 < 3 +#if defined(__GNUC__) && __GNUC__ + 0 < 3 #include - typedef istrstream istringstream ; - typedef ostrstream ostringstream ; +typedef istrstream istringstream; +typedef ostrstream ostringstream; #define ENDS << '\0' -#define OLDCPP 1 +#define OLDCPP 1 #else // car ostringstream n'est pas encore defin sous g++ -// +// #include -#define ENDS +#define ENDS #endif - using std::exception; +using std::exception; extern long mpirank; -class Error : public exception -{ public: - enum CODE_ERROR { NONE, COMPILE_ERROR,LOAD_ERROR,EXEC_ERROR, MEM_ERROR,MESH_ERROR,ASSERT_ERROR,INTERNAL_ERROR, UNKNOWN }; - - -private: - std::string message; +class Error : public exception { + public: + enum CODE_ERROR { NONE, COMPILE_ERROR, LOAD_ERROR, EXEC_ERROR, MEM_ERROR, MESH_ERROR, ASSERT_ERROR, INTERNAL_ERROR, UNKNOWN }; + + private: + std::string message; const CODE_ERROR code; -protected: - Error(CODE_ERROR c,const char * t1,const char * t2,const char * t3=0, - int n=0,const char * t4=0,const char * t5=0,const char * t6=0, - const char * t7=0,const char * t8=0,const char * t9=0) - : message(),code(c) - { + + protected: + Error(CODE_ERROR c, const char *t1, const char *t2, const char *t3 = 0, int n = 0, const char *t4 = 0, const char *t5 = 0, const char *t6 = 0, const char *t7 = 0, const char *t8 = 0, + const char *t9 = 0) + : message( ), code(c) { using namespace std; - ostringstream mess; - if(t1) mess << t1; - if(t2) mess << t2; - if(t3) mess << t3 << n ; - if(t4) mess << t4; - if(t5) mess << t5; - if(t6) mess << t6; - if(t7) mess << t7; - if(t8) mess << t8; - if(t9) mess << t9; - message = mess.str(); - extern void ShowDebugStack(); - ShowDebugStack(); - if (c!=NONE && mpirank==0) cerr << message << endl; // cerr << " at exec line " << TheCurrentLine << endl; - } -public: - virtual int errcode() const {return code;} - virtual const char * what() const throw () { return message.c_str(); } - virtual ~Error() throw () {} + ostringstream mess; + if (t1) mess << t1; + if (t2) mess << t2; + if (t3) mess << t3 << n; + if (t4) mess << t4; + if (t5) mess << t5; + if (t6) mess << t6; + if (t7) mess << t7; + if (t8) mess << t8; + if (t9) mess << t9; + message = mess.str( ); + extern void ShowDebugStack( ); + ShowDebugStack( ); + if (c != NONE && mpirank == 0) cerr << message << endl; // cerr << " at exec line " << TheCurrentLine << endl; + } + + public: + virtual int errcode( ) const { return code; } + virtual const char *what( ) const throw( ) { return message.c_str( ); } + virtual ~Error( ) throw( ) {} }; -class ErrorCompile : public Error -{ +class ErrorCompile : public Error { public: - ErrorCompile(const char * Text,int l,const char * t2="") : - Error(COMPILE_ERROR,"Compile error : ",Text,"\n\tline number :",l,", ", t2) {} + ErrorCompile(const char *Text, int l, const char *t2 = "") : Error(COMPILE_ERROR, "Compile error : ", Text, "\n\tline number :", l, ", ", t2) {} }; -class ErrorLoad : public Error -{ -public: - ErrorLoad(const char * Text,int l,const char * t2="") : - Error(LOAD_ERROR,"Load error : ",Text,"\n\tline number :",l,", ", t2) {} +class ErrorLoad : public Error { + public: + ErrorLoad(const char *Text, int l, const char *t2 = "") : Error(LOAD_ERROR, "Load error : ", Text, "\n\tline number :", l, ", ", t2) {} }; -class ErrorExec : public Error -{ +class ErrorExec : public Error { public: - ErrorExec(const char * Text,int l) : - Error(UNKNOWN,"Exec error : ",Text, "\n -- number :", l) {} + ErrorExec(const char *Text, int l) : Error(UNKNOWN, "Exec error : ", Text, "\n -- number :", l) {} }; -class ErrorInternal : public Error -{ +class ErrorInternal : public Error { public: - ErrorInternal(const char * Text,int l,const char * t2="") : - Error(INTERNAL_ERROR,"Internal error : ",Text, "\n\tline :",l,", in file ", t2) {} + ErrorInternal(const char *Text, int l, const char *t2 = "") : Error(INTERNAL_ERROR, "Internal error : ", Text, "\n\tline :", l, ", in file ", t2) {} }; -class ErrorAssert : public Error -{ +class ErrorAssert : public Error { public: - ErrorAssert(const char * Text,const char *file,const int line) : - Error(ASSERT_ERROR,"Assertion fail : (",Text, ")\n\tline :", line,", in file ",file) {} + ErrorAssert(const char *Text, const char *file, const int line) : Error(ASSERT_ERROR, "Assertion fail : (", Text, ")\n\tline :", line, ", in file ", file) {} }; - -class ErrorMemory : public Error -{ public: - ErrorMemory(const char * Text,int l=0) : - Error(MEM_ERROR,"Memory Error : ",Text," number: ",l) {} +class ErrorMemory : public Error { + public: + ErrorMemory(const char *Text, int l = 0) : Error(MEM_ERROR, "Memory Error : ", Text, " number: ", l) {} }; -class ErrorExit : public Error -{ +class ErrorExit : public Error { int codeexit; -public: - ErrorExit(const char * ,int l) : - Error(NONE,"exit","(","",l,")"), codeexit(l) {} - // the exit code fo freefem++ is given by l - int errcode() const{return codeexit;} + + public: + ErrorExit(const char *, int l) : Error(NONE, "exit", "(", "", l, ")"), codeexit(l) {} + // the exit code fo freefem++ is given by l + int errcode( ) const { return codeexit; } }; #endif diff --git a/src/fflib/ff++.hpp b/src/fflib/ff++.hpp index 4861e74c9..fafb2d84c 100644 --- a/src/fflib/ff++.hpp +++ b/src/fflib/ff++.hpp @@ -6,47 +6,47 @@ #pragma clang diagnostic ignored "-Wundefined-var-template" #endif #endif -// a not to bad list of freefem++ include +// a not to bad list of freefem++ include // to simplify like of programmer. -// FH. +// FH. #include #include #include #include #include #include -#include +#include using namespace std; #include "error.hpp" #include "AFunction.hpp" #include "ufunction.hpp" -using namespace std; +using namespace std; #include "rgraph.hpp" #include "RNM.hpp" -// after RNM otherwise +// after RNM otherwise // trouble with index in RNM (I do no understander FH) #include #include #include #include "fem.hpp" -#include "FESpacen.hpp" -#include "FESpace.hpp" +#include "FESpacen.hpp" +#include "FESpace.hpp" #include "HashMatrix.hpp" -#include "SparseLinearSolver.hpp" +#include "SparseLinearSolver.hpp" #include "MatriceCreuse_tpl.hpp" #include "MatriceCreuse.hpp" #include "MatriceCreuse_tpl.hpp" #include "VirtualSolverCG.hpp" -//#include "VirtualSolverSparseSuite.hpp" -//#include "VirtualSolverSkyLine.hpp" -//#include "SparseLinearSolver.hpp" +// #include "VirtualSolverSparseSuite.hpp" +// #include "VirtualSolverSkyLine.hpp" +// #include "SparseLinearSolver.hpp" #include "lgsolver.hpp" #include "MeshPoint.hpp" #include "Mesh2dn.hpp" #include "Mesh3dn.hpp" -#include "Operator.hpp" +#include "Operator.hpp" #include "lex.hpp" #include "libmeshb7.h" #include "lgfem.hpp" @@ -56,7 +56,7 @@ using namespace std; #include "Mesh2.h" #include "BamgFreeFem.hpp" -#include "ffapi.hpp" +#include "ffapi.hpp" #if defined(__clang__) && defined(__has_warning) #if __has_warning("-Wundefined-var-template") #pragma clang diagnostic pop diff --git a/src/fflib/ffapi.cpp b/src/fflib/ffapi.cpp index 50ccc48b7..9e7891854 100644 --- a/src/fflib/ffapi.cpp +++ b/src/fflib/ffapi.cpp @@ -6,17 +6,17 @@ /// http://www.ljll.math.upmc.fr/lehyaric /// ====================================================================== /// This file is part of Freefem++ -/// +/// /// Freefem++ is free software; you can redistribute it and/or modify /// it under the terms of the GNU Lesser General Public License as /// published by the Free Software Foundation; either version 2.1 of /// the License, or (at your option) any later version. -/// +/// /// Freefem++ is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU Lesser General Public License for more details. -/// +/// /// You should have received a copy of the GNU Lesser General Public /// License along with Freefem++; if not, write to the Free Software /// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -32,12 +32,12 @@ #endif // headerfilter [[shell:headerfilter '../../ff/src/fflib/ffapi.cpp']] [[file:~/alh/bin/headerfilter]] -#include "ffapi.hpp" // [[file:ffapi.hpp]] found by [[file:~/alh/bin/headerfilter]] -#include +#include "ffapi.hpp" // [[file:ffapi.hpp]] found by [[file:~/alh/bin/headerfilter]] +#include #ifdef FFLANG #include "socket.hpp" #include "spawn.hpp" -#include "buffer.hpp" // [[file:~/ffcs/src/buffer.hpp::Buffer]] +#include "buffer.hpp" // [[file:~/ffcs/src/buffer.hpp::Buffer]] #endif #include #include @@ -59,8 +59,7 @@ #endif #endif -extern long verbosity ; - +extern long verbosity; // FFCS-specific implementations for the FF API // -------------------------------------------- @@ -74,42 +73,42 @@ extern long verbosity ; /// if FFCS is around, we need to bufferize all communications to avoid mixing up CMD_FFG and CMD_STDOUT messages #ifdef FFLANG -void bufferwrite(const char *b,const int l){ - Socket::dialoglock->WAIT(); // need #include "socket.hpp" +void bufferwrite(const char *b, const int l) { + Socket::dialoglock->WAIT( ); // need #include "socket.hpp" // thank to the buffering, there is only one CMD_FFG tag for multiple visualization data items. - onlyffsock()<(b),l); + onlyffsock( ).bufferedwrite(static_cast< const char * >(b), l); - Socket::dialoglock->Free(); + Socket::dialoglock->Free( ); } -Buffer buffer(NULL,bufferwrite); // need #include "buffer.hpp" // [[file:~/ffcs/src/buffer.hpp::Buffer]] +Buffer buffer(NULL, bufferwrite); // need #include "buffer.hpp" // [[file:~/ffcs/src/buffer.hpp::Buffer]] #endif // allocation/definition of all ffapi in Global.cpp -namespace ffapi{ - +namespace ffapi { + // Get a pointer to the local cin/cout (which is distinct from ffcs's stdin/stdout under Windows because each DLL owns // separate cin/cout objects). // need #include - static std::istream *ffapi_cin(){return &std::cin;} - static std::ostream *ffapi_cout(){return &std::cout;} - static std::ostream *ffapi_cerr(){return &std::cerr;} + static std::istream *ffapi_cin( ) { return &std::cin; } + static std::ostream *ffapi_cout( ) { return &std::cout; } + static std::ostream *ffapi_cerr( ) { return &std::cerr; } // FFCS - ::stdout not accepted under mingw32 // need #include -static FILE *ffapi_ffstdout(){return stdout;} -static FILE *ffapi_ffstderr(){return stderr;} -static FILE *ffapi_ffstdin(){return stdin;} + static FILE *ffapi_ffstdout( ) { return stdout; } + static FILE *ffapi_ffstderr( ) { return stderr; } + static FILE *ffapi_ffstdin( ) { return stdin; } -static void ffapi_newplot(){} + static void ffapi_newplot( ) {} - FILE *ffapi_ff_popen(const char *command, const char *type){ + FILE *ffapi_ff_popen(const char *command, const char *type) { #ifdef FFLANG // this happens right at the begining of FF, so the socket @@ -117,30 +116,31 @@ static void ffapi_newplot(){} // visualization data needs to be transfered). PROGRESS; - return (FILE*)FFAPISTREAM; + return (FILE *)FFAPISTREAM; #else // need #include - FILE *f= popen(command,type); - if( f!=0) { -// ne marche pas car ffglut plante si flux vide -// int ppok=pclose(f); -// f =0; -// if(ppok==0) -// f= popen(command,type); -// else -// std::cerr << " fopen ok but plose bug ! =" << ppok << "\n"; - } - if( f==0) { - std::cerr << "Error: popen " << f << " " << command << " " << type << std::endl; - exit(1); } - - return f; + FILE *f = popen(command, type); + if (f != 0) { + // ne marche pas car ffglut plante si flux vide + // int ppok=pclose(f); + // f =0; + // if(ppok==0) + // f= popen(command,type); + // else + // std::cerr << " fopen ok but plose bug ! =" << ppok << "\n"; + } + if (f == 0) { + std::cerr << "Error: popen " << f << " " << command << " " << type << std::endl; + exit(1); + } + + return f; #endif } // <> -static int ffapi_ff_pclose(FILE *stream){ + static int ffapi_ff_pclose(FILE *stream) { #ifdef FFLANG // nothing to close in FFCS return 0; @@ -149,7 +149,7 @@ static int ffapi_ff_pclose(FILE *stream){ #endif } -static size_t ffapi_fwriteinit(const void *ptr, size_t size, size_t nmemb,FILE *stream){ + static size_t ffapi_fwriteinit(const void *ptr, size_t size, size_t nmemb, FILE *stream) { // printf() is useful for debug because it is not redirected through // the FFCS socket. But it is asynchronous with cout so it may end up @@ -160,22 +160,22 @@ static size_t ffapi_fwriteinit(const void *ptr, size_t size, size_t nmemb,FILE printf("debug: ffapi: using TCP sockets\n"); #else printf("debug: ffapi: using an anonymous pipe\n"); -#endif // FFLANG -#endif // DEBUG_FFAPI +#endif // FFLANG +#endif // DEBUG_FFAPI #ifdef FFLANG // Ask FFCS to analyze the visualization flux header. I could just skip this stage, but it will be useful to check // the coherency between FFCS and FF when FF evolves in the future. - Socket::dialoglock->WAIT(); - onlyffsock()<Free(); + Socket::dialoglock->WAIT( ); + onlyffsock( ) << CMD_FFGINIT; + Socket::dialoglock->Free( ); #endif - return ff_fwrite(ptr,size,nmemb,stream); + return ff_fwrite(ptr, size, nmemb, stream); } -static size_t ffapi_ff_fwrite(const void *ptr, size_t size, size_t nmemb,FILE *stream){ + static size_t ffapi_ff_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { #ifdef FFLANG // if the ffsock pointer is null here, it means that the pointer exported from the FFCS shared library is not a @@ -183,36 +183,36 @@ static size_t ffapi_ff_fwrite(const void *ptr, size_t size, size_t nmemb,FILE * // we won't make use of the stream, but make sure that the call from // FF is coherent with what we know. - assert(stream==(FILE*)FFAPISTREAM); + assert(stream == (FILE *)FFAPISTREAM); - buffer.write(static_cast(ptr),size*nmemb); + buffer.write(static_cast< const char * >(ptr), size * nmemb); // stops the server flux at one precise point (point value expressed during a previous crash while reading server // data in the client in visudata.cpp). Use abort() to call the debugger (which can display the call stack and show // where the problematic pipe value came from). // need #include "options.hpp" - if(options->AbortFFGraphicsDataAt==buffer.getpoint())abort(); // need #include + if (options->AbortFFGraphicsDataAt == buffer.getpoint( )) abort( ); // need #include #else - fwrite(ptr,size,nmemb,stream); + fwrite(ptr, size, nmemb, stream); #endif return 0; } -static int ffapi_ff_fflush(FILE *stream){ + static int ffapi_ff_fflush(FILE *stream) { #ifdef FFLANG - assert(stream==(FILE*)FFAPISTREAM); + assert(stream == (FILE *)FFAPISTREAM); // we need to flush both the buffer and the socket to avoid a separate callback for flush in the buffer - buffer.flush(); + buffer.flush( ); // ff_fflush() is used by FF only at the end of a plot, so we can use this location to send a marker for the // sequential java client to deal with one complete plot at a time. - Socket::dialoglock->WAIT(); - onlyffsock()<Free(); + Socket::dialoglock->WAIT( ); + onlyffsock( ) << CMD_FFGEND; + onlyffsock( ).writeflush( ); + Socket::dialoglock->Free( ); #else fflush(stream); @@ -220,7 +220,7 @@ static int ffapi_ff_fflush(FILE *stream){ return 0; } -static int ffapi_ff_ferror(FILE *stream){ + static int ffapi_ff_ferror(FILE *stream) { #ifndef FFLANG return ferror(stream); #else @@ -228,7 +228,7 @@ static int ffapi_ff_ferror(FILE *stream){ #endif } -static int ffapi_ff_feof(FILE *stream){ + static int ffapi_ff_feof(FILE *stream) { #ifndef FFLANG return feof(stream); #else @@ -236,34 +236,33 @@ static int ffapi_ff_feof(FILE *stream){ #endif } -static void ffapi_wintextmode(FILE *f){ + static void ffapi_wintextmode(FILE *f) { #ifndef FFLANG #ifdef _WIN32 // need #include - _setmode(fileno(f),O_TEXT); + _setmode(fileno(f), O_TEXT); #endif #endif } -static void ffapi_winbinmode(FILE *f){ + static void ffapi_winbinmode(FILE *f) { #ifndef FFLANG #ifdef _WIN32 - _setmode(fileno(f),O_BINARY); + _setmode(fileno(f), O_BINARY); #endif #endif } -static void ffapi_mpi_init(int &argc, char** &argv){ + static void ffapi_mpi_init(int &argc, char **&argv) { /// only call MPI_Init() if this has not already been done in [[file:~/ffcs/src/server.cpp]] #ifndef FFLANG #ifdef PARALLELE // need #include "mpi.h" int provided; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided); - if(provided < MPI_THREAD_SERIALIZED) { - MPI_Comm_rank(MPI_COMM_WORLD, &provided); - if(provided == 0) - std::cout << "MPI_THREAD_SERIALIZED not supported !" << std::endl; + if (provided < MPI_THREAD_SERIALIZED) { + MPI_Comm_rank(MPI_COMM_WORLD, &provided); + if (provided == 0) std::cout << "MPI_THREAD_SERIALIZED not supported !" << std::endl; } #ifdef WITH_PETSCxxxxx PetscInitialize(&argc, &argv, 0, ""); @@ -273,18 +272,18 @@ static void ffapi_mpi_init(int &argc, char** &argv){ #endif } - static void ffapi_mpi_finalize(){ + static void ffapi_mpi_finalize( ) { #ifndef FFLANG #ifdef PARALLELE #ifdef WITH_PETSCxxxxxxxx - PetscFinalize(); + PetscFinalize( ); #endif - MPI_Finalize(); + MPI_Finalize( ); #endif #endif } -static bool ffapi_protectedservermode(){ + static bool ffapi_protectedservermode( ) { #ifdef FFLANG return !options->LocalClient; #else @@ -293,7 +292,7 @@ static bool ffapi_protectedservermode(){ } // <> [[file:ffapi.hpp::init]] called by [[file:../lglib/mymain.cpp::ffapi::init]] - void init(){ + void init( ) { ffapi::cin = ffapi::ffapi_cin; ffapi::cout = ffapi::ffapi_cout; ffapi::cerr = ffapi::ffapi_cerr; @@ -302,7 +301,7 @@ static bool ffapi_protectedservermode(){ ffapi::ffstdin = ffapi::ffapi_ffstdin; ffapi::newplot = ffapi::ffapi_newplot; ffapi::ff_popen = ffapi::ffapi_ff_popen; - ffapi::ff_pclose = ffapi::ffapi_ff_pclose; // <> + ffapi::ff_pclose = ffapi::ffapi_ff_pclose; // <> ffapi::fwriteinit = ffapi::ffapi_fwriteinit; ffapi::ff_fwrite = ffapi::ffapi_ff_fwrite; ffapi::ff_fflush = ffapi::ffapi_ff_fflush; @@ -314,7 +313,7 @@ static bool ffapi_protectedservermode(){ ffapi::mpi_finalize = ffapi::ffapi_mpi_finalize; ffapi::protectedservermode = ffapi::ffapi_protectedservermode; } -} +} // namespace ffapi /// Local Variables: /// mode:c++ diff --git a/src/fflib/ffapi.hpp b/src/fflib/ffapi.hpp index a7faac524..c4963003a 100644 --- a/src/fflib/ffapi.hpp +++ b/src/fflib/ffapi.hpp @@ -6,17 +6,17 @@ /// http://www.ljll.math.upmc.fr/lehyaric /// ====================================================================== /// This file is part of Freefem++ -/// +/// /// Freefem++ is free software; you can redistribute it and/or modify /// it under the terms of the GNU Lesser General Public License as /// published by the Free Software Foundation; either version 2.1 of /// the License, or (at your option) any later version. -/// +/// /// Freefem++ is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /// GNU Lesser General Public License for more details. -/// +/// /// You should have received a copy of the GNU Lesser General Public /// License along with Freefem++; if not, write to the Free Software /// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -34,56 +34,56 @@ #include #include using namespace std; -#endif //FFAPI_HPP +#endif // FFAPI_HPP #ifndef FFAPI_HPP #define FFAPI_HPP - // void ff_finalize(); - // void ff_atend( void (*atendff)()); -typedef void (*AtEnd)(); +// void ff_finalize(); +// void ff_atend( void (*atendff)()); +typedef void (*AtEnd)( ); void ff_atend(AtEnd f); // big change F. Hecht Frev 2015 // passe all function by pointer -namespace ffapi{ - extern bool ff_ch2edpdtmpir; - extern bool ff_justcompile; +namespace ffapi { + extern bool ff_ch2edpdtmpir; + extern bool ff_justcompile; // Redirecting the FF data stream // ------------------------------ // Getting a pointer to FF stdin and stdout enables extra DLLs to use standard IO even when they are redirected (eg // through FFCS). - void init (); // <> def all pointeur [[file:ffapi.cpp::init]] + void init( ); // <> def all pointeur [[file:ffapi.cpp::init]] // need #include // need #include // need using namespace std; - extern std::istream * (*cin)(); - extern std::ostream *(*cout)(); - extern std::ostream *(*cerr)(); + extern std::istream *(*cin)( ); + extern std::ostream *(*cout)( ); + extern std::ostream *(*cerr)( ); // <> Cannot name these functions identically to the original file pointers under MingW32 (compile // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF // itself was changed. - extern FILE *(*ffstdout)(); - extern FILE *(*ffstderr)(); - extern FILE *(*ffstdin)(); + extern FILE *(*ffstdout)( ); + extern FILE *(*ffstderr)( ); + extern FILE *(*ffstdin)( ); /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut /// magic number - extern size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb,FILE *stream); + extern size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb, FILE *stream); /// Indicates the begining of a new plot to avoid sending socket control data with each plot item. - extern void (*newplot)(); + extern void (*newplot)( ); /// Redefinition of standard system calls extern FILE *(*ff_popen)(const char *command, const char *type); extern int (*ff_pclose)(FILE *stream); - extern size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb,FILE *stream); + extern size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream); extern int (*ff_fflush)(FILE *stream); extern int (*ff_ferror)(FILE *stream); extern int (*ff_feof)(FILE *stream); @@ -100,8 +100,8 @@ namespace ffapi{ // Transfer basic MPI control // -------------------------- - extern void (*mpi_init)(int &argc, char **& argv); - extern void (*mpi_finalize)(); + extern void (*mpi_init)(int &argc, char **&argv); + extern void (*mpi_finalize)( ); // Permanent server control // ------------------------ @@ -109,12 +109,12 @@ namespace ffapi{ /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell /// commands) are not allowed. - extern bool (*protectedservermode)(); - extern void ifchtmpdir(); - extern long chtmpdir(); -} + extern bool (*protectedservermode)( ); + extern void ifchtmpdir( ); + extern long chtmpdir( ); +} // namespace ffapi -#endif // FFAPI_HPP +#endif // FFAPI_HPP /// Local Variables: /// mode:c++ diff --git a/src/fflib/ffstack.hpp b/src/fflib/ffstack.hpp index ec8b44c51..df5ee3266 100644 --- a/src/fflib/ffstack.hpp +++ b/src/fflib/ffstack.hpp @@ -2,54 +2,52 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//----------------------------------- -// to manage the freefem stack +//----------------------------------- +// to manage the freefem stack #ifndef FFSTACK_HPP__ #define FFSTACK_HPP__ #include "throwassert.hpp" -// in the stack we save all the variable +// in the stack we save all the variable // a adresse 0 we have the MeshPointStack to defineP,N, .... -// a adresse sizeof(void *) -// +// a adresse sizeof(void *) +// // // Offset in (void *) -const int MeshPointStackOffset =0; +const int MeshPointStackOffset = 0; const int ParamPtrOffset = 1; const int ElemMatPtrOffset = 2; const int ExprPtrs = 4; const int NbPtrs = 5; - - const int BeginOffset = 6; -// 0 : MeshPoint pointeur +// 0 : MeshPoint pointeur // 1 : ParamPtrOffset // 2 : Truc les matrice elementaire @@ -61,361 +59,344 @@ typedef void StackType; /// <> typedef void *Stack; +const Stack NullStack = 0; +// typedef StackType& Stack; +inline Stack pvoid2Stack(void *pv) { return pv; } - const Stack NullStack=0; -//typedef StackType& Stack; -inline Stack pvoid2Stack(void * pv) { return pv;} - -template -T * Stack_offset (Stack stack,size_t offset) -{ //cout << "Stack_offset" << stack << " " << offset << endl; - return (T *) (void *) (((char *) stack)+offset);} +template< class T > +T *Stack_offset(Stack stack, size_t offset) { // cout << "Stack_offset" << stack << " " << offset << endl; + return (T *)(void *)(((char *)stack) + offset); +} // <> -template -T * & Stack_Ptr (Stack stack,size_t offset) - {return (T * &) (((void **) stack)[offset]);} - -void ShowType(ostream & f); +template< class T > +T *&Stack_Ptr(Stack stack, size_t offset) { + return (T *&)(((void **)stack)[offset]); +} +void ShowType(ostream &f); struct VOIDPtrType { - virtual ~VOIDPtrType(); + virtual ~VOIDPtrType( ); }; -template -struct PtrType: public VOIDPtrType { - T * p; - PtrType(T* pp):p(pp) {} - ~PtrType() {delete p;} +template< class T > +struct PtrType : public VOIDPtrType { + T *p; + PtrType(T *pp) : p(pp) {} + ~PtrType( ) { delete p; } }; -template -struct PtrArrayType: public VOIDPtrType { - T * p; - PtrArrayType(T* pp):p(pp) {} - PtrArrayType() {delete [] p;} +template< class T > +struct PtrArrayType : public VOIDPtrType { + T *p; + PtrArrayType(T *pp) : p(pp) {} + PtrArrayType( ) { delete[] p; } }; - #else struct StackType; -//typedef void *Stack; +// typedef void *Stack; /// Stack used by CListOfInst::eval() -typedef StackType & Stack; +typedef StackType &Stack; struct StackType { - size_t lg; - char * stack; - char * MeshPointStack; - operator char *() { return stack;} - operator void *() { return stack;} - operator long *() { return (long *)(void *)stack;} - operator void **() {return (void **) (void *) stack;} - operator StackType *() { return this;} - template - T * Offset(size_t offset){ return (T*) (void*) (stack+offset);} - template - T *& ptr(size_t offset){ return (T* &) ((void**) (void *) stack)[offset];} - StackType(size_t ll) :lg(ll),stack(new char[ll]),MeshPointStack(new char[1000]) - { - long * p= ptr(0); - long l4=lg/sizeof(long); - for (int i = 0;i< l4;i++) p[i]=0; + size_t lg; + char *stack; + char *MeshPointStack; + operator char *( ) { return stack; } + operator void *( ) { return stack; } + operator long *( ) { return (long *)(void *)stack; } + operator void **( ) { return (void **)(void *)stack; } + operator StackType *( ) { return this; } + template< class T > + T *Offset(size_t offset) { + return (T *)(void *)(stack + offset); + } + template< class T > + T *&ptr(size_t offset) { + return (T *&)((void **)(void *)stack)[offset]; + } + StackType(size_t ll) : lg(ll), stack(new char[ll]), MeshPointStack(new char[1000]) { + long *p = ptr< long >(0); + long l4 = lg / sizeof(long); + for (int i = 0; i < l4; i++) p[i] = 0; - ptr(MeshPointStackOffset)=MeshPointStack; + ptr< char >(MeshPointStackOffset) = MeshPointStack; + } + void clean( ) { + delete[] stack; + delete[] MeshPointStack; } - void clean() { delete []stack; delete [] MeshPointStack; } }; -inline Stack pvoid2Stack(void * pv) { return *static_cast(pv) ;} -static StackType * NullStackPtr= 0; -static StackType & NullStack(*NullStackPtr); -//typedef StackType& Stack; - +inline Stack pvoid2Stack(void *pv) { return *static_cast< StackType * >(pv); } +static StackType *NullStackPtr = 0; +static StackType &NullStack(*NullStackPtr); +// typedef StackType& Stack; -template -T * Stack_offset (Stack stack,size_t offset) - {return stack.Offset(offset);} - -template -T * & Stack_Ptr (Stack stack,size_t offset) - {return (T * &) (((void **) (void *) stack.stack)[offset]);} +template< class T > +T *Stack_offset(Stack stack, size_t offset) { + return stack.Offset< T >(offset); +} -void ShowType(ostream & f); +template< class T > +T *&Stack_Ptr(Stack stack, size_t offset) { + return (T *&)(((void **)(void *)stack.stack)[offset]); +} +void ShowType(ostream &f); struct VOIDPtrType { - virtual ~VOIDPtrType(); + virtual ~VOIDPtrType( ); }; -template -struct PtrType: public VOIDPtrType { - T * p; - PtrType(T* pp):p(pp) {} - ~PtrType() {delete p;} +template< class T > +struct PtrType : public VOIDPtrType { + T *p; + PtrType(T *pp) : p(pp) {} + ~PtrType( ) { delete p; } }; -template -struct PtrArrayType: public VOIDPtrType { - T * p; - PtrArrayType(T* pp):p(pp) {} - PtrArrayType() {delete [] p;} +template< class T > +struct PtrArrayType : public VOIDPtrType { + T *p; + PtrArrayType(T *pp) : p(pp) {} + PtrArrayType( ) { delete[] p; } }; - - #endif //------------------------------------ - - // Add FH mars 2006 - // clean pointeur ceated by the language - // ---- - struct BaseNewInStack { - virtual ~BaseNewInStack() {}; + +// Add FH mars 2006 +// clean pointeur ceated by the language +// ---- +struct BaseNewInStack { + virtual ~BaseNewInStack( ) {}; }; struct BaseNewInStack; struct StackOfPtr2Free; // <> [[Stack_Ptr]] [[StackOfPtr2Free]] [[ExprPtrs]] -inline StackOfPtr2Free * & WhereStackOfPtr2Free(Stack s) { return Stack_Ptr(s,ExprPtrs) ;} // fait +inline StackOfPtr2Free *&WhereStackOfPtr2Free(Stack s) { return Stack_Ptr< StackOfPtr2Free >(s, ExprPtrs); } // fait // <> struct StackOfPtr2Free { - typedef vector::iterator iterator; - typedef vector::reverse_iterator reverse_iterator; - StackOfPtr2Free ** where; // where is store the ptr to the stack - StackOfPtr2Free *prev; // previous stack - - vector stackptr; - static const int sizeofmemory4tmp=1024; - int topmemory4tmp; - char *memory4tmp ; // - void add(BaseNewInStack *p) { - // cout << "\n\t\t ### ptr/lg add " << p << " at " << stackptr.size() << " \n"; - stackptr.push_back(p);} - -public: - StackOfPtr2Free(Stack s): - where(&WhereStackOfPtr2Free(s)), - prev(*where), - topmemory4tmp(0), // add FH oct 2008 of tmp allocation clean after each instruction - memory4tmp(new char[sizeofmemory4tmp]) // add FH oct 2008 of tmp allocation clean after each instruction - { - stackptr.reserve(20); - if(prev) Add2StackOfPtr2Free(s,this); - } - size_t size() const {return stackptr.size();} // Add FH dec 2017 - bool clean(int ssize=0) - { - topmemory4tmp=0;// clean the tmp allocation - bool ret= !stackptr.empty(); - if(ret) - { - - if(stackptr.size()>=20 && verbosity>2) - // FFCS: nothing on following line for tests/compare - cout << "\n\t\t ### big?? ptr/lg clean " << stackptr.size() << " ptr's\n"; - reverse_iterator re= stackptr.rend()-ssize; - for (reverse_iterator i=stackptr.rbegin(); i != re;++i) - { - - delete (* (i) ); - if(verbosity>400) cout << "StackOfPtr2Free: clean " << (* (i) ) << " " << endl; - } - stackptr.resize(ssize);// clean the - - } - return ret; - } - void * alloc(int lg) - { - int lg8=lg%8; - if(lg8) lg += 8-lg8; - if(topmemory4tmp + lg>= sizeofmemory4tmp) { - ErrorExec(" Fatal Error: too much temporary alloction, your expression is too long, or a bug in ff++, FH; april,2015",1); - ffassert(0);} - void * p=static_cast (memory4tmp+topmemory4tmp);// correct FH Oct 2009 - topmemory4tmp+= lg; - return p; - } - ~StackOfPtr2Free() {clean();delete [] memory4tmp; *where=prev;} // restore the previous stack -private:// no copy .... - StackOfPtr2Free(const StackOfPtr2Free&); - void operator =(const StackOfPtr2Free&); - - template - friend T * NewTmp(Stack s); - template - friend T * Add2StackOfPtr2Free(Stack s,T * p); - -}; - - -inline void * NewAllocTmp(Stack s,size_t l) -{ - return WhereStackOfPtr2Free(s)->alloc(l); -} + typedef vector< BaseNewInStack * >::iterator iterator; + typedef vector< BaseNewInStack * >::reverse_iterator reverse_iterator; + StackOfPtr2Free **where; // where is store the ptr to the stack + StackOfPtr2Free *prev; // previous stack + + vector< BaseNewInStack * > stackptr; + static const int sizeofmemory4tmp = 1024; + int topmemory4tmp; + char *memory4tmp; // + void add(BaseNewInStack *p) { + // cout << "\n\t\t ### ptr/lg add " << p << " at " << stackptr.size() << " \n"; + stackptr.push_back(p); + } -template -struct NewInStack: public BaseNewInStack { - T * p; - bool array; - ~NewInStack() { - // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; - if(p) - delete p;} -private: - NewInStack(T * pp,bool aa=false) : p(pp),array(aa) { - // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; - } - - - template - friend TT * Add2StackOfPtr2FreeA(Stack s,TT * p); - template - friend TT * Add2StackOfPtr2Free(Stack s,TT * p); - + public: + StackOfPtr2Free(Stack s) + : where(&WhereStackOfPtr2Free(s)), prev(*where), topmemory4tmp(0), // add FH oct 2008 of tmp allocation clean after each instruction + memory4tmp(new char[sizeofmemory4tmp]) // add FH oct 2008 of tmp allocation clean after each instruction + { + stackptr.reserve(20); + if (prev) Add2StackOfPtr2Free(s, this); + } + size_t size( ) const { return stackptr.size( ); } // Add FH dec 2017 + bool clean(int ssize = 0) { + topmemory4tmp = 0; // clean the tmp allocation + bool ret = !stackptr.empty( ); + if (ret) { + + if (stackptr.size( ) >= 20 && verbosity > 2) + // FFCS: nothing on following line for tests/compare + cout << "\n\t\t ### big?? ptr/lg clean " << stackptr.size( ) << " ptr's\n"; + reverse_iterator re = stackptr.rend( ) - ssize; + for (reverse_iterator i = stackptr.rbegin( ); i != re; ++i) { + + delete (*(i)); + if (verbosity > 400) cout << "StackOfPtr2Free: clean " << (*(i)) << " " << endl; + } + stackptr.resize(ssize); // clean the + } + return ret; + } + void *alloc(int lg) { + int lg8 = lg % 8; + if (lg8) lg += 8 - lg8; + if (topmemory4tmp + lg >= sizeofmemory4tmp) { + ErrorExec(" Fatal Error: too much temporary alloction, your expression is too long, or a bug in ff++, FH; april,2015", 1); + ffassert(0); + } + void *p = static_cast< void * >(memory4tmp + topmemory4tmp); // correct FH Oct 2009 + topmemory4tmp += lg; + return p; + } + ~StackOfPtr2Free( ) { + clean( ); + delete[] memory4tmp; + *where = prev; + } // restore the previous stack + private: // no copy .... + StackOfPtr2Free(const StackOfPtr2Free &); + void operator=(const StackOfPtr2Free &); + + template< class T > + friend T *NewTmp(Stack s); + template< class T > + friend T *Add2StackOfPtr2Free(Stack s, T *p); +}; + +inline void *NewAllocTmp(Stack s, size_t l) { return WhereStackOfPtr2Free(s)->alloc(l); } + +template< class T > +struct NewInStack : public BaseNewInStack { + T *p; + bool array; + ~NewInStack( ) { + // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; + if (p) delete p; + } + + private: + NewInStack(T *pp, bool aa = false) : p(pp), array(aa) { + // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; + } + + template< class TT > + friend TT *Add2StackOfPtr2FreeA(Stack s, TT *p); + template< class TT > + friend TT *Add2StackOfPtr2Free(Stack s, TT *p); }; extern void freestring(const string *); template<> -struct NewInStack : public BaseNewInStack { - typedef string T; - T * p; - bool array; - ~NewInStack() { - // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; - if(p) - freestring(p);} -private: - NewInStack(T * pp,bool aa=false) : p(pp),array(aa) { - // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; - } - - - template - friend TT * Add2StackOfPtr2FreeA(Stack s,TT * p); - template - friend TT * Add2StackOfPtr2Free(Stack s,TT * p); - +struct NewInStack< string > : public BaseNewInStack { + typedef string T; + T *p; + bool array; + ~NewInStack( ) { + // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; + if (p) freestring(p); + } + + private: + NewInStack(T *pp, bool aa = false) : p(pp), array(aa) { + // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; + } + + template< class TT > + friend TT *Add2StackOfPtr2FreeA(Stack s, TT *p); + template< class TT > + friend TT *Add2StackOfPtr2Free(Stack s, TT *p); }; // ajout of 2 class NewRefCountInStack and NewArrayInStack -// for clean of meshes - -template -struct NewRefCountInStack: public BaseNewInStack { - T * p; - bool array; - ~NewRefCountInStack() { - // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; - if(p) p->destroy();} -private: - NewRefCountInStack(T * pp,bool aa=false) : p(pp),array(aa) { - // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; - } - - template - friend TT * Add2StackOfPtr2FreeRC(Stack s,TT * p); - +// for clean of meshes + +template< class T > +struct NewRefCountInStack : public BaseNewInStack { + T *p; + bool array; + ~NewRefCountInStack( ) { + // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; + if (p) p->destroy( ); + } + + private: + NewRefCountInStack(T *pp, bool aa = false) : p(pp), array(aa) { + // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; + } + + template< class TT > + friend TT *Add2StackOfPtr2FreeRC(Stack s, TT *p); }; -template -struct NewArrayInStack: public BaseNewInStack { - T * p; - bool array; - ~NewArrayInStack() { - // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; - if(p) delete [] p; - } -private: - NewArrayInStack(T * pp,bool aa=false) : p(pp),array(aa) { - // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; - } - - - template - friend TT * Add2StackOfPtr2FreeA(Stack s,TT * p); - template - friend TT * Add2StackOfPtr2Free(Stack s,TT * p); - +template< class T > +struct NewArrayInStack : public BaseNewInStack { + T *p; + bool array; + ~NewArrayInStack( ) { + // cout << "~NewInStack " << typeid(T).name() << " " << p << " array " << array << " " << this << "\n"; + if (p) delete[] p; + } + + private: + NewArrayInStack(T *pp, bool aa = false) : p(pp), array(aa) { + // cout << "NewInStack " << typeid(T).name() << " " << p << " array " << aa << " " << this << "\n"; + } + + template< class TT > + friend TT *Add2StackOfPtr2FreeA(Stack s, TT *p); + template< class TT > + friend TT *Add2StackOfPtr2Free(Stack s, TT *p); }; -template -T * Add2StackOfPtr2FreeRC(Stack s,T * p) -{ - if(p) - WhereStackOfPtr2Free(s)->add(new NewRefCountInStack(p)); - return p; -} - -template -T * Add2StackOfPtr2Free(Stack s,T * p) -{ - if(p) - WhereStackOfPtr2Free(s)->add(new NewInStack(p)); - return p; -} -template -T * Add2StackOfPtr2FreeA(Stack s,T * p) -{ - if(p) - WhereStackOfPtr2Free(s)->add(new NewArrayInStack(p)); - return p; -} -// fin modif gestion of allocation of Ptr in Language +template< class T > +T *Add2StackOfPtr2FreeRC(Stack s, T *p) { + if (p) WhereStackOfPtr2Free(s)->add(new NewRefCountInStack< T >(p)); + return p; +} + +template< class T > +T *Add2StackOfPtr2Free(Stack s, T *p) { + if (p) WhereStackOfPtr2Free(s)->add(new NewInStack< T >(p)); + return p; +} +template< class T > +T *Add2StackOfPtr2FreeA(Stack s, T *p) { + if (p) WhereStackOfPtr2Free(s)->add(new NewArrayInStack< T >(p)); + return p; +} +// fin modif gestion of allocation of Ptr in Language // --------------------------------------------------- #ifndef NEWFFSTACK extern void InitMeshPoint(void *p); /// <> -inline Stack newStack(size_t l) - { - char * mps; +inline Stack newStack(size_t l) { + char *mps; Stack thestack = new char[l]; - for (size_t i = 0;i< l/sizeof(long);i++) ((long*) thestack)[i]=0; - ((char **) thestack)[MeshPointStackOffset] = mps = new char [1000]; - for(int i=0;i<1000;++i) mps[i]=0; + for (size_t i = 0; i < l / sizeof(long); i++) ((long *)thestack)[i] = 0; + ((char **)thestack)[MeshPointStackOffset] = mps = new char[1000]; + for (int i = 0; i < 1000; ++i) mps[i] = 0; // unset x,y,z InitMeshPoint(mps); // [[WhereStackOfPtr2Free]] [[StackOfPtr2Free]] - WhereStackOfPtr2Free(thestack)=new StackOfPtr2Free(thestack); - + WhereStackOfPtr2Free(thestack) = new StackOfPtr2Free(thestack); + return thestack; - // return *new StackType(l);} + // return *new StackType(l);} } -inline void deleteStack(Stack s) - { - delete WhereStackOfPtr2Free(s); // add gestion of the Ptr - delete [] (((char **) s)[MeshPointStackOffset]); - delete [] (char *) s; - // s.clean(); - } +inline void deleteStack(Stack s) { + delete WhereStackOfPtr2Free(s); // add gestion of the Ptr + delete[] (((char **)s)[MeshPointStackOffset]); + delete[] (char *)s; + // s.clean(); +} #else // a faire .... /// Called to create a new #Stack used to evaluate a FreeFem++ script in CListOfInst::eval() -inline Stack newStack(size_t l) - { -/* Stack thestack = new char[l]; - for (int i = 0;i< l/sizeof(long);i++) ((long*) thestack)[i]=0; - ((char **) thestack)[MeshPointStackOffset] = new char [1000]; - - return thestack;*/ - return *new StackType(l); - } +inline Stack newStack(size_t l) { + /* Stack thestack = new char[l]; + for (int i = 0;i< l/sizeof(long);i++) ((long*) thestack)[i]=0; + ((char **) thestack)[MeshPointStackOffset] = new char [1000]; + return thestack;*/ + return *new StackType(l); +} -inline void deleteStack(Stack s) - { - // delete [] (((char **) s)[MeshPointStackOffset]); +inline void deleteStack(Stack s) { + // delete [] (((char **) s)[MeshPointStackOffset]); // delete [] (char *) s; - s.clean(); - } -#endif + s.clean( ); +} +#endif #endif diff --git a/src/fflib/global.cpp b/src/fflib/global.cpp index 6c78c0927..8b5273655 100644 --- a/src/fflib/global.cpp +++ b/src/fflib/global.cpp @@ -30,67 +30,66 @@ #include #include - namespace ffapi { - // void init) (); - // need #include - // need #include - // need using namespace std; - std::istream * (*cin)(); - std::ostream *(*cout)(); - std::ostream *(*cerr)(); + // void init) (); + // need #include + // need #include + // need using namespace std; + std::istream *(*cin)( ); + std::ostream *(*cout)( ); + std::ostream *(*cerr)( ); - // <> Cannot name these functions identically to the original file pointers under MingW32 (compile - // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF - // itself was changed. + // <> Cannot name these functions identically to the original file pointers under MingW32 (compile + // error). Impacts [[file:InitFunct.hpp::LOADINITIO]]. Changed from stdxxx_ptr() to ffstdxxx() according to the way FF + // itself was changed. - FILE *(*ffstdout)(); - FILE *(*ffstderr)(); - FILE *(*ffstdin)(); + FILE *(*ffstdout)( ); + FILE *(*ffstderr)( ); + FILE *(*ffstdin)( ); - /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut - /// magic number + /// Initiate graphical pipe output. I need a separate function for this to warn ffcs to check the corresponding ffglut + /// magic number - size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb,FILE *stream); + size_t (*fwriteinit)(const void *ptr, size_t size, size_t nmemb, FILE *stream); - /// Indicates the begining of a new plot to avoid sending socket control data with each plot item. + /// Indicates the begining of a new plot to avoid sending socket control data with each plot item. - void (*newplot)(); + void (*newplot)( ); - /// Redefinition of standard system calls + /// Redefinition of standard system calls - FILE *(*ff_popen)(const char *command, const char *type); - int (*ff_pclose)(FILE *stream); // [[file:ffapi.cpp::ff_pclose]] - size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb,FILE *stream); - int (*ff_fflush)(FILE *stream); - int (*ff_ferror)(FILE *stream); - int (*ff_feof)(FILE *stream); + FILE *(*ff_popen)(const char *command, const char *type); + int (*ff_pclose)(FILE *stream); // [[file:ffapi.cpp::ff_pclose]] + size_t (*ff_fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream); + int (*ff_fflush)(FILE *stream); + int (*ff_ferror)(FILE *stream); + int (*ff_feof)(FILE *stream); - // Windows file mode - // ----------------- + // Windows file mode + // ----------------- - /// Changing file mode needs to be disabled when the file is a TCP socket to FFCS. Since the treatment is different in - /// FF and in FFLANG executables, they have to be stored in a DLL that changes between these two programs. + /// Changing file mode needs to be disabled when the file is a TCP socket to FFCS. Since the treatment is different in + /// FF and in FFLANG executables, they have to be stored in a DLL that changes between these two programs. - void (*wintextmode)(FILE *f); - void (*winbinmode)(FILE *f); + void (*wintextmode)(FILE *f); + void (*winbinmode)(FILE *f); - // Transfer basic MPI control - // -------------------------- + // Transfer basic MPI control + // -------------------------- - void (*mpi_init)(int &argc, char **& argv); - void (*mpi_finalize)(); + void (*mpi_init)(int &argc, char **&argv); + void (*mpi_finalize)( ); - // Permanent server control - // ------------------------ + // Permanent server control + // ------------------------ - /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell - /// commands) are not allowed. + /// if true, FF is considered to be accessible from remote anonymous connections and some commands (like shell + /// commands) are not allowed. - bool (*protectedservermode)(); + bool (*protectedservermode)( ); -} +} // namespace ffapi // TODO: remove this block as soon as autoconf is removed from FreeFem++ #ifndef CMAKE @@ -107,12 +106,7 @@ namespace ffapi { #include "ufunction.hpp" using namespace std; - - - - - -#define FF_GRAPH_PTR_DCL +#define FF_GRAPH_PTR_DCL #include "rgraph.hpp" #include "fem.hpp" #include "Mesh3dn.hpp" @@ -121,21 +115,21 @@ using namespace std; #include "SparseLinearSolver.hpp" #include "MeshPoint.hpp" - bool NoGraphicWindow=false; +bool NoGraphicWindow = false; /// <> long verbosity = 1; -long searchMethod = 0; //pichon -long npichon2d=0, npichon3d=0; -long npichon2d1=0, npichon3d1=0; +long searchMethod = 0; // pichon +long npichon2d = 0, npichon3d = 0; +long npichon2d1 = 0, npichon3d1 = 0; - FILE *ThePlotStream=0; // Add for new plot. FH oct 2008 +FILE *ThePlotStream = 0; // Add for new plot. FH oct 2008 - KN *pkarg;// for the list of argument mars 2010 - Map_type_of_map map_type_of_map ; // to store te type -Map_type_of_map map_pair_of_type ; // to store te type +KN< String > *pkarg; // for the list of argument mars 2010 +Map_type_of_map map_type_of_map; // to store te type +Map_type_of_map map_pair_of_type; // to store te type - basicForEachType * typevarreal, * typevarcomplex; // type of real and complex variable +basicForEachType *typevarreal, *typevarcomplex; // type of real and complex variable /// <> see [[file:lex.hpp::mylex]] mylex *zzzfff; @@ -145,62 +139,57 @@ bool lexdebug; #include "lg.tab.hpp" YYSTYPE *plglval; - int TheCurrentLine=-1; // unset: by default -//int NbNewVarWithDel =0; // add FH sep 2016 (bof bof global variable not got but hard to set in E_F0 or C_F0 - long mpisize=0,mpirank=0; - +int TheCurrentLine = -1; // unset: by default + // int NbNewVarWithDel =0; // add FH sep 2016 (bof bof global variable not got but hard to set in E_F0 or C_F0 +long mpisize = 0, mpirank = 0; - C_F0 *pOne=0,*pZero=0,*pminusOne=0; +C_F0 *pOne = 0, *pZero = 0, *pminusOne = 0; // const C_F0 & One(*pOne), &Zero(*pZero); - Polymorphic * TheOperators=0, //=new Polymorphic(), - * TheRightOperators=0;//=new Polymorphic(); +Polymorphic *TheOperators = 0, //=new Polymorphic(), + *TheRightOperators = 0; //=new Polymorphic(); /// <> Contains all FreeFem++ language keywords. Declaration in [[file:AFunction.hpp::Global]] TableOfIdentifier Global; - long E_Border::Count =0; +long E_Border::Count = 0; /// <> declared at [[file:AFunction.hpp::tables_of_identifier]] -typedef list ListOfTOfId; +typedef list< TableOfIdentifier * > ListOfTOfId; ListOfTOfId tables_of_identifier; -const int AC_F0::MaxSize=1024; // maximal number of parameters - +const int AC_F0::MaxSize = 1024; // maximal number of parameters +map< const string, basicForEachType * > map_type; +bool showCPU = false; -map map_type; -bool showCPU= false; - - -size_t CodeAlloc::nb=0, CodeAlloc::lg=0,CodeAlloc::nbpx=0,CodeAlloc::chunk=2048; -size_t CodeAlloc::nbt,CodeAlloc::nbdl=0; -CodeAlloc ** CodeAlloc::mem=0; -size_t CodeAlloc::memoryusage=0; -bool CodeAlloc::sort=true; -bool CodeAlloc::cleanning=false; -bool echo_edp=true; // add F.H of remove script dump -int typeofscript = 0; // 0 .epd, 1: .md (markdown);, 2 : markdown after init Add FH. 21 may 2024 +size_t CodeAlloc::nb = 0, CodeAlloc::lg = 0, CodeAlloc::nbpx = 0, CodeAlloc::chunk = 2048; +size_t CodeAlloc::nbt, CodeAlloc::nbdl = 0; +CodeAlloc **CodeAlloc::mem = 0; +size_t CodeAlloc::memoryusage = 0; +bool CodeAlloc::sort = true; +bool CodeAlloc::cleanning = false; +bool echo_edp = true; // add F.H of remove script dump +int typeofscript = 0; // 0 .epd, 1: .md (markdown);, 2 : markdown after init Add FH. 21 may 2024 // add F. Hecht -EnvironmentData ffenvironment; +EnvironmentData ffenvironment; -basicForEachType *basicForEachType::tnull=0; -E_F0 *E_F0::tnull=0; +basicForEachType *basicForEachType::tnull = 0; +E_F0 *E_F0::tnull = 0; -long newconvect3=0;// old convect 3d +long newconvect3 = 0; // old convect 3d -CodeAlloc *CodeAlloc::tnull=0; +CodeAlloc *CodeAlloc::tnull = 0; #include -RefCounter *RefCounter::tnull=0; -double ff_tgv=1e30; -bool lockOrientation=true; - -void InitMeshPoint(void * p) -{ - EF23::MeshPoint*mps=static_cast(p); - mps->unset(); +RefCounter *RefCounter::tnull = 0; +double ff_tgv = 1e30; +bool lockOrientation = true; + +void InitMeshPoint(void *p) { + EF23::MeshPoint *mps = static_cast< EF23::MeshPoint * >(p); + mps->unset( ); } -string *def_solver=0,*def_solver_sym=0, *def_solver_sym_dp=0; +string *def_solver = 0, *def_solver_sym = 0, *def_solver_sym_dp = 0; diff --git a/src/fflib/glumesh2D.cpp b/src/fflib/glumesh2D.cpp index 077bd8480..d47d3fc38 100644 --- a/src/fflib/glumesh2D.cpp +++ b/src/fflib/glumesh2D.cpp @@ -12,7 +12,6 @@ using namespace std; #include "RNM.hpp" #include "fem.hpp" - #include "FESpacen.hpp" #include "FESpace.hpp" #include "HashMatrix.hpp" @@ -32,504 +31,431 @@ using namespace std; #include #include - -using namespace Fem2D; +using namespace Fem2D; class listMesh { -public: - list *lth; - void init() { lth=new list;} - void destroy() { delete lth;} - listMesh(Stack s,Mesh const*th) : lth(Add2StackOfPtr2Free(s,new list)) { lth->push_back(th);} - listMesh(Stack s,Mesh const*const tha,Mesh const* const thb) : lth(Add2StackOfPtr2Free(s,new list)) { lth->push_back(tha);lth->push_back(thb);} - listMesh(Stack s,const listMesh &l,Mesh const*const th) : lth(Add2StackOfPtr2Free(s,new list(*l.lth))) { lth->push_back(th);} - + public: + list< Mesh const * > *lth; + void init( ) { lth = new list< Mesh const * >; } + void destroy( ) { delete lth; } + listMesh(Stack s, Mesh const *th) : lth(Add2StackOfPtr2Free(s, new list< Mesh const * >)) { lth->push_back(th); } + listMesh(Stack s, Mesh const *const tha, Mesh const *const thb) : lth(Add2StackOfPtr2Free(s, new list< Mesh const * >)) { + lth->push_back(tha); + lth->push_back(thb); + } + listMesh(Stack s, const listMesh &l, Mesh const *const th) : lth(Add2StackOfPtr2Free(s, new list< Mesh const * >(*l.lth))) { lth->push_back(th); } }; - -Mesh * GluMesh(list const & lth, long labtodel = -1,double eps=-1) -{ - int nbt=0; - int neb=0; - int nebx=0; - int nbv=0; - int nbvx=0; - double hmin=1e100; - R2 Pn(1e100,1e100),Px(-1e100,-1e100); - const Mesh * th0=0; - int kk=0; - for(list::const_iterator i=lth.begin();i != lth.end();++i) - { - if(! *i ) continue; - ++kk; - const Mesh &Th(**i); - th0=&Th; - if(verbosity>1) cout << " GluMesh "<< kk << " + "<< Th.nv << " " << Th.nt << endl; - nbt+= Th.nt; - nbvx += Th.nv; - nebx += Th.neb; - for (int k=0;k const <h, long labtodel = -1, double eps = -1) { + int nbt = 0; + int neb = 0; + int nebx = 0; + int nbv = 0; + int nbvx = 0; + double hmin = 1e100; + R2 Pn(1e100, 1e100), Px(-1e100, -1e100); + const Mesh *th0 = 0; + int kk = 0; + for (list< Mesh const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; + ++kk; + const Mesh &Th(**i); + th0 = &Th; + if (verbosity > 1) cout << " GluMesh " << kk << " + " << Th.nv << " " << Th.nt << endl; + nbt += Th.nt; + nbvx += Th.nv; + nebx += Th.neb; + for (int k = 0; k < Th.nt; k++) + for (int e = 0; e < 3; e++) hmin = min(hmin, Th[k].lenEdge(e)); + + for (int i = 0; i < Th.nv; i++) { + R2 P(Th(i)); + Pn = Minc(P, Pn); + Px = Maxc(P, Px); } - if(kk==0) return 0; // no mesh ... - if(verbosity>2) - cout << " - hmin =" << hmin << " , Bounding Box: " << Pn - << " "<< Px << endl; - - Vertex * v= new Vertex[nbvx]; - Triangle *t= new Triangle[nbt]; - Triangle *tt=t; - BoundaryEdge *b= new BoundaryEdge[nebx]; - BoundaryEdge *bb= b; - - ffassert(hmin>Norme2(Pn-Px)/1e9); - double hseuil =hmin/10.; - if( eps >=0. ) hseuil= eps; - - FQuadTree *quadtree=hseuil ? new Fem2D::FQuadTree(th0,Pn,Px,0):0 ; + } + if (kk == 0) return 0; // no mesh ... + if (verbosity > 2) cout << " - hmin =" << hmin << " , Bounding Box: " << Pn << " " << Px << endl; + + Vertex *v = new Vertex[nbvx]; + Triangle *t = new Triangle[nbt]; + Triangle *tt = t; + BoundaryEdge *b = new BoundaryEdge[nebx]; + BoundaryEdge *bb = b; + + ffassert(hmin > Norme2(Pn - Px) / 1e9); + double hseuil = hmin / 10.; + if (eps >= 0.) hseuil = eps; + + FQuadTree *quadtree = hseuil ? new Fem2D::FQuadTree(th0, Pn, Px, 0) : 0; { - map,int> bbe; - kk=0; - for(list::const_iterator i=lth.begin();i != lth.end();++i) - { - if(! *i ) continue; - int offset= nbv; - const Mesh &Th(**i); - if(verbosity>1) cout << " GluMesh + "<< Th.nv << " " << Th.nt << " " << hseuil << " " << offset << endl; - - for (int ii=0;iiToClose(vi,hseuil); - if(!pvi) { - v[nbv].x = vi.x; - v[nbv].y = vi.y; - v[nbv].lab = vi.lab; - if(quadtree) quadtree->Add(v[nbv]); - ++nbv; - } - } - - for (int k=0;kToClose(K[0],hseuil)-v; //NearestVertex(K[0])-v; - i1=quadtree->ToClose(K[1],hseuil)-v; //NearestVertex(K[1])-v; - i2=quadtree->ToClose(K[2],hseuil)-v; //NearestVertex(K[2])-v; - } - else - { - i0 = offset + Th(K[0]); - i1 = offset + Th(K[1]); - i2 = offset + Th(K[2]); - } - (*tt++).set(v,i0,i1,i2,K.lab); - } - - - for (int k=0;kToClose(be[0],hseuil)-v; - i1=quadtree->ToClose(be[1],hseuil)-v; - int ii0=i0,ii1=i1; - if(ii1 i01(ii0,ii1); - if(be.lab != labtodel && bbe.find(i01) == bbe.end()) - { - (*bb++).set(v,i0,i1,be.lab); - bbe[i01]= neb++; - } - } - else - { - i0 = offset + Th(be[0]); - i1 = offset + Th(be[1]); - (*bb++).set(v,i0,i1,be.lab); - } - } - if(verbosity>9) cout << " " << quadtree << " "<, int > bbe; + kk = 0; + for (list< Mesh const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; + int offset = nbv; + const Mesh &Th(**i); + if (verbosity > 1) cout << " GluMesh + " << Th.nv << " " << Th.nt << " " << hseuil << " " << offset << endl; + + for (int ii = 0; ii < Th.nv; ii++) { + const Vertex &vi(Th(ii)); + Vertex *pvi = 0; + if (quadtree) pvi = quadtree->ToClose(vi, hseuil); + if (!pvi) { + v[nbv].x = vi.x; + v[nbv].y = vi.y; + v[nbv].lab = vi.lab; + if (quadtree) quadtree->Add(v[nbv]); + ++nbv; + } + } + + for (int k = 0; k < Th.nt; k++) { + const Triangle &K(Th[k]); + int i0, i1, i2; + if (quadtree) { + i0 = quadtree->ToClose(K[0], hseuil) - v; // NearestVertex(K[0])-v; + i1 = quadtree->ToClose(K[1], hseuil) - v; // NearestVertex(K[1])-v; + i2 = quadtree->ToClose(K[2], hseuil) - v; // NearestVertex(K[2])-v; + } else { + i0 = offset + Th(K[0]); + i1 = offset + Th(K[1]); + i2 = offset + Th(K[2]); + } + (*tt++).set(v, i0, i1, i2, K.lab); } + + for (int k = 0; k < Th.neb; k++) { + const BoundaryEdge &be(Th.bedges[k]); + int i0, i1; + if (quadtree) { + i0 = quadtree->ToClose(be[0], hseuil) - v; + i1 = quadtree->ToClose(be[1], hseuil) - v; + int ii0 = i0, ii1 = i1; + if (ii1 < ii0) Exchange(ii0, ii1); + pair< int, int > i01(ii0, ii1); + if (be.lab != labtodel && bbe.find(i01) == bbe.end( )) { + (*bb++).set(v, i0, i1, be.lab); + bbe[i01] = neb++; + } + } else { + i0 = offset + Th(be[0]); + i1 = offset + Th(be[1]); + (*bb++).set(v, i0, i1, be.lab); + } + } + if (verbosity > 9) cout << " " << quadtree << " " << offset + Th.nv << " " << nbv << endl; + ffassert(quadtree || (offset + Th.nv == nbv)); + } } delete quadtree; - - if(verbosity>1) - { - cout << " eps for equal points "<< hseuil << " (0 => no equal points) "<< endl; - cout << " Nb points : "<< nbv << " , nb edges : " << neb << endl; - cout << " Nb of glue point " << nbvx -nbv; - cout << " Nb of glue Boundary edge " << nebx-neb; - } + if (verbosity > 1) { + cout << " eps for equal points " << hseuil << " (0 => no equal points) " << endl; + cout << " Nb points : " << nbv << " , nb edges : " << neb << endl; + cout << " Nb of glue point " << nbvx - nbv; + cout << " Nb of glue Boundary edge " << nebx - neb; + } { - Mesh * m = new Mesh(nbv,nbt,neb,v,t,b); - R2 Pn,Px; - m->BoundingBox(Pn,Px); - m->quadtree=new Fem2D::FQuadTree(m,Pn,Px,m->nv); + Mesh *m = new Mesh(nbv, nbt, neb, v, t, b); + R2 Pn, Px; + m->BoundingBox(Pn, Px); + m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); return m; } - } -template +template< class RR, class AA = RR, class BB = AA > struct Op2_addmesh { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack s,const AA & a,const BB & b) - { return RR(s, a, b );} + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack s, const AA &a, const BB &b) { return RR(s, a, b); } }; -template +template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op2_setmesh { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack stack, const AA & a,const BB & b) - { - ffassert(a ); - pmesh p=GluMesh(*(b.lth)); - - if(!INIT && *a) (**a).destroy() ; - return *a=p,a; + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack stack, const AA &a, const BB &b) { + ffassert(a); + pmesh p = GluMesh(*(b.lth)); + + if (!INIT && *a) (**a).destroy( ); + return *a = p, a; } }; -class SetMesh_Op : public E_F0mps -{ -public: +class SetMesh_Op : public E_F0mps { + public: Expression a; - static const int n_name_param =2+2+2+2+2; // add nbiter FH 30/01/2007 11 -> 12 - static basicAC_F0::name_and_type name_param[] ; + static const int n_name_param = 2 + 2 + 2 + 2 + 2; // add nbiter FH 30/01/2007 11 -> 12 + static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_ arg(int i,Stack stack,KN_ a ) const{ return nargs[i] ? GetAny >( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack, long a ) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - bool arg(int i,Stack stack, bool a ) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - -public: - SetMesh_Op(const basicAC_F0 & args,Expression aa) : a(aa) { - args.SetNameParam(n_name_param,name_param,nargs); - if( nargs[0] && nargs[2] ) - CompileError("uncompatible change (Th, label= , refe= "); - if( nargs[1] && nargs[3] ) - CompileError("uncompatible change (Th, region= , reft= "); + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + public: + SetMesh_Op(const basicAC_F0 &args, Expression aa) : a(aa) { + args.SetNameParam(n_name_param, name_param, nargs); + if (nargs[0] && nargs[2]) CompileError("uncompatible change (Th, label= , refe= "); + if (nargs[1] && nargs[3]) CompileError("uncompatible change (Th, region= , reft= "); } - AnyType operator()(Stack stack) const ; + AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type SetMesh_Op::name_param[]= { - { "refe", &typeid(KN_ )}, - { "reft", &typeid(KN_ )}, - { "label", &typeid(KN_ )}, - { "region", &typeid(KN_ )}, - { "renumv",&typeid(KN_)}, - { "renumt",&typeid(KN_)}, - { "flabel", &typeid(long)}, - { "fregion", &typeid(long)}, - { "rmledges", &typeid(long)}, - { "rmInternalEdges", &typeid(bool)} -}; +basicAC_F0::name_and_type SetMesh_Op::name_param[] = {{"refe", &typeid(KN_< long >)}, {"reft", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, + {"renumv", &typeid(KN_< long >)}, {"renumt", &typeid(KN_< long >)}, {"flabel", &typeid(long)}, {"fregion", &typeid(long)}, + {"rmledges", &typeid(long)}, {"rmInternalEdges", &typeid(bool)}}; -static int ChangeLab(const map & m,int lab) -{ - map::const_iterator i=m.find(lab); - if(i != m.end()) - lab=i->second; +static int ChangeLab(const map< int, int > &m, int lab) { + map< int, int >::const_iterator i = m.find(lab); + if (i != m.end( )) lab = i->second; return lab; } -AnyType SetMesh_Op::operator()(Stack stack) const -{ - MeshPoint *mp=MeshPointStack(stack),smp=*mp; - Mesh * pTh= GetAny((*a)(stack)); - Mesh & Th=*pTh; - Mesh *m= pTh; - int nbv=Th.nv; // nombre de sommet - int nbt=Th.nt; // nombre de triangles - int neb=Th.neb; // nombre d'aretes fontiere - KN zz; - KN nre (arg(0,stack,arg(2,stack,zz))); - KN nrt (arg(1,stack,arg(3,stack,zz))); - KN rv (arg(4,stack,zz)); - KN rt (arg(5,stack,zz)); - Expression flab = nargs[6] ; - Expression freg = nargs[7] ; - bool rm_edge = nargs[8]; - long rmlabedges (arg(8,stack,0L)); - bool rm_i_edges = (arg(9,stack,false)); - - bool rV = (rv.size()== nbv); - bool rT = (rt.size()== nbt); - if(verbosity>1) - cout << " -- SetMesh_Op: nb vertices" << nbv<< " nb Trai "<< nbt << " nb b. edges " - << neb << "renum V " << rV << " , renum T "<< rT << " rm internal edges " << rm_i_edges<< endl; - - if(nre.N() <=0 && nrt.N()<=0 && !rV && ! rT && ! flab && ! freg && !rm_i_edges && !rm_edge ) return m; - ffassert( nre.N() %2 ==0); - ffassert( nrt.N() %2 ==0); - map mape,mapt; +AnyType SetMesh_Op::operator( )(Stack stack) const { + MeshPoint *mp = MeshPointStack(stack), smp = *mp; + Mesh *pTh = GetAny< Mesh * >((*a)(stack)); + Mesh &Th = *pTh; + Mesh *m = pTh; + int nbv = Th.nv; // nombre de sommet + int nbt = Th.nt; // nombre de triangles + int neb = Th.neb; // nombre d'aretes fontiere + KN< long > zz; + KN< long > nre(arg(0, stack, arg(2, stack, zz))); + KN< long > nrt(arg(1, stack, arg(3, stack, zz))); + KN< long > rv(arg(4, stack, zz)); + KN< long > rt(arg(5, stack, zz)); + Expression flab = nargs[6]; + Expression freg = nargs[7]; + bool rm_edge = nargs[8]; + long rmlabedges(arg(8, stack, 0L)); + bool rm_i_edges = (arg(9, stack, false)); + + bool rV = (rv.size( ) == nbv); + bool rT = (rt.size( ) == nbt); + if (verbosity > 1) + cout << " -- SetMesh_Op: nb vertices" << nbv << " nb Trai " << nbt << " nb b. edges " << neb << "renum V " << rV << " , renum T " << rT << " rm internal edges " << rm_i_edges << endl; + + if (nre.N( ) <= 0 && nrt.N( ) <= 0 && !rV && !rT && !flab && !freg && !rm_i_edges && !rm_edge) return m; + ffassert(nre.N( ) % 2 == 0); + ffassert(nrt.N( ) % 2 == 0); + map< int, int > mape, mapt; int z00 = false; - int err=0; - for(int i=0;ibedges[i].lab) ; - nebn++; - } + if (nre[i] != nre[i + 1]) mape[nre[i]] = nre[i + 1]; + } + for (int i = 0; i < nrt.N( ); i += 2) mapt[nrt[i]] = nrt[i + 1]; + int nebn = 0; + for (int i = 0; i < neb; ++i) { + int l0, l1 = ChangeLab(mape, l0 = m->bedges[i].lab); + nebn++; + } - Vertex * v= new Vertex[nbv]; - Triangle *t= new Triangle[nbt]; - BoundaryEdge *b= new BoundaryEdge[nebn]; + Vertex *v = new Vertex[nbv]; + Triangle *t = new Triangle[nbt]; + BoundaryEdge *b = new BoundaryEdge[nebn]; // generation des nouveaux sommets - Vertex *vv=v; + Vertex *vv = v; // copie des anciens sommets (remarque il n'y a pas operateur de copy des sommets) - for (int i=0;ix=V.x; - vv->y=V.y; - vv->lab = V.lab; - - } + for (int i = 0; i < nbv; i++) { + int ii = rV ? rv(i) : i; + vv = v + ii; + Vertex &V = Th(i); + vv->x = V.x; + vv->y = V.y; + vv->lab = V.lab; + } // generation des triangles - int nberr=0; - R2 PtHat(1./3.,1./3.); - for (int i=0;iset(Th,Th[i](PtHat),PtHat,Th[i],Th[i].lab); - t[ii].lab =GetAny( (* freg)(stack)) ; - } - + int nberr = 0; + R2 PtHat(1. / 3., 1. / 3.); + for (int i = 0; i < nbt; i++) { + int ii = rT ? rt(i) : i; + int i0 = Th(i, 0), i1 = Th(i, 1), i2 = Th(i, 2); + if (rV) { + i0 = rv(i0); + i1 = rv(i1); + i2 = rv(i2); + } + // les 3 triangles par triangles origines + t[ii].set(v, i0, i1, i2, ChangeLab(mapt, Th[i].lab)); + if (freg) { + mp->set(Th, Th[i](PtHat), PtHat, Th[i], Th[i].lab); + t[ii].lab = GetAny< long >((*freg)(stack)); } - int nrmedge=0; + } + int nrmedge = 0; // les arete frontieres qui n'ont pas change - BoundaryEdge * bb=b; - for (int i=0;ibedges[i].lab) ; - mp->set(Th,Th[k](PtHat),PtHat,Th[k],l1); - if(flab) - { - R2 E=K.Edge(ke); - double le = sqrt((E,E)); - double sa=0.5,sb=1-sa; - R2 PA(TriangleHat[VerticesOfTriangularEdge[ke][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ke][1]]); - R2 Pt(PA*sa+PB*sb ); - MeshPointStack(stack)->set(Th,K(Pt),Pt,K,l1,R2(E.y,-E.x)/le,ke); - l1 =GetAny( (*flab)(stack)) ; - } - if( !( intern && ( rm_i_edges || (rmlabedges && (l1 == rmlabedges)) ) )) - *bb++ = BoundaryEdge(v,i1,i2,l1); - else ++nrmedge; + BoundaryEdge *bb = b; + for (int i = 0; i < neb; i++) { + int ke, k = Th.BoundaryElement(i, ke); + int kke, kk = Th.ElementAdj(k, kke = ke); + int intern = !((kk == k) || (kk < 0)); + const Triangle &K(Th[k]); + int i1 = Th(Th.bedges[i][0]); + int i2 = Th(Th.bedges[i][1]); + + if (rV) { + i1 = rv(i1); + i2 = rv(i2); + } + + int l0, l1 = ChangeLab(mape, l0 = m->bedges[i].lab); + mp->set(Th, Th[k](PtHat), PtHat, Th[k], l1); + if (flab) { + R2 E = K.Edge(ke); + double le = sqrt((E, E)); + double sa = 0.5, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ke][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ke][1]]); + R2 Pt(PA * sa + PB * sb); + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, l1, R2(E.y, -E.x) / le, ke); + l1 = GetAny< long >((*flab)(stack)); } - nebn -= nrmedge; - if(nrmedge && verbosity > 2) cout << " change mesh2 : number of removed internal edges " << nrmedge << endl; - assert(nebn==bb-b); - m = new Mesh(nbv,nbt,nebn,v,t,b); - - R2 Pn,Px; - m->BoundingBox(Pn,Px); - m->quadtree=new Fem2D::FQuadTree(m,Pn,Px,m->nv); - Add2StackOfPtr2FreeRC(stack,m); - *mp=smp; + if (!(intern && (rm_i_edges || (rmlabedges && (l1 == rmlabedges))))) + *bb++ = BoundaryEdge(v, i1, i2, l1); + else + ++nrmedge; + } + nebn -= nrmedge; + if (nrmedge && verbosity > 2) cout << " change mesh2 : number of removed internal edges " << nrmedge << endl; + assert(nebn == bb - b); + m = new Mesh(nbv, nbt, nebn, v, t, b); + + R2 Pn, Px; + m->BoundingBox(Pn, Px); + m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); + Add2StackOfPtr2FreeRC(stack, m); + *mp = smp; return m; } -class SetMesh : public OneOperator { public: -typedef Mesh const *pmesh; - SetMesh() : OneOperator(atype(),atype() ) {} +class SetMesh : public OneOperator { + public: + typedef Mesh const *pmesh; + SetMesh( ) : OneOperator(atype< pmesh >( ), atype< pmesh >( )) {} - E_F0 * code(const basicAC_F0 & args) const - { - return new SetMesh_Op(args,t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new SetMesh_Op(args, t[0]->CastTo(args[0])); } }; -Mesh* GluMeshtab (KN *const &tab, long const &lab_delete,double eps=-1) { - list l; - for (int i=0; in; i++) - l.push_back((*tab)[i]); - return GluMesh(l,lab_delete,eps); +Mesh *GluMeshtab(KN< pmesh > *const &tab, long const &lab_delete, double eps = -1) { + list< Mesh const * > l; + for (int i = 0; i < tab->n; i++) l.push_back((*tab)[i]); + return GluMesh(l, lab_delete, eps); } -struct Op_GluMeshtab: public OneOperator { - typedef const Mesh *pmesh; - class Op: public E_F0mps { - public: - static basicAC_F0::name_and_type name_param []; - static const int n_name_param = 2; - Expression nargs[n_name_param]; - Expression getmeshtab; - KN te; - aType tgetmeshtab; - long arg (int i, Stack stack, long a) const {return nargs[i] ? GetAny((*nargs[i])(stack)) : a;} - - Op (const basicAC_F0 &args, Expression t, aType tt): getmeshtab(t),tgetmeshtab(tt),te(0) - {args.SetNameParam(n_name_param, name_param, nargs); - E_Array * at= dynamic_cast(t); - if( at) - { - te.resize(at->size()); - for(int i=0; isize();++i) - te[i]= CastTo((*at)[i]); - if(te.N()==0) CompileError("EMPTY MESH ARRAY",tt); - } - } - - AnyType operator () (Stack s) const; - }; +struct Op_GluMeshtab : public OneOperator { + typedef const Mesh *pmesh; + class Op : public E_F0mps { + public: + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 2; + Expression nargs[n_name_param]; + Expression getmeshtab; + KN< Expression > te; + aType tgetmeshtab; + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + Op(const basicAC_F0 &args, Expression t, aType tt) : getmeshtab(t), tgetmeshtab(tt), te(0) { + args.SetNameParam(n_name_param, name_param, nargs); + E_Array *at = dynamic_cast< E_Array * >(t); + if (at) { + te.resize(at->size( )); + for (int i = 0; i < at->size( ); ++i) te[i] = CastTo< pmesh >((*at)[i]); + if (te.N( ) == 0) CompileError("EMPTY MESH ARRAY", tt); + } + } - E_F0*code (const basicAC_F0 &args) const - {return new Op(args, t[0]->CastTo(args[0]),t[0]);} + AnyType operator( )(Stack s) const; + }; - Op_GluMeshtab (): - OneOperator(atype(), atype *>()) {}; - Op_GluMeshtab (int i): - OneOperator(atype(), atype()) {}; - Op_GluMeshtab (int i,int j): - OneOperator(atype(), atype()) {}; + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[0]); } + Op_GluMeshtab( ) : OneOperator(atype< const pmesh >( ), atype< KN< pmesh > * >( )) {}; + Op_GluMeshtab(int i) : OneOperator(atype< const pmesh >( ), atype< listMesh >( )) {}; + Op_GluMeshtab(int i, int j) : OneOperator(atype< const pmesh >( ), atype< E_Array >( )) {}; }; -basicAC_F0::name_and_type Op_GluMeshtab::Op::name_param[Op_GluMeshtab::Op::n_name_param] = -{ - {"labtodel", &typeid(long)}, - {"eps", &typeid(double)} -}; -AnyType Op_GluMeshtab::Op::operator () (Stack stack) const { - KN *tab=0; - KN ttab(te.N()); - list *lth=0; - if (tgetmeshtab==(aType)atype *>() ) - tab= GetAny *>((*getmeshtab)(stack)); - else if (tgetmeshtab==(aType) atype()) - lth = GetAny((*getmeshtab)(stack)).lth; - else if (tgetmeshtab==(aType) atype()) - { - for(int i=0;i((*te[i])(stack)); - tab = & ttab; - } - else - ffassert(0); // type inconnue - long labtodel = arg(0, stack, LONG_MIN); - double eps = arg(1, stack, -1.); - Mesh *Tht =0; - if(tab) - Tht = GluMeshtab(tab, labtodel,eps); - else - Tht=GluMesh(*lth,labtodel,eps); - ffassert(Tht); - Add2StackOfPtr2FreeRC(stack, Tht); - return Tht; +basicAC_F0::name_and_type Op_GluMeshtab::Op::name_param[Op_GluMeshtab::Op::n_name_param] = {{"labtodel", &typeid(long)}, {"eps", &typeid(double)}}; +AnyType Op_GluMeshtab::Op::operator( )(Stack stack) const { + KN< const Mesh * > *tab = 0; + KN< const Mesh * > ttab(te.N( )); + list< Mesh const * > *lth = 0; + if (tgetmeshtab == (aType)atype< KN< pmesh > * >( )) + tab = GetAny< KN< const Mesh * > * >((*getmeshtab)(stack)); + else if (tgetmeshtab == (aType)atype< listMesh >( )) + lth = GetAny< listMesh >((*getmeshtab)(stack)).lth; + else if (tgetmeshtab == (aType)atype< E_Array >( )) { + for (int i = 0; i < te.N( ); ++i) ttab[i] = GetAny< pmesh >((*te[i])(stack)); + tab = &ttab; + } else + ffassert(0); // type inconnue + long labtodel = arg(0, stack, LONG_MIN); + double eps = arg(1, stack, -1.); + Mesh *Tht = 0; + if (tab) + Tht = GluMeshtab(tab, labtodel, eps); + else + Tht = GluMesh(*lth, labtodel, eps); + ffassert(Tht); + Add2StackOfPtr2FreeRC(stack, Tht); + return Tht; } // truc pour que la fonction // Init::Init() soit appele a moment du chargement dynamique // du fichier // -#ifndef DYNAMICS_LIBS -void init_glumesh2D() -{ - Dcl_Type(); - typedef Mesh const *pmesh; +#ifndef DYNAMICS_LIBS +void init_glumesh2D( ) { + Dcl_Type< listMesh >( ); + typedef Mesh const *pmesh; - if(verbosity>2) - cout << " glumesh2D " ; - TheOperators->Add("+",new OneBinaryOperator_st< Op2_addmesh > ); - TheOperators->Add("+",new OneBinaryOperator_st< Op2_addmesh > ); - TheOperators->Add("=",new OneBinaryOperator_st< Op2_setmesh > ); - TheOperators->Add("<-",new OneBinaryOperator_st< Op2_setmesh > ); + if (verbosity > 2) cout << " glumesh2D "; + TheOperators->Add("+", new OneBinaryOperator_st< Op2_addmesh< listMesh, pmesh, pmesh > >); + TheOperators->Add("+", new OneBinaryOperator_st< Op2_addmesh< listMesh, listMesh, pmesh > >); + TheOperators->Add("=", new OneBinaryOperator_st< Op2_setmesh< false, pmesh *, pmesh *, listMesh > >); + TheOperators->Add("<-", new OneBinaryOperator_st< Op2_setmesh< true, pmesh *, pmesh *, listMesh > >); - Global.Add("change","(",new SetMesh); + Global.Add("change", "(", new SetMesh); Global.Add("gluemesh", "(", new Op_GluMeshtab); Global.Add("gluemesh", "(", new Op_GluMeshtab(1)); - Global.Add("gluemesh", "(", new Op_GluMeshtab(1,1)); + Global.Add("gluemesh", "(", new Op_GluMeshtab(1, 1)); } #else -class Init { public: - Init(); +class Init { + public: + Init( ); }; -static Init init; // une variable globale qui serat construite au chargement dynamique +static Init init; // une variable globale qui serat construite au chargement dynamique -Init::Init(){ // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ - Dcl_Type(); +Init::Init( ) { // le constructeur qui ajoute la fonction "splitmesh3" a freefem++ + Dcl_Type< listMesh >( ); typedef Mesh *pmesh; - if (verbosity) - cout << " glumesh2D " ; - TheOperators->Add("+",new OneBinaryOperator_st< Op2_addmesh > ); - TheOperators->Add("+",new OneBinaryOperator_st< Op2_addmesh > ); - TheOperators->Add("=",new OneBinaryOperator_st< Op2_setmesh > ); - TheOperators->Add("<-",new OneBinaryOperator_st< Op2_setmesh > ); + if (verbosity) cout << " glumesh2D "; + TheOperators->Add("+", new OneBinaryOperator_st< Op2_addmesh< listMesh, pmesh, pmesh > >); + TheOperators->Add("+", new OneBinaryOperator_st< Op2_addmesh< listMesh, listMesh, pmesh > >); + TheOperators->Add("=", new OneBinaryOperator_st< Op2_setmesh< false, pmesh *, pmesh *, listMesh > >); + TheOperators->Add("<-", new OneBinaryOperator_st< Op2_setmesh< true, pmesh *, pmesh *, listMesh > >); - Global.Add("change","(",new SetMesh); + Global.Add("change", "(", new SetMesh); Global.Add("gluemesh", "(", new Op_GluMeshtab); Global.Add("gluemesh", "(", new Op_GluMeshtab(1)); diff --git a/src/fflib/lex.cpp b/src/fflib/lex.cpp index a6d09afa9..2ac3a9ea5 100644 --- a/src/fflib/lex.cpp +++ b/src/fflib/lex.cpp @@ -25,16 +25,16 @@ along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include -#include "error.hpp" -#include -#include -#include +#include +#include +#include +#include "error.hpp" +#include +#include +#include #include "AFunction.hpp" -//class pfes; -#include +// class pfes; +#include #include "lg.tab.hpp" #include "lex.hpp" @@ -46,807 +46,901 @@ extern YYSTYPE *plglval; static const bool debugmacro = false; -int setMarkdown(const char * fn) - { - if(fn) { - size_t l = strnlen(fn,32768); - return strcasecmp(".md",fn+l-3) == 0 ; - } - else - return 0; - }; +int setMarkdown(const char *fn) { + if (fn) { + size_t l = strnlen(fn, 32768); + return strcasecmp(".md", fn + l - 3) == 0; + } else + return 0; +}; -void mylex::Add(Key k,int i) -{ - Check(!i,k,"mot clef"); - Add(k,i,0); +void mylex::Add(Key k, int i) { + Check(!i, k, "mot clef"); + Add(k, i, 0); } // <> -void mylex::Add(Key k,aType t) -{ - Check(!t,k,"type"); +void mylex::Add(Key k, aType t) { + Check(!t, k, "type"); - // TYPE defined at [[file:../lglib/lg.ypp::token type TYPE]] - Add(k,TYPE,t); + // TYPE defined at [[file:../lglib/lg.ypp::token type TYPE]] + Add(k, TYPE, t); } -void mylex::AddF(Key k,aType t) -{ - Check(!t,k,"FUNCTION"); - Add(k,FUNCTION,t); +void mylex::AddF(Key k, aType t) { + Check(!t, k, "FUNCTION"); + Add(k, FUNCTION, t); } -void mylex::AddSpace(Key k,aType t) -{ - Check(!t,k,"FESPACE"); - Add(k,FESPACE,t); +void mylex::AddSpace(Key k, aType t) { + Check(!t, k, "FESPACE"); + Add(k, FESPACE, t); } // <> looks in MotClef for the token contained in buf (buf is set by by [[mylex_basescan]]) and returns // its type as t and the grammar token id as r (eg [[file:~/ff/src/lglib/lg.ypp::TYPE]]). -bool mylex::InMotClef (aType & t, int & r) const -{ - const_iterator i= MotClef.find(buf); - if (i== MotClef.end()) - { - t=0; - r=ID; - return false; - } - else - { - r=i->second.first; - t=i->second.second; - ffassert(r); - return true; - } +bool mylex::InMotClef(aType &t, int &r) const { + const_iterator i = MotClef.find(buf); + if (i == MotClef.end( )) { + t = 0; + r = ID; + return false; + } else { + r = i->second.first; + t = i->second.second; + ffassert(r); + return true; + } } // alh - 5/4/15 - <> [[file:lex.hpp::InMotClef_string]] Same as [[mylex_InMotClef]], but checks // another buffer than buf -bool mylex::InMotClef(const char *b,aType &t,int &r)const -{ - const_iterator i=MotClef.find(b); - if(i==MotClef.end()) - { - t=0; - r=ID; - return false; - } - else - { - r=i->second.first; - t=i->second.second; - ffassert(r); - return true; - } +bool mylex::InMotClef(const char *b, aType &t, int &r) const { + const_iterator i = MotClef.find(b); + if (i == MotClef.end( )) { + t = 0; + r = ID; + return false; + } else { + r = i->second.first; + t = i->second.second; + ffassert(r); + return true; + } } // <> -void mylex::Add(Key k,int r,aType t) -{ - iterator ii= MotClef.find(k); - ffassert(ii==MotClef.end()); - MotClef.insert(pair(k,Value(r,t))); +void mylex::Add(Key k, int r, aType t) { + iterator ii = MotClef.find(k); + ffassert(ii == MotClef.end( )); + MotClef.insert(pair< const Key, Value >(k, Value(r, t))); } // <> -void mylex::dump(ostream & f ) -{ - const_iterator i=MotClef.begin(),e=MotClef.end(); - for (; i != e; i++) - { - f << " " << i->first << " " << i->second.first << " " << i->second.second->name() << endl; - } +void mylex::dump(ostream &f) { + const_iterator i = MotClef.begin( ), e = MotClef.end( ); + for (; i != e; i++) { + f << " " << i->first << " " << i->second.first << " " << i->second.second->name( ) << endl; + } } -inline bool isNLCR(istream & f,int c) -{ - // eat CR NL or NL CR paire - int cc= f.peek(); - bool ret=(c == 10 || c == 13) ; - if(ret && ( cc != c) && (cc == 10 || cc == 13) ) - f.get(); - return ret; +inline bool isNLCR(istream &f, int c) { + // eat CR NL or NL CR paire + int cc = f.peek( ); + bool ret = (c == 10 || c == 13); + if (ret && (cc != c) && (cc == 10 || cc == 13)) f.get( ); + return ret; } -int mylex::EatCommentAndSpace(string *data) -{ -// extern int typeofscript ; -// if data is !0 then add reading char in data -// return the last read char c -// -------------------- - int c,c1,c2,caux,sep=0,cnl=3; - string nnn; - int echomd=echo && (verbosity>4); -/* - =0 no markdown block - pilesource[level].typeofscript==1; => markdown file - */ - const int space=(int) ' '; - // incomment : loop if !=0 - // markdown FH 22 mai 2024 - // incomment = . => // comment - // incomment = 2 => /* */ comment - // incomment = 3 => markdown comment - int incomment =1, inmarkdown= pilesource[level].typeofscript==1; - if (firsttime) - { - if( inmarkdown) incomment=3; // start with markdown !!! - firsttime=false; - if(echo && inmarkdown==0) cout << setw(5) <sep() ; - if(echo && inmarkdown) cout << "\n...MD..@:"< 4); + /* + =0 no markdown block + pilesource[level].typeofscript==1; => markdown file + */ + const int space = (int)' '; + // incomment : loop if !=0 + // markdown FH 22 mai 2024 + // incomment = . => // comment + // incomment = 2 => /* */ comment + // incomment = 3 => markdown comment + int incomment = 1, inmarkdown = pilesource[level].typeofscript == 1; + if (firsttime) { + if (inmarkdown) incomment = 3; // start with markdown !!! + firsttime = false; + if (echo && inmarkdown == 0) cout << setw(5) << linenumber << this->sep( ); + if (echo && inmarkdown) cout << "\n...MD..@:" << inmarkdown << "\n\n"; + } + auto LineNumber = [&]( ) { + int ret = 0; + c = source( ).peek( ); + int nc = 0; + while (c == 10 || c == 13) { + if (nc > 2) break; + cnl++; + nc++; + sep = space; + c = source( ).get( ); + if (isNLCR(source( ), c)) cnl = 1, c = '\n'; + if (echo) cout << (char)c; + if (c == '\n') { + linenumber++; + if (echo) cout << setw(5) << linenumber << this->sep( ); + }; + if (data) *data += char(c); + c = source( ).peek( ); } - auto LineNumber = [&]() { - int ret=0; - c = source().peek(); - int nc=0; - while ( c == 10 || c == 13 ) - { - if( nc >2) break; - cnl++; - nc++; - sep=space; - c = source().get(); - if(isNLCR(source(),c)) cnl=1,c='\n'; - if (echo) cout << (char) c; - if(c=='\n') - { - linenumber++; - if (echo) cout << setw(5) <sep() ; - }; - if(data) *data+=char(c); - c=source().peek(); - } - }; - auto PushBack = [&](string s) { - for (auto i = s.rbegin(); i != s.rend(); ++i) - source().putback(*i); - }; - auto RemoveLF = [&](string s) - { - if( *(s.end()-1) =='\r') - s.erase( s.end()-1); - return s; - }; - auto GetLine = [&](string nnn) { - // begin of line !!! - getline(source(),nnn); - LineNumber(); - - }; - auto eatspaces= [&]() { - c = source().peek(); - - // eat spaces - while (isspace(c) || c == 0 || c == 10 || c == 13 ) - { - cnl++; - sep=space; - c = source().get(); - if(isNLCR(source(),c)) cnl=1,c='\n'; - if (echo) cout << (char) c; - if(c=='\n') - { - linenumber++; - if (echo) cout << setw(5) <sep() ; - }; - if(data) *data+=char(c); - c=source().peek(); - }}; - - auto ifblock = [&](char mark) {// begin end markdown block !!! - int ret =0; - char mark3[4]={mark,mark,mark,0}; - if(c==mark && cnl==1) { - source().get(); - int c1=source().get(); - int c2=source().get(); - if( c1==mark && c2==mark) { - getline(source(),nnn); // get end of line - if(data) *data += mark3+nnn; - if (echomd) cout << mark3<< nnn ; - linenumber++; - //if(echo) cout << "\n\n...MD..." << nnn << ":" << incomment << "\n\n"; - if (echomd) cout << "\n" << setw(5) <sep() ; - eatspaces(); - ret= 1; - } - else {source().putback(c);source().putback(c);source().putback(c);} - } - return ret; - }; - int count=0; - do // loop on type of comment !! - { - // cout << "incomment"<< incomment << " "<< int(c) << " " << c << endl; - ffassert(count++<100); - eatspaces(); - // eat markdown ~~~ or comment - if(incomment==1 && (ifblock('~')==1 ||ifblock('`')==1 )) { - LineNumber();// eat CR ??? - incomment=3;// in markdown - cnl=1; // starting line !! - } - if(incomment==1) - {// normal case - if(c=='/') - { - c = source().get(); - caux=source().peek(); - if(caux =='/') {// ex: - source().get(); - getline(source(),nnn); // eat \n - if (echo) cout << "//"<< nnn ; - if(data) *data+="//"+nnn; - source().putback('\n'); - LineNumber(); - eatspaces(); - } - else if (caux == '*' ) incomment = 2;// in /* - else {source().putback(c);incomment=0;} // a Char not in comment - } - else incomment=0; - } - if(incomment==2) // in /* ..*/ - { - - sep=space; - if (echo) cout << "/*" ; - if(data) *data+="/*"; - - do - { - c=source().get(); - if(isNLCR(source(),c)) c='\n'; - if (echo) cout << (char) c ; - if(data) *data+=char(c); - if(c=='\n') - { - linenumber++; - if (echo) cout << setw(5) <sep() ; - }; - caux = source().peek(); - } - while(c != EOF && !(c=='*' && caux=='/') ) ; - if(c != EOF) - { - c = source().get(); - if (echo) cout << (char) c ; - if(data) *data+=char(c); - } - else erreur( " Unterminated comment"); - incomment=1; // end comment /* */ - } - else if( incomment == 3) - { // warning tart at begin of line end eat all the line - int end =0; - sep=space; - do - { - getline(source(),nnn);// get line - if(echomd) cout << linenumber << " ::: " << nnn << endl; - linenumber++; - if(data) *data+=nnn+'\n'; - // search end - if (nnn.find("~~~freefem")==0 ||nnn.find("```freefem")==0) // we find => end MD - end = 1; - // cr eat by getline - cnl=1; // starting line !! - } - while(!source().eof() && end == 0 ) ; - if (echo) cout << "\n" << setw(5) <sep() ; - incomment=1; - // if(end==1 && c != EOF)// end of MD part..-> recall EatCommentAndSpace - // c = EatCommentAndSpace(data); - - } + }; + auto PushBack = [&](string s) { + for (auto i = s.rbegin( ); i != s.rend( ); ++i) source( ).putback(*i); + }; + auto RemoveLF = [&](string s) { + if (*(s.end( ) - 1) == '\r') s.erase(s.end( ) - 1); + return s; + }; + auto GetLine = [&](string nnn) { + // begin of line !!! + getline(source( ), nnn); + LineNumber( ); + }; + auto eatspaces = [&]( ) { + c = source( ).peek( ); + + // eat spaces + while (isspace(c) || c == 0 || c == 10 || c == 13) { + cnl++; + sep = space; + c = source( ).get( ); + if (isNLCR(source( ), c)) cnl = 1, c = '\n'; + if (echo) cout << (char)c; + if (c == '\n') { + linenumber++; + if (echo) cout << setw(5) << linenumber << this->sep( ); + }; + if (data) *data += char(c); + c = source( ).peek( ); } - while (incomment); - - - return (c==EOF) ? c : sep; -} + }; -// <> -int mylex::basescanprint(int lvl) -{ - int r=basescan(); - if (! lexdebug && echo && lvl==0 ) print(cout); - return r; -} -int mylex::basescan() -{ - // extern long mpirank; - - int c; - buf[0]=0; - buf[1]=0; - buf[2]=0; - buf[3]=0; -debut: - TheCurrentLine=linenumber; - // modif FH - EatCommentAndSpace(); // [[mylex::EatCommentAndSpace]] - c =source().get(); // the current char - char nc = source().peek(); // next char - buf[0]=c; - buf[1]=nc; - buf[2]=0; - int ret = c; - if (c == EOF) - { - if (close() ) goto debut; - buf[0]=0; - return ENDOFFILE; + auto ifblock = [&](char mark) { // begin end markdown block !!! + int ret = 0; + char mark3[4] = {mark, mark, mark, 0}; + if (c == mark && cnl == 1) { + source( ).get( ); + int c1 = source( ).get( ); + int c2 = source( ).get( ); + if (c1 == mark && c2 == mark) { + getline(source( ), nnn); // get end of line + if (data) *data += mark3 + nnn; + if (echomd) cout << mark3 << nnn; + linenumber++; + // if(echo) cout << "\n\n...MD..." << nnn << ":" << incomment << "\n\n"; + if (echomd) cout << "\n" << setw(5) << linenumber << this->sep( ); + eatspaces( ); + ret = 1; + } else { + source( ).putback(c); + source( ).putback(c); + source( ).putback(c); + } } - - // <> - else if (isdigit(c) || (c=='.' && isdigit(nc))) - { - int i=1; - buf[0]=c; - bool real= (c=='.'); - while ( isdigit(nc) && i < 1024 ) buf[i++]=source().get(),nc=source().peek(); - if (!real && (nc == '.')) real=true,buf[i++]=source().get(),nc=source().peek(); - while ( isdigit(nc) && i < 1024 ) buf[i++]=source().get(),nc=source().peek(); - if (nc =='E' || nc =='e' || nc =='D' || nc =='d') - { - real=true; - buf[i++]=source().get(),nc=source().peek(); - if (nc =='+' || nc =='-' || isdigit(nc)) buf[i++]=source().get(),nc=source().peek(); - while ( isdigit(nc) && i < 1024 ) buf[i++]=source().get(),nc=source().peek(); - } - if (i>= 1024) erreur("Number too long"); - - buf[i]=0; - if (nc=='i' ) - { - buf[i++]=source().get(),buf[i]=0,plglval->dnum = atof(buf),ret=CNUM; - } - else if (real) - plglval->dnum = atof(buf),ret=DNUM; - else - plglval->lnum = atol(buf),ret=LNUM;// FH 12/2022 - - if(lexdebug) cout << " NUM : " << buf << " "<~~~ or comment + if (incomment == 1 && (ifblock('~') == 1 || ifblock('`') == 1)) { + LineNumber( ); // eat CR ??? + incomment = 3; // in markdown + cnl = 1; // starting line !! } - - // <> - else if (isalpha(c) || c=='\\') + if (incomment == 1) { // normal case + if (c == '/') { + c = source( ).get( ); + caux = source( ).peek( ); + if (caux == '/') { // ex: + source( ).get( ); + getline(source( ), nnn); // eat \n + if (echo) cout << "//" << nnn; + if (data) *data += "//" + nnn; + source( ).putback('\n'); + LineNumber( ); + eatspaces( ); + } else if (caux == '*') + incomment = 2; // in /* + else { + source( ).putback(c); + incomment = 0; + } // a Char not in comment + } else + incomment = 0; + } + if (incomment == 2) // in /* ..*/ { - ret = ID; - int i; - for (i = 1; i < 1024 && isalnum(source().peek()); i++) - buf[i]=source().get(); - if (i == 1024) erreur ("Identifier too long"); - buf[i] = 0; + + sep = space; + if (echo) cout << "/*"; + if (data) *data += "/*"; + + do { + c = source( ).get( ); + if (isNLCR(source( ), c)) c = '\n'; + if (echo) cout << (char)c; + if (data) *data += char(c); + if (c == '\n') { + linenumber++; + if (echo) cout << setw(5) << linenumber << this->sep( ); + }; + caux = source( ).peek( ); + } while (c != EOF && !(c == '*' && caux == '/')); + if (c != EOF) { + c = source( ).get( ); + if (echo) cout << (char)c; + if (data) *data += char(c); + } else + erreur(" Unterminated comment"); + incomment = 1; // end comment /* */ + } else if (incomment == 3) { // warning tart at begin of line end eat all the line + int end = 0; + sep = space; + do { + getline(source( ), nnn); // get line + if (echomd) cout << linenumber << " ::: " << nnn << endl; + linenumber++; + if (data) *data += nnn + '\n'; + // search end + if (nnn.find("~~~freefem") == 0 || nnn.find("```freefem") == 0) // we find => end MD + end = 1; + // cr eat by getline + cnl = 1; // starting line !! + } while (!source( ).eof( ) && end == 0); + if (echo) cout << "\n" << setw(5) << linenumber << this->sep( ); + incomment = 1; + // if(end==1 && c != EOF)// end of MD part..-> recall EatCommentAndSpace + // c = EatCommentAndSpace(data); } + } while (incomment); - // <> - else if (c=='"') - { - int i; - char cc,ccc; - for ( i = 0,cc=source().peek(); - i < 1024 && ( (isprint(cc)|isspace(cc)) && cc !='\n' && cc !='"'); - cc=source().peek(),++i - ) - { - if ( cc == '\\') // escape - { - cc= source().get(); - cc= source().get(); - ccc= source().peek(); - switch (cc) - { - case 'n': - buf[i]='\n'; - break; - case 'r': - buf[i]='\r'; - break; - case 'f': - buf[i]='\f'; - break; - case 't': - buf[i]='\t'; - break; - case 'a': - buf[i]='\a'; - break; - case 10: - case 13: - cc='\n'; - if(ccc!=cc && (ccc==10 || ccc==13)) source().get();// NL CR eat ... - linenumber++; - default : - buf[i]=cc ; - break; - } - } - else - buf[i] = source().get(); - } - if (i == 1024) erreur ("String too long"); - buf[i] = 0; - if(source().get() != '"') erreur("End of String could not be found"); - plglval->str = newcopy(buf); - if(lexdebug) cout << "STRING=" << '"' << buf << '"' << endl; + return (c == EOF) ? c : sep; +} - ret= STRING; +// <> +int mylex::basescanprint(int lvl) { + int r = basescan( ); + if (!lexdebug && echo && lvl == 0) print(cout); + return r; +} +int mylex::basescan( ) { + // extern long mpirank; + + int c; + buf[0] = 0; + buf[1] = 0; + buf[2] = 0; + buf[3] = 0; +debut: + TheCurrentLine = linenumber; + // modif FH + EatCommentAndSpace( ); // [[mylex::EatCommentAndSpace]] + c = source( ).get( ); // the current char + char nc = source( ).peek( ); // next char + buf[0] = c; + buf[1] = nc; + buf[2] = 0; + int ret = c; + if (c == EOF) { + if (close( )) goto debut; + buf[0] = 0; + return ENDOFFILE; + } + + // <> + else if (isdigit(c) || (c == '.' && isdigit(nc))) { + int i = 1; + buf[0] = c; + bool real = (c == '.'); + while (isdigit(nc) && i < 1024) buf[i++] = source( ).get( ), nc = source( ).peek( ); + if (!real && (nc == '.')) real = true, buf[i++] = source( ).get( ), nc = source( ).peek( ); + while (isdigit(nc) && i < 1024) buf[i++] = source( ).get( ), nc = source( ).peek( ); + if (nc == 'E' || nc == 'e' || nc == 'D' || nc == 'd') { + real = true; + buf[i++] = source( ).get( ), nc = source( ).peek( ); + if (nc == '+' || nc == '-' || isdigit(nc)) buf[i++] = source( ).get( ), nc = source( ).peek( ); + while (isdigit(nc) && i < 1024) buf[i++] = source( ).get( ), nc = source( ).peek( ); } + if (i >= 1024) erreur("Number too long"); - // Anything else (eg brackets and operators) + buf[i] = 0; + if (nc == 'i') { + buf[i++] = source( ).get( ), buf[i] = 0, plglval->dnum = atof(buf), ret = CNUM; + } else if (real) + plglval->dnum = atof(buf), ret = DNUM; else - { - ret = c; - switch(c) - { - - case '{': - case '%': - case '}': - case '(': - case ')': - case '[': - case ']': - case ',': - case ';': - case '#': - break; - case '*': - if (nc == '=') ret=MULEQ; - break; - case '/': - if (nc == '=') ret=DIVEQ; - break; - case '^': - case '~': - case '\'': - case '_': - case '?': - break; - case '.': - if (nc == '*') ret = DOTSTAR; - else if (nc == '/') ret = DOTSLASH; - break; - case ':': - if (nc == '=') ret= SET; - break; - case '&': - if (nc == '&') ret= AND; - break; - case '|': - if (nc == '|') ret= OR; - break; - case '!': - if (nc == '=') ret=NE; + plglval->lnum = atol(buf), ret = LNUM; // FH 12/2022 + + if (lexdebug) cout << " NUM : " << buf << " " << endl; + } + + // <> + else if (isalpha(c) || c == '\\') { + ret = ID; + int i; + for (i = 1; i < 1024 && isalnum(source( ).peek( )); i++) buf[i] = source( ).get( ); + if (i == 1024) erreur("Identifier too long"); + buf[i] = 0; + } + + // <> + else if (c == '"') { + int i; + char cc, ccc; + for (i = 0, cc = source( ).peek( ); i < 1024 && ((isprint(cc) | isspace(cc)) && cc != '\n' && cc != '"'); cc = source( ).peek( ), ++i) { + if (cc == '\\') // escape + { + cc = source( ).get( ); + cc = source( ).get( ); + ccc = source( ).peek( ); + switch (cc) { + case 'n': + buf[i] = '\n'; break; - case '<': - if (nc == '=') ret=LE; - if (nc == '<') ret=LTLT; - if (nc == '>') ret= NE; + case 'r': + buf[i] = '\r'; break; - case '>': - if (nc == '=') ret=GE; - if (nc == '>') ret=GTGT; + case 'f': + buf[i] = '\f'; break; - case '=': - if (nc == '=') - ret=EQ; + case 't': + buf[i] = '\t'; break; - case '-': - if (nc == '>') ret=ARROW; - if (nc == '-') ret=MOINSMOINS; - if (nc == '=') ret=MOINSEQ; + case 'a': + buf[i] = '\a'; break; - case '+': - if (nc == '+') ret=PLUSPLUS; - if (nc == '=') ret=PLUSEQ; + case 10: + case 13: + cc = '\n'; + if (ccc != cc && (ccc == 10 || ccc == 13)) source( ).get( ); // NL CR eat ... + linenumber++; + default: + buf[i] = cc; break; - default: - cerr << "'" << (char) c << (char) nc << "' <=> " << (int) c << " is " ; - erreur (" Unexpected character"); } - if( (ret == DOTSTAR) || (ret==DOTSLASH)) - { - source().get(); - nc = source().peek(); - if(nc == '=' ) - { - buf[2]='=';// ad FH 19 april 2012 (bug in macro ) - buf[3]=0; - source().get(); - ret = (ret == DOTSTAR) ?DOTMULEQ : DOTDIVEQ; - } - } - else if (ret!=c) source().get(); - else buf[1] = 0; - strcpy(plglval->oper,buf); - if(lexdebug) cout << "Special '" << plglval->oper << "' " << ret << " "; + } else + buf[i] = source( ).get( ); } - typetoken=ret; - return ret; + if (i == 1024) erreur("String too long"); + buf[i] = 0; + if (source( ).get( ) != '"') erreur("End of String could not be found"); + plglval->str = newcopy(buf); + if (lexdebug) cout << "STRING=" << '"' << buf << '"' << endl; + + ret = STRING; + } + + // Anything else (eg brackets and operators) + else { + ret = c; + switch (c) { + + case '{': + case '%': + case '}': + case '(': + case ')': + case '[': + case ']': + case ',': + case ';': + case '#': + break; + case '*': + if (nc == '=') ret = MULEQ; + break; + case '/': + if (nc == '=') ret = DIVEQ; + break; + case '^': + case '~': + case '\'': + case '_': + case '?': + break; + case '.': + if (nc == '*') + ret = DOTSTAR; + else if (nc == '/') + ret = DOTSLASH; + break; + case ':': + if (nc == '=') ret = SET; + break; + case '&': + if (nc == '&') ret = AND; + break; + case '|': + if (nc == '|') ret = OR; + break; + case '!': + if (nc == '=') ret = NE; + break; + case '<': + if (nc == '=') ret = LE; + if (nc == '<') ret = LTLT; + if (nc == '>') ret = NE; + break; + case '>': + if (nc == '=') ret = GE; + if (nc == '>') ret = GTGT; + break; + case '=': + if (nc == '=') ret = EQ; + break; + case '-': + if (nc == '>') ret = ARROW; + if (nc == '-') ret = MOINSMOINS; + if (nc == '=') ret = MOINSEQ; + break; + case '+': + if (nc == '+') ret = PLUSPLUS; + if (nc == '=') ret = PLUSEQ; + break; + default: + cerr << "'" << (char)c << (char)nc << "' <=> " << (int)c << " is "; + erreur(" Unexpected character"); + } + if ((ret == DOTSTAR) || (ret == DOTSLASH)) { + source( ).get( ); + nc = source( ).peek( ); + if (nc == '=') { + buf[2] = '='; // ad FH 19 april 2012 (bug in macro ) + buf[3] = 0; + source( ).get( ); + ret = (ret == DOTSTAR) ? DOTMULEQ : DOTDIVEQ; + } + } else if (ret != c) + source( ).get( ); + else + buf[1] = 0; + strcpy(plglval->oper, buf); + if (lexdebug) cout << "Special '" << plglval->oper << "' " << ret << " "; + } + typetoken = ret; + return ret; } // <> -int mylex::scan1() -{ - - // extern long mpirank; -// bool echo = mpirank == 0; - - int ret= basescan(); // [[mylex_basescan]] - if(debugmacro) cout << " scan1 " << ret << " " << token() << " " << ID << endl; - while ( ret == ID && ( - SetMacro(ret) // correction mars 2014 FH - || CallMacro(ret) // correction mars 2014 FH - || IFMacro(ret) - ) - ) - ; // correction mars 2014 FH +int mylex::scan1( ) { - return ret; + // extern long mpirank; + // bool echo = mpirank == 0; + + int ret = basescan( ); // [[mylex_basescan]] + if (debugmacro) cout << " scan1 " << ret << " " << token( ) << " " << ID << endl; + while (ret == ID && (SetMacro(ret) // correction mars 2014 FH + || CallMacro(ret) // correction mars 2014 FH + || IFMacro(ret))); // correction mars 2014 FH + + return ret; } // <> -int mylex::scan(int lvl) -{ +int mylex::scan(int lvl) { - int ret= scan1(); + int ret = scan1( ); - // ID defined at [[file:../lglib/lg.ypp::ID]] and detected at [[found_an_identifier]] - if ( ret == ID) - { - if (! InMotClef(plglval->type,ret)) - { - int ft = FindType(buf); + // ID defined at [[file:../lglib/lg.ypp::ID]] and detected at [[found_an_identifier]] + if (ret == ID) { + if (!InMotClef(plglval->type, ret)) { + int ft = FindType(buf); - // FESPACE, FESPACE1, FESPACE3 defined at [[file:../lglib/lg.ypp::FESPACE]] - // Morice (june :: 2022)- Added VGFESPACE : Vector generic FESpace --> pvectgenericfes - // - Added GFESPACE : generic FESpace ( A enlever ???) --> pgenericfes - int feid3[8] = { ID,FESPACE1,FESPACE,FESPACE3,FESPACES,FESPACEL,VGFESPACE,GFESPACE}; + // FESPACE, FESPACE1, FESPACE3 defined at [[file:../lglib/lg.ypp::FESPACE]] + // Morice (june :: 2022)- Added VGFESPACE : Vector generic FESpace --> pvectgenericfes + // - Added GFESPACE : generic FESpace ( A enlever ???) --> pgenericfes + int feid3[8] = {ID, FESPACE1, FESPACE, FESPACE3, FESPACES, FESPACEL, VGFESPACE, GFESPACE}; - ffassert ( ft >= 0 && ft <= 7 ); - ret = feid3[ft]; - plglval->str = newcopy(buf); - } + ffassert(ft >= 0 && ft <= 7); + ret = feid3[ft]; + plglval->str = newcopy(buf); } + } - if ( ret =='{') - { - listMacroDef->push_back( MapMacroDef() ); - } - else if (ret == '}') - { - listMacroDef->pop_back( ); - } + if (ret == '{') { + listMacroDef->push_back(MapMacroDef( )); + } else if (ret == '}') { + listMacroDef->pop_back( ); + } - if (! lexdebug && echo && lvl==0 ) print(cout); + if (!lexdebug && echo && lvl == 0) print(cout); - return ret; + return ret; } -string mylex::token() const -{ - int i=-1; - string f; +string mylex::token( ) const { + int i = -1; + string f; + + // found at [[found_a_string]] + if (typetoken == STRING) { + f += '"'; + while (buf[++i]) + if (buf[i] == '\n') + f += "\\n"; + else if (buf[i] == '"') + f += "\\\""; + else + f += buf[i]; + f += '"'; + } else + while (buf[++i]) + if (buf[i] == '\n') + f += "\\n"; + else + f += buf[i]; + return f; +} - // found at [[found_a_string]] - if (typetoken == STRING) - { - f += '"'; - while (buf[++i]) - if (buf[i]=='\n') f += "\\n"; - else if (buf[i]=='"') f += "\\\""; - else f += buf[i] ; - f+= '"'; +void mylex::print(ostream &f) const { + int i = -1; + int k = 0; + if (typetoken == STRING) { + + f << '"'; + while (buf[++i]) { + k++; + if (buf[i] == '\n') + k++, f << "\\n"; + else if (buf[i] == '"') + k++, f << "\\\""; + else + f << buf[i]; + if (k % 50 == 49) f << "\n ... : "; } - else - while (buf[++i]) - if (buf[i]=='\n') f += "\\n"; - else f += buf[i] ; - return f; + f << '"'; + } else + while (buf[++i]) + if (buf[i] == '\n') + f << "\\n"; + else + f << buf[i]; } -void mylex::print(ostream &f) const -{ - int i=-1; - int k=0; - if (typetoken == STRING) - { +char *mylex::match(int i) { + if (i != basescanprint( )) { + cerr << " we waiting for a '" << char(i) << "'" << endl; + ErrorScan(" err macro "); + }; + return buf; +} - f <<'"'; - while (buf[++i]) - { - k++; - if (buf[i]=='\n') k++, f << "\\n"; - else if (buf[i]=='"') k++,f << "\\\""; - else f << buf[i] ; - if ( k%50==49) f << "\n ... : "; - } - f << '"'; +bool mylex::AddMacro(string m, string def) { + bool ok = 1; + char *macroname = newcopy(m.c_str( )); + int nbparam = 0; + MacroData macroparm; + macroparm.f = ""; + macroparm.l = 0; + macroparm.d.push_back(def); + MapMacroDef &MacroDef = listMacroDef->back( ); + MapMacroDef::const_iterator i = MacroDef.find(macroname); + if (verbosity > 3) cout << " add macro " << m << "->" << def << endl; + if (i == MacroDef.end( )) + MacroDef[macroname] = macroparm; + else { + cerr << " Error add macro varf: " << m << "->" << def << " the macro exist" << endl; + ErrorScan("Error in AddMacro parameters"); + ok = false; + } + return ok; +} +bool mylex::SetMacro(int &ret) { + char endmacro[] = "EndMacro"; + char newmacro[] = "NewMacro"; + + bool rt = false; + int oldmacro = 1; + if (strncmp(buf, "macro", 6) == 0 || (oldmacro = strncmp(buf, newmacro, 9)) == 0) { + if (echo) print(cout); + char *macroname = newcopy(match(ID)); + int nbparam = 0; + MacroData macroparm; + + int rr = basescanprint( ); + string def; + if (rr != '(') + def += buf; + else { + // a '(' after macro name + rr = basescanprint( ); + + if (rr != ')') do { + if (nbparam++ >= 100) { + cerr << "in macro " << macroname << endl; + ErrorScan(" Too much (more than 100) parameters"); + } + + if (rr != ID) { + cerr << " Erreur waiting of an ID: " << buf << " " << rr << endl; + erreur("in macro def: waiting for a ID"); + } + macroparm.d.push_back(buf); + rr = basescanprint( ); + if (rr == ')') break; + if (rr != ',') erreur("in macro def: waiting , or ) "); + rr = basescanprint( ); + + } while (1); } - else - while (buf[++i]) - if (buf[i]=='\n') f << "\\n"; - else f << buf[i] ; + int kmacro = 0; + + macroparm.l = linenumber; + macroparm.f = file( ); + do { + int lk = 0, nl = 0; + string item; + int i = source( ).get( ); + if (i == EOF) { + cerr << "in macro " << macroname << endl; + ErrorScan(" ENDOFFILE in macro definition. remark:a macro end with // or EndMacro"); + } + int ii = source( ).peek( ); + if (isNLCR(source( ), i)) { + linenumber++; + nl = 1; + } else if (isalpha(i) && isalpha(ii)) // Modif F.H + { + item = char(i); + i = source( ).get( ); + while (isalpha(i)) { + item += char(i); + i = source( ).get( ); + } + if (i == 10 || i == 13) { + linenumber++; + nl = 1; + } + if (item == newmacro) kmacro++; + if (item == endmacro) { + if (kmacro == 0) { + if (echo) cout << item; + source( ).putback(i); + break; + } + kmacro--; + } + if (echo) cout << item; + def += item; + item = ""; + ii = source( ).peek( ); + } -} + if (oldmacro) { + if (i == '/' && ii == '/') { + source( ).putback('/'); + break; + } + } -char * mylex::match(int i) -{ - if ( i != basescanprint() ) - { - cerr << " we waiting for a '" << char(i) <<"'" << endl; - ErrorScan(" err macro "); - }; - return buf; -} + def += char(i); + if (echo) cout << char(i); + if (echo && nl == 1) cout << setw(5) << linenumber << " # "; -bool mylex::AddMacro(string m,string def) -{ - bool ok=1; - char *macroname=newcopy(m.c_str()); - int nbparam =0; - MacroData macroparm; - macroparm.f=""; - macroparm.l=0; + } while (1); macroparm.d.push_back(def); - MapMacroDef & MacroDef =listMacroDef->back(); - MapMacroDef::const_iterator i=MacroDef.find(macroname); - if(verbosity>3) cout << " add macro "<< m << "->" << def << endl; - if ( i == MacroDef.end() ) - MacroDef[macroname]=macroparm; - else - { - cerr << " Error add macro varf: "<< m << "->" << def << " the macro exist"<< endl; - ErrorScan("Error in AddMacro parameters"); - ok = false; + if (verbosity > 999) cout << " macro : " << macroname << ", def = :" << def << endl; + if (nbparam) + if (echo) cout << " ) "; + MapMacroDef &MacroDef = listMacroDef->back( ); + MapMacroDef::const_iterator i = MacroDef.find(macroname); + if (i == MacroDef.end( )) + MacroDef[macroname] = macroparm; + else { + cerr << "ERREUR in macro name:" << macroname << endl; + ErrorScan(" The macro already exists, sorry"); } - return ok; + rt = true; + ret = basescan( ); + } + return rt; } -bool mylex::SetMacro(int &ret) -{ - char endmacro[]="EndMacro"; - char newmacro[]="NewMacro"; - - bool rt=false; - int oldmacro=1; - if (strncmp(buf,"macro",6)==0 || (oldmacro=strncmp(buf,newmacro,9))==0 ) - { - if(echo) print(cout); - char *macroname=newcopy(match(ID)); - int nbparam =0; - MacroData macroparm; - - int rr=basescanprint(); - string def; - if (rr!='(') - def += buf; - else - { - // a '(' after macro name - rr = basescanprint(); - - if (rr != ')' ) - do - { - if (nbparam++>= 100) - { - cerr << "in macro " <::const_iterator i = listMacroDef->begin( ); i != listMacroDef->end( ); i++) { + j = i->find(id.c_str( )); + if (j != i->end( )) { + exist = true; + break; + } + } + + if (withval && exist) { + const MacroData ¯oparm = j->second; + if (macroparm.d.size( ) > 0) { + const string &mval = macroparm.d[macroparm.d.size( ) - 1]; + if (debugmacro) cout << " check IFMACRO '" << val << "' '" << mval << "'" << endl; + exist = trim(mval) == trim(val); + } + } + return exist == (isnot == 0); +} +bool mylex::IFMacroArgs(int lvl) { // wait for string : ([!]ID [,val] ) + bool isnot = 0; + if (!lexdebug && echo) print(cout); + string val; + int rr = basescanprint( ); + if (rr != '(') { + ErrorScan(" missing '(' after IFMACRO "); + } + rr = basescanprint( ); + if (rr == '(') { // (..) *([&|] ()) + source( ).putback('('); + + bool ok = IFMacroArgs(lvl + 1); + while ((rr = basescanprint( ))) + if (rr == '&') + ok = IFMacroArgs(lvl + 1) && ok; + else if (rr == '|') + ok = IFMacroArgs(lvl + 1) || ok; + else if (rr == ')') + break; + else + ErrorScan(" missing '& | )' after IFMACRO expression "); + return ok; + } else { + if (rr == '!') { + isnot = 1; + rr = basescanprint( ); + } + if (rr != ID) cerr << "IFMACRO: Erreur waiting of an ID: " << buf << " " << rr << endl; + string id = buf; + int withval = 0; + rr = basescanprint( ); + if (rr == ',') { + while (1) { + int i = source( ).get( ); + if (i == EOF) { + cerr << "in IFMACRO " << id << endl; + ErrorScan(" ENDOFFILE in IFMACRO definition. remark:a end with ENDIFMACRO "); + } - if (rr != ID) - { - cerr <<" Erreur waiting of an ID: " << buf << " " << rr << endl; - erreur("in macro def: waiting for a ID"); - } - macroparm.d.push_back(buf); - rr = basescanprint(); - if (rr == ')') break; - if ( rr != ',') erreur("in macro def: waiting , or ) "); - rr = basescanprint(); + if (char(i) == ')') break; + val += char(i); + withval = 1; + } + if (!lexdebug && echo) cout << val; + source( ).putback(')'); + rr = basescanprint( ); + } - } - while(1); + if (rr != ')') { + ErrorScan(" missing ')' after IFMACRO(macro) "); + } + return IFMacroId(isnot, id, withval, val); + } +} +bool mylex::IFMacro(int &ret) { + // A faire !!!! F.H + bool rt = false; + const char *ifm = "IFMACRO"; + const char *ife = "ENDIFMACRO"; + int kif = 0; + int isnot = 0; + int lgifm = 0; + if (strncmp(buf, ifm, 8) == 0) { + rt = true; // we see IFMACRO + /* + if (! lexdebug && echo ) print(cout); + string val; + int rr=basescanprint(); + if (rr!='(') + { + ErrorScan(" missing '(' after IFMACRO "); + } + rr=basescanprint(); + if( rr=='!') + { + isnot =1; + rr=basescanprint(); + } + if (rr != ID) + cerr <<"IFMACRO: Erreur waiting of an ID: " << buf << " " << rr << endl; + string id =buf; + int withval=0; + rr=basescanprint(); + if( rr == ',') + { + while(1) + { + int i = source().get(); + if (i == EOF) + { + cerr << "in IFMACRO " <999) cout <<" macro : " << macroname<< ", def = :"<< def << endl; - if (nbparam) - if(echo) cout << " ) " ; - MapMacroDef & MacroDef =listMacroDef->back(); - MapMacroDef::const_iterator i=MacroDef.find(macroname); - if ( i == MacroDef.end() ) - MacroDef[macroname]=macroparm; - else - { - cerr << "ERREUR in macro name:" <::const_iterator i=listMacroDef->begin(); i != listMacroDef->end(); i++) @@ -858,7 +952,7 @@ bool mylex::IFMacroId(bool isnot,string & id,bool withval ,string &val) break; } } - + if(withval && exist) { const MacroData & macroparm= j->second; @@ -867,675 +961,393 @@ bool mylex::IFMacroId(bool isnot,string & id,bool withval ,string &val) const string & mval = macroparm.d[macroparm.d.size()-1]; if(debugmacro) cout << " check IFMACRO '"<< val << "' '"<< mval <<"'"<str = newcopy(p.c_str( )); + ret = STRING; - if( char(i) ==')') break; - val +=char(i); - withval=1; + return false; + } - } - if (! lexdebug && echo ) cout << val; - source().putback(')'); - rr=basescanprint(); - } + // <> + else if (strncmp(buf, "FILE", 5) == 0) { + if (echo) cout << buf; + plglval->str = newcopy(filename( )); + ret = STRING; + return false; + } - if (rr!=')') - { - ErrorScan(" missing ')' after IFMACRO(macro) "); - } - */ - bool ok=IFMacroArgs();// - int kmacro=0; - if(debugmacro) cout << " IFMacro:: " << linenumber << endl; - lgifm=linenumber; - string def; - do - { - int lk=0,nl=0; - string item; - int i = source().get(); - - if (i == EOF) - { - cerr << "in IFMACRO " << linenumber << endl; - ErrorScan(" ENDOFFILE in IFMACRO definition. remark:a end with ENDIFMACRO "); + // <> + else if (strncmp(buf, "LINE", 5) == 0) { + if (echo) cout << buf; + plglval->lnum = linenumber; + ret = LNUM; + return false; + } else + for (list< MapMacroDef >::const_iterator i = listMacroDef->begin( ); i != listMacroDef->end( ); i++) { + MapMacroDef::const_iterator j = i->find(buf); + + if (j != i->end( )) { + const MacroData ¯oparm = j->second; + int nbparam = macroparm.d.size( ) - 1; + if (debugmacro) cout << "call macro : " << buf << endl; + string *macronn = newstring(" macro: "); + *macronn += buf; + *macronn += " in "; + *macronn += macroparm.f; + if (echo) cout << buf; + MapMacroParam lp; + if (nbparam > 0) { + match('('); + + for (int k = 0; k < nbparam; k++) { + string p; + int kend = (k + 1 == nbparam) ? ')' : ','; + int lvl = 0; + int lvll = 0; + while (1) { + int sep = EatCommentAndSpace( ); + int rr = basescanprint( ); // basescan -> scan1 change 2/2/2007 ( not change to pass macro name as a parameter) + if ((rr == '}') && (--lvll == 0)) + continue; // remove first { + else if ((rr == '{') && (++lvll == 1)) + continue; // remove last } + else if (lvll == 0) // count the open close () [] + { + if (lvl && rr == ')') + lvl--; // if ( then we eat next ) + else if (lvl && rr == ']') + lvl--; // if ( then we eat next ) + else if (rr == '(') + lvl++; // eat next + else if (rr == '[') + lvl++; // eat next + else if (lvl <= 0) { + if (rr == kend) + break; + else if (rr == ')' || rr == ',') // Correction FH 2/06/2004 + { + cerr << "Error in macro expansion " << j->first << ", we wait for " << char(kend) << " and we get " << char(rr) << endl; + cerr << " number of macro parameter in definition is " << nbparam << endl; + ErrorScan(" Wrong number of parameter in macro call"); + } + } + } + + if (rr == ENDOFFILE) ErrorScan(" ENDOFFILE in macro usage"); + if (sep == ' ') p += ' '; + p += token( ); // Correction FH 2/06/2004 of string parameter } - int ii = source().peek(); - // - if(isNLCR(source(),i)) - { - linenumber++; - nl=1; + if (debugmacro) cout << "macro arg " << k << " :" << macroparm.d[k] << " -> " << p << endl; + lp.insert(pair< string, string >(macroparm.d[k], p)); + } + } + if (debugmacro) cout << " input in : -> " << macroparm.d[nbparam] << " <-> " << nbparam << endl; + input(macroparm.d[nbparam], 0, macroparm.l); // no file no error here FH. + // ici il faut faire la substitution de parameter + // ----------------------------------------------- + string expandtxt; + string currentexpand; + string leftexpand; + string rightexpand; + string ReadCommentAndSpace; + bool echosave = echo; + char buf2[256]; + const char *ifm = "IFMACRO"; + const char *ifs = "Stringification"; + bool inifmacro = 0; + bool isconc = 0; + int nbparenth = 0; + while (1) { + ReadCommentAndSpace = ""; + int c = EatCommentAndSpace(&ReadCommentAndSpace); // eat comment to save it; + if (c == EOF) { + expandtxt += currentexpand + ReadCommentAndSpace; + break; + } + ret = basescan( ); + if (debugmacro) cout << " ret = " << ret << token( ) << endl; + if (ret == ENDOFFILE) { + expandtxt += currentexpand + ReadCommentAndSpace; + break; + } + if (inifmacro && (ret == '(')) nbparenth++; + if (inifmacro && (ret == ')')) nbparenth--; + if (nbparam && (ret != '#') && (ret != ')' || !inifmacro)) { + if (strncmp(buf, ifm, 8) == 0 || strncmp(buf, ifs, 15) == 0) inifmacro = 1; + + if (!isconc) { + MapMacroParam::const_iterator j = lp.find(buf); + if (j != lp.end( )) { + expandtxt += currentexpand + ReadCommentAndSpace; + currentexpand = j->second; + } else { + expandtxt += currentexpand + ReadCommentAndSpace; + currentexpand = token( ); + } } - // - else if(isalpha(i) && isalpha(ii) ) // Modif F.H - { - //def +=char(i); - item = char(i); - i = source().get(); - while(isalpha(i)) - { - item += char(i); - i = source().get(); - } - if( item == ifm) kif++; - if( item == ife) - { - if (kif==0) - { - source().putback(i); - break; + if (isconc) { + MapMacroParam::const_iterator j = lp.find(buf); + if (j != lp.end( )) { + rightexpand = j->second; + + if (rightexpand[0] == ' ') rightexpand.erase(0, 1); + } else + rightexpand = token( ); + + currentexpand = leftexpand + rightexpand; + if (!inifmacro) + for (list< MapMacroDef >::const_iterator i = listMacroDef->begin( ); i != listMacroDef->end( ); i++) { + + while (currentexpand[0] == ' ') currentexpand.erase(0, 1); + + MapMacroDef::const_iterator j = i->find(currentexpand.c_str( )); + if (j != i->end( )) { + const MacroData ¯oparm = j->second; + if (macroparm.d.size( ) == 1) { + currentexpand = macroparm.d[0]; + if (currentexpand[currentexpand.size( ) - 1] == ' ') currentexpand.resize(currentexpand.size( ) - 1); } - kif--; + } } - if(echo) cout << item ; - def += item; - item =""; - - ii = source().peek(); + isconc = 0; } - - - - def +=char(i); - if(echo)cout << char(i) ; - if(echo && nl==1) cout << setw(5) <::const_iterator i=listMacroDef->begin(); i != listMacroDef->end(); i++) - { - j=i->find(id.c_str()); - if( j != i->end()) - { - exist =true; - break; + } else if (ret != '#') { // macro concatenation operator + if (ret == ')' && inifmacro && nbparenth == 0) inifmacro = 0; + if (!isconc) { + expandtxt += currentexpand + ReadCommentAndSpace; + currentexpand = token( ); } - } - if(withval && exist) - { - const MacroData & macroparm= j->second; - if(macroparm.d.size()>0) - { - const string & mval = macroparm.d[macroparm.d.size()-1]; - if(debugmacro) cout << " check IFMACRO '"<< val << "' '"<< mval <<"'"<str = newcopy(p.c_str()); - ret = STRING; - - return false; - } +void mylex::xxxx::open(mylex *lex, const char *ff, int ts) { - // <> - else if(strncmp(buf,"FILE",5)==0) - { - if(echo) cout << buf ; - plglval->str = newcopy(filename() ); - ret = STRING; - return false; - } + string dirname; + typeofscript = ts ? ts : setMarkdown(ff); - // <> - else if(strncmp(buf,"LINE",5)==0) - { - if(echo) cout << buf ; - plglval->lnum = linenumber; - ret=LNUM; - return false; - } - else - for (list::const_iterator i=listMacroDef->begin(); i != listMacroDef->end(); i++) - { - MapMacroDef::const_iterator j= i->find(buf); - - if (j != i->end()) - { - const MacroData & macroparm= j->second; - int nbparam= macroparm.d.size()-1; - if(debugmacro) cout <<"call macro : " << buf << endl; - string * macronn= newstring(" macro: "); - *macronn+= buf; - *macronn+=" in "; - *macronn+= macroparm.f; - if(echo) cout << buf ; - MapMacroParam lp; - if (nbparam > 0 ) - { - match('('); - - for (int k=0; k scan1 change 2/2/2007 ( not change to pass macro name as a parameter) - if ( (rr=='}') && (--lvll==0) ) - continue; // remove first { - else if ( (rr=='{') && (++lvll==1) ) - continue; // remove last } - else if(lvll==0) // count the open close () [] - { - if(lvl && rr==')') lvl--; // if ( then we eat next ) - else if(lvl && rr==']') lvl--; // if ( then we eat next ) - else if (rr=='(') lvl++ ; // eat next - else if (rr=='[') lvl++ ; // eat next - else if (lvl<=0) - { - if (rr==kend ) break; - else if (rr==')' || rr==',') // Correction FH 2/06/2004 - { - cerr << "Error in macro expansion "<< j->first - << ", we wait for "<< char(kend) << " and we get " << char(rr)<< endl; - cerr << " number of macro parameter in definition is " << nbparam << endl; - ErrorScan(" Wrong number of parameter in macro call"); - } - } - } - - if (rr==ENDOFFILE) ErrorScan(" ENDOFFILE in macro usage"); - if(sep==' ') p+=' '; - p += token(); // Correction FH 2/06/2004 of string parameter - - } - if(debugmacro) - cout << "macro arg "<< k << " :" << macroparm.d[k] << " -> " << p << endl; - lp.insert(pair(macroparm.d[k],p)); - } - } - if(debugmacro) - cout << " input in : -> " << macroparm.d[nbparam] << " <-> " << nbparam << endl; - input(macroparm.d[nbparam],0,macroparm.l);// no file no error here FH. - // ici il faut faire la substitution de parameter - // ----------------------------------------------- - string expandtxt; - string currentexpand; - string leftexpand; - string rightexpand; - string ReadCommentAndSpace; - bool echosave=echo; - char buf2[256]; - const char *ifm="IFMACRO"; - const char *ifs="Stringification"; - bool inifmacro = 0; - bool isconc = 0; - int nbparenth = 0; - while(1) - { - ReadCommentAndSpace = ""; - int c= EatCommentAndSpace(&ReadCommentAndSpace); // eat comment to save it; - if (c == EOF) { - expandtxt+=currentexpand+ReadCommentAndSpace; - break; - } - ret = basescan(); - if(debugmacro) cout << " ret = " << ret << token() << endl; - if(ret== ENDOFFILE) { - expandtxt+=currentexpand+ReadCommentAndSpace; - break; - } - if (inifmacro && (ret == '(')) - nbparenth++; - if (inifmacro && (ret == ')')) - nbparenth--; - if (nbparam && (ret != '#') && (ret != ')' || !inifmacro)) - { - if (strncmp(buf,ifm,8)==0 || strncmp(buf,ifs,15)==0) - inifmacro = 1; - - if (!isconc) { - MapMacroParam::const_iterator j=lp.find(buf); - if ( j != lp.end()) { - expandtxt+=currentexpand+ReadCommentAndSpace; - currentexpand=j->second; - } - else { - expandtxt+=currentexpand+ReadCommentAndSpace; - currentexpand=token(); - } - } - if (isconc) { - MapMacroParam::const_iterator j=lp.find(buf); - if ( j != lp.end()) { - rightexpand=j->second; - - if (rightexpand[0] == ' ') - rightexpand.erase(0, 1); - } - else - rightexpand=token(); - - currentexpand = leftexpand+rightexpand; - if (!inifmacro) - for (list::const_iterator i=listMacroDef->begin(); i != listMacroDef->end(); i++) { - - - while (currentexpand[0] == ' ') - currentexpand.erase(0, 1); - - MapMacroDef::const_iterator j= i->find(currentexpand.c_str()); - if (j != i->end()) { - const MacroData & macroparm= j->second; - if (macroparm.d.size() == 1) { - currentexpand = macroparm.d[0]; - if (currentexpand[currentexpand.size()-1] == ' ') - currentexpand.resize(currentexpand.size()-1); - } - } - } - isconc = 0; - } - } - else if (ret!='#') { // macro concatenation operator - if (ret == ')' && inifmacro && nbparenth == 0) - inifmacro = 0; - if (!isconc) { - expandtxt+=currentexpand+ReadCommentAndSpace; - currentexpand=token(); - } - - } - else { - leftexpand = currentexpand; - isconc = 1; - } - } - echo=echosave; - if(debugmacro) cout <<" (macro) eadin : " << expandtxt << endl; - input(expandtxt,macronn,macroparm.l); - ret = scan1(); // Correction FH 6/06/2004 of string parameter - return true; - } - } - return false; -} + l = 0; + nf = f = 0; + sep = ':'; + // Try to open the given file name without any extra path from [[file:lex.hpp::ffincludedir]] + if (lex->ffincludedir.empty( )) nf = f = new ifstream(ff, ios_base::binary); // modif of win32 -void mylex::xxxx::open(mylex *lex,const char * ff,int ts) -{ - - string dirname; - typeofscript=ts ? ts: setMarkdown(ff) ; - - l=0; - nf=f=0; - sep=':'; - // Try to open the given file name without any extra path from [[file:lex.hpp::ffincludedir]] - if (lex->ffincludedir.empty()) - nf=f= new ifstream(ff,ios_base::binary); // modif of win32 - - // If it worked, set [[file:lex.hpp::filename]] to ff, otherwise try to open it - // in the same directory as the file which includes it - if (!f || !*f) + // If it worked, set [[file:lex.hpp::filename]] to ff, otherwise try to open it + // in the same directory as the file which includes it + if (!f || !*f) { + // if the file is included by another one, it is searched in the same directory + if (lex->level >= 0) // file is included by another one { - // if the file is included by another one, it is searched in the same directory - if (lex->level >= 0) // file is included by another one - { - if (f) - { - delete f; - nf=f=0; - } + if (f) { + delete f; + nf = f = 0; + } - // directory separator can be / (Unix) or \ (Windows) - string separator = "/\\"; + // directory separator can be / (Unix) or \ (Windows) + string separator = "/\\"; - // parent_filename is the full path to the file which includes filename - string parent_filename(*lex->pilesource[lex->level].filename); + // parent_filename is the full path to the file which includes filename + string parent_filename(*lex->pilesource[lex->level].filename); - // get dirname of parent_filename - size_t found = parent_filename.find_last_of(separator); - dirname = parent_filename.substr(0,found+1); + // get dirname of parent_filename + size_t found = parent_filename.find_last_of(separator); + dirname = parent_filename.substr(0, found + 1); - // try to open dirname/ff - string dif_ff(dirname+ff); - nf=f= new ifstream(dif_ff.c_str(),ios_base::binary); - } + // try to open dirname/ff + string dif_ff(dirname + ff); + nf = f = new ifstream(dif_ff.c_str( ), ios_base::binary); + } + } + + // If it worked, set [[file:lex.hpp::filename]] to dirname+ff, otherwise try to add path elements from + // [[file:lex.hpp::ffincludedir]] + if (!f || !*f) { + if (f) { + delete f; + nf = f = 0; } - // If it worked, set [[file:lex.hpp::filename]] to dirname+ff, otherwise try to add path elements from - // [[file:lex.hpp::ffincludedir]] - if (!f || !*f) - { - if ( f) - { - delete f; - nf=f=0; - } - - // for every potential path element - for (ICffincludedir k=lex->ffincludedir.begin(); - k!=lex->ffincludedir.end(); - ++k) - { - string dif_ff(*k+ff); - if (verbosity>=50) lex->cout << " --lex open :" << dif_ff << endl; - nf=f= new ifstream(dif_ff.c_str(),ios_base::binary); - if ( f) - { - - // If path works, set [[file:lex.hpp::filename]] and close test stream - if ( f->good()) - { - filename = newstring(dif_ff); - break; - } - delete f; - nf=f=0; - } + // for every potential path element + for (ICffincludedir k = lex->ffincludedir.begin( ); k != lex->ffincludedir.end( ); ++k) { + string dif_ff(*k + ff); + if (verbosity >= 50) lex->cout << " --lex open :" << dif_ff << endl; + nf = f = new ifstream(dif_ff.c_str( ), ios_base::binary); + if (f) { + + // If path works, set [[file:lex.hpp::filename]] and close test stream + if (f->good( )) { + filename = newstring(dif_ff); + break; } + delete f; + nf = f = 0; + } } - else - filename=newstring(ff); + } else + filename = newstring(ff); - // Error message if no path was right - if (!f || !*f) - { - lex->cout << " Error opening file " <cout << " -- try :\"" << dirname+ff << "\"\n"; - for (ICffincludedir k=lex->ffincludedir.begin(); - k!=lex->ffincludedir.end(); - ++k) - lex->cout << " -- try :\"" << *k+ff << "\"\n"; - - lgerror("lex: Error input opening file "); - } + // Error message if no path was right + if (!f || !*f) { + lex->cout << " Error opening file " << ff << " in: " << endl; + if (!dirname.empty( )) lex->cout << " -- try :\"" << dirname + ff << "\"\n"; + for (ICffincludedir k = lex->ffincludedir.begin( ); k != lex->ffincludedir.end( ); ++k) lex->cout << " -- try :\"" << *k + ff << "\"\n"; + + lgerror("lex: Error input opening file "); + } } -void mylex::xxxx::readin(mylex *lex,const string & s,const string *name, int macroargs) -{ - filename=name; - macroarg=macroargs; - l=0; - nf=f= new istringstream(s.c_str()); - if(verbosity>999) std::cout << " readin :"<< s << "!!!.."<< endl; - sep='@'; - if (!f || !*f) - { - lex->cout << " Error readin string :" < 999) std::cout << " readin :" << s << "!!!.." << endl; + sep = '@'; + if (!f || !*f) { + lex->cout << " Error readin string :" << s << endl; + if (f) delete f; + nf = f = 0; + lgerror("lex: Error readin macro "); + } } -void mylex::xxxx::close() -{ - // ALH_BUG Why does this segfault under Windows? Probably needs valgrind to find out. +void mylex::xxxx::close( ) { + // ALH_BUG Why does this segfault under Windows? Probably needs valgrind to find out. #if !defined(ENABLE_FFCS) || !defined(WIN32) - if(nf) delete nf; + if (nf) delete nf; #endif - if(filename && (macroarg==0)) delete filename; // [[file:lex.hpp::filename]] - f=nf=0; + if (filename && (macroarg == 0)) delete filename; // [[file:lex.hpp::filename]] + f = nf = 0; } // <> -void mylex::input(const char * filename,int ts) -{ - ffassert(level<99 && level >= -1); - if (level>=0) - pilesource[level].l =linenumber; +void mylex::input(const char *filename, int ts) { + ffassert(level < 99 && level >= -1); + if (level >= 0) pilesource[level].l = linenumber; - pilesource[level+1].open(this,filename,ts); - pilesource[level+1].l =0; - linenumber = 1; - level++; + pilesource[level + 1].open(this, filename, ts); + pilesource[level + 1].l = 0; + linenumber = 1; + level++; } // <> -void mylex::input(const string & str,const string * name,int lg) -{ - - ffassert(level<99 && level >= -1); - if (level>=0) - { - pilesource[level].l =linenumber; - } +void mylex::input(const string &str, const string *name, int lg) { - pilesource[level+1].readin(this,str,name); - linenumber = lg; - level++; + ffassert(level < 99 && level >= -1); + if (level >= 0) { + pilesource[level].l = linenumber; + } + pilesource[level + 1].readin(this, str, name); + linenumber = lg; + level++; } -bool mylex::close() -{ - if(debugmacro ) - cout << "\n close " << level ; - ffassert(level >=0 && level < 100); - pilesource[level].close(); // [[mylex::xxxx::close]] - if (--level<0) - return false; - linenumber = pilesource[level].l; - return true; +bool mylex::close( ) { + if (debugmacro) cout << "\n close " << level; + ffassert(level >= 0 && level < 100); + pilesource[level].close( ); // [[mylex::xxxx::close]] + if (--level < 0) return false; + linenumber = pilesource[level].l; + return true; } -mylex::~mylex() -{ - delete listMacroDef; - while( ! strdata.empty()) - { - // commente july 2005 FH ???. a test plus finement. - delete [] strdata.top(); // bug ????? FH 25032005 - strdata.pop(); - } +mylex::~mylex( ) { + delete listMacroDef; + while (!strdata.empty( )) { + // commente july 2005 FH ???. a test plus finement. + delete[] strdata.top( ); // bug ????? FH 25032005 + strdata.pop( ); + } } -mylex::mylex(ostream & out,bool eecho,const KN *pargs) - : - linenumber(1), - charnumber(0), - ffincludedir(ffenvironment["includepath"]), - firsttime(true), - level(-1), - echo(eecho && (mpirank == 0) && verbosity), - cout(out), - listMacroDef(new list), - listMacroParam(0) -{ - listMacroDef->push_front(MapMacroDef()); - if(pargs) - { - const KN &args=*pargs; - for (int i=1; i 3) - AddMacro(a.substr(2,ie-2),a.substr(ie+1,a.length()-ie-1)); - - } - - } +mylex::mylex(ostream &out, bool eecho, const KN< String > *pargs) + : linenumber(1), charnumber(0), ffincludedir(ffenvironment["includepath"]), firsttime(true), level(-1), echo(eecho && (mpirank == 0) && verbosity), cout(out), listMacroDef(new list< MapMacroDef >), + listMacroParam(0) { + listMacroDef->push_front(MapMacroDef( )); + if (pargs) { + const KN< string > &args = *pargs; + for (int i = 1; i < args.N( ); ++i) { + const string &a = args[i]; + size_t id = a.find_first_of("-D"); + if (id == 0) { + size_t ie = a.find_first_of("="); + if (ie != std::string::npos && ie > 3) AddMacro(a.substr(2, ie - 2), a.substr(ie + 1, a.length( ) - ie - 1)); + } } + } }; -mylex * Newlex( ostream & out,bool eecho,KN * args) -{ - return new mylex(out,eecho,args); -} -void Destroylex(mylex * m) -{ - delete m; -} -ostream & mylex::ShowStack(ostream & f) -{ - for (int i=0; i *args) { return new mylex(out, eecho, args); } +void Destroylex(mylex *m) { delete m; } +ostream &mylex::ShowStack(ostream &f) { + for (int i = 0; i < level; ++i) + if (pilesource[i].filename) f << " \t" << i << "\t" << " in " << *pilesource[i].filename << " line : " << pilesource[i].l << endl; + return f; } diff --git a/src/fflib/lex.hpp b/src/fflib/lex.hpp index b87cfd084..cb574e776 100644 --- a/src/fflib/lex.hpp +++ b/src/fflib/lex.hpp @@ -2,182 +2,192 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MY_LEX_HPP_ #define MY_LEX_HPP_ -// with New version of macro expansion more simple and more stable +// with New version of macro expansion more simple and more stable // FH jan 2005 -#include +#include #include "environment.hpp" extern bool lexdebug; -extern long mpisize,mpirank; - +extern long mpisize, mpirank; /// <> -class mylex : public CodeAlloc { - public: - typedef const char * Key; - typedef pair Value; - struct MacroData{ deque d; int l; string f;};// f is not a pointeur (pb of delete) - // Warning f not a pointeur because - // - struct Keyless - { - using first_argument_type = Key; +class mylex : public CodeAlloc { + public: + typedef const char *Key; + typedef pair< int, aType > Value; + struct MacroData { + deque< string > d; + int l; + string f; + }; // f is not a pointeur (pb of delete) + // Warning f not a pointeur because + // + struct Keyless { + using first_argument_type = Key; using second_argument_type = Key; - using result_type = bool; - bool operator()(const Key& x, const Key& y) const{ return strcmp(x,y)<0;} }; - typedef map MapMotClef; - typedef map MapMacroDef; - typedef map MapMacroParam; - typedef MapMotClef::const_iterator const_iterator; - typedef MapMotClef::iterator iterator; - - public: - int linenumber,charnumber; - list ffincludedir; // <> - typedef list::iterator Iffincludedir; - typedef list::const_iterator ICffincludedir; - - private: + using result_type = bool; + bool operator( )(const Key &x, const Key &y) const { return strcmp(x, y) < 0; } + }; + typedef map< const char *, Value, Keyless > MapMotClef; + typedef map< const char *, MacroData, Keyless > MapMacroDef; + typedef map< string, string > MapMacroParam; + typedef MapMotClef::const_iterator const_iterator; + typedef MapMotClef::iterator iterator; + + public: + int linenumber, charnumber; + list< string > ffincludedir; // <> + typedef list< string >::iterator Iffincludedir; + typedef list< string >::const_iterator ICffincludedir; + + private: bool firsttime; int level; char buf[1024]; int typetoken; bool echo; - stack strdata; + stack< char * > strdata; - struct xxxx { + struct xxxx { int l; - istream * f; - const string * filename; // <> + istream *f; + const string *filename; // <> int macroarg; - istream * nf; - int typeofscript; + istream *nf; + int typeofscript; char sep; - xxxx() : l(0), f(0) , filename(0),macroarg(0),nf(0),typeofscript(0),sep(':') {} - void open(mylex *lexx,const char * ff,int ts=0) ; - void readin(mylex *lexx,const string & s,const string *name=0,int macroargg=0); - void close() ; + xxxx( ) : l(0), f(0), filename(0), macroarg(0), nf(0), typeofscript(0), sep(':') {} + void open(mylex *lexx, const char *ff, int ts = 0); + void readin(mylex *lexx, const string &s, const string *name = 0, int macroargg = 0); + void close( ); }; - + friend struct mylex::xxxx; - + xxxx pilesource[100]; - istream & source() const {return * pilesource[level].f;} - const char * sep() const {static char buf[]=" : "; buf[1]=pilesource[level].sep; return buf; } - const string file() const { return pilesource[level].filename? *pilesource[level].filename : string("") ;} - ostream & cout ; + istream &source( ) const { return *pilesource[level].f; } + const char *sep( ) const { + static char buf[] = " : "; + buf[1] = pilesource[level].sep; + return buf; + } + const string file( ) const { return pilesource[level].filename ? *pilesource[level].filename : string(""); } + ostream &cout; // <> - MapMotClef MotClef; - - list *listMacroDef; - list *listMacroParam; - public: - - mylex(ostream & out,bool eecho=true,const KN *pargs=0 ); - string token() const; - void print(ostream &f) const; + MapMotClef MotClef; + + list< MapMacroDef > *listMacroDef; + list< MapMacroParam > *listMacroParam; + + public: + mylex(ostream &out, bool eecho = true, const KN< String > *pargs = 0); + string token( ) const; + void print(ostream &f) const; /// This is the main [[file:../lglib/lg.ypp::yylex]] entry point from the grammar. Implemented in /// [[file:lex.cpp::mylex_scan]] - int scan(int lvl=0); + int scan(int lvl = 0); + + int lineno( ) { return linenumber; } + char *YYText( ) { return buf; } + void dump(ostream &f); - int lineno(){return linenumber;} - char * YYText() { return buf;} - void dump(ostream & f ) ; - - void erreur(const char * s) { - cerr << " Error line number" <> [[file:lex.cpp::mylex_input_string]] - bool InMotClef(const char *b,aType &t,int &r)const; - - void Add(Key k,int r,aType t); - - void Check(bool b,Key k,const char * s) { - if(b) {cout <<"Add " << s << " null: " << k << endl; - CompileError();}} - - void Add(Key k,int i) ;// {Check(!i,k,"mot clef");Add(k,i,0); } - void Add(Key k,aType t);// {Check(!t,k,"type");Add(k,TYPE,t); } - void AddF(Key k,aType t);// {Check(!t,k,"type");Add(k,FUNCTION,t); } - void AddSpace(Key k,aType t);// {Check(!t,k,"type");Add(k,FUNCTION,t); } - - const char * filename() const { - if ( level >=0 ) - return pilesource[level].filename ? pilesource[level].filename->c_str() : " -- in macro -- "; - return "-- unknown --";} - - void input(const char * filename,int ts=0) ; - void input(const string &str,const string *name=0,int lg=0); - bool close() ; - - char * newcopy(const char * s) - { - char *r(new char [strlen(s)+1]); + bool InMotClef(const char *b, aType &t, int &r) const; + + void Add(Key k, int r, aType t); + + void Check(bool b, Key k, const char *s) { + if (b) { + cout << "Add " << s << " null: " << k << endl; + CompileError( ); + } + } + + void Add(Key k, int i); // {Check(!i,k,"mot clef");Add(k,i,0); } + void Add(Key k, aType t); // {Check(!t,k,"type");Add(k,TYPE,t); } + void AddF(Key k, aType t); // {Check(!t,k,"type");Add(k,FUNCTION,t); } + void AddSpace(Key k, aType t); // {Check(!t,k,"type");Add(k,FUNCTION,t); } + + const char *filename( ) const { + if (level >= 0) return pilesource[level].filename ? pilesource[level].filename->c_str( ) : " -- in macro -- "; + return "-- unknown --"; + } + + void input(const char *filename, int ts = 0); + void input(const string &str, const string *name = 0, int lg = 0); + bool close( ); + + char *newcopy(const char *s) { + char *r(new char[strlen(s) + 1]); strcpy(r, s); strdata.push(r); return r; } - ostream & ShowStack(ostream & f); - ~mylex(); -private: - int basescan(); - int basescanprint(int lvl=0); // with print if lvl =0 - int EatCommentAndSpace(string *data=0); - int scan1(); + ostream &ShowStack(ostream &f); + ~mylex( ); + + private: + int basescan( ); + int basescanprint(int lvl = 0); // with print if lvl =0 + int EatCommentAndSpace(string *data = 0); + int scan1( ); bool SetMacro(int &ret); bool CallMacro(int &ret); - const MacroData *IsMacro(); - string ExpandMacro(const string ¯oname,const MacroData *pmacro); - + const MacroData *IsMacro( ); + string ExpandMacro(const string ¯oname, const MacroData *pmacro); + bool IFMacro(int &ret); - bool IFMacroArgs(int lvl=0);// scan IFMacroArgs - bool IFMacroId(bool isnot,string & id,bool withval ,string &val);// say if args is true or not .. - - bool AddMacro(string m,string def) ; - char * match(int i); - void ErrorScan(const char * s) { - cerr << "\n" ; - ShowStack(cerr); - throw(ErrorCompile(s,lineno(),YYText() ) );} - - -} ; - -mylex * Newlex( ostream & out,bool =true,KN * args=0); - void Destroylex(mylex * m); + bool IFMacroArgs(int lvl = 0); // scan IFMacroArgs + bool IFMacroId(bool isnot, string &id, bool withval, string &val); // say if args is true or not .. + + bool AddMacro(string m, string def); + char *match(int i); + void ErrorScan(const char *s) { + cerr << "\n"; + ShowStack(cerr); + throw(ErrorCompile(s, lineno( ), YYText( ))); + } +}; + +mylex *Newlex(ostream &out, bool = true, KN< String > *args = 0); +void Destroylex(mylex *m); /// <> This pointer is allocated in [[file:global.cpp::zzzfff]] and initialized in /// [[file:../lglib/lg.ypp::zzzfff]] diff --git a/src/fflib/lgfem.cpp b/src/fflib/lgfem.cpp index fb2512f7a..b3a3139b1 100644 --- a/src/fflib/lgfem.cpp +++ b/src/fflib/lgfem.cpp @@ -84,33 +84,33 @@ namespace Fem2D { extern GTypeOfFE< MeshS > &P2bLagrange_surf; extern GTypeOfFE< MeshS > &RT0surf; extern GTypeOfFE< MeshS > &RT0orthosurf; -// add 22 march 2021 FH. + // add 22 march 2021 FH. extern GTypeOfFE< Mesh3 > &G_P1dc_3d; extern GTypeOfFE< Mesh3 > &G_P2dc_3d; extern GTypeOfFE< Mesh3 > &G_P3dc_3d; extern GTypeOfFE< Mesh3 > &G_P4dc_3d; - extern GTypeOfFE & G_P0Edge_3d ; - extern GTypeOfFE & G_P0Edgedc_3d ; - extern GTypeOfFE & G_P0Face_3d ; - extern GTypeOfFE & G_P0Facedc_3d ; - extern GTypeOfFE & G_P0VF_3d ; - extern GTypeOfFE & G_P0VFdc_3d ; + extern GTypeOfFE< Mesh3 > &G_P0Edge_3d; + extern GTypeOfFE< Mesh3 > &G_P0Edgedc_3d; + extern GTypeOfFE< Mesh3 > &G_P0Face_3d; + extern GTypeOfFE< Mesh3 > &G_P0Facedc_3d; + extern GTypeOfFE< Mesh3 > &G_P0VF_3d; + extern GTypeOfFE< Mesh3 > &G_P0VFdc_3d; extern GTypeOfFE< MeshS > &G_P1dc_S; extern GTypeOfFE< MeshS > &G_P2dc_S; extern GTypeOfFE< MeshS > &G_P3dc_S; extern GTypeOfFE< MeshS > &G_P4dc_S; - extern GTypeOfFE & G_P0Edge_S ; - extern GTypeOfFE & G_P0Edgedc_S ; - extern GTypeOfFE & G_P0VF_S ; - extern GTypeOfFE & G_P0VFdc_S ; - -extern GTypeOfFE< MeshL > &G_P1dc_L; -extern GTypeOfFE< MeshL > &G_P2dc_L; -extern GTypeOfFE< MeshL > &G_P3dc_L; -extern GTypeOfFE< MeshL > &G_P4dc_L; -extern GTypeOfFE & G_P0VF_L ; -extern GTypeOfFE & G_P0VFdc_L ; + extern GTypeOfFE< MeshS > &G_P0Edge_S; + extern GTypeOfFE< MeshS > &G_P0Edgedc_S; + extern GTypeOfFE< MeshS > &G_P0VF_S; + extern GTypeOfFE< MeshS > &G_P0VFdc_S; + + extern GTypeOfFE< MeshL > &G_P1dc_L; + extern GTypeOfFE< MeshL > &G_P2dc_L; + extern GTypeOfFE< MeshL > &G_P3dc_L; + extern GTypeOfFE< MeshL > &G_P4dc_L; + extern GTypeOfFE< MeshL > &G_P0VF_L; + extern GTypeOfFE< MeshL > &G_P0VFdc_L; void Expandsetoflab(Stack stack, const CDomainOfIntegration &di, set< int > &setoflab, bool &all); } // namespace Fem2D @@ -130,11 +130,10 @@ namespace FreeFempp { TypeVarForm< R > *TypeVarForm< R >::Global; } -basicAC_F0::name_and_type OpCall_FormBilinear_np::name_param[] = { - {"bmat", &typeid(Matrice_Creuse< R > *)}, LIST_NAME_PARM_MAT, - // param for bem solver - LIST_NAME_PARM_HMAT -}; +basicAC_F0::name_and_type OpCall_FormBilinear_np::name_param[] = {{"bmat", &typeid(Matrice_Creuse< R > *)}, + LIST_NAME_PARM_MAT, + // param for bem solver + LIST_NAME_PARM_HMAT}; basicAC_F0::name_and_type OpCall_FormLinear_np::name_param[] = {"tgv", &typeid(double)}; @@ -297,36 +296,35 @@ class E_P_Stack_N : public E_F0mps { operator aType( ) const { return atype< R3 * >( ); } }; - class E_P_Stack_Nt : public E_F0mps { public: - AnyType operator( )(Stack s) const { - ExecError("Remove name Nt, now use Ns on surface and Tl on Curve"); - return SetAny< R3 * >(&MeshPointStack(s)->Nt); - } - - operator aType( ) const { return atype< R3 * >( ); } + AnyType operator( )(Stack s) const { + ExecError("Remove name Nt, now use Ns on surface and Tl on Curve"); + return SetAny< R3 * >(&MeshPointStack(s)->Nt); + } + + operator aType( ) const { return atype< R3 * >( ); } }; class E_P_Stack_Ns : public E_F0mps { public: - AnyType operator( )(Stack s) const { - throwassert(*((long *)s)); - assert(MeshPointStack(s)->dHat==2); - return SetAny< R3 * >(&MeshPointStack(s)->Nt); - } - - operator aType( ) const { return atype< R3 * >( ); } + AnyType operator( )(Stack s) const { + throwassert(*((long *)s)); + assert(MeshPointStack(s)->dHat == 2); + return SetAny< R3 * >(&MeshPointStack(s)->Nt); + } + + operator aType( ) const { return atype< R3 * >( ); } }; class E_P_Stack_Tl : public E_F0mps { public: - AnyType operator( )(Stack s) const { - throwassert(*((long *)s)); - assert(MeshPointStack(s)->dHat==1); - return SetAny< R3 * >(&MeshPointStack(s)->Nt); - } - - operator aType( ) const { return atype< R3 * >( ); } + AnyType operator( )(Stack s) const { + throwassert(*((long *)s)); + assert(MeshPointStack(s)->dHat == 1); + return SetAny< R3 * >(&MeshPointStack(s)->Nt); + } + + operator aType( ) const { return atype< R3 * >( ); } }; class E_P_Stack_Region : public E_F0mps { @@ -408,18 +406,19 @@ class E_P_Stack_lenEdge : public E_F0mps { throwassert(*((long *)s)); MeshPoint *mp = MeshPointStack(s); double l = 1e100; - if (mp->d == 2){ + if (mp->d == 2) { assert(mp->T); - l = mp->T->lenEdge(mp->e);} - else if (mp->d == 3 && mp->dHat == 3){ + l = mp->T->lenEdge(mp->e); + } else if (mp->d == 3 && mp->dHat == 3) { assert(mp->T3); - l = mp->T3->lenEdge(mp->e);} - else if (mp->d == 3 && mp->dHat == 2){ + l = mp->T3->lenEdge(mp->e); + } else if (mp->d == 3 && mp->dHat == 2) { assert(mp->TS); - l = mp->TS->lenEdge(mp->e);} - else if (mp->d == 3 && mp->dHat == 1){ + l = mp->TS->lenEdge(mp->e); + } else if (mp->d == 3 && mp->dHat == 1) { assert(mp->TL); - l = mp->TL->mesure();} + l = mp->TL->mesure( ); + } return SetAny< double >(l); } @@ -432,17 +431,17 @@ class E_P_Stack_hTriangle : public E_F0mps { throwassert(*((long *)s)); MeshPoint *mp = MeshPointStack(s); double l = 1e100; - if (mp->d == 2){ + if (mp->d == 2) { assert(mp->T); - l = mp->T->h( );} - else if (mp->d == 3 && mp->dHat == 3){ + l = mp->T->h( ); + } else if (mp->d == 3 && mp->dHat == 3) { assert(mp->T3); - l = mp->T3->lenEdgesmax( );} - else if (mp->d == 3 && mp->dHat == 2){ + l = mp->T3->lenEdgesmax( ); + } else if (mp->d == 3 && mp->dHat == 2) { assert(mp->TS); - l = mp->TS->lenEdgesmax( );} - else if (mp->d == 3 && mp->dHat == 1){ - l = mp->TS->mesure();// add FH juin 2021 + l = mp->TS->lenEdgesmax( ); + } else if (mp->d == 3 && mp->dHat == 1) { + l = mp->TS->mesure( ); // add FH juin 2021 } return SetAny< double >(l); } @@ -489,13 +488,11 @@ class E_P_Stack_uniqueBE : public E_F0mps { throwassert(*((long *)s)); MeshPoint *mp = MeshPointStack(s); double l = 0; - if ((mp->T) && (mp->e > -1) && (mp->d == 2)) - { - int it = mp->t,ie=mp->e; - int iee=ie,itt=mp->Th->ElementAdj(it,iee); - l = it*3+ie <= itt*3+iee; - } - else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) + if ((mp->T) && (mp->e > -1) && (mp->d == 2)) { + int it = mp->t, ie = mp->e; + int iee = ie, itt = mp->Th->ElementAdj(it, iee); + l = it * 3 + ie <= itt * 3 + iee; + } else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) l = mp->Th3->uniqueBE(mp->t, mp->f); else if (mp->d == 3 && mp->dHat == 2 && mp->TS && (mp->e >= 0)) l = mp->ThS->uniqueBE(mp->t, mp->e); @@ -507,25 +504,24 @@ class E_P_Stack_uniqueBE : public E_F0mps { operator aType( ) const { return atype< long >( ); } }; - -template< int NBT > // modif FH juin 2021 to be generic ... +template< int NBT > // modif FH juin 2021 to be generic ... class E_P_Stack_TypeBE : public E_F0mps { public: AnyType operator( )(Stack s) const { throwassert(*((long *)s)); MeshPoint *mp = MeshPointStack(s); - long l = 0; - if ((mp->T) && (mp->e > -1) && (mp->d == 2)) - l = mp->Th->nTonEdge(mp->t, mp->e); - else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) - l = mp->Th3->nElementonB(mp->t, mp->f); - else if (mp->d == 3 && mp->dHat == 2 && mp->TS && (mp->e >= 0)) - l = mp->ThS->nElementonB(mp->t, mp->e); - else if (mp->d == 3 && mp->dHat == 1 && mp->TL && (mp->v >= 0)) - l = mp->ThL->nElementonB(mp->t, mp->v); + long l = 0; + if ((mp->T) && (mp->e > -1) && (mp->d == 2)) + l = mp->Th->nTonEdge(mp->t, mp->e); + else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) + l = mp->Th3->nElementonB(mp->t, mp->f); + else if (mp->d == 3 && mp->dHat == 2 && mp->TS && (mp->e >= 0)) + l = mp->ThS->nElementonB(mp->t, mp->e); + else if (mp->d == 3 && mp->dHat == 1 && mp->TL && (mp->v >= 0)) + l = mp->ThL->nElementonB(mp->t, mp->v); ffassert(l); - long ll = min(l,2l) == NBT;// NBT 2 => internal but l > =2 if no manifold ase + long ll = min(l, 2l) == NBT; // NBT 2 => internal but l > =2 if no manifold ase return SetAny< long >(ll); } @@ -568,8 +564,8 @@ class E_P_Stack_EdgeOrient : public E_F0mps { if (mp.T3 && mp.f >= 0) r = mp.T3->faceOrient(mp.f); } else if (mp.d == 3 && mp.dHat == 2) { if (mp.TS && mp.e >= 0) r = mp.TS->EdgeOrientation(mp.e); - } - else ffassert(0); // debile on meshL FH juin 2021 .. + } else + ffassert(0); // debile on meshL FH juin 2021 .. return r; } @@ -609,8 +605,7 @@ class E_StopGC : public StopGC< R > { C_F0 stop; E_StopGC(Stack ss, long nn, const Polymorphic *op) - : s(ss), n(nn), iter(-1), xx(0, 0), gg(0, 0), citer(CConstant< long * >(&iter)), - cxx(dCPValue(&xx)), cgg(dCPValue(&gg)), stop(op, "(", citer, cxx, cgg) {} + : s(ss), n(nn), iter(-1), xx(0, 0), gg(0, 0), citer(CConstant< long * >(&iter)), cxx(dCPValue(&xx)), cgg(dCPValue(&gg)), stop(op, "(", citer, cxx, cgg) {} ~E_StopGC( ) { delete (E_F0 *)cxx; @@ -643,9 +638,7 @@ class LinearCG : public OneOperator { Expression mat1, mat; typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; - MatF_O(int n, Stack stk, const OneOperator *op) - : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), - mat1(op->code(basicAC_F0_wa(c_x))), mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op))) {} + MatF_O(int n, Stack stk, const OneOperator *op) : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), mat1(op->code(basicAC_F0_wa(c_x))), mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op))) {} ~MatF_O( ) { if (mat1 != mat) delete mat; @@ -718,8 +711,7 @@ class LinearCG : public OneOperator { if (nargs[1]) nbitermax = GetAny< long >((*nargs[1])(stack)); if (nargs[3]) veps = GetAny< double * >((*nargs[3])(stack)); if (nargs[4]) verb = Abs(GetAny< long >((*nargs[4])(stack))); - if (nargs[5]) - stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[5])); + if (nargs[5]) stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[5])); long gcverb = 51L - Min(Abs(verb), 50L); if (verb == 0) gcverb = 1000000000; // no print @@ -746,8 +738,7 @@ class LinearCG : public OneOperator { MatF_O CC(n, stack, C); ret = ConjuguedGradient2(AA, CC, x, *bb, nbitermax, eps, gcverb, stop); } else - ret = - ConjuguedGradient2(AA, MatriceIdentite< R >(n), x, *bb, nbitermax, eps, gcverb, stop); + ret = ConjuguedGradient2(AA, MatriceIdentite< R >(n), x, *bb, nbitermax, eps, gcverb, stop); if (veps) *veps = -(eps); } catch (...) { if (stop) delete stop; @@ -762,19 +753,14 @@ class LinearCG : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_LCG(args, cas); } - LinearCG( ) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), - atype< KN< R > * >( )), - cas(2) {} + LinearCG( ) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), cas(2) {} - LinearCG(int cc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} + LinearCG(int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} }; template< class R > -basicAC_F0::name_and_type LinearCG< R >::E_LCG::name_param[] = { - {"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, - {"veps", &typeid(double *)}, {"verbosity", &typeid(long)}, {"stop", &typeid(Polymorphic *)}}; +basicAC_F0::name_and_type LinearCG< R >::E_LCG::name_param[] = {{"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, + {"veps", &typeid(double *)}, {"verbosity", &typeid(long)}, {"stop", &typeid(Polymorphic *)}}; template< class R > class LinearGMRES : public OneOperator { @@ -793,9 +779,7 @@ class LinearGMRES : public OneOperator { typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; MatF_O(int n, Stack stk, const OneOperator *op, KN< R > *bb) - : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), b(bb), - mat1(op->code(basicAC_F0_wa(c_x))), - mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op)) /*op->code(basicAC_F0_wa(c_x))*/) {} + : RNM_VirtualMatrix< R >(n), stack(stk), x(n), c_x(CPValue(x)), b(bb), mat1(op->code(basicAC_F0_wa(c_x))), mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op)) /*op->code(basicAC_F0_wa(c_x))*/) {} ~MatF_O( ) { if (mat1 != mat) delete mat; @@ -865,15 +849,12 @@ class LinearGMRES : public OneOperator { if (nargs[3]) eps = *GetAny< double * >((*nargs[3])(stack)); if (nargs[4]) dKrylov = GetAny< long >((*nargs[4])(stack)); if (nargs[5]) verb = Abs(GetAny< long >((*nargs[5])(stack))); - if (nargs[6]) - stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[6])); + if (nargs[6]) stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[6])); long gcverb = 51L - Min(Abs(verb), 50L); int ret = -1; - if (verbosity > 4) - cout << " ..GMRES: eps= " << eps << " max iter " << nbitermax << " dim of Krylov space " - << dKrylov << endl; + if (verbosity > 4) cout << " ..GMRES: eps= " << eps << " max iter " << nbitermax << " dim of Krylov space " << dKrylov << endl; KNM< R > H(dKrylov + 1, dKrylov + 1); int k = dKrylov; //,nn=n; @@ -897,9 +878,7 @@ class LinearGMRES : public OneOperator { if (bbgmres) { AA.addMatMul(*bbgmres, *bbgmres); // Ok Ax == b -> not translation of b . *bbgmres = -(*bbgmres); - if (verbosity > 1) - cout << " ** GMRES set b = -A(0); : max = " << bbgmres->max( ) - << " min = " << bbgmres->min( ) << endl; + if (verbosity > 1) cout << " ** GMRES set b = -A(0); : max = " << bbgmres->max( ) << " min = " << bbgmres->min( ) << endl; } if (cas < 0) { ErrorExec("NL GMRES: to do! sorry ", 1); @@ -908,8 +887,7 @@ class LinearGMRES : public OneOperator { MatF_O CC(n, stack, C, 0); ret = GMRES(AA, (KN< R > &)x, *bb, CC, H, k, nbitermax, epsr, verb, stop); } else - ret = GMRES(AA, (KN< R > &)x, *bb, MatriceIdentite< R >(n), H, k, nbitermax, epsr, verb, - stop); + ret = GMRES(AA, (KN< R > &)x, *bb, MatriceIdentite< R >(n), H, k, nbitermax, epsr, verb, stop); } if (verbosity > 99) cout << " Sol GMRES :" << x << endl; if (stop) delete stop; @@ -921,32 +899,25 @@ class LinearGMRES : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_LGMRES(args, cas); } - LinearGMRES( ) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), - atype< KN< R > * >( )), - cas(2) {} + LinearGMRES( ) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), cas(2) {} - LinearGMRES(int cc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} + LinearGMRES(int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} }; template< class R > -basicAC_F0::name_and_type LinearGMRES< R >::E_LGMRES::name_param[] = { - {"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, - {"veps", &typeid(double *)}, {"dimKrylov", &typeid(long)}, {"verbosity", &typeid(long)}, - {"stop", &typeid(Polymorphic *)}}; +basicAC_F0::name_and_type LinearGMRES< R >::E_LGMRES::name_param[] = {{"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, {"veps", &typeid(double *)}, + {"dimKrylov", &typeid(long)}, {"verbosity", &typeid(long)}, {"stop", &typeid(Polymorphic *)}}; // Add Jan 2024 interface with fgmres real and complex ... - -template< class R> +template< class R > class LinearFGMRES : public OneOperator { public: typedef KN< R > Kn; typedef KN_< R > Kn_; const int cas; - class MatF_O : public CGMatVirt< int,R > { + class MatF_O : public CGMatVirt< int, R > { public: Stack stack; int n; @@ -955,28 +926,26 @@ class LinearFGMRES : public OneOperator { KN< R > *b; Expression mat1, mat; - // typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + // typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; MatF_O(int nn, Stack stk, const OneOperator *op, KN< R > *bb) - : CGMatVirt(nn),n(nn), stack(stk), x(nn), c_x(CPValue(x)), b(bb), - mat1(op->code(basicAC_F0_wa(c_x))), - mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op)) /*op->code(basicAC_F0_wa(c_x))*/) {} + : CGMatVirt< int, R >(nn), n(nn), stack(stk), x(nn), c_x(CPValue(x)), b(bb), mat1(op->code(basicAC_F0_wa(c_x))), mat(CastTo< Kn_ >(C_F0(mat1, (aType)*op)) /*op->code(basicAC_F0_wa(c_x))*/) {} ~MatF_O( ) { if (mat1 != mat) delete mat; delete mat1; delete c_x.LeftValue( ); } - R *addmatmul(R *xx, R *Ax) const { - // void addMatMul(const KN_< R > &xx, KN_< R > &Ax) const { - //ffassert(xx.N( ) == Ax.N( )); + R *addmatmul(R *xx, R *Ax) const { + // void addMatMul(const KN_< R > &xx, KN_< R > &Ax) const { + // ffassert(xx.N( ) == Ax.N( )); x = xx; - KN_< R >(Ax,n) += GetAny< KN_< R > >((*mat)(stack)); - if (b && Ax != (R*) *b) KN_< R >(Ax,n) += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b + KN_< R >(Ax, n) += GetAny< KN_< R > >((*mat)(stack)); + if (b && Ax != (R *)*b) KN_< R >(Ax, n) += *b; // Ax -b => add b (not in cas of init. b c.a.d &Ax == b WhereStackOfPtr2Free(stack)->clean( ); - return Ax; + return Ax; } - // plusAx operator*(const Kn &x) const { return plusAx(this, x); } + // plusAx operator*(const Kn &x) const { return plusAx(this, x); } virtual bool ChecknbLine(int n) const { return true; } virtual bool ChecknbColumn(int m) const { return true; } }; @@ -1029,17 +998,15 @@ class LinearFGMRES : public OneOperator { if (nargs[3]) eps = *GetAny< double * >((*nargs[3])(stack)); if (nargs[4]) dKrylov = GetAny< long >((*nargs[4])(stack)); if (nargs[5]) verb = Abs(GetAny< long >((*nargs[5])(stack))); - // if (nargs[6]) - // stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[6])); + // if (nargs[6]) + // stop = new E_StopGC< R >(stack, n, dynamic_cast< const Polymorphic * >(nargs[6])); long gcverb = 51L - Min(Abs(verb), 50L); int ret = -1; - if (verbosity > 4) - cout << " ..FGMRES: eps= " << eps << " max iter " << nbitermax << " dim of Krylov space " - << dKrylov << endl; + if (verbosity > 4) cout << " ..FGMRES: eps= " << eps << " max iter " << nbitermax << " dim of Krylov space " << dKrylov << endl; - // KNM< R > H(dKrylov + 1, dKrylov + 1); + // KNM< R > H(dKrylov + 1, dKrylov + 1); int k = dKrylov; //,nn=n; double epsr = eps; KN< R > bzero(B ? 1 : n); // const array zero @@ -1058,29 +1025,27 @@ class LinearFGMRES : public OneOperator { KN< R > *bbgmres = 0; if (!B) bbgmres = bb; // none zero if gmres without B MatF_O AA(n, stack, A, bbgmres); - CGMatVirt& AV =AA; + CGMatVirt< int, R > &AV = AA; if (bbgmres) { AA.addmatmul(*bbgmres, *bbgmres); // Ok Ax == b -> not translation of b . *bbgmres = -(*bbgmres); - if (verbosity > 1) - cout << " ** FGMRES set b = -A(0); : max = " << bbgmres->max( ) - << " min = " << bbgmres->min( ) << endl; + if (verbosity > 1) cout << " ** FGMRES set b = -A(0); : max = " << bbgmres->max( ) << " min = " << bbgmres->min( ) << endl; } - CGMatVirtId Id(n); + CGMatVirtId< int, R > Id(n); if (cas < 0) { ErrorExec("NL FGMRES: to do! sorry ", 1); } else { if (C) { MatF_O CC(n, stack, C, 0); - ret=fgmres(AV,CC,1,(R*)*bb,x,epsr,nbitermax,k,verb,CC.pwcl()); - //ret = GMRES(AA, (KN< R > &)x, *bb, CC, H, k, nbitermax, epsr, verb, stop); + ret = fgmres< R, int >(AV, CC, 1, (R *)*bb, x, epsr, nbitermax, k, verb, CC.pwcl( )); + // ret = GMRES(AA, (KN< R > &)x, *bb, CC, H, k, nbitermax, epsr, verb, stop); } else - ret=fgmres(AV,Id,1,(R*)*bb,x,epsr,nbitermax,k,verb); - // ret = GMRES(AA, (KN< R > &)x, *bb, MatriceIdentite< R >(n), H, k, nbitermax, epsr, verb, - // stop); + ret = fgmres< R, int >(AV, Id, 1, (R *)*bb, x, epsr, nbitermax, k, verb); + // ret = GMRES(AA, (KN< R > &)x, *bb, MatriceIdentite< R >(n), H, k, nbitermax, epsr, verb, + // stop); } if (verbosity > 99) cout << " Sol GMRES :" << x << " ret " << ret << endl; - //if (stop) delete stop; + // if (stop) delete stop; return SetAny< long >(ret); } @@ -1089,20 +1054,14 @@ class LinearFGMRES : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new E_LGMRES(args, cas); } - LinearFGMRES( ) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), - atype< KN< R > * >( )), - cas(2) {} + LinearFGMRES( ) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( ), atype< KN< R > * >( )), cas(2) {} - LinearFGMRES(int cc) - : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} + LinearFGMRES(int cc) : OneOperator(atype< long >( ), atype< Polymorphic * >( ), atype< KN< R > * >( )), cas(cc) {} }; template< class R > -basicAC_F0::name_and_type LinearFGMRES< R >::E_LGMRES::name_param[] = { - {"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, - {"veps", &typeid(double *)}, {"dimKrylov", &typeid(long)}, {"verbosity", &typeid(long)} - }; +basicAC_F0::name_and_type LinearFGMRES< R >::E_LGMRES::name_param[] = {{"eps", &typeid(double)}, {"nbiter", &typeid(long)}, {"precon", &typeid(Polymorphic *)}, + {"veps", &typeid(double *)}, {"dimKrylov", &typeid(long)}, {"verbosity", &typeid(long)}}; template< typename int2 > typename map< int, int2 >::iterator closeto(map< int, int2 > &m, int k) { @@ -1143,8 +1102,7 @@ int numeroteclink(KN_< T > &ndfv) { ndfv[j] = nbdfv; j = ii; } while (j != nbdfv); - if (verbosity > 100) - cout << " ndf: " << j << " " << ii << " <- " << nbdfv << " " << kkk << endl; + if (verbosity > 100) cout << " ndf: " << j << " " << ii << " <- " << nbdfv << " " << kkk << endl; nbdfv++; } } @@ -1163,8 +1121,7 @@ bool InCircularList(const int *p, int i, int k) { return false; } -bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack stack, int &nbdfv, - KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { +bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack stack, int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { /* build numbering of vertex form 0 to nbdfv-1 and build numbering of edge form 0 to nbdfe-1 @@ -1222,8 +1179,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack nlk2[ip] = nblink2 - l2; } if (step) break; // no reallocl - if (verbosity > 3) - cout << " Periodic = " << nblink1 << " " << nblink2 << " step=" << step << endl; + if (verbosity > 3) cout << " Periodic = " << nblink1 << " " << nblink2 << " step=" << step << endl; link1 = new int[nblink1]; link2 = new int[nblink2]; if (nblink1 != nblink2) { @@ -1249,10 +1205,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack double x0 = GetAny< double >((*periodic[k + kk1])(stack)); mp->set(e[1].x, e[1].y); double x1 = GetAny< double >((*periodic[k + kk1])(stack)); - if (verbosity > 5) - cout << "lab1: e[" << pke1[i1] << "] v0: " << e[0].x << " " << e[0].y - << " s = " << x0 << "\t v1 " << e[1].x << " " << e[1].y << " s = " << x1 - << endl; + if (verbosity > 5) cout << "lab1: e[" << pke1[i1] << "] v0: " << e[0].x << " " << e[0].y << " s = " << x0 << "\t v1 " << e[1].x << " " << e[1].y << " s = " << x1 << endl; xmn = Min(x1, x0, xmn); xmx = Max(x1, x0, xmx); hmn = Min(hmn, Abs(x1 - x0)); @@ -1283,9 +1236,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack if (verbosity > 50) cout << xx << " " << i0 << " " << ie << endl; im = m.insert(pair< int, int2 >(i0, i2)).first; } else { - if (verbosity > 50) - cout << xx << " " << i0 << " " << ie << " : " << im->second[0] << " " - << im->second[1] << endl; + if (verbosity > 50) cout << xx << " " << i0 << " " << ie << " : " << im->second[0] << " " << im->second[1] << endl; assert((im->second[1] < 0) && (im->second[0] >= 0)); im->second[1] = ie; } @@ -1301,10 +1252,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack double xx0 = GetAny< double >((*periodic[k + kk2])(stack)); mp->set(e[1].x, e[1].y); double xx1 = GetAny< double >((*periodic[k + kk2])(stack)); - if (verbosity > 5) - cout << "lab2: e[" << pke2[i2] << "] v0: " << e[0].x << " " << e[0].y - << " s = " << xx0 << "\t v1 " << e[1].x << " " << e[1].y << " s = " << xx1 - << endl; + if (verbosity > 5) cout << "lab2: e[" << pke2[i2] << "] v0: " << e[0].x << " " << e[0].y << " s = " << xx0 << "\t v1 " << e[1].x << " " << e[1].y << " s = " << xx1 << endl; int i0 = int((xx0 - x0) * coef); int i1 = int((xx1 - x0) * coef); @@ -1326,8 +1274,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack else if (((ie1 = im0->second[0]) == im1->second[0]) && (ie1 >= 0)) ; else { - cout << ie2 << " ~ " << im0->second[0] << " " << im0->second[1] << ", " - << im1->second[0] << " " << im1->second[1] << endl; + cout << ie2 << " ~ " << im0->second[0] << " " << im0->second[1] << ", " << im1->second[0] << " " << im1->second[1] << endl; ExecError("periodic: Sorry one edge is lost"); } if (verbosity > 50) cout << " ( " << im0->second << " , " << im1->second << " ) .. "; @@ -1337,16 +1284,13 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack double yy0 = GetAny< double >((*periodic[k + kk1])(stack)); mp->set(ep[1].x, ep[1].y); double yy1 = GetAny< double >((*periodic[k + kk1])(stack)); - if (verbosity > 50) - cout << " e0: s " << xx0 << " " << xx1 << "e1 s " << yy0 << " " << yy1; + if (verbosity > 50) cout << " e0: s " << xx0 << " " << xx1 << "e1 s " << yy0 << " " << yy1; pke1[i2] = ie1 * 2 + (((yy1 - yy0) < 0) == ((xx1 - xx0) < 0)); if (verbosity > 50) - cout << " \t edge " << ie1 << " <=> " << ie2 << " " - << (((yy1 - yy0) < 0) == ((xx1 - xx0) < 0)) << "; " << xx0 << " " << xx1 - << " <=> " << yy0 << " " << yy1 << " :: " << Th(ep[0]) << " " << Th(ep[1]) - << endl; + cout << " \t edge " << ie1 << " <=> " << ie2 << " " << (((yy1 - yy0) < 0) == ((xx1 - xx0) < 0)) << "; " << xx0 << " " << xx1 << " <=> " << yy0 << " " << yy1 << " :: " << Th(ep[0]) + << " " << Th(ep[1]) << endl; } } } @@ -1393,9 +1337,7 @@ bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack return false; } -bool v_fes::buildperiodic(Stack stack, int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { - return BuildPeriodic2(nbcperiodic, periodic, **ppTh, stack, nbdfv, ndfv, nbdfe, ndfe); -} +bool v_fes::buildperiodic(Stack stack, int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { return BuildPeriodic2(nbcperiodic, periodic, **ppTh, stack, nbdfv, ndfv, nbdfe, ndfe); } #ifdef ZZZZZZZZ FESpace *pfes_tef::update( ) { typedef Smallvect< int, 2 > int2; @@ -1444,8 +1386,8 @@ AnyType TypeOfFESto2(Stack, const AnyType &b) { if (tS == 0) { cerr << " sorry no cast to this surface finite element " << t2 << endl; - // for( map< TypeOfFE *, TypeOfFES * >::const_iterator i=TEF2dtoS.begin(); i != TEF2dtoS.end(); ++i ) - // { cout << i->first << " -> " << i->second <::const_iterator i=TEF2dtoS.begin(); i != TEF2dtoS.end(); ++i ) + // { cout << i->first << " -> " << i->second < tedim; - Op(Expression ppfes, Expression ppTh, const E_Array &aatef, int nbp, Expression *pr, - KN< int > &ttedim) - : eppTh(ppTh), eppfes(ppfes), atef(aatef), nbcperiodic(nbp), periodic(pr), tedim(ttedim) {} + Op(Expression ppfes, Expression ppTh, const E_Array &aatef, int nbp, Expression *pr, KN< int > &ttedim) : eppTh(ppTh), eppfes(ppfes), atef(aatef), nbcperiodic(nbp), periodic(pr), tedim(ttedim) {} ~Op( ) { if (periodic) delete[] periodic; } AnyType operator( )(Stack s) const { - aType pt_tfe = atype0< TypeOfFE ** >( );// - aType t_tfe = atype< TypeOfFE * >( );// - aType t_tfe2 = atype< TypeOfFE2 * >( ); + aType pt_tfe = atype0< TypeOfFE ** >( ); // + aType t_tfe = atype< TypeOfFE * >( ); // + aType t_tfe2 = atype< TypeOfFE2 * >( ); const int d = Mesh::Rd::d; const int dHat = Mesh::RdHat::d; - const int dHatfe = TypeOfFE::RdHat::d; - const int dfe = TypeOfFE::RdHat::d; - + const int dHatfe = TypeOfFE::RdHat::d; + const int dfe = TypeOfFE::RdHat::d; const Mesh **ppTh = GetAny< const Mesh ** >((*eppTh)(s)); AnyType r = (*eppfes)(s); const TypeOfFE **tef = new const TypeOfFE *[atef.size( )]; - for (int i = 0; i < atef.size( ); i++) - { - // verif type atef[i] coorection mars 2022 .. - aType ttfe =atef[i].left(); - ffassert( ttfe == t_tfe ||ttfe == t_tfe2 || ttfe == pt_tfe ) ; - if(verbosity>9) cout << "OpMake_pfes_np :: " << i << " " << (tedim[i] == dHat && d==dfe) << " " << tedim[i] - << dHat << d << dfe - << " " << typeid(TypeOfFE).name() << endl; - - if (ttfe == t_tfe) // good type no converstion + for (int i = 0; i < atef.size( ); i++) { + // verif type atef[i] coorection mars 2022 .. + aType ttfe = atef[i].left( ); + ffassert(ttfe == t_tfe || ttfe == t_tfe2 || ttfe == pt_tfe); + if (verbosity > 9) cout << "OpMake_pfes_np :: " << i << " " << (tedim[i] == dHat && d == dfe) << " " << tedim[i] << dHat << d << dfe << " " << typeid(TypeOfFE).name( ) << endl; + + if (ttfe == t_tfe) // good type no converstion tef[i] = GetAny< TypeOfFE * >(atef[i].eval(s)); - else if (ttfe == pt_tfe) // good type no converstion - tef[i] = *GetAny< TypeOfFE ** >(atef[i].eval(s)); - else if (tedim[i] == 2 && d==3 && dHat == 3) + else if (ttfe == pt_tfe) // good type no converstion + tef[i] = *GetAny< TypeOfFE ** >(atef[i].eval(s)); + else if (tedim[i] == 2 && d == 3 && dHat == 3) tef[i] = GetAny< TypeOfFE * >(TypeOfFE3to2(s, atef[i].eval(s))); - else if (tedim[i] == 2 && d==3 && dHat == 2) + else if (tedim[i] == 2 && d == 3 && dHat == 2) tef[i] = GetAny< TypeOfFE * >(TypeOfFESto2(s, atef[i].eval(s))); - else if (tedim[i] == 2 && d==3 && dHat == 1) + else if (tedim[i] == 2 && d == 3 && dHat == 1) tef[i] = GetAny< TypeOfFE * >(TypeOfFELto2(s, atef[i].eval(s))); else ffassert(0); - } - + } + pfes *ppfes = GetAny< pfes * >(r); bool same = true; for (int i = 1; i < atef.size( ); i++) same &= atef[i].LeftValue( ) == atef[1].LeftValue( ); @@ -1543,15 +1479,15 @@ struct OpMake_pfes : public OneOperator, public OpMake_pfes_np { Expression nargs[n_name_param]; args.SetNameParam(n_name_param, name_param, nargs); - const int d = TypeOfFE::RdHat::d; + const int d = TypeOfFE::RdHat::d; GetPeriodic(Mesh::RdHat::d, nargs[0], nbcperiodic, periodic); aType t_tfe = atype< TypeOfFE * >( ); aType pt_tfe = atype0< TypeOfFE ** >( ); aType t_tfe2 = atype< TypeOfFE2 * >( ); - ffassert(d>0 && d < 4); - char cdim[10]; - snprintf(cdim,10,"%dd",d); - string sdim = cdim ; + ffassert(d > 0 && d < 4); + char cdim[10]; + snprintf(cdim, 10, "%dd", d); + string sdim = cdim; const E_Array *a2(dynamic_cast< const E_Array * >(args[2].LeftValue( ))); ffassert(a2); int N = a2->size( ); @@ -1559,7 +1495,7 @@ struct OpMake_pfes : public OneOperator, public OpMake_pfes_np { if (!N) CompileError(sdim + " We wait an array of Type of Element "); KN< int > tedim(N); for (int i = 0; i < N; i++) - if ((*a2)[i].left( ) == t_tfe ||(*a2)[i].left( ) == pt_tfe ) + if ((*a2)[i].left( ) == t_tfe || (*a2)[i].left( ) == pt_tfe) tedim[i] = d; else if ((*a2)[i].left( ) == t_tfe2) tedim[i] = 2; @@ -1568,9 +1504,7 @@ struct OpMake_pfes : public OneOperator, public OpMake_pfes_np { // ffassert(0); return new Op(args[0], args[1], *a2, nbcperiodic, periodic, tedim); } - OpMake_pfes( ) - : OneOperator(atype< pfes * >( ), atype< pfes * >( ), atype< const Mesh ** >( ), - atype< E_Array >( )) {} + OpMake_pfes( ) : OneOperator(atype< pfes * >( ), atype< pfes * >( ), atype< const Mesh ** >( ), atype< E_Array >( )) {} }; struct OpMake_pvectgenericfes : public OneOperator { @@ -1579,33 +1513,30 @@ struct OpMake_pvectgenericfes : public OneOperator { Expression eppfes; const E_FEarray &atef; int nb; - - Op(Expression ppfes, const E_FEarray &aatef) - : eppfes(ppfes), atef(aatef) {} - ~Op(){ } + + Op(Expression ppfes, const E_FEarray &aatef) : eppfes(ppfes), atef(aatef) {} + ~Op( ) {} AnyType operator( )(Stack s) const { - + AnyType r = (*eppfes)(s); pvectgenericfes *ppfes = GetAny< pvectgenericfes * >(r); - *ppfes = new vect_generic_v_fes(atef,s); + *ppfes = new vect_generic_v_fes(atef, s); return r; } }; E_F0 *code(const basicAC_F0 &args) const { - + const E_FEarray *a2(dynamic_cast< const E_FEarray * >(args[1].LeftValue( ))); ffassert(a2); // int N = a2->size( ); // cout << "N=" << N << endl; - return new Op(args[0], *a2 ); + return new Op(args[0], *a2); } - OpMake_pvectgenericfes( ) - : OneOperator( atype< pvectgenericfes * >( ), atype< pvectgenericfes * >( ), atype< E_FEarray >( ) ) {} + OpMake_pvectgenericfes( ) : OneOperator(atype< pvectgenericfes * >( ), atype< pvectgenericfes * >( ), atype< E_FEarray >( )) {} }; - inline pfes *MakePtr2(pfes *const &p, pmesh *const &a, TypeOfFE *const &tef) { *p = new pfes_tef(a, tef); return p; @@ -1654,9 +1585,7 @@ class OP_MakePtr2 { typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); } }; class OP_MakePtr3 { @@ -1686,9 +1615,7 @@ class OP_MakePtr3 { typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); } }; class OP_MakePtrS { @@ -1719,9 +1646,7 @@ class OP_MakePtrS { typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); } }; class OP_MakePtrL { @@ -1752,15 +1677,13 @@ class OP_MakePtrL { typedef Op::R Result; static E_F0 *f(const basicAC_F0 &args) { return new Op(args); } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Op::A >( ), atype< Op::B >( ), atype< Op::C >( ), false); } }; void GetPeriodic(const int d, Expression perio, int &nbcperiodic, Expression *&periodic) { - ffassert(d==1 || d == 2 || d == 3); + ffassert(d == 1 || d == 2 || d == 3); if (perio) { - if (verbosity > 1) cout << " -- Periodical Condition to do d==" << d << endl; + if (verbosity > 1) cout << " -- Periodical Condition to do d==" << d << endl; const E_Array *a = dynamic_cast< const E_Array * >(perio); ffassert(a); int n = a->size( ); @@ -1768,52 +1691,43 @@ void GetPeriodic(const int d, Expression perio, int &nbcperiodic, Expression *&p if (verbosity > 1) cout << " the number of periodicBC " << n << endl; if (2 * nbcperiodic != n) CompileError(" Sorry the number of periodicBC must by even"); periodic = new Expression[n * d]; - - for (int i = 0, j = 0; i < n; i++, j += d) - { - if(verbosity>9) cout<< " GetPeriodic"< 9) cout << " GetPeriodic" << d << " " << i << ": " << j << endl; if (d == 1) { - if (GetPeriodic((*a)[i], periodic[j]) == 0) - CompileError(" a sub array of periodic BC must be [label ]"); - } - else if (d == 2) { - if (GetPeriodic((*a)[i], periodic[j], periodic[j + 1]) == 0) - CompileError(" a sub array of periodic BC must be [label, realfunction ]"); + if (GetPeriodic((*a)[i], periodic[j]) == 0) CompileError(" a sub array of periodic BC must be [label ]"); + } else if (d == 2) { + if (GetPeriodic((*a)[i], periodic[j], periodic[j + 1]) == 0) CompileError(" a sub array of periodic BC must be [label, realfunction ]"); } else if (d == 3) { - if (GetPeriodic((*a)[i], periodic[j], periodic[j + 1], periodic[j + 2]) == 0) - CompileError(" a sub array of periodic BC must be [label, realfunction , realfunction]"); + if (GetPeriodic((*a)[i], periodic[j], periodic[j + 1], periodic[j + 2]) == 0) CompileError(" a sub array of periodic BC must be [label, realfunction , realfunction]"); } else ffassert(0); - } + } } } -OP_MakePtr2::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { +OP_MakePtr2::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { nbcperiodic = 0; periodic = 0; args.SetNameParam(n_name_param, name_param, nargs); GetPeriodic(2, nargs[0], nbcperiodic, periodic); } // 3D volume -OP_MakePtr3::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { +OP_MakePtr3::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { nbcperiodic = 0; periodic = 0; args.SetNameParam(n_name_param, name_param, nargs); GetPeriodic(3, nargs[0], nbcperiodic, periodic); } // 3D surface -OP_MakePtrS::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { +OP_MakePtrS::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { nbcperiodic = 0; periodic = 0; args.SetNameParam(n_name_param, name_param, nargs); GetPeriodic(2, nargs[0], nbcperiodic, periodic); } // 3D curve -OP_MakePtrL::Op::Op(const basicAC_F0 &args) - : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { +OP_MakePtrL::Op::Op(const basicAC_F0 &args) : a(to< A >(args[0])), b(to< B >(args[1])), c(to< C >(args[2])) { nbcperiodic = 0; periodic = 0; args.SetNameParam(n_name_param, name_param, nargs); @@ -1937,23 +1851,25 @@ long pmesh_nv(pmesh *p) { } double pmesh_hmax(pmesh *p) { - if(p && *p) { + if (p && *p) { double hmax2 = 0; const Mesh &Th = **p; for (int k = 0; k < Th.nt; ++k) for (int e = 0; e < 3; ++e) hmax2 = max(hmax2, Th[k].lenEdge2(e)); return sqrt(hmax2); - } else return 0.0; + } else + return 0.0; } double pmesh_hmin(pmesh *p) { - if(p && *p) { + if (p && *p) { double hmin2 = 1e100; const Mesh &Th = **p; for (int k = 0; k < Th.nt; ++k) for (int e = 0; e < 3; ++e) hmin2 = min(hmin2, Th[k].lenEdge2(e)); return sqrt(hmin2); - } else return 0.0; + } else + return 0.0; } long pVh_ndof(pfes *p) { @@ -1978,20 +1894,20 @@ long pVh_ndofK(pfes *p) { return (*fes)[0].NbDoF( ); } -long pVhcomp_ndof(vect_generic_v_fes ** pp) { +long pVhcomp_ndof(vect_generic_v_fes **pp) { throwassert(pp && *pp); - vect_generic_v_fes & p = **pp; + vect_generic_v_fes &p = **pp; long ndof = 0; - for(int i=0; igetpVh())->NbOfDF; + ndof += ((FESpace *)p.vect[i]->getpVh( ))->NbOfDF; else if (tt == 3) - ndof += ((FESpace3 *) p.vect[i]->getpVh())->NbOfDF; + ndof += ((FESpace3 *)p.vect[i]->getpVh( ))->NbOfDF; else if (tt == 4) - ndof += ((FESpaceS *) p.vect[i]->getpVh())->NbOfDF; + ndof += ((FESpaceS *)p.vect[i]->getpVh( ))->NbOfDF; else if (tt == 5) - ndof += ((FESpaceL *) p.vect[i]->getpVh())->NbOfDF; + ndof += ((FESpaceL *)p.vect[i]->getpVh( ))->NbOfDF; else { cerr << "error in the Type of FESpace" << endl; ffassert(0); @@ -2107,8 +2023,7 @@ AnyType set_fe(Stack s, Expression ppfe, Expression e) { tabexp[0] = e; if (Vh.N != 1) { - cerr << " Try to set a vectorial FE function (nb componant=" << Vh.N << ") with one scalar " - << endl; + cerr << " Try to set a vectorial FE function (nb componant=" << Vh.N << ") with one scalar " << endl; ExecError(" Error interploation (set) FE function (vectorial) with a scalar"); } KN< R > *y = new KN< R >(Vh.NbOfDF); @@ -2166,9 +2081,7 @@ AnyType set_fe(Stack s, Expression ppfe, Expression e) { kkff = Mesh::kfind - kkff; kkth = Mesh::kthrough - kkth; - if (verbosity > 1) - ShowBound(*y, cout) << " " << kkth << "/" << kkff << " = " - << double(kkth) / Max< double >(1., kkff) << endl; + if (verbosity > 1) ShowBound(*y, cout) << " " << kkth << "/" << kkff << " = " << double(kkth) / Max< double >(1., kkff) << endl; return SetAny< FEbase< R, v_fes > * >(&fe); } AnyType set_feoX_1(Stack s, Expression ppfeX_1, Expression e) { // inutile @@ -2203,15 +2116,12 @@ AnyType set_feoX_1(Stack s, Expression ppfeX_1, Expression e) { // inutile } *MeshPointStack(s) = mp; fe = y; - if (verbosity > 1) - cout << " -- interpole f= g*X^-1, function's bound: " << y->min( ) << " " << y->max( ) - << endl; + if (verbosity > 1) cout << " -- interpole f= g*X^-1, function's bound: " << y->min( ) << " " << y->max( ) << endl; return SetAny< FEbase< R, v_fes > * >(&fe); } template< class K > -E_set_fev< K >::E_set_fev(const E_Array *a, Expression pp, int ddim) - : dim(ddim), aa(*a), ppfe(pp), optimize(true), where_in_stack_opt( ), optiexp0( ), optiexpK( ) { +E_set_fev< K >::E_set_fev(const E_Array *a, Expression pp, int ddim) : dim(ddim), aa(*a), ppfe(pp), optimize(true), where_in_stack_opt( ), optiexp0( ), optiexpK( ) { aa.map(to< K >); bool kdump = false; if (optimize) { // new code Optimized ------- @@ -2222,8 +2132,7 @@ E_set_fev< K >::E_set_fev(const E_Array *a, Expression pp, int ddim) size_t top = currentblock->OffSet(0), topbb = top; // FH. bofbof ??? for (int i = 0; i < n; i++) { Expression ee = aa[i].LeftValue( ); - if (kdump) - cout << "Optimize OneOperatorMakePtrFE: type exp: " << typeid(*ee).name( ) << " " << endl; + if (kdump) cout << "Optimize OneOperatorMakePtrFE: type exp: " << typeid(*ee).name( ) << " " << endl; where_in_stack_opt[i] = ee->Optimize(ll, m, top); if (kdump) cout << "\n\t\t" << i << ": " << where_in_stack_opt[i] << endl; } @@ -2390,8 +2299,7 @@ inline FEbase< K, v_fes > **MakePtrFE2(FEbase< K, v_fes > **const &p, pfes *cons } template< class K > -inline FEbaseArray< K, v_fes > **MakePtrFE3(FEbaseArray< K, v_fes > **const &p, pfes *const &a, - const long &N) { +inline FEbaseArray< K, v_fes > **MakePtrFE3(FEbaseArray< K, v_fes > **const &p, pfes *const &a, const long &N) { *p = new FEbaseArray< K, v_fes >(a, N); return p; } @@ -2412,8 +2320,7 @@ class OneOperatorMakePtrFE : public OneOperator { else v = dynamic_cast< const E_Array * >(args[2].LeftValue( )); if (!v) { - cout << "Error: type of arg :" << *args[2].left( ) << " in " << typeid(K).name( ) - << " case " << endl; + cout << "Error: type of arg :" << *args[2].left( ) << " in " << typeid(K).name( ) << " case " << endl; ErrorCompile(" We wait a double/complex expression or a array expression", 1); } e_set_fev = new E_set_fev< K >(v, fer, v_fes::dHat); @@ -2424,7 +2331,7 @@ class OneOperatorMakePtrFE : public OneOperator { R p = GetAny< R >((*fer)(stack)); B a = GetAny< B >((*fes)(stack)); *p = new FEbase< K, v_fes >(a); - (*e_set_fev)(stack); // Morice: recuperation et initialisation de la valeur de la << FEbase >>. + (*e_set_fev)(stack); // Morice: recuperation et initialisation de la valeur de la << FEbase >>. return SetAny< R >(p); } operator aType( ) const { return atype< R >( ); } @@ -2433,8 +2340,7 @@ class OneOperatorMakePtrFE : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new CODE(args); } OneOperatorMakePtrFE(aType tt) : // tt= aType() or aType() - OneOperator(map_type[typeid(R).name( )], map_type[typeid(R).name( )], - map_type[typeid(B).name( )], tt) {} + OneOperator(map_type[typeid(R).name( )], map_type[typeid(R).name( )], map_type[typeid(B).name( )], tt) {} }; template< class Result, class A > @@ -2443,9 +2349,7 @@ class OneOperator_Ptr_o_R : public OneOperator { ptr p; public: - E_F0 *code(const basicAC_F0 &args) const { - return new E_F_A_Ptr_o_R< Result, A >(t[0]->CastTo(args[0]), p); - } + E_F0 *code(const basicAC_F0 &args) const { return new E_F_A_Ptr_o_R< Result, A >(t[0]->CastTo(args[0]), p); } OneOperator_Ptr_o_R(ptr pp) : OneOperator(atype< Result * >( ), atype< A * >( )), p(pp) {} }; @@ -2507,8 +2411,7 @@ class Convect : public E_F0mps { dt = CastTo< double >(args[1]); ff = CastTo< double >(args[2]); // save previous state - if (!((ou && u->compare(ou) == 0) && (v->compare(ov) == 0) && - ((w == 0) || (w->compare(ov) == 0)) && (dt->compare(odt) == 0))) { + if (!((ou && u->compare(ou) == 0) && (v->compare(ov) == 0) && ((w == 0) || (w->compare(ov) == 0)) && (dt->compare(odt) == 0))) { count++; } state = count; // use of optim of convect @@ -2519,9 +2422,7 @@ class Convect : public E_F0mps { odt = dt; } - static ArrayOfaType typeargs( ) { - return ArrayOfaType(atype< E_Array >( ), atype< double >( ), atype< double >( )); - } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< E_Array >( ), atype< double >( ), atype< double >( )); } static E_F0 *f(const basicAC_F0 &args) { return new Convect(args); } AnyType operator( )(Stack s) const; @@ -2570,7 +2471,7 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { const void *cv[4]; // for }; pmesh th( ) { - // assert(v[0] && what == 0); + // assert(v[0] && what == 0); return static_cast< pmesh >(cv[0]); } pmesh3 th3( ) { @@ -2608,9 +2509,7 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { ListWhat(int w = -1, int ii = -1) : what(w), i(ii) { Set( ); } ListWhat(int what, int ii, int n, void **f0, int *c) : what(what), i(ii) { Set(n, f0, c); } - ListWhat(int what, int ii, int n, const void **f0, int *c) : what(what), i(ii) { - Set(n, f0, c); - } + ListWhat(int what, int ii, int n, const void **f0, int *c) : what(what), i(ii) { Set(n, f0, c); } ListWhat(int what, int ii, void *f0) : what(what), i(ii) { Set(1, &f0, 0); } ListWhat(int what, int ii, const void *f0) : what(what), i(ii) { Set(1, &f0, 0); } @@ -2828,32 +2727,32 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { return 0; } solS evalS(int i, Stack s, int &cmp) const { - cmp = -1; - if (e[i]) { - if (!composant) { - pfSr p = GetAny< pfSr >((*e[i])(s)); - cmp = p.second; - return p.first; - } else { - return GetAny< pfSrbase >((*e[i])(s)); - } - } else - return 0; + cmp = -1; + if (e[i]) { + if (!composant) { + pfSr p = GetAny< pfSr >((*e[i])(s)); + cmp = p.second; + return p.first; + } else { + return GetAny< pfSrbase >((*e[i])(s)); + } + } else + return 0; } solL evalL(int i, Stack s, int &cmp) const { - cmp = -1; - if (e[i]) { - if (!composant) { - pfLr p = GetAny< pfLr >((*e[i])(s)); - cmp = p.second; - return p.first; - } else { - return GetAny< pfLrbase >((*e[i])(s)); - } - } else - return 0; + cmp = -1; + if (e[i]) { + if (!composant) { + pfLr p = GetAny< pfLr >((*e[i])(s)); + cmp = p.second; + return p.first; + } else { + return GetAny< pfLrbase >((*e[i])(s)); + } + } else + return 0; } - + // add FH Japon 2010 .. for complex visu ... to complex .... try to uniformize ... solc evalc(int i, Stack s, int &cmp) const { cmp = -1; @@ -2937,11 +2836,11 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { asolL evalaL(int i, Stack s, int &cmp) const { cmp = -1; if (e[i]) { - pfLrarray p = GetAny< pfLrarray >((*e[i])(s)); - cmp = p.second; - return p.first; - } else - return 0; + pfLrarray p = GetAny< pfLrarray >((*e[i])(s)); + cmp = p.second; + return p.first; + } else + return 0; } asolc evalca(int i, Stack s, int &cmp) const { cmp = -1; @@ -2971,14 +2870,14 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { return 0; } asolcL evalcaL(int i, Stack s, int &cmp) const { - cmp = -1; - if (e[i]) { - pfLcarray p = GetAny< pfLcarray >((*e[i])(s)); - cmp = p.second; - return p.first; - } else - return 0; - } + cmp = -1; + if (e[i]) { + pfLcarray p = GetAny< pfLcarray >((*e[i])(s)); + cmp = p.second; + return p.first; + } else + return 0; + } const Mesh &evalm(int i, Stack s) const { throwassert(e[i]); return *GetAny< pmesh >((*e[i])(s)); @@ -3019,7 +2918,7 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { /// <> FFCS: added new parameters for VTK graphics. /// See /// [[Plot_name_param]] for new parameter names - static const int n_name_param = 46; // modified by fujiwara + static const int n_name_param = 46; // modified by fujiwara Expression bb[4]; @@ -3064,8 +2963,7 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { { l[i].what = 3; for (int j = 0; j < a->size( ); j++) l[i][j] = CastTo< tab >((*a)[j]); - } else if (bpttab && asizea >= 2 && - asizea <= 4) // change nov 2016 FH for arry of curve + } else if (bpttab && asizea >= 2 && asizea <= 4) // change nov 2016 FH for arry of curve { l[i].what = 103; for (int j = 0; j < a->size( ); j++) l[i][j] = CastTo< pttab >((*a)[j]); @@ -3108,9 +3006,8 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { } else { CompileError("plot of array with wrong number of components (!= 2 or 3) "); } - } else if (BCastTo< pferbase >( - args[i])) { // [[file:problem.hpp::pferbase]] [[file:lgmesh3.hpp::BCastTo]] - l[i].what = 1; // iso value 2d + } else if (BCastTo< pferbase >(args[i])) { // [[file:problem.hpp::pferbase]] [[file:lgmesh3.hpp::BCastTo]] + l[i].what = 1; // iso value 2d l[i].composant = true; l[i][0] = CastTo< pferbase >(args[i]); } else if (BCastTo< pfer >(args[i])) { // [[file:problem.hpp::pfer]] @@ -3227,11 +3124,9 @@ class Plot : public E_F0mps /* [[file:AFunction.hpp::E_F0mps]] */ { l[i].composant = true; l[i].what = 155; // mesh 3d curve array l[i][0] = CastTo< KN< pmeshL > * >(args[i]); - } - else { + } else { CompileError("Sorry no way to plot this kind of data"); } - } static ArrayOfaType typeargs( ) { return ArrayOfaType(true); } // all type @@ -3299,10 +3194,10 @@ basicAC_F0::name_and_type Plot::name_param[Plot::n_name_param] = { {"WindowIndex", &typeid(long)}, // #20 {"NbColorTicks", &typeid(long)}, // #21 {"NbColors", &typeid(long)}, // #22 -// after FFCS !!!! - {"pNormalT", &typeid(bool)} , //43 - {"pdf", &typeid(string*)}, // 44, add by fujiwara modif FH 09/01/23 - {"svg", &typeid(string*)} // 45, add by fujiwara + // after FFCS !!!! + {"pNormalT", &typeid(bool)}, // 43 + {"pdf", &typeid(string *)}, // 44, add by fujiwara modif FH 09/01/23 + {"svg", &typeid(string *)} // 45, add by fujiwara }; @@ -3311,15 +3206,13 @@ class pb2mat : public E_F0 { public: typedef Matrice_Creuse< K > *Result; const Problem *pb; - pb2mat(const basicAC_F0 &args) : pb(dynamic_cast< const Problem * >(args[0].left( ))) { - ffassert(pb); - } + pb2mat(const basicAC_F0 &args) : pb(dynamic_cast< const Problem * >(args[0].left( ))) { ffassert(pb); } static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const Problem * >( )); } static E_F0 *f(const basicAC_F0 &args) { return new Plot(args); } AnyType operator( )(Stack s) const { - Problem::Data< FESpace > *data = pb->dataptr(s);// coorect 9/11/24 Build breaks with clang-19 + Problem::Data< FESpace > *data = pb->dataptr(s); // coorect 9/11/24 Build breaks with clang-19 if (SameType< K, double >::OK) { ffassert(!!data->AR); return SetAny< Matrice_Creuse< K > * >(&data->AR); @@ -3366,7 +3259,7 @@ LinkToInterpreter::LinkToInterpreter( ) { Global.New("P", P); Global.New("N", N); Global.New("Nt", Nt); - Global.New("Ns", Ns);// add FH + Global.New("Ns", Ns); // add FH Global.New("Tl", Tl); Global.New("lenEdge", lenEdge); Global.New("area", area); @@ -3375,25 +3268,19 @@ LinkToInterpreter::LinkToInterpreter( ) { Global.New("inside", inside); Global.New("nTonEdge", make_Type_Expr(atype< long >( ), new E_P_Stack_nElementonB)); Global.New("nElementonB", make_Type_Expr(atype< long >( ), new E_P_Stack_nElementonB)); - Global.New("edgeOrientation", - make_Type_Expr(atype< R >( ), new E_P_Stack_EdgeOrient)); // Add FH jan 2018 - Global.New("BoundaryEdge", - make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 1 >)); // Add FH jan 2018 - Global.New("InternalEdge", - make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 2 >)); // Add FH jan 2018 - Global.New("BoundaryBE", - make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 1 >)); // Add FH jan 2018 - Global.New("InternalBE", - make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 2 >)); // Add FH jan 2018 - Global.New("uniqueBE", - make_Type_Expr(atype< double >( ), new E_P_Stack_uniqueBE)); // Add FH juin 2012 + Global.New("edgeOrientation", make_Type_Expr(atype< R >( ), new E_P_Stack_EdgeOrient)); // Add FH jan 2018 + Global.New("BoundaryEdge", make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 1 >)); // Add FH jan 2018 + Global.New("InternalEdge", make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 2 >)); // Add FH jan 2018 + Global.New("BoundaryBE", make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 1 >)); // Add FH jan 2018 + Global.New("InternalBE", make_Type_Expr(atype< long >( ), new E_P_Stack_TypeBE< 2 >)); // Add FH jan 2018 + Global.New("uniqueBE", make_Type_Expr(atype< double >( ), new E_P_Stack_uniqueBE)); // Add FH juin 2012 } template< class K > struct set_eqmatrice_creuse_fbl { - using first_argument_type = Matrice_Creuse< K > *; - using second_argument_type = const Matrice_Creuse< K > *; - using result_type = const C_args *; + using first_argument_type = Matrice_Creuse< K > *; + using second_argument_type = const Matrice_Creuse< K > *; + using result_type = const C_args *; static Matrice_Creuse< K > *f(Matrice_Creuse< K > *const &a, const C_args *const &b) { // 1 verif the FESpace @@ -3406,9 +3293,9 @@ struct set_eqmatrice_creuse_fbl { template< class K > struct set_eqvect_fl { - using first_argument_type = KN< K > *; - using second_argument_type = const FormLinear *; - using result_type = KN< K > *; + using first_argument_type = KN< K > *; + using second_argument_type = const FormLinear *; + using result_type = KN< K > *; static KN< K > *f(KN< K > *const &a, const FormLinear *const &b) { ffassert(0); return a; @@ -3425,8 +3312,8 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { SHOWVERB(cout << " int " << endl); const vector< Expression > &what(di->what); const int dim = di->d; - const bool surface = di->dHat==2 && di->d==3; - const bool curve = di->dHat==1 && di->d==3; + const bool surface = di->dHat == 2 && di->d == 3; + const bool curve = di->dHat == 1 && di->d == 3; const GQuadratureFormular< R1 > &FIE = di->FIE(stack); const GQuadratureFormular< R2 > &FIT = di->FIT(stack); const GQuadratureFormular< R3 > &FIV = di->FIV(stack); @@ -3440,8 +3327,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { if (verbosity > 3) { if (dim == 2) { if (CDomainOfIntegration::int1d == kind) - cout << " -- boundary int border ( nQP: " << FIE.n << ") levelset: " << di->islevelset( ) - << " ,"; + cout << " -- boundary int border ( nQP: " << FIE.n << ") levelset: " << di->islevelset( ) << " ,"; else if (CDomainOfIntegration::intalledges == kind) cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; else if (CDomainOfIntegration::intallVFedges == kind) @@ -3459,8 +3345,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { cout << " -- int 3d volume (nQP: " << FIV.n << " ) in "; } else if (dim == 3 && surface && !curve) { if (CDomainOfIntegration::int1d == kind) - cout << " -- boundary int border ( nQP: " << FIE.n << ") levelset: " << di->islevelset( ) - << " ,"; + cout << " -- boundary int border ( nQP: " << FIE.n << ") levelset: " << di->islevelset( ) << " ,"; else if (CDomainOfIntegration::intalledges == kind) cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; else if (CDomainOfIntegration::intallVFedges == kind) @@ -3468,18 +3353,17 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { else cout << " -- int 3d surface (nQP: " << FIT.n << " ) in "; } else if (dim == 3 && !surface && curve) { - if (CDomainOfIntegration::int0d==kind) - cout << " -- boundary int border ( nQP: "<< FIE.n << ") levelset: "<< di->islevelset() << " ," ; - else cout << " -- int 3d curve (nQP: " << FIT.n << " ) in "; + if (CDomainOfIntegration::int0d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") levelset: " << di->islevelset( ) << " ,"; + else + cout << " -- int 3d curve (nQP: " << FIT.n << " ) in "; } } Expandsetoflab(stack, *di, setoflab, all); if (dim == 2) { - if (di->islevelset( ) && (CDomainOfIntegration::int1d != kind) && - (CDomainOfIntegration::int2d != kind)) - InternalError("So no levelset integration type case (10 2d)"); + if (di->islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("So no levelset integration type case (10 2d)"); const Mesh &Th = *GetAny< pmesh >((*di->Th)(stack)); ffassert(&Th); @@ -3542,16 +3426,14 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { const Triangle &K(Th[i]); R2 E = K.Edge(ie); double le = sqrt((E, E)); - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); for (int npi = 0; npi < FI.n; npi++) // loop on the integration point { QuadratureFormular1dPoint pi(FI[npi]); double sa = pi.x, sb = 1. - sa; R2 Pt(PA * sa + PB * sb); // - MeshPointStack(stack)->set(Th, K(Pt), Pt, K, Th.bedges[e].lab, R2(E.y, -E.x) / le, - ie); + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, Th.bedges[e].lab, R2(E.y, -E.x) / le, ie); r += le * pi.a * GetAny< R >((*fonc)(stack)); } } @@ -3638,8 +3520,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { int lab = be ? be->lab : notaregion; R2 E = K.Edge(ie); double le = sqrt((E, E)); - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); for (int npi = 0; npi < FI.n; npi++) // loop on the integration point { @@ -3689,9 +3570,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { // volume 3d else if (dim == 3 && !surface && !curve) { - if (di->islevelset( ) && (CDomainOfIntegration::int2d != kind) && - (CDomainOfIntegration::int3d != kind)) - InternalError("So no levelset integration type on no int2d / int3d case (10 3d)"); + if (di->islevelset( ) && (CDomainOfIntegration::int2d != kind) && (CDomainOfIntegration::int3d != kind)) InternalError("So no levelset integration type on no int2d / int3d case (10 3d)"); const Mesh3 &Th = *GetAny< pmesh3 >((*di->Th)(stack)); ffassert(&Th); @@ -3713,8 +3592,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { double f[4]; for (int t = 0; t < Th.nt; ++t) { - double umx = std::numeric_limits< double >::lowest( ), - umn = std::numeric_limits< double >::max( ); + double umx = std::numeric_limits< double >::lowest( ), umn = std::numeric_limits< double >::max( ); for (int i = 0; i < 4; ++i) { int j = Th(t, i); if (phi[j] == uset) { @@ -3730,9 +3608,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { double l[3]; if (np > 2) { - if (verbosity > 999) - cout << t << " int levelset : " << umn << " .. " << umx << " np " << np << " " - << f[0] << " " << f[1] << " " << f[2] << " " << f[3] << " " << endl; + if (verbosity > 999) cout << t << " int levelset : " << umn << " .. " << umx << " np " << np << " " << f[0] << " " << f[1] << " " << f[2] << " " << f[3] << " " << endl; const Mesh3::Element &K(Th[t]); double epsmes3 = K.mesure( ) * K.mesure( ) * 1e-18; @@ -3802,8 +3678,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { for (int t = 0; t < Th.nt; t++) { const Mesh3::Element &K(Th[t]); if (all || setoflab.find(K.lab) != setoflab.end( )) { - double umx = std::numeric_limits< double >::lowest( ), - umn = std::numeric_limits< double >::max( ); + double umx = std::numeric_limits< double >::lowest( ), umn = std::numeric_limits< double >::max( ); for (int i = 0; i < 4; ++i) { int j = Th(t, i); if (phi[j] == uset) { @@ -3848,7 +3723,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { double mes = NN.norme( ); NN /= mes; mes *= 0.5; - + // correction 05/01/09 FH for (int npi = 0; npi < FI.n; npi++) // loop on the integration point { @@ -3864,9 +3739,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { } else if (dim == 3 && surface && !curve) { - if (di->islevelset( ) && (CDomainOfIntegration::int1d != kind) && - (CDomainOfIntegration::int2d != kind)) - InternalError("So no levelset integration type case (10 3d)"); + if (di->islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("So no levelset integration type case (10 3d)"); const MeshS &Th = *GetAny< pmeshS >((*di->Th)(stack)); ffassert(&Th); @@ -3897,56 +3770,56 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { umx = std::max(umx, phi[j]); umn = std::min(umn, phi[j]); } - if (umn <= 0 && umx >= 0) { - int np = IsoLineK(f, Q, 1e-10); - if (np == 2) { - const TriangleS &K(Th[t]); - R3 Ns=K.NormalTUnitaire(); - R3 PA(K(Q[0])), PB(K(Q[1])); - R3 NAB(PA, PB); - double lAB = sqrt((NAB, NAB)); - NAB = Ns^NAB / lAB; - llevelset += lAB; - for (int npi = 0; npi < FI.n; npi++) // loop on the integration point - { - QuadratureFormular1dPoint pi(FI[npi]); - double sa = pi.x, sb = 1. - sa; - R2 Pt(Q[0] * sa + Q[1] * sb); // - MeshPointStack(stack)->set(Th, K(Pt), Pt, K, -1, NAB,Ns, -1); - r += lAB * pi.a * GetAny< R >((*fonc)(stack)); - } - } - } - -/* - - if (umn <= 0 && umx >= 0) { int np = IsoLineK(f, Q, 1e-10); if (np == 2) { const TriangleS &K(Th[t]); - double epsmes3 = K.mesure( ) * K.mesure( ) * 1e-18; - R3 PA(K(Q[0])), PB(K(Q[1])), PC(K(Q[2])); - R3 NN = R3(PB, PA) ^ R3(PC, PA); // R3 NAB(PA,PB); - - double mes2 = (NN, NN); - double mes = sqrt(mes2); - - if (mes2 * mes < epsmes3) continue; // too small - NN /= mes; - llevelset += mes; - R3 NNt=K.NormalTUnitaire(); + R3 Ns = K.NormalTUnitaire( ); + R3 PA(K(Q[0])), PB(K(Q[1])); + R3 NAB(PA, PB); + double lAB = sqrt((NAB, NAB)); + NAB = Ns ^ NAB / lAB; + llevelset += lAB; for (int npi = 0; npi < FI.n; npi++) // loop on the integration point { QuadratureFormular1dPoint pi(FI[npi]); double sa = pi.x, sb = 1. - sa; R2 Pt(Q[0] * sa + Q[1] * sb); // - MeshPointStack(stack)->set(Th, K(Pt), Pt, K, -1, NN, NNt, -1); - r += mes * pi.a * GetAny< R >((*fonc)(stack)); + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, -1, NAB, Ns, -1); + r += lAB * pi.a * GetAny< R >((*fonc)(stack)); } } - }*/ - + } + + /* + + + if (umn <= 0 && umx >= 0) { + int np = IsoLineK(f, Q, 1e-10); + if (np == 2) { + const TriangleS &K(Th[t]); + double epsmes3 = K.mesure( ) * K.mesure( ) * 1e-18; + R3 PA(K(Q[0])), PB(K(Q[1])), PC(K(Q[2])); + R3 NN = R3(PB, PA) ^ R3(PC, PA); // R3 NAB(PA,PB); + + double mes2 = (NN, NN); + double mes = sqrt(mes2); + + if (mes2 * mes < epsmes3) continue; // too small + NN /= mes; + llevelset += mes; + R3 NNt=K.NormalTUnitaire(); + for (int npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + double sa = pi.x, sb = 1. - sa; + R2 Pt(Q[0] * sa + Q[1] * sb); // + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, -1, NN, NNt, -1); + r += mes * pi.a * GetAny< R >((*fonc)(stack)); + } + } + }*/ + wsptr2free->clean(swsptr2free); // ADD FH 11/2017 } if (verbosity > 5) cout << " Length level set = " << llevelset << endl; @@ -3960,15 +3833,14 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { const TriangleS &K(Th[i]); R3 E = K.Edge(ie); double le = sqrt((E, E)); - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); for (int npi = 0; npi < FI.n; npi++) // loop on the integration point { QuadratureFormular1dPoint pi(FI[npi]); double sa = pi.x, sb = 1. - sa; - R2 Pt(PA * sa + PB * sb); // - MeshPointStack(stack)->set(Th, K(Pt), Pt, K, Th.be(e).lab, E , ie);// Border surface + R2 Pt(PA * sa + PB * sb); // + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, Th.be(e).lab, E, ie); // Border surface r += le * pi.a * GetAny< R >((*fonc)(stack)); } } @@ -3987,7 +3859,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { for (int t = 0; t < Th.nt; ++t) { if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { const TriangleS &K(Th[t]); - R3 NNt=K.NormalTUnitaire(); + R3 NNt = K.NormalTUnitaire( ); double umx = -HUGE_VAL, umn = HUGE_VAL; for (int i = 0; i < 3; ++i) { int j = Th(t, i); @@ -4034,7 +3906,7 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { } else for (int i = 0; i < Th.nt; i++) { const TriangleS &K(Th[i]); - R3 NNt=K.NormalTUnitaire(); + R3 NNt = K.NormalTUnitaire( ); if (all || setoflab.find(Th[i].lab) != setoflab.end( )) for (int npi = 0; npi < FI.n; npi++) { QuadraturePoint pi(FI[npi]); @@ -4067,56 +3939,49 @@ AnyType IntFunction< R >::operator( )(Stack stack) const { } else { InternalError("CDomainOfIntegration kind unknown"); } - } else if (dim == 3 && !surface && curve) - { + } else if (dim == 3 && !surface && curve) { - if(di->islevelset() && (CDomainOfIntegration::int1d!=kind) && - (CDomainOfIntegration::int0d!=kind) ) - InternalError("So no levelset integration type case (103d)"); - const MeshL & Th = * GetAny( (*di->Th)(stack) ); + if (di->islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int0d != kind)) InternalError("So no levelset integration type case (103d)"); + const MeshL &Th = *GetAny< pmeshL >((*di->Th)(stack)); ffassert(&Th); - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; } - if (kind==CDomainOfIntegration::int1d) - { - const QuadratureFormular1d & FI = FIE; - if(di->islevelset()) - { - ffassert(0); // Do do !!! - - } + if (kind == CDomainOfIntegration::int1d) { + const QuadratureFormular1d &FI = FIE; + if (di->islevelset( )) { + ffassert(0); // Do do !!! - else - for( int k=0;kset(Th,Pt,Ph,K,NNt, K.lab); - r += K.mesure()*pi.a*GetAny( (*fonc)(stack)); - } - } - wsptr2free->clean(swsptr2free);// ADD FH 11/2017 + } + + else + for (int k = 0; k < Th.nt; k++) { + const EdgeL &K(Th[k]); + R3 NNt = K.TangenteUnitaire( ); + if (all || setoflab.find(Th[k].lab) != setoflab.end( )) { + // const EdgeL & K(Th[k]); + // double le = K.mesure(); + + for (int npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + R1 Ph(pi.x); //,sb=1.-sa; + R3 Pt(K(Ph)); // + // void set(const MeshL &aTh, const R3 &P2,const R1 & P_Hat,const EdgeL & aK,const int ll=notalabel,bool coutside=false) + MeshPointStack(stack)->set(Th, Pt, Ph, K, NNt, K.lab); + r += K.mesure( ) * pi.a * GetAny< R >((*fonc)(stack)); } + } + wsptr2free->clean(swsptr2free); // ADD FH 11/2017 + } + } else { + InternalError("int Curve CDomainOfIntegration kind unknown"); } - else - { - InternalError("int Curve CDomainOfIntegration kind unknown"); - } - - + } else { InternalError("CDomainOfIntegration dim unknown"); } @@ -4135,8 +4000,7 @@ void Show(const char *s, int k = 1) { } } template< class K, class v_fes > -int Send2d(PlotStream &theplot, Plot::ListWhat &lli, - map< const typename v_fes::FESpace::Mesh *, long > &mapth) { +int Send2d(PlotStream &theplot, Plot::ListWhat &lli, map< const typename v_fes::FESpace::Mesh *, long > &mapth) { typedef FEbase< K, v_fes > *pfek; pfek fe[3] = {0, 0, 0}; int cmp[3] = {-1, -1, -1}; @@ -4160,9 +4024,7 @@ int Send2d(PlotStream &theplot, Plot::ListWhat &lli, for (int sk = 0, p = 0; sk < nsubT; ++sk) for (int i = 0; i < 3; ++i, ++p) Ksub[p] = numSubTriangle(nsb, sk, i); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) - << " min " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) << " min " << V1.min( ) << endl; theplot << Psub; theplot << Ksub; theplot << V1; @@ -4192,8 +4054,7 @@ int Send2d(PlotStream &theplot, Plot::ListWhat &lli, } template< class K, class v_fes > -int Send3d(PlotStream &theplot, Plot::ListWhat &lli, - map< const typename v_fes::FESpace::Mesh *, long > &mapth3) { +int Send3d(PlotStream &theplot, Plot::ListWhat &lli, map< const typename v_fes::FESpace::Mesh *, long > &mapth3) { typedef FEbase< K, v_fes > *pfek3; pfek3 fe3[3] = {0, 0, 0}; int cmp[3] = {-1, -1, -1}; @@ -4212,9 +4073,7 @@ int Send3d(PlotStream &theplot, Plot::ListWhat &lli, KN< R3 > Psub; KN< int > Ksub; KN< K > V1 = fe3[0]->Vh->newSaveDraw(*fe3[0]->x( ), cmp[0], lg, Psub, Ksub, 0); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( ) - << " " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( ) << " " << V1.min( ) << endl; theplot << Psub; theplot << Ksub; theplot << V1; @@ -4234,9 +4093,7 @@ int Send3d(PlotStream &theplot, Plot::ListWhat &lli, KN< K > V1 = fe3[0]->Vh->newSaveDraw(*fe3[0]->x( ), cmp[0], lg, Psub1, Ksub1, 0); KN< K > V2 = fe3[1]->Vh->newSaveDraw(*fe3[1]->x( ), cmp[1], lg, Psub2, Ksub2, 0); KN< K > V3 = fe3[2]->Vh->newSaveDraw(*fe3[2]->x( ), cmp[2], lg, Psub3, Ksub3, 0); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( ) - << " " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( ) << " " << V1.min( ) << endl; theplot << Psub1; theplot << Ksub1; ffassert(V1.N( ) == V2.N( ) && V1.N( ) == V3.N( )); @@ -4270,18 +4127,15 @@ int SendS(PlotStream &theplot, Plot::ListWhat &lli, map< const MeshS *, long > & KN< int > Ksub; KN< K > V1 = feS[0]->Vh->newSaveDraw(*feS[0]->x( ), cmp[0], lg, Psub, Ksub, 0); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) - << " min " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) << " min " << V1.min( ) << endl; theplot << Psub; theplot << Ksub; theplot << V1; - } - else if (what % 10 == 9) { + } else if (what % 10 == 9) { int lg, nsb; lli.eval(feS, cmp); // FFCS is able to display 3d complex data - + if (feS[0]->x( ) && feS[1]->x( ) && feS[2]->x( )) { err = 0; theplot << what; @@ -4291,8 +4145,7 @@ int SendS(PlotStream &theplot, Plot::ListWhat &lli, map< const MeshS *, long > & KN< K > V1 = feS[0]->Vh->newSaveDraw(*feS[0]->x( ), cmp[0], lg, Psub1, Ksub1, 0); KN< K > V2 = feS[1]->Vh->newSaveDraw(*feS[1]->x( ), cmp[1], lg, Psub2, Ksub2, 0); KN< K > V3 = feS[2]->Vh->newSaveDraw(*feS[2]->x( ), cmp[2], lg, Psub3, Ksub3, 0); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( )<< " " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " " << V1.max( ) << " " << V1.min( ) << endl; theplot << Psub1; theplot << Ksub1; ffassert(V1.N( ) == V2.N( ) && V1.N( ) == V3.N( )); @@ -4302,7 +4155,7 @@ int SendS(PlotStream &theplot, Plot::ListWhat &lli, map< const MeshS *, long > & V123(2, '.') = V3; theplot << (KN_< K > &)V123; } - } + } return err; } @@ -4316,7 +4169,7 @@ int SendL(PlotStream &theplot, Plot::ListWhat &lli, map< const MeshL *, long > & int lg, nsb = 0; lli.eval(feL, cmp); - if( what == 14 || what == 20 || what == 114 || what == 120) { + if (what == 14 || what == 20 || what == 114 || what == 120) { err = 0; theplot << what; theplot << mapthS[&(feL[0]->Vh->Th)]; // numero du maillage @@ -4324,14 +4177,12 @@ int SendL(PlotStream &theplot, Plot::ListWhat &lli, map< const MeshL *, long > & KN< int > Ksub; KN< K > V1 = feL[0]->Vh->newSaveDraw(*feL[0]->x( ), cmp[0], lg, Psub, Ksub, 0); - if (verbosity > 9) - cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) - << " min " << V1.min( ) << endl; + if (verbosity > 9) cout << " Send plot:what: " << what << " " << nsb << " " << V1.N( ) << " Max " << V1.max( ) << " min " << V1.min( ) << endl; theplot << Psub; theplot << Ksub; theplot << V1; - } else if (what == 15 || what == 21 ) { + } else if (what == 15 || what == 21) { ffassert(0); } return err; @@ -4542,19 +4393,18 @@ AnyType Plot::operator( )(Stack s) const { if (nargs[19]) (theplot << 19L) <= GetAny< bool >((*nargs[19])(s)); if (nargs[20]) (theplot << 20L) <= (echelle = GetAny< double >((*nargs[20])(s))); - // FFCS: extra plot options for VTK (indexed from 1 to keep these lines unchanged even if the - // number of standard FF parameters above changes) received in - // [[file:../ffcs/src/visudata.cpp::receiving_plot_parameters]]. When adding a parameter here, - // do _NOT_ forget to change the size of the array at - // [[number_of_distinct_named_parameters_for_plot]] and to name the new parameters at - // [[Plot_name_param]]. Also update the list of displayed values at - // [[file:../ffcs/src/plot.cpp::Plotparam_listvalues]] and read the parameter value from the - // pipe at [[file:../ffcs/src/visudata.cpp::receiving_plot_parameters]]. + // FFCS: extra plot options for VTK (indexed from 1 to keep these lines unchanged even if the + // number of standard FF parameters above changes) received in + // [[file:../ffcs/src/visudata.cpp::receiving_plot_parameters]]. When adding a parameter here, + // do _NOT_ forget to change the size of the array at + // [[number_of_distinct_named_parameters_for_plot]] and to name the new parameters at + // [[Plot_name_param]]. Also update the list of displayed values at + // [[file:../ffcs/src/plot.cpp::Plotparam_listvalues]] and read the parameter value from the + // pipe at [[file:../ffcs/src/visudata.cpp::receiving_plot_parameters]]. -#define VTK_START 20 // modified by fujiwara +#define VTK_START 20 // modified by fujiwara #define SEND_VTK_PARAM(index, type) \ - if (nargs[VTK_START + index]) \ - (theplot << (long)(VTK_START + index)) <= GetAny< type >((*nargs[VTK_START + index])(s)); + if (nargs[VTK_START + index]) (theplot << (long)(VTK_START + index)) <= GetAny< type >((*nargs[VTK_START + index])(s)); SEND_VTK_PARAM(1, double); // ZScale SEND_VTK_PARAM(2, bool); // WhiteBackground @@ -4579,7 +4429,7 @@ AnyType Plot::operator( )(Stack s) const { SEND_VTK_PARAM(21, long); // NbColorTicks SEND_VTK_PARAM(22, long); // NbColors SEND_VTK_PARAM(23, bool); // pNormalT - // pdffile and svgfile !!!! + // pdffile and svgfile !!!! if (nargs[44]) (theplot << 44L) <= GetAny< string * >((*nargs[44])(s)); if (nargs[45]) (theplot << 45L) <= GetAny< string * >((*nargs[45])(s)); @@ -4592,7 +4442,7 @@ AnyType Plot::operator( )(Stack s) const { long kth = 0, kth3 = 0, kthS = 0, kthL = 0; // send all the mesh: for (size_t ii = 0; ii < ll.size( ); ii++) { - int i= ll[ii].i; + int i = ll[ii].i; long what = ll[ii].what; const Mesh *th = 0; const Mesh3 *th3 = 0; @@ -4602,10 +4452,10 @@ AnyType Plot::operator( )(Stack s) const { if (what == 0) th = ll[ii].th( ); // Prepare for the sending mesh 3d with differenciation 3D line / surface / volumuic / // volum+surfac / line+volum+surfac - if (what == 5) th3 = ll[ii].th3( ); //&(l[i].evalm3(0, s)); + if (what == 5) th3 = ll[ii].th3( ); //&(l[i].evalm3(0, s)); // 3d mesh3 -> if contains a meshS or meshL pointer, send only the principal mesh: the mesh3 - if (what == 50) thS = ll[ii].thS( ); //(&(l[i].evalmS(0, s))); // 3d meshS - if (what == 55) thL = ll[ii].thL( );//(&(l[ii].evalmL(0, s))); // 3d meshL + if (what == 50) thS = ll[ii].thS( ); //(&(l[i].evalmS(0, s))); // 3d meshS + if (what == 55) thL = ll[ii].thL( ); //(&(l[ii].evalmL(0, s))); // 3d meshL // Prepare for the sending 2d iso values for ffglut else if (what == 1 || what == 2 || what == 11 || what == 12) { ll[ii].eval(fe, cmp); @@ -4616,9 +4466,9 @@ AnyType Plot::operator( )(Stack s) const { // Prepare for the sending 3D volume iso values for ffglut else if (what == 6 || what == 7 || what == 16 || what == 17) { ll[ii].eval(fe3, cmp); - if (fe3[0]->x( ) &&!th3) th3 = &fe3[0]->Vh->Th; - if (fe[1] && fe3[1]->x( ) &&!th3) th3 = &fe3[1]->Vh->Th; - if (fe[2] && fe3[2]->x( ) &&!th3) th3 = &fe3[1]->Vh->Th; + if (fe3[0]->x( ) && !th3) th3 = &fe3[0]->Vh->Th; + if (fe[1] && fe3[1]->x( ) && !th3) th3 = &fe3[1]->Vh->Th; + if (fe[2] && fe3[2]->x( ) && !th3) th3 = &fe3[1]->Vh->Th; if (fe3[1]) ffassert(th3 == &fe3[1]->Vh->Th); if (fe3[2]) ffassert(th3 == &fe3[2]->Vh->Th); @@ -4627,7 +4477,7 @@ AnyType Plot::operator( )(Stack s) const { else if (what == 8 || what == 9 || what == 18 || what == 19) { ll[ii].eval(feS, cmp); if (feS[0]->x( )) thS = &feS[0]->Vh->Th; - if (feS[1] && feS[1]->x( ) &&!thS) thS = &feS[1]->Vh->Th; + if (feS[1] && feS[1]->x( ) && !thS) thS = &feS[1]->Vh->Th; if (feS[1] && feS[1]->x( )) ffassert(thS == &feS[1]->Vh->Th); if (feS[2] && feS[2]->x( )) ffassert(thS == &feS[2]->Vh->Th); } @@ -4635,7 +4485,7 @@ AnyType Plot::operator( )(Stack s) const { else if (what == 14 || what == 15 || what == 20 || what == 21) { ll[ii].eval(feL, cmp); if (feL[0]->x( )) thL = &feL[0]->Vh->Th; - if (feL[1] && feL[1]->x( ) &&!thL) thL = &feL[1]->Vh->Th; + if (feL[1] && feL[1]->x( ) && !thL) thL = &feL[1]->Vh->Th; if (feL[1] && feL[1]->x( )) ffassert(thL == &feL[1]->Vh->Th); if (feL[2] && feL[2]->x( )) ffassert(thL == &feL[2]->Vh->Th); } @@ -4649,27 +4499,23 @@ AnyType Plot::operator( )(Stack s) const { theplot.SendMeshes( ); theplot << kth; - for (map< const Mesh *, long >::const_iterator i = mapth.begin( ); i != mapth.end( ); ++i) - theplot << i->second << *i->first; + for (map< const Mesh *, long >::const_iterator i = mapth.begin( ); i != mapth.end( ); ++i) theplot << i->second << *i->first; // only send of volume meshes 3D if completed mesh3 (meshS!=NULL or/and !=meshL!=NULL) if (kth3) { theplot.SendMeshes3( ); theplot << kth3; - for (map< const Mesh3 *, long >::const_iterator i = mapth3.begin( ); i != mapth3.end( ); ++i) - theplot << i->second << *i->first; + for (map< const Mesh3 *, long >::const_iterator i = mapth3.begin( ); i != mapth3.end( ); ++i) theplot << i->second << *i->first; } if (kthS) { theplot.SendMeshesS( ); theplot << kthS; - for (map< const MeshS *, long >::const_iterator i = mapthS.begin( ); i != mapthS.end( ); ++i) - theplot << i->second << *i->first; + for (map< const MeshS *, long >::const_iterator i = mapthS.begin( ); i != mapthS.end( ); ++i) theplot << i->second << *i->first; } if (kthL) { theplot.SendMeshesL( ); theplot << kthL; - for (map< const MeshL *, long >::const_iterator i = mapthL.begin( ); i != mapthL.end( ); ++i) - theplot << i->second << *i->first; + for (map< const MeshL *, long >::const_iterator i = mapthL.begin( ); i != mapthL.end( ); ++i) theplot << i->second << *i->first; } // end of what ploting for meshes @@ -4727,26 +4573,26 @@ AnyType Plot::operator( )(Stack s) const { } // send volume 3d meshes for ffglut else if (what == 5) { - pTh3 = ll[ii].th3();; + pTh3 = ll[ii].th3( ); + ; if (pTh3) { err = 0; theplot << what; - theplot << mapth3[ll[ii].th3()]; // numero du maillage 3D volume + theplot << mapth3[ll[ii].th3( )]; // numero du maillage 3D volume } - } - else if (what == 50) { - pThS = ll[ii].thS(); + } else if (what == 50) { + pThS = ll[ii].thS( ); if (pThS) { err = 0; theplot << what; - theplot << mapthS[ll[ii].thS()]; // numero du maillage 3D surface + theplot << mapthS[ll[ii].thS( )]; // numero du maillage 3D surface } } else if (what == 55) { - pThL = ll[ii].thL(); + pThL = ll[ii].thL( ); if (pThL) { err = 0; theplot << what; - theplot << mapthL[ll[ii].thL()]; // numero du maillage 3D curve + theplot << mapthL[ll[ii].thL( )]; // numero du maillage 3D curve } } @@ -4770,8 +4616,7 @@ AnyType Plot::operator( )(Stack s) const { if (err == 1) { if (verbosity) cerr << "Warning: May be a bug in your script, \n" - << " a part of the plot is wrong t (mesh or FE function, curve) => skip the item " - << i + 1 << " in plot command " << endl; + << " a part of the plot is wrong t (mesh or FE function, curve) => skip the item " << i + 1 << " in plot command " << endl; theplot << -1L << (long)i; } } @@ -4804,8 +4649,8 @@ AnyType Plot::operator( )(Stack s) const { bool bw = false; string *psfile = 0; - string * pdffile=0; // add by fujiwara - string * svgfile=0; // add by fujiwara + string *pdffile = 0; // add by fujiwara + string *svgfile = 0; // add by fujiwara string *cm = 0; pferbase fe = 0, fe1 = 0; int cmp0, cmp1; @@ -4859,8 +4704,8 @@ AnyType Plot::operator( )(Stack s) const { if (nargs[19]) keepPV = GetAny< bool >((*nargs[19])(s)); if (nargs[VTK_START + 23]) pNormalT = GetAny< bool >((*nargs[VTK_START + 23])(s)); if (nargs[VTK_START + 8]) ArrowSize = GetAny< double >((*nargs[VTK_START + 8])(s)); - if (nargs[44]) pdffile= GetAny((*nargs[44])(s)); // add by fujiwara move by FH - if (nargs[45]) svgfile= GetAny((*nargs[45])(s)); // add by fujiwara move by FH + if (nargs[44]) pdffile = GetAny< string * >((*nargs[44])(s)); // add by fujiwara move by FH + if (nargs[45]) svgfile = GetAny< string * >((*nargs[45])(s)); // add by fujiwara move by FH // for the gestion of the PTR. WhereStackOfPtr2Free(s) = new StackOfPtr2Free(s); // FH aout 2007 @@ -4872,8 +4717,8 @@ AnyType Plot::operator( )(Stack s) const { const Mesh *cTh = 0; bool vecvalue = false, isovalue = false; bool ops = psfile; - bool opdf=pdffile; // add by fujiwara - bool osvg=svgfile; // add by fujiwara + bool opdf = pdffile; // add by fujiwara + bool osvg = svgfile; // add by fujiwara bool drawmeshes = false; if (clean) { // ALH - 28/3/15 - Open PS file before blanking the current picture because Javascript needs to @@ -4885,12 +4730,12 @@ AnyType Plot::operator( )(Stack s) const { } // add by fujiwara - if( pdffile ) { - openPDF(pdffile->c_str()); + if (pdffile) { + openPDF(pdffile->c_str( )); } // add by fujiwara - if( svgfile ) { - openSVG(svgfile->c_str()); + if (svgfile) { + openSVG(svgfile->c_str( )); } reffecran( ); @@ -4902,9 +4747,9 @@ AnyType Plot::operator( )(Stack s) const { for (size_t ii = 0; ii < ll.size( ); ii++) { int i = ll[ii].i; long what = ll[ii].what; - if(verbosity>99) cout << " plot " << ii << " "<< what << endl; - R2 P1(1e100,1e100), P2(-1e100,-1e100); - // R3 P11(1e100,1e100,1e100), P22(-1e100,-1e100,-1e100); + if (verbosity > 99) cout << " plot " << ii << " " << what << endl; + R2 P1(1e100, 1e100), P2(-1e100, -1e100); + // R3 P11(1e100,1e100,1e100), P22(-1e100,-1e100,-1e100); if (what == 1 || what == 2) { if (!uaspectratio) aspectratio = true; ll[ii].eval(fe, cmp0, fe1, cmp1); @@ -4924,18 +4769,18 @@ AnyType Plot::operator( )(Stack s) const { cerr << " On ne sait tracer que de vecteur sur un meme type element finite. " << endl; } } - } else if (l[i].what == 0 && ll[ii].th( ) ) { + } else if (l[i].what == 0 && ll[ii].th( )) { if (!uaspectratio) aspectratio = true; - + const Mesh &Th = *ll[ii].th( ); Th.BoundingBox(P1, P2); cTh = &Th; } else if (l[i].what == 4) { if (!uaspectratio) aspectratio = true; const E_BorderN *Bh = l[i].evalb(0, s); - double pminz=1e100,pmaxz=-1e100; + double pminz = 1e100, pmaxz = -1e100; Bh->BoundingBox(s, P1.x, P2.x, P1.y, P2.y, pminz, pmaxz); - + } else if (l[i].what == 3) { tab ttx = l[i].evalt(0, s); tab tty = l[i].evalt(1, s); @@ -4976,8 +4821,7 @@ AnyType Plot::operator( )(Stack s) const { if (aspectratio) cadreortho((float)O.x, (float)(O.y + r * 0.05), (float)r); else - cadre((float)(O.x - rx * .55), (float)(O.x + rx * 0.55), (float)(O.y - ry * .55), - (float)(O.y + ry * .55)); + cadre((float)(O.x - rx * .55), (float)(O.x + rx * 0.55), (float)(O.y - ry * .55), (float)(O.y + ry * .55)); R d = fill ? (umx - umn) / (N - 1) : (umx - umn) / (N); R x = fill ? umn - d / 2 : umn + d / 2; if (!pViso) @@ -5006,17 +4850,14 @@ AnyType Plot::operator( )(Stack s) const { xx1 = max(boundingbox[0], boundingbox[2]); yy0 = min(boundingbox[1], boundingbox[3]); yy1 = max(boundingbox[1], boundingbox[3]); - if (verbosity > 2) - cout << "bb= xmin =" << xx0 << ", max =" << xx1 << ", ymin = " << yy0 << ", ymax = " << yy1 - << endl; + if (verbosity > 2) cout << "bb= xmin =" << xx0 << ", max =" << xx1 << ", ymin = " << yy0 << ", ymax = " << yy1 << endl; if (aspectratio) cadreortho((xx0 + xx1) * 0.5, (yy0 + yy1) * 0.5, max(xx1 - xx0, yy1 - yy0) * 0.5); else cadre(xx0, xx1, yy0, yy1); } getcadre(xx0, xx1, yy0, yy1); - if (verbosity > 2) - cout << " getcadre bb= xmin =" << xx0 << ", max =" << xx1 << ", ymin = " << yy0 << ", ymax = " << yy1 << endl; + if (verbosity > 2) cout << " getcadre bb= xmin =" << xx0 << ", max =" << xx1 << ", ymin = " << yy0 << ", ymax = " << yy1 << endl; const R ccoeff = coeff; bool plotting = true; // drawing part ------------------------------ @@ -5026,9 +4867,9 @@ AnyType Plot::operator( )(Stack s) const { bool thfill = fill; for (size_t ii = 0; ii < ll.size( ); ii++) { int i = ll[ii].i; - long what = ll[ii].what;// correction FH 20201208 i->ii (wrong what) - if (verbosity > 99) cout << " plot " << ii << " i " << i << " " << what << endl; - if (l[i].what == 0 && ll[ii].th( )) + long what = ll[ii].what; // correction FH 20201208 i->ii (wrong what) + if (verbosity > 99) cout << " plot " << ii << " i " << i << " " << what << endl; + if (l[i].what == 0 && ll[ii].th( )) if (fill) ll[ii].th( )->Draw(0, thfill); else @@ -5038,22 +4879,19 @@ AnyType Plot::operator( )(Stack s) const { if (!fe->x( )) continue; #ifdef VVVVVVV cout << " Min = " << fe->x->min( ) << " max = " << fe->x->max( ); - if (fe1 && verbosity > 1) - cout << " Min = " << fe1->x->min( ) << " max = " << fe1->x->max( ); + if (fe1 && verbosity > 1) cout << " Min = " << fe1->x->min( ) << " max = " << fe1->x->max( ); cout << endl; #endif if (fe1) { if (fe->Vh == fe1->Vh) - vecvalue = true, fe->Vh->Draw(*fe->x( ), *fe1->x( ), Varrow, coeff, cmp0, cmp1, colors, - nbcolors, hsv, drawborder, ArrowSize); + vecvalue = true, fe->Vh->Draw(*fe->x( ), *fe1->x( ), Varrow, coeff, cmp0, cmp1, colors, nbcolors, hsv, drawborder, ArrowSize); else cerr << " Draw only vector field on same Finites Element , Sorry. " << endl; if (drawmeshes) fe->Vh->Th.Draw(0, fill); } else if (fill) - isovalue = true, - fe->Vh->Drawfill(*fe->x( ), Viso, cmp0, 1., colors, nbcolors, hsv, drawborder); + isovalue = true, fe->Vh->Drawfill(*fe->x( ), Viso, cmp0, 1., colors, nbcolors, hsv, drawborder); else isovalue = true, fe->Vh->Draw(*fe->x( ), Viso, cmp0, colors, nbcolors, hsv, drawborder); @@ -5080,9 +4918,8 @@ AnyType Plot::operator( )(Stack s) const { couleur(2 + i); for (int i = 1; i < k; i++) rlineto(x[i], y[i]); } else { - static int kerr=0; - if (verbosity && kerr++< 5 && mpirank==0) - cout << " Plot:: Sorry no ps version for this type of plot " << l[i].what << endl; + static int kerr = 0; + if (verbosity && kerr++ < 5 && mpirank == 0) cout << " Plot:: Sorry no ps version for this type of plot " << l[i].what << endl; } thfill = false; } @@ -5107,14 +4944,14 @@ AnyType Plot::operator( )(Stack s) const { closePS( ); } // add by fujiwara - if ( opdf ) { - opdf = false; - closePDF(); + if (opdf) { + opdf = false; + closePDF( ); } // add by fujiwara - if ( osvg ) { - osvg = false; - closeSVG(); + if (osvg) { + osvg = false; + closeSVG( ); } if (wait && !NoWait) { next: @@ -5322,17 +5159,12 @@ AnyType Convect::eval2(Stack s) const { static R ddtp = 0; R ddt = GetAny< double >((*dt)(s)); if (ddt) { - if ((stateold == state) && (ddt == ddtp) && - (*mp == mpp)) // optim same convect at same point nov/2015 + if ((stateold == state) && (ddt == ddtp) && (*mp == mpp)) // optim same convect at same point nov/2015 { - if (verbosity > 3 && count++ < 10) - cout << " -- optim convect " << stateold << " P= " << mp->P << ", " << mp->T - << " chi(P) = " << mps.P << "," << mps.T << endl; + if (verbosity > 3 && count++ < 10) cout << " -- optim convect " << stateold << " P= " << mp->P << ", " << mp->T << " chi(P) = " << mps.P << "," << mps.T << endl; mpc = mps; } else { - if (verbosity > 3 && count++ < 10 * 10) - cout << " -- no optim convect " << stateold << " " << state << " P= " << mp->P - << " PP= " << mpp.P << endl; + if (verbosity > 3 && count++ < 10 * 10) cout << " -- no optim convect " << stateold << " " << state << " P= " << mp->P << " PP= " << mpp.P << endl; stateold = state; // correction FH.. ddtp = ddt; const Mesh &Th(*mp->Th); @@ -5345,8 +5177,7 @@ AnyType Convect::eval2(Stack s) const { int k = 0; int j; int it = Th(mpc.T); - while ((j = WalkInTriangle(Th, it, l, GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), - ddt)) >= 0) { + while ((j = WalkInTriangle(Th, it, l, GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), ddt)) >= 0) { ffassert(l[j] == 0); // int jj = j; R a = l[(j + 1) % 3], b = l[(j + 2) % 3]; @@ -5372,8 +5203,7 @@ AnyType Convect::eval2(Stack s) const { } // warning use poit on &mpc .. bug correct in dec 2015 F.H. AnyType r = (*ff)(s); - if (verbosity > 3 && count++ < 10 * 10) - cout << " %%%r= " << GetAny< double >(r) << " P= " << mp->P << ", " << mp->T << endl; + if (verbosity > 3 && count++ < 10 * 10) cout << " %%%r= " << GetAny< double >(r) << " P= " << mp->P << ", " << mp->T << endl; MeshPointStack(s, mp); // restor old pointeur .. return r; @@ -5401,15 +5231,12 @@ AnyType Convect::eval3old(Stack s) const { R ddt = GetAny< double >((*dt)(s)); if (ddt) { bool ddd = verbosity > 1000; - if ((stateold == state) && (ddt == ddtp) && - (*mp == mpp)) // optim same convect at same point nov/2015 + if ((stateold == state) && (ddt == ddtp) && (*mp == mpp)) // optim same convect at same point nov/2015 { if (verbosity > 3 && count++ < 10) cout << " -- optim convect3 " << stateold << endl; mpc = mps; } else { - if (verbosity > 3 && count++ < 10 * 10) - cout << " -- no optim3 convect " << stateold << " " << state << " P= " << mp->P - << " PP= " << mpp.P << endl; + if (verbosity > 3 && count++ < 10 * 10) cout << " -- no optim3 convect " << stateold << " " << state << " P= " << mp->P << " PP= " << mpp.P << endl; const Mesh3 &Th3(*mp->Th3); ffassert(mp->Th3 && mp->T3); R3 PHat = mpc.PHat; @@ -5418,39 +5245,28 @@ AnyType Convect::eval3old(Stack s) const { int j; int it = Th3(mpc.T3); if (ddd) cout << " IN: " << (*mpc.T3)(PHat) << " ; " << mpc.P << " : " << ddt << endl; - while ((j = WalkInTet( - Th3, it, PHat, - R3(GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), GetAny< double >((*w)(s))), - ddt)) >= 0) + while ((j = WalkInTet(Th3, it, PHat, R3(GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), GetAny< double >((*w)(s))), ddt)) >= 0) if (j > 3) { it = j - 4; mpc.change(PHat, Th3[it], 0); - if (ddd) - cout << " **P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j - << " it: " << it << "ddt=" << ddt; + if (ddd) cout << " **P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j << " it: " << it << "ddt=" << ddt; if (ddt == 0) break; // finish ... } else { - if (ddd) - cout << "P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j - << " it: " << it; + if (ddd) cout << "P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j << " it: " << it; #ifdef DEBUG R3 Po = (*mpc.T3)(PHat), Pho = PHat; int ito = it; #endif int itt = Th3.ElementAdj(it, j, PHat); - if (ddd && itt >= 0) - cout << " -> " << itt << " " << j << " : Pn " << Th3[itt](PHat) << " PHn " << PHat - << " , " << ddt << endl; + if (ddd && itt >= 0) cout << " -> " << itt << " " << j << " : Pn " << Th3[itt](PHat) << " PHn " << PHat << " , " << ddt << endl; if (itt < 0) break; it = itt; mpc.change(PHat, Th3[it], 0); #ifdef DEBUG if (((Po - mpc.P).norme2( ) > 1e-10)) { - cout << ito << " " << &Th3[ito][0] << " " << &Th3[ito][1] << " " << &Th3[ito][2] << " " - << &Th3[ito][3] << " " << endl; - cout << it << " " << &Th3[it][0] << " " << &Th3[it][1] << " " << &Th3[it][2] << " " - << &Th3[it][3] << endl; + cout << ito << " " << &Th3[ito][0] << " " << &Th3[ito][1] << " " << &Th3[ito][2] << " " << &Th3[ito][3] << " " << endl; + cout << it << " " << &Th3[it][0] << " " << &Th3[it][1] << " " << &Th3[it][2] << " " << &Th3[it][3] << endl; cout << Pho << "o Hat " << PHat << endl; cout << Po << " o != " << mpc.P << " diff= " << (Po - mpc.P).norme2( ) << endl; assert(0); @@ -5469,8 +5285,7 @@ AnyType Convect::eval3old(Stack s) const { return r; } -AnyType Convect::eval3( - Stack s) const { // nouvelle version de convect 3d Feb 2015 version 3.44-01 +AnyType Convect::eval3(Stack s) const { // nouvelle version de convect 3d Feb 2015 version 3.44-01 MeshPoint *mp(MeshPointStack(s)), mpc(*mp); MeshPointStack(s, &mpc); // P ptr on variable mpc ... static MeshPoint mpp, mps; @@ -5492,39 +5307,28 @@ AnyType Convect::eval3( int j; int it = Th3(mpc.T3); if (ddd) cout << " IN: " << (*mpc.T3)(PHat) << " ; " << mpc.P << " : " << ddt << endl; - while ((j = WalkInTetn( - Th3, it, PHat, - R3(GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), GetAny< double >((*w)(s))), - ddt, offset)) >= 0) + while ((j = WalkInTetn(Th3, it, PHat, R3(GetAny< double >((*u)(s)), GetAny< double >((*v)(s)), GetAny< double >((*w)(s))), ddt, offset)) >= 0) if (j > 3) { it = j - 4; mpc.change(PHat, Th3[it], 0); - if (ddd) - cout << " **P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j - << " it: " << it << "ddt=" << ddt; + if (ddd) cout << " **P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j << " it: " << it << "ddt=" << ddt; if (ddt == 0) break; // finish ... } else { - if (ddd) - cout << "P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j - << " it: " << it; + if (ddd) cout << "P= " << (*mpc.T3)(PHat) << " , Ph " << PHat << " : j = " << j << " it: " << it; #ifdef DEBUG R3 Po = (*mpc.T3)(PHat), Pho = PHat; int ito = it; #endif int itt = Th3.ElementAdj(it, j, PHat); - if (ddd && itt >= 0) - cout << " -> " << itt << " " << j << " : Pn " << Th3[itt](PHat) << " PHn " << PHat - << " , " << ddt << endl; + if (ddd && itt >= 0) cout << " -> " << itt << " " << j << " : Pn " << Th3[itt](PHat) << " PHn " << PHat << " , " << ddt << endl; if (itt < 0) break; it = itt; mpc.change(PHat, Th3[it], 0); #ifdef DEBUG if (((Po - mpc.P).norme2( ) > 1e-10)) { - cout << ito << " " << &Th3[ito][0] << " " << &Th3[ito][1] << " " << &Th3[ito][2] << " " - << &Th3[ito][3] << " " << endl; - cout << it << " " << &Th3[it][0] << " " << &Th3[it][1] << " " << &Th3[it][2] << " " - << &Th3[it][3] << endl; + cout << ito << " " << &Th3[ito][0] << " " << &Th3[ito][1] << " " << &Th3[ito][2] << " " << &Th3[ito][3] << " " << endl; + cout << it << " " << &Th3[it][0] << " " << &Th3[it][1] << " " << &Th3[it][2] << " " << &Th3[it][3] << endl; cout << Pho << "o Hat " << PHat << endl; cout << Po << " o != " << mpc.P << " diff= " << (Po - mpc.P).norme2( ) << endl; assert(0); @@ -5550,9 +5354,7 @@ class Op3_pfe2K : public ternary_function< pair< FEbase< K, v_fes > *, int >, R, class Op : public E_F0mps { public: Expression a, b, c; - Op(Expression aa, Expression bb, Expression cc) - : a(aa), b(bb), c(cc) { /*cout << "Op3_pfe2K" << endl;*/ - } + Op(Expression aa, Expression bb, Expression cc) : a(aa), b(bb), c(cc) { /*cout << "Op3_pfe2K" << endl;*/ } AnyType operator( )(Stack s) const { R xx(GetAny< R >((*b)(s))); R yy(GetAny< R >((*c)(s))); @@ -5565,7 +5367,6 @@ class Op3_pfe2K : public ternary_function< pair< FEbase< K, v_fes > *, int >, R, }; }; - // Add FH 16032005 class Op3_Mesh2mp : public ternary_function< pmesh *, R, R, MeshPoint * > { public: @@ -5688,9 +5489,7 @@ pfec get_element(pfecarray const &a, long const &n) { return pfec(*(*a.first)[n] lgElement get_element(pmesh const &a, long const &n) { return lgElement(a, n); } lgElement get_element(pmesh *const &a, long const &n) { return lgElement(*a, n); } -lgBoundaryEdge get_belement(lgBoundaryEdge::BE const &a, long const &n) { - return lgBoundaryEdge(a, n); -} +lgBoundaryEdge get_belement(lgBoundaryEdge::BE const &a, long const &n) { return lgBoundaryEdge(a, n); } lgElement get_adj(lgElement::Adj const &a, long *const &n) { return a.adj(*n); } @@ -5723,8 +5522,7 @@ inline AnyType DestroyKN(Stack, const AnyType &x) { template< class RR, class A, class B > RR *get_elementp_(const A &a, const B &b) { if (b < 0 || a->N( ) <= b) { - cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) - << endl; + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) << endl; ExecError("Out of bound in operator []"); } return &((*a)[b]); @@ -5756,25 +5554,19 @@ R *set_initmat(R *const &a, const long &n) { void init_mesh_array( ) { Dcl_Type< KN< pmesh > * >(0, ::DestroyKN< pmesh >); - atype< KN< pmesh > * >( )->Add( - "[", "", - new OneOperator2_< pmesh *, KN< pmesh > *, long >(get_elementp_< pmesh, KN< pmesh > *, long >)); + atype< KN< pmesh > * >( )->Add("[", "", new OneOperator2_< pmesh *, KN< pmesh > *, long >(get_elementp_< pmesh, KN< pmesh > *, long >)); TheOperators->Add("<-", new OneOperator2_< KN< pmesh > *, KN< pmesh > *, long >(&set_initinit)); - map_type_of_map[make_pair(atype< long >( ), atype< pmesh >( ))] = - atype< KN< pmesh > * >( ); // vector + map_type_of_map[make_pair(atype< long >( ), atype< pmesh >( ))] = atype< KN< pmesh > * >( ); // vector // resize mars 2006 v2.4-1 Dcl_Type< Resize< KN< pmesh > > >( ); - Add< KN< pmesh > * >("resize", ".", - new OneOperator1< Resize< KN< pmesh > >, KN< pmesh > * >(to_Resize)); - Add< Resize< KN< pmesh > > >( - "(", "", new OneOperator2_< KN< pmesh > *, Resize< KN< pmesh > >, long >(resizeandclean1)); + Add< KN< pmesh > * >("resize", ".", new OneOperator1< Resize< KN< pmesh > >, KN< pmesh > * >(to_Resize)); + Add< Resize< KN< pmesh > > >("(", "", new OneOperator2_< KN< pmesh > *, Resize< KN< pmesh > >, long >(resizeandclean1)); } template< class RR, class A, class B > RR get_elementp(const A &a, const B &b) { if (b < 0 || a->N( ) <= b) { - cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) - << endl; + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) << endl; ExecError("Out of bound in operator []"); } return ((*a)[b]); @@ -5796,7 +5588,7 @@ T *resizeandclean2(const Resize< T > &t, const long &n) { // resizeandclean1 } /*R3 *init_R3(double x,double y,double z) { - + return (R3 *) &any; }*/ template< class PMat > @@ -5809,20 +5601,24 @@ AnyType ClearReturn(Stack stack, const AnyType &a) { Add2StackOfPtr2FreeRC(stack, m); return m; } -template long get_n(KN * p){ return p->N();}// -template long get__n(KN_ p){ return p.N();}// +template< class K > +long get_n(KN< K > *p) { + return p->N( ); +} // +template< class K > +long get__n(KN_< K > p) { + return p.N( ); +} // template< class R > void DclTypeMatrix( ) { Dcl_Type< RNM_VirtualMatrix< R > * >( ); // ??????? ZZZZZZ - Dcl_Type< Matrice_Creuse< R > * >(InitP< Matrice_Creuse< R > >, Destroy< Matrice_Creuse< R > >, - ClearReturn< Matrice_Creuse< R > >); + Dcl_Type< Matrice_Creuse< R > * >(InitP< Matrice_Creuse< R > >, Destroy< Matrice_Creuse< R > >, ClearReturn< Matrice_Creuse< R > >); // newpMatrice_Creuse Dcl_Type< newpMatrice_Creuse< R > >( ); // to def new Matrice_Creuse Dcl_Type< Matrice_Creuse_Transpose< R > >( ); // matrice^t (A') - Dcl_Type< Matrice_Creuse_inv< R > >( ); // matrice^-1 A^{-1} Dcl_Type< Matrice_Creuse_inv_trans< R > >( ); // matrice^-1 A'^{-1} Dcl_Type< typename RNM_VirtualMatrix< R >::plusAx >( ); // A*x (A'*x) @@ -5845,15 +5641,13 @@ void DclTypeMatrix( ) { // init array TheOperators->Add("<-", new OneOperator2_< AMat *, AMat *, long >(&set_initmat)); // A[i] - atype< AMat * >( )->Add( - "[", "", new OneOperator2_< PMat, AMat *, long >(get_elementp_< Mat, AMat *, long >)); + atype< AMat * >( )->Add("[", "", new OneOperator2_< PMat, AMat *, long >(get_elementp_< Mat, AMat *, long >)); // resize Dcl_Type< Resize< AMat > >( ); Add< AMat * >("resize", ".", new OneOperator1< Resize< AMat >, AMat * >(to_Resize)); - Add< Resize< AMat > >("(", "", - new OneOperator2_< AMat *, Resize< AMat >, long >(resizeandclean2)); - Add("n",".",new OneOperator1(get_n)); + Add< Resize< AMat > >("(", "", new OneOperator2_< AMat *, Resize< AMat >, long >(resizeandclean2)); + Add< AMat * >("n", ".", new OneOperator1< long, AMat * >(get_n)); // to declare matrix[int] map_type_of_map[make_pair(atype< long >( ), atype< PMat >( ))] = atype< AMat * >( ); @@ -5908,146 +5702,139 @@ R3 *set_eqp(R3 *a, R3 *b) { *a = *b; return a; } - class opDotR3 : public OneOperator{ - public: - AnyType operator()(Stack s) const {ffassert(0);return 0L;} - bool MeshIndependent() const { return false;} - - opDotR3(aType A, aType B): OneOperator(atype(),A,B) {} - opDotR3(): OneOperator(atype(),atype(),atype() ) {} - - E_F0 * code(const basicAC_F0 & ) const {ffassert(0);} - C_F0 code2(const basicAC_F0 &args) const; - }; - C_F0 opDotR3::code2(const basicAC_F0 &args) const - { - bool ta =args[0].left()==atype(); - bool tb =args[1].left()==atype(); - ffassert(ta == !tb); - const TransE_Array * tea=0; - const E_Array * ea=0; - C_F0 b= ta ? args[1] : args[0] ; // N - if( ta) tea = dynamic_cast((Expression) args[0]); - if( tb) ea = dynamic_cast((Expression) args[1]); - - ffassert( ea || tea ); - const E_Array & a= ta ? *tea->v : *ea; - int na=a.size(); - int nb=na; - if(na <1 || na > 3 ) CompileError(" bad array [ ...]' "); - - KN A(na), B(nb); - - - for (int i=0;i( ), A, B) {} + opDotR3( ) : OneOperator(atype< C_F0 >( ), atype< TransE_Array >( ), atype< R3 * >( )) {} + + E_F0 *code(const basicAC_F0 &) const { ffassert(0); } + C_F0 code2(const basicAC_F0 &args) const; +}; +C_F0 opDotR3::code2(const basicAC_F0 &args) const { + bool ta = args[0].left( ) == atype< TransE_Array >( ); + bool tb = args[1].left( ) == atype< E_Array >( ); + ffassert(ta == !tb); + const TransE_Array *tea = 0; + const E_Array *ea = 0; + C_F0 b = ta ? args[1] : args[0]; // N + if (ta) tea = dynamic_cast< const TransE_Array * >((Expression)args[0]); + if (tb) ea = dynamic_cast< const E_Array * >((Expression)args[1]); + + ffassert(ea || tea); + const E_Array &a = ta ? *tea->v : *ea; + int na = a.size( ); + int nb = na; + if (na < 1 || na > 3) CompileError(" bad array [ ...]' "); + + KN< CC_F0 > A(na), B(nb); + + for (int i = 0; i < na; ++i) + if (!ta) + A(i) = a[i]; + else + A(i) = TryConj(a[i]); + + const char *xyz[] = {"x", "y", "z"}; + for (int i = 0; i < nb; ++i) B[i] = C_F0(b, xyz[i]); + + CC_F0 ab; + ab = C_F0(TheOperators, "*", A[0], B[0]); + for (int i = 1; i < na; ++i) ab = C_F0(TheOperators, "+", ab, C_F0(TheOperators, "*", A(i), B(i))); + + return ab; +} +// Add FH ... mars 2020 for N'.x + template< class Result, class A > - class E_F_trans_A_Ptr_o_R : public E_F0 { - public: - typedef Result A::*ptr; - Expression a0; - ptr p; - E_F_trans_A_Ptr_o_R(Expression aa0, ptr pp) : a0(aa0), p(pp) {} - AnyType operator( )(Stack s) const { - return SetAny< Result * >(&(GetAny< Transpose >((*a0)(s)).t->*p)); } - bool MeshIndependent( ) const { return a0->MeshIndependent( ); } - }; -template< class A > - class OneOperator_trans_Ptr_o_R : public OneOperator { - typedef double Result ; - typedef double A::*ptr; - ptr p; - - public: - E_F0 *code(const basicAC_F0 &args) const { - return new E_F_trans_A_Ptr_o_R< Result , A >(t[0]->CastTo(args[0]), p); - } - OneOperator_trans_Ptr_o_R(ptr pp) : OneOperator(atype< Result * >( ), atype< Transpose >( )), p(pp) {} - }; -template +class E_F_trans_A_Ptr_o_R : public E_F0 { + public: + typedef Result A::*ptr; + Expression a0; + ptr p; + E_F_trans_A_Ptr_o_R(Expression aa0, ptr pp) : a0(aa0), p(pp) {} + AnyType operator( )(Stack s) const { return SetAny< Result * >(&(GetAny< Transpose< A * > >((*a0)(s)).t->*p)); } + bool MeshIndependent( ) const { return a0->MeshIndependent( ); } +}; +template< class A > +class OneOperator_trans_Ptr_o_R : public OneOperator { + typedef double Result; + typedef double A::*ptr; + ptr p; + + public: + E_F0 *code(const basicAC_F0 &args) const { return new E_F_trans_A_Ptr_o_R< Result, A >(t[0]->CastTo(args[0]), p); } + OneOperator_trans_Ptr_o_R(ptr pp) : OneOperator(atype< Result * >( ), atype< Transpose< A * > >( )), p(pp) {} +}; +template< class R, class A, class B > struct OppR3dot { - using first_argument_type = A; - using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - B pu = a; - return (*pu,*b);} }; - -template + using first_argument_type = A; + using second_argument_type = B; + using result_type = R; + static R f(const A &a, const B &b) { + B pu = a; + return (*pu, *b); + } +}; + +template< class R, class A, class B > struct OppqR3dot { - using first_argument_type = A; - using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - B* pu = a; - return (*pu,b);} }; - -template + using first_argument_type = A; + using second_argument_type = B; + using result_type = R; + static R f(const A &a, const B &b) { + B *pu = a; + return (*pu, b); + } +}; + +template< class R, class A, class B > struct OpR3dot { - using first_argument_type = A; - using second_argument_type = B; - using result_type = R; - static R f(const A & a,const B & b) { - B pu = a; - return (pu,b);} }; - -R3 CrossProduct(const R3 & A,const R3 & B){ return A^B;} -R Det(const R3 & A,const R3 & B,const R3 & C){ return det(A,B,C);} -R3* initR3(R3 *const & p,const R& a,const R& b,const R &c){*p = R3(a,b,c); return p;} -R3* initR3(R3 *const & p,const R3& a,const R3& b){*p = R3(a,b); return p;} - -R3 toR3(const R& a,const R& b,const R &c){return R3(a,b,c);} -R3 toR3(const R3& a,const R3& b){return R3(a,b);} - -R3 NElement(lgBoundaryEdge const & a) { return R3(a.NBoundaryElement()); }// add Jan 2022 -template -void Add_u_init_array(int ii=0) -{ - typedef Complex C; - typedef double R; - - TheOperators->Add( - "<-", - new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::plusAx > >(10), - new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::solveAxeqb > >(10), - new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::solveAtxeqb > >(10), - new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::plusAtx > >(10), - new init_FE_eqarray< FF_L_args< R, vfes, Call_FormLinear< v_fes > > >(10) - - ); - TheOperators->Add( - "<-", - new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::plusAx > >(10), - new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::solveAxeqb > >(10), - new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::solveAtxeqb > >(10), - new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::plusAtx > >(10) - - ); - - if( ii) - TheOperators->Add( - "<-", - new init_FE_eqarray< FFset3< R, vfes, KN_< R > > >(10), - new init_FE_eqarray< FFset3< C, vfes, KN_< C > > >(10)); + using first_argument_type = A; + using second_argument_type = B; + using result_type = R; + static R f(const A &a, const B &b) { + B pu = a; + return (pu, b); + } +}; +R3 CrossProduct(const R3 &A, const R3 &B) { return A ^ B; } +R Det(const R3 &A, const R3 &B, const R3 &C) { return det(A, B, C); } +R3 *initR3(R3 *const &p, const R &a, const R &b, const R &c) { + *p = R3(a, b, c); + return p; +} +R3 *initR3(R3 *const &p, const R3 &a, const R3 &b) { + *p = R3(a, b); + return p; +} + +R3 toR3(const R &a, const R &b, const R &c) { return R3(a, b, c); } +R3 toR3(const R3 &a, const R3 &b) { return R3(a, b); } + +R3 NElement(lgBoundaryEdge const &a) { return R3(a.NBoundaryElement( )); } // add Jan 2022 +template< class vfes > +void Add_u_init_array(int ii = 0) { + typedef Complex C; + typedef double R; + + TheOperators->Add("<-", new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::plusAx > >(10), new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::solveAxeqb > >(10), + new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::solveAtxeqb > >(10), new init_FE_eqarray< FFset3< R, vfes, RNM_VirtualMatrix< R >::plusAtx > >(10), + new init_FE_eqarray< FF_L_args< R, vfes, Call_FormLinear< v_fes > > >(10) + + ); + TheOperators->Add("<-", new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::plusAx > >(10), new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::solveAxeqb > >(10), + new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::solveAtxeqb > >(10), new init_FE_eqarray< FFset3< C, vfes, RNM_VirtualMatrix< C >::plusAtx > >(10) + + ); + + if (ii) TheOperators->Add("<-", new init_FE_eqarray< FFset3< R, vfes, KN_< R > > >(10), new init_FE_eqarray< FFset3< C, vfes, KN_< C > > >(10)); } void init_lgfem( ) { @@ -6058,19 +5845,15 @@ void init_lgfem( ) { #endif Dcl_Type< MeshPoint * >( ); - Dcl_TypeandPtr< R3 >(0,0,::InitializeDef,0); - Dcl_TypeandPtr< R2 >(0,0,::InitializeDef,0); - Dcl_Type< Transpose >(); - Dcl_Type< Transpose >(); - - Dcl_TypeandPtr< pmesh >(0, 0, ::InitializePtr< pmesh >, ::DestroyPtr< pmesh >, - AddIncrement< pmesh >, NotReturnOfthisType); - Dcl_TypeandPtr< pmesh3 >(0, 0, ::InitializePtr< pmesh3 >, ::DestroyPtr< pmesh3 >, - AddIncrement< pmesh3 >, NotReturnOfthisType); - Dcl_TypeandPtr< pmeshS >(0, 0, ::InitializePtr< pmeshS >, ::DestroyPtr< pmeshS >, - AddIncrement< pmeshS >, NotReturnOfthisType); - Dcl_TypeandPtr< pmeshL >(0, 0, ::InitializePtr< pmeshL >, ::DestroyPtr< pmeshL >, - AddIncrement< pmeshL >, NotReturnOfthisType); + Dcl_TypeandPtr< R3 >(0, 0, ::InitializeDef< R3 >, 0); + Dcl_TypeandPtr< R2 >(0, 0, ::InitializeDef< R2 >, 0); + Dcl_Type< Transpose< R3 * > >( ); + Dcl_Type< Transpose< R3 > >( ); + + Dcl_TypeandPtr< pmesh >(0, 0, ::InitializePtr< pmesh >, ::DestroyPtr< pmesh >, AddIncrement< pmesh >, NotReturnOfthisType); + Dcl_TypeandPtr< pmesh3 >(0, 0, ::InitializePtr< pmesh3 >, ::DestroyPtr< pmesh3 >, AddIncrement< pmesh3 >, NotReturnOfthisType); + Dcl_TypeandPtr< pmeshS >(0, 0, ::InitializePtr< pmeshS >, ::DestroyPtr< pmeshS >, AddIncrement< pmeshS >, NotReturnOfthisType); + Dcl_TypeandPtr< pmeshL >(0, 0, ::InitializePtr< pmeshL >, ::DestroyPtr< pmeshL >, AddIncrement< pmeshL >, NotReturnOfthisType); Dcl_Type< lgVertex >( ); Dcl_Type< lgElement >( ); Dcl_Type< lgElement::Adj >( ); @@ -6078,20 +5861,16 @@ void init_lgfem( ) { Dcl_Type< lgBoundaryEdge::BE >( ); Dcl_Type< lgBoundaryEdge >( ); - atype< long >( )->AddCast(new E_F1_funcT< long, lgVertex >(Cast< long, lgVertex >), - new E_F1_funcT< long, lgElement >(Cast< long, lgElement >), + atype< long >( )->AddCast(new E_F1_funcT< long, lgVertex >(Cast< long, lgVertex >), new E_F1_funcT< long, lgElement >(Cast< long, lgElement >), new E_F1_funcT< long, lgBoundaryEdge >(Cast< long, lgBoundaryEdge >)); Dcl_Type< TypeOfFE * >( ); Dcl_Type< TypeOfFE3 * >( ); // 3D volume Dcl_Type< TypeOfFES * >( ); // 3D surface Dcl_Type< TypeOfFEL * >( ); // 3D curve - map_type[typeid(TypeOfFE3 *).name( )]->AddCast( - new E_F1_funcT< TypeOfFE3 *, TypeOfFE * >(TypeOfFE3to2)); - map_type[typeid(TypeOfFES *).name( )]->AddCast( - new E_F1_funcT< TypeOfFES *, TypeOfFE * >(TypeOfFESto2)); - map_type[typeid(TypeOfFEL *).name( )]->AddCast( - new E_F1_funcT< TypeOfFEL *, TypeOfFE * >(TypeOfFELto2)); + map_type[typeid(TypeOfFE3 *).name( )]->AddCast(new E_F1_funcT< TypeOfFE3 *, TypeOfFE * >(TypeOfFE3to2)); + map_type[typeid(TypeOfFES *).name( )]->AddCast(new E_F1_funcT< TypeOfFES *, TypeOfFE * >(TypeOfFESto2)); + map_type[typeid(TypeOfFEL *).name( )]->AddCast(new E_F1_funcT< TypeOfFEL *, TypeOfFE * >(TypeOfFELto2)); DclTypeMatrix< R >( ); DclTypeMatrix< Complex >( ); @@ -6100,7 +5879,7 @@ void init_lgfem( ) { Dcl_TypeandPtr< pferbasearray >( ); // il faut le 2 pour pourvoir initialiser Dcl_Type< pfer >( ); Dcl_Type< pferarray >( ); - // Dcl_Type< pferarray >( ); + // Dcl_Type< pferarray >( ); // pour des Func FE complex // FH v 1.43 Dcl_TypeandPtr< pfecbase >( ); // il faut le 2 pour pourvoir initialiser @@ -6117,18 +5896,18 @@ void init_lgfem( ) { map_type[typeid(pfes).name( )] = new ForEachType< pfes >( ); map_type[typeid(pfes *).name( )] = new ForEachTypePtrfspace< pfes, 2 >( ); // Morice : le 2 correspond aux parametre de retour de la fonction <> (TYPEOFID) dans AFunction2.cpp - // c'est cette valeur qui permet de faire la distinction entre FESPACE, FESPACES, FESPACDE3, FESPACEL + // c'est cette valeur qui permet de faire la distinction entre FESPACE, FESPACES, FESPACDE3, FESPACEL // lorsque l'on initialise un FE (c-à-d par exemple Uh u;) // Elle correpond à la valeur <> dans la fonction <> // Elle correpond à la valeur <> dans [[lg.ypp]] voir <>. // Added june 2022 Morice : Il faut peut etre le mettre ailleurs ??? - map_type[typeid(pgenericfes).name( )] = new ForEachType< pgenericfes >( ); // Morice - map_type[typeid(pgenericfes *).name( )] = new ForEachTypePtrfspace< pgenericfes, 7 >( ); // Morice + map_type[typeid(pgenericfes).name( )] = new ForEachType< pgenericfes >( ); // Morice + map_type[typeid(pgenericfes *).name( )] = new ForEachTypePtrfspace< pgenericfes, 7 >( ); // Morice - map_type[typeid(pvectgenericfes).name( )] = new ForEachType< pvectgenericfes >( ); // Morice - map_type[typeid(pvectgenericfes *).name( )] =//new ForEachType< pvectgenericfes >( ); - new ForEachTypePtrfspace< pvectgenericfes, 6 >( ); // Morice + map_type[typeid(pvectgenericfes).name( )] = new ForEachType< pvectgenericfes >( ); // Morice + map_type[typeid(pvectgenericfes *).name( )] = // new ForEachType< pvectgenericfes >( ); + new ForEachTypePtrfspace< pvectgenericfes, 6 >( ); // Morice // Dcl type for 3D volume FE Dcl_TypeandPtr< pf3rbase >( ); // il faut le 2 pour pourvoir initialiser @@ -6167,52 +5946,32 @@ void init_lgfem( ) { Dcl_Type< pfLcarray >( ); // cast of eigen value mai 2009 ... - map_type[typeid(FEbaseArrayKn< double > *).name( )]->AddCast - ( + map_type[typeid(FEbaseArrayKn< double > *).name( )]->AddCast( // 2D - new E_F1_funcT< FEbaseArrayKn< double > *, pferbasearray > - ( Cast< FEbaseArrayKn< double > *, pferbasearray >), - new E_F1_funcT< FEbaseArrayKn< double > *, pferarray > - ( First< FEbaseArrayKn< double > *, pferarray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pferbasearray >(Cast< FEbaseArrayKn< double > *, pferbasearray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pferarray >(First< FEbaseArrayKn< double > *, pferarray >), // 3D Curve - new E_F1_funcT< FEbaseArrayKn< double > *, pfSrbasearray > - ( Cast< FEbaseArrayKn< double > *, pfSrbasearray >), - new E_F1_funcT< FEbaseArrayKn< double > *, pfSrarray > - ( First< FEbaseArrayKn< double > *, pfSrarray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pfSrbasearray >(Cast< FEbaseArrayKn< double > *, pfSrbasearray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pfSrarray >(First< FEbaseArrayKn< double > *, pfSrarray >), // 3D surface - new E_F1_funcT< FEbaseArrayKn< double > *, pfLrbasearray > - ( Cast< FEbaseArrayKn< double > *, pfLrbasearray >), - new E_F1_funcT< FEbaseArrayKn< double > *, pfLrarray > - ( First< FEbaseArrayKn< double > *, pfLrarray >), - // 3D - new E_F1_funcT< FEbaseArrayKn< double > *, pf3rbasearray > - ( Cast< FEbaseArrayKn< double > *, pf3rbasearray >), - new E_F1_funcT< FEbaseArrayKn< double > *, pf3rarray > - ( First< FEbaseArrayKn< double > *, pf3rarray >) + new E_F1_funcT< FEbaseArrayKn< double > *, pfLrbasearray >(Cast< FEbaseArrayKn< double > *, pfLrbasearray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pfLrarray >(First< FEbaseArrayKn< double > *, pfLrarray >), + // 3D + new E_F1_funcT< FEbaseArrayKn< double > *, pf3rbasearray >(Cast< FEbaseArrayKn< double > *, pf3rbasearray >), + new E_F1_funcT< FEbaseArrayKn< double > *, pf3rarray >(First< FEbaseArrayKn< double > *, pf3rarray >) ); - map_type[typeid(FEbaseArrayKn< Complex > *).name( )]->AddCast - ( - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfecbasearray > - (Cast< FEbaseArrayKn< Complex > *, pfecbasearray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfecarray > - (First< FEbaseArrayKn< Complex > *, pfecarray >), - - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfScbasearray > - (Cast< FEbaseArrayKn< Complex > *, pfScbasearray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfScarray > - (First< FEbaseArrayKn< Complex > *, pfScarray >), + map_type[typeid(FEbaseArrayKn< Complex > *).name( )]->AddCast(new E_F1_funcT< FEbaseArrayKn< Complex > *, pfecbasearray >(Cast< FEbaseArrayKn< Complex > *, pfecbasearray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pfecarray >(First< FEbaseArrayKn< Complex > *, pfecarray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfLcbasearray > - (Cast< FEbaseArrayKn< Complex > *, pfLcbasearray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pfLcarray > - (First< FEbaseArrayKn< Complex > *, pfLcarray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pfScbasearray >(Cast< FEbaseArrayKn< Complex > *, pfScbasearray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pfScarray >(First< FEbaseArrayKn< Complex > *, pfScarray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pf3cbasearray > - (Cast< FEbaseArrayKn< Complex > *, pf3cbasearray >), - new E_F1_funcT< FEbaseArrayKn< Complex > *, pf3carray > - (First< FEbaseArrayKn< Complex > *, pf3carray >)); + new E_F1_funcT< FEbaseArrayKn< Complex > *, pfLcbasearray >(Cast< FEbaseArrayKn< Complex > *, pfLcbasearray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pfLcarray >(First< FEbaseArrayKn< Complex > *, pfLcarray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pf3cbasearray >(Cast< FEbaseArrayKn< Complex > *, pf3cbasearray >), + new E_F1_funcT< FEbaseArrayKn< Complex > *, pf3carray >(First< FEbaseArrayKn< Complex > *, pf3carray >)); map_type[typeid(pfes3).name( )] = new ForEachType< pfes3 >( ); // 3D volume map_type[typeid(pfes3 *).name( )] = new ForEachTypePtrfspace< pfes3, 3 >( ); // // 3D volume @@ -6227,18 +5986,19 @@ void init_lgfem( ) { Dcl_Type< const QuadratureFormular * >( ); Dcl_Type< const QuadratureFormular1d * >( ); Dcl_Type< const GQuadratureFormular< R3 > * >( ); - TheOperators->Add("\'", new OneOperator1,R3* >(&Build,R3* >,2)); - TheOperators->Add("\'", new OneOperator1,R3>(&Build,R3>,1)); - //TheOperators->Add("*",new opDotR3(atype(),atype< R3* >() ) ); - TheOperators->Add("*",new opDotR3(atype(),atype< R3 >() ) ); // - // "N" a faire mais dur - // R3dot - //TheOperators->Add("*",new OneBinaryOperator< OppR3dot, R3* >> () ); // "N" a faire mais dur - TheOperators->Add("*",new OneBinaryOperator< OpR3dot, R3>> () ); // "N" a faire mais dur + TheOperators->Add("\'", new OneOperator1< Transpose< R3 * >, R3 * >(&Build< Transpose< R3 * >, R3 * >, 2)); + TheOperators->Add("\'", new OneOperator1< Transpose< R3 >, R3 >(&Build< Transpose< R3 >, R3 >, 1)); + // TheOperators->Add("*",new opDotR3(atype(),atype< R3* >() ) ); + TheOperators->Add("*", new opDotR3(atype< TransE_Array >( ), atype< R3 >( ))); // + // "N" a faire mais dur + // R3dot + // TheOperators->Add("*",new OneBinaryOperator< OppR3dot, R3* >> () ); // "N" a faire mais dur + TheOperators->Add("*", new OneBinaryOperator< OpR3dot< double, Transpose< R3 >, R3 > >( )); // "N" a faire mais dur - TheOperators->Add("*",new OneBinaryOperator< OppqR3dot, R3 >> () ); // "N" a faire mais dur TheOperators->Add("*",new OneBinaryOperator< OpR3dot, R3>> () ); // "N" a faire mais dur + TheOperators->Add("*", new OneBinaryOperator< OppqR3dot< double, Transpose< R3 * >, R3 > >( )); // "N" a faire mais dur TheOperators->Add("*",new OneBinaryOperator< OpR3dot, + // R3>> () ); // "N" a faire mais dur - TheOperators->Add("*",new opDotR3(atype< Transpose >(),atype() ) ); // "N" a faire mais dur + TheOperators->Add("*", new opDotR3(atype< Transpose< R3 * > >( ), atype< E_Array >( ))); // "N" a faire mais dur Global.New("qf1pT", CConstant< const QuadratureFormular * >(&QuadratureFormular_T_1)); Global.New("qf1pTlump", CConstant< const QuadratureFormular * >(&QuadratureFormular_T_1lump)); @@ -6259,8 +6019,7 @@ void init_lgfem( ) { Global.New("qfV1", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_1)); Global.New("qfV2", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_2)); Global.New("qfV5", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_5)); - Global.New("qfV1lump", - CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_1lump)); + Global.New("qfV1lump", CConstant< const GQuadratureFormular< R3 > * >(&QuadratureFormular_Tet_1lump)); // juste du code genere @@ -6268,42 +6027,42 @@ void init_lgfem( ) { Global.New("NoUseOfWait", CConstant< bool * >(&NoWait)); Global.New("NoGraphicWindow", CConstant< bool * >(&NoGraphicWindow)); - //Dcl_Type< MeshPoint * >( ); + // Dcl_Type< MeshPoint * >( ); Dcl_Type< finconnue * >( ); Dcl_Type< ftest * >( ); - + Dcl_Type< foperator * >( ); - Dcl_Type< const BC_set * >( ); // a set of boundary condition - Dcl_Type< const Call_FormLinear< v_fes > * >( ); // to set Vector - Dcl_Type< const Call_FormBilinear * >( ); // to set Matrix - Dcl_Type< const Call_FormLinear< v_fes3 > * >( ); // to set Vector 3D volume - Dcl_Type< const Call_FormBilinear * >( ); // to set Matrix 3D volume - Dcl_Type< const Call_FormLinear< v_fesS > * >( ); // to set Vector 3D surface - Dcl_Type< const Call_FormBilinear * >( ); // to set Matrix 3D surface - Dcl_Type< const Call_FormLinear< v_fesL > * >( ); // to set Vector 3D curve - Dcl_Type< const Call_FormBilinear * >( ); // to set Matrix 3D curve - - Dcl_Type< const Call_FormBilinear * >( ); // 3D curve / 2D on meshL - Dcl_Type< const Call_FormBilinear * >( ); // 2D / 3D curve on meshL - Dcl_Type< const Call_FormBilinear * >( ); // 3D Surf / 3D volume on meshS - Dcl_Type< const Call_FormBilinear * >( ); // 3D volume / 3D Surf on meshS - Dcl_Type< const Call_FormBilinear * >( ); // 3D curve / 3D Surf on meshL - Dcl_Type< const Call_FormBilinear * >( ); // 3D Surf / 3D curve on meshL and bem - Dcl_Type< const Call_FormBilinear * >( ); - - // Morice: composite FESpace / vect FESpace - Dcl_Type< vect_generic_v_fes ** >( ); // declare in line 6129 in lgfem ???? - Add("ndof",".",new OneOperator1(pVhcomp_ndof)); - - Dcl_Type< const Call_FormLinear< vect_generic_v_fes > * >( ); // to set Vector 3D curve - Dcl_Type< const Call_FormBilinear * >( ); - Dcl_Type< const Call_CompositeFormBilinear * >( ); - - Dcl_Type< interpolate_f_X_1< double >::type >( ); // to make interpolation x=f o X^1 ; + Dcl_Type< const BC_set * >( ); // a set of boundary condition + Dcl_Type< const Call_FormLinear< v_fes > * >( ); // to set Vector + Dcl_Type< const Call_FormBilinear< v_fes, v_fes > * >( ); // to set Matrix + Dcl_Type< const Call_FormLinear< v_fes3 > * >( ); // to set Vector 3D volume + Dcl_Type< const Call_FormBilinear< v_fes3, v_fes3 > * >( ); // to set Matrix 3D volume + Dcl_Type< const Call_FormLinear< v_fesS > * >( ); // to set Vector 3D surface + Dcl_Type< const Call_FormBilinear< v_fesS, v_fesS > * >( ); // to set Matrix 3D surface + Dcl_Type< const Call_FormLinear< v_fesL > * >( ); // to set Vector 3D curve + Dcl_Type< const Call_FormBilinear< v_fesL, v_fesL > * >( ); // to set Matrix 3D curve + + Dcl_Type< const Call_FormBilinear< v_fesL, v_fes > * >( ); // 3D curve / 2D on meshL + Dcl_Type< const Call_FormBilinear< v_fes, v_fesL > * >( ); // 2D / 3D curve on meshL + Dcl_Type< const Call_FormBilinear< v_fesS, v_fes3 > * >( ); // 3D Surf / 3D volume on meshS + Dcl_Type< const Call_FormBilinear< v_fes3, v_fesS > * >( ); // 3D volume / 3D Surf on meshS + Dcl_Type< const Call_FormBilinear< v_fesL, v_fesS > * >( ); // 3D curve / 3D Surf on meshL + Dcl_Type< const Call_FormBilinear< v_fesS, v_fesL > * >( ); // 3D Surf / 3D curve on meshL and bem + Dcl_Type< const Call_FormBilinear< v_fesS, v_fes > * >( ); + + // Morice: composite FESpace / vect FESpace + Dcl_Type< vect_generic_v_fes ** >( ); // declare in line 6129 in lgfem ???? + Add< vect_generic_v_fes ** >("ndof", ".", new OneOperator1< long, vect_generic_v_fes ** >(pVhcomp_ndof)); + + Dcl_Type< const Call_FormLinear< vect_generic_v_fes > * >( ); // to set Vector 3D curve + Dcl_Type< const Call_FormBilinear< vect_generic_v_fes, vect_generic_v_fes > * >( ); + Dcl_Type< const Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes > * >( ); + + Dcl_Type< interpolate_f_X_1< double >::type >( ); // to make interpolation x=f o X^1 ; map_type[typeid(const FormBilinear *).name( )] = new TypeFormBilinear; map_type[typeid(const FormLinear *).name( )] = new TypeFormLinear; - + aType t_C_args = map_type[typeid(const C_args *).name( )] = new TypeFormOperator; map_type[typeid(const Problem *).name( )] = new TypeSolve< false, Problem >; map_type[typeid(const Solve *).name( )] = new TypeSolve< true, Solve >; @@ -6315,12 +6074,12 @@ void init_lgfem( ) { basicForEachType *t_flin = atype< const FormLinear * >( ); basicForEachType *t_BC = atype< const BC_set * >( ); - + /// Doxygen doc basicForEachType *t_form = atype< const C_args * >( ); - + Dcl_Type< const CDomainOfIntegration * >( ); - + atype< pmesh >( )->AddCast(new E_F1_funcT< pmesh, pmesh * >(UnRef< pmesh >)); atype< pfes >( )->AddCast(new E_F1_funcT< pfes, pfes * >(UnRef< pfes >)); @@ -6338,7 +6097,7 @@ void init_lgfem( ) { Add< MeshPoint * >("nuTriangle", ".", new OneOperator1< long, MeshPoint * >(mp_nuTriangle)); Add< MeshPoint * >("region", ".", new OneOperator1< long, MeshPoint * >(mp_region)); - + Add< pfer >("refresh", ".", new OneOperator1< bool, pfer >(pfer_refresh< R, v_fes >)); Add< pfec >("refresh", ".", new OneOperator1< bool, pfec >(pfer_refresh< Complex, v_fes >)); @@ -6350,8 +6109,7 @@ void init_lgfem( ) { Add< pmesh * >("area", ".", new OneOperator1< double, pmesh * >(pmesh_area)); Add< pmesh * >("mesure", ".", new OneOperator1< double, pmesh * >(pmesh_area)); Add< pmesh * >("measure", ".", new OneOperator1< double, pmesh * >(pmesh_area)); - Add< pmesh * >("bordermeasure", ".", - new OneOperator1< double, pmesh * >(pmesh_bordermeasure)); // add june 2017 F.H + Add< pmesh * >("bordermeasure", ".", new OneOperator1< double, pmesh * >(pmesh_bordermeasure)); // add june 2017 F.H Add< pmesh * >("nt", ".", new OneOperator1< long, pmesh * >(pmesh_nt)); Add< pmesh * >("nbe", ".", new OneOperator1< long, pmesh * >(pmesh_nbe)); @@ -6396,82 +6154,70 @@ void init_lgfem( ) { // old -- // init FESpace - TheOperators->Add( - "<-", new OneOperator2_< pfes *, pfes *, pmesh * >(&MakePtr2), - //new OneOperatorCode< OP_MakePtrGeneric >, // Morice - new OpMake_pvectgenericfes, - new OneOperatorCode< OP_MakePtr2 >, new OneOperatorCode< OP_MakePtr3 >, - new OneOperatorCode< OP_MakePtrS >, new OneOperatorCode< OP_MakePtrL >, - new OpMake_pfes< pfes, Mesh, TypeOfFE, pfes_tefk >, - new OpMake_pfes< pfes3, Mesh3, TypeOfFE3, pfes3_tefk >, - new OpMake_pfes< pfesS, MeshS, TypeOfFES, pfesS_tefk >, // add for 3D surface FEspace - new OpMake_pfes< pfesL, MeshL, TypeOfFEL, pfesL_tefk >); - TheOperators->Add("=", new OneOperator2< R3 *, R3 *, R3 * >(&set_eqp,2)); + TheOperators->Add("<-", new OneOperator2_< pfes *, pfes *, pmesh * >(&MakePtr2), + // new OneOperatorCode< OP_MakePtrGeneric >, // Morice + new OpMake_pvectgenericfes, new OneOperatorCode< OP_MakePtr2 >, new OneOperatorCode< OP_MakePtr3 >, new OneOperatorCode< OP_MakePtrS >, new OneOperatorCode< OP_MakePtrL >, + new OpMake_pfes< pfes, Mesh, TypeOfFE, pfes_tefk >, new OpMake_pfes< pfes3, Mesh3, TypeOfFE3, pfes3_tefk >, + new OpMake_pfes< pfesS, MeshS, TypeOfFES, pfesS_tefk >, // add for 3D surface FEspace + new OpMake_pfes< pfesL, MeshL, TypeOfFEL, pfesL_tefk >); + TheOperators->Add("=", new OneOperator2< R3 *, R3 *, R3 * >(&set_eqp, 2)); Add< MeshPoint * >("P", ".", new OneOperator_Ptr_o_R< R3, MeshPoint >(&MeshPoint::P)); Add< MeshPoint * >("N", ".", new OneOperator_Ptr_o_R< R3, MeshPoint >(&MeshPoint::N)); Add< R3 * >("x", ".", new OneOperator_Ptr_o_R< R, R3 >(&R3::x)); Add< R3 * >("y", ".", new OneOperator_Ptr_o_R< R, R3 >(&R3::y)); Add< R3 * >("z", ".", new OneOperator_Ptr_o_R< R, R3 >(&R3::z)); - Add< Transpose >("x", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::x)); - Add< Transpose >("y", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::y)); - Add< Transpose >("z", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::z)); + Add< Transpose< R3 * > >("x", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::x)); + Add< Transpose< R3 * > >("y", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::y)); + Add< Transpose< R3 * > >("z", ".", new OneOperator_trans_Ptr_o_R< R3 >(&R3::z)); Add< R2 * >("x", ".", new OneOperator_Ptr_o_R< R, R2 >(&R2::x)); Add< R2 * >("y", ".", new OneOperator_Ptr_o_R< R, R2 >(&R2::y)); Add< R3 * >("[", "", new OneOperator2< double, R3 *, long >(get_R3)); -// ADD dec 2021 to R3 computation ... - map_type[typeid(R3).name()]->AddCast( - new E_F1_funcT(UnRef)); - TheOperators->Add("<-",new OneOperator4_(initR3)); - TheOperators->Add("<-",new OneOperator3_(initR3)); - - TheOperators->Add("=", - new OneBinaryOperator ,OneBinaryOperatorMIWO >, - new OneBinaryOperator ,OneBinaryOperatorMIWO >); - TheOperators->Add("<-", - new OneOperator2_(&set_copyp), - new OneOperator2_(&set_copyp)); // - TheOperators->Add("^", new OneOperator2_(CrossProduct)); - Global.Add("det", "(",new OneOperator3_(Det)); - TheOperators->Add("+", new OneBinaryOperator >); - TheOperators->Add(".*", new OneBinaryOperator >); - TheOperators->Add("./", new OneBinaryOperator >); - TheOperators->Add("-", new OneBinaryOperator >); - TheOperators->Add("*", new OneBinaryOperator >); - TheOperators->Add("/", new OneBinaryOperator >); - TheOperators->Add("*", new OneBinaryOperator >); - TheOperators->Add("+=", new OneBinaryOperator,OneBinaryOperatorMIWO >); - TheOperators->Add("-=", new OneBinaryOperator,OneBinaryOperatorMIWO >); - TheOperators->Add("*=", new OneBinaryOperator,OneBinaryOperatorMIWO >); - TheOperators->Add("/=", new OneBinaryOperator,OneBinaryOperatorMIWO >); - TheOperators->Add("<<", new OneBinaryOperator >); - Add("<--","(",new OneOperator3_(toR3)); - Add("<--","(",new OneOperator2_(toR3)); - Add("norm",".",new OneOperator1_(Norme2)); - Add("norm2",".",new OneOperator1_(Norme2_2)); - Add("l2",".",new OneOperator1_(Norme2)); - Add("linfty",".",new OneOperator1_(Norme_infty)); - Add("norm",".",new OneOperator1_(Norme2)); - Add("norm2",".",new OneOperator1_(Norme2_2)); - Add("l2",".",new OneOperator1_(Norme2)); - Add("linfty",".",new OneOperator1_(Norme_infty)); - Add("<--","(",new OneOperator3_(toR3)); - Add("<--","(",new OneOperator2_(toR3)); - - - -// end add + // ADD dec 2021 to R3 computation ... + map_type[typeid(R3).name( )]->AddCast(new E_F1_funcT< R3, R3 * >(UnRef< R3 >)); + TheOperators->Add("<-", new OneOperator4_< R3 *, R3 *, R, R, R >(initR3)); + TheOperators->Add("<-", new OneOperator3_< R3 *, R3 *, R3, R3 >(initR3)); + + TheOperators->Add("=", new OneBinaryOperator< set_eq< R3 >, OneBinaryOperatorMIWO >, new OneBinaryOperator< set_eq< R2 >, OneBinaryOperatorMIWO >); + TheOperators->Add("<-", new OneOperator2_< R3 *, R3 *, R3 >(&set_copyp), new OneOperator2_< R2 *, R2 *, R2 >(&set_copyp)); // + TheOperators->Add("^", new OneOperator2_< R3, R3, R3 >(CrossProduct)); + Global.Add("det", "(", new OneOperator3_< R, R3, R3, R3 >(Det)); + TheOperators->Add("+", new OneBinaryOperator< Op2_add< R3, R3, R3 > >); + TheOperators->Add(".*", new OneBinaryOperator< Op2_DotStar< R3, R3, R3 > >); + TheOperators->Add("./", new OneBinaryOperator< Op2_DotDiv< R3, R3, R3 > >); + TheOperators->Add("-", new OneBinaryOperator< Op2_sub< R3, R3, R3 > >); + TheOperators->Add("*", new OneBinaryOperator< Op2_mull< R3, R, R3 > >); + TheOperators->Add("/", new OneBinaryOperator< Op2_divv< R3, R3, R > >); + TheOperators->Add("*", new OneBinaryOperator< Op2_mull< R3, R2, R > >); + TheOperators->Add("+=", new OneBinaryOperator< set_eq_add< R3 >, OneBinaryOperatorMIWO >); + TheOperators->Add("-=", new OneBinaryOperator< set_eq_sub< R3 >, OneBinaryOperatorMIWO >); + TheOperators->Add("*=", new OneBinaryOperator< set_eq_mul< R3, R >, OneBinaryOperatorMIWO >); + TheOperators->Add("/=", new OneBinaryOperator< set_eq_div< R3, R >, OneBinaryOperatorMIWO >); + TheOperators->Add("<<", new OneBinaryOperator< Print< R3 > >); + Add< R3 * >("<--", "(", new OneOperator3_< R3, R, R, R >(toR3)); + Add< R3 * >("<--", "(", new OneOperator2_< R3, R3, R3 >(toR3)); + Add< R3 * >("norm", ".", new OneOperator1_< R, R3 >(Norme2)); + Add< R3 * >("norm2", ".", new OneOperator1_< R, R3 >(Norme2_2)); + Add< R3 * >("l2", ".", new OneOperator1_< R, R3 >(Norme2)); + Add< R3 * >("linfty", ".", new OneOperator1_< R, R3 >(Norme_infty)); + Add< R3 >("norm", ".", new OneOperator1_< R, R3 >(Norme2)); + Add< R3 >("norm2", ".", new OneOperator1_< R, R3 >(Norme2_2)); + Add< R3 >("l2", ".", new OneOperator1_< R, R3 >(Norme2)); + Add< R3 >("linfty", ".", new OneOperator1_< R, R3 >(Norme_infty)); + Add< R3 >("<--", "(", new OneOperator3_< R3, R, R, R >(toR3)); + Add< R3 >("<--", "(", new OneOperator2_< R3, R3, R3 >(toR3)); + + // end add Add< pmesh >("[", "", new OneOperator2_< lgElement, pmesh, long >(get_element)); Add< pmesh * >("be", ".", new OneOperator1_< lgBoundaryEdge::BE, pmesh * >(Build)); Add< lgElement >("adj", ".", new OneOperator1_< lgElement::Adj, lgElement >(Build)); - Add< lgBoundaryEdge::BE >( - "(", "", new OneOperator2_< lgBoundaryEdge, lgBoundaryEdge::BE, long >(get_belement)); + Add< lgBoundaryEdge::BE >("(", "", new OneOperator2_< lgBoundaryEdge, lgBoundaryEdge::BE, long >(get_belement)); Add< lgElement::Adj >("(", "", new OneOperator2_< lgElement, lgElement::Adj, long * >(get_adj)); - Add("N",".",new OneOperator1_(NElement)); + Add< lgBoundaryEdge >("N", ".", new OneOperator1_< R3, lgBoundaryEdge >(NElement)); TheOperators->Add("==", new OneBinaryOperator< Op2_eq< lgElement, lgElement > >); TheOperators->Add("!=", new OneBinaryOperator< Op2_ne< lgElement, lgElement > >); @@ -6485,7 +6231,7 @@ void init_lgfem( ) { Add< lgElement >("[", "", new OneOperator2_< lgVertex, lgElement, long >(get_element)); Add< lgBoundaryEdge >("[", "", new OneOperator2_< lgVertex, lgBoundaryEdge, long >(get_belement)); - Add< lgVertex >("P", ".", new OneOperator1_< R3, lgVertex >(getP));// Jan 2022 FH + Add< lgVertex >("P", ".", new OneOperator1_< R3, lgVertex >(getP)); // Jan 2022 FH Add< lgVertex >("x", ".", new OneOperator1_< R, lgVertex >(getx)); Add< lgVertex >("y", ".", new OneOperator1_< R, lgVertex >(gety)); Add< lgVertex >("label", ".", new OneOperator1_< long, lgVertex >(getlab)); @@ -6517,7 +6263,7 @@ void init_lgfem( ) { zzzfff->Add("meshS", atype< pmeshS * >( )); // pmeshL is a pointer to MeshL defined at [[file:lgfem.hpp::typedef MeshL pmeshL]] zzzfff->Add("meshL", atype< pmeshL * >( )); - + zzzfff->Add("element", atype< lgElement >( )); zzzfff->Add("vertex", atype< lgVertex >( )); zzzfff->Add("matrix", atype< Matrice_Creuse< R > * >( )); @@ -6527,20 +6273,20 @@ void init_lgfem( ) { Global.Add("LinearGMRES", "(", new LinearGMRES< R >( )); // old form Global.Add("LinearGMRES", "(", new LinearGMRES< R >(1)); // old form without rhs Global.Add("AffineGMRES", "(", new LinearGMRES< R >(1)); // New better - // add FH 25/01/22 - Global.Add("AffineFGMRES", "(", new LinearFGMRES(1)); // New better - Global.Add("AffineFGMRES", "(", new LinearFGMRES(1)); // New better - Global.Add("LinearFGMRES", "(", new LinearFGMRES()); // New better - Global.Add("LinearFGMRES", "(", new LinearFGMRES()); // New better - // end add - Global.Add("LinearCG", "(", new LinearCG< R >(1)); // without right handsize - Global.Add("AffineCG", "(", new LinearCG< R >(1)); // without right handsize - Global.Add("NLCG", "(", new LinearCG< R >(-1)); // without right handsize + // add FH 25/01/22 + Global.Add("AffineFGMRES", "(", new LinearFGMRES< double >(1)); // New better + Global.Add("AffineFGMRES", "(", new LinearFGMRES< Complex >(1)); // New better + Global.Add("LinearFGMRES", "(", new LinearFGMRES< double >( )); // New better + Global.Add("LinearFGMRES", "(", new LinearFGMRES< Complex >( )); // New better + // end add + Global.Add("LinearCG", "(", new LinearCG< R >(1)); // without right handsize + Global.Add("AffineCG", "(", new LinearCG< R >(1)); // without right handsize + Global.Add("NLCG", "(", new LinearCG< R >(-1)); // without right handsize zzzfff->AddF("varf", t_form); // var. form ~ <> zzzfff->AddF("solve", t_solve); zzzfff->AddF("problem", t_problem); - + Global.Add("jump", "(", new OneOperatorCode< Code_VF< Ftest, Code_Jump > >); Global.Add("jump", "(", new OneOperatorCode< Code_VF< Finconnue, Code_Jump > >); Global.Add("average", "(", new OneOperatorCode< Code_VF< Ftest, Code_Mean > >); @@ -6578,77 +6324,50 @@ void init_lgfem( ) { /// [[file:AFunction.hpp::Global]] Global.Add("plot", "(", new OneOperatorCode< Plot >); Global.Add("convect", "(", new OneOperatorCode< Convect >); - - TheOperators->Add("+", new OneOperatorCode< CODE_L_Add< Foperator > >, - new OneOperatorCode< CODE_L_Add< Ftest > >, - new OneOperatorCode< CODE_L_Add< Finconnue > >, - new OneOperatorCode< C_args >(t_C_args, t_C_args, t_C_args) - ); - TheOperators->Add("-", new OneOperatorCode< CODE_L_Minus< Foperator > >, - new OneOperatorCode< CODE_L_Minus< Ftest > >, - new OneOperatorCode< CODE_L_Minus< Finconnue > >, - new OneOperatorCode< CODE_L_Sub< Foperator > >, - new OneOperatorCode< CODE_L_Sub< Ftest > >, - new OneOperatorCode< CODE_L_Sub< Finconnue > >, - new OneOperatorCode< C_args_minus >(t_C_args, t_C_args, t_fbilin), - new OneOperatorCode< C_args_minus >(t_C_args, t_C_args, t_flin), - new OneOperatorCode< Minus_Form< FormBilinear > >, - new OneOperatorCode< Minus_Form< FormLinear > > - ); + TheOperators->Add("+", new OneOperatorCode< CODE_L_Add< Foperator > >, new OneOperatorCode< CODE_L_Add< Ftest > >, new OneOperatorCode< CODE_L_Add< Finconnue > >, + new OneOperatorCode< C_args >(t_C_args, t_C_args, t_C_args)); + TheOperators->Add("-", new OneOperatorCode< CODE_L_Minus< Foperator > >, new OneOperatorCode< CODE_L_Minus< Ftest > >, new OneOperatorCode< CODE_L_Minus< Finconnue > >, + new OneOperatorCode< CODE_L_Sub< Foperator > >, new OneOperatorCode< CODE_L_Sub< Ftest > >, new OneOperatorCode< CODE_L_Sub< Finconnue > >, + new OneOperatorCode< C_args_minus >(t_C_args, t_C_args, t_fbilin), new OneOperatorCode< C_args_minus >(t_C_args, t_C_args, t_flin), + new OneOperatorCode< Minus_Form< FormBilinear > >, new OneOperatorCode< Minus_Form< FormLinear > > - atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, t_fbilin), - new OneOperatorCode< C_args >(t_C_args, t_flin), - new OneOperatorCode< C_args >(t_C_args, t_BC) ); - atype< const C_args * >( )->AddCast( - new OneOperatorCode< C_args >(t_C_args, atype< DotSlash_KN_< R > >( )), - new OneOperatorCode< C_args >(t_C_args, atype< KN< R > * >( )), - new OneOperatorCode< C_args >(t_C_args, atype< DotStar_KN_< R > >( )), - new OneOperatorCode< C_args >(t_C_args, atype< Matrice_Creuse< R > * >( )), - new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< R >::plusAx >( )), - new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< R >::plusAtx >( )) + atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, t_fbilin), new OneOperatorCode< C_args >(t_C_args, t_flin), new OneOperatorCode< C_args >(t_C_args, t_BC)); + + atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, atype< DotSlash_KN_< R > >( )), new OneOperatorCode< C_args >(t_C_args, atype< KN< R > * >( )), + new OneOperatorCode< C_args >(t_C_args, atype< DotStar_KN_< R > >( )), new OneOperatorCode< C_args >(t_C_args, atype< Matrice_Creuse< R > * >( )), + new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< R >::plusAx >( )), + new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< R >::plusAtx >( )) ); - atype< const C_args * >( )->AddCast( - new OneOperatorCode< C_args >(t_C_args, atype< DotSlash_KN_< Complex > >( )), - new OneOperatorCode< C_args >(t_C_args, atype< KN< Complex > * >( )), - new OneOperatorCode< C_args >(t_C_args, atype< DotStar_KN_< Complex > >( )), - new OneOperatorCode< C_args >(t_C_args, atype< Matrice_Creuse< Complex > * >( )), - new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< Complex >::plusAx >( )), - new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< Complex >::plusAtx >( )) + atype< const C_args * >( )->AddCast(new OneOperatorCode< C_args >(t_C_args, atype< DotSlash_KN_< Complex > >( )), new OneOperatorCode< C_args >(t_C_args, atype< KN< Complex > * >( )), + new OneOperatorCode< C_args >(t_C_args, atype< DotStar_KN_< Complex > >( )), new OneOperatorCode< C_args >(t_C_args, atype< Matrice_Creuse< Complex > * >( )), + new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< Complex >::plusAx >( )), + new OneOperatorCode< C_args >(t_C_args, atype< RNM_VirtualMatrix< Complex >::plusAtx >( )) ); - TheOperators->Add("*", new OneOperatorCode< CODE_L_Mul< Foperator, Ftest, Finconnue > >, - new OneOperatorCode< CODE_L_Mul< Foperator, Finconnue, Ftest > >); + TheOperators->Add("*", new OneOperatorCode< CODE_L_Mul< Foperator, Ftest, Finconnue > >, new OneOperatorCode< CODE_L_Mul< Foperator, Finconnue, Ftest > >); // Warning just double or complex in following operator // ---------------------------------------------------- // in case of ambiguity we take the double version // case long -> double // long -> complex - TheOperators->Add("*", new OneOperatorCode< CODE_L_MulLR< Finconnue, double >, 20 >, - new OneOperatorCode< CODE_L_MulLR< Foperator, double >, 20 >, - new OneOperatorCode< CODE_L_MulLR< Ftest, double >, 20 >, - new OneOperatorCode< CODE_L_MulRL< double, Finconnue >, 20 >, - new OneOperatorCode< CODE_L_MulRL< double, Foperator >, 20 >, - new OneOperatorCode< CODE_L_MulRL< double, Ftest >, 20 >); - TheOperators->Add("*", new OneOperatorCode< CODE_L_MulLR< Finconnue, Complex >, 10 >, - new OneOperatorCode< CODE_L_MulLR< Foperator, Complex >, 10 >, - new OneOperatorCode< CODE_L_MulLR< Ftest, Complex >, 10 >, - new OneOperatorCode< CODE_L_MulRL< Complex, Finconnue >, 10 >, - new OneOperatorCode< CODE_L_MulRL< Complex, Foperator >, 10 >, - new OneOperatorCode< CODE_L_MulRL< Complex, Ftest >, 10 >); - - TheOperators->Add("/", new OneOperatorCode< CODE_L_DivLR< Finconnue, double >, 20 >, - new OneOperatorCode< CODE_L_DivLR< Foperator, double >, 20 >, + TheOperators->Add("*", new OneOperatorCode< CODE_L_MulLR< Finconnue, double >, 20 >, new OneOperatorCode< CODE_L_MulLR< Foperator, double >, 20 >, + new OneOperatorCode< CODE_L_MulLR< Ftest, double >, 20 >, new OneOperatorCode< CODE_L_MulRL< double, Finconnue >, 20 >, + new OneOperatorCode< CODE_L_MulRL< double, Foperator >, 20 >, new OneOperatorCode< CODE_L_MulRL< double, Ftest >, 20 >); + TheOperators->Add("*", new OneOperatorCode< CODE_L_MulLR< Finconnue, Complex >, 10 >, new OneOperatorCode< CODE_L_MulLR< Foperator, Complex >, 10 >, + new OneOperatorCode< CODE_L_MulLR< Ftest, Complex >, 10 >, new OneOperatorCode< CODE_L_MulRL< Complex, Finconnue >, 10 >, + new OneOperatorCode< CODE_L_MulRL< Complex, Foperator >, 10 >, new OneOperatorCode< CODE_L_MulRL< Complex, Ftest >, 10 >); + + TheOperators->Add("/", new OneOperatorCode< CODE_L_DivLR< Finconnue, double >, 20 >, new OneOperatorCode< CODE_L_DivLR< Foperator, double >, 20 >, new OneOperatorCode< CODE_L_DivLR< Ftest, double >, 20 >); - TheOperators->Add("/", new OneOperatorCode< CODE_L_DivLR< Finconnue, Complex >, 10 >, - new OneOperatorCode< CODE_L_DivLR< Foperator, Complex >, 10 >, + TheOperators->Add("/", new OneOperatorCode< CODE_L_DivLR< Finconnue, Complex >, 10 >, new OneOperatorCode< CODE_L_DivLR< Foperator, Complex >, 10 >, new OneOperatorCode< CODE_L_DivLR< Ftest, Complex >, 10 >); // Warning just double or complex in previous operator @@ -6656,174 +6375,136 @@ void init_lgfem( ) { // TheOperators->Add("=",new OneOperatorCode >); - TheOperators->Add( - "=", new OneOperator2< pmesh *, pmesh *, pmesh >(&set_eqdestroy_incr), - - new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::plusAx > >, - new OneBinaryOperator< - set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::plusAtx > >, // ZZ set_eq_array - new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::solveAxeqb > >, - new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::solveAtxeqb > >, - - new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN_< double > >( ), false, false), - new OpMatrixtoBilinearForm< double, Mesh, v_fes, v_fes >); - - TheOperators->Add("=", - new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN_< double > >( ), false, false), // 3D volume - new OpMatrixtoBilinearForm< double, Mesh3, v_fes3, v_fes3 >, // 3D volume - new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN_< double > >( ), false, false), // 3D surface - new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fesS >, // 3D surface - new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN_< double > >( ), false, false), // 3D curve - new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fesL >, // 3D curve - new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fes >, // 3D curve / 2D on meshL - new OpMatrixtoBilinearForm< double, MeshL, v_fes, v_fesL >, // 2D / 3D curve on meshL - new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fes3 >, // 3D Surf / 3D volume on meshS - new OpMatrixtoBilinearForm< double, MeshS, v_fes3, v_fesS >, // 3D volume / 3D Surf on meshS - new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fesS >, // 3D curve / 3D Surf on meshL - new OpMatrixtoBilinearForm< double, MeshL, v_fesS, v_fesL >); // 3D Surf / 3D curve on meshL - - TheOperators->Add( - "<-", new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN< double > * >( ), true, true), - new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN< Complex > * >( ), true, true), - new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN< double > * >( ), true, true), // 3D volume - new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN< Complex > * >( ), true, true), // 3D volume - new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN< double > * >( ), true, true), // 3D surface - new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN< Complex > * >( ), true, true), // 3D surface - new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN< double > * >( ), true, true), // 3D curve - new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN< Complex > * >( ), true, true) // 3D curve + TheOperators->Add("=", new OneOperator2< pmesh *, pmesh *, pmesh >(&set_eqdestroy_incr), + + new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::plusAx > >, + new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::plusAtx > >, // ZZ set_eq_array + new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::solveAxeqb > >, + new OneBinaryOperator< set_eq_array< KN_< double >, RNM_VirtualMatrix< R >::solveAtxeqb > >, + + new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN_< double > >( ), false, false), new OpMatrixtoBilinearForm< double, Mesh, v_fes, v_fes >); + + TheOperators->Add("=", new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN_< double > >( ), false, false), // 3D volume + new OpMatrixtoBilinearForm< double, Mesh3, v_fes3, v_fes3 >, // 3D volume + new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN_< double > >( ), false, false), // 3D surface + new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fesS >, // 3D surface + new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN_< double > >( ), false, false), // 3D curve + new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fesL >, // 3D curve + new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fes >, // 3D curve / 2D on meshL + new OpMatrixtoBilinearForm< double, MeshL, v_fes, v_fesL >, // 2D / 3D curve on meshL + new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fes3 >, // 3D Surf / 3D volume on meshS + new OpMatrixtoBilinearForm< double, MeshS, v_fes3, v_fesS >, // 3D volume / 3D Surf on meshS + new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fesS >, // 3D curve / 3D Surf on meshL + new OpMatrixtoBilinearForm< double, MeshL, v_fesS, v_fesL >); // 3D Surf / 3D curve on meshL + + TheOperators->Add("<-", new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN< double > * >( ), true, true), + new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN< Complex > * >( ), true, true), + new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN< double > * >( ), true, true), // 3D volume + new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN< Complex > * >( ), true, true), // 3D volume + new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN< double > * >( ), true, true), // 3D surface + new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN< Complex > * >( ), true, true), // 3D surface + new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN< double > * >( ), true, true), // 3D curve + new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN< Complex > * >( ), true, true) // 3D curve ); - TheOperators->Add( - "=", - new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, - new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, - new OneBinaryOperator< - set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::solveAxeqb > >, - new OneBinaryOperator< - set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::solveAtxeqb > >, - - new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN_< Complex > >( ), false, false), - // KN* -> KN_ FH Jan 2015 (Thank PJolivet) - new OpMatrixtoBilinearForm< Complex, Mesh, v_fes, v_fes >); - - TheOperators->Add("=", - new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN_< Complex > >( ), false, false), // 3D volume - new OpMatrixtoBilinearForm< Complex, Mesh3, v_fes3, v_fes3 >, // 3D volume - new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN_< Complex > >( ), false, false), // 3D surface - new OpMatrixtoBilinearForm< Complex, MeshS, v_fesS, v_fesS >, // 3D surface - new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN_< Complex > >( ), false, false), // 3D curve - new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fesL >, // 3D curve - new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fes >, // 3D curve / 2D on meshL - new OpMatrixtoBilinearForm< Complex, MeshL, v_fes, v_fesL >, // 2D / 3D curve on meshL - new OpMatrixtoBilinearForm< Complex, MeshS, v_fesS, v_fes3 >, // 3D Surf / 3D volume on meshS - new OpMatrixtoBilinearForm< Complex, MeshS, v_fes3, v_fesS >, // 3D volume / 3D Surf on meshS - new OpMatrixtoBilinearForm< Complex, MeshL, v_fesS, v_fesL >, // 3D Surf / 3D curve on meshL - new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL + TheOperators->Add("=", new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, + new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, + new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::solveAxeqb > >, + new OneBinaryOperator< set_eq_array< KN_< Complex >, RNM_VirtualMatrix< Complex >::solveAtxeqb > >, + + new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN_< Complex > >( ), false, false), + // KN* -> KN_ FH Jan 2015 (Thank PJolivet) + new OpMatrixtoBilinearForm< Complex, Mesh, v_fes, v_fes >); + + TheOperators->Add("=", new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN_< Complex > >( ), false, false), // 3D volume + new OpMatrixtoBilinearForm< Complex, Mesh3, v_fes3, v_fes3 >, // 3D volume + new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN_< Complex > >( ), false, false), // 3D surface + new OpMatrixtoBilinearForm< Complex, MeshS, v_fesS, v_fesS >, // 3D surface + new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN_< Complex > >( ), false, false), // 3D curve + new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fesL >, // 3D curve + new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fes >, // 3D curve / 2D on meshL + new OpMatrixtoBilinearForm< Complex, MeshL, v_fes, v_fesL >, // 2D / 3D curve on meshL + new OpMatrixtoBilinearForm< Complex, MeshS, v_fesS, v_fes3 >, // 3D Surf / 3D volume on meshS + new OpMatrixtoBilinearForm< Complex, MeshS, v_fes3, v_fesS >, // 3D volume / 3D Surf on meshS + new OpMatrixtoBilinearForm< Complex, MeshL, v_fesS, v_fesL >, // 3D Surf / 3D curve on meshL + new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL // add august 2007 TheOperators->Add( - "<-", - new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::plusAx > >, - new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::plusAtx > >, - new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::solveAxeqb > >, - new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::solveAtxeqb > >, - - new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, - new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, - new OneBinaryOperator< - init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::solveAxeqb > >, - new OneBinaryOperator< - init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::solveAtxeqb > > + "<-", new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::plusAx > >, new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::plusAtx > >, + new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::solveAxeqb > >, new OneBinaryOperator< init_eqarray< KN< double >, RNM_VirtualMatrix< double >::solveAtxeqb > >, + + new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, + new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::solveAxeqb > >, new OneBinaryOperator< init_eqarray< KN< Complex >, RNM_VirtualMatrix< Complex >::solveAtxeqb > > ); // Jan 2018 FH Vh uh=yu[]; // A FAIRE FH POUR F NATAF FFFFFFFF - TheOperators->Add( - "<-", new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::plusAx > >(10), - new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::solveAxeqb > >(10), - new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::solveAtxeqb > >(10), - new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::plusAtx > >(10), - new init_FE_eqarray< FFset3< R, v_fes, KN_< R > > >(10), - new init_FE_eqarray< FF_L_args< R, v_fes, Call_FormLinear< v_fes > > >(10) + TheOperators->Add("<-", new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::plusAx > >(10), new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::solveAxeqb > >(10), + new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::solveAtxeqb > >(10), new init_FE_eqarray< FFset3< R, v_fes, RNM_VirtualMatrix< R >::plusAtx > >(10), + new init_FE_eqarray< FFset3< R, v_fes, KN_< R > > >(10), new init_FE_eqarray< FF_L_args< R, v_fes, Call_FormLinear< v_fes > > >(10) ); TheOperators->Add( - "<-", new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::plusAx > >(10), - new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::solveAxeqb > >(10), - new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::solveAtxeqb > >(10), - new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::plusAtx > >(10), - new init_FE_eqarray< FFset3< Complex, v_fes, KN_< Complex > > >(10), - new init_FE_eqarray< FF_L_args< Complex, v_fes, Call_FormLinear< v_fes > > >(10)); - TheOperators->Add( - "<-", - new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::plusAx > >(10) // 3D volume - , - new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::solveAxeqb > >( - 10) // 3D volume - , - new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::plusAtx > >(10) // 3D volume - , - new init_FE_eqarray< FFset3< R, v_fes3, KN_< R > > >(10) // 3D volume - , - new init_FE_eqarray< FF_L_args< R, v_fes3, Call_FormLinear< v_fes3 > > >(10) // 3D volume + "<-", new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::plusAx > >(10), new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::solveAxeqb > >(10), + new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::solveAtxeqb > >(10), new init_FE_eqarray< FFset3< Complex, v_fes, RNM_VirtualMatrix< Complex >::plusAtx > >(10), + new init_FE_eqarray< FFset3< Complex, v_fes, KN_< Complex > > >(10), new init_FE_eqarray< FF_L_args< Complex, v_fes, Call_FormLinear< v_fes > > >(10)); + TheOperators->Add("<-", new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::plusAx > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::solveAxeqb > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< R, v_fes3, RNM_VirtualMatrix< R >::plusAtx > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< R, v_fes3, KN_< R > > >(10) // 3D volume + , + new init_FE_eqarray< FF_L_args< R, v_fes3, Call_FormLinear< v_fes3 > > >(10) // 3D volume ); - TheOperators->Add( - "<-", - new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::plusAx > >( - 10) // 3D volume - , - new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::solveAxeqb > >( - 10) // 3D volume - , - new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::plusAtx > >( - 10) // 3D volume - , - new init_FE_eqarray< FFset3< Complex, v_fes3, KN_< Complex > > >(10) // 3D volume - , - new init_FE_eqarray< FF_L_args< Complex, v_fes3, Call_FormLinear< v_fes3 > > >( - 10) // 3D volume + TheOperators->Add("<-", new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::plusAx > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::solveAxeqb > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< Complex, v_fes3, RNM_VirtualMatrix< Complex >::plusAtx > >(10) // 3D volume + , + new init_FE_eqarray< FFset3< Complex, v_fes3, KN_< Complex > > >(10) // 3D volume + , + new init_FE_eqarray< FF_L_args< Complex, v_fes3, Call_FormLinear< v_fes3 > > >(10) // 3D volume ); - Add_u_init_array(1); - Add_u_init_array(1); + Add_u_init_array< v_fesS >(1); + Add_u_init_array< v_fesL >(1); // Fin // Fin - TheOperators->Add( - "+=", - - new OneBinaryOperator< set_eq_array_add< KN_< double >, RNM_VirtualMatrix< double >::plusAx > >, - new OneBinaryOperator< - set_eq_array_add< KN_< double >, RNM_VirtualMatrix< double >::plusAtx > >, - - new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN_< double > >( ), false, false, false), - new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN_< double > >( ), false, false, - false), // 3D volume - new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN_< double > >( ), false, false, - false), // 3D surface - new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN_< double > >( ), false, false, - false) // 3D surface + TheOperators->Add("+=", + + new OneBinaryOperator< set_eq_array_add< KN_< double >, RNM_VirtualMatrix< double >::plusAx > >, + new OneBinaryOperator< set_eq_array_add< KN_< double >, RNM_VirtualMatrix< double >::plusAtx > >, + + new OpArraytoLinearForm< double, Mesh, v_fes >(atype< KN_< double > >( ), false, false, false), + new OpArraytoLinearForm< double, Mesh3, v_fes3 >(atype< KN_< double > >( ), false, false, + false), // 3D volume + new OpArraytoLinearForm< double, MeshS, v_fesS >(atype< KN_< double > >( ), false, false, + false), // 3D surface + new OpArraytoLinearForm< double, MeshL, v_fesL >(atype< KN_< double > >( ), false, false, + false) // 3D surface ); - TheOperators->Add( - "+=", + TheOperators->Add("+=", - new OneBinaryOperator< - set_eq_array_add< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, - new OneBinaryOperator< - set_eq_array_add< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, + new OneBinaryOperator< set_eq_array_add< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAx > >, + new OneBinaryOperator< set_eq_array_add< KN_< Complex >, RNM_VirtualMatrix< Complex >::plusAtx > >, - new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN_< Complex > >( ), false, false, false), + new OpArraytoLinearForm< Complex, Mesh, v_fes >(atype< KN_< Complex > >( ), false, false, false), - new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN_< Complex > >( ), false, false, - false), // 3D volume - new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN_< Complex > >( ), false, false, - false), // 3D surface - new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN_< Complex > >( ), false, false, - false) // 3D curve + new OpArraytoLinearForm< Complex, Mesh3, v_fes3 >(atype< KN_< Complex > >( ), false, false, + false), // 3D volume + new OpArraytoLinearForm< Complex, MeshS, v_fesS >(atype< KN_< Complex > >( ), false, false, + false), // 3D surface + new OpArraytoLinearForm< Complex, MeshL, v_fesL >(atype< KN_< Complex > >( ), false, false, + false) // 3D curve ); TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, Mesh, v_fes, v_fes >(1)); TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, Mesh, v_fes, v_fes >(1)); - TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, Mesh3, v_fes3,v_fes3 >(1)); // 3D volume + TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, Mesh3, v_fes3, v_fes3 >(1)); // 3D volume TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, Mesh3, v_fes3, v_fes3 >(1)); // 3D volume TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fesS >(1)); // 3D surface @@ -6832,10 +6513,10 @@ void init_lgfem( ) { TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fesL >(1)); // 3D curve TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fesL >(1)); // 3D curve - TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fes >(1)); // 3D curve / 2D on meshL - TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fes >(1)); // 3D curve / 2D on meshL - TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fes, v_fesL >(1)); // 2D / 3D curve on meshL - TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fes, v_fesL >(1)); // 2D / 3D curve on meshL + TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fesL, v_fes >(1)); // 3D curve / 2D on meshL + TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fesL, v_fes >(1)); // 3D curve / 2D on meshL + TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fes, v_fesL >(1)); // 2D / 3D curve on meshL + TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fes, v_fesL >(1)); // 2D / 3D curve on meshL TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshS, v_fesS, v_fes3 >(1)); // 3D Surf / 3D volume on meshS TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshS, v_fesS, v_fes3 >(1)); // 3D Surf / 3D volume on meshS TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshS, v_fes3, v_fesS >(1)); // 3D volume / 3D Surf on meshS @@ -6845,29 +6526,22 @@ void init_lgfem( ) { TheOperators->Add("<-", new OpMatrixtoBilinearForm< double, MeshL, v_fesS, v_fesL >(1)); // 3D Surf / 3D curve on meshL TheOperators->Add("<-", new OpMatrixtoBilinearForm< Complex, MeshL, v_fesS, v_fesL >(1)); // 3D Surf / 3D curve on meshL - // constructions d'une matrice à partir d'une forme bilinéaire dans le cas composite FESpace. - TheOperators->Add("<-", new OpMatrixtoBilinearFormVG< double >(1)); // - TheOperators->Add("<-", new OpMatrixtoBilinearFormVG< Complex >(1)); // + TheOperators->Add("<-", new OpMatrixtoBilinearFormVG< double >(1)); // + TheOperators->Add("<-", new OpMatrixtoBilinearFormVG< Complex >(1)); // - // affectation d'une matrice à partir d'une forme bilinéaire dans le cas composite FESpace. - // missing FH .. - TheOperators->Add("=", new OpMatrixtoBilinearFormVG< double >()); // - TheOperators->Add("=", new OpMatrixtoBilinearFormVG< Complex >()); // + // affectation d'une matrice à partir d'une forme bilinéaire dans le cas composite FESpace. + // missing FH .. + TheOperators->Add("=", new OpMatrixtoBilinearFormVG< double >( )); // + TheOperators->Add("=", new OpMatrixtoBilinearFormVG< Complex >( )); // // construction of an array with an linear form in composite FESpace. - TheOperators->Add("<-", - new OpArraytoLinearFormVG< double >(atype< KN< double > * >( ), true, true), - new OpArraytoLinearFormVG< Complex >(atype< KN< Complex > * >( ), true, true) ); + TheOperators->Add("<-", new OpArraytoLinearFormVG< double >(atype< KN< double > * >( ), true, true), new OpArraytoLinearFormVG< Complex >(atype< KN< Complex > * >( ), true, true)); - TheOperators->Add("=", - new OpArraytoLinearFormVG< double >(atype< KN_< double > >( ), false, false), - new OpArraytoLinearFormVG< Complex >(atype< KN_< Complex > >( ), false, false) - ); + TheOperators->Add("=", new OpArraytoLinearFormVG< double >(atype< KN_< double > >( ), false, false), new OpArraytoLinearFormVG< Complex >(atype< KN_< Complex > >( ), false, false)); - TheOperators->Add("+=", - new OpArraytoLinearFormVG< double >(atype< KN_< double > >( ), false, false, false), // real - new OpArraytoLinearFormVG< Complex >(atype< KN_< Complex > >( ), false, false, false) // complex + TheOperators->Add("+=", new OpArraytoLinearFormVG< double >(atype< KN_< double > >( ), false, false, false), // real + new OpArraytoLinearFormVG< Complex >(atype< KN_< Complex > >( ), false, false, false) // complex ); Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fes >); @@ -6876,47 +6550,46 @@ void init_lgfem( ) { Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fes >); Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes, v_fes >); - Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fes3 >); // 3D volume - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear,v_fes3, v_fes3 >); // 3D volume - Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fes3 >); // 3D volume - Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fes3 >); // 3D volume - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes3, v_fes3 >); // 3D volume + Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fes3 >); // 3D volume + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fes3, v_fes3 >); // 3D volume + Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fes3 >); // 3D volume + Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fes3 >); // 3D volume + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes3, v_fes3 >); // 3D volume - Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fesS >); // 3D surface + Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fesS >); // 3D surface Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fesS >); // 3D surface - Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fesS >); // 3D surface - Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fesS >); // 3D surface - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fesS >); // 3D surface + Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fesS >); // 3D surface + Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fesS >); // 3D surface + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fesS >); // 3D surface - Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fesL >); // 3D curve + Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, v_fesL >); // 3D curve Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesL, v_fesL >); // 3D curve - Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fesL >); // 3D curve - Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fesL >); // 3D curve - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fesL >); // 3D curve - - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fes >); // 3D curve / 2D on meshL - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes, v_fesL>); // 2D / 3D curve on meshL + Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, v_fesL >); // 3D curve + Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, v_fesL >); // 3D curve + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fesL >); // 3D curve + + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fes >); // 3D curve / 2D on meshL + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes, v_fesL >); // 2D / 3D curve on meshL Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fes >); - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fes3 >); // 3D Surf / 3D volume on meshS - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes3, v_fesS >); // 3D volume / 3D Surf on meshS - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL - Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fesL>); // 3D Surf / 3D curve on meshL + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fes3 >); // 3D Surf / 3D volume on meshS + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fes3, v_fesS >); // 3D volume / 3D Surf on meshS + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL + Add< const C_args * >("(", "", new OpCall_FormBilinear< C_args, v_fesS, v_fesL >); // 3D Surf / 3D curve on meshL - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesL, v_fes >); // 3D curve / 2D on meshL - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fes, v_fesL >); // 2D / 3D curve on meshL + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesL, v_fes >); // 3D curve / 2D on meshL + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fes, v_fesL >); // 2D / 3D curve on meshL Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fes >); - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fes3 >); // 3D Surf / 3D volume on meshS - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fes3, v_fesS >); // 3D volume / 3D Surf on meshS - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL - Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fesL >); // 3D Surf / 3D curve on meshL - - // Morice: composite FESpace / composite FESpace - Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, vect_generic_v_fes >); - Add< const FormBilinear * >("(", "", new OpCall_CompositeFormBilinear< FormBilinear, vect_generic_v_fes , vect_generic_v_fes >); - Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, vect_generic_v_fes >); - Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, vect_generic_v_fes >); - Add< const C_args * >("(", "", new OpCall_CompositeFormBilinear< C_args, vect_generic_v_fes, vect_generic_v_fes >); - + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fes3 >); // 3D Surf / 3D volume on meshS + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fes3, v_fesS >); // 3D volume / 3D Surf on meshS + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesL, v_fesS >); // 3D curve / 3D Surf on meshL + Add< const FormBilinear * >("(", "", new OpCall_FormBilinear< FormBilinear, v_fesS, v_fesL >); // 3D Surf / 3D curve on meshL + + // Morice: composite FESpace / composite FESpace + Add< const FormLinear * >("(", "", new OpCall_FormLinear< FormLinear, vect_generic_v_fes >); + Add< const FormBilinear * >("(", "", new OpCall_CompositeFormBilinear< FormBilinear, vect_generic_v_fes, vect_generic_v_fes >); + Add< const FormBilinear * >("(", "", new OpCall_FormLinear2< FormBilinear, vect_generic_v_fes >); + Add< const C_args * >("(", "", new OpCall_FormLinear2< C_args, vect_generic_v_fes >); + Add< const C_args * >("(", "", new OpCall_CompositeFormBilinear< C_args, vect_generic_v_fes, vect_generic_v_fes >); // correction du bug morale // Attention il y a moralement un bug @@ -6929,27 +6602,24 @@ void init_lgfem( ) { // Morice: Les versions de la suite autre que 2D sont dans [[lgmesh3.cpp]] chercher MakePtrFE3_2 // Morice: Creation de l'objet FEbase en 2D - TheOperators->Add("<-", - new OneOperator2_< pferbase *, pferbase *, pfes * >(MakePtrFE2), // Example:: Uh u; Uh [u,v]; - new OneOperator3_< pferbasearray *, pferbasearray *, pfes *, long >(MakePtrFE3), // Example:: Uh u[2]; Uh [u,v][2]; + TheOperators->Add("<-", new OneOperator2_< pferbase *, pferbase *, pfes * >(MakePtrFE2), // Example:: Uh u; Uh [u,v]; + new OneOperator3_< pferbasearray *, pferbasearray *, pfes *, long >(MakePtrFE3), // Example:: Uh u[2]; Uh [u,v][2]; - new OneOperator2_< pfecbase *, pfecbase *, pfes * >(MakePtrFE2), // Example:: Uh u; Uh [u,v]; - new OneOperator3_< pfecbasearray *, pfecbasearray *, pfes *, long >(MakePtrFE3) // Example:: Uh u[2]; Uh [u,v][2]; + new OneOperator2_< pfecbase *, pfecbase *, pfes * >(MakePtrFE2), // Example:: Uh u; Uh [u,v]; + new OneOperator3_< pfecbasearray *, pfecbasearray *, pfes *, long >(MakePtrFE3) // Example:: Uh u[2]; Uh [u,v][2]; ); // Morice: Creation de l'objet FEbase + Initialisation FEbase en 2D - TheOperators->Add( - "<-", - new OneOperatorMakePtrFE< double >(atype< double >( )), // scalar case ; Example:: Uh u = f(x,y); - new OneOperatorMakePtrFE< double >(atype< E_Array >( )), // vect case ; Example:: Uh [u,v] =[f1(x,y),f2(x,y)]; - new OneOperatorMakePtrFE< Complex >(atype< Complex >( )), // scalar complex case; Example:: Uh u = f(x,y); - new OneOperatorMakePtrFE< Complex >(atype< E_Array >( )) // vect complex case; Example:: Uh u = f(x,y); + TheOperators->Add("<-", + new OneOperatorMakePtrFE< double >(atype< double >( )), // scalar case ; Example:: Uh u = f(x,y); + new OneOperatorMakePtrFE< double >(atype< E_Array >( )), // vect case ; Example:: Uh [u,v] =[f1(x,y),f2(x,y)]; + new OneOperatorMakePtrFE< Complex >(atype< Complex >( )), // scalar complex case; Example:: Uh u = f(x,y); + new OneOperatorMakePtrFE< Complex >(atype< E_Array >( )) // vect complex case; Example:: Uh u = f(x,y); ); // interpolation operator TheOperators->Add( - "=", new OneOperator2_< pfer, pfer, double, E_F_StackF0F0opt2< double > >(set_fe< double >), - new OneOperator2_< pfec, pfec, Complex, E_F_StackF0F0opt2< Complex > >(set_fe< Complex >) + "=", new OneOperator2_< pfer, pfer, double, E_F_StackF0F0opt2< double > >(set_fe< double >), new OneOperator2_< pfec, pfec, Complex, E_F_StackF0F0opt2< Complex > >(set_fe< Complex >) ); @@ -6958,19 +6628,16 @@ void init_lgfem( ) { // les initialisation x(y) ( passe par l'operateur unaire <- de typedebase de x // ------- corrige - TheOperators->Add("=", new OneOperator2< pfes *, pfes *, pfes >(&set_eqdestroy_incr), - new Op_CopyArray( )); + TheOperators->Add("=", new OneOperator2< pfes *, pfes *, pfes >(&set_eqdestroy_incr), new Op_CopyArray( )); TheOperators->Add("<-", new OneOperator2_< pfes *, pfes *, pfes >(&set_copy_incr)); - TheOperators->Add("<<" ,// new OneBinaryOperator< PrintPnd< R3 * > >, - new OneBinaryOperator< PrintPnd< Matrice_Creuse< R > * > >, - new OneBinaryOperator< PrintPnd< Matrice_Creuse< Complex > * > > + TheOperators->Add("<<", // new OneBinaryOperator< PrintPnd< R3 * > >, + new OneBinaryOperator< PrintPnd< Matrice_Creuse< R > * > >, new OneBinaryOperator< PrintPnd< Matrice_Creuse< Complex > * > > ); - TheOperators->Add(">>", new OneBinaryOperator< Op_Read< Matrice_Creuse< R > > >, - new OneBinaryOperator< Op_Read< Matrice_Creuse< Complex > > > + TheOperators->Add(">>", new OneBinaryOperator< Op_Read< Matrice_Creuse< R > > >, new OneBinaryOperator< Op_Read< Matrice_Creuse< Complex > > > ); @@ -6987,14 +6654,14 @@ void init_lgfem( ) { Global.Add("jump", "(", new OneUnaryOperator< JumpOp< Complex >, JumpOp< Complex > >); Global.Add("mean", "(", new OneUnaryOperator< MeanOp< Complex >, MeanOp< Complex > >); Global.Add("average", "(", new OneUnaryOperator< MeanOp< Complex >, MeanOp< Complex > >); - Global.Add("otherside", "(",new OneUnaryOperator< OthersideOp< Complex >, OthersideOp< Complex > >); + Global.Add("otherside", "(", new OneUnaryOperator< OthersideOp< Complex >, OthersideOp< Complex > >); Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< FormBilinear >); Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< FormLinear >); Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< IntFunction< double >, 1 >); Add< const CDomainOfIntegration * >("(", "", new OneOperatorCode< IntFunction< complex< double > >, 0 >); - + map_type[typeid(double).name( )]->AddCast(new E_F1_funcT< double, pfer >(pfer2R< R, 0 >)); map_type[typeid(Complex).name( )]->AddCast(new E_F1_funcT< Complex, pfec >(pfer2R< Complex, 0 >)); @@ -7014,144 +6681,88 @@ void init_lgfem( ) { Global.Add("dxy", "(", new E_F1_funcT< Complex, pfec >(pfer2R< Complex, op_dxy >)); Global.Add("dyx", "(", new E_F1_funcT< Complex, pfec >(pfer2R< Complex, op_dyx >)); - Add< pfecbasearray * >( - "[", "", - new OneOperator2_< pfecbase *, pfecbasearray *, long >(get_element)); // use FH sep. 2009 - Add< pferbasearray * >("[", "", - new OneOperator2_< pferbase *, pferbasearray *, long >( - get_element)); // use ???? FH sep. 2009 + Add< pfecbasearray * >("[", "", new OneOperator2_< pfecbase *, pfecbasearray *, long >(get_element)); // use FH sep. 2009 + Add< pferbasearray * >("[", "", new OneOperator2_< pferbase *, pferbasearray *, long >(get_element)); // use ???? FH sep. 2009 // bof bof .. // resize of array of Finite element .. a little hard 2013 FH Dcl_Type< Resize1< pfecbasearray * > >( ); Dcl_Type< Resize1< pferbasearray * > >( ); Dcl_Type< Resize1< pfecarray > >( ); Dcl_Type< Resize1< pferarray > >( ); - Add< pfecbasearray * >( - "resize", ".", - new OneOperator1< Resize1< pfecbasearray * >, pfecbasearray * >(to_Resize1)); // FH fev 2013 - Add< pferbasearray * >("resize", ".", - new OneOperator1< Resize1< pferbasearray * >, pferbasearray * >( - to_Resize1)); // FH fev. 2013 - Add< pferarray >( - "resize", ".", - new OneOperator1< Resize1< pferarray >, pferarray >(to_Resize1)); // FH fev 2013 - Add< pfecarray >( - "resize", ".", - new OneOperator1< Resize1< pfecarray >, pfecarray >(to_Resize1)); // FH fev. 2013 - new OneOperator2_< pferbasearray *, Resize1< pferbasearray * >, long >( - fepresize< pferbasearray * >); - Add< Resize1< pferbasearray * > >( - "(", "", new OneOperator2_< pferbasearray *, Resize1< pferbasearray * >, long >(fepresize)); - Add< Resize1< pfecbasearray * > >( - "(", "", new OneOperator2_< pfecbasearray *, Resize1< pfecbasearray * >, long >(fepresize)); - Add< Resize1< pferarray > >("(", "", - new OneOperator2_< pferarray, Resize1< pferarray >, long >(feresize)); - Add< Resize1< pfecarray > >("(", "", - new OneOperator2_< pfecarray, Resize1< pfecarray >, long >(feresize)); + Add< pfecbasearray * >("resize", ".", new OneOperator1< Resize1< pfecbasearray * >, pfecbasearray * >(to_Resize1)); // FH fev 2013 + Add< pferbasearray * >("resize", ".", new OneOperator1< Resize1< pferbasearray * >, pferbasearray * >(to_Resize1)); // FH fev. 2013 + Add< pferarray >("resize", ".", new OneOperator1< Resize1< pferarray >, pferarray >(to_Resize1)); // FH fev 2013 + Add< pfecarray >("resize", ".", new OneOperator1< Resize1< pfecarray >, pfecarray >(to_Resize1)); // FH fev. 2013 + new OneOperator2_< pferbasearray *, Resize1< pferbasearray * >, long >(fepresize< pferbasearray * >); + Add< Resize1< pferbasearray * > >("(", "", new OneOperator2_< pferbasearray *, Resize1< pferbasearray * >, long >(fepresize)); + Add< Resize1< pfecbasearray * > >("(", "", new OneOperator2_< pfecbasearray *, Resize1< pfecbasearray * >, long >(fepresize)); + Add< Resize1< pferarray > >("(", "", new OneOperator2_< pferarray, Resize1< pferarray >, long >(feresize)); + Add< Resize1< pfecarray > >("(", "", new OneOperator2_< pfecarray, Resize1< pfecarray >, long >(feresize)); Dcl_Type< Resize1< pf3rbasearray * > >( ); Dcl_Type< Resize1< pf3rarray > >( ); - Dcl_Type< Resize1< pf3cbasearray * > >( ); // FH oct. 2016 - Dcl_Type< Resize1< pf3carray > >( ); // FH oct. 2016 - Add< pf3rbasearray * >("resize", ".", - new OneOperator1< Resize1< pf3rbasearray * >, pf3rbasearray * >( - to_Resize1)); // FH fev. 2013 - Add< pf3rarray >( - "resize", ".", - new OneOperator1< Resize1< pf3rarray >, pf3rarray >(to_Resize1)); // FH fev 2013 - Add< pf3cbasearray * >("resize", ".", - new OneOperator1< Resize1< pf3cbasearray * >, pf3cbasearray * >( - to_Resize1)); // FH oct. 2016 - Add< pf3carray >( - "resize", ".", - new OneOperator1< Resize1< pf3carray >, pf3carray >(to_Resize1)); // FH Oct 2016 - - Add< Resize1< pf3rbasearray * > >( - "(", "", new OneOperator2_< pf3rbasearray *, Resize1< pf3rbasearray * >, long >(fepresize)); - Add< Resize1< pf3rarray > >("(", "", - new OneOperator2_< pf3rarray, Resize1< pf3rarray >, long >(feresize)); - Add< Resize1< pf3cbasearray * > >( - "(", "", - new OneOperator2_< pf3cbasearray *, Resize1< pf3cbasearray * >, long >( - fepresize)); // FH Oct 2016 - Add< Resize1< pf3carray > >( - "(", "", - new OneOperator2_< pf3carray, Resize1< pf3carray >, long >(feresize)); // FH Oct 2016 + Dcl_Type< Resize1< pf3cbasearray * > >( ); // FH oct. 2016 + Dcl_Type< Resize1< pf3carray > >( ); // FH oct. 2016 + Add< pf3rbasearray * >("resize", ".", new OneOperator1< Resize1< pf3rbasearray * >, pf3rbasearray * >(to_Resize1)); // FH fev. 2013 + Add< pf3rarray >("resize", ".", new OneOperator1< Resize1< pf3rarray >, pf3rarray >(to_Resize1)); // FH fev 2013 + Add< pf3cbasearray * >("resize", ".", new OneOperator1< Resize1< pf3cbasearray * >, pf3cbasearray * >(to_Resize1)); // FH oct. 2016 + Add< pf3carray >("resize", ".", new OneOperator1< Resize1< pf3carray >, pf3carray >(to_Resize1)); // FH Oct 2016 + + Add< Resize1< pf3rbasearray * > >("(", "", new OneOperator2_< pf3rbasearray *, Resize1< pf3rbasearray * >, long >(fepresize)); + Add< Resize1< pf3rarray > >("(", "", new OneOperator2_< pf3rarray, Resize1< pf3rarray >, long >(feresize)); + Add< Resize1< pf3cbasearray * > >("(", "", new OneOperator2_< pf3cbasearray *, Resize1< pf3cbasearray * >, long >(fepresize)); // FH Oct 2016 + Add< Resize1< pf3carray > >("(", "", new OneOperator2_< pf3carray, Resize1< pf3carray >, long >(feresize)); // FH Oct 2016 Dcl_Type< Resize1< pfSrbasearray * > >( ); Dcl_Type< Resize1< pfSrarray > >( ); Dcl_Type< Resize1< pfScbasearray * > >( ); Dcl_Type< Resize1< pfScarray > >( ); - Add< pfSrbasearray * >( - "resize", ".", new OneOperator1< Resize1< pfSrbasearray * >, pfSrbasearray * >(to_Resize1)); + Add< pfSrbasearray * >("resize", ".", new OneOperator1< Resize1< pfSrbasearray * >, pfSrbasearray * >(to_Resize1)); Add< pfSrarray >("resize", ".", new OneOperator1< Resize1< pfSrarray >, pfSrarray >(to_Resize1)); - Add< pfScbasearray * >( - "resize", ".", new OneOperator1< Resize1< pfScbasearray * >, pfScbasearray * >(to_Resize1)); + Add< pfScbasearray * >("resize", ".", new OneOperator1< Resize1< pfScbasearray * >, pfScbasearray * >(to_Resize1)); Add< pfScarray >("resize", ".", new OneOperator1< Resize1< pfScarray >, pfScarray >(to_Resize1)); - Add< Resize1< pfSrbasearray * > >( - "(", "", new OneOperator2_< pfSrbasearray *, Resize1< pfSrbasearray * >, long >(fepresize)); - Add< Resize1< pfSrarray > >("(", "", - new OneOperator2_< pfSrarray, Resize1< pfSrarray >, long >(feresize)); - Add< Resize1< pfScbasearray * > >( - "(", "", new OneOperator2_< pfScbasearray *, Resize1< pfScbasearray * >, long >(fepresize)); - Add< Resize1< pfScarray > >("(", "", - new OneOperator2_< pfScarray, Resize1< pfScarray >, long >(feresize)); + Add< Resize1< pfSrbasearray * > >("(", "", new OneOperator2_< pfSrbasearray *, Resize1< pfSrbasearray * >, long >(fepresize)); + Add< Resize1< pfSrarray > >("(", "", new OneOperator2_< pfSrarray, Resize1< pfSrarray >, long >(feresize)); + Add< Resize1< pfScbasearray * > >("(", "", new OneOperator2_< pfScbasearray *, Resize1< pfScbasearray * >, long >(fepresize)); + Add< Resize1< pfScarray > >("(", "", new OneOperator2_< pfScarray, Resize1< pfScarray >, long >(feresize)); Dcl_Type< Resize1< pfLrbasearray * > >( ); Dcl_Type< Resize1< pfLrarray > >( ); Dcl_Type< Resize1< pfLcbasearray * > >( ); Dcl_Type< Resize1< pfLcarray > >( ); - Add< pfLrbasearray * >( - "resize", ".", new OneOperator1< Resize1< pfLrbasearray * >, pfLrbasearray * >(to_Resize1)); + Add< pfLrbasearray * >("resize", ".", new OneOperator1< Resize1< pfLrbasearray * >, pfLrbasearray * >(to_Resize1)); Add< pfLrarray >("resize", ".", new OneOperator1< Resize1< pfLrarray >, pfLrarray >(to_Resize1)); - Add< pfLcbasearray * >( - "resize", ".", new OneOperator1< Resize1< pfLcbasearray * >, pfLcbasearray * >(to_Resize1)); + Add< pfLcbasearray * >("resize", ".", new OneOperator1< Resize1< pfLcbasearray * >, pfLcbasearray * >(to_Resize1)); Add< pfLcarray >("resize", ".", new OneOperator1< Resize1< pfLcarray >, pfLcarray >(to_Resize1)); - Add< Resize1< pfLrbasearray * > >( - "(", "", new OneOperator2_< pfLrbasearray *, Resize1< pfLrbasearray * >, long >(fepresize)); - Add< Resize1< pfLrarray > >("(", "", - new OneOperator2_< pfLrarray, Resize1< pfLrarray >, long >(feresize)); - Add< Resize1< pfLcbasearray * > >( - "(", "", new OneOperator2_< pfLcbasearray *, Resize1< pfLcbasearray * >, long >(fepresize)); - Add< Resize1< pfLcarray > >("(", "", - new OneOperator2_< pfLcarray, Resize1< pfLcarray >, long >(feresize)); + Add< Resize1< pfLrbasearray * > >("(", "", new OneOperator2_< pfLrbasearray *, Resize1< pfLrbasearray * >, long >(fepresize)); + Add< Resize1< pfLrarray > >("(", "", new OneOperator2_< pfLrarray, Resize1< pfLrarray >, long >(feresize)); + Add< Resize1< pfLcbasearray * > >("(", "", new OneOperator2_< pfLcbasearray *, Resize1< pfLcbasearray * >, long >(fepresize)); + Add< Resize1< pfLcarray > >("(", "", new OneOperator2_< pfLcarray, Resize1< pfLcarray >, long >(feresize)); // end of resize ... - Add< pfecbasearray * >("n", ".", - new OneOperator1_< long, pfecbasearray * >(get_size)); // FH fev 2013 - Add< pferbasearray * >("n", ".", - new OneOperator1_< long, pferbasearray * >(get_size)); // FH fev. 2013 - Add< pferarray >("n", ".", new OneOperator1_< long, pferarray >(get_size)); // FH fev 2013 - Add< pfecarray >("n", ".", new OneOperator1_< long, pfecarray >(get_size)); // FH fev. 2013 - - Add< pf3rbasearray * >("n", ".", - new OneOperator1_< long, pf3rbasearray * >(get_size)); // FH fev. 2013 - Add< pf3rarray >("n", ".", new OneOperator1_< long, pf3rarray >(get_size)); // FH fev 2013 - Add< pf3cbasearray * >("n", ".", - new OneOperator1_< long, pf3cbasearray * >(get_size)); // FH Oct 2016 - Add< pf3carray >("n", ".", new OneOperator1_< long, pf3carray >(get_size)); // FH Oct 2016 - - Add< pferarray >("[", "", - new OneOperator2_FE_get_elmnt< double, v_fes >( )); // new version FH sep 2009 + Add< pfecbasearray * >("n", ".", new OneOperator1_< long, pfecbasearray * >(get_size)); // FH fev 2013 + Add< pferbasearray * >("n", ".", new OneOperator1_< long, pferbasearray * >(get_size)); // FH fev. 2013 + Add< pferarray >("n", ".", new OneOperator1_< long, pferarray >(get_size)); // FH fev 2013 + Add< pfecarray >("n", ".", new OneOperator1_< long, pfecarray >(get_size)); // FH fev. 2013 + + Add< pf3rbasearray * >("n", ".", new OneOperator1_< long, pf3rbasearray * >(get_size)); // FH fev. 2013 + Add< pf3rarray >("n", ".", new OneOperator1_< long, pf3rarray >(get_size)); // FH fev 2013 + Add< pf3cbasearray * >("n", ".", new OneOperator1_< long, pf3cbasearray * >(get_size)); // FH Oct 2016 + Add< pf3carray >("n", ".", new OneOperator1_< long, pf3carray >(get_size)); // FH Oct 2016 + + Add< pferarray >("[", "", new OneOperator2_FE_get_elmnt< double, v_fes >( )); // new version FH sep 2009 Add< pfecarray >("[", "", new OneOperator2_FE_get_elmnt< Complex, v_fes >( )); - Add< pf3rarray >("[", "", - new OneOperator2_FE_get_elmnt< double, v_fes >( )); // new version FH sep 2009 + Add< pf3rarray >("[", "", new OneOperator2_FE_get_elmnt< double, v_fes >( )); // new version FH sep 2009 Add< pf3carray >("[", "", new OneOperator2_FE_get_elmnt< Complex, v_fes >( )); // FH Oct 2016 - TheOperators->Add( - "\'", - new OneOperator1< Matrice_Creuse_Transpose< R >, Matrice_Creuse< R > * >( - &Build< Matrice_Creuse_Transpose< R >, Matrice_Creuse< R > * >), - new OneOperator1< Matrice_Creuse_Transpose< Complex >, Matrice_Creuse< Complex > * >( - &Build< Matrice_Creuse_Transpose< Complex >, Matrice_Creuse< Complex > * >)); + TheOperators->Add("\'", new OneOperator1< Matrice_Creuse_Transpose< R >, Matrice_Creuse< R > * >(&Build< Matrice_Creuse_Transpose< R >, Matrice_Creuse< R > * >), + new OneOperator1< Matrice_Creuse_Transpose< Complex >, Matrice_Creuse< Complex > * >(&Build< Matrice_Creuse_Transpose< Complex >, Matrice_Creuse< Complex > * >)); Add< pfer >("(", "", new interpolate_f_X_1< R >); - TheOperators->Add( - "=", - new OneOperator2_< void, interpolate_f_X_1< R >::type, double, E_F_StackF0F0 >(set_feoX_1)); + TheOperators->Add("=", new OneOperator2_< void, interpolate_f_X_1< R >::type, double, E_F_StackF0F0 >(set_feoX_1)); init_lgmat( ); init_mesh_array( ); @@ -7166,50 +6777,49 @@ void init_lgfem( ) { Global.New("RT03d", CConstantTFE3(&RT03d)); Global.New("Edge03d", CConstantTFE3(&Edge03d)); Global.New("P1b3d", CConstantTFE3(&P1bLagrange3d)); - - // add FH 22 march 2021 - - AddNewFE3("P1dc3d", &G_P1dc_3d,"P1dc");// deja code dans - AddNewFE3("P2dc3d", &G_P2dc_3d,"P2dc");// deja code dans - AddNewFE3("P3dc3d", &G_P3dc_3d);// deja code dans - AddNewFE3("P4dc3d", &G_P4dc_3d);// deja code dans - - AddNewFE3("P0edge3d", &G_P0Edge_3d,"P0edge");// deja code dans - AddNewFE3("P0edgedc3d", &G_P0Edgedc_3d);// deja code dans - AddNewFE3("P0VF3d", &G_P0VF_3d,"P0VF"); + + // add FH 22 march 2021 + + AddNewFE3("P1dc3d", &G_P1dc_3d, "P1dc"); // deja code dans + AddNewFE3("P2dc3d", &G_P2dc_3d, "P2dc"); // deja code dans + AddNewFE3("P3dc3d", &G_P3dc_3d); // deja code dans + AddNewFE3("P4dc3d", &G_P4dc_3d); // deja code dans + + AddNewFE3("P0edge3d", &G_P0Edge_3d, "P0edge"); // deja code dans + AddNewFE3("P0edgedc3d", &G_P0Edgedc_3d); // deja code dans + AddNewFE3("P0VF3d", &G_P0VF_3d, "P0VF"); AddNewFE3("P0VFdc3d", &G_P0VF_3d); AddNewFE3("P0face3d", &G_P0Face_3d); AddNewFE3("P0facedc3d", &G_P0Facedc_3d); + AddNewFES("P1dcS", &G_P1dc_S, "P1dc"); // deja code dans + AddNewFES("P2dcS", &G_P2dc_S, "P2dc"); // deja code dans + AddNewFES("P3dcS", &G_P3dc_S); // deja code dans + AddNewFES("P4dcS", &G_P4dc_S); // deja code dans + + AddNewFES("P0edgeS", &G_P0Edge_S, "P0edge"); // deja code dans + AddNewFES("P0edgedcS", &G_P0Edgedc_S); // deja code dans + AddNewFES("P0VF3S", &G_P0VF_S, "P0VF"); + AddNewFES("P0VFdc3S", &G_P0VFdc_S); + + AddNewFEL("P1dcL", &G_P1dc_L, "P1dc"); // + AddNewFEL("P2dcL", &G_P2dc_L, "P2dc"); // + AddNewFEL("P3dcL", &G_P3dc_L); // + AddNewFEL("P4dcL", &G_P4dc_L); // + AddNewFEL("P0VF3L", &G_P0VF_L, "P0VF"); + AddNewFEL("P0VF3dcL", &G_P0VFdc_L); - AddNewFES("P1dcS", &G_P1dc_S,"P1dc");// deja code dans - AddNewFES("P2dcS", &G_P2dc_S,"P2dc");// deja code dans - AddNewFES("P3dcS", &G_P3dc_S);// deja code dans - AddNewFES("P4dcS", &G_P4dc_S);// deja code dans - - AddNewFES("P0edgeS", &G_P0Edge_S,"P0edge");// deja code dans - AddNewFES("P0edgedcS", &G_P0Edgedc_S);// deja code dans - AddNewFES("P0VF3S", &G_P0VF_S,"P0VF"); - AddNewFES("P0VFdc3S", &G_P0VFdc_S); - - AddNewFEL("P1dcL", &G_P1dc_L,"P1dc");// - AddNewFEL("P2dcL", &G_P2dc_L,"P2dc");// - AddNewFEL("P3dcL", &G_P3dc_L);// - AddNewFEL("P4dcL", &G_P4dc_L);// - AddNewFEL("P0VF3L", &G_P0VF_L,"P0VF"); - AddNewFEL("P0VF3dcL", &G_P0VFdc_L); - // end add .. - Global.New("Edge0S",CConstantTFES(&RT0orthosurf)); - Global.New("RT0orthoS",CConstantTFES(&RT0orthosurf)); - Global.New("RT0S",CConstantTFES(&RT0surf)); + Global.New("Edge0S", CConstantTFES(&RT0orthosurf)); + Global.New("RT0orthoS", CConstantTFES(&RT0orthosurf)); + Global.New("RT0S", CConstantTFES(&RT0surf)); Global.New("P2S", CConstantTFES(&DataFE< MeshS >::P2)); Global.New("P1S", CConstantTFES(&DataFE< MeshS >::P1)); Global.New("P0S", CConstantTFES(&DataFE< MeshS >::P0)); Global.New("P1bS", CConstantTFES(&P1bLagrange_surf)); Global.New("P2bS", CConstantTFES(&P2bLagrange_surf)); - + Global.New("P2L", CConstantTFEL(&DataFE< MeshL >::P2)); Global.New("P1L", CConstantTFEL(&DataFE< MeshL >::P1)); Global.New("P0L", CConstantTFEL(&DataFE< MeshL >::P0)); @@ -7220,7 +6830,7 @@ void init_lgfem( ) { TEF2dtoS[FindFE2("P1b")] = &P1bLagrange_surf; TEF2dtoS[FindFE2("P2b")] = &P2bLagrange_surf; TEF2dtoS[FindFE2("RT0")] = &RT0surf; - + TEF2dtoL[FindFE2("P0")] = &DataFE< MeshL >::P0; TEF2dtoL[FindFE2("P1")] = &DataFE< MeshL >::P1; TEF2dtoL[FindFE2("P2")] = &DataFE< MeshL >::P2; @@ -7244,8 +6854,7 @@ Expression IsFEcomp(const C_F0 &c, int i, Expression &rrr, Expression &iii) { if (atype< typename E_FEcomp< K, v_fes >::Result >( ) == c.left( )) { const E_FEcomp< K, v_fes > *e = dynamic_cast< const E_FEcomp< K, v_fes > * >(c.LeftValue( )); if (!e) { - const E_FEcomp_get_elmnt_array< K, v_fes > *ee = - dynamic_cast< const E_FEcomp_get_elmnt_array< K, v_fes > * >(c.LeftValue( )); + const E_FEcomp_get_elmnt_array< K, v_fes > *ee = dynamic_cast< const E_FEcomp_get_elmnt_array< K, v_fes > * >(c.LeftValue( )); if (!ee) { cerr << " Fatal error Copy array .." << *c.left( ) << " composante : " << i << endl; @@ -7253,8 +6862,7 @@ Expression IsFEcomp(const C_F0 &c, int i, Expression &rrr, Expression &iii) { } else { if (ee->comp == i) { if (i && ee->a00->a0 != rrr) - cerr << " error composante arry vect. incompatible " << ee->comp << " " << ee->a00->a0 - << " != " << rrr << endl; + cerr << " error composante arry vect. incompatible " << ee->comp << " " << ee->a00->a0 << " != " << rrr << endl; else { r = ee->a0; rrr = ee->a00->a0; @@ -7287,8 +6895,7 @@ Expression Op_CopyArrayT(const E_Array &a, const E_Array &b) { rr = IsFEcomp< K, v_fes >(a[0], 0, rrr, iii); if (rr != 0) { for (int i = 1; i < nb; i++) - if (!IsFEcomp< K, v_fes >(a[i], i, rrr, iii)) - CompileError("Copy of Array with incompatible K vector value FE function () !"); + if (!IsFEcomp< K, v_fes >(a[i], i, rrr, iii)) CompileError("Copy of Array with incompatible K vector value FE function () !"); ; if (iii) { C_F0 aa(rrr, atype< FEba ** >( )), ii(iii, atype< long >( )); @@ -7324,7 +6931,8 @@ E_F0 *Op_CopyArray::code(const basicAC_F0 &args) const { if (!r) r = Op_CopyArrayT< Complex, v_fesS >(a, b); if (!r) r = Op_CopyArrayT< double, v_fesL >(a, b); if (!r) r = Op_CopyArrayT< Complex, v_fesL >(a, b); - if (r) return r; + if (r) + return r; else { CompileError("Internal Error: General Copy of Array : to do "); return ret; @@ -7332,8 +6940,7 @@ E_F0 *Op_CopyArray::code(const basicAC_F0 &args) const { } template< class v_fes, int DIM > -C_F0 NewFEvariableT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim) { +C_F0 NewFEvariableT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim) { ffassert(dim == DIM); typedef FEbase< double, v_fes > FE; typedef E_FEcomp< R, v_fes > FEi; @@ -7373,28 +6980,22 @@ C_F0 NewFEvariableT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F char *name = strcpy(CodeAllocT< char >::New(str.size( ) + 1), str.c_str( )); C_F0 ret; // modif 100109 (add Block:: before NewVar for g++ 3.3.3 on Suse 9) - ret = binit - ? currentblock->Block::NewVar< LocalVariable >(name, dcltype, - basicAC_F0_wa(fespacetype, init)) - : currentblock->Block::NewVar< LocalVariable >(name, dcltype, basicAC_F0_wa(fespacetype)); + ret = binit ? currentblock->Block::NewVar< LocalVariable >(name, dcltype, basicAC_F0_wa(fespacetype, init)) : currentblock->Block::NewVar< LocalVariable >(name, dcltype, basicAC_F0_wa(fespacetype)); C_F0 base = currentblock->Find(name); - // Morice : Ajout dans la table du block un NewId - // NewId = "une nouvelle variable", PAC: [u,v,w] ajout de 3 variables et non 1 variable. + // Morice : Ajout dans la table du block un NewId + // NewId = "une nouvelle variable", PAC: [u,v,w] ajout de 3 variables et non 1 variable. // E_FEcomp est l'expression qui contient la FEbase if (cplx) - for (int i = 0; i < n; i++) - currentblock->NewID(cf0type, ids[i].id, C_F0(new CFEi(base, i, n), rtype)); + for (int i = 0; i < n; i++) currentblock->NewID(cf0type, ids[i].id, C_F0(new CFEi(base, i, n), rtype)); else - for (int i = 0; i < n; i++) - currentblock->NewID(cf0type, ids[i].id, C_F0(new FEi(base, i, n), rtype)); + for (int i = 0; i < n; i++) currentblock->NewID(cf0type, ids[i].id, C_F0(new FEi(base, i, n), rtype)); delete pids; // add FH 25032005 return ret; } -C_F0 NewFEvariable(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim) { +C_F0 NewFEvariable(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim) { if (dim == 2) return NewFEvariableT< v_fes, 2 >(pids, currentblock, fespacetype, init, cplx, dim); else if (dim == 3) @@ -7403,10 +7004,10 @@ C_F0 NewFEvariable(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 return NewFEvariableT< v_fesS, 4 >(pids, currentblock, fespacetype, init, cplx, dim); else if (dim == 5) return NewFEvariableT< v_fesL, 5 >(pids, currentblock, fespacetype, init, cplx, dim); - //else if (dim == 6) - // return NewVecFEvariableT(pids, currentblock, fespacetype, init, cplx, dim); // Morice Fonction non testee - //else if (dim == 7) - // return NewFEvariableT< generic_v_fes, 7 >(pids, currentblock, fespacetype, init, cplx, dim); // Morice Fonction non testee + // else if (dim == 6) + // return NewVecFEvariableT(pids, currentblock, fespacetype, init, cplx, dim); // Morice Fonction non testee + // else if (dim == 7) + // return NewFEvariableT< generic_v_fes, 7 >(pids, currentblock, fespacetype, init, cplx, dim); // Morice Fonction non testee else { cerr << "value dim=" << dim << endl; CompileError("Invalid fespace on Rd ( d != 2 or 3) "); @@ -7414,100 +7015,94 @@ C_F0 NewFEvariable(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 return C_F0( ); } - -C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim) { +C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim) { ListOfId *lid = new ListOfId; lid->push_back(UnId(id)); return NewFEvariable(lid, currentblock, fespacetype, init, cplx, dim); } -KN dimFESpaceImage(const basicAC_F0 &args) { +KN< size_t > dimFESpaceImage(const basicAC_F0 &args) { // return the dimension of all the component of the FESpace and the result is of size 1. // // For a compositeFESpace Wh= , return the different dimension of each FESpace Uhi and the result is of size n; - // + // aType t_tfe = atype< TypeOfFE * >( ); aType t_tfe3 = atype< TypeOfFE3 * >( ); aType t_tfeS = atype< TypeOfFES * >( ); aType t_tfeL = atype< TypeOfFEL * >( ); - aType pt_tfe = atype0< TypeOfFE ** >( );// no verif because def in plugin !!!! + aType pt_tfe = atype0< TypeOfFE ** >( ); // no verif because def in plugin !!!! aType pt_tfe3 = atype0< TypeOfFE3 ** >( ); aType pt_tfeS = atype0< TypeOfFES ** >( ); aType pt_tfeL = atype0< TypeOfFEL ** >( ); aType t_a = atype< E_Array >( ); aType t_fea = atype< E_FEarray >( ); - aType atfs[] = {atype< pfes * >( ), atype< pfes3 * >( ), atype< pfesS * >( ), - atype< pfesL * >( )}; - - // J. Morice : actuellement, on fait cette hypothèse car je ne veux pas gérér pour l'instant les paramétres + aType atfs[] = {atype< pfes * >( ), atype< pfes3 * >( ), atype< pfesS * >( ), atype< pfesL * >( )}; + + // J. Morice : actuellement, on fait cette hypothèse car je ne veux pas gérér pour l'instant les paramétres // en même temps les fespace et les autres (Th,P1,[P1,P1],nb_periodic) - // - /// Dans cette fonction, on peut le faire sans problème (cf la boucle qui suit). + // + /// Dans cette fonction, on peut le faire sans problème (cf la boucle qui suit). // Mais garder par coherence vis à vis de la fonction << aType typeFESpace(const basicAC_F0 &args) >>. - // - // ffassert( numberOfpfes == args.size( ) || numberOfpfes == 0); + // + // ffassert( numberOfpfes == args.size( ) || numberOfpfes == 0); - // determination of the size of vector - bool compositeFESpace=false; - vector< size_t> dimComposite; - size_t dim23=0; + // determination of the size of vector + bool compositeFESpace = false; + vector< size_t > dimComposite; + size_t dim23 = 0; // create the good size for a compositeFESpace - for (int i = 0; i < args.size( ); i++){ + for (int i = 0; i < args.size( ); i++) { // case E_FEarray of FEspace - if(args[i].left( ) == t_fea){ - compositeFESpace= true; + if (args[i].left( ) == t_fea) { + compositeFESpace = true; const E_FEarray &efea = *dynamic_cast< const E_FEarray * >(args[i].LeftValue( )); ffassert(&efea); - dimComposite.resize(efea.size()); + dimComposite.resize(efea.size( )); } } - - for (int i = !compositeFESpace; i < args.size( ); i++) { // on saute le maillage si pas de composite !! - if ( args[i].left( ) == t_tfe || args[i].left( ) == t_tfe3 || args[i].left( ) == t_tfeS || args[i].left( ) == t_tfeL - || args[i].left( ) == pt_tfe || args[i].left( ) == pt_tfe3 || args[i].left( ) == pt_tfeS || args[i].left( ) == pt_tfeL) { // A febr 2023 FH et PH-T - dim23+= args[i].LeftValue( )->nbitem( ); + for (int i = !compositeFESpace; i < args.size( ); i++) { // on saute le maillage si pas de composite !! + if (args[i].left( ) == t_tfe || args[i].left( ) == t_tfe3 || args[i].left( ) == t_tfeS || args[i].left( ) == t_tfeL || args[i].left( ) == pt_tfe || args[i].left( ) == pt_tfe3 || + args[i].left( ) == pt_tfeS || args[i].left( ) == pt_tfeL) { // A febr 2023 FH et PH-T + dim23 += args[i].LeftValue( )->nbitem( ); } - // if(verbosity >99) cout << " args[i].LeftValue( )->nbitem( ) ="<< args[i].LeftValue( )->nbitem( ) << " "<< dim23 << endl; + // if(verbosity >99) cout << " args[i].LeftValue( )->nbitem( ) ="<< args[i].LeftValue( )->nbitem( ) << " "<< dim23 << endl; // case E_array of TypeOfFE else if (args[i].left( ) == t_a) { const E_Array &ea = *dynamic_cast< const E_Array * >(args[i].LeftValue( )); ffassert(&ea); for (int i = 0; i < ea.size( ); i++) - if ( ea[i].left( ) == t_tfe || ea[i].left( ) == t_tfe3 || ea[i].left( ) == t_tfeS || ea[i].left( ) == t_tfeL - || ea[i].left( ) == pt_tfe || ea[i].left( ) == pt_tfe3 || ea[i].left( ) == pt_tfeS || ea[i].left( ) == pt_tfeL) + if (ea[i].left( ) == t_tfe || ea[i].left( ) == t_tfe3 || ea[i].left( ) == t_tfeS || ea[i].left( ) == t_tfeL || ea[i].left( ) == pt_tfe || ea[i].left( ) == pt_tfe3 || + ea[i].left( ) == pt_tfeS || ea[i].left( ) == pt_tfeL) dim23 += ea[i].nbitem( ); - else - { - cout<< " tpye .. " << *ea[i].left() << " " << *ea[i].right() <(args[i].LeftValue( )); ffassert(&efea); - for (int ii = 0; ii < efea.size( ); ii++){ - if( atfs[0] == efea[ii].left( ) || atfs[1] == efea[ii].left( ) || atfs[2] == efea[ii].left( ) || atfs[3] == efea[ii].left( ) ){ - dimComposite[ii] = efea[ii].nbitem(); - dim23 += efea[ii].nbitem(); - } - else + for (int ii = 0; ii < efea.size( ); ii++) { + if (atfs[0] == efea[ii].left( ) || atfs[1] == efea[ii].left( ) || atfs[2] == efea[ii].left( ) || atfs[3] == efea[ii].left( )) { + dimComposite[ii] = efea[ii].nbitem( ); + dim23 += efea[ii].nbitem( ); + } else ffassert(0); // bug } } } - if(compositeFESpace){ - KN result(dimComposite.size()); + if (compositeFESpace) { + KN< size_t > result(dimComposite.size( )); result[0] = dim23; - for (int ii = 0; ii < dimComposite.size( ); ii++){ - if(dimComposite[ii] == 0){ + for (int ii = 0; ii < dimComposite.size( ); ii++) { + if (dimComposite[ii] == 0) { cerr << "Error you have a FESpace with 0 componenent" << endl; - cerr << "nbitem in the "<< ii << "-th FEspace =" << dimComposite[ii] << endl; + cerr << "nbitem in the " << ii << "-th FEspace =" << dimComposite[ii] << endl; ffassert(0); } @@ -7515,17 +7110,16 @@ KN dimFESpaceImage(const basicAC_F0 &args) { result[ii] = dimComposite[ii]; } return result; - } - else{ + } else { dim23 = dim23 ? dim23 : 1; // if(verbosity >99) cout << "nbitem in the FEspace =" << dim23 << endl; - KN result(1); result[0] = dim23; + KN< size_t > result(1); + result[0] = dim23; return result; } } - aType typeFESpace(const basicAC_F0 &args) { aType t_m2 = atype< pmesh * >( ); aType t_m3 = atype< pmesh3 * >( ); @@ -7538,8 +7132,7 @@ aType typeFESpace(const basicAC_F0 &args) { aType t_tfeL = atype< TypeOfFEL * >( ); aType atfe[] = {t_tfe, t_tfe3, t_tfeS, t_tfeL}; - aType atfs[] = {atype< pfes * >( ), atype< pfes3 * >( ), atype< pfesS * >( ), - atype< pfesL * >( )}; + aType atfs[] = {atype< pfes * >( ), atype< pfes3 * >( ), atype< pfesS * >( ), atype< pfesL * >( )}; aType t_a = atype< E_Array >( ); aType t_fea = atype< E_FEarray >( ); @@ -7547,45 +7140,42 @@ aType typeFESpace(const basicAC_F0 &args) { aType tMesh = 0; int dm = -1, id = -2; - // Test if one args correpond to - int numberOfpfes = 0; // number of type of pfes, pfes3, pfesS, pfesL in the parameter list + // Test if one args correpond to + int numberOfpfes = 0; // number of type of pfes, pfes3, pfesS, pfesL in the parameter list int size_efea = 0; - for (int i = 0; i < args.size( ); i++){ + for (int i = 0; i < args.size( ); i++) { tl = args[i].left( ); // Test is the args correspond to [Uh,Vh,...] - if(tl == t_fea){ + if (tl == t_fea) { const E_FEarray &efea = *dynamic_cast< const E_FEarray * >(args[i].LeftValue( )); ffassert(&efea); - size_efea = efea.size(); + size_efea = efea.size( ); for (int ii = 0; ii < efea.size( ); ii++) { - if( atfs[0] == efea[ii].left( ) || atfs[1] == efea[ii].left( ) || atfs[2] == efea[ii].left( ) || atfs[3] == efea[ii].left( ) ){ + if (atfs[0] == efea[ii].left( ) || atfs[1] == efea[ii].left( ) || atfs[2] == efea[ii].left( ) || atfs[3] == efea[ii].left( )) { numberOfpfes++; - } - else{ + } else { ffassert(0); // bug } } - } - } - if(verbosity > 4){ + if (verbosity > 4) { cout << "number of pfes in a composite FESpace=" << numberOfpfes << endl; - cout << "args.size()=" << args.size() << endl; + cout << "args.size()=" << args.size( ) << endl; } - + // J. Morice : actuellement, on fait cette hypothèse car je ne veux pas gérér pour l'instant les paramétres Uh // en même temps avec les fespace et les autres (Th,P1,[P1,P1],nb_periodic) - if( !( ( numberOfpfes == size_efea && size_efea > 0 && args.size() == 1 ) || numberOfpfes == 0 ) ){ + if (!((numberOfpfes == size_efea && size_efea > 0 && args.size( ) == 1) || numberOfpfes == 0)) { cerr << "you try to define a compositeFESpace with " << endl; cerr << " fespace Wh(, Th,[P1],...) or Wh(Th,[P1],..., ) is not allowed." << endl; cerr << " fespace Wh(, ) is not allowed." << endl; cerr << " Only possiblity is : " << endl; cerr << " fespace Wh() where Uhi is a FESpace." << endl; } - ffassert( ( numberOfpfes == size_efea && size_efea > 0 && args.size() == 1 ) || numberOfpfes == 0); + ffassert((numberOfpfes == size_efea && size_efea > 0 && args.size( ) == 1) || numberOfpfes == 0); - if( numberOfpfes == 0){ + if (numberOfpfes == 0) { // case without fespace in the arguments for (int i = 0; i < args.size( ); i++) { tl = args[i].left( ); @@ -7631,17 +7221,15 @@ aType typeFESpace(const basicAC_F0 &args) { } if (verbosity > 99) cout << " typeFESpace " << id << " " << ret->name( ) << endl; return ret; - } - else{ + } else { // case with fespace as parameter - ret = atype< pvectgenericfes * >(); - return ret; + ret = atype< pvectgenericfes * >( ); + return ret; } } template< class v_fes, int DIM > -C_F0 NewFEarrayT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, - bool cplx, int dim) { +C_F0 NewFEarrayT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, bool cplx, int dim) { ffassert(dim == DIM || dim != 4); // TODO typedef FEbaseArray< double, v_fes > FE; typedef E_FEcomp< R, v_fes, FE > FEi; @@ -7676,36 +7264,31 @@ C_F0 NewFEarrayT(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 s } str += "]"; char *name = strcpy(CodeAllocT< char >::New(str.size( ) + 1), str.c_str( )); - C_F0 ret = currentblock->Block::NewVar< LocalVariable >(name, dcltype, - basicAC_F0_wa(fespacetype, sizeofarray)); + C_F0 ret = currentblock->Block::NewVar< LocalVariable >(name, dcltype, basicAC_F0_wa(fespacetype, sizeofarray)); C_F0 base = currentblock->Find(name); if (cplx) - for (int i = 0; i < n; i++) - currentblock->NewID(cf0type, ids[i].id, C_F0(new CFEi(base, i, n), rtype)); + for (int i = 0; i < n; i++) currentblock->NewID(cf0type, ids[i].id, C_F0(new CFEi(base, i, n), rtype)); else - for (int i = 0; i < n; i++) - currentblock->NewID(cf0type, ids[i].id, C_F0(new FEi(base, i, n), rtype)); + for (int i = 0; i < n; i++) currentblock->NewID(cf0type, ids[i].id, C_F0(new FEi(base, i, n), rtype)); delete pids; // add FH 25032005 return ret; } -C_F0 NewFEarray(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, - bool cplx, int dim) { +C_F0 NewFEarray(ListOfId *pids, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, bool cplx, int dim) { if (dim == 2) return NewFEarrayT< v_fes, 2 >(pids, currentblock, fespacetype, sizeofarray, cplx, dim); else if (dim == 3) return NewFEarrayT< v_fes3, 3 >(pids, currentblock, fespacetype, sizeofarray, cplx, dim); else if (dim == 4) return NewFEarrayT< v_fesS, 4 >(pids, currentblock, fespacetype, sizeofarray, cplx, dim); - else if (dim==5) - return NewFEarrayT(pids,currentblock,fespacetype,sizeofarray,cplx,dim); + else if (dim == 5) + return NewFEarrayT< v_fesL, 5 >(pids, currentblock, fespacetype, sizeofarray, cplx, dim); else CompileError("Invalid vectorial fespace on Rd ( d != 2 or 3) "); return C_F0( ); } -C_F0 NewFEarray(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, - bool cplx, int dim) { +C_F0 NewFEarray(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 sizeofarray, bool cplx, int dim) { ListOfId *lid = new ListOfId; lid->push_back(UnId(id)); return NewFEarray(lid, currentblock, fespacetype, sizeofarray, cplx, dim); @@ -7729,8 +7312,7 @@ namespace Fem2D { if (verbosity > 99) cout << endl; } - void Expandsetoflab(Stack stack, const CDomainOfIntegration &di, set< int > &setoflab, - bool &all) { + void Expandsetoflab(Stack stack, const CDomainOfIntegration &di, set< int > &setoflab, bool &all) { for (size_t i = 0; i < di.what.size( ); i++) if (di.whatis[i] == 0) { long lab = GetAny< long >((*di.what[i])(stack)); diff --git a/src/fflib/lgfem.hpp b/src/fflib/lgfem.hpp index d39146f40..9eb38d5f1 100644 --- a/src/fflib/lgfem.hpp +++ b/src/fflib/lgfem.hpp @@ -39,22 +39,22 @@ extern Block *currentblock; void init_lgmat( ); // initialisation for sparse mat functionnallity -class generic_v_fes; // J. Morice : Added in 06/22 -class vect_generic_v_fes; // J. Morice : Added in 06/22 +class generic_v_fes; // J. Morice : Added in 06/22 +class vect_generic_v_fes; // J. Morice : Added in 06/22 class v_fes; class v_fes3; class v_fesS; class v_fesL; -typedef generic_v_fes *pgenericfes; // J. Morice : Added in 06/22 -typedef vect_generic_v_fes *pvectgenericfes; // J. Morice : Added in 06/22 +typedef generic_v_fes *pgenericfes; // J. Morice : Added in 06/22 +typedef vect_generic_v_fes *pvectgenericfes; // J. Morice : Added in 06/22 typedef v_fes *pfes; typedef v_fes3 *pfes3; typedef v_fesS *pfesS; typedef v_fesL *pfesL; -//typedef v_fesVect *pfesVect; // J. Morice +// typedef v_fesVect *pfesVect; // J. Morice namespace Fem2D { class Mesh3; @@ -227,40 +227,44 @@ namespace { (*pTh).BoundaryElement((*pTh)(k), ee); return ee; } - R2 NBoundaryElement() const {Check() ;int ee; - int kk=(*pTh).BoundaryElement((*pTh)(k),ee); - return (*pTh)[kk].n(ee);} - + R2 NBoundaryElement( ) const { + Check( ); + int ee; + int kk = (*pTh).BoundaryElement((*pTh)(k), ee); + return (*pTh)[kk].n(ee); + } }; } // namespace void GetPeriodic(const int d, Expression perio, int &nbcperiodic, Expression *&periodic); -bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack stack, int &nbdfv, - KN< int > &ndfv, int &nbdfe, KN< int > &ndfe); +bool BuildPeriodic2(int nbcperiodic, Expression *periodic, const Mesh &Th, Stack stack, int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe); // <> uses [[file:~/ff/src/femlib/RefCounter.hpp::RefCounter]] // virtual class for generic v_fes // Morice :: 06/2022 class generic_v_fes : public RefCounter { - typedef void* pfes; - typedef void* FESpace; + typedef void *pfes; + typedef void *FESpace; + + public: + virtual bool differentMesh( ) { + ffassert(0); + return true; + }; - public: - virtual bool differentMesh(){ ffassert(0); return true; }; - // declaration avec les virtuelles pure // function for vect_generic_v_fes - virtual void *getpVh()=0; // get the pointer of FESpace - virtual void *getpVh()const=0; // get the pointer of FESpace - virtual const void *getppTh()=0; // get the pointer on the pointer of the mesh - virtual int getN()=0; // get the number of item of the FESpace + virtual void *getpVh( ) = 0; // get the pointer of FESpace + virtual void *getpVh( ) const = 0; // get the pointer of FESpace + virtual const void *getppTh( ) = 0; // get the pointer on the pointer of the mesh + virtual int getN( ) = 0; // get the number of item of the FESpace }; // 2d -class v_fes : public generic_v_fes{ +class v_fes : public generic_v_fes { public: typedef ::pfes pfes; typedef ::FESpace FESpace; @@ -282,10 +286,8 @@ class v_fes : public generic_v_fes{ FESpace *update( ); - v_fes(int NN, const pmesh *t, Stack s, int n, Expression *p) - : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} - v_fes(int NN, const v_fes *f, Stack s, int n, Expression *p) - : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fes(int NN, const pmesh *t, Stack s, int n, Expression *p) : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fes(int NN, const v_fes *f, Stack s, int n, Expression *p) : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} void destroy( ) { ppTh = 0; @@ -296,12 +298,12 @@ class v_fes : public generic_v_fes{ bool buildperiodic(Stack stack, int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe); virtual FESpace *buildupdate(int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) = 0; virtual FESpace *buildupdate( ) = 0; - - // Added to return the pointer to FESpace - const void *getppTh(){ return ppTh; }; // Morice : get the pointer on the pointer of the mesh - void *getpVh(){ return pVh; }; // Morice : get the pointer of FESpace - void *getpVh()const{ return pVh; }; // Morice : get the pointer of FESpace - int getN(){ return N;}; // Morice : get the number of item of the FESpace + + // Added to return the pointer to FESpace + const void *getppTh( ) { return ppTh; }; // Morice : get the pointer on the pointer of the mesh + void *getpVh( ) { return pVh; }; // Morice : get the pointer of FESpace + void *getpVh( ) const { return pVh; }; // Morice : get the pointer of FESpace + int getN( ) { return N; }; // Morice : get the number of item of the FESpace }; // 3D volume @@ -327,10 +329,8 @@ class v_fes3 : public generic_v_fes { } FESpace3 *update( ); - v_fes3(int NN, const pmesh3 *t, Stack s, int n, Expression *p) - : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} - v_fes3(int NN, const v_fes3 *f, Stack s, int n, Expression *p) - : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fes3(int NN, const pmesh3 *t, Stack s, int n, Expression *p) : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fes3(int NN, const v_fes3 *f, Stack s, int n, Expression *p) : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} // void destroy(){ ppTh=0;pVh=0; delete this;} virtual ~v_fes3( ) {} @@ -338,10 +338,10 @@ class v_fes3 : public generic_v_fes { virtual FESpace3 *buildupdate(KN< int > &ndfe) { return 0; } virtual FESpace3 *buildupdate( ) { return 0; }; - const void * getppTh(){ return ppTh; }; // Morice : get the pointer on the pointer of the mesh - void * getpVh(){ return pVh; }; // Morice : get the pointer of FESpace - void * getpVh()const{ return pVh; }; // Morice : get the pointer of FESpace - int getN(){ return N;}; // Morice : get the number of item of the FESpace + const void *getppTh( ) { return ppTh; }; // Morice : get the pointer on the pointer of the mesh + void *getpVh( ) { return pVh; }; // Morice : get the pointer of FESpace + void *getpVh( ) const { return pVh; }; // Morice : get the pointer of FESpace + int getN( ) { return N; }; // Morice : get the number of item of the FESpace }; // 3D surface @@ -368,11 +368,9 @@ class v_fesS : public generic_v_fes { } FESpaceS *update( ); - v_fesS(int NN, const pmeshS *t, Stack s, int n, Expression *p) /// TODO - : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) { - } // take a pmesh3 and use the pmeshS - v_fesS(int NN, const v_fesS *f, Stack s, int n, Expression *p) - : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fesS(int NN, const pmeshS *t, Stack s, int n, Expression *p) /// TODO + : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} // take a pmesh3 and use the pmeshS + v_fesS(int NN, const v_fesS *f, Stack s, int n, Expression *p) : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} // void destroy(){ ppTh=0;pVh=0; delete this;} virtual ~v_fesS( ) {} @@ -380,10 +378,10 @@ class v_fesS : public generic_v_fes { virtual FESpaceS *buildupdate(KN< int > &ndfe) { return 0; } virtual FESpaceS *buildupdate( ) { return 0; }; - const void * getppTh(){ return ppTh; }; // Morice : get the pointer on the pointer of the mesh - void * getpVh(){ return pVh; }; // Morice : get the pointer of FESpace - void * getpVh()const{ return pVh; }; // Morice : get the pointer of FESpac - int getN(){ return N;}; // Morice : get the number of item of the FESpace + const void *getppTh( ) { return ppTh; }; // Morice : get the pointer on the pointer of the mesh + void *getpVh( ) { return pVh; }; // Morice : get the pointer of FESpace + void *getpVh( ) const { return pVh; }; // Morice : get the pointer of FESpac + int getN( ) { return N; }; // Morice : get the number of item of the FESpace }; // 3D curve @@ -410,11 +408,9 @@ class v_fesL : public generic_v_fes { } FESpaceL *update( ); - v_fesL(int NN, const pmeshL *t, Stack s, int n, Expression *p) /// TODO - : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) { - } // take a pmesh3 and use the pmeshS - v_fesL(int NN, const v_fesL *f, Stack s, int n, Expression *p) - : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} + v_fesL(int NN, const pmeshL *t, Stack s, int n, Expression *p) /// TODO + : N(NN), ppTh(t), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} // take a pmesh3 and use the pmeshS + v_fesL(int NN, const v_fesL *f, Stack s, int n, Expression *p) : N(NN), ppTh(f->ppTh), pVh(0), stack(s), nbcperiodic(n), periodic(p) {} // void destroy(){ ppTh=0;pVh=0; delete this;} virtual ~v_fesL( ) {} @@ -422,23 +418,18 @@ class v_fesL : public generic_v_fes { virtual FESpaceL *buildupdate(KN< int > &ndfe) { return 0; } virtual FESpaceL *buildupdate( ) { return 0; }; - const void *getppTh(){ return ppTh; }; // Morice : get the pointer on the pointer of the mesh - void *getpVh(){ return pVh; }; // Morice : get the pointer of FESpace - void * getpVh()const{ return pVh; }; // Morice : get the pointer of FESpac - int getN(){ return N;}; // Morice : get the number of item of the FESpace + const void *getppTh( ) { return ppTh; }; // Morice : get the pointer on the pointer of the mesh + void *getpVh( ) { return pVh; }; // Morice : get the pointer of FESpace + void *getpVh( ) const { return pVh; }; // Morice : get the pointer of FESpac + int getN( ) { return N; }; // Morice : get the number of item of the FESpace }; // 2d class pfes_tef : public v_fes { public: const TypeOfFE *tef; - pfes_tef(const pmesh *t, const TypeOfFE *tt, Stack s = NullStack, int n = 0, Expression *p = 0) - : v_fes(tt->N, t, s, n, p), tef(tt) { - operator FESpace *( ); - } - FESpace *buildupdate(int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { - return *ppTh ? new FESpace(**ppTh, *tef, nbdfv, (int *)ndfv, nbdfe, (int *)ndfe) : 0; - } + pfes_tef(const pmesh *t, const TypeOfFE *tt, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fes(tt->N, t, s, n, p), tef(tt) { operator FESpace *( ); } + FESpace *buildupdate(int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { return *ppTh ? new FESpace(**ppTh, *tef, nbdfv, (int *)ndfv, nbdfe, (int *)ndfe) : 0; } FESpace *buildupdate( ) { return *ppTh ? new FESpace(**ppTh, *tef) : 0; } }; @@ -446,9 +437,7 @@ class pfes_tefk : public v_fes { public: const TypeOfFE **tef; const int k; - pfes_tefk(const pmesh *t, const TypeOfFE **tt, int kk, Stack s = NullStack, int n = 0, - Expression *p = 0) - : v_fes(sum(tt, &Fem2D::TypeOfFE::N, kk), t, s, n, p), tef(tt), k(kk) { + pfes_tefk(const pmesh *t, const TypeOfFE **tt, int kk, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fes(sum(tt, &Fem2D::TypeOfFE::N, kk), t, s, n, p), tef(tt), k(kk) { operator FESpace *( ); } FESpace *buildupdate( ) { @@ -467,13 +456,8 @@ class pfes_tefk : public v_fes { class pfes3_tef : public v_fes3 { public: const TypeOfFE3 *tef; - pfes3_tef(const pmesh3 *t, const TypeOfFE3 *tt, Stack s = NullStack, int n = 0, Expression *p = 0) - : v_fes3(tt->N, t, s, n, p), tef(tt) { - operator FESpace3 *( ); - } - FESpace3 *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpace3(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; - } + pfes3_tef(const pmesh3 *t, const TypeOfFE3 *tt, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fes3(tt->N, t, s, n, p), tef(tt) { operator FESpace3 *( ); } + FESpace3 *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpace3(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; } FESpace3 *buildupdate( ) { return *ppTh ? new FESpace3(**ppTh, *tef) : 0; } }; @@ -490,10 +474,8 @@ class pfes3_tefk : public v_fes3 { return r; } - pfes3_tefk(const pmesh3 *t, const Fem2D::TypeOfFE3 **tt, int kk, Stack s = NullStack, int n = 0, - Expression *p = 0) - : v_fes3(sum((const Fem2D::TypeOfFE3 **)tt, &Fem2D::TypeOfFE3::N, kk), t, s, n, p), tef(tt), - k(kk), atef(kk, tt), tefs(atef) + pfes3_tefk(const pmesh3 *t, const Fem2D::TypeOfFE3 **tt, int kk, Stack s = NullStack, int n = 0, Expression *p = 0) + : v_fes3(sum((const Fem2D::TypeOfFE3 **)tt, &Fem2D::TypeOfFE3::N, kk), t, s, n, p), tef(tt), k(kk), atef(kk, tt), tefs(atef) { // cout << "pfes_tefk const" << tef << " " << this << endl; @@ -505,22 +487,15 @@ class pfes3_tefk : public v_fes3 { return *ppTh ? new FESpace3(**ppTh, tefs) : 0; } virtual ~pfes3_tefk( ) { delete[] tef; } - FESpace3 *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpace3(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; - } + FESpace3 *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpace3(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; } }; // 3D surface class pfesS_tef : public v_fesS { public: const TypeOfFES *tef; - pfesS_tef(const pmeshS *t, const TypeOfFES *tt, Stack s = NullStack, int n = 0, Expression *p = 0) - : v_fesS(tt->N, t, s, n, p), tef(tt) { - operator FESpaceS *( ); - } - FESpaceS *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpaceS(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; - } + pfesS_tef(const pmeshS *t, const TypeOfFES *tt, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fesS(tt->N, t, s, n, p), tef(tt) { operator FESpaceS *( ); } + FESpaceS *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpaceS(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; } FESpaceS *buildupdate( ) { return *ppTh ? new FESpaceS(**ppTh, *tef) : 0; } }; @@ -537,10 +512,8 @@ class pfesS_tefk : public v_fesS { return r; } - pfesS_tefk(const pmeshS *t, const Fem2D::TypeOfFES **tt, int kk, Stack s = NullStack, int n = 0, - Expression *p = 0) - : v_fesS(sum((const Fem2D::TypeOfFES **)tt, &Fem2D::TypeOfFES::N, kk), t, s, n, p), tef(tt), - k(kk), atef(kk, tt), tefs(atef) + pfesS_tefk(const pmeshS *t, const Fem2D::TypeOfFES **tt, int kk, Stack s = NullStack, int n = 0, Expression *p = 0) + : v_fesS(sum((const Fem2D::TypeOfFES **)tt, &Fem2D::TypeOfFES::N, kk), t, s, n, p), tef(tt), k(kk), atef(kk, tt), tefs(atef) { // cout << "pfes_tefk const" << tef << " " << this << endl; @@ -552,22 +525,15 @@ class pfesS_tefk : public v_fesS { return *ppTh ? new FESpaceS(**ppTh, tefs) : 0; } virtual ~pfesS_tefk( ) { delete[] tef; } - FESpaceS *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpaceS(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; - } + FESpaceS *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpaceS(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; } }; // 3D curve class pfesL_tef : public v_fesL { public: const TypeOfFEL *tef; - pfesL_tef(const pmeshL *t, const TypeOfFEL *tt, Stack s = NullStack, int n = 0, Expression *p = 0) - : v_fesL(tt->N, t, s, n, p), tef(tt) { - operator FESpaceL *( ); - } - FESpaceL *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpaceL(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; - } + pfesL_tef(const pmeshL *t, const TypeOfFEL *tt, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fesL(tt->N, t, s, n, p), tef(tt) { operator FESpaceL *( ); } + FESpaceL *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpaceL(**ppTh, *tef, ndfe.size( ) / 2, ndfe) : 0; } FESpaceL *buildupdate( ) { return *ppTh ? new FESpaceL(**ppTh, *tef) : 0; } }; @@ -584,10 +550,8 @@ class pfesL_tefk : public v_fesL { return r; } - pfesL_tefk(const pmeshL *t, const Fem2D::TypeOfFEL **tt, int kk, Stack s = NullStack, int n = 0, - Expression *p = 0) - : v_fesL(sum((const Fem2D::TypeOfFEL **)tt, &Fem2D::TypeOfFEL::N, kk), t, s, n, p), tef(tt), - k(kk), atef(kk, tt), tefs(atef) + pfesL_tefk(const pmeshL *t, const Fem2D::TypeOfFEL **tt, int kk, Stack s = NullStack, int n = 0, Expression *p = 0) + : v_fesL(sum((const Fem2D::TypeOfFEL **)tt, &Fem2D::TypeOfFEL::N, kk), t, s, n, p), tef(tt), k(kk), atef(kk, tt), tefs(atef) { // cout << "pfes_tefk const" << tef << " " << this << endl; @@ -599,16 +563,14 @@ class pfesL_tefk : public v_fesL { return *ppTh ? new FESpaceL(**ppTh, tefs) : 0; } virtual ~pfesL_tefk( ) { delete[] tef; } - FESpaceL *buildupdate(KN< int > &ndfe) { - return *ppTh ? new FESpaceL(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; - } + FESpaceL *buildupdate(KN< int > &ndfe) { return *ppTh ? new FESpaceL(**ppTh, tefs, ndfe.size( ) / 2, ndfe) : 0; } }; /* struct infoBlockCompositeFESpace{ // struct useful for composite FESpace KN beginBlock; - KN indexBlock; + KN indexBlock; KN localIndexInTheBlock; infoBlockCompositeFESpace( const KN & b, const KN & i, const KN & li ): beginBlock(b), indexBlock(i), localIndexInTheBlock(li) {}; @@ -616,137 +578,126 @@ struct infoBlockCompositeFESpace{ }; */ -class vect_generic_v_fes { //: public RefCounter{ - public: - +class vect_generic_v_fes { //: public RefCounter{ + public: typedef pgenericfes A; - public: - int N; // size of the vector ( the number of FESpace ) - A *vect; // the vector containing the adress of generic_v_fes - KN typeFE; // ===== type of FE ==== - // The value of a type correspond to the second parameter of << forEachTypePtrfspace >> - // in for pfes, pfes3, pfesS, pfesL in [[ fflib/lgfem.cpp ]]. + public: + int N; // size of the vector ( the number of FESpace ) + A *vect; // the vector containing the adress of generic_v_fes + KN< int > typeFE; // ===== type of FE ==== + // The value of a type correspond to the second parameter of << forEachTypePtrfspace >> + // in for pfes, pfes3, pfesS, pfesL in [[ fflib/lgfem.cpp ]]. - //CountPointer< FESpace > pVh; // A voir avec Frederic pour savoir si il faut rajouter un - // un CountPointer + // CountPointer< FESpace > pVh; // A voir avec Frederic pour savoir si il faut rajouter un + // un CountPointer - - Stack stack; // the stack is use whith periodique expression + Stack stack; // the stack is use whith periodique expression - // constructor - vect_generic_v_fes(const E_FEarray &args, Stack s): N( args.size() ), typeFE( args.size() ), stack(s){ + vect_generic_v_fes(const E_FEarray &args, Stack s) : N(args.size( )), typeFE(args.size( )), stack(s) { // constructor - //vect_generic_v_fes(const E_FEarray &args, Stack s=NullStack): N( args.size() ), typeFE( args.size() ){ + // vect_generic_v_fes(const E_FEarray &args, Stack s=NullStack): N( args.size() ), typeFE( args.size() ){ // == PAC(e) == // // Morice :: attention <> est redéfini pour cette classe. // Il faut faire appel au type de <> associé à v_fes: // ::pfes == typedef v_fes *pfes; // - typedef ::pfes pfesTrue; + typedef ::pfes pfesTrue; aType atfs[] = {atype< ::pfes * >( ), atype< pfes3 * >( ), atype< pfesS * >( ), atype< pfesL * >( )}; vect = new A[N]; - - if(verbosity>3){ - for(int i=0; i> " << endl; - cerr << "The aType of the FESpace " << args[i].left( ) << " is not considered." << endl; - cerr << "The aType considered for FESpace is " << atfs[0] << "." << endl; - cerr << "The aType considered for FESpace is " << atfs[1] << "." << endl; - cerr << "The aType considered for FESpace is " << atfs[2] << "." << endl; - cerr << "The aType considered for FESpace is " << atfs[3] << "." << endl; - cerr << "type pgenericfes= " << atype< pgenericfes *>() << endl; - ffassert(0); - } + + for (int i = 0; i < args.size( ); i++) { + // cout << "i=" << i << endl; + if (atype< ::pfes * >( ) == args[i].left( )) { + // a = to< atfs[iii] >(args[i]); + pfesTrue *tmp = GetAny< pfesTrue * >(args[i].eval(stack)); + vect[i] = *tmp; + // vect[i] = args[i].f; + typeFE[i] = args[i].TYPEOFID( ); + } else if (atype< pfes3 * >( ) == args[i].left( )) { + // a = to< atfs[iii] >(args[i]); + pfes3 *tmp = GetAny< pfes3 * >(args[i].eval(stack)); + vect[i] = *tmp; + // vect[i] = args[i].RightValue(); + typeFE[i] = args[i].TYPEOFID( ); + } else if (atype< pfesS * >( ) == args[i].left( )) { + // a = to< atfs[iii] >(args[i]); + pfesS *tmp = GetAny< pfesS * >(args[i].eval(stack)); + vect[i] = *tmp; + // vect[i] = args[i].RightValue(); + typeFE[i] = args[i].TYPEOFID( ); + } else if (atype< pfesL * >( ) == args[i].left( )) { + // a = to< atfs[iii] >(args[i]); + pfesL *tmp = GetAny< pfesL * >(args[i].eval(stack)); + vect[i] = *tmp; + // vect[i] = args[i].RightValue(); + typeFE[i] = args[i].TYPEOFID( ); + } else { + cerr << "Error in the constructor of <> " << endl; + cerr << "The aType of the FESpace " << args[i].left( ) << " is not considered." << endl; + cerr << "The aType considered for FESpace is " << atfs[0] << "." << endl; + cerr << "The aType considered for FESpace is " << atfs[1] << "." << endl; + cerr << "The aType considered for FESpace is " << atfs[2] << "." << endl; + cerr << "The aType considered for FESpace is " << atfs[3] << "." << endl; + cerr << "type pgenericfes= " << atype< pgenericfes * >( ) << endl; + ffassert(0); + } } - update(); + update( ); } // destructor void destroy( ) { - delete [] vect; + delete[] vect; delete this; } - ~vect_generic_v_fes(){ - } + ~vect_generic_v_fes( ) {} /** - * @brief update the composant of the composite FESpace if a mesh have changed - * - */ - void update( ){ + * @brief update the composant of the composite FESpace if a mesh have changed + * + */ + void update( ) { // loop over the FESpace - for(int i=0; i( vect[i] ); + if (tt == 2) { + pfes pFES = dynamic_cast< pfes >(vect[i]); ffassert(pFES); - pmesh* ppTh = (pmesh *) vect[i]->getppTh(); - FESpace * pVh = (FESpace *) vect[i]->getpVh(); + pmesh *ppTh = (pmesh *)vect[i]->getppTh( ); + FESpace *pVh = (FESpace *)vect[i]->getpVh( ); // pfes pFES = dynamic_cast( vect[i] ); // cout << &pVh->Th << " "<< &mac->pVh->Th << endl; if (!pVh || *ppTh != &pVh->Th) pFES->pVh = CountPointer< FESpace >(pFES->update( ), true); - } - else if(tt == 3){ - pmesh3* ppTh = (pmesh3 *) vect[i]->getppTh(); - const pfes3 pFES = dynamic_cast( vect[i] ); - ffassert(pFES); - FESpace3 * pVh = (FESpace3*) vect[i]->getpVh(); + } else if (tt == 3) { + pmesh3 *ppTh = (pmesh3 *)vect[i]->getppTh( ); + const pfes3 pFES = dynamic_cast< const pfes3 >(vect[i]); + ffassert(pFES); + FESpace3 *pVh = (FESpace3 *)vect[i]->getpVh( ); if (!pVh || *ppTh != &pVh->Th) pFES->pVh = CountPointer< FESpace3 >(pFES->update( ), true); - - } - else if(tt == 4){ - pmeshS* ppTh = (pmeshS *) vect[i]->getppTh(); - const pfesS pFES = dynamic_cast( vect[i] ); - ffassert(pFES); - FESpaceS * pVh = (FESpaceS*) vect[i]->getpVh(); + + } else if (tt == 4) { + pmeshS *ppTh = (pmeshS *)vect[i]->getppTh( ); + const pfesS pFES = dynamic_cast< const pfesS >(vect[i]); + ffassert(pFES); + FESpaceS *pVh = (FESpaceS *)vect[i]->getpVh( ); if (!pVh || *ppTh != &pVh->Th) pFES->pVh = CountPointer< FESpaceS >(pFES->update( ), true); - - } - else if(tt == 5){ - pmeshL* ppTh = (pmeshL *) vect[i]->getppTh(); - const pfesL pFES = dynamic_cast( vect[i] ); + + } else if (tt == 5) { + pmeshL *ppTh = (pmeshL *)vect[i]->getppTh( ); + const pfesL pFES = dynamic_cast< const pfesL >(vect[i]); ffassert(pFES); - FESpaceL * pVh = (FESpaceL*) vect[i]->getpVh(); + FESpaceL *pVh = (FESpaceL *)vect[i]->getpVh( ); if (!pVh || *ppTh != &pVh->Th) pFES->pVh = CountPointer< FESpaceL >(pFES->update( ), true); } /*else{ @@ -757,71 +708,67 @@ class vect_generic_v_fes { //: public RefCounter{ } } - // acces to the different pgenericfes - A &operator[](int i){ return vect[i];} + A &operator[](int i) { return vect[i]; } //=== Morice :: ATTENTION : PEUT ETRE A METTRE AILLEURS ===// - void printPointer(){ - cout <<" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " < vectOfNbOfDF(){ - KN result(N); - for(int i=0; i< N; i++){ + KN< int > vectOfNbOfDF( ) { + KN< int > result(N); + for (int i = 0; i < N; i++) { int tt = typeFE[i]; - if(tt == 2){ - const FESpace * PUh = (FESpace*) vect[i]->getpVh(); + if (tt == 2) { + const FESpace *PUh = (FESpace *)vect[i]->getpVh( ); result[i] = PUh->NbOfDF; - } - else if(tt == 3){ - const FESpace3 * PUh = (FESpace3*) vect[i]->getpVh(); - result[i] = PUh->NbOfDF; - } - else if(tt == 4){ - const FESpaceS * PUh = (FESpaceS*) vect[i]->getpVh(); + } else if (tt == 3) { + const FESpace3 *PUh = (FESpace3 *)vect[i]->getpVh( ); result[i] = PUh->NbOfDF; - } - else if(tt == 5){ - const FESpaceL * PUh = (FESpaceL*) vect[i]->getpVh(); + } else if (tt == 4) { + const FESpaceS *PUh = (FESpaceS *)vect[i]->getpVh( ); + result[i] = PUh->NbOfDF; + } else if (tt == 5) { + const FESpaceL *PUh = (FESpaceL *)vect[i]->getpVh( ); result[i] = PUh->NbOfDF; } } - //cout << "vectOfNbOfDF=" << result << endl; - return result; + // cout << "vectOfNbOfDF=" << result << endl; + return result; } - int totalNbOfDF(){ - KN arrayNbOfDF = vectOfNbOfDF(); - int tNbOfDF=0; - for(int i=0; i< N; i++){ - tNbOfDF += arrayNbOfDF[i]; + int totalNbOfDF( ) { + KN< int > arrayNbOfDF = vectOfNbOfDF( ); + int tNbOfDF = 0; + for (int i = 0; i < N; i++) { + tNbOfDF += arrayNbOfDF[i]; } - //cout << "total NbOfDF=" << tNbOfDF << endl; + // cout << "total NbOfDF=" << tNbOfDF << endl; return tNbOfDF; } - KN vectOfNbitem(){ - KN result(N); - for(int i=0; i< N; i++){ + KN< int > vectOfNbitem( ) { + KN< int > result(N); + for (int i = 0; i < N; i++) { // get the number of item of i-th component of the composite vector of FESpace - result[i] = vect[i]->getN(); + result[i] = vect[i]->getN( ); } - //cout << "vectOfNbitem=" << result << endl; + // cout << "vectOfNbitem=" << result << endl; return result; } - int totalNbitem(){ - KN arrayNbItem = vectOfNbitem(); - int tNbItem=0; - for(int i=0; i< N; i++){ - tNbItem += arrayNbItem[i]; + int totalNbitem( ) { + KN< int > arrayNbItem = vectOfNbitem( ); + int tNbItem = 0; + for (int i = 0; i < N; i++) { + tNbItem += arrayNbItem[i]; } return tNbItem; } @@ -831,10 +778,7 @@ class pfes_fes : public v_fes { public: pfes *Vh; int n; - pfes_fes(pfes *Vhh, int nn, Stack s = NullStack, int n = 0, Expression *p = 0) - : v_fes((**Vhh).N * nn, static_cast< const v_fes * >(*Vhh), s, n, p), Vh(Vhh), n(nn) { - operator FESpace *( ); - }; + pfes_fes(pfes *Vhh, int nn, Stack s = NullStack, int n = 0, Expression *p = 0) : v_fes((**Vhh).N * nn, static_cast< const v_fes * >(*Vhh), s, n, p), Vh(Vhh), n(nn) { operator FESpace *( ); }; FESpace *buildupdate( ) { return new FESpace(*(FESpace *)**Vh, n); } FESpace *buildupdate(int &nbdfv, KN< int > &ndfv, int &nbdfe, KN< int > &ndfe) { InternalError(" No way to define a periodic BC in this case: tensorisation of FEspace "); @@ -853,7 +797,7 @@ class FEcomp { friend class FEbase< K, v_fes >; FEbase< K, v_fes > *base; int comp; - FEcomp(FEbase< K, v_fes > *b, int c) : base(b), comp(c){}; + FEcomp(FEbase< K, v_fes > *b, int c) : base(b), comp(c) {}; private: // rule of programming FEcomp(const FEcomp &); @@ -933,8 +877,7 @@ class FEbaseArray : public FEbaseArrayKn< K > { // int N; FEbase< K, v_fes > **xx; - FEbaseArray(const pfes *ppVh, int NN) - : FEbaseArrayKn< K >(NN), xx(new FEbase< K, v_fes > *[std::max(NN, 1)]) { + FEbaseArray(const pfes *ppVh, int NN) : FEbaseArrayKn< K >(NN), xx(new FEbase< K, v_fes > *[std::max(NN, 1)]) { for (int i = 0; i < std::max(this->N, 1); i++) xx[i] = new FEbase< K, v_fes >(ppVh); } ~FEbaseArray( ) { @@ -955,8 +898,7 @@ class FEbaseArray : public FEbaseArrayKn< K > { FEbase< K, v_fes > **yy = new FEbase< K, v_fes > *[i]; if (i > this->N) { for (unsigned int j = 0; j < std::max(this->N, 1); ++j) yy[j] = xx[j]; - for (unsigned int j = std::max(this->N, 1); j < i; ++j) - yy[j] = new FEbase< K, v_fes >(xx[0]->pVh); + for (unsigned int j = std::max(this->N, 1); j < i; ++j) yy[j] = new FEbase< K, v_fes >(xx[0]->pVh); } else { for (unsigned int j = 0; j < i; ++j) yy[j] = xx[j]; for (unsigned int j = i; j < this->N; ++j) xx[j]->destroy( ); @@ -978,33 +920,27 @@ class FEbaseArray : public FEbaseArrayKn< K > { }; void GetPeriodic(const int d, Expression perio, int &nbcperiodic, Expression *&periodic); -int GetPeriodic(Expression bb, Expression &b);// 1dhat -int GetPeriodic(Expression bb, Expression &b, Expression &f);//2dhat -int GetPeriodic(Expression bb, Expression &b, Expression &f1, Expression &f2);//3dhat - -C_F0 NewFEarray(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim); -C_F0 NewFEarray(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim); -C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim); -C_F0 NewFEvariable(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, - int dim); -inline C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, bool cplx, - int dim) { +int GetPeriodic(Expression bb, Expression &b); // 1dhat +int GetPeriodic(Expression bb, Expression &b, Expression &f); // 2dhat +int GetPeriodic(Expression bb, Expression &b, Expression &f1, Expression &f2); // 3dhat + +C_F0 NewFEarray(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim); +C_F0 NewFEarray(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim); +C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim); +C_F0 NewFEvariable(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, CC_F0 init, bool cplx, int dim); +inline C_F0 NewFEvariable(const char *id, Block *currentblock, C_F0 &fespacetype, bool cplx, int dim) { CC_F0 init; init = 0; return NewFEvariable(id, currentblock, fespacetype, init, cplx, dim); } -inline C_F0 NewFEvariable(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, bool cplx, - int dim) { +inline C_F0 NewFEvariable(ListOfId *ids, Block *currentblock, C_F0 &fespacetype, bool cplx, int dim) { CC_F0 init; init = 0; return NewFEvariable(ids, currentblock, fespacetype, init, cplx, dim); } -KN dimFESpaceImage(const basicAC_F0 &args); +KN< size_t > dimFESpaceImage(const basicAC_F0 &args); aType typeFESpace(const basicAC_F0 &args); template< class K, class vv_fes, class FE = FEbase< K, vv_fes > > @@ -1016,13 +952,9 @@ class E_FEcomp : public E_F0mps { Expression a0; const int comp, N; - AnyType operator( )(Stack s) const { - return SetAny< Result >(Result(*GetAny< FE ** >((*a0)(s)), comp)); - } + AnyType operator( )(Stack s) const { return SetAny< Result >(Result(*GetAny< FE ** >((*a0)(s)), comp)); } E_FEcomp(const C_F0 &x, const int cc, int NN) : a0(x.LeftValue( )), comp(cc), N(NN) { - if (x.left( ) != atype< FE ** >( )) - cout << "E_FEcomp: Bug " << *x.left( ) << " != " << *atype< FE ** >( ) << " case " - << typeid(K).name( ) << endl; + if (x.left( ) != atype< FE ** >( )) cout << "E_FEcomp: Bug " << *x.left( ) << " != " << *atype< FE ** >( ) << " case " << typeid(K).name( ) << endl; // CompileError("E_FEcomp: Bug ?"); throwassert(x.left( ) == atype< FE ** >( ) && a0); } @@ -1067,9 +999,7 @@ class interpolate_f_X_1 : public OneOperator { E_F0 *code(const basicAC_F0 &args) const { return new CODE(args); } - interpolate_f_X_1( ) - : OneOperator(map_type[typeid(type).name( )], map_type[typeid(pfer).name( )], - map_type[typeid(E_Array).name( )]) {} + interpolate_f_X_1( ) : OneOperator(map_type[typeid(type).name( )], map_type[typeid(pfer).name( )], map_type[typeid(E_Array).name( )]) {} }; inline FESpace *v_fes::update( ) { @@ -1169,8 +1099,7 @@ class E_F_StackF0F0opt2 : public E_F0mps { const E_FEcomp< K, v_fes > *e = dynamic_cast< const E_FEcomp< K, v_fes > * >(a0); if (e && e->N != 1) { - cerr << " err interpolation of no scalar FE function componant (" << e->comp << " in 0.." - << e->N << ") << with scalar function \n"; + cerr << " err interpolation of no scalar FE function componant (" << e->comp << " in 0.." << e->N << ") << with scalar function \n"; CompileError("interpolation of no scalar FE function componant with scalar function "); } @@ -1314,12 +1243,8 @@ class E_FEcomp_get_elmnt_array : public E_F0 { const E_KFEArray *a00; const int comp, N; - E_FEcomp_get_elmnt_array(Expression aa0, Expression aa1, int compp, int NN, - const E_KFEArray *aa00) - : a0(aa0), a1(aa1), a00(aa00), comp(compp), N(NN) {} - AnyType operator( )(Stack s) const { - return SetAny< R >(get_element(GetAny< A >((*a0)(s)), GetAny< B >((*a1)(s)))); - } + E_FEcomp_get_elmnt_array(Expression aa0, Expression aa1, int compp, int NN, const E_KFEArray *aa00) : a0(aa0), a1(aa1), a00(aa00), comp(compp), N(NN) {} + AnyType operator( )(Stack s) const { return SetAny< R >(get_element(GetAny< A >((*a0)(s)), GetAny< B >((*a1)(s)))); } bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ); } // }; @@ -1350,10 +1275,7 @@ class OneOperator2_FE_get_elmnt : public OneOperator { ffassert(afe); return new CODE(t0->CastTo(args[0]), t1->CastTo(args[1]), afe->comp, afe->N, afe); } - OneOperator2_FE_get_elmnt( ) - : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], - map_type[typeid(B).name( )]), - t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]) {} + OneOperator2_FE_get_elmnt( ) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]), t0(map_type[typeid(A).name( )]), t1(map_type[typeid(B).name( )]) {} }; template< typename KK, typename vv_fes, typename CC > @@ -1408,9 +1330,7 @@ class init_FE_eqarray : public OneOperator { public: Expression a0, a1; MC a2; - CODE(Expression aa0, Expression aa1, Expression aa2) : a0(aa0), a1(aa1), a2(FF::Clone(aa2)) { - ffassert(FF::Check(a2)); - } + CODE(Expression aa0, Expression aa1, Expression aa2) : a0(aa0), a1(aa1), a2(FF::Clone(aa2)) { ffassert(FF::Check(a2)); } AnyType operator( )(Stack s) const { AnyType aa0 = (*a0)(s); @@ -1433,19 +1353,10 @@ class init_FE_eqarray : public OneOperator { return aa0; } virtual size_t nbitem( ) const { return a2->nbitem( ); } - bool MeshIndependent( ) const { - return a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ); - } // + bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ) && a2->MeshIndependent( ); } // }; - init_FE_eqarray(int ppref) - : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], - map_type[typeid(B).name( )], map_type[typeid(C).name( )]) { - pref = ppref; - } - E_F0 *code(const basicAC_F0 &args) const { - - return new CODE(args[0], args[1], map_type[typeid(C).name( )]->CastTo(args[2])); - } + init_FE_eqarray(int ppref) : OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )], map_type[typeid(C).name( )]) { pref = ppref; } + E_F0 *code(const basicAC_F0 &args) const { return new CODE(args[0], args[1], map_type[typeid(C).name( )]->CastTo(args[2])); } }; #endif diff --git a/src/fflib/lgmat.cpp b/src/fflib/lgmat.cpp index 3721fb54f..5e3dc9c29 100644 --- a/src/fflib/lgmat.cpp +++ b/src/fflib/lgmat.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef REMOVE_CODE - // to do F. HECHT +// to do F. HECHT #ifdef __MWERKS__ #pragma optimization_level 0 #endif @@ -36,17 +36,20 @@ #include "AFunction_ext.hpp" #include "CGNL.hpp" -namespace bamg { class Triangles; } -namespace Fem2D { void DrawIsoT(const R2 Pt[3],const R ff[3],const RN_ & Viso); } +namespace bamg { + class Triangles; +} +namespace Fem2D { + void DrawIsoT(const R2 Pt[3], const R ff[3], const RN_ &Viso); +} -extern const basicForEachType *aatypeknlongp; //// for compilation error with g++ 3.2.2 +extern const basicForEachType *aatypeknlongp; //// for compilation error with g++ 3.2.2 #include "BamgFreeFem.hpp" #include "PlotStream.hpp" extern FILE *ThePlotStream; - // Debut FH Houston -------- avril 2004 --------- // class for operator on sparse matrix // ------------------------------------ @@ -58,3109 +61,2860 @@ extern FILE *ThePlotStream; // \sum_i a_i*A_i where a_i is a scalare and A_i is a sparse matrix // - - -template -list *, bool > > * to(Matrice_Creuse * M) -{ - list *,bool> > * l=new list *,bool> >; - l ->push_back(make_tuple *,bool>(1,M->A,false)); - return l; +template< class R > +list< tuple< R, MatriceCreuse< R > *, bool > > *to(Matrice_Creuse< R > *M) { + list< tuple< R, MatriceCreuse< R > *, bool > > *l = new list< tuple< R, MatriceCreuse< R > *, bool > >; + l->push_back(make_tuple< R, MatriceCreuse< R > *, bool >(1, M->A, false)); + return l; } -template -list *, bool > > * to(Matrice_Creuse_Transpose M) -{ - list *,bool> > * l=new list *,bool> >; - l ->push_back(make_tuple *,bool>(1,M.A->A,true)); - return l; +template< class R > +list< tuple< R, MatriceCreuse< R > *, bool > > *to(Matrice_Creuse_Transpose< R > M) { + list< tuple< R, MatriceCreuse< R > *, bool > > *l = new list< tuple< R, MatriceCreuse< R > *, bool > >; + l->push_back(make_tuple< R, MatriceCreuse< R > *, bool >(1, M.A->A, true)); + return l; } -template -AnyType M2L3 (Stack , const AnyType & pp) -{ - return to(GetAny *>(pp)); +template< class R > +AnyType M2L3(Stack, const AnyType &pp) { + return to(GetAny< Matrice_Creuse< R > * >(pp)); } - -template -AnyType tM2L3 (Stack , const AnyType & pp) -{ - return to(GetAny >(pp)); +template< class R > +AnyType tM2L3(Stack, const AnyType &pp) { + return to(GetAny< Matrice_Creuse_Transpose< R > >(pp)); } +template< class R > +struct Op2_ListCM { + using first_argument_type = R; + using second_argument_type = Matrice_Creuse< R > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef R AA; + typedef Matrice_Creuse< R > *BB; -template -struct Op2_ListCM - { - using first_argument_type = R; - using second_argument_type = Matrice_Creuse *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef R AA; - typedef Matrice_Creuse * BB; - - static RR f(const AA & a,const BB & b) - { - RR r= new list

; - P p(a,b->pMC(),false); - r ->push_back(p); - return r;} + static RR f(const AA &a, const BB &b) { + RR r = new list< P >; + P p(a, b->pMC( ), false); + r->push_back(p); + return r; + } }; -template void PrintL(const char* cc, list*,bool> > const * const lM) -{ - if(verbosity<100) return; - typedef typename list *,bool> >::const_iterator lconst_iterator; - - lconst_iterator begin=lM->begin(); - lconst_iterator end=lM->end(); - lconst_iterator i; - cout << cc << " (" ; - for(i=begin;i!=end;i++++) +template< class R > +void PrintL(const char *cc, list< tuple< R, VirtualMatrix< int, R > *, bool > > const *const lM) { + if (verbosity < 100) return; + typedef typename list< tuple< R, VirtualMatrix< int, R > *, bool > >::const_iterator lconst_iterator; + + lconst_iterator begin = lM->begin( ); + lconst_iterator end = lM->end( ); + lconst_iterator i; + cout << cc << " ("; + for (i = begin; i != end; i++ ++) { + if (std::get< 1 >(*i)) // M == 0 => zero matrix { - if(std::get<1>(*i)) // M == 0 => zero matrix - { - VirtualMatrix& M=*std::get<1>(*i); - bool transpose = std::get<2>(*i) ; - R coef=std::get<0>(*i); - cout << " + " << coef << "*" << &M <<"^" << transpose ; - - } + VirtualMatrix< int, R > &M = *std::get< 1 >(*i); + bool transpose = std::get< 2 >(*i); + R coef = std::get< 0 >(*i); + cout << " + " << coef << "*" << &M << "^" << transpose; } - - - cout << ") "<< endl; -} -template -struct Op2_ListMC - { - using first_argument_type = Matrice_Creuse *; - using second_argument_type = R; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef R AA; - typedef Matrice_Creuse * BB; - - static RR f(const BB & b,const AA & a) - { - RR r= new list

; - P p(a,b->pMC(),false); - r ->push_back(p); - return r;} + } + + cout << ") " << endl; +} +template< class R > +struct Op2_ListMC { + using first_argument_type = Matrice_Creuse< R > *; + using second_argument_type = R; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef R AA; + typedef Matrice_Creuse< R > *BB; + + static RR f(const BB &b, const AA &a) { + RR r = new list< P >; + P p(a, b->pMC( ), false); + r->push_back(p); + return r; + } }; // ADD FH 16/02/2007 -template -struct Op2_ListCMt -{ - using first_argument_type = R; - using second_argument_type = Matrice_Creuse_Transpose ; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef R AA; - typedef Matrice_Creuse_Transpose BB; - - static RR f(const AA & a,const BB & b) - { - RR r= new list

; - P p(a,b.A->pMC(),true); - r ->push_back(p); - return r;} +template< class R > +struct Op2_ListCMt { + using first_argument_type = R; + using second_argument_type = Matrice_Creuse_Transpose< R >; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef R AA; + typedef Matrice_Creuse_Transpose< R > BB; + + static RR f(const AA &a, const BB &b) { + RR r = new list< P >; + P p(a, b.A->pMC( ), true); + r->push_back(p); + return r; + } }; -template -struct Op2_ListMtC -{ - using first_argument_type = Matrice_Creuse_Transpose ; - using second_argument_type = R; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef R AA; - typedef Matrice_Creuse_Transpose BB; - - static RR f(const BB & b,const AA & a) - { - RR r= new list

; - P p(a,b.A->pMC(),true); - r ->push_back(p); - return r;} +template< class R > +struct Op2_ListMtC { + using first_argument_type = Matrice_Creuse_Transpose< R >; + using second_argument_type = R; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef R AA; + typedef Matrice_Creuse_Transpose< R > BB; + + static RR f(const BB &b, const AA &a) { + RR r = new list< P >; + P p(a, b.A->pMC( ), true); + r->push_back(p); + return r; + } }; // FIN ADD 16/02/2007 - - -template -struct Op1_LCMd -{ // - ... - using argument_type = list *,bool> > *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - - static RR f(const RR & l) - { - typedef typename list *,bool> >::iterator lci; - for(lci i= l->begin();i !=l->end();++i) - get<0>(*i) *= R(c); - PrintL(" - Op1_LCMd: ",l); - return l; - } - +template< class R, int c = -1 > +struct Op1_LCMd { // - ... + using argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + + static RR f(const RR &l) { + typedef typename list< tuple< R, MatriceCreuse< R > *, bool > >::iterator lci; + for (lci i = l->begin( ); i != l->end( ); ++i) get< 0 >(*i) *= R(c); + PrintL(" - Op1_LCMd: ", l); + return l; + } }; -template -struct Op2_ListCMCMadd -{ // ... + ... - using first_argument_type = list *,bool> > *; - using second_argument_type = list *,bool> > *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - - static RR f(const RR & a,const RR & b) - { - a->insert(a->end(),b->begin(),b->end()); +template< class R > +struct Op2_ListCMCMadd { // ... + ... + using first_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using second_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + + static RR f(const RR &a, const RR &b) { + a->insert(a->end( ), b->begin( ), b->end( )); delete b; return a; } - }; -template -struct Op2_ListCMCMsub -{ // ... + ... - using first_argument_type = list *,bool> > *; - using second_argument_type = list *,bool> > *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - - static RR f(const RR & a,const RR & b) - { - Op1_LCMd::f(b); - PrintL("Op2_ListCMCMsub +",a); - PrintL(" -(-) ",b); - - a->insert(a->end(),b->begin(),b->end()); - PrintL(" => ",a); - delete b; - return a; - } - +template< class R > +struct Op2_ListCMCMsub { // ... + ... + using first_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using second_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + + static RR f(const RR &a, const RR &b) { + Op1_LCMd< R, -1 >::f(b); + PrintL("Op2_ListCMCMsub +", a); + PrintL(" -(-) ", b); + + a->insert(a->end( ), b->begin( ), b->end( )); + PrintL(" => ", a); + delete b; + return a; + } }; -template -struct Op2_ListMCMadd -{ // M + .... - using first_argument_type = Matrice_Creuse *; - using second_argument_type = list *,bool> > *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef Matrice_Creuse * MM; - - static RR f(const MM & a,const RR & b) - { +template< class R, int cc = 1 > +struct Op2_ListMCMadd { // M + .... + using first_argument_type = Matrice_Creuse< R > *; + using second_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef Matrice_Creuse< R > *MM; + + static RR f(const MM &a, const RR &b) { // M + c*L - Op1_LCMd::f(b); - PrintL("Op2_ListMCMadd M +",b); + Op1_LCMd< R, cc >::f(b); + PrintL("Op2_ListMCMadd M +", b); - b->push_front(make_tuple *,bool>(R(1.),a->A,false)); + b->push_front(make_tuple< R, MatriceCreuse< R > *, bool >(R(1.), a->A, false)); return b; } - - }; -template -struct Op2_ListCMMadd -{ // .... + M - using first_argument_type = list *,bool> > *; - using second_argument_type = Matrice_Creuse *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef Matrice_Creuse * MM; - - static RR f(const RR & a,const MM & b) - { +template< class R, int cc = 1 > +struct Op2_ListCMMadd { // .... + M + using first_argument_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + using second_argument_type = Matrice_Creuse< R > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef Matrice_Creuse< R > *MM; + + static RR f(const RR &a, const MM &b) { // L + c*M - a->push_back(make_tuple *,bool>(R(cc),b->A,false)); + a->push_back(make_tuple< R, MatriceCreuse< R > *, bool >(R(cc), b->A, false)); return a; } - - }; -template -struct Op2_ListMMadd -{ // M + M - using first_argument_type = Matrice_Creuse *; - using second_argument_type = Matrice_Creuse *; - using result_type = list *,bool> > *; - typedef tuple *,bool> P; - typedef list

L; - typedef L * RR; - typedef Matrice_Creuse * MM; - - static RR f(const MM & a,const MM & b) - { +template< class R, int cc = 1 > +struct Op2_ListMMadd { // M + M + using first_argument_type = Matrice_Creuse< R > *; + using second_argument_type = Matrice_Creuse< R > *; + using result_type = list< tuple< R, MatriceCreuse< R > *, bool > > *; + typedef tuple< R, MatriceCreuse< R > *, bool > P; + typedef list< P > L; + typedef L *RR; + typedef Matrice_Creuse< R > *MM; + + static RR f(const MM &a, const MM &b) { // M + c M - L * l=to(a); - l->push_back(make_tuple *>(R(cc),b->A,false)); + L *l = to(a); + l->push_back(make_tuple< R, MatriceCreuse< R > * >(R(cc), b->A, false)); return l; } - - }; // Fin Add FH Houston -------- // for Jolivet to build restriction jan 2014 // t[int] I= restrict(VCh,VGh,IPG); // ou -template -class RestrictArray : public OneOperator { public: - template< typename T > struct Base { typedef T B; }; - template< typename T > struct Base< T* >{ typedef T B;}; - - typedef typename Base::B::FESpace FESpace; - typedef typename FESpace::FElement FElement; - - class Op : public E_F0info { public: // passe de l'info .. - typedef pfes * A; - Expression a,b,c,d; - static const int n_name_param =0; - Expression nargs[n_name_param]; - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - KN_ arg(int i,Stack stack,KN_ a ) const{ return nargs[i] ? GetAny >( (*nargs[i])(stack) ): a;} - - public: - Op(const basicAC_F0 & args,Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc),d(0) { - args.SetNameParam(n_name_param,0,nargs); - - } - }; - RestrictArray() : OneOperator( atype::Op *>(),//atype* >(), - atype(), - atype(), - atype >()) {} - - E_F0 * code(const basicAC_F0 & args) const - { - if(args.size()!=3)CompileError("Bug in RestrictArray code nb of args != 3 ????? bizarre" ); - return new Op(args,t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); - } +template< class pfes > +class RestrictArray : public OneOperator { + public: + template< typename T > + struct Base { + typedef T B; + }; + template< typename T > + struct Base< T * > { + typedef T B; + }; + + typedef typename Base< pfes >::B::FESpace FESpace; + typedef typename FESpace::FElement FElement; + + class Op : public E_F0info { + public: // passe de l'info .. + typedef pfes *A; + Expression a, b, c, d; + static const int n_name_param = 0; + Expression nargs[n_name_param]; + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } + + public: + Op(const basicAC_F0 &args, Expression aa, Expression bb, Expression cc) : a(aa), b(bb), c(cc), d(0) { args.SetNameParam(n_name_param, 0, nargs); } + }; + RestrictArray( ) + : OneOperator(atype< const typename RestrictArray< pfes >::Op * >( ), // atype* >(), + atype< pfes * >( ), atype< pfes * >( ), atype< KN_< long > >( )) {} + + E_F0 *code(const basicAC_F0 &args) const { + if (args.size( ) != 3) CompileError("Bug in RestrictArray code nb of args != 3 ????? bizarre"); + return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); + } }; // end restrict ... -template< typename T > struct Base { typedef T B; }; -template< typename T > struct Base< T* >{ typedef T B;}; - -template -AnyType SetRestrict(Stack stack,Expression einj,Expression erest) -{ - - typedef typename Base::B::FESpace FESpace; - typedef typename FESpace::FElement FElement; - - KN * pinj =GetAny*>((*einj)(stack)); - const typename RestrictArray::Op * ar(dynamic_cast::Op *>(erest)); - ffassert(ar); - if( verbosity>9) cout << " -- RestrictArray "<< endl; - pfes * pCUh = GetAny< pfes * >((* ar->a)(stack)); - pfes * pFVh = GetAny< pfes * >((* ar->b)(stack)); - // verif same FE. - KN_ ncf= GetAny< KN_ >((* ar->c)(stack)); - FESpace * pVCh = **pCUh; - FESpace * pVFh = **pFVh; - FESpace & VCh = *pVCh; - FESpace & VFh = *pVFh; - long neC = pVCh ? VCh.NbOfElements : 0; - long neF = pVFh ? VFh.NbOfElements : 0; - long ndfC = pVCh ? VCh.NbOfDF : 0; - long ndfF = pVFh ? VFh.NbOfDF : 0; - if (!neC || !neF) neC = neF = ndfC = ndfF = 0; - - KN_ nc2f= ncf; - if(INIT==0) - pinj->init(ndfC); - else pinj->resize(ndfC); - KN & inj=*pinj; - inj = -1; // un set .. - if( verbosity>9) cout<< " ne =" << neC << " " << neF << endl; - - for(int kc=0; kc 99) cout << kc << " " << kf << " : " <= 0 && kf < neF); - ffassert( kc >= 0 && kc< neC); - - for(int df=0; df99) cout << dfC <<" -> "<< dfF << endl; - assert(dfC >= 0 && dfC < ndfC); - inj[dfC] = dfF; - } +template< typename T > +struct Base { + typedef T B; +}; +template< typename T > +struct Base< T * > { + typedef T B; +}; +template< class pfes, int INIT > +AnyType SetRestrict(Stack stack, Expression einj, Expression erest) { + + typedef typename Base< pfes >::B::FESpace FESpace; + typedef typename FESpace::FElement FElement; + + KN< long > *pinj = GetAny< KN< long > * >((*einj)(stack)); + const typename RestrictArray< pfes >::Op *ar(dynamic_cast< const typename RestrictArray< pfes >::Op * >(erest)); + ffassert(ar); + if (verbosity > 9) cout << " -- RestrictArray " << endl; + pfes *pCUh = GetAny< pfes * >((*ar->a)(stack)); + pfes *pFVh = GetAny< pfes * >((*ar->b)(stack)); + // verif same FE. + KN_< long > ncf = GetAny< KN_< long > >((*ar->c)(stack)); + FESpace *pVCh = **pCUh; + FESpace *pVFh = **pFVh; + FESpace &VCh = *pVCh; + FESpace &VFh = *pVFh; + long neC = pVCh ? VCh.NbOfElements : 0; + long neF = pVFh ? VFh.NbOfElements : 0; + long ndfC = pVCh ? VCh.NbOfDF : 0; + long ndfF = pVFh ? VFh.NbOfDF : 0; + if (!neC || !neF) neC = neF = ndfC = ndfF = 0; + + KN_< long > nc2f = ncf; + if (INIT == 0) + pinj->init(ndfC); + else + pinj->resize(ndfC); + KN< long > &inj = *pinj; + inj = -1; // un set .. + if (verbosity > 9) cout << " ne =" << neC << " " << neF << endl; + + for (int kc = 0; kc < neC; kc++) { + + int kf = nc2f(kc); + FElement KC(pVCh, kc); + FElement KF(pVFh, kf); + + int ndofKC = KC.NbDoF( ); + int ndofKF = KF.NbDoF( ); + if (verbosity > 99) cout << kc << " " << kf << " : " << ndofKC << " " << ndofKF << endl; + ffassert(ndofKC == ndofKF); + ffassert(kf >= 0 && kf < neF); + ffassert(kc >= 0 && kc < neC); + + for (int df = 0; df < ndofKC; df++) { + int dfC = KC(df), dfF = KF(df); + if (verbosity > 99) cout << dfC << " -> " << dfF << endl; + assert(dfC >= 0 && dfC < ndfC); + inj[dfC] = dfF; } - if( verbosity>9) cout << " restrict: Inject= " << inj << endl; - ffassert(inj.min() != -1); + } + if (verbosity > 9) cout << " restrict: Inject= " << inj << endl; + ffassert(inj.min( ) != -1); return pinj; } // Fin Add FH Houston -------- -template -class MatrixInterpolation : public OneOperator { public: - - class Op : public E_F0info { public: - //typedef pfes * A; - Expression a,b,c,d; - static const int n_name_param =5; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - KN_ arg(int i,Stack stack,KN_ a ) const{ return nargs[i] ? GetAny >( (*nargs[i])(stack) ): a;} - - public: - Op(const basicAC_F0 & args,Expression aa,Expression bb) : a(aa),b(bb),c(0),d(0) { - args.SetNameParam(n_name_param,name_param,nargs); } - Op(const basicAC_F0 & args,Expression aa,Expression bb,Expression cc) : a(aa),b(bb),c(cc),d(0) { - args.SetNameParam(n_name_param,name_param,nargs); } - Op(const basicAC_F0 & args,Expression aa,Expression bb,Expression cc,Expression dd) : a(aa),b(bb),c(cc),d(dd) { - args.SetNameParam(n_name_param,name_param,nargs); } - - - }; - // interpolation(Vh,Vh) - MatrixInterpolation() : OneOperator(atype::Op *>(), - atype(), - atype()) {} - // interpolation(Vh,xx,yy) // 2d - MatrixInterpolation(int bidon) : OneOperator(atype::Op *>(), - atype(),atype >(),atype >()) {} - - // interpolation(Vh,xx,yy,zz) // 3d - MatrixInterpolation(int bidon,int bidon2) : OneOperator(atype::Op *>(), - atype(),atype >(),atype >(),atype >()) {} - - - E_F0 * code(const basicAC_F0 & args) const - { - if(args.size()==2) - return new Op(args,t[0]->CastTo(args[0]), - t[1]->CastTo(args[1])); - else if(args.size()==3) - return new Op(args,t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); - else if(args.size()==4) - return new Op(args,t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), - t[2]->CastTo(args[3]) - ); - else CompileError("Bug in MatrixInterpolation code nb != 2 or 3 ????? bizarre" ); - return 0; - } +template< class pfes1, class pfes2 > +class MatrixInterpolation : public OneOperator { + public: + class Op : public E_F0info { + public: + // typedef pfes * A; + Expression a, b, c, d; + static const int n_name_param = 5; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } + + public: + Op(const basicAC_F0 &args, Expression aa, Expression bb) : a(aa), b(bb), c(0), d(0) { args.SetNameParam(n_name_param, name_param, nargs); } + Op(const basicAC_F0 &args, Expression aa, Expression bb, Expression cc) : a(aa), b(bb), c(cc), d(0) { args.SetNameParam(n_name_param, name_param, nargs); } + Op(const basicAC_F0 &args, Expression aa, Expression bb, Expression cc, Expression dd) : a(aa), b(bb), c(cc), d(dd) { args.SetNameParam(n_name_param, name_param, nargs); } + }; + // interpolation(Vh,Vh) + MatrixInterpolation( ) : OneOperator(atype< const typename MatrixInterpolation< pfes1, pfes2 >::Op * >( ), atype< pfes1 * >( ), atype< pfes2 * >( )) {} + // interpolation(Vh,xx,yy) // 2d + MatrixInterpolation(int bidon) : OneOperator(atype< const typename MatrixInterpolation< pfes1, pfes1 >::Op * >( ), atype< pfes1 * >( ), atype< KN_< double > >( ), atype< KN_< double > >( )) {} + + // interpolation(Vh,xx,yy,zz) // 3d + MatrixInterpolation(int bidon, int bidon2) + : OneOperator(atype< const typename MatrixInterpolation< pfes1, pfes1 >::Op * >( ), atype< pfes1 * >( ), atype< KN_< double > >( ), atype< KN_< double > >( ), atype< KN_< double > >( )) {} + + E_F0 *code(const basicAC_F0 &args) const { + if (args.size( ) == 2) + return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); + else if (args.size( ) == 3) + return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); + else if (args.size( ) == 4) + return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[2]->CastTo(args[3])); + else + CompileError("Bug in MatrixInterpolation code nb != 2 or 3 ????? bizarre"); + return 0; + } }; -template -basicAC_F0::name_and_type MatrixInterpolation::Op::name_param[]= { - { "t", &typeid(bool)}, - { "op", &typeid(long)}, - { "inside",&typeid(bool)}, - { "composante",&typeid(long)}, - { "U2Vc",&typeid(KN_)} +template< class pfes1, class pfes2 > +basicAC_F0::name_and_type MatrixInterpolation< pfes1, pfes2 >::Op::name_param[] = { + {"t", &typeid(bool)}, {"op", &typeid(long)}, {"inside", &typeid(bool)}, {"composante", &typeid(long)}, {"U2Vc", &typeid(KN_< long >)} }; +template< class R > +class SetMatrix_Op : public E_F0mps { + public: + Expression a; + + static aType btype; + static const int n_name_param = NB_NAME_PARM_MAT; // add nbiter FH 30/01/2007 11 -> 12 //add var MUMPS+autre + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + const OneOperator *precon; + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + public: + SetMatrix_Op(const basicAC_F0 &args, Expression aa) : a(aa) { + args.SetNameParam(n_name_param, name_param, nargs); + precon = 0; // a changer + if (nargs[3]) { + const Polymorphic *op = dynamic_cast< const Polymorphic * >(nargs[3]); + assert(op); + precon = op->Find("(", ArrayOfaType(atype< KN< R > * >( ), false)); // strange bug in g++ is R become a double + ffassert(precon); + } + } + AnyType operator( )(Stack stack) const; +}; -template - class SetMatrix_Op : public E_F0mps { public: - Expression a; - - static aType btype; - static const int n_name_param =NB_NAME_PARM_MAT; // add nbiter FH 30/01/2007 11 -> 12 //add var MUMPS+autre - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - const OneOperator * precon; - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - public: - SetMatrix_Op(const basicAC_F0 & args,Expression aa) : a(aa) { - args.SetNameParam(n_name_param,name_param,nargs); - precon = 0; // a changer - if ( nargs[3]) - { - const Polymorphic * op= dynamic_cast(nargs[3]); - assert(op); - precon = op->Find("(",ArrayOfaType(atype* >(),false)); // strange bug in g++ is R become a double - ffassert(precon); - } - - } - AnyType operator()(Stack stack) const ; - }; - - -template -class SetMatrix : public OneOperator { public: - - SetMatrix() : OneOperator(SetMatrix_Op::btype,atype *>() ) {} +template< class R > +class SetMatrix : public OneOperator { + public: + SetMatrix( ) : OneOperator(SetMatrix_Op< R >::btype, atype< Matrice_Creuse< R > * >( )) {} - E_F0 * code(const basicAC_F0 & args) const - { - return new SetMatrix_Op(args,t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new SetMatrix_Op< R >(args, t[0]->CastTo(args[0])); } }; -template - aType SetMatrix_Op::btype=0; +template< class R > +aType SetMatrix_Op< R >::btype = 0; -template -basicAC_F0::name_and_type SetMatrix_Op::name_param[]= { - LIST_NAME_PARM_MAT +template< class R > +basicAC_F0::name_and_type SetMatrix_Op< R >::name_param[] = {LIST_NAME_PARM_MAT }; -template -AnyType SetMatrix_Op::operator()(Stack stack) const -{ - Matrice_Creuse * A= GetAny *>((*a)(stack)); +template< class R > +AnyType SetMatrix_Op< R >::operator( )(Stack stack) const { + Matrice_Creuse< R > *A = GetAny< Matrice_Creuse< R > * >((*a)(stack)); - ffassert(A); - Data_Sparse_Solver ds; - bool VF=false; - ds.factorize=0; + ffassert(A); + Data_Sparse_Solver ds; + bool VF = false; + ds.factorize = 0; // get previous value of sym ??? FH & PHT fev 2020 - int syma=-1; - if( A->A) - { HashMatrix * phm= A->pHM(); - if(phm) - syma=phm->half; - } + int syma = -1; + if (A->A) { + HashMatrix< int, R > *phm = A->pHM( ); + if (phm) syma = phm->half; + } - if( !A->A) A->A.master(new MatriceMorse(0,0,0,0));// set to empty matrix .. mars 2014 FH .. - SetEnd_Data_Sparse_Solver(stack,ds,nargs,n_name_param,syma); - if( verbosity >4) cout <<" SetMatrix_Op " << ds.sym << " "<< ds.positive << " " << syma << endl; - VirtualMatrix *pvm =A->pMC(); - ffassert(pvm); - pvm->setsdp(ds.sym,ds.positive); // put the matrix in rigth format - SetSolver(stack,VF,*A->pMC(),ds); + if (!A->A) A->A.master(new MatriceMorse< R >(0, 0, 0, 0)); // set to empty matrix .. mars 2014 FH .. + SetEnd_Data_Sparse_Solver< R >(stack, ds, nargs, n_name_param, syma); + if (verbosity > 4) cout << " SetMatrix_Op " << ds.sym << " " << ds.positive << " " << syma << endl; + VirtualMatrix< int, R > *pvm = A->pMC( ); + ffassert(pvm); + pvm->setsdp(ds.sym, ds.positive); // put the matrix in rigth format + SetSolver< R >(stack, VF, *A->pMC( ), ds); return Nothing; } - -template -void BuildCombMat(MatriceMorse & mij,const KNM_ & A, int ii00=0,int jj00=0,R coef=R(1.),bool cnj=false) -{ - double eps0=numeric_limits::min(); - int i,j; - int n = A.N(),m=A.M(); - for ( i=0;i * buildInterpolationMatrix(const FESpace & Uh,const FESpace & Vh,void *data) -{ // Uh = Vh - MatriceMorse * m=0; - int op=op_id; // value of the function - bool transpose=false; - bool inside=false; - int * iU2V=0; - if (data) - { - int * idata=static_cast(data); - transpose=idata[0]; - op=idata[1]; - inside=idata[2]; - iU2V= idata + 4; - ffassert(op>=0 && op < 4); - } - if(verbosity>2) - { - cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " just inside = " << inside << endl; +template< class R > +void BuildCombMat(MatriceMorse< R > &mij, const KNM_< R > &A, int ii00 = 0, int jj00 = 0, R coef = R(1.), bool cnj = false) { + double eps0 = numeric_limits< double >::min( ); + int i, j; + int n = A.N( ), m = A.M( ); + for (i = 0; i < n; i++) + for (j = 0; j < m; j++) { + R cij = coef * A(i, j); + if (cnj) cij = RNM::conj(cij); + mij[ij_mat(false, ii00, jj00, i, j)] += cij; } +} + +MatriceMorse< R > *buildInterpolationMatrix(const FESpace &Uh, const FESpace &Vh, void *data) { // Uh = Vh + MatriceMorse< R > *m = 0; + int op = op_id; // value of the function + bool transpose = false; + bool inside = false; + int *iU2V = 0; + if (data) { + int *idata = static_cast< int * >(data); + transpose = idata[0]; + op = idata[1]; + inside = idata[2]; + iU2V = idata + 4; + ffassert(op >= 0 && op < 4); + } + if (verbosity > 2) { + cout << " -- buildInterpolationMatrix transpose =" << transpose << endl + << " value, dx , dy op = " << op << endl + << " just inside = " << inside << endl; + } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=Vh.NbOfDF; - if(transpose) Exchange(n,mm); - m = new MatriceMorse(n,mm,0,0); - const Mesh & ThU =Uh.Th; // line - const Mesh & ThV =Vh.Th; // colunm - bool samemesh = &Uh.Th == &Vh.Th; // same Mesh - int thecolor =0; - - int nnz =0; - - KN color(ThV.nt); - KN mark(n); - mark=0; - - color=thecolor++; + int n = Uh.NbOfDF; + int mm = Vh.NbOfDF; + if (transpose) Exchange(n, mm); + m = new MatriceMorse< R >(n, mm, 0, 0); + const Mesh &ThU = Uh.Th; // line + const Mesh &ThV = Vh.Th; // colunm + bool samemesh = &Uh.Th == &Vh.Th; // same Mesh + int thecolor = 0; + + int nnz = 0; + + KN< int > color(ThV.nt); + KN< int > mark(n); + mark = 0; + + color = thecolor++; FElement Uh0 = Uh[0]; FElement Vh0 = Vh[0]; - FElement::aIPJ ipjU(Uh0.Pi_h_ipj()); - FElement::aR2 PtHatU(Uh0.Pi_h_R2()); - - int nbdfVK= Vh0.NbDoF(); - int NVh= Vh0.N; - - int nbp= PtHatU.N(); - KN PV(nbp); // the PtHat in ThV mesh - KN itV(nbp); // the Triangle number - KN intV(nbp); // ouside or not - KN AipjU(ipjU.N()); - - KNM aaa(nbp,nbdfVK); - - - const R eps = 1.0e-10; - const int sfb1=Vh0.N*last_operatortype*Vh0.NbDoF(); - KN kv(sfb1*nbp); - R * v = kv; - KN ik(nbp); // the Triangle number - - bool whatd[last_operatortype]; - for (int i=0;i fait(Uh.NbOfDF); - fait=false; - R2 Gh(1./3,1./3); - { - - for (int it=0;it9 ) - cout << it << " " << i << " :: " << TU(PtHatU[i]) << " -- "<< outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) < fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); // valeur de fonction de base de Vh - // ou: fb(idf,j,0) valeur de la j composante de la fonction idf - Vh0.tfe->FB(whatd,ThV,ThV[itV[p]],PV[p],fb); - } - - for (int i=0;i next - R aipj = AipjU[i]; - FElement KV(Vh[itV[p]]); - int jV=jU; - if(iU2V) jV=iU2V[jU]; - - if(jV>=0 && jV fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); - KN_ fbj(fb('.',jV,op)); - - for (int idfv=0;idfveps) - { - int dfv=KV(idfv); - int ii=dfu, jj=dfv; - if(transpose) Exchange(ii,jj); - // le term dfu,dfv existe dans la matrice - R c= fbj[idfv]*aipj; - if(Abs(c)>eps) - (*m)(ii,jj) += c; - } - } - - } - - for (int df=0;df PV(nbp); // the PtHat in ThV mesh + KN< int > itV(nbp); // the Triangle number + KN< bool > intV(nbp); // ouside or not + KN< R > AipjU(ipjU.N( )); + + KNM< R > aaa(nbp, nbdfVK); + + const R eps = 1.0e-10; + const int sfb1 = Vh0.N * last_operatortype * Vh0.NbDoF( ); + KN< R > kv(sfb1 * nbp); + R *v = kv; + KN< int > ik(nbp); // the Triangle number + + bool whatd[last_operatortype]; + for (int i = 0; i < last_operatortype; i++) whatd[i] = false; + whatd[op] = true; // the value of function + KN< bool > fait(Uh.NbOfDF); + fait = false; + R2 Gh(1. / 3, 1. / 3); + { + + for (int it = 0; it < ThU.nt; it++) { + thecolor++; // change the current color + const Triangle &TU(ThU[it]); + FElement KU(Uh[it]); + KU.Pi_h(AipjU); + if (samemesh) { + PV = PtHatU; + itV = it; + intV = false; // add July 2009 (unset varaible FH) + } else { + const Triangle *ts = 0, *ts0 = 0; + // Search barycenter + bool outside; + R2 G; // Add frev 2019 more cleaver F. Hecht + ts0 = ThV.Find(TU(Gh), G, outside, ts0); // find barycenter good if imbricated mesh .... + if (outside) ts0 = 0; // not find + for (int i = 0; i < nbp; i++) { + ts = ThV.Find(TU(PtHatU[i]), PV[i], outside, ts0); + if (!outside && ts0 == 0) ts0 = ts; + if (outside && verbosity > 9) cout << it << " " << i << " :: " << TU(PtHatU[i]) << " -- " << outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) << endl; + itV[i] = ThV(ts); + intV[i] = outside && inside; // ouside and inside flag + } + } + + for (int p = 0; p < nbp; p++) { + + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); // valeur de fonction de base de Vh + // ou: fb(idf,j,0) valeur de la j composante de la fonction idf + Vh0.tfe->FB(whatd, ThV, ThV[itV[p]], PV[p], fb); + } + + for (int i = 0; i < ipjU.N( ); i++) { // pour tous le terme + const FElement::IPJ &ipj_i(ipjU[i]); + int dfu = KU(ipj_i.i); // le numero de df global + if (fait[dfu]) continue; + int jU = ipj_i.j; // la composante dans U + int p = ipj_i.p; // le points + if (intV[p]) continue; // ouside and inside flag => next + R aipj = AipjU[i]; + FElement KV(Vh[itV[p]]); + int jV = jU; + if (iU2V) jV = iU2V[jU]; + + if (jV >= 0 && jV < NVh) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); + KN_< R > fbj(fb('.', jV, op)); + + for (int idfv = 0; idfv < nbdfVK; idfv++) + if (Abs(fbj[idfv]) > eps) { + int dfv = KV(idfv); + int ii = dfu, jj = dfv; + if (transpose) Exchange(ii, jj); + // le term dfu,dfv existe dans la matrice + R c = fbj[idfv] * aipj; + if (Abs(c) > eps) (*m)(ii, jj) += c; + } + } + } + + for (int df = 0; df < KU.NbDoF( ); df++) { + int dfu = KU(df); // le numero de df global + fait[dfu] = true; + } } - // sij.clear(); - return m; + } + // sij.clear(); + return m; } -template -void copyKNPt( KN &A, KN B) -{ A=B; }; +template< typename RdHatT1, typename RdHatT2 > +void copyKNPt(KN< RdHatT1 > &A, KN< RdHatT2 > B) { + A = B; +}; template<> -void copyKNPt( KN &A, KN B) { -for( int ik=0;ik(KN< R2 > &A, KN< R1 > B) { + for (int ik = 0; ik < A.N( ); ik++) A[ik].x = B[ik].x; } template<> -void copyKNPt( KN &A, KN B) { - for( int ik=0;ik(KN< R3 > &A, KN< R2 > B) { + for (int ik = 0; ik < A.N( ); ik++) { + A[ik].x = B[ik].x; + A[ik].y = B[ik].y; + } } template<> -void copyKNPt( KN &A, KN B) { -for( int ik=0;ik(KN< R1 > &A, KN< R2 > B) { + for (int ik = 0; ik < A.N( ); ik++) A[ik].x = B[ik].x; } template<> -void copyKNPt( KN &A, KN B) { - for( int ik=0;ik(KN< R1 > &A, KN< R3 > B) { + for (int ik = 0; ik < A.N( ); ik++) { + A[ik].x = B[ik].x; + } } - - -template -void copyPt( RdHatT1 &A, RdHatT2 B) { - int d1=RdHatT1::d, d2=RdHatT2::d; - for (int i=0 ; i< min(d1,d2) ;i++) - A[i]=B[i]; +template< typename RdHatT1, typename RdHatT2 > +void copyPt(RdHatT1 &A, RdHatT2 B) { + int d1 = RdHatT1::d, d2 = RdHatT2::d; + for (int i = 0; i < min(d1, d2); i++) A[i] = B[i]; }; template<> -void copyPt( R2 &A, R1 B) { - A.x = B.x; +void copyPt< R2, R1 >(R2 &A, R1 B) { + A.x = B.x; } template<> -void copyPt( R3 &A, R2 B) { - A.x = B.x; - A.y = B.y; +void copyPt< R3, R2 >(R3 &A, R2 B) { + A.x = B.x; + A.y = B.y; } template<> -void copyPt( R3 &A, R1 B) { - A.x = B.x; +void copyPt< R3, R1 >(R3 &A, R1 B) { + A.x = B.x; } // template 3D RdHat(FESpaceT1) = RdHat(FESpaceT2) -template -MatriceMorse * buildInterpolationMatrixT(const FESpaceT1 & Uh,const FESpaceT2 & Vh,void *data) -{ - MatriceMorse * m=0; +template< class FESpaceT1, class FESpaceT2 > +MatriceMorse< R > *buildInterpolationMatrixT(const FESpaceT1 &Uh, const FESpaceT2 &Vh, void *data) { + MatriceMorse< R > *m = 0; typedef typename FESpaceT1::Mesh Mesh1; typedef typename FESpaceT1::FElement FElement1; typedef typename Mesh1::Element Element1; typedef typename FESpaceT1::Rd Rd1; typedef typename Element1::RdHat RdHat1; - + typedef typename FESpaceT2::Mesh Mesh2; typedef typename FESpaceT2::FElement FElement2; typedef typename Mesh2::Element Element2; typedef typename FESpaceT2::Rd Rd2; typedef typename Element2::RdHat RdHat2; - - int op=op_id; // value of the function - bool transpose=false; - bool inside=false; - int * iU2V=0; - if (data) - { - int * idata=static_cast(data); - transpose=idata[0]; - op=idata[1]; - inside=idata[2]; - iU2V= idata + 4; - ffassert(op>=0 && op < 4); - } - if(verbosity>2) - { + int op = op_id; // value of the function + bool transpose = false; + bool inside = false; + int *iU2V = 0; + if (data) { + int *idata = static_cast< int * >(data); + transpose = idata[0]; + op = idata[1]; + inside = idata[2]; + iU2V = idata + 4; + ffassert(op >= 0 && op < 4); + } + if (verbosity > 2) { cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " just inside = " << inside << endl; + << " value, dx , dy op = " << op << endl + << " just inside = " << inside << endl; } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=Vh.NbOfDF; - if(transpose) Exchange(n,mm); - m = new MatriceMorse(n,mm,0,0); - - RdHat1 Gh= RdHat1::diag(1./(RdHat1::d+1)); + int n = Uh.NbOfDF; + int mm = Vh.NbOfDF; + if (transpose) Exchange(n, mm); + m = new MatriceMorse< R >(n, mm, 0, 0); + + RdHat1 Gh = RdHat1::diag(1. / (RdHat1::d + 1)); RdHat2 G; - - int n1=n+1; - const Mesh1 & ThU =Uh.Th; // line - const Mesh2 & ThV =Vh.Th; // colunm - bool samemesh = (is_same< Mesh1, Mesh2 >::value) ? (void*)&Uh.Th == (void*)&Vh.Th : 0 ; // same Mesh - int thecolor =0; - int nnz =0; + int n1 = n + 1; + const Mesh1 &ThU = Uh.Th; // line + const Mesh2 &ThV = Vh.Th; // colunm + bool samemesh = (is_same< Mesh1, Mesh2 >::value) ? (void *)&Uh.Th == (void *)&Vh.Th : 0; // same Mesh + int thecolor = 0; + + int nnz = 0; - KN color(ThV.nt); - KN mark(n); - mark=0; + KN< int > color(ThV.nt); + KN< int > mark(n); + mark = 0; - int * cl = 0; - double *a=0; + int *cl = 0; + double *a = 0; - color=thecolor++; + color = thecolor++; FElement1 Uh0 = Uh[0]; FElement2 Vh0 = Vh[0]; + int nbdfVK = Vh0.NbDoF( ); + int NVh = Vh0.N; - int nbdfVK= Vh0.NbDoF(); - int NVh= Vh0.N; + InterpolationMatrix< RdHat1 > ipmat(Uh); - InterpolationMatrix ipmat(Uh); - - int nbp=ipmat.np; // - KN PV(nbp); // the PtHat in ThV mesh - KN itV(nbp); // the Triangle number - KN intV(nbp); // ouside or not - - KNM aaa(nbp,nbdfVK); + int nbp = ipmat.np; // + KN< RdHat2 > PV(nbp); // the PtHat in ThV mesh + KN< int > itV(nbp); // the Triangle number + KN< bool > intV(nbp); // ouside or not + KNM< R > aaa(nbp, nbdfVK); const R eps = 1.0e-10; - const int sfb1=Vh0.N*last_operatortype*Vh0.NbDoF(); - KN kv(sfb1*nbp); - R * v = kv; - KN ik(nbp); // the Triangle number - op= op==3 ? op_dz : op; // renumber op ???? dec 2010 FH. - What_d whatd= 1<< op; - KN fait(Uh.NbOfDF); - fait=false; + const int sfb1 = Vh0.N * last_operatortype * Vh0.NbDoF( ); + KN< R > kv(sfb1 * nbp); + R *v = kv; + KN< int > ik(nbp); // the Triangle number + op = op == 3 ? op_dz : op; // renumber op ???? dec 2010 FH. + What_d whatd = 1 << op; + KN< bool > fait(Uh.NbOfDF); + fait = false; { - for (int it=0;it(PV,ipmat.P); + copyKNPt< RdHat2, RdHat1 >(PV, ipmat.P); itV = it; - intV= false;// add July 2009 (unset varaible FH) - } - else - { - const Element2 *ts=0,*ts0=0; + intV = false; // add July 2009 (unset varaible FH) + } else { + const Element2 *ts = 0, *ts0 = 0; bool outside; - ts0=ThV.Find(TU(Gh),G,outside,ts0); - if(outside) ts0=0; // bad starting tet - for (int i=0;i9 ) - cout << it << " " << i << " :: " << TU(ipmat.P[i]) << " -- "<< outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) < 9) cout << it << " " << i << " :: " << TU(ipmat.P[i]) << " -- " << outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) << endl; + itV[i] = ThV(ts); + intV[i] = outside && inside; // ouside and inside flag } } - for (int p=0;p fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); // valeur de fonction de base de Vh + for (int p = 0; p < nbp; p++) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); // valeur de fonction de base de Vh // ou: fb(idf,j,0) valeur de la j composante de la fonction idf - Vh0.tfe->FB(whatd,ThV,ThV[itV[p]],PV[p],fb); + Vh0.tfe->FB(whatd, ThV, ThV[itV[p]], PV[p], fb); } - for (int i=0;i next + for (int i = 0; i < ipmat.ncoef; i++) { // pour tous le terme + int dfu = KU(ipmat.dofe[i]); // le numero de df global + if (fait[dfu]) continue; + int jU = ipmat.comp[i]; // la composante dans U + int p = ipmat.p[i]; // le point + if (intV[p]) continue; // ouside and inside flag => next R aipj = ipmat.coef[i]; FElement2 KV(Vh[itV[p]]); - int jV=jU; - if(iU2V) jV=iU2V[jU]; - - if(jV>=0 && jV fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); - KN_ fbj(fb('.',jV,op)); - - for (int idfv=0;idfveps) - { - int dfv=KV(idfv); - int ii=dfu, jj=dfv; - if(transpose) Exchange(ii,jj); - // le term dfu,dfv existe dans la matrice - R c= fbj[idfv]*aipj; - if(Abs(c)>eps) - (*m)(ii,jj) += c; - } + int jV = jU; + if (iU2V) jV = iU2V[jU]; + + if (jV >= 0 && jV < NVh) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); + KN_< R > fbj(fb('.', jV, op)); + + for (int idfv = 0; idfv < nbdfVK; idfv++) + if (Abs(fbj[idfv]) > eps) { + int dfv = KV(idfv); + int ii = dfu, jj = dfv; + if (transpose) Exchange(ii, jj); + // le term dfu,dfv existe dans la matrice + R c = fbj[idfv] * aipj; + if (Abs(c) > eps) (*m)(ii, jj) += c; + } } - } - for (int df=0;df -MatriceMorse * funcBuildInterpolationMatrixT2(const FESpaceT & Uh,const FESpace & Vh,void *data) { - MatriceMorse * m=0; +template< class FESpaceT > +MatriceMorse< R > *funcBuildInterpolationMatrixT2(const FESpaceT &Uh, const FESpace &Vh, void *data) { + MatriceMorse< R > *m = 0; typedef typename FESpaceT::Mesh MeshT; typedef typename FESpaceT::FElement FElementT; typedef typename MeshT::Element ElementT; typedef typename FESpaceT::Rd RdT; typedef typename ElementT::RdHat RdHatT; - + typedef typename FESpace::Mesh Mesh2; typedef typename FESpace::FElement FElement2; typedef typename Mesh2::Element Element2; typedef typename FESpace::Rd Rd2; typedef typename Element2::RdHat RdHat2; - - int op=op_id; // value of the function - bool transpose=false; - bool inside=false; - int * iU2V=0; - if (data) - { - int * idata=static_cast(data); - transpose=idata[0]; - op=idata[1]; - inside=idata[2]; - iU2V= idata + 4; - ffassert(op>=0 && op < 4); - } - if(verbosity>2) - { + int op = op_id; // value of the function + bool transpose = false; + bool inside = false; + int *iU2V = 0; + if (data) { + int *idata = static_cast< int * >(data); + transpose = idata[0]; + op = idata[1]; + inside = idata[2]; + iU2V = idata + 4; + ffassert(op >= 0 && op < 4); + } + if (verbosity > 2) { cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " just inside = " << inside << endl; + << " value, dx , dy op = " << op << endl + << " just inside = " << inside << endl; } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=Vh.NbOfDF; - if(transpose) Exchange(n,mm); - m = new MatriceMorse(n,mm,0,0); - - RdHatT Gh= RdHatT::diag(1./(RdHatT::d+1)); + int n = Uh.NbOfDF; + int mm = Vh.NbOfDF; + if (transpose) Exchange(n, mm); + m = new MatriceMorse< R >(n, mm, 0, 0); + + RdHatT Gh = RdHatT::diag(1. / (RdHatT::d + 1)); RdHat2 G; - - int n1=n+1; - const MeshT & ThU =Uh.Th; // line - const Mesh2 & ThV =Vh.Th; // colunm - bool samemesh = (is_same< MeshT, Mesh2 >::value) ? (void*)&Uh.Th == (void*)&Vh.Th : 0 ; // same Mesh - int thecolor =0; - int nnz =0; + int n1 = n + 1; + const MeshT &ThU = Uh.Th; // line + const Mesh2 &ThV = Vh.Th; // colunm + bool samemesh = (is_same< MeshT, Mesh2 >::value) ? (void *)&Uh.Th == (void *)&Vh.Th : 0; // same Mesh + int thecolor = 0; + + int nnz = 0; - KN color(ThV.nt); - KN mark(n); - mark=0; + KN< int > color(ThV.nt); + KN< int > mark(n); + mark = 0; - int * cl = 0; - double *a=0; + int *cl = 0; + double *a = 0; - color=thecolor++; + color = thecolor++; FElementT Uh0 = Uh[0]; FElement2 Vh0 = Vh[0]; - int nbdfVK= Vh0.NbDoF(), NVh= Vh0.N; + int nbdfVK = Vh0.NbDoF( ), NVh = Vh0.N; - InterpolationMatrix ipmat(Uh); + InterpolationMatrix< RdHatT > ipmat(Uh); - int nbp=ipmat.np; // - KN PV(nbp); // the PtHat in ThV mesh - KN itV(nbp); // the Triangle number - KN intV(nbp); // ouside or not - - KNM aaa(nbp,nbdfVK); + int nbp = ipmat.np; // + KN< RdHat2 > PV(nbp); // the PtHat in ThV mesh + KN< int > itV(nbp); // the Triangle number + KN< bool > intV(nbp); // ouside or not + KNM< R > aaa(nbp, nbdfVK); const R eps = 1.0e-6; - const int sfb1=Vh0.N*last_operatortype*Vh0.NbDoF(); - KN kv(sfb1*nbp); - R * v = kv; - KN ik(nbp); // the Triangle number - + const int sfb1 = Vh0.N * last_operatortype * Vh0.NbDoF( ); + KN< R > kv(sfb1 * nbp); + R *v = kv; + KN< int > ik(nbp); // the Triangle number + bool whatd[last_operatortype]; - for (int i=0;i fait(Uh.NbOfDF); - fait=false; - double epsP=1e-6; // must be choose - - for (int it=0;it(PV,ipmat.P); - itV = it; - intV= false;// add July 2009 (unset varaible FH) - } - else { - const Element2 *ts=0,*ts0=0; - bool outside; - R3 P1(TU(Gh)); - R2 P12(P1.p2()); - if(abs(P1.z)>epsP) {outside=true;ts0=0;} - else - ts0=ThV.Find(P12,G,outside,ts0); - if(outside) ts0=0; // bad starting tet - for (int i=0;iepsP) {outside=true;ts=0;} - else ts=ThV.Find(P12,PV[i],outside,ts0); - if( ts0 ==0 && !outside) ts0=ts; - if(outside && verbosity>9 ) - cout << it << " " << i << " :: " << TU(ipmat.P[i]) << " -- "<< outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) < fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); // valeur de fonction de base de Vh - // ou: fb(idf,j,0) valeur de la j composante de la fonction idf - Vh0.tfe->FB(whatd,ThV,ThV[itV[p]],PV[p],fb); + KN< bool > fait(Uh.NbOfDF); + fait = false; + double epsP = 1e-6; // must be choose + + for (int it = 0; it < ThU.nt; it++) { + thecolor++; // change the current color + const ElementT &TU(ThU[it]); + FElementT KU(Uh[it]); + ipmat.set(KU); + if (samemesh) { + copyKNPt< RdHat2, RdHatT >(PV, ipmat.P); + itV = it; + intV = false; // add July 2009 (unset varaible FH) + } else { + const Element2 *ts = 0, *ts0 = 0; + bool outside; + R3 P1(TU(Gh)); + R2 P12(P1.p2( )); + if (abs(P1.z) > epsP) { + outside = true; + ts0 = 0; + } else + ts0 = ThV.Find(P12, G, outside, ts0); + if (outside) ts0 = 0; // bad starting tet + for (int i = 0; i < nbp; i++) { + R3 P1(TU(ipmat.P[i])); + R2 P12(P1.p2( )); + if (abs(P1.z) > epsP) { + outside = true; + ts = 0; + } else + ts = ThV.Find(P12, PV[i], outside, ts0); + if (ts0 == 0 && !outside) ts0 = ts; + if (outside && verbosity > 9) cout << it << " " << i << " :: " << TU(ipmat.P[i]) << " -- " << outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) << endl; + itV[i] = ThV(ts); + intV[i] = outside && inside; // ouside and inside flag } + } - for (int i=0;i next - R aipj = ipmat.coef[i]; - FElement2 KV(Vh[itV[p]]); - int jV=jU; - if(iU2V) jV=iU2V[jU]; - - if(jV>=0 && jV fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); - KN_ fbj(fb('.',jV,op)); - - for (int idfv=0;idfveps) { - int dfv=KV(idfv); - int ii=dfu, jj=dfv; - if(transpose) Exchange(ii,jj); + for (int p = 0; p < nbp; p++) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); // valeur de fonction de base de Vh + // ou: fb(idf,j,0) valeur de la j composante de la fonction idf + Vh0.tfe->FB(whatd, ThV, ThV[itV[p]], PV[p], fb); + } + + for (int i = 0; i < ipmat.ncoef; i++) { // pour tous le terme + int dfu = KU(ipmat.dofe[i]); // le numero de df global + if (fait[dfu]) continue; + int jU = ipmat.comp[i]; // la composante dans U + int p = ipmat.p[i]; // le point + if (intV[p]) continue; // ouside and inside flag => next + R aipj = ipmat.coef[i]; + FElement2 KV(Vh[itV[p]]); + int jV = jU; + if (iU2V) jV = iU2V[jU]; + + if (jV >= 0 && jV < NVh) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); + KN_< R > fbj(fb('.', jV, op)); + + for (int idfv = 0; idfv < nbdfVK; idfv++) + if (Abs(fbj[idfv]) > eps) { + int dfv = KV(idfv); + int ii = dfu, jj = dfv; + if (transpose) Exchange(ii, jj); // le term dfu,dfv existe dans la matrice - R c= fbj[idfv]*aipj; - if(Abs(c)>eps) - (*m)(ii,jj) += c; + R c = fbj[idfv] * aipj; + if (Abs(c) > eps) (*m)(ii, jj) += c; } - } - } - for (int df=0;df -MatriceMorse * funcBuildInterpolationMatrix2T(const FESpace & Uh,const FESpaceT & Vh,void *data) { - MatriceMorse * m=0; +template< class FESpaceT > +MatriceMorse< R > *funcBuildInterpolationMatrix2T(const FESpace &Uh, const FESpaceT &Vh, void *data) { + MatriceMorse< R > *m = 0; typedef typename FESpace::Mesh Mesh1; typedef typename FESpace::FElement FElement1; typedef typename Mesh1::Element Element1; typedef typename FESpace::Rd Rd1; typedef typename Element1::RdHat RdHat1; - + typedef typename FESpaceT::Mesh MeshT; typedef typename FESpaceT::FElement FElementT; typedef typename MeshT::Element ElementT; typedef typename FESpaceT::Rd RdT; typedef typename ElementT::RdHat RdHatT; - - int op=op_id; // value of the function - bool transpose=false; - bool inside=false; - int * iU2V=0; - if (data) - { - int * idata=static_cast(data); - transpose=idata[0]; - op=idata[1]; - inside=idata[2]; - iU2V= idata + 4; - ffassert(op>=0 && op < 4); - } - if(verbosity>2) - { + int op = op_id; // value of the function + bool transpose = false; + bool inside = false; + int *iU2V = 0; + if (data) { + int *idata = static_cast< int * >(data); + transpose = idata[0]; + op = idata[1]; + inside = idata[2]; + iU2V = idata + 4; + ffassert(op >= 0 && op < 4); + } + if (verbosity > 2) { cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " just inside = " << inside << endl; + << " value, dx , dy op = " << op << endl + << " just inside = " << inside << endl; } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=Vh.NbOfDF; - if(transpose) Exchange(n,mm); - m = new MatriceMorse(n,mm,0,0); - - RdHat1 Gh(1./3,1./3); + int n = Uh.NbOfDF; + int mm = Vh.NbOfDF; + if (transpose) Exchange(n, mm); + m = new MatriceMorse< R >(n, mm, 0, 0); + + RdHat1 Gh(1. / 3, 1. / 3); RdHatT G; - - int n1=n+1; - const Mesh1 & ThU =Uh.Th; // line - const MeshT & ThV =Vh.Th; // colunm - bool samemesh = (is_same< Mesh1, MeshT >::value) ? (void*)&Uh.Th == (void*)&Vh.Th : 0 ; // same Mesh - int thecolor =0; - int nnz =0; + int n1 = n + 1; + const Mesh1 &ThU = Uh.Th; // line + const MeshT &ThV = Vh.Th; // colunm + bool samemesh = (is_same< Mesh1, MeshT >::value) ? (void *)&Uh.Th == (void *)&Vh.Th : 0; // same Mesh + int thecolor = 0; + + int nnz = 0; - KN color(ThV.nt); - KN mark(n); - mark=0; + KN< int > color(ThV.nt); + KN< int > mark(n); + mark = 0; - int * cl = 0; - double *a=0; + int *cl = 0; + double *a = 0; - color=thecolor++; + color = thecolor++; FElement1 Uh0 = Uh[0]; FElementT Vh0 = Vh[0]; - - FElement1::aIPJ ipjU(Uh0.Pi_h_ipj()); - FElement1::aR2 PtHatU(Uh0.Pi_h_R2()); - - int nbdfVK= Vh0.NbDoF(), NVh= Vh0.N; - int nbp= PtHatU.N(); - - KN PV(nbp); // the PtHat in ThV mesh - KN itV(nbp); // the Triangle number - KN intV(nbp); // ouside or not - KN AipjU(ipjU.N()); - KNM aaa(nbp,nbdfVK); + FElement1::aIPJ ipjU(Uh0.Pi_h_ipj( )); + FElement1::aR2 PtHatU(Uh0.Pi_h_R2( )); + + int nbdfVK = Vh0.NbDoF( ), NVh = Vh0.N; + + int nbp = PtHatU.N( ); + KN< RdHatT > PV(nbp); // the PtHat in ThV mesh + KN< int > itV(nbp); // the Triangle number + KN< bool > intV(nbp); // ouside or not + KN< R > AipjU(ipjU.N( )); + KNM< R > aaa(nbp, nbdfVK); const R eps = 1.0e-6; - const int sfb1=Vh0.N*last_operatortype*Vh0.NbDoF(); - KN kv(sfb1*nbp); - R * v = kv; - KN ik(nbp); // the Triangle number - - op= op==3 ? op_dz : op; // renumber op ???? dec 2010 FH. - What_d whatd= 1<< op; - - KN fait(Uh.NbOfDF); - fait=false; - double epsP=1e-6; // must be choose - - for (int it=0;it kv(sfb1 * nbp); + R *v = kv; + KN< int > ik(nbp); // the Triangle number + + op = op == 3 ? op_dz : op; // renumber op ???? dec 2010 FH. + What_d whatd = 1 << op; + + KN< bool > fait(Uh.NbOfDF); + fait = false; + double epsP = 1e-6; // must be choose + + for (int it = 0; it < ThU.nt; it++) { + thecolor++; // change the current color + const Element1 &TU(ThU[it]); FElement1 KU(Uh[it]); KU.Pi_h(AipjU); - if (samemesh) {copyKNPt(PV,PtHatU); - //PV = PtHatU.x; // R1 = R2 + if (samemesh) { + copyKNPt(PV, PtHatU); + // PV = PtHatU.x; // R1 = R2 itV = it; - intV= false;// add July 2009 (unset varaible FH) - } - else { - const ElementT *ts=0,*ts0=0; + intV = false; // add July 2009 (unset varaible FH) + } else { + const ElementT *ts = 0, *ts0 = 0; bool outside; RdHat1 P1(TU(Gh)); RdHatT P12; - - copyPt(P1,P12); - if(is_same< MeshT, MeshL >::value && abs(P1.y)>epsP) {outside=true;ts0=0;} - else - ts0=ThV.Find(P12,G,outside,ts0); - if(outside) ts0=0; // bad starting tet - - for (int i=0;i9 ) - cout << it << " " << i << " :: " << TU(PtHatU[i]) << " -- "<< outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) <(P1, P12); + if (is_same< MeshT, MeshL >::value && abs(P1.y) > epsP) { + outside = true; + ts0 = 0; + } else + ts0 = ThV.Find(P12, G, outside, ts0); + if (outside) ts0 = 0; // bad starting tet + + for (int i = 0; i < nbp; i++) { + ts = ThV.Find(TU(PtHatU[i]), PV[i], outside, ts0); + if (!outside && ts0 == 0) ts0 = ts; + if (outside && verbosity > 9) cout << it << " " << i << " :: " << TU(PtHatU[i]) << " -- " << outside << PV[i] << " " << ThV(ts) << " -> " << (*ts)(PV[i]) << endl; + itV[i] = ThV(ts); + intV[i] = outside && inside; // ouside and inside flag } } - for (int p=0;p fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); // valeur de fonction de base de Vh + for (int p = 0; p < nbp; p++) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); // valeur de fonction de base de Vh // ou: fb(idf,j,0) valeur de la j composante de la fonction idf - Vh0.tfe->FB(whatd,ThV,ThV[itV[p]],PV[p],fb); + Vh0.tfe->FB(whatd, ThV, ThV[itV[p]], PV[p], fb); } - for (int i=0;i next + int dfu = KU(ipj_i.i); // le numero de df global + if (fait[dfu]) continue; + int jU = ipj_i.j; // la composante dans U + int p = ipj_i.p; // le points + if (intV[p]) continue; // ouside and inside flag => next R aipj = AipjU[i]; FElementT KV(Vh[itV[p]]); - int jV=jU; - if(iU2V) jV=iU2V[jU]; - - if(jV>=0 && jV fb(v+p*sfb1,nbdfVK,NVh,last_operatortype); - KN_ fbj(fb('.',jV,op)); - - for (int idfv=0;idfveps) { - int dfv=KV(idfv); - int ii=dfu, jj=dfv; - if(transpose) Exchange(ii,jj); + int jV = jU; + if (iU2V) jV = iU2V[jU]; + + if (jV >= 0 && jV < NVh) { + KNMK_< R > fb(v + p * sfb1, nbdfVK, NVh, last_operatortype); + KN_< R > fbj(fb('.', jV, op)); + + for (int idfv = 0; idfv < nbdfVK; idfv++) + if (Abs(fbj[idfv]) > eps) { + int dfv = KV(idfv); + int ii = dfu, jj = dfv; + if (transpose) Exchange(ii, jj); // le term dfu,dfv existe dans la matrice - R c= fbj[idfv]*aipj; - if(Abs(c)>eps) - (*m)(ii,jj) += c; + R c = fbj[idfv] * aipj; + if (Abs(c) > eps) (*m)(ii, jj) += c; } } } - for (int df=0;df -MatriceMorse * buildInterpolationMatrixT(const FESpaceL & Uh,const FESpace & Vh,void *data) -{ - return funcBuildInterpolationMatrixT2(Uh,Vh,data); +template<> +MatriceMorse< R > *buildInterpolationMatrixT< FESpaceL, FESpace >(const FESpaceL &Uh, const FESpace &Vh, void *data) { + return funcBuildInterpolationMatrixT2(Uh, Vh, data); } -template< > -MatriceMorse * buildInterpolationMatrixT(const FESpaceS & Uh,const FESpace & Vh,void *data){ +template<> +MatriceMorse< R > *buildInterpolationMatrixT< FESpaceS, FESpace >(const FESpaceS &Uh, const FESpace &Vh, void *data) { - return funcBuildInterpolationMatrixT2(Uh,Vh,data); + return funcBuildInterpolationMatrixT2(Uh, Vh, data); } -template< > -MatriceMorse * buildInterpolationMatrixT(const FESpace & Uh,const FESpaceL & Vh,void *data) -{ - return funcBuildInterpolationMatrix2T(Uh,Vh,data); +template<> +MatriceMorse< R > *buildInterpolationMatrixT< FESpace, FESpaceL >(const FESpace &Uh, const FESpaceL &Vh, void *data) { + return funcBuildInterpolationMatrix2T(Uh, Vh, data); } -template< > -MatriceMorse * buildInterpolationMatrixT(const FESpace & Uh,const FESpaceS & Vh,void *data){ +template<> +MatriceMorse< R > *buildInterpolationMatrixT< FESpace, FESpaceS >(const FESpace &Uh, const FESpaceS &Vh, void *data) { - return funcBuildInterpolationMatrix2T(Uh,Vh,data); + return funcBuildInterpolationMatrix2T(Uh, Vh, data); } -template< > -MatriceMorse * buildInterpolationMatrixT(const FESpace & Uh,const FESpace3 & Vh,void *data){ +template<> +MatriceMorse< R > *buildInterpolationMatrixT< FESpace, FESpace3 >(const FESpace &Uh, const FESpace3 &Vh, void *data) { - return funcBuildInterpolationMatrix2T(Uh,Vh,data); + return funcBuildInterpolationMatrix2T(Uh, Vh, data); } - -MatriceMorse * buildInterpolationMatrix1(const FESpace & Uh,const KN_ & xx,const KN_ & yy ,int *data) -{ - int op=op_id; // value of the function - int icomp=0; - bool transpose=false; - bool inside=false; - if (data) - { - transpose=data[0]; - op=data[1]; - inside=data[2]; - icomp = data[3]; - ffassert(op>=0 && op < 4); - - } - if(verbosity>2) - { - cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " composante = " << icomp << endl - << " just inside = " << inside << endl; - } +MatriceMorse< R > *buildInterpolationMatrix1(const FESpace &Uh, const KN_< double > &xx, const KN_< double > &yy, int *data) { + int op = op_id; // value of the function + int icomp = 0; + bool transpose = false; + bool inside = false; + if (data) { + transpose = data[0]; + op = data[1]; + inside = data[2]; + icomp = data[3]; + ffassert(op >= 0 && op < 4); + } + if (verbosity > 2) { + cout << " -- buildInterpolationMatrix transpose =" << transpose << endl + << " value, dx , dy op = " << op << endl + << " composante = " << icomp << endl + << " just inside = " << inside << endl; + } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=xx.N(); - int nbxx= mm; - if(transpose) Exchange(n,mm); - const Mesh & ThU =Uh.Th; // line - + int n = Uh.NbOfDF; + int mm = xx.N( ); + int nbxx = mm; + if (transpose) Exchange(n, mm); + const Mesh &ThU = Uh.Th; // line FElement Uh0 = Uh[0]; + int nbdfUK = Uh0.NbDoF( ); + int NUh = Uh0.N; + ffassert(icomp < NUh && icomp >= 0); - int nbdfUK= Uh0.NbDoF(); - int NUh= Uh0.N; - - ffassert(icomp < NUh && icomp >=0); - - - const int sfb1=Uh0.N*last_operatortype*Uh0.NbDoF(); - KN kv(sfb1); - R * v = kv; - const R eps = 1.0e-10; - - bool whatd[last_operatortype]; - for (int i=0;i fait(Uh.NbOfDF); - fait=false; - R2 Phat; - bool outside; - MatriceMorse * m = new MatriceMorse(n,mm,0,0); - for(int ii=0;ii fb(v,nbdfUK,NUh,last_operatortype); - Uh0.tfe->FB(whatd,ThU,ThU[it],Phat,fb); - KN_ Fwi(fb('.',icomp,op)); - for (int idfu=0;idfueps) - (*m)(i,j) += c; - } - } + const int sfb1 = Uh0.N * last_operatortype * Uh0.NbDoF( ); + KN< R > kv(sfb1); + R *v = kv; + const R eps = 1.0e-10; + bool whatd[last_operatortype]; + for (int i = 0; i < last_operatortype; i++) whatd[i] = false; + whatd[op] = true; // the value of function + KN< bool > fait(Uh.NbOfDF); + fait = false; + R2 Phat; + bool outside; + MatriceMorse< R > *m = new MatriceMorse< R >(n, mm, 0, 0); + for (int ii = 0; ii < nbxx; ii++) { + const Triangle *ts = ThU.Find(R2(xx[ii], yy[ii]), Phat, outside); + if (outside && inside) continue; // sorry bug wrong not OK if outside and inside 28/04/25 FH and PHT + int it = ThU(ts); + FElement KU(Uh[it]); + KNMK_< R > fb(v, nbdfUK, NUh, last_operatortype); + Uh0.tfe->FB(whatd, ThU, ThU[it], Phat, fb); + KN_< R > Fwi(fb('.', icomp, op)); + for (int idfu = 0; idfu < nbdfUK; idfu++) { + int j = ii; + int i = KU(idfu); + if (transpose) Exchange(i, j); + R c = Fwi(idfu); + if (Abs(c) > eps) (*m)(i, j) += c; + } + } // sij.clear(); - return m; + return m; } -template -MatriceMorse * buildInterpolationMatrixT1(const FESpaceT & Uh,const KN_ & xx,const KN_ & yy ,const KN_ & zz,int *data) -{ +template< class FESpaceT > +MatriceMorse< R > *buildInterpolationMatrixT1(const FESpaceT &Uh, const KN_< double > &xx, const KN_< double > &yy, const KN_< double > &zz, int *data) { typedef typename FESpaceT::Mesh MeshT; - typedef typename FESpaceT::FElement FElementT; - typedef typename MeshT::Element ElementT; - typedef typename FESpaceT::Rd RdT; - typedef typename ElementT::RdHat RdHatT; - - int op=op_id; // value of the function - int icomp=0; - bool transpose=false; - bool inside=false; - if (data){ - transpose=data[0]; - op=data[1]; - inside=data[2]; + typedef typename FESpaceT::FElement FElementT; + typedef typename MeshT::Element ElementT; + typedef typename FESpaceT::Rd RdT; + typedef typename ElementT::RdHat RdHatT; + + int op = op_id; // value of the function + int icomp = 0; + bool transpose = false; + bool inside = false; + if (data) { + transpose = data[0]; + op = data[1]; + inside = data[2]; icomp = data[3]; - ffassert(op>=0 && op < 4); - if(op==3) op=op_dz;// correct missing + ffassert(op >= 0 && op < 4); + if (op == 3) op = op_dz; // correct missing } - if(verbosity>2){ + if (verbosity > 2) { cout << " -- buildInterpolationMatrix transpose =" << transpose << endl - << " value, dx , dy op = " << op << endl - << " composante = " << icomp << endl - << " just inside = " << inside << endl; + << " value, dx , dy op = " << op << endl + << " composante = " << icomp << endl + << " just inside = " << inside << endl; } using namespace Fem2D; - int n=Uh.NbOfDF; - int mm=xx.N(); - int nbxx= mm; - if(transpose) Exchange(n,mm); - const MeshT & ThU =Uh.Th; // line + int n = Uh.NbOfDF; + int mm = xx.N( ); + int nbxx = mm; + if (transpose) Exchange(n, mm); + const MeshT &ThU = Uh.Th; // line FElementT Uh0 = Uh[0]; - int nbdfUK= Uh0.NbDoF(); - int NUh= Uh0.N; + int nbdfUK = Uh0.NbDoF( ); + int NUh = Uh0.N; - ffassert(icomp < NUh && icomp >=0); + ffassert(icomp < NUh && icomp >= 0); - const int sfb1=Uh0.N*last_operatortype*Uh0.NbDoF(); - KN kv(sfb1); - R * v = kv; + const int sfb1 = Uh0.N * last_operatortype * Uh0.NbDoF( ); + KN< R > kv(sfb1); + R *v = kv; const R eps = 1.0e-10; - What_d whatd= 1 < fait(Uh.NbOfDF); - fait=false; + What_d whatd = 1 << op; + KN< bool > fait(Uh.NbOfDF); + fait = false; // map< pair , double > sij; - MatriceMorse * m = new MatriceMorse(n,mm,0,0); + MatriceMorse< R > *m = new MatriceMorse< R >(n, mm, 0, 0); RdHatT Phat; bool outside; - for(int ii=0;ii9) cout << " Find ThU " < 9) cout << " Find ThU " << ii << ":" << RdT(xx[ii], yy[ii], zz[ii]) << endl; + const ElementT *ts = ThU.Find(RdT(xx[ii], yy[ii], zz[ii]), Phat, outside); + if (outside && inside) continue; // sorry bug wrong not OK if outside and inside 28/04/25 FH and PHT int it = ThU(ts); FElementT KU(Uh[it]); - KNMK_ fb(v,nbdfUK,NUh,last_operatortype); - Uh0.tfe->FB(whatd,ThU,ThU[it],Phat,fb); - KN_ Fwi(fb('.',icomp,op)); - for (int idfu=0;idfu fb(v, nbdfUK, NUh, last_operatortype); + Uh0.tfe->FB(whatd, ThU, ThU[it], Phat, fb); + KN_< R > Fwi(fb('.', icomp, op)); + for (int idfu = 0; idfu < nbdfUK; idfu++) { + int j = ii; + int i = KU(idfu); + if (transpose) Exchange(i, j); R c = Fwi(idfu); - if(Abs(c)>eps) - (*m)(i,j) += c; + if (Abs(c) > eps) (*m)(i, j) += c; } } return m; } - template<> -MatriceMorse * buildInterpolationMatrixT1(const FESpace & Uh,const KN_ & xx,const KN_ & yy ,const KN_ & zz,int *data) -{ - return buildInterpolationMatrix1(Uh,xx,yy,data); +MatriceMorse< R > *buildInterpolationMatrixT1< FESpace >(const FESpace &Uh, const KN_< double > &xx, const KN_< double > &yy, const KN_< double > &zz, int *data) { + return buildInterpolationMatrix1(Uh, xx, yy, data); } - - - -AnyType SetMatrixInterpolation1(Stack stack,Expression emat,Expression einter,int init) -{ +AnyType SetMatrixInterpolation1(Stack stack, Expression emat, Expression einter, int init) { using namespace Fem2D; - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - const MatrixInterpolation::Op * mi(dynamic_cast::Op *>(einter)); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + const MatrixInterpolation< pfes, pfes >::Op *mi(dynamic_cast< const MatrixInterpolation< pfes, pfes >::Op * >(einter)); ffassert(einter); - pfes * pUh = GetAny< pfes * >((* mi->a)(stack)); - FESpace * Uh = **pUh; - int NUh =Uh->N; - int* data = new int[4 + NUh]; - data[0]=mi->arg(0,stack,false); // transpose not - data[1]=mi->arg(1,stack,(long) op_id); ; // get just value - data[2]=mi->arg(2,stack,false); ; // get just value - data[3]=mi->arg(3,stack,0L); ; // get just value - KN U2Vc; - U2Vc= mi->arg(4,stack,U2Vc); ; - if( mi->c==0) - { // old cas - pfes * pVh = GetAny< pfes * >((* mi->b)(stack)); - FESpace * Vh = **pVh; - int NVh =Vh->N; - - for(int i=0;i3) - for(int i=0;i " << data[4+i] << " Componante of Vh " <=NVh) - { - cout << "The Uh componante " << i << " -> " << data[4+i] << " >= " << NVh << " number of Vh Componante " <init(); - sparse_mat->typemat=0; //TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master(buildInterpolationMatrix(*Uh,*Vh,data)); - } - else - { // new cas mars 2006 - KN_ xx = GetAny< KN_ >((* mi->b)(stack)); - KN_ yy = GetAny< KN_ >((* mi->c)(stack)); - ffassert( xx.N() == yy.N()); - ffassert(Uh); + pfes *pUh = GetAny< pfes * >((*mi->a)(stack)); + FESpace *Uh = **pUh; + int NUh = Uh->N; + int *data = new int[4 + NUh]; + data[0] = mi->arg(0, stack, false); // transpose not + data[1] = mi->arg(1, stack, (long)op_id); + ; // get just value + data[2] = mi->arg(2, stack, false); + ; // get just value + data[3] = mi->arg(3, stack, 0L); + ; // get just value + KN< long > U2Vc; + U2Vc = mi->arg(4, stack, U2Vc); + ; + if (mi->c == 0) { // old cas + pfes *pVh = GetAny< pfes * >((*mi->b)(stack)); + FESpace *Vh = **pVh; + int NVh = Vh->N; + + for (int i = 0; i < NUh; ++i) data[4 + i] = i; // + for (int i = 0; i < min(NUh, (int)U2Vc.size( )); ++i) data[4 + i] = U2Vc[i]; // + if (verbosity > 3) + for (int i = 0; i < NUh; ++i) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " Componante of Vh " << endl; + } + for (int i = 0; i < NUh; ++i) + if (data[4 + i] >= NVh) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " >= " << NVh << " number of Vh Componante " << endl; + ExecError("Interpolation incompability between componante "); + } - if(!init) sparse_mat->init(); - sparse_mat->typemat=0;//TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master(buildInterpolationMatrix1(*Uh,xx,yy,data)); + ffassert(Vh); + ffassert(Uh); + + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; // TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(buildInterpolationMatrix(*Uh, *Vh, data)); + } else { // new cas mars 2006 + KN_< double > xx = GetAny< KN_< double > >((*mi->b)(stack)); + KN_< double > yy = GetAny< KN_< double > >((*mi->c)(stack)); + ffassert(xx.N( ) == yy.N( )); + ffassert(Uh); + + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; // TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(buildInterpolationMatrix1(*Uh, xx, yy, data)); } - delete [] data; - return sparse_mat; // Warning .. no correct gestion of temp ptr .. + delete[] data; + return sparse_mat; // Warning .. no correct gestion of temp ptr .. } - - -template -AnyType SetMatrixInterpolationT1(Stack stack,Expression emat,Expression einter,int init) -{ +template< class pfesT1, class FESpaceT1, class pfesT2, class FESpaceT2 > +AnyType SetMatrixInterpolationT1(Stack stack, Expression emat, Expression einter, int init) { using namespace Fem2D; - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - const typename MatrixInterpolation::Op * mi(dynamic_cast::Op *>(einter)); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + const typename MatrixInterpolation< pfesT1, pfesT2 >::Op *mi(dynamic_cast< const typename MatrixInterpolation< pfesT1, pfesT2 >::Op * >(einter)); ffassert(einter); - pfesT1 * pUh = GetAny< pfesT1 * >((* mi->a)(stack)); - FESpaceT1 * Uh = **pUh; - if(Uh) { - int NUh =Uh->N; - int* data = new int[4 + NUh]; - data[0]=mi->arg(0,stack,false); // transpose not - data[1]=mi->arg(1,stack,(long) op_id); ; // get just value - data[2]=mi->arg(2,stack,false); ; // get just value - data[3]=mi->arg(3,stack,0L); ; // get just value - KN U2Vc; - U2Vc= mi->arg(4,stack,U2Vc); ; - if( mi->c==0) - { // old cas - pfesT2 * pVh = GetAny< pfesT2 * >((* mi->b)(stack)); - FESpaceT2 * Vh = **pVh; - if(Vh) { - int NVh =Vh->N; - for(int i=0;i3) - for(int i=0;i " << data[4+i] << " Componante of Vh " <=NVh) - { - cout << "The Uh componante " << i << " -> " << data[4+i] << " >= " << NVh << " number of Vh Componante " <init(); - sparse_mat->typemat=0;//(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master(buildInterpolationMatrixT(*Uh,*Vh,data)); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); + pfesT1 *pUh = GetAny< pfesT1 * >((*mi->a)(stack)); + FESpaceT1 *Uh = **pUh; + if (Uh) { + int NUh = Uh->N; + int *data = new int[4 + NUh]; + data[0] = mi->arg(0, stack, false); // transpose not + data[1] = mi->arg(1, stack, (long)op_id); + ; // get just value + data[2] = mi->arg(2, stack, false); + ; // get just value + data[3] = mi->arg(3, stack, 0L); + ; // get just value + KN< long > U2Vc; + U2Vc = mi->arg(4, stack, U2Vc); + ; + if (mi->c == 0) { // old cas + pfesT2 *pVh = GetAny< pfesT2 * >((*mi->b)(stack)); + FESpaceT2 *Vh = **pVh; + if (Vh) { + int NVh = Vh->N; + for (int i = 0; i < NUh; ++i) data[4 + i] = i; // + for (int i = 0; i < min(NUh, (int)U2Vc.size( )); ++i) data[4 + i] = U2Vc[i]; // + if (verbosity > 3) + for (int i = 0; i < NUh; ++i) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " Componante of Vh " << endl; + } + for (int i = 0; i < NUh; ++i) + if (data[4 + i] >= NVh) { + cout << "The Uh componante " << i << " -> " << data[4 + i] << " >= " << NVh << " number of Vh Componante " << endl; + ExecError("Interpolation incompability between componante "); + } + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; //(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(buildInterpolationMatrixT< FESpaceT1, FESpaceT2 >(*Uh, *Vh, data)); // sparse_mat->A.master(new MatriceMorse(*Uh,*Vh,buildInterpolationMatrix,data)); } - } - else - { // new cas mars 2006 - KN_ xx = GetAny< KN_ >((* mi->b)(stack)); - KN_ yy = GetAny< KN_ >((* mi->c)(stack)); - KN_ zz = GetAny< KN_ >((* mi->d)(stack)); - ffassert( xx.N() == yy.N()); - ffassert( xx.N() == zz.N()); + } else { // new cas mars 2006 + KN_< double > xx = GetAny< KN_< double > >((*mi->b)(stack)); + KN_< double > yy = GetAny< KN_< double > >((*mi->c)(stack)); + KN_< double > zz = GetAny< KN_< double > >((*mi->d)(stack)); + ffassert(xx.N( ) == yy.N( )); + ffassert(xx.N( ) == zz.N( )); ffassert(Uh); - if(!init) sparse_mat->init(); - sparse_mat->typemat=0;//(TypeSolveMat::NONESQUARE); // none square matrice (morse) - sparse_mat->A.master(buildInterpolationMatrixT1(*Uh,xx,yy,zz,data)); + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; //(TypeSolveMat::NONESQUARE); // none square matrice (morse) + sparse_mat->A.master(buildInterpolationMatrixT1< FESpaceT1 >(*Uh, xx, yy, zz, data)); } - delete [] data; + delete[] data; } return sparse_mat; } +template< int init > +AnyType SetMatrixInterpolation(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolation1(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolation3(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfes3, FESpace3, pfes3, FESpace3 >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationS(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesS, FESpaceS, pfesS, FESpaceS >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationL(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesL, FESpaceL, pfesL, FESpaceL >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationS3(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesS, FESpaceS, pfes3, FESpace3 >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationL2(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesL, FESpaceL, pfes, FESpace >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationLS(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesL, FESpaceL, pfesS, FESpaceS >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationSL(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesS, FESpaceS, pfesL, FESpaceL >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolationS2(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfesS, FESpaceS, pfes, FESpace >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolation2L(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfes, FESpace, pfesL, FESpaceL >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolation2S(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfes, FESpace, pfesS, FESpaceS >(stack, emat, einter, init); +} +template< int init > +AnyType SetMatrixInterpolation23(Stack stack, Expression emat, Expression einter) { + return SetMatrixInterpolationT1< pfes, FESpace, pfes3, FESpace3 >(stack, emat, einter, init); +} -template -AnyType SetMatrixInterpolation(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolation1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolation3(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationS(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationL(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationS3(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationL2(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationLS(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationSL(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolationS2(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolation2L(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolation2S(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} -template -AnyType SetMatrixInterpolation23(Stack stack,Expression emat,Expression einter) -{ return SetMatrixInterpolationT1(stack,emat,einter,init);} - -template -AnyType ProdMat(Stack stack,Expression emat,Expression prodmat) -{ - using namespace Fem2D; - - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - const Matrix_Prod AB = GetAny >((*prodmat)(stack)); +template< class RA, class RB, class RAB, int init > +AnyType ProdMat(Stack stack, Expression emat, Expression prodmat) { + using namespace Fem2D; - MatriceMorse *mA= AB.A->pHM(); - MatriceMorse *mB= AB.B->pHM(); - bool ta = AB.ta, tb = AB.tb; - if( !mA || !mB) - { - ExecError(" numll matrix in pod mat "); + Matrice_Creuse< RAB > *sparse_mat = GetAny< Matrice_Creuse< RA > * >((*emat)(stack)); + const Matrix_Prod< RA, RB > AB = GetAny< Matrix_Prod< RA, RB > >((*prodmat)(stack)); + + MatriceMorse< RA > *mA = AB.A->pHM( ); + MatriceMorse< RB > *mB = AB.B->pHM( ); + bool ta = AB.ta, tb = AB.tb; + if (!mA || !mB) { + ExecError(" numll matrix in pod mat "); } - int An= mA->n, Am =mA->m; - int Bn= mB->n, Bm =mB->m; - if(ta) swap(An,Am); - if(tb) swap(Bn,Bm); + int An = mA->n, Am = mA->m; + int Bn = mB->n, Bm = mB->m; + if (ta) swap(An, Am); + if (tb) swap(Bn, Bm); - if( Am!= Bn) { + if (Am != Bn) { cerr << " -- Error dim ProdMat A*B : tA =" << AB.ta << " = tB " << AB.tb << endl; - cerr << " --MatProd " << mA->n<< " "<< mA->m << " x " << mB->n<< " "<< mB->m << endl; + cerr << " --MatProd " << mA->n << " " << mA->m << " x " << mB->n << " " << mB->m << endl; ExecError(" Wrong mat dim in MatProd"); } - MatriceMorse *mAB=new MatriceMorse(An,Bm,0,0); - AddMul(*mAB,*mA,*mB,ta,tb); + MatriceMorse< RAB > *mAB = new MatriceMorse< RAB >(An, Bm, 0, 0); + AddMul(*mAB, *mA, *mB, ta, tb); - if(!init) sparse_mat->init(); - sparse_mat->typemat=0; + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; sparse_mat->A.master(mAB); return sparse_mat; - } - -template -AnyType CombMat(Stack stack,Expression emat,Expression combMat) -{ +template< class R, int init > +AnyType CombMat(Stack stack, Expression emat, Expression combMat) { using namespace Fem2D; - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - list *,bool> > * lcB = GetAny *,bool> >*>((*combMat)(stack)); - HashMatrix * AA=BuildCombMat(*lcB,false,0,0); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + list< tuple< R, VirtualMatrix< int, R > *, bool > > *lcB = GetAny< list< tuple< R, VirtualMatrix< int, R > *, bool > > * >((*combMat)(stack)); + HashMatrix< int, R > *AA = BuildCombMat< R >(*lcB, false, 0, 0); - if(!init) sparse_mat->init(); + if (!init) sparse_mat->init( ); sparse_mat->A.master(AA); - sparse_mat->typemat=0; + sparse_mat->typemat = 0; delete lcB; return sparse_mat; } -template // July 2019 FH A += c M + ... -AnyType AddCombMat(Stack stack,Expression emat,Expression combMat) -{ - using namespace Fem2D; - - Matrice_Creuse * pMCA =GetAny* >((*emat)(stack)); - HashMatrix * pA=pMCA->pHM(); - ffassert(pA); - list *,bool> > * lcB = GetAny *,bool> >*>((*combMat)(stack)); - if( cc!=1) Op1_LCMd::f(lcB); - BuildCombMat(*pA,*lcB,false,0,0,false); - - delete lcB; - return pMCA; -} - -template -AnyType DiagMat(Stack stack,Expression emat,Expression edia) -{ +template< class R, int cc > // July 2019 FH A += c M + ... +AnyType AddCombMat(Stack stack, Expression emat, Expression combMat) { using namespace Fem2D; - KN * diag=GetAny* >((*edia)(stack)); - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - if(!init) sparse_mat->init(); - sparse_mat->typemat=VirtualMatrix::TS_SYM;//TypeSolveMat(TypeSolveMat::GC); // none square matrice (morse) - sparse_mat->A.master(new MatriceMorse((int) diag->N(),(const R*) *diag)); - return sparse_mat; -} + Matrice_Creuse< R > *pMCA = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + HashMatrix< int, R > *pA = pMCA->pHM( ); + ffassert(pA); + list< tuple< R, VirtualMatrix< int, R > *, bool > > *lcB = GetAny< list< tuple< R, VirtualMatrix< int, R > *, bool > > * >((*combMat)(stack)); + if (cc != 1) Op1_LCMd< R, cc >::f(lcB); + BuildCombMat< R >(*pA, *lcB, false, 0, 0, false); + delete lcB; + return pMCA; +} + +template< class R, int init > +AnyType DiagMat(Stack stack, Expression emat, Expression edia) { + using namespace Fem2D; + KN< R > *diag = GetAny< KN< R > * >((*edia)(stack)); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + if (!init) sparse_mat->init( ); + sparse_mat->typemat = VirtualMatrix< int, R >::TS_SYM; // TypeSolveMat(TypeSolveMat::GC); // none square matrice (morse) + sparse_mat->A.master(new MatriceMorse< R >((int)diag->N( ), (const R *)*diag)); + return sparse_mat; +} -template - struct ChangeMatriceMorse { - static MatriceMorse *f(MatriceMorse *mr) - { - MatriceMorse* mrr=new MatriceMorse(*mr); +template< class Rin, class Rout > +struct ChangeMatriceMorse { + static MatriceMorse< Rout > *f(MatriceMorse< Rin > *mr) { + MatriceMorse< Rout > *mrr = new MatriceMorse< Rout >(*mr); delete mr; return mrr; - } - }; - -template - struct ChangeMatriceMorse { - static MatriceMorse* f(MatriceMorse* mr) - { - return mr; - } - }; -template -AnyType CopyMat_tt(Stack stack,Expression emat,Expression eA,bool transp) -{ - using namespace Fem2D; - Matrice_Creuse * Mat; - - if(transp) - { - Matrice_Creuse_Transpose tMat=GetAny >((*eA)(stack)); - Mat=tMat; - } - else Mat =GetAny*>((*eA)(stack)); - MatriceMorse * mr=Mat->pHM(); - - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - if(mr) { - MatriceMorse * mrr = new MatriceMorse(mr->n,mr->m,0,0); - *mrr = *mr; - if(transp) mrr->dotranspose(); - + } +}; - if(!init) sparse_mat->init() ; - sparse_mat->typemat=Mat->typemat; // none square matrice (morse) - sparse_mat->A.master(mrr); - VirtualMatrix *pvm = sparse_mat->pMC(); - pvm->SetSolver(); // copy solver ??? - } - return sparse_mat; +template< class R > +struct ChangeMatriceMorse< R, R > { + static MatriceMorse< R > *f(MatriceMorse< R > *mr) { return mr; } +}; +template< class R, class RR, int init > +AnyType CopyMat_tt(Stack stack, Expression emat, Expression eA, bool transp) { + using namespace Fem2D; + Matrice_Creuse< R > *Mat; + + if (transp) { + Matrice_Creuse_Transpose< R > tMat = GetAny< Matrice_Creuse_Transpose< R > >((*eA)(stack)); + Mat = tMat; + } else + Mat = GetAny< Matrice_Creuse< R > * >((*eA)(stack)); + MatriceMorse< R > *mr = Mat->pHM( ); + + Matrice_Creuse< RR > *sparse_mat = GetAny< Matrice_Creuse< RR > * >((*emat)(stack)); + if (mr) { + MatriceMorse< RR > *mrr = new MatriceMorse< RR >(mr->n, mr->m, 0, 0); + *mrr = *mr; + if (transp) mrr->dotranspose( ); + + if (!init) sparse_mat->init( ); + sparse_mat->typemat = Mat->typemat; // none square matrice (morse) + sparse_mat->A.master(mrr); + VirtualMatrix< int, RR > *pvm = sparse_mat->pMC( ); + pvm->SetSolver( ); // copy solver ??? + } + return sparse_mat; } -template -AnyType CopyTrans(Stack stack,Expression emat,Expression eA) -{ - return CopyMat_tt(stack,emat,eA,true); +template< class R, class RR, int init > +AnyType CopyTrans(Stack stack, Expression emat, Expression eA) { + return CopyMat_tt< R, RR, init >(stack, emat, eA, true); } -template -AnyType CopyMat(Stack stack,Expression emat,Expression eA) -{ - return CopyMat_tt(stack,emat,eA,false); +template< class R, class RR, int init > +AnyType CopyMat(Stack stack, Expression emat, Expression eA) { + return CopyMat_tt< R, RR, init >(stack, emat, eA, false); } +template< class R, int init > +AnyType MatFull2Sparse(Stack stack, Expression emat, Expression eA) { + KNM< R > *A = GetAny< KNM< R > * >((*eA)(stack)); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + if (!init) sparse_mat->init( ); + sparse_mat->typemat = 0; //(TypeSolveMat::GMRES); // none square matrice (morse) + sparse_mat->A.master(new MatriceMorse< R >((KNM_< R > &)*A, 0.0)); -template -AnyType MatFull2Sparse(Stack stack,Expression emat,Expression eA) -{ - KNM * A=GetAny* >((*eA)(stack)); - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - if(!init) sparse_mat->init() ; - sparse_mat->typemat=0;//(TypeSolveMat::GMRES); // none square matrice (morse) - sparse_mat->A.master(new MatriceMorse((KNM_ &)*A,0.0)); - - return sparse_mat; + return sparse_mat; } -template +template< class RR, class AA = RR, class BB = AA > struct Op2_pair { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(const AA & a,const BB & b) - { return RR( a, b);} + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(const AA &a, const BB &b) { return RR(a, b); } }; +template< class R > +long get_mat_n(Matrice_Creuse< R > *p) { + ffassert(p); + return p->A ? p->A->n : 0; +} + +template< class R > +bool set_mat_COO(Matrice_Creuse< R > *p) { + ffassert(p); + HashMatrix< int, R > *phm = p->pHM( ); + if (phm) phm->COO( ); + return phm; +} +template< class R > +bool set_mat_CSR(Matrice_Creuse< R > *p) { + ffassert(p); + HashMatrix< int, R > *phm = p->pHM( ); + if (phm) phm->CSR( ); + return phm; +} +template< class R > +bool set_mat_CSC(Matrice_Creuse< R > *p) { + ffassert(p); + HashMatrix< int, R > *phm = p->pHM( ); + if (phm) phm->CSC( ); + return phm; +} + +template< class R > +long get_mat_m(Matrice_Creuse< R > *p) { + ffassert(p); + return p->A ? p->A->m : 0; +} + +template< class R > +long get_mat_nbcoef(Matrice_Creuse< R > *p) { + ffassert(p); + return p->A ? p->A->NbCoef( ) : 0; +} +template< class R > +long get_mat_half(Matrice_Creuse< R > *p) { + return p && p->pHM( ) ? p->pHM( )->half : -1; +} + +template< class R > +pair< long, long > get_NM(const list< tuple< R, MatriceCreuse< R > *, bool > > &lM) { + typedef typename list< tuple< R, MatriceCreuse< R > *, bool > >::const_iterator lconst_iterator; + + lconst_iterator begin = lM.begin( ); + lconst_iterator end = lM.end( ); + lconst_iterator i; + + long n = 0, m = 0; + for (i = begin; i != end; i++ ++) { + ffassert(get< 1 >(*i)); + MatriceCreuse< R > *M = get< 1 >(*i); + bool t = get< 2 >(*i); + int nn = M->n, mm = M->m; + if (t) swap(nn, mm); + if (n == 0) n = nn; + if (m == 0) m = mm; + if (n != 0) ffassert(nn == n); + if (m != 0) ffassert(mm == m); + } + return make_pair(n, m); +} -template -long get_mat_n(Matrice_Creuse * p) - { ffassert(p ) ; return p->A ?p->A->n: 0 ;} - -template -bool set_mat_COO(Matrice_Creuse * p) -{ ffassert(p ) ; - HashMatrix *phm=p->pHM(); - if(phm) phm->COO(); - return phm; -} -template -bool set_mat_CSR(Matrice_Creuse * p) -{ ffassert(p ) ; - HashMatrix *phm=p->pHM(); - if(phm) phm->CSR(); - return phm; -} -template -bool set_mat_CSC(Matrice_Creuse * p) -{ ffassert(p ) ; - HashMatrix *phm=p->pHM(); - if(phm) phm->CSC(); - return phm; -} - -template -long get_mat_m(Matrice_Creuse * p) - { ffassert(p ) ; return p->A ?p->A->m: 0 ;} - -template -long get_mat_nbcoef(Matrice_Creuse * p) - { ffassert(p ) ; return p->A ?p->A->NbCoef(): 0 ;} -template -long get_mat_half(Matrice_Creuse * p) -{ return p && p->pHM() ? p->pHM()->half: -1 ;} - -template -pair get_NM(const list *,bool> > & lM) -{ - typedef typename list *,bool> >::const_iterator lconst_iterator; - - lconst_iterator begin=lM.begin(); - lconst_iterator end=lM.end(); - lconst_iterator i; - - long n=0,m=0; - for(i=begin;i!=end;i++++) - { - ffassert(get<1>(*i)); - MatriceCreuse * M=get<1>(*i); - bool t=get<2>(*i); - int nn= M->n,mm=M->m; - if (t) swap(nn,mm); - if ( n==0) n = nn; - if ( m==0) m = mm; - if (n != 0) ffassert(nn == n); - if (m != 0) ffassert(mm == m); - } - return make_pair(n,m); -} - -template -long get_diag(Matrice_Creuse * p, KN * x) - { ffassert(p && x ) ; return p->A ?p->A->getdiag(*x): 0 ;} -template -long set_diag(Matrice_Creuse * p, KN * x) - { ffassert(p && x ) ; return p->A ?p->A->setdiag(*x): 0 ;} - - -template -R * get_elementp2mc(Matrice_Creuse * const & ac,const long & b,const long & c){ - MatriceMorse * a= ac ? ac->pHM() : 0 ; - if( !a || a->n <= b || c<0 || a->m <= c ) - { cerr << " Out of bound 0 <=" << b << " < " << (a ? a->n : 0) << ", 0 <= " << c << " < " << (a ? a->m : 0) - << " Matrix type = " << typeid(ac).name() << endl; - cerr << ac << " " << a << endl; - ExecError("Out of bound in operator Matrice_Creuse (,)");} - R * p =a->npij(b,c); - if( !p) { if(verbosity) cerr << "Error: the coef a(" << b << "," << c << ") doesn't exist in sparse matrix " - << " Matrix type = " << typeid(ac).name() << endl; - ExecError("Use of unexisting coef in sparse matrix operator a(i,j) ");} - return p;} - -template -R get_element2mc(Matrice_Creuse * const & ac,const long & b,const long & c){ - MatriceCreuse * a= ac ? ac->A:0 ; - R r=R(); - if( !a || a->n <= b || c<0 || a->m <= c ) - { cerr << " Out of bound 0 <=" << b << " < " << a->n << ", 0 <= " << c << " < " << a->m - << " Matrix type = " << typeid(ac).name() << endl; - cerr << ac << " " << a << endl; - ExecError("Out of bound in operator Matrice_Creuse (,)");} - R * p =a->pij(b,c); - if(p) r=*p; - return r;} - -template -struct Op2_mulAv{ - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(const AA & a,const BB & b) - { return (*a->A * *b );} +template< class R > +long get_diag(Matrice_Creuse< R > *p, KN< R > *x) { + ffassert(p && x); + return p->A ? p->A->getdiag(*x) : 0; +} +template< class R > +long set_diag(Matrice_Creuse< R > *p, KN< R > *x) { + ffassert(p && x); + return p->A ? p->A->setdiag(*x) : 0; +} + +template< class R > +R *get_elementp2mc(Matrice_Creuse< R > *const &ac, const long &b, const long &c) { + MatriceMorse< R > *a = ac ? ac->pHM( ) : 0; + if (!a || a->n <= b || c < 0 || a->m <= c) { + cerr << " Out of bound 0 <=" << b << " < " << (a ? a->n : 0) << ", 0 <= " << c << " < " << (a ? a->m : 0) << " Matrix type = " << typeid(ac).name( ) << endl; + cerr << ac << " " << a << endl; + ExecError("Out of bound in operator Matrice_Creuse (,)"); + } + R *p = a->npij(b, c); + if (!p) { + if (verbosity) + cerr << "Error: the coef a(" << b << "," << c << ") doesn't exist in sparse matrix " + << " Matrix type = " << typeid(ac).name( ) << endl; + ExecError("Use of unexisting coef in sparse matrix operator a(i,j) "); + } + return p; +} + +template< class R > +R get_element2mc(Matrice_Creuse< R > *const &ac, const long &b, const long &c) { + MatriceCreuse< R > *a = ac ? ac->A : 0; + R r = R( ); + if (!a || a->n <= b || c < 0 || a->m <= c) { + cerr << " Out of bound 0 <=" << b << " < " << a->n << ", 0 <= " << c << " < " << a->m << " Matrix type = " << typeid(ac).name( ) << endl; + cerr << ac << " " << a << endl; + ExecError("Out of bound in operator Matrice_Creuse (,)"); + } + R *p = a->pij(b, c); + if (p) r = *p; + return r; +} + +template< class RR, class AA = RR, class BB = AA > +struct Op2_mulAv { + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(const AA &a, const BB &b) { return (*a->A * *b); } }; -template -struct Op2_mulvirtAv{ - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(const AA & a,const BB & b) - { return RR( (*a).A, b );} +template< class RR, class AA = RR, class BB = AA > +struct Op2_mulvirtAv { + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(const AA &a, const BB &b) { return RR((*a).A, b); } }; -class Matrice_Creuse_C2R { public: - typedef Complex K; - Matrice_Creuse * A; - int cas; // 0 re , 1 im - Matrice_Creuse_C2R(Matrice_Creuse * AA,int cass) : A(AA),cas(cass) {assert(A);} - operator MatriceCreuse & () const {return *A->A;} - operator Matrice_Creuse * () const {return A;} +class Matrice_Creuse_C2R { + public: + typedef Complex K; + Matrice_Creuse< K > *A; + int cas; // 0 re , 1 im + Matrice_Creuse_C2R(Matrice_Creuse< K > *AA, int cass) : A(AA), cas(cass) { assert(A); } + operator MatriceCreuse< K > &( ) const { return *A->A; } + operator Matrice_Creuse< K > *( ) const { return A; } }; // ZZZZZ -R realC(Complex c) {return c.real();} -R imagC(Complex c) {return c.imag();} +R realC(Complex c) { return c.real( ); } +R imagC(Complex c) { return c.imag( ); } +template< int cas > +newpMatrice_Creuse< double > Build_Matrice_Creuse_C2R(Stack stack, Matrice_Creuse< Complex > *const &Mat) { -template -newpMatrice_Creuse Build_Matrice_Creuse_C2R(Stack stack,Matrice_Creuse * const & Mat) -{ - - typedef Complex C; - typedef double R; - using namespace Fem2D; - MatriceMorse * mr= Mat->pHM(); - ffassert(mr); - MatriceMorse * mrr = 0; - if(cas==0) - mrr = new MatriceMorse(*mr,realC); - else if(cas==1) - mrr = new MatriceMorse(*mr,imagC); - else { - cout << " cas = " << cas < *mr = Mat->pHM( ); + ffassert(mr); + MatriceMorse< R > *mrr = 0; + if (cas == 0) + mrr = new MatriceMorse< R >(*mr, realC); + else if (cas == 1) + mrr = new MatriceMorse< R >(*mr, imagC); + else { + cout << " cas = " << cas << endl; + ffassert(0); + } + return newpMatrice_Creuse< double >(stack, mrr); +} + +template< class K > +class OneBinaryOperatorA_inv : public OneOperator { + public: + OneBinaryOperatorA_inv( ) : OneOperator(atype< Matrice_Creuse_inv< K > >( ), atype< Matrice_Creuse< K > * >( ), atype< long >( )) {} + E_F0 *code(const basicAC_F0 &args) const { + Expression p = args[1]; + if (!p->EvaluableWithOutStack( )) { + bool bb = p->EvaluableWithOutStack( ); + cout << bb << " " << *p << endl; + CompileError(" A^p, The p must be a constant == -1, sorry"); } - return newpMatrice_Creuse(stack,mrr); - -} - -template -class OneBinaryOperatorA_inv : public OneOperator { public: - OneBinaryOperatorA_inv() : OneOperator(atype >(),atype *>(),atype()) {} - E_F0 * code(const basicAC_F0 & args) const - { Expression p=args[1]; - if ( ! p->EvaluableWithOutStack() ) - { - bool bb=p->EvaluableWithOutStack(); - cout << bb << " " << * p << endl; - CompileError(" A^p, The p must be a constant == -1, sorry");} - long pv = GetAny((*p)(NullStack)); - if (pv !=-1) - { char buf[100]; - snprintf(buf,100," A^%ld, The pow must be == -1, sorry",pv); - CompileError(buf);} - return new E_F_F0,Matrice_Creuse *>(Build,Matrice_Creuse *>,t[0]->CastTo(args[0])); + long pv = GetAny< long >((*p)(NullStack)); + if (pv != -1) { + char buf[100]; + snprintf(buf, 100, " A^%ld, The pow must be == -1, sorry", pv); + CompileError(buf); } + return new E_F_F0< Matrice_Creuse_inv< K >, Matrice_Creuse< K > * >(Build< Matrice_Creuse_inv< K >, Matrice_Creuse< K > * >, t[0]->CastTo(args[0])); + } }; -template -class OneBinaryOperatorAt_inv : public OneOperator { public: - OneBinaryOperatorAt_inv() : OneOperator(atype >(),atype >(),atype()) {} - E_F0 * code(const basicAC_F0 & args) const - { Expression p=args[1]; - if ( ! p->EvaluableWithOutStack() ) - { - bool bb=p->EvaluableWithOutStack(); - cout << bb << " " << * p << endl; - CompileError(" A^p, The p must be a constant == -1, sorry");} - long pv = GetAny((*p)(NullStack)); - if (pv !=-1) - { char buf[100]; - snprintf(buf,100," A^%ld, The pow must be == -1, sorry",pv); - CompileError(buf);} - return new E_F_F0,Matrice_Creuse_Transpose >(Build,Matrice_Creuse_Transpose >,t[0]->CastTo(args[0])); +template< class K > +class OneBinaryOperatorAt_inv : public OneOperator { + public: + OneBinaryOperatorAt_inv( ) : OneOperator(atype< Matrice_Creuse_inv_trans< K > >( ), atype< Matrice_Creuse_Transpose< K > >( ), atype< long >( )) {} + E_F0 *code(const basicAC_F0 &args) const { + Expression p = args[1]; + if (!p->EvaluableWithOutStack( )) { + bool bb = p->EvaluableWithOutStack( ); + cout << bb << " " << *p << endl; + CompileError(" A^p, The p must be a constant == -1, sorry"); } + long pv = GetAny< long >((*p)(NullStack)); + if (pv != -1) { + char buf[100]; + snprintf(buf, 100, " A^%ld, The pow must be == -1, sorry", pv); + CompileError(buf); + } + return new E_F_F0< Matrice_Creuse_inv_trans< K >, Matrice_Creuse_Transpose< K > >(Build< Matrice_Creuse_inv_trans< K >, Matrice_Creuse_Transpose< K > >, t[0]->CastTo(args[0])); + } }; +template< class K > +class Psor : public E_F0 { + public: + typedef double Result; + Expression mat; + Expression xx, gmn, gmx, oomega; + Psor(const basicAC_F0 &args) { + args.SetNameParam( ); + mat = to< Matrice_Creuse< K > * >(args[0]); + gmn = to< KN< K > * >(args[1]); + gmx = to< KN< K > * >(args[2]); + xx = to< KN< K > * >(args[3]); + oomega = to< double >(args[4]); + } + static ArrayOfaType typeargs( ) { + return ArrayOfaType(atype< double >( ), atype< Matrice_Creuse< K > * >( ), atype< KN< K > * >( ), atype< KN< K > * >( ), atype< KN< K > * >( ), atype< double >( ), false); + } + static E_F0 *f(const basicAC_F0 &args) { return new Psor(args); } + AnyType operator( )(Stack s) const { + Matrice_Creuse< K > *A = GetAny< Matrice_Creuse< K > * >((*mat)(s)); + KN< K > *gmin = GetAny< KN< K > * >((*gmn)(s)); + KN< K > *gmax = GetAny< KN< K > * >((*gmx)(s)); + KN< K > *x = GetAny< KN< K > * >((*xx)(s)); + double omega = GetAny< double >((*oomega)(s)); + return A->A->psor(*gmin, *gmax, *x, omega); + } +}; +template< class R > +struct TheDiagMat { + Matrice_Creuse< R > *A; + TheDiagMat(Matrice_Creuse< R > *AA) : A(AA) { ffassert(A); } + void get_mat_daig(KN_< R > &x) { + ffassert(A && A->A && x.N( ) == A->A->n && A->A->n == A->A->m); + A->A->getdiag(x); + } + void init_get_mat_daig(KN< R > &x) { + ffassert(A && A->A && A->A->n == A->A->m); + x.init(A->A->n); + A->A->getdiag(x); + } + void set_mat_daig(const KN_< R > &x) { + ffassert(A && A->A && x.N( ) == A->A->n && A->A->n == A->A->m); + A->A->setdiag(x); + } +}; -template -class Psor : public E_F0 { public: - - typedef double Result; - Expression mat; - Expression xx,gmn,gmx,oomega; - Psor(const basicAC_F0 & args) - { - args.SetNameParam(); - mat=to *>(args[0]); - gmn=to*>(args[1]); - gmx=to*>(args[2]); - xx=to*>(args[3]); - oomega=to(args[4]); - - } - static ArrayOfaType typeargs() { - return ArrayOfaType( atype(), - atype *>(), - atype*>(), - atype*>(), - atype*>(), - atype(),false);} - - static E_F0 * f(const basicAC_F0 & args){ return new Psor(args);} - - AnyType operator()(Stack s) const { - Matrice_Creuse* A= GetAny* >( (*mat)(s) ); - KN* gmin = GetAny* >( (*gmn)(s) ); - KN* gmax = GetAny* >( (*gmx)(s) ); - KN* x = GetAny* >( (*xx)(s) ); - double omega = GetAny((*oomega)(s)); - return A->A->psor(*gmin,*gmax,*x,omega); - } +template< class R > +struct TheCoefMat { + Matrice_Creuse< R > *A; + TheCoefMat(Matrice_Creuse< R > *AA) : A(AA) { ffassert(A); } + void get_mat_coef(KN_< R > &x) { + ffassert(A && A->A && x.N( ) == A->A->NbCoef( )); + A->A->getcoef(x); + } + void set_mat_coef(const KN_< R > &x) { + ffassert(A && A->A && x.N( ) == A->A->NbCoef( )); + A->A->setcoef(x); + } + void set_mat_coef(const R &v) { + ffassert(A && A->A); + KN< R > x(1, 0, v); // vertor constant to v + A->A->setcoef(x); + } + R trace( ) { return A->A->trace( ); } }; -template - struct TheDiagMat { - Matrice_Creuse * A; - TheDiagMat(Matrice_Creuse * AA) :A(AA) {ffassert(A);} - void get_mat_daig( KN_ & x) { ffassert(A && A->A && x.N() == A->A->n && A->A->n == A->A->m ); - A->A->getdiag(x);} - void init_get_mat_daig( KN & x) { - ffassert(A && A->A && A->A->n == A->A->m ); - x.init(A->A->n); - A->A->getdiag(x);} - void set_mat_daig(const KN_ & x) { ffassert(A && A->A && x.N() == A->A->n && A->A->n == A->A->m ); - A->A->setdiag(x);} - }; - - template - struct TheCoefMat { - Matrice_Creuse * A; - TheCoefMat(Matrice_Creuse * AA) :A(AA) {ffassert(A);} - void get_mat_coef( KN_ & x) { ffassert(A && A->A && x.N() == A->A->NbCoef() ); - A->A->getcoef(x);} - void set_mat_coef(const KN_ & x) { ffassert(A && A->A && x.N() == A->A->NbCoef() ); - A->A->setcoef(x);} - void set_mat_coef(const R & v) { ffassert(A && A->A ); - KN x(1,0,v);// vertor constant to v - A->A->setcoef(x);} - - R trace() { return A->A->trace(); } - }; - -template -R get_trace_mat(Matrice_Creuse * p) -{ - return p && p->A ? p->A->trace():0.; +template< class R > +R get_trace_mat(Matrice_Creuse< R > *p) { + return p && p->A ? p->A->trace( ) : 0.; } -template -bool clear_mat(Matrice_Creuse * p) -{ - if(p && p->A ) p->A->clear(); - return true; +template< class R > +bool clear_mat(Matrice_Creuse< R > *p) { + if (p && p->A) p->A->clear( ); + return true; } +template< class R > +TheDiagMat< R > thediag(Matrice_Creuse< R > *p) { + return TheDiagMat< R >(p); +} -template -TheDiagMat thediag(Matrice_Creuse * p) - { return TheDiagMat(p);} - -template -TheCoefMat thecoef(Matrice_Creuse * p) - { return TheCoefMat(p);} +template< class R > +TheCoefMat< R > thecoef(Matrice_Creuse< R > *p) { + return TheCoefMat< R >(p); +} -template -TheDiagMat set_mat_daig(TheDiagMat dm,KN * x) -{ +template< class R > +TheDiagMat< R > set_mat_daig(TheDiagMat< R > dm, KN< R > *x) { dm.set_mat_daig(*x); return dm; } -template -KN * get_mat_daig(KN * x,TheDiagMat dm) -{ +template< class R > +KN< R > *get_mat_daig(KN< R > *x, TheDiagMat< R > dm) { dm.get_mat_daig(*x); return x; } -template -KN * init_get_mat_daig(KN * x,TheDiagMat dm) -{ - dm.init_get_mat_daig(*x); - return x; +template< class R > +KN< R > *init_get_mat_daig(KN< R > *x, TheDiagMat< R > dm) { + dm.init_get_mat_daig(*x); + return x; } - -template -TheCoefMat set_mat_coef(TheCoefMat dm,KN * x) -{ +template< class R > +TheCoefMat< R > set_mat_coef(TheCoefMat< R > dm, KN< R > *x) { dm.set_mat_coef(*x); return dm; } -template -TheCoefMat set_mat_coef(TheCoefMat dm,R x) -{ - dm.set_mat_coef(x); - return dm; +template< class R > +TheCoefMat< R > set_mat_coef(TheCoefMat< R > dm, R x) { + dm.set_mat_coef(x); + return dm; } -template -KN * get_mat_coef(KN * x,TheCoefMat dm) -{ +template< class R > +KN< R > *get_mat_coef(KN< R > *x, TheCoefMat< R > dm) { dm.get_mat_coef(*x); return x; } -template struct Thresholding { - Matrice_Creuse *v; - Thresholding (Matrice_Creuse *vv): v(vv) {} +template< class T > +struct Thresholding { + Matrice_Creuse< T > *v; + Thresholding(Matrice_Creuse< T > *vv) : v(vv) {} }; -template -Matrice_Creuse*thresholding2 (const Thresholding &t, const double &threshold) { - typedef HashMatrix HMat; - Matrice_Creuse *sparse_mat = t.v; - if (sparse_mat) { - HMat *phm=sparse_mat->pHM() ; - if( phm) - { - int n = phm->n, m = phm->m; - int nnzo = phm->nnz; - phm->resize(n,m,0,threshold); - if (verbosity) {cout << " thresholding : remove " << nnzo-phm->nnz << " them in the matrix " << sparse_mat << " " << threshold << endl;} - } else if (verbosity) {cout << " empty matrix " << sparse_mat << endl;} +template< class R > +Matrice_Creuse< R > *thresholding2(const Thresholding< R > &t, const double &threshold) { + typedef HashMatrix< int, R > HMat; + Matrice_Creuse< R > *sparse_mat = t.v; + if (sparse_mat) { + HMat *phm = sparse_mat->pHM( ); + if (phm) { + int n = phm->n, m = phm->m; + int nnzo = phm->nnz; + phm->resize(n, m, 0, threshold); + if (verbosity) { + cout << " thresholding : remove " << nnzo - phm->nnz << " them in the matrix " << sparse_mat << " " << threshold << endl; + } + } else if (verbosity) { + cout << " empty matrix " << sparse_mat << endl; } - - return t.v; -} + } -template -long symmetrizeCSR (Matrice_Creuse *const &sparse_mat) -{ - - typedef HashMatrix HMat; - if (sparse_mat) { - HMat *phm=sparse_mat->pHM() ; - if( phm) - { - int n = phm->n, m = phm->m; - int nnzo = phm->nnz; - phm->resize(n,m,0,-1,true); - if (verbosity) {cout << " symmetrizeCSR remove " << (long) nnzo-(long) phm->nnz << " them in the matrix " << sparse_mat << endl;} - } else if (verbosity) {cout << " empty matrix " << sparse_mat << endl;} - } - - return 1L; + return t.v; } -template -Thresholding to_Thresholding (Matrice_Creuse *v) {return Thresholding(v);} - -template -bool IsRawMat(const basicAC_F0 & args) -{ - - const E_Array * pee= dynamic_cast((Expression) args[1]); - if (!pee) return 0; - const E_Array &ee=*pee; - int N=ee.size(); - if (N==1) - { - C_F0 c0(ee[0]); - return - atype >()->CastingFrom(ee[0].left()); +template< class T > +long symmetrizeCSR(Matrice_Creuse< T > *const &sparse_mat) { + typedef HashMatrix< int, T > HMat; + if (sparse_mat) { + HMat *phm = sparse_mat->pHM( ); + if (phm) { + int n = phm->n, m = phm->m; + int nnzo = phm->nnz; + phm->resize(n, m, 0, -1, true); + if (verbosity) { + cout << " symmetrizeCSR remove " << (long)nnzo - (long)phm->nnz << " them in the matrix " << sparse_mat << endl; + } + } else if (verbosity) { + cout << " empty matrix " << sparse_mat << endl; } - else if (N==3) - { - C_F0 c0(ee[0]),c1(ee[1]),c2(ee[2]); - return - atype >()->CastingFrom(ee[0].left()) - && atype >()->CastingFrom(ee[1].left()) - && atype >()->CastingFrom(ee[2].left()); + } - } - return 0; + return 1L; } +template< class T > +Thresholding< T > to_Thresholding(Matrice_Creuse< T > *v) { + return Thresholding< T >(v); +} -template -class RawMatrix : public E_F0 { public: - int init; - typedef Matrice_Creuse * Result; - Expression emat; - Expression coef,col,lig; - RawMatrix(const basicAC_F0 & args,int initt) ; - static ArrayOfaType typeargs() { return ArrayOfaType(atype*>(),atype());} - AnyType operator()(Stack s) const ; -}; +template< class R > +bool IsRawMat(const basicAC_F0 &args) { - template - class BlockMatrix : public E_F0 { public: - typedef Matrice_Creuse * Result; - int N,M; - int init; - Expression emat; - Expression ** e_Mij; - int ** t_Mij; - BlockMatrix(const basicAC_F0 & args,int iinit=0) ; - ~BlockMatrix() ; - - static ArrayOfaType typeargs() { return ArrayOfaType(atype*>(),atype());} - static E_F0 * f(const basicAC_F0 & args){ - if(IsRawMat(args)) return new RawMatrix(args,0); - else return new BlockMatrix(args,0); - } - AnyType operator()(Stack s) const ; + const E_Array *pee = dynamic_cast< const E_Array * >((Expression)args[1]); + if (!pee) return 0; + const E_Array &ee = *pee; + int N = ee.size( ); + if (N == 1) { + C_F0 c0(ee[0]); + return atype< KN_< R > >( )->CastingFrom(ee[0].left( )); + } else if (N == 3) { + C_F0 c0(ee[0]), c1(ee[1]), c2(ee[2]); + return atype< KN_< long > >( )->CastingFrom(ee[0].left( )) && atype< KN_< long > >( )->CastingFrom(ee[1].left( )) && atype< KN_< R > >( )->CastingFrom(ee[2].left( )); + } + return 0; +} + +template< typename R > +class RawMatrix : public E_F0 { + public: + int init; + typedef Matrice_Creuse< R > *Result; + Expression emat; + Expression coef, col, lig; + RawMatrix(const basicAC_F0 &args, int initt); + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< E_Array >( )); } + AnyType operator( )(Stack s) const; }; -template -class BlockMatrix1 : public BlockMatrix { public: - BlockMatrix1(const basicAC_F0 & args): BlockMatrix(args,1) {} - static E_F0 * f(const basicAC_F0 & args){ - if(IsRawMat(args)) return new RawMatrix(args,1); - else return new BlockMatrix(args,1); - } +template< typename R > +class BlockMatrix : public E_F0 { + public: + typedef Matrice_Creuse< R > *Result; + int N, M; + int init; + Expression emat; + Expression **e_Mij; + int **t_Mij; + BlockMatrix(const basicAC_F0 &args, int iinit = 0); + ~BlockMatrix( ); + + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< Matrice_Creuse< R > * >( ), atype< E_Array >( )); } + static E_F0 *f(const basicAC_F0 &args) { + if (IsRawMat< R >(args)) + return new RawMatrix< R >(args, 0); + else + return new BlockMatrix(args, 0); + } + AnyType operator( )(Stack s) const; +}; +template< typename R > +class BlockMatrix1 : public BlockMatrix< R > { + public: + BlockMatrix1(const basicAC_F0 &args) : BlockMatrix< R >(args, 1) {} + static E_F0 *f(const basicAC_F0 &args) { + if (IsRawMat< R >(args)) + return new RawMatrix< R >(args, 1); + else + return new BlockMatrix< R >(args, 1); + } }; -template -newpMatrice_Creuse Matrixfull2mapIJ_inv (Stack s,KNM * const & pa,const Inv_KN_long & iii,const Inv_KN_long & jjj) -{ +template< typename R > +newpMatrice_Creuse< R > Matrixfull2mapIJ_inv(Stack s, KNM< R > *const &pa, const Inv_KN_long &iii, const Inv_KN_long &jjj) { + + const KN_< long > &ii(iii), &jj(jjj); + const KNM< R > &a(*pa); + int N = a.N( ), M = a.M( ); + long n = ii(SubArray(N)).max( ) + 1; + long m = jj(SubArray(M)).max( ) + 1; + + HashMatrix< int, R > *pA = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + HashMatrix< int, R > &A = *pA; + + for (long i = 0; i < N; ++i) + for (long j = 0; j < M; ++j) { + R aij = a(i, j); + if (ii[i] >= 0 && jj[j] >= 0 && std::norm(aij) > 1e-40) A(ii[i], jj[j]) += aij; + } - const KN_ &ii(iii), &jj(jjj); - const KNM & a(*pa); - int N=a.N(),M=a.M(); - long n = ii(SubArray(N)).max()+1; - long m= jj(SubArray(M)).max()+1; + return newpMatrice_Creuse< R >(s, pA); +} +template< typename R > +newpMatrice_Creuse< R > Matrixfull2mapIJ(Stack s, KNM< R > *const &pa, const KN_< long > &ii, const KN_< long > &jj) { + const KNM< R > &a(*pa); + int N = a.N( ), M = a.M( ); + long n = ii.N( ); + long m = jj.N( ); + HashMatrix< int, R > *pA = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + HashMatrix< int, R > &A = *pA; - HashMatrix *pA= new HashMatrix((int) n,(int) m,0,0); - HashMatrix & A =*pA; + for (long il = 0; il < n; ++il) // correct juil 2017 FH N --> n + for (long jl = 0; jl < m; ++jl) // correct juil 2017 FH M --> m + { + long i = ii[il]; + long j = jj[jl]; + if (i >= 0 && j >= 0) { + if (!(0 <= i && i < N && 0 <= j && j < M)) { + cerr << " Out of Bound in A(I,J) : " << i << " " << j << " not in " << "[0," << N << "[x[0," << M << "[ \n"; + ExecError("Out of Bound Error"); + } - for (long i=0;i=0 && jj[j]>=0 && std::norm(aij)>1e-40) - A(ii[i],jj[j]) += aij; - } + R aij = a(i, j); + if (std::norm(aij) > 1e-40) A(il, jl) += aij; + } + } - return newpMatrice_Creuse(s,pA); + return newpMatrice_Creuse< R >(s, pA); //;pA; } -template -newpMatrice_Creuse Matrixfull2mapIJ (Stack s, KNM * const & pa,const KN_ & ii,const KN_ & jj) -{ - const KNM & a(*pa); - int N=a.N(),M=a.M(); - long n = ii.N(); - long m= jj.N(); - HashMatrix *pA= new HashMatrix((int)n,(int)m,0,0); - HashMatrix & A =*pA; - - for (long il=0;il n - for (long jl=0;jl m - { - long i = ii[il]; - long j = jj[jl]; - if( i>=0 && j >=0) { - if ( !(0 <= i && i < N && 0 <= j && j < M ) ) - { - cerr << " Out of Bound in A(I,J) : " << i << " " << j << " not in " << "[0,"<1e-40) - A(il,jl) += aij; - } - } - - return newpMatrice_Creuse (s,pA);//;pA; -} - -template -AnyType Matrixfull2map (Stack s , const AnyType & pp) -{ - const KNM & a(*GetAny *>(pp)); - int N=a.N(),M=a.M(); - int n = N; - int m= M; - HashMatrix *pA= new HashMatrix(n,m,0,0); - HashMatrix & A =*pA; +template< class R > +AnyType Matrixfull2map(Stack s, const AnyType &pp) { + const KNM< R > &a(*GetAny< KNM< R > * >(pp)); + int N = a.N( ), M = a.M( ); + int n = N; + int m = M; + HashMatrix< int, R > *pA = new HashMatrix< int, R >(n, m, 0, 0); + HashMatrix< int, R > &A = *pA; - A(n-1,m-1) = R(); // Hack to be sure that the last term existe + A(n - 1, m - 1) = R( ); // Hack to be sure that the last term existe - for (int i=0;i1e-40) - A(i,j) += aij; - } + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) { + R aij = a(i, j); + if (std::norm(aij) > 1e-40) A(i, j) += aij; + } - return SetAny >(newpMatrice_Creuse (s,pA));// + return SetAny< newpMatrice_Creuse< R > >(newpMatrice_Creuse< R >(s, pA)); // } +template< class R > +newpMatrice_Creuse< R > Matrixoutp2mapIJ_inv(Stack s, outProduct_KN_< R > *const &pop, const Inv_KN_long &iii, const Inv_KN_long &jjj) { + const KN_< long > &ii(iii), &jj(jjj); + const outProduct_KN_< R > &op(*pop); + long N = op.a.N( ), M = op.b.N( ); + long n = ii(SubArray(N)).max( ) + 1; + long m = jj(SubArray(M)).max( ) + 1; + HashMatrix< int, R > *pA = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + HashMatrix< int, R > &A = *pA; -template -newpMatrice_Creuse Matrixoutp2mapIJ_inv (Stack s,outProduct_KN_ * const & pop,const Inv_KN_long & iii,const Inv_KN_long & jjj) -{ - const KN_ &ii(iii), &jj(jjj); - const outProduct_KN_ & op(*pop); - long N=op.a.N(),M=op.b.N(); - long n = ii(SubArray(N)).max()+1; - long m= jj(SubArray(M)).max()+1; - HashMatrix *pA= new HashMatrix((int)n,(int)m,0,0); - HashMatrix & A =*pA; - - for (int i=0;i=0 && jj[j]>=0 && std::norm(aij)>1e-40) - A(ii[i],jj[j]) += aij; - } + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) { + R aij = op.a[i] * RNM::conj(op.b[j]) * op.c; + if (ii[i] >= 0 && jj[j] >= 0 && std::norm(aij) > 1e-40) A(ii[i], jj[j]) += aij; + } delete pop; - return newpMatrice_Creuse (s,pA); + return newpMatrice_Creuse< R >(s, pA); } +template< class R > +newpMatrice_Creuse< R > Matrixmapp2mapIJ1(Stack s, Matrice_Creuse< R > *const &mcB, const Inv_KN_long &iii, const Inv_KN_long &jjj) { + const KN_< long > &ii(iii), &jj(jjj); + typedef typename map< pair< int, int >, R >::const_iterator It; -template -newpMatrice_Creuse -Matrixmapp2mapIJ1 (Stack s,Matrice_Creuse *const & mcB,const Inv_KN_long & iii,const Inv_KN_long & jjj) -{ - const KN_ &ii(iii), &jj(jjj); - typedef typename map< pair, R>::const_iterator It; - - int n=0,m=0; - HashMatrix *B = dynamic_cast *>(mcB->pMC()); - ffassert(B); + int n = 0, m = 0; + HashMatrix< int, R > *B = dynamic_cast< HashMatrix< int, R > * >(mcB->pMC( )); + ffassert(B); - int N=ii.N(),M=jj.N(); - int nn = ii.max()+1, mm= jj.max()+1;// missing +1 FH oct 2022 - HashMatrix *pA= new HashMatrix(nn,mm,0,0); - HashMatrix & A =*pA; + int N = ii.N( ), M = jj.N( ); + int nn = ii.max( ) + 1, mm = jj.max( ) + 1; // missing +1 FH oct 2022 + HashMatrix< int, R > *pA = new HashMatrix< int, R >(nn, mm, 0, 0); + HashMatrix< int, R > &A = *pA; - for (int k=0;knnz;++k) - { - int il = B->i[k]; - int jl = B->j[k]; - if ( !( 0 <= il && il < N && 0 <= jl && jl < M ) ) - { - cerr << " Out of Bound in (Map)(I,J) : " << il << " " << jl << " not in " << "[0,"<aij[k]; - if(i >=0 && j>=0) - A(i,j) += aij; + for (int k = 0; k < B->nnz; ++k) { + int il = B->i[k]; + int jl = B->j[k]; + if (!(0 <= il && il < N && 0 <= jl && jl < M)) { + cerr << " Out of Bound in (Map)(I,J) : " << il << " " << jl << " not in " << "[0," << N << "[x[0," << M << "[ \n"; + ExecError("Out of Bound Error"); } - // A[make_pair(n,m)] += R(); // Hack to be sure that the last term existe - // delete B; - // FH question resize or not pA to (n,m); - return newpMatrice_Creuse (s,pA);// + int i = ii(il); + int j = jj(jl); + n = max(i, n); + m = max(j, m); + R aij = B->aij[k]; + if (i >= 0 && j >= 0) A(i, j) += aij; + } + // A[make_pair(n,m)] += R(); // Hack to be sure that the last term existe + // delete B; + // FH question resize or not pA to (n,m); + return newpMatrice_Creuse< R >(s, pA); // } -template +template< class R > // map< pair, R> * -newpMatrice_Creuse Matrixmapp2mapIJ (Stack s,Matrice_Creuse *const & mcB,const KN_ & ii,const KN_ & jj) -{ - - - typedef typename map< pair, R>::const_iterator It; -typedef typename multimap< int,int>::iterator MI; - HashMatrix *B = dynamic_cast *>(mcB->pMC()); - ffassert(B); - multimap< int,int > I,J; - int N=ii.N(),M=jj.N(); - for (int i=0;i=0) - I.insert(make_pair(ii[i],i)); - for (int j=0;j=0) - J.insert(make_pair(jj[j],j)); - int n=N-1,m=M-1;// change FH sep 2009 to have the correct size.. - HashMatrix *pA= new HashMatrix(N,M,0,0); - HashMatrix & A =*pA; - - for (int k=0;k!=B->nnz;++k) - { - int il = B->i[k]; - int jl = B->j[k]; - R aij = B->aij[k]; - pair PPi=I.equal_range(il); - pair PPj=J.equal_range(jl); - for(MI pi=PPi.first ; pi != PPi.second; ++pi) - { - int i=pi->second; - for(MI pj=PPj.first ; pj != PPj.second; ++pj) - { - int j=pj->second; - n=max(i,n); - m=max(j,m); - if(i >=0 && j>=0) - A(i,j) += aij; - } - } +newpMatrice_Creuse< R > Matrixmapp2mapIJ(Stack s, Matrice_Creuse< R > *const &mcB, const KN_< long > &ii, const KN_< long > &jj) { + + typedef typename map< pair< int, int >, R >::const_iterator It; + typedef typename multimap< int, int >::iterator MI; + HashMatrix< int, R > *B = dynamic_cast< HashMatrix< int, R > * >(mcB->pMC( )); + ffassert(B); + multimap< int, int > I, J; + int N = ii.N( ), M = jj.N( ); + for (int i = 0; i < N; ++i) + if (ii[i] >= 0) I.insert(make_pair(ii[i], i)); + for (int j = 0; j < M; ++j) + if (jj[j] >= 0) J.insert(make_pair(jj[j], j)); + int n = N - 1, m = M - 1; // change FH sep 2009 to have the correct size.. + HashMatrix< int, R > *pA = new HashMatrix< int, R >(N, M, 0, 0); + HashMatrix< int, R > &A = *pA; + + for (int k = 0; k != B->nnz; ++k) { + int il = B->i[k]; + int jl = B->j[k]; + R aij = B->aij[k]; + pair< MI, MI > PPi = I.equal_range(il); + pair< MI, MI > PPj = J.equal_range(jl); + for (MI pi = PPi.first; pi != PPi.second; ++pi) { + int i = pi->second; + for (MI pj = PPj.first; pj != PPj.second; ++pj) { + int j = pj->second; + n = max(i, n); + m = max(j, m); + if (i >= 0 && j >= 0) A(i, j) += aij; + } + } + } + // resier A to n,m ????? + // A[make_pair(n,m)] += R(); // Hack to be sure that the last term existe + // delete B; + + // return pA; + return newpMatrice_Creuse< R >(s, pA); // +} + +template< class R > +newpMatrice_Creuse< R > Matrixoutp2mapIJ(Stack s, outProduct_KN_< R > *const &pop, const KN_< long > &ii, const KN_< long > &jj) { + const outProduct_KN_< R > &op(*pop); + long N = op.a.N( ), M = op.b.N( ); + long n = ii.N( ), m = jj.N( ); + R c = op.c; + HashMatrix< int, R > *pA = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + HashMatrix< int, R > &A = *pA; + + for (long il = 0; il < n; ++il) + for (long jl = 0; jl < m; ++jl) { + long i = ii[il]; + long j = jj[jl]; + if (i >= 0 && j >= 0) { + if (!(0 <= i && i < N && 0 <= j && j < M)) { + cerr << " Out of Bound in (a*b')(I,J) : " << i << " " << j << " not in " << "[0," << N << "[x[0," << M << "[ \n"; + ExecError("Out of Bound Error"); + } + R aij = op.a[i] * RNM::conj(op.b[j]) * c; + if (std::norm(aij) > 1e-40) A(il, jl) += aij; + } } - // resier A to n,m ????? - // A[make_pair(n,m)] += R(); // Hack to be sure that the last term existe - // delete B; - - // return pA; - return newpMatrice_Creuse (s,pA);// -} - -template -newpMatrice_Creuse -Matrixoutp2mapIJ (Stack s,outProduct_KN_ * const & pop,const KN_ & ii,const KN_ & jj) -{ - const outProduct_KN_ & op(*pop); - long N=op.a.N(),M=op.b.N(); - long n=ii.N(),m=jj.N(); - R c = op.c; - HashMatrix *pA= new HashMatrix((int)n,(int)m,0,0); - HashMatrix & A =*pA; - - for (long il=0;il=0 && j >=0) - { - if ( !( 0 <= i && i < N && 0 <= j && j < M ) ) - { - cerr << " Out of Bound in (a*b')(I,J) : " << i << " " << j << " not in " << "[0,"<1e-40) - A(il,jl) += aij; - } - } delete pop; - return newpMatrice_Creuse (s,pA); -} - - -template -AnyType Matrixoutp2map (Stack s, const AnyType & pp) -{ - const outProduct_KN_ & op(*GetAny *>(pp)); - long N=op.a.N(),M=op.b.N(); - long n = N; - long m= M; -// A[make_pair(n-1,m-1)] = R(); // Hack to be sure that the last term existe - HashMatrix *pA= new HashMatrix((int)n,(int)m,0,0); - HashMatrix & A =*pA; - - for (long i=0;i1e-40) - A(i,j) += aij; - } + return newpMatrice_Creuse< R >(s, pA); +} + +template< class R > +AnyType Matrixoutp2map(Stack s, const AnyType &pp) { + const outProduct_KN_< R > &op(*GetAny< outProduct_KN_< R > * >(pp)); + long N = op.a.N( ), M = op.b.N( ); + long n = N; + long m = M; + // A[make_pair(n-1,m-1)] = R(); // Hack to be sure that the last term existe + HashMatrix< int, R > *pA = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + HashMatrix< int, R > &A = *pA; + + for (long i = 0; i < N; ++i) + for (long j = 0; j < M; ++j) { + R aij = op.a[i] * RNM::conj(op.b[j]) * op.c; + if (std::norm(aij) > 1e-40) A(i, j) += aij; + } delete &op; - return SetAny>(newpMatrice_Creuse (s,pA));// + return SetAny< newpMatrice_Creuse< R > >(newpMatrice_Creuse< R >(s, pA)); // } - -template BlockMatrix::~BlockMatrix() -{ - if (e_Mij) - { if(verbosity>9999) cout << " del Block matrix "<< this << " " << e_Mij <<" N = " << N << " M = " << M << endl; - for (int i=0;i RawMatrix::RawMatrix(const basicAC_F0 & args,int iinit) -: init(iinit) -{ - args.SetNameParam(); - emat = args[0]; - - const E_Array & ee= *dynamic_cast((Expression) args[1]); - - int N=ee.size(); - if (N==1) - { - C_F0 c0(ee[0]); - coef=to >(ee[0]); - lig=0; - col=0; +template< typename R > +BlockMatrix< R >::~BlockMatrix( ) { + if (e_Mij) { + if (verbosity > 9999) cout << " del Block matrix " << this << " " << e_Mij << " N = " << N << " M = " << M << endl; + for (int i = 0; i < N; i++) { + delete[] e_Mij[i]; + delete[] t_Mij[i]; } + delete[] e_Mij; + delete[] t_Mij; + N = 0; + M = 0; + e_Mij = 0; + t_Mij = 0; + } +} - else if (N==3) - { - C_F0 c0(ee[0]),c1(ee[1]),c2(ee[2]); - coef=to >(ee[2]); - lig=to >(ee[0]); - col=to >(ee[1]); +template< typename R > +RawMatrix< R >::RawMatrix(const basicAC_F0 &args, int iinit) : init(iinit) { + args.SetNameParam( ); + emat = args[0]; - } + const E_Array &ee = *dynamic_cast< const E_Array * >((Expression)args[1]); + int N = ee.size( ); + if (N == 1) { + C_F0 c0(ee[0]); + coef = to< KN_< R > >(ee[0]); + lig = 0; + col = 0; + } + else if (N == 3) { + C_F0 c0(ee[0]), c1(ee[1]), c2(ee[2]); + coef = to< KN_< R > >(ee[2]); + lig = to< KN_< long > >(ee[0]); + col = to< KN_< long > >(ee[1]); + } } -template BlockMatrix::BlockMatrix(const basicAC_F0 & args,int iinit) -: init(iinit) -{ - N=0; - M=0; - args.SetNameParam(); - emat = args[0]; - const E_Array & eMij= *dynamic_cast((Expression) args[1]); - N=eMij.size(); - int err =0; - for (int i=0;i((Expression) eMij[i]); - if (!emi) err++; - else - { - if ( i==0) - M = emi->size(); - else - if(M != emi->size()) err++; - } - } - if (err) { - CompileError(" Block matrix : [[ a, b, c], [ a,b,c ]] or Raw Matrix [a] or [ l, c, a ] "); +template< typename R > +BlockMatrix< R >::BlockMatrix(const basicAC_F0 &args, int iinit) : init(iinit) { + N = 0; + M = 0; + args.SetNameParam( ); + emat = args[0]; + const E_Array &eMij = *dynamic_cast< const E_Array * >((Expression)args[1]); + N = eMij.size( ); + int err = 0; + for (int i = 0; i < N; i++) { + const E_Array *emi = dynamic_cast< const E_Array * >((Expression)eMij[i]); + if (!emi) + err++; + else { + if (i == 0) + M = emi->size( ); + else if (M != emi->size( )) + err++; } - assert(N && M); - e_Mij = new Expression * [N]; - t_Mij = new int * [N]; - for (int i=0;i((Expression) eMij[i]); - - e_Mij[i] = new Expression [M]; - t_Mij[i] = new int [M]; - for (int j=0; j() && eij->EvaluableWithOutStack() ) - { - long contm = GetAny((*eij)(NullStack)); - if(contm==0) - { - e_Mij[i][j]=0; - t_Mij[i][j]=0; - } - else if ( atype()->CastingFrom(rij) ) - { // fevr 2007 - e_Mij[i][j]=to(c_Mij); - t_Mij[i][j]=7; // just un scalaire - } - else CompileError(" Block matrix , Just 0 matrix"); - } - else if ( rij == atype *>()) - { - e_Mij[i][j]=eij; - t_Mij[i][j]=1; - } - else if ( rij == atype >()) - { - e_Mij[i][j]=eij; - t_Mij[i][j]=2; - } - else if ( atype * >()->CastingFrom(rij) ) - { // before KN_ because KNM can be cast in KN_ - - e_Mij[i][j]=to * >(c_Mij); - t_Mij[i][j]=5; - } - else if ( atype >()->CastingFrom(rij) ) - { - e_Mij[i][j]=to >(c_Mij); - t_Mij[i][j]=3; - - } - else if ( atype > >()->CastingFrom(rij) ) - { - - e_Mij[i][j]=to > >(c_Mij); - t_Mij[i][j]=4; - } - else if ( atype * > >()->CastingFrom(rij) ) - { - - e_Mij[i][j]=to *> >(c_Mij); - t_Mij[i][j]=6; - } - else if ( atype()->CastingFrom(rij) ) - { // frev 2007 - e_Mij[i][j]=to(c_Mij); - t_Mij[i][j]=7; // just un scalaire - } - - else { - - CompileError(" Block matrix , bad type in block matrix"); - } - } + } + if (err) { + CompileError(" Block matrix : [[ a, b, c], [ a,b,c ]] or Raw Matrix [a] or [ l, c, a ] "); + } + assert(N && M); + e_Mij = new Expression *[N]; + t_Mij = new int *[N]; + for (int i = 0; i < N; i++) { + const E_Array li = *dynamic_cast< const E_Array * >((Expression)eMij[i]); + + e_Mij[i] = new Expression[M]; + t_Mij[i] = new int[M]; + for (int j = 0; j < M; j++) { + C_F0 c_Mij(li[j]); + Expression eij = c_Mij.LeftValue( ); + aType rij = c_Mij.left( ); + if (rij == atype< long >( ) && eij->EvaluableWithOutStack( )) { + long contm = GetAny< long >((*eij)(NullStack)); + if (contm == 0) { + e_Mij[i][j] = 0; + t_Mij[i][j] = 0; + } else if (atype< R >( )->CastingFrom(rij)) { // fevr 2007 + e_Mij[i][j] = to< R >(c_Mij); + t_Mij[i][j] = 7; // just un scalaire + } else + CompileError(" Block matrix , Just 0 matrix"); + } else if (rij == atype< Matrice_Creuse< R > * >( )) { + e_Mij[i][j] = eij; + t_Mij[i][j] = 1; + } else if (rij == atype< Matrice_Creuse_Transpose< R > >( )) { + e_Mij[i][j] = eij; + t_Mij[i][j] = 2; + } else if (atype< KNM< R > * >( )->CastingFrom(rij)) { // before KN_ because KNM can be cast in KN_ + + e_Mij[i][j] = to< KNM< R > * >(c_Mij); + t_Mij[i][j] = 5; + } else if (atype< KN_< R > >( )->CastingFrom(rij)) { + e_Mij[i][j] = to< KN_< R > >(c_Mij); + t_Mij[i][j] = 3; + + } else if (atype< Transpose< KN_< R > > >( )->CastingFrom(rij)) { + + e_Mij[i][j] = to< Transpose< KN_< R > > >(c_Mij); + t_Mij[i][j] = 4; + } else if (atype< Transpose< KNM< R > * > >( )->CastingFrom(rij)) { + + e_Mij[i][j] = to< Transpose< KNM< R > * > >(c_Mij); + t_Mij[i][j] = 6; + } else if (atype< R >( )->CastingFrom(rij)) { // frev 2007 + e_Mij[i][j] = to< R >(c_Mij); + t_Mij[i][j] = 7; // just un scalaire + } + + else { + CompileError(" Block matrix , bad type in block matrix"); + } } + } } -template -class SetRawMatformMat : public OneOperator { -public: - typedef Matrice_Creuse * A; // Warning B type of 2 parameter - typedef Matrice_Creuse * R; - typedef E_Array B; // A type of 1 parameter - - class CODE : public E_F0 { public: - Expression Mat; - Expression lig; - Expression col; - Expression coef; - bool mi; - CODE(Expression a,const E_Array & tt) - : Mat(a), - mi(tt.MeshIndependent()) - { - - assert(&tt); - if(tt.size()!=3) - CompileError("Set raw matrix: [ lg,col, a] = A (size !=3) "); - if ( aatypeknlongp->CastingFrom(tt[0].left() ) //// for compilation error with g++ 3.2.2 (4 times) - && aatypeknlongp->CastingFrom(tt[1].left() ) - && atype* >()->CastingFrom(tt[2].left() ) ) - { - lig = aatypeknlongp->CastTo(tt[0]); - col = aatypeknlongp->CastTo(tt[1]); - coef = atype* >()->CastTo(tt[2]); - } - else - CompileError(" we are waiting for [ lg,col,a] = A"); +template< typename RR > +class SetRawMatformMat : public OneOperator { + public: + typedef Matrice_Creuse< RR > *A; // Warning B type of 2 parameter + typedef Matrice_Creuse< RR > *R; + typedef E_Array B; // A type of 1 parameter + + class CODE : public E_F0 { + public: + Expression Mat; + Expression lig; + Expression col; + Expression coef; + bool mi; + CODE(Expression a, const E_Array &tt) : Mat(a), mi(tt.MeshIndependent( )) { + + assert(&tt); + if (tt.size( ) != 3) CompileError("Set raw matrix: [ lg,col, a] = A (size !=3) "); + if (aatypeknlongp->CastingFrom(tt[0].left( )) //// for compilation error with g++ 3.2.2 (4 times) + && aatypeknlongp->CastingFrom(tt[1].left( )) && atype< KN< RR > * >( )->CastingFrom(tt[2].left( ))) { + lig = aatypeknlongp->CastTo(tt[0]); + col = aatypeknlongp->CastTo(tt[1]); + coef = atype< KN< RR > * >( )->CastTo(tt[2]); + } else + CompileError(" we are waiting for [ lg,col,a] = A"); } - AnyType operator()(Stack stack) const - { - - //V4 - A a=GetAny((*Mat)(stack)); - - KN *lg,*cl; - KN *cc; - lg = GetAny*>((*lig)(stack)); - cl = GetAny*>((*col)(stack)); - cc = GetAny*>((*coef)(stack)); - int n=a->N(),m=a->M(); - HashMatrix *mh = a->pHM(); - mh->COO(); - - int kk = mh->nnz,k1=0; - if( mh->pij(n-1,m-1)==0 ) k1=1; - lg->resize(kk+k1); - cc->resize(kk+k1); - cl->resize(kk+k1); - int k=0; - - for ( k=0 ; k < kk;++k) - { - (*lg)[k]= mh->i[k]; - (*cl)[k]= mh->j[k]; - (*cc)[k]= mh->aij[k]; - } - - if(k1) - { - (*lg)[kk]= n; - (*cl)[kk]= m; - (*cc)[kk]= 0; - } - - return SetAny(a); - } - bool MeshIndependent() const {return mi;} // - ~CODE() {} - operator aType () const { return atype();} - }; // end sub class CODE - - -public: // warning hack A and B - E_F0 * code(const basicAC_F0 & args) const - { return new CODE(t[1]->CastTo(args[1]),*dynamic_cast( t[0]->CastTo(args[0]).RightValue()));} - SetRawMatformMat(): OneOperator(atype(),atype(),atype()) {} // warning with A and B + AnyType operator( )(Stack stack) const { + + // V4 + A a = GetAny< A >((*Mat)(stack)); + + KN< long > *lg, *cl; + KN< RR > *cc; + lg = GetAny< KN< long > * >((*lig)(stack)); + cl = GetAny< KN< long > * >((*col)(stack)); + cc = GetAny< KN< RR > * >((*coef)(stack)); + int n = a->N( ), m = a->M( ); + HashMatrix< int, RR > *mh = a->pHM( ); + mh->COO( ); + + int kk = mh->nnz, k1 = 0; + if (mh->pij(n - 1, m - 1) == 0) k1 = 1; + lg->resize(kk + k1); + cc->resize(kk + k1); + cl->resize(kk + k1); + int k = 0; + + for (k = 0; k < kk; ++k) { + (*lg)[k] = mh->i[k]; + (*cl)[k] = mh->j[k]; + (*cc)[k] = mh->aij[k]; + } -}; + if (k1) { + (*lg)[kk] = n; + (*cl)[kk] = m; + (*cc)[kk] = 0; + } -template AnyType RawMatrix::operator()(Stack stack) const -{ - MatriceMorse * amorse =0; - KN_ cc(GetAny< KN_ >((*coef)(stack))); - int k= cc.N(); - int n= k; - int m=n; - bool sym=false; - if( lig && col) - { - KN_ lg(GetAny< KN_ >((*lig)(stack))); - KN_ cl=(GetAny< KN_ >((*col)(stack))); - n = lg.max()+1; - m = cl.max()+1; - ffassert( lg.N()==k && cl.N()==k && lg.min()>=0 && lg.max()>=0); - amorse = new MatriceMorse(n,m,k,0); - sym=false; - for(int i=0;i((int)lg[i],(int)cl[i])]+=cc[i]; - } - else - { - amorse = new MatriceMorse(n,cc); + return SetAny< R >(a); } + bool MeshIndependent( ) const { return mi; } // + ~CODE( ) {} + operator aType( ) const { return atype< R >( ); } + }; // end sub class CODE + + public: // warning hack A and B + E_F0 *code(const basicAC_F0 &args) const { return new CODE(t[1]->CastTo(args[1]), *dynamic_cast< const E_Array * >(t[0]->CastTo(args[0]).RightValue( ))); } + SetRawMatformMat( ) : OneOperator(atype< R >( ), atype< B >( ), atype< A >( )) {} // warning with A and B +}; - if(verbosity) - cout << " -- Raw Matrix nxm =" <nnz << endl; +template< typename R > +AnyType RawMatrix< R >::operator( )(Stack stack) const { + MatriceMorse< R > *amorse = 0; + KN_< R > cc(GetAny< KN_< R > >((*coef)(stack))); + int k = cc.N( ); + int n = k; + int m = n; + bool sym = false; + if (lig && col) { + KN_< long > lg(GetAny< KN_< long > >((*lig)(stack))); + KN_< long > cl = (GetAny< KN_< long > >((*col)(stack))); + n = lg.max( ) + 1; + m = cl.max( ) + 1; + ffassert(lg.N( ) == k && cl.N( ) == k && lg.min( ) >= 0 && lg.max( ) >= 0); + amorse = new MatriceMorse< R >(n, m, k, 0); + sym = false; + for (int i = 0; i < k; ++i) (*amorse)[make_pair< int, int >((int)lg[i], (int)cl[i])] += cc[i]; + } else { + amorse = new MatriceMorse< R >(n, cc); + } - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(stack)); - if( !init) sparse_mat->init(); + if (verbosity) cout << " -- Raw Matrix nxm =" << n << "x" << m << " nb none zero coef. " << amorse->nnz << endl; - sparse_mat->A.master(amorse); - sparse_mat->typemat=0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(stack)); + if (!init) sparse_mat->init( ); - if(verbosity>3) { cout << " End Raw Matrix : " << endl;} + sparse_mat->A.master(amorse); + sparse_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + + if (verbosity > 3) { + cout << " End Raw Matrix : " << endl; + } - return sparse_mat; + return sparse_mat; } -template AnyType BlockMatrix::operator()(Stack s) const -{ - typedef list *,bool> > * L; - KNM Bij(N,M); - KNM * > Fij(N,M); - KNM cnjij(N,M); - KNM Rij(N,M); // to sto - - cnjij = false; - KN Oi(N+1), Oj(M+1); - KN Zi(N,false), Zj(M,false); - - if(verbosity>9) { cout << " Build Block Matrix : " << N << " x " << M << endl;} - Bij = (L) 0; - Oi = (long) 0; - Oj = (long)0; - - for (int i=0;i +AnyType BlockMatrix< R >::operator( )(Stack s) const { + typedef list< tuple< R, MatriceCreuse< R > *, bool > > *L; + KNM< L > Bij(N, M); + KNM< KNM_< R > * > Fij(N, M); + KNM< bool > cnjij(N, M); + KNM< R > Rij(N, M); // to sto + + cnjij = false; + KN< long > Oi(N + 1), Oj(M + 1); + KN< bool > Zi(N, false), Zj(M, false); + + if (verbosity > 9) { + cout << " Build Block Matrix : " << N << " x " << M << endl; + } + Bij = (L)0; + Oi = (long)0; + Oj = (long)0; + + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) { + Fij(i, j) = 0; Expression eij = e_Mij[i][j]; - int tij=t_Mij[i][j]; - if (eij) // warning eij == 0 is O case. + int tij = t_Mij[i][j]; + if (eij) // warning eij == 0 is O case. { - cnjij(i,j) = tij%2 == 0; - AnyType e=(*eij)(s); - if (tij==1) Bij(i,j) = to( GetAny< Matrice_Creuse* >( e)) ; - else if (tij==2) Bij(i,j) = to( GetAny >(e)); - else if (tij==3) { KN_ x=GetAny< KN_ >( e); Fij(i,j) = new KNM_(x,x.N(),1);} - else if (tij==4) { KN_ x=GetAny< Transpose< KN_ > >( e).t ; Fij(i,j) = new KNM_(x,1,x.N());} - else if (tij==5) { KNM * m= GetAny< KNM* >( e); Fij(i,j) = new KNM_(*m);} - else if (tij==6) { KNM * m= GetAny< Transpose< KNM* > >( e).t; Fij(i,j) = new KNM_(m->t()); } - else if (tij==7) { Rij(i,j)=GetAny< R >( e); Fij(i,j) = new KNM_(&(Rij(i,j)),1,1);} + cnjij(i, j) = tij % 2 == 0; + AnyType e = (*eij)(s); + if (tij == 1) + Bij(i, j) = to(GetAny< Matrice_Creuse< R > * >(e)); + else if (tij == 2) + Bij(i, j) = to(GetAny< Matrice_Creuse_Transpose< R > >(e)); + else if (tij == 3) { + KN_< R > x = GetAny< KN_< R > >(e); + Fij(i, j) = new KNM_< R >(x, x.N( ), 1); + } else if (tij == 4) { + KN_< R > x = GetAny< Transpose< KN_< R > > >(e).t; + Fij(i, j) = new KNM_< R >(x, 1, x.N( )); + } else if (tij == 5) { + KNM< R > *m = GetAny< KNM< R > * >(e); + Fij(i, j) = new KNM_< R >(*m); + } else if (tij == 6) { + KNM< R > *m = GetAny< Transpose< KNM< R > * > >(e).t; + Fij(i, j) = new KNM_< R >(m->t( )); + } else if (tij == 7) { + Rij(i, j) = GetAny< R >(e); + Fij(i, j) = new KNM_< R >(&(Rij(i, j)), 1, 1); + } else { - cout << " Bug " << tij << endl; - ExecError(" Type sub matrix block unknown "); + cout << " Bug " << tij << endl; + ExecError(" Type sub matrix block unknown "); + } + } else + ffassert(tij == 0); + } + // compute size of matrix + int err = 0; + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) { + pair< long, long > nm(0, 0); + + if (Bij(i, j)) + nm = get_NM(*Bij(i, j)); + else if (Fij(i, j)) + nm = make_pair< long, long >(Fij(i, j)->N( ), Fij(i, j)->M( )); + else + Zi(i) = Zj(j) = true; + if ((nm.first || nm.second) && verbosity > 3) cout << " Block [ " << i << "," << j << " ] = " << nm.first << " x " << nm.second << " cnj = " << cnjij(i, j) << endl; + if (nm.first) { + if (Oi(i + 1) == 0) + Oi(i + 1) = nm.first; + else if (Oi(i + 1) != nm.first) { + err++; + cerr << "Error Block Matrix, size sub matrix" << i << "," << j << " n (old) " << Oi(i + 1) << " n (new) " << nm.first << endl; } } - else ffassert(tij==0); - } - // compute size of matrix - int err=0; - for (int i=0;i nm(0,0); - - if (Bij(i,j)) - nm = get_NM( *Bij(i,j)); - else if(Fij(i,j)) - nm = make_pair(Fij(i,j)->N(), Fij(i,j)->M()); - else - Zi(i)=Zj(j)=true; - if (( nm.first || nm.second) && verbosity>3) - cout << " Block [ " << i << "," << j << " ] = " << nm.first << " x " << nm.second << " cnj = " << cnjij(i,j) << endl; - if (nm.first) - { - if ( Oi(i+1) ==0 ) Oi(i+1)=nm.first; - else if(Oi(i+1) != nm.first) - { - err++; - cerr <<"Error Block Matrix, size sub matrix" << i << ","<< j << " n (old) " << Oi(i+1) - << " n (new) " << nm.first << endl; - - } - } - if(nm.second) - { - if ( Oj(j+1) ==0) Oj(j+1)=nm.second; - else if(Oj(j+1) != nm.second) - { - cerr <<"Error Block Matrix, size sub matrix" << i << ","<< j << " m (old) " << Oj(j+1) - << " m (new) " << nm.second << endl; - err++;} - } + if (nm.second) { + if (Oj(j + 1) == 0) + Oj(j + 1) = nm.second; + else if (Oj(j + 1) != nm.second) { + cerr << "Error Block Matrix, size sub matrix" << i << "," << j << " m (old) " << Oj(j + 1) << " m (new) " << nm.second << endl; + err++; } - - if (err) ExecError("Error Block Matrix, size sub matrix"); - // gestion of zero block ???? -/* remove for block of size 0 june 13 2025 PHT and FH */ - for (int j=0;j99) cout << j << " column size" << Oj(j+1) << endl; - if ( Oj(j+1) ==0 && Zj(j)) - Oj(j+1)=1; - - } - for (int i=0;i99) cout << i << " row size" << Oi(i+1) << endl; - if ( Oi(i+1) ==0 && Zi(i)) - Oi(i+1)=1; + } } - for (int i=0;i99) - { - cout << " Oi = " << Oi << endl; - cout << " Oj = " << Oj << endl; - } - MatriceMorse * amorse =0; -{ - HashMatrix *Aij = new HashMatrix( n, m,0,0); - for (int i=0;i99) - cout << " Add Block S " << i << "," << j << " = at " << Oi(i) << " x " << Oj(j) << " conj = " << cnjij(i,j) << endl; - HashMatrix & mmij=*Aij; - const list*,bool> > &lM=*Bij(i,j); - bool ttrans=false; // transpose flag already in lM - int ii00=Oi(i); - int jj00=Oj(j); - bool cnj=false; // transpose flag already in lM - BuildCombMat(mmij,lM,ttrans,ii00,jj00,cnj); - - - } - else if (Fij(i,j)) - { - if(verbosity>99) - cout << " Add Block F " << i << "," << j << " = at " << Oi(i) << " x " << Oj(j) << endl; - BuildCombMat(*Aij,*Fij(i,j),Oi(i),Oj(j),R(1.),cnjij(i,j));// BuildCombMat - } + if (err) ExecError("Error Block Matrix, size sub matrix"); + // gestion of zero block ???? + /* remove for block of size 0 june 13 2025 PHT and FH */ + for (int j = 0; j < M; ++j) { + if (verbosity > 99) cout << j << " column size" << Oj(j + 1) << endl; + if (Oj(j + 1) == 0 && Zj(j)) Oj(j + 1) = 1; + } + for (int i = 0; i < N; ++i) { + if (verbosity > 99) cout << i << " row size" << Oi(i + 1) << endl; + if (Oi(i + 1) == 0 && Zi(i)) Oi(i + 1) = 1; + } + for (int i = 0; i < N; ++i) Oi(i + 1) += Oi(i); + for (int j = 0; j < M; ++j) // correct 10/01/2007 FH + Oj(j + 1) += Oj(j); // correct 07/03/2010 FH + long n = Oi(N), m = Oj(M); + if (verbosity > 99) { + cout << " Oi = " << Oi << endl; + cout << " Oj = " << Oj << endl; + } + MatriceMorse< R > *amorse = 0; + { + HashMatrix< int, R > *Aij = new HashMatrix< int, R >(n, m, 0, 0); + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) + if (Bij(i, j)) { + if (verbosity > 99) cout << " Add Block S " << i << "," << j << " = at " << Oi(i) << " x " << Oj(j) << " conj = " << cnjij(i, j) << endl; + HashMatrix< int, R > &mmij = *Aij; + const list< tuple< R, MatriceCreuse< R > *, bool > > &lM = *Bij(i, j); + bool ttrans = false; // transpose flag already in lM + int ii00 = Oi(i); + int jj00 = Oj(j); + bool cnj = false; // transpose flag already in lM + BuildCombMat(mmij, lM, ttrans, ii00, jj00, cnj); + + } else if (Fij(i, j)) { + if (verbosity > 99) cout << " Add Block F " << i << "," << j << " = at " << Oi(i) << " x " << Oj(j) << endl; + BuildCombMat(*Aij, *Fij(i, j), Oi(i), Oj(j), R(1.), cnjij(i, j)); // BuildCombMat + } - amorse= Aij; + amorse = Aij; } - if(verbosity>9) - cout << " -- Block Matrix NxM = " << N << "x" << M << " nxm =" <nnz << endl; + if (verbosity > 9) cout << " -- Block Matrix NxM = " << N << "x" << M << " nxm =" << n << "x" << m << " nb none zero coef. " << amorse->nnz << endl; - Matrice_Creuse * sparse_mat =GetAny* >((*emat)(s)); - if(!init) sparse_mat->init(); + Matrice_Creuse< R > *sparse_mat = GetAny< Matrice_Creuse< R > * >((*emat)(s)); + if (!init) sparse_mat->init( ); sparse_mat->A.master(amorse); - sparse_mat->typemat=0;//(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) - + sparse_mat->typemat = 0; //(amorse->n == amorse->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) // cleanning - for (int i=0;i9) { cout << " End Build Blok Matrix : " << endl;} - - return sparse_mat; + for (int i = 0; i < N; ++i) + for (int j = 0; j < M; ++j) + if (Bij(i, j)) + delete Bij(i, j); + else if (Fij(i, j)) + delete Fij(i, j); + if (verbosity > 9) { + cout << " End Build Blok Matrix : " << endl; + } + return sparse_mat; } -template -class minusMat { public: - list *,bool> > *l; - minusMat(list *,bool> > *ll): - l(new list *,bool> >(*ll) ) - { - typedef typename list *,bool> >::iterator lci; - for (lci i= l->begin();i !=l->end();++i) - get<0>(*i) *= R(-1); - } +template< class R > +class minusMat { + public: + list< tuple< R, MatriceCreuse< R > *, bool > > *l; + minusMat(list< tuple< R, MatriceCreuse< R > *, bool > > *ll) : l(new list< tuple< R, MatriceCreuse< R > *, bool > >(*ll)) { + typedef typename list< tuple< R, MatriceCreuse< R > *, bool > >::iterator lci; + for (lci i = l->begin( ); i != l->end( ); ++i) get< 0 >(*i) *= R(-1); + } }; -template -AnyType mM2L3 (Stack , const AnyType & pp) -{ - minusMat mpp(to(GetAny *>(pp))); - return SetAny >(mpp); -} - -template -class E_ForAllLoopMatrix -{ public: - - typedef R *VV; - typedef long KK; - - typedef Matrice_Creuse * Tab; - - typedef ForAllLoopOpBase DataL; - const DataL *data; - E_ForAllLoopMatrix(const DataL *t): data(t){} - AnyType f(Stack s) const { - Tab t= GetAny(data->tab(s)); - KK * i = GetAny(data->i(s)); - KK * j = GetAny(data->j(s)); - VV v = GetAny(data->v(s)); - if(verbosity>1000) { - cout << " i " << (char*) (void *) i - (char*)(void*) s ; - cout << " j " << (char*) (void *) j - (char*)(void*) s ; - cout << " vi " << (char*) (void *) v - (char*)(void*) s ; - cout << endl; - } - - ffassert(i && v); - MatriceCreuse *m=t->A; - MatriceMorse *mm = dynamic_cast*>(m); - if(!mm) ExecError(" Matrix sparse of bad type ( not HMatrix ) , sorry.. "); - if(mm) - for (long kk=0;kk< mm->nnz; ++kk) - { - *i=mm->i[kk]; - *j= mm->j[kk]; - *v = mm->aij[kk]; - try { - data->code(s); - mm->aij[kk] = *v; - } - catch ( E_exception & e) { - if (e.code == E_exception::e_break) break; - else if (e.code == E_exception::e_continue) continue; - else throw e; - } - - } - return Nothing ; +template< class R > +AnyType mM2L3(Stack, const AnyType &pp) { + minusMat< R > mpp(to(GetAny< Matrice_Creuse< R > * >(pp))); + return SetAny< minusMat< R > >(mpp); +} + +template< class R > +class E_ForAllLoopMatrix { + public: + typedef R *VV; + typedef long KK; + + typedef Matrice_Creuse< R > *Tab; + + typedef ForAllLoopOpBase DataL; + const DataL *data; + E_ForAllLoopMatrix(const DataL *t) : data(t) {} + AnyType f(Stack s) const { + Tab t = GetAny< Tab >(data->tab(s)); + KK *i = GetAny< KK * >(data->i(s)); + KK *j = GetAny< KK * >(data->j(s)); + VV v = GetAny< VV >(data->v(s)); + if (verbosity > 1000) { + cout << " i " << (char *)(void *)i - (char *)(void *)s; + cout << " j " << (char *)(void *)j - (char *)(void *)s; + cout << " vi " << (char *)(void *)v - (char *)(void *)s; + cout << endl; } + ffassert(i && v); + MatriceCreuse< R > *m = t->A; + MatriceMorse< R > *mm = dynamic_cast< MatriceMorse< R > * >(m); + if (!mm) ExecError(" Matrix sparse of bad type ( not HMatrix ) , sorry.. "); + if (mm) + for (long kk = 0; kk < mm->nnz; ++kk) { + *i = mm->i[kk]; + *j = mm->j[kk]; + *v = mm->aij[kk]; + try { + data->code(s); + mm->aij[kk] = *v; + } catch (E_exception &e) { + if (e.code == E_exception::e_break) + break; + else if (e.code == E_exception::e_continue) + continue; + else + throw e; + } + } + return Nothing; + } }; // Mat real -> mat complex .... ??? FH. april 2016 .... -struct VirtualMatCR :public RNM_VirtualMatrix{ public: - RNM_VirtualMatrix& VM; - typedef Complex R; - VirtualMatCR( RNM_VirtualMatrix & MM): RNM_VirtualMatrix(MM.N,MM.M), VM(MM) {} - void addMatMul(const KN_ & cx, KN_ & cy) const { - double *px = static_cast(static_cast(cx)); - double *py = static_cast(static_cast(cy)); - KN_ rx(px+0,cx.N(),cx.step*2); - KN_ ix(px+1,cx.N(),cx.step*2); - KN_ ry(py+0,cy.N(),cy.step*2); - KN_ iy(py+1,cy.N(),cy.step*2); - VM.addMatMul(rx,ry); - VM.addMatMul(ix,iy); - } - void addMatTransMul(const KN_ & cx , KN_ & cy ) const { - double *px = static_cast(static_cast(cx)); - double *py = static_cast(static_cast(cy)); - KN_ rx(px+0,cx.N(),cx.step*2); - KN_ ix(px+1,cx.N(),cx.step*2); - KN_ ry(py+0,cy.N(),cy.step*2); - KN_ iy(py+1,cy.N(),cy.step*2); - VM.addMatTransMul(rx,ry); - VM.addMatTransMul(ix,iy); - - } - bool WithSolver() const {return VM.WithSolver();} // by default no solver - virtual void Solve( KN_ & cx ,const KN_ & cy) const - { if( !VM.WithSolver()) InternalError("RNM_VirtualMatrix::solve not implemented "); - double *px = static_cast(static_cast(cx)); - double *py = static_cast(static_cast(cy)); - KN_ rx(px+0,cx.N(),cx.step*2); - KN_ ix(px+1,cx.N(),cx.step*2); - KN_ ry(py+0,cy.N(),cy.step*2); - KN_ iy(py+1,cy.N(),cy.step*2); - VM.Solve(rx,ry); - VM.Solve(ix,iy); - } +struct VirtualMatCR : public RNM_VirtualMatrix< Complex > { + public: + RNM_VirtualMatrix< double > &VM; + typedef Complex R; + VirtualMatCR(RNM_VirtualMatrix< double > &MM) : RNM_VirtualMatrix< Complex >(MM.N, MM.M), VM(MM) {} + void addMatMul(const KN_< R > &cx, KN_< R > &cy) const { + double *px = static_cast< double * >(static_cast< void * >(cx)); + double *py = static_cast< double * >(static_cast< void * >(cy)); + KN_< double > rx(px + 0, cx.N( ), cx.step * 2); + KN_< double > ix(px + 1, cx.N( ), cx.step * 2); + KN_< double > ry(py + 0, cy.N( ), cy.step * 2); + KN_< double > iy(py + 1, cy.N( ), cy.step * 2); + VM.addMatMul(rx, ry); + VM.addMatMul(ix, iy); + } + void addMatTransMul(const KN_< R > &cx, KN_< R > &cy) const { + double *px = static_cast< double * >(static_cast< void * >(cx)); + double *py = static_cast< double * >(static_cast< void * >(cy)); + KN_< double > rx(px + 0, cx.N( ), cx.step * 2); + KN_< double > ix(px + 1, cx.N( ), cx.step * 2); + KN_< double > ry(py + 0, cy.N( ), cy.step * 2); + KN_< double > iy(py + 1, cy.N( ), cy.step * 2); + VM.addMatTransMul(rx, ry); + VM.addMatTransMul(ix, iy); + } + bool WithSolver( ) const { return VM.WithSolver( ); } // by default no solver + virtual void Solve(KN_< R > &cx, const KN_< R > &cy) const { + if (!VM.WithSolver( )) InternalError("RNM_VirtualMatrix::solve not implemented "); + double *px = static_cast< double * >(static_cast< void * >(cx)); + double *py = static_cast< double * >(static_cast< void * >(cy)); + KN_< double > rx(px + 0, cx.N( ), cx.step * 2); + KN_< double > ix(px + 1, cx.N( ), cx.step * 2); + KN_< double > ry(py + 0, cy.N( ), cy.step * 2); + KN_< double > iy(py + 1, cy.N( ), cy.step * 2); + VM.Solve(rx, ry); + VM.Solve(ix, iy); + } - bool ChecknbLine (int n) const { return VM.ChecknbLine(n); } - bool ChecknbColumn (int m) const { return VM.ChecknbColumn(m); } + bool ChecknbLine(int n) const { return VM.ChecknbLine(n); } + bool ChecknbColumn(int m) const { return VM.ChecknbColumn(m); } }; -template // extend (4th arg.) -class Op2_mulvirtAvCR : public OneOperator { // - aType r; // return type - - -public: - class CODE :public E_F0 { public: // extend - Expression a0,a1; // extend - CODE( Expression aa0,Expression aa1) : a0(aa0), a1(aa1) {} // extend (2th arg.) - AnyType operator()(Stack s) const - { - - RNM_VirtualMatrix *pv = new VirtualMatCR ((*GetAny((*a0)(s))).A); - Add2StackOfPtr2Free(s,pv); - return SetAny(R(pv,GetAny((*a1)(s)))); - } - virtual size_t nbitem() const {return a1->nbitem(); } // modif ??? - bool MeshIndependent() const {return a0->MeshIndependent() && a1->MeshIndependent() ;} - }; +template< class R, class A, class B > // extend (4th arg.) +class Op2_mulvirtAvCR : public OneOperator { // + aType r; // return type - E_F0 * code(const basicAC_F0 & args) const - { if ( args.named_parameter && !args.named_parameter->empty() ) - CompileError( " They are used Named parameter "); - - return new CODE( t[0]->CastTo(args[0]), - t[1]->CastTo(args[1]));} // extend - Op2_mulvirtAvCR(int preff=0): // 3->4 - OneOperator(map_type[typeid(R).name()], - map_type[typeid(A).name()], - map_type[typeid(B).name()]) {pref=preff;} + public: + class CODE : public E_F0 { + public: // extend + Expression a0, a1; // extend + CODE(Expression aa0, Expression aa1) : a0(aa0), a1(aa1) {} // extend (2th arg.) + AnyType operator( )(Stack s) const { + RNM_VirtualMatrix< Complex > *pv = new VirtualMatCR((*GetAny< A >((*a0)(s))).A); + Add2StackOfPtr2Free(s, pv); + return SetAny< R >(R(pv, GetAny< B >((*a1)(s)))); + } + virtual size_t nbitem( ) const { return a1->nbitem( ); } // modif ??? + bool MeshIndependent( ) const { return a0->MeshIndependent( ) && a1->MeshIndependent( ); } + }; + + E_F0 *code(const basicAC_F0 &args) const { + if (args.named_parameter && !args.named_parameter->empty( )) CompileError(" They are used Named parameter "); + + return new CODE(t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); + } // extend + Op2_mulvirtAvCR(int preff = 0) + : // 3->4 + OneOperator(map_type[typeid(R).name( )], map_type[typeid(A).name( )], map_type[typeid(B).name( )]) { + pref = preff; + } }; // Norme Hashmatrix -template -double get_norme_linfty(Matrice_Creuse * p){ - if(p==0) return 0.; - HashMatrix* ph=p->pHM(); - ffassert(ph); - return ph->norminfty();} -template -double get_norme_l2(Matrice_Creuse * p){ - if(p==0) return 0.; - HashMatrix* ph=p->pHM(); - ffassert(ph); - return ph->FrobeniusNorm();} - -template -double get_norme_l1(Matrice_Creuse * p){ - if(p==0) return 0.; - HashMatrix* ph=p->pHM(); - ffassert(ph); - return ph->norm1();} - -template -Matrice_Creuse * SetMatrice_Creuse(Matrice_Creuse * p,newpMatrice_Creuse np) -{ - return np.set(p,Init); +template< class K > +double get_norme_linfty(Matrice_Creuse< K > *p) { + if (p == 0) return 0.; + HashMatrix< int, K > *ph = p->pHM( ); + ffassert(ph); + return ph->norminfty( ); } -// Add F.H July 2019 -template -Matrice_Creuse * InitMatrice_Creuse_nm(Matrice_Creuse * const & p,const long &n,const long &m) -{ - p->init() ; - HashMatrix *phm= new HashMatrix((int) n,(int) m,0,0); - MatriceCreuse *pmc(phm); - p->A.master(pmc); - return p; -} -template -Matrice_Creuse * InitMatrice_Creuse_n(Matrice_Creuse * const & p,const long &n) -{ - p->init() ; - HashMatrix *phm= new HashMatrix((int)n,(int) n,0,0); - MatriceCreuse *pmc(phm); - p->A.master(pmc); - return p; +template< class K > +double get_norme_l2(Matrice_Creuse< K > *p) { + if (p == 0) return 0.; + HashMatrix< int, K > *ph = p->pHM( ); + ffassert(ph); + return ph->FrobeniusNorm( ); } -template -Matrice_Creuse * AddtoMatrice_Creuse(Matrice_Creuse * p,newpMatrice_Creuse np) -{ - return np.add(p,double(c)); +template< class K > +double get_norme_l1(Matrice_Creuse< K > *p) { + if (p == 0) return 0.; + HashMatrix< int, K > *ph = p->pHM( ); + ffassert(ph); + return ph->norm1( ); } -template -Matrice_Creuse* set_H_Eye(Matrice_Creuse *pA,const Eye eye) -{ - int n = eye.n, m=eye.m, nn= min(n,m); - if( init) pA->init(); - pA->resize(n,m); - HashMatrix * pH= pA->pHM(); - - ffassert(pH); - pH->clear(); - pH->resize(n,m,nn); - for(int i=0; i< n; ++i) - (*pH)(i,i)=1.; - return pA; -} -template long Set_BC(Matrice_Creuse * const & pA,KN_ const & bc,double const & tgv) -{ - long nbc=0; - if( pA ==0 && pA->A) return nbc; - MatriceCreuse A = pA->A; - HashMatrix * pH= pA->pHM(); - ffassert(pH); - int n = bc.N(); - KN cbc(n); - for(int i=0; i< n;++i ) - if (bc[i]) - ++nbc,cbc[i] = char(1); - else - cbc[i]=char(0); - pH->SetBC(cbc,tgv); - return nbc; -} -template long Set_BC(Matrice_Creuse * const & pA,KN_ const & bc) -{ return Set_BC(pA,bc,ff_tgv); +template< class R, int Init > +Matrice_Creuse< R > *SetMatrice_Creuse(Matrice_Creuse< R > *p, newpMatrice_Creuse< R > np) { + return np.set(p, Init); } - -template -class SparseMat_Add { public: - typedef typename Matrice_Creuse::HMat HMat; - HMat *phm; - SparseMat_Add(Matrice_Creuse * ff) :phm(ff?ff->pHM():0) {ffassert(phm);} -// void Add(const HashMatrix *PA,R coef=R(1),bool trans=false, I ii00=0,I jj00=0); - SparseMat_Add(const SparseMat_Add & s): phm(s.phm) {} +// Add F.H July 2019 +template< class R > +Matrice_Creuse< R > *InitMatrice_Creuse_nm(Matrice_Creuse< R > *const &p, const long &n, const long &m) { + p->init( ); + HashMatrix< int, R > *phm = new HashMatrix< int, R >((int)n, (int)m, 0, 0); + MatriceCreuse< R > *pmc(phm); + p->A.master(pmc); + return p; +} +template< class R > +Matrice_Creuse< R > *InitMatrice_Creuse_n(Matrice_Creuse< R > *const &p, const long &n) { + p->init( ); + HashMatrix< int, R > *phm = new HashMatrix< int, R >((int)n, (int)n, 0, 0); + MatriceCreuse< R > *pmc(phm); + p->A.master(pmc); + return p; +} + +template< class R, int c > +Matrice_Creuse< R > *AddtoMatrice_Creuse(Matrice_Creuse< R > *p, newpMatrice_Creuse< R > np) { + return np.add(p, double(c)); +} + +template< class K, bool init > +Matrice_Creuse< K > *set_H_Eye(Matrice_Creuse< K > *pA, const Eye eye) { + int n = eye.n, m = eye.m, nn = min(n, m); + if (init) pA->init( ); + pA->resize(n, m); + HashMatrix< int, K > *pH = pA->pHM( ); + + ffassert(pH); + pH->clear( ); + pH->resize(n, m, nn); + for (int i = 0; i < n; ++i) (*pH)(i, i) = 1.; + return pA; +} +template< class K > +long Set_BC(Matrice_Creuse< K > *const &pA, KN_< double > const &bc, double const &tgv) { + long nbc = 0; + if (pA == 0 && pA->A) return nbc; + MatriceCreuse< K > A = pA->A; + HashMatrix< int, K > *pH = pA->pHM( ); + ffassert(pH); + int n = bc.N( ); + KN< char > cbc(n); + for (int i = 0; i < n; ++i) + if (bc[i]) + ++nbc, cbc[i] = char(1); + else + cbc[i] = char(0); + pH->SetBC(cbc, tgv); + return nbc; +} +template< class K > +long Set_BC(Matrice_Creuse< K > *const &pA, KN_< double > const &bc) { + return Set_BC(pA, bc, ff_tgv); +} + +template< class K > +class SparseMat_Add { + public: + typedef typename Matrice_Creuse< K >::HMat HMat; + HMat *phm; + SparseMat_Add(Matrice_Creuse< K > *ff) : phm(ff ? ff->pHM( ) : 0) { ffassert(phm); } + // void Add(const HashMatrix *PA,R coef=R(1),bool trans=false, I ii00=0,I jj00=0); + SparseMat_Add(const SparseMat_Add< K > &s) : phm(s.phm) {} }; /* template @@ -3173,883 +2927,774 @@ SparseMat_Add addMat(SparseMat_Add const &sm,Matrice_Creuse* const &pA) phm->Add(phA); return sm; }*/ -template -SparseMat_Add addMat(SparseMat_Add const &sm,K const & coef,Matrice_Creuse*const & pA,const long & i0,const long & j0) -{ - typedef typename Matrice_Creuse::HMat HMat; - HMat *phm= sm.phm; - HMat *phA= pA->pHM(); - ffassert(phm && phA); - phm->Add(phA,coef,false,i0,j0); - return sm; -} -template -SparseMat_Add addMat(SparseMat_Add const &sm,K const & coef,Matrice_Creuse*const & pA) -{ return addMat(sm,coef,pA,0,0);} - -template -SparseMat_Add addMat(SparseMat_Add const &sm,Matrice_Creuse*const & pA) -{ return addMat(sm,K(1.),pA,0,0);} - -template -SparseMat_Add to_add(Matrice_Creuse * ff){return SparseMat_Add(ff);} -template -R ffpscal(Matrice_Creuse * const & pM, KN_ const & a, KN_ const & b) -{ typedef typename Matrice_Creuse::HMat HMat; - HMat *phm= pM->pHM(); - R s=0; - if( phm) s = phm->pscal(a,b); - return s; -} -template -void AddSparseMat() -{ - SetMatrix_Op::btype = Dcl_Type * >(); - Dcl_Type >(); - Dcl_Type >(); // Add FH oct 2005 - Dcl_Type< map< pair, R> * >(); // Add FH mars 2005 - Dcl_Type< minusMat >(); // Add FJH mars 2007 - Dcl_Type< SparseMat_Add >(); // FH jan 2023 - basicForEachType * t_MC=atype< Matrice_Creuse* >(); - - t_MC->SetTypeLoop(atype< R* >(),atype< long* >(),atype< long* >()); - - basicForEachType * t_MM=atype, R> * >(); - -TheOperators->Add("*", - new OneBinaryOperator::plusAx,Matrice_Creuse*,KN_ > >, - new OneBinaryOperator::plusAtx,Matrice_Creuse_Transpose,KN_ > >, - new OneBinaryOperator::solveAxeqb,Matrice_Creuse_inv,KN_ > > , - new OneBinaryOperator::solveAtxeqb,Matrice_Creuse_inv_trans,KN_ > > - ); - -TheOperators->Add("^", new OneBinaryOperatorA_inv()); -TheOperators->Add("^", new OneBinaryOperatorAt_inv()); - -// matrix new code FH (Houston 2004) - TheOperators->Add("=", - new OneOperator2*,Matrice_Creuse*,newpMatrice_Creuse > (SetMatrice_Creuse ), - new OneOperator2_*,Matrice_Creuse*,const Matrix_Prod,E_F_StackF0F0>(ProdMat), - new OneOperator2_*,Matrice_Creuse*,KN *,E_F_StackF0F0>(DiagMat), - new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse_Transpose,E_F_StackF0F0>(CopyTrans), - new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse*,E_F_StackF0F0>(CopyMat) , - new OneOperator2_*,Matrice_Creuse*,KNM*,E_F_StackF0F0>(MatFull2Sparse) , - new OneOperator2_*,Matrice_Creuse*,list *,bool> > *,E_F_StackF0F0>(CombMat) , - new OneOperatorCode >(), - new OneOperator2*,Matrice_Creuse*,Eye>(set_H_Eye ) - - ); - TheOperators->Add("+=", - new OneOperator2*,Matrice_Creuse*,newpMatrice_Creuse > (AddtoMatrice_Creuse ), - new OneOperator2_*,Matrice_Creuse*,list *,bool> > *,E_F_StackF0F0>(AddCombMat)); - - TheOperators->Add("-=", - new OneOperator2*,Matrice_Creuse*,newpMatrice_Creuse > (AddtoMatrice_Creuse ), - new OneOperator2_*,Matrice_Creuse*,list *,bool> > *,E_F_StackF0F0>(AddCombMat)); - - - - TheOperators->Add("<-", - new OneOperatorCode >(), - new OneOperator2*,Matrice_Creuse*,newpMatrice_Creuse > (SetMatrice_Creuse ), - new OneOperator2_*,Matrice_Creuse*,long > (InitMatrice_Creuse_n ), - new OneOperator3_*,Matrice_Creuse*,long,long > (InitMatrice_Creuse_nm ), - new OneOperator2_*,Matrice_Creuse*,const Matrix_Prod,E_F_StackF0F0>(ProdMat), - new OneOperator2_*,Matrice_Creuse*,KN *,E_F_StackF0F0>(DiagMat) , - new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse_Transpose,E_F_StackF0F0>(CopyTrans), - new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse*,E_F_StackF0F0>(CopyMat) , - new OneOperator2_*,Matrice_Creuse*,KNM*,E_F_StackF0F0>(MatFull2Sparse) , - new OneOperator2_*,Matrice_Creuse*,list *,bool> > *,E_F_StackF0F0>(CombMat), - new OneOperator2*,Matrice_Creuse*,Eye>(set_H_Eye ) - - - ); -TheOperators->Add("*", - new OneBinaryOperator,Matrice_Creuse*,Matrice_Creuse*> >, - new OneBinaryOperator,Matrice_Creuse_Transpose,Matrice_Creuse* > >, - new OneBinaryOperator,Matrice_Creuse_Transpose,Matrice_Creuse_Transpose > >, - new OneBinaryOperator,Matrice_Creuse*,Matrice_Creuse_Transpose > > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > - - ); -TheOperators->Add("+", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > - - ); - TheOperators->Add("-", - new OneBinaryOperator >, // (L) - (L) - new OneBinaryOperator >, // L - M - new OneBinaryOperator >, // M - L - new OneBinaryOperator > // M - M - - ); - TheOperators->Add("-", - new OneUnaryOperator > - ); -TheOperators->Add("+", - new OneUnaryOperator > - ); - - Add *>("COO",".",new OneOperator1 *>(set_mat_COO) ); - Add *>("CSR",".",new OneOperator1 *>(set_mat_CSR) ); - Add *>("CSC",".",new OneOperator1 *>(set_mat_CSC) ); - Add *>("n",".",new OneOperator1 *>(get_mat_n) ); - Add *>("m",".",new OneOperator1 *>(get_mat_m) ); - Add *>("nbcoef",".",new OneOperator1 *>(get_mat_nbcoef) ); - Add *>("nnz",".",new OneOperator1 *>(get_mat_nbcoef) ); - Add *>("half",".",new OneOperator1 *>(get_mat_half) ); - Add *>("size",".",new OneOperator1 *>(get_mat_nbcoef) ); - Add *>("trace",".",new OneOperator1* >(get_trace_mat) ); - Add *>("clear",".",new OneOperator1* >(clear_mat) ); - - Add *>("diag",".",new OneOperator1 ,Matrice_Creuse *>(thediag) ); - Add *>("coef",".",new OneOperator1 ,Matrice_Creuse *>(thecoef) ); - - TheOperators->Add("=", new OneOperator2*,KN*,TheDiagMat >(get_mat_daig) ); - - TheOperators->Add("<-", new OneOperator2*,KN*,TheDiagMat >(init_get_mat_daig) ); - TheOperators->Add("=", new OneOperator2,TheDiagMat,KN*>(set_mat_daig) ); - -// ADD oct 2005 - TheOperators->Add("=", new OneOperator2*,KN*,TheCoefMat >(get_mat_coef) ); - TheOperators->Add("=", new OneOperator2,TheCoefMat,KN*>(set_mat_coef) ); - TheOperators->Add("=", new OneOperator2,TheCoefMat,R>(set_mat_coef) ); - - Global.Add("set","(",new SetMatrix); - Global.Add("setBC","(",new OneOperator3_ *,KN_,double>(Set_BC)); - Global.Add("setBC","(",new OneOperator2_ *,KN_>(Set_BC)); - Add *>("linfty",".",new OneOperator1 *>(get_norme_linfty)); - Add *>("l2",".",new OneOperator1 *>(get_norme_l2)); - Add *>("l1",".",new OneOperator1 *>(get_norme_l1)); - atype * >()->Add("(","",new OneOperator3_ *,long,long >(1,get_elementp2mc)); - - atype * >()->Add("[","",new OneOperator3_ *,long,long >(10,get_element2mc)); - -// typedef map< pair, R> MAPMAT; - typedef Matrice_Creuse * MAPMATC; - typedef newpMatrice_Creuse MAPMATN; - atype*>()->Add("(","",new OneOperator3s_*,Inv_KN_long,Inv_KN_long >(Matrixfull2mapIJ_inv)); - atype*>()->Add("(","",new OneOperator3s_*,KN_,KN_ >(Matrixfull2mapIJ)); - - atype*>()->Add("(","",new OneOperator3s_*,Inv_KN_long,Inv_KN_long >(Matrixoutp2mapIJ_inv)); - atype*>()->Add("(","",new OneOperator3s_*,KN_,KN_ >(Matrixoutp2mapIJ)); - - - TheOperators->Add("=", new SetRawMatformMat); - - - - t_MM->Add("(","",new OneOperator3s_(Matrixmapp2mapIJ1)); - t_MM->Add("(","",new OneOperator3s_,KN_ >(Matrixmapp2mapIJ)); - - t_MC->Add("(","",new OneOperator3s_(Matrixmapp2mapIJ1,t_MC)); - t_MC->Add("(","",new OneOperator3s_,KN_ >(Matrixmapp2mapIJ,t_MC)); - - map_type[typeid(MAPMATN ).name()]->AddCast( - new E_F1_funcT* >(Matrixfull2map), - new E_F1_funcT* >(Matrixoutp2map) - - ); - - map_type[typeid(list *,bool> > *).name()]->AddCast( - new E_F1_funcT *,bool> > *,Matrice_Creuse* >(M2L3), - new E_F1_funcT *,bool> > *,Matrice_Creuse_Transpose >(tM2L3), - new E_F1_funcT *,bool> > *,minusMat >(mM2L3 ) - ); - - - TheOperators->Add("{}",new ForAllLoop >); - // remove 2 plugin thresholding and symmetrizeCSR - typedef Thresholding TMR; - typedef Matrice_Creuse MR; - Dcl_Type(); - TMR t(0); - //thresholding2(t, 0.); - Add("thresholding", ".", new OneOperator1(to_Thresholding)); - Add("(", "", new OneOperator2_(thresholding2)); - Global.Add("symmetrizeCSR", "(", new OneOperator1_ *>(symmetrizeCSR )); - Global.Add("pscal","(",new OneOperator3_ *,KN_ ,KN_> (ffpscal)); - Add("add", ".", new OneOperator1, MR *>(to_add)); - Add>("(","", new OneOperator2_,SparseMat_Add,MR*>(addMat) - , new OneOperator3_,SparseMat_Add,R,MR*>(addMat) - , new OneOperator5_,SparseMat_Add,R,MR*,long,long>(addMat)); - -// --- end ADD - -} - -extern int lineno(); -class PrintErrorCompile : public OneOperator { - public: - const char * cmm; - E_F0 * code(const basicAC_F0 & ) const - { ErrorCompile(cmm,lineno()); - return 0;} - PrintErrorCompile(const char * cc): OneOperator(map_type[typeid(R).name()]),cmm(cc){} - +template< class K > +SparseMat_Add< K > addMat(SparseMat_Add< K > const &sm, K const &coef, Matrice_Creuse< K > *const &pA, const long &i0, const long &j0) { + typedef typename Matrice_Creuse< K >::HMat HMat; + HMat *phm = sm.phm; + HMat *phA = pA->pHM( ); + ffassert(phm && phA); + phm->Add(phA, coef, false, i0, j0); + return sm; +} +template< class K > +SparseMat_Add< K > addMat(SparseMat_Add< K > const &sm, K const &coef, Matrice_Creuse< K > *const &pA) { + return addMat(sm, coef, pA, 0, 0); +} + +template< class K > +SparseMat_Add< K > addMat(SparseMat_Add< K > const &sm, Matrice_Creuse< K > *const &pA) { + return addMat(sm, K(1.), pA, 0, 0); +} + +template< class R > +SparseMat_Add< R > to_add(Matrice_Creuse< R > *ff) { + return SparseMat_Add< R >(ff); +} +template< class R > +R ffpscal(Matrice_Creuse< R > *const &pM, KN_< R > const &a, KN_< R > const &b) { + typedef typename Matrice_Creuse< R >::HMat HMat; + HMat *phm = pM->pHM( ); + R s = 0; + if (phm) s = phm->pscal(a, b); + return s; +} +template< class R > +void AddSparseMat( ) { + SetMatrix_Op< R >::btype = Dcl_Type< const SetMatrix_Op< R > * >( ); + Dcl_Type< TheDiagMat< R > >( ); + Dcl_Type< TheCoefMat< R > >( ); // Add FH oct 2005 + Dcl_Type< map< pair< int, int >, R > * >( ); // Add FH mars 2005 + Dcl_Type< minusMat< R > >( ); // Add FJH mars 2007 + Dcl_Type< SparseMat_Add< R > >( ); // FH jan 2023 + basicForEachType *t_MC = atype< Matrice_Creuse< R > * >( ); + + t_MC->SetTypeLoop(atype< R * >( ), atype< long * >( ), atype< long * >( )); + + basicForEachType *t_MM = atype< map< pair< int, int >, R > * >( ); + + TheOperators->Add("*", new OneBinaryOperator< Op2_mulvirtAv< typename RNM_VirtualMatrix< R >::plusAx, Matrice_Creuse< R > *, KN_< R > > >, + new OneBinaryOperator< Op2_mulvirtAv< typename RNM_VirtualMatrix< R >::plusAtx, Matrice_Creuse_Transpose< R >, KN_< R > > >, + new OneBinaryOperator< Op2_mulvirtAv< typename RNM_VirtualMatrix< R >::solveAxeqb, Matrice_Creuse_inv< R >, KN_< R > > >, + new OneBinaryOperator< Op2_mulvirtAv< typename RNM_VirtualMatrix< R >::solveAtxeqb, Matrice_Creuse_inv_trans< R >, KN_< R > > >); + + TheOperators->Add("^", new OneBinaryOperatorA_inv< R >( )); + TheOperators->Add("^", new OneBinaryOperatorAt_inv< R >( )); + + // matrix new code FH (Houston 2004) + TheOperators->Add("=", new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, newpMatrice_Creuse< R > >(SetMatrice_Creuse< R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const Matrix_Prod< R, R >, E_F_StackF0F0 >(ProdMat< R, R, R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, KN< R > *, E_F_StackF0F0 >(DiagMat< R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse_Transpose< R >, E_F_StackF0F0 >(CopyTrans< R, R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse< R > *, E_F_StackF0F0 >(CopyMat< R, R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, KNM< R > *, E_F_StackF0F0 >(MatFull2Sparse< R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, list< tuple< R, MatriceCreuse< R > *, bool > > *, E_F_StackF0F0 >(CombMat< R, 1 >), + new OneOperatorCode< BlockMatrix1< R > >( ), new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Eye >(set_H_Eye< R, false >) + + ); + TheOperators->Add("+=", new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, newpMatrice_Creuse< R > >(AddtoMatrice_Creuse< R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, list< tuple< R, MatriceCreuse< R > *, bool > > *, E_F_StackF0F0 >(AddCombMat< R, 1 >)); + + TheOperators->Add("-=", new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, newpMatrice_Creuse< R > >(AddtoMatrice_Creuse< R, -1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, list< tuple< R, MatriceCreuse< R > *, bool > > *, E_F_StackF0F0 >(AddCombMat< R, -1 >)); + + TheOperators->Add("<-", new OneOperatorCode< BlockMatrix< R > >( ), new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, newpMatrice_Creuse< R > >(SetMatrice_Creuse< R, 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, long >(InitMatrice_Creuse_n< R >), + new OneOperator3_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, long, long >(InitMatrice_Creuse_nm< R >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const Matrix_Prod< R, R >, E_F_StackF0F0 >(ProdMat< R, R, R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, KN< R > *, E_F_StackF0F0 >(DiagMat< R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse_Transpose< R >, E_F_StackF0F0 >(CopyTrans< R, R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Matrice_Creuse< R > *, E_F_StackF0F0 >(CopyMat< R, R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, KNM< R > *, E_F_StackF0F0 >(MatFull2Sparse< R, 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, list< tuple< R, MatriceCreuse< R > *, bool > > *, E_F_StackF0F0 >(CombMat< R, 0 >), + new OneOperator2< Matrice_Creuse< R > *, Matrice_Creuse< R > *, Eye >(set_H_Eye< R, true >) + + ); + TheOperators->Add("*", new OneBinaryOperator< Op2_pair< Matrix_Prod< R, R >, Matrice_Creuse< R > *, Matrice_Creuse< R > * > >, + new OneBinaryOperator< Op2_pair< Matrix_Prod< R, R >, Matrice_Creuse_Transpose< R >, Matrice_Creuse< R > * > >, + new OneBinaryOperator< Op2_pair< Matrix_Prod< R, R >, Matrice_Creuse_Transpose< R >, Matrice_Creuse_Transpose< R > > >, + new OneBinaryOperator< Op2_pair< Matrix_Prod< R, R >, Matrice_Creuse< R > *, Matrice_Creuse_Transpose< R > > >, new OneBinaryOperator< Op2_ListCM< R > >, + new OneBinaryOperator< Op2_ListMC< R > >, new OneBinaryOperator< Op2_ListCMt< R > >, new OneBinaryOperator< Op2_ListMtC< R > > + + ); + TheOperators->Add( + "+", new OneBinaryOperator< Op2_ListCMCMadd< R > >, new OneBinaryOperator< Op2_ListCMMadd< R > >, new OneBinaryOperator< Op2_ListMCMadd< R > >, new OneBinaryOperator< Op2_ListMMadd< R > > + + ); + TheOperators->Add("-", + new OneBinaryOperator< Op2_ListCMCMsub< R > >, // (L) - (L) + new OneBinaryOperator< Op2_ListCMMadd< R, -1 > >, // L - M + new OneBinaryOperator< Op2_ListMCMadd< R, -1 > >, // M - L + new OneBinaryOperator< Op2_ListMMadd< R, -1 > > // M - M + + ); + TheOperators->Add("-", new OneUnaryOperator< Op1_LCMd< R, -1 > >); + TheOperators->Add("+", new OneUnaryOperator< Op1_LCMd< R, 1 > >); + + Add< Matrice_Creuse< R > * >("COO", ".", new OneOperator1< bool, Matrice_Creuse< R > * >(set_mat_COO< R >)); + Add< Matrice_Creuse< R > * >("CSR", ".", new OneOperator1< bool, Matrice_Creuse< R > * >(set_mat_CSR< R >)); + Add< Matrice_Creuse< R > * >("CSC", ".", new OneOperator1< bool, Matrice_Creuse< R > * >(set_mat_CSC< R >)); + Add< Matrice_Creuse< R > * >("n", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_n< R >)); + Add< Matrice_Creuse< R > * >("m", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_m< R >)); + Add< Matrice_Creuse< R > * >("nbcoef", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_nbcoef< R >)); + Add< Matrice_Creuse< R > * >("nnz", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_nbcoef< R >)); + Add< Matrice_Creuse< R > * >("half", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_half< R >)); + Add< Matrice_Creuse< R > * >("size", ".", new OneOperator1< long, Matrice_Creuse< R > * >(get_mat_nbcoef< R >)); + Add< Matrice_Creuse< R > * >("trace", ".", new OneOperator1< R, Matrice_Creuse< R > * >(get_trace_mat< R >)); + Add< Matrice_Creuse< R > * >("clear", ".", new OneOperator1< bool, Matrice_Creuse< R > * >(clear_mat< R >)); + + Add< Matrice_Creuse< R > * >("diag", ".", new OneOperator1< TheDiagMat< R >, Matrice_Creuse< R > * >(thediag< R >)); + Add< Matrice_Creuse< R > * >("coef", ".", new OneOperator1< TheCoefMat< R >, Matrice_Creuse< R > * >(thecoef< R >)); + + TheOperators->Add("=", new OneOperator2< KN< R > *, KN< R > *, TheDiagMat< R > >(get_mat_daig< R >)); + + TheOperators->Add("<-", new OneOperator2< KN< R > *, KN< R > *, TheDiagMat< R > >(init_get_mat_daig< R >)); + TheOperators->Add("=", new OneOperator2< TheDiagMat< R >, TheDiagMat< R >, KN< R > * >(set_mat_daig< R >)); + + // ADD oct 2005 + TheOperators->Add("=", new OneOperator2< KN< R > *, KN< R > *, TheCoefMat< R > >(get_mat_coef< R >)); + TheOperators->Add("=", new OneOperator2< TheCoefMat< R >, TheCoefMat< R >, KN< R > * >(set_mat_coef< R >)); + TheOperators->Add("=", new OneOperator2< TheCoefMat< R >, TheCoefMat< R >, R >(set_mat_coef< R >)); + + Global.Add("set", "(", new SetMatrix< R >); + Global.Add("setBC", "(", new OneOperator3_< long, Matrice_Creuse< R > *, KN_< double >, double >(Set_BC)); + Global.Add("setBC", "(", new OneOperator2_< long, Matrice_Creuse< R > *, KN_< double > >(Set_BC)); + Add< Matrice_Creuse< R > * >("linfty", ".", new OneOperator1< double, Matrice_Creuse< R > * >(get_norme_linfty)); + Add< Matrice_Creuse< R > * >("l2", ".", new OneOperator1< double, Matrice_Creuse< R > * >(get_norme_l2)); + Add< Matrice_Creuse< R > * >("l1", ".", new OneOperator1< double, Matrice_Creuse< R > * >(get_norme_l1)); + atype< Matrice_Creuse< R > * >( )->Add("(", "", new OneOperator3_< R *, Matrice_Creuse< R > *, long, long >(1, get_elementp2mc< R >)); + + atype< Matrice_Creuse< R > * >( )->Add("[", "", new OneOperator3_< R, Matrice_Creuse< R > *, long, long >(10, get_element2mc< R >)); + + // typedef map< pair, R> MAPMAT; + typedef Matrice_Creuse< R > *MAPMATC; + typedef newpMatrice_Creuse< R > MAPMATN; + atype< KNM< R > * >( )->Add("(", "", new OneOperator3s_< MAPMATN, KNM< R > *, Inv_KN_long, Inv_KN_long >(Matrixfull2mapIJ_inv< R >)); + atype< KNM< R > * >( )->Add("(", "", new OneOperator3s_< MAPMATN, KNM< R > *, KN_< long >, KN_< long > >(Matrixfull2mapIJ< R >)); + + atype< outProduct_KN_< R > * >( )->Add("(", "", new OneOperator3s_< MAPMATN, outProduct_KN_< R > *, Inv_KN_long, Inv_KN_long >(Matrixoutp2mapIJ_inv< R >)); + atype< outProduct_KN_< R > * >( )->Add("(", "", new OneOperator3s_< MAPMATN, outProduct_KN_< R > *, KN_< long >, KN_< long > >(Matrixoutp2mapIJ< R >)); + + TheOperators->Add("=", new SetRawMatformMat< R >); + + t_MM->Add("(", "", new OneOperator3s_< MAPMATN, MAPMATC, Inv_KN_long, Inv_KN_long >(Matrixmapp2mapIJ1< R >)); + t_MM->Add("(", "", new OneOperator3s_< MAPMATN, MAPMATC, KN_< long >, KN_< long > >(Matrixmapp2mapIJ< R >)); + + t_MC->Add("(", "", new OneOperator3s_< MAPMATN, MAPMATC, Inv_KN_long, Inv_KN_long >(Matrixmapp2mapIJ1< R >, t_MC)); + t_MC->Add("(", "", new OneOperator3s_< MAPMATN, MAPMATC, KN_< long >, KN_< long > >(Matrixmapp2mapIJ< R >, t_MC)); + + map_type[typeid(MAPMATN).name( )]->AddCast(new E_F1_funcT< MAPMATN, KNM< R > * >(Matrixfull2map< R >), new E_F1_funcT< MAPMATN, outProduct_KN_< R > * >(Matrixoutp2map< R >) + + ); + + map_type[typeid(list< tuple< R, MatriceCreuse< R > *, bool > > *).name( )]->AddCast(new E_F1_funcT< list< tuple< R, MatriceCreuse< R > *, bool > > *, Matrice_Creuse< R > * >(M2L3< R >), + new E_F1_funcT< list< tuple< R, MatriceCreuse< R > *, bool > > *, Matrice_Creuse_Transpose< R > >(tM2L3< R >), + new E_F1_funcT< list< tuple< R, MatriceCreuse< R > *, bool > > *, minusMat< R > >(mM2L3< R >)); + + TheOperators->Add("{}", new ForAllLoop< E_ForAllLoopMatrix< R > >); + // remove 2 plugin thresholding and symmetrizeCSR + typedef Thresholding< R > TMR; + typedef Matrice_Creuse< R > MR; + Dcl_Type< TMR >( ); + TMR t(0); + // thresholding2(t, 0.); + Add< MR * >("thresholding", ".", new OneOperator1< TMR, MR * >(to_Thresholding)); + Add< TMR >("(", "", new OneOperator2_< MR *, TMR, double >(thresholding2)); + Global.Add("symmetrizeCSR", "(", new OneOperator1_< long, Matrice_Creuse< R > * >(symmetrizeCSR< R >)); + Global.Add("pscal", "(", new OneOperator3_< R, Matrice_Creuse< R > *, KN_< R >, KN_< R > >(ffpscal)); + Add< MR * >("add", ".", new OneOperator1< SparseMat_Add< R >, MR * >(to_add)); + Add< SparseMat_Add< R > >("(", "", new OneOperator2_< SparseMat_Add< R >, SparseMat_Add< R >, MR * >(addMat< R >), new OneOperator3_< SparseMat_Add< R >, SparseMat_Add< R >, R, MR * >(addMat), + new OneOperator5_< SparseMat_Add< R >, SparseMat_Add< R >, R, MR *, long, long >(addMat)); + + // --- end ADD +} + +extern int lineno( ); +class PrintErrorCompile : public OneOperator { + public: + const char *cmm; + E_F0 *code(const basicAC_F0 &) const { + ErrorCompile(cmm, lineno( )); + return 0; + } + PrintErrorCompile(const char *cc) : OneOperator(map_type[typeid(R).name( )]), cmm(cc) {} }; -class PrintErrorCompileIM : public E_F0info { public: - typedef double Result; - static E_F0 * f(const basicAC_F0 & args) - { - lgerror("\n\n *** change interplotematrix in interpole.\n *** Bad name in previous version,\n *** sorry FH.\n\n"); - return 0; } - static ArrayOfaType typeargs() {return ArrayOfaType(true);} - operator aType () const { return atype();} - +class PrintErrorCompileIM : public E_F0info { + public: + typedef double Result; + static E_F0 *f(const basicAC_F0 &args) { + lgerror("\n\n *** change interplotematrix in interpole.\n *** Bad name in previous version,\n *** sorry FH.\n\n"); + return 0; + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(true); } + operator aType( ) const { return atype< double >( ); } }; -template +template< class T > class removeDOF_Op : public E_F0mps { -public: - Expression eA; - Expression eR; - Expression ex; - Expression eout; - bool transpose; - static const int n_name_param = 4; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - removeDOF_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3, Expression param4) - : eA(param1), eR(param2), ex(param3), eout(param4), transpose(false) { - args.SetNameParam(n_name_param, name_param, nargs); - } - removeDOF_Op(const basicAC_F0& args, Expression param2, Expression param3, Expression param4, bool t, int) - : eA(0), eR(param2), ex(param3), eout(param4), transpose(t) { - args.SetNameParam(n_name_param, name_param, nargs); - } - removeDOF_Op(const basicAC_F0& args, Expression param1, Expression param2) - : eA(param1), eR(param2), ex(0), eout(0), transpose(false) { - args.SetNameParam(n_name_param, name_param, nargs); - } + public: + Expression eA; + Expression eR; + Expression ex; + Expression eout; + bool transpose; + static const int n_name_param = 4; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + removeDOF_Op(const basicAC_F0 &args, Expression param1, Expression param2, Expression param3, Expression param4) : eA(param1), eR(param2), ex(param3), eout(param4), transpose(false) { + args.SetNameParam(n_name_param, name_param, nargs); + } + removeDOF_Op(const basicAC_F0 &args, Expression param2, Expression param3, Expression param4, bool t, int) : eA(0), eR(param2), ex(param3), eout(param4), transpose(t) { + args.SetNameParam(n_name_param, name_param, nargs); + } + removeDOF_Op(const basicAC_F0 &args, Expression param1, Expression param2) : eA(param1), eR(param2), ex(0), eout(0), transpose(false) { args.SetNameParam(n_name_param, name_param, nargs); } - AnyType operator()(Stack stack) const; + AnyType operator( )(Stack stack) const; }; -template -basicAC_F0::name_and_type removeDOF_Op::name_param[] = { - {"symmetrize", &typeid(bool)}, - {"condensation", &typeid(KN*)}, - {"R", &typeid(Matrice_Creuse*)}, - {"eps",&typeid(double)} -}; +template< class T > +basicAC_F0::name_and_type removeDOF_Op< T >::name_param[] = { + {"symmetrize", &typeid(bool)}, {"condensation", &typeid(KN< long > *)}, {"R", &typeid(Matrice_Creuse< double > *)}, {"eps", &typeid(double)}}; -template +template< class T > class removeDOF : public OneOperator { - const unsigned short withA; -public: - removeDOF() : OneOperator(atype(), atype*>(), atype*>(), atype*>(), atype*>()),withA(1) {} - removeDOF(int) : OneOperator(atype(), atype*>(), atype*>(), atype*>()),withA(0) {} - removeDOF(int, int) : OneOperator(atype(), atype*>(), atype*>()),withA(2) {} - removeDOF(int, int, int) : OneOperator(atype(), atype>(), atype*>(), atype*>()),withA(3) {} - - E_F0* code(const basicAC_F0& args) const { - if(withA == 1) - return new removeDOF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); - else if(withA == 0 || withA == 3) - return new removeDOF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), withA == 3, 1); - else - return new removeDOF_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } -}; -template bool cmp(const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; } -template -AnyType removeDOF_Op::operator()(Stack stack) const { - - static const double defEPS=1e-12; - typedef double R; - // code wri-ng no ... - Matrice_Creuse* pA = eA ? GetAny* >((*eA)(stack)):0; - Matrice_Creuse* pR; - if(transpose) { - Matrice_Creuse_Transpose tpR = GetAny>((*eR)(stack)); - pR = tpR; - } + const unsigned short withA; + + public: + removeDOF( ) : OneOperator(atype< long >( ), atype< Matrice_Creuse< T > * >( ), atype< Matrice_Creuse< double > * >( ), atype< KN< T > * >( ), atype< KN< T > * >( )), withA(1) {} + removeDOF(int) : OneOperator(atype< long >( ), atype< Matrice_Creuse< double > * >( ), atype< KN< T > * >( ), atype< KN< T > * >( )), withA(0) {} + removeDOF(int, int) : OneOperator(atype< long >( ), atype< Matrice_Creuse< T > * >( ), atype< Matrice_Creuse< double > * >( )), withA(2) {} + removeDOF(int, int, int) : OneOperator(atype< long >( ), atype< Matrice_Creuse_Transpose< double > >( ), atype< KN< T > * >( ), atype< KN< T > * >( )), withA(3) {} + + E_F0 *code(const basicAC_F0 &args) const { + if (withA == 1) + return new removeDOF_Op< T >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + else if (withA == 0 || withA == 3) + return new removeDOF_Op< T >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), withA == 3, 1); else - pR = GetAny*>((*eR)(stack)); - KN* pX = ex ? GetAny* >((*ex)(stack)) : 0; - KN* pOut = eout ? GetAny* >((*eout)(stack)) : 0; - Matrice_Creuse* pC = nargs[2] ? GetAny*>((*nargs[2])(stack)) : 0; - MatriceMorse *mC = 0; - if(pC && pC->A) { - mC = static_cast*>(&(*pC->A)); - } - ffassert(pR); - bool rhs = (pX && pOut) && (pOut->n > 0 || pX->n > 0); - if(pA) - { - if(!pC) - pC = pR; - MatriceMorse *mA = pA->pHM(); - MatriceMorse *mR = pR->pHM(); - if(!mC) - mC = mR; - pA->Uh = pR->Uh; - pA->Vh = pC->Vh; - - bool symmetrize = nargs[0] ? GetAny((*nargs[0])(stack)) : false; - double EPS=nargs[3] ? GetAny((*nargs[3])(stack)) :defEPS ; - KN* condensation = nargs[1] ? GetAny* >((*nargs[1])(stack)) : (KN*) 0; - ffassert(condensation ||( mR && mC) ); - unsigned int n = condensation ? condensation->n : mR->nnz; - unsigned int m = condensation ? condensation->n : mC->nnz; - KN lg(n+1,0); - - if(rhs && pOut->n != n) pOut->resize(n); - mC->COO(); - mR->COO(); - mA->CSR(); - std::vector tmpVec; - if(!condensation) - { - tmpVec.resize(mA->m); - for(long i = 0; i < m; ++i) - tmpVec[mC->j[i]] = i + 1; - if(!mA->half) { - std::vector > tmp; - tmp.reserve(mA->nnz); - - lg[0] = 0; - for(long i = 0; i < n; ++i) { - for(long j = mA->p[mR->j[i]]; j < mA->p[mR->j[i] + 1]; ++j) { - long col = tmpVec[mA->j[j]]; - if(col != 0 && abs(mA->aij[j]) > EPS) { - if(symmetrize) { - if(col - 1 <= i) - tmp.push_back(std::make_pair(col - 1, mA->aij[j])); - } - else - tmp.push_back(std::make_pair(col - 1, mA->aij[j])); - - } - } - std::sort(tmp.begin() + lg[i], tmp.end(),cmp ); - // c++11 , [](const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; }); - if(rhs) - *(*pOut + i) = *(*pX + mC->j[i]); - lg[i + 1] = tmp.size(); - } - mA->clear(); - mA->resize(n,m); - MatriceMorse &A = *mA; - A.half = symmetrize; - for(int i=0; iHalf - else { - std::vector > > tmp(n); - for(unsigned int i = 0; i < n; ++i) - tmp[i].reserve(mA->p[mR->j[i] + 1] - mA->p[mR->j[i]]); - - unsigned int nnz = 0; - for(unsigned int i = 0; i < n; ++i) { - for(unsigned int j = mA->p[mR->j[i]]; j < mA->p[mR->j[i] + 1]; ++j) { - unsigned int col = tmpVec[mA->j[j]]; - if(col != 0 && abs(mA->aij[j]) > EPS) { - if(i < col - 1) - tmp[col - 1].push_back(make_pair(i, mA->aij[j])); - else - tmp[i].push_back(make_pair(col - 1, mA->aij[j])); - ++nnz; - } - } - if(rhs) - *(*pOut + i) = *(*pX + mC->j[i]); - } - int Half = mA->half; - mA->clear(); - mA->resize(n,m,nnz); - MatriceMorse &A = *mA; - A.half = Half; - for(unsigned int i = 0; i < n; ++i) { - std::sort(tmp[i].begin(), tmp[i].end(),cmp); - // c++11, [](const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; }); - for(typename std::vector >::const_iterator it = tmp[i].begin(); it != tmp[i].end(); ++it) - A(i,it->first) =it->second; - - } - + return new removeDOF_Op< T >(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); + } +}; +template< class T > +bool cmp(const std::pair< unsigned int, T > &lhs, const std::pair< unsigned int, T > &rhs) { + return lhs.first < rhs.first; +} +template< class T > +AnyType removeDOF_Op< T >::operator( )(Stack stack) const { + + static const double defEPS = 1e-12; + typedef double R; + // code wri-ng no ... + Matrice_Creuse< T > *pA = eA ? GetAny< Matrice_Creuse< T > * >((*eA)(stack)) : 0; + Matrice_Creuse< R > *pR; + if (transpose) { + Matrice_Creuse_Transpose< R > tpR = GetAny< Matrice_Creuse_Transpose< R > >((*eR)(stack)); + pR = tpR; + } else + pR = GetAny< Matrice_Creuse< R > * >((*eR)(stack)); + KN< T > *pX = ex ? GetAny< KN< T > * >((*ex)(stack)) : 0; + KN< T > *pOut = eout ? GetAny< KN< T > * >((*eout)(stack)) : 0; + Matrice_Creuse< R > *pC = nargs[2] ? GetAny< Matrice_Creuse< R > * >((*nargs[2])(stack)) : 0; + MatriceMorse< R > *mC = 0; + if (pC && pC->A) { + mC = static_cast< MatriceMorse< R > * >(&(*pC->A)); + } + ffassert(pR); + bool rhs = (pX && pOut) && (pOut->n > 0 || pX->n > 0); + if (pA) { + if (!pC) pC = pR; + MatriceMorse< T > *mA = pA->pHM( ); + MatriceMorse< R > *mR = pR->pHM( ); + if (!mC) mC = mR; + pA->Uh = pR->Uh; + pA->Vh = pC->Vh; + + bool symmetrize = nargs[0] ? GetAny< bool >((*nargs[0])(stack)) : false; + double EPS = nargs[3] ? GetAny< double >((*nargs[3])(stack)) : defEPS; + KN< long > *condensation = nargs[1] ? GetAny< KN< long > * >((*nargs[1])(stack)) : (KN< long > *)0; + ffassert(condensation || (mR && mC)); + unsigned int n = condensation ? condensation->n : mR->nnz; + unsigned int m = condensation ? condensation->n : mC->nnz; + KN< int > lg(n + 1, 0); + + if (rhs && pOut->n != n) pOut->resize(n); + mC->COO( ); + mR->COO( ); + mA->CSR( ); + std::vector< signed int > tmpVec; + if (!condensation) { + tmpVec.resize(mA->m); + for (long i = 0; i < m; ++i) tmpVec[mC->j[i]] = i + 1; + if (!mA->half) { + std::vector< std::pair< int, T > > tmp; + tmp.reserve(mA->nnz); + + lg[0] = 0; + for (long i = 0; i < n; ++i) { + for (long j = mA->p[mR->j[i]]; j < mA->p[mR->j[i] + 1]; ++j) { + long col = tmpVec[mA->j[j]]; + if (col != 0 && abs(mA->aij[j]) > EPS) { + if (symmetrize) { + if (col - 1 <= i) tmp.push_back(std::make_pair(col - 1, mA->aij[j])); + } else + tmp.push_back(std::make_pair(col - 1, mA->aij[j])); } + } + std::sort(tmp.begin( ) + lg[i], tmp.end( ), cmp< T >); + // c++11 , [](const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; }); + if (rhs) *(*pOut + i) = *(*pX + mC->j[i]); + lg[i + 1] = tmp.size( ); + } + mA->clear( ); + mA->resize(n, m); + MatriceMorse< T > &A = *mA; + A.half = symmetrize; + for (int i = 0; i < n; ++i) { + for (int k = lg[i]; k < lg[i + 1]; ++k) { + int j = tmp[k].first; + T aij = tmp[k].second; + A(i, j) = aij; + } } - else - { - tmpVec.reserve(mA->n); - unsigned int i = 0, j = 1; - for(unsigned int k = 0; k < mA->n; ++k) { - if(k == *(*condensation + i)) { - ++i; - tmpVec.push_back(i); - } - else { - tmpVec.push_back(-j); - ++j; - } - + } // !mA->Half + else { + std::vector< std::vector< std::pair< unsigned int, T > > > tmp(n); + for (unsigned int i = 0; i < n; ++i) tmp[i].reserve(mA->p[mR->j[i] + 1] - mA->p[mR->j[i]]); + + unsigned int nnz = 0; + for (unsigned int i = 0; i < n; ++i) { + for (unsigned int j = mA->p[mR->j[i]]; j < mA->p[mR->j[i] + 1]; ++j) { + unsigned int col = tmpVec[mA->j[j]]; + if (col != 0 && abs(mA->aij[j]) > EPS) { + if (i < col - 1) + tmp[col - 1].push_back(make_pair(i, mA->aij[j])); + else + tmp[i].push_back(make_pair(col - 1, mA->aij[j])); + ++nnz; } + } + if (rhs) *(*pOut + i) = *(*pX + mC->j[i]); + } + int Half = mA->half; + mA->clear( ); + mA->resize(n, m, nnz); + MatriceMorse< T > &A = *mA; + A.half = Half; + for (unsigned int i = 0; i < n; ++i) { + std::sort(tmp[i].begin( ), tmp[i].end( ), cmp< T >); + // c++11, [](const std::pair& lhs, const std::pair& rhs) { return lhs.first < rhs.first; }); + for (typename std::vector< std::pair< unsigned int, T > >::const_iterator it = tmp[i].begin( ); it != tmp[i].end( ); ++it) A(i, it->first) = it->second; + } + } + } - std::vector > tmpInterior; - std::vector > tmpBoundary; - std::vector > tmpInteraction; - tmpInterior.reserve(mA->nnz); - tmpBoundary.reserve(mA->nnz); - tmpInteraction.reserve(mA->nnz); - - lg[0] = 0; - for(long i = 0; i < mA->n; ++i) { - int row = tmpVec[i]; - if(row < 0) { - for(unsigned int j = mA->p[i]; j < mA->p[i + 1]; ++j) { - int col = tmpVec[mA->j[j]]; - if(col < 0) - tmpInterior.push_back(make_pair(-col - 1, mA->aij[j])); - else - tmpInteraction.push_back(make_pair(col - 1, mA->aij[j])); - } - - } - else { - for(unsigned int j = mA->p[i]; j < mA->p[i + 1]; ++j) { - int col = tmpVec[mA->j[j]]; - if(col > 0) - tmpBoundary.push_back(make_pair(col - 1, mA->aij[j])); - } - if(rhs) - *(*pOut + i) = *(*pX + *(*condensation + i)); - lg[i + 1] = tmpBoundary.size(); - } - } + else { + tmpVec.reserve(mA->n); + unsigned int i = 0, j = 1; + for (unsigned int k = 0; k < mA->n; ++k) { + if (k == *(*condensation + i)) { + ++i; + tmpVec.push_back(i); + } else { + tmpVec.push_back(-j); + ++j; + } + } - mA->clear(); - mA->resize(n,n); - MatriceMorse &mR = *new MatriceMorse(n,m,tmpBoundary.size(),0); - for(unsigned int i = 0; i < tmpBoundary.size(); ++i) { - mR(i, tmpBoundary[i].first)= tmpBoundary[i].second; - } - ffassert(0); - pR->typemat = 0; //TypeSolveMat(TypeSolveMat::GMRES); - // bug ici ::: FH.. pR->A.master(&mR); + std::vector< std::pair< int, T > > tmpInterior; + std::vector< std::pair< int, T > > tmpBoundary; + std::vector< std::pair< int, T > > tmpInteraction; + tmpInterior.reserve(mA->nnz); + tmpBoundary.reserve(mA->nnz); + tmpInteraction.reserve(mA->nnz); + + lg[0] = 0; + for (long i = 0; i < mA->n; ++i) { + int row = tmpVec[i]; + if (row < 0) { + for (unsigned int j = mA->p[i]; j < mA->p[i + 1]; ++j) { + int col = tmpVec[mA->j[j]]; + if (col < 0) + tmpInterior.push_back(make_pair(-col - 1, mA->aij[j])); + else + tmpInteraction.push_back(make_pair(col - 1, mA->aij[j])); + } + + } else { + for (unsigned int j = mA->p[i]; j < mA->p[i + 1]; ++j) { + int col = tmpVec[mA->j[j]]; + if (col > 0) tmpBoundary.push_back(make_pair(col - 1, mA->aij[j])); + } + if (rhs) *(*pOut + i) = *(*pX + *(*condensation + i)); + lg[i + 1] = tmpBoundary.size( ); } + } + mA->clear( ); + mA->resize(n, n); + MatriceMorse< T > &mR = *new MatriceMorse< T >(n, m, tmpBoundary.size( ), 0); + for (unsigned int i = 0; i < tmpBoundary.size( ); ++i) { + mR(i, tmpBoundary[i].first) = tmpBoundary[i].second; + } + ffassert(0); + pR->typemat = 0; // TypeSolveMat(TypeSolveMat::GMRES); + // bug ici ::: FH.. pR->A.master(&mR); } - else if(rhs) - { - - MatriceMorse *mR = pR->pHM(); - if(mR && mR->n && mR->m) { - mR->COO(); - unsigned int n = mR->nnz; - if(transpose) { - if(pOut->n != mR->m) pOut->resize(mR->m); - *pOut = T(); - for(unsigned int i = 0; i < n; ++i) { - *(*pOut + mR->j[i]) = *(*pX + mR->i[i]); - } + } else if (rhs) { + + MatriceMorse< R > *mR = pR->pHM( ); + if (mR && mR->n && mR->m) { + mR->COO( ); + unsigned int n = mR->nnz; + if (transpose) { + if (pOut->n != mR->m) pOut->resize(mR->m); + *pOut = T( ); + for (unsigned int i = 0; i < n; ++i) { + *(*pOut + mR->j[i]) = *(*pX + mR->i[i]); } - else { - if(pOut->n != n) pOut->resize(n); - for(unsigned int i = 0; i < n; ++i) { - *(*pOut + i) = *(*pX + mR->j[i]); - } + } else { + if (pOut->n != n) pOut->resize(n); + for (unsigned int i = 0; i < n; ++i) { + *(*pOut + i) = *(*pX + mR->j[i]); } - } - else - *pOut = T(); - } - return 0L; + } + } else + *pOut = T( ); + } + return 0L; } - -bool SparseDefault() -{ - return 1;//TypeSolveMat::SparseSolver== TypeSolveMat::defaultvalue; +bool SparseDefault( ) { + return 1; // TypeSolveMat::SparseSolver== TypeSolveMat::defaultvalue; } -bool Have_UMFPACK_=false; -bool Have_UMFPACK() { return Have_UMFPACK_;} +bool Have_UMFPACK_ = false; +bool Have_UMFPACK( ) { return Have_UMFPACK_; } -template -MatriceMorse * removeHalf(MatriceMorse & A,long half,double tol) -{ +template< class R > +MatriceMorse< R > *removeHalf(MatriceMorse< R > &A, long half, double tol) { - // half < 0 => keep U - // half > 0 => keep L - // half = 0 => L and the result will be sym - int nnz =0; + // half < 0 => keep U + // half > 0 => keep L + // half = 0 => L and the result will be sym + int nnz = 0; - if( A.half ) - return new MatriceMorse(A);// copy - // do alloc - MatriceMorse *r=new MatriceMorse(A); - r->RemoveHalf(half,tol); - if(verbosity ) - cout << " removeHalf: new nnz = "<< r->nnz << " "<< r->half << endl; + if (A.half) return new MatriceMorse< R >(A); // copy + // do alloc + MatriceMorse< R > *r = new MatriceMorse< R >(A); + r->RemoveHalf(half, tol); + if (verbosity) cout << " removeHalf: new nnz = " << r->nnz << " " << r->half << endl; - return r; + return r; } - -template - KN > *Matrix2KKN(KN > *pij,Matrice_Creuse * pA,bool trans) - { - ffassert(pij); - if(init) pij->init(); - MatriceCreuse * pa=pA->A; - MatriceMorse *pma= dynamic_cast* > (pa); - if( pma ) { - long n = trans? pma->n:pma->m; - pij->resize(n); - KN > & ij=*pij; - int * pp, *pj; - R * pc; - if( trans) - pma->CSC(pp,pj,pc); - else - pma->CSR(pp,pj,pc); - - for( int i=0; i +KN< KN< long > > *Matrix2KKN(KN< KN< long > > *pij, Matrice_Creuse< R > *pA, bool trans) { + ffassert(pij); + if (init) pij->init( ); + MatriceCreuse< R > *pa = pA->A; + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + if (pma) { + long n = trans ? pma->n : pma->m; + pij->resize(n); + KN< KN< long > > &ij = *pij; + int *pp, *pj; + R *pc; + if (trans) + pma->CSC(pp, pj, pc); + else + pma->CSR(pp, pj, pc); + + for (int i = 0; i < n; ++i) { + long li = pp[i + 1] - pp[i]; + ij[i].resize(li); + long kk = 0; + for (long k = pp[i]; k < pp[i + 1]; ++k) ij[i][kk++] = pj[k]; + } } -template - KN > *Matrix2KKN(KN > *pij,Matrice_Creuse * pA) -{ return Matrix2KKN (pij,pA,false);} -template -KN > *Matrix2KKN(KN > *pij,Matrice_Creuse_Transpose pAt) -{ return Matrix2KKN(pij,pAt,true);} + return pij; +} +template< class R, int init > +KN< KN< long > > *Matrix2KKN(KN< KN< long > > *pij, Matrice_Creuse< R > *pA) { + return Matrix2KKN< R, init >(pij, pA, false); +} +template< class R, int init > +KN< KN< long > > *Matrix2KKN(KN< KN< long > > *pij, Matrice_Creuse_Transpose< R > pAt) { + return Matrix2KKN< R, init >(pij, pAt, true); +} -template -newpMatrice_Creuse removeHalf(Stack stack,Matrice_Creuse *const & pA,long const & half,const double & tol) -{ - MatriceCreuse * pa=pA->A; - MatriceMorse *pma= dynamic_cast* > (pa); - ffassert(pma); - return newpMatrice_Creuse(stack,removeHalf(*pma,half,tol)); +template< class R > +newpMatrice_Creuse< R > removeHalf(Stack stack, Matrice_Creuse< R > *const &pA, long const &half, const double &tol) { + MatriceCreuse< R > *pa = pA->A; + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + ffassert(pma); + return newpMatrice_Creuse< R >(stack, removeHalf(*pma, half, tol)); } -template -bool removeHalf(Stack stack,Matrice_Creuse *const & pR,Matrice_Creuse *const & pA,long const & half,const double & tol) -{ - MatriceCreuse * pa=pA->A; - MatriceMorse *pma= dynamic_cast* > (pa); - MatriceCreuse * pr= removeHalf(*pma,half,tol); +template< class R > +bool removeHalf(Stack stack, Matrice_Creuse< R > *const &pR, Matrice_Creuse< R > *const &pA, long const &half, const double &tol) { + MatriceCreuse< R > *pa = pA->A; + MatriceMorse< R > *pma = dynamic_cast< MatriceMorse< R > * >(pa); + MatriceCreuse< R > *pr = removeHalf(*pma, half, tol); - pR->A.master(pr); - return true; + pR->A.master(pr); + return true; } -template -newpMatrice_Creuse removeHalf(Stack stack,Matrice_Creuse *const & pA,long const & half) -{ - return removeHalf(stack,pA,half,-1.); +template< class R > +newpMatrice_Creuse< R > removeHalf(Stack stack, Matrice_Creuse< R > *const &pA, long const &half) { + return removeHalf(stack, pA, half, -1.); } -template +template< class K > class plotMatrix : public OneOperator { -public: - - class Op : public E_F0info { - public: - Expression a; - - static const int n_name_param = 1; - static basicAC_F0::name_and_type name_param[] ; - Expression nargs[n_name_param]; - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - public: - Op(const basicAC_F0 & args,Expression aa) : a(aa) { - args.SetNameParam(n_name_param,name_param,nargs); - } - - AnyType operator()(Stack stack) const{ - - if (mpirank == 0 && ThePlotStream) { - Matrice_Creuse* A =GetAny* >((*a)(stack)); - bool wait = arg(0,stack,false); - - PlotStream theplot(ThePlotStream); - theplot.SendNewPlot(); - theplot << 3L; - theplot <= wait; - theplot.SendEndArgPlot(); - theplot.SendMeshes(); - theplot << 0L; - theplot.SendPlots(); - theplot << 1L; - theplot << 31L; - - HashMatrix* ph=A->pHM(); - - if (!ph) { - theplot << 0; - theplot << 0; - theplot << 0L; - theplot << 0L; - } - else { - theplot << (int)ph->n; - theplot << (int)ph->m; - theplot << 0L; - theplot << (long)ph->nnz; - - for (int i=0;innz;i++) { - theplot << ph->i[i]; - theplot << ph->j[i]; - theplot << 1; - theplot << 1; - theplot << 1; - theplot << abs(ph->aij[i]); - } - } - - theplot.SendEndPlot(); - - } - - return 0L; - } - }; + public: + class Op : public E_F0info { + public: + Expression a; + + static const int n_name_param = 1; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + public: + Op(const basicAC_F0 &args, Expression aa) : a(aa) { args.SetNameParam(n_name_param, name_param, nargs); } + + AnyType operator( )(Stack stack) const { + + if (mpirank == 0 && ThePlotStream) { + Matrice_Creuse< K > *A = GetAny< Matrice_Creuse< K > * >((*a)(stack)); + bool wait = arg(0, stack, false); + + PlotStream theplot(ThePlotStream); + theplot.SendNewPlot( ); + theplot << 3L; + theplot <= wait; + theplot.SendEndArgPlot( ); + theplot.SendMeshes( ); + theplot << 0L; + theplot.SendPlots( ); + theplot << 1L; + theplot << 31L; + + HashMatrix< int, K > *ph = A->pHM( ); + + if (!ph) { + theplot << 0; + theplot << 0; + theplot << 0L; + theplot << 0L; + } else { + theplot << (int)ph->n; + theplot << (int)ph->m; + theplot << 0L; + theplot << (long)ph->nnz; + + for (int i = 0; i < ph->nnz; i++) { + theplot << ph->i[i]; + theplot << ph->j[i]; + theplot << 1; + theplot << 1; + theplot << 1; + theplot << abs(ph->aij[i]); + } + } - plotMatrix() : OneOperator(atype(),atype*>()) {} + theplot.SendEndPlot( ); + } - E_F0 * code(const basicAC_F0 & args) const - { - return new Op(args,t[0]->CastTo(args[0])); + return 0L; } -}; + }; -template -basicAC_F0::name_and_type plotMatrix::Op::name_param[]= { - { "wait", &typeid(bool)} -}; + plotMatrix( ) : OneOperator(atype< long >( ), atype< Matrice_Creuse< K > * >( )) {} -void init_lgmat() - -{ + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0])); } +}; - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - - map_type_of_map[make_pair(atype* >(),atype())]=atype *>(); - map_type_of_map[make_pair(atype* >(),atype())]=atype *>(); - AddSparseMat(); - AddSparseMat(); - - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - Add::Op *>("<-","(", new MatrixInterpolation); - Add::Op *>("<-","(", new MatrixInterpolation(1,1)); - - - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - Dcl_Type::Op *>(); - - Global.Add("restrict","(",new RestrictArray);// FH Jan 2014 - Global.Add("restrict","(",new RestrictArray);// FH Jan 2014 - Global.Add("restrict","(",new RestrictArray);// PHT Apr 2019 - Global.Add("restrict","(",new RestrictArray); - - TheOperators->Add("=", - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict) - ); - TheOperators->Add("<-", - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict), - new OneOperator2_*,KN*,const RestrictArray::Op*,E_F_StackF0F0>(SetRestrict) - ); - - - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation(1)); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation(1,1)); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation(1,1)); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation(1,1)); - // warning the case MatrixInterpolation (1,1) not use fe2 .. - // so remove case (1,1) to remove ambiguity Polymorphic Find 4 - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - Global.Add("interpolate","(",new MatrixInterpolation); - - Global.Add("interplotematrix","(",new OneOperatorCode); - zzzfff->Add("mapmatrix",atype, double> *>()); - zzzfff->Add("Cmapmatrix",atype, Complex> *>()); // a voir - - Dcl_Type< Resize > > (); - - Add *>("resize",".",new OneOperator1< Resize >,Matrice_Creuse *>(to_Resize)); - Add > >("(","",new OneOperator3_ *,Resize > , long, long >(resize2)); +template< class K > +basicAC_F0::name_and_type plotMatrix< K >::Op::name_param[] = {{"wait", &typeid(bool)}}; + +void init_lgmat( ) + +{ + + Dcl_Type< const MatrixInterpolation< pfes, pfes >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfes3, pfes3 >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesS, pfesS >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesL, pfesL >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesS, pfes3 >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesL, pfes >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesL, pfesS >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesS, pfesL >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfesS, pfes >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfes, pfesL >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfes, pfesS >::Op * >( ); + Dcl_Type< const MatrixInterpolation< pfes, pfes3 >::Op * >( ); + + map_type_of_map[make_pair(atype< Matrice_Creuse< double > * >( ), atype< double * >( ))] = atype< Matrice_Creuse< double > * >( ); + map_type_of_map[make_pair(atype< Matrice_Creuse< double > * >( ), atype< Complex * >( ))] = atype< Matrice_Creuse< Complex > * >( ); + AddSparseMat< double >( ); + AddSparseMat< Complex >( ); + + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfes >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfes >(1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes3, pfes3 >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes3, pfes3 >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfesS >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfesS >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfesL >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfesL >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfes3 >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfes3 >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfes >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfes >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfesS >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesL, pfesS >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfesL >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfesL >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfes >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfesS, pfes >(1, 1)); + + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfesL >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfesL >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfesS >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfesS >(1, 1)); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfes3 >); + Add< const MatrixInterpolation< pfes, pfes >::Op * >("<-", "(", new MatrixInterpolation< pfes, pfes3 >(1, 1)); + + Dcl_Type< const RestrictArray< pfes >::Op * >( ); + Dcl_Type< const RestrictArray< pfes3 >::Op * >( ); + Dcl_Type< const RestrictArray< pfesS >::Op * >( ); + Dcl_Type< const RestrictArray< pfesL >::Op * >( ); + + Global.Add("restrict", "(", new RestrictArray< pfes >); // FH Jan 2014 + Global.Add("restrict", "(", new RestrictArray< pfes3 >); // FH Jan 2014 + Global.Add("restrict", "(", new RestrictArray< pfesS >); // PHT Apr 2019 + Global.Add("restrict", "(", new RestrictArray< pfesL >); + + TheOperators->Add("=", new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfes >::Op *, E_F_StackF0F0 >(SetRestrict< pfes, 1 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfes3 >::Op *, E_F_StackF0F0 >(SetRestrict< pfes3, 1 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfesS >::Op *, E_F_StackF0F0 >(SetRestrict< pfesS, 1 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfesL >::Op *, E_F_StackF0F0 >(SetRestrict< pfesL, 1 >)); + TheOperators->Add("<-", new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfes >::Op *, E_F_StackF0F0 >(SetRestrict< pfes, 0 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfes3 >::Op *, E_F_StackF0F0 >(SetRestrict< pfes3, 0 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfesS >::Op *, E_F_StackF0F0 >(SetRestrict< pfesS, 0 >), + new OneOperator2_< KN< long > *, KN< long > *, const RestrictArray< pfesL >::Op *, E_F_StackF0F0 >(SetRestrict< pfesL, 0 >)); + + Global.Add("interpolate", "(", new MatrixInterpolation< pfes, pfes >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfes, pfes >(1)); + Global.Add("interpolate", "(", new MatrixInterpolation< pfes3, pfes3 >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfes3, pfes3 >(1, 1)); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesS, pfesS >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesS, pfesS >(1, 1)); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesL, pfesL >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesL, pfesL >(1, 1)); + // warning the case MatrixInterpolation (1,1) not use fe2 .. + // so remove case (1,1) to remove ambiguity Polymorphic Find 4 + Global.Add("interpolate", "(", new MatrixInterpolation< pfesS, pfes3 >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesL, pfes >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesL, pfesS >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesS, pfesL >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfesS, pfes >); + + Global.Add("interpolate", "(", new MatrixInterpolation< pfes, pfesL >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfes, pfesS >); + Global.Add("interpolate", "(", new MatrixInterpolation< pfes, pfes3 >); + + Global.Add("interplotematrix", "(", new OneOperatorCode< PrintErrorCompileIM >); + zzzfff->Add("mapmatrix", atype< map< pair< int, int >, double > * >( )); + zzzfff->Add("Cmapmatrix", atype< map< pair< int, int >, Complex > * >( )); // a voir + + Dcl_Type< Resize< Matrice_Creuse< double > > >( ); + + Add< Matrice_Creuse< double > * >("resize", ".", new OneOperator1< Resize< Matrice_Creuse< double > >, Matrice_Creuse< double > * >(to_Resize)); + Add< Resize< Matrice_Creuse< double > > >("(", "", new OneOperator3_< Matrice_Creuse< double > *, Resize< Matrice_Creuse< double > >, long, long >(resize2)); // add missing in - Dcl_Type< Resize > > (); - Add *>("resize",".",new OneOperator1< Resize >,Matrice_Creuse *>(to_Resize)); - Add > >("(","",new OneOperator3_ *,Resize > , long, long >(resize2)); - - - // pour compatibiliter - - TheOperators->Add("=", - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation3<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationL<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationL2<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationLS<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationSL<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS3<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS2<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation2L<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation2S<1>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation23<1>) - ); - - - TheOperators->Add("<-", - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation3<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationL<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationLS<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationSL<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationL2<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS3<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolationS2<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation2L<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation2S<0>), - new OneOperator2_*,Matrice_Creuse*,const MatrixInterpolation::Op*,E_F_StackF0F0>(SetMatrixInterpolation23<0>) - ); - // construction of complex matrix form a double matrix - TheOperators->Add("=", new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse*,E_F_StackF0F0>(CopyMat) - ); - - TheOperators->Add("<-", new OneOperator2_*,Matrice_Creuse*,Matrice_Creuse*,E_F_StackF0F0>(CopyMat) - ); - Dcl_Type(); - Add*>("re",".",new OneOperator1s_ ,Matrice_Creuse* >(Build_Matrice_Creuse_C2R<0> )); - Add*>("im",".",new OneOperator1s_ ,Matrice_Creuse* >(Build_Matrice_Creuse_C2R<1> )); - // construction of complex matrix form a double matrix - init_UMFPack_solver(); - init_HashMatrix (); - - Global.Add("renumbering", "(", new removeDOF); - Global.Add("renumbering", "(", new removeDOF); - Global.Add("renumbering", "(", new removeDOF(1)); - Global.Add("renumbering", "(", new removeDOF(1)); - Global.Add("renumbering", "(", new removeDOF(1, 1)); - Global.Add("renumbering", "(", new removeDOF(1, 1)); - Global.Add("renumbering", "(", new removeDOF(1, 1, 1)); - Global.Add("renumbering", "(", new removeDOF(1, 1, 1)); - - Global.Add("display", "(", new plotMatrix); - Global.Add("display", "(", new plotMatrix); - - // ZZZZZZ ne marche pas FH.... - TheOperators->Add("*", - new Op2_mulvirtAvCR< RNM_VirtualMatrix::plusAx,Matrice_Creuse*,KN_ > , - new Op2_mulvirtAvCR< RNM_VirtualMatrix::plusAtx,Matrice_Creuse_Transpose,KN_ > , - new Op2_mulvirtAvCR< RNM_VirtualMatrix::solveAxeqb,Matrice_Creuse_inv,KN_ >, - new Op2_mulvirtAvCR< RNM_VirtualMatrix::solveAtxeqb,Matrice_Creuse_inv,KN_ > - ); - init_SparseLinearSolver(); - - - Global.New("DefaultSolver",CPValue(def_solver)); - Global.New("DefaultSolverSym",CPValue(def_solver_sym)); - Global.New("DefaultSolverSDP",CPValue(def_solver_sym_dp)); - - Global.Add("removeHalf", "(", new OneOperator2s_ ,Matrice_Creuse * ,long>(removeHalf)); - Global.Add("removeHalf", "(", new OneOperator3s_ ,Matrice_Creuse * ,long,double>(removeHalf)); - Global.Add("removeHalf", "(", new OneOperator4s_ * ,Matrice_Creuse * ,long,double>(removeHalf)); -// Add FH sep 2022 - Global.Add("removeHalf", "(", new OneOperator2s_ ,Matrice_Creuse * ,long>(removeHalf)); - Global.Add("removeHalf", "(", new OneOperator3s_ ,Matrice_Creuse * ,long,double>(removeHalf)); - Global.Add("removeHalf", "(", new OneOperator4s_ * ,Matrice_Creuse * ,long,double>(removeHalf)); - - TheOperators->Add("<-", - new OneOperator2 >*,KN >*,Matrice_Creuse * >(Matrix2KKN )); - TheOperators->Add("<-", - new OneOperator2 >*,KN >*,Matrice_Creuse_Transpose >(Matrix2KKN )); - TheOperators->Add("=", - new OneOperator2 >*,KN >*,Matrice_Creuse * >(Matrix2KKN )); - TheOperators->Add("=", - new OneOperator2 >*,KN >*,Matrice_Creuse_Transpose >(Matrix2KKN )); - -} - -int Data_Sparse_Solver_version() { return VDATASPARSESOLVER;} + Dcl_Type< Resize< Matrice_Creuse< Complex > > >( ); + Add< Matrice_Creuse< Complex > * >("resize", ".", new OneOperator1< Resize< Matrice_Creuse< Complex > >, Matrice_Creuse< Complex > * >(to_Resize)); + Add< Resize< Matrice_Creuse< Complex > > >("(", "", new OneOperator3_< Matrice_Creuse< Complex > *, Resize< Matrice_Creuse< Complex > >, long, long >(resize2)); + + // pour compatibiliter + + TheOperators->Add("=", new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes3, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation3< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationL< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationL2< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationLS< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationSL< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS3< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS2< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation2L< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation2S< 1 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation23< 1 >)); + + TheOperators->Add("<-", new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes3, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation3< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationL< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationLS< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationSL< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesL, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationL2< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS3< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfesS, pfes >::Op *, E_F_StackF0F0 >(SetMatrixInterpolationS2< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfesL >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation2L< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfesS >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation2S< 0 >), + new OneOperator2_< Matrice_Creuse< R > *, Matrice_Creuse< R > *, const MatrixInterpolation< pfes, pfes3 >::Op *, E_F_StackF0F0 >(SetMatrixInterpolation23< 0 >)); + // construction of complex matrix form a double matrix + TheOperators->Add("=", new OneOperator2_< Matrice_Creuse< Complex > *, Matrice_Creuse< Complex > *, Matrice_Creuse< double > *, E_F_StackF0F0 >(CopyMat< R, Complex, 1 >)); + + TheOperators->Add("<-", new OneOperator2_< Matrice_Creuse< Complex > *, Matrice_Creuse< Complex > *, Matrice_Creuse< double > *, E_F_StackF0F0 >(CopyMat< R, Complex, 0 >)); + Dcl_Type< Matrice_Creuse_C2R >( ); + Add< Matrice_Creuse< Complex > * >("re", ".", new OneOperator1s_< newpMatrice_Creuse< double >, Matrice_Creuse< Complex > * >(Build_Matrice_Creuse_C2R< 0 >)); + Add< Matrice_Creuse< Complex > * >("im", ".", new OneOperator1s_< newpMatrice_Creuse< double >, Matrice_Creuse< Complex > * >(Build_Matrice_Creuse_C2R< 1 >)); + // construction of complex matrix form a double matrix + init_UMFPack_solver( ); + init_HashMatrix( ); + + Global.Add("renumbering", "(", new removeDOF< double >); + Global.Add("renumbering", "(", new removeDOF< Complex >); + Global.Add("renumbering", "(", new removeDOF< double >(1)); + Global.Add("renumbering", "(", new removeDOF< Complex >(1)); + Global.Add("renumbering", "(", new removeDOF< double >(1, 1)); + Global.Add("renumbering", "(", new removeDOF< Complex >(1, 1)); + Global.Add("renumbering", "(", new removeDOF< double >(1, 1, 1)); + Global.Add("renumbering", "(", new removeDOF< Complex >(1, 1, 1)); + + Global.Add("display", "(", new plotMatrix< double >); + Global.Add("display", "(", new plotMatrix< Complex >); + + // ZZZZZZ ne marche pas FH.... + TheOperators->Add("*", new Op2_mulvirtAvCR< RNM_VirtualMatrix< Complex >::plusAx, Matrice_Creuse< double > *, KN_< Complex > >, + new Op2_mulvirtAvCR< RNM_VirtualMatrix< Complex >::plusAtx, Matrice_Creuse_Transpose< double >, KN_< Complex > >, + new Op2_mulvirtAvCR< RNM_VirtualMatrix< Complex >::solveAxeqb, Matrice_Creuse_inv< R >, KN_< Complex > >, + new Op2_mulvirtAvCR< RNM_VirtualMatrix< Complex >::solveAtxeqb, Matrice_Creuse_inv< R >, KN_< Complex > >); + init_SparseLinearSolver( ); + + Global.New("DefaultSolver", CPValue< string * >(def_solver)); + Global.New("DefaultSolverSym", CPValue< string * >(def_solver_sym)); + Global.New("DefaultSolverSDP", CPValue< string * >(def_solver_sym_dp)); + + Global.Add("removeHalf", "(", new OneOperator2s_< newpMatrice_Creuse< R >, Matrice_Creuse< R > *, long >(removeHalf)); + Global.Add("removeHalf", "(", new OneOperator3s_< newpMatrice_Creuse< R >, Matrice_Creuse< R > *, long, double >(removeHalf)); + Global.Add("removeHalf", "(", new OneOperator4s_< bool, Matrice_Creuse< R > *, Matrice_Creuse< R > *, long, double >(removeHalf)); + // Add FH sep 2022 + Global.Add("removeHalf", "(", new OneOperator2s_< newpMatrice_Creuse< Complex >, Matrice_Creuse< Complex > *, long >(removeHalf)); + Global.Add("removeHalf", "(", new OneOperator3s_< newpMatrice_Creuse< Complex >, Matrice_Creuse< Complex > *, long, double >(removeHalf)); + Global.Add("removeHalf", "(", new OneOperator4s_< bool, Matrice_Creuse< Complex > *, Matrice_Creuse< Complex > *, long, double >(removeHalf)); + + TheOperators->Add("<-", new OneOperator2< KN< KN< long > > *, KN< KN< long > > *, Matrice_Creuse< double > * >(Matrix2KKN< double, 1 >)); + TheOperators->Add("<-", new OneOperator2< KN< KN< long > > *, KN< KN< long > > *, Matrice_Creuse_Transpose< double > >(Matrix2KKN< double, 1 >)); + TheOperators->Add("=", new OneOperator2< KN< KN< long > > *, KN< KN< long > > *, Matrice_Creuse< double > * >(Matrix2KKN< double, 0 >)); + TheOperators->Add("=", new OneOperator2< KN< KN< long > > *, KN< KN< long > > *, Matrice_Creuse_Transpose< double > >(Matrix2KKN< double, 0 >)); +} + +int Data_Sparse_Solver_version( ) { return VDATASPARSESOLVER; } #else #include -void init_lgmat() -{ std::cout << "\n warning init_lgmat EMPTY\n"<< std::endl; - -} +void init_lgmat( ) { std::cout << "\n warning init_lgmat EMPTY\n" << std::endl; } #endif diff --git a/src/fflib/lgmesh.cpp b/src/fflib/lgmesh.cpp index 13583926e..213cea275 100644 --- a/src/fflib/lgmesh.cpp +++ b/src/fflib/lgmesh.cpp @@ -30,7 +30,6 @@ #include "ff++.hpp" #include "AFunction_ext.hpp" - #include "lgmesh.hpp" using Fem2D::Mesh; @@ -38,1323 +37,1171 @@ using Fem2D::MeshPoint; extern bool NoWait; -typedef Mesh const * pmesh; - -template -class classBuildMesh : public E_F0mps { public: +typedef Mesh const *pmesh; - typedef pmesh Result; +template< class TP = E_BorderN > +class classBuildMesh : public E_F0mps { + public: + typedef pmesh Result; - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =6; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 6; - Expression nargs[n_name_param]; - - Expression getborders; + Expression nargs[n_name_param]; - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - double arg(int i,Stack stack,double a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - KNM* arg(int i,Stack stack,KNM* p) const{ return nargs[i] ? GetAny*>( (*nargs[i])(stack) ): p;} + Expression getborders; - classBuildMesh(const basicAC_F0 & args) - { - args.SetNameParam(n_name_param,name_param,nargs); - getborders=to(args[0]); - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + KNM< double > *arg(int i, Stack stack, KNM< double > *p) const { return nargs[i] ? GetAny< KNM< double > * >((*nargs[i])(stack)) : p; } - static ArrayOfaType typeargs() { return ArrayOfaType(atype());} - static E_F0 * f(const basicAC_F0 & args){ return new classBuildMesh(args);} - AnyType operator()(Stack s) const ; - operator aType () const { return atype();} + classBuildMesh(const basicAC_F0 &args) { + args.SetNameParam(n_name_param, name_param, nargs); + getborders = to< const TP * >(args[0]); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const TP * >( )); } + static E_F0 *f(const basicAC_F0 &args) { return new classBuildMesh(args); } + AnyType operator( )(Stack s) const; + operator aType( ) const { return atype< Result >( ); } }; -class classBuildMeshArray : public E_F0mps { public: - - typedef pmesh Result; +class classBuildMeshArray : public E_F0mps { + public: + typedef pmesh Result; - //static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =0; + // static basicAC_F0::name_and_type name_param[] ; + static const int n_name_param = 0; -//Expression nargs[n_name_param]; - - Expression env,ent,enbe; - Expression ev,et,ebe; + // Expression nargs[n_name_param]; + Expression env, ent, enbe; + Expression ev, et, ebe; + classBuildMeshArray(const basicAC_F0 &args) { + args.SetNameParam(0, 0, 0); + env = to< long >(args[0]); + ent = to< long >(args[1]); + enbe = to< long >(args[2]); + ev = to< KNM_< double > >(args[3]); + et = to< KNM_< long > >(args[4]); + ebe = to< KNM_< long > >(args[5]); + } + static ArrayOfaType typeargs( ) { - classBuildMeshArray(const basicAC_F0 & args) - { - args.SetNameParam(0,0,0); - env=to(args[0]); - ent=to(args[1]); - enbe=to(args[2]); - ev=to >(args[3]); - et=to >(args[4]); - ebe=to >(args[5]); + aType ffint = atype< long >( ); + aType ffMi = atype< KNM_< long > >( ); + aType ffMr = atype< KNM_< double > >( ); + return ArrayOfaType(ffint, ffint, ffint, ffMr, ffMi, ffMi); + } + static E_F0 *f(const basicAC_F0 &args) { return new classBuildMeshArray(args); } + AnyType operator( )(Stack s) const { + long nv = GetAny< long >((*env)(s)); + long nt = GetAny< long >((*ent)(s)); + long nbe = GetAny< long >((*enbe)(s)); + KNM_< double > xyl(GetAny< KNM_< double > >((*ev)(s))); + KNM_< long > nut(GetAny< KNM_< long > >((*et)(s))); + KNM_< long > nube(GetAny< KNM_< long > >((*ebe)(s))); + using Fem2D::BoundaryEdge; + using Fem2D::Mesh; + using Fem2D::MeshPointStack; + using Fem2D::R2; + using Fem2D::Vertex; + + cout << nv << " " << nt << " " << nbe << endl; + cout << xyl.N( ) << " " << xyl.M( ) << endl; + cout << nut.N( ) << " " << nut.M( ) << endl; + cout << nube.N( ) << " " << nube.M( ) << endl; + ffassert(xyl.N( ) >= nv && xyl.M( ) >= 3); + ffassert(nut.N( ) >= nt && nut.M( ) >= 4); + ffassert(nube.N( ) >= nbe && nube.M( ) >= 3); + Vertex *v = new Vertex[nv]; + Triangle *t = new Triangle[nt]; + BoundaryEdge *b = new BoundaryEdge[nbe]; + + for (int i = 0; i < nv; ++i) { + v[i].x = xyl(i, 0); + v[i].y = xyl(i, 1); + v[i].lab = xyl(i, 2); } + for (int i = 0; i < nt; ++i) t[i].set(v, nut(i, 0), nut(i, 1), nut(i, 2), nut(i, 3)); + for (int i = 0; i < nbe; ++i) b[i].set(v, nube(i, 0), nube(i, 1), nube(i, 2)); - static ArrayOfaType typeargs() { - - aType ffint =atype< long >(); - aType ffMi =atype< KNM_ >(); - aType ffMr =atype< KNM_ >(); - return ArrayOfaType(ffint,ffint,ffint,ffMr,ffMi,ffMi);} - - static E_F0 * f(const basicAC_F0 & args){ return new classBuildMeshArray(args);} - AnyType operator()(Stack s) const { - long nv = GetAny((*env)(s)); - long nt = GetAny((*ent)(s)); - long nbe = GetAny((*enbe)(s)); - KNM_ xyl( GetAny >((*ev)(s))); - KNM_ nut( GetAny >((*et)(s))); - KNM_ nube( GetAny >((*ebe)(s))); - using Fem2D::Vertex; - using Fem2D::R2; - using Fem2D::BoundaryEdge; - using Fem2D::Mesh; - using Fem2D::MeshPointStack; - - cout << nv << " " << nt << " " << nbe << endl; - cout << xyl.N() << " "<< xyl.M() << endl; - cout << nut.N() << " "<< nut.M() << endl; - cout << nube.N() << " "<< nube.M() << endl; - ffassert(xyl.N() >=nv && xyl.M() >= 3); - ffassert(nut.N() >=nt && nut.M() >= 4); - ffassert(nube.N() >=nbe && nube.M() >= 3); - Vertex *v= new Vertex [nv]; - Triangle *t= new Triangle[nt]; - BoundaryEdge *b = new BoundaryEdge[nbe]; - - for(int i=0;iBoundingBox(Pn,Px); - if(!pth->quadtree) - pth->quadtree=new Fem2D::FQuadTree(pth,Pn,Px,pth->nv); - - - return Add2StackOfPtr2FreeRC(s,pth);// 07/2008 FH - - - } - operator aType () const { return atype();} + Mesh *pth = new Mesh(nv, nt, nbe, v, t, b); + if (verbosity) cout << " -- BuildMesh " << pth << " " << nv << " " << nt << " " << nbe << endl; + R2 Pn, Px; + pth->BoundingBox(Pn, Px); + if (!pth->quadtree) pth->quadtree = new Fem2D::FQuadTree(pth, Pn, Px, pth->nv); + return Add2StackOfPtr2FreeRC(s, pth); // 07/2008 FH + } + operator aType( ) const { return atype< Result >( ); } }; template<> -basicAC_F0::name_and_type classBuildMesh::name_param[]= { - { "nbvx", &typeid(long)} , - {"fixeborder", &typeid(bool)},// obsolete - {"points", &typeid(KNM*)}, - {"fixedborder", &typeid(bool)}, - {"alea", &typeid(double)}, - {"splitpbedge", &typeid(bool)} // add april 20 FH +basicAC_F0::name_and_type classBuildMesh< E_BorderN >::name_param[] = { + {"nbvx", &typeid(long)}, + {"fixeborder", &typeid(bool)}, // obsolete + {"points", &typeid(KNM< double > *)}, + {"fixedborder", &typeid(bool)}, + {"alea", &typeid(double)}, + {"splitpbedge", &typeid(bool)} // add april 20 FH }; template<> -basicAC_F0::name_and_type classBuildMesh::name_param[]= { - { "nbvx", &typeid(long)} , - {"fixeborder", &typeid(bool)},// obsolete - {"points", &typeid(KNM*)}, - {"fixedborder", &typeid(bool)}, - {"alea", &typeid(double)}, - {"splitpbedge", &typeid(bool)} // add april 20 FH +basicAC_F0::name_and_type classBuildMesh< MeshL >::name_param[] = { + {"nbvx", &typeid(long)}, + {"fixeborder", &typeid(bool)}, // obsolete + {"points", &typeid(KNM< double > *)}, + {"fixedborder", &typeid(bool)}, + {"alea", &typeid(double)}, + {"splitpbedge", &typeid(bool)} // add april 20 FH }; // modif aout 2007 -class BuildMeshFile : public E_F0mps { public: - - typedef pmesh Result; +class BuildMeshFile : public E_F0mps { + public: + typedef pmesh Result; - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =1; - - Expression nargs[n_name_param]; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 1; - Expression getfilename; + Expression nargs[n_name_param]; - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} + Expression getfilename; - BuildMeshFile(const basicAC_F0 & args) - { - args.SetNameParam(n_name_param,name_param,nargs); - getfilename=to(args[0]); - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - static ArrayOfaType typeargs() { return ArrayOfaType(atype());} - static E_F0 * f(const basicAC_F0 & args){ return new BuildMeshFile(args);} - AnyType operator()(Stack s) const ; - operator aType () const { return atype();} + BuildMeshFile(const basicAC_F0 &args) { + args.SetNameParam(n_name_param, name_param, nargs); + getfilename = to< string * >(args[0]); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< string * >( )); } + static E_F0 *f(const basicAC_F0 &args) { return new BuildMeshFile(args); } + AnyType operator( )(Stack s) const; + operator aType( ) const { return atype< Result >( ); } }; -basicAC_F0::name_and_type BuildMeshFile::name_param[]= { - { "nbvx", &typeid(long) } -}; +basicAC_F0::name_and_type BuildMeshFile::name_param[] = {{"nbvx", &typeid(long)}}; // fin modif 2007 -class MoveMesh : public E_F0mps { public: - - typedef pmesh Result; - Expression getmesh; - Expression U,V; - int nbsol; - vector sol; - - MoveMesh(const basicAC_F0 & args) :nbsol(args.size()-2),sol(args.size()-2) - { - using Fem2D::Triangle; - using Fem2D::Vertex; - using Fem2D::R2; - using Fem2D::BoundaryEdge; - using Fem2D::Mesh; - // using Fem2D::R; - using Fem2D::MeshPointStack; - args.SetNameParam(); - getmesh=to(args[0]); - const E_Array * a = dynamic_cast(args[1].LeftValue()); - - ffassert(a); - if (a->size() !=2) CompileError("movemesh(Th,[u,v],...) need 2 componate in array ",atype()); - U=to( (*a)[0]); - V=to( (*a)[1]); - - for (int i=2;i(args[i]); - } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype(),true);} - static E_F0 * f(const basicAC_F0 & args){ return new MoveMesh(args);} - AnyType operator()(Stack s) const ; - operator aType () const { return atype();} - +class MoveMesh : public E_F0mps { + public: + typedef pmesh Result; + Expression getmesh; + Expression U, V; + int nbsol; + vector< Expression > sol; + + MoveMesh(const basicAC_F0 &args) : nbsol(args.size( ) - 2), sol(args.size( ) - 2) { + using Fem2D::BoundaryEdge; + using Fem2D::Mesh; + using Fem2D::R2; + using Fem2D::Triangle; + using Fem2D::Vertex; + // using Fem2D::R; + using Fem2D::MeshPointStack; + args.SetNameParam( ); + getmesh = to< pmesh >(args[0]); + const E_Array *a = dynamic_cast< const E_Array * >(args[1].LeftValue( )); + + ffassert(a); + if (a->size( ) != 2) CompileError("movemesh(Th,[u,v],...) need 2 componate in array ", atype< pmesh >( )); + U = to< double >((*a)[0]); + V = to< double >((*a)[1]); + + for (int i = 2; i < args.size( ); i++) sol[i - 2] = to< double >(args[i]); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), atype< E_Array >( ), true); } + static E_F0 *f(const basicAC_F0 &args) { return new MoveMesh(args); } + AnyType operator( )(Stack s) const; + operator aType( ) const { return atype< Result >( ); } }; -class SplitMesh : public E_F0mps { public: - - typedef pmesh Result; - Expression getmesh; - Expression U; - - SplitMesh(const basicAC_F0 & args) - { - args.SetNameParam(); - getmesh=to(args[0]); - U = to(args[1]); - } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());} - static E_F0 * f(const basicAC_F0 & args){ return new SplitMesh(args);} - AnyType operator()(Stack s) const ; - operator aType () const { return atype();} +class SplitMesh : public E_F0mps { + public: + typedef pmesh Result; + Expression getmesh; + Expression U; + SplitMesh(const basicAC_F0 &args) { + args.SetNameParam( ); + getmesh = to< pmesh >(args[0]); + U = to< long >(args[1]); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), atype< long >( )); } + static E_F0 *f(const basicAC_F0 &args) { return new SplitMesh(args); } + AnyType operator( )(Stack s) const; + operator aType( ) const { return atype< Result >( ); } }; -class SaveMesh : public E_F0 { public: - - typedef pmesh Result; - Expression getmesh; - Expression filename; - Expression xx,yy,zz; - SaveMesh(const basicAC_F0 & args) - { - xx=0; - yy=0; - zz=0; - args.SetNameParam(); - getmesh=to(args[0]); - filename=to(args[1]); - if (args.size() >2) - { - const E_Array * a = dynamic_cast(args[2].LeftValue()); - if (!a) CompileError("savemesh(Th,\"filename\",[u,v,w],..."); - int k=a->size() ; - // cout << k << endl; - if ( k!=2 && k !=3) CompileError("savemesh(Th,\"filename\",[u,v,w]) need 2 or 3 componate in array ",atype()); - xx=to( (*a)[0]); - yy=to( (*a)[1]); - if(k==3) - zz=to( (*a)[2]); - } - - } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype(),true);} - static E_F0 * f(const basicAC_F0 & args){ return new SaveMesh(args);} - AnyType operator()(Stack s) const ; - +class SaveMesh : public E_F0 { + public: + typedef pmesh Result; + Expression getmesh; + Expression filename; + Expression xx, yy, zz; + SaveMesh(const basicAC_F0 &args) { + xx = 0; + yy = 0; + zz = 0; + args.SetNameParam( ); + getmesh = to< pmesh >(args[0]); + filename = to< string * >(args[1]); + if (args.size( ) > 2) { + const E_Array *a = dynamic_cast< const E_Array * >(args[2].LeftValue( )); + if (!a) CompileError("savemesh(Th,\"filename\",[u,v,w],..."); + int k = a->size( ); + // cout << k << endl; + if (k != 2 && k != 3) CompileError("savemesh(Th,\"filename\",[u,v,w]) need 2 or 3 componate in array ", atype< pmesh >( )); + xx = to< double >((*a)[0]); + yy = to< double >((*a)[1]); + if (k == 3) zz = to< double >((*a)[2]); + } + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), atype< string * >( ), true); } + static E_F0 *f(const basicAC_F0 &args) { return new SaveMesh(args); } + AnyType operator( )(Stack s) const; }; +class Adaptation : public E_F0mps { + public: + typedef pmesh Result; -class Adaptation : public E_F0mps { public: - typedef pmesh Result; - - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =28; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 28; int nbsol; Expression nargs[n_name_param]; Expression getmesh; - Expression em11,em22,em12; - int typesol[100]; - vector sol; + Expression em11, em22, em12; + int typesol[100]; + vector< Expression > sol; int nbcperiodic; Expression *periodic; + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + long *arg(int i, Stack stack, long *a) const { return nargs[i] ? GetAny< long * >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + int arg(int i, Stack stack, int a) const { return nargs[i] ? GetAny< int >((*nargs[i])(stack)) : a; } + + Adaptation(const basicAC_F0 &args) : nbsol(args.size( ) - 1), sol(args.size( ) - 1) { + em11 = 0; + em22 = 0; + em12 = 0; + + args.SetNameParam(n_name_param, name_param, nargs); + getmesh = to< pmesh >(args[0]); + int ksol = 0; + ffassert(nbsol < 100); + for (int i = 1; i < nbsol + 1; i++) + if (args[i].left( ) == atype< E_Array >( )) { + const E_Array *a = dynamic_cast< const E_Array * >(args[i].LeftValue( )); + ffassert(a); + ksol += a->size( ); + } else + ksol++; + sol.resize(ksol); + ksol = 0; + for (int i = 1; i < nbsol + 1; i++) + if (args[i].left( ) == atype< E_Array >( )) { + const E_Array *a = dynamic_cast< const E_Array * >(args[i].LeftValue( )); + ffassert(a); + int N = a->size( ); + typesol[i - 1] = N - 1; // ok en 2D + if (N <= 4) { + for (int j = 0; j < N; j++) sol[ksol++] = to< double >((*a)[j]); + } else { + lgerror(" Adaptation vecteur a plus de 4 compossantes inconnue"); + } - double arg(int i,Stack stack,double a) const { return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - long* arg(int i,Stack stack,long* a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - int arg(int i,Stack stack,int a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} + } else { + typesol[i - 1] = 0; + sol[ksol++] = to< double >(args[i]); + } + const E_Array *expmetrix = dynamic_cast< const E_Array * >(nargs[24]); - Adaptation(const basicAC_F0 & args) :nbsol(args.size()-1),sol(args.size()-1) - { - em11=0; - em22=0; - em12=0; - - args.SetNameParam(n_name_param,name_param,nargs); - getmesh=to(args[0]); - int ksol=0; - ffassert(nbsol<100); - for (int i=1;i()) - { - const E_Array * a = dynamic_cast(args[i].LeftValue()); - ffassert(a); - ksol+=a->size(); - } - else - ksol++; - sol.resize(ksol); - ksol=0; - for (int i=1;i()) - { - const E_Array * a = dynamic_cast(args[i].LeftValue()); - ffassert(a); - int N=a->size(); - typesol[i-1]=N-1; // ok en 2D - if (N<=4) { - for (int j=0;j((*a)[j]); } - else { - lgerror(" Adaptation vecteur a plus de 4 compossantes inconnue"); - } - - } - else { - typesol[i-1]=0; - sol[ksol++]=to(args[i]); - } - const E_Array * expmetrix = dynamic_cast(nargs[24]); - - if(expmetrix) - { - if(expmetrix->nbitem()!=3) - ExecError("\nSorry we wait an array with 3 componants in: metrix=[m11,m12,m22]"); - - em11=(*expmetrix)[0]; - em12=(*expmetrix)[1]; - em22=(*expmetrix)[2]; - - if( (*expmetrix)[0].left()!= atype *>() ) - CompileError("Sorry the fist array componant in metrix=[m11,m12,m22] must be vector"); - if( (*expmetrix)[1].left()!= atype *>() ) - CompileError("Sorry the second array componant in metrix=[m11,m12,m22] must be vector"); - if( (*expmetrix)[2].left()!= atype *>() ) - CompileError("Sorry the third array componant in metrix=[m11,m12,m22] must be vector"); - - - } - nbcperiodic=0; - periodic=0; - GetPeriodic(2,nargs[25],nbcperiodic,periodic); - - } - - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),true);} - static E_F0 * f(const basicAC_F0 & args){ return new Adaptation(args);} - AnyType operator()(Stack s) const ; - operator aType () const { return atype();} + if (expmetrix) { + if (expmetrix->nbitem( ) != 3) ExecError("\nSorry we wait an array with 3 componants in: metrix=[m11,m12,m22]"); + + em11 = (*expmetrix)[0]; + em12 = (*expmetrix)[1]; + em22 = (*expmetrix)[2]; + + if ((*expmetrix)[0].left( ) != atype< KN< double > * >( )) CompileError("Sorry the fist array componant in metrix=[m11,m12,m22] must be vector"); + if ((*expmetrix)[1].left( ) != atype< KN< double > * >( )) CompileError("Sorry the second array componant in metrix=[m11,m12,m22] must be vector"); + if ((*expmetrix)[2].left( ) != atype< KN< double > * >( )) CompileError("Sorry the third array componant in metrix=[m11,m12,m22] must be vector"); + } + nbcperiodic = 0; + periodic = 0; + GetPeriodic(2, nargs[25], nbcperiodic, periodic); + } + + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), true); } + static E_F0 *f(const basicAC_F0 &args) { return new Adaptation(args); } + AnyType operator( )(Stack s) const; + operator aType( ) const { return atype< pmesh >( ); } }; +basicAC_F0::name_and_type Adaptation::name_param[Adaptation::n_name_param] = { + {"hmin", &typeid(double)}, // � + {"hmax", &typeid(double)}, + {"err", &typeid(double)}, + {"errg", &typeid(double)}, + {"nbvx", &typeid(long)}, // 4 + {"nbsmooth", &typeid(long)}, + {"nbjacoby", &typeid(long)}, + {"ratio", &typeid(double)}, + {"omega", &typeid(double)}, + {"iso", &typeid(bool)}, // 9 + {"abserror", &typeid(bool)}, + {"cutoff", &typeid(double)}, + {"verbosity", &typeid(long)}, + {"inquire", &typeid(bool)}, + {"splitpbedge", &typeid(bool)}, // 14 + {"maxsubdiv", &typeid(double)}, + {"anisomax", &typeid(double)}, + {"rescaling", &typeid(bool)}, + {"keepbackvertices", &typeid(bool)}, + {"IsMetric", &typeid(bool)}, // 19 + {"power", &typeid(double)}, // 20 + {"thetamax", &typeid(double)}, + {"splitin2", &typeid(bool)}, + {"nomeshgeneration", &typeid(bool)}, + {"metric", &typeid(E_Array)}, // 24 + {"periodic", &typeid(E_Array)}, // 25 + {"requirededges", &typeid(KN_< long >)}, // 26 + {"warning", &typeid(long *)} // 27 - basicAC_F0::name_and_type Adaptation::name_param[Adaptation::n_name_param] = { - { "hmin", &typeid(double)}, // � - { "hmax", &typeid(double)}, - { "err", &typeid(double)}, - { "errg", &typeid(double)}, - { "nbvx", &typeid(long)}, // 4 - { "nbsmooth", &typeid(long)}, - { "nbjacoby", &typeid(long)}, - { "ratio", &typeid(double)}, - { "omega", &typeid(double)}, - { "iso", &typeid(bool)}, // 9 - { "abserror", &typeid(bool)}, - { "cutoff", &typeid(double)}, - { "verbosity", &typeid(long)}, - { "inquire", &typeid(bool)}, - { "splitpbedge", &typeid(bool)}, // 14 - { "maxsubdiv", &typeid(double)}, - { "anisomax", &typeid(double)}, - { "rescaling", &typeid(bool)}, - { "keepbackvertices", &typeid(bool)}, - { "IsMetric", &typeid(bool)}, // 19 - { "power", &typeid(double)}, // 20 - { "thetamax", &typeid(double)}, - { "splitin2", &typeid(bool) }, - { "nomeshgeneration", &typeid(bool) }, - { "metric" , &typeid(E_Array)}, // 24 - { "periodic" , &typeid(E_Array) },// 25 - { "requirededges", &typeid(KN_ ) }, // 26 - { "warning", &typeid(long *) } // 27 - - }; +}; struct Op_trunc_mesh : public OneOperator { - class Op: public E_F0mps { public: - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =9; - Expression nargs[n_name_param]; - - Expression getmesh,bbb; - long arg(int i,Stack stack,long a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - bool arg(int i,Stack stack,bool a) const{ return nargs[i] ? GetAny( (*nargs[i])(stack) ): a;} - - KN * arg(int i,Stack stack) const{ return nargs[i] ? GetAny *>( (*nargs[i])(stack) ): 0;} - Op(const basicAC_F0 & args,Expression t,Expression b) : getmesh(t),bbb(b) - { args.SetNameParam(n_name_param,name_param,nargs); } - AnyType operator()(Stack s) const ; - }; - E_F0 * code(const basicAC_F0 & args) const - { return new Op(args,to(args[0]),to(args[1])) ;} - Op_trunc_mesh() : - OneOperator(atype(),atype(),atype()) {} -}; + class Op : public E_F0mps { + public: + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 9; + Expression nargs[n_name_param]; -basicAC_F0::name_and_type Op_trunc_mesh::Op::name_param[Op_trunc_mesh::Op::n_name_param] = - { - { "split", &typeid(long)}, - { "label", &typeid(long)}, - { "new2old", &typeid(KN*)}, // ajout FH pour P. Jolivet jan 2014 - { "old2new", &typeid(KN*)}, // ajout FH pour P. JoLivet jan 2014 - { "renum",&typeid(bool)}, -// add jan 2019 - { "labels", &typeid(KN_ )}, - { "region", &typeid(KN_ )}, - { "flabel", &typeid(long)}, - { "fregion", &typeid(long)}, - }; -template -AnyType classBuildMesh::operator()(Stack stack) const { - const TP * borders = GetAny((*getborders)(stack)); - long nbvx = arg(0,stack,0L); - int defrb = is_same::value ; - bool requireborder= arg(3,stack,arg(1,stack,false));// correct 23 nov. 2021 FH - KNM * p=0; p=arg(2,stack,p); - double alea = arg(4,stack,0.); - bool SplitEdgeWith2Boundary=arg(5,stack,false); - ffassert( nbvx >= 0); - return SetAny(Add2StackOfPtr2FreeRC(stack, - BuildMesh(stack,borders,false,nbvx,requireborder,p,alea,SplitEdgeWith2Boundary))); + Expression getmesh, bbb; + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } -} + KN< long > *arg(int i, Stack stack) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : 0; } + Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { args.SetNameParam(n_name_param, name_param, nargs); } + AnyType operator( )(Stack s) const; + }; + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, to< pmesh >(args[0]), to< bool >(args[1])); } + Op_trunc_mesh( ) : OneOperator(atype< pmesh >( ), atype< pmesh >( ), atype< bool >( )) {} +}; -AnyType BuildMeshFile::operator()(Stack stack) const { - string* filename = GetAny((*getfilename)(stack)); - long nbvx = arg(0,stack,0); - ffassert( nbvx >= 0); - pmesh pmsh=buildmeshbamg( filename,nbvx); - Add2StackOfPtr2FreeRC(stack,pmsh);// 07/2008 FH - return SetAny(pmsh); +basicAC_F0::name_and_type Op_trunc_mesh::Op::name_param[Op_trunc_mesh::Op::n_name_param] = { + {"split", &typeid(long)}, + {"label", &typeid(long)}, + {"new2old", &typeid(KN< long > *)}, // ajout FH pour P. Jolivet jan 2014 + {"old2new", &typeid(KN< long > *)}, // ajout FH pour P. JoLivet jan 2014 + {"renum", &typeid(bool)}, + // add jan 2019 + {"labels", &typeid(KN_< long >)}, + {"region", &typeid(KN_< long >)}, + {"flabel", &typeid(long)}, + {"fregion", &typeid(long)}, +}; +template< class TP > +AnyType classBuildMesh< TP >::operator( )(Stack stack) const { + const TP *borders = GetAny< const TP * >((*getborders)(stack)); + long nbvx = arg(0, stack, 0L); + int defrb = is_same< MeshL, TP >::value; + bool requireborder = arg(3, stack, arg(1, stack, false)); // correct 23 nov. 2021 FH + KNM< double > *p = 0; + p = arg(2, stack, p); + double alea = arg(4, stack, 0.); + bool SplitEdgeWith2Boundary = arg(5, stack, false); + ffassert(nbvx >= 0); + return SetAny< pmesh >(Add2StackOfPtr2FreeRC(stack, BuildMesh(stack, borders, false, nbvx, requireborder, p, alea, SplitEdgeWith2Boundary))); +} +AnyType BuildMeshFile::operator( )(Stack stack) const { + string *filename = GetAny< string * >((*getfilename)(stack)); + long nbvx = arg(0, stack, 0); + ffassert(nbvx >= 0); + pmesh pmsh = buildmeshbamg(filename, nbvx); + Add2StackOfPtr2FreeRC(stack, pmsh); // 07/2008 FH + return SetAny< pmesh >(pmsh); } -static int ChangeLab(const map & m,int lab) -{ - map::const_iterator i=m.find(lab); - if(i != m.end()) - lab=i->second; - return lab; +static int ChangeLab(const map< int, int > &m, int lab) { + map< int, int >::const_iterator i = m.find(lab); + if (i != m.end( )) lab = i->second; + return lab; } -AnyType Op_trunc_mesh::Op::operator()(Stack stack) const { - // Remark : F.Hecht feb 2016 ... - // WARNING for DDM - // trunc(trunc(Th,op1),op2) =trunc(trunc(Th,op2),op1) => no renumbering .... - using namespace Fem2D; - const pmesh pTh = GetAny((*getmesh)(stack)); - if( !pTh) return pTh; - const Mesh & Th = *pTh; - long kkksplit =std::max(1L, arg(0,stack,1L)); - long label =arg(1,stack,2L); - KN * pn2o = arg(2,stack); - KN * po2n = arg(3,stack); - KN split(Th.nt); - bool renum=arg(4,stack,false);// change to false too dangerous with ddm the trunc must commute in DDM - KN kempty; - KN nre = arg(5,stack,kempty); - KN nrt = arg(6,stack,kempty); - Expression flab = nargs[7] ; - Expression freg = nargs[8] ; - split=kkksplit; - long ks=kkksplit*kkksplit; - MeshPoint *mp= MeshPointStack(stack),mps=*mp; - long kk=0; - for (int k=0;kset(Th,K(B),B,K,0); - if ( GetAny((*bbb)(stack)) ) kk++; - else split[k]=0 ; - } - - if(pn2o) - { - pn2o->resize(kk*ks); - KN &n2o(*pn2o); - int l=0; - for(int k=0; k< Th.nt; ++k) - if( split[k] ) - for(int i=0; i< ks; ++i) - n2o[l++] = k; - } - if(po2n) - { - po2n->resize(Th.nt); - KN &o2n(*po2n); - int l=0; - for(int k=0; k< Th.nt; ++k) - if( split[k] ) - { - o2n[k] = l; - l+=ks; - } - else o2n[k]=-1; - } -// chnage .... - - *mp=mps; - if (verbosity>1) - cout << " -- Trunc mesh: Nb of Triangle = " << kk << " label=" < * a=GetAny*>(x); - for (int i=0;iN(); i++) - (*a)[i]->destroy(); - a->destroy(); - return Nothing; -} -template -RR * get_elementp_(const A & a,const B & b){ - if( b<0 || a->N() <= b) - { cerr << " Out of bound 0 <=" << b << " < " << a->N() << " array type = " << typeid(A).name() << endl; - ExecError("Out of bound in operator []");} - return &((*a)[b]);} - -template R * set_initinit( R* const & a,const long & n){ - SHOWVERB( cout << " set_init " << typeid(R).name() << " " << n << endl); - a->init(n); - for (int i=0;i1)cout << " init_mesh3_array"<< endl; - Dcl_Type *>(0,::DestroyKN ); - atype* >()->Add("[","",new OneOperator2_*,long >(get_elementp_*,long>)); - TheOperators->Add("<-", - new OneOperator2_ *,KN *,long>(&set_initinit)); - map_type_of_map[make_pair(atype(),atype())]=atype*>(); // vector - - Dcl_Type< Resize > > (); - Add*>("resize",".",new OneOperator1< Resize >,KN*>(to_Resize)); - Add > >("(","",new OneOperator2_ *,Resize > , long >(resizeandclean1)); - - -} - -//3D surface -void init_meshS_array() -{ - Dcl_Type *>(0,::DestroyKN ); - atype* >()->Add("[","",new OneOperator2_*,long >(get_elementp_*,long>)); - TheOperators->Add("<-", - new OneOperator2_ *,KN *,long>(&set_initinit)); - map_type_of_map[make_pair(atype(),atype())]=atype*>(); // vector - - Dcl_Type< Resize > > (); - Add*>("resize",".",new OneOperator1< Resize >,KN*>(to_Resize)); - Add > >("(","",new OneOperator2_ *,Resize > , long >(resizeandclean1)); - - -} - - -//3D Line -void init_meshL_array() -{ - Dcl_Type *>(0,::DestroyKN ); - atype* >()->Add("[","",new OneOperator2_*,long >(get_elementp_*,long>)); - TheOperators->Add("<-", - new OneOperator2_ *,KN *,long>(&set_initinit)); - map_type_of_map[make_pair(atype(),atype())]=atype*>(); // vector - - Dcl_Type< Resize > > (); - Add*>("resize",".",new OneOperator1< Resize >,KN*>(to_Resize)); - Add > >("(","",new OneOperator2_ *,Resize > , long >(resizeandclean1)); - - +// add Feb. 2010 FH +template< class A > +inline AnyType DestroyKN(Stack, const AnyType &x) { + KN< A > *a = GetAny< KN< A > * >(x); + for (int i = 0; i < a->N( ); i++) (*a)[i]->destroy( ); + a->destroy( ); + return Nothing; +} +template< class RR, class A, class B > +RR *get_elementp_(const A &a, const B &b) { + if (b < 0 || a->N( ) <= b) { + cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " array type = " << typeid(A).name( ) << endl; + ExecError("Out of bound in operator []"); + } + return &((*a)[b]); +} + +template< class R > +R *set_initinit(R *const &a, const long &n) { + SHOWVERB(cout << " set_init " << typeid(R).name( ) << " " << n << endl); + a->init(n); + for (int i = 0; i < n; i++) (*a)[i] = 0; + return a; } +// 3d Volume +void init_mesh3_array( ) { + if (mpirank == 0 && verbosity > 1) cout << " init_mesh3_array" << endl; + Dcl_Type< KN< pmesh3 > * >(0, ::DestroyKN< pmesh3 >); + atype< KN< pmesh3 > * >( )->Add("[", "", new OneOperator2_< pmesh3 *, KN< pmesh3 > *, long >(get_elementp_< pmesh3, KN< pmesh3 > *, long >)); + TheOperators->Add("<-", new OneOperator2_< KN< pmesh3 > *, KN< pmesh3 > *, long >(&set_initinit)); + map_type_of_map[make_pair(atype< long >( ), atype< pmesh3 >( ))] = atype< KN< pmesh3 > * >( ); // vector + + Dcl_Type< Resize< KN< pmesh3 > > >( ); + Add< KN< pmesh3 > * >("resize", ".", new OneOperator1< Resize< KN< pmesh3 > >, KN< pmesh3 > * >(to_Resize)); + Add< Resize< KN< pmesh3 > > >("(", "", new OneOperator2_< KN< pmesh3 > *, Resize< KN< pmesh3 > >, long >(resizeandclean1)); +} -template -bool pfer_refresh3(pair *,int> p) -{ - typedef typename v_fes::FESpace FESpace; - int n = 0; - if( p.first->x() ) n = p.first->x()->N(); - const FESpace * Vho = p.first->Vh; - p.first->Vh= p.first->newVh(); - if ( n && n != p.first->Vh->NbOfDF) - * p.first = new KN(p.first->Vh->NbOfDF,K()); - return Vho != (const FESpace * ) p.first->Vh;// FE change !!! -} - -template -KN_ listoflabel(Stack s, Mesh const * const & pTh) -{ - set sl; - for(int e=0; e< pTh->nbBrdElmts();++e) - sl.insert(pTh->be(e).lab); - - long n = sl.size(),ii=0; - long * p = Add2StackOfPtr2FreeA(s,new long[n]); // mark to be delete .. - KN_ A(p,n); - for(auto i=sl.begin();i!=sl.end();++i) - A[ii++]= *i; - ffassert(ii== n); - if(verbosity>99) cout << " -- listoflabels "<< A << endl; - return A; +// 3D surface +void init_meshS_array( ) { + Dcl_Type< KN< pmeshS > * >(0, ::DestroyKN< pmeshS >); + atype< KN< pmeshS > * >( )->Add("[", "", new OneOperator2_< pmeshS *, KN< pmeshS > *, long >(get_elementp_< pmeshS, KN< pmeshS > *, long >)); + TheOperators->Add("<-", new OneOperator2_< KN< pmeshS > *, KN< pmeshS > *, long >(&set_initinit)); + map_type_of_map[make_pair(atype< long >( ), atype< pmeshS >( ))] = atype< KN< pmeshS > * >( ); // vector + + Dcl_Type< Resize< KN< pmeshS > > >( ); + Add< KN< pmeshS > * >("resize", ".", new OneOperator1< Resize< KN< pmeshS > >, KN< pmeshS > * >(to_Resize)); + Add< Resize< KN< pmeshS > > >("(", "", new OneOperator2_< KN< pmeshS > *, Resize< KN< pmeshS > >, long >(resizeandclean1)); +} + +// 3D Line +void init_meshL_array( ) { + Dcl_Type< KN< pmeshL > * >(0, ::DestroyKN< pmeshL >); + atype< KN< pmeshL > * >( )->Add("[", "", new OneOperator2_< pmeshL *, KN< pmeshL > *, long >(get_elementp_< pmeshL, KN< pmeshL > *, long >)); + TheOperators->Add("<-", new OneOperator2_< KN< pmeshL > *, KN< pmeshL > *, long >(&set_initinit)); + map_type_of_map[make_pair(atype< long >( ), atype< pmeshL >( ))] = atype< KN< pmeshL > * >( ); // vector + + Dcl_Type< Resize< KN< pmeshL > > >( ); + Add< KN< pmeshL > * >("resize", ".", new OneOperator1< Resize< KN< pmeshL > >, KN< pmeshL > * >(to_Resize)); + Add< Resize< KN< pmeshL > > >("(", "", new OneOperator2_< KN< pmeshL > *, Resize< KN< pmeshL > >, long >(resizeandclean1)); +} + +template< class K, class v_fes > +bool pfer_refresh3(pair< FEbase< K, v_fes > *, int > p) { + typedef typename v_fes::FESpace FESpace; + int n = 0; + if (p.first->x( )) n = p.first->x( )->N( ); + const FESpace *Vho = p.first->Vh; + p.first->Vh = p.first->newVh( ); + if (n && n != p.first->Vh->NbOfDF) *p.first = new KN< K >(p.first->Vh->NbOfDF, K( )); + return Vho != (const FESpace *)p.first->Vh; // FE change !!! +} + +template< class Mesh > +KN_< long > listoflabel(Stack s, Mesh const *const &pTh) { + set< long > sl; + for (int e = 0; e < pTh->nbBrdElmts( ); ++e) sl.insert(pTh->be(e).lab); + + long n = sl.size( ), ii = 0; + long *p = Add2StackOfPtr2FreeA< long >(s, new long[n]); // mark to be delete .. + KN_< long > A(p, n); + for (auto i = sl.begin( ); i != sl.end( ); ++i) A[ii++] = *i; + ffassert(ii == n); + if (verbosity > 99) cout << " -- listoflabels " << A << endl; + return A; }; -template -KN_ listofregion(Stack s, Mesh const * const & pTh) -{ - const Mesh & Th=*pTh; - set sl; - for(int t=0; t< Th.nt;++t) - sl.insert(Th[t].lab); - - long n = sl.size(),ii=0; - long * p = Add2StackOfPtr2FreeA(s,new long[n]); // mark to be delete .. - KN_ A(p,n); - for(auto i=sl.begin();i!=sl.end();++i) - A[ii++]= *i; - if(verbosity>99) cout << " -- listofregions "<< A << endl; - return A; +template< class Mesh > +KN_< long > listofregion(Stack s, Mesh const *const &pTh) { + const Mesh &Th = *pTh; + set< long > sl; + for (int t = 0; t < Th.nt; ++t) sl.insert(Th[t].lab); + + long n = sl.size( ), ii = 0; + long *p = Add2StackOfPtr2FreeA< long >(s, new long[n]); // mark to be delete .. + KN_< long > A(p, n); + for (auto i = sl.begin( ); i != sl.end( ); ++i) A[ii++] = *i; + if (verbosity > 99) cout << " -- listofregions " << A << endl; + return A; }; /* // to see write u(x,y,z) 31 jan 2020 FH... @@ -2820,530 +2645,480 @@ class Op4_pfeK : public quad_function< pair< FEbase< K, v_fesL > *, int >, R, R, }; }; */ -template -void init_lgmesh1() -{ - typedef const Mesh3 * pmesh3; - // 3D volume - Dcl_Type >(); - Dcl_Type >( ); - Dcl_Type::Adj>( ); - - Dcl_Type::BE >( ); - Dcl_Type >( ); - - atype()->AddCast( - new E_F1_funcT >(Cast >), - new E_F1_funcT >(Cast >), - new E_F1_funcT >(Cast >) - - ); - - Add("[","",new OneOperator2_,pmesh3,long>(get_element)); - Add("[","",new OneOperator2_,pmesh3*,long>(get_element)); - Add("(","",new OneOperator2_,pmesh3,long>(get_vertex)); - Add("(","",new OneOperator2_,pmesh3*,long>(get_vertex)); +template< class Mesh3 > +void init_lgmesh1( ) { + typedef const Mesh3 *pmesh3; + // 3D volume + Dcl_Type< GlgVertex< Mesh3 > >( ); + Dcl_Type< GlgElement< Mesh3 > >( ); + Dcl_Type< typename GlgElement< Mesh3 >::Adj >( ); + + Dcl_Type< typename GlgBoundaryElement< Mesh3 >::BE >( ); + Dcl_Type< GlgBoundaryElement< Mesh3 > >( ); + + atype< long >( )->AddCast(new E_F1_funcT< long, GlgVertex< Mesh3 > >(Cast< long, GlgVertex< Mesh3 > >), new E_F1_funcT< long, GlgElement< Mesh3 > >(Cast< long, GlgElement< Mesh3 > >), + new E_F1_funcT< long, GlgBoundaryElement< Mesh3 > >(Cast< long, GlgBoundaryElement< Mesh3 > >) + + ); + + Add< pmesh3 >("[", "", new OneOperator2_< GlgElement< Mesh3 >, pmesh3, long >(get_element)); + Add< pmesh3 * >("[", "", new OneOperator2_< GlgElement< Mesh3 >, pmesh3 *, long >(get_element)); + Add< pmesh3 >("(", "", new OneOperator2_< GlgVertex< Mesh3 >, pmesh3, long >(get_vertex)); + Add< pmesh3 * >("(", "", new OneOperator2_< GlgVertex< Mesh3 >, pmesh3 *, long >(get_vertex)); // second case of Th(x,y,z) ???? FH attention deja fait dans Op4_Mesh32mp now remove - Add("(", "", new OneQuadOperator< Op3_MeshDmp,typename Op3_MeshDmp::Op >); - - Add("be",".",new OneOperator1_::BE,pmesh3*>(Build)); - Add >("adj",".",new OneOperator1_::Adj,GlgElement >(Build)); - Add::BE>("(","",new OneOperator2_,typename GlgBoundaryElement::BE,long>(get_element)); - Add::Adj>("(","",new OneOperator2_,typename GlgElement::Adj,long*>(get_adj)); - TheOperators->Add("==", new OneBinaryOperator,GlgElement > >); - TheOperators->Add("!=", new OneBinaryOperator,GlgElement > >); - TheOperators->Add("<", new OneBinaryOperator,GlgElement > >); - TheOperators->Add("<=", new OneBinaryOperator,GlgElement > >); - - Add >("label",".",new OneOperator1_ >(getlab)); - Add >("measure",".",new OneOperator1_ >(getmesb)); - Add >("Element",".",new OneOperator1_ ,GlgBoundaryElement >(getElement)); - Add >("whoinElement",".",new OneOperator1_ >(NuElement)); - Add >("N",".",new OneOperator1_ >(NElement)); - - - Add >("[","",new OneOperator2_ ,GlgElement ,long>(get_element)); - Add >("[","",new OneOperator2_,GlgBoundaryElement,long>(get_element)); - - Add >("P",".",new OneOperator1_ >(getP)); - - Add >("x",".",new OneOperator1_ >(getx)); - Add >("y",".",new OneOperator1_ >(gety)); - Add >("z",".",new OneOperator1_ >(getz)); - - Add >("label",".",new OneOperator1_ >(getlab)); - Add >("label",".",new OneOperator1_ >(getlab)); - Add >("region",".",new OneOperator1_ >(getlab)); - Add >("mesure",".",new OneOperator1_ >(getmes)); - Add >("measure",".",new OneOperator1_ >(getmes)); - Add("mesure",".",new OneOperator1(pmesh_mes)); - Add("measure",".",new OneOperator1(pmesh_mes)); - Add("bordermesure",".",new OneOperator1(pmesh_mesb)); - Add("bordermeasure",".",new OneOperator1(pmesh_mesb)); - Add("nt",".",new OneOperator1(pmesh_nt)); - Add("nv",".",new OneOperator1(pmesh_nv)); - Add("nbe",".",new OneOperator1(pmesh_nbe)); - Add("hmax",".",new OneOperator1(pmesh_hmax)); - Add("hmin",".",new OneOperator1(pmesh_hmin)); - - Add("nbnomanifold",".",new OneOperator1(pmesh_nadjnomanifold)); - -} -//using Fem2D::R3; -KN * set_initR3( KN *a, R3 b){ - SHOWVERB( cout << " set_init array R3" << " " << &b << endl); - a->init(3); (*a)[0]=b.x;(*a)[1]=b.y;(*a)[2]=b.z; return a;} + Add< pmesh3 * >("(", "", new OneQuadOperator< Op3_MeshDmp< Mesh3 >, typename Op3_MeshDmp< Mesh3 >::Op >); + + Add< pmesh3 * >("be", ".", new OneOperator1_< typename GlgBoundaryElement< Mesh3 >::BE, pmesh3 * >(Build)); + Add< GlgElement< Mesh3 > >("adj", ".", new OneOperator1_< typename GlgElement< Mesh3 >::Adj, GlgElement< Mesh3 > >(Build)); + Add< typename GlgBoundaryElement< Mesh3 >::BE >("(", "", new OneOperator2_< GlgBoundaryElement< Mesh3 >, typename GlgBoundaryElement< Mesh3 >::BE, long >(get_element)); + Add< typename GlgElement< Mesh3 >::Adj >("(", "", new OneOperator2_< GlgElement< Mesh3 >, typename GlgElement< Mesh3 >::Adj, long * >(get_adj)); + TheOperators->Add("==", new OneBinaryOperator< Op2_eq< GlgElement< Mesh3 >, GlgElement< Mesh3 > > >); + TheOperators->Add("!=", new OneBinaryOperator< Op2_ne< GlgElement< Mesh3 >, GlgElement< Mesh3 > > >); + TheOperators->Add("<", new OneBinaryOperator< Op2_lt< GlgElement< Mesh3 >, GlgElement< Mesh3 > > >); + TheOperators->Add("<=", new OneBinaryOperator< Op2_le< GlgElement< Mesh3 >, GlgElement< Mesh3 > > >); + + Add< GlgBoundaryElement< Mesh3 > >("label", ".", new OneOperator1_< long, GlgBoundaryElement< Mesh3 > >(getlab)); + Add< GlgBoundaryElement< Mesh3 > >("measure", ".", new OneOperator1_< double, GlgBoundaryElement< Mesh3 > >(getmesb)); + Add< GlgBoundaryElement< Mesh3 > >("Element", ".", new OneOperator1_< GlgElement< Mesh3 >, GlgBoundaryElement< Mesh3 > >(getElement)); + Add< GlgBoundaryElement< Mesh3 > >("whoinElement", ".", new OneOperator1_< long, GlgBoundaryElement< Mesh3 > >(NuElement)); + Add< GlgBoundaryElement< Mesh3 > >("N", ".", new OneOperator1_< R3, GlgBoundaryElement< Mesh3 > >(NElement)); + + Add< GlgElement< Mesh3 > >("[", "", new OneOperator2_< GlgVertex< Mesh3 >, GlgElement< Mesh3 >, long >(get_element)); + Add< GlgBoundaryElement< Mesh3 > >("[", "", new OneOperator2_< GlgVertex< Mesh3 >, GlgBoundaryElement< Mesh3 >, long >(get_element)); + + Add< GlgVertex< Mesh3 > >("P", ".", new OneOperator1_< R3, GlgVertex< Mesh3 > >(getP)); + + Add< GlgVertex< Mesh3 > >("x", ".", new OneOperator1_< R, GlgVertex< Mesh3 > >(getx)); + Add< GlgVertex< Mesh3 > >("y", ".", new OneOperator1_< R, GlgVertex< Mesh3 > >(gety)); + Add< GlgVertex< Mesh3 > >("z", ".", new OneOperator1_< R, GlgVertex< Mesh3 > >(getz)); + + Add< GlgVertex< Mesh3 > >("label", ".", new OneOperator1_< long, GlgVertex< Mesh3 > >(getlab)); + Add< GlgElement< Mesh3 > >("label", ".", new OneOperator1_< long, GlgElement< Mesh3 > >(getlab)); + Add< GlgElement< Mesh3 > >("region", ".", new OneOperator1_< long, GlgElement< Mesh3 > >(getlab)); + Add< GlgElement< Mesh3 > >("mesure", ".", new OneOperator1_< double, GlgElement< Mesh3 > >(getmes)); + Add< GlgElement< Mesh3 > >("measure", ".", new OneOperator1_< double, GlgElement< Mesh3 > >(getmes)); + Add< pmesh3 * >("mesure", ".", new OneOperator1< double, pmesh3 * >(pmesh_mes)); + Add< pmesh3 * >("measure", ".", new OneOperator1< double, pmesh3 * >(pmesh_mes)); + Add< pmesh3 * >("bordermesure", ".", new OneOperator1< double, pmesh3 * >(pmesh_mesb)); + Add< pmesh3 * >("bordermeasure", ".", new OneOperator1< double, pmesh3 * >(pmesh_mesb)); + Add< pmesh3 * >("nt", ".", new OneOperator1< long, pmesh3 * >(pmesh_nt)); + Add< pmesh3 * >("nv", ".", new OneOperator1< long, pmesh3 * >(pmesh_nv)); + Add< pmesh3 * >("nbe", ".", new OneOperator1< long, pmesh3 * >(pmesh_nbe)); + Add< pmesh3 * >("hmax", ".", new OneOperator1< double, pmesh3 * >(pmesh_hmax)); + Add< pmesh3 * >("hmin", ".", new OneOperator1< double, pmesh3 * >(pmesh_hmin)); + + Add< pmesh3 * >("nbnomanifold", ".", new OneOperator1< long, pmesh3 * >(pmesh_nadjnomanifold)); +} +// using Fem2D::R3; +KN< double > *set_initR3(KN< double > *a, R3 b) { + SHOWVERB(cout << " set_init array R3" << " " << &b << endl); + a->init(3); + (*a)[0] = b.x; + (*a)[1] = b.y; + (*a)[2] = b.z; + return a; +} /* KN * set_initR3( KN *a, R3 * b){ SHOWVERB( cout << " set_init array R3" << " " << &b << endl); a->init(3); (*a)[0]=b->x;(*a)[1]=b->y;(*a)[2]=b->z; return a;} */ -KN_ copy_R3( KN_ a, R3 b){ - SHOWVERB( cout << " set_init array R3" << " " << &b << endl); - ffassert(a.N()==3); (a)[0]=b.x;(a)[1]=b.y;(a)[2]=b.z; return a;} +KN_< double > copy_R3(KN_< double > a, R3 b) { + SHOWVERB(cout << " set_init array R3" << " " << &b << endl); + ffassert(a.N( ) == 3); + (a)[0] = b.x; + (a)[1] = b.y; + (a)[2] = b.z; + return a; +} /*KN_ copy_R3( KN_ a, R3 *b){ SHOWVERB( cout << " set_init array R3" << " " << &b << endl); ffassert(a.N()==3); (a)[0]=b->x;(a)[1]=b->y;(a)[2]=b->z; return a;} */ +AnyType Array2R3(Stack, const AnyType &b) { + KN_< double > a = GetAny< KN_< double > >(b); + ffassert(a.N( ) >= 3); + R3 P((double *)a); + return SetAny< R3 >(P); +} +AnyType pArray2R3(Stack, const AnyType &b) { + KN_< double > a = *GetAny< KN< double > * >(b); + ffassert(a.N( ) >= 3); + R3 P((double *)a); + return SetAny< R3 >(P); +} + +void init_lgmesh3( ) { + if (verbosity && (mpirank == 0)) cout << "lg_mesh3 "; -AnyType Array2R3(Stack,const AnyType &b) { - KN_ a = GetAny> (b); - ffassert(a.N()>=3); - R3 P((double*)a); - return SetAny(P);} -AnyType pArray2R3(Stack,const AnyType &b) { - KN_ a = *GetAny*> (b); - ffassert(a.N()>=3); - R3 P((double*)a); - return SetAny(P);} - -void init_lgmesh3() { - if(verbosity&&(mpirank==0)) cout <<"lg_mesh3 "; - - // Global.Add("buildmesh","(",new OneOperatorCode); - // Global.Add("buildmesh","(",new OneOperatorCode); - - //3D volume - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); + // Global.Add("buildmesh","(",new OneOperatorCode); + // Global.Add("buildmesh","(",new OneOperatorCode); + + // 3D volume + atype< pmesh3 >( )->AddCast(new E_F1_funcT< pmesh3, pmesh3 * >(UnRef< pmesh3 >)); + atype< pfes3 >( )->AddCast(new E_F1_funcT< pfes3, pfes3 * >(UnRef< pfes3 >)); + atype< pf3rbase >( )->AddCast(new E_F1_funcT< pf3rbase, pf3rbase >(UnRef< pf3rbase >)); + atype< pf3cbase >( )->AddCast(new E_F1_funcT< pf3cbase, pf3cbase >(UnRef< pf3cbase >)); // 3D surface - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); + atype< pmeshS >( )->AddCast(new E_F1_funcT< pmeshS, pmeshS * >(UnRef< pmeshS >)); + atype< pfesS >( )->AddCast(new E_F1_funcT< pfesS, pfesS * >(UnRef< pfesS >)); + atype< pfSrbase >( )->AddCast(new E_F1_funcT< pfSrbase, pfSrbase >(UnRef< pfSrbase >)); + atype< pfScbase >( )->AddCast(new E_F1_funcT< pfScbase, pfScbase >(UnRef< pfScbase >)); // 3D curve - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - atype()->AddCast( new E_F1_funcT(UnRef)); - //3D volume - Add("[]",".",new OneOperator1 *,pf3r>(pf3r2vect)); - Add("[]",".",new OneOperator1 *,pf3c>(pf3r2vect)); - Add("(","",new OneQuadOperator,Op4_pf32K::Op> ); - Add("(","",new OneQuadOperator,Op4_pf32K::Op> ); - //3D surface - Add("[]",".",new OneOperator1 *,pfSr>(pf3r2vect)); - Add("[]",".",new OneOperator1 *,pfSc>(pf3r2vect)); - Add("(","",new OneQuadOperator,Op4_pfS2K::Op> ); - Add("(","",new OneQuadOperator,Op4_pfS2K::Op> ); - - //3D curve - Add("[]",".",new OneOperator1 *,pfLr>(pf3r2vect)); - Add("[]",".",new OneOperator1 *,pfLc>(pf3r2vect)); - Add("(","",new OneQuadOperator,Op4_pfL2K::Op> ); - Add("(","",new OneQuadOperator,Op4_pfL2K::Op> ); - Add("(","",new OneTernaryOperator,Op3_pfL2K::Op> ); - Add("(","",new OneTernaryOperator,Op3_pfL2K::Op> ); - Add("(","",new OneBinaryOperatorCode,Op2_pfL2K::Op> ); - Add("(","",new OneBinaryOperatorCode,Op2_pfL2K::Op> ); - - Add("(","",new OneQuadOperator,Op4_K2R::Op> ); + atype< pmeshL >( )->AddCast(new E_F1_funcT< pmeshL, pmeshL * >(UnRef< pmeshL >)); + atype< pfesL >( )->AddCast(new E_F1_funcT< pfesL, pfesL * >(UnRef< pfesL >)); + atype< pfLrbase >( )->AddCast(new E_F1_funcT< pfLrbase, pfLrbase >(UnRef< pfLrbase >)); + atype< pfLcbase >( )->AddCast(new E_F1_funcT< pfLcbase, pfLcbase >(UnRef< pfLcbase >)); + // 3D volume + Add< pf3r >("[]", ".", new OneOperator1< KN< double > *, pf3r >(pf3r2vect< R, v_fes3 >)); + Add< pf3c >("[]", ".", new OneOperator1< KN< Complex > *, pf3c >(pf3r2vect< Complex, v_fes3 >)); + Add< pf3r >("(", "", new OneQuadOperator< Op4_pf32K< R, v_fes3 >, Op4_pf32K< R, v_fes3 >::Op >); + Add< pf3c >("(", "", new OneQuadOperator< Op4_pf32K< Complex, v_fes3 >, Op4_pf32K< Complex, v_fes3 >::Op >); + // 3D surface + Add< pfSr >("[]", ".", new OneOperator1< KN< double > *, pfSr >(pf3r2vect< R, v_fesS >)); + Add< pfSc >("[]", ".", new OneOperator1< KN< Complex > *, pfSc >(pf3r2vect< Complex, v_fesS >)); + Add< pfSr >("(", "", new OneQuadOperator< Op4_pfS2K< R, v_fesS >, Op4_pfS2K< R, v_fesS >::Op >); + Add< pfSc >("(", "", new OneQuadOperator< Op4_pfS2K< Complex, v_fesS >, Op4_pfS2K< Complex, v_fesS >::Op >); + + // 3D curve + Add< pfLr >("[]", ".", new OneOperator1< KN< double > *, pfLr >(pf3r2vect< R, v_fesL >)); + Add< pfLc >("[]", ".", new OneOperator1< KN< Complex > *, pfLc >(pf3r2vect< Complex, v_fesL >)); + Add< pfLr >("(", "", new OneQuadOperator< Op4_pfL2K< R, v_fesL >, Op4_pfL2K< R, v_fesL >::Op >); + Add< pfLc >("(", "", new OneQuadOperator< Op4_pfL2K< Complex, v_fesL >, Op4_pfL2K< Complex, v_fesL >::Op >); + Add< pfLr >("(", "", new OneTernaryOperator< Op3_pfL2K< R, v_fesL >, Op3_pfL2K< R, v_fesL >::Op >); + Add< pfLc >("(", "", new OneTernaryOperator< Op3_pfL2K< Complex, v_fesL >, Op3_pfL2K< Complex, v_fesL >::Op >); + Add< pfLr >("(", "", new OneBinaryOperatorCode< Op2_pfL2K< R, v_fesL >, Op2_pfL2K< R, v_fesL >::Op >); + Add< pfLc >("(", "", new OneBinaryOperatorCode< Op2_pfL2K< Complex, v_fesL >, Op2_pfL2K< Complex, v_fesL >::Op >); + + Add< double >("(", "", new OneQuadOperator< Op4_K2R< R >, Op4_K2R< R >::Op >); // Add("(","",new OneTernaryOperator,Op3_K2R::Op> ); // FH stupide - Add("(","",new OneQuadOperator,Op4_K2R::Op> ); + Add< Complex >("(", "", new OneQuadOperator< Op4_K2R< Complex >, Op4_K2R< Complex >::Op >); - // Th(x,y,z) first case ... remove old case - // Add("(","",new OneQuadOperator ); - // Add("(","",new OneQuadOperator ); - - + // Th(x,y,z) first case ... remove old case + // Add("(","",new OneQuadOperator ); + // Add("(","",new OneQuadOperator ); - //3D volume - TheOperators->Add("<-", new OneOperator2_(&initMesh)); + // 3D volume + TheOperators->Add("<-", new OneOperator2_< pmesh3 *, pmesh3 *, string * >(&initMesh)); // use for : mesh Th = readmesh ( ...); - TheOperators->Add("<-", new OneOperator2_(&set_copy_incr)); - TheOperators->Add("=", new OneOperator2(&set_eqdestroy_incr)); - //3D surface - TheOperators->Add("<-", new OneOperator2_(&initMesh)); + TheOperators->Add("<-", new OneOperator2_< pmesh3 *, pmesh3 *, pmesh3 >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pmesh3 *, pmesh3 *, pmesh3 >(&set_eqdestroy_incr)); + // 3D surface + TheOperators->Add("<-", new OneOperator2_< pmeshS *, pmeshS *, string * >(&initMesh)); // use for : mesh Th = readmesh ( ...); - TheOperators->Add("<-", new OneOperator2_(&set_copy_incr)); - TheOperators->Add("=", new OneOperator2(&set_eqdestroy_incr)); - //3D line - TheOperators->Add("<-", new OneOperator2_(&initMesh)); + TheOperators->Add("<-", new OneOperator2_< pmeshS *, pmeshS *, pmeshS >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pmeshS *, pmeshS *, pmeshS >(&set_eqdestroy_incr)); + // 3D line + TheOperators->Add("<-", new OneOperator2_< pmeshL *, pmeshL *, string * >(&initMesh)); // use for : mesh Th = readmesh ( ...); - TheOperators->Add("<-", new OneOperator2_(&set_copy_incr)); - TheOperators->Add("=", new OneOperator2(&set_eqdestroy_incr)); - - Global.Add("readmesh3","(",new OneOperatorCode); - - Global.Add("readmeshS","(",new OneOperatorCode); - Global.Add("readmeshL","(",new OneOperatorCode); - Global.Add("savemesh","(",new OneOperatorCode); - Global.Add("savemesh","(",new OneOperatorCode); - Global.Add("savemesh","(",new OneOperatorCode); - Global.Add("savesurfacemesh","(",new OneOperatorCode); - - Global.Add("buildmeshL","(",new OneOperator1s_(BuildMeshCurve3)); - - Add("x",".",new OneOperator1_(getx)); - Add("y",".",new OneOperator1_(gety)); - Add("z",".",new OneOperator1_(getz)); - - init_lgmesh1(); - init_lgmesh1(); - init_lgmesh1(); - - Add("Gamma",".",new OneOperator1s_(pmesh3_gamma)); - Add("Gamma",".",new OneOperator1s_(pmeshS_gamma)); - - Global.Add("solidangle","(",new OneOperator4_(SolidAngle)); - Global.Add("solidangle","(",new OneOperator2_ >(SolidAngle)); - Global.Add("solidangle","(",new OneOperator2_ >(SolidAngle)); - Global.Add("solidangle","(",new OneOperator3_,long >(SolidAngle)); - // Volume with a Capital because volume is the set in integral - Global.Add("Volume","(",new OneOperator4_(Volume)); - Global.Add("Volume","(",new OneOperator2_ >(Volume)); - Global.Add("Volume","(",new OneOperator2_ >(Volume)); - Global.Add("Volume","(",new OneOperator3_,long >(Volume)); - - //GlgElement - - // Morice: La version 2D de la suite sont dans [[lgmesh.cpp]] chercher MakePtrFE2 - // 3D volume - TheOperators->Add("<-", - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3), - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3) //, - // new OneOperator2_(MakePtr) - ); - TheOperators->Add("<-", - new OneOperatorMakePtrFE3(atype()), // scalar case - new OneOperatorMakePtrFE3(atype()), // vect case - new OneOperatorMakePtrFE3(atype()), // scalar complex case - new OneOperatorMakePtrFE3(atype()) // vect complex case - ); - TheOperators->Add("<-", - new OneOperator2_(&set_copy_incr)); - TheOperators->Add("=", - new OneOperator2(&set_eqdestroy_incr) - ); - TheOperators->Add("=", - new OneOperator2_ >(set_fe3) , // modif template - new OneOperator2_ >(set_fe3) // modif template - ) ; + TheOperators->Add("<-", new OneOperator2_< pmeshL *, pmeshL *, pmeshL >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pmeshL *, pmeshL *, pmeshL >(&set_eqdestroy_incr)); + + Global.Add("readmesh3", "(", new OneOperatorCode< ReadMesh3 >); + + Global.Add("readmeshS", "(", new OneOperatorCode< ReadMeshS >); + Global.Add("readmeshL", "(", new OneOperatorCode< ReadMeshL >); + Global.Add("savemesh", "(", new OneOperatorCode< SaveMesh3 >); + Global.Add("savemesh", "(", new OneOperatorCode< SaveMeshS >); + Global.Add("savemesh", "(", new OneOperatorCode< SaveMeshL >); + Global.Add("savesurfacemesh", "(", new OneOperatorCode< SaveSurfaceMesh3 >); + + Global.Add("buildmeshL", "(", new OneOperator1s_< pmeshL, const E_BorderN * >(BuildMeshCurve3)); + + Add< R3 >("x", ".", new OneOperator1_< R, R3 >(getx)); + Add< R3 >("y", ".", new OneOperator1_< R, R3 >(gety)); + Add< R3 >("z", ".", new OneOperator1_< R, R3 >(getz)); + + init_lgmesh1< Mesh3 >( ); + init_lgmesh1< MeshS >( ); + init_lgmesh1< MeshL >( ); + + Add< pmesh3 * >("Gamma", ".", new OneOperator1s_< pmeshS, pmesh3 * >(pmesh3_gamma)); + Add< pmeshS * >("Gamma", ".", new OneOperator1s_< pmeshL, pmeshS * >(pmeshS_gamma)); + + Global.Add("solidangle", "(", new OneOperator4_< R, R3, R3, R3, R3 >(SolidAngle)); + Global.Add("solidangle", "(", new OneOperator2_< R, R3, GlgBoundaryElement< Mesh3 > >(SolidAngle)); + Global.Add("solidangle", "(", new OneOperator2_< R, R3, GlgElement< MeshS > >(SolidAngle)); + Global.Add("solidangle", "(", new OneOperator3_< R, R3, GlgElement< Mesh3 >, long >(SolidAngle)); + // Volume with a Capital because volume is the set in integral + Global.Add("Volume", "(", new OneOperator4_< R, R3, R3, R3, R3 >(Volume)); + Global.Add("Volume", "(", new OneOperator2_< R, R3, GlgBoundaryElement< Mesh3 > >(Volume)); + Global.Add("Volume", "(", new OneOperator2_< R, R3, GlgElement< MeshS > >(Volume)); + Global.Add("Volume", "(", new OneOperator3_< R, R3, GlgElement< Mesh3 >, long >(Volume)); + + // GlgElement + + // Morice: La version 2D de la suite sont dans [[lgmesh.cpp]] chercher MakePtrFE2 + // 3D volume + TheOperators->Add("<-", new OneOperator2_< pf3rbase *, pf3rbase *, pfes3 * >(MakePtrFE3_2), new OneOperator3_< pf3rbasearray *, pf3rbasearray *, pfes3 *, long >(MakePtrFE3_3), + new OneOperator2_< pf3cbase *, pf3cbase *, pfes3 * >(MakePtrFE3_2), new OneOperator3_< pf3cbasearray *, pf3cbasearray *, pfes3 *, long >(MakePtrFE3_3) //, + // new OneOperator2_(MakePtr) + ); + TheOperators->Add("<-", new OneOperatorMakePtrFE3< double, v_fes3 >(atype< double >( )), // scalar case + new OneOperatorMakePtrFE3< double, v_fes3 >(atype< E_Array >( )), // vect case + new OneOperatorMakePtrFE3< Complex, v_fes3 >(atype< Complex >( )), // scalar complex case + new OneOperatorMakePtrFE3< Complex, v_fes3 >(atype< E_Array >( )) // vect complex case + ); + TheOperators->Add("<-", new OneOperator2_< pfes3 *, pfes3 *, pfes3 >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pfes3 *, pfes3 *, pfes3 >(&set_eqdestroy_incr)); + TheOperators->Add("=", new OneOperator2_< pf3r, pf3r, double, E_F_StackF0F0opt2< double > >(set_fe3< double, v_fes3 >), // modif template + new OneOperator2_< pf3c, pf3c, Complex, E_F_StackF0F0opt2< Complex > >(set_fe3< Complex, v_fes3 >) // modif template + ); -// 3D surface -TheOperators->Add("<-", - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3), - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3) //, - // new OneOperator2_(MakePtr) - ); -TheOperators->Add("<-", - new OneOperatorMakePtrFE3(atype()), // scalar case - new OneOperatorMakePtrFE3(atype()), // vect case - new OneOperatorMakePtrFE3(atype()), // scalar complex case - new OneOperatorMakePtrFE3(atype()) // vect complex case - ); -TheOperators->Add("<-", - new OneOperator2_(&set_copy_incr)); -TheOperators->Add("=", - new OneOperator2(&set_eqdestroy_incr) - ); -TheOperators->Add("=", - new OneOperator2_ >(set_fe3) , // modif/ use template - new OneOperator2_ >(set_fe3) // modif/ use template - ) ; - - // 3D curve - TheOperators->Add("<-", - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3), - new OneOperator2_(MakePtrFE3_2), - new OneOperator3_(MakePtrFE3_3) //, - // new OneOperator2_(MakePtr) - ); - TheOperators->Add("<-", - new OneOperatorMakePtrFE3(atype()), // scalar case - new OneOperatorMakePtrFE3(atype()), // vect case - new OneOperatorMakePtrFE3(atype()), // scalar complex case - new OneOperatorMakePtrFE3(atype()) // vect complex case - ); - TheOperators->Add("<-", - new OneOperator2_(&set_copy_incr)); - TheOperators->Add("=", - new OneOperator2(&set_eqdestroy_incr) - ); - TheOperators->Add("=", - new OneOperator2_ >(set_fe3) , // modif/ use template - new OneOperator2_ >(set_fe3) // modif/ use template - ) ; - // to write u(x,y,z) when u si FE function on Surface or Line .. FH. jan 2020. + // 3D surface + TheOperators->Add("<-", new OneOperator2_< pfSrbase *, pfSrbase *, pfesS * >(MakePtrFE3_2), new OneOperator3_< pfSrbasearray *, pfSrbasearray *, pfesS *, long >(MakePtrFE3_3), + new OneOperator2_< pfScbase *, pfScbase *, pfesS * >(MakePtrFE3_2), new OneOperator3_< pfScbasearray *, pfScbasearray *, pfesS *, long >(MakePtrFE3_3) //, + // new OneOperator2_(MakePtr) + ); + TheOperators->Add("<-", new OneOperatorMakePtrFE3< double, v_fesS >(atype< double >( )), // scalar case + new OneOperatorMakePtrFE3< double, v_fesS >(atype< E_Array >( )), // vect case + new OneOperatorMakePtrFE3< Complex, v_fesS >(atype< Complex >( )), // scalar complex case + new OneOperatorMakePtrFE3< Complex, v_fesS >(atype< E_Array >( )) // vect complex case + ); + TheOperators->Add("<-", new OneOperator2_< pfesS *, pfesS *, pfesS >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pfesS *, pfesS *, pfesS >(&set_eqdestroy_incr)); + TheOperators->Add("=", new OneOperator2_< pfSr, pfSr, double, E_F_StackF0F0opt2< double > >(set_fe3< double, v_fesS >), // modif/ use template + new OneOperator2_< pfSc, pfSc, Complex, E_F_StackF0F0opt2< Complex > >(set_fe3< Complex, v_fesS >) // modif/ use template + ); + + // 3D curve + TheOperators->Add("<-", new OneOperator2_< pfLrbase *, pfLrbase *, pfesL * >(MakePtrFE3_2), new OneOperator3_< pfLrbasearray *, pfLrbasearray *, pfesL *, long >(MakePtrFE3_3), + new OneOperator2_< pfLcbase *, pfLcbase *, pfesL * >(MakePtrFE3_2), new OneOperator3_< pfLcbasearray *, pfLcbasearray *, pfesL *, long >(MakePtrFE3_3) //, + // new OneOperator2_(MakePtr) + ); + TheOperators->Add("<-", new OneOperatorMakePtrFE3< double, v_fesL >(atype< double >( )), // scalar case + new OneOperatorMakePtrFE3< double, v_fesL >(atype< E_Array >( )), // vect case + new OneOperatorMakePtrFE3< Complex, v_fesL >(atype< Complex >( )), // scalar complex case + new OneOperatorMakePtrFE3< Complex, v_fesL >(atype< E_Array >( )) // vect complex case + ); + TheOperators->Add("<-", new OneOperator2_< pfesL *, pfesL *, pfesL >(&set_copy_incr)); + TheOperators->Add("=", new OneOperator2< pfesL *, pfesL *, pfesL >(&set_eqdestroy_incr)); + TheOperators->Add("=", new OneOperator2_< pfLr, pfLr, double, E_F_StackF0F0opt2< double > >(set_fe3< double, v_fesL >), // modif/ use template + new OneOperator2_< pfLc, pfLc, Complex, E_F_StackF0F0opt2< Complex > >(set_fe3< Complex, v_fesL >) // modif/ use template + ); + // to write u(x,y,z) when u si FE function on Surface or Line .. FH. jan 2020. /* Add< pfSr >("(", "", new OneQuadOperator< Op4_pfeK< R, v_fesS>, Op4_pfeK< R,v_fesS >::Op >); Add< pfSc >("(", "", new OneQuadOperator< Op4_pfeK< Complex,v_fesS >, Op4_pfeK< Complex,v_fesS >::Op >); Add< pfLr >("(", "", new OneQuadOperator< Op4_pfeK< R,v_fesL >, Op4_pfeK< R,v_fesL >::Op >); Add< pfLc >("(", "", new OneQuadOperator< Op4_pfeK< Complex, v_fesL>, Op4_pfeK< Complex,v_fesL >::Op >); */ - - TheOperators->Add("<-", - new OneOperator2 *,KN *,R3>(set_initR3) -// , new OneOperator2 *,KN *,R3*>(set_initR3) - ); -TheOperators->Add("=", - new OneOperator2 ,KN_ ,R3>(copy_R3) - // , new OneOperator2 ,KN_ ,R3*>(copy_R3) - ); - map_type[typeid(double).name()]->AddCast( - new E_F1_funcT(pf3r2R) - ); - - map_type[typeid(Complex).name()]->AddCast( - new E_F1_funcT(pf3r2R) - ); - - map_type[typeid(double).name()]->AddCast( - new E_F1_funcT(pfSr2R) - ); - - map_type[typeid(Complex).name()]->AddCast( - new E_F1_funcT(pfSr2R) - ); - - map_type[typeid(double).name()]->AddCast( - new E_F1_funcT(pfLr2R) - ); - - map_type[typeid(Complex).name()]->AddCast( - new E_F1_funcT(pfLr2R) - ); - - Global.Add("dz","(",new OneOperatorCode >); - Global.Add("dxz","(",new OneOperatorCode >); - Global.Add("dyz","(",new OneOperatorCode >); - Global.Add("dzx","(",new OneOperatorCode >); - Global.Add("dzx","(",new OneOperatorCode >); - Global.Add("dzz","(",new OneOperatorCode >); - - - Global.Add("dz","(",new OneOperatorCode >); - Global.Add("dxz","(",new OneOperatorCode >); - Global.Add("dyz","(",new OneOperatorCode >); - Global.Add("dzx","(",new OneOperatorCode >); - Global.Add("dzx","(",new OneOperatorCode >); - Global.Add("dzz","(",new OneOperatorCode >); - - - -// bof - // volume 3D real - Global.Add("dx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyz","(",new E_F1_funcT(pf3r2R)); - // volume 3D complex - Global.Add("dx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzx","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzy","(",new E_F1_funcT(pf3r2R)); - Global.Add("dzz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dxz","(",new E_F1_funcT(pf3r2R)); - Global.Add("dyz","(",new E_F1_funcT(pf3r2R)); - // surface 3D real - Global.Add("dx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyz","(",new E_F1_funcT(pfSr2R)); - // surface 3D complex - Global.Add("dx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzx","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzy","(",new E_F1_funcT(pfSr2R)); - Global.Add("dzz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dxz","(",new E_F1_funcT(pfSr2R)); - Global.Add("dyz","(",new E_F1_funcT(pfSr2R)); - // curve 3D real - Global.Add("dx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyz","(",new E_F1_funcT(pfLr2R)); - // curve 3D complex - Global.Add("dx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzx","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzy","(",new E_F1_funcT(pfLr2R)); - Global.Add("dzz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dxz","(",new E_F1_funcT(pfLr2R)); - Global.Add("dyz","(",new E_F1_funcT(pfLr2R)); - - - - - - - - - - - - // 3d volume - Global.Add("int3d","(",new OneOperatorCode); - Global.Add("int2d","(",new OneOperatorCode); - Global.Add("intallfaces","(",new OneOperatorCode); - Global.Add("intallBE","(",new OneOperatorCode); - Global.Add("intallBE","(",new OneOperatorCode); - Global.Add("intallBE","(",new OneOperatorCode); - // 3d surface - Global.Add("int2d","(",new OneOperatorCode); - Global.Add("int1d","(",new OneOperatorCode); - Global.Add("intalledges","(",new OneOperatorCode); - - // 3d curve - Global.Add("int1d","(",new OneOperatorCode); - Global.Add("int0d","(",new OneOperatorCode); // point int0d?? - /*decommente par J. Morice 14/01/09*/ - - Add("refresh",".",new OneOperator1(pfer_refresh3)); - Add("refresh",".",new OneOperator1(pfer_refresh3)); - - // 3d volume FE - Add("n",".",new OneOperator1(pf3r_nbdf)); - Add("n",".",new OneOperator1(pf3r_nbdf)); - - Add("Th",".",new OneOperator1(pf3r_Th)); - Add("Th",".",new OneOperator1(pf3r_Th)); - - Add("ndof",".",new OneOperator1(pVh3_ndof)); - Add("nt",".",new OneOperator1(pVh3_nt)); - Add("ndofK",".",new OneOperator1(pVh3_ndofK)); - Add("Th",".",new OneOperator1(pVh3_Th)); - - // 3d surface FE - Add("n",".",new OneOperator1(pfSr_nbdf)); - Add("n",".",new OneOperator1(pfSr_nbdf)); - Add("Th",".",new OneOperator1(pfSr_Th)); - Add("Th",".",new OneOperator1(pfSr_Th)); - Add("ndof",".",new OneOperator1(pVhS_ndof)); - Add("nt",".",new OneOperator1(pVhS_nt)); - Add("ndofK",".",new OneOperator1(pVhS_ndofK)); - Add("Th",".",new OneOperator1(pVhS_Th));//ADD JUIN 2021 FH. - -// Add("Th",".",new OneOperator1(pVhS_Th)); - -// 3d curve FE -Add("n",".",new OneOperator1(pfLr_nbdf)); -Add("n",".",new OneOperator1(pfLr_nbdf)); -Add("Th",".",new OneOperator1(pfLr_Th)); -Add("Th",".",new OneOperator1(pfLr_Th)); -Add("ndof",".",new OneOperator1(pVhL_ndof)); -Add("nt",".",new OneOperator1(pVhL_nt)); -Add("ndofK",".",new OneOperator1(pVhL_ndofK)); -Add("Th",".",new OneOperator1(pVhL_Th));//ADD JUIN 2021 FH. - - - //Add("[","",new OneOperator2_(get_element)); - //Add("[","",new OneOperator2_(get_element)); - //Add("[","",new OneOperator2_(get_element)); - - // 3d volume - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_FE_get_elmnt());// new version FH sep 2009 - Add("[","",new OneOperator2_FE_get_elmnt()); - Add("(","", new OneTernaryOperator ); - // 3d surface - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_FE_get_elmnt());// new version FH sep 2009 - Add("[","",new OneOperator2_FE_get_elmnt()); - Add("(","", new OneTernaryOperator ); - // 3d surface - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_(get_element)); // use ???? FH sep. 2009 - Add("[","",new OneOperator2_FE_get_elmnt());// new version FH sep 2009 - Add("[","",new OneOperator2_FE_get_elmnt()); - Add("(","", new OneTernaryOperator ); - - - init_mesh3_array(); //3D vomlume - init_meshS_array(); //3D surface - init_meshL_array(); //3D line - - // Add jan 2019 F.H ..to get a sorted the array of label and region of a mesh. - Global.Add("labels","(",new OneOperator1s_,pmeshL>(listoflabel)); - Global.Add("labels","(",new OneOperator1s_,pmeshS>(listoflabel)); - Global.Add("labels","(",new OneOperator1s_,pmesh3>(listoflabel)); - Global.Add("labels","(",new OneOperator1s_,pmesh>(listoflabel)); - Global.Add("regions","(",new OneOperator1s_,pmeshL>(listofregion)); - Global.Add("regions","(",new OneOperator1s_,pmeshS>(listofregion)); - Global.Add("regions","(",new OneOperator1s_,pmesh3>(listofregion)); - Global.Add("regions","(",new OneOperator1s_,pmesh>(listofregion)); - - atype()->AddCast( - new E_F1_funcT >(Array2R3) - // new E_F1_funcT* >(pArray2R3) - // new E_F1_funcT >(Cast > - ); -} - -//#include "InitFunct.hpp" -//static addingInitFunct TheaddingInitFunct(-10,init_lgmesh3); -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; -template E_set_fev3::E_set_fev3(const E_Array * a,Expression pp) ; + + TheOperators->Add("<-", new OneOperator2< KN< double > *, KN< double > *, R3 >(set_initR3) + // , new OneOperator2 *,KN *,R3*>(set_initR3) + ); + TheOperators->Add("=", new OneOperator2< KN_< double >, KN_< double >, R3 >(copy_R3) + // , new OneOperator2 ,KN_ ,R3*>(copy_R3) + ); + map_type[typeid(double).name( )]->AddCast(new E_F1_funcT< double, pf3r >(pf3r2R< R, 0, v_fes3 >)); + + map_type[typeid(Complex).name( )]->AddCast(new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, 0, v_fes3 >)); + + map_type[typeid(double).name( )]->AddCast(new E_F1_funcT< double, pfSr >(pfSr2R< R, 0, v_fesS >)); + + map_type[typeid(Complex).name( )]->AddCast(new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, 0, v_fesS >)); + + map_type[typeid(double).name( )]->AddCast(new E_F1_funcT< double, pfLr >(pfLr2R< R, 0, v_fesL >)); + + map_type[typeid(Complex).name( )]->AddCast(new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, 0, v_fesL >)); + + Global.Add("dz", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dz > >); + Global.Add("dxz", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dxz > >); + Global.Add("dyz", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dyz > >); + Global.Add("dzx", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dzx > >); + Global.Add("dzx", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dzy > >); + Global.Add("dzz", "(", new OneOperatorCode< CODE_Diff< Ftest, op_dzz > >); + + Global.Add("dz", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dz > >); + Global.Add("dxz", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dxz > >); + Global.Add("dyz", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dyz > >); + Global.Add("dzx", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dzx > >); + Global.Add("dzx", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dzy > >); + Global.Add("dzz", "(", new OneOperatorCode< CODE_Diff< Finconnue, op_dzz > >); + + // bof + // volume 3D real + Global.Add("dx", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dx, v_fes3 >)); + Global.Add("dy", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dy, v_fes3 >)); + Global.Add("dz", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dz, v_fes3 >)); + Global.Add("dxx", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dxx, v_fes3 >)); + Global.Add("dyy", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dyy, v_fes3 >)); + Global.Add("dxy", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dxy, v_fes3 >)); + Global.Add("dyx", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dyx, v_fes3 >)); + Global.Add("dzx", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dzx, v_fes3 >)); + Global.Add("dzy", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dzy, v_fes3 >)); + Global.Add("dzz", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dzz, v_fes3 >)); + Global.Add("dxz", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dxz, v_fes3 >)); + Global.Add("dyz", "(", new E_F1_funcT< double, pf3r >(pf3r2R< R, op_dyz, v_fes3 >)); + // volume 3D complex + Global.Add("dx", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dx, v_fes3 >)); + Global.Add("dy", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dy, v_fes3 >)); + Global.Add("dz", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dz, v_fes3 >)); + Global.Add("dxx", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dxx, v_fes3 >)); + Global.Add("dyy", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dyy, v_fes3 >)); + Global.Add("dxy", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dxy, v_fes3 >)); + Global.Add("dyx", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dyx, v_fes3 >)); + Global.Add("dzx", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dzx, v_fes3 >)); + Global.Add("dzy", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dzy, v_fes3 >)); + Global.Add("dzz", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dzz, v_fes3 >)); + Global.Add("dxz", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dxz, v_fes3 >)); + Global.Add("dyz", "(", new E_F1_funcT< Complex, pf3c >(pf3r2R< Complex, op_dyz, v_fes3 >)); + // surface 3D real + Global.Add("dx", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dx, v_fesS >)); + Global.Add("dy", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dy, v_fesS >)); + Global.Add("dz", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dz, v_fesS >)); + Global.Add("dxx", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dxx, v_fesS >)); + Global.Add("dyy", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dyy, v_fesS >)); + Global.Add("dxy", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dxy, v_fesS >)); + Global.Add("dyx", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dyx, v_fesS >)); + Global.Add("dzx", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dzx, v_fesS >)); + Global.Add("dzy", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dzy, v_fesS >)); + Global.Add("dzz", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dzz, v_fesS >)); + Global.Add("dxz", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dxz, v_fesS >)); + Global.Add("dyz", "(", new E_F1_funcT< double, pfSr >(pfSr2R< R, op_dyz, v_fesS >)); + // surface 3D complex + Global.Add("dx", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dx, v_fesS >)); + Global.Add("dy", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dy, v_fesS >)); + Global.Add("dz", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dz, v_fesS >)); + Global.Add("dxx", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dxx, v_fesS >)); + Global.Add("dyy", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dyy, v_fesS >)); + Global.Add("dxy", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dxy, v_fesS >)); + Global.Add("dyx", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dyx, v_fesS >)); + Global.Add("dzx", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dzx, v_fesS >)); + Global.Add("dzy", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dzy, v_fesS >)); + Global.Add("dzz", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dzz, v_fesS >)); + Global.Add("dxz", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dxz, v_fesS >)); + Global.Add("dyz", "(", new E_F1_funcT< Complex, pfSc >(pfSr2R< Complex, op_dyz, v_fesS >)); + // curve 3D real + Global.Add("dx", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dx, v_fesL >)); + Global.Add("dy", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dy, v_fesL >)); + Global.Add("dz", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dz, v_fesL >)); + Global.Add("dxx", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dxx, v_fesL >)); + Global.Add("dyy", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dyy, v_fesL >)); + Global.Add("dxy", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dxy, v_fesL >)); + Global.Add("dyx", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dyx, v_fesL >)); + Global.Add("dzx", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dzx, v_fesL >)); + Global.Add("dzy", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dzy, v_fesL >)); + Global.Add("dzz", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dzz, v_fesL >)); + Global.Add("dxz", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dxz, v_fesL >)); + Global.Add("dyz", "(", new E_F1_funcT< double, pfLr >(pfLr2R< R, op_dyz, v_fesL >)); + // curve 3D complex + Global.Add("dx", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dx, v_fesL >)); + Global.Add("dy", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dy, v_fesL >)); + Global.Add("dz", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dz, v_fesL >)); + Global.Add("dxx", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dxx, v_fesL >)); + Global.Add("dyy", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dyy, v_fesL >)); + Global.Add("dxy", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dxy, v_fesL >)); + Global.Add("dyx", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dyx, v_fesL >)); + Global.Add("dzx", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dzx, v_fesL >)); + Global.Add("dzy", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dzy, v_fesL >)); + Global.Add("dzz", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dzz, v_fesL >)); + Global.Add("dxz", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dxz, v_fesL >)); + Global.Add("dyz", "(", new E_F1_funcT< Complex, pfLc >(pfLr2R< Complex, op_dyz, v_fesL >)); + + // 3d volume + Global.Add("int3d", "(", new OneOperatorCode< CDomainOfIntegration3d >); + Global.Add("int2d", "(", new OneOperatorCode< CDomainOfIntegrationBorder3d >); + Global.Add("intallfaces", "(", new OneOperatorCode< CDomainOfIntegrationAllFaces >); + Global.Add("intallBE", "(", new OneOperatorCode< CDomainOfIntegrationAllFaces >); + Global.Add("intallBE", "(", new OneOperatorCode< CDomainOfIntegrationAllEdgesS >); + Global.Add("intallBE", "(", new OneOperatorCode< CDomainOfIntegrationAll0d >); + // 3d surface + Global.Add("int2d", "(", new OneOperatorCode< CDomainOfIntegrationS >); + Global.Add("int1d", "(", new OneOperatorCode< CDomainOfIntegrationBorderS >); + Global.Add("intalledges", "(", new OneOperatorCode< CDomainOfIntegrationAllEdgesS >); + + // 3d curve + Global.Add("int1d", "(", new OneOperatorCode< CDomainOfIntegrationL >); + Global.Add("int0d", "(", new OneOperatorCode< CDomainOfIntegrationBorderL >); // point int0d?? + /*decommente par J. Morice 14/01/09*/ + + Add< pf3r >("refresh", ".", new OneOperator1< bool, pf3r >(pfer_refresh3< R, v_fes3 >)); + Add< pf3c >("refresh", ".", new OneOperator1< bool, pf3c >(pfer_refresh3< Complex, v_fes3 >)); + + // 3d volume FE + Add< pf3r >("n", ".", new OneOperator1< long, pf3r >(pf3r_nbdf< R >)); + Add< pf3c >("n", ".", new OneOperator1< long, pf3c >(pf3r_nbdf< Complex >)); + + Add< pf3r >("Th", ".", new OneOperator1< pmesh3, pf3r >(pf3r_Th< R >)); + Add< pf3c >("Th", ".", new OneOperator1< pmesh3, pf3c >(pf3r_Th< Complex >)); + + Add< pfes3 * >("ndof", ".", new OneOperator1< long, pfes3 * >(pVh3_ndof)); + Add< pfes3 * >("nt", ".", new OneOperator1< long, pfes3 * >(pVh3_nt)); + Add< pfes3 * >("ndofK", ".", new OneOperator1< long, pfes3 * >(pVh3_ndofK)); + Add< pfes3 * >("Th", ".", new OneOperator1< pmesh3, pfes3 * >(pVh3_Th)); + + // 3d surface FE + Add< pfSr >("n", ".", new OneOperator1< long, pfSr >(pfSr_nbdf< R >)); + Add< pfSc >("n", ".", new OneOperator1< long, pfSc >(pfSr_nbdf< Complex >)); + Add< pfSr >("Th", ".", new OneOperator1< pmeshS, pfSr >(pfSr_Th< R >)); + Add< pfSc >("Th", ".", new OneOperator1< pmeshS, pfSc >(pfSr_Th< Complex >)); + Add< pfesS * >("ndof", ".", new OneOperator1< long, pfesS * >(pVhS_ndof)); + Add< pfesS * >("nt", ".", new OneOperator1< long, pfesS * >(pVhS_nt)); + Add< pfesS * >("ndofK", ".", new OneOperator1< long, pfesS * >(pVhS_ndofK)); + Add< pfesS * >("Th", ".", new OneOperator1< pmeshS, pfesS * >(pVhS_Th)); // ADD JUIN 2021 FH. + + // Add("Th",".",new OneOperator1(pVhS_Th)); + + // 3d curve FE + Add< pfLr >("n", ".", new OneOperator1< long, pfLr >(pfLr_nbdf< R >)); + Add< pfLc >("n", ".", new OneOperator1< long, pfLc >(pfLr_nbdf< Complex >)); + Add< pfLr >("Th", ".", new OneOperator1< pmeshL, pfLr >(pfLr_Th< R >)); + Add< pfLc >("Th", ".", new OneOperator1< pmeshL, pfLc >(pfLr_Th< Complex >)); + Add< pfesL * >("ndof", ".", new OneOperator1< long, pfesL * >(pVhL_ndof)); + Add< pfesL * >("nt", ".", new OneOperator1< long, pfesL * >(pVhL_nt)); + Add< pfesL * >("ndofK", ".", new OneOperator1< long, pfesL * >(pVhL_ndofK)); + Add< pfesL * >("Th", ".", new OneOperator1< pmeshL, pfesL * >(pVhL_Th)); // ADD JUIN 2021 FH. + + // Add("[","",new OneOperator2_(get_element)); + // Add("[","",new OneOperator2_(get_element)); + // Add("[","",new OneOperator2_(get_element)); + + // 3d volume + Add< pf3cbasearray * >("[", "", new OneOperator2_< pf3cbase *, pf3cbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pf3rbasearray * >("[", "", new OneOperator2_< pf3rbase *, pf3rbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pf3rarray >("[", "", new OneOperator2_FE_get_elmnt< double, v_fes3 >( )); // new version FH sep 2009 + Add< pf3carray >("[", "", new OneOperator2_FE_get_elmnt< Complex, v_fes3 >( )); + Add< pfes3 * >("(", "", new OneTernaryOperator< pVh3_ndf, pVh3_ndf::Op >); + // 3d surface + Add< pfScbasearray * >("[", "", new OneOperator2_< pfScbase *, pfScbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pfSrbasearray * >("[", "", new OneOperator2_< pfSrbase *, pfSrbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pfSrarray >("[", "", new OneOperator2_FE_get_elmnt< double, v_fesS >( )); // new version FH sep 2009 + Add< pfScarray >("[", "", new OneOperator2_FE_get_elmnt< Complex, v_fesS >( )); + Add< pfesS * >("(", "", new OneTernaryOperator< pVhS_ndf, pVhS_ndf::Op >); + // 3d surface + Add< pfLcbasearray * >("[", "", new OneOperator2_< pfLcbase *, pfLcbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pfLrbasearray * >("[", "", new OneOperator2_< pfLrbase *, pfLrbasearray *, long >(get_element)); // use ???? FH sep. 2009 + Add< pfLrarray >("[", "", new OneOperator2_FE_get_elmnt< double, v_fesL >( )); // new version FH sep 2009 + Add< pfLcarray >("[", "", new OneOperator2_FE_get_elmnt< Complex, v_fesL >( )); + Add< pfesL * >("(", "", new OneTernaryOperator< pVhL_ndf, pVhL_ndf::Op >); + + init_mesh3_array( ); // 3D vomlume + init_meshS_array( ); // 3D surface + init_meshL_array( ); // 3D line + + // Add jan 2019 F.H ..to get a sorted the array of label and region of a mesh. + Global.Add("labels", "(", new OneOperator1s_< KN_< long >, pmeshL >(listoflabel)); + Global.Add("labels", "(", new OneOperator1s_< KN_< long >, pmeshS >(listoflabel)); + Global.Add("labels", "(", new OneOperator1s_< KN_< long >, pmesh3 >(listoflabel)); + Global.Add("labels", "(", new OneOperator1s_< KN_< long >, pmesh >(listoflabel)); + Global.Add("regions", "(", new OneOperator1s_< KN_< long >, pmeshL >(listofregion)); + Global.Add("regions", "(", new OneOperator1s_< KN_< long >, pmeshS >(listofregion)); + Global.Add("regions", "(", new OneOperator1s_< KN_< long >, pmesh3 >(listofregion)); + Global.Add("regions", "(", new OneOperator1s_< KN_< long >, pmesh >(listofregion)); + + atype< R3 >( )->AddCast(new E_F1_funcT< R3, KN_< double > >(Array2R3) + // new E_F1_funcT* >(pArray2R3) + // new E_F1_funcT >(Cast > + ); +} + +// #include "InitFunct.hpp" +// static addingInitFunct TheaddingInitFunct(-10,init_lgmesh3); +template E_set_fev3< double, v_fes3 >::E_set_fev3(const E_Array *a, Expression pp); +template E_set_fev3< Complex, v_fes3 >::E_set_fev3(const E_Array *a, Expression pp); +template E_set_fev3< double, v_fesS >::E_set_fev3(const E_Array *a, Expression pp); +template E_set_fev3< Complex, v_fesS >::E_set_fev3(const E_Array *a, Expression pp); +template E_set_fev3< double, v_fesL >::E_set_fev3(const E_Array *a, Expression pp); +template E_set_fev3< Complex, v_fesL >::E_set_fev3(const E_Array *a, Expression pp); diff --git a/src/fflib/lgmesh3.hpp b/src/fflib/lgmesh3.hpp index f72fb0756..b5cb04887 100644 --- a/src/fflib/lgmesh3.hpp +++ b/src/fflib/lgmesh3.hpp @@ -1,70 +1,69 @@ #ifndef LGMESH3_HPP #define LGMESH3_HPP // 3d real (2d equivalent at [[file:problem.hpp::pferbase]]) -typedef FEbase * pf3rbase ; -typedef FEbaseArray * pf3rbasearray ; -typedef pair pf3r ; -typedef pair pf3rarray ; +typedef FEbase< double, v_fes3 > *pf3rbase; +typedef FEbaseArray< double, v_fes3 > *pf3rbasearray; +typedef pair< pf3rbase, int > pf3r; +typedef pair< pf3rbasearray, int > pf3rarray; // 3d complex (2d equivalent at [[file:problem.hpp::pfecbase]]) -typedef FEbase * pf3cbase ; -typedef FEbaseArray * pf3cbasearray ; -typedef pair pf3c ; -typedef pair pf3carray ; +typedef FEbase< Complex, v_fes3 > *pf3cbase; +typedef FEbaseArray< Complex, v_fes3 > *pf3cbasearray; +typedef pair< pf3cbase, int > pf3c; +typedef pair< pf3cbasearray, int > pf3carray; // fin // Surf real (2d equivalent at [[file:problem.hpp::pferbase]]) -typedef FEbase * pfSrbase ; -typedef FEbaseArray * pfSrbasearray ; -typedef pair pfSr ; -typedef pair pfSrarray ; +typedef FEbase< double, v_fesS > *pfSrbase; +typedef FEbaseArray< double, v_fesS > *pfSrbasearray; +typedef pair< pfSrbase, int > pfSr; +typedef pair< pfSrbasearray, int > pfSrarray; // Surf complex (2d equivalent at [[file:problem.hpp::pfecbase]]) -typedef FEbase * pfScbase ; -typedef FEbaseArray * pfScbasearray ; -typedef pair pfSc ; -typedef pair pfScarray ; +typedef FEbase< Complex, v_fesS > *pfScbase; +typedef FEbaseArray< Complex, v_fesS > *pfScbasearray; +typedef pair< pfScbase, int > pfSc; +typedef pair< pfScbasearray, int > pfScarray; // Curve real (2d equivalent at [[file:problem.hpp::pferbase]]) -typedef FEbase * pfLrbase ; -typedef FEbaseArray * pfLrbasearray ; -typedef pair pfLr ; -typedef pair pfLrarray ; +typedef FEbase< double, v_fesL > *pfLrbase; +typedef FEbaseArray< double, v_fesL > *pfLrbasearray; +typedef pair< pfLrbase, int > pfLr; +typedef pair< pfLrbasearray, int > pfLrarray; // Curve complex (2d equivalent at [[file:problem.hpp::pfecbase]]) -typedef FEbase * pfLcbase ; -typedef FEbaseArray * pfLcbasearray ; -typedef pair pfLc ; -typedef pair pfLcarray ; +typedef FEbase< Complex, v_fesL > *pfLcbase; +typedef FEbaseArray< Complex, v_fesL > *pfLcbasearray; +typedef pair< pfLcbase, int > pfLc; +typedef pair< pfLcbasearray, int > pfLcarray; // fin +bool isSameMesh(const list< C_F0 > &largs, const void *Thu, const void *Thv, Stack stack); // true => VF type of Matrix + // bool isSameMesh(const list & largs,const Mesh * Thu,const Mesh * Thv,Stack stack) ; -bool isSameMesh(const list & largs,const void * Thu,const void * Thv,Stack stack) ; // true => VF type of Matrix - //bool isSameMesh(const list & largs,const Mesh * Thu,const Mesh * Thv,Stack stack) ; +inline C_F0 CCastToR(const C_F0 &f) { return C_F0(atype< double >( )->CastTo(f), atype< double >( )); } +inline bool BCastToR(const C_F0 &f) { return atype< double >( )->CastingFrom(f.left( )); } +inline C_F0 CCastToC(const C_F0 &f) { return C_F0(atype< Complex >( )->CastTo(f), atype< Complex >( )); } +inline bool BCastToC(const C_F0 &f) { return atype< Complex >( )->CastingFrom(f.left( )); } -inline C_F0 CCastToR(const C_F0 & f){ return C_F0(atype()->CastTo(f),atype());} -inline bool BCastToR(const C_F0 & f){ return atype()->CastingFrom(f.left());} - - - -inline C_F0 CCastToC(const C_F0 & f){ return C_F0(atype()->CastTo(f),atype());} -inline bool BCastToC(const C_F0 & f){ return atype()->CastingFrom(f.left());} - -template -inline Expression CastTo(const C_F0 & f) { return atype()->CastTo(f);} +template< class Result > +inline Expression CastTo(const C_F0 &f) { + return atype< Result >( )->CastTo(f); +} // <> -template -inline bool BCastTo(const C_F0 & f) { return atype()->CastingFrom(f.left());} - -inline void Check(bool v,const char * mess) -{ - if (!v) { cerr << " Error " << mess ; - throw(ErrorExec(mess,1)); +template< class Result > +inline bool BCastTo(const C_F0 &f) { + return atype< Result >( )->CastingFrom(f.left( )); +} + +inline void Check(bool v, const char *mess) { + if (!v) { + cerr << " Error " << mess; + throw(ErrorExec(mess, 1)); } -} +} - #endif diff --git a/src/fflib/lgsolver.hpp b/src/fflib/lgsolver.hpp index 09fb4a503..f278eb69c 100644 --- a/src/fflib/lgsolver.hpp +++ b/src/fflib/lgsolver.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,663 +29,565 @@ #define lgsolver_hpp_ #include "gmres.hpp" -typedef void * pcommworld; - -namespace Fem2D { +typedef void *pcommworld; -// hack --- F. Hecht ----- +namespace Fem2D { -// une fonction pour change un tableau de + // hack --- F. Hecht ----- -// complex en tableau de real + // une fonction pour change un tableau de -// Idee faire + // complex en tableau de real -// Une class qui tranforme une matrice complex en matric real + // Idee faire -// et faire de transformateur de vecteur + // Une class qui tranforme une matrice complex en matric real + // et faire de transformateur de vecteur -inline KN_ C2R(KN_ > & vc) + inline KN_< double > C2R(KN_< complex< double > > &vc) -{ + { - assert(vc.step==1); + assert(vc.step == 1); - complex * pc=vc; // pointeur du tableau + complex< double > *pc = vc; // pointeur du tableau - double *pr = static_cast(static_cast(pc)); + double *pr = static_cast< double * >(static_cast< void * >(pc)); - return KN_(pr,vc.N()*2); + return KN_< double >(pr, vc.N( ) * 2); + } -} + inline const KN_< double > C2R(const KN_< complex< double > > &vc) + { -inline const KN_ C2R(const KN_ > & vc) + assert(vc.step == 1); -{ + complex< double > *pc = vc; // pointeur du tableau - assert(vc.step==1); + double *pr = static_cast< double * >(static_cast< void * >(pc)); - complex * pc=vc; // pointeur du tableau + return KN_< double >(pr, vc.N( ) * 2); + } - double *pr = static_cast(static_cast(pc)); + inline KN_< complex< double > > R2C(KN_< double > &vr) - return KN_(pr,vc.N()*2); + { -} + assert(vr.step == 1 && vr.N( ) % 2 == 0); + double *pr = vr; // pointeur du tableau + complex< double > *pc = static_cast< complex< double > * >(static_cast< void * >(pr)); + return KN_< complex< double > >(pc, vr.N( ) / 2); + } -inline KN_ > R2C(KN_ & vr) + template< class R > + struct RNM_VirtualMatrixTrans : public RNM_VirtualMatrix< R > { + public: + const RNM_VirtualMatrix< R > *A; + int N, M; + RNM_VirtualMatrixTrans(const RNM_VirtualMatrix< R > &AA) : RNM_VirtualMatrix< R >(AA.M, AA.N), A(&AA) { + N = AA.M; + M = AA.N; + // cout <<"Assertion fail " << N << " " << M << " "<< AA.N << " " << AA.M << endl; + } + void addMatMul(const KN_< R > &x, KN_< R > &y) const { A->addMatTransMul(x, y); } + void addMatTransMul(const KN_< R > &x, KN_< R > &y) const { A->addMatMul(x, y); } -{ + virtual bool ChecknbLine(int n) const { return N == n; } + virtual bool ChecknbColumn(int m) const { return M == m; } + /* struct plusAx { const RNM_VirtualMatrix * A; const KN_ x; + plusAx( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),x(y) + { if(B) { ffassert(B->ChecknbColumn(y.N())); } } + }; - assert(vr.step==1 && vr.N() %2 ==0); + plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - double *pr =vr; // pointeur du tableau + struct plusAtx { const RNM_VirtualMatrix * A; const KN_ x; + plusAtx( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),x(y) + { if(B) { ffassert(B->ChecknbLine(y.N())); } } }; - complex * pc = static_cast* >(static_cast(pr)); + struct solveAxeqb { const RNM_VirtualMatrix * A; const KN_ b; + solveAxeqb( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),b(y) + { if(B) { ffassert(B->ChecknbColumn(y.N())); } } }; - return KN_ >(pc,vr.N()/2); + struct solveAtxeqb { const RNM_VirtualMatrix * A; const KN_ b; + solveAtxeqb( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),b(y) + { if(B) { ffassert(B->ChecknbColumn(y.N())); } } }; + */ + RNM_VirtualMatrixTrans( ) {} + }; -} + inline const KN_< complex< double > > R2C(const KN_< double > &vr) - template - struct RNM_VirtualMatrixTrans:public RNM_VirtualMatrix { public: - const RNM_VirtualMatrix * A; - int N,M; - RNM_VirtualMatrixTrans(const RNM_VirtualMatrix & AA): RNM_VirtualMatrix(AA.M,AA.N),A(&AA) - { N=AA.M; M=AA.N; - // cout <<"Assertion fail " << N << " " << M << " "<< AA.N << " " << AA.M << endl; - } - void addMatMul(const KN_ & x, KN_ & y) const {A->addMatTransMul(x, y);} - void addMatTransMul(const KN_ & x , KN_ & y) const {A->addMatMul(x, y);} - - virtual bool ChecknbLine (int n) const {return N==n;} - virtual bool ChecknbColumn (int m) const {return M==m;} - /* struct plusAx { const RNM_VirtualMatrix * A; const KN_ x; - plusAx( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),x(y) - { if(B) { ffassert(B->ChecknbColumn(y.N())); } } - }; - - plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - - struct plusAtx { const RNM_VirtualMatrix * A; const KN_ x; - plusAtx( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),x(y) - { if(B) { ffassert(B->ChecknbLine(y.N())); } } }; - - struct solveAxeqb { const RNM_VirtualMatrix * A; const KN_ b; - solveAxeqb( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),b(y) - { if(B) { ffassert(B->ChecknbColumn(y.N())); } } }; - - struct solveAtxeqb { const RNM_VirtualMatrix * A; const KN_ b; - solveAtxeqb( const RNM_VirtualMatrix * B,const KN_ & y) :A(B),b(y) - { if(B) { ffassert(B->ChecknbColumn(y.N())); } } }; - */ - RNM_VirtualMatrixTrans(){} - }; - + { -inline const KN_ > R2C(const KN_ & vr) + assert(vr.step == 1 && vr.N( ) % 2 == 0); -{ + double *pr = vr; // pointeur du tableau - assert(vr.step==1 && vr.N() %2 ==0); + complex< double > *pc = static_cast< complex< double > * >(static_cast< void * >(pr)); - double *pr =vr; // pointeur du tableau + return KN_< complex< double > >(pc, vr.N( ) / 2); + } - complex * pc = static_cast* >(static_cast(pr)); + // une classe pour transforme une Matrice complex en Matrice real - return KN_ >(pc,vr.N()/2); + // ----------------------------------------------------------------- -} + template< class MM > + class MatC2R : public VirtualMatrix< double > { + public: + typedef typename VirtualMatrix< double >::plusAx plusAx; + // typedef RNM_VirtualMatrix > M; + const MM &m; -// une classe pour transforme une Matrice complex en Matrice real + MatC2R(const MM &mm) : VirtualMatrix< double >(mm.N * 2, mm.M * 2), m(mm) {} -// ----------------------------------------------------------------- + void addMatMul(const KN_< double > &x, KN_< double > &Ax) const { R2C(Ax) += m * R2C(x); } -template -class MatC2R : public VirtualMatrix { public: + plusAx operator*(const KN< double > &x) const { return plusAx(this, x); } + virtual bool ChecknbLine(int nn) const { return !n || n == nn; } + virtual bool ChecknbColumn(int mm) const { return !n || m == mm; } + }; - typedef typename VirtualMatrix::plusAx plusAx; +#ifdef REOMVE_CODE_V4 - // typedef RNM_VirtualMatrix > M; + template< class R > + class SolveGCPrecon : public MatriceCreuseOld< R >::VirtualSolver, public RNM_VirtualMatrix< R > { + int n; + int nbitermax; + double eps; + mutable double epsr; + const E_F0 *precon; + KN< R > D1; // pour le CL bloque (tgv) + mutable KN< R > xx; + Expression xx_del, code_del; + Stack stack; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + + public: + SolveGCPrecon(const MatriceCreuseOld< R > &A, const OneOperator *C, Stack stk, int itmax, double epsilon = 1e-6) + : RNM_VirtualMatrix< R >(A.n), n(A.n), nbitermax(itmax ? itmax : Max(100, n)), eps(epsilon), epsr(0), precon(0), D1(n), xx(n), stack(stk) { + assert(C); + + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 + throwassert(A.sym( )); + Type_Expr te_xx(CPValue(xx)); + xx_del = te_xx.second; + C_F0 e_xx(te_xx); // 1 undelete pointer + code_del = C->code(basicAC_F0_wa(e_xx)); + precon = to< KN_< R > >(C_F0(code_del, *C)); // 2 undelete pointer - const MM &m; + throwassert(precon); + R aii; + A.getdiag(D1); + double tgv = std::norm(D1.linfty( )); + if (std::norm(tgv) < 1e10) tgv = 1e100; + double tgv1 = 1. / tgv; // Corrige fH 11 mai 2015 ... + for (int i = 0; i < n; i++) D1[i] = std::norm(D1[i]) < tgv ? R(1.) : tgv1; + } + void Solver(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + // cout << " epsr = " << epsr << endl; + ConjuguedGradient< R, MatriceCreuseOld< R >, SolveGCPrecon< R >, StopGC< R > >(a, *this, b, x, nbitermax, epsr); + } + plusAx operator*(const KN_< R > &x) const { return plusAx(this, x); } + + void addMatMul(const KN_< R > &x, KN_< R > &Ax) const { + assert(x.N( ) == Ax.N( )); + + xx = x; + // cout << x[0] << " "; + xx = GetAny< KN_< R > >((*precon)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); + // cout << (xx)[0] << " " << endl; + R dii; + for (int i = 0; i < n; i++) Ax[i] += ((dii = D1[i]) == 1.0) ? (xx)[i] : x[i] * dii; + } - MatC2R(const MM &mm): - VirtualMatrix(mm.N*2,mm.M*2),m(mm) {} + ~SolveGCPrecon( ) { - void addMatMul(const KN_ & x, KN_ & Ax) const { + WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 + delete xx_del; + delete code_del; + // cout << "~SolveGCPrecon " << endl; + } + virtual bool ChecknbLine(int n) const { return true; } + virtual bool ChecknbColumn(int m) const { return true; } + }; + + template< class R > + class SolveGMRESPrecon : public MatriceCreuseOld< R >::VirtualSolver, public RNM_VirtualMatrix< R > { + int n; + int nbitermax; + double eps; + mutable double epsr; + const E_F0 *precon; + KN< R > D1; + mutable KN< R > xx; + Expression xx_del, code_del; + Stack stack; + int dKrylov; + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + + public: + SolveGMRESPrecon(const MatriceCreuseOld< R > &A, const OneOperator *C, Stack stk, int dk = 50, int itmax = 0, double epsilon = 1e-6) + : RNM_VirtualMatrix< R >(A.n), n(A.n), nbitermax(itmax ? itmax : Max(100, n)), eps(epsilon), epsr(0), precon(0), D1(n), xx(n), stack(stk), dKrylov(dk) - R2C(Ax) += m*R2C(x); + { + assert(C); + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 + // C_F0 e_xx(CPValue(xx)); + // precon = to >(C_F0(C->code(basicAC_F0_wa(e_xx)),*C)); + Type_Expr te_xx(CPValue(xx)); + xx_del = te_xx.second; + C_F0 e_xx(te_xx); // 1 undelete pointer + code_del = C->code(basicAC_F0_wa(e_xx)); + precon = to< KN_< R > >(C_F0(code_del, *C)); // 2 undelete pointer - } + throwassert(precon); - plusAx operator*(const KN & x) const {return plusAx(this,x);} - virtual bool ChecknbLine(int nn) const { return !n ||n==nn;} - virtual bool ChecknbColumn(int mm) const { return !n ||m==mm;} + R aii; + A.getdiag(D1); + double tgv = D1.linfty( ); + if (tgv < 1e5) + tgv = 1e100; // if no tgv remove .. + // if(verbosity>10 ) cout << " in Precon GMRES, find tgv = " << tgv << endl; + for (int i = 0; i < n; i++) D1[i] = (std::abs(D1[i]) < tgv) ? R(1.) : R( ); // remove the tgv ... + } + void Solver(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< R > H(dKrylov + 1, dKrylov + 1); + int k = dKrylov, nn = nbitermax; + GMRES(a, (KN< R > &)x, (const KN< R > &)b, *this, H, k, nn, epsr, verbosity); + } + void SolverT(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + RNM_VirtualMatrixTrans< R > at(a); + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< R > H(dKrylov + 1, dKrylov + 1); + int k = dKrylov, nn = nbitermax; + GMRES(at, (KN< R > &)x, (const KN< R > &)b, *this, H, k, nn, epsr, verbosity); + } + plusAx operator*(const KN_< R > &x) const { return plusAx(this, x); } + void addMatMul(const KN_< R > &x, KN_< R > &Ax) const { + assert(x.N( ) == Ax.N( )); -}; + xx = x; + // cout << x[0] << " "; + xx = GetAny< KN_< R > >((*precon)(stack)); // xx value of the preoco + WhereStackOfPtr2Free(stack)->clean( ); -#ifdef REOMVE_CODE_V4 + // cout << (xx)[0] << " " << endl; + // R dii; + // for (int i=0;i -class SolveGCPrecon : public MatriceCreuseOld::VirtualSolver , public RNM_VirtualMatrix{ - int n; - int nbitermax; - double eps; - mutable double epsr; - const E_F0 * precon; - KN D1; // pour le CL bloque (tgv) - mutable KN xx; - Expression xx_del, code_del; - Stack stack; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - - public: - SolveGCPrecon(const MatriceCreuseOld &A,const OneOperator * C,Stack stk,int itmax, double epsilon=1e-6) : - RNM_VirtualMatrix(A.n), - n(A.n),nbitermax(itmax?itmax: Max(100,n)),eps(epsilon),epsr(0),precon(0), - D1(n),xx(n),stack(stk) -{ - assert(C); - - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 - throwassert(A.sym()); - Type_Expr te_xx(CPValue(xx)); - xx_del=te_xx.second; - C_F0 e_xx(te_xx); // 1 undelete pointer - code_del= C->code(basicAC_F0_wa(e_xx)); - precon = to >(C_F0(code_del,*C));// 2 undelete pointer - - throwassert(precon); - R aii; + ~SolveGMRESPrecon( ) { + delete xx_del; + delete code_del; + WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 + // cout << "~SolveGMRESPrecon; " << endl; + } + virtual bool ChecknbLine(int n) const { return true; } + virtual bool ChecknbColumn(int m) const { return true; } + }; + + template< class R > + class SolveGMRESDiag : public MatriceCreuseOld< R >::VirtualSolver, public RNM_VirtualMatrix< R > { + int n; + int nbitermax; + double eps; + mutable double epsr; + int dKrilov; + KN< R > D1; + + public: + typedef typename RNM_VirtualMatrix< R >::plusAx plusAx; + SolveGMRESDiag(const MatriceCreuseOld< R > &A, int nbk = 50, int itmax = 0, double epsilon = 1e-6) + : RNM_VirtualMatrix< R >(A.n), n(A.n), nbitermax(itmax ? itmax : Max(100, n)), eps(epsilon), epsr(0), dKrilov(nbk), D1(n) { + R aii = 0; A.getdiag(D1); - double tgv=std::norm(D1.linfty() ) ; - if( std::norm(tgv) < 1e10) tgv=1e100; - double tgv1 = 1./tgv; // Corrige fH 11 mai 2015 ... - for (int i=0;i &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - // cout << " epsr = " << epsr << endl; - ConjuguedGradient,SolveGCPrecon,StopGC >(a,*this,b,x,nbitermax,epsr); - } -plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - - - void addMatMul(const KN_ & x, KN_ & Ax) const - { - assert(x.N()==Ax.N()); - - xx=x; - // cout << x[0] << " "; - xx=GetAny >((*precon)(stack)); - WhereStackOfPtr2Free(stack)->clean(); - // cout << (xx)[0] << " " << endl; - R dii; - for (int i=0;iclean(); // FH mars 2005 - delete xx_del; - delete code_del; -// cout << "~SolveGCPrecon " << endl; - } - virtual bool ChecknbLine(int n) const { return true;} - virtual bool ChecknbColumn(int m) const { return true;} - -}; - -template -class SolveGMRESPrecon : public MatriceCreuseOld::VirtualSolver , public RNM_VirtualMatrix{ - int n; - int nbitermax; - double eps; - mutable double epsr; - const E_F0 * precon; - KN D1; - mutable KN xx; - Expression xx_del, code_del; - Stack stack; - int dKrylov; - typedef typename RNM_VirtualMatrix::plusAx plusAx; - public: - SolveGMRESPrecon(const MatriceCreuseOld &A,const OneOperator * C,Stack stk,int dk=50,int itmax=0,double epsilon=1e-6) : - RNM_VirtualMatrix(A.n), - n(A.n),nbitermax(itmax?itmax: Max(100,n)),eps(epsilon),epsr(0),precon(0), - D1(n),xx(n), - stack(stk),dKrylov(dk) - -{ - assert(C); - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 - // C_F0 e_xx(CPValue(xx)); - //precon = to >(C_F0(C->code(basicAC_F0_wa(e_xx)),*C)); - Type_Expr te_xx(CPValue(xx)); - xx_del=te_xx.second; - C_F0 e_xx(te_xx); // 1 undelete pointer - code_del= C->code(basicAC_F0_wa(e_xx)); - precon = to >(C_F0(code_del,*C));// 2 undelete pointer - - throwassert(precon); - - R aii; + void Solver(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< R > H(dKrilov + 1, dKrilov + 1); + int k = dKrilov, nn = nbitermax; + GMRES(a, (KN< R > &)x, (const KN< R > &)b, *this, H, k, nn, epsr, verbosity); + } + void SolverT(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + RNM_VirtualMatrixTrans< R > at(a); + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< R > H(dKrilov + 1, dKrilov + 1); + int k = dKrilov, nn = nbitermax; + GMRES(at, (KN< R > &)x, (const KN< R > &)b, *this, H, k, nn, epsr, verbosity); + } + + plusAx operator*(const KN_< R > &x) const { return plusAx(this, x); } + + void addMatMul(const KN_< R > &x, KN_< R > &Ax) const { + assert(x.N( ) == Ax.N( )); + for (int i = 0; i < n; i++) Ax[i] += D1[i] * x[i]; + } + + virtual bool ChecknbLine(int n) const { return true; } + virtual bool ChecknbColumn(int m) const { return true; } + }; + + template<> + class SolveGMRESDiag< Complex > : public MatriceMorseOld< Complex >::VirtualSolver, public RNM_VirtualMatrix< Complex > { + int n; + int nbitermax; + KN< Complex > D1; + double eps; + mutable double epsr; + int dKrilov; + + public: + typedef RNM_VirtualMatrix< Complex >::plusAx plusAx; + SolveGMRESDiag(const MatriceMorseOld< Complex > &A, int nbk = 50, int itmax = 0, double epsilon = 1e-6) + : RNM_VirtualMatrix< Complex >(A.n), n(A.n), nbitermax(itmax ? itmax : Max(100, n)), D1(n), eps(epsilon), epsr(0), dKrilov(nbk) { + Complex aii = 0; A.getdiag(D1); - double tgv = D1.linfty(); - if( tgv < 1e5) tgv = 1e100; // if no tgv remove .. - // if(verbosity>10 ) cout << " in Precon GMRES, find tgv = " << tgv << endl; - for (int i=0;i &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrylov+1,dKrylov+1); - int k=dKrylov,nn=nbitermax; - GMRES(a,(KN &)x, (const KN &)b,*this,H,k,nn,epsr,verbosity); - - } - void SolverT(const MatriceCreuseOld &a,KN_ &x,const KN_ &b) const { - RNM_VirtualMatrixTrans at(a); - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrylov+1,dKrylov+1); - int k=dKrylov,nn=nbitermax; - GMRES(at ,(KN &)x, (const KN &)b,*this,H,k,nn,epsr,verbosity); + for (int i = 0; i < n; i++) D1[i] = (std::norm(aii = D1[i]) < 1e-20 ? Complex(1.) : Complex(1.) / aii); } -plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - - - void addMatMul(const KN_ & x, KN_ & Ax) const - { - assert(x.N()==Ax.N()); - - xx=x; - // cout << x[0] << " "; - xx=GetAny >((*precon)(stack)); // xx value of the preoco - WhereStackOfPtr2Free(stack)->clean(); - -// cout << (xx)[0] << " " << endl; - // R dii; - // for (int i=0;iclean(); // FH mars 2005 - // cout << "~SolveGMRESPrecon; " << endl; - } - virtual bool ChecknbLine(int n) const { return true;} - virtual bool ChecknbColumn(int m) const { return true;} - -}; - -template -class SolveGMRESDiag : public MatriceCreuseOld::VirtualSolver , public RNM_VirtualMatrix{ - int n; - int nbitermax; - double eps; - mutable double epsr; - int dKrilov; - KN D1; - public: - typedef typename RNM_VirtualMatrix::plusAx plusAx; - SolveGMRESDiag(const MatriceCreuseOld &A,int nbk=50,int itmax=0,double epsilon=1e-6) : - RNM_VirtualMatrix(A.n), - n(A.n),nbitermax(itmax?itmax: Max(100,n)),eps(epsilon),epsr(0), - dKrilov(nbk) ,D1(n) - { - R aii=0; - A.getdiag(D1); - for (int i=0;i &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrilov+1,dKrilov+1); - int k=dKrilov,nn=nbitermax; - GMRES(a,(KN &)x,(const KN &)b,*this,H,k,nn,epsr,verbosity); - - } - void SolverT(const MatriceCreuseOld &a,KN_ &x,const KN_ &b) const { - RNM_VirtualMatrixTrans at(a); - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrilov+1,dKrilov+1); - int k=dKrilov,nn=nbitermax; - GMRES(at,(KN &)x,(const KN &)b,*this,H,k,nn,epsr,verbosity); + void Solver(const MatriceMorseOld< Complex > &a, KN_< Complex > &x, const KN_< Complex > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< double > H(dKrilov + 1, dKrilov + 1); + int k = dKrilov, nn = nbitermax; + KN_< double > rx = C2R(x); + const KN_< double > rb = C2R(b); + typedef MatC2R< MatriceMorseOld< Complex > > VA; + typedef MatC2R< SolveGMRESDiag< Complex > > VC; + VA AR(a); + VC CR(*this); + // int res= + GMRES(AR, (KN< double > &)rx, (const KN< double > &)rb, CR, H, k, nn, epsr, verbosity); } -plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - - - void addMatMul(const KN_ & x, KN_ & Ax) const - { - assert(x.N()==Ax.N()); - for (int i=0;i -class SolveGMRESDiag : public MatriceMorseOld::VirtualSolver , public RNM_VirtualMatrix -{ - int n; - int nbitermax; - KN D1; - double eps; - mutable double epsr; - int dKrilov; - public: - typedef RNM_VirtualMatrix::plusAx plusAx; - SolveGMRESDiag(const MatriceMorseOld &A,int nbk=50,int itmax=0,double epsilon=1e-6) : - RNM_VirtualMatrix(A.n), - n(A.n),nbitermax(itmax?itmax: Max(100,n)),D1(n),eps(epsilon),epsr(0), - dKrilov(nbk) - { - Complex aii=0; - A.getdiag(D1); - for (int i=0;i &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrilov+1,dKrilov+1); - int k=dKrilov,nn=nbitermax; - KN_ rx=C2R(x); - const KN_ rb=C2R(b); - typedef MatC2R > VA; - typedef MatC2R > VC; + plusAx operator*(const KN_< Complex > &x) const { return plusAx(this, x); } + + void SolverT(const MatriceCreuseOld< Complex > &a, KN_< Complex > &x, const KN_< Complex > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< double > H(dKrilov + 1, dKrilov + 1); + int k = dKrilov, nn = nbitermax; + KN_< double > rx = C2R(x); + const KN_< double > rb = C2R(b); + typedef MatC2R< MatriceCreuseOld< Complex > > VA; + typedef MatC2R< SolveGMRESDiag< Complex > > VC; VA AR(a); VC CR(*this); - //int res= - GMRES(AR,(KN &)rx,(const KN &)rb,CR,H,k,nn,epsr,verbosity); - - } - -plusAx operator*(const KN_ & x) const {return plusAx(this,x);} - - void SolverT(const MatriceCreuseOld &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrilov+1,dKrilov+1); - int k=dKrilov,nn=nbitermax; - KN_ rx=C2R(x); - const KN_ rb=C2R(b); - typedef MatC2R > VA; - typedef MatC2R > VC; - VA AR(a); - VC CR(*this); - RNM_VirtualMatrixTrans ARt(AR); - GMRES(ARt,(KN &)rx,(const KN &)rb,CR,H,k,nn,epsr,verbosity); + RNM_VirtualMatrixTrans< double > ARt(AR); + GMRES(ARt, (KN< double > &)rx, (const KN< double > &)rb, CR, H, k, nn, epsr, verbosity); } - void addMatMul(const KN_ & x, KN_ & Ax) const - { - assert(x.N()==Ax.N()); - for (int i=0;i -class SolveGMRESPrecon : public MatriceCreuseOld::VirtualSolver , public RNM_VirtualMatrix -{ - public: - typedef Complex R ; - int n; - int nbitermax; - Expression xx_del, code_del; - const E_F0 * precon; - Stack stack; - double eps; - mutable double epsr; - int dKrylov; - KN D1; - mutable KN xx; - typedef RNM_VirtualMatrix::plusAx plusAx; - public: - SolveGMRESPrecon(const MatriceCreuseOld &A,const OneOperator * C,Stack stk,int dk=50,int itmax=0,double epsilon=1e-6) : - RNM_VirtualMatrix(A.n), - n(A.n),nbitermax(itmax?itmax: Max(100,n)), - xx_del(0),code_del(0), - precon(0),stack(stk),eps(epsilon),epsr(0),dKrylov(dk), - D1(n),xx(n) -{ - assert(C); - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH mars 2005 + void addMatMul(const KN_< Complex > &x, KN_< Complex > &Ax) const { + assert(x.N( ) == Ax.N( )); + for (int i = 0; i < n; i++) Ax[i] += D1[i] * x[i]; + } + + virtual bool ChecknbLine(int n) const { return true; } + virtual bool ChecknbColumn(int m) const { return true; } + }; + + template<> + class SolveGMRESPrecon< Complex > : public MatriceCreuseOld< Complex >::VirtualSolver, public RNM_VirtualMatrix< Complex > { + public: + typedef Complex R; + int n; + int nbitermax; + Expression xx_del, code_del; + const E_F0 *precon; + Stack stack; + double eps; + mutable double epsr; + int dKrylov; + KN< Complex > D1; + mutable KN< Complex > xx; + typedef RNM_VirtualMatrix< Complex >::plusAx plusAx; + + public: + SolveGMRESPrecon(const MatriceCreuseOld< Complex > &A, const OneOperator *C, Stack stk, int dk = 50, int itmax = 0, double epsilon = 1e-6) + : RNM_VirtualMatrix< Complex >(A.n), n(A.n), nbitermax(itmax ? itmax : Max(100, n)), xx_del(0), code_del(0), precon(0), stack(stk), eps(epsilon), epsr(0), dKrylov(dk), D1(n), xx(n) { + assert(C); + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH mars 2005 Type_Expr te_xx(CPValue(xx)); - xx_del=te_xx.second; - C_F0 e_xx(te_xx); // 1 undelete pointer - code_del= C->code(basicAC_F0_wa(e_xx)); - precon = to >(C_F0(code_del,*C));// 2 undelete pointer - //C_F0 e_xx(CPValue(xx)); - //precon = to >(C_F0(C->code(basicAC_F0_wa(e_xx)),*C)); - + xx_del = te_xx.second; + C_F0 e_xx(te_xx); // 1 undelete pointer + code_del = C->code(basicAC_F0_wa(e_xx)); + precon = to< KN_< R > >(C_F0(code_del, *C)); // 2 undelete pointer + // C_F0 e_xx(CPValue(xx)); + // precon = to >(C_F0(C->code(basicAC_F0_wa(e_xx)),*C)); + throwassert(precon); Complex aii; A.getdiag(D1); - for (int i=0;i &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrylov+1,dKrylov+1); - int k=dKrylov,nn=nbitermax; - KN_ rx=C2R(x); - const KN_ rb=C2R(b); - typedef MatC2R > VA; - typedef MatC2R > VC; + for (int i = 0; i < n; i++) D1[i] = std::norm(aii = D1[i]) < 1e-20 ? Complex(1.0) : Complex(1.) / aii; + } + void Solver(const MatriceCreuseOld< Complex > &a, KN_< Complex > &x, const KN_< Complex > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< double > H(dKrylov + 1, dKrylov + 1); + int k = dKrylov, nn = nbitermax; + KN_< double > rx = C2R(x); + const KN_< double > rb = C2R(b); + typedef MatC2R< MatriceCreuseOld< Complex > > VA; + typedef MatC2R< SolveGMRESPrecon< Complex > > VC; VA AR(a); VC CR(*this); - GMRES(AR,(KN &)rx,(const KN &)rb,CR,H,k,nn,epsr,verbosity); - - } - - void SolverT(const MatriceCreuseOld &a,KN_ &x,const KN_ &b) const { - epsr = (eps < 0) ? (epsr >0 ? -epsr : -eps ) : eps ; - KNM H(dKrylov+1,dKrylov+1); - int k=dKrylov,nn=nbitermax; - KN_ rx=C2R(x); - const KN_ rb=C2R(b); - typedef MatC2R > VA; - typedef MatC2R > VC; - VA AR(a); - VC CR(*this); - RNM_VirtualMatrixTrans ARt(AR); - GMRES(ARt,(KN &)rx,(const KN &)rb,CR,H,k,nn,epsr,verbosity); + GMRES(AR, (KN< double > &)rx, (const KN< double > &)rb, CR, H, k, nn, epsr, verbosity); + } + void SolverT(const MatriceCreuseOld< R > &a, KN_< R > &x, const KN_< R > &b) const { + epsr = (eps < 0) ? (epsr > 0 ? -epsr : -eps) : eps; + KNM< double > H(dKrylov + 1, dKrylov + 1); + int k = dKrylov, nn = nbitermax; + KN_< double > rx = C2R(x); + const KN_< double > rb = C2R(b); + typedef MatC2R< MatriceCreuseOld< Complex > > VA; + typedef MatC2R< SolveGMRESPrecon< Complex > > VC; + VA AR(a); + VC CR(*this); + RNM_VirtualMatrixTrans< double > ARt(AR); + GMRES(ARt, (KN< double > &)rx, (const KN< double > &)rb, CR, H, k, nn, epsr, verbosity); } -plusAx operator*(const KN_ & x) const {return plusAx(this,x);} + plusAx operator*(const KN_< Complex > &x) const { return plusAx(this, x); } + void addMatMul(const KN_< Complex > &x, KN_< Complex > &Ax) const { + assert(x.N( ) == Ax.N( )); - void addMatMul(const KN_ & x, KN_ & Ax) const - { - assert(x.N()==Ax.N()); - - xx=x; - // cout << x[0] << " "; - xx=GetAny >((*precon)(stack)); - WhereStackOfPtr2Free(stack)->clean(); + xx = x; + // cout << x[0] << " "; + xx = GetAny< KN_< Complex > >((*precon)(stack)); + WhereStackOfPtr2Free(stack)->clean( ); -// cout << (xx)[0] << " " << endl; - Complex dii; - for (int i=0;iclean(); // FH mars 2005 - delete xx_del; - delete code_del; - - // cout << "~SolveGMRESPrecon; " << endl; - } - virtual bool ChecknbLine(int ) const { return true;} - virtual bool ChecknbColumn(int ) const { return true;} - - -}; + ~SolveGMRESPrecon( ) { + WhereStackOfPtr2Free(stack)->clean( ); // FH mars 2005 + delete xx_del; + delete code_del; + + // cout << "~SolveGMRESPrecon; " << endl; + } + virtual bool ChecknbLine(int) const { return true; } + virtual bool ChecknbColumn(int) const { return true; } + }; #endif +#define LIST_NAME_PARM_MAT \ + {"init", &typeid(bool)}, {"solver", &typeid(string *)}, {"eps", &typeid(double)}, {"precon", &typeid(Polymorphic *)}, {"dimKrylov", &typeid(long)}, \ + \ + {"tgv", &typeid(double)}, {"factorize", &typeid(long)}, {"strategy", &typeid(long)}, {"tolpivot", &typeid(double)}, {"tolpivotsym", &typeid(double)}, \ + \ + {"nbiter", &typeid(long)}, {"datafilename", &typeid(string *)}, {"lparams", &typeid(KN_< long >)}, {"dparams", &typeid(KN_< double >)}, {"smap", &typeid(map< string, string > *)}, \ + \ + {"permr", &typeid(KN_< long >)}, {"permc", &typeid(KN_< long >)}, {"scaler", &typeid(KN_< double >)}, {"scalec", &typeid(KN_< double >)}, {"sparams", &typeid(string *)}, \ + \ + {"commworld", &typeid(pcommworld)}, {"master", &typeid(long)}, {"rinfo", &typeid(KN< double > *)}, {"info", &typeid(KN< long > *)}, {"kerneln", &typeid(KNM< double > *)}, \ + \ + {"kernelt", &typeid(KNM< double > *)}, {"kerneldim", &typeid(long *)}, {"verb", &typeid(long)}, {"x0", &typeid(bool)}, {"veps", &typeid(double *)}, \ + \ + {"rightprecon", &typeid(bool)}, {"sym", &typeid(long)}, {"positive", &typeid(bool)}, { \ + "getnbiteration", &typeid(long *) \ + } -#define LIST_NAME_PARM_MAT \ - { "init", &typeid(bool)}, \ - { "solver", &typeid(string*)}, \ - { "eps", &typeid(double) }, \ - { "precon",&typeid(Polymorphic*)}, \ - { "dimKrylov",&typeid(long)}, \ -\ - { "tgv",&typeid(double )}, \ - { "factorize",&typeid(long)}, \ - { "strategy",&typeid(long )}, \ - { "tolpivot",&typeid(double )}, \ - { "tolpivotsym",&typeid(double )}, \ - \ - \ - { "nbiter", &typeid(long)}, \ - { "datafilename", &typeid(string*)} , \ - { "lparams",&typeid(KN_)} , \ - { "dparams", &typeid(KN_)}, \ - { "smap", &typeid(map*)}, \ - \ - { "permr", &typeid(KN_)}, \ - { "permc", &typeid(KN_)}, \ - { "scaler", &typeid(KN_)}, \ - { "scalec", &typeid(KN_)}, \ - { "sparams", &typeid(string*)}, \ - \ - \ - { "commworld", &typeid(pcommworld)}, \ - { "master", &typeid(long)}, \ - { "rinfo", &typeid(KN*)}, \ - { "info", &typeid(KN*)}, \ - { "kerneln", &typeid( KNM *)}, \ - \ - { "kernelt", &typeid( KNM *)}, \ - { "kerneldim", &typeid(long*)}, \ - { "verb", &typeid(long)}, \ - { "x0", &typeid(bool)}, \ - { "veps", &typeid(double*) }, \ - \ - \ - { "rightprecon", &typeid(bool) }, \ - { "sym", &typeid(long) }, \ - { "positive", &typeid(bool) } ,\ - { "getnbiteration", &typeid(long*) } - -const int NB_NAME_PARM_MAT = 24 +6+4 ; - -// declaration for HMat bem - -#define LIST_NAME_PARM_HMAT \ - { "eta", &typeid(double)}, \ - { "maxleafsize", &typeid(long)}, \ - { "mintargetdepth", &typeid(long)}, \ - { "minsourcedepth", &typeid(long)}, \ - { "compressor",&typeid(string*)}, \ - { "recompress",&typeid(bool)}, \ - { "initialclustering",&typeid(string*)}, \ - { "clusteringdirections",&typeid(string*)}, \ - { "adaptiveclustering",&typeid(bool)} - -const int NB_NAME_PARM_HMAT = 9; - - -template -inline void SetEnd_Data_Sparse_Solver(Stack stack,Data_Sparse_Solver & ds,Expression const *nargs ,int n_name_param,int syma=-1) - { - bool unset_eps=true; - ds.initmat=true; - ds.factorize=0; - int kk = n_name_param-NB_NAME_PARM_MAT-1; - if (nargs[++kk]) ds.initmat= ! GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.solver= * GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.epsilon= GetAny((*nargs[kk])(stack)),unset_eps=false; - if (nargs[++kk]) - {// modif FH fev 2010 ... - const Polymorphic * op= dynamic_cast(nargs[kk]); - if(op) - { - ds.precon = op->Find("(",ArrayOfaType(atype* >(),false)); // strange bug in g++ is R become a double - ffassert(ds.precon); - } // add miss - } - - if (nargs[++kk]) ds.NbSpace= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tgv= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.factorize= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.strategy = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tol_pivot = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.tol_pivot_sym = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.itmax = GetAny((*nargs[kk])(stack)); // frev 2007 OK - if (nargs[++kk]) ds.data_filename = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.lparams = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.dparams = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.smap = GetAny *>((*nargs[kk])(stack)); - if (nargs[++kk]) ds.perm_r = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.perm_c = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.scale_r = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.scale_c = GetAny >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.sparams = *GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.commworld = GetAny((*nargs[kk])(stack)); + const int NB_NAME_PARM_MAT = 24 + 6 + 4; + + // declaration for HMat bem + +#define LIST_NAME_PARM_HMAT \ + {"eta", &typeid(double)}, {"maxleafsize", &typeid(long)}, {"mintargetdepth", &typeid(long)}, {"minsourcedepth", &typeid(long)}, {"compressor", &typeid(string *)}, {"recompress", &typeid(bool)}, \ + {"initialclustering", &typeid(string *)}, {"clusteringdirections", &typeid(string *)}, { \ + "adaptiveclustering", &typeid(bool) \ + } + + const int NB_NAME_PARM_HMAT = 9; + + template< class R > + inline void SetEnd_Data_Sparse_Solver(Stack stack, Data_Sparse_Solver &ds, Expression const *nargs, int n_name_param, int syma = -1) { + bool unset_eps = true; + ds.initmat = true; + ds.factorize = 0; + int kk = n_name_param - NB_NAME_PARM_MAT - 1; + if (nargs[++kk]) ds.initmat = !GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.solver = *GetAny< string * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.epsilon = GetAny< double >((*nargs[kk])(stack)), unset_eps = false; + if (nargs[++kk]) { // modif FH fev 2010 ... + const Polymorphic *op = dynamic_cast< const Polymorphic * >(nargs[kk]); + if (op) { + ds.precon = op->Find("(", ArrayOfaType(atype< KN< R > * >( ), false)); // strange bug in g++ is R become a double + ffassert(ds.precon); + } // add miss + } + + if (nargs[++kk]) ds.NbSpace = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tgv = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.factorize = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.strategy = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tol_pivot = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.tol_pivot_sym = GetAny< double >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.itmax = GetAny< long >((*nargs[kk])(stack)); // frev 2007 OK + if (nargs[++kk]) ds.data_filename = *GetAny< string * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.lparams = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.dparams = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.smap = GetAny< MyMap< String, String > * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.perm_r = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.perm_c = GetAny< KN_< long > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.scale_r = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.scale_c = GetAny< KN_< double > >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.sparams = *GetAny< string * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.commworld = GetAny< pcommworld >((*nargs[kk])(stack)); #ifdef VDATASPARSESOLVER - if (nargs[++kk]) ds.master = GetAny((*nargs[kk])(stack)); + if (nargs[++kk]) ds.master = GetAny< long >((*nargs[kk])(stack)); #else - ++kk; + ++kk; #endif - // add FH nov 2015 .. - if (nargs[++kk]) ds.rinfo = GetAny* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.info = GetAny* >((*nargs[kk])(stack)); - // add FH juin 2018 .. - if (nargs[++kk]) ds.kerneln = GetAny< KNM* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.kernelt = GetAny< KNM* >((*nargs[kk])(stack)); - if (nargs[++kk]) ds.kerneldim = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.verb = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.x0 = GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.veps= GetAny((*nargs[kk])(stack)); - if( unset_eps && ds.veps) ds.epsilon = *ds.veps;// if veps and no def value => veps def value of epsilon. - if (nargs[++kk]) ds.rightprecon= GetAny((*nargs[kk])(stack)); - ds.sym = syma; - if (nargs[++kk]) ds.sym= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) ds.positive= GetAny((*nargs[kk])(stack)); - if (nargs[++kk]) { ds.getnbiter= GetAny((*nargs[kk])(stack)); - if( ds.getnbiter) *ds.getnbiter=-1; //undef - } - ds.Init_sym_positive_var(ds.sym);// set def value of sym and posi - if(ds.solver == "") - { // SET DEFAULT SOLVER TO HRE ... - if( ds.sym && ds.positive ) ds.solver=*def_solver_sym_dp; - else if( ds.sym ) ds.solver=*def_solver_sym; - else ds.solver=*def_solver; - if(verbosity>4) cout << " **Warning: set default solver to " << ds.solver << endl; - } - - ffassert(++kk == n_name_param); + // add FH nov 2015 .. + if (nargs[++kk]) ds.rinfo = GetAny< KN< double > * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.info = GetAny< KN< long > * >((*nargs[kk])(stack)); + // add FH juin 2018 .. + if (nargs[++kk]) ds.kerneln = GetAny< KNM< double > * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.kernelt = GetAny< KNM< double > * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.kerneldim = GetAny< long * >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.verb = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.x0 = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.veps = GetAny< double * >((*nargs[kk])(stack)); + if (unset_eps && ds.veps) ds.epsilon = *ds.veps; // if veps and no def value => veps def value of epsilon. + if (nargs[++kk]) ds.rightprecon = GetAny< bool >((*nargs[kk])(stack)); + ds.sym = syma; + if (nargs[++kk]) ds.sym = GetAny< long >((*nargs[kk])(stack)); + if (nargs[++kk]) ds.positive = GetAny< bool >((*nargs[kk])(stack)); + if (nargs[++kk]) { + ds.getnbiter = GetAny< long * >((*nargs[kk])(stack)); + if (ds.getnbiter) *ds.getnbiter = -1; // undef + } + ds.Init_sym_positive_var< R >(ds.sym); // set def value of sym and posi + if (ds.solver == "") { // SET DEFAULT SOLVER TO HRE ... + if (ds.sym && ds.positive) + ds.solver = *def_solver_sym_dp; + else if (ds.sym) + ds.solver = *def_solver_sym; + else + ds.solver = *def_solver; + if (verbosity > 4) cout << " **Warning: set default solver to " << ds.solver << endl; } -} // end of namespace Fem2D + + ffassert(++kk == n_name_param); + } +} // end of namespace Fem2D #endif diff --git a/src/fflib/load.cpp b/src/fflib/load.cpp index c9dc82733..e982556c7 100644 --- a/src/fflib/load.cpp +++ b/src/fflib/load.cpp @@ -22,7 +22,7 @@ // TODO: remove this block as soon as autoconf is removed from FreeFEM #ifndef CMAKE -#include // needed for HAVE_DLFCN_H +#include // needed for HAVE_DLFCN_H #endif #include @@ -49,28 +49,27 @@ using namespace std; #include "ffapi.hpp" -set SetLoadFile; +set< string > SetLoadFile; -bool load (string ss) { +bool load(string ss) { // FFCS - do not allow potentially dangerous commands from remote anonymous clients - static int count =0; - if(count++==0) SetLoadFile.insert("msh3"); - if (ffapi::protectedservermode() && (ss == "pipe" || ss == "shell")) { + static int count = 0; + if (count++ == 0) SetLoadFile.insert("msh3"); + if (ffapi::protectedservermode( ) && (ss == "pipe" || ss == "shell")) { cerr << "library " << ss << " not allowed in server environment" << endl; CompileError("Error load"); return 0; } - if (SetLoadFile.find(ss) != SetLoadFile.end()) { - if ((mpirank == 0) && verbosity) - cout << " (already loaded: " << ss << ")"; + if (SetLoadFile.find(ss) != SetLoadFile.end( )) { + if ((mpirank == 0) && verbosity) cout << " (already loaded: " << ss << ")"; } else { SetLoadFile.insert(ss); bool ret = false; void *handle = 0; - const int /*nbprefix=2,*/nbsuffix = 2; - list prefix(ffenvironment["loadpath"]); - if (prefix.empty()) { + const int /*nbprefix=2,*/ nbsuffix = 2; + list< string > prefix(ffenvironment["loadpath"]); + if (prefix.empty( )) { prefix.push_back(""); prefix.push_back("./"); } @@ -85,38 +84,33 @@ bool load (string ss) { suffix[1] = ".dll"; #endif int j; - for (list::const_iterator i = prefix.begin(); i != prefix.end(); ++i) + for (list< string >::const_iterator i = prefix.begin( ); i != prefix.end( ); ++i) for (j = 0; j < nbsuffix; ++j) { string s = *i + ss + suffix[j]; #ifdef LOAD - handle = dlopen(s.c_str(), RTLD_NOW); // RTLD_GLOBAL RTLD_LAZY - if (verbosity > 9) - cout << " test dlopen(" << s << ") = " << handle << endl; + handle = dlopen(s.c_str( ), RTLD_NOW); // RTLD_GLOBAL RTLD_LAZY + if (verbosity > 9) cout << " test dlopen(" << s << ") = " << handle << endl; // FFCS - 20/9/11 - print explanation for load errors - if (verbosity > 9 && !handle) - cout << "load error was: " << dlerror() << endl; + if (verbosity > 9 && !handle) cout << "load error was: " << dlerror( ) << endl; ret = handle != 0; if (ret) { - if (verbosity > 1 && (mpirank == 0)) - cout << " (load: dlopen " << s << " " << handle << ")\n"; - callInitsFunct(); // [[file:InitFunct.cpp::callInitsFunct]] + if (verbosity > 1 && (mpirank == 0)) cout << " (load: dlopen " << s << " " << handle << ")\n"; + callInitsFunct( ); // [[file:InitFunct.cpp::callInitsFunct]] return handle; } #elif _WIN32 { - HINSTANCE mod = LoadLibrary(s.c_str()); + HINSTANCE mod = LoadLibrary(s.c_str( )); if (verbosity > 9) cout << " test LoadLibrary(" << s << ") = " << mod << endl; if (mod == 0) { - DWORD merr = GetLastError(); - if (verbosity > 19) - cerr << "\n try loadLibary: " << s << "\n\t fail: " << merr << endl; + DWORD merr = GetLastError( ); + if (verbosity > 19) cerr << "\n try loadLibary: " << s << "\n\t fail: " << merr << endl; } else { - if (verbosity && (mpirank == 0)) - cout << "(load: loadLibary " << s << " = " << handle << ")"; - callInitsFunct(); // [[file:InitFunct.cpp::callInitsFunct]] + if (verbosity && (mpirank == 0)) cout << "(load: loadLibary " << s << " = " << handle << ")"; + callInitsFunct( ); // [[file:InitFunct.cpp::callInitsFunct]] return mod; } } @@ -127,27 +121,26 @@ bool load (string ss) { // <> [[file:~/ff/examples++-load/msh3.cpp::dynamic_loading]] if (ss == "msh3-old") { // [[file:~/ff/examples++-load/msh3.cpp::msh3_Load_Init]] - void msh3_Load_Init(); - msh3_Load_Init(); + void msh3_Load_Init( ); + msh3_Load_Init( ); ok = true; } // <> [[file:~/ff/examples++-load/medit.cpp::dynamic_loading]] if (ss == "medit") { // [[file:~/ff/examples++-load/medit.cpp::medit_Load_Init]] - void medit_Load_Init(); - medit_Load_Init(); + void medit_Load_Init( ); + medit_Load_Init( ); ok = true; } - if (ok && verbosity && (mpirank == 0)) - cout << " (static load: " << ss << ")"; + if (ok && verbosity && (mpirank == 0)) cout << " (static load: " << ss << ")"; return ok; #else if (mpirank == 0) { - cout << "--------------------------------------- \n" ; - cout << " load: sorry no dlopen on this system " << s << " \n" ; - cout << "--------------------------------------- \n" ; + cout << "--------------------------------------- \n"; + cout << " load: sorry no dlopen on this system " << s << " \n"; + cout << "--------------------------------------- \n"; } CompileError("not load / dlopen on this system"); return 0; @@ -159,21 +152,20 @@ bool load (string ss) { char *error = 0; #ifndef _WIN32 #ifdef LOAD - error = dlerror(); + error = dlerror( ); if (error != NULL) { cerr << " dlerror : " << error << endl; } #endif #endif cerr << "list prefix: "; - for (list::const_iterator i = prefix.begin(); i != prefix.end(); ++i) - cerr << "'" << *i << "' "; + for (list< string >::const_iterator i = prefix.begin( ); i != prefix.end( ); ++i) cerr << "'" << *i << "' "; cerr << "list suffix: '" << suffix[0] << "' , '" << suffix[1] << "' "; cerr << endl; } - throw(ErrorLoad(ss.c_str(), zzzfff->lineno(), zzzfff->YYText())); - //ErrorLoad("Error load"); + throw(ErrorLoad(ss.c_str( ), zzzfff->lineno( ), zzzfff->YYText( ))); + // ErrorLoad("Error load"); } return 0; } diff --git a/src/fflib/msh3.cpp b/src/fflib/msh3.cpp index ee869b10c..ec46c4857 100644 --- a/src/fflib/msh3.cpp +++ b/src/fflib/msh3.cpp @@ -60,33 +60,28 @@ using namespace std; #include "renumb.hpp" #include -namespace std -{ - template - struct hash > - { - typedef array argument_type; - typedef size_t result_type; - - result_type operator()(const argument_type& a) const - { - hash hasher; - result_type h = 0; - for (result_type i = 0; i < N; ++i) - { - h = h * 31 + hasher(a[i]); - } - return h; - } - }; -} +namespace std { + template< typename T, size_t N > + struct hash< array< T, N > > { + typedef array< T, N > argument_type; + typedef size_t result_type; + + result_type operator( )(const argument_type &a) const { + hash< T > hasher; + result_type h = 0; + for (result_type i = 0; i < N; ++i) { + h = h * 31 + hasher(a[i]); + } + return h; + } + }; +} // namespace std using namespace Fem2D; int ChangeLab(const map< int, int > &m, int lab); -void TestSameVertexMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nv_t, int *Numero_Som) { +void TestSameVertexMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nv_t, int *Numero_Som) { Vertex3 *v = new Vertex3[Th3.nv]; nv_t = 0; @@ -116,8 +111,7 @@ void TestSameVertexMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, delete[] v; } -void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nt_t) { +void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nt_t) { Vertex3 *vt = new Vertex3[Th3.nt]; EF23::GTree< Vertex3 > *gtree_t = new EF23::GTree< Vertex3 >(vt, Pinf, Psup, 0); @@ -146,8 +140,7 @@ void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &P delete[] vt; } -void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int *Elem_ok, int &nt_t) { +void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int *Elem_ok, int &nt_t) { Vertex3 *vt = new Vertex3[Th3.nt]; EF23::GTree< Vertex3 > *gtree_t = new EF23::GTree< Vertex3 >(vt, Pinf, Psup, 0); @@ -183,8 +176,7 @@ void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &P delete[] vt; } -void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nbe_t) { +void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nbe_t) { Vertex3 *vbe = new Vertex3[Th3.nbe]; EF23::GTree< Vertex3 > *gtree_be = new EF23::GTree< Vertex3 >(vbe, Pinf, Psup, 0); @@ -214,8 +206,7 @@ void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psu delete[] vbe; } -void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int *Border_ok, int &nbe_t) { +void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int *Border_ok, int &nbe_t) { Vertex3 *vbe = new Vertex3[Th3.nbe]; EF23::GTree< Vertex3 > *gtree_be = new EF23::GTree< Vertex3 >(vbe, Pinf, Psup, 0); @@ -282,10 +273,8 @@ int TestElementMesh3(const Mesh3 &Th3) { } for (int eh = 0; eh < 6; eh++) { - cout << "tetrahedra: " << k << " edge : " << eh << " length " << Th3[k].lenEdge(eh) - << endl; - cout << " Tet vertices : " << iv[0] << " " << iv[1] << " " << iv[2] << " " << iv[3] << " " - << endl; + cout << "tetrahedra: " << k << " edge : " << eh << " length " << Th3[k].lenEdge(eh) << endl; + cout << " Tet vertices : " << iv[0] << " " << iv[1] << " " << iv[2] << " " << iv[3] << " " << endl; } cout << " A tetrahedra with a very small edge was created " << endl; @@ -301,8 +290,7 @@ int TestElementMesh3(const Mesh3 &Th3) { for (int e = 0; e < 3; e++) { if (Th3.be(k).lenEdge(e) < Norme2(Psup - Pinf) / 1e9) { for (int eh = 0; eh < 3; eh++) { - cout << "triangles: " << k << " edge : " << eh << " length " << Th3.be(k).lenEdge(e) - << endl; + cout << "triangles: " << k << " edge : " << eh << " length " << Th3.be(k).lenEdge(e) << endl; } cout << " A triangle with a very small edges was created " << endl; @@ -771,8 +759,7 @@ void discretisation_max_mesh(const int choix, const Mesh &Th2, int &Nmax) { } } -void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, - double *tab_zmax, int *tab_Ni) { +void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, double *tab_zmax, int *tab_Ni) { Nmax = 0; for (int ii = 0; ii < Th2.nv; ii++) { @@ -829,8 +816,7 @@ void build_layer_map_tetrahedra(const Mesh &Th2, map< int, int > &maptet) { // cout << "number of tetraedra label=" << numero_label << endl; } -void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, - map< int, int > &maptrizmax, map< int, int > &maptrizmin) { +void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, map< int, int > &maptrizmax, map< int, int > &maptrizmin) { int numero_label = 0; // cout << "in: buil_layer_map_triangle" << endl; @@ -865,8 +851,7 @@ void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, } } -void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, - map< int, int > &mapezmin) { +void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, map< int, int > &mapezmin) { int numero_label = 0; for (int ii = 0; ii < Th2.neb; ii++) { @@ -892,11 +877,8 @@ void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, i } } -Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, - const double *tab_zmax, const map< int, int > &maptet, - const map< int, int > &maptrimil, const map< int, int > &maptrizmax, - const map< int, int > &maptrizmin, const map< int, int > &mapemil, - const map< int, int > &mapezmax, const map< int, int > &mapezmin) { +Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const map< int, int > &maptet, const map< int, int > &maptrimil, + const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin) { int MajSom, MajElem, MajBord2D; Mesh3 *Th3 = new Mesh3; @@ -919,9 +901,7 @@ Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const dou << endl; } - Som3D_mesh_product_Version_Sommet_mesh_tab(Nmax, tab_Ni, tab_zmin, tab_zmax, Th2, maptet, - maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, - mapezmin, *Th3); + Som3D_mesh_product_Version_Sommet_mesh_tab(Nmax, tab_Ni, tab_zmin, tab_zmax, Th2, maptet, maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, mapezmin, *Th3); // Add FH because remove in call function.. @@ -933,9 +913,7 @@ Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const dou return Th3; } -void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, - const Mesh &Th2, int &MajSom, int &MajElem, - int &MajBord2D) { +void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, const Mesh &Th2, int &MajSom, int &MajElem, int &MajBord2D) { int i; MajSom = 0; @@ -975,12 +953,9 @@ void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int * // exit(1); } -void Som3D_mesh_product_Version_Sommet_mesh_tab( - const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, - const Mesh &Th2, const map< int, int > &maptet, const map< int, int > &maptrimil, - const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, - const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin, - Mesh3 &Th3) { +void Som3D_mesh_product_Version_Sommet_mesh_tab(const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const Mesh &Th2, const map< int, int > &maptet, + const map< int, int > &maptrimil, const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, + const map< int, int > &mapezmax, const map< int, int > &mapezmin, Mesh3 &Th3) { // intent(in) Nmax,Mesh &A2D // intent(out) Mesh3 &A3D @@ -1724,8 +1699,7 @@ void dpent1_mesh(int idl[3], int nu[12], int &nbe, int &option) { for (i2 = 1; i2 <= 2; i2++) { for (i1 = 1; i1 <= 2; i1++) { idf = idf + 1; - if ((pdd[idf] != 0) && (idl[0] == 0 || idl[0] == i1) && (idl[1] == 0 || idl[1] == i2) && - (idl[2] == 0 || idl[2] == i3)) { + if ((pdd[idf] != 0) && (idl[0] == 0 || idl[0] == i1) && (idl[1] == 0 || idl[1] == i2) && (idl[2] == 0 || idl[2] == i3)) { // nbdp=nbdp+1; idp[nbdp] = idf; nbdp = nbdp + 1; @@ -1767,20 +1741,14 @@ class listMesh3 { void destroy( ) { delete lth; } - listMesh3(Stack s, const Mesh3 *th) : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >)) { - lth->push_back(th); - } + listMesh3(Stack s, const Mesh3 *th) : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >)) { lth->push_back(th); } - listMesh3(Stack s, const Mesh3 *tha, const Mesh3 *thb) - : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >)) { + listMesh3(Stack s, const Mesh3 *tha, const Mesh3 *thb) : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >)) { lth->push_back(tha); lth->push_back(thb); } - listMesh3(Stack s, const listMesh3 &l, const Mesh3 *th) - : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >(*l.lth))) { - lth->push_back(th); - } + listMesh3(Stack s, const listMesh3 &l, const Mesh3 *th) : lth(Add2StackOfPtr2Free(s, new list< const Mesh3 * >(*l.lth))) { lth->push_back(th); } }; // to be modified Mesh3 *GluMesh3(listMesh3 const &lst) { @@ -1805,8 +1773,7 @@ Mesh3 *GluMesh3(listMesh3 const &lst) { const Mesh3 &Th3(**i); // definis ??? th0 = &Th3; if (verbosity > 1) { - cout << " determination of hmin : GluMesh3D + " << Th3.nv << " " << Th3.nt << " " << Th3.nbe - << endl; + cout << " determination of hmin : GluMesh3D + " << Th3.nv << " " << Th3.nt << " " << Th3.nbe << endl; } nbt += Th3.nt; nbvx += Th3.nv; @@ -1935,8 +1902,7 @@ Mesh3 *GluMesh3(listMesh3 const &lst) { gtree_be->Add(becog[nbe++]); int igluv[3]; - for (int i = 0; i < 3; i++) - igluv[i] = gtree->ToClose(K[i], hseuil) - v; // NumSom[iv[0]+nbv0]; + for (int i = 0; i < 3; i++) igluv[i] = gtree->ToClose(K[i], hseuil) - v; // NumSom[iv[0]+nbv0]; (bb++)->set(v, igluv, K.lab); } @@ -1982,17 +1948,17 @@ Mesh3 *GluMesh3(listMesh3 const &lst) { template< class RR, class AA = RR, class BB = AA > struct Op3_addmesh { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; static RR f(Stack s, const AA &a, const BB &b) { return RR(s, a, b); } }; template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op3_setmesh { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; static RR f(Stack stack, const AA &a, const BB &b) { ffassert(a); const pmesh3 p = GluMesh3(b); @@ -2015,418 +1981,374 @@ class listMeshS { void destroy( ) { delete lth; } - listMeshS(Stack s, const MeshS *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >)) { - lth->push_back(th); + listMeshS(Stack s, const MeshS *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >)) { lth->push_back(th); } + + listMeshS(Stack s, const MeshS *tha, const MeshS *thb) : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >)) { + lth->push_back(tha); + lth->push_back(thb); } - listMeshS(Stack s, const MeshS *tha, const MeshS *thb) - : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >)) { + listMeshS(Stack s, const listMeshS &l, const MeshS *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >(*l.lth))) { lth->push_back(th); } +}; + +template< class MeshT > +class listMeshT { + public: + typedef MeshT Mesh; + typedef const MeshT *pmeshT; + typedef list< const MeshT * > List; + list< const MeshT * > *lth; + void init( ) { lth = new list< const MeshT * >; } + + void destroy( ) { delete lth; } + + listMeshT(Stack s, const MeshT *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { lth->push_back(th); } + + listMeshT(Stack s, const MeshT *tha, const MeshT *thb) : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { lth->push_back(tha); lth->push_back(thb); } - listMeshS(Stack s, const listMeshS &l, const MeshS *th) - : lth(Add2StackOfPtr2Free(s, new list< const MeshS * >(*l.lth))) { - lth->push_back(th); + listMeshT(Stack s, const listMeshT &l, const MeshT *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >(*l.lth))) { lth->push_back(th); } + listMeshT(Stack s, KN< pmeshT > *const &tab) : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { + for (int i = 0; i < tab->N( ); ++i) lth->push_back((*tab)[i]); } }; -template -class listMeshT { -public: - typedef MeshT Mesh; - typedef const MeshT *pmeshT; - typedef list< const MeshT * > List; - list< const MeshT * > *lth; - void init( ) { lth = new list< const MeshT * >; } - - void destroy( ) { delete lth; } - - listMeshT(Stack s, const MeshT *th) : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { - lth->push_back(th); - } - - listMeshT(Stack s, const MeshT *tha, const MeshT *thb) - : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { - lth->push_back(tha); - lth->push_back(thb); - } - - listMeshT(Stack s, const listMeshT &l, const MeshT *th) - : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >(*l.lth))) { - lth->push_back(th); - } - listMeshT(Stack s, KN< pmeshT > *const &tab) - : lth(Add2StackOfPtr2Free(s, new list< const MeshT * >)) { - for(int i=0; iN();++i) - lth->push_back((*tab)[i]); +MeshS *GluMesh(listMeshT< MeshS > const &lst) { + typedef typename MeshS::Element T; + typedef typename MeshS::BorderElement B; + typedef typename MeshS::Vertex V; + typedef typename MeshS::Element::RdHat TRdHat; + typedef typename MeshS::BorderElement::RdHat BRdHat; + + int nbv = 0, nbt = 0, nbe = 0, nbvx = 0, nbtx = 0, nbex = 0; + + double hmin = 1e100; + R3 Pn(1e100, 1e100, 1e100), Px(-1e100, -1e100, -1e100); + const list< MeshS const * > lth(*lst.lth); + const MeshS *th0 = 0; + int kk = 0; + + for (typename list< MeshS const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; + ++kk; + const MeshS &Th(**i); + th0 = &Th; + if (verbosity > 1) cout << " GluMesh + " << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; + nbtx += Th.nt; + nbvx += Th.nv; + nbex += Th.nbe; + + for (int k = 0; k < Th.nt; k++) + for (int e = 0; e < 3; e++) hmin = min(hmin, Th[k].lenEdge(e)); + + for (int i = 0; i < Th.nv; i++) { + R3 P(Th(i)); + Pn = Minc(P, Pn); + Px = Maxc(P, Px); } -}; + } + if (kk == 0) return 0; // no mesh ... + if (verbosity > 2) cout << " - hmin =" << hmin << " , Bounding Box: " << Pn << " " << Px << endl; + V *v = new V[nbvx]; + T *t = new T[nbtx]; + T *tt = t; + B *b = new B[nbex]; + B *bb = b; + ffassert(hmin > Norme2(Pn - Px) / 1e9); + double hseuil = hmin / 10.; + EF23::GTree< V > *gtree = new EF23::GTree< V >(v, Pn, Px, 0); + for (typename list< MeshS const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; // + const MeshS &Th(**i); + if (!*i) continue; + if (verbosity > 1) + cout << " GluMesh + " + << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; -MeshS *GluMesh(listMeshT const &lst) { - typedef typename MeshS::Element T; - typedef typename MeshS::BorderElement B; - typedef typename MeshS::Vertex V; - typedef typename MeshS::Element::RdHat TRdHat; - typedef typename MeshS::BorderElement::RdHat BRdHat; - - int nbv = 0, nbt = 0, nbe = 0, nbvx = 0, nbtx = 0, nbex = 0; - - double hmin = 1e100; - R3 Pn(1e100, 1e100, 1e100), Px(-1e100, -1e100, -1e100); - const list< MeshS const * > lth(*lst.lth); - const MeshS *th0 = 0; - int kk = 0; - - for (typename list< MeshS const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { - if (!*i) continue; - ++kk; - const MeshS &Th(**i); - th0 = &Th; - if (verbosity > 1) - cout << " GluMesh + "<< "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; - nbtx += Th.nt; - nbvx += Th.nv; - nbex += Th.nbe; - - for (int k = 0; k < Th.nt; k++) - for (int e = 0; e < 3; e++) - hmin = min(hmin, Th[k].lenEdge(e)); - - for (int i = 0; i < Th.nv; i++) { - R3 P(Th(i)); - Pn = Minc(P, Pn); - Px = Maxc(P, Px); - } + for (int ii = 0; ii < Th.nv; ii++) { + const V &vi(Th(ii)); + V *pvi = gtree->ToClose(vi, hseuil); + if (!pvi) { + v[nbv].x = vi.x; + v[nbv].y = vi.y; + v[nbv].z = vi.z; + v[nbv].lab = vi.lab; + gtree->Add(v[nbv++]); + } } - if (kk == 0) return 0; // no mesh ... - if (verbosity > 2) - cout << " - hmin =" << hmin << " , Bounding Box: " << Pn << " " << Px << endl; - V *v = new V[nbvx]; - T *t = new T[nbtx]; - T *tt = t; - B *b = new B[nbex]; - B *bb = b; - ffassert(hmin > Norme2(Pn - Px) / 1e9); - double hseuil = hmin / 10.; - - EF23::GTree< V > *gtree = new EF23::GTree< V >(v, Pn, Px, 0); - - for (typename list< MeshS const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { - if (!*i) continue; // - const MeshS &Th(**i); - if (!*i) continue; - if (verbosity > 1) - cout << " GluMesh + " - << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; - - for (int ii = 0; ii < Th.nv; ii++) { - const V &vi(Th(ii)); - V *pvi = gtree->ToClose(vi, hseuil); - if (!pvi) { - v[nbv].x = vi.x; - v[nbv].y = vi.y; - v[nbv].z = vi.z; - v[nbv].lab = vi.lab; - gtree->Add(v[nbv++]); - } - } + } + + double hseuil_border = hseuil / 3.; + // gtree for barycenter of elements + Vertex3 *becog1 = new V[nbtx]; + EF23::GTree< V > *gtree_e = new EF23::GTree< V >(becog1, Pn, Px, 0); + // gtree for barycenter of border elements + V *becog2 = new V[nbex]; + EF23::GTree< V > *gtree_be = new EF23::GTree< V >(becog2, Pn, Px, 0); + + for (typename list< const MeshS * >::const_iterator i = lth.begin( ); i != lth.end( ); i++) { + if (!*i) continue; + const MeshS &Th(**i); + + if (verbosity > 1) cout << " creation of : BuildGTree for elements" << endl; + + TRdHat PtHat1 = TRdHat::diag(1. / T::nv); + for (int k = 0; k < Th.nt; k++) { + const T &K(Th[k]); + const R3 r3vi(K(PtHat1)); + const V &vi(r3vi); + V *pvi = gtree_e->ToClose(vi, hseuil_border); + if (!pvi) { + becog1[nbt].x = vi.x; + becog1[nbt].y = vi.y; + becog1[nbt].z = vi.z; + becog1[nbt].lab = vi.lab; + gtree_e->Add(becog1[nbt++]); + + int igluv[T::nv]; + for (int i = 0; i < (T::nv); i++) igluv[i] = gtree->ToClose(K[i], hseuil) - v; + (tt++)->set(v, igluv, K.lab); + } } - - double hseuil_border = hseuil / 3.; - // gtree for barycenter of elements - Vertex3 *becog1 = new V[nbtx]; - EF23::GTree< V > *gtree_e = new EF23::GTree< V >(becog1, Pn, Px, 0); - // gtree for barycenter of border elements - V *becog2 = new V[nbex]; - EF23::GTree< V > *gtree_be = new EF23::GTree< V >(becog2, Pn, Px, 0); - - for (typename list< const MeshS * >::const_iterator i = lth.begin( ); i != lth.end( ); i++) { - if (!*i) - continue; - const MeshS &Th(**i); - - if (verbosity > 1) - cout << " creation of : BuildGTree for elements" << endl; - - TRdHat PtHat1 = TRdHat::diag(1. / T::nv); - for (int k = 0; k < Th.nt; k++) { - const T &K(Th[k]); - const R3 r3vi(K(PtHat1)); - const V &vi(r3vi); - V *pvi = gtree_e->ToClose(vi, hseuil_border); - if (!pvi) { - becog1[nbt].x = vi.x; - becog1[nbt].y = vi.y; - becog1[nbt].z = vi.z; - becog1[nbt].lab = vi.lab; - gtree_e->Add(becog1[nbt++]); - - int igluv[T::nv]; - for (int i = 0; i < (T::nv); i++) - igluv[i] = gtree->ToClose(K[i], hseuil) - v; - (tt++)->set(v, igluv, K.lab); - } - } - - if (verbosity > 1) - cout << " creation of : BuildGTree for border elements" << endl; - BRdHat PtHat2 = BRdHat::diag(1. / B::nv); - for (int k = 0; k < Th.nbe; k++) { - const B &K(Th.be(k)); - - const R3 r3vi(K(PtHat2)); - const V &vi(r3vi); - V *pvi = gtree_be->ToClose(vi, hseuil_border); - if (!pvi) { - becog2[nbe].x = vi.x; - becog2[nbe].y = vi.y; - becog2[nbe].z = vi.z; - becog2[nbe].lab = vi.lab; - gtree_be->Add(becog2[nbe++]); - - int igluv[B::nv]; - for (int i = 0; i < (B::nv); i++) - igluv[i] = gtree->ToClose(K[i], hseuil) - v; - - (bb++)->set(v, igluv, K.lab); - } - } - } - delete gtree_be; - delete gtree; - delete gtree_e; - delete[] becog1; - delete[] becog2; - - if (verbosity > 1) { - cout << " Nb points : " << nbv << " , nb edges : " << nbe << endl; - cout << " Nb of glu point " << nbvx - nbv; - cout << " Nb of glu Boundary edge " << nbex - nbe; + + if (verbosity > 1) cout << " creation of : BuildGTree for border elements" << endl; + BRdHat PtHat2 = BRdHat::diag(1. / B::nv); + for (int k = 0; k < Th.nbe; k++) { + const B &K(Th.be(k)); + + const R3 r3vi(K(PtHat2)); + const V &vi(r3vi); + V *pvi = gtree_be->ToClose(vi, hseuil_border); + if (!pvi) { + becog2[nbe].x = vi.x; + becog2[nbe].y = vi.y; + becog2[nbe].z = vi.z; + becog2[nbe].lab = vi.lab; + gtree_be->Add(becog2[nbe++]); + + int igluv[B::nv]; + for (int i = 0; i < (B::nv); i++) igluv[i] = gtree->ToClose(K[i], hseuil) - v; + + (bb++)->set(v, igluv, K.lab); + } } - - MeshS *m = new MeshS(nbv, nbt, nbe, v, t, b); - m->BuildGTree( ); - return m; - + } + delete gtree_be; + delete gtree; + delete gtree_e; + delete[] becog1; + delete[] becog2; + + if (verbosity > 1) { + cout << " Nb points : " << nbv << " , nb edges : " << nbe << endl; + cout << " Nb of glu point " << nbvx - nbv; + cout << " Nb of glu Boundary edge " << nbex - nbe; + } + + MeshS *m = new MeshS(nbv, nbt, nbe, v, t, b); + m->BuildGTree( ); + return m; } - - - -MeshL *GluMesh(listMeshT const &lst) { - typedef typename MeshL::Element T; - typedef typename MeshL::BorderElement B; - typedef typename MeshL::Vertex V; - typedef typename MeshL::Element::RdHat TRdHat; - typedef typename MeshL::BorderElement::RdHat BRdHat; - - int nbv = 0, nbt = 0, nbe = 0, nbvx = 0, nbtx = 0, nbex = 0; - - double hmin = 1e100; - R3 Pn(1e100, 1e100, 1e100), Px(-1e100, -1e100, -1e100); - const list< MeshL const * > lth(*lst.lth); - const MeshL *th0 = 0; - int kk = 0; - - for (typename list< MeshL const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { - if (!*i) continue; - ++kk; - const MeshL &Th(**i); - th0 = &Th; - if (verbosity > 1) - cout << " GluMesh + "<< "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; - nbtx += Th.nt; - nbvx += Th.nv; - nbex += Th.nbe; - - for (int k = 0; k < Th.nt; k++) - hmin = min(hmin, Th[k].mesure()); - - for (int i = 0; i < Th.nv; i++) { - R3 P(Th(i)); - Pn = Minc(P, Pn); - Px = Maxc(P, Px); - } + +MeshL *GluMesh(listMeshT< MeshL > const &lst) { + typedef typename MeshL::Element T; + typedef typename MeshL::BorderElement B; + typedef typename MeshL::Vertex V; + typedef typename MeshL::Element::RdHat TRdHat; + typedef typename MeshL::BorderElement::RdHat BRdHat; + + int nbv = 0, nbt = 0, nbe = 0, nbvx = 0, nbtx = 0, nbex = 0; + + double hmin = 1e100; + R3 Pn(1e100, 1e100, 1e100), Px(-1e100, -1e100, -1e100); + const list< MeshL const * > lth(*lst.lth); + const MeshL *th0 = 0; + int kk = 0; + + for (typename list< MeshL const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; + ++kk; + const MeshL &Th(**i); + th0 = &Th; + if (verbosity > 1) cout << " GluMesh + " << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; + nbtx += Th.nt; + nbvx += Th.nv; + nbex += Th.nbe; + + for (int k = 0; k < Th.nt; k++) hmin = min(hmin, Th[k].mesure( )); + + for (int i = 0; i < Th.nv; i++) { + R3 P(Th(i)); + Pn = Minc(P, Pn); + Px = Maxc(P, Px); } - - if (kk == 0) return 0; // no mesh ... - if (verbosity > 2) - cout << " - hmin =" << hmin << " , Bounding Box: " << Pn << " " << Px << endl; - - V *v = new V[nbvx]; - T *t = new T[nbtx]; - T *tt = t; - B *b = new B[nbex]; - B *bb = b; - - ffassert(hmin > Norme2(Pn - Px) / 1e9); - double hseuil = hmin / 10.; - - EF23::GTree< V > *gtree = new EF23::GTree< V >(v, Pn, Px, 0); - - for (typename list< MeshL const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { - if (!*i) continue; // - const MeshL &Th(**i); - if (!*i) continue; - if (verbosity > 1) - cout << " GluMesh + " - << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; - - for (int ii = 0; ii < Th.nv; ii++) { - const V &vi(Th(ii)); - V *pvi = gtree->ToClose(vi, hseuil); - if (!pvi) { - v[nbv].x = vi.x; - v[nbv].y = vi.y; - v[nbv].z = vi.z; - v[nbv].lab = vi.lab; - gtree->Add(v[nbv++]); - } - } + } + + if (kk == 0) return 0; // no mesh ... + if (verbosity > 2) cout << " - hmin =" << hmin << " , Bounding Box: " << Pn << " " << Px << endl; + + V *v = new V[nbvx]; + T *t = new T[nbtx]; + T *tt = t; + B *b = new B[nbex]; + B *bb = b; + + ffassert(hmin > Norme2(Pn - Px) / 1e9); + double hseuil = hmin / 10.; + + EF23::GTree< V > *gtree = new EF23::GTree< V >(v, Pn, Px, 0); + + for (typename list< MeshL const * >::const_iterator i = lth.begin( ); i != lth.end( ); ++i) { + if (!*i) continue; // + const MeshL &Th(**i); + if (!*i) continue; + if (verbosity > 1) + cout << " GluMesh + " + << "nv: " << Th.nv << " nt: " << Th.nt << " nbe: " << Th.nbe << endl; + + for (int ii = 0; ii < Th.nv; ii++) { + const V &vi(Th(ii)); + V *pvi = gtree->ToClose(vi, hseuil); + if (!pvi) { + v[nbv].x = vi.x; + v[nbv].y = vi.y; + v[nbv].z = vi.z; + v[nbv].lab = vi.lab; + gtree->Add(v[nbv++]); + } } - - double hseuil_border = hseuil / 3.; - // gtree for barycenter of elements - Vertex3 *becog1 = new V[nbtx]; - EF23::GTree< V > *gtree_e = new EF23::GTree< V >(becog1, Pn, Px, 0); - // gtree for barycenter of border elements - V *becog2 = new V[nbex]; - EF23::GTree< V > *gtree_be = new EF23::GTree< V >(becog2, Pn, Px, 0); - - for (typename list< const MeshL * >::const_iterator i = lth.begin( ); i != lth.end( ); i++) { - if (!*i) - continue; - - const MeshL &Th(**i); - - if (verbosity > 1) - cout << " creation of : BuildGTree for elements" << endl; - - double kk = T::nv; - TRdHat PtHat1 = TRdHat::diag(1. / kk); - - for (int k = 0; k < Th.nt; k++) { - const T &K(Th[k]); - - const R3 r3vi(K(PtHat1)); - const V &vi(r3vi); - V *pvi = gtree_e->ToClose(vi, hseuil_border); - if (!pvi) { - becog1[nbt].x = vi.x; - becog1[nbt].y = vi.y; - becog1[nbt].z = vi.z; - becog1[nbt].lab = vi.lab; - gtree_e->Add(becog1[nbt++]); - - int igluv[T::nv]; - for (int i = 0; i < 2/*T::nv*/; i++) - igluv[i] = gtree->ToClose(K[i], hseuil) - v; - (tt++)->set(v, igluv, K.lab); - } - } - - if (verbosity > 1) - cout << " creation of : BuildGTree for border elements" << endl; - - for (int k = 0; k < Th.nbe; k++) { - const B &K(Th.be(k)); - const V &vi(Th(Th.operator( )(K[0]) )); - - V *pvi = gtree_be->ToClose(vi, hseuil_border); - if (!pvi) { - becog2[nbe].x = vi.x; - becog2[nbe].y = vi.y; - becog2[nbe].z = vi.z; - becog2[nbe].lab = vi.lab; - gtree_be->Add(becog2[nbe++]); - int igluv[B::nv]; - igluv[0] = gtree->ToClose(K[0], hseuil) - v; - (bb++)->set(v, igluv, K.lab); - } - } + } + + double hseuil_border = hseuil / 3.; + // gtree for barycenter of elements + Vertex3 *becog1 = new V[nbtx]; + EF23::GTree< V > *gtree_e = new EF23::GTree< V >(becog1, Pn, Px, 0); + // gtree for barycenter of border elements + V *becog2 = new V[nbex]; + EF23::GTree< V > *gtree_be = new EF23::GTree< V >(becog2, Pn, Px, 0); + + for (typename list< const MeshL * >::const_iterator i = lth.begin( ); i != lth.end( ); i++) { + if (!*i) continue; + + const MeshL &Th(**i); + + if (verbosity > 1) cout << " creation of : BuildGTree for elements" << endl; + double kk = T::nv; + TRdHat PtHat1 = TRdHat::diag(1. / kk); + + for (int k = 0; k < Th.nt; k++) { + const T &K(Th[k]); + + const R3 r3vi(K(PtHat1)); + const V &vi(r3vi); + V *pvi = gtree_e->ToClose(vi, hseuil_border); + if (!pvi) { + becog1[nbt].x = vi.x; + becog1[nbt].y = vi.y; + becog1[nbt].z = vi.z; + becog1[nbt].lab = vi.lab; + gtree_e->Add(becog1[nbt++]); + + int igluv[T::nv]; + for (int i = 0; i < 2 /*T::nv*/; i++) igluv[i] = gtree->ToClose(K[i], hseuil) - v; + (tt++)->set(v, igluv, K.lab); + } } - delete gtree_be; - delete gtree; - delete gtree_e; - delete[] becog1; - delete[] becog2; - - if (verbosity > 1) { - cout << " Nb points : " << nbv << " , nb edges : " << nbe << endl; - cout << " Nb of glu point " << nbvx - nbv; - cout << " Nb of glu Boundary edge " << nbex - nbe; + + if (verbosity > 1) cout << " creation of : BuildGTree for border elements" << endl; + + for (int k = 0; k < Th.nbe; k++) { + const B &K(Th.be(k)); + const V &vi(Th(Th.operator( )(K[0]))); + + V *pvi = gtree_be->ToClose(vi, hseuil_border); + if (!pvi) { + becog2[nbe].x = vi.x; + becog2[nbe].y = vi.y; + becog2[nbe].z = vi.z; + becog2[nbe].lab = vi.lab; + gtree_be->Add(becog2[nbe++]); + int igluv[B::nv]; + igluv[0] = gtree->ToClose(K[0], hseuil) - v; + (bb++)->set(v, igluv, K.lab); + } } - - MeshL *m = new MeshL(nbv, nbt, nbe, v, t, b); - m->BuildGTree( ); - return m; - -} + } + delete gtree_be; + delete gtree; + delete gtree_e; + delete[] becog1; + delete[] becog2; + + if (verbosity > 1) { + cout << " Nb points : " << nbv << " , nb edges : " << nbe << endl; + cout << " Nb of glu point " << nbvx - nbv; + cout << " Nb of glu Boundary edge " << nbex - nbe; + } + MeshL *m = new MeshL(nbv, nbt, nbe, v, t, b); + m->BuildGTree( ); + return m; +} template< class RR, class AA = RR, class BB = AA > struct Op3_addmeshS { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; static RR f(Stack s, const AA &a, const BB &b) { return RR(s, a, b); } }; template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op3_setmeshS { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; static RR f(Stack stack, const AA &a, const BB &b) { ffassert(a); const pmeshS p = GluMesh(b); - if (!INIT && *a) - (**a).destroy( ); + if (!INIT && *a) (**a).destroy( ); *a = p; return a; } }; - template< class RR, class AA = RR, class BB = AA > struct Op3_addmeshL { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack s, const AA &a, const BB &b) { return RR(s, a, b); } + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack s, const AA &a, const BB &b) { return RR(s, a, b); } }; template< bool INIT, class RR, class AA = RR, class BB = AA > struct Op3_setmeshL { - using first_argument_type = AA; - using second_argument_type = BB; - using result_type = RR; - static RR f(Stack stack, const AA &a, const BB &b) { - ffassert(a); - const pmeshL p = GluMesh(b); - - if (!INIT && *a) - (**a).destroy( ); - *a = p; - return a; - } -}; - - - + using first_argument_type = AA; + using second_argument_type = BB; + using result_type = RR; + static RR f(Stack stack, const AA &a, const BB &b) { + ffassert(a); + const pmeshL p = GluMesh(b); + if (!INIT && *a) (**a).destroy( ); + *a = p; + return a; + } +}; template< class MMesh > void finalize(MMesh *(&Th)); template<> void finalize< MeshL >(MeshL *(&Th)) { - Th->mapCurv2Surf = 0; - Th->mapSurf2Curv = 0; + Th->mapCurv2Surf = 0; + Th->mapSurf2Curv = 0; } template<> @@ -2472,22 +2394,18 @@ template< class MMesh > class SetMesh_Op : public E_F0mps { public: Expression a; - static const int n_name_param = 9+1; + static const int n_name_param = 9 + 1; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; KN_< long > arg(int i, Stack stack, KN_< long > a) const { - if (i < n_name_param-2) { + if (i < n_name_param - 2) { ffassert(!(nargs[i] && nargs[i + 2])); i = nargs[i] ? i : i + 2; } return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } KN_< long > arg(int i, int j, Stack stack, KN_< long > a) const { if (nargs[i]) { return GetAny< KN_< long > >((*nargs[i])(stack)); @@ -2495,6 +2413,7 @@ class SetMesh_Op : public E_F0mps { return nargs[j] ? GetAny< KN_< long > >((*nargs[j])(stack)) : a; } } + public: SetMesh_Op(const basicAC_F0 &args, Expression aa) : a(aa) { args.SetNameParam(n_name_param, name_param, nargs); @@ -2507,29 +2426,20 @@ class SetMesh_Op : public E_F0mps { // special instance, list arguments for mesh3 template<> basicAC_F0::name_and_type SetMesh_Op< Mesh3 >::name_param[] = { - {"reftet", &typeid(KN_< long >)}, {"refface", &typeid(KN_< long >)}, - {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, - {"fregion", &typeid(long)}, {"flabel", &typeid(long)}, - {"rmlfaces", &typeid(long)}, {"rmInternalFaces", &typeid(bool)}, - {"renumv", &typeid(KN_)}, {"renumt", &typeid(KN_)}}; + {"reftet", &typeid(KN_< long >)}, {"refface", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"fregion", &typeid(long)}, + {"flabel", &typeid(long)}, {"rmlfaces", &typeid(long)}, {"rmInternalFaces", &typeid(bool)}, {"renumv", &typeid(KN_< long >)}, {"renumt", &typeid(KN_< long >)}}; // special instance, list arguments for meshS template<> basicAC_F0::name_and_type SetMesh_Op< MeshS >::name_param[] = { - {"reftri", &typeid(KN_< long >)}, {"refedge", &typeid(KN_< long >)}, - {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, - {"fregion", &typeid(long)}, {"flabel", &typeid(long)}, - {"rmledge", &typeid(long)}, {"rmInternalEdges", &typeid(bool)}, - {"renumv", &typeid(KN_)}, {"renumt", &typeid(KN_)}}; + {"reftri", &typeid(KN_< long >)}, {"refedge", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"fregion", &typeid(long)}, + {"flabel", &typeid(long)}, {"rmledge", &typeid(long)}, {"rmInternalEdges", &typeid(bool)}, {"renumv", &typeid(KN_< long >)}, {"renumt", &typeid(KN_< long >)}}; // special instance, list arguments for meshL template<> basicAC_F0::name_and_type SetMesh_Op< MeshL >::name_param[] = { - {"refedge", &typeid(KN_< long >)}, {"refpoint", &typeid(KN_< long >)}, - {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, - {"fregion", &typeid(long)}, {"flabel", &typeid(long)}, - {"rmlpoint", &typeid(long)}, {"rmInternalPoints", &typeid(bool)}, - {"renumv", &typeid(KN_)}, {"renumt", &typeid(KN_)}}; + {"refedge", &typeid(KN_< long >)}, {"refpoint", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"fregion", &typeid(long)}, + {"flabel", &typeid(long)}, {"rmlpoint", &typeid(long)}, {"rmInternalPoints", &typeid(bool)}, {"renumv", &typeid(KN_< long >)}, {"renumt", &typeid(KN_< long >)}}; // function to apply the change of label with the map int ChangeLab(const map< int, int > &m, int lab) { @@ -2541,15 +2451,15 @@ int ChangeLab(const map< int, int > &m, int lab) { } template< class MMesh > -typename MMesh::BorderElement::RdHat setBaryBorder(){ - int k = MMesh::BorderElement::nv; - return MMesh::BorderElement::RdHat::diag(1. / k); +typename MMesh::BorderElement::RdHat setBaryBorder( ) { + int k = MMesh::BorderElement::nv; + return MMesh::BorderElement::RdHat::diag(1. / k); } -template< > -typename MeshL::BorderElement::RdHat setBaryBorder(){ - - return R0(); +template<> +typename MeshL::BorderElement::RdHat setBaryBorder< MeshL >( ) { + + return R0( ); } template< class MMesh > @@ -2576,23 +2486,21 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { KN< long > nrT(arg(0, 2, stack, zz)); KN< long > nrB(arg(1, 3, stack, zz)); - + // arguments Expression freg = nargs[4]; Expression flab = nargs[5]; bool rm_faces = nargs[6]; long rmlabfaces(arg(6, stack, 0L)); bool rm_i_faces(arg(7, stack, false)); - KN rv (arg(8,stack,zz)); - KN rt (arg(9,stack,zz)); - bool rV = (rv.size()== nbv); - bool rT = (rt.size()== nbv); + KN< long > rv(arg(8, stack, zz)); + KN< long > rt(arg(9, stack, zz)); + bool rV = (rv.size( ) == nbv); + bool rT = (rt.size( ) == nbv); - if (rm_i_faces && (is_same< MMesh, MeshS >::value || is_same< MMesh, MeshL >::value) ) - cout << " Warning: remove internal border isn't implemented " << endl; + if (rm_i_faces && (is_same< MMesh, MeshS >::value || is_same< MMesh, MeshL >::value)) cout << " Warning: remove internal border isn't implemented " << endl; - if (nrB.N( ) <= 0 && nrT.N( ) <= 0 && (!freg) && (!flab) && !rmlabfaces && !rm_i_faces && !rV) - return pTh; + if (nrB.N( ) <= 0 && nrT.N( ) <= 0 && (!freg) && (!flab) && !rmlabfaces && !rm_i_faces && !rV) return pTh; ffassert(nrT.N( ) % 2 == 0); ffassert(nrB.N( ) % 2 == 0); @@ -2617,7 +2525,7 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { V *v = new V[nbv]; V *vv = v; for (int i = 0; i < nbv; i++) { - const int ii=rV? rv(i): i; + const int ii = rV ? rv(i) : i; vv = v + ii; const V &V(Th.vertices[i]); vv->x = V.x; @@ -2627,45 +2535,41 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { } // new elements - int unsetlab = std::numeric_limits::max()-2; + int unsetlab = std::numeric_limits< int >::max( ) - 2; T *t = new T[nbt]; - for (int i = 0; i < nbt; i++) - t[i].lab = unsetlab; - // T *tt = t; - + for (int i = 0; i < nbt; i++) t[i].lab = unsetlab; + // T *tt = t; + int lmn = 2000000000; int lmx = -2000000000; double k = T::nv; TRdHat PtHat = TRdHat::diag(1. / k); for (int i = 0; i < nbt; i++) { - - int itt = rT ? rt[i] : i; - + + int itt = rT ? rt[i] : i; + const T &K(Th.elements[i]); int iv[T::nv]; for (int j = 0; j < k; j++) iv[j] = Th.operator( )(K[j]); - if(rV) { + if (rV) { for (int j = 0; j < k; j++) iv[j] = rv(iv[j]); } t[itt].set(v, iv, ChangeLab(mapTref, K.lab)); if (freg) { mp->set(Th, K(PtHat), PtHat, K, 0); - t[itt].lab = GetAny< long >((*freg)(stack)); - lmn = min(lmn, t[itt].lab ); - lmx = max(lmx, t[itt].lab ); - } - // tt++; - } - int err=0; - for (int i = 0; i < nbt; i++) - err += t[i].lab == unsetlab; - if(err ) - { - cout << " nb error in renumbering element "<< err << endl; - ffassert(0); - } - if (freg && verbosity > 1) - cout << " -- Change : new region number bound : " << lmn << " " << lmx << endl; + t[itt].lab = GetAny< long >((*freg)(stack)); + lmn = min(lmn, t[itt].lab); + lmx = max(lmx, t[itt].lab); + } + // tt++; + } + int err = 0; + for (int i = 0; i < nbt; i++) err += t[i].lab == unsetlab; + if (err) { + cout << " nb error in renumbering element " << err << endl; + ffassert(0); + } + if (freg && verbosity > 1) cout << " -- Change : new region number bound : " << lmn << " " << lmx << endl; // new border elements lmn = 2000000000; @@ -2673,7 +2577,7 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { B *b = new B[nben]; B *bb = b; k = B::nv; - BRdHat PtHat2 = setBaryBorder(); //BRdHat::diag(1. / k); const V &vi(Th(Th.operator( )(K[0]) )); + BRdHat PtHat2 = setBaryBorder< MMesh >( ); // BRdHat::diag(1. / k); const V &vi(Th(Th.operator( )(K[0]) )); int nrmf = 0; for (int i = 0; i < nbe; i++) { @@ -2681,11 +2585,10 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { int fk, ke = Th.BoundaryElement(i, fk); int fkk, kke = Th.ElementAdj(ke, fkk = fk); bool onborder = (kke == ke) || (kke < 0); - - + int iv[B::nv]; for (int j = 0; j < k; j++) iv[j] = Th.operator( )(K[j]); - if(rV) { + if (rV) { for (int j = 0; j < k; j++) iv[j] = rv(iv[j]); } bool rmf = rm_i_faces && !onborder; @@ -2696,7 +2599,7 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { TRdHat B = KE.PBord(fk, PtHat2); R3 NN = KE.N(fk); double mes = NN.norme( ); - NN /= mes; + NN /= mes; mp->set(Th, KE(B), B, KE, K.lab, NN, fk); // ok after version 4.10 l1 = GetAny< long >((*flab)(stack)); lmn = min(lmn, bb->lab); @@ -2710,9 +2613,7 @@ AnyType SetMesh_Op< MMesh >::operator( )(Stack stack) const { (*bb++).set(v, iv, l1); } - if (nrmf && verbosity > 2) - cout << " change mesh3 : number of removed internal faces " << nrmf - << " == " << nbe - (bb - b) << endl; + if (nrmf && verbosity > 2) cout << " change mesh3 : number of removed internal faces " << nrmf << " == " << nbe - (bb - b) << endl; nben -= nrmf; nbe -= nrmf; @@ -2735,16 +2636,12 @@ class SetMesh : public OneOperator { typedef const MMesh *ppmesh; SetMesh( ) : OneOperator(atype< ppmesh >( ), atype< ppmesh >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new SetMesh_Op< MMesh >(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new SetMesh_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; /* ancien fichier de TransfoMesh */ -Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_element, int &recollement_border, int &point_confondus_ok, - int orientation) { +Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int orientation) { // cas besoin memoire important @@ -2777,9 +2674,8 @@ Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double * cout << " debut: SamePointElement " << endl; } - SamePointElement(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_element, - recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, - ind_nbe_t, label_nt_t, label_nbe_t, nv_t, nt_t, nbe_t); + SamePointElement(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th3, recollement_element, recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nt_t, label_nbe_t, nv_t, + nt_t, nbe_t); if (verbosity > 1) { cout << " fin: SamePointElement " << endl; @@ -2889,11 +2785,8 @@ Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double * return T_Th3; } -void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, - int &recollement_border, int &point_confondus_ok, int *Numero_Som, - int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, - int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { +void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { int Elem_ok, Border_ok; double hmin, hmin_elem, hmin_border; R3 bmin, bmax; @@ -2922,8 +2815,7 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou cout << " OrderVertexTransfo_hcode gtree " << endl; } - OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, - ind_nv_t, nv_t); + OrderVertexTransfo_hcode_nv_gtree(Th3.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, ind_nv_t, nv_t); if (verbosity > 2) { cout << " fin order vertex gtree: nv_t=" << nv_t << endl; } @@ -3083,15 +2975,9 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou iv[jj] = Th3.operator( )(K[jj]); } - Cdg_be[i_border][0] = - (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; - Cdg_be[i_border][1] = - (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; - Cdg_be[i_border][2] = - (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / - 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; + Cdg_be[i_border][0] = (tab_XX[iv[0]] + tab_XX[iv[1]] + tab_XX[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].x + Th3.vertices[iv[1]].x + Th3.vertices[iv[2]].x )/3.; + Cdg_be[i_border][1] = (tab_YY[iv[0]] + tab_YY[iv[1]] + tab_YY[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].y + Th3.vertices[iv[1]].y + Th3.vertices[iv[2]].y )/3.; + Cdg_be[i_border][2] = (tab_ZZ[iv[0]] + tab_ZZ[iv[1]] + tab_ZZ[iv[2]]) / 3.; // ( Th3.vertices[iv[0]].z + Th3.vertices[iv[1]].z + Th3.vertices[iv[2]].z )/3.; label_be[i_border] = K.lab; } @@ -3105,8 +2991,7 @@ void SamePointElement(const double &precis_mesh, const double *tab_XX, const dou cout << "appele de PointCommun_hcode := " << point_confondus_ok << endl; } - PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, - hmin_border, ind_np, label_nbe_t, np); + PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, hmin_border, ind_np, label_nbe_t, np); if (verbosity > 1) { cout << "fin appele de PointCommun_hcode" << endl; } @@ -3157,9 +3042,8 @@ void Transfo_Mesh2_map_face(const Mesh &Th2, map< int, int > &maptri) { } } -MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_border, int &point_confondus_ok) { +MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_border, + int &point_confondus_ok) { int nv_t, nt_t, nbe_t; int *Numero_Som; @@ -3176,21 +3060,17 @@ MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * label_nbe_t = new int[Th2.neb]; if (verbosity > 5) { - cout << "before movemesh::Vertex triangle2 border " << Th2.nv << " " << Th2.nt << " " - << Th2.neb << endl; + cout << "before movemesh::Vertex triangle2 border " << Th2.nv << " " << Th2.nt << " " << Th2.neb << endl; } for (int ii = 0; ii < Th2.nv; ii++) Numero_Som[ii] = ii; if (verbosity > 1) cout << " debut: SamePointElement " << endl; // gestion of recollement ???? - SamePointElement_Mesh2(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th2, recollement_border, - point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nt_t, - label_nbe_t, nv_t, nt_t, nbe_t); + SamePointElement_Mesh2(precis_mesh, tab_XX, tab_YY, tab_ZZ, Th2, recollement_border, point_confondus_ok, Numero_Som, ind_nv_t, ind_nt_t, ind_nbe_t, label_nt_t, label_nbe_t, nv_t, nt_t, nbe_t); if (verbosity > 1) { cout << " fin: SamePointElement " << endl; - cout << "After movemesh::Vertex triangle border " << nv_t << " " << nt_t << " " << nbe_t - << endl; + cout << "After movemesh::Vertex triangle border " << nv_t << " " << nt_t << " " << nbe_t << endl; } Vertex3 *vS = new Vertex3[nv_t]; TriangleS *tS = new TriangleS[nt_t]; @@ -3243,11 +3123,8 @@ MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double * return T_ThS; } -void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, - int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, - int &nbe_t) { +void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t) { int Elem_ok, Border_ok; // int recollement_border=0; R3 bmin, bmax; @@ -3274,8 +3151,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con cout << "debut: OrderVertexTransfo_hcode_gtree " << endl; } - OrderVertexTransfo_hcode_nv_gtree(Th2.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, - ind_nv_t, nv_t); + OrderVertexTransfo_hcode_nv_gtree(Th2.nv, bmin, bmax, hmin, tab_XX, tab_YY, tab_ZZ, Numero_Som, ind_nv_t, nv_t); if (verbosity > 1) { cout << "fin: OrderVertexTransfo_hcode_gtree " << endl; } @@ -3379,8 +3255,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con for (int i_border = 0; i_border < nbe_t; i_border++) { int &ii = ind_nbe_t[i_border]; - const Mesh::BorderElement &K( - Th2.be(ii)); // const Triangle2 & K(Th2.elements[ii]); // avant Mesh2 + const Mesh::BorderElement &K(Th2.be(ii)); // const Triangle2 & K(Th2.elements[ii]); // avant Mesh2 int iv[2]; for (int jj = 0; jj < 2; jj++) iv[jj] = Th2.operator( )(K[jj]); @@ -3395,15 +3270,13 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con hmin_border = hmin / 3.; if (verbosity > 1) cout << "points commun " << endl; - PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, - hmin_border, ind_np, label_nbe_t, np); + PointCommun_hcode_gtree(dim, nbe_t, point_confondus_ok, Cdg_be, label_be, bmin, bmax, hmin_border, ind_np, label_nbe_t, np); if (verbosity > 1) cout << "points commun finis " << endl; assert(np <= nbe_t); int ind_nbe_t_tmp[np]; - for (int i_border = 0; i_border < np; i_border++) - ind_nbe_t_tmp[i_border] = ind_nbe_t[ind_np[i_border]]; + for (int i_border = 0; i_border < np; i_border++) ind_nbe_t_tmp[i_border] = ind_nbe_t[ind_np[i_border]]; for (int i_border = 0; i_border < np; i_border++) ind_nbe_t[i_border] = ind_nbe_t_tmp[i_border]; @@ -3422,9 +3295,7 @@ void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, con // Fin cas 2D //= ===================== // version Mesh2 -void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, - double &hmin) { +void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin) { // determination de la boite englobante // R3 bmin,bmax; double precispt; @@ -3480,8 +3351,7 @@ void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, cons for (int kk = jj + 1; kk < 3; kk++) { int &i1 = iv[jj]; int &i2 = iv[kk]; - longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + - pow(tab_ZZ[i1] - tab_ZZ[i2], 2); + longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + pow(tab_ZZ[i1] - tab_ZZ[i2], 2); longedge = sqrt(longedge); // cout << "longedge=" << longedge << endl; if (longedge > precispt) { @@ -3542,9 +3412,7 @@ void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, cons // version Mesh3 -void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, - double &hmin) { +void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, double &hmin) { // determination de la boite englobante // R3 bmin,bmax; double precispt; @@ -3616,8 +3484,7 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons for (int kk = jj + 1; kk < 4; kk++) { int &i1 = iv[jj]; int &i2 = iv[kk]; - longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + - pow(tab_ZZ[i1] - tab_ZZ[i2], 2); + longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + pow(tab_ZZ[i1] - tab_ZZ[i2], 2); longedge = sqrt(longedge); if (longedge > precispt) { hmin = min(hmin, longedge); @@ -3644,8 +3511,7 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons for (int kk = jj + 1; kk < 3; kk++) { int &i1 = iv[jj]; int &i2 = iv[kk]; - longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + - pow(tab_ZZ[i1] - tab_ZZ[i2], 2); + longedge = pow(tab_XX[i1] - tab_XX[i2], 2) + pow(tab_YY[i1] - tab_YY[i2], 2) + pow(tab_ZZ[i1] - tab_ZZ[i2], 2); longedge = sqrt(longedge); if (longedge > precispt) { hmin = min(hmin, longedge); @@ -3656,8 +3522,7 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons } if (hmin / longmini_box < 1e7) hmin = hmin * 0.1; // in case of bad shape element if (verbosity > 5) { - cout << " longmini_box" << longmini_box << " hmin =" << hmin << " longmini_box/hmin " - << hmin / longmini_box << endl; + cout << " longmini_box" << longmini_box << " hmin =" << hmin << " longmini_box/hmin " << hmin / longmini_box << endl; } if (verbosity > 9) { @@ -4009,9 +3874,7 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons //} //*/ -void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, - const double &hmin, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int *Numero_Som, +void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, const double &hmin, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int *Numero_Som, int *ind_nv_t, int &nv_t) { size_t i; size_t j[3]; @@ -4078,8 +3941,7 @@ void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const for (int jj = ii + 1; jj < tab_nv; jj++) { double dist = 0.; - dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + - pow(tab_ZZ[jj] - tab_ZZ[ii], 2); + dist = pow(tab_XX[jj] - tab_XX[ii], 2) + pow(tab_YY[jj] - tab_YY[ii], 2) + pow(tab_ZZ[jj] - tab_ZZ[ii], 2); if (sqrt(dist) < hseuil) { numberofpointsdiff = 1; } @@ -4096,10 +3958,8 @@ void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const } } -void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const int *label_point, const R3 &bmin, - const R3 &bmax, const double &hmin, int *ind_np, int *ind_label, - int &np) { +void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const int *label_point, const R3 &bmin, const R3 &bmax, const double &hmin, + int *ind_np, int *ind_label, int &np) { double hseuil = hmin / 10.; Vertex3 *v = new Vertex3[NbPoints]; // Vertex3 v[NbPoints]; @@ -4183,21 +4043,14 @@ class BuildLayeMesh_Op : public E_F0mps { static const int n_name_param = 9 + 4; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: - BuildLayeMesh_Op(const basicAC_F0 &args, Expression tth, Expression nmaxx) - : eTh(tth), enmax(nmaxx), ezmin(0), ezmax(0), xx(0), yy(0), zz(0) { + BuildLayeMesh_Op(const basicAC_F0 &args, Expression tth, Expression nmaxx) : eTh(tth), enmax(nmaxx), ezmin(0), ezmax(0), xx(0), yy(0), zz(0) { if (verbosity > 1) { cout << "construction par BuilLayeMesh_Op" << endl; } @@ -4253,19 +4106,11 @@ class BuildLayeMesh_Op : public E_F0mps { }; basicAC_F0::name_and_type BuildLayeMesh_Op::name_param[] = { - {"zbound", &typeid(E_Array)}, - {"transfo", &typeid(E_Array)}, - {"coef", &typeid(double)}, + {"zbound", &typeid(E_Array)}, {"transfo", &typeid(E_Array)}, {"coef", &typeid(double)}, {"reftet", &typeid(KN_< long >)}, // 3 - {"reffacemid", &typeid(KN_< long >)}, - {"reffaceup", &typeid(KN_< long >)}, - {"reffacelow", &typeid(KN_< long >)}, - {"facemerge", &typeid(long)}, - {"ptmerge", &typeid(double)}, - {"region", &typeid(KN_< long >)}, // 9 - {"labelmid", &typeid(KN_< long >)}, - {"labelup", &typeid(KN_< long >)}, - {"labeldown", &typeid(KN_< long >)}, // 12 + {"reffacemid", &typeid(KN_< long >)}, {"reffaceup", &typeid(KN_< long >)}, {"reffacelow", &typeid(KN_< long >)}, + {"facemerge", &typeid(long)}, {"ptmerge", &typeid(double)}, {"region", &typeid(KN_< long >)}, // 9 + {"labelmid", &typeid(KN_< long >)}, {"labelup", &typeid(KN_< long >)}, {"labeldown", &typeid(KN_< long >)}, // 12 }; class BuildLayerMesh : public OneOperator { @@ -4289,22 +4134,14 @@ class cubeMesh_Op : public E_F0mps { static const int n_name_param = 3; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: - cubeMesh_Op(const basicAC_F0 &args, Expression nnx, Expression nny, Expression nnz, - Expression transfo = 0) - : nx(nnx), ny(nny), nz(nnz), xx(0), yy(0), zz(0) { + cubeMesh_Op(const basicAC_F0 &args, Expression nnx, Expression nny, Expression nnz, Expression transfo = 0) : nx(nnx), ny(nny), nz(nnz), xx(0), yy(0), zz(0) { if (verbosity > 1) { cout << "construction par cubeMesh_Op" << endl; } @@ -4326,34 +4163,25 @@ class cubeMesh_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type cubeMesh_Op::name_param[] = { - {"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, {"flags", &typeid(long)} }; +basicAC_F0::name_and_type cubeMesh_Op::name_param[] = {{"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, {"flags", &typeid(long)}}; class cubeMesh : public OneOperator { public: int xyz; - cubeMesh( ) - : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( )), - xyz(0) {} + cubeMesh( ) : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( )), xyz(0) {} - cubeMesh(int) - : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( ), - atype< E_Array >( )), - xyz(1) {} + cubeMesh(int) : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( ), atype< E_Array >( )), xyz(1) {} E_F0 *code(const basicAC_F0 &args) const { if (xyz) { - return new cubeMesh_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); + return new cubeMesh_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } else { - return new cubeMesh_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new cubeMesh_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } } }; -extern Mesh *Carre_(int nx, int ny, Expression fx, Expression fy, Stack stack, int flags, - KN_< long > lab, long reg,bool rmdup=false); +extern Mesh *Carre_(int nx, int ny, Expression fx, Expression fy, Stack stack, int flags, KN_< long > lab, long reg, bool rmdup = false); AnyType cubeMesh_Op::operator( )(Stack stack) const { int n1 = (int)GetAny< long >((*nx)(stack)); @@ -4362,7 +4190,7 @@ AnyType cubeMesh_Op::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; long flags = arg(2, stack, 0L); - double cpu0 = ((double) clock())/CLOCKS_PER_SEC; + double cpu0 = ((double)clock( )) / CLOCKS_PER_SEC; KN< long > label2; long ll3[] = {1, 2, 3, 4, 5, 6}; KN_< long > l3_(ll3, 6); @@ -4371,7 +4199,7 @@ AnyType cubeMesh_Op::operator( )(Stack stack) const { long region = arg(0, stack, 0L); Mesh *pTh = Carre_(n1, n2, 0, 0, stack, flags, label2, 0L); // WARNING no clean of teh stack in this case (durdur) - double cpu1 = ((double) clock())/CLOCKS_PER_SEC; + double cpu1 = ((double)clock( )) / CLOCKS_PER_SEC; ffassert(pTh && nlayer > 0); Mesh &Th = *pTh; int nbv = Th.nv; // nombre de sommet @@ -4471,22 +4299,20 @@ AnyType cubeMesh_Op::operator( )(Stack stack) const { int i2 = Th.operator( )(K[2]); if (ni[i0] == 0 && ni[i1] == 0 && ni[i2] == 0) { - cout << "A tetrahedra with null volume will be created with triangle " << it << " of 2D Mesh " - << endl; + cout << "A tetrahedra with null volume will be created with triangle " << it << " of 2D Mesh " << endl; cout << "stop procedure of buildlayer" << endl; exit(1); } } - double cpu2 = ((double) clock())/CLOCKS_PER_SEC; + double cpu2 = ((double)clock( )) / CLOCKS_PER_SEC; // cas maillage volumique + surfacique - Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, - mapemil, mapezmax, mapezmin); + Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, mapezmin); // cas maillage surfacique simplement // A construire Jacques + donner le numero des edges que // l'on veut pas creer � l'int�rieure delete pTh; - double cpu3 = ((double) clock())/CLOCKS_PER_SEC, cpu4=cpu3; + double cpu3 = ((double)clock( )) / CLOCKS_PER_SEC, cpu4 = cpu3; if (xx && yy && zz) { // Mesh3 *Th3= build_layer(Th, nlayer, ni, zmin, zmax); @@ -4502,9 +4328,15 @@ AnyType cubeMesh_Op::operator( )(Stack stack) const { int i = (*Th3)(it, iv); if (takemesh[i] == 0) { mp->setP(Th3, it, iv); - { txx[i] = GetAny< double >((*xx)(stack)); } - { tyy[i] = GetAny< double >((*yy)(stack)); } - { tzz[i] = GetAny< double >((*zz)(stack)); } + { + txx[i] = GetAny< double >((*xx)(stack)); + } + { + tyy[i] = GetAny< double >((*yy)(stack)); + } + { + tzz[i] = GetAny< double >((*zz)(stack)); + } takemesh[i] = takemesh[i] + 1; } } @@ -4516,25 +4348,21 @@ AnyType cubeMesh_Op::operator( )(Stack stack) const { recollement_border = 0; point_confondus_ok = 1; } - - Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, *Th3, txx, tyy, tzz, border_only, recollement_elem, - recollement_border, point_confondus_ok, 1); - + + Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, *Th3, txx, tyy, tzz, border_only, recollement_elem, recollement_border, point_confondus_ok, 1); + delete Th3; Th3 = T_Th3; } - cpu4 = ((double) clock())/CLOCKS_PER_SEC; + cpu4 = ((double)clock( )) / CLOCKS_PER_SEC; Th3->BuildGTree( ); // A decommenter if (verbosity > 10) { cout << " Cube %%% " << Th3 << endl; } - double cpu5 = ((double) clock())/CLOCKS_PER_SEC; - if(verbosity>1) - { - cout<< " Cube timers 2d" << cpu1-cpu0 << " ?? "<< cpu2-cpu1 << endl << - " buildlayer: " << cpu3-cpu2 - << " Transfo " << cpu4-cpu3 << " Gtree " << cpu5-cpu4 << " " << endl; - } + double cpu5 = ((double)clock( )) / CLOCKS_PER_SEC; + if (verbosity > 1) { + cout << " Cube timers 2d" << cpu1 - cpu0 << " ?? " << cpu2 - cpu1 << endl << " buildlayer: " << cpu3 - cpu2 << " Transfo " << cpu4 - cpu3 << " Gtree " << cpu5 - cpu4 << " " << endl; + } Add2StackOfPtr2FreeRC(stack, Th3); *mp = mps; return Th3; @@ -4670,16 +4498,14 @@ AnyType BuildLayeMesh_Op::operator( )(Stack stack) const { int i2 = Th.operator( )(K[2]); if (ni[i0] == 0 && ni[i1] == 0 && ni[i2] == 0) { - cout << "A tetrahedra with null volume will be created with triangle " << it << " of 2D Mesh " - << endl; + cout << "A tetrahedra with null volume will be created with triangle " << it << " of 2D Mesh " << endl; cout << "stop procedure of buildlayer" << endl; exit(1); } } // cas maillage volumique + surfacique - Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, - mapemil, mapezmax, mapezmin); + Mesh3 *Th3 = build_layer(Th, nlayer, ni, zmin, zmax, maptet, maptrimil, maptrizmax, maptrizmin, mapemil, mapezmax, mapezmin); // cas maillage surfacique simplement // A construire Jacques + donner le numero des edges que // l'on veut pas creer à l'intérieure @@ -4746,8 +4572,7 @@ AnyType BuildLayeMesh_Op::operator( )(Stack stack) const { point_confondus_ok = 1; } - Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, rTh3, txx, tyy, tzz, border_only, recollement_elem, - recollement_border, point_confondus_ok, 1); + Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, rTh3, txx, tyy, tzz, border_only, recollement_elem, recollement_border, point_confondus_ok, 1); T_Th3->BuildGTree( ); // A decommenter delete Th3; @@ -4764,35 +4589,24 @@ class DeplacementTab_Op : public E_F0mps { static const int n_name_param = 6; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - KN_< double > arg(int i, Stack stack, KN_< double > a) const { - return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; - } + KN_< double > arg(int i, Stack stack, KN_< double > a) const { return nargs[i] ? GetAny< KN_< double > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: - DeplacementTab_Op(const basicAC_F0 &args, Expression tth) - : eTh(tth) { // , xx(0) , yy(0) , zz(0) + DeplacementTab_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { // , xx(0) , yy(0) , zz(0) args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type DeplacementTab_Op::name_param[] = { - {"deltax", &typeid(KN_< double >)}, {"deltay", &typeid(KN_< double >)}, - {"deltaz", &typeid(KN_< double >)}, {"ptmerge", &typeid(double)}, - {"facemerge", &typeid(long)}, {"boolsurface", &typeid(long)}}; +basicAC_F0::name_and_type DeplacementTab_Op::name_param[] = {{"deltax", &typeid(KN_< double >)}, {"deltay", &typeid(KN_< double >)}, {"deltaz", &typeid(KN_< double >)}, + {"ptmerge", &typeid(double)}, {"facemerge", &typeid(long)}, {"boolsurface", &typeid(long)}}; AnyType DeplacementTab_Op::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; Mesh3 *pTh = GetAny< Mesh3 * >((*eTh)(stack)); @@ -4804,8 +4618,7 @@ AnyType DeplacementTab_Op::operator( )(Stack stack) const { int nbt = Th.nt; // nombre de triangles int nbe = Th.nbe; // nombre d'aretes fontiere if (verbosity > 5) { - cout << "before movemesh: Vertex " << nbv << " Tetrahedra " << nbt << " triangles " << nbe - << endl; + cout << "before movemesh: Vertex " << nbv << " Tetrahedra " << nbt << " triangles " << nbe << endl; } // lecture des references @@ -4855,8 +4668,7 @@ AnyType DeplacementTab_Op::operator( )(Stack stack) const { point_confondus_ok = 1; } - Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, Th, txx, tyy, tzz, border_only, recollement_elem, - recollement_border, point_confondus_ok, 1); + Mesh3 *T_Th3 = Transfo_Mesh3(precis_mesh, Th, txx, tyy, tzz, border_only, recollement_elem, recollement_border, point_confondus_ok, 1); T_Th3->BuildGTree( ); /*if (nbt != 0) { @@ -4887,9 +4699,7 @@ class DeplacementTab : public OneOperator { public: DeplacementTab( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new DeplacementTab_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new DeplacementTab_Op(args, t[0]->CastTo(args[0])); } }; // CheckSurfaceMesh ==> @@ -4915,8 +4725,7 @@ void GetManifolds(Expression mani, int &nbcmanifold, int *&mani_nbe, Expression for (i = 0; i < n; i++) { GetNumberBEManifold((*a)[i], mani_nbe[i]); - cout << "number of manifold = " << n << "manifold i=" << i << "nb BE label=" << mani_nbe[i] - << endl; + cout << "number of manifold = " << n << "manifold i=" << i << "nb BE label=" << mani_nbe[i] << endl; size = size + mani_nbe[i]; } @@ -4998,17 +4807,11 @@ class CheckManifoldMesh_Op : public E_F0mps { int *mani_nbe; Expression *manifolds; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } public: CheckManifoldMesh_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { @@ -5071,9 +4874,8 @@ AnyType CheckManifoldMesh_Op::operator( )(Stack stack) const { // beginvariete[nbvariete]=count; long resultat = 1; - pTh->BuildBoundaryElementAdj( - nbmanifold, BeginManifold, TabLabelManifold, - OrientLabelManifold); // nbvariete, beginvariete, TabLabelVariete, OrientLabelVariete); + pTh->BuildBoundaryElementAdj(nbmanifold, BeginManifold, TabLabelManifold, + OrientLabelManifold); // nbvariete, beginvariete, TabLabelVariete, OrientLabelVariete); cout << "utilisation V2" << endl; *mp = mps; @@ -5084,15 +4886,9 @@ class CheckManifoldMesh : public OneOperator { public: CheckManifoldMesh( ) : OneOperator(atype< long >( ), atype< pmeshS >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new CheckManifoldMesh_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new CheckManifoldMesh_Op(args, t[0]->CastTo(args[0])); } }; - - - - template< class MMesh > void Renumb(MMesh *&pTh) { assert(pTh); @@ -5100,9 +4896,7 @@ void Renumb(MMesh *&pTh) { typedef typename MMesh::Element T; typedef typename MMesh::BorderElement B; typedef typename MMesh::Vertex V; - - - + int nbv = Th.nv; int nbt = Th.nt; int *xadg = new int[nbv + 1]; @@ -5176,8 +4970,7 @@ void Renumb(MMesh *&pTh) { for (int i = 0; i < nbt; i++) { int ivt[T::nv]; - for(int ii=0;iiset(v, ivv, K.lab); } @@ -5198,10 +4990,8 @@ void Renumb(MMesh *&pTh) { pTh->BuildGTree( ); } - // trunc for surface meshS -MeshS *truncmesh(const MeshS &Th, const long &kksplit, int *split, bool WithMortar, - const int newbelabel,double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate); +MeshS *truncmesh(const MeshS &Th, const long &kksplit, int *split, bool WithMortar, const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate); struct Op_trunc_meshS : public OneOperator { typedef const MeshS *pmeshS; @@ -5214,520 +5004,489 @@ struct Op_trunc_meshS : public OneOperator { long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } KN< long > *arg(int i, Stack stack) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : 0; } - double arg(int i, Stack stack, double a) const {return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { - args.SetNameParam(n_name_param, name_param, nargs); - } + Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack s) const; }; - E_F0 *code(const basicAC_F0 &args) const { - return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } - Op_trunc_meshS( ) : OneOperator(atype< pmeshS >( ), atype< pmeshS >( ), atype< bool >( )){}; + Op_trunc_meshS( ) : OneOperator(atype< pmeshS >( ), atype< pmeshS >( ), atype< bool >( )) {}; }; basicAC_F0::name_and_type Op_trunc_meshS::Op::name_param[Op_trunc_meshS::Op::n_name_param] = { - {"split", &typeid(long)}, {"label", &typeid(long)}, - {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, - {"renum", &typeid(bool)}, {"precis_mesh", &typeid(double)}, - {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"labels", &typeid(KN_ )}, - {"region", &typeid(KN_ )}, {"flabel", &typeid(long)}, - {"fregion", &typeid(long)} -}; - -inline SortArray< int, 2 > keyedge(const MeshS &Th,const TriangleS &K,int e) -{ - int e1 = Th(K[K.nvedge[e][0]]); - int e2 = Th(K[K.nvedge[e][1]]); - return SortArray< int, 2 >(e1,e2); -} -inline SortArray< int, 2 > keyedge(int e1,int e2) -{ - return SortArray< int, 2 >(e1,e2); + {"split", &typeid(long)}, {"label", &typeid(long)}, {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, {"renum", &typeid(bool)}, + {"precis_mesh", &typeid(double)}, {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"labels", &typeid(KN_< long >)}, + {"region", &typeid(KN_< long >)}, {"flabel", &typeid(long)}, {"fregion", &typeid(long)}}; + +inline SortArray< int, 2 > keyedge(const MeshS &Th, const TriangleS &K, int e) { + int e1 = Th(K[K.nvedge[e][0]]); + int e2 = Th(K[K.nvedge[e][1]]); + return SortArray< int, 2 >(e1, e2); } +inline SortArray< int, 2 > keyedge(int e1, int e2) { return SortArray< int, 2 >(e1, e2); } -MeshS *truncmesh(const MeshS &Th, const long &kksplit, int *split, bool WithMortar, - const int newbelabel, double precis_mesh, long orientation, - bool cleanmesh, bool removeduplicate) -{ - // computation of number of border elements and vertex without split - // warning the surf can be no manifold - int nbe = 0; - int nbei = 0;// not used - int nt = 0; - int nv = 0; - - int nvtrunc = 0; - int nedge = 0; - int nface = 0; - - double hmin = 1e100; - - R3 bmin, bmax; - // counter for edges, boundary or internal - int nbeee = 0; - int nbfi = 0; - - const int kksplit2 = kksplit * kksplit; - // construct of edge - nedge = 0; - // Attention FH class not the stl - // new code sep. 24 , 2025 - - // build all edges - HashTable< SortArray< int, 2 >, int > edges(3 * Th.nt, Th.nt); - KN nkie(3*Th.nt,-1);// number nkie(3*k+i) of i = 0,1,2 edge of triangle k ; - - for (int i = 0; i < Th.nt; i++) - if (split[i]) { - nt+=kksplit2; - const TriangleS &K(Th.elements[i]); - - for (int e = 0; e < 3; ++e) { - hmin = min(hmin, Th[i].lenEdge(e)); // calcul de .lenEdge pour un Mesh3 - SortArray< int, 2 > key=keyedge(Th,K,e); - auto it = edges.find(key); - int nue ; - if (!it) edges.add(key, nue = nedge++); - else nue=it->v;/// liste de tous les edges du mesh initial decoupe - nkie[3*i+e]= nue; - } - } - KN nwe(nedge,0); - - int newedge=0;// new border edge beetwen split and remove - - // nwe(i) == 1 => new edge , nwe(i) = 2 => edge old boundary - - // find all new edge in old edges !! - int nbeb =0; - for (int ibe = 0; ibe < Th.nbe; ibe++) { - int e1 = Th(Th.be(ibe)[0]); - int e2 = Th(Th.be(ibe)[1]); - SortArray< int, 2 > key = keyedge(e1,e2); - auto it =edges.find(key); - if( it ) // edge exist - { - int nue = it->v; - ++nbeb; - nwe[nue]=2; - }// - } - // search edge beetwen split and non remove - for (int i = 0; i < Th.nt; i++) - if (split[i]==0) {// for unsplited face - const TriangleS &K(Th.elements[i]); - - for (int e = 0; e < 3; ++e) { - SortArray< int, 2 > key=keyedge(Th,K,e); - auto it = edges.find(key); - if(it) { // beetwen split and non split - int nue = it->v; - if(!nwe[nue]) { - ++newedge; - nwe[nue]=1;} - } - } - } +MeshS *truncmesh(const MeshS &Th, const long &kksplit, int *split, bool WithMortar, const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate) { + // computation of number of border elements and vertex without split + // warning the surf can be no manifold + int nbe = 0; + int nbei = 0; // not used + int nt = 0; + int nv = 0; - int ntsplit = 0; - int tagb[3] = {1, 2, 4}; - - KN< int > tagTonB(Th.nt), n; - tagTonB = 0; - - if (verbosity > 2) - cout << " -- trunc: initial mesh, nb vertices: " << Th.nv << ", nb triangles: " << Th.nt - << ", nb boundary edges:" << Th.nbe << " split :"<< kksplit << endl - << " all nbe "<< nedge << " new edges " - << newedge << " edge on border "<< nbeb<< endl; - - - double hseuil = (hmin / kksplit) / 1000.; - nbe = (nbeb+newedge)*kksplit; - if (verbosity > 5) - cout << " - Before trunc, mesh has " << Th.nbe << " new boundary edges, " << nbeb - << " internal edges = " - << ", all edges = " << nedge << ", hseuil=" << hseuil << " new nbe = " << nbe << endl; - - - /* determination de bmin, bmax et hmin */ - - KN< int > takevertex(Th.nv, -1); - - for (int i = 0; i < Th.nt; i++) { - if (split[i]) { - const TriangleS &K(Th.elements[i]); - - for (int ii = 0; ii < 3; ii++) { - int iv = Th.operator( )(K[ii]); - if (takevertex[iv] == -1) { - bmin = Minc(Th.vertices[iv], bmin); - bmax = Maxc(Th.vertices[iv], bmax); - takevertex[iv] = nvtrunc++; - } - } - } - } - - // take same numbering - for (int i = 0, k = 0; i < Th.nv; i++) { - if (takevertex[i] >= 0) { - takevertex[i] = k++; - } - } - - - - /* determination des vertex, triangles et tetrahedre obtenue apres splitting dans le Simplex */ - - int nvmax = 0; - for (int i = 0; i < Th.nt; i++) - if (split[i]) { - int k = Abs(split[i]); - int r = (k + 2) * (k + 1) / 2; - split[i] < 0 ? nvmax += 3 *r - 3 : nvmax += r - 3; - } - nvmax += nvtrunc; - - int nvsub = (kksplit + 1) * (kksplit + 2) / 2; - int ntrisub = kksplit2; - int nedgesub = 3 * (kksplit + 1) * (kksplit + 2) / 2 - 3 * (kksplit + 1); - - R2 *vertexsub; - int *trisub; - int *edgesub; - - // split triangles element - fct splid on a the simplex - SplitSimplex< R2 >(kksplit, nvsub, vertexsub, ntrisub, trisub); - // split the boundary of the triangle simplex - SplitEdgeSimplex(kksplit, nedgesub, edgesub); - - int itt = 0; - int ie = 0; - - Vertex3 *vertices = new Vertex3[nvmax]; - TriangleS *t = new TriangleS[nt]; - TriangleS *triangles = t; - BoundaryEdgeS *b = new BoundaryEdgeS[nbe]; - BoundaryEdgeS *bbedges = b; - R3 hh = (bmax - bmin) / 10.; - - EF23::GTree< Vertex3 > *gtree = new EF23::GTree< Vertex3 >(vertices, bmin - hh, bmax + hh, 0); - - const R3 *pP[3]; - - int np = 0; // nb of new points .. - - // first build old point to keep the numbering order for DDM ... - for (int i = 0, k = 0; i < Th.nv; i++) { - if (takevertex[i] >= 0) { - Vertex3 *pvi = gtree->ToClose(Th(i), hseuil); - if (!pvi) { - (R3 &)vertices[np] = Th(i); - vertices[np].lab = Th(i).lab; - gtree->Add(vertices[np]); - np++; - } else { - ffassert(0); - } - } - } - - KN< R3 > vertextrisub(nvsub); - KN< int > newindex(nvsub); - - for (int i = 0; i < Th.nt; i++) - if (split[i]) { - const TriangleS &K(Th.elements[i]); - - for (int ii = 0; ii < 3; ii++) pP[ii] = &K[ii]; - for (int iv = 0; iv < nvsub; iv++) (R3 &)vertextrisub[iv] = vertexsub[iv].Bary(pP); - - // new points - for (int iv = 0; iv < nvsub; iv++) { - Vertex3 *pvi = gtree->ToClose(vertextrisub[iv], hseuil); - - if (!pvi) { - vertices[np].x = vertextrisub[iv].x; - vertices[np].y = vertextrisub[iv].y; - vertices[np].z = vertextrisub[iv].z; - vertices[np].lab = K.lab; - newindex[iv] = np; - gtree->Add(vertices[np]); - np++; - } else { - // assert(pvi); - newindex[iv] = pvi - vertices; - } - ffassert(np <= nvmax); - } - nv = np; - // new triangles - for (int ii = 0; ii < ntrisub; ii++) { - int ivt[3]; - for (int jj = 0; jj < 3; jj++) { - ivt[jj] = newindex[trisub[3 * ii + jj]]; - assert(trisub[3 * ii + jj] < nvsub); - assert(ivt[jj] < np); - } - R3 A = vertices[ivt[0]]; - R3 B = vertices[ivt[1]]; - R3 C = vertices[ivt[2]]; - R3 n = (B - A) ^ (C - A); - // to build the vectorial area - R a = (Area3(A, B, C), n); - if (a < 0) swap(ivt[1], ivt[2]); - triangles[itt].set(vertices, ivt, K.lab); - itt++; - assert(itt <= nt); - } - - // here split new edges not in boundary - for (int j = 0; j < 3; j++) { - int nedgesplit = 0; - if(verbosity>99) - cout << " ** " <=0); - if( nwe[nkie[3*i+j]]==1) nedgesplit=kksplit;// - if(nedgesplit) { - // new border not on boundary - int ivb[2]; - for (int ii = 0; ii < nedgesplit; ii++) { - for (int jjj = 0; jjj < 2; jjj++) { - int iedge = 2 * j * nedgesplit + 2 * ii; - ivb[jjj] = newindex[edgesub[iedge + jjj]]; ///// ??? - assert(edgesub[2 * ii + jjj] < nvsub); - assert(ivb[jjj] < np); - } - bbedges[ie].set(vertices, ivb, newbelabel); - ie++; - } - } - assert(ie <= nbe); - } + int nvtrunc = 0; + int nedge = 0; + int nface = 0; + + double hmin = 1e100; + + R3 bmin, bmax; + // counter for edges, boundary or internal + int nbeee = 0; + int nbfi = 0; + + const int kksplit2 = kksplit * kksplit; + // construct of edge + nedge = 0; + // Attention FH class not the stl + // new code sep. 24 , 2025 + + // build all edges + HashTable< SortArray< int, 2 >, int > edges(3 * Th.nt, Th.nt); + KN< int > nkie(3 * Th.nt, -1); // number nkie(3*k+i) of i = 0,1,2 edge of triangle k ; + + for (int i = 0; i < Th.nt; i++) + if (split[i]) { + nt += kksplit2; + const TriangleS &K(Th.elements[i]); + + for (int e = 0; e < 3; ++e) { + hmin = min(hmin, Th[i].lenEdge(e)); // calcul de .lenEdge pour un Mesh3 + SortArray< int, 2 > key = keyedge(Th, K, e); + auto it = edges.find(key); + int nue; + if (!it) + edges.add(key, nue = nedge++); + else + nue = it->v; /// liste de tous les edges du mesh initial decoupe + nkie[3 * i + e] = nue; + } + } + KN< int > nwe(nedge, 0); + + int newedge = 0; // new border edge beetwen split and remove + + // nwe(i) == 1 => new edge , nwe(i) = 2 => edge old boundary + + // find all new edge in old edges !! + int nbeb = 0; + for (int ibe = 0; ibe < Th.nbe; ibe++) { + int e1 = Th(Th.be(ibe)[0]); + int e2 = Th(Th.be(ibe)[1]); + SortArray< int, 2 > key = keyedge(e1, e2); + auto it = edges.find(key); + if (it) // edge exist + { + int nue = it->v; + ++nbeb; + nwe[nue] = 2; + } // + } + // search edge beetwen split and non remove + for (int i = 0; i < Th.nt; i++) + if (split[i] == 0) { // for unsplited face + const TriangleS &K(Th.elements[i]); + + for (int e = 0; e < 3; ++e) { + SortArray< int, 2 > key = keyedge(Th, K, e); + auto it = edges.find(key); + if (it) { // beetwen split and non split + int nue = it->v; + if (!nwe[nue]) { + ++newedge; + nwe[nue] = 1; + } + } + } + } + + int ntsplit = 0; + int tagb[3] = {1, 2, 4}; + + KN< int > tagTonB(Th.nt), n; + tagTonB = 0; + + if (verbosity > 2) + cout << " -- trunc: initial mesh, nb vertices: " << Th.nv << ", nb triangles: " << Th.nt << ", nb boundary edges:" << Th.nbe << " split :" << kksplit << endl + << " all nbe " << nedge << " new edges " << newedge << " edge on border " << nbeb << endl; + + double hseuil = (hmin / kksplit) / 1000.; + nbe = (nbeb + newedge) * kksplit; + if (verbosity > 5) + cout << " - Before trunc, mesh has " << Th.nbe << " new boundary edges, " << nbeb << " internal edges = " + << ", all edges = " << nedge << ", hseuil=" << hseuil << " new nbe = " << nbe << endl; + + /* determination de bmin, bmax et hmin */ + + KN< int > takevertex(Th.nv, -1); + + for (int i = 0; i < Th.nt; i++) { + if (split[i]) { + const TriangleS &K(Th.elements[i]); + + for (int ii = 0; ii < 3; ii++) { + int iv = Th.operator( )(K[ii]); + if (takevertex[iv] == -1) { + bmin = Minc(Th.vertices[iv], bmin); + bmax = Maxc(Th.vertices[iv], bmax); + takevertex[iv] = nvtrunc++; } - - - if (verbosity > 4) cout << " ++ np=" << np << "== nv=" << nvmax << endl; - - ffassert(np <= nv); - if (verbosity > 4) cout << " -- Number of new border face not on Border " << ie << endl; - - delete[] vertexsub; - delete[] trisub; - delete[] edgesub; - - // split border elements Edges - int nv1Dsub = kksplit + 1; - int nedge1Dsub = kksplit; - R1 *vertex1Dsub; - int *edge1Dsub; - - SplitSimplex< R1 >(kksplit, nv1Dsub, vertex1Dsub, nedge1Dsub, edge1Dsub); - if(verbosity>4) cout << " new nbe = "<< nbe << " old " << Th.nbe << " ie " << ie << endl; - for (int ibe = 0; ibe < Th.nbe; ibe++) { - const BoundaryEdgeS &K(Th.be(ibe)); - int ivv[2]; - bool nosplit=0; - ivv[0] = Th.operator( )(K[0]); - ivv[1] = Th.operator( )(K[1]); - SortArray< int, 2 > key = keyedge(ivv[0],ivv[1]); - auto it =edges.find(key); - if( it ) // edge exist - { - int nue = it->v; - nosplit = nwe[nue]==2; - }// - - - if( !nosplit)continue; - - R3 *vertexedgesub = new R3[nv1Dsub]; - int *newindex = new int[nv1Dsub]; - - for (int iv = 0; iv < nv1Dsub; iv++) { - double alpha = vertex1Dsub[iv].x; - - vertexedgesub[iv].x = alpha * Th.vertices[ivv[0]].x + (1. - alpha) * Th.vertices[ivv[1]].x; - vertexedgesub[iv].y = alpha * Th.vertices[ivv[0]].y + (1. - alpha) * Th.vertices[ivv[1]].y; - vertexedgesub[iv].z = alpha * Th.vertices[ivv[0]].z + (1. - alpha) * Th.vertices[ivv[1]].z; + } + } + } + + // take same numbering + for (int i = 0, k = 0; i < Th.nv; i++) { + if (takevertex[i] >= 0) { + takevertex[i] = k++; + } + } + + /* determination des vertex, triangles et tetrahedre obtenue apres splitting dans le Simplex */ + + int nvmax = 0; + for (int i = 0; i < Th.nt; i++) + if (split[i]) { + int k = Abs(split[i]); + int r = (k + 2) * (k + 1) / 2; + split[i] < 0 ? nvmax += 3 *r - 3 : nvmax += r - 3; + } + nvmax += nvtrunc; + + int nvsub = (kksplit + 1) * (kksplit + 2) / 2; + int ntrisub = kksplit2; + int nedgesub = 3 * (kksplit + 1) * (kksplit + 2) / 2 - 3 * (kksplit + 1); + + R2 *vertexsub; + int *trisub; + int *edgesub; + + // split triangles element - fct splid on a the simplex + SplitSimplex< R2 >(kksplit, nvsub, vertexsub, ntrisub, trisub); + // split the boundary of the triangle simplex + SplitEdgeSimplex(kksplit, nedgesub, edgesub); + + int itt = 0; + int ie = 0; + + Vertex3 *vertices = new Vertex3[nvmax]; + TriangleS *t = new TriangleS[nt]; + TriangleS *triangles = t; + BoundaryEdgeS *b = new BoundaryEdgeS[nbe]; + BoundaryEdgeS *bbedges = b; + R3 hh = (bmax - bmin) / 10.; + + EF23::GTree< Vertex3 > *gtree = new EF23::GTree< Vertex3 >(vertices, bmin - hh, bmax + hh, 0); + + const R3 *pP[3]; + + int np = 0; // nb of new points .. + + // first build old point to keep the numbering order for DDM ... + for (int i = 0, k = 0; i < Th.nv; i++) { + if (takevertex[i] >= 0) { + Vertex3 *pvi = gtree->ToClose(Th(i), hseuil); + if (!pvi) { + (R3 &)vertices[np] = Th(i); + vertices[np].lab = Th(i).lab; + gtree->Add(vertices[np]); + np++; + } else { + ffassert(0); + } + } + } + + KN< R3 > vertextrisub(nvsub); + KN< int > newindex(nvsub); + + for (int i = 0; i < Th.nt; i++) + if (split[i]) { + const TriangleS &K(Th.elements[i]); + + for (int ii = 0; ii < 3; ii++) pP[ii] = &K[ii]; + for (int iv = 0; iv < nvsub; iv++) (R3 &)vertextrisub[iv] = vertexsub[iv].Bary(pP); + + // new points + for (int iv = 0; iv < nvsub; iv++) { + Vertex3 *pvi = gtree->ToClose(vertextrisub[iv], hseuil); + + if (!pvi) { + vertices[np].x = vertextrisub[iv].x; + vertices[np].y = vertextrisub[iv].y; + vertices[np].z = vertextrisub[iv].z; + vertices[np].lab = K.lab; + newindex[iv] = np; + gtree->Add(vertices[np]); + np++; + } else { + // assert(pvi); + newindex[iv] = pvi - vertices; } - - for (int iv = 0; iv < nv1Dsub; iv++) { - const Vertex3 &vi(vertexedgesub[iv]); - Vertex3 *pvi = gtree->ToClose(vi, hseuil); - assert(pvi); - newindex[iv] = pvi - vertices; + ffassert(np <= nvmax); + } + nv = np; + // new triangles + for (int ii = 0; ii < ntrisub; ii++) { + int ivt[3]; + for (int jj = 0; jj < 3; jj++) { + ivt[jj] = newindex[trisub[3 * ii + jj]]; + assert(trisub[3 * ii + jj] < nvsub); + assert(ivt[jj] < np); } - for (int ii = 0; ii < nedge1Dsub; ii++) { - int ivb[2]; - + R3 A = vertices[ivt[0]]; + R3 B = vertices[ivt[1]]; + R3 C = vertices[ivt[2]]; + R3 n = (B - A) ^ (C - A); + // to build the vectorial area + R a = (Area3(A, B, C), n); + if (a < 0) swap(ivt[1], ivt[2]); + triangles[itt].set(vertices, ivt, K.lab); + itt++; + assert(itt <= nt); + } + + // here split new edges not in boundary + for (int j = 0; j < 3; j++) { + int nedgesplit = 0; + if (verbosity > 99) cout << " ** " << i << " " << j << " " << nkie[3 * i + j] << " " << nwe[nkie[3 * i + j]] << " " << ie << endl; + ffassert(nkie[3 * i + j] >= 0); + if (nwe[nkie[3 * i + j]] == 1) nedgesplit = kksplit; // + if (nedgesplit) { + // new border not on boundary + int ivb[2]; + for (int ii = 0; ii < nedgesplit; ii++) { for (int jjj = 0; jjj < 2; jjj++) { - ivb[jjj] = newindex[edge1Dsub[2 * ii + jjj]]; - assert(edge1Dsub[2 * ii + jjj] < nvsub); - if (verbosity > 199) { - cout << " " << ivb[jjj] << " np:" << np << endl; - } - - assert(ivb[jjj] < np); + int iedge = 2 * j * nedgesplit + 2 * ii; + ivb[jjj] = newindex[edgesub[iedge + jjj]]; ///// ??? + assert(edgesub[2 * ii + jjj] < nvsub); + assert(ivb[jjj] < np); } - bbedges[ie].set(vertices, ivb, K.lab); + bbedges[ie].set(vertices, ivb, newbelabel); ie++; - if(ie > nbe ) cout << " Bug " << ie << " "<< nbe << endl; - + } } - delete[] vertexedgesub; - delete[] newindex; - } - delete[] vertex1Dsub; - delete[] edge1Dsub; - if(nbe!=ie) cout << " nbe "<< nbe << " == "<< ie << endl; - ffassert(nbe==ie); - nbe = ie; - if (verbosity > 3) { - cout << " - Nb of vertices " << nv << endl; - cout << " - Nb of triangle " << nt << " == " << itt << endl; - cout << " - Nb of boundary edges " << nbe << endl; + assert(ie <= nbe); + } } - ffassert(itt==nt); - bool rebuildboundary=false; - MeshS *Tht = new MeshS(nv, itt, nbe, vertices, triangles, bbedges, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); - - Tht->BuildGTree( ); // Add JM. Oct 2010 - - delete gtree; - - return Tht; -} + if (verbosity > 4) cout << " ++ np=" << np << "== nv=" << nvmax << endl; - - - -AnyType Op_trunc_meshS::Op::operator( )(Stack stack) const { - MeshS *pTh = GetAny< MeshS * >((*getmesh)(stack)); - MeshS &Th = *pTh; - long kkksplit = std::max(1L, arg(0, stack, 1L)); - long label = arg(1, stack, 2L); - - KN< long > *pn2o = arg(2, stack); - KN< long > *po2n = arg(3, stack); - bool renum = arg(4, stack, false); - KN< long > kempty; - double precis_mesh(arg(5, stack, 1e-7)); - long orientation(arg(6, stack, 1L)); - bool cleanmesh(arg(7, stack, true)); - bool removeduplicate(arg(8, stack, false)); - - KN nrB = arg(9,stack,kempty); - KN nrT = arg(10,stack,kempty); - Expression flab = nargs[11] ; - Expression freg = nargs[12] ; - ffassert(nrT.N( ) % 2 == 0); - ffassert(nrB.N( ) % 2 == 0); - - KN< int > split(Th.nt); - split = kkksplit; - MeshPoint *mp = MeshPointStack(stack), mps = *mp; - long kk = 0; - long ks = kkksplit * kkksplit; - - for (int k = 0; k < Th.nt; k++) { - const TriangleS &K(Th.elements[k]); - R2 B(1. / 3., 1. / 3.); - mp->set(Th, K(B), B, K, 0); - if (GetAny< bool >((*bbb)(stack))) { - kk++; - } else { - split[k] = 0; - } + ffassert(np <= nv); + if (verbosity > 4) cout << " -- Number of new border face not on Border " << ie << endl; + + delete[] vertexsub; + delete[] trisub; + delete[] edgesub; + + // split border elements Edges + int nv1Dsub = kksplit + 1; + int nedge1Dsub = kksplit; + R1 *vertex1Dsub; + int *edge1Dsub; + + SplitSimplex< R1 >(kksplit, nv1Dsub, vertex1Dsub, nedge1Dsub, edge1Dsub); + if (verbosity > 4) cout << " new nbe = " << nbe << " old " << Th.nbe << " ie " << ie << endl; + for (int ibe = 0; ibe < Th.nbe; ibe++) { + const BoundaryEdgeS &K(Th.be(ibe)); + int ivv[2]; + bool nosplit = 0; + ivv[0] = Th.operator( )(K[0]); + ivv[1] = Th.operator( )(K[1]); + SortArray< int, 2 > key = keyedge(ivv[0], ivv[1]); + auto it = edges.find(key); + if (it) // edge exist + { + int nue = it->v; + nosplit = nwe[nue] == 2; + } // + + if (!nosplit) continue; + + R3 *vertexedgesub = new R3[nv1Dsub]; + int *newindex = new int[nv1Dsub]; + + for (int iv = 0; iv < nv1Dsub; iv++) { + double alpha = vertex1Dsub[iv].x; + + vertexedgesub[iv].x = alpha * Th.vertices[ivv[0]].x + (1. - alpha) * Th.vertices[ivv[1]].x; + vertexedgesub[iv].y = alpha * Th.vertices[ivv[0]].y + (1. - alpha) * Th.vertices[ivv[1]].y; + vertexedgesub[iv].z = alpha * Th.vertices[ivv[0]].z + (1. - alpha) * Th.vertices[ivv[1]].z; } - - // *mp=mps; - if (verbosity > 1) { - cout << " -- Trunc mesh: Nb of Surface Triangles = " << kk << " label=" << label << endl; - } - - if (pn2o) { - pn2o->resize(kk * ks); - KN< long > &n2o(*pn2o); - int l = 0; - - for (int k = 0; k < Th.nt; ++k) { - if (split[k]) { - for (int i = 0; i < ks; ++i) { - n2o[l++] = k; - } - } - } + + for (int iv = 0; iv < nv1Dsub; iv++) { + const Vertex3 &vi(vertexedgesub[iv]); + Vertex3 *pvi = gtree->ToClose(vi, hseuil); + assert(pvi); + newindex[iv] = pvi - vertices; } - - if (po2n) { - po2n->resize(Th.nt); - KN< long > &o2n(*po2n); - int l = 0; - - for (int k = 0; k < Th.nt; ++k) { - if (split[k]) { - o2n[k] = l; - l += ks; - } else { - o2n[k] = -1; - } + for (int ii = 0; ii < nedge1Dsub; ii++) { + int ivb[2]; + + for (int jjj = 0; jjj < 2; jjj++) { + ivb[jjj] = newindex[edge1Dsub[2 * ii + jjj]]; + assert(edge1Dsub[2 * ii + jjj] < nvsub); + if (verbosity > 199) { + cout << " " << ivb[jjj] << " np:" << np << endl; } + + assert(ivb[jjj] < np); + } + bbedges[ie].set(vertices, ivb, K.lab); + ie++; + if (ie > nbe) cout << " Bug " << ie << " " << nbe << endl; } - - *mp = mps; - MeshS *Tht = truncmesh(Th, kkksplit, split, false, label, precis_mesh, orientation, cleanmesh, removeduplicate); - - if (renum) - Renumb(Tht); - - MeshS &pTht=*Tht; - map mapB,mapT; - for(int i=0;iset(pTht,pTht[i](PtHat),PtHat,pTht[i],lab); - pTht.elements[i].lab =GetAny( (* freg)(stack)) ; - if(verbosity>5) cout << " freg "< 3) { + cout << " - Nb of vertices " << nv << endl; + cout << " - Nb of triangle " << nt << " == " << itt << endl; + cout << " - Nb of boundary edges " << nbe << endl; + } + ffassert(itt == nt); + + bool rebuildboundary = false; + MeshS *Tht = new MeshS(nv, itt, nbe, vertices, triangles, bbedges, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); + + Tht->BuildGTree( ); // Add JM. Oct 2010 + + delete gtree; + + return Tht; +} + +AnyType Op_trunc_meshS::Op::operator( )(Stack stack) const { + MeshS *pTh = GetAny< MeshS * >((*getmesh)(stack)); + MeshS &Th = *pTh; + long kkksplit = std::max(1L, arg(0, stack, 1L)); + long label = arg(1, stack, 2L); + + KN< long > *pn2o = arg(2, stack); + KN< long > *po2n = arg(3, stack); + bool renum = arg(4, stack, false); + KN< long > kempty; + double precis_mesh(arg(5, stack, 1e-7)); + long orientation(arg(6, stack, 1L)); + bool cleanmesh(arg(7, stack, true)); + bool removeduplicate(arg(8, stack, false)); + + KN< long > nrB = arg(9, stack, kempty); + KN< long > nrT = arg(10, stack, kempty); + Expression flab = nargs[11]; + Expression freg = nargs[12]; + ffassert(nrT.N( ) % 2 == 0); + ffassert(nrB.N( ) % 2 == 0); + + KN< int > split(Th.nt); + split = kkksplit; + MeshPoint *mp = MeshPointStack(stack), mps = *mp; + long kk = 0; + long ks = kkksplit * kkksplit; + + for (int k = 0; k < Th.nt; k++) { + const TriangleS &K(Th.elements[k]); + R2 B(1. / 3., 1. / 3.); + mp->set(Th, K(B), B, K, 0); + if (GetAny< bool >((*bbb)(stack))) { + kk++; + } else { + split[k] = 0; } - R1 PtHat2(1./2.); - for (int i=0;iset(pTht, KE(B), B, KE, lab, NN, fk); - pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); + } + + // *mp=mps; + if (verbosity > 1) { + cout << " -- Trunc mesh: Nb of Surface Triangles = " << kk << " label=" << label << endl; + } + + if (pn2o) { + pn2o->resize(kk * ks); + KN< long > &n2o(*pn2o); + int l = 0; + + for (int k = 0; k < Th.nt; ++k) { + if (split[k]) { + for (int i = 0; i < ks; ++i) { + n2o[l++] = k; } + } + } + } + + if (po2n) { + po2n->resize(Th.nt); + KN< long > &o2n(*po2n); + int l = 0; + + for (int k = 0; k < Th.nt; ++k) { + if (split[k]) { + o2n[k] = l; + l += ks; + } else { + o2n[k] = -1; + } + } + } + + *mp = mps; + MeshS *Tht = truncmesh(Th, kkksplit, split, false, label, precis_mesh, orientation, cleanmesh, removeduplicate); + + if (renum) Renumb< MeshS >(Tht); + + MeshS &pTht = *Tht; + map< int, int > mapB, mapT; + for (int i = 0; i < nrB.N( ); i += 2) mapB[nrB[i]] = nrB[i + 1]; + for (int i = 0; i < nrT.N( ); i += 2) mapT[nrT[i]] = nrT[i + 1]; + R2 PtHat(1. / 3., 1. / 3.); + for (int i = 0; i < pTht.nt; i++) { + int lab = ChangeLab(mapT, pTht[i].lab); + if (freg) { + mp->set(pTht, pTht[i](PtHat), PtHat, pTht[i], lab); + pTht.elements[i].lab = GetAny< long >((*freg)(stack)); + if (verbosity > 5) cout << " freg " << pTht[i].lab << endl; + } + } + R1 PtHat2(1. / 2.); + for (int i = 0; i < pTht.nbe; i++) { + const BoundaryEdgeS &K(pTht.be(i)); + int fk, ke = pTht.BoundaryElement(i, fk); + int fkk, kke = pTht.ElementAdj(ke, fkk = fk); + const TriangleS &KE(pTht[ke]); + R2 B = KE.PBord(fk, PtHat2); + int lab = ChangeLab(mapB, K.lab); + if (flab) { + R3 NN = KE.N(fk); + double mes = NN.norme( ); + NN /= mes; + mp->set(pTht, KE(B), B, KE, lab, NN, fk); + pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); } - Add2StackOfPtr2FreeRC(stack, Tht); // 07/2008 FH - - return Tht; + } + Add2StackOfPtr2FreeRC(stack, Tht); // 07/2008 FH + + return Tht; }; // trunc for surface meshL -MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMortar, - const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate); +MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMortar, const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate); struct Op_trunc_meshL : public OneOperator { typedef const MeshL *pmeshL; @@ -5738,41 +5497,30 @@ struct Op_trunc_meshL : public OneOperator { Expression nargs[n_name_param]; Expression getmesh, bbb; long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - KN< long > *arg(int i, Stack stack) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : 0; } - double arg(int i, Stack stack, double a) const {return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { - args.SetNameParam(n_name_param, name_param, nargs); - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + KN< long > *arg(int i, Stack stack) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : 0; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack s) const; }; - E_F0 *code(const basicAC_F0 &args) const { - return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } - Op_trunc_meshL( ) : OneOperator(atype< pmeshL >( ), atype< pmeshL >( ), atype< bool >( )){}; + Op_trunc_meshL( ) : OneOperator(atype< pmeshL >( ), atype< pmeshL >( ), atype< bool >( )) {}; }; basicAC_F0::name_and_type Op_trunc_meshL::Op::name_param[Op_trunc_meshL::Op::n_name_param] = { - {"split", &typeid(long)}, {"label", &typeid(long)}, - {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, - {"renum", &typeid(bool)}, {"precis_mesh", &typeid(double)}, - {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"labels", &typeid(KN_ )}, - {"region", &typeid(KN_ )}, {"flabel", &typeid(long)}, - {"fregion", &typeid(long)} -}; + {"split", &typeid(long)}, {"label", &typeid(long)}, {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, {"renum", &typeid(bool)}, + {"precis_mesh", &typeid(double)}, {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"labels", &typeid(KN_< long >)}, + {"region", &typeid(KN_< long >)}, {"flabel", &typeid(long)}, {"fregion", &typeid(long)}}; + +MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMortar, const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate) { -MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMortar, - const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate) { - typedef typename MeshL::Element T; typedef typename MeshL::BorderElement B; typedef typename MeshL::Vertex V; - - + // computation of number of border elements and vertex without split int nbe = 0; int nbei = 0; @@ -5788,24 +5536,19 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort R3 bmin, bmax; int ntsplit = 0; - - if (verbosity > 2) - cout << "initial mesh, nb vertices: " << Th.nv << ", nb edge elements: " << Th.nt - << ", nb boundary points:" << Th.nbe << endl; - + if (verbosity > 2) cout << "initial mesh, nb vertices: " << Th.nv << ", nb edge elements: " << Th.nt << ", nb boundary points:" << Th.nbe << endl; for (int i = 0; i < Th.nt; i++) { if (split[i]) { ++ntsplit; // number of original edges must be split // number of edges after trunc - nt = nt + (kksplit+1); - hmin = min(hmin, Th[i].mesure()); + nt = nt + (kksplit + 1); + hmin = min(hmin, Th[i].mesure( )); } } double hseuil = (hmin / kksplit) / 1000.; - if (verbosity > 5) - cout << "Before trunc hseuil=" << hseuil << endl; + if (verbosity > 5) cout << "Before trunc hseuil=" << hseuil << endl; /* determination de bmin, bmax et hmin */ @@ -5833,15 +5576,13 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort } } - - // determination des vertex, edges int nvmax = 0; for (int i = 0; i < Th.nt; i++) if (split[i]) { int k = Abs(split[i]); - int r = k + 1; + int r = k + 1; split[i] < 0 ? nvmax += 2 *r - 2 : nvmax += r - 2; } nvmax += nvtrunc; @@ -5874,8 +5615,7 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort vertices[np].lab = Th(i).lab; gtree->Add(vertices[np]); np++; - } - else + } else ffassert(0); } } @@ -5887,10 +5627,8 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort if (split[i]) { const T &K(Th.elements[i]); - for (int ii = 0; ii < T::nv; ii++) - pP[ii] = &K[ii]; - for (int iv = 0; iv < nvsub; iv++) - (R3 &)vertexedgesub[iv] = vertexsub[iv].Bary(pP); + for (int ii = 0; ii < T::nv; ii++) pP[ii] = &K[ii]; + for (int iv = 0; iv < nvsub; iv++) (R3 &)vertexedgesub[iv] = vertexsub[iv].Bary(pP); // new points for (int iv = 0; iv < nvsub; iv++) { @@ -5904,10 +5642,9 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort newindex[iv] = np; gtree->Add(vertices[np]); np++; - } - else + } else newindex[iv] = pvi - vertices; - + ffassert(np <= nvmax); } nv = np; @@ -5921,14 +5658,14 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort } R3 A = vertices[ivt[0]]; R3 B = vertices[ivt[1]]; - edges[itt].set(vertices, ivt, K.lab); //c est des edges + edges[itt].set(vertices, ivt, K.lab); // c est des edges itt++; assert(itt <= nt); } // here copy of original points border - //B *b = new B[nbe]; - //B *bpoints = b; + // B *b = new B[nbe]; + // B *bpoints = b; } } @@ -5938,27 +5675,25 @@ MeshL *truncmesh(const MeshL &Th, const long &kksplit, int *split, bool WithMort delete[] vertexsub; delete[] edgesub; - bool rebuildboundary=false; + bool rebuildboundary = false; MeshL *Tht = new MeshL(nv, itt, 0, vertices, edges, 0, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); - - //Tht->BuildBdElem(); done in the constructor + + // Tht->BuildBdElem(); done in the constructor Tht->BuildGTree( ); - + if (verbosity > 3) { - cout << " - Nb of vertices " << nv << endl; - cout << " - Nb of triangle " << nt << endl; - cout << " - Nb of boundary edges " << nbe << endl; + cout << " - Nb of vertices " << nv << endl; + cout << " - Nb of triangle " << nt << endl; + cout << " - Nb of boundary edges " << nbe << endl; } delete gtree; return Tht; - } - AnyType Op_trunc_meshL::Op::operator( )(Stack stack) const { MeshL *pTh = GetAny< MeshL * >((*getmesh)(stack)); MeshL &Th = *pTh; - if(!pTh) return pTh; + if (!pTh) return pTh; long kkksplit = std::max(1L, arg(0, stack, 1L)); long label = arg(1, stack, 2L); @@ -5971,10 +5706,10 @@ AnyType Op_trunc_meshL::Op::operator( )(Stack stack) const { bool cleanmesh(arg(7, stack, true)); bool removeduplicate(arg(8, stack, false)); - KN nrB = arg(9,stack,kempty); - KN nrT = arg(10,stack,kempty); - Expression flab = nargs[11] ; - Expression freg = nargs[12] ; + KN< long > nrB = arg(9, stack, kempty); + KN< long > nrT = arg(10, stack, kempty); + Expression flab = nargs[11]; + Expression freg = nargs[12]; ffassert(nrT.N( ) % 2 == 0); ffassert(nrB.N( ) % 2 == 0); KN< int > split(Th.nt); @@ -6029,50 +5764,45 @@ AnyType Op_trunc_meshL::Op::operator( )(Stack stack) const { } *mp = mps; - MeshL *Tht = truncmesh(Th, kkksplit, split, false, label, precis_mesh, orientation, cleanmesh, removeduplicate); - - if (renum) - Renumb(Tht); - - MeshL &pTht=*Tht; - map mapB,mapT; - for(int i=0;iset(pTht,pTht[i](PtHat),PtHat,pTht[i],lab); - pTht.elements[i].lab =GetAny( (* freg)(stack)) ; - if(verbosity>5) cout << " freg "<(Tht); + + MeshL &pTht = *Tht; + map< int, int > mapB, mapT; + for (int i = 0; i < nrB.N( ); i += 2) mapB[nrB[i]] = nrB[i + 1]; + for (int i = 0; i < nrT.N( ); i += 2) mapT[nrT[i]] = nrT[i + 1]; + R1 PtHat(1. / 2.); + for (int i = 0; i < pTht.nt; i++) { + int lab = ChangeLab(mapT, pTht[i].lab); + if (freg) { + mp->set(pTht, pTht[i](PtHat), PtHat, pTht[i], lab); + pTht.elements[i].lab = GetAny< long >((*freg)(stack)); + if (verbosity > 5) cout << " freg " << pTht[i].lab << endl; + } } R0 PtHat2; - for (int i=0;iset(pTht, KE(B), B, KE, lab, NN, fk); - pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); - } + for (int i = 0; i < pTht.nbe; i++) { + const BoundaryPointL &K(pTht.be(i)); + int fk, ke = pTht.BoundaryElement(i, fk); + int fkk, kke = pTht.ElementAdj(ke, fkk = fk); + const EdgeL &KE(pTht[ke]); + R1 B = KE.PBord(fk, PtHat2); + int lab = ChangeLab(mapB, K.lab); + if (flab) { + R3 NN = KE.N(fk); + double mes = NN.norme( ); + NN /= mes; + mp->set(pTht, KE(B), B, KE, lab, NN, fk); + pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); } + } Add2StackOfPtr2FreeRC(stack, Tht); // 07/2008 FH return Tht; }; - - // trunc volume mesh 3D Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, const int newbelabel); @@ -6087,31 +5817,22 @@ struct Op_trunc_mesh3 : public OneOperator { long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } KN< long > *arg(int i, Stack stack) const { return nargs[i] ? GetAny< KN< long > * >((*nargs[i])(stack)) : 0; } - double arg(int i, Stack stack, double a) const {return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { - args.SetNameParam(n_name_param, name_param, nargs); - } + Op(const basicAC_F0 &args, Expression t, Expression b) : getmesh(t), bbb(b) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack s) const; }; - E_F0 *code(const basicAC_F0 &args) const { - return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } - Op_trunc_mesh3( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( ), atype< bool >( )){}; + Op_trunc_mesh3( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( ), atype< bool >( )) {}; }; basicAC_F0::name_and_type Op_trunc_mesh3::Op::name_param[Op_trunc_mesh3::Op::n_name_param] = { - {"split", &typeid(long)}, {"label", &typeid(long)}, - {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, // ajout FH pour P. Jovilet jan 2014 - {"renum", &typeid(bool)}, {"precis_mesh", &typeid(double)}, - {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, {"labels", &typeid(KN_ )}, - {"region", &typeid(KN_ )}, {"flabel", &typeid(long)}, - {"fregion", &typeid(long)} -}; - + {"split", &typeid(long)}, {"label", &typeid(long)}, {"new2old", &typeid(KN< long > *)}, {"old2new", &typeid(KN< long > *)}, // ajout FH pour P. Jovilet jan 2014 + {"renum", &typeid(bool)}, {"precis_mesh", &typeid(double)}, {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, + {"labels", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"flabel", &typeid(long)}, {"fregion", &typeid(long)}}; + Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, const int newbelabel, double precis_mesh, long orientation, bool cleanmesh, bool removeduplicate) { static const int FaceTriangle[4] = {3, 0, 1, 2}; //= {{3,2,1}, {0,2,3},{ 3,1,0},{ 0,1,2}} @@ -6179,8 +5900,7 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons nface = nbeee + nbfi / 2; double hseuil = (hmin / kksplit) / 1000.; if (verbosity > 5) { - cout << " number of not intern boundary faces = " << nbeee << ", all faces = " << nbe - << ", hseuil=" << hseuil << endl; + cout << " number of not intern boundary faces = " << nbeee << ", all faces = " << nbe << ", hseuil=" << hseuil << endl; } /* determination de bmin, bmax et hmin */ @@ -6230,8 +5950,7 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons } if (verbosity > 10) { - cout << " -- nvertex " << nvtrunc << ", nedges = " << nedge << ", nfaces = " << nface - << " ntet =" << ntsplit << endl + cout << " -- nvertex " << nvtrunc << ", nedges = " << nedge << ", nfaces = " << nface << " ntet =" << ntsplit << endl << " -- Euler/Poincare constante = " << nvtrunc - nedge + nface - ntsplit << endl; } @@ -6255,8 +5974,7 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons int ntnosplit = nt / kksplit3; int nbenosplit = nbe / kksplit2 - nbei; // warning true bounding => remove internal border int nfacenosplit = (4 * ntnosplit + nbenosplit) / 2; - nv = ntnosplit * (nvsub - 4 * ((kksplit + 1) * (kksplit + 2) / 2 - 3 * (kksplit - 1) - 3) - - 6 * (kksplit - 1) - 4); + nv = ntnosplit * (nvsub - 4 * ((kksplit + 1) * (kksplit + 2) / 2 - 3 * (kksplit - 1) - 3) - 6 * (kksplit - 1) - 4); if (verbosity > 100) { cout << " 1) nv= " << nv << endl; } @@ -6300,12 +6018,11 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons gtree->Add(v[np]); np++; break; - } else if(j == 2) { + } else if (j == 2) { ffassert(0); } else { heps /= 10.0; - if(verbosity > 1) - cout << " Problem with vertex #" << i << ", need to refine h to " << heps << endl; + if (verbosity > 1) cout << " Problem with vertex #" << i << ", need to refine h to " << heps << endl; } } } @@ -6433,12 +6150,9 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons double alpha = vertex2Dsub[iv].x; double beta = vertex2Dsub[iv].y; - vertextrisub[iv].x = (1 - alpha - beta) * Th.vertices[ivv[0]].x + - alpha * Th.vertices[ivv[1]].x + beta * Th.vertices[ivv[2]].x; - vertextrisub[iv].y = (1 - alpha - beta) * Th.vertices[ivv[0]].y + - alpha * Th.vertices[ivv[1]].y + beta * Th.vertices[ivv[2]].y; - vertextrisub[iv].z = (1 - alpha - beta) * Th.vertices[ivv[0]].z + - alpha * Th.vertices[ivv[1]].z + beta * Th.vertices[ivv[2]].z; + vertextrisub[iv].x = (1 - alpha - beta) * Th.vertices[ivv[0]].x + alpha * Th.vertices[ivv[1]].x + beta * Th.vertices[ivv[2]].x; + vertextrisub[iv].y = (1 - alpha - beta) * Th.vertices[ivv[0]].y + alpha * Th.vertices[ivv[1]].y + beta * Th.vertices[ivv[2]].y; + vertextrisub[iv].z = (1 - alpha - beta) * Th.vertices[ivv[0]].z + alpha * Th.vertices[ivv[1]].z + beta * Th.vertices[ivv[2]].z; } for (int iv = 0; iv < nv2Dsub; iv++) { @@ -6487,7 +6201,7 @@ Mesh3 *truncmesh(const Mesh3 &Th, const long &kksplit, int *split, bool kk, cons ffassert(itt == nt); // delete gtree; - bool rebuildboundary=false; + bool rebuildboundary = false; Mesh3 *Tht = new Mesh3(nv, nt, nbe, v, t, b, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); Tht->BuildGTree( ); // Add JM. Oct 2010 delete gtree; @@ -6579,8 +6293,7 @@ void Renumb(Fem2D::Mesh3 *&pTh) { Tet *tt = t; for (int i = 0; i < nbt; i++) { - int i0 = perm_inv[Th(i, 0)], i1 = perm_inv[Th(i, 1)], i2 = perm_inv[Th(i, 2)], - i3 = perm_inv[Th(i, 3)]; + int i0 = perm_inv[Th(i, 0)], i1 = perm_inv[Th(i, 1)], i2 = perm_inv[Th(i, 2)], i3 = perm_inv[Th(i, 3)]; int ivt[4] = {i0, i1, i2, i3}; (*tt++).set(v, ivt, Th[i].lab); } @@ -6623,14 +6336,14 @@ AnyType Op_trunc_mesh3::Op::operator( )(Stack stack) const { long orientation(arg(6, stack, 1L)); bool cleanmesh(arg(7, stack, true)); bool removeduplicate(arg(8, stack, false)); - KN kempty; - KN nrB = arg(9,stack,kempty); - KN nrT = arg(10,stack,kempty); - Expression flab = nargs[11] ; - Expression freg = nargs[12] ; + KN< long > kempty; + KN< long > nrB = arg(9, stack, kempty); + KN< long > nrT = arg(10, stack, kempty); + Expression flab = nargs[11]; + Expression freg = nargs[12]; ffassert(nrT.N( ) % 2 == 0); ffassert(nrB.N( ) % 2 == 0); - + KN< int > split(Th.nt); split = kkksplit; MeshPoint *mp = MeshPointStack(stack), mps = *mp; @@ -6684,51 +6397,40 @@ AnyType Op_trunc_mesh3::Op::operator( )(Stack stack) const { } } - if (renum) - Renumb(Tht); - - - if (renum && Tht->meshS) - Renumb(Tht->meshS); - - - - Mesh3 &pTht=*Tht; - map mapB,mapT; - for(int i=0;iset(pTht,pTht[i](PtHat),PtHat,pTht[i],lab); - pTht.elements[i].lab =GetAny( (* freg)(stack)) ; - if(verbosity>5) cout << " freg "<set(pTht, KE(B), B, KE, lab, NN, fk); - pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); - } + if (renum) Renumb(Tht); + + if (renum && Tht->meshS) Renumb(Tht->meshS); + + Mesh3 &pTht = *Tht; + map< int, int > mapB, mapT; + for (int i = 0; i < nrB.N( ); i += 2) mapB[nrB[i]] = nrB[i + 1]; + for (int i = 0; i < nrT.N( ); i += 2) mapT[nrT[i]] = nrT[i + 1]; + R3 PtHat(1. / 4., 1. / 4., 1. / 4.); + for (int i = 0; i < pTht.nt; i++) { + int lab = ChangeLab(mapT, pTht[i].lab); + if (freg) { + mp->set(pTht, pTht[i](PtHat), PtHat, pTht[i], lab); + pTht.elements[i].lab = GetAny< long >((*freg)(stack)); + if (verbosity > 5) cout << " freg " << pTht[i].lab << endl; + } + } + R2 PtHat2(1. / 3., 1. / 3.); + for (int i = 0; i < pTht.nbe; i++) { + const Triangle3 &K(pTht.be(i)); + int fk, ke = pTht.BoundaryElement(i, fk); + int fkk, kke = pTht.ElementAdj(ke, fkk = fk); + const Tet &KE(pTht[ke]); + R3 B = KE.PBord(fk, PtHat2); + int lab = ChangeLab(mapB, K.lab); + if (flab) { + R3 NN = KE.N(fk); + double mes = NN.norme( ); + NN /= mes; + mp->set(pTht, KE(B), B, KE, lab, NN, fk); + pTht.borderelements[i].lab = GetAny< long >((*flab)(stack)); } - - - - - + } + Add2StackOfPtr2FreeRC(stack, Tht); // 07/2008 FH *mp = mps; @@ -6750,9 +6452,7 @@ class ExtractMesh_Op : public E_F0mps { static const int n_name_param = 10; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN_< long > arg(int i, Stack stack, KN_< long > a) const { - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } + KN_< long > arg(int i, Stack stack, KN_< long > a) const { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } KN_< long > arg(int i, int j, Stack stack, KN_< long > a) const { if (nargs[i]) { @@ -6762,18 +6462,12 @@ class ExtractMesh_Op : public E_F0mps { } } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - public: ExtractMesh_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { if (verbosity > 1) cout << "construction par ExtractMesh_Op" << endl; @@ -6793,32 +6487,14 @@ class ExtractMesh_Op : public E_F0mps { // instance arguments for mesh3 template<> basicAC_F0::name_and_type ExtractMesh_Op< Mesh3, MeshS >::name_param[] = { - {"refface", &typeid(KN_< long >)}, - {"reftet", &typeid(KN_< long >)}, - {"label", &typeid(KN_< long >)}, - {"region", &typeid(KN_< long >)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, - {"labeledBoundary", &typeid(bool)}, - {"angle", &typeid(double)} -}; + {"refface", &typeid(KN_< long >)}, {"reftet", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, {"labeledBoundary", &typeid(bool)}, {"angle", &typeid(double)}}; // instance arguments for meshS template<> basicAC_F0::name_and_type ExtractMesh_Op< MeshS, MeshL >::name_param[] = { - {"refedge", &typeid(KN_< long >)}, - {"reftri", &typeid(KN_< long >)}, - {"label", &typeid(KN_< long >)}, - {"region", &typeid(KN_< long >)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, - {"labeledBoundary", &typeid(bool)}, - {"angle", &typeid(double)} -}; + {"refedge", &typeid(KN_< long >)}, {"reftri", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"region", &typeid(KN_< long >)}, {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, {"labeledBoundary", &typeid(bool)}, {"angle", &typeid(double)}}; template< class MMesh, class MMeshO > class ExtractMesh : public OneOperator { @@ -6827,9 +6503,7 @@ class ExtractMesh : public OneOperator { typedef const MMeshO *ppmeshO; ExtractMesh( ) : OneOperator(atype< ppmeshO >( ), atype< ppmesh >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new ExtractMesh_Op< MMesh, MMeshO >(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new ExtractMesh_Op< MMesh, MMeshO >(args, t[0]->CastTo(args[0])); } }; template< class MMesh, class MMeshO > @@ -6855,39 +6529,35 @@ AnyType ExtractMesh_Op< MMesh, MMeshO >::operator( )(Stack stack) const { KN< long > labelelement(arg(1, 3, stack, zzempty)); long cleanmesh(arg(4, stack, true)); long removeduplicate(arg(5, stack, false)); - bool rebuildboundary=false;//(arg(7, stack, false)); + bool rebuildboundary = false; //(arg(7, stack, false)); double precis_mesh(arg(6, stack, 1e-7)); long orientation(arg(7, stack, 1L)); - bool labeledBoundary(arg(8, stack,false)); - double angle(arg(9, stack, 9.*atan(1.)/9.)); - + bool labeledBoundary(arg(8, stack, false)); + double angle(arg(9, stack, 9. * atan(1.) / 9.)); + // a trier les tableaux d'entier int nv = 0, nt = 0, ns = 0; - - if(!labelface.N( ) && verbosity) - cout << " empty list label, extract all boundaries" << endl; - + + if (!labelface.N( ) && verbosity) cout << " empty list label, extract all boundaries" << endl; + if (verbosity > 9) { cout << " labelface.N() " << labelface.N( ) << endl; for (int ii = 0; ii < labelface.N( ); ii++) cout << ii << " " << labelface[ii] << endl; } - - map slf; - for (int ii = 0; ii < labelface.N( ); ii++) - slf[labelface[ii]]=ii; + + map< int, int > slf; + for (int ii = 0; ii < labelface.N( ); ii++) slf[labelface[ii]] = ii; KN< int > takevertex(Th.nv, -1); KN< int > takebe(Th.nbe, -1); int nbeLab = 0; - - for (int ibe = 0; ibe < Th.nbe; ++ibe) { const B &K(Th.be(ibe)); - if(labelface.N()) { - map::iterator mi =slf.find(K.lab) ; - if( mi != slf.end()) { + if (labelface.N( )) { + map< int, int >::iterator mi = slf.find(K.lab); + if (mi != slf.end( )) { int ii = mi->second; nbeLab++; takebe[ibe] = 1; @@ -6897,16 +6567,15 @@ AnyType ExtractMesh_Op< MMesh, MMeshO >::operator( )(Stack stack) const { nv++; } } - } - else { - nbeLab++; - takebe[ibe] = 1; - for (int jj = 0; jj < B::nv; ++jj) { - if (takevertex[Th.operator( )(K[jj])] != -1) continue; - takevertex[Th.operator( )(K[jj])] = nv; - nv++; - } + } else { + nbeLab++; + takebe[ibe] = 1; + for (int jj = 0; jj < B::nv; ++jj) { + if (takevertex[Th.operator( )(K[jj])] != -1) continue; + takevertex[Th.operator( )(K[jj])] = nv; + nv++; } + } } ns = nbeLab; @@ -6953,153 +6622,123 @@ AnyType ExtractMesh_Op< MMesh, MMeshO >::operator( )(Stack stack) const { Add2StackOfPtr2FreeRC(stack, pThnew); return pThnew; - } +class ExtractMeshLfromMesh_Op : public E_F0mps { + public: + Expression eTh; + static const int n_name_param = 8; // + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param], xx, yy, zz; - - + KN_< long > arg(int i, int ii, Stack stack, KN_< long > a) const { + ffassert(!(nargs[i] && nargs[ii])); + i = nargs[i] ? i : ii; + return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; + } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } -class ExtractMeshLfromMesh_Op : public E_F0mps { -public: - Expression eTh; - static const int n_name_param = 8; // - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param], xx, yy, zz; - - KN_< long > arg(int i, int ii, Stack stack, KN_< long > a) const { - ffassert(!(nargs[i] && nargs[ii])); - i = nargs[i] ? i : ii; - return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - - long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - - bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - -public: - ExtractMeshLfromMesh_Op(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, - Expression zzz = 0) - : eTh(tth),xx(xxx), yy(yyy), zz(zzz) { - - args.SetNameParam(n_name_param, name_param, nargs); - const E_Array *a1 = 0; - if (nargs[0]) - a1 = dynamic_cast< const E_Array * >(nargs[0]); - - if (a1) { - xx = to< double >((*a1)[0]); - if(a1->size()>1) yy = to< double >((*a1)[1]); - if(a1->size()>2) zz = to< double >((*a1)[2]); - } -} + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + + public: + ExtractMeshLfromMesh_Op(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, Expression zzz = 0) : eTh(tth), xx(xxx), yy(yyy), zz(zzz) { + + args.SetNameParam(n_name_param, name_param, nargs); + const E_Array *a1 = 0; + if (nargs[0]) a1 = dynamic_cast< const E_Array * >(nargs[0]); -AnyType operator( )(Stack stack) const; + if (a1) { + xx = to< double >((*a1)[0]); + if (a1->size( ) > 1) yy = to< double >((*a1)[1]); + if (a1->size( ) > 2) zz = to< double >((*a1)[2]); + } + } + + AnyType operator( )(Stack stack) const; }; - - -basicAC_F0::name_and_type ExtractMeshLfromMesh_Op::name_param[] = { -{"transfo", &typeid(E_Array)}, // 0 -{"refedge", &typeid(KN_< long >)}, -{"label", &typeid(KN_< long >)}, -{"cleanmesh", &typeid(bool)}, -{"removeduplicate", &typeid(bool)}, -{"precismesh", &typeid(double)}, -{"orientation", &typeid(long)}, -{"ridgeangle", &typeid(double)} - - + +basicAC_F0::name_and_type ExtractMeshLfromMesh_Op::name_param[] = {{"transfo", &typeid(E_Array)}, // 0 + {"refedge", &typeid(KN_< long >)}, {"label", &typeid(KN_< long >)}, {"cleanmesh", &typeid(bool)}, + {"removeduplicate", &typeid(bool)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, + {"ridgeangle", &typeid(double)} + }; - - + class ExtractMeshLfromMesh : public OneOperator { -public: - int cas; - - ExtractMeshLfromMesh( ) : OneOperator(atype< pmeshL >( ), atype< pmesh >( )) , cas(0) {} - - ExtractMeshLfromMesh(int) : OneOperator(atype< pmeshL >( ), atype< pmesh >( ) , atype< E_Array >( )), cas(1) {} - - E_F0 *code(const basicAC_F0 &args) const { - if (cas == 0) { - return new ExtractMeshLfromMesh_Op(args, t[0]->CastTo(args[0])); - } else if (cas == 1) { - const E_Array *a = dynamic_cast< const E_Array * >(args[1].LeftValue( )); - ffassert(a); - Expression X = to< double >((*a)[0]); - Expression Y=0 ; if(a->size( )>1) Y=to< double >((*a)[1]); - Expression Z=0 ; if(a->size( )>2) Z= to< double >((*a)[2]); - return new ExtractMeshLfromMesh_Op(args, t[0]->CastTo(args[0]), X, Y, Z); - } - CompileError("ExtractMeshLfromMesh case unknown "); - return 0; - } + public: + int cas; + + ExtractMeshLfromMesh( ) : OneOperator(atype< pmeshL >( ), atype< pmesh >( )), cas(0) {} + + ExtractMeshLfromMesh(int) : OneOperator(atype< pmeshL >( ), atype< pmesh >( ), atype< E_Array >( )), cas(1) {} + + E_F0 *code(const basicAC_F0 &args) const { + if (cas == 0) { + return new ExtractMeshLfromMesh_Op(args, t[0]->CastTo(args[0])); + } else if (cas == 1) { + const E_Array *a = dynamic_cast< const E_Array * >(args[1].LeftValue( )); + ffassert(a); + Expression X = to< double >((*a)[0]); + Expression Y = 0; + if (a->size( ) > 1) Y = to< double >((*a)[1]); + Expression Z = 0; + if (a->size( ) > 2) Z = to< double >((*a)[2]); + return new ExtractMeshLfromMesh_Op(args, t[0]->CastTo(args[0]), X, Y, Z); + } + CompileError("ExtractMeshLfromMesh case unknown "); + return 0; + } }; - AnyType ExtractMeshLfromMesh_Op::operator( )(Stack stack) const { - MeshPoint *mp(MeshPointStack(stack)), mps = *mp; - Mesh *pTh = GetAny< Mesh * >((*eTh)(stack)); - Mesh &Th = *pTh; - MeshPoint *mpp(MeshPointStack(stack)); - ffassert(pTh); - - typedef typename Mesh::Element T; - typedef typename Mesh::BorderElement B; - typedef typename Mesh::Vertex V; - - typedef typename MeshL::Element TL; - typedef typename MeshL::BorderElement BL; - typedef typename MeshL::Vertex VL; - - int nbv = Th.nv; // nombre de sommet - int nbe = Th.neb; - - KN< long > zzempty(0); - KN< long > labelface(arg(1, 2, stack, zzempty)); - long cleanmesh(arg(3, stack, true)); - long removeduplicate(arg(4, stack, false)); - bool rebuildboundary=false;//(arg(7, stack, false)); - double precis_mesh(arg(5, stack, 1e-7)); - long orientation(arg(6, stack, 1L)); - double ridgeangle(arg(7, stack, Pi/4.)); - - if(!labelface.N( ) && verbosity) - cout << " empty list label, extract all boundaries" << endl; - - - // a trier les tableaux d'entier - map slf; - for (int ii = 0; ii < labelface.N( ); ii++) - slf[labelface[ii]]=ii; - if (verbosity > 9) { - cout << " labelface.N() " << labelface.N( ) << endl; - for (int ii = 0; ii < labelface.N( ); ii++) - cout << ii << " " << labelface[ii] << endl; - } - - - KN< int > takevertex(Th.nv, -1); - KN< int > takebe(Th.neb, -1); - - int nbeLab = 0, nvL=0; - for (int ibe = 0; ibe < Th.neb; ++ibe) { - const B &K(Th.be(ibe)); - if(labelface.N()) { - map::iterator mi =slf.find(K.lab) ; - if( mi != slf.end()) { - int ii = mi->second; - nbeLab++; - takebe[ibe] = 1; - for (int jj = 0; jj < 2; ++jj) { - if (takevertex[Th.operator( )(K[jj])] != -1) continue; - takevertex[Th.operator( )(K[jj])] = nvL; - nvL++; - } - } - } - else { + MeshPoint *mp(MeshPointStack(stack)), mps = *mp; + Mesh *pTh = GetAny< Mesh * >((*eTh)(stack)); + Mesh &Th = *pTh; + MeshPoint *mpp(MeshPointStack(stack)); + ffassert(pTh); + + typedef typename Mesh::Element T; + typedef typename Mesh::BorderElement B; + typedef typename Mesh::Vertex V; + + typedef typename MeshL::Element TL; + typedef typename MeshL::BorderElement BL; + typedef typename MeshL::Vertex VL; + + int nbv = Th.nv; // nombre de sommet + int nbe = Th.neb; + + KN< long > zzempty(0); + KN< long > labelface(arg(1, 2, stack, zzempty)); + long cleanmesh(arg(3, stack, true)); + long removeduplicate(arg(4, stack, false)); + bool rebuildboundary = false; //(arg(7, stack, false)); + double precis_mesh(arg(5, stack, 1e-7)); + long orientation(arg(6, stack, 1L)); + double ridgeangle(arg(7, stack, Pi / 4.)); + + if (!labelface.N( ) && verbosity) cout << " empty list label, extract all boundaries" << endl; + + // a trier les tableaux d'entier + map< int, int > slf; + for (int ii = 0; ii < labelface.N( ); ii++) slf[labelface[ii]] = ii; + if (verbosity > 9) { + cout << " labelface.N() " << labelface.N( ) << endl; + for (int ii = 0; ii < labelface.N( ); ii++) cout << ii << " " << labelface[ii] << endl; + } + + KN< int > takevertex(Th.nv, -1); + KN< int > takebe(Th.neb, -1); + + int nbeLab = 0, nvL = 0; + for (int ibe = 0; ibe < Th.neb; ++ibe) { + const B &K(Th.be(ibe)); + if (labelface.N( )) { + map< int, int >::iterator mi = slf.find(K.lab); + if (mi != slf.end( )) { + int ii = mi->second; nbeLab++; takebe[ibe] = 1; for (int jj = 0; jj < 2; ++jj) { @@ -7108,55 +6747,65 @@ AnyType ExtractMeshLfromMesh_Op::operator( )(Stack stack) const { nvL++; } } - } - VL *v = new VL[nvL]; - TL *b = new TL[nbeLab]; - TL *bb = b; - - for (int ii = 0; ii < Th.nv; ++ii) { - if (takevertex[ii] == -1) { - continue; - } - int iv = takevertex[ii]; - - mpp->set(Th.vertices[ii].x, Th.vertices[ii].y); - if (xx) v[iv].x = GetAny< double >((*xx)(stack)); - else v[iv].x = mpp->P.x; - if (yy) v[iv].y = GetAny< double >((*yy)(stack)); - else v[iv].y = mpp->P.y; - if (zz) v[iv].z = GetAny< double >((*zz)(stack)); - else v[iv].z = 0.; - - v[iv].lab = Th.vertices[ii].lab; - } - - for (int ibe = 0; ibe < Th.neb; ibe++) { - if (takebe[ibe] != 1) continue; - const B &K(Th.be(ibe)); - int ivv[2]; - for (int jj = 0; jj < 2; jj++) ivv[jj] = takevertex[Th.operator( )(K[jj])]; - int ie, i = Th.BoundaryElement(ibe, ie); - if (&(Th[i].Edge(0,ie)) != &(K[0])) - swap(ivv[0],ivv[1]); - (bb++)->set(v, ivv, K.lab); - } - ffassert(nvL>0); - - // build the moved mesh and apply option - MeshL *T_Th = new MeshL(nvL, nbeLab, 0, v, b, 0, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh,false,ridgeangle); - - - T_Th->BuildGTree( ); - Add2StackOfPtr2FreeRC(stack, T_Th); - *mp = mps; - return T_Th; - -} + } else { + nbeLab++; + takebe[ibe] = 1; + for (int jj = 0; jj < 2; ++jj) { + if (takevertex[Th.operator( )(K[jj])] != -1) continue; + takevertex[Th.operator( )(K[jj])] = nvL; + nvL++; + } + } + } + VL *v = new VL[nvL]; + TL *b = new TL[nbeLab]; + TL *bb = b; + + for (int ii = 0; ii < Th.nv; ++ii) { + if (takevertex[ii] == -1) { + continue; + } + int iv = takevertex[ii]; + + mpp->set(Th.vertices[ii].x, Th.vertices[ii].y); + if (xx) + v[iv].x = GetAny< double >((*xx)(stack)); + else + v[iv].x = mpp->P.x; + if (yy) + v[iv].y = GetAny< double >((*yy)(stack)); + else + v[iv].y = mpp->P.y; + if (zz) + v[iv].z = GetAny< double >((*zz)(stack)); + else + v[iv].z = 0.; + + v[iv].lab = Th.vertices[ii].lab; + } + + for (int ibe = 0; ibe < Th.neb; ibe++) { + if (takebe[ibe] != 1) continue; + const B &K(Th.be(ibe)); + int ivv[2]; + for (int jj = 0; jj < 2; jj++) ivv[jj] = takevertex[Th.operator( )(K[jj])]; + int ie, i = Th.BoundaryElement(ibe, ie); + if (&(Th[i].Edge(0, ie)) != &(K[0])) swap(ivv[0], ivv[1]); + (bb++)->set(v, ivv, K.lab); + } + ffassert(nvL > 0); + // build the moved mesh and apply option + MeshL *T_Th = new MeshL(nvL, nbeLab, 0, v, b, 0, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh, false, ridgeangle); + + T_Th->BuildGTree( ); + Add2StackOfPtr2FreeRC(stack, T_Th); + *mp = mps; + return T_Th; +} -template -bool AddLayers(MT const *const &pTh, KN< double > *const &psupp, long const &nlayer, - KN< double > *const &pphi) { +template< class MT > +bool AddLayers(MT const *const &pTh, KN< double > *const &psupp, long const &nlayer, KN< double > *const &pphi) { ffassert(pTh && psupp && pphi); const int nve = MT::Element::nv; const MT &Th = *pTh; @@ -7177,9 +6826,8 @@ bool AddLayers(MT const *const &pTh, KN< double > *const &psupp, long const &nla u = 0.; for (int k = 0; k < nt; ++k) { - if(s[k] > 0.0) - for (int i = 0; i < nve; ++i) - u[Th(k, i)] = 1.0; + if (s[k] > 0.0) + for (int i = 0; i < nve; ++i) u[Th(k, i)] = 1.0; } phi += u; @@ -7188,8 +6836,7 @@ bool AddLayers(MT const *const &pTh, KN< double > *const &psupp, long const &nla for (int k = 0; k < nt; ++k) { for (int i = 0; i < nve; ++i) { - if(u[Th(k,i)] > 0.0) - s[k] = 1.0; + if (u[Th(k, i)] > 0.0) s[k] = 1.0; } } @@ -7202,9 +6849,6 @@ bool AddLayers(MT const *const &pTh, KN< double > *const &psupp, long const &nla // supp =s; return true; } - - - Mesh3 *GluMesh3tab(KN< pmesh3 > *const &tab, long const &lab_delete, bool const &legacy) { int flagsurfaceall = 0; @@ -7233,8 +6877,7 @@ Mesh3 *GluMesh3tab(KN< pmesh3 > *const &tab, long const &lab_delete, bool const const Mesh3 &Th3(*tab->operator[](i)); th0 = &Th3; if (verbosity > 4) { - cout << " determination of hmin : GluMesh3D + " << Th3.nv << " " << Th3.nt << " " << Th3.nbe - << endl; + cout << " determination of hmin : GluMesh3D + " << Th3.nv << " " << Th3.nt << " " << Th3.nbe << endl; } nbt += Th3.nt; nbvx += Th3.nv; @@ -7362,20 +7005,19 @@ Mesh3 *GluMesh3tab(KN< pmesh3 > *const &tab, long const &lab_delete, bool const cout << " Nb of glu3D point " << nbvx - nbv; cout << " Nb of glu3D Boundary faces " << nbex - nbe << endl; } - } - else { - int** idx; - idx = new int*[tab->n + 1]; + } else { + int **idx; + idx = new int *[tab->n + 1]; *idx = new int[nbvx]; std::fill_n(*idx, nbvx, -1); nbvx = 0; for (int i = 0; i < tab->n; i++) { - const Mesh3& Th3(*tab->operator[](i)); - idx[i+1] = idx[i] + Th3.nv; + const Mesh3 &Th3(*tab->operator[](i)); + idx[i + 1] = idx[i] + Th3.nv; for (int k = 0; k < Th3.nbe; k++) { - const Triangle3& K(Th3.be(k)); + const Triangle3 &K(Th3.be(k)); for (int p = 0; p < 3; p++) { - const int iv = Th3.operator()(K[p]); + const int iv = Th3.operator( )(K[p]); const Vertex3 &vi(Th3.vertices[iv]); Vertex3 *pvi = gtree->ToClose(vi, hseuil); if (!pvi) { @@ -7385,14 +7027,15 @@ Mesh3 *GluMesh3tab(KN< pmesh3 > *const &tab, long const &lab_delete, bool const v[nbv].lab = vi.lab; gtree->Add(v[nbv]); idx[i][iv] = nbv++; - } else idx[i][iv] = pvi - v; + } else + idx[i][iv] = pvi - v; } } } - std::unordered_set> boundary; + std::unordered_set< std::array< int, 3 > > boundary; boundary.reserve(nbex); for (int i = 0; i < tab->n; i++) { - const Mesh3& Th3(*tab->operator[](i)); + const Mesh3 &Th3(*tab->operator[](i)); for (int j = 0; j < Th3.nv; j++) { if (idx[i][j] == -1) { const Vertex3 &vi(Th3.vertices[j]); @@ -7405,20 +7048,20 @@ Mesh3 *GluMesh3tab(KN< pmesh3 > *const &tab, long const &lab_delete, bool const } } for (int k = 0; k < Th3.nt; k++) { - const Tet& K(Th3.elements[k]); + const Tet &K(Th3.elements[k]); int iv[4]; - for (int iea = 0; iea < 4; iea++) iv[iea] = idx[i][Th3.operator()(K[iea])]; + for (int iea = 0; iea < 4; iea++) iv[iea] = idx[i][Th3.operator( )(K[iea])]; (t++)->set(v, iv, K.lab); } for (int k = 0; k < Th3.nbe; k++) { - const Triangle3& K(Th3.be(k)); + const Triangle3 &K(Th3.be(k)); if (K.lab != lab_delete) { int iv[3]; - for (int p = 0; p < 3; p++) iv[p] = idx[i][Th3.operator()(K[p])]; - std::array sort; - std::copy_n(iv, 3, sort.begin()); - std::sort(sort.begin(), sort.end()); - if(boundary.find(sort) == boundary.end()) { + for (int p = 0; p < 3; p++) iv[p] = idx[i][Th3.operator( )(K[p])]; + std::array< int, 3 > sort; + std::copy_n(iv, 3, sort.begin( )); + std::sort(sort.begin( ), sort.end( )); + if (boundary.find(sort) == boundary.end( )) { (bb++)->set(v, iv, K.lab); boundary.insert(sort); } @@ -7447,61 +7090,48 @@ struct Op_GluMesh3tab : public OneOperator { static const int n_name_param = 2; Expression nargs[n_name_param]; Expression getmeshtab; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - Op(const basicAC_F0 &args, Expression t) : getmeshtab(t) { - args.SetNameParam(n_name_param, name_param, nargs); - } + Op(const basicAC_F0 &args, Expression t) : getmeshtab(t) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack s) const; }; E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0])); } - Op_GluMesh3tab( ) : OneOperator(atype< const pmesh3 >( ), atype< KN< pmesh3 > * >( )){}; + Op_GluMesh3tab( ) : OneOperator(atype< const pmesh3 >( ), atype< KN< pmesh3 > * >( )) {}; }; -template +template< class MeshT > struct Op_GluMeshTtab : public OneOperator { typedef const MeshT *pmeshT; class Op : public E_F0mps { public: - //static basicAC_F0::name_and_type name_param[]; + // static basicAC_F0::name_and_type name_param[]; static const int n_name_param = 0; - Expression nargs[1];// use + Expression nargs[1]; // use Expression getmeshtab; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - Op(const basicAC_F0 &args, Expression t) : getmeshtab(t) { - args.SetNameParam(n_name_param); - } + Op(const basicAC_F0 &args, Expression t) : getmeshtab(t) { args.SetNameParam(n_name_param); } AnyType operator( )(Stack s) const { - KN< const MeshT * > *tab = GetAny< KN< const MeshT * > * >((*getmeshtab)(s)); - listMeshT lst(s,tab); - MeshT *Tht = GluMesh(lst); - Add2StackOfPtr2FreeRC(s, Tht); - return Tht; - } + KN< const MeshT * > *tab = GetAny< KN< const MeshT * > * >((*getmeshtab)(s)); + listMeshT< MeshT > lst(s, tab); + MeshT *Tht = GluMesh(lst); + Add2StackOfPtr2FreeRC(s, Tht); + return Tht; + } }; E_F0 *code(const basicAC_F0 &args) const { return new Op(args, t[0]->CastTo(args[0])); } - Op_GluMeshTtab( ) : OneOperator(atype< const pmeshT >( ), atype< KN< pmeshT > * >( )){}; + Op_GluMeshTtab( ) : OneOperator(atype< const pmeshT >( ), atype< KN< pmeshT > * >( )) {}; }; - -basicAC_F0::name_and_type Op_GluMesh3tab::Op::name_param[Op_GluMesh3tab::Op::n_name_param] = { - {"labtodel", &typeid(long)}, - {"legacy", &typeid(bool)}}; +basicAC_F0::name_and_type Op_GluMesh3tab::Op::name_param[Op_GluMesh3tab::Op::n_name_param] = {{"labtodel", &typeid(long)}, {"legacy", &typeid(bool)}}; AnyType Op_GluMesh3tab::Op::operator( )(Stack stack) const { KN< const Mesh3 * > *tab = GetAny< KN< const Mesh3 * > * >((*getmeshtab)(stack)); long labtodel = arg(0, stack, LONG_MIN); @@ -7512,8 +7142,6 @@ AnyType Op_GluMesh3tab::Op::operator( )(Stack stack) const { return Tht; } - - // return nbc the number of conex componants long BuildBoundaryElementAdj(const MeshS &Th, bool check = 0, KN< long > *pborder = 0) { typedef typename MeshS::Element T; @@ -7552,9 +7180,8 @@ long BuildBoundaryElementAdj(const MeshS &Th, bool check = 0, KN< long > *pborde int firstVertex = Th(K[T::nvadj[i][0]]) + 1; int secondVertex = Th(K[T::nvadj[i][1]]) + 1; if (err < 100 && check) { - cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex - << ", is oriented in the same direction in element " << k + 1 << " and in element " - << 1 + (p->v / T::nea) << endl; + cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex << ", is oriented in the same direction in element " << k + 1 << " and in element " << 1 + (p->v / T::nea) + << endl; } err++; @@ -7565,9 +7192,8 @@ long BuildBoundaryElementAdj(const MeshS &Th, bool check = 0, KN< long > *pborde int firstVertex = Th(K[T::nvadj[i][0]]) + 1; int secondVertex = Th(K[T::nvadj[i][1]]) + 1; if (err3 < 100 && check) { - cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex - << "belong to the three border elements ::" << 1 + (p->v) / T::nea << ", " << k + 1 - << " and " << 1 + (abs(TheElementAdjacencesLink[p->v]) - 1) / T::nea << endl; + cout << " The edges defined by vertex is " << firstVertex << "-" << secondVertex << "belong to the three border elements ::" << 1 + (p->v) / T::nea << ", " << k + 1 << " and " + << 1 + (abs(TheElementAdjacencesLink[p->v]) - 1) / T::nea << endl; cout << " The Surface contains these edges is not a manifold" << endl; } @@ -7696,66 +7322,33 @@ long ShowBorder(const MeshS *pth) { return BuildBoundaryElementAdj(*pth); } // FH July 2017 a cartienne cube // genere with split-Hexa-simplexe.cpp (Thank to D. Bernardi) const int nbsimplexes = 58; -const int simplexes[nbsimplexes][4] = { - {/* - 0 */ 5, 3, 6, 7}, {/* - 1 */ 5, 2, 6, 7}, {/* - 2 */ 5, 1, 6, 7}, - {/* - 3 */ 5, 0, 6, 7}, {/* - 4 */ 4, 3, 6, 7}, {/* - 5 */ 4, 2, 6, 7}, - {/* - 6 */ 4, 1, 6, 7}, {/* - 7 */ 4, 0, 6, 7}, {/* + 8 */ 1, 3, 6, 7}, - {/* + 9 */ 0, 3, 6, 7}, {/* + 10 */ 1, 2, 6, 7}, {/* + 11 */ 0, 2, 6, 7}, - {/* + 12 */ 3, 4, 5, 7}, {/* + 13 */ 2, 4, 5, 7}, {/* + 14 */ 1, 4, 5, 7}, - {/* + 15 */ 0, 4, 5, 7}, {/* - 16 */ 3, 2, 5, 7}, {/* - 17 */ 3, 0, 5, 7}, - {/* + 18 */ 1, 2, 5, 7}, {/* - 19 */ 1, 0, 5, 7}, {/* - 20 */ 3, 2, 4, 7}, - {/* + 21 */ 1, 3, 4, 7}, {/* + 22 */ 1, 2, 4, 7}, {/* + 23 */ 0, 2, 4, 7}, - {/* - 24 */ 1, 0, 4, 7}, {/* - 25 */ 2, 1, 3, 7}, {/* - 26 */ 2, 0, 3, 7}, - {/* + 27 */ 0, 1, 3, 7}, {/* + 28 */ 0, 1, 2, 7}, {/* + 29 */ 3, 4, 5, 6}, - {/* + 30 */ 2, 4, 5, 6}, {/* + 31 */ 1, 4, 5, 6}, {/* + 32 */ 0, 4, 5, 6}, - {/* - 33 */ 3, 2, 5, 6}, {/* - 34 */ 3, 1, 5, 6}, {/* - 35 */ 3, 0, 5, 6}, - {/* - 36 */ 2, 0, 5, 6}, {/* - 37 */ 1, 0, 5, 6}, {/* - 38 */ 3, 2, 4, 6}, - {/* - 39 */ 3, 0, 4, 6}, {/* + 40 */ 1, 2, 4, 6}, {/* - 41 */ 1, 0, 4, 6}, - {/* - 42 */ 2, 1, 3, 6}, {/* - 43 */ 2, 0, 3, 6}, {/* + 44 */ 0, 1, 3, 6}, - {/* + 45 */ 0, 1, 2, 6}, {/* + 46 */ 1, 3, 4, 5}, {/* + 47 */ 0, 3, 4, 5}, - {/* + 48 */ 1, 2, 4, 5}, {/* + 49 */ 0, 2, 4, 5}, {/* - 50 */ 2, 1, 3, 5}, - {/* - 51 */ 2, 0, 3, 5}, {/* + 52 */ 0, 1, 3, 5}, {/* + 53 */ 0, 1, 2, 5}, - {/* - 54 */ 2, 1, 3, 4}, {/* - 55 */ 2, 0, 3, 4}, {/* + 56 */ 0, 1, 3, 4}, - {/* + 57 */ 0, 1, 2, 4}}; +const int simplexes[nbsimplexes][4] = {{/* - 0 */ 5, 3, 6, 7}, {/* - 1 */ 5, 2, 6, 7}, {/* - 2 */ 5, 1, 6, 7}, {/* - 3 */ 5, 0, 6, 7}, {/* - 4 */ 4, 3, 6, 7}, {/* - 5 */ 4, 2, 6, 7}, + {/* - 6 */ 4, 1, 6, 7}, {/* - 7 */ 4, 0, 6, 7}, {/* + 8 */ 1, 3, 6, 7}, {/* + 9 */ 0, 3, 6, 7}, {/* + 10 */ 1, 2, 6, 7}, {/* + 11 */ 0, 2, 6, 7}, + {/* + 12 */ 3, 4, 5, 7}, {/* + 13 */ 2, 4, 5, 7}, {/* + 14 */ 1, 4, 5, 7}, {/* + 15 */ 0, 4, 5, 7}, {/* - 16 */ 3, 2, 5, 7}, {/* - 17 */ 3, 0, 5, 7}, + {/* + 18 */ 1, 2, 5, 7}, {/* - 19 */ 1, 0, 5, 7}, {/* - 20 */ 3, 2, 4, 7}, {/* + 21 */ 1, 3, 4, 7}, {/* + 22 */ 1, 2, 4, 7}, {/* + 23 */ 0, 2, 4, 7}, + {/* - 24 */ 1, 0, 4, 7}, {/* - 25 */ 2, 1, 3, 7}, {/* - 26 */ 2, 0, 3, 7}, {/* + 27 */ 0, 1, 3, 7}, {/* + 28 */ 0, 1, 2, 7}, {/* + 29 */ 3, 4, 5, 6}, + {/* + 30 */ 2, 4, 5, 6}, {/* + 31 */ 1, 4, 5, 6}, {/* + 32 */ 0, 4, 5, 6}, {/* - 33 */ 3, 2, 5, 6}, {/* - 34 */ 3, 1, 5, 6}, {/* - 35 */ 3, 0, 5, 6}, + {/* - 36 */ 2, 0, 5, 6}, {/* - 37 */ 1, 0, 5, 6}, {/* - 38 */ 3, 2, 4, 6}, {/* - 39 */ 3, 0, 4, 6}, {/* + 40 */ 1, 2, 4, 6}, {/* - 41 */ 1, 0, 4, 6}, + {/* - 42 */ 2, 1, 3, 6}, {/* - 43 */ 2, 0, 3, 6}, {/* + 44 */ 0, 1, 3, 6}, {/* + 45 */ 0, 1, 2, 6}, {/* + 46 */ 1, 3, 4, 5}, {/* + 47 */ 0, 3, 4, 5}, + {/* + 48 */ 1, 2, 4, 5}, {/* + 49 */ 0, 2, 4, 5}, {/* - 50 */ 2, 1, 3, 5}, {/* - 51 */ 2, 0, 3, 5}, {/* + 52 */ 0, 1, 3, 5}, {/* + 53 */ 0, 1, 2, 5}, + {/* - 54 */ 2, 1, 3, 4}, {/* - 55 */ 2, 0, 3, 4}, {/* + 56 */ 0, 1, 3, 4}, {/* + 57 */ 0, 1, 2, 4}}; const int nhex_decoupe = 74; const int hex_decoupe[74][7] = { // 74 - {/* 1 */ 5, 57, 22, 25, 14, 5, -1}, {/* 2 */ 5, 32, 35, 52, 43, 0, -1}, - {/* 1 */ 6, 57, 54, 46, 29, 38, 0}, {/* 2 */ 6, 57, 54, 46, 12, 20, 5}, - {/* 3 */ 6, 57, 54, 46, 12, 4, 38}, {/* 4 */ 6, 57, 54, 21, 14, 20, 5}, - {/* 5 */ 6, 57, 54, 21, 14, 4, 38}, {/* 6 */ 6, 57, 48, 50, 33, 30, 0}, - {/* 7 */ 6, 57, 48, 50, 16, 13, 5}, {/* 8 */ 6, 57, 48, 50, 16, 1, 30}, - {/* 9 */ 6, 57, 48, 18, 25, 13, 5}, {/* 10 */ 6, 57, 48, 18, 25, 1, 30}, - {/* 11 */ 6, 57, 40, 42, 34, 31, 0}, {/* 12 */ 6, 57, 40, 42, 8, 6, 14}, - {/* 13 */ 6, 57, 40, 42, 8, 2, 31}, {/* 14 */ 6, 57, 40, 10, 25, 6, 14}, - {/* 15 */ 6, 57, 40, 10, 25, 2, 31}, {/* 16 */ 6, 55, 56, 46, 29, 38, 0}, - {/* 17 */ 6, 55, 56, 46, 12, 20, 5}, {/* 18 */ 6, 55, 56, 46, 12, 4, 38}, - {/* 19 */ 6, 55, 56, 21, 14, 20, 5}, {/* 20 */ 6, 55, 56, 21, 14, 4, 38}, - {/* 21 */ 6, 55, 47, 52, 29, 38, 0}, {/* 22 */ 6, 55, 47, 52, 12, 20, 5}, - {/* 23 */ 6, 55, 47, 52, 12, 4, 38}, {/* 24 */ 6, 49, 53, 50, 33, 30, 0}, - {/* 25 */ 6, 49, 53, 50, 16, 13, 5}, {/* 26 */ 6, 49, 53, 50, 16, 1, 30}, - {/* 27 */ 6, 49, 53, 18, 25, 13, 5}, {/* 28 */ 6, 49, 53, 18, 25, 1, 30}, - {/* 29 */ 6, 49, 51, 52, 33, 30, 0}, {/* 30 */ 6, 49, 51, 52, 16, 13, 5}, - {/* 31 */ 6, 49, 51, 52, 16, 1, 30}, {/* 32 */ 6, 41, 45, 42, 34, 31, 0}, - {/* 33 */ 6, 41, 45, 42, 8, 6, 14}, {/* 34 */ 6, 41, 45, 42, 8, 2, 31}, - {/* 35 */ 6, 41, 45, 10, 25, 6, 14}, {/* 36 */ 6, 41, 45, 10, 25, 2, 31}, - {/* 37 */ 6, 41, 44, 43, 34, 31, 0}, {/* 38 */ 6, 41, 44, 43, 8, 6, 14}, - {/* 39 */ 6, 41, 44, 43, 8, 2, 31}, {/* 40 */ 6, 39, 56, 46, 29, 0, 43}, - {/* 41 */ 6, 39, 56, 46, 12, 4, 43}, {/* 42 */ 6, 39, 56, 21, 14, 4, 43}, - {/* 43 */ 6, 39, 47, 52, 29, 0, 43}, {/* 44 */ 6, 39, 47, 52, 12, 4, 43}, - {/* 45 */ 6, 32, 37, 45, 42, 34, 0}, {/* 46 */ 6, 32, 37, 45, 42, 8, 2}, - {/* 47 */ 6, 32, 37, 45, 10, 25, 2}, {/* 48 */ 6, 32, 37, 44, 43, 34, 0}, - {/* 49 */ 6, 32, 37, 44, 43, 8, 2}, {/* 50 */ 6, 32, 36, 53, 50, 33, 0}, - {/* 51 */ 6, 32, 36, 53, 50, 16, 1}, {/* 52 */ 6, 32, 36, 53, 18, 25, 1}, - {/* 53 */ 6, 32, 36, 51, 52, 33, 0}, {/* 54 */ 6, 32, 36, 51, 52, 16, 1}, - {/* 55 */ 6, 32, 3, 19, 28, 11, 25}, {/* 56 */ 6, 32, 3, 19, 27, 26, 11}, - {/* 57 */ 6, 32, 3, 19, 27, 9, 43}, {/* 58 */ 6, 32, 3, 17, 52, 26, 11}, - {/* 59 */ 6, 32, 3, 17, 52, 9, 43}, {/* 60 */ 6, 23, 28, 24, 14, 25, 5}, - {/* 61 */ 6, 23, 28, 19, 15, 25, 5}, {/* 62 */ 6, 23, 26, 27, 24, 14, 5}, - {/* 63 */ 6, 23, 26, 27, 19, 15, 5}, {/* 64 */ 6, 23, 26, 17, 52, 15, 5}, - {/* 65 */ 6, 7, 24, 28, 11, 25, 14}, {/* 66 */ 6, 7, 24, 27, 26, 11, 14}, - {/* 67 */ 6, 7, 24, 27, 9, 43, 14}, {/* 68 */ 6, 7, 15, 19, 28, 11, 25}, - {/* 69 */ 6, 7, 15, 19, 27, 26, 11}, {/* 70 */ 6, 7, 15, 19, 27, 9, 43}, - {/* 71 */ 6, 7, 15, 17, 52, 26, 11}, {/* 72 */ 6, 7, 15, 17, 52, 9, 43}}; + {/* 1 */ 5, 57, 22, 25, 14, 5, -1}, {/* 2 */ 5, 32, 35, 52, 43, 0, -1}, {/* 1 */ 6, 57, 54, 46, 29, 38, 0}, {/* 2 */ 6, 57, 54, 46, 12, 20, 5}, {/* 3 */ 6, 57, 54, 46, 12, 4, 38}, + {/* 4 */ 6, 57, 54, 21, 14, 20, 5}, {/* 5 */ 6, 57, 54, 21, 14, 4, 38}, {/* 6 */ 6, 57, 48, 50, 33, 30, 0}, {/* 7 */ 6, 57, 48, 50, 16, 13, 5}, {/* 8 */ 6, 57, 48, 50, 16, 1, 30}, + {/* 9 */ 6, 57, 48, 18, 25, 13, 5}, {/* 10 */ 6, 57, 48, 18, 25, 1, 30}, {/* 11 */ 6, 57, 40, 42, 34, 31, 0}, {/* 12 */ 6, 57, 40, 42, 8, 6, 14}, {/* 13 */ 6, 57, 40, 42, 8, 2, 31}, + {/* 14 */ 6, 57, 40, 10, 25, 6, 14}, {/* 15 */ 6, 57, 40, 10, 25, 2, 31}, {/* 16 */ 6, 55, 56, 46, 29, 38, 0}, {/* 17 */ 6, 55, 56, 46, 12, 20, 5}, {/* 18 */ 6, 55, 56, 46, 12, 4, 38}, + {/* 19 */ 6, 55, 56, 21, 14, 20, 5}, {/* 20 */ 6, 55, 56, 21, 14, 4, 38}, {/* 21 */ 6, 55, 47, 52, 29, 38, 0}, {/* 22 */ 6, 55, 47, 52, 12, 20, 5}, {/* 23 */ 6, 55, 47, 52, 12, 4, 38}, + {/* 24 */ 6, 49, 53, 50, 33, 30, 0}, {/* 25 */ 6, 49, 53, 50, 16, 13, 5}, {/* 26 */ 6, 49, 53, 50, 16, 1, 30}, {/* 27 */ 6, 49, 53, 18, 25, 13, 5}, {/* 28 */ 6, 49, 53, 18, 25, 1, 30}, + {/* 29 */ 6, 49, 51, 52, 33, 30, 0}, {/* 30 */ 6, 49, 51, 52, 16, 13, 5}, {/* 31 */ 6, 49, 51, 52, 16, 1, 30}, {/* 32 */ 6, 41, 45, 42, 34, 31, 0}, {/* 33 */ 6, 41, 45, 42, 8, 6, 14}, + {/* 34 */ 6, 41, 45, 42, 8, 2, 31}, {/* 35 */ 6, 41, 45, 10, 25, 6, 14}, {/* 36 */ 6, 41, 45, 10, 25, 2, 31}, {/* 37 */ 6, 41, 44, 43, 34, 31, 0}, {/* 38 */ 6, 41, 44, 43, 8, 6, 14}, + {/* 39 */ 6, 41, 44, 43, 8, 2, 31}, {/* 40 */ 6, 39, 56, 46, 29, 0, 43}, {/* 41 */ 6, 39, 56, 46, 12, 4, 43}, {/* 42 */ 6, 39, 56, 21, 14, 4, 43}, {/* 43 */ 6, 39, 47, 52, 29, 0, 43}, + {/* 44 */ 6, 39, 47, 52, 12, 4, 43}, {/* 45 */ 6, 32, 37, 45, 42, 34, 0}, {/* 46 */ 6, 32, 37, 45, 42, 8, 2}, {/* 47 */ 6, 32, 37, 45, 10, 25, 2}, {/* 48 */ 6, 32, 37, 44, 43, 34, 0}, + {/* 49 */ 6, 32, 37, 44, 43, 8, 2}, {/* 50 */ 6, 32, 36, 53, 50, 33, 0}, {/* 51 */ 6, 32, 36, 53, 50, 16, 1}, {/* 52 */ 6, 32, 36, 53, 18, 25, 1}, {/* 53 */ 6, 32, 36, 51, 52, 33, 0}, + {/* 54 */ 6, 32, 36, 51, 52, 16, 1}, {/* 55 */ 6, 32, 3, 19, 28, 11, 25}, {/* 56 */ 6, 32, 3, 19, 27, 26, 11}, {/* 57 */ 6, 32, 3, 19, 27, 9, 43}, {/* 58 */ 6, 32, 3, 17, 52, 26, 11}, + {/* 59 */ 6, 32, 3, 17, 52, 9, 43}, {/* 60 */ 6, 23, 28, 24, 14, 25, 5}, {/* 61 */ 6, 23, 28, 19, 15, 25, 5}, {/* 62 */ 6, 23, 26, 27, 24, 14, 5}, {/* 63 */ 6, 23, 26, 27, 19, 15, 5}, + {/* 64 */ 6, 23, 26, 17, 52, 15, 5}, {/* 65 */ 6, 7, 24, 28, 11, 25, 14}, {/* 66 */ 6, 7, 24, 27, 26, 11, 14}, {/* 67 */ 6, 7, 24, 27, 9, 43, 14}, {/* 68 */ 6, 7, 15, 19, 28, 11, 25}, + {/* 69 */ 6, 7, 15, 19, 27, 26, 11}, {/* 70 */ 6, 7, 15, 19, 27, 9, 43}, {/* 71 */ 6, 7, 15, 17, 52, 26, 11}, {/* 72 */ 6, 7, 15, 17, 52, 9, 43}}; class Cube_Op : public E_F0mps { public: @@ -7765,9 +7358,7 @@ class Cube_Op : public E_F0mps { Expression nargs[n_name_param], enx, eny, enz, xx, yy, zz; public: - Cube_Op(const basicAC_F0 &args, Expression nx, Expression ny, Expression nz, - Expression transfo = 0) - : enx(nx), eny(ny), enz(nz), xx(0), yy(0), zz(0) { + Cube_Op(const basicAC_F0 &args, Expression nx, Expression ny, Expression nz, Expression transfo = 0) : enx(nx), eny(ny), enz(nz), xx(0), yy(0), zz(0) { args.SetNameParam(n_name_param, name_param, nargs); if (transfo) { const E_Array *a2 = dynamic_cast< const E_Array * >(transfo); @@ -7788,56 +7379,44 @@ class Cube_Op : public E_F0mps { AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type Cube_Op::name_param[] = { - {"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, {"flags", &typeid(long)}}; +basicAC_F0::name_and_type Cube_Op::name_param[] = {{"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, {"flags", &typeid(long)}}; class Cube : public OneOperator { public: int cas; - Cube( ) - : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( )), - cas(0) {} + Cube( ) : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( )), cas(0) {} - Cube(int) - : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( ), - atype< E_Array >( )), - cas(1) {} + Cube(int) : OneOperator(atype< pmesh3 >( ), atype< long >( ), atype< long >( ), atype< long >( ), atype< E_Array >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 0) { return new Cube_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } else { - return new Cube_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), - t[3]->CastTo(args[3])); + return new Cube_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3])); } } }; class Square_Op : public E_F0mps { - public: static const int n_name_param = 7; // + public: + static const int n_name_param = 7; // static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param], enx, eny, xx, yy, zz; - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + public: - Square_Op(const basicAC_F0 &args, Expression nx, Expression ny, Expression transfo = 0) - : enx(nx), eny(ny), xx(0), yy(0), zz(0) { + Square_Op(const basicAC_F0 &args, Expression nx, Expression ny, Expression transfo = 0) : enx(nx), eny(ny), xx(0), yy(0), zz(0) { args.SetNameParam(n_name_param, name_param, nargs); if (transfo) { const E_Array *a2 = dynamic_cast< const E_Array * >(transfo); int err = 0; if (a2) { - if (a2->size( )<1) CompileError("Square (n1,n2, [X,Y,Z]) "); + if (a2->size( ) < 1) CompileError("Square (n1,n2, [X,Y,Z]) "); xx = to< double >((*a2)[0]); yy = to< double >((*a2)[1]); - if(a2->size()>2) zz = to< double >((*a2)[2]); + if (a2->size( ) > 2) zz = to< double >((*a2)[2]); } } } @@ -7846,10 +7425,8 @@ class Square_Op : public E_F0mps { }; basicAC_F0::name_and_type Square_Op::name_param[] = { - {"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, - {"flags", &typeid(long)}, {"orientation", &typeid(long)}, - {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, - {"precismesh", &typeid(double)} + {"region", &typeid(long)}, {"label", &typeid(KN_< long >)}, {"flags", &typeid(long)}, {"orientation", &typeid(long)}, + {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precismesh", &typeid(double)} //{"rebuildboundary", &typeid(bool)}, }; @@ -7858,16 +7435,13 @@ class Square : public OneOperator { int cas; Square( ) : OneOperator(atype< pmeshS >( ), atype< long >( ), atype< long >( )), cas(0) {} - Square(int) - : OneOperator(atype< pmeshS >( ), atype< long >( ), atype< long >( ), atype< E_Array >( )), - cas(1) {} + Square(int) : OneOperator(atype< pmeshS >( ), atype< long >( ), atype< long >( ), atype< E_Array >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { if (cas == 0) { return new Square_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1])); } else { - return new Square_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), - t[2]->CastTo(args[2])); + return new Square_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } } }; @@ -7876,8 +7450,7 @@ struct MovePoint { Stack stack; Expression xx, yy, zz; MeshPoint *mp, mps; - MovePoint(Stack ss, Expression x, Expression y, Expression z) - : stack(ss), xx(x), yy(y), zz(z), mp(MeshPointStack(ss)), mps(*mp) {} + MovePoint(Stack ss, Expression x, Expression y, Expression z) : stack(ss), xx(x), yy(y), zz(z), mp(MeshPointStack(ss)), mps(*mp) {} ~MovePoint( ) { *mp = mps; } @@ -7892,13 +7465,12 @@ struct MovePoint { } }; -Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, - MovePoint *tf = 0) { - const int(*const nvface)[3] = Tet::nvface; - int debug = verbosity / 10; +Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, MovePoint *tf = 0) { + const int (*const nvface)[3] = Tet::nvface; + int debug = verbosity / 10; int codesb[64], kcode[20]; int kstable = 0; - double cpu0 = ((double) clock())/CLOCKS_PER_SEC; + double cpu0 = ((double)clock( )) / CLOCKS_PER_SEC; if (debug) { cout << " Enter: BuildCube: " << kind << endl; @@ -7933,8 +7505,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, for (int c = 0; c < 2; ++c) { for (int b = 0; b < 2; ++b) { for (int a = 0; a < 2; ++a) { - l8[a + 2 * b + 4 * c] = 1 * (a == 0) + 2 * (a == 1) + 4 * (b == 0) + 8 * (b == 1) + - 16 * (c == 0) + 32 * (c == 1); + l8[a + 2 * b + 4 * c] = 1 * (a == 0) + 2 * (a == 1) + 4 * (b == 0) + 8 * (b == 1) + 16 * (c == 0) + 32 * (c == 1); } } } @@ -7981,9 +7552,8 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, } if (debug > 5) { - cout << d << " f " << f << " k " << k << " i =" << i0 << " " << i1 - << " fc =" << i4[0] << " " << i4[1] << " " << i4[2] << " " << i4[3] - << " J= " << j1 << " " << j2 << " di = " << di << endl; + cout << d << " f " << f << " k " << k << " i =" << i0 << " " << i1 << " fc =" << i4[0] << " " << i4[1] << " " << i4[2] << " " << i4[3] << " J= " << j1 << " " << j2 + << " di = " << di << endl; } if (dd[k] < 0) { @@ -8024,14 +7594,12 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, code6 = kcode[abs(kind) % kstable]; } - if (verbosity>1) { - cout << " Cube: kind = " << kind << " n tet Cube = " << ntetcube << " / n slip 6 " << code6 - << endl; + if (verbosity > 1) { + cout << " Cube: kind = " << kind << " n tet Cube = " << ntetcube << " / n slip 6 " << code6 << endl; } int nc = (nx) * (ny) * (nz); - int nv = (nx + 1) * (ny + 1) * (nz + 1), nt = nc * ntetcube, - nbe = 4 * (nx * ny + nx * nz + ny * nz); + int nv = (nx + 1) * (ny + 1) * (nz + 1), nt = nc * ntetcube, nbe = 4 * (nx * ny + nx * nz + ny * nz); int nj = nx + 1; int nk = nj * (ny + 1); Vertex3 *vff = new Vertex3[nv]; @@ -8044,8 +7612,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, vff[p].x = x0 + xd * i; vff[p].y = y0 + yd * j; vff[p].z = z0 + zd * k; - vff[p].lab = 1 * (i == 0) + 2 * (i == nx) + 4 * (j == 0) + 8 * (j == ny) + 16 * (k == 0) + - 32 * (k == nz); + vff[p].lab = 1 * (i == 0) + 2 * (i == nx) + 4 * (j == 0) + 8 * (j == ny) + 16 * (k == 0) + 32 * (k == nz); if (tf) { (R3 &)vff[p] = tf->eval(vff[p]); } @@ -8058,7 +7625,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, } } } - double cpu1 = ((double) clock())/CLOCKS_PER_SEC; + double cpu1 = ((double)clock( )) / CLOCKS_PER_SEC; Tet *tff = new Tet[nt]; Triangle3 *bff = new Triangle3[nbe]; @@ -8081,8 +7648,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, } if (debug > 9) { - cout << " h " << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << " " << n[4] << " " - << n[5] << " " << n[6] << " " << n[7] << endl; + cout << " h " << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << " " << n[4] << " " << n[5] << " " << n[6] << " " << n[7] << endl; } for (int d = 0; d < ntetcube; ++d) { @@ -8097,8 +7663,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, tff[p].set(vff, nu, region); if (debug > 4) { - cout << " tet = " << p << " " << nu[0] << " " << nu[1] << " " << nu[2] << " " << nu[3] - << " / " << kt << " " << tff[p].mesure( ) << endl; + cout << " tet = " << p << " " << nu[0] << " " << nu[1] << " " << nu[2] << " " << nu[3] << " / " << kt << " " << tff[p].mesure( ) << endl; } for (int f = 0; f < 4; ++f) { // pour le 4 face @@ -8110,8 +7675,7 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, int lk = 1 << k; // 2^k if (l == lk) { if (debug > 9) { - cout << kf << " " << l << " " << k << " :" << nf[0] << " " << nf[1] << " " - << nf[2] << " / " << nff[k] << endl; + cout << kf << " " << l << " " << k << " :" << nf[0] << " " << nf[1] << " " << nf[2] << " / " << nff[k] << endl; } int lf = label[nff[k]]; @@ -8137,14 +7701,12 @@ Mesh3 *BuildCube(long nx, long ny, long nz, long region, long *label, long kind, if (debug) { cout << " Out: BuildCube" << endl; } - double cpu2 = ((double) clock())/CLOCKS_PER_SEC; + double cpu2 = ((double)clock( )) / CLOCKS_PER_SEC; - Mesh3 * Th3= new Mesh3(nv, nt, nbe, vff, tff, bff); - double cpu3 = ((double) clock())/CLOCKS_PER_SEC; - if(verbosity>1) - cout << " cube timers "<< cpu1-cpu0 << " " < 1) cout << " cube timers " << cpu1 - cpu0 << " " << cpu2 - cpu1 << " Mesh3 " << cpu3 - cpu2 << endl; + return Th3; } AnyType Cube_Op::operator( )(Stack stack) const { @@ -8198,17 +7760,15 @@ AnyType Square_Op::operator( )(Stack stack) const { long orientation(arg(3, stack, 1L)); long cleanmesh(arg(4, stack, true)); long removeduplicate(arg(5, stack, false)); - bool rebuildboundary=false;//(arg(7, stack, false)); + bool rebuildboundary = false; //(arg(7, stack, false)); double precis_mesh(arg(6, stack, 1e-7)); - + Mesh *pTh = Carre_(nx, ny, 0, 0, stack, region, label, 0L); Mesh &Th = *pTh; KN< int > takemesh(Th.nv); takemesh = 0; - if (verbosity > 2) - cout << " -- SquareMesh_Op input: nv" << Th.nv << " nt: " << Th.nt << " nbe " << Th.neb - << endl; + if (verbosity > 2) cout << " -- SquareMesh_Op input: nv" << Th.nv << " nt: " << Th.nt << " nbe " << Th.neb << endl; typedef typename MeshS::Element T; typedef typename MeshS::BorderElement B; typedef typename MeshS::Vertex V; @@ -8251,8 +7811,7 @@ AnyType Square_Op::operator( )(Stack stack) const { b[ibe].set(v, iv, K.lab); } // build the moved mesh and apply option - MeshS *T_Th = new MeshS(Th.nv, Th.nt, Th.neb, v, t, b, cleanmesh, removeduplicate, - rebuildboundary, orientation, precis_mesh); + MeshS *T_Th = new MeshS(Th.nv, Th.nt, Th.neb, v, t, b, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); T_Th->BuildGTree( ); delete pTh; @@ -8270,25 +7829,17 @@ class BuildMeshS_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: - BuildMeshS_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { - args.SetNameParam(n_name_param, name_param, nargs); - } + BuildMeshS_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; basicAC_F0::name_and_type BuildMeshS_Op::name_param[] = { - {"angle", &typeid(double)}, - {"sublabBd", &typeid(bool)} -}; + {"angle", &typeid(double)}, {"sublabBd", &typeid(bool)}}; AnyType BuildMeshS_Op::operator( )(Stack stack) const { @@ -8304,15 +7855,15 @@ AnyType BuildMeshS_Op::operator( )(Stack stack) const { // criteria = arcsin(2/3) = 42 deg const double angle(arg(0, stack, 8. * atan(1.) / 9.)); // default angle = 40 deg)); if (atan(1) * 4 <= angle) ExecError(" the criteria angle must be inferior to pi alpha"); - bool labeledBoundary(arg(1, stack,false)); - - //double tolerance = cos(angle); + bool labeledBoundary(arg(1, stack, false)); + + // double tolerance = cos(angle); if (verbosity > 5) cout << "Angle criteria to determine an edge:" << angle << endl; if (Th.meshS) { cout << "Caution, Mesh3::meshS previously created, don't use builBdMesh operator " << endl; - return pTh; + return pTh; } else { @@ -8327,8 +7878,7 @@ AnyType BuildMeshS_Op::operator( )(Stack stack) const { Triangle3 *bb = b; double mes = 0, mesb = 0; - if (verbosity > 5) - cout << "copy the original mesh3... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; + if (verbosity > 5) cout << "copy the original mesh3... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; int i_som = 0, i_elem = 0, i_border = 0; for (int i = 0; i < nv; i++) { @@ -8378,12 +7928,9 @@ class BuildMeshSFromMesh3 : public OneOperator { public: BuildMeshSFromMesh3( ) : OneOperator(atype< pmesh3 >( ), atype< pmesh3 >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new BuildMeshS_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new BuildMeshS_Op(args, t[0]->CastTo(args[0])); } }; - class BuildMeshL_Op : public E_F0mps { public: Expression eTh; @@ -8391,27 +7938,18 @@ class BuildMeshL_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: - BuildMeshL_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { - args.SetNameParam(n_name_param, name_param, nargs); - } + BuildMeshL_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; basicAC_F0::name_and_type BuildMeshL_Op::name_param[] = { - {"angle", &typeid(double)}, - {"labeledBoundary", &typeid(bool)} -}; + {"angle", &typeid(double)}, {"labeledBoundary", &typeid(bool)}}; - AnyType BuildMeshL_Op::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; @@ -8419,10 +7957,10 @@ AnyType BuildMeshL_Op::operator( )(Stack stack) const { MeshS &Th = *pTh; ffassert(pTh); - double angle(arg(0, stack, 8.*atan(1.)/9.)); // default angle = 40 deg)); + double angle(arg(0, stack, 8. * atan(1.) / 9.)); // default angle = 40 deg)); if (atan(1) * 4 <= angle) ExecError(" the criteria angle must be inferior to pi alpha"); - bool labeledBoundary(arg(1, stack,false)); - + bool labeledBoundary(arg(1, stack, false)); + if (verbosity > 5) cout << "Enter in BuildMesh_Op.... " << endl; if (Th.meshL) { @@ -8440,8 +7978,7 @@ AnyType BuildMeshL_Op::operator( )(Stack stack) const { BoundaryEdgeS *bb = b; double mes = 0, mesb = 0; - if (verbosity > 5) - cout << "copy the original meshS... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; + if (verbosity > 5) cout << "copy the original meshS... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; int i_som = 0, i_elem = 0, i_border = 0; for (int i = 0; i < nv; i++) { @@ -8480,7 +8017,7 @@ AnyType BuildMeshL_Op::operator( )(Stack stack) const { MeshS *Th_t = new MeshS(nv, nt, nbe, v, t, b); Th_t->BuildGTree( ); // build the meshS and the edges list - Th_t->BuildMeshL(labeledBoundary,angle); + Th_t->BuildMeshL(labeledBoundary, angle); *mp = mps; Add2StackOfPtr2FreeRC(stack, Th_t); return Th_t; @@ -8490,9 +8027,7 @@ class BuildMeshLFromMeshS : public OneOperator { public: BuildMeshLFromMeshS( ) : OneOperator(atype< pmeshS >( ), atype< pmeshS >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new BuildMeshL_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new BuildMeshL_Op(args, t[0]->CastTo(args[0])); } }; // movemesh @@ -8511,29 +8046,25 @@ class Movemesh_Op : public E_F0mps { return nargs[i] ? GetAny< KN_< long > >((*nargs[i])(stack)) : a; } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - long arg(int i, Stack stack, long a) const { - return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; - } + long arg(int i, Stack stack, long a) const { return nargs[i] ? GetAny< long >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: - Movemesh_Op(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, - Expression zzz = 0) - : eTh(tth), xx(xxx), yy(yyy), zz(zzz) { - - int size; - if(is_same< MMesh, Mesh >::value) size=3; - else if(is_same< MMesh, Mesh3 >::value) size=3; - else if(is_same< MMesh, MeshS >::value) size=2; - else if(is_same< MMesh, MeshL >::value) size=1; - + Movemesh_Op(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, Expression zzz = 0) : eTh(tth), xx(xxx), yy(yyy), zz(zzz) { + + int size; + if (is_same< MMesh, Mesh >::value) + size = 3; + else if (is_same< MMesh, Mesh3 >::value) + size = 3; + else if (is_same< MMesh, MeshS >::value) + size = 2; + else if (is_same< MMesh, MeshL >::value) + size = 1; + args.SetNameParam(n_name_param, name_param, nargs); const E_Array *a1 = 0; if (nargs[0]) { @@ -8549,14 +8080,14 @@ class Movemesh_Op : public E_F0mps { CompileError("uncompatible movemesh (Th, label= , refface= "); } - if (a1) { + if (a1) { if (a1->size( ) < size || xx || yy || zz) { CompileError("movemesh (Th,transfo=[X,Y,Z],) "); } xx = to< double >((*a1)[0]); - if(a1->size()>1) yy = to< double >((*a1)[1]); - if(a1->size()>2) zz = to< double >((*a1)[2]); + if (a1->size( ) > 1) yy = to< double >((*a1)[1]); + if (a1->size( ) > 2) zz = to< double >((*a1)[2]); } } @@ -8566,48 +8097,42 @@ class Movemesh_Op : public E_F0mps { // instance arguments for mesh3 template<> basicAC_F0::name_and_type Movemesh_Op< Mesh3 >::name_param[] = { - {"transfo", &typeid(E_Array)}, // 0 - {"reftet", &typeid(KN_< long >)}, // 1 - {"refface", &typeid(KN_< long >)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, // 4 - {"region", &typeid(KN_< long >)}, // 5 - {"label", &typeid(KN_< long >)}, // 6 - {"cleanmesh", &typeid(bool)}, // 7 - {"removeduplicate", &typeid(bool)} // 8 + {"transfo", &typeid(E_Array)}, // 0 + {"reftet", &typeid(KN_< long >)}, // 1 + {"refface", &typeid(KN_< long >)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, // 4 + {"region", &typeid(KN_< long >)}, // 5 + {"label", &typeid(KN_< long >)}, // 6 + {"cleanmesh", &typeid(bool)}, // 7 + {"removeduplicate", &typeid(bool)} // 8 //{"rebuildboundary", &typeid(bool)} // 9 }; // instance arguments for meshS template<> basicAC_F0::name_and_type Movemesh_Op< MeshS >::name_param[] = { - {"transfo", &typeid(E_Array)}, // 0 - {"reftri", &typeid(KN_< long >)}, // 1 - {"refedge", &typeid(KN_< long >)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, // 4 - {"region", &typeid(KN_< long >)}, // 5 - {"label", &typeid(KN_< long >)}, // 6 - {"cleanmesh", &typeid(bool)}, // 7 - {"removeduplicate", &typeid(bool)} // 8 + {"transfo", &typeid(E_Array)}, // 0 + {"reftri", &typeid(KN_< long >)}, // 1 + {"refedge", &typeid(KN_< long >)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, // 4 + {"region", &typeid(KN_< long >)}, // 5 + {"label", &typeid(KN_< long >)}, // 6 + {"cleanmesh", &typeid(bool)}, // 7 + {"removeduplicate", &typeid(bool)} // 8 //{"rebuildboundary", &typeid(bool)} // 9 }; - // instance arguments for meshS +// instance arguments for meshS template<> basicAC_F0::name_and_type Movemesh_Op< MeshL >::name_param[] = { - {"transfo", &typeid(E_Array)}, // 0 - {"refedge", &typeid(KN_< long >)}, // 1 - {"refpoint", &typeid(KN_< long >)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, // 4 - {"region", &typeid(KN_< long >)}, // 5 - {"label", &typeid(KN_< long >)}, // 6 - {"cleanmesh", &typeid(bool)}, // 7 - {"removeduplicate", &typeid(bool)} // 8 - //{"rebuildboundary", &typeid(bool)} // 9 + {"transfo", &typeid(E_Array)}, // 0 + {"refedge", &typeid(KN_< long >)}, // 1 + {"refpoint", &typeid(KN_< long >)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, // 4 + {"region", &typeid(KN_< long >)}, // 5 + {"label", &typeid(KN_< long >)}, // 6 + {"cleanmesh", &typeid(bool)}, // 7 + {"removeduplicate", &typeid(bool)} // 8 + //{"rebuildboundary", &typeid(bool)} // 9 }; - + template< class MMesh > AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; @@ -8628,13 +8153,11 @@ AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { long orientation(arg(4, stack, 1L)); bool cleanmesh(arg(7, stack, true)); bool removeduplicate(arg(8, stack, false)); - bool rebuildboundary=false;//(arg(9, stack, false)); + bool rebuildboundary = false; //(arg(9, stack, false)); KN< int > takemesh(Th.nv); takemesh = 0; - if (verbosity > 5) - cout << "before movemesh: Vertex " << Th.nv << " Triangles " << Th.nt << " Edges " << Th.nbe - << endl; + if (verbosity > 5) cout << "before movemesh: Vertex " << Th.nv << " Triangles " << Th.nt << " Edges " << Th.nbe << endl; // map to change lab ffassert(nrT.N( ) % 2 == 0); @@ -8654,37 +8177,59 @@ AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { B *b = new B[Th.nbe]; // apply the geometric transfo and copy vertices - if( Th.nt ==0 && Th.nbe==0) - { // mesh with only vertex - for (int iv = 0; iv < Th.nv; ++iv) - { - - R3 P; - P = Th(iv); - mpp->set(P.x,P.y,P.z); + if (Th.nt == 0 && Th.nbe == 0) { // mesh with only vertex + for (int iv = 0; iv < Th.nv; ++iv) { + + R3 P; + P = Th(iv); + mpp->set(P.x, P.y, P.z); + if (xx) + v[iv].x = GetAny< double >((*xx)(stack)); + else + v[iv].x = mpp->P.x; + if (yy) + v[iv].y = GetAny< double >((*yy)(stack)); + else + v[iv].y = mpp->P.y; + if (zz) + v[iv].z = GetAny< double >((*zz)(stack)); + else + v[iv].z = mpp->P.z; + } + } else { + // loop over elements + for (int it = 0; it < Th.nt; ++it) { + const T &K(Th.elements[it]); + for (int iv = 0; iv < T::nv; iv++) { + int i = Th.operator( )(K[iv]); + if (takemesh[i] == 0) { + mpp->setP(&Th, it, iv); if (xx) - v[iv].x = GetAny< double >((*xx)(stack)); + v[i].x = GetAny< double >((*xx)(stack)); else - v[iv].x = mpp->P.x; + v[i].x = mpp->P.x; if (yy) - v[iv].y = GetAny< double >((*yy)(stack)); + v[i].y = GetAny< double >((*yy)(stack)); else - v[iv].y = mpp->P.y; + v[i].y = mpp->P.y; if (zz) - v[iv].z = GetAny< double >((*zz)(stack)); + v[i].z = GetAny< double >((*zz)(stack)); else - v[iv].z = mpp->P.z; + v[i].z = mpp->P.z; + v[i].lab = Th.vertices[i].lab; + takemesh[i] = takemesh[i] + 1; + } } + } } - else - { - // loop over elements - for (int it = 0; it < Th.nt; ++it) { - const T &K(Th.elements[it]); - for (int iv = 0; iv < T::nv; iv++) { - int i = Th.operator( )(K[iv]); + + // loop over border elements + for (int ibe = 0; ibe < Th.nbe; ++ibe) { + const B &K(Th.be(ibe)); + for (int j = 0; j < B::nv; j++) { + int i = Th.operator( )(K[j]); if (takemesh[i] == 0) { - mpp->setP(&Th, it, iv); + mpp->set(Th.vertices[i].x, Th.vertices[i].y, Th.vertices[i].z); if (xx) v[i].x = GetAny< double >((*xx)(stack)); else @@ -8702,26 +8247,6 @@ AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { } } } - } - - // loop over border elements - for (int ibe = 0; ibe < Th.nbe; ++ibe) { - const B &K(Th.be(ibe)); - for (int j = 0; j < B::nv; j++) { - int i = Th.operator( )(K[j]); - if (takemesh[i] == 0) { - mpp->set(Th.vertices[i].x, Th.vertices[i].y, Th.vertices[i].z); - if (xx) v[i].x = GetAny< double >((*xx)(stack)); - else v[i].x = mpp->P.x; - if (yy) v[i].y = GetAny< double >((*yy)(stack)); - else v[i].y = mpp->P.y; - if (zz) v[i].z = GetAny< double >((*zz)(stack)); - else v[i].z = mpp->P.z; - v[i].lab = Th.vertices[i].lab; - takemesh[i] = takemesh[i] + 1; - } - } - } // copy elements for (int it = 0; it < Th.nt; ++it) { @@ -8740,8 +8265,7 @@ AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { b[ibe].set(v, iv, K.lab); } // build the moved mesh and apply option - MMesh *T_Th = new MMesh(Th.nv, Th.nt, Th.nbe, v, t, b, cleanmesh, removeduplicate, - rebuildboundary, orientation, precis_mesh); + MMesh *T_Th = new MMesh(Th.nv, Th.nt, Th.nbe, v, t, b, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); // apply the change of elements and borderelements references if (nrT.N( ) > 0) @@ -8760,7 +8284,7 @@ AnyType Movemesh_Op< MMesh >::operator( )(Stack stack) const { // case MeshS: T_Th->mapSurf2Vol=0;_Th->mapVol2Surf=0; // case Mesh3: if(Th.meshS) T_Th->BuildMeshS(); finalize(T_Th); - if(verbosity>5) cout << " bb box "<< T_Th->Pmin << " ; " << T_Th->Pmax < 5) cout << " bb box " << T_Th->Pmin << " ; " << T_Th->Pmax << endl; Add2StackOfPtr2FreeRC(stack, T_Th); *mp = mps; return T_Th; @@ -8773,17 +8297,20 @@ class Movemesh : public OneOperator { typedef const MMesh *ppmesh; Movemesh( ) : OneOperator(atype< ppmesh >( ), atype< ppmesh >( )), cas(0) {} - Movemesh(int) - : OneOperator(atype< ppmesh >( ), atype< ppmesh >( ), atype< E_Array >( )), cas(1) {} + Movemesh(int) : OneOperator(atype< ppmesh >( ), atype< ppmesh >( ), atype< E_Array >( )), cas(1) {} E_F0 *code(const basicAC_F0 &args) const { - - int size; - if(is_same< MMesh, Mesh >::value) size=3; - else if(is_same< MMesh, Mesh3 >::value) size=3; - else if(is_same< MMesh, MeshS >::value) size=2; - else if(is_same< MMesh, MeshL >::value) size=1; - + + int size; + if (is_same< MMesh, Mesh >::value) + size = 3; + else if (is_same< MMesh, Mesh3 >::value) + size = 3; + else if (is_same< MMesh, MeshS >::value) + size = 2; + else if (is_same< MMesh, MeshL >::value) + size = 1; + if (cas == 0) { return new Movemesh_Op< MMesh >(args, t[0]->CastTo(args[0])); } else if (cas == 1) { @@ -8794,9 +8321,11 @@ class Movemesh : public OneOperator { CompileError("movemesh(Th,[ ],...) bad reequired componatenumber in array ", atype< ppmesh >( )); } - Expression X = to< double >((*a)[0]); - Expression Y=0 ; if(a->size( )>1) Y=to< double >((*a)[1]); - Expression Z=0 ; if(a->size( )>2) Z= to< double >((*a)[2]); + Expression X = to< double >((*a)[0]); + Expression Y = 0; + if (a->size( ) > 1) Y = to< double >((*a)[1]); + Expression Z = 0; + if (a->size( ) > 2) Z = to< double >((*a)[2]); return new Movemesh_Op< MMesh >(args, t[0]->CastTo(args[0]), X, Y, Z); } else { return 0; @@ -8807,15 +8336,13 @@ class Movemesh : public OneOperator { // special instance movemesh from 2D to 3D surface template<> basicAC_F0::name_and_type Movemesh_Op< Mesh >::name_param[] = { - {"transfo", &typeid(E_Array)}, // 0 - {"reftri", &typeid(KN_< long >)}, // 1 - {"refedge", &typeid(KN_< long >)}, - {"precismesh", &typeid(double)}, - {"orientation", &typeid(long)}, // 4 - {"region", &typeid(KN_< long >)}, // 5 - {"label", &typeid(KN_< long >)}, // 6 - {"cleanmesh", &typeid(bool)}, // 7 - {"removeduplicate", &typeid(bool)} // 8 + {"transfo", &typeid(E_Array)}, // 0 + {"reftri", &typeid(KN_< long >)}, // 1 + {"refedge", &typeid(KN_< long >)}, {"precismesh", &typeid(double)}, {"orientation", &typeid(long)}, // 4 + {"region", &typeid(KN_< long >)}, // 5 + {"label", &typeid(KN_< long >)}, // 6 + {"cleanmesh", &typeid(bool)}, // 7 + {"removeduplicate", &typeid(bool)} // 8 //{"rebuildboundary", &typeid(bool)} // 9 }; @@ -8842,11 +8369,9 @@ AnyType Movemesh_Op< Mesh >::operator( )(Stack stack) const { long orientation(arg(4, stack, 1L)); bool cleanmesh(arg(7, stack, true)); bool removeduplicate(arg(8, stack, false)); - bool rebuildboundary=false;//(arg(9, stack, false)); + bool rebuildboundary = false; //(arg(9, stack, false)); - if (verbosity > 5) - cout << "before movemesh: Vertex " << Th.nv << " Triangles " << Th.nt << " Edges " << Th.neb - << endl; + if (verbosity > 5) cout << "before movemesh: Vertex " << Th.nv << " Triangles " << Th.nt << " Edges " << Th.neb << endl; // map to change lab ffassert(nrT.N( ) % 2 == 0); @@ -8900,8 +8425,7 @@ AnyType Movemesh_Op< Mesh >::operator( )(Stack stack) const { } // build the moved mesh and apply option - MeshS *T_Th = new MeshS(Th.nv, Th.nt, Th.neb, vS, tS, bS, cleanmesh, removeduplicate, - rebuildboundary, orientation, precis_mesh); + MeshS *T_Th = new MeshS(Th.nv, Th.nt, Th.neb, vS, tS, bS, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); // apply the change of elements and borderelements references if (nrT.N( ) > 0) @@ -8924,144 +8448,132 @@ AnyType Movemesh_Op< Mesh >::operator( )(Stack stack) const { return T_Th; } -const Mesh * MoveTheMesh(const MeshS &Th,const KN_ & U,const KN_ &V,bool orientation) -{ - using Fem2D::Triangle; - using Fem2D::Vertex; - using Fem2D::R2; - using Fem2D::BoundaryEdge; - using Fem2D::Mesh; - // using Fem2D::R; - using Fem2D::MeshPointStack; - int nbv=Th.nv; - int nbt=Th.nt; - int neb=Th.nbe; - Vertex * v= new Vertex[nbv]; - Triangle *t= new Triangle[nbt]; - BoundaryEdge *b= new BoundaryEdge[neb]; - Vertex *vv=v; - for (int i=0;ix=P.x; - vv->y=P.y; - vv->lab = Th(i).lab; - vv++; - } - Triangle *tt= t; - int nberr=0; - double atotal=0,atotal0=0; - double amax=-1e100,amin=1e100; - int ineg=0, ipos =0; - for (int i=0;i0) ipos++; - atotal += a; - amax=max(a,amax); - amin=min(a,amin); - } - double eps = 1e-6 * max(abs(atotal),1e-100)/atotal0; - bool rev=(atotal<0); - if(ipos + ineg != nbt || (ipos >0 && ineg >0)) - { - cout << " Error " << ipos << " triangle positif " << endl; - cout << " Error " << ineg << " triangle negatif " << endl; - cout << " Error " << nbt-ineg-ipos << " triangle nulle " << endl; - nberr++; +const Mesh *MoveTheMesh(const MeshS &Th, const KN_< double > &U, const KN_< double > &V, bool orientation) { + using Fem2D::BoundaryEdge; + using Fem2D::Mesh; + using Fem2D::R2; + using Fem2D::Triangle; + using Fem2D::Vertex; + // using Fem2D::R; + using Fem2D::MeshPointStack; + int nbv = Th.nv; + int nbt = Th.nt; + int neb = Th.nbe; + Vertex *v = new Vertex[nbv]; + Triangle *t = new Triangle[nbt]; + BoundaryEdge *b = new BoundaryEdge[neb]; + Vertex *vv = v; + for (int i = 0; i < nbv; i++) { + R2 P(U[i], V[i]); + vv->x = P.x; + vv->y = P.y; + vv->lab = Th(i).lab; + vv++; } - if(verbosity>2 && rev) cout << " -- movemesh negatif tranfomation => reverse all triangle (old area " << atotal0 << ") ( new area " << atotal << ") "<< endl; - for (int i=0;i1) - { - if (nberr==1) { cerr << "Erreur: MoveMesh "; } - cerr << " T = " << Th[i] << endl; - } - if (nberr < verbosity*5) { - cerr << " " < no move)" << endl; - cout << " u min " << U.min() << " max " << U.max() << endl; - cout << " v min " << V.min() << " max " << V.max() << endl; - - delete []v; - delete []t; - delete []b; - throw(ErrorExec("Error move mesh triangles was reverse",1)); - return 0; + Triangle *tt = t; + int nberr = 0; + double atotal = 0, atotal0 = 0; + double amax = -1e100, amin = 1e100; + int ineg = 0, ipos = 0; + for (int i = 0; i < nbt; i++) { + atotal0 += Th[i].mesure( ); + int i0 = Th(i, 0), i1 = Th(i, 1), i2 = Th(i, 2); + double a = Area2(v[i0], v[i1], v[i2]) / 2; + if (a < 0) + ineg++; + else if (a > 0) + ipos++; + atotal += a; + amax = max(a, amax); + amin = min(a, amin); + } + double eps = 1e-6 * max(abs(atotal), 1e-100) / atotal0; + bool rev = (atotal < 0); + if (ipos + ineg != nbt || (ipos > 0 && ineg > 0)) { + cout << " Error " << ipos << " triangle positif " << endl; + cout << " Error " << ineg << " triangle negatif " << endl; + cout << " Error " << nbt - ineg - ipos << " triangle nulle " << endl; + nberr++; + } + if (verbosity > 2 && rev) cout << " -- movemesh negatif tranfomation => reverse all triangle (old area " << atotal0 << ") ( new area " << atotal << ") " << endl; + for (int i = 0; i < nbt; i++) { + int i0 = Th(i, 0), i1 = Th(i, 1), i2 = Th(i, 2); + if (rev) swap(i1, i2); + R a = Area2(v[i0], v[i1], v[i2]) / 2; + if (a < Th[i].mesure( ) * eps) { + nberr++; + if (verbosity > 1) { + if (nberr == 1) { + cerr << "Erreur: MoveMesh "; + } + cerr << " T = " << Th[i] << endl; } + if (nberr < verbosity * 5) { + cerr << " " << i; + if (nberr % 5) cerr << "\n\t"; + } + } else + (*tt++).set(v, i0, i1, i2, Th[i].lab, a); + } + if (nberr) { + if (verbosity) cerr << "Error movemesh: " << nberr << " triangles was reverse (=> no move)" << endl; + cout << " u min " << U.min( ) << " max " << U.max( ) << endl; + cout << " v min " << V.min( ) << " max " << V.max( ) << endl; + + delete[] v; + delete[] t; + delete[] b; + throw(ErrorExec("Error move mesh triangles was reverse", 1)); + return 0; + } - BoundaryEdge * bb=b; - for (int i=0;iBoundingBox(Pn,Px); - m->quadtree=new Fem2D::FQuadTree(m,Pn,Px,m->nv); - return m; - -} + BoundaryEdge *bb = b; + for (int i = 0; i < neb; i++) { + int i1 = Th(Th.be(i)[0]); + int i2 = Th(Th.be(i)[1]); + int lab = Th.be(i).lab; + if (rev) swap(i1, i2); + *bb++ = BoundaryEdge(v, i1, i2, lab); + } + { + Mesh *m = new Mesh(nbv, nbt, neb, v, t, b); + R2 Pn, Px; + m->BoundingBox(Pn, Px); + m->quadtree = new Fem2D::FQuadTree(m, Pn, Px, m->nv); + return m; + } } // movemesh class Movemesh_OpS2 : public E_F0mps { public: Expression eTh; - Expression X, Y , Z; + Expression X, Y, Z; // Expression lab,reg; static const int n_name_param = 3; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - KN< double >* arg(int i, Stack stack, KN< double > *a) const { - return nargs[i] ? GetAny< KN< double >* >((*nargs[i])(stack)) : a; - } - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + KN< double > *arg(int i, Stack stack, KN< double > *a) const { return nargs[i] ? GetAny< KN< double > * >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: - Movemesh_OpS2(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, Expression zzz = 0) - : eTh(tth), X(xxx), Y(yyy),Z(zzz) { - - // int size; - + Movemesh_OpS2(const basicAC_F0 &args, Expression tth, Expression xxx = 0, Expression yyy = 0, Expression zzz = 0) : eTh(tth), X(xxx), Y(yyy), Z(zzz) { + + // int size; + args.SetNameParam(n_name_param, name_param, nargs); - if( nargs[0]){ - - const E_Array *a = dynamic_cast< const E_Array * >(nargs[0]); - ffassert(a); - //cout << " a size "<< a->size() << endl; - if ( a->size( ) != 2 && a->size( ) != 3 ) { - CompileError("movemesh(Th,transfo=[X,Y],...) need 2 or 3 componates in array ", atype< pmeshS >( )); - } - ffassert(!X && !Y && !Z);// verif X,Y,Z == 0 - X = to< double >((*a)[0]); - Y = to< double >((*a)[1]); - if (a->size( ) == 3 ) - Z=to< double >((*a)[2]); + if (nargs[0]) { + + const E_Array *a = dynamic_cast< const E_Array * >(nargs[0]); + ffassert(a); + // cout << " a size "<< a->size() << endl; + if (a->size( ) != 2 && a->size( ) != 3) { + CompileError("movemesh(Th,transfo=[X,Y],...) need 2 or 3 componates in array ", atype< pmeshS >( )); + } + ffassert(!X && !Y && !Z); // verif X,Y,Z == 0 + X = to< double >((*a)[0]); + Y = to< double >((*a)[1]); + if (a->size( ) == 3) Z = to< double >((*a)[2]); } } @@ -9074,73 +8586,68 @@ class MovemeshS2 : public OneOperator { typedef const MeshS *pmeshS; MovemeshS2( ) : OneOperator(atype< pmesh >( ), atype< pmeshS >( )), cas(0) {} - // MovemeshS2(int) : OneOperator(atype< pmesh >( ), atype< pmeshS >( ), atype< E_Array >( )), cas(1) {} + // MovemeshS2(int) : OneOperator(atype< pmesh >( ), atype< pmeshS >( ), atype< E_Array >( )), cas(1) {} - E_F0 *code(const basicAC_F0 &args) const { - return new Movemesh_OpS2(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new Movemesh_OpS2(args, t[0]->CastTo(args[0])); } }; AnyType Movemesh_OpS2::operator( )(Stack stack) const { - typedef const Mesh *pmesh; - typedef const MeshS *pmeshS; + typedef const Mesh *pmesh; + typedef const MeshS *pmeshS; MeshPoint *mp(MeshPointStack(stack)), mps = *mp; MeshS *pTh = GetAny< MeshS * >((*eTh)(stack)); - bool orientation= arg(2,stack,true); + bool orientation = arg(2, stack, true); ffassert(pTh); MeshPoint *mpp(MeshPointStack(stack)); - MeshS &Th = *pTh; - int nv = Th.nv; - int nt = Th.nt; - KN U(nv),V(nv); - KN *gz=0; - gz = arg(1,stack,gz); - cout << " gz " << gz << endl; - double infini=DBL_MAX; - U=infini; - V=infini; - if(gz) gz->resize(nv); - for (int it=0;itsetP(&Th,it,iv); - if(X) - U[i]=GetAny((*X)(stack)); - else - U[i] = Th[it][iv].x; - if(Y) - V[i]=GetAny((*Y)(stack)); - else - V[i] = Th[it][iv].y; - if(gz ) - { - if(Z) - (*gz)[i]=GetAny((*Z)(stack)); - else - (*gz)[i] = Th[it][iv].z; + MeshS &Th = *pTh; + int nv = Th.nv; + int nt = Th.nt; + KN< double > U(nv), V(nv); + KN< double > *gz = 0; + gz = arg(1, stack, gz); + cout << " gz " << gz << endl; + double infini = DBL_MAX; + U = infini; + V = infini; + if (gz) gz->resize(nv); + for (int it = 0; it < nt; it++) + for (int iv = 0; iv < 3; iv++) { + int i = (Th)(it, iv); + if (U[i] == infini) { // if nuset the set - } - } + mp->setP(&Th, it, iv); + if (X) + U[i] = GetAny< double >((*X)(stack)); + else + U[i] = Th[it][iv].x; + if (Y) + V[i] = GetAny< double >((*Y)(stack)); + else + V[i] = Th[it][iv].y; + if (gz) { + if (Z) + (*gz)[i] = GetAny< double >((*Z)(stack)); + else + (*gz)[i] = Th[it][iv].z; } + } + } - const Mesh *pThr= MoveTheMesh(Th,U,V,orientation); - *mp=mps; - Add2StackOfPtr2FreeRC(stack,pThr); - return SetAny(pThr); + const Mesh *pThr = MoveTheMesh(Th, U, V, orientation); + *mp = mps; + Add2StackOfPtr2FreeRC(stack, pThr); + return SetAny< pmesh >(pThr); } // instance arguments for meshS basicAC_F0::name_and_type Movemesh_OpS2::name_param[] = { - {"transfo", &typeid(E_Array)}, // 0 - {"getZ", &typeid(KN< double >*)}, // 1 - {"orientation", &typeid(bool)} // 2 + {"transfo", &typeid(E_Array)}, // 0 + {"getZ", &typeid(KN< double > *)}, // 1 + {"orientation", &typeid(bool)} // 2 }; template<> @@ -9183,44 +8690,28 @@ class CheckMesh_Op : public E_F0mps { static const int n_name_param = 3; static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } - double arg(int i, Stack stack, double a) const { - return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } public: - CheckMesh_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { - args.SetNameParam(n_name_param, name_param, nargs); - } + CheckMesh_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; template<> -basicAC_F0::name_and_type CheckMesh_Op< Mesh3 >::name_param[] = { - {"precisvertice", &typeid(double)}, - {"removeduplicate", &typeid(bool)}, - {"rebuildboundary", &typeid(bool)} +basicAC_F0::name_and_type CheckMesh_Op< Mesh3 >::name_param[] = {{"precisvertice", &typeid(double)}, {"removeduplicate", &typeid(bool)}, {"rebuildboundary", &typeid(bool)} }; template<> -basicAC_F0::name_and_type CheckMesh_Op< MeshS >::name_param[] = { - {"precisvertice", &typeid(double)}, - {"removeduplicate", &typeid(bool)}, - {"rebuildboundary", &typeid(bool)} +basicAC_F0::name_and_type CheckMesh_Op< MeshS >::name_param[] = {{"precisvertice", &typeid(double)}, {"removeduplicate", &typeid(bool)}, {"rebuildboundary", &typeid(bool)} }; template<> -basicAC_F0::name_and_type CheckMesh_Op< MeshL >::name_param[] = { - {"precisvertice", &typeid(double)}, - {"removeduplicate", &typeid(bool)}, - {"rebuildboundary", &typeid(bool)} - }; - +basicAC_F0::name_and_type CheckMesh_Op< MeshL >::name_param[] = {{"precisvertice", &typeid(double)}, {"removeduplicate", &typeid(bool)}, {"rebuildboundary", &typeid(bool)}}; + template< class MMesh > AnyType CheckMesh_Op< MMesh >::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; @@ -9233,26 +8724,26 @@ AnyType CheckMesh_Op< MMesh >::operator( )(Stack stack) const { bool removeduplicate(arg(1, stack, false)); bool rebuildboundary(arg(2, stack, false)); int orientation = 1; - if (verbosity > 10) - cout << "call cleanmesh function, precis_mesh:" << precis_mesh - << " removeduplicate:" << removeduplicate << endl; + if (verbosity > 10) cout << "call cleanmesh function, precis_mesh:" << precis_mesh << " removeduplicate:" << removeduplicate << endl; // compute number of border elements - int nbet=0; + int nbet = 0; for (int i = 0; i < Th.nt; ++i) { for (int j = 0; j < T::nea; ++j) { int jt = j, it = Th.ElementAdj(i, jt); - if (it == i || it < 0) - nbet++; + if (it == i || it < 0) nbet++; } } - if(verbosity>10) cout << "number of true border elements: " << nbet << " number of given border elements: " << Th.nbe << endl; - if(Th.nbe!=nbet) { - if(!rebuildboundary) cout << " WARNING: incomplete list of true border elements, use argument rebuildboundary=true " << endl; - else {Th.nbe=0;Th.borderelements=0; - if(verbosity>10) cout << "rebuild true border elements: " << endl;} + if (verbosity > 10) cout << "number of true border elements: " << nbet << " number of given border elements: " << Th.nbe << endl; + if (Th.nbe != nbet) { + if (!rebuildboundary) + cout << " WARNING: incomplete list of true border elements, use argument rebuildboundary=true " << endl; + else { + Th.nbe = 0; + Th.borderelements = 0; + if (verbosity > 10) cout << "rebuild true border elements: " << endl; + } } - Th.clean_mesh(precis_mesh, Th.nv, Th.nt, Th.nbe, Th.vertices, Th.elements, Th.borderelements, - removeduplicate, rebuildboundary, orientation); + Th.clean_mesh(precis_mesh, Th.nv, Th.nt, Th.nbe, Th.vertices, Th.elements, Th.borderelements, removeduplicate, rebuildboundary, orientation); *mp = mps; return pTh; @@ -9264,92 +8755,71 @@ class CheckMesh : public OneOperator { typedef const MMesh *ppmesh; CheckMesh( ) : OneOperator(atype< ppmesh >( ), atype< ppmesh >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new CheckMesh_Op< MMesh >(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new CheckMesh_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; template< class MMesh > class RebuildBorder_Op : public E_F0mps { public: - Expression eTh; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - - double arg(int i, Stack stack, double a) const {return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } - bool arg(int i, Stack stack, bool a) const {return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } - - public: - RebuildBorder_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { - args.SetNameParam(n_name_param, name_param, nargs); - } - AnyType operator( )(Stack stack) const; + Expression eTh; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + + double arg(int i, Stack stack, double a) const { return nargs[i] ? GetAny< double >((*nargs[i])(stack)) : a; } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } + + public: + RebuildBorder_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { args.SetNameParam(n_name_param, name_param, nargs); } + AnyType operator( )(Stack stack) const; }; - + template<> -basicAC_F0::name_and_type RebuildBorder_Op< MeshS >::name_param[] = { - {"angle", &typeid(double)}, - {"labeledBoundary", &typeid(bool)} -}; - +basicAC_F0::name_and_type RebuildBorder_Op< MeshS >::name_param[] = {{"angle", &typeid(double)}, {"labeledBoundary", &typeid(bool)}}; + template<> -basicAC_F0::name_and_type RebuildBorder_Op< MeshL >::name_param[] = { - {"angle", &typeid(double)}, - {"labeledBoundary", &typeid(bool)} -}; - +basicAC_F0::name_and_type RebuildBorder_Op< MeshL >::name_param[] = {{"angle", &typeid(double)}, {"labeledBoundary", &typeid(bool)}}; + template< class MMesh > AnyType RebuildBorder_Op< MMesh >::operator( )(Stack stack) const { MeshPoint *mp(MeshPointStack(stack)), mps = *mp; - + MMesh *pTh = GetAny< MMesh * >((*eTh)(stack)); MMesh &Th = *pTh; ffassert(pTh); - double angle(arg(0, stack, 8.*atan(1.)/9.)); - bool labeledBoundary(arg(1, stack,false)); - int nbe_back= Th.nbe;Th.nbe=0; + double angle(arg(0, stack, 8. * atan(1.) / 9.)); + bool labeledBoundary(arg(1, stack, false)); + int nbe_back = Th.nbe; + Th.nbe = 0; Th.BuildBdElem(labeledBoundary, angle); - Th.BuildGTree(); - if (verbosity > 10) - cout << "RebuildBorder function, before nbe: " <size( ); + int size = a1->size( ); xx = to< double >((*a1)[0]); - if(size>1) yy = to< double >((*a1)[1]); - if(size>2) zz = to< double >((*a1)[2]); + if (size > 1) yy = to< double >((*a1)[1]); + if (size > 2) zz = to< double >((*a1)[2]); } } } @@ -9369,13 +8839,8 @@ class Line_Op : public E_F0mps { }; basicAC_F0::name_and_type Line_Op::name_param[] = { - {"orientation", &typeid(long)}, - {"cleanmesh", &typeid(bool)}, - {"removeduplicate", &typeid(bool)}, - {"precismesh", &typeid(double)}, - {"label", &typeid(KN_)}, - {"region", &typeid(long)} - + {"orientation", &typeid(long)}, {"cleanmesh", &typeid(bool)}, {"removeduplicate", &typeid(bool)}, {"precismesh", &typeid(double)}, + {"label", &typeid(KN_< long >)}, {"region", &typeid(long)} // {"rebuildboundary", &typeid(double)} }; @@ -9410,18 +8875,19 @@ AnyType Line_Op::operator( )(Stack stack) const { int nv = nt + 1, nbe = 2; long orientation(arg(0, stack, 1L)); bool cleanmesh(arg(1, stack, true)); - if(nt==1) cleanmesh=false; + if (nt == 1) cleanmesh = false; long removeduplicate(arg(2, stack, false)); double precis_mesh(arg(3, stack, 1e-7)); - KN lab(2); - lab[0]=1; lab[1]=2; - long reg = arg(5,stack,0L); - lab=arg(4,stack,lab); + KN< long > lab(2); + lab[0] = 1; + lab[1] = 2; + long reg = arg(5, stack, 0L); + lab = arg(4, stack, lab); // cout << " lab =" << lab << endl; - ffassert(lab.N()==2) ;// erif 2 lab .. - bool rebuildboundary=false; //(arg(4, stack, false)); - + ffassert(lab.N( ) == 2); // erif 2 lab .. + bool rebuildboundary = false; //(arg(4, stack, false)); + V *v = new V[nv]; T *t = new T[nt]; B *b = new B[nbe]; @@ -9432,9 +8898,6 @@ AnyType Line_Op::operator( )(Stack stack) const { vv[i].y = P.y; vv[i].z = P.z; vv[i].lab = 0; - - - mpp->set(vv[i].x, vv[i].y, vv[i].z); if (xx) @@ -9450,15 +8913,15 @@ AnyType Line_Op::operator( )(Stack stack) const { else vv[i].z = mpp->P.z; } - vv[0].lab = lab[0]; - vv[nv-1].lab = lab[1]; + vv[0].lab = lab[0]; + vv[nv - 1].lab = lab[1]; T *tt = t; for (int i = 0; i < nt; ++i) { int iv[2]; iv[0] = i, iv[1] = i + 1; int lab = 0; - (tt++)->set(v, iv, reg);// correct 6 oct 2023 FH.. + (tt++)->set(v, iv, reg); // correct 6 oct 2023 FH.. } B *bb = b; int ibeg[1], iend[1]; @@ -9467,8 +8930,7 @@ AnyType Line_Op::operator( )(Stack stack) const { (bb++)->set(v, ibeg, lab1); (bb++)->set(v, iend, lab2); - MeshL *ThL = new MeshL(nv, nt, nbe, v, t, b, cleanmesh, removeduplicate, - rebuildboundary, orientation, precis_mesh); + MeshL *ThL = new MeshL(nv, nt, nbe, v, t, b, cleanmesh, removeduplicate, rebuildboundary, orientation, precis_mesh); ThL->BuildGTree( ); Add2StackOfPtr2FreeRC(stack, ThL); @@ -9477,7 +8939,7 @@ AnyType Line_Op::operator( )(Stack stack) const { return ThL; } -template +template< class MMesh > class OrientNormal_Op : public E_F0mps { public: Expression eTh; @@ -9485,43 +8947,35 @@ class OrientNormal_Op : public E_F0mps { static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - bool arg(int i, Stack stack, bool a) const { - return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; - } + bool arg(int i, Stack stack, bool a) const { return nargs[i] ? GetAny< bool >((*nargs[i])(stack)) : a; } public: - OrientNormal_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { - args.SetNameParam(n_name_param, name_param, nargs); - } + OrientNormal_Op(const basicAC_F0 &args, Expression tth) : eTh(tth) { args.SetNameParam(n_name_param, name_param, nargs); } AnyType operator( )(Stack stack) const; }; -inline double SolidAngle(const Fem2D::R3& p, const EdgeL& e){ +inline double SolidAngle(const Fem2D::R3 &p, const EdgeL &e) { double M[2][2]; - for(int j=0; j<2; j++) - for(int k=0;k<2;k++) - M[j][k] = e[k][j] - p[j]; - return (1./2)*( M[0][0]*M[1][1]-M[1][0]*M[0][1] ); + for (int j = 0; j < 2; j++) + for (int k = 0; k < 2; k++) M[j][k] = e[k][j] - p[j]; + return (1. / 2) * (M[0][0] * M[1][1] - M[1][0] * M[0][1]); } -inline double SolidAngle(const Fem2D::R3& p, const TriangleS& e){ +inline double SolidAngle(const Fem2D::R3 &p, const TriangleS &e) { double M[3][3]; - for(int j=0; j<3; j++) - for(int k=0;k<3;k++) - M[j][k] = e[k][j] - p[j]; - return (-1./6)*( M[0][0]*( M[1][1]*M[2][2]-M[2][1]*M[1][2] ) - - M[0][1]*( M[1][0]*M[2][2]-M[2][0]*M[1][2] ) - + M[0][2]*( M[1][0]*M[2][1]-M[2][0]*M[1][1] ) ); + for (int j = 0; j < 3; j++) + for (int k = 0; k < 3; k++) M[j][k] = e[k][j] - p[j]; + return (-1. / 6) * (M[0][0] * (M[1][1] * M[2][2] - M[2][1] * M[1][2]) - M[0][1] * (M[1][0] * M[2][2] - M[2][0] * M[1][2]) + M[0][2] * (M[1][0] * M[2][1] - M[2][0] * M[1][1])); } -template -basicAC_F0::name_and_type OrientNormal_Op::name_param[] = { +template< class MMesh > +basicAC_F0::name_and_type OrientNormal_Op< MMesh >::name_param[] = { {"unbounded", &typeid(bool)}, }; -template -void ComputeOrientation(const Mesh& Th, std::vector& orientation, bool unbounded) { +template< class Mesh > +void ComputeOrientation(const Mesh &Th, std::vector< bool > &orientation, bool unbounded) { typedef typename Mesh::RdHat RdHat; typedef typename Mesh::Element T; @@ -9530,51 +8984,54 @@ void ComputeOrientation(const Mesh& Th, std::vector& orientation, bool unb // de chaque composante. // num[j][k] est le no du k ieme elt du // la composante no. j - std::vector< std::vector > num; + std::vector< std::vector< int > > num; int nbc = 1; num.resize(nbc); int nb_visited = 0; - std::queue visit; - int nbelt = Th.nt; - std::vector visited(nbelt,false); + std::queue< int > visit; + int nbelt = Th.nt; + std::vector< bool > visited(nbelt, false); // Initialisation de l'algo int j0 = 0; visit.push(j0); - visited[j0]=true; + visited[j0] = true; nb_visited++; - num[nbc-1].push_back(j0); + num[nbc - 1].push_back(j0); // Lancement de l'algo - while(nb_visited& orientation, bool unb // int nbelt = Th.nt; int nt = Th.nt; bool ok = true; - orientation.resize(nbelt,ok); - std::fill(visited.begin(),visited.end(),false); - std::vector global_orientation(nbc); + orientation.resize(nbelt, ok); + std::fill(visited.begin( ), visited.end( ), false); + std::vector< double > global_orientation(nbc); // std::vector visited(nbelt,false); //==================================== // initialisation de la recherche // d'un point extremal du maillage - int Iext = 0; - RdHat bary = RdHat::diag(1./(RdHat::d+1)); - double Ext = Th[0](bary).norme2(); + int Iext = 0; + RdHat bary = RdHat::diag(1. / (RdHat::d + 1)); + double Ext = Th[0](bary).norme2( ); //===============================// // Breadth First Search sur // // chaque composante connexe // //===============================// - for(int I=0; I visit; + std::queue< int > visit; int j0 = num[I][0]; visit.push(j0); - visited[j0]=true; + visited[j0] = true; - while(nb_visited < nbe){ + while (nb_visited < nbe) { - j0 = visit.front(); + j0 = visit.front( ); const T &K(Th[j0]); - visit.pop(); + visit.pop( ); nb_visited++; - if( K(bary).norme2() > Ext){ - Ext = K(bary).norme2(); + if (K(bary).norme2( ) > Ext) { + Ext = K(bary).norme2( ); Iext = I; } - for(int k0=0; k0& orientation, bool unb // orientation[j] = !orientation[j]; // } - if(global_orientation[I] > 0){ - for(int j=0; j 0) { + for (int j = 0; j < nbe; j++) { j0 = num[I][j]; orientation[j0] = !orientation[j0]; } @@ -9672,23 +9134,23 @@ void ComputeOrientation(const Mesh& Th, std::vector& orientation, bool unb // Si le domaine est borne la // composante exterieure du bord // doit etre orientee dans l'autre sens - if(!unbounded){ - for(int j=0; j -AnyType OrientNormal_Op::operator( )(Stack stack) const { +template< class MMesh > +AnyType OrientNormal_Op< MMesh >::operator( )(Stack stack) const { typedef typename MMesh::Element T; typedef typename MMesh::BorderElement B; typedef typename MMesh::Vertex V; MeshPoint *mp(MeshPointStack(stack)), mps = *mp; MMesh *pTh = GetAny< MMesh * >((*eTh)(stack)); - if( !pTh) return pTh; // + if (!pTh) return pTh; // MMesh &Th = *pTh; ffassert(pTh); @@ -9705,8 +9167,7 @@ AnyType OrientNormal_Op::operator( )(Stack stack) const { B *bb = b; double mes = 0, mesb = 0; - if (verbosity > 5) - cout << "copy the original mesh ... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; + if (verbosity > 5) cout << "copy the original mesh ... nv= " << nv << " nt= " << nt << " nbe= " << nbe << endl; for (int i = 0; i < nv; i++) { const V &K(Th.vertices[i]); @@ -9716,7 +9177,7 @@ AnyType OrientNormal_Op::operator( )(Stack stack) const { v[i].lab = K.lab; } - std::vector orientation; + std::vector< bool > orientation; ComputeOrientation(Th, orientation, unbounded); //===================================== // Add elements, with correct orientation @@ -9730,10 +9191,9 @@ AnyType OrientNormal_Op::operator( )(Stack stack) const { iv[jj] = Th.operator( )(K[jj]); assert(iv[jj] >= 0 && iv[jj] < nv); } - if (!orientation[i]) - swap(iv[0], iv[1]); + if (!orientation[i]) swap(iv[0], iv[1]); (tt)->set(v, iv, lab); - mes += tt++->mesure(); + mes += tt++->mesure( ); } for (int i = 0; i < nbe; i++) { @@ -9750,20 +9210,18 @@ AnyType OrientNormal_Op::operator( )(Stack stack) const { MMesh *Th_t = new MMesh(nv, nt, nbe, v, t, b); Th_t->BuildGTree( ); - //Th_t->BuildMeshL( ); + // Th_t->BuildMeshL( ); *mp = mps; Add2StackOfPtr2FreeRC(stack, Th_t); return Th_t; } -template +template< class MMesh > class OrientNormal : public OneOperator { public: - OrientNormal( ) : OneOperator(atype< const MMesh* >( ), atype< const MMesh* >( )) {} + OrientNormal( ) : OneOperator(atype< const MMesh * >( ), atype< const MMesh * >( )) {} - E_F0 *code(const basicAC_F0 &args) const { - return new OrientNormal_Op(args, t[0]->CastTo(args[0])); - } + E_F0 *code(const basicAC_F0 &args) const { return new OrientNormal_Op< MMesh >(args, t[0]->CastTo(args[0])); } }; #ifndef WITH_NO_INIT @@ -9771,8 +9229,8 @@ class OrientNormal : public OneOperator { // <> static void Load_Init_msh3( ) { - typedef listMeshT listMeshL; - typedef listMeshT listMeshS; + typedef listMeshT< MeshL > listMeshL; + typedef listMeshT< MeshS > listMeshS; Dcl_Type< listMesh3 >( ); Dcl_Type< listMeshS >( ); @@ -9782,7 +9240,6 @@ static void Load_Init_msh3( ) { typedef const MeshS *pmeshS; typedef const MeshL *pmeshL; - if (verbosity > 1 && mpirank == 0) { cout << " init msh3 " << endl; } @@ -9790,10 +9247,8 @@ static void Load_Init_msh3( ) { // operators for Mesh3 TheOperators->Add("+", new OneBinaryOperator_st< Op3_addmesh< listMesh3, pmesh3, pmesh3 > >); TheOperators->Add("+", new OneBinaryOperator_st< Op3_addmesh< listMesh3, listMesh3, pmesh3 > >); - TheOperators->Add( - "=", new OneBinaryOperator_st< Op3_setmesh< false, pmesh3 *, pmesh3 *, listMesh3 > >); - TheOperators->Add("<-", - new OneBinaryOperator_st< Op3_setmesh< true, pmesh3 *, pmesh3 *, listMesh3 > >); + TheOperators->Add("=", new OneBinaryOperator_st< Op3_setmesh< false, pmesh3 *, pmesh3 *, listMesh3 > >); + TheOperators->Add("<-", new OneBinaryOperator_st< Op3_setmesh< true, pmesh3 *, pmesh3 *, listMesh3 > >); Global.Add("deplacement", "(", new DeplacementTab); // movemesh ? Global.Add("checkbemesh", "(", new CheckManifoldMesh); // ?? @@ -9801,16 +9256,14 @@ static void Load_Init_msh3( ) { Global.Add("trunc", "(", new Op_trunc_mesh3); Global.Add("gluemesh", "(", new Op_GluMesh3tab); - Global.Add("gluemesh", "(", new Op_GluMeshTtab); - Global.Add("gluemesh", "(", new Op_GluMeshTtab); - Global.Add("extract", "(",new ExtractMesh< Mesh3, MeshS >); // take a Mesh3 in arg and return a part of MeshS + Global.Add("gluemesh", "(", new Op_GluMeshTtab< MeshL >); + Global.Add("gluemesh", "(", new Op_GluMeshTtab< MeshS >); + Global.Add("extract", "(", new ExtractMesh< Mesh3, MeshS >); // take a Mesh3 in arg and return a part of MeshS // for a mesh3 Th3, if Th3->meshS=NULL, build the meshS associated Global.Add("buildBdMesh", "(", new BuildMeshSFromMesh3); - - Global.Add( - "AddLayers", "(", - new OneOperator4_< bool, const Mesh3 *, KN< double > *, long, KN< double > * >(AddLayers)); + + Global.Add("AddLayers", "(", new OneOperator4_< bool, const Mesh3 *, KN< double > *, long, KN< double > * >(AddLayers< Mesh3 >)); Global.Add("bcube", "(", new cubeMesh); Global.Add("bcube", "(", new cubeMesh(1)); @@ -9823,7 +9276,7 @@ static void Load_Init_msh3( ) { TheOperators->Add("=", new OneBinaryOperator_st< Op3_setmeshS< false, pmeshS *, pmeshS *, listMeshS > >); TheOperators->Add("<-", new OneBinaryOperator_st< Op3_setmeshS< true, pmeshS *, pmeshS *, listMeshS > >); // operators for MeshL - + TheOperators->Add("+", new OneBinaryOperator_st< Op3_addmeshL< listMeshL, pmeshL, pmeshL > >); TheOperators->Add("+", new OneBinaryOperator_st< Op3_addmeshL< listMeshL, listMeshL, pmeshL > >); TheOperators->Add("=", new OneBinaryOperator_st< Op3_setmeshL< false, pmeshL *, pmeshL *, listMeshL > >); @@ -9835,15 +9288,15 @@ static void Load_Init_msh3( ) { Global.Add("showborder", "(", new OneOperator1< long, const MeshS * >(ShowBorder)); Global.Add("getborder", "(", new OneOperator2< long, const MeshS *, KN< long > * >(GetBorder)); - Global.Add("AddLayers", "(", new OneOperator4_< bool, const MeshS *, KN< double > *, long, KN< double > * >(AddLayers)); - Global.Add("AddLayers", "(", new OneOperator4_< bool, const MeshL *, KN< double > *, long, KN< double > * >(AddLayers)); - + Global.Add("AddLayers", "(", new OneOperator4_< bool, const MeshS *, KN< double > *, long, KN< double > * >(AddLayers< MeshS >)); + Global.Add("AddLayers", "(", new OneOperator4_< bool, const MeshL *, KN< double > *, long, KN< double > * >(AddLayers< MeshL >)); + Global.Add("square3", "(", new Square); Global.Add("square3", "(", new Square(1)); Global.Add("movemeshL", "(", new Movemesh< MeshL >); Global.Add("movemesh", "(", new Movemesh< MeshL >(1)); - + Global.Add("movemeshS", "(", new Movemesh< MeshS >); Global.Add("movemesh", "(", new Movemesh< MeshS >(1)); @@ -9853,9 +9306,8 @@ static void Load_Init_msh3( ) { Global.Add("movemesh23", "(", new Movemesh< Mesh >); // Global.Add("movemesh", "(", new Movemesh(1)); // Global.Add("movemesh", "(", new MovemeshS2(1)); genere un ambiguete on vide ... - Global.Add("movemesh", "(", new MovemeshS2); + Global.Add("movemesh", "(", new MovemeshS2); - Global.Add("change", "(", new SetMesh< MeshL >); Global.Add("change", "(", new SetMesh< MeshS >); Global.Add("change", "(", new SetMesh< Mesh3 >); @@ -9869,29 +9321,26 @@ static void Load_Init_msh3( ) { Global.Add("Sline", "(", new Line); Global.Add("Sline", "(", new Line(1)); - + Global.Add("buildBdMesh", "(", new BuildMeshLFromMeshS); Global.Add("extract", "(", new ExtractMesh< MeshS, MeshL >); // take a MeshS in arg and return a part of MeshL - Global.Add("extract", "(", new ExtractMeshLfromMesh); // take a Mesh in arg and return a part of MeshL - Global.Add("extract", "(", new ExtractMeshLfromMesh(1)); - - Global.Add("OrientNormal", "(", new OrientNormal); - Global.Add("OrientNormal", "(", new OrientNormal); - - Global.Add("rebuildBorder", "(", new RebuildBorder); - Global.Add("rebuildBorder", "(", new RebuildBorder); - + Global.Add("extract", "(", new ExtractMeshLfromMesh); // take a Mesh in arg and return a part of MeshL + Global.Add("extract", "(", new ExtractMeshLfromMesh(1)); + + Global.Add("OrientNormal", "(", new OrientNormal< MeshS >); + Global.Add("OrientNormal", "(", new OrientNormal< MeshL >); + + Global.Add("rebuildBorder", "(", new RebuildBorder< MeshS >); + Global.Add("rebuildBorder", "(", new RebuildBorder< MeshL >); } // <> static loading: calling Load_Init() from a function which is accessible from // [[file:~/ff/src/fflib/load.cpp::static_load_msh3]] -void msh3_Load_Init( ) { - Load_Init_msh3( ); -} +void msh3_Load_Init( ) { Load_Init_msh3( ); } // dynamic loading: calling [[file:../src/fflib/InitFunct.hpp::LOADFUNC]] on [[Load_Init]] -//LOADFUNC(Load_Init_msh3) +// LOADFUNC(Load_Init_msh3) #endif // [[WITH_NO_INIT]] diff --git a/src/fflib/msh3.hpp b/src/fflib/msh3.hpp index f7a227e80..2e0f46944 100644 --- a/src/fflib/msh3.hpp +++ b/src/fflib/msh3.hpp @@ -33,11 +33,8 @@ using namespace std; /* avant TransfoMesh_v2.cpp */ -void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin); -void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, - double &hmin); +void BuildBoundMinDist_th2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, R3 &bmin, R3 &bmax, double &hmin); +void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, R3 &bmin, R3 &bmax, double &hmin); // void BuildBoundMinDist_thS (const double &precis_mesh, const double *tab_XX, const double // *tab_YY, const double *tab_ZZ, const MeshS &ThS, R3 &bmin, R3 &bmax, double &hmin); @@ -47,10 +44,8 @@ void BuildBoundMinDist_th3(const double &precis_mesh, const double *tab_XX, cons // double **Coord_Point, // const double *bmin, const double *bmax, const double hmin, int *ind_np, // int &np); -void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, - double **Coord_Point, const int *label_point, const R3 &bmin, - const R3 &bmax, const double &hmin, int *ind_np, int *ind_label, - int &np); +void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &point_confondus_ok, double **Coord_Point, const int *label_point, const R3 &bmin, const R3 &bmax, const double &hmin, + int *ind_np, int *ind_label, int &np); // void OrderVertexTransfo_base(const double *tab_XX, const double *tab_YY, const double *tab_ZZ, // const Mesh3 & Th3, int *Numero_Som, int * ind_nv_t, int & nv_t ); @@ -59,33 +54,21 @@ void PointCommun_hcode_gtree(const int &dim, const int &NbPoints, const int &poi // const double *bmin, const double *bmax, const double hmin, int // *Numero_Som, int *ind_nv_t, int &nv_t); -void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, - const double &hmin, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int *Numero_Som, +void OrderVertexTransfo_hcode_nv_gtree(const int &tab_nv, const R3 &bmin, const R3 &bmax, const double &hmin, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int *Numero_Som, int *ind_nv_t, int &nv_t); // 3D volume -void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, - int &recollement_border, int &point_confondus_ok, int *Numero_Som, - int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, - int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); - -Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_element, int &recollement_border, int &point_confondus_ok, - int orientation); - -void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, - const double *tab_ZZ, const Mesh &Th2, int &recollement_border, - int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, - int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, - int &nbe_t); +void SamePointElement(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh3 &Th3, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); + +Mesh3 *Transfo_Mesh3(const double &precis_mesh, const Mesh3 &Th3, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_element, int &recollement_border, + int &point_confondus_ok, int orientation); + +void SamePointElement_Mesh2(const double &precis_mesh, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, const Mesh &Th2, int &recollement_border, int &point_confondus_ok, + int *Numero_Som, int *ind_nv_t, int *ind_nt_t, int *ind_nbe_t, int *label_nt_t, int *label_nbe_t, int &nv_t, int &nt_t, int &nbe_t); void Transfo_Mesh2_map_face(const Mesh &Th2, map< int, int > &maptri); -MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, - const double *tab_YY, const double *tab_ZZ, int &border_only, - int &recollement_border, int &point_confondus_ok); +MeshS *MoveMesh2_func(const double &precis_mesh, const Mesh &Th2, const double *tab_XX, const double *tab_YY, const double *tab_ZZ, int &border_only, int &recollement_border, int &point_confondus_ok); /* avant LayerMesh.cpp */ void recollement_maillage_mesh(const int Nmax, const int N, int *tab_recollement); @@ -95,49 +78,31 @@ double zmin_func_mesh(const int choix, const double x, const double y); double zmax_func_mesh(const int choix, const double x, const double y); int Ni_func_mesh(const int choix, const double x, const double y); -void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, - double *tab_zmax, int *tab_Ni); +void tab_zmin_zmax_Ni_mesh(const int choix, const Mesh &Th2, int &Nmax, double *tab_zmin, double *tab_zmax, int *tab_Ni); void Tet_mesh3_mes_neg(Mesh3 &Th3); void build_layer_map_tetrahedra(const Mesh &Th2, map< int, int > &maptet); -void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, - map< int, int > &maptrizmax, map< int, int > &maptrizmin); -void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, - map< int, int > &mapezmin); - -void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, - const Mesh &Th, int &MajSom, int &MajElem, - int &MajBord2D); - -void Som3D_mesh_product_Version_Sommet_mesh_tab( - const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, - const Mesh &Th2, const map< int, int > &maptet, const map< int, int > &maptrimil, - const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, - const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin, - Mesh3 &Th3); - -void transformation_2D_3D_maillage_mesh_tab(const Mesh &Th2, const int Nmax, const int *tab_Ni, - const double *tab_zmin, const double *tab_zmax, - Mesh3 &Th3); - -Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, - const double *tab_zmax, const map< int, int > &maptet, - const map< int, int > &maptrimil, const map< int, int > &maptrizmax, - const map< int, int > &maptrizmin, const map< int, int > &mapemil, - const map< int, int > &mapezmax, const map< int, int > &mapezmin); +void build_layer_map_triangle(const Mesh &Th2, map< int, int > &maptrimil, map< int, int > &maptrizmax, map< int, int > &maptrizmin); +void build_layer_map_edge(const Mesh &Th2, map< int, int > &mapemil, map< int, int > &mapezmax, map< int, int > &mapezmin); + +void NbSom3D_NbElem3D_NbBord2D_mesh_product_mesh_tab(const int Nmax, const int *tab_Ni, const Mesh &Th, int &MajSom, int &MajElem, int &MajBord2D); + +void Som3D_mesh_product_Version_Sommet_mesh_tab(const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const Mesh &Th2, const map< int, int > &maptet, + const map< int, int > &maptrimil, const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, + const map< int, int > &mapezmax, const map< int, int > &mapezmin, Mesh3 &Th3); + +void transformation_2D_3D_maillage_mesh_tab(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, Mesh3 &Th3); + +Mesh3 *build_layer(const Mesh &Th2, const int Nmax, const int *tab_Ni, const double *tab_zmin, const double *tab_zmax, const map< int, int > &maptet, const map< int, int > &maptrimil, + const map< int, int > &maptrizmax, const map< int, int > &maptrizmin, const map< int, int > &mapemil, const map< int, int > &mapezmax, const map< int, int > &mapezmin); // add 04/01/09 -void TestSameVertexMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nv_t, int *Numero_Som); -void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nt_t); -void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int *Elem_ok, int &nt_t); -void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int &nbe_t); -void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, - int *Border_ok, int &nbe_t); +void TestSameVertexMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nv_t, int *Numero_Som); +void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nt_t); +void TestSameTetrahedraMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int *Elem_ok, int &nt_t); +void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int &nbe_t); +void TestSameTriangleMesh3(const Mesh3 &Th3, const double &hseuil, const R3 &Psup, const R3 &Pinf, int *Border_ok, int &nbe_t); int TestElementMesh3(const Mesh3 &Th3); Mesh3 *TestElementMesh3_patch(const Mesh3 &Th3); diff --git a/src/fflib/mt19937ar.cpp b/src/fflib/mt19937ar.cpp index 3fbc4a954..09c8e2a9b 100644 --- a/src/fflib/mt19937ar.cpp +++ b/src/fflib/mt19937ar.cpp @@ -1,12 +1,12 @@ -/* +/* A C-program for MT19937, with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto. - Before using, initialize the state by using init_genrand(seed) + Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -19,8 +19,8 @@ notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -43,7 +43,7 @@ #include -/* Period parameters */ +/* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0dfUL /* constant vector a */ @@ -51,124 +51,119 @@ #define LOWER_MASK 0x7fffffffUL /* least significant r bits */ static unsigned long mt[N]; /* the array for the state vector */ -static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ +static int mti = N + 1; /* mti==N+1 means mt[N] is not initialized */ /* initializes mt[N] with a seed */ -void init_genrand(unsigned long s) -{ - mt[0]= s & 0xffffffffUL; - for (mti=1; mti> 30)) + mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - mt[mti] &= 0xffffffffUL; - /* for >32 bit machines */ - } +void init_genrand(unsigned long s) { + mt[0] = s & 0xffffffffUL; + for (mti = 1; mti < N; mti++) { + mt[mti] = (1812433253UL * (mt[mti - 1] ^ (mt[mti - 1] >> 30)) + mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + mt[mti] &= 0xffffffffUL; + /* for >32 bit machines */ + } } /* initialize by an array with array-length */ /* init_key is the array for initializing keys */ /* key_length is its length */ /* slight change for C++, 2004/2/26 */ -void init_by_array(unsigned long init_key[], int key_length) -{ - int i, j, k; - init_genrand(19650218UL); - i=1; j=0; - k = (N>key_length ? N : key_length); - for (; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) - + init_key[j] + j; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; j++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - if (j>=key_length) j=0; +void init_by_array(unsigned long init_key[], int key_length) { + int i, j, k; + init_genrand(19650218UL); + i = 1; + j = 0; + k = (N > key_length ? N : key_length); + for (; k; k--) { + mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL)) + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; + j++; + if (i >= N) { + mt[0] = mt[N - 1]; + i = 1; } - for (k=N-1; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - - i; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } + if (j >= key_length) j = 0; + } + for (k = N - 1; k; k--) { + mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1566083941UL)) - i; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; + if (i >= N) { + mt[0] = mt[N - 1]; + i = 1; } + } - mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ } /* generates a random number on [0,0xffffffff]-interval */ -unsigned long genrand_int32(void) -{ - unsigned long y; - static unsigned long mag01[2]={0x0UL, MATRIX_A}; - /* mag01[x] = x * MATRIX_A for x=0,1 */ - - if (mti >= N) { /* generate N words at one time */ - int kk; - - if (mti == N+1) /* if init_genrand() has not been called, */ - init_genrand(5489UL); /* a default initial seed is used */ - - for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; - } - for (;kk> 1) ^ mag01[y & 0x1UL]; - } - y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; - - mti = 0; +unsigned long genrand_int32(void) { + unsigned long y; + static unsigned long mag01[2] = {0x0UL, MATRIX_A}; + /* mag01[x] = x * MATRIX_A for x=0,1 */ + + if (mti >= N) { /* generate N words at one time */ + int kk; + + if (mti == N + 1) /* if init_genrand() has not been called, */ + init_genrand(5489UL); /* a default initial seed is used */ + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + M] ^ (y >> 1) ^ mag01[y & 0x1UL]; + } + for (; kk < N - 1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK); + mt[kk] = mt[kk + (M - N)] ^ (y >> 1) ^ mag01[y & 0x1UL]; } - - y = mt[mti++]; + y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N - 1] = mt[M - 1] ^ (y >> 1) ^ mag01[y & 0x1UL]; - /* Tempering */ - y ^= (y >> 11); - y ^= (y << 7) & 0x9d2c5680UL; - y ^= (y << 15) & 0xefc60000UL; - y ^= (y >> 18); + mti = 0; + } - return y; + y = mt[mti++]; + + /* Tempering */ + y ^= (y >> 11); + y ^= (y << 7) & 0x9d2c5680UL; + y ^= (y << 15) & 0xefc60000UL; + y ^= (y >> 18); + + return y; } /* generates a random number on [0,0x7fffffff]-interval */ -long genrand_int31(void) -{ - return (long)(genrand_int32()>>1); -} +long genrand_int31(void) { return (long)(genrand_int32( ) >> 1); } /* generates a random number on [0,1]-real-interval */ -double genrand_real1(void) -{ - return genrand_int32()*(1.0/4294967295.0); - /* divided by 2^32-1 */ +double genrand_real1(void) { + return genrand_int32( ) * (1.0 / 4294967295.0); + /* divided by 2^32-1 */ } /* generates a random number on [0,1)-real-interval */ -double genrand_real2(void) -{ - return genrand_int32()*(1.0/4294967296.0); - /* divided by 2^32 */ +double genrand_real2(void) { + return genrand_int32( ) * (1.0 / 4294967296.0); + /* divided by 2^32 */ } /* generates a random number on (0,1)-real-interval */ -double genrand_real3(void) -{ - return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); - /* divided by 2^32 */ +double genrand_real3(void) { + return (((double)genrand_int32( )) + 0.5) * (1.0 / 4294967296.0); + /* divided by 2^32 */ } /* generates a random number on [0,1) with 53-bit resolution*/ -double genrand_res53(void) -{ - unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; - return(a*67108864.0+b)*(1.0/9007199254740992.0); -} +double genrand_res53(void) { + unsigned long a = genrand_int32( ) >> 5, b = genrand_int32( ) >> 6; + return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0); +} /* These real versions are due to Isaku Wada, 2002/01/09 added */ /* int main(void) diff --git a/src/fflib/problem.cpp b/src/fflib/problem.cpp index b95ce9470..557a38418 100644 --- a/src/fflib/problem.cpp +++ b/src/fflib/problem.cpp @@ -25,14 +25,14 @@ along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include using namespace std; #include "rgraph.hpp" #include "error.hpp" #include "AFunction.hpp" -//#include "lex.hpp" +// #include "lex.hpp" #include "HashMatrix.hpp" #include "SparseLinearSolver.hpp" @@ -44,13465 +44,12121 @@ using namespace std; #include "problem.hpp" #include -basicAC_F0::name_and_type CDomainOfIntegration::name_param[]= { - { "qft", &typeid(const Fem2D::QuadratureFormular *)}, - { "qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, - { "qforder",&typeid(long)}, - { "qfnbpT",&typeid(long)}, - { "qfnbpE",&typeid(long)}, - { "optimize",&typeid(long)}, - { "binside",&typeid(double)}, - { "mortar",&typeid(bool)}, - { "qfV", &typeid(const Fem2D::GQuadratureFormular *)}, - { "levelset",&typeid(double)}, - { "mapt",&typeid(E_Array)}, - { "mapu",&typeid(E_Array)} +basicAC_F0::name_and_type CDomainOfIntegration::name_param[] = {{"qft", &typeid(const Fem2D::QuadratureFormular *)}, + {"qfe", &typeid(const Fem2D::QuadratureFormular1d *)}, + {"qforder", &typeid(long)}, + {"qfnbpT", &typeid(long)}, + {"qfnbpE", &typeid(long)}, + {"optimize", &typeid(long)}, + {"binside", &typeid(double)}, + {"mortar", &typeid(bool)}, + {"qfV", &typeid(const Fem2D::GQuadratureFormular< R3 > *)}, + {"levelset", &typeid(double)}, + {"mapt", &typeid(E_Array)}, + {"mapu", &typeid(E_Array)} - -}; - -basicAC_F0::name_and_type Problem::name_param[]= { - { "save",&typeid(string* )}, - { "cadna",&typeid(KN*)}, - { "bmat",&typeid(Matrice_Creuse* )}, - LIST_NAME_PARM_MAT - /* - { "init", &typeid(bool)}, - { "solver", &typeid(TypeSolveMat*)}, - { "eps", &typeid(double) }, - { "precon",&typeid(Polymorphic*)}, - { "dimKrylov",&typeid(long)}, - { "bmat",&typeid(Matrice_Creuse* )}, - { "tgv",&typeid(double )}, - { "strategy",&typeid(long )}, - { "save",&typeid(string* )}, - { "cadna",&typeid(KN*)}, - { "tolpivot", &typeid(double)}, - { "tolpivotsym", &typeid(double)}, - { "nbiter", &typeid(long)}, // 12 - { "paramint",&typeid(KN_)}, // Add J. Morice 02/09 - { "paramdouble",&typeid(KN_)}, - { "paramstring",&typeid(string *)}, - { "permrow",&typeid(KN_)}, - { "permcol",&typeid(KN_)}, - { "fileparamint",&typeid(string*)}, // Add J. Morice 02/09 - { "fileparamdouble",&typeid(string*)}, - { "fileparamstring",&typeid(string* )}, - { "filepermrow",&typeid(string*)}, - { "filepermcol",&typeid(string*)} //22 - */ - ,// param for bem solver - LIST_NAME_PARM_HMAT }; -struct pair_stack_double -{ - Stack first; - double *second; - pair_stack_double(Stack ss,double* bb) : first(ss),second(bb) {}; - +basicAC_F0::name_and_type Problem::name_param[] = {{"save", &typeid(string *)}, + {"cadna", &typeid(KN< double > *)}, + {"bmat", &typeid(Matrice_Creuse< R > *)}, + LIST_NAME_PARM_MAT + /* + { "init", &typeid(bool)}, + { "solver", &typeid(TypeSolveMat*)}, + { "eps", &typeid(double) }, + { "precon",&typeid(Polymorphic*)}, + { "dimKrylov",&typeid(long)}, + { "bmat",&typeid(Matrice_Creuse* )}, + { "tgv",&typeid(double )}, + { "strategy",&typeid(long )}, + { "save",&typeid(string* )}, + { "cadna",&typeid(KN*)}, + { "tolpivot", &typeid(double)}, + { "tolpivotsym", &typeid(double)}, + { "nbiter", &typeid(long)}, // 12 + { "paramint",&typeid(KN_)}, // Add J. Morice 02/09 + { "paramdouble",&typeid(KN_)}, + { "paramstring",&typeid(string *)}, + { "permrow",&typeid(KN_)}, + { "permcol",&typeid(KN_)}, + { "fileparamint",&typeid(string*)}, // Add J. Morice 02/09 + { "fileparamdouble",&typeid(string*)}, + { "fileparamstring",&typeid(string* )}, + { "filepermrow",&typeid(string*)}, + { "filepermcol",&typeid(string*)} //22 + */ + , // param for bem solver + LIST_NAME_PARM_HMAT}; + +struct pair_stack_double { + Stack first; + double *second; + pair_stack_double(Stack ss, double *bb) : first(ss), second(bb) {}; }; namespace Fem2D { - void Expandsetoflab(Stack stack,const CDomainOfIntegration & di,set & setoflab,bool &all); - void Expandsetoflab(Stack stack,const BC_set & bc,set & setoflab); - - void Check(const Opera &Op,int N,int M) - { - int err=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - pair jj(ll.first.first),ii(ll.first.second); - if (ii.first <0 || ii.first >= M) err++; - if (jj.first <0 || jj.first >= N) err++; - - } - if (err) { - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - pair jj(ll.first.first),ii(ll.first.second); - cout << " + " << jj.first << " " << jj.second << "*" << ii.first << " " << ii.second << endl; - cout << "check ii.first =" << ii.first << " < M " << M << endl; - cout << "check jj.first =" << jj.first << " < N " << N << endl; - } - cout << " value of N=" << N << endl; - cout << " value of M=" << M << endl; - ExecError("Check BilinearOperator N M"); - } + void Expandsetoflab(Stack stack, const CDomainOfIntegration &di, set< int > &setoflab, bool &all); + void Expandsetoflab(Stack stack, const BC_set &bc, set< long > &setoflab); + + void Check(const Opera &Op, int N, int M) { + int err = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + if (ii.first < 0 || ii.first >= M) err++; + if (jj.first < 0 || jj.first >= N) err++; + } + if (err) { + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + cout << " + " << jj.first << " " << jj.second << "*" << ii.first << " " << ii.second << endl; + cout << "check ii.first =" << ii.first << " < M " << M << endl; + cout << "check jj.first =" << jj.first << " < N " << N << endl; + } + cout << " value of N=" << N << endl; + cout << " value of M=" << M << endl; + ExecError("Check BilinearOperator N M"); } - void Check(const BC_set * bc,int N) - { - int err=0; - int kk=bc->bc.size(); - for (int k=0;k xx=bc->bc[k]; - if (xx.first >= N) { - err++; - cerr << " Sorry : just " << N << " componant in FE space \n" - << " and Boundary condition refere to " << xx.first << "+1 componant " << endl; - } - } - if (err) - ExecError("Incompatibility between boundary condition and FE space"); + } + void Check(const BC_set *bc, int N) { + int err = 0; + int kk = bc->bc.size( ); + for (int k = 0; k < kk; k++) { + pair< int, Expression > xx = bc->bc[k]; + if (xx.first >= N) { + err++; + cerr << " Sorry : just " << N << " componant in FE space \n" + << " and Boundary condition refere to " << xx.first << "+1 componant " << endl; + } } + if (err) ExecError("Incompatibility between boundary condition and FE space"); + } - void Check(const Ftest * fl,int N) - { - assert(fl); - int err=0; - Ftest::const_iterator kk= fl->v.end(),k; - int ii=0; - for (k=fl->v.begin();kfirst.first; - if ( j >= N) { - err++; - cerr << " Sorry : just " << N << " componant in FE space \n" - << " and linear var form refere to " << j << "+1 componant (part " << ii << ")" << endl; - } - } - if (err) - ExecError("Incompatibility between linear varf and FE space"); + void Check(const Ftest *fl, int N) { + assert(fl); + int err = 0; + Ftest::const_iterator kk = fl->v.end( ), k; + int ii = 0; + for (k = fl->v.begin( ); k < kk; k++) { + ii++; + int j = k->first.first; + if (j >= N) { + err++; + cerr << " Sorry : just " << N << " componant in FE space \n" + << " and linear var form refere to " << j << "+1 componant (part " << ii << ")" << endl; + } } - template - inline void CheckErrorOptimisation(const R& ccc,const R& cc,const char * cmm) - { - if ( ccc != cc) { - if( (abs(ccc-cc) >1e-8*(abs(cc)+abs(ccc)) ) // test for round off err - || (cc !=cc) || (ccc !=ccc) ) {// test for NaN - cerr << cc << " != " << ccc << " diff "<< cc-ccc <<" => "; - cerr << cmm << endl; - cerr << " remark if you add (.. , optimize=2) then you remove this check (be careful); "<< endl; - ExecError("In Optimized version "); }} - } - inline void CheckErrorOptimisation(const Complex ccc,const Complex& cc,const char * cmm) - { - if ( ccc != cc) { - if( (abs(ccc.real()-ccc.real())+ abs(cc.imag()-cc.imag()) >0.5e-8*( abs(cc.real())+abs(cc.imag())+abs(ccc.real())+abs(ccc.imag()) ) ) - || (cc !=cc) || (ccc !=ccc) ) - { - cerr << cc << " != " << ccc << " diff "<< cc-ccc <<" => "; - cerr << cmm << endl; - cerr << " remark if you add (.. , optimize=2) then you remove this check (be careful); " < + inline void CheckErrorOptimisation(const R &ccc, const R &cc, const char *cmm) { + if (ccc != cc) { + if ((abs(ccc - cc) > 1e-8 * (abs(cc) + abs(ccc))) // test for round off err + || (cc != cc) || (ccc != ccc)) { // test for NaN + cerr << cc << " != " << ccc << " diff " << cc - ccc << " => "; + cerr << cmm << endl; + cerr << " remark if you add (.. , optimize=2) then you remove this check (be careful); " << endl; + ExecError("In Optimized version "); + } } - - //--------------------------------------------------------------------------------------- -/* just fo debug ... - long bbnElementonB(Stack s) { - throwassert(*((long *)s)); - MeshPoint *mp = MeshPointStack(s); - long l = 0; - if ((mp->T) && (mp->e > -1) && (mp->d == 2)) - l = mp->Th->nTonEdge(mp->t, mp->e); - else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) - { cout << mp->t <<" .. " << mp->f << " "; - l = mp->Th3->nElementonB(mp->t, mp->f); + } + inline void CheckErrorOptimisation(const Complex ccc, const Complex &cc, const char *cmm) { + if (ccc != cc) { + if ((abs(ccc.real( ) - ccc.real( )) + abs(cc.imag( ) - cc.imag( )) > 0.5e-8 * (abs(cc.real( )) + abs(cc.imag( )) + abs(ccc.real( )) + abs(ccc.imag( )))) || (cc != cc) || (ccc != ccc)) { + cerr << cc << " != " << ccc << " diff " << cc - ccc << " => "; + cerr << cmm << endl; + cerr << " remark if you add (.. , optimize=2) then you remove this check (be careful); " << endl; + + ExecError("In Optimized version "); + } } - else if (mp->d == 3 && mp->dHat == 2 && mp->TS && (mp->e >= 0)) - l = mp->ThS->nElementonB(mp->t, mp->e); - return l; } -*/ -template - void Element_OpVF(MatriceElementairePleine & mat, - const FElement3 & Ku,const FElement3 & KKu, - const FElement3 & Kv,const FElement3 & KKv, - double * p,int ie,int iie, int label,void *bstack,R3 *B) - { - typedef typename FElement3::Element Element; - ffassert(B==0); - pair_stack_double * bs=static_cast(bstack); - Stack stack= bs->first; - double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) - ffassert(mat.onFace); // Finite Volume or discontinuous Galerkin - ffassert(ie>=0 && ie < 4); // int on Face - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - const Element & T = Ku.T; - const Element & TT = KKu.T; - bool sameT = &Ku == & KKu; - int nTonEdge = &Ku == &KKu ? 1 : 2; - double cmean = 1./nTonEdge; - - throwassert(&T == &Kv.T); - // const QuadratureFormular & FI = mat.FIT; - const QuadratureFormular & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - assert(nx<=mat.lga); - long N= Kv.N; - long M= Ku.N; - - long mu=Ku.NbDoF(); - long mmu=KKu.NbDoF(); - long nv=Kv.NbDoF(); - long nnv=Kv.NbDoF(); - assert(mu==mmu && nv == nnv) ; - - - - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - if (Ku.number<1 && ( verbosity > 1 ) ) - cout << "Element_OpVF 3d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; - - bool oldopt=1; // juin 2007 FH ???? a voir - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; - // - int lastop=0; - lastop = 0; - What_d Dop = Op.DiffOp(lastop); - - long lffv = sameT ? 0 : nv*N*lastop; - long lffu = sameT ? 0 : mu*M*lastop; - long loffset = same ? 0 : (nv+nnv)*N*lastop; - - RNMK_ fv(p,nv,N,lastop); // the value for basic fonction in K - RNMK_ ffv(p + lffv ,nnv,N,lastop); // the value for basic fonction in KK - RNMK_ fu( (double*) fv + loffset ,mu,M,lastop); // the value for basic fonction - RNMK_ ffu( (double*) fu + lffu ,mmu,M,lastop); // the value for basic fonction - - - - - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; - - // compute the permutaion face ie to iie ... - // a little tricky - int fpe= T.facePermutation(ie); - int fpee= TT.facePermutation(iie); - int pr[3],ppr[3]; - SetNumPerm<3>(fpe,pr); - SetNumPerm1<3>(fpee,ppr); - - for (npi=0;npi pi( FIb[npi]); - double lpi[3]; - pi.toBary(lpi); - double llpi[]={lpi[pr[ppr[0]]], lpi[pr[ppr[1]]], lpi[pr[ppr[2]]]}; - double coef = 0.5*mes*pi.a; // correction 0.5 050109 FH - R3 Pt(T.PBord(ie,pi)); - R2 pii(llpi+1); - R3 PP_t(TT.PBord(iie,pii)); - { - static int err=0; - R3 P(T(Pt)),PP(TT(PP_t)),D(P,PP); - if( D.norme2() > 1e-5) - { - const Mesh3 & Th=Ku.Vh.Th; - cout << " pr "<< pr[0] << pr[1]<< pr[2] << " prr " << ppr[0] << ppr[1]<< ppr[2]<<" " - << ppr[pr[0]] << ppr[pr[1]] << ppr[pr[2]] << " " << pr[ppr[0]] << pr[ppr[1]] << pr[ppr[2]]<< endl; - cout << ie << " " << iie << endl; - cout << " T = " << Th(T[0]) << " " <set(T(Pt),Pt,Ku,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - - + //--------------------------------------------------------------------------------------- + /* just fo debug ... + long bbnElementonB(Stack s) { + throwassert(*((long *)s)); + MeshPoint *mp = MeshPointStack(s); + long l = 0; + if ((mp->T) && (mp->e > -1) && (mp->d == 2)) + l = mp->Th->nTonEdge(mp->t, mp->e); + else if (mp->d == 3 && mp->dHat == 3 && mp->T3 && (mp->f >= 0)) + { cout << mp->t <<" .. " << mp->f << " "; + l = mp->Th3->nElementonB(mp->t, mp->f); + } + else if (mp->d == 3 && mp->dHat == 2 && mp->TS && (mp->e >= 0)) + l = mp->ThS->nElementonB(mp->t, mp->e); + return l; + } + */ + template< class R > + void Element_OpVF(MatriceElementairePleine< R, FESpace3 > &mat, const FElement3 &Ku, const FElement3 &KKu, const FElement3 &Kv, const FElement3 &KKv, double *p, int ie, int iie, int label, + void *bstack, R3 *B) { + typedef typename FElement3::Element Element; + ffassert(B == 0); + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + ffassert(mat.onFace); // Finite Volume or discontinuous Galerkin + ffassert(ie >= 0 && ie < 4); // int on Face + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool same = &Ku == &Kv; + const Element &T = Ku.T; + const Element &TT = KKu.T; + bool sameT = &Ku == &KKu; + int nTonEdge = &Ku == &KKu ? 1 : 2; + double cmean = 1. / nTonEdge; - for ( i=0; i 1)) cout << "Element_OpVF 3d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; - for ( j=0; j unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; + // + int lastop = 0; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); - RNM_ wj(fu(Max(jk,0),'.','.')); - RNM_ wwj(ffu(Max(jkk,0),'.','.')); + long lffv = sameT ? 0 : nv * N * lastop; + long lffu = sameT ? 0 : mu * M * lastop; + long loffset = same ? 0 : (nv + nnv) * N * lastop; - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { - BilinearOperator::K ll(*l); - pair jj(ll.first.first),ii(ll.first.second); - int iis = ii.second, jjs=jj.second; + RNMK_ fv(p, nv, N, lastop); // the value for basic fonction in K + RNMK_ ffv(p + lffv, nnv, N, lastop); // the value for basic fonction in KK + RNMK_ fu((double *)fv + loffset, mu, M, lastop); // the value for basic fonction + RNMK_ ffu((double *)fu + lffu, mmu, M, lastop); // the value for basic fonction - int iicase = iis / last_operatortype; - int jjcase = jjs / last_operatortype; + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; - iis %= last_operatortype; - jjs %= last_operatortype; - double w_i=0,w_j=0,ww_i=0,ww_j=0; + // compute the permutaion face ie to iie ... + // a little tricky + int fpe = T.facePermutation(ie); + int fpee = TT.facePermutation(iie); + int pr[3], ppr[3]; + SetNumPerm< 3 >(fpe, pr); + SetNumPerm1< 3 >(fpee, ppr); - if(ik>=0) w_i = wi(ii.first,iis ); - if(jk>=0) w_j = wj(jj.first,jjs ); + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + GQuadraturePoint< R2 > pi(FIb[npi]); + double lpi[3]; + pi.toBary(lpi); + double llpi[] = {lpi[pr[ppr[0]]], lpi[pr[ppr[1]]], lpi[pr[ppr[2]]]}; + double coef = 0.5 * mes * pi.a; // correction 0.5 050109 FH + R3 Pt(T.PBord(ie, pi)); + R2 pii(llpi + 1); + R3 PP_t(TT.PBord(iie, pii)); + { + static int err = 0; + R3 P(T(Pt)), PP(TT(PP_t)), D(P, PP); + if (D.norme2( ) > 1e-5) { + const Mesh3 &Th = Ku.Vh.Th; + cout << " pr " << pr[0] << pr[1] << pr[2] << " prr " << ppr[0] << ppr[1] << ppr[2] << " " << ppr[pr[0]] << ppr[pr[1]] << ppr[pr[2]] << " " << pr[ppr[0]] << pr[ppr[1]] << pr[ppr[2]] + << endl; + cout << ie << " " << iie << endl; + cout << " T = " << Th(T[0]) << " " << Th(T[1]) << " " << Th(T[2]) << " " << Th(T[3]) << endl; + cout << " TT = " << Th(TT[0]) << " " << Th(TT[1]) << " " << Th(TT[2]) << " " << Th(TT[3]) << endl; + cout << fpe << " " << fpee << endl; + cout << P << " " << PP << " diff=D.norme2() " << D.norme2( ) << endl; + err++; + ffassert(err < 10); + } + } + Ku.BF(Dop, Pt, fu); + if (!sameT) KKu.BF(Dop, PP_t, ffu); + if (!same) { + Kv.BF(Dop, Pt, fv); + if (!sameT) KKv.BF(Dop, PP_t, ffv); + } + if (verbosity == 99999 && (Ku.number == 3 || KKu.number == 2)) { + cout << "intallfaces " << Ku.number << " " << fu << endl; + cout << "intallfaces " << KKu.number << " " << ffu << endl; + } + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version - if( iicase>0 && ikk>=0) ww_i = wwi(ii.first,iis ); - if( jjcase>0 && jkk>=0) ww_j = wwj(jj.first,jjs ); + for (i = 0; i < n; i++) { + int ik = mat.nik[i]; + int ikk = mat.nikk[i]; + RNM_ wi(fv(Max(ik, 0), '.', '.')); + RNM_ wwi(ffv(Max(ikk, 0), '.', '.')); - if (iicase==Code_Jump) w_i = ww_i-w_i; // jump - else if (iicase==Code_Mean) { + for (j = 0; j < m; j++, pa++) { + int jk = mat.njk[j]; + int jkk = mat.njkk[j]; - w_i = cmean* (w_i + ww_i );} // average - else if (iicase==Code_OtherSide) w_i = ww_i; // valeur de autre cote + RNM_ wj(fu(Max(jk, 0), '.', '.')); + RNM_ wwj(ffu(Max(jkk, 0), '.', '.')); - if (jjcase==Code_Jump) w_j = ww_j-w_j; // jump - else if (jjcase==Code_Mean) w_j = cmean* (w_j +ww_j ); // average - else if (jjcase==Code_OtherSide) w_j = ww_j; // valeur de l'autre cote + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + int iis = ii.second, jjs = jj.second; - // R ccc = GetAny(ll.second.eval(stack)); + int iicase = iis / last_operatortype; + int jjcase = jjs / last_operatortype; - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_OpVF3d (face) add: intallface(Th,optimize=0)(...)"); - } - if(verbosity==99999) - cout << ie << " / " << i << " " << j << "/ (" << mat.ni[i] << " "<< mat.nj[j] << ") pi " << npi << " : " << coef << " c= " << ccc << " " << w_i << " " << w_j << " = " << coef * ccc * w_i*w_j - << " k/kk " << Ku.number << " "<< KKu.number << " :: " << ik << " " << ikk << ", "<< jk << " " << jkk << " ii/jj2= " << ii.second << " " << jj.second // << " // " << bbnElementonB(stack) - << endl; - *pa += coef * ccc * w_i*w_j; - } - } - } - // else pa += m; + iis %= last_operatortype; + jjs %= last_operatortype; + double w_i = 0, w_j = 0, ww_i = 0, ww_j = 0; + + if (ik >= 0) w_i = wi(ii.first, iis); + if (jk >= 0) w_j = wj(jj.first, jjs); + + if (iicase > 0 && ikk >= 0) ww_i = wwi(ii.first, iis); + if (jjcase > 0 && jkk >= 0) ww_j = wwj(jj.first, jjs); + + if (iicase == Code_Jump) + w_i = ww_i - w_i; // jump + else if (iicase == Code_Mean) { + + w_i = cmean * (w_i + ww_i); + } // average + else if (iicase == Code_OtherSide) + w_i = ww_i; // valeur de autre cote + + if (jjcase == Code_Jump) + w_j = ww_j - w_j; // jump + else if (jjcase == Code_Mean) + w_j = cmean * (w_j + ww_j); // average + else if (jjcase == Code_OtherSide) + w_j = ww_j; // valeur de l'autre cote + + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_OpVF3d (face) add: intallface(Th,optimize=0)(...)"); + } + if (verbosity == 99999) + cout << ie << " / " << i << " " << j << "/ (" << mat.ni[i] << " " << mat.nj[j] << ") pi " << npi << " : " << coef << " c= " << ccc << " " << w_i << " " << w_j << " = " + << coef * ccc * w_i * w_j << " k/kk " << Ku.number << " " << KKu.number << " :: " << ik << " " << ikk << ", " << jk << " " << jkk << " ii/jj2= " << ii.second << " " + << jj.second // << " // " << bbnElementonB(stack) + << endl; + *pa += coef * ccc * w_i * w_j; + } } - - - pa=a; - if ( (verbosity > 9999) ||( (verbosity > 55) && (Ku.number <=0 || KKu.number <=0 ))) { - cout < - void Element_OpVF(MatriceElementairePleine & mat, - const FElementS & Ku,const FElementS & KKu, - const FElementS & Kv,const FElementS & KKv, - double * p,int ie,int iie, int label,void *bstack,R3 *B) - { - ffassert(0); + pa = a; + if ((verbosity > 9999) || ((verbosity > 55) && (Ku.number <= 0 || KKu.number <= 0))) { + cout << endl << " face between " << Ku.number << " , " << KKu.number << " = " << T[0] << ", " << T[1] << ", " << T[2] << " " << nx << endl; + cout << " K u, uu = " << Ku.number << " " << KKu.number << " " << " K v, vv = " << Kv.number << " " << KKv.number << " " << endl; + for (int i = 0; i < n; i++) { + cout << setw(2) << i << setw(4) << mat.ni[i] << setw(4) << mat.nik[i] << setw(4) << mat.nikk[i] << " :"; + for (int j = 0; j < m; j++) cout << setw(5) << (*pa++) << " "; + cout << endl; + } } - template - void Element_OpVF(MatriceElementairePleine & mat, - const FElementL & Ku,const FElementL & KKu, - const FElementL & Kv,const FElementL & KKv, - double * p,int ie,int iie, int label,void *bstack,R3 *B) - { - typedef typename FElementL::E Element; - ffassert(B==0); - pair_stack_double * bs=static_cast(bstack); - Stack stack= bs->first; - double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) - assert(mat.onFace); // Finite Volume or discontinuous Galerkin - assert(ie>=0 && ie < 3); // int on edge - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - assert(same); - const Element & T = Ku.T; - R3 NNt=T.TangenteUnitaire(); - double s = ie; - double ss = iie; - GQuadraturePoint pi(1.,s); - R mes = 1.; - R3 NN=NNt; - if(ie==0) NN=-NN; - R coef = 1.; - R1 Pt(pi); - int nTonEdge = &Ku == &KKu ? 1 : 2; - double cmean = 1./nTonEdge; - - throwassert(&T == &Kv.T); - long npi=1; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - assert(nx<=mat.lga); - long N= Kv.N; - long M= Ku.N; - - long mu=Ku.NbDoF(); - long mmu=KKu.NbDoF(); - long nv=Kv.NbDoF(); - long nnv=Kv.NbDoF(); - assert(mu==mmu && nv == nnv) ; - - + *MeshPointStack(stack) = mp; + } - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - if (Ku.number<1 && ( verbosity > 1 ) ) - cout << "Element_OpVF 0d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; + template< class R > + void Element_OpVF(MatriceElementairePleine< R, FESpaceS > &mat, const FElementS &Ku, const FElementS &KKu, const FElementS &Kv, const FElementS &KKv, double *p, int ie, int iie, int label, + void *bstack, R3 *B) { + ffassert(0); + } + template< class R > + void Element_OpVF(MatriceElementairePleine< R, FESpaceL > &mat, const FElementL &Ku, const FElementL &KKu, const FElementL &Kv, const FElementL &KKv, double *p, int ie, int iie, int label, + void *bstack, R3 *B) { + typedef typename FElementL::E Element; + ffassert(B == 0); + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + assert(mat.onFace); // Finite Volume or discontinuous Galerkin + assert(ie >= 0 && ie < 3); // int on edge + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool same = &Ku == &Kv; + assert(same); + const Element &T = Ku.T; + R3 NNt = T.TangenteUnitaire( ); + double s = ie; + double ss = iie; + GQuadraturePoint< R1 > pi(1., s); + R mes = 1.; + R3 NN = NNt; + if (ie == 0) NN = -NN; + R coef = 1.; + R1 Pt(pi); + int nTonEdge = &Ku == &KKu ? 1 : 2; + double cmean = 1. / nTonEdge; - int lastop; - lastop = 0; - What_d Dop = Op.DiffOp(lastop); - //assert(lastop<=3); - int lffv = nv*N*last_operatortype; - int lffu = mu*M*last_operatortype; - int loffset = same ? 0 : (nv+nnv)*N*last_operatortype; + throwassert(&T == &Kv.T); + long npi = 1; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + assert(nx <= mat.lga); + long N = Kv.N; + long M = Ku.N; + + long mu = Ku.NbDoF( ); + long mmu = KKu.NbDoF( ); + long nv = Kv.NbDoF( ); + long nnv = Kv.NbDoF( ); + assert(mu == mmu && nv == nnv); + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) + if (Ku.number < 1 && (verbosity > 1)) cout << "Element_OpVF 0d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; - RNMK_ fv(p,nv,N,lastop); // the value for basic fonction in K - RNMK_ ffv(p + lffv ,nnv,N,lastop); // the value for basic fonction in KK - RNMK_ fu( (double*) fv + loffset ,mu,M,lastop); // the value for basic fonction - RNMK_ ffu( (double*) fu + lffu ,mmu,M,lastop); // the value for basic fonction + int lastop; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // assert(lastop<=3); + int lffv = nv * N * last_operatortype; + int lffu = mu * M * last_operatortype; + int loffset = same ? 0 : (nv + nnv) * N * last_operatortype; + RNMK_ fv(p, nv, N, lastop); // the value for basic fonction in K + RNMK_ ffv(p + lffv, nnv, N, lastop); // the value for basic fonction in KK + RNMK_ fu((double *)fv + loffset, mu, M, lastop); // the value for basic fonction + RNMK_ ffu((double *)fu + lffu, mmu, M, lastop); // the value for basic fonction - - { - pa =a; - double coef = 1.; - - R1 Pt=s; // - R1 PP_t=ss; - assert (!binside); - Ku.BF(Dop,Pt,fu); - KKu.BF(Dop,PP_t,ffu); - if (!same) { Kv.BF(Dop,Pt,fv); KKv.BF(Dop,PP_t,ffv); } - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,NNt,ie);// Axel - // MeshPointStack(stack)->set(T(Pt),Pt,Kv,label, Normal,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; iset(T(Pt), Pt, Kv, label, NN, NNt, ie); // Axel + // MeshPointStack(stack)->set(T(Pt),Pt,Kv,label, Normal,ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version - RNM_ wi(fv(Max(ik,0),'.','.')); - RNM_ wwi(ffv(Max(ikk,0),'.','.')); + for (i = 0; i < n; i++) { + int ik = mat.nik[i]; + int ikk = mat.nikk[i]; - for ( j=0; j jj(ll.first.first),ii(ll.first.second); - int iis = ii.second, jjs=jj.second; + RNM_ wj(fu(Max(jk, 0), '.', '.')); + RNM_ wwj(ffu(Max(jkk, 0), '.', '.')); - int iicase = iis / last_operatortype; - int jjcase = jjs / last_operatortype; + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + int iis = ii.second, jjs = jj.second; - iis %= last_operatortype; - jjs %= last_operatortype; - double w_i=0,w_j=0,ww_i=0,ww_j=0; + int iicase = iis / last_operatortype; + int jjcase = jjs / last_operatortype; - if(ik>=0) w_i = wi(ii.first,iis ); - if(jk>=0) w_j = wj(jj.first,jjs ); + iis %= last_operatortype; + jjs %= last_operatortype; + double w_i = 0, w_j = 0, ww_i = 0, ww_j = 0; - if( iicase>0 && ikk>=0) ww_i = wwi(ii.first,iis ); - if( jjcase>0 && jkk>=0) ww_j = wwj(jj.first,jjs ); + if (ik >= 0) w_i = wi(ii.first, iis); + if (jk >= 0) w_j = wj(jj.first, jjs); + if (iicase > 0 && ikk >= 0) ww_i = wwi(ii.first, iis); + if (jjcase > 0 && jkk >= 0) ww_j = wwj(jj.first, jjs); - if (iicase==Code_Jump) w_i = ww_i-w_i; // jump - else if (iicase==Code_Mean) { + if (iicase == Code_Jump) + w_i = ww_i - w_i; // jump + else if (iicase == Code_Mean) { - w_i = cmean* (w_i + ww_i );} // average - else if (iicase==Code_OtherSide) w_i = ww_i; // valeur de autre cote + w_i = cmean * (w_i + ww_i); + } // average + else if (iicase == Code_OtherSide) + w_i = ww_i; // valeur de autre cote - if (jjcase==Code_Jump) w_j = ww_j-w_j; // jump - else if (jjcase==Code_Mean) w_j = cmean* (w_j +ww_j ); // average - else if (jjcase==Code_OtherSide) w_j = ww_j; // valeur de l'autre cote + if (jjcase == Code_Jump) + w_j = ww_j - w_j; // jump + else if (jjcase == Code_Mean) + w_j = cmean * (w_j + ww_j); // average + else if (jjcase == Code_OtherSide) + w_j = ww_j; // valeur de l'autre cote - // R ccc = GetAny(ll.second.eval(stack)); + // R ccc = GetAny(ll.second.eval(stack)); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_OpVF0d (b) add: int2d(Th,optimize=0)(...)"); - } - *pa += coef * ccc * w_i*w_j; - } - } + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_OpVF0d (b) add: int2d(Th,optimize=0)(...)"); } - // else pa += m; + *pa += coef * ccc * w_i * w_j; + } } + } + // else pa += m; + } + pa = a; + if ((verbosity > 9999) || ((verbosity > 55) && (Ku.number <= 0 || KKu.number <= 0))) { + cout << endl << " vertex between " << Ku.number << " , " << KKu.number << " = " << T[0] << ", " << T[1] << ", " << T[2] << " " << nx << endl; + cout << " K u, uu = " << Ku.number << " " << KKu.number << " " << " K v, vv = " << Kv.number << " " << KKv.number << " " << endl; + for (int i = 0; i < n; i++) { + cout << setw(2) << i << setw(4) << mat.ni[i] << setw(4) << mat.nik[i] << setw(4) << mat.nikk[i] << " :"; + for (int j = 0; j < m; j++) cout << setw(5) << (*pa++) << " "; + cout << endl; + } + } - pa=a; - if ( (verbosity > 9999) ||( (verbosity > 55) && (Ku.number <=0 || KKu.number <=0 ))) { - cout < - void Element_OpVF(MatriceElementairePleine & mat, - const FElement & Ku,const FElement & KKu, - const FElement & Kv,const FElement & KKv, - double * p,int ie,int iie, int label,void *bstack,R2 *B) - { - ffassert(B==0); - pair_stack_double * bs=static_cast(bstack); - Stack stack= bs->first; - double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) - assert(mat.onFace); // Finite Volume or discontinuous Galerkin - assert(ie>=0 && ie < 3); // int on edge - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - - const Triangle & T = Ku.T; - int nTonEdge = &Ku == &KKu ? 1 : 2; - double cmean = 1./nTonEdge; - - throwassert(&T == &Kv.T); - // const QuadratureFormular & FI = mat.FIT; - const QuadratureFormular1d & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - assert(nx<=mat.lga); - long N= Kv.N; - long M= Ku.N; - - long mu=Ku.NbDoF(); - long mmu=KKu.NbDoF(); - long nv=Kv.NbDoF(); - long nnv=Kv.NbDoF(); - assert(mu==mmu && nv == nnv) ; - if(verbosity>9999) cout << " Element_OpVF:" <<" edge between " << Ku.number << " , " << KKu.number << endl; - - - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - if (Ku.number<1 && ( verbosity > 1 ) ) - cout << "Element_OpVF P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; - - - KN Dop(last_operatortype); // sinon ca plate bizarre - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(lastop<=3); - int lffv = nv*N*last_operatortype; - int lffu = mu*M*last_operatortype; - int loffset = same ? 0 : (nv+nnv)*N*last_operatortype; - - RNMK_ fv(p,nv,N,lastop); // the value for basic fonction in K - RNMK_ ffv(p + lffv ,nnv,N,lastop); // the value for basic fonction in KK - RNMK_ fu( (double*) fv + loffset ,mu,M,lastop); // the value for basic fonction - RNMK_ ffu( (double*) fu + loffset+ lffu ,mmu,M,lastop); // the value for basic fonction - if( verbosity>99999) - { - cout << " nv " << nv << " " << nnv << " mu = " << mu << " " << mmu << " / n " << n << " m " << m << endl; - cout << " fv " << fv << endl; - cout << "ffv " << ffv << endl; - cout << " fu " << fu << endl; - cout << "ffu " << ffu << endl; - } - R2 E=T.Edge(ie); - double le = sqrt((E,E)); - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]), - PC(TriangleHat[OppositeVertex[ie]]); - // warning the to edge are in opposite sens - R2 PP_A(TriangleHat[VerticesOfTriangularEdge[iie][1]]), - PP_B(TriangleHat[VerticesOfTriangularEdge[iie][0]]), - PP_C(TriangleHat[OppositeVertex[ie]]); - R2 Normal(E.perp()/-le); - for (npi=0;npiset(T(Pt),Pt,Kv,label, Normal,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i + void Element_OpVF(MatriceElementairePleine< R, FESpace > &mat, const FElement &Ku, const FElement &KKu, const FElement &Kv, const FElement &KKv, double *p, int ie, int iie, int label, void *bstack, + R2 *B) { + ffassert(B == 0); + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + assert(mat.onFace); // Finite Volume or discontinuous Galerkin + assert(ie >= 0 && ie < 3); // int on edge + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { - BilinearOperator::K ll(*l); - pair jj(ll.first.first),ii(ll.first.second); - int iis = ii.second, jjs=jj.second; + bool same = &Ku == &Kv; - int iicase = iis / last_operatortype; - int jjcase = jjs / last_operatortype; + const Triangle &T = Ku.T; + int nTonEdge = &Ku == &KKu ? 1 : 2; + double cmean = 1. / nTonEdge; - iis %= last_operatortype; - jjs %= last_operatortype; - double w_i=0,w_j=0,ww_i=0,ww_j=0; + throwassert(&T == &Kv.T); + // const QuadratureFormular & FI = mat.FIT; + const QuadratureFormular1d &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + assert(nx <= mat.lga); + long N = Kv.N; + long M = Ku.N; + + long mu = Ku.NbDoF( ); + long mmu = KKu.NbDoF( ); + long nv = Kv.NbDoF( ); + long nnv = Kv.NbDoF( ); + assert(mu == mmu && nv == nnv); + if (verbosity > 9999) cout << " Element_OpVF:" << " edge between " << Ku.number << " , " << KKu.number << endl; + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) + if (Ku.number < 1 && (verbosity > 1)) cout << "Element_OpVF P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << mat.optim << endl; - if(ik>=0) w_i = wi(ii.first,iis ); - if(jk>=0) w_j = wj(jj.first,jjs ); + KN< bool > Dop(last_operatortype); // sinon ca plate bizarre + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); + int lffv = nv * N * last_operatortype; + int lffu = mu * M * last_operatortype; + int loffset = same ? 0 : (nv + nnv) * N * last_operatortype; + + RNMK_ fv(p, nv, N, lastop); // the value for basic fonction in K + RNMK_ ffv(p + lffv, nnv, N, lastop); // the value for basic fonction in KK + RNMK_ fu((double *)fv + loffset, mu, M, lastop); // the value for basic fonction + RNMK_ ffu((double *)fu + loffset + lffu, mmu, M, lastop); // the value for basic fonction + if (verbosity > 99999) { + cout << " nv " << nv << " " << nnv << " mu = " << mu << " " << mmu << " / n " << n << " m " << m << endl; + cout << " fv " << fv << endl; + cout << "ffv " << ffv << endl; + cout << " fu " << fu << endl; + cout << "ffu " << ffu << endl; + } + R2 E = T.Edge(ie); + double le = sqrt((E, E)); + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]), PC(TriangleHat[OppositeVertex[ie]]); + // warning the to edge are in opposite sens + R2 PP_A(TriangleHat[VerticesOfTriangularEdge[iie][1]]), PP_B(TriangleHat[VerticesOfTriangularEdge[iie][0]]), PP_C(TriangleHat[OppositeVertex[ie]]); + R2 Normal(E.perp( ) / -le); + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 Pt(PA * sa + PB * sb); // + R2 PP_t(PP_A * sa + PP_B * sb); // + if (binside) { + Pt = (1 - binside) * Pt + binside * PC; + PP_t = (1 - binside) * PP_t + binside * PP_C; + } + Ku.BF(Dop, Pt, fu); + KKu.BF(Dop, PP_t, ffu); + if (!same) { + Kv.BF(Dop, Pt, fv); + KKv.BF(Dop, PP_t, ffv); + } + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, Normal, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version - if( iicase>0 && ikk>=0) ww_i = wwi(ii.first,iis ); - if( jjcase>0 && jkk>=0) ww_j = wwj(jj.first,jjs ); + for (i = 0; i < n; i++) { + int ik = mat.nik[i]; + int ikk = mat.nikk[i]; + RNM_ wi(fv(Max(ik, 0), '.', '.')); + RNM_ wwi(ffv(Max(ikk, 0), '.', '.')); - if (iicase==Code_Jump) w_i = ww_i-w_i; // jump - else if (iicase==Code_Mean) { + for (j = 0; j < m; j++, pa++) { + int jk = mat.njk[j]; + int jkk = mat.njkk[j]; - w_i = cmean* (w_i + ww_i );} // average - else if (iicase==Code_OtherSide) w_i = ww_i; // valeur de autre cote + RNM_ wj(fu(Max(jk, 0), '.', '.')); + RNM_ wwj(ffu(Max(jkk, 0), '.', '.')); - if (jjcase==Code_Jump) w_j = ww_j-w_j; // jump - else if (jjcase==Code_Mean) w_j = cmean* (w_j +ww_j ); // average - else if (jjcase==Code_OtherSide) w_j = ww_j; // valeur de l'autre cote + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + int iis = ii.second, jjs = jj.second; - // R ccc = GetAny(ll.second.eval(stack)); - if(verbosity>99999) cout << " w_i w_j : " << i << " "<< j << " "<< w_i << " " << ww_i << " " << wi(0,0 ) << "/ " << w_j << endl; - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - *pa += coef * ccc * w_i*w_j; - } - } - } - // else pa += m; - } - - - pa=a; - if ( (verbosity > 9999) ||( (verbosity > 55) && (Ku.number <=0 || KKu.number <=0 ))) { - cout <= 0) w_i = wi(ii.first, iis); + if (jk >= 0) w_j = wj(jj.first, jjs); + + if (iicase > 0 && ikk >= 0) ww_i = wwi(ii.first, iis); + if (jjcase > 0 && jkk >= 0) ww_j = wwj(jj.first, jjs); + + if (iicase == Code_Jump) + w_i = ww_i - w_i; // jump + else if (iicase == Code_Mean) { + + w_i = cmean * (w_i + ww_i); + } // average + else if (iicase == Code_OtherSide) + w_i = ww_i; // valeur de autre cote + + if (jjcase == Code_Jump) + w_j = ww_j - w_j; // jump + else if (jjcase == Code_Mean) + w_j = cmean * (w_j + ww_j); // average + else if (jjcase == Code_OtherSide) + w_j = ww_j; // valeur de l'autre cote + + // R ccc = GetAny(ll.second.eval(stack)); + if (verbosity > 99999) cout << " w_i w_j : " << i << " " << j << " " << w_i << " " << ww_i << " " << wi(0, 0) << "/ " << w_j << endl; + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + *pa += coef * ccc * w_i * w_j; + } + } + } + // else pa += m; + } + + pa = a; + if ((verbosity > 9999) || ((verbosity > 55) && (Ku.number <= 0 || KKu.number <= 0))) { + cout << endl << " edge between " << Ku.number << " , " << KKu.number << " = " << T[0] << ", " << T[1] << ", " << T[2] << " " << nx << endl; + cout << " K u, uu = " << Ku.number << " " << KKu.number << " " << " K v, vv = " << Kv.number << " " << KKv.number << " " << endl; + cout << " nj = "; + for (int j = 0; j < m; j++) cout << setw(5) << mat.nj[j] << " "; + cout << "\n njk = "; + for (int j = 0; j < m; j++) cout << setw(5) << mat.njk[j] << " "; + cout << "\n njkk = "; + for (int j = 0; j < m; j++) cout << setw(5) << mat.njkk[j] << " "; + cout << endl; + for (int i = 0; i < n; i++) { + cout << setw(2) << i << setw(4) << mat.ni[i] << setw(4) << mat.nik[i] << setw(4) << mat.nikk[i] << " :"; + for (int j = 0; j < m; j++) cout << setw(5) << (*pa++) << " "; + cout << endl; + } } - //-------------------------------------------------------------------------------------- - + *MeshPointStack(stack) = mp; + } + //-------------------------------------------------------------------------------------- + // creating an instance of AssembleBilinearForm with MatriceCreuse + // case 2d + // --------- FH 120105 + template< class R > + void AssembleBilinearForm(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - // creating an instance of AssembleBilinearForm with MatriceCreuse - // case 2d - // --------- FH 120105 - template - void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) + { + /*FH: case ..in 2D + in varf ... + standard case .. + */ + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + const CDomainOfIntegration &di = *b->di; + const Mesh *pThdi = GetAny< pmesh >((*di.Th)(stack)); + if (pThdi != &Th || &Uh.Th != &Th || &Vh.Th != &Th) { + cout << " --Use matrix formulation ---" << endl; + ExecError( + "No way to compute bilinear form with integrale of on mesh \n" + " test or unknown function defined on another mesh! sorry to hard. "); + } + SHOWVERB(cout << " FormBilinear " << endl); + double CPU0 = CPUtime( ); + MatriceElementaireSymetrique< R, FESpace > *mates = 0; + MatriceElementairePleine< R, FESpace > *matep = 0; + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); + + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + + const Mesh &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - { - /*FH: case ..in 2D - in varf ... - standard case .. - */ - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - const CDomainOfIntegration & di= *b->di; - const Mesh * pThdi = GetAny( (* di.Th)(stack)); - if ( pThdi != &Th || &Uh.Th !=&Th || &Vh.Th !=&Th) { - cout << " --Use matrix formulation ---" << endl; - ExecError("No way to compute bilinear form with integrale of on mesh \n" - " test or unknown function defined on another mesh! sorry to hard. "); - } - SHOWVERB(cout << " FormBilinear " << endl); - double CPU0 = CPUtime(); - MatriceElementaireSymetrique *mates =0; - MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const Mesh & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.neb/mpi_size); - int bei1 = min(Th.neb,(int)((mpi_rank+1)*ceil(1.*Th.neb/mpi_size))); - - // const QuadratureFormular1d & FIE = di.FIE(stack); - // const QuadratureFormular & FIT = di.FIT(stack); - const QuadratureFormular1d & FIEo = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - // const GQuadratureFormular & FIVo = di.FIV(stack); - // to change the quadrature on element ... may 2014 FH .. - QuadratureFormular1d FIE(FIEo,3); - QuadratureFormular FIT(FITo,3); - // GQuadratureFormular FIV(FIVo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int (nQP: "<< FIT.n << " ) in " ; - } - //if(di.islevelset()) InternalError("So no levelset integration type on this case (6)"); - if( di.withmap()) { ExecError(" no map in the case (2)??");} - if(di.islevelset() && ( (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) ) - InternalError("So no levelset integration type on no int1d case (6)"); + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.neb / mpi_size); + int bei1 = min(Th.neb, (int)((mpi_rank + 1) * ceil(1. * Th.neb / mpi_size))); + + // const QuadratureFormular1d & FIE = di.FIE(stack); + // const QuadratureFormular & FIT = di.FIT(stack); + const QuadratureFormular1d &FIEo = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + // const GQuadratureFormular & FIVo = di.FIV(stack); + // to change the quadrature on element ... may 2014 FH .. + QuadratureFormular1d FIE(FIEo, 3); + QuadratureFormular FIT(FITo, 3); + // GQuadratureFormular FIV(FIVo,3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int (nQP: " << FIT.n << " ) in "; + } + // if(di.islevelset()) InternalError("So no levelset integration type on this case (6)"); + if (di.withmap( )) { + ExecError(" no map in the case (2)??"); + } + if (di.islevelset( ) && ((CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind))) InternalError("So no levelset integration type on no int1d case (6)"); + + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + if ((verbosity / 100) % 10 >= 2) { + int il = 0; - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + void *paramate = stack; + pair_stack_double parammatElement_OpVF(stack, &binside); + // parammatElement_OpVF.first = stack; + // parammatElement_OpVF.second= & binside; + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (VF) { + if (!sameMesh || sym) { + (cout << "To Day in bilinear form with discontinuous Galerkin (2d): \n" + " test or unknown function must be defined on the same mesh, \n" + " and the matrix is not symmetric. \n" + "To hard to do !!!! "); + // cput << " " << di.kind << endl; + } + if (&Uh == &Vh) + matep = new MatriceElementairePleine< R, FESpace >(Uh, VF, FIT, FIE, useopt); + else + matep = new MatriceElementairePleine< R, FESpace >(Uh, Vh, VF, FIT, FIE, useopt); + + // matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE); + matep->faceelement = Element_OpVF; + paramate = ¶mmatElement_OpVF; + } else if (sym) { + mates = new MatriceElementaireSymetrique< R, FESpace >(Uh, FIT, FIE, useopt); + mates->element = Element_Op< R >; + } else { + matep = new MatriceElementairePleine< R, FESpace >(Uh, Vh, FIT, FIE, useopt); + matep->element = Element_Op< R >; + } + MatriceElementaireFES< R, FESpace > &mate(*(sym ? (MatriceElementaireFES< R, FESpace > *)mates : (MatriceElementaireFES< R, FESpace > *)matep)); + + mate.bilinearform = b->b; + + Check(*mate.bilinearform, mate.Uh.N, mate.Vh.N); + if (verbosity > 9) cout << " -- CPU init assemble mat " << CPUtime( ) - CPU0 << " s\n"; + + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[3]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + if (umn <= 0 && umx >= 0) { - if ( (verbosity/100) % 10 >= 2) - { - int il=0; + int np = IsoLineK(f, Q, 1e-10); + if (np == 2) { + /* if ( sameMesh) + { - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; + Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1]); + } + else*/ + // InternalError(" No levelSet on Diff mesh : to day int1d of Matrix"); + A += mate(t, 10, Th[t].lab, stack, Q); + } + if (sptrclean) sptrclean = sptr->clean( ); } + } + } + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.bedges[e].lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + A += mate(i, ie, Th.bedges[e].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - void *paramate=stack; - pair_stack_double parammatElement_OpVF(stack,& binside); - // parammatElement_OpVF.first = stack; - // parammatElement_OpVF.second= & binside; + } else if (di.kind == CDomainOfIntegration::intalledges) { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) { // modif F.H to get the correct label in intalledges + int e0 = VerticesOfTriangularEdge[ie][0]; + int e1 = VerticesOfTriangularEdge[ie][1]; + int i1 = Th(Th[i][e0]), i2 = Th(Th[i][e1]); + BoundaryEdge *be = Th.TheBoundaryEdge(i1, i2); + int lab = be ? be->lab : notalabel; + + A += mate(i, ie, lab, paramate); + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - if(VF) { - if( !sameMesh || sym) { - (cout << "To Day in bilinear form with discontinuous Galerkin (2d): \n" - " test or unknown function must be defined on the same mesh, \n" - " and the matrix is not symmetric. \n" - "To hard to do !!!! ") - ; - // cput << " " << di.kind << endl; - } - if(&Uh == &Vh) - matep= new MatriceElementairePleine(Uh,VF,FIT,FIE,useopt); - else - matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE,useopt); + } else if (di.kind == CDomainOfIntegration::intallVFedges) { + cerr << " a faire intallVFedges " << endl; + ffassert(0); + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) A += mate(i, ie, Th[i].lab, paramate); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } else if (di.kind == CDomainOfIntegration::int2d) { + + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2][3]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) A += mate(t, -1, Th[t].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); + } + } + FIT = FITo; + } else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) A += mate(i, -1, Th[i].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr - // matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE); - matep->faceelement = Element_OpVF; - paramate= ¶mmatElement_OpVF; - } - else if (sym) { - mates= new MatriceElementaireSymetrique(Uh,FIT,FIE,useopt); - mates->element = Element_Op; + // AA += mate; } - else { - matep= new MatriceElementairePleine(Uh,Vh,FIT,FIE,useopt); - matep->element = Element_Op; - } - MatriceElementaireFES & mate(*( sym? (MatriceElementaireFES *)mates : (MatriceElementaireFES *) matep)); + } else + InternalError(" kind of CDomainOfIntegration unknown"); + if (where_in_stack) delete[] where_in_stack; + delete &mate; + if (verbosity > 9) cout << " -- CPU assemble mat " << CPUtime( ) - CPU0 << " s\n"; + } - mate.bilinearform=b->b; + // creating an instance of AssembleBilinearForm with MatriceCreuse + // case 3D volume + // --------- FH 120105 + template< class R > + void AssembleBilinearForm(Stack stack, const FESpace3::Mesh &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - Check(*mate.bilinearform,mate.Uh.N,mate.Vh.N); - if(verbosity>9) cout << " -- CPU init assemble mat " << CPUtime()-CPU0 << " s\n"; + { + /*FH: case ..in 3D + in varf ... + standard case .. + */ - if (di.kind == CDomainOfIntegration::int1d ) - { - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[3]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - if( umn <=0 && umx >= 0) - { - - int np= IsoLineK(f,Q,1e-10); - if(np==2) - { - /* if ( sameMesh) - { - - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1]); - } - else*/ - // InternalError(" No levelSet on Diff mesh : to day int1d of Matrix"); - A += mate(t,10,Th[t].lab,stack,Q); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - } - else for( int e=bei0;eclean(); // modif FH mars 2006 clean Ptr + typedef FESpace3 FESpace; + typedef FESpace3::Mesh Mesh; + typedef Mesh *pmesh; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; - } - } - } - else if (di.kind == CDomainOfIntegration::intalledges) - { - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - { // modif F.H to get the correct label in intalledges - int e0=VerticesOfTriangularEdge[ie][0]; - int e1=VerticesOfTriangularEdge[ie][1]; - int i1 = Th(Th[i][e0]),i2 = Th(Th[i][e1]); - BoundaryEdge * be = Th.TheBoundaryEdge(i1,i2); - int lab = be ? be->lab : notalabel; - - A += mate(i,ie,lab,paramate); - } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); + + bool sptrclean = true; + const CDomainOfIntegration &di = *b->di; + ffassert(di.d == 3); + const Mesh *pThdi = GetAny< pmesh >((*di.Th)(stack)); + if (pThdi != &Th || &Uh.Th != &Th || &Vh.Th != &Th) { + cout << " Use matrix formulation .... " << endl; + ExecError( + "No way to compute bilinear form with integrale of on mesh \n" + " test or unknown function defined on another mesh! sorry to hard. "); + } + SHOWVERB(cout << " FormBilinear " << endl); + MatriceElementaireSymetrique< R, FESpace > *mates = 0; + MatriceElementairePleine< R, FESpace > *matep = 0; + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); + if (di.withmap( )) { + ExecError(" no map in the case (3)??"); + } + + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const QuadratureFormular1d &FIEo = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + const GQuadratureFormular< R3 > &FIVo = di.FIV(stack); + // to change the quadrature on element ... may 2014 FH .. + QuadratureFormular1d FIE(FIEo, 3); + QuadratureFormular FIT(FITo, 3); + GQuadratureFormular< R3 > FIV(FIVo, 3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int2d == kind) + cout << " -- boundary int border ( nQP: " << FIT.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIT.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int3d (nQP: " << FIV.n << " ) in "; + if (di.islevelset( )) cout << " ( int on Levelset) " << endl; + } + if (di.islevelset( ) && (CDomainOfIntegration::int2d != kind) && (CDomainOfIntegration::int3d != kind)) InternalError("Sorry no levelset integration type on no int[2|3]d case"); + + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - } - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - cerr << " a faire intallVFedges " << endl; - ffassert(0); - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - A += mate(i,ie,Th[i].lab,paramate); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + void *paramate = stack; + pair_stack_double parammatElement_OpVF(stack, &binside); + parammatElement_OpVF.first = stack; + parammatElement_OpVF.second = &binside; + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (VF) { + if (sym) + cout + << ("To Day in bilinear form with discontinuous Galerkin (3d): \n" + " test or unknown function must be defined on the same mesh, \n" + " and the matrix is not symmetric. \n" + " To HArd !!!! "); + if (&Uh == &Vh) + matep = new MatriceElementairePleine< R, FESpace >(Uh, VF, FIV, FIT, useopt); + else + matep = new MatriceElementairePleine< R, FESpace >(Uh, Vh, VF, FIV, FIT, useopt); + matep->faceelement = Element_OpVF; + paramate = ¶mmatElement_OpVF; + } else if (sym) { + mates = new MatriceElementaireSymetrique< R, FESpace >(Uh, FIV, FIT, useopt); + mates->element = Element_Op< R >; + } else { + matep = new MatriceElementairePleine< R, FESpace >(Uh, Vh, FIV, FIT, useopt); + matep->element = Element_Op< R >; + } + MatriceElementaireFES< R, FESpace > &mate(*(sym ? (MatriceElementaireFES< R, FESpace > *)mates : (MatriceElementaireFES< R, FESpace > *)matep)); + + mate.bilinearform = b->b; + + Check(*mate.bilinearform, mate.Uh.N, mate.Vh.N); + + if (di.kind == CDomainOfIntegration::int2d) { + + if (di.islevelset( )) { + if (verbosity > 99) cout << " int2d on levelset in 3d " << endl; + double uset = HUGE_VAL; + R3 Q[4]; + KN< double > phi(Th.nv); + phi = uset; + double f[4]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 4; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); } + if (umn <= 0 && umx >= 0) { + int np = IsoLineK(f, Q, 1e-10); // ca code ... + // cout < 2) { + if (verbosity > 999) cout << " -- int " << np << " on: " << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] << endl; + A += mate(t, 10 + np, Th[t].lab, stack, Q); + } + if (sptrclean) sptrclean = sptr->clean( ); + } + } } - else if (di.kind == CDomainOfIntegration::int2d ) - { - - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - A += mate(t,-1,Th[t].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + A += mate(i, ie, Th.be(e).lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (di.kind == CDomainOfIntegration::intallfaces) { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 4; ie++) A += mate(i, ie, Th[i].lab, paramate); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - A += mate(i,-1,Th[i].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } else if (di.kind == CDomainOfIntegration::intallVFedges) { + cerr << " a faire intallVFedges " << endl; + ffassert(0); + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) A += mate(i, ie, Th[i].lab, paramate); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - // AA += mate; + } else if (di.kind == CDomainOfIntegration::int3d) { + if (di.islevelset( )) // may 2014 FH ... + { // int3d levelset < 0 + double llevelset = 0; + const double uset = std::numeric_limits< double >::max( ); + // cout << " uset ="< phi(Th.nv); + phi = uset; + double f[4]; + + for (int t = ti0; t < ti1; t++) { + + const Mesh3::Element &K(Th[t]); + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) + + { + double umx = std::numeric_limits< double >::lowest( ), umn = std::numeric_limits< double >::max( ); + for (int i = 0; i < 4; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; } + int ntets = UnderIso(f, Q, vol6, 1e-14); + setQF< R3 >(FIV, FIVo, QuadratureFormular_Tet_1, Q, vol6, ntets); + if (FIV.n) { + A += mate(t, -1, Th[t].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } } - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - delete &mate; - if(verbosity>9) cout << " -- CPU assemble mat " << CPUtime()-CPU0 << " s\n"; - } - - // creating an instance of AssembleBilinearForm with MatriceCreuse - // case 3D volume - // --------- FH 120105 - template - void AssembleBilinearForm(Stack stack,const FESpace3::Mesh & Th,const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - /*FH: case ..in 3D - in varf ... - standard case .. - */ - - - typedef FESpace3 FESpace; - typedef FESpace3::Mesh Mesh; - typedef Mesh *pmesh ; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - bool sptrclean=true; - const CDomainOfIntegration & di= *b->di; - ffassert(di.d==3); - const Mesh * pThdi = GetAny( (* di.Th)(stack)); - if ( pThdi != &Th || &Uh.Th !=&Th || &Vh.Th !=&Th) { - cout << " Use matrix formulation .... " << endl; - ExecError("No way to compute bilinear form with integrale of on mesh \n" - " test or unknown function defined on another mesh! sorry to hard. "); - } - SHOWVERB(cout << " FormBilinear " << endl); - MatriceElementaireSymetrique *mates =0; - MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); - if( di.withmap()) { ExecError(" no map in the case (3)??");} - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - const QuadratureFormular1d & FIEo = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - const GQuadratureFormular & FIVo = di.FIV(stack); - // to change the quadrature on element ... may 2014 FH .. - QuadratureFormular1d FIE(FIEo,3); - QuadratureFormular FIT(FITo,3); - GQuadratureFormular FIV(FIVo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int2d==kind) cout << " -- boundary int border ( nQP: "<< FIT.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIT.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int3d (nQP: "<< FIV.n << " ) in " ; - if(di.islevelset()) cout << " ( int on Levelset) " << endl; + FIV = FIVo; + } else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) A += mate(i, -1, Th[i].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + // AA += mate; } - if(di.islevelset() && (CDomainOfIntegration::int2d!=kind) && (CDomainOfIntegration::int3d!=kind)) - InternalError("Sorry no levelset integration type on no int[2|3]d case"); - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } + } else { + cerr << " kind of CDomainOfIntegration unknown ?? " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); + } + if (where_in_stack) delete[] where_in_stack; + delete &mate; + mp = mps; // restore data x,yz + } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + // template struct to obtain the original type mesh - particular case for meshS FEM + /* template struct Trait_MESHO { + // By default Mesh == MeshO + typedef typename FE::Mesh MeshO;// Mesh origin for Mesh S + typedef typename FE::Mesh Mesh; // Mesh Mesh S + static Mesh * topmesh(MeshO *p) {return p;} + };*/ + /* template<> struct Trait_MESHO { + // By default Mesh == MeshS and MeshO == Mesh3 + typedef Mesh3 MeshO; + typedef typename FESpaceS::Mesh Mesh; + static Mesh * topmesh(MeshO *p) {return p->getMeshS();} + };*/ + + // creating an instance of AssembleBilinearForm with MatriceCreuse + // case 3D surface + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - if ( (verbosity/100) % 10 >= 2) - { - int il=0; + { + /*FH: case ..in 2D + in varf ... + standard case .. + */ - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - void *paramate=stack; - pair_stack_double parammatElement_OpVF(stack, & binside); - parammatElement_OpVF.first = stack; - parammatElement_OpVF.second= & binside; + typedef typename Mesh::RdHat RdHat; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + const CDomainOfIntegration &di = *b->di; + ffassert(di.d == 3); - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - if(VF) { - if( sym) - cout << ("To Day in bilinear form with discontinuous Galerkin (3d): \n" - " test or unknown function must be defined on the same mesh, \n" - " and the matrix is not symmetric. \n" - " To HArd !!!! "); - if(&Uh == &Vh) - matep= new MatriceElementairePleine(Uh,VF,FIV,FIT,useopt); - else - matep= new MatriceElementairePleine(Uh,Vh,VF,FIV,FIT,useopt); - matep->faceelement = Element_OpVF; - paramate= ¶mmatElement_OpVF; - } - else if (sym) { - mates= new MatriceElementaireSymetrique(Uh,FIV,FIT,useopt); - mates->element = Element_Op; - } - else { - matep= new MatriceElementairePleine(Uh,Vh,FIV,FIT,useopt); - matep->element = Element_Op; - } - MatriceElementaireFES & mate(*( sym? (MatriceElementaireFES *)mates : (MatriceElementaireFES *) matep)); + SHOWVERB(cout << " FormBilinear " << endl); + double CPU0 = CPUtime( ); + MatriceElementaireSymetrique< R, FESpaceS > *mates = 0; + MatriceElementairePleine< R, FESpaceS > *matep = 0; + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; - mate.bilinearform=b->b; + const MeshS &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - Check(*mate.bilinearform,mate.Uh.N,mate.Vh.N); + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); + + // const QuadratureFormular1d & FIE = di.FIE(stack); + // const QuadratureFormular & FIT = di.FIT(stack); + const QuadratureFormular1d &FIEo = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + // const GQuadratureFormular & FIVo = di.FIV(stack); + // to change the quadrature on element ... may 2014 FH .. + QuadratureFormular1d FIE(FIEo, 3); + QuadratureFormular FIT(FITo, 3); + // GQuadratureFormular FIV(FIVo,3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int (nQP: " << FIT.n << " ) in "; + } + // if(di.islevelset()) InternalError("So no levelset integration type on this case (6)"); + if (di.withmap( )) { + ExecError(" no map in the case (2)??"); + } + if (di.islevelset( ) && ((CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind))) InternalError("So no levelset integration type on no int1d case (6)"); + + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - if (di.kind == CDomainOfIntegration::int2d ) - { + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - if(di.islevelset()) - { - if(verbosity>99) cout << " int2d on levelset in 3d " << endl; - double uset = HUGE_VAL; - R3 Q[4]; - KN phi(Th.nv);phi=uset; - double f[4]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<4;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - if( umn <=0 && umx >= 0) - { - int np= IsoLineK(f,Q,1e-10);// ca code ... - // cout <2 ) - { - if( verbosity > 999 ) cout << " -- int " << np << " on: " << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] << endl; - A += mate(t,10+np,Th[t].lab,stack,Q); - } - if(sptrclean) sptrclean=sptr->clean(); - } - }} + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + void *paramate = stack; + pair_stack_double parammatElement_OpVF(stack, &binside); + // parammatElement_OpVF.first = stack; + // parammatElement_OpVF.second= & binside; + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (VF) { + if (!sameMesh || sym) + cout + << ("To Day in bilinear form with discontinuous Galerkin (MeshS): \n" + " test or unknown function must be defined on the same mesh, \n" + " and the matrix is not symmetric. \n" + " To do other case in a future (F. Hecht) dec. 2003 "); + if (&Uh == &Vh) + matep = new MatriceElementairePleine< R, FESpaceS >(Uh, VF, FIT, FIE, useopt); + else + matep = new MatriceElementairePleine< R, FESpaceS >(Uh, Vh, VF, FIT, FIE, useopt); + + // matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE); + matep->faceelement = Element_OpVF; + paramate = ¶mmatElement_OpVF; + } else if (sym) { + mates = new MatriceElementaireSymetrique< R, FESpaceS >(Uh, FIT, FIE, useopt); + mates->element = Element_Op< R >; + } else { + matep = new MatriceElementairePleine< R, FESpaceS >(Uh, Vh, FIT, FIE, useopt); + matep->element = Element_Op< R >; + } + MatriceElementaireFES< R, FESpaceS > &mate(*(sym ? (MatriceElementaireFES< R, FESpaceS > *)mates : (MatriceElementaireFES< R, FESpaceS > *)matep)); + + mate.bilinearform = b->b; + + Check(*mate.bilinearform, mate.Uh.N, mate.Vh.N); + if (verbosity > 9) cout << " -- CPU init assemble mat " << CPUtime( ) - CPU0 << " s\n"; + + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[3]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); } - else - for( int e=bei0;eclean(); // modif FH mars 2006 clean Ptr + if (umn <= 0 && umx >= 0) { - } + int np = IsoLineK(f, Q, 1e-10); + if (np == 2) { + /* if ( sameMesh) + { + + Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1]); + } + else*/ + // InternalError(" No levelSet on Diff mesh : to day int1d of Matrix"); + A += mate(t, 10, Th[t].lab, stack, Q); + } + if (sptrclean) sptrclean = sptr->clean( ); } + } } - else if (di.kind == CDomainOfIntegration::intallfaces ) - { - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<4;ie++) - A += mate(i,ie,Th[i].lab,paramate); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + A += mate(i, ie, Th.be(e).lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (di.kind == CDomainOfIntegration::intalledges) { + ffassert(0); + /* for (int i=0;i< Th.nt; i++) + { + if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + for (int ie=0;ie<3;ie++) + { // modif F.H to get the correct label in intalledges + int e0=VerticesOfTriangularEdge[ie][0]; + int e1=VerticesOfTriangularEdge[ie][1]; + int i1 = Th(Th[i][e0]),i2 = Th(Th[i][e1]); + BoundaryEdge * be = Th.TheBoundaryEdge(i1,i2); - } + int lab = be ? be->lab : notalabel; + + A += mate(i,ie,lab,paramate); + } + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + + } + */ + } else if (di.kind == CDomainOfIntegration::intallVFedges) { + ffassert(0); + /* cerr << " a faire intallVFedges " << endl; + ffassert(0); + for (int i=0;i< Th.nt; i++) + { + if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + for (int ie=0;ie<3;ie++) + A += mate(i,ie,Th[i].lab,paramate); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } + */ + } else if (di.kind == CDomainOfIntegration::int2d) { + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2][3]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) A += mate(t, -1, Th[t].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); + } } - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - cerr << " a faire intallVFedges " << endl; - ffassert(0); - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - A += mate(i,ie,Th[i].lab,paramate); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + FIT = FITo; + } else - } + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) A += mate(i, -1, Th[i].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + // AA += mate; } - else if (di.kind == CDomainOfIntegration::int3d ) - { - if(di.islevelset()) // may 2014 FH ... - { // int3d levelset < 0 - double llevelset = 0; - const double uset = std::numeric_limits::max(); - // cout << " uset ="< phi(Th.nv); - phi=uset; - double f[4]; - - for (int t=ti0;t< ti1; t++) - { + } else + InternalError(" kind of CDomainOfIntegration unknown"); - const Mesh3::Element & K(Th[t]); - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) + if (where_in_stack) delete[] where_in_stack; + delete &mate; + if (verbosity > 9) cout << " -- CPU assemble mat " << CPUtime( ) - CPU0 << " s\n"; + } - { - double umx=std::numeric_limits::lowest(),umn=std::numeric_limits::max(); - for(int i=0;i<4;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - } - int ntets= UnderIso(f,Q, vol6,1e-14); - setQF(FIV,FIVo,QuadratureFormular_Tet_1, Q,vol6,ntets); - if(FIV.n) - { - A += mate(t,-1,Th[t].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - } - } - } - FIV=FIVo; - } - else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - A += mate(i,-1,Th[i].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + // creating an instance of AssembleBilinearForm with MatriceCreuse + // case 3D curve + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - // AA += mate; - } + { - } - else - { - cerr << " kind of CDomainOfIntegration unknown ?? " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } + typedef typename Mesh::RdHat RdHat; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + const CDomainOfIntegration &di = *b->di; + ffassert(di.d == 3); - if (where_in_stack) delete [] where_in_stack; - delete &mate; - mp = mps;// restore data x,yz - } + SHOWVERB(cout << " FormBilinear " << endl); + double CPU0 = CPUtime( ); + MatriceElementaireSymetrique< R, FESpaceL > *mates = 0; + MatriceElementairePleine< R, FESpaceL > *matep = 0; + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const MeshL &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - // template struct to obtain the original type mesh - particular case for meshS FEM - /* template struct Trait_MESHO { - // By default Mesh == MeshO - typedef typename FE::Mesh MeshO;// Mesh origin for Mesh S - typedef typename FE::Mesh Mesh; // Mesh Mesh S - static Mesh * topmesh(MeshO *p) {return p;} - };*/ - /* template<> struct Trait_MESHO { - // By default Mesh == MeshS and MeshO == Mesh3 - typedef Mesh3 MeshO; - typedef typename FESpaceS::Mesh Mesh; - static Mesh * topmesh(MeshO *p) {return p->getMeshS();} - };*/ + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (di.withmap( )) { + ExecError(" no map in the case (2)??"); + } + if (di.islevelset( ) && ((CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind))) InternalError("So no levelset integration type on no int1d case (6)"); + Expandsetoflab(stack, di, setoflab, all); + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - // creating an instance of AssembleBilinearForm with MatriceCreuse - // case 3D surface - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) + if ((verbosity / 100) % 10 >= 2) { + int il = 0; - { - /*FH: case ..in 2D - in varf ... - standard case .. - */ + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + void *paramate = stack; + pair_stack_double parammatElement_OpVF(stack, &binside); + // parammatElement_OpVF.first = stack; + // parammatElement_OpVF.second= & binside; + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (VF) { + /* if(sameMesh || sym) // remove done in june 23 FH. + cout << ("To Day in bilinear form with discontinuous Galerkin (3d curve): \n" + " test or unknown function must be defined on the same meshL, \n" + " and the matrix is not symmetric. \n" + " To do other case in a future (F. Hecht) dec. 2003 "); */ + if (&Uh == &Vh) + matep = new MatriceElementairePleine< R, FESpaceL >(Uh, VF, FIT, 0, useopt); + else + matep = new MatriceElementairePleine< R, FESpaceL >(Uh, Vh, VF, FIT, 0, useopt); + + matep->faceelement = Element_OpVF; + paramate = ¶mmatElement_OpVF; + } else if (sym) { + mates = new MatriceElementaireSymetrique< R, FESpaceL >(Uh, FIT, 0, useopt); + mates->element = Element_Op< R >; + } else { + matep = new MatriceElementairePleine< R, FESpaceL >(Uh, Vh, FIT, 0, useopt); + matep->element = Element_Op< R >; + } + MatriceElementaireFES< R, FESpaceL > &mate(*(sym ? (MatriceElementaireFES< R, FESpaceL > *)mates : (MatriceElementaireFES< R, FESpaceL > *)matep)); + + mate.bilinearform = b->b; + + Check(*mate.bilinearform, mate.Uh.N, mate.Vh.N); + if (verbosity > 9) cout << " -- CPU init assemble mat " << CPUtime( ) - CPU0 << " s\n"; + + if (di.kind == CDomainOfIntegration::int1d) { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) A += mate(i, -1, Th[i].lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - typedef typename Mesh::RdHat RdHat; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - const CDomainOfIntegration & di= *b->di; - ffassert(di.d==3); - - SHOWVERB(cout << " FormBilinear " << endl); - double CPU0 = CPUtime(); - MatriceElementaireSymetrique *mates =0; - MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const MeshS & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - // const QuadratureFormular1d & FIE = di.FIE(stack); - // const QuadratureFormular & FIT = di.FIT(stack); - const QuadratureFormular1d & FIEo = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - // const GQuadratureFormular & FIVo = di.FIV(stack); - // to change the quadrature on element ... may 2014 FH .. - QuadratureFormular1d FIE(FIEo,3); - QuadratureFormular FIT(FITo,3); - // GQuadratureFormular FIV(FIVo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int (nQP: "<< FIT.n << " ) in " ; + else if (di.kind == CDomainOfIntegration::int0d) { + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + A += mate(i, ie, Th.be(e).lab, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (di.kind == CDomainOfIntegration::intall0d) { // add FH juin 2021 + for (int k = ti0; k < ti1; k++) { + if (all || setoflab.find(Th[k].lab) != setoflab.end( )) { + for (int ie = 0; ie < 2; ie++) A += mate(k, ie, Th[k].lab, ¶mmatElement_OpVF); + if (sptrclean) sptrclean = sptr->clean( ); } - //if(di.islevelset()) InternalError("So no levelset integration type on this case (6)"); - if( di.withmap()) { ExecError(" no map in the case (2)??");} - if(di.islevelset() && ( (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) ) - InternalError("So no levelset integration type on no int1d case (6)"); + } + } - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } + else + InternalError(" kind of CDomainOfIntegration unknown"); + if (where_in_stack) delete[] where_in_stack; + delete &mate; + if (verbosity > 9) cout << " -- CPU assemble mat " << CPUtime( ) - CPU0 << " s\n"; + } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + // 3D curve / 2D on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - if ( (verbosity/100) % 10 >= 2) - { - int il=0; + { + ffassert(0); + } - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - void *paramate=stack; - pair_stack_double parammatElement_OpVF(stack,& binside); - // parammatElement_OpVF.first = stack; - // parammatElement_OpVF.second= & binside; + // 2D / 3D curve on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { + ffassert(0); + } - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - if(VF) { - if(!sameMesh || sym) - cout << ("To Day in bilinear form with discontinuous Galerkin (MeshS): \n" - " test or unknown function must be defined on the same mesh, \n" - " and the matrix is not symmetric. \n" - " To do other case in a future (F. Hecht) dec. 2003 "); - if(&Uh == &Vh) - matep= new MatriceElementairePleine(Uh,VF,FIT,FIE,useopt); - else - matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE,useopt); + // 3D Surf / 3D volume on meshS + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { + ffassert(0); + } + // 3D volume / 3D Surf on meshS + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { + ffassert(0); + } + // 3D Surf / 3D curve on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { + ffassert(0); + } + // 3D curve / 3D Surf on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { + ffassert(0); + } + // end 3d - // matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,FIE); - matep->faceelement = Element_OpVF; - paramate= ¶mmatElement_OpVF; - } - else if (sym) { - mates= new MatriceElementaireSymetrique(Uh,FIT,FIE,useopt); - mates->element = Element_Op; - } - else { - matep= new MatriceElementairePleine(Uh,Vh,FIT,FIE,useopt); - matep->element = Element_Op; - } - MatriceElementaireFES & mate(*( sym? (MatriceElementaireFES *)mates : (MatriceElementaireFES *) matep)); + //////////////////////////////////////////////// + // AddMatElem + //////////////////////////////////////////////// + // case 2d + // --------- FH 170605 - mate.bilinearform=b->b; + template< class R > + void AddMatElem(MatriceMap< R > &A, const Mesh &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpace &Uh, const FESpace &Vh, const QuadratureFormular &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false, R2 *Q = 0) { + // cout << "AddMatElem" << Q << " " << ie << endl; + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Mesh &Thu(Uh.Th); + const Mesh &Thv(Vh.Th); - Check(*mate.bilinearform,mate.Uh.N,mate.Vh.N); - if(verbosity>9) cout << " -- CPU init assemble mat " << CPUtime()-CPU0 << " s\n"; + bool same = &Uh == &Vh; + const Triangle &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + // - if (di.kind == CDomainOfIntegration::int1d ) - { - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[3]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - if( umn <=0 && umx >= 0) - { - - int np= IsoLineK(f,Q,1e-10); - if(np==2) - { - /* if ( sameMesh) - { - - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1]); - } - else*/ - // InternalError(" No levelSet on Diff mesh : to day int1d of Matrix"); - A += mate(t,10,Th[t].lab,stack,Q); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - } - else for( int e=bei0;eclean(); // modif FH mars 2006 clean Ptr + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); - } - } + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.area * pi.a; + R2 Pt(pi), Ptu, Ptv; + R2 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Triangle *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } } - else if (di.kind == CDomainOfIntegration::intalledges) - { - ffassert(0); - /* for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - { // modif F.H to get the correct label in intalledges - int e0=VerticesOfTriangularEdge[ie][0]; - int e1=VerticesOfTriangularEdge[ie][1]; - int i1 = Th(Th[i][e0]),i2 = Th(Th[i][e1]); - BoundaryEdge * be = Th.TheBoundaryEdge(i1,i2); - - int lab = be ? be->lab : notalabel; - - A += mate(i,ie,lab,paramate); - } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; } - */ + } } - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - ffassert(0); - /* cerr << " a faire intallVFedges " << endl; - ffassert(0); - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - A += mate(i,ie,Th[i].lab,paramate); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - } - */ + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElement Ku(Uh[iut]); + FElement Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " on T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } } - else if (di.kind == CDomainOfIntegration::int2d ) - { - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - A += mate(t,-1,Th[t].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else - - - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - A += mate(i,-1,Th[i].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } + } else // int on edge ie + { + R2 PA, PB, E; + if (Q) { + PA = Q[0]; + PB = Q[1]; + E = T(PB) - T(PA); + // cout << " AddMAtElem " << PA << " " << PB << " "<< sqrt((E,E))<< endl; + } else { + PA = TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB = TriangleHat[VerticesOfTriangularEdge[ie][1]]; + E = T.Edge(ie); + } + double le = sqrt((E, E)); - // AA += mate; + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FIb[npi]); + double sa = pi.x, sb = 1 - sa; + double coef = le * pi.a; + + R2 Pt(PA * sa + PB * sb); // + + R2 Ptu, Ptv; + R2 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Triangle *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || (outsideu && !intmortar)) { + // R dd=-1; + // if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << Ptu << " " << tu << endl; + continue; + } + } + iut = Thu(tu); + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + ivt = iut; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || (outsidev && !intmortar)) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; } + } + ivt = Thv(tv); + } + FElement Ku(Uh[iut]); + FElement Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + if (!same) Kv.BF(Dop, Ptv, fv); + + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(Th, P, Pt, T, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // juste the df on edge bofbof generaly wrong FH dec 2003 + { + RNM_ wi(fv(i, '.', '.')); + int ig = Kv(i); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg = Ku(j); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + double wij = w_i * w_j; + if (abs(wij) >= 1e-10 && (verbosity > 1000)) cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i * w_j << " on edge \n"; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += wij * coef * ccc; + } + } } - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - delete &mate; - if(verbosity>9) cout << " -- CPU assemble mat " << CPUtime()-CPU0 << " s\n"; + } } + *MeshPointStack(stack) = mp; + } - // creating an instance of AssembleBilinearForm with MatriceCreuse - // case 3D curve - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { + template< class Mesh > + using QFMesh = GQuadratureFormular< typename Mesh::RdHat >; + template< class Mesh > + using QFMeshB = GQuadratureFormular< typename Mesh::BorderElement::RdHat >; - typedef typename Mesh::RdHat RdHat; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - const CDomainOfIntegration & di= *b->di; - ffassert(di.d==3); - - SHOWVERB(cout << " FormBilinear " << endl); - double CPU0 = CPUtime(); - MatriceElementaireSymetrique *mates =0; - MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const MeshL & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th && &ThI == &Uh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - - if( di.withmap()) { ExecError(" no map in the case (2)??");} - if(di.islevelset() && ( (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) ) - InternalError("So no levelset integration type on no int1d case (6)"); - - Expandsetoflab(stack,di, setoflab,all); - - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } + template< class Rd > + void getmap(Stack stack, Rd &P, Expression const *const map) { + if (map) + for (int i = 0; i < Rd::d; ++i) P[i] = GetAny< double >((*map[i])(stack)); + }; + /* + */ + R3 toR3(R2 P) { return R3(P.x, P.y, 0); } + R3 toR3(R3 P) { return P; } + R3 toR3(R1 P) { return R3(P.x, 0., 0); } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + template< class Mesh > + struct DataQPElm { - if ( (verbosity/100) % 10 >= 2) - { - int il=0; + typedef typename Mesh::Element Elm; + typedef typename Mesh::Rd Rd; + typedef typename Mesh::RdHat RdHat; + typedef typename Mesh::BorderElement::RdHat RdHatB; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - void *paramate=stack; - pair_stack_double parammatElement_OpVF(stack,& binside); - // parammatElement_OpVF.first = stack; - // parammatElement_OpVF.second= & binside; - - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - if(VF) { - /* if(sameMesh || sym) // remove done in june 23 FH. - cout << ("To Day in bilinear form with discontinuous Galerkin (3d curve): \n" - " test or unknown function must be defined on the same meshL, \n" - " and the matrix is not symmetric. \n" - " To do other case in a future (F. Hecht) dec. 2003 "); */ - if(&Uh == &Vh) - matep= new MatriceElementairePleine(Uh,VF,FIT,0,useopt); - else - matep= new MatriceElementairePleine(Uh,Vh,VF,FIT,0,useopt); - - matep->faceelement = Element_OpVF; - paramate= ¶mmatElement_OpVF; - } - else if (sym) { - mates= new MatriceElementaireSymetrique(Uh,FIT,0,useopt); - mates->element = Element_Op; - } - else { - matep= new MatriceElementairePleine(Uh,Vh,FIT,0,useopt); - matep->element = Element_Op; + const Mesh &Th; + RdHat Ph; + Rd P; + bool outside; + const Elm *pK; + long it; + Stack stack; + Expression const *const mapp; + DataQPElm(Stack s, const Mesh &TTh, Expression const *const mappp = 0) : Th(TTh), stack(s), mapp(mappp) {} + void Set(RdHat PPh, Elm *pKK) { + Ph = PPh; + pK = pKK; + it = Th(pK); + P = (*pK)(Ph); + outside = false; + } + template< class M > + bool same(DataQPElm< M > &from) { + return false; + } + bool same(DataQPElm< Mesh > &from) { return &Th == &from.Th; } + + template< class M > + bool copy(DataQPElm< M > &from) { + R3 P3 = toR3(from.P); // to be sure !!!!! + P = Rd(&P3); + getmap(stack, P, mapp); + pK = Th.Find(P, Ph, outside); + if (!pK || outside) { + if (verbosity > 99) cout << " Do not find P (u or v) " << P << " in " << Th << endl; + return false; + } + it = Th(pK); + + return true; + } + // template<> + bool copy(DataQPElm< Mesh > &from) { + if (&Th == &from.Th && mapp == 0) // same mesh and no map + { // just copy + Ph = from.Ph; + P = from.P; + outside = from.outside; + pK = from.pK; + it = from.it; + } // + else { + P = from.P; + getmap(stack, P, mapp); + pK = Th.Find(P, Ph, outside); + if (!pK || outside) { + if (verbosity > 99) cout << " Do not find P (u or v) " << P << " in " << Th << endl; + return false; } - MatriceElementaireFES & mate(*( sym? (MatriceElementaireFES *)mates : (MatriceElementaireFES *) matep)); + it = Th(pK); + } + return true; + } + }; + /* Essai F. Hecht !!! + template + bool optfindnotsame(const Mesh &Thu,const ElmU *&Ku,Rd & Pu,RdH & Ptu,bool & outsideu) + { + Ku= Thu.Find(Pu,Ptu,outsideu); + if( !Ku || outsideu) { + if(verbosity>100) cout << " On a pas trouver (u or v ) " << Pu << " " << endl; + return false;} + }; + + template + bool optfindsame(const ElmU *&K,RdH & Pt,bool &outside, const ElmU *&Ku,RdH & Ptu,bool &outsideu) + { + Ku=K; + outsideu=outside; + Ptu=Pt; + return true; + } + */ - mate.bilinearform=b->b; + template< class R, class Mesh, class FESpaceU, class FESpaceV > + void AddMatElem2(Expression const *const mapu, Expression const *const mapt, MatriceMap< R > &A, const Mesh &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceU &Uh, + const FESpaceV &Vh, const QFMesh< Mesh > &FI, const QFMeshB< Mesh > &FIb, double *p, void *vstack, bool intmortar = false, typename Mesh::Rd *Q = 0) { + typedef typename FESpaceU::Mesh MeshU; + typedef typename FESpaceV::Mesh MeshV; + typedef typename FESpaceU::FElement FElmU; + typedef typename FESpaceV::FElement FElmV; - Check(*mate.bilinearform,mate.Uh.N,mate.Vh.N); - if(verbosity>9) cout << " -- CPU init assemble mat " << CPUtime()-CPU0 << " s\n"; + typedef typename Mesh::Element Elm; + // cout << "AddMatElem" << Q << " " << ie << endl; + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshU &Thu(Uh.Th); + const MeshV &Thv(Vh.Th); + DataQPElm< Mesh > Pq(stack, Th); + DataQPElm< MeshU > Pu(stack, Th, mapu); + DataQPElm< MeshV > Pv(stack, Th, mapt); + + bool same = ((const void *)&Uh == (const void *)&Vh) && !mapu && !mapt; + bool sameu = (const void *)&Th == (const void *)&Thu && !mapu; + bool samev = (const void *)&Th == (const void *)&Thv && !mapt; + + const Elm &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + // - if (di.kind == CDomainOfIntegration::int1d ) { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - A += mate(i,-1,Th[i].lab,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); - else if (di.kind == CDomainOfIntegration::int0d ) { - for( int e=bei0;eclean(); // modif FH mars 2006 clean Ptr - } - } + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + auto pi(FI[npi]); + Pq.Set(pi); + MeshPointStack(stack)->set(Th, Pq.P, Pq.Ph, Pq.T, notalabel); + if (!Pu.copy(Pq)) continue; // no in mesh !!! + if (same) + Pv.copy(Pu); // simple copy + else if (!Pv.copy(Pq)) + continue; // refinded !!! + + double coef = T.mes( ) * pi.a; + + int iut = Pu.it; // Thu(tu); + int ivt = Pv.it; + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + auto Ku = *Pu.pK; + auto Kv = *Pv.pK; + // FElmV Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Pu.Ph, fu); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Pv.Ph, fv); + for (i = 0; i < n; i++) { + + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " on T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } } - else if (di.kind == CDomainOfIntegration::intall0d ) {// add FH juin 2021 - for( int k=ti0;kclean(); - } - } + } + } else // int on edge or face !!! ie + { + double mes = T.mesBord(ie); + auto NN = T.N(ie); + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + auto pi(FIb[npi]); + double coef = mes * pi.a; + auto Pt(T.PBord(ie, pi)); + MeshPointStack(stack)->set(Th, Pq.P, Pq.Ph, T, label, NN, ie); + if (!Pu.copy(Pq)) continue; // no in mesh !!! + if (same) + Pv.copy(Pu); // simple copy + else if (!Pv.copy(Pq)) + continue; // refinded !!! + + const FElement Ku = *Pu.pK; + const FElement Kv = *Pv.pK; + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Pu.Ph, fu); + if (!same) Kv.BF(Dop, Pv.Ph, fv); + + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) { + RNM_ wi(fv(i, '.', '.')); + int ig = Kv(i); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg = Ku(j); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + double wij = w_i * w_j; + if (abs(wij) >= 1e-10 && (verbosity > 1000)) cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i * w_j << " on edge \n"; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += wij * coef * ccc; + } + } } - - - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - delete &mate; - if(verbosity>9) cout << " -- CPU assemble mat " << CPUtime()-CPU0 << " s\n"; + } } - // 3D curve / 2D on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) + *MeshPointStack(stack) = mp; + } - { - ffassert(0); - } + template<> + void AddMatElem2< R, MeshS, FESpaceS, FESpaceS >(Expression const *const mapu, Expression const *const mapt, MatriceMap< R > &A, const MeshS &Th, const BilinearOperator &Op, bool sym, int it, + int ie, int label, const FESpaceS &Uh, const FESpaceS &Vh, const QFMesh< MeshS > &FI, const QFMeshB< MeshS > &FIb, double *p, void *vstack, + bool intmortar, MeshS::Rd *Q); + + // Warning reput F Hecht 3 May 2024 from + // commit 897a6ed0606d497b043b593e0d7db86448731889 (HEAD -> master, tag: v4.9, origin/master, origin/HEAD) + template< class R > + void AddMatElem(Expression const *const mapu, Expression const *const mapt, MatriceMap< R > &A, const Mesh &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpace &Uh, + const FESpace &Vh, const QuadratureFormular &FI, const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false, R2 *Q = 0) { + // cout << "AddMatElem" << Q << " " << ie << endl; + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Mesh &Thu(Uh.Th); + const Mesh &Thv(Vh.Th); + + bool same = (&Uh == &Vh) && !mapu && !mapt; + bool sameu = &Th == &Thu && !mapu; + bool samev = &Th == &Thv && !mapt; + const Triangle &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + // - // 2D / 3D curve on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - { - ffassert(0); - } + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); - // 3D Surf / 3D volume on meshS - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.area * pi.a; + R2 Pt(pi), Ptu, Ptv; + R2 P(T(Pt)), Pu(P), Pv(P); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + + if (mapu) Pu = R2(GetAny< double >((*mapu[0])(vstack)), GetAny< double >((*mapu[1])(vstack))); + if (mapt) Pv = R2(GetAny< double >((*mapt[0])(vstack)), GetAny< double >((*mapt[1])(vstack))); + if (verbosity > 9999 && (mapu || mapt)) cout << " mapinng: " << P << " AddMatElem + map -> (u) " << Pu << " (t) ->" << Pv << endl; + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Triangle *tu, *tv; + if (sameu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(Pu, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + } else if (samev) { + tv = &T; + Ptv = Pt; + + } else { + tv = Thv.Find(Pv, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElement Ku(Uh[iut]); + FElement Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " on T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on edge ie { - ffassert(0); - } - // 3D volume / 3D Surf on meshS - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - { - ffassert(0); - } - // 3D Surf / 3D curve on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - { - ffassert(0); - } - // 3D curve / 3D Surf on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize = nullptr) - { - ffassert(0); - } - -// end 3d - + R2 PA, PB, E; + if (Q) { + PA = Q[0]; + PB = Q[1]; + E = T(PB) - T(PA); + // cout << " AddMAtElem " << PA << " " << PB << " "<< sqrt((E,E))<< endl; + } else { + PA = TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB = TriangleHat[VerticesOfTriangularEdge[ie][1]]; + E = T.Edge(ie); + } + double le = sqrt((E, E)); + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FIb[npi]); + double sa = pi.x, sb = 1 - sa; + double coef = le * pi.a; + + R2 Pt(PA * sa + PB * sb); // + + R2 Ptu, Ptv; + R2 P(T(Pt)), Pu(P), Pv(P); + MeshPointStack(stack)->set(Th, P, Pt, T, label, R2(E.y, -E.x) / le, ie); + if (mapu) Pu = R2(GetAny< double >((*mapu[0])(vstack)), GetAny< double >((*mapu[1])(vstack))); + if (mapt) Pv = R2(GetAny< double >((*mapt[0])(vstack)), GetAny< double >((*mapt[1])(vstack))); + + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Triangle *tu, *tv; + if (sameu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(Pu, Ptu, outsideu); + if (!tu || (outsideu && !intmortar)) { + // R dd=-1; + // if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << Ptu << " " << tu << endl; + continue; + } + } + iut = Thu(tu); - //////////////////////////////////////////////// - // AddMatElem - //////////////////////////////////////////////// + if (samev) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(Pv, Ptv, outsidev); + if (!tv || (outsidev && !intmortar)) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + } + ivt = Thv(tv); - // case 2d - // --------- FH 170605 + FElement Ku(Uh[iut]); + FElement Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction - template - void AddMatElem(MatriceMap & A,const Mesh & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpace & Uh,const FESpace & Vh, - const QuadratureFormular & FI, - const QuadratureFormular1d & FIb, - double *p, void *vstack, bool intmortar=false,R2 *Q=0) - { - //cout << "AddMatElem" << Q << " " << ie << endl; - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Mesh & Thu(Uh.Th); - const Mesh & Thv(Vh.Th); - - bool same = &Uh == & Vh; - const Triangle & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(lastop<=3); + if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (ie<0) + for (i = 0; i < n; i++) + // if (onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // juste the df on edge bofbof generaly wrong FH dec 2003 { - for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;}} - if(same) - { - tv=tu; - outsidev=outsideu; - Ptv=Ptu; - } - else - { - if(&Th == & Thv ) - { - tv =&T; - Ptv=Pt; - } - else - { - tv= Thv.Find(P,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - }} - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElement Ku(Uh[iut]); - FElement Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " on T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } + RNM_ wi(fv(i, '.', '.')); + int ig = Kv(i); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg = Ku(j); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + double wij = w_i * w_j; + if (abs(wij) >= 1e-10 && (verbosity > 1000)) cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i * w_j << " on edge \n"; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += wij * coef * ccc; + } + } } - else // int on edge ie - { - R2 PA,PB,E; - if(Q) - { - PA=Q[0]; - PB=Q[1]; - E=T(PB)-T(PA); - // cout << " AddMAtElem " << PA << " " << PB << " "<< sqrt((E,E))<< endl; - } - else - { - PA=TriangleHat[VerticesOfTriangularEdge[ie][0]]; - PB=TriangleHat[VerticesOfTriangularEdge[ie][1]]; - E=T.Edge(ie); - } - double le = sqrt((E,E)); + } + } - for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " <100) cout << " On a pas trouver (v) " << P << " " << endl; - continue;}} - ivt = Thv(tv); - } - FElement Ku(Uh[iut]); - FElement Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction + *MeshPointStack(stack) = mp; + } - Ku.BF(Dop,Ptu,fu); - if( !same) - Kv.BF(Dop,Ptv,fv); + // 3D volume + template< class R > + void AddMatElem(MatriceMap< R > &A, const Mesh3 &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpace3 &Uh, const FESpace3 &Vh, + const Fem2D::GQuadratureFormular< R3 > &FI, const QuadratureFormular &FIb, double *p, void *vstack, bool intmortar = false) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + static int count = 0; // non test FH ......................... + if (count++ < 1) { + cout << " Warning : Assemble Matrix with incompatible 3d meshes in test (FH) " << endl; + cout << " ------------------------------------------------------------- " << endl; + } + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Mesh3 &Thu(Uh.Th); + const Mesh3 &Thv(Vh.Th); - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(Th,P,Pt,T,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool same = &Uh == &Vh; + const Tet &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + // + int lastop = 0; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // assert(lastop<=3); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - } + if (ie < 0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R3 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R3 Pt(pi), Ptu, Ptv; + R3 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Tet *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; } + } } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElement3 Ku(Uh[iut]); + FElement3 Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, (long)lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, (long)lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " on T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + else // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { - *MeshPointStack(stack) = mp; - } - + GQuadraturePoint< R2 > pi(FIb[npi]); + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; + double coef = 0.5 * mes * pi.a; // correction 0.5 050109 FH + R3 Pt(T.PBord(ie, pi)); + // Ku.BF(Dop,Pt,fu); + + R3 Ptu, Ptv; + R3 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Tet *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || (outsideu && !intmortar)) { + // R dd=-1; + // if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << Ptu << " " << tu << endl; + continue; + } + } + iut = Thu(tu); + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + ivt = iut; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || (outsidev && !intmortar)) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + } + ivt = Thv(tv); + } + FElement3 Ku(Uh[iut]); + FElement3 Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + if (!same) Kv.BF(Dop, Ptv, fv); + + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(Th, P, Pt, T, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // juste the df on edge bofbof generaly wrong FH dec 2003 + { + RNM_ wi(fv(i, '.', '.')); + int ig = Kv(i); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg = Ku(j); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + double wij = w_i * w_j; + if (abs(wij) >= 1e-10 && (verbosity > 1000)) cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i * w_j << " on edge \n"; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += wij * coef * ccc; + } + } + } + } -template using QFMesh= GQuadratureFormular ; -template using QFMeshB= GQuadratureFormular ; + *MeshPointStack(stack) = mp; + } -template void getmap(Stack stack,Rd & P,Expression const * const map) -{ - if(map) - for(int i=0; i< Rd::d;++i) - P[i] = GetAny((*map[i])(stack)); -}; -/* - - */ -R3 toR3(R2 P){ return R3(P.x,P.y,0);} -R3 toR3(R3 P){ return P;} -R3 toR3(R1 P){ return R3(P.x,0.,0);} + // 3D surface case + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshS &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceS &Uh, const FESpaceS &Vh, const QuadratureFormular &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshS &Thu(Uh.Th); + const MeshS &Thv(Vh.Th); + + bool same = &Uh == &Vh; + const TriangleS &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + // -template -struct DataQPElm { + // KN Dop(last_operatortype); + // Op.DiffOp(Dop); + // int lastop=1+Dop.last(binder1st >(equal_to(),true)); + // assert(lastop<=3); - typedef typename Mesh::Element Elm; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::RdHat RdHat; - typedef typename Mesh::BorderElement::RdHat RdHatB; + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); - const Mesh &Th; - RdHat Ph; - Rd P; - bool outside; - const Elm * pK; - long it ; - Stack stack; - Expression const * const mapp; - DataQPElm(Stack s,const Mesh &TTh,Expression const * const mappp=0): Th(TTh),stack(s),mapp(mappp){} - void Set(RdHat PPh,Elm * pKK) + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R2 Pt(pi), Ptu, Ptv; + R3 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const TriangleS *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + } + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementS Ku(Uh[iut]); + FElementS Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on edge ie { - Ph=PPh; - pK=pKK; - it = Th(pK); - P = (*pK)(Ph) ; - outside = false; - } - template bool same(DataQPElm & from) {return false;} - bool same(DataQPElm & from) {return & Th == & from.Th;} + // ffassert(0); + R2 PA, PB; + PA = TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB = TriangleHat[VerticesOfTriangularEdge[ie][1]]; + R3 E = T.Edge(ie); + double le = sqrt((E, E)); + + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FIb[npi]); + double sa = pi.x, sb = 1 - sa; + double coef = le * pi.a; + R2 Pt(PA * sa + PB * sb); + R2 Ptu, Ptv; + R3 P(T(Pt)); + + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const TriangleS *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); ////// probleme + if (!tu || (outsideu && !intmortar)) { + // R dd=-1; + // if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << Ptu << " " << tu << endl; + continue; + } + } - template - bool copy(DataQPElm & from) - { - R3 P3 = toR3(from.P); // to be sure !!!!! - P = Rd(&P3); - getmap(stack,P,mapp); - pK= Th.Find(P,Ph,outside); - if( !pK || outside) { - if(verbosity>99) cout << " Do not find P (u or v) " << P << " in " << Th << endl; - return false;} - it = Th(pK); - - return true; - } - //template<> - bool copy(DataQPElm & from) - { - if( & Th == &from.Th && mapp ==0 ) // same mesh and no map - {// just copy - Ph=from.Ph; - P=from.P; - outside=from.outside; - pK = from.pK; - it = from.it; - } // - else { - P = from.P; - getmap(stack,P,mapp); - pK= Th.Find(P,Ph,outside); - if( !pK || outside) { - if(verbosity>99) cout << " Do not find P (u or v) " << P << " in " << Th << endl; - return false;} - it = Th(pK); - } - return true; - } - -}; + iut = Thu(tu); -/* Essai F. Hecht !!! -template -bool optfindnotsame(const Mesh &Thu,const ElmU *&Ku,Rd & Pu,RdH & Ptu,bool & outsideu) - { - Ku= Thu.Find(Pu,Ptu,outsideu); - if( !Ku || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u or v ) " << Pu << " " << endl; - return false;} - }; - -template -bool optfindsame(const ElmU *&K,RdH & Pt,bool &outside, const ElmU *&Ku,RdH & Ptu,bool &outsideu) - { - Ku=K; - outsideu=outside; - Ptu=Pt; - return true; + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + ivt = iut; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || (outsidev && !intmortar)) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + } + ivt = Thv(tv); + } + + FElementS Ku(Uh[iut]); + FElementS Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + if (!same) Kv.BF(Dop, Ptv, fv); + + R3 NN = T.N(ie); // dHat=2 + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(Th, P, Pt, T, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // juste the df on edge bofbof generaly wrong FH dec 2003 + { + RNM_ wi(fv(i, '.', '.')); + int ig = Kv(i); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg = Ku(j); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + double wij = w_i * w_j; + if (abs(wij) >= 1e-10 && (verbosity > 1000)) cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i * w_j << " on edge \n"; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += wij * coef * ccc; + } + } + } + } } -*/ - template - void AddMatElem2(Expression const *const mapu,Expression const * const mapt, MatriceMap & A,const Mesh & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpaceU & Uh,const FESpaceV & Vh, - const QFMesh & FI, - const QFMeshB & FIb, - double *p, void *vstack, bool intmortar=false,typename Mesh::Rd *Q=0) - { - typedef typename FESpaceU::Mesh MeshU; - typedef typename FESpaceV::Mesh MeshV; - typedef typename FESpaceU::FElement FElmU; - typedef typename FESpaceV::FElement FElmV; - - typedef typename Mesh::Element Elm; - //cout << "AddMatElem" << Q << " " << ie << endl; - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshU & Thu(Uh.Th); - const MeshV & Thv(Vh.Th); - DataQPElm Pq(stack,Th); - DataQPElm Pu(stack,Th,mapu); - DataQPElm Pv(stack,Th,mapt); - - bool same = ((const void*) &Uh == (const void*)& Vh) && !mapu && !mapt; - bool sameu = (const void*)&Th == (const void*)& Thu && !mapu ; - bool samev = (const void*)&Th == (const void*)& Thv && !mapt ; - - const Elm & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(lastop<=3); + *MeshPointStack(stack) = mp; + } - if (ie<0) - { - for (npi=0;npiset(Th,Pq.P,Pq.Ph,Pq.T,notalabel); - if(!Pu.copy(Pq)) continue;// no in mesh !!! - if(same) Pv.copy(Pu);// simple copy - else if(!Pv.copy(Pq)) continue;// refinded !!! - - double coef = T.mes()*pi.a; - - int iut = Pu.it;//Thu(tu); - int ivt = Pv.it; - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - auto Ku=*Pu.pK; - auto Kv=*Pv.pK; - // FElmV Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - - Ku.BF(Dop,Pu.Ph,fu); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Pv.Ph,fv); - for ( i=0; i + void AddMatElem(MatriceMap< R > &A, const MeshL &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceL &Uh, const FESpaceL &Vh, const GQuadratureFormular< R1 > &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshL &Thu(Uh.Th); + const MeshL &Thv(Vh.Th); + + bool same = &Uh == &Vh; + const EdgeL &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); - // attention la fonction test donne la ligne - // et la fonction test est en second - int ig = Kv(i); - RNM_ wi(fv(i,'.','.')); - for ( j=0; j jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " on T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi), Ptu, Ptv; + R3 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const EdgeL *tu, *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } } - else // int on edge or face !!! ie - { - double mes = T.mesBord(ie); - auto NN = T.N(ie); - for (npi=0;npiset(Th,Pq.P,Pq.Ph,T,label,NN,ie); - if(!Pu.copy(Pq)) continue;// no in mesh !!! - if(same) Pv.copy(Pu);// simple copy - else if(!Pv.copy(Pq)) continue;// refinded !!! - - - const FElement Ku =*Pu.pK; - const FElement Kv =*Pv.pK; - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - Ku.BF(Dop,Pu.Ph,fu); - if( !same) - Kv.BF(Dop,Pv.Ph,fv); - - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - } + if (same) { + tv = tu; + outsidev = outsideu; + Ptv = Ptu; + } else { + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; } + } } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementL Ku(Uh[iut]), Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N; + long M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + Ku.BF(Dop, Ptu, fu); + R3 NNt = T.TangenteUnitaire( ); + MeshPointStack(stack)->set(Th, P, Pt, T, NNt, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + //{ + ffassert(0); + /*R2 PA,PB; + PA=TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB=TriangleHat[VerticesOfTriangularEdge[ie][1]]; + R3 E=T.Edge(ie); + double le = sqrt((E,E)); + for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " < -void AddMatElem2(Expression const *const mapu,Expression const * const mapt, MatriceMap & A,const MeshS & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpaceS & Uh,const FESpaceS & Vh, - const QFMesh & FI, - const QFMeshB & FIb, - double *p, void *vstack, bool intmortar,MeshS::Rd *Q); + iut = Thu(tu); -// Warning reput F Hecht 3 May 2024 from -// commit 897a6ed0606d497b043b593e0d7db86448731889 (HEAD -> master, tag: v4.9, origin/master, origin/HEAD) - template - void AddMatElem(Expression const *const mapu,Expression const * const mapt, MatriceMap & A,const Mesh & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpace & Uh,const FESpace & Vh, - const QuadratureFormular & FI, - const QuadratureFormular1d & FIb, - double *p, void *vstack, bool intmortar=false,R2 *Q=0) - { - //cout << "AddMatElem" << Q << " " << ie << endl; - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Mesh & Thu(Uh.Th); - const Mesh & Thv(Vh.Th); - - bool same = (&Uh == & Vh) && !mapu && !mapt; - bool sameu = &Th == & Thu && !mapu ; - bool samev = &Th == & Thv && !mapt ; - const Triangle & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(lastop<=3); - - if (ie<0) - { - for (npi=0;npiset(Th,P,Pt,T,label); - - if(mapu) - Pu = R2( GetAny((*mapu[0])(vstack)), GetAny((*mapu[1])(vstack))); - if(mapt) - Pv = R2( GetAny((*mapt[0])(vstack)), GetAny((*mapt[1])(vstack))); - if(verbosity>9999 && (mapu || mapt) ) - cout << " mapinng: " << P << " AddMatElem + map -> (u) " << Pu << " (t) ->"<< Pv << endl; - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const Triangle * tu,*tv; - if(sameu ) - { - tu =&T; - Ptu=Pt; - } - else - { - tu= Thu.Find(Pu,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;}} - if(same ) - { - tv=tu; - outsidev=outsideu; - Ptv=Ptu; - } - else if(samev) - { - tv =&T; - Ptv=Pt; - - } - else - { - tv= Thv.Find(Pv,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - } - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElement Ku(Uh[iut]); - FElement Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - - Ku.BF(Dop,Ptu,fu); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " on T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on edge ie - { - R2 PA,PB,E; - if(Q) - { - PA=Q[0]; - PB=Q[1]; - E=T(PB)-T(PA); - // cout << " AddMAtElem " << PA << " " << PB << " "<< sqrt((E,E))<< endl; - } - else - { - PA=TriangleHat[VerticesOfTriangularEdge[ie][0]]; - PB=TriangleHat[VerticesOfTriangularEdge[ie][1]]; - E=T.Edge(ie); - } - double le = sqrt((E,E)); - - for (npi=0;npiset(Th,P,Pt,T,label,R2(E.y,-E.x)/le,ie); - if(mapu) - Pu = R2( GetAny((*mapu[0])(vstack)), GetAny((*mapu[1])(vstack))); - if(mapt) - Pv = R2( GetAny((*mapt[0])(vstack)), GetAny((*mapt[1])(vstack))); - - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const Triangle * tu, *tv; - if(sameu ) - { - tu =&T; - Ptu=Pt; - } - else - { - tu= Thu.Find(Pu,Ptu,outsideu); - if( !tu || (outsideu && !intmortar) ) { - //R dd=-1; - //if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " <100) cout << " On a pas trouver (v) " << P << " " << endl; - continue;}} - ivt = Thv(tv); - - FElement Ku(Uh[iut]); - FElement Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - Ku.BF(Dop,Ptu,fu); - if( !same) - Kv.BF(Dop,Ptv,fv); - - - // int label=-999999; // a passer en argument - - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - } - } - } - - *MeshPointStack(stack) = mp; - } - - - //3D volume - template - void AddMatElem(MatriceMap & A,const Mesh3 & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpace3 & Uh,const FESpace3 & Vh, - const Fem2D::GQuadratureFormular & FI, - const QuadratureFormular & FIb, - double *p, void *vstack, bool intmortar=false) - { - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - static int count =0; // non test FH ......................... - if(count++ < 1) { - cout << " Warning : Assemble Matrix with incompatible 3d meshes in test (FH) " << endl; - cout << " ------------------------------------------------------------- " << endl; - } - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Mesh3 & Thu(Uh.Th); - const Mesh3 & Thv(Vh.Th); - - bool same = &Uh == & Vh; - const Tet & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() pi(FI[npi]); - double coef = T.mesure()*pi.a; - R3 Pt(pi),Ptu,Ptv; - R3 P(T(Pt)); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const Tet * tu,*tv; - if(&Th == & Thu ) - { - tu =&T; - Ptu=Pt; - } - else - { - tu= Thu.Find(P,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;}} - if(same) - { - tv=tu; - outsidev=outsideu; - Ptv=Ptu; - } - else - { - if(&Th == & Thv ) - { - tv =&T; - Ptv=Pt; - } - else - { - tv= Thv.Find(P,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - }} - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElement3 Ku(Uh[iut]); - FElement3 Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,(long) lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,(long) lastop); // the value for basic fonction - - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " on T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - else // int on edge ie - for (npi=0;npi pi( FIb[npi]); - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; - double coef = 0.5*mes*pi.a; // correction 0.5 050109 FH - R3 Pt(T.PBord(ie,pi)); - //Ku.BF(Dop,Pt,fu); - - - - R3 Ptu,Ptv; - R3 P(T(Pt)); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const Tet * tu, *tv; - if(&Th == & Thu ) - { - tu =&T; - Ptu=Pt; - } - else - { - tu= Thu.Find(P,Ptu,outsideu); - if( !tu || (outsideu && !intmortar) ) { - //R dd=-1; - //if(tu) { R2 PP((*tu)(Ptu)),PPP(P,PP) ; cout << PP << " " << sqrt( (PPP,PPP) ) <<" "; } - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " <100) cout << " On a pas trouver (v) " << P << " " << endl; - continue;}} - ivt = Thv(tv); - } - FElement3 Ku(Uh[iut]); - FElement3 Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - Ku.BF(Dop,Ptu,fu); - if( !same) - Kv.BF(Dop,Ptv,fv); - - - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(Th,P,Pt,T,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - } - } - - - *MeshPointStack(stack) = mp; - } - - - // 3D surface case - template - void AddMatElem(MatriceMap & A,const MeshS & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpaceS & Uh,const FESpaceS & Vh, - const QuadratureFormular & FI, - const QuadratureFormular1d & FIb, - double *p, void *vstack, bool intmortar=false) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshS & Thu(Uh.Th); - const MeshS & Thv(Vh.Th); - - bool same = &Uh == & Vh; - const TriangleS & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop(last_operatortype); - //Op.DiffOp(Dop); - //int lastop=1+Dop.last(binder1st >(equal_to(),true)); - //assert(lastop<=3); - - int lastop=0; - What_d Dop = Op.DiffOp(lastop); - - if (ie<0) + if(same) { - for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;}} - if(same) - { - tv=tu; - outsidev=outsideu; - Ptv=Ptu; - } - else - { - if(&Th == & Thv ) - { - tv =&T; - Ptv=Pt; - } - else - { - tv= Thv.Find(P,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - }} - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementS Ku(Uh[iut]); - FElementS Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } + tv=tu; + outsidev=outsideu; + Ptv=Ptu; + ivt=iut; } - else // int on edge ie - { - // ffassert(0); - R2 PA,PB; - PA=TriangleHat[VerticesOfTriangularEdge[ie][0]]; - PB=TriangleHat[VerticesOfTriangularEdge[ie][1]]; - R3 E=T.Edge(ie); - double le = sqrt((E,E)); - - for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " <100) cout << " On a pas trouver (v) " << P << " " << endl; - continue;}} - ivt = Thv(tv); - } - - FElementS Ku(Uh[iut]); - FElementS Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - Ku.BF(Dop,Ptu,fu); - if( !same) - Kv.BF(Dop,Ptv,fv); - - R3 NN= T.N(ie); //dHat=2 - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(Th,P,Pt,T,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - }} - } - - - *MeshPointStack(stack) = mp; - } - - - - - // 3D curve case - template - void AddMatElem(MatriceMap & A,const MeshL & Th,const BilinearOperator & Op,bool sym,int it, int ie,int label, - const FESpaceL & Uh,const FESpaceL & Vh, - const GQuadratureFormular & FI, - const QuadratureFormular1d & FIb, - double *p, void *vstack, bool intmortar=false) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshL & Thu(Uh.Th); - const MeshL & Thv(Vh.Th); - - bool same = &Uh == & Vh; - const EdgeL & T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi),Ptu,Ptv; - R3 P(T(Pt)); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const EdgeL * tu,*tv; - if(&Th == & Thu ) { - tu =&T; - Ptu=Pt; - } - else { - tu= Thu.Find(P,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;} - } - if(same) { - tv=tu; - outsidev=outsideu; - Ptv=Ptu; - } - else { - if(&Th == & Thv ) { - tv =&T; - Ptv=Pt; - } - else { - tv= Thv.Find(P,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - } - } - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementL Ku(Uh[iut]), Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - - Ku.BF(Dop,Ptu,fu); - R3 NNt=T.TangenteUnitaire(); - MeshPointStack(stack)->set(Th,P,Pt,T,NNt,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)) ; - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - //{ - ffassert(0); - /*R2 PA,PB; - PA=TriangleHat[VerticesOfTriangularEdge[ie][0]]; - PB=TriangleHat[VerticesOfTriangularEdge[ie][1]]; - R3 E=T.Edge(ie); - double le = sqrt((E,E)); - for (npi=0;npi100) cout << " On a pas trouver (u) " << P << " " <100) cout << " On a pas trouver (v) " << P << " " << endl; - continue;}} - ivt = Thv(tv); - } - - FElementS Ku(Uh[iut]); - FElementS Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N; - long M= Ku.N; - // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - - Ku.BF(Dop,Ptu,fu); - if( !same) - Kv.BF(Dop,Ptv,fv); - - R3 NN= T.N(ie); //dHat=2 - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(Th,P,Pt,T,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - double wij = w_i*w_j; - if (abs(wij)>= 1e-10&& (verbosity>1000)) - cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += wij*coef*ccc ; - } - } - }} - }*/ - - - *MeshPointStack(stack) = mp; - } - - -// 3D curve / 2D on meshL -template -void AddMatElem(MatriceMap & A,const MeshL & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpaceL & Uh,const FESpace & Vh,const GQuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshL & Thu(Uh.Th); - const Mesh & Thv(Vh.Th); - - bool same = false; - const EdgeL &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop2(last_operatortype); - Op.DiffOp(Dop2); - int lastop2=lastop;//1+Dop2.last(binder1st >(equal_to(),true)); - double epsP=1e-6; // must be choose - - if (ie<0) - { - for (npi=0;npi pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi),Ptu; - R2 Ptv; - R3 P(T(Pt)); - R2 PP(P.p2()); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const EdgeL * tu; - const Triangle *tv; - if(&Th == & Thu) { - tu =&T; - Ptu=Pt; - } - else { - tu= Thu.Find(P,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - } - if(abs(P.z)>epsP) {outsidev=true;tv=0;} - else tv= Thv.Find(PP,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementL Ku(Uh[iut]); - FElement Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop2); // the value for basic fonction // AXEL lastop2 - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop2,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} - -// 2D / 3D curve on meshL -template -void AddMatElem(MatriceMap & A,const MeshL & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpace & Uh,const FESpaceL & Vh,const GQuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Mesh & Thu(Uh.Th); - const MeshL & Thv(Vh.Th); - - bool same = false; - const EdgeL &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() Dop2(last_operatortype); - Op.DiffOp(Dop2); - int lastop2=lastop;//1+Dop2.last(binder1st >(equal_to(),true)); - double epsP=1e-6; // must be choose - - if (ie<0) { - for (npi=0;npi pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi),Ptv; - R2 Ptu; - R3 P(T(Pt)); - R2 PP(P.p2()); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const Triangle * tu; - const EdgeL *tv; - if(abs(P.z)>epsP) {outsidev=true;tu=0;} - else tu= Thu.Find(PP,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - - if(&Th == & Thv ) { - tv =&T; - Ptv=Pt; + tv =&T; + Ptv=Pt; } else { - tv= Thv.Find(P,Ptv,outsideu); - if( !tv || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;} - } - - iut = Thu(tu); + tv= Thv.Find(P,Ptv,outsidev); + if( !tv || (outsidev&& !intmortar)) { + if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; + continue;}} ivt = Thv(tv); - - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElement Ku(Uh[iut]); - FElementL Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop2); // the value for basic fonction // AXEL lastop2 - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; - - Ku.BF(Dop2,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} -// 3D Surf / 3D volume on meshS -template -void AddMatElem(MatriceMap & A,const MeshS & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpaceS & Uh,const FESpace3 & Vh,const QuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshS & Thu(Uh.Th); - const Mesh3 & Thv(Vh.Th); - - bool same = false; - const TriangleS &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() 100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - } - tv= Thv.Find(PP,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementS Ku(Uh[iut]); - FElement3 Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} -// 3D volume / 3D Surf on meshS -template -void AddMatElem(MatriceMap & A,const MeshS & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpace3 & Uh,const FESpaceS & Vh,const QuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Mesh3 & Thu(Uh.Th); - const MeshS & Thv(Vh.Th); - - bool same = false; - const TriangleS &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() 100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - - if(&Th == & Thv ) { - tv =&T; - Ptv=Pt; - } - else { - tv= Thv.Find(PP,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;} - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElement3 Ku(Uh[iut]); - FElementS Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} - - -// 3D curve / 3D Surf on meshL -template -void AddMatElem(MatriceMap & A,const MeshL & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpaceL & Uh,const FESpaceS & Vh,const GQuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshL & Thu(Uh.Th); - const MeshS & Thv(Vh.Th); - - bool same = false; - const EdgeL &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi),Ptu; - R2 Ptv; - R3 P(T(Pt)); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const EdgeL * tu; - const TriangleS *tv; - if(&Th == & Thu) { - tu =&T; - Ptu=Pt; - } - else { - tu= Thu.Find(P,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - } - - tv= Thv.Find(P,Ptv,outsidev); - if( !tv || outsidev) { - if(verbosity>100) cout << " On a pas trouver (v) " << P << " " << endl; - continue; - } - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementL Ku(Uh[iut]); - FElementS Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} - -// 3D Surf / 3D curve on meshL -template -void AddMatElem(MatriceMap & A,const MeshL & Th,const BilinearOperator & Op,bool sym,int it,int ie,int label, - const FESpaceS & Uh,const FESpaceL & Vh,const GQuadratureFormular & FI,const QuadratureFormular1d & FIb, - double *p,void *vstack, bool intmortar=false) -{ - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const MeshS & Thu(Uh.Th); - const MeshL & Thv(Vh.Th); - - bool same = false; - const EdgeL &T = Th[it]; - long npi; - long i,j; - bool classoptm = copt && Op.optiexpK; - assert(Op.MaxOp() pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi),Ptv; - R2 Ptu; - R3 P(T(Pt)); - R2 PP(P.p2()); - bool outsideu,outsidev; - // ici trouve le T - int iut=0,ivt=0; - const TriangleS * tu; - const EdgeL *tv; - if(abs(P.z)>epsP) {outsidev=true;tu=0;} - else tu= Thu.Find(PP,Ptu,outsideu); - if( !tu || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue; - } - if(&Th == & Thv ) { - tv =&T; - Ptv=Pt; - } - else { - tv= Thv.Find(P,Ptv,outsideu); - if( !tv || outsideu) { - if(verbosity>100) cout << " On a pas trouver (u) " << P << " " << endl; - continue;} - } - - iut = Thu(tu); - ivt = Thv(tv); - if( verbosity>1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl ; - FElementS Ku(Uh[iut]); - FElementL Kv(Vh[ivt]); - long n= Kv.NbDoF() ,m=Ku.NbDoF(); - long N= Kv.N, M= Ku.N; - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction // lastop - - Ku.BF(Dop,Ptu,fu); - MeshPointStack(stack)->set(Th,P,Pt,T,label); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - if (!same) Kv.BF(Dop,Ptv,fv); - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if( verbosity>1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i*w_j << " T \n" ; - double wij = w_i*w_j; - if (abs(wij)>= 1e-10) - A[make_pair(ig,jg)] += coef * ccc * wij; - } - } - } - } - } - else // int on point ie - ffassert(0); - - *MeshPointStack(stack) = mp; -} - - //////////////////////////////////////////////// - // AssembleBilinearForm - //////////////////////////////////////////////// - - - // creating an instance of AssembleBilinearForm with map - // case 2d - template - void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - /*FH: case ..in 2D - in varf ... - all mesh can can be different .... - */ - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - const CDomainOfIntegration & di= *b->di; - const Mesh * pThdi = GetAny( (* di.Th)(stack)); - SHOWVERB(cout << " FormBilinear () " << endl); - //MatriceElementaireSymetrique *mates =0; - // MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - - if ( verbosity >1) - { - cout << " Integral(1) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - // ExecError(" no map in the case (4) ??");} - ffassert(pThdi == & Th); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.neb/mpi_size); - int bei1 = min(Th.neb,(int)((mpi_rank+1)*ceil(1.*Th.neb/mpi_size))); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - QuadratureFormular FIT(FITo,3); - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - } - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) - InternalError("Sorry no levelset integration type on no int1d case"); - - /* - if (verbosity>3) - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; - else cout << " -- int in " ; */ - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) - { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) - { - - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3], ll=0; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int ntp= IsoLineK(f,Q,1e-10); - if(verbosity>999 && ntp==2) - { - const Triangle &T = Th[t]; - R2 E(T(Q[0]),T(Q[1])); - double le=sqrt((E,E)); - ll += le; - cout << "\t\t" << ntp <<" : " << Q[0] << " " << Q[1] << " ; " - << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll<b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar,Q); - else - AddMatElem(A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar,Q); - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - FIT =FITo; - } - - - else - { - for( int e=bei0;eb,sym,i,ie,Th.bedges[e].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - else - AddMatElem(A,Th,*b->b,sym,i,ie,Th.bedges[e].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - }} - else if (di.kind == CDomainOfIntegration::intalledges) - { - cerr << " Sorry no implement to hard "<< endl; - ExecError("FH: no intalledges on diff mesh ???"); - ffassert(0); // a faire - if(withmap) - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - } - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - - cerr << " a faire intallVFedges " << endl; - ffassert(0); - - } - else if (di.kind == CDomainOfIntegration::int2d ) - { - // cerr << " a faire CDomainOfIntegration::int2d " << endl; - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - { - if(withmap) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - else - AddMatElem(A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else - - { - if(withmap) - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - - else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - - }} - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - } - - // creating an instance of AssembleBilinearForm with map - // case 3D volume - template - void AssembleBilinearForm(Stack stack,const Mesh3 & Th,const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - /*FH: case ..in 3D - in varf ... - all mesh can can be different .... - */ - - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - Fem2D::MeshPoint & mp (*Fem2D::MeshPointStack(stack)), mps = mp; - - const CDomainOfIntegration & di= *b->di; - const Mesh3 * pThdi = GetAny( (* di.Th)(stack)); - SHOWVERB(cout << " FormBilinear () " << endl); - //MatriceElementaireSymetrique *mates =0; - // MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(2) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << endl; - } - assert(pThdi == & Th); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - - set setoflab; - bool all=true; - // const QuadratureFormular1d & FIEo = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - const GQuadratureFormular & FIVo = di.FIV(stack); - // to change the quadrature on element ... may 2014 FH .. - // QuadratureFormular1d FIE(FIEo,3); - QuadratureFormular FIT(FITo,3); - GQuadratureFormular FIV(FIVo,3); - - - - // const QuadratureFormular & FIT = di.FIT(stack); - // const Fem2D::GQuadratureFormular & FIV = di.FIV(stack); - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int2d==kind) cout << " -- boundary int border ( nQP: "<< FIT.n << ") ," ; - else if (CDomainOfIntegration::intallfaces==kind) cout << " -- boundary int all edges ( nQP: "<< FIT.n << ")," ; - //else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIT.n << ")," ; - else cout << " -- int 3d (nQP: "<< FIV.n << " ) in " ; - } - if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (2)"); - if(di.islevelset() && (CDomainOfIntegration::int2d!=kind) && (CDomainOfIntegration::int3d!=kind) ) InternalError("Sorry no levelset integration type on no int2d case"); - - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 *poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) - { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int2d ) - { - for( int e=bei0;eb,sym,i,ie,Th.be(e).lab,Uh,Vh,FIV,FIT,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else if (di.kind == CDomainOfIntegration::intallfaces) - { - ffassert(0); // a faire - - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIV,FIT,p,stack,intmortar); - - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - } - /* else if (di.kind == CDomainOfIntegration::intallVFedges) - { - - cerr << " a faire intallVFedges " << endl; - ffassert(0); - - } */ - else if (di.kind == CDomainOfIntegration::int3d ) - { - if(di.islevelset()) // may 2014 FH ... - { // int3d levelset < 0 - double llevelset = 0; - const double uset = std::numeric_limits::max(); - // cout << " uset ="< phi(Th.nv); - phi=uset; - double f[4]; - - for (int t=ti0;t< ti1; t++) - { - - const Mesh3::Element & K(Th[t]); - if (all || setoflab.find(Th[t].lab) != setoflab.end()) - - { - double umx=std::numeric_limits::lowest(),umn=std::numeric_limits::max(); - for(int i=0;i<4;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - } - int ntets= UnderIso(f,Q, vol6,1e-14); - setQF(FIV,FIVo,QuadratureFormular_Tet_1, Q,vol6,ntets); - if(FIV.n) - { - AddMatElem(A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIV,FIT,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - } - - } - } - FIV = FIVo; - - } - else - - { - // cerr << " a faire CDomainOfIntegration::int3d " << endl; - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIV,FIT,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - - } } - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - mp=mps;// restore x,y,z - - } - - // creating an instance of AssembleBilinearForm with map - // case 3D surface - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - const CDomainOfIntegration & di= *b->di; - ///typedef typename Trait_MESHO::MeshO * pmeshO; - // pmeshO ThbfO = GetAny((*b->di->Th)(stack)); // case 3D surface ThbfO = - pmeshS pThdi = GetAny((*b->di->Th)(stack)); //Trait_MESHO::topmesh(ThbfO); // - - SHOWVERB(cout << " FormBilinear () " << endl); - //MatriceElementaireSymetrique *mates =0; - // MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(3) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - // ExecError(" no map in the case (4) ??");} - assert(pThdi == & Th); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - QuadratureFormular FIT(FITo,3); - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - } - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) - InternalError("Sorry no levelset integration type on no int1d case"); - - /* - if (verbosity>3) - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; - else cout << " -- int in " ; */ - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) - { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) - { - - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3], ll=0; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int ntp= IsoLineK(f,Q,1e-10); - if(verbosity>999 && ntp==2) - { - const TriangleS &T = Th[t]; - R3 E(T(Q[0]),T(Q[1])); - double le=sqrt((E,E)); - ll += le; - cout << "\t\t" << ntp <<" : " << Q[0] << " " << Q[1] << " ; " - << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll<b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - FIT =FITo; - } - - - else - { - for( int e=bei0;eb,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - }} - /*else if (di.kind == CDomainOfIntegration::intalledges) - { - cerr << " Sorry no implement to hard "<< endl; - ExecError("FH: no intalledges on diff mesh ???"); - ffassert(0); // a faire - if(withmap) - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - else - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - }*/ - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - - cerr << " a faire intallVFedges " << endl; - ffassert(0); - - } - else if (di.kind == CDomainOfIntegration::int2d ) { - // cerr << " a faire CDomainOfIntegration::int2d " << endl; - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - { - //if(withmap) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - //else - AddMatElem(A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else - - { - //if(withmap) - // for (int i=0;i< Th.nt; i++) - // { - // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - // } - - //else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - - } - - } - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - } - - - - // creating an instance of AssembleBilinearForm with map - // case 3D curve - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - const CDomainOfIntegration & di= *b->di; - pmeshL pThdi = GetAny((*b->di->Th)(stack)); - - SHOWVERB(cout << " FormBilinear () " << endl); - - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(4) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - assert(pThdi == & Th); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind)) - InternalError("Sorry no levelset integration type on no int1d case"); - - Expandsetoflab(stack,di, setoflab,all); - - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) { - if(di.islevelset()) ////// must be check - ffassert(0); - else { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,0,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else { cout << " di.kind " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } - if (where_in_stack) delete [] where_in_stack; - } - - // creating an instance of AssembleBilinearForm with map - // case 3D curve / 2D on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - - const CDomainOfIntegration & di= *b->di; - pmeshL pThdi = GetAny((*b->di->Th)(stack)); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - SHOWVERB(cout << " FormBilinear () " << endl); - - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(5) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - assert(pThdi == & Th); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind)) - InternalError("Sorry no levelset integration type on no int1d case"); - - Expandsetoflab(stack,di, setoflab,all); - - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) { - if(di.islevelset()) - ffassert(0); - else { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,0,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else { cout << " di.kind " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } - if (where_in_stack) delete [] where_in_stack; - } - - // case 2D / 3D curve on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - - { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - - const CDomainOfIntegration & di= *b->di; - pmeshL pThdi = GetAny((*b->di->Th)(stack)); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - SHOWVERB(cout << " FormBilinear () " << endl); - - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) { - cout << " Integral(6) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - assert(pThdi == & Th); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind)) - InternalError("Sorry no levelset integration type on no int1d case"); - - Expandsetoflab(stack,di, setoflab,all); - - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) { - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - KN p(Vh.esize()+ Uh.esize() ); - - if (verbosity >3) { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) { - if(di.islevelset()) - ffassert(0); - else { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,0,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else { cout << " di.kind " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } - if (where_in_stack) delete [] where_in_stack; - } - -// case 3D Surf / 3D volume on meshS - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) - -{ - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - const CDomainOfIntegration & di= *b->di; - ///typedef typename Trait_MESHO::MeshO * pmeshO; -// pmeshO ThbfO = GetAny((*b->di->Th)(stack)); // case 3D surface ThbfO = - pmeshS pThdi = GetAny((*b->di->Th)(stack)); //Trait_MESHO::topmesh(ThbfO); // - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - SHOWVERB(cout << " FormBilinear () " << endl); - //MatriceElementaireSymetrique *mates =0; - // MatriceElementairePleine *matep =0; - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(7) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - // ExecError(" no map in the case (4) ??");} - assert(pThdi == & Th); - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - QuadratureFormular FIT(FITo,3); - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - } - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) - InternalError("Sorry no levelset integration type on no int1d case"); - - /* - if (verbosity>3) - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; - else cout << " -- int in " ; */ - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - - - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) - { - int il=0; - - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); - - - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) - { - - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3], ll=0; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int ntp= IsoLineK(f,Q,1e-10); - if(verbosity>999 && ntp==2) - { - const TriangleS &T = Th[t]; - R3 E(T(Q[0]),T(Q[1])); - double le=sqrt((E,E)); - ll += le; - cout << "\t\t" << ntp <<" : " << Q[0] << " " << Q[1] << " ; " - << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll<b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - FIT =FITo; - } - - - else - { - for( int e=bei0;eb,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - }} - /*else if (di.kind == CDomainOfIntegration::intalledges) - { - cerr << " Sorry no implement to hard "<< endl; - ExecError("FH: no intalledges on diff mesh ???"); - ffassert(0); // a faire - if(withmap) - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - else - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - - } - - }*/ - else if (di.kind == CDomainOfIntegration::intallVFedges) - { - - cerr << " a faire intallVFedges " << endl; - ffassert(0); - - } - else if (di.kind == CDomainOfIntegration::int2d ) { - // cerr << " a faire CDomainOfIntegration::int2d " << endl; - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - { - //if(withmap) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - //else - AddMatElem(A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else - - { - //if(withmap) - // for (int i=0;i< Th.nt; i++) - // { - // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - // } - - //else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - - } - - } - else - InternalError(" kind of CDomainOfIntegration unknown"); - - if (where_in_stack) delete [] where_in_stack; - } + FElementS Ku(Uh[iut]); + FElementS Kv(Vh[ivt]); + long n= Kv.NbDoF() ,m=Ku.NbDoF(); + long N= Kv.N; + long M= Ku.N; + // cout << P << " " << Pt << " " << iut << " " << ivt << " Ptu : " << Ptu << " Ptv: " << Ptv << " n:" << n << " m:" << m << endl; + RNMK_ fv(p,n,N,lastop); // the value for basic fonction + RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction + Ku.BF(Dop,Ptu,fu); + if( !same) + Kv.BF(Dop,Ptv,fv); + R3 NN= T.N(ie); //dHat=2 + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(Th,P,Pt,T,label,NN,ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + for ( i=0; i jj(ll.first.first),ii(ll.first.second); + double w_i = wi(ii.first,ii.second); + double w_j = wj(jj.first,jj.second); + // R ccc = GetAny(ll.second.eval(stack)); -// case 3D volume / 3D Surf on meshS - template - void AssembleBilinearForm(Stack stack,const MeshS & Th,const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) + R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); + double wij = w_i*w_j; + if (abs(wij)>= 1e-10&& (verbosity>1000)) + cout << " \t\t\t" << ig << " " << jg << " " << ccc << " " << coef * ccc * w_i*w_j << " on edge \n" ; + if (abs(wij)>= 1e-10) + A[make_pair(ig,jg)] += wij*coef*ccc ; + } + } + }} +}*/ -{ - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - const CDomainOfIntegration & di= *b->di; -pmeshS pThdi = GetAny((*b->di->Th)(stack)); - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - SHOWVERB(cout << " FormBilinear () " << endl); - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(8) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - // ExecError(" no map in the case (4) ??");} - assert(pThdi == & Th); - //const vector & what(di.what); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - QuadratureFormular FIT(FITo,3); - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; - if (verbosity>3) - { - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") ," ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - } - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) - InternalError("Sorry no levelset integration type on no int1d case"); - - /* - if (verbosity>3) - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; - else cout << " -- int in " ; */ - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - }*/ - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } + *MeshPointStack(stack) = mp; + } + // 3D curve / 2D on meshL + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshL &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceL &Uh, const FESpace &Vh, const GQuadratureFormular< R1 > &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - { // remove the zero coef in the liste - // R zero=R(); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - } - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshL &Thu(Uh.Th); + const Mesh &Thv(Vh.Th); - if ( (verbosity/100) % 10 >= 2) - { - int il=0; + bool same = false; + const EdgeL &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + KN< bool > Dop2(last_operatortype); + Op.DiffOp(Dop2); + int lastop2 = lastop; // 1+Dop2.last(binder1st >(equal_to(),true)); + double epsP = 1e-6; // must be choose - KN p(Vh.esize()+ Uh.esize() ); + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi), Ptu; + R2 Ptv; + R3 P(T(Pt)); + R2 PP(P.p2( )); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const EdgeL *tu; + const Triangle *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + if (abs(P.z) > epsP) { + outsidev = true; + tv = 0; + } else + tv = Thv.Find(PP, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementL Ku(Uh[iut]); + FElement Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop2); // the value for basic fonction // AXEL lastop2 + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop2, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); + *MeshPointStack(stack) = mp; + } - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } + // 2D / 3D curve on meshL + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshL &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpace &Uh, const FESpaceL &Vh, const GQuadratureFormular< R1 > &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { - if (di.kind == CDomainOfIntegration::int1d ) - { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Mesh &Thu(Uh.Th); + const MeshL &Thv(Vh.Th); - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3], ll=0; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); + bool same = false; + const EdgeL &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); - } - int ntp= IsoLineK(f,Q,1e-10); - if(verbosity>999 && ntp==2) - { - const TriangleS &T = Th[t]; - R3 E(T(Q[0]),T(Q[1])); - double le=sqrt((E,E)); - ll += le; - cout << "\t\t" << ntp <<" : " << Q[0] << " " << Q[1] << " ; " - << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll<b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - FIT =FITo; - } + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + KN< bool > Dop2(last_operatortype); + Op.DiffOp(Dop2); + int lastop2 = lastop; // 1+Dop2.last(binder1st >(equal_to(),true)); + double epsP = 1e-6; // must be choose + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi), Ptv; + R2 Ptu; + R3 P(T(Pt)); + R2 PP(P.p2( )); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Triangle *tu; + const EdgeL *tv; + if (abs(P.z) > epsP) { + outsidev = true; + tu = 0; + } else + tu = Thu.Find(PP, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsideu); + if (!tv || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } - else - { - for( int e=bei0;eb,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - //else - AddMatElem(A,Th,*b->b,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - }} - /*else if (di.kind == CDomainOfIntegration::intalledges) - { - cerr << " Sorry no implement to hard "<< endl; - ExecError("FH: no intalledges on diff mesh ???"); - ffassert(0); // a faire - if(withmap) - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + iut = Thu(tu); + ivt = Thv(tv); + + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElement Ku(Uh[iut]); + FElementL Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop2); // the value for basic fonction // AXEL lastop2 + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; + + Ku.BF(Dop2, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); + *MeshPointStack(stack) = mp; + } - } + // 3D Surf / 3D volume on meshS + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshS &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceS &Uh, const FESpace3 &Vh, const QuadratureFormular &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { - else - for (int i=0;i< Th.nt; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshS &Thu(Uh.Th); + const Mesh3 &Thv(Vh.Th); + bool same = false; + const TriangleS &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); - } + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + double epsP = 1e-6; // must be choose - }*/ - else if (di.kind == CDomainOfIntegration::intallVFedges) - { + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R2 Pt(pi), Ptu; + R3 Ptv; + R3 P(T(Pt)); + R3 PP(P); // correction FH. Sep 2022.. + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const TriangleS *tu; + const Tet *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + tv = Thv.Find(PP, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementS Ku(Uh[iut]); + FElement3 Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + // cout << " same ?0:n*N*lastop " << same ?0:n*N*lastop << endl; + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); - cerr << " a faire intallVFedges " << endl; - ffassert(0); + *MeshPointStack(stack) = mp; + } + // 3D volume / 3D Surf on meshS + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshS &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpace3 &Uh, const FESpaceS &Vh, const QuadratureFormular &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { - } - else if (di.kind == CDomainOfIntegration::int2d ) { - // cerr << " a faire CDomainOfIntegration::int2d " << endl; - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[2][3]; - double vol6[2]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(Th[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= Th(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&Th,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Mesh3 &Thu(Uh.Th); + const MeshS &Thv(Vh.Th); - } - int nt= UnderIso(f,Q, vol6,1e-14); - setQF(FIT,FITo,QuadratureFormular_T_1, Q,vol6,nt); - if(FIT.n) - { - //if(withmap) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - //else - AddMatElem(A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - FIT =FITo; - } - else + bool same = false; + const TriangleS &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); - { - //if(withmap) - // for (int i=0;i< Th.nt; i++) - // { - // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - // } - - //else - for (int i=ti0;i< ti1; i++) - { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); - } + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R2 Pt(pi), Ptv; + R3 Ptu; + R3 P(T(Pt)); + R2 PP(P.p2( )); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const Tet *tu; + const TriangleS *tv; + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(PP, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElement3 Ku(Uh[iut]); + FElementS Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); - } - else - InternalError(" kind of CDomainOfIntegration unknown"); + *MeshPointStack(stack) = mp; + } - if (where_in_stack) delete [] where_in_stack; - } + // 3D curve / 3D Surf on meshL + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshL &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceL &Uh, const FESpaceS &Vh, const GQuadratureFormular< R1 > &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshL &Thu(Uh.Th); + const MeshS &Thv(Vh.Th); -// 3D Surf / 3D curve on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) + bool same = false; + const EdgeL &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); -{ - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi), Ptu; + R2 Ptv; + R3 P(T(Pt)); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const EdgeL *tu; + const TriangleS *tv; + if (&Th == &Thu) { + tu = &T; + Ptu = Pt; + } else { + tu = Thu.Find(P, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } - const CDomainOfIntegration & di= *b->di; - pmeshL pThdi = GetAny((*b->di->Th)(stack)); + tv = Thv.Find(P, Ptv, outsidev); + if (!tv || outsidev) { + if (verbosity > 100) cout << " On a pas trouver (v) " << P << " " << endl; + continue; + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementL Ku(Uh[iut]); + FElementS Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); + *MeshPointStack(stack) = mp; + } - SHOWVERB(cout << " FormBilinear () " << endl); + // 3D Surf / 3D curve on meshL + template< class R > + void AddMatElem(MatriceMap< R > &A, const MeshL &Th, const BilinearOperator &Op, bool sym, int it, int ie, int label, const FESpaceS &Uh, const FESpaceL &Vh, const GQuadratureFormular< R1 > &FI, + const QuadratureFormular1d &FIb, double *p, void *vstack, bool intmortar = false) { - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) { - cout << " Integral(9) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - assert(pThdi == & Th); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; - - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); - - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const MeshS &Thu(Uh.Th); + const MeshL &Thv(Vh.Th); - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind)) - InternalError("Sorry no levelset integration type on no int1d case"); - - Expandsetoflab(stack,di, setoflab,all); - - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() << " total " << n_where_in_stack_opt << endl; - - if ( (verbosity/100) % 10 >= 2) { - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; - } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - KN p(Vh.esize()+ Uh.esize() ); - - if (verbosity >3) { - if (all) cout << " all " << endl ; - else cout << endl; - } - - if (di.kind == CDomainOfIntegration::int1d ) { - if(di.islevelset()) - ffassert(0); - else { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,0,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else { cout << " di.kind " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } - if (where_in_stack) delete [] where_in_stack; -} + bool same = false; + const EdgeL &T = Th[it]; + long npi; + long i, j; + bool classoptm = copt && Op.optiexpK; + assert(Op.MaxOp( ) < last_operatortype); + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + double epsP = 1e-6; // must be choose + + if (ie < 0) { + for (npi = 0; npi < FI.n; npi++) { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi), Ptv; + R2 Ptu; + R3 P(T(Pt)); + R2 PP(P.p2( )); + bool outsideu, outsidev; + // ici trouve le T + int iut = 0, ivt = 0; + const TriangleS *tu; + const EdgeL *tv; + if (abs(P.z) > epsP) { + outsidev = true; + tu = 0; + } else + tu = Thu.Find(PP, Ptu, outsideu); + if (!tu || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + if (&Th == &Thv) { + tv = &T; + Ptv = Pt; + } else { + tv = Thv.Find(P, Ptv, outsideu); + if (!tv || outsideu) { + if (verbosity > 100) cout << " On a pas trouver (u) " << P << " " << endl; + continue; + } + } + iut = Thu(tu); + ivt = Thv(tv); + if (verbosity > 1000) cout << " T " << it << " iut " << iut << " ivt " << ivt << endl; + FElementS Ku(Uh[iut]); + FElementL Kv(Vh[ivt]); + long n = Kv.NbDoF( ), m = Ku.NbDoF( ); + long N = Kv.N, M = Ku.N; + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction // lastop + + Ku.BF(Dop, Ptu, fu); + MeshPointStack(stack)->set(Th, P, Pt, T, label); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + if (!same) Kv.BF(Dop, Ptv, fv); + for (i = 0; i < n; i++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + int ig = Kv(i); + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + int jg(Ku(j)); + if (!sym || ig <= jg) + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (verbosity > 1000) cout << ig << " " << jg << " " << " " << ccc << " " << coef * ccc * w_i * w_j << " T \n"; + double wij = w_i * w_j; + if (abs(wij) >= 1e-10) A[make_pair(ig, jg)] += coef * ccc * wij; + } + } + } + } + } else // int on point ie + ffassert(0); + *MeshPointStack(stack) = mp; + } + //////////////////////////////////////////////// + // AssembleBilinearForm + //////////////////////////////////////////////// -// 3D curve / 3D Surf on meshL - template - void AssembleBilinearForm(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize = nullptr) + // creating an instance of AssembleBilinearForm with map + // case 2d + template< class R > + void AssembleBilinearForm(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; + /*FH: case ..in 2D + in varf ... + all mesh can can be different .... + */ + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr - const CDomainOfIntegration & di= *b->di; - pmeshL pThdi = GetAny((*b->di->Th)(stack)); + const CDomainOfIntegration &di = *b->di; + const Mesh *pThdi = GetAny< pmesh >((*di.Th)(stack)); + SHOWVERB(cout << " FormBilinear () " << endl); + // MatriceElementaireSymetrique *mates =0; + // MatriceElementairePleine *matep =0; + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + + if (verbosity > 1) { + cout << " Integral(1) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + // ExecError(" no map in the case (4) ??");} + ffassert(pThdi == &Th); int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*Th.nt/mpi_size); - int ti1 = min(Th.nt,(int)((mpi_rank+1)*ceil(1.*Th.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*Th.nbe/mpi_size); - int bei1 = min(Th.nbe,(int)((mpi_rank+1)*ceil(1.*Th.nbe/mpi_size))); - - SHOWVERB(cout << " FormBilinear () " << endl); - - const int useopt=di.UseOpt(stack); - //double binside=di.binside(stack); - const bool intmortar=di.intmortar(stack); - if ( verbosity >1) - { - cout << " Integral(10) on Th "<< &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; - cout << " Th/ u "<< &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; - cout << " Th/ v "<< &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; - cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset() << " withmap: " << di.withmap() << endl; - } - Expression const * const mapt=*di.mapt?di.mapt:0 ; - Expression const * const mapu=*di.mapu?di.mapu:0 ; - bool withmap =di.withmap(); - assert(pThdi == & Th); - CDomainOfIntegration::typeofkind kind = di.kind; - set setoflab; - bool all=true; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.neb / mpi_size); + int bei1 = min(Th.neb, (int)((mpi_rank + 1) * ceil(1. * Th.neb / mpi_size))); + + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + QuadratureFormular FIT(FITo, 3); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; + } + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); - const GQuadratureFormular & FITo = di.FIE(stack); - GQuadratureFormular FIT(FITo,3); + /* + if (verbosity>3) + if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; + else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; + else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; + else cout << " -- int in " ; */ + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - bool VF=b->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size()<< " Bytes\n"; + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); - if(di.islevelset() && (CDomainOfIntegration::int1d!=kind)) - InternalError("Sorry no levelset integration type on no int1d case"); + if ((verbosity / 100) % 10 >= 2) { + int il = 0; - Expandsetoflab(stack,di, setoflab,all); + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3], ll = 0; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int ntp = IsoLineK(f, Q, 1e-10); + if (verbosity > 999 && ntp == 2) { + const Triangle &T = Th[t]; + R2 E(T(Q[0]), T(Q[1])); + double le = sqrt((E, E)); + ll += le; + cout << "\t\t" << ntp << " : " << Q[0] << " " << Q[1] << " ; " << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll << endl; + } + if (ntp == 2) { + if (withmap) + AddMatElem(mapu, mapt, A, Th, *b->b, sym, t, 10, Th[t].lab, Uh, Vh, FIT, FIE, p, stack, intmortar, Q); + else + AddMatElem(A, Th, *b->b, sym, t, 10, Th[t].lab, Uh, Vh, FIT, FIE, p, stack, intmortar, Q); + if (sptrclean) sptrclean = sptr->clean( ); + } + } + } + FIT = FITo; + } - if (verbosity>3) cout <<" Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=b->b->optiexp0; - // const E_F0 & optiexpK=*b->b->optiexpK; - int n_where_in_stack_opt=b->b->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) { - assert(b->b->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;ib->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; + else { + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.bedges[e].lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + if (withmap) + AddMatElem(mapu, mapt, A, Th, *b->b, sym, i, ie, Th.bedges[e].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + else + AddMatElem(A, Th, *b->b, sym, i, ie, Th.bedges[e].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } + } + } + } else if (di.kind == CDomainOfIntegration::intalledges) { + cerr << " Sorry no implement to hard " << endl; + ExecError("FH: no intalledges on diff mesh ???"); + ffassert(0); // a faire + if (withmap) + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) AddMatElem(mapu, mapt, A, Th, *b->b, sym, i, ie, Th[i].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) AddMatElem(A, Th, *b->b, sym, i, ie, Th[i].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - if(poptiexp0) - (*poptiexp0)(stack); - KN ok(b->b->v.size()); - int il=0; - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - ok[il] = ! (b->b->mesh_indep_stack_opt[il] && ( std::norm(*(where_in_stack[il])) < 1e-100 ) ); - - BilinearOperator b_nozer(*b->b,ok); - if (verbosity % 10 > 3 ) - cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size() - << " total " << n_where_in_stack_opt << endl; + } else if (di.kind == CDomainOfIntegration::intallVFedges) { - if ( (verbosity/100) % 10 >= 2) { - int il=0; + cerr << " a faire intallVFedges " << endl; + ffassert(0); - for (BilinearOperator::const_iterator l=b->b->v.begin();l!=b->b->v.end();l++,il++) - cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) - << " offset=" << b->b->where_in_stack_opt[il] - << " dep mesh " << l->second.MeshIndependent() << b->b->mesh_indep_stack_opt[il] << endl; + } else if (di.kind == CDomainOfIntegration::int2d) { + // cerr << " a faire CDomainOfIntegration::int2d " << endl; + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2][3]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) { + if (withmap) + AddMatElem(mapu, mapt, A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIT, FIE, p, stack); + else + AddMatElem(A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIT, FIE, p, stack); + } + if (sptrclean) sptrclean = sptr->clean( ); } - } - Stack_Ptr(stack,ElemMatPtrOffset) =where_in_stack; - - KN p(Vh.esize()+ Uh.esize() ); + } + FIT = FITo; + } else + { + if (withmap) + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(mapu, mapt, A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, FIE, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - if (verbosity >3) { - if (all) cout << " all " << endl ; - else cout << endl; + else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, FIE, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } } + } else + InternalError(" kind of CDomainOfIntegration unknown"); - if (di.kind == CDomainOfIntegration::int1d ) { - if(di.islevelset()) - ffassert(0); - else { - for (int i=ti0;i< ti1; i++) { - if ( all || setoflab.find(Th[i].lab) != setoflab.end()) - AddMatElem(A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,0,p,stack); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else { cout << " di.kind " << di.kind << endl; - InternalError(" kind of CDomainOfIntegration unknown"); - } - if (where_in_stack) delete [] where_in_stack; + if (where_in_stack) delete[] where_in_stack; } + // creating an instance of AssembleBilinearForm with map + // case 3D volume + template< class R > + void AssembleBilinearForm(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) + { + /*FH: case ..in 3D + in varf ... + all mesh can can be different .... + */ - // --------- FH 170605 - //////////////////////////////////////////////// - // Element_Op for MatriceElementairePleine - //////////////////////////////////////////////// + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + Fem2D::MeshPoint &mp(*Fem2D::MeshPointStack(stack)), mps = mp; + const CDomainOfIntegration &di = *b->di; + const Mesh3 *pThdi = GetAny< pmesh3 >((*di.Th)(stack)); + SHOWVERB(cout << " FormBilinear () " << endl); + // MatriceElementaireSymetrique *mates =0; + // MatriceElementairePleine *matep =0; + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(2) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << endl; + } + assert(pThdi == &Th); - // xxxxxxxxxxxxxxxxx modif a faire - // creating an instance of Element_Op with MatriceElementairePleine - // case 2d - template - void Element_Op(MatriceElementairePleine & mat,const FElement & Ku,const FElement & Kv,double * p,int ie,int label,void *vstack,R2 *B) - { - Stack stack=pvoid2Stack(vstack); - typedef FElement::Element Element; - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - const Element & T = Ku.T; - throwassert(&T == &Kv.T); - const QuadratureFormular & FI = mat.FIT; - const QuadratureFormular1d & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - long N= Kv.N; - long M= Ku.N; + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); + + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + + set< int > setoflab; + bool all = true; + // const QuadratureFormular1d & FIEo = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + const GQuadratureFormular< R3 > &FIVo = di.FIV(stack); + // to change the quadrature on element ... may 2014 FH .. + // QuadratureFormular1d FIE(FIEo,3); + QuadratureFormular FIT(FITo, 3); + GQuadratureFormular< R3 > FIV(FIVo, 3); + + // const QuadratureFormular & FIT = di.FIT(stack); + // const Fem2D::GQuadratureFormular & FIV = di.FIV(stack); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int2d == kind) + cout << " -- boundary int border ( nQP: " << FIT.n << ") ,"; + else if (CDomainOfIntegration::intallfaces == kind) + cout << " -- boundary int all edges ( nQP: " << FIT.n << "),"; + // else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIT.n << ")," ; + else + cout << " -- int 3d (nQP: " << FIV.n << " ) in "; + } + if (di.islevelset( )) InternalError("Sorry no levelset integration type on this case (2)"); + if (di.islevelset( ) && (CDomainOfIntegration::int2d != kind) && (CDomainOfIntegration::int3d != kind)) InternalError("Sorry no levelset integration type on no int2d case"); + + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + KN< double > p(Vh.esize( ) + Uh.esize( )); - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - bool oldopt=1; // juin 2007 FH ???? a voir - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_Op P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; - assert(Op.MaxOp() 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (di.kind == CDomainOfIntegration::int2d) { + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + AddMatElem(A, Th, *b->b, sym, i, ie, Th.be(e).lab, Uh, Vh, FIV, FIT, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (di.kind == CDomainOfIntegration::intallfaces) { + ffassert(0); // a faire - KN Dop(last_operatortype); - Op.DiffOp(Dop); - // int lastop=1+Dop.last(binder1st >(equal_to(),true); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(lastop<=3); - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) AddMatElem(A, Th, *b->b, sym, i, ie, Th[i].lab, Uh, Vh, FIV, FIT, p, stack, intmortar); - for (i=0;i< nx;i++) - *pa++ = 0.; - if (ie<0 )//&& B==0) - for (npi=0;npix : T.area; - R coef = mes *pi.a; - R2 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv); - if (classoptm) { - if( oldopt) (*Op.optiexpK)(stack); // call old optim version - else Op.optiexpK->eval(stack,iloop++,unvarexp); // new optim version - } - if (!same) Kv.BF(Dop,Pt,fv); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + } + /* else if (di.kind == CDomainOfIntegration::intallVFedges) + { - // attention la fonction test donne la ligne - // et la fonction test est en second - for ( i=fi; i::max( ); + // cout << " uset ="< phi(Th.nv); + phi = uset; + double f[4]; + + for (int t = ti0; t < ti1; t++) { + + const Mesh3::Element &K(Th[t]); + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) + + { + double umx = std::numeric_limits< double >::lowest( ), umn = std::numeric_limits< double >::max( ); + for (int i = 0; i < 4; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + } + int ntets = UnderIso(f, Q, vol6, 1e-14); + setQF< R3 >(FIV, FIVo, QuadratureFormular_Tet_1, Q, vol6, ntets); + if (FIV.n) { + AddMatElem(A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIV, FIT, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } + } } - else if(B) - { // int on isovalue ... - R2 PA(B[0]),PB(B[1]); - R2 A=T(PA),B=T(PB); - R2 E(A,B); - double le = sqrt((E,E)); - // cout << " xxxx "<< le << " "<< A << " " << B << endl; - if(le > 1e-15) // bofbof ???? - for (npi=0;npiset(T(Pt),Pt,Kv,-1,R2(E.y,-E.x)/le,-1); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (f) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (f) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + FIV = FIVo; - // attention la fonction test donne la ligne - // et la fonction test est en second + } else - for ( i=fi; ib, sym, i, -1, Th[i].lab, Uh, Vh, FIV, FIT, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } - else // int on edge ie - for (npi=0;npiset(T(Pt),Pt,Kv,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + } + } else + InternalError(" kind of CDomainOfIntegration unknown"); + if (where_in_stack) delete[] where_in_stack; + mp = mps; // restore x,y,z + } - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + // creating an instance of AssembleBilinearForm with map + // case 3D surface + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - // attention la fonction test donne la ligne - // et la fonction test est en second + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr - for ( i=fi; idi; + /// typedef typename Trait_MESHO::MeshO * pmeshO; + // pmeshO ThbfO = GetAny((*b->di->Th)(stack)); // case 3D surface ThbfO = + pmeshS pThdi = GetAny< pmeshS >((*b->di->Th)(stack)); // Trait_MESHO::topmesh(ThbfO); // - /* - for ( i=0; i jj(ll.first.first),ii(ll.first.second); - - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (h) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - *pa += coef * ccc * w_i*w_j; - } - } - } - // else pa += m; FH dec 2003 - */ - } - - - /* pa=a; - if (Ku.Vh.Th(T) >=0 ) { - cout < *mates =0; + // MatriceElementairePleine *matep =0; + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(3) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + // ExecError(" no map in the case (4) ??");} + assert(pThdi == &Th); + + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); + + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + QuadratureFormular FIT(FITo, 3); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; } + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); + + /* + if (verbosity>3) + if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; + else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; + else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; + else cout << " -- int in " ; */ + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + if ((verbosity / 100) % 10 >= 2) { + int il = 0; - // creating an instance of Element_Op with MatriceElementairePleine - // case 3D volume - template - void Element_Op(MatriceElementairePleine & mat,const FElement3 & Ku,const FElement3 & Kv,double * p,int ie,int label,void *vstack,R3 *B) - { - // ffassert(B==0); - Stack stack=pvoid2Stack(vstack); - // ffassert(0); - typedef FElement3::Element Element; - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - const Element & T = Ku.T; - throwassert(&T == &Kv.T); - const GQuadratureFormular & FI = mat.FIT; - const GQuadratureFormular & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - long N= Kv.N; - long M= Ku.N; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3], ll = 0; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int ntp = IsoLineK(f, Q, 1e-10); + if (verbosity > 999 && ntp == 2) { + const TriangleS &T = Th[t]; + R3 E(T(Q[0]), T(Q[1])); + double le = sqrt((E, E)); + ll += le; + cout << "\t\t" << ntp << " : " << Q[0] << " " << Q[1] << " ; " << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll << endl; + } + if (ntp == 2) { // if( withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + // else + AddMatElem(A, Th, *b->b, sym, t, 10, Th[t].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); + } + } + } + FIT = FITo; + } + else { + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + // if( withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + // else + AddMatElem(A, Th, *b->b, sym, i, ie, Th.be(e).lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } + } + /*else if (di.kind == CDomainOfIntegration::intalledges) + { + cerr << " Sorry no implement to hard "<< endl; + ExecError("FH: no intalledges on diff mesh ???"); + ffassert(0); // a faire + if(withmap) + for (int i=0;i< Th.nt; i++) + { + if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + for (int ie=0;ie<3;ie++) + AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } + else + for (int i=0;i< Th.nt; i++) + { + if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + for (int ie=0;ie<3;ie++) + AddMatElem(A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - bool oldopt=1; // juin 2007 FH ???? a voir - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; - assert(Op.MaxOp() Dop(last_operatortype); - //p.DiffOp(Dop); - //int lastop=1+Dop.last(binder1st >(equal_to(),true)); - //assert(lastop<=3); - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction - for (i=0;i< nx;i++) - *pa++ = 0.; - if (ie<0) - for (npi=0;npi pi(FI[npi]); - R coef = T.mesure()*pi.a; - R3 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv); - if (classoptm) { - if( oldopt) (*Op.optiexpK)(stack); // call old optim version - else Op.optiexpK->eval(stack,iloop++,unvarexp); // new optim version } - if (!same) Kv.BF(Dop,Pt,fv); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_Op plein 3d (a) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization Element_Op plein 3d (a) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + }*/ + else if (di.kind == CDomainOfIntegration::intallVFedges) { - // attention la fonction test donne la ligne - // et la fonction test est en second + cerr << " a faire intallVFedges " << endl; + ffassert(0); - for ( i=fi; i phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) { + // if(withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); + // else + AddMatElem(A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIT, FIE, p, stack); + } + if (sptrclean) sptrclean = sptr->clean( ); + } } - else if(B) - { // int on leveset - int np = ie-10; //= (B[0].x == B[3].x ) && (B[0].y == B[3].y ) && (B[0].z == B[3].z ) ? 3 : 4; - if(verbosity>999) cout << " Ass mat pleine /"<< np << endl; - assert( np==3 || np==4); - // XXXXXXX - double epsmes3=T.mesure()*T.mesure()*1e-18; - R3 PP[4]; - double l[3]; - for(int i=0; i< np; ++i) - PP[i]= T(B[i]); - - for( int i =0; i+1 < np; i+=2) - { // 0,1,, a and 2,3,0. - int i0=i,i1=i+1,i2=(i+2)%np; - R3 NN= R3(PP[i0],PP[i1])^R3(PP[i0],PP[i2]); - double mes2 = (NN,NN); - double mes = sqrt(mes2); - - if(mes2*mes 999) - cout << " --int on leveset3d " << np << " " << mes << " " << i0< pi( FIb[npi]); - // cout << " %% " << npi << " " << pi.a << " " << pi.x << " " << pi.y << endl; - asum+= pi.a; - pi.toBary(l); - R3 Pt( l[0]*B[i0]+l[1]*B[i1]+l[2]*B[i2]); // - double coef = mes*pi.a; // correction 0.5 050109 FH - Ku.BF(Dop,Pt,fu); - if (!same) Kv.BF(Dop,Pt,fv); - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - pa=a; - for (int i=0; i jj(ll.first.first),ii(ll.first.second); - - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_Op plein 3d (b) add: int2d(Th,optimize=0)(...)"); - /* if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization Element_Op plein 3d (b) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - if(verbosity>999) - cout << " -- int on leveset3d aij = "<< pi.a* ccc * w_i*w_j <<" " << ccc << " " << w_i*w_j <999) cout << " ++\n"; - } - - if(verbosity>999) cout << " @@ "<< asum << endl;; + FIT = FITo; + } else - } + { + // if(withmap) + // for (int i=0;i< Th.nt; i++) + // { + // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); + // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + // } + + // else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, FIE, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - }// end int level set ... - else // int on edge ie - for (npi=0;npi pi( FIb[npi]); - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; - double coef = 0.5*mes*pi.a; // correction 0.5 050109 FH - R3 Pt(T.PBord(ie,pi)); - Ku.BF(Dop,Pt,fu); - if (!same) Kv.BF(Dop,Pt,fv); - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i jj(ll.first.first),ii(ll.first.second); + } else + InternalError(" kind of CDomainOfIntegration unknown"); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); + if (where_in_stack) delete[] where_in_stack; + } - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_Op plein 3d (c) add: int2d(Th,optimize=0)(...)"); - /* - if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization Element_Op plein 3d (c) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - *pa += coef * ccc * w_i*w_j; - } - } - } - } + // creating an instance of AssembleBilinearForm with map + // case 3D curve + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr - if (Ku.Vh.Th(T) <1 && verbosity>100) { - pa=mat.a; - cout <di; + pmeshL pThdi = GetAny< pmeshL >((*b->di->Th)(stack)); + SHOWVERB(cout << " FormBilinear () " << endl); + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(4) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + assert(pThdi == &Th); + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); - // creating an instance of Element_Op with MatriceElementairePleine - // case 3D surface - template - void Element_Op(MatriceElementairePleine & mat,const FElementS & Ku,const FElementS & Kv,double * p,int ie,int label,void *vstack,R3 *B) - { - Stack stack=pvoid2Stack(vstack); - typedef FElementS::Element Element; - - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - const Element & T = Ku.T; - throwassert(&T == &Kv.T); - const QuadratureFormular & FI = mat.FIT; - const QuadratureFormular1d & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - long N= Kv.N; - long M= Ku.N; + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - bool oldopt=1; // juin 2007 FH ???? a voir - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; - assert(Op.MaxOp() VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; - int lastop; - lastop = 0; - What_d Dop = Op.DiffOp(lastop); + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); - //assert(lastop<=3); - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction + Expandsetoflab(stack, di, setoflab, all); - for (i=0;i< nx;i++) - *pa++ = 0.; - if (ie<0 )//&& B==0) - for (npi=0;npix : T.mesure(); - R coef = mes *pi.a; - R2 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv); - if (classoptm) { - if( oldopt) (*Op.optiexpK)(stack); // call old optim version - else Op.optiexpK->eval(stack,iloop++,unvarexp); // new optim version - } - if (!same) Kv.BF(Dop,Pt,fv); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); - /*if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - // attention la fonction test donne la ligne - // et la fonction test est en second - for ( i=fi; i= 2) { + int il = 0; + + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) ////// must be check + ffassert(0); + else { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, 0, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } - else if(B) - ffassert(0); - else // int on edge ie - for (npi=0;npiset(T(Pt),Pt,Kv,label,NN,NNt,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + } + } else { + cout << " di.kind " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); + } + if (where_in_stack) delete[] where_in_stack; + } + // creating an instance of AssembleBilinearForm with map + // case 3D curve / 2D on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)"); - /* - if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; - // attention la fonction test donne la ligne - // et la fonction test est en second + const CDomainOfIntegration &di = *b->di; + pmeshL pThdi = GetAny< pmeshL >((*b->di->Th)(stack)); - for ( i=fi; i jj(ll.first.first),ii(ll.first.second); - - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (h) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - *pa += coef * ccc * w_i*w_j; - } - } - } - // else pa += m; FH dec 2003 - */ - } - - - /* pa=a; - if (Ku.Vh.Th(T) >=0 ) { - cout < - void Element_Op(MatriceElementairePleine & mat,const FElementL & Ku,const FElementL & Kv,double * p,int ie,int label,void *vstack,R3 *B) - { - Stack stack=pvoid2Stack(vstack); - typedef FElementL::Element Element; - - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - bool same = &Ku == & Kv; - const Element & T = Ku.T; - throwassert(&T == &Kv.T); - //const QuadratureFormular & FI = mat.FIT; - const GQuadratureFormular & FI = mat.FIT; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*m; - long N= Kv.N; - long M= Ku.N; + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(5) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + assert(pThdi == &Th); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - bool oldopt=1; // juin 2007 FH ???? a voir - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; - assert(Op.MaxOp() 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - //assert(lastop<=3); - RNMK_ fv(p,n,N,lastop); // the value for basic fonction - RNMK_ fu(p+ (same ?0:n*N*lastop) ,m,M,lastop); // the value for basic fonction + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); - for (i=0;i< nx;i++) - *pa++ = 0.; - int ll=-1; //bof bof - R3 NNt=T.TangenteUnitaire(); - R3 NN; - if (ie<0 )//&& B==0) - for (npi=0;npi pi(FI[npi]); - R mes = B ? B->x : T.mesure(); - R coef = mes *pi.a; - R1 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv,-1,NN,NNt,-1);// non on boundary ,NNt,ll);//,label,NN,NNt,ie); Axel - if (classoptm) { - if( oldopt) (*Op.optiexpK)(stack); // call old optim version - else Op.optiexpK->eval(stack,iloop++,unvarexp); // new optim version - } - if (!same) Kv.BF(Dop,Pt,fv); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); - /*if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; - - // attention la fonction test donne la ligne - // et la fonction test est en second - for ( i=fi; i pi(1.,s); - R mes = 1.; - R3 NN=NNt; - if(ie==0) NN=-NN; - R coef = 1.; - R1 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,NNt,ie);// Axel - if (classoptm) { - if( oldopt) (*Op.optiexpK)(stack); // call old optim version - else Op.optiexpK->eval(stack,iloop++,unvarexp); // new optim version - } - if (!same) Kv.BF(Dop,Pt,fv); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( mat.optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - //cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); - /*if ( ccc != cc) { - cerr << cc << " != " << ccc << " => "; - cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - int fi=Kv.dfcbegin(icomp); - int li=Kv.dfcend(icomp); - int fj=Ku.dfcbegin(jcomp); - int lj=Ku.dfcend(jcomp); - ccc *= coef; - - // attention la fonction test donne la ligne - // et la fonction test est en second - for ( i=fi; ib, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; - *MeshPointStack(stack) = mp; - } + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + KN< double > p(Vh.esize( ) + Uh.esize( )); - //////////////////////////////////////////////// - // Element_Op for MatriceElementaireSymetrique - //////////////////////////////////////////////// - // using to define new solver + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } - // creating an instance of Element_Op with MatriceElementaireSymetrique - // case 2d - // xxxxxxxxxxxxxxxxx modif a faire - template - void Element_Op(MatriceElementaireSymetrique & mat,const FElement & Ku,double * p,int ie,int label, void * vstack,R2*B) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Triangle & T = Ku.T; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - // const QuadratureFormular1d & FIb = QF_GaussLegendre2; - const QuadratureFormular & FI = mat.FIT; - const QuadratureFormular1d & FIb = mat.FIE; - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*(m+1)/2; - long N= Ku.N; - //long M=N; - // bool show = Ku.Vh.Th(T)==0; - // char * xxx[] ={" u"," v"," p"," q"," r"}; - //char * xxxx[] ={" u'"," v'"," p'"," q'"," r'"}; - //char * yyy[] ={" ","_x ","_y "}; - - - throwassert(mat.bilinearform); - - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) || (Op.where_in_stack_opt.size() !=0) ); - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2 ) - cout << "Element_Op S: copt = " << copt << " " << classoptm << " opt "<< mat.optim << endl; - assert(Op.MaxOp() Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - // assert(lastop<=3); - - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - - pa =a; - for (i=0;i< nx;i++) - *pa++ = 0.; - - if (ie<0) - for (npi=0;npix :T.area; - double coef = mes*pi.a; - R2 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(pi),pi,Ku); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) + ffassert(0); + else { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, 0, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else { + cout << " di.kind " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); + } + if (where_in_stack) delete[] where_in_stack; + } - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - if (verbosity>10 && Ku.Vh.Th(T) < 1 && npi < 1) - cout << " ic "<< icomp << fi<< " "<< lj << " "<< " c "<< jcomp << " " < + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - mat(i,j) += c * w_i*w_j; + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; - } + const CDomainOfIntegration &di = *b->di; + pmeshL pThdi = GetAny< pmeshL >((*b->di->Th)(stack)); - } + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); - /* - for ( i=0; i "; - cerr << "Sorry error in Optimization (m) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - *pa += coef * c * w_i*w_j; - } - } - - }*/ - - } - else if(B) - { - R2 PA(B[0]),PB(B[1]); - R2 A=T(PA),B=T(PB); - R2 E(A,B); - double le = sqrt((E,E)); - if(le > 1e-15) - for (npi=0;npi 1) { + cout << " Integral(6) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + assert(pThdi == &Th); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; - double coef = le*pi.a; - double sa=pi.x,sb=1-sa; - R2 Pt(PA*sa+PB*sb ); // - Ku.BF(Dop,Pt,fu); - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(T(Pt),Pt,Ku,0,R2(E.y,-E.x)/le,0); - if (classoptm) (*Op.optiexpK)(stack); // call optim version + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (n) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (n) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for ( i=fi; i 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + KN< double > p(Vh.esize( ) + Uh.esize( )); - pa =a; - QuadratureFormular1dPoint pi( FIb[npi]); - R2 E=T.Edge(ie); - double le = sqrt((E,E)); - double coef = le*pi.a; - double sa=pi.x,sb=1-sa; - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); - R2 Pt(PA*sa+PB*sb ); // - Ku.BF(Dop,Pt,fu); - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for ( i=fi; ib, sym, i, -1, Th[i].lab, Uh, Vh, FIT, 0, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else { + cout << " di.kind " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); + } + if (where_in_stack) delete[] where_in_stack; + } - } + // case 3D Surf / 3D volume on meshS + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - /* - for ( i=0; i ii(ll.first.first),jj(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - R ccc = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( ccc != cc) { - cerr << ccc << " != " << cc << ", xy = "<< T(Pt) << " => "; - cerr << "Sorry error in Optimization (d) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - *pa += coef * ccc * w_i*w_j; - } - } - } //else pa+= i+1; - */ - } + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr - /* - pa=a; - if (Ku.Vh.Th(T) <=0 ) { - cout < *mates =0; + // MatriceElementairePleine *matep =0; + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(7) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + // ExecError(" no map in the case (4) ??");} + assert(pThdi == &Th); + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + QuadratureFormular FIT(FITo, 3); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; } + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); + + /* + if (verbosity>3) + if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; + else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; + else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; + else cout << " -- int in " ; */ + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3], ll = 0; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int ntp = IsoLineK(f, Q, 1e-10); + if (verbosity > 999 && ntp == 2) { + const TriangleS &T = Th[t]; + R3 E(T(Q[0]), T(Q[1])); + double le = sqrt((E, E)); + ll += le; + cout << "\t\t" << ntp << " : " << Q[0] << " " << Q[1] << " ; " << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll << endl; + } + if (ntp == 2) { // if( withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + // else + AddMatElem(A, Th, *b->b, sym, t, 10, Th[t].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); + } + } + } + FIT = FITo; + } - // creating an instance of Element_Op MatriceElementaireSymetrique - // case 3D volume - template - void Element_Op(MatriceElementaireSymetrique & mat,const FElement3 & Ku,double * p,int ie,int label, void * vstack,R3 *B) + else { + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(Th.be(e).lab) != setoflab.end( )) { + int ie, i = Th.BoundaryElement(e, ie); + // if( withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th.be(e).lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + // else + AddMatElem(A, Th, *b->b, sym, i, ie, Th.be(e).lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } + } + /*else if (di.kind == CDomainOfIntegration::intalledges) { - // ffassert(B==0); - Stack stack=pvoid2Stack(vstack); - typedef FESpace3 FESpace; - typedef typename FESpace3::Mesh Mesh; - typedef Mesh *pmesh ; - typedef typename Mesh::Element Element; - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Element & T = Ku.T; - - const GQuadratureFormular & FI = mat.FIT; - const GQuadratureFormular & FIb = mat.FIE; - - long npi; - R *a=mat.a; - R *pa=a; - long i,j; - long n= mat.n,m=mat.m,nx=n*(m+1)/2; - long N= Ku.N; - - assert(mat.bilinearform); - - const Opera &Op(*mat.bilinearform); - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) || (Op.where_in_stack_opt.size() !=0) ); - int lastop; - What_d Dop = Op.DiffOp(lastop); - - if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2 ) - cout << "Element_Op S 3d: copt = " << copt << " " << classoptm << " lastop = "<< lastop << " Dop " << Dop << " opt: " << mat.optim << endl; - assert(Op.MaxOp() pi(FI[npi]); - double coef = T.mesure()*pi.a; - //R3 Pt(pi); - pa =a; - Ku.BF(Dop,pi,fu); - MeshPointStack(stack)->set(T(pi),pi,Ku); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + cerr << " Sorry no implement to hard "<< endl; + ExecError("FH: no intalledges on diff mesh ???"); + ffassert(0); // a faire + if(withmap) + for (int i=0;i< Th.nt; i++) + { + if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + for (int ie=0;ie<3;ie++) + AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (i) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (i) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for ( i=fi; ib,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - /* - if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) - cout <<" + " << c << " (" <999) cout << " Ass mat pleine /"<< np << endl; - assert( np==3 || np==4); - // XXXXXXX - double epsmes3=T.mesure()*T.mesure()*1e-18; - R3 PP[4]; - double l[3]; - for(int i=0; i< np; ++i) - PP[i]= T(B[i]); - - for( int i =0; i+1 < np; i+=2) - { // 0,1,, a and 2,3,0. - int i0=i,i1=i+1,i2=(i+2)%np; - R3 NN= R3(PP[i0],PP[i1])^R3(PP[i0],PP[i2]); - double mes2 = (NN,NN); - double mes = sqrt(mes2); - - if(mes2*mes 999) - cout << " --int on leveset3d " << np << " " << mes << " " << i0< pi( FIb[npi]); - // cout << " %% " << npi << " " << pi.a << " " << pi.x << " " << pi.y << endl; - asum+= pi.a; - pi.toBary(l); - R3 Pt( l[0]*B[i0]+l[1]*B[i1]+l[2]*B[i2]); // - double coef = mes*pi.a; // correction 0.5 050109 FH - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - pa=a; - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (j) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (j) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for (long i=fi; i phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) { + // if(withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); + // else + AddMatElem(A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIT, FIE, p, stack); + } + if (sptrclean) sptrclean = sptr->clean( ); + } + } + FIT = FITo; + } else + { + // if(withmap) + // for (int i=0;i< Th.nt; i++) + // { + // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); + // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + // } + + // else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, FIE, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - } + } else + InternalError(" kind of CDomainOfIntegration unknown"); + if (where_in_stack) delete[] where_in_stack; + } - } + // case 3D volume / 3D Surf on meshS + template< class R > + void AssembleBilinearForm(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - }// end int level set ... - else - // int on edge ie - for (npi=0;npiclean(); // modif FH mars 2006 clean Ptr - pa =a; - GQuadraturePoint pi( FIb[npi]); - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; - mes *=0.5; - double coef = mes*pi.a; // correction 0.5 050109 FH - R3 Pt(T.PBord(ie,pi)); - Ku.BF(Dop,Pt,fu); - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; + const CDomainOfIntegration &di = *b->di; + pmeshS pThdi = GetAny< pmeshS >((*b->di->Th)(stack)); - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (k) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (k) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for (long i=fi; i 1) { + cout << " Integral(8) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + // ExecError(" no map in the case (4) ??");} + assert(pThdi == &Th); + // const vector & what(di.what); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + QuadratureFormular FIT(FITo, 3); + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; + if (verbosity > 3) { + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") ,"; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; + } + // if(di.islevelset()) InternalError("Sorry no levelset integration type on this case (1)"); + if (di.islevelset( ) && (CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind)) InternalError("Sorry no levelset integration type on no int1d case"); - /* - if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) - cout <<" + " << c << " (" <3) + if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border " ; + else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges, " ; + else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges, " ; + else cout << " -- int in " ; */ + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + }*/ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + { // remove the zero coef in the liste + // R zero=R(); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3], ll = 0; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int ntp = IsoLineK(f, Q, 1e-10); + if (verbosity > 999 && ntp == 2) { + const TriangleS &T = Th[t]; + R3 E(T(Q[0]), T(Q[1])); + double le = sqrt((E, E)); + ll += le; + cout << "\t\t" << ntp << " : " << Q[0] << " " << Q[1] << " ; " << f[0] << " " << f[1] << " " << f[2] << " " << le << " / " << ll << endl; + } + if (ntp == 2) { // if( withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,10,Th[t].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + // else + AddMatElem(A, Th, *b->b, sym, t, 10, Th[t].lab, Uh, Vh, FIT, FIE, p, stack, intmortar); + if (sptrclean) sptrclean = sptr->clean( ); + } + } } + FIT = FITo; + } - - pa=a; - if (Ku.Vh.Th(T) <0 & verbosity>100) { - cout <x :T.mesure(); - double coef = mes*pi.a; - R2 Pt(pi); - pa =a; - Ku.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(pi),pi,Ku); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - if (verbosity>10 && Ku.Vh.Th(T) < 1 && npi < 1) - cout << " ic "<< icomp << fi<< " "<< lj << " "<< " c "<< jcomp << " " <b,sym,i,ie,Th[i].lab,Uh,Vh,FIT,FIE,p,stack,intmortar); + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - /* - for ( i=0; i "; - cerr << "Sorry error in Optimization (m) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + cerr << " a faire intallVFedges " << endl; + ffassert(0); - *pa += coef * c * w_i*w_j; - } - } + } else if (di.kind == CDomainOfIntegration::int2d) { + // cerr << " a faire CDomainOfIntegration::int2d " << endl; + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[2][3]; + double vol6[2]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(Th[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = Th(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&Th, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + int nt = UnderIso(f, Q, vol6, 1e-14); + setQF< R2 >(FIT, FITo, QuadratureFormular_T_1, Q, vol6, nt); + if (FIT.n) { + // if(withmap) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,t,-1,Th[t].lab,Uh,Vh,FIT,FIE,p,stack); + // else + AddMatElem(A, Th, *b->b, sym, t, -1, Th[t].lab, Uh, Vh, FIT, FIE, p, stack); + } + if (sptrclean) sptrclean = sptr->clean( ); + } + } + FIT = FITo; + } else - }*/ + { + // if(withmap) + // for (int i=0;i< Th.nt; i++) + // { + // if ( all || setoflab.find(Th[i].lab) != setoflab.end()) + // AddMatElem(mapu,mapt,A,Th,*b->b,sym,i,-1,Th[i].lab,Uh,Vh,FIT,FIE,p,stack); + // if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + // } + + // else + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, FIE, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - } - else if(B) + } else + InternalError(" kind of CDomainOfIntegration unknown"); - ffassert(0); + if (where_in_stack) delete[] where_in_stack; + } - else // int on edge ie - for (npi=0;npi + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - pa =a; - QuadratureFormular1dPoint pi( FIb[npi]); - R3 E=T.Edge(ie); - double le = sqrt((E,E)); - double coef = le*pi.a; - double sa=pi.x,sb=1-sa; - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); - R2 Pt(PA*sa+PB*sb ); // - Ku.BF(Dop,Pt,fu); - // int label=-999999; // a passer en argument - MeshPointStack(stack)->set(T(Pt),Pt,Ku,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; - int il=0; - for (BilinearOperator::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { // attention la fonction test donne la ligne - // et la fonction test est en second - BilinearOperator::K ll(*l); - // pair jj(ll.first.first),ii(ll.first.second); - long jcomp= ll.first.first.first,jop=ll.first.first.second; - long icomp= ll.first.second.first,iop=ll.first.second.second; - - R c = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - // cout << *(copt[il]) << " == " << cc << endl; - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - c *= coef ; - long fi=Ku.dfcbegin(icomp); - long li=Ku.dfcend(icomp); - long fj=Ku.dfcbegin(jcomp); - long lj=Ku.dfcend(jcomp); - - for ( i=fi; idi; + pmeshL pThdi = GetAny< pmeshL >((*b->di->Th)(stack)); - } + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); - /* - for ( i=0; i ii(ll.first.first),jj(ll.first.second); - double w_i = wi(ii.first,ii.second); - double w_j = wj(jj.first,jj.second); - // R ccc = GetAny(ll.second.eval(stack)); - R ccc = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); - if ( copt && Ku.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( ccc != cc) { - cerr << ccc << " != " << cc << ", xy = "<< T(Pt) << " => "; - cerr << "Sorry error in Optimization (d) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + SHOWVERB(cout << " FormBilinear () " << endl); - *pa += coef * ccc * w_i*w_j; - } - } - } //else pa+= i+1; - */ - } + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(9) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + assert(pThdi == &Th); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; - /* - pa=a; - if (Ku.Vh.Th(T) <=0 ) { - cout < 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); + + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + KN< double > p(Vh.esize( ) + Uh.esize( )); + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; } - // creating an instance of Element_Op with MatriceElementaireSymetrique - // case 3D surface - // xxxxxxxxxxxxxxxxx modif a faire - template - void Element_Op(MatriceElementaireSymetrique & mat,const FElementL & Ku,double * p,int ie,int label, void * vstack,R3 *B) - { + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) ffassert(0); + else { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, 0, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else { + cout << " di.kind " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); } + if (where_in_stack) delete[] where_in_stack; + } + // 3D curve / 3D Surf on meshL + template< class R > + void AssembleBilinearForm(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceMap< R > &A, const FormBilinear *b, int *mpirankandsize = nullptr) - ////////////////////////////////// - // Element_rhs - ////////////////////////////////// + { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; - // #pragma optimization_level 0 - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Triangle & T = Kv.T; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; + const CDomainOfIntegration &di = *b->di; + pmeshL pThdi = GetAny< pmeshL >((*b->di->Th)(stack)); - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * Th.nt / mpi_size); + int ti1 = min(Th.nt, (int)((mpi_rank + 1) * ceil(1. * Th.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * Th.nbe / mpi_size); + int bei1 = min(Th.nbe, (int)((mpi_rank + 1) * ceil(1. * Th.nbe / mpi_size))); - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt " << optim << endl; + SHOWVERB(cout << " FormBilinear () " << endl); + const int useopt = di.UseOpt(stack); + // double binside=di.binside(stack); + const bool intmortar = di.intmortar(stack); + if (verbosity > 1) { + cout << " Integral(10) on Th " << &Th << " nv : " << Th.nv << " nt : " << Th.nt << endl; + cout << " Th/ u " << &Uh.Th << " nv : " << Uh.Th.nv << " nt : " << Uh.Th.nt << endl; + cout << " Th/ v " << &Vh.Th << " nv : " << Vh.Th.nv << " nt : " << Vh.Th.nt << endl; + cout << " suppose in mortar " << intmortar << " levelset= " << di.islevelset( ) << " withmap: " << di.withmap( ) << endl; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + Expression const *const mapu = *di.mapu ? di.mapu : 0; + bool withmap = di.withmap( ); + assert(pThdi == &Th); + CDomainOfIntegration::typeofkind kind = di.kind; + set< int > setoflab; + bool all = true; + + const GQuadratureFormular< R1 > &FITo = di.FIE(stack); + GQuadratureFormular< R1 > FIT(FITo, 3); + + bool VF = b->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- discontinuous Galerkin =" << VF << " size of Mat =" << A.size( ) << " Bytes\n"; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = b->b->optiexp0; + // const E_F0 & optiexpK=*b->b->optiexpK; + int n_where_in_stack_opt = b->b->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(b->b->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = b->b->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } - RNMK_ fu(p,n,N,lastop); // the value for basic fonction + if (poptiexp0) (*poptiexp0)(stack); + KN< bool > ok(b->b->v.size( )); + int il = 0; + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) ok[il] = !(b->b->mesh_indep_stack_opt[il] && (std::norm(*(where_in_stack[il])) < 1e-100)); - for (npi=0;npiset(T(Pt),Pt,Kv); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - //copt=0; - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); //GetAny(ll.second.eval(stack)); - if ( copt && ( optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(c,cc, "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)" ); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - //if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; - R a = coef * c * w_i; - B[Kv(i)] += a; - } - } + BilinearOperator b_nozer(*b->b, ok); + if (verbosity % 10 > 3) cout << " -- nb term in bilinear form (!0) : " << b_nozer.v.size( ) << " total " << n_where_in_stack_opt << endl; + + if ((verbosity / 100) % 10 >= 2) { + int il = 0; + + for (BilinearOperator::const_iterator l = b->b->v.begin( ); l != b->b->v.end( ); l++, il++) + cout << il << " coef (" << l->first << ") = " << *(where_in_stack[il]) << " offset=" << b->b->where_in_stack_opt[il] << " dep mesh " << l->second.MeshIndependent( ) + << b->b->mesh_indep_stack_opt[il] << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< double > p(Vh.esize( ) + Uh.esize( )); + + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + + if (di.kind == CDomainOfIntegration::int1d) { + if (di.islevelset( )) + ffassert(0); + else { + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(Th[i].lab) != setoflab.end( )) AddMatElem(A, Th, *b->b, sym, i, -1, Th[i].lab, Uh, Vh, FIT, 0, p, stack); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else { + cout << " di.kind " << di.kind << endl; + InternalError(" kind of CDomainOfIntegration unknown"); + } + if (where_in_stack) delete[] where_in_stack; + } + + // --------- FH 170605 + //////////////////////////////////////////////// + // Element_Op for MatriceElementairePleine + //////////////////////////////////////////////// + + // xxxxxxxxxxxxxxxxx modif a faire + // creating an instance of Element_Op with MatriceElementairePleine + // case 2d + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpace > &mat, const FElement &Ku, const FElement &Kv, double *p, int ie, int label, void *vstack, R2 *B) { + Stack stack = pvoid2Stack(vstack); + typedef FElement::Element Element; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool same = &Ku == &Kv; + const Element &T = Ku.T; + throwassert(&T == &Kv.T); + const QuadratureFormular &FI = mat.FIT; + const QuadratureFormular1d &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + long N = Kv.N; + long M = Ku.N; + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + bool oldopt = 1; // juin 2007 FH ???? a voir + int iloop = 0; + KN< bool > unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); + + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + // int lastop=1+Dop.last(binder1st >(equal_to(),true); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + for (i = 0; i < nx; i++) *pa++ = 0.; + if (ie < 0) //&& B==0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + R mes = B ? B->x : T.area; + R coef = mes * pi.a; + R2 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) { + if (oldopt) + (*Op.optiexpK)(stack); // call old optim version + else + Op.optiexpK->eval(stack, iloop++, unvarexp); // new optim version + } + if (!same) Kv.BF(Dop, Pt, fv); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; + + // attention la fonction test donne la ligne + // et la fonction test est en second + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; + } + } + } + } + else if (B) { // int on isovalue ... + R2 PA(B[0]), PB(B[1]); + R2 A = T(PA), B = T(PB); + R2 E(A, B); + double le = sqrt((E, E)); + // cout << " xxxx "<< le << " "<< A << " " << B << endl; + if (le > 1e-15) // bofbof ???? + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 Pt(PA * sa + PB * sb); // + Ku.BF(Dop, Pt, fu); + if (!same) Kv.BF(Dop, Pt, fv); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Kv, -1, R2(E.y, -E.x) / le, -1); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (f) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (f) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; + + // attention la fonction test donne la ligne + // et la fonction test est en second + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; + } + } + } } - *MeshPointStack(stack) = mp; - + } else // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + R2 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); // + Ku.BF(Dop, Pt, fu); + if (!same) Kv.BF(Dop, Pt, fv); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; - } + // attention la fonction test donne la ligne + // et la fonction test est en second - // creating an instance of Element_rhs - // case 3D volume - template - void Element_rhs(const FElement3 & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const GQuadratureFormular & FI = QuadratureFormular_Tet_2,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - typedef FElement3::Element Element; - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Element & T = Kv.T; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; + } + } + } + /* + for ( i=0; i jj(ll.first.first),ii(ll.first.second); - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt: " << optim << endl; + double w_i = wi(ii.first,ii.second); + double w_j = wj(jj.first,jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); + if ( copt && ( mat.optim==1) && Kv.number <1) + { + R cc = GetAny(ll.second.eval(stack)); + if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (h) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } + *pa += coef * ccc * w_i*w_j; + } + } + } + // else pa += m; FH dec 2003 + */ + } - int lastop; - What_d Dop = Op.DiffOp(lastop); - assert(Op.MaxOp() =0 ) { + cout < + void Element_Op(MatriceElementairePleine< R, FESpace3 > &mat, const FElement3 &Ku, const FElement3 &Kv, double *p, int ie, int label, void *vstack, R3 *B) { + // ffassert(B==0); + Stack stack = pvoid2Stack(vstack); + // ffassert(0); + typedef FElement3::Element Element; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool same = &Ku == &Kv; + const Element &T = Ku.T; + throwassert(&T == &Kv.T); + const GQuadratureFormular< R3 > &FI = mat.FIT; + const GQuadratureFormular< R2 > &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + long N = Kv.N; + long M = Ku.N; + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + bool oldopt = 1; // juin 2007 FH ???? a voir + int iloop = 0; + KN< bool > unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); + // + int lastop; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // KN Dop(last_operatortype); + // p.DiffOp(Dop); + // int lastop=1+Dop.last(binder1st >(equal_to(),true)); + // assert(lastop<=3); + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + for (i = 0; i < nx; i++) *pa++ = 0.; + if (ie < 0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R3 > pi(FI[npi]); + R coef = T.mesure( ) * pi.a; + R3 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) { + if (oldopt) + (*Op.optiexpK)(stack); // call old optim version + else + Op.optiexpK->eval(stack, iloop++, unvarexp); // new optim version + } + if (!same) Kv.BF(Dop, Pt, fv); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_Op plein 3d (a) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization Element_Op plein 3d (a) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction + // attention la fonction test donne la ligne + // et la fonction test est en second - for (npi=0;npi pi(FI[npi]); - double coef = T.mesure()*pi.a; - R3 Pt(pi); - Kv.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - //copt=0; - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); //GetAny(ll.second.eval(stack)); - if ( copt && ( optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (q) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (q) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - //if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; - R a = coef * c * w_i; - B[Kv(i)] += a; - } + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; } + } + } + } + else if (B) { // int on leveset + int np = ie - 10; //= (B[0].x == B[3].x ) && (B[0].y == B[3].y ) && (B[0].z == B[3].z ) ? 3 : 4; + if (verbosity > 999) cout << " Ass mat pleine /" << np << endl; + assert(np == 3 || np == 4); + // XXXXXXX + double epsmes3 = T.mesure( ) * T.mesure( ) * 1e-18; + R3 PP[4]; + double l[3]; + for (int i = 0; i < np; ++i) PP[i] = T(B[i]); + + for (int i = 0; i + 1 < np; i += 2) { // 0,1,, a and 2,3,0. + int i0 = i, i1 = i + 1, i2 = (i + 2) % np; + R3 NN = R3(PP[i0], PP[i1]) ^ R3(PP[i0], PP[i2]); + double mes2 = (NN, NN); + double mes = sqrt(mes2); + + if (mes2 * mes < epsmes3) continue; // too small + NN /= mes; + mes *= 0.5; + if (verbosity > 999) cout << " --int on leveset3d " << np << " " << mes << " " << i0 << i1 << i2 << endl; + double asum = 0; + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + GQuadraturePoint< R2 > pi(FIb[npi]); + // cout << " %% " << npi << " " << pi.a << " " << pi.x << " " << pi.y << endl; + asum += pi.a; + pi.toBary(l); + R3 Pt(l[0] * B[i0] + l[1] * B[i1] + l[2] * B[i2]); // + double coef = mes * pi.a; // correction 0.5 050109 FH + Ku.BF(Dop, Pt, fu); + if (!same) Kv.BF(Dop, Pt, fv); + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + pa = a; + for (int i = 0; i < n; i++) { + RNM_ wi(fv(i, '.', '.')); + for (int j = 0; j < m; j++, pa++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_Op plein 3d (b) add: int2d(Th,optimize=0)(...)"); + /* if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization Element_Op plein 3d (b) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + if (verbosity > 999) cout << " -- int on leveset3d aij = " << pi.a * ccc * w_i * w_j << " " << ccc << " " << w_i * w_j << endl; + *pa += coef * ccc * w_i * w_j; + } + } + } + if (verbosity > 999) cout << " ++\n"; + } + if (verbosity > 999) cout << " @@ " << asum << endl; + ; + } + } // end int level set ... + else // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + GQuadraturePoint< R2 > pi(FIb[npi]); + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; + double coef = 0.5 * mes * pi.a; // correction 0.5 050109 FH + R3 Pt(T.PBord(ie, pi)); + Ku.BF(Dop, Pt, fu); + if (!same) Kv.BF(Dop, Pt, fv); + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) { + RNM_ wi(fv(i, '.', '.')); + for (j = 0; j < m; j++, pa++) { + RNM_ wj(fu(j, '.', '.')); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + BilinearOperator::K ll(*l); + pair< int, int > jj(ll.first.first), ii(ll.first.second); + + double w_i = wi(ii.first, ii.second); + double w_j = wj(jj.first, jj.second); + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization Element_Op plein 3d (c) add: int2d(Th,optimize=0)(...)"); + /* + if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization Element_Op plein 3d (c) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + *pa += coef * ccc * w_i * w_j; + } + } } - *MeshPointStack(stack) = mp; + } + if (Ku.Vh.Th(T) < 1 && verbosity > 100) { + pa = mat.a; + cout << endl << " Tet " << Ku.Vh.Th(T) << " = " << T << " " << nx << endl; + for (int i = 0; i < n; i++) { + cout << setw(2) << i << setw(4) << mat.ni[i] << " :"; + for (int j = 0; j < m; j++) cout << setw(5) << (*pa++) << " "; + cout << endl; + } } + } + // creating an instance of Element_Op with MatriceElementairePleine + // case 3D surface + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpaceS > &mat, const FElementS &Ku, const FElementS &Kv, double *p, int ie, int label, void *vstack, R3 *B) { + Stack stack = pvoid2Stack(vstack); + typedef FElementS::Element Element; - // creating an instance of Element_rhs - // case 3D surface - template - void Element_rhs(const FElementS & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const TriangleS & T = Kv.T; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - // const QuadratureFormular & FI = QuadratureFormular_T_2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt " << optim << endl; + bool same = &Ku == &Kv; + const Element &T = Ku.T; + throwassert(&T == &Kv.T); + const QuadratureFormular &FI = mat.FIT; + const QuadratureFormular1d &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + long N = Kv.N; + long M = Ku.N; + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + bool oldopt = 1; // juin 2007 FH ???? a voir + int iloop = 0; + KN< bool > unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); - int lastop=0; - What_d Dop = Op.DiffOp(lastop); + int lastop; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); - // assert(lastop<=3); + // assert(lastop<=3); + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + for (i = 0; i < nx; i++) *pa++ = 0.; + if (ie < 0) //&& B==0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + R mes = B ? B->x : T.mesure( ); + R coef = mes * pi.a; + R2 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) { + if (oldopt) + (*Op.optiexpK)(stack); // call old optim version + else + Op.optiexpK->eval(stack, iloop++, unvarexp); // new optim version + } + if (!same) Kv.BF(Dop, Pt, fv); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); + /*if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; + + // attention la fonction test donne la ligne + // et la fonction test est en second + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; + } + } + } + } + else if (B) + ffassert(0); + else // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + R3 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); // + Ku.BF(Dop, Pt, fu); + // surface normal + R3 NNt = T.NormalTUnitaire( ); + // exterior normal (flux) + R3 NN = T.N(ie); + NN /= NN.norme( ); + if (!same) Kv.BF(Dop, Pt, fv); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, NNt, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)"); + /* + if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (g) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction + // attention la fonction test donne la ligne + // et la fonction test est en second - for (npi=0;npiset(T(Pt),Pt,Kv); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - //copt=0; - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); //GetAny(ll.second.eval(stack)); - if ( copt && ( optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(c,cc,"Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - //if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; - R a = coef * c * w_i; - B[Kv(i)] += a; - } + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; } + } + } + + /* + for ( i=0; i jj(ll.first.first),ii(ll.first.second); + double w_i = wi(ii.first,ii.second); + double w_j = wj(jj.first,jj.second); + // R ccc = GetAny(ll.second.eval(stack)); - } - *MeshPointStack(stack) = mp; - } + R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); + if ( copt && ( mat.optim==1) && Kv.number <1) + { + R cc = GetAny(ll.second.eval(stack)); + if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (h) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } + *pa += coef * ccc * w_i*w_j; + } + } + } + // else pa += m; FH dec 2003 + */ + } - // case 3D curve YYYY + /* pa=a; + if (Ku.Vh.Th(T) >=0 ) { + cout < -void Element_rhsVF(const FElementL & Kv,const FElementL & KKv,int ie,int iie,int label,const LOperaD &Op,double * p,int *ip,void * bstack,KN_ & B, - int optim=1) -{ - - - typedef typename FElementL::E Element; - pair_stack_double * bs=static_cast(bstack); - Stack stack= bs->first; - double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) - assert(ie>=0 && ie < 2); // int verter - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - const Element & T = Kv.T; - R3 NNt=T.TangenteUnitaire(); - double s = ie; - double ss = iie; - GQuadraturePoint pi(1.,s); - R mes = 1.; - R3 NN=NNt; - if(ie==0) NN=-NN; - R coef = 1.; - - int nTonEdge = &Kv == &KKv ? 1 : 2; - double cmean = 1./nTonEdge; - + // creating an instance of Element_Op with MatriceElementairePleine + // case 3D curve + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpaceL > &mat, const FElementL &Ku, const FElementL &Kv, double *p, int ie, int label, void *vstack, R3 *B) { + Stack stack = pvoid2Stack(vstack); + typedef FElementL::Element Element; + + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool same = &Ku == &Kv; + const Element &T = Ku.T; throwassert(&T == &Kv.T); - long npi=1; - long i,j; - long N= Kv.N; - - long nv=Kv.NbDoF(); - long nnv=KKv.NbDoF(); - assert(nv == nnv) ; - - int lp =nv*2; - KN_ pp(ip,lp),pk(ip+lp,lp),pkk(ip+2*lp,lp); - int n = BuildMEK_KK(lp,pp,pk,pkk,&Kv,&KKv); - - + // const QuadratureFormular & FI = mat.FIT; + const GQuadratureFormular< R1 > &FI = mat.FIT; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * m; + long N = Kv.N; + long M = Ku.N; + + const Opera &Op(*mat.bilinearform); bool classoptm = copt && Op.optiexpK; - // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) - if (Kv.number<1 && ( verbosity > 1 ) ) - cout << "Element_rhsVF 0d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << endl; - - + bool oldopt = 1; // juin 2007 FH ???? a voir + int iloop = 0; + KN< bool > unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op 3d P: copt = " << copt << " " << classoptm << " opt: " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); + int lastop; lastop = 0; What_d Dop = Op.DiffOp(lastop); - //assert(lastop<=3); - int lffv = nv*N*last_operatortype; - int loffset = 0 ; - - RNMK_ fv(p,nv,N,lastop); // the value for basic fonction in K - RNMK_ ffv(p + lffv ,nnv,N,lastop); // the value for basic fonction in KK - - - - - - - R1 Pt=s; // - R1 PP_t=ss; - assert (!binside); - Kv.BF(Dop,Pt,fv); - KKv.BF(Dop,PP_t,ffv); - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,NNt,ie);// Axel - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - - for ( i=0; i=0? Kv(ik):-1; - int dofikk=ikk>=0? KKv(ikk):-1; - - RNM_ wi(fv(Max(ik,0),'.','.')); - RNM_ wwi(ffv(Max(ikk,0),'.','.')); - - - int il=0; - if(dofik >=0 || dofikk>=0 ) - for (LinearOperatorD::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { - LOperaD::K ll(*l); - pair ii(ll.first); - int iis = ii.second; - int iicase = iis / last_operatortype; - iis %= last_operatortype; - double w_i=0,ww_i=0; - if(ik>=0) w_i = wi(ii.first,iis ); - if( iicase>0 ) - { - if( ikk>=0) ww_i = wwi(ii.first,iis ); - if (iicase==Code_Jump) w_i = -w_i; ///(w_i = ww_i-w_i); // jump - else if (iicase==Code_Mean) ww_i=w_i = cmean* (w_i + ww_i ); // average - else if (iicase==Code_OtherSide) std::swap(w_i,ww_i); // valeur de autre cote - else ffassert(0); - } - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (x) add: int0d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - - if(dofik>=0) B[dofik] += coef * c * w_i; - if(dofikk>=0) B[dofikk] += coef * c * ww_i; - - } - } - - - - - *MeshPointStack(stack) = mp; - -} - template - void Element_rhs(const FElementL & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const GQuadratureFormular & FI = QF_GaussLegendre2,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const EdgeL & T = Kv.T; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt " << optim << endl; - - int lastop=0; - What_d Dop = Op.DiffOp(lastop); - - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - - for (npi=0;npi pi(FI[npi]); - double coef = T.mesure()*pi.a; - R1 Pt(pi); - Kv.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - //copt=0; - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); //GetAny(ll.second.eval(stack)); - if ( copt && ( optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(c,cc,"Sorry error in Optimization Element_OpVF3dcurve (b) add: int2d(Th,optimize=0)(...)"); - } - R a = coef * c * w_i; - B[Kv(i)] += a; - } + // assert(lastop<=3); + RNMK_ fv(p, n, N, lastop); // the value for basic fonction + RNMK_ fu(p + (same ? 0 : n * N * lastop), m, M, lastop); // the value for basic fonction + + for (i = 0; i < nx; i++) *pa++ = 0.; + int ll = -1; // bof bof + R3 NNt = T.TangenteUnitaire( ); + R3 NN; + if (ie < 0) //&& B==0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R1 > pi(FI[npi]); + R mes = B ? B->x : T.mesure( ); + R coef = mes * pi.a; + R1 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, -1, NN, NNt, -1); // non on boundary ,NNt,ll);//,label,NN,NNt,ie); Axel + if (classoptm) { + if (oldopt) + (*Op.optiexpK)(stack); // call old optim version + else + Op.optiexpK->eval(stack, iloop++, unvarexp); // new optim version + } + if (!same) Kv.BF(Dop, Pt, fv); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); + /*if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; + + // attention la fonction test donne la ligne + // et la fonction test est en second + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; } - - + } + } + } + else if (B) + ffassert(0); + else // int on vetex ie + { // Add F.H sep 2020 for int0d(Th)( u*v ) + double s = ie; + GQuadraturePoint< R1 > pi(1., s); + R mes = 1.; + R3 NN = NNt; + if (ie == 0) NN = -NN; + R coef = 1.; + R1 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, NNt, ie); // Axel + if (classoptm) { + if (oldopt) + (*Op.optiexpK)(stack); // call old optim version + else + Op.optiexpK->eval(stack, iloop++, unvarexp); // new optim version + } + if (!same) Kv.BF(Dop, Pt, fv); + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R ccc = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && (mat.optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(cc, ccc, "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)"); + /*if ( ccc != cc) { + cerr << cc << " != " << ccc << " => "; + cerr << "Sorry error in Optimization (e) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + int fi = Kv.dfcbegin(icomp); + int li = Kv.dfcend(icomp); + int fj = Ku.dfcbegin(jcomp); + int lj = Ku.dfcend(jcomp); + ccc *= coef; + + // attention la fonction test donne la ligne + // et la fonction test est en second + for (i = fi; i < li; i++) { + for (j = fj; j < lj; j++) { + R w_i = fv(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += ccc * w_i * w_j; + } } - *MeshPointStack(stack) = mp; + } } - // #pragma optimization_level 0 - - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(const Mesh & ThI,const Triangle & KI, - const FESpace & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - // int maxd = Op.MaxOp(); - // assert(maxd + void Element_Op(MatriceElementaireSymetrique< R, FESpace > &mat, const FElement &Ku, double *p, int ie, int label, void *vstack, R2 *B) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Triangle &T = Ku.T; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + // const QuadratureFormular1d & FIb = QF_GaussLegendre2; + const QuadratureFormular &FI = mat.FIT; + const QuadratureFormular1d &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * (m + 1) / 2; + long N = Ku.N; + // long M=N; + // bool show = Ku.Vh.Th(T)==0; + // char * xxx[] ={" u"," v"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v'"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; + + throwassert(mat.bilinearform); + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) || (Op.where_in_stack_opt.size() !=0) ); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op S: copt = " << copt << " " << classoptm << " opt " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); - cout << "Element_rhs 3: copt = " << copt << " " << classoptm <<" opt " << optim<< endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(lastop<=3); - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() set(ThI,PI,pi,KI,KI.lab); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - bool outside; - R2 Pt; - const Triangle & K = *Vh.Th.Find(PI,Pt,outside,Kp); - if ( ! outside) + if (ie < 0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double mes = B ? B->x : T.area; + double coef = mes * pi.a; + R2 Pt(pi); + pa = a; + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(pi), pi, Ku); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); + if (verbosity > 10 && Ku.Vh.Th(T) < 1 && npi < 1) cout << " ic " << icomp << fi << " " << lj << " " << " c " << jcomp << " " << fj << " " << lj << endl; + for (i = fi; i < li; i++) + for (j = fj; j < min(lj, i + 1); j++) // { - const FElement Kv= Vh[K]; - long i,n=Kv.NbDoF(),N=Kv.N; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - Kv.BF(Dop,Pt,fu); + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - for ( i=0; i ii(ll.first); - - double w_i = wi(ii.first,ii.second); - - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack));;//GetAny(ll.second.eval(stack)); - if ( copt && ThI(KI) <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(c,cc,"Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)"); - /* - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); }*/ - } - - R a = coef * c * w_i; - B[Kv(i)] += a; - } - } + mat(i, j) += c * w_i * w_j; } - Kp = & K; } - *MeshPointStack(stack) = mp; - - - } + /* + for ( i=0; i(stack,ElemMatPtrOffset); - // int maxd = Op.MaxOp(); - // assert(maxd "; + cerr << "Sorry error in Optimization (m) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } - cout << "Element_rhs 3d 3: copt = " << copt << " " << classoptm <<" opt " < 1e-15) + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 Pt(PA * sa + PB * sb); // + Ku.BF(Dop, Pt, fu); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Ku, 0, R2(E.y, -E.x) / le, 0); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (n) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (n) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); + + for (i = fi; i < li; i++) + for (j = fj; j < min(lj, i + 1); j++, pa++) // + { + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + + mat(i, j) += c * w_i * w_j; + /* + if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) + cout <<" + " << c << " (" <set(T(Pt), Pt, Ku, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); - for (long npi=0;npi pi(FI[npi]); - R3 PI(KI(pi)); - double coef = KI.mesure()*pi.a; - MeshPointStack(stack)->set(ThI,PI,pi,KI,KI.lab); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - bool outside; - R3 Pt; - const Tet & K = *Vh.Th.Find(PI,Pt,outside,Kp); - if ( ! outside) + for (i = fi; i < li; i++) + for (j = fj; j < min(lj, i + 1); j++, pa++) // { - const FElement3 Kv= Vh[K]; - long i,n=Kv.NbDoF(),N=Kv.N; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - Kv.BF(Dop,Pt,fu); - - for ( i=0; i ii(ll.first); - - double w_i = wi(ii.first,ii.second); + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack));;//GetAny(ll.second.eval(stack)); - if ( copt && ThI(KI) <1 && optim==1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (r) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - R a = coef * c * w_i; - B[Kv(i)] += a; - } - } + mat(i, j) += c * w_i * w_j; + /* + if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) + cout <<" + " << c << " (" < - void Element_rhs(const MeshS & ThI,const TriangleS & KI, - const FESpaceS & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - ffassert(0); - } - // creating an instance of Element_rhs - // case 3D curve - template - void Element_rhs(const MeshL & ThI,const EdgeL & KI, - const FESpaceL & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const GQuadratureFormular & FI = QF_GaussLegendre2,int optim=1) - { - ffassert(0); - } + /* + for ( i=0; i ii(ll.first.first),jj(ll.first.second); + double w_i = wi(ii.first,ii.second); + double w_j = wj(jj.first,jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + R ccc = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); + if ( copt && Ku.number <1) + { + R cc = GetAny(ll.second.eval(stack)); + if ( ccc != cc) { + cerr << ccc << " != " << cc << ", xy = "<< T(Pt) << " => "; + cerr << "Sorry error in Optimization (d) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(Expression const * const mapt,const Mesh & ThI,const Triangle & KI, - const FESpace & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { + *pa += coef * ccc * w_i*w_j; + } + } + } //else pa+= i+1; + */ + } - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - // int maxd = Op.MaxOp(); - // assert(maxd + void Element_Op(MatriceElementaireSymetrique< R, FESpace3 > &mat, const FElement3 &Ku, double *p, int ie, int label, void *vstack, R3 *B) { + // ffassert(B==0); + Stack stack = pvoid2Stack(vstack); + typedef FESpace3 FESpace; + typedef typename FESpace3::Mesh Mesh; + typedef Mesh *pmesh; + typedef typename Mesh::Element Element; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Element &T = Ku.T; + + const GQuadratureFormular< R3 > &FI = mat.FIT; + const GQuadratureFormular< R2 > &FIb = mat.FIE; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() set(ThI,PI,pi,KI,KI.lab); - if(mapt) - { // move poit - PI= R2( GetAny((*mapt[0])(vstack)), GetAny((*mapt[1])(vstack))); - if(verbosity>9999) cout << " Element_rhs mapt =" << PIo << " -> " < ii(ll.first); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) + cout << "Element_Op S 3d: copt = " << copt << " " << classoptm << " lastop = " << lastop << " Dop " << Dop << " opt: " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); - double w_i = wi(ii.first,ii.second); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - R c = copt ? *(copt[il]) : GetAny(ll.second.eval(stack));;//GetAny(ll.second.eval(stack)); - if ( copt && ThI(KI) <1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " != " << cc << " => "; - cerr << "Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - R a = coef * c * w_i; - B[Kv(i)] += a; - } - } - } - Kp = & K; - } - *MeshPointStack(stack) = mp; + pa = a; + for (i = 0; i < nx; i++) *pa++ = 0.; + if (ie < 0) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R3 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + // R3 Pt(pi); + pa = a; + Ku.BF(Dop, pi, fu); + MeshPointStack(stack)->set(T(pi), pi, Ku); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (i) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (i) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); - } - // creating an instance of Element_rhs - // case 3D volume - template - void Element_rhs(const FElement3 & Kv,int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI ,bool alledges=false,int optim=1) - { - // AFAIRE("Element_rhs on border"); - Stack stack=pvoid2Stack(vstack); - typedef FElement3::Element Element; - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Element & T = Kv.T; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs 3d S: copt = " << copt << " " << classoptm <<" opt " << optim << endl; - int lastop; - What_d Dop = Op.DiffOp(lastop); - - assert(Op.MaxOp() pi( FI[npi]); - R3 NN=T.N(ie); - double le= NN.norme(); - NN /= le; - double coef = le*pi.a*0.5;// correction 050109 FH - R3 Pt(T.PBord(ie,pi)); - // - Kv.BF(Dop,Pt,fu); - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (t) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); + mat(i, j) += c * w_i * w_j; - //= GetAny(ll.second.eval(stack)); - if(verbosity>100000) - cout << "Element_rhs 3d S: " < 999) cout << " Ass mat pleine /" << np << endl; + assert(np == 3 || np == 4); + // XXXXXXX + double epsmes3 = T.mesure( ) * T.mesure( ) * 1e-18; + R3 PP[4]; + double l[3]; + for (int i = 0; i < np; ++i) PP[i] = T(B[i]); + + for (int i = 0; i + 1 < np; i += 2) { // 0,1,, a and 2,3,0. + int i0 = i, i1 = i + 1, i2 = (i + 2) % np; + R3 NN = R3(PP[i0], PP[i1]) ^ R3(PP[i0], PP[i2]); + double mes2 = (NN, NN); + double mes = sqrt(mes2); + + if (mes2 * mes < epsmes3) continue; // too small + NN /= mes; + mes *= 0.5; + if (verbosity > 999) cout << " --int on leveset3d " << np << " " << mes << " " << i0 << i1 << i2 << endl; + double asum = 0; + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + GQuadraturePoint< R2 > pi(FIb[npi]); + // cout << " %% " << npi << " " << pi.a << " " << pi.x << " " << pi.y << endl; + asum += pi.a; + pi.toBary(l); + R3 Pt(l[0] * B[i0] + l[1] * B[i1] + l[2] * B[i2]); // + double coef = mes * pi.a; // correction 0.5 050109 FH + Ku.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + pa = a; + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (j) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (j) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); + for (long i = fi; i < li; i++) + for (long j = fj; j < min(lj, i + 1); j++, pa++) // + { + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - } - *MeshPointStack(stack) = mp; + mat(i, j) += c * w_i * w_j; - } + /* + if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) + cout <<" + " << c << " (" < - void Element_rhs(Expression const * const mapt,const MeshS & ThI,const TriangleS & KI, - const FESpaceS & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - ffassert(0); - } - // creating an instance of Element_rhs - // case 3D curve - template - void Element_rhs(Expression const * const mapt,const MeshL & ThI,const EdgeL & KI, - const FESpaceL & Vh,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI = QuadratureFormular_T_2,int optim=1) - { - ffassert(0); - } + } // end int level set ... + else + // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { + pa = a; + GQuadraturePoint< R2 > pi(FIb[npi]); + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; + mes *= 0.5; + double coef = mes * pi.a; // correction 0.5 050109 FH + R3 Pt(T.PBord(ie, pi)); + Ku.BF(Dop, Pt, fu); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (k) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (k) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(const FElement & Kv,int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Triangle & T = Kv.T; - // const QuadratureFormular1d & FI = QF_GaussLegendre2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S: copt = " << copt << " " << classoptm << "opt " << optim << endl; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() set(T(Pt),Pt,Kv,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (v) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - //= GetAny(ll.second.eval(stack)); + mat(i, j) += c * w_i * w_j; - B[Kv(i)] += coef * c * w_i; - } + /* + if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) + cout <<" + " << c << " (" < 100) { + cout << endl << " Tet " << Ku.Vh.Th(T) << " = " << T << " nx= " << nx << endl; + for (int i = 0; i < n; i++) { + cout << setw(2) << i << setw(4) << mat.ni[i] << " :"; + for (int j = 0; j <= i; j++) cout << setw(5) << (*pa++) << " "; + cout << endl; + } } + /* + pa=a; + for (int i=0;i(stack,ElemMatPtrOffset); - const Element & K = Kv.T; - const Mesh3 & Th= Kv.Vh.Th; - double epsmes3=K.mesure()*K.mesure()*1e-18; - long npi; - long n=Kv.NbDoF(),N=Kv.N; - double l[3]; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs 3d S(levelset): copt = " << copt << " " << classoptm << " opt " << optim << endl; - int lastop; - What_d Dop = Op.DiffOp(lastop); - - assert(Op.MaxOp() pi( FI[npi]); - pi.toBary(l); - R3 Pt( l[0]*Q[i0]+l[1]*Q[i1]+l[2]*Q[i2]); // - MeshPointStack(stack)->set(Th,K(Pt),Pt,K,-1,NN,-1); - // - Kv.BF(Dop,Pt,fu); - // MeshPointStack(stack)->set(K(Pt),Pt,Kv,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - double coef = mes*pi.a; - for (int i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (u) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - - - //= GetAny(ll.second.eval(stack)); + // creating an instance of Element_Op with MatriceElementaireSymetrique + // case 3D surface + // xxxxxxxxxxxxxxxxx modif a faire + template< class R > + void Element_Op(MatriceElementaireSymetrique< R, FESpaceS > &mat, const FElementS &Ku, double *p, int ie, int label, void *vstack, R3 *B) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const TriangleS &T = Ku.T; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + // const QuadratureFormular1d & FIb = QF_GaussLegendre2; + const QuadratureFormular &FI = mat.FIT; + const QuadratureFormular1d &FIb = mat.FIE; + long npi; + R *a = mat.a; + R *pa = a; + long i, j; + long n = mat.n, m = mat.m, nx = n * (m + 1) / 2; + long N = Ku.N; + // long M=N; + // bool show = Ku.Vh.Th(T)==0; + // char * xxx[] ={" u"," v"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v'"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; + + throwassert(mat.bilinearform); + + const Opera &Op(*mat.bilinearform); + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) || (Op.where_in_stack_opt.size() !=0) ); + if (Ku.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_Op S: copt = " << copt << " " << classoptm << " opt " << mat.optim << endl; + assert(Op.MaxOp( ) < last_operatortype); - B[Kv(i)] += coef * c * w_i; - } - } + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // assert(lastop<=3); - } - } - *MeshPointStack(stack) = mp; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - } + pa = a; + for (i = 0; i < nx; i++) *pa++ = 0.; - // creating an instance of Element_rhs - // case 3D surface - template - void Element_rhs(const FElementS & Kv,int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,int optim=1) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const TriangleS & T = Kv.T; - // const QuadratureFormular1d & FI = QF_GaussLegendre2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S: copt = " << copt << " " << classoptm << "opt " << optim << endl; - - int lastop=0; - What_d Dop = Op.DiffOp(lastop); - assert(Op.MaxOp() "; + cerr << "Sorry error in Optimization (l) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); + if (verbosity > 10 && Ku.Vh.Th(T) < 1 && npi < 1) cout << " ic " << icomp << fi << " " << lj << " " << " c " << jcomp << " " << fj << " " << lj << endl; + for (i = fi; i < li; i++) + for (j = fj; j < min(lj, i + 1); j++) // { - RNM_ wi(fu(i,'.','.')); - int il=0; - for (LOperaD::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { - LOperaD::K ll(*l); - pair ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (v) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } - + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - //= GetAny(ll.second.eval(stack)); - - B[Kv(i)] += coef * c * w_i; - } + mat(i, j) += c * w_i * w_j; } - - } - *MeshPointStack(stack) = mp; - } - // creating an instance of Element_rhs - // case 3D curve - template - void Element_rhs(const FElementL & Kv,int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2, - bool alledges=false,int optim=1) - { - // cout << "MMMMMMMMM " <(stack,ElemMatPtrOffset); - const EdgeL & T = Kv.T; - // const QuadratureFormular1d & FI = QF_GaussLegendre2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs L: copt = " << copt << " " << classoptm << "opt " << optim << " int0d " << endl; - int lastop=0; - What_d Dop = Op.DiffOp(lastop); - - // assert(lastop<=3); - - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - - - { - double s = ie; - QuadratureFormular1dPoint pi(1.,s); - R1 Pt(pi); - Kv.BF(Dop,Pt,fu); - // calcul de N ... - R3 Nt=T.TangenteUnitaire(),NN=Nt; - if(ie==0) NN=-NN; - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,Nt,ie);//;set(T(Pt),Pt,Kv);// pas bon ... - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - - B[Kv(i)] += c * w_i; - } - } + /* + for ( i=0; i "; + cerr << "Sorry error in Optimization (m) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } - - } + *pa += coef * c * w_i*w_j; + } + } + }*/ + } + else if (B) - // end 3d + ffassert(0); + else // int on edge ie + for (npi = 0; npi < FIb.n; npi++) // loop on the integration point + { - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI ,const R2 & PPA,const R2 &PPB,int optim) - { - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - const Triangle & T = Kv.T; - R2 PA=T(PPA),PB=T(PPB); - // const QuadratureFormular1d & FI = QF_GaussLegendre2; - long npi; - long i,n=Kv.NbDoF(),N=Kv.N; - - // bool show = Kv.Vh.Th(T)==0; - // char * xxx[] ={" u"," v,"," p"," q"," r"}; - // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; - // char * yyy[] ={" ","_x ","_y "}; - - bool classoptm = copt && Op.optiexpK; - // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs(levelset) S: copt = " << copt << " " << classoptm <<" opt " << optim << endl; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() set(T(Pt),Pt,Kv,0,R2(E.y,-E.x)/le,0); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (w) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + pa = a; + QuadratureFormular1dPoint pi(FIb[npi]); + R3 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); // + Ku.BF(Dop, Pt, fu); + // int label=-999999; // a passer en argument + MeshPointStack(stack)->set(T(Pt), Pt, Ku, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + int il = 0; + for (BilinearOperator::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { // attention la fonction test donne la ligne + // et la fonction test est en second + BilinearOperator::K ll(*l); + // pair jj(ll.first.first),ii(ll.first.second); + long jcomp = ll.first.first.first, jop = ll.first.first.second; + long icomp = ll.first.second.first, iop = ll.first.second.second; + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + if (copt && Ku.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + // cout << *(copt[il]) << " == " << cc << endl; + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (o) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + c *= coef; + long fi = Ku.dfcbegin(icomp); + long li = Ku.dfcend(icomp); + long fj = Ku.dfcbegin(jcomp); + long lj = Ku.dfcend(jcomp); + for (i = fi; i < li; i++) + for (j = fj; j < min(lj, i + 1); j++, pa++) // + { + R w_i = fu(i, icomp, iop); + R w_j = fu(j, jcomp, jop); - //= GetAny(ll.second.eval(stack)); - // cout << " " << coef<< " " << c << " " << w_i << " " << Kv(i) << " | " << Pt << endl; - B[Kv(i)] += coef * c * w_i; - } + mat(i, j) += c * w_i * w_j; + /* + if (Ku.Vh.Th(T) < 1 && npi < 1 && i < 1 && j < 1 ) + cout <<" + " << c << " (" < ii(ll.first.first),jj(ll.first.second); + double w_i = wi(ii.first,ii.second); + double w_j = wj(jj.first,jj.second); + // R ccc = GetAny(ll.second.eval(stack)); + R ccc = copt ? *(copt[il]): GetAny(ll.second.eval(stack)); + if ( copt && Ku.number <1) + { + R cc = GetAny(ll.second.eval(stack)); + if ( ccc != cc) { + cerr << ccc << " != " << cc << ", xy = "<< T(Pt) << " => "; + cerr << "Sorry error in Optimization (d) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } - // case 3D surface - template - void Element_rhs(const FElementS & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI ,const R3 & PPA,const R3 &PPB,int optim) - { - ffassert(0); - } + *pa += coef * ccc * w_i*w_j; + } + } + } //else pa+= i+1; + */ + } - // case 3D curve - template - void Element_rhs(const FElementL & Kv,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI ,const R3 & PPA,const R3 &PPB,int optim) - { - ffassert(0); - } + /* + pa=a; + if (Ku.Vh.Th(T) <=0 ) { + cout < Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - //assert(Op.MaxOp() pp(ip,lp),pk(ip+lp,lp),pkk(ip+2*lp,lp); - int n = BuildMEK_KK(lp,pp,pk,pkk,&Kv,pKKv); - RNMK_ fu(p,nv,N,lastop); // the value for basic fonction - RNMK_ ffu( (double*) p + lffv ,nv,N,lastop); // the value for basic fonction - - R2 E=T.Edge(ie); - double le = sqrt((E,E)); - R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), - PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]), - PC(TriangleHat[OppositeVertex[ie]]); - // warning the to edge are in opposite sens - R2 PP_A(TriangleHat[VerticesOfTriangularEdge[iie][1]]), - PP_B(TriangleHat[VerticesOfTriangularEdge[iie][0]]), - PP_C(TriangleHat[OppositeVertex[ie]]); - R2 Normal(E.perp()/-le); - double cmean = onborder ? 1. : 0.5; - for (npi=0;npi + void Element_rhs(const FElement &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI = QuadratureFormular_T_2, int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Triangle &T = Kv.T; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; - for ( i=0; i=0? Kv(ik):-1; - int dofikk=ikk>=0? KKv(ikk):-1; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); - for (LOperaD::const_iterator l=Op.v.begin();l!=Op.v.end();l++,il++) - { + // assert(lastop<=3); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - LOperaD::K ll(*l); - pair ii(ll.first); - int iis = ii.second; - int iicase = iis / last_operatortype; - iis %= last_operatortype; - double w_i=0,ww_i=0; - if(ik>=0) w_i = wi(ii.first,iis ); - if( iicase>0 ) - { - if( ikk>=0) ww_i = wwi(ii.first,iis ); - if (iicase==Code_Jump) w_i = -w_i; ///(w_i = ww_i-w_i); // jump - else if (iicase==Code_Mean) ww_i=w_i = cmean* (w_i + ww_i ); // average - else if (iicase==Code_OtherSide) std::swap(w_i,ww_i); // valeur de autre cote - else ffassert(0); - } - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (x) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + double coef = T.area * pi.a; + R2 Pt(pi); + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + // copt=0; + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); // GetAny(ll.second.eval(stack)); + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(c, cc, "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + // if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; + R a = coef * c * w_i; + B[Kv(i)] += a; + } + } + } + *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D volume + template< class R > + void Element_rhs(const FElement3 &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const GQuadratureFormular< R3 > &FI = QuadratureFormular_Tet_2, int optim = 1) { + Stack stack = pvoid2Stack(vstack); + typedef FElement3::Element Element; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Element &T = Kv.T; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - //= GetAny(ll.second.eval(stack)); + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt: " << optim << endl; - if(dofik>=0) B[dofik] += coef * c * w_i; - if(dofikk>=0) B[dofikk] += coef * c * ww_i; + int lastop; + What_d Dop = Op.DiffOp(lastop); + assert(Op.MaxOp( ) < last_operatortype); - } - } + // assert(lastop<=3); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R3 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R3 Pt(pi); + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + // copt=0; + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); // GetAny(ll.second.eval(stack)); + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (q) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (q) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + // if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; + R a = coef * c * w_i; + B[Kv(i)] += a; } - *MeshPointStack(stack) = mp; - + } } + *MeshPointStack(stack) = mp; + } -// creating an instance of Element_rhs -// case 3D volume + // creating an instance of Element_rhs + // case 3D surface + template< class R > + void Element_rhs(const FElementS &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI = QuadratureFormular_T_2, int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const TriangleS &T = Kv.T; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + // const QuadratureFormular & FI = QuadratureFormular_T_2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; -// VFVF -template -void Element_rhsVF(const FElement3 & Kv,const FElement3 & KKv,int ie,int iie,int label,const LOperaD &Op,double * p,int *ip,void * bstack,KN_ & B, - const QuadratureFormular & FIb, - int optim=1) -{ - - int intmortar=0; - // AFAIRE("Element_rhsVF 3d "); A FAit 23 sep 2022 FH - typedef typename FElement3::Element Element; - ffassert(B!=0); - pair_stack_double * bs=static_cast(bstack); - Stack stack= bs->first; - double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) - ffassert(ie>=0 && ie < 4); // int on Face - MeshPoint mp= *MeshPointStack(stack); - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - const Element & T = Kv.T; - const Element & TT = KKv.T; - bool sameT = &T == & TT; - int nTonEdge = &T == &TT ? 1 : 2; - double cmean = 1./nTonEdge; - bool onborder= &T == &TT; - const FElement3 *pKKv= !onborder ? & KKv : 0; + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt " << optim << endl; - long npi; - long i; - long N= Kv.N; - long nv=Kv.NbDoF(); - long nnv=Kv.NbDoF(); - assert(nv == nnv) ; - int lp =nv*2; - KN_ pp(ip,lp),pk(ip+lp,lp),pkk(ip+2*lp,lp); - int n = BuildMEK_KK(lp,pp,pk,pkk,&Kv,pKKv); - - bool classoptm = copt && Op.optiexpK;// a voir !!!! - if (Kv.number<1 && ( verbosity > 1 ) ) - cout << "Element_rhsVF 3d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << optim << endl; - - bool oldopt=1; - int iloop=0; - KN unvarexp(classoptm ? Op.optiexpK->sizevar() : 1); - if (Kv.number<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhsVF 3d P: copt = " << copt << " " << classoptm << " opt: " << optim << endl; - // - int lastop=0; - lastop = 0; + int lastop = 0; What_d Dop = Op.DiffOp(lastop); - long lffv = sameT ? 0 : nv*N*lastop; + // assert(lastop<=3); - RNMK_ fv(p,nv,N,lastop); // the value for basic fonction in K - RNMK_ ffv(p + lffv ,nnv,N,lastop); // the value for basic fonction in KK - - + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; -// PB for find common dof - // compute the permutaion face ie to iie ... - // a little tricky - int fpe= T.facePermutation(ie); - int fpee= TT.facePermutation(iie); - int pr[3],ppr[3]; - SetNumPerm<3>(fpe,pr); - SetNumPerm1<3>(fpee,ppr); - - for (npi=0;npi pi( FIb[npi]); - double lpi[3]; - pi.toBary(lpi); - double llpi[]={lpi[pr[ppr[0]]], lpi[pr[ppr[1]]], lpi[pr[ppr[2]]]}; - double coef = 0.5*mes*pi.a; // correction 0.5 050109 FH - R3 Pt(T.PBord(ie,pi)); - R2 pii(llpi+1); - R3 PP_t(TT.PBord(iie,pii)); - { - static int err=0; - R3 P(T(Pt)),PP(TT(PP_t)),D(P,PP); - if( D.norme2() > 1e-5) - { - const Mesh3 & Th=Kv.Vh.Th; - cout << " pr "<< pr[0] << pr[1]<< pr[2] << " prr " << ppr[0] << ppr[1]<< ppr[2]<<" " - << ppr[pr[0]] << ppr[pr[1]] << ppr[pr[2]] << " " << pr[ppr[0]] << pr[ppr[1]] << pr[ppr[2]]<< endl; - cout << ie << " " << iie << endl; - cout << " T = " << Th(T[0]) << " " <set(T(Pt), Pt, Kv); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + // copt=0; + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); // GetAny(ll.second.eval(stack)); + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(c, cc, "Sorry error in Optimization Element_OpVF2d (b) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization add: (p) int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ + } + // if (Kv.number<5) cout << il<< " " << i << " c== " << c << endl; + R a = coef * c * w_i; + B[Kv(i)] += a; } - MeshPointStack(stack)->set(T(Pt),Pt,Kv,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version + } + } + *MeshPointStack(stack) = mp; + } + // case 3D curve YYYY - + template< class R > + void Element_rhsVF(const FElementL &Kv, const FElementL &KKv, int ie, int iie, int label, const LOperaD &Op, double *p, int *ip, void *bstack, KN_< R > &B, int optim = 1) { + typedef typename FElementL::E Element; + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + assert(ie >= 0 && ie < 2); // int verter + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + const Element &T = Kv.T; + R3 NNt = T.TangenteUnitaire( ); + double s = ie; + double ss = iie; + GQuadraturePoint< R1 > pi(1., s); + R mes = 1.; + R3 NN = NNt; + if (ie == 0) NN = -NN; + R coef = 1.; + int nTonEdge = &Kv == &KKv ? 1 : 2; + double cmean = 1. / nTonEdge; - for ( i=0; i=0? Kv(ik):-1; - int dofikk=ikk>=0? KKv(ikk):-1; + throwassert(&T == &Kv.T); + long npi = 1; + long i, j; + long N = Kv.N; - RNM_ wi(fv(Max(ik,0),'.','.')); - RNM_ wwi(ffv(Max(ikk,0),'.','.')); + long nv = Kv.NbDoF( ); + long nnv = KKv.NbDoF( ); + assert(nv == nnv); + int lp = nv * 2; + KN_< int > pp(ip, lp), pk(ip + lp, lp), pkk(ip + 2 * lp, lp); + int n = BuildMEK_KK(lp, pp, pk, pkk, &Kv, &KKv); - int il=0; - for (auto l=Op.v.begin();l!=Op.v.end();l++,il++) - { - auto ll(*l); - pair ii(ll.first); - int iis = ii.second; + bool classoptm = copt && Op.optiexpK; + // if (Ku.number<1 && verbosity/100 && verbosity % 10 == 2) + if (Kv.number < 1 && (verbosity > 1)) cout << "Element_rhsVF 0d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << endl; + + int lastop; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // assert(lastop<=3); + int lffv = nv * N * last_operatortype; + int loffset = 0; + + RNMK_ fv(p, nv, N, lastop); // the value for basic fonction in K + RNMK_ ffv(p + lffv, nnv, N, lastop); // the value for basic fonction in KK + + R1 Pt = s; // + R1 PP_t = ss; + assert(!binside); + Kv.BF(Dop, Pt, fv); + KKv.BF(Dop, PP_t, ffv); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, NNt, ie); // Axel + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < nv; i++) { + + int ik = pk[i]; + int ikk = pkk[i]; + int dofik = ik >= 0 ? Kv(ik) : -1; + int dofikk = ikk >= 0 ? KKv(ikk) : -1; + + RNM_ wi(fv(Max(ik, 0), '.', '.')); + RNM_ wwi(ffv(Max(ikk, 0), '.', '.')); + + int il = 0; + if (dofik >= 0 || dofikk >= 0) + for (LinearOperatorD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + int iis = ii.second; + int iicase = iis / last_operatortype; + iis %= last_operatortype; + double w_i = 0, ww_i = 0; + if (ik >= 0) w_i = wi(ii.first, iis); + if (iicase > 0) { + if (ikk >= 0) ww_i = wwi(ii.first, iis); + if (iicase == Code_Jump) + w_i = -w_i; ///(w_i = ww_i-w_i); // jump + else if (iicase == Code_Mean) + ww_i = w_i = cmean * (w_i + ww_i); // average + else if (iicase == Code_OtherSide) + std::swap(w_i, ww_i); // valeur de autre cote + else + ffassert(0); + } + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (x) add: int0d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } + + if (dofik >= 0) B[dofik] += coef * c * w_i; + if (dofikk >= 0) B[dofikk] += coef * c * ww_i; + } + } + + *MeshPointStack(stack) = mp; + } + template< class R > + void Element_rhs(const FElementL &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const GQuadratureFormular< R1 > &FI = QF_GaussLegendre2, int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const EdgeL &T = Kv.T; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - int iicase = iis / last_operatortype; + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S0: copt = " << copt << " " << classoptm << " opt " << optim << endl; - iis %= last_operatortype; - /* - double w_i=0,w_j=0,ww_i=0; + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); - if(ik>=0) w_i = wi(ii.first,iis ); - + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - if( iicase>0 && ikk>=0) ww_i = wwi(ii.first,iis ); - + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R1 > pi(FI[npi]); + double coef = T.mesure( ) * pi.a; + R1 Pt(pi); + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + // copt=0; + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); // GetAny(ll.second.eval(stack)); + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(c, cc, "Sorry error in Optimization Element_OpVF3dcurve (b) add: int2d(Th,optimize=0)(...)"); + } + R a = coef * c * w_i; + B[Kv(i)] += a; + } + } + } + *MeshPointStack(stack) = mp; + } + // #pragma optimization_level 0 - if (iicase==Code_Jump) ww_i=-(w_i = ww_i-w_i); // jump - else if (iicase==Code_Mean) { + // creating an instance of Element_rhs + // case 2d + template< class R > + void Element_rhs(const Mesh &ThI, const Triangle &KI, const FESpace &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI = QuadratureFormular_T_2, + int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + // int maxd = Op.MaxOp(); + // assert(maxd(ll.second.eval(stack)); + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); - R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - if ( copt && ( optim==1) && Kv.number <1) - { - R cc = GetAny(ll.second.eval(stack)); - CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_OpVF3d (face) add: intallface(Th,optimize=0)(...)"); - } - if(verbosity==99999) - cout << ie << " / " << i << "/ "<<" pi " << npi << " : " << coef << " c= " << ccc << " " << w_i << " = " << coef * ccc * w_i - << " k/kk " << Kv.number << " "<< KKv.number << " :: " << ik << " " << ikk << ", " << " ii" << ii.second << " w= " // << " // " << bbnElementonB(stack) - << w_i << " " << ww_i << endl; - if(dofik>=0) B[dofik] += coef * ccc * w_i; - if(dofikk>=0) B[dofikk] += coef * ccc * ww_i; - */ - - double w_i=0,ww_i=0; - if(ik>=0) w_i = wi(ii.first,iis ); - if( iicase>0 ) - { - if( ikk>=0) ww_i = wwi(ii.first,iis ); - if (iicase== Code_Jump) w_i = -w_i; ///(w_i = ww_i-w_i); // jump - else if (iicase==Code_Mean) ww_i=w_i = cmean* (w_i + ww_i ); // average - else if (iicase==Code_OtherSide) std::swap(w_i,ww_i); // valeur de autre cote - else ffassert(0); - } - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (x) add: int2d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + // assert(lastop<=3); - if(verbosity>999) - cout<< iicase << " : " << dofik << " " << dofikk << " :: " << coef << " "<< c << " " << w_i << " " << ww_i << " K = "<< Kv.number<< " " << KKv.number << " ?? "; - - //= GetAny(ll.second.eval(stack)); + for (long npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + R2 PI(KI(pi)); + double coef = KI.area * pi.a; + MeshPointStack(stack)->set(ThI, PI, pi, KI, KI.lab); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R2 Pt; + const Triangle &K = *Vh.Th.Find(PI, Pt, outside, Kp); + if (!outside) { + const FElement Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, Pt, fu); + + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); - if(dofik>=0) B[dofik] += coef * c * w_i; - if(dofikk>=0) B[dofikk] += coef * c * ww_i; - if(verbosity>999) - { - if(dofik>=0) cout << " + "<< dofik << " " << coef * c * w_i << " b " << B[dofik] << " , cm " << cmean; - if(dofikk>=0) cout << " + "<< dofikk <<" " << coef * c * ww_i << " b " << B[dofikk] << " , cm " << cmean; - cout << endl; - } + double w_i = wi(ii.first, ii.second); - } + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + ; // GetAny(ll.second.eval(stack)); + if (copt && ThI(KI) < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + CheckErrorOptimisation(c, cc, "Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)"); + /* + if ( c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); }*/ } - } - - - *MeshPointStack(stack) = mp; - - } -// creating an instance of Element_rhs -// case 3D volume -template -void Element_rhs(const Mesh3 & ThI,const Mesh3::Element & KI, const FESpace3 & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular & FI,bool alledges=false,int optim=1) -{ - Stack stack=pvoid2Stack(vstack); - int intmortar=0; - // AFAIRE("Element_rhs 3d on surface 2 diff mesh "); - static int count =0; - if(count++<1) - { - cout << " Element_rhs 3d on surface 2 diff mesh int test (FH)" << endl; - cout << " -----------------------------------------------------" << endl; + R a = coef * c * w_i; + B[Kv(i)] += a; + } + } + } + Kp = &K; } - // integration 1d on 2 diff mesh - - - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); + *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D volume + template< class R > + void Element_rhs(const Mesh3 &ThI, const Mesh3::Element &KI, const FESpace3 &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const GQuadratureFormular< R3 > &FI, int optim) { + Stack stack = pvoid2Stack(vstack); + // AFAIRE("Element_rhs 3d diff meshes"); + static int count = 0; + if (count++ < 1) { + cout << "Warning: Element_rhs 3 3d diff meshes in test (FH) " << endl; + cout << "--------------------------------------------------- " << endl; + } + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + // int maxd = Op.MaxOp(); + // assert(maxd pi(FI[npi]); + R3 PI(KI(pi)); + double coef = KI.mesure( ) * pi.a; + MeshPointStack(stack)->set(ThI, PI, pi, KI, KI.lab); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R3 Pt; + const Tet &K = *Vh.Th.Find(PI, Pt, outside, Kp); + if (!outside) { + const FElement3 Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, Pt, fu); + + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + + double w_i = wi(ii.first, ii.second); + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + ; // GetAny(ll.second.eval(stack)); + if (copt && ThI(KI) < 1 && optim == 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (r) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } + + R a = coef * c * w_i; + B[Kv(i)] += a; + } + } + } + Kp = &K; + } + *MeshPointStack(stack) = mp; + } - GQuadraturePoint pi(FI[npi]); - R3 NN= T.N(ie); - double mes=NN.norme(); - NN/=mes; - double coef = 0.5*mes*pi.a; // - R3 Pt(T.PBord(ie,pi)),PI(T(Pt)); + // creating an instance of Element_rhs + // case 3D surface + template< class R > + void Element_rhs(const MeshS &ThI, const TriangleS &KI, const FESpaceS &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI = QuadratureFormular_T_2, + int optim = 1) { + ffassert(0); + } + // creating an instance of Element_rhs + // case 3D curve + template< class R > + void Element_rhs(const MeshL &ThI, const EdgeL &KI, const FESpaceL &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const GQuadratureFormular< R1 > &FI = QF_GaussLegendre2, + int optim = 1) { + ffassert(0); + } + // creating an instance of Element_rhs + // case 2d + template< class R > + void Element_rhs(Expression const *const mapt, const Mesh &ThI, const Triangle &KI, const FESpace &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular &FI = QuadratureFormular_T_2, int optim = 1) { - MeshPointStack(stack)->set(ThI,PI,Pt,KI,label,NN,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - bool outside; - R3 PIt; - const Tet & K = *Vh.Th.Find(PI,PIt,outside,Kp); - if ( ! outside || intmortar) // FH march 2009 ??? - { - const FElement3 Kv= Vh[K]; - long i,n=Kv.NbDoF(),N=Kv.N; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - Kv.BF(Dop,PIt,fu); + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + // int maxd = Op.MaxOp(); + // assert(maxd ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( c != cc) { - cerr << c << " =! " << cc << endl; - cerr << "Sorry error in Optimization (y) add: int1d(Th,optimize=0)(...)" << endl; - ExecError("In Optimized version "); } - } + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (ThI(KI) < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs 3: copt = " << copt << " " << classoptm << " opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); - //= GetAny(ll.second.eval(stack)); + // assert(lastop<=3); - B[Kv(i)] += coef * c * w_i; - } + for (long npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadraturePoint pi(FI[npi]); + R2 PIo(KI(pi)), PI(PIo); + double coef = KI.area * pi.a; + MeshPointStack(stack)->set(ThI, PI, pi, KI, KI.lab); + if (mapt) { // move poit + PI = R2(GetAny< double >((*mapt[0])(vstack)), GetAny< double >((*mapt[1])(vstack))); + if (verbosity > 9999) cout << " Element_rhs mapt =" << PIo << " -> " << PI << endl; + } + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R2 Pt; + const Triangle &K = *Vh.Th.Find(PI, Pt, outside, Kp); + if (!outside) { + const FElement Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, Pt, fu); + + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + + double w_i = wi(ii.first, ii.second); + + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + ; // GetAny(ll.second.eval(stack)); + if (copt && ThI(KI) < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " != " << cc << " => "; + cerr << "Sorry error in Optimization (s) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } } + R a = coef * c * w_i; + B[Kv(i)] += a; + } } + } + Kp = &K; } *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D volume + template< class R > + void Element_rhs(const FElement3 &Kv, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI, bool alledges = false, int optim = 1) { + // AFAIRE("Element_rhs on border"); + Stack stack = pvoid2Stack(vstack); + typedef FElement3::Element Element; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Element &T = Kv.T; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; -} - // creating an instance of Element_rhs - // case 3D surface - template - void Element_rhs(const MeshS & ThI,const TriangleS & KI, const FESpaceS & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R2 *Q=0,int optim=1) - { - ffassert(0); - } - - // creating an instance of Element_rhs - // case 3D curve - template - void Element_rhs(const MeshL & ThI,const EdgeL & KI, const FESpaceL & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R2 *Q=0,int optim=1) - { - ffassert(0); - } - - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(const Mesh & ThI,const Triangle & KI, const FESpace & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R2 *Q=0,int optim=1) - { - // integration 1d on 2 diff mesh - - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - - bool classoptm = copt && Op.optiexpK; - //assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (ThI.number(KI)<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() set(ThI,PI,Pt,KI,label,R2(E.y,-E.x)/le,ie); - if (classoptm) (*Op.optiexpK)(stack); // call optim version - bool outside; - R2 PIt; - const Triangle & K = *Vh.Th.Find(PI,PIt,outside,Kp); - if ( ! outside || intmortar) // FH march 2009 ??? - { - const FElement Kv= Vh[K]; - long i,n=Kv.NbDoF(),N=Kv.N; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - Kv.BF(Dop,PIt,fu); + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( abs(c-cc) > abs(c)*1e-10) { - cerr << c << " =! " << cc << " diff " << c -cc << endl; - cerr << "Sorry error in Optimization (z) add: int1d(Th,optimize=0)(...)" << endl; - cerr << " PI = " << PI << " in K v " << Vh.Th(K) << " " << " K in Th " <(ll.second.eval(stack)); - - B[Kv(i)] += coef * c * w_i; - } - } + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R2 > pi(FI[npi]); + R3 NN = T.N(ie); + double le = NN.norme( ); + NN /= le; + double coef = le * pi.a * 0.5; // correction 050109 FH + R3 Pt(T.PBord(ie, pi)); + // + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (t) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } - } - *MeshPointStack(stack) = mp; + } - } - // creating an instance of Element_rhs - // case 2d - template - void Element_rhs(Expression const * const mapt,const Mesh & ThI,const Triangle & KI, const FESpace & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R2 *Q=0,int optim=1) - { - // integration 1d on 2 diff mesh - // ffassert(0); - Stack stack=pvoid2Stack(vstack); - MeshPoint mp=*MeshPointStack(stack) ; - R ** copt = Stack_Ptr(stack,ElemMatPtrOffset); - - - bool classoptm = copt && Op.optiexpK; - //assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); - if (ThI.number(KI)<1 && verbosity/100 && verbosity % 10 == 2) - cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; - KN Dop(last_operatortype); - Op.DiffOp(Dop); - int lastop=1+Dop.last([](bool x){return x;}); - assert(Op.MaxOp() (ll.second.eval(stack)); + if (verbosity > 100000) cout << "Element_rhs 3d S: " << coef << " " << c << " " << w_i << " = " << coef * c * w_i << " += " << Kv(i) << endl; + B[Kv(i)] += coef * c * w_i; } - else - { - PA=Q[0]; - PB=Q[1]; - E=T(PB)-T(PA); - } - double le = sqrt((E,E)); + } + } + *MeshPointStack(stack) = mp; + } - for (npi=0;npiset(ThI,PI,Pt,KI,label,R2(E.y,-E.x)/le,ie); - if(mapt) - { // move poit - PI= R2( GetAny((*mapt[0])(vstack)), GetAny((*mapt[1])(vstack))); - if(verbosity>9999) cout << " Element_rhs(2) mapt =" << PIo << " -> " < + void Element_rhs(Expression const *const mapt, const MeshS &ThI, const TriangleS &KI, const FESpaceS &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular &FI = QuadratureFormular_T_2, int optim = 1) { + ffassert(0); + } + // creating an instance of Element_rhs + // case 3D curve + template< class R > + void Element_rhs(Expression const *const mapt, const MeshL &ThI, const EdgeL &KI, const FESpaceL &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular &FI = QuadratureFormular_T_2, int optim = 1) { + ffassert(0); + } - if (classoptm) (*Op.optiexpK)(stack); // call optim version - bool outside; - R2 PIt; - const Triangle & K = *Vh.Th.Find(PI,PIt,outside,Kp); - if ( ! outside || intmortar) // FH march 2009 ??? - { - const FElement Kv= Vh[K]; - long i,n=Kv.NbDoF(),N=Kv.N; - RNMK_ fu(p,n,N,lastop); // the value for basic fonction - Kv.BF(Dop,PIt,fu); + // creating an instance of Element_rhs + // case 2d + template< class R > + void Element_rhs(const FElement &Kv, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, + int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Triangle &T = Kv.T; + // const QuadratureFormular1d & FI = QF_GaussLegendre2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - for ( i=0; i ii(ll.first); - double w_i = wi(ii.first,ii.second); - R c =copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); - // FFCS - removing what is probably a small glitch - if ( copt && ( optim==1) && Kv.number<1) - { - R cc = GetAny(ll.second.eval(stack)); - if ( abs(c-cc) > abs(c)*1e-10) { - cerr << c << " =! " << cc << " diff = " << c-cc << endl; - cerr << "Sorry error in Optimization (z) add: int1d(Th,optimize=0)(...)" << endl; - cerr << " Pt = " << Pt << " in Kv " << Vh.Th(K) << "K in Th " << ThI.number(KI) << " "<< PIt << endl; + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; - ExecError("In Optimized version "); } - } + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << "opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction - //= GetAny(ll.second.eval(stack)); + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + R2 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); // + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (v) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } - B[Kv(i)] += coef * c * w_i; - } - } + //= GetAny(ll.second.eval(stack)); - } + B[Kv(i)] += coef * c * w_i; } - *MeshPointStack(stack) = mp; - + } } + *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D volume isoline ... levelset ... + template< class R > + void Element_rhs(const FElement3 &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI, int np, R3 *Q, int optim) { + // AFAIRE("Element_rhs on border"); + Stack stack = pvoid2Stack(vstack); + typedef FElement3::Element Element; + + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Element &K = Kv.T; + const Mesh3 &Th = Kv.Vh.Th; + double epsmes3 = K.mesure( ) * K.mesure( ) * 1e-18; + long npi; + long n = Kv.NbDoF( ), N = Kv.N; + double l[3]; - // creating an instance of Element_rhs - // case 3D surface - template - void Element_rhs(Expression const * const mapt,const MeshS & ThI,const TriangleS & KI, const FESpaceS & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R2 *Q=0,int optim=1) - { - ffassert(0); - } - // creating an instance of Element_rhs - // case 3D curve - template - void Element_rhs(Expression const * const mapt,const MeshL & ThI,const EdgeL & KI, const FESpaceL & Vh, - int ie,int label,const LOperaD &Op,double * p,void * vstack,KN_ & B, - const QuadratureFormular1d & FI = QF_GaussLegendre2,bool alledges=false,bool intmortar=false, - R1 *Q=0,int optim=1) - { - ffassert(0); - } + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs 3d S(levelset): copt = " << copt << " " << classoptm << " opt " << optim << endl; + int lastop; + What_d Dop = Op.DiffOp(lastop); -// creating an instance of Element_rhs -// case 3D + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); -template -void Element_rhs3(Expression const * const mapt,const Mesh3 & ThI,const Mesh3::Element & KI, const FESpace3 & Vh, - const LOperaD &Op,double * p,void * vstack,KN_ & B, - const GQuadratureFormular & FI = QuadratureFormular_Tet_5,bool alledges=false,bool intmortar=false, - R3 *Q=0,int optim=1) -{ - // add mapt case in 3d here !!!!!!!! FH - ffassert(0); -} + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + R3 PP[4]; + for (int i = 0; i < np; ++i) PP[i] = K(Q[i]); + + for (int iii = 0; iii + 1 < np; iii += 2) { // 0,1,, a and 2,3,0. + int i0 = iii, i1 = iii + 1, i2 = (iii + 2) % np; + R3 NN = R3(PP[i0], PP[i1]) ^ R3(PP[i0], PP[i2]); + double mes2 = (NN, NN); + double mes = sqrt(mes2); + if (mes2 * mes < epsmes3) continue; // too small + NN /= mes; + mes *= 0.5; + // cout << " Element_rhs::mes " << mes << " " << iii << endl; + + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + GQuadraturePoint< R2 > pi(FI[npi]); + pi.toBary(l); + R3 Pt(l[0] * Q[i0] + l[1] * Q[i1] + l[2] * Q[i2]); // + MeshPointStack(stack)->set(Th, K(Pt), Pt, K, -1, NN, -1); + // + Kv.BF(Dop, Pt, fu); + // MeshPointStack(stack)->set(K(Pt),Pt,Kv,label,NN,ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + double coef = mes * pi.a; + for (int i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (u) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } -// generic template for AssembleVarForm -template -bool AssembleVarForm(Stack stack,const MMesh & Th,const FESpace1 & Uh,const FESpace2 & Vh,bool sym, - MC * A,KN_ * B,const list &largs, int * mpirankandsize) -{ // return true if BC - - typedef MMesh * pmesh; // integration mesh type - bool ret=false; - typedef DotStar_KN_ DotStar; - typedef DotSlash_KN_ DotSlash; - list::const_iterator ii,ib=largs.begin(), - ie=largs.end(); - using namespace FreeFempp; - TypeVarForm *tvf=TypeVarForm::Global; - assert( tvf); - for (ii=ib;ii != ie;ii++) - { - Expression e=ii->LeftValue(); - aType r = ii->left(); - // if(verbosity > 99) cout << << "AssembleVarForm " << << " " << (*A)(0,3) << endl; - if (r== tvf->tFB) - { - if (A) - { - const FormBilinear * bf =dynamic_cast(e); - if((bf->di->d != MMesh::Rd::d) || (bf->di->dHat != MMesh::RdHat::d) ) - { - cout << " Errer: int "<< bf->di->dHat << "d case ( Bilinear Form ) on Mesh"<< MMesh::RdHat::d <<" Bizarre !!!!! "<< endl; - cout << " dim coord (template) "<di->d << endl; + //= GetAny(ll.second.eval(stack)); - ffassert(0); - - } - else { - pmesh Thbf= GetAny((*bf->di->Th)(stack)); - if(Thbf) AssembleBilinearForm( stack,*Thbf,Uh,Vh,sym,*A,bf,mpirankandsize); - } - } - } - else if (r==tvf->tMat) - { - if (A) - InternalError(" Add sparse matrice; to do, sorry"); - } - else if (r==tvf->tFL) - { - if (B) { - const FormLinear * bf =dynamic_cast(e); - if(bf->di->d != MMesh::Rd::d ) - { - - if( bf->di->dHat==2) - { - cout << " int on Mesh toDo ( Linear Form )" << endl; - cout << "Mesh::d " <di->kind<< endl; - ffassert(0); - - } - else if( bf->di->dHat==1) - { - cout << " int on MeshL toDo ( Linear Form )" << endl; - ffassert(0); - - } - else if(bf->di->d != MMesh::Rd::d ){ - cout << " int 2d case on Mesh ( Linear Form )"<< MMesh::Rd::d <<" debile !!!!! "<< endl; - ffassert(0);} - } - - else - { - pmesh Thbf= GetAny((*bf->di->Th)(stack)); - if(Thbf) AssembleLinearForm( stack,*Thbf, Vh, B,bf,mpirankandsize); - }} - } - else if (r==tvf->tTab) - { - if ( B) - *B += *GetAny *>( (*e)(stack) ); - } - else if (r==tvf->tDotStar) - { - if ( B) - { - DotStar ab=GetAny( (*e)(stack) ); - *B += ab; - } - } - else if (r==tvf->tMatX) - { - if ( B) - { - *B += GetAny::plusAx >( (*e)(stack) ) ; - } - } - else if (r==tvf->tMatTX) - { - if ( B) - { - *B += GetAny::plusAtx >( (*e)(stack) ) ; - } - } - else if (r== tvf->tBC) - ret=true; - else - { - cerr << "AssembleVarForm invalid type : " << * r << endl; - throw(ErrorExec("AssembleVarForm invalid type in varf",1)); + B[Kv(i)] += coef * c * w_i; + } } + } } - return ret; -} + *MeshPointStack(stack) = mp; + } - template - void AssembleBC(Stack stack,const MMesh & Th,const FESpace1 & Uh,const FESpace2 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv , int * mpirankandsize) - { - list::const_iterator ii,ib=largs.begin(), - ie=largs.end(); - aType tBC( atype()) ; - for (ii=ib;ii != ie;ii++) - { - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==tBC) - AssembleBC(stack,Th,Uh,Vh,sym,A,B,X, dynamic_cast(e),tgv,mpirankandsize); - } + // creating an instance of Element_rhs + // case 3D surface + template< class R > + void Element_rhs(const FElementS &Kv, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, + int optim = 1) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const TriangleS &T = Kv.T; + // const QuadratureFormular1d & FI = QF_GaussLegendre2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - } + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; + + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << "opt " << optim << endl; - ////////////////////////////////// - // AssembleBC - ////////////////////////////////// + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); + assert(Op.MaxOp( ) < last_operatortype); - // creating an instance of AssembleBC - // case 2d - template - void AssembleBC(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) + // assert(lastop<=3); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + // surface normal + R3 NNt = T.NormalTUnitaire( ); + // exterior normal (flux) + R3 NN = T.N(ie); + NN /= NN.norme( ); + // cout << " NN= " << NN << endl; + for (npi = 0; npi < FI.n; npi++) // loop on the integration point { - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - int ktbc=0, nbon =0; - bool Aii = A && A->n == A->m; - - int Nbcomp=Vh.N; - Check(bc,Nbcomp); - ffassert(Vh.N == Uh.N); - TabFuncArg tabexp(stack,Vh.N); - KN buf((long int)Vh.MaximalNbOfDF() * (long int)last_operatortype * (long int)Vh.N); - int ndofBC = Aii ? A->n : 1; - KN onBC(ndofBC); - onBC= '\0'; - - if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 - if (std::abs(tgv+1.0) < 1.0e-10) - tgv = -10; - else if (std::abs(tgv+2.0) < 1.0e-10) - tgv = -20; - else if (std::abs(tgv+3.0) < 1.0e-10) - tgv = -30; - } - - KN gg(buf); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); - if(verbosity>99) cout << " Problem : BC_set "<< typeid(R).name() << " " ; - nbon =bc->on.size(); - set on; - Expandsetoflab(stack,*bc, on); - /* - for (int i=0;i( (*bc->on[i])(stack)); - if(verbosity>99) cout << lab << " " ; - on.insert(lab); - } - if(verbosity>99) - cout << endl; - */ - int kk=bc->bc.size(); + QuadratureFormular1dPoint pi(FI[npi]); + R3 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); + Kv.BF(Dop, Pt, fu); + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, NNt, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (v) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } - const int dim=Vh.N; - FElement::aIPJ ipj(Vh[0].Pi_h_ipj()); - FElement::aR2 PtHat(Vh[0].Pi_h_R2()); + //= GetAny(ll.second.eval(stack)); - KN PtonB(PtHat.N()); + B[Kv(i)] += coef * c * w_i; + } + } + } + *MeshPointStack(stack) = mp; + } - KN Aipj(ipj.N()); - KNM Vp(dim,PtHat.N()); - double tgv1=tgv <0? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1): tgv; // change 21 dec 2010 FH (Hack of ILU) + // creating an instance of Element_rhs + // case 3D curve + template< class R > + void Element_rhs(const FElementL &Kv, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, + int optim = 1) { + // cout << "MMMMMMMMM " <(stack, ElemMatPtrOffset); + const EdgeL &T = Kv.T; + // const QuadratureFormular1d & FI = QF_GaussLegendre2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - // if(mpirank==0) cout << "Th.neb=" << Th.neb << ",tgv = " << tgv << ", kk="<< kk << endl; - for (int ib=0;ib99) cout << "BC " << it << " " << ie << " lab=" << r << ":\t" - << K.T[VerticesOfTriangularEdge[ie][0]] << "; " - << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs L: copt = " << copt << " " << classoptm << "opt " << optim << " int0d " << endl; + int lastop = 0; + What_d Dop = Op.DiffOp(lastop); - for (int k=0;k xx=bc->bc[k]; - tabexp=0; - int comp = xx.first; - tabexp[comp]=xx.second; - // while (comp+1 bc[k].first) ) - tabexp[comp]=bc->bc[k].second; - else - CompileError("In Boundary condition the vector FESpace , we must have:" - " all componant, in the right order"); + // assert(lastop<=3); - } - // cout << " k "<< k << " " << comp << " " << " Nbcomp=" << Nbcomp << " " << Uh.dim_which_sub_fem[comp] << " " << Uh.dim_which_sub_fem[comp+1] << endl; -#ifdef OLDPih - K.Pi_h(gg,F_Pi_h,buf,&tabexp); + RNMK_ fu(p, n, N, lastop); // the value for basic fonction -#else - K.Pi_h(Aipj); - PtonB = 0; - for (int i=0;icomplextype: " << bc->complextype << endl; - for (int p=0;pset(K.T(PtHat[p]),PtHat[p],K,r,R2(E.y,-E.x)/le,ie); // la normal bofbof ? - KN_ Vpp(Vp('.',p)); - Vpp=R(); - for (int j=0;jcomplextype) // FH may 2007 MatriceCreuse - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - else - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - } - else Vpp[j]=0.; - } - //cout << " ..... Vp " << Vp << " " << bc->complextype << " " << bc << endl; - for (int i=0;iSetBC(ddf, tgv);// change 21 dec 2010 FH (Hack of ILU) - if (B) (*B)[ddf]=tgv1*gg[df]; - if (X) (*X)[ddf]=gg[df]; - } - } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - if( Aii) A->SetBC(onBC,tgv); - if (! ktbc && nbon && verbosity ) - { - cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; + { + double s = ie; + QuadratureFormular1dPoint pi(1., s); + R1 Pt(pi); + Kv.BF(Dop, Pt, fu); + // calcul de N ... + R3 Nt = T.TangenteUnitaire( ), NN = Nt; + if (ie == 0) NN = -NN; + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, Nt, ie); //;set(T(Pt),Pt,Kv);// pas bon ... + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + + B[Kv(i)] += c * w_i; } - *mps =mp; + } } + *MeshPointStack(stack) = mp; + } - // creating an instance of AssembleBC - // case 3D volume - template - void AssembleBC(Stack stack,const Mesh3 & Th,const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - - { - typedef Mesh3 Mesh; - typedef typename FESpace3::FElement FElement; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::Element Element; - typedef typename Mesh::RdHat RdHat; - - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - int ktbc=0, nbon =0; - bool Aii = A && A->n == A->m; - int ndofBC = Aii ? A->n : 1; - KN onBC(ndofBC); - onBC= '\0'; - - if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 - if (std::abs(tgv+1.0) < 1.0e-10) - tgv = -10; - else if (std::abs(tgv+2.0) < 1.0e-10) - tgv = -20; - else if (std::abs(tgv+3.0) < 1.0e-10) - tgv = -30; - } - - int Nbcomp=Vh.N; - Check(bc,Nbcomp); - assert(Vh.N == Uh.N); - TabFuncArg tabexp(stack,Vh.N); - KN buf((long int)Vh.MaximalNbOfDF() * (long int)last_operatortype * (long int)Vh.N); - KN gg(buf); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); - if(verbosity>99) cout << " Problem : BC_set "<< typeid(R).name() << " " ; - nbon =bc->on.size(); - set on; - Expandsetoflab(stack,*bc, on); - /*for (int i=0;i( (*bc->on[i])(stack)); - if(verbosity>99) cout << lab << " " ; - on.insert(lab); - } - if(verbosity>99) - cout << endl;*/ - int kk=bc->bc.size(); - - const int dim=Vh.N; - - InterpolationMatrix ipmat(Vh); - int npPh = Vh.maxNbPtforInterpolation; - KN PtonB(npPh); - KNM Vp(npPh,dim); - Vp=R(); - KN Vdf(Vh.MaxNbDFPerElement); - double tgv1=tgv <0? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1): tgv; - map lll; - for (int ib=0;ib + void Element_rhs(const FElement &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI, const R2 &PPA, const R2 &PPB, int optim) { + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Triangle &T = Kv.T; + R2 PA = T(PPA), PB = T(PPB); + // const QuadratureFormular1d & FI = QF_GaussLegendre2; + long npi; + long i, n = Kv.NbDoF( ), N = Kv.N; - //R2 E=K.T.Edge(ie); - //double le = be.mesure(); + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; - ktbc++; - /* - if(verbosity>99) cout << "BC " << it << " " << ie << " lab=" << r << ":\t" - << K.T[VerticesOfTriangularEdge[ie][0]] << "; " - << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; - */ - for (int k=0;k xx=bc->bc[k]; - tabexp=0; - int comp = xx.first; - tabexp[comp]=xx.second; - // while (comp+1 bc[k].first) ) - tabexp[comp]=bc->bc[k].second; - else - CompileError("In Boundary condition the vector FESpace , we must have:" - " all componant, in the right order"); + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs(levelset) S: copt = " << copt << " " << classoptm << " opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); - } - int nbdf=K.NbDoF() ; - //ipmat.set(it); - PtonB = 0; - Rd NN=K.T.N(ie); - NN /= NN.norme(); - for (int i=0;iset(K.T(PtHat),PtHat,K,r,NN,ie); // la normal bofbof ? - KN_ Vpp(Vp(p,'.')); - for (int j=0;jcomplextype) // FH may 2007 - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - else - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - - else Vpp[j]=0.; - } - // cout << " Vp: " << Vp << endl; - K.Pi_h(Vp,Vdf,ipmat); - for (int df=0;dfset(T(Pt), Pt, Kv, 0, R2(E.y, -E.x) / le, 0); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (w) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } + } + + //= GetAny(ll.second.eval(stack)); + // cout << " " << coef<< " " << c << " " << w_i << " " << Kv(i) << " | " << Pt << endl; + B[Kv(i)] += coef * c * w_i; } - if( Aii) A->SetBC(onBC,tgv); - if (! ktbc && nbon && verbosity>1 ) - { - cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; - if(verbosity>4) - for (map::const_iterator i=lll.begin();i!=lll.end();i++) - if( on.find(i->first) != on.end() ) - cout << " on: missing lab " << i-> first << " nb " << i->second << endl; - } - *mps =mp; + } } + *MeshPointStack(stack) = mp; + } - // creating an instance of AssembleBC - // case 3D surface - template - void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - typedef MeshS Mesh; - typedef typename FESpaceS::FElement FElement; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::Element Element; - typedef typename Mesh::RdHat RdHat; - - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - int ktbc=0, nbon =0; - bool Aii = A && A->n == A->m; - int ndofBC = Aii ? A->n : 1; - KN onBC(ndofBC); - onBC= '\0'; - - if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 - if (std::abs(tgv+1.0) < 1.0e-10) - tgv = -10; - else if (std::abs(tgv+2.0) < 1.0e-10) - tgv = -20; - else if (std::abs(tgv+3.0) < 1.0e-10) - tgv = -30; - } - - int Nbcomp=Vh.N; - Check(bc,Nbcomp); - assert(Vh.N == Uh.N); - TabFuncArg tabexp(stack,Vh.N); - KN buf((long int)Vh.MaximalNbOfDF() * (long int)last_operatortype * (long int)Vh.N); - KN gg(buf); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); - if(verbosity>99) cout << " Problem : BC_set "<< typeid(R).name() << " " ; - nbon =bc->on.size(); - set on; - Expandsetoflab(stack,*bc, on); - /* - for (int i=0;i( (*bc->on[i])(stack)); - if(verbosity>99) cout << lab << " " ; - on.insert(lab); - } - if(verbosity>99) - cout << endl;*/ - int kk=bc->bc.size(); - - const int dim=Vh.N; - - InterpolationMatrix ipmat(Vh); - int npPh = Vh.maxNbPtforInterpolation; - KN PtonB(npPh); - KNM Vp(npPh,dim); - Vp=R(); - KN Vdf(Vh.MaxNbDFPerElement); - double tgv1=tgv <0? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1): tgv; - map lll; - for (int ib=0;ib + void Element_rhs(const FElementS &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI, const R3 &PPA, const R3 &PPB, int optim) { + ffassert(0); + } - //const BorderElement &be=Th.be(ib); - int r =Th.be(ib).lab; - lll[r]++; - if (on.find(r) != on.end() ) - { - const FElement K(Uh[it]); - ipmat.set(K); + // case 3D curve + template< class R > + void Element_rhs(const FElementL &Kv, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular1d &FI, const R3 &PPA, const R3 &PPB, int optim) { + ffassert(0); + } - //R2 E=K.T.Edge(ie); - //double le = be.mesure(); + // creating an instance of Element_rhsVF + // case 2d + template< class R > + void Element_rhsVF(const FElement &Kv, const FElement &KKv, int ie, int iie, int label, const LOperaD &Op, double *p, int *ip, void *bstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, int optim = 1) + // sier of ip + // version correct the 29 april 2015 by. FH + // missing before in case of jump, mean , .. in test functions + // Thank to Lucas Franceschini + { + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + bool onborder = &Kv.T == &KKv.T; + const FElement *pKKv = !onborder ? &KKv : 0; + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + const Triangle &T = Kv.T; + // const QuadratureFormular1d & FI = QF_GaussLegendre2; + long npi; + long i, nv = Kv.NbDoF( ), N = Kv.N; + long nnv = KKv.NbDoF( ); + assert(nv == nnv); + // bool show = Kv.Vh.Th(T)==0; + // char * xxx[] ={" u"," v,"," p"," q"," r"}; + // char * xxxx[] ={" u'"," v',"," p'"," q'"," r'"}; + // char * yyy[] ={" ","_x ","_y "}; - ktbc++; - /* - if(verbosity>99) cout << "BC " << it << " " << ie << " lab=" << r << ":\t" - << K.T[VerticesOfTriangularEdge[ie][0]] << "; " - << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; - */ - for (int k=0;k xx=bc->bc[k]; - tabexp=0; - int comp = xx.first; - tabexp[comp]=xx.second; - // while (comp+1 bc[k].first) ) - tabexp[comp]=bc->bc[k].second; - else - CompileError("In Boundary condition the vector FESpace , we must have:" - " all componant, in the right order"); + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + // assert(Op.MaxOp() pp(ip, lp), pk(ip + lp, lp), pkk(ip + 2 * lp, lp); + int n = BuildMEK_KK(lp, pp, pk, pkk, &Kv, pKKv); + RNMK_ fu(p, nv, N, lastop); // the value for basic fonction + RNMK_ ffu((double *)p + lffv, nv, N, lastop); // the value for basic fonction + + R2 E = T.Edge(ie); + double le = sqrt((E, E)); + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]), PC(TriangleHat[OppositeVertex[ie]]); + // warning the to edge are in opposite sens + R2 PP_A(TriangleHat[VerticesOfTriangularEdge[iie][1]]), PP_B(TriangleHat[VerticesOfTriangularEdge[iie][0]]), PP_C(TriangleHat[OppositeVertex[ie]]); + R2 Normal(E.perp( ) / -le); + double cmean = onborder ? 1. : 0.5; + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + R2 E = T.Edge(ie); + double le = sqrt((E, E)); + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 PA(TriangleHat[VerticesOfTriangularEdge[ie][0]]), PB(TriangleHat[VerticesOfTriangularEdge[ie][1]]); + R2 Pt(PA * sa + PB * sb); // + R2 PP_t(PP_A * sa + PP_B * sb); // + if (binside) { + Pt = (1 - binside) * Pt + binside * PC; + PP_t = (1 - binside) * PP_t + binside * PP_C; + } + Kv.BF(Dop, Pt, fu); + if (onborder) + ffu = 0; + else + KKv.BF(Dop, PP_t, ffu); - } - int nbdf=K.NbDoF() ; - //ipmat.set(it); - PtonB = 0; - - R3 E=K.T.Edge(ie); - double le = sqrt((E,E)); - // surface normal - Rd NNt=K.T.NormalTUnitaire(); - // exterior normal (flux) - Rd NN=K.T.N(ie); - NN /= NN.norme(); - - for (int i=0;iset(K.T(PtHat),PtHat,K,r,NN,NNt,ie); // la normal bofbof ? - KN_ Vpp(Vp(p,'.')); - for (int j=0;jcomplextype) // FH may 2007 - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - else - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - - else Vpp[j]=0.; - } - // cout << " Vp: " << Vp << endl; - K.Pi_h(Vp,Vdf,ipmat); - for (int df=0;dfSetBC(onBC,tgv); - if (! ktbc && nbon && verbosity>1 ) - { - cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; - if(verbosity>9) - for (map::const_iterator i=lll.begin();i!=lll.end();i++) - if( on.find(i->first) != on.end() ) - cout << " on: missing lab " << i-> first << " nb " << i->second << endl; - } - *mps =mp; - } + } - // creating an instance of AssembleBC - // case 3D curve - template - void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - typedef MeshL Mesh; - typedef typename FESpaceL::FElement FElement; - typedef typename Mesh::BorderElement BorderElement; - typedef typename Mesh::Rd Rd; - typedef typename Mesh::Element Element; - typedef typename Mesh::RdHat RdHat; - - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - - int ktbc=0, nbon =0; - bool Aii = A && A->n == A->m; - int ndofBC = Aii ? A->n : 1; - KN onBC(ndofBC); - onBC= '\0'; - - if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 - if (std::abs(tgv+1.0) < 1.0e-10) - tgv = -10; - else if (std::abs(tgv+2.0) < 1.0e-10) - tgv = -20; - else if (std::abs(tgv+3.0) < 1.0e-10) - tgv = -30; - } - - int Nbcomp=Vh.N; - Check(bc,Nbcomp); - assert(Vh.N == Uh.N); - TabFuncArg tabexp(stack,Vh.N); - KN buf((long int)Vh.MaximalNbOfDF() * (long int)last_operatortype * (long int)Vh.N); - KN gg(buf); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); - if(verbosity>99) cout << " Problem : BC_set "<< typeid(R).name() << " " ; - nbon =bc->on.size(); - set on; - Expandsetoflab(stack,*bc, on); - - int kk=bc->bc.size(); - - const int dim=Vh.N; - - InterpolationMatrix ipmat(Vh); - int npPh = Vh.maxNbPtforInterpolation; - KN PtonB(npPh); - KNM Vp(npPh,dim); - Vp=R(); - KN Vdf(Vh.MaxNbDFPerElement); - double tgv1=tgv <0? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1): tgv; - map lll; - for (int ib=0;ib xx=bc->bc[k]; - tabexp=0; - int comp = xx.first; - tabexp[comp]=xx.second; - // while (comp+1 bc[k].first) ) - tabexp[comp]=bc->bc[k].second; - else - CompileError("In Boundary condition the vector FESpace , we must have:" - " all componant, in the right order"); + //= GetAny(ll.second.eval(stack)); - } - int nbdf=K.NbDoF() ; - //ipmat.set(it); - PtonB = 0; - R3 NNt=K.T.NormalTUnitaire(); - // exterior normal (flux) - Rd NN=K.T.N(ie); - NN /= NN.norme(); - - for (int i=0;iset(K.T(PtHat),PtHat,K,r,NN,NNt,ie); - KN_ Vpp(Vp(p,'.')); - for (int j=0;jcomplextype) // FH may 2007 - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - else - Vpp[j]=GetAny( (*tabexp[j])(stack) ); - - else Vpp[j]=0.; - } - K.Pi_h(Vp,Vdf,ipmat); - for (int df=0;dfclean(); // modif FH mars 2006 clean Ptr - } - } + if (dofik >= 0) B[dofik] += coef * c * w_i; + if (dofikk >= 0) B[dofikk] += coef * c * ww_i; } - if( Aii) A->SetBC(onBC,tgv); - if (! ktbc && nbon && verbosity ) - { - cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; - for (map::const_iterator i=lll.begin();i!=lll.end();i++) - cout << " lab " << i-> first << " nb " << i->second << endl; - } - *mps =mp; + } } + *MeshPointStack(stack) = mp; + } - // case 3D curve / 2D on meshL - template - void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } + // creating an instance of Element_rhs + // case 3D volume - // case 2D / 3D curve on meshL - template - void AssembleBC(Stack stack,const MeshL & Th,const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } - // case 3D Surf / 3D volume on meshS - template - void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } - // case 3D volume / 3D Surf on meshS - template - void AssembleBC(Stack stack,const MeshS & Th,const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } - // case 3D curve / 3D Surf on meshL - template - void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } - // case 3D Surf / 3D curve on meshL - template - void AssembleBC(Stack stack,const MeshL & Th,const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc, double tgv, int * mpirankandsize) - { - ffassert(0); - } + // VFVF + template< class R > + void Element_rhsVF(const FElement3 &Kv, const FElement3 &KKv, int ie, int iie, int label, const LOperaD &Op, double *p, int *ip, void *bstack, KN_< R > &B, const QuadratureFormular &FIb, + int optim = 1) { - void Expandsetoflab(Stack stack,const BC_set & bc,set & setoflab); - void Expandsetoflab(Stack stack,const CDomainOfIntegration & di,set & setoflab,bool &all); + int intmortar = 0; + // AFAIRE("Element_rhsVF 3d "); A FAit 23 sep 2022 FH + typedef typename FElement3::Element Element; + ffassert(B != 0); + pair_stack_double *bs = static_cast< pair_stack_double * >(bstack); + Stack stack = bs->first; + double binside = *bs->second; // truc FH pour fluide de grad2 (decentrage bizard) + ffassert(ie >= 0 && ie < 4); // int on Face + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + const Element &T = Kv.T; + const Element &TT = KKv.T; + bool sameT = &T == &TT; + int nTonEdge = &T == &TT ? 1 : 2; + double cmean = 1. / nTonEdge; + bool onborder = &T == &TT; + const FElement3 *pKKv = !onborder ? &KKv : 0; - ////////////////////////////////// - // AssembleLinearForm - ////////////////////////////////// + long npi; + long i; + long N = Kv.N; + long nv = Kv.NbDoF( ); + long nnv = Kv.NbDoF( ); + assert(nv == nnv); + int lp = nv * 2; + KN_< int > pp(ip, lp), pk(ip + lp, lp), pkk(ip + 2 * lp, lp); + int n = BuildMEK_KK(lp, pp, pk, pkk, &Kv, pKKv); + + bool classoptm = copt && Op.optiexpK; // a voir !!!! + if (Kv.number < 1 && (verbosity > 1)) cout << "Element_rhsVF 3d P: copt = " << copt << " " << classoptm << " binside (For FH) =" << binside << " opt: " << optim << endl; + + bool oldopt = 1; + int iloop = 0; + KN< bool > unvarexp(classoptm ? Op.optiexpK->sizevar( ) : 1); + if (Kv.number < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhsVF 3d P: copt = " << copt << " " << classoptm << " opt: " << optim << endl; + // + int lastop = 0; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); - // creating an instance of AssembleLinearForm - // case 2d - template - void AssembleLinearForm(Stack stack,const Mesh & Th,const FESpace & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - Check(l->l,Vh.N); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); - // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); - KN buf(Vh.MaximalNbOfDF()*last_operatortype*Vh.N*2); - - // const FormLinear * l=dynamic_cast(e); - const CDomainOfIntegration & di= *l->di; - const Mesh & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*ThI.nt/mpi_size); - int ti1 = min(ThI.nt,(int)((mpi_rank+1)*ceil(1.*ThI.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*ThI.neb/mpi_size); - int bei1 = min(ThI.neb,(int)((mpi_rank+1)*ceil(1.*ThI.neb/mpi_size))); - - const bool intmortar=di.intmortar(stack); - - SHOWVERB(cout << " FormLinear " << endl); - // const vector & what(di.what); - - CDomainOfIntegration::typeofkind kind = di.kind; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FIT = di.FIT(stack); - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) - // cout << "AssembleLinearForm " << l->l->v.size() << endl; - set setoflab; - bool all=true; - bool VF=l->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- AssembleLinearForm 2, discontinuous Galerkin =" << VF << " binside = "<< binside - << " levelset integration " <2) cout << mpirank <<" ti0= " << ti0 << ", ti1 =" << ti1 << endl; - if(verbosity>2) cout << mpirank <<" bei0=" << bei0 <<", bei1=" << bei1 << endl; - // if( di.withmap()) { ExecError(" no map in the case (6)??");} - Expression const * const mapt=di.mapt[0] ? di.mapt:0; - sameMesh = sameMesh && !mapt; // - - if (verbosity>3) - { + long lffv = sameT ? 0 : nv * N * lastop; - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") "; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - cout << ", samemesh :"<< sameMesh<< " int mortar: " << intmortar ; - } - /* - if ( verbosity>3) - if (kind==CDomainOfIntegration::int1d) cout << " -- boundary int border " ; - else if (kind==CDomainOfIntegration::intalledges) cout << " -- boundary int all edges " ; - else if (kind==CDomainOfIntegration::intallVFedges) cout << " -- boundary int all edges " ; - else cout << " -- boundary int " ; - */ - if(di.islevelset() && ( (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) ) - InternalError("So no levelset integration type on no int1d/int2d case (4)"); - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - } */ - if (verbosity>3) cout << " Optimized = "<< useopt << ", "; - - const E_F0 * poptiexp0=l->l->optiexp0; - // const E_F0 & optiexpK=*l->l->optiexpK; - int n_where_in_stack_opt=l->l->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(l->l->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;il->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - if(poptiexp0) (*poptiexp0)(stack); + RNMK_ fv(p, nv, N, lastop); // the value for basic fonction in K + RNMK_ ffv(p + lffv, nnv, N, lastop); // the value for basic fonction in KK - if( (verbosity/100) && verbosity % 10 == 2) - { - int il=0; + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; + // PB for find common dof + // compute the permutaion face ie to iie ... + // a little tricky + int fpe = T.facePermutation(ie); + int fpee = TT.facePermutation(iie); + int pr[3], ppr[3]; + SetNumPerm< 3 >(fpe, pr); + SetNumPerm1< 3 >(fpee, ppr); - for (LinearOperatorD::const_iterator ll=l->l->v.begin();ll!=l->l->v.end();ll++,il++) - cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] <(stack,ElemMatPtrOffset) =where_in_stack; + } + Kv.BF(Dop, Pt, fv); + if (!sameT) KKv.BF(Dop, PP_t, ffv); + if (verbosity == 99999 && (Kv.number == 3 || KKv.number == 2)) { + cout << "intallfaces " << Kv.number << " " << fv << endl; + cout << "intallfaces " << KKv.number << " " << ffv << endl; + } + MeshPointStack(stack)->set(T(Pt), Pt, Kv, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version - KN ip(Vh.MaxNbDFPerElement*6); - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; - } - if(di.islevelset() && (kind !=CDomainOfIntegration::int1d)&& (kind !=CDomainOfIntegration::int2d)) - InternalError(" Sorry No levelSet integral for is case ..(5)"); + for (i = 0; i < n; i++) { + int ik = pk[i]; + int ikk = pkk[i]; + int dofik = ik >= 0 ? Kv(ik) : -1; + int dofikk = ikk >= 0 ? KKv(ikk) : -1; + RNM_ wi(fv(Max(ik, 0), '.', '.')); + RNM_ wwi(ffv(Max(ikk, 0), '.', '.')); - if (kind==CDomainOfIntegration::int1d) - { + int il = 0; + for (auto l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + auto ll(*l); + pair< int, int > ii(ll.first); + int iis = ii.second; + int iicase = iis / last_operatortype; - if(VF) InternalError(" no jump or average in int1d of RHS"); - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[3]; - KN phi(ThI.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); + iis %= last_operatortype; + /* + double w_i=0,w_j=0,ww_i=0; - } - if( umn <=0 && umx >= 0) - { + if(ik>=0) w_i = wi(ii.first,iis ); - int np= IsoLineK(f,Q,1e-10); - if(np==2) - { - if ( sameMesh ) - {/* - void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B, - const QuadratureFormular1d & FI ,const R2 & PA,const R2 &PB) - - */ - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1],useopt); - } - else if(!mapt) - Element_rhs(ThI,ThI[t],Vh,0,ThI[t].lab,*l->l,buf,stack,*B,FIE,false,intmortar,Q,useopt); - else - Element_rhs(mapt,ThI,ThI[t],Vh,0,ThI[t].lab,*l->l,buf,stack,*B,FIE,false,intmortar,Q,useopt); - - //InternalError(" No levelSet on Diff mesh : to day int1d of RHS"); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - else - for( int e=bei0;e(Vh[i],ie,Th.bedges[e].lab,*l->l,buf,stack,*B,FIE,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,Th.bedges[e].lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - else - Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.bedges[e].lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else if (kind==CDomainOfIntegration::intalledges) - { - ffassert(mapt==0); - if(VF) - { - pair_stack_double bstack(stack,& binside); + if( iicase>0 && ikk>=0) ww_i = wwi(ii.first,iis ); - //bstack.first = stack; - //bstack.second= & binside; - //InternalError(" Today no jump or average in intalledges of RHS "); - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - for (int ie=0;ie<3;ie++) - if ( sameMesh) - { - int iie=ie,ii=Th.ElementAdj(i,iie); - if(ii<0) ii=i;// sur le bord - const Triangle & K(ThI[i]); - int e0=VerticesOfTriangularEdge[ie][0]; - int e1=VerticesOfTriangularEdge[ie][1]; - int i1 = ThI(K[e0]),i2 = ThI(K[e1]); - BoundaryEdge * be = ThI.TheBoundaryEdge(i1,i2); - int lab = be ? be->lab : notalabel; - - Element_rhsVF(Vh[i],Vh[ii],ie,iie,lab,*l->l,buf,ip,&bstack,*B,FIE,useopt); - } - else - InternalError("To Do") ; - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } + if (iicase==Code_Jump) ww_i=-(w_i = ww_i-w_i); // jump + else if (iicase==Code_Mean) { - } - else - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - for (int ie=0;ie<3;ie++) - if ( sameMesh) - Element_rhs(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIE,true,useopt); - else - InternalError("To Do") ; - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - else if (kind==CDomainOfIntegration::intallVFedges) - { - cerr << " intallVFedges a faire" << endl; + ww_i=w_i = cmean* (w_i + ww_i );} // average + else if (iicase==Code_OtherSide) swap(w_i,ww_i); // valeur de autre cote - InternalError(" intallVFedges a faire "); - ffassert(0); - for (int i=ti0;i< ti1; i++) - { - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - { - if ( sameMesh) - Element_rhs(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIE,true,useopt); - else - InternalError("To Do") ; - } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } + // R ccc = GetAny(ll.second.eval(stack)); - else if (kind==CDomainOfIntegration::int2d){ - if(di.islevelset()) - { - QuadratureFormular FITM(FIT); - double uset = HUGE_VAL; - R2 Q[4]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) + R ccc = copt ? *(copt[il]) : GetAny(ll.second.eval(stack)); + if ( copt && ( optim==1) && Kv.number <1) { - if ( all || setoflab.find(ThI[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - if( umx <=0 ) - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIT,useopt); - else if( umn <0 ) - { // coupe .. - int i0 = 0, i1 = 1, i2 =2; - - if( f[i0] > f[i1] ) swap(i0,i1) ; - if( f[i0] > f[i2] ) swap(i0,i2) ; - if( f[i1] > f[i2] ) swap(i1,i2) ; - - double c = (f[i2]-f[i1])/(f[i2]-f[i0]); // coef Up Traing - if( f[i1] < 0 ) {double y=f[i2]/(f[i2]-f[i1]); c *=y*y; } - else {double y=f[i0]/(f[i0]-f[i1]) ; c = 1.- (1.-c)*y*y; }; - assert( c > 0 && c < 1); - double arean = (1-c)*Th[t].area; - FITM=FIT; - FITM*=1-c; - ffassert(mapt==0); - Element_rhs(Vh[t],*l->l,buf,stack,*B,FITM,useopt); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - } + R cc = GetAny(ll.second.eval(stack)); + CheckErrorOptimisation(cc,ccc,"Sorry error in Optimization Element_OpVF3d (face) add: intallface(Th,optimize=0)(...)"); + } + if(verbosity==99999) + cout << ie << " / " << i << "/ "<<" pi " << npi << " : " << coef << " c= " << ccc << " " << w_i << " = " << coef * ccc * w_i + << " k/kk " << Kv.number << " "<< KKv.number << " :: " << ik << " " << ikk << ", " << " ii" << ii.second << " w= " // << " // " << bbnElementonB(stack) + << w_i << " " << ww_i << endl; + if(dofik>=0) B[dofik] += coef * ccc * w_i; + if(dofikk>=0) B[dofikk] += coef * ccc * ww_i; + */ + + double w_i = 0, ww_i = 0; + if (ik >= 0) w_i = wi(ii.first, iis); + if (iicase > 0) { + if (ikk >= 0) ww_i = wwi(ii.first, iis); + if (iicase == Code_Jump) + w_i = -w_i; ///(w_i = ww_i-w_i); // jump + else if (iicase == Code_Mean) + ww_i = w_i = cmean * (w_i + ww_i); // average + else if (iicase == Code_OtherSide) + std::swap(w_i, ww_i); // valeur de autre cote else - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - if ( sameMesh ) - Element_rhs(Vh[i],*l->l,buf,stack,*B,FIT,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIT,useopt); - else - Element_rhs(mapt,ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIT,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + ffassert(0); + } + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (x) add: int2d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); } - } + } + + if (verbosity > 999) cout << iicase << " : " << dofik << " " << dofikk << " :: " << coef << " " << c << " " << w_i << " " << ww_i << " K = " << Kv.number << " " << KKv.number << " ?? "; - if (n_where_in_stack_opt) delete [] where_in_stack; + //= GetAny(ll.second.eval(stack)); + if (dofik >= 0) B[dofik] += coef * c * w_i; + if (dofikk >= 0) B[dofikk] += coef * c * ww_i; + if (verbosity > 999) { + if (dofik >= 0) cout << " + " << dofik << " " << coef * c * w_i << " b " << B[dofik] << " , cm " << cmean; + if (dofikk >= 0) cout << " + " << dofikk << " " << coef * c * ww_i << " b " << B[dofikk] << " , cm " << cmean; + cout << endl; + } + } + } + } + + *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D volume + template< class R > + void Element_rhs(const Mesh3 &ThI, const Mesh3::Element &KI, const FESpace3 &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, const QuadratureFormular &FI, + bool alledges = false, int optim = 1) { + Stack stack = pvoid2Stack(vstack); + int intmortar = 0; + // AFAIRE("Element_rhs 3d on surface 2 diff mesh "); + static int count = 0; + if (count++ < 1) { + cout << " Element_rhs 3d on surface 2 diff mesh int test (FH)" << endl; + cout << " -----------------------------------------------------" << endl; } + // integration 1d on 2 diff mesh + + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (ThI(KI) < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; + assert(Op.MaxOp( ) < last_operatortype); + // + int lastop = 0; + lastop = 0; + What_d Dop = Op.DiffOp(lastop); + // assert(lastop<=3); + const Tet &T = KI; + long npi; + const Tet *Kp = 0; - // creating an instance of AssembleLinearForm - // case 3D volume - template - void AssembleLinearForm(Stack stack,const Mesh3 & Th,const FESpace3 & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) + for (npi = 0; npi < FI.n; npi++) // loop on the integration point { - typedef FESpace3 FESpace; - typedef FESpace3::Mesh Mesh; - typedef Mesh *pmesh ; - typedef Mesh::BorderElement BorderElement; - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - Check(l->l,Vh.N); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); - // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); - KN buf(Vh.MaximalNbOfDF()*last_operatortype*Vh.N*2); - - // const FormLinear * l=dynamic_cast(e); - const CDomainOfIntegration & di= *l->di; - ffassert(di.d==3); - // const Mesh * pThdi = GetAny( (* di.Th)(stack)); - - const Mesh & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*ThI.nt/mpi_size); - int ti1 = min(ThI.nt,(int)((mpi_rank+1)*ceil(1.*ThI.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*ThI.nbe/mpi_size); - int bei1 = min(ThI.nbe,(int)((mpi_rank+1)*ceil(1.*ThI.nbe/mpi_size))); - - SHOWVERB(cout << " FormLinear " << endl); - //const vector & what(di.what); - - CDomainOfIntegration::typeofkind kind = di.kind; - //const QuadratureFormular1d & FIE = di.FIE(stack); - // const QuadratureFormular & FIT = di.FIT(stack); - // const GQuadratureFormular & FIV = di.FIV(stack); - - // const QuadratureFormular1d & FIEo = di.FIE(stack); - const QuadratureFormular & FITo = di.FIT(stack); - const GQuadratureFormular & FIVo = di.FIV(stack); - // to change the quadrature on element ... may 2014 FH .. - // QuadratureFormular1d FIE(FIEo,3); - QuadratureFormular FIT(FITo,3); - GQuadratureFormular FIV(FIVo,3); - - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) - // cout << "AssembleLinearForm " << l->l->v.size() << endl; - set setoflab; - bool all=true; - bool VF=l->VF(); // finite Volume or discontinuous Galerkin - if (verbosity>2) cout << " -- AssembleLinearForm 1, discontinuous Galerkin =" << VF << " binside = "<< binside <<"\n"; - - if (verbosity>3) + + GQuadraturePoint< R2 > pi(FI[npi]); + R3 NN = T.N(ie); + double mes = NN.norme( ); + NN /= mes; + double coef = 0.5 * mes * pi.a; // + R3 Pt(T.PBord(ie, pi)), PI(T(Pt)); + + MeshPointStack(stack)->set(ThI, PI, Pt, KI, label, NN, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R3 PIt; + const Tet &K = *Vh.Th.Find(PI, PIt, outside, Kp); + if (!outside || intmortar) // FH march 2009 ??? + { + const FElement3 Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, PIt, fu); + + for (i = 0; i < n; i++) + // if (alledges || onWhatIsFace[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. { - if (CDomainOfIntegration::int2d==kind) cout << " -- boundary int border ( nQP: "<< FIT.n << ") , samemesh: " << sameMesh << " " ; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIT.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIT.n << ")," ; - else cout << " -- int 3d (nQP: "<< FIV.n << " ) in " ; + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (c != cc) { + cerr << c << " =! " << cc << endl; + cerr << "Sorry error in Optimization (y) add: int1d(Th,optimize=0)(...)" << endl; + ExecError("In Optimized version "); + } + } + + //= GetAny(ll.second.eval(stack)); + + B[Kv(i)] += coef * c * w_i; + } } - Expression const * const mapt=*di.mapt?di.mapt:0 ; + } + } + *MeshPointStack(stack) = mp; + } + // creating an instance of Element_rhs + // case 3D surface + template< class R > + void Element_rhs(const MeshS &ThI, const TriangleS &KI, const FESpaceS &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, bool intmortar = false, R2 *Q = 0, int optim = 1) { + ffassert(0); + } - // if( di.withmap()) { ExecError(" no map in the case (5)??");} + // creating an instance of Element_rhs + // case 3D curve + template< class R > + void Element_rhs(const MeshL &ThI, const EdgeL &KI, const FESpaceL &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, bool intmortar = false, R2 *Q = 0, int optim = 1) { + ffassert(0); + } - // if(di.islevelset()) InternalError("So no levelset integration type on this case (3)"); - if(di.islevelset() && (CDomainOfIntegration::int2d!=kind) && (CDomainOfIntegration::int3d!=kind) ) - InternalError("So no levelset intgeration type on no int2d/3d case"); - /* - if ( verbosity>3) - if (kind==CDomainOfIntegration::int1d) cout << " -- boundary int border " ; - else if (kind==CDomainOfIntegration::intalledges) cout << " -- boundary int all edges " ; - else if (kind==CDomainOfIntegration::intallVFedges) cout << " -- boundary int all edges " ; - else cout << " -- boundary int " ; - */ + // creating an instance of Element_rhs + // case 2d + template< class R > + void Element_rhs(const Mesh &ThI, const Triangle &KI, const FESpace &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, bool intmortar = false, R2 *Q = 0, int optim = 1) { + // integration 1d on 2 diff mesh - Expandsetoflab(stack,di, setoflab,all); - /* - for (size_t i=0;i( (*what[i])(stack)); - setoflab.insert(lab); - if ( verbosity>3) cout << lab << " "; - all=false; - } - else - { - KN labs( GetAny >( (*what[i])(stack))); - for (long j=0; j3) cout << labs[j] << " "; - } - all=false; - }*/ + Stack stack = pvoid2Stack(vstack); + MeshPoint mp = *MeshPointStack(stack); + R **copt = Stack_Ptr< R * >(stack, ElemMatPtrOffset); + + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (ThI.number(KI) < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); + const Triangle &T = KI; + long npi; - if (verbosity>3) cout << " Optimized = "<< useopt << ", "; + const Triangle *Kp = 0; + R2 PA, PB, E; + if (Q == 0) { + PA = TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB = TriangleHat[VerticesOfTriangularEdge[ie][1]]; + E = T.Edge(ie); + } else { + PA = Q[0]; + PB = Q[1]; + E = T(PB) - T(PA); + } + double le = sqrt((E, E)); + + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 Pt(PA * sa + PB * sb); // + R2 PI(KI(Pt)); + // Kv.BF(Dop,Pt,fu); + MeshPointStack(stack)->set(ThI, PI, Pt, KI, label, R2(E.y, -E.x) / le, ie); + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R2 PIt; + const Triangle &K = *Vh.Th.Find(PI, PIt, outside, Kp); + if (!outside || intmortar) // FH march 2009 ??? + { + const FElement Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, PIt, fu); - const E_F0 * poptiexp0=l->l->optiexp0; - // const E_F0 & optiexpK=*l->l->optiexpK; - int n_where_in_stack_opt=l->l->where_in_stack_opt.size(); - R** where_in_stack = 0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. { - assert(l->l->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;il->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (abs(c - cc) > abs(c) * 1e-10) { + cerr << c << " =! " << cc << " diff " << c - cc << endl; + cerr << "Sorry error in Optimization (z) add: int1d(Th,optimize=0)(...)" << endl; + cerr << " PI = " << PI << " in K v " << Vh.Th(K) << " " << " K in Th " << ThI.number(KI) << " " << PIt << endl; + ExecError("In Optimized version "); + } } - if(poptiexp0) (*poptiexp0)(stack); - if( (verbosity/100) && verbosity % 10 == 2) - { - int il=0; + //= GetAny(ll.second.eval(stack)); - for (LinearOperatorD::const_iterator ll=l->l->v.begin();ll!=l->l->v.end();ll++,il++) - cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] < phi(ThI.nv);phi=uset; - double f[4]; - for(int t=ti0; t< ti1;++t) - { + bool classoptm = copt && Op.optiexpK; + // assert( (copt !=0) == (Op.where_in_stack_opt.size() !=0) ); + if (ThI.number(KI) < 1 && verbosity / 100 && verbosity % 10 == 2) cout << "Element_rhs S: copt = " << copt << " " << classoptm << " opt " << optim << endl; + KN< bool > Dop(last_operatortype); + Op.DiffOp(Dop); + int lastop = 1 + Dop.last([](bool x) { return x; }); + assert(Op.MaxOp( ) < last_operatortype); + // assert(lastop<=3); + const Triangle &T = KI; + long npi; - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<4;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); + const Triangle *Kp = 0; + R2 PA, PB, E; + if (Q == 0) { + PA = TriangleHat[VerticesOfTriangularEdge[ie][0]]; + PB = TriangleHat[VerticesOfTriangularEdge[ie][1]]; + E = T.Edge(ie); + } else { + PA = Q[0]; + PB = Q[1]; + E = T(PB) - T(PA); + } + double le = sqrt((E, E)); - } - if( umn <=0 && umx >= 0) - { + for (npi = 0; npi < FI.n; npi++) // loop on the integration point + { + QuadratureFormular1dPoint pi(FI[npi]); + + double coef = le * pi.a; + double sa = pi.x, sb = 1 - sa; + R2 Pt(PA * sa + PB * sb); // + R2 PIo(KI(Pt)), PI(PIo); + // Kv.BF(Dop,Pt,fu); + MeshPointStack(stack)->set(ThI, PI, Pt, KI, label, R2(E.y, -E.x) / le, ie); + if (mapt) { // move poit + PI = R2(GetAny< double >((*mapt[0])(vstack)), GetAny< double >((*mapt[1])(vstack))); + if (verbosity > 9999) cout << " Element_rhs(2) mapt =" << PIo << " -> " << PI << endl; + } - int np= IsoLineK(f,Q,1e-10);// ca code ... - if(np==3 || np==4) - { // if(np==3) Q[3]=Q[0]; // same 0 == 3 bofbof ??? FH - // cout << " Q[0]" << Q[0] << endl; - if( verbosity> 99) - { - R3 PP[4]; - const Tet &K(ThI[t]); - for(int i=0; i< np; ++i) - PP[i]= K(Q[i]); - for( int i =0; i+1 < np; i+=2) - { - int i0=i,i1=i+1,i2=(i+2)%np; - R3 NN= R3(PP[i0],PP[i1])^R3(PP[i0],PP[i2]); - double mes2 = (NN,NN); - double mes = sqrt(mes2)/2; - ss+= mes; - //cout << "mes " << mes << " " << i << " , "; - } - } - - if ( sameMesh) - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIT,np,Q,useopt); - else - // else - InternalError(" No levelSet on Diff mesh3 : to day int2d of RHS"); - // Element_rhs(ThI,ThI[t],Vh,-1,lab,*l->l,buf,stack,*B,FIT,false); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - if( verbosity> 99) - cout << " surf levelset = " << ss << endl; + if (classoptm) (*Op.optiexpK)(stack); // call optim version + bool outside; + R2 PIt; + const Triangle &K = *Vh.Th.Find(PI, PIt, outside, Kp); + if (!outside || intmortar) // FH march 2009 ??? + { + const FElement Kv = Vh[K]; + long i, n = Kv.NbDoF( ), N = Kv.N; + RNMK_ fu(p, n, N, lastop); // the value for basic fonction + Kv.BF(Dop, PIt, fu); + for (i = 0; i < n; i++) + // if (alledges || onWhatIsEdge[ie][Kv.DFOnWhat(i)]) // bofbof faux si il y a des derives .. + { + RNM_ wi(fu(i, '.', '.')); + int il = 0; + for (LOperaD::const_iterator l = Op.v.begin( ); l != Op.v.end( ); l++, il++) { + LOperaD::K ll(*l); + pair< int, int > ii(ll.first); + double w_i = wi(ii.first, ii.second); + R c = copt ? *(copt[il]) : GetAny< R >(ll.second.eval(stack)); + // FFCS - removing what is probably a small glitch + if (copt && (optim == 1) && Kv.number < 1) { + R cc = GetAny< R >(ll.second.eval(stack)); + if (abs(c - cc) > abs(c) * 1e-10) { + cerr << c << " =! " << cc << " diff = " << c - cc << endl; + cerr << "Sorry error in Optimization (z) add: int1d(Th,optimize=0)(...)" << endl; + cerr << " Pt = " << Pt << " in Kv " << Vh.Th(K) << "K in Th " << ThI.number(KI) << " " << PIt << endl; + + ExecError("In Optimized version "); + } } - else - for( int e=bei0;e(Vh[i],ie,Th.be(e).lab,*l->l,buf,stack,*B,FIT,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIT,false,useopt); - else - ffassert(0); // DO do FH... - - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else if (kind==CDomainOfIntegration::intalledges) - { InternalError("3D Element RHS CDomainOfIntegration::intalledges : stupide !!!"); + + //= GetAny(ll.second.eval(stack)); + + B[Kv(i)] += coef * c * w_i; + } } - else if (kind==CDomainOfIntegration::intallVFedges) - { - cerr << " intallVFedges a faire" << endl; + } + } + *MeshPointStack(stack) = mp; + } - InternalError(" intallVFedges a stupide!!! "); + // creating an instance of Element_rhs + // case 3D surface + template< class R > + void Element_rhs(Expression const *const mapt, const MeshS &ThI, const TriangleS &KI, const FESpaceS &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, bool intmortar = false, R2 *Q = 0, int optim = 1) { + ffassert(0); + } + // creating an instance of Element_rhs + // case 3D curve + template< class R > + void Element_rhs(Expression const *const mapt, const MeshL &ThI, const EdgeL &KI, const FESpaceL &Vh, int ie, int label, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const QuadratureFormular1d &FI = QF_GaussLegendre2, bool alledges = false, bool intmortar = false, R1 *Q = 0, int optim = 1) { + ffassert(0); + } - ffassert(0); - } + // creating an instance of Element_rhs + // case 3D - else if(kind==CDomainOfIntegration::int3d) { - if(di.islevelset()) // may 2014 FH ... - { // int3d levelset < 0 - double llevelset = 0; - const double uset = std::numeric_limits::max(); - // cout << " uset ="< phi(Th.nv); - phi=uset; - double f[4]; + template< class R > + void Element_rhs3(Expression const *const mapt, const Mesh3 &ThI, const Mesh3::Element &KI, const FESpace3 &Vh, const LOperaD &Op, double *p, void *vstack, KN_< R > &B, + const GQuadratureFormular< R3 > &FI = QuadratureFormular_Tet_5, bool alledges = false, bool intmortar = false, R3 *Q = 0, int optim = 1) { + // add mapt case in 3d here !!!!!!!! FH + ffassert(0); + } - for (int t=ti0;t< ti1; t++) - { + // generic template for AssembleVarForm + template< class R, typename MC, class MMesh, class FESpace1, class FESpace2 > + bool AssembleVarForm(Stack stack, const MMesh &Th, const FESpace1 &Uh, const FESpace2 &Vh, bool sym, MC *A, KN_< R > *B, const list< C_F0 > &largs, int *mpirankandsize) { // return true if BC - const Mesh3::Element & K(ThI[t]); - if (all || setoflab.find(ThI[t].lab) != setoflab.end()) + typedef MMesh *pmesh; // integration mesh type + bool ret = false; + typedef DotStar_KN_< R > DotStar; + typedef DotSlash_KN_< R > DotSlash; + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + using namespace FreeFempp; + TypeVarForm< R > *tvf = TypeVarForm< R >::Global; + assert(tvf); + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + // if(verbosity > 99) cout << << "AssembleVarForm " << << " " << (*A)(0,3) << endl; + if (r == tvf->tFB) { + if (A) { + const FormBilinear *bf = dynamic_cast< const FormBilinear * >(e); + if ((bf->di->d != MMesh::Rd::d) || (bf->di->dHat != MMesh::RdHat::d)) { + cout << " Errer: int " << bf->di->dHat << "d case ( Bilinear Form ) on Mesh" << MMesh::RdHat::d << " Bizarre !!!!! " << endl; + cout << " dim coord (template) " << MMesh::Rd::d << " mesh : " << bf->di->d << endl; - { - double umx=std::numeric_limits::lowest(),umn=std::numeric_limits::max(); - for(int i=0;i<4;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - } - int ntets= UnderIso(f,Q, vol6,1e-14); - setQF(FIV,FIVo,QuadratureFormular_Tet_1, Q,vol6,ntets); - if(FIV.n) - { - if ( sameMesh ) - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIV,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[t],Vh,*l->l,buf,stack,*B,FIV,useopt); - else ffassert(0); - // Element_rhs3(mapt,ThI,ThI[t],Vh,*l->l,buf,stack,*B,FIV,useopt); - - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - } - } - } - FIV=FIVo; - } - else - { + ffassert(0); - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - if ( sameMesh ) - Element_rhs(Vh[i],*l->l,buf,stack,*B,FIV,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIV,useopt); - else - Element_rhs3(mapt,ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIV,useopt);// to do !!!!! - // Element_rhs(mapt,ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIV,useopt); - - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - }} - } - else if(kind==CDomainOfIntegration::intallfaces ) { - assert(mapt==0); - if(VF) - { - if ( !sameMesh) InternalError(" no jump or average in intallfaces for RHS in not samemesh"); - // InternalError(" no jump or average in intallfaces for RHS"); - pair_stack_double bstack(stack,& binside); + } else { + pmesh Thbf = GetAny< pmesh >((*bf->di->Th)(stack)); + if (Thbf) AssembleBilinearForm< R >(stack, *Thbf, Uh, Vh, sym, *A, bf, mpirankandsize); + } + } + } else if (r == tvf->tMat) { + if (A) InternalError(" Add sparse matrice; to do, sorry"); + } else if (r == tvf->tFL) { + if (B) { + const FormLinear *bf = dynamic_cast< const FormLinear * >(e); + if (bf->di->d != MMesh::Rd::d) { + + if (bf->di->dHat == 2) { + cout << " int on Mesh toDo ( Linear Form )" << endl; + cout << "Mesh::d " << MMesh::Rd::d << endl; + cout << "Mesh v ::d " << FESpace2::Mesh::Rd::d << endl; + cout << "int ::d " << bf->di->kind << endl; + ffassert(0); - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { + } else if (bf->di->dHat == 1) { + cout << " int on MeshL toDo ( Linear Form )" << endl; + ffassert(0); - for (int ie=0;ie<4;ie++) - - { - int iie=ie,ii=Th.ElementAdj(i,iie); - BorderElement * be = 0; // FIND BOUNDARY ELEMENT !!! - if(ii<0) ii=i;// sur le bord - const Tet & K(ThI[i]); - - int lab = be ? be->lab : notalabel; - Element_rhsVF(Vh[i],Vh[ii],ie,iie,lab,*l->l,buf,ip,&bstack,*B,FIT,useopt); - } - - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - - } - + } else if (bf->di->d != MMesh::Rd::d) { + cout << " int 2d case on Mesh ( Linear Form )" << MMesh::Rd::d << " debile !!!!! " << endl; + ffassert(0); } - else - { - for(int i=ti0;i(Vh[i],ie,lab,*l->l,buf,stack,*B,FIT,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,lab,*l->l,buf,stack,*B,FIT,false,useopt); - else - ffassert(mapt==0);// - //Element_rhs(mapt,ThI,ThI[i],Vh,ie,lab,*l->l,buf,stack,*B,FIT,false,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } - } - } + else { + pmesh Thbf = GetAny< pmesh >((*bf->di->Th)(stack)); + if (Thbf) AssembleLinearForm< R >(stack, *Thbf, Vh, B, bf, mpirankandsize); + } } - else - { - cout << " Strange (unknows) kind = " << kind << endl; - ffassert(0); + } else if (r == tvf->tTab) { + if (B) *B += *GetAny< KN< R > * >((*e)(stack)); + } else if (r == tvf->tDotStar) { + if (B) { + DotStar ab = GetAny< DotStar >((*e)(stack)); + *B += ab; } - if (n_where_in_stack_opt) delete [] where_in_stack; - + } else if (r == tvf->tMatX) { + if (B) { + *B += GetAny< typename RNM_VirtualMatrix< R >::plusAx >((*e)(stack)); + } + } else if (r == tvf->tMatTX) { + if (B) { + *B += GetAny< typename RNM_VirtualMatrix< R >::plusAtx >((*e)(stack)); + } + } else if (r == tvf->tBC) + ret = true; + else { + cerr << "AssembleVarForm invalid type : " << *r << endl; + throw(ErrorExec("AssembleVarForm invalid type in varf", 1)); + } } + return ret; + } + template< class R, class MMesh, class FESpace1, class FESpace2 > + void AssembleBC(Stack stack, const MMesh &Th, const FESpace1 &Uh, const FESpace2 &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const list< C_F0 > &largs, double tgv, + int *mpirankandsize) { + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + aType tBC(atype< const BC_set * >( )); + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (r == tBC) AssembleBC(stack, Th, Uh, Vh, sym, A, B, X, dynamic_cast< const BC_set * >(e), tgv, mpirankandsize); + } + } + ////////////////////////////////// + // AssembleBC + ////////////////////////////////// + // creating an instance of AssembleBC + // case 2d + template< class R > + void AssembleBC(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) + { + MeshPoint *mps = MeshPointStack(stack), mp = *mps; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + + int ktbc = 0, nbon = 0; + bool Aii = A && A->n == A->m; + + int Nbcomp = Vh.N; + Check(bc, Nbcomp); + ffassert(Vh.N == Uh.N); + TabFuncArg tabexp(stack, Vh.N); + KN< double > buf((long int)Vh.MaximalNbOfDF( ) * (long int)last_operatortype * (long int)Vh.N); + int ndofBC = Aii ? A->n : 1; + KN< char > onBC(ndofBC); + onBC = '\0'; + + if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 + if (std::abs(tgv + 1.0) < 1.0e-10) + tgv = -10; + else if (std::abs(tgv + 2.0) < 1.0e-10) + tgv = -20; + else if (std::abs(tgv + 3.0) < 1.0e-10) + tgv = -30; + } + + KN< R > gg(buf); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); + if (verbosity > 99) cout << " Problem : BC_set " << typeid(R).name( ) << " "; + nbon = bc->on.size( ); + set< long > on; + Expandsetoflab(stack, *bc, on); + /* + for (int i=0;i( (*bc->on[i])(stack)); + if(verbosity>99) cout << lab << " " ; + on.insert(lab); + } + if(verbosity>99) + cout << endl; + */ + int kk = bc->bc.size( ); + + const int dim = Vh.N; + FElement::aIPJ ipj(Vh[0].Pi_h_ipj( )); + FElement::aR2 PtHat(Vh[0].Pi_h_R2( )); + + KN< int > PtonB(PtHat.N( )); + + KN< double > Aipj(ipj.N( )); + KNM< R > Vp(dim, PtHat.N( )); + double tgv1 = tgv < 0 ? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1) : tgv; // change 21 dec 2010 FH (Hack of ILU) + + // if(mpirank==0) cout << "Th.neb=" << Th.neb << ",tgv = " << tgv << ", kk="<< kk << endl; + for (int ib = 0; ib < Th.neb; ib++) { + int ie; + int it = Th.BoundaryElement(ib, ie); + int r = Th.bedges[ib].lab; + if (on.find(r) != on.end( )) { + + const FElement K(Uh[it]); + R2 E = K.T.Edge(ie); + double le = sqrt((E, E)); + + ktbc++; + if (verbosity > 99) + cout << "BC " << it << " " << ie << " lab=" << r << ":\t" << K.T[VerticesOfTriangularEdge[ie][0]] << "; " << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; + + for (int k = 0; k < kk; k++) { + gg = R( ); + pair< int, Expression > xx = bc->bc[k]; + tabexp = 0; + int comp = xx.first; + tabexp[comp] = xx.second; + // while (comp+1 bc[k].first)) + tabexp[comp] = bc->bc[k].second; + else + CompileError( + "In Boundary condition the vector FESpace , we must have:" + " all componant, in the right order"); + } + // cout << " k "<< k << " " << comp << " " << " Nbcomp=" << Nbcomp << " " << Uh.dim_which_sub_fem[comp] << " " << Uh.dim_which_sub_fem[comp+1] << endl; +#ifdef OLDPih + K.Pi_h(gg, F_Pi_h, buf, &tabexp); - - -// creating an instance of AssembleLinearForm -// case surface 3d -template -void AssembleLinearForm(Stack stack,const MeshS & Th,const FESpaceS & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - Check(l->l,Vh.N); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); - // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); - KN buf(Vh.MaximalNbOfDF()*last_operatortype*Vh.N*2); - - // const FormLinear * l=dynamic_cast(e); - const CDomainOfIntegration & di= *l->di; - ffassert(di.d==3); - - const MeshS & ThI = Th;// * GetAny( (* di.Th)(stack)); - bool sameMesh = &ThI == &Vh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*ThI.nt/mpi_size); - int ti1 = min(ThI.nt,(int)((mpi_rank+1)*ceil(1.*ThI.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*ThI.nbe/mpi_size); - int bei1 = min(ThI.nbe,(int)((mpi_rank+1)*ceil(1.*ThI.nbe/mpi_size))); - - const bool intmortar=di.intmortar(stack); - - SHOWVERB(cout << " FormLinear " << endl); - // const vector & what(di.what); - - CDomainOfIntegration::typeofkind kind = di.kind; - const QuadratureFormular1d & FIE = di.FIE(stack); - const QuadratureFormular & FIT = di.FIT(stack); - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) - // cout << "AssembleLinearForm " << l->l->v.size() << endl; - set setoflab; - bool all=true; - bool VF=l->VF(); // finite Volume or discontinuous Galerkin - - if (verbosity>2) cout << " -- AssembleLinearForm S, discontinuous Galerkin =" << VF << " binside = "<< binside - << " levelset integration " <3) - { - - if (CDomainOfIntegration::int1d==kind) cout << " -- boundary int border ( nQP: "<< FIE.n << ") "; - else if (CDomainOfIntegration::intalledges==kind) cout << " -- boundary int all edges ( nQP: "<< FIE.n << ")," ; - else if (CDomainOfIntegration::intallVFedges==kind) cout << " -- boundary int all VF edges nQP: ("<< FIE.n << ")," ; - else cout << " -- int 2d (nQP: "<< FIT.n << " ) in " ; - cout << ", samemesh :"<< sameMesh<< " int mortar: " << intmortar ; - } - if(di.islevelset() && ( (CDomainOfIntegration::int1d!=kind) && (CDomainOfIntegration::int2d!=kind) ) ) - InternalError("So no levelset integration type on no int1d/int2d case (4)"); - Expandsetoflab(stack,di, setoflab,all); - if (verbosity>3) cout << " Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=l->l->optiexp0; - // const E_F0 & optiexpK=*l->l->optiexpK; - int n_where_in_stack_opt=l->l->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(l->l->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;il->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; +#else + K.Pi_h(Aipj); + PtonB = 0; + for (int i = 0; i < Aipj.N( ); i++) PtonB[ipj[i].p] += onWhatIsEdge[ie][K.DFOnWhat(ipj[i].i)]; + // cout << " bc->complextype: " << bc->complextype << endl; + for (int p = 0; p < PtHat.N( ); p++) + if (PtonB[p]) // in on boundary + { + mps->set(K.T(PtHat[p]), PtHat[p], K, r, R2(E.y, -E.x) / le, ie); // la normal bofbof ? + KN_< R > Vpp(Vp('.', p)); + Vpp = R( ); + for (int j = 0; j < dim; j++) + if (tabexp[j]) { + if (bc->complextype) // FH may 2007 MatriceCreuse + Vpp[j] = GetAny< R >((*tabexp[j])(stack)); + else + Vpp[j] = GetAny< double >((*tabexp[j])(stack)); + } else + Vpp[j] = 0.; + } + // cout << " ..... Vp " << Vp << " " << bc->complextype << " " << bc << endl; + for (int i = 0; i < Aipj.N( ); i++) { + const FElement::IPJ &ipj_i(ipj[i]); + gg[ipj_i.i] += Aipj[i] * Vp(ipj_i.j, ipj_i.p); + } +#endif + int nbdf = K.NbDoF( ); + for (int df = 0; df < nbdf; df++) + // if (K.FromFE(df)==which_uh[xx.first] && onWhatIsEdge[ie][K.DFOnWhat(df)] ) + { + // cout << df << " from = " << K.FromFE(df) << " dim .. " << Uh.dim_which_sub_fem[xx.first] << " first " << xx.first << " " << onWhatIsEdge[ie][K.DFOnWhat(df)] << endl; + if (K.FromASubFE(df) == Uh.dim_which_sub_fem[xx.first] && onWhatIsEdge[ie][K.DFOnWhat(df)]) { + // cout << k << " df=" << df << " g= " << gg[df] <<" " << gg(FromTo(0,2)) << endl; + int ddf = K(df); + // AA(ddf,ddf) =tgv; + if (Aii) onBC[ddf] = '1'; + ; // A->SetBC(ddf, tgv);// change 21 dec 2010 FH (Hack of ILU) + if (B) (*B)[ddf] = tgv1 * gg[df]; + if (X) (*X)[ddf] = gg[df]; } - if(poptiexp0) (*poptiexp0)(stack); + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } + if (Aii) A->SetBC(onBC, tgv); + if (!ktbc && nbon && verbosity) { + cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; + } + *mps = mp; + } - if( (verbosity/100) && verbosity % 10 == 2) - { - int il=0; + // creating an instance of AssembleBC + // case 3D volume + template< class R > + void AssembleBC(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) - for (LinearOperatorD::const_iterator ll=l->l->v.begin();ll!=l->l->v.end();ll++,il++) - cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] <clean(); // modif FH mars 2006 clean Ptr + + int ktbc = 0, nbon = 0; + bool Aii = A && A->n == A->m; + int ndofBC = Aii ? A->n : 1; + KN< char > onBC(ndofBC); + onBC = '\0'; + + if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 + if (std::abs(tgv + 1.0) < 1.0e-10) + tgv = -10; + else if (std::abs(tgv + 2.0) < 1.0e-10) + tgv = -20; + else if (std::abs(tgv + 3.0) < 1.0e-10) + tgv = -30; + } + + int Nbcomp = Vh.N; + Check(bc, Nbcomp); + assert(Vh.N == Uh.N); + TabFuncArg tabexp(stack, Vh.N); + KN< double > buf((long int)Vh.MaximalNbOfDF( ) * (long int)last_operatortype * (long int)Vh.N); + KN< R > gg(buf); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); + if (verbosity > 99) cout << " Problem : BC_set " << typeid(R).name( ) << " "; + nbon = bc->on.size( ); + set< long > on; + Expandsetoflab(stack, *bc, on); + /*for (int i=0;i( (*bc->on[i])(stack)); + if(verbosity>99) cout << lab << " " ; + on.insert(lab); + } + if(verbosity>99) + cout << endl;*/ + int kk = bc->bc.size( ); + + const int dim = Vh.N; + + InterpolationMatrix< RdHat > ipmat(Vh); + int npPh = Vh.maxNbPtforInterpolation; + KN< int > PtonB(npPh); + KNM< R > Vp(npPh, dim); + Vp = R( ); + KN< R > Vdf(Vh.MaxNbDFPerElement); + double tgv1 = tgv < 0 ? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1) : tgv; + map< int, int > lll; + for (int ib = 0; ib < Th.nbe; ib++) { + int ie; + int it = Th.BoundaryElement(ib, ie); + + // const BorderElement &be=Th.be(ib); + int r = Th.be(ib).lab; + lll[r]++; + if (on.find(r) != on.end( )) { + const FElement K(Uh[it]); + ipmat.set(K); + + // R2 E=K.T.Edge(ie); + // double le = be.mesure(); + + ktbc++; + /* + if(verbosity>99) cout << "BC " << it << " " << ie << " lab=" << r << ":\t" + << K.T[VerticesOfTriangularEdge[ie][0]] << "; " + << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; + */ + for (int k = 0; k < kk; k++) { + gg = R( ); + pair< int, Expression > xx = bc->bc[k]; + tabexp = 0; + int comp = xx.first; + tabexp[comp] = xx.second; + // while (comp+1 bc[k].first)) + tabexp[comp] = bc->bc[k].second; + else + CompileError( + "In Boundary condition the vector FESpace , we must have:" + " all componant, in the right order"); + } + int nbdf = K.NbDoF( ); + // ipmat.set(it); + PtonB = 0; + Rd NN = K.T.N(ie); + NN /= NN.norme( ); + for (int i = 0; i < ipmat.ncoef; i++) PtonB[ipmat.p[i]] += Element::onWhatBorder[ie][K.DFOnWhat(ipmat.dofe[i])]; + + for (int p = 0; p < ipmat.np; p++) + if (PtonB[p]) // in on boundary + { + const RdHat &PtHat(ipmat.P[p]); + mps->set(K.T(PtHat), PtHat, K, r, NN, ie); // la normal bofbof ? + KN_< R > Vpp(Vp(p, '.')); + for (int j = 0; j < dim; j++) + if (tabexp[j]) + if (bc->complextype) // FH may 2007 + Vpp[j] = GetAny< R >((*tabexp[j])(stack)); + else + Vpp[j] = GetAny< double >((*tabexp[j])(stack)); - for (int i=0;i 4) + for (map< int, int >::const_iterator i = lll.begin( ); i != lll.end( ); i++) + if (on.find(i->first) != on.end( )) cout << " on: missing lab " << i->first << " nb " << i->second << endl; + } + *mps = mp; + } - KN ip(Vh.MaxNbDFPerElement*6); - if (verbosity >3) - { - if (all) cout << " all " << endl ; - else cout << endl; + // creating an instance of AssembleBC + // case 3D surface + template< class R > + void AssembleBC(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + typedef MeshS Mesh; + typedef typename FESpaceS::FElement FElement; + typedef typename Mesh::BorderElement BorderElement; + typedef typename Mesh::Rd Rd; + typedef typename Mesh::Element Element; + typedef typename Mesh::RdHat RdHat; + + MeshPoint *mps = MeshPointStack(stack), mp = *mps; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + + int ktbc = 0, nbon = 0; + bool Aii = A && A->n == A->m; + int ndofBC = Aii ? A->n : 1; + KN< char > onBC(ndofBC); + onBC = '\0'; + + if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 + if (std::abs(tgv + 1.0) < 1.0e-10) + tgv = -10; + else if (std::abs(tgv + 2.0) < 1.0e-10) + tgv = -20; + else if (std::abs(tgv + 3.0) < 1.0e-10) + tgv = -30; + } + + int Nbcomp = Vh.N; + Check(bc, Nbcomp); + assert(Vh.N == Uh.N); + TabFuncArg tabexp(stack, Vh.N); + KN< double > buf((long int)Vh.MaximalNbOfDF( ) * (long int)last_operatortype * (long int)Vh.N); + KN< R > gg(buf); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); + if (verbosity > 99) cout << " Problem : BC_set " << typeid(R).name( ) << " "; + nbon = bc->on.size( ); + set< long > on; + Expandsetoflab(stack, *bc, on); + /* + for (int i=0;i( (*bc->on[i])(stack)); + if(verbosity>99) cout << lab << " " ; + on.insert(lab); + } + if(verbosity>99) + cout << endl;*/ + int kk = bc->bc.size( ); + + const int dim = Vh.N; + + InterpolationMatrix< RdHat > ipmat(Vh); + int npPh = Vh.maxNbPtforInterpolation; + KN< int > PtonB(npPh); + KNM< R > Vp(npPh, dim); + Vp = R( ); + KN< R > Vdf(Vh.MaxNbDFPerElement); + double tgv1 = tgv < 0 ? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1) : tgv; + map< int, int > lll; + for (int ib = 0; ib < Th.nbe; ib++) { + int ie; + int it = Th.BoundaryElement(ib, ie); + + // const BorderElement &be=Th.be(ib); + int r = Th.be(ib).lab; + lll[r]++; + if (on.find(r) != on.end( )) { + const FElement K(Uh[it]); + ipmat.set(K); + + // R2 E=K.T.Edge(ie); + // double le = be.mesure(); + + ktbc++; + /* + if(verbosity>99) cout << "BC " << it << " " << ie << " lab=" << r << ":\t" + << K.T[VerticesOfTriangularEdge[ie][0]] << "; " + << K.T[VerticesOfTriangularEdge[ie][1]] << " E=" << K.T.Edge(ie) << endl; + */ + for (int k = 0; k < kk; k++) { + gg = R( ); + pair< int, Expression > xx = bc->bc[k]; + tabexp = 0; + int comp = xx.first; + tabexp[comp] = xx.second; + // while (comp+1 bc[k].first)) + tabexp[comp] = bc->bc[k].second; + else + CompileError( + "In Boundary condition the vector FESpace , we must have:" + " all componant, in the right order"); + } + int nbdf = K.NbDoF( ); + // ipmat.set(it); + PtonB = 0; + + R3 E = K.T.Edge(ie); + double le = sqrt((E, E)); + // surface normal + Rd NNt = K.T.NormalTUnitaire( ); + // exterior normal (flux) + Rd NN = K.T.N(ie); + NN /= NN.norme( ); + + for (int i = 0; i < ipmat.ncoef; i++) PtonB[ipmat.p[i]] += Element::onWhatBorder[ie][K.DFOnWhat(ipmat.dofe[i])]; + + for (int p = 0; p < ipmat.np; p++) + if (PtonB[p]) // in on boundary + { + const RdHat &PtHat(ipmat.P[p]); + mps->set(K.T(PtHat), PtHat, K, r, NN, NNt, ie); // la normal bofbof ? + KN_< R > Vpp(Vp(p, '.')); + for (int j = 0; j < dim; j++) + if (tabexp[j]) + if (bc->complextype) // FH may 2007 + Vpp[j] = GetAny< R >((*tabexp[j])(stack)); + else + Vpp[j] = GetAny< double >((*tabexp[j])(stack)); + + else + Vpp[j] = 0.; + } + // cout << " Vp: " << Vp << endl; + K.Pi_h(Vp, Vdf, ipmat); + for (int df = 0; df < nbdf; df++) { + if (K.FromASubFE(df) == Uh.dim_which_sub_fem[xx.first] && Element::onWhatBorder[ie][K.DFOnWhat(df)]) { + int ddf = K(df); + // cout << ddf << " " << df << " " << Vdf[df] << " " << it << " ib = " << ib << " == " << Th(Th[it][df]) << endl; + // if (Aii) A->SetBC(ddf,tgv);// change 21 dec 2010 FH (Hack of ILU) + if (Aii) onBC[ddf] = '1'; + ; // april 2018 FH + if (B) (*B)[ddf] = tgv1 * Vdf[df]; + if (X) (*X)[ddf] = Vdf[df]; + } + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } - if(di.islevelset() && (kind !=CDomainOfIntegration::int1d)&& (kind !=CDomainOfIntegration::int2d)) - InternalError(" Sorry No levelSet integral for is case ..(5)"); + } + } + if (Aii) A->SetBC(onBC, tgv); + if (!ktbc && nbon && verbosity > 1) { + cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; + if (verbosity > 9) + for (map< int, int >::const_iterator i = lll.begin( ); i != lll.end( ); i++) + if (on.find(i->first) != on.end( )) cout << " on: missing lab " << i->first << " nb " << i->second << endl; + } + *mps = mp; + } + // creating an instance of AssembleBC + // case 3D curve + template< class R > + void AssembleBC(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + typedef MeshL Mesh; + typedef typename FESpaceL::FElement FElement; + typedef typename Mesh::BorderElement BorderElement; + typedef typename Mesh::Rd Rd; + typedef typename Mesh::Element Element; + typedef typename Mesh::RdHat RdHat; + + MeshPoint *mps = MeshPointStack(stack), mp = *mps; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + + int ktbc = 0, nbon = 0; + bool Aii = A && A->n == A->m; + int ndofBC = Aii ? A->n : 1; + KN< char > onBC(ndofBC); + onBC = '\0'; + + if (mpirankandsize && mpirankandsize[0] != 0) { // if tgv < 0, the diagonal term is handled by rank 0 + if (std::abs(tgv + 1.0) < 1.0e-10) + tgv = -10; + else if (std::abs(tgv + 2.0) < 1.0e-10) + tgv = -20; + else if (std::abs(tgv + 3.0) < 1.0e-10) + tgv = -30; + } + + int Nbcomp = Vh.N; + Check(bc, Nbcomp); + assert(Vh.N == Uh.N); + TabFuncArg tabexp(stack, Vh.N); + KN< double > buf((long int)Vh.MaximalNbOfDF( ) * (long int)last_operatortype * (long int)Vh.N); + KN< R > gg(buf); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleBC size rhs and nb of DF of Vh"); + if (verbosity > 99) cout << " Problem : BC_set " << typeid(R).name( ) << " "; + nbon = bc->on.size( ); + set< long > on; + Expandsetoflab(stack, *bc, on); + + int kk = bc->bc.size( ); + + const int dim = Vh.N; + + InterpolationMatrix< RdHat > ipmat(Vh); + int npPh = Vh.maxNbPtforInterpolation; + KN< int > PtonB(npPh); + KNM< R > Vp(npPh, dim); + Vp = R( ); + KN< R > Vdf(Vh.MaxNbDFPerElement); + double tgv1 = tgv < 0 ? ((mpirankandsize && mpirankandsize[0] != 0) ? 0 : 1) : tgv; + map< int, int > lll; + for (int ib = 0; ib < Th.nbe; ib++) { + int ie; + int it = Th.BoundaryElement(ib, ie); + + int r = Th.be(ib).lab; + lll[r]++; + if (on.find(r) != on.end( )) { + const FElement K(Uh[it]); + ipmat.set(K); + ktbc++; + + for (int k = 0; k < kk; k++) { + gg = R( ); + pair< int, Expression > xx = bc->bc[k]; + tabexp = 0; + int comp = xx.first; + tabexp[comp] = xx.second; + // while (comp+1 bc[k].first)) + tabexp[comp] = bc->bc[k].second; + else + CompileError( + "In Boundary condition the vector FESpace , we must have:" + " all componant, in the right order"); + } + int nbdf = K.NbDoF( ); + // ipmat.set(it); + PtonB = 0; + R3 NNt = K.T.NormalTUnitaire( ); + // exterior normal (flux) + Rd NN = K.T.N(ie); + NN /= NN.norme( ); + + for (int i = 0; i < ipmat.ncoef; i++) PtonB[ipmat.p[i]] += Element::onWhatBorder[ie][K.DFOnWhat(ipmat.dofe[i])]; + + for (int p = 0; p < ipmat.np; p++) + if (PtonB[p]) // in on boundary + { + const RdHat &PtHat(ipmat.P[p]); + mps->set(K.T(PtHat), PtHat, K, r, NN, NNt, ie); + KN_< R > Vpp(Vp(p, '.')); + for (int j = 0; j < dim; j++) + if (tabexp[j]) + if (bc->complextype) // FH may 2007 + Vpp[j] = GetAny< R >((*tabexp[j])(stack)); + else + Vpp[j] = GetAny< double >((*tabexp[j])(stack)); - if (kind==CDomainOfIntegration::int1d) - { + else + Vpp[j] = 0.; + } + K.Pi_h(Vp, Vdf, ipmat); + for (int df = 0; df < nbdf; df++) { + if (K.FromASubFE(df) == Uh.dim_which_sub_fem[xx.first] && Element::onWhatBorder[ie][K.DFOnWhat(df)]) { + int ddf = K(df); + if (Aii) onBC[ddf] = '1'; + ; // april 2018 FH + if (B) (*B)[ddf] = tgv1 * Vdf[df]; + if (X) (*X)[ddf] = Vdf[df]; + } + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } + if (Aii) A->SetBC(onBC, tgv); + if (!ktbc && nbon && verbosity) { + cout << " Warning: -- Your set of boundary condition is incompatible with the mesh label." << endl; + for (map< int, int >::const_iterator i = lll.begin( ); i != lll.end( ); i++) cout << " lab " << i->first << " nb " << i->second << endl; + } + *mps = mp; + } + // case 3D curve / 2D on meshL + template< class R > + void AssembleBC(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } - if(VF) InternalError(" no jump or average in int1d of RHS"); - if(di.islevelset()) - { - double uset = HUGE_VAL; - R2 Q[3]; - KN phi(ThI.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); + // case 2D / 3D curve on meshL + template< class R > + void AssembleBC(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } + // case 3D Surf / 3D volume on meshS + template< class R > + void AssembleBC(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } + // case 3D volume / 3D Surf on meshS + template< class R > + void AssembleBC(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } + // case 3D curve / 3D Surf on meshL + template< class R > + void AssembleBC(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } + // case 3D Surf / 3D curve on meshL + template< class R > + void AssembleBC(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, int *mpirankandsize) { + ffassert(0); + } - } - if( umn <=0 && umx >= 0) - { + void Expandsetoflab(Stack stack, const BC_set &bc, set< long > &setoflab); + void Expandsetoflab(Stack stack, const CDomainOfIntegration &di, set< int > &setoflab, bool &all); + + ////////////////////////////////// + // AssembleLinearForm + ////////////////////////////////// + + // creating an instance of AssembleLinearForm + // case 2d + template< class R > + void AssembleLinearForm(Stack stack, const Mesh &Th, const FESpace &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + Check(l->l, Vh.N); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); + // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); + KN< double > buf(Vh.MaximalNbOfDF( ) * last_operatortype * Vh.N * 2); + + // const FormLinear * l=dynamic_cast(e); + const CDomainOfIntegration &di = *l->di; + const Mesh &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th; - int np= IsoLineK(f,Q,1e-10); - if(np==2) - { - if ( sameMesh ) - {/* - void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B, - const QuadratureFormular1d & FI ,const R2 & PA,const R2 &PB) - - */ - Element_rhs(Vh[t],*l->l,buf,stack,*B,FIE,Q[0],Q[1],useopt); - } - else if(!mapt) - Element_rhs(ThI,ThI[t],Vh,0,ThI[t].lab,*l->l,buf,stack,*B,FIE,false,intmortar,Q,useopt); - else - ffassert(0); //Element_rhs(mapt,ThI,ThI[t],Vh,0,ThI[t].lab,*l->l,buf,stack,*B,FIE,false,intmortar,Q,useopt); - - //InternalError(" No levelSet on Diff mesh : to day int1d of RHS"); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * ThI.nt / mpi_size); + int ti1 = min(ThI.nt, (int)((mpi_rank + 1) * ceil(1. * ThI.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * ThI.neb / mpi_size); + int bei1 = min(ThI.neb, (int)((mpi_rank + 1) * ceil(1. * ThI.neb / mpi_size))); + + const bool intmortar = di.intmortar(stack); + + SHOWVERB(cout << " FormLinear " << endl); + // const vector & what(di.what); + + CDomainOfIntegration::typeofkind kind = di.kind; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FIT = di.FIT(stack); + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) + // cout << "AssembleLinearForm " << l->l->v.size() << endl; + set< int > setoflab; + bool all = true; + bool VF = l->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) + cout << " -- AssembleLinearForm 2, discontinuous Galerkin =" << VF << " binside = " << binside << " levelset integration " << di.islevelset( ) << " withmap: " << di.withmap( ) << "\n"; + + if (verbosity > 2) cout << mpirank << " ti0= " << ti0 << ", ti1 =" << ti1 << endl; + if (verbosity > 2) cout << mpirank << " bei0=" << bei0 << ", bei1=" << bei1 << endl; + // if( di.withmap()) { ExecError(" no map in the case (6)??");} + Expression const *const mapt = di.mapt[0] ? di.mapt : 0; + sameMesh = sameMesh && !mapt; // + + if (verbosity > 3) { + + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") "; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; + cout << ", samemesh :" << sameMesh << " int mortar: " << intmortar; + } + /* + if ( verbosity>3) + if (kind==CDomainOfIntegration::int1d) cout << " -- boundary int border " ; + else if (kind==CDomainOfIntegration::intalledges) cout << " -- boundary int all edges " ; + else if (kind==CDomainOfIntegration::intallVFedges) cout << " -- boundary int all edges " ; + else cout << " -- boundary int " ; + */ + if (di.islevelset( ) && ((CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind))) InternalError("So no levelset integration type on no int1d/int2d case (4)"); + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + } */ + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + + const E_F0 *poptiexp0 = l->l->optiexp0; + // const E_F0 & optiexpK=*l->l->optiexpK; + int n_where_in_stack_opt = l->l->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(l->l->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = l->l->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); - } - else - for( int e=bei0;e(Vh[i],ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - else - ffassert(0);//Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } - else if (kind==CDomainOfIntegration::intalledges) - { - ffassert(mapt==0); - cerr << " intalledges on fespaceS (to do) " << endl; - InternalError(" intalledges (to do) "); - ffassert(0); + if ((verbosity / 100) && verbosity % 10 == 2) { + int il = 0; - /*if(VF) code 2d .... ici - { - pair_stack_double bstack(stack,& binside); + for (LinearOperatorD::const_iterator ll = l->l->v.begin( ); ll != l->l->v.end( ); ll++, il++) + cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] << endl; - //bstack.first = stack; - //bstack.second= & binside; + for (int i = 0; i < n_where_in_stack_opt; i++) cout << "const coef " << i << " = " << *(where_in_stack[i]) << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< int > ip(Vh.MaxNbDFPerElement * 6); + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (di.islevelset( ) && (kind != CDomainOfIntegration::int1d) && (kind != CDomainOfIntegration::int2d)) InternalError(" Sorry No levelSet integral for is case ..(5)"); + + if (kind == CDomainOfIntegration::int1d) { + + if (VF) InternalError(" no jump or average in int1d of RHS"); + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[3]; + KN< double > phi(ThI.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + if (umn <= 0 && umx >= 0) { - //InternalError(" Today no jump or average in intalledges of RHS "); - for (int i=0;i< ThI.nt; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { + int np = IsoLineK(f, Q, 1e-10); + if (np == 2) { + if (sameMesh) { /* + void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B, + const QuadratureFormular1d & FI ,const R2 & PA,const R2 &PB) - for (int ie=0;ie<3;ie++) - if ( sameMesh) - { - int iie=ie,ii=Th.ElementAdj(i,iie); - if(ii<0) ii=i;// sur le bord - const TriangleS & K(ThI[i]); - int e0=VerticesOfTriangularEdge[ie][0]; - int e1=VerticesOfTriangularEdge[ie][1]; - int i1 = ThI(K[e0]),i2 = ThI(K[e1]); - BoundaryEdge * be = ThI.TheBoundaryEdge(i1,i2); - int lab = be ? be->lab : notalabel; - - Element_rhsVF(Vh[i],Vh[ii],ie,iie,lab,*l->l,buf,ip,&bstack,*B,FIE,useopt); - } - else - InternalError("To Do") ; - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } + */ + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIE, Q[0], Q[1], useopt); + } else if (!mapt) + Element_rhs< R >(ThI, ThI[t], Vh, 0, ThI[t].lab, *l->l, buf, stack, *B, FIE, false, intmortar, Q, useopt); + else + Element_rhs< R >(mapt, ThI, ThI[t], Vh, 0, ThI[t].lab, *l->l, buf, stack, *B, FIE, false, intmortar, Q, useopt); + // InternalError(" No levelSet on Diff mesh : to day int1d of RHS"); } + if (sptrclean) sptrclean = sptr->clean( ); + } + } + + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(ThI.bedges[e].lab) != setoflab.end( )) { + int ie, i = ThI.BoundaryElement(e, ie); + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th.bedges[e].lab, *l->l, buf, stack, *B, FIE, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, Th.bedges[e].lab, *l->l, buf, stack, *B, FIE, false, intmortar, 0, useopt); else - for (int i=0;i< ThI.nt; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - for (int ie=0;ie<3;ie++) - if ( sameMesh) - Element_rhs(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIE,true,useopt); - else - InternalError("To Do") ; - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - }*/ - } - else if (kind==CDomainOfIntegration::intallVFedges) - { - cerr << " intallVFedges a faire" << endl; + Element_rhs< R >(mapt, ThI, ThI[i], Vh, ie, Th.bedges[e].lab, *l->l, buf, stack, *B, FIE, false, intmortar, 0, useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (kind == CDomainOfIntegration::intalledges) { + ffassert(mapt == 0); + if (VF) { + pair_stack_double bstack(stack, &binside); + + // bstack.first = stack; + // bstack.second= & binside; + + // InternalError(" Today no jump or average in intalledges of RHS "); + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + + for (int ie = 0; ie < 3; ie++) + if (sameMesh) { + int iie = ie, ii = Th.ElementAdj(i, iie); + if (ii < 0) ii = i; // sur le bord + const Triangle &K(ThI[i]); + int e0 = VerticesOfTriangularEdge[ie][0]; + int e1 = VerticesOfTriangularEdge[ie][1]; + int i1 = ThI(K[e0]), i2 = ThI(K[e1]); + BoundaryEdge *be = ThI.TheBoundaryEdge(i1, i2); + int lab = be ? be->lab : notalabel; + + Element_rhsVF< R >(Vh[i], Vh[ii], ie, iie, lab, *l->l, buf, ip, &bstack, *B, FIE, useopt); + } else + InternalError("To Do"); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } - InternalError(" intallVFedges a faire "); + } else + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + for (int ie = 0; ie < 3; ie++) + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th[i].lab, *l->l, buf, stack, *B, FIE, true, useopt); + else + InternalError("To Do"); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } else if (kind == CDomainOfIntegration::intallVFedges) { + cerr << " intallVFedges a faire" << endl; - ffassert(0); - for (int i=ti0;i< ti1; i++) - { - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - for (int ie=0;ie<3;ie++) - { - if ( sameMesh) - Element_rhs(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIE,true,useopt); - else - InternalError("To Do") ; - } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } + InternalError(" intallVFedges a faire "); - else if (kind==CDomainOfIntegration::int2d){ - if(di.islevelset()) - { - QuadratureFormular FITM(FIT); - double uset = HUGE_VAL; - R2 Q[4]; - KN phi(Th.nv);phi=uset; - double f[3]; - for(int t=ti0; t< ti1;++t) - { - if ( all || setoflab.find(ThI[t].lab) != setoflab.end()) - { - double umx=-HUGE_VAL,umn=HUGE_VAL; - for(int i=0;i<3;++i) - { - int j= ThI(t,i); - if( phi[j]==uset) - { - MeshPointStack(stack)->setP(&ThI,t,i); - phi[j]= di.levelset(stack);//zzzz - } - f[i]=phi[j]; - umx = std::max(umx,phi[j]); - umn = std::min(umn,phi[j]); - - } - if( umx <=0 ) - {Element_rhs(Vh[t],*l->l,buf,stack,*B,FIT,useopt);} - else if( umn <0 ) - { // coupe .. - int i0 = 0, i1 = 1, i2 =2; - - if( f[i0] > f[i1] ) swap(i0,i1) ; - if( f[i0] > f[i2] ) swap(i0,i2) ; - if( f[i1] > f[i2] ) swap(i1,i2) ; - - double c = (f[i2]-f[i1])/(f[i2]-f[i0]); // coef Up Traing - if( f[i1] < 0 ) {double y=f[i2]/(f[i2]-f[i1]); c *=y*y; } - else {double y=f[i0]/(f[i0]-f[i1]) ; c = 1.- (1.-c)*y*y; }; - assert( c > 0 && c < 1); - double arean = (1-c)*Th[t].mesure(); - FITM=FIT; - FITM*=1-c; - ffassert(mapt==0); - Element_rhs(Vh[t],*l->l,buf,stack,*B,FITM,useopt); - } - if(sptrclean) sptrclean=sptr->clean(); - } - } - } - else { - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - if ( sameMesh ) - Element_rhs(Vh[i],*l->l,buf,stack,*B,FIT,useopt); - else - Element_rhs(ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIT,useopt); + ffassert(0); + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) { + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th[i].lab, *l->l, buf, stack, *B, FIE, true, useopt); + else + InternalError("To Do"); + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } } + else if (kind == CDomainOfIntegration::int2d) { + if (di.islevelset( )) { + QuadratureFormular FITM(FIT); + double uset = HUGE_VAL; + R2 Q[4]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(ThI[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + if (umx <= 0) + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIT, useopt); + else if (umn < 0) { // coupe .. + int i0 = 0, i1 = 1, i2 = 2; + + if (f[i0] > f[i1]) swap(i0, i1); + if (f[i0] > f[i2]) swap(i0, i2); + if (f[i1] > f[i2]) swap(i1, i2); + + double c = (f[i2] - f[i1]) / (f[i2] - f[i0]); // coef Up Traing + if (f[i1] < 0) { + double y = f[i2] / (f[i2] - f[i1]); + c *= y * y; + } else { + double y = f[i0] / (f[i0] - f[i1]); + c = 1. - (1. - c) * y * y; + }; + assert(c > 0 && c < 1); + double arean = (1 - c) * Th[t].area; + FITM = FIT; + FITM *= 1 - c; + ffassert(mapt == 0); + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FITM, useopt); + } + if (sptrclean) sptrclean = sptr->clean( ); + } } + } else + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + if (sameMesh) + Element_rhs< R >(Vh[i], *l->l, buf, stack, *B, FIT, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIT, useopt); + else + Element_rhs< R >(mapt, ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIT, useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - if (n_where_in_stack_opt) delete [] where_in_stack; + if (n_where_in_stack_opt) delete[] where_in_stack; + } - } + // creating an instance of AssembleLinearForm + // case 3D volume + template< class R > + void AssembleLinearForm(Stack stack, const Mesh3 &Th, const FESpace3 &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + typedef FESpace3 FESpace; + typedef FESpace3::Mesh Mesh; + typedef Mesh *pmesh; + typedef Mesh::BorderElement BorderElement; + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + Check(l->l, Vh.N); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); + // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); + KN< double > buf(Vh.MaximalNbOfDF( ) * last_operatortype * Vh.N * 2); + + // const FormLinear * l=dynamic_cast(e); + const CDomainOfIntegration &di = *l->di; + ffassert(di.d == 3); + // const Mesh * pThdi = GetAny( (* di.Th)(stack)); + + const Mesh &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th; - // creating an instance of AssembleLinearForm - // case 3d curve - template - void AssembleLinearForm(Stack stack,const MeshL & Th,const FESpaceL & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - typedef typename MeshL::Element Element; - typedef typename MeshL::BorderElement BorderElement; - - StackOfPtr2Free * sptr = WhereStackOfPtr2Free(stack); - bool sptrclean=true; - // sptr->clean(); // modif FH mars 2006 clean Ptr - Check(l->l,Vh.N); - if ( B && B->N() != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); - // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); - KN buf(Vh.MaximalNbOfDF()*last_operatortype*Vh.N*2); - const CDomainOfIntegration & di= *l->di; - ffassert(di.d==3); - - const MeshL & ThI = Th; - bool sameMesh = &ThI == &Vh.Th; - - int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; - int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize+1) : 1; - int ti0 = mpi_rank*ceil(1.*ThI.nt/mpi_size); - int ti1 = min(ThI.nt,(int)((mpi_rank+1)*ceil(1.*ThI.nt/mpi_size))); - int bei0 = mpi_rank*ceil(1.*ThI.nbe/mpi_size); - int bei1 = min(ThI.nbe,(int)((mpi_rank+1)*ceil(1.*ThI.nbe/mpi_size))); - - const bool intmortar=di.intmortar(stack); - - SHOWVERB(cout << " FormLinear " << endl); - // const vector & what(di.what); - - CDomainOfIntegration::typeofkind kind = di.kind; - const GQuadratureFormular & FIT = di.FIE(stack); - //const QuadratureFormular & FIT = di.FIT(stack); - const int useopt=di.UseOpt(stack); - double binside=di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) - // cout << "AssembleLinearForm " << l->l->v.size() << endl; - set setoflab; - bool all=true; - bool VF=l->VF(); // finite Volume or discontinuous Galerkin - - if (verbosity>2) cout << " -- AssembleLinearForm L, discontinuous Galerkin =" << VF << " binside = "<< binside - << " levelset integration " <3) cout << " Optimized = "<< useopt << ", "; - const E_F0 * poptiexp0=l->l->optiexp0; - // const E_F0 & optiexpK=*l->l->optiexpK; - int n_where_in_stack_opt=l->l->where_in_stack_opt.size(); - R** where_in_stack =0; - if (n_where_in_stack_opt && useopt) - where_in_stack = new R * [n_where_in_stack_opt]; - if (where_in_stack) - { - assert(l->l->v.size()==(size_t) n_where_in_stack_opt); - for (int i=0;il->where_in_stack_opt[i]; - assert(offset>10); - where_in_stack[i]= static_cast(static_cast((char*)stack+offset)); - *(where_in_stack[i])=0; - } - if(poptiexp0) (*poptiexp0)(stack); + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * ThI.nt / mpi_size); + int ti1 = min(ThI.nt, (int)((mpi_rank + 1) * ceil(1. * ThI.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * ThI.nbe / mpi_size); + int bei1 = min(ThI.nbe, (int)((mpi_rank + 1) * ceil(1. * ThI.nbe / mpi_size))); + + SHOWVERB(cout << " FormLinear " << endl); + // const vector & what(di.what); + + CDomainOfIntegration::typeofkind kind = di.kind; + // const QuadratureFormular1d & FIE = di.FIE(stack); + // const QuadratureFormular & FIT = di.FIT(stack); + // const GQuadratureFormular & FIV = di.FIV(stack); + + // const QuadratureFormular1d & FIEo = di.FIE(stack); + const QuadratureFormular &FITo = di.FIT(stack); + const GQuadratureFormular< R3 > &FIVo = di.FIV(stack); + // to change the quadrature on element ... may 2014 FH .. + // QuadratureFormular1d FIE(FIEo,3); + QuadratureFormular FIT(FITo, 3); + GQuadratureFormular< R3 > FIV(FIVo, 3); + + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) + // cout << "AssembleLinearForm " << l->l->v.size() << endl; + set< int > setoflab; + bool all = true; + bool VF = l->VF( ); // finite Volume or discontinuous Galerkin + if (verbosity > 2) cout << " -- AssembleLinearForm 1, discontinuous Galerkin =" << VF << " binside = " << binside << "\n"; + + if (verbosity > 3) { + if (CDomainOfIntegration::int2d == kind) + cout << " -- boundary int border ( nQP: " << FIT.n << ") , samemesh: " << sameMesh << " "; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIT.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIT.n << "),"; + else + cout << " -- int 3d (nQP: " << FIV.n << " ) in "; + } + Expression const *const mapt = *di.mapt ? di.mapt : 0; + + // if( di.withmap()) { ExecError(" no map in the case (5)??");} + + // if(di.islevelset()) InternalError("So no levelset integration type on this case (3)"); + if (di.islevelset( ) && (CDomainOfIntegration::int2d != kind) && (CDomainOfIntegration::int3d != kind)) InternalError("So no levelset intgeration type on no int2d/3d case"); + /* + if ( verbosity>3) + if (kind==CDomainOfIntegration::int1d) cout << " -- boundary int border " ; + else if (kind==CDomainOfIntegration::intalledges) cout << " -- boundary int all edges " ; + else if (kind==CDomainOfIntegration::intallVFedges) cout << " -- boundary int all edges " ; + else cout << " -- boundary int " ; + */ - if( (verbosity/100) && verbosity % 10 == 2) - { - int il=0; + Expandsetoflab(stack, di, setoflab, all); + /* + for (size_t i=0;i( (*what[i])(stack)); + setoflab.insert(lab); + if ( verbosity>3) cout << lab << " "; + all=false; + } + else + { + KN labs( GetAny >( (*what[i])(stack))); + for (long j=0; j3) cout << labs[j] << " "; + } + all=false; + }*/ - for (LinearOperatorD::const_iterator ll=l->l->v.begin();ll!=l->l->v.end();ll++,il++) - cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] < 3) cout << " Optimized = " << useopt << ", "; - for (int i=0;il->v.begin( ); ll != l->l->v.end( ); ll++, il++) + cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] << endl; - if(VF) InternalError(" no jump or average in int1d of RHS"); - if(di.islevelset()) - {cout << " ok di.islevelset() " << di.islevelset() << endl;} - - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { - if ( sameMesh ) - Element_rhs(Vh[i],*l->l,buf,stack,*B,FIT,useopt); - else - Element_rhs(ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIT,useopt); + for (int i = 0; i < n_where_in_stack_opt; i++) cout << "const coef " << i << " = " << *(where_in_stack[i]) << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + KN< int > ip(Vh.MaxNbDFPerElement * 6); + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (kind == CDomainOfIntegration::int2d) { // AFAIRE("3D Element RHS CDomainOfIntegration::int2d"); + double ss = 0; + if (VF) InternalError(" no jump or average in int1d of RHS"); + if (di.islevelset( )) // init on level set (of RHS) + { + ffassert(mapt == 0); + double uset = HUGE_VAL; + R3 Q[4]; + KN< double > phi(ThI.nv); + phi = uset; + double f[4]; + for (int t = ti0; t < ti1; ++t) { + + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 4; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + if (umn <= 0 && umx >= 0) { + + int np = IsoLineK(f, Q, 1e-10); // ca code ... + if (np == 3 || np == 4) { // if(np==3) Q[3]=Q[0]; // same 0 == 3 bofbof ??? FH + // cout << " Q[0]" << Q[0] << endl; + if (verbosity > 99) { + R3 PP[4]; + const Tet &K(ThI[t]); + for (int i = 0; i < np; ++i) PP[i] = K(Q[i]); + for (int i = 0; i + 1 < np; i += 2) { + int i0 = i, i1 = i + 1, i2 = (i + 2) % np; + R3 NN = R3(PP[i0], PP[i1]) ^ R3(PP[i0], PP[i2]); + double mes2 = (NN, NN); + double mes = sqrt(mes2) / 2; + ss += mes; + // cout << "mes " << mes << " " << i << " , "; } + } - + if (sameMesh) + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIT, np, Q, useopt); + else + // else + InternalError(" No levelSet on Diff mesh3 : to day int2d of RHS"); + // Element_rhs(ThI,ThI[t],Vh,-1,lab,*l->l,buf,stack,*B,FIT,false); + } + if (sptrclean) sptrclean = sptr->clean( ); + } } - else if(kind==CDomainOfIntegration::int0d){ // to + if (verbosity > 99) cout << " surf levelset = " << ss << endl; - for( int e=bei0;e(Vh[i],ie,Th.be(e).lab,*l->l,buf,stack,*B,FIT,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIT,false,intmortar,0,useopt); - else - ffassert(0);//Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(ThI.be(e).lab) != setoflab.end( )) { + int ie, i = ThI.BoundaryElement(e, ie); + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th.be(e).lab, *l->l, buf, stack, *B, FIT, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, Th.be(e).lab, *l->l, buf, stack, *B, FIT, false, useopt); + else + ffassert(0); // DO do FH... + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } } - else if(kind==CDomainOfIntegration::intall0d){ // to - // wrong to day ... - - ffassert(mapt==0); - if(VF) - { // Add juin 2021 ... - pair_stack_double bstack(stack,& binside); + } else if (kind == CDomainOfIntegration::intalledges) { + InternalError("3D Element RHS CDomainOfIntegration::intalledges : stupide !!!"); + } else if (kind == CDomainOfIntegration::intallVFedges) { + cerr << " intallVFedges a faire" << endl; - for (int i=ti0;i< ti1; i++) - if (all || setoflab.find(ThI[i].lab) != setoflab.end()) - { + InternalError(" intallVFedges a stupide!!! "); - for (int ie=0;ie<2;ie++) - if ( sameMesh) - { - int iie=ie,ii=Th.ElementAdj(i,iie); - if(ii<0) ii=i;// sur le bord - const Element & K(ThI[i]); - BorderElement * be=0; // to def - int lab = be ? be->lab : notalabel; + ffassert(0); + } - Element_rhsVF(Vh[i],Vh[ii],ie,iie,lab,*l->l,buf,ip,&bstack,*B,useopt); - } - else - InternalError("To Do") ; - if(sptrclean) sptrclean=sptr->clean(); - } + else if (kind == CDomainOfIntegration::int3d) { + if (di.islevelset( )) // may 2014 FH ... + { // int3d levelset < 0 + double llevelset = 0; + const double uset = std::numeric_limits< double >::max( ); + // cout << " uset ="< phi(Th.nv); + phi = uset; + double f[4]; + + for (int t = ti0; t < ti1; t++) { + + const Mesh3::Element &K(ThI[t]); + if (all || setoflab.find(ThI[t].lab) != setoflab.end( )) + + { + double umx = std::numeric_limits< double >::lowest( ), umn = std::numeric_limits< double >::max( ); + for (int i = 0; i < 4; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + } + int ntets = UnderIso(f, Q, vol6, 1e-14); + setQF< R3 >(FIV, FIVo, QuadratureFormular_Tet_1, Q, vol6, ntets); + if (FIV.n) { + if (sameMesh) + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIV, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[t], Vh, *l->l, buf, stack, *B, FIV, useopt); + else + ffassert(0); + // Element_rhs3(mapt,ThI,ThI[t],Vh,*l->l,buf,stack,*B,FIV,useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } + } + } + FIV = FIVo; + } else { + + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + if (sameMesh) + Element_rhs< R >(Vh[i], *l->l, buf, stack, *B, FIV, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIV, useopt); else - - for( int i=ti0;i(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIT,false,useopt); - else if(!mapt) - Element_rhs(ThI,ThI[i],Vh,ie,Th[i].lab,*l->l,buf,stack,*B,FIT,false,intmortar,0,useopt); - else - ffassert(0);//Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); - if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr - } - } - } + Element_rhs3< R >(mapt, ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIV, useopt); // to do !!!!! + // Element_rhs(mapt,ThI,ThI[i],Vh,*l->l,buf,stack,*B,FIV,useopt); + + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (kind == CDomainOfIntegration::intallfaces) { + assert(mapt == 0); + if (VF) { + if (!sameMesh) InternalError(" no jump or average in intallfaces for RHS in not samemesh"); + // InternalError(" no jump or average in intallfaces for RHS"); + pair_stack_double bstack(stack, &binside); - } + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { - else - { - cerr << " Error integration on MeshL unknown kind " << kind << endl; - ffassert(0); - - } - if (n_where_in_stack_opt) delete [] where_in_stack; + for (int ie = 0; ie < 4; ie++) + + { + int iie = ie, ii = Th.ElementAdj(i, iie); + BorderElement *be = 0; // FIND BOUNDARY ELEMENT !!! + if (ii < 0) ii = i; // sur le bord + const Tet &K(ThI[i]); + + int lab = be ? be->lab : notalabel; + Element_rhsVF< R >(Vh[i], Vh[ii], ie, iie, lab, *l->l, buf, ip, &bstack, *B, FIT, useopt); + } + + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } else { + for (int i = ti0; i < ti1; i++) + for (int ie = 0; ie < Mesh3::nea; ie++) { + int lab = 0; + // if face on bord get the lab ??? + if (sameMesh) + Element_rhs< R >(Vh[i], ie, lab, *l->l, buf, stack, *B, FIT, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, lab, *l->l, buf, stack, *B, FIT, false, useopt); + else + ffassert(mapt == 0); // + // Element_rhs(mapt,ThI,ThI[i],Vh,ie,lab,*l->l,buf,stack,*B,FIT,false,useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else { + cout << " Strange (unknows) kind = " << kind << endl; + ffassert(0); } + if (n_where_in_stack_opt) delete[] where_in_stack; + } + // creating an instance of AssembleLinearForm + // case surface 3d + template< class R > + void AssembleLinearForm(Stack stack, const MeshS &Th, const FESpaceS &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { - // creating an instance of AssembleLinearForm - // 3D curve / 2D on meshL - template - void AssembleLinearForm(Stack stack,const MeshL & Th,const FESpace & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - ffassert(0); - } - // creating an instance of AssembleLinearForm - // 3D Surf / 3D volume on meshS - template - void AssembleLinearForm(Stack stack,const MeshS & Th,const FESpace3 & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - ffassert(0); - } - // 3D curve / 3D Surf on meshL - template - void AssembleLinearForm(Stack stack,const MeshL & Th,const FESpaceS & Vh,KN_ * B,const FormLinear * l, int * mpirankandsize) - { - ffassert(0); - } + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + Check(l->l, Vh.N); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); + // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); + KN< double > buf(Vh.MaximalNbOfDF( ) * last_operatortype * Vh.N * 2); -}// END of NameSpace Fem2D + // const FormLinear * l=dynamic_cast(e); + const CDomainOfIntegration &di = *l->di; + ffassert(di.d == 3); + const MeshS &ThI = Th; // * GetAny( (* di.Th)(stack)); + bool sameMesh = &ThI == &Vh.Th; -bool isVF(const list & largs) // true => VF type of Matrix -{ - list::const_iterator ii,ib=largs.begin(), - ie=largs.end(); + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * ThI.nt / mpi_size); + int ti1 = min(ThI.nt, (int)((mpi_rank + 1) * ceil(1. * ThI.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * ThI.nbe / mpi_size); + int bei1 = min(ThI.nbe, (int)((mpi_rank + 1) * ceil(1. * ThI.nbe / mpi_size))); + + const bool intmortar = di.intmortar(stack); + + SHOWVERB(cout << " FormLinear " << endl); + // const vector & what(di.what); + + CDomainOfIntegration::typeofkind kind = di.kind; + const QuadratureFormular1d &FIE = di.FIE(stack); + const QuadratureFormular &FIT = di.FIT(stack); + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) + // cout << "AssembleLinearForm " << l->l->v.size() << endl; + set< int > setoflab; + bool all = true; + bool VF = l->VF( ); // finite Volume or discontinuous Galerkin + + if (verbosity > 2) + cout << " -- AssembleLinearForm S, discontinuous Galerkin =" << VF << " binside = " << binside << " levelset integration " << di.islevelset( ) << " withmap: " << di.withmap( ) << "\n"; + // if( di.withmap()) { ExecError(" no map in the case (6)??");} + Expression const *const mapt = di.mapt[0] ? di.mapt : 0; + sameMesh = sameMesh && !mapt; // + + if (verbosity > 3) { + + if (CDomainOfIntegration::int1d == kind) + cout << " -- boundary int border ( nQP: " << FIE.n << ") "; + else if (CDomainOfIntegration::intalledges == kind) + cout << " -- boundary int all edges ( nQP: " << FIE.n << "),"; + else if (CDomainOfIntegration::intallVFedges == kind) + cout << " -- boundary int all VF edges nQP: (" << FIE.n << "),"; + else + cout << " -- int 2d (nQP: " << FIT.n << " ) in "; + cout << ", samemesh :" << sameMesh << " int mortar: " << intmortar; + } + if (di.islevelset( ) && ((CDomainOfIntegration::int1d != kind) && (CDomainOfIntegration::int2d != kind))) InternalError("So no levelset integration type on no int1d/int2d case (4)"); + Expandsetoflab(stack, di, setoflab, all); + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = l->l->optiexp0; + // const E_F0 & optiexpK=*l->l->optiexpK; + int n_where_in_stack_opt = l->l->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(l->l->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = l->l->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); - bool VVF =false; - int kk=0,err=0; - - for (ii=ib;ii != ie;ii++) - { - kk++; - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==atype()) - { - const FormBilinear * bb=dynamic_cast(e); - bool vvf = bb->VF(); - if( vvf && (bb->di->kind != CDomainOfIntegration::intalledges) - && (bb->di->kind != CDomainOfIntegration::intallVFedges) - && (bb->di->kind != CDomainOfIntegration::intallfaces) - && (bb->di->kind != CDomainOfIntegration::intall0d)) // Add 15 juin 2021 FH? - { - if(err==0) cerr << "\n\n"; - cerr << " ** Fatal error in term "<< kk << " of the varf form (integral, on , ... ) " << endl; - err++; - } - VVF = vvf || VVF; - } - } - if(err) - { - cerr << " ** number " << err << " of error the varf form, with " << kk << " terms "<< endl; - CompileError("Sorry, no jump, mean, otherside in bilinear term must be in integral of type intalledges, intallVFedges or intallfaces"); + if ((verbosity / 100) && verbosity % 10 == 2) { + int il = 0; + + for (LinearOperatorD::const_iterator ll = l->l->v.begin( ); ll != l->l->v.end( ); ll++, il++) + cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] << endl; + + for (int i = 0; i < n_where_in_stack_opt; i++) cout << "const coef " << i << " = " << *(where_in_stack[i]) << endl; + } } - return VVF; -} + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; + + KN< int > ip(Vh.MaxNbDFPerElement * 6); + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (di.islevelset( ) && (kind != CDomainOfIntegration::int1d) && (kind != CDomainOfIntegration::int2d)) InternalError(" Sorry No levelSet integral for is case ..(5)"); + + if (kind == CDomainOfIntegration::int1d) { + + if (VF) InternalError(" no jump or average in int1d of RHS"); + if (di.islevelset( )) { + double uset = HUGE_VAL; + R2 Q[3]; + KN< double > phi(ThI.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + if (umn <= 0 && umx >= 0) { + int np = IsoLineK(f, Q, 1e-10); + if (np == 2) { + if (sameMesh) { /* + void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B, + const QuadratureFormular1d & FI ,const R2 & PA,const R2 &PB) -bool isSameMesh(const list & largs,const void * Thu,const void * Thv,Stack stack) // true => VF type of Matrix -{ - if( Thv != Thu ) return false; - list::const_iterator ii,ib=largs.begin(), - ie=largs.end(); + */ + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIE, Q[0], Q[1], useopt); + } else if (!mapt) + Element_rhs< R >(ThI, ThI[t], Vh, 0, ThI[t].lab, *l->l, buf, stack, *B, FIE, false, intmortar, Q, useopt); + else + ffassert(0); // Element_rhs(mapt,ThI,ThI[t],Vh,0,ThI[t].lab,*l->l,buf,stack,*B,FIE,false,intmortar,Q,useopt); - // bool VVF =false; - for (ii=ib;ii != ie;ii++) - { - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==atype()) - { - const FormBilinear * bb=dynamic_cast(e); - const void * Thbf = GetAny((*bb->di->Th)(stack)); - if (Thbf != Thu) return false; - } - else if (r==atype()) - { - const FormLinear * bb=dynamic_cast(e); - const void * Thbf = GetAny((*bb->di->Th)(stack)); - if (Thbf != Thu) return false; + // InternalError(" No levelSet on Diff mesh : to day int1d of RHS"); + } + if (sptrclean) sptrclean = sptr->clean( ); + } } - } - return true; -} -template -void InitProblem( int Nb, const FESpace & Uh, - const FESpace & Vh, - KN *&B,KN *&X,vector< pair< FEbase * ,int> > &u_hh, - Data_Sparse_Solver *ds ,// *typemat , - vector< FEbase * > & u_h,const FESpace ** LL, bool initx ) -{ - typedef typename FESpace::Mesh Mesh; - typedef typename FESpace::FElement FElement; - typedef typename Mesh::Element Element; - typedef typename Mesh::Vertex Vertex; - typedef typename Mesh::RdHat RdHat; - typedef typename Mesh::Rd Rd; + } else + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(ThI.be(e).lab) != setoflab.end( )) { + int ie, i = ThI.BoundaryElement(e, ie); + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th.be(e).lab, *l->l, buf, stack, *B, FIE, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, Th.be(e).lab, *l->l, buf, stack, *B, FIE, false, intmortar, 0, useopt); + else + ffassert(0); // Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } + } else if (kind == CDomainOfIntegration::intalledges) { + ffassert(mapt == 0); + cerr << " intalledges on fespaceS (to do) " << endl; + InternalError(" intalledges (to do) "); + ffassert(0); - *B=R(); + /*if(VF) code 2d .... ici + { + pair_stack_double bstack(stack,& binside); + + //bstack.first = stack; + //bstack.second= & binside; + + //InternalError(" Today no jump or average in intalledges of RHS "); + for (int i=0;i< ThI.nt; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end()) + { + + for (int ie=0;ie<3;ie++) + if ( sameMesh) + { + int iie=ie,ii=Th.ElementAdj(i,iie); + if(ii<0) ii=i;// sur le bord + const TriangleS & K(ThI[i]); + int e0=VerticesOfTriangularEdge[ie][0]; + int e1=VerticesOfTriangularEdge[ie][1]; + int i1 = ThI(K[e0]),i2 = ThI(K[e1]); + BoundaryEdge * be = ThI.TheBoundaryEdge(i1,i2); + int lab = be ? be->lab : notalabel; + + Element_rhsVF(Vh[i],Vh[ii],ie,iie,lab,*l->l,buf,ip,&bstack,*B,FIE,useopt); + } + else + InternalError("To Do") ; + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + } - // bool initx = typemat->t==TypeSolveMat::GC; + } + else + for (int i=0;i< ThI.nt; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end()) + { + for (int ie=0;ie<3;ie++) + if ( sameMesh) + Element_rhs(Vh[i],ie,Th[i].lab,*l->l,buf,stack,*B,FIE,true,useopt); + else + InternalError("To Do") ; + if(sptrclean) sptrclean=sptr->clean(); // modif FH mars 2006 clean Ptr + }*/ + } else if (kind == CDomainOfIntegration::intallVFedges) { + cerr << " intallVFedges a faire" << endl; - const Mesh & Th(Uh.Th); + InternalError(" intallVFedges a faire "); - if (initx) - { - if (!X || (X =B) ) - X=new KN(B->N()); - const FEbase & u_h0 = *(u_h[0]); - const FESpace * u_Vh = u_h0.Vh ; + ffassert(0); + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) + for (int ie = 0; ie < 3; ie++) { + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th[i].lab, *l->l, buf, stack, *B, FIE, true, useopt); + else + InternalError("To Do"); + } + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr + } + } - if ( u_Vh==0 || &((u_h[0])->Vh->Th) != &Th ) - { - *X=R(); - if(verbosity>1) - cout << " -- Change of Mesh " << (u_Vh ? & (*(u_h[0])).Vh->Th: 0 ) - << " " << &Th << endl; + else if (kind == CDomainOfIntegration::int2d) { + if (di.islevelset( )) { + QuadratureFormular FITM(FIT); + double uset = HUGE_VAL; + R2 Q[4]; + KN< double > phi(Th.nv); + phi = uset; + double f[3]; + for (int t = ti0; t < ti1; ++t) { + if (all || setoflab.find(ThI[t].lab) != setoflab.end( )) { + double umx = -HUGE_VAL, umn = HUGE_VAL; + for (int i = 0; i < 3; ++i) { + int j = ThI(t, i); + if (phi[j] == uset) { + MeshPointStack(stack)->setP(&ThI, t, i); + phi[j] = di.levelset(stack); // zzzz + } + f[i] = phi[j]; + umx = std::max(umx, phi[j]); + umn = std::min(umn, phi[j]); + } + if (umx <= 0) { + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FIT, useopt); + } else if (umn < 0) { // coupe .. + int i0 = 0, i1 = 1, i2 = 2; + + if (f[i0] > f[i1]) swap(i0, i1); + if (f[i0] > f[i2]) swap(i0, i2); + if (f[i1] > f[i2]) swap(i1, i2); + + double c = (f[i2] - f[i1]) / (f[i2] - f[i0]); // coef Up Traing + if (f[i1] < 0) { + double y = f[i2] / (f[i2] - f[i1]); + c *= y * y; + } else { + double y = f[i0] / (f[i0] - f[i1]); + c = 1. - (1. - c) * y * y; + }; + assert(c > 0 && c < 1); + double arean = (1 - c) * Th[t].mesure( ); + FITM = FIT; + FITM *= 1 - c; + ffassert(mapt == 0); + Element_rhs< R >(Vh[t], *l->l, buf, stack, *B, FITM, useopt); + } + if (sptrclean) sptrclean = sptr->clean( ); + } } - else - { // copy the previous soluton to initialize CG, GMRES, etc ... - if (Nb==1) - { // modif FH 0701/2005 + april 2006 - if(u_h[0]->x() && u_h[0]->x()->N() != X->N() )// correction juin FH 2021 .. - cout << " bug ???? " << endl; - if (u_h[0]->x() && u_h[0]->x()->N() == X->N() ) - *X= * u_h[0]->x(); - else - *X=R(); - } - else { // dispatch the solution - const FElement ** sK= new const FElement * [Nb]; - KN ** sol= new KN * [Nb]; - for (int i=0;i(Vh[i], *l->l, buf, stack, *B, FIT, useopt); + else + Element_rhs< R >(ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIT, useopt); - for (int it=0;itclean( ); // modif FH mars 2006 clean Ptr + } + } } + if (n_where_in_stack_opt) delete[] where_in_stack; + } -} + // creating an instance of AssembleLinearForm + // case 3d curve + template< class R > + void AssembleLinearForm(Stack stack, const MeshL &Th, const FESpaceL &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + typedef typename MeshL::Element Element; + typedef typename MeshL::BorderElement BorderElement; + + StackOfPtr2Free *sptr = WhereStackOfPtr2Free(stack); + bool sptrclean = true; + // sptr->clean(); // modif FH mars 2006 clean Ptr + Check(l->l, Vh.N); + if (B && B->N( ) != Vh.NbOfDF) ExecError("AssembleLinearForm size rhs and nb of DF of Vh"); + // if ( & Th != &Vh.Th ) ExecError("AssembleLinearForm on different meshes ( not implemented FH)."); + KN< double > buf(Vh.MaximalNbOfDF( ) * last_operatortype * Vh.N * 2); + const CDomainOfIntegration &di = *l->di; + ffassert(di.d == 3); + + const MeshL &ThI = Th; + bool sameMesh = &ThI == &Vh.Th; -// version InitProblem epuree pour les FESpace composite -template< class R, class FESpace, class v_fes> -void InitProblem( int Nb, const FESpace & Uh, - KN *&B,KN *&X, - FEbase * &u_h,bool initx ) -{ - typedef typename FESpace::Mesh Mesh; - typedef typename FESpace::FElement FElement; - typedef typename Mesh::Element Element; - typedef typename Mesh::Vertex Vertex; - typedef typename Mesh::RdHat RdHat; - typedef typename Mesh::Rd Rd; + int mpi_rank = mpirankandsize != nullptr ? *mpirankandsize : 0; + int mpi_size = mpirankandsize != nullptr ? *(mpirankandsize + 1) : 1; + int ti0 = mpi_rank * ceil(1. * ThI.nt / mpi_size); + int ti1 = min(ThI.nt, (int)((mpi_rank + 1) * ceil(1. * ThI.nt / mpi_size))); + int bei0 = mpi_rank * ceil(1. * ThI.nbe / mpi_size); + int bei1 = min(ThI.nbe, (int)((mpi_rank + 1) * ceil(1. * ThI.nbe / mpi_size))); + + const bool intmortar = di.intmortar(stack); + + SHOWVERB(cout << " FormLinear " << endl); + // const vector & what(di.what); + + CDomainOfIntegration::typeofkind kind = di.kind; + const GQuadratureFormular< R1 > &FIT = di.FIE(stack); + // const QuadratureFormular & FIT = di.FIT(stack); + const int useopt = di.UseOpt(stack); + double binside = di.binside(stack); // truc FH pour fluide de grad2 (decentrage bizard) + // cout << "AssembleLinearForm " << l->l->v.size() << endl; + set< int > setoflab; + bool all = true; + bool VF = l->VF( ); // finite Volume or discontinuous Galerkin + + if (verbosity > 2) + cout << " -- AssembleLinearForm L, discontinuous Galerkin =" << VF << " binside = " << binside << " levelset integration " << di.islevelset( ) << " withmap: " << di.withmap( ) + << " kind int: " << kind << "\n"; + // if( di.withmap()) { ExecError(" no map in the case (6)??");} + Expression const *const mapt = di.mapt[0] ? di.mapt : 0; + sameMesh = sameMesh && !mapt; // + + if (di.islevelset( ) && CDomainOfIntegration::int1d != kind) InternalError("So no levelset integration type on no int1d/int2d case (4)"); + Expandsetoflab(stack, di, setoflab, all); + if (verbosity > 3) cout << " Optimized = " << useopt << ", "; + const E_F0 *poptiexp0 = l->l->optiexp0; + // const E_F0 & optiexpK=*l->l->optiexpK; + int n_where_in_stack_opt = l->l->where_in_stack_opt.size( ); + R **where_in_stack = 0; + if (n_where_in_stack_opt && useopt) where_in_stack = new R *[n_where_in_stack_opt]; + if (where_in_stack) { + assert(l->l->v.size( ) == (size_t)n_where_in_stack_opt); + for (int i = 0; i < n_where_in_stack_opt; i++) { + int offset = l->l->where_in_stack_opt[i]; + assert(offset > 10); + where_in_stack[i] = static_cast< R * >(static_cast< void * >((char *)stack + offset)); + *(where_in_stack[i]) = 0; + } + if (poptiexp0) (*poptiexp0)(stack); + + if ((verbosity / 100) && verbosity % 10 == 2) { + int il = 0; - ffassert(Nb==1); + for (LinearOperatorD::const_iterator ll = l->l->v.begin( ); ll != l->l->v.end( ); ll++, il++) + cout << il << " coef (" << ll->first << ") = " << *(where_in_stack[il]) << " offset=" << l->l->where_in_stack_opt[il] << endl; - *B=R(); + for (int i = 0; i < n_where_in_stack_opt; i++) cout << "const coef " << i << " = " << *(where_in_stack[i]) << endl; + } + } + Stack_Ptr< R * >(stack, ElemMatPtrOffset) = where_in_stack; - // bool initx = typemat->t==TypeSolveMat::GC; + KN< int > ip(Vh.MaxNbDFPerElement * 6); + if (verbosity > 3) { + if (all) + cout << " all " << endl; + else + cout << endl; + } + if (di.islevelset( ) && (kind != CDomainOfIntegration::int1d)) InternalError(" Sorry No levelSet integral for is case ..(5)"); - const Mesh & Th(Uh.Th); + if (kind == CDomainOfIntegration::int1d) { - if (initx) - { - if (!X || (X =B) ) - X=new KN(B->N()); - const FEbase & u_h0 = *(u_h); - const FESpace * u_Vh = u_h0.Vh ; + if (VF) InternalError(" no jump or average in int1d of RHS"); + if (di.islevelset( )) { + cout << " ok di.islevelset() " << di.islevelset( ) << endl; + } - if ( u_Vh==0 || &((u_h)->Vh->Th) != &Th ) - { - *X=R(); - if(verbosity>1) - cout << " -- Change of Mesh " << (u_Vh ? & (*(u_h)).Vh->Th: 0 ) - << " " << &Th << endl; - } - else - { // copy the previous soluton to initialize CG, GMRES, etc ... - if (Nb==1) - { // modif FH 0701/2005 + april 2006 - if( u_h->x() && u_h->x()->N() != X->N() )// correction juin FH 2021 .. - cout << " bug ???? " << endl; - if( u_h->x() && u_h->x()->N() == X->N() ) - *X = * u_h->x(); - else - *X = R(); - } + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + if (sameMesh) + Element_rhs< R >(Vh[i], *l->l, buf, stack, *B, FIT, useopt); + else + Element_rhs< R >(ThI, ThI[i], Vh, *l->l, buf, stack, *B, FIT, useopt); + + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } - } -} -template -void InitCompositeProblem( vector &typeUh, vector & offsetUh, - vector &pfesUh, vector< void *> &u_h, KN *&X,KN *&B,bool initx) -{ - const int NpUh = typeUh.size(); + } else if (kind == CDomainOfIntegration::int0d) { // to - if(initx){ - if( !X || (X=B) ){ - X = new KN(offsetUh[NpUh]); + for (int e = bei0; e < bei1; e++) { + if (all || setoflab.find(ThI.be(e).lab) != setoflab.end( )) { + int ie, i = ThI.BoundaryElement(e, ie); + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th.be(e).lab, *l->l, buf, stack, *B, FIT, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, Th.be(e).lab, *l->l, buf, stack, *B, FIT, false, intmortar, 0, useopt); + else + ffassert(0); // Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } - for(int I=0; IgetpVh(); - const FESpace & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + } - KN *Bbloc=new KN(PUh->NbOfDF); // local B - KN *Xbloc=Bbloc; // local X + } else if (kind == CDomainOfIntegration::intall0d) { // to + // wrong to day ... - InitProblem( 1, Uh, Bbloc, Xbloc, u_h_loc, initx); + ffassert(mapt == 0); + if (VF) { // Add juin 2021 ... + pair_stack_double bstack(stack, &binside); - for(int i=0; iNbOfDF; i++){ - (*X)[i+offsetUh[I]] = (*Xbloc)[i]; - } - delete Bbloc; - delete Xbloc; - } - else if( typeUh[I] == 3){ - - const FESpace3 * PUh = (FESpace3 *) pfesUh[I]->getpVh(); - const FESpace3 & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; - KN *Bbloc=new KN(PUh->NbOfDF); // local B - KN *Xbloc=Bbloc; // local X - - InitProblem( 1, Uh, Bbloc, Xbloc, u_h_loc, initx); - - for(int i=0; iNbOfDF; i++){ - (*X)[i+offsetUh[I]] = (*Xbloc)[i]; - } - delete Bbloc; - delete Xbloc; - } - else if( typeUh[I] == 4){ + for (int i = ti0; i < ti1; i++) + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { - const FESpaceS * PUh = (FESpaceS *) pfesUh[I]->getpVh(); - const FESpaceS & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + for (int ie = 0; ie < 2; ie++) + if (sameMesh) { + int iie = ie, ii = Th.ElementAdj(i, iie); + if (ii < 0) ii = i; // sur le bord + const Element &K(ThI[i]); + BorderElement *be = 0; // to def + int lab = be ? be->lab : notalabel; - KN *Bbloc=new KN(PUh->NbOfDF); // local B - KN *Xbloc=Bbloc; // local X - - InitProblem( 1, Uh, Bbloc, Xbloc, u_h_loc, initx); + Element_rhsVF< R >(Vh[i], Vh[ii], ie, iie, lab, *l->l, buf, ip, &bstack, *B, useopt); + } else + InternalError("To Do"); + if (sptrclean) sptrclean = sptr->clean( ); + } - for(int i=0; iNbOfDF; i++){ - (*X)[i+offsetUh[I]] = (*Xbloc)[i]; - } - delete Bbloc; - delete Xbloc; - } - else if( typeUh[I] == 5){ - const FESpaceL * PUh = (FESpaceL *) pfesUh[I]->getpVh(); - const FESpaceL & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; - - KN *Bbloc=new KN(PUh->NbOfDF); // local B - KN *Xbloc=Bbloc; // local X - - InitProblem( 1, Uh, Bbloc, Xbloc, u_h_loc, initx); - - for(int i=0; iNbOfDF; i++) - (*X)[i+offsetUh[I]] = (*Xbloc)[i]; - delete Bbloc; - delete Xbloc; - } - else{ - cerr << "error int the Type of FESpace" << endl; - ffassert(0); + } else + + for (int i = ti0; i < ti1; i++) { + if (all || setoflab.find(ThI[i].lab) != setoflab.end( )) { + for (int ie = 0; ie < 2; ++ie) { + + if (sameMesh) + Element_rhs< R >(Vh[i], ie, Th[i].lab, *l->l, buf, stack, *B, FIT, false, useopt); + else if (!mapt) + Element_rhs< R >(ThI, ThI[i], Vh, ie, Th[i].lab, *l->l, buf, stack, *B, FIT, false, intmortar, 0, useopt); + else + ffassert(0); // Element_rhs(mapt,ThI,ThI[i],Vh,ie,Th.be(e).lab,*l->l,buf,stack,*B,FIE,false,intmortar,0,useopt); + if (sptrclean) sptrclean = sptr->clean( ); // modif FH mars 2006 clean Ptr } + } } + } -} + else { + cerr << " Error integration on MeshL unknown kind " << kind << endl; + ffassert(0); + } + if (n_where_in_stack_opt) delete[] where_in_stack; + } + + // creating an instance of AssembleLinearForm + // 3D curve / 2D on meshL + template< class R > + void AssembleLinearForm(Stack stack, const MeshL &Th, const FESpace &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + ffassert(0); + } + // creating an instance of AssembleLinearForm + // 3D Surf / 3D volume on meshS + template< class R > + void AssembleLinearForm(Stack stack, const MeshS &Th, const FESpace3 &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + ffassert(0); + } + // 3D curve / 3D Surf on meshL + template< class R > + void AssembleLinearForm(Stack stack, const MeshL &Th, const FESpaceS &Vh, KN_< R > *B, const FormLinear *l, int *mpirankandsize) { + ffassert(0); + } +} // END of NameSpace Fem2D -template - MatriceCreuse::Scalaire> * DefSolverCadna( - Stack stack, - MatriceCreuse & A, - Data_Sparse_Solver & ds -/* long NbSpace , - long itmax, - double & eps, - bool initmat, - int strategy, - const OneOperator *precon, - double tgv, - double tol_pivot, double tol_pivot_sym -*/ -) +bool isVF(const list< C_F0 > &largs) // true => VF type of Matrix { - typedef typename CadnaType::Scalaire R_st; - /* - // MatriceCreuse *CadnaMat; - if (ds.typemat->profile) + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + + bool VVF = false; + int kk = 0, err = 0; + + for (ii = ib; ii != ie; ii++) { + kk++; + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + bool vvf = bb->VF( ); + if (vvf && (bb->di->kind != CDomainOfIntegration::intalledges) && (bb->di->kind != CDomainOfIntegration::intallVFedges) && (bb->di->kind != CDomainOfIntegration::intallfaces) && + (bb->di->kind != CDomainOfIntegration::intall0d)) // Add 15 juin 2021 FH? { - if(verbosity>5) cout << " Matrix skyline type:" << ds.typemat->t < & AAA(dynamic_cast &>(A)); - MatriceProfile &AA(*new MatriceProfile(AAA)); // - - throwassert(&AA); - double tol_pivot1= (ds.tol_pivot>0) ? ds.tol_pivot : EPSILON/8.; - // cout << " tol_pivot1 " <t) { - case TypeSolveMat::LU : AA.LU(tol_pivot1); break; - case TypeSolveMat::CROUT : AA.crout(tol_pivot1); break; - case TypeSolveMat::CHOLESKY : AA.cholesky(tol_pivot1); break; - default: - cerr << " type resolution " << ds.typemat->t << endl; - CompileError("type resolution profile inconnue"); break; - } - return &AA; - } - else */ - { - ExecError("matrix HMAT & CADNA are incompatible today, sorry!"); - return 0; + if (err == 0) cerr << "\n\n"; + cerr << " ** Fatal error in term " << kk << " of the varf form (integral, on , ... ) " << endl; + err++; } - return 0; + VVF = vvf || VVF; + } } + if (err) { + cerr << " ** number " << err << " of error the varf form, with " << kk << " terms " << endl; + CompileError("Sorry, no jump, mean, otherside in bilinear term must be in integral of type intalledges, intallVFedges or intallfaces"); + } + return VVF; +} -template -void DispatchSolution(const typename FESpace::Mesh & Th,int Nb, vector< FEbase * > & u_h,KN * X,KN * B,const FESpace ** LL,const FESpace & Uh) +bool isSameMesh(const list< C_F0 > &largs, const void *Thu, const void *Thv, Stack stack) // true => VF type of Matrix { - typedef typename FESpace::Mesh Mesh; - typedef typename FESpace::FElement FElement; - typedef typename Mesh::Element Element; - typedef typename Mesh::Vertex Vertex; - typedef typename Mesh::RdHat RdHat; - typedef typename Mesh::Rd Rd; - - // dispatch the solution - if (Nb==1) { - *(u_h[0])=X; - if (X != B ) delete B; } - else { - const FElement ** sK= new const FElement * [Nb]; + if (Thv != Thu) return false; + list< C_F0 >::const_iterator ii, ib = largs.begin( ), ie = largs.end( ); + + // bool VVF =false; + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + const void *Thbf = GetAny< const void * >((*bb->di->Th)(stack)); + if (Thbf != Thu) return false; + } else if (r == atype< const FormLinear * >( )) { + const FormLinear *bb = dynamic_cast< const FormLinear * >(e); + const void *Thbf = GetAny< const void * >((*bb->di->Th)(stack)); + if (Thbf != Thu) return false; + } + } + return true; +} - KN ** sol= new KN * [Nb]; - for (int i=0;i( LL[i]->NbOfDF) ; - *(u_h[i]) = sol[i]; +template< class R, class FESpace, class v_fes > +void InitProblem(int Nb, const FESpace &Uh, const FESpace &Vh, KN< R > *&B, KN< R > *&X, vector< pair< FEbase< R, v_fes > *, int > > &u_hh, + Data_Sparse_Solver *ds, // *typemat , + vector< FEbase< R, v_fes > * > &u_h, const FESpace **LL, bool initx) { + typedef typename FESpace::Mesh Mesh; + typedef typename FESpace::FElement FElement; + typedef typename Mesh::Element Element; + typedef typename Mesh::Vertex Vertex; + typedef typename Mesh::RdHat RdHat; + typedef typename Mesh::Rd Rd; + + *B = R( ); + + // bool initx = typemat->t==TypeSolveMat::GC; + + const Mesh &Th(Uh.Th); + + if (initx) { + if (!X || (X = B)) X = new KN< R >(B->N( )); + const FEbase< R, v_fes > &u_h0 = *(u_h[0]); + const FESpace *u_Vh = u_h0.Vh; + + if (u_Vh == 0 || &((u_h[0])->Vh->Th) != &Th) { + *X = R( ); + if (verbosity > 1) cout << " -- Change of Mesh " << (u_Vh ? &(*(u_h[0])).Vh->Th : 0) << " " << &Th << endl; + } else { // copy the previous soluton to initialize CG, GMRES, etc ... + if (Nb == 1) { // modif FH 0701/2005 + april 2006 + if (u_h[0]->x( ) && u_h[0]->x( )->N( ) != X->N( )) // correction juin FH 2021 .. + cout << " bug ???? " << endl; + if (u_h[0]->x( ) && u_h[0]->x( )->N( ) == X->N( )) + *X = *u_h[0]->x( ); + else + *X = R( ); + } else { // dispatch the solution + const FElement **sK = new const FElement *[Nb]; + KN< R > **sol = new KN< R > *[Nb]; + for (int i = 0; i < Nb; i++) { + + sol[i] = (*(u_h[i])).x( ); + } + + for (int it = 0; it < Th.nt; it++) { + const FElement K(Uh[it]); + const int nbdf = K.NbDoF( ); + for (int i = 0; i < Nb; i++) sK[i] = new FElement((*LL[i])[it]); + for (int df = 0; df < nbdf; df++) { + int kfe = K.FromFE(df); + int kdf = K.FromDF(df); + if (sol[kfe]) { + const FElement &SK(*sK[kfe]); + (*X)[K(df)] = (*sol[kfe])[SK(kdf)]; + } else + (*X)[K(df)] = R( ); + } + for (int i = 0; i < Nb; i++) delete sK[i]; } + delete[] sol; + delete[] sK; + } + } + } +} - for (int it=0;it +void InitProblem(int Nb, const FESpace &Uh, KN< R > *&B, KN< R > *&X, FEbase< R, v_fes > *&u_h, bool initx) { + typedef typename FESpace::Mesh Mesh; + typedef typename FESpace::FElement FElement; + typedef typename Mesh::Element Element; + typedef typename Mesh::Vertex Vertex; + typedef typename Mesh::RdHat RdHat; + typedef typename Mesh::Rd Rd; + + ffassert(Nb == 1); + + *B = R( ); + + // bool initx = typemat->t==TypeSolveMat::GC; + + const Mesh &Th(Uh.Th); + + if (initx) { + if (!X || (X = B)) X = new KN< R >(B->N( )); + const FEbase< R, v_fes > &u_h0 = *(u_h); + const FESpace *u_Vh = u_h0.Vh; + + if (u_Vh == 0 || &((u_h)->Vh->Th) != &Th) { + *X = R( ); + if (verbosity > 1) cout << " -- Change of Mesh " << (u_Vh ? &(*(u_h)).Vh->Th : 0) << " " << &Th << endl; + } else { // copy the previous soluton to initialize CG, GMRES, etc ... + if (Nb == 1) { // modif FH 0701/2005 + april 2006 + if (u_h->x( ) && u_h->x( )->N( ) != X->N( )) // correction juin FH 2021 .. + cout << " bug ???? " << endl; + if (u_h->x( ) && u_h->x( )->N( ) == X->N( )) + *X = *u_h->x( ); + else + *X = R( ); + } + } + } +} - } +template< class R > +void InitCompositeProblem(vector< int > &typeUh, vector< long > &offsetUh, vector< generic_v_fes * > &pfesUh, vector< void * > &u_h, KN< R > *&X, KN< R > *&B, bool initx) { + const int NpUh = typeUh.size( ); - delete [] sK; - delete [] sol; - if (X != B && X ) delete X; - delete B; + if (initx) { + if (!X || (X = B)) { + X = new KN< R >(offsetUh[NpUh]); } -} + for (int I = 0; I < NpUh; I++) { + if (typeUh[I] == 2) { + const FESpace *PUh = (FESpace *)pfesUh[I]->getpVh( ); + const FESpace &Uh = *PUh; + FEbase< R, v_fes > *u_h_loc = (FEbase< R, v_fes > *)u_h[I]; -// version dispatch solution for composite FESpace -template -void DispatchSolution( vector &typeUh, vector & offsetUh, - vector &pfesUh, vector< void *> &u_h, KN * X,KN * B) -{ - const int NpUh = typeUh.size(); + KN< R > *Bbloc = new KN< R >(PUh->NbOfDF); // local B + KN< R > *Xbloc = Bbloc; // local X - for(int I=0; I(1, Uh, Bbloc, Xbloc, u_h_loc, initx); - const FESpace * PUh = (FESpace *) pfesUh[I]->getpVh(); - const FESpace & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + for (int i = 0; i < PUh->NbOfDF; i++) { + (*X)[i + offsetUh[I]] = (*Xbloc)[i]; + } + delete Bbloc; + delete Xbloc; + } else if (typeUh[I] == 3) { - KN *Xbloc=new KN(PUh->NbOfDF); // local X - for(int i=0; iNbOfDF; i++){ (*Xbloc)[i] = (*X)[i+offsetUh[I]]; } - (*u_h_loc)=Xbloc; - } - else if( typeUh[I] == 3){ + const FESpace3 *PUh = (FESpace3 *)pfesUh[I]->getpVh( ); + const FESpace3 &Uh = *PUh; + FEbase< R, v_fes3 > *u_h_loc = (FEbase< R, v_fes3 > *)u_h[I]; + KN< R > *Bbloc = new KN< R >(PUh->NbOfDF); // local B + KN< R > *Xbloc = Bbloc; // local X - const FESpace3 * PUh = (FESpace3 *) pfesUh[I]->getpVh(); - const FESpace3 & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + InitProblem< R, FESpace3, v_fes3 >(1, Uh, Bbloc, Xbloc, u_h_loc, initx); - KN *Xbloc=new KN(PUh->NbOfDF); // local X - for(int i=0; iNbOfDF; i++){ (*Xbloc)[i] = (*X)[i+offsetUh[I]]; } - (*u_h_loc)=Xbloc; + for (int i = 0; i < PUh->NbOfDF; i++) { + (*X)[i + offsetUh[I]] = (*Xbloc)[i]; } - else if( typeUh[I] == 4){ + delete Bbloc; + delete Xbloc; + } else if (typeUh[I] == 4) { - const FESpaceS * PUh = (FESpaceS *) pfesUh[I]->getpVh(); - const FESpaceS & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + const FESpaceS *PUh = (FESpaceS *)pfesUh[I]->getpVh( ); + const FESpaceS &Uh = *PUh; + FEbase< R, v_fesS > *u_h_loc = (FEbase< R, v_fesS > *)u_h[I]; - KN *Xbloc=new KN(PUh->NbOfDF); // local X - for(int i=0; iNbOfDF; i++){ (*Xbloc)[i] = (*X)[i+offsetUh[I]]; } - (*u_h_loc)=Xbloc; - } - else if( typeUh[I] == 5){ + KN< R > *Bbloc = new KN< R >(PUh->NbOfDF); // local B + KN< R > *Xbloc = Bbloc; // local X - const FESpaceL * PUh = (FESpaceL *) pfesUh[I]->getpVh(); - const FESpaceL & Uh= *PUh; - FEbase * u_h_loc = (FEbase *) u_h[I]; + InitProblem< R, FESpaceS, v_fesS >(1, Uh, Bbloc, Xbloc, u_h_loc, initx); - KN *Xbloc=new KN(PUh->NbOfDF); // local X - for(int i=0; iNbOfDF; i++){ (*Xbloc)[i] = (*X)[i+offsetUh[I]]; } - (*u_h_loc)=Xbloc; - } - else{ - cerr << "error int the Type of FESpace" << endl; - ffassert(0); + for (int i = 0; i < PUh->NbOfDF; i++) { + (*X)[i + offsetUh[I]] = (*Xbloc)[i]; } + delete Bbloc; + delete Xbloc; + } else if (typeUh[I] == 5) { + const FESpaceL *PUh = (FESpaceL *)pfesUh[I]->getpVh( ); + const FESpaceL &Uh = *PUh; + FEbase< R, v_fesL > *u_h_loc = (FEbase< R, v_fesL > *)u_h[I]; + + KN< R > *Bbloc = new KN< R >(PUh->NbOfDF); // local B + KN< R > *Xbloc = Bbloc; // local X + + InitProblem< R, FESpaceL, v_fesL >(1, Uh, Bbloc, Xbloc, u_h_loc, initx); + + for (int i = 0; i < PUh->NbOfDF; i++) (*X)[i + offsetUh[I]] = (*Xbloc)[i]; + delete Bbloc; + delete Xbloc; + } else { + cerr << "error int the Type of FESpace" << endl; + ffassert(0); + } } - if (X != B ) delete B; + } } -/* -#ifdef HAVE_LIBUMFPACK -TypeSolveMat::TSolveMat TypeSolveMat::defaultvalue=TypeSolveMat::SparseSolver; -#else -TypeSolveMat::TSolveMat TypeSolveMat::defaultvalue=TypeSolveMat::LU; -#endif -*/ -template // TODO if coupling FE with problem -AnyType Problem::eval(Stack stack,Data * data,CountPointer > & dataA, - MatriceCreuse< typename CadnaType::Scalaire > * & cadnamat ) const -{ - typedef typename FESpace::Mesh MeshT; - typedef typename FESpace::FElement FElement; - typedef typename MeshT::Element Element; - typedef typename MeshT::Vertex Vertex; - typedef typename MeshT::RdHat RdHat; - typedef typename MeshT::Rd Rd; - - using namespace Fem2D; - typedef typename CadnaType::Scalaire R_st; - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - Data_Sparse_Solver ds; - /* long NbSpace = 50; - long itmax=0; - double epsilon=1e-6;*/ - string save; - - KN* cadna=0; - - if (nargs[0]) save = *GetAny((*nargs[0])(stack)); - if (nargs[1]) cadna= GetAny* >((*nargs[1])(stack)); - - int np_bem = n_name_param; - int np = np_bem - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver(stack,ds,nargs,np); - - - // for the gestion of the PTR. - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH aout 2007 - - bool sym = ds.sym; - - //list::const_iterator ii,ib=op->largs.begin(), ie=op->largs.end(); // delete unused variable - int Nbcomp2=var.size(),Nbcomp=Nbcomp2/2; // nb de composante - throwassert(Nbcomp2==2*Nbcomp); - // Data *data= dataptr(stack); - // data->init(); - KN which_comp(Nbcomp2),which_uh(Nbcomp2); - - //TabFuncArg tabexp(stack,Nbcomp); // delete unused variable - typedef pair< FEbase *,int> pfer; - vector< pair< FEbase *,int> > u_hh(Nbcomp2); - // u_hh.first --> FEbase * - // u_hh.second --> numero de la composante dans le cas d'un vectorial FESpace (ex: pfes*_tefk) - - for (size_t i=0;i( (*(var[i]))(stack)); - for (size_t i=0;inewVh(); // get FESpace, FESpace3, ... - // compression pour les cas vectoriel - int kkk=0; - for (int i=0;i * > u_h(kkk); // the list of the true pointer to FEbase - kkk= 0; - for (int i=0;i LL(var.size()); // creation de la liste des FESpace" Nb2 <= var.size() " - for (int i=0;iTh; - for (int i=0;iTh != pTh) - ExecError("all the finite element spaces must be defined on the same mesh in solve"); - - if ( pTh != data->pTh ) +template< class R > +MatriceCreuse< typename CadnaType< R >::Scalaire > *DefSolverCadna(Stack stack, MatriceCreuse< R > &A, Data_Sparse_Solver &ds + /* long NbSpace , + long itmax, + double & eps, + bool initmat, + int strategy, + const OneOperator *precon, + double tgv, + double tol_pivot, double tol_pivot_sym + */ +) { + typedef typename CadnaType< R >::Scalaire R_st; + /* +// MatriceCreuse *CadnaMat; + if (ds.typemat->profile) { - // set value of the struct data - ds.initmat = true; - data->pTh=pTh; - if (Nb==1) - { // cas scalaire - data->Uh=LL[0]; - data->Vh=LL[1]; } - else - { // cas vectoriel - // check that we have the same finconue space and ftest space - bool same=true; - for (int i=0;iFirstDfOfNodeData)// Correct jan 2015 not FE product this case - { - unique = false; - break; - } - - if (unique) - data->Uh.master( new FESpace(*LL[0],Nb)); - else - data->Uh.master(new FESpace(LL,Nb)); - data->Vh=data->Uh; - } - - } + if(verbosity>5) cout << " Matrix skyline type:" << ds.typemat->t < & AAA(dynamic_cast &>(A)); + MatriceProfile &AA(*new MatriceProfile(AAA)); // + + throwassert(&AA); + double tol_pivot1= (ds.tol_pivot>0) ? ds.tol_pivot : EPSILON/8.; + // cout << " tol_pivot1 " <t) { + case TypeSolveMat::LU : AA.LU(tol_pivot1); break; + case TypeSolveMat::CROUT : AA.crout(tol_pivot1); break; + case TypeSolveMat::CHOLESKY : AA.cholesky(tol_pivot1); break; + default: + cerr << " type resolution " << ds.typemat->t << endl; + CompileError("type resolution profile inconnue"); break; + } + return &AA; } + else */ + { + ExecError("matrix HMAT & CADNA are incompatible today, sorry!"); + return 0; + } + return 0; +} - const FESpace & Uh(*data->Uh); - const FESpace & Vh(*data->Vh); - throwassert(Nbcomp==Uh.N && Nbcomp==Vh.N); - KN *B=new KN(Vh.NbOfDF); - KN *X=B; // - const MeshT & Th(Uh.Th); - bool initx = true; //typemat->t==TypeSolveMat::GC ; // make x and b different in all case - // more safe for the future ( 4 days lose with is optimization FH ) +template< class R, class FESpace, class v_fes > +void DispatchSolution(const typename FESpace::Mesh &Th, int Nb, vector< FEbase< R, v_fes > * > &u_h, KN< R > *X, KN< R > *B, const FESpace **LL, const FESpace &Uh) { + typedef typename FESpace::Mesh Mesh; + typedef typename FESpace::FElement FElement; + typedef typename Mesh::Element Element; + typedef typename Mesh::Vertex Vertex; + typedef typename Mesh::RdHat RdHat; + typedef typename Mesh::Rd Rd; + + // dispatch the solution + if (Nb == 1) { + *(u_h[0]) = X; + if (X != B) delete B; + } else { + const FElement **sK = new const FElement *[Nb]; + + KN< R > **sol = new KN< R > *[Nb]; + for (int i = 0; i < Nb; i++) { + sol[i] = new KN< R >(LL[i]->NbOfDF); + *(u_h[i]) = sol[i]; + } + + for (int it = 0; it < Th.nt; it++) { + const FElement K(Uh[it]); + const int nbdf = K.NbDoF( ); + for (int i = 0; i < Nb; i++) sK[i] = new FElement((*LL[i])[it]); + for (int df = 0; df < nbdf; df++) { + int kfe = K.FromFE(df); + int kdf = K.FromDF(df); + const FElement &SK(*sK[kfe]); + (*sol[kfe])[SK(kdf)] = (*X)[K(df)]; + } + for (int i = 0; i < Nb; i++) delete sK[i]; + } - InitProblem( Nb, Uh, Vh, B, X,u_hh,&ds , u_h, LL, initx); + delete[] sK; + delete[] sol; + if (X != B && X) delete X; + delete B; + } +} - if(verbosity>2) cout << " Problem(): initmat " << ds.initmat << " VF (discontinuous Galerkin) = " << VF << endl; +// version dispatch solution for composite FESpace +template< class R > +void DispatchSolution(vector< int > &typeUh, vector< long > &offsetUh, vector< generic_v_fes * > &pfesUh, vector< void * > &u_h, KN< R > *X, KN< R > *B) { + const int NpUh = typeUh.size( ); + for (int I = 0; I < NpUh; I++) { + if (typeUh[I] == 2) { + const FESpace *PUh = (FESpace *)pfesUh[I]->getpVh( ); + const FESpace &Uh = *PUh; + FEbase< R, v_fes > *u_h_loc = (FEbase< R, v_fes > *)u_h[I]; - if (ds.initmat) - { - { - if ( &Uh == & Vh ) - dataA.master(new MatriceMorse( Vh.NbOfDF,Vh.NbOfDF,sym)); - else - dataA.master(new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,false)); - } - MatriceCreuse & AA(dataA); - if(verbosity>1) cout << " -- size of Matrix " << AA.size()<< " Bytes" <profile <<*/ endl; + KN< R > *Xbloc = new KN< R >(PUh->NbOfDF); // local X + for (int i = 0; i < PUh->NbOfDF; i++) { + (*Xbloc)[i] = (*X)[i + offsetUh[I]]; } - MatriceCreuse & A(dataA); - if (AssembleVarForm( stack,Th,Uh,Vh,sym, ds.initmat ? &A:0 , B, op->largs)) - { - *B = - *B; - // hach FH - for (int i=0, n= B->N(); i< n; i++) - if( abs((*B)[i]) < 1.e-60 ) (*B)[i]=0; - - AssembleBC ( stack,Th,Uh,Vh,sym, ds.initmat ? &A:0 , B, initx ? X:0, op->largs, ds.tgv ); // TODO with problem - } - else - *B = - *B; + (*u_h_loc) = Xbloc; + } else if (typeUh[I] == 3) { - dynamic_cast *>(&A)->half = ds.sym; + const FESpace3 *PUh = (FESpace3 *)pfesUh[I]->getpVh( ); + const FESpace3 &Uh = *PUh; + FEbase< R, v_fes3 > *u_h_loc = (FEbase< R, v_fes3 > *)u_h[I]; - MatriceCreuse * ACadna = 0; + KN< R > *Xbloc = new KN< R >(PUh->NbOfDF); // local X + for (int i = 0; i < PUh->NbOfDF; i++) { + (*Xbloc)[i] = (*X)[i + offsetUh[I]]; + } + (*u_h_loc) = Xbloc; + } else if (typeUh[I] == 4) { + const FESpaceS *PUh = (FESpaceS *)pfesUh[I]->getpVh( ); + const FESpaceS &Uh = *PUh; + FEbase< R, v_fesS > *u_h_loc = (FEbase< R, v_fesS > *)u_h[I]; - try { + KN< R > *Xbloc = new KN< R >(PUh->NbOfDF); // local X + for (int i = 0; i < PUh->NbOfDF; i++) { + (*Xbloc)[i] = (*X)[i + offsetUh[I]]; + } + (*u_h_loc) = Xbloc; + } else if (typeUh[I] == 5) { - if (ds.initmat) - { - // if(cadna) - // ACadna = DefSolverCadna( stack,A, ds); - // else - DefSolver(stack, A, ds); - } + const FESpaceL *PUh = (FESpaceL *)pfesUh[I]->getpVh( ); + const FESpaceL &Uh = *PUh; + FEbase< R, v_fesL > *u_h_loc = (FEbase< R, v_fesL > *)u_h[I]; + KN< R > *Xbloc = new KN< R >(PUh->NbOfDF); // local X + for (int i = 0; i < PUh->NbOfDF; i++) { + (*Xbloc)[i] = (*X)[i + offsetUh[I]]; + } + (*u_h_loc) = Xbloc; + } else { + cerr << "error int the Type of FESpace" << endl; + ffassert(0); + } + } + if (X != B) delete B; +} +/* +#ifdef HAVE_LIBUMFPACK +TypeSolveMat::TSolveMat TypeSolveMat::defaultvalue=TypeSolveMat::SparseSolver; +#else +TypeSolveMat::TSolveMat TypeSolveMat::defaultvalue=TypeSolveMat::LU; +#endif +*/ +template< class R, class FESpace, class v_fes > // TODO if coupling FE with problem +AnyType Problem::eval(Stack stack, Data< FESpace > *data, CountPointer< MatriceCreuse< R > > &dataA, MatriceCreuse< typename CadnaType< R >::Scalaire > *&cadnamat) const { + typedef typename FESpace::Mesh MeshT; + typedef typename FESpace::FElement FElement; + typedef typename MeshT::Element Element; + typedef typename MeshT::Vertex Vertex; + typedef typename MeshT::RdHat RdHat; + typedef typename MeshT::Rd Rd; + + using namespace Fem2D; + typedef typename CadnaType< R >::Scalaire R_st; + MeshPoint *mps = MeshPointStack(stack), mp = *mps; + Data_Sparse_Solver ds; + /* long NbSpace = 50; + long itmax=0; + double epsilon=1e-6;*/ + string save; + + KN< double > *cadna = 0; + + if (nargs[0]) save = *GetAny< string * >((*nargs[0])(stack)); + if (nargs[1]) cadna = GetAny< KN< double > * >((*nargs[1])(stack)); + + int np_bem = n_name_param; + int np = np_bem - NB_NAME_PARM_HMAT; + SetEnd_Data_Sparse_Solver< R >(stack, ds, nargs, np); + + // for the gestion of the PTR. + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH aout 2007 + + bool sym = ds.sym; + + // list::const_iterator ii,ib=op->largs.begin(), ie=op->largs.end(); // delete unused variable + int Nbcomp2 = var.size( ), Nbcomp = Nbcomp2 / 2; // nb de composante + throwassert(Nbcomp2 == 2 * Nbcomp); + // Data *data= dataptr(stack); + // data->init(); + KN< int > which_comp(Nbcomp2), which_uh(Nbcomp2); + + // TabFuncArg tabexp(stack,Nbcomp); // delete unused variable + typedef pair< FEbase< R, v_fes > *, int > pfer; + vector< pair< FEbase< R, v_fes > *, int > > u_hh(Nbcomp2); + // u_hh.first --> FEbase * + // u_hh.second --> numero de la composante dans le cas d'un vectorial FESpace (ex: pfes*_tefk) + + for (size_t i = 0; i < var.size( ); i++) u_hh[i] = GetAny< pfer >((*(var[i]))(stack)); + for (size_t i = 0; i < var.size( ); i++) u_hh[i].first->newVh( ); // get FESpace, FESpace3, ... + // compression pour les cas vectoriel + int kkk = 0; + for (int i = 0; i < Nbcomp2; i++) { + if (u_hh[i].second == 0) + kkk++; + else { + throwassert(u_hh[i].second == (u_hh[i - 1].second + 1)); + } // verification que les composantes des vectorial FESpace sont dans le bon ordre + which_uh[i] = kkk - 1; // set the numero of the FESpace + which_comp[i] = u_hh[i].second; // set the component of the FESpace (=0 for scalar FESpace by definition) + } - // if(verbosity>3) cout << " B min " << B->min() << " , max = " << B->max() << endl; - if( save.length() ) - { - string savem=save+".matrix"; - string saveb=save+".b"; - { - ofstream outmtx( savem.c_str()); - A.dump(outmtx) << endl; - } - { - ofstream outb(saveb.c_str()); - outb<< *B << endl; - } + vector< FEbase< R, v_fes > * > u_h(kkk); // the list of the true pointer to FEbase + kkk = 0; + for (int i = 0; i < Nbcomp2; i++) + if (u_hh[i].second == 0) u_h[kkk++] = u_hh[i].first; + const int Nb2 = kkk, Nb = Nb2 / 2; // nb of FESpace + throwassert(Nb2 == 2 * Nb); + + // const FESpace ** LL = new const FESpace *[var.size()]; + KN< const FESpace * > LL(var.size( )); // creation de la liste des FESpace" Nb2 <= var.size() " + for (int i = 0; i < Nb2; i++) LL[i] = (*(u_h[i])).newVh( ); + SHOWVERB(cout << "Problem " << Nb << endl); + + // const FESpace * Uhh , *Vhh; + // check we have same Th for each FESpace + const MeshT *pTh = &LL[0]->Th; + for (int i = 0; i < Nb2; i++) + if (&LL[i]->Th != pTh) ExecError("all the finite element spaces must be defined on the same mesh in solve"); + + if (pTh != data->pTh) { + // set value of the struct data + ds.initmat = true; + data->pTh = pTh; + if (Nb == 1) { // cas scalaire + data->Uh = LL[0]; + data->Vh = LL[1]; + } else { // cas vectoriel + // check that we have the same finconue space and ftest space + bool same = true; + for (int i = 0; i < Nb; i++) + if (LL[i] != LL[Nb + i]) { + same = false; + break; + } + if (!same) + InternalError("Methode de Galerkin (a faire)"); + else { + // check if we have only one FESpace + bool unique = true; + for (int i = 1; i < Nb; i++) + if (LL[0] != LL[i]) { + unique = false; + break; + } else if (LL[i]->FirstDfOfNodeData) // Correct jan 2015 not FE product this case + { + unique = false; + break; + } - } - if (verbosity>99) - { - cout << " X= " << *X << endl; - cout << " B= " << *B << endl; - } + if (unique) + data->Uh.master(new FESpace(*LL[0], Nb)); + else + data->Uh.master(new FESpace(LL, Nb)); + data->Vh = data->Uh; + } + } + } - if(ACadna) - { - KN XX(*X); - KN BB(*B); - ACadna->Solve(XX,BB); - *X=XX; - *cadna =-1.; + const FESpace &Uh(*data->Uh); + const FESpace &Vh(*data->Vh); + throwassert(Nbcomp == Uh.N && Nbcomp == Vh.N); + KN< R > *B = new KN< R >(Vh.NbOfDF); + KN< R > *X = B; // + const MeshT &Th(Uh.Th); + bool initx = true; // typemat->t==TypeSolveMat::GC ; // make x and b different in all case + // more safe for the future ( 4 days lose with is optimization FH ) -#ifdef HAVE_CADNA - R_st xxmin = XX.min(); - R_st xxmax = XX.max(); - cout << " cadna: min " << xxmin << "/ nd " << cestac(xxmin) - << " , max " << xxmax << " / nd " << cestac(xxmax) << endl ; - int nn= XX.N(); - if ( cadna->N() == nn ) - for (int i=0;i set sol = 0 !!!!!!! " << endl; - *X=R(); // erreur set the sol of zero ???? - DispatchSolution(Th,Nb,u_h,X,B,LL,Uh); - throw ; + if (&Uh == &Vh) + dataA.master(new MatriceMorse< R >(Vh.NbOfDF, Vh.NbOfDF, sym)); + else + dataA.master(new MatriceMorse< R >(Vh.NbOfDF, Uh.NbOfDF, false)); } - DispatchSolution(Th,Nb,u_h,X,B,LL,Uh); + MatriceCreuse< R > &AA(dataA); + if (verbosity > 1) cout << " -- size of Matrix " << AA.size( ) << " Bytes" << /* " skyline =" <profile <<*/ endl; + } + MatriceCreuse< R > &A(dataA); + if (AssembleVarForm(stack, Th, Uh, Vh, sym, ds.initmat ? &A : 0, B, op->largs)) { + *B = -*B; + // hach FH + for (int i = 0, n = B->N( ); i < n; i++) + if (abs((*B)[i]) < 1.e-60) (*B)[i] = 0; + AssembleBC< R, MeshT, FESpace, FESpace >(stack, Th, Uh, Vh, sym, ds.initmat ? &A : 0, B, initx ? X : 0, op->largs, ds.tgv); // TODO with problem + } else + *B = -*B; - if (verbosity) - {cout << " -- Solve : \n" ; - for (int i=0;ix()->min() << " max " << (u_h[i])->x()->max() << endl ; - } + dynamic_cast< HashMatrix< int, R > * >(&A)->half = ds.sym; - // delete [] LL; - // if (save) delete save; // clean memory - *mps=mp; - return SetAny(this); -} + MatriceCreuse< R_st > *ACadna = 0; -/** - * @brief Function to transform a list of FEbase into information of a composite FESpace - * input - * @param u_h vector of pointer to an FEbase element. - * @param type_varFE type of FESpace of the FEbase - * @param first_component of the FEbase corresponding to the composite FESpace - * @param size_component number of FEbase corresponding to the composite FESpace - * output - * @param LLUh vector of pointer of the FESpace of the composite FESpace Uh - * @param typeUh vector of the type of FESpace: FESpace, FESpace3, FESpaceS and FESpaceL. - * @param sizeUh vector of NbOfDF of each FESpace of the composite FESpace Uh - * @param offsetUh offset of each FESpace in the vector of all dof of the composite FESpace Uh - * @param UhNbItem vector of the number of item of each FESpace - */ - -void FEbaseToCompositeFESpaceInfo(const int &first_component,const int & size_component, const vector &u_h, const vector &type_varFE, - vector &typeUh, vector &sizeUh, vector & offsetUh, - vector &UhNbItem,vector &pfesUh){ - - ffassert( (size_component == sizeUh.size()) ); - ffassert( (size_component+1 == offsetUh.size()) ); - ffassert( (size_component == pfesUh.size())); - - int kkk = 0; - int min_i = first_component; - int max_i = min_i+size_component; - - for (int i=min_i; i * tyty = (FEbase *) u_h[i]; - FESpace * tmpVarToUpdateUh = tyty->newVh(); // get FESpace and update FESpace - sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; - UhNbItem[kkk] = tmpVarToUpdateUh->N; - typeUh[kkk] = type_varFE[i]; - pfesUh[kkk] = (pfes) *(tyty->pVh); - } - else if( type_varFE[i]== 3){ - FEbase * tyty = (FEbase *) u_h[i]; - FESpace3 *tmpVarToUpdateUh = tyty->newVh(); // get FESpace3 and update FESpace3 - sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; - UhNbItem[kkk] = tmpVarToUpdateUh->N; - typeUh[kkk] = type_varFE[i]; - pfesUh[kkk] = (pfes3) *(tyty->pVh); - } - else if( type_varFE[i]== 4){ - FEbase * tyty = (FEbase *) u_h[i]; - FESpaceS *tmpVarToUpdateUh = tyty->newVh(); // get FESpaceS and update FESpaceS - sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; - UhNbItem[kkk] = tmpVarToUpdateUh->N; - typeUh[kkk] = type_varFE[i]; - pfesUh[kkk] = (pfesS) *(tyty->pVh); - } - else if( type_varFE[i]== 5){ - FEbase * tyty = (FEbase *) u_h[i]; - FESpaceL *tmpVarToUpdateUh = tyty->newVh(); // get FESpaceL and update FESpaceL - sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; - UhNbItem[kkk] = tmpVarToUpdateUh->N; - typeUh[kkk] = type_varFE[i]; - pfesUh[kkk] = (pfesL) *(tyty->pVh); - } - else{ - cerr << "error in the type of FESpace" < & largs ,bool complextype); + try { -template // TODO if coupling FE with problem -AnyType Problem::evalComposite(Stack stack, DataComposite * data, CountPointer > & dataA ) const -{ - // - // Hypothesis: we have a square problem (Uh == Vh). - // + if (ds.initmat) { + // if(cadna) + // ACadna = DefSolverCadna( stack,A, ds); + // else + DefSolver(stack, A, ds); + } - using namespace Fem2D; - /* - typedef typename CadnaType::Scalaire R_st; - */ - MeshPoint *mps= MeshPointStack(stack),mp=*mps; - Data_Sparse_Solver ds; - /// long NbSpace = 50; - // long itmax=0; - // double epsilon=1e-6; - string save; - - KN* cadna=0; - - if (nargs[0]) save = *GetAny((*nargs[0])(stack)); - if (nargs[1]) cadna= GetAny* >((*nargs[1])(stack)); - - int np_bem = n_name_param; - int np = np_bem - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver(stack,ds,nargs,np); - if(verbosity>3 && mpirank==0) cout << " After reads :: ds.initmat=" << ds.initmat << endl; - if(verbosity>3 && mpirank==0) cout << " After reads :: ds.master=" << ds.master << endl; - - // for the gestion of the PTR. - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH aout 2007 - - bool sym = ds.sym; - if( verbosity>3 && mpirank==0) cout << "sym=" << ds.sym << endl; - - //list::const_iterator ii,ib=op->largs.begin(), ie=op->largs.end(); // delete unused variable - int Nbcomp2=var.size(),Nbcomp=Nbcomp2/2; // nb de composante - throwassert(Nbcomp2==2*Nbcomp); - KN which_comp(Nbcomp2),which_uh(Nbcomp2); - - //TabFuncArg tabexp(stack,Nbcomp); // delete unused variable - typedef pair< void *,int> pfer; - vector< pair< void *,int> > u_hh(Nbcomp2); - // u_hh.first --> FEbase * - // u_hh.second --> numero de la composante dans le cas d'un vectorial FESpace (ex: pfes*_tefk) - - for (size_t i=0;i( (*(var[i]))(stack)); - - // compression pour les cas vectoriel - int kkk=0; - for (int i=0;i0 ){ - // verifies that we have all component of a given FESpace - if( which_comp[i-1] >0){ - // check if the vectorial FESpace have exactly the good dimension - if( type_var[i-1]== 2){ - FEbase * tyty = (FEbase *) u_hh[i-1].first; - ffassert( (tyty->newVh()->N == u_hh[i-1].second+1) ); - } - else if( type_var[i-1]== 3){ - FEbase * tyty = (FEbase *) u_hh[i-1].first; - ffassert( (tyty->newVh()->N == u_hh[i-1].second+1) ); - } - else if( type_var[i-1]== 4){ - FEbase * tyty = (FEbase *) u_hh[i-1].first; - ffassert( (tyty->newVh()->N == u_hh[i-1].second+1) ); - } - else if( type_var[i-1]== 5){ - FEbase * tyty = (FEbase *) u_hh[i-1].first; - ffassert( (tyty->newVh()->N == u_hh[i-1].second+1) ); - } - else{ - //cerr << "type_var["< u_h(kkk); // the list of the true pointer to FEbase - vector< int > type_varFE(kkk); // the list of the true type var - kkk= 0; - for (int i=0;i pfesUh(Nb); - vector< int > typeUh(Nb); - vector< long > sizeUh(Nb); - vector< long > offsetUh(Nb+1,(long)0); - vector< int> UhNbItem(Nb); - - int first_component= 0; - int size_component = Nb; - FEbaseToCompositeFESpaceInfo(first_component, size_component, u_h, type_varFE, typeUh, sizeUh, offsetUh, UhNbItem,pfesUh); - - vector< generic_v_fes * > pfesVh(Nb); - vector< int > typeVh(Nb); - vector< long > sizeVh(Nb); - vector< long > offsetVh(Nb+1,(long)0); - vector< int> VhNbItem(Nb); - - first_component= Nb; - size_component = Nb; - FEbaseToCompositeFESpaceInfo(first_component, size_component, u_h, type_varFE, typeVh, sizeVh, offsetVh, VhNbItem, pfesVh); - - // check if we have the same FESpace for inconnue and test. - bool sameCompositeFESpace; - { - // If is not true, problem in the use of AssembleBC (Morice)) - bool same=true; - for (int i=0;i3) cout << " B min " << B->min() << " , max = " << B->max() << endl; + if (save.length( )) { + string savem = save + ".matrix"; + string saveb = save + ".b"; + { + ofstream outmtx(savem.c_str( )); + A.dump(outmtx) << endl; + } + { + ofstream outb(saveb.c_str( )); + outb << *B << endl; + } + } + if (verbosity > 99) { + cout << " X= " << *X << endl; + cout << " B= " << *B << endl; } - - SHOWVERB(cout << "Problem " << Nb << endl); - - int NpUh = (int) UhNbItem.size(); - int NpVh = (int) VhNbItem.size(); - ffassert(Nb == NpUh); - ffassert(Nb == NpVh); + if (ACadna) { + KN< R_st > XX(*X); + KN< R_st > BB(*B); + ACadna->Solve(XX, BB); + *X = XX; + *cadna = -1.; +#ifdef HAVE_CADNA + R_st xxmin = XX.min( ); + R_st xxmax = XX.max( ); + cout << " cadna: min " << xxmin << "/ nd " << cestac(xxmin) << " , max " << xxmax << " / nd " << cestac(xxmax) << endl; + int nn = XX.N( ); + if (cadna->N( ) == nn) + for (int i = 0; i < nn; ++i) (*cadna)[i] = cestac(XX[i]); + else + cerr << "Warning: Sorry array is incorrect size to store cestac " << nn << " != " << cadna->N( ) << endl; +#endif + } else - //cout << " avant test :: ds.initmat=" << ds.initmat << endl; + A.Solve(*X, *B); - // recuperation de la taille des FESpaces - // construction of the data composite structure - // initialisation des vecteurs de data->pThU - if( !data->pThU ){ - data->pThU = new vector(NpUh); - //data->pThU->resize(NpUh); - for(int i=0; ipThU)[i]=nullptr; } - ds.initmat=true; + if (verbosity > 99) { + cout << " X= " << *X << endl; } + } catch (...) { + if (verbosity) cout << " catch an erreur in solve => set sol = 0 !!!!!!! " << endl; + *X = R( ); // erreur set the sol of zero ???? + DispatchSolution< R, FESpace, v_fes >(Th, Nb, u_h, X, B, LL, Uh); + throw; + } + DispatchSolution< R, FESpace, v_fes >(Th, Nb, u_h, X, B, LL, Uh); - for(int i=0; igetpVh(); - if ( &(fes->Th) != (Mesh*) (*data->pThU)[i] ){ ds.initmat=true; (*data->pThU)[i]=(void*) &fes->Th; } - } - else if(typeUh[i]== 3){ - FESpace3 * fes = (FESpace3 *) pfesUh[i]->getpVh(); - if ( &(fes->Th) != (Mesh3*) (*data->pThU)[i] ){ ds.initmat=true; (*data->pThU)[i]=(void*) &fes->Th; } - } - else if(typeUh[i]== 4){ - FESpaceS * fes = (FESpaceS *) pfesUh[i]->getpVh(); - if ( &(fes->Th) != (MeshS*) (*data->pThU)[i] ){ ds.initmat=true; (*data->pThU)[i]=(void*) &fes->Th; } - } - else if(typeUh[i]== 5){ - FESpaceL * fes = (FESpaceL *) pfesUh[i]->getpVh(); - if ( &(fes->Th) != (MeshL*) (*data->pThU)[i] ){ ds.initmat=true; (*data->pThU)[i]=(void*) &fes->Th; } - - } - else{ - cerr<< "error in the type of FESpace." << endl; - ffassert(0); + if (verbosity) { + cout << " -- Solve : \n"; + for (int i = 0; i < Nb; i++) cout << " min " << (u_h[i])->x( )->min( ) << " max " << (u_h[i])->x( )->max( ) << endl; + } - } - } + // delete [] LL; + // if (save) delete save; // clean memory + *mps = mp; + return SetAny< const Problem * >(this); +} + +/** + * @brief Function to transform a list of FEbase into information of a composite FESpace + * input + * @param u_h vector of pointer to an FEbase element. + * @param type_varFE type of FESpace of the FEbase + * @param first_component of the FEbase corresponding to the composite FESpace + * @param size_component number of FEbase corresponding to the composite FESpace + * output + * @param LLUh vector of pointer of the FESpace of the composite FESpace Uh + * @param typeUh vector of the type of FESpace: FESpace, FESpace3, FESpaceS and FESpaceL. + * @param sizeUh vector of NbOfDF of each FESpace of the composite FESpace Uh + * @param offsetUh offset of each FESpace in the vector of all dof of the composite FESpace Uh + * @param UhNbItem vector of the number of item of each FESpace + */ - // initialisation des vecteurs de data->pThV - if( !data->pThV ){ - data->pThV = new vector(NpVh); - for(int i=0; ipThV)[i]=nullptr; } - ds.initmat=true; +void FEbaseToCompositeFESpaceInfo(const int &first_component, const int &size_component, const vector< void * > &u_h, const vector< int > &type_varFE, vector< int > &typeUh, vector< long > &sizeUh, + vector< long > &offsetUh, vector< int > &UhNbItem, vector< generic_v_fes * > &pfesUh) { + + ffassert((size_component == sizeUh.size( ))); + ffassert((size_component + 1 == offsetUh.size( ))); + ffassert((size_component == pfesUh.size( ))); + + int kkk = 0; + int min_i = first_component; + int max_i = min_i + size_component; + + for (int i = min_i; i < max_i; i++) { + if (type_varFE[i] == 2) { + FEbase< R, v_fes > *tyty = (FEbase< R, v_fes > *)u_h[i]; + FESpace *tmpVarToUpdateUh = tyty->newVh( ); // get FESpace and update FESpace + sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; + UhNbItem[kkk] = tmpVarToUpdateUh->N; + typeUh[kkk] = type_varFE[i]; + pfesUh[kkk] = (pfes) * (tyty->pVh); + } else if (type_varFE[i] == 3) { + FEbase< R, v_fes3 > *tyty = (FEbase< R, v_fes3 > *)u_h[i]; + FESpace3 *tmpVarToUpdateUh = tyty->newVh( ); // get FESpace3 and update FESpace3 + sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; + UhNbItem[kkk] = tmpVarToUpdateUh->N; + typeUh[kkk] = type_varFE[i]; + pfesUh[kkk] = (pfes3) * (tyty->pVh); + } else if (type_varFE[i] == 4) { + FEbase< R, v_fesS > *tyty = (FEbase< R, v_fesS > *)u_h[i]; + FESpaceS *tmpVarToUpdateUh = tyty->newVh( ); // get FESpaceS and update FESpaceS + sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; + UhNbItem[kkk] = tmpVarToUpdateUh->N; + typeUh[kkk] = type_varFE[i]; + pfesUh[kkk] = (pfesS) * (tyty->pVh); + } else if (type_varFE[i] == 5) { + FEbase< R, v_fesL > *tyty = (FEbase< R, v_fesL > *)u_h[i]; + FESpaceL *tmpVarToUpdateUh = tyty->newVh( ); // get FESpaceL and update FESpaceL + sizeUh[kkk] = tmpVarToUpdateUh->NbOfDF; + UhNbItem[kkk] = tmpVarToUpdateUh->N; + typeUh[kkk] = type_varFE[i]; + pfesUh[kkk] = (pfesL) * (tyty->pVh); + } else { + cerr << "error in the type of FESpace" << endl; + ffassert(0); } + kkk++; + } - // ??? A voir comment faire ??? - for(int i=0; igetpVh(); - if ( &(fes->Th) != (Mesh*) (*data->pThV)[i] ){ ds.initmat=true; (*data->pThV)[i]=(void*) &(fes->Th); } - } - else if( typeVh[i]== 3){ - FESpace3 * fes = (FESpace3 *) pfesVh[i]->getpVh(); - if ( &(fes->Th) != (Mesh3*) (*data->pThV)[i] ){ ds.initmat=true; (*data->pThV)[i]=(void*) &(fes->Th); } - } - else if( typeVh[i]== 4){ - FESpaceS * fes = (FESpaceS *) pfesVh[i]->getpVh(); - if ( &(fes->Th) != (MeshS*) (*data->pThV)[i] ){ ds.initmat=true; (*data->pThV)[i]=(void*) &(fes->Th); } - } - else if( typeVh[i]== 5){ - FESpaceL *fes = (FESpaceL *) pfesVh[i]->getpVh(); - if ( &(fes->Th) != (MeshL*) (*data->pThV)[i] ){ ds.initmat=true; (*data->pThV)[i]=(void*) &(fes->Th); } - } - else{ - cerr<< "error in the type of FESpace. type="<< typeVh[i] << endl; + // computation of offset + offsetUh[0] = 0; + for (int i = 0; i < size_component; i++) { + offsetUh[i + 1] = offsetUh[i] + sizeUh[i]; + } +} +bool FieldOfForm(list< C_F0 > &largs, bool complextype); + +template< class R > // TODO if coupling FE with problem +AnyType Problem::evalComposite(Stack stack, DataComposite *data, CountPointer< MatriceCreuse< R > > &dataA) const { + // + // Hypothesis: we have a square problem (Uh == Vh). + // + + using namespace Fem2D; + /* + typedef typename CadnaType::Scalaire R_st; + */ + MeshPoint *mps = MeshPointStack(stack), mp = *mps; + Data_Sparse_Solver ds; + /// long NbSpace = 50; + // long itmax=0; + // double epsilon=1e-6; + string save; + + KN< double > *cadna = 0; + + if (nargs[0]) save = *GetAny< string * >((*nargs[0])(stack)); + if (nargs[1]) cadna = GetAny< KN< double > * >((*nargs[1])(stack)); + + int np_bem = n_name_param; + int np = np_bem - NB_NAME_PARM_HMAT; + SetEnd_Data_Sparse_Solver< R >(stack, ds, nargs, np); + if (verbosity > 3 && mpirank == 0) cout << " After reads :: ds.initmat=" << ds.initmat << endl; + if (verbosity > 3 && mpirank == 0) cout << " After reads :: ds.master=" << ds.master << endl; + + // for the gestion of the PTR. + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH aout 2007 + + bool sym = ds.sym; + if (verbosity > 3 && mpirank == 0) cout << "sym=" << ds.sym << endl; + + // list::const_iterator ii,ib=op->largs.begin(), ie=op->largs.end(); // delete unused variable + int Nbcomp2 = var.size( ), Nbcomp = Nbcomp2 / 2; // nb de composante + throwassert(Nbcomp2 == 2 * Nbcomp); + KN< int > which_comp(Nbcomp2), which_uh(Nbcomp2); + + // TabFuncArg tabexp(stack,Nbcomp); // delete unused variable + typedef pair< void *, int > pfer; + vector< pair< void *, int > > u_hh(Nbcomp2); + // u_hh.first --> FEbase * + // u_hh.second --> numero de la composante dans le cas d'un vectorial FESpace (ex: pfes*_tefk) + + for (size_t i = 0; i < var.size( ); i++) u_hh[i] = GetAny< pfer >((*(var[i]))(stack)); + + // compression pour les cas vectoriel + int kkk = 0; + for (int i = 0; i < Nbcomp2; i++) { + if (u_hh[i].second == 0) { + kkk++; + + if (i > 0) { + // verifies that we have all component of a given FESpace + if (which_comp[i - 1] > 0) { + // check if the vectorial FESpace have exactly the good dimension + if (type_var[i - 1] == 2) { + FEbase< R, v_fes > *tyty = (FEbase< R, v_fes > *)u_hh[i - 1].first; + ffassert((tyty->newVh( )->N == u_hh[i - 1].second + 1)); + } else if (type_var[i - 1] == 3) { + FEbase< R, v_fes3 > *tyty = (FEbase< R, v_fes3 > *)u_hh[i - 1].first; + ffassert((tyty->newVh( )->N == u_hh[i - 1].second + 1)); + } else if (type_var[i - 1] == 4) { + FEbase< R, v_fesS > *tyty = (FEbase< R, v_fesS > *)u_hh[i - 1].first; + ffassert((tyty->newVh( )->N == u_hh[i - 1].second + 1)); + } else if (type_var[i - 1] == 5) { + FEbase< R, v_fesL > *tyty = (FEbase< R, v_fesL > *)u_hh[i - 1].first; + ffassert((tyty->newVh( )->N == u_hh[i - 1].second + 1)); + } else { + // cerr << "type_var["< u_h(kkk); // the list of the true pointer to FEbase + vector< int > type_varFE(kkk); // the list of the true type var + kkk = 0; + for (int i = 0; i < Nbcomp2; i++) + if (u_hh[i].second == 0) { + u_h[kkk] = u_hh[i].first; + type_varFE[kkk++] = type_var[i]; + } + const int Nb2 = kkk, Nb = Nb2 / 2; // nb of FESpace + throwassert(Nb2 == 2 * Nb); + + // creation of inconnue FESpace and test FESpace + + vector< generic_v_fes * > pfesUh(Nb); + vector< int > typeUh(Nb); + vector< long > sizeUh(Nb); + vector< long > offsetUh(Nb + 1, (long)0); + vector< int > UhNbItem(Nb); + + int first_component = 0; + int size_component = Nb; + FEbaseToCompositeFESpaceInfo(first_component, size_component, u_h, type_varFE, typeUh, sizeUh, offsetUh, UhNbItem, pfesUh); + + vector< generic_v_fes * > pfesVh(Nb); + vector< int > typeVh(Nb); + vector< long > sizeVh(Nb); + vector< long > offsetVh(Nb + 1, (long)0); + vector< int > VhNbItem(Nb); + + first_component = Nb; + size_component = Nb; + FEbaseToCompositeFESpaceInfo(first_component, size_component, u_h, type_varFE, typeVh, sizeVh, offsetVh, VhNbItem, pfesVh); + + // check if we have the same FESpace for inconnue and test. + bool sameCompositeFESpace; + { + // If is not true, problem in the use of AssembleBC (Morice)) + bool same = true; + for (int i = 0; i < Nb; i++) + if (pfesUh[i] != pfesVh[i]) { + same = false; + break; + } + if (!same) InternalError("Methode de Galerkin (a faire)"); + sameCompositeFESpace = same; + } - KN *B=new KN(offsetUh[NpUh]); // hypothese system carre - KN *X=B; // + SHOWVERB(cout << "Problem " << Nb << endl); - *B=R(0); - InitCompositeProblem( typeUh, offsetUh, pfesUh, u_h, X, B, initx); + int NpUh = (int)UhNbItem.size( ); + int NpVh = (int)VhNbItem.size( ); - // =================================================================== - // Appel de la fonction pour la construction de la matrice générique - // + ffassert(Nb == NpUh); + ffassert(Nb == NpVh); - if(verbosity>2) cout << " Problem(): initmat " << ds.initmat << " VF (discontinuous Galerkin) = " << VF << endl; - + // cout << " avant test :: ds.initmat=" << ds.initmat << endl; - // Dans le cas composite, j'ai besoin des << vec_generic_v_fes >> et "largs" + Call_FormBilinear - if (ds.initmat) - { - { - if ( sameCompositeFESpace ) - dataA.master(new MatriceMorse( offsetVh[NpVh], offsetUh[NpUh], sym)); - else - dataA.master(new MatriceMorse( offsetVh[NpVh], offsetUh[NpUh], false)); - } - MatriceCreuse & AA(dataA); - if(verbosity>1) cout << " -- size of Matrix " << AA.size()<< " Bytes" << endl; - } // fin ds.initmat - - MatriceCreuse & A(dataA); // A is the global matrix - HashMatrix * hm_A = dynamic_cast *>( &A ); - - if(verbosity>2) cout << "=== hm_A.nnz ==============:::" << hm_A->nnz << endl; - - int maxJVh=NpVh; - int offsetMatrixUh = 0; - for( int i=0; i2) cout << "i=" << i << ",j=" << j << " mmm "<< "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; - - const list &b_largs = block_largs(i,j); - if(verbosity>2) cout << "size_block =" << b_largs.size() << endl; - if( b_largs.size()> 0){ - list largs_FEM; - list largs_BEM; - largs_FEM.clear(); - largs_BEM.clear(); - separateFEMpartBemPart( b_largs, largs_FEM, largs_BEM ); - - if(verbosity>2){ - cout << " FEM.size()=" << largs_FEM.size() << endl; - cout << " BEM.size()=" << largs_BEM.size() << endl; - } - if( largs_FEM.size() >0 ){ - // computation of the matrix - const list & b_largs_zz = largs_FEM; - - // Assemblage // inside - varfToCompositeBlockLinearSystemALLCASE_pfes( i, j, typeUh[i], typeVh[j], - offsetUh[i], offsetVh[j], pfesUh[i], pfesVh[j], - ds.initmat, initx, sym, ds.tgv, ds.commworld, - b_largs_zz, stack, - B, X, hm_A); - //deleteNewLargs(largs_FEM); - } + // recuperation de la taille des FESpaces + // construction of the data composite structure + // initialisation des vecteurs de data->pThU + if (!data->pThU) { + data->pThU = new vector< void * >(NpUh); + // data->pThU->resize(NpUh); + for (int i = 0; i < NpUh; i++) { + (*data->pThU)[i] = nullptr; + } + ds.initmat = true; + } - if( largs_BEM.size() >0 ){ - // computation of the matrix - // Assemblage // - varfBemToCompositeBlockLinearSystem( i, j, typeUh[i], typeVh[j], sizeUh[i], sizeVh[j], - offsetUh[i], offsetVh[j], pfesUh[i], pfesVh[j], - largs_BEM, stack, nargs, hm_A,np_bem); - //deleteNewLargs(largs_BEM); - } + for (int i = 0; i < NpUh; i++) { + // if one mesh have changed, we recompute all the matrix + if (typeUh[i] == 2) { + FESpace *fes = (FESpace *)pfesUh[i]->getpVh( ); + if (&(fes->Th) != (Mesh *)(*data->pThU)[i]) { + ds.initmat = true; + (*data->pThU)[i] = (void *)&fes->Th; + } + } else if (typeUh[i] == 3) { + FESpace3 *fes = (FESpace3 *)pfesUh[i]->getpVh( ); + if (&(fes->Th) != (Mesh3 *)(*data->pThU)[i]) { + ds.initmat = true; + (*data->pThU)[i] = (void *)&fes->Th; + } + } else if (typeUh[i] == 4) { + FESpaceS *fes = (FESpaceS *)pfesUh[i]->getpVh( ); + if (&(fes->Th) != (MeshS *)(*data->pThU)[i]) { + ds.initmat = true; + (*data->pThU)[i] = (void *)&fes->Th; + } + } else if (typeUh[i] == 5) { + FESpaceL *fes = (FESpaceL *)pfesUh[i]->getpVh( ); + if (&(fes->Th) != (MeshL *)(*data->pThU)[i]) { + ds.initmat = true; + (*data->pThU)[i] = (void *)&fes->Th; + } - if(mpirank ==0 && verbosity >2) cout << "Add block (" << i << "," << j <<")=> size nnz=" << hm_A->nnz << endl; - //largs_FEM.clear(); - //largs_BEM.clear(); - } - } + } else { + cerr << "error in the type of FESpace." << endl; + ffassert(0); } + } + // initialisation des vecteurs de data->pThV + if (!data->pThV) { + data->pThV = new vector< void * >(NpVh); + for (int i = 0; i < NpVh; i++) { + (*data->pThV)[i] = nullptr; + } + ds.initmat = true; + } - dynamic_cast *>(&A)->half = ds.sym; - - // Resolution du systeme + // ??? A voir comment faire ??? + for (int i = 0; i < NpVh; i++) { + // if one mesh have changed, we recompute all the matrix + if (typeVh[i] == 2) { + FESpace *fes = (FESpace *)pfesVh[i]->getpVh( ); + if (&(fes->Th) != (Mesh *)(*data->pThV)[i]) { + ds.initmat = true; + (*data->pThV)[i] = (void *)&(fes->Th); + } + } else if (typeVh[i] == 3) { + FESpace3 *fes = (FESpace3 *)pfesVh[i]->getpVh( ); + if (&(fes->Th) != (Mesh3 *)(*data->pThV)[i]) { + ds.initmat = true; + (*data->pThV)[i] = (void *)&(fes->Th); + } + } else if (typeVh[i] == 4) { + FESpaceS *fes = (FESpaceS *)pfesVh[i]->getpVh( ); + if (&(fes->Th) != (MeshS *)(*data->pThV)[i]) { + ds.initmat = true; + (*data->pThV)[i] = (void *)&(fes->Th); + } + } else if (typeVh[i] == 5) { + FESpaceL *fes = (FESpaceL *)pfesVh[i]->getpVh( ); + if (&(fes->Th) != (MeshL *)(*data->pThV)[i]) { + ds.initmat = true; + (*data->pThV)[i] = (void *)&(fes->Th); + } + } else { + cerr << "error in the type of FESpace. type=" << typeVh[i] << endl; + ffassert(0); + } + } - try { + // ***************************************************************************************** + // On a besoin ici que des les FESpace de Uh + long VhNbOfDF = offsetVh[NpVh]; + bool initx = true; // make x and b different in all case + // more safe for the future ( 4 days lose with is optimization FH ) - if (ds.initmat) - { - if(verbosity >3) cout << " DefSolver(stack, A, ds)::::::::: ds.initmat=" << ds.initmat << endl; - // if(cadna) - // ACadna = DefSolverCadna( stack,A, ds); - // else - DefSolver(stack, A, ds); - } + KN< R > *B = new KN< R >(offsetUh[NpUh]); // hypothese system carre + KN< R > *X = B; // - // if(verbosity>3) cout << " B min " << B->min() << " , max = " << B->max() << endl; - if( save.length() ) - { - string savem=save+".matrix"; - string saveb=save+".b"; - { - ofstream outmtx( savem.c_str()); - A.dump(outmtx) << endl; - } - { - ofstream outb(saveb.c_str()); - outb<< *B << endl; - } + *B = R(0); + InitCompositeProblem< R >(typeUh, offsetUh, pfesUh, u_h, X, B, initx); - } - if (verbosity>99) - { - cout << " X= " << *X << endl; - cout << " B= " << *B << endl; - } - if(verbosity>3){ - if(mpirank==0){ - for(int ii=0; ii<10; ii++){ - cout << "before solve :: pb (*B)["<< ii <<"]=" << (*B)[ii] << endl; - } - } - } - A.Solve(*X,*B); // version sans CADNA - if (verbosity>99) - { - cout << " X= " << *X << endl; - } - }// fin try - catch (...) - { - if(verbosity) cout << " catch an erreur in solve => set sol = 0 !!!!!!! " << endl; - *X=R(); // erreur set the sol of zero ???? - DispatchSolution( typeUh, offsetUh, pfesUh, u_h, X, B); - throw ; - } + // =================================================================== + // Appel de la fonction pour la construction de la matrice générique + // - // Dispatch solution - DispatchSolution( typeUh, offsetUh, pfesUh, u_h, X, B); + if (verbosity > 2) cout << " Problem(): initmat " << ds.initmat << " VF (discontinuous Galerkin) = " << VF << endl; - if (verbosity) - {cout << " -- Solve : \n" ; - for (int i=0;i * u_h_loc = (FEbase *) u_h[i]; - cout << " min " << (u_h_loc)->x()->min() << " max " << (u_h_loc)->x()->max() << endl ; - } - else if( typeUh[i] == 3){ - FEbase * u_h_loc = (FEbase *) u_h[i]; - cout << " min " << (u_h_loc)->x()->min() << " max " << (u_h_loc)->x()->max() << endl ; - } - else if( typeUh[i] == 4){ - FEbase * u_h_loc = (FEbase *) u_h[i]; - cout << " min " << (u_h_loc)->x()->min() << " max " << (u_h_loc)->x()->max() << endl ; - } - else if( typeUh[i] == 5){ - FEbase * u_h_loc = (FEbase *) u_h[i]; - cout << " min " << (u_h_loc)->x()->min() << " max " << (u_h_loc)->x()->max() << endl ; - } - else{ - cerr << "Error in the type of FESpace" << endl; - ffassert(0); - } - } - } - for(int i=0; i> et "largs" + Call_FormBilinear + if (ds.initmat) { + { + if (sameCompositeFESpace) + dataA.master(new MatriceMorse< R >(offsetVh[NpVh], offsetUh[NpUh], sym)); + else + dataA.master(new MatriceMorse< R >(offsetVh[NpVh], offsetUh[NpUh], false)); + } + MatriceCreuse< R > &AA(dataA); + if (verbosity > 1) cout << " -- size of Matrix " << AA.size( ) << " Bytes" << endl; + } // fin ds.initmat + + MatriceCreuse< R > &A(dataA); // A is the global matrix + HashMatrix< int, R > *hm_A = dynamic_cast< HashMatrix< int, R > * >(&A); + + if (verbosity > 2) cout << "=== hm_A.nnz ==============:::" << hm_A->nnz << endl; + + int maxJVh = NpVh; + int offsetMatrixUh = 0; + for (int i = 0; i < NpUh; i++) { + int offsetMatrixVh = 0; + if (sym) { + maxJVh = (i + 1); + ffassert(maxJVh < NpVh); + } + for (int j = 0; j < maxJVh; j++) { + if (verbosity > 2) cout << "i=" << i << ",j=" << j << " mmm " << "offsetMatrixUh= " << offsetMatrixUh << ", offsetMatrixVh= " << offsetMatrixVh << endl; + + const list< C_F0 > &b_largs = block_largs(i, j); + if (verbosity > 2) cout << "size_block =" << b_largs.size( ) << endl; + if (b_largs.size( ) > 0) { + list< C_F0 > largs_FEM; + list< C_F0 > largs_BEM; + largs_FEM.clear( ); + largs_BEM.clear( ); + separateFEMpartBemPart(b_largs, largs_FEM, largs_BEM); + + if (verbosity > 2) { + cout << " FEM.size()=" << largs_FEM.size( ) << endl; + cout << " BEM.size()=" << largs_BEM.size( ) << endl; + } + if (largs_FEM.size( ) > 0) { + // computation of the matrix + const list< C_F0 > &b_largs_zz = largs_FEM; + + // Assemblage // inside + varfToCompositeBlockLinearSystemALLCASE_pfes< R >(i, j, typeUh[i], typeVh[j], offsetUh[i], offsetVh[j], pfesUh[i], pfesVh[j], ds.initmat, initx, sym, ds.tgv, ds.commworld, b_largs_zz, stack, + B, X, hm_A); + // deleteNewLargs(largs_FEM); + } + + if (largs_BEM.size( ) > 0) { + // computation of the matrix + // Assemblage // + varfBemToCompositeBlockLinearSystem(i, j, typeUh[i], typeVh[j], sizeUh[i], sizeVh[j], offsetUh[i], offsetVh[j], pfesUh[i], pfesVh[j], largs_BEM, stack, nargs, hm_A, np_bem); + // deleteNewLargs(largs_BEM); + } + + if (mpirank == 0 && verbosity > 2) cout << "Add block (" << i << "," << j << ")=> size nnz=" << hm_A->nnz << endl; + // largs_FEM.clear(); + // largs_BEM.clear(); + } } - // if (save) delete save; // clean memory - *mps=mp; - - delete X; - delete cadna; + } - return SetAny(this); -} + dynamic_cast< HashMatrix< int, R > * >(&A)->half = ds.sym; + // Resolution du systeme -bool isCompositeProblem(const ListOfId &l){ - // function to check a composite problem with chevron < > - int nb=l.size(); + try { - int nbcompo_begin = 0; - int nbcompo_end = 0; - for (int i=0;i 3) cout << " DefSolver(stack, A, ds)::::::::: ds.initmat=" << ds.initmat << endl; + // if(cadna) + // ACadna = DefSolverCadna( stack,A, ds); + // else + DefSolver(stack, A, ds); } - if( nbcompo_begin != nbcompo_end && (nbcompo_begin == 0 || nbcompo_begin == 2) ){ - cerr << "Try to use composite FESpace for a form "<< endl; - cerr << " Nb of symbol '<' is " << nbcompo_begin << endl; - cerr << " Nb of symbol '>' is " << nbcompo_end << endl; - CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); + // if(verbosity>3) cout << " B min " << B->min() << " , max = " << B->max() << endl; + if (save.length( )) { + string savem = save + ".matrix"; + string saveb = save + ".b"; + { + ofstream outmtx(savem.c_str( )); + A.dump(outmtx) << endl; + } + { + ofstream outb(saveb.c_str( )); + outb << *B << endl; + } } - - if( nbcompo_begin>0 ){ - return true; + if (verbosity > 99) { + cout << " X= " << *X << endl; + cout << " B= " << *B << endl; } - else{ - return false; + if (verbosity > 3) { + if (mpirank == 0) { + for (int ii = 0; ii < 10; ii++) { + cout << "before solve :: pb (*B)[" << ii << "]=" << (*B)[ii] << endl; + } + } + } + A.Solve(*X, *B); // version sans CADNA + if (verbosity > 99) { + cout << " X= " << *X << endl; + } + } // fin try + catch (...) { + if (verbosity) cout << " catch an erreur in solve => set sol = 0 !!!!!!! " << endl; + *X = R( ); // erreur set the sol of zero ???? + DispatchSolution< R >(typeUh, offsetUh, pfesUh, u_h, X, B); + throw; + } + + // Dispatch solution + DispatchSolution< R >(typeUh, offsetUh, pfesUh, u_h, X, B); + + if (verbosity) { + cout << " -- Solve : \n"; + for (int i = 0; i < Nb; i++) { + if (typeUh[i] == 2) { + FEbase< R, v_fes > *u_h_loc = (FEbase< R, v_fes > *)u_h[i]; + cout << " min " << (u_h_loc)->x( )->min( ) << " max " << (u_h_loc)->x( )->max( ) << endl; + } else if (typeUh[i] == 3) { + FEbase< R, v_fes3 > *u_h_loc = (FEbase< R, v_fes3 > *)u_h[i]; + cout << " min " << (u_h_loc)->x( )->min( ) << " max " << (u_h_loc)->x( )->max( ) << endl; + } else if (typeUh[i] == 4) { + FEbase< R, v_fesS > *u_h_loc = (FEbase< R, v_fesS > *)u_h[i]; + cout << " min " << (u_h_loc)->x( )->min( ) << " max " << (u_h_loc)->x( )->max( ) << endl; + } else if (typeUh[i] == 5) { + FEbase< R, v_fesL > *u_h_loc = (FEbase< R, v_fesL > *)u_h[i]; + cout << " min " << (u_h_loc)->x( )->min( ) << " max " << (u_h_loc)->x( )->max( ) << endl; + } else { + cerr << "Error in the type of FESpace" << endl; + ffassert(0); + } } + } + for (int i = 0; i < NpUh; i++) { + pfesUh[i] = nullptr; + } + for (int i = 0; i < NpVh; i++) { + pfesVh[i] = nullptr; + } + // if (save) delete save; // clean memory + *mps = mp; + delete X; + delete cadna; + + return SetAny< const Problem * >(this); } +bool isCompositeProblem(const ListOfId &l) { + // function to check a composite problem with chevron < > + int nb = l.size( ); + + int nbcompo_begin = 0; + int nbcompo_end = 0; + for (int i = 0; i < nb; i++) { + if (l[i].compo_begin == true) nbcompo_begin++; + if (l[i].compo_end == true) nbcompo_end++; + } + + if (nbcompo_begin != nbcompo_end && (nbcompo_begin == 0 || nbcompo_begin == 2)) { + cerr << "Try to use composite FESpace for a form " << endl; + cerr << " Nb of symbol '<' is " << nbcompo_begin << endl; + cerr << " Nb of symbol '>' is " << nbcompo_end << endl; + CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); + } + + if (nbcompo_begin > 0) { + return true; + } else { + return false; + } +} // read the arguments of problem ex: problem a(u,v) or a([u1,u2], [v1,v2]) // First Argument: samedim // If return true if all argument are in the same type of FESpace : pfes, pfes3, ... -// else return false +// else return false // Second Argument : complextype -// +// // Remark: This function check that all FEbase are complex or real; -std::pair< bool,bool> isSameDimAndComplexTypeProblem(const ListOfId &l){ - bool return_samedim=true; - bool complextype = false; - bool realtype = false; - int dim=0; - int nb=l.size();//,nbarray=0;//,n=0, - //const UnId *p1; - for(int i=0; i isSameDimAndComplexTypeProblem(const ListOfId &l) { + bool return_samedim = true; + bool complextype = false; + bool realtype = false; + int dim = 0; + int nb = l.size( ); //,nbarray=0;//,n=0, + // const UnId *p1; + for (int i = 0; i < nb; ++i) { + if (l[i].e == 0) // to miss name parameter solver=ddd { - if(l[i].e ==0)// to miss name parameter solver=ddd - { - if (l[i].array) - { - ListOfId * array=l[i].array; - for(int j=0; jsize(); ++j) - { - const UnId & idi( (*array)[j]); - if (idi.r == 0 && idi.re == 0 && idi.array==0 ) - { - C_F0 c=::Find( idi.id); - // mesh - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==2){ dim=2;} - else{ return_samedim = false; } - } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==2){ dim=2;} - else{ return_samedim = false; } - } - // mesh3 - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==3){ dim=3;} - else{ return_samedim = false; } - } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==3){ dim=3;} - else{ return_samedim = false; } - } - // meshS - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==4){ dim=4;} - else{ return_samedim = false; } - } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==4){ dim=4;} - else{ return_samedim = false; } - } - // meshL - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==5){ dim=5;} - else{ return_samedim = false; } - } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==5){ dim=5;} - else{ return_samedim = false; } - } - - } - } - - } - else - { - C_F0 c=::Find(l[i].id); + if (l[i].array) { + ListOfId *array = l[i].array; + for (int j = 0; j < array->size( ); ++j) { + const UnId &idi((*array)[j]); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + C_F0 c = ::Find(idi.id); // mesh - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==2){ dim=2;} - else{ return_samedim = false; } + if (BCastTo< pfec >(c)) { + complextype = true; + if (dim == 0 || dim == 2) { + dim = 2; + } else { + return_samedim = false; + } } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==2){ dim=2;} - else{ return_samedim = false; } + if (BCastTo< pfer >(c)) { + realtype = true; + if (dim == 0 || dim == 2) { + dim = 2; + } else { + return_samedim = false; + } } // mesh3 - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==3){ dim=3;} - else{ return_samedim = false; } + if (BCastTo< pf3c >(c)) { + complextype = true; + if (dim == 0 || dim == 3) { + dim = 3; + } else { + return_samedim = false; + } } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==3){ dim=3;} - else{ return_samedim = false; } + if (BCastTo< pf3r >(c)) { + realtype = true; + if (dim == 0 || dim == 3) { + dim = 3; + } else { + return_samedim = false; + } } // meshS - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==4){ dim=4;} - else{ return_samedim = false; } + if (BCastTo< pfSc >(c)) { + complextype = true; + if (dim == 0 || dim == 4) { + dim = 4; + } else { + return_samedim = false; + } } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==4){ dim=4;} - else{ return_samedim = false; } + if (BCastTo< pfSr >(c)) { + realtype = true; + if (dim == 0 || dim == 4) { + dim = 4; + } else { + return_samedim = false; + } } // meshL - if(BCastTo(c) ){ - complextype = true; - if(dim==0 || dim==5){ dim=5;} - else{ return_samedim = false; } + if (BCastTo< pfLc >(c)) { + complextype = true; + if (dim == 0 || dim == 5) { + dim = 5; + } else { + return_samedim = false; + } } - if(BCastTo(c) ){ - realtype = true; - if(dim==0 || dim==5){ dim=5;} - else{ return_samedim = false; } + if (BCastTo< pfLr >(c)) { + realtype = true; + if (dim == 0 || dim == 5) { + dim = 5; + } else { + return_samedim = false; + } } + } } - } - } - ffassert(dim); - if(verbosity>2) cout << "realtype= " << realtype << ", complextype=" << complextype << endl; - if( realtype == complextype ){ - if( realtype ){ - cerr << "In problem or solve, we used complex and real FESpace. This is not allowed in Freefem." << endl; - ffassert(0); - } - else{ - cerr << "In problem or solve, error in casting FEbase." << endl; - ffassert(0); - } - } - - return std::pair(return_samedim, complextype); -} - - -// dimProblem read the number of arguments of problem ex: problem a(u,v) or a([u1,u2], [v1,v2]) -int dimProblem(const ListOfId &l) -{ - int dim=0; - int nb=l.size();//,nbarray=0;//,n=0, - //const UnId *p1; - for(int i=0; isize(); ++j) - { - const UnId & idi( (*array)[j]); - if (idi.r == 0 && idi.re == 0 && idi.array==0 ) - { - C_F0 c=::Find( idi.id); - if(BCastTo(c) ) ffassert(dim==0 || dim==2),dim=2; - if(BCastTo(c) ) ffassert(dim==0 || dim==2),dim=2; - if(BCastTo(c) ) ffassert(dim==0 || dim==3),dim=3; - if(BCastTo(c) ) ffassert(dim==0 || dim==3),dim=3; - if(BCastTo(c) ) ffassert(dim==0 || dim==4),dim=4; - if(BCastTo(c) ) ffassert(dim==0 || dim==4),dim=4; - if(BCastTo(c) ) ffassert(dim==0 || dim==5),dim=5; - if(BCastTo(c) ) ffassert(dim==0 || dim==5),dim=5; - } - } + } else { + C_F0 c = ::Find(l[i].id); + // mesh + if (BCastTo< pfec >(c)) { + complextype = true; + if (dim == 0 || dim == 2) { + dim = 2; + } else { + return_samedim = false; + } } - else - { - C_F0 c=::Find(l[i].id); - if(BCastTo(c) ) ffassert(dim==0 || dim==2),dim=2; - if(BCastTo(c) ) ffassert(dim==0 || dim==2),dim=2; - if(BCastTo(c) ) ffassert(dim==0 || dim==3),dim=3; - if(BCastTo(c) ) ffassert(dim==0 || dim==3),dim=3; - if(BCastTo(c) ) ffassert(dim==0 || dim==4),dim=4; - if(BCastTo(c) ) ffassert(dim==0 || dim==4),dim=4; - if(BCastTo(c) ) ffassert(dim==0 || dim==5),dim=5; - if(BCastTo(c) ) ffassert(dim==0 || dim==5),dim=5; + if (BCastTo< pfer >(c)) { + realtype = true; + if (dim == 0 || dim == 2) { + dim = 2; + } else { + return_samedim = false; + } } + // mesh3 + if (BCastTo< pf3c >(c)) { + complextype = true; + if (dim == 0 || dim == 3) { + dim = 3; + } else { + return_samedim = false; + } } - } - ffassert(dim); - return dim; - -} - -AnyType Problem::operator()(Stack stack) const -{ - if(dim==2) { - Data *data= dataptr(stack); - if (complextype) - return eval(stack,data,data->AC,data->AcadnaC); - else - return eval(stack,data,data->AR,data->AcadnaR); - } - else if(dim==3) { - Data *data= dataptr3(stack); - if (complextype) - return eval(stack,data,data->AC,data->AcadnaC); - else - return eval(stack,data,data->AR,data->AcadnaR); - } - else if(dim==4) { - Data *data= dataptrS(stack); - if (complextype) - return eval(stack,data,data->AC,data->AcadnaC); - else - return eval(stack,data,data->AR,data->AcadnaR); - } - else if(dim==5) { - Data *data= dataptrL(stack); - if (complextype) - return eval(stack,data,data->AC,data->AcadnaC); - else - return eval(stack,data,data->AR,data->AcadnaR); - } - else if(dim==6){ - DataComposite *dataComposite= dataptrCompo(stack); - if (complextype) - return evalComposite( stack, dataComposite, dataComposite->ACglobal); - else - return evalComposite( stack, dataComposite, dataComposite->ARglobal); - } - - else ffassert(0); -} - -template -bool GetBilinearParam(const ListOfId &l,basicAC_F0::name_and_type *name_param,int n_name_param, - Expression *nargs,int & N,int & M, vector & var ) -{ - bool unset=true,complextype=false; - - for (int i=0;iname()]->CastTo(C_F0(l[i].e,l[i].re)); - break; + if (BCastTo< pf3r >(c)) { + realtype = true; + if (dim == 0 || dim == 3) { + dim = 3; + } else { + return_samedim = false; + } } - if (!ok) - { - cerr << " Error name argument " << l[i].id << " the kown arg : "; - for (int k=0;ksize(); - M = array[1]->size(); - var.resize(N+M); - for (size_t k=0,j=0;k<2;k++) - for (size_t i=0;isize();i++) - { - const UnId & idi((*array[k])[i]); - if (idi.r == 0 && idi.re == 0 && idi.array==0 ) - { C_F0 c=::Find( idi.id); - if (unset) - complextype = BCastTo(c) , unset=false; - - if(complextype) - var[j++]=CastTo(c); - else - var[j++]=CastTo(c); - } - else - CompileError(" Just Variable in array parameter "); + // meshS + if (BCastTo< pfSc >(c)) { + complextype = true; + if (dim == 0 || dim == 4) { + dim = 4; + } else { + return_samedim = false; + } } - } - else - { // old version - assert(n%2==0); - N=n/2; - M=N; - var.resize(N+M); - for (size_t i=0,j=0;i(c) , unset=false; - if(complextype) - var[j++]=CastTo(c); - else - var[j++]=CastTo(c); + if (BCastTo< pfSr >(c)) { + realtype = true; + if (dim == 0 || dim == 4) { + dim = 4; + } else { + return_samedim = false; + } } - - } - return complextype; -} - - -template < class K, class v_fes> -void verified_E_FEcompo_ForProblem( const int &typeFEbase, const int &k, const size_t &Nbitem, - const vector &var, const vector &type_var){ - ffassert(Nbitem == var.size()); - - Expression expFEbase = 0; - for (size_t i=0;i,<....>) " << endl; - cerr<< "Error in the definition of"<< k <<"-th FESpace in problem ."<< endl; - ffassert(0); + // meshL + if (BCastTo< pfLc >(c)) { + complextype = true; + if (dim == 0 || dim == 5) { + dim = 5; + } else { + return_samedim = false; + } + } + if (BCastTo< pfLr >(c)) { + realtype = true; + if (dim == 0 || dim == 5) { + dim = 5; + } else { + return_samedim = false; + } } + } + } + } + ffassert(dim); + if (verbosity > 2) cout << "realtype= " << realtype << ", complextype=" << complextype << endl; + if (realtype == complextype) { + if (realtype) { + cerr << "In problem or solve, we used complex and real FESpace. This is not allowed in Freefem." << endl; + ffassert(0); + } else { + cerr << "In problem or solve, error in casting FEbase." << endl; + ffassert(0); + } + } - const E_FEcomp * FEbase_comp = dynamic_cast *>( var[i]) ; - ffassert(FEbase_comp); + return std::pair< bool, bool >(return_samedim, complextype); +} - // check the index component of the FESpace - if( !(FEbase_comp->comp == i) ){ - // example : - //============ - // Uh [u1,u2] - // problem toto(<[u2,u1], ...>, < ...>) - // [u2,u1] is not permit. - cerr << "The list of element of a FESpace (Uh [u1,u2,u3] for example) must be in the same order in a Problem. " << endl; - cerr << "Error in the "<< k <<"-th FESpace."<< endl; - ffassert(0); - } - // check the size of nbitem in FESpace - if( ( (i-1)== Nbitem) ){ - if( !( FEbase_comp->N == Nbitem) ){ - cerr << "Error in the definition of "<< k <<"-th FESpace."<< endl; - cerr << "The size of t " << endl; - ffassert(0); - } - } - if(i ==0){ - expFEbase = FEbase_comp->a0; - }else{ - if( !(expFEbase = FEbase_comp->a0) ){ - // example : - //============ - // Uh [u1,u2] - // Vh [v1,v2,v3] - // problem toto(<[u1,v1], ...>, < ...>) - // [u1,v1] is not permit. - cerr << "Error in the definition of"<< k <<"-th FESpace."<< endl; - cerr << "This element contains different FESpaces." << endl; - ffassert(0); - } +// dimProblem read the number of arguments of problem ex: problem a(u,v) or a([u1,u2], [v1,v2]) +int dimProblem(const ListOfId &l) { + int dim = 0; + int nb = l.size( ); //,nbarray=0;//,n=0, + // const UnId *p1; + for (int i = 0; i < nb; ++i) { + if (l[i].e == 0) // to miss name parameter solver=ddd + { + if (l[i].array) { + ListOfId *array = l[i].array; + for (int j = 0; j < array->size( ); ++j) { + const UnId &idi((*array)[j]); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + C_F0 c = ::Find(idi.id); + if (BCastTo< pfec >(c)) ffassert(dim == 0 || dim == 2), dim = 2; + if (BCastTo< pfer >(c)) ffassert(dim == 0 || dim == 2), dim = 2; + if (BCastTo< pf3c >(c)) ffassert(dim == 0 || dim == 3), dim = 3; + if (BCastTo< pf3r >(c)) ffassert(dim == 0 || dim == 3), dim = 3; + if (BCastTo< pfSr >(c)) ffassert(dim == 0 || dim == 4), dim = 4; + if (BCastTo< pfSc >(c)) ffassert(dim == 0 || dim == 4), dim = 4; + if (BCastTo< pfLr >(c)) ffassert(dim == 0 || dim == 5), dim = 5; + if (BCastTo< pfLc >(c)) ffassert(dim == 0 || dim == 5), dim = 5; + } } - } -} + } else { + C_F0 c = ::Find(l[i].id); + if (BCastTo< pfec >(c)) ffassert(dim == 0 || dim == 2), dim = 2; + if (BCastTo< pfer >(c)) ffassert(dim == 0 || dim == 2), dim = 2; + if (BCastTo< pf3c >(c)) ffassert(dim == 0 || dim == 3), dim = 3; + if (BCastTo< pf3r >(c)) ffassert(dim == 0 || dim == 3), dim = 3; + if (BCastTo< pfSr >(c)) ffassert(dim == 0 || dim == 4), dim = 4; + if (BCastTo< pfSc >(c)) ffassert(dim == 0 || dim == 4), dim = 4; + if (BCastTo< pfLr >(c)) ffassert(dim == 0 || dim == 5), dim = 5; + if (BCastTo< pfLc >(c)) ffassert(dim == 0 || dim == 5), dim = 5; + } + } + } + ffassert(dim); + return dim; +} -// var expression -void GetBilinearParamCompositeFESpace(const ListOfId &l,basicAC_F0::name_and_type *name_param,int n_name_param, - Expression *nargs,int & N,int & M, vector & var, vector & type_var, - KN &UhNbItem,KN &VhNbItem ) -{ - // In this function compl - bool complextype=isSameDimAndComplexTypeProblem(l).second; +AnyType Problem::operator( )(Stack stack) const { + if (dim == 2) { + Data< FESpace > *data = dataptr(stack); + if (complextype) + return eval< Complex, FESpace, v_fes >(stack, data, data->AC, data->AcadnaC); + else + return eval< double, FESpace, v_fes >(stack, data, data->AR, data->AcadnaR); + } else if (dim == 3) { + Data< FESpace3 > *data = dataptr3(stack); + if (complextype) + return eval< Complex, FESpace3, v_fes3 >(stack, data, data->AC, data->AcadnaC); + else + return eval< double, FESpace3, v_fes3 >(stack, data, data->AR, data->AcadnaR); + } else if (dim == 4) { + Data< FESpaceS > *data = dataptrS(stack); + if (complextype) + return eval< Complex, FESpaceS, v_fesS >(stack, data, data->AC, data->AcadnaC); + else + return eval< double, FESpaceS, v_fesS >(stack, data, data->AR, data->AcadnaR); + } else if (dim == 5) { + Data< FESpaceL > *data = dataptrL(stack); + if (complextype) + return eval< Complex, FESpaceL, v_fesL >(stack, data, data->AC, data->AcadnaC); + else + return eval< double, FESpaceL, v_fesL >(stack, data, data->AR, data->AcadnaR); + } else if (dim == 6) { + DataComposite *dataComposite = dataptrCompo(stack); + if (complextype) + return evalComposite< Complex >(stack, dataComposite, dataComposite->ACglobal); + else + return evalComposite< double >(stack, dataComposite, dataComposite->ARglobal); + } - for (int i=0;i +bool GetBilinearParam(const ListOfId &l, basicAC_F0::name_and_type *name_param, int n_name_param, Expression *nargs, int &N, int &M, vector< Expression > &var) { + bool unset = true, complextype = false; + + for (int i = 0; i < n_name_param; i++) nargs[i] = 0; + int nb = l.size( ), n = 0, nbarray = 0; + ListOfId *array[2]; + for (int i = 0; i < nb; i++) + if (l[i].r == 0 && l[i].re == 0 && l[i].array == 0) + n++; + else if (l[i].array) + array[Min(nbarray++, 1)] = l[i].array; + else { + bool ok = false; + for (int j = 0; j < n_name_param; j++) + if (!strcmp(l[i].id, name_param[j].name)) { + ok = !nargs[j]; + nargs[j] = map_type[name_param[j].type->name( )]->CastTo(C_F0(l[i].e, l[i].re)); + break; + } + if (!ok) { + cerr << " Error name argument " << l[i].id << " the kown arg : "; + for (int k = 0; k < n_name_param; k++) cerr << name_param[k].name << " "; + cerr << endl; + CompileError("Unknown name argument or two times same name argument "); + } + } - int nb=l.size(),n=0,nbarray=0,counter=0; - for (int i=0;isize( ); + M = array[1]->size( ); + var.resize(N + M); + for (size_t k = 0, j = 0; k < 2; k++) + for (size_t i = 0; i < array[k]->size( ); i++) { + const UnId &idi((*array[k])[i]); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + C_F0 c = ::Find(idi.id); + if (unset) complextype = BCastTo< pfec >(c), unset = false; + + if (complextype) + var[j++] = CastTo< pfec >(c); + else + var[j++] = CastTo< pfer >(c); + } else + CompileError(" Just Variable in array parameter "); + } + } else { // old version + assert(n % 2 == 0); + N = n / 2; + M = N; + var.resize(N + M); + for (size_t i = 0, j = 0; i < l.size( ); i++) + if (l[i].r == 0 && l[i].re == 0 && l[i].array == 0) { + C_F0 c = ::Find(l[i].id); + if (unset) complextype = BCastTo< pfec >(c), unset = false; + if (complextype) + var[j++] = CastTo< pfec >(c); + else + var[j++] = CastTo< pfer >(c); + } + } + return complextype; +} - int nbcompo_begin=0; // variable for composite with chevron <> - int nbcompo_end=0; // variable for composite with chevron <> +template< class K, class v_fes > +void verified_E_FEcompo_ForProblem(const int &typeFEbase, const int &k, const size_t &Nbitem, const vector< Expression > &var, const vector< int > &type_var) { + ffassert(Nbitem == var.size( )); - ffassert( nbarray >1 ); - ListOfId * array[nbarray]; // ??? - - for (int i=0;i,<....>) " << endl; + cerr << "Error in the definition of" << k << "-th FESpace in problem ." << endl; + ffassert(0); } - ffassert( ( (nbcompo_begin == nbcompo_end) && (nbcompo_begin == 2) ) ); + const E_FEcomp< K, v_fes > *FEbase_comp = dynamic_cast< const E_FEcomp< K, v_fes > * >(var[i]); + ffassert(FEbase_comp); - for (int i=0;iname()]->CastTo(C_F0(l[i].e,l[i].re)); - break; - } - if (!ok) - { - cerr << " Error name argument " << l[i].id << " the kown arg : "; - for (int k=0;kcomp == i)) { + // example : + //============ + // Uh [u1,u2] + // problem toto(<[u2,u1], ...>, < ...>) + // [u2,u1] is not permit. + cerr << "The list of element of a FESpace (Uh [u1,u2,u3] for example) must be in the same order in a Problem. " << endl; + cerr << "Error in the " << k << "-th FESpace." << endl; + ffassert(0); } - ffassert( counter == nbarray ); - - // === reading the FEbase === // + // check the size of nbitem in FESpace + if (((i - 1) == Nbitem)) { + if (!(FEbase_comp->N == Nbitem)) { + cerr << "Error in the definition of " << k << "-th FESpace." << endl; + cerr << "The size of t " << endl; + ffassert(0); + } + } + if (i == 0) { + expFEbase = FEbase_comp->a0; + } else { + if (!(expFEbase = FEbase_comp->a0)) { + // example : + //============ + // Uh [u1,u2] + // Vh [v1,v2,v3] + // problem toto(<[u1,v1], ...>, < ...>) + // [u1,v1] is not permit. + cerr << "Error in the definition of" << k << "-th FESpace." << endl; + cerr << "This element contains different FESpaces." << endl; + ffassert(0); + } + } + } +} - // problem pb(< [u^{1}_{1},...u^{1}_{n_1}],..., >, < [v^{1}_{1},...v^{1}_{m_1}],...,[v^{p}_{1},...v^{p}_{m_p}] >) +// var expression +void GetBilinearParamCompositeFESpace(const ListOfId &l, basicAC_F0::name_and_type *name_param, int n_name_param, Expression *nargs, int &N, int &M, vector< Expression > &var, vector< int > &type_var, + KN< size_t > &UhNbItem, KN< size_t > &VhNbItem) { + // In this function compl + bool complextype = isSameDimAndComplexTypeProblem(l).second; - int first_index_compo[nbcompo_begin+1]; - { - int index_compo=0; - for (int i=0;isize(); - } // finconnues - for(int i=first_index_compo[1]; i< first_index_compo[2]; i++){ - M += array[i]->size(); - } // ftest + int nbcompo_begin = 0; // variable for composite with chevron <> + int nbcompo_end = 0; // variable for composite with chevron <> - ffassert( N == M ); // need to be relax in the future Morice - var.resize(N+M); - type_var.resize(N+M); + ffassert(nbarray > 1); + ListOfId *array[nbarray]; // ??? - UhNbItem.resize(first_index_compo[1]); - VhNbItem.resize(first_index_compo[2]-first_index_compo[1]); + for (int i = 0; i < nb; i++) { + if (l[i].compo_begin == true) nbcompo_begin++; + if (l[i].compo_end == true) nbcompo_end++; + } - for (size_t k=0,j=0;ksize();i++) - { - const UnId & idi((*array[k])[i]); - if (idi.r == 0 && idi.re == 0 && idi.array==0 ) - { C_F0 c=::Find( idi.id); - - if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=2; - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=2; - - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=3; - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=3; - - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=4; - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=4; - - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=5; - else if(BCastTo(c) ) var[j]=CastTo(c),type_var[j++]=5; - else CompileError(" Casting error of type of FEbase."); - } - else{ - CompileError(" Just Variable in array parameter "); - } - } + ffassert(((nbcompo_begin == nbcompo_end) && (nbcompo_begin == 2))); + + for (int i = 0; i < nb; i++) + if (l[i].r == 0 && l[i].re == 0 && l[i].array == 0) + n++; + else if (l[i].array) { + array[counter] = l[i].array; + counter++; + } else { + bool ok = false; + for (int j = 0; j < n_name_param; j++) + if (!strcmp(l[i].id, name_param[j].name)) { + ok = !nargs[j]; + nargs[j] = map_type[name_param[j].type->name( )]->CastTo(C_F0(l[i].e, l[i].re)); + break; + } + if (!ok) { + cerr << " Error name argument " << l[i].id << " the kown arg : "; + for (int k = 0; k < n_name_param; k++) cerr << name_param[k].name << " "; + cerr << endl; + CompileError("Unknown name argument or two times same name argument "); + } } + ffassert(counter == nbarray); - // check the consistency of the each FEbase space - counter = 0; //re-init the counter - int typeFEbase=-1; - for (size_t k=0,j=0;k local_var(array[k]->size()); // ?????? bug en memoire - vector< int> local_type_var(array[k]->size()); - for (size_t i=0;isize();i++){ - local_var[i] = var[counter]; - local_type_var[i] = type_var[counter]; - counter++; - } + // problem pb(< [u^{1}_{1},...u^{1}_{n_1}],..., >, < [v^{1}_{1},...v^{1}_{m_1}],...,[v^{p}_{1},...v^{p}_{m_p}] >) - size_t NbLocalitem= array[k]->size(); - //Remark: the NbLocalitem must be verified in verified_E_FEcompo_ForProblem - if( k( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - else - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - } - else if(typeFEbase == 3){ - if(complextype) - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - else - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - } - else if(typeFEbase == 4){ - if(complextype) - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - else - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - } - else if(typeFEbase == 5){ - if(complextype) - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - else - verified_E_FEcompo_ForProblem( typeFEbase, k, NbLocalitem, local_var, local_type_var ); - } - else{ - cerr << "error in typeFEbase." << endl; - ffassert(0); - } + ffassert((nbcompo_begin == nbcompo_end) && (nbcompo_begin == 2)); // lignes suivantes ne fonctionnent pas si cela n'est pas vrai + + UhNbItem.resize(first_index_compo[1]); + VhNbItem.resize(first_index_compo[2] - first_index_compo[1]); + + // get the size of the array + for (int i = first_index_compo[0]; i < first_index_compo[1]; i++) { + N += array[i]->size( ); + } // finconnues + for (int i = first_index_compo[1]; i < first_index_compo[2]; i++) { + M += array[i]->size( ); + } // ftest + + ffassert(N == M); // need to be relax in the future Morice + var.resize(N + M); + type_var.resize(N + M); + + UhNbItem.resize(first_index_compo[1]); + VhNbItem.resize(first_index_compo[2] - first_index_compo[1]); + + for (size_t k = 0, j = 0; k < nbarray; k++) { + for (size_t i = 0; i < array[k]->size( ); i++) { + const UnId &idi((*array[k])[i]); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + C_F0 c = ::Find(idi.id); + + if (BCastTo< pfec >(c)) + var[j] = CastTo< pfec >(c), type_var[j++] = 2; + else if (BCastTo< pfer >(c)) + var[j] = CastTo< pfer >(c), type_var[j++] = 2; + + else if (BCastTo< pf3c >(c)) + var[j] = CastTo< pf3c >(c), type_var[j++] = 3; + else if (BCastTo< pf3r >(c)) + var[j] = CastTo< pf3r >(c), type_var[j++] = 3; + + else if (BCastTo< pfSc >(c)) + var[j] = CastTo< pfSc >(c), type_var[j++] = 4; + else if (BCastTo< pfSr >(c)) + var[j] = CastTo< pfSr >(c), type_var[j++] = 4; + + else if (BCastTo< pfLc >(c)) + var[j] = CastTo< pfLc >(c), type_var[j++] = 5; + else if (BCastTo< pfLr >(c)) + var[j] = CastTo< pfLr >(c), type_var[j++] = 5; + else + CompileError(" Casting error of type of FEbase."); + } else { + CompileError(" Just Variable in array parameter "); + } + } + } + + // check the consistency of the each FEbase space + counter = 0; // re-init the counter + int typeFEbase = -1; + for (size_t k = 0, j = 0; k < nbarray; k++) { + typeFEbase = type_var[counter]; + + vector< Expression > local_var(array[k]->size( )); // ?????? bug en memoire + vector< int > local_type_var(array[k]->size( )); + for (size_t i = 0; i < array[k]->size( ); i++) { + local_var[i] = var[counter]; + local_type_var[i] = type_var[counter]; + counter++; + } + + size_t NbLocalitem = array[k]->size( ); + // Remark: the NbLocalitem must be verified in verified_E_FEcompo_ForProblem + if (k < first_index_compo[1]) { + UhNbItem[(long)k] = NbLocalitem; + } else { + VhNbItem[(long)(k - first_index_compo[1])] = NbLocalitem; + } + + if (typeFEbase == 2) { + if (complextype) + verified_E_FEcompo_ForProblem< Complex, v_fes >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + else + verified_E_FEcompo_ForProblem< double, v_fes >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + } else if (typeFEbase == 3) { + if (complextype) + verified_E_FEcompo_ForProblem< Complex, v_fes3 >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + else + verified_E_FEcompo_ForProblem< double, v_fes3 >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + } else if (typeFEbase == 4) { + if (complextype) + verified_E_FEcompo_ForProblem< Complex, v_fesS >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + else + verified_E_FEcompo_ForProblem< double, v_fesS >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + } else if (typeFEbase == 5) { + if (complextype) + verified_E_FEcompo_ForProblem< Complex, v_fesL >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + else + verified_E_FEcompo_ForProblem< double, v_fesL >(typeFEbase, k, NbLocalitem, local_var, local_type_var); + } else { + cerr << "error in typeFEbase." << endl; + ffassert(0); } + } } /* @@ -13568,866 +12224,755 @@ bool CheckSizeOfForm( list & largs ,int N,int M) } */ -bool FieldOfForm( list & largs ,bool complextype) // true => complex problem +bool FieldOfForm(list< C_F0 > &largs, bool complextype) // true => complex problem { - // bool iscomplextype=complextype; - list::iterator ii,ib=largs.begin(), - ie=largs.end(); - // bool complextype =false; - for (ii=ib;ii != ie;ii++) - { - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==atype()) - { - const FormBilinear * bb=dynamic_cast(e); - if (! bb->b->mappable(BCastToR)) - complextype=true; - } - else if (r==atype()) - { - const FormLinear * ll=dynamic_cast(e); - if (! ll->l->mappable(BCastToR)) - complextype=true; - } - else if (r == atype()) - { - const BC_set * bc=dynamic_cast(e); - if (bc->complextype) complextype=true; - - } + // bool iscomplextype=complextype; + list< C_F0 >::iterator ii, ib = largs.begin( ), ie = largs.end( ); + // bool complextype =false; + for (ii = ib; ii != ie; ii++) { + Expression e = ii->LeftValue( ); + aType r = ii->left( ); + if (r == atype< const FormBilinear * >( )) { + const FormBilinear *bb = dynamic_cast< const FormBilinear * >(e); + if (!bb->b->mappable(BCastToR)) complextype = true; + } else if (r == atype< const FormLinear * >( )) { + const FormLinear *ll = dynamic_cast< const FormLinear * >(e); + if (!ll->l->mappable(BCastToR)) complextype = true; + } else if (r == atype< const BC_set * >( )) { + const BC_set *bc = dynamic_cast< const BC_set * >(e); + if (bc->complextype) complextype = true; } + } - for (ii=ib;ii != ie;ii++) - { - Expression e=ii->LeftValue(); - aType r = ii->left(); - if (r==atype()) - { - FormBilinear * bb=new FormBilinear(*dynamic_cast(e)); - Foperator * b=const_cast< Foperator *>(bb->b); - // const Foperator * b=bb->b; - //cout << b << " bb->b " << bb->b << " " << bb->b << " " << bb->b->isoptimize <isoptimize==false); - if (complextype) b->mapping(&CCastToC); - else b->mapping(&CCastToR) ; - Foperator * bn = b->Optimize(currentblock); - *bb->b = *bn; - *ii=C_F0(bb,r); - } - else if (r==atype()) - { - FormLinear * ll=new FormLinear(*dynamic_cast(e)); - Ftest * l= const_cast(ll->l); - if (complextype) l->mapping(&CCastToC) ; - else l->mapping(&CCastToR) ; - Ftest * ln = l->Optimize(currentblock); - *ll->l=*ln; - *ii=C_F0(ll,r); - //cout << l << " ll->l " << ll->l << " " << ll->l->isoptimize <()) - {// modif FH mai 2007 A FAIRE il y a un bug ici XXXXXXXXXXXXX - - BC_set * bc= new BC_set(*dynamic_cast(e)); - if (complextype && !bc->complextype) { - bc->CastToK() ; - if(verbosity > 10) cout << " Bc to complex " << endl; - } - //else bc->mapping(&CCastToR) ; - //cout << l << " ll->l " << ll->l << " " << ll->l->isoptimize <LeftValue( ); + aType r = ii->left( ); + if (r == atype< const FormBilinear * >( )) { + FormBilinear *bb = new FormBilinear(*dynamic_cast< const FormBilinear * >(e)); + Foperator *b = const_cast< Foperator * >(bb->b); + // const Foperator * b=bb->b; + // cout << b << " bb->b " << bb->b << " " << bb->b << " " << bb->b->isoptimize <isoptimize == false); + if (complextype) + b->mapping(&CCastToC); + else + b->mapping(&CCastToR); + Foperator *bn = b->Optimize(currentblock); + *bb->b = *bn; + *ii = C_F0(bb, r); + } else if (r == atype< const FormLinear * >( )) { + FormLinear *ll = new FormLinear(*dynamic_cast< const FormLinear * >(e)); + Ftest *l = const_cast< Ftest * >(ll->l); + if (complextype) + l->mapping(&CCastToC); + else + l->mapping(&CCastToR); + Ftest *ln = l->Optimize(currentblock); + *ll->l = *ln; + *ii = C_F0(ll, r); + // cout << l << " ll->l " << ll->l << " " << ll->l->isoptimize <( )) { // modif FH mai 2007 A FAIRE il y a un bug ici XXXXXXXXXXXXX + + BC_set *bc = new BC_set(*dynamic_cast< const BC_set * >(e)); + if (complextype && !bc->complextype) { + bc->CastToK< Complex >( ); + if (verbosity > 10) cout << " Bc to complex " << endl; + } + // else bc->mapping(&CCastToR) ; + // cout << l << " ll->l " << ll->l << " " << ll->l->isoptimize < 999) cout << "Problem : ----------------------------- " << top << " dim = " << dim << " " << nargs << endl; -Problem::Problem(const C_args * ca,const ListOfId &l,size_t & top) : -op(new C_args(*ca)), -var(l.size()), -type_var(), -VF(false), -offset(align8(top)), -dim( isCompositeProblem(l) ? 6 : ( isSameDimAndComplexTypeProblem(l).first ? dimProblem(l) : 6 ) ) -{ - if( verbosity > 999) cout << "Problem : ----------------------------- " << top << " dim = " << dim<<" " << nargs << endl; - - if(dim==6){ - top = offset + sizeof( DataComposite ); - } - else{ - top = offset + max(sizeof(Data),sizeof(Data)); - } - bool iscomplex=isSameDimAndComplexTypeProblem(l).second; // iscomplex of the type of argument u1,u2, ... of : problem myproblem([u1,u2],[v1,v2]), ... - - if(dim==2) - iscomplex=GetBilinearParam(l,name_param,n_name_param,nargs, Nitem,Mitem,var); - else if (dim==3) - iscomplex=GetBilinearParam(l,name_param,n_name_param,nargs, Nitem,Mitem,var); - else if (dim==4) // dim = 4 for a 3D surface problem - iscomplex=GetBilinearParam(l,name_param,n_name_param,nargs, Nitem,Mitem,var); - else if (dim==5) // dim = 5 for a 3D curve problem - iscomplex=GetBilinearParam(l,name_param,n_name_param,nargs, Nitem,Mitem,var); - else if (dim==6){ - if(! isCompositeProblem(l) ){ - cerr << "write our problem/solve in composite form." << endl; - cerr << "problem pb(<[u1,u2],[u3]>,<[v1,v2],[v3]>) = " << endl; - ffassert(0); - } - ffassert( (isCompositeProblem(l) == true) ); // ??? - Nitem = 0; // initialize value to zero - Mitem = 0; // initialize value - - KN UhNbItem; - KN VhNbItem; - GetBilinearParamCompositeFESpace(l,name_param,n_name_param,nargs, Nitem,Mitem,var,type_var,UhNbItem,VhNbItem); - - // recuperation de la taille des FESpaces - int NpUh = (int) UhNbItem.size(); - int NpVh = (int) VhNbItem.size(); - - KN indexBlockUh(Nitem); - KN indexBlockVh(Mitem); - KN localIndexInTheBlockUh(Nitem); - KN localIndexInTheBlockVh(Mitem); - - // index for the construction of the block of Uh - { - // =========================================== - // - // varf([u0,u1,...,u4], ... ) - // varf([ [u0_blk1,u1_blk1],[u0_blk2,u1_blk2,u2_blk2] ], ... ) - - // u4 correspond to u2_blk2 in the block varf - // ============================================ - // For u4, on a :: current_index = 4 - // :: indexBlockUh = 2 - // :: localIndexInThBlock = 3 - int current_index=0; - for(int i=0; i), sizeof(Data< FESpace >)); + } + bool iscomplex = isSameDimAndComplexTypeProblem(l).second; // iscomplex of the type of argument u1,u2, ... of : problem myproblem([u1,u2],[v1,v2]), ... + + if (dim == 2) + iscomplex = GetBilinearParam< pfer, pfec >(l, name_param, n_name_param, nargs, Nitem, Mitem, var); + else if (dim == 3) + iscomplex = GetBilinearParam< pf3r, pf3c >(l, name_param, n_name_param, nargs, Nitem, Mitem, var); + else if (dim == 4) // dim = 4 for a 3D surface problem + iscomplex = GetBilinearParam< pfSr, pfSc >(l, name_param, n_name_param, nargs, Nitem, Mitem, var); + else if (dim == 5) // dim = 5 for a 3D curve problem + iscomplex = GetBilinearParam< pfLr, pfLc >(l, name_param, n_name_param, nargs, Nitem, Mitem, var); + else if (dim == 6) { + if (!isCompositeProblem(l)) { + cerr << "write our problem/solve in composite form." << endl; + cerr << "problem pb(<[u1,u2],[u3]>,<[v1,v2],[v3]>) = " << endl; + ffassert(0); + } + ffassert((isCompositeProblem(l) == true)); // ??? + Nitem = 0; // initialize value to zero + Mitem = 0; // initialize value - // index for the construction of the block of Vh - { - int current_index=0; - for(int i=0; i UhNbItem; + KN< size_t > VhNbItem; + GetBilinearParamCompositeFESpace(l, name_param, n_name_param, nargs, Nitem, Mitem, var, type_var, UhNbItem, VhNbItem); - block_largs.resize( (long) NpUh, (long) NpVh ); - //listOfComponentBilinearForm(op->largs); - list tmp_largs = creationLargsForCompositeFESpace( op->largs, NpUh, NpVh, indexBlockUh, indexBlockVh ); - //cout << "tmp_largs.size()=" << tmp_largs.size() << endl; - block_largs = computeBlockLargs( tmp_largs, NpUh, NpVh, indexBlockUh, indexBlockVh ); - changeComponentFormCompositeFESpace( localIndexInTheBlockUh, localIndexInTheBlockVh, block_largs ); + // recuperation de la taille des FESpaces + int NpUh = (int)UhNbItem.size( ); + int NpVh = (int)VhNbItem.size( ); - bool total_iscmplx=false; - // loop over block - for(int i=0; i indexBlockUh(Nitem); + KN< int > indexBlockVh(Mitem); + KN< int > localIndexInTheBlockUh(Nitem); + KN< int > localIndexInTheBlockVh(Mitem); - if( iscmplx ){ total_iscmplx =true;} - } + // index for the construction of the block of Uh + { + // =========================================== + // + // varf([u0,u1,...,u4], ... ) + // varf([ [u0_blk1,u1_blk1],[u0_blk2,u1_blk2,u2_blk2] ], ... ) + + // u4 correspond to u2_blk2 in the block varf + // ============================================ + // For u4, on a :: current_index = 4 + // :: indexBlockUh = 2 + // :: localIndexInThBlock = 3 + int current_index = 0; + for (int i = 0; i < NpUh; i++) { + for (int j = 0; j < UhNbItem[i]; j++) { + indexBlockUh[current_index] = i; + localIndexInTheBlockUh[current_index] = j; + current_index++; } - complextype = total_iscmplx; - if( complextype && !iscomplex ) - CompileError("Error: Problem a complex problem with no complex FE function "); - if( verbosity > 1) - cout << " -- Problem type ( complex : " << complextype << " ) " <(nargs[3+3]); - assert(op); - precon = op->Find("(",ArrayOfaType(atype* >(),false)); - ffassert(precon); + int current_index = 0; + for (int i = 0; i < NpVh; i++) { + for (int j = 0; j < VhNbItem[i]; j++) { + indexBlockVh[current_index] = i; + localIndexInTheBlockVh[current_index] = j; + current_index++; + } + } + ffassert(current_index == Mitem); } - VF=isVF(op->largs); - // cout << " Problem ) VF = " << VF << endl; - - if( dim != 6 ){ - complextype = FieldOfForm(op->largs,iscomplex) ; // Warning do the casting of all expression in double or complex - if( complextype && !iscomplex) - CompileError("Error: Problem a complex problem with no complex FE function "); - } + block_largs.resize((long)NpUh, (long)NpVh); + // listOfComponentBilinearForm(op->largs); + list< C_F0 > tmp_largs = creationLargsForCompositeFESpace(op->largs, NpUh, NpVh, indexBlockUh, indexBlockVh); + // cout << "tmp_largs.size()=" << tmp_largs.size() << endl; + block_largs = computeBlockLargs(tmp_largs, NpUh, NpVh, indexBlockUh, indexBlockVh); + changeComponentFormCompositeFESpace(localIndexInTheBlockUh, localIndexInTheBlockVh, block_largs); - if( verbosity > 1) - cout << " -- Problem type ( complex : " << complextype << " ) " <nbitem(); - E_Array * vvi(dynamic_cast< E_Array *>(f)); - if ( ! vvi) return 0; - E_Array & vi(*vvi); - Expression febase=0; - for (size_t i=0;i() ); - const E_FEcomp * comp=dynamic_cast *>( vi[i].LeftValue()) ; - if (!(comp && comp->comp == (int) i && comp->N == (int) N)) return 0; - if (!febase) febase = comp->a0; - else if(comp->a0 != febase) return 0; + if (iscmplx) { + total_iscmplx = true; + } + } } - return febase; -} -template -Call_FormBilinear< VFES1, VFES2>::Call_FormBilinear(Expression * na,Expression BB,Expression fi, Expression fj) -: nargs(na),largs(),N(fi->nbitem()),M(fj->nbitem()), -euh(fi), evh(fj) -{ - assert(nargs ); - const C_args * LLL=dynamic_cast(BB); - if (!LLL) - CompileError("Sorry the variationnal form (varf) is not a the variationnal form (type const C_args *)"); - largs=LLL->largs; -} + complextype = total_iscmplx; + if (complextype && !iscomplex) CompileError("Error: Problem a complex problem with no complex FE function "); + if (verbosity > 1) cout << " -- Problem type ( complex : " << complextype << " ) " << endl; + } else + ffassert(0); // bug + + precon = 0; // a changer + if (nargs[3 + 3]) { + const Polymorphic *op = dynamic_cast< const Polymorphic * >(nargs[3 + 3]); + assert(op); + precon = op->Find("(", ArrayOfaType(atype< KN< R > * >( ), false)); + ffassert(precon); + } + + VF = isVF(op->largs); + // cout << " Problem ) VF = " << VF << endl; + if (dim != 6) { + complextype = FieldOfForm(op->largs, iscomplex); // Warning do the casting of all expression in double or complex + if (complextype && !iscomplex) CompileError("Error: Problem a complex problem with no complex FE function "); + } -template -Call_CompositeFormBilinear< VFES1, VFES2>::Call_CompositeFormBilinear(Expression * na,Expression BB,Expression fi, Expression fj) -: nargs(na),block_largs( (long) fi->componentNbitem().size(),(long) fj->componentNbitem().size() ),N(fi->nbitem()),M(fj->nbitem()), - euh(fi), evh(fj){ + if (verbosity > 1) cout << " -- Problem type ( complex : " << complextype << " ) " << endl; +} - assert(nargs ); - const C_args * LLL=dynamic_cast(BB); - if (!LLL) - CompileError("Sorry the variationnal form (varf) is not a the variationnal form (type const C_args *)"); +Expression IsFebaseArray(Expression f) { + assert(f); + size_t N = f->nbitem( ); + E_Array *vvi(dynamic_cast< E_Array * >(f)); + if (!vvi) return 0; + E_Array &vi(*vvi); + Expression febase = 0; + for (size_t i = 0; i < N; i++) { + assert(vi[i].left( ) == atype< pfer >( )); + const E_FEcomp< R, v_fes > *comp = dynamic_cast< const E_FEcomp< R, v_fes > * >(vi[i].LeftValue( )); + if (!(comp && comp->comp == (int)i && comp->N == (int)N)) return 0; + if (!febase) + febase = comp->a0; + else if (comp->a0 != febase) + return 0; + } + return febase; +} +template< class VFES1, class VFES2 > +Call_FormBilinear< VFES1, VFES2 >::Call_FormBilinear(Expression *na, Expression BB, Expression fi, Expression fj) : nargs(na), largs( ), N(fi->nbitem( )), M(fj->nbitem( )), euh(fi), evh(fj) { + assert(nargs); + const C_args *LLL = dynamic_cast< const C_args * >(BB); + if (!LLL) CompileError("Sorry the variationnal form (varf) is not a the variationnal form (type const C_args *)"); + largs = LLL->largs; +} +template< class VFES1, class VFES2 > +Call_CompositeFormBilinear< VFES1, VFES2 >::Call_CompositeFormBilinear(Expression *na, Expression BB, Expression fi, Expression fj) + : nargs(na), block_largs((long)fi->componentNbitem( ).size( ), (long)fj->componentNbitem( ).size( )), N(fi->nbitem( )), M(fj->nbitem( )), euh(fi), evh(fj) { - // recuperation de la taille des FESpaces - KN UhNbItem = fi->componentNbitem(); - KN VhNbItem = fj->componentNbitem(); + assert(nargs); + const C_args *LLL = dynamic_cast< const C_args * >(BB); + if (!LLL) CompileError("Sorry the variationnal form (varf) is not a the variationnal form (type const C_args *)"); - int NpUh = (int) UhNbItem.size(); - int NpVh = (int) VhNbItem.size(); + // recuperation de la taille des FESpaces + KN< size_t > UhNbItem = fi->componentNbitem( ); + KN< size_t > VhNbItem = fj->componentNbitem( ); - KN indexBlockUh(fi->nbitem()); - KN indexBlockVh(fj->nbitem()); - KN localIndexInTheBlockUh(fi->nbitem()); - KN localIndexInTheBlockVh(fj->nbitem()); + int NpUh = (int)UhNbItem.size( ); + int NpVh = (int)VhNbItem.size( ); - // index for the construction of the block of Uh - { - // =========================================== - // - // varf([u0,u1,...,u4], ... ) - // varf([ [u0_blk1,u1_blk1],[u0_blk2,u1_blk2,u2_blk2] ], ... ) + KN< int > indexBlockUh(fi->nbitem( )); + KN< int > indexBlockVh(fj->nbitem( )); + KN< int > localIndexInTheBlockUh(fi->nbitem( )); + KN< int > localIndexInTheBlockVh(fj->nbitem( )); - // u4 correspond to u2_blk2 in the block varf - // ============================================ - // For u4, on a :: current_index = 4 - // :: indexBlockUh = 2 - // :: localIndexInThBlock = 3 - int current_index=0; - for(int i=0; inbitem()); + // index for the construction of the block of Uh + { + // =========================================== + // + // varf([u0,u1,...,u4], ... ) + // varf([ [u0_blk1,u1_blk1],[u0_blk2,u1_blk2,u2_blk2] ], ... ) + + // u4 correspond to u2_blk2 in the block varf + // ============================================ + // For u4, on a :: current_index = 4 + // :: indexBlockUh = 2 + // :: localIndexInThBlock = 3 + int current_index = 0; + for (int i = 0; i < NpUh; i++) { + for (int j = 0; j < UhNbItem[i]; j++) { + indexBlockUh[current_index] = i; + localIndexInTheBlockUh[current_index] = j; + current_index++; + } } + ffassert(current_index == fi->nbitem( )); + } - // index for the construction of the block of Vh - { - int current_index=0; - for(int i=0; inbitem()); + // index for the construction of the block of Vh + { + int current_index = 0; + for (int i = 0; i < NpVh; i++) { + for (int j = 0; j < VhNbItem[i]; j++) { + indexBlockVh[current_index] = i; + localIndexInTheBlockVh[current_index] = j; + current_index++; + } } + ffassert(current_index == fj->nbitem( )); + } - list tmp_largs = creationLargsForCompositeFESpace( LLL->largs, NpUh, NpVh, indexBlockUh, indexBlockVh ); - block_largs = computeBlockLargs( tmp_largs, NpUh, NpVh, indexBlockUh, indexBlockVh ); - changeComponentFormCompositeFESpace( localIndexInTheBlockUh, localIndexInTheBlockVh, block_largs ); + list< C_F0 > tmp_largs = creationLargsForCompositeFESpace(LLL->largs, NpUh, NpVh, indexBlockUh, indexBlockVh); + block_largs = computeBlockLargs(tmp_largs, NpUh, NpVh, indexBlockUh, indexBlockVh); + changeComponentFormCompositeFESpace(localIndexInTheBlockUh, localIndexInTheBlockVh, block_largs); } -template -Call_FormLinear::Call_FormLinear(Expression *na,Expression LL, Expression ft) -: largs(), nargs(na), N(ft->nbitem()), ppfes(ft)//IsFebaseArray(ft)) +template< class VFES > +Call_FormLinear< VFES >::Call_FormLinear(Expression *na, Expression LL, Expression ft) + : largs( ), nargs(na), N(ft->nbitem( )), ppfes(ft) // IsFebaseArray(ft)) { - const C_args * LLL=dynamic_cast(LL); - if ( !LLL) CompileError("The parameter of a LinearForm must be a array of all componate of FE function"); - largs=LLL->largs; + const C_args *LLL = dynamic_cast< const C_args * >(LL); + if (!LLL) CompileError("The parameter of a LinearForm must be a array of all componate of FE function"); + largs = LLL->largs; } // version for composite case -Call_FormLinear::Call_FormLinear(Expression *na,Expression LL, Expression ft) -: block_largs(), nargs(na), N(ft->nbitem()), ppfes(ft)//IsFebaseArray(ft)) +Call_FormLinear< vect_generic_v_fes >::Call_FormLinear(Expression *na, Expression LL, Expression ft) + : block_largs( ), nargs(na), N(ft->nbitem( )), ppfes(ft) // IsFebaseArray(ft)) { - const C_args * LLL=dynamic_cast(LL); - if ( !LLL) CompileError("The parameter of a LinearForm must be a array of all componate of FE function"); + const C_args *LLL = dynamic_cast< const C_args * >(LL); + if (!LLL) CompileError("The parameter of a LinearForm must be a array of all componate of FE function"); - // recuperation de la taille des FESpaces - KN VhNbItem = ft->componentNbitem(); - int NpVh = (int) VhNbItem.size(); - KN indexBlockVh(ft->nbitem()); - KN localIndexInTheBlockVh(ft->nbitem()); + // recuperation de la taille des FESpaces + KN< size_t > VhNbItem = ft->componentNbitem( ); + int NpVh = (int)VhNbItem.size( ); + KN< int > indexBlockVh(ft->nbitem( )); + KN< int > localIndexInTheBlockVh(ft->nbitem( )); - // index for the construction of the block of Vh - { - int current_index=0; - for(int i=0; inbitem()); + // index for the construction of the block of Vh + { + int current_index = 0; + for (int i = 0; i < NpVh; i++) { + for (int j = 0; j < VhNbItem[i]; j++) { + indexBlockVh[current_index] = i; + localIndexInTheBlockVh[current_index] = j; + current_index++; + } } + ffassert(current_index == ft->nbitem( )); + } - block_largs.resize( (long) NpVh); - block_largs = creationLinearFormCompositeFESpace( LLL->largs, NpVh, indexBlockVh, localIndexInTheBlockVh ); + block_largs.resize((long)NpVh); + block_largs = creationLinearFormCompositeFESpace(LLL->largs, NpVh, indexBlockVh, localIndexInTheBlockVh); } -bool C_args::IsLinearOperator() const { - // int n=largs.size(); - aType tRn =atype* >(); - aType tCn =atype* >(); - for (const_iterator i=largs.begin(); i != largs.end();i++) - { - C_F0 c= *i; - // Expression e=c; - aType r=c.left(); - if ( ( r != atype() ) - && ( r != atype() ) - && ( r != atype::plusAx >() ) - && ( r != atype::plusAtx >() ) - && ( r != atype::plusAx >() ) - && ( r != atype::plusAtx >() ) - && ( r != tRn) - && ( r != tCn) - ) return false; - } - return true;} - -bool C_args::IsBilinearOperator() const { - //int n=largs.size(); - aType tRn =atype* >(); - aType tCn =atype* >(); - for (const_iterator i=largs.begin(); i != largs.end();i++) - { - C_F0 c= *i; - //Expression e=c; - aType r=c.left(); - if ( ( r!= atype() ) - && ( r != atype() ) - && ( r != tRn) - && ( r != tCn) - ) return false; - } - return true;} +bool C_args::IsLinearOperator( ) const { + // int n=largs.size(); + aType tRn = atype< KN< R > * >( ); + aType tCn = atype< KN< Complex > * >( ); + for (const_iterator i = largs.begin( ); i != largs.end( ); i++) { + C_F0 c = *i; + // Expression e=c; + aType r = c.left( ); + if ((r != atype< const FormLinear * >( )) && (r != atype< const BC_set * >( )) && (r != atype< RNM_VirtualMatrix< R >::plusAx >( )) && (r != atype< RNM_VirtualMatrix< R >::plusAtx >( )) && + (r != atype< RNM_VirtualMatrix< Complex >::plusAx >( )) && (r != atype< RNM_VirtualMatrix< Complex >::plusAtx >( )) && (r != tRn) && (r != tCn)) + return false; + } + return true; +} + +bool C_args::IsBilinearOperator( ) const { + // int n=largs.size(); + aType tRn = atype< Matrice_Creuse< R > * >( ); + aType tCn = atype< Matrice_Creuse< Complex > * >( ); + for (const_iterator i = largs.begin( ); i != largs.end( ); i++) { + C_F0 c = *i; + // Expression e=c; + aType r = c.left( ); + if ((r != atype< const FormBilinear * >( )) && (r != atype< const BC_set * >( )) && (r != tRn) && (r != tCn)) return false; + } + return true; +} +void SetArgsFormLinear(const ListOfId *lid, int ordre) { + // the local parameter are + // ordre ==2 => bilinear form unknown (newU_) and test function (newV_) + // ordre ==1 => linear form just test function (newV_) + // --------------------- + throwassert(ordre > 0 && ordre <= 2 && (lid || lid->size( ) > 0)); + const ListOfId &l(*lid); + int nb = l.size( ); + int n = 0; + C_F0 type, init; + int nbarray = 0; + int nbcompo_begin = 0; // variable for chevron <> for problem/solve + int nbcompo_end = 0; // variable for chevron <> for problem/solve + aType uh = atype< const finconnue * >( ), vh = atype< const ftest * >( ); + + for (int i = 0; i < nb; i++) { + if (l[i].compo_begin == true) nbcompo_begin++; + if (l[i].compo_end == true) nbcompo_end++; + } -void SetArgsFormLinear(const ListOfId *lid,int ordre) -{ - // the local parameter are - // ordre ==2 => bilinear form unknown (newU_) and test function (newV_) - // ordre ==1 => linear form just test function (newV_) - // --------------------- - throwassert(ordre >0 && ordre <=2 && (lid || lid->size()>0 ) ); - const ListOfId & l(*lid); - int nb=l.size(); - int n=0; - C_F0 type,init; - int nbarray=0; - int nbcompo_begin=0; // variable for chevron <> for problem/solve - int nbcompo_end=0; // variable for chevron <> for problem/solve - aType uh=atype(),vh=atype(); - - for (int i=0;i' is " << nbcompo_end << endl; - CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); - } - else{ - if( nbcompo_begin == 0 && nbcompo_end == 0){ - if(nbarray!=ordre && nbarray >0){ - { cerr << " form " << ordre << " == " << nbarray << " Nb of Array "<' is " << nbcompo_end << endl; + CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); + } else { + if (nbcompo_begin == 0 && nbcompo_end == 0) { + if (nbarray != ordre && nbarray > 0) { + { + cerr << " form " << ordre << " == " << nbarray << " Nb of Array " << endl; + CompileError(" Must have 1 or 2 array, one for unknown functions, one for test functions"); } + } } + } - // create the array - ListOfId * array[nbarray]; - nbarray=0; // reinit nbarray - for (int i=0;i2){ - cout << "nbarray = " << nbarray << endl; - cout << "l.size()= " << l.size() << endl; + // create the array + ListOfId *array[nbarray]; + nbarray = 0; // reinit nbarray + for (int i = 0; i < nb; i++) { + if (l[i].r == 0 && l[i].re == 0 && l[i].id) + n++; + else if (l[i].array) { + array[nbarray] = l[i].array; + nbarray++; } + } - if( nbcompo_begin != nbcompo_end && (nbcompo_begin == 0 || nbcompo_begin == 2) ){ - cerr << "Try to use composite FESpace for a form " << ordre << " == " << endl; - cerr << " Nb of symbol '<' is " << nbcompo_begin << endl; - cerr << " Nb of symbol '>' is " << nbcompo_end << endl; - CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); - } + if (verbosity > 2) { + cout << "nbarray = " << nbarray << endl; + cout << "l.size()= " << l.size( ) << endl; + } - if( nbcompo_begin>0 && nbcompo_end>0 && nbarray >0 && n ==0 ){ - ffassert( nbcompo_begin == 2 ); - ffassert( n == 0 ); - // composite FESpace : Est ce que l'on peut le faire uniquement pour le problem? - ffassert(ordre == 2); // todo form linear - if(ordre == 2){ - ListOfId * new_array[nbarray]; // same as array need to delete - int first_index_compo[nbcompo_begin+1]; - { - int index_compo=0; - for (int i=0;isize();iNewID(uh,idi.id,C_F0(newU_(counter_index_FEbase),uh)); - else // test function - currentblock->NewID(vh,idi.id,C_F0(newV_(counter_index_FEbase),vh)); - - counter_index_FEbase++; - } - else - CompileError(" Just Variable in array parameter "); - } - } - } - } - } - else if (nbarray >0 && n==0) - { // + if (nbcompo_begin != nbcompo_end && (nbcompo_begin == 0 || nbcompo_begin == 2)) { + cerr << "Try to use composite FESpace for a form " << ordre << " == " << endl; + cerr << " Nb of symbol '<' is " << nbcompo_begin << endl; + cerr << " Nb of symbol '>' is " << nbcompo_end << endl; + CompileError(" Must have have 2 '< ... >' , one for unknown functions, one for test functions for composite form"); + } - if(nbarray!=ordre) - { cerr << " form " << ordre << " == " << nbarray << " Nb of Array "<size();iNewID(uh,idi.id,C_F0(newU_(i),uh)); - else // test function - currentblock->NewID(vh,idi.id,C_F0(newV_(i),vh)); - } - else - CompileError(" Just Variable in array parameter "); + if (nbcompo_begin > 0 && nbcompo_end > 0 && nbarray > 0 && n == 0) { + ffassert(nbcompo_begin == 2); + ffassert(n == 0); + // composite FESpace : Est ce que l'on peut le faire uniquement pour le problem? + ffassert(ordre == 2); // todo form linear + if (ordre == 2) { + ListOfId *new_array[nbarray]; // same as array need to delete + int first_index_compo[nbcompo_begin + 1]; + { + int index_compo = 0; + for (int i = 0; i < nbarray; i++) { + new_array[i] = l[i].array; + if (l[i].compo_begin) { + first_index_compo[index_compo] = i; + index_compo++; + } } - } - else if (nbarray==0) - { // a supprimer to remove in case of bilinear - - SHOWVERB(cout << "SetArgs:: form set parameter " << endl); - if( ! ( ordre==1 || n%2==0) ) - CompileError(" Error in test or unknown function (odd number of function) "); - ffassert( ordre==1 || n%2==0); - int nn=ordre==1 ? 0 : n/2; // order == 1 => no unknown function just test function + ffassert(index_compo == nbcompo_begin); + first_index_compo[index_compo] = nbarray; + } - for (int i=0,j=0;iNewID(uh,l[i].id,C_F0(newU_(j%nn),uh)); - else - currentblock->NewID(vh,l[i].id,C_F0(newV_(j%nn),vh)); - j++; + for (int index = 0; index < nbcompo_begin; index++) { + int counter_index_FEbase = 0; // reinit this counter for ftest + for (int k = first_index_compo[index]; k < first_index_compo[index + 1]; k++) { + for (int i = 0, iend = new_array[k]->size( ); i < iend; i++) { + const UnId &idi((*new_array[k])[i].id); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + if (index == 0) // unknow function just in case of bilinear form + currentblock->NewID(uh, idi.id, C_F0(newU_(counter_index_FEbase), uh)); + else // test function + currentblock->NewID(vh, idi.id, C_F0(newV_(counter_index_FEbase), vh)); + + counter_index_FEbase++; + } else + CompileError(" Just Variable in array parameter "); + } } + } } - else - { - CompileError(" Sorry you mixte formulation with and without array "); - } + } else if (nbarray > 0 && n == 0) { // + + if (nbarray != ordre) { + cerr << " form " << ordre << " == " << nbarray << " Nb of Array " << endl; + CompileError(" Must have 1 or 2 array, one for unknown functions, one for test functions"); + } + for (int k = 0; k < ordre; k++) + for (int i = 0, iend = array[k]->size( ); i < iend; i++) { + const UnId &idi((*array[k])[i].id); + if (idi.r == 0 && idi.re == 0 && idi.array == 0) { + if (k == ordre - 2) // unknow function just in case of bilinear form + currentblock->NewID(uh, idi.id, C_F0(newU_(i), uh)); + else // test function + currentblock->NewID(vh, idi.id, C_F0(newV_(i), vh)); + } else + CompileError(" Just Variable in array parameter "); + } + } else if (nbarray == 0) { // a supprimer to remove in case of bilinear + + SHOWVERB(cout << "SetArgs:: form set parameter " << endl); + if (!(ordre == 1 || n % 2 == 0)) CompileError(" Error in test or unknown function (odd number of function) "); + ffassert(ordre == 1 || n % 2 == 0); + int nn = ordre == 1 ? 0 : n / 2; // order == 1 => no unknown function just test function + + for (int i = 0, j = 0; i < nb; i++) + if (l[i].r == 0 && l[i].re == 0 && l[i].array == 0) { + SHOWVERB(cout << " " << l[i].id << " " << (j < nn) << endl); + if (j < nn) + currentblock->NewID(uh, l[i].id, C_F0(newU_(j % nn), uh)); + else + currentblock->NewID(vh, l[i].id, C_F0(newV_(j % nn), vh)); + j++; + } + } else { + CompileError(" Sorry you mixte formulation with and without array "); + } } -const Fem2D::GQuadratureFormular & CDomainOfIntegration::FIV(Stack stack) const -{ - using namespace Fem2D; - if (nargs[8]) return *GetAny *>((*nargs[8])(stack)); - int exact = 5; - if (nargs[2]) exact= GetAny((*nargs[2])(stack))-1; - GQuadratureFormular *qf=QF_Simplex(exact);//QF_Tria_exact(exact); - if(verbosity>99 && qf ) cout << " QF Tet n:" << qf->n << " exact = " << exact << endl; - if(qf) return *qf; - /* - if( QuadratureFormular_T_1.exact >= exact ) return QuadratureFormular_T_1; - if( QuadratureFormular_T_2.exact >= exact ) return QuadratureFormular_T_2; - if( QuadratureFormular_T_5.exact >= exact ) return QuadratureFormular_T_5; - if( QuadratureFormular_T_7.exact >= exact ) return QuadratureFormular_T_7; - if( QuadratureFormular_T_9.exact >= exact ) return QuadratureFormular_T_9; - */ - static long count = 0; - if(verbosity > 1 && count++ < 5) - cerr << "Warning : Max Order of the Quadrature Formular Tet is 6 and expect: " << exact+1 - << endl; - // ExecError(" We find no Quadrature Formular on Tet for this order: too high"); - return QuadratureFormular_Tet_5; +const Fem2D::GQuadratureFormular< R3 > &CDomainOfIntegration::FIV(Stack stack) const { + using namespace Fem2D; + if (nargs[8]) return *GetAny< const Fem2D::GQuadratureFormular< R3 > * >((*nargs[8])(stack)); + int exact = 5; + if (nargs[2]) exact = GetAny< long >((*nargs[2])(stack)) - 1; + GQuadratureFormular< R3 > *qf = QF_Simplex< R3 >(exact); // QF_Tria_exact(exact); + if (verbosity > 99 && qf) cout << " QF Tet n:" << qf->n << " exact = " << exact << endl; + if (qf) return *qf; + /* + if( QuadratureFormular_T_1.exact >= exact ) return QuadratureFormular_T_1; + if( QuadratureFormular_T_2.exact >= exact ) return QuadratureFormular_T_2; + if( QuadratureFormular_T_5.exact >= exact ) return QuadratureFormular_T_5; + if( QuadratureFormular_T_7.exact >= exact ) return QuadratureFormular_T_7; + if( QuadratureFormular_T_9.exact >= exact ) return QuadratureFormular_T_9; + */ + static long count = 0; + if (verbosity > 1 && count++ < 5) cerr << "Warning : Max Order of the Quadrature Formular Tet is 6 and expect: " << exact + 1 << endl; + // ExecError(" We find no Quadrature Formular on Tet for this order: too high"); + return QuadratureFormular_Tet_5; } -const Fem2D::QuadratureFormular & CDomainOfIntegration::FIT(Stack stack) const -{ - using namespace Fem2D; - if (nargs[0]) return *GetAny((*nargs[0])(stack)); - int exact = 5; - if (nargs[2]) exact= GetAny((*nargs[2])(stack))-1; - QuadratureFormular *qf=QF_Simplex(exact);//QF_Tria_exact(exact); - if(verbosity>99 && qf ) cout << " QF Tria n:" << qf->n << " exact = " << exact << endl; - if(qf) return *qf; - /* - if( QuadratureFormular_T_1.exact >= exact ) return QuadratureFormular_T_1; - if( QuadratureFormular_T_2.exact >= exact ) return QuadratureFormular_T_2; - if( QuadratureFormular_T_5.exact >= exact ) return QuadratureFormular_T_5; - if( QuadratureFormular_T_7.exact >= exact ) return QuadratureFormular_T_7; - if( QuadratureFormular_T_9.exact >= exact ) return QuadratureFormular_T_9; - */ - cerr << " Order of the Quadature Formular: order = " << exact+1 << " exact = " << exact << endl; - ExecError("Sorry, we find no Quadrature Formular on Triangle for this order: too high."); - return QuadratureFormular_T_1; +const Fem2D::QuadratureFormular &CDomainOfIntegration::FIT(Stack stack) const { + using namespace Fem2D; + if (nargs[0]) return *GetAny< const Fem2D::QuadratureFormular * >((*nargs[0])(stack)); + int exact = 5; + if (nargs[2]) exact = GetAny< long >((*nargs[2])(stack)) - 1; + QuadratureFormular *qf = QF_Simplex< R2 >(exact); // QF_Tria_exact(exact); + if (verbosity > 99 && qf) cout << " QF Tria n:" << qf->n << " exact = " << exact << endl; + if (qf) return *qf; + /* + if( QuadratureFormular_T_1.exact >= exact ) return QuadratureFormular_T_1; + if( QuadratureFormular_T_2.exact >= exact ) return QuadratureFormular_T_2; + if( QuadratureFormular_T_5.exact >= exact ) return QuadratureFormular_T_5; + if( QuadratureFormular_T_7.exact >= exact ) return QuadratureFormular_T_7; + if( QuadratureFormular_T_9.exact >= exact ) return QuadratureFormular_T_9; + */ + cerr << " Order of the Quadature Formular: order = " << exact + 1 << " exact = " << exact << endl; + ExecError("Sorry, we find no Quadrature Formular on Triangle for this order: too high."); + return QuadratureFormular_T_1; } -const Fem2D::QuadratureFormular1d & CDomainOfIntegration::FIE(Stack stack) const -{ - using namespace Fem2D; - if (nargs[1]) return *GetAny((*nargs[1])(stack)); - int exact = 5; - if (nargs[2]) exact= GetAny((*nargs[2])(stack))-1; - QuadratureFormular1d *qf=QF_Simplex(exact);//QF_1d_exact(exact); - if(verbosity>99 && qf ) cout << " QF 1d n:" << qf->n << " exact = " << exact << endl; - if(qf) return *qf; - /* - if( 1 >= exact ) return QF_GaussLegendre1; - if( 3 >= exact ) return QF_GaussLegendre2; - if( 5 >= exact ) return QF_GaussLegendre3; - if( 7 >= exact ) return QF_GaussLegendre4; - if( 9 >= exact ) return QF_GaussLegendre5; - */ - cerr << " Ordre of the Integration Formular on Edge, order = " << exact+1 << " exact = " << exact << endl; - ExecError(" We find no Quadrature Formular on Edge for this order: too high."); - return QF_GaussLegendre1; +const Fem2D::QuadratureFormular1d &CDomainOfIntegration::FIE(Stack stack) const { + using namespace Fem2D; + if (nargs[1]) return *GetAny< const Fem2D::QuadratureFormular1d * >((*nargs[1])(stack)); + int exact = 5; + if (nargs[2]) exact = GetAny< long >((*nargs[2])(stack)) - 1; + QuadratureFormular1d *qf = QF_Simplex< R1 >(exact); // QF_1d_exact(exact); + if (verbosity > 99 && qf) cout << " QF 1d n:" << qf->n << " exact = " << exact << endl; + if (qf) return *qf; + /* + if( 1 >= exact ) return QF_GaussLegendre1; + if( 3 >= exact ) return QF_GaussLegendre2; + if( 5 >= exact ) return QF_GaussLegendre3; + if( 7 >= exact ) return QF_GaussLegendre4; + if( 9 >= exact ) return QF_GaussLegendre5; + */ + cerr << " Ordre of the Integration Formular on Edge, order = " << exact + 1 << " exact = " << exact << endl; + ExecError(" We find no Quadrature Formular on Edge for this order: too high."); + return QF_GaussLegendre1; } - namespace Fem2D { - - // general template - template void AssembleLinearForm(Stack stack,const Mesh & Th,const FESpace & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize); - - template void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize); - - template void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize); - - template void AssembleLinearForm(Stack stack,const Mesh & Th,const FESpace & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize); - - template void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse & A, const FormBilinear * b, int * mpirankandsize); - - template void AssembleBilinearForm(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceMap & A, const FormBilinear * b, int * mpirankandsize); - - - - /////// 2d case - // instantation for type double - template bool AssembleVarForm,Mesh,FESpace,FESpace >(Stack stack,const Mesh & Th, - const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,Mesh,FESpace,FESpace>(Stack stack,const Mesh & Th, - const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - // instantation for type complex - template bool AssembleVarForm,Mesh,FESpace,FESpace>(Stack stack,const Mesh & Th, - const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - - template bool AssembleVarForm,Mesh,FESpace,FESpace >(Stack stack,const Mesh & Th, - const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - - template void AssembleBC(Stack stack,const Mesh & Th,const FESpace & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - - /////// 3D volume case - // instantation for type double - template bool AssembleVarForm,Mesh3,FESpace3,FESpace3>(Stack stack,const Mesh3 & Th, - const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,Mesh3,FESpace3,FESpace3 >(Stack stack,const Mesh3 & Th, - const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const Mesh3 & Th,const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,Mesh3,FESpace3,FESpace3>(Stack stack,const Mesh3 & Th, - const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,Mesh3,FESpace3,FESpace3>(Stack stack,const Mesh3 & Th, - const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const Mesh3 & Th,const FESpace3 & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - - - - - - /////// 3D surface case - // instantation for type double - - template bool AssembleVarForm,MeshS,FESpaceS,FESpaceS>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpaceS,FESpaceS>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshS,FESpaceS,FESpaceS>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpaceS,FESpaceS>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - - /////// 3D curve - // instantation for type double - - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceL>(Stack stack,const FESpaceL::Mesh & Th, - const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - /////// 3D curve / 2D on meshL - // instantation for type double - - template bool AssembleVarForm,MeshL,FESpaceL,FESpace>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpace>(Stack stack,const FESpaceL::Mesh & Th, - const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshL,FESpaceL,FESpace>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpace>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpace & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - /////// 2D / 3D curve on meshL - // instantation for type double - - template bool AssembleVarForm,MeshL,FESpace,FESpaceL>(Stack stack,const MeshL & Th, - const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpace,FESpaceL>(Stack stack,const MeshL & Th, - const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshL,FESpace,FESpaceL>(Stack stack,const MeshL & Th, - const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpace,FESpaceL>(Stack stack,const MeshL & Th, - const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpace & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tg, int * mpirankandsize); - /////// 3D Surf / 3D volume on meshS - // instantation for type double - - template bool AssembleVarForm,MeshS,FESpaceS,FESpace3>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpaceS,FESpace3>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshS,FESpaceS,FESpace3>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpaceS,FESpace3>(Stack stack,const MeshS & Th, - const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpaceS & Uh,const FESpace3 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - /////// 3D volume / 3D Surf on meshS - // instantation for type double - - template bool AssembleVarForm,MeshS,FESpace3,FESpaceS>(Stack stack,const MeshS & Th, - const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpace3,FESpaceS>(Stack stack,const MeshS & Th, - const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshS,FESpace3,FESpaceS>(Stack stack,const MeshS & Th, - const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshS,FESpace3,FESpaceS>(Stack stack,const MeshS & Th, - const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshS & Th,const FESpace3 & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - /////// 3D curve / 3D Surf on meshL - // instantation for type double - - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceS>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceS>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceS>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceL,FESpaceS>(Stack stack,const MeshL & Th, - const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceL & Uh,const FESpaceS & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - /////// 3D Surf / 3D curve on meshL - // instantation for type double - - template bool AssembleVarForm,MeshL,FESpaceS,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceS,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - - // instantation for type complex - template bool AssembleVarForm,MeshL,FESpaceS,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,const list &largs , int * mpirankandsize); - template bool AssembleVarForm,MeshL,FESpaceS,FESpaceL>(Stack stack,const MeshL & Th, - const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceMap * A,KN_ * B,const list &largs , int * mpirankandsize); - template void AssembleBC(Stack stack,const MeshL & Th,const FESpaceS & Uh,const FESpaceL & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const list &largs , double tgv, int * mpirankandsize); - -} - -template class Call_FormLinear; -template class Call_FormLinear; -template class Call_FormLinear; -template class Call_FormLinear; -template class Call_FormLinear; // Morice: added vector FESpace (composite FESpace) - -template class Call_FormBilinear; -template class Call_FormBilinear; -template class Call_FormBilinear; -template class Call_FormBilinear; - -template class Call_FormBilinear; // 3D curve / 3D Surf on meshL and bem -template class Call_FormBilinear; // 3D Surf / 3D curve on meshL -template class Call_FormBilinear; // 3D curve / 2D on meshL -template class Call_FormBilinear; // 2D / 3D curve on meshL -template class Call_FormBilinear; // 3D Surf / 3D volume on meshS -template class Call_FormBilinear; // 3D volume / 3D Surf on meshS -template class Call_FormBilinear; - -template class Call_CompositeFormBilinear; // Morice: added vector FESpace (composite FESpace) + // general template + template void AssembleLinearForm< double >(Stack stack, const Mesh &Th, const FESpace &Vh, KN_< double > *B, const FormLinear *const l, int *mpirankandsize); + + template void AssembleBilinearForm< double >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< double > &A, const FormBilinear *b, int *mpirankandsize); + + template void AssembleBilinearForm< double >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceMap< double > &A, const FormBilinear *b, int *mpirankandsize); + + template void AssembleLinearForm< Complex >(Stack stack, const Mesh &Th, const FESpace &Vh, KN_< Complex > *B, const FormLinear *const l, int *mpirankandsize); + + template void AssembleBilinearForm< Complex >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< Complex > &A, const FormBilinear *b, int *mpirankandsize); + + template void AssembleBilinearForm< Complex >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceMap< Complex > &A, const FormBilinear *b, int *mpirankandsize); + + /////// 2d case + // instantation for type double + template bool AssembleVarForm< double, MatriceCreuse< double >, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + + template bool AssembleVarForm< Complex, MatriceMap< Complex >, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + + template void AssembleBC< Complex, Mesh, FESpace, FESpace >(Stack stack, const Mesh &Th, const FESpace &Uh, const FESpace &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + /////// 3D volume case + // instantation for type double + template bool AssembleVarForm< double, MatriceCreuse< double >, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, Mesh3, FESpace3, FESpace3 >(Stack stack, const Mesh3 &Th, const FESpace3 &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + /////// 3D surface case + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshS, FESpaceS, FESpaceS >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + /////// 3D curve + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshL, FESpaceL, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshL, FESpaceL, FESpaceL >(Stack stack, const FESpaceL::Mesh &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, + MatriceMap< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshL, FESpaceL, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshL, FESpaceL, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshL, FESpaceL, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshL, FESpaceL, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + /////// 3D curve / 2D on meshL + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshL, FESpaceL, FESpace >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceCreuse< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshL, FESpaceL, FESpace >(Stack stack, const FESpaceL::Mesh &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, + MatriceMap< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshL, FESpaceL, FESpace >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshL, FESpaceL, FESpace >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshL, FESpaceL, FESpace >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshL, FESpaceL, FESpace >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpace &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + /////// 2D / 3D curve on meshL + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshL, FESpace, FESpaceL >(Stack stack, const MeshL &Th, const FESpace &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tg, int *mpirankandsize); + /////// 3D Surf / 3D volume on meshS + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshS, FESpaceS, FESpace3 >(Stack stack, const MeshS &Th, const FESpaceS &Uh, const FESpace3 &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + /////// 3D volume / 3D Surf on meshS + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshS, FESpace3, FESpaceS >(Stack stack, const MeshS &Th, const FESpace3 &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + /////// 3D curve / 3D Surf on meshL + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshL, FESpaceL, FESpaceS >(Stack stack, const MeshL &Th, const FESpaceL &Uh, const FESpaceS &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + /////// 3D Surf / 3D curve on meshL + // instantation for type double + + template bool AssembleVarForm< double, MatriceCreuse< double >, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, + MatriceCreuse< double > *A, KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< double, MatriceMap< double >, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceMap< double > *A, + KN_< double > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< double, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< double > *A, KN_< double > *B, + KN_< double > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + + // instantation for type complex + template bool AssembleVarForm< Complex, MatriceCreuse< Complex >, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, + MatriceCreuse< Complex > *A, KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template bool AssembleVarForm< Complex, MatriceMap< Complex >, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceMap< Complex > *A, + KN_< Complex > *B, const list< C_F0 > &largs, int *mpirankandsize); + template void AssembleBC< Complex, MeshL, FESpaceS, FESpaceL >(Stack stack, const MeshL &Th, const FESpaceS &Uh, const FESpaceL &Vh, bool sym, MatriceCreuse< Complex > *A, KN_< Complex > *B, + KN_< Complex > *X, const list< C_F0 > &largs, double tgv, int *mpirankandsize); + +} // namespace Fem2D + +template class Call_FormLinear< v_fes >; +template class Call_FormLinear< v_fes3 >; +template class Call_FormLinear< v_fesS >; +template class Call_FormLinear< v_fesL >; +template class Call_FormLinear< vect_generic_v_fes >; // Morice: added vector FESpace (composite FESpace) + +template class Call_FormBilinear< v_fes, v_fes >; +template class Call_FormBilinear< v_fes3, v_fes3 >; +template class Call_FormBilinear< v_fesS, v_fesS >; +template class Call_FormBilinear< v_fesL, v_fesL >; + +template class Call_FormBilinear< v_fesL, v_fesS >; // 3D curve / 3D Surf on meshL and bem +template class Call_FormBilinear< v_fesS, v_fesL >; // 3D Surf / 3D curve on meshL +template class Call_FormBilinear< v_fesL, v_fes >; // 3D curve / 2D on meshL +template class Call_FormBilinear< v_fes, v_fesL >; // 2D / 3D curve on meshL +template class Call_FormBilinear< v_fesS, v_fes3 >; // 3D Surf / 3D volume on meshS +template class Call_FormBilinear< v_fes3, v_fesS >; // 3D volume / 3D Surf on meshS +template class Call_FormBilinear< v_fesS, v_fes >; + +template class Call_CompositeFormBilinear< vect_generic_v_fes, vect_generic_v_fes >; // Morice: added vector FESpace (composite FESpace) diff --git a/src/fflib/problem.hpp b/src/fflib/problem.hpp index 0833d7ae6..abf40bba2 100644 --- a/src/fflib/problem.hpp +++ b/src/fflib/problem.hpp @@ -30,80 +30,85 @@ #include namespace FreeFempp { -template -class TypeVarForm; + template< class R > + class TypeVarForm; } extern Block *currentblock; -template class Matrice_Creuse; -//template using MatriceMap=map,K>; -template using MatriceMap=HashMatrix; +template< class K > +class Matrice_Creuse; +// template using MatriceMap=map,K>; +template< class K > +using MatriceMap = HashMatrix< int, K >; -//template class MatriceCreuse; -namespace Fem2D { - template class SolveGCPrecon; - template class SolveGMRESPrecon; - template class SolveGMRESDiag; -// int IsoLineK(double *f,R2 *Q,double eps); +// template class MatriceCreuse; +namespace Fem2D { + template< class K > + class SolveGCPrecon; + template< class K > + class SolveGMRESPrecon; + template< class K > + class SolveGMRESDiag; + // int IsoLineK(double *f,R2 *Q,double eps); -} +} // namespace Fem2D #include "P1IsoValue.hpp" - -template class SolveGCDiag; +template< class K > +class SolveGCDiag; class Plot; -class v_fes; // [[file:lgfem.hpp::v_fes]] +class v_fes; // [[file:lgfem.hpp::v_fes]] // real [[file:lgfem.hpp::FEbase]] using [[file:lgfem.hpp::v_fes]] -typedef FEbase * pferbase ; // <> -typedef FEbaseArray * pferbasearray ; // <> -typedef pair pfer ; // <> -typedef pair pferarray ; // <> +typedef FEbase< double, v_fes > *pferbase; // <> +typedef FEbaseArray< double, v_fes > *pferbasearray; // <> +typedef pair< pferbase, int > pfer; // <> +typedef pair< pferbasearray, int > pferarray; // <> // complex [[file:lgfem.hpp::FEbase]] using [[file:lgfem.hpp::v_fes]] -typedef FEbase * pfecbase ; // <> -typedef FEbaseArray * pfecbasearray ; // <> -typedef pair pfec ; // <> -typedef pair pfecarray ; // <> - - -//typedef pair pmesharray ; - -typedef LinearComb Finconnue; -typedef LinearComb Ftest; -typedef LinearComb,C_F0> Foperator; - -inline int intOp(const MGauche &i) {return i.second;} -inline int intOp(const MDroit &i) {return i.second;} -inline int intOp(pair & p) {return Max(intOp(p.first),intOp(p.second));} - -inline void SetOp(KN_ & d,const MGauche &i) - { d[i.second% last_operatortype]=true;} -inline void SetOp(KN_ & d,const MDroit &i) - { d[(int) i.second % last_operatortype]=true;} -inline void SetOp(KN_ & d,const pair & p) - {SetOp(d,p.first);SetOp(d,p.second);} - -inline unsigned int GetDiffOp(const MGauche &i, int& lastop) - {int op=(i.second% last_operatortype); - lastop=max(lastop,op) ; - return 1< &p, int& lastop) -{ return GetDiffOp(p.first,lastop)|GetDiffOp(p.second,lastop);} - -typedef const Finconnue finconnue; -typedef const Ftest ftest; -typedef const Foperator foperator; +typedef FEbase< Complex, v_fes > *pfecbase; // <> +typedef FEbaseArray< Complex, v_fes > *pfecbasearray; // <> +typedef pair< pfecbase, int > pfec; // <> +typedef pair< pfecbasearray, int > pfecarray; // <> + +// typedef pair pmesharray ; + +typedef LinearComb< MGauche, C_F0 > Finconnue; +typedef LinearComb< MDroit, C_F0 > Ftest; +typedef LinearComb< pair< MGauche, MDroit >, C_F0 > Foperator; + +inline int intOp(const MGauche &i) { return i.second; } +inline int intOp(const MDroit &i) { return i.second; } +inline int intOp(pair< MGauche, MDroit > &p) { return Max(intOp(p.first), intOp(p.second)); } + +inline void SetOp(KN_< bool > &d, const MGauche &i) { d[i.second % last_operatortype] = true; } +inline void SetOp(KN_< bool > &d, const MDroit &i) { d[(int)i.second % last_operatortype] = true; } +inline void SetOp(KN_< bool > &d, const pair< MGauche, MDroit > &p) { + SetOp(d, p.first); + SetOp(d, p.second); +} + +inline unsigned int GetDiffOp(const MGauche &i, int &lastop) { + int op = (i.second % last_operatortype); + lastop = max(lastop, op); + return 1 << op; +} +inline unsigned int GetDiffOp(const MDroit &i, int &lastop) { + int op = (i.second % last_operatortype); + lastop = max(lastop, op); + return 1 << op; +} +inline unsigned int GetDiffOp(const pair< MGauche, MDroit > &p, int &lastop) { return GetDiffOp(p.first, lastop) | GetDiffOp(p.second, lastop); } + +typedef const Finconnue finconnue; +typedef const Ftest ftest; +typedef const Foperator foperator; Expression IsFebaseArray(Expression f); -void SetArgsFormLinear(const ListOfId *lid,int ordre); +void SetArgsFormLinear(const ListOfId *lid, int ordre); /* inline ostream & operator<<(ostream & f,const TypeSolveMat & tm) { @@ -121,1671 +126,1587 @@ inline ostream & operator<<(ostream & f,const TypeSolveMat & tm) } */ -class C_args: public E_F0mps {public: - typedef const C_args * Result; - list largs; - typedef list ::const_iterator const_iterator ; +class C_args : public E_F0mps { + public: + typedef const C_args *Result; + list< C_F0 > largs; + typedef list< C_F0 >::const_iterator const_iterator; // il faut expendre - C_args() :largs(){} - C_args(C_F0 c) : largs() { if(!c.Zero() )largs.push_back(c);} - C_args( const basicAC_F0 & args) :largs(){ - int n=args.size(); - for (int i=0;i< n;i++) - { - if(args[i].Zero()) ; // skip zero term ... - else if (args[i].left() == atype()) - { - const C_args * a = dynamic_cast(args[i].LeftValue()); - if (a == NULL) printf("dynamic_cast error\n"); - for (list::const_iterator i=a->largs.begin();i!=a->largs.end();i++) - if( ! i->Zero()) // skip Zero term - largs.push_back(*i); - } - else - largs.push_back(args[i]); - };} - static ArrayOfaType typeargs() { return ArrayOfaType(true);} - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - - static E_F0 * f(const basicAC_F0 & args) { return new C_args(args);} - bool Zero() const { return largs.empty();} // BIG WARNING April and wrong functon FH v 3.60 ....... - bool IsLinearOperator() const; - bool IsBilinearOperator() const; - bool IsBemBilinearOperator() const; - bool IsMixedBilinearOperator() const; + C_args( ) : largs( ) {} + C_args(C_F0 c) : largs( ) { + if (!c.Zero( )) largs.push_back(c); + } + C_args(const basicAC_F0 &args) : largs( ) { + int n = args.size( ); + for (int i = 0; i < n; i++) { + if (args[i].Zero( )) + ; // skip zero term ... + else if (args[i].left( ) == atype< const C_args * >( )) { + const C_args *a = dynamic_cast< const C_args * >(args[i].LeftValue( )); + if (a == NULL) printf("dynamic_cast error\n"); + for (list< C_F0 >::const_iterator i = a->largs.begin( ); i != a->largs.end( ); i++) + if (!i->Zero( )) // skip Zero term + largs.push_back(*i); + } else + largs.push_back(args[i]); + }; + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(true); } + AnyType operator( )(Stack) const { return SetAny< const C_args * >(this); } + operator aType( ) const { return atype< const C_args * >( ); } + + static E_F0 *f(const basicAC_F0 &args) { return new C_args(args); } + bool Zero( ) const { return largs.empty( ); } // BIG WARNING April and wrong functon FH v 3.60 ....... + bool IsLinearOperator( ) const; + bool IsBilinearOperator( ) const; + bool IsBemBilinearOperator( ) const; + bool IsMixedBilinearOperator( ) const; }; -class C_args_minus: public C_args {public: - C_args_minus( const basicAC_F0 & args) { - int n=args.size(); - ffassert(n==2); - if (args[0].left() == atype()) - { - const C_args * a = dynamic_cast(args[0].LeftValue()); - ffassert(a); - for (list::const_iterator i=a->largs.begin();i!=a->largs.end();i++) - largs.push_back(*i); - } - else +class C_args_minus : public C_args { + public: + C_args_minus(const basicAC_F0 &args) { + int n = args.size( ); + ffassert(n == 2); + if (args[0].left( ) == atype< const C_args * >( )) { + const C_args *a = dynamic_cast< const C_args * >(args[0].LeftValue( )); + ffassert(a); + for (list< C_F0 >::const_iterator i = a->largs.begin( ); i != a->largs.end( ); i++) largs.push_back(*i); + } else largs.push_back(args[0]); - largs.push_back(C_F0(TheOperators,"-",args[1])); - } + largs.push_back(C_F0(TheOperators, "-", args[1])); + } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),true);} - static E_F0 * f(const basicAC_F0 & args) { return new C_args_minus(args);} + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const C_args * >( ), true); } + static E_F0 *f(const basicAC_F0 &args) { return new C_args_minus(args); } }; -bool isVF(const list & largs); - -template -class Minus_Form: public E_F0mps {public: - typedef const F * Result; - static ArrayOfaType typeargs() { return ArrayOfaType(atype());} - static E_F0 * f(const basicAC_F0 & args) { - int n=args.size(); - ffassert(n==1); - aType tF=atype(); - ffassert(args[0].left() == tF); - Result f = dynamic_cast(args[0].LeftValue()); +bool isVF(const list< C_F0 > &largs); + +template< typename F > +class Minus_Form : public E_F0mps { + public: + typedef const F *Result; + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< const F * >( )); } + static E_F0 *f(const basicAC_F0 &args) { + int n = args.size( ); + ffassert(n == 1); + aType tF = atype< Result >( ); + ffassert(args[0].left( ) == tF); + Result f = dynamic_cast< Result >(args[0].LeftValue( )); ffassert(f); // F mf = -*f; - F * rf=new F(-*f); - return rf; + F *rf = new F(-*f); + return rf; } - operator aType () const { return atype();} + operator aType( ) const { return atype< Result >( ); } +}; +// template +class BC_set : public E_F0mps { + public: + bool complextype; + typedef const BC_set *Result; + vector< Expression > on; + vector< int > onis; + + vector< pair< int, Expression > > bc; // n� de l'inconnue+ valeur + BC_set(const basicAC_F0 &args) : on(args.size( )), onis(args.size( )) { + int n = args.size( ); + ffassert(args.named_parameter); + AC_F0::const_iterator ii = args.named_parameter->begin( ); + AC_F0::const_iterator ie = args.named_parameter->end( ); + bc.resize(args.named_parameter->size( )); + complextype = false; + for (int kk = 0; ii != ie; kk++, ii++) { + if (!BCastTo< double >(ii->second)) complextype = true; + } + ii = args.named_parameter->begin( ); + for (int kk = 0; ii != ie; kk++, ii++) { // + C_F0 x = Find(ii->first); + if (x.left( ) != atype< const finconnue * >( )) CompileError("We expected an unknown u=... of the problem"); + const finconnue *uu = dynamic_cast< const finconnue * >(x.LeftValue( )); + ffassert(uu); + const MGauche *ui = uu->simple( ); + ffassert(ui && ui->second == op_id); + if (verbosity > 9) cout << "bc=" << kk << " on : " << ii->first << " n " << ui->first << " = ? " << endl; + if (complextype) + bc[kk] = make_pair(ui->first, CastTo< Complex >(ii->second)); + else + bc[kk] = make_pair(ui->first, CastTo< double >(ii->second)); + } -}; + // sort bc / num de composante -//template -class BC_set : public E_F0mps { public: - bool complextype; - typedef const BC_set* Result; - vector on; - vector onis; + std::sort(bc.begin( ), bc.end( )); + if (verbosity > 9) + for (vector< pair< int, Expression > >::iterator i = bc.begin( ); i != bc.end( ); ++i) cout << "bc: on " << i->first << " " << i->second << endl; - vector > bc; // n� de l'inconnue+ valeur - BC_set( const basicAC_F0 & args) - :on(args.size()),onis(args.size()) - { - int n = args.size(); - ffassert(args.named_parameter); - AC_F0::const_iterator ii=args.named_parameter->begin(); - AC_F0::const_iterator ie=args.named_parameter->end(); - bc.resize(args.named_parameter->size()); - complextype=false; - for (int kk=0;ii!=ie;kk++,ii++) - { - if( ! BCastTo(ii->second)) - complextype = true; - } - ii=args.named_parameter->begin(); - for (int kk=0;ii!=ie;kk++,ii++) - { // - C_F0 x=Find(ii->first); - if (x.left() != atype()) - CompileError("We expected an unknown u=... of the problem"); - const finconnue * uu = dynamic_cast(x.LeftValue()); - ffassert(uu); - const MGauche *ui=uu->simple(); - ffassert(ui && ui->second == op_id); - if(verbosity>9) - cout <<"bc=" << kk << " on : " << ii->first << " n " << ui->first << " = ? " << endl; - if (complextype) - bc[kk]= make_pair(ui->first,CastTo(ii->second)); - else - bc[kk]= make_pair(ui->first,CastTo(ii->second)); - + for (int i = 0; i < n; i++) + if (!BCastTo< KN_< long > >(args[i])) { + on[i] = CastTo< long >(args[i]); + onis[i] = 0; + } else { + on[i] = CastTo< KN_< long > >(args[i]); + onis[i] = 1; } - - // sort bc / num de composante - - std::sort(bc.begin(),bc.end()); - if(verbosity>9) - for (vector >::iterator i=bc.begin(); i !=bc.end();++i) - cout <<"bc: on " << i->first << " " << i->second << endl; - - for (int i=0;i >(args[i])) - { - on[i]=CastTo(args[i]); - onis[i]=0; - } - else - { - on[i]=CastTo >(args[i]); - onis[i]=1; - } } // operator by copy : used for FESpace composite to renum block index of finconnue et ftest. // Remark: it used also in other part of Freefem // In this, we loose the optimal information - BC_set( const BC_set & bcold ): complextype(bcold.complextype), on(bcold.on), - onis(bcold.onis), bc(bcold.bc){} - int nbtrue(bool *ok) const - { - int k=0; - for (size_t i=0;i - void CastToK() - { - aType rr = complextype ? atype() : atype(); - if (rr == atype()) complextype= true; - if(verbosity > 10) cout << " CastToK => " << complextype < >::iterator k=bc.begin();k!=bc.end();k++) - k->second=CastTo(C_F0(k->second,rr)) ; + BC_set(const BC_set &bcold) : complextype(bcold.complextype), on(bcold.on), onis(bcold.onis), bc(bcold.bc) {} + int nbtrue(bool *ok) const { + int k = 0; + for (size_t i = 0; i < bc.size( ); i++) + if (ok[i]) k++; + return k; + } + BC_set(const BC_set &bcold, bool *ok) : complextype(bcold.complextype), on(bcold.on), onis(bcold.onis) { + bc.resize(bcold.nbtrue(ok)); + int kk = 0; + for (size_t i = 0; i < bcold.bc.size( ); i++) { + if (ok[i]) { + bc[kk].first = bcold.bc[i].first; + bc[kk].second = bcold.bc[i].second; + kk++; + } } -/* De - // ajout modif FH mai 2007 XXXXXXXXXXXXX.... - void mappingC(C_F0 (*f)(const C_F0 &)) { - - for ( vector >::iterator k=bc.begin();k!=bc.end();k++) - k->second=CastTo(C_F0(k->second,rr)) ;} - // fin ajout -*/ - static ArrayOfaType typeargs() { return ArrayOfaType(/*atype(),*/true);} // change frev 2011 FH... - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} + ffassert(kk == bc.size( )); + } - static E_F0 * f(const basicAC_F0 & args) { return new BC_set(args);} + template< class K > + void CastToK( ) { + aType rr = complextype ? atype< Complex >( ) : atype< double >( ); + if (rr == atype< Complex >( )) complextype = true; + if (verbosity > 10) cout << " CastToK => " << complextype << endl; + for (vector< pair< int, Expression > >::iterator k = bc.begin( ); k != bc.end( ); k++) k->second = CastTo< K >(C_F0(k->second, rr)); + } + /* De + // ajout modif FH mai 2007 XXXXXXXXXXXXX.... + void mappingC(C_F0 (*f)(const C_F0 &)) { + + for ( vector >::iterator k=bc.begin();k!=bc.end();k++) + k->second=CastTo(C_F0(k->second,rr)) ;} + // fin ajout + */ + static ArrayOfaType typeargs( ) { return ArrayOfaType(/*atype(),*/ true); } // change frev 2011 FH... + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + + static E_F0 *f(const basicAC_F0 &args) { return new BC_set(args); } // void init(Stack stack) const {} - }; -class CDomainOfIntegration: public E_F0mps { -public: - static const int n_name_param =12; - static basicAC_F0::name_and_type name_param[] ; +class CDomainOfIntegration : public E_F0mps { + public: + static const int n_name_param = 12; + static basicAC_F0::name_and_type name_param[]; Expression nargs[n_name_param]; - enum typeofkind { int2d=0, int1d=1, intalledges=2,intallVFedges=3, int3d = 4, intallfaces= 5,intallVFfaces=6,int0d=7,intall0d=8 } ; //3d - typeofkind kind; // 0 - int d; // 3d - int dHat;// -// bool isMeshS,isMeshL; - typedef const CDomainOfIntegration* Result; + enum typeofkind { int2d = 0, int1d = 1, intalledges = 2, intallVFedges = 3, int3d = 4, intallfaces = 5, intallVFfaces = 6, int0d = 7, intall0d = 8 }; // 3d + typeofkind kind; // 0 + int d; // 3d + int dHat; // + // bool isMeshS,isMeshL; + typedef const CDomainOfIntegration *Result; Expression Th; - Expression mapt[3],mapu[3]; - vector what; - vector whatis; // 0 -> long , 1 -> array ??? - CDomainOfIntegration( const basicAC_F0 & args,typeofkind b=int2d,int ddim=2,int ddHat=0) // 3d - :kind(b),d(ddim),dHat(ddHat==0 ? d : ddHat), Th(0), what(args.size()-1),whatis(args.size()-1) + Expression mapt[3], mapu[3]; + vector< Expression > what; + vector< int > whatis; // 0 -> long , 1 -> array ??? + CDomainOfIntegration(const basicAC_F0 &args, typeofkind b = int2d, int ddim = 2, int ddHat = 0) // 3d + : kind(b), d(ddim), dHat(ddHat == 0 ? d : ddHat), Th(0), what(args.size( ) - 1), whatis(args.size( ) - 1) { - - // isMeshS=surface; - // isMeshL=curve; - mapt[0]=mapt[1]=mapt[2]=0; // no map of intergration points for test function - mapu[0]=mapu[1]=mapu[2]=0; // no map of intergration points for unknows function - args.SetNameParam(n_name_param,name_param,nargs); - if(d==2) // 2d - Th=CastTo(args[0]); - else if(d==3 && dHat==3){ - Th=CastTo(args[0]);} - else if(d==3 && dHat==2){ - Th=CastTo(args[0]);} - else if(d==3 && dHat==1){ - Th=CastTo(args[0]);} - else ffassert(0); // a faire - int n=args.size(); - - for (int i=1;i >(args[i]) ) - { - whatis[i-1]=0; - what[i-1]=CastTo(args[i]); - } - else - { - whatis[i-1]=1; - what[i-1]=CastTo >(args[i]); - } - const E_Array *pmapt = dynamic_cast(nargs[10]); - const E_Array *pmapu = dynamic_cast(nargs[11]); - if(pmapt ) - { - if( pmapt->size() != d ) ErrorCompile("mapt bad arry size ",1); - for(int i=0; i((*pmapt)[i]); - } - if(pmapu ) - { - if( pmapu->size() != d ) ErrorCompile("mapu bad arry size ",1); - for(int i=0; i((*pmapu)[i]); + // isMeshS=surface; + // isMeshL=curve; + mapt[0] = mapt[1] = mapt[2] = 0; // no map of intergration points for test function + mapu[0] = mapu[1] = mapu[2] = 0; // no map of intergration points for unknows function + args.SetNameParam(n_name_param, name_param, nargs); + if (d == 2) // 2d + Th = CastTo< pmesh >(args[0]); + else if (d == 3 && dHat == 3) { + Th = CastTo< pmesh3 >(args[0]); + } else if (d == 3 && dHat == 2) { + Th = CastTo< pmeshS >(args[0]); + } else if (d == 3 && dHat == 1) { + Th = CastTo< pmeshL >(args[0]); + } else + ffassert(0); // a faire + int n = args.size( ); + + for (int i = 1; i < n; i++) + if (!BCastTo< KN_< long > >(args[i])) { + whatis[i - 1] = 0; + what[i - 1] = CastTo< long >(args[i]); + } else { + whatis[i - 1] = 1; + what[i - 1] = CastTo< KN_< long > >(args[i]); } + const E_Array *pmapt = dynamic_cast< E_Array * >(nargs[10]); + const E_Array *pmapu = dynamic_cast< E_Array * >(nargs[11]); + if (pmapt) { + if (pmapt->size( ) != d) ErrorCompile("mapt bad arry size ", 1); + for (int i = 0; i < d; ++i) mapt[i] = CastTo< double >((*pmapt)[i]); + } + if (pmapu) { + if (pmapu->size( ) != d) ErrorCompile("mapu bad arry size ", 1); + for (int i = 0; i < d; ++i) mapu[i] = CastTo< double >((*pmapu)[i]); + } // cout << " CDomainOfIntegration " << this << endl; } - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args);} - const Fem2D::QuadratureFormular & FIT(Stack) const ; - const Fem2D::QuadratureFormular1d & FIE(Stack) const ; - const Fem2D::GQuadratureFormular & FIV(Stack) const ; // 3d - long UseOpt(Stack s) const { return nargs[5] ? GetAny( (*(nargs[5]))(s) ) : 1;} - double binside(Stack s) const { return nargs[6] ? GetAny( (*(nargs[6]))(s) ) : 0;} // truc pour FH - bool intmortar(Stack s) const { return nargs[7] ? GetAny( (*(nargs[7])) (s) ) : 1;} // truc pour - double levelset(Stack s) const { return nargs[9] ? GetAny( (*(nargs[9]))(s) ) : 0;} - bool islevelset() const { return nargs[9] != 0; } - bool withmap() const {return mapu[0] || mapt[0]; } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh >( ), true); } // all type + AnyType operator( )(Stack) const { return SetAny< const CDomainOfIntegration * >(this); } + operator aType( ) const { return atype< const CDomainOfIntegration * >( ); } + + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args); } + const Fem2D::QuadratureFormular &FIT(Stack) const; + const Fem2D::QuadratureFormular1d &FIE(Stack) const; + const Fem2D::GQuadratureFormular< R3 > &FIV(Stack) const; // 3d + long UseOpt(Stack s) const { return nargs[5] ? GetAny< long >((*(nargs[5]))(s)) : 1; } + double binside(Stack s) const { return nargs[6] ? GetAny< double >((*(nargs[6]))(s)) : 0; } // truc pour FH + bool intmortar(Stack s) const { return nargs[7] ? GetAny< bool >((*(nargs[7]))(s)) : 1; } // truc pour + double levelset(Stack s) const { return nargs[9] ? GetAny< double >((*(nargs[9]))(s)) : 0; } + bool islevelset( ) const { return nargs[9] != 0; } + bool withmap( ) const { return mapu[0] || mapt[0]; } }; - -class CDomainOfIntegrationBorder: public CDomainOfIntegration { -public: - CDomainOfIntegrationBorder( const basicAC_F0 & args) :CDomainOfIntegration(args,int1d) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int1d);} +class CDomainOfIntegrationBorder : public CDomainOfIntegration { + public: + CDomainOfIntegrationBorder(const basicAC_F0 &args) : CDomainOfIntegration(args, int1d) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int1d); } }; -class CDomainOfIntegrationAllEdges: public CDomainOfIntegration { -public: - CDomainOfIntegrationAllEdges( const basicAC_F0 & args) :CDomainOfIntegration(args,intalledges) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,intalledges);} +class CDomainOfIntegrationAllEdges : public CDomainOfIntegration { + public: + CDomainOfIntegrationAllEdges(const basicAC_F0 &args) : CDomainOfIntegration(args, intalledges) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, intalledges); } }; -class CDomainOfIntegrationVFEdges: public CDomainOfIntegration { -public: - CDomainOfIntegrationVFEdges( const basicAC_F0 & args) :CDomainOfIntegration(args,intallVFedges) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,intallVFedges);} +class CDomainOfIntegrationVFEdges : public CDomainOfIntegration { + public: + CDomainOfIntegrationVFEdges(const basicAC_F0 &args) : CDomainOfIntegration(args, intallVFedges) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, intallVFedges); } }; // 3D Volume -class CDomainOfIntegration3d: public CDomainOfIntegration { -public: - CDomainOfIntegration3d( const basicAC_F0 & args) :CDomainOfIntegration(args,int3d,3) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int3d,3);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegration3d : public CDomainOfIntegration { + public: + CDomainOfIntegration3d(const basicAC_F0 &args) : CDomainOfIntegration(args, int3d, 3) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int3d, 3); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh3 >( ), true); } // all type }; -class CDomainOfIntegrationBorder3d: public CDomainOfIntegration { -public: - CDomainOfIntegrationBorder3d( const basicAC_F0 & args) :CDomainOfIntegration(args,int2d,3) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int2d,3);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationBorder3d : public CDomainOfIntegration { + public: + CDomainOfIntegrationBorder3d(const basicAC_F0 &args) : CDomainOfIntegration(args, int2d, 3) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int2d, 3); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh3 >( ), true); } // all type }; -class CDomainOfIntegrationAllFaces: public CDomainOfIntegration { -public: - CDomainOfIntegrationAllFaces( const basicAC_F0 & args) :CDomainOfIntegration(args,intallfaces,3) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,intallfaces,3);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationAllFaces : public CDomainOfIntegration { + public: + CDomainOfIntegrationAllFaces(const basicAC_F0 &args) : CDomainOfIntegration(args, intallfaces, 3) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, intallfaces, 3); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmesh3 >( ), true); } // all type }; -// MeshL -class CDomainOfIntegrationAll0d: public CDomainOfIntegration { -public: - CDomainOfIntegrationAll0d( const basicAC_F0 & args) :CDomainOfIntegration(args,intall0d,3) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,intall0d,3,1);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +// MeshL +class CDomainOfIntegrationAll0d : public CDomainOfIntegration { + public: + CDomainOfIntegrationAll0d(const basicAC_F0 &args) : CDomainOfIntegration(args, intall0d, 3) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, intall0d, 3, 1); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshL >( ), true); } // all type }; // 3D surface -class CDomainOfIntegrationS: public CDomainOfIntegration { -public: - CDomainOfIntegrationS( const basicAC_F0 & args) :CDomainOfIntegration(args,int2d,3,2) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int2d,3,2);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationS : public CDomainOfIntegration { + public: + CDomainOfIntegrationS(const basicAC_F0 &args) : CDomainOfIntegration(args, int2d, 3, 2) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int2d, 3, 2); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; -class CDomainOfIntegrationBorderS: public CDomainOfIntegration { -public: - CDomainOfIntegrationBorderS( const basicAC_F0 & args) :CDomainOfIntegration(args,int1d,3,2) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int1d,3,2);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationBorderS : public CDomainOfIntegration { + public: + CDomainOfIntegrationBorderS(const basicAC_F0 &args) : CDomainOfIntegration(args, int1d, 3, 2) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int1d, 3, 2); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; -class CDomainOfIntegrationAllEdgesS: public CDomainOfIntegration { -public: - CDomainOfIntegrationAllEdgesS( const basicAC_F0 & args) :CDomainOfIntegration(args,intalledges,3,2) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,intalledges,3,2);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationAllEdgesS : public CDomainOfIntegration { + public: + CDomainOfIntegrationAllEdgesS(const basicAC_F0 &args) : CDomainOfIntegration(args, intalledges, 3, 2) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, intalledges, 3, 2); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshS >( ), true); } // all type }; - // 3D curve -class CDomainOfIntegrationL: public CDomainOfIntegration { -public: - CDomainOfIntegrationL( const basicAC_F0 & args) :CDomainOfIntegration(args,int1d,3,1) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int1d,3,1);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationL : public CDomainOfIntegration { + public: + CDomainOfIntegrationL(const basicAC_F0 &args) : CDomainOfIntegration(args, int1d, 3, 1) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int1d, 3, 1); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshL >( ), true); } // all type }; -class CDomainOfIntegrationBorderL: public CDomainOfIntegration { -public: - CDomainOfIntegrationBorderL( const basicAC_F0 & args) :CDomainOfIntegration(args,int0d,3,1) {} - static E_F0 * f(const basicAC_F0 & args) { return new CDomainOfIntegration(args,int0d,3,1);} - static ArrayOfaType typeargs() { return ArrayOfaType(atype(), true);} // all type +class CDomainOfIntegrationBorderL : public CDomainOfIntegration { + public: + CDomainOfIntegrationBorderL(const basicAC_F0 &args) : CDomainOfIntegration(args, int0d, 3, 1) {} + static E_F0 *f(const basicAC_F0 &args) { return new CDomainOfIntegration(args, int0d, 3, 1); } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< pmeshL >( ), true); } // all type }; // hack build template -template struct CadnaType{ - typedef T Scalaire; - }; -#ifdef HAVE_CADNA +template< class T > +struct CadnaType { + typedef T Scalaire; +}; +#ifdef HAVE_CADNA #include // specialisation -template<> struct CadnaType >{ - typedef complex Scalaire; - }; -template<> struct CadnaType { - typedef double_st Scalaire; - }; -inline double_st conj(const double_st &x){ return x;}; -inline complex conj(const complex &x){ return complex(x.real(),-x.imag());} - - inline double norm(complex x){return x.real()*x.real()+x.imag()*x.imag();} - inline double norm(double_st x){return x*x;} -inline int cestac(const complex & z) -{return min(cestac(z.real()),cestac(z.imag()));} +template<> +struct CadnaType< complex< double > > { + typedef complex< double_st > Scalaire; +}; +template<> +struct CadnaType< double > { + typedef double_st Scalaire; +}; +inline double_st conj(const double_st &x) { return x; }; +inline complex< double_st > conj(const complex< double_st > &x) { return complex< double_st >(x.real( ), -x.imag( )); } + +inline double norm(complex< double_st > x) { return x.real( ) * x.real( ) + x.imag( ) * x.imag( ); } +inline double norm(double_st x) { return x * x; } +inline int cestac(const complex< double_st > &z) { return min(cestac(z.real( )), cestac(z.imag( ))); } #endif -class Problem : public Polymorphic { +class Problem : public Polymorphic { // typedef double R; - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =3+NB_NAME_PARM_MAT + NB_NAME_PARM_HMAT; // modi FH oct 2005 add tol_pivot 02/ 2007 add nbiter - int Nitem,Mitem; + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 3 + NB_NAME_PARM_MAT + NB_NAME_PARM_HMAT; // modi FH oct 2005 add tol_pivot 02/ 2007 add nbiter + int Nitem, Mitem; const int dim; -public: - template + + public: + template< class FESpace > struct Data { typedef typename FESpace::Mesh Mesh; - const Mesh * pTh; - CountPointer Uh; - CountPointer Vh; - CountPointer > AR; - CountPointer > AC; - typedef CadnaType::Scalaire double_st; - typedef CadnaType >::Scalaire cmplx_st; - MatriceCreuse * AcadnaR; - MatriceCreuse * AcadnaC; - - void init() {pTh=0; AcadnaR=0;AcadnaC=0; Uh.init(),Vh.init();AR.init();AC.init();} - void destroy() { - pTh=0; - Uh.destroy(); - Vh.destroy(); - AR.destroy(); - AC.destroy(); - - if(AcadnaR) AcadnaR->destroy(); - if(AcadnaC) AcadnaC->destroy(); - } - } ; - - struct DataComposite{ - vector< void * > *pThU; - vector< void * > *pThV; - - CountPointer > ARglobal; - CountPointer > ACglobal; - void init() { pThU=0; pThV=0; ARglobal.init(); ACglobal.init();} - void destroy() { - if(pThU){ - if(! pThU->empty()){ - for( int i=0;isize(); i++) (*pThU)[i] = nullptr; - pThU->clear(); + const Mesh *pTh; + CountPointer< const FESpace > Uh; + CountPointer< const FESpace > Vh; + CountPointer< MatriceCreuse< double > > AR; + CountPointer< MatriceCreuse< Complex > > AC; + typedef CadnaType< double >::Scalaire double_st; + typedef CadnaType< complex< double > >::Scalaire cmplx_st; + MatriceCreuse< double_st > *AcadnaR; + MatriceCreuse< cmplx_st > *AcadnaC; + + void init( ) { + pTh = 0; + AcadnaR = 0; + AcadnaC = 0; + Uh.init( ), Vh.init( ); + AR.init( ); + AC.init( ); + } + void destroy( ) { + pTh = 0; + Uh.destroy( ); + Vh.destroy( ); + AR.destroy( ); + AC.destroy( ); + + if (AcadnaR) AcadnaR->destroy( ); + if (AcadnaC) AcadnaC->destroy( ); + } + }; + + struct DataComposite { + vector< void * > *pThU; + vector< void * > *pThV; + + CountPointer< MatriceCreuse< double > > ARglobal; + CountPointer< MatriceCreuse< Complex > > ACglobal; + void init( ) { + pThU = 0; + pThV = 0; + ARglobal.init( ); + ACglobal.init( ); + } + void destroy( ) { + if (pThU) { + if (!pThU->empty( )) { + for (int i = 0; i < pThU->size( ); i++) (*pThU)[i] = nullptr; + pThU->clear( ); } delete pThU; } - if(pThV){ - if(! pThV->empty()){ - for( int i=0;isize(); i++) (*pThV)[i] = nullptr; - pThV->clear(); + if (pThV) { + if (!pThV->empty( )) { + for (int i = 0; i < pThV->size( ); i++) (*pThV)[i] = nullptr; + pThV->clear( ); } delete pThV; } - if(ARglobal){ ARglobal->SetSolver(); ARglobal.destroy(); } - if(ACglobal){ ACglobal->SetSolver(); ACglobal.destroy(); } + if (ARglobal) { + ARglobal->SetSolver( ); + ARglobal.destroy( ); + } + if (ACglobal) { + ACglobal->SetSolver( ); + ACglobal.destroy( ); + } } }; - + const OneOperator *precon; - C_args *op; // the list of all operator - KNM> block_largs; - // list largs; - mutable vector var; // list des var pour les solutions et test - mutable vector type_var; // list des type des FESpace for each var pour les solutions et test (used only different type of FESpace) - bool complextype,VF; + C_args *op; // the list of all operator + KNM< list< C_F0 > > block_largs; + // list largs; + mutable vector< Expression > var; // list des var pour les solutions et test + mutable vector< int > type_var; // list des type des FESpace for each var pour les solutions et test (used only different type of FESpace) + bool complextype, VF; // Expression noinit,type,epsilon; Expression nargs[n_name_param]; - const size_t offset; - Problem(const C_args * ca,const ListOfId &l,size_t & top) ; - static ArrayOfaType typeargs() { return ArrayOfaType(true);}// all type - - Data * dataptr (Stack stack) const {return (Data *) (void *) (((char *) stack)+offset);} - Data * dataptr3 (Stack stack) const {return (Data *) (void *) (((char *) stack)+offset);} - Data * dataptrS (Stack stack) const {return (Data *) (void *) (((char *) stack)+offset);} - Data * dataptrL (Stack stack) const {return (Data *) (void *) (((char *) stack)+offset);} - - DataComposite *dataptrCompo(Stack stack) const {return (DataComposite *) (void *) (((char *) stack)+offset);} - - void init(Stack stack) const { - if(dim==2) - dataptr(stack)->init(); - else if(dim==3) - dataptr3(stack)->init(); - else if(dim==4) - dataptrS(stack)->init(); - else if(dim==5) - dataptrL(stack)->init(); - else if(dim==6) dataptrCompo(stack)->init(); // allocation pour que les offset soit correct + const size_t offset; + Problem(const C_args *ca, const ListOfId &l, size_t &top); + static ArrayOfaType typeargs( ) { return ArrayOfaType(true); } // all type + + Data< FESpace > *dataptr(Stack stack) const { return (Data< FESpace > *)(void *)(((char *)stack) + offset); } + Data< FESpace3 > *dataptr3(Stack stack) const { return (Data< FESpace3 > *)(void *)(((char *)stack) + offset); } + Data< FESpaceS > *dataptrS(Stack stack) const { return (Data< FESpaceS > *)(void *)(((char *)stack) + offset); } + Data< FESpaceL > *dataptrL(Stack stack) const { return (Data< FESpaceL > *)(void *)(((char *)stack) + offset); } + + DataComposite *dataptrCompo(Stack stack) const { return (DataComposite *)(void *)(((char *)stack) + offset); } + + void init(Stack stack) const { + if (dim == 2) + dataptr(stack)->init( ); + else if (dim == 3) + dataptr3(stack)->init( ); + else if (dim == 4) + dataptrS(stack)->init( ); + else if (dim == 5) + dataptrL(stack)->init( ); + else if (dim == 6) + dataptrCompo(stack)->init( ); // allocation pour que les offset soit correct } - void destroy(Stack stack) const { - if(dim==2) dataptr(stack)->destroy(); - else if(dim==3) dataptr3(stack)->destroy(); - else if(dim==4) dataptrS(stack)->destroy(); - else if(dim==5) dataptrL(stack)->destroy(); - else if(dim==6) dataptrCompo(stack)->destroy(); // allocation pour que les offset soit correct + void destroy(Stack stack) const { + if (dim == 2) + dataptr(stack)->destroy( ); + else if (dim == 3) + dataptr3(stack)->destroy( ); + else if (dim == 4) + dataptrS(stack)->destroy( ); + else if (dim == 5) + dataptrL(stack)->destroy( ); + else if (dim == 6) + dataptrCompo(stack)->destroy( ); // allocation pour que les offset soit correct } - template - AnyType eval(Stack stack,Data * data,CountPointer > & dataA, - MatriceCreuse< typename CadnaType::Scalaire > * & dataCadna) const; - template // TODO if coupling FE wit problem - AnyType evalComposite(Stack stack,DataComposite *data, CountPointer > & dataA) const; - AnyType operator()(Stack stack) const; // move in Problem.cpp dec. 2018 FH + template< class R, class FESpace, class v_fes > + AnyType eval(Stack stack, Data< FESpace > *data, CountPointer< MatriceCreuse< R > > &dataA, MatriceCreuse< typename CadnaType< R >::Scalaire > *&dataCadna) const; + template< class R > // TODO if coupling FE wit problem + AnyType evalComposite(Stack stack, DataComposite *data, CountPointer< MatriceCreuse< R > > &dataA) const; + AnyType operator( )(Stack stack) const; // move in Problem.cpp dec. 2018 FH - bool Empty() const {return false;} - size_t nbitem() const { return Nitem;} + bool Empty( ) const { return false; } + size_t nbitem( ) const { return Nitem; } }; - -class Solve : public Problem { public: +class Solve : public Problem { + public: // just a problem with implicit solve - Solve(const C_args * ca,const ListOfId &l,size_t & top) - : Problem(new C_args(*ca),l,top) {} + Solve(const C_args *ca, const ListOfId &l, size_t &top) : Problem(new C_args(*ca), l, top) {} }; -class FormBilinear : public E_F0mps { public: - typedef const FormBilinear* Result; - typedef const CDomainOfIntegration * A; - typedef const foperator * B; - A di; - Foperator * b; - FormBilinear(const basicAC_F0 & args) { - di= dynamic_cast(CastTo(args[0])); - B bb= dynamic_cast(CastTo(args[1])); - // b = bb->Optimize(currentblock); // FH1004 - b=new Foperator(*bb); // FH1004 no optimisation here because we don't the type of the bilinear form here. - // the opimisation is done after in FieldOfForm routine - // to find if the form is real or complex - - // delete bb; il ne faut pas detruire .. car bb peut etre dans une variable - ffassert(di && b); } - - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());}// all type - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - - static E_F0 * f(const basicAC_F0 & args) { return new FormBilinear(args);} - FormBilinear(A a,Expression bb) : di(a),b(new Foperator(*dynamic_cast(bb))/*->Optimize(currentblock) FH1004 */) - {ffassert(b);} +class FormBilinear : public E_F0mps { + public: + typedef const FormBilinear *Result; + typedef const CDomainOfIntegration *A; + typedef const foperator *B; + A di; + Foperator *b; + FormBilinear(const basicAC_F0 &args) { + di = dynamic_cast< A >(CastTo< A >(args[0])); + B bb = dynamic_cast< B >(CastTo< B >(args[1])); + // b = bb->Optimize(currentblock); // FH1004 + b = new Foperator(*bb); // FH1004 no optimisation here because we don't the type of the bilinear form here. + // the opimisation is done after in FieldOfForm routine + // to find if the form is real or complex + + // delete bb; il ne faut pas detruire .. car bb peut etre dans une variable + ffassert(di && b); + } + + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >( ), atype< B >( )); } // all type + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + + static E_F0 *f(const basicAC_F0 &args) { return new FormBilinear(args); } + FormBilinear(A a, Expression bb) : di(a), b(new Foperator(*dynamic_cast< B >(bb)) /*->Optimize(currentblock) FH1004 */) { ffassert(b); } // Added J. Morice to recreate largs // FormBilinear(A a, Foperator &bb) : di(a),b(&bb)/*->Optimize(currentblock) FH1004 */ // {ffassert(b);} - // Fin Added J. Morice + // Fin Added J. Morice - FormBilinear operator-() const { return FormBilinear(di,C_F0(TheOperators,"-",C_F0(b,atype())));} - bool VF() const { return MaxOp(b) >= last_operatortype;} - int dim() const {return di->d;} - FormBilinear(const FormBilinear & fb) : di(fb.di),b(new Foperator(*fb.b) ) {} + FormBilinear operator-( ) const { return FormBilinear(di, C_F0(TheOperators, "-", C_F0(b, atype< B >( )))); } + bool VF( ) const { return MaxOp(b) >= last_operatortype; } + int dim( ) const { return di->d; } + FormBilinear(const FormBilinear &fb) : di(fb.di), b(new Foperator(*fb.b)) {} // void init(Stack stack) const {} }; - -//template -class FormLinear : public E_F0mps { public: - typedef const FormLinear* Result; - typedef const CDomainOfIntegration * A; - typedef const ftest * B; - A di; - Ftest * l; - - FormLinear(const basicAC_F0 & args) { - di= dynamic_cast(CastTo(args[0])); +// template +class FormLinear : public E_F0mps { + public: + typedef const FormLinear *Result; + typedef const CDomainOfIntegration *A; + typedef const ftest *B; + A di; + Ftest *l; + + FormLinear(const basicAC_F0 &args) { + di = dynamic_cast< A >(CastTo< A >(args[0])); assert(di); - Expression a1=CastTo(args[1]); + Expression a1 = CastTo< B >(args[1]); assert(a1); - B ll= dynamic_cast(a1); + B ll = dynamic_cast< B >(a1); assert(ll); - l = new Ftest(*ll); // FH1004 ->Optimize(currentblock); same as bilinear + l = new Ftest(*ll); // FH1004 ->Optimize(currentblock); same as bilinear // delete ll; // il ne faut pas detruire car ll peut etre dans une variable assert(l); ffassert(di && l); } - bool VF() const { return MaxOp(l) >= last_operatortype;} - - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());}// all type - AnyType operator()(Stack ) const { return SetAny(this);} - operator aType () const { return atype();} - int dim() const {return di->d;} - static E_F0 * f(const basicAC_F0 & args) { return new FormLinear(args);} - FormLinear(A a,Expression bb) : di(a),l(new Ftest(*dynamic_cast(bb))/*->Optimize(currentblock) FH1004 */) {ffassert(l);} - FormLinear operator-() const { return FormLinear(di,C_F0(TheOperators,"-",C_F0(l,atype())));} + bool VF( ) const { return MaxOp(l) >= last_operatortype; } + + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >( ), atype< B >( )); } // all type + AnyType operator( )(Stack) const { return SetAny< Result >(this); } + operator aType( ) const { return atype< Result >( ); } + int dim( ) const { return di->d; } + static E_F0 *f(const basicAC_F0 &args) { return new FormLinear(args); } + FormLinear(A a, Expression bb) : di(a), l(new Ftest(*dynamic_cast< B >(bb)) /*->Optimize(currentblock) FH1004 */) { ffassert(l); } + FormLinear operator-( ) const { return FormLinear(di, C_F0(TheOperators, "-", C_F0(l, atype< B >( )))); } // void init(Stack stack) const {} - FormLinear(const FormLinear & fb) : di(fb.di),l(new Ftest(*fb.l) ) {} - + FormLinear(const FormLinear &fb) : di(fb.di), l(new Ftest(*fb.l)) {} }; -template -class Call_FormLinear: public E_F0mps -{ -public: - list largs; +template< class VFES > +class Call_FormLinear : public E_F0mps { + public: + list< C_F0 > largs; Expression *nargs; - typedef list::const_iterator const_iterator; + typedef list< C_F0 >::const_iterator const_iterator; const int N; Expression ppfes; - Call_FormLinear(Expression * na,Expression LL, Expression ft) ; - AnyType operator()(Stack stack) const - { InternalError(" bug: no eval of Call_FormLinear ");} - operator aType () const { return atype();} - + Call_FormLinear(Expression *na, Expression LL, Expression ft); + AnyType operator( )(Stack stack) const { InternalError(" bug: no eval of Call_FormLinear "); } + operator aType( ) const { return atype< void >( ); } }; // specification of Linear Form in the case of composite template<> -class Call_FormLinear< vect_generic_v_fes>: public E_F0mps -{ -public: - KN> block_largs; +class Call_FormLinear< vect_generic_v_fes > : public E_F0mps { + public: + KN< list< C_F0 > > block_largs; Expression *nargs; - typedef list::const_iterator const_iterator; + typedef list< C_F0 >::const_iterator const_iterator; const int N; Expression ppfes; - Call_FormLinear(Expression * na,Expression LL, Expression ft); - AnyType operator()(Stack stack) const - { InternalError(" bug: no eval of Call_FormLinear ");} - operator aType () const { return atype();} - + Call_FormLinear(Expression *na, Expression LL, Expression ft); + AnyType operator( )(Stack stack) const { InternalError(" bug: no eval of Call_FormLinear "); } + operator aType( ) const { return atype< void >( ); } }; -template -class Call_FormBilinear: public E_F0mps -{ -public: +template< class VFES1, class VFES2 > +class Call_FormBilinear : public E_F0mps { + public: Expression *nargs; - list largs; - typedef list::const_iterator const_iterator; - - const int N,M; - Expression euh,evh; - Call_FormBilinear(Expression * na,Expression LL, Expression fi,Expression fj) ; - AnyType operator()(Stack stack) const - { InternalError(" bug: no eval of Call_FormBilinear ");} - -operator aType () const { return atype();} + list< C_F0 > largs; + typedef list< C_F0 >::const_iterator const_iterator; + + const int N, M; + Expression euh, evh; + Call_FormBilinear(Expression *na, Expression LL, Expression fi, Expression fj); + AnyType operator( )(Stack stack) const { InternalError(" bug: no eval of Call_FormBilinear "); } + + operator aType( ) const { return atype< void >( ); } }; -template -class Call_CompositeFormBilinear: public E_F0mps -{ -public: +template< class VFES1, class VFES2 > +class Call_CompositeFormBilinear : public E_F0mps { + public: Expression *nargs; - KNM> block_largs; + KNM< list< C_F0 > > block_largs; - typedef list::const_iterator const_iterator; + typedef list< C_F0 >::const_iterator const_iterator; - const int N,M; - Expression euh,evh; - Call_CompositeFormBilinear(Expression * na,Expression LL, Expression fi,Expression fj) ; - AnyType operator()(Stack stack) const - { InternalError(" bug: no eval of Call_CompositeFormBilinear ");} - -operator aType () const { return atype();} + const int N, M; + Expression euh, evh; + Call_CompositeFormBilinear(Expression *na, Expression LL, Expression fi, Expression fj); + AnyType operator( )(Stack stack) const { InternalError(" bug: no eval of Call_CompositeFormBilinear "); } + operator aType( ) const { return atype< void >( ); } }; - struct OpCall_FormLinear_np { - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =1; - + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 1; }; struct OpCall_FormBilinear_np { - static basicAC_F0::name_and_type name_param[] ; - static const int n_name_param =1+NB_NAME_PARM_MAT+NB_NAME_PARM_HMAT; // 9-> 11 FH 31/10/2005 11->12 nbiter 02/2007 // 12->22 MUMPS+ Autre Solveur 02/08 // 34->40 param bem solver + static basicAC_F0::name_and_type name_param[]; + static const int n_name_param = 1 + NB_NAME_PARM_MAT + NB_NAME_PARM_HMAT; // 9-> 11 FH 31/10/2005 11->12 nbiter 02/2007 // 12->22 MUMPS+ Autre Solveur 02/08 // 34->40 param bem solver }; -template -struct OpCall_FormLinear - : public OneOperator, - public OpCall_FormLinear_np -{ +template< class T, class v_fes > +struct OpCall_FormLinear : public OneOperator, public OpCall_FormLinear_np { typedef v_fes *pfes; - E_F0 * code(const basicAC_F0 & args) const - { - Expression * nargs = new Expression[n_name_param]; - args.SetNameParam(n_name_param,name_param,nargs); + E_F0 *code(const basicAC_F0 &args) const { + Expression *nargs = new Expression[n_name_param]; + args.SetNameParam(n_name_param, name_param, nargs); - return new Call_FormLinear(nargs,to(args[0]),to(args[1]));} - OpCall_FormLinear() : - OneOperator(atype*>(),atype(),atype()) {} + return new Call_FormLinear< v_fes >(nargs, to< const C_args * >(args[0]), to< pfes * >(args[1])); + } + OpCall_FormLinear( ) : OneOperator(atype< const Call_FormLinear< v_fes > * >( ), atype< const T * >( ), atype< pfes * >( )) {} }; - -template -struct OpCall_FormLinear2 - : public OneOperator, - public OpCall_FormLinear_np -{ +template< class T, class v_fes > +struct OpCall_FormLinear2 : public OneOperator, public OpCall_FormLinear_np { typedef v_fes *pfes; - E_F0 * code(const basicAC_F0 & args) const - { - Expression * nargs = new Expression[this->n_name_param]; - args.SetNameParam(this->n_name_param,this->name_param,nargs); - - Expression p=args[1]; - if ( ! p->EvaluableWithOutStack() ) - { CompileError(" a(long,Vh) , The long must be a constant, and = 0, sorry");} - long pv = GetAny((*p)(NullStack)); - if ( pv ) - { CompileError(" a(long,Vh) , The long must be a constant == 0, sorry");} - return new Call_FormLinear(nargs,to(args[0]),to(args[2]));} - OpCall_FormLinear2() : - OneOperator(atype*>(),atype(),atype(),atype()) {} -}; + E_F0 *code(const basicAC_F0 &args) const { + Expression *nargs = new Expression[this->n_name_param]; + args.SetNameParam(this->n_name_param, this->name_param, nargs); -template -struct OpCall_FormBilinear - : public OneOperator , - OpCall_FormBilinear_np -{ - typedef v_fes1 *pfes1; typedef v_fes2 *pfes2; - - E_F0 * code(const basicAC_F0 & args) const - { Expression * nargs = new Expression[n_name_param]; - args.SetNameParam(n_name_param,name_param,nargs); - return new Call_FormBilinear(nargs,to(args[0]),to(args[1]),to(args[2]));} - OpCall_FormBilinear() : - OneOperator(atype*>(),atype(),atype(),atype()) {} + Expression p = args[1]; + if (!p->EvaluableWithOutStack( )) { + CompileError(" a(long,Vh) , The long must be a constant, and = 0, sorry"); + } + long pv = GetAny< long >((*p)(NullStack)); + if (pv) { + CompileError(" a(long,Vh) , The long must be a constant == 0, sorry"); + } + return new Call_FormLinear< v_fes >(nargs, to< const C_args * >(args[0]), to< pfes * >(args[2])); + } + OpCall_FormLinear2( ) : OneOperator(atype< const Call_FormLinear< v_fes > * >( ), atype< const T * >( ), atype< long >( ), atype< pfes * >( )) {} }; -template -struct OpCall_CompositeFormBilinear - : public OneOperator , - OpCall_FormBilinear_np -{ - typedef v_fes1 *pfes1; typedef v_fes2 *pfes2; - - E_F0 * code(const basicAC_F0 & args) const - { Expression * nargs = new Expression[n_name_param]; - args.SetNameParam(n_name_param,name_param,nargs); - - return new Call_CompositeFormBilinear(nargs,to(args[0]),to(args[1]),to(args[2])); +template< class T, class v_fes1, class v_fes2 > +struct OpCall_FormBilinear : public OneOperator, OpCall_FormBilinear_np { + typedef v_fes1 *pfes1; + typedef v_fes2 *pfes2; + E_F0 *code(const basicAC_F0 &args) const { + Expression *nargs = new Expression[n_name_param]; + args.SetNameParam(n_name_param, name_param, nargs); + return new Call_FormBilinear< v_fes1, v_fes2 >(nargs, to< const C_args * >(args[0]), to< pfes1 * >(args[1]), to< pfes2 * >(args[2])); } - - OpCall_CompositeFormBilinear() : - OneOperator(atype*>(),atype(),atype(),atype()) {} + OpCall_FormBilinear( ) : OneOperator(atype< const Call_FormBilinear< v_fes1, v_fes2 > * >( ), atype< const T * >( ), atype< pfes1 * >( ), atype< pfes2 * >( )) {} }; +template< class T, class v_fes1, class v_fes2 > +struct OpCall_CompositeFormBilinear : public OneOperator, OpCall_FormBilinear_np { + typedef v_fes1 *pfes1; + typedef v_fes2 *pfes2; + E_F0 *code(const basicAC_F0 &args) const { + Expression *nargs = new Expression[n_name_param]; + args.SetNameParam(n_name_param, name_param, nargs); -bool FieldOfForm( list & largs ,bool complextype); -template struct IsComplexType { static const bool value=false;}; -template<> struct IsComplexType { static const bool value=true;}; + return new Call_CompositeFormBilinear< v_fes1, v_fes2 >(nargs, to< const C_args * >(args[0]), to< pfes1 * >(args[1]), to< pfes2 * >(args[2])); + } -template // to make x=linearform(x) -struct OpArraytoLinearForm - : public OneOperator -{ - typedef typename Call_FormLinear::const_iterator const_iterator; + OpCall_CompositeFormBilinear( ) : OneOperator(atype< const Call_CompositeFormBilinear< v_fes1, v_fes2 > * >( ), atype< const T * >( ), atype< pfes1 * >( ), atype< pfes2 * >( )) {} +}; + +bool FieldOfForm(list< C_F0 > &largs, bool complextype); +template< class A > +struct IsComplexType { + static const bool value = false; +}; +template<> +struct IsComplexType< Complex > { + static const bool value = true; +}; + +template< class R, class MMesh, class v_fes > // to make x=linearform(x) +struct OpArraytoLinearForm : public OneOperator { + typedef typename Call_FormLinear< v_fes >::const_iterator const_iterator; const bool isptr; const bool init; const bool zero; - class Op : public E_F0mps - { - public: - Call_FormLinear *l; + class Op : public E_F0mps { + public: + Call_FormLinear< v_fes > *l; Expression x; - const bool isptr; - const bool init; - const bool zero; - AnyType operator()(Stack s) const ; - Op(Expression xx,Expression ll,bool isptrr,bool initt,bool zzero) - : l(new Call_FormLinear(*dynamic_cast *>(ll))), - x(xx), - isptr(isptrr),init(initt),zero(zzero) - {assert(l); - - bool iscmplx=FieldOfForm(l->largs,IsComplexType::value); - //cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " <<( (iscmplx) == IsComplexType::value) << endl; - ffassert( (iscmplx) == IsComplexType::value); -} - operator aType () const { return atype *>();} - + const bool isptr; + const bool init; + const bool zero; + AnyType operator( )(Stack s) const; + Op(Expression xx, Expression ll, bool isptrr, bool initt, bool zzero) + : l(new Call_FormLinear< v_fes >(*dynamic_cast< const Call_FormLinear< v_fes > * >(ll))), x(xx), isptr(isptrr), init(initt), zero(zzero) { + assert(l); + + bool iscmplx = FieldOfForm(l->largs, IsComplexType< R >::value); + // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " <<( (iscmplx) == IsComplexType::value) << endl; + ffassert((iscmplx) == IsComplexType< R >::value); + } + operator aType( ) const { return atype< KN< R > * >( ); } }; - E_F0 * code(const basicAC_F0 & args) const - { if(isptr) return new Op(to *>(args[0]),args[1],isptr,init,zero); - else return new Op(to >(args[0]),args[1],isptr,init,zero);} - + E_F0 *code(const basicAC_F0 &args) const { + if (isptr) + return new Op(to< KN< R > * >(args[0]), args[1], isptr, init, zero); + else + return new Op(to< KN_< R > >(args[0]), args[1], isptr, init, zero); + } // OpArraytoLinearForm(const basicForEachType * tt) : // OneOperator(atype >(),tt,atype()),init(false),isptr(false) {} - OpArraytoLinearForm(const basicForEachType * tt,bool isptrr, bool initt,bool zzero=1) : - OneOperator(atype >(),tt,atype*>()), - isptr(isptrr), init(initt),zero(zzero) {} - + OpArraytoLinearForm(const basicForEachType *tt, bool isptrr, bool initt, bool zzero = 1) + : OneOperator(atype< KN_< R > >( ), tt, atype< const Call_FormLinear< v_fes > * >( )), isptr(isptrr), init(initt), zero(zzero) {} }; - -template // to make A=linearform(x) -struct OpMatrixtoBilinearForm - : public OneOperator -{ - typedef typename Call_FormBilinear::const_iterator const_iterator; +template< class R, class MMesh, class v_fes1, class v_fes2 > // to make A=linearform(x) +struct OpMatrixtoBilinearForm : public OneOperator { + typedef typename Call_FormBilinear< v_fes1, v_fes2 >::const_iterator const_iterator; int init; class Op : public E_F0mps { - public: - Call_FormBilinear *b; + public: + Call_FormBilinear< v_fes1, v_fes2 > *b; Expression a; int init; - AnyType operator()(Stack s) const ; - - Op(Expression aa,Expression bb,int initt) - : b(new Call_FormBilinear(* dynamic_cast *>(bb))),a(aa),init(initt) - { assert(b && b->nargs); - bool iscmplx=FieldOfForm(b->largs,IsComplexType::value) ; - // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; - ffassert( (iscmplx) == IsComplexType::value); -} - operator aType () const { return atype *>();} + AnyType operator( )(Stack s) const; + Op(Expression aa, Expression bb, int initt) : b(new Call_FormBilinear< v_fes1, v_fes2 >(*dynamic_cast< const Call_FormBilinear< v_fes1, v_fes2 > * >(bb))), a(aa), init(initt) { + assert(b && b->nargs); + bool iscmplx = FieldOfForm(b->largs, IsComplexType< R >::value); + // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; + ffassert((iscmplx) == IsComplexType< R >::value); + } + operator aType( ) const { return atype< Matrice_Creuse< R > * >( ); } }; - E_F0 * code(const basicAC_F0 & args) const - { return new Op(to*>(args[0]),args[1],init);} - OpMatrixtoBilinearForm(int initt=0) : - OneOperator(atype*>(),atype*>(),atype*>()), - init(initt) - {} + E_F0 *code(const basicAC_F0 &args) const { return new Op(to< Matrice_Creuse< R > * >(args[0]), args[1], init); } + OpMatrixtoBilinearForm(int initt = 0) : OneOperator(atype< Matrice_Creuse< R > * >( ), atype< Matrice_Creuse< R > * >( ), atype< const Call_FormBilinear< v_fes1, v_fes2 > * >( )), init(initt) {} }; -template // to make x=linearform(x) -struct OpArraytoLinearFormVG - : public OneOperator -{ - typedef typename Call_FormLinear::const_iterator const_iterator; +template< class R > // to make x=linearform(x) +struct OpArraytoLinearFormVG : public OneOperator { + typedef typename Call_FormLinear< vect_generic_v_fes >::const_iterator const_iterator; const bool isptr; const bool init; const bool zero; - class Op : public E_F0mps - { - public: - Call_FormLinear *l; + class Op : public E_F0mps { + public: + Call_FormLinear< vect_generic_v_fes > *l; Expression x; - const bool isptr; - const bool init; - const bool zero; - - AnyType operator()(Stack s) const ; - Op(Expression xx,Expression ll,bool isptrr,bool initt,bool zzero) - : l(new Call_FormLinear(*dynamic_cast *>(ll))), - x(xx), - isptr(isptrr),init(initt),zero(zzero) - { - assert(l); - - int NN = (int) l->ppfes->componentNbitem().size(); - - bool total_iscmplx=false; - // loop over block - for(int i=0; iblock_largs(i),IsComplexType::value) ; - // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; - ffassert( (iscmplx) == IsComplexType::value); - if( !total_iscmplx ) total_iscmplx=iscmplx; - } - } - operator aType () const { return atype *>();} - + const bool isptr; + const bool init; + const bool zero; + + AnyType operator( )(Stack s) const; + Op(Expression xx, Expression ll, bool isptrr, bool initt, bool zzero) + : l(new Call_FormLinear< vect_generic_v_fes >(*dynamic_cast< const Call_FormLinear< vect_generic_v_fes > * >(ll))), x(xx), isptr(isptrr), init(initt), zero(zzero) { + assert(l); + + int NN = (int)l->ppfes->componentNbitem( ).size( ); + + bool total_iscmplx = false; + // loop over block + for (int i = 0; i < NN; i++) { + // FieldOfForm : optimize the terms (flags -O3) of the variational form and verifies the type of the variational form + bool iscmplx = FieldOfForm(l->block_largs(i), IsComplexType< R >::value); + // cout<< "FieldOfForm:iscmplx " << iscmplx << " " << IsComplexType::value << " " << ((iscmplx) == IsComplexType::value) << endl; + ffassert((iscmplx) == IsComplexType< R >::value); + if (!total_iscmplx) total_iscmplx = iscmplx; + } + } + operator aType( ) const { return atype< KN< R > * >( ); } }; - E_F0 * code(const basicAC_F0 & args) const - { if(isptr) return new Op(to *>(args[0]),args[1],isptr,init,zero); - else return new Op(to >(args[0]),args[1],isptr,init,zero);} - + E_F0 *code(const basicAC_F0 &args) const { + if (isptr) + return new Op(to< KN< R > * >(args[0]), args[1], isptr, init, zero); + else + return new Op(to< KN_< R > >(args[0]), args[1], isptr, init, zero); + } // OpArraytoLinearForm(const basicForEachType * tt) : // OneOperator(atype >(),tt,atype()),init(false),isptr(false) {} - OpArraytoLinearFormVG(const basicForEachType * tt,bool isptrr, bool initt,bool zzero=1) : - OneOperator(atype >(),tt,atype*>()), - isptr(isptrr), init(initt),zero(zzero) {} - + OpArraytoLinearFormVG(const basicForEachType *tt, bool isptrr, bool initt, bool zzero = 1) + : OneOperator(atype< KN_< R > >( ), tt, atype< const Call_FormLinear< vect_generic_v_fes > * >( )), isptr(isptrr), init(initt), zero(zzero) {} }; -template -class IntFunction : public E_F0mps { public: +template< class R > +class IntFunction : public E_F0mps { + public: typedef R Result; - typedef const CDomainOfIntegration * A; - typedef R B; - A di; + typedef const CDomainOfIntegration *A; + typedef R B; + A di; Expression fonc; - IntFunction(const basicAC_F0 & args) { - di= dynamic_cast(CastTo(args[0])); - fonc= CastTo(args[1]); - ffassert(di && fonc); } - - static ArrayOfaType typeargs() { return ArrayOfaType(atype(),atype());}// all type - AnyType operator()(Stack ) const; - static E_F0 * f(const basicAC_F0 & args) { return new IntFunction(args);} - // IntFunction(A a,Expression bb) : di(a),fonc(bb) {} - operator aType () const { return atype();} + IntFunction(const basicAC_F0 &args) { + di = dynamic_cast< A >(CastTo< A >(args[0])); + fonc = CastTo< B >(args[1]); + ffassert(di && fonc); + } + static ArrayOfaType typeargs( ) { return ArrayOfaType(atype< A >( ), atype< B >( )); } // all type + AnyType operator( )(Stack) const; + static E_F0 *f(const basicAC_F0 &args) { return new IntFunction(args); } + // IntFunction(A a,Expression bb) : di(a),fonc(bb) {} + operator aType( ) const { return atype< Result >( ); } }; - extern Block *currentblock; -class TypeFormOperator: public ForEachType { -public: - TypeFormOperator() : ForEachType(0,0) {} - void SetArgs(const ListOfId *lid) const { - SetArgsFormLinear(lid,2); } +class TypeFormOperator : public ForEachType< const C_args * > { + public: + TypeFormOperator( ) : ForEachType< const C_args * >(0, 0) {} + void SetArgs(const ListOfId *lid) const { SetArgsFormLinear(lid, 2); } - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { return Type_Expr(this,CastTo(c));} - - inline C_F0 Initialization(const Type_Expr & e) const {return C_F0();} + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { return Type_Expr(this, CastTo(c)); } + inline C_F0 Initialization(const Type_Expr &e) const { return C_F0( ); } }; -class TypeFormBilinear: public ForEachType { -public: - TypeFormBilinear() : ForEachType(0,0) {} - void SetArgs(const ListOfId *lid) const { - SetArgsFormLinear(lid,2); - } - - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { return Type_Expr(this,CastTo(c));} +class TypeFormBilinear : public ForEachType< const FormBilinear * > { + public: + TypeFormBilinear( ) : ForEachType< const FormBilinear * >(0, 0) {} + void SetArgs(const ListOfId *lid) const { SetArgsFormLinear(lid, 2); } + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { return Type_Expr(this, CastTo(c)); } - C_F0 Initialization(const Type_Expr & e) const - { + C_F0 Initialization(const Type_Expr &e) const { // cout << "Initialization " << *e.first << endl; - return C_F0(); } // nothing to initialize - Type_Expr construct(const Type_Expr & e) const - { - //cout << "construct " << *e.first << endl; - return e; } - + return C_F0( ); + } // nothing to initialize + Type_Expr construct(const Type_Expr &e) const { + // cout << "construct " << *e.first << endl; + return e; + } }; -template -class TypeSolve : public ForEachType { -public: - TypeSolve() : ForEachType(0,0) {} +template< bool exec_init, class Problem > +class TypeSolve : public ForEachType< const Problem * > { + public: + TypeSolve( ) : ForEachType< const Problem * >(0, 0) {} - void SetArgs(const ListOfId *lid) const { - SetArgsFormLinear(lid,2); - - - } - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { if (c.left() != atype()) - CompileError(" Problem a(...) = invalid type ",c.left()); - const C_args * ca = dynamic_cast(c.LeftValue()); - Problem * pb=new Problem(ca,*l,top); - SHOWVERB(cout << "solve:SetParam " << ca << " pb=" << pb << endl); - - return Type_Expr(this,pb); + void SetArgs(const ListOfId *lid) const { SetArgsFormLinear(lid, 2); } + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { + if (c.left( ) != atype< const C_args * >( )) CompileError(" Problem a(...) = invalid type ", c.left( )); + const C_args *ca = dynamic_cast< const C_args * >(c.LeftValue( )); + Problem *pb = new Problem(ca, *l, top); + SHOWVERB(cout << "solve:SetParam " << ca << " pb=" << pb << endl); + return Type_Expr(this, pb); } - class SolveInit: public E_F0 { public: - const Problem * a; - AnyType operator()(Stack s) const { + class SolveInit : public E_F0 { + public: + const Problem *a; + AnyType operator( )(Stack s) const { a->init(s); - return exec_init ? (*a)(s) : Nothing ; + return exec_init ? (*a)(s) : Nothing; + } + SolveInit(const Type_Expr &te) : a(dynamic_cast< const Problem * >(te.second)) { + SHOWVERB(cout << "SolveInit " << te.second << endl); + ffassert(a); } - SolveInit(const Type_Expr & te) : a(dynamic_cast(te.second)) - { SHOWVERB(cout << "SolveInit " << te.second << endl); - ffassert(a);} }; - class SolveDel: public E_F0 { public: - const Problem * a; - SolveDel(const C_F0 & c) : a(dynamic_cast(c.LeftValue())) - { - SHOWVERB(cout << "SolveDel " << c.left() << endl); - ffassert(a);} + class SolveDel : public E_F0 { + public: + const Problem *a; + SolveDel(const C_F0 &c) : a(dynamic_cast< const Problem * >(c.LeftValue( ))) { + SHOWVERB(cout << "SolveDel " << c.left( ) << endl); + ffassert(a); + } - AnyType operator()(Stack s) const { + AnyType operator( )(Stack s) const { a->destroy(s); return Nothing; - }}; + } + }; - Expression Destroy(const C_F0 & c) const - { return new SolveDel(c);} + Expression Destroy(const C_F0 &c) const { return new SolveDel(c); } - bool ExistDestroy() const {return true;} + bool ExistDestroy( ) const { return true; } - C_F0 Initialization(const Type_Expr & e) const - { return C_F0( new SolveInit(e) ,atype()); } + C_F0 Initialization(const Type_Expr &e) const { return C_F0(new SolveInit(e), atype< void >( )); } }; +class TypeFormLinear : public ForEachType< const FormLinear * > { + public: + TypeFormLinear( ) : ForEachType< const FormLinear * >(0, 0) {} + void SetArgs(const ListOfId *lid) const { SetArgsFormLinear(lid, 1); } - -class TypeFormLinear: public ForEachType { -public: - TypeFormLinear() : ForEachType(0,0) {} - - void SetArgs(const ListOfId *lid) const { - SetArgsFormLinear(lid,1); } - - Type_Expr SetParam(const C_F0 & c,const ListOfId *l,size_t & top) const - { return Type_Expr(this,CastTo(c));} + Type_Expr SetParam(const C_F0 &c, const ListOfId *l, size_t &top) const { return Type_Expr(this, CastTo(c)); } // { return Type_Expr(c.left(),c.LeftValue()); } // - C_F0 Initialization(const Type_Expr & e) const - { return C_F0(); } // nothing to initialize - + C_F0 Initialization(const Type_Expr &e) const { return C_F0( ); } // nothing to initialize }; - - -template class Matrice_Creuse -{ -public: - UniqueffId Uh,Vh; // pour la reconstruction - // MatriceCreuse == VirtualMatrix - typedef VirtualMatrix VMat; - typedef HashMatrix HMat; - - CountPointer > A; - int typemat; // - static const int TS_SYM=1,TS_DEF_POS=2,TS_PARA=4; - //TypeSolveMat typemat; - size_t count; - void init() { - count=0; - A.init();Uh.init();Vh.init(); - typemat=0 ; }// - Matrice_Creuse() { init();} - void destroy() {// Correct Oct 2015 FH (avant test a 'envert) !!!! - if(verbosity>99999) - cerr << " ## DEL MC " << this <<" " << count <<" " << A << endl; - if(count--==0) - { - VMat *pvm=pMC(); - if(pvm) pvm->SetSolver(); - pvm=0; // del solver before the del of the real matrix... - A.destroy(); +template< class K > +class Matrice_Creuse { + public: + UniqueffId Uh, Vh; // pour la reconstruction + // MatriceCreuse == VirtualMatrix + typedef VirtualMatrix< int, K > VMat; + typedef HashMatrix< int, K > HMat; + + CountPointer< MatriceCreuse< K > > A; + int typemat; // + static const int TS_SYM = 1, TS_DEF_POS = 2, TS_PARA = 4; + // TypeSolveMat typemat; + size_t count; + void init( ) { + count = 0; + A.init( ); + Uh.init( ); + Vh.init( ); + typemat = 0; + } // + Matrice_Creuse( ) { init( ); } + void destroy( ) { // Correct Oct 2015 FH (avant test a 'envert) !!!! + if (verbosity > 99999) cerr << " ## DEL MC " << this << " " << count << " " << A << endl; + if (count-- == 0) { + VMat *pvm = pMC( ); + if (pvm) pvm->SetSolver( ); + pvm = 0; // del solver before the del of the real matrix... + A.destroy( ); } -//else count--; - // Uh.destroy(); - //Vh.destroy(); + // else count--; + // Uh.destroy(); + // Vh.destroy(); } - void copysolver(Matrice_Creuse *a) - { - VMat *pvm=pMC(), *pvam=a->pMC(); - if( pvm) - { - //typename VMat::VSolver s= pvam ? pvam->CloneSolver() : 0; - // to hard to CloneSolver - pvm->SetSolver();//So Solver .. - pvm=0; - } + void copysolver(Matrice_Creuse *a) { + VMat *pvm = pMC( ), *pvam = a->pMC( ); + if (pvm) { + // typename VMat::VSolver s= pvam ? pvam->CloneSolver() : 0; + // to hard to CloneSolver + pvm->SetSolver( ); // So Solver .. + pvm = 0; + } + } + Matrice_Creuse(MatriceCreuse< K > *aa) //,const pfes *ppUh,const pfes *ppVh) + : A(aa) {} //,pUh(ppUh),pVh(ppVh),Uh(*ppUh),Vh(*ppVh) {} + Matrice_Creuse(MatriceCreuse< K > *aa, const UniqueffId *pUh, const UniqueffId *pVh) //,const pfes *ppUh,const pfes *ppVh) + : A(aa), Uh(*pUh), Vh(*pVh) {} //,pUh(ppUh),pVh(ppVh),Uh(*ppUh),Vh(*ppVh) {} + long N( ) const { return A ? A->n : 0; } + long M( ) const { return A ? A->m : 0; } + void resize(int n, int m) { + if (A) + A->resize(n, m); + else { // matrice vide a cree + HashMatrix< int, K > *phm = new HashMatrix< int, K >(n, m, 0, 0); + MatriceCreuse< K > *pmc(phm); + A.master(pmc); } - Matrice_Creuse( MatriceCreuse * aa)//,const pfes *ppUh,const pfes *ppVh) - :A(aa){}//,pUh(ppUh),pVh(ppVh),Uh(*ppUh),Vh(*ppVh) {} - Matrice_Creuse( MatriceCreuse * aa,const UniqueffId *pUh,const UniqueffId *pVh)//,const pfes *ppUh,const pfes *ppVh) - :A(aa),Uh(*pUh),Vh(*pVh) {}//,pUh(ppUh),pVh(ppVh),Uh(*ppUh),Vh(*ppVh) {} - long N() const {return A ? A->n : 0;} - long M() const { return A ? A->m : 0;} - void resize(int n,int m) { - if(A) A->resize(n,m); - else {// matrice vide a cree - HashMatrix *phm= new HashMatrix(n,m,0,0); - MatriceCreuse *pmc(phm); - A.master(pmc); - } - } - void increment(){ count++;} - VMat *pMC() {return A ? ( MatriceCreuse *)A:0; } - HMat *pHM() {return dynamic_cast *>(pMC());} + void increment( ) { count++; } + VMat *pMC( ) { return A ? (MatriceCreuse< K > *)A : 0; } + HMat *pHM( ) { return dynamic_cast< HashMatrix< int, K > * >(pMC( )); } }; -template class newpMatrice_Creuse -{ -public: - MatriceCreuse *pmc; - newpMatrice_Creuse(Stack s,HashMatrix *pvm) :pmc(pvm) - { +template< class K > +class newpMatrice_Creuse { + public: + MatriceCreuse< K > *pmc; + newpMatrice_Creuse(Stack s, HashMatrix< int, K > *pvm) : pmc(pvm) { - if(verbosity>99999) cerr << " newpMatrice_Creuse Add2StackOfPtr2FreeRC "<< pmc << endl; - Add2StackOfPtr2FreeRC(s,pmc); - // Add2StackOfPtr2Free(s,pmc); - } - Matrice_Creuse * set(Matrice_Creuse *pmcc,int init) { - if(init) pmcc->init() ; - pmc->increment() ; - pmcc->A.master(pmc); - // pmcc->A.cswap(pmc); - - if(verbosity>99999) cerr << "newpMatrice_Creuse set " << pmcc << " " << pmcc->count <<" " << pmcc->A - << " to " << pmc << " init: "<< init << endl; - // pmc->dump(cerr) << endl; - pmc=0; - return pmcc; + if (verbosity > 99999) cerr << " newpMatrice_Creuse Add2StackOfPtr2FreeRC " << pmc << endl; + Add2StackOfPtr2FreeRC(s, pmc); + // Add2StackOfPtr2Free(s,pmc); + } + Matrice_Creuse< K > *set(Matrice_Creuse< K > *pmcc, int init) { + if (init) pmcc->init( ); + pmc->increment( ); + pmcc->A.master(pmc); + // pmcc->A.cswap(pmc); + + if (verbosity > 99999) cerr << "newpMatrice_Creuse set " << pmcc << " " << pmcc->count << " " << pmcc->A << " to " << pmc << " init: " << init << endl; + // pmc->dump(cerr) << endl; + pmc = 0; + return pmcc; + } + Matrice_Creuse< K > *add(Matrice_Creuse< K > *pmcc, double cc = 1) { + // pmcc->A.cswap(pmc); + HashMatrix< int, K > *pA = pmcc->pHM( ); + HashMatrix< int, K > *pC = dynamic_cast< HashMatrix< int, K > * >(pmc); + + if (pA == 0) { + cerr << " error A += B (A) empty matrix" << endl; } - Matrice_Creuse * add(Matrice_Creuse *pmcc,double cc=1) { - // pmcc->A.cswap(pmc); - HashMatrix *pA= pmcc->pHM(); - HashMatrix *pC= dynamic_cast *>(pmc); - - if(pA==0) { cerr<< " error A += B (A) empty matrix" << endl; } - if(pC==0) { cerr<< " error += B (B) empty matrix" << endl; } - ffassert(pA && pC); - HashMatrix A=*pA; - pA->Add(pC,cc); - // to do.. XXXX July 2017 FH. - if(verbosity>99999) cerr << "newpMatrice_Creuse add " << pmcc << " " << pmcc->count <<" " << pmcc->A - << " to " << pmc << endl; - - pmc=0;// pcm is delete after instriction - return pmcc; + if (pC == 0) { + cerr << " error += B (B) empty matrix" << endl; } + ffassert(pA && pC); + HashMatrix< int, K > A = *pA; + pA->Add(pC, cc); + // to do.. XXXX July 2017 FH. + if (verbosity > 99999) cerr << "newpMatrice_Creuse add " << pmcc << " " << pmcc->count << " " << pmcc->A << " to " << pmc << endl; + + pmc = 0; // pcm is delete after instriction + return pmcc; + } // ~newpMatrice_Creuse() { if(pmc) delete pmc;pmc=0; } }; -template class Matrice_Creuse_Transpose; +template< class K > +class Matrice_Creuse_Transpose; + +template< class KA, class KB > +class Matrix_Prod { + public: + Matrice_Creuse< KA > *A; + Matrice_Creuse< KB > *B; + bool ta, tb; + Matrix_Prod(Matrice_Creuse< KA > *AA, Matrice_Creuse< KB > *BB) : A(AA), B(BB), ta(false), tb(false) { assert(AA && BB); } + Matrix_Prod(Matrice_Creuse_Transpose< KA > AA, Matrice_Creuse< KB > *BB) : A(AA), B(BB), ta(true), tb(false) { assert(AA && BB); } + Matrix_Prod(Matrice_Creuse< KA > *AA, Matrice_Creuse_Transpose< KB > BB) : A(AA), B(BB), ta(false), tb(true) { assert(AA && BB); } + Matrix_Prod(Matrice_Creuse_Transpose< KA > AA, Matrice_Creuse_Transpose< KB > BB) : A(AA), B(BB), ta(true), tb(true) { assert(AA && BB); } +}; - template class Matrix_Prod { public: - Matrice_Creuse *A; - Matrice_Creuse *B; - bool ta,tb; - Matrix_Prod(Matrice_Creuse *AA,Matrice_Creuse *BB) : A(AA),B(BB),ta(false),tb(false) {assert(AA && BB);} - Matrix_Prod(Matrice_Creuse_Transpose AA,Matrice_Creuse *BB) : A(AA),B(BB),ta(true),tb(false) {assert(AA && BB);} - Matrix_Prod(Matrice_Creuse *AA,Matrice_Creuse_Transpose BB) : A(AA),B(BB),ta(false),tb(true) {assert(AA && BB);} - Matrix_Prod(Matrice_Creuse_Transpose AA,Matrice_Creuse_Transpose BB) : A(AA),B(BB),ta(true),tb(true) {assert(AA && BB);} - }; +template< class K > +ostream &operator<<(ostream &f, const Matrice_Creuse< K > &A) { + if (!A.A) + f << " unset sparse matrix " << endl; + else + A.A->dump(f); + ; + return f; +} -template ostream & operator << (ostream & f,const Matrice_Creuse & A) -{ if ( !A.A) f << " unset sparse matrix " << endl; - else A.A->dump(f); ; - return f; } +template< class K > +istream &operator>>(istream &f, Matrice_Creuse< K > &A) { + int wm = WhichMatrix(f); + if (wm > 0) { + MatriceMorse< K > *HA = 0; + A.A.master(HA = new MatriceMorse< K >(f, wm)); + A.typemat = HA->sym( ); //(A.A->n == A.A->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) + } else { + cerr << " unknown type of matrix " << wm << endl; + ExecError("Error reading the matrix "); + A.A = 0; + } + return f; +} -template istream & operator >> (istream & f,Matrice_Creuse & A) -{ - int wm=WhichMatrix(f); - if ( wm>0 ) - { - MatriceMorse *HA =0; - A.A.master(HA=new MatriceMorse(f,wm)); - A.typemat=HA->sym() ;//(A.A->n == A.A->m) ? TypeSolveMat(TypeSolveMat::GMRES) : TypeSolveMat(TypeSolveMat::NONESQUARE); // none square matrice (morse) - } - else { - cerr << " unknown type of matrix " << wm < class Matrice_Creuse_Transpose { public: - Matrice_Creuse * A; - - Matrice_Creuse_Transpose(Matrice_Creuse * AA) : A(AA) {assert(A);} - operator MatriceCreuse & () const {return *A->A;} - operator Matrice_Creuse * () const {return A;} +template< class K > +class Matrice_Creuse_Transpose { + public: + Matrice_Creuse< K > *A; + + Matrice_Creuse_Transpose(Matrice_Creuse< K > *AA) : A(AA) { assert(A); } + operator MatriceCreuse< K > &( ) const { return *A->A; } + operator Matrice_Creuse< K > *( ) const { return A; } }; -template class Matrice_Creuse_inv { public: - Matrice_Creuse * A; - Matrice_Creuse_inv(Matrice_Creuse * AA) : A(AA) {assert(A);} - operator MatriceCreuse & () const {return *A->A;} - operator Matrice_Creuse * () const {return A;} +template< class K > +class Matrice_Creuse_inv { + public: + Matrice_Creuse< K > *A; + Matrice_Creuse_inv(Matrice_Creuse< K > *AA) : A(AA) { assert(A); } + operator MatriceCreuse< K > &( ) const { return *A->A; } + operator Matrice_Creuse< K > *( ) const { return A; } }; -template class Matrice_Creuse_inv_trans { public:// add aug 2018 FH. - Matrice_Creuse * A; - Matrice_Creuse_inv_trans(Matrice_Creuse * AA) : A(AA) {assert(A);} - Matrice_Creuse_inv_trans(Matrice_Creuse_Transpose * AA) : A(AA) {assert(A);} - Matrice_Creuse_inv_trans(const Matrice_Creuse_Transpose & AA) : A(AA.A) {assert(A);} - operator MatriceCreuse & () const {return *A->A;} - operator Matrice_Creuse * () const {return A;} +template< class K > +class Matrice_Creuse_inv_trans { + public: // add aug 2018 FH. + Matrice_Creuse< K > *A; + Matrice_Creuse_inv_trans(Matrice_Creuse< K > *AA) : A(AA) { assert(A); } + Matrice_Creuse_inv_trans(Matrice_Creuse_Transpose< K > *AA) : A(AA) { assert(A); } + Matrice_Creuse_inv_trans(const Matrice_Creuse_Transpose< K > &AA) : A(AA.A) { assert(A); } + operator MatriceCreuse< K > &( ) const { return *A->A; } + operator Matrice_Creuse< K > *( ) const { return A; } }; namespace Fem2D { - inline void F_Pi_h(R* v, const R2 & P,const baseFElement & K,int i,const R2 & Phat,void * arg) - { - TabFuncArg &tabe(*(TabFuncArg*)arg); - //MeshPoint & mp = *MeshPointStack(tabe.s); - MeshPointStack(tabe.s)->set(P,Phat,K); + inline void F_Pi_h(R *v, const R2 &P, const baseFElement &K, int i, const R2 &Phat, void *arg) { + TabFuncArg &tabe(*(TabFuncArg *)arg); + // MeshPoint & mp = *MeshPointStack(tabe.s); + MeshPointStack(tabe.s)->set(P, Phat, K); tabe.eval(v); // if (Norme2_2(P-mp.P) > 1e-10) // cout << " bug?? F_Pi_h " << endl; - } - inline void FoX_1_Pi_h(R* v, const R2 & P,const baseFElement & K,int i,const R2 & Phat,void * arg) - { - TabFuncArg &tabe(*(TabFuncArg*)arg); - MeshPointStack(tabe.s)->set(P,Phat,K); - R2 X=tabe.eval_X(); - MeshPointStack(tabe.s)->set(X.x,X.y); + inline void FoX_1_Pi_h(R *v, const R2 &P, const baseFElement &K, int i, const R2 &Phat, void *arg) { + TabFuncArg &tabe(*(TabFuncArg *)arg); + MeshPointStack(tabe.s)->set(P, Phat, K); + R2 X = tabe.eval_X( ); + MeshPointStack(tabe.s)->set(X.x, X.y); tabe.eval_2(v); } -//general templates for 2d and 3d volume // for Surf version ... -template bool AssembleVarForm(Stack stack,const MMesh & Th, - const FESpace1 & Uh,const FESpace2 & Vh,bool sym, - MC * A,KN_ * B,const list &largs, int * mpirankandsize = nullptr); - -template void AssembleBC(Stack stack,const MMesh & Th, - const FESpace1 & Uh,const FESpace2 & Vh,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, - const list &largs , double tgv , int * mpirankandsize = nullptr); - -// 2d case -template void AssembleLinearForm(Stack stack,const Mesh & Th,const FESpace & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize = nullptr); -template void Element_rhs(const FElement & Kv,int ie,int label,const LOperaD &Op,double * p,void * stack,KN_ & B,bool all,int optim); -template void Element_rhs(const FElement & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B,int optim); -template void Element_Op(MatriceElementairePleine & mat,const FElement & Ku,const FElement & Kv,double * p, - int ie,int label, void *stack,R2 *B); -template void Element_Op(MatriceElementaireSymetrique & mat,const FElement & Ku,double * p,int ie,int label, - void * stack,R2 *B); -template void AssembleBC(Stack stack,const Mesh & Th3,const FESpace & Uh3,const FESpace & Vh3,bool sym, - MatriceCreuse * A,KN_ * B,KN_ * X, const BC_set * bc , double tgv, int * mpirankandsize = nullptr); - - -// 3d volume case -template void AssembleLinearForm(Stack stack,const Mesh3 & Th,const FESpace3 & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize = nullptr); -template void Element_rhs(const FElement3 & Kv,int ie,int label,const LOperaD &Op,double * p,void * stack,KN_ & B,bool all,int optim); -template void Element_rhs(const FElement3 & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B,int optim); -template void Element_Op(MatriceElementairePleine & mat,const FElement3 & Ku,const FElement3 & Kv,double * p, - int ie,int label, void *stack,R3 *B); -template void Element_Op(MatriceElementaireSymetrique & mat,const FElement3 & Ku,double * p,int ie,int label, - void * stack,R3 *B); - -// 3d surface case -template void AssembleLinearForm(Stack stack,const MeshS & Th,const FESpaceS & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize = nullptr); -template void Element_rhs(const FElementS & Kv,int ie,int label,const LOperaD &Op,double * p,void * stack,KN_ & B,bool all,int optim); -template void Element_rhs(const FElementS & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B,int optim); -template void Element_Op(MatriceElementairePleine & mat,const FElementS & Ku,const FElementS & Kv,double * p, - int ie,int label, void *stack,R3 *B); -template void Element_Op(MatriceElementaireSymetrique & mat,const FElementS & Ku,double * p,int ie,int label, - void * stack,R3 *B); - -// 3d curve case -template void AssembleLinearForm(Stack stack,const MeshL & Th,const FESpaceL & Vh,KN_ * B,const FormLinear * const l, int * mpirankandsize = nullptr); -template void Element_rhs(const FElementL & Kv,int ie,int label,const LOperaD &Op,double * p,void * stack,KN_ & B,bool all,int optim); -template void Element_rhs(const FElementL & Kv,const LOperaD &Op,double * p,void * stack,KN_ & B,int optim); -template void Element_Op(MatriceElementairePleine & mat,const FElementL & Ku,const FElementL & Kv,double * p, - int ie,int label, void *stack,R3 *B); -template void Element_Op(MatriceElementaireSymetrique & mat,const FElementL & Ku,double * p,int ie,int label, - void * stack,R3 *B); - -} - - -template -AnyType OpArraytoLinearForm::Op::operator()(Stack stack) const -{ + // general templates for 2d and 3d volume // for Surf version ... + template< class R, typename MC, class MMesh, class FESpace1, class FESpace2 > + bool AssembleVarForm(Stack stack, const MMesh &Th, const FESpace1 &Uh, const FESpace2 &Vh, bool sym, MC *A, KN_< R > *B, const list< C_F0 > &largs, int *mpirankandsize = nullptr); + + template< class R, class MMesh, class FESpace1, class FESpace2 > + void AssembleBC(Stack stack, const MMesh &Th, const FESpace1 &Uh, const FESpace2 &Vh, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const list< C_F0 > &largs, double tgv, + int *mpirankandsize = nullptr); + + // 2d case + template< class R > + void AssembleLinearForm(Stack stack, const Mesh &Th, const FESpace &Vh, KN_< R > *B, const FormLinear *const l, int *mpirankandsize = nullptr); + template< class R > + void Element_rhs(const FElement &Kv, int ie, int label, const LOperaD &Op, double *p, void *stack, KN_< R > &B, bool all, int optim); + template< class R > + void Element_rhs(const FElement &Kv, const LOperaD &Op, double *p, void *stack, KN_< R > &B, int optim); + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpace > &mat, const FElement &Ku, const FElement &Kv, double *p, int ie, int label, void *stack, R2 *B); + template< class R > + void Element_Op(MatriceElementaireSymetrique< R, FESpace > &mat, const FElement &Ku, double *p, int ie, int label, void *stack, R2 *B); + template< class R > + void AssembleBC(Stack stack, const Mesh &Th3, const FESpace &Uh3, const FESpace &Vh3, bool sym, MatriceCreuse< R > *A, KN_< R > *B, KN_< R > *X, const BC_set *bc, double tgv, + int *mpirankandsize = nullptr); + + // 3d volume case + template< class R > + void AssembleLinearForm(Stack stack, const Mesh3 &Th, const FESpace3 &Vh, KN_< R > *B, const FormLinear *const l, int *mpirankandsize = nullptr); + template< class R > + void Element_rhs(const FElement3 &Kv, int ie, int label, const LOperaD &Op, double *p, void *stack, KN_< R > &B, bool all, int optim); + template< class R > + void Element_rhs(const FElement3 &Kv, const LOperaD &Op, double *p, void *stack, KN_< R > &B, int optim); + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpace3 > &mat, const FElement3 &Ku, const FElement3 &Kv, double *p, int ie, int label, void *stack, R3 *B); + template< class R > + void Element_Op(MatriceElementaireSymetrique< R, FESpace3 > &mat, const FElement3 &Ku, double *p, int ie, int label, void *stack, R3 *B); + + // 3d surface case + template< class R > + void AssembleLinearForm(Stack stack, const MeshS &Th, const FESpaceS &Vh, KN_< R > *B, const FormLinear *const l, int *mpirankandsize = nullptr); + template< class R > + void Element_rhs(const FElementS &Kv, int ie, int label, const LOperaD &Op, double *p, void *stack, KN_< R > &B, bool all, int optim); + template< class R > + void Element_rhs(const FElementS &Kv, const LOperaD &Op, double *p, void *stack, KN_< R > &B, int optim); + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpaceS > &mat, const FElementS &Ku, const FElementS &Kv, double *p, int ie, int label, void *stack, R3 *B); + template< class R > + void Element_Op(MatriceElementaireSymetrique< R, FESpaceS > &mat, const FElementS &Ku, double *p, int ie, int label, void *stack, R3 *B); + + // 3d curve case + template< class R > + void AssembleLinearForm(Stack stack, const MeshL &Th, const FESpaceL &Vh, KN_< R > *B, const FormLinear *const l, int *mpirankandsize = nullptr); + template< class R > + void Element_rhs(const FElementL &Kv, int ie, int label, const LOperaD &Op, double *p, void *stack, KN_< R > &B, bool all, int optim); + template< class R > + void Element_rhs(const FElementL &Kv, const LOperaD &Op, double *p, void *stack, KN_< R > &B, int optim); + template< class R > + void Element_Op(MatriceElementairePleine< R, FESpaceL > &mat, const FElementL &Ku, const FElementL &Kv, double *p, int ie, int label, void *stack, R3 *B); + template< class R > + void Element_Op(MatriceElementaireSymetrique< R, FESpaceL > &mat, const FElementL &Ku, double *p, int ie, int label, void *stack, R3 *B); + +} // namespace Fem2D + +template< class R, class MMesh, class v_fes > +AnyType OpArraytoLinearForm< R, MMesh, v_fes >::Op::operator( )(Stack stack) const { typedef v_fes *pfes; - typedef typename v_fes::FESpace FESpaceT; - typedef typename FESpaceT::FElement FElementT; + typedef typename v_fes::FESpace FESpaceT; + typedef typename FESpaceT::FElement FElementT; /*typedef typename MMesh::Element ElementT; typedef typename MMesh::Vertex VertexT; typedef typename MMesh::RdHat RdHatT; typedef typename MMesh::Rd RdT;*/ - pfes & pp= *GetAny((*l->ppfes)(stack)); - FESpaceT * pVh = *pp ; - FESpaceT & Vh = *pVh ; - double tgv= ff_tgv; - if (l->nargs[0]) tgv= GetAny((*l->nargs[0])(stack)); - long NbOfDF = pVh ? Vh.NbOfDF: 0; - KN *px=0; - if(isptr) - { - px = GetAny * >((*x)(stack) ); - if(init ) - px->init(NbOfDF); - - if(px->N() != NbOfDF) //add Dec 2009 - { - if(!zero ) ExecError("Error in OpArraytoLinearForm += not correct size: n != NbOfDF !"); - px->resize(NbOfDF); - } - ffassert(px->N() == NbOfDF); - } - KN_ xx( px ? *(KN_ *) px : GetAny >((*x)(stack) )); - KN cc; - list::const_iterator ii,ib=l->largs.begin(), - ie=l->largs.end(); - using namespace FreeFempp; - TypeVarForm *tvf=FreeFempp::TypeVarForm::Global; - assert( tvf); - bool ret = false; - for (ii=ib;ii != ie;ii++) + pfes &pp = *GetAny< pfes * >((*l->ppfes)(stack)); + FESpaceT *pVh = *pp; + FESpaceT &Vh = *pVh; + double tgv = ff_tgv; + if (l->nargs[0]) tgv = GetAny< double >((*l->nargs[0])(stack)); + long NbOfDF = pVh ? Vh.NbOfDF : 0; + KN< R > *px = 0; + if (isptr) { + px = GetAny< KN< R > * >((*x)(stack)); + if (init) px->init(NbOfDF); + + if (px->N( ) != NbOfDF) // add Dec 2009 { - if (ii->left() == tvf->tBC) { - ret=true; - continue; - } + if (!zero) ExecError("Error in OpArraytoLinearForm += not correct size: n != NbOfDF !"); + px->resize(NbOfDF); + } + ffassert(px->N( ) == NbOfDF); + } + KN_< R > xx(px ? *(KN_< R > *)px : GetAny< KN_< R > >((*x)(stack))); + KN< R > cc; + list< C_F0 >::const_iterator ii, ib = l->largs.begin( ), ie = l->largs.end( ); + using namespace FreeFempp; + TypeVarForm< R > *tvf = FreeFempp::TypeVarForm< R >::Global; + assert(tvf); + bool ret = false; + for (ii = ib; ii != ie; ii++) { + if (ii->left( ) == tvf->tBC) { + ret = true; + continue; } - if(zero && NbOfDF) - xx=R(); - else if(!zero && NbOfDF && ret) { + } + if (zero && NbOfDF) + xx = R( ); + else if (!zero && NbOfDF && ret) { cc.resize(xx.n); cc = xx; } - if ( pVh && AssembleVarForm,MMesh,FESpaceT,FESpaceT>(stack,Vh.Th,Vh,Vh,false,0,&xx,l->largs) ) { + if (pVh && AssembleVarForm< R, MatriceCreuse< R >, MMesh, FESpaceT, FESpaceT >(stack, Vh.Th, Vh, Vh, false, 0, &xx, l->largs)) { if (!zero && NbOfDF && ret) { - KN bb(xx.n, std::numeric_limits::lowest()); - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&bb,0,l->largs,tgv); - for(int i = 0; i < xx.n; ++i) - if(bb[i] != std::numeric_limits::lowest()) - xx[i] = cc[i] + bb[i]; - } - else - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&xx,0,l->largs,tgv); + KN< R > bb(xx.n, std::numeric_limits< double >::lowest( )); + AssembleBC< R, MMesh, FESpaceT, FESpaceT >(stack, Vh.Th, Vh, Vh, false, 0, &bb, 0, l->largs, tgv); + for (int i = 0; i < xx.n; ++i) + if (bb[i] != std::numeric_limits< double >::lowest( )) xx[i] = cc[i] + bb[i]; + } else + AssembleBC< R, MMesh, FESpaceT, FESpaceT >(stack, Vh.Th, Vh, Vh, false, 0, &xx, 0, l->largs, tgv); } - return SetAny >(xx); + return SetAny< KN_< R > >(xx); } #include "compositeFESpace.hpp" /** - * @brief Builds a new largs whit each element are included in one block - * @param largs list of argument of the initial Forms - * @param NpVh number of FESpace in Vh - * @param indexBlockVh give the index of the block for a given component of FESpace Vh - * - */ - -// -inline KN< list > creationLinearFormCompositeFESpace( const list & largs, const int& NpVh, const KN & indexBlockVh - ,const KN &localIndexInTheBlockVh ) -{ + * @brief Builds a new largs whit each element are included in one block + * @param largs list of argument of the initial Forms + * @param NpVh number of FESpace in Vh + * @param indexBlockVh give the index of the block for a given component of FESpace Vh + * + */ + +// +inline KN< list< C_F0 > > creationLinearFormCompositeFESpace(const list< C_F0 > &largs, const int &NpVh, const KN< int > &indexBlockVh, const KN< int > &localIndexInTheBlockVh) { // hypothesis :: NpUh = NpVh // :: indexBlockUh = indexBlockVh // :: localIndexInTheBlockUh = localIndexInTheBlockVh // This hypothesis is BC_set condition - KNM< list > block_largs; - block_largs.resize( (long) NpVh, (long) NpVh ); - - list tmp_largs = creationLargsForCompositeFESpace( largs, NpVh, NpVh, indexBlockVh, indexBlockVh ); - block_largs = computeBlockLargs( tmp_largs, NpVh, NpVh, indexBlockVh, indexBlockVh ); - changeComponentFormCompositeFESpace( localIndexInTheBlockVh, localIndexInTheBlockVh, block_largs ); + KNM< list< C_F0 > > block_largs; + block_largs.resize((long)NpVh, (long)NpVh); + + list< C_F0 > tmp_largs = creationLargsForCompositeFESpace(largs, NpVh, NpVh, indexBlockVh, indexBlockVh); + block_largs = computeBlockLargs(tmp_largs, NpVh, NpVh, indexBlockVh, indexBlockVh); + changeComponentFormCompositeFESpace(localIndexInTheBlockVh, localIndexInTheBlockVh, block_largs); // Remark : block_largs contains Bilinear and Non diagonnal if you use one varf to define Matrix and rhs - KN< list > block_diag_largs( (long) NpVh); - for( int i=0; i & tp_largs = block_largs(i,i); - list::const_iterator ii,ib=tp_largs.begin(),ie=tp_largs.end(); - for (ii=ib;ii != ie;ii++) { - aType r = ii->left(); - if(r == atype() || r==atype() ){ + KN< list< C_F0 > > block_diag_largs((long)NpVh); + for (int i = 0; i < NpVh; i++) { + const list< C_F0 > &tp_largs = block_largs(i, i); + list< C_F0 >::const_iterator ii, ib = tp_largs.begin( ), ie = tp_largs.end( ); + for (ii = ib; ii != ie; ii++) { + aType r = ii->left( ); + if (r == atype< const BC_set * >( ) || r == atype< const FormLinear * >( )) { // only add BC_set in FormLinear in the varf that we want to evaluate block_diag_largs(i).push_back(*ii); } } } - return block_diag_largs; + return block_diag_largs; } -template -AnyType OpArraytoLinearFormVG::Op::operator()(Stack stack) const -{ +template< class R > +AnyType OpArraytoLinearFormVG< R >::Op::operator( )(Stack stack) const { // typedef typename v_fes::FESpace FESpaceT; - // get tgv value - double tgv= ff_tgv; - if (l->nargs[0]) tgv= GetAny((*l->nargs[0])(stack)); - pcommworld commworld = nullptr; // PLACEHOLDER FOR DISTRIBUTED PARAMETER FOR LINEAR FORMS + // get tgv value + double tgv = ff_tgv; + if (l->nargs[0]) tgv = GetAny< double >((*l->nargs[0])(stack)); + pcommworld commworld = nullptr; // PLACEHOLDER FOR DISTRIBUTED PARAMETER FOR LINEAR FORMS // get the composite FESpace - pvectgenericfes * pCompoVh= GetAny((*l->ppfes)(stack)); - ffassert( *pCompoVh ); - (*pCompoVh)->update(); - -// get info the composite FESpace - int NpVh = (*pCompoVh)->N; - KN VhNbItem = (*pCompoVh)->vectOfNbitem(); - KN VhNbOfDf = (*pCompoVh)->vectOfNbOfDF(); - // get x from the stack - long totalNbOfDF = (*pCompoVh) ? (*pCompoVh)->totalNbOfDF(): 0; - KN *px=0; - if(isptr) + pvectgenericfes *pCompoVh = GetAny< pvectgenericfes * >((*l->ppfes)(stack)); + ffassert(*pCompoVh); + (*pCompoVh)->update( ); + + // get info the composite FESpace + int NpVh = (*pCompoVh)->N; + KN< int > VhNbItem = (*pCompoVh)->vectOfNbitem( ); + KN< int > VhNbOfDf = (*pCompoVh)->vectOfNbOfDF( ); + // get x from the stack + long totalNbOfDF = (*pCompoVh) ? (*pCompoVh)->totalNbOfDF( ) : 0; + KN< R > *px = 0; + if (isptr) { + px = GetAny< KN< R > * >((*x)(stack)); + if (init) px->init(totalNbOfDF); + + if (px->N( ) != totalNbOfDF) // add Dec 2009 { - px = GetAny * >((*x)(stack) ); - if(init ) - px->init(totalNbOfDF); - - if(px->N() != totalNbOfDF) //add Dec 2009 - { - if(!zero ) ExecError("Error in OpArraytoLinearForm += not correct size: n != NbOfDF !"); - px->resize(totalNbOfDF); - } - ffassert(px->N() == totalNbOfDF); - } + if (!zero) ExecError("Error in OpArraytoLinearForm += not correct size: n != NbOfDF !"); + px->resize(totalNbOfDF); + } + ffassert(px->N( ) == totalNbOfDF); + } // construction of the Array of Composite FESpace - KN_ xx( px ? *(KN_ *) px : GetAny >((*x)(stack) )); - if(zero && totalNbOfDF ) - xx=R(); - - int VhtotalNbItem=0; - for(int i=0; i< NpVh; i++) VhtotalNbItem += VhNbItem[i]; + KN_< R > xx(px ? *(KN_< R > *)px : GetAny< KN_< R > >((*x)(stack))); + if (zero && totalNbOfDF) xx = R( ); + int VhtotalNbItem = 0; + for (int i = 0; i < NpVh; i++) VhtotalNbItem += VhNbItem[i]; - KN beginBlockVh( NpVh ); - KN indexBlockVh( VhtotalNbItem ); - KN localIndexInTheBlockVh( VhtotalNbItem ); + KN< int > beginBlockVh(NpVh); + KN< int > indexBlockVh(VhtotalNbItem); + KN< int > localIndexInTheBlockVh(VhtotalNbItem); - int current_index=0; - for(int i=0; i & b_largs=l->block_largs(j); + const list< C_F0 > &b_largs = l->block_largs(j); int M_block = VhNbOfDf[j]; - if( b_largs.size() > 0 ){ - - if(!parallel_assemble){ - KN xxblock2(M_block); - xxblock2=R(); // initiallise the block to zero ??? (get previous value of xxblock2). + if (b_largs.size( ) > 0) { + + if (!parallel_assemble) { + KN< R > xxblock2(M_block); + xxblock2 = R( ); // initiallise the block to zero ??? (get previous value of xxblock2). - if( (*pCompoVh)->typeFE[j] == 2 ){ - // 2d Mesh - FESpace * pVh = (FESpace*) (*pCompoVh)->vect[j]->getpVh();; - FESpace & Vh = *pVh; + if ((*pCompoVh)->typeFE[j] == 2) { + // 2d Mesh + FESpace *pVh = (FESpace *)(*pCompoVh)->vect[j]->getpVh( ); + ; + FESpace &Vh = *pVh; - if ( pVh && AssembleVarForm,Mesh,FESpace,FESpace>(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,b_largs) ) - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,0,b_largs,tgv); + if (pVh && AssembleVarForm< R, MatriceCreuse< R >, Mesh, FESpace, FESpace >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, b_largs)) + AssembleBC< R, Mesh, FESpace, FESpace >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, 0, b_largs, tgv); - }else if( (*pCompoVh)->typeFE[j] == 3 ){ + } else if ((*pCompoVh)->typeFE[j] == 3) { // 3d Mesh - FESpace3 * pVh = (FESpace3*) (*pCompoVh)->vect[j]->getpVh();; - FESpace3 & Vh = *pVh; + FESpace3 *pVh = (FESpace3 *)(*pCompoVh)->vect[j]->getpVh( ); + ; + FESpace3 &Vh = *pVh; - if ( pVh && AssembleVarForm,Mesh3,FESpace3,FESpace3>(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,b_largs) ) - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,0,b_largs,tgv); + if (pVh && AssembleVarForm< R, MatriceCreuse< R >, Mesh3, FESpace3, FESpace3 >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, b_largs)) + AssembleBC< R, Mesh3, FESpace3, FESpace3 >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, 0, b_largs, tgv); - }else if( (*pCompoVh)->typeFE[j] == 4 ){ - // 3d Surface Mesh - FESpaceS * pVh = (FESpaceS*) (*pCompoVh)->vect[j]->getpVh();; - FESpaceS & Vh = *pVh; + } else if ((*pCompoVh)->typeFE[j] == 4) { + // 3d Surface Mesh + FESpaceS *pVh = (FESpaceS *)(*pCompoVh)->vect[j]->getpVh( ); + ; + FESpaceS &Vh = *pVh; - if ( pVh && AssembleVarForm,MeshS,FESpaceS,FESpaceS>(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,b_largs) ) - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,0,b_largs,tgv); + if (pVh && AssembleVarForm< R, MatriceCreuse< R >, MeshS, FESpaceS, FESpaceS >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, b_largs)) + AssembleBC< R, MeshS, FESpaceS, FESpaceS >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, 0, b_largs, tgv); - }else if( (*pCompoVh)->typeFE[j] == 5 ){ + } else if ((*pCompoVh)->typeFE[j] == 5) { // 3d Curve Mesh - FESpaceL * pVh = (FESpaceL*) (*pCompoVh)->vect[j]->getpVh();; - FESpaceL & Vh = *pVh; + FESpaceL *pVh = (FESpaceL *)(*pCompoVh)->vect[j]->getpVh( ); + ; + FESpaceL &Vh = *pVh; - if ( pVh && AssembleVarForm,MeshL,FESpaceL,FESpaceL>(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,b_largs) ) - AssembleBC(stack,Vh.Th,Vh,Vh,false,0,&xxblock2,0,b_largs,tgv); + if (pVh && AssembleVarForm< R, MatriceCreuse< R >, MeshL, FESpaceL, FESpaceL >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, b_largs)) + AssembleBC< R, MeshL, FESpaceL, FESpaceL >(stack, Vh.Th, Vh, Vh, false, 0, &xxblock2, 0, b_largs, tgv); - } - else{ - cerr << "Error in the definition in the type of FESpace." << endl; + } else { + cerr << "Error in the definition in the type of FESpace." << endl; ffassert(0); } - for(int indexJ=0; indexJ bidon(totalNbOfDF); - bool rhs_from_varf=true; - //KN bidon(1); ??? - varfToCompositeBlockLinearSystemALLCASE_pfes( j, j, - (*pCompoVh)->typeFE[j], (*pCompoVh)->typeFE[j], - offsetVh, offsetVh, - (*pCompoVh)->vect[j], (*pCompoVh)->vect[j], - false, false, false, tgv, commworld, - b_largs, stack, - &xx , &bidon, nullptr,rhs_from_varf); + // delete [] xxblock2; + } else { + KN< R > bidon(totalNbOfDF); + bool rhs_from_varf = true; + // KN bidon(1); ??? + varfToCompositeBlockLinearSystemALLCASE_pfes< R >(j, j, (*pCompoVh)->typeFE[j], (*pCompoVh)->typeFE[j], offsetVh, offsetVh, (*pCompoVh)->vect[j], (*pCompoVh)->vect[j], false, false, false, + tgv, commworld, b_largs, stack, &xx, &bidon, nullptr, rhs_from_varf); } } offsetVh += M_block; } - return SetAny >(xx); + return SetAny< KN_< R > >(xx); } - - -template +template< typename KK, typename vv_fes, typename CC > struct FF_L_args { - typedef KK K; - typedef vv_fes v_fes; - typedef v_fes *pfes; - typedef typename v_fes::FESpace FESpaceT; - typedef typename FESpaceT::Mesh MeshT; - typedef FEbase ** R; - typedef R A; - typedef pfes* B; - typedef const CC * C; - typedef CC * MC; - static bool Check(MC l) {return IsComplexType::value==FieldOfForm(l->largs,IsComplexType::value);} - static MC Clone(Expression ll){C l = dynamic_cast(ll);ffassert(l);return new CC(*l); } - static void f(KN *x,MC l,A pp,Stack stack) - { - ffassert(l); - double tgv=ff_tgv; - if (l->nargs[0]) tgv= GetAny((*l->nargs[0])(stack)); - FESpaceT * pVh= (*pp)->newVh(); - KN_ xx=*x; - if ( pVh && AssembleVarForm,MeshT,FESpaceT,FESpaceT>(stack,pVh->Th,*pVh,*pVh,false,0,&xx,l->largs) ) - AssembleBC(stack,pVh->Th,*pVh,*pVh,false,0,&xx,0,l->largs,tgv); - } + typedef KK K; + typedef vv_fes v_fes; + typedef v_fes *pfes; + typedef typename v_fes::FESpace FESpaceT; + typedef typename FESpaceT::Mesh MeshT; + typedef FEbase< K, v_fes > **R; + typedef R A; + typedef pfes *B; + typedef const CC *C; + typedef CC *MC; + static bool Check(MC l) { return IsComplexType< K >::value == FieldOfForm(l->largs, IsComplexType< K >::value); } + static MC Clone(Expression ll) { + C l = dynamic_cast< C >(ll); + ffassert(l); + return new CC(*l); + } + static void f(KN< K > *x, MC l, A pp, Stack stack) { + ffassert(l); + double tgv = ff_tgv; + if (l->nargs[0]) tgv = GetAny< double >((*l->nargs[0])(stack)); + FESpaceT *pVh = (*pp)->newVh( ); + KN_< K > xx = *x; + if (pVh && AssembleVarForm< K, MatriceCreuse< K >, MeshT, FESpaceT, FESpaceT >(stack, pVh->Th, *pVh, *pVh, false, 0, &xx, l->largs)) + AssembleBC< K, MeshT, FESpaceT, FESpaceT >(stack, pVh->Th, *pVh, *pVh, false, 0, &xx, 0, l->largs, tgv); + } }; -template -struct CGMatVirtPreco : CGMatVirt -{ - int n; - MatriceMorse *A; - CGMatVirtPreco(Stack stack,const OneOperator* pprecon,MatriceMorse *HA); - R * addmatmul(R *x,R *Ax) - { - - } +template< class R = double > +struct CGMatVirtPreco : CGMatVirt< int, R > { + int n; + MatriceMorse< R > *A; + CGMatVirtPreco(Stack stack, const OneOperator *pprecon, MatriceMorse< R > *HA); + R *addmatmul(R *x, R *Ax) {} }; -template -void creationBlockOfMatrixToBilinearForm( const FESpace1 * PUh, const FESpace2 * PVh, const int &sym, const double &tgv, - const list & largs, Stack stack, Matrice_Creuse &A, int * mpirankandsize = nullptr); - -template -AnyType OpMatrixtoBilinearForm::Op::operator()(Stack stack) const -{ - typedef typename MMesh::Element Element; - typedef typename MMesh::Vertex Vertex; - typedef typename MMesh::RdHat RdHat; - typedef typename MMesh::Rd Rd; - - typedef typename v_fes1::pfes pfes1; - typedef typename v_fes1::FESpace FESpace1; - typedef typename FESpace1::Mesh Mesh1; - typedef typename FESpace1::FElement FElement1; - - typedef typename v_fes2::pfes pfes2; - typedef typename v_fes2::FESpace FESpace2; - typedef typename FESpace2::Mesh Mesh2; - typedef typename FESpace2::FElement FElement2; - assert(b && b->nargs);// *GetAny - pfes1 * pUh= GetAny((*b->euh)(stack)); - pfes2 * pVh= GetAny((*b->evh)(stack)); - const FESpace1 * PUh = (FESpace1*) **pUh ; - const FESpace2 * PVh = (FESpace2*) **pVh ; - bool A_is_square= (void*)PUh == (void*)PVh || (PUh->NbOfDF) == (PVh->NbOfDF) ; - - bool VF=isVF(b->largs); +template< class R, class MMESH, class FESpace1, class FESpace2 > +void creationBlockOfMatrixToBilinearForm(const FESpace1 *PUh, const FESpace2 *PVh, const int &sym, const double &tgv, const list< C_F0 > &largs, Stack stack, Matrice_Creuse< R > &A, + int *mpirankandsize = nullptr); + +template< class R, class MMesh, class v_fes1, class v_fes2 > +AnyType OpMatrixtoBilinearForm< R, MMesh, v_fes1, v_fes2 >::Op::operator( )(Stack stack) const { + typedef typename MMesh::Element Element; + typedef typename MMesh::Vertex Vertex; + typedef typename MMesh::RdHat RdHat; + typedef typename MMesh::Rd Rd; + + typedef typename v_fes1::pfes pfes1; + typedef typename v_fes1::FESpace FESpace1; + typedef typename FESpace1::Mesh Mesh1; + typedef typename FESpace1::FElement FElement1; + + typedef typename v_fes2::pfes pfes2; + typedef typename v_fes2::FESpace FESpace2; + typedef typename FESpace2::Mesh Mesh2; + typedef typename FESpace2::FElement FElement2; + assert(b && b->nargs); // *GetAny + pfes1 *pUh = GetAny< pfes1 * >((*b->euh)(stack)); + pfes2 *pVh = GetAny< pfes2 * >((*b->evh)(stack)); + const FESpace1 *PUh = (FESpace1 *)**pUh; + const FESpace2 *PVh = (FESpace2 *)**pVh; + bool A_is_square = (void *)PUh == (void *)PVh || (PUh->NbOfDF) == (PVh->NbOfDF); + + bool VF = isVF(b->largs); Data_Sparse_Solver ds; - ds.factorize=0; - ds.initmat=true; + ds.factorize = 0; + ds.initmat = true; int np = OpCall_FormBilinear_np::n_name_param - NB_NAME_PARM_HMAT; - SetEnd_Data_Sparse_Solver(stack,ds, b->nargs,np); + SetEnd_Data_Sparse_Solver< R >(stack, ds, b->nargs, np); - if (! A_is_square ) - { - if(verbosity>3) cout << " -- the solver is un set on rectangular matrix " << endl; - } - WhereStackOfPtr2Free(stack)=new StackOfPtr2Free(stack);// FH aout 2007 + if (!A_is_square) { + if (verbosity > 3) cout << " -- the solver is un set on rectangular matrix " << endl; + } + WhereStackOfPtr2Free(stack) = new StackOfPtr2Free(stack); // FH aout 2007 - Matrice_Creuse & A( * GetAny*>((*a)(stack))); - // - if(init) A.init(); // - if( ! PUh || ! PVh) return SetAny *>(&A); + Matrice_Creuse< R > &A(*GetAny< Matrice_Creuse< R > * >((*a)(stack))); + // + if (init) A.init( ); // + if (!PUh || !PVh) return SetAny< Matrice_Creuse< R > * >(&A); - creationBlockOfMatrixToBilinearForm( PUh, PVh, ds.sym, ds.tgv, b->largs, stack, A); + creationBlockOfMatrixToBilinearForm< R, MMesh, FESpace1, FESpace2 >(PUh, PVh, ds.sym, ds.tgv, b->largs, stack, A); - A.pHM()->half = ds.sym; - if (A_is_square) - SetSolver(stack,VF,*A.A,ds); - - return SetAny *>(&A); + A.pHM( )->half = ds.sym; + if (A_is_square) SetSolver(stack, VF, *A.A, ds); + return SetAny< Matrice_Creuse< R > * >(&A); } -template -void creationBlockOfMatrixToBilinearForm( const FESpace1 * PUh, const FESpace2 * PVh, const int &sym, const double &tgv, - const list & largs, Stack stack, Matrice_Creuse &A, int * mpirankandsize){ - typedef typename FESpace1::Mesh Mesh1; - typedef typename FESpace2::Mesh Mesh2; +template< class R, class MMesh, class FESpace1, class FESpace2 > +void creationBlockOfMatrixToBilinearForm(const FESpace1 *PUh, const FESpace2 *PVh, const int &sym, const double &tgv, const list< C_F0 > &largs, Stack stack, Matrice_Creuse< R > &A, + int *mpirankandsize) { + typedef typename FESpace1::Mesh Mesh1; + typedef typename FESpace2::Mesh Mesh2; // this lines must be defined outside this function // if(init) A.init(); // if( ! PUh || ! PVh) return SetAny *>(&A); - const FESpace1 & Uh = *PUh ; - const FESpace2 & Vh = *PVh ; - const MMesh* pTh = (is_same< Mesh1, Mesh2 >::value) ? (MMesh*)&PUh->Th : 0; - const MMesh &Th= *pTh ; // integration Th - bool same=isSameMesh(largs, &Uh.Th, &Vh.Th, stack); - if ( same) - { - if ( A.Uh != Uh || A.Vh != Vh ) - { // reconstruct all the matrix - A.A=0; // to delete old matrix ADD FH 16112005 - A.Uh=Uh; - A.Vh=Vh; - if (sym ){ - A.A.master( new MatriceMorse(Vh.NbOfDF,Vh.NbOfDF,sym) ); - ffassert( (void*)&Uh == (void*)&Vh); - } - else - A.A.master( new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,Vh.NbOfDF*2,0) ); // lines corresponding to test functions - // reset the solver ... - } - *A.A=R(); // reset value of the matrix - if ( AssembleVarForm,MMesh,FESpace1,FESpace2 >( stack,Th,Uh,Vh,sym>0,A.A,0,largs,mpirankandsize) ) - AssembleBC( stack,Th,Uh,Vh,sym>0,A.A,0,0,largs,tgv); - } - else - { // add FH 17 06 2005 int on different meshes. + const FESpace1 &Uh = *PUh; + const FESpace2 &Vh = *PVh; + const MMesh *pTh = (is_same< Mesh1, Mesh2 >::value) ? (MMesh *)&PUh->Th : 0; + const MMesh &Th = *pTh; // integration Th + bool same = isSameMesh(largs, &Uh.Th, &Vh.Th, stack); + if (same) { + if (A.Uh != Uh || A.Vh != Vh) { // reconstruct all the matrix + A.A = 0; // to delete old matrix ADD FH 16112005 + A.Uh = Uh; + A.Vh = Vh; + if (sym) { + A.A.master(new MatriceMorse< R >(Vh.NbOfDF, Vh.NbOfDF, sym)); + ffassert((void *)&Uh == (void *)&Vh); + } else + A.A.master(new MatriceMorse< R >(Vh.NbOfDF, Uh.NbOfDF, Vh.NbOfDF * 2, 0)); // lines corresponding to test functions + // reset the solver ... + } + *A.A = R( ); // reset value of the matrix + if (AssembleVarForm< R, MatriceCreuse< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, A.A, 0, largs, mpirankandsize)) + AssembleBC< R, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, A.A, 0, 0, largs, tgv); + } else { // add FH 17 06 2005 int on different meshes. #ifdef V3__CODE - MatriceMap AAA; - MatriceMorse *pMA = new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,AAA.size(),sym>0); - bool bc=AssembleVarForm,MMesh,FESpace1,FESpace2>( stack,Th,Uh,Vh,sym>0,&AAA,0,largs); - pMA->addMap(1.,AAA); + MatriceMap< R > AAA; + MatriceMorse< R > *pMA = new MatriceMorse< R >(Vh.NbOfDF, Uh.NbOfDF, AAA.size( ), sym > 0); + bool bc = AssembleVarForm< R, MatriceMap< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, &AAA, 0, largs); + pMA->addMap(1., AAA); #else - MatriceMorse *pMA = new MatriceMorse(Vh.NbOfDF,Uh.NbOfDF,0,sym); - MatriceMap & AAA = *pMA; - bool bc=AssembleVarForm,MMesh,FESpace1,FESpace2>( stack,Th,Uh,Vh,sym>0,&AAA,0,largs,mpirankandsize); + MatriceMorse< R > *pMA = new MatriceMorse< R >(Vh.NbOfDF, Uh.NbOfDF, 0, sym); + MatriceMap< R > &AAA = *pMA; + bool bc = AssembleVarForm< R, MatriceMap< R >, MMesh, FESpace1, FESpace2 >(stack, Th, Uh, Vh, sym > 0, &AAA, 0, largs, mpirankandsize); #endif - A.A.master(pMA ) ; + A.A.master(pMA); - if (bc) - AssembleBC( stack,Th,Uh,Vh,sym>0,A.A,0,0,largs,tgv); - - } + if (bc) AssembleBC< R >(stack, Th, Uh, Vh, sym > 0, A.A, 0, 0, largs, tgv); + } } -//bool SetGMRES(); -//bool SetCG(); +// bool SetGMRES(); +// bool SetCG(); #ifdef HAVE_LIBUMFPACK -//bool SetUMFPACK(); +// bool SetUMFPACK(); #endif namespace FreeFempp { -template -class TypeVarForm { public: + template< class R > + class TypeVarForm { + public: aType tFB; aType tMat; aType tMat3; aType tFL; - //aType tFL3; + // aType tFL3; aType tTab; aType tMatX; aType tMatTX; aType tDotStar; - aType tBC ; - // aType tBC3 ; -TypeVarForm() : - tFB( atype() ), - // tBemKFB( atype() ), - //tFB3( atype *>() ), - tMat( atype*>() ), - // tMat3( atype*>() ), - tFL( atype() ), - //tFL3( atype *>() ), - tTab( atype *>() ), - tMatX( atype::plusAx >() ), - tMatTX( atype::plusAtx >() ), - tDotStar(atype< DotStar_KN_ >() ), - tBC( atype()) - { } - - - static TypeVarForm *Global; -}; + aType tBC; + // aType tBC3 ; + TypeVarForm( ) + : tFB(atype< const FormBilinear * >( )), + // tBemKFB( atype() ), + // tFB3( atype *>() ), + tMat(atype< Matrice_Creuse< R > * >( )), + // tMat3( atype*>() ), + tFL(atype< const FormLinear * >( )), + // tFL3( atype *>() ), + tTab(atype< KN< R > * >( )), tMatX(atype< typename RNM_VirtualMatrix< R >::plusAx >( )), tMatTX(atype< typename RNM_VirtualMatrix< R >::plusAtx >( )), tDotStar(atype< DotStar_KN_< R > >( )), + tBC(atype< const BC_set * >( )) {} + + static TypeVarForm *Global; + }; -} +} // namespace FreeFempp #endif diff --git a/src/fflib/renumb.hpp b/src/fflib/renumb.hpp index 34a37f2a0..fa16638b7 100644 --- a/src/fflib/renumb.hpp +++ b/src/fflib/renumb.hpp @@ -47,21 +47,15 @@ namespace renumb { void i4vec_print(int n, int a[], string title); void adj_print(int node_num, int adj_num, int adj_row[], int adj[], string title); - void adj_print_some(int node_num, int node_lo, int node_hi, int adj_num, int adj_row[], int adj[], - string title); + void adj_print_some(int node_num, int node_lo, int node_hi, int adj_num, int adj_row[], int adj[], string title); int adj_bandwidth(int node_num, int adj_num, int adj_row[], int adj[]); - int adj_perm_bandwidth(int node_num, int adj_num, int adj_row[], int adj[], int perm[], - int perm_inv[]); + int adj_perm_bandwidth(int node_num, int adj_num, int adj_row[], int adj[], int perm[], int perm_inv[]); int *genrcm(int node_num, int adj_num, int adj_row[], int adj[]); - void rcm(int root, int adj_num, int adj_row[], int adj[], int mask[], int perm[], int *iccsze, - int node_num); - void root_find(int *root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, - int level_row[], int level[], int node_num); + void rcm(int root, int adj_num, int adj_row[], int adj[], int mask[], int perm[], int *iccsze, int node_num); + void root_find(int *root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num); void i4vec_reverse(int n, int a[]); - void level_set(int root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, - int level_row[], int level[], int node_num); - void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, - int ls[], int node_num); + void level_set(int root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num); + void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num); int *perm_inverse3(int n, int perm[]); void i4vec_print(int n, int a[], string title) { @@ -217,8 +211,7 @@ namespace renumb { return value; } - int adj_perm_bandwidth(int node_num, int adj_num, int adj_row[], int adj[], int perm[], - int perm_inv[]) { + int adj_perm_bandwidth(int node_num, int adj_num, int adj_row[], int adj[], int perm[], int perm_inv[]) { // ****************************************************************************80 // // Purpose: @@ -384,8 +377,7 @@ namespace renumb { // Find a pseudo-peripheral node ROOT. The level structure found by // ROOT_FIND is stored starting at PERM(NUM). // - root_find(&root, adj_num, adj_row, adj, mask, &level_num, level_row, perm + num - 1, - node_num); + root_find(&root, adj_num, adj_row, adj, mask, &level_num, level_row, perm + num - 1, node_num); // // RCM orders the component using ROOT as the starting node. // @@ -427,8 +419,7 @@ namespace renumb { return perm; } - void adj_print_some(int node_num, int node_lo, int node_hi, int adj_num, int adj_row[], int adj[], - string title) { + void adj_print_some(int node_num, int node_lo, int node_hi, int adj_num, int adj_row[], int adj[], string title) { // ****************************************************************************80 // // Purpose: @@ -505,8 +496,7 @@ namespace renumb { jhi = std::min(jlo + 4, jmax); if (jlo == jmin) { - cout << " " << setw(4) << i << " " << setw(4) << jmin << " " << setw(4) << jmax - << " "; + cout << " " << setw(4) << i << " " << setw(4) << jmin << " " << setw(4) << jmax << " "; for (j = jlo; j <= jhi; j++) { cout << setw(8) << adj[j]; @@ -529,8 +519,7 @@ namespace renumb { return; } - void rcm(int root, int adj_num, int adj_row[], int adj[], int mask[], int perm[], int *iccsze, - int node_num) { + void rcm(int root, int adj_num, int adj_row[], int adj[], int mask[], int perm[], int *iccsze, int node_num) { // ****************************************************************************80 // // Purpose: @@ -710,8 +699,7 @@ namespace renumb { return; } - void root_find(int *root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, - int level_row[], int level[], int node_num) { + void root_find(int *root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num) { // ****************************************************************************80 // // Purpose: @@ -940,8 +928,7 @@ namespace renumb { return; } - void level_set(int root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, - int level_row[], int level[], int node_num) { + void level_set(int root, int adj_num, int adj_row[], int adj[], int mask[], int *level_num, int level_row[], int level[], int node_num) { // ****************************************************************************80 // // Purpose: @@ -1073,8 +1060,7 @@ namespace renumb { return; } - void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, - int ls[], int node_num) { + void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num) { // ****************************************************************************80 // // Purpose: diff --git a/src/fflib/showverb.hpp b/src/fflib/showverb.hpp index 6bbba10fa..911bec201 100644 --- a/src/fflib/showverb.hpp +++ b/src/fflib/showverb.hpp @@ -1,37 +1,37 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//#define VERBOSE +// #define VERBOSE #ifndef SHOWVERB #ifdef VERBOSE #define SHOWVERB(i) i #else -#define SHOWVERB(i) ( (void)0) +#define SHOWVERB(i) ((void)0) #endif #endif #define SHOWVERB1(i) i diff --git a/src/fflib/string_def.cpp b/src/fflib/string_def.cpp index f11c35f7f..9f23c8dc0 100644 --- a/src/fflib/string_def.cpp +++ b/src/fflib/string_def.cpp @@ -20,8 +20,8 @@ // AUTHORS : ... // E-MAIL : ... -//#pragma dont_inline on -//#pragma inline_depth(1) +// #pragma dont_inline on +// #pragma inline_depth(1) // TODO: remove this block as soon as autoconf is removed from FreeFem++ #ifndef CMAKE @@ -46,29 +46,33 @@ #include "array_init.hpp" class SubString { - public: - string *s; - long i, n; - SubString(string **ss, long ii, long jj) : s(*ss), i(ii), n(jj) {} - SubString(string **ss, const SubArray &sb) : s(*ss), i(sb.start), n(sb.n) { - ffassert(sb.step == 1); - } + public: + string *s; + long i, n; + SubString(string **ss, long ii, long jj) : s(*ss), i(ii), n(jj) {} + SubString(string **ss, const SubArray &sb) : s(*ss), i(sb.start), n(sb.n) { ffassert(sb.step == 1); } }; -extern Map_type_of_map map_type_of_map ; // to store the type -extern Map_type_of_map map_pair_of_type ; // to store the type +extern Map_type_of_map map_type_of_map; // to store the type +extern Map_type_of_map map_pair_of_type; // to store the type -extern basicForEachType *typevarreal, *typevarcomplex; // type of real and complex variable +extern basicForEachType *typevarreal, *typevarcomplex; // type of real and complex variable -extern int TheCurrentLine; // unset: by default +extern int TheCurrentLine; // unset: by default extern long mpisize, mpirank; -long get_size(string *p) { ffassert(p); return p->size(); } -long get_sizep(string **p) { ffassert(p && *p); return (*p)->size(); } +long get_size(string *p) { + ffassert(p); + return p->size( ); +} +long get_sizep(string **p) { + ffassert(p && *p); + return (*p)->size( ); +} string **get_replace(string **pp, long i, long j, string *rr) { ffassert(pp && *pp); - string s = **pp; // copy modif for windows pb free + string s = **pp; // copy modif for windows pb free s.replace(i, j, *rr); delete *pp; *pp = newstring(s); @@ -77,25 +81,25 @@ string **get_replace(string **pp, long i, long j, string *rr) { // a( : ) = "sqsd"; struct set_substring { - using first_argument_type = SubString; - using second_argument_type = string *; - using result_type = SubString; + using first_argument_type = SubString; + using second_argument_type = string *; + using result_type = SubString; static SubString f(SubString const &a, string *const &b) { string s = *a.s; s.replace(a.i, a.n, *b); - *a.s = s; // bofbof pour windows + *a.s = s; // bofbof pour windows return a; } }; -SubString fSubString(string **const &a, const SubArray &b) { return SubString(a,b); } +SubString fSubString(string **const &a, const SubArray &b) { return SubString(a, b); } -template - struct String_find { +template< bool B > +struct String_find { string *p; - String_find(string *pp) : p(pp){ ffassert(p); } - String_find(string **pp) : p(*pp){ ffassert(p); } + String_find(string *pp) : p(pp) { ffassert(p); } + String_find(string **pp) : p(*pp) { ffassert(p); } long find(string *f) const { return p->find(*f); } long find(string *f, long i) const { return p->find(*f, i); } @@ -103,74 +107,88 @@ template // specialization find -> rfind (bofbof ??) template<> -struct String_find { +struct String_find< false > { string *p; - String_find(string *pp) : p(pp){ ffassert(p); } - String_find(string **pp) : p(*pp){ ffassert(p); } + String_find(string *pp) : p(pp) { ffassert(p); } + String_find(string **pp) : p(*pp) { ffassert(p); } long find(string *f) const { return p->rfind(*f); } long find(string *f, long i) const { return p->rfind(*f, i); } }; -template -String_find to_String_find(string *p) { return String_find(p); } - -template -String_find to_String_findp(string ** p) { return String_find(*p); } +template< bool B > +String_find< B > to_String_find(string *p) { + return String_find< B >(p); +} -template -long string_find(String_find sf, string *s) { return sf.find(s); } +template< bool B > +String_find< B > to_String_findp(string **p) { + return String_find< B >(*p); +} -template -long string_find(String_find const &sf, string *const &s, long const &i) { - return sf.find(s,i); +template< bool B > +long string_find(String_find< B > sf, string *s) { + return sf.find(s); } -string *TOString(SubString const &a) { - return newstring(a.s->substr(a.i, a.n)); +template< bool B > +long string_find(String_find< B > const &sf, string *const &s, long const &i) { + return sf.find(s, i); } +string *TOString(SubString const &a) { return newstring(a.s->substr(a.i, a.n)); } + istream *getlinep(istream *f, string **s) { getline(*f, **s); - size_t l = (**s).length(); + size_t l = (**s).length( ); // clean begin end for win32 file - if (l) { if((**s)[0] == '\r') { (**s).erase(0, 1); l--; } } - if (l) { if((**s)[l-1] == '\r') { (**s).erase(l-1, 1); l--; } } + if (l) { + if ((**s)[0] == '\r') { + (**s).erase(0, 1); + l--; + } + } + if (l) { + if ((**s)[l - 1] == '\r') { + (**s).erase(l - 1, 1); + l--; + } + } return f; } -void initStringOperator() { - Dcl_Type(); +void initStringOperator( ) { + Dcl_Type< SubString >( ); // aType tstringp =atype(); - //aType tstringpp =atype(); + // aType tstringpp =atype(); - Dcl_Type< String_find > (); - Dcl_Type< String_find > (); - map_type[typeid(string*).name()]->AddCast(new E_F1_funcT(FCast)); + Dcl_Type< String_find< true > >( ); + Dcl_Type< String_find< false > >( ); + map_type[typeid(string *).name( )]->AddCast(new E_F1_funcT< string *, SubString >(FCast< string *, SubString, TOString >)); - Add("size", ".", new OneOperator1(get_sizep)); - Add("length", ".", new OneOperator1(get_sizep)); + Add< string ** >("size", ".", new OneOperator1< long, string ** >(get_sizep)); + Add< string ** >("length", ".", new OneOperator1< long, string ** >(get_sizep)); - Add("size", ".", new OneOperator1(get_size)); - Add("length", ".", new OneOperator1(get_size)); + Add< string * >("size", ".", new OneOperator1< long, string * >(get_size)); + Add< string * >("length", ".", new OneOperator1< long, string * >(get_size)); - Add("find", ".", new OneOperator1, string *>(to_String_find)); - Add("rfind", ".", new OneOperator1, string *>(to_String_find)); - Add("find", ".", new OneOperator1, string **>(to_String_findp)); - Add("rfind", ".", new OneOperator1, string **>(to_String_findp)); + Add< string * >("find", ".", new OneOperator1< String_find< true >, string * >(to_String_find< true >)); + Add< string * >("rfind", ".", new OneOperator1< String_find< false >, string * >(to_String_find< false >)); + Add< string ** >("find", ".", new OneOperator1< String_find< true >, string ** >(to_String_findp< true >)); + Add< string ** >("rfind", ".", new OneOperator1< String_find< false >, string ** >(to_String_findp< false >)); - Add >("(", "", new OneOperator2, string *>(string_find)); - Add >("(", "", new OneOperator2, string *>(string_find)); + Add< String_find< true > >("(", "", new OneOperator2< long, String_find< true >, string * >(string_find)); + Add< String_find< false > >("(", "", new OneOperator2< long, String_find< false >, string * >(string_find)); - Add >("(", "", new OneOperator3_, string *, long>(string_find)); - Add >("(", "", new OneOperator3_, string *, long>(string_find)); + Add< String_find< true > >("(", "", new OneOperator3_< long, String_find< true >, string *, long >(string_find)); + Add< String_find< false > >("(", "", new OneOperator3_< long, String_find< false >, string *, long >(string_find)); - TheOperators->Add("=", new OneBinaryOperator); + TheOperators->Add("=", new OneBinaryOperator< set_substring >); - Add("(", "", new OneOperator2_(fSubString)); + Add< string ** >("(", "", new OneOperator2_< SubString, string **, SubArray >(fSubString)); - TheOperators->Add("getline", new OneOperator2(getlinep)); + TheOperators->Add("getline", new OneOperator2< istream *, istream *, string ** >(getlinep)); // Add("[","",new OneOperator2_(fSubString)); - //Add("rfind",".",new OneOperator4_(get_replace) ); + // Add("rfind",".",new OneOperator4_(get_replace) ); } diff --git a/src/fflib/strversionnumber.hpp b/src/fflib/strversionnumber.hpp index 21de3190e..f7c699bcb 100644 --- a/src/fflib/strversionnumber.hpp +++ b/src/fflib/strversionnumber.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -31,7 +31,7 @@ #include using namespace std; -double VersionNumber(); -string StrVersionNumber(); +double VersionNumber( ); +string StrVersionNumber( ); -#endif//STRVERSIONNUMBER_HPP +#endif // STRVERSIONNUMBER_HPP diff --git a/src/fflib/throwassert.hpp b/src/fflib/throwassert.hpp index 5e91ccdec..c157be775 100644 --- a/src/fflib/throwassert.hpp +++ b/src/fflib/throwassert.hpp @@ -1,26 +1,26 @@ // -*- Mode : c++ -*- // -// SUMMARY : -// USAGE : -// ORG : +// SUMMARY : +// USAGE : +// ORG : // AUTHOR : Frederic Hecht // E-MAIL : hecht@ann.jussieu.fr // /* - + This file is part of Freefem++ - + Freefem++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Freefem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Freefem++; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -29,26 +29,26 @@ #define THROWASSERT #include -//#ifdef __INTEL__ -#define cerr cout -//#endif +// #ifdef __INTEL__ +#define cerr cout +// #endif #include "error.hpp" #ifdef NDEBUG -#define throwassert(i) ( (void) 0) +#define throwassert(i) ((void)0) #else -#define throwassert(condition) ((condition) ? ( (void) 0) : throw(ErrorAssert(#condition,__FILE__, __LINE__))) - +#define throwassert(condition) ((condition) ? ((void)0) : throw(ErrorAssert(#condition, __FILE__, __LINE__))) + #undef assert #define assert(condition) throwassert(condition) #endif // <> an unremovable assert. According to FH, ffassert() is as a more reliable way to trap FF than assert(). #undef ffassert -#define ffassert(condition) ((condition) ? ( (void) 0) : throw(ErrorAssert(#condition,__FILE__, __LINE__))) -//#define AFAIRE(str) ( (cerr << " TO be Done " << str << endl), throw(ErrorAssert("AFAIRE)/TO DO (FH????",__FILE__, __LINE__))) -#define AFAIRE(cmm) ( cerr << "FH: A Faire/ To Do "<< cmm << " file " << __FILE__<< " line "<< __LINE__ << endl, InternalError(cmm)) +#define ffassert(condition) ((condition) ? ((void)0) : throw(ErrorAssert(#condition, __FILE__, __LINE__))) +// #define AFAIRE(str) ( (cerr << " TO be Done " << str << endl), throw(ErrorAssert("AFAIRE)/TO DO (FH????",__FILE__, __LINE__))) +#define AFAIRE(cmm) (cerr << "FH: A Faire/ To Do " << cmm << " file " << __FILE__ << " line " << __LINE__ << endl, InternalError(cmm)) -#define InternalError(message) throw(ErrorInternal(message,__LINE__,__FILE__)) +#define InternalError(message) throw(ErrorInternal(message, __LINE__, __FILE__)) #endif diff --git a/src/lglib/lg.tab.cpp b/src/lglib/lg.tab.cpp index c69f779fb..b4d07c51f 100644 --- a/src/lglib/lg.tab.cpp +++ b/src/lglib/lg.tab.cpp @@ -60,74 +60,73 @@ /* Substitute the variable and function names. */ #define yyparse lgparse -#define yylex lglex +#define yylex lglex #define yyerror lgerror -#define yylval lglval -#define yychar lgchar +#define yylval lglval +#define yychar lgchar #define yydebug lgdebug #define yynerrs lgnerrs - /* Tokens. */ #ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - IF = 258, - ELSE = 259, - SET = 260, - GTGT = 261, - LTLT = 262, - OR = 263, - AND = 264, - NE = 265, - EQ = 266, - GE = 267, - LE = 268, - DOTSLASH = 269, - DOTSTAR = 270, - MOINSMOINS = 271, - PLUSPLUS = 272, - UNARY = 273, - LNUM = 274, - DNUM = 275, - CNUM = 276, - ID = 277, - FESPACEID = 278, - IDPARAM = 279, - STRING = 280, - ENDOFFILE = 281, - INCLUDE = 282, - LOAD = 283, - BIDON = 284, - FOR = 285, - WHILE = 286, - BREAK = 287, - CONTINUE = 288, - RETURN = 289, - TRY = 290, - CATCH = 291, - THROW = 292, - TYPE = 293, - FUNCTION = 294, - FESPACE = 295, - FESPACE1 = 296, - FESPACE3 = 297, - FESPACES = 298, - FESPACEL = 299, - VGFESPACE = 300, - GFESPACE = 301, - PLUSEQ = 302, - MOINSEQ = 303, - MULEQ = 304, - DIVEQ = 305, - DOTMULEQ = 306, - DOTDIVEQ = 307, - ARROW = 308, - BORDER = 309, - SOLVE = 310 - }; +#define YYTOKENTYPE +/* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ +enum yytokentype { + IF = 258, + ELSE = 259, + SET = 260, + GTGT = 261, + LTLT = 262, + OR = 263, + AND = 264, + NE = 265, + EQ = 266, + GE = 267, + LE = 268, + DOTSLASH = 269, + DOTSTAR = 270, + MOINSMOINS = 271, + PLUSPLUS = 272, + UNARY = 273, + LNUM = 274, + DNUM = 275, + CNUM = 276, + ID = 277, + FESPACEID = 278, + IDPARAM = 279, + STRING = 280, + ENDOFFILE = 281, + INCLUDE = 282, + LOAD = 283, + BIDON = 284, + FOR = 285, + WHILE = 286, + BREAK = 287, + CONTINUE = 288, + RETURN = 289, + TRY = 290, + CATCH = 291, + THROW = 292, + TYPE = 293, + FUNCTION = 294, + FESPACE = 295, + FESPACE1 = 296, + FESPACE3 = 297, + FESPACES = 298, + FESPACEL = 299, + VGFESPACE = 300, + GFESPACE = 301, + PLUSEQ = 302, + MOINSEQ = 303, + MULEQ = 304, + DIVEQ = 305, + DOTMULEQ = 306, + DOTDIVEQ = 307, + ARROW = 308, + BORDER = 309, + SOLVE = 310 +}; #endif /* Tokens. */ #define IF 258 @@ -184,51 +183,48 @@ #define BORDER 309 #define SOLVE 310 +/* Copy the first part of user declarations. */ +#line 3 "lg.ypp" +// -*- Mode : c++ -*- +// +// SUMMARY : +// USAGE : +// ORG : +// AUTHOR : Frederic Hecht +// E-MAIL : hecht@ann.jussieu.fr +// +/* -/* Copy the first part of user declarations. */ -#line 3 "lg.ypp" + This file is part of Freefem++ + + Freefem++ is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. - // -*- Mode : c++ -*- - // - // SUMMARY : - // USAGE : - // ORG : - // AUTHOR : Frederic Hecht - // E-MAIL : hecht@ann.jussieu.fr - // - - /* - - This file is part of Freefem++ - - Freefem++ is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - Freefem++ is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with Freefem++; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ + Freefem++ is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Freefem++; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ /* bug of clang if optimisation !!!!! */ -#ifdef __clang__ +#ifdef __clang__ #pragma clang optimize off #endif #include #include -#include +#include #include - // for reset cout,cin in windows dll +// for reset cout,cin in windows dll #ifdef _WIN32 #include #include @@ -259,32 +255,34 @@ class Iden; #include "lgfem.hpp" #include "lex.hpp" #include "environment.hpp" -extern long storageused(); - extern FILE *ThePlotStream; - extern KN *pkarg; +extern long storageused( ); +extern FILE *ThePlotStream; +extern KN< String > *pkarg; class Routine; bool load(string s); - template class FE; - template class FE_; +template< class R, int d > +class FE; +template< class R, int d, int i > +class FE_; extern mylex *zzzfff; // modif FH for window to have 1 dll for mpi and none mpi .. -extern void (*initparallele)(int &, char **&); -extern void (*init_lgparallele)(); +extern void (*initparallele)(int &, char **&); +extern void (*init_lgparallele)( ); // extern void (*end_parallele)(); // #ifdef HAVE_LIBARPACK - void init_eigenvalue(); +void init_eigenvalue( ); #endif - aType dcltype; -const int nbembtype=10; +aType dcltype; +const int nbembtype = 10; aType rettype[nbembtype]; -Block * routineinblock[nbembtype]; // Add FH july 2005 pb clean on return -int kkembtype=-1; -int inloopcount=0; +Block *routineinblock[nbembtype]; // Add FH july 2005 pb clean on return +int kkembtype = -1; +int inloopcount = 0; /// <> Block class from [[file:../fflib/AFunction.hpp::Block]] @@ -292,139 +290,128 @@ Block *currentblock; // Add FH july 2005 // problem clean variable after break,continue and return. -const int sizeStackOfLoop=100; -Block * StackOfLoop[sizeStackOfLoop]; +const int sizeStackOfLoop = 100; +Block *StackOfLoop[sizeStackOfLoop]; // end ADD -double CPUcompileInit =0; -//class pfes; -C_F0 fespacetype; +double CPUcompileInit = 0; +// class pfes; +C_F0 fespacetype; bool fespacecomplex; int fespacedim; extern int UnShowAlloc; -int ShowAlloc(const char *s,size_t &); +int ShowAlloc(const char *s, size_t &); // <> Connection from grammar to lexer object zzzfff [[file:../fflib/lex.hpp::zzzfff]] of class mylex // [[file:../fflib/lex.hpp::class mylex]]. Method mylex::scan() is implemented at [[file:../fflib/lex.cpp::mylex_scan]] - -inline int yylex() {return zzzfff->scan();} -inline int lineno() {return zzzfff->lineno();} +inline int yylex( ) { return zzzfff->scan( ); } +inline int lineno( ) { return zzzfff->lineno( ); } extern bool withrgraphique; /// <> -inline void fingraphique() - { if(withrgraphique) - { withrgraphique=false; +inline void fingraphique( ) { + if (withrgraphique) { + withrgraphique = false; rattente(1); - closegraphique(); - }} - -void lgerror (const char* s) ; + closegraphique( ); + } +} +void lgerror(const char *s); - // mpi ptr to function ... -void (*initparallele)(int &argc, char **& argv)=0 ; -void (*init_lgparallele)()=0; -//void (*end_parallele)()=0; +// mpi ptr to function ... +void (*initparallele)(int &argc, char **&argv) = 0; +void (*init_lgparallele)( ) = 0; +// void (*end_parallele)()=0; // Add dec 2014 #include -typedef void (*AtEnd)(); -vector AtFFEnd; -void ff_finalize() -{ - for (vector::const_reverse_iterator i=AtFFEnd.rbegin(); i !=AtFFEnd.rend(); ++ i) - (**i)(); - AtFFEnd.clear(); -} -void ff_atend(AtEnd f) -{ - AtFFEnd.push_back(f); +typedef void (*AtEnd)( ); +vector< AtEnd > AtFFEnd; +void ff_finalize( ) { + for (vector< AtEnd >::const_reverse_iterator i = AtFFEnd.rbegin( ); i != AtFFEnd.rend( ); ++i) (**i)( ); + AtFFEnd.clear( ); } +void ff_atend(AtEnd f) { AtFFEnd.push_back(f); } #include -void signalCPUHandler( int signum ) { - ff_finalize(); - std::cout << "Cputime limit exceeded: (" << signum << ") received.\n"; - - exit(24); -} - +void signalCPUHandler(int signum) { + ff_finalize( ); + std::cout << "Cputime limit exceeded: (" << signum << ") received.\n"; + exit(24); +} /* Enabling traces. */ #ifndef YYDEBUG -# define YYDEBUG 1 +#define YYDEBUG 1 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 +#undef YYERROR_VERBOSE +#define YYERROR_VERBOSE 1 #else -# define YYERROR_VERBOSE 0 +#define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +#define YYTOKEN_TABLE 0 #endif -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED typedef union YYSTYPE #line 170 "lg.ypp" { - double dnum; + double dnum; - /* <> */ - long lnum;// to read long long number !!!! FH dec 2022 + /* <> */ + long lnum; // to read long long number !!!! FH dec 2022 - /* <> */ - char * str; - char oper[8]; + /* <> */ + char *str; + char oper[8]; - /* <> [[file:../fflib/AFunction.hpp::CC_F0]] */ - CC_F0 cexp; + /* <> [[file:../fflib/AFunction.hpp::CC_F0]] */ + CC_F0 cexp; - Routine *routine; + Routine *routine; - /* <> [[file:~/ff/src/fflib/AFunction.hpp::AC_F0]] */ - AC_F0 args; + /* <> [[file:~/ff/src/fflib/AFunction.hpp::AC_F0]] */ + AC_F0 args; - /* <> refers to [[file:~/ff/src/fflib/AnyType.hpp::aType]] */ - aType type; + /* <> refers to [[file:~/ff/src/fflib/AnyType.hpp::aType]] */ + aType type; - /* <> refers to [[file:~/ff/src/fflib/AFunction.hpp::CListOfInst]] */ - CListOfInst cinst; + /* <> refers to [[file:~/ff/src/fflib/AFunction.hpp::CListOfInst]] */ + CListOfInst cinst; - Block * block; + Block *block; - /* <> [[file:~/ff/src/fflib/AFunction.hpp::ListOfId]] */ - ListOfId *clist_id; + /* <> [[file:~/ff/src/fflib/AFunction.hpp::ListOfId]] */ + ListOfId *clist_id; -/* ListCatch * clist_Catchs;*/ + /* ListCatch * clist_Catchs;*/ - vectorOfInst * endb; + vectorOfInst *endb; } /* Line 193 of yacc.c. */ #line 412 "lg.tab.cpp" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 +YYSTYPE; +#define yystype YYSTYPE /* obsolescent; will be withdrawn */ +#define YYSTYPE_IS_DECLARED 1 +#define YYSTYPE_IS_TRIVIAL 1 #endif - - /* Copy the second part of user declarations. */ - /* Line 216 of yacc.c. */ #line 425 "lg.tab.cpp" #ifdef short -# undef short +#undef short #endif #ifdef YYTYPE_UINT8 @@ -435,8 +422,7 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +#elif (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; @@ -455,1018 +441,583 @@ typedef short int yytype_int16; #endif #ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif +#ifdef __SIZE_TYPE__ +#define YYSIZE_T __SIZE_TYPE__ +#elif defined size_t +#define YYSIZE_T size_t +#elif !defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +#include /* INFRINGES ON USER NAME SPACE */ +#define YYSIZE_T size_t +#else +#define YYSIZE_T unsigned int +#endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM ((YYSIZE_T) - 1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif +#if defined YYENABLE_NLS && YYENABLE_NLS +#if ENABLE_NLS +#include /* INFRINGES ON USER NAME SPACE */ +#define YY_(msgid) dgettext("bison-runtime", msgid) +#endif +#endif +#ifndef YY_ +#define YY_(msgid) msgid +#endif #endif /* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +#if !defined lint || defined __GNUC__ +#define YYUSE(e) ((void)(e)) #else -# define YYUSE(e) /* empty */ +#define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint -# define YYID(n) (n) +#define YYID(n) (n) #else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static int YYID(int i) #else -static int -YYID (i) - int i; +static int YYID(i) +int i; #endif { return i; } #endif -#if ! defined yyoverflow || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ +#ifdef YYSTACK_USE_ALLOCA +#if YYSTACK_USE_ALLOCA +#ifdef __GNUC__ +#define YYSTACK_ALLOC __builtin_alloca +#elif defined __BUILTIN_VA_ARG_INCR +#include /* INFRINGES ON USER NAME SPACE */ +#elif defined _AIX +#define YYSTACK_ALLOC __alloca +#elif defined _MSC_VER +#include /* INFRINGES ON USER NAME SPACE */ +#define alloca _alloca +#else +#define YYSTACK_ALLOC alloca +#if !defined _ALLOCA_H && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +#include /* INFRINGES ON USER NAME SPACE */ +#ifndef _STDLIB_H +#define _STDLIB_H 1 +#endif +#endif +#endif +#endif +#endif +#ifdef YYSTACK_ALLOC +/* Pacify GCC's `empty if-body' warning. */ +#define YYSTACK_FREE(Ptr) \ + do { /* empty */ \ + ; \ + } while (YYID(0)) +#ifndef YYSTACK_ALLOC_MAXIMUM +/* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +#endif +#else +#define YYSTACK_ALLOC YYMALLOC +#define YYSTACK_FREE YYFREE +#ifndef YYSTACK_ALLOC_MAXIMUM +#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +#endif +#if (defined __cplusplus && !defined _STDLIB_H && !((defined YYMALLOC || defined malloc) && (defined YYFREE || defined free))) +#include /* INFRINGES ON USER NAME SPACE */ +#ifndef _STDLIB_H +#define _STDLIB_H 1 +#endif +#endif +#ifndef YYMALLOC +#define YYMALLOC malloc +#if !defined malloc && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +void *malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +#endif +#endif +#ifndef YYFREE +#define YYFREE free +#if !defined free && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +void free(void *); /* INFRINGES ON USER NAME SPACE */ +#endif +#endif +#endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) +#if (!defined yyoverflow && (!defined __cplusplus || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ -union yyalloc -{ +union yyalloc { yytype_int16 yyss; YYSTYPE yyvs; - }; +}; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +#define YYSTACK_GAP_MAXIMUM (sizeof(union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) +#define YYSTACK_BYTES(N) ((N) * (sizeof(yytype_int16) + sizeof(YYSTYPE)) + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +#ifndef YYCOPY +#if defined __GNUC__ && 1 < __GNUC__ +#define YYCOPY(To, From, Count) __builtin_memcpy(To, From, (Count) * sizeof(*(From))) +#else +#define YYCOPY(To, From, Count) \ + do { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) (To)[yyi] = (From)[yyi]; \ + } while (YYID(0)) +#endif +#endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) +#define YYSTACK_RELOCATE(Stack) \ + do { \ + YYSIZE_T yynewbytes; \ + YYCOPY(&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof(*yyptr); \ + } while (YYID(0)) #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 100 +#define YYFINAL 100 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1274 +#define YYLAST 1274 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 81 +#define YYNTOKENS 81 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 50 +#define YYNNTS 50 /* YYNRULES -- Number of rules. */ -#define YYNRULES 252 +#define YYNRULES 252 /* YYNRULES -- Number of states. */ -#define YYNSTATES 507 +#define YYNSTATES 507 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 310 +#define YYUNDEFTOK 2 +#define YYMAXUTOK 310 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) +#define YYTRANSLATE(YYX) ((unsigned int)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 27, 2, 2, 2, 24, 12, 32, - 34, 37, 22, 20, 5, 21, 36, 23, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 79, 76, - 16, 6, 17, 80, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 35, 2, 38, 31, 33, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 77, 10, 78, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 7, 8, 9, 11, 13, 14, 15, 18, 19, 25, - 26, 28, 29, 30, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75 -}; +static const yytype_uint8 yytranslate[] = {0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 2, 2, 2, 24, 12, + 32, 34, 37, 22, 20, 5, 21, 36, 23, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 79, 76, 16, 6, 17, 80, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 35, 2, 38, 31, 33, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 77, 10, 78, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 7, 8, 9, 11, 13, 14, 15, 18, 19, 25, 26, 28, 29, + 30, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75}; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 6, 8, 10, 13, 14, 16, 20, - 23, 27, 30, 34, 37, 41, 44, 48, 51, 55, - 59, 65, 70, 74, 80, 87, 95, 102, 108, 113, - 119, 124, 130, 135, 141, 146, 152, 157, 163, 165, - 169, 171, 173, 175, 177, 179, 181, 183, 187, 192, - 196, 198, 201, 204, 207, 210, 213, 215, 217, 219, - 221, 223, 227, 231, 233, 238, 246, 253, 263, 268, - 276, 286, 288, 293, 297, 301, 308, 314, 319, 326, - 328, 330, 332, 334, 336, 338, 340, 342, 347, 349, - 353, 355, 359, 362, 368, 373, 377, 379, 383, 384, - 389, 393, 396, 402, 403, 414, 415, 425, 427, 429, - 431, 433, 434, 438, 440, 442, 446, 452, 454, 457, - 460, 466, 469, 471, 472, 481, 491, 501, 507, 513, - 521, 525, 529, 536, 539, 542, 546, 554, 562, 572, - 575, 577, 581, 583, 585, 587, 589, 591, 593, 597, - 601, 605, 609, 613, 617, 621, 623, 629, 633, 639, - 641, 645, 649, 653, 657, 661, 665, 669, 673, 677, - 681, 685, 689, 693, 697, 701, 705, 709, 713, 717, - 719, 721, 725, 731, 735, 736, 738, 740, 742, 744, - 746, 748, 752, 754, 758, 762, 766, 770, 774, 778, - 782, 788, 790, 794, 796, 798, 800, 802, 804, 808, - 812, 816, 820, 824, 828, 832, 836, 840, 844, 846, - 849, 851, 855, 859, 861, 864, 866, 868, 870, 872, - 874, 879, 884, 891, 895, 899, 903, 908, 912, 917, - 921, 926, 930, 935, 939, 944, 947, 950, 955, 960, - 964, 968, 972 -}; +static const yytype_uint16 yyprhs[] = {0, 0, 3, 6, 8, 10, 13, 14, 16, 20, 23, 27, 30, 34, 37, 41, 44, 48, 51, 55, 59, 65, 70, 74, 80, 87, 95, 102, 108, 113, 119, 124, + 130, 135, 141, 146, 152, 157, 163, 165, 169, 171, 173, 175, 177, 179, 181, 183, 187, 192, 196, 198, 201, 204, 207, 210, 213, 215, 217, 219, 221, 223, 227, 231, + 233, 238, 246, 253, 263, 268, 276, 286, 288, 293, 297, 301, 308, 314, 319, 326, 328, 330, 332, 334, 336, 338, 340, 342, 347, 349, 353, 355, 359, 362, 368, 373, + 377, 379, 383, 384, 389, 393, 396, 402, 403, 414, 415, 425, 427, 429, 431, 433, 434, 438, 440, 442, 446, 452, 454, 457, 460, 466, 469, 471, 472, 481, 491, 501, + 507, 513, 521, 525, 529, 536, 539, 542, 546, 554, 562, 572, 575, 577, 581, 583, 585, 587, 589, 591, 593, 597, 601, 605, 609, 613, 617, 621, 623, 629, 633, 639, + 641, 645, 649, 653, 657, 661, 665, 669, 673, 677, 681, 685, 689, 693, 697, 701, 705, 709, 713, 717, 719, 721, 725, 731, 735, 736, 738, 740, 742, 744, 746, 748, + 752, 754, 758, 762, 766, 770, 774, 778, 782, 788, 790, 794, 796, 798, 800, 802, 804, 808, 812, 816, 820, 824, 828, 832, 836, 840, 844, 846, 849, 851, 855, 859, + 861, 864, 866, 868, 870, 872, 874, 879, 884, 891, 895, 899, 903, 908, 912, 917, 921, 926, 930, 935, 939, 944, 947, 950, 955, 960, 964, 968, 972}; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 82, 0, -1, 83, 46, -1, 84, -1, 112, -1, - 84, 112, -1, -1, 87, -1, 87, 6, 119, -1, - 60, 87, -1, 60, 12, 87, -1, 62, 87, -1, - 62, 12, 87, -1, 63, 87, -1, 63, 12, 87, - -1, 64, 87, -1, 64, 12, 87, -1, 90, 87, - -1, 90, 12, 87, -1, 35, 85, 38, -1, 16, - 35, 85, 38, 17, -1, 16, 35, 85, 38, -1, - 85, 5, 87, -1, 85, 5, 35, 85, 38, -1, - 85, 5, 35, 85, 38, 17, -1, 85, 5, 16, - 35, 85, 38, 17, -1, 85, 5, 16, 35, 85, - 38, -1, 85, 5, 87, 6, 119, -1, 85, 5, - 60, 87, -1, 85, 5, 60, 12, 87, -1, 85, - 5, 62, 87, -1, 85, 5, 62, 12, 87, -1, - 85, 5, 63, 87, -1, 85, 5, 63, 12, 87, - -1, 85, 5, 64, 87, -1, 85, 5, 64, 12, - 87, -1, 85, 5, 90, 87, -1, 85, 5, 90, - 12, 87, -1, 87, -1, 86, 5, 87, -1, 42, - -1, 60, -1, 62, -1, 63, -1, 64, -1, 61, - -1, 42, -1, 42, 6, 119, -1, 42, 34, 89, - 37, -1, 88, 5, 88, -1, 120, -1, 60, 42, - -1, 61, 42, -1, 62, 42, -1, 63, 42, -1, - 64, 42, -1, 60, -1, 61, -1, 62, -1, 63, - -1, 64, -1, 42, 6, 120, -1, 89, 5, 89, - -1, 58, -1, 58, 35, 58, 38, -1, 58, 35, - 58, 38, 35, 58, 38, -1, 58, 35, 58, 5, - 58, 38, -1, 58, 35, 58, 5, 58, 38, 35, - 58, 38, -1, 58, 16, 58, 17, -1, 58, 16, - 58, 17, 35, 58, 38, -1, 58, 16, 58, 17, - 35, 58, 5, 58, 38, -1, 42, -1, 42, 35, - 120, 38, -1, 42, 6, 120, -1, 35, 86, 38, - -1, 35, 86, 38, 35, 120, 38, -1, 35, 86, - 38, 6, 120, -1, 42, 34, 120, 37, -1, 35, - 86, 38, 34, 120, 37, -1, 60, -1, 61, -1, - 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, - 93, -1, 93, 16, 58, 17, -1, 92, -1, 95, - 5, 92, -1, 91, -1, 96, 5, 91, -1, 94, - 96, -1, 94, 35, 58, 38, 95, -1, 42, 34, - 89, 37, -1, 42, 6, 89, -1, 98, -1, 99, - 5, 98, -1, -1, 90, 101, 88, 76, -1, 43, - 99, 76, -1, 97, 76, -1, 59, 42, 6, 117, - 76, -1, -1, 59, 90, 42, 34, 85, 37, 102, - 77, 84, 78, -1, -1, 59, 42, 34, 85, 37, - 103, 6, 119, 76, -1, 77, -1, 78, -1, 50, - -1, 51, -1, -1, 90, 109, 88, -1, 55, -1, - 87, -1, 87, 5, 87, -1, 87, 5, 87, 5, - 87, -1, 76, -1, 47, 45, -1, 48, 45, -1, - 110, 77, 84, 78, 114, -1, 117, 76, -1, 100, - -1, -1, 106, 35, 111, 79, 130, 38, 113, 112, - -1, 106, 34, 117, 76, 117, 76, 117, 37, 112, - -1, 106, 34, 108, 76, 117, 76, 117, 37, 112, - -1, 107, 34, 117, 37, 112, -1, 3, 34, 117, - 37, 112, -1, 3, 34, 117, 37, 112, 4, 112, - -1, 104, 84, 105, -1, 74, 42, 116, -1, 74, - 42, 35, 125, 38, 76, -1, 52, 76, -1, 53, - 76, -1, 54, 117, 76, -1, 56, 34, 36, 36, - 36, 37, 112, -1, 34, 42, 6, 117, 5, 117, - 37, -1, 34, 42, 6, 117, 5, 117, 76, 42, - 37, -1, 115, 112, -1, 119, -1, 117, 5, 117, - -1, 21, -1, 20, -1, 27, -1, 29, -1, 28, - -1, 120, -1, 120, 6, 119, -1, 120, 67, 119, - -1, 120, 68, 119, -1, 120, 69, 119, -1, 120, - 70, 119, -1, 120, 71, 119, -1, 120, 72, 119, - -1, 121, -1, 121, 80, 121, 79, 121, -1, 121, - 79, 121, -1, 121, 79, 121, 79, 121, -1, 127, - -1, 121, 22, 121, -1, 121, 26, 121, -1, 121, - 25, 121, -1, 121, 23, 121, -1, 121, 24, 121, - -1, 121, 20, 121, -1, 121, 21, 121, -1, 121, - 9, 121, -1, 121, 8, 121, -1, 121, 12, 121, - -1, 121, 13, 121, -1, 121, 10, 121, -1, 121, - 11, 121, -1, 121, 16, 121, -1, 121, 19, 121, - -1, 121, 17, 121, -1, 121, 18, 121, -1, 121, - 15, 121, -1, 121, 14, 121, -1, 121, -1, 79, - -1, 121, 79, 121, -1, 121, 79, 121, 79, 121, - -1, 122, 5, 124, -1, -1, 60, -1, 61, -1, - 62, -1, 63, -1, 64, -1, 65, -1, 87, 6, - 120, -1, 122, -1, 124, 5, 60, -1, 124, 5, - 61, -1, 124, 5, 62, -1, 124, 5, 63, -1, - 124, 5, 64, -1, 124, 5, 65, -1, 124, 5, - 122, -1, 124, 5, 87, 6, 120, -1, 119, -1, - 125, 5, 119, -1, 60, -1, 61, -1, 62, -1, - 63, -1, 64, -1, 126, 5, 60, -1, 126, 5, - 61, -1, 126, 5, 62, -1, 126, 5, 63, -1, - 126, 5, 64, -1, 126, 22, 60, -1, 126, 22, - 61, -1, 126, 22, 62, -1, 126, 22, 63, -1, - 126, 22, 64, -1, 128, -1, 118, 128, -1, 129, - -1, 129, 31, 127, -1, 129, 33, 127, -1, 130, - -1, 130, 32, -1, 42, -1, 39, -1, 40, -1, - 41, -1, 45, -1, 130, 34, 124, 37, -1, 130, - 35, 122, 38, -1, 130, 35, 122, 5, 122, 38, - -1, 130, 35, 38, -1, 130, 36, 42, -1, 60, - 36, 42, -1, 60, 34, 124, 37, -1, 61, 36, - 42, -1, 61, 34, 124, 37, -1, 62, 36, 42, - -1, 62, 34, 124, 37, -1, 63, 36, 42, -1, - 63, 34, 124, 37, -1, 64, 36, 42, -1, 64, - 34, 124, 37, -1, 130, 29, -1, 130, 28, -1, - 58, 34, 122, 37, -1, 58, 34, 123, 37, -1, - 34, 117, 37, -1, 35, 125, 38, -1, 16, 126, - 17, -1, 126, -1 -}; +static const yytype_int16 yyrhs[] = { + 82, 0, -1, 83, 46, -1, 84, -1, 112, -1, 84, 112, -1, -1, 87, -1, 87, 6, 119, -1, 60, 87, -1, 60, 12, 87, -1, 62, 87, -1, 62, 12, 87, -1, 63, 87, -1, 63, 12, + 87, -1, 64, 87, -1, 64, 12, 87, -1, 90, 87, -1, 90, 12, 87, -1, 35, 85, 38, -1, 16, 35, 85, 38, 17, -1, 16, 35, 85, 38, -1, 85, 5, 87, -1, 85, 5, 35, 85, + 38, -1, 85, 5, 35, 85, 38, 17, -1, 85, 5, 16, 35, 85, 38, 17, -1, 85, 5, 16, 35, 85, 38, -1, 85, 5, 87, 6, 119, -1, 85, 5, 60, 87, -1, 85, 5, 60, 12, + 87, -1, 85, 5, 62, 87, -1, 85, 5, 62, 12, 87, -1, 85, 5, 63, 87, -1, 85, 5, 63, 12, 87, -1, 85, 5, 64, 87, -1, 85, 5, 64, 12, 87, -1, 85, 5, 90, 87, + -1, 85, 5, 90, 12, 87, -1, 87, -1, 86, 5, 87, -1, 42, -1, 60, -1, 62, -1, 63, -1, 64, -1, 61, -1, 42, -1, 42, 6, 119, -1, 42, 34, 89, 37, -1, 88, 5, 88, + -1, 120, -1, 60, 42, -1, 61, 42, -1, 62, 42, -1, 63, 42, -1, 64, 42, -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, 42, 6, 120, -1, 89, 5, 89, -1, 58, -1, 58, + 35, 58, 38, -1, 58, 35, 58, 38, 35, 58, 38, -1, 58, 35, 58, 5, 58, 38, -1, 58, 35, 58, 5, 58, 38, 35, 58, 38, -1, 58, 16, 58, 17, -1, 58, 16, 58, 17, 35, + 58, 38, -1, 58, 16, 58, 17, 35, 58, 5, 58, 38, -1, 42, -1, 42, 35, 120, 38, -1, 42, 6, 120, -1, 35, 86, 38, -1, 35, 86, 38, 35, 120, 38, -1, 35, 86, 38, 6, + 120, -1, 42, 34, 120, 37, -1, 35, 86, 38, 34, 120, 37, -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, 93, -1, 93, 16, 58, 17, -1, 92, -1, 95, 5, + 92, -1, 91, -1, 96, 5, 91, -1, 94, 96, -1, 94, 35, 58, 38, 95, -1, 42, 34, 89, 37, -1, 42, 6, 89, -1, 98, -1, 99, 5, 98, -1, -1, 90, 101, 88, 76, -1, 43, + 99, 76, -1, 97, 76, -1, 59, 42, 6, 117, 76, -1, -1, 59, 90, 42, 34, 85, 37, 102, 77, 84, 78, -1, -1, 59, 42, 34, 85, 37, 103, 6, 119, 76, -1, 77, -1, 78, -1, + 50, -1, 51, -1, -1, 90, 109, 88, -1, 55, -1, 87, -1, 87, 5, 87, -1, 87, 5, 87, 5, 87, -1, 76, -1, 47, 45, -1, 48, 45, -1, 110, 77, 84, 78, 114, -1, 117, 76, + -1, 100, -1, -1, 106, 35, 111, 79, 130, 38, 113, 112, -1, 106, 34, 117, 76, 117, 76, 117, 37, 112, -1, 106, 34, 108, 76, 117, 76, 117, 37, 112, -1, 107, 34, 117, 37, 112, -1, + 3, 34, 117, 37, 112, -1, 3, 34, 117, 37, 112, 4, 112, -1, 104, 84, 105, -1, 74, 42, 116, -1, 74, 42, 35, 125, 38, 76, -1, 52, 76, -1, 53, 76, -1, 54, 117, 76, -1, + 56, 34, 36, 36, 36, 37, 112, -1, 34, 42, 6, 117, 5, 117, 37, -1, 34, 42, 6, 117, 5, 117, 76, 42, 37, -1, 115, 112, -1, 119, -1, 117, 5, 117, -1, 21, -1, 20, -1, + 27, -1, 29, -1, 28, -1, 120, -1, 120, 6, 119, -1, 120, 67, 119, -1, 120, 68, 119, -1, 120, 69, 119, -1, 120, 70, 119, -1, 120, 71, 119, -1, 120, 72, 119, -1, 121, -1, 121, + 80, 121, 79, 121, -1, 121, 79, 121, -1, 121, 79, 121, 79, 121, -1, 127, -1, 121, 22, 121, -1, 121, 26, 121, -1, 121, 25, 121, -1, 121, 23, 121, -1, 121, 24, 121, -1, 121, 20, + 121, -1, 121, 21, 121, -1, 121, 9, 121, -1, 121, 8, 121, -1, 121, 12, 121, -1, 121, 13, 121, -1, 121, 10, 121, -1, 121, 11, 121, -1, 121, 16, 121, -1, 121, 19, 121, -1, 121, + 17, 121, -1, 121, 18, 121, -1, 121, 15, 121, -1, 121, 14, 121, -1, 121, -1, 79, -1, 121, 79, 121, -1, 121, 79, 121, 79, 121, -1, 122, 5, 124, -1, -1, 60, -1, 61, -1, 62, + -1, 63, -1, 64, -1, 65, -1, 87, 6, 120, -1, 122, -1, 124, 5, 60, -1, 124, 5, 61, -1, 124, 5, 62, -1, 124, 5, 63, -1, 124, 5, 64, -1, 124, 5, 65, -1, 124, 5, + 122, -1, 124, 5, 87, 6, 120, -1, 119, -1, 125, 5, 119, -1, 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, 126, 5, 60, -1, 126, 5, 61, -1, 126, 5, 62, -1, 126, 5, 63, + -1, 126, 5, 64, -1, 126, 22, 60, -1, 126, 22, 61, -1, 126, 22, 62, -1, 126, 22, 63, -1, 126, 22, 64, -1, 128, -1, 118, 128, -1, 129, -1, 129, 31, 127, -1, 129, 33, 127, + -1, 130, -1, 130, 32, -1, 42, -1, 39, -1, 40, -1, 41, -1, 45, -1, 130, 34, 124, 37, -1, 130, 35, 122, 38, -1, 130, 35, 122, 5, 122, 38, -1, 130, 35, 38, -1, 130, 36, + 42, -1, 60, 36, 42, -1, 60, 34, 124, 37, -1, 61, 36, 42, -1, 61, 34, 124, 37, -1, 62, 36, 42, -1, 62, 34, 124, 37, -1, 63, 36, 42, -1, 63, 34, 124, 37, -1, 64, + 36, 42, -1, 64, 34, 124, 37, -1, 130, 29, -1, 130, 28, -1, 58, 34, 122, 37, -1, 58, 34, 123, 37, -1, 34, 117, 37, -1, 35, 125, 38, -1, 16, 126, 17, -1, 126, -1}; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 339, 339, 409, 413, 414, 420, 421, 422, 423, - 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, - 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, - 444, 445, 446, 447, 448, 449, 450, 451, 454, 455, - 460, 460, 460, 460, 460, 460, 463, 464, 465, 466, - 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, - 482, 483, 484, 489, 490, 491, 492, 493, 494, 495, - 496, 500, 501, 502, 503, 504, 505, 509, 510, 515, - 516, 517, 518, 519, 520, 521, 524, 525, 530, 531, - 533, 534, 536, 537, 540, 543, 547, 548, 551, 551, - 552, 553, 554, 556, 555, 572, 571, 581, 582, 586, - 588, 592, 592, 595, 597, 598, 599, 601, 602, 603, - 604, 605, 606, 608, 607, 613, 614, 618, 619, 620, - 621, 626, 628, 631, 635, 639, 646, 649, 657, 665, - 672, 673, 677, 678, 679, 680, 681, 685, 686, 687, - 688, 689, 690, 691, 692, 697, 698, 699, 700, 704, - 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, - 715, 716, 717, 718, 719, 720, 721, 722, 723, 727, - 728, 729, 730, 735, 739, 740, 741, 742, 743, 744, - 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, - 757, 760, 761, 764, 765, 766, 767, 768, 769, 770, - 771, 772, 773, 774, 775, 776, 777, 778, 782, 783, - 787, 788, 789, 793, 794, 802, 806, 807, 808, 809, - 814, 816, 817, 818, 819, 820, 821, 822, 823, 824, - 825, 826, 827, 828, 829, 830, 831, 832, 841, 849, - 850, 851, 852 -}; +static const yytype_uint16 yyrline[] = {0, 339, 339, 409, 413, 414, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, + 446, 447, 448, 449, 450, 451, 454, 455, 460, 460, 460, 460, 460, 460, 463, 464, 465, 466, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 489, + 490, 491, 492, 493, 494, 495, 496, 500, 501, 502, 503, 504, 505, 509, 510, 515, 516, 517, 518, 519, 520, 521, 524, 525, 530, 531, 533, 534, 536, 537, 540, 543, + 547, 548, 551, 551, 552, 553, 554, 556, 555, 572, 571, 581, 582, 586, 588, 592, 592, 595, 597, 598, 599, 601, 602, 603, 604, 605, 606, 608, 607, 613, 614, 618, + 619, 620, 621, 626, 628, 631, 635, 639, 646, 649, 657, 665, 672, 673, 677, 678, 679, 680, 681, 685, 686, 687, 688, 689, 690, 691, 692, 697, 698, 699, 700, 704, + 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 727, 728, 729, 730, 735, 739, 740, 741, 742, 743, 744, 745, 746, + 747, 748, 749, 750, 751, 752, 753, 754, 757, 760, 761, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 782, 783, 787, 788, 789, 793, + 794, 802, 806, 807, 808, 809, 814, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 841, 849, 850, 851, 852}; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "IF", "ELSE", "','", "'='", "SET", - "GTGT", "LTLT", "'|'", "OR", "'&'", "AND", "NE", "EQ", "'<'", "'>'", - "GE", "LE", "'+'", "'-'", "'*'", "'/'", "'%'", "DOTSLASH", "DOTSTAR", - "'!'", "MOINSMOINS", "PLUSPLUS", "UNARY", "'^'", "'''", "'_'", "'('", - "'['", "'.'", "')'", "']'", "LNUM", "DNUM", "CNUM", "ID", "FESPACEID", - "IDPARAM", "STRING", "ENDOFFILE", "INCLUDE", "LOAD", "BIDON", "FOR", - "WHILE", "BREAK", "CONTINUE", "RETURN", "TRY", "CATCH", "THROW", "TYPE", - "FUNCTION", "FESPACE", "FESPACE1", "FESPACE3", "FESPACES", "FESPACEL", - "VGFESPACE", "GFESPACE", "PLUSEQ", "MOINSEQ", "MULEQ", "DIVEQ", - "DOTMULEQ", "DOTDIVEQ", "ARROW", "BORDER", "SOLVE", "';'", "'{'", "'}'", - "':'", "'?'", "$accept", "start", "input", "instructions", - "list_of_id_args", "list_of_id1", "id", "list_of_dcls", - "parameters_list", "type_of_dcl", "ID_space", "ID_array_space", - "fespace123", "fespace", "spaceIDa", "spaceIDb", "spaceIDs", - "fespace_def", "fespace_def_list", "declaration", "@1", "@2", "@3", - "begin", "end", "for_loop", "while_loop", "declaration_for", "@4", "try", - "IDfor", "instruction", "@5", "catchs", "bornes", "border_expr", "Expr", - "unop", "no_comma_expr", "no_set_expr", "no_ternary_expr", - "sub_script_expr", "parameterstype", "parameters", "array", "FEarray", - "unary_expr", "pow_expr", "primaryp", "primary", 0 -}; +static const char *const yytname[] = {"$end", + "error", + "$undefined", + "IF", + "ELSE", + "','", + "'='", + "SET", + "GTGT", + "LTLT", + "'|'", + "OR", + "'&'", + "AND", + "NE", + "EQ", + "'<'", + "'>'", + "GE", + "LE", + "'+'", + "'-'", + "'*'", + "'/'", + "'%'", + "DOTSLASH", + "DOTSTAR", + "'!'", + "MOINSMOINS", + "PLUSPLUS", + "UNARY", + "'^'", + "'''", + "'_'", + "'('", + "'['", + "'.'", + "')'", + "']'", + "LNUM", + "DNUM", + "CNUM", + "ID", + "FESPACEID", + "IDPARAM", + "STRING", + "ENDOFFILE", + "INCLUDE", + "LOAD", + "BIDON", + "FOR", + "WHILE", + "BREAK", + "CONTINUE", + "RETURN", + "TRY", + "CATCH", + "THROW", + "TYPE", + "FUNCTION", + "FESPACE", + "FESPACE1", + "FESPACE3", + "FESPACES", + "FESPACEL", + "VGFESPACE", + "GFESPACE", + "PLUSEQ", + "MOINSEQ", + "MULEQ", + "DIVEQ", + "DOTMULEQ", + "DOTDIVEQ", + "ARROW", + "BORDER", + "SOLVE", + "';'", + "'{'", + "'}'", + "':'", + "'?'", + "$accept", + "start", + "input", + "instructions", + "list_of_id_args", + "list_of_id1", + "id", + "list_of_dcls", + "parameters_list", + "type_of_dcl", + "ID_space", + "ID_array_space", + "fespace123", + "fespace", + "spaceIDa", + "spaceIDb", + "spaceIDs", + "fespace_def", + "fespace_def_list", + "declaration", + "@1", + "@2", + "@3", + "begin", + "end", + "for_loop", + "while_loop", + "declaration_for", + "@4", + "try", + "IDfor", + "instruction", + "@5", + "catchs", + "bornes", + "border_expr", + "Expr", + "unop", + "no_comma_expr", + "no_set_expr", + "no_ternary_expr", + "sub_script_expr", + "parameterstype", + "parameters", + "array", + "FEarray", + "unary_expr", + "pow_expr", + "primaryp", + "primary", + 0}; #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 44, 61, 260, 261, 262, - 124, 263, 38, 264, 265, 266, 60, 62, 267, 268, - 43, 45, 42, 47, 37, 269, 270, 33, 271, 272, - 273, 94, 39, 95, 40, 91, 46, 41, 93, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 59, 123, 125, 58, - 63 -}; -# endif +static const yytype_uint16 yytoknum[] = {0, 256, 257, 258, 259, 44, 61, 260, 261, 262, 124, 263, 38, 264, 265, 266, 60, 62, 267, 268, 43, 45, 42, 47, 37, 269, 270, + 33, 271, 272, 273, 94, 39, 95, 40, 91, 46, 41, 93, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, + 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 59, 123, 125, 58, 63}; +#endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 81, 82, 83, 84, 84, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 86, 86, - 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 90, 90, 90, 90, 90, 90, 90, - 90, 91, 91, 91, 91, 91, 91, 92, 92, 93, - 93, 93, 93, 93, 93, 93, 94, 94, 95, 95, - 96, 96, 97, 97, 98, 98, 99, 99, 101, 100, - 100, 100, 100, 102, 100, 103, 100, 104, 105, 106, - 107, 109, 108, 110, 111, 111, 111, 112, 112, 112, - 112, 112, 112, 113, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 114, 115, 115, 116, - 117, 117, 118, 118, 118, 118, 118, 119, 119, 119, - 119, 119, 119, 119, 119, 120, 120, 120, 120, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 122, - 122, 122, 122, 123, 124, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 125, 125, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, - 128, 128, 128, 129, 129, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130 -}; +static const yytype_uint8 yyr1[] = {0, 81, 82, 83, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, + 85, 85, 85, 85, 85, 85, 86, 86, 87, 87, 87, 87, 87, 87, 88, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 90, + 90, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 93, 93, 93, 93, 93, 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, + 99, 99, 101, 100, 100, 100, 100, 102, 100, 103, 100, 104, 105, 106, 107, 109, 108, 110, 111, 111, 111, 112, 112, 112, 112, 112, 112, 113, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 114, 115, 115, 116, 117, 117, 118, 118, 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, 119, 120, 120, 120, 120, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 123, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, 128, 128, 128, 129, + 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130}; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 2, 1, 1, 2, 0, 1, 3, 2, - 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, - 5, 4, 3, 5, 6, 7, 6, 5, 4, 5, - 4, 5, 4, 5, 4, 5, 4, 5, 1, 3, - 1, 1, 1, 1, 1, 1, 1, 3, 4, 3, - 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, - 1, 3, 3, 1, 4, 7, 6, 9, 4, 7, - 9, 1, 4, 3, 3, 6, 5, 4, 6, 1, - 1, 1, 1, 1, 1, 1, 1, 4, 1, 3, - 1, 3, 2, 5, 4, 3, 1, 3, 0, 4, - 3, 2, 5, 0, 10, 0, 9, 1, 1, 1, - 1, 0, 3, 1, 1, 3, 5, 1, 2, 2, - 5, 2, 1, 0, 8, 9, 9, 5, 5, 7, - 3, 3, 6, 2, 2, 3, 7, 7, 9, 2, - 1, 3, 1, 1, 1, 1, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 1, 5, 3, 5, 1, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, - 1, 3, 5, 3, 0, 1, 1, 1, 1, 1, - 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, - 5, 1, 3, 1, 1, 1, 1, 1, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, - 1, 3, 3, 1, 2, 1, 1, 1, 1, 1, - 4, 4, 6, 3, 3, 3, 4, 3, 4, 3, - 4, 3, 4, 3, 4, 2, 2, 4, 4, 3, - 3, 3, 1 -}; +static const yytype_uint8 yyr2[] = {0, 2, 2, 1, 1, 2, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 5, 4, 3, 5, 6, 7, 6, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 4, 3, 1, + 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 3, 1, 4, 7, 6, 9, 4, 7, 9, 1, 4, 3, 3, 6, 5, 4, 6, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 3, 1, 3, 2, 5, 4, 3, 1, 3, 0, 4, 3, 2, + 5, 0, 10, 0, 9, 1, 1, 1, 1, 0, 3, 1, 1, 3, 5, 1, 2, 2, 5, 2, 1, 0, 8, 9, 9, 5, 5, 7, 3, 3, 6, 2, 2, 3, 7, 7, 9, 2, 1, 3, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 1, 5, 3, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 3, 5, 3, 0, 1, 1, 1, 1, 1, 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, 5, 1, 3, 1, + 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 1, 3, 3, 1, 2, 1, 1, 1, 1, 1, 4, 4, 6, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 2, 2, 4, 4, 3, 3, 3, 1}; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 0, 0, 143, 142, 144, 146, 145, 0, 0, - 226, 227, 228, 225, 0, 229, 0, 0, 109, 110, - 0, 0, 0, 113, 63, 0, 203, 204, 205, 206, - 207, 84, 85, 0, 117, 107, 0, 0, 3, 98, - 86, 0, 0, 122, 0, 0, 0, 0, 4, 0, - 0, 140, 147, 155, 252, 159, 218, 220, 223, 0, - 203, 204, 205, 206, 207, 0, 0, 203, 204, 205, - 206, 207, 0, 201, 0, 0, 96, 0, 118, 119, - 133, 134, 0, 0, 0, 0, 0, 63, 0, 184, - 0, 184, 0, 184, 0, 184, 0, 184, 0, 0, - 1, 2, 5, 0, 0, 0, 71, 90, 92, 101, - 0, 0, 0, 0, 0, 0, 121, 219, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 246, 245, 224, 184, 0, 0, 0, 251, 249, 0, - 250, 0, 0, 0, 100, 135, 0, 180, 179, 0, - 0, 0, 0, 6, 0, 225, 203, 204, 205, 206, - 207, 190, 0, 192, 0, 235, 0, 237, 0, 239, - 0, 241, 0, 243, 0, 0, 0, 131, 46, 0, - 0, 40, 0, 41, 45, 42, 43, 44, 0, 38, - 0, 0, 0, 108, 130, 111, 0, 0, 114, 0, - 0, 0, 141, 148, 149, 150, 151, 152, 153, 154, - 168, 167, 171, 172, 169, 170, 178, 177, 173, 175, - 176, 174, 165, 166, 160, 163, 164, 162, 161, 157, - 0, 208, 209, 210, 211, 212, 213, 214, 215, 216, - 217, 221, 222, 0, 233, 0, 234, 0, 202, 225, - 203, 204, 205, 206, 207, 95, 50, 0, 97, 68, - 0, 184, 247, 248, 0, 64, 0, 0, 6, 41, - 42, 43, 44, 0, 7, 0, 6, 0, 0, 236, - 238, 240, 242, 244, 0, 0, 139, 0, 0, 0, - 99, 87, 0, 0, 74, 73, 0, 0, 91, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 230, 0, - 231, 128, 0, 51, 52, 53, 54, 55, 0, 94, - 0, 181, 183, 0, 0, 102, 6, 0, 0, 9, - 0, 11, 0, 13, 0, 15, 0, 105, 0, 0, - 17, 0, 191, 203, 204, 205, 206, 207, 198, 0, - 199, 0, 0, 47, 0, 49, 0, 0, 88, 93, - 39, 0, 0, 72, 112, 0, 0, 115, 0, 127, - 0, 120, 158, 156, 0, 0, 61, 62, 0, 0, - 66, 0, 0, 19, 10, 12, 14, 16, 0, 6, - 41, 42, 43, 44, 22, 0, 0, 8, 18, 103, - 0, 0, 132, 48, 0, 0, 0, 76, 0, 0, - 0, 0, 123, 0, 232, 129, 0, 69, 182, 0, - 65, 21, 6, 0, 0, 28, 0, 30, 0, 32, - 0, 34, 0, 0, 36, 0, 0, 200, 0, 0, - 0, 89, 75, 0, 0, 116, 0, 0, 0, 0, - 20, 0, 23, 29, 31, 33, 35, 27, 37, 0, - 0, 141, 0, 77, 0, 0, 124, 0, 70, 67, - 26, 24, 106, 0, 137, 0, 0, 126, 125, 0, - 25, 104, 0, 78, 0, 138, 136 -}; +static const yytype_uint8 yydefact[] = { + 0, 0, 0, 143, 142, 144, 146, 145, 0, 0, 226, 227, 228, 225, 0, 229, 0, 0, 109, 110, 0, 0, 0, 113, 63, 0, 203, 204, 205, 206, 207, 84, 85, 0, 117, 107, 0, 0, 3, + 98, 86, 0, 0, 122, 0, 0, 0, 0, 4, 0, 0, 140, 147, 155, 252, 159, 218, 220, 223, 0, 203, 204, 205, 206, 207, 0, 0, 203, 204, 205, 206, 207, 0, 201, 0, 0, 96, 0, + 118, 119, 133, 134, 0, 0, 0, 0, 0, 63, 0, 184, 0, 184, 0, 184, 0, 184, 0, 184, 0, 0, 1, 2, 5, 0, 0, 0, 71, 90, 92, 101, 0, 0, 0, 0, 0, 0, 121, + 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 246, 245, 224, 184, 0, 0, + 0, 251, 249, 0, 250, 0, 0, 0, 100, 135, 0, 180, 179, 0, 0, 0, 0, 6, 0, 225, 203, 204, 205, 206, 207, 190, 0, 192, 0, 235, 0, 237, 0, 239, 0, 241, 0, 243, 0, + 0, 0, 131, 46, 0, 0, 40, 0, 41, 45, 42, 43, 44, 0, 38, 0, 0, 0, 108, 130, 111, 0, 0, 114, 0, 0, 0, 141, 148, 149, 150, 151, 152, 153, 154, 168, 167, 171, 172, + 169, 170, 178, 177, 173, 175, 176, 174, 165, 166, 160, 163, 164, 162, 161, 157, 0, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 221, 222, 0, 233, 0, 234, 0, 202, 225, 203, 204, 205, + 206, 207, 95, 50, 0, 97, 68, 0, 184, 247, 248, 0, 64, 0, 0, 6, 41, 42, 43, 44, 0, 7, 0, 6, 0, 0, 236, 238, 240, 242, 244, 0, 0, 139, 0, 0, 0, 99, 87, + 0, 0, 74, 73, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 230, 0, 231, 128, 0, 51, 52, 53, 54, 55, 0, 94, 0, 181, 183, 0, 0, 102, 6, 0, 0, 9, 0, + 11, 0, 13, 0, 15, 0, 105, 0, 0, 17, 0, 191, 203, 204, 205, 206, 207, 198, 0, 199, 0, 0, 47, 0, 49, 0, 0, 88, 93, 39, 0, 0, 72, 112, 0, 0, 115, 0, 127, + 0, 120, 158, 156, 0, 0, 61, 62, 0, 0, 66, 0, 0, 19, 10, 12, 14, 16, 0, 6, 41, 42, 43, 44, 22, 0, 0, 8, 18, 103, 0, 0, 132, 48, 0, 0, 0, 76, 0, + 0, 0, 0, 123, 0, 232, 129, 0, 69, 182, 0, 65, 21, 6, 0, 0, 28, 0, 30, 0, 32, 0, 34, 0, 0, 36, 0, 0, 200, 0, 0, 0, 89, 75, 0, 0, 116, 0, 0, + 0, 0, 20, 0, 23, 29, 31, 33, 35, 27, 37, 0, 0, 141, 0, 77, 0, 0, 124, 0, 70, 67, 26, 24, 106, 0, 137, 0, 0, 126, 125, 0, 25, 104, 0, 78, 0, 138, 136}; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 36, 37, 38, 293, 208, 182, 199, 275, 39, - 107, 378, 40, 41, 379, 108, 42, 76, 77, 43, - 103, 456, 416, 44, 214, 45, 46, 216, 319, 47, - 219, 48, 466, 391, 196, 197, 49, 50, 51, 52, - 53, 183, 170, 184, 74, 54, 55, 56, 57, 58 -}; +static const yytype_int16 yydefgoto[] = {-1, 36, 37, 38, 293, 208, 182, 199, 275, 39, 107, 378, 40, 41, 379, 108, 42, 76, 77, 43, 103, 456, 416, 44, 214, + 45, 46, 216, 319, 47, 219, 48, 466, 391, 196, 197, 49, 50, 51, 52, 53, 183, 170, 184, 74, 54, 55, 56, 57, 58}; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -284 -static const yytype_int16 yypact[] = -{ - 697, 77, 642, -284, -284, -284, -284, -284, 1020, 1020, - -284, -284, -284, -284, -6, -284, 31, 69, -284, -284, - -15, 73, 1020, -284, 285, 0, 402, 442, 523, 621, - 685, -284, -284, 121, -284, -284, 197, 140, 697, -284, - 184, -5, 134, -284, 697, 209, 179, 149, -284, 16, - 1060, -284, 99, 119, 102, -284, -284, 70, 806, 1020, - -284, -284, -284, -284, -284, 245, 200, 139, 218, 246, - 275, 276, 34, -284, 2, 11, -284, 17, -284, -284, - -284, -284, 18, 191, 971, 208, 78, 268, 230, 816, - 253, 816, 265, 816, 292, 816, 293, 816, 294, 287, - -284, -284, -284, 295, 260, 907, 154, -284, 234, -284, - 440, 1069, 332, 1020, 697, 1020, -284, -284, 1020, 1020, - 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, - 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, - 1020, 1020, 1020, 1020, 1020, 1020, 1080, 1205, 1020, 1020, - -284, -284, -284, 816, 869, 301, 50, -284, -284, 1020, - -284, 1118, 1118, -6, -284, -284, 329, -284, 511, 52, - 312, 15, 1020, 959, 328, 360, 117, 142, 227, 311, - 353, -284, 362, -284, 76, -284, 147, -284, 157, -284, - 167, -284, 172, -284, 330, 1020, 697, -284, 182, 19, - 359, -284, 340, -284, -284, -284, -284, -284, 24, -284, - 1020, 1020, 252, -284, -284, -284, 304, 20, 365, 302, - 175, 568, -284, -284, -284, -284, -284, -284, -284, -284, - 1192, 1192, 1207, 1207, 1220, 1220, 1148, 1148, 1238, 1238, - 1238, 1238, 1248, 1248, -284, -284, -284, -284, -284, 767, - 786, -284, -284, -284, -284, -284, -284, -284, -284, -284, - -284, -284, -284, 177, -284, 26, -284, 697, -284, 377, - 14, 33, 49, 159, 169, -284, -284, 186, -284, 349, - 1020, 816, -284, -284, 327, 356, 21, 385, 959, 195, - 229, 236, 264, 203, 382, 290, 959, 1020, 918, -284, - -284, -284, -284, -284, 415, 27, -284, 1020, 1118, 295, - -284, -284, 273, 332, 155, -284, 386, 332, -284, 295, - 1020, 1020, 332, 1060, 697, 371, 1020, 1020, -284, 971, - -284, 425, 1020, -284, -284, -284, -284, -284, 1118, -284, - 372, 805, 426, 394, 387, -284, 959, 28, 332, -284, - 332, -284, 332, -284, 332, -284, 1009, -284, 1020, 332, - -284, 210, -284, 428, 436, 538, 542, 549, -284, 429, - -284, 1020, 364, -284, 223, -284, 332, 414, -284, 445, - -284, 1020, 1020, -284, 448, 22, 23, 449, 1219, -284, - 423, -284, 1175, 1175, 433, 697, -284, -284, 30, 1020, - 451, 458, 39, -284, -284, -284, -284, -284, 462, 959, - 447, 500, 704, 857, 457, 880, 507, -284, -284, -284, - 1020, 510, -284, -284, 41, 1020, 273, -284, 502, 1020, - 1020, 332, -284, 505, -284, -284, 480, -284, 1175, 487, - -284, 529, 959, 42, 332, -284, 332, -284, 332, -284, - 332, -284, 1020, 332, -284, 1020, 472, -284, 1020, 516, - 514, -284, -284, 231, 233, -284, 697, 520, 528, 530, - -284, 44, 550, -284, -284, -284, -284, -284, -284, 493, - 697, -33, 1020, -284, 697, 697, -284, 537, -284, -284, - 560, -284, -284, 633, -284, 539, 543, -284, -284, 545, - -284, -284, 554, -284, 697, -284, -284 -}; +static const yytype_int16 yypact[] = { + 697, 77, 642, -284, -284, -284, -284, -284, 1020, 1020, -284, -284, -284, -284, -6, -284, 31, 69, -284, -284, -15, 73, 1020, -284, 285, 0, 402, 442, 523, 621, 685, -284, + -284, 121, -284, -284, 197, 140, 697, -284, 184, -5, 134, -284, 697, 209, 179, 149, -284, 16, 1060, -284, 99, 119, 102, -284, -284, 70, 806, 1020, -284, -284, -284, -284, + -284, 245, 200, 139, 218, 246, 275, 276, 34, -284, 2, 11, -284, 17, -284, -284, -284, -284, 18, 191, 971, 208, 78, 268, 230, 816, 253, 816, 265, 816, 292, 816, + 293, 816, 294, 287, -284, -284, -284, 295, 260, 907, 154, -284, 234, -284, 440, 1069, 332, 1020, 697, 1020, -284, -284, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, + 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1080, 1205, 1020, 1020, -284, -284, -284, 816, 869, 301, 50, -284, -284, 1020, + -284, 1118, 1118, -6, -284, -284, 329, -284, 511, 52, 312, 15, 1020, 959, 328, 360, 117, 142, 227, 311, 353, -284, 362, -284, 76, -284, 147, -284, 157, -284, 167, -284, + 172, -284, 330, 1020, 697, -284, 182, 19, 359, -284, 340, -284, -284, -284, -284, -284, 24, -284, 1020, 1020, 252, -284, -284, -284, 304, 20, 365, 302, 175, 568, -284, -284, + -284, -284, -284, -284, -284, -284, 1192, 1192, 1207, 1207, 1220, 1220, 1148, 1148, 1238, 1238, 1238, 1238, 1248, 1248, -284, -284, -284, -284, -284, 767, 786, -284, -284, -284, -284, -284, + -284, -284, -284, -284, -284, -284, -284, 177, -284, 26, -284, 697, -284, 377, 14, 33, 49, 159, 169, -284, -284, 186, -284, 349, 1020, 816, -284, -284, 327, 356, 21, 385, + 959, 195, 229, 236, 264, 203, 382, 290, 959, 1020, 918, -284, -284, -284, -284, -284, 415, 27, -284, 1020, 1118, 295, -284, -284, 273, 332, 155, -284, 386, 332, -284, 295, + 1020, 1020, 332, 1060, 697, 371, 1020, 1020, -284, 971, -284, 425, 1020, -284, -284, -284, -284, -284, 1118, -284, 372, 805, 426, 394, 387, -284, 959, 28, 332, -284, 332, -284, + 332, -284, 332, -284, 1009, -284, 1020, 332, -284, 210, -284, 428, 436, 538, 542, 549, -284, 429, -284, 1020, 364, -284, 223, -284, 332, 414, -284, 445, -284, 1020, 1020, -284, + 448, 22, 23, 449, 1219, -284, 423, -284, 1175, 1175, 433, 697, -284, -284, 30, 1020, 451, 458, 39, -284, -284, -284, -284, -284, 462, 959, 447, 500, 704, 857, 457, 880, + 507, -284, -284, -284, 1020, 510, -284, -284, 41, 1020, 273, -284, 502, 1020, 1020, 332, -284, 505, -284, -284, 480, -284, 1175, 487, -284, 529, 959, 42, 332, -284, 332, -284, + 332, -284, 332, -284, 1020, 332, -284, 1020, 472, -284, 1020, 516, 514, -284, -284, 231, 233, -284, 697, 520, 528, 530, -284, 44, 550, -284, -284, -284, -284, -284, -284, 493, + 697, -33, 1020, -284, 697, 697, -284, 537, -284, -284, 560, -284, -284, 633, -284, 539, 543, -284, -284, 545, -284, -284, 554, -284, 697, -284, -284}; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -284, -284, -284, -41, -283, 211, -71, -209, -153, -23, - 380, 168, -284, -284, -284, -284, -284, 430, -284, -284, - -284, -284, -284, -284, -284, -284, -284, -284, -284, -284, - -284, -38, -284, -284, -284, -284, -7, -284, -3, -151, - 272, -76, -284, -79, 405, 602, 181, 555, -284, 283 -}; +static const yytype_int16 yypgoto[] = {-284, -284, -284, -41, -283, 211, -71, -209, -153, -23, 380, 168, -284, -284, -284, -284, -284, 430, -284, -284, -284, -284, -284, -284, -284, + -284, -284, -284, -284, -284, -284, -38, -284, -284, -284, -284, -7, -284, -3, -151, 272, -76, -284, -79, 405, 602, 181, 555, -284, 283}; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -198 -static const yytype_int16 yytable[] = -{ - 102, 72, 88, 110, 494, 347, 73, 159, 169, 277, - 276, 276, 186, 361, 188, 82, 190, 161, 192, -56, - 284, 115, 163, 115, 309, 115, 115, 115, 115, 313, - 105, 329, 159, 356, 209, 436, 75, 106, -57, 115, - 160, 218, 86, 495, 356, 162, 313, 356, 89, 356, - 90, -56, 156, 285, -58, 115, 333, 281, 87, 315, - 316, 80, 314, 402, 330, 372, 403, 91, 437, 92, - -57, 158, 102, 221, 263, 334, 78, 441, 265, 459, - 472, 298, 490, 93, 172, 94, -58, 267, 215, 282, - -56, 335, 116, 164, 165, 310, 321, 345, 429, 430, - 375, 148, 294, 149, 217, 118, 220, 146, 222, -57, - 384, 59, 173, 299, 79, 223, 224, 225, 226, 227, - 228, 229, -185, -41, 147, -58, 443, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 142, 143, 362, -186, -45, 81, - 295, 89, 298, 90, -185, 374, 268, 276, 306, 471, - 210, 381, 298, 99, -59, 286, 119, 120, 121, 122, - 123, 124, 298, 89, -60, 90, 91, 298, 92, -186, - 115, 396, 298, 102, 300, 397, 101, 276, 307, 211, - 382, 338, 73, 95, 301, 96, -59, 100, 144, 145, - 104, 336, 342, 97, 302, 98, -60, 348, 356, 303, - 109, 337, 324, 113, 328, 356, 308, 294, 349, 351, - 353, 355, 370, 339, 360, 294, 114, 369, 338, 331, - 427, 428, -187, -42, 84, -59, 115, 201, 115, 212, - 357, 350, 380, 111, 112, -60, 209, 419, 352, 166, - 146, 387, 91, 394, 92, 203, 204, 205, 206, 207, - 423, 93, 157, 94, -187, 295, 171, 147, 484, 457, - 485, 201, 174, 295, 460, 294, 354, 404, 201, 405, - 93, 406, 94, 407, 83, 414, 389, 317, 418, 203, - 204, 205, 206, 207, 106, 185, 203, 204, 205, 206, - 207, 83, 359, 85, 373, 209, 201, 187, 376, 95, - 97, 96, 98, 385, 386, 377, -188, -43, 200, 84, - 85, 194, 195, 295, 203, 204, 205, 206, 207, 261, - 262, 496, 201, 415, 189, 191, 193, 198, 294, 445, - 447, 449, 451, 266, 454, 95, 279, 96, -188, 283, - 203, 204, 205, 206, 207, 417, 168, 435, -189, -44, - 465, 168, 296, 168, 421, 168, -40, 168, 297, 168, - 322, 294, 304, 473, 201, 474, 311, 475, 312, 476, - 320, 323, 478, 332, 340, 343, 295, 97, 358, 98, - -189, 344, 203, 204, 205, 206, 207, 230, 231, 232, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, - 243, 244, 245, 246, 247, 248, 249, 250, -79, 295, - 346, 371, 463, 464, 383, 168, 168, 390, 486, 395, - 398, 298, 400, -193, -41, 420, 89, -79, 90, 493, - 422, -194, -45, 1, -79, 401, 497, 498, 425, 477, - 426, 481, 479, 309, 431, 102, 2, 433, -80, 444, - 3, 4, 89, 452, 90, -193, 506, 5, 6, 7, - 91, 434, 92, -194, 8, 9, 91, -80, 92, 10, - 11, 12, 13, 14, -80, 15, 439, 16, 17, 201, - 18, 19, 20, 21, 22, 23, 440, 442, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 203, 204, 205, - 206, 207, 446, 455, 33, 458, 34, 35, 213, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 468, -81, - 462, 467, 201, -195, -42, 469, 470, -196, -43, 480, - 482, 483, 341, 168, -197, -44, 487, 93, -81, 94, - 203, 204, 205, 206, 207, -81, 488, 491, 489, 492, - 168, 1, 93, 499, 94, -195, 95, 500, 96, -196, - 503, 502, 504, 97, 2, 98, -197, 424, 3, 4, - 280, 505, 318, 278, 461, 5, 6, 7, 392, 393, - 305, 168, 8, 9, 65, 117, 388, 10, 11, 12, - 13, 14, 0, 15, 0, 16, 17, 0, 18, 19, - 20, 21, 22, 23, 0, 0, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 1, -82, 0, 0, - 0, 0, 33, 0, 34, 35, 325, 0, 0, 2, - 0, 0, 0, 3, 4, 95, -82, 96, 0, 0, - 5, 6, 7, -82, 0, 0, 0, 8, 9, 0, - 0, 438, 10, 11, 12, 13, 14, 0, 15, 0, - 16, 17, 0, 18, 19, 20, 21, 22, 23, 0, - 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 1, -83, 60, 61, 62, 63, 64, 33, 0, 34, - 35, 501, 0, 2, 0, 0, 448, 3, 4, 97, - -83, 98, 0, 0, 5, 6, 7, -83, 0, 0, - 0, 8, 9, 0, 0, 0, 10, 11, 12, 13, - 14, 0, 15, 0, 16, 17, 201, 18, 19, 20, - 21, 22, 23, 0, 0, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 203, 204, 205, 206, 207, 0, - 0, 33, 0, 34, 35, 125, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 2, 0, 150, 151, 3, 4, 152, 0, - 153, 154, 155, 5, 6, 7, 326, 0, 0, 0, - 8, 9, 0, 0, 0, 10, 11, 12, 175, 0, - 0, 15, 0, 0, 0, 327, 0, 0, 0, 450, - 0, 0, 0, 0, 66, 0, 176, 177, 178, 179, - 180, 181, 0, 0, 399, 2, 0, 0, 0, 3, - 4, 0, 453, 0, 0, 167, 5, 6, 7, 201, - 0, 0, 0, 8, 9, 0, 0, 264, 10, 11, - 12, 13, 0, 0, 15, 0, 0, 203, 204, 205, - 206, 207, 201, 0, 0, 0, 0, 66, 0, 67, - 68, 69, 70, 71, 2, 0, 0, 0, 3, 4, - 203, 204, 205, 206, 207, 5, 6, 7, 167, 201, - 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, - 175, 0, 0, 15, 0, 202, 0, 203, 204, 205, - 206, 207, 0, 0, 0, 287, 66, 0, 363, 364, - 365, 366, 367, 368, 0, 0, 0, 2, 0, 0, - 0, 3, 4, 0, 288, 0, 0, 167, 5, 6, - 7, 201, 0, 0, 0, 8, 9, 0, 0, 0, - 10, 11, 12, 13, 0, 0, 15, 87, 0, 289, - 204, 290, 291, 292, 0, 408, 0, 0, 0, 66, - 0, 67, 68, 69, 70, 71, 2, 0, 0, 0, - 3, 4, 0, 0, 409, 0, 0, 5, 6, 7, - 167, 201, 0, 0, 8, 9, 0, 0, 0, 10, - 11, 12, 13, 0, 0, 15, 0, 87, 0, 410, - 204, 411, 412, 413, 0, 0, 2, 0, 66, 0, - 67, 68, 69, 70, 71, 2, 0, 0, 0, 3, - 4, 0, 0, 0, 8, 9, 5, 6, 7, 10, - 11, 12, 13, 8, 9, 15, 0, 0, 10, 11, - 12, 13, 0, 0, 15, 0, 0, 0, 66, 0, - 67, 68, 69, 70, 71, 0, 0, 24, 0, 67, - 68, 69, 70, 71, 2, 0, 0, 0, 3, 4, - 251, 252, 253, 254, 255, 5, 6, 7, 0, 0, - 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, - 269, 0, 0, 15, 133, 134, 135, 136, 137, 138, - 139, 140, 141, 142, 143, 0, 66, 0, 270, 271, - 272, 273, 274, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 131, 132, 133, 134, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 150, 151, 0, - 0, 0, 0, 153, 154, 155, 0, 432, 137, 138, - 139, 140, 141, 142, 143, 256, 257, 258, 259, 260, - 139, 140, 141, 142, 143 -}; - -static const yytype_int16 yycheck[] = -{ - 38, 8, 25, 44, 37, 288, 9, 5, 84, 162, - 161, 162, 91, 296, 93, 22, 95, 6, 97, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 35, 5, 5, 5, 105, 5, 42, 42, 5, 5, - 38, 112, 42, 76, 5, 34, 5, 5, 34, 5, - 36, 37, 59, 38, 5, 5, 42, 5, 58, 210, - 211, 76, 38, 346, 38, 38, 38, 34, 38, 36, - 37, 37, 110, 114, 153, 42, 45, 38, 154, 38, - 38, 5, 38, 34, 6, 36, 37, 37, 111, 37, - 76, 42, 76, 76, 76, 76, 76, 76, 76, 76, - 309, 31, 173, 33, 111, 6, 113, 5, 115, 76, - 319, 34, 34, 37, 45, 118, 119, 120, 121, 122, - 123, 124, 5, 6, 22, 76, 409, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 297, 5, 6, 76, - 173, 34, 5, 36, 37, 308, 159, 308, 196, 442, - 6, 6, 5, 42, 5, 172, 67, 68, 69, 70, - 71, 72, 5, 34, 5, 36, 34, 5, 36, 37, - 5, 332, 5, 221, 37, 338, 46, 338, 6, 35, - 35, 5, 195, 34, 37, 36, 37, 0, 79, 80, - 16, 42, 281, 34, 37, 36, 37, 12, 5, 37, - 76, 42, 37, 34, 37, 5, 34, 288, 289, 290, - 291, 292, 298, 37, 295, 296, 77, 298, 5, 267, - 381, 382, 5, 6, 34, 76, 5, 42, 5, 5, - 37, 12, 313, 34, 35, 76, 317, 37, 12, 58, - 5, 322, 34, 329, 36, 60, 61, 62, 63, 64, - 37, 34, 17, 36, 37, 288, 58, 22, 37, 420, - 37, 42, 42, 296, 425, 346, 12, 348, 42, 350, - 34, 352, 36, 354, 16, 356, 324, 35, 359, 60, - 61, 62, 63, 64, 42, 42, 60, 61, 62, 63, - 64, 16, 12, 35, 307, 376, 42, 42, 35, 34, - 34, 36, 36, 320, 321, 42, 5, 6, 58, 34, - 35, 34, 35, 346, 60, 61, 62, 63, 64, 148, - 149, 482, 42, 356, 42, 42, 42, 42, 409, 410, - 411, 412, 413, 42, 415, 34, 17, 36, 37, 37, - 60, 61, 62, 63, 64, 358, 84, 395, 5, 6, - 431, 89, 34, 91, 371, 93, 6, 95, 6, 97, - 5, 442, 42, 444, 42, 446, 17, 448, 38, 450, - 76, 79, 453, 6, 35, 58, 409, 34, 6, 36, - 37, 35, 60, 61, 62, 63, 64, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 142, 143, 144, 145, 16, 442, - 35, 6, 429, 430, 38, 153, 154, 56, 466, 4, - 58, 5, 38, 5, 6, 6, 34, 35, 36, 480, - 76, 5, 6, 3, 42, 58, 484, 485, 34, 452, - 5, 458, 455, 5, 5, 493, 16, 34, 16, 12, - 20, 21, 34, 6, 36, 37, 504, 27, 28, 29, - 34, 38, 36, 37, 34, 35, 34, 35, 36, 39, - 40, 41, 42, 43, 42, 45, 35, 47, 48, 42, - 50, 51, 52, 53, 54, 55, 38, 35, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 60, 61, 62, - 63, 64, 12, 6, 74, 5, 76, 77, 78, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 58, 16, - 38, 36, 42, 5, 6, 58, 17, 5, 6, 77, - 34, 37, 280, 281, 5, 6, 36, 34, 35, 36, - 60, 61, 62, 63, 64, 42, 38, 17, 38, 76, - 298, 3, 34, 36, 36, 37, 34, 17, 36, 37, - 37, 42, 37, 34, 16, 36, 37, 376, 20, 21, - 79, 37, 212, 163, 426, 27, 28, 29, 326, 327, - 195, 329, 34, 35, 2, 50, 323, 39, 40, 41, - 42, 43, -1, 45, -1, 47, 48, -1, 50, 51, - 52, 53, 54, 55, -1, -1, 58, 59, 60, 61, - 62, 63, 64, 65, 66, -1, 3, 16, -1, -1, - -1, -1, 74, -1, 76, 77, 78, -1, -1, 16, - -1, -1, -1, 20, 21, 34, 35, 36, -1, -1, - 27, 28, 29, 42, -1, -1, -1, 34, 35, -1, - -1, 399, 39, 40, 41, 42, 43, -1, 45, -1, - 47, 48, -1, 50, 51, 52, 53, 54, 55, -1, - -1, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 3, 16, 60, 61, 62, 63, 64, 74, -1, 76, - 77, 78, -1, 16, -1, -1, 12, 20, 21, 34, - 35, 36, -1, -1, 27, 28, 29, 42, -1, -1, - -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, - 43, -1, 45, -1, 47, 48, 42, 50, 51, 52, - 53, 54, 55, -1, -1, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 60, 61, 62, 63, 64, -1, - -1, 74, -1, 76, 77, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 16, -1, 28, 29, 20, 21, 32, -1, - 34, 35, 36, 27, 28, 29, 79, -1, -1, -1, - 34, 35, -1, -1, -1, 39, 40, 41, 42, -1, - -1, 45, -1, -1, -1, 79, -1, -1, -1, 12, - -1, -1, -1, -1, 58, -1, 60, 61, 62, 63, - 64, 65, -1, -1, 79, 16, -1, -1, -1, 20, - 21, -1, 12, -1, -1, 79, 27, 28, 29, 42, - -1, -1, -1, 34, 35, -1, -1, 38, 39, 40, - 41, 42, -1, -1, 45, -1, -1, 60, 61, 62, - 63, 64, 42, -1, -1, -1, -1, 58, -1, 60, - 61, 62, 63, 64, 16, -1, -1, -1, 20, 21, - 60, 61, 62, 63, 64, 27, 28, 29, 79, 42, - -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, - 42, -1, -1, 45, -1, 58, -1, 60, 61, 62, - 63, 64, -1, -1, -1, 16, 58, -1, 60, 61, - 62, 63, 64, 65, -1, -1, -1, 16, -1, -1, - -1, 20, 21, -1, 35, -1, -1, 79, 27, 28, - 29, 42, -1, -1, -1, 34, 35, -1, -1, -1, - 39, 40, 41, 42, -1, -1, 45, 58, -1, 60, - 61, 62, 63, 64, -1, 16, -1, -1, -1, 58, - -1, 60, 61, 62, 63, 64, 16, -1, -1, -1, - 20, 21, -1, -1, 35, -1, -1, 27, 28, 29, - 79, 42, -1, -1, 34, 35, -1, -1, -1, 39, - 40, 41, 42, -1, -1, 45, -1, 58, -1, 60, - 61, 62, 63, 64, -1, -1, 16, -1, 58, -1, - 60, 61, 62, 63, 64, 16, -1, -1, -1, 20, - 21, -1, -1, -1, 34, 35, 27, 28, 29, 39, - 40, 41, 42, 34, 35, 45, -1, -1, 39, 40, - 41, 42, -1, -1, 45, -1, -1, -1, 58, -1, - 60, 61, 62, 63, 64, -1, -1, 58, -1, 60, - 61, 62, 63, 64, 16, -1, -1, -1, 20, 21, - 60, 61, 62, 63, 64, 27, 28, 29, -1, -1, - -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, - 42, -1, -1, 45, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, -1, 58, -1, 60, 61, - 62, 63, 64, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 28, 29, -1, - -1, -1, -1, 34, 35, 36, -1, 38, 20, 21, - 22, 23, 24, 25, 26, 60, 61, 62, 63, 64, - 22, 23, 24, 25, 26 -}; +static const yytype_int16 yytable[] = { + 102, 72, 88, 110, 494, 347, 73, 159, 169, 277, 276, 276, 186, 361, 188, 82, 190, 161, 192, -56, 284, 115, 163, 115, 309, 115, 115, 115, 115, 313, 105, 329, 159, 356, 209, 436, 75, + 106, -57, 115, 160, 218, 86, 495, 356, 162, 313, 356, 89, 356, 90, -56, 156, 285, -58, 115, 333, 281, 87, 315, 316, 80, 314, 402, 330, 372, 403, 91, 437, 92, -57, 158, 102, 221, + 263, 334, 78, 441, 265, 459, 472, 298, 490, 93, 172, 94, -58, 267, 215, 282, -56, 335, 116, 164, 165, 310, 321, 345, 429, 430, 375, 148, 294, 149, 217, 118, 220, 146, 222, -57, 384, + 59, 173, 299, 79, 223, 224, 225, 226, 227, 228, 229, -185, -41, 147, -58, 443, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 362, -186, + -45, 81, 295, 89, 298, 90, -185, 374, 268, 276, 306, 471, 210, 381, 298, 99, -59, 286, 119, 120, 121, 122, 123, 124, 298, 89, -60, 90, 91, 298, 92, -186, 115, 396, 298, 102, 300, + 397, 101, 276, 307, 211, 382, 338, 73, 95, 301, 96, -59, 100, 144, 145, 104, 336, 342, 97, 302, 98, -60, 348, 356, 303, 109, 337, 324, 113, 328, 356, 308, 294, 349, 351, 353, 355, + 370, 339, 360, 294, 114, 369, 338, 331, 427, 428, -187, -42, 84, -59, 115, 201, 115, 212, 357, 350, 380, 111, 112, -60, 209, 419, 352, 166, 146, 387, 91, 394, 92, 203, 204, 205, 206, + 207, 423, 93, 157, 94, -187, 295, 171, 147, 484, 457, 485, 201, 174, 295, 460, 294, 354, 404, 201, 405, 93, 406, 94, 407, 83, 414, 389, 317, 418, 203, 204, 205, 206, 207, 106, 185, + 203, 204, 205, 206, 207, 83, 359, 85, 373, 209, 201, 187, 376, 95, 97, 96, 98, 385, 386, 377, -188, -43, 200, 84, 85, 194, 195, 295, 203, 204, 205, 206, 207, 261, 262, 496, 201, + 415, 189, 191, 193, 198, 294, 445, 447, 449, 451, 266, 454, 95, 279, 96, -188, 283, 203, 204, 205, 206, 207, 417, 168, 435, -189, -44, 465, 168, 296, 168, 421, 168, -40, 168, 297, 168, + 322, 294, 304, 473, 201, 474, 311, 475, 312, 476, 320, 323, 478, 332, 340, 343, 295, 97, 358, 98, -189, 344, 203, 204, 205, 206, 207, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, -79, 295, 346, 371, 463, 464, 383, 168, 168, 390, 486, 395, 398, 298, 400, -193, -41, 420, 89, -79, 90, 493, 422, -194, -45, 1, + -79, 401, 497, 498, 425, 477, 426, 481, 479, 309, 431, 102, 2, 433, -80, 444, 3, 4, 89, 452, 90, -193, 506, 5, 6, 7, 91, 434, 92, -194, 8, 9, 91, -80, 92, 10, 11, + 12, 13, 14, -80, 15, 439, 16, 17, 201, 18, 19, 20, 21, 22, 23, 440, 442, 24, 25, 26, 27, 28, 29, 30, 31, 32, 203, 204, 205, 206, 207, 446, 455, 33, 458, 34, 35, + 213, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 468, -81, 462, 467, 201, -195, -42, 469, 470, -196, -43, 480, 482, 483, 341, 168, -197, + -44, 487, 93, -81, 94, 203, 204, 205, 206, 207, -81, 488, 491, 489, 492, 168, 1, 93, 499, 94, -195, 95, 500, 96, -196, 503, 502, 504, 97, 2, 98, -197, 424, 3, 4, 280, 505, + 318, 278, 461, 5, 6, 7, 392, 393, 305, 168, 8, 9, 65, 117, 388, 10, 11, 12, 13, 14, 0, 15, 0, 16, 17, 0, 18, 19, 20, 21, 22, 23, 0, 0, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 0, 1, -82, 0, 0, 0, 0, 33, 0, 34, 35, 325, 0, 0, 2, 0, 0, 0, 3, 4, 95, -82, 96, 0, 0, 5, 6, 7, -82, 0, 0, + 0, 8, 9, 0, 0, 438, 10, 11, 12, 13, 14, 0, 15, 0, 16, 17, 0, 18, 19, 20, 21, 22, 23, 0, 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1, -83, 60, + 61, 62, 63, 64, 33, 0, 34, 35, 501, 0, 2, 0, 0, 448, 3, 4, 97, -83, 98, 0, 0, 5, 6, 7, -83, 0, 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, 13, + 14, 0, 15, 0, 16, 17, 201, 18, 19, 20, 21, 22, 23, 0, 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, 203, 204, 205, 206, 207, 0, 0, 33, 0, 34, 35, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 2, 0, 150, 151, 3, 4, 152, 0, 153, 154, 155, 5, 6, 7, 326, 0, 0, 0, 8, + 9, 0, 0, 0, 10, 11, 12, 175, 0, 0, 15, 0, 0, 0, 327, 0, 0, 0, 450, 0, 0, 0, 0, 66, 0, 176, 177, 178, 179, 180, 181, 0, 0, 399, 2, 0, 0, + 0, 3, 4, 0, 453, 0, 0, 167, 5, 6, 7, 201, 0, 0, 0, 8, 9, 0, 0, 264, 10, 11, 12, 13, 0, 0, 15, 0, 0, 203, 204, 205, 206, 207, 201, 0, 0, + 0, 0, 66, 0, 67, 68, 69, 70, 71, 2, 0, 0, 0, 3, 4, 203, 204, 205, 206, 207, 5, 6, 7, 167, 201, 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, 175, 0, + 0, 15, 0, 202, 0, 203, 204, 205, 206, 207, 0, 0, 0, 287, 66, 0, 363, 364, 365, 366, 367, 368, 0, 0, 0, 2, 0, 0, 0, 3, 4, 0, 288, 0, 0, 167, 5, + 6, 7, 201, 0, 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, 13, 0, 0, 15, 87, 0, 289, 204, 290, 291, 292, 0, 408, 0, 0, 0, 66, 0, 67, 68, 69, 70, 71, + 2, 0, 0, 0, 3, 4, 0, 0, 409, 0, 0, 5, 6, 7, 167, 201, 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, 13, 0, 0, 15, 0, 87, 0, 410, 204, 411, 412, + 413, 0, 0, 2, 0, 66, 0, 67, 68, 69, 70, 71, 2, 0, 0, 0, 3, 4, 0, 0, 0, 8, 9, 5, 6, 7, 10, 11, 12, 13, 8, 9, 15, 0, 0, 10, 11, + 12, 13, 0, 0, 15, 0, 0, 0, 66, 0, 67, 68, 69, 70, 71, 0, 0, 24, 0, 67, 68, 69, 70, 71, 2, 0, 0, 0, 3, 4, 251, 252, 253, 254, 255, 5, 6, + 7, 0, 0, 0, 0, 8, 9, 0, 0, 0, 10, 11, 12, 269, 0, 0, 15, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 0, 66, 0, 270, 271, 272, 273, 274, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 150, 151, 0, 0, 0, 0, 153, 154, 155, 0, 432, + 137, 138, 139, 140, 141, 142, 143, 256, 257, 258, 259, 260, 139, 140, 141, 142, 143}; + +static const yytype_int16 yycheck[] = { + 38, 8, 25, 44, 37, 288, 9, 5, 84, 162, 161, 162, 91, 296, 93, 22, 95, 6, 97, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 35, 5, 5, 5, 105, 5, 42, 42, 5, + 5, 38, 112, 42, 76, 5, 34, 5, 5, 34, 5, 36, 37, 59, 38, 5, 5, 42, 5, 58, 210, 211, 76, 38, 346, 38, 38, 38, 34, 38, 36, 37, 37, 110, 114, 153, 42, 45, 38, + 154, 38, 38, 5, 38, 34, 6, 36, 37, 37, 111, 37, 76, 42, 76, 76, 76, 76, 76, 76, 76, 76, 309, 31, 173, 33, 111, 6, 113, 5, 115, 76, 319, 34, 34, 37, 45, 118, 119, + 120, 121, 122, 123, 124, 5, 6, 22, 76, 409, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 297, 5, 6, 76, 173, 34, 5, 36, 37, 308, + 159, 308, 196, 442, 6, 6, 5, 42, 5, 172, 67, 68, 69, 70, 71, 72, 5, 34, 5, 36, 34, 5, 36, 37, 5, 332, 5, 221, 37, 338, 46, 338, 6, 35, 35, 5, 195, 34, 37, + 36, 37, 0, 79, 80, 16, 42, 281, 34, 37, 36, 37, 12, 5, 37, 76, 42, 37, 34, 37, 5, 34, 288, 289, 290, 291, 292, 298, 37, 295, 296, 77, 298, 5, 267, 381, 382, 5, 6, + 34, 76, 5, 42, 5, 5, 37, 12, 313, 34, 35, 76, 317, 37, 12, 58, 5, 322, 34, 329, 36, 60, 61, 62, 63, 64, 37, 34, 17, 36, 37, 288, 58, 22, 37, 420, 37, 42, 42, + 296, 425, 346, 12, 348, 42, 350, 34, 352, 36, 354, 16, 356, 324, 35, 359, 60, 61, 62, 63, 64, 42, 42, 60, 61, 62, 63, 64, 16, 12, 35, 307, 376, 42, 42, 35, 34, 34, 36, + 36, 320, 321, 42, 5, 6, 58, 34, 35, 34, 35, 346, 60, 61, 62, 63, 64, 148, 149, 482, 42, 356, 42, 42, 42, 42, 409, 410, 411, 412, 413, 42, 415, 34, 17, 36, 37, 37, 60, + 61, 62, 63, 64, 358, 84, 395, 5, 6, 431, 89, 34, 91, 371, 93, 6, 95, 6, 97, 5, 442, 42, 444, 42, 446, 17, 448, 38, 450, 76, 79, 453, 6, 35, 58, 409, 34, 6, 36, + 37, 35, 60, 61, 62, 63, 64, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 16, 442, 35, 6, 429, 430, 38, 153, 154, 56, 466, + 4, 58, 5, 38, 5, 6, 6, 34, 35, 36, 480, 76, 5, 6, 3, 42, 58, 484, 485, 34, 452, 5, 458, 455, 5, 5, 493, 16, 34, 16, 12, 20, 21, 34, 6, 36, 37, 504, 27, + 28, 29, 34, 38, 36, 37, 34, 35, 34, 35, 36, 39, 40, 41, 42, 43, 42, 45, 35, 47, 48, 42, 50, 51, 52, 53, 54, 55, 38, 35, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 60, 61, 62, 63, 64, 12, 6, 74, 5, 76, 77, 78, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 58, 16, 38, 36, 42, 5, 6, 58, + 17, 5, 6, 77, 34, 37, 280, 281, 5, 6, 36, 34, 35, 36, 60, 61, 62, 63, 64, 42, 38, 17, 38, 76, 298, 3, 34, 36, 36, 37, 34, 17, 36, 37, 37, 42, 37, 34, 16, + 36, 37, 376, 20, 21, 79, 37, 212, 163, 426, 27, 28, 29, 326, 327, 195, 329, 34, 35, 2, 50, 323, 39, 40, 41, 42, 43, -1, 45, -1, 47, 48, -1, 50, 51, 52, 53, 54, 55, + -1, -1, 58, 59, 60, 61, 62, 63, 64, 65, 66, -1, 3, 16, -1, -1, -1, -1, 74, -1, 76, 77, 78, -1, -1, 16, -1, -1, -1, 20, 21, 34, 35, 36, -1, -1, 27, 28, 29, + 42, -1, -1, -1, 34, 35, -1, -1, 399, 39, 40, 41, 42, 43, -1, 45, -1, 47, 48, -1, 50, 51, 52, 53, 54, 55, -1, -1, 58, 59, 60, 61, 62, 63, 64, 65, 66, 3, 16, + 60, 61, 62, 63, 64, 74, -1, 76, 77, 78, -1, 16, -1, -1, 12, 20, 21, 34, 35, 36, -1, -1, 27, 28, 29, 42, -1, -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, 43, + -1, 45, -1, 47, 48, 42, 50, 51, 52, 53, 54, 55, -1, -1, 58, 59, 60, 61, 62, 63, 64, 65, 66, 60, 61, 62, 63, 64, -1, -1, 74, -1, 76, 77, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 16, -1, 28, 29, 20, 21, 32, -1, 34, 35, 36, 27, 28, 29, 79, -1, -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, + 42, -1, -1, 45, -1, -1, -1, 79, -1, -1, -1, 12, -1, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 65, -1, -1, 79, 16, -1, -1, -1, 20, 21, -1, 12, -1, -1, 79, 27, + 28, 29, 42, -1, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, -1, -1, 45, -1, -1, 60, 61, 62, 63, 64, 42, -1, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 16, -1, + -1, -1, 20, 21, 60, 61, 62, 63, 64, 27, 28, 29, 79, 42, -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, -1, -1, 45, -1, 58, -1, 60, 61, 62, 63, 64, -1, -1, -1, + 16, 58, -1, 60, 61, 62, 63, 64, 65, -1, -1, -1, 16, -1, -1, -1, 20, 21, -1, 35, -1, -1, 79, 27, 28, 29, 42, -1, -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, + -1, -1, 45, 58, -1, 60, 61, 62, 63, 64, -1, 16, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, 16, -1, -1, -1, 20, 21, -1, -1, 35, -1, -1, 27, 28, 29, 79, 42, -1, + -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, -1, -1, 45, -1, 58, -1, 60, 61, 62, 63, 64, -1, -1, 16, -1, 58, -1, 60, 61, 62, 63, 64, 16, -1, -1, -1, 20, 21, -1, + -1, -1, 34, 35, 27, 28, 29, 39, 40, 41, 42, 34, 35, 45, -1, -1, 39, 40, 41, 42, -1, -1, 45, -1, -1, -1, 58, -1, 60, 61, 62, 63, 64, -1, -1, 58, -1, 60, 61, + 62, 63, 64, 16, -1, -1, -1, 20, 21, 60, 61, 62, 63, 64, 27, 28, 29, -1, -1, -1, -1, 34, 35, -1, -1, -1, 39, 40, 41, 42, -1, -1, 45, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, -1, 58, -1, 60, 61, 62, 63, 64, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, + 29, -1, -1, -1, -1, 34, 35, 36, -1, 38, 20, 21, 22, 23, 24, 25, 26, 60, 61, 62, 63, 64, 22, 23, 24, 25, 26}; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 3, 16, 20, 21, 27, 28, 29, 34, 35, - 39, 40, 41, 42, 43, 45, 47, 48, 50, 51, - 52, 53, 54, 55, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 74, 76, 77, 82, 83, 84, 90, - 93, 94, 97, 100, 104, 106, 107, 110, 112, 117, - 118, 119, 120, 121, 126, 127, 128, 129, 130, 34, - 60, 61, 62, 63, 64, 126, 58, 60, 61, 62, - 63, 64, 117, 119, 125, 42, 98, 99, 45, 45, - 76, 76, 117, 16, 34, 35, 42, 58, 90, 34, - 36, 34, 36, 34, 36, 34, 36, 34, 36, 42, - 0, 46, 112, 101, 16, 35, 42, 91, 96, 76, - 84, 34, 35, 34, 77, 5, 76, 128, 6, 67, - 68, 69, 70, 71, 72, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 79, 80, 5, 22, 31, 33, - 28, 29, 32, 34, 35, 36, 117, 17, 37, 5, - 38, 6, 34, 5, 76, 76, 58, 79, 121, 122, - 123, 58, 6, 34, 42, 42, 60, 61, 62, 63, - 64, 65, 87, 122, 124, 42, 124, 42, 124, 42, - 124, 42, 124, 42, 34, 35, 115, 116, 42, 88, - 58, 42, 58, 60, 61, 62, 63, 64, 86, 87, - 6, 35, 5, 78, 105, 90, 108, 117, 87, 111, - 117, 84, 117, 119, 119, 119, 119, 119, 119, 119, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 60, 61, 62, 63, 64, 60, 61, 62, 63, - 64, 127, 127, 124, 38, 122, 42, 37, 119, 42, - 60, 61, 62, 63, 64, 89, 120, 89, 98, 17, - 79, 5, 37, 37, 5, 38, 117, 16, 35, 60, - 62, 63, 64, 85, 87, 90, 34, 6, 5, 37, - 37, 37, 37, 37, 42, 125, 112, 6, 34, 5, - 76, 17, 38, 5, 38, 120, 120, 35, 91, 109, - 76, 76, 5, 79, 37, 78, 79, 79, 37, 5, - 38, 112, 6, 42, 42, 42, 42, 42, 5, 37, - 35, 121, 124, 58, 35, 76, 35, 85, 12, 87, - 12, 87, 12, 87, 12, 87, 5, 37, 6, 12, - 87, 85, 120, 60, 61, 62, 63, 64, 65, 87, - 122, 6, 38, 119, 89, 88, 35, 42, 92, 95, - 87, 6, 35, 38, 88, 117, 117, 87, 130, 112, - 56, 114, 121, 121, 122, 4, 120, 89, 58, 79, - 38, 58, 85, 38, 87, 87, 87, 87, 16, 35, - 60, 62, 63, 64, 87, 90, 103, 119, 87, 37, - 6, 117, 76, 37, 86, 34, 5, 120, 120, 76, - 76, 5, 38, 34, 38, 112, 5, 38, 121, 35, - 38, 38, 35, 85, 12, 87, 12, 87, 12, 87, - 12, 87, 6, 12, 87, 6, 102, 120, 5, 38, - 120, 92, 38, 117, 117, 87, 113, 36, 58, 58, - 17, 85, 38, 87, 87, 87, 87, 119, 87, 119, - 77, 117, 34, 37, 37, 37, 112, 36, 38, 38, - 38, 17, 76, 84, 37, 76, 120, 112, 112, 36, - 17, 78, 42, 37, 37, 37, 112 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - +static const yytype_uint8 yystos[] = { + 0, 3, 16, 20, 21, 27, 28, 29, 34, 35, 39, 40, 41, 42, 43, 45, 47, 48, 50, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 74, 76, 77, 82, 83, 84, + 90, 93, 94, 97, 100, 104, 106, 107, 110, 112, 117, 118, 119, 120, 121, 126, 127, 128, 129, 130, 34, 60, 61, 62, 63, 64, 126, 58, 60, 61, 62, 63, 64, 117, 119, 125, 42, 98, 99, + 45, 45, 76, 76, 117, 16, 34, 35, 42, 58, 90, 34, 36, 34, 36, 34, 36, 34, 36, 34, 36, 42, 0, 46, 112, 101, 16, 35, 42, 91, 96, 76, 84, 34, 35, 34, 77, 5, 76, + 128, 6, 67, 68, 69, 70, 71, 72, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 79, 80, 5, 22, 31, 33, 28, 29, 32, 34, 35, 36, + 117, 17, 37, 5, 38, 6, 34, 5, 76, 76, 58, 79, 121, 122, 123, 58, 6, 34, 42, 42, 60, 61, 62, 63, 64, 65, 87, 122, 124, 42, 124, 42, 124, 42, 124, 42, 124, 42, 34, + 35, 115, 116, 42, 88, 58, 42, 58, 60, 61, 62, 63, 64, 86, 87, 6, 35, 5, 78, 105, 90, 108, 117, 87, 111, 117, 84, 117, 119, 119, 119, 119, 119, 119, 119, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 60, 61, 62, 63, 64, 60, 61, 62, 63, 64, 127, 127, 124, 38, 122, 42, 37, 119, 42, 60, 61, 62, + 63, 64, 89, 120, 89, 98, 17, 79, 5, 37, 37, 5, 38, 117, 16, 35, 60, 62, 63, 64, 85, 87, 90, 34, 6, 5, 37, 37, 37, 37, 37, 42, 125, 112, 6, 34, 5, 76, 17, + 38, 5, 38, 120, 120, 35, 91, 109, 76, 76, 5, 79, 37, 78, 79, 79, 37, 5, 38, 112, 6, 42, 42, 42, 42, 42, 5, 37, 35, 121, 124, 58, 35, 76, 35, 85, 12, 87, 12, + 87, 12, 87, 12, 87, 5, 37, 6, 12, 87, 85, 120, 60, 61, 62, 63, 64, 65, 87, 122, 6, 38, 119, 89, 88, 35, 42, 92, 95, 87, 6, 35, 38, 88, 117, 117, 87, 130, 112, + 56, 114, 121, 121, 122, 4, 120, 89, 58, 79, 38, 58, 85, 38, 87, 87, 87, 87, 16, 35, 60, 62, 63, 64, 87, 90, 103, 119, 87, 37, 6, 117, 76, 37, 86, 34, 5, 120, 120, + 76, 76, 5, 38, 34, 38, 112, 5, 38, 121, 35, 38, 38, 35, 85, 12, 87, 12, 87, 12, 87, 12, 87, 6, 12, 87, 6, 102, 120, 5, 38, 120, 92, 38, 117, 117, 87, 113, 36, + 58, 58, 17, 85, 38, 87, 87, 87, 87, 119, 87, 119, 77, 117, 34, 37, 37, 37, 112, 36, 38, 38, 38, 17, 76, 84, 37, 76, 120, 112, 112, 36, 17, 78, 42, 37, 37, 37, 112}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab +#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) +#define YYRECOVERING( ) (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY && yylen == 1) { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE(yychar); \ + YYPOPSTACK(1); \ + goto yybackup; \ + } else { \ + yyerror(YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (YYID(0)) +#define YYTERROR 1 +#define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends @@ -1474,132 +1025,106 @@ while (YYID (0)) #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID(N)) { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + } else { \ + (Current).first_line = (Current).last_line = YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = YYRHSLOC(Rhs, 0).last_column; \ + } \ + while (YYID(0)) #endif - /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#define YY_LOCATION_PRINT(File, Loc) fprintf(File, "%d.%d-%d.%d", (Loc).first_line, (Loc).first_column, (Loc).last_line, (Loc).last_column) +#else +#define YY_LOCATION_PRINT(File, Loc) ((void)0) +#endif #endif - /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) +#define YYLEX yylex(YYLEX_PARAM) #else -# define YYLEX yylex () +#define YYLEX yylex( ) #endif /* Enable debugging if requested. */ #if YYDEBUG -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) +#ifndef YYFPRINTF +#include /* INFRINGES ON USER NAME SPACE */ +#define YYFPRINTF fprintf +#endif + +#define YYDPRINTF(Args) \ + do { \ + if (yydebug) YYFPRINTF Args; \ + } while (YYID(0)) +#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ + do { \ + if (yydebug) { \ + YYFPRINTF(stderr, "%s ", Title); \ + yy_symbol_print(stderr, Type, Value); \ + YYFPRINTF(stderr, "\n"); \ + } \ + } while (YYID(0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep) #else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; +static void yy_symbol_value_print(yyoutput, yytype, yyvaluep) FILE *yyoutput; +int yytype; +YYSTYPE const *const yyvaluep; #endif { - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } + if (!yyvaluep) return; +#ifdef YYPRINT + if (yytype < YYNTOKENS) YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep); +#else + YYUSE(yyoutput); +#endif + switch (yytype) { + default: + break; + } } - /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep) #else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; +static void yy_symbol_print(yyoutput, yytype, yyvaluep) FILE *yyoutput; +int yytype; +YYSTYPE const *const yyvaluep; #endif { if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + YYFPRINTF(yyoutput, "token %s (", yytname[yytype]); else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print(yyoutput, yytype, yyvaluep); + YYFPRINTF(yyoutput, ")"); } /*------------------------------------------------------------------. @@ -1607,81 +1132,64 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void yy_stack_print(yytype_int16 *bottom, yytype_int16 *top) #else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +static void yy_stack_print(bottom, top) yytype_int16 *bottom; +yytype_int16 *top; #endif { - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); + YYFPRINTF(stderr, "Stack now"); + for (; bottom <= top; ++bottom) YYFPRINTF(stderr, " %d", *bottom); + YYFPRINTF(stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - +#define YY_STACK_PRINT(Bottom, Top) \ + do { \ + if (yydebug) yy_stack_print((Bottom), (Top)); \ + } while (YYID(0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void yy_reduce_print(YYSTYPE *yyvsp, int yyrule) #else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; +static void yy_reduce_print(yyvsp, yyrule) YYSTYPE *yyvsp; +int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); - } + for (yyi = 0; yyi < yynrhs; yyi++) { + fprintf(stderr, " $%d = ", yyi + 1); + yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)])); + fprintf(stderr, "\n"); + } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) +#define YY_REDUCE_PRINT(Rule) \ + do { \ + if (yydebug) yy_reduce_print(yyvsp, Rule); \ + } while (YYID(0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) +#define YYDPRINTF(Args) +#define YY_SYMBOL_PRINT(Title, Type, Value, Location) +#define YY_STACK_PRINT(Bottom, Top) +#define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ - /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -1692,65 +1200,54 @@ int yydebug; evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 +#define YYMAXDEPTH 10000 #endif - - #if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else +#ifndef yystrlen +#if defined __GLIBC__ && defined _STRING_H +#define yystrlen strlen +#else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T yystrlen(const char *yystr) #else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; +static YYSIZE_T yystrlen(yystr) const char *yystr; #endif { YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; + for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } -# endif -# endif +#endif +#endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else +#ifndef yystpcpy +#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +#define yystpcpy stpcpy +#else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static char *yystpcpy(char *yydest, const char *yysrc) #else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; +static char *yystpcpy(yydest, yysrc) +char *yydest; +const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') - continue; + while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } -# endif -# endif +#endif +#endif -# ifndef yytnamerr +#ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string @@ -1758,45 +1255,36 @@ yystpcpy (yydest, yysrc) backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } +static YYSIZE_T yytnamerr(char *yyres, const char *yystr) { + if (*yystr == '"') { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) switch (*++yyp) { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes:; + } - if (! yyres) - return yystrlen (yystr); + if (!yyres) return yystrlen(yystr); - return yystpcpy (yyres, yystr) - yyres; + return yystpcpy(yyres, yystr) - yyres; } -# endif +#endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, @@ -1805,25 +1293,22 @@ yytnamerr (char *yyres, const char *yystr) copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ +static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 + else { + int yytype = YYTRANSLATE(yychar); + YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +#if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); @@ -1831,133 +1316,112 @@ yysyntax_error (char *yyresult, int yystate, int yychar) YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy(yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr(0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy(yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen(yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) return YYSIZE_MAXIMUM; + + if (yyresult) { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { + yyp += yytnamerr(yyp, yyarg[yyi++]); + yyf += 2; + } else { + yyp++; + yyf++; + } + } } + return yysize; + } } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; +static void yydestruct(yymsg, yytype, yyvaluep) const char *yymsg; +int yytype; +YYSTYPE *yyvaluep; #endif { - YYUSE (yyvaluep); + YYUSE(yyvaluep); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + if (!yymsg) yymsg = "Deleting"; + YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { + switch (yytype) { - default: - break; - } + default: + break; + } } - /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); +int yyparse(void *YYPARSE_PARAM); #else -int yyparse (); +int yyparse( ); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (void); +int yyparse(void); #else -int yyparse (); +int yyparse( ); #endif #endif /* ! YYPARSE_PARAM */ - - /* The look-ahead symbol. */ int yychar; @@ -1967,35 +1431,26 @@ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; - - /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int yyparse(void *YYPARSE_PARAM) #else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; +int yyparse(YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int yyparse(void) #else -int -yyparse () +int yyparse( ) #endif #endif { - + int yystate; int yyn; int yyresult; @@ -2028,9 +1483,7 @@ yyparse () YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; - - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; @@ -2038,17 +1491,16 @@ yyparse () action routines. */ YYSTYPE yyval; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - YYDPRINTF ((stderr, "Starting parse\n")); + YYDPRINTF((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack @@ -2060,83 +1512,71 @@ yyparse () goto yysetstate; -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: + /*------------------------------------------------------------. + | yynewstate -- Push a new state, which is found in yystate. | + `------------------------------------------------------------*/ +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: +yysetstate: *yyssp = yystate; - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + if (yyss + yystacksize - 1 <= yyssp) { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow(YY_("memory exhausted"), &yyss1, yysize * sizeof(*yyssp), &yyvs1, yysize * sizeof(*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +#else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = (union yyalloc *)YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize)); + if (!yyptr) goto yyexhaustedlab; + YYSTACK_RELOCATE(yyss); + YYSTACK_RELOCATE(yyvs); + +#undef YYSTACK_RELOCATE + if (yyss1 != yyssa) YYSTACK_FREE(yyss1); + } +#endif #endif /* no yyoverflow */ - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YYDPRINTF((stderr, "Stack size increased to %lu\n", (unsigned long int)yystacksize)); - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } + if (yyss + yystacksize - 1 <= yyssp) YYABORT; + } - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YYDPRINTF((stderr, "Entering state %d\n", yystate)); goto yybackup; @@ -2150,74 +1590,60 @@ yyparse () /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; + if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } + if (yychar == YYEMPTY) { + YYDPRINTF((stderr, "Reading a token: ")); + yychar = YYLEX; + } - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } + if (yychar <= YYEOF) { + yychar = yytoken = YYEOF; + YYDPRINTF((stderr, "Now at end of input.\n")); + } else { + yytoken = YYTRANSLATE(yychar); + YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc); + } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } + if (yyn <= 0) { + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } - if (yyn == YYFINAL) - YYACCEPT; + if (yyn == YYFINAL) YYACCEPT; /* Count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) - yyerrstatus--; + if (yyerrstatus) yyerrstatus--; /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; - /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; + if (yyn == 0) goto yyerrlab; goto yyreduce; - /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ @@ -2233,1317 +1659,1807 @@ yyparse () users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; + yyval = yyvsp[1 - yylen]; - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: + YY_REDUCE_PRINT(yyn); + switch (yyn) { + case 2: #line 339 "lg.ypp" { - if( ffapi::ff_justcompile) exit(0); - // clean FH mach 2014 - const char * magicffglut="#!ffglutdata4.1\n";// for complex and vector 3d plot - //FFCS: divert stream to FFCS - if(ThePlotStream) ffapi::fwriteinit(magicffglut,strlen(magicffglut),1,ThePlotStream); - - // <> - size_t sizestack = currentblock->size()+1024 ; // before close - - // <> - // $1+=currentblock->close(currentblock); - (yyvsp[(1) - (2)].cinst).setclose(Block::snewclose(currentblock));// Sep 2016 FH - if(verbosity>2 || ( (mpirank==0) && verbosity)) cout << " sizestack + 1024 =" << sizestack << " ( " << sizestack-1024 <<" )\n" ; - size_t lg0,lg1; - ffapi::ifchtmpdir(); // change to tmp after compile FH sep 2015 ... - int NbPtr = ShowAlloc("init execution ",lg0); // number of un delele ptr - debugstack= new vector >; - size_t stu0=storageused(); // get Storage usage - UnShowAlloc =0;// add FH for parallee - if(verbosity>2 || ( (mpirank==0) && verbosity) ) cout << endl; - { - - // <> calls [[file:../fflib/ffstack.hpp::newStack]] - - Stack stack = newStack(sizestack); - - double CPUcompile= CPUtime(); - try { - - // <> calls [[file:../fflib/AFunction.hpp::CListOfInst::eval]] - (yyvsp[(1) - (2)].cinst).eval(stack); - } - catch ( E_exception & e) { - cerr << e.what() << " , mpirank " << mpirank << endl; - return 1; } - catch( Error & err) { - cerr << err.what() << endl; - cerr << " err code " << err.errcode() << " , mpirank " << mpirank << endl; - return err.errcode(); - } - catch( ...) { cerr << "Strange catch exception ???\n"; - cerr << " at exec line " << TheCurrentLine << " , mpirank " << mpirank << endl; - return 1; - } - - if(verbosity) cout << "times: compile "<< CPUcompile-CPUcompileInit <<"s, execution " - << CPUtime()-CPUcompile <<"s, mpirank:" << mpirank << endl; - - - // <> - - deleteStack(stack); - - //debugstack.clear() - } - fingraphique(); - //FFCS: divert stream to FFCS - if(ThePlotStream) {ffapi::ff_pclose(ThePlotStream); ThePlotStream=0;} - UnShowAlloc =1; - if(debugstack) delete debugstack; - NbPtr = ShowAlloc("end execution -- ",lg1) - NbPtr; - long stu1 =storageused()-stu0 ; - - - if (verbosity && (NbPtr || (stu1>100000) )) { cout << " ######## unfreed pointers " << NbPtr - << " Nb pointer, " << lg1-lg0 << "Bytes " << " , mpirank " << mpirank << ", memory leak ="<< stu1 << endl;} - return 0;;} - break; - - case 4: + if (ffapi::ff_justcompile) exit(0); + // clean FH mach 2014 + const char *magicffglut = "#!ffglutdata4.1\n"; // for complex and vector 3d plot + // FFCS: divert stream to FFCS + if (ThePlotStream) ffapi::fwriteinit(magicffglut, strlen(magicffglut), 1, ThePlotStream); + + // <> + size_t sizestack = currentblock->size( ) + 1024; // before close + + // <> + // $1+=currentblock->close(currentblock); + (yyvsp[(1) - (2)].cinst).setclose(Block::snewclose(currentblock)); // Sep 2016 FH + if (verbosity > 2 || ((mpirank == 0) && verbosity)) cout << " sizestack + 1024 =" << sizestack << " ( " << sizestack - 1024 << " )\n"; + size_t lg0, lg1; + ffapi::ifchtmpdir( ); // change to tmp after compile FH sep 2015 ... + int NbPtr = ShowAlloc("init execution ", lg0); // number of un delele ptr + debugstack = new vector< pair< const E_Routine *, int > >; + size_t stu0 = storageused( ); // get Storage usage + UnShowAlloc = 0; // add FH for parallee + if (verbosity > 2 || ((mpirank == 0) && verbosity)) cout << endl; + { + + // <> calls [[file:../fflib/ffstack.hpp::newStack]] + + Stack stack = newStack(sizestack); + + double CPUcompile = CPUtime( ); + try { + + // <> calls [[file:../fflib/AFunction.hpp::CListOfInst::eval]] + (yyvsp[(1) - (2)].cinst).eval(stack); + } catch (E_exception &e) { + cerr << e.what( ) << " , mpirank " << mpirank << endl; + return 1; + } catch (Error &err) { + cerr << err.what( ) << endl; + cerr << " err code " << err.errcode( ) << " , mpirank " << mpirank << endl; + return err.errcode( ); + } catch (...) { + cerr << "Strange catch exception ???\n"; + cerr << " at exec line " << TheCurrentLine << " , mpirank " << mpirank << endl; + return 1; + } + + if (verbosity) cout << "times: compile " << CPUcompile - CPUcompileInit << "s, execution " << CPUtime( ) - CPUcompile << "s, mpirank:" << mpirank << endl; + + // <> + + deleteStack(stack); + + // debugstack.clear() + } + fingraphique( ); + // FFCS: divert stream to FFCS + if (ThePlotStream) { + ffapi::ff_pclose(ThePlotStream); + ThePlotStream = 0; + } + UnShowAlloc = 1; + if (debugstack) delete debugstack; + NbPtr = ShowAlloc("end execution -- ", lg1) - NbPtr; + long stu1 = storageused( ) - stu0; + + if (verbosity && (NbPtr || (stu1 > 100000))) { + cout << " ######## unfreed pointers " << NbPtr << " Nb pointer, " << lg1 - lg0 << "Bytes " << " , mpirank " << mpirank << ", memory leak =" << stu1 << endl; + } + return 0; + ; + } break; + + case 4: #line 413 "lg.ypp" - {(yyval.cinst) = (yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.cinst) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 5: + case 5: #line 414 "lg.ypp" - {(yyval.cinst) = ((yyvsp[(1) - (2)].cinst)+=(yyvsp[(2) - (2)].cexp));;} - break; + { + (yyval.cinst) = ((yyvsp[(1) - (2)].cinst) += (yyvsp[(2) - (2)].cexp)); + ; + } break; - case 6: + case 6: #line 420 "lg.ypp" - { (yyval.clist_id) = new ListOfId();;} - break; + { + (yyval.clist_id) = new ListOfId( ); + ; + } break; - case 7: + case 7: #line 421 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (1)].str)));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (1)].str))); + ; + } break; - case 8: + case 8: #line 422 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (3)].str),(yyvsp[(3) - (3)].cexp)));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].cexp))); + ; + } break; - case 9: + case 9: #line 423 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str),Find((yyvsp[(1) - (2)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str), Find((yyvsp[(1) - (2)].str)), atype< FE< double, 2 > ** >( ))); + ; + } break; - case 10: + case 10: #line 424 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str),Find((yyvsp[(1) - (3)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str), Find((yyvsp[(1) - (3)].str)), atype< FE< double, 2 > ** >( ), true)); + ; + } break; - case 11: + case 11: #line 425 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str),Find((yyvsp[(1) - (2)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str), Find((yyvsp[(1) - (2)].str)), atype< FE< double, 3 > ** >( ))); + ; + } break; - case 12: + case 12: #line 426 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str),Find((yyvsp[(1) - (3)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str), Find((yyvsp[(1) - (3)].str)), atype< FE< double, 3 > ** >( ), true)); + ; + } break; - case 13: + case 13: #line 427 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str),Find((yyvsp[(1) - (2)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str), Find((yyvsp[(1) - (2)].str)), atype< FE< double, 4 > ** >( ))); + ; + } break; - case 14: + case 14: #line 428 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str),Find((yyvsp[(1) - (3)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str), Find((yyvsp[(1) - (3)].str)), atype< FE< double, 4 > ** >( ), true)); + ; + } break; - case 15: + case 15: #line 429 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str),Find((yyvsp[(1) - (2)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str), Find((yyvsp[(1) - (2)].str)), atype< FE< double, 5 > ** >( ))); + ; + } break; - case 16: + case 16: #line 430 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str),Find((yyvsp[(1) - (3)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str), Find((yyvsp[(1) - (3)].str)), atype< FE< double, 5 > ** >( ), true)); + ; + } break; - case 17: + case 17: #line 431 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str),C_F0(),(yyvsp[(1) - (2)].type)->right()));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (2)].str), C_F0( ), (yyvsp[(1) - (2)].type)->right( ))); + ; + } break; - case 18: + case 18: #line 432 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str),C_F0(),(yyvsp[(1) - (3)].type),true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str), C_F0( ), (yyvsp[(1) - (3)].type), true)); + ; + } break; - case 19: + case 19: #line 433 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (3)].clist_id)));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(2) - (3)].clist_id))); + ; + } break; - case 20: + case 20: #line 434 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].clist_id),true,true));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].clist_id), true, true)); + ; + } break; - case 21: + case 21: #line 435 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (4)].clist_id),true,false));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (4)].clist_id), true, false)); + ; + } break; - case 22: + case 22: #line 436 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (3)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (3)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str))); + ; + } break; - case 23: + case 23: #line 437 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (5)].clist_id)));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (5)].clist_id))); + ; + } break; - case 24: + case 24: #line 438 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (6)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (6)].clist_id),false,true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (6)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (6)].clist_id), false, true)); + ; + } break; - case 25: + case 25: #line 439 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (7)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (7)].clist_id),true,true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (7)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (7)].clist_id), true, true)); + ; + } break; - case 26: + case 26: #line 440 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (6)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (6)].clist_id),true,false));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (6)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (6)].clist_id), true, false)); + ; + } break; - case 27: + case 27: #line 441 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].str),(yyvsp[(5) - (5)].cexp)));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].cexp))); + ; + } break; - case 28: + case 28: #line 442 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str),Find((yyvsp[(3) - (4)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str), Find((yyvsp[(3) - (4)].str)), atype< FE< double, 2 > ** >( ))); + ; + } break; - case 29: + case 29: #line 443 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str),Find((yyvsp[(3) - (5)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str), Find((yyvsp[(3) - (5)].str)), atype< FE< double, 2 > ** >( ), true)); + ; + } break; - case 30: + case 30: #line 444 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str),Find((yyvsp[(3) - (4)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str), Find((yyvsp[(3) - (4)].str)), atype< FE< double, 3 > ** >( ))); + ; + } break; - case 31: + case 31: #line 445 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str),Find((yyvsp[(3) - (5)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str), Find((yyvsp[(3) - (5)].str)), atype< FE< double, 3 > ** >( ), true)); + ; + } break; - case 32: + case 32: #line 446 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str),Find((yyvsp[(3) - (4)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str), Find((yyvsp[(3) - (4)].str)), atype< FE< double, 4 > ** >( ))); + ; + } break; - case 33: + case 33: #line 447 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str),Find((yyvsp[(3) - (5)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str), Find((yyvsp[(3) - (5)].str)), atype< FE< double, 4 > ** >( ), true)); + ; + } break; - case 34: + case 34: #line 448 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str),Find((yyvsp[(3) - (4)].str)),atype **>()));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str), Find((yyvsp[(3) - (4)].str)), atype< FE< double, 5 > ** >( ))); + ; + } break; - case 35: + case 35: #line 449 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str),Find((yyvsp[(3) - (5)].str)),atype **>(),true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str), Find((yyvsp[(3) - (5)].str)), atype< FE< double, 5 > ** >( ), true)); + ; + } break; - case 36: + case 36: #line 450 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str),C_F0(),(yyvsp[(3) - (4)].type)->right()));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (4)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(4) - (4)].str), C_F0( ), (yyvsp[(3) - (4)].type)->right( ))); + ; + } break; - case 37: + case 37: #line 451 "lg.ypp" - { (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str),C_F0(),(yyvsp[(3) - (5)].type),true));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (5)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str), C_F0( ), (yyvsp[(3) - (5)].type), true)); + ; + } break; - case 38: + case 38: #line 454 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (1)].str)));;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (1)].str))); + ; + } break; - case 39: + case 39: #line 455 "lg.ypp" - { (yyval.clist_id)=(yyvsp[(1) - (3)].clist_id) ; (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.clist_id) = (yyvsp[(1) - (3)].clist_id); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str))); + ; + } break; - case 46: + case 46: #line 463 "lg.ypp" - {(yyval.cexp)=currentblock->NewVar((yyvsp[(1) - (1)].str),dcltype);;} - break; + { + (yyval.cexp) = currentblock->NewVar< LocalVariable >((yyvsp[(1) - (1)].str), dcltype); + ; + } break; - case 47: + case 47: #line 464 "lg.ypp" - {(yyval.cexp)=currentblock->NewVar((yyvsp[(1) - (3)].str),dcltype,(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = currentblock->NewVar< LocalVariable >((yyvsp[(1) - (3)].str), dcltype, (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 48: + case 48: #line 465 "lg.ypp" - {(yyval.cexp)=currentblock->NewVar((yyvsp[(1) - (4)].str),dcltype,(yyvsp[(3) - (4)].args));(yyvsp[(3) - (4)].args).destroy();;} - break; + { + (yyval.cexp) = currentblock->NewVar< LocalVariable >((yyvsp[(1) - (4)].str), dcltype, (yyvsp[(3) - (4)].args)); + (yyvsp[(3) - (4)].args).destroy( ); + ; + } break; - case 49: + case 49: #line 466 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 50: + case 50: #line 472 "lg.ypp" - { (yyval.args)=(yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.args) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 51: + case 51: #line 473 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (2)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (2)].str)); + ; + } break; - case 52: + case 52: #line 474 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (2)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (2)].str)); + ; + } break; - case 53: + case 53: #line 475 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (2)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (2)].str)); + ; + } break; - case 54: + case 54: #line 476 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (2)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (2)].str)); + ; + } break; - case 55: + case 55: #line 477 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (2)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (2)].str)); + ; + } break; - case 56: + case 56: #line 478 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 57: + case 57: #line 479 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 58: + case 58: #line 480 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 59: + case 59: #line 481 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 60: + case 60: #line 482 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 61: + case 61: #line 483 "lg.ypp" - { (yyval.args)=make_pair((const char *) (yyvsp[(1) - (3)].str),(C_F0) (yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.args) = make_pair< const char *, const C_F0 >((const char *)(yyvsp[(1) - (3)].str), (C_F0)(yyvsp[(3) - (3)].cexp)); + ; + } break; - case 62: + case 62: #line 484 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].args));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].args)); + ; + } break; - case 64: + case 64: #line 490 "lg.ypp" - {(yyval.type)=TypeArray((yyvsp[(1) - (4)].type),(yyvsp[(3) - (4)].type));;} - break; + { + (yyval.type) = TypeArray((yyvsp[(1) - (4)].type), (yyvsp[(3) - (4)].type)); + ; + } break; - case 65: + case 65: #line 491 "lg.ypp" - {(yyval.type)=TypeArray(TypeArray((yyvsp[(1) - (7)].type),(yyvsp[(3) - (7)].type)),(yyvsp[(6) - (7)].type));;} - break; + { + (yyval.type) = TypeArray(TypeArray((yyvsp[(1) - (7)].type), (yyvsp[(3) - (7)].type)), (yyvsp[(6) - (7)].type)); + ; + } break; - case 66: + case 66: #line 492 "lg.ypp" - {(yyval.type)=TypeArray((yyvsp[(1) - (6)].type),(yyvsp[(3) - (6)].type),(yyvsp[(5) - (6)].type));;} - break; + { + (yyval.type) = TypeArray((yyvsp[(1) - (6)].type), (yyvsp[(3) - (6)].type), (yyvsp[(5) - (6)].type)); + ; + } break; - case 67: + case 67: #line 493 "lg.ypp" - {(yyval.type)=TypeArray(TypeArray((yyvsp[(1) - (9)].type),(yyvsp[(3) - (9)].type),(yyvsp[(5) - (9)].type)),(yyvsp[(8) - (9)].type));;} - break; + { + (yyval.type) = TypeArray(TypeArray((yyvsp[(1) - (9)].type), (yyvsp[(3) - (9)].type), (yyvsp[(5) - (9)].type)), (yyvsp[(8) - (9)].type)); + ; + } break; - case 68: + case 68: #line 494 "lg.ypp" - {(yyval.type)=TypeTemplate((yyvsp[(1) - (4)].type),(yyvsp[(3) - (4)].type));;} - break; + { + (yyval.type) = TypeTemplate((yyvsp[(1) - (4)].type), (yyvsp[(3) - (4)].type)); + ; + } break; - case 69: + case 69: #line 495 "lg.ypp" - {(yyval.type)=TypeArray(TypeTemplate((yyvsp[(1) - (7)].type),(yyvsp[(3) - (7)].type)),(yyvsp[(6) - (7)].type));;} - break; + { + (yyval.type) = TypeArray(TypeTemplate((yyvsp[(1) - (7)].type), (yyvsp[(3) - (7)].type)), (yyvsp[(6) - (7)].type)); + ; + } break; - case 70: + case 70: #line 496 "lg.ypp" - {(yyval.type)=TypeArray(TypeTemplate((yyvsp[(1) - (9)].type),(yyvsp[(3) - (9)].type)),(yyvsp[(6) - (9)].type),(yyvsp[(8) - (9)].type));;} - break; + { + (yyval.type) = TypeArray(TypeTemplate((yyvsp[(1) - (9)].type), (yyvsp[(3) - (9)].type)), (yyvsp[(6) - (9)].type), (yyvsp[(8) - (9)].type)); + ; + } break; - case 71: + case 71: #line 500 "lg.ypp" - { (yyval.cexp) = NewFEvariable((yyvsp[(1) - (1)].str),currentblock,fespacetype,fespacecomplex,fespacedim); ;} - break; + { + (yyval.cexp) = NewFEvariable((yyvsp[(1) - (1)].str), currentblock, fespacetype, fespacecomplex, fespacedim); + ; + } break; - case 72: + case 72: #line 501 "lg.ypp" - { (yyval.cexp) = NewFEarray((yyvsp[(1) - (4)].str),currentblock,fespacetype,(yyvsp[(3) - (4)].cexp),fespacecomplex,fespacedim); ;} - break; + { + (yyval.cexp) = NewFEarray((yyvsp[(1) - (4)].str), currentblock, fespacetype, (yyvsp[(3) - (4)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 73: + case 73: #line 502 "lg.ypp" - { (yyval.cexp) = NewFEvariable((yyvsp[(1) - (3)].str),currentblock,fespacetype,(yyvsp[(3) - (3)].cexp),fespacecomplex,fespacedim);;} - break; + { + (yyval.cexp) = NewFEvariable((yyvsp[(1) - (3)].str), currentblock, fespacetype, (yyvsp[(3) - (3)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 74: + case 74: #line 503 "lg.ypp" - { (yyval.cexp) = NewFEvariable((yyvsp[(2) - (3)].clist_id),currentblock,fespacetype,fespacecomplex,fespacedim);;} - break; + { + (yyval.cexp) = NewFEvariable((yyvsp[(2) - (3)].clist_id), currentblock, fespacetype, fespacecomplex, fespacedim); + ; + } break; - case 75: + case 75: #line 504 "lg.ypp" - { (yyval.cexp) = NewFEarray((yyvsp[(2) - (6)].clist_id),currentblock,fespacetype,(yyvsp[(5) - (6)].cexp),fespacecomplex,fespacedim);;} - break; + { + (yyval.cexp) = NewFEarray((yyvsp[(2) - (6)].clist_id), currentblock, fespacetype, (yyvsp[(5) - (6)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 76: + case 76: #line 505 "lg.ypp" - { (yyval.cexp) = NewFEvariable((yyvsp[(2) - (5)].clist_id),currentblock,fespacetype,(yyvsp[(5) - (5)].cexp),fespacecomplex,fespacedim);;} - break; + { + (yyval.cexp) = NewFEvariable((yyvsp[(2) - (5)].clist_id), currentblock, fespacetype, (yyvsp[(5) - (5)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 77: + case 77: #line 509 "lg.ypp" - { (yyval.cexp) = NewFEarray((yyvsp[(1) - (4)].str),currentblock,fespacetype,(yyvsp[(3) - (4)].cexp),fespacecomplex,fespacedim); ;} - break; + { + (yyval.cexp) = NewFEarray((yyvsp[(1) - (4)].str), currentblock, fespacetype, (yyvsp[(3) - (4)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 78: + case 78: #line 510 "lg.ypp" - { (yyval.cexp) = NewFEarray((yyvsp[(2) - (6)].clist_id),currentblock,fespacetype,(yyvsp[(5) - (6)].cexp),fespacecomplex,fespacedim);;} - break; + { + (yyval.cexp) = NewFEarray((yyvsp[(2) - (6)].clist_id), currentblock, fespacetype, (yyvsp[(5) - (6)].cexp), fespacecomplex, fespacedim); + ; + } break; - case 79: + case 79: #line 515 "lg.ypp" - { fespacedim=2;;} - break; + { + fespacedim = 2; + ; + } break; - case 80: + case 80: #line 516 "lg.ypp" - { fespacedim=1;;} - break; + { + fespacedim = 1; + ; + } break; - case 81: + case 81: #line 517 "lg.ypp" - { fespacedim=3;;} - break; + { + fespacedim = 3; + ; + } break; - case 82: + case 82: #line 518 "lg.ypp" - { fespacedim=4;;} - break; + { + fespacedim = 4; + ; + } break; - case 83: + case 83: #line 519 "lg.ypp" - { fespacedim=5;;} - break; + { + fespacedim = 5; + ; + } break; - case 84: + case 84: #line 520 "lg.ypp" - { fespacedim=6;;} - break; + { + fespacedim = 6; + ; + } break; - case 85: + case 85: #line 521 "lg.ypp" - { fespacedim=7;;} - break; + { + fespacedim = 7; + ; + } break; - case 86: + case 86: #line 524 "lg.ypp" - {fespacecomplex=false; fespacetype = Find((yyvsp[(1) - (1)].str));;} - break; + { + fespacecomplex = false; + fespacetype = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 87: + case 87: #line 525 "lg.ypp" { - if ((yyvsp[(3) - (4)].type) != typevarreal && (yyvsp[(3) - (4)].type) != typevarcomplex) lgerror (" type of finite element or "); - fespacecomplex=((yyvsp[(3) - (4)].type)==typevarcomplex); - fespacetype = Find((yyvsp[(1) - (4)].str));;} - break; + if ((yyvsp[(3) - (4)].type) != typevarreal && (yyvsp[(3) - (4)].type) != typevarcomplex) lgerror(" type of finite element or "); + fespacecomplex = ((yyvsp[(3) - (4)].type) == typevarcomplex); + fespacetype = Find((yyvsp[(1) - (4)].str)); + ; + } break; - case 88: + case 88: #line 530 "lg.ypp" - { (yyval.cexp) = (yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 89: + case 89: #line 531 "lg.ypp" - { (yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 90: + case 90: #line 533 "lg.ypp" - { (yyval.cexp) = (yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 91: + case 91: #line 534 "lg.ypp" - { (yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 92: + case 92: #line 536 "lg.ypp" - { (yyval.cexp)=0; (yyval.cexp) = (yyvsp[(2) - (2)].cexp);;} - break; + { + (yyval.cexp) = 0; + (yyval.cexp) = (yyvsp[(2) - (2)].cexp); + ; + } break; - case 93: + case 93: #line 537 "lg.ypp" - { (yyval.cexp)=0; (yyval.cexp) = (yyvsp[(5) - (5)].cexp);;} - break; + { + (yyval.cexp) = 0; + (yyval.cexp) = (yyvsp[(5) - (5)].cexp); + ; + } break; - case 94: + case 94: #line 540 "lg.ypp" - {(yyval.cexp)=currentblock->NewVar>((yyvsp[(1) - (4)].str),typeFESpace((yyvsp[(3) - (4)].args)),(yyvsp[(3) - (4)].args),dimFESpaceImage((yyvsp[(3) - (4)].args))); - (yyvsp[(3) - (4)].args).destroy(); ;} - break; + { + (yyval.cexp) = + currentblock->NewVar< LocalVariableFES, KN< size_t > >((yyvsp[(1) - (4)].str), typeFESpace((yyvsp[(3) - (4)].args)), (yyvsp[(3) - (4)].args), dimFESpaceImage((yyvsp[(3) - (4)].args))); + (yyvsp[(3) - (4)].args).destroy( ); + ; + } break; - case 95: + case 95: #line 543 "lg.ypp" - {(yyval.cexp)=currentblock->NewVar>((yyvsp[(1) - (3)].str),typeFESpace((yyvsp[(3) - (3)].args)),(yyvsp[(3) - (3)].args),dimFESpaceImage((yyvsp[(3) - (3)].args))); - (yyvsp[(3) - (3)].args).destroy(); ;} - break; + { + (yyval.cexp) = + currentblock->NewVar< LocalVariableFES, KN< size_t > >((yyvsp[(1) - (3)].str), typeFESpace((yyvsp[(3) - (3)].args)), (yyvsp[(3) - (3)].args), dimFESpaceImage((yyvsp[(3) - (3)].args))); + (yyvsp[(3) - (3)].args).destroy( ); + ; + } break; - case 97: + case 97: #line 548 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 98: + case 98: #line 551 "lg.ypp" - {dcltype=(yyvsp[(1) - (1)].type);;} - break; + { + dcltype = (yyvsp[(1) - (1)].type); + ; + } break; - case 99: + case 99: #line 551 "lg.ypp" - {(yyval.cexp)=(yyvsp[(3) - (4)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(3) - (4)].cexp); + ; + } break; - case 100: + case 100: #line 552 "lg.ypp" - {(yyval.cexp)=(yyvsp[(2) - (3)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(2) - (3)].cexp); + ; + } break; - case 101: + case 101: #line 553 "lg.ypp" - { (yyval.cexp)=(yyvsp[(1) - (2)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (2)].cexp); + ; + } break; - case 102: + case 102: #line 554 "lg.ypp" - {(yyval.cexp)=currentblock->NewID((yyvsp[(1) - (5)].type),(yyvsp[(2) - (5)].str),(yyvsp[(4) - (5)].cexp));;} - break; + { + (yyval.cexp) = currentblock->NewID((yyvsp[(1) - (5)].type), (yyvsp[(2) - (5)].str), (yyvsp[(4) - (5)].cexp)); + ; + } break; - case 103: + case 103: #line 556 "lg.ypp" - { /* use the stack to store the prev return type*/ - assert(kkembtype+1right(); - routineinblock[kkembtype] = currentblock; - (yyvsp[(5) - (6)].routine)=new Routine((yyvsp[(1) - (6)].type),(yyvsp[(2) - (6)].type)->right(),(yyvsp[(3) - (6)].str),(yyvsp[(5) - (6)].clist_id),currentblock); - // routineinblock[kkembtype]->Add($3,"(",$5); //pas recursif pour l'instanat test FH 27 dec 2008 - // cout << " \n after new routine \n " << endl; - ;} - break; - - case 104: + { /* use the stack to store the prev return type*/ + assert(kkembtype + 1 < nbembtype); + rettype[++kkembtype] = (yyvsp[(2) - (6)].type)->right( ); + routineinblock[kkembtype] = currentblock; + (yyvsp[(5) - (6)].routine) = new Routine((yyvsp[(1) - (6)].type), (yyvsp[(2) - (6)].type)->right( ), (yyvsp[(3) - (6)].str), (yyvsp[(5) - (6)].clist_id), currentblock); + // routineinblock[kkembtype]->Add($3,"(",$5); //pas recursif pour l'instanat test FH 27 dec 2008 + // cout << " \n after new routine \n " << endl; + ; + } break; + + case 104: #line 565 "lg.ypp" - { currentblock=(yyvsp[(5) - (10)].routine)->Set((yyvsp[(9) - (10)].cinst)); - currentblock->Add((yyvsp[(3) - (10)].str),"(",(yyvsp[(5) - (10)].routine)); //pas recursif pour l'instant test FH 27 dec 2008 - kkembtype--; - (yyval.cexp)=0; + { + currentblock = (yyvsp[(5) - (10)].routine)->Set((yyvsp[(9) - (10)].cinst)); + currentblock->Add((yyvsp[(3) - (10)].str), "(", (yyvsp[(5) - (10)].routine)); // pas recursif pour l'instant test FH 27 dec 2008 + kkembtype--; + (yyval.cexp) = 0; - ;} - break; + ; + } break; - case 105: + case 105: #line 572 "lg.ypp" - {Block::open(currentblock); (yyvsp[(1) - (5)].type)->SetArgs((yyvsp[(4) - (5)].clist_id));;} - break; + { + Block::open(currentblock); + (yyvsp[(1) - (5)].type)->SetArgs((yyvsp[(4) - (5)].clist_id)); + ; + } break; - case 106: + case 106: #line 574 "lg.ypp" - { //$$=currentblock->close(currentblock); - (yyval.cinst).setclose(Block::snewclose(currentblock));// Sep 2016 FH. - (yyval.cexp)=currentblock->NewID((yyvsp[(1) - (9)].type),(yyvsp[(2) - (9)].str),(yyvsp[(8) - (9)].cexp),*(yyvsp[(4) - (9)].clist_id)); - delete (yyvsp[(4) - (9)].clist_id); // FH 23032005 - ;} - break; - - case 107: + { //$$=currentblock->close(currentblock); + (yyval.cinst).setclose(Block::snewclose(currentblock)); // Sep 2016 FH. + (yyval.cexp) = currentblock->NewID((yyvsp[(1) - (9)].type), (yyvsp[(2) - (9)].str), (yyvsp[(8) - (9)].cexp), *(yyvsp[(4) - (9)].clist_id)); + delete (yyvsp[(4) - (9)].clist_id); // FH 23032005 + ; + } break; + + case 107: #line 581 "lg.ypp" - { Block::open(currentblock);;} - break; + { + Block::open(currentblock); + ; + } break; - case 108: + case 108: #line 582 "lg.ypp" - { (yyval.endb)=Block::snewclose(currentblock); -// $$=currentblock->close(currentblock); -;} - break; + { + (yyval.endb) = Block::snewclose(currentblock); + // $$=currentblock->close(currentblock); + ; + } break; - case 109: + case 109: #line 586 "lg.ypp" - {ffassert(inloopcountpush_back(UnId((yyvsp[(1) - (1)].str)));Block::open(currentblock); ;} - break; + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (1)].str))); + Block::open(currentblock); + ; + } break; - case 115: + case 115: #line 598 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (3)].str)));(yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str)));Block::open(currentblock); ;} - break; - - case 116: + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (3)].str))); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (3)].str))); + Block::open(currentblock); + ; + } break; + + case 116: #line 599 "lg.ypp" - { (yyval.clist_id) = new ListOfId(); (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (5)].str)));(yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].str)));(yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str)));Block::open(currentblock); ;} - break; - - case 117: + { + (yyval.clist_id) = new ListOfId( ); + (yyval.clist_id)->push_back(UnId((yyvsp[(1) - (5)].str))); + (yyval.clist_id)->push_back(UnId((yyvsp[(3) - (5)].str))); + (yyval.clist_id)->push_back(UnId((yyvsp[(5) - (5)].str))); + Block::open(currentblock); + ; + } break; + + case 117: #line 601 "lg.ypp" - {(yyval.cexp)=0;;} - break; + { + (yyval.cexp) = 0; + ; + } break; - case 118: + case 118: #line 602 "lg.ypp" - {zzzfff->input((yyvsp[(2) - (2)].str));(yyval.cexp)= 0; ;} - break; + { + zzzfff->input((yyvsp[(2) - (2)].str)); + (yyval.cexp) = 0; + ; + } break; - case 119: + case 119: #line 603 "lg.ypp" - {load((yyvsp[(2) - (2)].str));(yyval.cexp)= 0; ;} - break; + { + load((yyvsp[(2) - (2)].str)); + (yyval.cexp) = 0; + ; + } break; - case 120: + case 120: #line 604 "lg.ypp" - {(yyval.cexp)=Try((yyvsp[(3) - (5)].cinst),currentblock->close(currentblock,(yyvsp[(5) - (5)].cexp)));;} - break; + { + (yyval.cexp) = Try((yyvsp[(3) - (5)].cinst), currentblock->close(currentblock, (yyvsp[(5) - (5)].cexp))); + ; + } break; - case 121: + case 121: #line 605 "lg.ypp" - {(yyval.cexp)=(yyvsp[(1) - (2)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (2)].cexp); + ; + } break; - case 122: + case 122: #line 606 "lg.ypp" - {(yyval.cexp)=(yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 123: + case 123: #line 608 "lg.ypp" - {(yyvsp[(5) - (6)].cexp)=ForAll(currentblock,(yyvsp[(3) - (6)].clist_id),(yyvsp[(5) - (6)].cexp));;} - break; + { + (yyvsp[(5) - (6)].cexp) = ForAll(currentblock, (yyvsp[(3) - (6)].clist_id), (yyvsp[(5) - (6)].cexp)); + ; + } break; - case 124: + case 124: #line 609 "lg.ypp" { - inloopcount--; - (yyval.cexp)=Block::close(currentblock,C_F0(ForAll((yyvsp[(5) - (8)].cexp),(yyvsp[(8) - (8)].cexp)))); - ;} - break; + inloopcount--; + (yyval.cexp) = Block::close(currentblock, C_F0(ForAll((yyvsp[(5) - (8)].cexp), (yyvsp[(8) - (8)].cexp)))); + ; + } break; - case 125: + case 125: #line 613 "lg.ypp" - {inloopcount--; (yyval.cexp)=For((yyvsp[(3) - (9)].cexp),(yyvsp[(5) - (9)].cexp),(yyvsp[(7) - (9)].cexp),(yyvsp[(9) - (9)].cexp));;} - break; + { + inloopcount--; + (yyval.cexp) = For((yyvsp[(3) - (9)].cexp), (yyvsp[(5) - (9)].cexp), (yyvsp[(7) - (9)].cexp), (yyvsp[(9) - (9)].cexp)); + ; + } break; - case 126: + case 126: #line 615 "lg.ypp" - {inloopcount--; - (yyval.cexp)=Block::close(currentblock,C_F0(For((yyvsp[(3) - (9)].cexp),(yyvsp[(5) - (9)].cexp),(yyvsp[(7) - (9)].cexp),(yyvsp[(9) - (9)].cexp)))); - ;} - break; + { + inloopcount--; + (yyval.cexp) = Block::close(currentblock, C_F0(For((yyvsp[(3) - (9)].cexp), (yyvsp[(5) - (9)].cexp), (yyvsp[(7) - (9)].cexp), (yyvsp[(9) - (9)].cexp)))); + ; + } break; - case 127: + case 127: #line 618 "lg.ypp" - {inloopcount--;(yyval.cexp)=While((yyvsp[(3) - (5)].cexp),(yyvsp[(5) - (5)].cexp));;} - break; + { + inloopcount--; + (yyval.cexp) = While((yyvsp[(3) - (5)].cexp), (yyvsp[(5) - (5)].cexp)); + ; + } break; - case 128: + case 128: #line 619 "lg.ypp" - {(yyval.cexp)=FIf((yyvsp[(3) - (5)].cexp),(yyvsp[(5) - (5)].cexp));;} - break; + { + (yyval.cexp) = FIf((yyvsp[(3) - (5)].cexp), (yyvsp[(5) - (5)].cexp)); + ; + } break; - case 129: + case 129: #line 620 "lg.ypp" - {(yyval.cexp)=FIf((yyvsp[(3) - (7)].cexp),(yyvsp[(5) - (7)].cexp),(yyvsp[(7) - (7)].cexp));;} - break; + { + (yyval.cexp) = FIf((yyvsp[(3) - (7)].cexp), (yyvsp[(5) - (7)].cexp), (yyvsp[(7) - (7)].cexp)); + ; + } break; - case 130: + case 130: #line 621 "lg.ypp" { /* [[begin:]] [[end:]] */ - (yyvsp[(2) - (3)].cinst).setclose((yyvsp[(3) - (3)].endb)); - (yyval.cexp)=(yyvsp[(2) - (3)].cinst); - // $$=C_F0(new E_block($2,$3),atype()); - ;} - break; + (yyvsp[(2) - (3)].cinst).setclose((yyvsp[(3) - (3)].endb)); + (yyval.cexp) = (yyvsp[(2) - (3)].cinst); + // $$=C_F0(new E_block($2,$3),atype()); + ; + } break; - case 131: + case 131: #line 626 "lg.ypp" { /* <> */ - (yyval.cexp)=0;currentblock->NewID(atype(),(yyvsp[(2) - (3)].str),C_F0(TheOperators,"[border]",(yyvsp[(3) - (3)].args)));;} - break; + (yyval.cexp) = 0; + currentblock->NewID(atype< const E_Border * >( ), (yyvsp[(2) - (3)].str), C_F0(TheOperators, "[border]", (yyvsp[(3) - (3)].args))); + ; + } break; - case 132: + case 132: #line 628 "lg.ypp" { - (yyval.cexp)=0;currentblock->NewID(atype(),(yyvsp[(2) - (6)].str),C_F0(TheOperators,"[border]",(yyvsp[(4) - (6)].args)));;} - break; + (yyval.cexp) = 0; + currentblock->NewID(atype< const E_Border * >( ), (yyvsp[(2) - (6)].str), C_F0(TheOperators, "[border]", (yyvsp[(4) - (6)].args))); + ; + } break; - case 133: + case 133: #line 631 "lg.ypp" { - if(inloopcount) - (yyval.cexp)= C_F0(new E_throw(E_exception::e_break),atype()); - else lgerror("break not in loop");;} - break; + if (inloopcount) + (yyval.cexp) = C_F0(new E_throw(E_exception::e_break), atype< void >( )); + else + lgerror("break not in loop"); + ; + } break; - case 134: + case 134: #line 635 "lg.ypp" { - if(inloopcount) - (yyval.cexp)= C_F0(new E_throw(E_exception::e_continue),atype()) ; - else lgerror("continue not in loop");;} - break; + if (inloopcount) + (yyval.cexp) = C_F0(new E_throw(E_exception::e_continue), atype< void >( )); + else + lgerror("continue not in loop"); + ; + } break; - case 135: + case 135: #line 639 "lg.ypp" { - if (kkembtype>=0) - (yyval.cexp)= C_F0(new E_throw(E_exception::e_return,(rettype[kkembtype]->CastTo((yyvsp[(2) - (3)].cexp))).OnReturn()) ,atype()); - else lgerror(" return not in routine ");;} - break; + if (kkembtype >= 0) + (yyval.cexp) = C_F0(new E_throw(E_exception::e_return, (rettype[kkembtype]->CastTo((yyvsp[(2) - (3)].cexp))).OnReturn( )), atype< void >( )); + else + lgerror(" return not in routine "); + ; + } break; - case 136: + case 136: #line 646 "lg.ypp" - {(yyval.cexp) = (yyvsp[(7) - (7)].cexp); ;} - break; + { + (yyval.cexp) = (yyvsp[(7) - (7)].cexp); + ; + } break; - case 137: + case 137: #line 649 "lg.ypp" { - Block::open(currentblock); - (yyval.args) = currentblock->NewVar((yyvsp[(2) - (7)].str),atype()); - (yyval.args)+= (yyvsp[(4) - (7)].cexp); - (yyval.args)+= (yyvsp[(6) - (7)].cexp); - (yyval.args)+= currentblock->NewVar("IndexBorder",atype());;} - break; - - case 138: + Block::open(currentblock); + (yyval.args) = currentblock->NewVar< LocalVariable >((yyvsp[(2) - (7)].str), atype< double * >( )); + (yyval.args) += (yyvsp[(4) - (7)].cexp); + (yyval.args) += (yyvsp[(6) - (7)].cexp); + (yyval.args) += currentblock->NewVar< LocalVariable >("IndexBorder", atype< long * >( )); + ; + } break; + + case 138: #line 657 "lg.ypp" { - Block::open(currentblock); - (yyval.args) = currentblock->NewVar((yyvsp[(2) - (9)].str),atype()); - (yyval.args)+= (yyvsp[(4) - (9)].cexp); - (yyval.args)+= (yyvsp[(6) - (9)].cexp); - (yyval.args)+= currentblock->NewVar((yyvsp[(8) - (9)].str),atype());;} - break; - - case 139: + Block::open(currentblock); + (yyval.args) = currentblock->NewVar< LocalVariable >((yyvsp[(2) - (9)].str), atype< double * >( )); + (yyval.args) += (yyvsp[(4) - (9)].cexp); + (yyval.args) += (yyvsp[(6) - (9)].cexp); + (yyval.args) += currentblock->NewVar< LocalVariable >((yyvsp[(8) - (9)].str), atype< long * >( )); + ; + } break; + + case 139: #line 665 "lg.ypp" { - //currentblock->close(currentblock;); - (yyval.args) = ((yyvsp[(1) - (2)].args) += currentblock->close(currentblock,(yyvsp[(2) - (2)].cexp))); - ;} - break; + // currentblock->close(currentblock;); + (yyval.args) = ((yyvsp[(1) - (2)].args) += currentblock->close(currentblock, (yyvsp[(2) - (2)].cexp))); + ; + } break; - case 141: + case 141: #line 673 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 148: + case 148: #line 686 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 149: + case 149: #line 687 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"+=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "+=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 150: + case 150: #line 688 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"-=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "-=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 151: + case 151: #line 689 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"*=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "*=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 152: + case 152: #line 690 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"/=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "/=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 153: + case 153: #line 691 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,".*=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, ".*=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 154: + case 154: #line 692 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"./=",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "./=", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 156: + case 156: #line 698 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"?:",(yyvsp[(1) - (5)].cexp),(yyvsp[(3) - (5)].cexp),(yyvsp[(5) - (5)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "?:", (yyvsp[(1) - (5)].cexp), (yyvsp[(3) - (5)].cexp), (yyvsp[(5) - (5)].cexp)); + ; + } break; - case 157: + case 157: #line 699 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"::",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "::", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 158: + case 158: #line 700 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,"::",(yyvsp[(1) - (5)].cexp),(yyvsp[(3) - (5)].cexp),(yyvsp[(5) - (5)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "::", (yyvsp[(1) - (5)].cexp), (yyvsp[(3) - (5)].cexp), (yyvsp[(5) - (5)].cexp)); + ; + } break; - case 160: + case 160: #line 705 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 161: + case 161: #line 706 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 162: + case 162: #line 707 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 163: + case 163: #line 708 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 164: + case 164: #line 709 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 165: + case 165: #line 710 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 166: + case 166: #line 711 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 167: + case 167: #line 712 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 168: + case 168: #line 713 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 169: + case 169: #line 714 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 170: + case 170: #line 715 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 171: + case 171: #line 716 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 172: + case 172: #line 717 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 173: + case 173: #line 718 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 174: + case 174: #line 719 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 175: + case 175: #line 720 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 176: + case 176: #line 721 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 177: + case 177: #line 722 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 178: + case 178: #line 723 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 179: + case 179: #line 727 "lg.ypp" - {(yyval.cexp)=(yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 180: + case 180: #line 728 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,":");;} - break; + { + (yyval.cexp) = C_F0(TheOperators, ":"); + ; + } break; - case 181: + case 181: #line 729 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,":",(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, ":", (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 182: + case 182: #line 730 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,":",(yyvsp[(1) - (5)].cexp),(yyvsp[(3) - (5)].cexp),(yyvsp[(5) - (5)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, ":", (yyvsp[(1) - (5)].cexp), (yyvsp[(3) - (5)].cexp), (yyvsp[(5) - (5)].cexp)); + ; + } break; - case 183: + case 183: #line 735 "lg.ypp" { (yyval.args) = (yyvsp[(1) - (3)].cexp); - (yyval.args) += (yyvsp[(3) - (3)].args); ;} - break; + (yyval.args) += (yyvsp[(3) - (3)].args); + ; + } break; - case 184: + case 184: #line 739 "lg.ypp" - {(yyval.args) = 0;;} - break; + { + (yyval.args) = 0; + ; + } break; - case 185: + case 185: #line 740 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 186: + case 186: #line 741 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 187: + case 187: #line 742 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 188: + case 188: #line 743 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 189: + case 189: #line 744 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 190: + case 190: #line 745 "lg.ypp" - {(yyval.args) = Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 191: + case 191: #line 746 "lg.ypp" - {(yyval.args) = make_pair((const char *) (yyvsp[(1) - (3)].str),(C_F0) (yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.args) = make_pair< const char *, const C_F0 >((const char *)(yyvsp[(1) - (3)].str), (C_F0)(yyvsp[(3) - (3)].cexp)); + ; + } break; - case 192: + case 192: #line 747 "lg.ypp" - {(yyval.args) = (yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.args) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 193: + case 193: #line 748 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 194: + case 194: #line 749 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 195: + case 195: #line 750 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 196: + case 196: #line 751 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 197: + case 197: #line 752 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 198: + case 198: #line 753 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 199: + case 199: #line 754 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 200: + case 200: #line 757 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (5)].args)+= make_pair((const char *)(yyvsp[(3) - (5)].str),(C_F0) (yyvsp[(5) - (5)].cexp)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (5)].args) += make_pair< const char *, const C_F0 >((const char *)(yyvsp[(3) - (5)].str), (C_F0)(yyvsp[(5) - (5)].cexp))); + ; + } break; - case 201: + case 201: #line 760 "lg.ypp" - {(yyval.args)=(yyvsp[(1) - (1)].cexp);;} - break; + { + (yyval.args) = (yyvsp[(1) - (1)].cexp); + ; + } break; - case 202: + case 202: #line 761 "lg.ypp" - {(yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 203: + case 203: #line 764 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + } break; - case 204: + case 204: #line 765 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 205: + case 205: #line 766 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 206: + case 206: #line 767 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 207: + case 207: #line 768 "lg.ypp" - { (yyval.args)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.args) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 208: + case 208: #line 769 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 209: + case 209: #line 770 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 210: + case 210: #line 771 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 211: + case 211: #line 772 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 212: + case 212: #line 773 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 213: + case 213: #line 774 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 214: + case 214: #line 775 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 215: + case 215: #line 776 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 216: + case 216: #line 777 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 217: + case 217: #line 778 "lg.ypp" - { (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str)));;} - break; + { + (yyval.args) = ((yyvsp[(1) - (3)].args) += Find((yyvsp[(3) - (3)].str))); + ; + } break; - case 219: + case 219: #line 783 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(1) - (2)].oper),(yyvsp[(2) - (2)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(1) - (2)].oper), (yyvsp[(2) - (2)].cexp)); + ; + } break; - case 221: + case 221: #line 788 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 222: + case 222: #line 789 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (3)].oper),(yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (3)].oper), (yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].cexp)); + ; + } break; - case 224: + case 224: #line 794 "lg.ypp" - {(yyval.cexp)=C_F0(TheOperators,(yyvsp[(2) - (2)].oper),(yyvsp[(1) - (2)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, (yyvsp[(2) - (2)].oper), (yyvsp[(1) - (2)].cexp)); + ; + } break; - case 225: + case 225: #line 802 "lg.ypp" - {(yyval.cexp)=Find((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.cexp) = Find((yyvsp[(1) - (1)].str)); + ; + } break; - case 226: + case 226: #line 806 "lg.ypp" - {(yyval.cexp)= CConstant((yyvsp[(1) - (1)].lnum));;} - break; + { + (yyval.cexp) = CConstant((yyvsp[(1) - (1)].lnum)); + ; + } break; - case 227: + case 227: #line 807 "lg.ypp" - {(yyval.cexp)= CConstant((yyvsp[(1) - (1)].dnum));;} - break; + { + (yyval.cexp) = CConstant((yyvsp[(1) - (1)].dnum)); + ; + } break; - case 228: + case 228: #line 808 "lg.ypp" - {(yyval.cexp)= CConstant(complex(0,(yyvsp[(1) - (1)].dnum)));;} - break; + { + (yyval.cexp) = CConstant(complex< double >(0, (yyvsp[(1) - (1)].dnum))); + ; + } break; - case 229: + case 229: #line 809 "lg.ypp" - {(yyval.cexp)= CConstant((yyvsp[(1) - (1)].str));;} - break; + { + (yyval.cexp) = CConstant< const char * >((yyvsp[(1) - (1)].str)); + ; + } break; - case 230: + case 230: #line 814 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (4)].cexp),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (4)].cexp), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 231: + case 231: #line 816 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (4)].cexp),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (4)].cexp), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].cexp)); + ; + } break; - case 232: + case 232: #line 817 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (6)].cexp),(yyvsp[(2) - (6)].oper),(yyvsp[(3) - (6)].cexp),(yyvsp[(5) - (6)].cexp));;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (6)].cexp), (yyvsp[(2) - (6)].oper), (yyvsp[(3) - (6)].cexp), (yyvsp[(5) - (6)].cexp)); + ; + } break; - case 233: + case 233: #line 818 "lg.ypp" - {(yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),"[]");;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), "[]"); + ; + } break; - case 234: + case 234: #line 819 "lg.ypp" - { (yyval.cexp)=C_F0((yyvsp[(1) - (3)].cexp),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0((yyvsp[(1) - (3)].cexp), (yyvsp[(3) - (3)].str)); + ; + } break; - case 235: + case 235: #line 820 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (3)].str)),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (3)].str)), (yyvsp[(3) - (3)].str)); + ; + } break; - case 236: + case 236: #line 821 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (4)].str)),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (4)].str)), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 237: + case 237: #line 822 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (3)].str)),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (3)].str)), (yyvsp[(3) - (3)].str)); + ; + } break; - case 238: + case 238: #line 823 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (4)].str)),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (4)].str)), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 239: + case 239: #line 824 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (3)].str)),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (3)].str)), (yyvsp[(3) - (3)].str)); + ; + } break; - case 240: + case 240: #line 825 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (4)].str)),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (4)].str)), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 241: + case 241: #line 826 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (3)].str)),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (3)].str)), (yyvsp[(3) - (3)].str)); + ; + } break; - case 242: + case 242: #line 827 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (4)].str)),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (4)].str)), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 243: + case 243: #line 828 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (3)].str)),(yyvsp[(3) - (3)].str)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (3)].str)), (yyvsp[(3) - (3)].str)); + ; + } break; - case 244: + case 244: #line 829 "lg.ypp" - { (yyval.cexp)=C_F0(Find((yyvsp[(1) - (4)].str)),(yyvsp[(2) - (4)].oper),(yyvsp[(3) - (4)].args)) ;;} - break; + { + (yyval.cexp) = C_F0(Find((yyvsp[(1) - (4)].str)), (yyvsp[(2) - (4)].oper), (yyvsp[(3) - (4)].args)); + ; + } break; - case 245: + case 245: #line 830 "lg.ypp" - {(yyval.cexp)=C_F0(TheRightOperators,(yyvsp[(2) - (2)].oper),(yyvsp[(1) - (2)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheRightOperators, (yyvsp[(2) - (2)].oper), (yyvsp[(1) - (2)].cexp)); + ; + } break; - case 246: + case 246: #line 831 "lg.ypp" - {(yyval.cexp)=C_F0(TheRightOperators,(yyvsp[(2) - (2)].oper),(yyvsp[(1) - (2)].cexp));;} - break; + { + (yyval.cexp) = C_F0(TheRightOperators, (yyvsp[(2) - (2)].oper), (yyvsp[(1) - (2)].cexp)); + ; + } break; - case 247: + case 247: #line 832 "lg.ypp" { - if ((yyvsp[(1) - (4)].type)->right()->CastingFrom((yyvsp[(3) - (4)].cexp).left()) ) - (yyval.cexp)=(yyvsp[(1) - (4)].type)->right()->CastTo((yyvsp[(3) - (4)].cexp)) ; - else { (yyval.cexp)=(yyvsp[(1) - (4)].type)->right()->Find("<--",basicAC_F0_wa((yyvsp[(3) - (4)].cexp))); - if (!(yyval.cexp).left()) { cerr << " no wait to change " << (yyvsp[(3) - (4)].cexp).left()->right()->name() << " in " << - (yyvsp[(1) - (4)].type)->right()->name() << endl; - CompileError(" Error in type(exp) "); } - } - ;} - break; - - case 248: + if ((yyvsp[(1) - (4)].type)->right( )->CastingFrom((yyvsp[(3) - (4)].cexp).left( ))) + (yyval.cexp) = (yyvsp[(1) - (4)].type)->right( )->CastTo((yyvsp[(3) - (4)].cexp)); + else { + (yyval.cexp) = (yyvsp[(1) - (4)].type)->right( )->Find("<--", basicAC_F0_wa((yyvsp[(3) - (4)].cexp))); + if (!(yyval.cexp).left( )) { + cerr << " no wait to change " << (yyvsp[(3) - (4)].cexp).left( )->right( )->name( ) << " in " << (yyvsp[(1) - (4)].type)->right( )->name( ) << endl; + CompileError(" Error in type(exp) "); + } + }; + } break; + + case 248: #line 841 "lg.ypp" { - { (yyval.cexp)=(yyvsp[(1) - (4)].type)->right()->Find("<--",basicAC_F0_wa((yyvsp[(3) - (4)].args))); - if (!(yyval.cexp).left()) { cerr << " no wait to change (args) in " << - (yyvsp[(1) - (4)].type)->right()->name() << endl; - CompileError(" Error in type(exp) "); } - } - ;} - break; - - case 249: + { + (yyval.cexp) = (yyvsp[(1) - (4)].type)->right( )->Find("<--", basicAC_F0_wa((yyvsp[(3) - (4)].args))); + if (!(yyval.cexp).left( )) { + cerr << " no wait to change (args) in " << (yyvsp[(1) - (4)].type)->right( )->name( ) << endl; + CompileError(" Error in type(exp) "); + } + }; + } break; + + case 249: #line 849 "lg.ypp" - {(yyval.cexp)=(yyvsp[(2) - (3)].cexp);;} - break; + { + (yyval.cexp) = (yyvsp[(2) - (3)].cexp); + ; + } break; - case 250: + case 250: #line 850 "lg.ypp" - { (yyval.cexp)=C_F0(TheOperators,"[]",(yyvsp[(2) - (3)].args));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "[]", (yyvsp[(2) - (3)].args)); + ; + } break; - case 251: + case 251: #line 851 "lg.ypp" - { (yyval.cexp)=C_F0(TheOperators,"<>",(yyvsp[(2) - (3)].args));;} - break; + { + (yyval.cexp) = C_F0(TheOperators, "<>", (yyvsp[(2) - (3)].args)); + ; + } break; - case 252: + case 252: #line 852 "lg.ypp" - { (yyval.cexp)=C_F0(TheOperators,"<>",(yyvsp[(1) - (1)].args));;} - break; - + { + (yyval.cexp) = C_F0(TheOperators, "<>", (yyvsp[(1) - (1)].args)); + ; + } break; /* Line 1267 of yacc.c. */ #line 3536 "lg.tab.cpp" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + default: + break; + } + YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc); - YYPOPSTACK (yylen); + YYPOPSTACK(yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); + YY_STACK_PRINT(yyss, yyssp); *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -3558,78 +3474,59 @@ yyparse () goto yynewstate; - /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); + if (!yyerrstatus) { + ++yynerrs; +#if !YYERROR_VERBOSE + yyerror(YY_("syntax error")); #else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + { + YYSIZE_T yysize = yysyntax_error(0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { + YYSIZE_T yyalloc = 2 * yysize; + if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) YYSTACK_FREE(yymsg); + yymsg = (char *)YYSTACK_ALLOC(yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } } -#endif - } - + if (0 < yysize && yysize <= yymsg_alloc) { + (void)yysyntax_error(yymsg, yystate, yychar); + yyerror(yymsg); + } else { + yyerror(YY_("syntax error")); + if (yysize != 0) goto yyexhaustedlab; + } + } +#endif + } - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ + if (yyerrstatus == 3) { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + if (yychar <= YYEOF) { + /* Return failure if at end of input. */ + if (yychar == YYEOF) YYABORT; + } else { + yydestruct("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; } + } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; - /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ @@ -3638,63 +3535,51 @@ yyparse () /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ - YYPOPSTACK (yylen); + YYPOPSTACK(yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); + YY_STACK_PRINT(yyss, yyssp); yystate = *yyssp; goto yyerrlab1; - /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { + yyn = yytable[yyn]; + if (0 < yyn) break; + } } - if (yyn == YYFINAL) - YYACCEPT; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) YYABORT; - *++yyvsp = yylval; + yydestruct("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK(1); + yystate = *yyssp; + YY_STACK_PRINT(yyss, yyssp); + } + + if (yyn == YYFINAL) YYACCEPT; + *++yyvsp = yylval; /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; - /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ @@ -3714,270 +3599,250 @@ yyparse () | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (YY_("memory exhausted")); + yyerror(YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + if (yychar != YYEOF && yychar != YYEMPTY) yydestruct("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } + YYPOPSTACK(yylen); + YY_STACK_PRINT(yyss, yyssp); + while (yyssp != yyss) { + yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp); + YYPOPSTACK(1); + } #ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); + if (yyss != yyssa) YYSTACK_FREE(yyss); #endif #if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); + if (yymsg != yymsgbuf) YYSTACK_FREE(yymsg); #endif /* Make sure YYID is used. */ - return YYID (yyresult); + return YYID(yyresult); } - #line 856 "lg.ypp" - - #include using namespace std; -void ForDebug(); -void ForDebug() -{ - int i=0; +void ForDebug( ); +void ForDebug( ) { + int i = 0; i++; } -//extern void ShowAlloc(const char *s, size_t lg); -//extern void ShowNbAlloc(const char *s); -void init_lgfem() ; -void init_lgmesh() ; -void init_lgmesh3() ; -void init_algo(); -void msh3_Load_Init( ); // +// extern void ShowAlloc(const char *s, size_t lg); +// extern void ShowNbAlloc(const char *s); +void init_lgfem( ); +void init_lgmesh( ); +void init_lgmesh3( ); +void init_algo( ); +void msh3_Load_Init( ); // bool withrgraphique = false; /// <> Called by mainff(). Activates the bison parser by calling yyparse() -int Compile() -{ +int Compile( ) { // see [[YYSTYPE]] [[yylval]] [[lglval]] - extern YYSTYPE *plglval; // modif FH + extern YYSTYPE *plglval; // modif FH /// plglval is allocated at [[file:../fflib/global.cpp::plglval]] plglval = &lglval; - int retvalue=0; + int retvalue = 0; // <> - currentblock=0; + currentblock = 0; Block::open(currentblock); try { - UnShowAlloc =0; - - retvalue=yyparse(); // grammar analysis starting from [[start_symbol]] - - if(retvalue==0){ - if(currentblock) - {retvalue=1; if(!mpirank) cerr << "Error:a block is not close" << endl; } - else { - if( verbosity ) { - UnShowAlloc =1; - cerr << " CodeAlloc : nb ptr "<< CodeAlloc::nb << ", size :" << CodeAlloc::lg - << " mpirank: " < * ccout = new stdio_filebuf(stdout, std::ios_base::out); - static stdio_filebuf ccout(stdout, std::ios_base::out); - static stdio_filebuf ccin(stdin, std::ios_base::in); - //stdio_filebuf *ccin= new stdio_filebuf(stdin, std::ios_base::in); - - cout.rdbuf(&ccout); - cin.rdbuf(&ccin); - cerr.rdbuf(&ccout); - cout << " -- SetcppIo --" << endl; + static stdio_filebuf< char > ccout(stdout, std::ios_base::out); + static stdio_filebuf< char > ccin(stdin, std::ios_base::in); + // stdio_filebuf *ccin= new stdio_filebuf(stdin, std::ios_base::in); + + cout.rdbuf(&ccout); + cin.rdbuf(&ccin); + cerr.rdbuf(&ccout); + cout << " -- SetcppIo --" << endl; #endif - ios::sync_with_stdio(); + ios::sync_with_stdio( ); } // pour l'environement. -extern const char * prognamearg; -extern bool echo_edp; +extern const char *prognamearg; +extern bool echo_edp; /// <> Called by [[file:mymain.cpp::mymain]] and calls [[Compile]] to run the FF language parser -int mainff (int argc, char **argv) -{ +int mainff(int argc, char **argv) { #ifndef _WIN32 - signal(SIGXCPU, signalCPUHandler); -#endif - if(argc) - prognamearg=argv[0]; + signal(SIGXCPU, signalCPUHandler); +#endif + if (argc) prognamearg = argv[0]; - // int vvold=verbosity; - if(mpirank !=0) verbosity=0; + // int vvold=verbosity; + if (mpirank != 0) verbosity = 0; // ALH - 14/10/8 - This breaks FFCS output redirection #ifndef ENABLE_FFCS - SetcppIo(); + SetcppIo( ); #endif - GetEnvironment(); // [[file:~/ff/src/fflib/environment.cpp::GetEnvironment]] -// vvold=verbosity; - if(mpirank !=0) verbosity=0; + GetEnvironment( ); // [[file:~/ff/src/fflib/environment.cpp::GetEnvironment]] + // vvold=verbosity; + if (mpirank != 0) verbosity = 0; // size_t lg000; - // ShowAlloc("begin main ",lg000); - int retvalue=0; - ff_atend(fingraphique); - if (initparallele)initparallele(argc,argv); + // ShowAlloc("begin main ",lg000); + int retvalue = 0; + ff_atend(fingraphique); + if (initparallele) initparallele(argc, argv); - CPUcompileInit= CPUtime(); + CPUcompileInit = CPUtime( ); withrgraphique = false; - atexit(ForDebug); -// AllFunctions::maptype xlocal; -// local=&xlocal; + atexit(ForDebug); + // AllFunctions::maptype xlocal; + // local=&xlocal; lexdebug = false; lgdebug = false; - char * cc= new char [1024]; + char *cc = new char[1024]; // istream * ccin=0; - if ( ! (getprog(cc,argc,argv) >0) ) // [[file:~/ff/src/Graphics/getprog-unix.hpp::getprog]] - { - cout << "-- FreeFem++ v" << StrVersionNumber() << " (error parameter!)\n" ; - if(ThePlotStream) {ffapi::ff_pclose(ThePlotStream); ThePlotStream=0;} - return 1; + if (!(getprog(cc, argc, argv) > 0)) // [[file:~/ff/src/Graphics/getprog-unix.hpp::getprog]] + { + cout << "-- FreeFem++ v" << StrVersionNumber( ) << " (error parameter!)\n"; + if (ThePlotStream) { + ffapi::ff_pclose(ThePlotStream); + ThePlotStream = 0; } - - if(verbosity && (mpirank==0)) { - cout << "-- FreeFem++ v" << StrVersionNumber() << endl; - cout << " file : " << cc ; - if(verbosity>1) cout << " " << " verbosity= " << verbosity ; - if( typeofscript ) cout << " " << " Markdown = " << typeofscript; - cout << endl; + return 1; } - KN karg(argc); - for(int i=0;i< argc;++i) - karg[i]=argv[i]; - pkarg= &karg; - - /// <> - zzzfff = Newlex(cout,echo_edp,pkarg); + if (verbosity && (mpirank == 0)) { + cout << "-- FreeFem++ v" << StrVersionNumber( ) << endl; + cout << " file : " << cc; + if (verbosity > 1) cout << " " << " verbosity= " << verbosity; + if (typeofscript) cout << " " << " Markdown = " << typeofscript; + cout << endl; + } - -/* - ccin= new ifstream(cc); - if (argc >1 && (ccin!=0) ) - ccin= new ifstream(argv[1]),throwassert(ccin); - if (ccin!=0) - zzzfff = new mylex(*ccin,cout) ; - else - zzzfff = new mylex(cin,cout) ; -*/ -// les motsclefs - zzzfff->Add("include",INCLUDE); - zzzfff->Add("load",LOAD); - zzzfff->Add("while",WHILE); - zzzfff->Add("for",FOR); - // zzzfff->Add("forall",FORALL); - zzzfff->Add("if",IF); - zzzfff->Add("else",ELSE); - zzzfff->Add("end",ENDOFFILE); - zzzfff->Add("break",BREAK); - zzzfff->Add("continue",CONTINUE); - zzzfff->Add("return",RETURN); - zzzfff->Add("border",BORDER); - zzzfff->Add("fespace",FESPACEID); - zzzfff->Add("try",TRY); - zzzfff->Add("catch",CATCH); - zzzfff->Add("throw",THROW); -// Init_map_type(); - if(verbosity>2 || ( (mpirank==0) && verbosity ) ) cout << " Load: "; - callInitsFunct() ; // init for dynamique libs ... - // init_lgfem() ; - init_lgmesh() ; - init_lgmesh3() ; - init_algo(); + KN< String > karg(argc); + for (int i = 0; i < argc; ++i) karg[i] = argv[i]; + pkarg = &karg; + + /// <> + zzzfff = Newlex(cout, echo_edp, pkarg); + + /* + ccin= new ifstream(cc); + if (argc >1 && (ccin!=0) ) + ccin= new ifstream(argv[1]),throwassert(ccin); + if (ccin!=0) + zzzfff = new mylex(*ccin,cout) ; + else + zzzfff = new mylex(cin,cout) ; + */ + // les motsclefs + zzzfff->Add("include", INCLUDE); + zzzfff->Add("load", LOAD); + zzzfff->Add("while", WHILE); + zzzfff->Add("for", FOR); + // zzzfff->Add("forall",FORALL); + zzzfff->Add("if", IF); + zzzfff->Add("else", ELSE); + zzzfff->Add("end", ENDOFFILE); + zzzfff->Add("break", BREAK); + zzzfff->Add("continue", CONTINUE); + zzzfff->Add("return", RETURN); + zzzfff->Add("border", BORDER); + zzzfff->Add("fespace", FESPACEID); + zzzfff->Add("try", TRY); + zzzfff->Add("catch", CATCH); + zzzfff->Add("throw", THROW); + // Init_map_type(); + if (verbosity > 2 || ((mpirank == 0) && verbosity)) cout << " Load: "; + callInitsFunct( ); // init for dynamique libs ... + // init_lgfem() ; + init_lgmesh( ); + init_lgmesh3( ); + init_algo( ); #ifdef HAVE_LIBARPACK - init_eigenvalue(); + init_eigenvalue( ); #endif - if(init_lgparallele) init_lgparallele(); - msh3_Load_Init(); // Add msh3 lib !!! - // callInitsFunct() ; // init for dynamique libs ... + if (init_lgparallele) init_lgparallele( ); + msh3_Load_Init( ); // Add msh3 lib !!! + // callInitsFunct() ; // init for dynamique libs ... - if(verbosity>2 || ((mpirank==0)&& verbosity) ) cout << endl; - zzzfff->input(cc,typeofscript); // [[file:../fflib/lex.cpp::mylex_input_filename]] - EnvironmentLoad(); // just before compile [[file:~/ff/src/fflib/environment.cpp::EnvironmentLoad]] + if (verbosity > 2 || ((mpirank == 0) && verbosity)) cout << endl; + zzzfff->input(cc, typeofscript); // [[file:../fflib/lex.cpp::mylex_input_filename]] + EnvironmentLoad( ); // just before compile [[file:~/ff/src/fflib/environment.cpp::EnvironmentLoad]] - retvalue= Compile(); // [[Compile]] - // cout << " xxxxx " << retvalue << " " << ThePlotStream << endl; + retvalue = Compile( ); // [[Compile]] + // cout << " xxxxx " << retvalue << " " << ThePlotStream << endl; - //if(end_parallele) end_parallele(); - ff_finalize(); + // if(end_parallele) end_parallele(); + ff_finalize( ); // currentblock->close(currentblock).eval(thestack); - // fingraphique(); + // fingraphique(); // FFCS: divert stream to FFCS - if(ThePlotStream){ + if (ThePlotStream) { ffapi::ff_pclose(ThePlotStream); - ThePlotStream=0; + ThePlotStream = 0; } - Destroylex( zzzfff); - delete [] cc; - // ClearMem(); + Destroylex(zzzfff); + delete[] cc; + // ClearMem(); return retvalue; } @@ -3990,4 +3855,3 @@ int mainff (int argc, char **argv) * coding:utf-8 * End: */ - diff --git a/src/lglib/lg.tab.hpp b/src/lglib/lg.tab.hpp index 101eddc34..8b3c2ffe6 100644 --- a/src/lglib/lg.tab.hpp +++ b/src/lglib/lg.tab.hpp @@ -35,64 +35,64 @@ /* Tokens. */ #ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - IF = 258, - ELSE = 259, - SET = 260, - GTGT = 261, - LTLT = 262, - OR = 263, - AND = 264, - NE = 265, - EQ = 266, - GE = 267, - LE = 268, - DOTSLASH = 269, - DOTSTAR = 270, - MOINSMOINS = 271, - PLUSPLUS = 272, - UNARY = 273, - LNUM = 274, - DNUM = 275, - CNUM = 276, - ID = 277, - FESPACEID = 278, - IDPARAM = 279, - STRING = 280, - ENDOFFILE = 281, - INCLUDE = 282, - LOAD = 283, - BIDON = 284, - FOR = 285, - WHILE = 286, - BREAK = 287, - CONTINUE = 288, - RETURN = 289, - TRY = 290, - CATCH = 291, - THROW = 292, - TYPE = 293, - FUNCTION = 294, - FESPACE = 295, - FESPACE1 = 296, - FESPACE3 = 297, - FESPACES = 298, - FESPACEL = 299, - VGFESPACE = 300, - GFESPACE = 301, - PLUSEQ = 302, - MOINSEQ = 303, - MULEQ = 304, - DIVEQ = 305, - DOTMULEQ = 306, - DOTDIVEQ = 307, - ARROW = 308, - BORDER = 309, - SOLVE = 310 - }; +#define YYTOKENTYPE +/* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ +enum yytokentype { + IF = 258, + ELSE = 259, + SET = 260, + GTGT = 261, + LTLT = 262, + OR = 263, + AND = 264, + NE = 265, + EQ = 266, + GE = 267, + LE = 268, + DOTSLASH = 269, + DOTSTAR = 270, + MOINSMOINS = 271, + PLUSPLUS = 272, + UNARY = 273, + LNUM = 274, + DNUM = 275, + CNUM = 276, + ID = 277, + FESPACEID = 278, + IDPARAM = 279, + STRING = 280, + ENDOFFILE = 281, + INCLUDE = 282, + LOAD = 283, + BIDON = 284, + FOR = 285, + WHILE = 286, + BREAK = 287, + CONTINUE = 288, + RETURN = 289, + TRY = 290, + CATCH = 291, + THROW = 292, + TYPE = 293, + FUNCTION = 294, + FESPACE = 295, + FESPACE1 = 296, + FESPACE3 = 297, + FESPACES = 298, + FESPACEL = 299, + VGFESPACE = 300, + GFESPACE = 301, + PLUSEQ = 302, + MOINSEQ = 303, + MULEQ = 304, + DIVEQ = 305, + DOTMULEQ = 306, + DOTDIVEQ = 307, + ARROW = 308, + BORDER = 309, + SOLVE = 310 +}; #endif /* Tokens. */ #define IF 258 @@ -149,52 +149,48 @@ #define BORDER 309 #define SOLVE 310 - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED typedef union YYSTYPE #line 170 "lg.ypp" { - double dnum; + double dnum; - /* <> */ - long lnum;// to read long long number !!!! FH dec 2022 + /* <> */ + long lnum; // to read long long number !!!! FH dec 2022 - /* <> */ - char * str; - char oper[8]; + /* <> */ + char *str; + char oper[8]; - /* <> [[file:../fflib/AFunction.hpp::CC_F0]] */ - CC_F0 cexp; + /* <> [[file:../fflib/AFunction.hpp::CC_F0]] */ + CC_F0 cexp; - Routine *routine; + Routine *routine; - /* <> [[file:~/ff/src/fflib/AFunction.hpp::AC_F0]] */ - AC_F0 args; + /* <> [[file:~/ff/src/fflib/AFunction.hpp::AC_F0]] */ + AC_F0 args; - /* <> refers to [[file:~/ff/src/fflib/AnyType.hpp::aType]] */ - aType type; + /* <> refers to [[file:~/ff/src/fflib/AnyType.hpp::aType]] */ + aType type; - /* <> refers to [[file:~/ff/src/fflib/AFunction.hpp::CListOfInst]] */ - CListOfInst cinst; + /* <> refers to [[file:~/ff/src/fflib/AFunction.hpp::CListOfInst]] */ + CListOfInst cinst; - Block * block; + Block *block; - /* <> [[file:~/ff/src/fflib/AFunction.hpp::ListOfId]] */ - ListOfId *clist_id; + /* <> [[file:~/ff/src/fflib/AFunction.hpp::ListOfId]] */ + ListOfId *clist_id; -/* ListCatch * clist_Catchs;*/ + /* ListCatch * clist_Catchs;*/ - vectorOfInst * endb; + vectorOfInst *endb; } /* Line 1529 of yacc.c. */ #line 193 "lg.tab.hpp" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 +YYSTYPE; +#define yystype YYSTYPE /* obsolescent; will be withdrawn */ +#define YYSTYPE_IS_DECLARED 1 +#define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE lglval; - diff --git a/src/lglib/mymain.cpp b/src/lglib/mymain.cpp index 850817580..591a007ab 100644 --- a/src/lglib/mymain.cpp +++ b/src/lglib/mymain.cpp @@ -1,17 +1,18 @@ /// \file -int mainff (int argc, char **argv); -namespace ffapi { void init();} -extern void init_ptr_parallelepmi(); +int mainff(int argc, char **argv); +namespace ffapi { + void init( ); +} +extern void init_ptr_parallelepmi( ); /// called by platform-dependent main() in [[file:../Graphics/sansrgraph.cpp::calling_mymain]] -int mymain (int argc, char **argv) -{ - ffapi::init(); // [[file:~/ff/src/fflib/ffapi.cpp::init]] +int mymain(int argc, char **argv) { + ffapi::init( ); // [[file:~/ff/src/fflib/ffapi.cpp::init]] // Calls either [[file:~/ff/src/mpi/parallelempi.cpp::init_ptr_parallelepmi]] or // [[file:~/ff/src/mpi/parallelempi-empty.cpp::init_ptr_parallelepmi]] - init_ptr_parallelepmi(); + init_ptr_parallelepmi( ); - return mainff(argc,argv); // [[file:lg.ypp::mainff]] + return mainff(argc, argv); // [[file:lg.ypp::mainff]] } diff --git a/src/libMesh/chrono.c b/src/libMesh/chrono.c index 16f5cf0ff..d36dd8464 100644 --- a/src/libMesh/chrono.c +++ b/src/libMesh/chrono.c @@ -1,4 +1,4 @@ -/* +/* * simulation of a chronograph * in : tim * out: tim.dtim = elapsed time in micro-secs @@ -7,7 +7,7 @@ * * Written by Pascal J. Frey * email: Pascal.Frey@inria.fr, 1999 -*/ + */ #ifdef __cplusplus extern "C" { @@ -18,12 +18,11 @@ extern "C" { #include #include "chrono.h" - /* return elapsed time in secs. */ -static double diftim(time_t t2,time_t t1) { - struct tm *ptm; - double tim; - int hh1,mm1,ss1,hh2,mm2,ss2; +static double diftim(time_t t2, time_t t1) { + struct tm *ptm; + double tim; + int hh1, mm1, ss1, hh2, mm2, ss2; ptm = localtime(&t1); hh1 = ptm->tm_hour; @@ -34,65 +33,58 @@ static double diftim(time_t t2,time_t t1) { hh2 = ptm->tm_hour; mm2 = ptm->tm_min; ss2 = ptm->tm_sec; - if ( hh2 < hh1 ) hh2 += 24; - - tim = 3600.0*(hh2-hh1); - tim += 60.0*(mm2-mm1); - tim += ss2-ss1; + if (hh2 < hh1) hh2 += 24; - return(tim); -} + tim = 3600.0 * (hh2 - hh1); + tim += 60.0 * (mm2 - mm1); + tim += ss2 - ss1; + return (tim); +} /* get system and user times in micro-seconds */ -void chrono(int cmode,mytime *ptt) { +void chrono(int cmode, mytime *ptt) { time_t tt; - if ( cmode == RESET ) { - ptt->dtim = clock(); - ptt->ctim = 0.0f; - ptt->ptim = 0; - ptt->call = 0; - } - else { - ptt->dtim = difftime(clock(),ptt->dtim); /* in secs */ - if ( cmode == ON ) { + if (cmode == RESET) { + ptt->dtim = clock( ); + ptt->ctim = 0.0f; + ptt->ptim = 0; + ptt->call = 0; + } else { + ptt->dtim = difftime(clock( ), ptt->dtim); /* in secs */ + if (cmode == ON) { ptt->ptim = time(NULL); ptt->call++; - } - else if ( cmode == OFF ) { + } else if (cmode == OFF) { tt = time(NULL); - ptt->ctim += diftim(tt,ptt->ptim); - ptt->ptim = 0; + ptt->ctim += diftim(tt, ptt->ptim); + ptt->ptim = 0; } } } - /* return time (converted in secs */ double gttime(mytime t) { - if ( t.ctim < MAXCLK ) - return(t.dtim / (double)CLOCKS_PER_SEC); + if (t.ctim < MAXCLK) + return (t.dtim / (double)CLOCKS_PER_SEC); else - return(t.ctim); + return (t.ctim); } - /* initialize time table */ -void tminit(mytime *t,int maxtim) { - int k; +void tminit(mytime *t, int maxtim) { + int k; - for (k=0; k -#ifndef ON -#define RESET 0 -#define ON 1 -#define OFF 2 +#ifndef ON +#define RESET 0 +#define ON 1 +#define OFF 2 #endif -#define TIMEMAX 16 -#define MAXCLK ( 1073741823. / (double)CLOCKS_PER_SEC ) - +#define TIMEMAX 16 +#define MAXCLK (1073741823. / (double)CLOCKS_PER_SEC) typedef struct mytime { - double ctim,dtim; - time_t ptim; - short call; + double ctim, dtim; + time_t ptim; + short call; } mytime; - /* prototypes */ -void chrono(int cmode,mytime *ptt); +void chrono(int cmode, mytime *ptt); double gttime(mytime t); -void tminit(mytime *t,int maxtim); - +void tminit(mytime *t, int maxtim); #ifdef __cplusplus } diff --git a/src/libMesh/eigenv.c b/src/libMesh/eigenv.c index 66826273f..d6052b6ba 100644 --- a/src/libMesh/eigenv.c +++ b/src/libMesh/eigenv.c @@ -4,33 +4,25 @@ /* seeking 1.e-05 accuracy */ /* Modif F. Hecht because in some case the result a wrong */ -#define EPSD 1.e-12 -#define EPSD2 1.e-10 -#define EPS6 5.e-06 -#define EPS 1.e-06 -#define EPSX2 2.e-06 -#define MAXTOU 50 +#define EPSD 1.e-12 +#define EPSD2 1.e-10 +#define EPS6 5.e-06 +#define EPS 1.e-06 +#define EPSX2 2.e-06 +#define MAXTOU 50 -/* check if numbers are equal */ -#define egal(x,y) ( \ - ( ((x) == 0.0f) ? (fabs(y) < EPS) : \ - ( ((y) == 0.0f) ? (fabs(x) < EPS) : \ - (fabs((x)-(y)) / (fabs(x) + fabs(y)) < EPSX2) ) ) ) +/* check if numbers are equal */ +#define egal(x, y) ((((x) == 0.0f) ? (fabs(y) < EPS) : (((y) == 0.0f) ? (fabs(x) < EPS) : (fabs((x) - (y)) / (fabs(x) + fabs(y)) < EPSX2)))) +static double Id[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; -static double Id[3][3] = { - { 1.0, 0.0, 0.0}, - { 0.0, 1.0, 0.0}, - { 0.0, 0.0, 1.0} }; - - -/* find root(s) of polynomial: P(x)= x^3+bx^2+cx+d +/* find root(s) of polynomial: P(x)= x^3+bx^2+cx+d return 1: 3 roots, 2: 2 roots, 3: 1 root */ -static int newton3(double p[4],double x[3]) { - double b,c,d,da,db,dc,epsd; - double delta,fx,dfx,dxx; - double fdx0,fdx1,dx0,dx1,x1,x2; - int it,n; +static int newton3(double p[4], double x[3]) { + double b, c, d, da, db, dc, epsd; + double delta, fx, dfx, dxx; + double fdx0, fdx1, dx0, dx1, x1, x2; + int it, n; /* coeffs polynomial, a=1 */ b = p[2]; @@ -40,180 +32,176 @@ static int newton3(double p[4],double x[3]) { /* 1st derivative of f */ da = 3.0; - db = 2.0*b; + db = 2.0 * b; /* solve 2nd order eqn */ - delta = db*db - 4.0*da*c; - epsd = db*db*EPSD2; + delta = db * db - 4.0 * da * c; + epsd = db * db * EPSD2; /* inflexion (f'(x)=0, x=-b/2a) */ x1 = -db / 6.0f; n = 1; - if ( delta > epsd ) { + if (delta > epsd) { delta = sqrt(delta); - dx0 = (-db + delta) / 6.0; - dx1 = (-db - delta) / 6.0; + dx0 = (-db + delta) / 6.0; + dx1 = (-db - delta) / 6.0; /* Horner */ - fdx0 = d + dx0*(c+dx0*(b+dx0)); - fdx1 = d + dx1*(c+dx1*(b+dx1)); + fdx0 = d + dx0 * (c + dx0 * (b + dx0)); + fdx1 = d + dx1 * (c + dx1 * (b + dx1)); - if ( fabs(fdx0) < EPSD ) { + if (fabs(fdx0) < EPSD) { /* dx0: double root, compute single root */ n = 2; x[0] = dx0; x[1] = dx0; - x[2] = -b - 2.0*dx0; + x[2] = -b - 2.0 * dx0; /* check if P(x) = 0 */ - fx = d + x[2]*(c+x[2]*(b+x[2])); - if ( fabs(fx) > EPSD2 ) { + fx = d + x[2] * (c + x[2] * (b + x[2])); + if (fabs(fx) > EPSD2) { #ifdef DDEBUG - fprintf(stderr," ## ERR 9100, newton3: fx= %E\n",fx); + fprintf(stderr, " ## ERR 9100, newton3: fx= %E\n", fx); #endif - return(0); + return (0); } - return(n); - } - else if ( fabs(fdx1) < EPSD ) { + return (n); + } else if (fabs(fdx1) < EPSD) { /* dx1: double root, compute single root */ n = 2; x[0] = dx1; x[1] = dx1; - x[2] = -b - 2.0*dx1; + x[2] = -b - 2.0 * dx1; /* check if P(x) = 0 */ - fx = d + x[2]*(c+x[2]*(b+x[2])); - if ( fabs(fx) > EPSD2 ) { + fx = d + x[2] * (c + x[2] * (b + x[2])); + if (fabs(fx) > EPSD2) { #ifdef DDEBUG - fprintf(stderr," ## ERR 9100, newton3: fx= %E\n",fx); + fprintf(stderr, " ## ERR 9100, newton3: fx= %E\n", fx); #endif - return(0); + return (0); } - return(n); + return (n); } } - else if ( fabs(delta) < epsd ) { + else if (fabs(delta) < epsd) { /* triple root */ n = 3; x[0] = x1; x[1] = x1; x[2] = x1; /* check if P(x) = 0 */ - fx = d + x[0]*(c+x[0]*(b+x[0])); - if ( fabs(fx) > EPSD2 ) { + fx = d + x[0] * (c + x[0] * (b + x[0])); + if (fabs(fx) > EPSD2) { #ifdef DDEBUG - fprintf(stderr," ## ERR 9100, newton3: fx= %E\n",fx); + fprintf(stderr, " ## ERR 9100, newton3: fx= %E\n", fx); #endif - return(0); + return (0); } - return(n); + return (n); } - + else { #ifdef DDEBUG - fprintf(stderr," ## ERR 9101, newton3: no real roots\n"); + fprintf(stderr, " ## ERR 9101, newton3: no real roots\n"); #endif - return(0); + return (0); } /* Newton method: find one root (middle) starting point: P"(x)=0 */ - x1 = -b / 3.0; - dfx = c + b*x1; - fx = d + x1*(c -2.0*x1*x1); - it = 0; + x1 = -b / 3.0; + dfx = c + b * x1; + fx = d + x1 * (c - 2.0 * x1 * x1); + it = 0; do { x2 = x1 - fx / dfx; - fx = d + x2*(c+x2*(b+x2)); - if ( fabs(fx) < EPSD ) { + fx = d + x2 * (c + x2 * (b + x2)); + if (fabs(fx) < EPSD) { x[0] = x2; break; } - dfx = c + x2*(db + da*x2); + dfx = c + x2 * (db + da * x2); /* check for break-off condition */ - dxx = fabs((x2-x1) / x2); - if ( dxx < 1.0e-10 ) { + dxx = fabs((x2 - x1) / x2); + if (dxx < 1.0e-10) { x[0] = x2; - if ( fabs(fx) > EPSD2 ) { - fprintf(stderr," ## ERR 9102, newton3, no root found (fx %E).\n",fx); - return(0); + if (fabs(fx) > EPSD2) { + fprintf(stderr, " ## ERR 9102, newton3, no root found (fx %E).\n", fx); + return (0); } break; - } - else + } else x1 = x2; - } - while ( ++it < MAXTOU ); + } while (++it < MAXTOU); - if ( it == MAXTOU ) { + if (it == MAXTOU) { x[0] = x1; - fx = d + x1*(c+(x1*(b+x1))); - if ( fabs(fx) > EPSD2 ) { - fprintf(stderr," ## ERR 9102, newton3, no root found (fx %E).\n",fx); - return(0); + fx = d + x1 * (c + (x1 * (b + x1))); + if (fabs(fx) > EPSD2) { + fprintf(stderr, " ## ERR 9102, newton3, no root found (fx %E).\n", fx); + return (0); } } /* solve 2nd order equation P(x) = (x-sol(1))* (x^2+bb*x+cc) */ - db = b + x[0]; - dc = c + x[0]*db; - delta = db*db - 4.0*dc; - - if ( delta <= 0.0 ) { - fprintf(stderr," ## ERR 9103, newton3, det = 0.\n"); - return(0); + db = b + x[0]; + dc = c + x[0] * db; + delta = db * db - 4.0 * dc; + + if (delta <= 0.0) { + fprintf(stderr, " ## ERR 9103, newton3, det = 0.\n"); + return (0); } delta = sqrt(delta); - x[1] = 0.5 * (-db+delta); - x[2] = 0.5 * (-db-delta); - + x[1] = 0.5 * (-db + delta); + x[2] = 0.5 * (-db - delta); + #ifdef DDEBUG - /* check for root accuracy */ - fx = d + x[1]*(c+x[1]*(b+x[1])); - if ( fabs(fx) > EPSD2 ) { - fprintf(stderr," ## ERR 9104, newton3: fx= %E x= %E\n",fx,x[1]); - return(0); - } - fx = d + x[2]*(c+x[2]*(b+x[2])); - if ( fabs(fx) > EPSD2 ) { - fprintf(stderr," ## ERR 9104, newton3: fx= %E x= %E\n",fx,x[2]); - return(0); - } + /* check for root accuracy */ + fx = d + x[1] * (c + x[1] * (b + x[1])); + if (fabs(fx) > EPSD2) { + fprintf(stderr, " ## ERR 9104, newton3: fx= %E x= %E\n", fx, x[1]); + return (0); + } + fx = d + x[2] * (c + x[2] * (b + x[2])); + if (fabs(fx) > EPSD2) { + fprintf(stderr, " ## ERR 9104, newton3: fx= %E x= %E\n", fx, x[2]); + return (0); + } #endif - return(n); + return (n); } - /* find eigenvalues and vectors of a 3x3 symmetric definite - * positive matrix + * positive matrix * return order of eigenvalues (1,2,3) or 0 if failed */ -int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { - double a11,a12,a13,a21,a22,a23,a31,a32,a33; - double aa,bb,cc,dd,ee,ii,vx1[3],vx2[3],vx3[3],dd1,dd2,dd3; - double maxd,maxm,valm,p[4],w1[3],w2[3],w3[3]; - int k,n; +int eigenv(int symmat, double *mat, double lambda[3], double v[3][3]) { + double a11, a12, a13, a21, a22, a23, a31, a32, a33; + double aa, bb, cc, dd, ee, ii, vx1[3], vx2[3], vx3[3], dd1, dd2, dd3; + double maxd, maxm, valm, p[4], w1[3], w2[3], w3[3]; + int k, n; /* default */ - memcpy(v,Id,9*sizeof(double)); - if ( symmat ) { + memcpy(v, Id, 9 * sizeof(double)); + if (symmat) { lambda[0] = (double)mat[0]; lambda[1] = (double)mat[3]; lambda[2] = (double)mat[5]; maxm = fabs(mat[0]); - for (k=1; k<6; k++) { + for (k = 1; k < 6; k++) { valm = fabs(mat[k]); - if ( valm > maxm ) maxm = valm; + if (valm > maxm) maxm = valm; } /* single float accuracy */ - if ( maxm < EPS6 ) return(1); + if (maxm < EPS6) return (1); /* normalize matrix */ - dd = 1.0 / maxm; + dd = 1.0 / maxm; a11 = mat[0] * dd; a12 = mat[1] * dd; a13 = mat[2] * dd; @@ -224,40 +212,39 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { /* diagonal matrix */ maxd = fabs(a12); valm = fabs(a13); - if ( valm > maxd ) maxd = valm; + if (valm > maxd) maxd = valm; valm = fabs(a23); - if ( valm > maxd ) maxd = valm; - if ( maxd < EPSD ) return(1); + if (valm > maxd) maxd = valm; + if (maxd < EPSD) return (1); + + a21 = a12; + a31 = a13; + a32 = a23; - a21 = a12; - a31 = a13; - a32 = a23; - /* build characteristic polynomial P(X) = X^3 - trace X^2 + (somme des mineurs)X - det = 0 */ - aa = a11*a22; - bb = a23*a32; - cc = a12*a21; - dd = a13*a31; - p[0] = a11*bb + a33*(cc-aa) + a22*dd -2.0*a12*a13*a23; - p[1] = a11*(a22 + a33) + a22*a33 - bb - cc - dd; + aa = a11 * a22; + bb = a23 * a32; + cc = a12 * a21; + dd = a13 * a31; + p[0] = a11 * bb + a33 * (cc - aa) + a22 * dd - 2.0 * a12 * a13 * a23; + p[1] = a11 * (a22 + a33) + a22 * a33 - bb - cc - dd; p[2] = -a11 - a22 - a33; - p[3] = 1.0; - } - else { + p[3] = 1.0; + } else { lambda[0] = (double)mat[0]; lambda[1] = (double)mat[4]; lambda[2] = (double)mat[8]; maxm = fabs(mat[0]); - for (k=1; k<9; k++) { + for (k = 1; k < 9; k++) { valm = fabs(mat[k]); - if ( valm > maxm ) maxm = valm; + if (valm > maxm) maxm = valm; } - if ( maxm < EPS6 ) return(1); + if (maxm < EPS6) return (1); /* normalize matrix */ - dd = 1.0 / maxm; + dd = 1.0 / maxm; a11 = mat[0] * dd; a12 = mat[1] * dd; a13 = mat[2] * dd; @@ -271,145 +258,145 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { /* diagonal matrix */ maxd = fabs(a12); valm = fabs(a13); - if ( valm > maxd ) maxd = valm; + if (valm > maxd) maxd = valm; valm = fabs(a23); - if ( valm > maxd ) maxd = valm; + if (valm > maxd) maxd = valm; valm = fabs(a21); - if ( valm > maxd ) maxd = valm; + if (valm > maxd) maxd = valm; valm = fabs(a31); - if ( valm > maxd ) maxd = valm; - valm = fabs(a32); - if ( valm > maxd ) maxd = valm; - if ( maxd < EPSD ) return(1); + if (valm > maxd) maxd = valm; + valm = fabs(a32); + if (valm > maxd) maxd = valm; + if (maxd < EPSD) return (1); /* build characteristic polynomial P(X) = X^3 - trace X^2 + (somme des mineurs)X - det = 0 */ - aa = a22*a33 - a23*a32; - bb = a23*a31 - a21*a33; - cc = a21*a32 - a31*a22; - ee = a11*a33 - a13*a31; - ii = a11*a22 - a12*a21; - - p[0] = -a11*aa - a12*bb - a13*cc; - p[1] = aa + ee + ii; + aa = a22 * a33 - a23 * a32; + bb = a23 * a31 - a21 * a33; + cc = a21 * a32 - a31 * a22; + ee = a11 * a33 - a13 * a31; + ii = a11 * a22 - a12 * a21; + + p[0] = -a11 * aa - a12 * bb - a13 * cc; + p[1] = aa + ee + ii; p[2] = -a11 - a22 - a33; - p[3] = 1.0; + p[3] = 1.0; } /* solve polynomial (find roots using newton) */ - n = newton3(p,lambda); - if ( n <= 0 ) return(0); + n = newton3(p, lambda); + if (n <= 0) return (0); /* compute eigenvectors: an eigenvalue belong to orthogonal of Im(A-lambda*Id) */ - v[0][0] = 1.0; v[0][1] = v[0][2] = 0.0; - v[1][1] = 1.0; v[1][0] = v[1][2] = 0.0; - v[2][2] = 1.0; v[2][0] = v[2][1] = 0.0; - - w1[1] = a12; w1[2] = a13; - w2[0] = a21; w2[2] = a23; - w3[0] = a31; w3[1] = a32; - - if ( n == 1 ) { + v[0][0] = 1.0; + v[0][1] = v[0][2] = 0.0; + v[1][1] = 1.0; + v[1][0] = v[1][2] = 0.0; + v[2][2] = 1.0; + v[2][0] = v[2][1] = 0.0; + + w1[1] = a12; + w1[2] = a13; + w2[0] = a21; + w2[2] = a23; + w3[0] = a31; + w3[1] = a32; + + if (n == 1) { /* vk = crsprd(wi,wj) */ - for (k=0; k<3; k++) { + for (k = 0; k < 3; k++) { w1[0] = a11 - lambda[k]; w2[1] = a22 - lambda[k]; w3[2] = a33 - lambda[k]; /* cross product vectors in (Im(A-lambda(i) Id) ortho */ - vx1[0] = w1[1]*w3[2] - w1[2]*w3[1]; - vx1[1] = w1[2]*w3[0] - w1[0]*w3[2]; - vx1[2] = w1[0]*w3[1] - w1[1]*w3[0]; - dd1 = vx1[0]*vx1[0] + vx1[1]*vx1[1] + vx1[2]*vx1[2]; + vx1[0] = w1[1] * w3[2] - w1[2] * w3[1]; + vx1[1] = w1[2] * w3[0] - w1[0] * w3[2]; + vx1[2] = w1[0] * w3[1] - w1[1] * w3[0]; + dd1 = vx1[0] * vx1[0] + vx1[1] * vx1[1] + vx1[2] * vx1[2]; - vx2[0] = w1[1]*w2[2] - w1[2]*w2[1]; - vx2[1] = w1[2]*w2[0] - w1[0]*w2[2]; - vx2[2] = w1[0]*w2[1] - w1[1]*w2[0]; - dd2 = vx2[0]*vx2[0] + vx2[1]*vx2[1] + vx2[2]*vx2[2]; + vx2[0] = w1[1] * w2[2] - w1[2] * w2[1]; + vx2[1] = w1[2] * w2[0] - w1[0] * w2[2]; + vx2[2] = w1[0] * w2[1] - w1[1] * w2[0]; + dd2 = vx2[0] * vx2[0] + vx2[1] * vx2[1] + vx2[2] * vx2[2]; - vx3[0] = w2[1]*w3[2] - w2[2]*w3[1]; - vx3[1] = w2[2]*w3[0] - w2[0]*w3[2]; - vx3[2] = w2[0]*w3[1] - w2[1]*w3[0]; - dd3 = vx3[0]*vx3[0] + vx3[1]*vx3[1] + vx3[2]*vx3[2]; + vx3[0] = w2[1] * w3[2] - w2[2] * w3[1]; + vx3[1] = w2[2] * w3[0] - w2[0] * w3[2]; + vx3[2] = w2[0] * w3[1] - w2[1] * w3[0]; + dd3 = vx3[0] * vx3[0] + vx3[1] * vx3[1] + vx3[2] * vx3[2]; /* find vector of max norm */ - if ( dd1 > dd2 ) { - if ( dd1 > dd3 ) { + if (dd1 > dd2) { + if (dd1 > dd3) { dd1 = 1.0 / sqrt(dd1); v[k][0] = vx1[0] * dd1; v[k][1] = vx1[1] * dd1; v[k][2] = vx1[2] * dd1; - } - else { + } else { dd3 = 1.0 / sqrt(dd3); v[k][0] = vx3[0] * dd3; v[k][1] = vx3[1] * dd3; v[k][2] = vx3[2] * dd3; - } - } - else { - if ( dd2 > dd3 ) { + } + } else { + if (dd2 > dd3) { dd2 = 1.0 / sqrt(dd2); v[k][0] = vx2[0] * dd2; v[k][1] = vx2[1] * dd2; v[k][2] = vx2[2] * dd2; - } - else { + } else { dd3 = 1.0 / sqrt(dd3); v[k][0] = vx3[0] * dd3; v[k][1] = vx3[1] * dd3; v[k][2] = vx3[2] * dd3; - } + } } } } /* (vp1,vp2) double, vp3 simple root */ - else if ( n == 2 ) { + else if (n == 2) { w1[0] = a11 - lambda[2]; w2[1] = a22 - lambda[2]; w3[2] = a33 - lambda[2]; /* cross product */ - vx1[0] = w1[1]*w3[2] - w1[2]*w3[1]; - vx1[1] = w1[2]*w3[0] - w1[0]*w3[2]; - vx1[2] = w1[0]*w3[1] - w1[1]*w3[0]; - dd1 = vx1[0]*vx1[0] + vx1[1]*vx1[1] + vx1[2]*vx1[2]; - - vx2[0] = w1[1]*w2[2] - w1[2]*w2[1]; - vx2[1] = w1[2]*w2[0] - w1[0]*w2[2]; - vx2[2] = w1[0]*w2[1] - w1[1]*w2[0]; - dd2 = vx2[0]*vx2[0] + vx2[1]*vx2[1] + vx2[2]*vx2[2]; - - vx3[0] = w2[1]*w3[2] - w2[2]*w3[1]; - vx3[1] = w2[2]*w3[0] - w2[0]*w3[2]; - vx3[2] = w2[0]*w3[1] - w2[1]*w3[0]; - dd3 = vx3[0]*vx3[0] + vx3[1]*vx3[1] + vx3[2]*vx3[2]; + vx1[0] = w1[1] * w3[2] - w1[2] * w3[1]; + vx1[1] = w1[2] * w3[0] - w1[0] * w3[2]; + vx1[2] = w1[0] * w3[1] - w1[1] * w3[0]; + dd1 = vx1[0] * vx1[0] + vx1[1] * vx1[1] + vx1[2] * vx1[2]; + + vx2[0] = w1[1] * w2[2] - w1[2] * w2[1]; + vx2[1] = w1[2] * w2[0] - w1[0] * w2[2]; + vx2[2] = w1[0] * w2[1] - w1[1] * w2[0]; + dd2 = vx2[0] * vx2[0] + vx2[1] * vx2[1] + vx2[2] * vx2[2]; + + vx3[0] = w2[1] * w3[2] - w2[2] * w3[1]; + vx3[1] = w2[2] * w3[0] - w2[0] * w3[2]; + vx3[2] = w2[0] * w3[1] - w2[1] * w3[0]; + dd3 = vx3[0] * vx3[0] + vx3[1] * vx3[1] + vx3[2] * vx3[2]; /* find vector of max norm */ - if ( dd1 > dd2 ) { - if ( dd1 > dd3 ) { + if (dd1 > dd2) { + if (dd1 > dd3) { dd1 = 1.0 / sqrt(dd1); v[2][0] = vx1[0] * dd1; v[2][1] = vx1[1] * dd1; v[2][2] = vx1[2] * dd1; - } - else { + } else { dd3 = 1.0 / sqrt(dd3); v[2][0] = vx3[0] * dd3; v[2][1] = vx3[1] * dd3; v[2][2] = vx3[2] * dd3; } - } - else { - if ( dd2 > dd3 ) { + } else { + if (dd2 > dd3) { dd2 = 1.0 / sqrt(dd2); v[2][0] = vx2[0] * dd2; v[2][1] = vx2[1] * dd2; v[2][2] = vx2[2] * dd2; - } - else { + } else { dd3 = 1.0 / sqrt(dd3); v[2][0] = vx3[0] * dd3; v[2][1] = vx3[1] * dd3; @@ -418,26 +405,25 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { } /* compute v1 and v2 in Im(A-vp3*Id) */ - dd1 = w1[0]*w1[0] + w1[1]*w1[1] + w1[2]*w1[2]; - dd2 = w2[0]*w2[0] + w2[1]*w2[1] + w2[2]*w2[2]; - if ( dd1 > dd2 ) { + dd1 = w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]; + dd2 = w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]; + if (dd1 > dd2) { dd1 = 1.0 / sqrt(dd1); - v[0][0] = w1[0]*dd1; - v[0][1] = w1[1]*dd1; - v[0][2] = w1[2]*dd1; - } - else { + v[0][0] = w1[0] * dd1; + v[0][1] = w1[1] * dd1; + v[0][2] = w1[2] * dd1; + } else { dd2 = 1.0 / sqrt(dd2); - v[0][0] = w2[0]*dd2; - v[0][1] = w2[1]*dd2; - v[0][2] = w2[2]*dd2; + v[0][0] = w2[0] * dd2; + v[0][1] = w2[1] * dd2; + v[0][2] = w2[2] * dd2; } /* 3rd vector orthogonal */ - v[1][0] = v[2][1]*v[0][2] - v[2][2]*v[0][1]; - v[1][1] = v[2][2]*v[0][0] - v[2][0]*v[0][2]; - v[1][2] = v[2][0]*v[0][1] - v[2][1]*v[0][0]; - dd1 = v[1][0]*v[1][0] + v[1][1]*v[1][1] + v[1][2]*v[1][2]; + v[1][0] = v[2][1] * v[0][2] - v[2][2] * v[0][1]; + v[1][1] = v[2][2] * v[0][0] - v[2][0] * v[0][2]; + v[1][2] = v[2][0] * v[0][1] - v[2][1] * v[0][0]; + dd1 = v[1][0] * v[1][0] + v[1][1] * v[1][1] + v[1][2] * v[1][2]; dd1 = 1.0 / sqrt(dd1); v[1][0] *= dd1; v[1][1] *= dd1; @@ -484,7 +470,7 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { v[0][0]*v[2][0]+v[0][1]*v[2][1]+ v[0][2]*v[2][2]); printf("v2.v3 = %.14f\n", v[1][0]*v[2][0]+v[1][1]*v[2][1]+ v[1][2]*v[2][2]); - + printf("Consistency\n"); for (i=0; i<3; i++) { tmpx = v[0][i]*m[0] + v[1][i]*m[1] @@ -495,7 +481,7 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { + v[2][i]*m[5] - lambda[i]*v[2][i]; printf(" Av %d - lambda %d *v %d = %f %f %f\n", i,i,i,tmpx,tmpy,tmpz); - + printf("w1 %f %f %f\n",w1[0],w1[1],w1[2]); printf("w2 %f %f %f\n",w2[0],w2[1],w2[2]); printf("w3 %f %f %f\n",w3[0],w3[1],w3[2]); @@ -505,65 +491,61 @@ int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]) { } -------------------------------------------------------------------*/ - return(n); + return (n); } - /* eigen value + vector extraction */ -int eigen2(double *mm,double *lambda,double vp[2][2]) { - double m[3],dd,a1,xn,ddeltb,rr1,rr2,ux,uy; +int eigen2(double *mm, double *lambda, double vp[2][2]) { + double m[3], dd, a1, xn, ddeltb, rr1, rr2, ux, uy; /* init */ ux = 1.0; uy = 0.0; /* normalize */ - memcpy(m,mm,3*sizeof(double)); + memcpy(m, mm, 3 * sizeof(double)); xn = fabs(m[0]); - if ( fabs(m[1]) > xn ) xn = fabs(m[1]); - if ( fabs(m[2]) > xn ) xn = fabs(m[2]); - if ( xn < EPSD2 ) { + if (fabs(m[1]) > xn) xn = fabs(m[1]); + if (fabs(m[2]) > xn) xn = fabs(m[2]); + if (xn < EPSD2) { lambda[0] = lambda[1] = 0.0; - vp[0][0] = 1.0; + vp[0][0] = 1.0; vp[0][1] = 0.0; vp[1][0] = 0.0; vp[1][1] = 1.0; - return(1); + return (1); } xn = 1.0 / xn; m[0] *= xn; m[1] *= xn; m[2] *= xn; - if ( egal(m[1],0.0) ) { + if (egal(m[1], 0.0)) { rr1 = m[0]; rr2 = m[2]; goto vect; } /* eigenvalues of jacobian */ - a1 = -(m[0] + m[2]); - ddeltb = a1*a1 - 4.0 * (m[0]*m[2] - m[1]*m[1]); + a1 = -(m[0] + m[2]); + ddeltb = a1 * a1 - 4.0 * (m[0] * m[2] - m[1] * m[1]); - if ( ddeltb < 0.0 ) { - fprintf(stderr," Delta: %f\n",ddeltb); + if (ddeltb < 0.0) { + fprintf(stderr, " Delta: %f\n", ddeltb); ddeltb = 0.0; } ddeltb = sqrt(ddeltb); - if ( fabs(a1) < EPS ) { + if (fabs(a1) < EPS) { rr1 = 0.5 * sqrt(ddeltb); rr2 = -rr1; - } - else if ( a1 < 0.0 ) { + } else if (a1 < 0.0) { rr1 = 0.5 * (-a1 + ddeltb); - rr2 = (-m[1]*m[1] + m[0]*m[2]) / rr1; - } - else if ( a1 > 0.0 ) { + rr2 = (-m[1] * m[1] + m[0] * m[2]) / rr1; + } else if (a1 > 0.0) { rr1 = 0.5 * (-a1 - ddeltb); - rr2 = (-m[1]*m[1] + m[0]*m[2]) / rr1; - } - else { + rr2 = (-m[1] * m[1] + m[0] * m[2]) / rr1; + } else { rr1 = 0.5 * ddeltb; rr2 = -rr1; } @@ -575,47 +557,41 @@ int eigen2(double *mm,double *lambda,double vp[2][2]) { /* eigenvectors */ a1 = m[0] - rr1; - if ( fabs(a1)+fabs(m[1]) < EPS ) { - if (fabs(lambda[1]) < fabs(lambda[0]) ) { + if (fabs(a1) + fabs(m[1]) < EPS) { + if (fabs(lambda[1]) < fabs(lambda[0])) { ux = 1.0; - uy = 0.0; - } - else { + uy = 0.0; + } else { ux = 0.0; uy = 1.0; } - } - else if ( fabs(a1) < fabs(m[1]) ) { + } else if (fabs(a1) < fabs(m[1])) { ux = 1.0; uy = -a1 / m[1]; - } - else if ( fabs(a1) > fabs(m[1]) ) { + } else if (fabs(a1) > fabs(m[1])) { ux = -m[1] / a1; uy = 1.0; - } - else if ( fabs(lambda[1]) > fabs(lambda[0]) ) { + } else if (fabs(lambda[1]) > fabs(lambda[0])) { ux = 0.0; uy = 1.0; - } - else { + } else { ux = 1.0; uy = 0.0; } - dd = sqrt(ux*ux + uy*uy); + dd = sqrt(ux * ux + uy * uy); dd = 1.0 / dd; - if ( fabs(lambda[0]) > fabs(lambda[1]) ) { - vp[0][0] = ux * dd; - vp[0][1] = uy * dd; - } - else { - vp[0][0] = uy * dd; + if (fabs(lambda[0]) > fabs(lambda[1])) { + vp[0][0] = ux * dd; + vp[0][1] = uy * dd; + } else { + vp[0][0] = uy * dd; vp[0][1] = -ux * dd; } /* orthogonal vector */ vp[1][0] = -vp[0][1]; - vp[1][1] = vp[0][0]; + vp[1][1] = vp[0][0]; - return(1); + return (1); } diff --git a/src/libMesh/eigenv.h b/src/libMesh/eigenv.h index 8b1d266d6..b155a04e0 100644 --- a/src/libMesh/eigenv.h +++ b/src/libMesh/eigenv.h @@ -2,8 +2,8 @@ extern "C" { #endif -int eigenv(int symmat,double *mat,double lambda[3],double v[3][3]); -int eigen2(double *mm,double *lambda,double vp[2][2]); +int eigenv(int symmat, double *mat, double lambda[3], double v[3][3]); +int eigen2(double *mm, double *lambda, double vp[2][2]); #ifdef __cplusplus } diff --git a/src/libMesh/libmeshb7.c b/src/libMesh/libmeshb7.c index 39fc3cd26..080dbcbfc 100644 --- a/src/libMesh/libmeshb7.c +++ b/src/libMesh/libmeshb7.c @@ -21,27 +21,26 @@ // Add a final underscore to Fortran procedure names #ifdef F77_NO_UNDER_SCORE -#define NAMF77(c,f) f -#define APIF77(x) x +#define NAMF77(c, f) f +#define APIF77(x) x #else -#define NAMF77(c,f) f ## _ -#define APIF77(x) x ## _ +#define NAMF77(c, f) f##_ +#define APIF77(x) x##_ #endif // Pass parameters as pointers in Fortran -#define VALF77(v) *v -#define TYPF77(t) t* +#define VALF77(v) *v +#define TYPF77(t) t * #else // Pass parameters as values in C -#define NAMF77(c,f) c -#define VALF77(v) v -#define TYPF77(t) t +#define NAMF77(c, f) c +#define VALF77(v) v +#define TYPF77(t) t #endif - /*----------------------------------------------------------------------------*/ /* Includes */ /*----------------------------------------------------------------------------*/ @@ -58,12 +57,11 @@ #include #include - /* - * [Bruno] include the headers with the prototypes for - * open()/close()/write()/lseek() - * and define the constants to be used to open() a file. - * Under Windows, + * [Bruno] include the headers with the prototypes for + * open()/close()/write()/lseek() + * and define the constants to be used to open() a file. + * Under Windows, * 1) _O_BINARY should be set in the flags. * 2) 'mode' has a completely different meaning */ @@ -72,11 +70,11 @@ #include -#define OPEN_READ_FLAGS O_RDONLY -#define OPEN_WRITE_FLAGS O_CREAT | O_WRONLY | O_TRUNC -#define OPEN_READ_MODE 0666 -#define OPEN_WRITE_MODE 0666 - +#define OPEN_READ_FLAGS O_RDONLY +#define OPEN_WRITE_FLAGS O_CREAT | O_WRONLY | O_TRUNC +#define OPEN_READ_MODE 0666 +#define OPEN_WRITE_MODE 0666 + #elif defined(WIN32) || defined(_WIN64) #define GMF_WINDOWS @@ -87,10 +85,10 @@ #include #include -#define OPEN_READ_FLAGS O_RDONLY | _O_BINARY -#define OPEN_WRITE_FLAGS O_CREAT | O_WRONLY | O_TRUNC | _O_BINARY -#define OPEN_READ_MODE _S_IREAD -#define OPEN_WRITE_MODE _S_IREAD | S_IWRITE +#define OPEN_READ_FLAGS O_RDONLY | _O_BINARY +#define OPEN_WRITE_FLAGS O_CREAT | O_WRONLY | O_TRUNC | _O_BINARY +#define OPEN_READ_MODE _S_IREAD +#define OPEN_WRITE_MODE _S_IREAD | S_IWRITE #endif @@ -103,12 +101,12 @@ #ifdef PRINTF_INT64_MODIFIER #define INT64_T_FMT "%" PRINTF_INT64_MODIFIER "d" #else -# ifdef GMF_WINDOWS -# define INT64_T_FMT "%Id" -# else -# include -# define INT64_T_FMT "%" PRId64 -# endif +#ifdef GMF_WINDOWS +#define INT64_T_FMT "%Id" +#else +#include +#define INT64_T_FMT "%" PRId64 +#endif #endif // [Bruno] Made asynchronous I/O optional @@ -117,1173 +115,973 @@ #else // Mockup aio library -struct aiocb -{ - FILE *aio_fildes; // File descriptor - off_t aio_offset; // File offset - void *aio_buf; // Location of buffer - size_t aio_nbytes; // Length of transfer - int aio_lio_opcode; // Operation to be performed +struct aiocb { + FILE *aio_fildes; // File descriptor + off_t aio_offset; // File offset + void *aio_buf; // Location of buffer + size_t aio_nbytes; // Length of transfer + int aio_lio_opcode; // Operation to be performed }; -int aio_error( const struct aiocb * aiocbp ) -{ - return(aiocbp->aio_lio_opcode); -} +int aio_error(const struct aiocb *aiocbp) { return (aiocbp->aio_lio_opcode); } // Set the file position and read a block of data -int aio_read( struct aiocb * aiocbp ) -{ - if( (fseek(aiocbp->aio_fildes, (off_t)aiocbp->aio_offset, SEEK_SET) == 0) - && (fread(aiocbp->aio_buf, 1, aiocbp->aio_nbytes, aiocbp->aio_fildes) - == aiocbp->aio_nbytes) ) - { - aiocbp->aio_lio_opcode = 0; - } - else - { - aiocbp->aio_lio_opcode = -1; - } - - return(aiocbp->aio_lio_opcode); +int aio_read(struct aiocb *aiocbp) { + if ((fseek(aiocbp->aio_fildes, (off_t)aiocbp->aio_offset, SEEK_SET) == 0) && (fread(aiocbp->aio_buf, 1, aiocbp->aio_nbytes, aiocbp->aio_fildes) == aiocbp->aio_nbytes)) { + aiocbp->aio_lio_opcode = 0; + } else { + aiocbp->aio_lio_opcode = -1; + } + + return (aiocbp->aio_lio_opcode); } -size_t aio_return( struct aiocb * aiocbp ) -{ - return(aiocbp->aio_nbytes); -} +size_t aio_return(struct aiocb *aiocbp) { return (aiocbp->aio_nbytes); } // Set the file position and write a block of data -int aio_write( struct aiocb * aiocbp ) -{ - if( (fseek(aiocbp->aio_fildes, (off_t)aiocbp->aio_offset, SEEK_SET) == 0) - && (fwrite(aiocbp->aio_buf, 1, aiocbp->aio_nbytes, aiocbp->aio_fildes) - == aiocbp->aio_nbytes) ) - { - aiocbp->aio_lio_opcode = 0; - } - else - { - aiocbp->aio_lio_opcode = -1; - } - - return(aiocbp->aio_lio_opcode); +int aio_write(struct aiocb *aiocbp) { + if ((fseek(aiocbp->aio_fildes, (off_t)aiocbp->aio_offset, SEEK_SET) == 0) && (fwrite(aiocbp->aio_buf, 1, aiocbp->aio_nbytes, aiocbp->aio_fildes) == aiocbp->aio_nbytes)) { + aiocbp->aio_lio_opcode = 0; + } else { + aiocbp->aio_lio_opcode = -1; + } + + return (aiocbp->aio_lio_opcode); } #endif - - /*----------------------------------------------------------------------------*/ /* Defines */ /*----------------------------------------------------------------------------*/ -#define Asc 1 -#define Bin 2 -#define MshFil 4 -#define SolFil 8 -#define InfKwd 1 -#define RegKwd 2 -#define SolKwd 3 -#define CmtKwd 4 -#define WrdSiz 4 +#define Asc 1 +#define Bin 2 +#define MshFil 4 +#define SolFil 8 +#define InfKwd 1 +#define RegKwd 2 +#define SolKwd 3 +#define CmtKwd 4 +#define WrdSiz 4 #define FilStrSiz 64 -#define BufSiz 10000 -#define MaxArg 20 - +#define BufSiz 10000 +#define MaxArg 20 /*----------------------------------------------------------------------------*/ /* Structures */ /*----------------------------------------------------------------------------*/ -typedef struct -{ - int typ, deg, NmbNod, SolSiz, NmbWrd, NmbTyp, TypTab[ GmfMaxTyp ]; - int *OrdTab; - int64_t NmbLin; - size_t pos; - char fmt[ GmfMaxTyp*9 ]; -}KwdSct; - -typedef struct -{ - int dim, ver, mod, typ, cod, FilDes; - int64_t NexKwdPos, siz; - size_t pos; - jmp_buf err; - KwdSct KwdTab[ GmfMaxKwd + 1 ]; - FILE *hdl; - int *IntBuf; - float *FltBuf; - char *buf; - char FilNam[ GmfStrSiz ]; - double DblBuf[1000/8]; - unsigned char blk[ BufSiz + 1000 ]; -}GmfMshSct; - +typedef struct { + int typ, deg, NmbNod, SolSiz, NmbWrd, NmbTyp, TypTab[GmfMaxTyp]; + int *OrdTab; + int64_t NmbLin; + size_t pos; + char fmt[GmfMaxTyp * 9]; +} KwdSct; + +typedef struct { + int dim, ver, mod, typ, cod, FilDes; + int64_t NexKwdPos, siz; + size_t pos; + jmp_buf err; + KwdSct KwdTab[GmfMaxKwd + 1]; + FILE *hdl; + int *IntBuf; + float *FltBuf; + char *buf; + char FilNam[GmfStrSiz]; + double DblBuf[1000 / 8]; + unsigned char blk[BufSiz + 1000]; +} GmfMshSct; /*----------------------------------------------------------------------------*/ /* Global variables */ /*----------------------------------------------------------------------------*/ -const char *GmfKwdFmt[ GmfMaxKwd + 1 ][3] = -{ - {"Reserved", "", ""}, - {"MeshVersionFormatted", "", "i"}, - {"Reserved", "", ""}, - {"Dimension", "", "i"}, - {"Vertices", "i", "dri"}, - {"Edges", "i", "iii"}, - {"Triangles", "i", "iiii"}, - {"Quadrilaterals", "i", "iiiii"}, - {"Tetrahedra", "i", "iiiii"}, - {"Prisms", "i", "iiiiiii"}, - {"Hexahedra", "i", "iiiiiiiii"}, - {"Reserved", "", ""}, - {"Reserved", "", ""}, - {"Corners", "i", "i"}, - {"Ridges", "i", "i"}, - {"RequiredVertices", "i", "i"}, - {"RequiredEdges", "i", "i"}, - {"RequiredTriangles", "i", "i"}, - {"RequiredQuadrilaterals", "i", "i"}, - {"TangentAtEdgeVertices", "i", "iii"}, - {"NormalAtVertices", "i", "ii"}, - {"NormalAtTriangleVertices", "i", "iii"}, - {"NormalAtQuadrilateralVertices", "i", "iiii"}, - {"AngleOfCornerBound", "", "r"}, - {"TrianglesP2", "i", "iiiiiii"}, - {"EdgesP2", "i", "iiii"}, - {"SolAtPyramids", "i", "sr"}, - {"QuadrilateralsQ2", "i", "iiiiiiiiii"}, - {"ISolAtPyramids", "i", "iiiii"}, - {"SubDomainFromGeom", "i", "iii"}, - {"TetrahedraP2", "i", "iiiiiiiiiii"}, - {"Fault_NearTri", "i", "i"}, - {"Fault_Inter", "i", "i"}, - {"HexahedraQ2", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"ExtraVerticesAtEdges", "i", "in"}, - {"ExtraVerticesAtTriangles", "i", "in"}, - {"ExtraVerticesAtQuadrilaterals", "i", "in"}, - {"ExtraVerticesAtTetrahedra", "i", "in"}, - {"ExtraVerticesAtPrisms", "i", "in"}, - {"ExtraVerticesAtHexahedra", "i", "in"}, - {"VerticesOnGeometricVertices", "i", "ii"}, - {"VerticesOnGeometricEdges", "i", "iirr"}, - {"VerticesOnGeometricTriangles", "i", "iirrr"}, - {"VerticesOnGeometricQuadrilaterals", "i", "iirrr"}, - {"EdgesOnGeometricEdges", "i", "ii"}, - {"Fault_FreeEdge", "i", "i"}, - {"Polyhedra", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"Polygons", "", "iiiiiiiii"}, - {"Fault_Overlap", "i", "i"}, - {"Pyramids", "i", "iiiiii"}, - {"BoundingBox", "", "drdr"}, - {"Reserved", "", ""}, - {"PrivateTable", "i", "i"}, - {"Fault_BadShape", "i", "i"}, - {"End", "", ""}, - {"TrianglesOnGeometricTriangles", "i", "ii"}, - {"TrianglesOnGeometricQuadrilaterals", "i", "ii"}, - {"QuadrilateralsOnGeometricTriangles", "i", "ii"}, - {"QuadrilateralsOnGeometricQuadrilaterals", "i", "ii"}, - {"Tangents", "i", "dr"}, - {"Normals", "i", "dr"}, - {"TangentAtVertices", "i", "ii"}, - {"SolAtVertices", "i", "sr"}, - {"SolAtEdges", "i", "sr"}, - {"SolAtTriangles", "i", "sr"}, - {"SolAtQuadrilaterals", "i", "sr"}, - {"SolAtTetrahedra", "i", "sr"}, - {"SolAtPrisms", "i", "sr"}, - {"SolAtHexahedra", "i", "sr"}, - {"DSolAtVertices", "i", "sr"}, - {"ISolAtVertices", "i", "i"}, - {"ISolAtEdges", "i", "ii"}, - {"ISolAtTriangles", "i", "iii"}, - {"ISolAtQuadrilaterals", "i", "iiii"}, - {"ISolAtTetrahedra", "i", "iiii"}, - {"ISolAtPrisms", "i", "iiiiii"}, - {"ISolAtHexahedra", "i", "iiiiiiii"}, - {"Iterations", "", "i"}, - {"Time", "", "r"}, - {"Fault_SmallTri", "i", "i"}, - {"CoarseHexahedra", "i", "i"}, - {"Comments", "i", "c"}, - {"PeriodicVertices", "i", "ii"}, - {"PeriodicEdges", "i", "ii"}, - {"PeriodicTriangles", "i", "ii"}, - {"PeriodicQuadrilaterals", "i", "ii"}, - {"PrismsP2", "i", "iiiiiiiiiiiiiiiiiii"}, - {"PyramidsP2", "i", "iiiiiiiiiiiiiii"}, - {"QuadrilateralsQ3", "i", "iiiiiiiiiiiiiiiii"}, - {"QuadrilateralsQ4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"TrianglesP3", "i", "iiiiiiiiiii"}, - {"TrianglesP4", "i", "iiiiiiiiiiiiiiii"}, - {"EdgesP3", "i", "iiiii"}, - {"EdgesP4", "i", "iiiiii"}, - {"IRefGroups", "i", "ciii"}, - {"DRefGroups", "i", "iii"}, - {"TetrahedraP3", "i", "iiiiiiiiiiiiiiiiiiiii"}, - {"TetrahedraP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"HexahedraQ3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"HexahedraQ4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"PyramidsP3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"PyramidsP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"PrismsP3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"PrismsP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, - {"HOSolAtEdgesP1", "i", "hr"}, - {"HOSolAtEdgesP2", "i", "hr"}, - {"HOSolAtEdgesP3", "i", "hr"}, - {"HOSolAtTrianglesP1", "i", "hr"}, - {"HOSolAtTrianglesP2", "i", "hr"}, - {"HOSolAtTrianglesP3", "i", "hr"}, - {"HOSolAtQuadrilateralsQ1", "i", "hr"}, - {"HOSolAtQuadrilateralsQ2", "i", "hr"}, - {"HOSolAtQuadrilateralsQ3", "i", "hr"}, - {"HOSolAtTetrahedraP1", "i", "hr"}, - {"HOSolAtTetrahedraP2", "i", "hr"}, - {"HOSolAtTetrahedraP3", "i", "hr"}, - {"HOSolAtPyramidsP1", "i", "hr"}, - {"HOSolAtPyramidsP2", "i", "hr"}, - {"HOSolAtPyramidsP3", "i", "hr"}, - {"HOSolAtPrismsP1", "i", "hr"}, - {"HOSolAtPrismsP2", "i", "hr"}, - {"HOSolAtPrismsP3", "i", "hr"}, - {"HOSolAtHexahedraQ1", "i", "hr"}, - {"HOSolAtHexahedraQ2", "i", "hr"}, - {"HOSolAtHexahedraQ3", "i", "hr"}, - {"BezierMode", "", "i"}, - {"ByteFlow", "i", "i"}, - {"EdgesP2Ordering", "i", "i"}, - {"EdgesP3Ordering", "i", "i"}, - {"TrianglesP2Ordering", "i", "iii"}, - {"TrianglesP3Ordering", "i", "iii"}, - {"QuadrilateralsQ2Ordering", "i", "ii"}, - {"QuadrilateralsQ3Ordering", "i", "ii"}, - {"TetrahedraP2Ordering", "i", "iiii"}, - {"TetrahedraP3Ordering", "i", "iiii"}, - {"PyramidsP2Ordering", "i", "iii"}, - {"PyramidsP3Ordering", "i", "iii"}, - {"PrismsP2Ordering", "i", "iiii"}, - {"PrismsP3Ordering", "i", "iiii"}, - {"HexahedraQ2Ordering", "i", "iii"}, - {"HexahedraQ3Ordering", "i", "iii"}, - {"EdgesP1Ordering", "i", "i"}, - {"EdgesP4Ordering", "i", "i"}, - {"TrianglesP1Ordering", "i", "iii"}, - {"TrianglesP4Ordering", "i", "iii"}, - {"QuadrilateralsQ1Ordering", "i", "ii"}, - {"QuadrilateralsQ4Ordering", "i", "ii"}, - {"TetrahedraP1Ordering", "i", "iiii"}, - {"TetrahedraP4Ordering", "i", "iiii"}, - {"PyramidsP1Ordering", "i", "iii"}, - {"PyramidsP4Ordering", "i", "iii"}, - {"PrismsP1Ordering", "i", "iiii"}, - {"PrismsP4Ordering", "i", "iiii"}, - {"HexahedraQ1Ordering", "i", "iii"}, - {"HexahedraQ4Ordering", "i", "iii"} -}; +const char *GmfKwdFmt[GmfMaxKwd + 1][3] = {{"Reserved", "", ""}, + {"MeshVersionFormatted", "", "i"}, + {"Reserved", "", ""}, + {"Dimension", "", "i"}, + {"Vertices", "i", "dri"}, + {"Edges", "i", "iii"}, + {"Triangles", "i", "iiii"}, + {"Quadrilaterals", "i", "iiiii"}, + {"Tetrahedra", "i", "iiiii"}, + {"Prisms", "i", "iiiiiii"}, + {"Hexahedra", "i", "iiiiiiiii"}, + {"Reserved", "", ""}, + {"Reserved", "", ""}, + {"Corners", "i", "i"}, + {"Ridges", "i", "i"}, + {"RequiredVertices", "i", "i"}, + {"RequiredEdges", "i", "i"}, + {"RequiredTriangles", "i", "i"}, + {"RequiredQuadrilaterals", "i", "i"}, + {"TangentAtEdgeVertices", "i", "iii"}, + {"NormalAtVertices", "i", "ii"}, + {"NormalAtTriangleVertices", "i", "iii"}, + {"NormalAtQuadrilateralVertices", "i", "iiii"}, + {"AngleOfCornerBound", "", "r"}, + {"TrianglesP2", "i", "iiiiiii"}, + {"EdgesP2", "i", "iiii"}, + {"SolAtPyramids", "i", "sr"}, + {"QuadrilateralsQ2", "i", "iiiiiiiiii"}, + {"ISolAtPyramids", "i", "iiiii"}, + {"SubDomainFromGeom", "i", "iii"}, + {"TetrahedraP2", "i", "iiiiiiiiiii"}, + {"Fault_NearTri", "i", "i"}, + {"Fault_Inter", "i", "i"}, + {"HexahedraQ2", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"ExtraVerticesAtEdges", "i", "in"}, + {"ExtraVerticesAtTriangles", "i", "in"}, + {"ExtraVerticesAtQuadrilaterals", "i", "in"}, + {"ExtraVerticesAtTetrahedra", "i", "in"}, + {"ExtraVerticesAtPrisms", "i", "in"}, + {"ExtraVerticesAtHexahedra", "i", "in"}, + {"VerticesOnGeometricVertices", "i", "ii"}, + {"VerticesOnGeometricEdges", "i", "iirr"}, + {"VerticesOnGeometricTriangles", "i", "iirrr"}, + {"VerticesOnGeometricQuadrilaterals", "i", "iirrr"}, + {"EdgesOnGeometricEdges", "i", "ii"}, + {"Fault_FreeEdge", "i", "i"}, + {"Polyhedra", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"Polygons", "", "iiiiiiiii"}, + {"Fault_Overlap", "i", "i"}, + {"Pyramids", "i", "iiiiii"}, + {"BoundingBox", "", "drdr"}, + {"Reserved", "", ""}, + {"PrivateTable", "i", "i"}, + {"Fault_BadShape", "i", "i"}, + {"End", "", ""}, + {"TrianglesOnGeometricTriangles", "i", "ii"}, + {"TrianglesOnGeometricQuadrilaterals", "i", "ii"}, + {"QuadrilateralsOnGeometricTriangles", "i", "ii"}, + {"QuadrilateralsOnGeometricQuadrilaterals", "i", "ii"}, + {"Tangents", "i", "dr"}, + {"Normals", "i", "dr"}, + {"TangentAtVertices", "i", "ii"}, + {"SolAtVertices", "i", "sr"}, + {"SolAtEdges", "i", "sr"}, + {"SolAtTriangles", "i", "sr"}, + {"SolAtQuadrilaterals", "i", "sr"}, + {"SolAtTetrahedra", "i", "sr"}, + {"SolAtPrisms", "i", "sr"}, + {"SolAtHexahedra", "i", "sr"}, + {"DSolAtVertices", "i", "sr"}, + {"ISolAtVertices", "i", "i"}, + {"ISolAtEdges", "i", "ii"}, + {"ISolAtTriangles", "i", "iii"}, + {"ISolAtQuadrilaterals", "i", "iiii"}, + {"ISolAtTetrahedra", "i", "iiii"}, + {"ISolAtPrisms", "i", "iiiiii"}, + {"ISolAtHexahedra", "i", "iiiiiiii"}, + {"Iterations", "", "i"}, + {"Time", "", "r"}, + {"Fault_SmallTri", "i", "i"}, + {"CoarseHexahedra", "i", "i"}, + {"Comments", "i", "c"}, + {"PeriodicVertices", "i", "ii"}, + {"PeriodicEdges", "i", "ii"}, + {"PeriodicTriangles", "i", "ii"}, + {"PeriodicQuadrilaterals", "i", "ii"}, + {"PrismsP2", "i", "iiiiiiiiiiiiiiiiiii"}, + {"PyramidsP2", "i", "iiiiiiiiiiiiiii"}, + {"QuadrilateralsQ3", "i", "iiiiiiiiiiiiiiiii"}, + {"QuadrilateralsQ4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"TrianglesP3", "i", "iiiiiiiiiii"}, + {"TrianglesP4", "i", "iiiiiiiiiiiiiiii"}, + {"EdgesP3", "i", "iiiii"}, + {"EdgesP4", "i", "iiiiii"}, + {"IRefGroups", "i", "ciii"}, + {"DRefGroups", "i", "iii"}, + {"TetrahedraP3", "i", "iiiiiiiiiiiiiiiiiiiii"}, + {"TetrahedraP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"HexahedraQ3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"HexahedraQ4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"PyramidsP3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"PyramidsP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"PrismsP3", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"PrismsP4", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"HOSolAtEdgesP1", "i", "hr"}, + {"HOSolAtEdgesP2", "i", "hr"}, + {"HOSolAtEdgesP3", "i", "hr"}, + {"HOSolAtTrianglesP1", "i", "hr"}, + {"HOSolAtTrianglesP2", "i", "hr"}, + {"HOSolAtTrianglesP3", "i", "hr"}, + {"HOSolAtQuadrilateralsQ1", "i", "hr"}, + {"HOSolAtQuadrilateralsQ2", "i", "hr"}, + {"HOSolAtQuadrilateralsQ3", "i", "hr"}, + {"HOSolAtTetrahedraP1", "i", "hr"}, + {"HOSolAtTetrahedraP2", "i", "hr"}, + {"HOSolAtTetrahedraP3", "i", "hr"}, + {"HOSolAtPyramidsP1", "i", "hr"}, + {"HOSolAtPyramidsP2", "i", "hr"}, + {"HOSolAtPyramidsP3", "i", "hr"}, + {"HOSolAtPrismsP1", "i", "hr"}, + {"HOSolAtPrismsP2", "i", "hr"}, + {"HOSolAtPrismsP3", "i", "hr"}, + {"HOSolAtHexahedraQ1", "i", "hr"}, + {"HOSolAtHexahedraQ2", "i", "hr"}, + {"HOSolAtHexahedraQ3", "i", "hr"}, + {"BezierMode", "", "i"}, + {"ByteFlow", "i", "i"}, + {"EdgesP2Ordering", "i", "i"}, + {"EdgesP3Ordering", "i", "i"}, + {"TrianglesP2Ordering", "i", "iii"}, + {"TrianglesP3Ordering", "i", "iii"}, + {"QuadrilateralsQ2Ordering", "i", "ii"}, + {"QuadrilateralsQ3Ordering", "i", "ii"}, + {"TetrahedraP2Ordering", "i", "iiii"}, + {"TetrahedraP3Ordering", "i", "iiii"}, + {"PyramidsP2Ordering", "i", "iii"}, + {"PyramidsP3Ordering", "i", "iii"}, + {"PrismsP2Ordering", "i", "iiii"}, + {"PrismsP3Ordering", "i", "iiii"}, + {"HexahedraQ2Ordering", "i", "iii"}, + {"HexahedraQ3Ordering", "i", "iii"}, + {"EdgesP1Ordering", "i", "i"}, + {"EdgesP4Ordering", "i", "i"}, + {"TrianglesP1Ordering", "i", "iii"}, + {"TrianglesP4Ordering", "i", "iii"}, + {"QuadrilateralsQ1Ordering", "i", "ii"}, + {"QuadrilateralsQ4Ordering", "i", "ii"}, + {"TetrahedraP1Ordering", "i", "iiii"}, + {"TetrahedraP4Ordering", "i", "iiii"}, + {"PyramidsP1Ordering", "i", "iii"}, + {"PyramidsP4Ordering", "i", "iii"}, + {"PrismsP1Ordering", "i", "iiii"}, + {"PrismsP4Ordering", "i", "iiii"}, + {"HexahedraQ1Ordering", "i", "iii"}, + {"HexahedraQ4Ordering", "i", "iii"}}; #ifdef TRANSMESH -int GmfMaxRefTab[ GmfMaxKwd + 1 ]; +int GmfMaxRefTab[GmfMaxKwd + 1]; #endif - /*----------------------------------------------------------------------------*/ /* Prototypes of local procedures */ /*----------------------------------------------------------------------------*/ -static void ScaWrd (GmfMshSct *, void *); -static void ScaDblWrd(GmfMshSct *, void *); -static int64_t GetPos (GmfMshSct *); -static void RecWrd (GmfMshSct *, const void *); -static void RecDblWrd(GmfMshSct *, const void *); -static void RecBlk (GmfMshSct *, const void *, int); -static void SetPos (GmfMshSct *, int64_t); -static int ScaKwdTab(GmfMshSct *); -static void ExpFmt (GmfMshSct *, int); -static void ScaKwdHdr(GmfMshSct *, int); -static void SwpWrd (char *, int); -static int SetFilPos(GmfMshSct *, int64_t); +static void ScaWrd(GmfMshSct *, void *); +static void ScaDblWrd(GmfMshSct *, void *); +static int64_t GetPos(GmfMshSct *); +static void RecWrd(GmfMshSct *, const void *); +static void RecDblWrd(GmfMshSct *, const void *); +static void RecBlk(GmfMshSct *, const void *, int); +static void SetPos(GmfMshSct *, int64_t); +static int ScaKwdTab(GmfMshSct *); +static void ExpFmt(GmfMshSct *, int); +static void ScaKwdHdr(GmfMshSct *, int); +static void SwpWrd(char *, int); +static int SetFilPos(GmfMshSct *, int64_t); static int64_t GetFilPos(GmfMshSct *msh); static int64_t GetFilSiz(GmfMshSct *); #ifdef F77API -static void CalF77Prc(int64_t, int64_t, void *, int, void **); +static void CalF77Prc(int64_t, int64_t, void *, int, void **); #endif - /*----------------------------------------------------------------------------*/ /* Fscanf and fgets checking for errors */ /*----------------------------------------------------------------------------*/ -#define safe_fscanf(hdl, format, ptr, JmpErr) \ - do { \ - if( fscanf(hdl, format, ptr) != 1 ) \ - longjmp( JmpErr, -1); \ - } while(0) - - -#define safe_fgets(ptr, siz, hdl, JmpErr) \ - do { \ - if( fgets(ptr, siz, hdl) == NULL ) \ - longjmp( JmpErr, -1); \ - } while(0) - +#define safe_fscanf(hdl, format, ptr, JmpErr) \ + do { \ + if (fscanf(hdl, format, ptr) != 1) longjmp(JmpErr, -1); \ + } while (0) -#define safe_fread(ptr, siz, nit, str, JmpErr) \ - do { \ - if( fread(ptr, siz, nit, str) != nit ) \ - longjmp( JmpErr, -1); \ - } while(0) +#define safe_fgets(ptr, siz, hdl, JmpErr) \ + do { \ + if (fgets(ptr, siz, hdl) == NULL) longjmp(JmpErr, -1); \ + } while (0) +#define safe_fread(ptr, siz, nit, str, JmpErr) \ + do { \ + if (fread(ptr, siz, nit, str) != nit) longjmp(JmpErr, -1); \ + } while (0) /*----------------------------------------------------------------------------*/ /* Open a mesh file in read or write mode */ /*----------------------------------------------------------------------------*/ -int64_t GmfOpenMesh(const char *FilNam, int mod, ...) -{ - int KwdCod, res, *PtrVer, *PtrDim; - int64_t MshIdx; - char str[ GmfStrSiz ]; - va_list VarArg; - GmfMshSct *msh; +int64_t GmfOpenMesh(const char *FilNam, int mod, ...) { + int KwdCod, res, *PtrVer, *PtrDim; + int64_t MshIdx; + char str[GmfStrSiz]; + va_list VarArg; + GmfMshSct *msh; - /*---------------------*/ - /* MESH STRUCTURE INIT */ - /*---------------------*/ + /*---------------------*/ + /* MESH STRUCTURE INIT */ + /*---------------------*/ - if(!(msh = calloc(1, sizeof(GmfMshSct)))) - return(0); + if (!(msh = calloc(1, sizeof(GmfMshSct)))) return (0); - MshIdx = (int64_t)msh; + MshIdx = (int64_t)msh; - // Save the current stack environment for longjmp - if(setjmp(msh->err) != 0) - { - if(msh->hdl != NULL) - fclose(msh->hdl); + // Save the current stack environment for longjmp + if (setjmp(msh->err) != 0) { + if (msh->hdl != NULL) fclose(msh->hdl); - if(msh->FilDes != 0) - close(msh->FilDes); + if (msh->FilDes != 0) close(msh->FilDes); - free(msh); - return(0); - } + free(msh); + return (0); + } - // Copy the FilNam into the structure - if(strlen(FilNam) + 7 >= GmfStrSiz) - longjmp(msh->err, -1); + // Copy the FilNam into the structure + if (strlen(FilNam) + 7 >= GmfStrSiz) longjmp(msh->err, -1); - strcpy(msh->FilNam, FilNam); - - // Store the opening mod (read or write) and guess - // the filetype (binary or ascii) depending on the extension - msh->mod = mod; - msh->buf = (void *)msh->DblBuf; - msh->FltBuf = (void *)msh->DblBuf; - msh->IntBuf = (void *)msh->DblBuf; - - if(strstr(msh->FilNam, ".meshb")) - msh->typ |= (Bin | MshFil); - else if(strstr(msh->FilNam, ".mesh")) - msh->typ |= (Asc | MshFil); - else if(strstr(msh->FilNam, ".solb")) - msh->typ |= (Bin | SolFil); - else if(strstr(msh->FilNam, ".sol")) - msh->typ |= (Asc | SolFil); - else - longjmp(msh->err, -1); + strcpy(msh->FilNam, FilNam); + + // Store the opening mod (read or write) and guess + // the filetype (binary or ascii) depending on the extension + msh->mod = mod; + msh->buf = (void *)msh->DblBuf; + msh->FltBuf = (void *)msh->DblBuf; + msh->IntBuf = (void *)msh->DblBuf; - // Open the file in the required mod and initialize the mesh structure - if(msh->mod == GmfRead) - { + if (strstr(msh->FilNam, ".meshb")) + msh->typ |= (Bin | MshFil); + else if (strstr(msh->FilNam, ".mesh")) + msh->typ |= (Asc | MshFil); + else if (strstr(msh->FilNam, ".solb")) + msh->typ |= (Bin | SolFil); + else if (strstr(msh->FilNam, ".sol")) + msh->typ |= (Asc | SolFil); + else + longjmp(msh->err, -1); - /*-----------------------*/ - /* OPEN FILE FOR READING */ - /*-----------------------*/ + // Open the file in the required mod and initialize the mesh structure + if (msh->mod == GmfRead) { - va_start(VarArg, mod); - PtrVer = va_arg(VarArg, int *); - PtrDim = va_arg(VarArg, int *); - va_end(VarArg); + /*-----------------------*/ + /* OPEN FILE FOR READING */ + /*-----------------------*/ - // Read the endian coding tag, the mesh version - // and the mesh dimension (mandatory kwd) - if(msh->typ & Bin) - { - // Create the name string and open the file + va_start(VarArg, mod); + PtrVer = va_arg(VarArg, int *); + PtrDim = va_arg(VarArg, int *); + va_end(VarArg); + + // Read the endian coding tag, the mesh version + // and the mesh dimension (mandatory kwd) + if (msh->typ & Bin) { + // Create the name string and open the file #ifdef WITH_AIO - // [Bruno] added binary flag (necessary under Windows) - msh->FilDes = open(msh->FilNam, OPEN_READ_FLAGS, OPEN_READ_MODE); + // [Bruno] added binary flag (necessary under Windows) + msh->FilDes = open(msh->FilNam, OPEN_READ_FLAGS, OPEN_READ_MODE); - if(msh->FilDes <= 0) - longjmp(msh->err, -1); + if (msh->FilDes <= 0) longjmp(msh->err, -1); - // Read the endian coding tag - if(read(msh->FilDes, &msh->cod, WrdSiz) != WrdSiz) - longjmp(msh->err, -1); + // Read the endian coding tag + if (read(msh->FilDes, &msh->cod, WrdSiz) != WrdSiz) longjmp(msh->err, -1); #else - // [Bruno] added binary flag (necessary under Windows) - if(!(msh->hdl = fopen(msh->FilNam, "rb"))) - longjmp(msh->err, -1); + // [Bruno] added binary flag (necessary under Windows) + if (!(msh->hdl = fopen(msh->FilNam, "rb"))) longjmp(msh->err, -1); - // Read the endian coding tag - safe_fread(&msh->cod, WrdSiz, 1, msh->hdl, msh->err); + // Read the endian coding tag + safe_fread(&msh->cod, WrdSiz, 1, msh->hdl, msh->err); #endif - // Read the mesh version and the mesh dimension (mandatory kwd) - if( (msh->cod != 1) && (msh->cod != 16777216) ) - longjmp(msh->err, -1); + // Read the mesh version and the mesh dimension (mandatory kwd) + if ((msh->cod != 1) && (msh->cod != 16777216)) longjmp(msh->err, -1); - ScaWrd(msh, (unsigned char *)&msh->ver); + ScaWrd(msh, (unsigned char *)&msh->ver); - if( (msh->ver < 1) || (msh->ver > 4) ) - longjmp(msh->err, -1); + if ((msh->ver < 1) || (msh->ver > 4)) longjmp(msh->err, -1); - if( (msh->ver >= 3) && (sizeof(int64_t) != 8) ) - longjmp(msh->err, -1); + if ((msh->ver >= 3) && (sizeof(int64_t) != 8)) longjmp(msh->err, -1); - ScaWrd(msh, (unsigned char *)&KwdCod); + ScaWrd(msh, (unsigned char *)&KwdCod); - if(KwdCod != GmfDimension) - longjmp(msh->err, -1); + if (KwdCod != GmfDimension) longjmp(msh->err, -1); - GetPos(msh); - ScaWrd(msh, (unsigned char *)&msh->dim); - } - else - { - // Create the name string and open the file - if(!(msh->hdl = fopen(msh->FilNam, "rb"))) - longjmp(msh->err, -1); + GetPos(msh); + ScaWrd(msh, (unsigned char *)&msh->dim); + } else { + // Create the name string and open the file + if (!(msh->hdl = fopen(msh->FilNam, "rb"))) longjmp(msh->err, -1); - do - { - res = fscanf(msh->hdl, "%s", str); - }while( (res != EOF) && strcmp(str, "MeshVersionFormatted") ); + do { + res = fscanf(msh->hdl, "%s", str); + } while ((res != EOF) && strcmp(str, "MeshVersionFormatted")); - if(res == EOF) - longjmp(msh->err, -1); + if (res == EOF) longjmp(msh->err, -1); - safe_fscanf(msh->hdl, "%d", &msh->ver, msh->err); + safe_fscanf(msh->hdl, "%d", &msh->ver, msh->err); - if( (msh->ver < 1) || (msh->ver > 4) ) - longjmp(msh->err, -1); + if ((msh->ver < 1) || (msh->ver > 4)) longjmp(msh->err, -1); - do - { - res = fscanf(msh->hdl, "%s", str); - }while( (res != EOF) && strcmp(str, "Dimension") ); + do { + res = fscanf(msh->hdl, "%s", str); + } while ((res != EOF) && strcmp(str, "Dimension")); - if(res == EOF) - longjmp(msh->err, -1); + if (res == EOF) longjmp(msh->err, -1); - safe_fscanf(msh->hdl, "%d", &msh->dim, msh->err); - } + safe_fscanf(msh->hdl, "%d", &msh->dim, msh->err); + } - if( (msh->dim != 2) && (msh->dim != 3) ) - longjmp(msh->err, -1); + if ((msh->dim != 2) && (msh->dim != 3)) longjmp(msh->err, -1); - (*PtrVer) = msh->ver; - (*PtrDim) = msh->dim; + (*PtrVer) = msh->ver; + (*PtrDim) = msh->dim; - /*------------*/ - /* KW READING */ - /*------------*/ + /*------------*/ + /* KW READING */ + /*------------*/ - // Read the list of kw present in the file - if(!ScaKwdTab(msh)) - return(0); + // Read the list of kw present in the file + if (!ScaKwdTab(msh)) return (0); - return(MshIdx); - } - else if(msh->mod == GmfWrite) - { + return (MshIdx); + } else if (msh->mod == GmfWrite) { - /*-----------------------*/ - /* OPEN FILE FOR WRITING */ - /*-----------------------*/ + /*-----------------------*/ + /* OPEN FILE FOR WRITING */ + /*-----------------------*/ - msh->cod = 1; + msh->cod = 1; - // Check if the user provided a valid version number and dimension - va_start(VarArg, mod); - msh->ver = va_arg(VarArg, int); - msh->dim = va_arg(VarArg, int); - va_end(VarArg); + // Check if the user provided a valid version number and dimension + va_start(VarArg, mod); + msh->ver = va_arg(VarArg, int); + msh->dim = va_arg(VarArg, int); + va_end(VarArg); - if( (msh->ver < 1) || (msh->ver > 4) ) - longjmp(msh->err, -1); + if ((msh->ver < 1) || (msh->ver > 4)) longjmp(msh->err, -1); - if( (msh->ver >= 3) && (sizeof(int64_t) != 8) ) - longjmp(msh->err, -1); + if ((msh->ver >= 3) && (sizeof(int64_t) != 8)) longjmp(msh->err, -1); - if( (msh->dim != 2) && (msh->dim != 3) ) - longjmp(msh->err, -1); + if ((msh->dim != 2) && (msh->dim != 3)) longjmp(msh->err, -1); - // Create the mesh file - if(msh->typ & Bin) - { - /* - * [Bruno] replaced previous call to creat(): - * with a call to open(), because Windows needs the - * binary flag to be specified. - */ + // Create the mesh file + if (msh->typ & Bin) { + /* + * [Bruno] replaced previous call to creat(): + * with a call to open(), because Windows needs the + * binary flag to be specified. + */ #ifdef WITH_AIO - msh->FilDes = open(msh->FilNam, OPEN_WRITE_FLAGS, OPEN_WRITE_MODE); + msh->FilDes = open(msh->FilNam, OPEN_WRITE_FLAGS, OPEN_WRITE_MODE); - if(msh->FilDes <= 0) - longjmp(msh->err, -1); + if (msh->FilDes <= 0) longjmp(msh->err, -1); #else - if(!(msh->hdl = fopen(msh->FilNam, "wb"))) - longjmp(msh->err, -1); + if (!(msh->hdl = fopen(msh->FilNam, "wb"))) longjmp(msh->err, -1); #endif - } - else if(!(msh->hdl = fopen(msh->FilNam, "wb"))) - longjmp(msh->err, -1); - - - /*------------*/ - /* KW WRITING */ - /*------------*/ - - // Write the mesh version and dimension - if(msh->typ & Asc) - { - fprintf(msh->hdl, "%s %d\n\n", - GmfKwdFmt[ GmfVersionFormatted ][0], msh->ver); - fprintf(msh->hdl, "%s %d\n", - GmfKwdFmt[ GmfDimension ][0], msh->dim); - } - else - { - RecWrd(msh, (unsigned char *)&msh->cod); - RecWrd(msh, (unsigned char *)&msh->ver); - GmfSetKwd(MshIdx, GmfDimension, 0); - RecWrd(msh, (unsigned char *)&msh->dim); - } + } else if (!(msh->hdl = fopen(msh->FilNam, "wb"))) + longjmp(msh->err, -1); - return(MshIdx); - } - else - { - free(msh); - return(0); - } + /*------------*/ + /* KW WRITING */ + /*------------*/ + + // Write the mesh version and dimension + if (msh->typ & Asc) { + fprintf(msh->hdl, "%s %d\n\n", GmfKwdFmt[GmfVersionFormatted][0], msh->ver); + fprintf(msh->hdl, "%s %d\n", GmfKwdFmt[GmfDimension][0], msh->dim); + } else { + RecWrd(msh, (unsigned char *)&msh->cod); + RecWrd(msh, (unsigned char *)&msh->ver); + GmfSetKwd(MshIdx, GmfDimension, 0); + RecWrd(msh, (unsigned char *)&msh->dim); + } + + return (MshIdx); + } else { + free(msh); + return (0); + } } - /*----------------------------------------------------------------------------*/ /* Close a meshfile in the right way */ /*----------------------------------------------------------------------------*/ -int GmfCloseMesh(int64_t MshIdx) -{ - int res = 1; - GmfMshSct *msh = (GmfMshSct *)MshIdx; +int GmfCloseMesh(int64_t MshIdx) { + int res = 1; + GmfMshSct *msh = (GmfMshSct *)MshIdx; - RecBlk(msh, msh->buf, 0); + RecBlk(msh, msh->buf, 0); - // In write down the "End" kw in write mode - if(msh->mod == GmfWrite) - { - if(msh->typ & Asc) - fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[ GmfEnd ][0]); - else - GmfSetKwd(MshIdx, GmfEnd, 0); - } + // In write down the "End" kw in write mode + if (msh->mod == GmfWrite) { + if (msh->typ & Asc) + fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[GmfEnd][0]); + else + GmfSetKwd(MshIdx, GmfEnd, 0); + } - // Close the file and free the mesh structure - if(msh->typ & Bin) + // Close the file and free the mesh structure + if (msh->typ & Bin) #ifdef WITH_AIO - close(msh->FilDes); + close(msh->FilDes); #else - fclose(msh->hdl); + fclose(msh->hdl); #endif - else if(fclose(msh->hdl)) - res = 0; + else if (fclose(msh->hdl)) + res = 0; - free(msh); + free(msh); - return(res); + return (res); } - /*----------------------------------------------------------------------------*/ /* Read the number of lines and set the position to this kwd */ /*----------------------------------------------------------------------------*/ -int64_t GmfStatKwd(int64_t MshIdx, int KwdCod, ...) -{ - int i, *PtrNmbTyp, *PtrSolSiz, *TypTab, *PtrDeg, *PtrNmbNod; - GmfMshSct *msh = (GmfMshSct *)MshIdx; - KwdSct *kwd; - va_list VarArg; +int64_t GmfStatKwd(int64_t MshIdx, int KwdCod, ...) { + int i, *PtrNmbTyp, *PtrSolSiz, *TypTab, *PtrDeg, *PtrNmbNod; + GmfMshSct *msh = (GmfMshSct *)MshIdx; + KwdSct *kwd; + va_list VarArg; - if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) - return(0); + if ((KwdCod < 1) || (KwdCod > GmfMaxKwd)) return (0); - kwd = &msh->KwdTab[ KwdCod ]; + kwd = &msh->KwdTab[KwdCod]; - if(!kwd->NmbLin) - return(0); + if (!kwd->NmbLin) return (0); - // Read further arguments if this kw is a sol - if(kwd->typ == SolKwd) - { - va_start(VarArg, KwdCod); + // Read further arguments if this kw is a sol + if (kwd->typ == SolKwd) { + va_start(VarArg, KwdCod); - PtrNmbTyp = va_arg(VarArg, int *); - *PtrNmbTyp = kwd->NmbTyp; + PtrNmbTyp = va_arg(VarArg, int *); + *PtrNmbTyp = kwd->NmbTyp; - PtrSolSiz = va_arg(VarArg, int *); - *PtrSolSiz = kwd->SolSiz; + PtrSolSiz = va_arg(VarArg, int *); + *PtrSolSiz = kwd->SolSiz; - TypTab = va_arg(VarArg, int *); + TypTab = va_arg(VarArg, int *); - for(i=0;iNmbTyp;i++) - TypTab[i] = kwd->TypTab[i]; + for (i = 0; i < kwd->NmbTyp; i++) TypTab[i] = kwd->TypTab[i]; - // Add two extra paramaters for HO elements: degree and nmb nodes - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2]) ) - { - PtrDeg = va_arg(VarArg, int *); - *PtrDeg = kwd->deg; - - PtrNmbNod = va_arg(VarArg, int *); - *PtrNmbNod = kwd->NmbNod; - } + // Add two extra paramaters for HO elements: degree and nmb nodes + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) { + PtrDeg = va_arg(VarArg, int *); + *PtrDeg = kwd->deg; - va_end(VarArg); - } + PtrNmbNod = va_arg(VarArg, int *); + *PtrNmbNod = kwd->NmbNod; + } - return(kwd->NmbLin); -} + va_end(VarArg); + } + return (kwd->NmbLin); +} /*----------------------------------------------------------------------------*/ /* Set the current file position to a given kwd */ /*----------------------------------------------------------------------------*/ -int GmfGotoKwd(int64_t MshIdx, int KwdCod) -{ - GmfMshSct *msh = (GmfMshSct *)MshIdx; - KwdSct *kwd = &msh->KwdTab[ KwdCod ]; +int GmfGotoKwd(int64_t MshIdx, int KwdCod) { + GmfMshSct *msh = (GmfMshSct *)MshIdx; + KwdSct *kwd = &msh->KwdTab[KwdCod]; - if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) || !kwd->NmbLin ) - return(0); + if ((KwdCod < 1) || (KwdCod > GmfMaxKwd) || !kwd->NmbLin) return (0); - return(SetFilPos(msh, kwd->pos)); + return (SetFilPos(msh, kwd->pos)); } - /*----------------------------------------------------------------------------*/ /* Write the kwd and set the number of lines */ /*----------------------------------------------------------------------------*/ -int GmfSetKwd(int64_t MshIdx, int KwdCod, int64_t NmbLin, ...) -{ - int i, *TypTab; - int64_t CurPos; - va_list VarArg; - GmfMshSct *msh = (GmfMshSct *)MshIdx; - KwdSct *kwd; - - RecBlk(msh, msh->buf, 0); - - if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) - return(0); - - kwd = &msh->KwdTab[ KwdCod ]; - - // Read further arguments if this kw is a solution - if(!strcmp(GmfKwdFmt[ KwdCod ][2], "sr") - || !strcmp(GmfKwdFmt[ KwdCod ][2], "hr")) - { - va_start(VarArg, NmbLin); +int GmfSetKwd(int64_t MshIdx, int KwdCod, int64_t NmbLin, ...) { + int i, *TypTab; + int64_t CurPos; + va_list VarArg; + GmfMshSct *msh = (GmfMshSct *)MshIdx; + KwdSct *kwd; - kwd->NmbTyp = va_arg(VarArg, int); - TypTab = va_arg(VarArg, int *); + RecBlk(msh, msh->buf, 0); - for(i=0;iNmbTyp;i++) - kwd->TypTab[i] = TypTab[i]; + if ((KwdCod < 1) || (KwdCod > GmfMaxKwd)) return (0); - // Add two extra paramaters for HO elements: degree and nmb nodes - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2])) - { - kwd->deg = va_arg(VarArg, int); - kwd->NmbNod = va_arg(VarArg, int); - } + kwd = &msh->KwdTab[KwdCod]; - va_end(VarArg); - } + // Read further arguments if this kw is a solution + if (!strcmp(GmfKwdFmt[KwdCod][2], "sr") || !strcmp(GmfKwdFmt[KwdCod][2], "hr")) { + va_start(VarArg, NmbLin); - // Setup the kwd info - ExpFmt(msh, KwdCod); + kwd->NmbTyp = va_arg(VarArg, int); + TypTab = va_arg(VarArg, int *); - if(!kwd->typ) - return(0); - else if(kwd->typ == InfKwd) - kwd->NmbLin = 1; - else - kwd->NmbLin = NmbLin; + for (i = 0; i < kwd->NmbTyp; i++) kwd->TypTab[i] = TypTab[i]; - // Store the next kwd position in binary file - if( (msh->typ & Bin) && msh->NexKwdPos ) - { - CurPos = GetFilPos(msh); + // Add two extra paramaters for HO elements: degree and nmb nodes + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) { + kwd->deg = va_arg(VarArg, int); + kwd->NmbNod = va_arg(VarArg, int); + } - if(!SetFilPos(msh, msh->NexKwdPos)) - return(0); + va_end(VarArg); + } - SetPos(msh, CurPos); + // Setup the kwd info + ExpFmt(msh, KwdCod); - if(!SetFilPos(msh, CurPos)) - return(0); - } + if (!kwd->typ) + return (0); + else if (kwd->typ == InfKwd) + kwd->NmbLin = 1; + else + kwd->NmbLin = NmbLin; - // Write the header - if(msh->typ & Asc) - { - fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[ KwdCod ][0]); + // Store the next kwd position in binary file + if ((msh->typ & Bin) && msh->NexKwdPos) { + CurPos = GetFilPos(msh); - if(kwd->typ != InfKwd) - fprintf(msh->hdl, INT64_T_FMT"\n", kwd->NmbLin); + if (!SetFilPos(msh, msh->NexKwdPos)) return (0); - // In case of solution field, write the extended header - if(kwd->typ == SolKwd) - { - fprintf(msh->hdl, "%d ", kwd->NmbTyp); + SetPos(msh, CurPos); - for(i=0;iNmbTyp;i++) - fprintf(msh->hdl, "%d ", kwd->TypTab[i]); + if (!SetFilPos(msh, CurPos)) return (0); + } - fprintf(msh->hdl, "\n"); - } + // Write the header + if (msh->typ & Asc) { + fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[KwdCod][0]); - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2])) - fprintf(msh->hdl, "%d %d\n", kwd->deg, kwd->NmbNod); - } - else - { - RecWrd(msh, (unsigned char *)&KwdCod); - msh->NexKwdPos = GetFilPos(msh); - SetPos(msh, 0); - - if(kwd->typ != InfKwd) - { - if(msh->ver < 4) - { - i = (int)kwd->NmbLin; - RecWrd(msh, (unsigned char *)&i); - } - else - RecDblWrd(msh, (unsigned char *)&kwd->NmbLin); - } + if (kwd->typ != InfKwd) fprintf(msh->hdl, INT64_T_FMT "\n", kwd->NmbLin); - // In case of solution field, write the extended header at once - if(kwd->typ == SolKwd) - { - RecWrd(msh, (unsigned char *)&kwd->NmbTyp); + // In case of solution field, write the extended header + if (kwd->typ == SolKwd) { + fprintf(msh->hdl, "%d ", kwd->NmbTyp); - for(i=0;iNmbTyp;i++) - RecWrd(msh, (unsigned char *)&kwd->TypTab[i]); + for (i = 0; i < kwd->NmbTyp; i++) fprintf(msh->hdl, "%d ", kwd->TypTab[i]); - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2])) - { - RecWrd(msh, (unsigned char *)&kwd->deg); - RecWrd(msh, (unsigned char *)&kwd->NmbNod); - } + fprintf(msh->hdl, "\n"); + } + + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) fprintf(msh->hdl, "%d %d\n", kwd->deg, kwd->NmbNod); + } else { + RecWrd(msh, (unsigned char *)&KwdCod); + msh->NexKwdPos = GetFilPos(msh); + SetPos(msh, 0); + + if (kwd->typ != InfKwd) { + if (msh->ver < 4) { + i = (int)kwd->NmbLin; + RecWrd(msh, (unsigned char *)&i); + } else + RecDblWrd(msh, (unsigned char *)&kwd->NmbLin); + } + + // In case of solution field, write the extended header at once + if (kwd->typ == SolKwd) { + RecWrd(msh, (unsigned char *)&kwd->NmbTyp); + + for (i = 0; i < kwd->NmbTyp; i++) RecWrd(msh, (unsigned char *)&kwd->TypTab[i]); + + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) { + RecWrd(msh, (unsigned char *)&kwd->deg); + RecWrd(msh, (unsigned char *)&kwd->NmbNod); } - } + } + } - // Reset write buffer position - msh->pos = 0; + // Reset write buffer position + msh->pos = 0; - // Compute the total file size and check if it crosses the 2GB threshold - msh->siz += kwd->NmbLin * kwd->NmbWrd * WrdSiz; + // Compute the total file size and check if it crosses the 2GB threshold + msh->siz += kwd->NmbLin * kwd->NmbWrd * WrdSiz; - return(1); + return (1); } - /*----------------------------------------------------------------------------*/ /* Read a full line from the current kwd */ /*----------------------------------------------------------------------------*/ -int NAMF77(GmfGetLin, gmfgetlin)(TYPF77(int64_t)MshIdx, TYPF77(int)KwdCod, ...) -{ - int i; - float *FltSolTab, FltVal, *PtrFlt; - double *DblSolTab, *PtrDbl; - va_list VarArg; - GmfMshSct *msh = (GmfMshSct *) VALF77(MshIdx); - KwdSct *kwd = &msh->KwdTab[ VALF77(KwdCod) ]; - - if( (VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd) ) - return(0); - - // Save the current stack environment for longjmp - if(setjmp(msh->err) != 0) - return(0); - - // Start decoding the arguments - va_start(VarArg, KwdCod); - - switch(kwd->typ) - { - case InfKwd : case RegKwd : case CmtKwd : - { - if(msh->typ & Asc) - { - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - { - if(msh->ver <= 1) - { - safe_fscanf(msh->hdl, "%f", &FltVal, msh->err); - PtrDbl = va_arg(VarArg, double *); - PtrFlt = (float *)PtrDbl; - *PtrFlt = FltVal; - } - else - { - safe_fscanf(msh->hdl, "%lf", - va_arg(VarArg, double *), msh->err); - } - } - else if(kwd->fmt[i] == 'i') - { - if(msh->ver <= 3) - { - safe_fscanf(msh->hdl, "%d", - va_arg(VarArg, int *), msh->err); - } - else - { - // [Bruno] %ld -> INT64_T_FMT - safe_fscanf(msh->hdl, INT64_T_FMT, - va_arg(VarArg, int64_t *), msh->err); - } - } - else if(kwd->fmt[i] == 'c') - { - safe_fgets( va_arg(VarArg, char *), - WrdSiz * FilStrSiz, msh->hdl, msh->err); - } +int NAMF77(GmfGetLin, gmfgetlin)(TYPF77(int64_t) MshIdx, TYPF77(int) KwdCod, ...) { + int i; + float *FltSolTab, FltVal, *PtrFlt; + double *DblSolTab, *PtrDbl; + va_list VarArg; + GmfMshSct *msh = (GmfMshSct *)VALF77(MshIdx); + KwdSct *kwd = &msh->KwdTab[VALF77(KwdCod)]; + + if ((VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd)) return (0); + + // Save the current stack environment for longjmp + if (setjmp(msh->err) != 0) return (0); + + // Start decoding the arguments + va_start(VarArg, KwdCod); + + switch (kwd->typ) { + case InfKwd: + case RegKwd: + case CmtKwd: { + if (msh->typ & Asc) { + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') { + if (msh->ver <= 1) { + safe_fscanf(msh->hdl, "%f", &FltVal, msh->err); + PtrDbl = va_arg(VarArg, double *); + PtrFlt = (float *)PtrDbl; + *PtrFlt = FltVal; + } else { + safe_fscanf(msh->hdl, "%lf", va_arg(VarArg, double *), msh->err); + } + } else if (kwd->fmt[i] == 'i') { + if (msh->ver <= 3) { + safe_fscanf(msh->hdl, "%d", va_arg(VarArg, int *), msh->err); + } else { + // [Bruno] %ld -> INT64_T_FMT + safe_fscanf(msh->hdl, INT64_T_FMT, va_arg(VarArg, int64_t *), msh->err); } - } - else - { - for(i=0;iSolSiz;i++) - if(kwd->fmt[i] == 'r') - if(msh->ver <= 1) - ScaWrd(msh, (unsigned char *)va_arg(VarArg, float *)); - else - ScaDblWrd(msh, (unsigned char *)va_arg(VarArg, double *)); - else if(kwd->fmt[i] == 'i') - if(msh->ver <= 3) - ScaWrd(msh, (unsigned char *)va_arg(VarArg, int *)); - else - ScaDblWrd(msh, (unsigned char *)va_arg(VarArg, int64_t *)); - else if(kwd->fmt[i] == 'c') - // [Bruno] added error control - safe_fread(va_arg(VarArg, char *), WrdSiz, FilStrSiz, msh->hdl, msh->err); - } - }break; - - case SolKwd : - { - if(msh->ver == 1) - { - FltSolTab = va_arg(VarArg, float *); - - if(msh->typ & Asc) - for(i=0; iSolSiz; i++) - safe_fscanf(msh->hdl, "%f", &FltSolTab[i], msh->err); + } else if (kwd->fmt[i] == 'c') { + safe_fgets(va_arg(VarArg, char *), WrdSiz * FilStrSiz, msh->hdl, msh->err); + } + } + } else { + for (i = 0; i < kwd->SolSiz; i++) + if (kwd->fmt[i] == 'r') + if (msh->ver <= 1) + ScaWrd(msh, (unsigned char *)va_arg(VarArg, float *)); else - for(i=0; iSolSiz; i++) - ScaWrd(msh, (unsigned char *)&FltSolTab[i]); - } - else - { - DblSolTab = va_arg(VarArg, double *); - - if(msh->typ & Asc) - for(i=0; iSolSiz; i++) - safe_fscanf(msh->hdl, "%lf", &DblSolTab[i], msh->err); + ScaDblWrd(msh, (unsigned char *)va_arg(VarArg, double *)); + else if (kwd->fmt[i] == 'i') + if (msh->ver <= 3) + ScaWrd(msh, (unsigned char *)va_arg(VarArg, int *)); else - for(i=0; iSolSiz; i++) - ScaDblWrd(msh, (unsigned char *)&DblSolTab[i]); - } - }break; - } + ScaDblWrd(msh, (unsigned char *)va_arg(VarArg, int64_t *)); + else if (kwd->fmt[i] == 'c') + // [Bruno] added error control + safe_fread(va_arg(VarArg, char *), WrdSiz, FilStrSiz, msh->hdl, msh->err); + } + } break; + + case SolKwd: { + if (msh->ver == 1) { + FltSolTab = va_arg(VarArg, float *); + + if (msh->typ & Asc) + for (i = 0; i < kwd->SolSiz; i++) safe_fscanf(msh->hdl, "%f", &FltSolTab[i], msh->err); + else + for (i = 0; i < kwd->SolSiz; i++) ScaWrd(msh, (unsigned char *)&FltSolTab[i]); + } else { + DblSolTab = va_arg(VarArg, double *); + + if (msh->typ & Asc) + for (i = 0; i < kwd->SolSiz; i++) safe_fscanf(msh->hdl, "%lf", &DblSolTab[i], msh->err); + else + for (i = 0; i < kwd->SolSiz; i++) ScaDblWrd(msh, (unsigned char *)&DblSolTab[i]); + } + } break; + } - va_end(VarArg); + va_end(VarArg); - return(1); + return (1); } - /*----------------------------------------------------------------------------*/ /* Write a full line from the current kwd */ /*----------------------------------------------------------------------------*/ -int NAMF77(GmfSetLin, gmfsetlin)(TYPF77(int64_t) MshIdx, TYPF77(int) KwdCod, ...) -{ - int i, pos, *IntBuf; - int64_t *LngBuf; - float *FltSolTab, *FltBuf; - double *DblSolTab, *DblBuf; - va_list VarArg; - GmfMshSct *msh = (GmfMshSct *) VALF77(MshIdx); - KwdSct *kwd = &msh->KwdTab[ VALF77(KwdCod) ]; - - if( ( VALF77(KwdCod) < 1) || ( VALF77(KwdCod) > GmfMaxKwd) ) - return(0); - - // Start decoding the arguments - va_start(VarArg, KwdCod); - - if(kwd->typ != SolKwd) - { - if(msh->typ & Asc) - { - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - { - if(msh->ver <= 1) +int NAMF77(GmfSetLin, gmfsetlin)(TYPF77(int64_t) MshIdx, TYPF77(int) KwdCod, ...) { + int i, pos, *IntBuf; + int64_t *LngBuf; + float *FltSolTab, *FltBuf; + double *DblSolTab, *DblBuf; + va_list VarArg; + GmfMshSct *msh = (GmfMshSct *)VALF77(MshIdx); + KwdSct *kwd = &msh->KwdTab[VALF77(KwdCod)]; + + if ((VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd)) return (0); + + // Start decoding the arguments + va_start(VarArg, KwdCod); + + if (kwd->typ != SolKwd) { + if (msh->typ & Asc) { + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') { + if (msh->ver <= 1) #ifdef F77API - fprintf(msh->hdl, "%g ", *(va_arg(VarArg, float *))); + fprintf(msh->hdl, "%g ", *(va_arg(VarArg, float *))); #else - fprintf(msh->hdl, "%g ", va_arg(VarArg, double)); + fprintf(msh->hdl, "%g ", va_arg(VarArg, double)); #endif - else - fprintf(msh->hdl, "%.15g ", VALF77(va_arg(VarArg, TYPF77(double)))); - } - else if(kwd->fmt[i] == 'i') - { - if(msh->ver <= 3) - fprintf(msh->hdl, "%d ", VALF77(va_arg(VarArg, TYPF77(int)))); - else - { - // [Bruno] %ld -> INT64_T_FMT - fprintf( msh->hdl, INT64_T_FMT " ", - VALF77(va_arg(VarArg, TYPF77(int64_t)))); - } - } - else if(kwd->fmt[i] == 'c') - fprintf(msh->hdl, "%s ", va_arg(VarArg, char *)); - } + else + fprintf(msh->hdl, "%.15g ", VALF77(va_arg(VarArg, TYPF77(double)))); + } else if (kwd->fmt[i] == 'i') { + if (msh->ver <= 3) + fprintf(msh->hdl, "%d ", VALF77(va_arg(VarArg, TYPF77(int)))); + else { + // [Bruno] %ld -> INT64_T_FMT + fprintf(msh->hdl, INT64_T_FMT " ", VALF77(va_arg(VarArg, TYPF77(int64_t)))); + } + } else if (kwd->fmt[i] == 'c') + fprintf(msh->hdl, "%s ", va_arg(VarArg, char *)); } - else - { - pos = 0; - - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - { - if(msh->ver <= 1) - { - FltBuf = (void *)&msh->buf[ pos ]; + } else { + pos = 0; + + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') { + if (msh->ver <= 1) { + FltBuf = (void *)&msh->buf[pos]; #ifdef F77API - *FltBuf = (float)*(va_arg(VarArg, float *)); + *FltBuf = (float)*(va_arg(VarArg, float *)); #else - *FltBuf = (float)va_arg(VarArg, double); + *FltBuf = (float)va_arg(VarArg, double); #endif - pos += 4; - } - else - { - DblBuf = (void *)&msh->buf[ pos ]; - *DblBuf = VALF77(va_arg(VarArg, TYPF77(double))); - pos += 8; - } - } - else if(kwd->fmt[i] == 'i') - { - if(msh->ver <= 3) - { - IntBuf = (void *)&msh->buf[ pos ]; - *IntBuf = VALF77(va_arg(VarArg, TYPF77(int))); - pos += 4; - } - else - { - LngBuf = (void *)&msh->buf[ pos ]; - *LngBuf = VALF77(va_arg(VarArg, TYPF77(int64_t))); - pos += 8; - } - } - else if(kwd->fmt[i] == 'c') - { - memset(&msh->buf[ pos ], 0, FilStrSiz * WrdSiz); - strncpy(&msh->buf[ pos ], va_arg(VarArg, char *), FilStrSiz * WrdSiz); - pos += FilStrSiz; - } - } - - RecBlk(msh, msh->buf, kwd->NmbWrd); - } - } - else - { - if(msh->ver == 1) - { - FltSolTab = va_arg(VarArg, float *); - - if(msh->typ & Asc) - for(i=0; iSolSiz; i++) - fprintf(msh->hdl, "%g ", (double)FltSolTab[i]); - else - RecBlk(msh, (unsigned char *)FltSolTab, kwd->NmbWrd); + pos += 4; + } else { + DblBuf = (void *)&msh->buf[pos]; + *DblBuf = VALF77(va_arg(VarArg, TYPF77(double))); + pos += 8; + } + } else if (kwd->fmt[i] == 'i') { + if (msh->ver <= 3) { + IntBuf = (void *)&msh->buf[pos]; + *IntBuf = VALF77(va_arg(VarArg, TYPF77(int))); + pos += 4; + } else { + LngBuf = (void *)&msh->buf[pos]; + *LngBuf = VALF77(va_arg(VarArg, TYPF77(int64_t))); + pos += 8; + } + } else if (kwd->fmt[i] == 'c') { + memset(&msh->buf[pos], 0, FilStrSiz * WrdSiz); + strncpy(&msh->buf[pos], va_arg(VarArg, char *), FilStrSiz * WrdSiz); + pos += FilStrSiz; + } } + + RecBlk(msh, msh->buf, kwd->NmbWrd); + } + } else { + if (msh->ver == 1) { + FltSolTab = va_arg(VarArg, float *); + + if (msh->typ & Asc) + for (i = 0; i < kwd->SolSiz; i++) fprintf(msh->hdl, "%g ", (double)FltSolTab[i]); else - { - DblSolTab = va_arg(VarArg, double *); - - if(msh->typ & Asc) - for(i=0; iSolSiz; i++) - fprintf(msh->hdl, "%.15g ", DblSolTab[i]); - else - RecBlk(msh, (unsigned char *)DblSolTab, kwd->NmbWrd); - } - } + RecBlk(msh, (unsigned char *)FltSolTab, kwd->NmbWrd); + } else { + DblSolTab = va_arg(VarArg, double *); + + if (msh->typ & Asc) + for (i = 0; i < kwd->SolSiz; i++) fprintf(msh->hdl, "%.15g ", DblSolTab[i]); + else + RecBlk(msh, (unsigned char *)DblSolTab, kwd->NmbWrd); + } + } - va_end(VarArg); + va_end(VarArg); - if(msh->typ & Asc) - fprintf(msh->hdl, "\n"); + if (msh->typ & Asc) fprintf(msh->hdl, "\n"); - return(1); + return (1); } - /*----------------------------------------------------------------------------*/ /* Private procedure for transmesh : copy a whole line */ /*----------------------------------------------------------------------------*/ #ifdef TRANSMESH -int GmfCpyLin(int64_t InpIdx, int64_t OutIdx, int KwdCod) -{ - char s[ WrdSiz * FilStrSiz ]; - double d; - float f; - int i, a; - int64_t l; - GmfMshSct *InpMsh = (GmfMshSct *)InpIdx, *OutMsh = (GmfMshSct *)OutIdx; - KwdSct *kwd = &InpMsh->KwdTab[ KwdCod ]; - - // Save the current stack environment for longjmp - if(setjmp(InpMsh->err) != 0) - return(0); - - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - { - if(InpMsh->ver == 1) - { - if(InpMsh->typ & Asc) - safe_fscanf(InpMsh->hdl, "%f", &f, InpMsh->err); - else - ScaWrd(InpMsh, (unsigned char *)&f); - - d = (double)f; - } - else - { - if(InpMsh->typ & Asc) - safe_fscanf(InpMsh->hdl, "%lf", &d, InpMsh->err); - else - ScaDblWrd(InpMsh, (unsigned char *)&d); - - f = (float)d; - } - - if(OutMsh->ver == 1) - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, "%g ", (double)f); - else - RecWrd(OutMsh, (unsigned char *)&f); - else - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, "%.15g ", d); - else - RecDblWrd(OutMsh, (unsigned char *)&d); +int GmfCpyLin(int64_t InpIdx, int64_t OutIdx, int KwdCod) { + char s[WrdSiz * FilStrSiz]; + double d; + float f; + int i, a; + int64_t l; + GmfMshSct *InpMsh = (GmfMshSct *)InpIdx, *OutMsh = (GmfMshSct *)OutIdx; + KwdSct *kwd = &InpMsh->KwdTab[KwdCod]; + + // Save the current stack environment for longjmp + if (setjmp(InpMsh->err) != 0) return (0); + + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') { + if (InpMsh->ver == 1) { + if (InpMsh->typ & Asc) + safe_fscanf(InpMsh->hdl, "%f", &f, InpMsh->err); + else + ScaWrd(InpMsh, (unsigned char *)&f); + + d = (double)f; + } else { + if (InpMsh->typ & Asc) + safe_fscanf(InpMsh->hdl, "%lf", &d, InpMsh->err); + else + ScaDblWrd(InpMsh, (unsigned char *)&d); + + f = (float)d; } - else if(kwd->fmt[i] == 'i') - { - if(InpMsh->ver <= 3) - { - if(InpMsh->typ & Asc) - safe_fscanf(InpMsh->hdl, "%d", &a, InpMsh->err); - else - ScaWrd(InpMsh, (unsigned char *)&a); - - l = (int64_t)a; - } - else - { - if(InpMsh->typ & Asc) - safe_fscanf(InpMsh->hdl, INT64_T_FMT, &l, InpMsh->err); - else - ScaDblWrd(InpMsh, (unsigned char *)&l); - - a = (int)l; - } - if( (i == kwd->SolSiz-1) && (a > GmfMaxRefTab[ KwdCod ]) ) - GmfMaxRefTab[ KwdCod ] = a; + if (OutMsh->ver == 1) + if (OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%g ", (double)f); + else + RecWrd(OutMsh, (unsigned char *)&f); + else if (OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%.15g ", d); + else + RecDblWrd(OutMsh, (unsigned char *)&d); + } else if (kwd->fmt[i] == 'i') { + if (InpMsh->ver <= 3) { + if (InpMsh->typ & Asc) + safe_fscanf(InpMsh->hdl, "%d", &a, InpMsh->err); + else + ScaWrd(InpMsh, (unsigned char *)&a); + + l = (int64_t)a; + } else { + if (InpMsh->typ & Asc) + safe_fscanf(InpMsh->hdl, INT64_T_FMT, &l, InpMsh->err); + else + ScaDblWrd(InpMsh, (unsigned char *)&l); + + a = (int)l; + } - if(OutMsh->ver <= 3) - { - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, "%d ", a); - else - RecWrd(OutMsh, (unsigned char *)&a); - } - else - { - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, INT64_T_FMT" ", l); - else - RecDblWrd(OutMsh, (unsigned char *)&l); - } + if ((i == kwd->SolSiz - 1) && (a > GmfMaxRefTab[KwdCod])) GmfMaxRefTab[KwdCod] = a; + + if (OutMsh->ver <= 3) { + if (OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%d ", a); + else + RecWrd(OutMsh, (unsigned char *)&a); + } else { + if (OutMsh->typ & Asc) + fprintf(OutMsh->hdl, INT64_T_FMT " ", l); + else + RecDblWrd(OutMsh, (unsigned char *)&l); } - else if(kwd->fmt[i] == 'c') - { - memset(s, 0, FilStrSiz * WrdSiz); + } else if (kwd->fmt[i] == 'c') { + memset(s, 0, FilStrSiz * WrdSiz); - if(InpMsh->typ & Asc) - safe_fgets(s, WrdSiz * FilStrSiz, InpMsh->hdl, InpMsh->err); - else + if (InpMsh->typ & Asc) + safe_fgets(s, WrdSiz * FilStrSiz, InpMsh->hdl, InpMsh->err); + else #ifdef WITH_AIO - read(InpMsh->FilDes, s, WrdSiz * FilStrSiz); + read(InpMsh->FilDes, s, WrdSiz * FilStrSiz); #else - safe_fread(s, WrdSiz, FilStrSiz, InpMsh->hdl, InpMsh->err); + safe_fread(s, WrdSiz, FilStrSiz, InpMsh->hdl, InpMsh->err); #endif - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, "%s ", s); - else + if (OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%s ", s); + else #ifdef WITH_AIO - write(OutMsh->FilDes, s, WrdSiz * FilStrSiz); + write(OutMsh->FilDes, s, WrdSiz * FilStrSiz); #else - fwrite(s, WrdSiz, FilStrSiz, OutMsh->hdl); + fwrite(s, WrdSiz, FilStrSiz, OutMsh->hdl); #endif - } - } + } + } - if(OutMsh->typ & Asc) - fprintf(OutMsh->hdl, "\n"); + if (OutMsh->typ & Asc) fprintf(OutMsh->hdl, "\n"); - return(1); + return (1); } #endif @@ -1295,1691 +1093,1447 @@ int GmfCpyLin(int64_t InpIdx, int64_t OutIdx, int KwdCod) /* Bufferized asynchronous reading of all keyword's lines */ /*----------------------------------------------------------------------------*/ -int NAMF77(GmfGetBlock, gmfgetblock)( TYPF77(int64_t) MshIdx, - TYPF77(int) KwdCod, - TYPF77(int64_t) BegIdx, - TYPF77(int64_t) EndIdx, - TYPF77(int) MapTyp, - void *MapTab, - void *prc, ... ) -{ - char *UsrDat[ GmfMaxTyp ], *UsrBas[ GmfMaxTyp ], *FilPos, *EndUsrDat; - char *FilBuf = NULL, *FrtBuf = NULL, *BckBuf = NULL; - char *StrTab[5] = { "", "%f", "%lf", "%d", INT64_T_FMT }; - int b, i, j, k, LinSiz, *FilPtrI32, *UsrPtrI32, FilTyp[ GmfMaxTyp ]; - int UsrTyp[ GmfMaxTyp ], NmbBlk, SizTab[5] = {0,4,8,4,8}; - int *IntMapTab = NULL, err; - float *FilPtrR32, *UsrPtrR32; - double *FilPtrR64, *UsrPtrR64; - int64_t BlkNmbLin, *FilPtrI64, *UsrPtrI64, BlkBegIdx, BlkEndIdx = 0; - int64_t *LngMapTab = NULL, OldIdx = 0, RepCnt, UsrNmbLin; - int64_t FilBegIdx = VALF77(BegIdx), FilEndIdx = VALF77(EndIdx); - void (*UsrPrc)(int64_t, int64_t, void *) = NULL; - size_t UsrLen[ GmfMaxTyp ], ret; - va_list VarArg; - GmfMshSct *msh = (GmfMshSct *) VALF77(MshIdx); - KwdSct *kwd = &msh->KwdTab[ VALF77(KwdCod) ]; - struct aiocb aio; +int NAMF77(GmfGetBlock, gmfgetblock)(TYPF77(int64_t) MshIdx, TYPF77(int) KwdCod, TYPF77(int64_t) BegIdx, TYPF77(int64_t) EndIdx, TYPF77(int) MapTyp, void *MapTab, void *prc, ...) { + char *UsrDat[GmfMaxTyp], *UsrBas[GmfMaxTyp], *FilPos, *EndUsrDat; + char *FilBuf = NULL, *FrtBuf = NULL, *BckBuf = NULL; + char *StrTab[5] = {"", "%f", "%lf", "%d", INT64_T_FMT}; + int b, i, j, k, LinSiz, *FilPtrI32, *UsrPtrI32, FilTyp[GmfMaxTyp]; + int UsrTyp[GmfMaxTyp], NmbBlk, SizTab[5] = {0, 4, 8, 4, 8}; + int *IntMapTab = NULL, err; + float *FilPtrR32, *UsrPtrR32; + double *FilPtrR64, *UsrPtrR64; + int64_t BlkNmbLin, *FilPtrI64, *UsrPtrI64, BlkBegIdx, BlkEndIdx = 0; + int64_t *LngMapTab = NULL, OldIdx = 0, RepCnt, UsrNmbLin; + int64_t FilBegIdx = VALF77(BegIdx), FilEndIdx = VALF77(EndIdx); + void (*UsrPrc)(int64_t, int64_t, void *) = NULL; + size_t UsrLen[GmfMaxTyp], ret; + va_list VarArg; + GmfMshSct *msh = (GmfMshSct *)VALF77(MshIdx); + KwdSct *kwd = &msh->KwdTab[VALF77(KwdCod)]; + struct aiocb aio; #ifdef F77API - int NmbArg = 0; - void *ArgTab[ MaxArg ]; + int NmbArg = 0; + void *ArgTab[MaxArg]; #else - char *UsrArg = NULL; + char *UsrArg = NULL; #endif - // Save the current stack environment for longjmp - if(setjmp(msh->err) != 0) - { - if(BckBuf) - free(BckBuf); + // Save the current stack environment for longjmp + if (setjmp(msh->err) != 0) { + if (BckBuf) free(BckBuf); - if(FrtBuf) - free(FrtBuf); + if (FrtBuf) free(FrtBuf); - return(0); - } + return (0); + } - // Check mesh and keyword - if( (VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd) || !kwd->NmbLin ) - return(0); + // Check mesh and keyword + if ((VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd) || !kwd->NmbLin) return (0); - // Make sure it's not a simple information keyword - if( (kwd->typ != RegKwd) && (kwd->typ != SolKwd) ) - return(0); + // Make sure it's not a simple information keyword + if ((kwd->typ != RegKwd) && (kwd->typ != SolKwd)) return (0); - // Check user's bounds - if( (FilBegIdx < 1) || (FilBegIdx > FilEndIdx) || (FilEndIdx > kwd->NmbLin) ) - return(0); + // Check user's bounds + if ((FilBegIdx < 1) || (FilBegIdx > FilEndIdx) || (FilEndIdx > kwd->NmbLin)) return (0); - // Compute the number of lines to be read - UsrNmbLin = FilEndIdx - FilBegIdx + 1; + // Compute the number of lines to be read + UsrNmbLin = FilEndIdx - FilBegIdx + 1; - // Get the renumbering map if any - if(VALF77(MapTyp) == GmfInt) - IntMapTab = (int *)MapTab; - else if(VALF77(MapTyp) == GmfLong) - LngMapTab = (int64_t *)MapTab; + // Get the renumbering map if any + if (VALF77(MapTyp) == GmfInt) + IntMapTab = (int *)MapTab; + else if (VALF77(MapTyp) == GmfLong) + LngMapTab = (int64_t *)MapTab; - // Start decoding the arguments - va_start(VarArg, prc); - LinSiz = 0; + // Start decoding the arguments + va_start(VarArg, prc); + LinSiz = 0; - // Get the user's preporcessing procedure and argument adresses, if any + // Get the user's preporcessing procedure and argument adresses, if any #ifdef F77API - if(prc) - { - UsrPrc = (void (*)(int64_t, int64_t, void *))prc; - NmbArg = *(va_arg(VarArg, int *)); - - for(i=0;ityp == RegKwd) - { - for(i=0;iSolSiz;i++) - { - // Get the type from the variable arguments - UsrTyp[i] = VALF77(va_arg(VarArg, TYPF77(int)));; - - // If a table is given, read its size in the next argument - // and automatically fill the pointer table by incrementing - // as many times the base user address - if(UsrTyp[i] == GmfIntTab) - { - RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); - UsrTyp[i] = GmfInt; - } - else if(UsrTyp[i] == GmfLongTab) - { - RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); - UsrTyp[i] = GmfLong; - } - else - RepCnt = 0; - - // Get the begin and end pointers from the variable arguments - UsrDat[i] = UsrBas[i] = va_arg(VarArg, char *); - EndUsrDat = va_arg(VarArg, char *); - - if(UsrNmbLin > 1) - UsrLen[i] = (size_t)(EndUsrDat - UsrDat[i]) / (UsrNmbLin - 1); - else - UsrLen[i] = 0; - - // Replicate the table data type and increment the base address - if(RepCnt >= 2) - { - for(j=i+1; jtyp == SolKwd) - { - // Get the type, begin and end pointers from the variable arguments - UsrTyp[0] = VALF77(va_arg(VarArg, TYPF77(int)));; - UsrDat[0] = UsrBas[0] = va_arg(VarArg, char *); + // Get the user's data type and pointers to first + // and last adresses in order to compute the stride + if (kwd->typ == RegKwd) { + for (i = 0; i < kwd->SolSiz; i++) { + // Get the type from the variable arguments + UsrTyp[i] = VALF77(va_arg(VarArg, TYPF77(int))); + ; + + // If a table is given, read its size in the next argument + // and automatically fill the pointer table by incrementing + // as many times the base user address + if (UsrTyp[i] == GmfIntTab) { + RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); + UsrTyp[i] = GmfInt; + } else if (UsrTyp[i] == GmfLongTab) { + RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); + UsrTyp[i] = GmfLong; + } else + RepCnt = 0; + + // Get the begin and end pointers from the variable arguments + UsrDat[i] = UsrBas[i] = va_arg(VarArg, char *); EndUsrDat = va_arg(VarArg, char *); - if(UsrNmbLin > 1) - UsrLen[0] = (size_t)(EndUsrDat - UsrDat[0]) / (UsrNmbLin - 1); - else - UsrLen[0] = 0; - - // Solutions use only on set of type/begin/end pointers - // and the base adress is incremented for each entry - for(i=1;iSolSiz;i++) - { - UsrTyp[i] = UsrTyp[0]; - UsrDat[i] = UsrBas[i] = UsrDat[ i-1 ] + SizTab[ UsrTyp[0] ]; - UsrLen[i] = UsrLen[0]; - } - } - else - return(0); - - // Get the file's data type - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - if(msh->ver <= 1) - FilTyp[i] = GmfFloat; - else - FilTyp[i] = GmfDouble; + if (UsrNmbLin > 1) + UsrLen[i] = (size_t)(EndUsrDat - UsrDat[i]) / (UsrNmbLin - 1); else - if(msh->ver <= 3) - FilTyp[i] = GmfInt; - else - FilTyp[i] = GmfLong; - - // Compute the file stride - LinSiz += SizTab[ FilTyp[i] ]; - } - - va_end(VarArg); - - // Move file pointer to the keyword data - SetFilPos(msh, kwd->pos); - - // Read the whole kwd data - if(msh->typ & Asc) - { - for(i=1;i<=FilEndIdx;i++) - for(j=0;jSolSiz;j++) - { - // Reorder HO nodes on the fly - if(kwd->OrdTab && (j != kwd->SolSiz-1)) - k = kwd->OrdTab[j]; - else - k = j; + UsrLen[i] = 0; - safe_fscanf(msh->hdl, StrTab[ UsrTyp[k] ], UsrDat[k], msh->err); + // Replicate the table data type and increment the base address + if (RepCnt >= 2) { + for (j = i + 1; j < i + RepCnt; j++) { + UsrTyp[j] = UsrTyp[i]; + UsrDat[j] = UsrBas[j] = UsrDat[j - 1] + SizTab[UsrTyp[i]]; + UsrLen[j] = UsrLen[i]; + } - // Move to the next user's data line only when the desired - // begining position in the ascii file has been reached since - // we cannot move directly to an arbitrary position - if(i >= FilBegIdx) - UsrDat[k] += UsrLen[k]; - } + i += RepCnt - 1; + } + } + } else if (kwd->typ == SolKwd) { + // Get the type, begin and end pointers from the variable arguments + UsrTyp[0] = VALF77(va_arg(VarArg, TYPF77(int))); + ; + UsrDat[0] = UsrBas[0] = va_arg(VarArg, char *); + EndUsrDat = va_arg(VarArg, char *); + + if (UsrNmbLin > 1) + UsrLen[0] = (size_t)(EndUsrDat - UsrDat[0]) / (UsrNmbLin - 1); + else + UsrLen[0] = 0; + + // Solutions use only on set of type/begin/end pointers + // and the base adress is incremented for each entry + for (i = 1; i < kwd->SolSiz; i++) { + UsrTyp[i] = UsrTyp[0]; + UsrDat[i] = UsrBas[i] = UsrDat[i - 1] + SizTab[UsrTyp[0]]; + UsrLen[i] = UsrLen[0]; + } + } else + return (0); + + // Get the file's data type + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') + if (msh->ver <= 1) + FilTyp[i] = GmfFloat; + else + FilTyp[i] = GmfDouble; + else if (msh->ver <= 3) + FilTyp[i] = GmfInt; + else + FilTyp[i] = GmfLong; + + // Compute the file stride + LinSiz += SizTab[FilTyp[i]]; + } + + va_end(VarArg); + + // Move file pointer to the keyword data + SetFilPos(msh, kwd->pos); + + // Read the whole kwd data + if (msh->typ & Asc) { + for (i = 1; i <= FilEndIdx; i++) + for (j = 0; j < kwd->SolSiz; j++) { + // Reorder HO nodes on the fly + if (kwd->OrdTab && (j != kwd->SolSiz - 1)) + k = kwd->OrdTab[j]; + else + k = j; + + safe_fscanf(msh->hdl, StrTab[UsrTyp[k]], UsrDat[k], msh->err); + + // Move to the next user's data line only when the desired + // begining position in the ascii file has been reached since + // we cannot move directly to an arbitrary position + if (i >= FilBegIdx) UsrDat[k] += UsrLen[k]; + } - // Call the user's preprocessing procedure - if(UsrPrc) + // Call the user's preprocessing procedure + if (UsrPrc) #ifdef F77API - CalF77Prc(1, kwd->NmbLin, UsrPrc, NmbArg, ArgTab); + CalF77Prc(1, kwd->NmbLin, UsrPrc, NmbArg, ArgTab); #else - UsrPrc(1, kwd->NmbLin, UsrArg); + UsrPrc(1, kwd->NmbLin, UsrArg); #endif - } - else - { - // Allocate both front and back buffers - if(!(BckBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) - return(0); - - if(!(FrtBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) - return(0); - - // Setup the ansynchonous parameters - memset(&aio, 0, sizeof(struct aiocb)); - FilBuf = BckBuf; - aio.aio_buf = BckBuf; + } else { + // Allocate both front and back buffers + if (!(BckBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) return (0); + + if (!(FrtBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) return (0); + + // Setup the ansynchonous parameters + memset(&aio, 0, sizeof(struct aiocb)); + FilBuf = BckBuf; + aio.aio_buf = BckBuf; #ifdef WITH_AIO - aio.aio_fildes = msh->FilDes; + aio.aio_fildes = msh->FilDes; #else - aio.aio_fildes = msh->hdl; + aio.aio_fildes = msh->hdl; #endif - aio.aio_offset = GetFilPos(msh) + (FilBegIdx-1) * (size_t)LinSiz; + aio.aio_offset = GetFilPos(msh) + (FilBegIdx - 1) * (size_t)LinSiz; + + NmbBlk = UsrNmbLin / BufSiz; + + // Loop over N+1 blocks + for (b = 0; b <= NmbBlk + 1; b++) { + // Wait for the previous block read to complete except + // for the first loop interation + if (b) { + while (aio_error(&aio) == EINPROGRESS); + + err = aio_error(&aio); + ret = aio_return(&aio); + + if (err != 0) { + printf(" Error at aio_error() : %s\n", strerror(err)); + exit(1); + } + + if (ret != aio.aio_nbytes) { + printf(" Error at aio_return()\n"); + exit(1); + } + + // Increment the reading position + aio.aio_offset += aio.aio_nbytes; + + // and swap the buffers + if (aio.aio_buf == BckBuf) { + aio.aio_buf = FrtBuf; + FilBuf = BckBuf; + } else { + aio.aio_buf = BckBuf; + FilBuf = FrtBuf; + } + } - NmbBlk = UsrNmbLin / BufSiz; + // Read a chunk of data except for the last loop interarion + if (b <= NmbBlk) { + // The last block is shorter than the others + if (b == NmbBlk) + BlkNmbLin = UsrNmbLin - b * BufSiz; + else + BlkNmbLin = BufSiz; - // Loop over N+1 blocks - for(b=0;b<=NmbBlk+1;b++) - { - // Wait for the previous block read to complete except - // for the first loop interation - if(b) - { - while(aio_error(&aio) == EINPROGRESS); + aio.aio_nbytes = BlkNmbLin * LinSiz; - err = aio_error(&aio); - ret = aio_return(&aio); + if (aio_read(&aio) == -1) { + printf("block = %d / %d\n", b + 1, NmbBlk + 1); + printf("size = " INT64_T_FMT " lines\n", BlkNmbLin); +#ifdef WITH_AIO + printf("aio_fildes = %d\n", aio.aio_fildes); +#else + printf("aio_fildes = %p\n", aio.aio_fildes); +#endif + printf("aio_buf = %p\n", aio.aio_buf); + printf("aio_offset = " INT64_T_FMT "\n", (int64_t)aio.aio_offset); + printf("aio_nbytes = " INT64_T_FMT "\n", (int64_t)aio.aio_nbytes); + printf("errno = %d\n", errno); + exit(1); + } + } - if (err != 0) { - printf (" Error at aio_error() : %s\n", strerror (err)); - exit(1); - } + // Then decode the block and store it in the user's data structure + // except for the first loop interation + if (b) { + // The last block is shorter than the others + if (b - 1 == NmbBlk) + BlkNmbLin = UsrNmbLin - (b - 1) * BufSiz; + else + BlkNmbLin = BufSiz; - if (ret != aio.aio_nbytes) { - printf(" Error at aio_return()\n"); - exit(1); - } + BlkBegIdx = BlkEndIdx + 1; + BlkEndIdx += BlkNmbLin; + FilPos = FilBuf; - // Increment the reading position - aio.aio_offset += aio.aio_nbytes; + for (i = 0; i < BlkNmbLin; i++) { + OldIdx++; - // and swap the buffers - if(aio.aio_buf == BckBuf) - { - aio.aio_buf = FrtBuf; - FilBuf = BckBuf; - } - else - { - aio.aio_buf = BckBuf; - FilBuf = FrtBuf; - } - } - - // Read a chunk of data except for the last loop interarion - if(b <= NmbBlk) - { - // The last block is shorter than the others - if(b == NmbBlk) - BlkNmbLin = UsrNmbLin - b * BufSiz; - else - BlkNmbLin = BufSiz; + for (j = 0; j < kwd->SolSiz; j++) { + if (msh->cod != 1) SwpWrd(FilPos, SizTab[FilTyp[j]]); - aio.aio_nbytes = BlkNmbLin * LinSiz; + // Reorder HO nodes on the fly + if (kwd->OrdTab && (j != kwd->SolSiz - 1)) + k = kwd->OrdTab[j]; + else + k = j; - if(aio_read(&aio) == -1) - { - printf("block = %d / %d\n", b+1, NmbBlk+1); - printf("size = "INT64_T_FMT" lines\n", BlkNmbLin); -#ifdef WITH_AIO - printf("aio_fildes = %d\n",aio.aio_fildes); -#else - printf("aio_fildes = %p\n",aio.aio_fildes); -#endif - printf("aio_buf = %p\n",aio.aio_buf); - printf("aio_offset = " INT64_T_FMT "\n",(int64_t)aio.aio_offset); - printf("aio_nbytes = " INT64_T_FMT "\n",(int64_t)aio.aio_nbytes); - printf("errno = %d\n",errno); - exit(1); - } - } - - // Then decode the block and store it in the user's data structure - // except for the first loop interation - if(b) - { - // The last block is shorter than the others - if(b-1 == NmbBlk) - BlkNmbLin = UsrNmbLin - (b-1) * BufSiz; + if (IntMapTab) + UsrDat[j] = UsrBas[k] + (IntMapTab[OldIdx] - 1) * UsrLen[k]; + else if (LngMapTab) + UsrDat[j] = UsrBas[k] + (LngMapTab[OldIdx] - 1) * UsrLen[k]; else - BlkNmbLin = BufSiz; - - BlkBegIdx = BlkEndIdx+1; - BlkEndIdx += BlkNmbLin; - FilPos = FilBuf; - - for(i=0;iSolSiz;j++) - { - if(msh->cod != 1) - SwpWrd(FilPos, SizTab[ FilTyp[j] ]); - - // Reorder HO nodes on the fly - if(kwd->OrdTab && (j != kwd->SolSiz-1)) - k = kwd->OrdTab[j]; - else - k = j; - - if(IntMapTab) - UsrDat[j] = UsrBas[k] + (IntMapTab[ OldIdx ] - 1) * UsrLen[k]; - else if(LngMapTab) - UsrDat[j] = UsrBas[k] + (LngMapTab[ OldIdx ] - 1) * UsrLen[k]; - else - UsrDat[j] = UsrBas[k] + (OldIdx - 1) * UsrLen[k]; - - if(FilTyp[j] == GmfInt) - { - FilPtrI32 = (int *)FilPos; - - if(UsrTyp[j] == GmfInt) - { - UsrPtrI32 = (int *)UsrDat[j]; - *UsrPtrI32 = *FilPtrI32; - } - else - { - UsrPtrI64 = (int64_t *)UsrDat[j]; - *UsrPtrI64 = (int64_t)*FilPtrI32; - } - } - else if(FilTyp[j] == GmfLong) - { - FilPtrI64 = (int64_t *)FilPos; - - if(UsrTyp[j] == GmfLong) - { - UsrPtrI64 = (int64_t *)UsrDat[j]; - *UsrPtrI64 = *FilPtrI64; - } - else - { - UsrPtrI32 = (int *)UsrDat[j]; - *UsrPtrI32 = (int)*FilPtrI64; - } - } - else if(FilTyp[j] == GmfFloat) - { - FilPtrR32 = (float *)FilPos; - - if(UsrTyp[j] == GmfFloat) - { - UsrPtrR32 = (float *)UsrDat[j]; - *UsrPtrR32 = *FilPtrR32; - } - else - { - UsrPtrR64 = (double *)UsrDat[j]; - *UsrPtrR64 = (double)*FilPtrR32; - } - } - else if(FilTyp[j] == GmfDouble) - { - FilPtrR64 = (double *)FilPos; - - if(UsrTyp[j] == GmfDouble) - { - UsrPtrR64 = (double *)UsrDat[j]; - *UsrPtrR64 = *FilPtrR64; - } - else - { - UsrPtrR32 = (float *)UsrDat[j]; - *UsrPtrR32 = (float)*FilPtrR64; - } - } - - FilPos += SizTab[ FilTyp[j] ]; - } + UsrDat[j] = UsrBas[k] + (OldIdx - 1) * UsrLen[k]; + + if (FilTyp[j] == GmfInt) { + FilPtrI32 = (int *)FilPos; + + if (UsrTyp[j] == GmfInt) { + UsrPtrI32 = (int *)UsrDat[j]; + *UsrPtrI32 = *FilPtrI32; + } else { + UsrPtrI64 = (int64_t *)UsrDat[j]; + *UsrPtrI64 = (int64_t)*FilPtrI32; + } + } else if (FilTyp[j] == GmfLong) { + FilPtrI64 = (int64_t *)FilPos; + + if (UsrTyp[j] == GmfLong) { + UsrPtrI64 = (int64_t *)UsrDat[j]; + *UsrPtrI64 = *FilPtrI64; + } else { + UsrPtrI32 = (int *)UsrDat[j]; + *UsrPtrI32 = (int)*FilPtrI64; + } + } else if (FilTyp[j] == GmfFloat) { + FilPtrR32 = (float *)FilPos; + + if (UsrTyp[j] == GmfFloat) { + UsrPtrR32 = (float *)UsrDat[j]; + *UsrPtrR32 = *FilPtrR32; + } else { + UsrPtrR64 = (double *)UsrDat[j]; + *UsrPtrR64 = (double)*FilPtrR32; + } + } else if (FilTyp[j] == GmfDouble) { + FilPtrR64 = (double *)FilPos; + + if (UsrTyp[j] == GmfDouble) { + UsrPtrR64 = (double *)UsrDat[j]; + *UsrPtrR64 = *FilPtrR64; + } else { + UsrPtrR32 = (float *)UsrDat[j]; + *UsrPtrR32 = (float)*FilPtrR64; + } } - // Call the user's preprocessing procedure - if(UsrPrc) + FilPos += SizTab[FilTyp[j]]; + } + } + + // Call the user's preprocessing procedure + if (UsrPrc) #ifdef F77API - CalF77Prc(BlkBegIdx, BlkEndIdx, UsrPrc, NmbArg, ArgTab); + CalF77Prc(BlkBegIdx, BlkEndIdx, UsrPrc, NmbArg, ArgTab); #else - UsrPrc(BlkBegIdx, BlkEndIdx, UsrArg); + UsrPrc(BlkBegIdx, BlkEndIdx, UsrArg); #endif - } } + } - free(BckBuf); - free(FrtBuf); - } + free(BckBuf); + free(FrtBuf); + } - return(1); + return (1); } - /*----------------------------------------------------------------------------*/ /* Bufferized writing of all keyword's lines */ /*----------------------------------------------------------------------------*/ -int NAMF77(GmfSetBlock, gmfsetblock)( TYPF77(int64_t) MshIdx, - TYPF77(int) KwdCod, - TYPF77(int64_t) BegIdx, - TYPF77(int64_t) EndIdx, - TYPF77(int) MapTyp, - void *MapTab, - void *prc, ... ) -{ - char *UsrDat[ GmfMaxTyp ], *UsrBas[ GmfMaxTyp ], *EndUsrDat; - char *StrTab[5] = { "", "%g", "%.15g", "%d", "%lld" }, *FilPos; - char *FilBuf = NULL, *FrtBuf = NULL, *BckBuf = NULL; - int i, j, LinSiz, *FilPtrI32, *UsrPtrI32, FilTyp[ GmfMaxTyp ]; - int UsrTyp[ GmfMaxTyp ], NmbBlk, b, SizTab[5] = {0,4,8,4,8}; - int err, *IntMapTab = NULL, RepCnt; - float *FilPtrR32, *UsrPtrR32; - double *FilPtrR64, *UsrPtrR64; - int64_t UsrNmbLin, BlkNmbLin = 0, BlkBegIdx, BlkEndIdx = 0; - int64_t *FilPtrI64, *UsrPtrI64, *LngMapTab = NULL, OldIdx = 0; - int64_t FilBegIdx = VALF77(BegIdx), FilEndIdx = VALF77(EndIdx); - void (*UsrPrc)(int64_t, int64_t, void *) = NULL; - size_t UsrLen[ GmfMaxTyp ], ret; - va_list VarArg; - GmfMshSct *msh = (GmfMshSct *) VALF77(MshIdx); - KwdSct *kwd = &msh->KwdTab[ VALF77(KwdCod) ]; - struct aiocb aio; +int NAMF77(GmfSetBlock, gmfsetblock)(TYPF77(int64_t) MshIdx, TYPF77(int) KwdCod, TYPF77(int64_t) BegIdx, TYPF77(int64_t) EndIdx, TYPF77(int) MapTyp, void *MapTab, void *prc, ...) { + char *UsrDat[GmfMaxTyp], *UsrBas[GmfMaxTyp], *EndUsrDat; + char *StrTab[5] = {"", "%g", "%.15g", "%d", "%lld"}, *FilPos; + char *FilBuf = NULL, *FrtBuf = NULL, *BckBuf = NULL; + int i, j, LinSiz, *FilPtrI32, *UsrPtrI32, FilTyp[GmfMaxTyp]; + int UsrTyp[GmfMaxTyp], NmbBlk, b, SizTab[5] = {0, 4, 8, 4, 8}; + int err, *IntMapTab = NULL, RepCnt; + float *FilPtrR32, *UsrPtrR32; + double *FilPtrR64, *UsrPtrR64; + int64_t UsrNmbLin, BlkNmbLin = 0, BlkBegIdx, BlkEndIdx = 0; + int64_t *FilPtrI64, *UsrPtrI64, *LngMapTab = NULL, OldIdx = 0; + int64_t FilBegIdx = VALF77(BegIdx), FilEndIdx = VALF77(EndIdx); + void (*UsrPrc)(int64_t, int64_t, void *) = NULL; + size_t UsrLen[GmfMaxTyp], ret; + va_list VarArg; + GmfMshSct *msh = (GmfMshSct *)VALF77(MshIdx); + KwdSct *kwd = &msh->KwdTab[VALF77(KwdCod)]; + struct aiocb aio; #ifdef F77API - int NmbArg = 0; - void *ArgTab[ MaxArg ]; + int NmbArg = 0; + void *ArgTab[MaxArg]; #else - char *UsrArg = NULL; + char *UsrArg = NULL; #endif - // Save the current stack environment for longjmp - if(setjmp(msh->err) != 0) - { - if(FilBuf) - free(FilBuf); + // Save the current stack environment for longjmp + if (setjmp(msh->err) != 0) { + if (FilBuf) free(FilBuf); - return(0); - } + return (0); + } - // Check mesh and keyword - if( (VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd) || !kwd->NmbLin ) - return(0); + // Check mesh and keyword + if ((VALF77(KwdCod) < 1) || (VALF77(KwdCod) > GmfMaxKwd) || !kwd->NmbLin) return (0); - // Make sure it's not a simple information keyword - if( (kwd->typ != RegKwd) && (kwd->typ != SolKwd) ) - return(0); + // Make sure it's not a simple information keyword + if ((kwd->typ != RegKwd) && (kwd->typ != SolKwd)) return (0); - // Temporarily overwright the given begin and end values - // as arbitrary position block write is not yet implemented - FilBegIdx = 1; - FilEndIdx = kwd->NmbLin; + // Temporarily overwright the given begin and end values + // as arbitrary position block write is not yet implemented + FilBegIdx = 1; + FilEndIdx = kwd->NmbLin; - // Check user's bounds - if( (FilBegIdx < 1) || (FilBegIdx > FilEndIdx) || (FilEndIdx > kwd->NmbLin) ) - return(0); + // Check user's bounds + if ((FilBegIdx < 1) || (FilBegIdx > FilEndIdx) || (FilEndIdx > kwd->NmbLin)) return (0); - // Compute the number of lines to be written - UsrNmbLin = FilEndIdx - FilBegIdx + 1; + // Compute the number of lines to be written + UsrNmbLin = FilEndIdx - FilBegIdx + 1; - // Get the renumbering map if any - if(VALF77(MapTyp) == GmfInt) - IntMapTab = (int *)MapTab; - else if(VALF77(MapTyp) == GmfLong) - LngMapTab = (int64_t *)MapTab; + // Get the renumbering map if any + if (VALF77(MapTyp) == GmfInt) + IntMapTab = (int *)MapTab; + else if (VALF77(MapTyp) == GmfLong) + LngMapTab = (int64_t *)MapTab; - // Start decoding the arguments - va_start(VarArg, prc); - LinSiz = 0; + // Start decoding the arguments + va_start(VarArg, prc); + LinSiz = 0; - // Get the user's postprocessing procedure and argument adresses, if any + // Get the user's postprocessing procedure and argument adresses, if any #ifdef F77API - if(prc) - { - UsrPrc = (void (*)(int64_t, int64_t, void *))prc; - NmbArg = *(va_arg(VarArg, int *)); - - for(i=0;ityp == RegKwd) - { - for(i=0;iSolSiz;i++) - { - // Get the type from the variable arguments - UsrTyp[i] = VALF77(va_arg(VarArg, TYPF77(int))); - - // If a table is given, read its size in the next argument - // and automatically fill the pointer table by incrementing - // as many times the base user address - if(UsrTyp[i] == GmfIntTab) - { - RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); - UsrTyp[i] = GmfInt; - } - else if(UsrTyp[i] == GmfLongTab) - { - RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); - UsrTyp[i] = GmfLong; - } - else - RepCnt = 0; - - // Get the begin and end pointers from the variable arguments - UsrDat[i] = UsrBas[i] = va_arg(VarArg, char *); - EndUsrDat = va_arg(VarArg, char *); - - if(UsrNmbLin > 1) - UsrLen[i] = (size_t)(EndUsrDat - UsrDat[i]) / (UsrNmbLin - 1); - else - UsrLen[i] = 0; - - // Replicate the table data type and increment the base address - if(RepCnt >= 2) - { - for(j=i+1; jtyp == SolKwd) - { - // Get the type, begin and end pointers from the variable arguments - UsrTyp[0] = VALF77(va_arg(VarArg, TYPF77(int)));; - UsrDat[0] = UsrBas[0] = va_arg(VarArg, char *); + // Get the user's data type and pointers to first + // and last adresses in order to compute the stride + if (kwd->typ == RegKwd) { + for (i = 0; i < kwd->SolSiz; i++) { + // Get the type from the variable arguments + UsrTyp[i] = VALF77(va_arg(VarArg, TYPF77(int))); + + // If a table is given, read its size in the next argument + // and automatically fill the pointer table by incrementing + // as many times the base user address + if (UsrTyp[i] == GmfIntTab) { + RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); + UsrTyp[i] = GmfInt; + } else if (UsrTyp[i] == GmfLongTab) { + RepCnt = VALF77(va_arg(VarArg, TYPF77(int))); + UsrTyp[i] = GmfLong; + } else + RepCnt = 0; + + // Get the begin and end pointers from the variable arguments + UsrDat[i] = UsrBas[i] = va_arg(VarArg, char *); EndUsrDat = va_arg(VarArg, char *); - if(UsrNmbLin > 1) - UsrLen[0] = (size_t)(EndUsrDat - UsrDat[0]) / (UsrNmbLin - 1); + if (UsrNmbLin > 1) + UsrLen[i] = (size_t)(EndUsrDat - UsrDat[i]) / (UsrNmbLin - 1); else - UsrLen[0] = 0; - - // Solutions use only on set of type/begin/end pointers - // and the base adress is incremented for each entry - for(i=1;iSolSiz;i++) - { - UsrTyp[i] = UsrTyp[0]; - UsrDat[i] = UsrBas[i] = UsrDat[ i-1 ] + SizTab[ UsrTyp[0] ]; - UsrLen[i] = UsrLen[0]; + UsrLen[i] = 0; + + // Replicate the table data type and increment the base address + if (RepCnt >= 2) { + for (j = i + 1; j < i + RepCnt; j++) { + UsrTyp[j] = UsrTyp[i]; + UsrDat[j] = UsrBas[j] = UsrDat[j - 1] + SizTab[UsrTyp[i]]; + UsrLen[j] = UsrLen[i]; + } + + i += RepCnt - 1; } - } - else - return(0); - - // Get the file's data type - for(i=0;iSolSiz;i++) - { - if(kwd->fmt[i] == 'r') - if(msh->ver <= 1) - FilTyp[i] = GmfFloat; - else - FilTyp[i] = GmfDouble; + } + } else if (kwd->typ == SolKwd) { + // Get the type, begin and end pointers from the variable arguments + UsrTyp[0] = VALF77(va_arg(VarArg, TYPF77(int))); + ; + UsrDat[0] = UsrBas[0] = va_arg(VarArg, char *); + EndUsrDat = va_arg(VarArg, char *); + + if (UsrNmbLin > 1) + UsrLen[0] = (size_t)(EndUsrDat - UsrDat[0]) / (UsrNmbLin - 1); + else + UsrLen[0] = 0; + + // Solutions use only on set of type/begin/end pointers + // and the base adress is incremented for each entry + for (i = 1; i < kwd->SolSiz; i++) { + UsrTyp[i] = UsrTyp[0]; + UsrDat[i] = UsrBas[i] = UsrDat[i - 1] + SizTab[UsrTyp[0]]; + UsrLen[i] = UsrLen[0]; + } + } else + return (0); + + // Get the file's data type + for (i = 0; i < kwd->SolSiz; i++) { + if (kwd->fmt[i] == 'r') + if (msh->ver <= 1) + FilTyp[i] = GmfFloat; else - if(msh->ver <= 3) - FilTyp[i] = GmfInt; - else - FilTyp[i] = GmfLong; + FilTyp[i] = GmfDouble; + else if (msh->ver <= 3) + FilTyp[i] = GmfInt; + else + FilTyp[i] = GmfLong; - // Compute the file stride - LinSiz += SizTab[ FilTyp[i] ]; - } + // Compute the file stride + LinSiz += SizTab[FilTyp[i]]; + } - va_end(VarArg); + va_end(VarArg); - // Write the whole kwd data - if(msh->typ & Asc) - { - if(UsrPrc) + // Write the whole kwd data + if (msh->typ & Asc) { + if (UsrPrc) #ifdef F77API - CalF77Prc(1, kwd->NmbLin, UsrPrc, NmbArg, ArgTab); + CalF77Prc(1, kwd->NmbLin, UsrPrc, NmbArg, ArgTab); #else - UsrPrc(1, kwd->NmbLin, UsrArg); + UsrPrc(1, kwd->NmbLin, UsrArg); #endif - for(i=FilBegIdx; i<=FilEndIdx; i++) - for(j=0;jSolSiz;j++) - { - if(UsrTyp[j] == GmfFloat) - { - UsrPtrR32 = (float *)UsrDat[j]; - fprintf(msh->hdl, StrTab[ UsrTyp[j] ], (double)*UsrPtrR32); - } - else if(UsrTyp[j] == GmfDouble) - { - UsrPtrR64 = (double *)UsrDat[j]; - fprintf(msh->hdl, StrTab[ UsrTyp[j] ], *UsrPtrR64); - } - else if(UsrTyp[j] == GmfInt) - { - UsrPtrI32 = (int *)UsrDat[j]; - fprintf(msh->hdl, StrTab[ UsrTyp[j] ], *UsrPtrI32); - } - else if(UsrTyp[j] == GmfLong) - { - UsrPtrI64 = (int64_t *)UsrDat[j]; - fprintf(msh->hdl, StrTab[ UsrTyp[j] ], *UsrPtrI64); - } + for (i = FilBegIdx; i <= FilEndIdx; i++) + for (j = 0; j < kwd->SolSiz; j++) { + if (UsrTyp[j] == GmfFloat) { + UsrPtrR32 = (float *)UsrDat[j]; + fprintf(msh->hdl, StrTab[UsrTyp[j]], (double)*UsrPtrR32); + } else if (UsrTyp[j] == GmfDouble) { + UsrPtrR64 = (double *)UsrDat[j]; + fprintf(msh->hdl, StrTab[UsrTyp[j]], *UsrPtrR64); + } else if (UsrTyp[j] == GmfInt) { + UsrPtrI32 = (int *)UsrDat[j]; + fprintf(msh->hdl, StrTab[UsrTyp[j]], *UsrPtrI32); + } else if (UsrTyp[j] == GmfLong) { + UsrPtrI64 = (int64_t *)UsrDat[j]; + fprintf(msh->hdl, StrTab[UsrTyp[j]], *UsrPtrI64); + } + + if (j < kwd->SolSiz - 1) + fprintf(msh->hdl, " "); + else + fprintf(msh->hdl, "\n"); + + UsrDat[j] += UsrLen[j]; + } + } else { + // Allocate the front and back buffers + if (!(BckBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) return (0); - if(j < kwd->SolSiz -1) - fprintf(msh->hdl, " "); - else - fprintf(msh->hdl, "\n"); - - UsrDat[j] += UsrLen[j]; - } - } - else - { - // Allocate the front and back buffers - if(!(BckBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) - return(0); - - if(!(FrtBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) - return(0); - - // Setup the asynchronous parameters - memset(&aio, 0, sizeof(struct aiocb)); - FilBuf = BckBuf; + if (!(FrtBuf = malloc((size_t)BufSiz * (size_t)LinSiz))) return (0); + + // Setup the asynchronous parameters + memset(&aio, 0, sizeof(struct aiocb)); + FilBuf = BckBuf; #ifdef WITH_AIO - aio.aio_fildes = msh->FilDes; + aio.aio_fildes = msh->FilDes; #else - aio.aio_fildes = msh->hdl; + aio.aio_fildes = msh->hdl; #endif - aio.aio_offset = GetFilPos(msh); - - NmbBlk = UsrNmbLin / BufSiz; - - // Loop over N+1 blocks - for(b=0;b<=NmbBlk+1;b++) - { - // Launch an asynchronous block write - // except for the first loop iteration - if(b) - { - aio.aio_nbytes = BlkNmbLin * LinSiz; - - if(aio_write(&aio) == -1) - { + aio.aio_offset = GetFilPos(msh); + + NmbBlk = UsrNmbLin / BufSiz; + + // Loop over N+1 blocks + for (b = 0; b <= NmbBlk + 1; b++) { + // Launch an asynchronous block write + // except for the first loop iteration + if (b) { + aio.aio_nbytes = BlkNmbLin * LinSiz; + + if (aio_write(&aio) == -1) { #ifdef WITH_AIO - printf("aio_fildes = %d\n",aio.aio_fildes); + printf("aio_fildes = %d\n", aio.aio_fildes); #else - printf("aio_fildes = %p\n",aio.aio_fildes); + printf("aio_fildes = %p\n", aio.aio_fildes); #endif - printf("aio_buf = %p\n",aio.aio_buf); - printf("aio_offset = " INT64_T_FMT "\n",(int64_t)aio.aio_offset); - printf("aio_nbytes = " INT64_T_FMT "\n",(int64_t)aio.aio_nbytes); - printf("errno = %d\n",errno); - exit(1); - } - } - - // Parse the block data except at the last loop iteration - if(b<=NmbBlk) - { - // The last block is shorter - if(b == NmbBlk) - BlkNmbLin = UsrNmbLin - b * BufSiz; - else - BlkNmbLin = BufSiz; + printf("aio_buf = %p\n", aio.aio_buf); + printf("aio_offset = " INT64_T_FMT "\n", (int64_t)aio.aio_offset); + printf("aio_nbytes = " INT64_T_FMT "\n", (int64_t)aio.aio_nbytes); + printf("errno = %d\n", errno); + exit(1); + } + } - FilPos = FilBuf; - BlkBegIdx = BlkEndIdx+1; - BlkEndIdx += BlkNmbLin; + // Parse the block data except at the last loop iteration + if (b <= NmbBlk) { + // The last block is shorter + if (b == NmbBlk) + BlkNmbLin = UsrNmbLin - b * BufSiz; + else + BlkNmbLin = BufSiz; - // Call user's preprocessing first - if(UsrPrc) + FilPos = FilBuf; + BlkBegIdx = BlkEndIdx + 1; + BlkEndIdx += BlkNmbLin; + + // Call user's preprocessing first + if (UsrPrc) #ifdef F77API - CalF77Prc(BlkBegIdx, BlkEndIdx, UsrPrc, NmbArg, ArgTab); + CalF77Prc(BlkBegIdx, BlkEndIdx, UsrPrc, NmbArg, ArgTab); #else - UsrPrc(BlkBegIdx, BlkEndIdx, UsrArg); + UsrPrc(BlkBegIdx, BlkEndIdx, UsrArg); #endif - // Then copy it's data to the file buffer - for(i=0;iSolSiz;j++) - { - if(IntMapTab) - UsrDat[j] = UsrBas[j] + (IntMapTab[ OldIdx ] - 1) * UsrLen[j]; - else if(LngMapTab) - UsrDat[j] = UsrBas[j] + (LngMapTab[ OldIdx ] - 1) * UsrLen[j]; - else - UsrDat[j] = UsrBas[j] + (OldIdx - 1) * UsrLen[j]; - - if(FilTyp[j] == GmfInt) - { - FilPtrI32 = (int *)FilPos; - - if(UsrTyp[j] == GmfInt) - { - UsrPtrI32 = (int *)UsrDat[j]; - *FilPtrI32 = *UsrPtrI32; - } - else - { - UsrPtrI64 = (int64_t *)UsrDat[j]; - *FilPtrI32 = (int)*UsrPtrI64; - } - } - else if(FilTyp[j] == GmfLong) - { - FilPtrI64 = (int64_t *)FilPos; - - if(UsrTyp[j] == GmfLong) - { - UsrPtrI64 = (int64_t *)UsrDat[j]; - *FilPtrI64 = *UsrPtrI64; - } - else - { - UsrPtrI32 = (int *)UsrDat[j]; - *FilPtrI64 = (int64_t)*UsrPtrI32; - } - } - else if(FilTyp[j] == GmfFloat) - { - FilPtrR32 = (float *)FilPos; - - if(UsrTyp[j] == GmfFloat) - { - UsrPtrR32 = (float *)UsrDat[j]; - *FilPtrR32 = *UsrPtrR32; - } - else - { - UsrPtrR64 = (double *)UsrDat[j]; - *FilPtrR32 = (float)*UsrPtrR64; - } - } - else if(FilTyp[j] == GmfDouble) - { - FilPtrR64 = (double *)FilPos; - - if(UsrTyp[j] == GmfDouble) - { - UsrPtrR64 = (double *)UsrDat[j]; - *FilPtrR64 = *UsrPtrR64; - } - else - { - UsrPtrR32 = (float *)UsrDat[j]; - *FilPtrR64 = (double)*UsrPtrR32; - } - } - - FilPos += SizTab[ FilTyp[j] ]; - } + // Then copy it's data to the file buffer + for (i = 0; i < BlkNmbLin; i++) { + OldIdx++; + + for (j = 0; j < kwd->SolSiz; j++) { + if (IntMapTab) + UsrDat[j] = UsrBas[j] + (IntMapTab[OldIdx] - 1) * UsrLen[j]; + else if (LngMapTab) + UsrDat[j] = UsrBas[j] + (LngMapTab[OldIdx] - 1) * UsrLen[j]; + else + UsrDat[j] = UsrBas[j] + (OldIdx - 1) * UsrLen[j]; + + if (FilTyp[j] == GmfInt) { + FilPtrI32 = (int *)FilPos; + + if (UsrTyp[j] == GmfInt) { + UsrPtrI32 = (int *)UsrDat[j]; + *FilPtrI32 = *UsrPtrI32; + } else { + UsrPtrI64 = (int64_t *)UsrDat[j]; + *FilPtrI32 = (int)*UsrPtrI64; + } + } else if (FilTyp[j] == GmfLong) { + FilPtrI64 = (int64_t *)FilPos; + + if (UsrTyp[j] == GmfLong) { + UsrPtrI64 = (int64_t *)UsrDat[j]; + *FilPtrI64 = *UsrPtrI64; + } else { + UsrPtrI32 = (int *)UsrDat[j]; + *FilPtrI64 = (int64_t)*UsrPtrI32; + } + } else if (FilTyp[j] == GmfFloat) { + FilPtrR32 = (float *)FilPos; + + if (UsrTyp[j] == GmfFloat) { + UsrPtrR32 = (float *)UsrDat[j]; + *FilPtrR32 = *UsrPtrR32; + } else { + UsrPtrR64 = (double *)UsrDat[j]; + *FilPtrR32 = (float)*UsrPtrR64; + } + } else if (FilTyp[j] == GmfDouble) { + FilPtrR64 = (double *)FilPos; + + if (UsrTyp[j] == GmfDouble) { + UsrPtrR64 = (double *)UsrDat[j]; + *FilPtrR64 = *UsrPtrR64; + } else { + UsrPtrR32 = (float *)UsrDat[j]; + *FilPtrR64 = (double)*UsrPtrR32; + } } - } - // Wait for write completion execpt at the first loop iteration - if(b) - { - while(aio_error(&aio) == EINPROGRESS); + FilPos += SizTab[FilTyp[j]]; + } + } + } - err = aio_error(&aio); - ret = aio_return(&aio); + // Wait for write completion execpt at the first loop iteration + if (b) { + while (aio_error(&aio) == EINPROGRESS); - if (err != 0) { - printf (" Error at aio_error() : %s\n", strerror (err)); - exit(1); - } + err = aio_error(&aio); + ret = aio_return(&aio); - if (ret != aio.aio_nbytes) { - printf(" Error at aio_return()\n"); - exit(1); - } + if (err != 0) { + printf(" Error at aio_error() : %s\n", strerror(err)); + exit(1); + } - // Move the write position - aio.aio_offset += aio.aio_nbytes; - } - - // Swap the buffers - if(FilBuf == BckBuf) - { - aio.aio_buf = BckBuf; - FilBuf = FrtBuf; - } - else - { - aio.aio_buf = FrtBuf; - FilBuf = BckBuf; - } + if (ret != aio.aio_nbytes) { + printf(" Error at aio_return()\n"); + exit(1); + } + + // Move the write position + aio.aio_offset += aio.aio_nbytes; } - SetFilPos(msh, aio.aio_offset); - free(BckBuf); - free(FrtBuf); - } + // Swap the buffers + if (FilBuf == BckBuf) { + aio.aio_buf = BckBuf; + FilBuf = FrtBuf; + } else { + aio.aio_buf = FrtBuf; + FilBuf = BckBuf; + } + } - return(1); -} + SetFilPos(msh, aio.aio_offset); + free(BckBuf); + free(FrtBuf); + } + return (1); +} /*----------------------------------------------------------------------------*/ /* Map two HO element's nodes numbering orders */ /*----------------------------------------------------------------------------*/ -int GmfSetHONodesOrdering(int64_t MshIdx, int KwdCod, int *BasTab, int *OrdTab) -{ - int i, j, k, flg, NmbNod, NmbCrd; - GmfMshSct *msh = (GmfMshSct *)MshIdx; - KwdSct *kwd; - - if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) - return(0); - - kwd = &msh->KwdTab[ KwdCod ]; - - // Find the Bezier indices dimension according to the element's kind - switch(KwdCod) - { - case GmfEdgesP2 : NmbNod = 3; NmbCrd = 1; break; - case GmfEdgesP3 : NmbNod = 4; NmbCrd = 1; break; - case GmfTrianglesP2 : NmbNod = 6; NmbCrd = 3; break; - case GmfTrianglesP3 : NmbNod = 10; NmbCrd = 3; break; - case GmfQuadrilateralsQ2 : NmbNod = 9; NmbCrd = 2; break; - case GmfQuadrilateralsQ3 : NmbNod = 16; NmbCrd = 2; break; - case GmfTetrahedraP2 : NmbNod = 10; NmbCrd = 4; break; - case GmfTetrahedraP3 : NmbNod = 20; NmbCrd = 4; break; - case GmfPyramidsP2 : NmbNod = 14; NmbCrd = 3; break; - case GmfPyramidsP3 : NmbNod = 30; NmbCrd = 3; break; - case GmfPrismsP2 : NmbNod = 18; NmbCrd = 4; break; - case GmfPrismsP3 : NmbNod = 40; NmbCrd = 4; break; - case GmfHexahedraQ2 : NmbNod = 27; NmbCrd = 3; break; - case GmfHexahedraQ3 : NmbNod = 64; NmbCrd = 3; break; - default : return(0); - } - - // Free and rebuild the mapping table it there were already one - if(kwd->OrdTab) - free(kwd->OrdTab); - - if(!(kwd->OrdTab = malloc(NmbNod * sizeof(int)))) - return(0); - - // Find the corresponding Bezier coordinates from the source table - for(i=0;iOrdTab[j] = i; - } - } - - for(i=0;iOrdTab[i]); - - return(1); +int GmfSetHONodesOrdering(int64_t MshIdx, int KwdCod, int *BasTab, int *OrdTab) { + int i, j, k, flg, NmbNod, NmbCrd; + GmfMshSct *msh = (GmfMshSct *)MshIdx; + KwdSct *kwd; + + if ((KwdCod < 1) || (KwdCod > GmfMaxKwd)) return (0); + + kwd = &msh->KwdTab[KwdCod]; + + // Find the Bezier indices dimension according to the element's kind + switch (KwdCod) { + case GmfEdgesP2: + NmbNod = 3; + NmbCrd = 1; + break; + case GmfEdgesP3: + NmbNod = 4; + NmbCrd = 1; + break; + case GmfTrianglesP2: + NmbNod = 6; + NmbCrd = 3; + break; + case GmfTrianglesP3: + NmbNod = 10; + NmbCrd = 3; + break; + case GmfQuadrilateralsQ2: + NmbNod = 9; + NmbCrd = 2; + break; + case GmfQuadrilateralsQ3: + NmbNod = 16; + NmbCrd = 2; + break; + case GmfTetrahedraP2: + NmbNod = 10; + NmbCrd = 4; + break; + case GmfTetrahedraP3: + NmbNod = 20; + NmbCrd = 4; + break; + case GmfPyramidsP2: + NmbNod = 14; + NmbCrd = 3; + break; + case GmfPyramidsP3: + NmbNod = 30; + NmbCrd = 3; + break; + case GmfPrismsP2: + NmbNod = 18; + NmbCrd = 4; + break; + case GmfPrismsP3: + NmbNod = 40; + NmbCrd = 4; + break; + case GmfHexahedraQ2: + NmbNod = 27; + NmbCrd = 3; + break; + case GmfHexahedraQ3: + NmbNod = 64; + NmbCrd = 3; + break; + default: + return (0); + } + + // Free and rebuild the mapping table it there were already one + if (kwd->OrdTab) free(kwd->OrdTab); + + if (!(kwd->OrdTab = malloc(NmbNod * sizeof(int)))) return (0); + + // Find the corresponding Bezier coordinates from the source table + for (i = 0; i < NmbNod; i++) { + for (j = 0; j < NmbNod; j++) { + flg = 1; + + for (k = 0; k < NmbCrd; k++) + if (BasTab[i * NmbCrd + k] != OrdTab[j * NmbCrd + k]) { + flg = 0; + break; + } + + if (flg) kwd->OrdTab[j] = i; + } + } + + for (i = 0; i < NmbNod; i++) printf("%d : %d\n", i, kwd->OrdTab[i]); + + return (1); } #endif - #ifndef F77API - /*----------------------------------------------------------------------------*/ /* Read an EGADS binary CAD and return the byte flow and its exact byte size */ /*----------------------------------------------------------------------------*/ -char *GmfReadByteFlow(int64_t MshIdx, int *NmbByt) -{ - int i, cod, *WrdTab, NmbWrd; - GmfMshSct *msh = (GmfMshSct *)MshIdx; +char *GmfReadByteFlow(int64_t MshIdx, int *NmbByt) { + int i, cod, *WrdTab, NmbWrd; + GmfMshSct *msh = (GmfMshSct *)MshIdx; - if(!(NmbWrd = GmfStatKwd(MshIdx, GmfByteFlow))) - return(NULL); + if (!(NmbWrd = GmfStatKwd(MshIdx, GmfByteFlow))) return (NULL); - if(!(WrdTab = malloc(NmbWrd * WrdSiz))) - return(NULL); + if (!(WrdTab = malloc(NmbWrd * WrdSiz))) return (NULL); - cod = msh->cod; - msh->cod = 1; + cod = msh->cod; + msh->cod = 1; - GmfGotoKwd(MshIdx, GmfByteFlow); - GmfGetLin(MshIdx, GmfByteFlow, NmbByt); + GmfGotoKwd(MshIdx, GmfByteFlow); + GmfGetLin(MshIdx, GmfByteFlow, NmbByt); - for(i=0;icod = cod; + msh->cod = cod; - return((char *)WrdTab); + return ((char *)WrdTab); } - /*----------------------------------------------------------------------------*/ /* Write an EGADS binary CAD as an integer table whose first entry is the size*/ /*----------------------------------------------------------------------------*/ -int GmfWriteByteFlow(int64_t MshIdx, char *BytTab, int NmbByt) -{ - int i, *WrdTab = (int *)BytTab, NmbWrd = NmbByt / WrdSiz + 1; +int GmfWriteByteFlow(int64_t MshIdx, char *BytTab, int NmbByt) { + int i, *WrdTab = (int *)BytTab, NmbWrd = NmbByt / WrdSiz + 1; - if(!GmfSetKwd(MshIdx, GmfByteFlow, NmbWrd + 1)) - return(0); + if (!GmfSetKwd(MshIdx, GmfByteFlow, NmbWrd + 1)) return (0); - GmfSetLin(MshIdx, GmfByteFlow, NmbByt); + GmfSetLin(MshIdx, GmfByteFlow, NmbByt); - for(i=0;ityp & Asc) - { - // Scan each string in the file until the end - while(fscanf(msh->hdl, "%s", str) != EOF) - { - // Fast test in order to reject quickly the numeric values - if(isalpha(str[0])) - { - // Search which kwd code this string is associated with, then get its - // header and save the curent position in file (just before the data) - for(KwdCod=1; KwdCod<= GmfMaxKwd; KwdCod++) - if(!strcmp(str, GmfKwdFmt[ KwdCod ][0])) - { - ScaKwdHdr(msh, KwdCod); - break; - } - } - else if(str[0] == '#') - while((c = fgetc(msh->hdl)) != '\n' && c != EOF); - } - } - else - { - // Get file size - EndPos = GetFilSiz(msh); - - // Jump through kwd positions in the file - do - { - // Get the kwd code and the next kwd position - ScaWrd(msh, ( char *)&KwdCod); - NexPos = GetPos(msh); - - if(NexPos > EndPos) - longjmp(msh->err, -1); - - // Check if this kwd belongs to this mesh version - if( (KwdCod >= 1) && (KwdCod <= GmfMaxKwd) ) +static int ScaKwdTab(GmfMshSct *msh) { + int KwdCod, c; + int64_t NexPos, EndPos; + char str[GmfStrSiz]; + + if (msh->typ & Asc) { + // Scan each string in the file until the end + while (fscanf(msh->hdl, "%s", str) != EOF) { + // Fast test in order to reject quickly the numeric values + if (isalpha(str[0])) { + // Search which kwd code this string is associated with, then get its + // header and save the curent position in file (just before the data) + for (KwdCod = 1; KwdCod <= GmfMaxKwd; KwdCod++) + if (!strcmp(str, GmfKwdFmt[KwdCod][0])) { ScaKwdHdr(msh, KwdCod); - - // Go to the next kwd - if(NexPos && !(SetFilPos(msh, NexPos))) - longjmp(msh->err, -1); - }while(NexPos && (KwdCod != GmfEnd)); - } - - return(1); + break; + } + } else if (str[0] == '#') + while ((c = fgetc(msh->hdl)) != '\n' && c != EOF); + } + } else { + // Get file size + EndPos = GetFilSiz(msh); + + // Jump through kwd positions in the file + do { + // Get the kwd code and the next kwd position + ScaWrd(msh, (char *)&KwdCod); + NexPos = GetPos(msh); + + if (NexPos > EndPos) longjmp(msh->err, -1); + + // Check if this kwd belongs to this mesh version + if ((KwdCod >= 1) && (KwdCod <= GmfMaxKwd)) ScaKwdHdr(msh, KwdCod); + + // Go to the next kwd + if (NexPos && !(SetFilPos(msh, NexPos))) longjmp(msh->err, -1); + } while (NexPos && (KwdCod != GmfEnd)); + } + + return (1); } - /*----------------------------------------------------------------------------*/ /* Read and setup the keyword's header */ /*----------------------------------------------------------------------------*/ -static void ScaKwdHdr(GmfMshSct *msh, int KwdCod) -{ - int i; - KwdSct *kwd = &msh->KwdTab[ KwdCod ]; +static void ScaKwdHdr(GmfMshSct *msh, int KwdCod) { + int i; + KwdSct *kwd = &msh->KwdTab[KwdCod]; + + if (!strcmp("i", GmfKwdFmt[KwdCod][1])) + if (msh->typ & Asc) + safe_fscanf(msh->hdl, INT64_T_FMT, &kwd->NmbLin, msh->err); + else if (msh->ver <= 3) { + ScaWrd(msh, (unsigned char *)&i); + kwd->NmbLin = i; + } else + ScaDblWrd(msh, (unsigned char *)&kwd->NmbLin); + else + kwd->NmbLin = 1; + + if (!strcmp("sr", GmfKwdFmt[KwdCod][2]) || !strcmp("hr", GmfKwdFmt[KwdCod][2])) { + if (msh->typ & Asc) { + safe_fscanf(msh->hdl, "%d", &kwd->NmbTyp, msh->err); + + for (i = 0; i < kwd->NmbTyp; i++) safe_fscanf(msh->hdl, "%d", &kwd->TypTab[i], msh->err); + + // Scan two extra fields for HO solutions: deg and nmb Nodes + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) { + safe_fscanf(msh->hdl, "%d", &kwd->deg, msh->err); + safe_fscanf(msh->hdl, "%d", &kwd->NmbNod, msh->err); + } else { + kwd->deg = 0; + kwd->NmbNod = 1; + } - if(!strcmp("i", GmfKwdFmt[ KwdCod ][1])) - if(msh->typ & Asc) - safe_fscanf(msh->hdl, INT64_T_FMT, &kwd->NmbLin, msh->err); - else - if(msh->ver <= 3) - { - ScaWrd(msh, (unsigned char *)&i); - kwd->NmbLin = i; - } - else - ScaDblWrd(msh, (unsigned char *)&kwd->NmbLin); - else - kwd->NmbLin = 1; - - if(!strcmp("sr", GmfKwdFmt[ KwdCod ][2]) - || !strcmp("hr", GmfKwdFmt[ KwdCod ][2]) ) - { - if(msh->typ & Asc) - { - safe_fscanf(msh->hdl, "%d", &kwd->NmbTyp, msh->err); - - for(i=0;iNmbTyp;i++) - safe_fscanf(msh->hdl, "%d", &kwd->TypTab[i], msh->err); - - // Scan two extra fields for HO solutions: deg and nmb Nodes - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2])) - { - safe_fscanf(msh->hdl, "%d", &kwd->deg, msh->err); - safe_fscanf(msh->hdl, "%d", &kwd->NmbNod, msh->err); - } - else - { - kwd->deg = 0; - kwd->NmbNod = 1; - } + } else { + ScaWrd(msh, (unsigned char *)&kwd->NmbTyp); + for (i = 0; i < kwd->NmbTyp; i++) ScaWrd(msh, (unsigned char *)&kwd->TypTab[i]); + + // Scan two extra fields for HO solutions: deg and nmb Nodes + if (!strcmp("hr", GmfKwdFmt[KwdCod][2])) { + ScaWrd(msh, (unsigned char *)&kwd->deg); + ScaWrd(msh, (unsigned char *)&kwd->NmbNod); + } else { + kwd->deg = 0; + kwd->NmbNod = 1; } - else - { - ScaWrd(msh, (unsigned char *)&kwd->NmbTyp); - - for(i=0;iNmbTyp;i++) - ScaWrd(msh, (unsigned char *)&kwd->TypTab[i]); - - // Scan two extra fields for HO solutions: deg and nmb Nodes - if(!strcmp("hr", GmfKwdFmt[ KwdCod ][2])) - { - ScaWrd(msh, (unsigned char *)&kwd->deg); - ScaWrd(msh, (unsigned char *)&kwd->NmbNod); - } - else - { - kwd->deg = 0; - kwd->NmbNod = 1; - } - } - } + } + } - ExpFmt(msh, KwdCod); - kwd->pos = GetFilPos(msh); + ExpFmt(msh, KwdCod); + kwd->pos = GetFilPos(msh); } - /*----------------------------------------------------------------------------*/ /* Expand the compacted format and compute the line size */ /*----------------------------------------------------------------------------*/ -static void ExpFmt(GmfMshSct *msh, int KwdCod) -{ - int i, j, TmpSiz=0, IntWrd, FltWrd; - char chr; - const char *InpFmt = GmfKwdFmt[ KwdCod ][2]; - KwdSct *kwd = &msh->KwdTab[ KwdCod ]; - - // Set the kwd's type - if(!strlen(GmfKwdFmt[ KwdCod ][1])) - kwd->typ = InfKwd; - else if( !strcmp(InpFmt, "sr") || !strcmp(InpFmt, "hr") ) - kwd->typ = SolKwd; - else - kwd->typ = RegKwd; - - // Get the solution-field's size - if(kwd->typ == SolKwd) - for(i=0;iNmbTyp;i++) - switch(kwd->TypTab[i]) - { - case GmfSca : TmpSiz += 1; break; - case GmfVec : TmpSiz += msh->dim; break; - case GmfSymMat : TmpSiz += (msh->dim * (msh->dim+1)) / 2; break; - case GmfMat : TmpSiz += msh->dim * msh->dim; break; - } - - // Scan each character from the format string - i = kwd->SolSiz = kwd->NmbWrd = 0; - - while(i < (int)strlen(InpFmt)) - { - chr = InpFmt[ i++ ]; - - if(chr == 'd') - { - chr = InpFmt[i++]; - - for(j=0;jdim;j++) - kwd->fmt[ kwd->SolSiz++ ] = chr; - } - else if((chr == 's')||(chr == 'h')) - { - chr = InpFmt[i++]; - - for(j=0;jfmt[ kwd->SolSiz++ ] = chr; +static void ExpFmt(GmfMshSct *msh, int KwdCod) { + int i, j, TmpSiz = 0, IntWrd, FltWrd; + char chr; + const char *InpFmt = GmfKwdFmt[KwdCod][2]; + KwdSct *kwd = &msh->KwdTab[KwdCod]; + + // Set the kwd's type + if (!strlen(GmfKwdFmt[KwdCod][1])) + kwd->typ = InfKwd; + else if (!strcmp(InpFmt, "sr") || !strcmp(InpFmt, "hr")) + kwd->typ = SolKwd; + else + kwd->typ = RegKwd; + + // Get the solution-field's size + if (kwd->typ == SolKwd) + for (i = 0; i < kwd->NmbTyp; i++) switch (kwd->TypTab[i]) { + case GmfSca: + TmpSiz += 1; + break; + case GmfVec: + TmpSiz += msh->dim; + break; + case GmfSymMat: + TmpSiz += (msh->dim * (msh->dim + 1)) / 2; + break; + case GmfMat: + TmpSiz += msh->dim * msh->dim; + break; } - else - kwd->fmt[ kwd->SolSiz++ ] = chr; - } - - if(msh->ver <= 1) - FltWrd = 1; - else - FltWrd = 2; - - if(msh->ver <= 3) - IntWrd = 1; - else - IntWrd = 2; - - for(i=0;iSolSiz;i++) - switch(kwd->fmt[i]) - { - case 'i' : kwd->NmbWrd += IntWrd; break; - case 'c' : kwd->NmbWrd += FilStrSiz; break; - case 'r' : kwd->NmbWrd += FltWrd;break; - } - - // HO solution: duplicate the format as many times as the number of nodes - if( !strcmp(InpFmt, "hr") && (kwd->NmbNod > 1) ) - { - for(i=1;i<=kwd->NmbNod;i++) - for(j=0;jSolSiz;j++) - kwd->fmt[ i * kwd->SolSiz + j ] = kwd->fmt[j]; - kwd->SolSiz *= kwd->NmbNod; - kwd->NmbWrd *= kwd->NmbNod; - } + // Scan each character from the format string + i = kwd->SolSiz = kwd->NmbWrd = 0; + + while (i < (int)strlen(InpFmt)) { + chr = InpFmt[i++]; + + if (chr == 'd') { + chr = InpFmt[i++]; + + for (j = 0; j < msh->dim; j++) kwd->fmt[kwd->SolSiz++] = chr; + } else if ((chr == 's') || (chr == 'h')) { + chr = InpFmt[i++]; + + for (j = 0; j < TmpSiz; j++) kwd->fmt[kwd->SolSiz++] = chr; + } else + kwd->fmt[kwd->SolSiz++] = chr; + } + + if (msh->ver <= 1) + FltWrd = 1; + else + FltWrd = 2; + + if (msh->ver <= 3) + IntWrd = 1; + else + IntWrd = 2; + + for (i = 0; i < kwd->SolSiz; i++) switch (kwd->fmt[i]) { + case 'i': + kwd->NmbWrd += IntWrd; + break; + case 'c': + kwd->NmbWrd += FilStrSiz; + break; + case 'r': + kwd->NmbWrd += FltWrd; + break; + } + + // HO solution: duplicate the format as many times as the number of nodes + if (!strcmp(InpFmt, "hr") && (kwd->NmbNod > 1)) { + for (i = 1; i <= kwd->NmbNod; i++) + for (j = 0; j < kwd->SolSiz; j++) kwd->fmt[i * kwd->SolSiz + j] = kwd->fmt[j]; + + kwd->SolSiz *= kwd->NmbNod; + kwd->NmbWrd *= kwd->NmbNod; + } } - /*----------------------------------------------------------------------------*/ /* Read a four bytes word from a mesh file */ /*----------------------------------------------------------------------------*/ -static void ScaWrd(GmfMshSct *msh, void *ptr) -{ +static void ScaWrd(GmfMshSct *msh, void *ptr) { #ifdef WITH_AIO - if(read(msh->FilDes, ptr, WrdSiz) != WrdSiz) + if (read(msh->FilDes, ptr, WrdSiz) != WrdSiz) #else - if(fread(ptr, WrdSiz, 1, msh->hdl) != 1) + if (fread(ptr, WrdSiz, 1, msh->hdl) != 1) #endif - longjmp(msh->err, -1); + longjmp(msh->err, -1); - if(msh->cod != 1) - SwpWrd((char *)ptr, WrdSiz); + if (msh->cod != 1) SwpWrd((char *)ptr, WrdSiz); } - /*----------------------------------------------------------------------------*/ /* Read an eight bytes word from a mesh file */ /*----------------------------------------------------------------------------*/ -static void ScaDblWrd(GmfMshSct *msh, void *ptr) -{ +static void ScaDblWrd(GmfMshSct *msh, void *ptr) { #ifdef WITH_AIO - if(read(msh->FilDes, ptr, WrdSiz * 2) != WrdSiz * 2) + if (read(msh->FilDes, ptr, WrdSiz * 2) != WrdSiz * 2) #else - if( fread(ptr, WrdSiz, 2, msh->hdl) != 2 ) + if (fread(ptr, WrdSiz, 2, msh->hdl) != 2) #endif - longjmp(msh->err, -1); + longjmp(msh->err, -1); - if(msh->cod != 1) - SwpWrd((char *)ptr, 2 * WrdSiz); + if (msh->cod != 1) SwpWrd((char *)ptr, 2 * WrdSiz); } - /*----------------------------------------------------------------------------*/ /* Read a 4 or 8 bytes position in mesh file */ /*----------------------------------------------------------------------------*/ -static int64_t GetPos(GmfMshSct *msh) -{ - int IntVal; - int64_t pos; +static int64_t GetPos(GmfMshSct *msh) { + int IntVal; + int64_t pos; - if(msh->ver >= 3) - ScaDblWrd(msh, (unsigned char*)&pos); - else - { - ScaWrd(msh, (unsigned char*)&IntVal); - pos = (int64_t)IntVal; - } + if (msh->ver >= 3) + ScaDblWrd(msh, (unsigned char *)&pos); + else { + ScaWrd(msh, (unsigned char *)&IntVal); + pos = (int64_t)IntVal; + } - return(pos); + return (pos); } - /*----------------------------------------------------------------------------*/ /* Write a four bytes word to a mesh file */ /*----------------------------------------------------------------------------*/ -static void RecWrd(GmfMshSct *msh, const void *wrd) -{ - // [Bruno] added error control +static void RecWrd(GmfMshSct *msh, const void *wrd) { + // [Bruno] added error control #ifdef WITH_AIO - if(write(msh->FilDes, wrd, WrdSiz) != WrdSiz) + if (write(msh->FilDes, wrd, WrdSiz) != WrdSiz) #else - if(fwrite(wrd, WrdSiz, 1, msh->hdl) != 1) + if (fwrite(wrd, WrdSiz, 1, msh->hdl) != 1) #endif - longjmp(msh->err,-1); + longjmp(msh->err, -1); } - /*----------------------------------------------------------------------------*/ /* Write an eight bytes word to a mesh file */ /*----------------------------------------------------------------------------*/ -static void RecDblWrd(GmfMshSct *msh, const void *wrd) -{ - // [Bruno] added error control +static void RecDblWrd(GmfMshSct *msh, const void *wrd) { + // [Bruno] added error control #ifdef WITH_AIO - if(write(msh->FilDes, wrd, WrdSiz * 2) != WrdSiz*2) + if (write(msh->FilDes, wrd, WrdSiz * 2) != WrdSiz * 2) #else - if(fwrite(wrd, WrdSiz, 2, msh->hdl) != 2) + if (fwrite(wrd, WrdSiz, 2, msh->hdl) != 2) #endif - longjmp(msh->err,-1); + longjmp(msh->err, -1); } - /*----------------------------------------------------------------------------*/ /* Write a block of four bytes word to a mesh file */ /*----------------------------------------------------------------------------*/ -static void RecBlk(GmfMshSct *msh, const void *blk, int siz) -{ - // Copy this line-block into the main mesh buffer - if(siz) - { - memcpy(&msh->blk[ msh->pos ], blk, (size_t)(siz * WrdSiz)); - msh->pos += siz * WrdSiz; - } +static void RecBlk(GmfMshSct *msh, const void *blk, int siz) { + // Copy this line-block into the main mesh buffer + if (siz) { + memcpy(&msh->blk[msh->pos], blk, (size_t)(siz * WrdSiz)); + msh->pos += siz * WrdSiz; + } - // When the buffer is full or this procedure is APIF77ed with a 0 size, - // flush the cache on disk + // When the buffer is full or this procedure is APIF77ed with a 0 size, + // flush the cache on disk - if( (msh->pos > BufSiz) || (!siz && msh->pos) ) - { + if ((msh->pos > BufSiz) || (!siz && msh->pos)) { #ifdef GMF_WINDOWS - /* - * [Bruno] TODO: check that msh->pos is smaller - * than 4G (fits in 32 bits). - * Note: for now, when trying to write more than 4Gb, it will - * trigger an error (longjmp). - * As far as I understand: - * Given that this function just flushes the cache, and given that - * the cache size is 10000 words, this is much much smaller than 4Gb - * so there is probably no problem. - */ + /* + * [Bruno] TODO: check that msh->pos is smaller + * than 4G (fits in 32 bits). + * Note: for now, when trying to write more than 4Gb, it will + * trigger an error (longjmp). + * As far as I understand: + * Given that this function just flushes the cache, and given that + * the cache size is 10000 words, this is much much smaller than 4Gb + * so there is probably no problem. + */ #ifdef WITH_AIO - if((int64_t)write(msh->FilDes, msh->blk, (int)msh->pos) != msh->pos) -#else - if(fwrite(msh->blk, 1, (size_t)msh->pos, msh->hdl) != msh->pos) -#endif - longjmp(msh->err, -1); -#else + if ((int64_t)write(msh->FilDes, msh->blk, (int)msh->pos) != msh->pos) +#else + if (fwrite(msh->blk, 1, (size_t)msh->pos, msh->hdl) != msh->pos) +#endif + longjmp(msh->err, -1); +#else #ifdef WITH_AIO - if(write(msh->FilDes, msh->blk, msh->pos) != msh->pos) -#else - if(fwrite(msh->blk, 1, msh->pos, msh->hdl) != msh->pos) -#endif - longjmp(msh->err, -1); -#endif - msh->pos = 0; - } + if (write(msh->FilDes, msh->blk, msh->pos) != msh->pos) +#else + if (fwrite(msh->blk, 1, msh->pos, msh->hdl) != msh->pos) +#endif + longjmp(msh->err, -1); +#endif + msh->pos = 0; + } } - /*----------------------------------------------------------------------------*/ /* Write a 4 or 8 bytes position in a mesh file */ /*----------------------------------------------------------------------------*/ -static void SetPos(GmfMshSct *msh, int64_t pos) -{ - int IntVal; +static void SetPos(GmfMshSct *msh, int64_t pos) { + int IntVal; - if(msh->ver >= 3) - RecDblWrd(msh, (unsigned char*)&pos); - else - { - IntVal = (int)pos; - RecWrd(msh, (unsigned char*)&IntVal); - } + if (msh->ver >= 3) + RecDblWrd(msh, (unsigned char *)&pos); + else { + IntVal = (int)pos; + RecWrd(msh, (unsigned char *)&IntVal); + } } - /*----------------------------------------------------------------------------*/ /* Endianness conversion */ /*----------------------------------------------------------------------------*/ -static void SwpWrd(char *wrd, int siz) -{ - char swp; - int i; +static void SwpWrd(char *wrd, int siz) { + char swp; + int i; - for(i=0;ityp & Bin) +static int SetFilPos(GmfMshSct *msh, int64_t pos) { + if (msh->typ & Bin) #ifdef WITH_AIO - return((lseek(msh->FilDes, (off_t)pos, 0) != -1)); + return ((lseek(msh->FilDes, (off_t)pos, 0) != -1)); #else - return((fseek(msh->hdl, (off_t)pos, SEEK_SET) == 0)); + return ((fseek(msh->hdl, (off_t)pos, SEEK_SET) == 0)); #endif - else - return((fseek(msh->hdl, (off_t)pos, SEEK_SET) == 0)); + else + return ((fseek(msh->hdl, (off_t)pos, SEEK_SET) == 0)); } - /*----------------------------------------------------------------------------*/ /* Get current position in a file */ /*----------------------------------------------------------------------------*/ -static int64_t GetFilPos(GmfMshSct *msh) -{ - if(msh->typ & Bin) +static int64_t GetFilPos(GmfMshSct *msh) { + if (msh->typ & Bin) #ifdef WITH_AIO - return(lseek(msh->FilDes, 0, 1)); + return (lseek(msh->FilDes, 0, 1)); #else - return(ftell(msh->hdl)); + return (ftell(msh->hdl)); #endif - else - return(ftell(msh->hdl)); + else + return (ftell(msh->hdl)); } - /*----------------------------------------------------------------------------*/ /* Move the position to the end of file and return the size */ /*----------------------------------------------------------------------------*/ -static int64_t GetFilSiz(GmfMshSct *msh) -{ - int64_t CurPos, EndPos = 0; +static int64_t GetFilSiz(GmfMshSct *msh) { + int64_t CurPos, EndPos = 0; - if(msh->typ & Bin) - { + if (msh->typ & Bin) { #ifdef WITH_AIO - CurPos = lseek(msh->FilDes, 0, 1); - EndPos = lseek(msh->FilDes, 0, 2); - lseek(msh->FilDes, (off_t)CurPos, 0); + CurPos = lseek(msh->FilDes, 0, 1); + EndPos = lseek(msh->FilDes, 0, 2); + lseek(msh->FilDes, (off_t)CurPos, 0); #else - CurPos = ftell(msh->hdl); + CurPos = ftell(msh->hdl); - if(fseek(msh->hdl, 0, SEEK_END) != 0) - longjmp(msh->err, -1); + if (fseek(msh->hdl, 0, SEEK_END) != 0) longjmp(msh->err, -1); - EndPos = ftell(msh->hdl); + EndPos = ftell(msh->hdl); - if(fseek(msh->hdl, (off_t)CurPos, SEEK_SET) != 0) - longjmp(msh->err, -1); + if (fseek(msh->hdl, (off_t)CurPos, SEEK_SET) != 0) longjmp(msh->err, -1); #endif - } - else - { - CurPos = ftell(msh->hdl); + } else { + CurPos = ftell(msh->hdl); - if(fseek(msh->hdl, 0, SEEK_END) != 0) - longjmp(msh->err, -1); + if (fseek(msh->hdl, 0, SEEK_END) != 0) longjmp(msh->err, -1); - EndPos = ftell(msh->hdl); + EndPos = ftell(msh->hdl); - if(fseek(msh->hdl, (off_t)CurPos, SEEK_SET) != 0) - longjmp(msh->err, -1); - } + if (fseek(msh->hdl, (off_t)CurPos, SEEK_SET) != 0) longjmp(msh->err, -1); + } - return(EndPos); + return (EndPos); } - /*----------------------------------------------------------------------------*/ /* Fortran 77 API */ /*----------------------------------------------------------------------------*/ #ifdef F77API -int64_t APIF77(gmfopenmesh)( char *FilNam, int *mod, - int *ver, int *dim, int StrSiz ) -{ - int i = 0; - char TmpNam[ GmfStrSiz ]; +int64_t APIF77(gmfopenmesh)(char *FilNam, int *mod, int *ver, int *dim, int StrSiz) { + int i = 0; + char TmpNam[GmfStrSiz]; - if(StrSiz <= 0) - return(0); + if (StrSiz <= 0) return (0); - // Trim trailing spaces from the fortran string - while(isspace(FilNam[ StrSiz-1 ])) - StrSiz--; + // Trim trailing spaces from the fortran string + while (isspace(FilNam[StrSiz - 1])) StrSiz--; - for(i=0;i #include #include @@ -9,231 +9,213 @@ #include "memory.h" - typedef struct memstack { - size_t size; - void *ptr; - int nxt; - char call[30]; + size_t size; + void *ptr; + int nxt; + char call[30]; } Memstack; -typedef Memstack * pMemstack; - -const int MAXMEM = 300; -pMemstack mstack; -int stack,cur; +typedef Memstack *pMemstack; +const int MAXMEM = 300; +pMemstack mstack; +int stack, cur; -int M_memLeak() { - int i,c=0; +int M_memLeak( ) { + int i, c = 0; - for (i=1; i<=MAXMEM; i++) - if (mstack[i].ptr) c++; - return(c); + for (i = 1; i <= MAXMEM; i++) + if (mstack[i].ptr) c++; + return (c); } /* print out allocated pointers */ -void M_memDump() { - size_t size; - int i,c; +void M_memDump( ) { + size_t size; + int i, c; static long mega = 1024 * 1024; static long kilo = 1024; - fprintf(stdout,"\n -- MEMORY USAGE\n"); - fprintf(stdout," Allocated pointers\n"); + fprintf(stdout, "\n -- MEMORY USAGE\n"); + fprintf(stdout, " Allocated pointers\n"); size = 0; - c = 0; - for (i=1; i<=MAXMEM; i++) - if ( mstack[i].ptr ) { - fprintf(stdout," %3d %3d Pointer %10p size ",++c,i,mstack[i].ptr); + c = 0; + for (i = 1; i <= MAXMEM; i++) + if (mstack[i].ptr) { + fprintf(stdout, " %3d %3d Pointer %10p size ", ++c, i, mstack[i].ptr); if (mstack[i].size > mega) - fprintf(stdout," %10d Mbytes ",(int)(mstack[i].size/mega)); + fprintf(stdout, " %10d Mbytes ", (int)(mstack[i].size / mega)); else if (mstack[i].size > kilo) - fprintf(stdout," %10d Kbytes ",(int)(mstack[i].size/kilo)); - else - fprintf(stdout," %10d bytes ",(int)(mstack[i].size)); - fprintf(stdout,"(%s)\n",mstack[i].call); + fprintf(stdout, " %10d Kbytes ", (int)(mstack[i].size / kilo)); + else + fprintf(stdout, " %10d bytes ", (int)(mstack[i].size)); + fprintf(stdout, "(%s)\n", mstack[i].call); size += mstack[i].size; } - fprintf(stdout," Memory leaks "); - if ( size > mega ) - fprintf(stdout," %10d Mbytes %d pointers\n",(int)(size/mega),c); - else if ( size > kilo ) - fprintf(stdout," %10d Kbytes %d pointers\n",(int)(size/kilo),c); - else if ( size ) - fprintf(stdout," %10d bytes %d pointers\n",(int)size,c); + fprintf(stdout, " Memory leaks "); + if (size > mega) + fprintf(stdout, " %10d Mbytes %d pointers\n", (int)(size / mega), c); + else if (size > kilo) + fprintf(stdout, " %10d Kbytes %d pointers\n", (int)(size / kilo), c); + else if (size) + fprintf(stdout, " %10d bytes %d pointers\n", (int)size, c); } /* Returns allocated memory space in bytes */ -size_t M_memSize() { +size_t M_memSize( ) { size_t size; - int i; + int i; size = 0; - for (i=1; i<=MAXMEM; i++) - if ( mstack[i].ptr ) - size += mstack[i].size; + for (i = 1; i <= MAXMEM; i++) + if (mstack[i].ptr) size += mstack[i].size; return size; } /* Allocates space for a block of at least size bytes, but does not initialize the space. */ -void *M_malloc(size_t size,char *call) { - int i; +void *M_malloc(size_t size, char *call) { + int i; /* check if first call */ - if ( !mstack ) { - mstack = (Memstack *)calloc((1+MAXMEM),sizeof(Memstack)); + if (!mstack) { + mstack = (Memstack *)calloc((1 + MAXMEM), sizeof(Memstack)); assert(mstack); - for (i=1; i= nelem * elsize bytes. */ -void *M_calloc(size_t nelem, size_t elsize,char *call) { - int i; +void *M_calloc(size_t nelem, size_t elsize, char *call) { + int i; /* check if first call */ - if ( !mstack ) { - mstack = (Memstack *)calloc((1+MAXMEM),sizeof(Memstack)); + if (!mstack) { + mstack = (Memstack *)calloc((1 + MAXMEM), sizeof(Memstack)); assert(mstack); - for (i=1; i 1024*1024) - fprintf(stdout," Total size : %10zd Mbytes", - (long int)(memsize/(1024.*1024.))); + memsize = M_memSize( ); + if (memsize) { + fprintf(stdout, "\n -- MEMORY REQUIREMENTS\n"); + if (memsize > 1024 * 1024) + fprintf(stdout, " Total size : %10zd Mbytes", (long int)(memsize / (1024. * 1024.))); else if (memsize > 1024) - fprintf(stdout," Total size : %10zd Kbytes",(long int)(memsize/1024.)); + fprintf(stdout, " Total size : %10zd Kbytes", (long int)(memsize / 1024.)); else - fprintf(stdout," Total size : %10zd bytes ",(long int)memsize); - fprintf(stdout," (i.e. %d bytes/point)\n",memsize / np); + fprintf(stdout, " Total size : %10zd bytes ", (long int)memsize); + fprintf(stdout, " (i.e. %d bytes/point)\n", memsize / np); } } diff --git a/src/libMesh/memory.h b/src/libMesh/memory.h index 4ef55ac01..f5cfb3fa3 100644 --- a/src/libMesh/memory.h +++ b/src/libMesh/memory.h @@ -9,19 +9,18 @@ extern "C" { #include /* prototype (re)definitions */ -void *M_malloc(size_t size,char *call); -void *M_calloc(size_t nelem,size_t elsize,char *call); -void *M_realloc(void *ptr, size_t size,char *call); -void M_free(void *ptr); +void *M_malloc(size_t size, char *call); +void *M_calloc(size_t nelem, size_t elsize, char *call); +void *M_realloc(void *ptr, size_t size, char *call); +void M_free(void *ptr); /* ptototypes : tools */ -int M_memLeak(); -void M_memDump(); -size_t M_memSize(); - +int M_memLeak( ); +void M_memDump( ); +size_t M_memSize( ); #ifdef __cplusplus } #endif -#endif //MEMORY_H_ +#endif // MEMORY_H_ diff --git a/src/medit/animat.c b/src/medit/animat.c index a7e009603..e5d1670d4 100644 --- a/src/medit/animat.c +++ b/src/medit/animat.c @@ -236,9 +236,8 @@ int animat( ) { fprintf(stdout, " File name(s) missing. Please enter : "); fflush(stdout); - while (fgetc(stdin) != EOF) - ; // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - // systems + while (fgetc(stdin) != EOF); // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + // systems res = fgets(data, 120, stdin); if (!strlen(data) || res == NULL) { fprintf(stdout, " ## Error\n"); @@ -247,9 +246,8 @@ int animat( ) { fprintf(stdout, " Enter range [start,end] :"); fflush(stdout); - while (fgetc(stdin) != EOF) - ; // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - // systems + while (fgetc(stdin) != EOF); // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + // systems ret = fscanf(stdin, "%d %d", &animdep, &animfin); if (ret == EOF) { fprintf(stdout, " ## Error\n"); diff --git a/src/medit/camera.c b/src/medit/camera.c index cb9d255f9..0d7c21f1c 100644 --- a/src/medit/camera.c +++ b/src/medit/camera.c @@ -100,10 +100,8 @@ void updateCamera(pScene sc, pCamera c, double azim, double elev) { c->speed[1] = sin(lelev); c->speed[2] = cos(lazim) * cos(lelev); - d = (double)c->speed[0] * sc->par.sunpos[0] + c->speed[1] * sc->par.sunpos[1] + - c->speed[2] * sc->par.sunpos[2]; - d = d / sqrt((double)sc->par.sunpos[0] * sc->par.sunpos[0] + - sc->par.sunpos[1] * sc->par.sunpos[1] + sc->par.sunpos[2] * sc->par.sunpos[2]); + d = (double)c->speed[0] * sc->par.sunpos[0] + c->speed[1] * sc->par.sunpos[1] + c->speed[2] * sc->par.sunpos[2]; + d = d / sqrt((double)sc->par.sunpos[0] * sc->par.sunpos[0] + sc->par.sunpos[1] * sc->par.sunpos[1] + sc->par.sunpos[2] * sc->par.sunpos[2]); d = acos(d); if (fabs(d) > 0.10 * sc->persp->fovy * DTOR) updateSun(sc, c); } diff --git a/src/medit/cenrad.c b/src/medit/cenrad.c index 8cb37551f..3428fea1c 100644 --- a/src/medit/cenrad.c +++ b/src/medit/cenrad.c @@ -54,8 +54,7 @@ int cenrad(pMesh mesh, int iel, double *c, double *rad) { n1[1] = uy * dd; n1[2] = uz * dd; /* plan: vecteur directeur passant par milieu(1,4) */ - pl1 = - n1[0] * (p4->c[0] + p1->c[0]) + n1[1] * (p4->c[1] + p1->c[1]) + n1[2] * (p4->c[2] + p1->c[2]); + pl1 = n1[0] * (p4->c[0] + p1->c[0]) + n1[1] * (p4->c[1] + p1->c[1]) + n1[2] * (p4->c[2] + p1->c[2]); ux = p4->c[0] - p2->c[0]; uy = p4->c[1] - p2->c[1]; @@ -64,8 +63,7 @@ int cenrad(pMesh mesh, int iel, double *c, double *rad) { n2[0] = ux * dd; n2[1] = uy * dd; n2[2] = uz * dd; - pl2 = - n2[0] * (p4->c[0] + p2->c[0]) + n2[1] * (p4->c[1] + p2->c[1]) + n2[2] * (p4->c[2] + p2->c[2]); + pl2 = n2[0] * (p4->c[0] + p2->c[0]) + n2[1] * (p4->c[1] + p2->c[1]) + n2[2] * (p4->c[2] + p2->c[2]); ux = p4->c[0] - p3->c[0]; uy = p4->c[1] - p3->c[1]; @@ -74,8 +72,7 @@ int cenrad(pMesh mesh, int iel, double *c, double *rad) { n3[0] = ux * dd; n3[1] = uy * dd; n3[2] = uz * dd; - pl3 = - n3[0] * (p4->c[0] + p3->c[0]) + n3[1] * (p4->c[1] + p3->c[1]) + n3[2] * (p4->c[2] + p3->c[2]); + pl3 = n3[0] * (p4->c[0] + p3->c[0]) + n3[1] * (p4->c[1] + p3->c[1]) + n3[2] * (p4->c[2] + p3->c[2]); /* center = intersection of 3 planes */ ux = n2[1] * n3[2] - n2[2] * n3[1]; @@ -86,18 +83,15 @@ int cenrad(pMesh mesh, int iel, double *c, double *rad) { dd = 0.5 / dd; c1 = ux * pl1 + uy * pl2 + uz * pl3; - c2 = pl1 * (n2[2] * n3[0] - n2[0] * n3[2]) + pl2 * (n1[0] * n3[2] - n3[0] * n1[2]) + - pl3 * (n2[0] * n1[2] - n2[2] * n1[0]); - c3 = pl1 * (n2[0] * n3[1] - n2[1] * n3[0]) + pl2 * (n3[0] * n1[1] - n3[1] * n1[0]) + - pl3 * (n1[0] * n2[1] - n2[0] * n1[1]); + c2 = pl1 * (n2[2] * n3[0] - n2[0] * n3[2]) + pl2 * (n1[0] * n3[2] - n3[0] * n1[2]) + pl3 * (n2[0] * n1[2] - n2[2] * n1[0]); + c3 = pl1 * (n2[0] * n3[1] - n2[1] * n3[0]) + pl2 * (n3[0] * n1[1] - n3[1] * n1[0]) + pl3 * (n1[0] * n2[1] - n2[0] * n1[1]); c[0] = dd * c1; c[1] = dd * c2; c[2] = dd * c3; /* radius (squared) */ - *rad = (c[0] - p4->c[0]) * (c[0] - p4->c[0]) + (c[1] - p4->c[1]) * (c[1] - p4->c[1]) + - (c[2] - p4->c[2]) * (c[2] - p4->c[2]); + *rad = (c[0] - p4->c[0]) * (c[0] - p4->c[0]) + (c[1] - p4->c[1]) * (c[1] - p4->c[1]) + (c[2] - p4->c[2]) * (c[2] - p4->c[2]); return (1); } diff --git a/src/medit/clip.c b/src/medit/clip.c index 7fb01d2c6..7fad6560b 100644 --- a/src/medit/clip.c +++ b/src/medit/clip.c @@ -123,8 +123,7 @@ void updateClip(pClip clip, pMesh mesh) { dmax = mesh->xmax - mesh->xmin; dmax = max(dmax, mesh->ymax - mesh->ymin); dmax = max(dmax, mesh->zmax - mesh->zmin) / 1.8; - if (fabs(cliptr->tra[12]) > dmax || fabs(cliptr->tra[13]) > dmax || - fabs(cliptr->tra[14]) > dmax) { + if (fabs(cliptr->tra[12]) > dmax || fabs(cliptr->tra[13]) > dmax || fabs(cliptr->tra[14]) > dmax) { if (cliptr->manim == GL_TRUE) { cliptr->panx = -cliptr->panx; cliptr->pany = -cliptr->pany; @@ -192,8 +191,7 @@ void clipVertices(pMesh mesh, pScene sc, pClip clip) { p0 = &mesh->point[k]; if (p0->tag & M_UNUSED) continue; - dd1 = - p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + clip->eqn[3]; + dd1 = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + clip->eqn[3]; if (dd1 > zero) p0->clip = 2; else if (dd1 < zero) @@ -369,8 +367,7 @@ void resetClip(pScene sc, pClip clip, pMesh mesh) { double dd; resetTransform(clip->cliptr); - dd = sc->par.clip[0] * sc->par.clip[3] + sc->par.clip[1] * sc->par.clip[4] + - sc->par.clip[2] * sc->par.clip[5]; + dd = sc->par.clip[0] * sc->par.clip[3] + sc->par.clip[1] * sc->par.clip[4] + sc->par.clip[2] * sc->par.clip[5]; clip->active |= C_REDO; clip->eqn[0] = sc->par.clip[3]; diff --git a/src/medit/clipvol.c b/src/medit/clipvol.c index 67bc0fb87..de24b43bc 100644 --- a/src/medit/clipvol.c +++ b/src/medit/clipvol.c @@ -39,9 +39,9 @@ GLuint capTetra(pMesh mesh) { pPoint p0, p1; pMaterial pm; double dd1[6], d, ax, ay, az, bx, by, bz; - double cx[4] = {}, cy[4] = {}, cz[4] = {}, cc; + double cx[4] = { }, cy[4] = { }, cz[4] = { }, cc; float n[3]; - int m, k1, k2, l, transp, pos[6] = {}, neg[6] = {}, nbpos, nbneg, nbnul; + int m, k1, k2, l, transp, pos[6] = { }, neg[6] = { }, nbpos, nbneg, nbnul; static int tn[4] = {0, 0, 1, 1}; static int tp[4] = {0, 1, 1, 0}; @@ -100,8 +100,7 @@ GLuint capTetra(pMesh mesh) { else nbnul++; - dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + - clip->eqn[3]; + dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + clip->eqn[3]; } if (nbneg == 2 && nbpos == 2) { @@ -206,9 +205,9 @@ GLuint capTetraMap(pMesh mesh) { pMaterial pm; pSolution ps0, ps1; double dd1[6], d, ax, ay, az, bx, by, bz; - double cx[4] = {}, cy[4] = {}, cz[4] = {}, cc; - float n[3], sol[4] = {}; - int m, k1, k2, l, pos[6] = {}, neg[6] = {}, nbpos, nbneg, nbnul; + double cx[4] = { }, cy[4] = { }, cz[4] = { }, cc; + float n[3], sol[4] = { }; + int m, k1, k2, l, pos[6] = { }, neg[6] = { }, nbpos, nbneg, nbnul; static int tn[4] = {0, 0, 1, 1}; static int tp[4] = {0, 1, 1, 0}; triangle t1, t2; @@ -255,8 +254,7 @@ GLuint capTetraMap(pMesh mesh) { else nbnul++; - dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + - clip->eqn[3]; + dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + clip->eqn[3]; } if (nbneg == 2 && nbpos == 2) { @@ -418,9 +416,9 @@ GLuint capTetraIso(pMesh mesh) { pMaterial pm; pSolution ps0, ps1; double dd1[6]; - double rgb[3], cx[4] = {}, cy[4] = {}, cz[4] = {}, ccx, ccy, ccz, cc; + double rgb[3], cx[4] = { }, cy[4] = { }, cz[4] = { }, ccx, ccy, ccz, cc; float iso, kc, sol[4]; - int i, m, k, k1, k2, l, l1, nc, pos[6] = {}, neg[6] = {}, nbpos, nbneg, nbnul, ncol; + int i, m, k, k1, k2, l, l1, nc, pos[6] = { }, neg[6] = { }, nbpos, nbneg, nbnul, ncol; static int tn[4] = {0, 0, 1, 1}; static int tp[4] = {0, 1, 1, 0}; static double hsv[3] = {0.0f, 1.0f, 0.20f}; @@ -484,8 +482,7 @@ GLuint capTetraIso(pMesh mesh) { else nbnul++; - dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + - clip->eqn[3]; + dd1[l] = p0->c[0] * clip->eqn[0] + p0->c[1] * clip->eqn[1] + p0->c[2] * clip->eqn[2] + clip->eqn[3]; } if (nbneg == 2 && nbpos == 2) { diff --git a/src/medit/critip.c b/src/medit/critip.c index 0ed3dec91..fdad54718 100644 --- a/src/medit/critip.c +++ b/src/medit/critip.c @@ -162,8 +162,7 @@ GLuint listCritPoint(pScene sc, pMesh mesh) { p[1] = dd * (vv[0][1] * vv[2][0] - vv[0][0] * vv[2][1]); p[2] = 0.0; - if (p[0] < mesh->xmin - mesh->xtra || p[0] > mesh->xmax - mesh->xtra || - p[1] < mesh->ymin - mesh->ytra || p[1] > mesh->ymax - mesh->ytra) { + if (p[0] < mesh->xmin - mesh->xtra || p[0] > mesh->xmax - mesh->xtra || p[1] < mesh->ymin - mesh->ytra || p[1] > mesh->ymax - mesh->ytra) { k = pt->nxt; continue; } else if (!inTria(mesh, k, p, bc)) { diff --git a/src/medit/cube.c b/src/medit/cube.c index d17e86859..a596b77d5 100644 --- a/src/medit/cube.c +++ b/src/medit/cube.c @@ -108,8 +108,7 @@ void dumpCube(pScene sc, pMesh mesh, pCube cube) { u[2] = cube->cmi[2] - mesh->ztra; u[3] = 1.0; transformPoint2(v, u, tr); - fprintf(out, "\n%f %f %f %f\n", v[0] + mesh->xtra, v[1] + mesh->ytra, v[2] + mesh->ztra, - v[3]); + fprintf(out, "\n%f %f %f %f\n", v[0] + mesh->xtra, v[1] + mesh->ytra, v[2] + mesh->ztra, v[3]); u[0] = cube->cma[0] - mesh->xtra; u[1] = cube->cma[1] - mesh->ytra; @@ -117,11 +116,9 @@ void dumpCube(pScene sc, pMesh mesh, pCube cube) { transformPoint2(v, u, tr); fprintf(out, "%f %f %f %f\n", v[0] + mesh->xtra, v[1] + mesh->ytra, v[2] + mesh->ztra, v[3]); - fprintf(out, "\n%f %f %f\n", cube->cubetr->tra[12], cube->cubetr->tra[13], - cube->cubetr->tra[14]); + fprintf(out, "\n%f %f %f\n", cube->cubetr->tra[12], cube->cubetr->tra[13], cube->cubetr->tra[14]); - fprintf(out, "%f %f %f %f\n", cube->cubetr->angle, cube->cubetr->axis[0], - cube->cubetr->axis[1], cube->cubetr->axis[2]); + fprintf(out, "%f %f %f %f\n", cube->cubetr->angle, cube->cubetr->axis[0], cube->cubetr->axis[1], cube->cubetr->axis[2]); fclose(out); } } diff --git a/src/medit/dlists.c b/src/medit/dlists.c index d1872c47b..8938bcf7e 100644 --- a/src/medit/dlists.c +++ b/src/medit/dlists.c @@ -30,8 +30,7 @@ extern "C" { /* list of element faces */ static int ct[4][3] = {{0, 1, 2}, {0, 3, 1}, {1, 3, 2}, {0, 2, 3}}; -static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; +static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; static float redcol[4] = {1.0, 0.0, 0.0, 1.0}; static float greencol[4] = {0.0, 0.6, 0.0, 1.0}; @@ -597,14 +596,11 @@ GLuint listTetra(pScene sc, pMesh mesh, ubyte clip) { } glNormal3fv(n); - glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, - shrink * (p0->c[2] - cz) + cz); + glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, - shrink * (p1->c[2] - cz) + cz); + glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, - shrink * (p2->c[2] - cz) + cz); + glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, shrink * (p2->c[2] - cz) + cz); } k = pt->nxt; @@ -716,17 +712,13 @@ GLuint listHexa(pScene sc, pMesh mesh, ubyte clip) { } glNormal3fv(n); - glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, - shrink * (p0->c[2] - cz) + cz); + glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, - shrink * (p1->c[2] - cz) + cz); + glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, - shrink * (p2->c[2] - cz) + cz); + glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, shrink * (p2->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p3->c[0] - cx) + cx, shrink * (p3->c[1] - cy) + cy, - shrink * (p3->c[2] - cz) + cz); + glVertex3f(shrink * (p3->c[0] - cx) + cx, shrink * (p3->c[1] - cy) + cy, shrink * (p3->c[2] - cz) + cz); } k = ph->nxt; diff --git a/src/medit/ellipse.c b/src/medit/ellipse.c index 4b21fe606..b7701ebad 100644 --- a/src/medit/ellipse.c +++ b/src/medit/ellipse.c @@ -35,8 +35,7 @@ extern "C" { extern int refmat; extern int eigen2(double m[3], double lambda[2], double vp[2][2]); -static GLfloat IdMatrix[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; +static GLfloat IdMatrix[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; void drawEllipsoid(pScene sc, pMesh mesh, int typel, int k) { pMaterial pm; @@ -73,8 +72,7 @@ void drawEllipsoid(pScene sc, pMesh mesh, int typel, int k) { fprintf(stdout, " Eigenvalues : %f %f %f %d\n", lambda[0], lambda[1], lambda[2], iord); if (lambda[0] <= 0.0 || lambda[1] <= 0.0 || lambda[2] <= 0.0) return; - fprintf(stdout, " Sizes : %f %f %f\n", 1.0 / sqrt(lambda[0]), 1.0 / sqrt(lambda[1]), - 1.0 / sqrt(lambda[2])); + fprintf(stdout, " Sizes : %f %f %f\n", 1.0 / sqrt(lambda[0]), 1.0 / sqrt(lambda[1]), 1.0 / sqrt(lambda[2])); } else if (lambda[0] <= 0.0 || lambda[1] <= 0.0 || lambda[2] <= 0.0) { return; } diff --git a/src/medit/grafic.h b/src/medit/grafic.h index daa842b9b..1dea783bd 100644 --- a/src/medit/grafic.h +++ b/src/medit/grafic.h @@ -52,14 +52,7 @@ extern "C" { #define LEFT 1 #define RIGHT 2 -enum { - WIRE = S_BDRY, - HIDDEN = S_BDRY + S_FILL, - DEPTH = S_BDRY + S_COLOR, - FILL = S_FILL + S_COLOR, - SHADED = S_BDRY + S_FILL + S_COLOR, - SIZEMAP = S_BDRY + S_FILL + S_MAP -}; +enum { WIRE = S_BDRY, HIDDEN = S_BDRY + S_FILL, DEPTH = S_BDRY + S_COLOR, FILL = S_FILL + S_COLOR, SHADED = S_BDRY + S_FILL + S_COLOR, SIZEMAP = S_BDRY + S_FILL + S_MAP }; enum { LTria, LQuad, LTets, LHexa, LEdges, LPoint }; diff --git a/src/medit/hash.c b/src/medit/hash.c index 9a043a229..359d73a96 100644 --- a/src/medit/hash.c +++ b/src/medit/hash.c @@ -38,8 +38,7 @@ extern "C" { #define KB (int)57 #define KC (int)79 -static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; +static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; static int idir[5] = {0, 1, 2, 0, 1}; static int idirt[7] = {0, 1, 2, 3, 0, 1, 2}; diff --git a/src/medit/ilists.c b/src/medit/ilists.c index dddd3b6b2..d846d358e 100644 --- a/src/medit/ilists.c +++ b/src/medit/ilists.c @@ -240,8 +240,8 @@ GLuint listTetraIso(pScene sc, pMesh mesh) { pMaterial pm; pSolution ps0, ps1; double delta, rgb[4], d, ax, ay, az, bx, by, bz; - float n[3], cx[4] = {}, cy[4] = {}, cz[4] = {}, cc; - int m, k, k1, k2, i, l, pos[4] = {}, neg[4] = {}, nbpos, nbneg, nbnul, nv, nf; + float n[3], cx[4] = { }, cy[4] = { }, cz[4] = { }, cc; + int m, k, k1, k2, i, l, pos[4] = { }, neg[4] = { }, nbpos, nbneg, nbnul, nv, nf; static double hsv[3] = {0.0f, 1.0f, 0.80f}; static int tn[4] = {0, 0, 1, 1}; static int tp[4] = {0, 1, 1, 0}; @@ -466,7 +466,7 @@ int tetraIsoPOVray(pScene sc, pMesh mesh) { pSolution ps0, ps1; double delta; float cx[4], cy[4], cz[4], cc; - int m, k, k1, k2, i, l, pos[4] = {}, neg[4] = {}, nbpos, nbneg, nbnul; + int m, k, k1, k2, i, l, pos[4] = { }, neg[4] = { }, nbpos, nbneg, nbnul; char data[128]; static int tn[4] = {0, 0, 1, 1}; static int tp[4] = {0, 1, 1, 0}; @@ -548,21 +548,15 @@ int tetraIsoPOVray(pScene sc, pMesh mesh) { } fprintf(isofil, "triangle {\n"); - fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, - cz[0] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>,\n", cx[1] + mesh->xtra, cy[1] + mesh->ytra, - cz[1] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, - cz[2] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, cz[0] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[1] + mesh->xtra, cy[1] + mesh->ytra, cz[1] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, cz[2] + mesh->ztra); fprintf(isofil, "}\n"); fprintf(isofil, "triangle {\n"); - fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, - cz[0] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>,\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, - cz[2] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>\n", cx[3] + mesh->xtra, cy[3] + mesh->ytra, - cz[3] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, cz[0] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, cz[2] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>\n", cx[3] + mesh->xtra, cy[3] + mesh->ytra, cz[3] + mesh->ztra); fprintf(isofil, "}\n"); } else if (!nbnul) { for (l = 0; l < 3; l++) { @@ -581,12 +575,9 @@ int tetraIsoPOVray(pScene sc, pMesh mesh) { } fprintf(isofil, "triangle {\n"); - fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, - cz[0] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>,\n", cx[1] + mesh->xtra, cy[1] + mesh->ytra, - cz[1] + mesh->ztra); - fprintf(isofil, " <%f,%f,%f>\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, - cz[2] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[0] + mesh->xtra, cy[0] + mesh->ytra, cz[0] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>,\n", cx[1] + mesh->xtra, cy[1] + mesh->ytra, cz[1] + mesh->ztra); + fprintf(isofil, " <%f,%f,%f>\n", cx[2] + mesh->xtra, cy[2] + mesh->ytra, cz[2] + mesh->ztra); fprintf(isofil, "}\n"); } diff --git a/src/medit/image.c b/src/medit/image.c index 702b8de07..dafdf6ece 100644 --- a/src/medit/image.c +++ b/src/medit/image.c @@ -250,8 +250,7 @@ int savePPM(const char *imgname, pPPMimage img, int typimg) { fprintf(out, "%d %d\n", img->sizeX, img->sizeY); fprintf(out, "255\n"); bitsize = (img->sizeX * 24 + 7) / 8 * img->sizeY; - if (fwrite(img->data, sizeof(ubyte), bitsize, out) < bitsize) - fprintf(stderr, " ## Data file corrupted.\n"); + if (fwrite(img->data, sizeof(ubyte), bitsize, out) < bitsize) fprintf(stderr, " ## Data file corrupted.\n"); break; } diff --git a/src/medit/inmsh2.c b/src/medit/inmsh2.c index 33ce3d169..a5a3f7286 100644 --- a/src/medit/inmsh2.c +++ b/src/medit/inmsh2.c @@ -171,11 +171,9 @@ int inmsh2(pMesh mesh) { pp1->tag = M_NOTAG; } else if (degree == 3) { pt1 = &mesh->tria[++mesh->nt]; - ret = fscanf(inf, "%d %d %d %d %d %d %d\n", &pt1->v[0], &pt1->v[1], &pt1->v[2], &ref, &dum, - &dum, &dum); + ret = fscanf(inf, "%d %d %d %d %d %d %d\n", &pt1->v[0], &pt1->v[1], &pt1->v[2], &ref, &dum, &dum, &dum); if (ret == EOF) printf("fscanf error\n"); - if (pt1->v[0] <= 0 || pt1->v[0] > mesh->np || pt1->v[1] <= 0 || pt1->v[1] > mesh->np || - pt1->v[2] <= 0 || pt1->v[2] > mesh->np) { + if (pt1->v[0] <= 0 || pt1->v[0] > mesh->np || pt1->v[1] <= 0 || pt1->v[1] > mesh->np || pt1->v[2] <= 0 || pt1->v[2] > mesh->np) { ret = fprintf(stdout, " ## Wrong index\n"); if (ret == EOF) printf("fscanf error\n"); disc++; @@ -196,8 +194,7 @@ int inmsh2(pMesh mesh) { if (ret == EOF) printf("fscanf error\n"); ret = fscanf(inf, "%d %d %d %d %d", &ref, &dum, &dum, &dum, &dum); if (ret == EOF) printf("fscanf error\n"); - if (pq1->v[0] <= 0 || pq1->v[0] > mesh->np || pq1->v[1] <= 0 || pq1->v[1] > mesh->np || - pq1->v[2] <= 0 || pq1->v[2] > mesh->np || pq1->v[3] <= 0 || pq1->v[3] > mesh->np) { + if (pq1->v[0] <= 0 || pq1->v[0] > mesh->np || pq1->v[1] <= 0 || pq1->v[1] > mesh->np || pq1->v[2] <= 0 || pq1->v[2] > mesh->np || pq1->v[3] <= 0 || pq1->v[3] > mesh->np) { fprintf(stdout, " ## Wrong index\n"); disc++; pq1->v[0] = 0; diff --git a/src/medit/inout.c b/src/medit/inout.c index 60d5b3fa2..9949cef05 100644 --- a/src/medit/inout.c +++ b/src/medit/inout.c @@ -200,8 +200,7 @@ int loadMesh(pMesh mesh) { for (k = 1; k <= mesh->nhex; k++) { ph = &mesh->hexa[k]; - GmfGetLin(inm, GmfHexahedra, &ph->v[0], &ph->v[1], &ph->v[2], &ph->v[3], &ph->v[4], &ph->v[5], - &ph->v[6], &ph->v[7], &ref); + GmfGetLin(inm, GmfHexahedra, &ph->v[0], &ph->v[1], &ph->v[2], &ph->v[3], &ph->v[4], &ph->v[5], &ph->v[6], &ph->v[7], &ref); ph->ref = ref & 0x7fff; for (i = 0; i < 8; i++) { @@ -568,8 +567,7 @@ int saveMesh(pScene sc, pMesh mesh, char *fileout, ubyte clipon) { if (i < 3) continue; ref = pt->ref; - GmfSetLin(outm, GmfTriangles, mesh->point[pt->v[0]].tmp, mesh->point[pt->v[1]].tmp, - mesh->point[pt->v[2]].tmp, ref); + GmfSetLin(outm, GmfTriangles, mesh->point[pt->v[0]].tmp, mesh->point[pt->v[1]].tmp, mesh->point[pt->v[2]].tmp, ref); } /* write quads */ @@ -607,8 +605,7 @@ int saveMesh(pScene sc, pMesh mesh, char *fileout, ubyte clipon) { if (i < 4) continue; ref = pq->ref; - GmfSetLin(outm, GmfQuadrilaterals, mesh->point[pq->v[0]].tmp, mesh->point[pq->v[1]].tmp, - mesh->point[pq->v[2]].tmp, mesh->point[pq->v[3]].tmp, ref); + GmfSetLin(outm, GmfQuadrilaterals, mesh->point[pq->v[0]].tmp, mesh->point[pq->v[1]].tmp, mesh->point[pq->v[2]].tmp, mesh->point[pq->v[3]].tmp, ref); } /* write tetrahedra */ @@ -629,8 +626,7 @@ int saveMesh(pScene sc, pMesh mesh, char *fileout, ubyte clipon) { if (i < 4) continue; ref = ptt->ref; - GmfSetLin(outm, GmfTetrahedra, mesh->point[ptt->v[0]].tmp, mesh->point[ptt->v[1]].tmp, - mesh->point[ptt->v[2]].tmp, mesh->point[ptt->v[3]].tmp, ref); + GmfSetLin(outm, GmfTetrahedra, mesh->point[ptt->v[0]].tmp, mesh->point[ptt->v[1]].tmp, mesh->point[ptt->v[2]].tmp, mesh->point[ptt->v[3]].tmp, ref); } /* write hexahedra */ @@ -650,7 +646,7 @@ int saveMesh(pScene sc, pMesh mesh, char *fileout, ubyte clipon) { int loadSol(pMesh mesh, char *filename, int numsol) { pSolution sol; double dbuf[GmfMaxTyp]; - float fbuf[GmfMaxTyp] = {}; + float fbuf[GmfMaxTyp] = { }; double m[6], lambda[3], eigv[3][3], vp[2][2]; long inm; int k, i, key = 0, nel, size, type, iord, off, typtab[GmfMaxTyp], ver, dim; @@ -678,8 +674,7 @@ int loadSol(pMesh mesh, char *filename, int numsol) { nel = GmfStatKwd(inm, GmfSolAtVertices, &type, &size, typtab); if (nel) { - if (nel > mesh->np) - fprintf(stderr, " %%%% Wrong number: %d Solutions discarded\n", nel - mesh->np); + if (nel > mesh->np) fprintf(stderr, " %%%% Wrong number: %d Solutions discarded\n", nel - mesh->np); mesh->typage = 2; key = GmfSolAtVertices; diff --git a/src/medit/inout_morice.c b/src/medit/inout_morice.c index 3fe8625a9..021224e0e 100644 --- a/src/medit/inout_morice.c +++ b/src/medit/inout_morice.c @@ -1003,10 +1003,9 @@ int loadMesh_popen(pMesh mesh) { /* function of lecture */ -int loadScaVecTen(pMesh mesh, int numsol, int dim, int ver, int nel, int type, int size, - int *typtab, int key, char *natureread) { +int loadScaVecTen(pMesh mesh, int numsol, int dim, int ver, int nel, int type, int size, int *typtab, int key, char *natureread) { pSolution sol; - float fbuf[GmfMaxTyp] = {}; + float fbuf[GmfMaxTyp] = { }; double m[6], lambda[3], eigv[3][3], vp[2][2]; int k, i, iord, off; double ScaSol[1], VecSol[3], TenSol[9]; diff --git a/src/medit/inout_popenbinaire.c b/src/medit/inout_popenbinaire.c index 5d7e4d1ad..2da8d4aba 100644 --- a/src/medit/inout_popenbinaire.c +++ b/src/medit/inout_popenbinaire.c @@ -739,8 +739,7 @@ int loadMesh_popen_bin(pMesh mesh) { /* function of lecture */ -int loadScaVecTen_bin(pMesh mesh, int numsol, int dim, int ver, int nel, int type, int size, - int *typtab, int key) { +int loadScaVecTen_bin(pMesh mesh, int numsol, int dim, int ver, int nel, int type, int size, int *typtab, int key) { pSolution sol; float fbuf[GmfMaxTyp]; double m[6], lambda[3], eigv[3][3], vp[2][2]; diff --git a/src/medit/items.c b/src/medit/items.c index a82724a3c..7483a40cf 100644 --- a/src/medit/items.c +++ b/src/medit/items.c @@ -81,8 +81,7 @@ void drawAxis(pScene sc, int dim) { mesh = cv.mesh[sc->idmesh]; glPushMatrix( ); - glTranslatef(1.01 * (mesh->xmin - mesh->xtra), 1.01 * (mesh->ymin - mesh->ytra), - 1.01 * (mesh->zmin - mesh->ztra)); + glTranslatef(1.01 * (mesh->xmin - mesh->xtra), 1.01 * (mesh->ymin - mesh->ytra), 1.01 * (mesh->zmin - mesh->ztra)); glScalef(0.6 * sc->dmin, 0.6 * sc->dmin, 0.6 * sc->dmin); glLineWidth(max(2, sc->par.linewidth)); glColor3f(1.0, 0., 0.); @@ -157,8 +156,7 @@ void drawBox(pScene sc, pMesh mesh, int mode) { glDisable(GL_LIGHTING); glPushMatrix( ); - glScalef(1.01 * fabs(mesh->xmax - mesh->xmin), 1.01 * fabs(mesh->ymax - mesh->ymin), - 1.01 * fabs(mesh->zmax - mesh->zmin)); + glScalef(1.01 * fabs(mesh->xmax - mesh->xmin), 1.01 * fabs(mesh->ymax - mesh->ymin), 1.01 * fabs(mesh->zmax - mesh->zmin)); glColor3f(1.0, 0.0, 0.5); glutWireCube(1.0); glPopMatrix( ); diff --git a/src/medit/keyboard.c b/src/medit/keyboard.c index 6600aa47e..e85a524c7 100644 --- a/src/medit/keyboard.c +++ b/src/medit/keyboard.c @@ -870,9 +870,8 @@ void keyScene(unsigned char key, int x, int y) { case '#': /* select entity */ fprintf(stdout, "ENTITY NUMBER: "); fflush(stdout); - while (fgetc(stdin) != EOF) - ; /* fflush() called on input stream 'stdin' may result in undefined behaviour on - non-linux systems */ + while (fgetc(stdin) != EOF); /* fflush() called on input stream 'stdin' may result in undefined behaviour on + non-linux systems */ ret = fscanf(stdin, "%d", &numit); if (ret == EOF) printf("fscanf error\n"); if (sc->picklist) glDeleteLists(sc->picklist, 1); @@ -932,9 +931,8 @@ void keyScene(unsigned char key, int x, int y) { case '%': fprintf(stdout, "reference (%d): ", refpick); fflush(stdout); - while (fgetc(stdin) != EOF) - ; /* fflush() called on input stream 'stdin' may result in undefined behaviour on - non-linux systems */ + while (fgetc(stdin) != EOF); /* fflush() called on input stream 'stdin' may result in undefined behaviour on + non-linux systems */ ret = fscanf(stdin, "%d", &refpick); if (ret == EOF) printf("fscanf error\n"); break; diff --git a/src/medit/material.c b/src/medit/material.c index c4cf381b1..f782d7f3a 100644 --- a/src/medit/material.c +++ b/src/medit/material.c @@ -51,13 +51,11 @@ static float colors[MAX_MAT + 1][3] = { {0.0, 0.4, 0.0}, /* dark green */ {0.4, 0.0, 0.0}, /* dark red */ {1.0, 1.0, 0.5}, {1.0, 0.5, 1.0}, {1.0, 0.5, 0.5}, {1.0, 0.5, 0.0}, /* orange */ - {1.0, 0.0, 1.0}, {1.0, 0.0, 0.5}, {0.5, 1.0, 1.0}, {0.5, 1.0, 0.5}, - {0.5, 1.0, 0.0}, {0.5, 0.5, 1.0}, {0.5, 0.5, 0.5}, {0.5, 0.5, 0.0}, - {0.5, 0.0, 0.5}, {0.5, 0.0, 0.0}, {0.0, 1.0, 0.5}, {0.0, 0.5, 1.0}, - {0.0, 0.5, 0.5}, {0.0, 0.5, 0.0}, {0.0, 0.0, 0.5}, {0.4, 0.4, 0.0}, /* dark yellow */ - {0.0, 0.4, 0.4}, /* dark cyan */ - {0.3, 0.7, 0.9}, /* default blue */ - {0.3, 0.7, 0.9} /* default blue */ + {1.0, 0.0, 1.0}, {1.0, 0.0, 0.5}, {0.5, 1.0, 1.0}, {0.5, 1.0, 0.5}, {0.5, 1.0, 0.0}, {0.5, 0.5, 1.0}, {0.5, 0.5, 0.5}, {0.5, 0.5, 0.0}, + {0.5, 0.0, 0.5}, {0.5, 0.0, 0.0}, {0.0, 1.0, 0.5}, {0.0, 0.5, 1.0}, {0.0, 0.5, 0.5}, {0.0, 0.5, 0.0}, {0.0, 0.0, 0.5}, {0.4, 0.4, 0.0}, /* dark yellow */ + {0.0, 0.4, 0.4}, /* dark cyan */ + {0.3, 0.7, 0.9}, /* default blue */ + {0.3, 0.7, 0.9} /* default blue */ }; cell ambient[4] = { {1, 120, 60, 0.0, 1.0, 0.0, 0.01, "Specifies R coordinate of ambient vector.", "%.2f"}, diff --git a/src/medit/medit.c b/src/medit/medit.c index 85d2efa28..c573abec7 100644 --- a/src/medit/medit.c +++ b/src/medit/medit.c @@ -138,9 +138,8 @@ int medit0( ) { fprintf(stdout, " File name(s) missing. Please enter : "); fflush(stdout); - while (fgetc(stdin) != EOF) - ; // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - // systems + while (fgetc(stdin) != EOF); // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + // systems res = fgets(data, 120, stdin); if (res == NULL) printf("fgets error\n"); if (!strlen(data)) { @@ -168,9 +167,8 @@ int medit0( ) { if (!cv.nbm) { fprintf(stdout, " Number of mesh missing:. Please enter : "); fflush(stdout); - while (fgetc(stdin) != EOF) - ; // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - // systems + while (fgetc(stdin) != EOF); // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + // systems res = fgets(data, 120, stdin); if (res == NULL) printf("fgets error\n"); cv.nbm = atoi(data); @@ -245,9 +243,8 @@ int medit0_popen( ) { fprintf(stdout, " Number of mesh missing:. Please enter : "); fflush(stdout); - while (fgetc(stdin) != EOF) - ; // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - // systems + while (fgetc(stdin) != EOF); // fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + // systems res = fgets(data, 128, stdin); if (res == NULL) printf("fgets error\n"); cv.nbm = atoi(data); diff --git a/src/medit/medit.h b/src/medit/medit.h index 45862da25..db9cbf022 100644 --- a/src/medit/medit.h +++ b/src/medit/medit.h @@ -91,10 +91,7 @@ #define max(a, b) (((b) > (a)) ? (b) : (a)) /* check if numbers are equal */ -#define egal(x, y) \ - ((((x) == 0.0f) \ - ? (fabs(y) < EPS) \ - : (((y) == 0.0f) ? (fabs(x) < EPS) : (fabs((x) - (y)) / (fabs(x) + fabs(y)) < EPS2)))) +#define egal(x, y) ((((x) == 0.0f) ? (fabs(y) < EPS) : (((y) == 0.0f) ? (fabs(x) < EPS) : (fabs((x) - (y)) / (fabs(x) + fabs(y)) < EPS2)))) /* options */ enum { STANDARD = 1, SEQUENCE, VERYBIG, MORPHING, SCHNAUZER, ISOSURF, PARTICLE }; diff --git a/src/medit/menus.c b/src/medit/menus.c index 15fcec54f..7cd23e6a4 100644 --- a/src/medit/menus.c +++ b/src/medit/menus.c @@ -1105,9 +1105,8 @@ void keyMetric(unsigned char key, int x, int y) { case 'K': /* elevation coeff */ fprintf(stdout, "elevation coeff (%.2f): ", altcoef); fflush(stdout); - while (fgetc(stdin) != EOF) - ; /*fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux - systems*/ + while (fgetc(stdin) != EOF); /*fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux + systems*/ ret = fscanf(stdin, "%f", &altcoef); if (ret == EOF) printf("fscanf error\n"); if (altcoef == 0.0) sc->mode |= ~S_ALTITUDE; @@ -1192,8 +1191,7 @@ int createMenus(pScene sc, pMesh mesh) { glutAddMenuEntry("[p] Toggle palette", 'p'); if (mesh->typage == 2) glutAddMenuEntry("[o] Toggle iso-lines", 'l'); - if (mesh->ntet + mesh->nhex > 0 && mesh->nfield == 1) - glutAddMenuEntry(" Toggle iso-surfaces", 's'); + if (mesh->ntet + mesh->nhex > 0 && mesh->nfield == 1) glutAddMenuEntry(" Toggle iso-surfaces", 's'); if (mesh->nfield == mesh->dim) { glutAddMenuEntry("[w] Toggle vector/tensor", 'w'); diff --git a/src/medit/mesh.c b/src/medit/mesh.c index 45755bd02..aceea7e6f 100644 --- a/src/medit/mesh.c +++ b/src/medit/mesh.c @@ -42,8 +42,7 @@ double volTet(double *c1, double *c2, double *c3, double *c4) { by = c4[1] - c1[1]; bz = c4[2] - c1[2]; - vol = (c2[0] - c1[0]) * (ay * bz - az * by) + (c2[1] - c1[1]) * (az * bx - ax * bz) + - (c2[2] - c1[2]) * (ax * by - ay * bx); + vol = (c2[0] - c1[0]) * (ay * bz - az * by) + (c2[1] - c1[1]) * (az * bx - ax * bz) + (c2[2] - c1[2]) * (ax * by - ay * bx); return (vol / 6.0); } @@ -78,8 +77,7 @@ void meshInfo(pMesh mesh) { fprintf(stdout, " Tangents %d\n", mesh->ntg); } - fprintf(stdout, " Bounding box: x:[%g %g] y:[%g %g] z:[%g %g]\n", mesh->xmin, mesh->xmax, - mesh->ymin, mesh->ymax, mesh->zmin, mesh->zmax); + fprintf(stdout, " Bounding box: x:[%g %g] y:[%g %g] z:[%g %g]\n", mesh->xmin, mesh->xmax, mesh->ymin, mesh->ymax, mesh->zmin, mesh->zmax); } void meshCoord(pMesh mesh, int displ) { @@ -308,8 +306,7 @@ int meshSurf(pMesh mesh) { for (i = 0; i < 6; i++) { if (!adj[i]) { pQuad pq; - static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; + static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; pq = &mesh->quad[++mesh->nq]; pq->v[0] = ph->v[ch[i][0]]; @@ -465,8 +462,7 @@ void meshRef(pScene sc, pMesh mesh) { for (m = 0; m < sc->par.nbmat; m++) { pm = &sc->material[m]; if (pm->depmat[LTria] || pm->depmat[LQuad] || pm->depmat[LTets] || pm->depmat[LHexa]) - fprintf(stdout, " depart[%d], ref %d = %d %d %d %d\n", m, pm->ref, pm->depmat[LTria], - pm->depmat[LQuad], pm->depmat[LTets], pm->depmat[LHexa]); + fprintf(stdout, " depart[%d], ref %d = %d %d %d %d\n", m, pm->ref, pm->depmat[LTria], pm->depmat[LQuad], pm->depmat[LTets], pm->depmat[LHexa]); } } diff --git a/src/medit/mlists.c b/src/medit/mlists.c index ed219c6db..08208d64d 100644 --- a/src/medit/mlists.c +++ b/src/medit/mlists.c @@ -29,8 +29,7 @@ extern "C" { #include "sproto.h" static int ct[4][3] = {{0, 1, 2}, {0, 3, 1}, {1, 3, 2}, {0, 2, 3}}; -static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; +static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; /* recursively subdivide a triangle */ void cutTriangle(pScene sc, triangle t) { diff --git a/src/medit/parsop.c b/src/medit/parsop.c index 900566618..3c6ccd03f 100644 --- a/src/medit/parsop.c +++ b/src/medit/parsop.c @@ -57,8 +57,7 @@ int saveMeditFile(char *file, pScene sc) { fprintf(out, "\n# Assign background color\n"); fprintf(out, "BackgroundColor\n%f %f %f\n", sc->par.back[0], sc->par.back[1], sc->par.back[2]); - if (sc->par.linc) - fprintf(out, "LineColor\n%f %f %f\n", sc->par.line[0], sc->par.line[1], sc->par.line[2]); + if (sc->par.linc) fprintf(out, "LineColor\n%f %f %f\n", sc->par.line[0], sc->par.line[1], sc->par.line[2]); if (sc->mode == HIDDEN) fprintf(out, "\nRenderMode\nhidden\n"); @@ -75,8 +74,7 @@ int saveMeditFile(char *file, pScene sc) { fprintf(out, "WindowSize\n%d %d\n", sc->par.xs, sc->par.ys); if (sc->par.sunp) { fprintf(out, "\n# Source Light\n"); - fprintf(out, "SunPosition\n%f %f %f\n", sc->par.sunpos[0] / (2.0 * sc->dmax), - sc->par.sunpos[1] / (2.0 * sc->dmax), sc->par.sunpos[2] / (2.0 * sc->dmax)); + fprintf(out, "SunPosition\n%f %f %f\n", sc->par.sunpos[0] / (2.0 * sc->dmax), sc->par.sunpos[1] / (2.0 * sc->dmax), sc->par.sunpos[2] / (2.0 * sc->dmax)); } if (sc->iso.palette) { diff --git a/src/medit/particle.c b/src/medit/particle.c index 38de93f28..db069b3ec 100644 --- a/src/medit/particle.c +++ b/src/medit/particle.c @@ -117,8 +117,7 @@ void computeTetraParticle(pScene sc, pMesh mesh, int k) { pos[2] += pp->step * v[2]; } - if (pos[0] < st->xmin || pos[0] > st->xmax || pos[1] < st->ymin || pos[1] > st->ymax || - pos[2] < st->zmin || pos[2] > st->zmax) { + if (pos[0] < st->xmin || pos[0] > st->xmax || pos[1] < st->ymin || pos[1] > st->ymax || pos[2] < st->zmin || pos[2] > st->zmax) { pp->flag = 0; break; } diff --git a/src/medit/picking.c b/src/medit/picking.c index ae10ab39e..ba2502137 100644 --- a/src/medit/picking.c +++ b/src/medit/picking.c @@ -35,8 +35,7 @@ typedef struct color { } Color; int refmat = -1, reftype = -1, refitem = 0, numel = 0, refval = 0; -static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, - {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; +static int ch[6][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 5, 4}, {1, 2, 6, 5}, {2, 3, 7, 6}, {0, 3, 7, 4}}; static int ct[4][3] = {{0, 1, 2}, {0, 3, 1}, {1, 3, 2}, {0, 2, 3}}; extern int refpick; static void drawTria(pScene sc, pMesh mesh, int k) { @@ -86,14 +85,11 @@ static void drawTria(pScene sc, pMesh mesh, int k) { } glNormal3fv(n); - glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, - shrink * (p0->c[2] - cz) + cz); + glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, - shrink * (p1->c[2] - cz) + cz); + glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, - shrink * (p2->c[2] - cz) + cz); + glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, shrink * (p2->c[2] - cz) + cz); glEnd( ); glColor3f(1.0 - sc->par.back[0], 1.0 - sc->par.back[1], 1.0 - sc->par.back[2]); @@ -151,17 +147,13 @@ static void drawQuad(pScene sc, pMesh mesh, int k) { } glNormal3fv(n); - glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, - shrink * (p0->c[2] - cz) + cz); + glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, - shrink * (p1->c[2] - cz) + cz); + glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, - shrink * (p2->c[2] - cz) + cz); + glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, shrink * (p2->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p3->c[0] - cx) + cx, shrink * (p3->c[1] - cy) + cy, - shrink * (p3->c[2] - cz) + cz); + glVertex3f(shrink * (p3->c[0] - cx) + cx, shrink * (p3->c[1] - cy) + cy, shrink * (p3->c[2] - cz) + cz); glEnd( ); /* display vertex number */ @@ -226,14 +218,11 @@ static void drawTets(pScene sc, pMesh mesh, int k) { } glNormal3fv(n); - glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, - shrink * (p0->c[2] - cz) + cz); + glVertex3f(shrink * (p0->c[0] - cx) + cx, shrink * (p0->c[1] - cy) + cy, shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, - shrink * (p1->c[2] - cz) + cz); + glVertex3f(shrink * (p1->c[0] - cx) + cx, shrink * (p1->c[1] - cy) + cy, shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, - shrink * (p2->c[2] - cz) + cz); + glVertex3f(shrink * (p2->c[0] - cx) + cx, shrink * (p2->c[1] - cy) + cy, shrink * (p2->c[2] - cz) + cz); } glEnd( ); @@ -306,17 +295,13 @@ static void drawHexa(pScene sc, pMesh mesh, int k) { } glNormal3fv(n); - glVertex3f(sc->shrink * (p0->c[0] - cx) + cx, sc->shrink * (p0->c[1] - cy) + cy, - sc->shrink * (p0->c[2] - cz) + cz); + glVertex3f(sc->shrink * (p0->c[0] - cx) + cx, sc->shrink * (p0->c[1] - cy) + cy, sc->shrink * (p0->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(sc->shrink * (p1->c[0] - cx) + cx, sc->shrink * (p1->c[1] - cy) + cy, - sc->shrink * (p1->c[2] - cz) + cz); + glVertex3f(sc->shrink * (p1->c[0] - cx) + cx, sc->shrink * (p1->c[1] - cy) + cy, sc->shrink * (p1->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(sc->shrink * (p2->c[0] - cx) + cx, sc->shrink * (p2->c[1] - cy) + cy, - sc->shrink * (p2->c[2] - cz) + cz); + glVertex3f(sc->shrink * (p2->c[0] - cx) + cx, sc->shrink * (p2->c[1] - cy) + cy, sc->shrink * (p2->c[2] - cz) + cz); glNormal3fv(n); - glVertex3f(sc->shrink * (p3->c[0] - cx) + cx, sc->shrink * (p3->c[1] - cy) + cy, - sc->shrink * (p3->c[2] - cz) + cz); + glVertex3f(sc->shrink * (p3->c[0] - cx) + cx, sc->shrink * (p3->c[1] - cy) + cy, sc->shrink * (p3->c[2] - cz) + cz); } glEnd( ); @@ -362,9 +347,7 @@ static void infoData(pScene sc, pMesh mesh, int k, int typel) { fprintf(stdout, " Data (tensor): %f %f %f\n", ps->m[0], ps->m[1], ps->m[2]); drawEllipse(sc, mesh, typel, k); } else if (mesh->dim == 3 && mesh->nfield == 6) { - if (mesh->ne) - fprintf(stdout, " Data (tensor): %f %f %f %f %f %f\n", ps->m[0], ps->m[1], ps->m[2], - ps->m[3], ps->m[4], ps->m[5]); + if (mesh->ne) fprintf(stdout, " Data (tensor): %f %f %f %f %f %f\n", ps->m[0], ps->m[1], ps->m[2], ps->m[3], ps->m[4], ps->m[5]); drawEllipsoid(sc, mesh, typel, k); } @@ -388,9 +371,7 @@ static void infoEntity(pScene sc, pMesh mesh, int k, int type) { switch (type) { case LPoint: p0 = &mesh->point[k]; - if (mesh->ne) - fprintf(stdout, " Vertex %5d : %f, %f, %f ref : %d\n", k, p0->c[0] + mesh->xtra, - p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); + if (mesh->ne) fprintf(stdout, " Vertex %5d : %f, %f, %f ref : %d\n", k, p0->c[0] + mesh->xtra, p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); if (mesh->nbb && mesh->typage == 2) infoData(sc, mesh, k, LPoint); @@ -398,14 +379,12 @@ static void infoEntity(pScene sc, pMesh mesh, int k, int type) { case LTria: pt = &mesh->tria[k]; - fprintf(stdout, " Triangle %5d : %d, %d, %d ref : %d [%s]\n", k, pt->v[0], pt->v[1], - pt->v[2], pt->ref, pm->name); + fprintf(stdout, " Triangle %5d : %d, %d, %d ref : %d [%s]\n", k, pt->v[0], pt->v[1], pt->v[2], pt->ref, pm->name); if (mesh->nbb && mesh->typage == 1) infoData(sc, mesh, k, LTria); for (i = 0; i < 3; i++) { p0 = &mesh->point[pt->v[i]]; - fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", pt->v[i], p0->c[0] + mesh->xtra, - p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); + fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", pt->v[i], p0->c[0] + mesh->xtra, p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); if (mesh->nbb && mesh->typage == 2) infoData(sc, mesh, pt->v[i], LPoint); } @@ -413,14 +392,12 @@ static void infoEntity(pScene sc, pMesh mesh, int k, int type) { case LQuad: pq = &mesh->quad[k]; - fprintf(stdout, " Quad %5d : %d, %d, %d, %d ref : %d [%s]\n", k, pq->v[0], pq->v[1], - pq->v[2], pq->v[3], pq->ref, pm->name); + fprintf(stdout, " Quad %5d : %d, %d, %d, %d ref : %d [%s]\n", k, pq->v[0], pq->v[1], pq->v[2], pq->v[3], pq->ref, pm->name); if (mesh->nbb && mesh->typage == 1) infoData(sc, mesh, k, LQuad); for (i = 0; i < 4; i++) { p0 = &mesh->point[pq->v[i]]; - fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", pq->v[i], p0->c[0] + mesh->xtra, - p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); + fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", pq->v[i], p0->c[0] + mesh->xtra, p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); if (mesh->nbb && mesh->typage == 2) infoData(sc, mesh, pq->v[i], LPoint); } @@ -428,14 +405,12 @@ static void infoEntity(pScene sc, pMesh mesh, int k, int type) { case LTets: ptt = &mesh->tetra[k]; - fprintf(stdout, " Tetra %5d : %d, %d, %d, %d ref : %d [%s]\n", k, ptt->v[0], ptt->v[1], - ptt->v[2], ptt->v[3], ptt->ref, pm->name); + fprintf(stdout, " Tetra %5d : %d, %d, %d, %d ref : %d [%s]\n", k, ptt->v[0], ptt->v[1], ptt->v[2], ptt->v[3], ptt->ref, pm->name); if (mesh->nbb && mesh->typage == 1) infoData(sc, mesh, k, LTets); for (i = 0; i < 4; i++) { p0 = &mesh->point[ptt->v[i]]; - fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", ptt->v[i], p0->c[0] + mesh->xtra, - p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); + fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", ptt->v[i], p0->c[0] + mesh->xtra, p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); if (mesh->nbb && mesh->typage == 2) infoData(sc, mesh, ptt->v[i], LPoint); } @@ -443,15 +418,12 @@ static void infoEntity(pScene sc, pMesh mesh, int k, int type) { case LHexa: ph = &mesh->hexa[k]; - fprintf(stdout, " Hexa %5d : %d, %d, %d, %d, %d, %d, %d, %d ref : %d [%s]\n", k, - ph->v[0], ph->v[1], ph->v[2], ph->v[3], ph->v[4], ph->v[5], ph->v[6], ph->v[7], - ph->ref, pm->name); + fprintf(stdout, " Hexa %5d : %d, %d, %d, %d, %d, %d, %d, %d ref : %d [%s]\n", k, ph->v[0], ph->v[1], ph->v[2], ph->v[3], ph->v[4], ph->v[5], ph->v[6], ph->v[7], ph->ref, pm->name); if (mesh->nbb && mesh->typage == 1) infoData(sc, mesh, k, LHexa); for (i = 0; i < 8; i++) { p0 = &mesh->point[ph->v[i]]; - fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", ph->v[i], p0->c[0] + mesh->xtra, - p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); + fprintf(stdout, " vertex %5d : %f %f %f ref %d\n", ph->v[i], p0->c[0] + mesh->xtra, p0->c[1] + mesh->ytra, p0->c[2] + mesh->ztra, p0->ref); if (mesh->nbb && mesh->typage == 2) infoData(sc, mesh, ph->v[i], LPoint); } @@ -543,8 +515,7 @@ static void displayPoint(pScene sc, pMesh mesh, Color *c) { ppt = &mesh->point[k]; kk = 2 * k + 1; - glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, - (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); + glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); if (mesh->dim == 2) glVertex2dv(ppt->c); @@ -580,9 +551,7 @@ static void displayTria(pScene sc, pMesh mesh, Color *c) { p2 = &mesh->point[pt->v[2]]; kk = 2 * k + 1; - glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, - (kk & c->gMask) >> c->gShift << c->gBits, - (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); + glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); glVertex3dv(p0->c); glVertex3dv(p1->c); @@ -624,9 +593,7 @@ static void displayQuad(pScene sc, pMesh mesh, Color *c) { kk = base + k; kk = 2 * kk + 1; - glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, - (kk & c->gMask) >> c->gShift << c->gBits, - (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); + glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); glVertex3f(p0->c[0], p0->c[1], p0->c[2]); glVertex3f(p1->c[0], p1->c[1], p1->c[2]); @@ -672,9 +639,7 @@ static void displayTets(pScene sc, pMesh mesh, Color *c) { p1 = &mesh->point[ptt->v[ct[l][1]]]; p2 = &mesh->point[ptt->v[ct[l][2]]]; - glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, - (kk & c->gMask) >> c->gShift << c->gBits, - (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); + glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); glVertex3f(p0->c[0], p0->c[1], p0->c[2]); glVertex3f(p1->c[0], p1->c[1], p1->c[2]); @@ -723,9 +688,7 @@ static void displayHexa(pScene sc, pMesh mesh, Color *c) { p2 = &mesh->point[ph->v[ch[l][2]]]; p3 = &mesh->point[ph->v[ch[l][3]]]; - glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, - (kk & c->gMask) >> c->gShift << c->gBits, - (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); + glColor4ub((kk & c->rMask) >> c->rShift << c->rBits, (kk & c->gMask) >> c->gShift << c->gBits, (kk & c->bMask) >> c->bShift << c->bBits, (kk & c->aMask) << c->aBits); glVertex3f(p0->c[0], p0->c[1], p0->c[2]); glVertex3f(p1->c[0], p1->c[1], p1->c[2]); @@ -820,8 +783,7 @@ static int closestPoint(pScene sc, pMesh mesh, int x, int y, int item, int type) for (i = 0; i < 4; i++) { ppt = &mesh->point[pq->v[i]]; - gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, - viewport, &winx, &winy, &winz); + gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, viewport, &winx, &winy, &winz); dd = (winx - x) * (winx - x) + (winy - y) * (winy - y); if (dd < dmin) { dmin = dd; @@ -836,8 +798,7 @@ static int closestPoint(pScene sc, pMesh mesh, int x, int y, int item, int type) for (i = 0; i < 4; i++) { ppt = &mesh->point[pte->v[i]]; - gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, - viewport, &winx, &winy, &winz); + gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, viewport, &winx, &winy, &winz); dd = (winx - x) * (winx - x) + (winy - y) * (winy - y); if (dd < dmin) { dmin = dd; @@ -852,8 +813,7 @@ static int closestPoint(pScene sc, pMesh mesh, int x, int y, int item, int type) for (i = 0; i < 8; i++) { ppt = &mesh->point[ph->v[i]]; - gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, - viewport, &winx, &winy, &winz); + gluProject(ppt->c[0] - sc->cx, ppt->c[1] - sc->cy, ppt->c[2] - sc->cz, matrix, projmat, viewport, &winx, &winy, &winz); dd = (winx - x) * (winx - x) + (winy - y) * (winy - y); if (dd < dmin) { dmin = dd; @@ -870,7 +830,7 @@ static int closestPoint(pScene sc, pMesh mesh, int x, int y, int item, int type) GLuint pickingScene(pScene sc, int x, int y, int ident) { pMesh mesh; GLint viewport[4]; - GLubyte pixel[4] = {}; + GLubyte pixel[4] = { }; GLuint dlist; Color c; unsigned int item; diff --git a/src/medit/psfile.c b/src/medit/psfile.c index 77284030a..8c66a25ba 100644 --- a/src/medit/psfile.c +++ b/src/medit/psfile.c @@ -38,8 +38,7 @@ void writeEPSheader(FILE *out, char *data, char key, int ww, int hh, float cm, f fprintf(out, "%%LanguageLevel: 1\n"); fprintf(out, "%%%%Title: %s\n", data); fprintf(out, "%%%%Creator: medit - (C) INRIA-Rocquencourt, 1999-2001\n"); - fprintf(out, "%%%%BoundingBox: 50 50 %d %d\n", (int)(ww * 72. / dpi + 50.5), - (int)(hh * 72.0 / dpi + 50.5)); + fprintf(out, "%%%%BoundingBox: 50 50 %d %d\n", (int)(ww * 72. / dpi + 50.5), (int)(hh * 72.0 / dpi + 50.5)); fprintf(out, "%%%%Pages: (atend)\n"); fprintf(out, "%%DocumentFonts:\n"); fprintf(out, "%%%%EndComments\n"); diff --git a/src/medit/scene.c b/src/medit/scene.c index 98c91c896..bb5003cfa 100644 --- a/src/medit/scene.c +++ b/src/medit/scene.c @@ -457,8 +457,7 @@ void setupView(pScene sc) { glLoadIdentity( ); if (p->pmode != CAMERA) { glTranslatef(view->panx, view->pany, 0.0); - if (mesh->dim == 3 || sc->mode & S_ALTITUDE) - glRotatef(view->angle, view->axis[0], view->axis[1], view->axis[2]); + if (mesh->dim == 3 || sc->mode & S_ALTITUDE) glRotatef(view->angle, view->axis[0], view->axis[1], view->axis[2]); glTranslatef(-view->opanx, -view->opany, 0.); glMultMatrixf(view->matrix); diff --git a/src/medit/sftcpy.c b/src/medit/sftcpy.c index a4b144cc2..e6a0255d1 100644 --- a/src/medit/sftcpy.c +++ b/src/medit/sftcpy.c @@ -66,8 +66,7 @@ void headps(FILE *file) { fprintf(file, "%%LanguageLevel: 1\n"); fprintf(file, "%%%%Creator: Medit (via OpenGL feedback)\n"); fprintf(file, "%%%%Pages: (atend)\n"); - fprintf(file, "%%%%BoundingBox: %g %g %g %g\n", viewport[0], viewport[1], viewport[2], - viewport[3]); + fprintf(file, "%%%%BoundingBox: %g %g %g %g\n", viewport[0], viewport[1], viewport[2], viewport[3]); fprintf(file, "%%EndComments\n\n"); /* define macros */ @@ -157,8 +156,7 @@ int coreps(FILE *file, GLsizei size, GLfloat *buffer) { } if (ddebug) { - printf("size = %d ptr = %p buffer = %p -> size = %d\n", size, ptr, buffer, - (int)(ptr - buffer)); + printf("size = %d ptr = %p buffer = %p -> size = %d\n", size, ptr, buffer, (int)(ptr - buffer)); printf("%d tokens found\n", nit); } diff --git a/src/medit/status.c b/src/medit/status.c index 681c51ee9..a843d0fad 100644 --- a/src/medit/status.c +++ b/src/medit/status.c @@ -53,8 +53,7 @@ void initTexture(void) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgtex->sizeX, imgtex->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, - imgtex->data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgtex->sizeX, imgtex->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, imgtex->data); free(imgtex); } @@ -151,15 +150,13 @@ void redrawStatusBar(pScene sc) { if (fabs(clip->eqn[2]) > EPS) sprintf(buf, "%s %+.2gz", tmpbuf, clip->eqn[2]); strcpy(tmpbuf, buf); - dd = clip->eqn[3] - clip->eqn[0] * mesh->xtra - clip->eqn[1] * mesh->ytra - - clip->eqn[2] * mesh->ztra; + dd = clip->eqn[3] - clip->eqn[0] * mesh->xtra - clip->eqn[1] * mesh->ytra - clip->eqn[2] * mesh->ztra; if (dd) sprintf(buf, "%s %+.2g", tmpbuf, dd); if (sc->par.xs > 180) output2(150, 8, "%s = 0", buf); } - if ((sc->picklist) && (sc->par.xs > 390) && (!sc->isotyp) & (S_PARTICLE)) - output2(350, 8, "%15s", sc->material[refmat].name); + if ((sc->picklist) && (sc->par.xs > 390) && (!sc->isotyp) & (S_PARTICLE)) output2(350, 8, "%15s", sc->material[refmat].name); if (sc->persp->pmode == PERSPECTIVE && sc->item & S_PALETTE) drawPalette(sc); diff --git a/src/medit/stream.c b/src/medit/stream.c index 774423ff0..cb56c2283 100644 --- a/src/medit/stream.c +++ b/src/medit/stream.c @@ -552,8 +552,7 @@ double sizeHexa(pMesh mesh, int k) { pPoint p[8]; double hmin; int i; - static int idire[12][2] = {{0, 1}, {1, 2}, {2, 3}, {0, 3}, {4, 5}, {5, 6}, - {6, 7}, {4, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}; + static int idire[12][2] = {{0, 1}, {1, 2}, {2, 3}, {0, 3}, {4, 5}, {5, 6}, {6, 7}, {4, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}}; ph = &mesh->hexa[k]; @@ -1017,8 +1016,7 @@ int parseStream(pScene sc, pMesh mesh) { } k = 1; - printf("fin proc %f %f %f\n", sc->stream->listp[k], sc->stream->listp[k + 1], - sc->stream->listp[k + 2]); + printf("fin proc %f %f %f\n", sc->stream->listp[k], sc->stream->listp[k + 1], sc->stream->listp[k + 2]); return (1); } @@ -1070,9 +1068,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { nbp = 0; nsdep = mesh->ntet / 2; nbar = 0; - if (ddebug) - printf(" start point %d: %f %f %f\n", 3 * k / 3, st->listp[k], st->listp[k + 1], - st->listp[k + 2]); + if (ddebug) printf(" start point %d: %f %f %f\n", 3 * k / 3, st->listp[k], st->listp[k + 1], st->listp[k + 2]); for (i = 1; i < mesh->ntet; i++) { pt = &mesh->tetra[i]; @@ -1119,8 +1115,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { step = min(0.05 * sc->par.dt, step); out = fopen("particules.dat", "a+"); assert(out); - fprintf(out, "\n%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, - p[2] + mesh->ztra); + fprintf(out, "\n%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, p[2] + mesh->ztra); } do { @@ -1137,8 +1132,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { p[2] += step * v[2]; } - if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || - p[1] > st->ymax || p[2] > st->zmax) { + if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || p[1] > st->ymax || p[2] > st->zmax) { break; } else if (sc->par.maxtime < FLT_MAX) { ox -= p[0]; @@ -1150,8 +1144,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { if (sc->par.cumtim > sc->par.maxtime) break; if (ldt > sc->par.dt) { - fprintf(out, "%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, - p[2] + mesh->ztra); + fprintf(out, "%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, p[2] + mesh->ztra); ldt = fabs(sc->par.dt - ldt); } } @@ -1192,8 +1185,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { } if (sc->par.maxtime < FLT_MAX) { - fprintf(out, "%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, - p[2] + mesh->ztra); + fprintf(out, "%8.2f %f %f %f\n", sc->par.cumtim, p[0] + mesh->xtra, p[1] + mesh->ytra, p[2] + mesh->ztra); fclose(out); } @@ -1225,9 +1217,7 @@ int listTetraStream(pScene sc, pMesh mesh, float *pp, int squiet) { p[2] -= step * v[2]; } - if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || - p[1] > st->ymax || p[2] > st->zmax) - break; + if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || p[1] > st->ymax || p[2] > st->zmax) break; /* find tet containing p */ nsfin = locateTetra(mesh, nsdep, ++mesh->mark, p, cb); @@ -1317,9 +1307,7 @@ int listHexaStream(pScene sc, pMesh mesh, float *pp, int squiet) { nsdep = mesh->nhex / 2; step = 0.0f; nbar = 0; - if (ddebug) - printf(" start point %d: %f %f %f\n", 3 * k / 3, st->listp[k], st->listp[k + 1], - st->listp[k + 2]); + if (ddebug) printf(" start point %d: %f %f %f\n", 3 * k / 3, st->listp[k], st->listp[k + 1], st->listp[k + 2]); for (i = 1; i < mesh->nhex; i++) { ph = &mesh->hexa[i]; @@ -1331,8 +1319,7 @@ int listHexaStream(pScene sc, pMesh mesh, float *pp, int squiet) { depart = locateHexa(mesh, nsdep, ++mesh->mark, p, cb, pt); printf("DEPART %d\n", depart); ph = &mesh->hexa[depart]; - printf("sommets %d %d %d %d %d %d %d %d\n", ph->v[0], ph->v[1], ph->v[2], ph->v[3], ph->v[4], - ph->v[5], ph->v[6], ph->v[7]); + printf("sommets %d %d %d %d %d %d %d %d\n", ph->v[0], ph->v[1], ph->v[2], ph->v[3], ph->v[4], ph->v[5], ph->v[6], ph->v[7]); if (!depart) { for (depart = 1; depart <= mesh->nhex; depart++) { @@ -1368,9 +1355,7 @@ int listHexaStream(pScene sc, pMesh mesh, float *pp, int squiet) { p[2] += step * v[2]; } - if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || - p[1] > st->ymax || p[2] > st->zmax) - break; + if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || p[1] > st->ymax || p[2] > st->zmax) break; /* find tet containing p */ nsfin = locateHexa(mesh, nsdep, ++mesh->mark, p, cb, pt); @@ -1436,9 +1421,7 @@ int listHexaStream(pScene sc, pMesh mesh, float *pp, int squiet) { p[2] -= step * v[2]; } - if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || - p[1] > st->ymax || p[2] > st->zmax) - break; + if (p[0] < st->xmin || p[1] < st->ymin || p[2] < st->zmin || p[0] > st->xmax || p[1] > st->ymax || p[2] > st->zmax) break; /* find tet containing p */ nsfin = locateHexa(mesh, nsdep, ++mesh->mark, p, cb, pt); diff --git a/src/medit/tiles.c b/src/medit/tiles.c index d56f849d0..72075e6b4 100644 --- a/src/medit/tiles.c +++ b/src/medit/tiles.c @@ -66,8 +66,7 @@ int imgTiling(pScene sc, char *data, char key) { glPixelStorei(GL_PACK_ALIGNMENT, 1); - bckbyte = - (ubyte)(255 * (0.30 * sc->par.back[0] + 0.59 * sc->par.back[1] + 0.11 * sc->par.back[2]) + 0.5); + bckbyte = (ubyte)(255 * (0.30 * sc->par.back[0] + 0.59 * sc->par.back[1] + 0.11 * sc->par.back[2]) + 0.5); /* compute image size */ ratio = (double)sc->par.xs / (double)sc->par.ys; @@ -90,8 +89,7 @@ int imgTiling(pScene sc, char *data, char key) { if (ddebug) { fprintf(stdout, " Generating %d by %d image\n", imgWidth, imgHeight); fprintf(stdout, " tile %d x %d\n", tileWidth, tileHeight); - fprintf(stdout, " image size %f x %f cm\n", sc->par.cm, - (double)imgHeight / sc->par.dpi / CM2IN); + fprintf(stdout, " image size %f x %f cm\n", sc->par.cm, (double)imgHeight / sc->par.dpi / CM2IN); } /* buffer to store one tile */ @@ -218,8 +216,7 @@ int imgTiling(pScene sc, char *data, char key) { bitsTileOffset = 0; for (i = 0; i < th; i++) { - memcpy(buffer + i * imgRowSize + bitsImgOffset, tile + i * bitsTileRow + bitsTileOffset, - bitsCurTileRow); + memcpy(buffer + i * imgRowSize + bitsImgOffset, tile + i * bitsTileRow + bitsTileOffset, bitsCurTileRow); } deblarg = finlarg + 1; diff --git a/src/medit/util.c b/src/medit/util.c index ef22b0d98..734d83853 100644 --- a/src/medit/util.c +++ b/src/medit/util.c @@ -30,8 +30,7 @@ extern "C" { #include "extern.h" #include "sproto.h" -static GLfloat IdMatrix[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; +static GLfloat IdMatrix[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; /* set font style and size */ void setFont(char *name, int size) { diff --git a/src/medit/vector.c b/src/medit/vector.c index 29dc54803..4a80141ea 100644 --- a/src/medit/vector.c +++ b/src/medit/vector.c @@ -79,26 +79,22 @@ void drawVector3D(float p[3], double u[3], double scale) { /* M^-1 . X */ glVertex3dv(c); - glVertex3d(c[0] + (m[0] * cc[0] + m[6] * cc[2]), c[1] + (m[1] * cc[0] + m[7] * cc[2]), - c[2] + (m[2] * cc[0] + m[8] * cc[2])); + glVertex3d(c[0] + (m[0] * cc[0] + m[6] * cc[2]), c[1] + (m[1] * cc[0] + m[7] * cc[2]), c[2] + (m[2] * cc[0] + m[8] * cc[2])); cc[0] = -COSPI15 * scal5; cc[2] = -cc[2]; glVertex3dv(c); - glVertex3d(c[0] + (m[0] * cc[0] + m[6] * cc[2]), c[1] + (m[1] * cc[0] + m[7] * cc[2]), - c[2] + (m[2] * cc[0] + m[8] * cc[2])); + glVertex3d(c[0] + (m[0] * cc[0] + m[6] * cc[2]), c[1] + (m[1] * cc[0] + m[7] * cc[2]), c[2] + (m[2] * cc[0] + m[8] * cc[2])); cc[0] = -COSPI15 * scal5; cc[1] = SINPI15 * scal5; cc[2] = 0.0; glVertex3dv(c); - glVertex3d(c[0] + (m[0] * cc[0] + m[3] * cc[1]), c[1] + (m[1] * cc[0] + m[4] * cc[1]), - c[2] + (m[2] * cc[0] + m[5] * cc[1])); + glVertex3d(c[0] + (m[0] * cc[0] + m[3] * cc[1]), c[1] + (m[1] * cc[0] + m[4] * cc[1]), c[2] + (m[2] * cc[0] + m[5] * cc[1])); cc[1] = -cc[1]; glVertex3dv(c); - glVertex3d(c[0] + (m[0] * cc[0] + m[3] * cc[1]), c[1] + (m[1] * cc[0] + m[4] * cc[1]), - c[2] + (m[2] * cc[0] + m[5] * cc[1])); + glVertex3d(c[0] + (m[0] * cc[0] + m[3] * cc[1]), c[1] + (m[1] * cc[0] + m[4] * cc[1]), c[2] + (m[2] * cc[0] + m[5] * cc[1])); } void drawVector2D(float p[2], double u[2], double scale) { diff --git a/src/mpi/parallelempi-empty.cpp b/src/mpi/parallelempi-empty.cpp index eb4aab37a..bb172ad38 100644 --- a/src/mpi/parallelempi-empty.cpp +++ b/src/mpi/parallelempi-empty.cpp @@ -23,9 +23,9 @@ // empty parallel interface if no MPI to build dll // with or without mpi.. -extern void (*initparallele)(int &argc, char **& argv); -extern void (*init_lgparallele)(); -extern void (*end_parallele)(); +extern void (*initparallele)(int &argc, char **&argv); +extern void (*init_lgparallele)( ); +extern void (*end_parallele)( ); -void init_ptr_parallelepmi(); -void init_ptr_parallelepmi(){}; +void init_ptr_parallelepmi( ); +void init_ptr_parallelepmi( ) {}; diff --git a/src/mpi/parallelempi.cpp b/src/mpi/parallelempi.cpp index 872b8d038..213b26407 100644 --- a/src/mpi/parallelempi.cpp +++ b/src/mpi/parallelempi.cpp @@ -64,9 +64,9 @@ using namespace std; #include "lgsolver.hpp" #include "problem.hpp" -//FFCS redirection +// FFCS redirection #include "../fflib/ffapi.hpp" -void ff_atend( void (*atendff)()); +void ff_atend(void (*atendff)( )); #undef MPICH_SKIP_MPICXX #define MPICH_SKIP_MPICXX @@ -77,26 +77,26 @@ void ff_atend( void (*atendff)()); // Remark: on mipich MPI_Comm, MPI_Resquest, MPI_Group, MPI_Op are int // => encapsulation -//static long verbosity = 1000; -template +// static long verbosity = 1000; +template< class MPI_type, int DIFF > struct fMPI { MPI_type v; - operator MPI_type &() { return v; } - operator MPI_type *() { return &v; } - operator MPI_type () const { return v; } + operator MPI_type &( ) { return v; } + operator MPI_type *( ) { return &v; } + operator MPI_type( ) const { return v; } // MPI_type * operator &() { return &v; } - void operator = (const MPI_type vv) { v=vv; } - fMPI(const MPI_type vv=0) : v(vv) {} - bool operator != (MPI_type vv) const { return vv != v; } - bool operator == (MPI_type vv) const { return vv == v; } + void operator=(const MPI_type vv) { v = vv; } + fMPI(const MPI_type vv = 0) : v(vv) {} + bool operator!=(MPI_type vv) const { return vv != v; } + bool operator==(MPI_type vv) const { return vv == v; } }; // the encapsulation for the for MPI type (int on mpich ) -typedef fMPI fMPI_Comm; -typedef fMPI fMPI_Group; -typedef fMPI fMPI_Request; -typedef fMPI fMPI_Op; +typedef fMPI< MPI_Comm, 1 > fMPI_Comm; +typedef fMPI< MPI_Group, 2 > fMPI_Group; +typedef fMPI< MPI_Request, 3 > fMPI_Request; +typedef fMPI< MPI_Op, 4 > fMPI_Op; // end of encapsulation .. // to send a sparse matrix we send header, line array, colmun array, value array. @@ -111,180 +111,301 @@ typedef fMPI fMPI_Op; class MPIrank; class DoOnWaitMPI_Request; -map ToDoOnWaitMPI_Request; +map< MPI_Request *, DoOnWaitMPI_Request * > ToDoOnWaitMPI_Request; -void GetPendingWait() ; -// change the priority to remove ambiguity between KN * and KN_ -template<> struct SameType *> { static const int OK=100;};// -template<> struct SameType *> { static const int OK=100;};// -template<> struct SameType *> { static const int OK=100;};// -template<> struct SameType *> { static const int OK=100;};// -template<> struct SameType *> { static const int OK=100;};// -template<> struct SameType *> { static const int OK=100;};// +void GetPendingWait( ); +// change the priority to remove ambiguity between KN * and KN_ +template<> +struct SameType< MPIrank, KN< double > * > { + static const int OK = 100; +}; // +template<> +struct SameType< MPIrank, KN< long > * > { + static const int OK = 100; +}; // +template<> +struct SameType< MPIrank, KN< Complex > * > { + static const int OK = 100; +}; // +template<> +struct SameType< MPIrank, KNM< double > * > { + static const int OK = 100; +}; // +template<> +struct SameType< MPIrank, KNM< long > * > { + static const int OK = 100; +}; // +template<> +struct SameType< MPIrank, KNM< Complex > * > { + static const int OK = 100; +}; // -template struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_BYTE; } }; -template<> struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_LONG; } }; -template<> struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_INT; } }; -template<> struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_DOUBLE; } }; -template<> struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_BYTE; } }; +template< class T > +struct MPI_TYPE { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; +template<> +struct MPI_TYPE< long > { + static MPI_Datatype TYPE( ) { return MPI_LONG; } +}; +template<> +struct MPI_TYPE< int > { + static MPI_Datatype TYPE( ) { return MPI_INT; } +}; +template<> +struct MPI_TYPE< double > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE; } +}; +template<> +struct MPI_TYPE< char > { + static MPI_Datatype TYPE( ) { return MPI_BYTE; } +}; #ifdef HAVE_MPI_DOUBLE_COMPLEX -template<> struct MPI_TYPE { static MPI_Datatype TYPE(){ return MPI_DOUBLE_COMPLEX; } }; +template<> +struct MPI_TYPE< Complex > { + static MPI_Datatype TYPE( ) { return MPI_DOUBLE_COMPLEX; } +}; #endif -template struct MPI_WHAT {}; -template<> struct MPI_WHAT { static const int WHAT=101; }; -template<> struct MPI_WHAT { static const int WHAT=102; }; -template<> struct MPI_WHAT { static const int WHAT=103; }; -template<> struct MPI_WHAT* > { static const int WHAT=104; }; -template<> struct MPI_WHAT* > { static const int WHAT=105; }; -template<> struct MPI_WHAT* > { static const int WHAT=106; }; -template<> struct MPI_WHAT* > { static const int WHAT=107; }; -template<> struct MPI_WHAT* > { static const int WHAT=108; }; -template<> struct MPI_WHAT* > { static const int WHAT=109; }; - -template struct MPI_TAG {}; -template<> struct MPI_TAG { static const int TAG=5; }; -template<> struct MPI_TAG { static const int TAG=4; }; -template<> struct MPI_TAG { static const int TAG=6; }; -template<> struct MPI_TAG* > { static const int TAG=11; }; -template<> struct MPI_TAG* > { static const int TAG=12; }; -template<> struct MPI_TAG* > { static const int TAG=13; }; -template<> struct MPI_TAG* > { static const int TAG=14; }; -template<> struct MPI_TAG* > { static const int TAG=15; }; -template<> struct MPI_TAG* > { static const int TAG=16; }; -template<> struct MPI_TAG { static const int TAG=1000; }; -template<> struct MPI_TAG { static const int TAG=1010; }; -template<> struct MPI_TAG { static const int TAG=1040; }; -template<> struct MPI_TAG { static const int TAG=1050; }; -template<> struct MPI_TAG { static const int TAG=1000; }; -template<> struct MPI_TAG { static const int TAG=1010; }; -template<> struct MPI_TAG { static const int TAG=1040; }; -template<> struct MPI_TAG { static const int TAG=1050; }; - -template<> struct MPI_TAG *> { static const int TAG=1020; }; -template<> struct MPI_TAG *> { static const int TAG=1030; }; +template< class T > +struct MPI_WHAT {}; +template<> +struct MPI_WHAT< long > { + static const int WHAT = 101; +}; +template<> +struct MPI_WHAT< double > { + static const int WHAT = 102; +}; +template<> +struct MPI_WHAT< Complex > { + static const int WHAT = 103; +}; +template<> +struct MPI_WHAT< KN< long > * > { + static const int WHAT = 104; +}; +template<> +struct MPI_WHAT< KN< double > * > { + static const int WHAT = 105; +}; +template<> +struct MPI_WHAT< KN< Complex > * > { + static const int WHAT = 106; +}; +template<> +struct MPI_WHAT< KNM< long > * > { + static const int WHAT = 107; +}; +template<> +struct MPI_WHAT< KNM< double > * > { + static const int WHAT = 108; +}; +template<> +struct MPI_WHAT< KNM< Complex > * > { + static const int WHAT = 109; +}; + +template< class T > +struct MPI_TAG {}; +template<> +struct MPI_TAG< long > { + static const int TAG = 5; +}; +template<> +struct MPI_TAG< double > { + static const int TAG = 4; +}; +template<> +struct MPI_TAG< Complex > { + static const int TAG = 6; +}; +template<> +struct MPI_TAG< KN< long > * > { + static const int TAG = 11; +}; +template<> +struct MPI_TAG< KN< double > * > { + static const int TAG = 12; +}; +template<> +struct MPI_TAG< KN< Complex > * > { + static const int TAG = 13; +}; +template<> +struct MPI_TAG< KNM< long > * > { + static const int TAG = 14; +}; +template<> +struct MPI_TAG< KNM< double > * > { + static const int TAG = 15; +}; +template<> +struct MPI_TAG< KNM< Complex > * > { + static const int TAG = 16; +}; +template<> +struct MPI_TAG< Mesh * > { + static const int TAG = 1000; +}; +template<> +struct MPI_TAG< Mesh3 * > { + static const int TAG = 1010; +}; +template<> +struct MPI_TAG< MeshS * > { + static const int TAG = 1040; +}; +template<> +struct MPI_TAG< MeshL * > { + static const int TAG = 1050; +}; +template<> +struct MPI_TAG< const Mesh * > { + static const int TAG = 1000; +}; +template<> +struct MPI_TAG< const Mesh3 * > { + static const int TAG = 1010; +}; +template<> +struct MPI_TAG< const MeshS * > { + static const int TAG = 1040; +}; +template<> +struct MPI_TAG< const MeshL * > { + static const int TAG = 1050; +}; + +template<> +struct MPI_TAG< Matrice_Creuse< double > * > { + static const int TAG = 1020; +}; +template<> +struct MPI_TAG< Matrice_Creuse< Complex > * > { + static const int TAG = 1030; +}; void f_initparallele(int &, char **&); -void f_init_lgparallele(); +void f_init_lgparallele( ); -extern long mpirank ; -extern long mpisize ; +extern long mpirank; +extern long mpisize; // for syncro communication -MPI_Request *Syncro_block = reinterpret_cast (1); +MPI_Request *Syncro_block = reinterpret_cast< MPI_Request * >(1); -const size_t sizempibuf = 1024*320; +const size_t sizempibuf = 1024 * 320; -template -long WSend (R *v, int l, int who, int tag, MPI_Comm comm, MPI_Request *rq) { +template< class R > +long WSend(R *v, int l, int who, int tag, MPI_Comm comm, MPI_Request *rq) { long ret = 0; MPI_Request rq0, *request = &rq0; - if(verbosity>100) - cout << mpirank << " send to " << who << " tag " << tag << " " << rq << " " << comm << " syncro " << (rq == Syncro_block) << endl; + if (verbosity > 100) cout << mpirank << " send to " << who << " tag " << tag << " " << rq << " " << comm << " syncro " << (rq == Syncro_block) << endl; if (rq == Syncro_block || rq == 0) - ret = MPI_Send((void *)v, l, MPI_TYPE::TYPE(), who, tag, comm); + ret = MPI_Send((void *)v, l, MPI_TYPE< R >::TYPE( ), who, tag, comm); else { - ret = MPI_Isend((void *)v, l, MPI_TYPE::TYPE(), who, tag, comm, request); + ret = MPI_Isend((void *)v, l, MPI_TYPE< R >::TYPE( ), who, tag, comm, request); *rq = *request; } return ret; } -template -void CheckContigueKNM (const KNM_ &t) { - if (t.step != 1 && !t.IsVector1()) { - cout << " step = "<< t.step << " size " << t.N() << " " << &t[0] << " " << &t[1] << endl; +template< class T > +void CheckContigueKNM(const KNM_< T > &t) { + if (t.step != 1 && !t.IsVector1( )) { + cout << " step = " << t.step << " size " << t.N( ) << " " << &t[0] << " " << &t[1] << endl; ExecError("Sorry the array is not contiguous (step != 1) "); } } -template -void CheckContigueKN (const KN_ &t) { - if (t.step != 1 && t.N() > 1) { - cout<< " step = " << t.step << " size " << t.N() << " " << &t[0] << " " << &t[1] << endl; +template< class T > +void CheckContigueKN(const KN_< T > &t) { + if (t.step != 1 && t.N( ) > 1) { + cout << " step = " << t.step << " size " << t.N( ) << " " << &t[0] << " " << &t[1] << endl; ExecError("Sorry the array is not contiguous (step != 1) "); } } template<> -long WSend (Complex *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { +long WSend< Complex >(Complex *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { long ret = 0; MPI_Request rq0, *request = &rq0; - if (verbosity > 100) - cout << mpirank << " send to " << who << " tag " << tag << " " << rq << " " << comm << " syncro "<< (rq == Syncro_block) << endl; + if (verbosity > 100) cout << mpirank << " send to " << who << " tag " << tag << " " << rq << " " << comm << " syncro " << (rq == Syncro_block) << endl; if (rq == Syncro_block || rq == 0) { #ifdef HAVE_MPI_DOUBLE_COMPLEX - ret = MPI_Send(reinterpret_cast(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm); + ret = MPI_Send(reinterpret_cast< void * >(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm); #else n *= 2; - ret = MPI_Send(reinterpret_cast(v), n, MPI_DOUBLE, who, tag, comm); + ret = MPI_Send(reinterpret_cast< void * >(v), n, MPI_DOUBLE, who, tag, comm); #endif } else { #ifdef HAVE_MPI_DOUBLE_COMPLEX - ret = MPI_Isend(reinterpret_cast(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, request); + ret = MPI_Isend(reinterpret_cast< void * >(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, request); #else n *= 2; - ret = MPI_Isend(reinterpret_cast(v), n, MPI_DOUBLE, who, tag, comm, request); + ret = MPI_Isend(reinterpret_cast< void * >(v), n, MPI_DOUBLE, who, tag, comm, request); n /= 2; #endif - if(rq) *rq = *request; - else MPI_Request_free(request); + if (rq) + *rq = *request; + else + MPI_Request_free(request); } return ret; } -template -long WRecv (R *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { +template< class R > +long WRecv(R *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { MPI_Status status; if (rq && (rq != Syncro_block)) - return MPI_Irecv(reinterpret_cast(v), n, MPI_TYPE::TYPE(), who, tag, comm, rq); + return MPI_Irecv(reinterpret_cast< void * >(v), n, MPI_TYPE< R >::TYPE( ), who, tag, comm, rq); else - return MPI_Recv(reinterpret_cast(v), n, MPI_TYPE::TYPE(), who, tag, comm, &status); + return MPI_Recv(reinterpret_cast< void * >(v), n, MPI_TYPE< R >::TYPE( ), who, tag, comm, &status); } template<> -long WRecv (Complex *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { +long WRecv< Complex >(Complex *v, int n, int who, int tag, MPI_Comm comm, MPI_Request *rq) { MPI_Status status; #ifdef HAVE_MPI_DOUBLE_COMPLEX if (rq && (rq != Syncro_block)) - return MPI_Irecv(reinterpret_cast(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, rq); + return MPI_Irecv(reinterpret_cast< void * >(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, rq); else - return MPI_Recv(reinterpret_cast(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, &status); + return MPI_Recv(reinterpret_cast< void * >(v), n, MPI_DOUBLE_COMPLEX, who, tag, comm, &status); #else n *= 2; if (rq && (rq != Syncro_block)) - return MPI_Irecv(reinterpret_cast(v), n, MPI_DOUBLE, who, tag, comm, rq); + return MPI_Irecv(reinterpret_cast< void * >(v), n, MPI_DOUBLE, who, tag, comm, rq); else - return MPI_Recv(reinterpret_cast(v), n, MPI_DOUBLE, who, tag, comm, &status); + return MPI_Recv(reinterpret_cast< void * >(v), n, MPI_DOUBLE, who, tag, comm, &status); #endif } -template -void WBcast (R *v, int n, int who, MPI_Comm comm) { +template< class R > +void WBcast(R *v, int n, int who, MPI_Comm comm) { assert(v && n > 0); - MPI_Bcast(reinterpret_cast(v), n, MPI_TYPE::TYPE(), who, comm); + MPI_Bcast(reinterpret_cast< void * >(v), n, MPI_TYPE< R >::TYPE( ), who, comm); } template<> -void WBcast (Complex *v, int n, int who, MPI_Comm comm) { +void WBcast< Complex >(Complex *v, int n, int who, MPI_Comm comm) { assert(v && n > 0); #ifdef HAVE_MPI_DOUBLE_COMPLEX - MPI_Bcast(reinterpret_cast(v), n, MPI_DOUBLE_COMPLEX /*MPI_TYPE::TYPE()*/, who, comm); + MPI_Bcast(reinterpret_cast< void * >(v), n, MPI_DOUBLE_COMPLEX /*MPI_TYPE::TYPE()*/, who, comm); #else n *= 2; - MPI_Bcast(reinterpret_cast(v), n, MPI_DOUBLE, who, comm); + MPI_Bcast(reinterpret_cast< void * >(v), n, MPI_DOUBLE, who, comm); #endif } struct MPIrank { - int who,lmpirank; + int who, lmpirank; MPI_Comm comm; MPI_Request *rq; // mutable bool block; - MPIrank(int i=0, MPI_Comm com=MPI_COMM_WORLD, MPI_Request *rqq=0) - : who(i), comm(com), rq(rqq) { - ffassert(who >=0 || who == MPI_ANY_SOURCE ); // check jan 2024 PHT , FH + MPIrank(int i = 0, MPI_Comm com = MPI_COMM_WORLD, MPI_Request *rqq = 0) : who(i), comm(com), rq(rqq) { + ffassert(who >= 0 || who == MPI_ANY_SOURCE); // check jan 2024 PHT , FH int n; MPI_Comm_size(comm, &n); MPI_Comm_rank(comm, &lmpirank); @@ -294,143 +415,135 @@ struct MPIrank { long Send(long a) const { return WSend(&a, 1, who, MPI_TAG< long >::TAG, comm, rq); } long Send(Complex a) const { return WSend(&a, 1, who, MPI_TAG< Complex >::TAG, comm, rq); } - long Send(double * a) const { return WSend(a, 1, who, MPI_TAG< double >::TAG, comm, rq); } - long Send(long * a) const { return WSend(a, 1, who, MPI_TAG< long >::TAG, comm, rq); } - long Send(Complex * a) const { return WSend(a, 1, who, MPI_TAG< Complex >::TAG, comm, rq); } + long Send(double *a) const { return WSend(a, 1, who, MPI_TAG< double >::TAG, comm, rq); } + long Send(long *a) const { return WSend(a, 1, who, MPI_TAG< long >::TAG, comm, rq); } + long Send(Complex *a) const { return WSend(a, 1, who, MPI_TAG< Complex >::TAG, comm, rq); } - long Recv(double & a) const { return WRecv(&a, 1, who, MPI_TAG< double >::TAG ,comm, rq); } - long Recv(long & a) const { return WRecv(&a, 1, who, MPI_TAG< long >::TAG ,comm, rq); } - long Recv(Complex & a) const { return WRecv(&a, 1, who, MPI_TAG< Complex >::TAG ,comm, rq); } + long Recv(double &a) const { return WRecv(&a, 1, who, MPI_TAG< double >::TAG, comm, rq); } + long Recv(long &a) const { return WRecv(&a, 1, who, MPI_TAG< long >::TAG, comm, rq); } + long Recv(Complex &a) const { return WRecv(&a, 1, who, MPI_TAG< Complex >::TAG, comm, rq); } - const MPIrank & Bcast(double & a) const { WBcast(&a, 1, who, comm); return *this; } - const MPIrank & Bcast(long & a) const { WBcast(&a, 1, who, comm); return *this; } - const MPIrank & Bcast(Complex & a) const { WBcast(&a, 1, who, comm); return *this; } + const MPIrank &Bcast(double &a) const { + WBcast(&a, 1, who, comm); + return *this; + } + const MPIrank &Bcast(long &a) const { + WBcast(&a, 1, who, comm); + return *this; + } + const MPIrank &Bcast(Complex &a) const { + WBcast(&a, 1, who, comm); + return *this; + } - template - long Recv (KN & a) const { + template< class R > + long Recv(KN< R > &a) const { assert(&a); CheckContigueKN(a); - if (verbosity > 99) - cout << " ---- " << who << " >> " << &a << " " << a.N() << " " << a.step << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - int n = a.N(); - long ll = WRecv((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - if (verbosity > 99) - cout << " ++++ " << who << " >> " << &a << " " << a.N() << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - ffassert(a.N() == n); + if (verbosity > 99) cout << " ---- " << who << " >> " << &a << " " << a.N( ) << " " << a.step << " " << MPI_TAG< KN< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + int n = a.N( ); + long ll = WRecv((R *)a, n, who, MPI_TAG< KN< R > * >::TAG, comm, rq); + if (verbosity > 99) cout << " ++++ " << who << " >> " << &a << " " << a.N( ) << " " << MPI_TAG< KN< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + ffassert(a.N( ) == n); return ll; } - template - long Send (const KN *aa) const { - const KN & a = *aa; + template< class R > + long Send(const KN< R > *aa) const { + const KN< R > &a = *aa; ffassert(&a); - int n = a.N(); + int n = a.N( ); CheckContigueKN(*aa); - if (verbosity > 99) - cout << " .... " << who << " >> " << &a << " " << a.N() << " " << a.step << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - return WSend((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - } - - template - long Send (const KN_ &aa) const { - const KN_ & a = aa; - ffassert(&a); - int n = a.N(); - CheckContigueKN(aa); - if (verbosity > 99) - cout << " .... _ " << who << " >> " << &a << " " << a.N() << " " << a.step << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - return WSend((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - } + if (verbosity > 99) cout << " .... " << who << " >> " << &a << " " << a.N( ) << " " << a.step << " " << MPI_TAG< KN< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + return WSend((R *)a, n, who, MPI_TAG< KN< R > * >::TAG, comm, rq); + } + + template< class R > + long Send(const KN_< R > &aa) const { + const KN_< R > &a = aa; + ffassert(&a); + int n = a.N( ); + CheckContigueKN(aa); + if (verbosity > 99) cout << " .... _ " << who << " >> " << &a << " " << a.N( ) << " " << a.step << " " << MPI_TAG< KN< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + return WSend((R *)a, n, who, MPI_TAG< KN< R > * >::TAG, comm, rq); + } - template - const MPIrank & Bcast (const KN &a) const { + template< class R > + const MPIrank &Bcast(const KN< R > &a) const { assert(&a); - int n = a.N(); + int n = a.N( ); CheckContigueKN(a); WBcast((R *)a, n, who, comm); - ffassert(a.N() == n); + ffassert(a.N( ) == n); return *this; } // KNM *********************************** Add FH. Nov 2016 - template - long Recv (KNM & a) const { + template< class R > + long Recv(KNM< R > &a) const { assert(&a); CheckContigueKNM(a); - if (verbosity > 399) - cout << " ---- " << who << " >> " << &a << " " << a.N() << "x" << a.M() << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - int n = a.N()*a.M(); - long ll = WRecv((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - if (verbosity > 399) - cout << " ++++ " << who << " >> " << &a << " " << a.N() << "x" << a.M() << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - ffassert(a.N()*a.M() == n); + if (verbosity > 399) cout << " ---- " << who << " >> " << &a << " " << a.N( ) << "x" << a.M( ) << " " << MPI_TAG< KNM< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + int n = a.N( ) * a.M( ); + long ll = WRecv((R *)a, n, who, MPI_TAG< KNM< R > * >::TAG, comm, rq); + if (verbosity > 399) cout << " ++++ " << who << " >> " << &a << " " << a.N( ) << "x" << a.M( ) << " " << MPI_TAG< KNM< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + ffassert(a.N( ) * a.M( ) == n); return ll; } - template - long Send (const KNM *aa) const { - const KNM & a = *aa; + template< class R > + long Send(const KNM< R > *aa) const { + const KNM< R > &a = *aa; ffassert(&a); - int n = a.N()*a.M(); + int n = a.N( ) * a.M( ); CheckContigueKNM(*aa); if (verbosity > 399) - cout << " .... " << who << " >> " << &a << " " << a.N() << "x" << a.M() << " " << a.step << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - return WSend((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - } - template - long Send (const KNM_ &aa) const { - const KNM_ & a = aa; - ffassert(&a); - int n = a.N()*a.M(); - CheckContigueKNM(aa); - if (verbosity > 399) - cout << " .... _ " << who << " >> " << &a << " " << a.N() << "x" << a.M() << " " << a.step << " " << MPI_TAG* >::TAG - << " from " << mpirank << " " << (R *)a << endl; - return WSend((R *)a, n, who, MPI_TAG* >::TAG, comm, rq); - } + cout << " .... " << who << " >> " << &a << " " << a.N( ) << "x" << a.M( ) << " " << a.step << " " << MPI_TAG< KNM< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + return WSend((R *)a, n, who, MPI_TAG< KNM< R > * >::TAG, comm, rq); + } + template< class R > + long Send(const KNM_< R > &aa) const { + const KNM_< R > &a = aa; + ffassert(&a); + int n = a.N( ) * a.M( ); + CheckContigueKNM(aa); + if (verbosity > 399) + cout << " .... _ " << who << " >> " << &a << " " << a.N( ) << "x" << a.M( ) << " " << a.step << " " << MPI_TAG< KNM< R > * >::TAG << " from " << mpirank << " " << (R *)a << endl; + return WSend((R *)a, n, who, MPI_TAG< KNM< R > * >::TAG, comm, rq); + } - template - const MPIrank & Bcast (const KNM &a) const { + template< class R > + const MPIrank &Bcast(const KNM< R > &a) const { assert(&a); - int n = a.N()*a.M(); + int n = a.N( ) * a.M( ); CheckContigueKNM(a); WBcast((R *)a, n, who, comm); - ffassert(a.N()*a.M() == n); + ffassert(a.N( ) * a.M( ) == n); return *this; } // KNM *********************************** - const MPIrank & Bcast (Fem2D::Mesh const *&a) const { - if(verbosity>100) - cout << " MPI Bcast (mesh *) " << a << endl; + const MPIrank &Bcast(Fem2D::Mesh const *&a) const { + if (verbosity > 100) cout << " MPI Bcast (mesh *) " << a << endl; Serialize *buf = 0; long nbsize = 0; if (who == lmpirank) { - buf = new Serialize((*a).serialize()); - nbsize = buf->size(); + buf = new Serialize((*a).serialize( )); + nbsize = buf->size( ); } WBcast(&nbsize, 1, who, comm); - if (who != lmpirank) - buf = new Serialize(nbsize, Fem2D::Mesh::magicmesh); + if (who != lmpirank) buf = new Serialize(nbsize, Fem2D::Mesh::magicmesh); assert(nbsize); - if (verbosity > 200) - cout << " size to bcast : " << nbsize << " mpirank : " << mpirank << endl; + if (verbosity > 200) cout << " size to bcast : " << nbsize << " mpirank : " << mpirank << endl; WBcast((char *)(*buf), nbsize, who, comm); if (who != lmpirank) { - if (a) (*a).decrement(); + if (a) (*a).decrement( ); Fem2D::Mesh *pTh = new Fem2D::Mesh(*buf); Fem2D::R2 Pn, Px; pTh->BoundingBox(Pn, Px); @@ -441,117 +554,104 @@ struct MPIrank { return *this; } - const MPIrank & Bcast (Fem2D::Mesh3 const *&a) const { - if(verbosity>100) - cout << " MPI Bcast (const mesh3 *) " << a << endl; + const MPIrank &Bcast(Fem2D::Mesh3 const *&a) const { + if (verbosity > 100) cout << " MPI Bcast (const mesh3 *) " << a << endl; Serialize *buf = 0; - long nbsize[2]={0,0}; + long nbsize[2] = {0, 0}; if (who == lmpirank) { - if((*a).meshS) { - buf = new Serialize((*a).serialize_withBorderMesh()); - nbsize[1]=1; - } - else - buf = new Serialize((*a).serialize()); - nbsize[0] = buf->size(); + if ((*a).meshS) { + buf = new Serialize((*a).serialize_withBorderMesh( )); + nbsize[1] = 1; + } else + buf = new Serialize((*a).serialize( )); + nbsize[0] = buf->size( ); } WBcast(&nbsize[0], 2, who, comm); - if (who != lmpirank) - buf = new Serialize(nbsize[0], Fem2D::GenericMesh_magicmesh); + if (who != lmpirank) buf = new Serialize(nbsize[0], Fem2D::GenericMesh_magicmesh); assert(nbsize); - if (verbosity > 200) - cout << " size to bcast : " << nbsize[0] << " mpirank : " << mpirank << endl; + if (verbosity > 200) cout << " size to bcast : " << nbsize[0] << " mpirank : " << mpirank << endl; WBcast((char *)(*buf), nbsize[0], who, comm); - Fem2D::Mesh3 * aa; + Fem2D::Mesh3 *aa; if (who != lmpirank) { - if (a) (*a).decrement(); - if(nbsize[1]) - aa = new Fem2D::Mesh3(*buf, 1); - else - aa = new Fem2D::Mesh3(*buf); - - aa->BuildGTree(); + if (a) (*a).decrement( ); + if (nbsize[1]) + aa = new Fem2D::Mesh3(*buf, 1); + else + aa = new Fem2D::Mesh3(*buf); + + aa->BuildGTree( ); a = aa; } delete buf; return *this; } - const MPIrank & Bcast (Fem2D::MeshS const *&a) const { - if(verbosity>100) - cout << " MPI Bcast (const meshS *) " << a << endl; + const MPIrank &Bcast(Fem2D::MeshS const *&a) const { + if (verbosity > 100) cout << " MPI Bcast (const meshS *) " << a << endl; Serialize *buf = 0; - long nbsize[2]={0,0}; + long nbsize[2] = {0, 0}; if (who == lmpirank) { - if((*a).meshL) { - buf = new Serialize((*a).serialize_withBorderMesh()); - nbsize[1]=1; - } - else - buf = new Serialize((*a).serialize()); - nbsize[0] = buf->size(); + if ((*a).meshL) { + buf = new Serialize((*a).serialize_withBorderMesh( )); + nbsize[1] = 1; + } else + buf = new Serialize((*a).serialize( )); + nbsize[0] = buf->size( ); } WBcast(&nbsize[0], 2, who, comm); - if (who != lmpirank) - buf = new Serialize(nbsize[0], Fem2D::GenericMesh_magicmesh); + if (who != lmpirank) buf = new Serialize(nbsize[0], Fem2D::GenericMesh_magicmesh); assert(nbsize); - if (verbosity > 200) - cout << " size to bcast : " << nbsize[0] << " mpirank : " << mpirank << endl; - WBcast((char *)(*buf), nbsize[0], who, comm); - Fem2D::MeshS * aa; + if (verbosity > 200) cout << " size to bcast : " << nbsize[0] << " mpirank : " << mpirank << endl; + WBcast((char *)(*buf), nbsize[0], who, comm); + Fem2D::MeshS *aa; if (who != lmpirank) { - if (a) (*a).decrement(); - if(nbsize[1]) - aa = new Fem2D::MeshS(*buf, 1); - else - aa = new Fem2D::MeshS(*buf); - - aa->BuildGTree(); + if (a) (*a).decrement( ); + if (nbsize[1]) + aa = new Fem2D::MeshS(*buf, 1); + else + aa = new Fem2D::MeshS(*buf); + + aa->BuildGTree( ); a = aa; } delete buf; return *this; } - - const MPIrank & Bcast (Fem2D::MeshL const *&a) const { - if(verbosity>100) - cout << " MPI Bcast (const meshL *) " << a << endl; - Serialize *buf = 0; - long nbsize = 0; - if (who == lmpirank) { - buf = new Serialize((*a).serialize()); - nbsize = buf->size(); - } - WBcast(&nbsize, 1, who, comm); - if (who != lmpirank) - buf = new Serialize(nbsize, Fem2D::GenericMesh_magicmesh); - assert(nbsize); - if (verbosity > 200) - cout << " size to bcast : " << nbsize << " mpirank : " << mpirank << endl; - - WBcast((char *)(*buf), nbsize, who, comm); - - if (who != lmpirank) { - if (a) (*a).decrement(); - Fem2D::MeshL * aa = new Fem2D::MeshL(*buf); - aa->BuildGTree(); - a = aa; - } - delete buf; - return *this; + + const MPIrank &Bcast(Fem2D::MeshL const *&a) const { + if (verbosity > 100) cout << " MPI Bcast (const meshL *) " << a << endl; + Serialize *buf = 0; + long nbsize = 0; + if (who == lmpirank) { + buf = new Serialize((*a).serialize( )); + nbsize = buf->size( ); + } + WBcast(&nbsize, 1, who, comm); + if (who != lmpirank) buf = new Serialize(nbsize, Fem2D::GenericMesh_magicmesh); + assert(nbsize); + if (verbosity > 200) cout << " size to bcast : " << nbsize << " mpirank : " << mpirank << endl; + + WBcast((char *)(*buf), nbsize, who, comm); + + if (who != lmpirank) { + if (a) (*a).decrement( ); + Fem2D::MeshL *aa = new Fem2D::MeshL(*buf); + aa->BuildGTree( ); + a = aa; + } + delete buf; + return *this; } - - template - const MPIrank & Bcast(Matrice_Creuse &a) const { - if(verbosity>100) - cout << mpirank << ": MPI Bcast " << who << " (Matrice_Creuse &) " << &a << " " << a.A << endl; - MatriceMorse *mA = 0; + template< class R > + const MPIrank &Bcast(Matrice_Creuse< R > &a) const { + if (verbosity > 100) cout << mpirank << ": MPI Bcast " << who << " (Matrice_Creuse &) " << &a << " " << a.A << endl; + MatriceMorse< R > *mA = 0; int ldata[4] = {0, 0, 0, 0}; if (who == lmpirank) { - if(a.A) { - mA = a.pHM(); + if (a.A) { + mA = a.pHM( ); ldata[0] = mA->n; ldata[1] = mA->m; ldata[2] = mA->nnz; @@ -561,10 +661,10 @@ struct MPIrank { int n4 = 4; WBcast(ldata, n4, who, comm); if (who != lmpirank && ldata[0]) - mA = new MatriceMorse(ldata[0], ldata[1], ldata[2], ldata[3]); + mA = new MatriceMorse< R >(ldata[0], ldata[1], ldata[2], ldata[3]); else CheckPtrHashMatrix(mA, "Bcast 2"); - if(ldata[0]) { + if (ldata[0]) { WBcast(mA->i, ldata[2], who, comm); WBcast(mA->j, ldata[2], who, comm); WBcast(mA->aij, ldata[2], who, comm); @@ -572,149 +672,147 @@ struct MPIrank { mA->Increaze(ldata[2], ldata[2]); } CheckPtrHashMatrix(mA, "Bcast 2"); - if (who != lmpirank) - a.A.master(mA); + if (who != lmpirank) a.A.master(mA); // else // delete mA; return *this; } // old async or sync Nov 2010 ... - template long Send (Matrice_Creuse * const &a) const; - template long Recv (Matrice_Creuse &a) const; - long Send (Fem2D::Mesh const *a) const; - long Send (Fem2D::Mesh3 const *a) const; - long Send (Fem2D::MeshS const *a) const; - long Send (Fem2D::MeshL const *a) const; - long Recv (Fem2D::Mesh const *&a) const; - long Recv (Fem2D::Mesh3 const *&a) const; - long Recv (Fem2D::MeshS const *&a) const; - long Recv (Fem2D::MeshL const *&a) const; - - operator int () const { return who; } + template< class R > + long Send(Matrice_Creuse< R > *const &a) const; + template< class R > + long Recv(Matrice_Creuse< R > &a) const; + long Send(Fem2D::Mesh const *a) const; + long Send(Fem2D::Mesh3 const *a) const; + long Send(Fem2D::MeshS const *a) const; + long Send(Fem2D::MeshL const *a) const; + long Recv(Fem2D::Mesh const *&a) const; + long Recv(Fem2D::Mesh3 const *&a) const; + long Recv(Fem2D::MeshS const *&a) const; + long Recv(Fem2D::MeshL const *&a) const; + + operator int( ) const { return who; } }; // for MPI_WAIT_resquets (complex MPI async MPI recv request ) ... class DoOnWaitMPI_Request : public MPIrank { -public: + public: bool sync; - DoOnWaitMPI_Request( MPIrank mpr) : MPIrank(mpr), sync((rq == 0 || rq == Syncro_block)) {} - virtual bool Do(MPI_Request *rrq) = 0; // false -> end - bool DoSR() { // do the Send/Recv Op. + DoOnWaitMPI_Request(MPIrank mpr) : MPIrank(mpr), sync((rq == 0 || rq == Syncro_block)) {} + virtual bool Do(MPI_Request *rrq) = 0; // false -> end + bool DoSR( ) { // do the Send/Recv Op. bool ret = false; - if (verbosity > 100) - cout << mpirank << " --- Do Send/Recv : " << " " << rq << " " << sync << endl; - if(sync) { // wait ... + if (verbosity > 100) cout << mpirank << " --- Do Send/Recv : " << " " << rq << " " << sync << endl; + if (sync) { // wait ... bool c = 1; - if (verbosity > 100) - cout << mpirank << " --- Do way : " << c << " " << rq << endl; + if (verbosity > 100) cout << mpirank << " --- Do way : " << c << " " << rq << endl; while (c) { c = Do(rq); - if (verbosity > 100) - cout << mpirank << " --- Do return : " << c << " " << rq << endl; + if (verbosity > 100) cout << mpirank << " --- Do return : " << c << " " << rq << endl; } - ret = true;// clean + ret = true; // clean } else - ToDoOnWaitMPI_Request[rq] = this; // add request for WAIT .. + ToDoOnWaitMPI_Request[rq] = this; // add request for WAIT .. return ret; } - virtual ~DoOnWaitMPI_Request(){} - private: - DoOnWaitMPI_Request (const DoOnWaitMPI_Request &); - DoOnWaitMPI_Request & operator= ( DoOnWaitMPI_Request &); + virtual ~DoOnWaitMPI_Request( ) {} + + private: + DoOnWaitMPI_Request(const DoOnWaitMPI_Request &); + DoOnWaitMPI_Request &operator=(DoOnWaitMPI_Request &); }; -void DoOnWaitMPIRequest (MPI_Request *rq) { +void DoOnWaitMPIRequest(MPI_Request *rq) { if (rq) { - map:: iterator drd = ToDoOnWaitMPI_Request.find(rq); - if (drd != ToDoOnWaitMPI_Request.end()) { - if (verbosity > 100) - cout << " Do on DoOnWaitMPIRequest " << rq << " " << endl; + map< MPI_Request *, DoOnWaitMPI_Request * >::iterator drd = ToDoOnWaitMPI_Request.find(rq); + if (drd != ToDoOnWaitMPI_Request.end( )) { + if (verbosity > 100) cout << " Do on DoOnWaitMPIRequest " << rq << " " << endl; if (!drd->second->Do(rq)) { delete drd->second; - ToDoOnWaitMPI_Request.erase(drd); // finish ... + ToDoOnWaitMPI_Request.erase(drd); // finish ... } } } } -void DeSerialize (Serialize * sTh, Fem2D::Mesh const ** ppTh) { - if (*ppTh) (**ppTh).decrement(); +void DeSerialize(Serialize *sTh, Fem2D::Mesh const **ppTh) { + if (*ppTh) (**ppTh).decrement( ); Fem2D::Mesh *pTh = new Fem2D::Mesh(*sTh); *ppTh = pTh; - Fem2D::R2 Pn,Px; + Fem2D::R2 Pn, Px; pTh->BoundingBox(Pn, Px); pTh->quadtree = new Fem2D::FQuadTree(pTh, Pn, Px, pTh->nv); } -void DeSerialize (Serialize *sTh, const Fem2D::Mesh3 **ppTh) { - if (*ppTh) (**ppTh).decrement(); - Fem2D::Mesh3 *pTh; - int havebordermesh = sTh->havebordermesh(); - if( !havebordermesh) pTh = new Fem2D::Mesh3(*sTh); - else if(havebordermesh==1) { - if (verbosity>99) cout << " DeSerialize mesh3:meshS " << endl; - pTh = new Fem2D::Mesh3(*sTh, havebordermesh); // have a meshS - } - pTh->BuildGTree(); +void DeSerialize(Serialize *sTh, const Fem2D::Mesh3 **ppTh) { + if (*ppTh) (**ppTh).decrement( ); + Fem2D::Mesh3 *pTh; + int havebordermesh = sTh->havebordermesh( ); + if (!havebordermesh) + pTh = new Fem2D::Mesh3(*sTh); + else if (havebordermesh == 1) { + if (verbosity > 99) cout << " DeSerialize mesh3:meshS " << endl; + pTh = new Fem2D::Mesh3(*sTh, havebordermesh); // have a meshS + } + pTh->BuildGTree( ); *ppTh = pTh; } -void DeSerialize (Serialize *sTh, const Fem2D::MeshS **ppTh) { - if (*ppTh) (**ppTh).decrement(); - Fem2D::MeshS *pTh; - int havebordermesh = sTh->havebordermesh(); - if( !havebordermesh) pTh = new Fem2D::MeshS(*sTh); - else if(havebordermesh==1) { - if (verbosity>99) cout << " DeSerialize mesh3:meshS " << endl; - pTh = new Fem2D::MeshS(*sTh, havebordermesh); // have a meshS - } - pTh->BuildGTree(); +void DeSerialize(Serialize *sTh, const Fem2D::MeshS **ppTh) { + if (*ppTh) (**ppTh).decrement( ); + Fem2D::MeshS *pTh; + int havebordermesh = sTh->havebordermesh( ); + if (!havebordermesh) + pTh = new Fem2D::MeshS(*sTh); + else if (havebordermesh == 1) { + if (verbosity > 99) cout << " DeSerialize mesh3:meshS " << endl; + pTh = new Fem2D::MeshS(*sTh, havebordermesh); // have a meshS + } + pTh->BuildGTree( ); *ppTh = pTh; } -void DeSerialize (Serialize *sTh, const Fem2D::MeshL **ppTh) { - if (*ppTh) (**ppTh).decrement(); +void DeSerialize(Serialize *sTh, const Fem2D::MeshL **ppTh) { + if (*ppTh) (**ppTh).decrement( ); Fem2D::MeshL *pTh = new Fem2D::MeshL(*sTh); - pTh->BuildGTree(); + pTh->BuildGTree( ); *ppTh = pTh; } -template +template< class R > class RevcWMatd : public DoOnWaitMPI_Request { -public: - typedef Matrice_Creuse Mat; - Matrice_Creuse *pmat; - MatriceMorse *mA; + public: + typedef Matrice_Creuse< R > Mat; + Matrice_Creuse< R > *pmat; + MatriceMorse< R > *mA; int state; int ldata[4]; - RevcWMatd(const MPIrank *mpirank, Mat * pm) - : DoOnWaitMPI_Request(*mpirank), pmat(pm), mA(0), state(0) { - int tag = MPI_TAG* >::TAG; + RevcWMatd(const MPIrank *mpirank, Mat *pm) : DoOnWaitMPI_Request(*mpirank), pmat(pm), mA(0), state(0) { + int tag = MPI_TAG< Matrice_Creuse< R > * >::TAG; int ll = WRecv(ldata, 4, who, tag, comm, rq); ffassert(ll == MPI_SUCCESS); } - bool Do(MPI_Request *rrq) { + bool Do(MPI_Request *rrq) { state++; - int tag = MPI_TAG::TAG; - if (verbosity > 100) - cout << mpirank << " ---R: ldata " << ldata[0] << " " << ldata[1] << " " << ldata[2] << " " <::TAG; + if (verbosity > 100) cout << mpirank << " ---R: ldata " << ldata[0] << " " << ldata[1] << " " << ldata[2] << " " << ldata[3] << " " << state << endl; int ll = 0; switch (state) { case 1: - mA = new MatriceMorse(ldata[0], ldata[1], ldata[2], ldata[3]); - ll = WRecv(mA->i, ldata[2], who, tag+1, comm, rq); + mA = new MatriceMorse< R >(ldata[0], ldata[1], ldata[2], ldata[3]); + ll = WRecv(mA->i, ldata[2], who, tag + 1, comm, rq); break; case 2: - ll = WRecv(mA->j, ldata[2], who, tag+2, comm, rq); + ll = WRecv(mA->j, ldata[2], who, tag + 2, comm, rq); break; case 3: - ll = WRecv(mA->aij, ldata[2], who, tag+3, comm, rq); + ll = WRecv(mA->aij, ldata[2], who, tag + 3, comm, rq); break; default: mA->Increaze(ldata[2], ldata[2]); @@ -727,51 +825,49 @@ class RevcWMatd : public DoOnWaitMPI_Request { ffassert(ll == MPI_SUCCESS); - return true; // OK + return true; // OK } - ~RevcWMatd() { - if(mA) delete mA; + ~RevcWMatd( ) { + if (mA) delete mA; } }; -template +template< class R > class SendWMatd : public DoOnWaitMPI_Request { -public: - typedef Matrice_Creuse Mat; - Matrice_Creuse *pmat; - MatriceMorse *mA; + public: + typedef Matrice_Creuse< R > Mat; + Matrice_Creuse< R > *pmat; + MatriceMorse< R > *mA; int state; int ldata[4]; - SendWMatd(const MPIrank *mpirank, Mat *pm) - : DoOnWaitMPI_Request(*mpirank), pmat(pm), mA(0), state(0) { - mA = pmat->pHM(); + SendWMatd(const MPIrank *mpirank, Mat *pm) : DoOnWaitMPI_Request(*mpirank), pmat(pm), mA(0), state(0) { + mA = pmat->pHM( ); CheckPtrHashMatrix(mA, " SendWMatd "); ldata[0] = mA->n; ldata[1] = mA->m; ldata[2] = mA->nnz; ldata[3] = mA->half; - int tag = MPI_TAG* >::TAG; + int tag = MPI_TAG< Matrice_Creuse< R > * >::TAG; int ll = WSend(ldata, 4, who, tag, comm, rq); ffassert(ll == MPI_SUCCESS); } bool Do(MPI_Request *rrq) { state++; - int tag = MPI_TAG::TAG; - if (verbosity > 100) - cout << mpirank << " ---S ldata " << ldata[0] << " " << ldata[1] << " " << ldata[2] << " " <::TAG; + if (verbosity > 100) cout << mpirank << " ---S ldata " << ldata[0] << " " << ldata[1] << " " << ldata[2] << " " << ldata[3] << " " << state << endl; CheckPtrHashMatrix(mA, " SendWMatd 2"); int ll = 0; switch (state) { case 1: - ll = WSend(mA->i, ldata[2], who, tag+1, comm, rq); + ll = WSend(mA->i, ldata[2], who, tag + 1, comm, rq); break; case 2: - ll = WSend(mA->j, ldata[2], who, tag+2, comm, rq); + ll = WSend(mA->j, ldata[2], who, tag + 2, comm, rq); break; case 3: - ll = WSend(mA->aij, ldata[2], who, tag+3, comm, rq); + ll = WSend(mA->aij, ldata[2], who, tag + 3, comm, rq); break; default: return false; @@ -780,1773 +876,1536 @@ class SendWMatd : public DoOnWaitMPI_Request { ffassert(ll == MPI_SUCCESS); - return true; // OK + return true; // OK } - ~SendWMatd() { - } + ~SendWMatd( ) {} }; -template +template< class Mesh > class RevcWMeshd : public DoOnWaitMPI_Request, Serialize { -public: + public: Mesh const **ppTh; int state; - RevcWMeshd (const MPIrank *mpirank, Mesh const **ppThh) - : DoOnWaitMPI_Request(*mpirank), Serialize(sizempibuf, Fem2D::Mesh::magicmesh), - ppTh(ppThh), state(0) { + RevcWMeshd(const MPIrank *mpirank, Mesh const **ppThh) : DoOnWaitMPI_Request(*mpirank), Serialize(sizempibuf, Fem2D::Mesh::magicmesh), ppTh(ppThh), state(0) { // remark: the first data in p is the size in long long - int tag = MPI_TAG::TAG; - if (verbosity > 99) - cout << " -- RevcWMeshd " << rq << " " << comm << " " << p << endl; - int ll = WRecv(p, sizempibuf, who, tag, comm, rq); // wait first part Warning async => not wait. + int tag = MPI_TAG< Mesh * >::TAG; + if (verbosity > 99) cout << " -- RevcWMeshd " << rq << " " << comm << " " << p << endl; + int ll = WRecv(p, sizempibuf, who, tag, comm, rq); // wait first part Warning async => not wait. } - bool Do (MPI_Request *rrq) { + bool Do(MPI_Request *rrq) { long long lsz; - int tag = MPI_TAG::TAG; + int tag = MPI_TAG< Mesh * >::TAG; ffassert(rq == rrq); size_t kk = 0; get(kk, lsz); - if (verbosity > 199) - cout << mpirank << " -- lsk = " << lsz << " p= " << p << " p[]= " - << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; + if (verbosity > 199) cout << mpirank << " -- lsk = " << lsz << " p= " << p << " p[]= " << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; long l1 = lsz - sizempibuf; - if (verbosity > 100) - cout << mpirank << " Do RevcWMeshd " << lsz << " " << state << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; + if (verbosity > 100) cout << mpirank << " Do RevcWMeshd " << lsz << " " << state << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; - if (0 == state++ && l1 > 0 ) { // recv first part .. - if (verbosity > 100) - cout << mpirank << " + Do RevcWMeshd " << lsz << " " << state << " cont : " << (l1 > sizempibuf) << " " << rq << " " << l1 << endl; + if (0 == state++ && l1 > 0) { // recv first part .. + if (verbosity > 100) cout << mpirank << " + Do RevcWMeshd " << lsz << " " << state << " cont : " << (l1 > sizempibuf) << " " << rq << " " << l1 << endl; + resize(lsz); + int ll = WRecv(p + sizempibuf, l1, who, tag + state, comm, rq); + return true; // continue .. + } else resize(lsz); - int ll = WRecv(p+sizempibuf, l1, who, tag+state, comm, rq); - return true; // continue .. - } else resize(lsz); // we have the all buffer => DeSerialize - if(lsz) - DeSerialize(this, ppTh); - if (verbosity > 100) - cout << " " << mpirank << " received from " << who << " serialized " << what << ", l=" - << lsz << ", tag=" << tag << " rq = " << rq << " " << *ppTh << endl; - return false; // OK + if (lsz) DeSerialize(this, ppTh); + if (verbosity > 100) cout << " " << mpirank << " received from " << who << " serialized " << what << ", l=" << lsz << ", tag=" << tag << " rq = " << rq << " " << *ppTh << endl; + return false; // OK } - ~RevcWMeshd() {} + ~RevcWMeshd( ) {} }; -template +template< class Mesh > class SendWMeshd : public DoOnWaitMPI_Request, Serialize { -public: + public: const Mesh **ppTh; MPI_Request rqSecond; - SendWMeshd(const MPIrank *mpirank, const Mesh ** ppThh) - : DoOnWaitMPI_Request(*mpirank), Serialize((**ppThh).serialize()), - ppTh(ppThh) { + SendWMeshd(const MPIrank *mpirank, const Mesh **ppThh) : DoOnWaitMPI_Request(*mpirank), Serialize((**ppThh).serialize( )), ppTh(ppThh) { { long long lsz; size_t kk = 0; get(kk, lsz); - ffassert(lsz == lg); // verif + ffassert(lsz == lg); // verif } - int tag = MPI_TAG::TAG; + int tag = MPI_TAG< Mesh * >::TAG; - if (verbosity > 100) - cout << " -- SendWMeshd " << rq << " " << comm << " " << p << " " << lg << " "<< " p[]= " - << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; + if (verbosity > 100) cout << " -- SendWMeshd " << rq << " " << comm << " " << p << " " << lg << " " << " p[]= " << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; if (lg <= sizempibuf) WSend(p, lg, who, tag, comm, rq); else WSend(p, sizempibuf, who, tag, comm, rq); - long l1 = lg-sizempibuf; - if (l1 > 0) { // send the second part - if (verbosity > 100) - cout << mpirank << " Do SendWMeshd " << lg << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; - WSend(p+sizempibuf, l1, who, tag+1, comm, &rqSecond); + long l1 = lg - sizempibuf; + if (l1 > 0) { // send the second part + if (verbosity > 100) cout << mpirank << " Do SendWMeshd " << lg << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; + WSend(p + sizempibuf, l1, who, tag + 1, comm, &rqSecond); + } else + rqSecond = MPI_REQUEST_NULL; + } + + SendWMeshd(const MPIrank *mpirank, const Mesh **ppThh, bool havebordermesh) : DoOnWaitMPI_Request(*mpirank), Serialize((**ppThh).serialize_withBorderMesh( )), ppTh(ppThh) { + { + long long lsz; + size_t kk = 0; + get(kk, lsz); + ffassert(lsz == lg); // verif + kk = 2 * sizeof(int); + int bordermesh = 0; + get(kk, bordermesh); + ffassert(bordermesh == 1); } + int tag = MPI_TAG< Mesh * >::TAG; + + if (verbosity > 100) cout << " -- SendWMeshd with border mesh" << rq << " " << comm << " " << p << " " << lg << " " << " p[]= " << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; + + if (lg <= sizempibuf) + WSend(p, lg, who, tag, comm, rq); else + WSend(p, sizempibuf, who, tag, comm, rq); + long l1 = lg - sizempibuf; + if (l1 > 0) { // send the second part + if (verbosity > 100) cout << mpirank << " Do SendWMeshd " << lg << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; + WSend(p + sizempibuf, l1, who, tag + 1, comm, &rqSecond); + } else rqSecond = MPI_REQUEST_NULL; } - - SendWMeshd(const MPIrank *mpirank, const Mesh ** ppThh, bool havebordermesh) - : DoOnWaitMPI_Request(*mpirank), Serialize((**ppThh).serialize_withBorderMesh()), - ppTh(ppThh) { - { - long long lsz; - size_t kk = 0; - get(kk, lsz); - ffassert(lsz == lg); // verif - kk=2*sizeof(int); - int bordermesh=0; - get(kk, bordermesh); - ffassert(bordermesh == 1); - - } - int tag = MPI_TAG::TAG; - - if (verbosity > 100) - cout << " -- SendWMeshd with border mesh" << rq << " " << comm << " " << p << " " << lg << " "<< " p[]= " - << (int)p[0] << (int)p[1] << (int)p[2] << (int)p[3] << endl; - - if (lg <= sizempibuf) - WSend(p, lg, who, tag, comm, rq); - else - WSend(p, sizempibuf, who, tag, comm, rq); - long l1 = lg-sizempibuf; - if (l1 > 0) { // send the second part - if (verbosity > 100) - cout << mpirank << " Do SendWMeshd " << lg << " cont : " << (l1 > 0) << " " << rq << " " << comm << endl; - WSend(p+sizempibuf, l1, who, tag+1, comm, &rqSecond); - } - else - rqSecond = MPI_REQUEST_NULL; - } - bool Do(MPI_Request *rrq) { - if(rqSecond != MPI_REQUEST_NULL) - MPI_Wait(&rqSecond, MPI_STATUS_IGNORE); - return false;// Fini + if (rqSecond != MPI_REQUEST_NULL) MPI_Wait(&rqSecond, MPI_STATUS_IGNORE); + return false; // Fini } - ~SendWMeshd() {count()=0;} + ~SendWMeshd( ) { count( ) = 0; } }; +template< class R > +long MPIrank::Send(Matrice_Creuse< R > *const &a) const { + SendWMatd< R > *rwm = new SendWMatd< R >(this, a); + if (rwm->DoSR( )) delete rwm; + return MPI_SUCCESS; +} -template - long MPIrank::Send(Matrice_Creuse * const & a) const - { - SendWMatd *rwm= new SendWMatd(this,a); - if( rwm->DoSR() ) delete rwm; - return MPI_SUCCESS; - } - - template - long MPIrank::Recv(Matrice_Creuse & a) const +template< class R > +long MPIrank::Recv(Matrice_Creuse< R > &a) const { { - { - RevcWMatd *rwm= new RevcWMatd(this,&a); - if( rwm->DoSR() ) delete rwm; - return MPI_SUCCESS; - } - } - - -long MPIrank::Send(const Fem2D::Mesh * a) const { - if(verbosity>100) - cout << " MPI << (mesh *) " << a << endl; - if(a) { - SendWMeshd *rwm= new SendWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - } - else { - WSend((char*)NULL, 0, who, MPI_TAG::TAG, comm, rq); - } + RevcWMatd< R > *rwm = new RevcWMatd< R >(this, &a); + if (rwm->DoSR( )) delete rwm; return MPI_SUCCESS; } +} - -long MPIrank::Send (const Fem2D::Mesh3 * a) const { - if(verbosity>100) - cout << " MPI << (mesh3 *) " << a << endl; - if(a) { - SendWMeshd *rwm= new SendWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - } - else { - WSend((char*)NULL, 0, who, MPI_TAG::TAG, comm, rq); - } - return MPI_SUCCESS; +long MPIrank::Send(const Fem2D::Mesh *a) const { + if (verbosity > 100) cout << " MPI << (mesh *) " << a << endl; + if (a) { + SendWMeshd< Mesh > *rwm = new SendWMeshd< Mesh >(this, &a); + if (rwm->DoSR( )) delete rwm; + } else { + WSend((char *)NULL, 0, who, MPI_TAG< Fem2D::Mesh * >::TAG, comm, rq); } + return MPI_SUCCESS; +} -long MPIrank::Send (const Fem2D::MeshS * a) const { - if(verbosity>100) - cout << " MPI << (meshS *) " << a << endl; - ffassert(a); - SendWMeshd *rwm= new SendWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - return MPI_SUCCESS; +long MPIrank::Send(const Fem2D::Mesh3 *a) const { + if (verbosity > 100) cout << " MPI << (mesh3 *) " << a << endl; + if (a) { + SendWMeshd< Mesh3 > *rwm = new SendWMeshd< Mesh3 >(this, &a); + if (rwm->DoSR( )) delete rwm; + } else { + WSend((char *)NULL, 0, who, MPI_TAG< Fem2D::Mesh3 * >::TAG, comm, rq); } + return MPI_SUCCESS; +} -long MPIrank::Send (const Fem2D::MeshL * a) const { - if(verbosity>100) - cout << " MPI << (meshL *) " << a << endl; +long MPIrank::Send(const Fem2D::MeshS *a) const { + if (verbosity > 100) cout << " MPI << (meshS *) " << a << endl; ffassert(a); - SendWMeshd *rwm= new SendWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; + SendWMeshd< MeshS > *rwm = new SendWMeshd< MeshS >(this, &a); + if (rwm->DoSR( )) delete rwm; + return MPI_SUCCESS; +} + +long MPIrank::Send(const Fem2D::MeshL *a) const { + if (verbosity > 100) cout << " MPI << (meshL *) " << a << endl; + ffassert(a); + SendWMeshd< MeshL > *rwm = new SendWMeshd< MeshL >(this, &a); + if (rwm->DoSR( )) delete rwm; return MPI_SUCCESS; } // new version asyncrone ... Now 2010 ... -long MPIrank::Recv(const Fem2D::Mesh *& a) const { - if(verbosity>100) - cout << " MPI >> (mesh *) &" << a << " " << &a << endl; - RevcWMeshd *rwm= new RevcWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - if((rq==0 || rq == Syncro_block)) - ffassert( a ); - return MPI_SUCCESS; +long MPIrank::Recv(const Fem2D::Mesh *&a) const { + if (verbosity > 100) cout << " MPI >> (mesh *) &" << a << " " << &a << endl; + RevcWMeshd< Mesh > *rwm = new RevcWMeshd< Mesh >(this, &a); + if (rwm->DoSR( )) delete rwm; + if ((rq == 0 || rq == Syncro_block)) ffassert(a); + return MPI_SUCCESS; } -long MPIrank::Recv(const Fem2D::Mesh3 *& a) const { - if(verbosity>100) - cout << " MPI >> (mesh3 *) &" << a << " " << &a << endl; - RevcWMeshd *rwm= new RevcWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - if((rq==0 || rq == Syncro_block)) - ffassert( a ); - return MPI_SUCCESS; +long MPIrank::Recv(const Fem2D::Mesh3 *&a) const { + if (verbosity > 100) cout << " MPI >> (mesh3 *) &" << a << " " << &a << endl; + RevcWMeshd< Mesh3 > *rwm = new RevcWMeshd< Mesh3 >(this, &a); + if (rwm->DoSR( )) delete rwm; + if ((rq == 0 || rq == Syncro_block)) ffassert(a); + return MPI_SUCCESS; } -long MPIrank::Recv(const Fem2D::MeshS *& a) const { - if(verbosity>100) - cout << " MPI >> (meshS *) &" << a << " " << &a << endl; - RevcWMeshd *rwm= new RevcWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - if((rq==0 || rq == Syncro_block)) - ffassert( a ); - return MPI_SUCCESS; +long MPIrank::Recv(const Fem2D::MeshS *&a) const { + if (verbosity > 100) cout << " MPI >> (meshS *) &" << a << " " << &a << endl; + RevcWMeshd< MeshS > *rwm = new RevcWMeshd< MeshS >(this, &a); + if (rwm->DoSR( )) delete rwm; + if ((rq == 0 || rq == Syncro_block)) ffassert(a); + return MPI_SUCCESS; } -long MPIrank::Recv(const Fem2D::MeshL *& a) const { - if(verbosity>100) - cout << " MPI >> (meshL *) &" << a << " " << &a << endl; - RevcWMeshd *rwm= new RevcWMeshd(this,&a); - if( rwm->DoSR() ) delete rwm; - if((rq==0 || rq == Syncro_block)) - ffassert( a ); - return MPI_SUCCESS; +long MPIrank::Recv(const Fem2D::MeshL *&a) const { + if (verbosity > 100) cout << " MPI >> (meshL *) &" << a << " " << &a << endl; + RevcWMeshd< MeshL > *rwm = new RevcWMeshd< MeshL >(this, &a); + if (rwm->DoSR( )) delete rwm; + if ((rq == 0 || rq == Syncro_block)) ffassert(a); + return MPI_SUCCESS; } -void Serialize::mpisend(const MPIrank & rank,long tag,const void * vmpirank) -{ - const MPIrank * mpirank=static_cast (vmpirank); - MPI_Comm comm=mpirank->comm; - MPI_Request *rq=mpirank->rq; - ffassert(rq==0 || rq == Syncro_block); - char * pp = p-sizeof(long); - long countsave=count(); // save count - count()=lg; // store length in count - long l=lg+sizeof(long); - if(verbosity>100) - cout << " -- send from " << mpirank << " to " << rank << " serialized " << what - << ", l=" << l << ", tag=" << tag << " " << (l < sizempibuf) << endl; - if (l <=sizempibuf) - WSend(pp,l, rank, tag,comm,rq); +void Serialize::mpisend(const MPIrank &rank, long tag, const void *vmpirank) { + const MPIrank *mpirank = static_cast< const MPIrank * >(vmpirank); + MPI_Comm comm = mpirank->comm; + MPI_Request *rq = mpirank->rq; + ffassert(rq == 0 || rq == Syncro_block); + char *pp = p - sizeof(long); + long countsave = count( ); // save count + count( ) = lg; // store length in count + long l = lg + sizeof(long); + if (verbosity > 100) cout << " -- send from " << mpirank << " to " << rank << " serialized " << what << ", l=" << l << ", tag=" << tag << " " << (l < sizempibuf) << endl; + if (l <= sizempibuf) + WSend(pp, l, rank, tag, comm, rq); else { - WSend(pp,sizempibuf, rank, tag,comm,rq); - WSend(pp+sizempibuf,l-sizempibuf, rank, tag+1,comm,rq); + WSend(pp, sizempibuf, rank, tag, comm, rq); + WSend(pp + sizempibuf, l - sizempibuf, rank, tag + 1, comm, rq); } - if(verbosity>100) - cout << " ok send is arrived " << endl; - count()=countsave; // restore count + if (verbosity > 100) cout << " ok send is arrived " << endl; + count( ) = countsave; // restore count } +Serialize::Serialize(const MPIrank &rank, const char *wht, long tag, const void *vmpirank) : what(wht) { + const MPIrank *mpirank = static_cast< const MPIrank * >(vmpirank); + MPI_Comm comm = mpirank->comm; + MPI_Request *rq = mpirank->rq; -Serialize::Serialize(const MPIrank & rank,const char * wht,long tag,const void * vmpirank) - :what(wht) -{ - const MPIrank * mpirank=static_cast (vmpirank); - MPI_Comm comm=mpirank->comm; - MPI_Request *rq=mpirank->rq; - - if(verbosity>100) - cout << " -- waiting " << mpirank << " from " << rank << " serialized " << what - << " tag = " << tag << endl; - if(!(rq==0 || rq == Syncro_block)) - { - ExecError("Not async recv of complex objet! Sorry to hard to code (FH!)."); - ffassert(rq==0 || rq == Syncro_block); - } - - - char * buf= new char [sizempibuf]; - WRecv(buf, sizempibuf, rank, tag,comm,rq); - lg = * (long *) (void *) buf; - long l=lg+sizeof(long); - char * pp= new char[l] ; - if ( l <= sizempibuf) - memcpy(pp,buf,l); - else - { - memcpy(pp,buf,sizempibuf); - WRecv(pp+sizempibuf,l-sizempibuf, rank, tag+1,comm,rq) ; - } + if (verbosity > 100) cout << " -- waiting " << mpirank << " from " << rank << " serialized " << what << " tag = " << tag << endl; + if (!(rq == 0 || rq == Syncro_block)) { + ExecError("Not async recv of complex objet! Sorry to hard to code (FH!)."); + ffassert(rq == 0 || rq == Syncro_block); + } - if(verbosity>100) - cout << " " << mpirank << " received from " << rank << " serialized " << what << ", l=" - << l << ", tag=" << tag << endl; - delete [] buf; - p=pp+sizeof(long); - count()=0; + char *buf = new char[sizempibuf]; + WRecv(buf, sizempibuf, rank, tag, comm, rq); + lg = *(long *)(void *)buf; + long l = lg + sizeof(long); + char *pp = new char[l]; + if (l <= sizempibuf) + memcpy(pp, buf, l); + else { + memcpy(pp, buf, sizempibuf); + WRecv(pp + sizempibuf, l - sizempibuf, rank, tag + 1, comm, rq); + } + if (verbosity > 100) cout << " " << mpirank << " received from " << rank << " serialized " << what << ", l=" << l << ", tag=" << tag << endl; + delete[] buf; + p = pp + sizeof(long); + count( ) = 0; } -template +template< class A > struct Op_Readmpi { - using first_argument_type = MPIrank; - using second_argument_type = A*; - using result_type = MPIrank; - static MPIrank f(MPIrank const & f,A * const & a) - { + using first_argument_type = MPIrank; + using second_argument_type = A *; + using result_type = MPIrank; + static MPIrank f(MPIrank const &f, A *const &a) { f.Recv(*a); return f; } }; -template +template< class A > struct Op_Recvmpi { - using first_argument_type = MPIrank; - using second_argument_type = A*; - using result_type = long; - static MPIrank f(MPIrank const & f,A * const & a) - { - ffassert(f.rq ==0 || f.rq == Syncro_block); // Block + using first_argument_type = MPIrank; + using second_argument_type = A *; + using result_type = long; + static MPIrank f(MPIrank const &f, A *const &a) { + ffassert(f.rq == 0 || f.rq == Syncro_block); // Block return f.Recv(*a); - } }; -template +template< class A > struct Op_IRecvmpi { - using first_argument_type = MPIrank; - using second_argument_type = A*; - using result_type = long; - static MPIrank f(MPIrank const & f,A * const & a) - { - ffassert(f.rq !=0 || f.rq != Syncro_block); // no Block + using first_argument_type = MPIrank; + using second_argument_type = A *; + using result_type = long; + static MPIrank f(MPIrank const &f, A *const &a) { + ffassert(f.rq != 0 || f.rq != Syncro_block); // no Block return f.Recv(*a); - } }; - -template +template< class A > struct Op_Writempi { - using first_argument_type = MPIrank; + using first_argument_type = MPIrank; using second_argument_type = A; - using result_type = MPIrank; - static MPIrank f(MPIrank const & f,A const & a) - { + using result_type = MPIrank; + static MPIrank f(MPIrank const &f, A const &a) { f.Send(a); return f; } }; - -template +template< class A > struct Op_Bcastmpi { - using first_argument_type = MPIrank; - using second_argument_type = A*; - using result_type = MPIrank; - static MPIrank f(MPIrank const & f,A * const & a) - { + using first_argument_type = MPIrank; + using second_argument_type = A *; + using result_type = MPIrank; + static MPIrank f(MPIrank const &f, A *const &a) { f.Bcast(*a); return f; - } + } }; -template +template< class A > struct Op_ISendmpi { - using first_argument_type = MPIrank; + using first_argument_type = MPIrank; using second_argument_type = A; - using result_type = long; - static MPIrank f(MPIrank const & f,A const & a) - { + using result_type = long; + static MPIrank f(MPIrank const &f, A const &a) { ffassert(f.rq != Syncro_block); return f.Send(a); } }; -template +template< class A > struct Op_Sendmpi { - using first_argument_type = MPIrank; + using first_argument_type = MPIrank; using second_argument_type = A; - using result_type = long; - static MPIrank f(MPIrank const & f,A const & a) - { - MPIrank ff(f.who,f.comm,Syncro_block); - return ff.Send(a); + using result_type = long; + static MPIrank f(MPIrank const &f, A const &a) { + MPIrank ff(f.who, f.comm, Syncro_block); + return ff.Send(a); } }; - -template +template< class R > struct Op_All2All { - using first_argument_type = KN_; - using second_argument_type = KN_; - using result_type = long; - static long f( KN_ const & s, KN_ const &r) - { - CheckContigueKN(s); - CheckContigueKN(r); + using first_argument_type = KN_< R >; + using second_argument_type = KN_< R >; + using result_type = long; + static long f(KN_< R > const &s, KN_< R > const &r) { + CheckContigueKN(s); + CheckContigueKN(r); - MPI_Comm comm=MPI_COMM_WORLD; + MPI_Comm comm = MPI_COMM_WORLD; int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = s.N()/mpisizew; - ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); + int chunk = s.N( ) / mpisizew; + ffassert(s.N( ) == mpisizew * chunk && r.N( ) == s.N( )); - return MPI_Alltoall( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); + return MPI_Alltoall((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); } }; - -template +template< class R > struct Op_Allgather1 { - using first_argument_type = R*; - using second_argument_type = KN_; - using result_type = long; - static long f( R* const & s, KN_ const &r) - { - MPI_Comm comm=MPI_COMM_WORLD; - int mpisizew; - CheckContigueKN(r); + using first_argument_type = R *; + using second_argument_type = KN_< R >; + using result_type = long; + static long f(R *const &s, KN_< R > const &r) { + MPI_Comm comm = MPI_COMM_WORLD; + int mpisizew; + CheckContigueKN(r); - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = 1; - ffassert(r.N()==mpisizew); + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = 1; + ffassert(r.N( ) == mpisizew); - return MPI_Allgather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); - } + return MPI_Allgather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); + } }; -template +template< class R > struct Op_Allgather { - using first_argument_type = KN_; - using second_argument_type = KN_; - using result_type = long; - static long f( KN_ const & s, KN_ const &r) - { - CheckContigueKN(s); - CheckContigueKN(r); - - MPI_Comm comm=MPI_COMM_WORLD; - int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = r.N()/mpisizew; - ffassert(r.N()==mpisizew*chunk && chunk == s.N()); - return MPI_Allgather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); - } + using first_argument_type = KN_< R >; + using second_argument_type = KN_< R >; + using result_type = long; + static long f(KN_< R > const &s, KN_< R > const &r) { + CheckContigueKN(s); + CheckContigueKN(r); + + MPI_Comm comm = MPI_COMM_WORLD; + int mpisizew; + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = r.N( ) / mpisizew; + ffassert(r.N( ) == mpisizew * chunk && chunk == s.N( )); + return MPI_Allgather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); + } }; -template -struct Op_All2All3 : public ternary_function,KN_,fMPI_Comm,long> { - static long f(Stack, KN_ const & s, KN_ const &r,fMPI_Comm const & cmm ) - { - CheckContigueKN(s); - CheckContigueKN(r); +template< class R > +struct Op_All2All3 : public ternary_function< KN_< R >, KN_< R >, fMPI_Comm, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, fMPI_Comm const &cmm) { + CheckContigueKN(s); + CheckContigueKN(r); - MPI_Comm comm=cmm; - int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = s.N()/mpisizew; - ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); + MPI_Comm comm = cmm; + int mpisizew; + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = s.N( ) / mpisizew; + ffassert(s.N( ) == mpisizew * chunk && r.N( ) == s.N( )); - return MPI_Alltoall( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); - } + return MPI_Alltoall((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); + } }; -template -struct Op_Allgather3 : public ternary_function,KN_,fMPI_Comm,long> { - static long f(Stack, KN_ const & s, KN_ const &r,fMPI_Comm const & cmm) - { - CheckContigueKN(r); - CheckContigueKN(s); +template< class R > +struct Op_Allgather3 : public ternary_function< KN_< R >, KN_< R >, fMPI_Comm, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, fMPI_Comm const &cmm) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = r.N()/mpisizew; // bug corrected by J. Morice - //ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); - ffassert(s.N()==chunk && r.N()==s.N()*mpisizew); + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = r.N( ) / mpisizew; // bug corrected by J. Morice + // ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); + ffassert(s.N( ) == chunk && r.N( ) == s.N( ) * mpisizew); - return MPI_Allgather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); + return MPI_Allgather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); } }; +template< class R > +struct Op_Allgather13 : public ternary_function< R *, KN_< R >, fMPI_Comm, long > { + static long f(Stack, R *const &s, KN_< R > const &r, fMPI_Comm const &cmm) { -template -struct Op_Allgather13 : public ternary_function,fMPI_Comm,long> { - static long f(Stack, R* const & s, KN_ const &r,fMPI_Comm const & cmm) - { - - CheckContigueKN(r); + CheckContigueKN(r); - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = 1; // bug corrected by J. Morice - ffassert( r.N()==mpisizew); + int chunk = 1; // bug corrected by J. Morice + ffassert(r.N( ) == mpisizew); - return MPI_Allgather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(), comm); + return MPI_Allgather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), comm); } }; // Add J. Morice -template -long Op_All2Allv( KN_ const & s, KN_ const &r, KN_ const &sendcnts, KN_ const &sdispls, KN_ const &recvcnts, KN_ const &rdispls) -{ - CheckContigueKN(s); - CheckContigueKN(r); +template< class R > +long Op_All2Allv(KN_< R > const &s, KN_< R > const &r, KN_< long > const &sendcnts, KN_< long > const &sdispls, KN_< long > const &recvcnts, KN_< long > const &rdispls) { + CheckContigueKN(s); + CheckContigueKN(r); - MPI_Comm comm=MPI_COMM_WORLD; - int mpirankv=MPI_UNDEFINED; + MPI_Comm comm = MPI_COMM_WORLD; + int mpirankv = MPI_UNDEFINED; MPI_Comm_rank(comm, &mpirankv); int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - ffassert( sendcnts.N() == sdispls.N() && sendcnts.N() == recvcnts.N() && sendcnts.N() == rdispls.N() && sendcnts.N() == mpisizew ); + ffassert(sendcnts.N( ) == sdispls.N( ) && sendcnts.N( ) == recvcnts.N( ) && sendcnts.N( ) == rdispls.N( ) && sendcnts.N( ) == mpisizew); - KN INTsendcnts(sendcnts.N()); - KN INTsdispls(sdispls.N()); - KN INTrecvcnts(recvcnts.N()); - KN INTrdispls(rdispls.N()); + KN< int > INTsendcnts(sendcnts.N( )); + KN< int > INTsdispls(sdispls.N( )); + KN< int > INTrecvcnts(recvcnts.N( )); + KN< int > INTrdispls(rdispls.N( )); - for(int ii=0; ii< sendcnts.N(); ii++){ + for (int ii = 0; ii < sendcnts.N( ); ii++) { INTsendcnts[ii] = sendcnts[ii]; - INTsdispls[ii] = sdispls[ii]; - INTrecvcnts[ii] = recvcnts[ii]; - INTrdispls[ii] = rdispls[ii]; + INTsdispls[ii] = sdispls[ii]; + INTrecvcnts[ii] = recvcnts[ii]; + INTrdispls[ii] = rdispls[ii]; } - return MPI_Alltoallv( (void *) (R*) s, INTsendcnts, INTsdispls, MPI_TYPE::TYPE(), - (void *) (R*) r, INTrecvcnts, INTrdispls, MPI_TYPE::TYPE(), comm); + return MPI_Alltoallv((void *)(R *)s, INTsendcnts, INTsdispls, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, INTrecvcnts, INTrdispls, MPI_TYPE< R >::TYPE( ), comm); } +template< class R > +struct Op_Allgatherv : public quad_function< KN_< R >, KN_< R >, KN_< long >, KN_< long >, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, KN_< long > const &recvcount, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); - -template -struct Op_Allgatherv : public quad_function,KN_,KN_,KN_,long> { - static long f( Stack ,KN_ const & s, KN_ const &r, KN_ const & recvcount, KN_ const & displs) - { - CheckContigueKN(r); - CheckContigueKN(s); - - MPI_Comm comm=MPI_COMM_WORLD; + MPI_Comm comm = MPI_COMM_WORLD; int mpisizew; MPI_Comm_size(comm, &mpisizew); - ffassert( recvcount.N() == displs.N() && recvcount.N() == mpisizew); - long sum=0; - for(int ii=0; ii< recvcount.N(); ii++) - sum+=recvcount[ii]; - ffassert( sum == r.N() ); - - KN INTrecvcount(recvcount.N()); - KN INTdispls(displs.N()); - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; + ffassert(recvcount.N( ) == displs.N( ) && recvcount.N( ) == mpisizew); + long sum = 0; + for (int ii = 0; ii < recvcount.N( ); ii++) sum += recvcount[ii]; + ffassert(sum == r.N( )); + + KN< int > INTrecvcount(recvcount.N( )); + KN< int > INTdispls(displs.N( )); + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Allgatherv( (void *) (R*) s, s.N(), MPI_TYPE::TYPE(), - (void *) (R*) r, INTrecvcount, INTdispls,MPI_TYPE::TYPE(), comm); + return MPI_Allgatherv((void *)(R *)s, s.N( ), MPI_TYPE< R >::TYPE( ), (void *)(R *)r, INTrecvcount, INTdispls, MPI_TYPE< R >::TYPE( ), comm); } }; -template -long Op_All2All3v(KN_ const & s, KN_ const &r,fMPI_Comm const & cmm, KN_ const &sendcnts, KN_ const &sdispls, KN_ const &recvcnts, KN_ const &rdispls ) -{ - CheckContigueKN(r); - CheckContigueKN(s); +template< class R > +long Op_All2All3v(KN_< R > const &s, KN_< R > const &r, fMPI_Comm const &cmm, KN_< long > const &sendcnts, KN_< long > const &sdispls, KN_< long > const &recvcnts, KN_< long > const &rdispls) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=cmm; - int mpirankv=MPI_UNDEFINED; + MPI_Comm comm = cmm; + int mpirankv = MPI_UNDEFINED; MPI_Comm_rank(comm, &mpirankv); int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - ffassert( sendcnts.N() == sdispls.N() && sendcnts.N() == recvcnts.N() && sendcnts.N() == rdispls.N() && sendcnts.N() == mpisizew ); + ffassert(sendcnts.N( ) == sdispls.N( ) && sendcnts.N( ) == recvcnts.N( ) && sendcnts.N( ) == rdispls.N( ) && sendcnts.N( ) == mpisizew); - KN INTsendcnts(sendcnts.N()); - KN INTsdispls(sdispls.N()); - KN INTrecvcnts(recvcnts.N()); - KN INTrdispls(rdispls.N()); + KN< int > INTsendcnts(sendcnts.N( )); + KN< int > INTsdispls(sdispls.N( )); + KN< int > INTrecvcnts(recvcnts.N( )); + KN< int > INTrdispls(rdispls.N( )); - for(int ii=0; ii< sendcnts.N(); ii++){ + for (int ii = 0; ii < sendcnts.N( ); ii++) { INTsendcnts[ii] = sendcnts[ii]; - INTsdispls[ii] = sdispls[ii]; - INTrecvcnts[ii] = recvcnts[ii]; - INTrdispls[ii] = rdispls[ii]; + INTsdispls[ii] = sdispls[ii]; + INTrecvcnts[ii] = recvcnts[ii]; + INTrdispls[ii] = rdispls[ii]; } - return MPI_Alltoallv( (void *) (R*) s, INTsendcnts, INTsdispls, MPI_TYPE::TYPE(), - (void *) (R*) r, INTrecvcnts, INTrdispls, MPI_TYPE::TYPE(), comm); + return MPI_Alltoallv((void *)(R *)s, INTsendcnts, INTsdispls, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, INTrecvcnts, INTrdispls, MPI_TYPE< R >::TYPE( ), comm); } +template< class R > +long Op_Allgatherv3(KN_< R > const &s, KN_< R > const &r, fMPI_Comm const &cmm, KN_< long > const &recvcount, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); -template -long Op_Allgatherv3(KN_ const & s, KN_ const &r,fMPI_Comm const & cmm, KN_ const & recvcount, KN_ const & displs) -{ - CheckContigueKN(r); - CheckContigueKN(s); - - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; MPI_Comm_size(comm, &mpisizew); - ffassert( recvcount.N() == displs.N() && recvcount.N() == mpisizew); - long sum=0; - for(int ii=0; ii< recvcount.N(); ii++) - sum+=recvcount[ii]; - ffassert( sum == r.N() ); - KN INTrecvcount(recvcount.N()); - KN INTdispls(displs.N()); - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; - } - - return MPI_Allgatherv( (void *) (R*) s, s.N(), MPI_TYPE::TYPE(), - (void *) (R*) r, INTrecvcount, INTdispls,MPI_TYPE::TYPE(), comm); + ffassert(recvcount.N( ) == displs.N( ) && recvcount.N( ) == mpisizew); + long sum = 0; + for (int ii = 0; ii < recvcount.N( ); ii++) sum += recvcount[ii]; + ffassert(sum == r.N( )); + KN< int > INTrecvcount(recvcount.N( )); + KN< int > INTdispls(displs.N( )); + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; + } + + return MPI_Allgatherv((void *)(R *)s, s.N( ), MPI_TYPE< R >::TYPE( ), (void *)(R *)r, INTrecvcount, INTdispls, MPI_TYPE< R >::TYPE( ), comm); } - -template -struct Op_Scatter1 : public ternary_function, R* ,MPIrank,long> { - static long f(Stack, KN_ const & s, R* const &r, MPIrank const & root) - { - CheckContigueKN(s); - +template< class R > +struct Op_Scatter1 : public ternary_function< KN_< R >, R *, MPIrank, long > { + static long f(Stack, KN_< R > const &s, R *const &r, MPIrank const &root) { + CheckContigueKN(s); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); int chunk = 1; - return MPI_Scatter( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Scatter((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), root.who, root.comm); } }; - // Fin add J. Morice +template< class R > +struct Op_Scatter3 : public ternary_function< KN_< R >, KN_< R >, MPIrank, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, MPIrank const &root) { -template -struct Op_Scatter3 : public ternary_function,KN_,MPIrank,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root) - { - - CheckContigueKN(r); - CheckContigueKN(s); + CheckContigueKN(r); + CheckContigueKN(s); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); - int chunk = r.N(); // FH correct jan 2012 ... + int chunk = r.N( ); // FH correct jan 2012 ... - return MPI_Scatter( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Scatter((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), root.who, root.comm); } }; // Add J. Morice -template -long Op_Scatterv3( KN_ const & s, KN_ const &r, MPIrank const & root, KN_ const &sendcnts, KN_ const &displs) -{ - CheckContigueKN(r); - CheckContigueKN(s); +template< class R > +long Op_Scatterv3(KN_< R > const &s, KN_< R > const &r, MPIrank const &root, KN_< long > const &sendcnts, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); - int mpirankv=MPI_UNDEFINED; - if(root.comm != MPI_COMM_NULL) - MPI_Comm_rank(root.comm, &mpirankv); + int mpirankv = MPI_UNDEFINED; + if (root.comm != MPI_COMM_NULL) MPI_Comm_rank(root.comm, &mpirankv); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); /* local */ - KN INTsendcnts(mpirankv == root.who ? sendcnts.N() : 0); - KN INTdispls(mpirankv == root.who ? sendcnts.N() : 0); - for(int ii=0; ii< INTsendcnts.N(); ii++){ - INTsendcnts[ii]= sendcnts[ii]; - INTdispls[ii]= displs[ii]; + KN< int > INTsendcnts(mpirankv == root.who ? sendcnts.N( ) : 0); + KN< int > INTdispls(mpirankv == root.who ? sendcnts.N( ) : 0); + for (int ii = 0; ii < INTsendcnts.N( ); ii++) { + INTsendcnts[ii] = sendcnts[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Scatterv( (void *) (R*) s, INTsendcnts, INTdispls, MPI_TYPE::TYPE(), - (void *) (R*) r, r.N(), MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Scatterv((void *)(R *)s, INTsendcnts, INTdispls, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, r.N( ), MPI_TYPE< R >::TYPE( ), root.who, root.comm); } // fin J. Morice -template uint64_t CodeIJ(const MatriceMorse * pa) { return pa->CodeIJ();} +template< class R > +uint64_t CodeIJ(const MatriceMorse< R > *pa) { + return pa->CodeIJ( ); +} -template -struct Op_ReduceMat : public quad_function*,Matrice_Creuse *,MPIrank,fMPI_Op,long> { - static long f(Stack, Matrice_Creuse* const & s,Matrice_Creuse* const &r, MPIrank const & root, fMPI_Op const &op) - { - ffassert( r && s); - MatriceCreuse * sA=s->A; - MatriceCreuse * rA=r->A; - int mpirankw,mpisizew; - MPI_Comm_rank(root.comm, &mpirankw); - MPI_Comm_size(root.comm, &mpisizew); - int who = root.who; - ffassert( sA ); - MatriceMorse * sM = s->pHM(); - MatriceMorse * rM=0; - if( !rA && (mpirankw==who) ) { // build a zero matric copy of sM on proc root - MatriceMorse *rm=new MatriceMorse(*sM); //new MatriceMorse(sM.n,sM.m,sM.nnz,sM.half,0,sM.lg,sM.cl); - *rm=R(); // set the matrix to Zero .. - r->A.master(rm); - rA=r->A; - - } - if(r) - rM = r->pHM(); - - ffassert( sM); - cout << " Op_ReduceMat " << rM << " " << who << " " <nnz : (int) sM->nnz; - // moralement pattern de rM commun - // verif the code of matrix - sM->COO(); // sort - if(rM) rM->COO(); // sort - R * saij=sM->aij; - if(rcode != scode) - { // build array to send .. - if( verbosity> 9) cout <nnz;++k ) - { - - R * prij = rM->pij(sM->i[k],sM->j[k]); - if( prij) *prij = sM->aij[k]; - else err++; - } - if (err) { - cerr << mpirank << " **** MPI_Reduce sparse matrix: warning missing term in pattern "<< err << endl; - } - saij = new R [sM->nnz]; - copy(rM->aij,rM->aij+rM->nnz,saij); - *rM=R(); - } - KN allcode(mpisizew); - if(mpisizew>1) - { - KN code(mpisizew); - MPI_Gather( (void *) & rcode , 1, MPI_UNSIGNED_LONG_LONG, - (void *) &code[0] , 1, MPI_UNSIGNED_LONG_LONG, root.who ,root.comm); - int ok=1; - if(mpirankw==root.who) // verif same patern ... - for(int i=0; innz : (int)sM->nnz; + // moralement pattern de rM commun + // verif the code of matrix + sM->COO( ); // sort + if (rM) rM->COO( ); // sort + R *saij = sM->aij; + if (rcode != scode) { // build array to send .. + if (verbosity > 9) cout << mpirank << " MPI_Reduce sparse matrix not same pattern in send/recv build data to send " << endl; + int err = 0; + *rM = R( ); + for (int k = 0; k < sM->nnz; ++k) { + + R *prij = rM->pij(sM->i[k], sM->j[k]); + if (prij) + *prij = sM->aij[k]; + else + err++; + } + if (err) { + cerr << mpirank << " **** MPI_Reduce sparse matrix: warning missing term in pattern " << err << endl; + } + saij = new R[sM->nnz]; + copy(rM->aij, rM->aij + rM->nnz, saij); + *rM = R( ); + } + KN< uint64_t > allcode(mpisizew); + if (mpisizew > 1) { + KN< uint64_t > code(mpisizew); + MPI_Gather((void *)&rcode, 1, MPI_UNSIGNED_LONG_LONG, (void *)&code[0], 1, MPI_UNSIGNED_LONG_LONG, root.who, root.comm); + int ok = 1; + if (mpirankw == root.who) // verif same patern ... + for (int i = 0; i < mpisizew; ++i) ok = ok && (rcode == code[i]); + if (!ok) { + cerr << " Fatal error MPI_reduce mat: the pattern of the all recv matrix are not the same " << endl; + cerr << " set the recv matrix with same patten" << endl; + for (int i = 0; i < mpisizew; ++i) cout << " proc " << i << " pattern code: " << code[i] << " != " << rcode << endl; + ; + ffassert(0); + } + } + + long ret = MPI_Reduce((void *)saij, (void *)rM->aij, chunk, MPI_TYPE< R >::TYPE( ), op, root.who, root.comm); + if (saij != sM->aij) delete[] saij; + return ret; + } }; -template -struct Op_AllReduceMat : public quad_function*,Matrice_Creuse *,fMPI_Comm,fMPI_Op,long> { - static long f(Stack, Matrice_Creuse* const & s,Matrice_Creuse* const &r, fMPI_Comm const & comm, fMPI_Op const &op) - { - ffassert( r && s); - MatriceCreuse * sA=s->A; - MatriceCreuse * rA=r->A; - ffassert( sA ); - - MatriceMorse * sM = s->pHM(); - if( ! rA ) { // build a zero matric copy of sM - MatriceMorse *rm=new MatriceMorse(*sM); //new MatriceMorse(sM.n,sM.m,sM.nnz,sM.half,0,sM.lg,sM.cl); - *rm=R(); // set the matrix to Zero .. - r->A.master(rm); - rA=r->A; - - } - - MatriceMorse * rM = r->pHM(); - - ffassert( sM && rM); - sM->COO(); // sort - rM->COO(); // sort - int nnz = (int) sM->nnz; - uint64_t rcode = CodeIJ(rM); - uint64_t scode = ( sM != rM) ? CodeIJ(sM) : rcode; - R * saij=sM->aij; - if(rcode != scode) - { // build array to send .. - int err =0; - *rM=R(); - for (int k=0; k< sM->nnz;++k ) - { - - R * prij = rM->pij(sM->i[k],sM->j[k]); - if( prij) *prij = sM->aij[k]; - else err++; - } - nnz = (int) rM->nnz; - saij = new R [nnz]; - nnz = (int) rM->nnz; - if( verbosity> 9) - cout <nnz<< endl; - - copy(rM->aij,rM->aij+rM->nnz,saij); - *rM=R(); - - } - int mpirankw,mpisizew; - MPI_Comm_rank(comm, &mpirankw); - MPI_Comm_size(comm, &mpisizew); - - KN allcode(mpisizew); - if((mpisizew>1) ) - { - int chunk = 1; - KN code(mpisizew); - MPI_Gather( (void *) & rcode , 1, MPI_UNSIGNED_LONG_LONG, - (void *) &code[0] , 1, MPI_UNSIGNED_LONG_LONG, 0 ,comm); - int ok=1; - if(mpirankw==0) - for(int i=1; i99) cout << " MPI_Allreduce mat: revif " << mpirankw << " " << ok << " / " << sM->aij << " -> " << rM->aij << " " << comm <<" " << chunk << endl; - if( !ok) - { - cerr << " Fatal error MPI_Allreduce matrix the pattern of the all recv matrix are not the same "<< endl; - cerr << " set the recv matrix with same patten" <aij, nnz , MPI_TYPE::TYPE(),op,comm); - if( saij != sM->aij) delete [] saij; - return ret; +template< class R > +struct Op_AllReduceMat : public quad_function< Matrice_Creuse< R > *, Matrice_Creuse< R > *, fMPI_Comm, fMPI_Op, long > { + static long f(Stack, Matrice_Creuse< R > *const &s, Matrice_Creuse< R > *const &r, fMPI_Comm const &comm, fMPI_Op const &op) { + ffassert(r && s); + MatriceCreuse< R > *sA = s->A; + MatriceCreuse< R > *rA = r->A; + ffassert(sA); + + MatriceMorse< R > *sM = s->pHM( ); + if (!rA) { // build a zero matric copy of sM + MatriceMorse< R > *rm = new MatriceMorse< R >(*sM); // new MatriceMorse(sM.n,sM.m,sM.nnz,sM.half,0,sM.lg,sM.cl); + *rm = R( ); // set the matrix to Zero .. + r->A.master(rm); + rA = r->A; } -}; + MatriceMorse< R > *rM = r->pHM( ); + + ffassert(sM && rM); + sM->COO( ); // sort + rM->COO( ); // sort + int nnz = (int)sM->nnz; + uint64_t rcode = CodeIJ(rM); + uint64_t scode = (sM != rM) ? CodeIJ(sM) : rcode; + R *saij = sM->aij; + if (rcode != scode) { // build array to send .. + int err = 0; + *rM = R( ); + for (int k = 0; k < sM->nnz; ++k) { + + R *prij = rM->pij(sM->i[k], sM->j[k]); + if (prij) + *prij = sM->aij[k]; + else + err++; + } + nnz = (int)rM->nnz; + saij = new R[nnz]; + nnz = (int)rM->nnz; + if (verbosity > 9) cout << mpirank << " ** Warning: MPI_AllReduce sparse matrix not same pattern in send/recv build data to send, build send: R nnz " << nnz << " S nnz " << sM->nnz << endl; + + copy(rM->aij, rM->aij + rM->nnz, saij); + *rM = R( ); + } + int mpirankw, mpisizew; + MPI_Comm_rank(comm, &mpirankw); + MPI_Comm_size(comm, &mpisizew); + KN< uint64_t > allcode(mpisizew); + if ((mpisizew > 1)) { + int chunk = 1; + KN< uint64_t > code(mpisizew); + MPI_Gather((void *)&rcode, 1, MPI_UNSIGNED_LONG_LONG, (void *)&code[0], 1, MPI_UNSIGNED_LONG_LONG, 0, comm); + int ok = 1; + if (mpirankw == 0) + for (int i = 1; i < mpisizew; ++i) ok |= (rcode == code[i]); + if (verbosity > 99) cout << " MPI_Allreduce mat: revif " << mpirankw << " " << ok << " / " << sM->aij << " -> " << rM->aij << " " << comm << " " << chunk << endl; + if (!ok) { + cerr << " Fatal error MPI_Allreduce matrix the pattern of the all recv matrix are not the same " << endl; + cerr << " set the recv matrix with same patten" << endl; + } + ffassert(ok); + } + long ret = MPI_Allreduce((void *)saij, (void *)rM->aij, nnz, MPI_TYPE< R >::TYPE( ), op, comm); + if (saij != sM->aij) delete[] saij; + return ret; + } +}; -template -struct Op_Reduce : public quad_function,KN_,MPIrank,fMPI_Op,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root, fMPI_Op const &op) - { - CheckContigueKN(r); - CheckContigueKN(s); +template< class R > +struct Op_Reduce : public quad_function< KN_< R >, KN_< R >, MPIrank, fMPI_Op, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, MPIrank const &root, fMPI_Op const &op) { + CheckContigueKN(r); + CheckContigueKN(s); - int chunk = s.N(); - ffassert(chunk==r.N()); + int chunk = s.N( ); + ffassert(chunk == r.N( )); - return MPI_Reduce( (void *) (R*) s,(void *) (R*) r, chunk , MPI_TYPE::TYPE(),op,root.who,root.comm); + return MPI_Reduce((void *)(R *)s, (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), op, root.who, root.comm); } }; -template -struct Op_AllReduce : public quad_function,KN_,fMPI_Comm,fMPI_Op,long> { - static long f(Stack, KN_ const & s, KN_ const &r, fMPI_Comm const & comm,fMPI_Op const &op) - { - CheckContigueKN(r); - CheckContigueKN(s); +template< class R > +struct Op_AllReduce : public quad_function< KN_< R >, KN_< R >, fMPI_Comm, fMPI_Op, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, fMPI_Comm const &comm, fMPI_Op const &op) { + CheckContigueKN(r); + CheckContigueKN(s); - int chunk = s.N(); - ffassert(chunk==r.N()); - return MPI_Allreduce( (void *) (R*) s,(void *) (R*) r, chunk , MPI_TYPE::TYPE(),op,comm); + int chunk = s.N( ); + ffassert(chunk == r.N( )); + return MPI_Allreduce((void *)(R *)s, (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), op, comm); } }; -template -struct Op_AllReduce1 : public quad_function { - static long f(Stack, R * const & s, R * const &r, fMPI_Comm const & comm,fMPI_Op const &op) - { - int chunk = 1; - return MPI_Allreduce( (void *) (R*) s,(void *) (R*) r, 1 , MPI_TYPE::TYPE(),op,comm); - } +template< class R > +struct Op_AllReduce1 : public quad_function< R *, R *, fMPI_Comm, fMPI_Op, long > { + static long f(Stack, R *const &s, R *const &r, fMPI_Comm const &comm, fMPI_Op const &op) { + int chunk = 1; + return MPI_Allreduce((void *)(R *)s, (void *)(R *)r, 1, MPI_TYPE< R >::TYPE( ), op, comm); + } }; -template -struct Op_Reduce1 : public quad_function { - static long f(Stack, R* const & s, R* const &r, MPIrank const & root, fMPI_Op const &op) - { +template< class R > +struct Op_Reduce1 : public quad_function< R *, R *, MPIrank, fMPI_Op, long > { + static long f(Stack, R *const &s, R *const &r, MPIrank const &root, fMPI_Op const &op) { int chunk = 1; - return MPI_Reduce( (void *) (R*) s,(void *) (R*) r, chunk , MPI_TYPE::TYPE(),op,root.who,root.comm); + return MPI_Reduce((void *)(R *)s, (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), op, root.who, root.comm); } }; // Add J. Morice -template -struct Op_Gather1 : public ternary_function,MPIrank,long> { - static long f(Stack, R* const & s, KN_ const &r, MPIrank const & root) - { +template< class R > +struct Op_Gather1 : public ternary_function< R *, KN_< R >, MPIrank, long > { + static long f(Stack, R *const &s, KN_< R > const &r, MPIrank const &root) { - int mpisizew,myrank; + int mpisizew, myrank; MPI_Comm_size(root.comm, &mpisizew); - MPI_Comm_rank( root.comm, &myrank) ; + MPI_Comm_rank(root.comm, &myrank); int chunk = 1; - return MPI_Gather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Gather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), root.who, root.comm); } }; // Fin Add J. Morice +template< class R > +struct Op_Gather3 : public ternary_function< KN_< R >, KN_< R >, MPIrank, long > { + static long f(Stack, KN_< R > const &s, KN_< R > const &r, MPIrank const &root) { + CheckContigueKN(r); + CheckContigueKN(s); + int mpisizew, myrank; + MPI_Comm_size(root.comm, &mpisizew); + MPI_Comm_rank(root.comm, &myrank); -template -struct Op_Gather3 : public ternary_function,KN_,MPIrank,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root) - { - CheckContigueKN(r); - CheckContigueKN(s); - int mpisizew,myrank; - MPI_Comm_size(root.comm, &mpisizew); - MPI_Comm_rank(root.comm, &myrank) ; - - int chunk = s.N(); + int chunk = s.N( ); - return MPI_Gather( (void *) (R*) s, chunk, MPI_TYPE::TYPE(), - (void *) (R*) r, chunk, MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Gather((void *)(R *)s, chunk, MPI_TYPE< R >::TYPE( ), (void *)(R *)r, chunk, MPI_TYPE< R >::TYPE( ), root.who, root.comm); } }; // Add by J. Morice -template -long Op_Gatherv3(KN_ const & s, KN_ const &r, MPIrank const & root, KN_ const & recvcount, KN_ const & displs) -{ +template< class R > +long Op_Gatherv3(KN_< R > const &s, KN_< R > const &r, MPIrank const &root, KN_< long > const &recvcount, KN_< long > const &displs) { - CheckContigueKN(r); - CheckContigueKN(s); + CheckContigueKN(r); + CheckContigueKN(s); int mpirankw; MPI_Comm_rank(root.comm, &mpirankw); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); - KN INTrecvcount(mpirankw == root.who ? recvcount.N() : 0); - KN INTdispls(mpirankw == root.who ? recvcount.N() : 0); - for(int ii=0; ii< INTrecvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; + KN< int > INTrecvcount(mpirankw == root.who ? recvcount.N( ) : 0); + KN< int > INTdispls(mpirankw == root.who ? recvcount.N( ) : 0); + for (int ii = 0; ii < INTrecvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Gatherv( (void *) (R*) s, s.N(), MPI_TYPE::TYPE(), - (void *) (R*) r, INTrecvcount, INTdispls,MPI_TYPE::TYPE(),root.who,root.comm); + return MPI_Gatherv((void *)(R *)s, s.N( ), MPI_TYPE< R >::TYPE( ), (void *)(R *)r, INTrecvcount, INTdispls, MPI_TYPE< R >::TYPE( ), root.who, root.comm); } // Fin Add J. Morice - // Add J. Morice communications entre processeurs complex template<> -struct Op_All2All { - using first_argument_type = KN_; - using second_argument_type = KN_; - using result_type = long; - static long f( KN_ const & s, KN_ const &r) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_All2All< Complex > { + using first_argument_type = KN_< Complex >; + using second_argument_type = KN_< Complex >; + using result_type = long; + static long f(KN_< Complex > const &s, KN_< Complex > const &r) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=MPI_COMM_WORLD; + MPI_Comm comm = MPI_COMM_WORLD; int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = s.N()/mpisizew; - ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); + int chunk = s.N( ) / mpisizew; + ffassert(s.N( ) == mpisizew * chunk && r.N( ) == s.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Alltoall( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Alltoall((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Alltoall( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Alltoall(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, comm); #endif } }; template<> -struct Op_Allgather1 { - using first_argument_type = Complex*; - using second_argument_type = KN_; - using result_type = long; - static long f( Complex * const & s, KN_ const &r) - { - CheckContigueKN(r); - +struct Op_Allgather1< Complex > { + using first_argument_type = Complex *; + using second_argument_type = KN_< Complex >; + using result_type = long; + static long f(Complex *const &s, KN_< Complex > const &r) { + CheckContigueKN(r); - MPI_Comm comm=MPI_COMM_WORLD; + MPI_Comm comm = MPI_COMM_WORLD; int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ int chunk = 1; - ffassert( r.N()== mpisizew); + ffassert(r.N( ) == mpisizew); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Allgather( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Allgather( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Allgather(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, comm); #endif } }; - template<> -struct Op_Allgather { - using first_argument_type = KN_; - using second_argument_type = KN_; - using result_type = long; - static long f( KN_ const & s, KN_ const &r) - { - CheckContigueKN(r); - CheckContigueKN(s); - - MPI_Comm comm=MPI_COMM_WORLD; - int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = r.N()/mpisizew; - ffassert( r.N()==chunk*mpisizew && chunk==s.N() ); +struct Op_Allgather< Complex > { + using first_argument_type = KN_< Complex >; + using second_argument_type = KN_< Complex >; + using result_type = long; + static long f(KN_< Complex > const &s, KN_< Complex > const &r) { + CheckContigueKN(r); + CheckContigueKN(s); + + MPI_Comm comm = MPI_COMM_WORLD; + int mpisizew; + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = r.N( ) / mpisizew; + ffassert(r.N( ) == chunk * mpisizew && chunk == s.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Allgather( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Allgather( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Allgather(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, comm); #endif - } + } }; template<> -struct Op_All2All3 : public ternary_function,KN_,fMPI_Comm,long> { - static long f(Stack, KN_ const & s, KN_ const &r,fMPI_Comm const & cmm ) - { - CheckContigueKN(r); - CheckContigueKN(s); - - MPI_Comm comm=cmm; - int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = s.N()/mpisizew; - ffassert(s.N()==mpisizew*chunk && r.N()==s.N()); +struct Op_All2All3< Complex > : public ternary_function< KN_< Complex >, KN_< Complex >, fMPI_Comm, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, fMPI_Comm const &cmm) { + CheckContigueKN(r); + CheckContigueKN(s); + + MPI_Comm comm = cmm; + int mpisizew; + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = s.N( ) / mpisizew; + ffassert(s.N( ) == mpisizew * chunk && r.N( ) == s.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Alltoall( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Alltoall((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Alltoall( (void *) (Complex*) s, chunk, MPI_DOUBLE, - (void *) (Complex*) (r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Alltoall((void *)(Complex *)s, chunk, MPI_DOUBLE, (void *)(Complex *)(r), chunk, MPI_DOUBLE, comm); #endif - } + } }; template<> -struct Op_Allgather3 : public ternary_function,KN_,fMPI_Comm,long> { - static long f(Stack, KN_ const & s, KN_ const &r,fMPI_Comm const & cmm) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_Allgather3< Complex > : public ternary_function< KN_< Complex >, KN_< Complex >, fMPI_Comm, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, fMPI_Comm const &cmm) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; - MPI_Comm_size(comm, &mpisizew); /* local */ - int chunk = r.N()/mpisizew; // bug corrected by J. Morice - ffassert(s.N()==chunk && r.N()==s.N()*mpisizew); + MPI_Comm_size(comm, &mpisizew); /* local */ + int chunk = r.N( ) / mpisizew; // bug corrected by J. Morice + ffassert(s.N( ) == chunk && r.N( ) == s.N( ) * mpisizew); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Allgather( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Allgather( (void *) (Complex*) (s), chunk, MPI_DOUBLE, - (void *) (Complex*) (r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Allgather((void *)(Complex *)(s), chunk, MPI_DOUBLE, (void *)(Complex *)(r), chunk, MPI_DOUBLE, comm); #endif } }; template<> -struct Op_Allgather13 : public ternary_function,fMPI_Comm,long> { - static long f(Stack, Complex * const & s, KN_ const &r,fMPI_Comm const & cmm) - { - CheckContigueKN(r); - +struct Op_Allgather13< Complex > : public ternary_function< Complex *, KN_< Complex >, fMPI_Comm, long > { + static long f(Stack, Complex *const &s, KN_< Complex > const &r, fMPI_Comm const &cmm) { + CheckContigueKN(r); - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ int chunk = 1; - ffassert( r.N()==mpisizew); + ffassert(r.N( ) == mpisizew); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Allgather( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, comm); #else - chunk*=2; - return MPI_Allgather((void *) (Complex*)(s), chunk, MPI_DOUBLE, - (void *) (Complex*) (r), chunk, MPI_DOUBLE, comm); + chunk *= 2; + return MPI_Allgather((void *)(Complex *)(s), chunk, MPI_DOUBLE, (void *)(Complex *)(r), chunk, MPI_DOUBLE, comm); #endif } }; - template<> -long Op_All2Allv( KN_ const & s, KN_ const &r, KN_ const &sendcnts, KN_ const &sdispls, KN_ const &recvcnts, KN_ const &rdispls) -{ - CheckContigueKN(r); - CheckContigueKN(s); +long Op_All2Allv< Complex >(KN_< Complex > const &s, KN_< Complex > const &r, KN_< long > const &sendcnts, KN_< long > const &sdispls, KN_< long > const &recvcnts, KN_< long > const &rdispls) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=MPI_COMM_WORLD; - int mpirankv=MPI_UNDEFINED; + MPI_Comm comm = MPI_COMM_WORLD; + int mpirankv = MPI_UNDEFINED; MPI_Comm_rank(comm, &mpirankv); int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - ffassert( sendcnts.N() == sdispls.N() && sendcnts.N() == recvcnts.N() && sendcnts.N() == rdispls.N() && sendcnts.N() == mpisizew ); - - KN INTsendcnts(sendcnts.N()); - KN INTsdispls(sdispls.N()); - KN INTrecvcnts(recvcnts.N()); - KN INTrdispls(rdispls.N()); + ffassert(sendcnts.N( ) == sdispls.N( ) && sendcnts.N( ) == recvcnts.N( ) && sendcnts.N( ) == rdispls.N( ) && sendcnts.N( ) == mpisizew); + KN< int > INTsendcnts(sendcnts.N( )); + KN< int > INTsdispls(sdispls.N( )); + KN< int > INTrecvcnts(recvcnts.N( )); + KN< int > INTrdispls(rdispls.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< sendcnts.N(); ii++){ + for (int ii = 0; ii < sendcnts.N( ); ii++) { INTsendcnts[ii] = sendcnts[ii]; - INTsdispls[ii] = sdispls[ii]; - INTrecvcnts[ii] = recvcnts[ii]; - INTrdispls[ii] = rdispls[ii]; + INTsdispls[ii] = sdispls[ii]; + INTrecvcnts[ii] = recvcnts[ii]; + INTrdispls[ii] = rdispls[ii]; } - return MPI_Alltoallv( (void *) (Complex*) s, INTsendcnts, INTsdispls, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, INTrecvcnts, INTrdispls, MPI_DOUBLE_COMPLEX, comm); + return MPI_Alltoallv((void *)(Complex *)s, INTsendcnts, INTsdispls, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, INTrecvcnts, INTrdispls, MPI_DOUBLE_COMPLEX, comm); #else - for(int ii=0; ii< sendcnts.N(); ii++){ - INTsendcnts[ii] = 2*sendcnts[ii]; - INTsdispls[ii] = 2*sdispls[ii]; - INTrecvcnts[ii] = 2*recvcnts[ii]; - INTrdispls[ii] = 2*rdispls[ii]; - } - return MPI_Alltoallv( reinterpret_cast ( (Complex*) s), INTsendcnts, INTsdispls, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), INTrecvcnts, INTrdispls, MPI_DOUBLE, comm); + for (int ii = 0; ii < sendcnts.N( ); ii++) { + INTsendcnts[ii] = 2 * sendcnts[ii]; + INTsdispls[ii] = 2 * sdispls[ii]; + INTrecvcnts[ii] = 2 * recvcnts[ii]; + INTrdispls[ii] = 2 * rdispls[ii]; + } + return MPI_Alltoallv(reinterpret_cast< void * >((Complex *)s), INTsendcnts, INTsdispls, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), INTrecvcnts, INTrdispls, MPI_DOUBLE, comm); #endif } - - template<> -struct Op_Allgatherv : public quad_function,KN_,KN_,KN_,long> { - static long f( Stack ,KN_ const & s, KN_ const &r, KN_ const & recvcount, KN_ const & displs) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_Allgatherv< Complex > : public quad_function< KN_< Complex >, KN_< Complex >, KN_< long >, KN_< long >, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, KN_< long > const &recvcount, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=MPI_COMM_WORLD; + MPI_Comm comm = MPI_COMM_WORLD; int mpisizew; MPI_Comm_size(comm, &mpisizew); - ffassert( recvcount.N() == displs.N() && recvcount.N() == mpisizew); - long sum=0; - for(int ii=0; ii< recvcount.N(); ii++) - sum+=recvcount[ii]; - ffassert( sum == r.N() ); - + ffassert(recvcount.N( ) == displs.N( ) && recvcount.N( ) == mpisizew); + long sum = 0; + for (int ii = 0; ii < recvcount.N( ); ii++) sum += recvcount[ii]; + ffassert(sum == r.N( )); - KN INTrecvcount(recvcount.N()); - KN INTdispls(displs.N()); + KN< int > INTrecvcount(recvcount.N( )); + KN< int > INTdispls(displs.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Allgatherv( (void *) (Complex*)s, s.N(), MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, INTrecvcount, INTdispls,MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgatherv((void *)(Complex *)s, s.N( ), MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, INTrecvcount, INTdispls, MPI_DOUBLE_COMPLEX, comm); #else - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= 2*recvcount[ii]; - INTdispls[ii]= 2*displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = 2 * recvcount[ii]; + INTdispls[ii] = 2 * displs[ii]; } - return MPI_Allgatherv( reinterpret_cast ( (Complex*) s), 2*s.N(), MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), INTrecvcount, INTdispls,MPI_DOUBLE, comm); + return MPI_Allgatherv(reinterpret_cast< void * >((Complex *)s), 2 * s.N( ), MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), INTrecvcount, INTdispls, MPI_DOUBLE, comm); #endif } }; template<> -long Op_All2All3v(KN_ const & s, KN_ const &r,fMPI_Comm const & cmm, KN_ const &sendcnts, KN_ const &sdispls, KN_ const &recvcnts, KN_ const &rdispls ) -{ - CheckContigueKN(r); - CheckContigueKN(s); +long Op_All2All3v< Complex >(KN_< Complex > const &s, KN_< Complex > const &r, fMPI_Comm const &cmm, KN_< long > const &sendcnts, KN_< long > const &sdispls, KN_< long > const &recvcnts, + KN_< long > const &rdispls) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=cmm; - int mpirankv=MPI_UNDEFINED; + MPI_Comm comm = cmm; + int mpirankv = MPI_UNDEFINED; MPI_Comm_rank(comm, &mpirankv); int mpisizew; MPI_Comm_size(comm, &mpisizew); /* local */ - ffassert( sendcnts.N() == sdispls.N() && sendcnts.N() == recvcnts.N() && sendcnts.N() == rdispls.N() && sendcnts.N() == mpisizew ); + ffassert(sendcnts.N( ) == sdispls.N( ) && sendcnts.N( ) == recvcnts.N( ) && sendcnts.N( ) == rdispls.N( ) && sendcnts.N( ) == mpisizew); - //ffassert(s.N()==sendcnts[mpirankv] && r.N()==recvbuf[mpirankv]); + // ffassert(s.N()==sendcnts[mpirankv] && r.N()==recvbuf[mpirankv]); - KN INTsendcnts(sendcnts.N()); - KN INTsdispls(sdispls.N()); - KN INTrecvcnts(recvcnts.N()); - KN INTrdispls(rdispls.N()); + KN< int > INTsendcnts(sendcnts.N( )); + KN< int > INTsdispls(sdispls.N( )); + KN< int > INTrecvcnts(recvcnts.N( )); + KN< int > INTrdispls(rdispls.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< sendcnts.N(); ii++){ + for (int ii = 0; ii < sendcnts.N( ); ii++) { INTsendcnts[ii] = sendcnts[ii]; - INTsdispls[ii] = sdispls[ii]; - INTrecvcnts[ii] = recvcnts[ii]; - INTrdispls[ii] = rdispls[ii]; + INTsdispls[ii] = sdispls[ii]; + INTrecvcnts[ii] = recvcnts[ii]; + INTrdispls[ii] = rdispls[ii]; } - return MPI_Alltoallv( (void *) (Complex*)s, INTsendcnts, INTsdispls, MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, INTrecvcnts, INTrdispls, MPI_DOUBLE_COMPLEX, comm); + return MPI_Alltoallv((void *)(Complex *)s, INTsendcnts, INTsdispls, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, INTrecvcnts, INTrdispls, MPI_DOUBLE_COMPLEX, comm); #else - for(int ii=0; ii< sendcnts.N(); ii++){ - INTsendcnts[ii] = 2*sendcnts[ii]; - INTsdispls[ii] = 2*sdispls[ii]; - INTrecvcnts[ii] = 2*recvcnts[ii]; - INTrdispls[ii] = 2*rdispls[ii]; + for (int ii = 0; ii < sendcnts.N( ); ii++) { + INTsendcnts[ii] = 2 * sendcnts[ii]; + INTsdispls[ii] = 2 * sdispls[ii]; + INTrecvcnts[ii] = 2 * recvcnts[ii]; + INTrdispls[ii] = 2 * rdispls[ii]; } - return MPI_Alltoallv( reinterpret_cast ( (Complex*) s), INTsendcnts, INTsdispls, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), INTrecvcnts, INTrdispls, MPI_DOUBLE, comm); + return MPI_Alltoallv(reinterpret_cast< void * >((Complex *)s), INTsendcnts, INTsdispls, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), INTrecvcnts, INTrdispls, MPI_DOUBLE, comm); #endif } - template<> -long Op_Allgatherv3(KN_ const & s, KN_ const &r,fMPI_Comm const & cmm, KN_ const & recvcount, KN_ const & displs) -{ - CheckContigueKN(r); - CheckContigueKN(s); +long Op_Allgatherv3< Complex >(KN_< Complex > const &s, KN_< Complex > const &r, fMPI_Comm const &cmm, KN_< long > const &recvcount, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); - MPI_Comm comm=cmm; + MPI_Comm comm = cmm; int mpisizew; MPI_Comm_size(comm, &mpisizew); - ffassert( recvcount.N() == displs.N() && recvcount.N() == mpisizew); - long sum=0; - for(int ii=0; ii< recvcount.N(); ii++) - sum+=recvcount[ii]; - ffassert( sum == r.N() ); - KN INTrecvcount(recvcount.N()); - KN INTdispls(displs.N()); + ffassert(recvcount.N( ) == displs.N( ) && recvcount.N( ) == mpisizew); + long sum = 0; + for (int ii = 0; ii < recvcount.N( ); ii++) sum += recvcount[ii]; + ffassert(sum == r.N( )); + KN< int > INTrecvcount(recvcount.N( )); + KN< int > INTdispls(displs.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Allgatherv( (void *) (Complex*)s, s.N(), MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, INTrecvcount, INTdispls,MPI_DOUBLE_COMPLEX, comm); + return MPI_Allgatherv((void *)(Complex *)s, s.N( ), MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, INTrecvcount, INTdispls, MPI_DOUBLE_COMPLEX, comm); #else - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= 2*recvcount[ii]; - INTdispls[ii]= 2*displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = 2 * recvcount[ii]; + INTdispls[ii] = 2 * displs[ii]; } - return MPI_Allgatherv( reinterpret_cast ( (Complex*) s), 2*s.N(), MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), INTrecvcount, INTdispls,MPI_DOUBLE, comm); + return MPI_Allgatherv(reinterpret_cast< void * >((Complex *)s), 2 * s.N( ), MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), INTrecvcount, INTdispls, MPI_DOUBLE, comm); #endif - } template<> -struct Op_Scatter1 : public ternary_function,Complex *,MPIrank,long> { - static long f(Stack, KN_ const & s, Complex * const &r, MPIrank const & root) - { +struct Op_Scatter1< Complex > : public ternary_function< KN_< Complex >, Complex *, MPIrank, long > { + static long f(Stack, KN_< Complex > const &s, Complex *const &r, MPIrank const &root) { - CheckContigueKN(s); + CheckContigueKN(s); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); int chunk = 1; #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Scatter( (void *) (Complex*)s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, chunk, MPI_DOUBLE_COMPLEX,root.who,root.comm); + return MPI_Scatter((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, root.who, root.comm); #else - chunk*=2; - return MPI_Scatter( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE,root.who,root.comm); + chunk *= 2; + return MPI_Scatter(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, root.who, root.comm); #endif } }; - template<> -struct Op_Scatter3 : public ternary_function,KN_,MPIrank,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_Scatter3< Complex > : public ternary_function< KN_< Complex >, KN_< Complex >, MPIrank, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, MPIrank const &root) { + CheckContigueKN(r); + CheckContigueKN(s); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); - int chunk = r.N();// correct 2012 FH + int chunk = r.N( ); // correct 2012 FH #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Scatter( (void *) (Complex*)s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, chunk, MPI_DOUBLE_COMPLEX,root.who,root.comm); + return MPI_Scatter((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, root.who, root.comm); #else - chunk*=2; - return MPI_Scatter( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE,root.who,root.comm); + chunk *= 2; + return MPI_Scatter(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, root.who, root.comm); #endif } }; template<> -long Op_Scatterv3( KN_ const & s, KN_ const &r, MPIrank const & root, KN_ const &sendcnts, KN_ const &displs) -{ +long Op_Scatterv3< Complex >(KN_< Complex > const &s, KN_< Complex > const &r, MPIrank const &root, KN_< long > const &sendcnts, KN_< long > const &displs) { - CheckContigueKN(r); - CheckContigueKN(s); + CheckContigueKN(r); + CheckContigueKN(s); - int mpirankv=MPI_UNDEFINED; - if(root.comm != MPI_COMM_NULL) - MPI_Comm_rank(root.comm, &mpirankv); + int mpirankv = MPI_UNDEFINED; + if (root.comm != MPI_COMM_NULL) MPI_Comm_rank(root.comm, &mpirankv); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); /* local */ - long sumsize=0; - for(int ii=0; ii INTsendcnts(sendcnts.N()); - KN INTdispls(displs.N()); + KN< int > INTsendcnts(sendcnts.N( )); + KN< int > INTdispls(displs.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< sendcnts.N(); ii++){ - INTsendcnts[ii]= sendcnts[ii]; - INTdispls[ii]= displs[ii]; + for (int ii = 0; ii < sendcnts.N( ); ii++) { + INTsendcnts[ii] = sendcnts[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Scatterv( (void *) (Complex*)s, INTsendcnts, INTdispls, MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, r.N(), MPI_DOUBLE_COMPLEX,root.who,root.comm); + return MPI_Scatterv((void *)(Complex *)s, INTsendcnts, INTdispls, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, r.N( ), MPI_DOUBLE_COMPLEX, root.who, root.comm); #else - for(int ii=0; ii< sendcnts.N(); ii++){ - INTsendcnts[ii]= 2*sendcnts[ii]; - INTdispls[ii]= 2*displs[ii]; + for (int ii = 0; ii < sendcnts.N( ); ii++) { + INTsendcnts[ii] = 2 * sendcnts[ii]; + INTdispls[ii] = 2 * displs[ii]; } - return MPI_Scatterv( reinterpret_cast ( (Complex*) s), INTsendcnts, INTdispls, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), 2*r.N(), MPI_DOUBLE,root.who,root.comm); + return MPI_Scatterv(reinterpret_cast< void * >((Complex *)s), INTsendcnts, INTdispls, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), 2 * r.N( ), MPI_DOUBLE, root.who, root.comm); #endif - } - template<> -struct Op_Reduce : public quad_function,KN_,MPIrank,fMPI_Op,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root, fMPI_Op const &op) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_Reduce< Complex > : public quad_function< KN_< Complex >, KN_< Complex >, MPIrank, fMPI_Op, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, MPIrank const &root, fMPI_Op const &op) { + CheckContigueKN(r); + CheckContigueKN(s); - int chunk = s.N(); - ffassert(chunk==r.N()); + int chunk = s.N( ); + ffassert(chunk == r.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Reduce( (void *) (Complex*)s,(void *) (Complex*)r, chunk , MPI_DOUBLE_COMPLEX,op,root.who,root.comm); + return MPI_Reduce((void *)(Complex *)s, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, op, root.who, root.comm); #else - chunk*=2; - return MPI_Reduce( reinterpret_cast ( (Complex*) s), reinterpret_cast ( (Complex*) r), chunk , MPI_DOUBLE,op,root.who,root.comm); + chunk *= 2; + return MPI_Reduce(reinterpret_cast< void * >((Complex *)s), reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, op, root.who, root.comm); #endif } }; template<> -struct Op_AllReduce : public quad_function,KN_,fMPI_Comm,fMPI_Op,long> { - static long f(Stack, KN_ const & s, KN_ const &r, fMPI_Comm const & comm,fMPI_Op const &op) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_AllReduce< Complex > : public quad_function< KN_< Complex >, KN_< Complex >, fMPI_Comm, fMPI_Op, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, fMPI_Comm const &comm, fMPI_Op const &op) { + CheckContigueKN(r); + CheckContigueKN(s); - int chunk = s.N(); - ffassert(chunk==r.N()); + int chunk = s.N( ); + ffassert(chunk == r.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Allreduce( (void *) (Complex*)s,(void *) (Complex*)r, chunk , MPI_DOUBLE_COMPLEX,op,comm); + return MPI_Allreduce((void *)(Complex *)s, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, op, comm); #else - chunk *=2; - return MPI_Allreduce( reinterpret_cast ( (Complex*) s), reinterpret_cast ( (Complex*) r), chunk , MPI_DOUBLE,op,comm); + chunk *= 2; + return MPI_Allreduce(reinterpret_cast< void * >((Complex *)s), reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, op, comm); #endif } }; template<> -struct Op_Reduce1 : public quad_function { - static long f(Stack, Complex* const & s, Complex* const &r, MPIrank const & root, fMPI_Op const &op) - { +struct Op_Reduce1< Complex > : public quad_function< Complex *, Complex *, MPIrank, fMPI_Op, long > { + static long f(Stack, Complex *const &s, Complex *const &r, MPIrank const &root, fMPI_Op const &op) { #ifdef HAVE_MPI_DOUBLE_COMPLEX int chunk = 1; - return MPI_Reduce( (void *) s, (void *) r, chunk , MPI_DOUBLE_COMPLEX,op,root.who,root.comm); + return MPI_Reduce((void *)s, (void *)r, chunk, MPI_DOUBLE_COMPLEX, op, root.who, root.comm); #else int chunk = 2; - return MPI_Reduce( reinterpret_cast ( (Complex*) s), reinterpret_cast ( (Complex*) r), chunk , MPI_DOUBLE,op,root.who,root.comm); + return MPI_Reduce(reinterpret_cast< void * >((Complex *)s), reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, op, root.who, root.comm); #endif } }; // Add J. Morice template<> -struct Op_Gather1 : public ternary_function,MPIrank,long> { - static long f(Stack, Complex * const & s, KN_ const &r, MPIrank const & root) - { - - CheckContigueKN(r); +struct Op_Gather1< Complex > : public ternary_function< Complex *, KN_< Complex >, MPIrank, long > { + static long f(Stack, Complex *const &s, KN_< Complex > const &r, MPIrank const &root) { + CheckContigueKN(r); - int mpisizew,myrank; - MPI_Comm_size(root.comm, &mpisizew); - MPI_Comm_rank( root.comm, &myrank) ; + int mpisizew, myrank; + MPI_Comm_size(root.comm, &mpisizew); + MPI_Comm_rank(root.comm, &myrank); int chunk = 1; #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Gather( (void *) (Complex*) s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*) r, chunk, MPI_DOUBLE_COMPLEX, root.who, root.comm); + return MPI_Gather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, root.who, root.comm); #else chunk = 2; - return MPI_Gather( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE, root.who, root.comm); + return MPI_Gather(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, root.who, root.comm); #endif } }; // Fin Add J. Morice - template<> -struct Op_Gather3 : public ternary_function,KN_,MPIrank,long> { - static long f(Stack, KN_ const & s, KN_ const &r, MPIrank const & root) - { - CheckContigueKN(r); - CheckContigueKN(s); +struct Op_Gather3< Complex > : public ternary_function< KN_< Complex >, KN_< Complex >, MPIrank, long > { + static long f(Stack, KN_< Complex > const &s, KN_< Complex > const &r, MPIrank const &root) { + CheckContigueKN(r); + CheckContigueKN(s); - int mpisizew,myrank; - MPI_Comm_size(root.comm, &mpisizew); - MPI_Comm_rank( root.comm, &myrank) ; + int mpisizew, myrank; + MPI_Comm_size(root.comm, &mpisizew); + MPI_Comm_rank(root.comm, &myrank); - int chunk = s.N(); + int chunk = s.N( ); #ifdef HAVE_MPI_DOUBLE_COMPLEX - return MPI_Gather( (void *) (Complex*)s, chunk, MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, chunk, MPI_DOUBLE_COMPLEX,root.who,root.comm); + return MPI_Gather((void *)(Complex *)s, chunk, MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, chunk, MPI_DOUBLE_COMPLEX, root.who, root.comm); #else chunk *= 2; - return MPI_Gather( reinterpret_cast ( (Complex*) s), chunk, MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), chunk, MPI_DOUBLE,root.who,root.comm); + return MPI_Gather(reinterpret_cast< void * >((Complex *)s), chunk, MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), chunk, MPI_DOUBLE, root.who, root.comm); #endif } }; - template<> -long Op_Gatherv3(KN_ const & s, KN_ const &r, MPIrank const & root, KN_ const & recvcount, KN_ const & displs) -{ - CheckContigueKN(r); - CheckContigueKN(s); +long Op_Gatherv3< Complex >(KN_< Complex > const &s, KN_< Complex > const &r, MPIrank const &root, KN_< long > const &recvcount, KN_< long > const &displs) { + CheckContigueKN(r); + CheckContigueKN(s); int mpirankw; MPI_Comm_rank(root.comm, &mpirankw); int mpisizew; MPI_Comm_size(root.comm, &mpisizew); - if( mpirankw == root.who){ - long sum=0; - for(int ii=0; ii< recvcount.N(); ii++) - sum+=recvcount[ii]; - ffassert( sum == r.N() ); + if (mpirankw == root.who) { + long sum = 0; + for (int ii = 0; ii < recvcount.N( ); ii++) sum += recvcount[ii]; + ffassert(sum == r.N( )); } - KN INTrecvcount(recvcount.N()); - KN INTdispls(displs.N()); + KN< int > INTrecvcount(recvcount.N( )); + KN< int > INTdispls(displs.N( )); #ifdef HAVE_MPI_DOUBLE_COMPLEX - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= recvcount[ii]; - INTdispls[ii]= displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = recvcount[ii]; + INTdispls[ii] = displs[ii]; } - return MPI_Gatherv( (void *) (Complex*)s, s.N(), MPI_DOUBLE_COMPLEX, - (void *) (Complex*)r, INTrecvcount, INTdispls,MPI_DOUBLE_COMPLEX,root.who,root.comm); + return MPI_Gatherv((void *)(Complex *)s, s.N( ), MPI_DOUBLE_COMPLEX, (void *)(Complex *)r, INTrecvcount, INTdispls, MPI_DOUBLE_COMPLEX, root.who, root.comm); #else - for(int ii=0; ii< recvcount.N(); ii++){ - INTrecvcount[ii]= 2*recvcount[ii]; - INTdispls[ii]= 2*displs[ii]; + for (int ii = 0; ii < recvcount.N( ); ii++) { + INTrecvcount[ii] = 2 * recvcount[ii]; + INTdispls[ii] = 2 * displs[ii]; } - return MPI_Gatherv( reinterpret_cast ( (Complex*) s), 2*s.N(), MPI_DOUBLE, - reinterpret_cast ( (Complex*) r), INTrecvcount, INTdispls,MPI_DOUBLE,root.who,root.comm); + return MPI_Gatherv(reinterpret_cast< void * >((Complex *)s), 2 * s.N( ), MPI_DOUBLE, reinterpret_cast< void * >((Complex *)r), INTrecvcount, INTdispls, MPI_DOUBLE, root.who, root.comm); #endif } // Fin Add J. Morice communication entre complexe -MPIrank mpiwho(long i) { return MPIrank(i);} -MPIrank mpiwho(long i,fMPI_Comm comm) { return MPIrank(i,comm,Syncro_block);} -MPIrank mpiwho(fMPI_Comm comm,long i) { return MPIrank(i,comm,Syncro_block);} -MPIrank mpiwhob(long i) { return MPIrank(i);} -MPIrank mpiwhob(long i,fMPI_Comm comm) { return MPIrank(i,comm,Syncro_block);} - -MPIrank mpiwho_(const long &i,const fMPI_Comm &comm,fMPI_Request * const &rq) { return MPIrank(i,comm,*rq);} -MPIrank mpiwho_(const long &i,fMPI_Request * const &rq) { return MPIrank(i, MPI_COMM_WORLD ,*rq);} +MPIrank mpiwho(long i) { return MPIrank(i); } +MPIrank mpiwho(long i, fMPI_Comm comm) { return MPIrank(i, comm, Syncro_block); } +MPIrank mpiwho(fMPI_Comm comm, long i) { return MPIrank(i, comm, Syncro_block); } +MPIrank mpiwhob(long i) { return MPIrank(i); } +MPIrank mpiwhob(long i, fMPI_Comm comm) { return MPIrank(i, comm, Syncro_block); } -long mpiWait(fMPI_Request * frq) { - MPI_Request * rq= *frq; - MPI_Status status; - long res=MPI_SUCCESS; - while(rq && *rq!=MPI_REQUEST_NULL) - { - res = MPI_Wait(rq,&status); - DoOnWaitMPIRequest(rq); - } - return res; +MPIrank mpiwho_(const long &i, const fMPI_Comm &comm, fMPI_Request *const &rq) { return MPIrank(i, comm, *rq); } +MPIrank mpiwho_(const long &i, fMPI_Request *const &rq) { return MPIrank(i, MPI_COMM_WORLD, *rq); } +long mpiWait(fMPI_Request *frq) { + MPI_Request *rq = *frq; + MPI_Status status; + long res = MPI_SUCCESS; + while (rq && *rq != MPI_REQUEST_NULL) { + res = MPI_Wait(rq, &status); + DoOnWaitMPIRequest(rq); + } + return res; } -long mpiBarrier(fMPI_Comm * comm) -{ - return MPI_Barrier(*comm); -} +long mpiBarrier(fMPI_Comm *comm) { return MPI_Barrier(*comm); } -long mpiWaitAny(KN* rq) -{ +long mpiWaitAny(KN< MPI_Request > *rq) { MPI_Status status; int index; do { - MPI_Waitany(rq->N(),*rq,&index,&status); - if(index != MPI_UNDEFINED) - DoOnWaitMPIRequest(&(*rq)[index]); - } while (MPI_UNDEFINED != index && (*rq)[index] != MPI_REQUEST_NULL); + MPI_Waitany(rq->N( ), *rq, &index, &status); + if (index != MPI_UNDEFINED) DoOnWaitMPIRequest(&(*rq)[index]); + } while (MPI_UNDEFINED != index && (*rq)[index] != MPI_REQUEST_NULL); return index; } -long mpiWaitAll(KN* rq) -{ - MPI_Status* statuses = new MPI_Status[rq->N()](); - MPI_Waitall(rq->N(),*rq,statuses); - for(int i = 0; i < rq->N(); ++i) { - if(statuses[i].MPI_TAG != MPI_ANY_TAG && statuses[i].MPI_SOURCE != MPI_ANY_SOURCE) - DoOnWaitMPIRequest(&(*rq)[i]); +long mpiWaitAll(KN< MPI_Request > *rq) { + MPI_Status *statuses = new MPI_Status[rq->N( )]( ); + MPI_Waitall(rq->N( ), *rq, statuses); + for (int i = 0; i < rq->N( ); ++i) { + if (statuses[i].MPI_TAG != MPI_ANY_TAG && statuses[i].MPI_SOURCE != MPI_ANY_SOURCE) DoOnWaitMPIRequest(&(*rq)[i]); } - MPI_Waitall(rq->N(),*rq,statuses); - for(int i = 0; i < rq->N(); ++i) { - if(statuses[i].MPI_TAG != MPI_ANY_TAG && statuses[i].MPI_SOURCE != MPI_ANY_SOURCE) - DoOnWaitMPIRequest(&(*rq)[i]); + MPI_Waitall(rq->N( ), *rq, statuses); + for (int i = 0; i < rq->N( ); ++i) { + if (statuses[i].MPI_TAG != MPI_ANY_TAG && statuses[i].MPI_SOURCE != MPI_ANY_SOURCE) DoOnWaitMPIRequest(&(*rq)[i]); } - delete [] statuses; + delete[] statuses; return 0L; } -MPIrank * set_copympi( MPIrank* const & a,const MPIrank & b){ *a=b;return a;} - +MPIrank *set_copympi(MPIrank *const &a, const MPIrank &b) { + *a = b; + return a; +} -long mpiSize(fMPI_Comm cmm) { - int s=0; - if(cmm != (MPI_Comm) MPI_COMM_NULL) - MPI_Comm_size(cmm, &s); /* local */ - return s; +long mpiSize(fMPI_Comm cmm) { + int s = 0; + if (cmm != (MPI_Comm)MPI_COMM_NULL) MPI_Comm_size(cmm, &s); /* local */ + return s; } -long mpiRank(fMPI_Comm cmm) { - int s=MPI_UNDEFINED; - if(cmm != (MPI_Comm)MPI_COMM_NULL) - MPI_Comm_rank(cmm, &s); /* local */ - return s; +long mpiRank(fMPI_Comm cmm) { + int s = MPI_UNDEFINED; + if (cmm != (MPI_Comm)MPI_COMM_NULL) MPI_Comm_rank(cmm, &s); /* local */ + return s; } -AnyType InitializeGroup(Stack stack,const AnyType &x){ - MPI_Group *g=*PGetAny(x); - *g=MPI_GROUP_NULL; - MPI_Comm_group(MPI_COMM_WORLD, g); - return g; +AnyType InitializeGroup(Stack stack, const AnyType &x) { + MPI_Group *g = *PGetAny< fMPI_Group >(x); + *g = MPI_GROUP_NULL; + MPI_Comm_group(MPI_COMM_WORLD, g); + return g; } -AnyType DeleteGroup(Stack stack,const AnyType &x){ - MPI_Group *g=*PGetAny(x); - if(g && (*g != MPI_GROUP_NULL))MPI_Group_free(g); - return Nothing; +AnyType DeleteGroup(Stack stack, const AnyType &x) { + MPI_Group *g = *PGetAny< fMPI_Group >(x); + if (g && (*g != MPI_GROUP_NULL)) MPI_Group_free(g); + return Nothing; } -AnyType InitializeComm(Stack stack,const AnyType &x){ - MPI_Comm *comm= *PGetAny(x); - *comm=MPI_COMM_NULL; - MPI_Comm_dup(MPI_COMM_WORLD, comm); - return comm; +AnyType InitializeComm(Stack stack, const AnyType &x) { + MPI_Comm *comm = *PGetAny< fMPI_Comm >(x); + *comm = MPI_COMM_NULL; + MPI_Comm_dup(MPI_COMM_WORLD, comm); + return comm; } -AnyType DeleteComm(Stack stack,const AnyType &x){ - MPI_Comm *comm= *PGetAny(x); - if(comm && (*comm != MPI_COMM_NULL && *comm != MPI_COMM_WORLD))// add MPI_COMM_WORLD FH 11/2010 FH - MPI_Comm_free(comm); - return Nothing; +AnyType DeleteComm(Stack stack, const AnyType &x) { + MPI_Comm *comm = *PGetAny< fMPI_Comm >(x); + if (comm && (*comm != MPI_COMM_NULL && *comm != MPI_COMM_WORLD)) // add MPI_COMM_WORLD FH 11/2010 FH + MPI_Comm_free(comm); + return Nothing; } -AnyType InitializeRequest(Stack stack,const AnyType &x){ - MPI_Request *comm=*PGetAny(x); - *comm=MPI_REQUEST_NULL; +AnyType InitializeRequest(Stack stack, const AnyType &x) { + MPI_Request *comm = *PGetAny< fMPI_Request >(x); + *comm = MPI_REQUEST_NULL; - return comm; + return comm; } -AnyType DeleteRequest(Stack stack,const AnyType &x){ - MPI_Request *comm=*PGetAny(x); - if(comm && ( *comm!=MPI_REQUEST_NULL )) MPI_Request_free(comm); - return Nothing; +AnyType DeleteRequest(Stack stack, const AnyType &x) { + MPI_Request *comm = *PGetAny< fMPI_Request >(x); + if (comm && (*comm != MPI_REQUEST_NULL)) MPI_Request_free(comm); + return Nothing; } // Hack to Bypass a bug in freefem FH ... template<> -class ForEachType: public basicForEachType{public:// correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(MPI_Group),sizeof(MPI_Group),0,0,iv,id,OOnReturn) { } +class ForEachType< MPI_Group > : public basicForEachType { + public: // correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(MPI_Group), sizeof(MPI_Group), 0, 0, iv, id, OOnReturn) {} }; template<> -class ForEachType: public basicForEachType{public:// coorection july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(fMPI_Comm),sizeof(fMPI_Comm),0,0,iv,id,OOnReturn) {} +class ForEachType< fMPI_Comm > : public basicForEachType { + public: // coorection july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(fMPI_Comm), sizeof(fMPI_Comm), 0, 0, iv, id, OOnReturn) {} }; template<> -class ForEachType: public basicForEachType{public:// correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) - ForEachType(Function1 iv=0,Function1 id=0,Function1 OOnReturn=0):basicForEachType(typeid(fMPI_Request),sizeof(fMPI_Request),0,0,iv,id,OOnReturn) {} +class ForEachType< fMPI_Request > : public basicForEachType { + public: // correction july 2009..... FH Hoooo.... (Il y a un bug DUR DUR FH ...) + ForEachType(Function1 iv = 0, Function1 id = 0, Function1 OOnReturn = 0) : basicForEachType(typeid(fMPI_Request), sizeof(fMPI_Request), 0, 0, iv, id, OOnReturn) {} }; // end Hack ... +fMPI_Group *def_group(fMPI_Group *const &a, fMPI_Comm *const &comm, KN_< long > const &b) { + MPI_Group group; + MPI_Comm_group(*comm, &group); + KN< int > ranks(b); + MPI_Group_incl(group, ranks.N( ), (int *)ranks, *a); + MPI_Group_free(&group); + // ici def a .. + return a; +} -fMPI_Group* def_group( fMPI_Group* const & a,fMPI_Comm * const &comm, KN_ const & b) -{ +fMPI_Group *def_group(fMPI_Group *const &a, KN_< long > const &b) { MPI_Group group; - MPI_Comm_group(*comm,& group); - KN ranks(b); - MPI_Group_incl(group, ranks.N(),(int *) ranks, *a); - MPI_Group_free(&group) ; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Comm_group(comm, &group); + KN< int > ranks(b); + MPI_Group_incl(group, ranks.N( ), (int *)ranks, *a); + MPI_Group_free(&group); // ici def a .. - return a;} - -fMPI_Group* def_group( fMPI_Group* const & a, KN_ const & b) -{ - MPI_Group group; - MPI_Comm comm=MPI_COMM_WORLD; - MPI_Comm_group(comm,& group); - KN ranks(b); - MPI_Group_incl(group, ranks.N(),(int *) ranks, *a); - MPI_Group_free(&group) ; - // ici def a .. -return a;} - -fMPI_Group* def_group( fMPI_Group* const & a,fMPI_Comm * const &comm) -{ - MPI_Comm_group(*comm,*a); - return a;} - -fMPI_Comm* def_comm( fMPI_Comm* const & a,fMPI_Group* const & g) -{ - int ok=MPI_Comm_create(MPI_COMM_WORLD,*g,*a); - return a; + return a; } -fMPI_Comm* def_comm( fMPI_Comm* const & a,fMPI_Comm* const & b,fMPI_Group* const & g) -{ - MPI_Comm_create(*b,*g,*a); - return a; +fMPI_Group *def_group(fMPI_Group *const &a, fMPI_Comm *const &comm) { + MPI_Comm_group(*comm, *a); + return a; } -fMPI_Group* def_group( fMPI_Group* const & a,fMPI_Group * const & group,KN_ const & b) -{ +fMPI_Comm *def_comm(fMPI_Comm *const &a, fMPI_Group *const &g) { + int ok = MPI_Comm_create(MPI_COMM_WORLD, *g, *a); + return a; +} - KN ranks(b); - MPI_Group_incl(*group, ranks.N(), (int *) ranks, *a); +fMPI_Comm *def_comm(fMPI_Comm *const &a, fMPI_Comm *const &b, fMPI_Group *const &g) { + MPI_Comm_create(*b, *g, *a); + return a; +} + +fMPI_Group *def_group(fMPI_Group *const &a, fMPI_Group *const &group, KN_< long > const &b) { + + KN< int > ranks(b); + MPI_Group_incl(*group, ranks.N( ), (int *)ranks, *a); // ici def a .. return a; } -struct Def_def_Commsplit : public quad_function -{ - static fMPI_Comm * f(Stack,fMPI_Comm* const & a,fMPI_Comm* const & comm,const long &color ,const long &key ) - { - MPI_Comm_split(*comm,color, key, *a); - return a; - } +struct Def_def_Commsplit : public quad_function< fMPI_Comm *, fMPI_Comm *, long, long, fMPI_Comm * > { + static fMPI_Comm *f(Stack, fMPI_Comm *const &a, fMPI_Comm *const &comm, const long &color, const long &key) { + MPI_Comm_split(*comm, color, key, *a); + return a; + } }; -fMPI_Comm * mpiCommsplit(fMPI_Comm* const & a,const MPIrank &p1,const long &key ) -{ - MPI_Comm_split(p1.comm, p1.who, key, *a); - return a; +fMPI_Comm *mpiCommsplit(fMPI_Comm *const &a, const MPIrank &p1, const long &key) { + MPI_Comm_split(p1.comm, p1.who, key, *a); + return a; } - -struct Def_def_Intercommcreate : public quad_function -{ -static fMPI_Comm * f(Stack,fMPI_Comm* const & a, MPIrank const & p1, MPIrank const & p2, long const & tag ) -{ +struct Def_def_Intercommcreate : public quad_function< fMPI_Comm *, MPIrank, MPIrank, long, fMPI_Comm * > { + static fMPI_Comm *f(Stack, fMPI_Comm *const &a, MPIrank const &p1, MPIrank const &p2, long const &tag) { int err; - err=MPI_Intercomm_create(p1.comm, p1.who, p2.comm,p2.who,tag, *a); + err = MPI_Intercomm_create(p1.comm, p1.who, p2.comm, p2.who, tag, *a); return a; -} + } }; -fMPI_Comm * def_intercommmerge(fMPI_Comm* const & a,fMPI_Comm* const & b, const long & high) -{ - MPI_Intercomm_merge(*b, high, *a); - return a; +fMPI_Comm *def_intercommmerge(fMPI_Comm *const &a, fMPI_Comm *const &b, const long &high) { + MPI_Intercomm_merge(*b, high, *a); + return a; } - -template -AnyType ClearReturnpKK(Stack stack, const AnyType & a) -{ +template< typename K, typename KK > +AnyType ClearReturnpKK(Stack stack, const AnyType &a) { // a ne faire que pour les variables local au return... // pour l'instant on copie pour fqire mqrche // a repense FH mqi 2009.... - KK * m = GetAny(a); - m->increment(); - Add2StackOfPtr2FreeRC(stack,m); - if(verbosity>400) - cout << "ClearReturnpKK:: increment + Add2StackOfPtr2FreeRC nb ref " << -m->next << endl; - return m; + KK *m = GetAny< KK * >(a); + m->increment( ); + Add2StackOfPtr2FreeRC(stack, m); + if (verbosity > 400) cout << "ClearReturnpKK:: increment + Add2StackOfPtr2FreeRC nb ref " << -m->next << endl; + return m; } -template -AnyType ClearReturnpKK_(Stack stack, const AnyType & a) -{ +template< typename K, typename KK, typename KK_ > +AnyType ClearReturnpKK_(Stack stack, const AnyType &a) { // il faut faire un copie du tableau - KK_ * m = GetAny(a); - KK *cm=new KK(*m); + KK_ *m = GetAny< KK_ * >(a); + KK *cm = new KK(*m); - Add2StackOfPtr2Free(stack,cm);// detruire la copie - if(verbosity>400) - cout << "ClearReturnpKK_:: copie Add2StackOfPtr2Free " << endl; - return (KK_ *) cm; + Add2StackOfPtr2Free(stack, cm); // detruire la copie + if (verbosity > 400) cout << "ClearReturnpKK_:: copie Add2StackOfPtr2Free " << endl; + return (KK_ *)cm; } -template -AnyType ClearReturnKK_(Stack stack, const AnyType & a) -{ +template< typename K, typename KK, typename KK_ > +AnyType ClearReturnKK_(Stack stack, const AnyType &a) { // il faut faire un copie du tableau - KK_ m = GetAny(a); - KK *cm=new KK(m); - - Add2StackOfPtr2Free(stack,cm);// detruire la copie - if(verbosity>400) - cout << "ClearReturnKK_:: copie Add2StackOfPtr2Free " << endl; - return SetAny(*cm); -} -fMPI_Request * get_elementp_( KN * const & a,const long & b){ - if( a==0 || b<0 || a->N() <= b) - { if(a) cerr << " Out of bound 0 <=" << b << " < " << a->N() << " KN * " << endl; - ExecError("Out of bound in operator []");} - return reinterpret_cast (&((*a)[b]));}// bofBof ... - -KN * set_init0( KN * const & a,const long & b) - { - a->init(b); - for(int i=0;i + KK_ m = GetAny< KK_ >(a); + KK *cm = new KK(m); + + Add2StackOfPtr2Free(stack, cm); // detruire la copie + if (verbosity > 400) cout << "ClearReturnKK_:: copie Add2StackOfPtr2Free " << endl; + return SetAny< KK_ >(*cm); +} +fMPI_Request *get_elementp_(KN< MPI_Request > *const &a, const long &b) { + if (a == 0 || b < 0 || a->N( ) <= b) { + if (a) cerr << " Out of bound 0 <=" << b << " < " << a->N( ) << " KN * " << endl; + ExecError("Out of bound in operator []"); + } + return reinterpret_cast< fMPI_Request * >(&((*a)[b])); +} // bofBof ... + +KN< MPI_Request > *set_init0(KN< MPI_Request > *const &a, const long &b) { + a->init(b); + for (int i = 0; i < b; ++i) (*a)[i] = MPI_REQUEST_NULL; + return a; +} +bool toBool(fMPI_Comm *comm) { return (comm && (*comm != (MPI_Comm)MPI_COMM_NULL)); } +void *topVoid(fMPI_Comm *comm) { return comm; } + +template< typename T > class Quad_Op : public E_F0 { typedef typename T::result_type R; typedef typename T::first_argument_type A; @@ -2554,500 +2413,426 @@ class Quad_Op : public E_F0 { typedef typename T::third_argument_type C; typedef typename T::fourth_argument_type D; - typedef typename T::result_type Result; - Expression a,b,c,d; -public: - AnyType operator()(Stack s) const - {return SetAny(static_cast(T::f(s, GetAny((*a)(s)) , - GetAny((*b)(s)) , - GetAny((*c)(s)), - GetAny((*d)(s)) - )));} - Quad_Op(Expression aa,Expression bb,Expression cc,Expression dd) : a(aa),b(bb),c(cc),d(dd) {} - bool MeshIndependent() const { - return a->MeshIndependent() && b->MeshIndependent() && c->MeshIndependent() && d->MeshIndependent();} -}; + typedef typename T::result_type Result; + Expression a, b, c, d; + public: + AnyType operator( )(Stack s) const { return SetAny< R >(static_cast< R >(T::f(s, GetAny< A >((*a)(s)), GetAny< B >((*b)(s)), GetAny< C >((*c)(s)), GetAny< D >((*d)(s))))); } + Quad_Op(Expression aa, Expression bb, Expression cc, Expression dd) : a(aa), b(bb), c(cc), d(dd) {} + bool MeshIndependent( ) const { return a->MeshIndependent( ) && b->MeshIndependent( ) && c->MeshIndependent( ) && d->MeshIndependent( ); } +}; // Fin add J. Morice -void f_end_parallele() -{ - /// FFCS: MPI_Finalize() needs to be called later than this (in - /// ffcs/src/server.cpp) - ffapi::mpi_finalize(); - if(verbosity> 2 || (verbosity>1&&mpirank ==0)) cout << "FreeFem++-mpi finalize correctly .\n" << flush ; - else if(verbosity>5) cout << '.' << endl ; +void f_end_parallele( ) { + /// FFCS: MPI_Finalize() needs to be called later than this (in + /// ffcs/src/server.cpp) + ffapi::mpi_finalize( ); + if (verbosity > 2 || (verbosity > 1 && mpirank == 0)) + cout << "FreeFem++-mpi finalize correctly .\n" << flush; + else if (verbosity > 5) + cout << '.' << endl; } -void f_initparallele(int &argc, char **& argv) -{ +void f_initparallele(int &argc, char **&argv) { /// FFCS: MPI_Init() needs to be called earlier (in ffcs/src/server.cpp) - ffapi::mpi_init(argc,argv); + ffapi::mpi_init(argc, argv); - int mpirank1,mpisize1; + int mpirank1, mpisize1; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank1); /* local */ MPI_Comm_size(MPI_COMM_WORLD, &mpisize1); /* local */ - mpirank = mpirank1;//MPI::COMM_WORLD.Get_rank(); - mpisize =mpisize1;// MPI::COMM_WORLD.Get_size(); - if(verbosity> 2 || (verbosity>1&&mpirank ==0)) - cout << "initparallele rank " << mpirank << " on " << mpisize << endl; - ff_atend(f_end_parallele); // set end MPI // + mpirank = mpirank1; // MPI::COMM_WORLD.Get_rank(); + mpisize = mpisize1; // MPI::COMM_WORLD.Get_size(); + if (verbosity > 2 || (verbosity > 1 && mpirank == 0)) cout << "initparallele rank " << mpirank << " on " << mpisize << endl; + ff_atend(f_end_parallele); // set end MPI // } -double ffMPI_Wtime() {return MPI_Wtime();} -double ffMPI_Wtick() {return MPI_Wtick();} +double ffMPI_Wtime( ) { return MPI_Wtime( ); } +double ffMPI_Wtick( ) { return MPI_Wtick( ); } class splitComm_Op : public E_F0mps { -public: - Expression comm; - Expression p; - Expression splitComm; - static const int n_name_param = 2; - static basicAC_F0::name_and_type name_param[]; - Expression nargs[n_name_param]; - splitComm_Op(const basicAC_F0& args, Expression param1, Expression param2, Expression param3) : comm(param1), p(param2), splitComm(param3) { - args.SetNameParam(n_name_param, name_param, nargs); - } - AnyType operator()(Stack stack) const; + public: + Expression comm; + Expression p; + Expression splitComm; + static const int n_name_param = 2; + static basicAC_F0::name_and_type name_param[]; + Expression nargs[n_name_param]; + splitComm_Op(const basicAC_F0 &args, Expression param1, Expression param2, Expression param3) : comm(param1), p(param2), splitComm(param3) { args.SetNameParam(n_name_param, name_param, nargs); } + AnyType operator( )(Stack stack) const; }; -basicAC_F0::name_and_type splitComm_Op::name_param[] = { - {"topology", &typeid(long)}, - {"exclude", &typeid(bool)} -}; +basicAC_F0::name_and_type splitComm_Op::name_param[] = {{"topology", &typeid(long)}, {"exclude", &typeid(bool)}}; class splitComm : public OneOperator { -public: - splitComm() : OneOperator(atype(), atype(), atype(), atype()) {} - E_F0* code(const basicAC_F0& args) const - { - return new splitComm_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); - } + public: + splitComm( ) : OneOperator(atype< long >( ), atype< pcommworld >( ), atype< long * >( ), atype< pcommworld >( )) {} + E_F0 *code(const basicAC_F0 &args) const { return new splitComm_Op(args, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2])); } }; -static inline bool splitCommunicator(const MPI_Comm& in, MPI_Comm& out, const bool& exclude, unsigned short& p, const unsigned short& T) { - int size, rank; - MPI_Comm_size(in, &size); - MPI_Comm_rank(in, &rank); - if(p > size / 2 && size > 1) { - p = size / 2; - if(rank == 0) - std::cout << "WARNING -- the number of master processes was set to a value greater than MPI_Comm_size, the value has been reset to " << p << std::endl; - } - p = std::max(p, static_cast(1)); - if(exclude) { - MPI_Group oldGroup, newGroup; - MPI_Comm_group(in, &oldGroup); - int* pm = new int[p]; - if(T == 1) - for(int i=0;i(size - std::sqrt(std::max(size * size - 2 * size * pm[i - 1] - 2 * area + pm[i - 1] * pm[i - 1], 1.0f)) + 0.5); - } - else - for(unsigned short i = 0; i < p; ++i) - pm[i] = i * (size / p); - bool excluded = std::binary_search(pm, pm + p, rank); - if(excluded) - MPI_Group_incl(oldGroup, p, pm, &newGroup); - else - MPI_Group_excl(oldGroup, p, pm, &newGroup); - MPI_Comm_create(in, newGroup, &out); - MPI_Group_free(&oldGroup); - MPI_Group_free(&newGroup); - delete [] pm; - return excluded; - } - else { - MPI_Comm_dup(in, &out); - return false; - } +static inline bool splitCommunicator(const MPI_Comm &in, MPI_Comm &out, const bool &exclude, unsigned short &p, const unsigned short &T) { + int size, rank; + MPI_Comm_size(in, &size); + MPI_Comm_rank(in, &rank); + if (p > size / 2 && size > 1) { + p = size / 2; + if (rank == 0) std::cout << "WARNING -- the number of master processes was set to a value greater than MPI_Comm_size, the value has been reset to " << p << std::endl; + } + p = std::max(p, static_cast< unsigned short >(1)); + if (exclude) { + MPI_Group oldGroup, newGroup; + MPI_Comm_group(in, &oldGroup); + int *pm = new int[p]; + if (T == 1) + for (int i = 0; i < p; ++i) pm[i] = i; + else if (T == 2) { + float area = size * size / (2.0 * p); + *pm = 0; + for (unsigned short i = 1; i < p; ++i) pm[i] = static_cast< int >(size - std::sqrt(std::max(size * size - 2 * size * pm[i - 1] - 2 * area + pm[i - 1] * pm[i - 1], 1.0f)) + 0.5); + } else + for (unsigned short i = 0; i < p; ++i) pm[i] = i * (size / p); + bool excluded = std::binary_search(pm, pm + p, rank); + if (excluded) + MPI_Group_incl(oldGroup, p, pm, &newGroup); + else + MPI_Group_excl(oldGroup, p, pm, &newGroup); + MPI_Comm_create(in, newGroup, &out); + MPI_Group_free(&oldGroup); + MPI_Group_free(&newGroup); + delete[] pm; + return excluded; + } else { + MPI_Comm_dup(in, &out); + return false; + } } - -AnyType splitComm_Op::operator()(Stack stack) const { - bool exclude = nargs[1] ? GetAny((*nargs[1])(stack)) : false; - MPI_Comm* orig_comm = (MPI_Comm*)GetAny((*comm)(stack)); - MPI_Comm* new_comm = (MPI_Comm*)GetAny((*splitComm)(stack)); - long* pp = GetAny((*p)(stack)); - unsigned short p = *pp; - long topology = nargs[0] ? GetAny((*nargs[0])(stack)) : 0; - bool excluded = splitCommunicator(*orig_comm, *new_comm, exclude, p, topology); - *pp = p; - return static_cast(excluded); +AnyType splitComm_Op::operator( )(Stack stack) const { + bool exclude = nargs[1] ? GetAny< bool >((*nargs[1])(stack)) : false; + MPI_Comm *orig_comm = (MPI_Comm *)GetAny< pcommworld >((*comm)(stack)); + MPI_Comm *new_comm = (MPI_Comm *)GetAny< pcommworld >((*splitComm)(stack)); + long *pp = GetAny< long * >((*p)(stack)); + unsigned short p = *pp; + long topology = nargs[0] ? GetAny< long >((*nargs[0])(stack)) : 0; + bool excluded = splitCommunicator(*orig_comm, *new_comm, exclude, p, topology); + *pp = p; + return static_cast< long >(excluded); } - -void f_init_lgparallele() - { - if(verbosity && mpirank == 0) cout << "parallelempi "; - using namespace Fem2D; - Dcl_TypeandPtr(0); - - Dcl_TypeandPtr(0,0,InitializeGroup,DeleteGroup); - Dcl_TypeandPtr(0,0,InitializeComm,DeleteComm); - Dcl_Type(); - Dcl_TypeandPtr(0,0,InitializeRequest,DeleteRequest); // bof bof ... - Dcl_TypeandPtr_ ,KN* > - (0,0,0,::Destroy >, - ::ClearReturnKK_,KN_ >, - ::ClearReturnpKK >); - - zzzfff->Add("mpiGroup",atype()); - zzzfff->Add("mpiComm",atype()); - zzzfff->Add("mpiRequest",atype()); - - map_type_of_map[make_pair(atype(),atype())]=atype*>(); // vector - - - map_type[typeid(MPIrank).name()]->AddCast(new E_F1_funcT(UnRef)); - map_type[typeid(fMPI_Group).name()]->AddCast(new E_F1_funcT(UnRef)); - map_type[typeid(fMPI_Comm).name()]->AddCast(new E_F1_funcT(UnRef)); - map_type[typeid(bool).name()]->AddCast(new OneOperator1(toBool)); - map_type[typeid(void*).name()]->AddCast(new OneOperator1(topVoid)); - - - TheOperators->Add("<-", - new OneOperator2_(&set_copympi)); - - // constructor example ... - TheOperators->Add("<-", - new OneOperator2_ >(&def_group), - new OneOperator3_ >(&def_group), - new OneOperator3_ >(&def_group), - new OneOperator2_(&def_group)); - - - TheOperators->Add("<-", - new OneOperator2_(&def_comm), - new OneOperator3_(&def_comm), - new OneOperator3_(&mpiCommsplit), - new OneOperator3_(&def_intercommmerge), - new OneQuadOperator< Def_def_Intercommcreate, Quad_Op >, - new OneQuadOperator< Def_def_Commsplit, Quad_Op > - - ); - - Global.Add("processor","(",new OneOperator1(mpiwho)); - Global.Add("processor","(",new OneOperator2(mpiwho)); - Global.Add("processor","(",new OneOperator2(mpiwho)); - - Global.Add("processorblock","(",new OneOperator1(mpiwhob)); - Global.Add("processorblock","(",new OneOperator2(mpiwhob)); - - TheOperators->Add(">>", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > , - new OneBinaryOperator > > , - new OneBinaryOperator > > , - new OneBinaryOperator > > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > > , - new OneBinaryOperator > > - ); - - TheOperators->Add(">>", - new OneBinaryOperator > > , - new OneBinaryOperator > > , - new OneBinaryOperator > > ); - - TheOperators->Add("<<", - new OneBinaryOperator >, - new OneBinaryOperator >, - new OneBinaryOperator > , - new OneBinaryOperator * > > , - new OneBinaryOperator * > > , - new OneBinaryOperator * > > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator > , - new OneBinaryOperator * > > , - new OneBinaryOperator* > > - - ); - - TheOperators->Add("<<", - new OneBinaryOperator * > > , - new OneBinaryOperator * > > , - new OneBinaryOperator * > > ); - - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator> >); - Global.Add("Send","(", new OneBinaryOperator > >); - Global.Add("Send","(", new OneBinaryOperator > >); - Global.Add("Send","(", new OneBinaryOperator > >); - Global.Add("Send","(", new OneBinaryOperator > >); - Global.Add("Send","(", new OneBinaryOperator > >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator >); - Global.Add("Send","(", new OneBinaryOperator *> >); - Global.Add("Send","(", new OneBinaryOperator *> >); - - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >(1)); // takes priority - Global.Add("Isend","(", new OneBinaryOperator >(1)); // takes priority - Global.Add("Isend","(", new OneBinaryOperator >(1)); // takes priority - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator > >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator> >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator> >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator> >); - Global.Add("Isend","(", new OneBinaryOperator> >); - Global.Add("Isend","(", new OneBinaryOperator> >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - Global.Add("Isend","(", new OneBinaryOperator *> >); - - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator >); - Global.Add("Recv","(", new OneBinaryOperator > >); - Global.Add("Recv","(", new OneBinaryOperator > >); - - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - Global.Add("Irecv","(", new OneBinaryOperator > >); - - - - - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - Global.Add("broadcast","(",new OneBinaryOperator > >); - - Global.Add("mpiAlltoall","(",new OneBinaryOperator >); - Global.Add("mpiAlltoall","(",new OneBinaryOperator >); - Global.Add("mpiAllgather","(",new OneBinaryOperator >); - Global.Add("mpiAllgather","(",new OneBinaryOperator >); - Global.Add("mpiAlltoall","(",new OneTernaryOperator3 >); - Global.Add("mpiAlltoall","(",new OneTernaryOperator3 >); - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >); - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >); - - Global.Add("mpiAllgather","(",new OneBinaryOperator >); // Add J. Morice - Global.Add("mpiAllgather","(",new OneBinaryOperator >); // Add J. Morice - - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >); // Add J. Morice - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >);// Add J. Morice - - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); // Add J. Morice - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); // Add J. Morice - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); - - Global.Add("mpiGather","(",new OneTernaryOperator3 >); // Add J. Morice - Global.Add("mpiGather","(",new OneTernaryOperator3 >); // Add J. Morice - Global.Add("mpiGather","(",new OneTernaryOperator3 >); // correction J. Morice Scatter --> Gather - Global.Add("mpiGather","(",new OneTernaryOperator3 >); - - // Add J. Morice communication with vector of different size - Global.Add("mpiAlltoallv","(",new OneOperator6_, KN_, KN_, KN_, KN_, KN_ >( Op_All2Allv ) ); - Global.Add("mpiAlltoallv","(",new OneOperator6_, KN_, KN_, KN_, KN_, KN_ >( Op_All2Allv ) ); - - Global.Add("mpiAlltoallv","(",new OneOperator7_, KN_, fMPI_Comm, KN_, KN_, KN_, KN_ >( Op_All2All3v ) ); - Global.Add("mpiAlltoallv","(",new OneOperator7_, KN_, fMPI_Comm, KN_, KN_, KN_, KN_ >( Op_All2All3v ) ); - - Global.Add("mpiAllgatherv","(",new OneQuadOperator, Quad_Op > > ); - Global.Add("mpiAllgatherv","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllgatherv","(",new OneOperator5_, KN_, fMPI_Comm, KN_, KN_ >(Op_Allgatherv3< long >) ); - Global.Add("mpiAllgatherv","(",new OneOperator5_, KN_, fMPI_Comm, KN_, KN_ >(Op_Allgatherv3< double >) ); - - Global.Add("mpiScatterv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >(Op_Scatterv3< long >) ); - Global.Add("mpiScatterv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >(Op_Scatterv3< double >) ); - - Global.Add("mpiGatherv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >( Op_Gatherv3< long > ) ); - Global.Add("mpiGatherv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >( Op_Gatherv3< double > ) ); - // Fin Add J. Morice - - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >); // add FH jan 2011 - - // Add J. Morice - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >); // add FH jan 2011 - // Global.Add("mpiReduceScatter","(",new OneQuadOperator, Quad_Op > >); - // fin Add J. Morice - - // Add J. Morice :: complex communication between processor - Global.Add("mpiAlltoall","(",new OneBinaryOperator >); - Global.Add("mpiAllgather","(",new OneBinaryOperator >); - Global.Add("mpiAlltoall","(",new OneTernaryOperator3 >); - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >); - - Global.Add("mpiAllgather","(",new OneBinaryOperator >); - Global.Add("mpiAllgather","(",new OneTernaryOperator3 >); - - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); - Global.Add("mpiGather","(",new OneTernaryOperator3 >); - - Global.Add("mpiScatter","(",new OneTernaryOperator3 >); - Global.Add("mpiGather","(",new OneTernaryOperator3 >); - - // Add J. Morice communication with vector of different size - Global.Add("mpiAlltoallv","(",new OneOperator6_, KN_, KN_, KN_, KN_, KN_ >( Op_All2Allv ) ); - Global.Add("mpiAlltoallv","(",new OneOperator7_, KN_, fMPI_Comm, KN_, KN_, KN_, KN_ >( Op_All2All3v ) ); - Global.Add("mpiAllgatherv","(",new OneQuadOperator, Quad_Op > >); - - Global.Add("mpiAllgatherv","(",new OneOperator5_, KN_, fMPI_Comm, KN_, KN_ >(Op_Allgatherv3< Complex >) ); - Global.Add("mpiScatterv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >(Op_Scatterv3< Complex >) ); - Global.Add("mpiGatherv","(",new OneOperator5_, KN_, MPIrank, KN_, KN_ >( Op_Gatherv3< Complex > ) ); - - - - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >);// add FH april 2011 - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >);// add FH april 2011 - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >);// add FH april 2011 - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >);// add FH april 2011 - - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiReduce","(",new OneQuadOperator, Quad_Op > >); - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >); +void f_init_lgparallele( ) { + if (verbosity && mpirank == 0) cout << "parallelempi "; + using namespace Fem2D; + Dcl_TypeandPtr< MPIrank >(0); + + Dcl_TypeandPtr< fMPI_Group >(0, 0, InitializeGroup, DeleteGroup); + Dcl_TypeandPtr< fMPI_Comm >(0, 0, InitializeComm, DeleteComm); + Dcl_Type< fMPI_Op >( ); + Dcl_TypeandPtr< fMPI_Request >(0, 0, InitializeRequest, DeleteRequest); // bof bof ... + Dcl_TypeandPtr_< KN_< MPI_Request >, KN< MPI_Request > * >(0, 0, 0, ::Destroy< KN< MPI_Request > >, ::ClearReturnKK_< MPI_Request, KN< MPI_Request >, KN_< MPI_Request > >, + ::ClearReturnpKK< MPI_Request, KN< MPI_Request > >); + + zzzfff->Add("mpiGroup", atype< fMPI_Group * >( )); + zzzfff->Add("mpiComm", atype< fMPI_Comm * >( )); + zzzfff->Add("mpiRequest", atype< fMPI_Request * >( )); + + map_type_of_map[make_pair(atype< long >( ), atype< fMPI_Request >( ))] = atype< KN< MPI_Request > * >( ); // vector + + map_type[typeid(MPIrank).name( )]->AddCast(new E_F1_funcT< MPIrank, MPIrank * >(UnRef< MPIrank >)); + map_type[typeid(fMPI_Group).name( )]->AddCast(new E_F1_funcT< fMPI_Group, fMPI_Group * >(UnRef< fMPI_Group >)); + map_type[typeid(fMPI_Comm).name( )]->AddCast(new E_F1_funcT< fMPI_Comm, fMPI_Comm * >(UnRef< fMPI_Comm >)); + map_type[typeid(bool).name( )]->AddCast(new OneOperator1< bool, fMPI_Comm * >(toBool)); + map_type[typeid(void *).name( )]->AddCast(new OneOperator1< void *, fMPI_Comm * >(topVoid)); + + TheOperators->Add("<-", new OneOperator2_< MPIrank *, MPIrank *, MPIrank >(&set_copympi)); + + // constructor example ... + TheOperators->Add("<-", new OneOperator2_< fMPI_Group *, fMPI_Group *, KN_< long > >(&def_group), new OneOperator3_< fMPI_Group *, fMPI_Group *, fMPI_Group *, KN_< long > >(&def_group), + new OneOperator3_< fMPI_Group *, fMPI_Group *, fMPI_Comm *, KN_< long > >(&def_group), new OneOperator2_< fMPI_Group *, fMPI_Group *, fMPI_Comm * >(&def_group)); + + TheOperators->Add("<-", new OneOperator2_< fMPI_Comm *, fMPI_Comm *, fMPI_Group * >(&def_comm), new OneOperator3_< fMPI_Comm *, fMPI_Comm *, fMPI_Comm *, fMPI_Group * >(&def_comm), + new OneOperator3_< fMPI_Comm *, fMPI_Comm *, MPIrank, long >(&mpiCommsplit), new OneOperator3_< fMPI_Comm *, fMPI_Comm *, fMPI_Comm *, long >(&def_intercommmerge), + new OneQuadOperator< Def_def_Intercommcreate, Quad_Op< Def_def_Intercommcreate > >, new OneQuadOperator< Def_def_Commsplit, Quad_Op< Def_def_Commsplit > > + + ); + + Global.Add("processor", "(", new OneOperator1< MPIrank, long >(mpiwho)); + Global.Add("processor", "(", new OneOperator2< MPIrank, long, fMPI_Comm >(mpiwho)); + Global.Add("processor", "(", new OneOperator2< MPIrank, fMPI_Comm, long >(mpiwho)); + + Global.Add("processorblock", "(", new OneOperator1< MPIrank, long >(mpiwhob)); + Global.Add("processorblock", "(", new OneOperator2< MPIrank, long, fMPI_Comm >(mpiwhob)); + + TheOperators->Add(">>", new OneBinaryOperator< Op_Readmpi< double > >, new OneBinaryOperator< Op_Readmpi< Complex > >, new OneBinaryOperator< Op_Readmpi< long > >, + new OneBinaryOperator< Op_Readmpi< KN< double > > >, new OneBinaryOperator< Op_Readmpi< KN< long > > >, new OneBinaryOperator< Op_Readmpi< KN< Complex > > >, + new OneBinaryOperator< Op_Readmpi< const Mesh * > >, new OneBinaryOperator< Op_Readmpi< const Mesh3 * > >, new OneBinaryOperator< Op_Readmpi< const MeshS * > >, + new OneBinaryOperator< Op_Readmpi< const MeshL * > >, new OneBinaryOperator< Op_Readmpi< Matrice_Creuse< R > > >, new OneBinaryOperator< Op_Readmpi< Matrice_Creuse< Complex > > >); + + TheOperators->Add(">>", new OneBinaryOperator< Op_Readmpi< KNM< double > > >, new OneBinaryOperator< Op_Readmpi< KNM< long > > >, new OneBinaryOperator< Op_Readmpi< KNM< Complex > > >); + + TheOperators->Add("<<", new OneBinaryOperator< Op_Writempi< double > >, new OneBinaryOperator< Op_Writempi< Complex > >, new OneBinaryOperator< Op_Writempi< long > >, + new OneBinaryOperator< Op_Writempi< KN< double > * > >, new OneBinaryOperator< Op_Writempi< KN< long > * > >, new OneBinaryOperator< Op_Writempi< KN< Complex > * > >, + new OneBinaryOperator< Op_Writempi< const Mesh * > >, new OneBinaryOperator< Op_Writempi< const Mesh3 * > >, new OneBinaryOperator< Op_Writempi< const MeshS * > >, + new OneBinaryOperator< Op_Writempi< const MeshL * > >, new OneBinaryOperator< Op_Writempi< Matrice_Creuse< R > * > >, + new OneBinaryOperator< Op_Writempi< Matrice_Creuse< Complex > * > > + + ); + + TheOperators->Add("<<", new OneBinaryOperator< Op_Writempi< KNM< double > * > >, new OneBinaryOperator< Op_Writempi< KNM< long > * > >, new OneBinaryOperator< Op_Writempi< KNM< Complex > * > >); + + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< double > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< Complex > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< long > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN< double > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN< long > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN< Complex > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM< double > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM< long > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM< Complex > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN_< double > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN_< long > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KN_< Complex > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM_< double > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM_< long > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< KNM_< Complex > > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< const Mesh * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< const Mesh3 * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< const MeshS * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< const MeshL * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< Matrice_Creuse< R > * > >); + Global.Add("Send", "(", new OneBinaryOperator< Op_Sendmpi< Matrice_Creuse< Complex > * > >); + + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< double > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< long > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< Complex > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< double * > >(1)); // takes priority + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< long * > >(1)); // takes priority + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< Complex * > >(1)); // takes priority + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN< double > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN_< double > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN< long > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN_< long > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN< Complex > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KN_< Complex > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM< double > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM< long > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM< Complex > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM_< double > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM_< long > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< KNM_< Complex > > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< const Mesh * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< const Mesh3 * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< const MeshS * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< const MeshL * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< Matrice_Creuse< R > * > >); + Global.Add("Isend", "(", new OneBinaryOperator< Op_ISendmpi< Matrice_Creuse< Complex > * > >); + + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< double > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< long > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< Complex > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KN< double > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KN< long > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KN< Complex > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KNM< double > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KNM< long > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< KNM< Complex > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< const Mesh * > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< const Mesh3 * > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< const MeshS * > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< const MeshL * > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< Matrice_Creuse< R > > >); + Global.Add("Recv", "(", new OneBinaryOperator< Op_Recvmpi< Matrice_Creuse< Complex > > >); + + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< double > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< long > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< Complex > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KN< double > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KN< long > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KN< Complex > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KNM< double > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KNM< long > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< KNM< Complex > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< const Mesh * > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< const Mesh3 * > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< const MeshS * > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< const MeshL * > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< Matrice_Creuse< R > > >); + Global.Add("Irecv", "(", new OneBinaryOperator< Op_IRecvmpi< Matrice_Creuse< Complex > > >); + + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< double > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< Complex > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< long > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KN< double > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KN< long > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KN< Complex > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KNM< double > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KNM< long > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< KNM< Complex > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< const Mesh * > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< const Mesh3 * > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< const MeshS * > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< const MeshL * > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< Matrice_Creuse< R > > >); + Global.Add("broadcast", "(", new OneBinaryOperator< Op_Bcastmpi< Matrice_Creuse< Complex > > >); + + Global.Add("mpiAlltoall", "(", new OneBinaryOperator< Op_All2All< long > >); + Global.Add("mpiAlltoall", "(", new OneBinaryOperator< Op_All2All< double > >); + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather< long > >); + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather< double > >); + Global.Add("mpiAlltoall", "(", new OneTernaryOperator3< Op_All2All3< long > >); + Global.Add("mpiAlltoall", "(", new OneTernaryOperator3< Op_All2All3< double > >); + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather3< long > >); + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather3< double > >); + + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather1< long > >); // Add J. Morice + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather1< double > >); // Add J. Morice + + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather13< long > >); // Add J. Morice + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather13< double > >); // Add J. Morice + + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter1< long > >); // Add J. Morice + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter1< double > >); // Add J. Morice + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter3< long > >); + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter3< double > >); + + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather1< long > >); // Add J. Morice + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather1< double > >); // Add J. Morice + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather3< long > >); // correction J. Morice Scatter --> Gather + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather3< double > >); + + // Add J. Morice communication with vector of different size + Global.Add("mpiAlltoallv", "(", new OneOperator6_< long, KN_< double >, KN_< double >, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2Allv< double >)); + Global.Add("mpiAlltoallv", "(", new OneOperator6_< long, KN_< long >, KN_< long >, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2Allv< long >)); + + Global.Add("mpiAlltoallv", "(", new OneOperator7_< long, KN_< long >, KN_< long >, fMPI_Comm, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2All3v< long >)); + Global.Add("mpiAlltoallv", "(", new OneOperator7_< long, KN_< double >, KN_< double >, fMPI_Comm, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2All3v< double >)); + + Global.Add("mpiAllgatherv", "(", new OneQuadOperator< Op_Allgatherv< long >, Quad_Op< Op_Allgatherv< long > > >); + Global.Add("mpiAllgatherv", "(", new OneQuadOperator< Op_Allgatherv< double >, Quad_Op< Op_Allgatherv< double > > >); + Global.Add("mpiAllgatherv", "(", new OneOperator5_< long, KN_< long >, KN_< long >, fMPI_Comm, KN_< long >, KN_< long > >(Op_Allgatherv3< long >)); + Global.Add("mpiAllgatherv", "(", new OneOperator5_< long, KN_< double >, KN_< double >, fMPI_Comm, KN_< long >, KN_< long > >(Op_Allgatherv3< double >)); + + Global.Add("mpiScatterv", "(", new OneOperator5_< long, KN_< long >, KN_< long >, MPIrank, KN_< long >, KN_< long > >(Op_Scatterv3< long >)); + Global.Add("mpiScatterv", "(", new OneOperator5_< long, KN_< double >, KN_< double >, MPIrank, KN_< long >, KN_< long > >(Op_Scatterv3< double >)); + + Global.Add("mpiGatherv", "(", new OneOperator5_< long, KN_< long >, KN_< long >, MPIrank, KN_< long >, KN_< long > >(Op_Gatherv3< long >)); + Global.Add("mpiGatherv", "(", new OneOperator5_< long, KN_< double >, KN_< double >, MPIrank, KN_< long >, KN_< long > >(Op_Gatherv3< double >)); + // Fin Add J. Morice + + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce< double >, Quad_Op< Op_Reduce< double > > >); + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce1< double >, Quad_Op< Op_Reduce1< double > > >); + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce< double >, Quad_Op< Op_AllReduce< double > > >); + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce1< double >, Quad_Op< Op_AllReduce1< double > > >); // add FH jan 2011 + + // Add J. Morice + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce< long >, Quad_Op< Op_Reduce< long > > >); + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce1< long >, Quad_Op< Op_Reduce1< long > > >); + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce< long >, Quad_Op< Op_AllReduce< long > > >); + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce1< long >, Quad_Op< Op_AllReduce1< long > > >); // add FH jan 2011 + // Global.Add("mpiReduceScatter","(",new OneQuadOperator, Quad_Op > >); + // fin Add J. Morice + + // Add J. Morice :: complex communication between processor + Global.Add("mpiAlltoall", "(", new OneBinaryOperator< Op_All2All< Complex > >); + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather< Complex > >); + Global.Add("mpiAlltoall", "(", new OneTernaryOperator3< Op_All2All3< Complex > >); + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather3< Complex > >); + + Global.Add("mpiAllgather", "(", new OneBinaryOperator< Op_Allgather1< Complex > >); + Global.Add("mpiAllgather", "(", new OneTernaryOperator3< Op_Allgather13< Complex > >); + + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter3< Complex > >); + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather3< Complex > >); + + Global.Add("mpiScatter", "(", new OneTernaryOperator3< Op_Scatter1< Complex > >); + Global.Add("mpiGather", "(", new OneTernaryOperator3< Op_Gather1< Complex > >); + + // Add J. Morice communication with vector of different size + Global.Add("mpiAlltoallv", "(", new OneOperator6_< long, KN_< Complex >, KN_< Complex >, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2Allv< Complex >)); + Global.Add("mpiAlltoallv", "(", new OneOperator7_< long, KN_< Complex >, KN_< Complex >, fMPI_Comm, KN_< long >, KN_< long >, KN_< long >, KN_< long > >(Op_All2All3v< Complex >)); + Global.Add("mpiAllgatherv", "(", new OneQuadOperator< Op_Allgatherv< Complex >, Quad_Op< Op_Allgatherv< Complex > > >); + + Global.Add("mpiAllgatherv", "(", new OneOperator5_< long, KN_< Complex >, KN_< Complex >, fMPI_Comm, KN_< long >, KN_< long > >(Op_Allgatherv3< Complex >)); + Global.Add("mpiScatterv", "(", new OneOperator5_< long, KN_< Complex >, KN_< Complex >, MPIrank, KN_< long >, KN_< long > >(Op_Scatterv3< Complex >)); + Global.Add("mpiGatherv", "(", new OneOperator5_< long, KN_< Complex >, KN_< Complex >, MPIrank, KN_< long >, KN_< long > >(Op_Gatherv3< Complex >)); + + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_ReduceMat< Complex >, Quad_Op< Op_ReduceMat< Complex > > >); // add FH april 2011 + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_ReduceMat< double >, Quad_Op< Op_ReduceMat< double > > >); // add FH april 2011 + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduceMat< Complex >, Quad_Op< Op_AllReduceMat< Complex > > >); // add FH april 2011 + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduceMat< double >, Quad_Op< Op_AllReduceMat< double > > >); // add FH april 2011 + + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce< Complex >, Quad_Op< Op_Reduce< Complex > > >); + Global.Add("mpiReduce", "(", new OneQuadOperator< Op_Reduce1< Complex >, Quad_Op< Op_Reduce1< Complex > > >); + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce< Complex >, Quad_Op< Op_AllReduce< Complex > > >); #ifdef HAVE_MPI_DOUBLE_COMPLEX - Global.Add("mpiAllReduce","(",new OneQuadOperator, Quad_Op > >);// add FH jan 2011 + Global.Add("mpiAllReduce", "(", new OneQuadOperator< Op_AllReduce1< Complex >, Quad_Op< Op_AllReduce1< Complex > > >); // add FH jan 2011 #endif - // Fin Add J. Morice :: complex communication between processor - - Global.New("mpirank",CConstant(mpirank)); - Global.New("mpisize",CConstant(mpisize)); - static long mpiUndefined=MPI_UNDEFINED, mpiAnySource = MPI_ANY_SOURCE,mpiAnyTag=MPI_ANY_TAG ; - static fMPI_Comm fmpiWorld=MPI_COMM_WORLD; - static fMPI_Comm fmpiSelf=MPI_COMM_SELF; - - Global.New("mpiUndefined",CConstant(mpiUndefined)); - Global.New("mpiAnySource",CConstant(mpiAnySource)); - Global.New("mpiAnyTag",CConstant(mpiAnyTag)); - - - - Global.New("mpiCommWorld",CConstant(&fmpiWorld)); - Global.New("mpiCommSelf",CConstant(&fmpiSelf)); - // add FH - - - Global.Add("mpiWtime","(",new OneOperator0(ffMPI_Wtime)); - Global.Add("mpiWtick","(",new OneOperator0(ffMPI_Wtick)); - Global.Add("processor","(",new OneOperator3_(mpiwho_)); - Global.Add("processor","(",new OneOperator2_(mpiwho_)); - Global.Add("mpiWait","(",new OneOperator1(mpiWait)); - Global.Add("mpiWaitAny","(",new OneOperator1*>(mpiWaitAny)); - Global.Add("mpiWaitAll","(",new OneOperator1*>(mpiWaitAll)); - Global.Add("mpiSize","(",new OneOperator1(mpiSize)); - Global.Add("mpiRank","(",new OneOperator1(mpiRank)); - Global.Add("mpiBarrier","(",new OneOperator1(mpiBarrier)); - - static fMPI_Op op_max(MPI_MAX); - static fMPI_Op op_min(MPI_MIN); - static fMPI_Op op_sum(MPI_SUM); - static fMPI_Op op_prod(MPI_PROD); - static fMPI_Op op_land(MPI_LAND); - - static fMPI_Op op_lor(MPI_LOR); - static fMPI_Op op_lxor(MPI_LXOR); - static fMPI_Op op_band(MPI_BAND); - static fMPI_Op op_bor(MPI_BOR); - static fMPI_Op op_bxor(MPI_BXOR); - static fMPI_Op op_maxloc(MPI_MAXLOC); - static fMPI_Op op_minloc(MPI_MINLOC); - - Global.New("mpiMAX",CConstant(op_max)); - Global.New("mpiMIN",CConstant(op_min)); - Global.New("mpiSUM",CConstant(op_sum)); - Global.New("mpiPROD",CConstant(op_prod)); - Global.New("mpiLAND",CConstant(op_land)); - - Global.New("mpiLOR",CConstant(op_lor)); - Global.New("mpiLXOR",CConstant(op_lxor)); - Global.New("mpiBAND",CConstant(op_band)); - Global.New("mpiBXOR",CConstant(op_bxor)); - // sur des pair bof bof ... - Global.New("mpiMAXLOC",CConstant(op_maxloc)); - Global.New("mpiMINLOC",CConstant(op_minloc)); - - - TheOperators->Add("<-", - new OneOperator2_ *,KN *,long>(&set_init0) - ); - atype* >()->Add("[","",new OneOperator2_*,long >(get_elementp_)); - - Global.Add("splitComm", "(", new splitComm); - - } - + // Fin Add J. Morice :: complex communication between processor + + Global.New("mpirank", CConstant< long >(mpirank)); + Global.New("mpisize", CConstant< long >(mpisize)); + static long mpiUndefined = MPI_UNDEFINED, mpiAnySource = MPI_ANY_SOURCE, mpiAnyTag = MPI_ANY_TAG; + static fMPI_Comm fmpiWorld = MPI_COMM_WORLD; + static fMPI_Comm fmpiSelf = MPI_COMM_SELF; + + Global.New("mpiUndefined", CConstant< long >(mpiUndefined)); + Global.New("mpiAnySource", CConstant< long >(mpiAnySource)); + Global.New("mpiAnyTag", CConstant< long >(mpiAnyTag)); + + Global.New("mpiCommWorld", CConstant< fMPI_Comm * >(&fmpiWorld)); + Global.New("mpiCommSelf", CConstant< fMPI_Comm * >(&fmpiSelf)); + // add FH + + Global.Add("mpiWtime", "(", new OneOperator0< double >(ffMPI_Wtime)); + Global.Add("mpiWtick", "(", new OneOperator0< double >(ffMPI_Wtick)); + Global.Add("processor", "(", new OneOperator3_< MPIrank, long, fMPI_Comm, fMPI_Request * >(mpiwho_)); + Global.Add("processor", "(", new OneOperator2_< MPIrank, long, fMPI_Request * >(mpiwho_)); + Global.Add("mpiWait", "(", new OneOperator1< long, fMPI_Request * >(mpiWait)); + Global.Add("mpiWaitAny", "(", new OneOperator1< long, KN< MPI_Request > * >(mpiWaitAny)); + Global.Add("mpiWaitAll", "(", new OneOperator1< long, KN< MPI_Request > * >(mpiWaitAll)); + Global.Add("mpiSize", "(", new OneOperator1< long, fMPI_Comm >(mpiSize)); + Global.Add("mpiRank", "(", new OneOperator1< long, fMPI_Comm >(mpiRank)); + Global.Add("mpiBarrier", "(", new OneOperator1< long, fMPI_Comm * >(mpiBarrier)); + + static fMPI_Op op_max(MPI_MAX); + static fMPI_Op op_min(MPI_MIN); + static fMPI_Op op_sum(MPI_SUM); + static fMPI_Op op_prod(MPI_PROD); + static fMPI_Op op_land(MPI_LAND); + + static fMPI_Op op_lor(MPI_LOR); + static fMPI_Op op_lxor(MPI_LXOR); + static fMPI_Op op_band(MPI_BAND); + static fMPI_Op op_bor(MPI_BOR); + static fMPI_Op op_bxor(MPI_BXOR); + static fMPI_Op op_maxloc(MPI_MAXLOC); + static fMPI_Op op_minloc(MPI_MINLOC); + + Global.New("mpiMAX", CConstant< fMPI_Op >(op_max)); + Global.New("mpiMIN", CConstant< fMPI_Op >(op_min)); + Global.New("mpiSUM", CConstant< fMPI_Op >(op_sum)); + Global.New("mpiPROD", CConstant< fMPI_Op >(op_prod)); + Global.New("mpiLAND", CConstant< fMPI_Op >(op_land)); + + Global.New("mpiLOR", CConstant< fMPI_Op >(op_lor)); + Global.New("mpiLXOR", CConstant< fMPI_Op >(op_lxor)); + Global.New("mpiBAND", CConstant< fMPI_Op >(op_band)); + Global.New("mpiBXOR", CConstant< fMPI_Op >(op_bxor)); + // sur des pair bof bof ... + Global.New("mpiMAXLOC", CConstant< fMPI_Op >(op_maxloc)); + Global.New("mpiMINLOC", CConstant< fMPI_Op >(op_minloc)); + + TheOperators->Add("<-", new OneOperator2_< KN< MPI_Request > *, KN< MPI_Request > *, long >(&set_init0)); + atype< KN< MPI_Request > * >( )->Add("[", "", new OneOperator2_< fMPI_Request *, KN< MPI_Request > *, long >(get_elementp_)); + + Global.Add("splitComm", "(", new splitComm); +} // set the 3 ptr -extern void (*initparallele)(int &argc, char **& argv) ; -extern void (*init_lgparallele)(); - +extern void (*initparallele)(int &argc, char **&argv); +extern void (*init_lgparallele)( ); -void init_ptr_parallelepmi(); -void init_ptr_parallelepmi(){ -initparallele=&f_initparallele ; -init_lgparallele=&f_init_lgparallele; +void init_ptr_parallelepmi( ); +void init_ptr_parallelepmi( ) { + initparallele = &f_initparallele; + init_lgparallele = &f_init_lgparallele; };